diff options
author | Christopher Page | 2008-06-02 21:36:45 +0000 |
---|---|---|
committer | Christopher Page | 2008-06-02 21:36:45 +0000 |
commit | 0cbfc3a9d1b30822373360aa4c398518c9a74990 (patch) | |
tree | 24c865ed3153978aa00df03613b1bdde1a6efe5d /engines/parallaction | |
parent | a338d5fdb2715a7b29ae789c632a0cfa05803079 (diff) | |
parent | 6f09c5a9286f97a1fac6e85fa4092295bc779440 (diff) | |
download | scummvm-rg350-0cbfc3a9d1b30822373360aa4c398518c9a74990.tar.gz scummvm-rg350-0cbfc3a9d1b30822373360aa4c398518c9a74990.tar.bz2 scummvm-rg350-0cbfc3a9d1b30822373360aa4c398518c9a74990.zip |
Merged revisions 32348-32349,32351-32356,32358-32411,32413-32441,32443-32445,32449,32453-32454,32456-32457,32459-32462,32464-32465,32467-32492,32494-32503 via svnmerge from
https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/trunk
svn-id: r32505
Diffstat (limited to 'engines/parallaction')
-rw-r--r-- | engines/parallaction/exec_br.cpp | 176 | ||||
-rw-r--r-- | engines/parallaction/exec_ns.cpp | 99 | ||||
-rw-r--r-- | engines/parallaction/parallaction.h | 5 | ||||
-rw-r--r-- | engines/parallaction/parallaction_ns.cpp | 12 | ||||
-rw-r--r-- | engines/parallaction/parser.h | 46 | ||||
-rw-r--r-- | engines/parallaction/parser_br.cpp | 305 | ||||
-rw-r--r-- | engines/parallaction/parser_ns.cpp | 207 | ||||
-rw-r--r-- | engines/parallaction/staticres.cpp | 34 |
8 files changed, 417 insertions, 467 deletions
diff --git a/engines/parallaction/exec_br.cpp b/engines/parallaction/exec_br.cpp index 07ed3f5d78..2aeec6358d 100644 --- a/engines/parallaction/exec_br.cpp +++ b/engines/parallaction/exec_br.cpp @@ -62,11 +62,13 @@ namespace Parallaction { -typedef OpcodeImpl<Parallaction_br> OpcodeV2; -#define COMMAND_OPCODE(op) OpcodeV2(this, &Parallaction_br::cmdOp_##op) +#define SetOpcodeTable(x) table = &x; + +typedef Common::Functor0Mem<void, Parallaction_br> OpcodeV2; +#define COMMAND_OPCODE(op) table->push_back(new OpcodeV2(this, &Parallaction_br::cmdOp_##op)) #define DECLARE_COMMAND_OPCODE(op) void Parallaction_br::cmdOp_##op() -#define INSTRUCTION_OPCODE(op) OpcodeV2(this, &Parallaction_br::instOp_##op) +#define INSTRUCTION_OPCODE(op) table->push_back(new OpcodeV2(this, &Parallaction_br::instOp_##op)) #define DECLARE_INSTRUCTION_OPCODE(op) void Parallaction_br::instOp_##op() void Parallaction_br::setupSubtitles(char *s, char *s2, int y) { @@ -498,95 +500,85 @@ DECLARE_INSTRUCTION_OPCODE(endscript) { void Parallaction_br::initOpcodes() { - static const OpcodeV2 op1[] = { - COMMAND_OPCODE(invalid), - COMMAND_OPCODE(set), - COMMAND_OPCODE(clear), - COMMAND_OPCODE(start), - COMMAND_OPCODE(speak), - COMMAND_OPCODE(get), - COMMAND_OPCODE(location), - COMMAND_OPCODE(open), - COMMAND_OPCODE(close), - COMMAND_OPCODE(on), - COMMAND_OPCODE(off), - COMMAND_OPCODE(call), - COMMAND_OPCODE(toggle), - COMMAND_OPCODE(drop), - COMMAND_OPCODE(quit), - COMMAND_OPCODE(move), - COMMAND_OPCODE(stop), - COMMAND_OPCODE(character), - COMMAND_OPCODE(followme), - COMMAND_OPCODE(onmouse), - COMMAND_OPCODE(offmouse), - COMMAND_OPCODE(add), - COMMAND_OPCODE(leave), - COMMAND_OPCODE(inc), - COMMAND_OPCODE(dec), - COMMAND_OPCODE(ifeq), - COMMAND_OPCODE(iflt), - COMMAND_OPCODE(ifgt), - COMMAND_OPCODE(let), - COMMAND_OPCODE(music), - COMMAND_OPCODE(fix), - COMMAND_OPCODE(unfix), - COMMAND_OPCODE(zeta), - COMMAND_OPCODE(scroll), - COMMAND_OPCODE(swap), - COMMAND_OPCODE(give), - COMMAND_OPCODE(text), - COMMAND_OPCODE(part), - COMMAND_OPCODE(testsfx), - COMMAND_OPCODE(ret), - COMMAND_OPCODE(onsave), - COMMAND_OPCODE(offsave) - }; - - uint i; - for (i = 0; i < ARRAYSIZE(op1); i++) - _commandOpcodes.push_back(&op1[i]); - - - static const OpcodeV2 op2[] = { - INSTRUCTION_OPCODE(invalid), - INSTRUCTION_OPCODE(on), - INSTRUCTION_OPCODE(off), - INSTRUCTION_OPCODE(set), // x - INSTRUCTION_OPCODE(set), // y - INSTRUCTION_OPCODE(set), // z - INSTRUCTION_OPCODE(set), // f - INSTRUCTION_OPCODE(loop), - INSTRUCTION_OPCODE(endloop), - INSTRUCTION_OPCODE(null), // show - INSTRUCTION_OPCODE(inc), - INSTRUCTION_OPCODE(inc), // dec - INSTRUCTION_OPCODE(set), - INSTRUCTION_OPCODE(put), - INSTRUCTION_OPCODE(call), - INSTRUCTION_OPCODE(wait), - INSTRUCTION_OPCODE(start), - INSTRUCTION_OPCODE(process), - INSTRUCTION_OPCODE(move), - INSTRUCTION_OPCODE(color), - INSTRUCTION_OPCODE(process), // sound - INSTRUCTION_OPCODE(mask), - INSTRUCTION_OPCODE(print), - INSTRUCTION_OPCODE(text), - INSTRUCTION_OPCODE(inc), // mul - INSTRUCTION_OPCODE(inc), // div - INSTRUCTION_OPCODE(ifeq), - INSTRUCTION_OPCODE(iflt), - INSTRUCTION_OPCODE(ifgt), - INSTRUCTION_OPCODE(endif), - INSTRUCTION_OPCODE(stop), - INSTRUCTION_OPCODE(endscript) - }; - - for (i = 0; i < ARRAYSIZE(op2); i++) - _instructionOpcodes.push_back(&op2[i]); - - + Common::Array<const Opcode*> *table = 0; + + SetOpcodeTable(_commandOpcodes); + COMMAND_OPCODE(invalid); + COMMAND_OPCODE(set); + COMMAND_OPCODE(clear); + COMMAND_OPCODE(start); + COMMAND_OPCODE(speak); + COMMAND_OPCODE(get); + COMMAND_OPCODE(location); + COMMAND_OPCODE(open); + COMMAND_OPCODE(close); + COMMAND_OPCODE(on); + COMMAND_OPCODE(off); + COMMAND_OPCODE(call); + COMMAND_OPCODE(toggle); + COMMAND_OPCODE(drop); + COMMAND_OPCODE(quit); + COMMAND_OPCODE(move); + COMMAND_OPCODE(stop); + COMMAND_OPCODE(character); + COMMAND_OPCODE(followme); + COMMAND_OPCODE(onmouse); + COMMAND_OPCODE(offmouse); + COMMAND_OPCODE(add); + COMMAND_OPCODE(leave); + COMMAND_OPCODE(inc); + COMMAND_OPCODE(dec); + COMMAND_OPCODE(ifeq); + COMMAND_OPCODE(iflt); + COMMAND_OPCODE(ifgt); + COMMAND_OPCODE(let); + COMMAND_OPCODE(music); + COMMAND_OPCODE(fix); + COMMAND_OPCODE(unfix); + COMMAND_OPCODE(zeta); + COMMAND_OPCODE(scroll); + COMMAND_OPCODE(swap); + COMMAND_OPCODE(give); + COMMAND_OPCODE(text); + COMMAND_OPCODE(part); + COMMAND_OPCODE(testsfx); + COMMAND_OPCODE(ret); + COMMAND_OPCODE(onsave); + COMMAND_OPCODE(offsave); + + SetOpcodeTable(_instructionOpcodes); + INSTRUCTION_OPCODE(invalid); + INSTRUCTION_OPCODE(on); + INSTRUCTION_OPCODE(off); + INSTRUCTION_OPCODE(set); // x + INSTRUCTION_OPCODE(set); // y + INSTRUCTION_OPCODE(set); // z + INSTRUCTION_OPCODE(set); // f + INSTRUCTION_OPCODE(loop); + INSTRUCTION_OPCODE(endloop); + INSTRUCTION_OPCODE(null); // show + INSTRUCTION_OPCODE(inc); + INSTRUCTION_OPCODE(inc); // dec + INSTRUCTION_OPCODE(set); + INSTRUCTION_OPCODE(put); + INSTRUCTION_OPCODE(call); + INSTRUCTION_OPCODE(wait); + INSTRUCTION_OPCODE(start); + INSTRUCTION_OPCODE(process); + INSTRUCTION_OPCODE(move); + INSTRUCTION_OPCODE(color); + INSTRUCTION_OPCODE(process); // sound + INSTRUCTION_OPCODE(mask); + INSTRUCTION_OPCODE(print); + INSTRUCTION_OPCODE(text); + INSTRUCTION_OPCODE(inc); // mul + INSTRUCTION_OPCODE(inc); // div + INSTRUCTION_OPCODE(ifeq); + INSTRUCTION_OPCODE(iflt); + INSTRUCTION_OPCODE(ifgt); + INSTRUCTION_OPCODE(endif); + INSTRUCTION_OPCODE(stop); + INSTRUCTION_OPCODE(endscript); } #if 0 diff --git a/engines/parallaction/exec_ns.cpp b/engines/parallaction/exec_ns.cpp index f7c3b895c2..bd2d54c0a0 100644 --- a/engines/parallaction/exec_ns.cpp +++ b/engines/parallaction/exec_ns.cpp @@ -50,12 +50,13 @@ namespace Parallaction { #define INST_MOVE 18 #define INST_ENDSCRIPT 19 +#define SetOpcodeTable(x) table = &x; -typedef OpcodeImpl<Parallaction_ns> OpcodeV1; -#define COMMAND_OPCODE(op) OpcodeV1(this, &Parallaction_ns::cmdOp_##op) +typedef Common::Functor0Mem<void, Parallaction_ns> OpcodeV2; +#define COMMAND_OPCODE(op) table->push_back(new OpcodeV2(this, &Parallaction_ns::cmdOp_##op)) #define DECLARE_COMMAND_OPCODE(op) void Parallaction_ns::cmdOp_##op() -#define INSTRUCTION_OPCODE(op) OpcodeV1(this, &Parallaction_ns::instOp_##op) +#define INSTRUCTION_OPCODE(op) table->push_back(new OpcodeV2(this, &Parallaction_ns::instOp_##op)) #define DECLARE_INSTRUCTION_OPCODE(op) void Parallaction_ns::instOp_##op() @@ -655,56 +656,48 @@ ZonePtr Parallaction::hitZone(uint32 type, uint16 x, uint16 y) { void Parallaction_ns::initOpcodes() { - static const OpcodeV1 op1[] = { - INSTRUCTION_OPCODE(invalid), - INSTRUCTION_OPCODE(on), - INSTRUCTION_OPCODE(off), - INSTRUCTION_OPCODE(set), // x - INSTRUCTION_OPCODE(set), // y - INSTRUCTION_OPCODE(set), // z - INSTRUCTION_OPCODE(set), // f - INSTRUCTION_OPCODE(loop), - INSTRUCTION_OPCODE(endloop), - INSTRUCTION_OPCODE(null), - INSTRUCTION_OPCODE(inc), - INSTRUCTION_OPCODE(inc), // dec - INSTRUCTION_OPCODE(set), - INSTRUCTION_OPCODE(put), - INSTRUCTION_OPCODE(call), - INSTRUCTION_OPCODE(wait), - INSTRUCTION_OPCODE(start), - INSTRUCTION_OPCODE(sound), - INSTRUCTION_OPCODE(move), - INSTRUCTION_OPCODE(endscript) - }; - - uint i; - for (i = 0; i < ARRAYSIZE(op1); i++) - _instructionOpcodes.push_back(&op1[i]); - - static const OpcodeV1 op3[] = { - COMMAND_OPCODE(invalid), - COMMAND_OPCODE(set), - COMMAND_OPCODE(clear), - COMMAND_OPCODE(start), - COMMAND_OPCODE(speak), - COMMAND_OPCODE(get), - COMMAND_OPCODE(location), - COMMAND_OPCODE(open), - COMMAND_OPCODE(close), - COMMAND_OPCODE(on), - COMMAND_OPCODE(off), - COMMAND_OPCODE(call), - COMMAND_OPCODE(toggle), - COMMAND_OPCODE(drop), - COMMAND_OPCODE(quit), - COMMAND_OPCODE(move), - COMMAND_OPCODE(stop) - }; - - for (i = 0; i < ARRAYSIZE(op3); i++) - _commandOpcodes.push_back(&op3[i]); - + Common::Array<const Opcode*> *table = 0; + + SetOpcodeTable(_instructionOpcodes); + INSTRUCTION_OPCODE(invalid); + INSTRUCTION_OPCODE(on); + INSTRUCTION_OPCODE(off); + INSTRUCTION_OPCODE(set); // x + INSTRUCTION_OPCODE(set); // y + INSTRUCTION_OPCODE(set); // z + INSTRUCTION_OPCODE(set); // f + INSTRUCTION_OPCODE(loop); + INSTRUCTION_OPCODE(endloop); + INSTRUCTION_OPCODE(null); + INSTRUCTION_OPCODE(inc); + INSTRUCTION_OPCODE(inc); // dec + INSTRUCTION_OPCODE(set); + INSTRUCTION_OPCODE(put); + INSTRUCTION_OPCODE(call); + INSTRUCTION_OPCODE(wait); + INSTRUCTION_OPCODE(start); + INSTRUCTION_OPCODE(sound); + INSTRUCTION_OPCODE(move); + INSTRUCTION_OPCODE(endscript); + + SetOpcodeTable(_commandOpcodes); + COMMAND_OPCODE(invalid); + COMMAND_OPCODE(set); + COMMAND_OPCODE(clear); + COMMAND_OPCODE(start); + COMMAND_OPCODE(speak); + COMMAND_OPCODE(get); + COMMAND_OPCODE(location); + COMMAND_OPCODE(open); + COMMAND_OPCODE(close); + COMMAND_OPCODE(on); + COMMAND_OPCODE(off); + COMMAND_OPCODE(call); + COMMAND_OPCODE(toggle); + COMMAND_OPCODE(drop); + COMMAND_OPCODE(quit); + COMMAND_OPCODE(move); + COMMAND_OPCODE(stop); } diff --git a/engines/parallaction/parallaction.h b/engines/parallaction/parallaction.h index f639185580..3117424373 100644 --- a/engines/parallaction/parallaction.h +++ b/engines/parallaction/parallaction.h @@ -522,8 +522,9 @@ private: void initCursors(); void initParsers(); - static byte _mouseArrow[256]; - Frames *_mouseComposedArrow; + static byte _resMouseArrow[256]; + byte *_mouseArrow; + Frames *_mouseComposedArrow; static const Callable _dosCallables[25]; static const Callable _amigaCallables[25]; diff --git a/engines/parallaction/parallaction_ns.cpp b/engines/parallaction/parallaction_ns.cpp index 8254a85a34..74003ee78b 100644 --- a/engines/parallaction/parallaction_ns.cpp +++ b/engines/parallaction/parallaction_ns.cpp @@ -172,18 +172,8 @@ void Parallaction_ns::freeFonts() { } void Parallaction_ns::initCursors() { - _mouseComposedArrow = _disk->loadPointer("pointer"); - - byte temp[MOUSEARROW_WIDTH*MOUSEARROW_HEIGHT]; - memcpy(temp, _mouseArrow, MOUSEARROW_WIDTH*MOUSEARROW_HEIGHT); - - uint16 k = 0; - for (uint16 i = 0; i < 4; i++) { - for (uint16 j = 0; j < 64; j++) _mouseArrow[k++] = temp[i + j * 4]; - } - - return; + _mouseArrow = _resMouseArrow; } void Parallaction_ns::setArrowCursor() { diff --git a/engines/parallaction/parser.h b/engines/parallaction/parser.h index e8de07822e..79e9cc7df0 100644 --- a/engines/parallaction/parser.h +++ b/engines/parallaction/parser.h @@ -60,31 +60,7 @@ public: }; - -class Opcode { - -public: - virtual void operator()() const = 0; - virtual ~Opcode() { } -}; - -template <class T> -class OpcodeImpl : public Opcode { - - typedef void (T::*Fn)(); - - T* _instance; - Fn _fn; - -public: - OpcodeImpl(T* instance, const Fn &fn) : _instance(instance), _fn(fn) { } - - void operator()() const { - (_instance->*_fn)(); - } - -}; - +typedef Common::Functor0<void> Opcode; typedef Common::Array<const Opcode*> OpcodeSet; @@ -233,6 +209,11 @@ protected: uint _numForwardedCommands; void init(); + void clearSet(OpcodeSet &opcodes) { + for (Common::Array<const Opcode*>::iterator i = opcodes.begin(); i != opcodes.end(); ++i) + delete *i; + opcodes.clear(); + } public: LocationParser_ns(Parallaction_ns *vm) : _vm(vm) { @@ -248,6 +229,13 @@ public: delete _locationAnimStmt; delete _zoneTypeNames; delete _zoneFlagNames; + + delete _parser; + + clearSet(_commandParsers); + clearSet(_locationAnimParsers); + clearSet(_locationZoneParsers); + clearSet(_locationParsers); } void parse(Script *script); @@ -361,6 +349,11 @@ protected: virtual void parseRValue(ScriptVar &var, const char *str); void init(); + void clearSet(OpcodeSet &opcodes) { + for (Common::Array<const Opcode*>::iterator i = opcodes.begin(); i != opcodes.end(); ++i) + delete *i; + opcodes.clear(); + } public: ProgramParser_ns(Parallaction_ns *vm) : _vm(vm) { @@ -369,6 +362,7 @@ public: virtual ~ProgramParser_ns() { delete _instructionNames; + clearSet(_instructionParsers); } void parse(Script *script, ProgramPtr program); @@ -400,6 +394,8 @@ public: virtual ~ProgramParser_br() { delete _instructionNames; + delete _parser; + } }; diff --git a/engines/parallaction/parser_br.cpp b/engines/parallaction/parser_br.cpp index d9dd2ef5c8..cebda4b5ed 100644 --- a/engines/parallaction/parser_br.cpp +++ b/engines/parallaction/parser_br.cpp @@ -288,6 +288,20 @@ const char *_instructionNamesRes_br[] = { }; +#define SetOpcodeTable(x) table = &x; + +typedef Common::Functor0Mem<void, ProgramParser_br> OpcodeV1; +#define INSTRUCTION_PARSER(sig) table->push_back(new OpcodeV1(this, &ProgramParser_br::instParse_##sig)) + +typedef Common::Functor0Mem<void, LocationParser_br> OpcodeV2; +#define ZONE_PARSER(sig) table->push_back(new OpcodeV2(this, &LocationParser_br::locZoneParse_##sig)) +#define ANIM_PARSER(sig) table->push_back(new OpcodeV2(this, &LocationParser_br::locAnimParse_##sig)) +#define LOCATION_PARSER(sig) table->push_back(new OpcodeV2(this, &LocationParser_br::locParse_##sig)) +#define COMMAND_PARSER(sig) table->push_back(new OpcodeV2(this, &LocationParser_br::cmdParse_##sig)) + +#define WARNING_PARSER(sig) table->push_back(new OpcodeV2(this, &LocationParser_br::warning_##sig)) + + #define DECLARE_ZONE_PARSER(sig) void LocationParser_br::locZoneParse_##sig() #define DECLARE_ANIM_PARSER(sig) void LocationParser_br::locAnimParse_##sig() #define DECLARE_COMMAND_PARSER(sig) void LocationParser_br::cmdParse_##sig() @@ -940,16 +954,6 @@ void ProgramParser_br::parseRValue(ScriptVar &v, const char *str) { } -typedef OpcodeImpl<LocationParser_br> OpcodeV2; -#define ZONE_PARSER(sig) OpcodeV2(this, &LocationParser_br::locZoneParse_##sig) -#define ANIM_PARSER(sig) OpcodeV2(this, &LocationParser_br::locAnimParse_##sig) -#define LOCATION_PARSER(sig) OpcodeV2(this, &LocationParser_br::locParse_##sig) -#define COMMAND_PARSER(sig) OpcodeV2(this, &LocationParser_br::cmdParse_##sig) -#define WARNING_PARSER(sig) OpcodeV2(this, &LocationParser_br::warning_##sig) - -typedef OpcodeImpl<ProgramParser_br> OpcodeV3; -#define INSTRUCTION_PARSER(sig) OpcodeV3(this, &ProgramParser_br::instParse_##sig) - void LocationParser_br::init() { @@ -963,118 +967,101 @@ void LocationParser_br::init() { _locationZoneStmt = new Table(ARRAYSIZE(_locationZoneStmtRes_br), _locationZoneStmtRes_br); _locationAnimStmt = new Table(ARRAYSIZE(_locationAnimStmtRes_br), _locationAnimStmtRes_br); - - int i; - - static const OpcodeV2 op2[] = { - WARNING_PARSER(unexpected), - COMMAND_PARSER(flags), // set - COMMAND_PARSER(flags), // clear - COMMAND_PARSER(zone), // start - COMMAND_PARSER(zone), // speak - COMMAND_PARSER(zone), // get - COMMAND_PARSER(location), - COMMAND_PARSER(zone), // open - COMMAND_PARSER(zone), // close - COMMAND_PARSER(zone), // on - COMMAND_PARSER(zone), // off - COMMAND_PARSER(call), - COMMAND_PARSER(flags), // toggle - COMMAND_PARSER(drop), - COMMAND_PARSER(simple), // quit - COMMAND_PARSER(move), - COMMAND_PARSER(zone), // stop - COMMAND_PARSER(string), // character - COMMAND_PARSER(string), // followme - COMMAND_PARSER(simple), // onmouse - COMMAND_PARSER(simple), // offmouse - COMMAND_PARSER(drop), // add - COMMAND_PARSER(zone), // leave - COMMAND_PARSER(math), // inc - COMMAND_PARSER(math), // dec - COMMAND_PARSER(test), // test - WARNING_PARSER(unexpected), - WARNING_PARSER(unexpected), - COMMAND_PARSER(math), // let - COMMAND_PARSER(music), - COMMAND_PARSER(zone), // fix - COMMAND_PARSER(zone), // unfix - COMMAND_PARSER(zeta), - COMMAND_PARSER(unary), // scroll - COMMAND_PARSER(string), // swap - COMMAND_PARSER(give), - COMMAND_PARSER(text), - COMMAND_PARSER(unary), // part - WARNING_PARSER(unexpected), - COMMAND_PARSER(simple), // return - COMMAND_PARSER(simple), // onsave - COMMAND_PARSER(simple), // offsave - COMMAND_PARSER(endcommands), // endcommands - COMMAND_PARSER(ifchar), - COMMAND_PARSER(endif) - }; - - for (i = 0; i < ARRAYSIZE(op2); i++) - _commandParsers.push_back(&op2[i]); - - static const OpcodeV2 op4[] = { - WARNING_PARSER(unexpected), - LOCATION_PARSER(character), - LOCATION_PARSER(endlocation), - LOCATION_PARSER(ifchar), - LOCATION_PARSER(null), // endif - LOCATION_PARSER(location), - LOCATION_PARSER(mask), - LOCATION_PARSER(path), - LOCATION_PARSER(null), // disk - LOCATION_PARSER(localflags), - LOCATION_PARSER(commands), - LOCATION_PARSER(escape), - LOCATION_PARSER(acommands), - LOCATION_PARSER(flags), - LOCATION_PARSER(comment), - LOCATION_PARSER(endcomment), - LOCATION_PARSER(zone), - LOCATION_PARSER(animation), - LOCATION_PARSER(zeta), - LOCATION_PARSER(music), - LOCATION_PARSER(sound) - }; - - for (i = 0; i < ARRAYSIZE(op4); i++) - _locationParsers.push_back(&op4[i]); - - static const OpcodeV2 op5[] = { - WARNING_PARSER(unexpected), - ZONE_PARSER(endzone), - ZONE_PARSER(limits), - ZONE_PARSER(moveto), - ZONE_PARSER(type), - ZONE_PARSER(commands), - ZONE_PARSER(label), - ZONE_PARSER(flags) - }; - - for (i = 0; i < ARRAYSIZE(op5); i++) - _locationZoneParsers.push_back(&op5[i]); - - static const OpcodeV2 op6[] = { - WARNING_PARSER(unexpected), - ANIM_PARSER(endanimation), - ANIM_PARSER(endanimation), // endzone - ANIM_PARSER(script), - ANIM_PARSER(commands), - ANIM_PARSER(type), - ANIM_PARSER(label), - ANIM_PARSER(flags), - ANIM_PARSER(file), - ANIM_PARSER(position), - ANIM_PARSER(moveto) - }; - - for (i = 0; i < ARRAYSIZE(op6); i++) - _locationAnimParsers.push_back(&op6[i]); - + Common::Array<const Opcode*> *table = 0; + + SetOpcodeTable(_commandParsers); + WARNING_PARSER(unexpected); + COMMAND_PARSER(flags); // set + COMMAND_PARSER(flags); // clear + COMMAND_PARSER(zone); // start + COMMAND_PARSER(zone); // speak + COMMAND_PARSER(zone); // get + COMMAND_PARSER(location); + COMMAND_PARSER(zone); // open + COMMAND_PARSER(zone); // close + COMMAND_PARSER(zone); // on + COMMAND_PARSER(zone); // off + COMMAND_PARSER(call); + COMMAND_PARSER(flags); // toggle + COMMAND_PARSER(drop); + COMMAND_PARSER(simple); // quit + COMMAND_PARSER(move); + COMMAND_PARSER(zone); // stop + COMMAND_PARSER(string); // character + COMMAND_PARSER(string); // followme + COMMAND_PARSER(simple); // onmouse + COMMAND_PARSER(simple); // offmouse + COMMAND_PARSER(drop); // add + COMMAND_PARSER(zone); // leave + COMMAND_PARSER(math); // inc + COMMAND_PARSER(math); // dec + COMMAND_PARSER(test); // test + WARNING_PARSER(unexpected); + WARNING_PARSER(unexpected); + COMMAND_PARSER(math); // let + COMMAND_PARSER(music); + COMMAND_PARSER(zone); // fix + COMMAND_PARSER(zone); // unfix + COMMAND_PARSER(zeta); + COMMAND_PARSER(unary); // scroll + COMMAND_PARSER(string); // swap + COMMAND_PARSER(give); + COMMAND_PARSER(text); + COMMAND_PARSER(unary); // part + WARNING_PARSER(unexpected); + COMMAND_PARSER(simple); // return + COMMAND_PARSER(simple); // onsave + COMMAND_PARSER(simple); // offsave + COMMAND_PARSER(endcommands); // endcommands + COMMAND_PARSER(ifchar); + COMMAND_PARSER(endif); + + SetOpcodeTable(_locationParsers); + WARNING_PARSER(unexpected); + LOCATION_PARSER(character); + LOCATION_PARSER(endlocation); + LOCATION_PARSER(ifchar); + LOCATION_PARSER(null); // endif + LOCATION_PARSER(location); + LOCATION_PARSER(mask); + LOCATION_PARSER(path); + LOCATION_PARSER(null); // disk + LOCATION_PARSER(localflags); + LOCATION_PARSER(commands); + LOCATION_PARSER(escape); + LOCATION_PARSER(acommands); + LOCATION_PARSER(flags); + LOCATION_PARSER(comment); + LOCATION_PARSER(endcomment); + LOCATION_PARSER(zone); + LOCATION_PARSER(animation); + LOCATION_PARSER(zeta); + LOCATION_PARSER(music); + LOCATION_PARSER(sound); + + SetOpcodeTable(_locationZoneParsers); + WARNING_PARSER(unexpected); + ZONE_PARSER(endzone); + ZONE_PARSER(limits); + ZONE_PARSER(moveto); + ZONE_PARSER(type); + ZONE_PARSER(commands); + ZONE_PARSER(label); + ZONE_PARSER(flags); + + + SetOpcodeTable(_locationAnimParsers); + WARNING_PARSER(unexpected); + ANIM_PARSER(endanimation); + ANIM_PARSER(endanimation); // endzone + ANIM_PARSER(script); + ANIM_PARSER(commands); + ANIM_PARSER(type); + ANIM_PARSER(label); + ANIM_PARSER(flags); + ANIM_PARSER(file); + ANIM_PARSER(position); + ANIM_PARSER(moveto); } void ProgramParser_br::init() { @@ -1083,45 +1070,41 @@ void ProgramParser_br::init() { _instructionNames = new Table(ARRAYSIZE(_instructionNamesRes_br), _instructionNamesRes_br); - static const OpcodeV3 op0[] = { - INSTRUCTION_PARSER(defLocal), // invalid opcode -> local definition - INSTRUCTION_PARSER(zone), // on - INSTRUCTION_PARSER(zone), // off - INSTRUCTION_PARSER(x), - INSTRUCTION_PARSER(y), - INSTRUCTION_PARSER(z), - INSTRUCTION_PARSER(f), - INSTRUCTION_PARSER(loop), - INSTRUCTION_PARSER(null), // endloop - INSTRUCTION_PARSER(null), // show - INSTRUCTION_PARSER(inc), - INSTRUCTION_PARSER(inc), // dec - INSTRUCTION_PARSER(set), - INSTRUCTION_PARSER(put), - INSTRUCTION_PARSER(call), - INSTRUCTION_PARSER(null), // wait - INSTRUCTION_PARSER(zone), // start - INSTRUCTION_PARSER(zone), // process - INSTRUCTION_PARSER(move), - INSTRUCTION_PARSER(color), - INSTRUCTION_PARSER(zone), // sound - INSTRUCTION_PARSER(mask), - INSTRUCTION_PARSER(print), - INSTRUCTION_PARSER(text), - INSTRUCTION_PARSER(inc), // mul - INSTRUCTION_PARSER(inc), // div - INSTRUCTION_PARSER(if_op), - INSTRUCTION_PARSER(null), - INSTRUCTION_PARSER(null), - INSTRUCTION_PARSER(endif), - INSTRUCTION_PARSER(zone), // stop - INSTRUCTION_PARSER(endscript) - }; - - uint i; - for (i = 0; i < ARRAYSIZE(op0); i++) - _instructionParsers.push_back(&op0[i]); - + Common::Array<const Opcode*> *table = 0; + + SetOpcodeTable(_instructionParsers); + INSTRUCTION_PARSER(defLocal); // invalid opcode -> local definition + INSTRUCTION_PARSER(zone); // on + INSTRUCTION_PARSER(zone); // off + INSTRUCTION_PARSER(x); + INSTRUCTION_PARSER(y); + INSTRUCTION_PARSER(z); + INSTRUCTION_PARSER(f); + INSTRUCTION_PARSER(loop); + INSTRUCTION_PARSER(null); // endloop + INSTRUCTION_PARSER(null); // show + INSTRUCTION_PARSER(inc); + INSTRUCTION_PARSER(inc); // dec + INSTRUCTION_PARSER(set); + INSTRUCTION_PARSER(put); + INSTRUCTION_PARSER(call); + INSTRUCTION_PARSER(null); // wait + INSTRUCTION_PARSER(zone); // start + INSTRUCTION_PARSER(zone); // process + INSTRUCTION_PARSER(move); + INSTRUCTION_PARSER(color); + INSTRUCTION_PARSER(zone); // sound + INSTRUCTION_PARSER(mask); + INSTRUCTION_PARSER(print); + INSTRUCTION_PARSER(text); + INSTRUCTION_PARSER(inc); // mul + INSTRUCTION_PARSER(inc); // div + INSTRUCTION_PARSER(if_op); + INSTRUCTION_PARSER(null); + INSTRUCTION_PARSER(null); + INSTRUCTION_PARSER(endif); + INSTRUCTION_PARSER(zone); // stop + INSTRUCTION_PARSER(endscript); } void LocationParser_br::parse(Script *script) { diff --git a/engines/parallaction/parser_ns.cpp b/engines/parallaction/parser_ns.cpp index 4966d46ad3..96a4fced71 100644 --- a/engines/parallaction/parser_ns.cpp +++ b/engines/parallaction/parser_ns.cpp @@ -1146,7 +1146,7 @@ void LocationParser_ns::parseWalkNodes(WalkNodeList &list) { return; } - +/* typedef OpcodeImpl<ProgramParser_ns> OpcodeV1; #define INSTRUCTION_PARSER(sig) OpcodeV1(this, &ProgramParser_ns::instParse_##sig) @@ -1157,6 +1157,23 @@ typedef OpcodeImpl<LocationParser_ns> OpcodeV2; #define COMMAND_PARSER(sig) OpcodeV2(this, &LocationParser_ns::cmdParse_##sig) #define WARNING_PARSER(sig) OpcodeV2(this, &LocationParser_br::warning_##sig) +*/ + +#define SetOpcodeTable(x) table = &x; + + +typedef Common::Functor0Mem<void, ProgramParser_ns> OpcodeV1; +#define SetOpcodeTable(x) table = &x; +#define INSTRUCTION_PARSER(sig) table->push_back(new OpcodeV1(this, &ProgramParser_ns::instParse_##sig)) + +typedef Common::Functor0Mem<void, LocationParser_ns> OpcodeV2; +#define ZONE_PARSER(sig) table->push_back(new OpcodeV2(this, &LocationParser_ns::locZoneParse_##sig)) +#define ANIM_PARSER(sig) table->push_back(new OpcodeV2(this, &LocationParser_ns::locAnimParse_##sig)) +#define LOCATION_PARSER(sig) table->push_back(new OpcodeV2(this, &LocationParser_ns::locParse_##sig)) +#define COMMAND_PARSER(sig) table->push_back(new OpcodeV2(this, &LocationParser_ns::cmdParse_##sig)) + +#define WARNING_PARSER(sig) table->push_back(new OpcodeV2(this, &LocationParser_br::warning_##sig)) + void LocationParser_ns::init() { @@ -1169,85 +1186,67 @@ void LocationParser_ns::init() { _locationZoneStmt = new Table(ARRAYSIZE(_locationZoneStmtRes_ns), _locationZoneStmtRes_ns); _locationAnimStmt = new Table(ARRAYSIZE(_locationAnimStmtRes_ns), _locationAnimStmtRes_ns); - uint i; - - static const OpcodeV2 op2[] = { - WARNING_PARSER(unexpected), - COMMAND_PARSER(flags), // set - COMMAND_PARSER(flags), // clear - COMMAND_PARSER(zone), // start - COMMAND_PARSER(zone), // speak - COMMAND_PARSER(zone), // get - COMMAND_PARSER(location), // location - COMMAND_PARSER(zone), // open - COMMAND_PARSER(zone), // close - COMMAND_PARSER(zone), // on - COMMAND_PARSER(zone), // off - COMMAND_PARSER(call), // call - COMMAND_PARSER(flags), // toggle - COMMAND_PARSER(drop), // drop - COMMAND_PARSER(simple), // quit - COMMAND_PARSER(move), // move - COMMAND_PARSER(zone), // stop - COMMAND_PARSER(endcommands), // endcommands - COMMAND_PARSER(endcommands) // endzone - }; - - for (i = 0; i < ARRAYSIZE(op2); i++) - _commandParsers.push_back(&op2[i]); - - - static const OpcodeV2 op4[] = { - WARNING_PARSER(unexpected), - LOCATION_PARSER(endlocation), - LOCATION_PARSER(location), - LOCATION_PARSER(disk), - LOCATION_PARSER(nodes), - LOCATION_PARSER(zone), - LOCATION_PARSER(animation), - LOCATION_PARSER(localflags), - LOCATION_PARSER(commands), - LOCATION_PARSER(acommands), - LOCATION_PARSER(flags), - LOCATION_PARSER(comment), - LOCATION_PARSER(endcomment), - LOCATION_PARSER(sound), - LOCATION_PARSER(music) - }; - - for (i = 0; i < ARRAYSIZE(op4); i++) - _locationParsers.push_back(&op4[i]); - - static const OpcodeV2 op5[] = { - WARNING_PARSER(unexpected), - ZONE_PARSER(limits), - ZONE_PARSER(moveto), - ZONE_PARSER(type), - ZONE_PARSER(commands), - ZONE_PARSER(label), - ZONE_PARSER(flags), - ZONE_PARSER(endzone) - }; - - for (i = 0; i < ARRAYSIZE(op5); i++) - _locationZoneParsers.push_back(&op5[i]); - - static const OpcodeV2 op6[] = { - WARNING_PARSER(unexpected), - ANIM_PARSER(script), - ANIM_PARSER(commands), - ANIM_PARSER(type), - ANIM_PARSER(label), - ANIM_PARSER(flags), - ANIM_PARSER(file), - ANIM_PARSER(position), - ANIM_PARSER(moveto), - ANIM_PARSER(endanimation) - }; - - for (i = 0; i < ARRAYSIZE(op6); i++) - _locationAnimParsers.push_back(&op6[i]); - + Common::Array<const Opcode*> *table = 0; + + SetOpcodeTable(_commandParsers); + WARNING_PARSER(unexpected); + COMMAND_PARSER(flags); // set + COMMAND_PARSER(flags); // clear + COMMAND_PARSER(zone); // start + COMMAND_PARSER(zone); // speak + COMMAND_PARSER(zone); // get + COMMAND_PARSER(location); // location + COMMAND_PARSER(zone); // open + COMMAND_PARSER(zone); // close + COMMAND_PARSER(zone); // on + COMMAND_PARSER(zone); // off + COMMAND_PARSER(call); // call + COMMAND_PARSER(flags); // toggle + COMMAND_PARSER(drop); // drop + COMMAND_PARSER(simple); // quit + COMMAND_PARSER(move); // move + COMMAND_PARSER(zone); // stop + COMMAND_PARSER(endcommands); // endcommands + COMMAND_PARSER(endcommands); // endzone + + SetOpcodeTable(_locationParsers); + WARNING_PARSER(unexpected); + LOCATION_PARSER(endlocation); + LOCATION_PARSER(location); + LOCATION_PARSER(disk); + LOCATION_PARSER(nodes); + LOCATION_PARSER(zone); + LOCATION_PARSER(animation); + LOCATION_PARSER(localflags); + LOCATION_PARSER(commands); + LOCATION_PARSER(acommands); + LOCATION_PARSER(flags); + LOCATION_PARSER(comment); + LOCATION_PARSER(endcomment); + LOCATION_PARSER(sound); + LOCATION_PARSER(music); + + SetOpcodeTable(_locationZoneParsers); + WARNING_PARSER(unexpected); + ZONE_PARSER(limits); + ZONE_PARSER(moveto); + ZONE_PARSER(type); + ZONE_PARSER(commands); + ZONE_PARSER(label); + ZONE_PARSER(flags); + ZONE_PARSER(endzone); + + SetOpcodeTable(_locationAnimParsers); + WARNING_PARSER(unexpected); + ANIM_PARSER(script); + ANIM_PARSER(commands); + ANIM_PARSER(type); + ANIM_PARSER(label); + ANIM_PARSER(flags); + ANIM_PARSER(file); + ANIM_PARSER(position); + ANIM_PARSER(moveto); + ANIM_PARSER(endanimation); } @@ -1257,32 +1256,28 @@ void ProgramParser_ns::init() { _instructionNames = new Table(ARRAYSIZE(_instructionNamesRes_ns), _instructionNamesRes_ns); - static const OpcodeV1 op0[] = { - INSTRUCTION_PARSER(defLocal), // invalid opcode -> local definition - INSTRUCTION_PARSER(animation), // on - INSTRUCTION_PARSER(animation), // off - INSTRUCTION_PARSER(x), - INSTRUCTION_PARSER(y), - INSTRUCTION_PARSER(z), - INSTRUCTION_PARSER(f), - INSTRUCTION_PARSER(loop), - INSTRUCTION_PARSER(null), // endloop - INSTRUCTION_PARSER(null), // show - INSTRUCTION_PARSER(inc), - INSTRUCTION_PARSER(inc), // dec - INSTRUCTION_PARSER(set), - INSTRUCTION_PARSER(put), - INSTRUCTION_PARSER(call), - INSTRUCTION_PARSER(null), // wait - INSTRUCTION_PARSER(animation), // start - INSTRUCTION_PARSER(sound), - INSTRUCTION_PARSER(move), - INSTRUCTION_PARSER(endscript) - }; - - for (uint i = 0; i < ARRAYSIZE(op0); i++) - _instructionParsers.push_back(&op0[i]); - + Common::Array<const Opcode*> *table = 0; + SetOpcodeTable(_instructionParsers); + INSTRUCTION_PARSER(defLocal); // invalid opcode -> local definition + INSTRUCTION_PARSER(animation); // on + INSTRUCTION_PARSER(animation); // off + INSTRUCTION_PARSER(x); + INSTRUCTION_PARSER(y); + INSTRUCTION_PARSER(z); + INSTRUCTION_PARSER(f); + INSTRUCTION_PARSER(loop); + INSTRUCTION_PARSER(null); // endloop + INSTRUCTION_PARSER(null); // show + INSTRUCTION_PARSER(inc); + INSTRUCTION_PARSER(inc); // dec + INSTRUCTION_PARSER(set); + INSTRUCTION_PARSER(put); + INSTRUCTION_PARSER(call); + INSTRUCTION_PARSER(null); // wait + INSTRUCTION_PARSER(animation); // start + INSTRUCTION_PARSER(sound); + INSTRUCTION_PARSER(move); + INSTRUCTION_PARSER(endscript); } // diff --git a/engines/parallaction/staticres.cpp b/engines/parallaction/staticres.cpp index 18021db9a1..2c5cf281dd 100644 --- a/engines/parallaction/staticres.cpp +++ b/engines/parallaction/staticres.cpp @@ -29,23 +29,23 @@ namespace Parallaction { -byte Parallaction_ns::_mouseArrow[256] = { - 0x12, 0x11, 0x11, 0x11, 0x13, 0x12, 0x12, 0x12, 0x13, 0x12, 0x12, 0x11, 0x13, 0x12, 0x12, 0x00, - 0x13, 0x12, 0x12, 0x11, 0x13, 0x12, 0x12, 0x12, 0x13, 0x12, 0x12, 0x12, 0x13, 0x12, 0x12, 0x12, - 0x13, 0x12, 0x12, 0x12, 0x13, 0x12, 0x12, 0x12, 0x13, 0x12, 0x12, 0x13, 0x13, 0x13, 0x12, 0x00, - 0x13, 0x00, 0x12, 0x00, 0x13, 0x00, 0x12, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x11, 0x11, 0x11, 0x11, 0x12, 0x12, 0x12, 0x11, 0x12, 0x12, 0x12, 0x00, 0x12, 0x12, 0x12, 0x00, - 0x12, 0x12, 0x12, 0x00, 0x12, 0x12, 0x12, 0x11, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, - 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x13, 0x12, 0x12, 0x12, 0x00, 0x12, 0x12, 0x12, 0x00, - 0x13, 0x13, 0x12, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x11, 0x11, 0x11, 0x11, 0x12, 0x12, 0x12, 0x00, 0x12, 0x12, 0x12, 0x00, 0x12, 0x12, 0x12, 0x00, - 0x12, 0x12, 0x12, 0x00, 0x12, 0x12, 0x12, 0x00, 0x12, 0x12, 0x12, 0x11, 0x12, 0x12, 0x12, 0x12, - 0x12, 0x12, 0x12, 0x13, 0x12, 0x12, 0x12, 0x00, 0x12, 0x12, 0x12, 0x00, 0x13, 0x12, 0x12, 0x00, - 0x00, 0x12, 0x13, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x11, 0x11, 0x11, 0x00, 0x12, 0x12, 0x12, 0x00, 0x12, 0x12, 0x12, 0x00, 0x12, 0x12, 0x11, 0x00, - 0x12, 0x12, 0x12, 0x00, 0x12, 0x12, 0x12, 0x00, 0x12, 0x12, 0x12, 0x00, 0x12, 0x12, 0x12, 0x11, - 0x12, 0x12, 0x12, 0x00, 0x12, 0x12, 0x12, 0x00, 0x13, 0x12, 0x12, 0x00, 0x00, 0x12, 0x13, 0x00, - 0x00, 0x12, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +byte Parallaction_ns::_resMouseArrow[256] = { + 0x12, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x00, 0x00, + 0x11, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x13, 0x00, 0x00, 0x00, + 0x11, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x13, 0x00, 0x00, 0x00, 0x00, + 0x11, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x11, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x13, 0x00, 0x00, 0x00, 0x00, + 0x11, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x13, 0x00, 0x00, 0x00, + 0x11, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x13, 0x00, 0x00, + 0x11, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x13, 0x00, + 0x11, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x13, 0x00, + 0x11, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x13, 0x00, 0x00, + 0x11, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x13, 0x00, 0x00, 0x00, + 0x11, 0x12, 0x12, 0x11, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x13, 0x00, 0x00, 0x00, 0x00, + 0x11, 0x12, 0x11, 0x00, 0x11, 0x12, 0x12, 0x12, 0x12, 0x12, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x11, 0x11, 0x00, 0x00, 0x00, 0x11, 0x12, 0x12, 0x12, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x12, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; |