diff options
-rw-r--r-- | queen/defs.h | 6 | ||||
-rw-r--r-- | queen/logic.cpp | 218 | ||||
-rw-r--r-- | queen/logic.h | 48 | ||||
-rw-r--r-- | queen/resource.cpp | 37 | ||||
-rw-r--r-- | queen/resource.h | 6 |
5 files changed, 302 insertions, 13 deletions
diff --git a/queen/defs.h b/queen/defs.h index e939ae8b24..61c7a8ac72 100644 --- a/queen/defs.h +++ b/queen/defs.h @@ -89,6 +89,12 @@ enum { PANEL_AREA_INV_4 = 14 }; +enum Language { + ENGLISH = 'E', + FRENCH = 'F', + GERMAN = 'G', + ITALIAN = 'I' +}; } // End of namespace Queen diff --git a/queen/logic.cpp b/queen/logic.cpp index 1cf71ee33a..21b947b252 100644 --- a/queen/logic.cpp +++ b/queen/logic.cpp @@ -216,7 +216,224 @@ void Logic::initialise() { } //Command List Data + _numCmdList = READ_BE_UINT16(ptr); + ptr += 2; + _cmdList = new CmdListData[_numCmdList + 1]; + for (i = 1; i <= _numCmdList; i++) { + _cmdList[i].verb = (int16)READ_BE_UINT16(ptr); + ptr += 2; + _cmdList[i].nounObj1 = (int16)READ_BE_UINT16(ptr); + ptr += 2; + _cmdList[i].nounObj2 = (int16)READ_BE_UINT16(ptr); + ptr += 2; + _cmdList[i].song = (int16)READ_BE_UINT16(ptr); + ptr += 2; + _cmdList[i].setAreas = READ_BE_UINT16(ptr) != 0; + ptr += 2; + _cmdList[i].setObjects = READ_BE_UINT16(ptr) != 0; + ptr += 2; + _cmdList[i].setItems = READ_BE_UINT16(ptr) != 0; + ptr += 2; + _cmdList[i].setConditions = READ_BE_UINT16(ptr) != 0; + ptr += 2; + _cmdList[i].image = (int16)READ_BE_UINT16(ptr); + ptr += 2; + _cmdList[i].specialSection = (int16)READ_BE_UINT16(ptr); + ptr += 2; + } + + //Command AREA + _numCmdArea = READ_BE_UINT16(ptr); + ptr += 2; + _cmdArea = new CmdArea[_numCmdArea + 1]; + for (i = 1; i <= _numCmdArea; i++) { + _cmdArea[i].id = (int16)READ_BE_UINT16(ptr); + ptr += 2; + _cmdArea[i].area = (int16)READ_BE_UINT16(ptr); + ptr += 2; + _cmdArea[i].room = (int16)READ_BE_UINT16(ptr); + ptr += 2; + } + + //Command OBJECT + _numCmdObject = READ_BE_UINT16(ptr); + ptr += 2; + _cmdObject = new CmdObject[_numCmdObject + 1]; + for (i = 1; i <= _numCmdObject; i++) { + _cmdObject[i].id = (int16)READ_BE_UINT16(ptr); + ptr += 2; + _cmdObject[i].dstObj = (int16)READ_BE_UINT16(ptr); + ptr += 2; + _cmdObject[i].srcObj = (int16)READ_BE_UINT16(ptr); + ptr += 2; + } + //Command INVENTORY + _numCmdInventory = READ_BE_UINT16(ptr); + ptr += 2; + _cmdInventory = new CmdInventory[_numCmdInventory + 1]; + for (i = 1; i <= _numCmdInventory; i++) { + _cmdInventory[i].id = (int16)READ_BE_UINT16(ptr); + ptr += 2; + _cmdInventory[i].dstItem = (int16)READ_BE_UINT16(ptr); + ptr += 2; + _cmdInventory[i].srcItem = (int16)READ_BE_UINT16(ptr); + ptr += 2; + } + + //Command GAMESTATE + _numCmdGameState = READ_BE_UINT16(ptr); + ptr += 2; + _cmdGameState = new CmdGameState[_numCmdGameState + 1]; + for (i = 1; i <= _numCmdGameState; i++) { + _cmdGameState[i].id = (int16)READ_BE_UINT16(ptr); + ptr += 2; + _cmdGameState[i].gameStateSlot = (int16)READ_BE_UINT16(ptr); + ptr += 2; + _cmdGameState[i].gameStateValue = (int16)READ_BE_UINT16(ptr); + ptr += 2; + _cmdGameState[i].speakValue = (int16)READ_BE_UINT16(ptr); + ptr += 2; + } + + _entryObj = READ_BE_UINT16(ptr); + ptr += 2; + + //Furniture DATA + _numFurniture = READ_BE_UINT16(ptr); + ptr += 2; + + _furnitureData = new FurnitureData[_numFurniture + 1]; + for (i = 1; i <= _numFurniture; i++) { + _furnitureData[i].room = (int16)READ_BE_UINT16(ptr); + ptr += 2; + _furnitureData[i].gameStateValue = (int16)READ_BE_UINT16(ptr); + ptr += 2; + } + + _numActors = READ_BE_UINT16(ptr); + ptr += 2; + _numAAnim = READ_BE_UINT16(ptr); + ptr += 2; + _numAName = READ_BE_UINT16(ptr); + ptr += 2; + _numAFile = READ_BE_UINT16(ptr); + ptr += 2; + + _actorData = new ActorData[_numActors + 1]; + for (i = 1; i <= _numActors; i++) { + _actorData[i].room = (int16)READ_BE_UINT16(ptr); + ptr += 2; + _actorData[i].bobNum = (int16)READ_BE_UINT16(ptr); + ptr += 2; + _actorData[i].name = READ_BE_UINT16(ptr); + ptr += 2; + _actorData[i].gameStateSlot = (int16)READ_BE_UINT16(ptr); + ptr += 2; + _actorData[i].gameStateValue = (int16)READ_BE_UINT16(ptr); + ptr += 2; + _actorData[i].color = READ_BE_UINT16(ptr); + ptr += 2; + _actorData[i].bobFrameStanding = READ_BE_UINT16(ptr); + ptr += 2; + _actorData[i].x = READ_BE_UINT16(ptr); + ptr += 2; + _actorData[i].y = READ_BE_UINT16(ptr); + ptr += 2; + _actorData[i].anim = READ_BE_UINT16(ptr); + ptr += 2; + _actorData[i].bankNum = READ_BE_UINT16(ptr); + ptr += 2; + _actorData[i].actorFile = READ_BE_UINT16(ptr); + ptr += 2; + } + + _numGraphicAnim = READ_BE_UINT16(ptr); + ptr += 2; + + _graphicAnim = new GraphicAnim[_numGraphicAnim + 1]; + for (i = 1; i <= _numGraphicAnim; i++) { + _graphicAnim[i].frame1 = (int16)READ_BE_UINT16(ptr); + ptr += 2; + _graphicAnim[i].frame2 = (int16)READ_BE_UINT16(ptr); + ptr += 2; + _graphicAnim[i].frame3 = (int16)READ_BE_UINT16(ptr); + ptr += 2; + } + + _currentRoom = _objectData[_entryObj].room; + _entryObj = 0; + + /* + switch (_resource->getLanguage()) { + case ENGLISH: + _keyLanguage = _keyCommands[KEYS_ENGLISH]; + break; + case GERMAN: + _keyLanguage = _keyCommands[KEYS_GERMAN]; + break; + case FRENCH: + _keyLanguage = _keyCommands[KEYS_FRENCH]; + break; + case ITALIAN: + _keyLanguage = _keyCommands[KEYS_ITALIAN]; + break; + default: + _keyLanguage = _keyCommands[KEYS_ENGLISH]; + break; + } + */ + + _objDescription = new char*[_numDescriptions + 1]; + _objDescription[0] = 0; + for (i = 1; i <= _numDescriptions; i++) + _objDescription[i] = _resource->getJAS2Line(); + + //Patch for German text bug + if (_resource->getLanguage() == GERMAN) { + char *txt = new char[48]; + strcpy(txt, "Es bringt nicht viel, das festzubinden."); + _objDescription[296] = txt; + } + + _objName = new char*[_numNames + 1]; + _objName[0] = 0; + for (i = 1; i <= _numNames; i++) + _objName[i] = _resource->getJAS2Line(); + + _roomName = new char*[_numRooms + 1]; + _roomName[0] = 0; + for (i = 1; i <= _numRooms; i++) + _roomName[i] = _resource->getJAS2Line(); + + _verbName[0] = 0; + for (i = 1; i <= 12; i++) + _verbName[i] = _resource->getJAS2Line(); + + _joeResponse[0] = 0; + for (i = 1; i <= JOE_RESPONSE_MAX; i++) + _joeResponse[i] = _resource->getJAS2Line(); + + _aAnim = new char*[_numAAnim + 1]; + _aAnim[0] = 0; + for (i = 1; i <= _numAAnim; i++) + _aAnim[i] = _resource->getJAS2Line(); + + _aName = new char*[_numAName + 1]; + _aName[0] = 0; + for (i = 1; i <= _numAName; i++) + _aName[i] = _resource->getJAS2Line(); + + _aFile = new char*[_numAFile + 1]; + _aFile[0] = 0; + for (i = 1; i <= _numAFile; i++) + _aFile[i] = _resource->getJAS2Line(); + + _textToggle = true; + if (_resource->isFloppy()) + _speechToggle = false; + else + _speechToggle = true; _graphics->panelLoad(); _graphics->bobSetupControl(); @@ -224,7 +441,6 @@ void Logic::initialise() { memset(_zones, 0, sizeof(_zones)); _oldRoom = 0; - _entryObj = 0; } uint16 Logic::currentRoom() { diff --git a/queen/logic.h b/queen/logic.h index b9de3fedd8..ab036b5882 100644 --- a/queen/logic.h +++ b/queen/logic.h @@ -27,15 +27,8 @@ namespace Queen { -#define MAX_ZONES_NUMBER 32 - - -enum Language { - ENGLISH = 'E', - FRENCH = 'F', - GERMAN = 'G', - ITALIAN = 'I' -}; +#define MAX_ZONES_NUMBER 32 +#define JOE_RESPONSE_MAX 40 enum RoomDisplayMode { RDM_FADE_NOJOE = 0, // fade in, no Joe @@ -95,7 +88,10 @@ public: int16 gameState(int index); void gameState(int index, int16 newValue); - Language language() { return ENGLISH; } // FIXME: get from queen.jas + char *getRoomName(uint16 roomNum) { return _roomName[roomNum] ; } + char *getObjectName(uint16 objNum) { return _objName[objNum]; } + + Language language() { return _resource->getLanguage(); } void zoneSet(uint16 screen, uint16 zone, uint16 x1, uint16 y1, uint16 x2, uint16 y2); void zoneSet(uint16 screen, uint16 zone, const Box& box); @@ -118,6 +114,9 @@ public: protected: + bool _textToggle; + bool _speechToggle; + uint8 *_jas; uint16 _numRooms; uint16 _currentRoom; @@ -132,6 +131,17 @@ protected: uint16 _numObjectBoxes; uint16 _numWalkOffs; uint16 _numObjDesc; + uint16 _numCmdList; //COM_LIST_MAX + uint16 _numCmdArea; //COM_A_MAX + uint16 _numCmdObject; //COM_O_MAX + uint16 _numCmdInventory; //COM_I_MAX + uint16 _numCmdGameState; //COM_G_MAX + uint16 _numFurniture; //FURN_DATA_MAX + uint16 _numActors; //ACTOR_DATA_MAX + uint16 _numAAnim; //A_ANIM_MAX + uint16 _numAName; //A_NAME_MAX + uint16 _numAFile; //A_FILE_MAX + uint16 _numGraphicAnim; //GRAPHIC_ANIM_MAX uint16 *_roomData; uint16 *_sfxName; @@ -142,12 +152,28 @@ protected: GraphicData *_graphicData; ObjectData *_objectData; ObjectDescription *_objectDescription; - uint16 (*_actorData)[12]; // FIXME: ActorData *_actorData; + ActorData *_actorData; Area (*_area)[11]; WalkOffData *_walkOffData; + CmdListData *_cmdList; + CmdArea *_cmdArea; + CmdObject *_cmdObject; + CmdInventory *_cmdInventory; + CmdGameState *_cmdGameState; + FurnitureData *_furnitureData; + GraphicAnim *_graphicAnim; ZoneSlot _zones[2][MAX_ZONES_NUMBER]; uint16 _entryObj; + char **_objDescription; //OBJECT_DESCRstr + char **_objName; //OBJECT_NAMEstr + char **_roomName; //ROOM_NAMEstr + char *_verbName[13]; //VERB_NAMEstr + char *_joeResponse[JOE_RESPONSE_MAX + 1]; //JOE_RESPstr + char **_aAnim; //A_ANIMstr + char **_aName; //A_NAMEstr + char **_aFile; //A_FILEstr + enum { GAME_STATE_COUNT = 211 }; diff --git a/queen/resource.cpp b/queen/resource.cpp index 61a1e55e13..93e5ad521c 100644 --- a/queen/resource.cpp +++ b/queen/resource.cpp @@ -44,7 +44,7 @@ const GameVersion Resource::_gameVersions[] = { }; Resource::Resource(const Common::String &datafilePath) - : _resourceEntries(0), _resourceTable(NULL), _datafilePath(datafilePath) { + : _resourceEntries(0), _resourceTable(NULL), _datafilePath(datafilePath), _JAS2Pos(0) { _resourceFile = new File(); _resourceFile->open(dataFilename, _datafilePath); @@ -69,12 +69,15 @@ Resource::Resource(const Common::String &datafilePath) error("Verifying game version failed! (expected: '%s', found: '%s')", _gameVersion->versionString, JASVersion()); debug(5, "Detected game version: %s, which has %d resource entries", _gameVersion->versionString, _resourceEntries); + + _JAS2Ptr = (char *)loadFile("QUEEN2.JAS", 0); } Resource::~Resource() { _resourceFile->close(); if(_resourceTable != _resourceTablePEM10) delete[] _resourceTable; + delete[] _JAS2Ptr; } int32 Resource::resourceIndex(const char *filename) { @@ -118,6 +121,19 @@ int32 Resource::resourceIndex(const char *filename) { return -1; } +char *Resource::getJAS2Line() { + char *startOfLine = _JAS2Ptr + _JAS2Pos; + char *pos = strstr(startOfLine, "\r\n"); + if (pos) { + *pos = '\0'; + pos += 2; + } else { + error("Couldn't find newline"); + } + _JAS2Pos = (pos - _JAS2Ptr); + return startOfLine; +} + uint32 Resource::fileSize(const char *filename) { return _resourceTable[resourceIndex(filename)].size; } @@ -153,6 +169,25 @@ bool Resource::isDemo() { return _gameVersion->isDemo; } +bool Resource::isFloppy() { + return _gameVersion->isFloppy; +} + +Language Resource::getLanguage() { + switch (_gameVersion->versionString[1]) { + case 'E': + return ENGLISH; + case 'G': + return GERMAN; + case 'F': + return FRENCH; + case 'I': + return ITALIAN; + default: + return ENGLISH; + } +} + const GameVersion *Resource::detectGameVersion(uint32 dataFilesize) { const GameVersion *pgv = NULL; //detect game version based on resource file size. diff --git a/queen/resource.h b/queen/resource.h index bfc808f5d6..eb396da06b 100644 --- a/queen/resource.h +++ b/queen/resource.h @@ -23,6 +23,7 @@ #define QUEEN_RESOURCE_H #include "common/file.h" +#include "defs.h" namespace Queen { @@ -60,12 +61,17 @@ public: Resource(const Common::String &datafilePath); ~Resource(void); uint8 *loadFile(const char *filename, uint32 skipBytes = 0); + char *getJAS2Line(); bool exists(const char *filename); bool isDemo(); + bool isFloppy(); uint32 fileSize(const char *filename); + Language getLanguage(); protected: File *_resourceFile; + char *_JAS2Ptr; + uint32 _JAS2Pos; const Common::String _datafilePath; const GameVersion *_gameVersion; uint32 _resourceEntries; |