Ticket #8495: kyra-debugandtextfade_v1.patch

File kyra-debugandtextfade_v1.patch, 24.8 KB (added by vinterstum, 18 years ago)

Debug console and text fading and misc, current to CVS at time of submission

  • kyra/debugger.cpp

    diff --exclude=.cvsignore --exclude=.deps --exclude=CVS -Pur ./scummvmcvs/kyra/debugger.cpp scummvm/kyra/debugger.cpp
    old new  
     1/* ScummVM - Scumm Interpreter
     2 * Copyright (C) 2003-2005 The ScummVM project
     3 *
     4 * This program is free software; you can redistribute it and/or
     5 * modify it under the terms of the GNU General Public License
     6 * as published by the Free Software Foundation; either version 2
     7 * of the License, or (at your option) any later version.
     8
     9 * This program is distributed in the hope that it will be useful,
     10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     12 * GNU General Public License for more details.
     13
     14 * You should have received a copy of the GNU General Public License
     15 * along with this program; if not, write to the Free Software
     16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
     17 *
     18 */
     19
     20#include "common/stdafx.h"
     21#include "common/config-manager.h"
     22#include "common/debugger.cpp"
     23#include "kyra/debugger.h"
     24#include "kyra/kyra.h"
     25#include "kyra/screen.h"
     26
     27namespace Kyra {
     28
     29Debugger::Debugger(KyraEngine *vm)
     30        : Common::Debugger<Debugger>() {
     31        _vm = vm;
     32
     33        DCmd_Register("continue",                       &Debugger::cmd_Exit);
     34        DCmd_Register("exit",                           &Debugger::cmd_Exit);
     35        DCmd_Register("help",                           &Debugger::cmd_Help);
     36        DCmd_Register("quit",                           &Debugger::cmd_Exit);
     37        DCmd_Register("enter",                          &Debugger::cmd_EnterRoom);
     38        DCmd_Register("rooms",                          &Debugger::cmd_ListRooms);
     39        DCmd_Register("flags",                          &Debugger::cmd_ListFlags);
     40        DCmd_Register("toggleflag",                     &Debugger::cmd_ToggleFlag);
     41        DCmd_Register("queryflag",                      &Debugger::cmd_QueryFlag);
     42        DCmd_Register("timers",                         &Debugger::cmd_ListTimers);
     43        DCmd_Register("settimercountdown",      &Debugger::cmd_SetTimerCountdown);
     44}
     45
     46void Debugger::preEnter() {
     47        //_vm->midi.pause(1);
     48}
     49
     50void Debugger::postEnter() {
     51        //_vm->midi.pause(0);
     52}
     53
     54bool Debugger::cmd_EnterRoom(int argc, const char **argv) {
     55        if (argc > 1) {
     56                uint room = atoi(argv[1]);
     57
     58                // Dirty way of hiding the debug console while the room entry scripts are running,
     59                // otherwise the graphics didn't update.
     60                _vm->_system->hideOverlay();
     61                _vm->enterNewScene(room, _vm->_currentCharacter->facing, 0, 0, 1);
     62                _vm->_system->showOverlay();
     63                return false;
     64        }
     65
     66        DebugPrintf("Syntax: room <roomnum>\n");
     67        return true;
     68}
     69
     70bool Debugger::cmd_Exit(int argc, const char **argv) {
     71        _detach_now = true;
     72        return false;
     73}
     74
     75bool Debugger::cmd_Help(int argc, const char **argv) {
     76        // console normally has 39 line width
     77        // wrap around nicely
     78        int width = 0, size, i;
     79
     80        DebugPrintf("Commands are:\n");
     81        for (i = 0 ; i < _dcmd_count ; i++) {
     82                size = strlen(_dcmds[i].name) + 1;
     83
     84                if ((width + size) >= 39) {
     85                        DebugPrintf("\n");
     86                        width = size;
     87                } else
     88                        width += size;
     89
     90                DebugPrintf("%s ", _dcmds[i].name);
     91        }
     92        DebugPrintf("\n");
     93        return true;
     94}
     95
     96bool Debugger::cmd_ListRooms(int argc, const char **argv) {
     97        for (int i = 0; i < _vm->_roomTableSize; i++) {
     98                DebugPrintf("%-3i: %-10s", i, _vm->_roomFilenameTable[_vm->_roomTable[i].nameIndex]);
     99                if (!(i % 8))
     100                        DebugPrintf("\n");
     101        }
     102        DebugPrintf("\n");
     103        DebugPrintf("Current room: %i\n", _vm->_currentRoom);
     104        return true;
     105}
     106
     107bool Debugger::cmd_ListFlags(int argc, const char **argv) {
     108        for (int i = 0; i < (int)sizeof(_vm->_flagsTable)*8; i++) {
     109                DebugPrintf("(%-3i): %-5i", i, _vm->queryGameFlag(i));
     110                if (!(i % 10))
     111                        DebugPrintf("\n");
     112        }
     113        DebugPrintf("\n");
     114        return true;
     115}
     116
     117bool Debugger::cmd_ToggleFlag(int argc, const char **argv) {
     118        if (argc > 1) {
     119                uint flag = atoi(argv[1]);
     120                if (_vm->queryGameFlag(flag))
     121                        _vm->resetGameFlag(flag);
     122                else
     123                        _vm->setGameFlag(flag);
     124                DebugPrintf("Flag %i is now %i\n", flag, _vm->queryGameFlag(flag));
     125        } else
     126                DebugPrintf("Syntax: toggleflag <flag>\n");
     127
     128        return true;
     129}
     130
     131bool Debugger::cmd_QueryFlag(int argc, const char **argv) {
     132        if (argc > 1) {
     133                uint flag = atoi(argv[1]);
     134                DebugPrintf("Flag %i is %i\n", flag, _vm->queryGameFlag(flag));
     135        } else
     136                DebugPrintf("Syntax: queryflag <flag>\n");
     137
     138        return true;
     139}
     140
     141bool Debugger::cmd_ListTimers(int argc, const char **argv) {
     142        for (int i = 0; i < ARRAYSIZE(_vm->_timers); i++)
     143                DebugPrintf("Timer %-2i: Active: %-3s Countdown: %-6i\n", i, _vm->_timers[i].active ? "Yes" : "No", _vm->_timers[i].countdown);
     144
     145        return true;
     146}
     147
     148bool Debugger::cmd_SetTimerCountdown(int argc, const char **argv) {
     149        if (argc > 2) {
     150                uint timer = atoi(argv[1]);
     151                uint countdown = atoi(argv[2]);
     152                _vm->setTimerCountdown(timer, countdown);       
     153                DebugPrintf("Timer %i now has countdown %i\n", timer, _vm->_timers[timer].countdown);
     154        } else
     155                DebugPrintf("Syntax: settimercountdown <timer> <countdown>\n");
     156
     157        return true;
     158}
     159
     160} // End of namespace Kyra
     161
  • kyra/debugger.h

    diff --exclude=.cvsignore --exclude=.deps --exclude=CVS -Pur ./scummvmcvs/kyra/debugger.h scummvm/kyra/debugger.h
    old new  
     1/* ScummVM - Scumm Interpreter
     2 * Copyright (C) 2003-2005 The ScummVM project
     3 *
     4 * This program is free software; you can redistribute it and/or
     5 * modify it under the terms of the GNU General Public License
     6 * as published by the Free Software Foundation; either version 2
     7 * of the License, or (at your option) any later version.
     8
     9 * This program is distributed in the hope that it will be useful,
     10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     12 * GNU General Public License for more details.
     13
     14 * You should have received a copy of the GNU General Public License
     15 * along with this program; if not, write to the Free Software
     16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
     17 *
     18 */
     19
     20#ifndef KYRA_DEBUGGER_H
     21#define KYRA_DEBUGGER_H
     22
     23#include "common/debugger.h"
     24
     25namespace Kyra {
     26
     27class KyraEngine;
     28
     29class Debugger : public Common::Debugger<Debugger> {
     30public:
     31        Debugger(KyraEngine *vm);
     32        virtual ~Debugger() {}  // we need this for __SYMBIAN32__ archaic gcc/UIQ
     33
     34protected:
     35        KyraEngine *_vm;
     36
     37        virtual void preEnter();
     38        virtual void postEnter();
     39
     40        bool cmd_Exit(int argc, const char **argv);
     41        bool cmd_Help(int argc, const char **argv);
     42        bool cmd_EnterRoom(int argc, const char **argv);
     43        bool cmd_ListRooms(int argc, const char **argv);
     44        bool cmd_ListFlags(int argc, const char **argv);
     45        bool cmd_ToggleFlag(int argc, const char **argv);
     46        bool cmd_QueryFlag(int argc, const char **argv);
     47        bool cmd_ListTimers(int argc, const char **argv);
     48        bool cmd_SetTimerCountdown(int argc, const char **argv);
     49};
     50
     51} // End of namespace Kyra
     52
     53#endif
  • kyra/kyra.cpp

    diff --exclude=.cvsignore --exclude=.deps --exclude=CVS -Pur ./scummvmcvs/kyra/kyra.cpp scummvm/kyra/kyra.cpp
    old new  
    1515 * along with this program; if not, write to the Free Software
    1616 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
    1717 *
    18  * $Header: /cvsroot/scummvm/scummvm/kyra/kyra.cpp,v 1.76 2005/12/08 17:19:17 lordhoto Exp $
     18 * $Header: /cvsroot/scummvm/scummvm/kyra/kyra.cpp,v 1.75 2005/11/27 10:02:22 lordhoto Exp $
    1919 *
    2020 */
    2121
     
    4444#include "kyra/sound.h"
    4545#include "kyra/sprites.h"
    4646#include "kyra/wsamovie.h"
     47#include "kyra/debugger.h"
    4748
    4849using namespace Kyra;
    4950
     
    308309        assert(_scriptClick);
    309310        memset(_scriptClick, 0, sizeof(ScriptState));
    310311       
     312        _debugger = new Debugger(this);
     313        assert(_debugger);     
    311314        memset(_shapes, 0, sizeof(_shapes));
    312315        memset(_wsaObjects, 0, sizeof(_wsaObjects));
    313316
     
    320323        _talkMessageY = 0xC;
    321324        _talkMessageH = 0;
    322325        _talkMessagePrinted = false;
    323         _charSayUnk1 = -1;
     326        _talkingCharNum = -1;
    324327        _charSayUnk3 = -1;
    325328        _mouseX = _mouseY = -1;
    326        
     329        memset(_currSentenceColor, 0, 3);
     330        _startSentencePalIndex = -1;
     331        _fadeText = false;
     332
    327333        _brandonPosX = _brandonPosY = -1;
    328334        _brandonDrawFrame = 113;
    329335       
     
    353359}
    354360
    355361KyraEngine::~KyraEngine() {
     362        delete _debugger;
    356363        delete _sprites;
    357364        delete _screen;
    358365        delete _res;
     
    501508                        case OSystem::EVENT_KEYDOWN:
    502509                                if (event.kbd.keycode == 'q' || event.kbd.keycode == 27) {
    503510                                        _quitFlag = true;
     511                                } else if (event.kbd.keycode == 'd') {
     512                                        _debugger->attach();
    504513                                }
    505514                                break;
    506515                        case OSystem::EVENT_MOUSEMOVE:
     
    523532                                break;
    524533                        }
    525534                }
     535
     536                if (_debugger->isAttached())
     537                        _debugger->onFrame();
     538
    526539                _sprites->updateSceneAnims();
    527540                updateAllObjectShapes();
    528541
     
    541554
    542555        while (!_quitFlag) {
    543556                int32 frameTime = (int32)_system->getMillis();
    544 
    545557                updateMousePointer();
    546558                updateGameTimers();
    547559                _sprites->updateSceneAnims();
    548560                updateAllObjectShapes();
    549                 // XXX call processPalette
     561                updateTextFade();
    550562
    551563                _handleInput = true;
    552564                delay((frameTime + _gameSpeed) - _system->getMillis());
     
    11861198       
    11871199        memset(_entranceMouseCursorTracks, 0xFFFF, sizeof(uint16)*4);
    11881200        _currentCharacter->sceneId = sceneId;
    1189         assert(sceneId < _roomFilenameTableSize);
    11901201       
    11911202        assert(sceneId < _roomTableSize);
     1203        assert(_roomTable[sceneId].nameIndex < _roomFilenameTableSize);
     1204
    11921205        Room *currentRoom = &_roomTable[sceneId];
    11931206       
    11941207        if (_currentRoom != 0xFFFF && (_features & GF_TALKIE)) {
     
    12031216       
    12041217        _currentRoom = sceneId;
    12051218       
    1206         assert(_currentCharacter->sceneId < _roomTableSize);
    12071219        int tableId = _roomTable[_currentCharacter->sceneId].nameIndex;
    1208         assert(tableId < _roomFilenameTableSize);
    12091220        char fileNameBuffer[32];
    12101221        strcpy(fileNameBuffer, _roomFilenameTable[tableId]);
    12111222        strcat(fileNameBuffer, ".DAT");
     
    12451256        startSceneScript(brandonAlive);
    12461257        setupSceneItems();
    12471258        initSceneData(facing, unk2, brandonAlive);
    1248        
     1259        setTextFadeTimerCountdown(-1);
     1260
    12491261        _loopFlag2 = 0;
    12501262        _screen->showMouse();
    12511263        if (!brandonAlive) {
     
    13121324        _sprites->updateSceneAnims();
    13131325        updateGameTimers();
    13141326        updateAllObjectShapes();
    1315         // XXX processPalette
     1327        updateTextFade();
     1328
    13161329        if (_currentCharacter->sceneId == 210) {
    13171330                // XXX game_updateKyragemFading
    13181331        }
     
    21852198                if (_system->getMillis() > timeToEnd && !hasUpdatedNPCs) {
    21862199                        hasUpdatedNPCs = true;
    21872200                        disableTimer(15);
    2188                         _charSayUnk4 = 4;
     2201                        _currHeadShape = 4;
    21892202                        animRefreshNPC(0);
    2190                         animRefreshNPC(_charSayUnk1);
     2203                        animRefreshNPC(_talkingCharNum);
    21912204
    21922205                        if (_charSayUnk2 != -1) {
    21932206                                _sprites->_animObjects[_charSayUnk2].active = 0;
     
    22082221                _screen->_curPage = currPage;
    22092222
    22102223                copyChangedObjectsForward(0);
    2211                 //processPalette();
     2224                updateTextFade();
    22122225
    22132226                if ((chatDuration < (int16)(_system->getMillis() - timeAtStart)) && chatDuration != -1)
    22142227                        break;
     
    22492262        }
    22502263
    22512264        if (convoInitialized != 0) {
    2252                 _charSayUnk1 = -1;
     2265                _talkingCharNum = -1;
    22532266                _currentCharacter->currentAnimFrame = 7;
    22542267                animRefreshNPC(0);
    22552268                updateAllObjectShapes();
     
    22572270}
    22582271
    22592272void KyraEngine::restoreChatPartnerAnimFrame(int8 charNum) {
    2260         _charSayUnk1 = -1;
     2273        _talkingCharNum = -1;
    22612274
    22622275        if (charNum > 0 && charNum < 5) {
    22632276                _characterList[charNum].currentAnimFrame = _currentChatPartnerBackupFrame;
     
    22702283}
    22712284
    22722285void KyraEngine::backupChatPartnerAnimFrame(int8 charNum) {
    2273         _charSayUnk1 = 0;
     2286        _talkingCharNum = 0;
    22742287
    22752288        if (charNum < 5 && charNum > 0)
    22762289                _currentChatPartnerBackupFrame = _characterList[charNum].currentAnimFrame;
     
    23072320}
    23082321
    23092322int KyraEngine::initCharacterChat(int8 charNum) {
    2310         if (_charSayUnk1 == -1) {
    2311                 _charSayUnk1 = 0;
     2323        if (_talkingCharNum == -1) {
     2324                _talkingCharNum = 0;
    23122325
    23132326                if (_scaleMode != 0)
    23142327                        _currentCharacter->currentAnimFrame = 7;
     
    23752388        if (charNum < 5) {
    23762389                _characterList[charNum].currentAnimFrame = startAnimFrames[charNum];
    23772390                _charSayUnk3 = charNum;
    2378                 _charSayUnk1 = charNum;
     2391                _talkingCharNum = charNum;
    23792392                animRefreshNPC(charNum);
    23802393        }
    23812394
     
    24282441        endCharacterChat(charNum, convoInitialized);
    24292442}
    24302443
    2431 void KyraEngine::drawSentenceCommand(char *sentence, int unk1) {
     2444void KyraEngine::drawSentenceCommand(char *sentence, int color) {
     2445        debug(9, "drawSentenceCommand(%s, %i)", sentence, color);
    24322446        _screen->hideMouse();
    24332447        _screen->fillRect(8, 143, 311, 152, 12);
    2434         // XXX: palette stuff
     2448
     2449        if (_startSentencePalIndex != color || _fadeText != false) {
     2450                _currSentenceColor[0] = _screen->_currentPalette[765] = _screen->_currentPalette[color*3];
     2451                _currSentenceColor[1] = _screen->_currentPalette[766] = _screen->_currentPalette[color*3+1];
     2452                _currSentenceColor[2] = _screen->_currentPalette[767] = _screen->_currentPalette[color*3+2];
     2453       
     2454                _screen->setScreenPalette(_screen->_currentPalette);
     2455                _startSentencePalIndex = 0;
     2456        }
    24352457
    24362458        printText(sentence, 8, 143, 0xFF, 12, 0);
    24372459        _screen->showMouse();
    2438         //setTextFadeTimerCountdown(_textFadeTimerCountdown);
    2439         //_palScrollEnabled = 0;
     2460        setTextFadeTimerCountdown(15);
     2461        _fadeText = false;
     2462}
     2463
     2464void KyraEngine::updateSentenceCommand(char *str1, char *str2, int color) {
     2465        debug(9, "updateSentenceCommand(%s, %s, %i)", str1, str2, color);
     2466        char sentenceCommand[500];
     2467        strncpy(sentenceCommand, str1, 500);
     2468        if (str2)
     2469                strncat(sentenceCommand, str2, 500 - strlen(sentenceCommand));
     2470
     2471        drawSentenceCommand(sentenceCommand, color);
    24402472}
    24412473
     2474void KyraEngine::updateTextFade() {
     2475        debug(9, "updateTextFade()");
     2476        if (!_fadeText)
     2477                return;
     2478       
     2479        bool finished = false;
     2480        for (int i = 0; i < 3; i++)
     2481                if (_currSentenceColor[i] > 4)
     2482                        _currSentenceColor[i] -= 4;
     2483                else
     2484                        if (_currSentenceColor[i]) {
     2485                                _currSentenceColor[i] = 0;
     2486                                finished = true;
     2487                        }
     2488               
     2489        _screen->_currentPalette[765] = _currSentenceColor[0];
     2490        _screen->_currentPalette[766] = _currSentenceColor[1];
     2491        _screen->_currentPalette[767] = _currSentenceColor[2];
     2492        _screen->setScreenPalette(_screen->_currentPalette);
     2493
     2494        if (finished) {
     2495                _fadeText = false;
     2496                _startSentencePalIndex = -1;
     2497        }
     2498
     2499}
     2500
     2501
    24422502#pragma mark -
    24432503#pragma mark - Item handling
    24442504#pragma mark -
     
    31313191                        }
    31323192                       
    31333193                        // talking head functionallity
    3134                         if (_charSayUnk1 != -1) {
     3194                        if (_talkingCharNum != -1) {
    31353195                                const int16 baseAnimFrameTable1[] = { 0x11, 0x35, 0x59, 0x00, 0x00, 0x00 };
    31363196                                const int16 baseAnimFrameTable2[] = { 0x15, 0x39, 0x5D, 0x00, 0x00, 0x00 };
    31373197                                const int8 xOffsetTable1[] = { 2, 4, 0, 5, 2, 0, 0, 0 };
     
    31413201                                if (curObject->index == 0 || curObject->index <= 4) {
    31423202                                        int shapesIndex = 0;
    31433203                                        if (curObject->index == _charSayUnk3) {
    3144                                                 shapesIndex = _charSayUnk4 + baseAnimFrameTable1[curObject->index];
     3204                                                shapesIndex = _currHeadShape + baseAnimFrameTable1[curObject->index];
    31453205                                        } else {
    31463206                                                shapesIndex = baseAnimFrameTable2[curObject->index];
    31473207                                                int temp2 = 0;
     
    40764136                        updateMousePointer();
    40774137                        updateGameTimers();
    40784138                        updateAllObjectShapes();
    4079                         // XXX processPalette
     4139                        updateTextFade();
    40804140                        if (_currentCharacter->sceneId == 210) {
    40814141                                // XXX updateKyragemFading
    40824142                                // XXX playEnd
     
    42174277#pragma mark -
    42184278
    42194279void KyraEngine::setupTimers() {
    4220         debug(9, "KyraEngine::setupTimers()");
     4280        debug(9, "setupTimers()");
    42214281        memset(_timers, 0, sizeof(_timers));
    42224282
    42234283        for (int i = 0; i < 34; i++)
     
    42264286        _timers[0].func = _timers[1].func = _timers[2].func = _timers[3].func = _timers[4].func = 0; //Unused.
    42274287        _timers[5].func = _timers[6].func = _timers[7].func = _timers[8].func = _timers[9].func = 0; //_nullsub51;
    42284288        _timers[10].func = _timers[11].func = _timers[12].func = _timers[13].func = 0; //_nullsub50;
    4229         _timers[14].func = &KyraEngine::timerCheckAnimFlag2;; //_nullsub52;
     4289        _timers[14].func = &KyraEngine::timerCheckAnimFlag2; //_nullsub52;
    42304290        _timers[15].func = &KyraEngine::timerUpdateHeadAnims; //_nullsub48;
    42314291        _timers[16].func = &KyraEngine::timerSetFlags1; //_nullsub47;
    42324292        _timers[17].func = 0; //sub_15120;
     
    42434303        _timers[28].func = 0; //offset _timerDummy6
    42444304        _timers[29].func = 0; //offset _timerDummy7,
    42454305        _timers[30].func = 0; //offset _timerDummy8,
    4246         _timers[31].func = 0; //sub_151F8;
     4306        _timers[31].func = &KyraEngine::timerFadeText; //sub_151F8;
    42474307        _timers[32].func = 0; //_nullsub61;
    42484308        _timers[33].func = 0; //_nullsub62;
    42494309
     
    42704330        _timers[33].countdown = 3;
    42714331}
    42724332
    4273 void KyraEngine::setTimer19() {
    4274         debug(9, "KyraEngine::setTimer19()");
    4275         if (_brandonStatusBit & 2) {
    4276                 // XXX call sub_3F9C
    4277                 setTimerCountdown(19, 300);
    4278         } else if (_brandonStatusBit & 0x20) {
    4279                 // XXX call sub_4110
    4280                 setTimerCountdown(19, 300);
    4281         }
    4282 }
    4283 
    42844333void KyraEngine::updateGameTimers() {
    4285         debug(9, "KyraEngine::updateGameTimers()");
    4286         void (Kyra::KyraEngine::*callback)(int timerNum);
     4334        debug(9, "updateGameTimers()");
    42874335       
    42884336        if (_system->getMillis() < _timerNextRun)
    42894337                return;
     
    42934341        for (int i = 0; i < 34; i++) {
    42944342                if (_timers[i].active && _timers[i].countdown > -1) {
    42954343                        if (_timers[i].nextRun <=_system->getMillis()) {
    4296                                 if (i < 5)
    4297                                         callback = 0;
    4298                                 else
    4299                                         callback = _timers[i].func;
    4300 
    4301                                 if (callback)
    4302                                         (*this.*callback)(i);
     4344                                if (i > 4 && _timers[i].func)
     4345                                        (*this.*_timers[i].func)(i);
    43034346
    43044347                                _timers[i].nextRun = _system->getMillis() + _timers[i].countdown * _tickLength;
    43054348
     
    43114354}
    43124355
    43134356void KyraEngine::clearNextEventTickCount() {
    4314         debug(9, "KyraEngine::clearNextEventTickCount()");
     4357        debug(9, "clearNextEventTickCount()");
    43154358        _timerNextRun = 0;
    43164359}
    43174360
    43184361int16 KyraEngine::getTimerDelay(uint8 timer) {
     4362        debug(9, "getTimerDelay(%i)", timer);
    43194363        return _timers[timer].countdown;
    43204364}
    43214365
    4322 void KyraEngine::setTimerCountdown(uint8 timer, int16 countdown) {
    4323         debug(9, "KyraEngine::setTimerCountdown(%i, %i)", timer, countdown);
     4366void KyraEngine::setTimerCountdown(uint8 timer, int32 countdown) {
     4367        debug(9, "setTimerCountdown(%i, %i)", timer, countdown);
    43244368        _timers[timer].countdown = countdown;
    43254369
    43264370        uint32 nextRun = _system->getMillis() + countdown;
     
    43294373}
    43304374
    43314375void KyraEngine::enableTimer(uint8 timer) {
    4332         debug(9, "KyraEngine::enableTimer(%i)", timer);
     4376        debug(9, "enableTimer(%i)", timer);
    43334377        _timers[timer].active = 1;
    43344378}
    43354379
    43364380void KyraEngine::disableTimer(uint8 timer) {
    4337         debug(9, "KyraEngine::disableTimer(%i)", timer);
     4381        debug(9, "disableTimer(%i)", timer);
    43384382        _timers[timer].active = 0;
    43394383}
    43404384
    43414385void KyraEngine::timerUpdateHeadAnims(int timerNum) {
    4342         debug(9, "KyraEngine::timerUpdateHeadAnims(%i)", timerNum);
     4386        debug(9, "timerUpdateHeadAnims(%i)", timerNum);
    43434387        static int8 currentFrame = 0;
    43444388        static const int8 frameTable[] = {4, 5, 4, 5, 4, 5, 0, 1, 4, 5,
    43454389                                                                4, 4, 6, 4, 8, 1, 9, 4, -1};
    43464390
    4347         if (_charSayUnk1 < 0)
     4391        if (_talkingCharNum < 0)
    43484392                return;
    43494393
    4350         _charSayUnk4 = frameTable[currentFrame];
     4394        _currHeadShape = frameTable[currentFrame];
    43514395        currentFrame++;
    43524396
    43534397        if (frameTable[currentFrame] == -1)
    43544398                currentFrame = 0;
    43554399
    43564400        animRefreshNPC(0);
    4357         animRefreshNPC(_charSayUnk1);
     4401        animRefreshNPC(_talkingCharNum);
    43584402}
    43594403
    43604404void KyraEngine::timerSetFlags1(int timerNum) {
    4361         debug(9, "KyraEngine::timerSetFlags(%i)", timerNum);
     4405        debug(9, "timerSetFlags(%i)", timerNum);
    43624406        if (_currentCharacter->sceneId == 0x1C)
    43634407                return;
    43644408
     
    43764420        }
    43774421}
    43784422
     4423void KyraEngine::timerFadeText(int timerNum) {
     4424        debug(9, "timerFadeText(%i)", timerNum);
     4425        _fadeText = true;
     4426}
     4427
     4428void KyraEngine::setTextFadeTimerCountdown(int16 countdown) {
     4429        debug(9, "setTextFadeTimerCountdown(%i)", countdown);
     4430        //if (countdown == -1)
     4431                //countdown = 32000;
     4432
     4433        setTimerCountdown(31, countdown*60);
     4434}
     4435
    43794436void KyraEngine::timerSetFlags2(int timerNum) {
     4437        debug(9, "timerSetFlags2(%i)", timerNum);
    43804438        if (!((uint32*)(_flagsTable+0x2D))[timerNum])
    43814439                ((uint32*)(_flagsTable+0x2D))[timerNum] = 1;   
    43824440}
    43834441
    43844442void KyraEngine::timerCheckAnimFlag1(int timerNum) {
    4385         debug(9, "KyraEngine::timerCheckAnimFlag1(%i)", timerNum);
     4443        debug(9, "timerCheckAnimFlag1(%i)", timerNum);
    43864444        if (_brandonStatusBit & 0x20) {
    4387                 checkSpecialAnimFlags();
     4445                checkAmuletAnimFlags();
    43884446                setTimerCountdown(18, -1);
    43894447        }
    43904448}
    43914449
    43924450void KyraEngine::timerCheckAnimFlag2(int timerNum) {
    4393         debug(9, "KyraEngine::timerCheckAnimFlag1(%i)", timerNum);
     4451        debug(9, "timerCheckAnimFlag1(%i)", timerNum);
    43944452        if (_brandonStatusBit & 0x2) {
    4395                 checkSpecialAnimFlags();
     4453                checkAmuletAnimFlags();
    43964454                setTimerCountdown(14, -1);
    43974455        }
    43984456}
    43994457
    4400 void KyraEngine::checkSpecialAnimFlags() {
    4401         debug(9, "KyraEngine::checkSpecialAnimFlags()");
     4458void KyraEngine::checkAmuletAnimFlags() {
     4459        debug(9, "checkSpecialAnimFlags()");
    44024460        if (_brandonStatusBit & 2) {
    44034461                warning("STUB: playSpecialAnim1");
    44044462                // XXX
     
    44134471}
    44144472
    44154473void KyraEngine::timerRedrawAmulet(int timerNum) {
     4474        debug(9, "timerRedrawAmulet(%i)", timerNum);
    44164475        if (queryGameFlag(241)) {
    44174476                drawAmulet();
    4418                 setTimerCountdown(0x13, -1);
     4477                setTimerCountdown(19, -1);
    44194478        }
    44204479}
    44214480
    44224481void KyraEngine::drawAmulet() {
     4482        debug(9, "drawAmulet()");
    44234483        static const int16 amuletTable1[] = {0x167, 0x162, 0x15D, 0x158, 0x153, 0x150, 0x155, 0x15A, 0x15F, 0x164, 0x145, -1};
    44244484        static const int16 amuletTable3[] = {0x167, 0x162, 0x15D, 0x158, 0x153, 0x14F, 0x154, 0x159, 0x15E, 0x163, 0x144, -1};
    44254485        static const int16 amuletTable2[] = {0x167, 0x162, 0x15D, 0x158, 0x153, 0x152, 0x157, 0x15C, 0x161, 0x166, 0x147, -1};
  • kyra/kyra.h

    diff --exclude=.cvsignore --exclude=.deps --exclude=CVS -Pur ./scummvmcvs/kyra/kyra.h scummvm/kyra/kyra.h
    old new  
    142142struct ScriptState;
    143143struct ScriptData;
    144144class ScriptHelper;
     145class Debugger;
    145146class KyraEngine;
    146147
    147148struct Timer {
    148149        bool active;
    149         int16 countdown;
     150        int32 countdown;
    150151        uint32 nextRun;
    151152        void (KyraEngine::*func)(int timerNum);
    152153};
    153154
    154155class KyraEngine : public Engine {
    155156        friend class MusicPlayer;
     157        friend class Debugger;
    156158public:
    157159
    158160        enum {
     
    202204        void printTalkTextMessage(const char *text, int x, int y, uint8 color, int srcPage, int dstPage);
    203205        void restoreTalkTextMessageBkgd(int srcPage, int dstPage);
    204206        void drawSentenceCommand(char *sentence, int unk1);
     207        void updateSentenceCommand(char *str1, char *str2, int unk1);
     208        void updateTextFade();
    205209
    206210        void updateGameTimers();
    207211        void clearNextEventTickCount();
    208         void setTimerCountdown(uint8 timer, int16 countdown);
     212        void setTimerCountdown(uint8 timer, int32 countdown);
    209213        int16 getTimerDelay(uint8 timer);
    210214        void enableTimer(uint8 timer);
    211215        void disableTimer(uint8 timer);
     
    532536        void timerSetFlags2(int timerNum);
    533537        void timerCheckAnimFlag1(int timerNum);
    534538        void timerCheckAnimFlag2(int timerNum);
    535         void checkSpecialAnimFlags();
     539        void checkAmuletAnimFlags();
    536540        void timerRedrawAmulet(int timerNum);
     541        void timerFadeText(int timerNum);
    537542        void drawAmulet();
    538 
     543        void setTextFadeTimerCountdown(int16 countdown);
    539544        uint8 _game;
    540545        bool _fastMode;
    541546        bool _quitFlag;
     
    605610        int _lastFindWayRet;
    606611        int *_movFacingTable;
    607612       
    608         int8 _charSayUnk1;
     613        int8 _talkingCharNum;
    609614        int8 _charSayUnk2;
    610615        int8 _charSayUnk3;
    611         int8 _charSayUnk4;
     616        int8 _currHeadShape;
     617        uint8 _currSentenceColor[3];
     618        int8 _startSentencePalIndex;
     619        bool _fadeText;
    612620
    613621        uint8 _configTalkspeed;
    614622        AnimObject *_objectQueue;
     
    626634        SeqPlayer *_seq;
    627635        Sprites *_sprites;
    628636        ScriptHelper *_scriptInterpreter;
     637        Debugger *_debugger;
    629638       
    630639        ScriptState *_scriptMain;
    631640        ScriptData *_npcScriptData;
  • kyra/module.mk

    diff --exclude=.cvsignore --exclude=.deps --exclude=CVS -Pur ./scummvmcvs/kyra/module.mk scummvm/kyra/module.mk
    old new  
    1010        kyra/sound.o \
    1111        kyra/staticres.o \
    1212        kyra/sprites.o \
    13         kyra/wsamovie.o
     13        kyra/wsamovie.o \
     14        kyra/debugger.o
    1415
    1516MODULE_DIRS += \
    1617        kyra
  • kyra/script_v1.cpp

    diff --exclude=.cvsignore --exclude=.deps --exclude=CVS -Pur ./scummvmcvs/kyra/script_v1.cpp scummvm/kyra/script_v1.cpp
    old new  
    573573
    574574int KyraEngine::cmd_pauseSeconds(ScriptState *script) {
    575575        debug(3, "cmd_pauseSeconds(0x%X) (%d)", script, stackPos(0));
    576         delay(stackPos(0)*1000);
     576        if (stackPos(0) > 0)
     577                delay(stackPos(0)*1000);
    577578        return 0;
    578579}
    579580
     
    600601
    601602int KyraEngine::cmd_forceBrandonToNormal(ScriptState *script) {
    602603        debug(3, "cmd_forceBrandonToNormal(0x%X) ()", script);
    603         setTimer19();
     604        checkAmuletAnimFlags();
    604605        return 0;
    605606}
    606607
     
    681682        _screen->hideMouse();
    682683        wsa_play(_wsaObjects[wsaIndex], frame, xpos, ypos, 0);
    683684        // XXX
    684         waitTicks(waitTime);
    685         _sprites->updateSceneAnims();
    686         updateAllObjectShapes();
     685        delay(waitTime * _tickLength);
    687686        _screen->updateScreen();
    688687        _screen->showMouse();
    689688        return 0;
     
    879878        _screen->hideMouse();
    880879        wsa_play(_wsaObjects[wsaIndex], frame, xpos, ypos, 2);
    881880        // XXX
    882         waitTicks(waitTime);
     881        //waitTicks(waitTime);
     882        delay(waitTime*_tickLength);
    883883        _sprites->updateSceneAnims();
    884884        updateAllObjectShapes();
    885885        _screen->showMouse();
     
    11281128                        updateMousePointer();
    11291129                        updateGameTimers();
    11301130                        updateAllObjectShapes();
    1131                         // XXX processPalette();
     1131                        updateTextFade();
    11321132                        if ((nextFrame - _system->getMillis()) >= 10)
    11331133                                delay(10);
    11341134                }