diff options
Diffstat (limited to 'engines/access')
-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 | 132 | ||||
-rw-r--r-- | engines/access/scripts.h | 85 |
4 files changed, 208 insertions, 13 deletions
diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp index c2a0332e17..da7b7e18ee 100644 --- a/engines/access/amazon/amazon_room.cpp +++ b/engines/access/amazon/amazon_room.cpp @@ -113,7 +113,7 @@ void AmazonRoom::reloadRoom1() { void AmazonRoom::roomSet() { _vm->_numAnimTimers = 0; _vm->_scripts->_sequence = 1000; - _vm->_scripts->searchForSeq(); + _vm->_scripts->searchForSequence(); _vm->_scripts->executeCommand(); } diff --git a/engines/access/room.cpp b/engines/access/room.cpp index de9a41c2d3..e3e3700b51 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -230,7 +230,7 @@ void Room::loadRoomData(const byte *roomData) { void Room::roomLoop() { _vm->_scripts->_sequence = 2000; - _vm->_scripts->searchForSeq(); + _vm->_scripts->searchForSequence(); _vm->_scripts->executeCommand(); } diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index bd480b8b64..6652b2922c 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -24,28 +24,146 @@ #include "access/access.h" #include "access/scripts.h" +#define SCRIPT_START_BYTE 0xE0 + 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; + _endFlag = false; + _returnCode = 0; } Scripts::~Scripts() { freeScriptData(); } -void Scripts::searchForSeq() { - // TODO +void Scripts::freeScriptData() { + delete[] _script; + _script = nullptr; } -void Scripts::executeCommand() { - // TODO +void Scripts::searchForSequence() { + assert(_script); + byte *pSrc = _script; + int sequenceId; + do { + while (*pSrc++ != SCRIPT_START_BYTE) ; + sequenceId = READ_LE_UINT16(pSrc); + pSrc += 2; + } while (sequenceId != _sequence); + + _scriptLoc = pSrc; } -void Scripts::freeScriptData() { - delete[] _script; - _script = nullptr; +int Scripts::executeCommand() { + assert(_scriptLoc); + _endFlag = 0; + _returnCode = 0; + + do { + byte *pSrc = _scriptLoc; + for (pSrc = _scriptLoc; *pSrc == SCRIPT_START_BYTE; pSrc += 3) ; + _scriptCommand = *pSrc++; + + (this->*_commandList[_scriptCommand - 0x80])(); + _scriptLoc = pSrc; + } while (!_endFlag); + + return _returnCode; } +void Scripts::CMDENDOBJECT() { } +void Scripts::CMDJUMPLOOK() { } +void Scripts::CMDJUMPHELP() { } +void Scripts::CMDJUMPGET() { } +void Scripts::CMDJUMPMOVE() { } +void Scripts::CMDJUMPUSE() { } +void Scripts::CMDJUMPTALK() { } +void Scripts::CMDNULL() { } +void Scripts::CMDPRINT() { } +void Scripts::CMDRETPOS() { } +void Scripts::CMDANIM() { } +void Scripts::CMDSETFLAG() { } +void Scripts::CMDCHECKFLAG() { } +void Scripts::CMDGOTO() { } +void Scripts::CMDSETINV() { } +void Scripts::CMDCHECKINV() { } +void Scripts::CMDSETTEX() { } +void Scripts::CMDNEWROOM() { } +void Scripts::CMDCONVERSE() { } +void Scripts::CMDCHECKFRAME() { } +void Scripts::CMDCHECKANIM() { } +void Scripts::CMDSND() { } +void Scripts::CMDRETNEG() { } +void Scripts::CMDCHECKLOC() { } +void Scripts::CMDSETANIM() { } +void Scripts::CMDDISPINV() { } +void Scripts::CMDSETTIMER() { } +void Scripts::CMDCHECKTIMER() { } +void Scripts::CMDSETTRAVEL() { } +void Scripts::CMDSETVID() { } +void Scripts::CMDPLAYVID() { } +void Scripts::CMDPLOTIMAGE() { } +void Scripts::CMDSETDISPLAY() { } +void Scripts::CMDSETBUFFER() { } +void Scripts::CMDSETSCROLL() { } +void Scripts::CMDSAVERECT() { } +void Scripts::CMDSETBUFVID() { } +void Scripts::CMDPLAYBUFVID() { } +void Scripts::CMDREMOVELAST() { } +void Scripts::CMDSPECIAL() { } +void Scripts::CMDSETCYCLE() { } +void Scripts::CMDCYCLE() { } +void Scripts::CMDCHARSPEAK() { } +void Scripts::CMDTEXSPEAK() { } +void Scripts::CMDTEXCHOICE() { } +void Scripts::CMDWAIT() { } +void Scripts::CMDSETCONPOS() { } +void Scripts::CMDCHECKVFRAME() { } +void Scripts::CMDJUMPCHOICE() { } +void Scripts::CMDRETURNCHOICE() { } +void Scripts::CMDCLEARBLOCK() { } +void Scripts::CMDLOADSOUND() { } +void Scripts::CMDFREESOUND() { } +void Scripts::CMDSETVIDSND() { } +void Scripts::CMDPLAYVIDSND() { } +void Scripts::CMDPUSHLOCATION() { } +void Scripts::CMDPLAYEROFF() { } +void Scripts::CMDPLAYERON() { } +void Scripts::CMDDEAD() { } +void Scripts::CMDFADEOUT() { } +void Scripts::CMDENDVID() { } +void Scripts::CMDHELP() { } +void Scripts::CMDCYCLEBACK() { } +void Scripts::CMDCHAPTER() { } +void Scripts::CMDSETHELP() { } +void Scripts::CMDCENTERPANEL() { } +void Scripts::CMDMAINPANEL() { } +void Scripts::CMDRETFLASH() { } + + } // End of namespace Access diff --git a/engines/access/scripts.h b/engines/access/scripts.h index 995f12930f..99e35384a7 100644 --- a/engines/access/scripts.h +++ b/engines/access/scripts.h @@ -28,23 +28,100 @@ namespace Access { class AccessEngine; +class Scripts; + +typedef void(Scripts::*ScriptMethodPtr)(); class Scripts { protected: AccessEngine *_vm; + const ScriptMethodPtr *_commandList; +public: + void CMDENDOBJECT(); + void CMDJUMPLOOK(); + void CMDJUMPHELP(); + void CMDJUMPGET(); + void CMDJUMPMOVE(); + void CMDJUMPUSE(); + void CMDJUMPTALK(); + void CMDNULL(); + void CMDPRINT(); + void CMDRETPOS(); + void CMDANIM(); + void CMDSETFLAG(); + void CMDCHECKFLAG(); + void CMDGOTO(); + void CMDSETINV(); + void CMDCHECKINV(); + void CMDSETTEX(); + void CMDNEWROOM(); + void CMDCONVERSE(); + void CMDCHECKFRAME(); + void CMDCHECKANIM(); + void CMDSND(); + void CMDRETNEG(); + void CMDCHECKLOC(); + void CMDSETANIM(); + void CMDDISPINV(); + void CMDSETTIMER(); + void CMDCHECKTIMER(); + void CMDSETTRAVEL(); + void CMDSETVID(); + void CMDPLAYVID(); + void CMDPLOTIMAGE(); + void CMDSETDISPLAY(); + void CMDSETBUFFER(); + void CMDSETSCROLL(); + void CMDSAVERECT(); + void CMDSETBUFVID(); + void CMDPLAYBUFVID(); + void CMDREMOVELAST(); + void CMDSPECIAL(); + void CMDSETCYCLE(); + void CMDCYCLE(); + void CMDCHARSPEAK(); + void CMDTEXSPEAK(); + void CMDTEXCHOICE(); + void CMDWAIT(); + void CMDSETCONPOS(); + void CMDCHECKVFRAME(); + void CMDJUMPCHOICE(); + void CMDRETURNCHOICE(); + void CMDCLEARBLOCK(); + void CMDLOADSOUND(); + void CMDFREESOUND(); + void CMDSETVIDSND(); + void CMDPLAYVIDSND(); + void CMDPUSHLOCATION(); + void CMDPLAYEROFF(); + void CMDPLAYERON(); + void CMDDEAD(); + void CMDFADEOUT(); + void CMDENDVID(); + void CMDHELP(); + void CMDCYCLEBACK(); + void CMDCHAPTER(); + void CMDSETHELP(); + void CMDCENTERPANEL(); + void CMDMAINPANEL(); + void CMDRETFLASH(); public: byte *_script; + byte *_scriptLoc; int _sequence; + bool _endFlag; + int _returnCode; + int _scriptCommand; public: Scripts(AccessEngine *vm); virtual ~Scripts(); - void searchForSeq(); - - void executeCommand(); - void freeScriptData(); + + void searchForSequence(); + + int executeCommand(); }; } // End of namespace Access |