diff options
author | Gregory Montoir | 2003-10-23 18:46:04 +0000 |
---|---|---|
committer | Gregory Montoir | 2003-10-23 18:46:04 +0000 |
commit | 00e2ee13ffac04b1c4c6d4986aef1cb1ce451866 (patch) | |
tree | 7374803ddf77663855fd3ba4c860342fc2b8f4b9 | |
parent | 58df0207177b080548589d40a8a9eb622a55e847 (diff) | |
download | scummvm-rg350-00e2ee13ffac04b1c4c6d4986aef1cb1ce451866.tar.gz scummvm-rg350-00e2ee13ffac04b1c4c6d4986aef1cb1ce451866.tar.bz2 scummvm-rg350-00e2ee13ffac04b1c4c6d4986aef1cb1ce451866.zip |
move state related methods to specific class + minor changes
svn-id: r10951
-rw-r--r-- | queen/defs.h | 8 | ||||
-rw-r--r-- | queen/logic.cpp | 205 | ||||
-rw-r--r-- | queen/logic.h | 33 | ||||
-rw-r--r-- | queen/xref.txt | 44 |
4 files changed, 169 insertions, 121 deletions
diff --git a/queen/defs.h b/queen/defs.h index c81a8283d1..809b67135c 100644 --- a/queen/defs.h +++ b/queen/defs.h @@ -138,14 +138,6 @@ enum Verb { }; -enum StateDirection { - STATE_DIR_BACK = 0, - STATE_DIR_RIGHT = 1, - STATE_DIR_LEFT = 2, - STATE_DIR_FRONT = 3 -}; - - enum StateTalk { STATE_TALK_TALK, STATE_TALK_MUTE diff --git a/queen/logic.cpp b/queen/logic.cpp index aca33a595d..d98cce80a9 100644 --- a/queen/logic.cpp +++ b/queen/logic.cpp @@ -31,6 +31,119 @@ namespace Queen { + +Direction State::findDirection(uint16 state) { + // queen.c l.4014-4021 + static const Direction sd[] = { + DIR_BACK, + DIR_RIGHT, + DIR_LEFT, + DIR_FRONT + }; + return sd[(state >> 2) & 3]; +} + +StateTalk State::findTalk(uint16 state) { + return (state & (1 << 9)) ? STATE_TALK_TALK : STATE_TALK_MUTE; +} + +StateGrab State::findGrab(uint16 state) { + // queen.c l.4022-4029 + static const StateGrab gd[] = { + STATE_GRAB_NONE, + STATE_GRAB_DOWN, + STATE_GRAB_UP, + STATE_GRAB_MID + }; + return gd[state & 3]; +} + +StateOn State::findOn(uint16 state) { + return (state & (1 << 8)) ? STATE_ON_ON : STATE_ON_OFF; +} + + +Verb State::findDefaultVerb(uint16 state) { + Verb v; + switch((state >> 4) & 0xF) { + case 1: + v = VERB_OPEN; + break; + case 3: + v = VERB_CLOSE; + break; + case 7: + v = VERB_MOVE; + break; + case 8: + v = VERB_GIVE; + break; + case 12: + v = VERB_USE; + break; + case 14: + v = VERB_PICK_UP; + break; + case 9: + v = VERB_TALK_TO; + break; + case 6: + v = VERB_LOOK_AT; + break; + default: + v = VERB_NONE; + break; + } + return v; +} + + +void State::alterOn(uint16 *objState, StateOn state) { + switch (state) { + case STATE_ON_ON: + *objState |= (1 << 8); + break; + case STATE_ON_OFF: + *objState &= ~(1 << 8); + break; + } +} + +void State::alterDefaultVerb(uint16 *objState, Verb v) { + uint16 val; + switch (v) { + case VERB_OPEN: + val = 0; + break; + case VERB_CLOSE: + val = 3; + break; + case VERB_MOVE: + val = 7; + break; + case VERB_GIVE: + val = 8; + break; + case VERB_USE: + val = 12; + break; + case VERB_PICK_UP: + val = 14; + break; + case VERB_TALK_TO: + val = 9; + break; + case VERB_LOOK_AT: + val = 6; + break; + default: + val = 0; + break; + } + *objState = (*objState & ~0xF0) | (v << 4); +} + + Logic::Logic(Resource *resource, Graphics *graphics, Display *theDisplay, Input *input, Sound *sound) : _resource(resource), _graphics(graphics), _display(theDisplay), _input(input), _sound(sound), _talkSpeed(DEFAULT_TALK_SPEED) { @@ -1457,65 +1570,16 @@ void Logic::animSetup(const GraphicData *gd, uint16 firstImage, uint16 bobNum, b } -StateDirection Logic::findStateDirection(uint16 state) const { - - // FIXME: may be we should return a DIR_* constant instead - // of a STATE_DIR_*. Some (all ?) calls to FIND_STATE(, "DIR") - // are often followed by a DIR_* constant. - - // queen.c l.4014-4021 - static const StateDirection sd[] = { - STATE_DIR_BACK, - STATE_DIR_RIGHT, - STATE_DIR_LEFT, - STATE_DIR_FRONT - }; - return sd[(state >> 2) & 3]; -} - -StateTalk Logic::findStateTalk(uint16 state) const { - return (state & (1 << 9)) ? STATE_TALK_TALK : STATE_TALK_MUTE; -} - -StateGrab Logic::findStateGrab(uint16 state) const { - - // queen.c l.4022-4029 - static const StateGrab gd[] = { - STATE_GRAB_NONE, - STATE_GRAB_DOWN, - STATE_GRAB_UP, - STATE_GRAB_MID - }; - return gd[state & 3]; -} - -StateOn Logic::findStateOn(uint16 state) const { - return (state & (1 << 8)) ? STATE_ON_ON : STATE_ON_OFF; -} - - -void Logic::alterStateOn(uint16 *objState, StateOn state) const { - switch (state) { - case STATE_ON_ON: - *objState |= (1 << 8); - break; - case STATE_ON_OFF: - *objState &= ~(1 << 8); - break; - } -} - - -void Logic::joeSetupFromBanks(const char *bank1, const char* bank2) { +void Logic::joeSetupFromBanks(const char *animBank, const char *standBank) { int i; - _graphics->bankLoad(bank1, 13); + _graphics->bankLoad(animBank, 13); for (i = 11; i <= 28 + FRAMES_JOE_XTRA; ++i) { _graphics->bankUnpack(i - 10, i, 13); } _graphics->bankErase(13); - _graphics->bankLoad(bank2, 7); + _graphics->bankLoad(standBank, 7); _graphics->bankUnpack(1, 33 + FRAMES_JOE_XTRA, 7); _graphics->bankUnpack(3, 34 + FRAMES_JOE_XTRA, 7); _graphics->bankUnpack(5, 35 + FRAMES_JOE_XTRA, 7); @@ -1577,22 +1641,9 @@ ObjectData *Logic::joeSetupInRoom(bool autoPosition, uint16 scale) { // TODO: cutawayJoeFacing // check to see which way Joe entered room - switch (findStateDirection(pod->state)) { - case STATE_DIR_FRONT: - _joe.facing = DIR_FRONT; - break; - case STATE_DIR_BACK: - _joe.facing = DIR_BACK; - break; - case STATE_DIR_LEFT: - _joe.facing = DIR_LEFT; - break; - case STATE_DIR_RIGHT: - _joe.facing = DIR_RIGHT; - break; - } - + _joe.facing = State::findDirection(pod->state); _joe.prevFacing = _joe.facing; + BobSlot *pbs = _graphics->bob(0); pbs->scale = _joe.scale; @@ -1694,21 +1745,7 @@ int16 Logic::joeWalkTo(int16 x, int16 y, const Command_ *cmd, bool mustWalk) { // determine which way for Joe to face Object - uint16 facing = 0; - switch (findStateDirection(objData->state)) { - case STATE_DIR_BACK: - facing = DIR_BACK; - break; - case STATE_DIR_FRONT: - facing = DIR_FRONT; - break; - case STATE_DIR_LEFT: - facing = DIR_LEFT; - break; - case STATE_DIR_RIGHT: - facing = DIR_RIGHT; - break; - } + uint16 facing = State::findDirection(objData->state); int16 p = 0; if (mustWalk) { @@ -1729,7 +1766,7 @@ int16 Logic::joeWalkTo(int16 x, int16 y, const Command_ *cmd, bool mustWalk) { void Logic::joeGrab(uint16 state, uint16 speed) { - StateGrab sg = findStateGrab(state); + StateGrab sg = State::findGrab(state); if (sg != STATE_GRAB_NONE) { joeGrabDirection(sg, speed); } @@ -1859,6 +1896,7 @@ void Logic::playCutaway(const char* cutFile) { Cutaway::run(cutFile, next, _graphics, _input, this, _resource, _sound); } + void Logic::update() { _graphics->update(_currentRoom); _input->delay(); @@ -1868,5 +1906,6 @@ void Logic::update() { _input->checkKeys(); } + } // End of namespace Queen diff --git a/queen/logic.h b/queen/logic.h index 521671db0e..17900a11d7 100644 --- a/queen/logic.h +++ b/queen/logic.h @@ -44,12 +44,35 @@ struct ZoneSlot { Box box; }; - struct Command_ { Verb action, action2; uint16 noun, noun2; }; +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); + + //! FIND_STATE(state, "ON"); + static StateOn findOn(uint16 state); + + //! FIND_STATE(state, "DEF"); + static Verb findDefaultVerb(uint16 state); + + //! ALTER_STATE(state, "ON"); + static void alterOn(uint16 *objState, StateOn state); + + //! ALTER_STATE(state, verb); + static void alterDefaultVerb(uint16 *objState, Verb v); +}; + class Graphics; class Resource; @@ -142,17 +165,11 @@ public: void animErase(uint16 bobNum); void animSetup(const GraphicData *gd, uint16 firstImage, uint16 bobNum, bool visible); // FIND_GRAPHIC_ANIMS - StateDirection findStateDirection(uint16 state) const; // == FIND_STATE(state, "DIR"); - StateTalk findStateTalk (uint16 state) const; // == FIND_STATE(state, "TALK"); - StateGrab findStateGrab (uint16 state) const; // == FIND_STATE(state, "GRAB"); - StateOn findStateOn (uint16 state) const; // == FIND_STATE(state, "ON"); - void alterStateOn(uint16 *objState, StateOn state) const; // == ALTER_STATE(state, "ON"); - Walk *walk() { return _walk; } int talkSpeed() { return _talkSpeed; } - void joeSetupFromBanks(const char *bank1, const char* bank2); + void joeSetupFromBanks(const char *animBank, const char *standBank); //! SETUP_JOE(), loads the various bobs needed to animate Joe void joeSetup(); diff --git a/queen/xref.txt b/queen/xref.txt index e61af27d75..8db6ffff76 100644 --- a/queen/xref.txt +++ b/queen/xref.txt @@ -15,33 +15,34 @@ unpack() Graphics::bankUnpack COMMAND ======= ALTER_DEFAULT() -CLEAR_COMMAND() +CLEAR_COMMAND() Command::clear EXECUTE_ACTION() -OPEN_CLOSE_OTHER() -P1_SET_CONDITIONS() -P2_SET_AREAS() -P3_SET_OBJECTS() -P4_SET_ITEMS() +FIND_DEFAULT() Command::findDefault +OPEN_CLOSE_OTHER() Command::openOrCloseAssociatedObject +P1_SET_CONDITIONS() Command::setConditions +P2_SET_AREAS() Command::setAreas +P3_SET_OBJECTS() Command::setObjects +P4_SET_ITEMS() Command::setItems SELECT() SELECT_ITEM() SELECT_NOUN() SELECT_VERB() - ACTION,ACTION2 -CLEVEL -COM -COMMANDstr -COMMAX -COND -CURRCOM +CLEVEL Command::_commandLevel +COM *EXECUTE_ACTION local* +COMMANDstr Command::_command +COMMAX *EXECUTE_ACTION local* +COND *EXECUTE_ACTION local* +CURRCOM *EXECUTE_ACTION local* DEFCOMM -GSET +GSET *P1_SET_CONDITIONS local* OLDVERB,VERB OLDNOUN,NOUN,NOUN2 -PARSE -SUBJ1,SUBJ2,SUBJECT -TA2 -TEMPI +PARSE Command::_parse +SUBJ1,SUBJ2,SUBJECT Command::_subject* +A2 *EXECUTE_ACTION local* +TEMPI *P1_SET_CONDITIONS local* TEMPstr WORDstr @@ -204,7 +205,6 @@ LOGIC DISP_OBJECTS() Logic::roomSetupObjects DISP_ROOM() Logic::roomDisplay FIND_BOB() Logic::findBob -FIND_DEFAULT() FIND_FRAME() Logic::findFrame FIND_GRAPHIC() Logic::graphicData FIND_SCALE() Logic::findScale @@ -348,11 +348,11 @@ VOLUME STATE ===== -ALTER_STATE() Logic::alterState* -FIND_STATE() Logic::findState* +ALTER_STATE() State::alterState* +FIND_STATE() State::findState* - -Gstr // grab state -Pstr // FIND_STATE result +Gstr *no needed* // grab state +Pstr *no needed* // FIND_STATE result TALK |