diff options
-rw-r--r-- | engines/touche/opcodes.cpp | 22 | ||||
-rw-r--r-- | engines/touche/resource.cpp | 4 | ||||
-rw-r--r-- | engines/touche/touche.cpp | 48 | ||||
-rw-r--r-- | engines/touche/touche.h | 13 |
4 files changed, 43 insertions, 44 deletions
diff --git a/engines/touche/opcodes.cpp b/engines/touche/opcodes.cpp index 65124449aa..04fe0cabda 100644 --- a/engines/touche/opcodes.cpp +++ b/engines/touche/opcodes.cpp @@ -175,7 +175,7 @@ void ToucheEngine::setupOpcodes() { &ToucheEngine::op_sleep, 0, /* 0x74 */ - &ToucheEngine::op_delay, + &ToucheEngine::op_setKeyCharDelay, &ToucheEngine::op_lockHitBox, &ToucheEngine::op_removeItemFromInventory, &ToucheEngine::op_unlockHitBox, @@ -192,7 +192,7 @@ void ToucheEngine::setupOpcodes() { /* 0x80 */ &ToucheEngine::op_unsetKeyCharFlags, &ToucheEngine::op_drawSpriteOnBackdrop, - &ToucheEngine::op_loadVoice, + &ToucheEngine::op_loadSpeechSegment, 0, /* 0x84 */ &ToucheEngine::op_startPaletteFadeIn, @@ -868,12 +868,18 @@ void ToucheEngine::op_startMusic() { void ToucheEngine::op_sleep() { debugC(9, kDebugOpcodes, "ToucheEngine::op_sleep()"); - int16 cycles = _script.readNextWord(); - _sleepCycles = cycles * 2; + // this should probably be turned into a no-op/debug-op... + int cycles = _script.readNextWord() * 2; + if (!_fastMode) { + for (; cycles > 0; --cycles) { + _system->delayMillis(kCycleDelay); + _system->updateScreen(); + } + } } -void ToucheEngine::op_delay() { - debugC(9, kDebugOpcodes, "ToucheEngine::op_delay()"); +void ToucheEngine::op_setKeyCharDelay() { + debugC(9, kDebugOpcodes, "ToucheEngine::op_setKeyCharDelay()"); int16 delay = _script.readNextWord(); _keyCharsTable[_script.keyCharNum].delay = delay; _script.quitFlag = 3; @@ -927,8 +933,8 @@ void ToucheEngine::op_unsetKeyCharFlags() { _keyCharsTable[keyChar].flags &= ~flags; } -void ToucheEngine::op_loadVoice() { - debugC(9, kDebugOpcodes, "ToucheEngine::op_loadVoice()"); +void ToucheEngine::op_loadSpeechSegment() { + debugC(9, kDebugOpcodes, "ToucheEngine::op_loadSpeechSegment()"); int16 num = _script.readNextWord(); res_loadSpeech(num); } diff --git a/engines/touche/resource.cpp b/engines/touche/resource.cpp index 12ab6f72a1..f047cd8bd7 100644 --- a/engines/touche/resource.cpp +++ b/engines/touche/resource.cpp @@ -120,12 +120,12 @@ void ToucheEngine::res_allocateTables() { error("Unable to allocate memory for program data"); } - _mouseData = (uint8 *)malloc(58 * 42); + _mouseData = (uint8 *)malloc(kCursorWidth * kCursorHeight); if (!_mouseData) { error("Unable to allocate memory for mouse data"); } - _iconData = (uint8 *)malloc(58 * 42); + _iconData = (uint8 *)malloc(kIconWidth * kIconHeight); if (!_iconData) { error("Unable to allocate memory for object data"); } diff --git a/engines/touche/touche.cpp b/engines/touche/touche.cpp index 31e28bf1d1..c7df692da8 100644 --- a/engines/touche/touche.cpp +++ b/engines/touche/touche.cpp @@ -245,25 +245,18 @@ void ToucheEngine::mainLoop() { _inp_rightMouseButtonPressed = false; showCursor(_newEpisodeNum != kStartupEpisode); - const int cycleDelay = 1000 / (1193180 / 32768); uint32 frameTimeStamp = _system->getMillis(); - _sleepCycles = 0; - uint32 cycleCounter = 0; - while (_flagsTable[611] == 0) { - if (_sleepCycles) { - --_sleepCycles; - } else { - if ((cycleCounter % 3) == 0) { - runCycle(); - } - if ((cycleCounter % 2) == 0) { - fadePaletteFromFlags(); - } - ++cycleCounter; - } + for (uint32 cycleCounter = 0; _flagsTable[611] == 0; ++cycleCounter) { + if ((cycleCounter % 3) == 0) { + runCycle(); + } + if ((cycleCounter % 2) == 0) { + fadePaletteFromFlags(); + } + _system->updateScreen(); int delay = _system->getMillis() - frameTimeStamp; - delay = (_fastMode ? 10 : cycleDelay) - delay; + delay = (_fastMode ? 10 : kCycleDelay) - delay; if (delay < 1) { delay = 1; } @@ -787,8 +780,8 @@ bool ToucheEngine::scrollRoom(int keyChar) { // horizontal scrolling int prevRoomDx = _flagsTable[614]; - if (key->xPos > prevRoomDx + 480) { - int dx = key->xPos - (prevRoomDx + 480); + if (key->xPos > prevRoomDx + kScreenWidth - 160) { + int dx = key->xPos - (prevRoomDx + kScreenWidth - 160); prevRoomDx += dx; } else if (key->xPos < prevRoomDx + 160) { int dx = prevRoomDx + 160 - key->xPos; @@ -822,8 +815,8 @@ bool ToucheEngine::scrollRoom(int keyChar) { void ToucheEngine::drawIcon(int x, int y, int num) { res_loadImage(num, _iconData); Graphics::copyRect(_offscreenBuffer, kScreenWidth, x, y, - _iconData, 58, 0, 0, - 58, 42, + _iconData, kIconWidth, 0, 0, + kIconWidth, kIconHeight, Graphics::kTransparent); } @@ -1394,10 +1387,8 @@ void ToucheEngine::showCursor(bool show) { void ToucheEngine::setCursor(int num) { debugC(9, kDebugEngine, "ToucheEngine::setCursor(%d)", num); _currentCursorObject = num; - const int cursorW = 58; - const int cursorH = 42; res_loadImage(num, _mouseData); - _system->setMouseCursor(_mouseData, cursorW, cursorH, cursorW / 2, cursorH / 2, 0); + _system->setMouseCursor(_mouseData, kCursorWidth, kCursorHeight, kCursorWidth / 2, kCursorHeight / 2, 0); } void ToucheEngine::setDefaultCursor(int num) { @@ -1745,7 +1736,6 @@ void ToucheEngine::clearRoomArea() { } void ToucheEngine::startNewMusic() { -// _midiPlayer->setLooping(_flagsTable[619] != 0); if (_newMusicNum != 0 && _newMusicNum != _currentMusicNum) { res_loadMusic(_newMusicNum); _currentMusicNum = _newMusicNum; @@ -2425,7 +2415,7 @@ void ToucheEngine::drawCharacterConversation() { for (int i = 0; i < 4; ++i) { drawString(214, 42, 328 + i * 16, _conversationChoicesTable[_scrollConversationChoiceOffset + i].msg); } - updateScreenArea(0, 320, kScreenWidth, 80); + updateScreenArea(0, 320, kScreenWidth, kScreenHeight - 320); _conversationAreaCleared = false; } @@ -3111,12 +3101,12 @@ void ToucheEngine::copyAnimationImage(int dstX, int dstY, int w, int h, const ui if (copyRegion.clip(_screenRect)) { if (fillColor != -1) { Graphics::copyMask(_offscreenBuffer, kScreenWidth, copyRegion.r.left, copyRegion.r.top, - src, 58, copyRegion.srcX, copyRegion.srcY, + src, kIconWidth, copyRegion.srcX, copyRegion.srcY, copyRegion.r.width(), copyRegion.r.height(), (uint8)fillColor); } else { Graphics::copyRect(_offscreenBuffer, kScreenWidth, copyRegion.r.left, copyRegion.r.top, - src, 58, copyRegion.srcX, copyRegion.srcY, + src, kIconWidth, copyRegion.srcX, copyRegion.srcY, copyRegion.r.width(), copyRegion.r.height(), Graphics::kTransparent); } @@ -3151,7 +3141,7 @@ void ToucheEngine::drawAnimationImage(AnimationEntry *anim) { if (i == 5) { color = -1; } - copyAnimationImage(x, y, 58, 42, _iconData, 0, 0, color); + copyAnimationImage(x, y, kIconWidth, kIconHeight, _iconData, 0, 0, color); --color; displayRectX1 = MIN(x, displayRectX1); displayRectX2 = MAX(x, displayRectX2); @@ -3160,7 +3150,7 @@ void ToucheEngine::drawAnimationImage(AnimationEntry *anim) { x += dx; y += dy; } - anim->displayRect = Common::Rect(displayRectX1, displayRectY1, displayRectX2 + 58, displayRectY2 + 42); + anim->displayRect = Common::Rect(displayRectX1, displayRectY1, displayRectX2 + kIconWidth, displayRectY2 + kIconHeight); addToDirtyRect(anim->displayRect); } diff --git a/engines/touche/touche.h b/engines/touche/touche.h index 7199cfaab5..e36b455a40 100644 --- a/engines/touche/touche.h +++ b/engines/touche/touche.h @@ -317,7 +317,12 @@ enum { kScreenWidth = 640, kScreenHeight = 400, kRoomHeight = 352, - kStartupEpisode = 90 + kStartupEpisode = 90, + kCycleDelay = 1000 / (1193180 / 32768), + kIconWidth = 58, + kIconHeight = 42, + kCursorWidth = 58, + kCursorHeight = 42 }; class MidiPlayer; @@ -555,14 +560,14 @@ protected: void op_setKeyCharTextColor(); void op_startMusic(); void op_sleep(); - void op_delay(); + void op_setKeyCharDelay(); void op_lockHitBox(); void op_removeItemFromInventory(); void op_unlockHitBox(); void op_addRoomArea(); void op_setKeyCharFlags(); void op_unsetKeyCharFlags(); - void op_loadVoice(); + void op_loadSpeechSegment(); void op_drawSpriteOnBackdrop(); void op_startPaletteFadeIn(); void op_startPaletteFadeOut(); @@ -614,8 +619,6 @@ protected: int _disabledInputCounter; bool _hideInventoryTexts; - int _sleepCycles; - bool _displayQuitDialog; int _saveLoadCurrentPage; int _saveLoadCurrentSlot; |