ScummVM API documentation
logic.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef QUEEN_LOGIC_H
23 #define QUEEN_LOGIC_H
24 
25 #include "common/str-array.h"
26 #include "common/util.h"
27 #include "queen/structs.h"
28 
29 namespace Queen {
30 
31 enum RoomDisplayMode {
32  RDM_FADE_NOJOE = 0, // fade in, hide Joe
33  RDM_FADE_JOE = 1, // fade in, display Joe
34  RDM_NOFADE_JOE = 2, // screen does not dissolve into view
35  RDM_FADE_JOE_XY = 3 // display Joe at the current X, Y coords
36 };
37 
38 enum JoeWalkMode {
39  JWM_NORMAL = 0,
40  JWM_MOVE = 1,
41  JWM_EXECUTE = 2,
42  JWM_SPEAK = 3
43 };
44 
45 enum {
46  JSO_OBJECT_DESCRIPTION = 0,
47  JSO_OBJECT_NAME,
48  JSO_ROOM_NAME,
49  JSO_VERB_NAME,
50  JSO_JOE_RESPONSE,
51  JSO_ACTOR_ANIM,
52  JSO_ACTOR_NAME,
53  JSO_ACTOR_FILE,
54  JSO_COUNT
55 };
56 
57 class Credits;
58 class Journal;
59 class QueenEngine;
60 
61 class Logic {
62 public:
63 
64  Logic(QueenEngine *vm);
65  virtual ~Logic();
66 
67  uint16 currentRoom() const { return _currentRoom; }
68  void currentRoom(uint16 room) {
69  assert(room >= 1 && room <= _numRooms);
70  _currentRoom = room;
71  }
72 
73  uint16 oldRoom() const { return _oldRoom; }
74  void oldRoom(uint16 room) {
75  assert(room <= _numRooms);
76  _oldRoom = room;
77  }
78 
79  uint16 newRoom() const { return _newRoom; }
80  void newRoom(uint16 room) {
81  assert(room <= _numRooms);
82  _newRoom = room;
83  }
84 
85  ObjectData *objectData(int index) const { return &_objectData[index]; }
86  uint16 roomData(int room) const { return _roomData[room]; }
87  GraphicData *graphicData(int index) const { return &_graphicData[index]; }
88  ItemData *itemData(int index) const { return &_itemData[index]; }
89  uint16 itemDataCount() const { return _numItems; }
90 
91  uint16 findBob(uint16 obj) const;
92  uint16 findFrame(uint16 obj) const;
93  uint16 objectForPerson(uint16 bobnum) const;
94  WalkOffData *walkOffPointForObject(int16 obj) const;
95 
96  uint16 walkOffCount() const { return _numWalkOffs; }
97  WalkOffData *walkOffData(int index) const { return &_walkOffData[index]; }
98  uint16 currentRoomData() const { return _roomData[_currentRoom]; }
99  GraphicAnim *graphicAnim(int index) const { return &_graphicAnim[index]; }
100  uint16 graphicAnimCount() const { return _numGraphicAnim; }
101  ObjectDescription *objectDescription(uint16 objNum) const { return &_objectDescription[objNum]; }
102  uint16 objectDescriptionCount() const { return _numObjDesc; }
103  uint16 currentRoomSfx() const { return _sfxName[_currentRoom]; }
104 
105  uint16 joeFacing() const { return _joe.facing; }
106  uint16 joeX() const { return _joe.x; }
107  uint16 joeY() const { return _joe.y; }
108  JoeWalkMode joeWalk() const { return _joe.walk; }
109  uint16 joeScale() const { return _joe.scale; }
110  uint16 joeCutFacing() const { return _joe.cutFacing; }
111  uint16 joePrevFacing() const { return _joe.prevFacing; }
112 
113  void joeFacing(uint16 dir) { _joe.facing = dir; }
114  void joePos(uint16 x, uint16 y) { _joe.x = x; _joe.y = y; }
115  void joeWalk(JoeWalkMode walking);
116  void joeScale(uint16 scale) { _joe.scale = scale; }
117  void joeCutFacing(uint16 dir) { _joe.cutFacing = dir; }
118  void joePrevFacing(uint16 dir) { _joe.prevFacing = dir; }
119 
120  int16 gameState(int index) const;
121  void gameState(int index, int16 newValue);
122 
123  TalkSelected *talkSelected(int index) { return &_talkSelected[index]; }
124 
125  const char *roomName(uint16 roomNum) const;
126  const char *objectName(uint16 objNum) const;
127  const char *objectTextualDescription(uint16 objNum) const;
128  const char *joeResponse(int i) const;
129  const char *verbName(Verb v) const;
130  const char *actorAnim(int num) const;
131  const char *actorName(int num) const;
132  const char *actorFile(int num) const;
133 
134  void eraseRoom();
135  void setupRoom(const char *room, int comPanel, bool inCutaway);
136  void displayRoom(uint16 room, RoomDisplayMode mode, uint16 joeScale, int comPanel, bool inCutaway);
137 
138  int16 entryObj() const { return _entryObj; }
139  void entryObj(int16 obj) { _entryObj = obj; }
140 
141  ActorData *findActor(uint16 noun, const char *name = NULL) const;
142  bool initPerson(uint16 noun, const char *actorName, bool loadBank, Person *pp);
143  uint16 findPersonNumber(uint16 obj, uint16 room) const;
144 
146  void loadJoeBanks(const char *animBank, const char *standBank);
147 
149  void setupJoe();
150 
152  void setupJoeInRoom(bool autoPosition, uint16 scale);
153 
154  uint16 joeFace();
155  void joeGrab(int16 grabState);
156 
158  void joeUseDress(bool showCut);
159 
161  void joeUseClothes(bool showCut);
162 
164  void joeUseUnderwear();
165 
166  void makeJoeSpeak(uint16 descNum, bool objectType = false);
167  void makePersonSpeak(const char *sentence, Person *person, const char *voiceFilePrefix);
168 
170  void startDialogue(const char *dlgFile, int personInRoom, char *cutaway);
171 
173  void playCutaway(const char *cutFile, char *next = NULL);
174 
176  void inventorySetup();
177 
179  uint16 findInventoryItem(int invSlot) const;
180 
182  void inventoryRefresh();
183  int16 previousInventoryItem(int16 first) const;
184  int16 nextInventoryItem(int16 first) const;
185  void removeDuplicateItems();
186  uint16 numItemsInventory() const;
187  void inventoryInsertItem(uint16 itemNum, bool refresh = true);
188  void inventoryDeleteItem(uint16 itemNum, bool refresh = true);
189  void inventoryScroll(uint16 count, bool up);
190  void removeHotelItemsFromInventory();
191 
193  void objectCopy(int dummyObjectIndex, int objectIndex);
194 
196  void handleSpecialArea(Direction facing, uint16 areaNum, uint16 walkDataNum);
197 
199  void handlePinnacleRoom();
200 
201  void update();
202 
203  void saveState(byte *&ptr);
204  void loadState(uint32 ver, byte *&ptr);
205 
207  void setupRestoredGame();
208 
210  void sceneReset() { _scene = 0; }
211 
213  void sceneStart();
214 
216  void sceneStop();
217 
218  void changeRoom();
219 
221  virtual void useJournal() = 0;
222 
224  void executeSpecialMove(uint16 sm);
225 
226  void startCredits(const char *filename);
227  void stopCredits();
228 
229  void start();
230 
231  enum {
232  JOE_RESPONSE_MAX = 40,
233  DEFAULT_TALK_SPEED = 7 * 3,
234  GAME_STATE_COUNT = 211,
235  TALK_SELECTED_COUNT = 86
236  };
237 
238  typedef void (Logic::*SpecialMoveProc)();
239 
240 protected:
241 
242  void readQueenJas();
243 
244  void asmMakeJoeUseDress();
245  void asmMakeJoeUseNormalClothes();
246  void asmMakeJoeUseUnderwear();
247  void asmSwitchToDressPalette();
248  void asmSwitchToNormalPalette();
249  void asmStartCarAnimation();
250  void asmStopCarAnimation();
251  void asmStartFightAnimation();
252  void asmWaitForFrankPosition();
253  void asmMakeFrankGrowing();
254  void asmMakeRobotGrowing();
255  void asmShrinkRobot();
256  void asmEndGame();
257  void asmPutCameraOnDino();
258  void asmPutCameraOnJoe();
259  void asmAltIntroPanRight();
260  void asmAltIntroPanLeft();
261  void asmSetAzuraInLove();
262  void asmPanRightFromJoe();
263  void asmSetLightsOff();
264  void asmSetLightsOn();
265  void asmSetManequinAreaOn();
266  void asmPanToJoe();
267  void asmTurnGuardOn();
268  void asmPanLeft320To144();
269  void asmSmooch();
270  void asmSmoochNoScroll();
271  void asmMakeLightningHitPlane();
272  void asmScaleBlimp();
273  void asmScaleEnding();
274  void asmWaitForCarPosition();
275  void asmShakeScreen();
276  void asmAttemptPuzzle();
277  void asmScaleTitle();
278  void asmScrollTitle();
279  void asmPanRightToHugh();
280  void asmMakeWhiteFlash();
281  void asmPanRightToJoeAndRita();
282  void asmPanLeftToBomb();
283  void asmEndDemo();
284  void asmInterviewIntro();
285  void asmEndInterview();
286 
287  virtual bool changeToSpecialRoom() = 0;
288  virtual void setupSpecialMoveTable() = 0;
289 
290 
291  uint16 _currentRoom;
292  uint16 _oldRoom;
293  uint16 _newRoom;
294 
296  uint16 _numRooms;
297 
299  uint16 *_roomData;
300 
302  uint16 *_sfxName;
303 
306 
309  uint16 _numItems;
310 
311  GraphicData *_graphicData;
312  uint16 _numGraphics;
313 
314  ObjectData *_objectData;
315  uint16 _numObjects;
316 
317  ObjectDescription *_objectDescription;
318  uint16 _numObjDesc;
319 
320  ActorData *_actorData;
321  uint16 _numActors;
322 
325  uint16 _numWalkOffs;
326 
327  FurnitureData *_furnitureData;
328  uint16 _numFurniture;
329 
330  GraphicAnim *_graphicAnim;
331  uint16 _numGraphicAnim;
332 
334  int16 _entryObj;
335 
336  Common::StringArray _jasStringList;
337  int _jasStringOffset[JSO_COUNT];
338 
339  uint16 _numDescriptions;
340  uint16 _numNames;
341  uint16 _numAAnim;
342  uint16 _numAName;
343  uint16 _numAFile;
344 
345  struct {
346  uint16 x, y;
347  uint16 facing, cutFacing, prevFacing;
348  JoeWalkMode walk;
349  uint16 scale;
350  } _joe;
351 
352  int16 _gameState[GAME_STATE_COUNT];
353 
354  TalkSelected _talkSelected[TALK_SELECTED_COUNT];
355 
357  int16 _inventoryItem[4];
358 
361 
363  int _scene;
364 
365  SpecialMoveProc _specialMoves[40];
366 
367  Credits *_credits;
368  Journal *_journal;
369 
370  QueenEngine *_vm;
371 };
372 
373 class LogicDemo : public Logic {
374 public:
375 
376  LogicDemo(QueenEngine *vm) : Logic(vm) {}
377  void useJournal() override;
378 
379 protected:
380 
381  bool changeToSpecialRoom() override;
382  void setupSpecialMoveTable() override;
383 };
384 
385 class LogicInterview : public Logic {
386 public:
387 
388  LogicInterview(QueenEngine *vm) : Logic(vm) {}
389  void useJournal() override;
390 
391 protected:
392 
393  bool changeToSpecialRoom() override;
394  void setupSpecialMoveTable() override;
395 };
396 
397 class LogicGame : public Logic {
398 public:
399 
400  LogicGame(QueenEngine *vm) : Logic(vm) {}
401  void useJournal() override;
402 
403 protected:
404 
405  bool changeToSpecialRoom() override;
406  void setupSpecialMoveTable() override;
407 };
408 
409 
410 } // End of namespace Queen
411 
412 #endif
Definition: structs.h:543
uint8 _puzzleAttemptCount
puzzle counter for room T7
Definition: logic.h:360
WalkOffData * _walkOffData
walk off point for an object
Definition: logic.h:324
Definition: structs.h:30
Definition: queen.h:62
void handleSpecialArea(Direction facing, uint16 areaNum, uint16 walkDataNum)
handle a particular event when Joe walks on this area
uint16 _numRooms
total number of room in game
Definition: logic.h:296
Definition: credits.h:33
void sceneReset()
ugly hack from original code
Definition: logic.h:210
Definition: structs.h:524
Definition: journal.h:33
int16 _inventoryItem[4]
inventory items
Definition: logic.h:357
Box * _objectBox
bounding box of object
Definition: logic.h:305
Definition: structs.h:345
Definition: structs.h:265
Definition: logic.h:397
Definition: bankman.h:28
virtual void useJournal()=0
enter the Journal (save/load, configuration)
void setupRestoredGame()
called after a save state has been loaded
Definition: structs.h:495
Definition: logic.h:61
void objectCopy(int dummyObjectIndex, int objectIndex)
copy data from dummy object to object
void playCutaway(const char *cutFile, char *next=NULL)
play the specified cutaway
int16 _entryObj
actor initial position in room is _walkOffData[_entryObj]
Definition: logic.h:334
void joeUseDress(bool showCut)
change Joe clothes to dress
Definition: logic.h:385
Definition: structs.h:315
void joeUseClothes(bool showCut)
restore Joe clothes
uint16 * _sfxName
background music to play in room
Definition: logic.h:302
void joeUseUnderwear()
change Joe clothes to underwear
void setupJoe()
load the various bobs needed to animate Joe
Definition: structs.h:147
Definition: structs.h:127
uint16 * _roomData
first object number in room
Definition: logic.h:299
ItemData * _itemData
inventory items
Definition: logic.h:308
void inventoryRefresh()
refresh inventory contents
void executeSpecialMove(uint16 sm)
execute a special move
void startDialogue(const char *dlgFile, int personInRoom, char *cutaway)
start the specified dialogue
void handlePinnacleRoom()
handle the pinnacle room (== room chooser in the jungle)
void inventorySetup()
initialize the inventory
Definition: structs.h:555
void sceneStop()
stop making a scene
Definition: structs.h:185
void setupJoeInRoom(bool autoPosition, uint16 scale)
setup Joe at the right place when entering a room
void loadJoeBanks(const char *animBank, const char *standBank)
load banks used for Joe animation
void sceneStart()
make a scene
int _scene
cutscene counter
Definition: logic.h:363
uint16 findInventoryItem(int invSlot) const
get the inventory item for the specified inventory slot
Definition: logic.h:373