1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
|
/* 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 QUEENLOGIC_H
#define QUEENLOGIC_H
#include "common/util.h"
#include "queen/defs.h"
#include "queen/structs.h"
namespace Queen {
enum RoomDisplayMode {
RDM_FADE_NOJOE = 0, // fade in, no Joe
RDM_FADE_JOE = 1, // Joe is to be displayed
RDM_NOFADE_JOE = 2, // screen does not dissolve into view
RDM_FADE_JOE_XY = 3 // display Joe at the current X, Y coords
};
enum {
ZONE_ROOM = 0,
ZONE_PANEL = 1
};
enum JoeWalkMode {
JWM_NORMAL = 0,
JWM_MOVE = 1,
JWM_EXECUTE = 2,
JWM_SPEAK = 3
};
struct ZoneSlot {
bool valid;
Box box;
};
class Debug;
class QueenEngine;
class Logic {
public:
Logic(QueenEngine *vm);
~Logic();
uint16 currentRoom() const { return _currentRoom; }
void currentRoom(uint16 room) {
if (room >= 1 && room <= _numRooms)
_currentRoom = room;
else
error("Invalid room number: %i", room);
}
uint16 oldRoom() const { return _oldRoom; }
void oldRoom(uint16 room) {
if (room <= _numRooms)
_oldRoom = room;
else
error("Invalid room number: %i", room);
}
uint16 newRoom() const { return _newRoom; }
void newRoom(uint16 room) {
if (room <= _numRooms)
_newRoom = room;
else
error("Invalid room number: %i", room);
}
ObjectData *objectData(int index) const;
uint16 roomData(int room) const;
uint16 objMax(int room) const;
GraphicData *graphicData(int index) const;
ItemData *itemData(int index) const { return &_itemData[index]; }
uint16 itemDataCount() const { return _numItems; }
uint16 findBob(uint16 obj);
uint16 findFrame(uint16 obj);
uint16 objectForPerson(uint16 bobnum) const; // OBJ_PERSON
WalkOffData *walkOffPointForObject(uint16 obj) const;
Area *area(int room, int num) const;
Area *currentRoomArea(int num) const;
uint16 areaMax(int room) const;
uint16 currentRoomAreaMax() const;
uint16 walkOffCount() const;
WalkOffData *walkOffData(int index) const;
uint16 currentRoomObjMax() const { return _objMax[_currentRoom]; }
uint16 currentRoomData() const { return _roomData[_currentRoom]; }
ObjectDescription *objectDescription(uint16 objNum) const { return &_objectDescription[objNum]; }
uint16 objectDescriptionCount() const { return _numObjDesc; }
uint16 joeFacing() const { return _joe.facing; }
uint16 joeX() const { return _joe.x; }
uint16 joeY() const { return _joe.y; }
JoeWalkMode joeWalk() const { return _joe.walk; }
uint16 joeScale() const { return _joe.scale; }
uint16 joeCutFacing() const { return _joe.cutFacing; }
uint16 joePrevFacing() const { return _joe.prevFacing; }
void joeFacing(uint16 dir);
void joeX(uint16 x);
void joeY(uint16 y);
void joeWalk(JoeWalkMode walking);
void joeScale(uint16 scale);
void joeCutFacing(uint16 dir);
void joePrevFacing(uint16 dir);
const char *joeResponse(int i) const { return _joeResponse[i]; }
const char *verbName(Verb v) const { return _verbName[v]; }
int16 gameState(int index);
void gameState(int index, int16 newValue);
TalkSelected *talkSelected(int index) { return _talkSelected + index; }
const char *roomName(uint16 roomNum) const {
if (roomNum >= 1 && roomNum <= _numRooms)
return _roomName[roomNum];
else
error("Invalid room number: %i", roomNum);
}
const char *objectName(uint16 objNum) const { return _objName[objNum]; }
const char *objectTextualDescription(uint16 objNum) const { return _objDescription[objNum]; }
void zoneSet(uint16 screen, uint16 zone, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
void zoneSet(uint16 screen, uint16 zone, const Box& box);
uint16 zoneIn(uint16 screen, uint16 x, uint16 y) const;
uint16 zoneInArea(uint16 screen, uint16 x, uint16 y) const;
void zoneClearAll(uint16 screen);
void zoneSetup();
void zoneSetupPanel();
Box &zoneBox(uint16 screen, uint16 index) { return _zones[screen][index].box; }
void roomErase();
void roomSetupFurniture(); // SETUP_FURNITURE()
void roomSetupObjects(); // DISP_OBJECTS
uint16 roomRefreshObject(uint16 obj); // REDISP_OBJECT
void roomSetup(const char *room, int comPanel, bool inCutaway);
void roomDisplay(uint16 room, RoomDisplayMode mode, uint16 joeScale, int comPanel, bool inCutaway); // DISP_ROOM
uint16 findScale(uint16 x, uint16 y);
int16 entryObj() const { return _entryObj; }
void entryObj(int16 obj) { _entryObj = obj; }
uint16 numFrames() const { return _numFrames; }
void personSetData(int16 noun, const char *actorName, bool loadBank, Person *pp); // SET_PERSON_DATA
uint16 personSetup(uint16 noun, uint16 curImage); // SETUP_PERSON
uint16 personAllocate(uint16 noun, uint16 curImage); // ALLOCATE_PERSON
uint16 personFrames(uint16 bobNum) const { return _personFrames[bobNum]; }
uint16 animCreate(uint16 curImage, const Person *person); // CREATE_ANIM
void animErase(uint16 bobNum);
void animReset(uint16 bobNum);
void animSetup(const GraphicData *gd, uint16 firstImage, uint16 bobNum, bool visible); // FIND_GRAPHIC_ANIMS
void joeSetupFromBanks(const char *animBank, const char *standBank);
//! Load the various bobs needed to animate Joe
void joeSetup();
//! Setup Joe at the right place when entering a room
ObjectData *joeSetupInRoom(bool autoPosition, uint16 scale);
uint16 joeFace();
void joeGrab(int16 grabState);
void joeUseDress(bool showCut);
void joeUseClothes(bool showCut);
void joeUseUnderwear();
void joeSpeak(uint16 descNum, bool objectType = false);
void makePersonSpeak(const char *sentence, Person *person, const char *voiceFilePrefix);
void dialogue(const char *dlgFile, int personInRoom, char *cutaway);
void playCutaway(const char *cutFile, char *next = NULL);
Verb findVerbUnderCursor(int16 cursorx, int16 cursory) const;
uint16 findObjectUnderCursor(int16 cursorx, int16 cursory) const;
uint16 findObjectNumber(uint16 zoneNum) const;
void inventorySetup();
uint16 findInventoryItem(int invSlot) const;
void inventoryRefresh();
int16 previousInventoryItem(int16 start) const;
int16 nextInventoryItem(int16 start) const;
void removeDuplicateItems();
uint16 numItemsInventory() const;
void inventoryInsertItem(uint16 itemNum, bool refresh = true);
void inventoryDeleteItem(uint16 itemNum, bool refresh = true);
void inventoryScroll(uint16 count, bool up);
//! Copy data from dummy object to object
void objectCopy(int dummyObjectIndex, int objectIndex);
void checkPlayer();
void customMoveJoe(int facing, uint16 areaNum, uint16 walkDataNum);
void handlePinnacleRoom();
void update();
bool gameSave(uint16 slot, const char *desc);
bool gameLoad(uint16 slot);
//! Ugly hack from original code
void sceneReset() { _scene = 0; }
//! Make a scene
void sceneStart();
//! Stop making a scene
void sceneStop();
void changeRoom();
void useJournal();
int talkSpeed() const { return _talkSpeed; }
void talkSpeed(int speed) { _talkSpeed = speed; }
bool subtitles() const { return _subtitles; }
void subtitles(bool enable) { _subtitles = enable; }
void registerDefaultSettings();
void checkOptionSettings();
void readOptionSettings();
void writeOptionSettings();
void executeSpecialMove(uint16 sm);
void asmMakeJoeUseDress();
void asmMakeJoeUseNormalClothes();
void asmMakeJoeUseUnderwear();
void asmSwitchToDressPalette();
void asmSwitchToNormalPalette();
void asmStartCarAnimation();
void asmStopCarAnimation();
void asmStartFightAnimation();
void asmWaitForFrankPosition();
void asmMakeFrankGrowing();
void asmMakeRobotGrowing();
void asmShrinkRobot();
void asmEndGame();
void asmPutCameraOnDino();
void asmPutCameraOnJoe();
void asmSetAzuraInLove();
void asmPanRightFromJoe();
void asmSetLightsOff();
void asmSetLightsOn();
void asmSetManequinAreaOn();
void asmPanToJoe();
void asmTurnGuardOn();
void asmPanLeft320To144();
void asmSmooch();
void asmMakeLightningHitPlane();
void asmScaleBlimp();
void asmScaleEnding();
void asmWaitForCarPosition();
void asmShakeScreen();
void asmAttemptPuzzle();
void asmScaleTitle();
void asmPanRightToHugh();
void asmMakeWhiteFlash();
void asmPanRightToJoeAndRita();
void asmPanLeftToBomb();
typedef void (Logic::*SpecialMoveProc)();
enum {
MAX_ZONES_NUMBER = 32,
MAX_AREAS_NUMBER = 11,
JOE_RESPONSE_MAX = 40,
DEFAULT_TALK_SPEED = 7 * 3,
GAME_STATE_COUNT = 211,
TALK_SELECTED_COUNT = 86
};
protected:
void initialise();
uint16 _currentRoom;
uint16 _oldRoom;
uint16 _newRoom;
//! Total number of room in game
uint16 _numRooms;
//! First object number in room
uint16 *_roomData;
//! Background music to play in room
uint16 *_sfxName;
//! Number of objects in room
int16 *_objMax;
//! Bounding box of object
Box *_objectBox;
//! Inventory items
ItemData *_itemData;
uint16 _numItems;
GraphicData *_graphicData;
uint16 _numGraphics;
ObjectData *_objectData;
uint16 _numObjects;
ObjectDescription *_objectDescription;
uint16 _numObjDesc;
ActorData *_actorData;
uint16 _numActors; //ACTOR_DATA_MAX
//! Areas in room
Area (*_area)[MAX_AREAS_NUMBER];
//! Number of areas in room
int16 *_areaMax;
//! Walk off point for an object
WalkOffData *_walkOffData;
uint16 _numWalkOffs;
FurnitureData *_furnitureData;
uint16 _numFurniture; //FURN_DATA_MAX
GraphicAnim *_graphicAnim;
uint16 _numGraphicAnim; //GRAPHIC_ANIM_MAX
//! Current areas in room
ZoneSlot _zones[2][MAX_ZONES_NUMBER];
//! Actor position in room is _walkOffData[_entryObj]
int16 _entryObj;
//! Object description (Look At)
char **_objDescription; //OBJECT_DESCRstr
uint16 _numDescriptions;
char **_objName; //OBJECT_NAMEstr
uint16 _numNames;
//! Room name, prefix for data files (PCX, LUM...)
char **_roomName; //ROOM_NAMEstr
char *_verbName[13];
char *_joeResponse[JOE_RESPONSE_MAX + 1]; //JOE_RESPstr
//! Actor animation string
char **_aAnim;
uint16 _numAAnim; //A_ANIM_MAX
//! Actor name
char **_aName;
uint16 _numAName; //A_NAME_MAX
//! Actor filename
char **_aFile;
uint16 _numAFile; //A_FILE_MAX
struct {
uint16 x, y;
uint16 facing, cutFacing, prevFacing;
JoeWalkMode walk;
uint16 scale;
} _joe;
int16 _gameState[GAME_STATE_COUNT];
TalkSelected _talkSelected[TALK_SELECTED_COUNT];
//! Number of animated furniture in current room (FMAXA)
uint16 _numFurnitureAnimated;
//! Number of static furniture in current room (FMAX)
uint16 _numFurnitureStatic;
//! Total number of frames for the animated furniture (FMAXLEN)
uint16 _numFurnitureAnimatedLen;
//! Current number of frames unpacked (FRAMES)
uint16 _numFrames;
//! Last frame number used for person animation
uint16 _personFrames[4];
//! Describe a string based animation (30 frames maximum, bob number must be < 17)
AnimFrame _newAnim[17][30];
//! Inventory items
int16 _inventoryItem[4];
//! scene counter
int _scene;
int _talkSpeed;
bool _subtitles;
Debug *_dbg;
QueenEngine *_vm;
};
} // End of namespace Queen
#endif
|