aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--queen/cutaway.cpp2
-rw-r--r--queen/defs.h34
-rw-r--r--queen/input.cpp18
-rw-r--r--queen/input.h28
-rw-r--r--queen/logic.cpp47
-rw-r--r--queen/logic.h6
-rw-r--r--queen/structs.h6
-rw-r--r--queen/talk.cpp2
-rw-r--r--queen/verb.h145
-rw-r--r--queen/xref.txt2
10 files changed, 183 insertions, 107 deletions
diff --git a/queen/cutaway.cpp b/queen/cutaway.cpp
index 5376ba0229..fe41a2af8e 100644
--- a/queen/cutaway.cpp
+++ b/queen/cutaway.cpp
@@ -1500,7 +1500,7 @@ void Cutaway::handleText(
if (_input->cutawayQuit())
return;
- if (_input->verbSkipText()) {
+ if (_input->keyVerb().isSkipText()) {
_input->clearKeyVerb();
break;
}
diff --git a/queen/defs.h b/queen/defs.h
index 1400b153e8..39e2709cb0 100644
--- a/queen/defs.h
+++ b/queen/defs.h
@@ -90,40 +90,6 @@ enum Language {
};
-enum Verb {
- VERB_NONE = 0,
-
- VERB_PANEL_COMMAND_FIRST = 1,
- VERB_OPEN = 1,
- VERB_CLOSE = 2,
- VERB_MOVE = 3,
- // no verb 4
- VERB_GIVE = 5,
- VERB_USE = 6,
- VERB_PICK_UP = 7,
- VERB_LOOK_AT = 9,
- VERB_TALK_TO = 8,
- VERB_PANEL_COMMAND_LAST = 9,
-
- VERB_WALK_TO = 10,
- VERB_SCROLL_UP = 11,
- VERB_SCROLL_DOWN = 12,
-
- VERB_DIGIT_FIRST = 13,
- VERB_DIGIT_1 = 13,
- VERB_DIGIT_2 = 14,
- VERB_DIGIT_3 = 15,
- VERB_DIGIT_4 = 16,
- VERB_DIGIT_LAST = 16,
-
- VERB_USE_JOURNAL = 20,
- VERB_SKIP_TEXT = 101,
-
- VERB_PREP_WITH = 11,
- VERB_PREP_TO = 12
-};
-
-
enum StateTalk {
STATE_TALK_TALK,
STATE_TALK_MUTE
diff --git a/queen/input.cpp b/queen/input.cpp
index b1b86d3130..75ac0d1d0e 100644
--- a/queen/input.cpp
+++ b/queen/input.cpp
@@ -102,31 +102,31 @@ void Input::checkKeys() {
switch (_inKey) {
case KEY_SPACE:
- _keyVerb = VERB_SKIP_TEXT;
+ _keyVerb = Verb(VERB_SKIP_TEXT);
break;
case KEY_COMMA:
- _keyVerb = VERB_SCROLL_UP;
+ _keyVerb = Verb(VERB_SCROLL_UP);
break;
case KEY_DOT:
- _keyVerb = VERB_SCROLL_DOWN;
+ _keyVerb = Verb(VERB_SCROLL_DOWN);
break;
case KEY_DIGIT_1:
- _keyVerb = VERB_DIGIT_1;
+ _keyVerb = Verb(VERB_DIGIT_1);
break;
case KEY_DIGIT_2:
- _keyVerb = VERB_DIGIT_2;
+ _keyVerb = Verb(VERB_DIGIT_2);
break;
case KEY_DIGIT_3:
- _keyVerb = VERB_DIGIT_3;
+ _keyVerb = Verb(VERB_DIGIT_3);
break;
case KEY_DIGIT_4:
- _keyVerb = VERB_DIGIT_4;
+ _keyVerb = Verb(VERB_DIGIT_4);
break;
case KEY_ESCAPE:
@@ -144,12 +144,12 @@ void Input::checkKeys() {
case KEY_F1: // Use Journal
if (_cutawayRunning) {
if (_canQuit) {
- _keyVerb = VERB_USE_JOURNAL;
+ _keyVerb = Verb(VERB_USE_JOURNAL);
_cutawayQuit = _talkQuit = true;
}
}
else {
- _keyVerb = VERB_USE_JOURNAL;
+ _keyVerb = Verb(VERB_USE_JOURNAL);
if (_canQuit)
_talkQuit = true;
}
diff --git a/queen/input.h b/queen/input.h
index fd97df91b3..6c9d15b1bc 100644
--- a/queen/input.h
+++ b/queen/input.h
@@ -23,6 +23,7 @@
#define INPUT_H
#include "queen/defs.h"
+#include "queen/verb.h"
#include "common/scummsys.h"
class OSystem;
@@ -56,32 +57,7 @@ class Input {
void checkKeys();
//! use instead of KEYVERB=0
- void clearKeyVerb() { _keyVerb = VERB_NONE; }
-
- //! _keyVerb is open/close/move/give/look at/pick up/talk to
- bool verbIsPanelCommand() {
- return
- _keyVerb >= VERB_PANEL_COMMAND_FIRST &&
- _keyVerb <= VERB_PANEL_COMMAND_LAST;
- }
-
- //! return _keyVerb if isPanelCommand() is true, otherwise VERB_NONE
- Verb verbPanelCommand();
-
- //! If _keyVerb is VERB_USE_JOURNAL
- bool verbUseJournal() { return _keyVerb == VERB_USE_JOURNAL; }
-
- //! If _keyVerb is VERB_KEY_1 to VERB_KEY_4
- bool verbIsDigit() {
- return
- _keyVerb >= VERB_DIGIT_FIRST &&
- _keyVerb <= VERB_DIGIT_LAST;
- }
-
- //! Returns 1-4 if keyDigit() is true, otherwise -1
- int verbDigit();
-
- bool verbSkipText() { return _keyVerb == VERB_SKIP_TEXT; }
+ void clearKeyVerb() { _keyVerb = Verb(VERB_NONE); }
void canQuit(bool cq) { _canQuit = cq; }
diff --git a/queen/logic.cpp b/queen/logic.cpp
index dac6854ef6..0d9f073f9f 100644
--- a/queen/logic.cpp
+++ b/queen/logic.cpp
@@ -32,7 +32,7 @@
namespace Queen {
-const Verb Logic::PANEL_VERBS[] = {
+const VerbEnum Logic::PANEL_VERBS[] = {
VERB_NONE,
VERB_OPEN,
VERB_CLOSE,
@@ -51,6 +51,8 @@ const Verb Logic::PANEL_VERBS[] = {
};
+char* Verb::_verbName[13];
+
Direction State::findDirection(uint16 state) {
// queen.c l.4014-4021
static const Direction sd[] = {
@@ -86,31 +88,31 @@ Verb State::findDefaultVerb(uint16 state) {
Verb v;
switch((state >> 4) & 0xF) {
case 1:
- v = VERB_OPEN;
+ v = Verb(VERB_OPEN);
break;
case 3:
- v = VERB_CLOSE;
+ v = Verb(VERB_CLOSE);
break;
case 7:
- v = VERB_MOVE;
+ v = Verb(VERB_MOVE);
break;
case 8:
- v = VERB_GIVE;
+ v = Verb(VERB_GIVE);
break;
case 12:
- v = VERB_USE;
+ v = Verb(VERB_USE);
break;
case 14:
- v = VERB_PICK_UP;
+ v = Verb(VERB_PICK_UP);
break;
case 9:
- v = VERB_TALK_TO;
+ v = Verb(VERB_TALK_TO);
break;
case 6:
- v = VERB_LOOK_AT;
+ v = Verb(VERB_LOOK_AT);
break;
default:
- v = VERB_NONE;
+ v = Verb(VERB_NONE);
break;
}
return v;
@@ -135,7 +137,7 @@ void State::alterOn(uint16 *objState, StateOn state) {
void State::alterDefaultVerb(uint16 *objState, Verb v) {
uint16 val;
- switch (v) {
+ switch (v.value()) {
case VERB_OPEN:
val = 1;
break;
@@ -418,9 +420,9 @@ void Logic::initialise() {
for (i = 1; i <= _numRooms; i++)
_roomName[i] = _resource->getJAS2Line();
- _verbName[0] = 0;
+ Verb::initName(0, NULL);
for (i = 1; i <= 12; i++)
- _verbName[i] = _resource->getJAS2Line();
+ Verb::initName(i, _resource->getJAS2Line());
_joeResponse[0] = 0;
for (i = 1; i <= JOE_RESPONSE_MAX; i++)
@@ -1751,7 +1753,7 @@ int16 Logic::joeWalkTo(int16 x, int16 y, const Command_ *cmd, bool mustWalk) {
y = objData->y;
}
- if (cmd->action2 == VERB_WALK_TO) {
+ if (cmd->action2.value() == VERB_WALK_TO) {
_entryObj = objData->entryObj;
}
else {
@@ -1760,7 +1762,7 @@ int16 Logic::joeWalkTo(int16 x, int16 y, const Command_ *cmd, bool mustWalk) {
_newRoom = 0;
- if (_entryObj != 0 && cmd->action2 != VERB_CLOSE) {
+ if (_entryObj != 0 && cmd->action2.value() != VERB_CLOSE) {
// because this is an exit object, see if there is
// a walk off point and set (x,y) accordingly
WalkOffData *wod = walkOffPointForObject(k + cmd->noun2);
@@ -1954,7 +1956,7 @@ const char* Logic::objectOrItemName(int16 obj) const {
Verb Logic::findVerbUnderCursor(int16 cursorx, int16 cursory) const {
- return PANEL_VERBS[zoneIn(ZONE_PANEL, cursorx, cursory)];
+ return Verb(PANEL_VERBS[zoneIn(ZONE_PANEL, cursorx, cursory)]);
}
@@ -1992,19 +1994,6 @@ uint16 Logic::findObjectGlobalNumber(uint16 zoneNum) const {
}
-const char *Logic::verbName(Verb v) const {
-
- // FIXME: rewrite this test with future VerbCommand methods
- if (v != VERB_NONE && v < 13) {
- return _verbName[v];
- }
- else {
- error("Logic::verbName() - Invalid verb %d", v);
- return NULL;
- }
-}
-
-
void Logic::update() {
_graphics->update(_currentRoom);
_input->delay();
diff --git a/queen/logic.h b/queen/logic.h
index c0044afa87..2b210ca00d 100644
--- a/queen/logic.h
+++ b/queen/logic.h
@@ -25,6 +25,7 @@
#include "queen/queen.h"
#include "queen/defs.h"
#include "queen/structs.h"
+#include "queen/verb.h"
namespace Queen {
@@ -271,7 +272,6 @@ public:
uint16 findObjectRoomNumber(uint16 zoneNum) const;
uint16 findObjectGlobalNumber(uint16 zoneNum) const;
- const char *verbName(Verb v) const;
const char *lockedVerbPrefix() const { return _joeResponse[39]; }
void update();
@@ -361,8 +361,6 @@ protected:
//! 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
//! Actor animation string
@@ -414,7 +412,7 @@ protected:
Walk *_walk;
//! Verbs (in order) available in panel
- static const Verb PANEL_VERBS[];
+ static const VerbEnum PANEL_VERBS[];
};
} // End of namespace Queen
diff --git a/queen/structs.h b/queen/structs.h
index 39f8c991b7..14e9ba8072 100644
--- a/queen/structs.h
+++ b/queen/structs.h
@@ -24,6 +24,8 @@
namespace Queen {
+#include "queen/verb.h"
+
struct Box {
int16 x1, y1, x2, y2;
@@ -365,7 +367,7 @@ struct CmdListData {
int16 specialSection;
void readFrom(byte *&ptr) {
- verb = (Verb)READ_BE_UINT16(ptr); ptr += 2;
+ verb = Verb((VerbEnum)READ_BE_UINT16(ptr)); ptr += 2;
nounObj1 = (int16)READ_BE_UINT16(ptr); ptr += 2;
nounObj2 = (int16)READ_BE_UINT16(ptr); ptr += 2;
song = (int16)READ_BE_UINT16(ptr); ptr += 2;
@@ -377,7 +379,7 @@ struct CmdListData {
specialSection = (int16)READ_BE_UINT16(ptr); ptr += 2;
}
- bool match(Verb v, int16 obj1, int16 obj2) const {
+ bool match(const Verb& v, int16 obj1, int16 obj2) const {
return verb == v && nounObj1 == obj1 && nounObj2 == obj2;
}
};
diff --git a/queen/talk.cpp b/queen/talk.cpp
index f38f1b56ed..c2d771c93c 100644
--- a/queen/talk.cpp
+++ b/queen/talk.cpp
@@ -810,7 +810,7 @@ void Talk::defaultAnimation(
}
// Skip through text more quickly
- if (_input->verbSkipText()) {
+ if (_input->keyVerb().isSkipText()) {
_input->clearKeyVerb();
break;
}
diff --git a/queen/verb.h b/queen/verb.h
new file mode 100644
index 0000000000..351e9df14b
--- /dev/null
+++ b/queen/verb.h
@@ -0,0 +1,145 @@
+
+/* 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 QUEENVERB_H
+#define QUEENVERB_H
+
+
+enum VerbEnum {
+ VERB_NONE = 0,
+
+ VERB_PANEL_COMMAND_FIRST = 1,
+ VERB_OPEN = 1,
+ VERB_CLOSE = 2,
+ VERB_MOVE = 3,
+ // no verb 4
+ VERB_GIVE = 5,
+ VERB_USE = 6,
+ VERB_PICK_UP = 7,
+ VERB_LOOK_AT = 9,
+ VERB_TALK_TO = 8,
+ VERB_PANEL_COMMAND_LAST = 9,
+
+ VERB_WALK_TO = 10,
+ VERB_SCROLL_UP = 11,
+ VERB_SCROLL_DOWN = 12,
+
+ VERB_DIGIT_FIRST = 13,
+ VERB_DIGIT_1 = 13,
+ VERB_DIGIT_2 = 14,
+ VERB_DIGIT_3 = 15,
+ VERB_DIGIT_4 = 16,
+ VERB_DIGIT_LAST = 16,
+
+ VERB_INV_FIRST = VERB_DIGIT_FIRST,
+ VERB_INV_1 = VERB_DIGIT_1,
+ VERB_INV_2 = VERB_DIGIT_2,
+ VERB_INV_3 = VERB_DIGIT_3,
+ VERB_INV_4 = VERB_DIGIT_4,
+ VERB_INV_LAST = VERB_DIGIT_LAST,
+
+ VERB_USE_JOURNAL = 20,
+ VERB_SKIP_TEXT = 101,
+
+ VERB_PREP_WITH = 11,
+ VERB_PREP_TO = 12
+};
+
+
+class Verb {
+public:
+
+ Verb() {
+ _verb = VERB_NONE;
+ }
+
+ Verb(VerbEnum v) {
+ _verb = v;
+ }
+
+ //! _verb is open/close/move/give/look at/pick up/talk to
+ bool isPanelCommand() const {
+ return
+ _verb >= VERB_PANEL_COMMAND_FIRST &&
+ _verb <= VERB_PANEL_COMMAND_LAST;
+ }
+
+ bool isScrollInventory() const {
+ return
+ _verb == VERB_SCROLL_UP ||
+ _verb == VERB_SCROLL_DOWN;
+ }
+
+ bool isInventory() const {
+ return
+ _verb >= VERB_INV_FIRST &&
+ _verb <= VERB_INV_LAST;
+ }
+
+ bool isJournal() const {
+ return _verb == VERB_USE_JOURNAL;
+ }
+
+ bool isTwoLevelsCommand() const {
+ return
+ _verb == VERB_GIVE ||
+ _verb == VERB_USE;
+ }
+
+ bool isDigit() const {
+ return
+ _verb >= VERB_DIGIT_FIRST &&
+ _verb <= VERB_DIGIT_LAST;
+ }
+
+ bool isSkipText() const {
+ return _verb == VERB_SKIP_TEXT;
+ }
+
+ VerbEnum value() const {
+ return _verb;
+ }
+
+ const char* name() const {
+ if (_verb > 0 && _verb < 13) {
+ _verbName[_verb];
+ }
+ return NULL;
+ }
+
+ bool operator==(const Verb& other) const {
+ return _verb == other._verb;
+ }
+
+ static void initName(int i, char* name) {
+ _verbName[i] = name;
+ }
+
+private:
+
+ VerbEnum _verb;
+
+ static char* _verbName[13];
+};
+
+
+#endif
diff --git a/queen/xref.txt b/queen/xref.txt
index b051bdd603..0a6459489c 100644
--- a/queen/xref.txt
+++ b/queen/xref.txt
@@ -256,7 +256,7 @@ OLDROOM,ROOM,NEW_ROOM Logic::_*oom
ROOMTOT Logic::_numRooms
ROOM_DATA Logic::_roomData
ROOM_NAMEstr Logic::_roomName
-VERB_NAMEstr Logic::_verbName
+VERB_NAMEstr Verb::_verbName
WALK_OFF_DATA Logic::_walkOffData
WALK_OFF_MAX Logic::_numWalkOffs