diff options
Diffstat (limited to 'engines/parallaction/parallaction.h')
-rw-r--r-- | engines/parallaction/parallaction.h | 698 |
1 files changed, 604 insertions, 94 deletions
diff --git a/engines/parallaction/parallaction.h b/engines/parallaction/parallaction.h index 31b125c92a..c0975d4c85 100644 --- a/engines/parallaction/parallaction.h +++ b/engines/parallaction/parallaction.h @@ -27,21 +27,18 @@ #define PARALLACTION_H #include "common/str.h" - +#include "common/stack.h" +#include "common/array.h" #include "engines/engine.h" #include "parallaction/defs.h" #include "parallaction/inventory.h" #include "parallaction/parser.h" +#include "parallaction/objects.h" #include "parallaction/disk.h" #include "parallaction/walk.h" -#include "parallaction/zone.h" -namespace GUI { - class ListWidget; - class CommandSender; -} extern OSystem *g_system; @@ -50,10 +47,10 @@ namespace Parallaction { enum { kDebugDisk = 1 << 0, kDebugWalk = 1 << 1, - kDebugLocation = 1 << 2, + kDebugParser = 1 << 2, kDebugDialogue = 1 << 3, kDebugGraphics = 1 << 4, - kDebugJobs = 1 << 5, + kDebugExec = 1 << 5, kDebugInput = 1 << 6, kDebugAudio = 1 << 7, kDebugMenu = 1 << 8 @@ -93,7 +90,8 @@ enum { kPriority18 = 18, kPriority19 = 19, kPriority20 = 20, - kPriority21 = 21 + kPriority21 = 21, + kPriority99 = 99 // fictitious priority value used as a flag to handle quick label deletion }; enum { @@ -143,32 +141,23 @@ struct PARALLACTIONGameDescription; struct Job; -typedef void (*JobFn)(void*, Job*); struct Job { uint16 _count; // # of executions left uint16 _tag; // used for ordering uint16 _finished; void * _parm; - JobFn _fn; public: - Job() : _count(0), _tag(0), _finished(0), _parm(NULL), _fn(NULL) { + Job() : _count(0), _tag(0), _finished(0), _parm(NULL) { } }; -typedef Job* JobPointer; -typedef ManagedList<JobPointer> JobList; - -typedef void (*callable)(void*); extern uint16 _mouseButtons; extern uint16 _score; extern uint16 _language; -extern Zone *_activeZone; extern uint32 _engineFlags; -extern callable _callables[]; -extern uint32 _localFlags[]; extern Command *_forwardedCommands[]; extern char _forwardedAnimationNames[][20]; extern uint16 _numForwards; @@ -200,19 +189,6 @@ extern const char *_minidrkiName; void waitUntilLeftClick(); -void jobRemovePickedItem(void*, Job *j); -void jobDisplayDroppedItem(void*, Job *j); -void jobToggleDoor(void*, Job *j); -void jobEraseAnimations(void *arg_0, Job *j); -void jobWalk(void*, Job *j); -void jobRunScripts(void*, Job *j); -void jobDisplayAnimations(void*, Job *j); -void jobDisplayLabel(void *parm, Job *j); -void jobWaitRemoveJob(void *parm, Job *j); -void jobShowInventory(void *parm, Job *j); -void jobHideInventory(void *parm, Job *j); -void jobEraseLabel(void *parm, Job *j); - class Debugger; @@ -221,12 +197,10 @@ class Menu; class SoundMan; - struct Location { Common::Point _startPosition; uint16 _startFrame; - WalkNodeList _walkNodes; char _name[100]; CommandList _aCommands; @@ -234,13 +208,18 @@ struct Location { char *_comment; char *_endComment; + // NS specific + WalkNodeList _walkNodes; + + // BRA specific + CommandList _escapeCommands; }; struct Character { Animation _ani; - StaticCnv *_head; - Cnv *_talk; - Cnv *_objs; + Graphics::Surface *_head; + Frames *_talk; + Frames *_objs; PathBuilder _builder; Character() : _builder(&_ani) { @@ -256,31 +235,133 @@ struct Character { _ani._frame = 0; _ani._flags = kFlagsActive | kFlagsNoName; _ani._type = kZoneYou; - _ani._label._cnv._data0 = NULL; + _ani._label._cnv.pixels = NULL; _ani._label._text = strdup("yourself"); } + void getFoot(Common::Point &foot) { + foot.x = _ani._left + _ani.width() / 2; + foot.y = _ani._top + _ani.height(); + } + + void setFoot(const Common::Point &foot) { + _ani._left = foot.x - _ani.width() / 2; + _ani._top = foot.y - _ani.height(); + } + + +}; + + + + +struct BackgroundInfo { + uint width; + uint height; + + Graphics::Surface bg; + MaskBuffer mask; + PathBuffer path; + + Palette palette; }; +class Opcode { + +public: + virtual void operator()() const = 0; + virtual ~Opcode() { } +}; -class Table { +template <class T> +class OpcodeImpl : public Opcode { - char **_data; - uint16 _size; - uint16 _used; - bool _disposeMemory; + typedef void (T::*Fn)(); + + T* _instance; + Fn _fn; public: - Table(uint32 size); - Table(uint32 size, const char** data); + OpcodeImpl(T* instance, const Fn &fn) : _instance(instance), _fn(fn) { } + + void operator()() const { + (_instance->*_fn)(); + } + +}; + +typedef Common::Array<const Opcode*> OpcodeSet; - ~Table(); +class JobOpcode { - void addData(const char* s); +public: + Job *_job; - int16 lookup(const char* s); + JobOpcode(Job *job) : _job(job) { } + + virtual void operator()() const = 0; + virtual ~JobOpcode() { + delete _job; + } }; +template <class T> +class OpcodeImpl2 : public JobOpcode { + + typedef void (T::*Fn)(void *, Job*); + + T* _instance; + Fn _fn; + +public: + OpcodeImpl2(T* instance, const Fn &fn, Job* job) : JobOpcode(job), _instance(instance), _fn(fn) { } + + void operator()() const { + (_instance->*_fn)(_job->_parm, _job); + } + +}; + +typedef JobOpcode* JobPointer; +typedef ManagedList<JobPointer> JobList; + +enum Jobs { + kJobDisplayAnimations = 0, + kJobEraseAnimations = 1, + kJobDisplayDroppedItem = 2, + kJobRemovePickedItem = 3, + kJobRunScripts = 4, + kJobWalk = 5, + kJobDisplayLabel = 6, + kJobEraseLabel = 7, + kJobWaitRemoveJob = 8, + kJobToggleDoor = 9, + + // NS specific + kJobShowInventory = 10, + kJobHideInventory, + + // BRA specific + kJobEraseSubtitle = 10, + kJobDisplaySubtitle, + kJobWaitRemoveSubtitleJob, + kJobPauseSfx, + kJobStopFollower, + kJobScroll +}; + + +#define DECLARE_UNQUALIFIED_ZONE_PARSER(sig) void locZoneParse_##sig() +#define DECLARE_UNQUALIFIED_ANIM_PARSER(sig) void locAnimParse_##sig() +#define DECLARE_UNQUALIFIED_COMMAND_PARSER(sig) void cmdParse_##sig() +#define DECLARE_UNQUALIFIED_LOCATION_PARSER(sig) void locParse_##sig() +#define DECLARE_UNQUALIFIED_INSTRUCTION_PARSER(sig) void instParse_##sig() + +#define DECLARE_UNQUALIFIED_COMMAND_OPCODE(op) void cmdOp_##op() +#define DECLARE_UNQUALIFIED_INSTRUCTION_OPCODE(op) void instOp_##op() + + +#define NUM_LOCATIONS 120 class Parallaction : public Engine { friend class Debugger; @@ -291,31 +372,50 @@ public: ~Parallaction(); int init(); - int go(); - void loadGame(); - void saveGame(); + virtual void loadGame() = 0; + virtual void saveGame() = 0; uint16 updateInput(); void waitTime(uint32 t); - void parseLocation(const char *filename); + uint _lookup; + Common::Stack<OpcodeSet*> _opcodes; + Common::Stack<Table*> _statements; + OpcodeSet *_currentOpcodes; + Table *_currentStatements; + void pushParserTables(OpcodeSet *opcodes, Table* statements); + void popParserTables(); + void parseStatement(); + + OpcodeSet _commandOpcodes; + + struct { + Command *cmd; + Zone *z; + } _cmdRunCtxt; + + OpcodeSet _instructionOpcodes; + + struct { + Animation *a; + InstructionList::iterator inst; + uint16 modCounter; + bool suspend; + } _instRunCtxt; + + void changeCursor(int32 index); void showCursor(bool visible); - void changeCharacter(const char *name); - - char *parseComment(Script &script); - char *parseDialogueString(Script &script); - Dialogue *parseDialogue(Script &script); - Job *addJob(JobFn fn, void *parm, uint16 tag); + Job *addJob(uint functionId, void *parm, uint16 tag); void removeJob(Job *j); void pauseJobs(); void resumeJobs(); void runJobs(); + virtual JobOpcode* createJobOpcode(uint functionId, Job *job) = 0; - void setPath(byte *path); void finalizeWalk(WalkNodeList *list); int16 selectWalkFrame(const Common::Point& pos, const WalkNode* from); void clipMove(Common::Point& pos, const WalkNode* from); @@ -333,16 +433,20 @@ public: void sortAnimations(); void freeAnimations(); + void showSlide(const char *name); + void setBackground(const char *background, const char *mask, const char *path); + void freeBackground(); + Table *_globalTable; Table *_objectsNames; Table *_zoneTypeNames; Table *_zoneFlagNames; - Table *_commandsNames; Table *_callableNames; - Table *_instructionNames; Table *_localFlagNames; + void showLabel(Label &label); + void hideLabel(uint priority); public: int getGameType() const; @@ -359,21 +463,18 @@ public: int32 _screenHeight; int32 _screenSize; - int32 _screenMaskWidth; - int32 _screenMaskSize; - int32 _screenPathWidth; - int32 _screenPathSize; + PathBuffer *_pathBuffer; SoundMan *_soundMan; Gfx* _gfx; - Menu* _menu; Disk* _disk; Character _char; char _characterName[30]; - char _locationNames[120][32]; + uint32 _localFlags[NUM_LOCATIONS]; + char _locationNames[NUM_LOCATIONS][32]; int16 _currentLocationIndex; uint16 _numLocations; Location _location; @@ -382,9 +483,16 @@ public: Common::Point _mousePos; + Zone *_activeZone; + ZoneList _zones; AnimationList _animations; + Font *_labelFont; + Font *_menuFont; + Font *_dialogueFont; + + protected: // data Debugger *_debugger; @@ -397,8 +505,6 @@ protected: // data Label* _label; }; - bool _skipMenu; - bool _mouseHidden; // input-only @@ -422,11 +528,15 @@ protected: // data bool _hasLocationSound; char _locationSound[50]; + BackgroundInfo *_backgroundInfo; + + Job *_jDrawLabel; + Job *_jEraseLabel; + Zone *_hoverZone; protected: // members bool detectGame(void); - void initGame(); void initGlobals(); void runGame(); uint32 getElapsedTime(); @@ -435,34 +545,20 @@ protected: // members InputData *translateInput(); void processInput(InputData*); - int buildSaveFileList(Common::StringList& l); - int selectSaveFile(uint16 arg_0, const char* caption, const char* button); - void doLoadGame(uint16 slot); - void doSaveGame(uint16 slot, const char* name); - void doLocationEnterTransition(); - void changeLocation(char *location); - void showSlide(const char *name); - void resolveLocationForwards(); + virtual void changeLocation(char *location) = 0; + virtual void changeCharacter(const char *name) = 0; + void allocateLocationSlot(const char *name); + void finalizeLocationParsing(); void switchBackground(const char* background, const char* mask); void freeLocation(); + void showLocationComment(const char *text, bool end); - void parseZone(Script &script, ZoneList &list, char *name); - void parseZoneTypeBlock(Script &script, Zone *z); void displayCharacterComment(ExamineData *data); void displayItemComment(ExamineData *data); - void parseWalkNodes(Script& script, WalkNodeList &list); - void initWalk(); uint16 checkDoor(); - Animation * parseAnimation(Script &script, AnimationList &list, char *name); - void parseScriptLine(Instruction *inst, Animation *a, LocalVariable *locals); - void loadProgram(Animation *a, char *filename); - LValue getLValue(Instruction *inst, char *str, LocalVariable *locals, Animation *a); - - void parseCommands(Script &script, CommandList&); - void freeCharacter(); int addInventoryItem(uint16 item); @@ -473,6 +569,23 @@ protected: // members public: virtual void callFunction(uint index, void* parm) { } + virtual void renderLabel(Graphics::Surface *cnv, char *text) { } + virtual void setMousePointer(int16 index) = 0; + + + virtual void parseLocation(const char* name) = 0; + + virtual void jobDisplayAnimations(void*, Job *j) = 0; + virtual void jobEraseAnimations(void *arg_0, Job *j) = 0; + virtual void jobRunScripts(void*, Job *j) = 0; + virtual void jobDisplayDroppedItem(void*, Job *j) = 0; + virtual void jobRemovePickedItem(void*, Job *j) = 0; + virtual void jobToggleDoor(void*, Job *j) = 0; + virtual void jobWalk(void*, Job *j) = 0; + virtual void jobDisplayLabel(void *parm, Job *j) = 0; + virtual void jobEraseLabel(void *parm, Job *j) = 0; + virtual void jobWaitRemoveJob(void *parm, Job *j) = 0; + public: const char **_zoneFlagNamesRes; @@ -483,21 +596,54 @@ public: }; + class Parallaction_ns : public Parallaction { public: Parallaction_ns(OSystem* syst) : Parallaction(syst) { } - ~Parallaction_ns() { } + ~Parallaction_ns(); int init(); + int go(); public: typedef void (Parallaction_ns::*Callable)(void*); virtual void callFunction(uint index, void* parm); + void renderLabel(Graphics::Surface *cnv, char *text); + void setMousePointer(int16 index); + + void initJobs(); + + typedef void (Parallaction_ns::*JobFn)(void*, Job*); + + const JobFn *_jobsFn; + JobOpcode* createJobOpcode(uint functionId, Job *job); + + void loadGame(); + void saveGame(); + private: - void initResources(); + Menu* _menu; + + void initFonts(); + void freeFonts(); + +private: + void changeLocation(char *location); + void changeCharacter(const char *name); + + void doLoadGame(uint16 slot); + void doSaveGame(uint16 slot, const char* name); + int buildSaveFileList(Common::StringList& l); + int selectSaveFile(uint16 arg_0, const char* caption, const char* button); + + void initResources(); + void initCursors(); + + static byte _mouseArrow[256]; + Graphics::Surface *_mouseComposedArrow; static const Callable _dosCallables[25]; static const Callable _amigaCallables[25]; @@ -536,26 +682,266 @@ private: void _c_HBOn(void*); const Callable *_callables; + +protected: + void jobDisplayAnimations(void*, Job *j); + void jobEraseAnimations(void *arg_0, Job *j); + void jobRunScripts(void*, Job *j); + void jobDisplayDroppedItem(void*, Job *j); + void jobRemovePickedItem(void*, Job *j); + void jobToggleDoor(void*, Job *j); + void jobWalk(void*, Job *j); + void jobDisplayLabel(void *parm, Job *j); + void jobEraseLabel(void *parm, Job *j); + void jobWaitRemoveJob(void *parm, Job *j); + void jobShowInventory(void *parm, Job *j); + void jobHideInventory(void *parm, Job *j); + + // location parser + OpcodeSet _locationParsers; + OpcodeSet _locationZoneParsers; + OpcodeSet _locationAnimParsers; + OpcodeSet _commandParsers; + Table *_commandsNames; + Table *_locationStmt; + Table *_locationZoneStmt; + Table *_locationAnimStmt; + + struct LocationParserContext { + bool end; + + const char *filename; + Script *script; + Zone *z; + Animation *a; + int nextToken; + CommandList *list; + bool endcommands; + Command *cmd; + + // BRA specific + int numZones; + } _locParseCtxt; + + DECLARE_UNQUALIFIED_LOCATION_PARSER(invalid); + DECLARE_UNQUALIFIED_LOCATION_PARSER(endlocation); + DECLARE_UNQUALIFIED_LOCATION_PARSER(location); + DECLARE_UNQUALIFIED_LOCATION_PARSER(disk); + DECLARE_UNQUALIFIED_LOCATION_PARSER(nodes); + DECLARE_UNQUALIFIED_LOCATION_PARSER(zone); + DECLARE_UNQUALIFIED_LOCATION_PARSER(animation); + DECLARE_UNQUALIFIED_LOCATION_PARSER(localflags); + DECLARE_UNQUALIFIED_LOCATION_PARSER(commands); + DECLARE_UNQUALIFIED_LOCATION_PARSER(acommands); + DECLARE_UNQUALIFIED_LOCATION_PARSER(flags); + DECLARE_UNQUALIFIED_LOCATION_PARSER(comment); + DECLARE_UNQUALIFIED_LOCATION_PARSER(endcomment); + DECLARE_UNQUALIFIED_LOCATION_PARSER(sound); + DECLARE_UNQUALIFIED_LOCATION_PARSER(music); + DECLARE_UNQUALIFIED_LOCATION_PARSER(redundant); + DECLARE_UNQUALIFIED_ZONE_PARSER(invalid); + DECLARE_UNQUALIFIED_ZONE_PARSER(limits); + DECLARE_UNQUALIFIED_ZONE_PARSER(moveto); + DECLARE_UNQUALIFIED_ZONE_PARSER(type); + DECLARE_UNQUALIFIED_ZONE_PARSER(commands); + DECLARE_UNQUALIFIED_ZONE_PARSER(label); + DECLARE_UNQUALIFIED_ZONE_PARSER(flags); + DECLARE_UNQUALIFIED_ZONE_PARSER(endzone); + DECLARE_UNQUALIFIED_ANIM_PARSER(invalid); + DECLARE_UNQUALIFIED_ANIM_PARSER(script); + DECLARE_UNQUALIFIED_ANIM_PARSER(commands); + DECLARE_UNQUALIFIED_ANIM_PARSER(type); + DECLARE_UNQUALIFIED_ANIM_PARSER(label); + DECLARE_UNQUALIFIED_ANIM_PARSER(flags); + DECLARE_UNQUALIFIED_ANIM_PARSER(file); + DECLARE_UNQUALIFIED_ANIM_PARSER(position); + DECLARE_UNQUALIFIED_ANIM_PARSER(moveto); + DECLARE_UNQUALIFIED_ANIM_PARSER(endanimation); + DECLARE_UNQUALIFIED_COMMAND_PARSER(invalid); + DECLARE_UNQUALIFIED_COMMAND_PARSER(flags); + DECLARE_UNQUALIFIED_COMMAND_PARSER(animation); + DECLARE_UNQUALIFIED_COMMAND_PARSER(zone); + DECLARE_UNQUALIFIED_COMMAND_PARSER(location); + DECLARE_UNQUALIFIED_COMMAND_PARSER(drop); + DECLARE_UNQUALIFIED_COMMAND_PARSER(call); + DECLARE_UNQUALIFIED_COMMAND_PARSER(simple); + DECLARE_UNQUALIFIED_COMMAND_PARSER(move); + DECLARE_UNQUALIFIED_COMMAND_PARSER(endcommands); + + virtual void parseGetData(Script &script, Zone *z); + virtual void parseExamineData(Script &script, Zone *z); + virtual void parseDoorData(Script &script, Zone *z); + virtual void parseMergeData(Script &script, Zone *z); + virtual void parseHearData(Script &script, Zone *z); + virtual void parseSpeakData(Script &script, Zone *z); + + void parseLocation(const char *filename); + char *parseComment(Script &script); + char *parseDialogueString(Script &script); + Dialogue *parseDialogue(Script &script); + void parseZone(Script &script, ZoneList &list, char *name); + void parseZoneTypeBlock(Script &script, Zone *z); + void parseWalkNodes(Script& script, WalkNodeList &list); + Animation *parseAnimation(Script &script, AnimationList &list, char *name); + void parseCommands(Script &script, CommandList&); + void parseCommandFlags(); + void createCommand(uint id); + void addCommand(); + void initOpcodes(); + void initParsers(); + + + // program parser + OpcodeSet _instructionParsers; + Table *_instructionNames; + + struct { + bool end; + Animation *a; + Instruction *inst; + LocalVariable *locals; + Program *program; + + // BRA specific + Instruction *openIf; + } _instParseCtxt; + + DECLARE_UNQUALIFIED_INSTRUCTION_PARSER(defLocal); + DECLARE_UNQUALIFIED_INSTRUCTION_PARSER(animation); + DECLARE_UNQUALIFIED_INSTRUCTION_PARSER(loop); + DECLARE_UNQUALIFIED_INSTRUCTION_PARSER(x); + DECLARE_UNQUALIFIED_INSTRUCTION_PARSER(y); + DECLARE_UNQUALIFIED_INSTRUCTION_PARSER(z); + DECLARE_UNQUALIFIED_INSTRUCTION_PARSER(f); + DECLARE_UNQUALIFIED_INSTRUCTION_PARSER(inc); + DECLARE_UNQUALIFIED_INSTRUCTION_PARSER(set); + DECLARE_UNQUALIFIED_INSTRUCTION_PARSER(move); + DECLARE_UNQUALIFIED_INSTRUCTION_PARSER(put); + DECLARE_UNQUALIFIED_INSTRUCTION_PARSER(call); + DECLARE_UNQUALIFIED_INSTRUCTION_PARSER(sound); + DECLARE_UNQUALIFIED_INSTRUCTION_PARSER(null); + DECLARE_UNQUALIFIED_INSTRUCTION_PARSER(endscript); + + void parseInstruction(Animation *a, LocalVariable *locals); + void loadProgram(Animation *a, const char *filename); + void parseLValue(ScriptVar &var, const char *str); + virtual void parseRValue(ScriptVar &var, const char *str); + void wrapLocalVar(LocalVariable *local); + + DECLARE_UNQUALIFIED_COMMAND_OPCODE(invalid); + DECLARE_UNQUALIFIED_COMMAND_OPCODE(set); + DECLARE_UNQUALIFIED_COMMAND_OPCODE(clear); + DECLARE_UNQUALIFIED_COMMAND_OPCODE(start); + DECLARE_UNQUALIFIED_COMMAND_OPCODE(speak); + DECLARE_UNQUALIFIED_COMMAND_OPCODE(get); + DECLARE_UNQUALIFIED_COMMAND_OPCODE(location); + DECLARE_UNQUALIFIED_COMMAND_OPCODE(open); + DECLARE_UNQUALIFIED_COMMAND_OPCODE(close); + DECLARE_UNQUALIFIED_COMMAND_OPCODE(on); + DECLARE_UNQUALIFIED_COMMAND_OPCODE(off); + DECLARE_UNQUALIFIED_COMMAND_OPCODE(call); + DECLARE_UNQUALIFIED_COMMAND_OPCODE(toggle); + DECLARE_UNQUALIFIED_COMMAND_OPCODE(drop); + DECLARE_UNQUALIFIED_COMMAND_OPCODE(quit); + DECLARE_UNQUALIFIED_COMMAND_OPCODE(move); + DECLARE_UNQUALIFIED_COMMAND_OPCODE(stop); + + DECLARE_UNQUALIFIED_INSTRUCTION_OPCODE(invalid); + DECLARE_UNQUALIFIED_INSTRUCTION_OPCODE(on); + DECLARE_UNQUALIFIED_INSTRUCTION_OPCODE(off); + DECLARE_UNQUALIFIED_INSTRUCTION_OPCODE(loop); + DECLARE_UNQUALIFIED_INSTRUCTION_OPCODE(endloop); + DECLARE_UNQUALIFIED_INSTRUCTION_OPCODE(null); + DECLARE_UNQUALIFIED_INSTRUCTION_OPCODE(call); + DECLARE_UNQUALIFIED_INSTRUCTION_OPCODE(inc); + DECLARE_UNQUALIFIED_INSTRUCTION_OPCODE(set); + DECLARE_UNQUALIFIED_INSTRUCTION_OPCODE(put); + DECLARE_UNQUALIFIED_INSTRUCTION_OPCODE(wait); + DECLARE_UNQUALIFIED_INSTRUCTION_OPCODE(start); + DECLARE_UNQUALIFIED_INSTRUCTION_OPCODE(sound); + DECLARE_UNQUALIFIED_INSTRUCTION_OPCODE(move); + DECLARE_UNQUALIFIED_INSTRUCTION_OPCODE(endscript); + }; -class Parallaction_br : public Parallaction { + + +#define NUM_ZONES 100 + +class Parallaction_br : public Parallaction_ns { + + typedef Parallaction_ns Super; public: - Parallaction_br(OSystem* syst) : Parallaction(syst) { } - ~Parallaction_br() { } + Parallaction_br(OSystem* syst) : Parallaction_ns(syst) { } + ~Parallaction_br(); int init(); + int go(); public: typedef void (Parallaction_br::*Callable)(void*); virtual void callFunction(uint index, void* parm); public: + Table *_countersNames; + Table *_audioCommandsNames; const char **_audioCommandsNamesRes; + int _part; + int _progress; + + int _zeta0; + int _zeta1; + int _zeta2; + + int16 _lipSyncVal; + uint _subtitleLipSync; + + Label _subtitle0; + Label _subtitle1; + + Zone *_activeZone2; + + int32 _counters[32]; + + uint32 _zoneFlags[NUM_LOCATIONS][NUM_ZONES]; + private: void initResources(); + void initFonts(); + void freeFonts(); + void initOpcodes(); + void initParsers(); + void initJobs(); + + typedef void (Parallaction_br::*JobFn)(void*, Job*); + const JobFn *_jobsFn; + JobOpcode* createJobOpcode(uint functionId, Job *job); + + + void changeLocation(char *location); + void changeCharacter(const char *name); + + void initPart(); + void freePart(); + void startPart(); + + void setMousePointer(int16 index); + void initCursors(); + + Graphics::Surface *_dinoCursor; + Graphics::Surface *_dougCursor; + Graphics::Surface *_donnaCursor; + Graphics::Surface *_mouseArrow; + + + int showMenu(); + void renderMenuItem(Graphics::Surface &surf, const char *text); + void invertMenuItem(Graphics::Surface &surf); + + void splash(const char *name); static const Callable _dosCallables[6]; @@ -567,6 +953,130 @@ private: void _c_password(void*); const Callable *_callables; + + DECLARE_UNQUALIFIED_LOCATION_PARSER(location); + DECLARE_UNQUALIFIED_LOCATION_PARSER(zone); + DECLARE_UNQUALIFIED_LOCATION_PARSER(animation); + DECLARE_UNQUALIFIED_LOCATION_PARSER(localflags); + DECLARE_UNQUALIFIED_LOCATION_PARSER(flags); + DECLARE_UNQUALIFIED_LOCATION_PARSER(comment); + DECLARE_UNQUALIFIED_LOCATION_PARSER(endcomment); + DECLARE_UNQUALIFIED_LOCATION_PARSER(sound); + DECLARE_UNQUALIFIED_LOCATION_PARSER(music); + DECLARE_UNQUALIFIED_LOCATION_PARSER(redundant); + DECLARE_UNQUALIFIED_LOCATION_PARSER(ifchar); + DECLARE_UNQUALIFIED_LOCATION_PARSER(character); + DECLARE_UNQUALIFIED_LOCATION_PARSER(mask); + DECLARE_UNQUALIFIED_LOCATION_PARSER(path); + DECLARE_UNQUALIFIED_LOCATION_PARSER(escape); + DECLARE_UNQUALIFIED_LOCATION_PARSER(zeta); + DECLARE_UNQUALIFIED_LOCATION_PARSER(null); + DECLARE_UNQUALIFIED_COMMAND_PARSER(ifchar); + DECLARE_UNQUALIFIED_COMMAND_PARSER(endif); + DECLARE_UNQUALIFIED_COMMAND_PARSER(zone); + DECLARE_UNQUALIFIED_COMMAND_PARSER(location); + DECLARE_UNQUALIFIED_COMMAND_PARSER(toggle); + DECLARE_UNQUALIFIED_COMMAND_PARSER(string); + DECLARE_UNQUALIFIED_COMMAND_PARSER(math); + DECLARE_UNQUALIFIED_COMMAND_PARSER(test); + DECLARE_UNQUALIFIED_COMMAND_PARSER(music); + DECLARE_UNQUALIFIED_COMMAND_PARSER(zeta); + DECLARE_UNQUALIFIED_COMMAND_PARSER(swap); + DECLARE_UNQUALIFIED_COMMAND_PARSER(give); + DECLARE_UNQUALIFIED_COMMAND_PARSER(text); + DECLARE_UNQUALIFIED_COMMAND_PARSER(unary); + + void parseLocation(const char* name); + + DECLARE_UNQUALIFIED_INSTRUCTION_PARSER(zone); + DECLARE_UNQUALIFIED_INSTRUCTION_PARSER(color); + DECLARE_UNQUALIFIED_INSTRUCTION_PARSER(mask); + DECLARE_UNQUALIFIED_INSTRUCTION_PARSER(print); + DECLARE_UNQUALIFIED_INSTRUCTION_PARSER(text); + DECLARE_UNQUALIFIED_INSTRUCTION_PARSER(if_op); + DECLARE_UNQUALIFIED_INSTRUCTION_PARSER(endif); + + virtual void parseRValue(ScriptVar &var, const char *str); + + DECLARE_UNQUALIFIED_COMMAND_OPCODE(location); + DECLARE_UNQUALIFIED_COMMAND_OPCODE(open); + DECLARE_UNQUALIFIED_COMMAND_OPCODE(close); + DECLARE_UNQUALIFIED_COMMAND_OPCODE(on); + DECLARE_UNQUALIFIED_COMMAND_OPCODE(off); + DECLARE_UNQUALIFIED_COMMAND_OPCODE(call); + DECLARE_UNQUALIFIED_COMMAND_OPCODE(drop); + DECLARE_UNQUALIFIED_COMMAND_OPCODE(move); + DECLARE_UNQUALIFIED_COMMAND_OPCODE(start); + DECLARE_UNQUALIFIED_COMMAND_OPCODE(stop); + DECLARE_UNQUALIFIED_COMMAND_OPCODE(character); + DECLARE_UNQUALIFIED_COMMAND_OPCODE(followme); + DECLARE_UNQUALIFIED_COMMAND_OPCODE(onmouse); + DECLARE_UNQUALIFIED_COMMAND_OPCODE(offmouse); + DECLARE_UNQUALIFIED_COMMAND_OPCODE(add); + DECLARE_UNQUALIFIED_COMMAND_OPCODE(leave); + DECLARE_UNQUALIFIED_COMMAND_OPCODE(inc); + DECLARE_UNQUALIFIED_COMMAND_OPCODE(dec); + DECLARE_UNQUALIFIED_COMMAND_OPCODE(ifeq); + DECLARE_UNQUALIFIED_COMMAND_OPCODE(iflt); + DECLARE_UNQUALIFIED_COMMAND_OPCODE(ifgt); + DECLARE_UNQUALIFIED_COMMAND_OPCODE(let); + DECLARE_UNQUALIFIED_COMMAND_OPCODE(music); + DECLARE_UNQUALIFIED_COMMAND_OPCODE(fix); + DECLARE_UNQUALIFIED_COMMAND_OPCODE(unfix); + DECLARE_UNQUALIFIED_COMMAND_OPCODE(zeta); + DECLARE_UNQUALIFIED_COMMAND_OPCODE(scroll); + DECLARE_UNQUALIFIED_COMMAND_OPCODE(swap); + DECLARE_UNQUALIFIED_COMMAND_OPCODE(give); + DECLARE_UNQUALIFIED_COMMAND_OPCODE(text); + DECLARE_UNQUALIFIED_COMMAND_OPCODE(part); + DECLARE_UNQUALIFIED_COMMAND_OPCODE(testsfx); + DECLARE_UNQUALIFIED_COMMAND_OPCODE(ret); + DECLARE_UNQUALIFIED_COMMAND_OPCODE(onsave); + DECLARE_UNQUALIFIED_COMMAND_OPCODE(offsave); + DECLARE_UNQUALIFIED_ZONE_PARSER(limits); + DECLARE_UNQUALIFIED_ZONE_PARSER(moveto); + DECLARE_UNQUALIFIED_ZONE_PARSER(type); + DECLARE_UNQUALIFIED_ANIM_PARSER(file); + DECLARE_UNQUALIFIED_ANIM_PARSER(position); + DECLARE_UNQUALIFIED_ANIM_PARSER(moveto); + DECLARE_UNQUALIFIED_ANIM_PARSER(endanimation); + + DECLARE_UNQUALIFIED_INSTRUCTION_OPCODE(on); + DECLARE_UNQUALIFIED_INSTRUCTION_OPCODE(off); + DECLARE_UNQUALIFIED_INSTRUCTION_OPCODE(loop); + DECLARE_UNQUALIFIED_INSTRUCTION_OPCODE(inc); + DECLARE_UNQUALIFIED_INSTRUCTION_OPCODE(dec); + DECLARE_UNQUALIFIED_INSTRUCTION_OPCODE(set); + DECLARE_UNQUALIFIED_INSTRUCTION_OPCODE(put); + DECLARE_UNQUALIFIED_INSTRUCTION_OPCODE(wait); + DECLARE_UNQUALIFIED_INSTRUCTION_OPCODE(start); + DECLARE_UNQUALIFIED_INSTRUCTION_OPCODE(process); + DECLARE_UNQUALIFIED_INSTRUCTION_OPCODE(move); + DECLARE_UNQUALIFIED_INSTRUCTION_OPCODE(color); + DECLARE_UNQUALIFIED_INSTRUCTION_OPCODE(mask); + DECLARE_UNQUALIFIED_INSTRUCTION_OPCODE(print); + DECLARE_UNQUALIFIED_INSTRUCTION_OPCODE(text); + DECLARE_UNQUALIFIED_INSTRUCTION_OPCODE(mul); + DECLARE_UNQUALIFIED_INSTRUCTION_OPCODE(div); + DECLARE_UNQUALIFIED_INSTRUCTION_OPCODE(ifeq); + DECLARE_UNQUALIFIED_INSTRUCTION_OPCODE(iflt); + DECLARE_UNQUALIFIED_INSTRUCTION_OPCODE(ifgt); + DECLARE_UNQUALIFIED_INSTRUCTION_OPCODE(endif); + DECLARE_UNQUALIFIED_INSTRUCTION_OPCODE(stop); + DECLARE_UNQUALIFIED_INSTRUCTION_OPCODE(endscript); + + Job *_jDisplaySubtitle; + Job *_jEraseSubtitle; + void setupSubtitles(char *s, char *s2, int y); + + void jobWaitRemoveLabelJob(void *parm, Job *job); + void jobDisplaySubtitle(void *parm, Job *job); + void jobEraseSubtitle(void *parm, Job *job); + void jobWaitRemoveSubtitleJob(void *parm, Job *job); + void jobPauseSfx(void *parm, Job *job); + void jobStopFollower(void *parm, Job *job); + void jobScroll(void *parm, Job *job); + }; // FIXME: remove global |