Implemented the o2_setCharacterAnimFrame opcode and made sure o2_delay does game updates during the delay

svn-id: r29208
This commit is contained in:
Oystein Eftevaag 2007-10-13 18:47:52 +00:00
parent 3f7b4e62cc
commit 4f93e96d5f
3 changed files with 36 additions and 2 deletions

View File

@ -671,6 +671,24 @@ void KyraEngine_v2::removeInputTop() {
_eventList.erase(_eventList.begin());
}
void KyraEngine_v2::delay(uint32 amount, bool updateGame, bool isMainLoop) {
uint32 start = _system->getMillis();
do {
if (updateGame) {
if (_chatText)
updateWithText();
else
update();
}
if (amount > 0 )
_system->delayMillis(amount > 10 ? 10 : amount);
} while (!_skipFlag && _system->getMillis() < start + amount && !_quitFlag);
}
void KyraEngine_v2::cleanup() {
delete [] _gamePlayBuffer;
delete [] _unkBuf500Bytes;
@ -1460,7 +1478,7 @@ void KyraEngine_v2::setupOpcodeTable() {
Opcode(o2_setSceneComment),
OpcodeUnImpl(),
OpcodeUnImpl(),
OpcodeUnImpl(),
Opcode(o2_setCharacterAnimFrame),
// 0x0c
OpcodeUnImpl(),
Opcode(o2_trySceneChange),

View File

@ -540,6 +540,9 @@ protected:
void setTimer1DelaySecs(int secs);
// delay
void delay(uint32 millis, bool updateGame = false, bool isMainLoop = false);
// opcodes
int o2_setCharacterFacingRefresh(ScriptState *script);
int o2_defineObject(ScriptState *script);
@ -548,6 +551,7 @@ protected:
int o2_getCharacterY(ScriptState *script);
int o2_getCharacterFacing(ScriptState *script);
int o2_setSceneComment(ScriptState *script);
int o2_setCharacterAnimFrame(ScriptState *script);
int o2_trySceneChange(ScriptState *script);
int o2_showChapterMessage(ScriptState *script);
int o2_wsaClose(ScriptState *script);

View File

@ -90,6 +90,18 @@ int KyraEngine_v2::o2_setSceneComment(ScriptState *script) {
return 0;
}
int KyraEngine_v2::o2_setCharacterAnimFrame(ScriptState *script) {
debugC(3, kDebugLevelScriptFuncs, "o2_setCharacterAnimFrame(%p) (-, %d, %d)", (const void *)script, stackPos(1), stackPos(2));
int animFrame = stackPos(1);
int skipRefresh = stackPos(2);
_mainCharacter.animFrame = animFrame;
if (skipRefresh)
updateCharacterAnim(0);
return 0;
}
int KyraEngine_v2::o2_trySceneChange(ScriptState *script) {
debugC(3, kDebugLevelScriptFuncs, "o2_trySceneChange(%p) (%d, %d, %d, %d)", (const void *)script,
stackPos(0), stackPos(1), stackPos(2), stackPos(3));
@ -292,7 +304,7 @@ int KyraEngine_v2::o2_delay(ScriptState *script) {
//if (stackPos(1))
// sub_27100(stackPos(0) * _tickLength);
//else
delay(stackPos(0) * _tickLength);
delay(stackPos(0) * _tickLength, true);
return 0;
}