Ticket #8495: kyra-debugandtextfade_v3.patch

File kyra-debugandtextfade_v3.patch, 28.8 KB (added by vinterstum, 18 years ago)

v3, against current CVS

  • 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        uint direction = 0;
     56        if (argc > 1) {
     57                uint room = atoi(argv[1]);
     58
     59                if (argc > 2)
     60                        direction = atoi(argv[2]);
     61                else {
     62                        if (_vm->_roomTable[room].northExit != 0xff)
     63                                direction = 3;
     64                        else if (_vm->_roomTable[room].eastExit != 0xff)
     65                                direction = 4;
     66                        else if (_vm->_roomTable[room].southExit != 0xff)
     67                                direction = 1;
     68                        else if (_vm->_roomTable[room].westExit != 0xff)
     69                                direction = 2;
     70                }
     71
     72                // Dirty way of hiding the debug console while the room entry scripts are running,
     73                // otherwise the graphics didn't update.
     74                _vm->_system->hideOverlay();
     75                _vm->_currentCharacter->facing = direction;
     76               
     77                _vm->enterNewScene(room, _vm->_currentCharacter->facing, 0, 0, 1);
     78                _vm->_system->showOverlay();
     79                _detach_now = true;
     80                return false;
     81        }
     82
     83        DebugPrintf("Syntax: room <roomnum> <direction>\n");
     84        return true;
     85}
     86
     87bool Debugger::cmd_exit(int argc, const char **argv) {
     88        _detach_now = true;
     89        return false;
     90}
     91
     92bool Debugger::cmd_help(int argc, const char **argv) {
     93        // console normally has 39 line width
     94        // wrap around nicely
     95        int width = 0, size, i;
     96
     97        DebugPrintf("Commands are:\n");
     98        for (i = 0 ; i < _dcmd_count ; i++) {
     99                size = strlen(_dcmds[i].name) + 1;
     100
     101                if ((width + size) >= 39) {
     102                        DebugPrintf("\n");
     103                        width = size;
     104                } else
     105                        width += size;
     106
     107                DebugPrintf("%s ", _dcmds[i].name);
     108        }
     109        DebugPrintf("\n");
     110        return true;
     111}
     112
     113bool Debugger::cmd_listRooms(int argc, const char **argv) {
     114        for (int i = 0; i < _vm->_roomTableSize; i++) {
     115                DebugPrintf("%-3i: %-10s", i, _vm->_roomFilenameTable[_vm->_roomTable[i].nameIndex]);
     116                if (!(i % 8))
     117                        DebugPrintf("\n");
     118        }
     119        DebugPrintf("\n");
     120        DebugPrintf("Current room: %i\n", _vm->_currentRoom);
     121        return true;
     122}
     123
     124bool Debugger::cmd_listFlags(int argc, const char **argv) {
     125        for (int i = 0; i < (int)sizeof(_vm->_flagsTable)*8; i++) {
     126                DebugPrintf("(%-3i): %-5i", i, _vm->queryGameFlag(i));
     127                if (!(i % 10))
     128                        DebugPrintf("\n");
     129        }
     130        DebugPrintf("\n");
     131        return true;
     132}
     133
     134bool Debugger::cmd_toggleFlag(int argc, const char **argv) {
     135        if (argc > 1) {
     136                uint flag = atoi(argv[1]);
     137                if (_vm->queryGameFlag(flag))
     138                        _vm->resetGameFlag(flag);
     139                else
     140                        _vm->setGameFlag(flag);
     141                DebugPrintf("Flag %i is now %i\n", flag, _vm->queryGameFlag(flag));
     142        } else
     143                DebugPrintf("Syntax: toggleflag <flag>\n");
     144
     145        return true;
     146}
     147
     148bool Debugger::cmd_queryFlag(int argc, const char **argv) {
     149        if (argc > 1) {
     150                uint flag = atoi(argv[1]);
     151                DebugPrintf("Flag %i is %i\n", flag, _vm->queryGameFlag(flag));
     152        } else
     153                DebugPrintf("Syntax: queryflag <flag>\n");
     154
     155        return true;
     156}
     157
     158bool Debugger::cmd_listTimers(int argc, const char **argv) {
     159        for (int i = 0; i < ARRAYSIZE(_vm->_timers); i++)
     160                DebugPrintf("Timer %-2i: Active: %-3s Countdown: %-6i\n", i, _vm->_timers[i].active ? "Yes" : "No", _vm->_timers[i].countdown);
     161
     162        return true;
     163}
     164
     165bool Debugger::cmd_setTimerCountdown(int argc, const char **argv) {
     166        if (argc > 2) {
     167                uint timer = atoi(argv[1]);
     168                uint countdown = atoi(argv[2]);
     169                _vm->setTimerCountdown(timer, countdown);       
     170                DebugPrintf("Timer %i now has countdown %i\n", timer, _vm->_timers[timer].countdown);
     171        } else
     172                DebugPrintf("Syntax: settimercountdown <timer> <countdown>\n");
     173
     174        return true;
     175}
     176
     177} // End of namespace Kyra
     178
  • 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  
    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' && !_debugger->isAttached()) {
     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");
     
    12411252        if (!brandonAlive) {
    12421253                // XXX
    12431254        }
    1244        
     1255
    12451256        startSceneScript(brandonAlive);
    12461257        setupSceneItems();
     1258       
    12471259        initSceneData(facing, unk2, brandonAlive);
    12481260       
    12491261        _loopFlag2 = 0;
     
    13121324        _sprites->updateSceneAnims();
    13131325        updateGameTimers();
    13141326        updateAllObjectShapes();
    1315         // XXX processPalette
     1327        updateTextFade();
     1328
    13161329        if (_currentCharacter->sceneId == 210) {
    13171330                // XXX game_updateKyragemFading
    13181331        }
     
    19531966        while (_scriptInterpreter->validScript(_scriptClick))
    19541967                _scriptInterpreter->runScript(_scriptClick);
    19551968
     1969        setTextFadeTimerCountdown(-1);
    19561970        if (_currentCharacter->sceneId == 0xD2) {
    19571971                // XXX
    19581972        }
     
    21852199                if (_system->getMillis() > timeToEnd && !hasUpdatedNPCs) {
    21862200                        hasUpdatedNPCs = true;
    21872201                        disableTimer(15);
    2188                         _charSayUnk4 = 4;
     2202                        _currHeadShape = 4;
    21892203                        animRefreshNPC(0);
    2190                         animRefreshNPC(_charSayUnk1);
     2204                        animRefreshNPC(_talkingCharNum);
    21912205
    21922206                        if (_charSayUnk2 != -1) {
    21932207                                _sprites->_animObjects[_charSayUnk2].active = 0;
     
    22082222                _screen->_curPage = currPage;
    22092223
    22102224                copyChangedObjectsForward(0);
    2211                 //processPalette();
     2225                updateTextFade();
    22122226
    22132227                if ((chatDuration < (int16)(_system->getMillis() - timeAtStart)) && chatDuration != -1)
    22142228                        break;
     
    22492263        }
    22502264
    22512265        if (convoInitialized != 0) {
    2252                 _charSayUnk1 = -1;
     2266                _talkingCharNum = -1;
    22532267                _currentCharacter->currentAnimFrame = 7;
    22542268                animRefreshNPC(0);
    22552269                updateAllObjectShapes();
     
    22572271}
    22582272
    22592273void KyraEngine::restoreChatPartnerAnimFrame(int8 charNum) {
    2260         _charSayUnk1 = -1;
     2274        _talkingCharNum = -1;
    22612275
    22622276        if (charNum > 0 && charNum < 5) {
    22632277                _characterList[charNum].currentAnimFrame = _currentChatPartnerBackupFrame;
     
    22702284}
    22712285
    22722286void KyraEngine::backupChatPartnerAnimFrame(int8 charNum) {
    2273         _charSayUnk1 = 0;
     2287        _talkingCharNum = 0;
    22742288
    22752289        if (charNum < 5 && charNum > 0)
    22762290                _currentChatPartnerBackupFrame = _characterList[charNum].currentAnimFrame;
     
    23072321}
    23082322
    23092323int KyraEngine::initCharacterChat(int8 charNum) {
    2310         if (_charSayUnk1 == -1) {
    2311                 _charSayUnk1 = 0;
     2324        if (_talkingCharNum == -1) {
     2325                _talkingCharNum = 0;
    23122326
    23132327                if (_scaleMode != 0)
    23142328                        _currentCharacter->currentAnimFrame = 7;
     
    23752389        if (charNum < 5) {
    23762390                _characterList[charNum].currentAnimFrame = startAnimFrames[charNum];
    23772391                _charSayUnk3 = charNum;
    2378                 _charSayUnk1 = charNum;
     2392                _talkingCharNum = charNum;
    23792393                animRefreshNPC(charNum);
    23802394        }
    23812395
     
    24282442        endCharacterChat(charNum, convoInitialized);
    24292443}
    24302444
    2431 void KyraEngine::drawSentenceCommand(char *sentence, int unk1) {
     2445void KyraEngine::drawSentenceCommand(char *sentence, int color) {
     2446        debug(9, "drawSentenceCommand('%s', %i)", sentence, color);
    24322447        _screen->hideMouse();
    24332448        _screen->fillRect(8, 143, 311, 152, 12);
    2434         // XXX: palette stuff
     2449
     2450        if (_startSentencePalIndex != color || _fadeText != false) {
     2451                _currSentenceColor[0] = _screen->_currentPalette[765] = _screen->_currentPalette[color*3];
     2452                _currSentenceColor[1] = _screen->_currentPalette[766] = _screen->_currentPalette[color*3+1];
     2453                _currSentenceColor[2] = _screen->_currentPalette[767] = _screen->_currentPalette[color*3+2];
     2454       
     2455                _screen->setScreenPalette(_screen->_currentPalette);
     2456                _startSentencePalIndex = 0;
     2457        }
    24352458
    24362459        printText(sentence, 8, 143, 0xFF, 12, 0);
    24372460        _screen->showMouse();
    2438         //setTextFadeTimerCountdown(_textFadeTimerCountdown);
    2439         //_palScrollEnabled = 0;
     2461        setTextFadeTimerCountdown(15);
     2462        _fadeText = false;
     2463}
     2464
     2465void KyraEngine::updateSentenceCommand(char *str1, char *str2, int color) {
     2466        debug(9, "updateSentenceCommand('%s', '%s', %i)", str1, str2, color);
     2467        char sentenceCommand[500];
     2468        strncpy(sentenceCommand, str1, 500);
     2469        if (str2)
     2470                strncat(sentenceCommand, str2, 500 - strlen(sentenceCommand));
     2471
     2472        drawSentenceCommand(sentenceCommand, color);
     2473}
     2474
     2475void KyraEngine::updateTextFade() {
     2476        debug(9, "updateTextFade()");
     2477        if (!_fadeText)
     2478                return;
     2479       
     2480        bool finished = false;
     2481        for (int i = 0; i < 3; i++)
     2482                if (_currSentenceColor[i] > 4)
     2483                        _currSentenceColor[i] -= 4;
     2484                else
     2485                        if (_currSentenceColor[i]) {
     2486                                _currSentenceColor[i] = 0;
     2487                                finished = true;
     2488                        }
     2489               
     2490        _screen->_currentPalette[765] = _currSentenceColor[0];
     2491        _screen->_currentPalette[766] = _currSentenceColor[1];
     2492        _screen->_currentPalette[767] = _currSentenceColor[2];
     2493        _screen->setScreenPalette(_screen->_currentPalette);
     2494
     2495        if (finished) {
     2496                _fadeText = false;
     2497                _startSentencePalIndex = -1;
     2498        }
     2499
    24402500}
    24412501
     2502
    24422503#pragma mark -
    24432504#pragma mark - Item handling
    24442505#pragma mark -
     
    31313192                        }
    31323193                       
    31333194                        // talking head functionallity
    3134                         if (_charSayUnk1 != -1) {
     3195                        if (_talkingCharNum != -1) {
    31353196                                const int16 baseAnimFrameTable1[] = { 0x11, 0x35, 0x59, 0x00, 0x00, 0x00 };
    31363197                                const int16 baseAnimFrameTable2[] = { 0x15, 0x39, 0x5D, 0x00, 0x00, 0x00 };
    31373198                                const int8 xOffsetTable1[] = { 2, 4, 0, 5, 2, 0, 0, 0 };
     
    31413202                                if (curObject->index == 0 || curObject->index <= 4) {
    31423203                                        int shapesIndex = 0;
    31433204                                        if (curObject->index == _charSayUnk3) {
    3144                                                 shapesIndex = _charSayUnk4 + baseAnimFrameTable1[curObject->index];
     3205                                                shapesIndex = _currHeadShape + baseAnimFrameTable1[curObject->index];
    31453206                                        } else {
    31463207                                                shapesIndex = baseAnimFrameTable2[curObject->index];
    31473208                                                int temp2 = 0;
     
    40764137                        updateMousePointer();
    40774138                        updateGameTimers();
    40784139                        updateAllObjectShapes();
    4079                         // XXX processPalette
     4140                        updateTextFade();
    40804141                        if (_currentCharacter->sceneId == 210) {
    40814142                                // XXX updateKyragemFading
    40824143                                // XXX playEnd
     
    42174278#pragma mark -
    42184279
    42194280void KyraEngine::setupTimers() {
    4220         debug(9, "KyraEngine::setupTimers()");
     4281        debug(9, "setupTimers()");
    42214282        memset(_timers, 0, sizeof(_timers));
    42224283
    42234284        for (int i = 0; i < 34; i++)
     
    42264287        _timers[0].func = _timers[1].func = _timers[2].func = _timers[3].func = _timers[4].func = 0; //Unused.
    42274288        _timers[5].func = _timers[6].func = _timers[7].func = _timers[8].func = _timers[9].func = 0; //_nullsub51;
    42284289        _timers[10].func = _timers[11].func = _timers[12].func = _timers[13].func = 0; //_nullsub50;
    4229         _timers[14].func = &KyraEngine::timerCheckAnimFlag2;; //_nullsub52;
     4290        _timers[14].func = &KyraEngine::timerCheckAnimFlag2; //_nullsub52;
    42304291        _timers[15].func = &KyraEngine::timerUpdateHeadAnims; //_nullsub48;
    42314292        _timers[16].func = &KyraEngine::timerSetFlags1; //_nullsub47;
    42324293        _timers[17].func = 0; //sub_15120;
     
    42434304        _timers[28].func = 0; //offset _timerDummy6
    42444305        _timers[29].func = 0; //offset _timerDummy7,
    42454306        _timers[30].func = 0; //offset _timerDummy8,
    4246         _timers[31].func = 0; //sub_151F8;
     4307        _timers[31].func = &KyraEngine::timerFadeText; //sub_151F8;
    42474308        _timers[32].func = 0; //_nullsub61;
    42484309        _timers[33].func = 0; //_nullsub62;
    42494310
     
    42704331        _timers[33].countdown = 3;
    42714332}
    42724333
    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 
    42844334void KyraEngine::updateGameTimers() {
    4285         debug(9, "KyraEngine::updateGameTimers()");
    4286         void (Kyra::KyraEngine::*callback)(int timerNum);
     4335        debug(9, "updateGameTimers()");
    42874336       
    42884337        if (_system->getMillis() < _timerNextRun)
    42894338                return;
     
    42934342        for (int i = 0; i < 34; i++) {
    42944343                if (_timers[i].active && _timers[i].countdown > -1) {
    42954344                        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);
     4345                                if (i > 4 && _timers[i].func)
     4346                                        (*this.*_timers[i].func)(i);
    43034347
    43044348                                _timers[i].nextRun = _system->getMillis() + _timers[i].countdown * _tickLength;
    43054349
     
    43114355}
    43124356
    43134357void KyraEngine::clearNextEventTickCount() {
    4314         debug(9, "KyraEngine::clearNextEventTickCount()");
     4358        debug(9, "clearNextEventTickCount()");
    43154359        _timerNextRun = 0;
    43164360}
    43174361
    43184362int16 KyraEngine::getTimerDelay(uint8 timer) {
     4363        debug(9, "getTimerDelay(%i)", timer);
    43194364        return _timers[timer].countdown;
    43204365}
    43214366
    4322 void KyraEngine::setTimerCountdown(uint8 timer, int16 countdown) {
    4323         debug(9, "KyraEngine::setTimerCountdown(%i, %i)", timer, countdown);
     4367void KyraEngine::setTimerCountdown(uint8 timer, int32 countdown) {
     4368        debug(9, "setTimerCountdown(%i, %i)", timer, countdown);
    43244369        _timers[timer].countdown = countdown;
    43254370
    43264371        uint32 nextRun = _system->getMillis() + countdown;
     
    43294374}
    43304375
    43314376void KyraEngine::enableTimer(uint8 timer) {
    4332         debug(9, "KyraEngine::enableTimer(%i)", timer);
     4377        debug(9, "enableTimer(%i)", timer);
    43334378        _timers[timer].active = 1;
    43344379}
    43354380
    43364381void KyraEngine::disableTimer(uint8 timer) {
    4337         debug(9, "KyraEngine::disableTimer(%i)", timer);
     4382        debug(9, "disableTimer(%i)", timer);
    43384383        _timers[timer].active = 0;
    43394384}
    43404385
    43414386void KyraEngine::timerUpdateHeadAnims(int timerNum) {
    4342         debug(9, "KyraEngine::timerUpdateHeadAnims(%i)", timerNum);
     4387        debug(9, "timerUpdateHeadAnims(%i)", timerNum);
    43434388        static int8 currentFrame = 0;
    43444389        static const int8 frameTable[] = {4, 5, 4, 5, 4, 5, 0, 1, 4, 5,
    43454390                                                                4, 4, 6, 4, 8, 1, 9, 4, -1};
    43464391
    4347         if (_charSayUnk1 < 0)
     4392        if (_talkingCharNum < 0)
    43484393                return;
    43494394
    4350         _charSayUnk4 = frameTable[currentFrame];
     4395        _currHeadShape = frameTable[currentFrame];
    43514396        currentFrame++;
    43524397
    43534398        if (frameTable[currentFrame] == -1)
    43544399                currentFrame = 0;
    43554400
    43564401        animRefreshNPC(0);
    4357         animRefreshNPC(_charSayUnk1);
     4402        animRefreshNPC(_talkingCharNum);
    43584403}
    43594404
    43604405void KyraEngine::timerSetFlags1(int timerNum) {
    4361         debug(9, "KyraEngine::timerSetFlags(%i)", timerNum);
     4406        debug(9, "timerSetFlags(%i)", timerNum);
    43624407        if (_currentCharacter->sceneId == 0x1C)
    43634408                return;
    43644409
     
    43764421        }
    43774422}
    43784423
     4424void KyraEngine::timerFadeText(int timerNum) {
     4425        debug(9, "timerFadeText(%i)", timerNum);
     4426        _fadeText = true;
     4427}
     4428
     4429void KyraEngine::setTextFadeTimerCountdown(int16 countdown) {
     4430        debug(9, "setTextFadeTimerCountdown(%i)", countdown);
     4431        //if (countdown == -1)
     4432                //countdown = 32000;
     4433
     4434        setTimerCountdown(31, countdown*60);
     4435}
     4436
    43794437void KyraEngine::timerSetFlags2(int timerNum) {
     4438        debug(9, "timerSetFlags2(%i)", timerNum);
    43804439        if (!((uint32*)(_flagsTable+0x2D))[timerNum])
    43814440                ((uint32*)(_flagsTable+0x2D))[timerNum] = 1;   
    43824441}
    43834442
    43844443void KyraEngine::timerCheckAnimFlag1(int timerNum) {
    4385         debug(9, "KyraEngine::timerCheckAnimFlag1(%i)", timerNum);
     4444        debug(9, "timerCheckAnimFlag1(%i)", timerNum);
    43864445        if (_brandonStatusBit & 0x20) {
    4387                 checkSpecialAnimFlags();
     4446                checkAmuletAnimFlags();
    43884447                setTimerCountdown(18, -1);
    43894448        }
    43904449}
    43914450
    43924451void KyraEngine::timerCheckAnimFlag2(int timerNum) {
    4393         debug(9, "KyraEngine::timerCheckAnimFlag1(%i)", timerNum);
     4452        debug(9, "timerCheckAnimFlag1(%i)", timerNum);
    43944453        if (_brandonStatusBit & 0x2) {
    4395                 checkSpecialAnimFlags();
     4454                checkAmuletAnimFlags();
    43964455                setTimerCountdown(14, -1);
    43974456        }
    43984457}
    43994458
    4400 void KyraEngine::checkSpecialAnimFlags() {
    4401         debug(9, "KyraEngine::checkSpecialAnimFlags()");
     4459void KyraEngine::checkAmuletAnimFlags() {
     4460        debug(9, "checkSpecialAnimFlags()");
    44024461        if (_brandonStatusBit & 2) {
    44034462                warning("STUB: playSpecialAnim1");
    44044463                // XXX
     
    44134472}
    44144473
    44154474void KyraEngine::timerRedrawAmulet(int timerNum) {
     4475        debug(9, "timerRedrawAmulet(%i)", timerNum);
    44164476        if (queryGameFlag(241)) {
    44174477                drawAmulet();
    4418                 setTimerCountdown(0x13, -1);
     4478                setTimerCountdown(19, -1);
    44194479        }
    44204480}
    44214481
    44224482void KyraEngine::drawAmulet() {
     4483        debug(9, "drawAmulet()");
    44234484        static const int16 amuletTable1[] = {0x167, 0x162, 0x15D, 0x158, 0x153, 0x150, 0x155, 0x15A, 0x15F, 0x164, 0x145, -1};
    44244485        static const int16 amuletTable3[] = {0x167, 0x162, 0x15D, 0x158, 0x153, 0x14F, 0x154, 0x159, 0x15E, 0x163, 0x144, -1};
    44254486        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);
     
    336340        int cmd_shakeScreen(ScriptState *script);
    337341        int cmd_createAmuletJewel(ScriptState *script);
    338342        int cmd_setSceneAnimCurrXY(ScriptState *script);
    339         int cmd_Poison_Brandon_And_Remaps(ScriptState *script);
     343        int cmd_poisonBrandonAndRemaps(ScriptState *script);
    340344        int cmd_fillFlaskWithWater(ScriptState *script);
    341345        int cmd_getCharactersMovementDelay(ScriptState *script);
    342346        int cmd_getBirthstoneGem(ScriptState *script);
     
    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

    Binary files ./scummvmcvs/kyra/libkyra.a and scummvm/kyra/libkyra.a differ
    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
     
    657658                if (wsaFrame >= wsa_getNumFrames(_wsaObjects[wsaIndex]))
    658659                        running = false;
    659660               
    660                 // XXX
    661                 waitTicks(waitTime);
     661                delay(waitTime * _tickLength);
    662662                if (worldUpdate) {
    663663                        _sprites->updateSceneAnims();
    664664                        updateAllObjectShapes();
     
    680680        int wsaIndex = stackPos(4);
    681681        _screen->hideMouse();
    682682        wsa_play(_wsaObjects[wsaIndex], frame, xpos, ypos, 0);
    683         // XXX
    684         waitTicks(waitTime);
    685         _sprites->updateSceneAnims();
    686         updateAllObjectShapes();
     683        delay(waitTime * _tickLength);
    687684        _screen->updateScreen();
    688685        _screen->showMouse();
    689686        return 0;
     
    878875       
    879876        _screen->hideMouse();
    880877        wsa_play(_wsaObjects[wsaIndex], frame, xpos, ypos, 2);
    881         // XXX
    882         waitTicks(waitTime);
     878        delay(waitTime*_tickLength);
    883879        _sprites->updateSceneAnims();
    884880        updateAllObjectShapes();
    885881        _screen->showMouse();
     
    906902                        int frame = startFrame;
    907903                        while (endFrame >= frame) {
    908904                                wsa_play(_wsaObjects[wsaIndex], frame, xpos, ypos, 0);
    909                                 // XXX
    910                                 waitTicks(waitTime);
    911                                 _sprites->updateSceneAnims();
    912                                 updateAllObjectShapes();
     905                                delay(waitTime * _tickLength);
     906                                _screen->updateScreen();
    913907                                ++frame;
    914908                        }
    915909                } else {
    916910                        int frame = endFrame;
    917911                        while (startFrame <= frame) {
    918912                                wsa_play(_wsaObjects[wsaIndex], frame, xpos, ypos, 0);
    919                                 // XXX
    920                                 waitTicks(waitTime);
    921                                 _sprites->updateSceneAnims();
    922                                 updateAllObjectShapes();
     913                                delay(waitTime * _tickLength);
     914                                _screen->updateScreen();
    923915                                --frame;
    924916                        }
    925917                }
     
    11281120                        updateMousePointer();
    11291121                        updateGameTimers();
    11301122                        updateAllObjectShapes();
    1131                         // XXX processPalette();
     1123                        updateTextFade();
    11321124                        if ((nextFrame - _system->getMillis()) >= 10)
    11331125                                delay(10);
    11341126                }
     
    11571149}
    11581150
    11591151int KyraEngine::cmd_preserveAllObjectBackgrounds(ScriptState *script) {
    1160         warning("STUB: cmd_preserveAllObjectBackgrounds");
     1152        debug(3, "cmd_preserveAllObjectBackgrounds(0x%X) ()", script);
     1153        preserveAllBackgrounds();
    11611154        return 0;
    11621155}
    11631156
     
    12831276        return 0;
    12841277}
    12851278
    1286 int KyraEngine::cmd_Poison_Brandon_And_Remaps(ScriptState *script) {
    1287         warning("STUB: cmd_Poison_Brandon_And_Remaps");
     1279int KyraEngine::cmd_poisonBrandonAndRemaps(ScriptState *script) {
     1280        warning("STUB: cmdPoisonBrandonAndRemaps");
    12881281        return 0;
    12891282}
    12901283
     
    14971490}
    14981491
    14991492int KyraEngine::cmd_protectCommandLine(ScriptState *script) {
    1500         warning("STUB: cmd_protectCommandLine");
    1501         return 0;
     1493        debug(3, "cmd_protectCommandLine(0x%X) (%d)", script, stackPos(0));
     1494        return stackPos(0);
    15021495}
    15031496
    15041497int KyraEngine::cmd_pauseMusicSeconds(ScriptState *script) {
  • kyra/sprites.cpp

    diff --exclude=.cvsignore --exclude=.deps --exclude=CVS -Pur ./scummvmcvs/kyra/sprites.cpp scummvm/kyra/sprites.cpp
    old new  
    344344                                data += 2;
    345345                                debug(5, "func: Play sound");
    346346                                debug(5, "Sound index %i", READ_LE_UINT16(data));
    347                                 _engine->snd_playSoundEffect(READ_LE_UINT16(data));
     347                                //_engine->snd_playSoundEffect(READ_LE_UINT16(data));
    348348                                data += 2;
    349349                                break;
    350350                        case 0xFFB1:
     
    363363                                data += 2;
    364364                                debug(5, "Percentage %i", READ_LE_UINT16(data));
    365365                                rndNr = _rnd.getRandomNumber(100);
    366                                 if (rndNr <= READ_LE_UINT16(data))
    367                                         _engine->snd_playSoundEffect(sound);
     366                                //if (rndNr <= READ_LE_UINT16(data))
     367                                        //_engine->snd_playSoundEffect(sound);
    368368                                data += 2;
    369369                                break;
    370370                        case 0xFFA7:
  • kyra/staticres.cpp

    diff --exclude=.cvsignore --exclude=.deps --exclude=CVS -Pur ./scummvmcvs/kyra/staticres.cpp scummvm/kyra/staticres.cpp
    old new  
    497497        // 0x6c
    498498        Opcode(cmd_createAmuletJewel),
    499499        Opcode(cmd_setSceneAnimCurrXY),
    500         Opcode(cmd_Poison_Brandon_And_Remaps),
     500        Opcode(cmd_poisonBrandonAndRemaps),
    501501        Opcode(cmd_fillFlaskWithWater),
    502502        // 0x70
    503503        Opcode(cmd_getCharactersMovementDelay),