[Scummvm-cvs-logs] CVS: scummvm/queen state.cpp,NONE,1.1 state.h,NONE,1.1 command.cpp,1.34,1.35 defs.h,1.35,1.36 logic.cpp,1.126,1.127 logic.h,1.82,1.83 module.mk,1.16,1.17 talk.cpp,1.56,1.57
Gregory Montoir
cyx at users.sourceforge.net
Thu Dec 11 02:04:03 CET 2003
Update of /cvsroot/scummvm/scummvm/queen
In directory sc8-pr-cvs1:/tmp/cvs-serv28467/queen
Modified Files:
command.cpp defs.h logic.cpp logic.h module.mk talk.cpp
Added Files:
state.cpp state.h
Log Message:
centralize all State related stuff
--- NEW FILE: state.cpp ---
/* 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: /cvsroot/scummvm/scummvm/queen/state.cpp,v 1.1 2003/12/11 10:03:35 cyx Exp $
*
*/
#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
--- NEW FILE: state.h ---
/* 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: /cvsroot/scummvm/scummvm/queen/state.h,v 1.1 2003/12/11 10:03:35 cyx Exp $
*
*/
#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
Index: command.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/command.cpp,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- command.cpp 6 Dec 2003 13:13:13 -0000 1.34
+++ command.cpp 11 Dec 2003 10:03:35 -0000 1.35
@@ -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"
Index: defs.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/defs.h,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- defs.h 5 Dec 2003 20:16:31 -0000 1.35
+++ defs.h 11 Dec 2003 10:03:35 -0000 1.36
@@ -280,32 +280,6 @@
};
-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,
Index: logic.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/logic.cpp,v
retrieving revision 1.126
retrieving revision 1.127
diff -u -d -r1.126 -r1.127
--- logic.cpp 10 Dec 2003 21:36:56 -0000 1.126
+++ logic.cpp 11 Dec 2003 10:03:35 -0000 1.127
@@ -59,123 +59,6 @@
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;
Index: logic.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/logic.h,v
retrieving revision 1.82
retrieving revision 1.83
diff -u -d -r1.82 -r1.83
--- logic.h 10 Dec 2003 20:13:25 -0000 1.82
+++ logic.h 11 Dec 2003 10:03:35 -0000 1.83
@@ -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 {
@@ -40,63 +41,6 @@
bool valid;
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;
Index: module.mk
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/module.mk,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- module.mk 26 Nov 2003 13:53:17 -0000 1.16
+++ module.mk 11 Dec 2003 10:03:35 -0000 1.17
@@ -14,6 +14,7 @@
queen/resource.o \
queen/restables.o \
queen/sound.o \
+ queen/state.o \
queen/talk.o \
queen/walk.o
Index: talk.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/talk.cpp,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -d -r1.56 -r1.57
--- talk.cpp 10 Dec 2003 20:13:25 -0000 1.56
+++ talk.cpp 11 Dec 2003 10:03:35 -0000 1.57
@@ -27,6 +27,7 @@
#include "queen/logic.h"
#include "queen/resource.h"
#include "queen/sound.h"
+#include "queen/state.h"
namespace Queen {
More information about the Scummvm-git-logs
mailing list