diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/parallaction/animation.cpp | 36 | ||||
-rw-r--r-- | engines/parallaction/callables.cpp | 4 | ||||
-rw-r--r-- | engines/parallaction/commands.cpp | 6 | ||||
-rw-r--r-- | engines/parallaction/defs.h | 11 | ||||
-rw-r--r-- | engines/parallaction/inventory.cpp | 2 | ||||
-rw-r--r-- | engines/parallaction/location.cpp | 6 | ||||
-rw-r--r-- | engines/parallaction/parallaction.cpp | 35 | ||||
-rw-r--r-- | engines/parallaction/parallaction.h | 21 | ||||
-rw-r--r-- | engines/parallaction/walk.cpp | 30 | ||||
-rw-r--r-- | engines/parallaction/zone.cpp | 18 | ||||
-rw-r--r-- | engines/parallaction/zone.h | 12 |
11 files changed, 93 insertions, 88 deletions
diff --git a/engines/parallaction/animation.cpp b/engines/parallaction/animation.cpp index 0af2561250..edcf47a861 100644 --- a/engines/parallaction/animation.cpp +++ b/engines/parallaction/animation.cpp @@ -67,7 +67,7 @@ Animation *findAnimation(const char *name) { while (v4) { if (!scumm_stricmp(name, v4->_zone._label._text)) return v4; - v4 = (Animation*)v4->_zone._node._next; + v4 = (Animation*)v4->_zone._next; } return NULL; @@ -83,7 +83,7 @@ Animation *Parallaction::parseAnimation(Script& script, Node *list, char *name) vD0->_zone._label._text = (char*)malloc(strlen(name)+1); strcpy(vD0->_zone._label._text, name); - addNode(list, &vD0->_zone._node); + addNode(list, &vD0->_zone); fillBuffers(script, true); while (scumm_stricmp(_tokens[0], "endanimation")) { @@ -160,7 +160,7 @@ void freeScript(Program *program) { if (!program) return; free(program->_locals); - freeNodeList(&program->_node); + freeNodeList(program); return; } @@ -172,7 +172,7 @@ void freeAnimations() { while (v4) { freeScript(v4->_program); _vm->_gfx->freeCnv(&v4->_cnv); - v4 = (Animation*)v4->_zone._node._next; + v4 = (Animation*)v4->_zone._next; } return; @@ -188,7 +188,7 @@ void jobDisplayAnimations(void *parm, Job *j) { uint16 _si = 0; - for ( ; v18; v18 = (Animation*)v18->_zone._node._next) { + for ( ; v18; v18 = (Animation*)v18->_zone._next) { if ((v18->_zone._flags & kFlagsActive) && ((v18->_zone._flags & kFlagsRemove) == 0)) { v14._width = v18->_cnv._width; @@ -229,7 +229,7 @@ void jobEraseAnimations(void *arg_0, Job *j) { Animation *a = (Animation*)_animations._next; - for (; a; a=(Animation*)a->_zone._node._next) { + for (; a; a=(Animation*)a->_zone._next) { if (((a->_zone._flags & kFlagsActive) == 0) && ((a->_zone._flags & kFlagsRemove) == 0)) continue; @@ -262,7 +262,7 @@ void Parallaction::loadProgram(Animation *a, char *filename) { a->_program = (Program*)malloc(sizeof(Program)); memset(a->_program, 0, sizeof(Program)); a->_program->_locals = (LocalVariable*)malloc(sizeof(LocalVariable)*10); - Node *vD0 = &a->_program->_node; + Node *vD0 = a->_program; Instruction *vCC = (Instruction*)malloc(sizeof(Instruction)); memset(vCC, 0, sizeof(Instruction)); @@ -270,8 +270,8 @@ void Parallaction::loadProgram(Animation *a, char *filename) { while (scumm_stricmp(_tokens[0], "endscript")) { parseScriptLine(vCC, a, a->_program->_locals); - addNode(vD0, &vCC->_node); - vD0 = &vCC->_node; + addNode(vD0, vCC); + vD0 = vCC; vCC = (Instruction*)malloc(sizeof(Instruction)); memset(vCC, 0, sizeof(Instruction)); @@ -279,11 +279,11 @@ void Parallaction::loadProgram(Animation *a, char *filename) { } vCC->_index = INST_END; - addNode(vD0, &vCC->_node); + addNode(vD0, vCC); delete script; - a->_program->_ip = (Instruction*)a->_program->_node._next; + a->_program->_ip = (Instruction*)a->_program->_next; return; } @@ -490,7 +490,7 @@ void jobRunScripts(void *parm, Job *j) { WalkNode *v4 = NULL; if (a->_zone._flags & kFlagsCharacter) a->_z = a->_zone.pos._position._y + a->_cnv._height; - for ( ; a; a = (Animation*)a->_zone._node._next) { + for ( ; a; a = (Animation*)a->_zone._next) { if ((a->_zone._flags & kFlagsActing) == 0) continue; Instruction *inst = a->_program->_ip; @@ -566,7 +566,7 @@ void jobRunScripts(void *parm, Job *j) { case INST_MOVE: // move v4 = buildWalkPath(*inst->_opA._pvalue, *inst->_opB._pvalue); - addJob(jobWalk, v4, kPriority19 ); + _vm->addJob(jobWalk, v4, kPriority19 ); _engineFlags |= kEngineWalking; break; @@ -591,7 +591,7 @@ void jobRunScripts(void *parm, Job *j) { a->_zone._flags &= ~kFlagsActing; runCommands(a->_zone._commands, (Zone*)&a->_zone); } - a->_program->_ip = (Instruction*)a->_program->_node._next; + a->_program->_ip = (Instruction*)a->_program->_next; goto label1; @@ -625,10 +625,10 @@ void jobRunScripts(void *parm, Job *j) { } - inst = (Instruction*)inst->_node._next; + inst = (Instruction*)inst->_next; } - a->_program->_ip = (Instruction*)inst->_node._next; + a->_program->_ip = (Instruction*)inst->_next; label1: if (a->_zone._flags & kFlagsCharacter) @@ -672,9 +672,9 @@ void sortAnimations() { v8 = v8->_next; } - v4 = (Animation*)vC->_zone._node._next; + v4 = (Animation*)vC->_zone._next; - addNode(v8, &vC->_zone._node); + addNode(v8, &vC->_zone); vC = v4; } diff --git a/engines/parallaction/callables.cpp b/engines/parallaction/callables.cpp index 950b8a6a24..b422909010 100644 --- a/engines/parallaction/callables.cpp +++ b/engines/parallaction/callables.cpp @@ -322,7 +322,7 @@ void _c_finito(void *parm) { _vm->_menu->selectCharacter(); } - removeNode(&_vm->_char._ani._zone._node); + removeNode(&_vm->_char._ani._zone); _vm->_locationNames[0][0] = '\0'; _vm->_numLocations = 0; _commandFlags = 0; @@ -339,7 +339,7 @@ void _c_finito(void *parm) { _engineFlags &= ~kEngineQuit; - addNode(&_animations, &_vm->_char._ani._zone._node); + addNode(&_animations, &_vm->_char._ani._zone); _score = 0; return; diff --git a/engines/parallaction/commands.cpp b/engines/parallaction/commands.cpp index ca8ae70085..52ce068a63 100644 --- a/engines/parallaction/commands.cpp +++ b/engines/parallaction/commands.cpp @@ -286,7 +286,7 @@ void runCommands(Command *list, Zone *z) { case CMD_OPEN: // open u->_zone->_flags &= ~kFlagsClosed; if (u->_zone->u.door->_cnv._count != 0) { - addJob(&jobToggleDoor, (void*)u->_zone, kPriority18 ); + _vm->addJob(&jobToggleDoor, (void*)u->_zone, kPriority18 ); } break; @@ -305,7 +305,7 @@ void runCommands(Command *list, Zone *z) { u->_zone->_flags &= ~kFlagsRemove; u->_zone->_flags |= kFlagsActive; if ((u->_zone->_type & 0xFFFF) == kZoneGet) { - addJob(&jobDisplayDroppedItem, u->_zone, kPriority17 ); + _vm->addJob(&jobDisplayDroppedItem, u->_zone, kPriority17 ); } } break; @@ -334,7 +334,7 @@ void runCommands(Command *list, Zone *z) { WalkNode *vC = buildWalkPath(u->_move._x, u->_move._y); - addJob(&jobWalk, vC, kPriority19 ); + _vm->addJob(&jobWalk, vC, kPriority19 ); _engineFlags |= kEngineWalking; } break; diff --git a/engines/parallaction/defs.h b/engines/parallaction/defs.h index 587b211816..f5d2093d38 100644 --- a/engines/parallaction/defs.h +++ b/engines/parallaction/defs.h @@ -38,10 +38,17 @@ struct Node { Node* _next; }; -struct WalkNode { - Node _node; +struct WalkNode : public Node { +// Node _node; int32 _x; int32 _y; + +public: + WalkNode() : _x(0), _y(0) { + } + + WalkNode(int32 x, int32 y) : _x(x), _y(y) { + } }; struct Point { diff --git a/engines/parallaction/inventory.cpp b/engines/parallaction/inventory.cpp index 0308266101..c82ae19fb8 100644 --- a/engines/parallaction/inventory.cpp +++ b/engines/parallaction/inventory.cpp @@ -125,7 +125,7 @@ int16 pickupItem(Zone *z) { _inventory[_si]._id = MAKE_INVENTORY_ID(z->u.get->_icon); _inventory[_si]._index = z->u.get->_icon; - addJob(jobRemovePickedItem, z, kPriority17 ); + _vm->addJob(jobRemovePickedItem, z, kPriority17 ); if (_inventory[_si]._id == 0) return 0; diff --git a/engines/parallaction/location.cpp b/engines/parallaction/location.cpp index e092240d81..ff0f13c943 100644 --- a/engines/parallaction/location.cpp +++ b/engines/parallaction/location.cpp @@ -240,7 +240,7 @@ void parseWalkNodes(Script& script, Node *list) { v4->_x = atoi(_tokens[1]) - _vm->_char._ani._cnv._width/2; v4->_y = atoi(_tokens[2]) - _vm->_char._ani._cnv._height; - addNode(list, &v4->_node); + addNode(list, v4); } @@ -342,7 +342,7 @@ void Parallaction::changeLocation(char *location) { debugC(2, kDebugLocation, "changeLocation: changed cursor"); } - removeNode(&_vm->_char._ani._zone._node); + removeNode(&_vm->_char._ani._zone); debugC(2, kDebugLocation, "changeLocation: removed character from the animation list"); freeLocation(); @@ -375,7 +375,7 @@ void Parallaction::changeLocation(char *location) { } } - addNode(&_animations, &_vm->_char._ani._zone._node); + addNode(&_animations, &_vm->_char._ani._zone); debugC(2, kDebugLocation, "changeLocation: new character added to the animation list"); strcpy(_saveData1, list[0].c_str()); diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp index a11e88391a..62268aa3c1 100644 --- a/engines/parallaction/parallaction.cpp +++ b/engines/parallaction/parallaction.cpp @@ -136,9 +136,6 @@ uint16 _introSarcData2 = 1; // private stuff - - - static Job *_jDrawInventory = NULL; Job *_jDrawLabel = NULL; Job *_jEraseLabel = NULL; @@ -146,12 +143,6 @@ Zone *_hoverZone = NULL; static Job *_jRunScripts = NULL; - -static Job _jobs = { { NULL, NULL }, 0, 0, 0, NULL, 0 }; - - - - Parallaction::Parallaction(OSystem *syst) : Engine(syst) { @@ -248,7 +239,7 @@ int Parallaction::init() { _vm->_char._ani._zone._label._cnv._data0 = NULL; _vm->_char._ani._zone._label._text = strdup("yourself"); - addNode(&_animations, &_vm->_char._ani._zone._node); + addNode(&_animations, &_vm->_char._ani._zone); _gfx = new Gfx(this); int midiDriver = MidiDriver::detectMusicDriver(MDT_MIDI | MDT_ADLIB | MDT_PREFER_MIDI); @@ -902,7 +893,7 @@ void removeNode(Node *n) { } -Job *addJob(JobFn fn, void *parm, uint16 tag) { +Job *Parallaction::addJob(JobFn fn, void *parm, uint16 tag) { Job *v8 = (Job*)malloc(sizeof(Job)); @@ -914,41 +905,41 @@ Job *addJob(JobFn fn, void *parm, uint16 tag) { Job *v4 = &_jobs; - while (v4->_node._next && ((Job*)(v4->_node._next))->_tag > tag) { - v4 = (Job*)v4->_node._next; + while (v4->_next && ((Job*)(v4->_next))->_tag > tag) { + v4 = (Job*)v4->_next; } - addNode(&v4->_node, &v8->_node); + addNode(v4, v8); return v8; } -void removeJob(Job *j) { +void Parallaction::removeJob(Job *j) { - removeNode(&j->_node); + removeNode(j); free(j); return; } -void pauseJobs() { +void Parallaction::pauseJobs() { _engineFlags |= kEnginePauseJobs; return; } -void resumeJobs() { +void Parallaction::resumeJobs() { _engineFlags &= ~kEnginePauseJobs; return; } -void runJobs() { +void Parallaction::runJobs() { if (_engineFlags & kEnginePauseJobs) return; - Job *j = (Job*)_jobs._node._next; + Job *j = (Job*)_jobs._next; while (j) { debugC(3, kDebugJobs, "runJobs: %i", j->_tag); (*j->_fn)(j->_parm, j); - Job *v4 = (Job*)j->_node._next; + Job *v4 = (Job*)j->_next; if (j->_finished == 1) removeJob(j); @@ -974,7 +965,7 @@ void jobWaitRemoveJob(void *parm, Job *j) { count++; if (count == 2) { count = 0; - removeJob(arg); + _vm->removeJob(arg); _engineFlags &= ~kEngineMouse; j->_finished = 1; } diff --git a/engines/parallaction/parallaction.h b/engines/parallaction/parallaction.h index 348ead7a87..00f382a68f 100644 --- a/engines/parallaction/parallaction.h +++ b/engines/parallaction/parallaction.h @@ -87,13 +87,17 @@ struct PARALLACTIONGameDescription; struct Job; typedef void (*JobFn)(void*, Job*); -struct Job { - Node _node; +struct Job : public Node { +// Node _node; 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) { + } }; extern Point _mousePos; @@ -166,11 +170,7 @@ void runDialogue(SpeakData*); WalkNode *buildWalkPath(uint16 x, uint16 y); -Job *addJob(JobFn fn, void *parm, uint16 tag); -void removeJob(Job *j); -void runJobs(); -void pauseJobs(); -void resumeJobs(); + void jobRemovePickedItem(void*, Job *j); void jobDisplayDroppedItem(void*, Job *j); @@ -275,6 +275,11 @@ public: char *parseDialogueString(Script &script); Dialogue *parseDialogue(Script &script); + Job *addJob(JobFn fn, void *parm, uint16 tag); + void removeJob(Job *j); + void pauseJobs(); + void resumeJobs(); + void runJobs(); public: int getGameType() const; @@ -334,6 +339,8 @@ protected: // data int16 _keyDown; + Job _jobs; + protected: // members bool detectGame(void); diff --git a/engines/parallaction/walk.cpp b/engines/parallaction/walk.cpp index d22cdb5a06..152dc68d24 100644 --- a/engines/parallaction/walk.cpp +++ b/engines/parallaction/walk.cpp @@ -32,7 +32,7 @@ namespace Parallaction { uint16 walkFunc1(int16, int16, WalkNode *); -WalkNode _NULL_WALKNODE = { {NULL, NULL}, 0, 0 }; +WalkNode _NULL_WALKNODE(); static byte *_buffer; @@ -117,7 +117,7 @@ WalkNode *buildWalkPath(uint16 x, uint16 y) { v48->_x = to_x - _vm->_char._ani._cnv._width / 2; // target top left coordinates v48->_y = to_y - _vm->_char._ani._cnv._height; - v48->_node._next = NULL; + v48->_next = NULL; memcpy(v44, v48, sizeof(WalkNode)); uint16 v38 = walkFunc1(to_x, to_y, v44); @@ -136,7 +136,7 @@ WalkNode *buildWalkPath(uint16 x, uint16 y) { int16 _si = v48->_x; // _si, _di: target top left coordinates int16 _di = v48->_y; - addNode(&v58._node, &v48->_node); + addNode(&v58, v48); WalkNode *_closest_node = NULL; @@ -182,7 +182,7 @@ WalkNode *buildWalkPath(uint16 x, uint16 y) { _closest_node = location_node; } - location_node = (WalkNode*)location_node->_node._next; + location_node = (WalkNode*)location_node->_next; } if (_closest_node_found == 0) break; @@ -197,7 +197,7 @@ WalkNode *buildWalkPath(uint16 x, uint16 y) { debugC(1, kDebugWalk, "adding walk node (%i, %i) to path", _newnode->_x, _newnode->_y); - addNode(&v48->_node, &_newnode->_node); + addNode(v48, _newnode); v48 = _newnode; } @@ -205,12 +205,12 @@ WalkNode *buildWalkPath(uint16 x, uint16 y) { if (v38 != 0 && v34 > v38) { // no alternative path (gap?) - freeNodeList(v58._node._next); + freeNodeList(v58._next); debugC(1, kDebugWalk, "can't find a path node: rejecting partial path"); return v44; } else { - _si = ((WalkNode*)(v58._node._next))->_x; - _di = ((WalkNode*)(v58._node._next))->_y; + _si = ((WalkNode*)(v58._next))->_x; + _di = ((WalkNode*)(v58._next))->_y; emptyList = false; _closest_node_found = 1; } @@ -221,15 +221,15 @@ WalkNode *buildWalkPath(uint16 x, uint16 y) { WalkNode* tmp = &v58; uint16 i = 1; - while (tmp->_node._next) { + while (tmp->_next) { debugC(1, kDebugWalk, "node %i: %i, %i", i, tmp->_x, tmp->_y); - tmp = (WalkNode*)tmp->_node._next; + tmp = (WalkNode*)tmp->_next; i++; } free(v44); - return (WalkNode*)v58._node._next; + return (WalkNode*)v58._next; } @@ -325,7 +325,7 @@ void jobWalk(void *parm, Job *j) { _vm->_char._ani._zone.pos._oldposition._y = _di; if ((node->_x == _si) && (node->_y == _di)) { - if (node->_node._next == NULL) { + if (node->_next == NULL) { debugC(1, kDebugWalk, "jobWalk reached last node"); @@ -336,8 +336,8 @@ void jobWalk(void *parm, Job *j) { } - WalkNode *tmp = (WalkNode*)node->_node._next; - j->_parm = node->_node._next; + WalkNode *tmp = (WalkNode*)node->_next; + j->_parm = node->_next; free(node); debugC(1, kDebugWalk, "jobWalk moving to next node (%i, %i)", tmp->_x, tmp->_y); @@ -419,7 +419,7 @@ void jobWalk(void *parm, Job *j) { j->_finished = 1; checkDoor(); - freeNodeList(&node->_node); + freeNodeList(node); } else { diff --git a/engines/parallaction/zone.cpp b/engines/parallaction/zone.cpp index fd8237a1ec..8ce938be5f 100644 --- a/engines/parallaction/zone.cpp +++ b/engines/parallaction/zone.cpp @@ -44,7 +44,7 @@ Zone *findZone(const char *name) { while (v4) { if (!scumm_stricmp(name, v4->_label._text)) return v4; - v4 = (Zone*)v4->_node._next; + v4 = (Zone*)v4->_next; } Animation *a = findAnimation(name); @@ -70,7 +70,7 @@ void Parallaction::parseZone(Script &script, Node *list, char *name) { z->_label._text = (char*)malloc(strlen(name)+1); strcpy(z->_label._text, name); - addNode(list, &z->_node); + addNode(list, z); fillBuffers(script, true); while (scumm_stricmp(_tokens[0], "endzone")) { @@ -140,9 +140,9 @@ void freeZones(Node *list) { debugC(1, kDebugLocation, "freeZones preserving zone '%s'", z->_label._text); - v8 = (Zone*)z->_node._next; - removeNode(&z->_node); - addNode(&helperNode, &z->_node); + v8 = (Zone*)z->_next; + removeNode(z); + addNode(&helperNode, z); z = v8; continue; } @@ -190,7 +190,7 @@ void freeZones(Node *list) { _vm->_gfx->freeStaticCnv(&z->_label._cnv); freeCommands(z->_commands); - z=(Zone*)z->_node._next; + z=(Zone*)z->_next; } @@ -456,7 +456,7 @@ uint16 runZone(Zone *z) { if (z->_flags & kFlagsLocked) break; z->_flags ^= kFlagsClosed; if (z->u.door->_cnv._count == 0) break; - addJob(jobToggleDoor, z, kPriority18 ); + _vm->addJob(jobToggleDoor, z, kPriority18 ); break; case kZoneHear: @@ -576,7 +576,7 @@ Zone *hitZone(uint32 type, uint16 x, uint16 y) { uint16 _si = x; Zone *z = (Zone*)_zones._next; - for (; z; z = (Zone*)z->_node._next) { + for (; z; z = (Zone*)z->_next) { // printf("Zone name: %s", z->_name); if (z->_flags & kFlagsRemove) continue; @@ -632,7 +632,7 @@ Zone *hitZone(uint32 type, uint16 x, uint16 y) { Animation *a = (Animation*)_animations._next; int16 _a, _b, _c, _d, _e, _f; - for (; a; a = (Animation*)a->_zone._node._next) { + for (; a; a = (Animation*)a->_zone._next) { // printf("Animation name: %s", a->_zone._name); _a = (a->_zone._flags & kFlagsActive) ? 1 : 0; // _a: active Animation diff --git a/engines/parallaction/zone.h b/engines/parallaction/zone.h index c7158e1821..6ae7c8a538 100644 --- a/engines/parallaction/zone.h +++ b/engines/parallaction/zone.h @@ -123,8 +123,8 @@ struct ZoneLabel { StaticCnv _cnv; }; -struct Zone { - Node _node; +struct Zone : public Node { +// Node _node; union { Rect _limits; // for zones struct { // for animations @@ -163,8 +163,8 @@ enum InstructionFlags { kInstMaskedPut = 8 }; -struct Instruction { - Node _node; +struct Instruction : public Node { +// Node _node; uint32 _index; uint32 _flags; union { @@ -178,8 +178,8 @@ struct Instruction { }; -struct Program { - Node _node; +struct Program : public Node { +// Node _node; LocalVariable *_locals; uint16 _loopCounter; Instruction *_ip; |