2005-04-05 15:53:16 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
|
|
|
* Copyright (C) 2004 Ivan Dubrov
|
2006-01-18 17:39:49 +00:00
|
|
|
* Copyright (C) 2004-2006 The ScummVM project
|
2005-04-05 15:53:16 +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.
|
|
|
|
|
|
|
|
* 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
|
2005-04-09 19:19:54 +00:00
|
|
|
* along with this program; if not, write to the Free Software
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2005-04-05 15:53:16 +00:00
|
|
|
*
|
2006-02-11 10:11:37 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
2005-04-05 15:53:16 +00:00
|
|
|
*
|
|
|
|
*/
|
2005-04-05 18:08:02 +00:00
|
|
|
#ifndef GOB_GAME_H
|
|
|
|
#define GOB_GAME_H
|
2005-04-05 15:07:40 +00:00
|
|
|
|
|
|
|
#include "gob/sound.h"
|
2006-05-01 12:43:50 +00:00
|
|
|
#include "gob/video.h"
|
2005-04-05 15:07:40 +00:00
|
|
|
|
|
|
|
namespace Gob {
|
|
|
|
|
2006-01-03 23:14:39 +00:00
|
|
|
class Game {
|
|
|
|
public:
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-01-03 23:14:39 +00:00
|
|
|
#pragma START_PACK_STRUCTS
|
2006-01-29 02:27:10 +00:00
|
|
|
struct Collision {
|
2006-01-03 23:14:39 +00:00
|
|
|
int16 id;
|
|
|
|
int16 left;
|
|
|
|
int16 top;
|
|
|
|
int16 right;
|
|
|
|
int16 bottom;
|
|
|
|
int16 flags;
|
|
|
|
int16 key;
|
|
|
|
int16 funcEnter;
|
|
|
|
int16 funcLeave;
|
2006-04-18 09:59:18 +00:00
|
|
|
int16 field_12; // New in GOB2
|
2006-01-29 02:27:10 +00:00
|
|
|
} GCC_PACK;
|
2006-01-03 23:14:39 +00:00
|
|
|
|
2006-04-18 09:59:18 +00:00
|
|
|
#define szGame_TotResItem (4 + 2 + 2 + 2)
|
2006-01-29 02:27:10 +00:00
|
|
|
struct TotResItem {
|
2006-01-03 23:14:39 +00:00
|
|
|
int32 offset; // if > 0, then offset from end of resource table.
|
|
|
|
// If < 0, then -offset-1 is index in .IM file table
|
|
|
|
int16 size;
|
|
|
|
int16 width;
|
|
|
|
int16 height;
|
2006-01-29 02:27:10 +00:00
|
|
|
} GCC_PACK;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
|
|
|
#define szGame_TotResTable (2 + 1)
|
2006-01-29 02:27:10 +00:00
|
|
|
struct TotResTable {
|
2006-01-03 23:14:39 +00:00
|
|
|
int16 itemsCount;
|
|
|
|
byte unknown;
|
|
|
|
TotResItem items[1];
|
2006-01-29 02:27:10 +00:00
|
|
|
} GCC_PACK;
|
2006-01-03 23:14:39 +00:00
|
|
|
|
|
|
|
#define szGame_ExtItem (4 + 2 + 2 + 2)
|
2006-01-29 02:27:10 +00:00
|
|
|
struct ExtItem {
|
2006-01-03 23:14:39 +00:00
|
|
|
int32 offset; // offset from the table end
|
|
|
|
uint16 size;
|
|
|
|
int16 width; // width&0x7fff - width, width&0x8000 - pack flag
|
|
|
|
int16 height; // not zero
|
2006-01-29 02:27:10 +00:00
|
|
|
} GCC_PACK;
|
2006-01-03 23:14:39 +00:00
|
|
|
|
|
|
|
#define szGame_ExtTable (2 + 1)
|
2006-01-29 02:27:10 +00:00
|
|
|
struct ExtTable {
|
2006-01-03 23:14:39 +00:00
|
|
|
int16 itemsCount;
|
|
|
|
byte unknown;
|
2006-01-29 02:27:10 +00:00
|
|
|
ExtItem* items;
|
|
|
|
} GCC_PACK;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
|
|
|
#define szGame_TotTextItem (2 + 2)
|
2006-01-29 02:27:10 +00:00
|
|
|
struct TotTextItem {
|
2006-01-03 23:14:39 +00:00
|
|
|
int16 offset;
|
|
|
|
int16 size;
|
2006-01-29 02:27:10 +00:00
|
|
|
} GCC_PACK;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
|
|
|
#define szGame_TotTextTable (2)
|
2006-01-29 02:27:10 +00:00
|
|
|
struct TotTextTable {
|
2006-01-03 23:14:39 +00:00
|
|
|
int16 itemsCount;
|
|
|
|
TotTextItem items[1];
|
2006-01-29 02:27:10 +00:00
|
|
|
} GCC_PACK;
|
2006-01-03 23:14:39 +00:00
|
|
|
|
2006-01-29 02:27:10 +00:00
|
|
|
struct InputDesc {
|
2006-01-03 23:14:39 +00:00
|
|
|
int16 fontIndex;
|
|
|
|
int16 backColor;
|
|
|
|
int16 frontColor;
|
|
|
|
char *ptr;
|
2006-01-29 02:27:10 +00:00
|
|
|
} GCC_PACK;
|
2005-04-05 15:07:40 +00:00
|
|
|
#pragma END_PACK_STRUCTS
|
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
TotResTable *_totResourceTable;
|
|
|
|
Collision *_collisionAreas;
|
2006-05-01 12:43:50 +00:00
|
|
|
Collision *_collStack[5];
|
2006-01-03 23:14:39 +00:00
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
TotTextTable *_totTextData;
|
2006-01-03 23:14:39 +00:00
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
char _curTotFile[14];
|
|
|
|
char _curExtFile[14];
|
2006-01-03 23:14:39 +00:00
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
char *_imFileData;
|
|
|
|
char *_totFileData;
|
2006-01-03 23:14:39 +00:00
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
int16 _extHandle;
|
2006-01-03 23:14:39 +00:00
|
|
|
|
2006-05-11 19:43:30 +00:00
|
|
|
Snd::SoundDesc *_soundSamples[60];
|
|
|
|
int16 _soundIds[60];
|
|
|
|
int8 _soundTypes[60];
|
2006-01-03 23:14:39 +00:00
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
char _totToLoad[20];
|
2006-01-03 23:14:39 +00:00
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
int32 _startTimeKey;
|
|
|
|
int16 _mouseButtons;
|
2006-01-03 23:14:39 +00:00
|
|
|
|
2006-02-24 21:58:03 +00:00
|
|
|
char _soundFromExt[20];
|
|
|
|
|
2006-04-13 20:56:22 +00:00
|
|
|
// For totSub()
|
|
|
|
int8 _backupedCount;
|
|
|
|
int8 _curBackupPos;
|
|
|
|
int16 _cursorXDeltaArray[5];
|
|
|
|
int16 _cursorYDeltaArray[5];
|
|
|
|
TotTextTable *_totTextDataArray[5];
|
|
|
|
char *_totFileDataArray[5];
|
|
|
|
TotResTable *_totResourceTableArray[5];
|
|
|
|
ExtTable *_extTableArray[5];
|
|
|
|
int16 _extHandleArray[5];
|
|
|
|
char *_imFileDataArray[5];
|
|
|
|
char *_variablesArray[5];
|
|
|
|
char _curTotFileArray[5][14];
|
|
|
|
|
2006-01-03 23:14:39 +00:00
|
|
|
Game(GobEngine *vm);
|
2006-04-18 09:59:18 +00:00
|
|
|
virtual ~Game() {};
|
2006-01-03 23:14:39 +00:00
|
|
|
|
|
|
|
char *loadExtData(int16 dataId, int16 *pResWidth, int16 *pResHeight);
|
|
|
|
char *loadTotResource(int16 id);
|
|
|
|
|
|
|
|
void capturePush(int16 left, int16 top, int16 width, int16 height);
|
|
|
|
|
|
|
|
void capturePop(char doDraw);
|
|
|
|
void freeSoundSlot(int16 slot);
|
|
|
|
void freeCollision(int16 id);
|
|
|
|
|
|
|
|
void loadSound(int16 slot, char *dataPtr);
|
|
|
|
int16 inputArea(int16 xPos, int16 yPos, int16 width, int16 height, int16 backColor,
|
|
|
|
int16 frontColor, char *str, int16 fontIndex, char inpType, int16 *pTotTime);
|
|
|
|
int16 multiEdit(int16 time, int16 index, int16 *pCurPos,
|
|
|
|
InputDesc * inpDesc);
|
|
|
|
int16 adjustKey(int16 key);
|
|
|
|
void collisionsBlock(void);
|
|
|
|
void loadTotFile(char *path);
|
|
|
|
void loadExtTable(void);
|
|
|
|
void loadImFile(void);
|
|
|
|
void start(void);
|
2006-04-13 20:56:22 +00:00
|
|
|
void totSub(int8 flags, char *newTotFile);
|
2006-05-11 19:43:30 +00:00
|
|
|
void switchTotSub(int16 index, int16 skipPlay);
|
2006-04-18 09:59:18 +00:00
|
|
|
char *loadLocTexts(void);
|
2006-05-11 19:43:30 +00:00
|
|
|
Snd::SoundDesc *loadSND(const char *path, int8 arg_4);
|
2006-04-18 09:59:18 +00:00
|
|
|
|
|
|
|
virtual void playTot(int16 skipPlay) = 0;
|
|
|
|
virtual void clearCollisions(void) = 0;
|
|
|
|
virtual void addNewCollision(int16 id, int16 left, int16 top, int16 right,
|
|
|
|
int16 bottom, int16 flags, int16 key, int16 funcEnter, int16 funcLeave) = 0;
|
2006-05-01 12:43:50 +00:00
|
|
|
virtual int16 checkKeys(int16 *pMousex, int16 *pMouseY, int16 *pButtons,
|
|
|
|
char handleMouse) = 0;
|
|
|
|
virtual int16 checkCollisions(char handleMouse, int16 deltaTime, int16 *pResId,
|
|
|
|
int16 *pResIndex) = 0;
|
|
|
|
virtual void prepareStart(void) = 0;
|
|
|
|
|
|
|
|
int8 _byte_2FC9B;
|
|
|
|
int16 _word_2FC9C;
|
|
|
|
int16 _word_2FC9E;
|
|
|
|
int16 _word_2E51F;
|
|
|
|
Video::SurfaceDesc *_off_2E51B;
|
|
|
|
Video::SurfaceDesc *_off_2E517;
|
|
|
|
void sub_ADD2(void);
|
|
|
|
void sub_BB28(void);
|
2006-01-03 23:14:39 +00:00
|
|
|
protected:
|
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
int16 _lastCollKey;
|
|
|
|
int16 _lastCollAreaIndex;
|
|
|
|
int16 _lastCollId;
|
2006-01-03 23:14:39 +00:00
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
int16 _activeCollResId;
|
|
|
|
int16 _activeCollIndex;
|
|
|
|
char _handleMouse;
|
|
|
|
char _forceHandleMouse;
|
2006-01-03 23:14:39 +00:00
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
char _tempStr[256];
|
2006-01-03 23:14:39 +00:00
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
ExtTable *_extTable;
|
|
|
|
char _curImaFile[18];
|
2006-01-03 23:14:39 +00:00
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
int16 _collStackSize;
|
2006-05-01 12:43:50 +00:00
|
|
|
int16 _collStackElemSizes[5];
|
2006-01-03 23:14:39 +00:00
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
char _shouldPushColls;
|
2006-01-03 23:14:39 +00:00
|
|
|
|
|
|
|
// Capture
|
2006-01-07 22:28:54 +00:00
|
|
|
static Common::Rect _captureStack[20];
|
|
|
|
static int16 _captureCount;
|
2006-01-03 23:14:39 +00:00
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
char _collStr[256];
|
2006-01-03 23:14:39 +00:00
|
|
|
|
|
|
|
GobEngine *_vm;
|
|
|
|
|
|
|
|
int16 checkMousePoint(int16 all, int16 *resId, int16 *resIndex);
|
2006-05-01 12:43:50 +00:00
|
|
|
void setCollisions(void);
|
|
|
|
void collSub(int16 offset);
|
|
|
|
void collAreaSub(int16 index, int8 enter);
|
|
|
|
int16 openLocTextFile(char *locTextFile, int language);
|
|
|
|
|
|
|
|
virtual void pushCollisions(char all) = 0;
|
|
|
|
virtual void popCollisions(void) = 0;
|
2006-01-03 23:14:39 +00:00
|
|
|
};
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-04-18 09:59:18 +00:00
|
|
|
class Game_v1 : public Game {
|
|
|
|
public:
|
|
|
|
virtual void playTot(int16 skipPlay);
|
|
|
|
virtual void clearCollisions(void);
|
|
|
|
virtual void addNewCollision(int16 id, int16 left, int16 top, int16 right,
|
|
|
|
int16 bottom, int16 flags, int16 key, int16 funcEnter, int16 funcLeave);
|
2006-05-01 12:43:50 +00:00
|
|
|
virtual int16 checkKeys(int16 *pMousex, int16 *pMouseY, int16 *pButtons,
|
|
|
|
char handleMouse);
|
|
|
|
virtual int16 checkCollisions(char handleMouse, int16 deltaTime, int16 *pResId,
|
|
|
|
int16 *pResIndex);
|
|
|
|
virtual void prepareStart(void);
|
2006-04-18 09:59:18 +00:00
|
|
|
|
|
|
|
Game_v1(GobEngine *vm);
|
|
|
|
virtual ~Game_v1() {};
|
2006-05-01 12:43:50 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void pushCollisions(char all);
|
|
|
|
virtual void popCollisions(void);
|
2006-04-18 09:59:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class Game_v2 : public Game_v1 {
|
|
|
|
public:
|
|
|
|
virtual void playTot(int16 skipPlay);
|
|
|
|
virtual void clearCollisions(void);
|
|
|
|
virtual void addNewCollision(int16 id, int16 left, int16 top, int16 right,
|
|
|
|
int16 bottom, int16 flags, int16 key, int16 funcEnter, int16 funcLeave);
|
2006-05-01 12:43:50 +00:00
|
|
|
virtual int16 checkKeys(int16 *pMousex, int16 *pMouseY, int16 *pButtons,
|
|
|
|
char handleMouse);
|
|
|
|
virtual int16 checkCollisions(char handleMouse, int16 deltaTime, int16 *pResId,
|
|
|
|
int16 *pResIndex);
|
|
|
|
virtual void prepareStart(void);
|
2006-04-18 09:59:18 +00:00
|
|
|
|
|
|
|
Game_v2(GobEngine *vm);
|
|
|
|
virtual ~Game_v2() {};
|
2006-05-01 12:43:50 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
struct CollLast {
|
|
|
|
int16 key;
|
|
|
|
int16 id;
|
|
|
|
int16 areaIndex;
|
|
|
|
};
|
|
|
|
|
|
|
|
CollLast _collLasts[5];
|
|
|
|
|
|
|
|
virtual void pushCollisions(char all);
|
|
|
|
virtual void popCollisions(void);
|
2006-04-18 09:59:18 +00:00
|
|
|
};
|
|
|
|
|
2005-04-05 15:07:40 +00:00
|
|
|
} // End of namespace Gob
|
|
|
|
|
|
|
|
#endif
|