Skip to content

Commit

Permalink
MACVENTURE: Make opcode $ca return current time, not played time
Browse files Browse the repository at this point in the history
This is used by some games to determine the appropriate greeting,
e.g. "Good evening" if you play the game in the evening.
  • Loading branch information
Torbjörn Andersson committed Sep 5, 2016
1 parent 89dd40c commit c4368a7
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions engines/macventure/script.cpp
Expand Up @@ -1044,19 +1044,20 @@ void ScriptEngine::opc9WAIT(EngineState *state, EngineFrame *frame) {
}

void ScriptEngine::opcaTIME(EngineState *state, EngineFrame *frame) {
for (uint i = 0; i < 3; i++) {// We skip year, month and date
state->push(0x00);
}
TimeDate t;
g_system->getTimeAndDate(t);

int year = 1900 + t.tm_year;
int month = 1 + t.tm_mon;

state->push(year);
state->push(month);
state->push(t.tm_mday);
state->push(t.tm_hour);
state->push(t.tm_min);
state->push(t.tm_sec);

uint32 totalPlayTime = _engine->getTotalPlayTime() / 1000; // In seconds
int16 hours = totalPlayTime / 3600;
totalPlayTime %= 3600;
state->push(hours);
int16 minutes = totalPlayTime / 60;
totalPlayTime %= 60;
state->push(minutes);
state->push(totalPlayTime);
debugC(2, kMVDebugScript, "Saved time: h[%d] m[%d] s[%d]", hours, minutes, totalPlayTime);
debugC(2, kMVDebugScript, "Saved time: Y[%d] M[%d] D[%d] h[%d] m[%d] s[%d]", year, month, t.tm_mday, t.tm_hour, t.tm_min, t.tm_sec);
}

void ScriptEngine::opcbDAY(EngineState *state, EngineFrame *frame) {
Expand Down

0 comments on commit c4368a7

Please sign in to comment.