diff options
-rw-r--r-- | engines/access/amazon/amazon_room.cpp | 2 | ||||
-rw-r--r-- | engines/access/room.cpp | 2 | ||||
-rw-r--r-- | engines/access/scripts.cpp | 48 | ||||
-rw-r--r-- | engines/access/scripts.h | 6 |
4 files changed, 30 insertions, 28 deletions
diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp index da7b7e18ee..df2a6b759d 100644 --- a/engines/access/amazon/amazon_room.cpp +++ b/engines/access/amazon/amazon_room.cpp @@ -114,7 +114,7 @@ void AmazonRoom::roomSet() { _vm->_numAnimTimers = 0; _vm->_scripts->_sequence = 1000; _vm->_scripts->searchForSequence(); - _vm->_scripts->executeCommand(); + _vm->_scripts->executeScript(); } void AmazonRoom::roomMenu() { diff --git a/engines/access/room.cpp b/engines/access/room.cpp index e3e3700b51..80ab3329ac 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -231,7 +231,7 @@ void Room::loadRoomData(const byte *roomData) { void Room::roomLoop() { _vm->_scripts->_sequence = 2000; _vm->_scripts->searchForSequence(); - _vm->_scripts->executeCommand(); + _vm->_scripts->executeScript(); } void Room::setupRoom() { diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 6652b2922c..6513f34a86 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -28,28 +28,7 @@ namespace Access { -const ScriptMethodPtr COMMAND_LIST[] = { - &Scripts::CMDENDOBJECT, &Scripts::CMDJUMPLOOK, &Scripts::CMDJUMPHELP, &Scripts::CMDJUMPGET, &Scripts::CMDJUMPMOVE, - &Scripts::CMDJUMPUSE, &Scripts::CMDJUMPTALK, &Scripts::CMDNULL, &Scripts::CMDPRINT, &Scripts::CMDRETPOS, &Scripts::CMDANIM, - &Scripts::CMDSETFLAG, &Scripts::CMDCHECKFLAG, &Scripts::CMDGOTO, &Scripts::CMDSETINV, &Scripts::CMDSETINV, - &Scripts::CMDCHECKINV, &Scripts::CMDSETTEX, &Scripts::CMDNEWROOM, &Scripts::CMDCONVERSE, &Scripts::CMDCHECKFRAME, - &Scripts::CMDCHECKANIM, &Scripts::CMDSND, &Scripts::CMDRETNEG, &Scripts::CMDRETPOS, &Scripts::CMDCHECKLOC, &Scripts::CMDSETANIM, - &Scripts::CMDDISPINV, &Scripts::CMDSETTIMER, &Scripts::CMDSETTIMER, &Scripts::CMDCHECKTIMER, &Scripts::CMDSETTRAVEL, - &Scripts::CMDSETTRAVEL, &Scripts::CMDSETVID, &Scripts::CMDPLAYVID, &Scripts::CMDPLOTIMAGE, &Scripts::CMDSETDISPLAY, - &Scripts::CMDSETBUFFER, &Scripts::CMDSETSCROLL, &Scripts::CMDSAVERECT, &Scripts::CMDSAVERECT, &Scripts::CMDSETBUFVID, - &Scripts::CMDPLAYBUFVID, &Scripts::CMDREMOVELAST, &Scripts::CMDSPECIAL, &Scripts::CMDSPECIAL, &Scripts::CMDSPECIAL, - &Scripts::CMDSETCYCLE, &Scripts::CMDCYCLE, &Scripts::CMDCHARSPEAK, &Scripts::CMDTEXSPEAK, &Scripts::CMDTEXCHOICE, - &Scripts::CMDWAIT, &Scripts::CMDSETCONPOS, &Scripts::CMDCHECKVFRAME, &Scripts::CMDJUMPCHOICE, &Scripts::CMDRETURNCHOICE, - &Scripts::CMDCLEARBLOCK, &Scripts::CMDLOADSOUND, &Scripts::CMDFREESOUND, &Scripts::CMDSETVIDSND, &Scripts::CMDPLAYVIDSND, - &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, - &Scripts::CMDPUSHLOCATION, &Scripts::CMDPLAYEROFF, &Scripts::CMDPLAYERON, &Scripts::CMDDEAD, &Scripts::CMDFADEOUT, - &Scripts::CMDENDVID, &Scripts::CMDHELP, &Scripts::CMDCYCLEBACK, &Scripts::CMDCHAPTER, &Scripts::CMDSETHELP, &Scripts::CMDCENTERPANEL, - &Scripts::CMDMAINPANEL, &Scripts::CMDRETFLASH -}; - Scripts::Scripts(AccessEngine *vm) : _vm(vm) { - _commandList = COMMAND_LIST; - _script = nullptr; _scriptLoc = nullptr; _sequence = 0; @@ -79,7 +58,7 @@ void Scripts::searchForSequence() { _scriptLoc = pSrc; } -int Scripts::executeCommand() { +int Scripts::executeScript() { assert(_scriptLoc); _endFlag = 0; _returnCode = 0; @@ -89,13 +68,36 @@ int Scripts::executeCommand() { for (pSrc = _scriptLoc; *pSrc == SCRIPT_START_BYTE; pSrc += 3) ; _scriptCommand = *pSrc++; - (this->*_commandList[_scriptCommand - 0x80])(); + executeCommand(_scriptCommand - 0x80); _scriptLoc = pSrc; } while (!_endFlag); return _returnCode; } +void Scripts::executeCommand(int commandIndex) { + static const ScriptMethodPtr COMMAND_LIST[] = { + &Scripts::CMDENDOBJECT, &Scripts::CMDJUMPLOOK, &Scripts::CMDJUMPHELP, &Scripts::CMDJUMPGET, &Scripts::CMDJUMPMOVE, + &Scripts::CMDJUMPUSE, &Scripts::CMDJUMPTALK, &Scripts::CMDNULL, &Scripts::CMDPRINT, &Scripts::CMDRETPOS, &Scripts::CMDANIM, + &Scripts::CMDSETFLAG, &Scripts::CMDCHECKFLAG, &Scripts::CMDGOTO, &Scripts::CMDSETINV, &Scripts::CMDSETINV, + &Scripts::CMDCHECKINV, &Scripts::CMDSETTEX, &Scripts::CMDNEWROOM, &Scripts::CMDCONVERSE, &Scripts::CMDCHECKFRAME, + &Scripts::CMDCHECKANIM, &Scripts::CMDSND, &Scripts::CMDRETNEG, &Scripts::CMDRETPOS, &Scripts::CMDCHECKLOC, &Scripts::CMDSETANIM, + &Scripts::CMDDISPINV, &Scripts::CMDSETTIMER, &Scripts::CMDSETTIMER, &Scripts::CMDCHECKTIMER, &Scripts::CMDSETTRAVEL, + &Scripts::CMDSETTRAVEL, &Scripts::CMDSETVID, &Scripts::CMDPLAYVID, &Scripts::CMDPLOTIMAGE, &Scripts::CMDSETDISPLAY, + &Scripts::CMDSETBUFFER, &Scripts::CMDSETSCROLL, &Scripts::CMDSAVERECT, &Scripts::CMDSAVERECT, &Scripts::CMDSETBUFVID, + &Scripts::CMDPLAYBUFVID, &Scripts::CMDREMOVELAST, &Scripts::CMDSPECIAL, &Scripts::CMDSPECIAL, &Scripts::CMDSPECIAL, + &Scripts::CMDSETCYCLE, &Scripts::CMDCYCLE, &Scripts::CMDCHARSPEAK, &Scripts::CMDTEXSPEAK, &Scripts::CMDTEXCHOICE, + &Scripts::CMDWAIT, &Scripts::CMDSETCONPOS, &Scripts::CMDCHECKVFRAME, &Scripts::CMDJUMPCHOICE, &Scripts::CMDRETURNCHOICE, + &Scripts::CMDCLEARBLOCK, &Scripts::CMDLOADSOUND, &Scripts::CMDFREESOUND, &Scripts::CMDSETVIDSND, &Scripts::CMDPLAYVIDSND, + &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, + &Scripts::CMDPUSHLOCATION, &Scripts::CMDPLAYEROFF, &Scripts::CMDPLAYERON, &Scripts::CMDDEAD, &Scripts::CMDFADEOUT, + &Scripts::CMDENDVID, &Scripts::CMDHELP, &Scripts::CMDCYCLEBACK, &Scripts::CMDCHAPTER, &Scripts::CMDSETHELP, &Scripts::CMDCENTERPANEL, + &Scripts::CMDMAINPANEL, &Scripts::CMDRETFLASH + }; + + (this->*COMMAND_LIST[commandIndex])(); +} + void Scripts::CMDENDOBJECT() { } void Scripts::CMDJUMPLOOK() { } void Scripts::CMDJUMPHELP() { } diff --git a/engines/access/scripts.h b/engines/access/scripts.h index 99e35384a7..b9c8b2cd56 100644 --- a/engines/access/scripts.h +++ b/engines/access/scripts.h @@ -35,8 +35,8 @@ typedef void(Scripts::*ScriptMethodPtr)(); class Scripts { protected: AccessEngine *_vm; - const ScriptMethodPtr *_commandList; -public: + + virtual void executeCommand(int commandIndex); void CMDENDOBJECT(); void CMDJUMPLOOK(); void CMDJUMPHELP(); @@ -121,7 +121,7 @@ public: void searchForSequence(); - int executeCommand(); + int executeScript(); }; } // End of namespace Access |