diff options
author | Johannes Schickel | 2005-12-09 14:52:31 +0000 |
---|---|---|
committer | Johannes Schickel | 2005-12-09 14:52:31 +0000 |
commit | 1fc81a08fa6eab8d29b8e0d443501727b1c6c224 (patch) | |
tree | 1b6a29fd64f5b61fb2af1f0f55d4169462d9a615 /kyra | |
parent | 4f1c89591eb4abde1f535e7edde0839da16749f5 (diff) | |
download | scummvm-rg350-1fc81a08fa6eab8d29b8e0d443501727b1c6c224.tar.gz scummvm-rg350-1fc81a08fa6eab8d29b8e0d443501727b1c6c224.tar.bz2 scummvm-rg350-1fc81a08fa6eab8d29b8e0d443501727b1c6c224.zip |
Commited patch # 1376551 (debug console, text fade, misc). Thanks to vinterstum.
svn-id: r19763
Diffstat (limited to 'kyra')
-rw-r--r-- | kyra/debugger.cpp | 179 | ||||
-rw-r--r-- | kyra/debugger.h | 55 | ||||
-rw-r--r-- | kyra/kyra.cpp | 191 | ||||
-rw-r--r-- | kyra/kyra.h | 23 | ||||
-rw-r--r-- | kyra/module.mk | 3 | ||||
-rw-r--r-- | kyra/script_v1.cpp | 41 | ||||
-rw-r--r-- | kyra/sprites.cpp | 6 | ||||
-rw-r--r-- | kyra/staticres.cpp | 2 |
8 files changed, 399 insertions, 101 deletions
diff --git a/kyra/debugger.cpp b/kyra/debugger.cpp new file mode 100644 index 0000000000..989f7f1eba --- /dev/null +++ b/kyra/debugger.cpp @@ -0,0 +1,179 @@ +/* ScummVM - Scumm Interpreter + * Copyright (C) 2003-2005 The ScummVM project + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $Header$ + * + */ + +#include "common/stdafx.h" +#include "common/config-manager.h" +#include "common/debugger.cpp" +#include "kyra/debugger.h" +#include "kyra/kyra.h" +#include "kyra/screen.h" + +namespace Kyra { + +Debugger::Debugger(KyraEngine *vm) + : Common::Debugger<Debugger>() { + _vm = vm; + + DCmd_Register("continue", &Debugger::cmd_exit); + DCmd_Register("exit", &Debugger::cmd_exit); + DCmd_Register("help", &Debugger::cmd_help); + DCmd_Register("quit", &Debugger::cmd_exit); + DCmd_Register("enter", &Debugger::cmd_enterRoom); + DCmd_Register("rooms", &Debugger::cmd_listRooms); + DCmd_Register("flags", &Debugger::cmd_listFlags); + DCmd_Register("toggleflag", &Debugger::cmd_toggleFlag); + DCmd_Register("queryflag", &Debugger::cmd_queryFlag); + DCmd_Register("timers", &Debugger::cmd_listTimers); + DCmd_Register("settimercountdown", &Debugger::cmd_setTimerCountdown); +} + +void Debugger::preEnter() { + //_vm->midi.pause(1); +} + +void Debugger::postEnter() { + //_vm->midi.pause(0); +} + +bool Debugger::cmd_enterRoom(int argc, const char **argv) { + uint direction = 0; + if (argc > 1) { + uint room = atoi(argv[1]); + + if (argc > 2) + direction = atoi(argv[2]); + else { + if (_vm->_roomTable[room].northExit != 0xff) + direction = 3; + else if (_vm->_roomTable[room].eastExit != 0xff) + direction = 4; + else if (_vm->_roomTable[room].southExit != 0xff) + direction = 1; + else if (_vm->_roomTable[room].westExit != 0xff) + direction = 2; + } + + // Dirty way of hiding the debug console while the room entry scripts are running, + // otherwise the graphics didn't update. + _vm->_system->hideOverlay(); + _vm->_currentCharacter->facing = direction; + + _vm->enterNewScene(room, _vm->_currentCharacter->facing, 0, 0, 1); + _vm->_system->showOverlay(); + _detach_now = true; + return false; + } + + DebugPrintf("Syntax: room <roomnum> <direction>\n"); + return true; +} + +bool Debugger::cmd_exit(int argc, const char **argv) { + _detach_now = true; + return false; +} + +bool Debugger::cmd_help(int argc, const char **argv) { + // console normally has 39 line width + // wrap around nicely + int width = 0, size, i; + + DebugPrintf("Commands are:\n"); + for (i = 0 ; i < _dcmd_count ; i++) { + size = strlen(_dcmds[i].name) + 1; + + if ((width + size) >= 39) { + DebugPrintf("\n"); + width = size; + } else + width += size; + + DebugPrintf("%s ", _dcmds[i].name); + } + DebugPrintf("\n"); + return true; +} + +bool Debugger::cmd_listRooms(int argc, const char **argv) { + for (int i = 0; i < _vm->_roomTableSize; i++) { + DebugPrintf("%-3i: %-10s", i, _vm->_roomFilenameTable[_vm->_roomTable[i].nameIndex]); + if (!(i % 8)) + DebugPrintf("\n"); + } + DebugPrintf("\n"); + DebugPrintf("Current room: %i\n", _vm->_currentRoom); + return true; +} + +bool Debugger::cmd_listFlags(int argc, const char **argv) { + for (int i = 0; i < (int)sizeof(_vm->_flagsTable)*8; i++) { + DebugPrintf("(%-3i): %-5i", i, _vm->queryGameFlag(i)); + if (!(i % 10)) + DebugPrintf("\n"); + } + DebugPrintf("\n"); + return true; +} + +bool Debugger::cmd_toggleFlag(int argc, const char **argv) { + if (argc > 1) { + uint flag = atoi(argv[1]); + if (_vm->queryGameFlag(flag)) + _vm->resetGameFlag(flag); + else + _vm->setGameFlag(flag); + DebugPrintf("Flag %i is now %i\n", flag, _vm->queryGameFlag(flag)); + } else + DebugPrintf("Syntax: toggleflag <flag>\n"); + + return true; +} + +bool Debugger::cmd_queryFlag(int argc, const char **argv) { + if (argc > 1) { + uint flag = atoi(argv[1]); + DebugPrintf("Flag %i is %i\n", flag, _vm->queryGameFlag(flag)); + } else + DebugPrintf("Syntax: queryflag <flag>\n"); + + return true; +} + +bool Debugger::cmd_listTimers(int argc, const char **argv) { + for (int i = 0; i < ARRAYSIZE(_vm->_timers); i++) + DebugPrintf("Timer %-2i: Active: %-3s Countdown: %-6i\n", i, _vm->_timers[i].active ? "Yes" : "No", _vm->_timers[i].countdown); + + return true; +} + +bool Debugger::cmd_setTimerCountdown(int argc, const char **argv) { + if (argc > 2) { + uint timer = atoi(argv[1]); + uint countdown = atoi(argv[2]); + _vm->setTimerCountdown(timer, countdown); + DebugPrintf("Timer %i now has countdown %i\n", timer, _vm->_timers[timer].countdown); + } else + DebugPrintf("Syntax: settimercountdown <timer> <countdown>\n"); + + return true; +} + +} // End of namespace Kyra diff --git a/kyra/debugger.h b/kyra/debugger.h new file mode 100644 index 0000000000..b764e2a303 --- /dev/null +++ b/kyra/debugger.h @@ -0,0 +1,55 @@ +/* ScummVM - Scumm Interpreter + * Copyright (C) 2003-2005 The ScummVM project + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $Header$ + * + */ + +#ifndef KYRA_DEBUGGER_H +#define KYRA_DEBUGGER_H + +#include "common/debugger.h" + +namespace Kyra { + +class KyraEngine; + +class Debugger : public Common::Debugger<Debugger> { +public: + Debugger(KyraEngine *vm); + virtual ~Debugger() {} // we need this for __SYMBIAN32__ archaic gcc/UIQ + +protected: + KyraEngine *_vm; + + virtual void preEnter(); + virtual void postEnter(); + + bool cmd_exit(int argc, const char **argv); + bool cmd_help(int argc, const char **argv); + bool cmd_enterRoom(int argc, const char **argv); + bool cmd_listRooms(int argc, const char **argv); + bool cmd_listFlags(int argc, const char **argv); + bool cmd_toggleFlag(int argc, const char **argv); + bool cmd_queryFlag(int argc, const char **argv); + bool cmd_listTimers(int argc, const char **argv); + bool cmd_setTimerCountdown(int argc, const char **argv); +}; + +} // End of namespace Kyra + +#endif diff --git a/kyra/kyra.cpp b/kyra/kyra.cpp index 2c0dcfa204..76d3aae899 100644 --- a/kyra/kyra.cpp +++ b/kyra/kyra.cpp @@ -44,6 +44,7 @@ #include "kyra/sound.h" #include "kyra/sprites.h" #include "kyra/wsamovie.h" +#include "kyra/debugger.h" using namespace Kyra; @@ -308,6 +309,8 @@ int KyraEngine::init(GameDetector &detector) { assert(_scriptClick); memset(_scriptClick, 0, sizeof(ScriptState)); + _debugger = new Debugger(this); + assert(_debugger); memset(_shapes, 0, sizeof(_shapes)); memset(_wsaObjects, 0, sizeof(_wsaObjects)); @@ -320,10 +323,13 @@ int KyraEngine::init(GameDetector &detector) { _talkMessageY = 0xC; _talkMessageH = 0; _talkMessagePrinted = false; - _charSayUnk1 = -1; + _talkingCharNum = -1; _charSayUnk3 = -1; _mouseX = _mouseY = -1; - + memset(_currSentenceColor, 0, 3); + _startSentencePalIndex = -1; + _fadeText = false; + _brandonPosX = _brandonPosY = -1; _brandonDrawFrame = 113; @@ -353,6 +359,7 @@ int KyraEngine::init(GameDetector &detector) { } KyraEngine::~KyraEngine() { + delete _debugger; delete _sprites; delete _screen; delete _res; @@ -501,6 +508,8 @@ void KyraEngine::delay(uint32 amount) { case OSystem::EVENT_KEYDOWN: if (event.kbd.keycode == 'q' || event.kbd.keycode == 27) { _quitFlag = true; + } else if (event.kbd.keycode == 'd' && !_debugger->isAttached()) { + _debugger->attach(); } break; case OSystem::EVENT_MOUSEMOVE: @@ -523,6 +532,10 @@ void KyraEngine::delay(uint32 amount) { break; } } + + if (_debugger->isAttached()) + _debugger->onFrame(); + _sprites->updateSceneAnims(); updateAllObjectShapes(); @@ -541,12 +554,11 @@ void KyraEngine::mainLoop() { while (!_quitFlag) { int32 frameTime = (int32)_system->getMillis(); - updateMousePointer(); updateGameTimers(); _sprites->updateSceneAnims(); updateAllObjectShapes(); - // XXX call processPalette + updateTextFade(); _handleInput = true; delay((frameTime + _gameSpeed) - _system->getMillis()); @@ -1186,9 +1198,10 @@ void KyraEngine::enterNewScene(int sceneId, int facing, int unk1, int unk2, int memset(_entranceMouseCursorTracks, 0xFFFF, sizeof(uint16)*4); _currentCharacter->sceneId = sceneId; - assert(sceneId < _roomFilenameTableSize); assert(sceneId < _roomTableSize); + assert(_roomTable[sceneId].nameIndex < _roomFilenameTableSize); + Room *currentRoom = &_roomTable[sceneId]; if (_currentRoom != 0xFFFF && (_features & GF_TALKIE)) { @@ -1203,9 +1216,7 @@ void KyraEngine::enterNewScene(int sceneId, int facing, int unk1, int unk2, int _currentRoom = sceneId; - assert(_currentCharacter->sceneId < _roomTableSize); int tableId = _roomTable[_currentCharacter->sceneId].nameIndex; - assert(tableId < _roomFilenameTableSize); char fileNameBuffer[32]; strcpy(fileNameBuffer, _roomFilenameTable[tableId]); strcat(fileNameBuffer, ".DAT"); @@ -1241,9 +1252,10 @@ void KyraEngine::enterNewScene(int sceneId, int facing, int unk1, int unk2, int if (!brandonAlive) { // XXX } - + startSceneScript(brandonAlive); setupSceneItems(); + initSceneData(facing, unk2, brandonAlive); _loopFlag2 = 0; @@ -1312,7 +1324,8 @@ void KyraEngine::setCharacterPositionWithUpdate(int character) { _sprites->updateSceneAnims(); updateGameTimers(); updateAllObjectShapes(); - // XXX processPalette + updateTextFade(); + if (_currentCharacter->sceneId == 210) { // XXX game_updateKyragemFading } @@ -1953,6 +1966,7 @@ void KyraEngine::initSceneScreen(int brandonAlive) { while (_scriptInterpreter->validScript(_scriptClick)) _scriptInterpreter->runScript(_scriptClick); + setTextFadeTimerCountdown(-1); if (_currentCharacter->sceneId == 0xD2) { // XXX } @@ -2185,9 +2199,9 @@ void KyraEngine::waitForChatToFinish(int16 chatDuration, char *chatStr, uint8 ch if (_system->getMillis() > timeToEnd && !hasUpdatedNPCs) { hasUpdatedNPCs = true; disableTimer(15); - _charSayUnk4 = 4; + _currHeadShape = 4; animRefreshNPC(0); - animRefreshNPC(_charSayUnk1); + animRefreshNPC(_talkingCharNum); if (_charSayUnk2 != -1) { _sprites->_animObjects[_charSayUnk2].active = 0; @@ -2208,7 +2222,7 @@ void KyraEngine::waitForChatToFinish(int16 chatDuration, char *chatStr, uint8 ch _screen->_curPage = currPage; copyChangedObjectsForward(0); - //processPalette(); + updateTextFade(); if ((chatDuration < (int16)(_system->getMillis() - timeAtStart)) && chatDuration != -1) break; @@ -2249,7 +2263,7 @@ void KyraEngine::endCharacterChat(int8 charNum, int16 convoInitialized) { } if (convoInitialized != 0) { - _charSayUnk1 = -1; + _talkingCharNum = -1; _currentCharacter->currentAnimFrame = 7; animRefreshNPC(0); updateAllObjectShapes(); @@ -2257,7 +2271,7 @@ void KyraEngine::endCharacterChat(int8 charNum, int16 convoInitialized) { } void KyraEngine::restoreChatPartnerAnimFrame(int8 charNum) { - _charSayUnk1 = -1; + _talkingCharNum = -1; if (charNum > 0 && charNum < 5) { _characterList[charNum].currentAnimFrame = _currentChatPartnerBackupFrame; @@ -2270,7 +2284,7 @@ void KyraEngine::restoreChatPartnerAnimFrame(int8 charNum) { } void KyraEngine::backupChatPartnerAnimFrame(int8 charNum) { - _charSayUnk1 = 0; + _talkingCharNum = 0; if (charNum < 5 && charNum > 0) _currentChatPartnerBackupFrame = _characterList[charNum].currentAnimFrame; @@ -2307,8 +2321,8 @@ int8 KyraEngine::getChatPartnerNum() { } int KyraEngine::initCharacterChat(int8 charNum) { - if (_charSayUnk1 == -1) { - _charSayUnk1 = 0; + if (_talkingCharNum == -1) { + _talkingCharNum = 0; if (_scaleMode != 0) _currentCharacter->currentAnimFrame = 7; @@ -2375,7 +2389,7 @@ void KyraEngine::characterSays(char *chatStr, int8 charNum, int8 chatDuration) { if (charNum < 5) { _characterList[charNum].currentAnimFrame = startAnimFrames[charNum]; _charSayUnk3 = charNum; - _charSayUnk1 = charNum; + _talkingCharNum = charNum; animRefreshNPC(charNum); } @@ -2428,17 +2442,64 @@ void KyraEngine::characterSays(char *chatStr, int8 charNum, int8 chatDuration) { endCharacterChat(charNum, convoInitialized); } -void KyraEngine::drawSentenceCommand(char *sentence, int unk1) { +void KyraEngine::drawSentenceCommand(char *sentence, int color) { + debug(9, "drawSentenceCommand('%s', %i)", sentence, color); _screen->hideMouse(); _screen->fillRect(8, 143, 311, 152, 12); - // XXX: palette stuff + + if (_startSentencePalIndex != color || _fadeText != false) { + _currSentenceColor[0] = _screen->_currentPalette[765] = _screen->_currentPalette[color*3]; + _currSentenceColor[1] = _screen->_currentPalette[766] = _screen->_currentPalette[color*3+1]; + _currSentenceColor[2] = _screen->_currentPalette[767] = _screen->_currentPalette[color*3+2]; + + _screen->setScreenPalette(_screen->_currentPalette); + _startSentencePalIndex = 0; + } printText(sentence, 8, 143, 0xFF, 12, 0); _screen->showMouse(); - //setTextFadeTimerCountdown(_textFadeTimerCountdown); - //_palScrollEnabled = 0; + setTextFadeTimerCountdown(15); + _fadeText = false; +} + +void KyraEngine::updateSentenceCommand(char *str1, char *str2, int color) { + debug(9, "updateSentenceCommand('%s', '%s', %i)", str1, str2, color); + char sentenceCommand[500]; + strncpy(sentenceCommand, str1, 500); + if (str2) + strncat(sentenceCommand, str2, 500 - strlen(sentenceCommand)); + + drawSentenceCommand(sentenceCommand, color); +} + +void KyraEngine::updateTextFade() { + debug(9, "updateTextFade()"); + if (!_fadeText) + return; + + bool finished = false; + for (int i = 0; i < 3; i++) + if (_currSentenceColor[i] > 4) + _currSentenceColor[i] -= 4; + else + if (_currSentenceColor[i]) { + _currSentenceColor[i] = 0; + finished = true; + } + + _screen->_currentPalette[765] = _currSentenceColor[0]; + _screen->_currentPalette[766] = _currSentenceColor[1]; + _screen->_currentPalette[767] = _currSentenceColor[2]; + _screen->setScreenPalette(_screen->_currentPalette); + + if (finished) { + _fadeText = false; + _startSentencePalIndex = -1; + } + } + #pragma mark - #pragma mark - Item handling #pragma mark - @@ -3131,7 +3192,7 @@ void KyraEngine::prepDrawAllObjects() { } // talking head functionallity - if (_charSayUnk1 != -1) { + if (_talkingCharNum != -1) { const int16 baseAnimFrameTable1[] = { 0x11, 0x35, 0x59, 0x00, 0x00, 0x00 }; const int16 baseAnimFrameTable2[] = { 0x15, 0x39, 0x5D, 0x00, 0x00, 0x00 }; const int8 xOffsetTable1[] = { 2, 4, 0, 5, 2, 0, 0, 0 }; @@ -3141,7 +3202,7 @@ void KyraEngine::prepDrawAllObjects() { if (curObject->index == 0 || curObject->index <= 4) { int shapesIndex = 0; if (curObject->index == _charSayUnk3) { - shapesIndex = _charSayUnk4 + baseAnimFrameTable1[curObject->index]; + shapesIndex = _currHeadShape + baseAnimFrameTable1[curObject->index]; } else { shapesIndex = baseAnimFrameTable2[curObject->index]; int temp2 = 0; @@ -4076,7 +4137,7 @@ int KyraEngine::processSceneChange(int *table, int unk1, int frameReset) { updateMousePointer(); updateGameTimers(); updateAllObjectShapes(); - // XXX processPalette + updateTextFade(); if (_currentCharacter->sceneId == 210) { // XXX updateKyragemFading // XXX playEnd @@ -4217,7 +4278,7 @@ int KyraEngine::changeScene(int facing) { #pragma mark - void KyraEngine::setupTimers() { - debug(9, "KyraEngine::setupTimers()"); + debug(9, "setupTimers()"); memset(_timers, 0, sizeof(_timers)); for (int i = 0; i < 34; i++) @@ -4226,7 +4287,7 @@ void KyraEngine::setupTimers() { _timers[0].func = _timers[1].func = _timers[2].func = _timers[3].func = _timers[4].func = 0; //Unused. _timers[5].func = _timers[6].func = _timers[7].func = _timers[8].func = _timers[9].func = 0; //_nullsub51; _timers[10].func = _timers[11].func = _timers[12].func = _timers[13].func = 0; //_nullsub50; - _timers[14].func = &KyraEngine::timerCheckAnimFlag2;; //_nullsub52; + _timers[14].func = &KyraEngine::timerCheckAnimFlag2; //_nullsub52; _timers[15].func = &KyraEngine::timerUpdateHeadAnims; //_nullsub48; _timers[16].func = &KyraEngine::timerSetFlags1; //_nullsub47; _timers[17].func = 0; //sub_15120; @@ -4243,7 +4304,7 @@ void KyraEngine::setupTimers() { _timers[28].func = 0; //offset _timerDummy6 _timers[29].func = 0; //offset _timerDummy7, _timers[30].func = 0; //offset _timerDummy8, - _timers[31].func = 0; //sub_151F8; + _timers[31].func = &KyraEngine::timerFadeText; //sub_151F8; _timers[32].func = 0; //_nullsub61; _timers[33].func = 0; //_nullsub62; @@ -4270,20 +4331,8 @@ void KyraEngine::setupTimers() { _timers[33].countdown = 3; } -void KyraEngine::setTimer19() { - debug(9, "KyraEngine::setTimer19()"); - if (_brandonStatusBit & 2) { - // XXX call sub_3F9C - setTimerCountdown(19, 300); - } else if (_brandonStatusBit & 0x20) { - // XXX call sub_4110 - setTimerCountdown(19, 300); - } -} - void KyraEngine::updateGameTimers() { - debug(9, "KyraEngine::updateGameTimers()"); - void (Kyra::KyraEngine::*callback)(int timerNum); + debug(9, "updateGameTimers()"); if (_system->getMillis() < _timerNextRun) return; @@ -4293,13 +4342,8 @@ void KyraEngine::updateGameTimers() { for (int i = 0; i < 34; i++) { if (_timers[i].active && _timers[i].countdown > -1) { if (_timers[i].nextRun <=_system->getMillis()) { - if (i < 5) - callback = 0; - else - callback = _timers[i].func; - - if (callback) - (*this.*callback)(i); + if (i > 4 && _timers[i].func) + (*this.*_timers[i].func)(i); _timers[i].nextRun = _system->getMillis() + _timers[i].countdown * _tickLength; @@ -4311,16 +4355,17 @@ void KyraEngine::updateGameTimers() { } void KyraEngine::clearNextEventTickCount() { - debug(9, "KyraEngine::clearNextEventTickCount()"); + debug(9, "clearNextEventTickCount()"); _timerNextRun = 0; } int16 KyraEngine::getTimerDelay(uint8 timer) { + debug(9, "getTimerDelay(%i)", timer); return _timers[timer].countdown; } -void KyraEngine::setTimerCountdown(uint8 timer, int16 countdown) { - debug(9, "KyraEngine::setTimerCountdown(%i, %i)", timer, countdown); +void KyraEngine::setTimerCountdown(uint8 timer, int32 countdown) { + debug(9, "setTimerCountdown(%i, %i)", timer, countdown); _timers[timer].countdown = countdown; uint32 nextRun = _system->getMillis() + countdown; @@ -4329,36 +4374,36 @@ void KyraEngine::setTimerCountdown(uint8 timer, int16 countdown) { } void KyraEngine::enableTimer(uint8 timer) { - debug(9, "KyraEngine::enableTimer(%i)", timer); + debug(9, "enableTimer(%i)", timer); _timers[timer].active = 1; } void KyraEngine::disableTimer(uint8 timer) { - debug(9, "KyraEngine::disableTimer(%i)", timer); + debug(9, "disableTimer(%i)", timer); _timers[timer].active = 0; } void KyraEngine::timerUpdateHeadAnims(int timerNum) { - debug(9, "KyraEngine::timerUpdateHeadAnims(%i)", timerNum); + debug(9, "timerUpdateHeadAnims(%i)", timerNum); static int8 currentFrame = 0; static const int8 frameTable[] = {4, 5, 4, 5, 4, 5, 0, 1, 4, 5, 4, 4, 6, 4, 8, 1, 9, 4, -1}; - if (_charSayUnk1 < 0) + if (_talkingCharNum < 0) return; - _charSayUnk4 = frameTable[currentFrame]; + _currHeadShape = frameTable[currentFrame]; currentFrame++; if (frameTable[currentFrame] == -1) currentFrame = 0; animRefreshNPC(0); - animRefreshNPC(_charSayUnk1); + animRefreshNPC(_talkingCharNum); } void KyraEngine::timerSetFlags1(int timerNum) { - debug(9, "KyraEngine::timerSetFlags(%i)", timerNum); + debug(9, "timerSetFlags(%i)", timerNum); if (_currentCharacter->sceneId == 0x1C) return; @@ -4376,29 +4421,43 @@ void KyraEngine::timerSetFlags1(int timerNum) { } } +void KyraEngine::timerFadeText(int timerNum) { + debug(9, "timerFadeText(%i)", timerNum); + _fadeText = true; +} + +void KyraEngine::setTextFadeTimerCountdown(int16 countdown) { + debug(9, "setTextFadeTimerCountdown(%i)", countdown); + //if (countdown == -1) + //countdown = 32000; + + setTimerCountdown(31, countdown*60); +} + void KyraEngine::timerSetFlags2(int timerNum) { + debug(9, "timerSetFlags2(%i)", timerNum); if (!((uint32*)(_flagsTable+0x2D))[timerNum]) ((uint32*)(_flagsTable+0x2D))[timerNum] = 1; } void KyraEngine::timerCheckAnimFlag1(int timerNum) { - debug(9, "KyraEngine::timerCheckAnimFlag1(%i)", timerNum); + debug(9, "timerCheckAnimFlag1(%i)", timerNum); if (_brandonStatusBit & 0x20) { - checkSpecialAnimFlags(); + checkAmuletAnimFlags(); setTimerCountdown(18, -1); } } void KyraEngine::timerCheckAnimFlag2(int timerNum) { - debug(9, "KyraEngine::timerCheckAnimFlag1(%i)", timerNum); + debug(9, "timerCheckAnimFlag1(%i)", timerNum); if (_brandonStatusBit & 0x2) { - checkSpecialAnimFlags(); + checkAmuletAnimFlags(); setTimerCountdown(14, -1); } } -void KyraEngine::checkSpecialAnimFlags() { - debug(9, "KyraEngine::checkSpecialAnimFlags()"); +void KyraEngine::checkAmuletAnimFlags() { + debug(9, "checkSpecialAnimFlags()"); if (_brandonStatusBit & 2) { warning("STUB: playSpecialAnim1"); // XXX @@ -4413,13 +4472,15 @@ void KyraEngine::checkSpecialAnimFlags() { } void KyraEngine::timerRedrawAmulet(int timerNum) { + debug(9, "timerRedrawAmulet(%i)", timerNum); if (queryGameFlag(241)) { drawAmulet(); - setTimerCountdown(0x13, -1); + setTimerCountdown(19, -1); } } void KyraEngine::drawAmulet() { + debug(9, "drawAmulet()"); static const int16 amuletTable1[] = {0x167, 0x162, 0x15D, 0x158, 0x153, 0x150, 0x155, 0x15A, 0x15F, 0x164, 0x145, -1}; static const int16 amuletTable3[] = {0x167, 0x162, 0x15D, 0x158, 0x153, 0x14F, 0x154, 0x159, 0x15E, 0x163, 0x144, -1}; static const int16 amuletTable2[] = {0x167, 0x162, 0x15D, 0x158, 0x153, 0x152, 0x157, 0x15C, 0x161, 0x166, 0x147, -1}; diff --git a/kyra/kyra.h b/kyra/kyra.h index 872d7f0266..ec9cdf15a9 100644 --- a/kyra/kyra.h +++ b/kyra/kyra.h @@ -142,17 +142,19 @@ class Sprites; struct ScriptState; struct ScriptData; class ScriptHelper; +class Debugger; class KyraEngine; struct Timer { bool active; - int16 countdown; + int32 countdown; uint32 nextRun; void (KyraEngine::*func)(int timerNum); }; class KyraEngine : public Engine { friend class MusicPlayer; + friend class Debugger; public: enum { @@ -202,10 +204,12 @@ public: void printTalkTextMessage(const char *text, int x, int y, uint8 color, int srcPage, int dstPage); void restoreTalkTextMessageBkgd(int srcPage, int dstPage); void drawSentenceCommand(char *sentence, int unk1); + void updateSentenceCommand(char *str1, char *str2, int unk1); + void updateTextFade(); void updateGameTimers(); void clearNextEventTickCount(); - void setTimerCountdown(uint8 timer, int16 countdown); + void setTimerCountdown(uint8 timer, int32 countdown); int16 getTimerDelay(uint8 timer); void enableTimer(uint8 timer); void disableTimer(uint8 timer); @@ -336,7 +340,7 @@ public: int cmd_shakeScreen(ScriptState *script); int cmd_createAmuletJewel(ScriptState *script); int cmd_setSceneAnimCurrXY(ScriptState *script); - int cmd_Poison_Brandon_And_Remaps(ScriptState *script); + int cmd_poisonBrandonAndRemaps(ScriptState *script); int cmd_fillFlaskWithWater(ScriptState *script); int cmd_getCharactersMovementDelay(ScriptState *script); int cmd_getBirthstoneGem(ScriptState *script); @@ -532,10 +536,11 @@ protected: void timerSetFlags2(int timerNum); void timerCheckAnimFlag1(int timerNum); void timerCheckAnimFlag2(int timerNum); - void checkSpecialAnimFlags(); + void checkAmuletAnimFlags(); void timerRedrawAmulet(int timerNum); + void timerFadeText(int timerNum); void drawAmulet(); - + void setTextFadeTimerCountdown(int16 countdown); uint8 _game; bool _fastMode; bool _quitFlag; @@ -605,10 +610,13 @@ protected: int _lastFindWayRet; int *_movFacingTable; - int8 _charSayUnk1; + int8 _talkingCharNum; int8 _charSayUnk2; int8 _charSayUnk3; - int8 _charSayUnk4; + int8 _currHeadShape; + uint8 _currSentenceColor[3]; + int8 _startSentencePalIndex; + bool _fadeText; uint8 _configTalkspeed; AnimObject *_objectQueue; @@ -626,6 +634,7 @@ protected: SeqPlayer *_seq; Sprites *_sprites; ScriptHelper *_scriptInterpreter; + Debugger *_debugger; ScriptState *_scriptMain; ScriptData *_npcScriptData; diff --git a/kyra/module.mk b/kyra/module.mk index 1f12f23417..ed33f27ba6 100644 --- a/kyra/module.mk +++ b/kyra/module.mk @@ -10,7 +10,8 @@ MODULE_OBJS := \ kyra/sound.o \ kyra/staticres.o \ kyra/sprites.o \ - kyra/wsamovie.o + kyra/wsamovie.o \ + kyra/debugger.o MODULE_DIRS += \ kyra diff --git a/kyra/script_v1.cpp b/kyra/script_v1.cpp index e3ea0ff215..3c5488bebe 100644 --- a/kyra/script_v1.cpp +++ b/kyra/script_v1.cpp @@ -573,7 +573,8 @@ int KyraEngine::cmd_setBrandonStatusBit(ScriptState *script) { int KyraEngine::cmd_pauseSeconds(ScriptState *script) { debug(3, "cmd_pauseSeconds(0x%X) (%d)", script, stackPos(0)); - delay(stackPos(0)*1000); + if (stackPos(0) > 0) + delay(stackPos(0)*1000); return 0; } @@ -600,7 +601,7 @@ int KyraEngine::cmd_internalAnimOn(ScriptState *script) { int KyraEngine::cmd_forceBrandonToNormal(ScriptState *script) { debug(3, "cmd_forceBrandonToNormal(0x%X) ()", script); - setTimer19(); + checkAmuletAnimFlags(); return 0; } @@ -657,8 +658,7 @@ int KyraEngine::cmd_runWSAFromBeginningToEnd(ScriptState *script) { if (wsaFrame >= wsa_getNumFrames(_wsaObjects[wsaIndex])) running = false; - // XXX - waitTicks(waitTime); + delay(waitTime * _tickLength); if (worldUpdate) { _sprites->updateSceneAnims(); updateAllObjectShapes(); @@ -680,10 +680,7 @@ int KyraEngine::cmd_displayWSAFrame(ScriptState *script) { int wsaIndex = stackPos(4); _screen->hideMouse(); wsa_play(_wsaObjects[wsaIndex], frame, xpos, ypos, 0); - // XXX - waitTicks(waitTime); - _sprites->updateSceneAnims(); - updateAllObjectShapes(); + delay(waitTime * _tickLength); _screen->updateScreen(); _screen->showMouse(); return 0; @@ -878,8 +875,7 @@ int KyraEngine::cmd_displayWSAFrameOnHidPage(ScriptState *script) { _screen->hideMouse(); wsa_play(_wsaObjects[wsaIndex], frame, xpos, ypos, 2); - // XXX - waitTicks(waitTime); + delay(waitTime*_tickLength); _sprites->updateSceneAnims(); updateAllObjectShapes(); _screen->showMouse(); @@ -906,20 +902,16 @@ int KyraEngine::cmd_displayWSASequentialFrames(ScriptState *script) { int frame = startFrame; while (endFrame >= frame) { wsa_play(_wsaObjects[wsaIndex], frame, xpos, ypos, 0); - // XXX - waitTicks(waitTime); - _sprites->updateSceneAnims(); - updateAllObjectShapes(); + delay(waitTime * _tickLength); + _screen->updateScreen(); ++frame; } } else { int frame = endFrame; while (startFrame <= frame) { wsa_play(_wsaObjects[wsaIndex], frame, xpos, ypos, 0); - // XXX - waitTicks(waitTime); - _sprites->updateSceneAnims(); - updateAllObjectShapes(); + delay(waitTime * _tickLength); + _screen->updateScreen(); --frame; } } @@ -1128,7 +1120,7 @@ int KyraEngine::cmd_walkCharacterToPoint(ScriptState *script) { updateMousePointer(); updateGameTimers(); updateAllObjectShapes(); - // XXX processPalette(); + updateTextFade(); if ((nextFrame - _system->getMillis()) >= 10) delay(10); } @@ -1157,7 +1149,8 @@ int KyraEngine::cmd_fatPrint(ScriptState *script) { } int KyraEngine::cmd_preserveAllObjectBackgrounds(ScriptState *script) { - warning("STUB: cmd_preserveAllObjectBackgrounds"); + debug(3, "cmd_preserveAllObjectBackgrounds(0x%X) ()", script); + preserveAllBackgrounds(); return 0; } @@ -1283,8 +1276,8 @@ int KyraEngine::cmd_setSceneAnimCurrXY(ScriptState *script) { return 0; } -int KyraEngine::cmd_Poison_Brandon_And_Remaps(ScriptState *script) { - warning("STUB: cmd_Poison_Brandon_And_Remaps"); +int KyraEngine::cmd_poisonBrandonAndRemaps(ScriptState *script) { + warning("STUB: cmdPoisonBrandonAndRemaps"); return 0; } @@ -1497,8 +1490,8 @@ int KyraEngine::cmd_brandonHealingSequence(ScriptState *script) { } int KyraEngine::cmd_protectCommandLine(ScriptState *script) { - warning("STUB: cmd_protectCommandLine"); - return 0; + debug(3, "cmd_protectCommandLine(0x%X) (%d)", script, stackPos(0)); + return stackPos(0); } int KyraEngine::cmd_pauseMusicSeconds(ScriptState *script) { diff --git a/kyra/sprites.cpp b/kyra/sprites.cpp index 046727d4f3..eee22fda23 100644 --- a/kyra/sprites.cpp +++ b/kyra/sprites.cpp @@ -344,7 +344,7 @@ void Sprites::updateSceneAnims() { data += 2; debug(5, "func: Play sound"); debug(5, "Sound index %i", READ_LE_UINT16(data)); - _engine->snd_playSoundEffect(READ_LE_UINT16(data)); + //_engine->snd_playSoundEffect(READ_LE_UINT16(data)); data += 2; break; case 0xFFB1: @@ -363,8 +363,8 @@ void Sprites::updateSceneAnims() { data += 2; debug(5, "Percentage %i", READ_LE_UINT16(data)); rndNr = _rnd.getRandomNumber(100); - if (rndNr <= READ_LE_UINT16(data)) - _engine->snd_playSoundEffect(sound); + //if (rndNr <= READ_LE_UINT16(data)) + //_engine->snd_playSoundEffect(sound); data += 2; break; case 0xFFA7: diff --git a/kyra/staticres.cpp b/kyra/staticres.cpp index f29b0e4ba1..ee71bcaee2 100644 --- a/kyra/staticres.cpp +++ b/kyra/staticres.cpp @@ -497,7 +497,7 @@ KyraEngine::OpcodeProc KyraEngine::_opcodeTable[] = { // 0x6c Opcode(cmd_createAmuletJewel), Opcode(cmd_setSceneAnimCurrXY), - Opcode(cmd_Poison_Brandon_And_Remaps), + Opcode(cmd_poisonBrandonAndRemaps), Opcode(cmd_fillFlaskWithWater), // 0x70 Opcode(cmd_getCharactersMovementDelay), |