scummvm/engines/queen/logic.h

414 lines
10 KiB
C
Raw Normal View History

/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
2003-09-28 15:50:47 +00:00
*
* 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.
*
2003-09-28 15:50:47 +00:00
* 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
2003-09-28 15:50:47 +00:00
* GNU General Public License for more details.
*
2003-09-28 15:50:47 +00:00
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2003-09-28 15:50:47 +00:00
*
*/
2006-11-12 17:47:16 +00:00
#ifndef QUEEN_LOGIC_H
#define QUEEN_LOGIC_H
2003-09-28 15:50:47 +00:00
#include "common/str-array.h"
2003-12-01 20:48:41 +00:00
#include "common/util.h"
#include "queen/structs.h"
2003-09-28 15:50:47 +00:00
2003-10-03 19:47:41 +00:00
namespace Queen {
enum RoomDisplayMode {
RDM_FADE_NOJOE = 0, // fade in, hide Joe
RDM_FADE_JOE = 1, // fade in, display Joe
RDM_NOFADE_JOE = 2, // screen does not dissolve into view
RDM_FADE_JOE_XY = 3 // display Joe at the current X, Y coords
};
2003-12-11 10:24:27 +00:00
enum JoeWalkMode {
JWM_NORMAL = 0,
JWM_MOVE = 1,
JWM_EXECUTE = 2,
JWM_SPEAK = 3
};
enum {
JSO_OBJECT_DESCRIPTION = 0,
JSO_OBJECT_NAME,
JSO_ROOM_NAME,
JSO_VERB_NAME,
JSO_JOE_RESPONSE,
JSO_ACTOR_ANIM,
JSO_ACTOR_NAME,
JSO_ACTOR_FILE,
JSO_COUNT
};
2004-01-05 11:58:20 +00:00
class Credits;
class Journal;
class QueenEngine;
2003-10-09 09:09:40 +00:00
class Logic {
2003-09-28 15:50:47 +00:00
public:
2003-12-11 22:16:35 +00:00
Logic(QueenEngine *vm);
virtual ~Logic();
2003-10-24 08:55:13 +00:00
uint16 currentRoom() const { return _currentRoom; }
void currentRoom(uint16 room) {
assert(room >= 1 && room <= _numRooms);
_currentRoom = room;
}
2003-11-08 23:45:45 +00:00
2003-10-24 08:55:13 +00:00
uint16 oldRoom() const { return _oldRoom; }
void oldRoom(uint16 room) {
assert(room <= _numRooms);
_oldRoom = room;
}
2003-11-08 23:45:45 +00:00
2003-10-24 08:55:13 +00:00
uint16 newRoom() const { return _newRoom; }
void newRoom(uint16 room) {
assert(room <= _numRooms);
_newRoom = room;
}
ObjectData *objectData(int index) const { return &_objectData[index]; }
uint16 roomData(int room) const { return _roomData[room]; }
GraphicData *graphicData(int index) const { return &_graphicData[index]; }
ItemData *itemData(int index) const { return &_itemData[index]; }
uint16 itemDataCount() const { return _numItems; }
uint16 findBob(uint16 obj) const;
uint16 findFrame(uint16 obj) const;
uint16 objectForPerson(uint16 bobnum) const;
WalkOffData *walkOffPointForObject(int16 obj) const;
2003-09-28 15:50:47 +00:00
uint16 walkOffCount() const { return _numWalkOffs; }
WalkOffData *walkOffData(int index) const { return &_walkOffData[index]; }
uint16 currentRoomData() const { return _roomData[_currentRoom]; }
GraphicAnim *graphicAnim(int index) const { return &_graphicAnim[index]; }
uint16 graphicAnimCount() const { return _numGraphicAnim; }
ObjectDescription *objectDescription(uint16 objNum) const { return &_objectDescription[objNum]; }
2003-10-31 13:47:28 +00:00
uint16 objectDescriptionCount() const { return _numObjDesc; }
uint16 currentRoomSfx() const { return _sfxName[_currentRoom]; }
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) { _joe.facing = dir; }
void joePos(uint16 x, uint16 y) { _joe.x = x; _joe.y = y; }
void joeWalk(JoeWalkMode walking);
void joeScale(uint16 scale) { _joe.scale = scale; }
void joeCutFacing(uint16 dir) { _joe.cutFacing = dir; }
void joePrevFacing(uint16 dir) { _joe.prevFacing = dir; }
int16 gameState(int index) const;
void gameState(int index, int16 newValue);
TalkSelected *talkSelected(int index) { return &_talkSelected[index]; }
const char *roomName(uint16 roomNum) const;
const char *objectName(uint16 objNum) const;
const char *objectTextualDescription(uint16 objNum) const;
const char *joeResponse(int i) const;
const char *verbName(Verb v) const;
const char *actorAnim(int num) const;
const char *actorName(int num) const;
const char *actorFile(int num) const;
void eraseRoom();
void setupRoom(const char *room, int comPanel, bool inCutaway);
void displayRoom(uint16 room, RoomDisplayMode mode, uint16 joeScale, int comPanel, bool inCutaway);
int16 entryObj() const { return _entryObj; }
void entryObj(int16 obj) { _entryObj = obj; }
ActorData *findActor(uint16 noun, const char *name = NULL) const;
2004-01-11 14:11:36 +00:00
bool initPerson(uint16 noun, const char *actorName, bool loadBank, Person *pp);
uint16 findPersonNumber(uint16 obj, uint16 room) const;
//! load banks used for Joe animation
void loadJoeBanks(const char *animBank, const char *standBank);
//! load the various bobs needed to animate Joe
void setupJoe();
//! setup Joe at the right place when entering a room
void setupJoeInRoom(bool autoPosition, uint16 scale);
uint16 joeFace();
void joeGrab(int16 grabState);
//! change Joe clothes to dress
void joeUseDress(bool showCut);
//! restore Joe clothes
void joeUseClothes(bool showCut);
//! change Joe clothes to underwear
void joeUseUnderwear();
void makeJoeSpeak(uint16 descNum, bool objectType = false);
void makePersonSpeak(const char *sentence, Person *person, const char *voiceFilePrefix);
//! start the specified dialogue
void startDialogue(const char *dlgFile, int personInRoom, char *cutaway);
//! play the specified cutaway
void playCutaway(const char *cutFile, char *next = NULL);
//! initialize the inventory
2003-10-31 13:47:28 +00:00
void inventorySetup();
//! get the inventory item for the specified inventory slot
2003-10-31 13:47:28 +00:00
uint16 findInventoryItem(int invSlot) const;
//! refresh inventory contents
2003-10-31 13:47:28 +00:00
void inventoryRefresh();
int16 previousInventoryItem(int16 first) const;
int16 nextInventoryItem(int16 first) const;
void removeDuplicateItems();
uint16 numItemsInventory() const;
2003-10-31 13:47:28 +00:00
void inventoryInsertItem(uint16 itemNum, bool refresh = true);
void inventoryDeleteItem(uint16 itemNum, bool refresh = true);
void inventoryScroll(uint16 count, bool up);
void removeHotelItemsFromInventory();
2003-10-31 13:47:28 +00:00
//! copy data from dummy object to object
2003-10-31 13:47:28 +00:00
void objectCopy(int dummyObjectIndex, int objectIndex);
//! handle a particular event when Joe walks on this area
2004-01-08 16:41:03 +00:00
void handleSpecialArea(Direction facing, uint16 areaNum, uint16 walkDataNum);
//! handle the pinnacle room (== room chooser in the jungle)
void handlePinnacleRoom();
void update();
void saveState(byte *&ptr);
void loadState(uint32 ver, byte *&ptr);
//! called after a save state has been loaded
void setupRestoredGame();
//! ugly hack from original code
void sceneReset() { _scene = 0; }
//! make a scene
void sceneStart();
//! stop making a scene
void sceneStop();
void changeRoom();
//! enter the Journal (save/load, configuration)
virtual void useJournal() = 0;
//! execute a special move
void executeSpecialMove(uint16 sm);
2004-01-08 16:41:03 +00:00
void startCredits(const char *filename);
void stopCredits();
void start();
2004-01-08 16:41:03 +00:00
enum {
JOE_RESPONSE_MAX = 40,
DEFAULT_TALK_SPEED = 7 * 3,
GAME_STATE_COUNT = 211,
TALK_SELECTED_COUNT = 86
};
typedef void (Logic::*SpecialMoveProc)();
2004-01-08 16:41:03 +00:00
protected:
2006-11-12 17:47:16 +00:00
void readQueenJas();
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 asmAltIntroPanRight();
void asmAltIntroPanLeft();
void asmSetAzuraInLove();
void asmPanRightFromJoe();
void asmSetLightsOff();
void asmSetLightsOn();
void asmSetManequinAreaOn();
void asmPanToJoe();
void asmTurnGuardOn();
void asmPanLeft320To144();
void asmSmooch();
void asmSmoochNoScroll();
void asmMakeLightningHitPlane();
void asmScaleBlimp();
void asmScaleEnding();
void asmWaitForCarPosition();
void asmShakeScreen();
void asmAttemptPuzzle();
void asmScaleTitle();
void asmScrollTitle();
void asmPanRightToHugh();
void asmMakeWhiteFlash();
void asmPanRightToJoeAndRita();
void asmPanLeftToBomb();
void asmEndDemo();
void asmInterviewIntro();
void asmEndInterview();
virtual bool changeToSpecialRoom() = 0;
virtual void setupSpecialMoveTable() = 0;
2004-01-05 11:58:20 +00:00
2003-09-28 15:50:47 +00:00
uint16 _currentRoom;
2003-10-26 13:54:26 +00:00
uint16 _oldRoom;
uint16 _newRoom;
//! total number of room in game
2003-10-26 13:54:26 +00:00
uint16 _numRooms;
//! first object number in room
2003-09-28 15:50:47 +00:00
uint16 *_roomData;
2003-10-26 13:54:26 +00:00
//! background music to play in room
2003-09-28 15:50:47 +00:00
uint16 *_sfxName;
2003-10-26 13:54:26 +00:00
//! bounding box of object
Box *_objectBox;
2003-10-26 13:54:26 +00:00
//! inventory items
ItemData *_itemData;
2003-10-26 13:54:26 +00:00
uint16 _numItems;
GraphicData *_graphicData;
2003-10-26 13:54:26 +00:00
uint16 _numGraphics;
ObjectData *_objectData;
2003-10-26 13:54:26 +00:00
uint16 _numObjects;
ObjectDescription *_objectDescription;
2003-10-31 13:47:28 +00:00
uint16 _numObjDesc;
2003-10-26 13:54:26 +00:00
ActorData *_actorData;
uint16 _numActors;
2003-10-26 13:54:26 +00:00
//! walk off point for an object
WalkOffData *_walkOffData;
2003-10-26 13:54:26 +00:00
uint16 _numWalkOffs;
FurnitureData *_furnitureData;
uint16 _numFurniture;
GraphicAnim *_graphicAnim;
uint16 _numGraphicAnim;
2003-10-26 13:54:26 +00:00
//! actor initial position in room is _walkOffData[_entryObj]
int16 _entryObj;
Common::StringArray _jasStringList;
int _jasStringOffset[JSO_COUNT];
2003-10-26 13:54:26 +00:00
uint16 _numDescriptions;
2003-10-26 13:54:26 +00:00
uint16 _numNames;
uint16 _numAAnim;
uint16 _numAName;
uint16 _numAFile;
struct {
uint16 x, y;
uint16 facing, cutFacing, prevFacing;
JoeWalkMode walk;
uint16 scale;
} _joe;
int16 _gameState[GAME_STATE_COUNT];
TalkSelected _talkSelected[TALK_SELECTED_COUNT];
//! inventory items
2003-10-31 13:47:28 +00:00
int16 _inventoryItem[4];
//! puzzle counter for room T7
uint8 _puzzleAttemptCount;
//! cutscene counter
int _scene;
SpecialMoveProc _specialMoves[40];
Credits *_credits;
Journal *_journal;
2003-12-11 22:16:35 +00:00
QueenEngine *_vm;
2003-09-28 15:50:47 +00:00
};
class LogicDemo : public Logic {
public:
LogicDemo(QueenEngine *vm) : Logic(vm) {}
2020-02-09 11:05:31 +00:00
void useJournal() override;
protected:
2020-02-09 11:05:31 +00:00
bool changeToSpecialRoom() override;
void setupSpecialMoveTable() override;
};
class LogicInterview : public Logic {
public:
LogicInterview(QueenEngine *vm) : Logic(vm) {}
2020-02-09 11:05:31 +00:00
void useJournal() override;
protected:
2020-02-09 11:05:31 +00:00
bool changeToSpecialRoom() override;
void setupSpecialMoveTable() override;
};
class LogicGame : public Logic {
public:
LogicGame(QueenEngine *vm) : Logic(vm) {}
2020-02-09 11:05:31 +00:00
void useJournal() override;
protected:
2020-02-09 11:05:31 +00:00
bool changeToSpecialRoom() override;
void setupSpecialMoveTable() override;
};
2003-10-03 19:47:41 +00:00
} // End of namespace Queen
2003-09-28 15:50:47 +00:00
#endif