From 2a139049d621479da4898fcb22c742c52d17eac3 Mon Sep 17 00:00:00 2001 From: Gregory Montoir Date: Sun, 26 Oct 2003 13:54:26 +0000 Subject: cleanup, add comments svn-id: r10977 --- queen/logic.cpp | 11 +++- queen/logic.h | 183 ++++++++++++++++++++++++++++++++++++++++---------------- queen/structs.h | 50 ++++++++++------ queen/xref.txt | 32 +++++----- 4 files changed, 185 insertions(+), 91 deletions(-) (limited to 'queen') diff --git a/queen/logic.cpp b/queen/logic.cpp index 6a1f40364a..790bb2bb60 100644 --- a/queen/logic.cpp +++ b/queen/logic.cpp @@ -1915,7 +1915,7 @@ const char* Logic::objectOrItemName(int16 obj) const { uint16 name; if (obj < 0) { - name = _itemData[ABS(obj)].item; + name = _itemData[ABS(obj)].name; } else { name = _objectData[obj].name; @@ -1931,7 +1931,7 @@ Verb Logic::findVerb(int16 cursorx, int16 cursory) const { } -uint16 Logic::findObjectFromZone(uint16 zoneNum) { +uint16 Logic::findObjectRoomNumber(uint16 zoneNum) const { // l.316-327 select.c uint16 noun = zoneNum; @@ -1948,6 +1948,12 @@ uint16 Logic::findObjectFromZone(uint16 zoneNum) { } +uint16 Logic::findObjectGlobalNumber(uint16 zoneNum) const { + + return _roomData[_currentRoom] + findObjectRoomNumber(zoneNum); +} + + const char *Logic::verbName(Verb v) const { if (v != VERB_NONE && v < 13) { @@ -1960,7 +1966,6 @@ const char *Logic::verbName(Verb v) const { } - void Logic::update() { _graphics->update(_currentRoom); _input->delay(); diff --git a/queen/logic.h b/queen/logic.h index 9e8d4411a3..e59ddb2218 100644 --- a/queen/logic.h +++ b/queen/logic.h @@ -28,10 +28,6 @@ namespace Queen { -#define MAX_ZONES_NUMBER 32 -#define MAX_AREAS_NUMBER 11 -#define JOE_RESPONSE_MAX 40 - enum RoomDisplayMode { RDM_FADE_NOJOE = 0, // fade in, no Joe RDM_FADE_JOE = 1, // Joe is to be displayed @@ -58,29 +54,59 @@ struct GameSettings { int talkSpeed; }; + +/*! + Each object/item in game has a state field. + (refer to ObjectData and ItemData). + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameBitsDescription
USE10Use
TALK9Talk
ON8On/Off
DEF7,6,5,4Default verb command
DIR3,2Direction faced
GRAB1,0Grab Direction
+*/ struct State { - //! FIND_STATE(state, "DIR"); static Direction findDirection(uint16 state); - - //! FIND_STATE(state, "TALK"); static StateTalk findTalk(uint16 state); - - //! FIND_STATE(state, "GRAB"); static StateGrab findGrab(uint16 state); + static StateOn findOn(uint16 state); + static Verb findDefaultVerb(uint16 state); + static StateUse findUse(uint16 state); - //! FIND_STATE(state, "ON"); - static StateOn findOn(uint16 state); - - //! FIND_STATE(state, "DEF"); - static Verb findDefaultVerb(uint16 state); - - static StateUse findUse(uint16 state); - - //! ALTER_STATE(state, "ON"); static void alterOn(uint16 *objState, StateOn state); - - //! ALTER_STATE(state, verb); static void alterDefaultVerb(uint16 *objState, Verb v); }; @@ -217,78 +243,127 @@ public: Walk *walk() { return _walk; } Display *display() { return _display; } - uint16 findObjectFromZone(uint16 zoneNum); + uint16 findObjectRoomNumber(uint16 zoneNum) const; + uint16 findObjectGlobalNumber(uint16 zoneNum) const; const char *verbName(Verb v) const; void update(); -protected: - GameSettings _settings; + enum { + MAX_ZONES_NUMBER = 32, + MAX_AREAS_NUMBER = 11, + JOE_RESPONSE_MAX = 40, + DEFAULT_TALK_SPEED = 7, + GAME_STATE_COUNT = 211 + }; + + +protected: void initialise(); + //! Contents of queen.jas file uint8 *_jas; - uint16 _numRooms; + uint16 _currentRoom; - uint16 _oldRoom; - uint16 _newRoom; - uint16 _numNames; - uint16 _numObjects; - uint16 _numDescriptions; - uint16 _numItems; - uint16 _numGraphics; + uint16 _oldRoom; + uint16 _newRoom; - 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 + //! Total number of room in game + uint16 _numRooms; + //! First object number in room uint16 *_roomData; + + //! Background music to play in room uint16 *_sfxName; + + //! Number of objects in room int16 *_objMax; - int16 *_areaMax; + + //! Bounding box of object Box *_objectBox; + + //! Inventory items ItemData *_itemData; + uint16 _numItems; + GraphicData *_graphicData; + uint16 _numGraphics; + ObjectData *_objectData; + uint16 _numObjects; + ObjectDescription *_objectDescription; + uint16 _numDescriptions; + ActorData *_actorData; + uint16 _numActors; //ACTOR_DATA_MAX + + //! Areas in room Area (*_area)[MAX_AREAS_NUMBER]; + + //! Number of areas in room + int16 *_areaMax; + + //! Walk off point for an object WalkOffData *_walkOffData; + uint16 _numWalkOffs; + CmdListData *_cmdList; + uint16 _numCmdList; //COM_LIST_MAX + CmdArea *_cmdArea; + uint16 _numCmdArea; //COM_A_MAX + CmdObject *_cmdObject; - CmdInventory *_cmdInventory; + uint16 _numCmdObject; //COM_O_MAX + + CmdInventory *_cmdInventory; + uint16 _numCmdInventory; //COM_I_MAX + CmdGameState *_cmdGameState; + uint16 _numCmdGameState; //COM_G_MAX + FurnitureData *_furnitureData; + uint16 _numFurniture; //FURN_DATA_MAX + GraphicAnim *_graphicAnim; + uint16 _numGraphicAnim; //GRAPHIC_ANIM_MAX + + //! Current areas in room ZoneSlot _zones[2][MAX_ZONES_NUMBER]; + + //! Actor position in room is _walkOffData[_entryObj] uint16 _entryObj; + //! Object description (Look At) char **_objDescription; //OBJECT_DESCRstr + uint16 _numObjDesc; + char **_objName; //OBJECT_NAMEstr + uint16 _numNames; + + //! Room name, prefix for data files (PCX, LUM...) 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 { - DEFAULT_TALK_SPEED = 7, - GAME_STATE_COUNT = 211 - }; + //! Actor animation string + char **_aAnim; + uint16 _numAAnim; //A_ANIM_MAX + + //! Actor name + char **_aName; + uint16 _numAName; //A_NAME_MAX + + //! Actor filename + char **_aFile; + uint16 _numAFile; //A_FILE_MAX struct { uint16 x, y; @@ -317,6 +392,8 @@ protected: //! Describe a string based animation (30 frames maximum, bob number must be < 17) AnimFrame _newAnim[17][30]; + GameSettings _settings; + Resource *_resource; Graphics *_graphics; Display *_display; diff --git a/queen/structs.h b/queen/structs.h index 70d15f9ec0..39f8c991b7 100644 --- a/queen/structs.h +++ b/queen/structs.h @@ -144,7 +144,7 @@ struct GraphicData { struct ObjectData { - //! entry in OBJECT_NAME (<0: object is hidden) + //! entry in OBJECT_NAME (<0: object is hidden, 0: object has been deleted) int16 name; //! coordinates of object uint16 x, y; @@ -156,13 +156,17 @@ struct ObjectData { uint16 room; //! state of the object (grab direction, on/off, default command...) uint16 state; - //! entry in GraphicData (can be negative) + //! entry in GraphicData /*! + + + + @@ -180,7 +184,11 @@ struct ObjectData { - + + + + + @@ -249,7 +257,7 @@ struct ObjectDescription { struct ItemData { //! entry in OBJECT_NAME - int16 item; + int16 name; //! entry in OBJECT_DESCR uint16 description; //! state of the object @@ -260,7 +268,7 @@ struct ItemData { int16 sfxDescription; void readFrom(byte *&ptr) { - item = (int16)READ_BE_UINT16(ptr); ptr += 2; + name = (int16)READ_BE_UINT16(ptr); ptr += 2; description = READ_BE_UINT16(ptr); ptr += 2; state = READ_BE_UINT16(ptr); ptr += 2; bobFrame = READ_BE_UINT16(ptr); ptr += 2; @@ -326,8 +334,8 @@ struct CmdListData { bool setItems; //! if set, P1_SET_CONDITIONS must be called (using CmdGameState) bool setConditions; - //! graphic image of object - int16 image; + //! graphic image order + int16 imageOrder; //! special section to execute /*! refer to execute.c l.423-451 @@ -365,18 +373,18 @@ struct CmdListData { setObjects = READ_BE_UINT16(ptr) != 0; ptr += 2; setItems = READ_BE_UINT16(ptr) != 0; ptr += 2; setConditions = READ_BE_UINT16(ptr) != 0; ptr += 2; - image = (int16)READ_BE_UINT16(ptr); ptr += 2; + imageOrder = (int16)READ_BE_UINT16(ptr); ptr += 2; specialSection = (int16)READ_BE_UINT16(ptr); ptr += 2; } bool match(Verb v, int16 obj1, int16 obj2) const { - return verb == verb && nounObj1 == obj1 && nounObj2 == obj2; + return verb == v && nounObj1 == obj1 && nounObj2 == obj2; } }; struct CmdArea { - //! identifier of the command + //! CmdListData number int16 id; //! area to turn off/on (<0: off, >0: on) int16 area; @@ -392,10 +400,12 @@ struct CmdArea { struct CmdObject { - //! identifier of the command + //! CmdListData number int16 id; - int16 dstObj; // >0: show, <0: hide - int16 srcObj; // >0: copy from srcObj, 0: nothing, -1: delete dstObj + //! >0: show, <0: hide + int16 dstObj; + //! >0: copy from srcObj, 0: nothing, -1: delete dstObj + int16 srcObj; void readFrom(byte *&ptr) { id = (int16)READ_BE_UINT16(ptr); ptr += 2; @@ -406,10 +416,12 @@ struct CmdObject { struct CmdInventory { - //! identifier of the command + //! CmdListData number int16 id; - int16 dstItem; // <0: delete, >0: add - int16 srcItem; // >0: valid + //! <0: delete, >0: add + int16 dstItem; + //! >0: valid + int16 srcItem; void readFrom(byte *&ptr) { id = (int16)READ_BE_UINT16(ptr); ptr += 2; @@ -420,17 +432,17 @@ struct CmdInventory { struct CmdGameState { - //! identifier of the command + //! CmdListData number int16 id; int16 gameStateSlot; int16 gameStateValue; - int16 speakValue; + uint16 speakValue; void readFrom(byte *&ptr) { id = (int16)READ_BE_UINT16(ptr); ptr += 2; gameStateSlot = (int16)READ_BE_UINT16(ptr); ptr += 2; gameStateValue = (int16)READ_BE_UINT16(ptr); ptr += 2; - speakValue = (int16)READ_BE_UINT16(ptr); ptr += 2; + speakValue = READ_BE_UINT16(ptr); ptr += 2; } }; diff --git a/queen/xref.txt b/queen/xref.txt index 28fc4cf170..c0091ea96f 100644 --- a/queen/xref.txt +++ b/queen/xref.txt @@ -18,6 +18,10 @@ ALTER_DEFAULT() Command::alterDefault CLEAR_COMMAND() Command::clear EXECUTE_ACTION() Command::executeCurrentAction FIND_DEFAULT() Command::findDefault +LOOK() +LOOK_ICON() +LOOK_ITEM() Command::lookCurrentItem +LOOK_ROOM() OPEN_CLOSE_OTHER() Command::openOrCloseAssociatedObject P1_SET_CONDITIONS() Command::setConditions P2_SET_AREAS() Command::setAreas @@ -30,10 +34,20 @@ SELECT_VERB() Command::grabSelectedVerb - ACTION,ACTION2 Command::_action* CLEVEL Command::_commandLevel +COM_A Logic::_cmdArea +COM_A_MAX Logic::_numCmdArea +COM_O Logic::_cmdObject +COM_O_MAX Logic::_numCmdObject +COM_G Logic::_cmdGameState +COM_G_MAX Logic::_numCmdGameState +COM_I Logic::_cmdInventory +COM_I_MAX Logic::_numCmdInventory +COM_LIST Logic::_cmdList +COM_LIST_MAX Logic::_numCmdList COMMANDstr Command::_command DEFCOMM Command::_defaultVerb OLDVERB,VERB Command::_*verb* -OLDNOUN,NOUN,NOUN2 Command::_*old* +OLDNOUN,NOUN,NOUN2 Command::_*noun* PARSE Command::_parse SUBJ1,SUBJ2,SUBJECT Command::_subject* @@ -194,10 +208,6 @@ FIND_FRAME() Logic::findFrame FIND_GRAPHIC() Logic::graphicData FIND_SCALE() Logic::findScale FIND_VERB() Logic::findVerb -LOOK() -LOOK_ICON() -LOOK_ITEM() -LOOK_ROOM() P3_COPY_FROM() Cutaway::objectCopy R_MAP() (handle map 'm1') REDISP_OBJECT() Logic::roomRefreshObject @@ -218,16 +228,6 @@ A_FILE_MAX Logic::_numAFile ACTOR_DATA_MAX Logic::_numActors AREA Logic::_area AREAMAX Logic::_areaMax -COM_A Logic::_cmdArea -COM_A_MAX Logic::_numCmdArea -COM_O Logic::_cmdObject -COM_O_MAX Logic::_numCmdObject -COM_G Logic::_cmdGameState -COM_G_MAX Logic::_numCmdGameState -COM_I Logic::_cmdInventory -COM_I_MAX Logic::_numCmdInventory -COM_LIST Logic::_cmdList -COM_LIST_MAX Logic::_numCmdList DESCTOT Logic::_numDescriptions ENTRY_OBJ Logic::_entryObj FMAX Logic::_numFurnitureStatic @@ -451,7 +451,7 @@ CANTQUIT (NO NEED TO BE GLOBAL) -=============== +====================== Nstr,F1,F2,F3,F4,F5,F6,F7,F8,SF,BF,AS,MS // MOVE_OTHER (struct movdata *) Nstr,S,F,BODY,BF,RF,AF,SANIMstr,FF // FIND_SACTION (struct action *) CURRBOB // SETUP_FURNITURE, REDISP_OBJECT, DISP_OBJECTS -- cgit v1.2.3
value description
]-4000..-10]graphic image turned off
-4 person object (right facing)static bob (off)
[0..5000]0object deleted
]0..5000] static or animated bob (on)