aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/access/scripts.cpp156
-rw-r--r--engines/access/scripts.h151
2 files changed, 159 insertions, 148 deletions
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index 6513f34a86..337aa43eb5 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -45,9 +45,9 @@ void Scripts::freeScriptData() {
_script = nullptr;
}
-void Scripts::searchForSequence() {
+const byte *Scripts::searchForSequence() {
assert(_script);
- byte *pSrc = _script;
+ const byte *pSrc = _script;
int sequenceId;
do {
while (*pSrc++ != SCRIPT_START_BYTE) ;
@@ -56,6 +56,7 @@ void Scripts::searchForSequence() {
} while (sequenceId != _sequence);
_scriptLoc = pSrc;
+ return pSrc;
}
int Scripts::executeScript() {
@@ -64,22 +65,22 @@ int Scripts::executeScript() {
_returnCode = 0;
do {
- byte *pSrc = _scriptLoc;
+ const byte *pSrc = _scriptLoc;
for (pSrc = _scriptLoc; *pSrc == SCRIPT_START_BYTE; pSrc += 3) ;
_scriptCommand = *pSrc++;
- executeCommand(_scriptCommand - 0x80);
+ executeCommand(_scriptCommand - 0x80, pSrc);
_scriptLoc = pSrc;
} while (!_endFlag);
return _returnCode;
}
-void Scripts::executeCommand(int commandIndex) {
+void Scripts::executeCommand(int commandIndex, const byte *&pScript) {
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::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,
@@ -95,77 +96,82 @@ void Scripts::executeCommand(int commandIndex) {
&Scripts::CMDMAINPANEL, &Scripts::CMDRETFLASH
};
- (this->*COMMAND_LIST[commandIndex])();
+ (this->*COMMAND_LIST[commandIndex])(pScript);
}
-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() { }
+void Scripts::CMDENDOBJECT(const byte *&pScript) { }
+void Scripts::CMDJUMPLOOK(const byte *&pScript) { }
+void Scripts::CMDJUMPHELP(const byte *&pScript) { }
+void Scripts::CMDJUMPGET(const byte *&pScript) { }
+void Scripts::CMDJUMPMOVE(const byte *&pScript) { }
+void Scripts::CMDJUMPUSE(const byte *&pScript) { }
+void Scripts::CMDJUMPTALK(const byte *&pScript) { }
+void Scripts::CMDNULL(const byte *&pScript) { }
+void Scripts::CMDPRINT(const byte *&pScript) { }
+void Scripts::CMDRETPOS(const byte *&pScript) { }
+void Scripts::CMDANIM(const byte *&pScript) { }
+void Scripts::CMDSETFLAG(const byte *&pScript) { }
+void Scripts::CMDCHECKFLAG(const byte *&pScript) { }
+
+void Scripts::cmdGoto(const byte *&pScript) {
+ _sequence = READ_LE_UINT16(pScript);
+ pScript = searchForSequence();
+}
+
+void Scripts::CMDSETINV(const byte *&pScript) { }
+void Scripts::CMDCHECKINV(const byte *&pScript) { }
+void Scripts::CMDSETTEX(const byte *&pScript) { }
+void Scripts::CMDNEWROOM(const byte *&pScript) { }
+void Scripts::CMDCONVERSE(const byte *&pScript) { }
+void Scripts::CMDCHECKFRAME(const byte *&pScript) { }
+void Scripts::CMDCHECKANIM(const byte *&pScript) { }
+void Scripts::CMDSND(const byte *&pScript) { }
+void Scripts::CMDRETNEG(const byte *&pScript) { }
+void Scripts::CMDCHECKLOC(const byte *&pScript) { }
+void Scripts::CMDSETANIM(const byte *&pScript) { }
+void Scripts::CMDDISPINV(const byte *&pScript) { }
+void Scripts::CMDSETTIMER(const byte *&pScript) { }
+void Scripts::CMDCHECKTIMER(const byte *&pScript) { }
+void Scripts::CMDSETTRAVEL(const byte *&pScript) { }
+void Scripts::CMDSETVID(const byte *&pScript) { }
+void Scripts::CMDPLAYVID(const byte *&pScript) { }
+void Scripts::CMDPLOTIMAGE(const byte *&pScript) { }
+void Scripts::CMDSETDISPLAY(const byte *&pScript) { }
+void Scripts::CMDSETBUFFER(const byte *&pScript) { }
+void Scripts::CMDSETSCROLL(const byte *&pScript) { }
+void Scripts::CMDSAVERECT(const byte *&pScript) { }
+void Scripts::CMDSETBUFVID(const byte *&pScript) { }
+void Scripts::CMDPLAYBUFVID(const byte *&pScript) { }
+void Scripts::CMDREMOVELAST(const byte *&pScript) { }
+void Scripts::CMDSPECIAL(const byte *&pScript) { }
+void Scripts::CMDSETCYCLE(const byte *&pScript) { }
+void Scripts::CMDCYCLE(const byte *&pScript) { }
+void Scripts::CMDCHARSPEAK(const byte *&pScript) { }
+void Scripts::CMDTEXSPEAK(const byte *&pScript) { }
+void Scripts::CMDTEXCHOICE(const byte *&pScript) { }
+void Scripts::CMDWAIT(const byte *&pScript) { }
+void Scripts::CMDSETCONPOS(const byte *&pScript) { }
+void Scripts::CMDCHECKVFRAME(const byte *&pScript) { }
+void Scripts::CMDJUMPCHOICE(const byte *&pScript) { }
+void Scripts::CMDRETURNCHOICE(const byte *&pScript) { }
+void Scripts::CMDCLEARBLOCK(const byte *&pScript) { }
+void Scripts::CMDLOADSOUND(const byte *&pScript) { }
+void Scripts::CMDFREESOUND(const byte *&pScript) { }
+void Scripts::CMDSETVIDSND(const byte *&pScript) { }
+void Scripts::CMDPLAYVIDSND(const byte *&pScript) { }
+void Scripts::CMDPUSHLOCATION(const byte *&pScript) { }
+void Scripts::CMDPLAYEROFF(const byte *&pScript) { }
+void Scripts::CMDPLAYERON(const byte *&pScript) { }
+void Scripts::CMDDEAD(const byte *&pScript) { }
+void Scripts::CMDFADEOUT(const byte *&pScript) { }
+void Scripts::CMDENDVID(const byte *&pScript) { }
+void Scripts::CMDHELP(const byte *&pScript) { }
+void Scripts::CMDCYCLEBACK(const byte *&pScript) { }
+void Scripts::CMDCHAPTER(const byte *&pScript) { }
+void Scripts::CMDSETHELP(const byte *&pScript) { }
+void Scripts::CMDCENTERPANEL(const byte *&pScript) { }
+void Scripts::CMDMAINPANEL(const byte *&pScript) { }
+void Scripts::CMDRETFLASH(const byte *&pScript) { }
} // End of namespace Access
diff --git a/engines/access/scripts.h b/engines/access/scripts.h
index b9c8b2cd56..fc75e9e9ab 100644
--- a/engines/access/scripts.h
+++ b/engines/access/scripts.h
@@ -30,84 +30,89 @@ namespace Access {
class AccessEngine;
class Scripts;
-typedef void(Scripts::*ScriptMethodPtr)();
+typedef void(Scripts::*ScriptMethodPtr)(const byte *&pScript);
class Scripts {
protected:
AccessEngine *_vm;
- virtual void executeCommand(int commandIndex);
- 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();
+ virtual void executeCommand(int commandIndex, const byte *&pScript);
+ void CMDENDOBJECT(const byte *&pScript);
+ void CMDJUMPLOOK(const byte *&pScript);
+ void CMDJUMPHELP(const byte *&pScript);
+ void CMDJUMPGET(const byte *&pScript);
+ void CMDJUMPMOVE(const byte *&pScript);
+ void CMDJUMPUSE(const byte *&pScript);
+ void CMDJUMPTALK(const byte *&pScript);
+ void CMDNULL(const byte *&pScript);
+ void CMDPRINT(const byte *&pScript);
+ void CMDRETPOS(const byte *&pScript);
+ void CMDANIM(const byte *&pScript);
+ void CMDSETFLAG(const byte *&pScript);
+ void CMDCHECKFLAG(const byte *&pScript);
+
+ /**
+ * Jump to another script
+ */
+ void cmdGoto(const byte *&pScript);
+
+ void CMDSETINV(const byte *&pScript);
+ void CMDCHECKINV(const byte *&pScript);
+ void CMDSETTEX(const byte *&pScript);
+ void CMDNEWROOM(const byte *&pScript);
+ void CMDCONVERSE(const byte *&pScript);
+ void CMDCHECKFRAME(const byte *&pScript);
+ void CMDCHECKANIM(const byte *&pScript);
+ void CMDSND(const byte *&pScript);
+ void CMDRETNEG(const byte *&pScript);
+ void CMDCHECKLOC(const byte *&pScript);
+ void CMDSETANIM(const byte *&pScript);
+ void CMDDISPINV(const byte *&pScript);
+ void CMDSETTIMER(const byte *&pScript);
+ void CMDCHECKTIMER(const byte *&pScript);
+ void CMDSETTRAVEL(const byte *&pScript);
+ void CMDSETVID(const byte *&pScript);
+ void CMDPLAYVID(const byte *&pScript);
+ void CMDPLOTIMAGE(const byte *&pScript);
+ void CMDSETDISPLAY(const byte *&pScript);
+ void CMDSETBUFFER(const byte *&pScript);
+ void CMDSETSCROLL(const byte *&pScript);
+ void CMDSAVERECT(const byte *&pScript);
+ void CMDSETBUFVID(const byte *&pScript);
+ void CMDPLAYBUFVID(const byte *&pScript);
+ void CMDREMOVELAST(const byte *&pScript);
+ void CMDSPECIAL(const byte *&pScript);
+ void CMDSETCYCLE(const byte *&pScript);
+ void CMDCYCLE(const byte *&pScript);
+ void CMDCHARSPEAK(const byte *&pScript);
+ void CMDTEXSPEAK(const byte *&pScript);
+ void CMDTEXCHOICE(const byte *&pScript);
+ void CMDWAIT(const byte *&pScript);
+ void CMDSETCONPOS(const byte *&pScript);
+ void CMDCHECKVFRAME(const byte *&pScript);
+ void CMDJUMPCHOICE(const byte *&pScript);
+ void CMDRETURNCHOICE(const byte *&pScript);
+ void CMDCLEARBLOCK(const byte *&pScript);
+ void CMDLOADSOUND(const byte *&pScript);
+ void CMDFREESOUND(const byte *&pScript);
+ void CMDSETVIDSND(const byte *&pScript);
+ void CMDPLAYVIDSND(const byte *&pScript);
+ void CMDPUSHLOCATION(const byte *&pScript);
+ void CMDPLAYEROFF(const byte *&pScript);
+ void CMDPLAYERON(const byte *&pScript);
+ void CMDDEAD(const byte *&pScript);
+ void CMDFADEOUT(const byte *&pScript);
+ void CMDENDVID(const byte *&pScript);
+ void CMDHELP(const byte *&pScript);
+ void CMDCYCLEBACK(const byte *&pScript);
+ void CMDCHAPTER(const byte *&pScript);
+ void CMDSETHELP(const byte *&pScript);
+ void CMDCENTERPANEL(const byte *&pScript);
+ void CMDMAINPANEL(const byte *&pScript);
+ void CMDRETFLASH(const byte *&pScript);
public:
- byte *_script;
- byte *_scriptLoc;
+ const byte *_script;
+ const byte *_scriptLoc;
int _sequence;
bool _endFlag;
int _returnCode;
@@ -119,7 +124,7 @@ public:
void freeScriptData();
- void searchForSequence();
+ const byte *searchForSequence();
int executeScript();
};