diff options
Diffstat (limited to 'engines/parallaction')
-rw-r--r-- | engines/parallaction/dialogue.cpp | 2 | ||||
-rw-r--r-- | engines/parallaction/objects.h | 2 | ||||
-rw-r--r-- | engines/parallaction/parallaction.cpp | 3 | ||||
-rw-r--r-- | engines/parallaction/parallaction.h | 49 | ||||
-rw-r--r-- | engines/parallaction/parser_ns.cpp | 162 | ||||
-rw-r--r-- | engines/parallaction/staticres.cpp | 4 |
6 files changed, 109 insertions, 113 deletions
diff --git a/engines/parallaction/dialogue.cpp b/engines/parallaction/dialogue.cpp index 33d109842d..721d43fa19 100644 --- a/engines/parallaction/dialogue.cpp +++ b/engines/parallaction/dialogue.cpp @@ -162,7 +162,7 @@ uint16 DialogueManager::askPassword() { bool DialogueManager::displayAnswer(uint16 i) { - uint32 v28 = _localFlags[_vm->_currentLocationIndex]; + uint32 v28 = _vm->_localFlags[_vm->_currentLocationIndex]; if (_q->_answers[i]->_yesFlags & kFlagsGlobal) v28 = _commandFlags | kFlagsGlobal; diff --git a/engines/parallaction/objects.h b/engines/parallaction/objects.h index 3699e98f01..26c841b285 100644 --- a/engines/parallaction/objects.h +++ b/engines/parallaction/objects.h @@ -275,6 +275,8 @@ struct Zone { CommandList _commands; Common::Point _moveTo; + uint _index; + Zone(); virtual ~Zone(); diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp index dedcddb8c7..4a93ee968b 100644 --- a/engines/parallaction/parallaction.cpp +++ b/engines/parallaction/parallaction.cpp @@ -56,7 +56,6 @@ uint32 _engineFlags = 0; uint16 _score = 1; -uint32 _localFlags[120] = { 0 }; Command * _forwardedCommands[20] = { NULL, NULL, @@ -941,7 +940,7 @@ void Parallaction::freeLocation() { // HACK: prevents leakage. A routine like this // should allocate memory at all, though. if ((_engineFlags & kEngineQuit) == 0) { - _localFlagNames = new Table(120); + _localFlagNames = new Table(NUM_LOCATIONS); _localFlagNames->addData("visited"); } diff --git a/engines/parallaction/parallaction.h b/engines/parallaction/parallaction.h index 791724a08d..e9b28a1f1d 100644 --- a/engines/parallaction/parallaction.h +++ b/engines/parallaction/parallaction.h @@ -43,6 +43,7 @@ namespace GUI { class ListWidget; class CommandSender; } +#define BRA_TEST 0 extern OSystem *g_system; @@ -161,14 +162,10 @@ public: typedef Job* JobPointer; typedef ManagedList<JobPointer> JobList; -typedef void (*callable)(void*); - extern uint16 _mouseButtons; extern uint16 _score; extern uint16 _language; extern uint32 _engineFlags; -extern callable _callables[]; -extern uint32 _localFlags[]; extern Command *_forwardedCommands[]; extern char _forwardedAnimationNames[][20]; extern uint16 _numForwards; @@ -338,7 +335,7 @@ typedef Common::Array<const Opcode*> OpcodeSet; #define DECLARE_UNQUALIFIED_INSTRUCTION_OPCODE(op) void instOp_##op() - +#define NUM_LOCATIONS 120 class Parallaction : public Engine { friend class Debugger; @@ -448,7 +445,8 @@ public: Character _char; char _characterName[30]; - char _locationNames[120][32]; + uint32 _localFlags[NUM_LOCATIONS]; + char _locationNames[NUM_LOCATIONS][32]; int16 _currentLocationIndex; uint16 _numLocations; Location _location; @@ -466,6 +464,7 @@ public: Font *_menuFont; Font *_dialogueFont; + protected: // data Debugger *_debugger; @@ -637,28 +636,18 @@ protected: Table *_locationZoneStmt; Table *_locationAnimStmt; - struct { + struct LocationParserContext { + bool end; + const char *filename; - bool end; - Script *script; - } _locParseCtxt; - struct { - bool end; - Script *script; - Zone *z; - } _locZoneParseCtxt; - struct { - bool end; - Script *script; - Animation *a; - } _locAnimParseCtxt; - struct { - Command *cmd; - int nextToken; + Script *script; + Zone *z; + Animation *a; + int nextToken; CommandList *list; - bool end; - Script *script; - } _cmdParseCtxt; + bool endcommands; + Command *cmd; + } _locParseCtxt; DECLARE_UNQUALIFIED_LOCATION_PARSER(invalid); DECLARE_UNQUALIFIED_LOCATION_PARSER(endlocation); @@ -796,7 +785,7 @@ protected: - +#define NUM_ZONES 100 class Parallaction_br : public Parallaction_ns { @@ -832,6 +821,12 @@ public: int32 _counters[32]; + uint32 _zoneFlags[NUM_LOCATIONS][NUM_ZONES]; + + struct LocationParserContext_br : public LocationParserContext { + int numZones; + } _locParseCtxt; + private: void initResources(); void initFonts(); diff --git a/engines/parallaction/parser_ns.cpp b/engines/parallaction/parser_ns.cpp index 5ee0b6b413..1956e7cb03 100644 --- a/engines/parallaction/parser_ns.cpp +++ b/engines/parallaction/parser_ns.cpp @@ -78,43 +78,43 @@ namespace Parallaction { DECLARE_ANIM_PARSER(invalid) { - error("unknown statement '%s' in animation %s", _tokens[0], _locAnimParseCtxt.a->_label._text); + error("unknown statement '%s' in animation %s", _tokens[0], _locParseCtxt.a->_label._text); } DECLARE_ANIM_PARSER(script) { - _locAnimParseCtxt.a->_scriptName = strdup(_tokens[1]); + _locParseCtxt.a->_scriptName = strdup(_tokens[1]); } DECLARE_ANIM_PARSER(commands) { - parseCommands(*_locAnimParseCtxt.script, _locAnimParseCtxt.a->_commands); + parseCommands(*_locParseCtxt.script, _locParseCtxt.a->_commands); } DECLARE_ANIM_PARSER(type) { if (_tokens[2][0] != '\0') { - _locAnimParseCtxt.a->_type = ((4 + _objectsNames->lookup(_tokens[2])) << 16) & 0xFFFF0000; + _locParseCtxt.a->_type = ((4 + _objectsNames->lookup(_tokens[2])) << 16) & 0xFFFF0000; } int16 _si = _zoneTypeNames->lookup(_tokens[1]); if (_si != Table::notFound) { - _locAnimParseCtxt.a->_type |= 1 << (_si-1); - if (((_locAnimParseCtxt.a->_type & 0xFFFF) != kZoneNone) && ((_locAnimParseCtxt.a->_type & 0xFFFF) != kZoneCommand)) { - parseZoneTypeBlock(*_locAnimParseCtxt.script, _locAnimParseCtxt.a); + _locParseCtxt.a->_type |= 1 << (_si-1); + if (((_locParseCtxt.a->_type & 0xFFFF) != kZoneNone) && ((_locParseCtxt.a->_type & 0xFFFF) != kZoneCommand)) { + parseZoneTypeBlock(*_locParseCtxt.script, _locParseCtxt.a); } } - _locAnimParseCtxt.a->_oldPos.x = -1000; - _locAnimParseCtxt.a->_oldPos.y = -1000; + _locParseCtxt.a->_oldPos.x = -1000; + _locParseCtxt.a->_oldPos.y = -1000; - _locAnimParseCtxt.a->_flags |= 0x1000000; + _locParseCtxt.a->_flags |= 0x1000000; popParserTables(); } DECLARE_ANIM_PARSER(label) { - renderLabel(&_locAnimParseCtxt.a->_label._cnv, _tokens[1]); + renderLabel(&_locParseCtxt.a->_label._cnv, _tokens[1]); } @@ -124,7 +124,7 @@ DECLARE_ANIM_PARSER(flags) { do { byte _al = _zoneFlagNames->lookup(_tokens[_si]); _si++; - _locAnimParseCtxt.a->_flags |= 1 << (_al - 1); + _locParseCtxt.a->_flags |= 1 << (_al - 1); } while (!scumm_stricmp(_tokens[_si++], "|")); } @@ -137,29 +137,29 @@ DECLARE_ANIM_PARSER(file) { strcat(vC8, "tras"); } } - _locAnimParseCtxt.a->_cnv = _disk->loadFrames(vC8); + _locParseCtxt.a->_cnv = _disk->loadFrames(vC8); } DECLARE_ANIM_PARSER(position) { - _locAnimParseCtxt.a->_left = atoi(_tokens[1]); - _locAnimParseCtxt.a->_top = atoi(_tokens[2]); - _locAnimParseCtxt.a->_z = atoi(_tokens[3]); + _locParseCtxt.a->_left = atoi(_tokens[1]); + _locParseCtxt.a->_top = atoi(_tokens[2]); + _locParseCtxt.a->_z = atoi(_tokens[3]); } DECLARE_ANIM_PARSER(moveto) { - _locAnimParseCtxt.a->_moveTo.x = atoi(_tokens[1]); - _locAnimParseCtxt.a->_moveTo.y = atoi(_tokens[2]); + _locParseCtxt.a->_moveTo.x = atoi(_tokens[1]); + _locParseCtxt.a->_moveTo.y = atoi(_tokens[2]); } DECLARE_ANIM_PARSER(endanimation) { - _locAnimParseCtxt.a->_oldPos.x = -1000; - _locAnimParseCtxt.a->_oldPos.y = -1000; + _locParseCtxt.a->_oldPos.x = -1000; + _locParseCtxt.a->_oldPos.y = -1000; - _locAnimParseCtxt.a->_flags |= 0x1000000; + _locParseCtxt.a->_flags |= 0x1000000; popParserTables(); } @@ -173,9 +173,9 @@ Animation *Parallaction_ns::parseAnimation(Script& script, AnimationList &list, list.push_front(a); - _locAnimParseCtxt.a = a; - _locAnimParseCtxt.end = false; - _locAnimParseCtxt.script = &script; + _locParseCtxt.a = a; + _locParseCtxt.end = false; + _locParseCtxt.script = &script; pushParserTables(&_locationAnimParsers, _locationAnimStmt); @@ -425,19 +425,19 @@ DECLARE_COMMAND_PARSER(flags) { if (_globalTable->lookup(_tokens[1]) == Table::notFound) { do { - char _al = _localFlagNames->lookup(_tokens[_cmdParseCtxt.nextToken]); - _cmdParseCtxt.nextToken++; - _cmdParseCtxt.cmd->u._flags |= 1 << (_al - 1); - } while (!scumm_stricmp(_tokens[_cmdParseCtxt.nextToken++], "|")); - _cmdParseCtxt.nextToken--; + char _al = _localFlagNames->lookup(_tokens[_locParseCtxt.nextToken]); + _locParseCtxt.nextToken++; + _locParseCtxt.cmd->u._flags |= 1 << (_al - 1); + } while (!scumm_stricmp(_tokens[_locParseCtxt.nextToken++], "|")); + _locParseCtxt.nextToken--; } else { - _cmdParseCtxt.cmd->u._flags |= kFlagsGlobal; + _locParseCtxt.cmd->u._flags |= kFlagsGlobal; do { char _al = _globalTable->lookup(_tokens[1]); - _cmdParseCtxt.nextToken++; - _cmdParseCtxt.cmd->u._flags |= 1 << (_al - 1); - } while (!scumm_stricmp(_tokens[_cmdParseCtxt.nextToken++], "|")); - _cmdParseCtxt.nextToken--; + _locParseCtxt.nextToken++; + _locParseCtxt.cmd->u._flags |= 1 << (_al - 1); + } while (!scumm_stricmp(_tokens[_locParseCtxt.nextToken++], "|")); + _locParseCtxt.nextToken--; } parseCommandFlags(); @@ -448,11 +448,11 @@ DECLARE_COMMAND_PARSER(flags) { DECLARE_COMMAND_PARSER(animation) { createCommand(_lookup); - _cmdParseCtxt.cmd->u._animation = findAnimation(_tokens[_cmdParseCtxt.nextToken]); - _cmdParseCtxt.nextToken++; - if (_cmdParseCtxt.cmd->u._animation == NULL) { - strcpy(_forwardedAnimationNames[_numForwards], _tokens[_cmdParseCtxt.nextToken-1]); - _forwardedCommands[_numForwards] = _cmdParseCtxt.cmd; + _locParseCtxt.cmd->u._animation = findAnimation(_tokens[_locParseCtxt.nextToken]); + _locParseCtxt.nextToken++; + if (_locParseCtxt.cmd->u._animation == NULL) { + strcpy(_forwardedAnimationNames[_numForwards], _tokens[_locParseCtxt.nextToken-1]); + _forwardedCommands[_numForwards] = _locParseCtxt.cmd; _numForwards++; } @@ -464,8 +464,8 @@ DECLARE_COMMAND_PARSER(animation) { DECLARE_COMMAND_PARSER(zone) { createCommand(_lookup); - _cmdParseCtxt.cmd->u._zone = findZone(_tokens[_cmdParseCtxt.nextToken]); - _cmdParseCtxt.nextToken++; + _locParseCtxt.cmd->u._zone = findZone(_tokens[_locParseCtxt.nextToken]); + _locParseCtxt.nextToken++; parseCommandFlags(); addCommand(); @@ -475,9 +475,9 @@ DECLARE_COMMAND_PARSER(zone) { DECLARE_COMMAND_PARSER(location) { createCommand(_lookup); - _cmdParseCtxt.cmd->u._string = (char*)malloc(strlen(_tokens[_cmdParseCtxt.nextToken])+1); - strcpy(_cmdParseCtxt.cmd->u._string, _tokens[_cmdParseCtxt.nextToken]); - _cmdParseCtxt.nextToken++; + _locParseCtxt.cmd->u._string = (char*)malloc(strlen(_tokens[_locParseCtxt.nextToken])+1); + strcpy(_locParseCtxt.cmd->u._string, _tokens[_locParseCtxt.nextToken]); + _locParseCtxt.nextToken++; parseCommandFlags(); addCommand(); @@ -487,8 +487,8 @@ DECLARE_COMMAND_PARSER(location) { DECLARE_COMMAND_PARSER(drop) { createCommand(_lookup); - _cmdParseCtxt.cmd->u._object = 4 + _objectsNames->lookup(_tokens[_cmdParseCtxt.nextToken]); - _cmdParseCtxt.nextToken++; + _locParseCtxt.cmd->u._object = 4 + _objectsNames->lookup(_tokens[_locParseCtxt.nextToken]); + _locParseCtxt.nextToken++; parseCommandFlags(); addCommand(); @@ -498,8 +498,8 @@ DECLARE_COMMAND_PARSER(drop) { DECLARE_COMMAND_PARSER(call) { createCommand(_lookup); - _cmdParseCtxt.cmd->u._callable = _callableNames->lookup(_tokens[_cmdParseCtxt.nextToken]) - 1; - _cmdParseCtxt.nextToken++; + _locParseCtxt.cmd->u._callable = _callableNames->lookup(_tokens[_locParseCtxt.nextToken]) - 1; + _locParseCtxt.nextToken++; parseCommandFlags(); addCommand(); @@ -515,10 +515,10 @@ DECLARE_COMMAND_PARSER(simple) { DECLARE_COMMAND_PARSER(move) { createCommand(_lookup); - _cmdParseCtxt.cmd->u._move.x = atoi(_tokens[_cmdParseCtxt.nextToken]); - _cmdParseCtxt.nextToken++; - _cmdParseCtxt.cmd->u._move.y = atoi(_tokens[_cmdParseCtxt.nextToken]); - _cmdParseCtxt.nextToken++; + _locParseCtxt.cmd->u._move.x = atoi(_tokens[_locParseCtxt.nextToken]); + _locParseCtxt.nextToken++; + _locParseCtxt.cmd->u._move.y = atoi(_tokens[_locParseCtxt.nextToken]); + _locParseCtxt.nextToken++; parseCommandFlags(); addCommand(); @@ -532,13 +532,13 @@ DECLARE_COMMAND_PARSER(endcommands) { popParserTables(); // temporary trick to handle dialogue commands - _cmdParseCtxt.end = true; + _locParseCtxt.endcommands = true; } void Parallaction_ns::parseCommandFlags() { - int _si = _cmdParseCtxt.nextToken; - Command *cmd = _cmdParseCtxt.cmd; + int _si = _locParseCtxt.nextToken; + Command *cmd = _locParseCtxt.cmd; if (!scumm_stricmp(_tokens[_si], "flags")) { _si++; @@ -589,26 +589,26 @@ void Parallaction_ns::parseCommandFlags() { } - _si = _cmdParseCtxt.nextToken; + _si = _locParseCtxt.nextToken; } void Parallaction_ns::addCommand() { - _cmdParseCtxt.list->push_front(_cmdParseCtxt.cmd); // NOTE: command lists are written backwards in scripts + _locParseCtxt.list->push_front(_locParseCtxt.cmd); // NOTE: command lists are written backwards in scripts } void Parallaction_ns::createCommand(uint id) { - _cmdParseCtxt.nextToken = 1; - _cmdParseCtxt.cmd = new Command; - _cmdParseCtxt.cmd->_id = id; + _locParseCtxt.nextToken = 1; + _locParseCtxt.cmd = new Command; + _locParseCtxt.cmd->_id = id; } void Parallaction_ns::parseCommands(Script &script, CommandList& list) { - _cmdParseCtxt.list = &list; - _cmdParseCtxt.end = false; - _cmdParseCtxt.script = &script; + _locParseCtxt.list = &list; + _locParseCtxt.end = false; + _locParseCtxt.script = &script; pushParserTables(&_commandParsers, _commandsNames); @@ -685,11 +685,11 @@ Dialogue *Parallaction_ns::parseDialogue(Script &script) { if (!scumm_stricmp(_tokens[0], "commands")) { parseCommands(script, answer->_commands); - _cmdParseCtxt.end = false; + _locParseCtxt.endcommands = false; do { fillBuffers(script, true); parseStatement(); - } while (!_cmdParseCtxt.end); + } while (!_locParseCtxt.endcommands); fillBuffers(script, true); } @@ -1086,7 +1086,7 @@ char *Parallaction_ns::parseComment(Script &script) { DECLARE_ZONE_PARSER(invalid) { - error("unknown statement '%s' in zone %s", _tokens[0], _locZoneParseCtxt.z->_label._text); + error("unknown statement '%s' in zone %s", _tokens[0], _locParseCtxt.z->_label._text); } DECLARE_ZONE_PARSER(endzone) { @@ -1094,27 +1094,27 @@ DECLARE_ZONE_PARSER(endzone) { } DECLARE_ZONE_PARSER(limits) { - _locZoneParseCtxt.z->_left = atoi(_tokens[1]); - _locZoneParseCtxt.z->_top = atoi(_tokens[2]); - _locZoneParseCtxt.z->_right = atoi(_tokens[3]); - _locZoneParseCtxt.z->_bottom = atoi(_tokens[4]); + _locParseCtxt.z->_left = atoi(_tokens[1]); + _locParseCtxt.z->_top = atoi(_tokens[2]); + _locParseCtxt.z->_right = atoi(_tokens[3]); + _locParseCtxt.z->_bottom = atoi(_tokens[4]); } DECLARE_ZONE_PARSER(moveto) { - _locZoneParseCtxt.z->_moveTo.x = atoi(_tokens[1]); - _locZoneParseCtxt.z->_moveTo.y = atoi(_tokens[2]); + _locParseCtxt.z->_moveTo.x = atoi(_tokens[1]); + _locParseCtxt.z->_moveTo.y = atoi(_tokens[2]); } DECLARE_ZONE_PARSER(type) { if (_tokens[2][0] != '\0') { - _locZoneParseCtxt.z->_type = (4 + _objectsNames->lookup(_tokens[2])) << 16; + _locParseCtxt.z->_type = (4 + _objectsNames->lookup(_tokens[2])) << 16; } int16 _si = _zoneTypeNames->lookup(_tokens[1]); if (_si != Table::notFound) { - _locZoneParseCtxt.z->_type |= 1 << (_si - 1); - parseZoneTypeBlock(*_locZoneParseCtxt.script, _locZoneParseCtxt.z); + _locParseCtxt.z->_type |= 1 << (_si - 1); + parseZoneTypeBlock(*_locParseCtxt.script, _locParseCtxt.z); } popParserTables(); @@ -1122,13 +1122,13 @@ DECLARE_ZONE_PARSER(type) { DECLARE_ZONE_PARSER(commands) { - parseCommands(*_locZoneParseCtxt.script, _locZoneParseCtxt.z->_commands); + parseCommands(*_locParseCtxt.script, _locParseCtxt.z->_commands); } DECLARE_ZONE_PARSER(label) { // printf("label: %s", _tokens[1]); - renderLabel(&_locZoneParseCtxt.z->_label._cnv, _tokens[1]); + renderLabel(&_locParseCtxt.z->_label._cnv, _tokens[1]); } @@ -1138,7 +1138,7 @@ DECLARE_ZONE_PARSER(flags) { do { char _al = _zoneFlagNames->lookup(_tokens[_si]); _si++; - _locZoneParseCtxt.z->_flags |= 1 << (_al - 1); + _locParseCtxt.z->_flags |= 1 << (_al - 1); } while (!scumm_stricmp(_tokens[_si++], "|")); } @@ -1155,9 +1155,9 @@ void Parallaction_ns::parseZone(Script &script, ZoneList &list, char *name) { z->_label._text = strdup(name); - _locZoneParseCtxt.z = z; - _locZoneParseCtxt.end = false; - _locZoneParseCtxt.script = &script; + _locParseCtxt.z = z; + _locParseCtxt.end = false; + _locParseCtxt.script = &script; list.push_front(z); diff --git a/engines/parallaction/staticres.cpp b/engines/parallaction/staticres.cpp index 048aed4089..ddc71d8e85 100644 --- a/engines/parallaction/staticres.cpp +++ b/engines/parallaction/staticres.cpp @@ -657,7 +657,7 @@ void Parallaction_ns::initResources() { _locationZoneStmt = new Table(ARRAYSIZE(_locationZoneStmtRes_ns), _locationZoneStmtRes_ns); _locationAnimStmt = new Table(ARRAYSIZE(_locationAnimStmtRes_ns), _locationAnimStmtRes_ns); - _localFlagNames = new Table(120); + _localFlagNames = new Table(NUM_LOCATIONS); _localFlagNames->addData("visited"); if (getPlatform() == Common::kPlatformPC) { @@ -688,7 +688,7 @@ void Parallaction_br::initResources() { _locationAnimStmt = new Table(ARRAYSIZE(_locationAnimStmtRes_br), _locationAnimStmtRes_br); // TODO: make sure there are 120 max locations in Big Red Adventure - _localFlagNames = new Table(120); + _localFlagNames = new Table(NUM_LOCATIONS); _localFlagNames->addData("visited"); if (getPlatform() == Common::kPlatformPC) { |