diff options
Diffstat (limited to 'queen')
-rw-r--r-- | queen/command.cpp | 1 | ||||
-rw-r--r-- | queen/defs.h | 26 | ||||
-rw-r--r-- | queen/logic.cpp | 117 | ||||
-rw-r--r-- | queen/logic.h | 58 | ||||
-rw-r--r-- | queen/module.mk | 1 | ||||
-rw-r--r-- | queen/state.cpp | 149 | ||||
-rw-r--r-- | queen/state.h | 116 | ||||
-rw-r--r-- | queen/talk.cpp | 1 |
8 files changed, 269 insertions, 200 deletions
diff --git a/queen/command.cpp b/queen/command.cpp index e50a7ba851..df1c4b82e9 100644 --- a/queen/command.cpp +++ b/queen/command.cpp @@ -26,6 +26,7 @@ #include "queen/graphics.h" #include "queen/logic.h" #include "queen/sound.h" +#include "queen/state.h" #include "queen/talk.h" #include "queen/walk.h" diff --git a/queen/defs.h b/queen/defs.h index 8f6e4394de..d93c3cebfa 100644 --- a/queen/defs.h +++ b/queen/defs.h @@ -280,32 +280,6 @@ enum Language { }; -enum StateTalk { - STATE_TALK_TALK, - STATE_TALK_MUTE -}; - - -enum StateGrab { - STATE_GRAB_NONE, - STATE_GRAB_DOWN, - STATE_GRAB_UP, - STATE_GRAB_MID -}; - - -enum StateOn { - STATE_ON_ON, - STATE_ON_OFF -}; - - -enum StateUse { - STATE_USE, - STATE_USE_ON -}; - - enum JoeWalkMode { JWM_NORMAL = 0, JWM_MOVE = 1, diff --git a/queen/logic.cpp b/queen/logic.cpp index 1b49bc8580..dc9c5383a2 100644 --- a/queen/logic.cpp +++ b/queen/logic.cpp @@ -59,123 +59,6 @@ const VerbEnum Logic::PANEL_VERBS[] = { char* Verb::_verbName[13]; -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(VERB_OPEN); - break; - case 3: - v = Verb(VERB_CLOSE); - break; - case 7: - v = Verb(VERB_MOVE); - break; - case 8: - v = Verb(VERB_GIVE); - break; - case 12: - v = Verb(VERB_USE); - break; - case 14: - v = Verb(VERB_PICK_UP); - break; - case 9: - v = Verb(VERB_TALK_TO); - break; - case 6: - v = Verb(VERB_LOOK_AT); - break; - default: - v = Verb(VERB_NONE); - break; - } - return v; -} - - -StateUse State::findUse(uint16 state) { - return (state & (1 << 10)) ? STATE_USE : STATE_USE_ON; -} - - -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.value()) { - case VERB_OPEN: - val = 1; - 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) | (val << 4); -} - - Common::RandomSource Logic::randomizer; diff --git a/queen/logic.h b/queen/logic.h index 87143c48f4..16ef37c62f 100644 --- a/queen/logic.h +++ b/queen/logic.h @@ -25,6 +25,7 @@ #include "common/util.h" #include "queen/defs.h" #include "queen/structs.h" +#include "queen/state.h" // for joeGrabDirection() #include "queen/verb.h" namespace Queen { @@ -41,63 +42,6 @@ struct ZoneSlot { Box box; }; - -/*! - Each object/item in game has a state field. - (refer to ObjectData and ItemData). - - <table> - <tr> - <td>Name</td> - <td>Bits</td> - <td>Description</td> - </tr> - <tr> - <td>USE</td> - <td>10</td> - <td>Use</td> - </tr> - <tr> - <td>TALK</td> - <td>9</td> - <td>Talk</td> - </tr> - <tr> - <td>ON</td> - <td>8</td> - <td>On/Off</td> - </tr> - <tr> - <td>DEF</td> - <td>7,6,5,4</td> - <td>Default verb command</td> - </tr> - <tr> - <td>DIR</td> - <td>3,2</td> - <td>Direction faced</td> - </tr> - <tr> - <td>GRAB</td> - <td>1,0</td> - <td>Grab Direction</td> - </tr> - </table> -*/ -struct State { - - static Direction findDirection(uint16 state); - static StateTalk findTalk(uint16 state); - static StateGrab findGrab(uint16 state); - static StateOn findOn(uint16 state); - static Verb findDefaultVerb(uint16 state); - static StateUse findUse(uint16 state); - - static void alterOn(uint16 *objState, StateOn state); - static void alterDefaultVerb(uint16 *objState, Verb v); -}; - - class Command; class Debug; class Display; diff --git a/queen/module.mk b/queen/module.mk index b01bb1e343..64f10fc6c0 100644 --- a/queen/module.mk +++ b/queen/module.mk @@ -14,6 +14,7 @@ MODULE_OBJS = \ queen/resource.o \ queen/restables.o \ queen/sound.o \ + queen/state.o \ queen/talk.o \ queen/walk.o diff --git a/queen/state.cpp b/queen/state.cpp new file mode 100644 index 0000000000..65fc915076 --- /dev/null +++ b/queen/state.cpp @@ -0,0 +1,149 @@ +/* ScummVM - Scumm Interpreter + * Copyright (C) 2003 The ScummVM project + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Header$ + * + */ + +#include "stdafx.h" +#include "queen/state.h" + +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(VERB_OPEN); + break; + case 3: + v = Verb(VERB_CLOSE); + break; + case 7: + v = Verb(VERB_MOVE); + break; + case 8: + v = Verb(VERB_GIVE); + break; + case 12: + v = Verb(VERB_USE); + break; + case 14: + v = Verb(VERB_PICK_UP); + break; + case 9: + v = Verb(VERB_TALK_TO); + break; + case 6: + v = Verb(VERB_LOOK_AT); + break; + default: + v = Verb(VERB_NONE); + break; + } + return v; +} + + +StateUse State::findUse(uint16 state) { + return (state & (1 << 10)) ? STATE_USE : STATE_USE_ON; +} + + +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.value()) { + case VERB_OPEN: + val = 1; + 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) | (val << 4); +} + + +} // End of namespace Queen diff --git a/queen/state.h b/queen/state.h new file mode 100644 index 0000000000..9408a17aa3 --- /dev/null +++ b/queen/state.h @@ -0,0 +1,116 @@ +/* ScummVM - Scumm Interpreter + * Copyright (C) 2003 The ScummVM project + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Header$ + * + */ + +#ifndef QUEENSTATE_H +#define QUEENSTATE_H + +#include "common/util.h" +#include "queen/defs.h" +#include "queen/verb.h" + +namespace Queen { + + +enum StateTalk { + STATE_TALK_TALK, + STATE_TALK_MUTE +}; + + +enum StateGrab { + STATE_GRAB_NONE, + STATE_GRAB_DOWN, + STATE_GRAB_UP, + STATE_GRAB_MID +}; + + +enum StateOn { + STATE_ON_ON, + STATE_ON_OFF +}; + + +enum StateUse { + STATE_USE, + STATE_USE_ON +}; + + +/*! + Each object/item in game has a state field. + (refer to ObjectData and ItemData). + + <table> + <tr> + <td>Name</td> + <td>Bits</td> + <td>Description</td> + </tr> + <tr> + <td>USE</td> + <td>10</td> + <td>Use</td> + </tr> + <tr> + <td>TALK</td> + <td>9</td> + <td>Talk</td> + </tr> + <tr> + <td>ON</td> + <td>8</td> + <td>On/Off</td> + </tr> + <tr> + <td>DEF</td> + <td>7,6,5,4</td> + <td>Default verb command</td> + </tr> + <tr> + <td>DIR</td> + <td>3,2</td> + <td>Direction to face for the object</td> + </tr> + <tr> + <td>GRAB</td> + <td>1,0</td> + <td>Grab Direction</td> + </tr> + </table> +*/ +struct State { + + static Direction findDirection(uint16 state); + static StateTalk findTalk(uint16 state); + static StateGrab findGrab(uint16 state); + static StateOn findOn(uint16 state); + static Verb findDefaultVerb(uint16 state); + static StateUse findUse(uint16 state); + + static void alterOn(uint16 *objState, StateOn state); + static void alterDefaultVerb(uint16 *objState, Verb v); +}; + + +} // End of namespace Queen + +#endif diff --git a/queen/talk.cpp b/queen/talk.cpp index 74f90f8751..0ce91e6078 100644 --- a/queen/talk.cpp +++ b/queen/talk.cpp @@ -27,6 +27,7 @@ #include "queen/logic.h" #include "queen/resource.h" #include "queen/sound.h" +#include "queen/state.h" namespace Queen { |