aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilippos Karapetis2009-05-21 10:34:13 +0000
committerFilippos Karapetis2009-05-21 10:34:13 +0000
commitfddd2a2214ae8d05fb8dc48cd8515427795d44c8 (patch)
tree5229278716093774d198ceba0161d95a215cf2f7
parent234828825afe62b26f9133ad8eee02e52c63e44f (diff)
downloadscummvm-rg350-fddd2a2214ae8d05fb8dc48cd8515427795d44c8.tar.gz
scummvm-rg350-fddd2a2214ae8d05fb8dc48cd8515427795d44c8.tar.bz2
scummvm-rg350-fddd2a2214ae8d05fb8dc48cd8515427795d44c8.zip
Slight cleanup to kGetTime()
svn-id: r40754
-rw-r--r--engines/sci/engine/kmisc.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/engines/sci/engine/kmisc.cpp b/engines/sci/engine/kmisc.cpp
index 396fba72e2..2d1180b827 100644
--- a/engines/sci/engine/kmisc.cpp
+++ b/engines/sci/engine/kmisc.cpp
@@ -132,13 +132,13 @@ reg_t kGetTime(EngineState *s, int funct_nr, int argc, reg_t *argv) {
g_system->getTimeAndDate(loc_time);
start_time = g_system->getMillis() - s->game_start_time;
- if (argc && s->flags & GF_SCI0_OLDGETTIME) { // Use old semantics
- retval = loc_time.tm_sec + loc_time.tm_min * 60 + (loc_time.tm_hour % 12) * 3600;
+ if ((s->flags & GF_SCI0_OLDGETTIME) && argc) { // Use old semantics
+ retval = (loc_time.tm_hour % 12) * 3600 + loc_time.tm_min * 60 + loc_time.tm_sec;
debugC(2, kDebugLevelTime, "GetTime(timeofday) returns %d", retval);
return make_reg(0, retval);
}
- int mode = UKPV_OR_ALT(0, 0);
+ int mode = argc > 0 ? UKPV_OR_ALT(0, 0) : 0;
switch (mode) {
case _K_NEW_GETTIME_TICKS :
@@ -146,16 +146,15 @@ reg_t kGetTime(EngineState *s, int funct_nr, int argc, reg_t *argv) {
debugC(2, kDebugLevelTime, "GetTime(elapsed) returns %d", retval);
break;
case _K_NEW_GETTIME_TIME_12HOUR :
- loc_time.tm_hour %= 12;
- retval = (loc_time.tm_min << 6) | (loc_time.tm_hour << 12) | (loc_time.tm_sec);
+ retval = ((loc_time.tm_hour % 12) << 12) | (loc_time.tm_min << 6) | (loc_time.tm_sec);
debugC(2, kDebugLevelTime, "GetTime(12h) returns %d", retval);
break;
case _K_NEW_GETTIME_TIME_24HOUR :
- retval = (loc_time.tm_min << 5) | (loc_time.tm_sec >> 1) | (loc_time.tm_hour << 11);
+ retval = (loc_time.tm_hour << 11) | (loc_time.tm_min << 5) | (loc_time.tm_sec >> 1);
debugC(2, kDebugLevelTime, "GetTime(24h) returns %d", retval);
break;
case _K_NEW_GETTIME_DATE :
- retval = ((loc_time.tm_mon + 1) << 5) | loc_time.tm_mday | (((loc_time.tm_year + 1900) & 0x7f) << 9);
+ retval = loc_time.tm_mday | ((loc_time.tm_mon + 1) << 5) | (((loc_time.tm_year + 1900) & 0x7f) << 9);
debugC(2, kDebugLevelTime, "GetTime(date) returns %d", retval);
break;
default: