mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-18 15:48:48 +00:00
ACCESS: Simplify command list array to use a virtual method
This commit is contained in:
parent
9aefd90939
commit
80c8fbe024
@ -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() {
|
||||
|
@ -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() {
|
||||
|
@ -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() { }
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user