Skip to content

Commit

Permalink
Various small fixes, nothing really important (#125)
Browse files Browse the repository at this point in the history
- Tech info: were missing the $ prefix
- Tech info: replace 315-5226 with 315-5246
- Show local time instead of UTC time on main window lower right corner
  • Loading branch information
sverx committed May 13, 2024
1 parent ff7a7d3 commit 2daf9c2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 63 deletions.
2 changes: 1 addition & 1 deletion meka/srcs/app_techinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ void TechInfo_Update(void)
switch (g_machine.VDP.model)
{
case VDP_MODEL_315_5124: sprintf(model_str, "315-5124"); break;
case VDP_MODEL_315_5226: sprintf(model_str, "315-5226"); break;
case VDP_MODEL_315_5226: sprintf(model_str, "315-5246"); break;
case VDP_MODEL_315_5378: sprintf(model_str, "315-5378"); break;
case VDP_MODEL_315_5313: sprintf(model_str, "315-5313"); break;
default: assert(0); break;
Expand Down
67 changes: 5 additions & 62 deletions meka/srcs/tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ void StrPath_RemoveExtension(char* buf)
{
// Assume single dotted extension
char *p = strrchr(buf, '.');
if (p != NULL)
if (p != NULL)
*p = EOSTR;
}

void StrPath_GetExtension(char* buf)
{
const char *p = strrchr (buf, '.');
if (p == NULL)
if (p == NULL)
return;

char tmp[FILENAME_LEN];
Expand Down Expand Up @@ -78,63 +78,6 @@ void StrPath_RemoveDirectory(char *dst, const char *src)
// Time Functions
//-----------------------------------------------------------------------------

// nb- not const because we overwrite the month of February
static int month_len_table[12] =
{ 31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

// return number of days in February for given year
#ifndef ARCH_WIN32
static int get_february_len (int year)
{
if ((year % 4) != 0 || (((year % 100) == 0) && ((year % 400) == 0)))
return (28);
return (29);
}

// FIXME: do we really have to code this manually in 2005^h^h^h^h2012? seems insane (disclaimer: this is 1998 ms-dos code)
// ctime() anymore? (or similar function?)
static void meka_get_time_date (int *phour, int *pminute, int *psecond, int *pday, int *pmonth, int *pyear, int *pday_of_week)
{
time_t t;
int cnt;
int day, month, year, day_of_week;

t = time(&t);

cnt = (int)(t % (24 * 60 * 60));
if (phour) *phour = cnt / (60 * 60);
cnt %= (60 * 60);
if (pminute) *pminute = cnt / (60);
cnt %= 60;
if (psecond) *psecond = cnt;

cnt = (int)(t / (24 * 60 * 60));
day = 0; // First
month = 0; // January
year = 1970; // 1970
day_of_week = 3; // it was a Wednesday!
month_len_table[1] = get_february_len(year);
while (cnt--)
{
day_of_week = (day_of_week + 1) % 7;
if (++day == month_len_table[month])
{
day = 0;
if (++month == 12)
{
month = 0;
year += 1;
month_len_table[1] = get_february_len(year);
}
}
}
if (pday) *pday = day;
if (pmonth) *pmonth = month + 1;
if (pyear) *pyear = year;
if (pday_of_week) *pday_of_week = day_of_week;
}
#endif

char * meka_date_getf (void)
{
time_t t;
Expand All @@ -149,9 +92,9 @@ char * meka_time_getf (char *str)
GetLocalTime (&t);
sprintf(str, "%02i:%02i:%02i", t.wHour, t.wMinute, t.wSecond);
#else
int hour, minute, second;
meka_get_time_date(&hour, &minute, &second, 0, 0, 0, 0);
sprintf(str, "%02i:%02i:%02i", hour, minute, second);
time_t t = time(NULL);
struct tm tm = *localtime(&t);
sprintf(str, "%02i:%02i:%02i", tm.tm_hour, tm.tm_min, tm.tm_sec);
#endif
return (str);
}
Expand Down

0 comments on commit 2daf9c2

Please sign in to comment.