2006-05-23 23:43:52 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
|
|
|
* Copyright (C) 2006 The ScummVM project
|
|
|
|
*
|
|
|
|
* Copyright (C) 1999-2001 Sarien Team
|
|
|
|
*
|
|
|
|
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
* $URL$
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2006-05-24 14:25:42 +00:00
|
|
|
#ifndef AGI_H
|
|
|
|
#define AGI_H
|
2006-05-23 23:43:52 +00:00
|
|
|
|
|
|
|
#include "common/stdafx.h"
|
|
|
|
#include "common/scummsys.h"
|
|
|
|
#include "common/endian.h"
|
|
|
|
#include "common/util.h"
|
|
|
|
#include "common/file.h"
|
|
|
|
#include "common/savefile.h"
|
|
|
|
#include "common/system.h"
|
2006-12-06 19:27:02 +00:00
|
|
|
#include "common/hash-str.h"
|
2006-05-23 23:43:52 +00:00
|
|
|
|
2006-09-23 00:42:35 +00:00
|
|
|
#include "engines/engine.h"
|
2006-05-23 23:43:52 +00:00
|
|
|
|
|
|
|
namespace Agi {
|
|
|
|
|
|
|
|
typedef signed int Err;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Version and other definitions
|
|
|
|
*/
|
|
|
|
|
2006-12-06 15:31:35 +00:00
|
|
|
#define USE_IIGS_SOUND
|
2006-05-23 23:43:52 +00:00
|
|
|
|
|
|
|
#define TITLE "AGI engine"
|
|
|
|
|
|
|
|
#define DIR_ "dir"
|
|
|
|
#define LOGDIR "logdir"
|
|
|
|
#define PICDIR "picdir"
|
|
|
|
#define VIEWDIR "viewdir"
|
|
|
|
#define SNDDIR "snddir"
|
|
|
|
#define OBJECTS "object"
|
|
|
|
#define WORDS "words.tok"
|
|
|
|
|
|
|
|
#define MAX_DIRS 256
|
|
|
|
#define MAX_VARS 256
|
|
|
|
#define MAX_FLAGS (256 >> 3)
|
|
|
|
#define MAX_VIEWTABLE 255 /* KQ3 uses o255! */
|
|
|
|
#define MAX_WORDS 20
|
2006-05-25 19:56:05 +00:00
|
|
|
#define MAX_STRINGS 24 /* MAX_STRINGS + 1 used for get.num */
|
2006-05-23 23:43:52 +00:00
|
|
|
#define MAX_STRINGLEN 40
|
|
|
|
#ifndef MAX_PATH
|
|
|
|
#define MAX_PATH 260
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define _EMPTY 0xfffff
|
|
|
|
#define EGO_OWNED 0xff
|
|
|
|
|
|
|
|
#define CRYPT_KEY_SIERRA "Avis Durgan"
|
|
|
|
#define CRYPT_KEY_AGDS "Alex Simkin"
|
|
|
|
|
|
|
|
#ifndef INLINE
|
|
|
|
#define INLINE
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define MSG_BOX_COLOUR 0x0f /* White */
|
|
|
|
#define MSG_BOX_TEXT 0x00 /* Black */
|
|
|
|
#define MSG_BOX_LINE 0x04 /* Red */
|
2006-05-25 19:56:05 +00:00
|
|
|
#define STATUS_FG 0x00 /* Black */
|
|
|
|
#define STATUS_BG 0x0f /* White */
|
|
|
|
#define PATCH_LOGIC /* disable copy protection on some games */
|
2006-05-23 23:43:52 +00:00
|
|
|
|
2007-01-12 02:29:20 +00:00
|
|
|
#define ADD_PIC 1
|
|
|
|
#define ADD_VIEW 2
|
|
|
|
|
2006-05-25 19:56:05 +00:00
|
|
|
} // End of namespace Agi
|
2006-05-23 23:43:52 +00:00
|
|
|
|
|
|
|
/* AGI resources */
|
|
|
|
#include "agi/console.h"
|
|
|
|
#include "agi/view.h"
|
|
|
|
#include "agi/picture.h"
|
|
|
|
#include "agi/logic.h"
|
|
|
|
#include "agi/sound.h"
|
|
|
|
|
|
|
|
namespace Agi {
|
|
|
|
|
2006-12-19 01:11:41 +00:00
|
|
|
enum AgiGameType {
|
|
|
|
GType_V2 = 1,
|
|
|
|
GType_V3
|
|
|
|
};
|
|
|
|
|
|
|
|
enum AgiGameFeatures {
|
|
|
|
AGI_AMIGA = 1 << 0,
|
|
|
|
AGI_MOUSE = 1 << 1,
|
|
|
|
AGI_AGDS = 1 << 2
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2007-01-21 20:24:38 +00:00
|
|
|
struct AGIGameDescription;
|
2006-12-19 01:11:41 +00:00
|
|
|
|
2006-05-23 23:43:52 +00:00
|
|
|
enum {
|
|
|
|
NO_GAMEDIR = 0,
|
|
|
|
GAMEDIR
|
|
|
|
};
|
|
|
|
|
|
|
|
enum AGIErrors {
|
2007-01-16 12:40:51 +00:00
|
|
|
errOK = 0,
|
|
|
|
errDoNothing,
|
|
|
|
errBadCLISwitch,
|
|
|
|
errInvalidAGIFile,
|
|
|
|
errBadFileOpen,
|
|
|
|
errNotEnoughMemory,
|
|
|
|
errBadResource,
|
|
|
|
errUnknownAGIVersion,
|
|
|
|
errRestartGame,
|
|
|
|
errNoLoopsInView,
|
|
|
|
errViewDataError,
|
|
|
|
errNoGameList,
|
|
|
|
|
|
|
|
errUnk = 127
|
2006-05-23 23:43:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum kDebugLevels {
|
|
|
|
kDebugLevelMain = 1 << 0,
|
|
|
|
kDebugLevelResources = 1 << 1,
|
|
|
|
kDebugLevelSprites = 1 << 2,
|
|
|
|
kDebugLevelInventory = 1 << 3,
|
|
|
|
kDebugLevelInput = 1 << 4,
|
|
|
|
kDebugLevelMenu = 1 << 5,
|
|
|
|
kDebugLevelScripts = 1 << 6,
|
|
|
|
kDebugLevelSound = 1 << 7,
|
2007-01-12 02:29:20 +00:00
|
|
|
kDebugLevelText = 1 << 8,
|
|
|
|
kDebugLevelSavegame = 1 << 9
|
2006-05-23 23:43:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* AGI resources.
|
|
|
|
*/
|
|
|
|
enum {
|
|
|
|
rLOGIC = 1,
|
|
|
|
rSOUND,
|
|
|
|
rVIEW,
|
|
|
|
rPICTURE
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
RES_LOADED = 1,
|
|
|
|
RES_COMPRESSED = 0x40
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
lCOMMAND_MODE = 1,
|
|
|
|
lTEST_MODE
|
|
|
|
};
|
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
struct gameIdList {
|
|
|
|
gameIdList *next;
|
2006-05-23 23:43:52 +00:00
|
|
|
uint32 version;
|
|
|
|
uint32 crc;
|
|
|
|
char *gName;
|
|
|
|
char *switches;
|
|
|
|
};
|
|
|
|
|
2006-12-06 19:27:02 +00:00
|
|
|
struct Mouse {
|
2006-05-23 23:43:52 +00:00
|
|
|
int button;
|
|
|
|
unsigned int x;
|
|
|
|
unsigned int y;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Command-line options.
|
|
|
|
*/
|
2007-01-16 12:40:51 +00:00
|
|
|
struct AgiOptions {
|
2006-05-23 23:43:52 +00:00
|
|
|
#define GAMERUN_RUNGAME 0
|
|
|
|
#define GAMERUN_PICVIEW 1
|
|
|
|
#define GAMERUN_WORDS 2
|
|
|
|
#define GAMERUN_OBJECTS 3
|
|
|
|
#define GAMERUN_GAMES 4
|
|
|
|
#define GAMERUN_CRC 5
|
|
|
|
int gamerun; /**< game run mode*/
|
|
|
|
int emuversion; /**< AGI version to emulate */
|
2007-01-07 18:02:54 +00:00
|
|
|
bool agdsMode; /**< enable AGDS mode */
|
|
|
|
bool amigaMode; /**< enable Amiga mode */
|
|
|
|
bool nosound; /**< disable sound */
|
2006-05-25 19:46:28 +00:00
|
|
|
Common::RenderMode renderMode;
|
2006-05-23 23:43:52 +00:00
|
|
|
int soundemu; /**< sound emulation mode */
|
2007-01-07 18:02:54 +00:00
|
|
|
bool agimouse; /**< AGI Mouse 1.0 emulation */
|
2006-05-23 23:43:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#define report printf
|
|
|
|
|
|
|
|
enum GameId {
|
|
|
|
GID_AGI = 1
|
|
|
|
};
|
|
|
|
|
|
|
|
#define WIN_TO_PIC_X(x) ((x) / 2)
|
|
|
|
#define WIN_TO_PIC_Y(y) ((y) < 8 ? 999 : (y) >= (8 + _HEIGHT) ? 999 : (y) - 8)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* AGI variables.
|
|
|
|
*/
|
|
|
|
enum {
|
2007-01-16 12:40:51 +00:00
|
|
|
vCurRoom = 0, /* 0 */
|
|
|
|
vPrevRoom,
|
|
|
|
vBorderTouchEgo,
|
|
|
|
vScore,
|
|
|
|
vBorderCode,
|
|
|
|
vBorderTouchObj, /* 5 */
|
|
|
|
vEgoDir,
|
|
|
|
vMaxScore,
|
|
|
|
vFreePages,
|
|
|
|
vWordNotFound,
|
|
|
|
vTimeDelay, /* 10 */
|
|
|
|
vSeconds,
|
|
|
|
vMinutes,
|
|
|
|
vHours,
|
|
|
|
vDays,
|
|
|
|
vJoystickSensitivity, /* 15 */
|
|
|
|
vEgoViewResource,
|
|
|
|
vAgiErrCode,
|
|
|
|
vAgiErrCodeInfo,
|
|
|
|
vKey,
|
|
|
|
vComputer, /* 20 */
|
|
|
|
vWindowReset,
|
|
|
|
vSoundgen,
|
|
|
|
vVolume,
|
|
|
|
vMaxInputChars,
|
|
|
|
vSelItem, /* 25 */
|
|
|
|
vMonitor
|
2006-05-23 23:43:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* AGI flags
|
|
|
|
*/
|
|
|
|
enum {
|
2007-01-16 12:40:51 +00:00
|
|
|
fEgoWater = 0, /* 0 */
|
|
|
|
fEgoInvisible,
|
|
|
|
fEnteredCli,
|
|
|
|
fEgoTouchedP2,
|
|
|
|
fSaidAcceptedInput,
|
|
|
|
fNewRoomExec, /* 5 */
|
|
|
|
fRestartGame,
|
|
|
|
fScriptBlocked,
|
|
|
|
fJoySensitivity,
|
|
|
|
fSoundOn,
|
|
|
|
fDebuggerOn, /* 10 */
|
|
|
|
fLogicZeroFirsttime,
|
|
|
|
fRestoreJustRan,
|
|
|
|
fStatusSelectsItems,
|
|
|
|
fMenusWork,
|
|
|
|
fOutputMode, /* 15 */
|
|
|
|
fAutoRestart
|
2006-05-23 23:43:52 +00:00
|
|
|
};
|
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
struct AgiEvent {
|
2006-05-23 23:43:52 +00:00
|
|
|
uint16 data;
|
|
|
|
uint8 occured;
|
|
|
|
};
|
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
struct AgiObject {
|
2006-05-23 23:43:52 +00:00
|
|
|
int location;
|
|
|
|
char *name;
|
|
|
|
};
|
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
struct AgiWord {
|
2006-05-23 23:43:52 +00:00
|
|
|
int id;
|
|
|
|
char *word;
|
|
|
|
};
|
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
struct AgiDir {
|
2006-05-23 23:43:52 +00:00
|
|
|
uint8 volume;
|
|
|
|
uint32 offset;
|
|
|
|
uint32 len;
|
|
|
|
uint32 clen;
|
|
|
|
uint8 flags;
|
|
|
|
/* 0 = not in mem, can be freed
|
|
|
|
* 1 = in mem, can be released
|
|
|
|
* 2 = not in mem, cant be released
|
|
|
|
* 3 = in mem, cant be released
|
|
|
|
* 0x40 = was compressed
|
|
|
|
*/
|
|
|
|
};
|
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
struct AgiBlock {
|
2006-05-23 23:43:52 +00:00
|
|
|
int active;
|
|
|
|
int x1, y1;
|
|
|
|
int x2, y2;
|
|
|
|
uint8 *buffer; /* used for window background */
|
|
|
|
};
|
|
|
|
|
|
|
|
#define EGO_VIEW_TABLE 0
|
|
|
|
#define HORIZON 36
|
|
|
|
#define _WIDTH 160
|
|
|
|
#define _HEIGHT 168
|
|
|
|
|
|
|
|
/**
|
|
|
|
* AGI game structure.
|
|
|
|
* This structure contains all global data of an AGI game executed
|
|
|
|
* by the interpreter.
|
|
|
|
*/
|
2007-01-16 12:40:51 +00:00
|
|
|
struct AgiGame {
|
2006-05-23 23:43:52 +00:00
|
|
|
#define STATE_INIT 0x00
|
|
|
|
#define STATE_LOADED 0x01
|
|
|
|
#define STATE_RUNNING 0x02
|
|
|
|
int state; /**< state of the interpreter */
|
|
|
|
|
2006-05-25 19:56:05 +00:00
|
|
|
char name[8]; /**< lead in id (e.g. `GR' for goldrush) */
|
2006-05-23 23:43:52 +00:00
|
|
|
char id[8]; /**< game id */
|
|
|
|
uint32 crc; /**< game CRC */
|
|
|
|
|
|
|
|
/* game flags and variables */
|
2006-05-25 19:56:05 +00:00
|
|
|
uint8 flags[MAX_FLAGS]; /**< 256 1-bit flags */
|
|
|
|
uint8 vars[MAX_VARS]; /**< 256 variables */
|
2006-05-23 23:43:52 +00:00
|
|
|
|
|
|
|
/* internal variables */
|
2006-05-25 19:56:05 +00:00
|
|
|
int horizon; /**< horizon y coordinate */
|
2007-01-16 12:40:51 +00:00
|
|
|
int lineStatus; /**< line number to put status on */
|
|
|
|
int lineUserInput; /**< line to put user input on */
|
|
|
|
int lineMinPrint; /**< num lines to print on */
|
|
|
|
int cursorPos; /**< column where the input cursor is */
|
|
|
|
uint8 inputBuffer[40]; /**< buffer for user input */
|
|
|
|
uint8 echoBuffer[40]; /**< buffer for echo.line */
|
2006-05-23 23:43:52 +00:00
|
|
|
int keypress;
|
|
|
|
#define INPUT_NORMAL 0x01
|
|
|
|
#define INPUT_GETSTRING 0x02
|
|
|
|
#define INPUT_MENU 0x03
|
|
|
|
#define INPUT_NONE 0x04
|
2007-01-16 12:40:51 +00:00
|
|
|
int inputMode; /**< keyboard input mode */
|
|
|
|
int inputEnabled; /**< keyboard input enabled */
|
2006-05-25 19:56:05 +00:00
|
|
|
int lognum; /**< current logic number */
|
2006-05-23 23:43:52 +00:00
|
|
|
|
|
|
|
/* internal flags */
|
2007-01-16 12:40:51 +00:00
|
|
|
int playerControl; /**< player is in control */
|
|
|
|
int quitProgNow; /**< quit now */
|
|
|
|
int statusLine; /**< status line on/off */
|
|
|
|
int clockEnabled; /**< clock is on/off */
|
|
|
|
int exitAllLogics; /**< break cycle after new.room */
|
|
|
|
int pictureShown; /**< show.pic has been issued */
|
|
|
|
int hasPrompt; /**< input prompt has been printed */
|
2006-05-23 23:43:52 +00:00
|
|
|
#define ID_AGDS 0x00000001
|
|
|
|
#define ID_AMIGA 0x00000002
|
2007-01-16 12:40:51 +00:00
|
|
|
int gameFlags; /**< agi options flags */
|
2006-05-23 23:43:52 +00:00
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
uint8 priTable[_HEIGHT];/**< priority table */
|
2006-05-23 23:43:52 +00:00
|
|
|
|
|
|
|
/* windows */
|
2007-01-16 12:40:51 +00:00
|
|
|
uint32 msgBoxTicks; /**< timed message box tick counter */
|
|
|
|
AgiBlock block;
|
|
|
|
AgiBlock window;
|
|
|
|
int hasWindow;
|
2006-05-23 23:43:52 +00:00
|
|
|
|
|
|
|
/* graphics & text */
|
2007-01-16 12:40:51 +00:00
|
|
|
int gfxMode;
|
|
|
|
char cursorChar;
|
|
|
|
unsigned int colorFg;
|
|
|
|
unsigned int colorBg;
|
2006-05-23 23:43:52 +00:00
|
|
|
uint8 *sbuf; /**< 160x168 AGI screen buffer */
|
|
|
|
|
|
|
|
/* player command line */
|
2007-01-16 12:40:51 +00:00
|
|
|
AgiWord egoWords[MAX_WORDS];
|
|
|
|
int numEgoWords;
|
2006-05-23 23:43:52 +00:00
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
unsigned int numObjects;
|
2006-05-23 23:43:52 +00:00
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
AgiEvent evKeyp[MAX_DIRS]; /**< keyboard keypress events */
|
2006-05-25 19:56:05 +00:00
|
|
|
char strings[MAX_STRINGS + 1][MAX_STRINGLEN]; /**< strings */
|
2006-05-23 23:43:52 +00:00
|
|
|
|
|
|
|
/* directory entries for resources */
|
2007-01-16 12:40:51 +00:00
|
|
|
AgiDir dirLogic[MAX_DIRS];
|
|
|
|
AgiDir dirPic[MAX_DIRS];
|
|
|
|
AgiDir dirView[MAX_DIRS];
|
|
|
|
AgiDir dirSound[MAX_DIRS];
|
2006-05-23 23:43:52 +00:00
|
|
|
|
|
|
|
/* resources */
|
2007-01-16 12:40:51 +00:00
|
|
|
AgiPicture pictures[MAX_DIRS]; /**< AGI picture resources */
|
|
|
|
AgiLogic logics[MAX_DIRS]; /**< AGI logic resources */
|
|
|
|
AgiView views[MAX_DIRS]; /**< AGI view resources */
|
|
|
|
AgiSound sounds[MAX_DIRS]; /**< AGI sound resources */
|
2006-05-23 23:43:52 +00:00
|
|
|
|
|
|
|
/* view table */
|
2007-02-03 21:37:52 +00:00
|
|
|
VtEntry viewTable[MAX_VIEWTABLE];
|
2006-05-23 23:43:52 +00:00
|
|
|
|
2006-05-25 19:56:05 +00:00
|
|
|
int32 ver; /**< detected game version */
|
2006-05-23 23:43:52 +00:00
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
int simpleSave; /**< select simple savegames */
|
2006-05-23 23:43:52 +00:00
|
|
|
};
|
|
|
|
|
2006-12-06 19:27:02 +00:00
|
|
|
class AgiLoader {
|
|
|
|
private:
|
2007-01-16 12:40:51 +00:00
|
|
|
int intVersion;
|
2006-12-06 19:27:02 +00:00
|
|
|
AgiEngine *_vm;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
AgiLoader() {}
|
2006-12-06 21:23:01 +00:00
|
|
|
virtual ~AgiLoader() {}
|
2006-12-06 19:27:02 +00:00
|
|
|
|
|
|
|
virtual int init() = 0;
|
|
|
|
virtual int deinit() = 0;
|
2007-01-16 12:40:51 +00:00
|
|
|
virtual int detectGame() = 0;
|
|
|
|
virtual int loadResource(int, int) = 0;
|
|
|
|
virtual int unloadResource(int, int) = 0;
|
|
|
|
virtual int loadObjects(const char *) = 0;
|
|
|
|
virtual int loadWords(const char *) = 0;
|
2006-12-06 19:27:02 +00:00
|
|
|
virtual int version() = 0;
|
|
|
|
virtual void setIntVersion(int) = 0;
|
|
|
|
virtual int getIntVersion() = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
class AgiLoader_v2 : public AgiLoader {
|
|
|
|
private:
|
2007-01-16 12:40:51 +00:00
|
|
|
int _intVersion;
|
2006-12-06 19:27:02 +00:00
|
|
|
AgiEngine *_vm;
|
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
int loadDir(AgiDir *agid, const char *fname);
|
|
|
|
uint8 *loadVolRes(AgiDir *agid);
|
2006-12-06 19:27:02 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
AgiLoader_v2(AgiEngine *vm) {
|
|
|
|
_vm = vm;
|
2007-01-16 12:40:51 +00:00
|
|
|
_intVersion = 0;
|
2006-12-06 19:27:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual int init();
|
|
|
|
virtual int deinit();
|
2007-01-16 12:40:51 +00:00
|
|
|
virtual int detectGame();
|
|
|
|
virtual int loadResource(int, int);
|
|
|
|
virtual int unloadResource(int, int);
|
|
|
|
virtual int loadObjects(const char *);
|
|
|
|
virtual int loadWords(const char *);
|
2006-12-06 19:27:02 +00:00
|
|
|
virtual int version();
|
|
|
|
virtual void setIntVersion(int);
|
|
|
|
virtual int getIntVersion();
|
|
|
|
};
|
|
|
|
|
|
|
|
class AgiLoader_v3 : public AgiLoader {
|
|
|
|
private:
|
2007-01-16 12:40:51 +00:00
|
|
|
int _intVersion;
|
2006-12-06 19:27:02 +00:00
|
|
|
AgiEngine *_vm;
|
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
int loadDir(AgiDir *agid, Common::File *fp, uint32 offs, uint32 len);
|
|
|
|
uint8 *loadVolRes(AgiDir *agid);
|
2006-12-06 19:27:02 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
AgiLoader_v3(AgiEngine *vm) {
|
|
|
|
_vm = vm;
|
2007-01-16 12:40:51 +00:00
|
|
|
_intVersion = 0;
|
2006-12-06 19:27:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual int init();
|
|
|
|
virtual int deinit();
|
2007-01-16 12:40:51 +00:00
|
|
|
virtual int detectGame();
|
|
|
|
virtual int loadResource(int, int);
|
|
|
|
virtual int unloadResource(int, int);
|
|
|
|
virtual int loadObjects(const char *);
|
|
|
|
virtual int loadWords(const char *);
|
2006-12-06 19:27:02 +00:00
|
|
|
virtual int version();
|
|
|
|
virtual void setIntVersion(int);
|
|
|
|
virtual int getIntVersion();
|
2006-05-23 23:43:52 +00:00
|
|
|
};
|
|
|
|
|
2006-12-06 19:27:02 +00:00
|
|
|
class GfxMgr;
|
|
|
|
class SpritesMgr;
|
|
|
|
class Menu;
|
|
|
|
|
|
|
|
extern struct Mouse g_mouse;
|
|
|
|
|
|
|
|
/* Image stack support */
|
2007-01-16 12:40:51 +00:00
|
|
|
struct ImageStackElement {
|
2006-12-06 19:27:02 +00:00
|
|
|
uint8 type;
|
|
|
|
uint8 pad;
|
|
|
|
int16 parm1;
|
|
|
|
int16 parm2;
|
|
|
|
int16 parm3;
|
|
|
|
int16 parm4;
|
|
|
|
int16 parm5;
|
|
|
|
int16 parm6;
|
|
|
|
int16 parm7;
|
|
|
|
};
|
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
struct StringData {
|
2006-12-06 19:27:02 +00:00
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
int len;
|
|
|
|
int str;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define TICK_SECONDS 20
|
|
|
|
|
|
|
|
#define KEY_QUEUE_SIZE 16
|
|
|
|
|
|
|
|
class AgiEngine : public ::Engine {
|
|
|
|
int _gameId;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
int init();
|
|
|
|
int go();
|
|
|
|
void shutdown();
|
|
|
|
void initialize();
|
|
|
|
|
2006-12-19 01:11:41 +00:00
|
|
|
bool initGame();
|
|
|
|
|
2006-12-06 19:27:02 +00:00
|
|
|
public:
|
|
|
|
AgiEngine(OSystem *syst);
|
|
|
|
virtual ~AgiEngine();
|
|
|
|
int getGameId() {
|
|
|
|
return _gameId;
|
|
|
|
}
|
|
|
|
|
2006-12-19 01:11:41 +00:00
|
|
|
const AGIGameDescription *_gameDescription;
|
2007-01-21 20:24:38 +00:00
|
|
|
uint32 getFeatures() const;
|
|
|
|
uint16 getVersion() const;
|
2006-12-19 01:11:41 +00:00
|
|
|
|
2006-12-06 19:27:02 +00:00
|
|
|
private:
|
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
int _keyQueue[KEY_QUEUE_SIZE];
|
|
|
|
int _keyQueueStart;
|
|
|
|
int _keyQueueEnd;
|
2006-12-06 19:27:02 +00:00
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
int checkPriority(VtEntry *v);
|
|
|
|
int checkCollision(VtEntry *v);
|
|
|
|
int checkPosition(VtEntry *v);
|
2006-12-06 19:27:02 +00:00
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
uint32 matchVersion(uint32 crc);
|
2006-12-06 19:27:02 +00:00
|
|
|
|
|
|
|
public:
|
2007-01-16 12:40:51 +00:00
|
|
|
AgiGame _game;
|
|
|
|
AgiObject *_objects; /* objects in the game */
|
2006-12-06 19:27:02 +00:00
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
StringData _stringdata;
|
2006-12-06 19:27:02 +00:00
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
AgiLoader *_loader; /* loader */
|
2006-12-06 19:27:02 +00:00
|
|
|
|
|
|
|
Common::RandomSource *_rnd;
|
|
|
|
const char *_savePath;
|
|
|
|
|
2007-01-12 02:29:20 +00:00
|
|
|
const char *getSavegameFilename(int num);
|
|
|
|
int selectSlot();
|
|
|
|
int saveGame(const char *fileName, const char *saveName);
|
|
|
|
int saveGameDialog();
|
|
|
|
int saveGameSimple();
|
|
|
|
int loadGame(const char *fileName);
|
|
|
|
int loadGameDialog();
|
|
|
|
int loadGameSimple();
|
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
volatile uint32 _clockCount;
|
2006-12-06 19:27:02 +00:00
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
uint8 *_intobj;
|
|
|
|
int _oldMode;
|
2006-12-06 19:27:02 +00:00
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
Menu* _menu;
|
2006-12-06 19:27:02 +00:00
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
char _lastSentence[40];
|
2006-12-06 19:27:02 +00:00
|
|
|
|
|
|
|
SpritesMgr *_sprites;
|
|
|
|
GfxMgr *_gfx;
|
|
|
|
SoundMgr *_sound;
|
|
|
|
PictureMgr *_picture;
|
|
|
|
|
|
|
|
#define INITIAL_IMAGE_STACK_SIZE 32
|
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
int _stackSize;
|
|
|
|
ImageStackElement *_imageStack;
|
|
|
|
int _imageStackPointer;
|
2006-12-06 19:27:02 +00:00
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
void clearImageStack();
|
|
|
|
void recordImageStackCall(uint8 type, int16 p1, int16 p2, int16 p3,
|
2006-12-06 19:27:02 +00:00
|
|
|
int16 p4, int16 p5, int16 p6, int16 p7);
|
2007-01-16 12:40:51 +00:00
|
|
|
void replayImageStackCall(uint8 type, int16 p1, int16 p2, int16 p3,
|
2006-12-06 19:27:02 +00:00
|
|
|
int16 p4, int16 p5, int16 p6, int16 p7);
|
2007-01-16 12:40:51 +00:00
|
|
|
void releaseImageStack();
|
2006-12-06 19:27:02 +00:00
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
AgiDebug _debug;
|
|
|
|
AgiOptions _opt;
|
2006-12-06 19:27:02 +00:00
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
int _keyControl;
|
|
|
|
int _keyAlt;
|
2006-12-06 19:27:02 +00:00
|
|
|
|
|
|
|
Console *_console;
|
|
|
|
|
|
|
|
int agiInit();
|
|
|
|
int agiDeinit();
|
|
|
|
int agiVersion();
|
|
|
|
int agiGetRelease();
|
|
|
|
void agiSetRelease(int);
|
|
|
|
int agiDetectGame();
|
|
|
|
int agiLoadResource(int, int);
|
|
|
|
int agiUnloadResource(int, int);
|
|
|
|
void agiUnloadResources();
|
|
|
|
|
|
|
|
void agiTimerLow();
|
|
|
|
int agiGetKeypressLow();
|
|
|
|
int agiIsKeypressLow();
|
|
|
|
static void agiTimerFunctionLow(void *refCon);
|
|
|
|
void initPriTable();
|
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
void newInputMode(int);
|
|
|
|
void oldInputMode();
|
2006-12-06 19:27:02 +00:00
|
|
|
|
|
|
|
int getflag(int);
|
|
|
|
void setflag(int, int);
|
|
|
|
void flipflag(int);
|
|
|
|
int getvar(int);
|
|
|
|
void setvar(int, int);
|
|
|
|
void decrypt(uint8 * mem, int len);
|
2007-01-16 12:40:51 +00:00
|
|
|
void releaseSprites();
|
|
|
|
int mainCycle();
|
|
|
|
int viewPictures();
|
|
|
|
int parseCli(int, char **);
|
|
|
|
int runGame();
|
2006-12-06 19:27:02 +00:00
|
|
|
void inventory();
|
2007-01-16 12:40:51 +00:00
|
|
|
void listGames();
|
|
|
|
uint32 matchCrc(uint32, char *, int);
|
|
|
|
int v2IdGame();
|
|
|
|
int v3IdGame();
|
|
|
|
int v4IdGame(uint32 ver);
|
|
|
|
void updateTimer();
|
|
|
|
int getAppDir(char *appDir, unsigned int size);
|
|
|
|
|
|
|
|
int setupV2Game(int ver, uint32 crc);
|
|
|
|
int setupV3Game(int ver, uint32 crc);
|
|
|
|
|
|
|
|
void newRoom(int n);
|
|
|
|
void resetControllers();
|
|
|
|
void interpretCycle();
|
|
|
|
int playGame();
|
2006-12-06 19:27:02 +00:00
|
|
|
|
|
|
|
void printItem(int n, int fg, int bg);
|
|
|
|
int findItem();
|
|
|
|
int showItems();
|
|
|
|
void selectItems(int n);
|
|
|
|
|
|
|
|
void processEvents();
|
|
|
|
|
|
|
|
// Objects
|
2007-01-16 12:40:51 +00:00
|
|
|
int showObjects();
|
|
|
|
int decodeObjects(uint8 *mem, uint32 flen);
|
|
|
|
int loadObjects(const char *fname);
|
|
|
|
int allocObjects(int);
|
|
|
|
void unloadObjects();
|
|
|
|
const char *objectName(unsigned int);
|
|
|
|
int objectGetLocation(unsigned int);
|
|
|
|
void objectSetLocation(unsigned int, int);
|
2006-12-06 19:27:02 +00:00
|
|
|
|
|
|
|
// Logic
|
2007-01-16 12:40:51 +00:00
|
|
|
int decodeLogic(int);
|
|
|
|
void unloadLogic(int);
|
|
|
|
int runLogic(int);
|
|
|
|
void patchLogic(int n);
|
2006-12-06 19:27:02 +00:00
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
void debugConsole(int, int, const char *);
|
|
|
|
int testIfCode(int);
|
|
|
|
void executeAgiCommand(uint8, uint8 *);
|
2006-12-06 19:27:02 +00:00
|
|
|
|
|
|
|
// View
|
|
|
|
private:
|
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
void lSetCel(VtEntry *v, int n);
|
|
|
|
void lSetLoop(VtEntry *v, int n);
|
|
|
|
void updateView(VtEntry *v);
|
2006-12-06 19:27:02 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
void setCel(VtEntry *, int);
|
|
|
|
void setLoop(VtEntry *, int);
|
|
|
|
void setView(VtEntry *, int);
|
|
|
|
void startUpdate(VtEntry *);
|
|
|
|
void stopUpdate(VtEntry *);
|
|
|
|
void updateViewtable();
|
|
|
|
void unloadView(int);
|
|
|
|
int decodeView(int);
|
|
|
|
void addToPic(int, int, int, int, int, int, int);
|
|
|
|
void drawObj(int);
|
|
|
|
bool isEgoView(const VtEntry *v);
|
2006-12-06 19:27:02 +00:00
|
|
|
|
|
|
|
// Words
|
2007-01-16 12:40:51 +00:00
|
|
|
int showWords();
|
|
|
|
int loadWords(const char *);
|
|
|
|
void unloadWords();
|
|
|
|
int findWord(char *word, int *flen);
|
|
|
|
void dictionaryWords(char *);
|
2006-12-06 19:27:02 +00:00
|
|
|
|
|
|
|
// Motion
|
|
|
|
private:
|
2007-01-16 12:40:51 +00:00
|
|
|
int checkStep(int delta, int step);
|
|
|
|
int checkBlock(int x, int y);
|
|
|
|
void changePos(VtEntry *v);
|
|
|
|
void motionWander(VtEntry *v);
|
|
|
|
void motionFollowEgo(VtEntry *v);
|
|
|
|
void motionMoveObj(VtEntry *v);
|
|
|
|
void checkMotion(VtEntry *v);
|
2006-12-06 19:27:02 +00:00
|
|
|
public:
|
2007-01-16 12:40:51 +00:00
|
|
|
void checkAllMotions();
|
|
|
|
void moveObj(VtEntry *);
|
|
|
|
void inDestination(VtEntry *);
|
|
|
|
void fixPosition(int);
|
|
|
|
void updatePosition();
|
|
|
|
int getDirection(int x0, int y0, int x, int y, int s);
|
2006-12-06 19:27:02 +00:00
|
|
|
|
|
|
|
// Keyboard
|
2007-01-16 12:40:51 +00:00
|
|
|
void initWords();
|
|
|
|
void cleanInput();
|
|
|
|
int doPollKeyboard();
|
|
|
|
void cleanKeyboard();
|
|
|
|
void handleKeys(int);
|
|
|
|
void handleGetstring(int);
|
|
|
|
int handleController(int);
|
|
|
|
void getString(int, int, int, int);
|
|
|
|
uint16 agiGetKeypress();
|
|
|
|
int waitKey();
|
|
|
|
int waitAnyKey();
|
2006-12-06 19:27:02 +00:00
|
|
|
|
|
|
|
// Text
|
|
|
|
public:
|
|
|
|
#define MAXWORDLEN 24
|
|
|
|
|
|
|
|
typedef Common::String String;
|
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
int messageBox(const char *);
|
|
|
|
int selectionBox(const char *, const char **);
|
|
|
|
void closeWindow(void);
|
|
|
|
void drawWindow(int, int, int, int);
|
|
|
|
void printText(const char *, int, int, int, int, int, int, bool checkerboard = false);
|
|
|
|
void printTextConsole(const char *, int, int, int, int, int);
|
2006-12-06 19:27:02 +00:00
|
|
|
int print(const char *, int, int, int);
|
2007-01-16 12:40:51 +00:00
|
|
|
char *wordWrapString(char *, int *);
|
|
|
|
char *agiSprintf(const char *);
|
|
|
|
void writeStatus(void);
|
|
|
|
void writePrompt(void);
|
|
|
|
void clearLines(int, int, int);
|
|
|
|
void flushLines(int, int);
|
2006-12-06 19:27:02 +00:00
|
|
|
bool predictiveDialog(void);
|
|
|
|
|
|
|
|
private:
|
2007-01-16 12:40:51 +00:00
|
|
|
void printStatus(const char *message, ...);
|
|
|
|
void printText2(int l, const char *msg, int foff, int xoff, int yoff, int len, int fg, int bg, bool checkerboard = false);
|
|
|
|
void blitTextbox(const char *p, int y, int x, int len);
|
|
|
|
void eraseTextbox();
|
|
|
|
char *safeStrcat(char *s, const char *t);
|
2006-12-06 19:27:02 +00:00
|
|
|
void loadDict(void);
|
|
|
|
bool matchWord(void);
|
|
|
|
|
|
|
|
typedef Common::HashMap<String, String, Common::CaseSensitiveString_Hash, Common::CaseSensitiveString_EqualTo> DictMap;
|
|
|
|
DictMap _dict;
|
|
|
|
Common::StringList _dictKeys;
|
|
|
|
String _currentCode;
|
|
|
|
String _currentWord;
|
|
|
|
String _matchedWord;
|
|
|
|
int _wordNumber;
|
|
|
|
uint _wordPosition;
|
|
|
|
bool _nextIsActive;
|
|
|
|
bool _addIsActive;
|
|
|
|
public:
|
|
|
|
char _predictiveResult[40];
|
|
|
|
};
|
2006-05-23 23:43:52 +00:00
|
|
|
|
2006-05-25 19:56:05 +00:00
|
|
|
} // End of namespace Agi
|
2006-05-23 23:43:52 +00:00
|
|
|
|
2006-05-25 19:56:05 +00:00
|
|
|
#endif // AGI_H
|