Whitespace fixes and C++ comments
svn-id: r41239
This commit is contained in:
parent
c585366ce9
commit
93d62da652
37 changed files with 1218 additions and 1040 deletions
|
@ -23,7 +23,6 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "common/md5.h"
|
#include "common/md5.h"
|
||||||
#include "common/events.h"
|
#include "common/events.h"
|
||||||
#include "common/file.h"
|
#include "common/file.h"
|
||||||
|
@ -291,7 +290,7 @@ void AgiEngine::agiTimerLow() {
|
||||||
int AgiEngine::agiGetKeypressLow() {
|
int AgiEngine::agiGetKeypressLow() {
|
||||||
int k;
|
int k;
|
||||||
|
|
||||||
while (_keyQueueStart == _keyQueueEnd) /* block */
|
while (_keyQueueStart == _keyQueueEnd) // block
|
||||||
agiTimerLow();
|
agiTimerLow();
|
||||||
keyDequeue(k);
|
keyDequeue(k);
|
||||||
|
|
||||||
|
@ -358,16 +357,16 @@ int AgiEngine::agiInit() {
|
||||||
debug(2, "initializing");
|
debug(2, "initializing");
|
||||||
debug(2, "game.ver = 0x%x", _game.ver);
|
debug(2, "game.ver = 0x%x", _game.ver);
|
||||||
|
|
||||||
/* initialize with adj.ego.move.to.x.y(0, 0) so to speak */
|
// initialize with adj.ego.move.to.x.y(0, 0) so to speak
|
||||||
_game.adjMouseX = _game.adjMouseY = 0;
|
_game.adjMouseX = _game.adjMouseY = 0;
|
||||||
|
|
||||||
/* reset all flags to false and all variables to 0 */
|
// reset all flags to false and all variables to 0
|
||||||
for (i = 0; i < MAX_FLAGS; i++)
|
for (i = 0; i < MAX_FLAGS; i++)
|
||||||
_game.flags[i] = 0;
|
_game.flags[i] = 0;
|
||||||
for (i = 0; i < MAX_VARS; i++)
|
for (i = 0; i < MAX_VARS; i++)
|
||||||
_game.vars[i] = 0;
|
_game.vars[i] = 0;
|
||||||
|
|
||||||
/* clear all resources and events */
|
// clear all resources and events
|
||||||
for (i = 0; i < MAX_DIRS; i++) {
|
for (i = 0; i < MAX_DIRS; i++) {
|
||||||
memset(&_game.views[i], 0, sizeof(struct AgiView));
|
memset(&_game.views[i], 0, sizeof(struct AgiView));
|
||||||
memset(&_game.pictures[i], 0, sizeof(struct AgiPicture));
|
memset(&_game.pictures[i], 0, sizeof(struct AgiPicture));
|
||||||
|
@ -379,7 +378,7 @@ int AgiEngine::agiInit() {
|
||||||
memset(&_game.dirSound[i], 0, sizeof(struct AgiDir));
|
memset(&_game.dirSound[i], 0, sizeof(struct AgiDir));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* clear view table */
|
// clear view table
|
||||||
for (i = 0; i < MAX_VIEWTABLE; i++)
|
for (i = 0; i < MAX_VIEWTABLE; i++)
|
||||||
memset(&_game.viewTable[i], 0, sizeof(VtEntry));
|
memset(&_game.viewTable[i], 0, sizeof(VtEntry));
|
||||||
|
|
||||||
|
@ -392,11 +391,11 @@ int AgiEngine::agiInit() {
|
||||||
|
|
||||||
initPriTable();
|
initPriTable();
|
||||||
|
|
||||||
/* clear string buffer */
|
// clear string buffer
|
||||||
for (i = 0; i < MAX_STRINGS; i++)
|
for (i = 0; i < MAX_STRINGS; i++)
|
||||||
_game.strings[i][0] = 0;
|
_game.strings[i][0] = 0;
|
||||||
|
|
||||||
/* setup emulation */
|
// setup emulation
|
||||||
|
|
||||||
switch (_loader->getIntVersion() >> 12) {
|
switch (_loader->getIntVersion() >> 12) {
|
||||||
case 2:
|
case 2:
|
||||||
|
@ -427,19 +426,19 @@ int AgiEngine::agiInit() {
|
||||||
if (_game.gameFlags & ID_AGDS)
|
if (_game.gameFlags & ID_AGDS)
|
||||||
report("AGDS mode enabled.\n");
|
report("AGDS mode enabled.\n");
|
||||||
|
|
||||||
ec = _loader->init(); /* load vol files, etc */
|
ec = _loader->init(); // load vol files, etc
|
||||||
|
|
||||||
if (ec == errOK)
|
if (ec == errOK)
|
||||||
ec = _loader->loadObjects(OBJECTS);
|
ec = _loader->loadObjects(OBJECTS);
|
||||||
|
|
||||||
/* note: demogs has no words.tok */
|
// note: demogs has no words.tok
|
||||||
if (ec == errOK)
|
if (ec == errOK)
|
||||||
ec = _loader->loadWords(WORDS);
|
ec = _loader->loadWords(WORDS);
|
||||||
|
|
||||||
/* FIXME: load IIgs instruments and samples */
|
// FIXME: load IIgs instruments and samples
|
||||||
/* load_instruments("kq.sys16"); */
|
// load_instruments("kq.sys16");
|
||||||
|
|
||||||
/* Load logic 0 into memory */
|
// Load logic 0 into memory
|
||||||
if (ec == errOK)
|
if (ec == errOK)
|
||||||
ec = _loader->loadResource(rLOGIC, 0);
|
ec = _loader->loadResource(rLOGIC, 0);
|
||||||
|
|
||||||
|
@ -459,7 +458,7 @@ int AgiEngine::agiInit() {
|
||||||
void AgiEngine::agiUnloadResources() {
|
void AgiEngine::agiUnloadResources() {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* Make sure logic 0 is always loaded */
|
// Make sure logic 0 is always loaded
|
||||||
for (i = 1; i < MAX_DIRS; i++) {
|
for (i = 1; i < MAX_DIRS; i++) {
|
||||||
_loader->unloadResource(rLOGIC, i);
|
_loader->unloadResource(rLOGIC, i);
|
||||||
}
|
}
|
||||||
|
@ -473,8 +472,8 @@ void AgiEngine::agiUnloadResources() {
|
||||||
int AgiEngine::agiDeinit() {
|
int AgiEngine::agiDeinit() {
|
||||||
int ec;
|
int ec;
|
||||||
|
|
||||||
cleanInput(); /* remove all words from memory */
|
cleanInput(); // remove all words from memory
|
||||||
agiUnloadResources(); /* unload resources in memory */
|
agiUnloadResources(); // unload resources in memory
|
||||||
_loader->unloadResource(rLOGIC, 0);
|
_loader->unloadResource(rLOGIC, 0);
|
||||||
ec = _loader->deinit();
|
ec = _loader->deinit();
|
||||||
unloadObjects();
|
unloadObjects();
|
||||||
|
@ -744,7 +743,7 @@ void AgiEngine::initialize() {
|
||||||
|
|
||||||
_timer->installTimerProc(agiTimerFunctionLow, 10 * 1000, NULL);
|
_timer->installTimerProc(agiTimerFunctionLow, 10 * 1000, NULL);
|
||||||
|
|
||||||
_game.ver = -1; /* Don't display the conf file warning */
|
_game.ver = -1; // Don't display the conf file warning
|
||||||
|
|
||||||
debugC(2, kDebugLevelMain, "Detect game");
|
debugC(2, kDebugLevelMain, "Detect game");
|
||||||
|
|
||||||
|
@ -805,7 +804,7 @@ Common::Error AgiEngine::go() {
|
||||||
mainCycle();
|
mainCycle();
|
||||||
} while (_game.state < STATE_RUNNING);
|
} while (_game.state < STATE_RUNNING);
|
||||||
if (_game.ver < 0)
|
if (_game.ver < 0)
|
||||||
_game.ver = 0; /* Enable conf file warning */
|
_game.ver = 0; // Enable conf file warning
|
||||||
}
|
}
|
||||||
|
|
||||||
runGame();
|
runGame();
|
||||||
|
|
|
@ -42,9 +42,9 @@ namespace Agi {
|
||||||
|
|
||||||
typedef signed int Err;
|
typedef signed int Err;
|
||||||
|
|
||||||
/*
|
//
|
||||||
* Version and other definitions
|
// Version and other definitions
|
||||||
*/
|
//
|
||||||
|
|
||||||
#define TITLE "AGI engine"
|
#define TITLE "AGI engine"
|
||||||
|
|
||||||
|
@ -59,9 +59,9 @@ typedef signed int Err;
|
||||||
#define MAX_DIRS 256
|
#define MAX_DIRS 256
|
||||||
#define MAX_VARS 256
|
#define MAX_VARS 256
|
||||||
#define MAX_FLAGS (256 >> 3)
|
#define MAX_FLAGS (256 >> 3)
|
||||||
#define MAX_VIEWTABLE 255 /* KQ3 uses o255! */
|
#define MAX_VIEWTABLE 255 // KQ3 uses o255!
|
||||||
#define MAX_WORDS 20
|
#define MAX_WORDS 20
|
||||||
#define MAX_STRINGS 24 /* MAX_STRINGS + 1 used for get.num */
|
#define MAX_STRINGS 24 // MAX_STRINGS + 1 used for get.num
|
||||||
#define MAX_STRINGLEN 40
|
#define MAX_STRINGLEN 40
|
||||||
#ifndef MAX_PATH
|
#ifndef MAX_PATH
|
||||||
#define MAX_PATH 260
|
#define MAX_PATH 260
|
||||||
|
@ -77,12 +77,12 @@ typedef signed int Err;
|
||||||
#define INLINE
|
#define INLINE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MSG_BOX_COLOUR 0x0f /* White */
|
#define MSG_BOX_COLOUR 0x0f // White
|
||||||
#define MSG_BOX_TEXT 0x00 /* Black */
|
#define MSG_BOX_TEXT 0x00 // Black
|
||||||
#define MSG_BOX_LINE 0x04 /* Red */
|
#define MSG_BOX_LINE 0x04 // Red
|
||||||
#define BUTTON_BORDER 0x00 /* Black */
|
#define BUTTON_BORDER 0x00 // Black
|
||||||
#define STATUS_FG 0x00 /* Black */
|
#define STATUS_FG 0x00 // Black
|
||||||
#define STATUS_BG 0x0f /* White */
|
#define STATUS_BG 0x0f // White
|
||||||
|
|
||||||
#define ADD_PIC 1
|
#define ADD_PIC 1
|
||||||
#define ADD_VIEW 2
|
#define ADD_VIEW 2
|
||||||
|
@ -113,7 +113,7 @@ enum AgiGameID {
|
||||||
|
|
||||||
} // End of namespace Agi
|
} // End of namespace Agi
|
||||||
|
|
||||||
/* AGI resources */
|
// AGI resources
|
||||||
#include "agi/console.h"
|
#include "agi/console.h"
|
||||||
#include "agi/view.h"
|
#include "agi/view.h"
|
||||||
#include "agi/picture.h"
|
#include "agi/picture.h"
|
||||||
|
@ -128,13 +128,13 @@ enum AgiGameType {
|
||||||
GType_V3 = 2
|
GType_V3 = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
//
|
||||||
* GF_OLDAMIGAV20 means that the interpreter is an old Amiga AGI interpreter that
|
// GF_OLDAMIGAV20 means that the interpreter is an old Amiga AGI interpreter that
|
||||||
* uses value 20 for the computer type (v20 i.e. vComputer) rather than the usual value 5.
|
// uses value 20 for the computer type (v20 i.e. vComputer) rather than the usual value 5.
|
||||||
*
|
//
|
||||||
* GF_CLIPCOORDS means that views' coordinates must be clipped at least in commands
|
// GF_CLIPCOORDS means that views' coordinates must be clipped at least in commands
|
||||||
* position and position.v.
|
// position and position.v.
|
||||||
*/
|
//
|
||||||
enum AgiGameFeatures {
|
enum AgiGameFeatures {
|
||||||
GF_AGIMOUSE = (1 << 0),
|
GF_AGIMOUSE = (1 << 0),
|
||||||
GF_AGDS = (1 << 1),
|
GF_AGDS = (1 << 1),
|
||||||
|
@ -241,32 +241,32 @@ enum GameId {
|
||||||
* AGI variables.
|
* AGI variables.
|
||||||
*/
|
*/
|
||||||
enum {
|
enum {
|
||||||
vCurRoom = 0, /* 0 */
|
vCurRoom = 0, // 0
|
||||||
vPrevRoom,
|
vPrevRoom,
|
||||||
vBorderTouchEgo,
|
vBorderTouchEgo,
|
||||||
vScore,
|
vScore,
|
||||||
vBorderCode,
|
vBorderCode,
|
||||||
vBorderTouchObj, /* 5 */
|
vBorderTouchObj, // 5
|
||||||
vEgoDir,
|
vEgoDir,
|
||||||
vMaxScore,
|
vMaxScore,
|
||||||
vFreePages,
|
vFreePages,
|
||||||
vWordNotFound,
|
vWordNotFound,
|
||||||
vTimeDelay, /* 10 */
|
vTimeDelay, // 10
|
||||||
vSeconds,
|
vSeconds,
|
||||||
vMinutes,
|
vMinutes,
|
||||||
vHours,
|
vHours,
|
||||||
vDays,
|
vDays,
|
||||||
vJoystickSensitivity, /* 15 */
|
vJoystickSensitivity, // 15
|
||||||
vEgoViewResource,
|
vEgoViewResource,
|
||||||
vAgiErrCode,
|
vAgiErrCode,
|
||||||
vAgiErrCodeInfo,
|
vAgiErrCodeInfo,
|
||||||
vKey,
|
vKey,
|
||||||
vComputer, /* 20 */
|
vComputer, // 20
|
||||||
vWindowReset,
|
vWindowReset,
|
||||||
vSoundgen,
|
vSoundgen,
|
||||||
vVolume,
|
vVolume,
|
||||||
vMaxInputChars,
|
vMaxInputChars,
|
||||||
vSelItem, /* 25 */
|
vSelItem, // 25
|
||||||
vMonitor
|
vMonitor
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -315,22 +315,22 @@ enum AgiComputerType {
|
||||||
* AGI flags
|
* AGI flags
|
||||||
*/
|
*/
|
||||||
enum {
|
enum {
|
||||||
fEgoWater = 0, /* 0 */
|
fEgoWater = 0, // 0
|
||||||
fEgoInvisible,
|
fEgoInvisible,
|
||||||
fEnteredCli,
|
fEnteredCli,
|
||||||
fEgoTouchedP2,
|
fEgoTouchedP2,
|
||||||
fSaidAcceptedInput,
|
fSaidAcceptedInput,
|
||||||
fNewRoomExec, /* 5 */
|
fNewRoomExec, // 5
|
||||||
fRestartGame,
|
fRestartGame,
|
||||||
fScriptBlocked,
|
fScriptBlocked,
|
||||||
fJoySensitivity,
|
fJoySensitivity,
|
||||||
fSoundOn,
|
fSoundOn,
|
||||||
fDebuggerOn, /* 10 */
|
fDebuggerOn, // 10
|
||||||
fLogicZeroFirsttime,
|
fLogicZeroFirsttime,
|
||||||
fRestoreJustRan,
|
fRestoreJustRan,
|
||||||
fStatusSelectsItems,
|
fStatusSelectsItems,
|
||||||
fMenusWork,
|
fMenusWork,
|
||||||
fOutputMode, /* 15 */
|
fOutputMode, // 15
|
||||||
fAutoRestart,
|
fAutoRestart,
|
||||||
fNoSaveLoadAllowed
|
fNoSaveLoadAllowed
|
||||||
};
|
};
|
||||||
|
@ -355,20 +355,20 @@ struct AgiDir {
|
||||||
uint32 offset;
|
uint32 offset;
|
||||||
uint32 len;
|
uint32 len;
|
||||||
uint32 clen;
|
uint32 clen;
|
||||||
|
|
||||||
|
// 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
|
||||||
uint8 flags;
|
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
|
|
||||||
*/
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct AgiBlock {
|
struct AgiBlock {
|
||||||
int active;
|
int active;
|
||||||
int x1, y1;
|
int x1, y1;
|
||||||
int x2, y2;
|
int x2, y2;
|
||||||
uint8 *buffer; /* used for window background */
|
uint8 *buffer; // used for window background
|
||||||
};
|
};
|
||||||
|
|
||||||
/** AGI text color (Background and foreground color). */
|
/** AGI text color (Background and foreground color). */
|
||||||
|
@ -508,11 +508,11 @@ struct AgiGame {
|
||||||
char id[8]; /**< game id */
|
char id[8]; /**< game id */
|
||||||
uint32 crc; /**< game CRC */
|
uint32 crc; /**< game CRC */
|
||||||
|
|
||||||
/* game flags and variables */
|
// game flags and variables
|
||||||
uint8 flags[MAX_FLAGS]; /**< 256 1-bit flags */
|
uint8 flags[MAX_FLAGS]; /**< 256 1-bit flags */
|
||||||
uint8 vars[MAX_VARS]; /**< 256 variables */
|
uint8 vars[MAX_VARS]; /**< 256 variables */
|
||||||
|
|
||||||
/* internal variables */
|
// internal variables
|
||||||
int horizon; /**< horizon y coordinate */
|
int horizon; /**< horizon y coordinate */
|
||||||
int lineStatus; /**< line number to put status on */
|
int lineStatus; /**< line number to put status on */
|
||||||
int lineUserInput; /**< line to put user input on */
|
int lineUserInput; /**< line to put user input on */
|
||||||
|
@ -529,7 +529,7 @@ struct AgiGame {
|
||||||
int inputEnabled; /**< keyboard input enabled */
|
int inputEnabled; /**< keyboard input enabled */
|
||||||
int lognum; /**< current logic number */
|
int lognum; /**< current logic number */
|
||||||
|
|
||||||
/* internal flags */
|
// internal flags
|
||||||
int playerControl; /**< player is in control */
|
int playerControl; /**< player is in control */
|
||||||
int statusLine; /**< status line on/off */
|
int statusLine; /**< status line on/off */
|
||||||
int clockEnabled; /**< clock is on/off */
|
int clockEnabled; /**< clock is on/off */
|
||||||
|
@ -542,13 +542,13 @@ struct AgiGame {
|
||||||
|
|
||||||
uint8 priTable[_HEIGHT];/**< priority table */
|
uint8 priTable[_HEIGHT];/**< priority table */
|
||||||
|
|
||||||
/* windows */
|
// windows
|
||||||
uint32 msgBoxTicks; /**< timed message box tick counter */
|
uint32 msgBoxTicks; /**< timed message box tick counter */
|
||||||
AgiBlock block;
|
AgiBlock block;
|
||||||
AgiBlock window;
|
AgiBlock window;
|
||||||
int hasWindow;
|
int hasWindow;
|
||||||
|
|
||||||
/* graphics & text */
|
// graphics & text
|
||||||
int gfxMode;
|
int gfxMode;
|
||||||
char cursorChar;
|
char cursorChar;
|
||||||
unsigned int colorFg;
|
unsigned int colorFg;
|
||||||
|
@ -562,7 +562,7 @@ struct AgiGame {
|
||||||
uint8 *sbuf256c; /**< 160x168 256 color AGI screen buffer (For AGI256 and AGI256-2 support). Points at sbufOrig + SBUF256_OFFSET. */
|
uint8 *sbuf256c; /**< 160x168 256 color AGI screen buffer (For AGI256 and AGI256-2 support). Points at sbufOrig + SBUF256_OFFSET. */
|
||||||
uint8 *sbuf; /**< Currently chosen AGI screen buffer (sbuf256c if AGI256 or AGI256-2 is used, otherwise sbuf16c). */
|
uint8 *sbuf; /**< Currently chosen AGI screen buffer (sbuf256c if AGI256 or AGI256-2 is used, otherwise sbuf16c). */
|
||||||
|
|
||||||
/* player command line */
|
// player command line
|
||||||
AgiWord egoWords[MAX_WORDS];
|
AgiWord egoWords[MAX_WORDS];
|
||||||
int numEgoWords;
|
int numEgoWords;
|
||||||
|
|
||||||
|
@ -571,19 +571,19 @@ struct AgiGame {
|
||||||
AgiEvent evKeyp[MAX_DIRS]; /**< keyboard keypress events */
|
AgiEvent evKeyp[MAX_DIRS]; /**< keyboard keypress events */
|
||||||
char strings[MAX_STRINGS + 1][MAX_STRINGLEN]; /**< strings */
|
char strings[MAX_STRINGS + 1][MAX_STRINGLEN]; /**< strings */
|
||||||
|
|
||||||
/* directory entries for resources */
|
// directory entries for resources
|
||||||
AgiDir dirLogic[MAX_DIRS];
|
AgiDir dirLogic[MAX_DIRS];
|
||||||
AgiDir dirPic[MAX_DIRS];
|
AgiDir dirPic[MAX_DIRS];
|
||||||
AgiDir dirView[MAX_DIRS];
|
AgiDir dirView[MAX_DIRS];
|
||||||
AgiDir dirSound[MAX_DIRS];
|
AgiDir dirSound[MAX_DIRS];
|
||||||
|
|
||||||
/* resources */
|
// resources
|
||||||
AgiPicture pictures[MAX_DIRS]; /**< AGI picture resources */
|
AgiPicture pictures[MAX_DIRS]; /**< AGI picture resources */
|
||||||
AgiLogic logics[MAX_DIRS]; /**< AGI logic resources */
|
AgiLogic logics[MAX_DIRS]; /**< AGI logic resources */
|
||||||
AgiView views[MAX_DIRS]; /**< AGI view resources */
|
AgiView views[MAX_DIRS]; /**< AGI view resources */
|
||||||
AgiSound *sounds[MAX_DIRS]; /**< Pointers to AGI sound resources */
|
AgiSound *sounds[MAX_DIRS]; /**< Pointers to AGI sound resources */
|
||||||
|
|
||||||
/* view table */
|
// view table
|
||||||
VtEntry viewTable[MAX_VIEWTABLE];
|
VtEntry viewTable[MAX_VIEWTABLE];
|
||||||
|
|
||||||
int32 ver; /**< detected game version */
|
int32 ver; /**< detected game version */
|
||||||
|
@ -670,7 +670,7 @@ class SearchTree;
|
||||||
|
|
||||||
extern struct Mouse g_mouse;
|
extern struct Mouse g_mouse;
|
||||||
|
|
||||||
/* Image stack support */
|
// Image stack support
|
||||||
struct ImageStackElement {
|
struct ImageStackElement {
|
||||||
uint8 type;
|
uint8 type;
|
||||||
uint8 pad;
|
uint8 pad;
|
||||||
|
@ -792,7 +792,7 @@ private:
|
||||||
int _firstSlot;
|
int _firstSlot;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AgiObject *_objects; /* objects in the game */
|
AgiObject *_objects; // objects in the game
|
||||||
|
|
||||||
StringData _stringdata;
|
StringData _stringdata;
|
||||||
|
|
||||||
|
@ -817,7 +817,7 @@ public:
|
||||||
SpritesMgr *_sprites;
|
SpritesMgr *_sprites;
|
||||||
SoundMgr *_sound;
|
SoundMgr *_sound;
|
||||||
PictureMgr *_picture;
|
PictureMgr *_picture;
|
||||||
AgiLoader *_loader; /* loader */
|
AgiLoader *_loader; // loader
|
||||||
|
|
||||||
Common::Stack<ImageStackElement> _imageStack;
|
Common::Stack<ImageStackElement> _imageStack;
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "agi/agi.h"
|
#include "agi/agi.h"
|
||||||
|
|
||||||
namespace Agi {
|
namespace Agi {
|
||||||
|
@ -41,7 +40,7 @@ int AgiEngine::checkPosition(VtEntry *v) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* MH1 needs this, but it breaks LSL1 */
|
// MH1 needs this, but it breaks LSL1
|
||||||
if (agiGetRelease() >= 0x3000) {
|
if (agiGetRelease() >= 0x3000) {
|
||||||
if (v->yPos < v->ySize)
|
if (v->yPos < v->ySize)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -66,21 +65,21 @@ int AgiEngine::checkCollision(VtEntry *v) {
|
||||||
if (u->flags & IGNORE_OBJECTS)
|
if (u->flags & IGNORE_OBJECTS)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* Same object, check next */
|
// Same object, check next
|
||||||
if (v->entry == u->entry)
|
if (v->entry == u->entry)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* No horizontal overlap, check next */
|
// No horizontal overlap, check next
|
||||||
if (v->xPos + v->xSize < u->xPos || v->xPos > u->xPos + u->xSize)
|
if (v->xPos + v->xSize < u->xPos || v->xPos > u->xPos + u->xSize)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* Same y, return error! */
|
// Same y, return error!
|
||||||
if (v->yPos == u->yPos) {
|
if (v->yPos == u->yPos) {
|
||||||
debugC(4, kDebugLevelSprites, "check returns 1 (object %d)", v->entry);
|
debugC(4, kDebugLevelSprites, "check returns 1 (object %d)", v->entry);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Crossed the baseline, return error! */
|
// Crossed the baseline, return error!
|
||||||
if ((v->yPos > u->yPos && v->yPos2 < u->yPos2) ||
|
if ((v->yPos > u->yPos && v->yPos2 < u->yPos2) ||
|
||||||
(v->yPos < u->yPos && v->yPos2 > u->yPos2)) {
|
(v->yPos < u->yPos && v->yPos2 > u->yPos2)) {
|
||||||
debugC(4, kDebugLevelSprites, "check returns 1 (object %d)", v->entry);
|
debugC(4, kDebugLevelSprites, "check returns 1 (object %d)", v->entry);
|
||||||
|
@ -97,7 +96,7 @@ int AgiEngine::checkPriority(VtEntry *v) {
|
||||||
uint8 *p0;
|
uint8 *p0;
|
||||||
|
|
||||||
if (~v->flags & FIXED_PRIORITY) {
|
if (~v->flags & FIXED_PRIORITY) {
|
||||||
/* Priority bands */
|
// Priority bands
|
||||||
v->priority = _game.priTable[v->yPos];
|
v->priority = _game.priTable[v->yPos];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,17 +121,17 @@ int AgiEngine::checkPriority(VtEntry *v) {
|
||||||
for (i = 0; i < v->xSize; i++, p0++) {
|
for (i = 0; i < v->xSize; i++, p0++) {
|
||||||
pri = *p0 >> 4;
|
pri = *p0 >> 4;
|
||||||
|
|
||||||
if (pri == 0) { /* unconditional black. no go at all! */
|
if (pri == 0) { // unconditional black. no go at all!
|
||||||
pass = 0;
|
pass = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pri == 3) /* water surface */
|
if (pri == 3) // water surface
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
water = 0;
|
water = 0;
|
||||||
|
|
||||||
if (pri == 1) { /* conditional blue */
|
if (pri == 1) { // conditional blue
|
||||||
if (v->flags & IGNORE_BLOCKS)
|
if (v->flags & IGNORE_BLOCKS)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -141,7 +140,7 @@ int AgiEngine::checkPriority(VtEntry *v) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pri == 2) { /* trigger */
|
if (pri == 2) { // trigger
|
||||||
debugC(4, kDebugLevelSprites, "stepped on trigger");
|
debugC(4, kDebugLevelSprites, "stepped on trigger");
|
||||||
if (!_debug.ignoretriggers)
|
if (!_debug.ignoretriggers)
|
||||||
trigger = 1;
|
trigger = 1;
|
||||||
|
@ -198,7 +197,7 @@ void AgiEngine::updatePosition() {
|
||||||
x = oldX = v->xPos;
|
x = oldX = v->xPos;
|
||||||
y = oldY = v->yPos;
|
y = oldY = v->yPos;
|
||||||
|
|
||||||
/* If object has moved, update its position */
|
// If object has moved, update its position
|
||||||
if (~v->flags & UPDATE_POS) {
|
if (~v->flags & UPDATE_POS) {
|
||||||
int dx[9] = { 0, 0, 1, 1, 1, 0, -1, -1, -1 };
|
int dx[9] = { 0, 0, 1, 1, 1, 0, -1, -1, -1 };
|
||||||
int dy[9] = { 0, -1, -1, 0, 1, 1, 1, 0, -1 };
|
int dy[9] = { 0, -1, -1, 0, 1, 1, 1, 0, -1 };
|
||||||
|
@ -206,18 +205,18 @@ void AgiEngine::updatePosition() {
|
||||||
y += v->stepSize * dy[v->direction];
|
y += v->stepSize * dy[v->direction];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now check if it touched the borders */
|
// Now check if it touched the borders
|
||||||
border = 0;
|
border = 0;
|
||||||
|
|
||||||
/* Check left/right borders */
|
// Check left/right borders
|
||||||
if (x < 0) {
|
if (x < 0) {
|
||||||
x = 0;
|
x = 0;
|
||||||
border = 4;
|
border = 4;
|
||||||
} else if (x <= 0 && agiGetRelease() == 0x3086) { /* KQ4 */
|
} else if (x <= 0 && agiGetRelease() == 0x3086) { // KQ4
|
||||||
x = 0; /* See Sarien bug #590462 */
|
x = 0; // See Sarien bug #590462
|
||||||
border = 4;
|
border = 4;
|
||||||
} else if (v->entry == 0 && x == 0 && v->flags & ADJ_EGO_XY) {
|
} else if (v->entry == 0 && x == 0 && v->flags & ADJ_EGO_XY) {
|
||||||
/* Extra test to walk west clicking the mouse */
|
// Extra test to walk west clicking the mouse
|
||||||
x = 0;
|
x = 0;
|
||||||
border = 4;
|
border = 4;
|
||||||
} else if (x + v->xSize > _WIDTH) {
|
} else if (x + v->xSize > _WIDTH) {
|
||||||
|
@ -225,7 +224,7 @@ void AgiEngine::updatePosition() {
|
||||||
border = 2;
|
border = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check top/bottom borders. */
|
// Check top/bottom borders.
|
||||||
if (y - v->ySize + 1 < 0) {
|
if (y - v->ySize + 1 < 0) {
|
||||||
y = v->ySize - 1;
|
y = v->ySize - 1;
|
||||||
border = 1;
|
border = 1;
|
||||||
|
@ -238,7 +237,7 @@ void AgiEngine::updatePosition() {
|
||||||
border = 1;
|
border = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Test new position. rollback if test fails */
|
// Test new position. rollback if test fails
|
||||||
v->xPos = x;
|
v->xPos = x;
|
||||||
v->yPos = y;
|
v->yPos = y;
|
||||||
if (checkCollision(v) || !checkPriority(v)) {
|
if (checkCollision(v) || !checkPriority(v)) {
|
||||||
|
@ -279,7 +278,7 @@ void AgiEngine::fixPosition(int n) {
|
||||||
|
|
||||||
debugC(4, kDebugLevelSprites, "adjusting view table entry #%d (%d,%d)", n, v->xPos, v->yPos);
|
debugC(4, kDebugLevelSprites, "adjusting view table entry #%d (%d,%d)", n, v->xPos, v->yPos);
|
||||||
|
|
||||||
/* test horizon */
|
// test horizon
|
||||||
if ((~v->flags & IGNORE_HORIZON) && v->yPos <= _game.horizon)
|
if ((~v->flags & IGNORE_HORIZON) && v->yPos <= _game.horizon)
|
||||||
v->yPos = _game.horizon + 1;
|
v->yPos = _game.horizon + 1;
|
||||||
|
|
||||||
|
@ -288,26 +287,26 @@ void AgiEngine::fixPosition(int n) {
|
||||||
|
|
||||||
while (!checkPosition(v) || checkCollision(v) || !checkPriority(v)) {
|
while (!checkPosition(v) || checkCollision(v) || !checkPriority(v)) {
|
||||||
switch (dir) {
|
switch (dir) {
|
||||||
case 0: /* west */
|
case 0: // west
|
||||||
v->xPos--;
|
v->xPos--;
|
||||||
if (--count)
|
if (--count)
|
||||||
continue;
|
continue;
|
||||||
dir = 1;
|
dir = 1;
|
||||||
break;
|
break;
|
||||||
case 1: /* south */
|
case 1: // south
|
||||||
v->yPos++;
|
v->yPos++;
|
||||||
if (--count)
|
if (--count)
|
||||||
continue;
|
continue;
|
||||||
dir = 2;
|
dir = 2;
|
||||||
size++;
|
size++;
|
||||||
break;
|
break;
|
||||||
case 2: /* east */
|
case 2: // east
|
||||||
v->xPos++;
|
v->xPos++;
|
||||||
if (--count)
|
if (--count)
|
||||||
continue;
|
continue;
|
||||||
dir = 3;
|
dir = 3;
|
||||||
break;
|
break;
|
||||||
case 3: /* north */
|
case 3: // north
|
||||||
v->yPos--;
|
v->yPos--;
|
||||||
if (--count)
|
if (--count)
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "agi/agi.h"
|
#include "agi/agi.h"
|
||||||
#include "agi/sprite.h"
|
#include "agi/sprite.h"
|
||||||
#include "agi/graphics.h"
|
#include "agi/graphics.h"
|
||||||
|
@ -68,7 +67,7 @@ void AgiEngine::newRoom(int n) {
|
||||||
|
|
||||||
agiLoadResource(rLOGIC, n);
|
agiLoadResource(rLOGIC, n);
|
||||||
|
|
||||||
/* Reposition ego in the new room */
|
// Reposition ego in the new room
|
||||||
switch (_game.vars[vBorderTouchEgo]) {
|
switch (_game.vars[vBorderTouchEgo]) {
|
||||||
case 1:
|
case 1:
|
||||||
_game.viewTable[0].yPos = _HEIGHT - 1;
|
_game.viewTable[0].yPos = _HEIGHT - 1;
|
||||||
|
@ -183,12 +182,12 @@ void AgiEngine::oldInputMode() {
|
||||||
_game.inputMode = _oldMode;
|
_game.inputMode = _oldMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If main_cycle returns false, don't process more events! */
|
// If main_cycle returns false, don't process more events!
|
||||||
int AgiEngine::mainCycle() {
|
int AgiEngine::mainCycle() {
|
||||||
unsigned int key, kascii;
|
unsigned int key, kascii;
|
||||||
VtEntry *v = &_game.viewTable[0];
|
VtEntry *v = &_game.viewTable[0];
|
||||||
|
|
||||||
_gfx->pollTimer(); /* msdos driver -> does nothing */
|
_gfx->pollTimer(); // msdos driver -> does nothing
|
||||||
updateTimer();
|
updateTimer();
|
||||||
|
|
||||||
if (_game.ver == 0) {
|
if (_game.ver == 0) {
|
||||||
|
@ -198,9 +197,8 @@ int AgiEngine::mainCycle() {
|
||||||
|
|
||||||
key = doPollKeyboard();
|
key = doPollKeyboard();
|
||||||
|
|
||||||
/* In AGI Mouse emulation mode we must update the mouse-related
|
// In AGI Mouse emulation mode we must update the mouse-related
|
||||||
* vars in every interpreter cycle.
|
// vars in every interpreter cycle.
|
||||||
*/
|
|
||||||
if (getFeatures() & GF_AGIMOUSE) {
|
if (getFeatures() & GF_AGIMOUSE) {
|
||||||
_game.vars[28] = g_mouse.x / 2;
|
_game.vars[28] = g_mouse.x / 2;
|
||||||
_game.vars[29] = g_mouse.y;
|
_game.vars[29] = g_mouse.y;
|
||||||
|
@ -220,7 +218,7 @@ int AgiEngine::mainCycle() {
|
||||||
key = 0;
|
key = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Click-to-walk mouse interface */
|
// Click-to-walk mouse interface
|
||||||
if (_game.playerControl && v->flags & ADJ_EGO_XY) {
|
if (_game.playerControl && v->flags & ADJ_EGO_XY) {
|
||||||
int toX = v->parm1;
|
int toX = v->parm1;
|
||||||
int toY = v->parm2;
|
int toY = v->parm2;
|
||||||
|
@ -257,25 +255,25 @@ process_key:
|
||||||
break;
|
break;
|
||||||
handleKeys(key);
|
handleKeys(key);
|
||||||
|
|
||||||
/* if ESC pressed, activate menu before
|
// if ESC pressed, activate menu before
|
||||||
* accept.input from the interpreter cycle
|
// accept.input from the interpreter cycle
|
||||||
* sets the input mode to normal again
|
// sets the input mode to normal again
|
||||||
* (closes: #540856)
|
// (closes: #540856)
|
||||||
*/
|
|
||||||
if (key == KEY_ESCAPE) {
|
if (key == KEY_ESCAPE) {
|
||||||
key = 0;
|
key = 0;
|
||||||
goto process_key;
|
goto process_key;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* commented out to close Sarien bug #438872
|
// commented out to close Sarien bug #438872
|
||||||
* if (key) game.keypress = key;
|
// if (key)
|
||||||
*/
|
// game.keypress = key;
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case INPUT_GETSTRING:
|
case INPUT_GETSTRING:
|
||||||
handleController(key);
|
handleController(key);
|
||||||
handleGetstring(key);
|
handleGetstring(key);
|
||||||
setvar(vKey, 0); /* clear ENTER key */
|
setvar(vKey, 0); // clear ENTER key
|
||||||
break;
|
break;
|
||||||
case INPUT_MENU:
|
case INPUT_MENU:
|
||||||
_menu->keyhandler(key);
|
_menu->keyhandler(key);
|
||||||
|
@ -307,10 +305,10 @@ int AgiEngine::playGame() {
|
||||||
_game.horizon = HORIZON;
|
_game.horizon = HORIZON;
|
||||||
_game.playerControl = false;
|
_game.playerControl = false;
|
||||||
|
|
||||||
setflag(fLogicZeroFirsttime, true); /* not in 2.917 */
|
setflag(fLogicZeroFirsttime, true); // not in 2.917
|
||||||
setflag(fNewRoomExec, true); /* needed for MUMG and SQ2! */
|
setflag(fNewRoomExec, true); // needed for MUMG and SQ2!
|
||||||
setflag(fSoundOn, true); /* enable sound */
|
setflag(fSoundOn, true); // enable sound
|
||||||
setvar(vTimeDelay, 2); /* "normal" speed */
|
setvar(vTimeDelay, 2); // "normal" speed
|
||||||
|
|
||||||
_game.gfxMode = true;
|
_game.gfxMode = true;
|
||||||
_game.clockEnabled = true;
|
_game.clockEnabled = true;
|
||||||
|
@ -378,7 +376,7 @@ int AgiEngine::runGame() {
|
||||||
for (i = 0; i < MAX_DIRS; i++)
|
for (i = 0; i < MAX_DIRS; i++)
|
||||||
memset(&_game.evKeyp[i], 0, sizeof(struct AgiEvent));
|
memset(&_game.evKeyp[i], 0, sizeof(struct AgiEvent));
|
||||||
|
|
||||||
/* Execute the game */
|
// Execute the game
|
||||||
do {
|
do {
|
||||||
debugC(2, kDebugLevelMain, "game loop");
|
debugC(2, kDebugLevelMain, "game loop");
|
||||||
debugC(2, kDebugLevelMain, "game.ver = 0x%x", _game.ver);
|
debugC(2, kDebugLevelMain, "game.ver = 0x%x", _game.ver);
|
||||||
|
@ -411,7 +409,7 @@ int AgiEngine::runGame() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
setvar(vSoundgen, 1); /* IBM PC SOUND */
|
setvar(vSoundgen, 1); // IBM PC SOUND
|
||||||
|
|
||||||
// Set monitor type (v26 i.e. vMonitor)
|
// Set monitor type (v26 i.e. vMonitor)
|
||||||
switch (_renderMode) {
|
switch (_renderMode) {
|
||||||
|
|
|
@ -26,25 +26,23 @@
|
||||||
#ifndef AGI_FONT_H
|
#ifndef AGI_FONT_H
|
||||||
#define AGI_FONT_H
|
#define AGI_FONT_H
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "agi/agi.h"
|
#include "agi/agi.h"
|
||||||
|
|
||||||
namespace Agi {
|
namespace Agi {
|
||||||
|
|
||||||
/* 8x8 font patterns */
|
// 8x8 font patterns
|
||||||
static const uint8 curFont[] = {
|
static const uint8 curFont[] = {
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x7E, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x7E, /* cursor hollow */
|
0x7E, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x7E, // cursor hollow
|
||||||
0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, /* cursor solid */
|
0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, // cursor solid
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* cursor empty */
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // cursor empty
|
||||||
0x10, 0x38, 0x7C, 0xFE, 0x7C, 0x38, 0x10, 0x00,
|
0x10, 0x38, 0x7C, 0xFE, 0x7C, 0x38, 0x10, 0x00,
|
||||||
0x3C, 0x3C, 0x18, 0xFF, 0xE7, 0x18, 0x3C, 0x00,
|
0x3C, 0x3C, 0x18, 0xFF, 0xE7, 0x18, 0x3C, 0x00,
|
||||||
0x10, 0x38, 0x7C, 0xFE, 0xEE, 0x10, 0x38, 0x00,
|
0x10, 0x38, 0x7C, 0xFE, 0xEE, 0x10, 0x38, 0x00,
|
||||||
0x00, 0x00, 0x18, 0x3C, 0x3C, 0x18, 0x00, 0x00,
|
0x00, 0x00, 0x18, 0x3C, 0x3C, 0x18, 0x00, 0x00,
|
||||||
0xFF, 0xFF, 0xE7, 0xC3, 0xC3, 0xE7, 0xFF, 0xFF,
|
0xFF, 0xFF, 0xE7, 0xC3, 0xC3, 0xE7, 0xFF, 0xFF,
|
||||||
0x00, 0x3C, 0x66, 0x42, 0x42, 0x66, 0x3C, 0x00,
|
0x00, 0x3C, 0x66, 0x42, 0x42, 0x66, 0x3C, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* \n */
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // \n
|
||||||
0x0F, 0x07, 0x0F, 0x7D, 0xCC, 0xCC, 0xCC, 0x78,
|
0x0F, 0x07, 0x0F, 0x7D, 0xCC, 0xCC, 0xCC, 0x78,
|
||||||
0x3C, 0x66, 0x66, 0x66, 0x3C, 0x18, 0x7E, 0x18,
|
0x3C, 0x66, 0x66, 0x66, 0x3C, 0x18, 0x7E, 0x18,
|
||||||
0x08, 0x0C, 0x0A, 0x0A, 0x08, 0x78, 0xF0, 0x00,
|
0x08, 0x0C, 0x0A, 0x0A, 0x08, 0x78, 0xF0, 0x00,
|
||||||
|
@ -161,8 +159,8 @@ static const uint8 curFont[] = {
|
||||||
0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x00,
|
0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x00,
|
||||||
0xE0, 0x30, 0x30, 0x18, 0x30, 0x30, 0xE0, 0x00,
|
0xE0, 0x30, 0x30, 0x18, 0x30, 0x30, 0xE0, 0x00,
|
||||||
0x76, 0xDC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x76, 0xDC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
/*0x00, 0x10, 0x38, 0x6C, 0xC6, 0xC6, 0xFE, 0x00, */
|
//0x00, 0x10, 0x38, 0x6C, 0xC6, 0xC6, 0xFE, 0x00,
|
||||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /*replacement 0x7F */
|
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, //replacement 0x7F
|
||||||
|
|
||||||
0x1E, 0x36, 0x66, 0x66, 0x7E, 0x66, 0x66, 0x00,
|
0x1E, 0x36, 0x66, 0x66, 0x7E, 0x66, 0x66, 0x00,
|
||||||
0x7C, 0x60, 0x60, 0x7C, 0x66, 0x66, 0x7C, 0x00,
|
0x7C, 0x60, 0x60, 0x7C, 0x66, 0x66, 0x7C, 0x00,
|
||||||
|
|
|
@ -23,8 +23,6 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "agi/agi.h"
|
#include "agi/agi.h"
|
||||||
|
|
||||||
namespace Agi {
|
namespace Agi {
|
||||||
|
@ -41,16 +39,16 @@ void AgiBase::setflag(int n, int v) {
|
||||||
|
|
||||||
set += n >> 3;
|
set += n >> 3;
|
||||||
if (v)
|
if (v)
|
||||||
*set |= 1 << (n & 0x07); /* set bit */
|
*set |= 1 << (n & 0x07); // set bit
|
||||||
else
|
else
|
||||||
*set &= ~(1 << (n & 0x07)); /* clear bit */
|
*set &= ~(1 << (n & 0x07)); // clear bit
|
||||||
}
|
}
|
||||||
|
|
||||||
void AgiBase::flipflag(int n) {
|
void AgiBase::flipflag(int n) {
|
||||||
uint8 *set = (uint8 *)&_game.flags;
|
uint8 *set = (uint8 *)&_game.flags;
|
||||||
|
|
||||||
set += n >> 3;
|
set += n >> 3;
|
||||||
*set ^= 1 << (n & 0x07); /* flip bit */
|
*set ^= 1 << (n & 0x07); // flip bit
|
||||||
}
|
}
|
||||||
|
|
||||||
void AgiEngine::setvar(int var, int val) {
|
void AgiEngine::setvar(int var, int val) {
|
||||||
|
|
|
@ -505,22 +505,22 @@ static const uint8 vgaPalette[256 * 3] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static const uint16 cgaMap[16] = {
|
static const uint16 cgaMap[16] = {
|
||||||
0x0000, /* 0 - black */
|
0x0000, // 0 - black
|
||||||
0x0d00, /* 1 - blue */
|
0x0d00, // 1 - blue
|
||||||
0x0b00, /* 2 - green */
|
0x0b00, // 2 - green
|
||||||
0x0f00, /* 3 - cyan */
|
0x0f00, // 3 - cyan
|
||||||
0x000b, /* 4 - red */
|
0x000b, // 4 - red
|
||||||
0x0b0d, /* 5 - magenta */
|
0x0b0d, // 5 - magenta
|
||||||
0x000d, /* 6 - brown */
|
0x000d, // 6 - brown
|
||||||
0x0b0b, /* 7 - gray */
|
0x0b0b, // 7 - gray
|
||||||
0x0d0d, /* 8 - dark gray */
|
0x0d0d, // 8 - dark gray
|
||||||
0x0b0f, /* 9 - light blue */
|
0x0b0f, // 9 - light blue
|
||||||
0x0b0d, /* 10 - light green */
|
0x0b0d, // 10 - light green
|
||||||
0x0f0d, /* 11 - light cyan */
|
0x0f0d, // 11 - light cyan
|
||||||
0x0f0d, /* 12 - light red */
|
0x0f0d, // 12 - light red
|
||||||
0x0f00, /* 13 - light magenta */
|
0x0f00, // 13 - light magenta
|
||||||
0x0f0b, /* 14 - yellow */
|
0x0f0b, // 14 - yellow
|
||||||
0x0f0f /* 15 - white */
|
0x0f0f // 15 - white
|
||||||
};
|
};
|
||||||
|
|
||||||
struct UpdateBlock {
|
struct UpdateBlock {
|
||||||
|
@ -540,22 +540,22 @@ GfxMgr::GfxMgr(AgiBase *vm) : _vm(vm) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
//
|
||||||
* Layer 4: 640x480? ================== User display
|
// Layer 4: 640x480? ================== User display
|
||||||
* ^
|
// ^
|
||||||
* | do_update(), put_block()
|
// | do_update(), put_block()
|
||||||
* |
|
// |
|
||||||
* Layer 3: 640x480? ================== Framebuffer
|
// Layer 3: 640x480? ================== Framebuffer
|
||||||
* ^
|
// ^
|
||||||
* | flush_block(), put_pixels()
|
// | flush_block(), put_pixels()
|
||||||
* |
|
// |
|
||||||
* Layer 2: 320x200 ================== AGI engine screen (console), put_pixel()
|
// Layer 2: 320x200 ================== AGI engine screen (console), put_pixel()
|
||||||
* |
|
// |
|
||||||
* Layer 1: 160x336 ================== AGI screen
|
// Layer 1: 160x336 ================== AGI screen
|
||||||
*
|
//
|
||||||
* Upper half (160x168) of Layer 1 is for the normal 16 color & control line/priority info.
|
// Upper half (160x168) of Layer 1 is for the normal 16 color & control line/priority info.
|
||||||
* Lower half (160x168) of Layer 1 is for the 256 color information (Used with AGI256 & AGI256-2).
|
// Lower half (160x168) of Layer 1 is for the 256 color information (Used with AGI256 & AGI256-2).
|
||||||
*/
|
//
|
||||||
|
|
||||||
#define SHAKE_MAG 3
|
#define SHAKE_MAG 3
|
||||||
|
|
||||||
|
@ -638,9 +638,8 @@ void GfxMgr::putTextCharacter(int l, int x, int y, unsigned char c, int fg, int
|
||||||
_agiScreen[xx + yy * GFX_WIDTH] = 15;
|
_agiScreen[xx + yy * GFX_WIDTH] = 15;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: we don't want this when we're writing on the
|
// FIXME: we don't want this when we're writing on the
|
||||||
* console!
|
// console!
|
||||||
*/
|
|
||||||
flushBlock(x, y, x + CHAR_COLS - 1, y + CHAR_LINES - 1);
|
flushBlock(x, y, x + CHAR_COLS - 1, y + CHAR_LINES - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -670,16 +669,16 @@ void GfxMgr::drawFrame(int x1, int y1, int x2, int y2, int c1, int c2) {
|
||||||
int y, w;
|
int y, w;
|
||||||
uint8 *p0;
|
uint8 *p0;
|
||||||
|
|
||||||
/* top line */
|
// top line
|
||||||
w = x2 - x1 + 1;
|
w = x2 - x1 + 1;
|
||||||
p0 = &_agiScreen[x1 + y1 * GFX_WIDTH];
|
p0 = &_agiScreen[x1 + y1 * GFX_WIDTH];
|
||||||
memset(p0, c1, w);
|
memset(p0, c1, w);
|
||||||
|
|
||||||
/* bottom line */
|
// bottom line
|
||||||
p0 = &_agiScreen[x1 + y2 * GFX_WIDTH];
|
p0 = &_agiScreen[x1 + y2 * GFX_WIDTH];
|
||||||
memset(p0, c2, w);
|
memset(p0, c2, w);
|
||||||
|
|
||||||
/* side lines */
|
// side lines
|
||||||
for (y = y1; y <= y2; y++) {
|
for (y = y1; y <= y2; y++) {
|
||||||
_agiScreen[x1 + y * GFX_WIDTH] = c1;
|
_agiScreen[x1 + y * GFX_WIDTH] = c1;
|
||||||
_agiScreen[x2 + y * GFX_WIDTH] = c2;
|
_agiScreen[x2 + y * GFX_WIDTH] = c2;
|
||||||
|
@ -890,7 +889,7 @@ int GfxMgr::getAGIPalFileNum() {
|
||||||
return _agipalFileNum;
|
return _agipalFileNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* put a block onto the screen */
|
// put a block onto the screen
|
||||||
void GfxMgr::gfxPutBlock(int x1, int y1, int x2, int y2) {
|
void GfxMgr::gfxPutBlock(int x1, int y1, int x2, int y2) {
|
||||||
if (x1 >= GFX_WIDTH)
|
if (x1 >= GFX_WIDTH)
|
||||||
x1 = GFX_WIDTH - 1;
|
x1 = GFX_WIDTH - 1;
|
||||||
|
@ -1151,7 +1150,7 @@ void GfxMgr::doUpdate() {
|
||||||
gfxPutBlock(update.x1, update.y1, update.x2, update.y2);
|
gfxPutBlock(update.x1, update.y1, update.x2, update.y2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* reset update block variables */
|
// reset update block variables
|
||||||
update.x1 = MAX_INT;
|
update.x1 = MAX_INT;
|
||||||
update.y1 = MAX_INT;
|
update.y1 = MAX_INT;
|
||||||
update.x2 = 0;
|
update.x2 = 0;
|
||||||
|
|
|
@ -41,13 +41,13 @@ int AgiEngine::v2IdGame() {
|
||||||
return setupV2Game(ver, 0);
|
return setupV2Game(ver, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
//
|
||||||
* Currently, there is no known difference between v3.002.098 -> v3.002.149
|
// Currently, there is no known difference between v3.002.098 -> v3.002.149
|
||||||
* So version emulated;
|
// So version emulated;
|
||||||
*
|
//
|
||||||
* 0x0086,
|
// 0x0086,
|
||||||
* 0x0149
|
// 0x0149
|
||||||
*/
|
//
|
||||||
|
|
||||||
int AgiEngine::v3IdGame() {
|
int AgiEngine::v3IdGame() {
|
||||||
int ver;
|
int ver;
|
||||||
|
@ -74,7 +74,7 @@ int AgiEngine::setupV2Game(int ver, uint32 crc) {
|
||||||
// Should this go above the previous lines, so we can force emulation versions
|
// Should this go above the previous lines, so we can force emulation versions
|
||||||
// even for AGDS games? -- dsymonds
|
// even for AGDS games? -- dsymonds
|
||||||
if (getFeatures() & GF_AGDS)
|
if (getFeatures() & GF_AGDS)
|
||||||
agiSetRelease(ver = 0x2440); /* ALL AGDS games built for 2.440 */
|
agiSetRelease(ver = 0x2440); // ALL AGDS games built for 2.440
|
||||||
|
|
||||||
report("Setting up for version 0x%04X\n", ver);
|
report("Setting up for version 0x%04X\n", ver);
|
||||||
|
|
||||||
|
|
|
@ -23,8 +23,6 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "agi/agi.h"
|
#include "agi/agi.h"
|
||||||
#include "agi/sprite.h"
|
#include "agi/sprite.h"
|
||||||
#include "agi/graphics.h"
|
#include "agi/graphics.h"
|
||||||
|
@ -32,9 +30,9 @@
|
||||||
|
|
||||||
namespace Agi {
|
namespace Agi {
|
||||||
|
|
||||||
/*
|
//
|
||||||
* Messages and coordinates
|
// Messages and coordinates
|
||||||
*/
|
//
|
||||||
|
|
||||||
#define NOTHING_X 16
|
#define NOTHING_X 16
|
||||||
#define NOTHING_Y 3
|
#define NOTHING_Y 3
|
||||||
|
@ -92,7 +90,7 @@ int AgiEngine::showItems() {
|
||||||
|
|
||||||
for (x = i = 0; x < _game.numObjects; x++) {
|
for (x = i = 0; x < _game.numObjects; x++) {
|
||||||
if (objectGetLocation(x) == EGO_OWNED) {
|
if (objectGetLocation(x) == EGO_OWNED) {
|
||||||
/* add object to our list! */
|
// add object to our list!
|
||||||
_intobj[i] = x;
|
_intobj[i] = x;
|
||||||
printItem(i, STATUS_FG, STATUS_BG);
|
printItem(i, STATUS_FG, STATUS_BG);
|
||||||
i++;
|
i++;
|
||||||
|
@ -182,7 +180,7 @@ void AgiEngine::inventory() {
|
||||||
int oldFg, oldBg;
|
int oldFg, oldBg;
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
/* screen is white with black text */
|
// screen is white with black text
|
||||||
oldFg = _game.colorFg;
|
oldFg = _game.colorFg;
|
||||||
oldBg = _game.colorBg;
|
oldBg = _game.colorBg;
|
||||||
_game.colorFg = 0;
|
_game.colorFg = 0;
|
||||||
|
@ -198,7 +196,7 @@ void AgiEngine::inventory() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: doesn't check if objects overflow off screen... */
|
// FIXME: doesn't check if objects overflow off screen...
|
||||||
|
|
||||||
_intobj = (uint8 *)malloc(4 + _game.numObjects);
|
_intobj = (uint8 *)malloc(4 + _game.numObjects);
|
||||||
memset(_intobj, 0, (4 + _game.numObjects));
|
memset(_intobj, 0, (4 + _game.numObjects));
|
||||||
|
@ -224,10 +222,9 @@ void AgiEngine::inventory() {
|
||||||
|
|
||||||
_gfx->flushScreen();
|
_gfx->flushScreen();
|
||||||
|
|
||||||
/* If flag 13 is set, we want to highlight & select an item.
|
// If flag 13 is set, we want to highlight & select an item.
|
||||||
* opon selection, put objnum in var 25. Then on esc put in
|
// opon selection, put objnum in var 25. Then on esc put in
|
||||||
* var 25 = 0xff.
|
// var 25 = 0xff.
|
||||||
*/
|
|
||||||
|
|
||||||
if (getflag(fStatusSelectsItems))
|
if (getflag(fStatusSelectsItems))
|
||||||
selectItems(n);
|
selectItems(n);
|
||||||
|
|
|
@ -35,36 +35,36 @@
|
||||||
|
|
||||||
namespace Agi {
|
namespace Agi {
|
||||||
|
|
||||||
/*
|
//
|
||||||
* IBM-PC keyboard scancodes
|
// IBM-PC keyboard scancodes
|
||||||
*/
|
//
|
||||||
uint8 scancodeTable[26] = {
|
uint8 scancodeTable[26] = {
|
||||||
30, /* A */
|
30, // A
|
||||||
48, /* B */
|
48, // B
|
||||||
46, /* C */
|
46, // C
|
||||||
32, /* D */
|
32, // D
|
||||||
18, /* E */
|
18, // E
|
||||||
33, /* F */
|
33, // F
|
||||||
34, /* G */
|
34, // G
|
||||||
35, /* H */
|
35, // H
|
||||||
23, /* I */
|
23, // I
|
||||||
36, /* J */
|
36, // J
|
||||||
37, /* K */
|
37, // K
|
||||||
38, /* L */
|
38, // L
|
||||||
50, /* M */
|
50, // M
|
||||||
49, /* N */
|
49, // N
|
||||||
24, /* O */
|
24, // O
|
||||||
25, /* P */
|
25, // P
|
||||||
16, /* Q */
|
16, // Q
|
||||||
19, /* R */
|
19, // R
|
||||||
31, /* S */
|
31, // S
|
||||||
20, /* T */
|
20, // T
|
||||||
22, /* U */
|
22, // U
|
||||||
47, /* V */
|
47, // V
|
||||||
17, /* W */
|
17, // W
|
||||||
45, /* X */
|
45, // X
|
||||||
21, /* Y */
|
21, // Y
|
||||||
44 /* Z */
|
44 // Z
|
||||||
};
|
};
|
||||||
|
|
||||||
void AgiEngine::initWords() {
|
void AgiEngine::initWords() {
|
||||||
|
@ -93,7 +93,7 @@ void AgiEngine::getString(int x, int y, int len, int str) {
|
||||||
int AgiEngine::doPollKeyboard() {
|
int AgiEngine::doPollKeyboard() {
|
||||||
int key = 0;
|
int key = 0;
|
||||||
|
|
||||||
/* If a key is ready, rip it */
|
// If a key is ready, rip it
|
||||||
if (_gfx->keypress()) {
|
if (_gfx->keypress()) {
|
||||||
key = _gfx->getKey();
|
key = _gfx->getKey();
|
||||||
|
|
||||||
|
@ -114,8 +114,9 @@ int AgiEngine::handleController(int key) {
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if ((getGameID() == GID_MH1 || getGameID() == GID_MH2) && (key == KEY_ENTER) &&
|
if ((getGameID() == GID_MH1 || getGameID() == GID_MH2) && (key == KEY_ENTER) &&
|
||||||
(_game.inputMode == INPUT_NONE))
|
(_game.inputMode == INPUT_NONE)) {
|
||||||
key = 0x20; // Set Enter key to Space in Manhunter when there's no text input
|
key = 0x20; // Set Enter key to Space in Manhunter when there's no text input
|
||||||
|
}
|
||||||
|
|
||||||
debugC(3, kDebugLevelInput, "key = %04x", key);
|
debugC(3, kDebugLevelInput, "key = %04x", key);
|
||||||
|
|
||||||
|
@ -184,7 +185,7 @@ int AgiEngine::handleController(int key) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(getFeatures() & GF_AGIMOUSE)) {
|
if (!(getFeatures() & GF_AGIMOUSE)) {
|
||||||
/* Handle mouse button events */
|
// Handle mouse button events
|
||||||
if (key == BUTTON_LEFT) {
|
if (key == BUTTON_LEFT) {
|
||||||
v->flags |= ADJ_EGO_XY;
|
v->flags |= ADJ_EGO_XY;
|
||||||
v->parm1 = WIN_TO_PIC_X(g_mouse.x);
|
v->parm1 = WIN_TO_PIC_X(g_mouse.x);
|
||||||
|
@ -205,7 +206,7 @@ int AgiEngine::handleController(int key) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void AgiEngine::handleGetstring(int key) {
|
void AgiEngine::handleGetstring(int key) {
|
||||||
static int pos = 0; /* Cursor position */
|
static int pos = 0; // Cursor position
|
||||||
static char buf[40];
|
static char buf[40];
|
||||||
|
|
||||||
if (KEY_ASCII(key) == 0)
|
if (KEY_ASCII(key) == 0)
|
||||||
|
@ -230,9 +231,11 @@ void AgiEngine::handleGetstring(int key) {
|
||||||
debugC(3, kDebugLevelInput, "KEY_ENTER");
|
debugC(3, kDebugLevelInput, "KEY_ENTER");
|
||||||
_game.hasPrompt = 0;
|
_game.hasPrompt = 0;
|
||||||
buf[pos] = 0;
|
buf[pos] = 0;
|
||||||
|
|
||||||
strcpy(_game.strings[_stringdata.str], buf);
|
strcpy(_game.strings[_stringdata.str], buf);
|
||||||
debugC(3, kDebugLevelInput, "buffer=[%s]", buf);
|
debugC(3, kDebugLevelInput, "buffer=[%s]", buf);
|
||||||
buf[pos = 0] = 0;
|
buf[pos = 0] = 0;
|
||||||
|
|
||||||
newInputMode(INPUT_NORMAL);
|
newInputMode(INPUT_NORMAL);
|
||||||
_gfx->printCharacter(_stringdata.x + strlen(_game.strings[_stringdata.str]) + 1,
|
_gfx->printCharacter(_stringdata.x + strlen(_game.strings[_stringdata.str]) + 1,
|
||||||
_stringdata.y, ' ', _game.colorFg, _game.colorBg);
|
_stringdata.y, ' ', _game.colorFg, _game.colorBg);
|
||||||
|
@ -241,11 +244,13 @@ void AgiEngine::handleGetstring(int key) {
|
||||||
debugC(3, kDebugLevelInput, "KEY_ESCAPE");
|
debugC(3, kDebugLevelInput, "KEY_ESCAPE");
|
||||||
_game.hasPrompt = 0;
|
_game.hasPrompt = 0;
|
||||||
buf[pos = 0] = 0;
|
buf[pos = 0] = 0;
|
||||||
|
|
||||||
strcpy(_game.strings[_stringdata.str], buf);
|
strcpy(_game.strings[_stringdata.str], buf);
|
||||||
newInputMode(INPUT_NORMAL);
|
newInputMode(INPUT_NORMAL);
|
||||||
/* newInputMode(INPUT_MENU); */
|
|
||||||
|
// newInputMode(INPUT_MENU);
|
||||||
break;
|
break;
|
||||||
case KEY_BACKSPACE: /*0x08: */
|
case KEY_BACKSPACE: // 0x08
|
||||||
if (!pos)
|
if (!pos)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -264,14 +269,14 @@ void AgiEngine::handleGetstring(int key) {
|
||||||
buf[pos++] = key;
|
buf[pos++] = key;
|
||||||
buf[pos] = 0;
|
buf[pos] = 0;
|
||||||
|
|
||||||
/* Echo */
|
// Echo
|
||||||
_gfx->printCharacter(_stringdata.x + pos, _stringdata.y, buf[pos - 1],
|
_gfx->printCharacter(_stringdata.x + pos, _stringdata.y, buf[pos - 1],
|
||||||
_game.colorFg, _game.colorBg);
|
_game.colorFg, _game.colorBg);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* print cursor */
|
// print cursor
|
||||||
_gfx->printCharacter(_stringdata.x + pos + 1, _stringdata.y,
|
_gfx->printCharacter(_stringdata.x + pos + 1, _stringdata.y,
|
||||||
(char)_game.cursorChar, _game.colorFg, _game.colorBg);
|
(char)_game.cursorChar, _game.colorFg, _game.colorBg);
|
||||||
}
|
}
|
||||||
|
@ -293,13 +298,13 @@ void AgiEngine::handleKeys(int key) {
|
||||||
debugC(3, kDebugLevelInput, "KEY_ENTER");
|
debugC(3, kDebugLevelInput, "KEY_ENTER");
|
||||||
_game.keypress = 0;
|
_game.keypress = 0;
|
||||||
|
|
||||||
/* Remove all leading spaces */
|
// Remove all leading spaces
|
||||||
for (p = _game.inputBuffer; *p && *p == 0x20; p++)
|
for (p = _game.inputBuffer; *p && *p == 0x20; p++)
|
||||||
;
|
;
|
||||||
|
|
||||||
/* Copy to internal buffer */
|
// Copy to internal buffer
|
||||||
for (; *p; p++) {
|
for (; *p; p++) {
|
||||||
/* Squash spaces */
|
// Squash spaces
|
||||||
if (*p == 0x20 && *(p + 1) == 0x20) {
|
if (*p == 0x20 && *(p + 1) == 0x20) {
|
||||||
p++;
|
p++;
|
||||||
continue;
|
continue;
|
||||||
|
@ -308,14 +313,14 @@ void AgiEngine::handleKeys(int key) {
|
||||||
}
|
}
|
||||||
formattedEntry[c++] = 0;
|
formattedEntry[c++] = 0;
|
||||||
|
|
||||||
/* Handle string only if it's not empty */
|
// Handle string only if it's not empty
|
||||||
if (formattedEntry[0]) {
|
if (formattedEntry[0]) {
|
||||||
strcpy((char *)_game.echoBuffer, (const char *)_game.inputBuffer);
|
strcpy((char *)_game.echoBuffer, (const char *)_game.inputBuffer);
|
||||||
strcpy(_lastSentence, (const char *)formattedEntry);
|
strcpy(_lastSentence, (const char *)formattedEntry);
|
||||||
dictionaryWords(_lastSentence);
|
dictionaryWords(_lastSentence);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Clear to start a new line */
|
// Clear to start a new line
|
||||||
_game.hasPrompt = 0;
|
_game.hasPrompt = 0;
|
||||||
_game.inputBuffer[_game.cursorPos = 0] = 0;
|
_game.inputBuffer[_game.cursorPos = 0] = 0;
|
||||||
debugC(3, kDebugLevelInput, "clear lines");
|
debugC(3, kDebugLevelInput, "clear lines");
|
||||||
|
@ -331,14 +336,15 @@ void AgiEngine::handleKeys(int key) {
|
||||||
newInputMode(INPUT_MENU);
|
newInputMode(INPUT_MENU);
|
||||||
break;
|
break;
|
||||||
case KEY_BACKSPACE:
|
case KEY_BACKSPACE:
|
||||||
/* Ignore backspace at start of line */
|
// Ignore backspace at start of line
|
||||||
if (_game.cursorPos == 0)
|
if (_game.cursorPos == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* erase cursor */
|
// erase cursor
|
||||||
_gfx->printCharacter(_game.cursorPos + promptLength, l, ' ', fg, bg);
|
_gfx->printCharacter(_game.cursorPos + promptLength, l, ' ', fg, bg);
|
||||||
_game.inputBuffer[--_game.cursorPos] = 0;
|
_game.inputBuffer[--_game.cursorPos] = 0;
|
||||||
/* Print cursor */
|
|
||||||
|
// Print cursor
|
||||||
_gfx->printCharacter(_game.cursorPos + promptLength, l, _game.cursorChar, fg, bg);
|
_gfx->printCharacter(_game.cursorPos + promptLength, l, _game.cursorChar, fg, bg);
|
||||||
|
|
||||||
#ifdef __DS__
|
#ifdef __DS__
|
||||||
|
@ -346,11 +352,11 @@ void AgiEngine::handleKeys(int key) {
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
/* Ignore invalid keystrokes */
|
// Ignore invalid keystrokes
|
||||||
if (key < 0x20 || key > 0x7f)
|
if (key < 0x20 || key > 0x7f)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* Maximum input size reached */
|
// Maximum input size reached
|
||||||
if (_game.cursorPos >= getvar(vMaxInputChars))
|
if (_game.cursorPos >= getvar(vMaxInputChars))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -361,10 +367,10 @@ void AgiEngine::handleKeys(int key) {
|
||||||
DS::findWordCompletions((char *) _game.inputBuffer);
|
DS::findWordCompletions((char *) _game.inputBuffer);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* echo */
|
// echo
|
||||||
_gfx->printCharacter(_game.cursorPos + promptLength - 1, l, _game.inputBuffer[_game.cursorPos - 1], fg, bg);
|
_gfx->printCharacter(_game.cursorPos + promptLength - 1, l, _game.inputBuffer[_game.cursorPos - 1], fg, bg);
|
||||||
|
|
||||||
/* Print cursor */
|
// Print cursor
|
||||||
_gfx->printCharacter(_game.cursorPos + promptLength, l, _game.cursorChar, fg, bg);
|
_gfx->printCharacter(_game.cursorPos + promptLength, l, _game.cursorChar, fg, bg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -373,14 +379,14 @@ void AgiEngine::handleKeys(int key) {
|
||||||
int AgiEngine::waitKey() {
|
int AgiEngine::waitKey() {
|
||||||
int key = 0;
|
int key = 0;
|
||||||
|
|
||||||
/* clear key queue */
|
// clear key queue
|
||||||
while (_gfx->keypress()) {
|
while (_gfx->keypress()) {
|
||||||
_gfx->getKey();
|
_gfx->getKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
debugC(3, kDebugLevelInput, "waiting...");
|
debugC(3, kDebugLevelInput, "waiting...");
|
||||||
while (!(shouldQuit() || restartGame || getflag(fRestoreJustRan))) {
|
while (!(shouldQuit() || restartGame || getflag(fRestoreJustRan))) {
|
||||||
_gfx->pollTimer(); /* msdos driver -> does nothing */
|
_gfx->pollTimer(); // msdos driver -> does nothing
|
||||||
key = doPollKeyboard();
|
key = doPollKeyboard();
|
||||||
if (key == KEY_ENTER || key == KEY_ESCAPE || key == BUTTON_LEFT)
|
if (key == KEY_ENTER || key == KEY_ESCAPE || key == BUTTON_LEFT)
|
||||||
break;
|
break;
|
||||||
|
@ -396,14 +402,14 @@ int AgiEngine::waitKey() {
|
||||||
int AgiEngine::waitAnyKey() {
|
int AgiEngine::waitAnyKey() {
|
||||||
int key = 0;
|
int key = 0;
|
||||||
|
|
||||||
/* clear key queue */
|
// clear key queue
|
||||||
while (_gfx->keypress()) {
|
while (_gfx->keypress()) {
|
||||||
_gfx->getKey();
|
_gfx->getKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
debugC(3, kDebugLevelInput, "waiting... (any key)");
|
debugC(3, kDebugLevelInput, "waiting... (any key)");
|
||||||
while (!(shouldQuit() || restartGame)) {
|
while (!(shouldQuit() || restartGame)) {
|
||||||
_gfx->pollTimer(); /* msdos driver -> does nothing */
|
_gfx->pollTimer(); // msdos driver -> does nothing
|
||||||
key = doPollKeyboard();
|
key = doPollKeyboard();
|
||||||
if (key)
|
if (key)
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -26,8 +26,6 @@
|
||||||
#ifndef AGI_KEYBOARD_H
|
#ifndef AGI_KEYBOARD_H
|
||||||
#define AGI_KEYBOARD_H
|
#define AGI_KEYBOARD_H
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace Agi {
|
namespace Agi {
|
||||||
|
|
||||||
#define keyEnqueue(k) do { _keyQueue[_keyQueueEnd++] = (k); \
|
#define keyEnqueue(k) do { _keyQueue[_keyQueueEnd++] = (k); \
|
||||||
|
@ -51,10 +49,10 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* QNX4 has a KEY_DOWN defined which we don't need to care about */
|
// QNX4 has a KEY_DOWN defined which we don't need to care about
|
||||||
#undef KEY_DOWN
|
#undef KEY_DOWN
|
||||||
|
|
||||||
/* Allegro defines these */
|
// Allegro defines these
|
||||||
#undef KEY_BACKSPACE
|
#undef KEY_BACKSPACE
|
||||||
#undef KEY_ENTER
|
#undef KEY_ENTER
|
||||||
#undef KEY_LEFT
|
#undef KEY_LEFT
|
||||||
|
@ -79,18 +77,18 @@ public:
|
||||||
#define KEY_UP_LEFT 0x4700
|
#define KEY_UP_LEFT 0x4700
|
||||||
#define KEY_UP_RIGHT 0x4900
|
#define KEY_UP_RIGHT 0x4900
|
||||||
|
|
||||||
#define KEY_STATUSLN 0xd900 /* F11 */
|
#define KEY_STATUSLN 0xd900 // F11
|
||||||
#define KEY_PRIORITY 0xda00 /* F12 */
|
#define KEY_PRIORITY 0xda00 // F12
|
||||||
|
|
||||||
#define KEY_PGUP 0x4900 /* Page Up (fixed by Ziv Barber) */
|
#define KEY_PGUP 0x4900 // Page Up (fixed by Ziv Barber)
|
||||||
#define KEY_PGDN 0x5100 /* Page Down */
|
#define KEY_PGDN 0x5100 // Page Down
|
||||||
#define KEY_HOME 0x4700 /* Home */
|
#define KEY_HOME 0x4700 // Home
|
||||||
#define KEY_END 0x4f00 /* End * */
|
#define KEY_END 0x4f00 // End *
|
||||||
|
|
||||||
#define BUTTON_LEFT 0xF101 /* Left mouse button */
|
#define BUTTON_LEFT 0xF101 // Left mouse button
|
||||||
#define BUTTON_RIGHT 0xF202 /* Right mouse button */
|
#define BUTTON_RIGHT 0xF202 // Right mouse button
|
||||||
#define WHEEL_UP 0xF203 /* Mouse wheel up */
|
#define WHEEL_UP 0xF203 // Mouse wheel up
|
||||||
#define WHEEL_DOWN 0xF204 /* Mouse wheel down */
|
#define WHEEL_DOWN 0xF204 // Mouse wheel down
|
||||||
|
|
||||||
#define KEY_SCAN(k) (k >> 8)
|
#define KEY_SCAN(k) (k >> 8)
|
||||||
#define KEY_ASCII(k) (k & 0xff)
|
#define KEY_ASCII(k) (k & 0xff)
|
||||||
|
|
|
@ -48,7 +48,7 @@ int AgiLoader_v2::detectGame() {
|
||||||
!Common::File::exists(VIEWDIR))
|
!Common::File::exists(VIEWDIR))
|
||||||
return errInvalidAGIFile;
|
return errInvalidAGIFile;
|
||||||
|
|
||||||
_intVersion = 0x2917; /* setup for 2.917 */
|
_intVersion = 0x2917; // setup for 2.917
|
||||||
return _vm->v2IdGame();
|
return _vm->v2IdGame();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,13 +75,13 @@ int AgiLoader_v2::loadDir(AgiDir *agid, const char *fname) {
|
||||||
|
|
||||||
fp.read(mem, flen);
|
fp.read(mem, flen);
|
||||||
|
|
||||||
/* set all directory resources to gone */
|
// set all directory resources to gone
|
||||||
for (i = 0; i < MAX_DIRS; i++) {
|
for (i = 0; i < MAX_DIRS; i++) {
|
||||||
agid[i].volume = 0xff;
|
agid[i].volume = 0xff;
|
||||||
agid[i].offset = _EMPTY;
|
agid[i].offset = _EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* build directory entries */
|
// build directory entries
|
||||||
for (i = 0; i < flen; i += 3) {
|
for (i = 0; i < flen; i += 3) {
|
||||||
agid[i / 3].volume = *(mem + i) >> 4;
|
agid[i / 3].volume = *(mem + i) >> 4;
|
||||||
agid[i / 3].offset = READ_BE_UINT24(mem + i) & (uint32) _EMPTY;
|
agid[i / 3].offset = READ_BE_UINT24(mem + i) & (uint32) _EMPTY;
|
||||||
|
@ -97,7 +97,7 @@ int AgiLoader_v2::loadDir(AgiDir *agid, const char *fname) {
|
||||||
int AgiLoader_v2::init() {
|
int AgiLoader_v2::init() {
|
||||||
int ec = errOK;
|
int ec = errOK;
|
||||||
|
|
||||||
/* load directory files */
|
// load directory files
|
||||||
ec = loadDir(_vm->_game.dirLogic, LOGDIR);
|
ec = loadDir(_vm->_game.dirLogic, LOGDIR);
|
||||||
if (ec == errOK)
|
if (ec == errOK)
|
||||||
ec = loadDir(_vm->_game.dirPic, PICDIR);
|
ec = loadDir(_vm->_game.dirPic, PICDIR);
|
||||||
|
@ -113,10 +113,10 @@ int AgiLoader_v2::deinit() {
|
||||||
int ec = errOK;
|
int ec = errOK;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/* unload words */
|
// unload words
|
||||||
agiV2UnloadWords();
|
agiV2UnloadWords();
|
||||||
|
|
||||||
/* unload objects */
|
// unload objects
|
||||||
agiV2UnloadObjects();
|
agiV2UnloadObjects();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ int AgiLoader_v2::unloadResource(int t, int n) {
|
||||||
return errOK;
|
return errOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* This function does noting but load a raw resource into memory,
|
* This function does noting but load a raw resource into memory,
|
||||||
* if further decoding is required, it must be done by another
|
* if further decoding is required, it must be done by another
|
||||||
* routine. NULL is returned if unsucsessfull.
|
* routine. NULL is returned if unsucsessfull.
|
||||||
|
@ -178,15 +178,15 @@ uint8 *AgiLoader_v2::loadVolRes(struct AgiDir *agid) {
|
||||||
}
|
}
|
||||||
fp.close();
|
fp.close();
|
||||||
} else {
|
} else {
|
||||||
/* we have a bad volume resource */
|
// we have a bad volume resource
|
||||||
/* set that resource to NA */
|
// set that resource to NA
|
||||||
agid->offset = _EMPTY;
|
agid->offset = _EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Loads a resource into memory, a raw resource is loaded in
|
* Loads a resource into memory, a raw resource is loaded in
|
||||||
* with above routine, then further decoded here.
|
* with above routine, then further decoded here.
|
||||||
*/
|
*/
|
||||||
|
@ -204,7 +204,7 @@ int AgiLoader_v2::loadResource(int t, int n) {
|
||||||
debugC(3, kDebugLevelResources, "loading logic resource %d", n);
|
debugC(3, kDebugLevelResources, "loading logic resource %d", n);
|
||||||
unloadResource(rLOGIC, n);
|
unloadResource(rLOGIC, n);
|
||||||
|
|
||||||
/* load raw resource into data */
|
// load raw resource into data
|
||||||
data = loadVolRes(&_vm->_game.dirLogic[n]);
|
data = loadVolRes(&_vm->_game.dirLogic[n]);
|
||||||
|
|
||||||
_vm->_game.logics[n].data = data;
|
_vm->_game.logics[n].data = data;
|
||||||
|
@ -213,22 +213,21 @@ int AgiLoader_v2::loadResource(int t, int n) {
|
||||||
_vm->_game.logics[n].sIP = 2;
|
_vm->_game.logics[n].sIP = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if logic was cached, we get here */
|
// if logic was cached, we get here
|
||||||
/* reset code pointers incase it was cached */
|
// reset code pointers incase it was cached
|
||||||
|
|
||||||
_vm->_game.logics[n].cIP = _vm->_game.logics[n].sIP;
|
_vm->_game.logics[n].cIP = _vm->_game.logics[n].sIP;
|
||||||
break;
|
break;
|
||||||
case rPICTURE:
|
case rPICTURE:
|
||||||
/* if picture is currently NOT loaded *OR* cacheing is off,
|
// if picture is currently NOT loaded *OR* cacheing is off,
|
||||||
* unload the resource (caching == off) and reload it
|
// unload the resource (caching == off) and reload it
|
||||||
*/
|
|
||||||
|
|
||||||
debugC(3, kDebugLevelResources, "loading picture resource %d", n);
|
debugC(3, kDebugLevelResources, "loading picture resource %d", n);
|
||||||
if (_vm->_game.dirPic[n].flags & RES_LOADED)
|
if (_vm->_game.dirPic[n].flags & RES_LOADED)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* if loaded but not cached, unload it */
|
// if loaded but not cached, unload it
|
||||||
/* if cached but not loaded, etc */
|
// if cached but not loaded, etc
|
||||||
unloadResource(rPICTURE, n);
|
unloadResource(rPICTURE, n);
|
||||||
data = loadVolRes(&_vm->_game.dirPic[n]);
|
data = loadVolRes(&_vm->_game.dirPic[n]);
|
||||||
|
|
||||||
|
@ -255,11 +254,10 @@ int AgiLoader_v2::loadResource(int t, int n) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case rVIEW:
|
case rVIEW:
|
||||||
/* Load a VIEW resource into memory...
|
// Load a VIEW resource into memory...
|
||||||
* Since VIEWS alter the view table ALL the time
|
// Since VIEWS alter the view table ALL the time
|
||||||
* can we cache the view? or must we reload it all
|
// can we cache the view? or must we reload it all
|
||||||
* the time?
|
// the time?
|
||||||
*/
|
|
||||||
if (_vm->_game.dirView[n].flags & RES_LOADED)
|
if (_vm->_game.dirView[n].flags & RES_LOADED)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -89,13 +89,13 @@ int AgiLoader_v3::loadDir(struct AgiDir *agid, Common::File *fp,
|
||||||
if ((mem = (uint8 *)malloc(len + 32)) != NULL) {
|
if ((mem = (uint8 *)malloc(len + 32)) != NULL) {
|
||||||
fp->read(mem, len);
|
fp->read(mem, len);
|
||||||
|
|
||||||
/* set all directory resources to gone */
|
// set all directory resources to gone
|
||||||
for (i = 0; i < MAX_DIRS; i++) {
|
for (i = 0; i < MAX_DIRS; i++) {
|
||||||
agid[i].volume = 0xff;
|
agid[i].volume = 0xff;
|
||||||
agid[i].offset = _EMPTY;
|
agid[i].offset = _EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* build directory entries */
|
// build directory entries
|
||||||
for (i = 0; i < len; i += 3) {
|
for (i = 0; i < len; i += 3) {
|
||||||
agid[i / 3].volume = *(mem + i) >> 4;
|
agid[i / 3].volume = *(mem + i) >> 4;
|
||||||
agid[i / 3].offset = READ_BE_UINT24(mem + i) & (uint32) _EMPTY;
|
agid[i / 3].offset = READ_BE_UINT24(mem + i) & (uint32) _EMPTY;
|
||||||
|
@ -136,7 +136,7 @@ int AgiLoader_v3::init() {
|
||||||
printf("Failed to open \"%s\"\n", path.c_str());
|
printf("Failed to open \"%s\"\n", path.c_str());
|
||||||
return errBadFileOpen;
|
return errBadFileOpen;
|
||||||
}
|
}
|
||||||
/* build offset table for v3 directory format */
|
// build offset table for v3 directory format
|
||||||
fp.read(&xd, 8);
|
fp.read(&xd, 8);
|
||||||
fp.seek(0, SEEK_END);
|
fp.seek(0, SEEK_END);
|
||||||
|
|
||||||
|
@ -153,7 +153,7 @@ int AgiLoader_v3::init() {
|
||||||
|
|
||||||
fp.seek(0, SEEK_SET);
|
fp.seek(0, SEEK_SET);
|
||||||
|
|
||||||
/* read in directory files */
|
// read in directory files
|
||||||
ec = loadDir(_vm->_game.dirLogic, &fp, agiVol3[0].sddr, agiVol3[0].len);
|
ec = loadDir(_vm->_game.dirLogic, &fp, agiVol3[0].sddr, agiVol3[0].len);
|
||||||
|
|
||||||
if (ec == errOK) {
|
if (ec == errOK) {
|
||||||
|
@ -175,10 +175,10 @@ int AgiLoader_v3::deinit() {
|
||||||
int ec = errOK;
|
int ec = errOK;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/* unload words */
|
// unload words
|
||||||
agiV3UnloadWords();
|
agiV3UnloadWords();
|
||||||
|
|
||||||
/* unload objects */
|
// unload objects
|
||||||
agiV3UnloadObjects();
|
agiV3UnloadObjects();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -204,7 +204,7 @@ int AgiLoader_v3::unloadResource(int t, int n) {
|
||||||
return errOK;
|
return errOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* This function does noting but load a raw resource into memory.
|
* This function does noting but load a raw resource into memory.
|
||||||
* If further decoding is required, it must be done by another
|
* If further decoding is required, it must be done by another
|
||||||
* routine.
|
* routine.
|
||||||
|
@ -234,28 +234,27 @@ uint8 *AgiLoader_v3::loadVolRes(AgiDir *agid) {
|
||||||
_vm->quitGame();
|
_vm->quitGame();
|
||||||
}
|
}
|
||||||
|
|
||||||
agid->len = READ_LE_UINT16((uint8 *) x + 3); /* uncompressed size */
|
agid->len = READ_LE_UINT16((uint8 *) x + 3); // uncompressed size
|
||||||
agid->clen = READ_LE_UINT16((uint8 *) x + 5); /* compressed len */
|
agid->clen = READ_LE_UINT16((uint8 *) x + 5); // compressed len
|
||||||
|
|
||||||
compBuffer = (uint8 *)calloc(1, agid->clen + 32);
|
compBuffer = (uint8 *)calloc(1, agid->clen + 32);
|
||||||
fp.read(compBuffer, agid->clen);
|
fp.read(compBuffer, agid->clen);
|
||||||
|
|
||||||
if (x[2] & 0x80 || agid->len == agid->clen) {
|
if (x[2] & 0x80 || agid->len == agid->clen) {
|
||||||
/* do not decompress */
|
// do not decompress
|
||||||
data = compBuffer;
|
data = compBuffer;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/* CM: added to avoid problems in
|
// CM: added to avoid problems in
|
||||||
* convert_v2_v3_pic() when clen > len
|
// convert_v2_v3_pic() when clen > len
|
||||||
* e.g. Sierra demo 4, first picture
|
// e.g. Sierra demo 4, first picture
|
||||||
* (Tue Mar 16 13:13:43 EST 1999)
|
// (Tue Mar 16 13:13:43 EST 1999)
|
||||||
*/
|
|
||||||
agid->len = agid->clen;
|
agid->len = agid->clen;
|
||||||
|
|
||||||
/* Now removed to fix Gold Rush! in demo4 */
|
// Now removed to fix Gold Rush! in demo4
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
/* it is compressed */
|
// it is compressed
|
||||||
data = (uint8 *)calloc(1, agid->len + 32);
|
data = (uint8 *)calloc(1, agid->len + 32);
|
||||||
lzwExpand(compBuffer, data, agid->len);
|
lzwExpand(compBuffer, data, agid->len);
|
||||||
free(compBuffer);
|
free(compBuffer);
|
||||||
|
@ -264,15 +263,15 @@ uint8 *AgiLoader_v3::loadVolRes(AgiDir *agid) {
|
||||||
|
|
||||||
fp.close();
|
fp.close();
|
||||||
} else {
|
} else {
|
||||||
/* we have a bad volume resource */
|
// we have a bad volume resource
|
||||||
/* set that resource to NA */
|
// set that resource to NA
|
||||||
agid->offset = _EMPTY;
|
agid->offset = _EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Loads a resource into memory, a raw resource is loaded in
|
* Loads a resource into memory, a raw resource is loaded in
|
||||||
* with above routine, then further decoded here.
|
* with above routine, then further decoded here.
|
||||||
*/
|
*/
|
||||||
|
@ -285,42 +284,40 @@ int AgiLoader_v3::loadResource(int t, int n) {
|
||||||
|
|
||||||
switch (t) {
|
switch (t) {
|
||||||
case rLOGIC:
|
case rLOGIC:
|
||||||
/* load resource into memory, decrypt messages at the end
|
// load resource into memory, decrypt messages at the end
|
||||||
* and build the message list (if logic is in memory)
|
// and build the message list (if logic is in memory)
|
||||||
*/
|
|
||||||
if (~_vm->_game.dirLogic[n].flags & RES_LOADED) {
|
if (~_vm->_game.dirLogic[n].flags & RES_LOADED) {
|
||||||
/* if logic is already in memory, unload it */
|
// if logic is already in memory, unload it
|
||||||
unloadResource(rLOGIC, n);
|
unloadResource(rLOGIC, n);
|
||||||
|
|
||||||
/* load raw resource into data */
|
// load raw resource into data
|
||||||
data = loadVolRes(&_vm->_game.dirLogic[n]);
|
data = loadVolRes(&_vm->_game.dirLogic[n]);
|
||||||
_vm->_game.logics[n].data = data;
|
_vm->_game.logics[n].data = data;
|
||||||
|
|
||||||
/* uncompressed logic files need to be decrypted */
|
// uncompressed logic files need to be decrypted
|
||||||
if (data != NULL) {
|
if (data != NULL) {
|
||||||
/* resloaded flag gets set by decode logic */
|
// resloaded flag gets set by decode logic
|
||||||
/* needed to build string table */
|
// needed to build string table
|
||||||
ec = _vm->decodeLogic(n);
|
ec = _vm->decodeLogic(n);
|
||||||
_vm->_game.logics[n].sIP = 2;
|
_vm->_game.logics[n].sIP = 2;
|
||||||
} else {
|
} else {
|
||||||
ec = errBadResource;
|
ec = errBadResource;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*logics[n].sIP=2; *//* saved IP = 2 */
|
// logics[n].sIP=2; // saved IP = 2
|
||||||
/*logics[n].cIP=2; *//* current IP = 2 */
|
// logics[n].cIP=2; // current IP = 2
|
||||||
|
|
||||||
_vm->_game.logics[n].cIP = _vm->_game.logics[n].sIP;
|
_vm->_game.logics[n].cIP = _vm->_game.logics[n].sIP;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if logic was cached, we get here */
|
// if logic was cached, we get here
|
||||||
/* reset code pointers incase it was cached */
|
// reset code pointers incase it was cached
|
||||||
|
|
||||||
_vm->_game.logics[n].cIP = _vm->_game.logics[n].sIP;
|
_vm->_game.logics[n].cIP = _vm->_game.logics[n].sIP;
|
||||||
break;
|
break;
|
||||||
case rPICTURE:
|
case rPICTURE:
|
||||||
/* if picture is currently NOT loaded *OR* cacheing is off,
|
// if picture is currently NOT loaded *OR* cacheing is off,
|
||||||
* unload the resource (caching==off) and reload it
|
// unload the resource (caching==off) and reload it
|
||||||
*/
|
|
||||||
if (~_vm->_game.dirPic[n].flags & RES_LOADED) {
|
if (~_vm->_game.dirPic[n].flags & RES_LOADED) {
|
||||||
unloadResource(rPICTURE, n);
|
unloadResource(rPICTURE, n);
|
||||||
data = loadVolRes(&_vm->_game.dirPic[n]);
|
data = loadVolRes(&_vm->_game.dirPic[n]);
|
||||||
|
@ -347,11 +344,11 @@ int AgiLoader_v3::loadResource(int t, int n) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case rVIEW:
|
case rVIEW:
|
||||||
/* Load a VIEW resource into memory...
|
// Load a VIEW resource into memory...
|
||||||
* Since VIEWS alter the view table ALL the time can we
|
// Since VIEWS alter the view table ALL the time can we
|
||||||
* cache the view? or must we reload it all the time?
|
// cache the view? or must we reload it all the time?
|
||||||
*/
|
//
|
||||||
/* load a raw view from a VOL file into data */
|
// load a raw view from a VOL file into data
|
||||||
if (_vm->_game.dirView[n].flags & RES_LOADED)
|
if (_vm->_game.dirView[n].flags & RES_LOADED)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -23,8 +23,6 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "agi/agi.h"
|
#include "agi/agi.h"
|
||||||
|
|
||||||
namespace Agi {
|
namespace Agi {
|
||||||
|
@ -40,52 +38,50 @@ int AgiEngine::decodeLogic(int n) {
|
||||||
int mstart, mend, mc;
|
int mstart, mend, mc;
|
||||||
uint8 *m0;
|
uint8 *m0;
|
||||||
|
|
||||||
/* decrypt messages at end of logic + build message list */
|
// decrypt messages at end of logic + build message list
|
||||||
|
|
||||||
/* report ("decoding logic #%d\n", n); */
|
// report ("decoding logic #%d\n", n);
|
||||||
m0 = _game.logics[n].data;
|
m0 = _game.logics[n].data;
|
||||||
|
|
||||||
mstart = READ_LE_UINT16(m0) + 2;
|
mstart = READ_LE_UINT16(m0) + 2;
|
||||||
mc = *(m0 + mstart);
|
mc = *(m0 + mstart);
|
||||||
mend = READ_LE_UINT16(m0 + mstart + 1);
|
mend = READ_LE_UINT16(m0 + mstart + 1);
|
||||||
m0 += mstart + 3; /* cover header info */
|
m0 += mstart + 3; // cover header info
|
||||||
mstart = mc << 1;
|
mstart = mc << 1;
|
||||||
|
|
||||||
/* if the logic was not compressed, decrypt the text messages
|
// if the logic was not compressed, decrypt the text messages
|
||||||
* only if there are more than 0 messages
|
// only if there are more than 0 messages
|
||||||
*/
|
|
||||||
if ((~_game.dirLogic[n].flags & RES_COMPRESSED) && mc > 0)
|
if ((~_game.dirLogic[n].flags & RES_COMPRESSED) && mc > 0)
|
||||||
decrypt(m0 + mstart, mend - mstart); /* decrypt messages */
|
decrypt(m0 + mstart, mend - mstart); // decrypt messages
|
||||||
|
|
||||||
/* build message list */
|
// build message list
|
||||||
m0 = _game.logics[n].data;
|
m0 = _game.logics[n].data;
|
||||||
mstart = READ_LE_UINT16(m0) + 2; /* +2 covers pointer */
|
mstart = READ_LE_UINT16(m0) + 2; // +2 covers pointer
|
||||||
_game.logics[n].numTexts = *(m0 + mstart);
|
_game.logics[n].numTexts = *(m0 + mstart);
|
||||||
|
|
||||||
/* resetp logic pointers */
|
// resetp logic pointers
|
||||||
_game.logics[n].sIP = 2;
|
_game.logics[n].sIP = 2;
|
||||||
_game.logics[n].cIP = 2;
|
_game.logics[n].cIP = 2;
|
||||||
_game.logics[n].size = READ_LE_UINT16(m0) + 2; /* logic end pointer */
|
_game.logics[n].size = READ_LE_UINT16(m0) + 2; // logic end pointer
|
||||||
|
|
||||||
/* allocate list of pointers to point into our data */
|
// allocate list of pointers to point into our data
|
||||||
|
|
||||||
_game.logics[n].texts = (const char **)calloc(1 + _game.logics[n].numTexts, sizeof(char *));
|
_game.logics[n].texts = (const char **)calloc(1 + _game.logics[n].numTexts, sizeof(char *));
|
||||||
|
|
||||||
/* cover header info */
|
// cover header info
|
||||||
m0 += mstart + 3;
|
m0 += mstart + 3;
|
||||||
|
|
||||||
if (_game.logics[n].texts != NULL) {
|
if (_game.logics[n].texts != NULL) {
|
||||||
/* move list of strings into list to make real pointers */
|
// move list of strings into list to make real pointers
|
||||||
for (mc = 0; mc < _game.logics[n].numTexts; mc++) {
|
for (mc = 0; mc < _game.logics[n].numTexts; mc++) {
|
||||||
mend = READ_LE_UINT16(m0 + mc * 2);
|
mend = READ_LE_UINT16(m0 + mc * 2);
|
||||||
_game.logics[n].texts[mc] = mend ? (const char *)m0 + mend - 2 : (const char *)"";
|
_game.logics[n].texts[mc] = mend ? (const char *)m0 + mend - 2 : (const char *)"";
|
||||||
}
|
}
|
||||||
/* set loaded flag now its all completly loaded */
|
// set loaded flag now its all completly loaded
|
||||||
_game.dirLogic[n].flags |= RES_LOADED;
|
_game.dirLogic[n].flags |= RES_LOADED;
|
||||||
} else {
|
} else {
|
||||||
/* unload data
|
// unload data
|
||||||
* Note that not every logic has text
|
// Note that not every logic has text
|
||||||
*/
|
|
||||||
free(_game.logics[n].data);
|
free(_game.logics[n].data);
|
||||||
ec = errNotEnoughMemory;
|
ec = errNotEnoughMemory;
|
||||||
}
|
}
|
||||||
|
@ -108,7 +104,7 @@ void AgiEngine::unloadLogic(int n) {
|
||||||
_game.dirLogic[n].flags &= ~RES_LOADED;
|
_game.dirLogic[n].flags &= ~RES_LOADED;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if cached, we end up here */
|
// if cached, we end up here
|
||||||
_game.logics[n].sIP = 2;
|
_game.logics[n].sIP = 2;
|
||||||
_game.logics[n].cIP = 2;
|
_game.logics[n].cIP = 2;
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,21 +41,21 @@
|
||||||
namespace Agi {
|
namespace Agi {
|
||||||
|
|
||||||
#define MAXBITS 12
|
#define MAXBITS 12
|
||||||
#define TABLE_SIZE 18041 /* strange number */
|
#define TABLE_SIZE 18041 // strange number
|
||||||
#define START_BITS 9
|
#define START_BITS 9
|
||||||
|
|
||||||
static int32 BITS, MAX_VALUE, MAX_CODE;
|
static int32 BITS, MAX_VALUE, MAX_CODE;
|
||||||
static uint32 *prefixCode;
|
static uint32 *prefixCode;
|
||||||
static uint8 *appendCharacter;
|
static uint8 *appendCharacter;
|
||||||
static uint8 *decodeStack;
|
static uint8 *decodeStack;
|
||||||
static int32 inputBitCount = 0; /* Number of bits in input bit buffer */
|
static int32 inputBitCount = 0; // Number of bits in input bit buffer
|
||||||
static uint32 inputBitBuffer = 0L;
|
static uint32 inputBitBuffer = 0L;
|
||||||
|
|
||||||
static void initLZW() {
|
static void initLZW() {
|
||||||
decodeStack = (uint8 *)calloc(1, 8192);
|
decodeStack = (uint8 *)calloc(1, 8192);
|
||||||
prefixCode = (uint32 *)malloc(TABLE_SIZE * sizeof(uint32));
|
prefixCode = (uint32 *)malloc(TABLE_SIZE * sizeof(uint32));
|
||||||
appendCharacter = (uint8 *)malloc(TABLE_SIZE * sizeof(uint8));
|
appendCharacter = (uint8 *)malloc(TABLE_SIZE * sizeof(uint8));
|
||||||
inputBitCount = 0; /* Number of bits in input bit buffer */
|
inputBitCount = 0; // Number of bits in input bit buffer
|
||||||
inputBitBuffer = 0L;
|
inputBitBuffer = 0L;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,18 +141,18 @@ void lzwExpand(uint8 *in, uint8 *out, int32 len) {
|
||||||
|
|
||||||
initLZW();
|
initLZW();
|
||||||
|
|
||||||
setBits(START_BITS); /* Starts at 9-bits */
|
setBits(START_BITS); // Starts at 9-bits
|
||||||
lzwnext = 257; /* Next available code to define */
|
lzwnext = 257; // Next available code to define
|
||||||
|
|
||||||
end = (uint8 *)(out + (uint32)len);
|
end = (uint8 *)(out + (uint32)len);
|
||||||
|
|
||||||
lzwold = inputCode(&in); /* Read in the first code */
|
lzwold = inputCode(&in); // Read in the first code
|
||||||
c = lzwold;
|
c = lzwold;
|
||||||
lzwnew = inputCode(&in);
|
lzwnew = inputCode(&in);
|
||||||
|
|
||||||
while ((out < end) && (lzwnew != 0x101)) {
|
while ((out < end) && (lzwnew != 0x101)) {
|
||||||
if (lzwnew == 0x100) {
|
if (lzwnew == 0x100) {
|
||||||
/* Code to "start over" */
|
// Code to "start over"
|
||||||
lzwnext = 258;
|
lzwnext = 258;
|
||||||
setBits(START_BITS);
|
setBits(START_BITS);
|
||||||
lzwold = inputCode(&in);
|
lzwold = inputCode(&in);
|
||||||
|
@ -161,15 +161,14 @@ void lzwExpand(uint8 *in, uint8 *out, int32 len) {
|
||||||
lzwnew = inputCode(&in);
|
lzwnew = inputCode(&in);
|
||||||
} else {
|
} else {
|
||||||
if (lzwnew >= lzwnext) {
|
if (lzwnew >= lzwnext) {
|
||||||
/* Handles special LZW scenario */
|
// Handles special LZW scenario
|
||||||
*decodeStack = c;
|
*decodeStack = c;
|
||||||
s = decodeString(decodeStack + 1, lzwold);
|
s = decodeString(decodeStack + 1, lzwold);
|
||||||
} else
|
} else
|
||||||
s = decodeString(decodeStack, lzwnew);
|
s = decodeString(decodeStack, lzwnew);
|
||||||
|
|
||||||
/* Reverse order of decoded string and
|
// Reverse order of decoded string and
|
||||||
* store in out buffer
|
// store in out buffer
|
||||||
*/
|
|
||||||
c = *s;
|
c = *s;
|
||||||
while (s >= decodeStack)
|
while (s >= decodeStack)
|
||||||
*out++ = *s--;
|
*out++ = *s--;
|
||||||
|
|
|
@ -23,8 +23,6 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "agi/agi.h"
|
#include "agi/agi.h"
|
||||||
#include "agi/sprite.h"
|
#include "agi/sprite.h"
|
||||||
#include "agi/graphics.h"
|
#include "agi/graphics.h"
|
||||||
|
@ -66,6 +64,7 @@ AgiMenu *Menu::getMenu(int i) {
|
||||||
AgiMenuOption *Menu::getMenuOption(int i, int j) {
|
AgiMenuOption *Menu::getMenuOption(int i, int j) {
|
||||||
AgiMenu *m = getMenu(i);
|
AgiMenu *m = getMenu(i);
|
||||||
MenuOptionList::iterator iter;
|
MenuOptionList::iterator iter;
|
||||||
|
|
||||||
for (iter = m->down.begin(); iter != m->down.end(); ++iter) {
|
for (iter = m->down.begin(); iter != m->down.end(); ++iter) {
|
||||||
AgiMenuOption* d = *iter;
|
AgiMenuOption* d = *iter;
|
||||||
if (d->index == j)
|
if (d->index == j)
|
||||||
|
@ -82,6 +81,7 @@ void Menu::drawMenuBar() {
|
||||||
MenuList::iterator iter;
|
MenuList::iterator iter;
|
||||||
for (iter = _menubar.begin(); iter != _menubar.end(); ++iter) {
|
for (iter = _menubar.begin(); iter != _menubar.end(); ++iter) {
|
||||||
AgiMenu *m = *iter;
|
AgiMenu *m = *iter;
|
||||||
|
|
||||||
_vm->printText(m->text, 0, m->col, 0, 40, MENU_FG, MENU_BG);
|
_vm->printText(m->text, 0, m->col, 0, 40, MENU_FG, MENU_BG);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,22 +89,26 @@ void Menu::drawMenuBar() {
|
||||||
|
|
||||||
void Menu::drawMenuHilite(int curMenu) {
|
void Menu::drawMenuHilite(int curMenu) {
|
||||||
AgiMenu *m = getMenu(curMenu);
|
AgiMenu *m = getMenu(curMenu);
|
||||||
|
|
||||||
debugC(6, kDebugLevelMenu, "[%s]", m->text);
|
debugC(6, kDebugLevelMenu, "[%s]", m->text);
|
||||||
|
|
||||||
_vm->printText(m->text, 0, m->col, 0, 40, MENU_BG, MENU_FG);
|
_vm->printText(m->text, 0, m->col, 0, 40, MENU_BG, MENU_FG);
|
||||||
_vm->flushLines(0, 0);
|
_vm->flushLines(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* draw box and pulldowns. */
|
// draw box and pulldowns.
|
||||||
void Menu::drawMenuOption(int hMenu) {
|
void Menu::drawMenuOption(int hMenu) {
|
||||||
/* find which vertical menu it is */
|
// find which vertical menu it is
|
||||||
AgiMenu *m = getMenu(hMenu);
|
AgiMenu *m = getMenu(hMenu);
|
||||||
|
|
||||||
_gfx->drawBox(m->wincol * CHAR_COLS, 1 * CHAR_LINES, (m->wincol + m->width + 2) * CHAR_COLS,
|
_gfx->drawBox(m->wincol * CHAR_COLS, 1 * CHAR_LINES, (m->wincol + m->width + 2) * CHAR_COLS,
|
||||||
(1 + m->height + 2) * CHAR_LINES, MENU_BG, MENU_LINE, 0);
|
(1 + m->height + 2) * CHAR_LINES, MENU_BG, MENU_LINE, 0);
|
||||||
|
|
||||||
MenuOptionList::iterator iter;
|
MenuOptionList::iterator iter;
|
||||||
|
|
||||||
for (iter = m->down.begin(); iter != m->down.end(); ++iter) {
|
for (iter = m->down.begin(); iter != m->down.end(); ++iter) {
|
||||||
AgiMenuOption* d = *iter;
|
AgiMenuOption* d = *iter;
|
||||||
|
|
||||||
_vm->printText(d->text, 0, m->wincol + 1, d->index + 2, m->width + 2,
|
_vm->printText(d->text, 0, m->wincol + 1, d->index + 2, m->width + 2,
|
||||||
MENU_FG, MENU_BG, !d->enabled);
|
MENU_FG, MENU_BG, !d->enabled);
|
||||||
}
|
}
|
||||||
|
@ -180,17 +184,24 @@ Menu::~Menu() {
|
||||||
MenuList::iterator iterh;
|
MenuList::iterator iterh;
|
||||||
for (iterh = _menubar.reverse_begin(); iterh != _menubar.end(); ) {
|
for (iterh = _menubar.reverse_begin(); iterh != _menubar.end(); ) {
|
||||||
AgiMenu *m = *iterh;
|
AgiMenu *m = *iterh;
|
||||||
|
|
||||||
debugC(3, kDebugLevelMenu, "deiniting hmenu %s", m->text);
|
debugC(3, kDebugLevelMenu, "deiniting hmenu %s", m->text);
|
||||||
|
|
||||||
MenuOptionList::iterator iterv;
|
MenuOptionList::iterator iterv;
|
||||||
|
|
||||||
for (iterv = m->down.reverse_begin(); iterv != m->down.end(); ) {
|
for (iterv = m->down.reverse_begin(); iterv != m->down.end(); ) {
|
||||||
AgiMenuOption *d = *iterv;
|
AgiMenuOption *d = *iterv;
|
||||||
|
|
||||||
debugC(3, kDebugLevelMenu, " deiniting vmenu %s", d->text);
|
debugC(3, kDebugLevelMenu, " deiniting vmenu %s", d->text);
|
||||||
|
|
||||||
free(d->text);
|
free(d->text);
|
||||||
delete d;
|
delete d;
|
||||||
|
|
||||||
iterv = m->down.reverse_erase(iterv);
|
iterv = m->down.reverse_erase(iterv);
|
||||||
}
|
}
|
||||||
free(m->text);
|
free(m->text);
|
||||||
delete m;
|
delete m;
|
||||||
|
|
||||||
iterh = _menubar.reverse_erase(iterh);
|
iterh = _menubar.reverse_erase(iterh);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -198,8 +209,10 @@ Menu::~Menu() {
|
||||||
void Menu::add(const char *s) {
|
void Menu::add(const char *s) {
|
||||||
AgiMenu *m = new AgiMenu;
|
AgiMenu *m = new AgiMenu;
|
||||||
m->text = strdup(s);
|
m->text = strdup(s);
|
||||||
|
|
||||||
while (m->text[strlen(m->text) - 1] == ' ')
|
while (m->text[strlen(m->text) - 1] == ' ')
|
||||||
m->text[strlen(m->text) - 1] = 0;
|
m->text[strlen(m->text) - 1] = 0;
|
||||||
|
|
||||||
m->width = 0;
|
m->width = 0;
|
||||||
m->height = 0;
|
m->height = 0;
|
||||||
m->index = _hIndex++;
|
m->index = _hIndex++;
|
||||||
|
@ -218,6 +231,7 @@ void Menu::addItem(const char *s, int code) {
|
||||||
int l;
|
int l;
|
||||||
|
|
||||||
AgiMenuOption* d = new AgiMenuOption;
|
AgiMenuOption* d = new AgiMenuOption;
|
||||||
|
|
||||||
d->text = strdup(s);
|
d->text = strdup(s);
|
||||||
d->enabled = true;
|
d->enabled = true;
|
||||||
d->event = code;
|
d->event = code;
|
||||||
|
@ -239,22 +253,26 @@ void Menu::addItem(const char *s, int code) {
|
||||||
m->width = l;
|
m->width = l;
|
||||||
|
|
||||||
debugC(3, kDebugLevelMenu, "Adding menu item: %s (size = %d)", s, m->height);
|
debugC(3, kDebugLevelMenu, "Adding menu item: %s (size = %d)", s, m->height);
|
||||||
|
|
||||||
m->down.push_back(d);
|
m->down.push_back(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::submit() {
|
void Menu::submit() {
|
||||||
debugC(3, kDebugLevelMenu, "Submitting menu");
|
debugC(3, kDebugLevelMenu, "Submitting menu");
|
||||||
|
|
||||||
/* add_about_option (); */
|
// add_about_option ();
|
||||||
|
|
||||||
/* If a menu has no options, delete it */
|
// If a menu has no options, delete it
|
||||||
MenuList::iterator iter;
|
MenuList::iterator iter;
|
||||||
for (iter = _menubar.reverse_begin(); iter != _menubar.end(); ) {
|
for (iter = _menubar.reverse_begin(); iter != _menubar.end(); ) {
|
||||||
AgiMenu *m = *iter;
|
AgiMenu *m = *iter;
|
||||||
|
|
||||||
if (m->down.empty()) {
|
if (m->down.empty()) {
|
||||||
free(m->text);
|
free(m->text);
|
||||||
delete m;
|
delete m;
|
||||||
|
|
||||||
_hMaxMenu--;
|
_hMaxMenu--;
|
||||||
|
|
||||||
iter = _menubar.reverse_erase(iter);
|
iter = _menubar.reverse_erase(iter);
|
||||||
} else {
|
} else {
|
||||||
--iter;
|
--iter;
|
||||||
|
@ -275,20 +293,23 @@ bool Menu::keyhandler(int key) {
|
||||||
_vm->_game.clockEnabled = false;
|
_vm->_game.clockEnabled = false;
|
||||||
drawMenuBar();
|
drawMenuBar();
|
||||||
}
|
}
|
||||||
/*
|
//
|
||||||
* Mouse handling
|
// Mouse handling
|
||||||
*/
|
//
|
||||||
if (g_mouse.button) {
|
if (g_mouse.button) {
|
||||||
int hmenu, vmenu;
|
int hmenu, vmenu;
|
||||||
|
|
||||||
buttonUsed = 1; /* Button has been used at least once */
|
buttonUsed = 1; // Button has been used at least once
|
||||||
|
|
||||||
if (g_mouse.y <= CHAR_LINES) {
|
if (g_mouse.y <= CHAR_LINES) {
|
||||||
/* on the menubar */
|
// on the menubar
|
||||||
hmenu = 0;
|
hmenu = 0;
|
||||||
|
|
||||||
MenuList::iterator iterh;
|
MenuList::iterator iterh;
|
||||||
|
|
||||||
for (iterh = _menubar.begin(); iterh != _menubar.end(); ++iterh) {
|
for (iterh = _menubar.begin(); iterh != _menubar.end(); ++iterh) {
|
||||||
AgiMenu *m = *iterh;
|
AgiMenu *m = *iterh;
|
||||||
|
|
||||||
if (mouseOverText(0, m->col, m->text)) {
|
if (mouseOverText(0, m->col, m->text)) {
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
|
@ -304,13 +325,16 @@ bool Menu::keyhandler(int key) {
|
||||||
_hCurMenu = hmenu;
|
_hCurMenu = hmenu;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* not in menubar */
|
// not in menubar
|
||||||
vmenu = 0;
|
vmenu = 0;
|
||||||
|
|
||||||
AgiMenu *m = getMenu(_hCurMenu);
|
AgiMenu *m = getMenu(_hCurMenu);
|
||||||
|
|
||||||
MenuOptionList::iterator iterv;
|
MenuOptionList::iterator iterv;
|
||||||
|
|
||||||
for (iterv = m->down.begin(); iterv != m->down.end(); ++iterv) {
|
for (iterv = m->down.begin(); iterv != m->down.end(); ++iterv) {
|
||||||
AgiMenuOption *do1 = *iterv;
|
AgiMenuOption *do1 = *iterv;
|
||||||
|
|
||||||
if (mouseOverText(2 + do1->index, m->wincol + 1, do1->text)) {
|
if (mouseOverText(2 + do1->index, m->wincol + 1, do1->text)) {
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
|
@ -327,7 +351,7 @@ bool Menu::keyhandler(int key) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (buttonUsed) {
|
} else if (buttonUsed) {
|
||||||
/* Button released */
|
// Button released
|
||||||
buttonUsed = 0;
|
buttonUsed = 0;
|
||||||
|
|
||||||
debugC(6, kDebugLevelMenu | kDebugLevelInput, "button released!");
|
debugC(6, kDebugLevelMenu | kDebugLevelInput, "button released!");
|
||||||
|
@ -338,15 +362,17 @@ bool Menu::keyhandler(int key) {
|
||||||
drawMenuOptionHilite(_hCurMenu, _vCurMenu);
|
drawMenuOptionHilite(_hCurMenu, _vCurMenu);
|
||||||
|
|
||||||
if (g_mouse.y <= CHAR_LINES) {
|
if (g_mouse.y <= CHAR_LINES) {
|
||||||
/* on the menubar */
|
// on the menubar
|
||||||
} else {
|
} else {
|
||||||
/* see which option we selected */
|
// see which option we selected
|
||||||
AgiMenu *m = getMenu(_hCurMenu);
|
AgiMenu *m = getMenu(_hCurMenu);
|
||||||
MenuOptionList::iterator iterv;
|
MenuOptionList::iterator iterv;
|
||||||
|
|
||||||
for (iterv = m->down.begin(); iterv != m->down.end(); ++iterv) {
|
for (iterv = m->down.begin(); iterv != m->down.end(); ++iterv) {
|
||||||
AgiMenuOption *d = *iterv;
|
AgiMenuOption *d = *iterv;
|
||||||
|
|
||||||
if (mouseOverText(2 + d->index, m->wincol + 1, d->text)) {
|
if (mouseOverText(2 + d->index, m->wincol + 1, d->text)) {
|
||||||
/* activate that option */
|
// activate that option
|
||||||
if (d->enabled) {
|
if (d->enabled) {
|
||||||
debugC(6, kDebugLevelMenu | kDebugLevelInput, "event %d registered", d->event);
|
debugC(6, kDebugLevelMenu | kDebugLevelInput, "event %d registered", d->event);
|
||||||
_vm->_game.evKeyp[d->event].occured = true;
|
_vm->_game.evKeyp[d->event].occured = true;
|
||||||
|
@ -383,6 +409,7 @@ bool Menu::keyhandler(int key) {
|
||||||
{
|
{
|
||||||
debugC(6, kDebugLevelMenu | kDebugLevelInput, "KEY_ENTER");
|
debugC(6, kDebugLevelMenu | kDebugLevelInput, "KEY_ENTER");
|
||||||
AgiMenuOption* d = getMenuOption(_hCurMenu, _vCurMenu);
|
AgiMenuOption* d = getMenuOption(_hCurMenu, _vCurMenu);
|
||||||
|
|
||||||
if (d->enabled) {
|
if (d->enabled) {
|
||||||
debugC(6, kDebugLevelMenu | kDebugLevelInput, "event %d registered", d->event);
|
debugC(6, kDebugLevelMenu | kDebugLevelInput, "event %d registered", d->event);
|
||||||
_vm->_game.evKeyp[d->event].occured = true;
|
_vm->_game.evKeyp[d->event].occured = true;
|
||||||
|
@ -428,6 +455,7 @@ exit_menu:
|
||||||
_vm->_game.keypress = 0;
|
_vm->_game.keypress = 0;
|
||||||
_vm->_game.clockEnabled = clockVal;
|
_vm->_game.clockEnabled = clockVal;
|
||||||
_vm->oldInputMode();
|
_vm->oldInputMode();
|
||||||
|
|
||||||
debugC(3, kDebugLevelMenu, "exit_menu: input mode reset to %d", _vm->_game.inputMode);
|
debugC(3, kDebugLevelMenu, "exit_menu: input mode reset to %d", _vm->_game.inputMode);
|
||||||
menuActive = false;
|
menuActive = false;
|
||||||
|
|
||||||
|
@ -435,15 +463,18 @@ exit_menu:
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::setItem(int event, int state) {
|
void Menu::setItem(int event, int state) {
|
||||||
/* scan all menus for event number # */
|
// scan all menus for event number #
|
||||||
|
|
||||||
debugC(6, kDebugLevelMenu, "event = %d, state = %d", event, state);
|
debugC(6, kDebugLevelMenu, "event = %d, state = %d", event, state);
|
||||||
MenuList::iterator iterh;
|
MenuList::iterator iterh;
|
||||||
|
|
||||||
for (iterh = _menubar.begin(); iterh != _menubar.end(); ++iterh) {
|
for (iterh = _menubar.begin(); iterh != _menubar.end(); ++iterh) {
|
||||||
AgiMenu *m = *iterh;
|
AgiMenu *m = *iterh;
|
||||||
MenuOptionList::iterator iterv;
|
MenuOptionList::iterator iterv;
|
||||||
|
|
||||||
for (iterv = m->down.begin(); iterv != m->down.end(); ++iterv) {
|
for (iterv = m->down.begin(); iterv != m->down.end(); ++iterv) {
|
||||||
AgiMenuOption *d = *iterv;
|
AgiMenuOption *d = *iterv;
|
||||||
|
|
||||||
if (d->event == event) {
|
if (d->event == event) {
|
||||||
d->enabled = state;
|
d->enabled = state;
|
||||||
// keep going; we need to set the state of every menu item
|
// keep going; we need to set the state of every menu item
|
||||||
|
@ -458,8 +489,10 @@ void Menu::enableAll() {
|
||||||
for (iterh = _menubar.begin(); iterh != _menubar.end(); ++iterh) {
|
for (iterh = _menubar.begin(); iterh != _menubar.end(); ++iterh) {
|
||||||
AgiMenu *m = *iterh;
|
AgiMenu *m = *iterh;
|
||||||
MenuOptionList::iterator iterv;
|
MenuOptionList::iterator iterv;
|
||||||
|
|
||||||
for (iterv = m->down.begin(); iterv != m->down.end(); ++iterv) {
|
for (iterv = m->down.begin(); iterv != m->down.end(); ++iterv) {
|
||||||
AgiMenuOption *d = *iterv;
|
AgiMenuOption *d = *iterv;
|
||||||
|
|
||||||
d->enabled = true;
|
d->enabled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,11 +30,11 @@
|
||||||
|
|
||||||
namespace Agi {
|
namespace Agi {
|
||||||
|
|
||||||
#define MENU_BG 0x0f /* White */
|
#define MENU_BG 0x0f // White
|
||||||
#define MENU_DISABLED 0x07 /* Grey */
|
#define MENU_DISABLED 0x07 // Grey
|
||||||
|
|
||||||
#define MENU_FG 0x00 /* Black */
|
#define MENU_FG 0x00 // Black
|
||||||
#define MENU_LINE 0x00 /* Black */
|
#define MENU_LINE 0x00 // Black
|
||||||
|
|
||||||
struct AgiMenu;
|
struct AgiMenu;
|
||||||
struct AgiMenuOption;
|
struct AgiMenuOption;
|
||||||
|
|
|
@ -23,8 +23,6 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "agi/agi.h"
|
#include "agi/agi.h"
|
||||||
|
|
||||||
namespace Agi {
|
namespace Agi {
|
||||||
|
@ -76,7 +74,7 @@ void AgiEngine::motionWander(VtEntry *v) {
|
||||||
if (isEgoView(v)) {
|
if (isEgoView(v)) {
|
||||||
_game.vars[vEgoDir] = v->direction;
|
_game.vars[vEgoDir] = v->direction;
|
||||||
while (v->parm1 < 6) {
|
while (v->parm1 < 6) {
|
||||||
v->parm1 = _rnd->getRandomNumber(50); /* huh? */
|
v->parm1 = _rnd->getRandomNumber(50); // huh?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -92,10 +90,10 @@ void AgiEngine::motionFollowEgo(VtEntry *v) {
|
||||||
objX = v->xPos + v->xSize / 2;
|
objX = v->xPos + v->xSize / 2;
|
||||||
objY = v->yPos;
|
objY = v->yPos;
|
||||||
|
|
||||||
/* Get direction to reach ego */
|
// Get direction to reach ego
|
||||||
dir = getDirection(objX, objY, egoX, egoY, v->parm1);
|
dir = getDirection(objX, objY, egoX, egoY, v->parm1);
|
||||||
|
|
||||||
/* Already at ego coordinates */
|
// Already at ego coordinates
|
||||||
if (dir == 0) {
|
if (dir == 0) {
|
||||||
v->direction = 0;
|
v->direction = 0;
|
||||||
v->motion = MOTION_NORMAL;
|
v->motion = MOTION_NORMAL;
|
||||||
|
@ -126,12 +124,12 @@ void AgiEngine::motionFollowEgo(VtEntry *v) {
|
||||||
if (v->parm3 != 0) {
|
if (v->parm3 != 0) {
|
||||||
int k;
|
int k;
|
||||||
|
|
||||||
/* DF: this is ugly and I dont know why this works, but
|
// DF: this is ugly and I dont know why this works, but
|
||||||
* other line does not! (watcom complained about lvalue)
|
// other line does not! (watcom complained about lvalue)
|
||||||
*
|
//
|
||||||
* if (((int8)v->parm3 -= v->step_size) < 0)
|
// if (((int8)v->parm3 -= v->step_size) < 0)
|
||||||
* v->parm3 = 0;
|
// v->parm3 = 0;
|
||||||
*/
|
|
||||||
k = v->parm3;
|
k = v->parm3;
|
||||||
k -= v->stepSize;
|
k -= v->stepSize;
|
||||||
v->parm3 = k;
|
v->parm3 = k;
|
||||||
|
@ -146,7 +144,7 @@ void AgiEngine::motionFollowEgo(VtEntry *v) {
|
||||||
void AgiEngine::motionMoveObj(VtEntry *v) {
|
void AgiEngine::motionMoveObj(VtEntry *v) {
|
||||||
v->direction = getDirection(v->xPos, v->yPos, v->parm1, v->parm2, v->stepSize);
|
v->direction = getDirection(v->xPos, v->yPos, v->parm1, v->parm2, v->stepSize);
|
||||||
|
|
||||||
/* Update V6 if ego */
|
// Update V6 if ego
|
||||||
if (isEgoView(v))
|
if (isEgoView(v))
|
||||||
_game.vars[vEgoDir] = v->direction;
|
_game.vars[vEgoDir] = v->direction;
|
||||||
|
|
||||||
|
|
|
@ -44,9 +44,8 @@ int AgiEngine::decodeObjects(uint8 *mem, uint32 flen) {
|
||||||
_game.numObjects = 0;
|
_game.numObjects = 0;
|
||||||
_objects = NULL;
|
_objects = NULL;
|
||||||
|
|
||||||
/* check if first pointer exceeds file size
|
// check if first pointer exceeds file size
|
||||||
* if so, its encrypted, else it is not
|
// if so, its encrypted, else it is not
|
||||||
*/
|
|
||||||
|
|
||||||
if (READ_LE_UINT16(mem) > flen) {
|
if (READ_LE_UINT16(mem) > flen) {
|
||||||
report("Decrypting objects... ");
|
report("Decrypting objects... ");
|
||||||
|
@ -54,11 +53,10 @@ int AgiEngine::decodeObjects(uint8 *mem, uint32 flen) {
|
||||||
report("done.\n");
|
report("done.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* alloc memory for object list
|
// alloc memory for object list
|
||||||
* byte 3 = number of animated objects. this is ignored.. ??
|
// byte 3 = number of animated objects. this is ignored.. ??
|
||||||
*/
|
|
||||||
if (READ_LE_UINT16(mem) / padsize >= 256) {
|
if (READ_LE_UINT16(mem) / padsize >= 256) {
|
||||||
/* die with no error! AGDS game needs not to die to work!! :( */
|
// die with no error! AGDS game needs not to die to work!! :(
|
||||||
return errOK;
|
return errOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +66,7 @@ int AgiEngine::decodeObjects(uint8 *mem, uint32 flen) {
|
||||||
if (allocObjects(_game.numObjects) != errOK)
|
if (allocObjects(_game.numObjects) != errOK)
|
||||||
return errNotEnoughMemory;
|
return errNotEnoughMemory;
|
||||||
|
|
||||||
/* build the object list */
|
// build the object list
|
||||||
for (i = 0, so = padsize; i < _game.numObjects; i++, so += padsize) {
|
for (i = 0, so = padsize; i < _game.numObjects; i++, so += padsize) {
|
||||||
int offset;
|
int offset;
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ namespace Agi {
|
||||||
static struct AgiLogic *curLogic;
|
static struct AgiLogic *curLogic;
|
||||||
static AgiEngine *g_agi;
|
static AgiEngine *g_agi;
|
||||||
|
|
||||||
int timerHack; /* Workaround for timer loop in MH1 */
|
int timerHack; // Workaround for timer loop in MH1
|
||||||
|
|
||||||
#define _v game.vars
|
#define _v game.vars
|
||||||
#define cmd(x) static void cmd_##x (uint8 *p)
|
#define cmd(x) static void cmd_##x (uint8 *p)
|
||||||
|
@ -291,7 +291,7 @@ cmd(release_priority) {
|
||||||
vt.flags &= ~FIXED_PRIORITY;
|
vt.flags &= ~FIXED_PRIORITY;
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd(set_upper_left) { /* do nothing (AGI 2.917) */
|
cmd(set_upper_left) { // do nothing (AGI 2.917)
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd(start_update) {
|
cmd(start_update) {
|
||||||
|
@ -497,23 +497,23 @@ cmd(load_game) {
|
||||||
game.simpleSave ? g_agi->loadGameSimple() : g_agi->loadGameDialog();
|
game.simpleSave ? g_agi->loadGameSimple() : g_agi->loadGameDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd(init_disk) { /* do nothing */
|
cmd(init_disk) { // do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd(log) { /* do nothing */
|
cmd(log) { // do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd(trace_on) { /* do nothing */
|
cmd(trace_on) { // do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd(trace_info) { /* do nothing */
|
cmd(trace_info) { // do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd(show_mem) {
|
cmd(show_mem) {
|
||||||
g_agi->messageBox("Enough memory");
|
g_agi->messageBox("Enough memory");
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd(init_joy) { /* do nothing */ ;
|
cmd(init_joy) { // do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd(script_size) {
|
cmd(script_size) {
|
||||||
|
@ -600,15 +600,14 @@ cmd(obj_status_f) {
|
||||||
g_agi->messageBox(msg);
|
g_agi->messageBox(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* unknown commands:
|
// unknown commands:
|
||||||
* unk_170: Force savegame name -- j5
|
// unk_170: Force savegame name -- j5
|
||||||
* unk_171: script save -- j5
|
// unk_171: script save -- j5
|
||||||
* unk_172: script restore -- j5
|
// unk_172: script restore -- j5
|
||||||
* unk_173: Activate keypressed control (ego only moves while key is pressed)
|
// unk_173: Activate keypressed control (ego only moves while key is pressed)
|
||||||
* unk_174: Change priority table (used in KQ4) -- j5
|
// unk_174: Change priority table (used in KQ4) -- j5
|
||||||
* unk_177: Disable menus completely -- j5
|
// unk_177: Disable menus completely -- j5
|
||||||
* unk_181: Deactivate keypressed control (default control of ego)
|
// unk_181: Deactivate keypressed control (default control of ego)
|
||||||
*/
|
|
||||||
cmd(set_simple) {
|
cmd(set_simple) {
|
||||||
if (!(g_agi->getFeatures() & (GF_AGI256 | GF_AGI256_2))) {
|
if (!(g_agi->getFeatures() & (GF_AGI256 | GF_AGI256_2))) {
|
||||||
game.simpleSave = true;
|
game.simpleSave = true;
|
||||||
|
@ -723,9 +722,8 @@ cmd(call) {
|
||||||
int oldCIP;
|
int oldCIP;
|
||||||
int oldLognum;
|
int oldLognum;
|
||||||
|
|
||||||
/* CM: we don't save sIP because set.scan.start can be
|
// CM: we don't save sIP because set.scan.start can be
|
||||||
* used in a called script (fixes xmas demo)
|
// used in a called script (fixes xmas demo)
|
||||||
*/
|
|
||||||
oldCIP = curLogic->cIP;
|
oldCIP = curLogic->cIP;
|
||||||
oldLognum = game.lognum;
|
oldLognum = game.lognum;
|
||||||
|
|
||||||
|
@ -766,10 +764,12 @@ cmd(draw_pic) {
|
||||||
|
|
||||||
cmd(show_pic) {
|
cmd(show_pic) {
|
||||||
debugC(6, kDebugLevelScripts, "=== show pic ===");
|
debugC(6, kDebugLevelScripts, "=== show pic ===");
|
||||||
|
|
||||||
g_agi->setflag(fOutputMode, false);
|
g_agi->setflag(fOutputMode, false);
|
||||||
cmd_close_window(NULL);
|
cmd_close_window(NULL);
|
||||||
g_picture->showPic();
|
g_picture->showPic();
|
||||||
game.pictureShown = 1;
|
game.pictureShown = 1;
|
||||||
|
|
||||||
debugC(6, kDebugLevelScripts, "--- end of show pic ---");
|
debugC(6, kDebugLevelScripts, "--- end of show pic ---");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -781,11 +781,12 @@ cmd(load_pic) {
|
||||||
|
|
||||||
cmd(discard_pic) {
|
cmd(discard_pic) {
|
||||||
debugC(6, kDebugLevelScripts, "--- discard pic ---");
|
debugC(6, kDebugLevelScripts, "--- discard pic ---");
|
||||||
/* do nothing */
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd(overlay_pic) {
|
cmd(overlay_pic) {
|
||||||
debugC(6, kDebugLevelScripts, "--- overlay pic ---");
|
debugC(6, kDebugLevelScripts, "--- overlay pic ---");
|
||||||
|
|
||||||
g_sprites->eraseBoth();
|
g_sprites->eraseBoth();
|
||||||
g_picture->decodePicture(_v[p0], false);
|
g_picture->decodePicture(_v[p0], false);
|
||||||
g_sprites->blitBoth();
|
g_sprites->blitBoth();
|
||||||
|
@ -798,7 +799,9 @@ cmd(show_pri_screen) {
|
||||||
g_sprites->eraseBoth();
|
g_sprites->eraseBoth();
|
||||||
g_picture->showPic();
|
g_picture->showPic();
|
||||||
g_sprites->blitBoth();
|
g_sprites->blitBoth();
|
||||||
|
|
||||||
g_agi->waitKey();
|
g_agi->waitKey();
|
||||||
|
|
||||||
g_agi->_debug.priority = 0;
|
g_agi->_debug.priority = 0;
|
||||||
g_sprites->eraseBoth();
|
g_sprites->eraseBoth();
|
||||||
g_picture->showPic();
|
g_picture->showPic();
|
||||||
|
@ -818,6 +821,7 @@ cmd(animate_obj) {
|
||||||
|
|
||||||
cmd(unanimate_all) {
|
cmd(unanimate_all) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < MAX_VIEWTABLE; i++)
|
for (i = 0; i < MAX_VIEWTABLE; i++)
|
||||||
game.viewTable[i].flags &= ~(ANIMATED | DRAWN);
|
game.viewTable[i].flags &= ~(ANIMATED | DRAWN);
|
||||||
}
|
}
|
||||||
|
@ -836,6 +840,7 @@ cmd(draw) {
|
||||||
g_agi->setLoop(&vt, vt.currentLoop);
|
g_agi->setLoop(&vt, vt.currentLoop);
|
||||||
g_agi->setCel(&vt, vt.currentCel);
|
g_agi->setCel(&vt, vt.currentCel);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_agi->fixPosition(p0);
|
g_agi->fixPosition(p0);
|
||||||
vt.xPos2 = vt.xPos;
|
vt.xPos2 = vt.xPos;
|
||||||
vt.yPos2 = vt.yPos;
|
vt.yPos2 = vt.yPos;
|
||||||
|
@ -854,7 +859,7 @@ cmd(draw) {
|
||||||
// TODO: Investigate this further and check if any other fanmade AGI
|
// TODO: Investigate this further and check if any other fanmade AGI
|
||||||
// games are affected. If yes, then it'd be best to set this for Space
|
// games are affected. If yes, then it'd be best to set this for Space
|
||||||
// Trek only
|
// Trek only
|
||||||
if (g_agi->getFeatures() & GF_FANMADE) /* See Sarien bug #546562 */
|
if (g_agi->getFeatures() & GF_FANMADE) // See Sarien bug #546562
|
||||||
vt.flags |= ANIMATED;
|
vt.flags |= ANIMATED;
|
||||||
|
|
||||||
g_sprites->blitUpdSprites();
|
g_sprites->blitUpdSprites();
|
||||||
|
@ -870,6 +875,7 @@ cmd(erase) {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
g_sprites->eraseUpdSprites();
|
g_sprites->eraseUpdSprites();
|
||||||
|
|
||||||
if (vt.flags & UPDATE) {
|
if (vt.flags & UPDATE) {
|
||||||
vt.flags &= ~DRAWN;
|
vt.flags &= ~DRAWN;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1002,7 +1008,7 @@ cmd(normal_motion) {
|
||||||
cmd(stop_motion) {
|
cmd(stop_motion) {
|
||||||
vt.direction = 0;
|
vt.direction = 0;
|
||||||
vt.motion = MOTION_NORMAL;
|
vt.motion = MOTION_NORMAL;
|
||||||
if (p0 == 0) { /* ego only */
|
if (p0 == 0) { // ego only
|
||||||
_v[vEgoDir] = 0;
|
_v[vEgoDir] = 0;
|
||||||
game.playerControl = false;
|
game.playerControl = false;
|
||||||
}
|
}
|
||||||
|
@ -1010,7 +1016,7 @@ cmd(stop_motion) {
|
||||||
|
|
||||||
cmd(start_motion) {
|
cmd(start_motion) {
|
||||||
vt.motion = MOTION_NORMAL;
|
vt.motion = MOTION_NORMAL;
|
||||||
if (p0 == 0) { /* ego only */
|
if (p0 == 0) { // ego only
|
||||||
_v[vEgoDir] = 0;
|
_v[vEgoDir] = 0;
|
||||||
game.playerControl = true;
|
game.playerControl = true;
|
||||||
}
|
}
|
||||||
|
@ -1035,7 +1041,7 @@ cmd(follow_ego) {
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd(move_obj) {
|
cmd(move_obj) {
|
||||||
/* _D (_D_WARN "o=%d, x=%d, y=%d, s=%d, f=%d", p0, p1, p2, p3, p4); */
|
// _D (_D_WARN "o=%d, x=%d, y=%d, s=%d, f=%d", p0, p1, p2, p3, p4);
|
||||||
|
|
||||||
vt.motion = MOTION_MOVE_OBJ;
|
vt.motion = MOTION_MOVE_OBJ;
|
||||||
vt.parm1 = p1;
|
vt.parm1 = p1;
|
||||||
|
@ -1052,7 +1058,7 @@ cmd(move_obj) {
|
||||||
if (p0 == 0)
|
if (p0 == 0)
|
||||||
game.playerControl = false;
|
game.playerControl = false;
|
||||||
|
|
||||||
/* AGI 2.272 (ddp, xmas) doesn't call move_obj! */
|
// AGI 2.272 (ddp, xmas) doesn't call move_obj!
|
||||||
if (g_agi->agiGetRelease() > 0x2272)
|
if (g_agi->agiGetRelease() > 0x2272)
|
||||||
g_agi->moveObj(&vt);
|
g_agi->moveObj(&vt);
|
||||||
}
|
}
|
||||||
|
@ -1073,7 +1079,7 @@ cmd(move_obj_f) {
|
||||||
if (p0 == 0)
|
if (p0 == 0)
|
||||||
game.playerControl = false;
|
game.playerControl = false;
|
||||||
|
|
||||||
/* AGI 2.272 (ddp, xmas) doesn't call move_obj! */
|
// AGI 2.272 (ddp, xmas) doesn't call move_obj!
|
||||||
if (g_agi->agiGetRelease() > 0x2272)
|
if (g_agi->agiGetRelease() > 0x2272)
|
||||||
g_agi->moveObj(&vt);
|
g_agi->moveObj(&vt);
|
||||||
}
|
}
|
||||||
|
@ -1081,6 +1087,7 @@ cmd(move_obj_f) {
|
||||||
cmd(wander) {
|
cmd(wander) {
|
||||||
if (p0 == 0)
|
if (p0 == 0)
|
||||||
game.playerControl = false;
|
game.playerControl = false;
|
||||||
|
|
||||||
vt.motion = MOTION_WANDER;
|
vt.motion = MOTION_WANDER;
|
||||||
vt.flags |= UPDATE;
|
vt.flags |= UPDATE;
|
||||||
}
|
}
|
||||||
|
@ -1114,12 +1121,14 @@ cmd(pause) {
|
||||||
|
|
||||||
cmd(set_menu) {
|
cmd(set_menu) {
|
||||||
debugC(4, kDebugLevelScripts, "text %02x of %02x", p0, curLogic->numTexts);
|
debugC(4, kDebugLevelScripts, "text %02x of %02x", p0, curLogic->numTexts);
|
||||||
|
|
||||||
if (curLogic->texts != NULL && p0 <= curLogic->numTexts)
|
if (curLogic->texts != NULL && p0 <= curLogic->numTexts)
|
||||||
g_agi->_menu->add(curLogic->texts[p0 - 1]);
|
g_agi->_menu->add(curLogic->texts[p0 - 1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd(set_menu_item) {
|
cmd(set_menu_item) {
|
||||||
debugC(4, kDebugLevelScripts, "text %02x of %02x", p0, curLogic->numTexts);
|
debugC(4, kDebugLevelScripts, "text %02x of %02x", p0, curLogic->numTexts);
|
||||||
|
|
||||||
if (curLogic->texts != NULL && p0 <= curLogic->numTexts)
|
if (curLogic->texts != NULL && p0 <= curLogic->numTexts)
|
||||||
g_agi->_menu->addItem(curLogic->texts[p0 - 1], p1);
|
g_agi->_menu->addItem(curLogic->texts[p0 - 1], p1);
|
||||||
}
|
}
|
||||||
|
@ -1134,7 +1143,7 @@ cmd(version) {
|
||||||
"\n"
|
"\n"
|
||||||
" \n\n"
|
" \n\n"
|
||||||
" Emulating AGI v%x.002.%03x\n";
|
" Emulating AGI v%x.002.%03x\n";
|
||||||
/* no Sierra as it wraps textbox */
|
// no Sierra as it wraps textbox
|
||||||
char *r, *q;
|
char *r, *q;
|
||||||
int ver, maj, min;
|
int ver, maj, min;
|
||||||
char msg[256];
|
char msg[256];
|
||||||
|
@ -1150,9 +1159,10 @@ cmd(version) {
|
||||||
q = maj == 2 ? ver2Msg : ver3Msg;
|
q = maj == 2 ? ver2Msg : ver3Msg;
|
||||||
r = strchr(q + 1, '\n');
|
r = strchr(q + 1, '\n');
|
||||||
|
|
||||||
/* insert our version into the other version */
|
// insert our version into the other version
|
||||||
len = strlen(verMsg);
|
len = strlen(verMsg);
|
||||||
gap = r - q;
|
gap = r - q;
|
||||||
|
|
||||||
if (gap < 0)
|
if (gap < 0)
|
||||||
gap = 0;
|
gap = 0;
|
||||||
else
|
else
|
||||||
|
@ -1172,17 +1182,18 @@ cmd(configure_screen) {
|
||||||
cmd(text_screen) {
|
cmd(text_screen) {
|
||||||
debugC(4, kDebugLevelScripts, "switching to text mode");
|
debugC(4, kDebugLevelScripts, "switching to text mode");
|
||||||
game.gfxMode = false;
|
game.gfxMode = false;
|
||||||
/*
|
|
||||||
* Simulates the "bright background bit" of the PC video
|
// Simulates the "bright background bit" of the PC video
|
||||||
* controller.
|
// controller.
|
||||||
*/
|
|
||||||
if (game.colorBg)
|
if (game.colorBg)
|
||||||
game.colorBg |= 0x08;
|
game.colorBg |= 0x08;
|
||||||
|
|
||||||
g_gfx->clearScreen(game.colorBg);
|
g_gfx->clearScreen(game.colorBg);
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd(graphics) {
|
cmd(graphics) {
|
||||||
debugC(4, kDebugLevelScripts, "switching to graphics mode");
|
debugC(4, kDebugLevelScripts, "switching to graphics mode");
|
||||||
|
|
||||||
if (!game.gfxMode) {
|
if (!game.gfxMode) {
|
||||||
game.gfxMode = true;
|
game.gfxMode = true;
|
||||||
g_gfx->clearScreen(0);
|
g_gfx->clearScreen(0);
|
||||||
|
@ -1290,6 +1301,7 @@ cmd(distance) {
|
||||||
|
|
||||||
cmd(accept_input) {
|
cmd(accept_input) {
|
||||||
debugC(4, kDebugLevelScripts | kDebugLevelInput, "input normal");
|
debugC(4, kDebugLevelScripts | kDebugLevelInput, "input normal");
|
||||||
|
|
||||||
g_agi->newInputMode(INPUT_NORMAL);
|
g_agi->newInputMode(INPUT_NORMAL);
|
||||||
game.inputEnabled = true;
|
game.inputEnabled = true;
|
||||||
g_agi->writePrompt();
|
g_agi->writePrompt();
|
||||||
|
@ -1297,6 +1309,7 @@ cmd(accept_input) {
|
||||||
|
|
||||||
cmd(prevent_input) {
|
cmd(prevent_input) {
|
||||||
debugC(4, kDebugLevelScripts | kDebugLevelInput, "no input");
|
debugC(4, kDebugLevelScripts | kDebugLevelInput, "no input");
|
||||||
|
|
||||||
g_agi->newInputMode(INPUT_NONE);
|
g_agi->newInputMode(INPUT_NONE);
|
||||||
game.inputEnabled = false;
|
game.inputEnabled = false;
|
||||||
}
|
}
|
||||||
|
@ -1310,9 +1323,8 @@ cmd(get_string) {
|
||||||
row = p2;
|
row = p2;
|
||||||
col = p3;
|
col = p3;
|
||||||
|
|
||||||
/* Workaround for SQLC bug.
|
// Workaround for SQLC bug.
|
||||||
* See Sarien bug #792125 for details
|
// See Sarien bug #792125 for details
|
||||||
*/
|
|
||||||
if (row > 24)
|
if (row > 24)
|
||||||
row = 24;
|
row = 24;
|
||||||
if (col > 39)
|
if (col > 39)
|
||||||
|
@ -1322,10 +1334,11 @@ cmd(get_string) {
|
||||||
|
|
||||||
if (curLogic->texts != NULL && curLogic->numTexts >= tex) {
|
if (curLogic->texts != NULL && curLogic->numTexts >= tex) {
|
||||||
int len = strlen(curLogic->texts[tex]);
|
int len = strlen(curLogic->texts[tex]);
|
||||||
|
|
||||||
g_agi->printText(curLogic->texts[tex], 0, col, row, len, game.colorFg, game.colorBg);
|
g_agi->printText(curLogic->texts[tex], 0, col, row, len, game.colorFg, game.colorBg);
|
||||||
g_agi->getString(col + len - 1, row, p4, p0);
|
g_agi->getString(col + len - 1, row, p4, p0);
|
||||||
|
|
||||||
/* SGEO: display input char */
|
// SGEO: display input char
|
||||||
g_gfx->printCharacter((col + len), row, game.cursorChar, game.colorFg, game.colorBg);
|
g_gfx->printCharacter((col + len), row, game.cursorChar, game.colorFg, game.colorBg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1336,14 +1349,16 @@ cmd(get_string) {
|
||||||
|
|
||||||
cmd(get_num) {
|
cmd(get_num) {
|
||||||
debugC(4, kDebugLevelScripts, "%d %d", p0, p1);
|
debugC(4, kDebugLevelScripts, "%d %d", p0, p1);
|
||||||
|
|
||||||
g_agi->newInputMode(INPUT_GETSTRING);
|
g_agi->newInputMode(INPUT_GETSTRING);
|
||||||
|
|
||||||
if (curLogic->texts != NULL && curLogic->numTexts >= (p0 - 1)) {
|
if (curLogic->texts != NULL && curLogic->numTexts >= (p0 - 1)) {
|
||||||
int len = strlen(curLogic->texts[p0 - 1]);
|
int len = strlen(curLogic->texts[p0 - 1]);
|
||||||
|
|
||||||
g_agi->printText(curLogic->texts[p0 - 1], 0, 0, 22, len, game.colorFg, game.colorBg);
|
g_agi->printText(curLogic->texts[p0 - 1], 0, 0, 22, len, game.colorFg, game.colorBg);
|
||||||
g_agi->getString(len - 1, 22, 3, MAX_STRINGS);
|
g_agi->getString(len - 1, 22, 3, MAX_STRINGS);
|
||||||
|
|
||||||
/* CM: display input char */
|
// CM: display input char
|
||||||
g_gfx->printCharacter((p3 + len), 22, game.cursorChar, game.colorFg, game.colorBg);
|
g_gfx->printCharacter((p3 + len), 22, game.cursorChar, game.colorFg, game.colorBg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1352,7 +1367,9 @@ cmd(get_num) {
|
||||||
} while (game.inputMode == INPUT_GETSTRING && !(g_agi->shouldQuit() || g_agi->restartGame));
|
} while (game.inputMode == INPUT_GETSTRING && !(g_agi->shouldQuit() || g_agi->restartGame));
|
||||||
|
|
||||||
_v[p1] = atoi(game.strings[MAX_STRINGS]);
|
_v[p1] = atoi(game.strings[MAX_STRINGS]);
|
||||||
|
|
||||||
debugC(4, kDebugLevelScripts, "[%s] -> %d", game.strings[MAX_STRINGS], _v[p1]);
|
debugC(4, kDebugLevelScripts, "[%s] -> %d", game.strings[MAX_STRINGS], _v[p1]);
|
||||||
|
|
||||||
g_agi->clearLines(22, 22, game.colorBg);
|
g_agi->clearLines(22, 22, game.colorBg);
|
||||||
g_agi->flushLines(22, 22);
|
g_agi->flushLines(22, 22);
|
||||||
}
|
}
|
||||||
|
@ -1361,7 +1378,7 @@ cmd(set_cursor_char) {
|
||||||
if (curLogic->texts != NULL && (p0 - 1) <= curLogic->numTexts) {
|
if (curLogic->texts != NULL && (p0 - 1) <= curLogic->numTexts) {
|
||||||
game.cursorChar = *curLogic->texts[p0 - 1];
|
game.cursorChar = *curLogic->texts[p0 - 1];
|
||||||
} else {
|
} else {
|
||||||
/* default */
|
// default
|
||||||
game.cursorChar = '_';
|
game.cursorChar = '_';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1371,7 +1388,7 @@ cmd(set_key) {
|
||||||
|
|
||||||
debugC(4, kDebugLevelScripts, "%d %d %d", p0, p1, p2);
|
debugC(4, kDebugLevelScripts, "%d %d %d", p0, p1, p2);
|
||||||
|
|
||||||
if (game.evKeyp[p2].data != 0) /* TBC sets c23 (ESC) twice! */
|
if (game.evKeyp[p2].data != 0) // TBC sets c23 (ESC) twice!
|
||||||
return;
|
return;
|
||||||
|
|
||||||
key = 256 * p1 + p0;
|
key = 256 * p1 + p0;
|
||||||
|
@ -1380,7 +1397,7 @@ cmd(set_key) {
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd(set_string) {
|
cmd(set_string) {
|
||||||
/* CM: to avoid crash in Groza (str = 150) */
|
// CM: to avoid crash in Groza (str = 150)
|
||||||
if (p0 > MAX_STRINGS)
|
if (p0 > MAX_STRINGS)
|
||||||
return;
|
return;
|
||||||
strcpy(game.strings[p0], curLogic->texts[p1 - 1]);
|
strcpy(game.strings[p0], curLogic->texts[p1 - 1]);
|
||||||
|
@ -1406,12 +1423,13 @@ cmd(clear_text_rect) {
|
||||||
|
|
||||||
if ((c = p4) != 0)
|
if ((c = p4) != 0)
|
||||||
c = 15;
|
c = 15;
|
||||||
|
|
||||||
x1 = p1 * CHAR_COLS;
|
x1 = p1 * CHAR_COLS;
|
||||||
y1 = p0 * CHAR_LINES;
|
y1 = p0 * CHAR_LINES;
|
||||||
x2 = (p3 + 1) * CHAR_COLS - 1;
|
x2 = (p3 + 1) * CHAR_COLS - 1;
|
||||||
y2 = (p2 + 1) * CHAR_LINES - 1;
|
y2 = (p2 + 1) * CHAR_LINES - 1;
|
||||||
|
|
||||||
/* Added to prevent crash with x2 = 40 in the iigs demo */
|
// Added to prevent crash with x2 = 40 in the iigs demo
|
||||||
if (x1 > GFX_WIDTH)
|
if (x1 > GFX_WIDTH)
|
||||||
x1 = GFX_WIDTH - 1;
|
x1 = GFX_WIDTH - 1;
|
||||||
if (x2 > GFX_WIDTH)
|
if (x2 > GFX_WIDTH)
|
||||||
|
@ -1438,7 +1456,7 @@ cmd(echo_line) {
|
||||||
cmd(clear_lines) {
|
cmd(clear_lines) {
|
||||||
uint8 l;
|
uint8 l;
|
||||||
|
|
||||||
/* Residence 44 calls clear.lines(24,0,0), see Sarien bug #558423 */
|
// Residence 44 calls clear.lines(24,0,0), see Sarien bug #558423
|
||||||
l = p1 ? p1 : p0;
|
l = p1 ? p1 : p0;
|
||||||
|
|
||||||
// Agent06 incorrectly calls clear.lines(1,150,0), see ScummVM bugs
|
// Agent06 incorrectly calls clear.lines(1,150,0), see ScummVM bugs
|
||||||
|
@ -1451,22 +1469,27 @@ cmd(clear_lines) {
|
||||||
|
|
||||||
cmd(print) {
|
cmd(print) {
|
||||||
int n = p0 < 1 ? 1 : p0;
|
int n = p0 < 1 ? 1 : p0;
|
||||||
|
|
||||||
g_agi->print(curLogic->texts[n - 1], 0, 0, 0);
|
g_agi->print(curLogic->texts[n - 1], 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd(print_f) {
|
cmd(print_f) {
|
||||||
int n = _v[p0] < 1 ? 1 : _v[p0];
|
int n = _v[p0] < 1 ? 1 : _v[p0];
|
||||||
|
|
||||||
g_agi->print(curLogic->texts[n - 1], 0, 0, 0);
|
g_agi->print(curLogic->texts[n - 1], 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd(print_at) {
|
cmd(print_at) {
|
||||||
int n = p0 < 1 ? 1 : p0;
|
int n = p0 < 1 ? 1 : p0;
|
||||||
|
|
||||||
debugC(4, kDebugLevelScripts, "%d %d %d %d", p0, p1, p2, p3);
|
debugC(4, kDebugLevelScripts, "%d %d %d %d", p0, p1, p2, p3);
|
||||||
|
|
||||||
g_agi->print(curLogic->texts[n - 1], p1, p2, p3);
|
g_agi->print(curLogic->texts[n - 1], p1, p2, p3);
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd(print_at_v) {
|
cmd(print_at_v) {
|
||||||
int n = _v[p0] < 1 ? 1 : _v[p0];
|
int n = _v[p0] < 1 ? 1 : _v[p0];
|
||||||
|
|
||||||
g_agi->print(curLogic->texts[n - 1], p1, p2, p3);
|
g_agi->print(curLogic->texts[n - 1], p1, p2, p3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1484,7 +1507,7 @@ cmd(set_pri_base) {
|
||||||
|
|
||||||
report("Priority base set to %d\n", p0);
|
report("Priority base set to %d\n", p0);
|
||||||
|
|
||||||
/* game.alt_pri = true; */
|
// game.alt_pri = true;
|
||||||
x = (_HEIGHT - p0) * _HEIGHT / 10;
|
x = (_HEIGHT - p0) * _HEIGHT / 10;
|
||||||
|
|
||||||
for (i = 0; i < _HEIGHT; i++) {
|
for (i = 0; i < _HEIGHT; i++) {
|
||||||
|
@ -1521,7 +1544,7 @@ cmd(shake_screen) {
|
||||||
|
|
||||||
g_gfx->shakeStart();
|
g_gfx->shakeStart();
|
||||||
|
|
||||||
g_sprites->commitBoth(); /* Fixes SQ1 demo */
|
g_sprites->commitBoth(); // Fixes SQ1 demo
|
||||||
for (i = 4 * p0; i; i--) {
|
for (i = 4 * p0; i; i--) {
|
||||||
g_gfx->shakeScreen(i & 1);
|
g_gfx->shakeScreen(i & 1);
|
||||||
g_gfx->flushBlock(0, 0, GFX_WIDTH - 1, GFX_HEIGHT - 1);
|
g_gfx->flushBlock(0, 0, GFX_WIDTH - 1, GFX_HEIGHT - 1);
|
||||||
|
@ -1534,7 +1557,7 @@ cmd(shake_screen) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void (*agiCommand[183])(uint8 *) = {
|
static void (*agiCommand[183])(uint8 *) = {
|
||||||
NULL, /* 0x00 */
|
NULL, // 0x00
|
||||||
cmd_increment,
|
cmd_increment,
|
||||||
cmd_decrement,
|
cmd_decrement,
|
||||||
cmd_assignn,
|
cmd_assignn,
|
||||||
|
@ -1542,7 +1565,7 @@ static void (*agiCommand[183])(uint8 *) = {
|
||||||
cmd_addn,
|
cmd_addn,
|
||||||
cmd_addv,
|
cmd_addv,
|
||||||
cmd_subn,
|
cmd_subn,
|
||||||
cmd_subv, /* 0x08 */
|
cmd_subv, // 0x08
|
||||||
cmd_lindirectv,
|
cmd_lindirectv,
|
||||||
cmd_rindirect,
|
cmd_rindirect,
|
||||||
cmd_lindirectn,
|
cmd_lindirectn,
|
||||||
|
@ -1550,7 +1573,7 @@ static void (*agiCommand[183])(uint8 *) = {
|
||||||
cmd_reset,
|
cmd_reset,
|
||||||
cmd_toggle,
|
cmd_toggle,
|
||||||
cmd_set_v,
|
cmd_set_v,
|
||||||
cmd_reset_v, /* 0x10 */
|
cmd_reset_v, // 0x10
|
||||||
cmd_toggle_v,
|
cmd_toggle_v,
|
||||||
cmd_new_room,
|
cmd_new_room,
|
||||||
cmd_new_room_f,
|
cmd_new_room_f,
|
||||||
|
@ -1558,7 +1581,7 @@ static void (*agiCommand[183])(uint8 *) = {
|
||||||
cmd_load_logic_f,
|
cmd_load_logic_f,
|
||||||
cmd_call,
|
cmd_call,
|
||||||
cmd_call_f,
|
cmd_call_f,
|
||||||
cmd_load_pic, /* 0x18 */
|
cmd_load_pic, // 0x18
|
||||||
cmd_draw_pic,
|
cmd_draw_pic,
|
||||||
cmd_show_pic,
|
cmd_show_pic,
|
||||||
cmd_discard_pic,
|
cmd_discard_pic,
|
||||||
|
@ -1566,7 +1589,7 @@ static void (*agiCommand[183])(uint8 *) = {
|
||||||
cmd_show_pri_screen,
|
cmd_show_pri_screen,
|
||||||
cmd_load_view,
|
cmd_load_view,
|
||||||
cmd_load_view_f,
|
cmd_load_view_f,
|
||||||
cmd_discard_view, /* 0x20 */
|
cmd_discard_view, // 0x20
|
||||||
cmd_animate_obj,
|
cmd_animate_obj,
|
||||||
cmd_unanimate_all,
|
cmd_unanimate_all,
|
||||||
cmd_draw,
|
cmd_draw,
|
||||||
|
@ -1574,7 +1597,7 @@ static void (*agiCommand[183])(uint8 *) = {
|
||||||
cmd_position,
|
cmd_position,
|
||||||
cmd_position_f,
|
cmd_position_f,
|
||||||
cmd_get_posn,
|
cmd_get_posn,
|
||||||
cmd_reposition, /* 0x28 */
|
cmd_reposition, // 0x28
|
||||||
cmd_set_view,
|
cmd_set_view,
|
||||||
cmd_set_view_f,
|
cmd_set_view_f,
|
||||||
cmd_set_loop,
|
cmd_set_loop,
|
||||||
|
@ -1582,7 +1605,7 @@ static void (*agiCommand[183])(uint8 *) = {
|
||||||
cmd_fix_loop,
|
cmd_fix_loop,
|
||||||
cmd_release_loop,
|
cmd_release_loop,
|
||||||
cmd_set_cel,
|
cmd_set_cel,
|
||||||
cmd_set_cel_f, /* 0x30 */
|
cmd_set_cel_f, // 0x30
|
||||||
cmd_last_cel,
|
cmd_last_cel,
|
||||||
cmd_current_cel,
|
cmd_current_cel,
|
||||||
cmd_current_loop,
|
cmd_current_loop,
|
||||||
|
@ -1590,7 +1613,7 @@ static void (*agiCommand[183])(uint8 *) = {
|
||||||
cmd_number_of_loops,
|
cmd_number_of_loops,
|
||||||
cmd_set_priority,
|
cmd_set_priority,
|
||||||
cmd_set_priority_f,
|
cmd_set_priority_f,
|
||||||
cmd_release_priority, /* 0x38 */
|
cmd_release_priority, // 0x38
|
||||||
cmd_get_priority,
|
cmd_get_priority,
|
||||||
cmd_stop_update,
|
cmd_stop_update,
|
||||||
cmd_start_update,
|
cmd_start_update,
|
||||||
|
@ -1598,7 +1621,7 @@ static void (*agiCommand[183])(uint8 *) = {
|
||||||
cmd_ignore_horizon,
|
cmd_ignore_horizon,
|
||||||
cmd_observe_horizon,
|
cmd_observe_horizon,
|
||||||
cmd_set_horizon,
|
cmd_set_horizon,
|
||||||
cmd_object_on_water, /* 0x40 */
|
cmd_object_on_water, // 0x40
|
||||||
cmd_object_on_land,
|
cmd_object_on_land,
|
||||||
cmd_object_on_anything,
|
cmd_object_on_anything,
|
||||||
cmd_ignore_objs,
|
cmd_ignore_objs,
|
||||||
|
@ -1606,7 +1629,7 @@ static void (*agiCommand[183])(uint8 *) = {
|
||||||
cmd_distance,
|
cmd_distance,
|
||||||
cmd_stop_cycling,
|
cmd_stop_cycling,
|
||||||
cmd_start_cycling,
|
cmd_start_cycling,
|
||||||
cmd_normal_cycle, /* 0x48 */
|
cmd_normal_cycle, // 0x48
|
||||||
cmd_end_of_loop,
|
cmd_end_of_loop,
|
||||||
cmd_reverse_cycle,
|
cmd_reverse_cycle,
|
||||||
cmd_reverse_loop,
|
cmd_reverse_loop,
|
||||||
|
@ -1614,7 +1637,7 @@ static void (*agiCommand[183])(uint8 *) = {
|
||||||
cmd_stop_motion,
|
cmd_stop_motion,
|
||||||
cmd_start_motion,
|
cmd_start_motion,
|
||||||
cmd_step_size,
|
cmd_step_size,
|
||||||
cmd_step_time, /* 0x50 */
|
cmd_step_time, // 0x50
|
||||||
cmd_move_obj,
|
cmd_move_obj,
|
||||||
cmd_move_obj_f,
|
cmd_move_obj_f,
|
||||||
cmd_follow_ego,
|
cmd_follow_ego,
|
||||||
|
@ -1622,7 +1645,7 @@ static void (*agiCommand[183])(uint8 *) = {
|
||||||
cmd_normal_motion,
|
cmd_normal_motion,
|
||||||
cmd_set_dir,
|
cmd_set_dir,
|
||||||
cmd_get_dir,
|
cmd_get_dir,
|
||||||
cmd_ignore_blocks, /* 0x58 */
|
cmd_ignore_blocks, // 0x58
|
||||||
cmd_observe_blocks,
|
cmd_observe_blocks,
|
||||||
cmd_block,
|
cmd_block,
|
||||||
cmd_unblock,
|
cmd_unblock,
|
||||||
|
@ -1630,7 +1653,7 @@ static void (*agiCommand[183])(uint8 *) = {
|
||||||
cmd_get_f,
|
cmd_get_f,
|
||||||
cmd_drop,
|
cmd_drop,
|
||||||
cmd_put,
|
cmd_put,
|
||||||
cmd_put_f, /* 0x60 */
|
cmd_put_f, // 0x60
|
||||||
cmd_get_room_f,
|
cmd_get_room_f,
|
||||||
cmd_load_sound,
|
cmd_load_sound,
|
||||||
cmd_sound,
|
cmd_sound,
|
||||||
|
@ -1638,7 +1661,7 @@ static void (*agiCommand[183])(uint8 *) = {
|
||||||
cmd_print,
|
cmd_print,
|
||||||
cmd_print_f,
|
cmd_print_f,
|
||||||
cmd_display,
|
cmd_display,
|
||||||
cmd_display_f, /* 0x68 */
|
cmd_display_f, // 0x68
|
||||||
cmd_clear_lines,
|
cmd_clear_lines,
|
||||||
cmd_text_screen,
|
cmd_text_screen,
|
||||||
cmd_graphics,
|
cmd_graphics,
|
||||||
|
@ -1646,7 +1669,7 @@ static void (*agiCommand[183])(uint8 *) = {
|
||||||
cmd_set_text_attribute,
|
cmd_set_text_attribute,
|
||||||
cmd_shake_screen,
|
cmd_shake_screen,
|
||||||
cmd_configure_screen,
|
cmd_configure_screen,
|
||||||
cmd_status_line_on, /* 0x70 */
|
cmd_status_line_on, // 0x70
|
||||||
cmd_status_line_off,
|
cmd_status_line_off,
|
||||||
cmd_set_string,
|
cmd_set_string,
|
||||||
cmd_get_string,
|
cmd_get_string,
|
||||||
|
@ -1654,7 +1677,7 @@ static void (*agiCommand[183])(uint8 *) = {
|
||||||
cmd_parse,
|
cmd_parse,
|
||||||
cmd_get_num,
|
cmd_get_num,
|
||||||
cmd_prevent_input,
|
cmd_prevent_input,
|
||||||
cmd_accept_input, /* 0x78 */
|
cmd_accept_input, // 0x78
|
||||||
cmd_set_key,
|
cmd_set_key,
|
||||||
cmd_add_to_pic,
|
cmd_add_to_pic,
|
||||||
cmd_add_to_pic_f,
|
cmd_add_to_pic_f,
|
||||||
|
@ -1662,7 +1685,7 @@ static void (*agiCommand[183])(uint8 *) = {
|
||||||
cmd_save_game,
|
cmd_save_game,
|
||||||
cmd_load_game,
|
cmd_load_game,
|
||||||
cmd_init_disk,
|
cmd_init_disk,
|
||||||
cmd_restart_game, /* 0x80 */
|
cmd_restart_game, // 0x80
|
||||||
cmd_show_obj,
|
cmd_show_obj,
|
||||||
cmd_random,
|
cmd_random,
|
||||||
cmd_program_control,
|
cmd_program_control,
|
||||||
|
@ -1670,7 +1693,7 @@ static void (*agiCommand[183])(uint8 *) = {
|
||||||
cmd_obj_status_f,
|
cmd_obj_status_f,
|
||||||
cmd_quit,
|
cmd_quit,
|
||||||
cmd_show_mem,
|
cmd_show_mem,
|
||||||
cmd_pause, /* 0x88 */
|
cmd_pause, // 0x88
|
||||||
cmd_echo_line,
|
cmd_echo_line,
|
||||||
cmd_cancel_line,
|
cmd_cancel_line,
|
||||||
cmd_init_joy,
|
cmd_init_joy,
|
||||||
|
@ -1678,7 +1701,7 @@ static void (*agiCommand[183])(uint8 *) = {
|
||||||
cmd_version,
|
cmd_version,
|
||||||
cmd_script_size,
|
cmd_script_size,
|
||||||
cmd_set_game_id,
|
cmd_set_game_id,
|
||||||
cmd_log, /* 0x90 */
|
cmd_log, // 0x90
|
||||||
cmd_set_scan_start,
|
cmd_set_scan_start,
|
||||||
cmd_reset_scan_start,
|
cmd_reset_scan_start,
|
||||||
cmd_reposition_to,
|
cmd_reposition_to,
|
||||||
|
@ -1686,7 +1709,7 @@ static void (*agiCommand[183])(uint8 *) = {
|
||||||
cmd_trace_on,
|
cmd_trace_on,
|
||||||
cmd_trace_info,
|
cmd_trace_info,
|
||||||
cmd_print_at,
|
cmd_print_at,
|
||||||
cmd_print_at_v, /* 0x98 */
|
cmd_print_at_v, // 0x98
|
||||||
cmd_discard_view,
|
cmd_discard_view,
|
||||||
cmd_clear_text_rect,
|
cmd_clear_text_rect,
|
||||||
cmd_set_upper_left,
|
cmd_set_upper_left,
|
||||||
|
@ -1694,7 +1717,7 @@ static void (*agiCommand[183])(uint8 *) = {
|
||||||
cmd_set_menu_item,
|
cmd_set_menu_item,
|
||||||
cmd_submit_menu,
|
cmd_submit_menu,
|
||||||
cmd_enable_item,
|
cmd_enable_item,
|
||||||
cmd_disable_item, /* 0xa0 */
|
cmd_disable_item, // 0xa0
|
||||||
cmd_menu_input,
|
cmd_menu_input,
|
||||||
cmd_show_obj_v,
|
cmd_show_obj_v,
|
||||||
cmd_open_dialogue,
|
cmd_open_dialogue,
|
||||||
|
@ -1702,7 +1725,7 @@ static void (*agiCommand[183])(uint8 *) = {
|
||||||
cmd_mul_n,
|
cmd_mul_n,
|
||||||
cmd_mul_v,
|
cmd_mul_v,
|
||||||
cmd_div_n,
|
cmd_div_n,
|
||||||
cmd_div_v, /* 0xa8 */
|
cmd_div_v, // 0xa8
|
||||||
cmd_close_window,
|
cmd_close_window,
|
||||||
cmd_set_simple,
|
cmd_set_simple,
|
||||||
cmd_push_script,
|
cmd_push_script,
|
||||||
|
@ -1710,7 +1733,7 @@ static void (*agiCommand[183])(uint8 *) = {
|
||||||
cmd_hold_key,
|
cmd_hold_key,
|
||||||
cmd_set_pri_base,
|
cmd_set_pri_base,
|
||||||
cmd_discard_sound,
|
cmd_discard_sound,
|
||||||
cmd_hide_mouse, /* 0xb0 */
|
cmd_hide_mouse, // 0xb0
|
||||||
cmd_allow_menu,
|
cmd_allow_menu,
|
||||||
cmd_show_mouse,
|
cmd_show_mouse,
|
||||||
cmd_fence_mouse,
|
cmd_fence_mouse,
|
||||||
|
@ -1732,7 +1755,7 @@ int AgiEngine::runLogic(int n) {
|
||||||
g_agi = this;
|
g_agi = this;
|
||||||
int num = 0;
|
int num = 0;
|
||||||
|
|
||||||
/* If logic not loaded, load it */
|
// If logic not loaded, load it
|
||||||
if (~_game.dirLogic[n].flags & RES_LOADED) {
|
if (~_game.dirLogic[n].flags & RES_LOADED) {
|
||||||
debugC(4, kDebugLevelScripts, "logic %d not loaded!", n);
|
debugC(4, kDebugLevelScripts, "logic %d not loaded!", n);
|
||||||
agiLoadResource(rLOGIC, n);
|
agiLoadResource(rLOGIC, n);
|
||||||
|
@ -1762,22 +1785,22 @@ int AgiEngine::runLogic(int n) {
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (op = *(code + ip++)) {
|
switch (op = *(code + ip++)) {
|
||||||
case 0xff: /* if (open/close) */
|
case 0xff: // if (open/close)
|
||||||
testIfCode(n);
|
testIfCode(n);
|
||||||
break;
|
break;
|
||||||
case 0xfe: /* goto */
|
case 0xfe: // goto
|
||||||
/* +2 covers goto size */
|
// +2 covers goto size
|
||||||
ip += 2 + ((int16)READ_LE_UINT16(code + ip));
|
ip += 2 + ((int16)READ_LE_UINT16(code + ip));
|
||||||
/* timer must keep running even in goto loops,
|
|
||||||
* but AGI engine can't do that :(
|
// timer must keep running even in goto loops,
|
||||||
*/
|
// but AGI engine can't do that :(
|
||||||
if (timerHack > 20) {
|
if (timerHack > 20) {
|
||||||
g_gfx->pollTimer();
|
g_gfx->pollTimer();
|
||||||
updateTimer();
|
updateTimer();
|
||||||
timerHack = 0;
|
timerHack = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 0x00: /* return */
|
case 0x00: // return
|
||||||
return 1;
|
return 1;
|
||||||
default:
|
default:
|
||||||
num = logicNamesCmd[op].numArgs;
|
num = logicNamesCmd[op].numArgs;
|
||||||
|
@ -1793,7 +1816,7 @@ int AgiEngine::runLogic(int n) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0; /* after executing new.room() */
|
return 0; // after executing new.room()
|
||||||
}
|
}
|
||||||
|
|
||||||
void AgiEngine::executeAgiCommand(uint8 op, uint8 *p) {
|
void AgiEngine::executeAgiCommand(uint8 op, uint8 *p) {
|
||||||
|
|
|
@ -23,8 +23,6 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "agi/agi.h"
|
#include "agi/agi.h"
|
||||||
#include "agi/opcodes.h"
|
#include "agi/opcodes.h"
|
||||||
|
|
||||||
|
@ -58,7 +56,7 @@ struct AgiLogicnames logicNamesTest[] = {
|
||||||
_L("controller", 1, 0x00),
|
_L("controller", 1, 0x00),
|
||||||
_L("have.key", 0, 0x00),
|
_L("have.key", 0, 0x00),
|
||||||
|
|
||||||
/* Not 0 args. Has variable number. */
|
// Not 0 args. Has variable number.
|
||||||
_L("said", 0, 0x00),
|
_L("said", 0, 0x00),
|
||||||
|
|
||||||
_L("compare.strings", 2, 0x00),
|
_L("compare.strings", 2, 0x00),
|
||||||
|
@ -66,7 +64,7 @@ struct AgiLogicnames logicNamesTest[] = {
|
||||||
_L("center.posn", 5, 0x00),
|
_L("center.posn", 5, 0x00),
|
||||||
_L("right.posn", 5, 0x00),
|
_L("right.posn", 5, 0x00),
|
||||||
|
|
||||||
/* Haven't seen an official name for this command so tried to name it descriptively. */
|
// Haven't seen an official name for this command so tried to name it descriptively.
|
||||||
_L("in.motion.using.mouse", 0, 0x00)
|
_L("in.motion.using.mouse", 0, 0x00)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -78,200 +76,200 @@ struct AgiLogicnames logicNamesIf[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct AgiLogicnames logicNamesCmd[] = {
|
struct AgiLogicnames logicNamesCmd[] = {
|
||||||
_L("return", 0, 0x00), /* 00 */
|
_L("return", 0, 0x00), // 00
|
||||||
_L("increment", 1, 0x80), /* 01 */
|
_L("increment", 1, 0x80), // 01
|
||||||
_L("decrement", 1, 0x80), /* 02 */
|
_L("decrement", 1, 0x80), // 02
|
||||||
_L("assignn", 2, 0x80), /* 03 */
|
_L("assignn", 2, 0x80), // 03
|
||||||
_L("assignv", 2, 0xC0), /* 04 */
|
_L("assignv", 2, 0xC0), // 04
|
||||||
_L("addn", 2, 0x80), /* 05 */
|
_L("addn", 2, 0x80), // 05
|
||||||
_L("addv", 2, 0xC0), /* 06 */
|
_L("addv", 2, 0xC0), // 06
|
||||||
_L("subn", 2, 0x80), /* 07 */
|
_L("subn", 2, 0x80), // 07
|
||||||
_L("subv", 2, 0xC0), /* 08 */
|
_L("subv", 2, 0xC0), // 08
|
||||||
_L("lindirectv", 2, 0xC0), /* 09 */
|
_L("lindirectv", 2, 0xC0), // 09
|
||||||
_L("rindirect", 2, 0xC0), /* 0A */
|
_L("rindirect", 2, 0xC0), // 0A
|
||||||
_L("lindirectn", 2, 0x80), /* 0B */
|
_L("lindirectn", 2, 0x80), // 0B
|
||||||
_L("set", 1, 0x00), /* 0C */
|
_L("set", 1, 0x00), // 0C
|
||||||
_L("reset", 1, 0x00), /* 0D */
|
_L("reset", 1, 0x00), // 0D
|
||||||
_L("toggle", 1, 0x00), /* 0E */
|
_L("toggle", 1, 0x00), // 0E
|
||||||
_L("set.v", 1, 0x80), /* 0F */
|
_L("set.v", 1, 0x80), // 0F
|
||||||
_L("reset.v", 1, 0x80), /* 10 */
|
_L("reset.v", 1, 0x80), // 10
|
||||||
_L("toggle.v", 1, 0x80), /* 11 */
|
_L("toggle.v", 1, 0x80), // 11
|
||||||
_L("new.room", 1, 0x00), /* 12 */
|
_L("new.room", 1, 0x00), // 12
|
||||||
_L("new.room.v", 1, 0x80), /* 13 */
|
_L("new.room.v", 1, 0x80), // 13
|
||||||
_L("load.logics", 1, 0x00), /* 14 */
|
_L("load.logics", 1, 0x00), // 14
|
||||||
_L("load.logics.v", 1, 0x80), /* 15 */
|
_L("load.logics.v", 1, 0x80), // 15
|
||||||
_L("call", 1, 0x00), /* 16 */
|
_L("call", 1, 0x00), // 16
|
||||||
_L("call.v", 1, 0x80), /* 17 */
|
_L("call.v", 1, 0x80), // 17
|
||||||
_L("load.pic", 1, 0x80), /* 18 */
|
_L("load.pic", 1, 0x80), // 18
|
||||||
_L("draw.pic", 1, 0x80), /* 19 */
|
_L("draw.pic", 1, 0x80), // 19
|
||||||
_L("show.pic", 0, 0x00), /* 1A */
|
_L("show.pic", 0, 0x00), // 1A
|
||||||
_L("discard.pic", 1, 0x80), /* 1B */
|
_L("discard.pic", 1, 0x80), // 1B
|
||||||
_L("overlay.pic", 1, 0x80), /* 1C */
|
_L("overlay.pic", 1, 0x80), // 1C
|
||||||
_L("show.pri.screen", 0, 0x00), /* 1D */
|
_L("show.pri.screen", 0, 0x00), // 1D
|
||||||
_L("load.view", 1, 0x00), /* 1E */
|
_L("load.view", 1, 0x00), // 1E
|
||||||
_L("load.view.v", 1, 0x80), /* 1F */
|
_L("load.view.v", 1, 0x80), // 1F
|
||||||
_L("discard.view", 1, 0x00), /* 20 */
|
_L("discard.view", 1, 0x00), // 20
|
||||||
_L("animate.obj", 1, 0x00), /* 21 */
|
_L("animate.obj", 1, 0x00), // 21
|
||||||
_L("unanimate.all", 0, 0x00), /* 22 */
|
_L("unanimate.all", 0, 0x00), // 22
|
||||||
_L("draw", 1, 0x00), /* 23 */
|
_L("draw", 1, 0x00), // 23
|
||||||
_L("erase", 1, 0x00), /* 24 */
|
_L("erase", 1, 0x00), // 24
|
||||||
_L("position", 3, 0x00), /* 25 */
|
_L("position", 3, 0x00), // 25
|
||||||
_L("position.v", 3, 0x60), /* 26 */
|
_L("position.v", 3, 0x60), // 26
|
||||||
_L("get.posn", 3, 0x60), /* 27 */
|
_L("get.posn", 3, 0x60), // 27
|
||||||
_L("reposition", 3, 0x60), /* 28 */
|
_L("reposition", 3, 0x60), // 28
|
||||||
_L("set.view", 2, 0x00), /* 29 */
|
_L("set.view", 2, 0x00), // 29
|
||||||
_L("set.view.v", 2, 0x40), /* 2A */
|
_L("set.view.v", 2, 0x40), // 2A
|
||||||
_L("set.loop", 2, 0x00), /* 2B */
|
_L("set.loop", 2, 0x00), // 2B
|
||||||
_L("set.loop.v", 2, 0x40), /* 2C */
|
_L("set.loop.v", 2, 0x40), // 2C
|
||||||
_L("fix.loop", 1, 0x00), /* 2D */
|
_L("fix.loop", 1, 0x00), // 2D
|
||||||
_L("release.loop", 1, 0x00), /* 2E */
|
_L("release.loop", 1, 0x00), // 2E
|
||||||
_L("set.cel", 2, 0x00), /* 2F */
|
_L("set.cel", 2, 0x00), // 2F
|
||||||
_L("set.cel.v", 2, 0x40), /* 30 */
|
_L("set.cel.v", 2, 0x40), // 30
|
||||||
_L("last.cel", 2, 0x40), /* 31 */
|
_L("last.cel", 2, 0x40), // 31
|
||||||
_L("current.cel", 2, 0x40), /* 32 */
|
_L("current.cel", 2, 0x40), // 32
|
||||||
_L("current.loop", 2, 0x40), /* 33 */
|
_L("current.loop", 2, 0x40), // 33
|
||||||
_L("current.view", 2, 0x40), /* 34 */
|
_L("current.view", 2, 0x40), // 34
|
||||||
_L("number.of.loops", 2, 0x40), /* 35 */
|
_L("number.of.loops", 2, 0x40), // 35
|
||||||
_L("set.priority", 2, 0x00), /* 36 */
|
_L("set.priority", 2, 0x00), // 36
|
||||||
_L("set.priority.v", 2, 0x40), /* 37 */
|
_L("set.priority.v", 2, 0x40), // 37
|
||||||
_L("release.priority", 1, 0x00), /* 38 */
|
_L("release.priority", 1, 0x00), // 38
|
||||||
_L("get.priority", 2, 0x40), /* 39 */
|
_L("get.priority", 2, 0x40), // 39
|
||||||
_L("stop.update", 1, 0x00), /* 3A */
|
_L("stop.update", 1, 0x00), // 3A
|
||||||
_L("start.update", 1, 0x00), /* 3B */
|
_L("start.update", 1, 0x00), // 3B
|
||||||
_L("force.update", 1, 0x00), /* 3C */
|
_L("force.update", 1, 0x00), // 3C
|
||||||
_L("ignore.horizon", 1, 0x00), /* 3D */
|
_L("ignore.horizon", 1, 0x00), // 3D
|
||||||
_L("observe.horizon", 1, 0x00), /* 3E */
|
_L("observe.horizon", 1, 0x00), // 3E
|
||||||
_L("set.horizon", 1, 0x00), /* 3F */
|
_L("set.horizon", 1, 0x00), // 3F
|
||||||
_L("object.on.water", 1, 0x00), /* 40 */
|
_L("object.on.water", 1, 0x00), // 40
|
||||||
_L("object.on.land", 1, 0x00), /* 41 */
|
_L("object.on.land", 1, 0x00), // 41
|
||||||
_L("object.on.anything", 1, 0x00), /* 42 */
|
_L("object.on.anything", 1, 0x00), // 42
|
||||||
_L("ignore.objs", 1, 0x00), /* 43 */
|
_L("ignore.objs", 1, 0x00), // 43
|
||||||
_L("observe.objs", 1, 0x00), /* 44 */
|
_L("observe.objs", 1, 0x00), // 44
|
||||||
_L("distance", 3, 0x20), /* 45 */
|
_L("distance", 3, 0x20), // 45
|
||||||
_L("stop.cycling", 1, 0x00), /* 46 */
|
_L("stop.cycling", 1, 0x00), // 46
|
||||||
_L("start.cycling", 1, 0x00), /* 47 */
|
_L("start.cycling", 1, 0x00), // 47
|
||||||
_L("normal.cycle", 1, 0x00), /* 48 */
|
_L("normal.cycle", 1, 0x00), // 48
|
||||||
_L("end.of.loop", 2, 0x00), /* 49 */
|
_L("end.of.loop", 2, 0x00), // 49
|
||||||
_L("reverse.cycle", 1, 0x00), /* 4A */
|
_L("reverse.cycle", 1, 0x00), // 4A
|
||||||
_L("reverse.loop", 2, 0x00), /* 4B */
|
_L("reverse.loop", 2, 0x00), // 4B
|
||||||
_L("cycle.time", 2, 0x40), /* 4C */
|
_L("cycle.time", 2, 0x40), // 4C
|
||||||
_L("stop.motion", 1, 0x00), /* 4D */
|
_L("stop.motion", 1, 0x00), // 4D
|
||||||
_L("start.motion", 1, 0x00), /* 4E */
|
_L("start.motion", 1, 0x00), // 4E
|
||||||
_L("step.size", 2, 0x40), /* 4F */
|
_L("step.size", 2, 0x40), // 4F
|
||||||
_L("step.time", 2, 0x40), /* 50 */
|
_L("step.time", 2, 0x40), // 50
|
||||||
_L("move.obj", 5, 0x00), /* 51 */
|
_L("move.obj", 5, 0x00), // 51
|
||||||
_L("move.obj.v", 5, 0x70), /* 52 */
|
_L("move.obj.v", 5, 0x70), // 52
|
||||||
_L("follow.ego", 3, 0x00), /* 53 */
|
_L("follow.ego", 3, 0x00), // 53
|
||||||
_L("wander", 1, 0x00), /* 54 */
|
_L("wander", 1, 0x00), // 54
|
||||||
_L("normal.motion", 1, 0x00), /* 55 */
|
_L("normal.motion", 1, 0x00), // 55
|
||||||
_L("set.dir", 2, 0x40), /* 56 */
|
_L("set.dir", 2, 0x40), // 56
|
||||||
_L("get.dir", 2, 0x40), /* 57 */
|
_L("get.dir", 2, 0x40), // 57
|
||||||
_L("ignore.blocks", 1, 0x00), /* 58 */
|
_L("ignore.blocks", 1, 0x00), // 58
|
||||||
_L("observe.blocks", 1, 0x00), /* 59 */
|
_L("observe.blocks", 1, 0x00), // 59
|
||||||
_L("block", 4, 0x00), /* 5A */
|
_L("block", 4, 0x00), // 5A
|
||||||
_L("unblock", 0, 0x00), /* 5B */
|
_L("unblock", 0, 0x00), // 5B
|
||||||
_L("get", 1, 0x00), /* 5C */
|
_L("get", 1, 0x00), // 5C
|
||||||
_L("get.v", 1, 0x80), /* 5D */
|
_L("get.v", 1, 0x80), // 5D
|
||||||
_L("drop", 1, 0x00), /* 5E */
|
_L("drop", 1, 0x00), // 5E
|
||||||
_L("put", 2, 0x00), /* 5F */
|
_L("put", 2, 0x00), // 5F
|
||||||
_L("put.v", 2, 0x40), /* 60 */
|
_L("put.v", 2, 0x40), // 60
|
||||||
_L("get.room.v", 2, 0xC0), /* 61 */
|
_L("get.room.v", 2, 0xC0), // 61
|
||||||
_L("load.sound", 1, 0x00), /* 62 */
|
_L("load.sound", 1, 0x00), // 62
|
||||||
_L("sound", 2, 0x00), /* 63 */
|
_L("sound", 2, 0x00), // 63
|
||||||
_L("stop.sound", 0, 0x00), /* 64 */
|
_L("stop.sound", 0, 0x00), // 64
|
||||||
_L("print", 1, 0x00), /* 65 */
|
_L("print", 1, 0x00), // 65
|
||||||
_L("print.v", 1, 0x80), /* 66 */
|
_L("print.v", 1, 0x80), // 66
|
||||||
_L("display", 3, 0x00), /* 67 */
|
_L("display", 3, 0x00), // 67
|
||||||
_L("display.v", 3, 0xE0), /* 68 */
|
_L("display.v", 3, 0xE0), // 68
|
||||||
_L("clear.lines", 3, 0x00), /* 69 */
|
_L("clear.lines", 3, 0x00), // 69
|
||||||
_L("text.screen", 0, 0x00), /* 6A */
|
_L("text.screen", 0, 0x00), // 6A
|
||||||
_L("graphics", 0, 0x00), /* 6B */
|
_L("graphics", 0, 0x00), // 6B
|
||||||
_L("set.cursor.char", 1, 0x00), /* 6C */
|
_L("set.cursor.char", 1, 0x00), // 6C
|
||||||
_L("set.text.attribute", 2, 0x00), /* 6D */
|
_L("set.text.attribute", 2, 0x00), // 6D
|
||||||
_L("shake.screen", 1, 0x00), /* 6E */
|
_L("shake.screen", 1, 0x00), // 6E
|
||||||
_L("configure.screen", 3, 0x00), /* 6F */
|
_L("configure.screen", 3, 0x00), // 6F
|
||||||
_L("status.line.on", 0, 0x00), /* 70 */
|
_L("status.line.on", 0, 0x00), // 70
|
||||||
_L("status.line.off", 0, 0x00), /* 71 */
|
_L("status.line.off", 0, 0x00), // 71
|
||||||
_L("set.string", 2, 0x00), /* 72 */
|
_L("set.string", 2, 0x00), // 72
|
||||||
_L("get.string", 5, 0x00), /* 73 */
|
_L("get.string", 5, 0x00), // 73
|
||||||
_L("word.to.string", 2, 0x00), /* 74 */
|
_L("word.to.string", 2, 0x00), // 74
|
||||||
_L("parse", 1, 0x00), /* 75 */
|
_L("parse", 1, 0x00), // 75
|
||||||
_L("get.num", 2, 0x40), /* 76 */
|
_L("get.num", 2, 0x40), // 76
|
||||||
_L("prevent.input", 0, 0x00), /* 77 */
|
_L("prevent.input", 0, 0x00), // 77
|
||||||
_L("accept.input", 0, 0x00), /* 78 */
|
_L("accept.input", 0, 0x00), // 78
|
||||||
_L("set.key", 3, 0x00), /* 79 */
|
_L("set.key", 3, 0x00), // 79
|
||||||
_L("add.to.pic", 7, 0x00), /* 7A */
|
_L("add.to.pic", 7, 0x00), // 7A
|
||||||
_L("add.to.pic.v", 7, 0xFE), /* 7B */
|
_L("add.to.pic.v", 7, 0xFE), // 7B
|
||||||
_L("status", 0, 0x00), /* 7C */
|
_L("status", 0, 0x00), // 7C
|
||||||
_L("save.game", 0, 0x00), /* 7D */
|
_L("save.game", 0, 0x00), // 7D
|
||||||
_L("restore.game", 0, 0x00), /* 7E */
|
_L("restore.game", 0, 0x00), // 7E
|
||||||
_L("init.disk", 0, 0x00), /* 7F */
|
_L("init.disk", 0, 0x00), // 7F
|
||||||
_L("restart.game", 0, 0x00), /* 80 */
|
_L("restart.game", 0, 0x00), // 80
|
||||||
_L("show.obj", 1, 0x00), /* 81 */
|
_L("show.obj", 1, 0x00), // 81
|
||||||
_L("random", 3, 0x20), /* 82 */
|
_L("random", 3, 0x20), // 82
|
||||||
_L("program.control", 0, 0x00), /* 83 */
|
_L("program.control", 0, 0x00), // 83
|
||||||
_L("player.control", 0, 0x00), /* 84 */
|
_L("player.control", 0, 0x00), // 84
|
||||||
_L("obj.status.v", 1, 0x80), /* 85 */
|
_L("obj.status.v", 1, 0x80), // 85
|
||||||
/* 0 args for AGI version 2.089 */
|
// 0 args for AGI version 2.089
|
||||||
_L("quit", 1, 0x00), /* 86 */
|
_L("quit", 1, 0x00), // 86
|
||||||
|
|
||||||
_L("show.mem", 0, 0x00), /* 87 */
|
_L("show.mem", 0, 0x00), // 87
|
||||||
_L("pause", 0, 0x00), /* 88 */
|
_L("pause", 0, 0x00), // 88
|
||||||
_L("echo.line", 0, 0x00), /* 89 */
|
_L("echo.line", 0, 0x00), // 89
|
||||||
_L("cancel.line", 0, 0x00), /* 8A */
|
_L("cancel.line", 0, 0x00), // 8A
|
||||||
_L("init.joy", 0, 0x00), /* 8B */
|
_L("init.joy", 0, 0x00), // 8B
|
||||||
_L("toggle.monitor", 0, 0x00), /* 8C */
|
_L("toggle.monitor", 0, 0x00), // 8C
|
||||||
_L("version", 0, 0x00), /* 8D */
|
_L("version", 0, 0x00), // 8D
|
||||||
_L("script.size", 1, 0x00), /* 8E */
|
_L("script.size", 1, 0x00), // 8E
|
||||||
_L("set.game.id", 1, 0x00), /* 8F */
|
_L("set.game.id", 1, 0x00), // 8F
|
||||||
_L("log", 1, 0x00), /* 90 */
|
_L("log", 1, 0x00), // 90
|
||||||
_L("set.scan.start", 0, 0x00), /* 91 */
|
_L("set.scan.start", 0, 0x00), // 91
|
||||||
_L("reset.scan.start", 0, 0x00), /* 92 */
|
_L("reset.scan.start", 0, 0x00), // 92
|
||||||
_L("reposition.to", 3, 0x00), /* 93 */
|
_L("reposition.to", 3, 0x00), // 93
|
||||||
_L("reposition.to.v", 3, 0x60), /* 94 */
|
_L("reposition.to.v", 3, 0x60), // 94
|
||||||
_L("trace.on", 0, 0x00), /* 95 */
|
_L("trace.on", 0, 0x00), // 95
|
||||||
_L("trace.info", 3, 0x00), /* 96 */
|
_L("trace.info", 3, 0x00), // 96
|
||||||
|
|
||||||
/* 3 args for AGI versions before 2.440 */
|
// 3 args for AGI versions before 2.440
|
||||||
_L("print.at", 4, 0x00), /* 97 */
|
_L("print.at", 4, 0x00), // 97
|
||||||
_L("print.at.v", 4, 0x80), /* 98 */
|
_L("print.at.v", 4, 0x80), // 98
|
||||||
|
|
||||||
_L("discard.view.v", 1, 0x80), /* 99 */
|
_L("discard.view.v", 1, 0x80), // 99
|
||||||
_L("clear.text.rect", 5, 0x00), /* 9A */
|
_L("clear.text.rect", 5, 0x00), // 9A
|
||||||
_L("set.upper.left", 2, 0x00), /* 9B */
|
_L("set.upper.left", 2, 0x00), // 9B
|
||||||
_L("set.menu", 1, 0x00), /* 9C */
|
_L("set.menu", 1, 0x00), // 9C
|
||||||
_L("set.menu.item", 2, 0x00), /* 9D */
|
_L("set.menu.item", 2, 0x00), // 9D
|
||||||
_L("submit.menu", 0, 0x00), /* 9E */
|
_L("submit.menu", 0, 0x00), // 9E
|
||||||
_L("enable.item", 1, 0x00), /* 9F */
|
_L("enable.item", 1, 0x00), // 9F
|
||||||
_L("disable.item", 1, 0x00), /* A0 */
|
_L("disable.item", 1, 0x00), // A0
|
||||||
_L("menu.input", 0, 0x00), /* A1 */
|
_L("menu.input", 0, 0x00), // A1
|
||||||
_L("show.obj.v", 1, 0x01), /* A2 */
|
_L("show.obj.v", 1, 0x01), // A2
|
||||||
_L("open.dialogue", 0, 0x00), /* A3 */
|
_L("open.dialogue", 0, 0x00), // A3
|
||||||
_L("close.dialogue", 0, 0x00), /* A4 */
|
_L("close.dialogue", 0, 0x00), // A4
|
||||||
_L("mul.n", 2, 0x80), /* A5 */
|
_L("mul.n", 2, 0x80), // A5
|
||||||
_L("mul.v", 2, 0xC0), /* A6 */
|
_L("mul.v", 2, 0xC0), // A6
|
||||||
_L("div.n", 2, 0x80), /* A7 */
|
_L("div.n", 2, 0x80), // A7
|
||||||
_L("div.v", 2, 0xC0), /* A8 */
|
_L("div.v", 2, 0xC0), // A8
|
||||||
_L("close.window", 0, 0x00), /* A9 */
|
_L("close.window", 0, 0x00), // A9
|
||||||
|
|
||||||
_L("set.simple", 1, 0x00), /* AA */
|
_L("set.simple", 1, 0x00), // AA
|
||||||
_L("push.script", 0, 0x00), /* AB */
|
_L("push.script", 0, 0x00), // AB
|
||||||
_L("pop.script", 0, 0x00), /* AC */
|
_L("pop.script", 0, 0x00), // AC
|
||||||
_L("hold.key", 0, 0x00), /* AD */
|
_L("hold.key", 0, 0x00), // AD
|
||||||
_L("set.pri.base", 1, 0x00), /* AE */
|
_L("set.pri.base", 1, 0x00), // AE
|
||||||
_L("discard.sound", 1, 0x00), /* AF */
|
_L("discard.sound", 1, 0x00), // AF
|
||||||
|
|
||||||
/* 1 arg for AGI version 3.002.086 */
|
// 1 arg for AGI version 3.002.086
|
||||||
_L("hide.mouse", 0, 0x00), /* B0 */
|
_L("hide.mouse", 0, 0x00), // B0
|
||||||
|
|
||||||
_L("allow.menu", 1, 0x00), /* B1 */
|
_L("allow.menu", 1, 0x00), // B1
|
||||||
_L("show.mouse", 0, 0x00), /* B2 */
|
_L("show.mouse", 0, 0x00), // B2
|
||||||
_L("fence.mouse", 4, 0x00), /* B3 */
|
_L("fence.mouse", 4, 0x00), // B3
|
||||||
_L("mouse.posn", 2, 0x00), /* B4 */
|
_L("mouse.posn", 2, 0x00), // B4
|
||||||
_L("release.key", 0, 0x00), /* B5 */
|
_L("release.key", 0, 0x00), // B5
|
||||||
|
|
||||||
/* 2 args for at least the Amiga Gold Rush! (v2.05 1989-03-09) using Amiga AGI 2.316. */
|
// 2 args for at least the Amiga Gold Rush! (v2.05 1989-03-09) using Amiga AGI 2.316.
|
||||||
_L("adj.ego.move.to.xy", 0, 0x00), /* B6 */
|
_L("adj.ego.move.to.xy", 0, 0x00), // B6
|
||||||
_L(NULL, 0, 0x00)
|
_L(NULL, 0, 0x00)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ static AgiEngine *g_agi;
|
||||||
#define testHas(obj) (g_agi->objectGetLocation(obj) == EGO_OWNED)
|
#define testHas(obj) (g_agi->objectGetLocation(obj) == EGO_OWNED)
|
||||||
#define testObjInRoom(obj, v) (g_agi->objectGetLocation(obj) == g_agi->getvar(v))
|
#define testObjInRoom(obj, v) (g_agi->objectGetLocation(obj) == g_agi->getvar(v))
|
||||||
|
|
||||||
extern int timerHack; /* For the timer loop in MH1 logic 153 */
|
extern int timerHack; // For the timer loop in MH1 logic 153
|
||||||
|
|
||||||
static uint8 testCompareStrings(uint8 s1, uint8 s2) {
|
static uint8 testCompareStrings(uint8 s1, uint8 s2) {
|
||||||
char ms1[MAX_STRINGLEN];
|
char ms1[MAX_STRINGLEN];
|
||||||
|
@ -113,6 +113,7 @@ static uint8 testKeypressed() {
|
||||||
game.keypress = 0;
|
game.keypress = 0;
|
||||||
if (!x) {
|
if (!x) {
|
||||||
int mode = game.inputMode;
|
int mode = game.inputMode;
|
||||||
|
|
||||||
game.inputMode = INPUT_NONE;
|
game.inputMode = INPUT_NONE;
|
||||||
g_agi->mainCycle();
|
g_agi->mainCycle();
|
||||||
game.inputMode = mode;
|
game.inputMode = mode;
|
||||||
|
@ -146,7 +147,7 @@ static uint8 testObjInBox(uint8 n, uint8 x1, uint8 y1, uint8 x2, uint8 y2) {
|
||||||
v->yPos >= y1 && v->xPos + v->xSize - 1 <= x2 && v->yPos <= y2;
|
v->yPos >= y1 && v->xPos + v->xSize - 1 <= x2 && v->yPos <= y2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if n is in centre of box */
|
// if n is in centre of box
|
||||||
static uint8 testObjCentre(uint8 n, uint8 x1, uint8 y1, uint8 x2, uint8 y2) {
|
static uint8 testObjCentre(uint8 n, uint8 x1, uint8 y1, uint8 x2, uint8 y2) {
|
||||||
VtEntry *v = &game.viewTable[n];
|
VtEntry *v = &game.viewTable[n];
|
||||||
|
|
||||||
|
@ -154,7 +155,7 @@ static uint8 testObjCentre(uint8 n, uint8 x1, uint8 y1, uint8 x2, uint8 y2) {
|
||||||
v->xPos + v->xSize / 2 <= x2 && v->yPos >= y1 && v->yPos <= y2;
|
v->xPos + v->xSize / 2 <= x2 && v->yPos >= y1 && v->yPos <= y2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if nect N is in right corner */
|
// if nect N is in right corner
|
||||||
static uint8 testObjRight(uint8 n, uint8 x1, uint8 y1, uint8 x2, uint8 y2) {
|
static uint8 testObjRight(uint8 n, uint8 x1, uint8 y1, uint8 x2, uint8 y2) {
|
||||||
VtEntry *v = &game.viewTable[n];
|
VtEntry *v = &game.viewTable[n];
|
||||||
|
|
||||||
|
@ -162,7 +163,7 @@ static uint8 testObjRight(uint8 n, uint8 x1, uint8 y1, uint8 x2, uint8 y2) {
|
||||||
v->xPos + v->xSize - 1 <= x2 && v->yPos >= y1 && v->yPos <= y2;
|
v->xPos + v->xSize - 1 <= x2 && v->yPos >= y1 && v->yPos <= y2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* When player has entered something, it is parsed elsewhere */
|
// When player has entered something, it is parsed elsewhere
|
||||||
static uint8 testSaid(uint8 nwords, uint8 *cc) {
|
static uint8 testSaid(uint8 nwords, uint8 *cc) {
|
||||||
int c, n = game.numEgoWords;
|
int c, n = game.numEgoWords;
|
||||||
int z = 0;
|
int z = 0;
|
||||||
|
@ -170,33 +171,32 @@ static uint8 testSaid(uint8 nwords, uint8 *cc) {
|
||||||
if (g_agi->getflag(fSaidAcceptedInput) || !g_agi->getflag(fEnteredCli))
|
if (g_agi->getflag(fSaidAcceptedInput) || !g_agi->getflag(fEnteredCli))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/* FR:
|
// FR:
|
||||||
* I think the reason for the code below is to add some speed....
|
// I think the reason for the code below is to add some speed....
|
||||||
*
|
//
|
||||||
* if (nwords != num_ego_words)
|
// if (nwords != num_ego_words)
|
||||||
* return false;
|
// return false;
|
||||||
*
|
//
|
||||||
* In the disco scene in Larry 1 when you type "examine blonde",
|
// In the disco scene in Larry 1 when you type "examine blonde",
|
||||||
* inside the logic is expected ( said("examine", "blonde", "rol") )
|
// inside the logic is expected ( said("examine", "blonde", "rol") )
|
||||||
* where word("rol") = 9999
|
// where word("rol") = 9999
|
||||||
*
|
//
|
||||||
* According to the interpreter code 9999 means that whatever the
|
// According to the interpreter code 9999 means that whatever the
|
||||||
* user typed should be correct, but it looks like code 9999 means that
|
// user typed should be correct, but it looks like code 9999 means that
|
||||||
* if the string is empty at this point, the entry is also correct...
|
// if the string is empty at this point, the entry is also correct...
|
||||||
*
|
//
|
||||||
* With the removal of this code, the behaviour of the scene was
|
// With the removal of this code, the behaviour of the scene was
|
||||||
* corrected
|
// corrected
|
||||||
*/
|
|
||||||
|
|
||||||
for (c = 0; nwords && n; c++, nwords--, n--) {
|
for (c = 0; nwords && n; c++, nwords--, n--) {
|
||||||
z = READ_LE_UINT16(cc);
|
z = READ_LE_UINT16(cc);
|
||||||
cc += 2;
|
cc += 2;
|
||||||
|
|
||||||
switch (z) {
|
switch (z) {
|
||||||
case 9999: /* rest of line (empty string counts to...) */
|
case 9999: // rest of line (empty string counts to...)
|
||||||
nwords = 1;
|
nwords = 1;
|
||||||
break;
|
break;
|
||||||
case 1: /* any word */
|
case 1: // any word
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (game.egoWords[c].id != z)
|
if (game.egoWords[c].id != z)
|
||||||
|
@ -205,13 +205,12 @@ static uint8 testSaid(uint8 nwords, uint8 *cc) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The entry string should be entirely parsed, or last word = 9999 */
|
// The entry string should be entirely parsed, or last word = 9999
|
||||||
if (n && z != 9999)
|
if (n && z != 9999)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/* The interpreter string shouldn't be entirely parsed, but next
|
// The interpreter string shouldn't be entirely parsed, but next
|
||||||
* word must be 9999.
|
// word must be 9999.
|
||||||
*/
|
|
||||||
if (nwords != 0 && READ_LE_UINT16(cc) != 9999)
|
if (nwords != 0 && READ_LE_UINT16(cc) != 9999)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -240,16 +239,15 @@ int AgiEngine::testIfCode(int lognum) {
|
||||||
memmove(p, (code + ip), 16);
|
memmove(p, (code + ip), 16);
|
||||||
|
|
||||||
switch (op) {
|
switch (op) {
|
||||||
case 0xFF: /* END IF, TEST true */
|
case 0xFF: // END IF, TEST true
|
||||||
end_test = true;
|
end_test = true;
|
||||||
break;
|
break;
|
||||||
case 0xFD:
|
case 0xFD:
|
||||||
notTest = !notTest;
|
notTest = !notTest;
|
||||||
continue;
|
continue;
|
||||||
case 0xFC: /* OR */
|
case 0xFC: // OR
|
||||||
/* if or_test is ON and we hit 0xFC, end of OR, then
|
// if or_test is ON and we hit 0xFC, end of OR, then
|
||||||
* or is STILL false so break.
|
// or is STILL false so break.
|
||||||
*/
|
|
||||||
if (orTest) {
|
if (orTest) {
|
||||||
ec = false;
|
ec = false;
|
||||||
retval = false;
|
retval = false;
|
||||||
|
@ -260,7 +258,7 @@ int AgiEngine::testIfCode(int lognum) {
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case 0x00:
|
case 0x00:
|
||||||
/* return true? */
|
// return true?
|
||||||
end_test = true;
|
end_test = true;
|
||||||
break;
|
break;
|
||||||
case 0x01:
|
case 0x01:
|
||||||
|
@ -317,9 +315,9 @@ int AgiEngine::testIfCode(int lognum) {
|
||||||
case 0x0E:
|
case 0x0E:
|
||||||
ec = testSaid(p[0], (uint8 *) code + (ip + 1));
|
ec = testSaid(p[0], (uint8 *) code + (ip + 1));
|
||||||
ip = lastIp;
|
ip = lastIp;
|
||||||
ip++; /* skip opcode */
|
ip++; // skip opcode
|
||||||
ip += p[0] * 2; /* skip num_words * 2 */
|
ip += p[0] * 2; // skip num_words * 2
|
||||||
ip++; /* skip num_words opcode */
|
ip++; // skip num_words opcode
|
||||||
break;
|
break;
|
||||||
case 0x0F:
|
case 0x0F:
|
||||||
debugC(7, kDebugLevelScripts, "comparing [%s], [%s]", game.strings[p[0]], game.strings[p[1]]);
|
debugC(7, kDebugLevelScripts, "comparing [%s], [%s]", game.strings[p[0]], game.strings[p[1]]);
|
||||||
|
@ -353,39 +351,38 @@ int AgiEngine::testIfCode(int lognum) {
|
||||||
if (op <= 0x12)
|
if (op <= 0x12)
|
||||||
ip += logicNamesTest[op].numArgs;
|
ip += logicNamesTest[op].numArgs;
|
||||||
|
|
||||||
/* exchange ec value */
|
// exchange ec value
|
||||||
if (notTest)
|
if (notTest)
|
||||||
ec = !ec;
|
ec = !ec;
|
||||||
|
|
||||||
/* not is only enabled for 1 test command */
|
// not is only enabled for 1 test command
|
||||||
notTest = false;
|
notTest = false;
|
||||||
|
|
||||||
if (orTest && ec) {
|
if (orTest && ec) {
|
||||||
/* a true inside an OR statement passes
|
// a true inside an OR statement passes
|
||||||
* ENTIRE statement scan for end of OR
|
// ENTIRE statement scan for end of OR
|
||||||
*/
|
|
||||||
|
|
||||||
/* CM: test for opcode < 0xfc changed from 'op' to
|
// CM: test for opcode < 0xfc changed from 'op' to
|
||||||
* '*(code+ip)', to avoid problem with the 0xfd (NOT)
|
// '*(code+ip)', to avoid problem with the 0xfd (NOT)
|
||||||
* opcode byte. Changed a bad ip += ... ip++ construct.
|
// opcode byte. Changed a bad ip += ... ip++ construct.
|
||||||
* This should fix the crash with Larry's logic.0 code:
|
// This should fix the crash with Larry's logic.0 code:
|
||||||
*
|
//
|
||||||
* if ((isset(4) ||
|
// if ((isset(4) ||
|
||||||
* !isset(2) ||
|
// !isset(2) ||
|
||||||
* v30 == 2 ||
|
// v30 == 2 ||
|
||||||
* v30 == 1)) {
|
// v30 == 1)) {
|
||||||
* goto Label1;
|
// goto Label1;
|
||||||
* }
|
// }
|
||||||
*
|
//
|
||||||
* The bytecode is:
|
// The bytecode is:
|
||||||
* ff fc 07 04 fd 07 02 01 1e 02 01 1e 01 fc ff
|
// ff fc 07 04 fd 07 02 01 1e 02 01 1e 01 fc ff
|
||||||
*/
|
|
||||||
|
|
||||||
/* find end of OR */
|
// find end of OR
|
||||||
while (*(code + ip) != 0xFC) {
|
while (*(code + ip) != 0xFC) {
|
||||||
if (*(code + ip) == 0x0E) { /* said */
|
if (*(code + ip) == 0x0E) { // said
|
||||||
ip++;
|
ip++;
|
||||||
/* cover count + ^words */
|
|
||||||
|
// cover count + ^words
|
||||||
ip += 1 + ((*(code + ip)) * 2);
|
ip += 1 + ((*(code + ip)) * 2);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -404,7 +401,7 @@ int AgiEngine::testIfCode(int lognum) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if false, scan for end of IP? */
|
// if false, scan for end of IP?
|
||||||
if (retval)
|
if (retval)
|
||||||
ip += 2;
|
ip += 2;
|
||||||
else {
|
else {
|
||||||
|
@ -420,7 +417,7 @@ int AgiEngine::testIfCode(int lognum) {
|
||||||
ip++;
|
ip++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ip++; /* skip over 0xFF */
|
ip++; // skip over 0xFF
|
||||||
ip += READ_LE_UINT16(code + ip) + 2;
|
ip += READ_LE_UINT16(code + ip) + 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -90,7 +90,7 @@ void PictureMgr::drawLine(int x1, int y1, int x2, int y2) {
|
||||||
#else
|
#else
|
||||||
int i, x, y, deltaX, deltaY, stepX, stepY, errorX, errorY, detdelta;
|
int i, x, y, deltaX, deltaY, stepX, stepY, errorX, errorY, detdelta;
|
||||||
|
|
||||||
/* Vertical line */
|
// Vertical line
|
||||||
|
|
||||||
if (x1 == x2) {
|
if (x1 == x2) {
|
||||||
if (y1 > y2) {
|
if (y1 > y2) {
|
||||||
|
@ -103,7 +103,7 @@ void PictureMgr::drawLine(int x1, int y1, int x2, int y2) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Horizontal line */
|
// Horizontal line
|
||||||
|
|
||||||
if (y1 == y2) {
|
if (y1 == y2) {
|
||||||
if (x1 > x2) {
|
if (x1 > x2) {
|
||||||
|
@ -274,7 +274,7 @@ void PictureMgr::agiFill(unsigned int x, unsigned int y) {
|
||||||
if (!isOkFillHere(p.x, p.y))
|
if (!isOkFillHere(p.x, p.y))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* Scan for left border */
|
// Scan for left border
|
||||||
for (c = p.x - 1; isOkFillHere(c, p.y); c--)
|
for (c = p.x - 1; isOkFillHere(c, p.y); c--)
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -592,7 +592,7 @@ void PictureMgr::drawPicture() {
|
||||||
break;
|
break;
|
||||||
case 0xe4: // fill (C64)
|
case 0xe4: // fill (C64)
|
||||||
_scrColor = nextByte();
|
_scrColor = nextByte();
|
||||||
_scrColor &= 0xF; /* for v3 drawing diff */
|
_scrColor &= 0xF; // for v3 drawing diff
|
||||||
fill();
|
fill();
|
||||||
break;
|
break;
|
||||||
case 0xe5: // enable screen drawing (C64)
|
case 0xe5: // enable screen drawing (C64)
|
||||||
|
@ -883,7 +883,7 @@ int PictureMgr::decodePicture(byte* data, uint32 length, int clr, int pic_width,
|
||||||
* @param n AGI picture resource number
|
* @param n AGI picture resource number
|
||||||
*/
|
*/
|
||||||
int PictureMgr::unloadPicture(int n) {
|
int PictureMgr::unloadPicture(int n) {
|
||||||
/* remove visual buffer & priority buffer if they exist */
|
// remove visual buffer & priority buffer if they exist
|
||||||
if (_vm->_game.dirPic[n].flags & RES_LOADED) {
|
if (_vm->_game.dirPic[n].flags & RES_LOADED) {
|
||||||
free(_vm->_game.pictures[n].rdata);
|
free(_vm->_game.pictures[n].rdata);
|
||||||
_vm->_game.dirPic[n].flags &= ~RES_LOADED;
|
_vm->_game.dirPic[n].flags &= ~RES_LOADED;
|
||||||
|
|
|
@ -54,15 +54,6 @@ PreAgiEngine::PreAgiEngine(OSystem *syst, const AGIGameDescription *gameDesc) :
|
||||||
_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume"));
|
_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume"));
|
||||||
_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, ConfMan.getInt("music_volume"));
|
_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, ConfMan.getInt("music_volume"));
|
||||||
|
|
||||||
/*
|
|
||||||
const GameSettings *g;
|
|
||||||
|
|
||||||
const char *gameid = ConfMan.get("gameid").c_str();
|
|
||||||
for (g = agiSettings; g->gameid; ++g)
|
|
||||||
if (!scumm_stricmp(g->gameid, gameid))
|
|
||||||
_gameId = g->id;
|
|
||||||
*/
|
|
||||||
|
|
||||||
_rnd = new Common::RandomSource();
|
_rnd = new Common::RandomSource();
|
||||||
|
|
||||||
Common::addDebugChannel(kDebugLevelMain, "Main", "Generic debug level");
|
Common::addDebugChannel(kDebugLevelMain, "Main", "Generic debug level");
|
||||||
|
@ -79,29 +70,6 @@ PreAgiEngine::PreAgiEngine(OSystem *syst, const AGIGameDescription *gameDesc) :
|
||||||
memset(&_game, 0, sizeof(struct AgiGame));
|
memset(&_game, 0, sizeof(struct AgiGame));
|
||||||
memset(&_debug, 0, sizeof(struct AgiDebug));
|
memset(&_debug, 0, sizeof(struct AgiDebug));
|
||||||
memset(&g_mouse, 0, sizeof(struct Mouse));
|
memset(&g_mouse, 0, sizeof(struct Mouse));
|
||||||
|
|
||||||
/*
|
|
||||||
_game.clockEnabled = false;
|
|
||||||
_game.state = STATE_INIT;
|
|
||||||
|
|
||||||
_keyQueueStart = 0;
|
|
||||||
_keyQueueEnd = 0;
|
|
||||||
|
|
||||||
_allowSynthetic = false;
|
|
||||||
|
|
||||||
g_tickTimer = 0;
|
|
||||||
|
|
||||||
_intobj = NULL;
|
|
||||||
|
|
||||||
_lastSentence[0] = 0;
|
|
||||||
memset(&_stringdata, 0, sizeof(struct StringData));
|
|
||||||
|
|
||||||
_objects = NULL;
|
|
||||||
|
|
||||||
_oldMode = -1;
|
|
||||||
|
|
||||||
_firstSlot = 0;
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreAgiEngine::initialize() {
|
void PreAgiEngine::initialize() {
|
||||||
|
@ -170,7 +138,7 @@ void PreAgiEngine::initialize() {
|
||||||
|
|
||||||
debugC(2, kDebugLevelMain, "Detect game");
|
debugC(2, kDebugLevelMain, "Detect game");
|
||||||
|
|
||||||
/* clear all resources and events */
|
// clear all resources and events
|
||||||
for (int i = 0; i < MAX_DIRS; i++) {
|
for (int i = 0; i < MAX_DIRS; i++) {
|
||||||
memset(&_game.pictures[i], 0, sizeof(struct AgiPicture));
|
memset(&_game.pictures[i], 0, sizeof(struct AgiPicture));
|
||||||
memset(&_game.sounds[i], 0, sizeof(class AgiSound *)); // _game.sounds contains pointers now
|
memset(&_game.sounds[i], 0, sizeof(class AgiSound *)); // _game.sounds contains pointers now
|
||||||
|
@ -190,10 +158,10 @@ PreAgiEngine::~PreAgiEngine() {
|
||||||
Common::Error PreAgiEngine::go() {
|
Common::Error PreAgiEngine::go() {
|
||||||
setflag(fSoundOn, true); // enable sound
|
setflag(fSoundOn, true); // enable sound
|
||||||
|
|
||||||
/*
|
//
|
||||||
FIXME (Fingolfin asks): Why are Mickey, Winnie and Troll standalone classes
|
// FIXME (Fingolfin asks): Why are Mickey, Winnie and Troll standalone classes
|
||||||
instead of being subclasses of PreAgiEngine ?
|
// instead of being subclasses of PreAgiEngine ?
|
||||||
*/
|
//
|
||||||
|
|
||||||
// run preagi engine main loop
|
// run preagi engine main loop
|
||||||
switch (getGameID()) {
|
switch (getGameID()) {
|
||||||
|
|
|
@ -92,8 +92,10 @@ void Mickey::readOfsData(int offset, int iItem, uint8 *buffer, long buflen) {
|
||||||
|
|
||||||
readExe(offset, buffer, buflen);
|
readExe(offset, buffer, buflen);
|
||||||
memcpy(ofs, buffer, sizeof(ofs));
|
memcpy(ofs, buffer, sizeof(ofs));
|
||||||
|
|
||||||
for (int i = 0; i < 256; i++)
|
for (int i = 0; i < 256; i++)
|
||||||
ofs[i] = buffer[i*2] + 256 * buffer[i*2+1];
|
ofs[i] = buffer[i*2] + 256 * buffer[i*2+1];
|
||||||
|
|
||||||
readExe(ofs[iItem] + IDI_MSA_OFS_EXE, buffer, buflen);
|
readExe(ofs[iItem] + IDI_MSA_OFS_EXE, buffer, buflen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -395,26 +397,38 @@ bool Mickey::getMenuSelRow(MSA_MENU menu, int *sel0, int *sel1, int iRow) {
|
||||||
// Click to move
|
// Click to move
|
||||||
if (northIndex >= 0 && (event.mouse.x >= 20 && event.mouse.x <= (IDI_MSA_PIC_WIDTH + 10) * 2) &&
|
if (northIndex >= 0 && (event.mouse.x >= 20 && event.mouse.x <= (IDI_MSA_PIC_WIDTH + 10) * 2) &&
|
||||||
(event.mouse.y >= 0 && event.mouse.y <= 10)) {
|
(event.mouse.y >= 0 && event.mouse.y <= 10)) {
|
||||||
*sel0 = goIndex; *sel1 = northIndex;
|
*sel0 = goIndex;
|
||||||
|
*sel1 = northIndex;
|
||||||
|
|
||||||
drawMenu(menu, *sel0, *sel1);
|
drawMenu(menu, *sel0, *sel1);
|
||||||
|
|
||||||
_vm->_gfx->setCursorPalette(false);
|
_vm->_gfx->setCursorPalette(false);
|
||||||
_clickToMove = true;
|
_clickToMove = true;
|
||||||
} else if (southIndex >= 0 && (event.mouse.x >= 20 && event.mouse.x <= (IDI_MSA_PIC_WIDTH + 10) * 2) &&
|
} else if (southIndex >= 0 && (event.mouse.x >= 20 && event.mouse.x <= (IDI_MSA_PIC_WIDTH + 10) * 2) &&
|
||||||
(event.mouse.y >= IDI_MSA_PIC_HEIGHT - 10 && event.mouse.y <= IDI_MSA_PIC_HEIGHT)) {
|
(event.mouse.y >= IDI_MSA_PIC_HEIGHT - 10 && event.mouse.y <= IDI_MSA_PIC_HEIGHT)) {
|
||||||
*sel0 = goIndex; *sel1 = southIndex;
|
*sel0 = goIndex;
|
||||||
|
*sel1 = southIndex;
|
||||||
|
|
||||||
drawMenu(menu, *sel0, *sel1);
|
drawMenu(menu, *sel0, *sel1);
|
||||||
|
|
||||||
_vm->_gfx->setCursorPalette(false);
|
_vm->_gfx->setCursorPalette(false);
|
||||||
_clickToMove = true;
|
_clickToMove = true;
|
||||||
} else if (westIndex >= 0 && (event.mouse.y >= 0 && event.mouse.y <= IDI_MSA_PIC_HEIGHT) &&
|
} else if (westIndex >= 0 && (event.mouse.y >= 0 && event.mouse.y <= IDI_MSA_PIC_HEIGHT) &&
|
||||||
(event.mouse.x >= 20 && event.mouse.x <= 30)) {
|
(event.mouse.x >= 20 && event.mouse.x <= 30)) {
|
||||||
*sel0 = goIndex; *sel1 = westIndex;
|
*sel0 = goIndex;
|
||||||
|
*sel1 = westIndex;
|
||||||
|
|
||||||
drawMenu(menu, *sel0, *sel1);
|
drawMenu(menu, *sel0, *sel1);
|
||||||
|
|
||||||
_vm->_gfx->setCursorPalette(false);
|
_vm->_gfx->setCursorPalette(false);
|
||||||
_clickToMove = true;
|
_clickToMove = true;
|
||||||
} else if (eastIndex >= 0 && (event.mouse.y >= 0 && event.mouse.y <= IDI_MSA_PIC_HEIGHT) &&
|
} else if (eastIndex >= 0 && (event.mouse.y >= 0 && event.mouse.y <= IDI_MSA_PIC_HEIGHT) &&
|
||||||
(event.mouse.x >= IDI_MSA_PIC_WIDTH * 2 && event.mouse.x <= (IDI_MSA_PIC_WIDTH + 10) * 2)) {
|
(event.mouse.x >= IDI_MSA_PIC_WIDTH * 2 && event.mouse.x <= (IDI_MSA_PIC_WIDTH + 10) * 2)) {
|
||||||
*sel0 = goIndex; *sel1 = eastIndex;
|
*sel0 = goIndex;
|
||||||
|
*sel1 = eastIndex;
|
||||||
|
|
||||||
drawMenu(menu, *sel0, *sel1);
|
drawMenu(menu, *sel0, *sel1);
|
||||||
|
|
||||||
_vm->_gfx->setCursorPalette(false);
|
_vm->_gfx->setCursorPalette(false);
|
||||||
_clickToMove = true;
|
_clickToMove = true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -422,19 +436,26 @@ bool Mickey::getMenuSelRow(MSA_MENU menu, int *sel0, int *sel1, int iRow) {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
case Common::EVENT_RBUTTONUP:
|
case Common::EVENT_RBUTTONUP:
|
||||||
*sel0 = 0; *sel1 = -1;
|
*sel0 = 0;
|
||||||
|
*sel1 = -1;
|
||||||
return false;
|
return false;
|
||||||
case Common::EVENT_WHEELUP:
|
case Common::EVENT_WHEELUP:
|
||||||
if (iRow < 2) {
|
if (iRow < 2) {
|
||||||
*sel -= 1;
|
*sel -= 1;
|
||||||
if (*sel < 0) *sel = nWords - 1;
|
|
||||||
|
if (*sel < 0)
|
||||||
|
*sel = nWords - 1;
|
||||||
|
|
||||||
drawMenu(menu, *sel0, *sel1);
|
drawMenu(menu, *sel0, *sel1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Common::EVENT_WHEELDOWN:
|
case Common::EVENT_WHEELDOWN:
|
||||||
if (iRow < 2) {
|
if (iRow < 2) {
|
||||||
*sel += 1;
|
*sel += 1;
|
||||||
if (*sel == nWords) *sel = 0;
|
|
||||||
|
if (*sel == nWords)
|
||||||
|
*sel = 0;
|
||||||
|
|
||||||
drawMenu(menu, *sel0, *sel1);
|
drawMenu(menu, *sel0, *sel1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -458,28 +479,45 @@ bool Mickey::getMenuSelRow(MSA_MENU menu, int *sel0, int *sel1, int iRow) {
|
||||||
break;
|
break;
|
||||||
case Common::KEYCODE_8:
|
case Common::KEYCODE_8:
|
||||||
if (event.kbd.flags & Common::KBD_CTRL) {
|
if (event.kbd.flags & Common::KBD_CTRL) {
|
||||||
*sel0 = 0; *sel1 = -1; return false;
|
*sel0 = 0;
|
||||||
|
*sel1 = -1;
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Common::KEYCODE_ESCAPE:
|
case Common::KEYCODE_ESCAPE:
|
||||||
*sel0 = 0; *sel1 = -1; return false;
|
*sel0 = 0;
|
||||||
|
*sel1 = -1;
|
||||||
|
|
||||||
|
return false;
|
||||||
case Common::KEYCODE_s:
|
case Common::KEYCODE_s:
|
||||||
_vm->flipflag(fSoundOn);
|
_vm->flipflag(fSoundOn);
|
||||||
break;
|
break;
|
||||||
case Common::KEYCODE_c:
|
case Common::KEYCODE_c:
|
||||||
inventory();
|
inventory();
|
||||||
drawRoom();
|
drawRoom();
|
||||||
*sel0 = 0; *sel1 = -1; return false;
|
|
||||||
|
*sel0 = 0;
|
||||||
|
*sel1 = -1;
|
||||||
|
|
||||||
|
return false;
|
||||||
case Common::KEYCODE_b:
|
case Common::KEYCODE_b:
|
||||||
printRoomDesc();
|
printRoomDesc();
|
||||||
drawMenu(menu, *sel0, *sel1);
|
drawMenu(menu, *sel0, *sel1);
|
||||||
*sel0 = 0; *sel1 = -1; return false;
|
|
||||||
|
*sel0 = 0;
|
||||||
|
*sel1 = -1;
|
||||||
|
|
||||||
|
return false;
|
||||||
case Common::KEYCODE_LEFT:
|
case Common::KEYCODE_LEFT:
|
||||||
case Common::KEYCODE_KP4:
|
case Common::KEYCODE_KP4:
|
||||||
case Common::KEYCODE_4:
|
case Common::KEYCODE_4:
|
||||||
if (iRow < 2) {
|
if (iRow < 2) {
|
||||||
*sel -= 1;
|
*sel -= 1;
|
||||||
if (*sel < 0) *sel = nWords - 1;
|
|
||||||
|
if (*sel < 0)
|
||||||
|
*sel = nWords - 1;
|
||||||
|
|
||||||
drawMenu(menu, *sel0, *sel1);
|
drawMenu(menu, *sel0, *sel1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -489,7 +527,10 @@ bool Mickey::getMenuSelRow(MSA_MENU menu, int *sel0, int *sel1, int iRow) {
|
||||||
case Common::KEYCODE_6:
|
case Common::KEYCODE_6:
|
||||||
if (iRow < 2) {
|
if (iRow < 2) {
|
||||||
*sel += 1;
|
*sel += 1;
|
||||||
if (*sel == nWords) *sel = 0;
|
|
||||||
|
if (*sel == nWords)
|
||||||
|
*sel = 0;
|
||||||
|
|
||||||
drawMenu(menu, *sel0, *sel1);
|
drawMenu(menu, *sel0, *sel1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -529,7 +570,9 @@ void Mickey::getMenuSel(char *buffer, int *sel0, int *sel1) {
|
||||||
if (getMenuSelRow(menu, sel0, sel1, 0)) {
|
if (getMenuSelRow(menu, sel0, sel1, 0)) {
|
||||||
if (_clickToMove)
|
if (_clickToMove)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
*sel1 = 0;
|
*sel1 = 0;
|
||||||
|
|
||||||
if (getMenuSelRow(menu, sel0, sel1, 1)) {
|
if (getMenuSelRow(menu, sel0, sel1, 1)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -557,6 +600,7 @@ void Mickey::centerMenu(MSA_MENU *menu) {
|
||||||
}
|
}
|
||||||
w += menu->row[iRow].count - 1;
|
w += menu->row[iRow].count - 1;
|
||||||
x = (40 - w) / 2; // FIX
|
x = (40 - w) / 2; // FIX
|
||||||
|
|
||||||
for (iWord = 0; iWord < menu->row[iRow].count; iWord++) {
|
for (iWord = 0; iWord < menu->row[iRow].count; iWord++) {
|
||||||
menu->row[iRow].entry[iWord].x0 = x;
|
menu->row[iRow].entry[iWord].x0 = x;
|
||||||
x += strlen((char *)menu->row[iRow].entry[iWord].szText) + 1;
|
x += strlen((char *)menu->row[iRow].entry[iWord].szText) + 1;
|
||||||
|
@ -688,6 +732,7 @@ void Mickey::drawObj(ENUM_MSA_OBJECT iObj, int x0, int y0) {
|
||||||
Common::File file;
|
Common::File file;
|
||||||
if (!file.open(szFile))
|
if (!file.open(szFile))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
uint32 size = file.size();
|
uint32 size = file.size();
|
||||||
file.read(buffer, size);
|
file.read(buffer, size);
|
||||||
file.close();
|
file.close();
|
||||||
|
@ -709,6 +754,7 @@ void Mickey::drawPic(int iPic) {
|
||||||
Common::File file;
|
Common::File file;
|
||||||
if (!file.open(szFile))
|
if (!file.open(szFile))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
uint32 size = file.size();
|
uint32 size = file.size();
|
||||||
file.read(buffer, size);
|
file.read(buffer, size);
|
||||||
file.close();
|
file.close();
|
||||||
|
@ -750,7 +796,8 @@ void Mickey::drawRoomAnimation() {
|
||||||
|
|
||||||
for (int i = 0; i < 12; i++) {
|
for (int i = 0; i < 12; i++) {
|
||||||
iColor = _game.nFrame + i;
|
iColor = _game.nFrame + i;
|
||||||
if (iColor > 15) iColor -= 15;
|
if (iColor > 15)
|
||||||
|
iColor -= 15;
|
||||||
|
|
||||||
objLight[1] = iColor;
|
objLight[1] = iColor;
|
||||||
objLight[4] += 7;
|
objLight[4] += 7;
|
||||||
|
@ -763,7 +810,8 @@ void Mickey::drawRoomAnimation() {
|
||||||
|
|
||||||
|
|
||||||
_game.nFrame--;
|
_game.nFrame--;
|
||||||
if (_game.nFrame < 0) _game.nFrame = 15;
|
if (_game.nFrame < 0)
|
||||||
|
_game.nFrame = 15;
|
||||||
|
|
||||||
playSound(IDI_MSA_SND_PRESS_BLUE);
|
playSound(IDI_MSA_SND_PRESS_BLUE);
|
||||||
}
|
}
|
||||||
|
@ -773,7 +821,9 @@ void Mickey::drawRoomAnimation() {
|
||||||
|
|
||||||
// draw XL30 screen
|
// draw XL30 screen
|
||||||
if (_game.fAnimXL30) {
|
if (_game.fAnimXL30) {
|
||||||
if (_game.nFrame > 5) _game.nFrame = 0;
|
if (_game.nFrame > 5)
|
||||||
|
_game.nFrame = 0;
|
||||||
|
|
||||||
drawObj((ENUM_MSA_OBJECT)(IDI_MSA_OBJECT_XL31 + _game.nFrame), 0, 4);
|
drawObj((ENUM_MSA_OBJECT)(IDI_MSA_OBJECT_XL31 + _game.nFrame), 0, 4);
|
||||||
_game.nFrame++;
|
_game.nFrame++;
|
||||||
};
|
};
|
||||||
|
@ -787,7 +837,8 @@ void Mickey::drawRoomAnimation() {
|
||||||
if (!_game.fHasXtal) {
|
if (!_game.fHasXtal) {
|
||||||
switch(_game.iPlanet) {
|
switch(_game.iPlanet) {
|
||||||
case IDI_MSA_PLANET_VENUS:
|
case IDI_MSA_PLANET_VENUS:
|
||||||
if (_game.iRmMenu[_game.iRoom] != 2) break;
|
if (_game.iRmMenu[_game.iRoom] != 2)
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
drawObj(
|
drawObj(
|
||||||
IDI_MSA_OBJECT_CRYSTAL,
|
IDI_MSA_OBJECT_CRYSTAL,
|
||||||
|
@ -882,6 +933,7 @@ void Mickey::drawLogo() {
|
||||||
Common::File infile;
|
Common::File infile;
|
||||||
if (!infile.open(szFile))
|
if (!infile.open(szFile))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
infile.read(buffer, infile.size());
|
infile.read(buffer, infile.size());
|
||||||
infile.close();
|
infile.close();
|
||||||
|
|
||||||
|
@ -947,6 +999,7 @@ bool Mickey::loadGame() {
|
||||||
sprintf(szFile, "%s.s%02d", _vm->getTargetName().c_str(), sel);
|
sprintf(szFile, "%s.s%02d", _vm->getTargetName().c_str(), sel);
|
||||||
if (!(infile = _vm->getSaveFileMan()->openForLoading(szFile))) {
|
if (!(infile = _vm->getSaveFileMan()->openForLoading(szFile))) {
|
||||||
printLine("PLEASE CHECK THE DISK DRIVE");
|
printLine("PLEASE CHECK THE DISK DRIVE");
|
||||||
|
|
||||||
if (_vm->getSelection(kSelAnyKey) == 0)
|
if (_vm->getSelection(kSelAnyKey) == 0)
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1063,6 +1116,7 @@ void Mickey::saveGame() {
|
||||||
sprintf(szFile, "%s.s%02d", _vm->getTargetName().c_str(), sel);
|
sprintf(szFile, "%s.s%02d", _vm->getTargetName().c_str(), sel);
|
||||||
if (!(outfile = _vm->getSaveFileMan()->openForSaving(szFile))) {
|
if (!(outfile = _vm->getSaveFileMan()->openForSaving(szFile))) {
|
||||||
printLine("PLEASE CHECK THE DISK DRIVE");
|
printLine("PLEASE CHECK THE DISK DRIVE");
|
||||||
|
|
||||||
if (_vm->getSelection(kSelAnyKey) == 0)
|
if (_vm->getSelection(kSelAnyKey) == 0)
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1658,15 +1712,18 @@ bool Mickey::parse(int cmd, int arg) {
|
||||||
if (_game.fItem[IDI_MSA_ITEM_WRENCH]) {
|
if (_game.fItem[IDI_MSA_ITEM_WRENCH]) {
|
||||||
_game.iRmMenu[_game.iRoom] = 1;
|
_game.iRmMenu[_game.iRoom] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
printDatMessage(arg);
|
printDatMessage(arg);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case IDI_MSA_ACTION_USE_WRENCH:
|
case IDI_MSA_ACTION_USE_WRENCH:
|
||||||
_game.fItemUsed[IDI_MSA_ITEM_WRENCH] = true;
|
_game.fItemUsed[IDI_MSA_ITEM_WRENCH] = true;
|
||||||
printDatString(arg);
|
printDatString(arg);
|
||||||
|
|
||||||
if (_game.iRmPic[_game.iRoom] == IDI_MSA_PIC_VENUS_PROBE_1) {
|
if (_game.iRmPic[_game.iRoom] == IDI_MSA_PIC_VENUS_PROBE_1) {
|
||||||
_vm->clearRow(22);
|
_vm->clearRow(22);
|
||||||
}
|
}
|
||||||
|
|
||||||
waitAnyKey();
|
waitAnyKey();
|
||||||
break;
|
break;
|
||||||
case IDI_MSA_ACTION_GET_XTAL_VENUS:
|
case IDI_MSA_ACTION_GET_XTAL_VENUS:
|
||||||
|
@ -1685,11 +1742,13 @@ bool Mickey::parse(int cmd, int arg) {
|
||||||
case IDI_MSA_ACTION_ENTER_OPENING:
|
case IDI_MSA_ACTION_ENTER_OPENING:
|
||||||
if (_game.fItemUsed[IDI_MSA_ITEM_CROWBAR]) {
|
if (_game.fItemUsed[IDI_MSA_ITEM_CROWBAR]) {
|
||||||
_game.iRoom = IDI_MSA_PIC_NEPTUNE_CASTLE_4;
|
_game.iRoom = IDI_MSA_PIC_NEPTUNE_CASTLE_4;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
if (_game.fItem[IDI_MSA_ITEM_CROWBAR]) {
|
if (_game.fItem[IDI_MSA_ITEM_CROWBAR]) {
|
||||||
_game.iRmMenu[_game.iRoom] = 2;
|
_game.iRmMenu[_game.iRoom] = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
printDatMessage(arg);
|
printDatMessage(arg);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1707,11 +1766,13 @@ bool Mickey::parse(int cmd, int arg) {
|
||||||
if (_game.fItem[IDI_MSA_ITEM_SCARF]) {
|
if (_game.fItem[IDI_MSA_ITEM_SCARF]) {
|
||||||
_game.iRmMenu[_game.iRoom] = 1;
|
_game.iRmMenu[_game.iRoom] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
printDatMessage(arg);
|
printDatMessage(arg);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case IDI_MSA_ACTION_TALK_LEADER:
|
case IDI_MSA_ACTION_TALK_LEADER:
|
||||||
_game.iRoom = IDI_MSA_PIC_NEPTUNE_ENTRYWAY;
|
_game.iRoom = IDI_MSA_PIC_NEPTUNE_ENTRYWAY;
|
||||||
|
|
||||||
printDatMessage(arg);
|
printDatMessage(arg);
|
||||||
return true;
|
return true;
|
||||||
case IDI_MSA_ACTION_GIVE_SCARF:
|
case IDI_MSA_ACTION_GIVE_SCARF:
|
||||||
|
@ -1721,6 +1782,7 @@ bool Mickey::parse(int cmd, int arg) {
|
||||||
_game.iRmMenu[_game.iRoom] = 0;
|
_game.iRmMenu[_game.iRoom] = 0;
|
||||||
_game.iRmMenu[IDI_MSA_PIC_EARTH_BEDROOM] = 2;
|
_game.iRmMenu[IDI_MSA_PIC_EARTH_BEDROOM] = 2;
|
||||||
_game.iRoom = IDI_MSA_PIC_NEPTUNE_ENTRYWAY;
|
_game.iRoom = IDI_MSA_PIC_NEPTUNE_ENTRYWAY;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// MERCURY
|
// MERCURY
|
||||||
|
@ -1740,7 +1802,9 @@ bool Mickey::parse(int cmd, int arg) {
|
||||||
_game.iRmObj[_game.iRoom] = 17;
|
_game.iRmObj[_game.iRoom] = 17;
|
||||||
_game.iRmMenu[_game.iRoom] = 2;
|
_game.iRmMenu[_game.iRoom] = 2;
|
||||||
_game.fItem[IDI_MSA_ITEM_SUNGLASSES] = false;
|
_game.fItem[IDI_MSA_ITEM_SUNGLASSES] = false;
|
||||||
|
|
||||||
getXtal(arg);
|
getXtal(arg);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// TITAN (SATURN)
|
// TITAN (SATURN)
|
||||||
|
@ -1751,11 +1815,15 @@ bool Mickey::parse(int cmd, int arg) {
|
||||||
_game.iRmMenu[IDI_MSA_PIC_SATURN_LAKE_1] = 1;
|
_game.iRmMenu[IDI_MSA_PIC_SATURN_LAKE_1] = 1;
|
||||||
_game.iRmMenu[IDI_MSA_PIC_SATURN_LAKE_2] = 1;
|
_game.iRmMenu[IDI_MSA_PIC_SATURN_LAKE_2] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
printDatMessage(arg);
|
printDatMessage(arg);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case IDI_MSA_ACTION_USE_MATTRESS:
|
case IDI_MSA_ACTION_USE_MATTRESS:
|
||||||
_game.iRoom = IDI_MSA_PIC_SATURN_ISLAND;
|
_game.iRoom = IDI_MSA_PIC_SATURN_ISLAND;
|
||||||
|
|
||||||
printDatMessage(arg);
|
printDatMessage(arg);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
case IDI_MSA_ACTION_GET_XTAL_SATURN:
|
case IDI_MSA_ACTION_GET_XTAL_SATURN:
|
||||||
if (_game.fHasXtal) {
|
if (_game.fHasXtal) {
|
||||||
|
@ -1766,7 +1834,9 @@ bool Mickey::parse(int cmd, int arg) {
|
||||||
break;
|
break;
|
||||||
case IDI_MSA_ACTION_LEAVE_ISLAND:
|
case IDI_MSA_ACTION_LEAVE_ISLAND:
|
||||||
_game.iRoom = IDI_MSA_PIC_SATURN_LAKE_1;
|
_game.iRoom = IDI_MSA_PIC_SATURN_LAKE_1;
|
||||||
|
|
||||||
printDatMessage(arg);
|
printDatMessage(arg);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// PLUTO
|
// PLUTO
|
||||||
|
@ -1785,7 +1855,9 @@ bool Mickey::parse(int cmd, int arg) {
|
||||||
_game.fItem[IDI_MSA_ITEM_BONE] = false;
|
_game.fItem[IDI_MSA_ITEM_BONE] = false;
|
||||||
_game.iRmMenu[_game.iRoom] = 0;
|
_game.iRmMenu[_game.iRoom] = 0;
|
||||||
_game.iRmObj[_game.iRoom] = 16;
|
_game.iRmObj[_game.iRoom] = 16;
|
||||||
|
|
||||||
getXtal(arg);
|
getXtal(arg);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// IO (JUPITER)
|
// IO (JUPITER)
|
||||||
|
@ -1829,12 +1901,15 @@ bool Mickey::parse(int cmd, int arg) {
|
||||||
_game.nItems--;
|
_game.nItems--;
|
||||||
_game.iRmObj[_game.iRoom]++;
|
_game.iRmObj[_game.iRoom]++;
|
||||||
_game.iRmMenu[_game.iRoom] = 0;
|
_game.iRmMenu[_game.iRoom] = 0;
|
||||||
|
|
||||||
drawRoom();
|
drawRoom();
|
||||||
|
|
||||||
if (_game.nRocks) {
|
if (_game.nRocks) {
|
||||||
printDatMessage(37);
|
printDatMessage(37);
|
||||||
} else {
|
} else {
|
||||||
printDatMessage(arg);
|
printDatMessage(arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
_game.nRocks++;
|
_game.nRocks++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1844,11 +1919,15 @@ bool Mickey::parse(int cmd, int arg) {
|
||||||
if (_game.fItem[IDI_MSA_ITEM_FLASHLIGHT]) {
|
if (_game.fItem[IDI_MSA_ITEM_FLASHLIGHT]) {
|
||||||
_game.iRmMenu[_game.iRoom] = 1;
|
_game.iRmMenu[_game.iRoom] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
printDatMessage(arg);
|
printDatMessage(arg);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case IDI_MSA_ACTION_USE_FLASHLIGHT:
|
case IDI_MSA_ACTION_USE_FLASHLIGHT:
|
||||||
_game.iRoom = IDI_MSA_PIC_MARS_TUBE_1;
|
_game.iRoom = IDI_MSA_PIC_MARS_TUBE_1;
|
||||||
|
|
||||||
printDatMessage(15);
|
printDatMessage(15);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
case IDI_MSA_ACTION_PLUTO_DIG:
|
case IDI_MSA_ACTION_PLUTO_DIG:
|
||||||
if (_game.fHasXtal) {
|
if (_game.fHasXtal) {
|
||||||
|
@ -1869,6 +1948,7 @@ bool Mickey::parse(int cmd, int arg) {
|
||||||
|
|
||||||
case IDI_MSA_ACTION_ENTER_TEMPLE:
|
case IDI_MSA_ACTION_ENTER_TEMPLE:
|
||||||
_game.iRoom = IDI_MSA_PIC_URANUS_TEMPLE;
|
_game.iRoom = IDI_MSA_PIC_URANUS_TEMPLE;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
case IDI_MSA_ACTION_USE_CRYSTAL:
|
case IDI_MSA_ACTION_USE_CRYSTAL:
|
||||||
if (_game.iRmMenu[_game.iRoom]) {
|
if (_game.iRmMenu[_game.iRoom]) {
|
||||||
|
@ -1876,8 +1956,11 @@ bool Mickey::parse(int cmd, int arg) {
|
||||||
} else {
|
} else {
|
||||||
_game.iRmMenu[_game.iRoom] = 1;
|
_game.iRmMenu[_game.iRoom] = 1;
|
||||||
_game.iRmPic[_game.iRoom] = IDI_MSA_PIC_URANUS_TEMPLE_1;
|
_game.iRmPic[_game.iRoom] = IDI_MSA_PIC_URANUS_TEMPLE_1;
|
||||||
|
|
||||||
drawRoom();
|
drawRoom();
|
||||||
|
|
||||||
_game.iRmPic[_game.iRoom] = IDI_MSA_PIC_URANUS_TEMPLE;
|
_game.iRmPic[_game.iRoom] = IDI_MSA_PIC_URANUS_TEMPLE;
|
||||||
|
|
||||||
printDatMessage(arg);
|
printDatMessage(arg);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1887,13 +1970,16 @@ bool Mickey::parse(int cmd, int arg) {
|
||||||
} else {
|
} else {
|
||||||
_game.fTempleDoorOpen = 1;
|
_game.fTempleDoorOpen = 1;
|
||||||
_game.iRmPic[_game.iRoom] = IDI_MSA_PIC_URANUS_TEMPLE_2;
|
_game.iRmPic[_game.iRoom] = IDI_MSA_PIC_URANUS_TEMPLE_2;
|
||||||
|
|
||||||
drawRoom();
|
drawRoom();
|
||||||
|
|
||||||
printDatMessage(arg);
|
printDatMessage(arg);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case IDI_MSA_ACTION_ENTER_DOOR:
|
case IDI_MSA_ACTION_ENTER_DOOR:
|
||||||
if (_game.fTempleDoorOpen) {
|
if (_game.fTempleDoorOpen) {
|
||||||
_game.iRoom = IDI_MSA_PIC_URANUS_STEPS;
|
_game.iRoom = IDI_MSA_PIC_URANUS_STEPS;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
printDatMessage(arg);
|
printDatMessage(arg);
|
||||||
|
@ -1911,7 +1997,9 @@ bool Mickey::parse(int cmd, int arg) {
|
||||||
break;
|
break;
|
||||||
case IDI_MSA_ACTION_USE_CROWBAR_1:
|
case IDI_MSA_ACTION_USE_CROWBAR_1:
|
||||||
_game.iRmMenu[_game.iRoom] = 0;
|
_game.iRmMenu[_game.iRoom] = 0;
|
||||||
|
|
||||||
getXtal(arg);
|
getXtal(arg);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// SPACESHIP
|
// SPACESHIP
|
||||||
|
@ -1935,11 +2023,14 @@ bool Mickey::parse(int cmd, int arg) {
|
||||||
if ((_game.iPlanet == _game.iPlanetXtal[_game.nXtals]) || (_game.iPlanet == IDI_MSA_PLANET_EARTH)) {
|
if ((_game.iPlanet == _game.iPlanetXtal[_game.nXtals]) || (_game.iPlanet == IDI_MSA_PLANET_EARTH)) {
|
||||||
_game.fHasXtal = false;
|
_game.fHasXtal = false;
|
||||||
_game.iRoom = IDI_MSA_HOME_PLANET[_game.iPlanet];
|
_game.iRoom = IDI_MSA_HOME_PLANET[_game.iPlanet];
|
||||||
|
|
||||||
if (_game.iPlanet != IDI_MSA_PLANET_EARTH)
|
if (_game.iPlanet != IDI_MSA_PLANET_EARTH)
|
||||||
insertDisk(1);
|
insertDisk(1);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
_game.iRoom = IDI_MSA_SHIP_PLANET[_game.iPlanet];
|
_game.iRoom = IDI_MSA_SHIP_PLANET[_game.iPlanet];
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1953,13 +2044,17 @@ bool Mickey::parse(int cmd, int arg) {
|
||||||
} else {
|
} else {
|
||||||
_game.fShipDoorOpen = false;
|
_game.fShipDoorOpen = false;
|
||||||
_game.iRmPic[_game.iRoom]--;
|
_game.iRmPic[_game.iRoom]--;
|
||||||
|
|
||||||
drawRoom();
|
drawRoom();
|
||||||
|
|
||||||
printDatMessage(2);
|
printDatMessage(2);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
_game.fShipDoorOpen = true;
|
_game.fShipDoorOpen = true;
|
||||||
_game.iRmPic[_game.iRoom]++;
|
_game.iRmPic[_game.iRoom]++;
|
||||||
|
|
||||||
drawRoom();
|
drawRoom();
|
||||||
|
|
||||||
printDatMessage(14);
|
printDatMessage(14);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1969,7 +2064,9 @@ bool Mickey::parse(int cmd, int arg) {
|
||||||
_game.fSuit = false;
|
_game.fSuit = false;
|
||||||
_game.iRmMenu[_game.iRoom] = 0;
|
_game.iRmMenu[_game.iRoom] = 0;
|
||||||
_game.iRmPic[_game.iRoom] -= 2;
|
_game.iRmPic[_game.iRoom] -= 2;
|
||||||
|
|
||||||
drawRoom();
|
drawRoom();
|
||||||
|
|
||||||
printDatMessage(13);
|
printDatMessage(13);
|
||||||
} else {
|
} else {
|
||||||
printDatMessage(3);
|
printDatMessage(3);
|
||||||
|
@ -1979,7 +2076,9 @@ bool Mickey::parse(int cmd, int arg) {
|
||||||
_game.fSuit = true;
|
_game.fSuit = true;
|
||||||
_game.iRmMenu[_game.iRoom] = 1;
|
_game.iRmMenu[_game.iRoom] = 1;
|
||||||
_game.iRmPic[_game.iRoom] += 2;
|
_game.iRmPic[_game.iRoom] += 2;
|
||||||
|
|
||||||
drawRoom();
|
drawRoom();
|
||||||
|
|
||||||
printDatMessage(arg);
|
printDatMessage(arg);
|
||||||
} else {
|
} else {
|
||||||
printDatMessage(12);
|
printDatMessage(12);
|
||||||
|
@ -1988,11 +2087,11 @@ bool Mickey::parse(int cmd, int arg) {
|
||||||
break;
|
break;
|
||||||
case IDI_MSA_ACTION_READ_GAUGE:
|
case IDI_MSA_ACTION_READ_GAUGE:
|
||||||
printDatString(arg);
|
printDatString(arg);
|
||||||
_vm->drawStr(21, 15, IDA_DEFAULT,
|
_vm->drawStr(21, 15, IDA_DEFAULT, (const char *)IDS_MSA_TEMP_C[_game.iPlanet]);
|
||||||
(const char *)IDS_MSA_TEMP_C[_game.iPlanet]);
|
_vm->drawStr(21, 23, IDA_DEFAULT, (const char *)IDS_MSA_TEMP_F[_game.iPlanet]);
|
||||||
_vm->drawStr(21, 23, IDA_DEFAULT,
|
|
||||||
(const char *)IDS_MSA_TEMP_F[_game.iPlanet]);
|
|
||||||
waitAnyKey();
|
waitAnyKey();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case IDI_MSA_ACTION_PRESS_ORANGE:
|
case IDI_MSA_ACTION_PRESS_ORANGE:
|
||||||
if (_game.fFlying) {
|
if (_game.fFlying) {
|
||||||
|
@ -2019,12 +2118,18 @@ bool Mickey::parse(int cmd, int arg) {
|
||||||
if (_game.fFlying) {
|
if (_game.fFlying) {
|
||||||
_game.fFlying = false;
|
_game.fFlying = false;
|
||||||
_game.nButtons = 0;
|
_game.nButtons = 0;
|
||||||
|
|
||||||
memset(_game.szAddr, 0, sizeof(_game.szAddr));
|
memset(_game.szAddr, 0, sizeof(_game.szAddr));
|
||||||
|
|
||||||
drawRoom();
|
drawRoom();
|
||||||
|
|
||||||
printDatString(22);
|
printDatString(22);
|
||||||
|
|
||||||
_vm->drawStr(IDI_MSA_ROW_PLANET, IDI_MSA_COL_PLANET, IDA_DEFAULT,
|
_vm->drawStr(IDI_MSA_ROW_PLANET, IDI_MSA_COL_PLANET, IDA_DEFAULT,
|
||||||
(const char *)IDS_MSA_PLANETS[_game.iPlanet]);
|
(const char *)IDS_MSA_PLANETS[_game.iPlanet]);
|
||||||
|
|
||||||
waitAnyKey(true);
|
waitAnyKey(true);
|
||||||
|
|
||||||
showPlanetInfo();
|
showPlanetInfo();
|
||||||
} else {
|
} else {
|
||||||
printDatMessage(arg);
|
printDatMessage(arg);
|
||||||
|
@ -2037,11 +2142,15 @@ bool Mickey::parse(int cmd, int arg) {
|
||||||
if (getPlanet() != -1) {
|
if (getPlanet() != -1) {
|
||||||
_game.fFlying = true;
|
_game.fFlying = true;
|
||||||
_game.iPlanet = getPlanet();
|
_game.iPlanet = getPlanet();
|
||||||
|
|
||||||
drawRoom();
|
drawRoom();
|
||||||
|
|
||||||
printDatMessage(16);
|
printDatMessage(16);
|
||||||
} else {
|
} else {
|
||||||
_game.nButtons = 0;
|
_game.nButtons = 0;
|
||||||
|
|
||||||
memset(_game.szAddr, 0, sizeof(_game.szAddr));
|
memset(_game.szAddr, 0, sizeof(_game.szAddr));
|
||||||
|
|
||||||
printDatMessage(17);
|
printDatMessage(17);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2060,23 +2169,32 @@ bool Mickey::parse(int cmd, int arg) {
|
||||||
} else {
|
} else {
|
||||||
_game.iRmMenu[_game.iRoom] = 1;
|
_game.iRmMenu[_game.iRoom] = 1;
|
||||||
_game.iRmPic[_game.iRoom] = IDI_MSA_PIC_SHIP_KITCHEN_1;
|
_game.iRmPic[_game.iRoom] = IDI_MSA_PIC_SHIP_KITCHEN_1;
|
||||||
|
|
||||||
drawRoom();
|
drawRoom();
|
||||||
|
|
||||||
printDatMessage(arg);
|
printDatMessage(arg);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case IDI_MSA_ACTION_READ_MAP:
|
case IDI_MSA_ACTION_READ_MAP:
|
||||||
_game.iRmPic[_game.iRoom] = IDI_MSA_PIC_STAR_MAP;
|
_game.iRmPic[_game.iRoom] = IDI_MSA_PIC_STAR_MAP;
|
||||||
|
|
||||||
drawRoom();
|
drawRoom();
|
||||||
|
|
||||||
printDatMessage(46);
|
printDatMessage(46);
|
||||||
printDatMessage(47);
|
printDatMessage(47);
|
||||||
printDatMessage(48);
|
printDatMessage(48);
|
||||||
|
|
||||||
_game.iRmPic[_game.iRoom] = IDI_MSA_PIC_SHIP_BEDROOM;
|
_game.iRmPic[_game.iRoom] = IDI_MSA_PIC_SHIP_BEDROOM;
|
||||||
|
|
||||||
drawRoom();
|
drawRoom();
|
||||||
break;
|
break;
|
||||||
case IDI_MSA_ACTION_GO_WEST:
|
case IDI_MSA_ACTION_GO_WEST:
|
||||||
_game.nButtons = 0;
|
_game.nButtons = 0;
|
||||||
|
|
||||||
memset(_game.szAddr, 0, sizeof(_game.szAddr));
|
memset(_game.szAddr, 0, sizeof(_game.szAddr));
|
||||||
|
|
||||||
_game.iRoom = arg;
|
_game.iRoom = arg;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -80,7 +80,9 @@ bool Troll::getMenuSel(const char *szMenu, int *iSel, int nSel) {
|
||||||
case Common::KEYCODE_t:
|
case Common::KEYCODE_t:
|
||||||
case Common::KEYCODE_f:
|
case Common::KEYCODE_f:
|
||||||
inventory();
|
inventory();
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case Common::KEYCODE_DOWN:
|
case Common::KEYCODE_DOWN:
|
||||||
case Common::KEYCODE_SPACE:
|
case Common::KEYCODE_SPACE:
|
||||||
|
@ -282,6 +284,7 @@ void Troll::tutorial() {
|
||||||
done = false;
|
done = false;
|
||||||
while (!done && !_vm->shouldQuit()) {
|
while (!done && !_vm->shouldQuit()) {
|
||||||
getMenuSel(IDS_TRO_TUTORIAL_1, &iSel, IDI_TRO_MAX_OPTION);
|
getMenuSel(IDS_TRO_TUTORIAL_1, &iSel, IDI_TRO_MAX_OPTION);
|
||||||
|
|
||||||
switch(iSel) {
|
switch(iSel) {
|
||||||
case IDI_TRO_SEL_OPTION_1:
|
case IDI_TRO_SEL_OPTION_1:
|
||||||
_vm->clearScreen(0x22, false);
|
_vm->clearScreen(0x22, false);
|
||||||
|
@ -410,6 +413,7 @@ void Troll::gameOver() {
|
||||||
_vm->drawStr(21, 1, kColorDefault, szMoves);
|
_vm->drawStr(21, 1, kColorDefault, szMoves);
|
||||||
_vm->drawStr(22, 1, kColorDefault, IDS_TRO_GAMEOVER_1);
|
_vm->drawStr(22, 1, kColorDefault, IDS_TRO_GAMEOVER_1);
|
||||||
_vm->_gfx->doUpdate();
|
_vm->_gfx->doUpdate();
|
||||||
|
|
||||||
pressAnyKey();
|
pressAnyKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -474,12 +478,6 @@ void Troll::playTune(int tune, int len) {
|
||||||
if (!_soundOn)
|
if (!_soundOn)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
warning("STUB: playTune(%d, %d)", tune, len);
|
|
||||||
|
|
||||||
// TODO:
|
|
||||||
//
|
|
||||||
// apparently sound format consist of 16bit LE pairs of frequency and duration
|
|
||||||
|
|
||||||
int freq, duration;
|
int freq, duration;
|
||||||
int ptr = _tunes[tune - 1];
|
int ptr = _tunes[tune - 1];
|
||||||
|
|
||||||
|
|
|
@ -150,9 +150,11 @@ void Winnie::randomize() {
|
||||||
|
|
||||||
for (int i = 0; i < IDI_WTP_MAX_OBJ_MISSING; i++) {
|
for (int i = 0; i < IDI_WTP_MAX_OBJ_MISSING; i++) {
|
||||||
done = false;
|
done = false;
|
||||||
|
|
||||||
while (!done) {
|
while (!done) {
|
||||||
iObj = _vm->rnd(IDI_WTP_MAX_OBJ - 1);
|
iObj = _vm->rnd(IDI_WTP_MAX_OBJ - 1);
|
||||||
done = true;
|
done = true;
|
||||||
|
|
||||||
for (int j = 0; j < IDI_WTP_MAX_OBJ_MISSING; j++) {
|
for (int j = 0; j < IDI_WTP_MAX_OBJ_MISSING; j++) {
|
||||||
if (_game.iUsedObj[j] == iObj) {
|
if (_game.iUsedObj[j] == iObj) {
|
||||||
done = false;
|
done = false;
|
||||||
|
@ -167,6 +169,7 @@ void Winnie::randomize() {
|
||||||
while (!done) {
|
while (!done) {
|
||||||
iRoom = _vm->rnd(IDI_WTP_MAX_ROOM_NORMAL);
|
iRoom = _vm->rnd(IDI_WTP_MAX_ROOM_NORMAL);
|
||||||
done = true;
|
done = true;
|
||||||
|
|
||||||
for (int j = 0; j < IDI_WTP_MAX_ROOM_OBJ; j++) {
|
for (int j = 0; j < IDI_WTP_MAX_ROOM_OBJ; j++) {
|
||||||
if (_game.iObjRoom[j] == iRoom) {
|
if (_game.iObjRoom[j] == iRoom) {
|
||||||
done = false;
|
done = false;
|
||||||
|
@ -185,17 +188,23 @@ void Winnie::intro() {
|
||||||
_vm->_gfx->doUpdate();
|
_vm->_gfx->doUpdate();
|
||||||
_vm->_system->updateScreen();
|
_vm->_system->updateScreen();
|
||||||
_vm->_system->delayMillis(0x640);
|
_vm->_system->delayMillis(0x640);
|
||||||
|
|
||||||
if (_vm->getPlatform() == Common::kPlatformAmiga)
|
if (_vm->getPlatform() == Common::kPlatformAmiga)
|
||||||
_vm->_gfx->clearScreen(0);
|
_vm->_gfx->clearScreen(0);
|
||||||
|
|
||||||
drawPic(IDS_WTP_FILE_TITLE);
|
drawPic(IDS_WTP_FILE_TITLE);
|
||||||
|
|
||||||
_vm->printStr(IDS_WTP_INTRO_1);
|
_vm->printStr(IDS_WTP_INTRO_1);
|
||||||
_vm->_gfx->doUpdate();
|
_vm->_gfx->doUpdate();
|
||||||
_vm->_system->updateScreen();
|
_vm->_system->updateScreen();
|
||||||
_vm->_system->delayMillis(0x640);
|
_vm->_system->delayMillis(0x640);
|
||||||
|
|
||||||
if (!playSound(IDI_WTP_SND_POOH_0))
|
if (!playSound(IDI_WTP_SND_POOH_0))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!playSound(IDI_WTP_SND_POOH_1))
|
if (!playSound(IDI_WTP_SND_POOH_1))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!playSound(IDI_WTP_SND_POOH_2))
|
if (!playSound(IDI_WTP_SND_POOH_2))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -346,6 +355,7 @@ int Winnie::parser(int pc, int index, uint8 *buffer) {
|
||||||
case IDI_WTP_SEL_EAST:
|
case IDI_WTP_SEL_EAST:
|
||||||
case IDI_WTP_SEL_WEST:
|
case IDI_WTP_SEL_WEST:
|
||||||
iDir = iSel - IDI_WTP_SEL_NORTH;
|
iDir = iSel - IDI_WTP_SEL_NORTH;
|
||||||
|
|
||||||
if (hdr.roomNew[iDir] == IDI_WTP_ROOM_NONE) {
|
if (hdr.roomNew[iDir] == IDI_WTP_ROOM_NONE) {
|
||||||
_vm->printStr(IDS_WTP_CANT_GO);
|
_vm->printStr(IDS_WTP_CANT_GO);
|
||||||
_vm->getSelection(kSelAnyKey);
|
_vm->getSelection(kSelAnyKey);
|
||||||
|
@ -517,6 +527,7 @@ void Winnie::takeObj(int iRoom) {
|
||||||
} else {
|
} else {
|
||||||
// take object
|
// take object
|
||||||
int iObj = getObjInRoom(iRoom);
|
int iObj = getObjInRoom(iRoom);
|
||||||
|
|
||||||
_game.iObjHave = iObj;
|
_game.iObjHave = iObj;
|
||||||
_game.iObjRoom[iObj] = 0;
|
_game.iObjRoom[iObj] = 0;
|
||||||
|
|
||||||
|
@ -590,8 +601,10 @@ void Winnie::dropObj(int iRoom) {
|
||||||
// object has been dropped in the wrong place
|
// object has been dropped in the wrong place
|
||||||
_vm->printStr(IDS_WTP_WRONG_PLACE);
|
_vm->printStr(IDS_WTP_WRONG_PLACE);
|
||||||
_vm->getSelection(kSelAnyKey);
|
_vm->getSelection(kSelAnyKey);
|
||||||
|
|
||||||
playSound(IDI_WTP_SND_DROP);
|
playSound(IDI_WTP_SND_DROP);
|
||||||
drawRoomPic();
|
drawRoomPic();
|
||||||
|
|
||||||
_vm->printStr(IDS_WTP_WRONG_PLACE);
|
_vm->printStr(IDS_WTP_WRONG_PLACE);
|
||||||
_vm->getSelection(kSelAnyKey);
|
_vm->getSelection(kSelAnyKey);
|
||||||
|
|
||||||
|
@ -639,6 +652,7 @@ void Winnie::wind() {
|
||||||
_vm->printStr(IDS_WTP_WIND_0);
|
_vm->printStr(IDS_WTP_WIND_0);
|
||||||
playSound(IDI_WTP_SND_WIND_0);
|
playSound(IDI_WTP_SND_WIND_0);
|
||||||
_vm->getSelection(kSelAnyKey);
|
_vm->getSelection(kSelAnyKey);
|
||||||
|
|
||||||
_vm->printStr(IDS_WTP_WIND_1);
|
_vm->printStr(IDS_WTP_WIND_1);
|
||||||
playSound(IDI_WTP_SND_WIND_0);
|
playSound(IDI_WTP_SND_WIND_0);
|
||||||
_vm->getSelection(kSelAnyKey);
|
_vm->getSelection(kSelAnyKey);
|
||||||
|
@ -652,6 +666,7 @@ void Winnie::wind() {
|
||||||
while (!done) {
|
while (!done) {
|
||||||
iRoom = _vm->rnd(IDI_WTP_MAX_ROOM_NORMAL);
|
iRoom = _vm->rnd(IDI_WTP_MAX_ROOM_NORMAL);
|
||||||
done = true;
|
done = true;
|
||||||
|
|
||||||
for (int j = 0; j < IDI_WTP_MAX_ROOM_OBJ; j++) {
|
for (int j = 0; j < IDI_WTP_MAX_ROOM_OBJ; j++) {
|
||||||
if (_game.iObjRoom[j] == iRoom) {
|
if (_game.iObjRoom[j] == iRoom) {
|
||||||
done = false;
|
done = false;
|
||||||
|
@ -1006,11 +1021,13 @@ phase0:
|
||||||
drawRoomPic();
|
drawRoomPic();
|
||||||
_vm->_gfx->doUpdate();
|
_vm->_gfx->doUpdate();
|
||||||
_vm->_system->updateScreen();
|
_vm->_system->updateScreen();
|
||||||
|
|
||||||
phase1:
|
phase1:
|
||||||
if (getObjInRoom(_room)) {
|
if (getObjInRoom(_room)) {
|
||||||
printObjStr(getObjInRoom(_room), IDI_WTP_OBJ_DESC);
|
printObjStr(getObjInRoom(_room), IDI_WTP_OBJ_DESC);
|
||||||
_vm->getSelection(kSelAnyKey);
|
_vm->getSelection(kSelAnyKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
phase2:
|
phase2:
|
||||||
for (iBlock = 0; iBlock < IDI_WTP_MAX_BLOCK; iBlock++) {
|
for (iBlock = 0; iBlock < IDI_WTP_MAX_BLOCK; iBlock++) {
|
||||||
if (parser(hdr.ofsDesc[iBlock] - _roomOffset, iBlock, roomdata) == IDI_WTP_PAR_BACK)
|
if (parser(hdr.ofsDesc[iBlock] - _roomOffset, iBlock, roomdata) == IDI_WTP_PAR_BACK)
|
||||||
|
@ -1047,6 +1064,7 @@ void Winnie::drawPic(const char *szName) {
|
||||||
warning ("Could not open file \'%s\'", szFile);
|
warning ("Could not open file \'%s\'", szFile);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 size = file.size();
|
uint32 size = file.size();
|
||||||
file.read(buffer, size);
|
file.read(buffer, size);
|
||||||
file.close();
|
file.close();
|
||||||
|
|
|
@ -176,7 +176,7 @@ bool AgiEngine::predictiveDialog(void) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* clear key queue */
|
// clear key queue
|
||||||
while (_gfx->keypress())
|
while (_gfx->keypress())
|
||||||
_gfx->getKey();
|
_gfx->getKey();
|
||||||
|
|
||||||
|
@ -234,7 +234,7 @@ bool AgiEngine::predictiveDialog(void) {
|
||||||
_gfx->doUpdate();
|
_gfx->doUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
_gfx->pollTimer(); /* msdos driver -> does nothing */
|
_gfx->pollTimer(); // msdos driver -> does nothing
|
||||||
key = doPollKeyboard();
|
key = doPollKeyboard();
|
||||||
processkey = false;
|
processkey = false;
|
||||||
switch (key) {
|
switch (key) {
|
||||||
|
@ -274,7 +274,7 @@ bool AgiEngine::predictiveDialog(void) {
|
||||||
active = 14;
|
active = 14;
|
||||||
processkey = true;
|
processkey = true;
|
||||||
break;
|
break;
|
||||||
case 0x09: /* Tab */
|
case 0x09: // Tab
|
||||||
navigationwithkeys = true;
|
navigationwithkeys = true;
|
||||||
debugC(3, kDebugLevelText, "Focus change");
|
debugC(3, kDebugLevelText, "Focus change");
|
||||||
lastactive = active = lastactive + 1;
|
lastactive = active = lastactive + 1;
|
||||||
|
|
|
@ -23,10 +23,10 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
//
|
||||||
* Savegame support by Vasyl Tsvirkunov <vasyl@pacbell.net>
|
// Savegame support by Vasyl Tsvirkunov <vasyl@pacbell.net>
|
||||||
* Multi-slots by Claudio Matsuoka <claudio@helllabs.org>
|
// Multi-slots by Claudio Matsuoka <claudio@helllabs.org>
|
||||||
*/
|
//
|
||||||
|
|
||||||
#include <time.h> // for extended infos
|
#include <time.h> // for extended infos
|
||||||
|
|
||||||
|
@ -41,13 +41,13 @@
|
||||||
|
|
||||||
#define SAVEGAME_VERSION 4
|
#define SAVEGAME_VERSION 4
|
||||||
|
|
||||||
/*
|
//
|
||||||
* Version 0 (Sarien): view table has 64 entries
|
// Version 0 (Sarien): view table has 64 entries
|
||||||
* Version 1 (Sarien): view table has 256 entries (needed in KQ3)
|
// Version 1 (Sarien): view table has 256 entries (needed in KQ3)
|
||||||
* Version 2 (ScummVM): first ScummVM version
|
// Version 2 (ScummVM): first ScummVM version
|
||||||
* Version 3 (ScummVM): added AGIPAL save/load support
|
// Version 3 (ScummVM): added AGIPAL save/load support
|
||||||
* Version 4 (ScummVM): added thumbnails and save creation date/time
|
// Version 4 (ScummVM): added thumbnails and save creation date/time
|
||||||
*/
|
//
|
||||||
|
|
||||||
namespace Agi {
|
namespace Agi {
|
||||||
|
|
||||||
|
@ -128,20 +128,20 @@ int AgiEngine::saveGame(const char *fileName, const char *description) {
|
||||||
out->writeSint16BE((int16)_game.colorFg);
|
out->writeSint16BE((int16)_game.colorFg);
|
||||||
out->writeSint16BE((int16)_game.colorBg);
|
out->writeSint16BE((int16)_game.colorBg);
|
||||||
|
|
||||||
/* game.hires */
|
// game.hires
|
||||||
/* game.sbuf */
|
// game.sbuf
|
||||||
/* game.ego_words */
|
// game.ego_words
|
||||||
/* game.num_ego_words */
|
// game.num_ego_words
|
||||||
|
|
||||||
out->writeSint16BE((int16)_game.numObjects);
|
out->writeSint16BE((int16)_game.numObjects);
|
||||||
for (i = 0; i < (int16)_game.numObjects; i++)
|
for (i = 0; i < (int16)_game.numObjects; i++)
|
||||||
out->writeSint16BE((int16)objectGetLocation(i));
|
out->writeSint16BE((int16)objectGetLocation(i));
|
||||||
|
|
||||||
/* game.ev_keyp */
|
// game.ev_keyp
|
||||||
for (i = 0; i < MAX_STRINGS; i++)
|
for (i = 0; i < MAX_STRINGS; i++)
|
||||||
out->write(_game.strings[i], MAX_STRINGLEN);
|
out->write(_game.strings[i], MAX_STRINGLEN);
|
||||||
|
|
||||||
/* record info about loaded resources */
|
// record info about loaded resources
|
||||||
for (i = 0; i < MAX_DIRS; i++) {
|
for (i = 0; i < MAX_DIRS; i++) {
|
||||||
out->writeByte(_game.dirLogic[i].flags);
|
out->writeByte(_game.dirLogic[i].flags);
|
||||||
out->writeSint16BE((int16)_game.logics[i].sIP);
|
out->writeSint16BE((int16)_game.logics[i].sIP);
|
||||||
|
@ -154,10 +154,10 @@ int AgiEngine::saveGame(const char *fileName, const char *description) {
|
||||||
for (i = 0; i < MAX_DIRS; i++)
|
for (i = 0; i < MAX_DIRS; i++)
|
||||||
out->writeByte(_game.dirSound[i].flags);
|
out->writeByte(_game.dirSound[i].flags);
|
||||||
|
|
||||||
/* game.pictures */
|
// game.pictures
|
||||||
/* game.logics */
|
// game.logics
|
||||||
/* game.views */
|
// game.views
|
||||||
/* game.sounds */
|
// game.sounds
|
||||||
|
|
||||||
for (i = 0; i < MAX_VIEWTABLE; i++) {
|
for (i = 0; i < MAX_VIEWTABLE; i++) {
|
||||||
VtEntry *v = &_game.viewTable[i];
|
VtEntry *v = &_game.viewTable[i];
|
||||||
|
@ -169,23 +169,23 @@ int AgiEngine::saveGame(const char *fileName, const char *description) {
|
||||||
out->writeSint16BE(v->yPos);
|
out->writeSint16BE(v->yPos);
|
||||||
out->writeByte(v->currentView);
|
out->writeByte(v->currentView);
|
||||||
|
|
||||||
/* v->view_data */
|
// v->view_data
|
||||||
|
|
||||||
out->writeByte(v->currentLoop);
|
out->writeByte(v->currentLoop);
|
||||||
out->writeByte(v->numLoops);
|
out->writeByte(v->numLoops);
|
||||||
|
|
||||||
/* v->loop_data */
|
// v->loop_data
|
||||||
|
|
||||||
out->writeByte(v->currentCel);
|
out->writeByte(v->currentCel);
|
||||||
out->writeByte(v->numCels);
|
out->writeByte(v->numCels);
|
||||||
|
|
||||||
/* v->cel_data */
|
// v->cel_data
|
||||||
/* v->cel_data_2 */
|
// v->cel_data_2
|
||||||
|
|
||||||
out->writeSint16BE(v->xPos2);
|
out->writeSint16BE(v->xPos2);
|
||||||
out->writeSint16BE(v->yPos2);
|
out->writeSint16BE(v->yPos2);
|
||||||
|
|
||||||
/* v->s */
|
// v->s
|
||||||
|
|
||||||
out->writeSint16BE(v->xSize);
|
out->writeSint16BE(v->xSize);
|
||||||
out->writeSint16BE(v->ySize);
|
out->writeSint16BE(v->ySize);
|
||||||
|
@ -206,7 +206,7 @@ int AgiEngine::saveGame(const char *fileName, const char *description) {
|
||||||
out->writeByte(v->parm4);
|
out->writeByte(v->parm4);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Save image stack */
|
// Save image stack
|
||||||
|
|
||||||
for (i = 0; i < _imageStack.size(); i++) {
|
for (i = 0; i < _imageStack.size(); i++) {
|
||||||
ImageStackElement ise = _imageStack[i];
|
ImageStackElement ise = _imageStack[i];
|
||||||
|
@ -311,7 +311,7 @@ int AgiEngine::loadGame(const char *fileName, bool checkId) {
|
||||||
_game.lineUserInput = in->readSint16BE();
|
_game.lineUserInput = in->readSint16BE();
|
||||||
_game.lineMinPrint = in->readSint16BE();
|
_game.lineMinPrint = in->readSint16BE();
|
||||||
|
|
||||||
/* These are never saved */
|
// These are never saved
|
||||||
_game.cursorPos = 0;
|
_game.cursorPos = 0;
|
||||||
_game.inputBuffer[0] = 0;
|
_game.inputBuffer[0] = 0;
|
||||||
_game.echoBuffer[0] = 0;
|
_game.echoBuffer[0] = 0;
|
||||||
|
@ -339,25 +339,25 @@ int AgiEngine::loadGame(const char *fileName, bool checkId) {
|
||||||
|
|
||||||
_game.msgBoxTicks = 0;
|
_game.msgBoxTicks = 0;
|
||||||
_game.block.active = false;
|
_game.block.active = false;
|
||||||
/* game.window - fixed by close_window() */
|
// game.window - fixed by close_window()
|
||||||
/* game.has_window - fixed by close_window() */
|
// game.has_window - fixed by close_window()
|
||||||
|
|
||||||
_game.gfxMode = in->readSint16BE();
|
_game.gfxMode = in->readSint16BE();
|
||||||
_game.cursorChar = in->readByte();
|
_game.cursorChar = in->readByte();
|
||||||
_game.colorFg = in->readSint16BE();
|
_game.colorFg = in->readSint16BE();
|
||||||
_game.colorBg = in->readSint16BE();
|
_game.colorBg = in->readSint16BE();
|
||||||
|
|
||||||
/* game.hires - rebuilt from image stack */
|
// game.hires - rebuilt from image stack
|
||||||
/* game.sbuf - rebuilt from image stack */
|
// game.sbuf - rebuilt from image stack
|
||||||
|
|
||||||
/* game.ego_words - fixed by clean_input */
|
// game.ego_words - fixed by clean_input
|
||||||
/* game.num_ego_words - fixed by clean_input */
|
// game.num_ego_words - fixed by clean_input
|
||||||
|
|
||||||
_game.numObjects = in->readSint16BE();
|
_game.numObjects = in->readSint16BE();
|
||||||
for (i = 0; i < (int16)_game.numObjects; i++)
|
for (i = 0; i < (int16)_game.numObjects; i++)
|
||||||
objectSetLocation(i, in->readSint16BE());
|
objectSetLocation(i, in->readSint16BE());
|
||||||
|
|
||||||
/* Those are not serialized */
|
// Those are not serialized
|
||||||
for (i = 0; i < MAX_DIRS; i++) {
|
for (i = 0; i < MAX_DIRS; i++) {
|
||||||
_game.evKeyp[i].occured = false;
|
_game.evKeyp[i].occured = false;
|
||||||
}
|
}
|
||||||
|
@ -395,10 +395,10 @@ int AgiEngine::loadGame(const char *fileName, bool checkId) {
|
||||||
agiUnloadResource(rSOUND, i);
|
agiUnloadResource(rSOUND, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* game.pictures - loaded above */
|
// game.pictures - loaded above
|
||||||
/* game.logics - loaded above */
|
// game.logics - loaded above
|
||||||
/* game.views - loaded above */
|
// game.views - loaded above
|
||||||
/* game.sounds - loaded above */
|
// game.sounds - loaded above
|
||||||
|
|
||||||
for (i = 0; i < vtEntries; i++) {
|
for (i = 0; i < vtEntries; i++) {
|
||||||
VtEntry *v = &_game.viewTable[i];
|
VtEntry *v = &_game.viewTable[i];
|
||||||
|
@ -410,23 +410,23 @@ int AgiEngine::loadGame(const char *fileName, bool checkId) {
|
||||||
v->yPos = in->readSint16BE();
|
v->yPos = in->readSint16BE();
|
||||||
v->currentView = in->readByte();
|
v->currentView = in->readByte();
|
||||||
|
|
||||||
/* v->view_data - fixed below */
|
// v->view_data - fixed below
|
||||||
|
|
||||||
v->currentLoop = in->readByte();
|
v->currentLoop = in->readByte();
|
||||||
v->numLoops = in->readByte();
|
v->numLoops = in->readByte();
|
||||||
|
|
||||||
/* v->loop_data - fixed below */
|
// v->loop_data - fixed below
|
||||||
|
|
||||||
v->currentCel = in->readByte();
|
v->currentCel = in->readByte();
|
||||||
v->numCels = in->readByte();
|
v->numCels = in->readByte();
|
||||||
|
|
||||||
/* v->cel_data - fixed below */
|
// v->cel_data - fixed below
|
||||||
/* v->cel_data_2 - fixed below */
|
// v->cel_data_2 - fixed below
|
||||||
|
|
||||||
v->xPos2 = in->readSint16BE();
|
v->xPos2 = in->readSint16BE();
|
||||||
v->yPos2 = in->readSint16BE();
|
v->yPos2 = in->readSint16BE();
|
||||||
|
|
||||||
/* v->s - fixed below */
|
// v->s - fixed below
|
||||||
|
|
||||||
v->xSize = in->readSint16BE();
|
v->xSize = in->readSint16BE();
|
||||||
v->ySize = in->readSint16BE();
|
v->ySize = in->readSint16BE();
|
||||||
|
@ -450,7 +450,7 @@ int AgiEngine::loadGame(const char *fileName, bool checkId) {
|
||||||
memset(&_game.viewTable[i], 0, sizeof(VtEntry));
|
memset(&_game.viewTable[i], 0, sizeof(VtEntry));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fix some pointers in viewtable */
|
// Fix some pointers in viewtable
|
||||||
|
|
||||||
for (i = 0; i < MAX_VIEWTABLE; i++) {
|
for (i = 0; i < MAX_VIEWTABLE; i++) {
|
||||||
VtEntry *v = &_game.viewTable[i];
|
VtEntry *v = &_game.viewTable[i];
|
||||||
|
@ -461,20 +461,20 @@ int AgiEngine::loadGame(const char *fileName, bool checkId) {
|
||||||
if (!(_game.dirView[v->currentView].flags & RES_LOADED))
|
if (!(_game.dirView[v->currentView].flags & RES_LOADED))
|
||||||
agiLoadResource(rVIEW, v->currentView);
|
agiLoadResource(rVIEW, v->currentView);
|
||||||
|
|
||||||
setView(v, v->currentView); /* Fix v->view_data */
|
setView(v, v->currentView); // Fix v->view_data
|
||||||
setLoop(v, v->currentLoop); /* Fix v->loop_data */
|
setLoop(v, v->currentLoop); // Fix v->loop_data
|
||||||
setCel(v, v->currentCel); /* Fix v->cel_data */
|
setCel(v, v->currentCel); // Fix v->cel_data
|
||||||
v->celData2 = v->celData;
|
v->celData2 = v->celData;
|
||||||
v->s = NULL; /* not sure if it is used... */
|
v->s = NULL; // not sure if it is used...
|
||||||
}
|
}
|
||||||
|
|
||||||
_sprites->eraseBoth();
|
_sprites->eraseBoth();
|
||||||
|
|
||||||
/* Clear input line */
|
// Clear input line
|
||||||
_gfx->clearScreen(0);
|
_gfx->clearScreen(0);
|
||||||
writeStatus();
|
writeStatus();
|
||||||
|
|
||||||
/* Recreate background from saved image stack */
|
// Recreate background from saved image stack
|
||||||
clearImageStack();
|
clearImageStack();
|
||||||
while ((t = in->readByte()) != 0) {
|
while ((t = in->readByte()) != 0) {
|
||||||
for (i = 0; i < 7; i++)
|
for (i = 0; i < 7; i++)
|
||||||
|
@ -492,7 +492,7 @@ int AgiEngine::loadGame(const char *fileName, bool checkId) {
|
||||||
|
|
||||||
setflag(fRestoreJustRan, true);
|
setflag(fRestoreJustRan, true);
|
||||||
|
|
||||||
_game.hasPrompt = 0; /* force input line repaint if necessary */
|
_game.hasPrompt = 0; // force input line repaint if necessary
|
||||||
cleanInput();
|
cleanInput();
|
||||||
|
|
||||||
_sprites->eraseBoth();
|
_sprites->eraseBoth();
|
||||||
|
@ -524,13 +524,16 @@ void AgiEngine::getSavegameDescription(int num, char *buf, bool showEmpty) {
|
||||||
sprintf(fileName, "%s", getSavegameFilename(num));
|
sprintf(fileName, "%s", getSavegameFilename(num));
|
||||||
if (!(in = _saveFileMan->openForLoading(fileName))) {
|
if (!(in = _saveFileMan->openForLoading(fileName))) {
|
||||||
debugC(4, kDebugLevelMain | kDebugLevelSavegame, "File %s does not exist", fileName);
|
debugC(4, kDebugLevelMain | kDebugLevelSavegame, "File %s does not exist", fileName);
|
||||||
|
|
||||||
if (showEmpty)
|
if (showEmpty)
|
||||||
strcpy(buf, " (empty slot)");
|
strcpy(buf, " (empty slot)");
|
||||||
else
|
else
|
||||||
*buf = 0;
|
*buf = 0;
|
||||||
} else {
|
} else {
|
||||||
debugC(4, kDebugLevelMain | kDebugLevelSavegame, "Successfully opened %s for reading", fileName);
|
debugC(4, kDebugLevelMain | kDebugLevelSavegame, "Successfully opened %s for reading", fileName);
|
||||||
|
|
||||||
uint32 type = in->readUint32BE();
|
uint32 type = in->readUint32BE();
|
||||||
|
|
||||||
if (type == AGIflag) {
|
if (type == AGIflag) {
|
||||||
debugC(6, kDebugLevelMain | kDebugLevelSavegame, "Has AGI flag, good start");
|
debugC(6, kDebugLevelMain | kDebugLevelSavegame, "Has AGI flag, good start");
|
||||||
in->read(buf, 31);
|
in->read(buf, 31);
|
||||||
|
@ -546,7 +549,7 @@ void AgiEngine::getSavegameDescription(int num, char *buf, bool showEmpty) {
|
||||||
int AgiEngine::selectSlot() {
|
int AgiEngine::selectSlot() {
|
||||||
int i, key, active = 0;
|
int i, key, active = 0;
|
||||||
int rc = -1;
|
int rc = -1;
|
||||||
int hm = 1, vm = 3; /* box margins */
|
int hm = 1, vm = 3; // box margins
|
||||||
int xmin, xmax, slotClicked;
|
int xmin, xmax, slotClicked;
|
||||||
char desc[NUM_VISIBLE_SLOTS][40];
|
char desc[NUM_VISIBLE_SLOTS][40];
|
||||||
int textCentre, buttonLength, buttonX[2], buttonY;
|
int textCentre, buttonLength, buttonX[2], buttonY;
|
||||||
|
@ -613,7 +616,7 @@ int AgiEngine::selectSlot() {
|
||||||
oldFirstSlot = _firstSlot;
|
oldFirstSlot = _firstSlot;
|
||||||
}
|
}
|
||||||
|
|
||||||
_gfx->pollTimer(); /* msdos driver -> does nothing */
|
_gfx->pollTimer(); // msdos driver -> does nothing
|
||||||
key = doPollKeyboard();
|
key = doPollKeyboard();
|
||||||
|
|
||||||
// It may happen that somebody will open GMM while
|
// It may happen that somebody will open GMM while
|
||||||
|
@ -840,7 +843,7 @@ int AgiEngine::saveGameSimple() {
|
||||||
int AgiEngine::loadGameDialog() {
|
int AgiEngine::loadGameDialog() {
|
||||||
char fileName[MAX_PATH];
|
char fileName[MAX_PATH];
|
||||||
int rc, slot = 0;
|
int rc, slot = 0;
|
||||||
int hm, vm, hp, vp; /* box margins */
|
int hm, vm, hp, vp; // box margins
|
||||||
int w;
|
int w;
|
||||||
|
|
||||||
hm = 1;
|
hm = 1;
|
||||||
|
|
|
@ -37,8 +37,9 @@ namespace Agi {
|
||||||
#define USE_INTERPOLATION
|
#define USE_INTERPOLATION
|
||||||
static bool g_useChorus = true;
|
static bool g_useChorus = true;
|
||||||
|
|
||||||
/* TODO: add support for variable sampling rate in the output device
|
//
|
||||||
*/
|
// TODO: add support for variable sampling rate in the output device
|
||||||
|
//
|
||||||
|
|
||||||
AgiSound *AgiSound::createFromRawResource(uint8 *data, uint32 len, int resnum, SoundMgr &manager) {
|
AgiSound *AgiSound::createFromRawResource(uint8 *data, uint32 len, int resnum, SoundMgr &manager) {
|
||||||
if (data == NULL || len < 2) // Check for too small resource or no resource at all
|
if (data == NULL || len < 2) // Check for too small resource or no resource at all
|
||||||
|
@ -83,6 +84,7 @@ PCjrSound::PCjrSound(uint8 *data, uint32 len, int resnum, SoundMgr &manager) : A
|
||||||
const uint8 *PCjrSound::getVoicePointer(uint voiceNum) {
|
const uint8 *PCjrSound::getVoicePointer(uint voiceNum) {
|
||||||
assert(voiceNum < 4);
|
assert(voiceNum < 4);
|
||||||
uint16 voiceStartOffset = READ_LE_UINT16(_data + voiceNum * 2);
|
uint16 voiceStartOffset = READ_LE_UINT16(_data + voiceNum * 2);
|
||||||
|
|
||||||
return _data + voiceStartOffset;
|
return _data + voiceStartOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,11 +101,13 @@ IIgsSample::IIgsSample(uint8 *data, uint32 len, int resnum, SoundMgr &manager) :
|
||||||
// of sample data although header says it should have 16384 bytes.
|
// of sample data although header says it should have 16384 bytes.
|
||||||
warning("Apple IIGS sample (%d) too short (%d bytes. Should be %d bytes). Using the part that's left",
|
warning("Apple IIGS sample (%d) too short (%d bytes. Should be %d bytes). Using the part that's left",
|
||||||
resnum, tailLen, _header.sampleSize);
|
resnum, tailLen, _header.sampleSize);
|
||||||
|
|
||||||
_header.sampleSize = (uint16) tailLen; // Use the part that's left
|
_header.sampleSize = (uint16) tailLen; // Use the part that's left
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_header.pitch > 0x7F) { // Check if the pitch is invalid
|
if (_header.pitch > 0x7F) { // Check if the pitch is invalid
|
||||||
warning("Apple IIGS sample (%d) has too high pitch (0x%02x)", resnum, _header.pitch);
|
warning("Apple IIGS sample (%d) has too high pitch (0x%02x)", resnum, _header.pitch);
|
||||||
|
|
||||||
_header.pitch &= 0x7F; // Apple IIGS AGI probably did it this way too
|
_header.pitch &= 0x7F; // Apple IIGS AGI probably did it this way too
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,6 +117,7 @@ IIgsSample::IIgsSample(uint8 *data, uint32 len, int resnum, SoundMgr &manager) :
|
||||||
// Convert sample data from 8-bit unsigned to 8-bit signed format
|
// Convert sample data from 8-bit unsigned to 8-bit signed format
|
||||||
stream.seek(sampleStartPos);
|
stream.seek(sampleStartPos);
|
||||||
_sample = new int8[_header.sampleSize];
|
_sample = new int8[_header.sampleSize];
|
||||||
|
|
||||||
if (_sample != NULL)
|
if (_sample != NULL)
|
||||||
_isValid = SoundMgr::convertWave(stream, _sample, _header.sampleSize);
|
_isValid = SoundMgr::convertWave(stream, _sample, _header.sampleSize);
|
||||||
}
|
}
|
||||||
|
@ -127,6 +132,7 @@ bool IIgsEnvelope::read(Common::SeekableReadStream &stream) {
|
||||||
seg[segNum].bp = stream.readByte();
|
seg[segNum].bp = stream.readByte();
|
||||||
seg[segNum].inc = stream.readUint16LE();
|
seg[segNum].inc = stream.readUint16LE();
|
||||||
}
|
}
|
||||||
|
|
||||||
return !stream.ioFailed();
|
return !stream.ioFailed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,6 +176,7 @@ bool IIgsWaveInfo::finalize(Common::SeekableReadStream &uint8Wave) {
|
||||||
size = trueSize; // Set the true sample size
|
size = trueSize; // Set the true sample size
|
||||||
|
|
||||||
uint8Wave.seek(startPos); // Seek back to the stream's starting position
|
uint8Wave.seek(startPos); // Seek back to the stream's starting position
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,6 +184,7 @@ bool IIgsOscillator::finalize(Common::SeekableReadStream &uint8Wave) {
|
||||||
for (uint i = 0; i < WAVES_PER_OSCILLATOR; i++)
|
for (uint i = 0; i < WAVES_PER_OSCILLATOR; i++)
|
||||||
if (!waves[i].finalize(uint8Wave))
|
if (!waves[i].finalize(uint8Wave))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,6 +196,7 @@ bool IIgsOscillatorList::read(Common::SeekableReadStream &stream, uint oscillato
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
count = oscillatorCount; // Set the oscillator count
|
count = oscillatorCount; // Set the oscillator count
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,6 +204,7 @@ bool IIgsOscillatorList::finalize(Common::SeekableReadStream &uint8Wave) {
|
||||||
for (uint i = 0; i < count; i++)
|
for (uint i = 0; i < count; i++)
|
||||||
if (!osc[i].finalize(uint8Wave))
|
if (!osc[i].finalize(uint8Wave))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -225,6 +235,7 @@ bool IIgsSampleHeader::read(Common::SeekableReadStream &stream) {
|
||||||
instrumentSize = stream.readUint16LE();
|
instrumentSize = stream.readUint16LE();
|
||||||
sampleSize = stream.readUint16LE();
|
sampleSize = stream.readUint16LE();
|
||||||
// Read the instrument header *ignoring* its wave address info
|
// Read the instrument header *ignoring* its wave address info
|
||||||
|
|
||||||
return instrument.read(stream, true);
|
return instrument.read(stream, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -287,7 +298,7 @@ static const int16 waveformRamp[WAVEFORM_SIZE] = {
|
||||||
0, -248, -240, -232, -224, -216, -208, -200,
|
0, -248, -240, -232, -224, -216, -208, -200,
|
||||||
-192, -184, -176, -168, -160, -152, -144, -136,
|
-192, -184, -176, -168, -160, -152, -144, -136,
|
||||||
-128, -120, -112, -104, -96, -88, -80, -72,
|
-128, -120, -112, -104, -96, -88, -80, -72,
|
||||||
-64, -56, -48, -40, -32, -24, -16, -8 /* Ramp up */
|
-64, -56, -48, -40, -32, -24, -16, -8 // Ramp up
|
||||||
};
|
};
|
||||||
|
|
||||||
static const int16 waveformSquare[WAVEFORM_SIZE] = {
|
static const int16 waveformSquare[WAVEFORM_SIZE] = {
|
||||||
|
@ -298,7 +309,7 @@ static const int16 waveformSquare[WAVEFORM_SIZE] = {
|
||||||
-255, -230, -220, -220, -220, -220, -220, -220,
|
-255, -230, -220, -220, -220, -220, -220, -220,
|
||||||
-220, -220, -220, -220, -220, -220, -220, -220,
|
-220, -220, -220, -220, -220, -220, -220, -220,
|
||||||
-220, -220, -220, -220, -220, -220, -220, -220,
|
-220, -220, -220, -220, -220, -220, -220, -220,
|
||||||
-220, -220, -220, -110, 0, 0, 0, 0 /* Square */
|
-220, -220, -220, -110, 0, 0, 0, 0 // Square
|
||||||
};
|
};
|
||||||
|
|
||||||
static const int16 waveformMac[WAVEFORM_SIZE] = {
|
static const int16 waveformMac[WAVEFORM_SIZE] = {
|
||||||
|
@ -369,14 +380,17 @@ void SoundMgr::startSound(int resnum, int flag) {
|
||||||
break;
|
break;
|
||||||
case AGI_SOUND_4CHN:
|
case AGI_SOUND_4CHN:
|
||||||
PCjrSound *pcjrSound = (PCjrSound *) _vm->_game.sounds[resnum];
|
PCjrSound *pcjrSound = (PCjrSound *) _vm->_game.sounds[resnum];
|
||||||
/* Initialize channel info */
|
|
||||||
|
// Initialize channel info
|
||||||
for (i = 0; i < NUM_CHANNELS; i++) {
|
for (i = 0; i < NUM_CHANNELS; i++) {
|
||||||
_chn[i].type = type;
|
_chn[i].type = type;
|
||||||
_chn[i].flags = AGI_SOUND_LOOP;
|
_chn[i].flags = AGI_SOUND_LOOP;
|
||||||
|
|
||||||
if (_env) {
|
if (_env) {
|
||||||
_chn[i].flags |= AGI_SOUND_ENVELOPE;
|
_chn[i].flags |= AGI_SOUND_ENVELOPE;
|
||||||
_chn[i].adsr = AGI_SOUND_ENV_ATTACK;
|
_chn[i].adsr = AGI_SOUND_ENV_ATTACK;
|
||||||
}
|
}
|
||||||
|
|
||||||
_chn[i].ins = _waveform;
|
_chn[i].ins = _waveform;
|
||||||
_chn[i].size = WAVEFORM_SIZE;
|
_chn[i].size = WAVEFORM_SIZE;
|
||||||
_chn[i].ptr = pcjrSound->getVoicePointer(i % 4);
|
_chn[i].ptr = pcjrSound->getVoicePointer(i % 4);
|
||||||
|
@ -390,8 +404,7 @@ void SoundMgr::startSound(int resnum, int flag) {
|
||||||
memset(_sndBuffer, 0, BUFFER_SIZE << 1);
|
memset(_sndBuffer, 0, BUFFER_SIZE << 1);
|
||||||
_endflag = flag;
|
_endflag = flag;
|
||||||
|
|
||||||
/* Nat Budin reports that the flag should be reset when sound starts
|
// Nat Budin reports that the flag should be reset when sound starts
|
||||||
*/
|
|
||||||
_vm->setflag(_endflag, false);
|
_vm->setflag(_endflag, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -424,9 +437,11 @@ void IIgsSoundMgr::stopSounds() {
|
||||||
bool IIgsSoundMgr::playSampleSound(const IIgsSampleHeader &sampleHeader, const int8 *sample) {
|
bool IIgsSoundMgr::playSampleSound(const IIgsSampleHeader &sampleHeader, const int8 *sample) {
|
||||||
stopSounds();
|
stopSounds();
|
||||||
IIgsMidiChannel &channel = _midiChannels[kSfxMidiChannel];
|
IIgsMidiChannel &channel = _midiChannels[kSfxMidiChannel];
|
||||||
|
|
||||||
channel.setInstrument(&sampleHeader.instrument, sample);
|
channel.setInstrument(&sampleHeader.instrument, sample);
|
||||||
channel.setVolume(sampleHeader.volume);
|
channel.setVolume(sampleHeader.volume);
|
||||||
channel.noteOn(sampleHeader.pitch, 64); // Use default velocity (i.e. 64)
|
channel.noteOn(sampleHeader.pitch, 64); // Use default velocity (i.e. 64)
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -434,6 +449,7 @@ void IIgsMidiChannel::stopSounds() {
|
||||||
// Stops all sounds on this single MIDI channel
|
// Stops all sounds on this single MIDI channel
|
||||||
for (iterator iter = _gsChannels.begin(); iter != _gsChannels.end(); iter++)
|
for (iterator iter = _gsChannels.begin(); iter != _gsChannels.end(); iter++)
|
||||||
iter->stop();
|
iter->stop();
|
||||||
|
|
||||||
_gsChannels.clear();
|
_gsChannels.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -476,6 +492,7 @@ int SoundMgr::initSound() {
|
||||||
|
|
||||||
void SoundMgr::deinitSound() {
|
void SoundMgr::deinitSound() {
|
||||||
debugC(3, kDebugLevelSound, "()");
|
debugC(3, kDebugLevelSound, "()");
|
||||||
|
|
||||||
_mixer->stopHandle(_soundHandle);
|
_mixer->stopHandle(_soundHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -483,7 +500,7 @@ void SoundMgr::stopNote(int i) {
|
||||||
_chn[i].adsr = AGI_SOUND_ENV_RELEASE;
|
_chn[i].adsr = AGI_SOUND_ENV_RELEASE;
|
||||||
|
|
||||||
if (g_useChorus) {
|
if (g_useChorus) {
|
||||||
/* Stop chorus ;) */
|
// Stop chorus ;)
|
||||||
if (_chn[i].type == AGI_SOUND_4CHN &&
|
if (_chn[i].type == AGI_SOUND_4CHN &&
|
||||||
_vm->_soundemu == SOUND_EMU_NONE && i < 3) {
|
_vm->_soundemu == SOUND_EMU_NONE && i < 3) {
|
||||||
stopNote(i + 4);
|
stopNote(i + 4);
|
||||||
|
@ -504,12 +521,15 @@ void SoundMgr::playNote(int i, int freq, int vol) {
|
||||||
_chn[i].adsr = AGI_SOUND_ENV_ATTACK;
|
_chn[i].adsr = AGI_SOUND_ENV_ATTACK;
|
||||||
|
|
||||||
if (g_useChorus) {
|
if (g_useChorus) {
|
||||||
/* Add chorus ;) */
|
// Add chorus ;)
|
||||||
if (_chn[i].type == AGI_SOUND_4CHN &&
|
if (_chn[i].type == AGI_SOUND_4CHN &&
|
||||||
_vm->_soundemu == SOUND_EMU_NONE && i < 3) {
|
_vm->_soundemu == SOUND_EMU_NONE && i < 3) {
|
||||||
|
|
||||||
int newfreq = freq * 1007 / 1000;
|
int newfreq = freq * 1007 / 1000;
|
||||||
|
|
||||||
if (freq == newfreq)
|
if (freq == newfreq)
|
||||||
newfreq++;
|
newfreq++;
|
||||||
|
|
||||||
playNote(i + 4, newfreq, vol * 2 / 3);
|
playNote(i + 4, newfreq, vol * 2 / 3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -526,6 +546,7 @@ void SoundMgr::playMidiSound() {
|
||||||
if (_playingSound == -1 || _vm->_game.sounds[_playingSound] == NULL) {
|
if (_playingSound == -1 || _vm->_game.sounds[_playingSound] == NULL) {
|
||||||
warning("Error playing Apple IIGS MIDI sound resource");
|
warning("Error playing Apple IIGS MIDI sound resource");
|
||||||
_playing = false;
|
_playing = false;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -543,11 +564,14 @@ void SoundMgr::playMidiSound() {
|
||||||
if (readByte == MIDI_BYTE_STOP_SEQUENCE) {
|
if (readByte == MIDI_BYTE_STOP_SEQUENCE) {
|
||||||
debugC(3, kDebugLevelSound, "End of MIDI sequence (Before reading delta-time)");
|
debugC(3, kDebugLevelSound, "End of MIDI sequence (Before reading delta-time)");
|
||||||
_playing = false;
|
_playing = false;
|
||||||
|
|
||||||
midiObj->rewind();
|
midiObj->rewind();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
} else if (readByte == MIDI_BYTE_TIMER_SYNC) {
|
} else if (readByte == MIDI_BYTE_TIMER_SYNC) {
|
||||||
debugC(3, kDebugLevelSound, "Timer sync");
|
debugC(3, kDebugLevelSound, "Timer sync");
|
||||||
p++; // Jump over the timer sync byte as it's not needed
|
p++; // Jump over the timer sync byte as it's not needed
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -562,7 +586,9 @@ void SoundMgr::playMidiSound() {
|
||||||
if (*p == MIDI_BYTE_STOP_SEQUENCE) {
|
if (*p == MIDI_BYTE_STOP_SEQUENCE) {
|
||||||
debugC(3, kDebugLevelSound, "End of MIDI sequence (After reading delta-time)");
|
debugC(3, kDebugLevelSound, "End of MIDI sequence (After reading delta-time)");
|
||||||
_playing = false;
|
_playing = false;
|
||||||
|
|
||||||
midiObj->rewind();
|
midiObj->rewind();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -597,6 +623,7 @@ void SoundMgr::playMidiSound() {
|
||||||
case MIDI_CMD_PITCH_WHEEL:
|
case MIDI_CMD_PITCH_WHEEL:
|
||||||
parm1 = *p++;
|
parm1 = *p++;
|
||||||
parm2 = *p++;
|
parm2 = *p++;
|
||||||
|
|
||||||
uint16 wheelPos = ((parm2 & 0x7F) << 7) | (parm1 & 0x7F); // 14-bit value
|
uint16 wheelPos = ((parm2 & 0x7F) << 7) | (parm1 & 0x7F); // 14-bit value
|
||||||
_gsSound.midiPitchWheel(wheelPos);
|
_gsSound.midiPitchWheel(wheelPos);
|
||||||
break;
|
break;
|
||||||
|
@ -675,22 +702,27 @@ void IIgsMidiChannel::removeStoppedSounds() {
|
||||||
|
|
||||||
uint IIgsSoundMgr::activeSounds() const {
|
uint IIgsSoundMgr::activeSounds() const {
|
||||||
uint result = 0;
|
uint result = 0;
|
||||||
|
|
||||||
for (Common::Array<IIgsMidiChannel>::const_iterator iter = _midiChannels.begin(); iter != _midiChannels.end(); iter++)
|
for (Common::Array<IIgsMidiChannel>::const_iterator iter = _midiChannels.begin(); iter != _midiChannels.end(); iter++)
|
||||||
result += iter->activeSounds();
|
result += iter->activeSounds();
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint IIgsMidiChannel::activeSounds() const {
|
uint IIgsMidiChannel::activeSounds() const {
|
||||||
uint result = 0;
|
uint result = 0;
|
||||||
|
|
||||||
for (const_iterator iter = _gsChannels.begin(); iter != _gsChannels.end(); iter++)
|
for (const_iterator iter = _gsChannels.begin(); iter != _gsChannels.end(); iter++)
|
||||||
if (!iter->end)
|
if (!iter->end)
|
||||||
result++;
|
result++;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IIgsMidiChannel::setInstrument(const IIgsInstrumentHeader *instrument, const int8 *sample) {
|
void IIgsMidiChannel::setInstrument(const IIgsInstrumentHeader *instrument, const int8 *sample) {
|
||||||
_instrument = instrument;
|
_instrument = instrument;
|
||||||
_sample = sample;
|
_sample = sample;
|
||||||
|
|
||||||
// Set program on each Apple IIGS channel playing on this MIDI channel
|
// Set program on each Apple IIGS channel playing on this MIDI channel
|
||||||
for (iterator iter = _gsChannels.begin(); iter != _gsChannels.end(); iter++)
|
for (iterator iter = _gsChannels.begin(); iter != _gsChannels.end(); iter++)
|
||||||
iter->setInstrument(instrument, sample);
|
iter->setInstrument(instrument, sample);
|
||||||
|
@ -698,6 +730,7 @@ void IIgsMidiChannel::setInstrument(const IIgsInstrumentHeader *instrument, cons
|
||||||
|
|
||||||
void IIgsMidiChannel::setVolume(uint8 volume) {
|
void IIgsMidiChannel::setVolume(uint8 volume) {
|
||||||
_volume = volume;
|
_volume = volume;
|
||||||
|
|
||||||
// Set volume on each Apple IIGS channel playing on this MIDI channel
|
// Set volume on each Apple IIGS channel playing on this MIDI channel
|
||||||
for (iterator iter = _gsChannels.begin(); iter != _gsChannels.end(); iter++)
|
for (iterator iter = _gsChannels.begin(); iter != _gsChannels.end(); iter++)
|
||||||
iter->setChannelVolume(volume);
|
iter->setChannelVolume(volume);
|
||||||
|
@ -713,9 +746,11 @@ void IIgsMidiChannel::noteOff(uint8 note, uint8 velocity) {
|
||||||
|
|
||||||
void IIgsMidiChannel::noteOn(uint8 note, uint8 velocity) {
|
void IIgsMidiChannel::noteOn(uint8 note, uint8 velocity) {
|
||||||
IIgsChannelInfo channel;
|
IIgsChannelInfo channel;
|
||||||
|
|
||||||
// Use the default channel volume and instrument
|
// Use the default channel volume and instrument
|
||||||
channel.setChannelVolume(_volume);
|
channel.setChannelVolume(_volume);
|
||||||
channel.setInstrument(_instrument, _sample);
|
channel.setInstrument(_instrument, _sample);
|
||||||
|
|
||||||
// Set the note on and save the channel
|
// Set the note on and save the channel
|
||||||
channel.noteOn(note, velocity);
|
channel.noteOn(note, velocity);
|
||||||
_gsChannels.push_back(channel);
|
_gsChannels.push_back(channel);
|
||||||
|
@ -742,11 +777,15 @@ void IIgsChannelInfo::noteOn(uint8 noteParam, uint8 velocity) {
|
||||||
this->origNote = noteParam;
|
this->origNote = noteParam;
|
||||||
this->startEnvVol = intToFrac(0);
|
this->startEnvVol = intToFrac(0);
|
||||||
rewind();
|
rewind();
|
||||||
|
|
||||||
const IIgsWaveInfo *waveInfo = NULL;
|
const IIgsWaveInfo *waveInfo = NULL;
|
||||||
|
|
||||||
for (uint i = 0; i < ins->oscList.count; i++)
|
for (uint i = 0; i < ins->oscList.count; i++)
|
||||||
if (ins->oscList(i).waves[0].top >= noteParam)
|
if (ins->oscList(i).waves[0].top >= noteParam)
|
||||||
waveInfo = &ins->oscList(i).waves[0];
|
waveInfo = &ins->oscList(i).waves[0];
|
||||||
|
|
||||||
assert(waveInfo != NULL);
|
assert(waveInfo != NULL);
|
||||||
|
|
||||||
this->relocatedSample = this->unrelocatedSample + waveInfo->addr;
|
this->relocatedSample = this->unrelocatedSample + waveInfo->addr;
|
||||||
this->posAdd = intToFrac(0);
|
this->posAdd = intToFrac(0);
|
||||||
this->note = intToFrac(noteParam) + doubleToFrac(waveInfo->relPitch/256.0);
|
this->note = intToFrac(noteParam) + doubleToFrac(waveInfo->relPitch/256.0);
|
||||||
|
@ -808,7 +847,7 @@ void SoundMgr::playAgiSound() {
|
||||||
_chn[i].env = 0;
|
_chn[i].env = 0;
|
||||||
|
|
||||||
if (g_useChorus) {
|
if (g_useChorus) {
|
||||||
/* chorus */
|
// chorus
|
||||||
if (_chn[i].type == AGI_SOUND_4CHN && _vm->_soundemu == SOUND_EMU_NONE && i < 3) {
|
if (_chn[i].type == AGI_SOUND_4CHN && _vm->_soundemu == SOUND_EMU_NONE && i < 3) {
|
||||||
_chn[i + 4].vol = 0;
|
_chn[i + 4].vol = 0;
|
||||||
_chn[i + 4].env = 0;
|
_chn[i + 4].env = 0;
|
||||||
|
@ -929,7 +968,7 @@ uint32 SoundMgr::mixSound(void) {
|
||||||
}
|
}
|
||||||
_gsSound.removeStoppedSounds();
|
_gsSound.removeStoppedSounds();
|
||||||
return IIGS_BUFFER_SIZE;
|
return IIGS_BUFFER_SIZE;
|
||||||
} /* else ... */
|
} // else ...
|
||||||
|
|
||||||
// Handle PCjr 4-channel sound mixing here
|
// Handle PCjr 4-channel sound mixing here
|
||||||
for (c = 0; c < NUM_CHANNELS; c++) {
|
for (c = 0; c < NUM_CHANNELS; c++) {
|
||||||
|
@ -954,7 +993,7 @@ uint32 SoundMgr::mixSound(void) {
|
||||||
|
|
||||||
// FIXME: Fingolfin asks: why is there a FIXME here? Please either clarify what
|
// FIXME: Fingolfin asks: why is there a FIXME here? Please either clarify what
|
||||||
// needs fixing, or remove it!
|
// needs fixing, or remove it!
|
||||||
/* FIXME */
|
// FIXME
|
||||||
if (_chn[c].flags & AGI_SOUND_LOOP) {
|
if (_chn[c].flags & AGI_SOUND_LOOP) {
|
||||||
p %= _chn[c].size << 8;
|
p %= _chn[c].size << 8;
|
||||||
} else {
|
} else {
|
||||||
|
@ -968,7 +1007,7 @@ uint32 SoundMgr::mixSound(void) {
|
||||||
}
|
}
|
||||||
_chn[c].phase = p;
|
_chn[c].phase = p;
|
||||||
} else {
|
} else {
|
||||||
/* Add white noise */
|
// Add white noise
|
||||||
for (i = 0; i < BUFFER_SIZE; i++) {
|
for (i = 0; i < BUFFER_SIZE; i++) {
|
||||||
b = _vm->_rnd->getRandomNumber(255) - 128;
|
b = _vm->_rnd->getRandomNumber(255) - 128;
|
||||||
_sndBuffer[i] += (b * m) >> 4;
|
_sndBuffer[i] += (b * m) >> 4;
|
||||||
|
@ -977,7 +1016,7 @@ uint32 SoundMgr::mixSound(void) {
|
||||||
|
|
||||||
switch (_chn[c].adsr) {
|
switch (_chn[c].adsr) {
|
||||||
case AGI_SOUND_ENV_ATTACK:
|
case AGI_SOUND_ENV_ATTACK:
|
||||||
/* not implemented */
|
// not implemented
|
||||||
_chn[c].adsr = AGI_SOUND_ENV_DECAY;
|
_chn[c].adsr = AGI_SOUND_ENV_DECAY;
|
||||||
break;
|
break;
|
||||||
case AGI_SOUND_ENV_DECAY:
|
case AGI_SOUND_ENV_DECAY:
|
||||||
|
@ -1040,6 +1079,7 @@ bool IIgsSoundMgr::loadInstrumentHeaders(const Common::FSNode &exePath, const II
|
||||||
|
|
||||||
// Check instrument set's md5sum
|
// Check instrument set's md5sum
|
||||||
data->seek(exeInfo.instSetStart);
|
data->seek(exeInfo.instSetStart);
|
||||||
|
|
||||||
char md5str[32+1];
|
char md5str[32+1];
|
||||||
Common::md5_file_string(*data, md5str, exeInfo.instSet.byteCount);
|
Common::md5_file_string(*data, md5str, exeInfo.instSet.byteCount);
|
||||||
if (scumm_stricmp(md5str, exeInfo.instSet.md5)) {
|
if (scumm_stricmp(md5str, exeInfo.instSet.md5)) {
|
||||||
|
@ -1053,6 +1093,7 @@ bool IIgsSoundMgr::loadInstrumentHeaders(const Common::FSNode &exePath, const II
|
||||||
// Load the instruments
|
// Load the instruments
|
||||||
_instruments.clear();
|
_instruments.clear();
|
||||||
_instruments.reserve(exeInfo.instSet.instCount);
|
_instruments.reserve(exeInfo.instSet.instCount);
|
||||||
|
|
||||||
IIgsInstrumentHeader instrument;
|
IIgsInstrumentHeader instrument;
|
||||||
for (uint i = 0; i < exeInfo.instSet.instCount; i++) {
|
for (uint i = 0; i < exeInfo.instSet.instCount; i++) {
|
||||||
if (!instrument.read(*data)) {
|
if (!instrument.read(*data)) {
|
||||||
|
@ -1102,6 +1143,7 @@ bool IIgsSoundMgr::loadWaveFile(const Common::FSNode &wavePath, const IIgsExeInf
|
||||||
"Please report the information on the previous line to the ScummVM team.\n" \
|
"Please report the information on the previous line to the ScummVM team.\n" \
|
||||||
"Using the wave file as it is - music may sound weird", md5str, exeInfo.exePrefix);
|
"Using the wave file as it is - music may sound weird", md5str, exeInfo.exePrefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8Wave->seek(0); // Seek wave to its start
|
uint8Wave->seek(0); // Seek wave to its start
|
||||||
// Convert the wave file from 8-bit unsigned to 8-bit signed and save the result
|
// Convert the wave file from 8-bit unsigned to 8-bit signed and save the result
|
||||||
_wave.resize(uint8Wave->size());
|
_wave.resize(uint8Wave->size());
|
||||||
|
|
|
@ -50,15 +50,14 @@ struct Sprite {
|
||||||
#undef ALLOC_DEBUG
|
#undef ALLOC_DEBUG
|
||||||
|
|
||||||
|
|
||||||
#define POOL_SIZE 68000 /* Gold Rush mine room needs > 50000 */
|
#define POOL_SIZE 68000 // Gold Rush mine room needs > 50000
|
||||||
/* Speeder bike challenge needs > 67000 */
|
// Speeder bike challenge needs > 67000
|
||||||
|
|
||||||
void *SpritesMgr::poolAlloc(int size) {
|
void *SpritesMgr::poolAlloc(int size) {
|
||||||
uint8 *x;
|
uint8 *x;
|
||||||
|
|
||||||
/* Adjust size to 32-bit boundary to prevent data misalignment
|
// Adjust size to 32-bit boundary to prevent data misalignment
|
||||||
* errors.
|
// errors.
|
||||||
*/
|
|
||||||
size = (size + 3) & ~3;
|
size = (size + 3) & ~3;
|
||||||
|
|
||||||
x = _poolTop;
|
x = _poolTop;
|
||||||
|
@ -73,9 +72,8 @@ void *SpritesMgr::poolAlloc(int size) {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Note: it's critical that pool_release() is called in the exact
|
// Note: it's critical that pool_release() is called in the exact
|
||||||
reverse order of pool_alloc()
|
// reverse order of pool_alloc()
|
||||||
*/
|
|
||||||
void SpritesMgr::poolRelease(void *s) {
|
void SpritesMgr::poolRelease(void *s) {
|
||||||
_poolTop = (uint8 *)s;
|
_poolTop = (uint8 *)s;
|
||||||
}
|
}
|
||||||
|
@ -84,27 +82,25 @@ void SpritesMgr::poolRelease(void *s) {
|
||||||
* Blitter functions
|
* Blitter functions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Blit one pixel considering the priorities */
|
// Blit one pixel considering the priorities
|
||||||
|
|
||||||
void SpritesMgr::blitPixel(uint8 *p, uint8 *end, uint8 col, int spr, int width, int *hidden) {
|
void SpritesMgr::blitPixel(uint8 *p, uint8 *end, uint8 col, int spr, int width, int *hidden) {
|
||||||
int epr = 0, pr = 0; /* effective and real priorities */
|
int epr = 0, pr = 0; // effective and real priorities
|
||||||
|
|
||||||
/* CM: priority 15 overrides control lines and is ignored when
|
// CM: priority 15 overrides control lines and is ignored when
|
||||||
* tracking effective priority. This tweak is needed to fix
|
// tracking effective priority. This tweak is needed to fix
|
||||||
* Sarien bug #451768, and should not affect Sierra games because
|
// Sarien bug #451768, and should not affect Sierra games because
|
||||||
* sprites shouldn't have priority 15 (like the AGI Mouse
|
// sprites shouldn't have priority 15 (like the AGI Mouse
|
||||||
* demo "mouse pointer")
|
// demo "mouse pointer")
|
||||||
*
|
//
|
||||||
* Update: this solution breaks other games, and can't be used.
|
// Update: this solution breaks other games, and can't be used.
|
||||||
*/
|
|
||||||
|
|
||||||
if (p >= end)
|
if (p >= end)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Check if we're on a control line */
|
// Check if we're on a control line
|
||||||
if ((pr = *p & 0xf0) < 0x30) {
|
if ((pr = *p & 0xf0) < 0x30) {
|
||||||
uint8 *p1;
|
uint8 *p1;
|
||||||
/* Yes, get effective priority going down */
|
// Yes, get effective priority going down
|
||||||
for (p1 = p; p1 < end && (epr = *p1 & 0xf0) < 0x30; p1 += width)
|
for (p1 = p; p1 < end && (epr = *p1 & 0xf0) < 0x30; p1 += width)
|
||||||
;
|
;
|
||||||
if (p1 >= end)
|
if (p1 >= end)
|
||||||
|
@ -114,9 +110,8 @@ void SpritesMgr::blitPixel(uint8 *p, uint8 *end, uint8 col, int spr, int width,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (spr >= epr) {
|
if (spr >= epr) {
|
||||||
/* Keep control line information visible, but put our
|
// Keep control line information visible, but put our
|
||||||
* priority over water (0x30) surface
|
// priority over water (0x30) surface
|
||||||
*/
|
|
||||||
if (_vm->getFeatures() & (GF_AGI256 | GF_AGI256_2))
|
if (_vm->getFeatures() & (GF_AGI256 | GF_AGI256_2))
|
||||||
*(p + FROM_SBUF16_TO_SBUF256_OFFSET) = col; // Write to 256 color buffer
|
*(p + FROM_SBUF16_TO_SBUF256_OFFSET) = col; // Write to 256 color buffer
|
||||||
else
|
else
|
||||||
|
@ -124,14 +119,13 @@ void SpritesMgr::blitPixel(uint8 *p, uint8 *end, uint8 col, int spr, int width,
|
||||||
|
|
||||||
*hidden = false;
|
*hidden = false;
|
||||||
|
|
||||||
/* Except if our priority is 15, which should never happen
|
// Except if our priority is 15, which should never happen
|
||||||
* (fixes Sarien bug #451768)
|
// (fixes Sarien bug #451768)
|
||||||
*
|
//
|
||||||
* Update: breaks other games, can't be used
|
// Update: breaks other games, can't be used
|
||||||
*
|
//
|
||||||
* if (spr == 0xf0)
|
// if (spr == 0xf0)
|
||||||
* *p = spr | col;
|
// *p = spr | col;
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,7 +135,7 @@ int SpritesMgr::blitCel(int x, int y, int spr, ViewCel *c, bool agi256_2) {
|
||||||
int i, j, t, m, col;
|
int i, j, t, m, col;
|
||||||
int hidden = true;
|
int hidden = true;
|
||||||
|
|
||||||
/* Fixes Sarien bug #477841 (crash in PQ1 map C4 when y == -2) */
|
// Fixes Sarien bug #477841 (crash in PQ1 map C4 when y == -2)
|
||||||
if (y < 0)
|
if (y < 0)
|
||||||
y = 0;
|
y = 0;
|
||||||
if (x < 0)
|
if (x < 0)
|
||||||
|
@ -253,7 +247,7 @@ void SpritesMgr::objsRestoreArea(Sprite *s) {
|
||||||
* Condition to determine whether a sprite will be in the 'updating' list.
|
* Condition to determine whether a sprite will be in the 'updating' list.
|
||||||
*/
|
*/
|
||||||
bool SpritesMgr::testUpdating(VtEntry *v, AgiEngine *agi) {
|
bool SpritesMgr::testUpdating(VtEntry *v, AgiEngine *agi) {
|
||||||
/* Sanity check (see Sarien bug #779302) */
|
// Sanity check (see Sarien bug #779302)
|
||||||
if (~agi->_game.dirView[v->currentView].flags & RES_LOADED)
|
if (~agi->_game.dirView[v->currentView].flags & RES_LOADED)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -264,7 +258,7 @@ bool SpritesMgr::testUpdating(VtEntry *v, AgiEngine *agi) {
|
||||||
* Condition to determine whether a sprite will be in the 'non-updating' list.
|
* Condition to determine whether a sprite will be in the 'non-updating' list.
|
||||||
*/
|
*/
|
||||||
bool SpritesMgr::testNotUpdating(VtEntry *v, AgiEngine *vm) {
|
bool SpritesMgr::testNotUpdating(VtEntry *v, AgiEngine *vm) {
|
||||||
/* Sanity check (see Sarien bug #779302) */
|
// Sanity check (see Sarien bug #779302)
|
||||||
if (~vm->_game.dirView[v->currentView].flags & RES_LOADED)
|
if (~vm->_game.dirView[v->currentView].flags & RES_LOADED)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -285,7 +279,7 @@ INLINE int SpritesMgr::prioToY(int p) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1; /* (p - 5) * 12 + 48; */
|
return -1; // (p - 5) * 12 + 48;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -297,13 +291,13 @@ Sprite *SpritesMgr::newSprite(VtEntry *v) {
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
s->v = v; /* link sprite to associated view table entry */
|
s->v = v; // link sprite to associated view table entry
|
||||||
s->xPos = v->xPos;
|
s->xPos = v->xPos;
|
||||||
s->yPos = v->yPos - v->ySize + 1;
|
s->yPos = v->yPos - v->ySize + 1;
|
||||||
s->xSize = v->xSize;
|
s->xSize = v->xSize;
|
||||||
s->ySize = v->ySize;
|
s->ySize = v->ySize;
|
||||||
s->buffer = (uint8 *)poolAlloc(s->xSize * s->ySize);
|
s->buffer = (uint8 *)poolAlloc(s->xSize * s->ySize);
|
||||||
v->s = s; /* link view table entry to this sprite */
|
v->s = s; // link view table entry to this sprite
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
@ -326,9 +320,8 @@ void SpritesMgr::buildList(SpriteList &l, bool (*test)(VtEntry *, AgiEngine *))
|
||||||
int yVal[0x100];
|
int yVal[0x100];
|
||||||
int minY = 0xff, minIndex = 0;
|
int minY = 0xff, minIndex = 0;
|
||||||
|
|
||||||
/* fill the arrays with all sprites that satisfy the 'test'
|
// fill the arrays with all sprites that satisfy the 'test'
|
||||||
* condition and their y values
|
// condition and their y values
|
||||||
*/
|
|
||||||
i = 0;
|
i = 0;
|
||||||
for (v = _vm->_game.viewTable; v < &_vm->_game.viewTable[MAX_VIEWTABLE]; v++) {
|
for (v = _vm->_game.viewTable; v < &_vm->_game.viewTable[MAX_VIEWTABLE]; v++) {
|
||||||
if ((*test)(v, _vm)) {
|
if ((*test)(v, _vm)) {
|
||||||
|
@ -338,11 +331,11 @@ void SpritesMgr::buildList(SpriteList &l, bool (*test)(VtEntry *, AgiEngine *))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* now look for the smallest y value in the array and put that
|
// now look for the smallest y value in the array and put that
|
||||||
* sprite in the list
|
// sprite in the list
|
||||||
*/
|
|
||||||
for (j = 0; j < i; j++) {
|
for (j = 0; j < i; j++) {
|
||||||
minY = 0xff;
|
minY = 0xff;
|
||||||
|
|
||||||
for (k = 0; k < i; k++) {
|
for (k = 0; k < i; k++) {
|
||||||
if (yVal[k] < minY) {
|
if (yVal[k] < minY) {
|
||||||
minIndex = k;
|
minIndex = k;
|
||||||
|
@ -376,6 +369,7 @@ void SpritesMgr::freeList(SpriteList &l) {
|
||||||
SpriteList::iterator iter;
|
SpriteList::iterator iter;
|
||||||
for (iter = l.reverse_begin(); iter != l.end(); ) {
|
for (iter = l.reverse_begin(); iter != l.end(); ) {
|
||||||
Sprite* s = *iter;
|
Sprite* s = *iter;
|
||||||
|
|
||||||
poolRelease(s->buffer);
|
poolRelease(s->buffer);
|
||||||
poolRelease(s);
|
poolRelease(s);
|
||||||
iter = l.reverse_erase(iter);
|
iter = l.reverse_erase(iter);
|
||||||
|
@ -452,12 +446,15 @@ void SpritesMgr::eraseSprites(SpriteList &l) {
|
||||||
void SpritesMgr::blitSprites(SpriteList& l) {
|
void SpritesMgr::blitSprites(SpriteList& l) {
|
||||||
int hidden;
|
int hidden;
|
||||||
SpriteList::iterator iter;
|
SpriteList::iterator iter;
|
||||||
|
|
||||||
for (iter = l.begin(); iter != l.end(); ++iter) {
|
for (iter = l.begin(); iter != l.end(); ++iter) {
|
||||||
Sprite *s = *iter;
|
Sprite *s = *iter;
|
||||||
|
|
||||||
objsSaveArea(s);
|
objsSaveArea(s);
|
||||||
debugC(8, kDebugLevelSprites, "s->v->entry = %d (prio %d)", s->v->entry, s->v->priority);
|
debugC(8, kDebugLevelSprites, "s->v->entry = %d (prio %d)", s->v->entry, s->v->priority);
|
||||||
hidden = blitCel(s->xPos, s->yPos, s->v->priority, s->v->celData, s->v->viewData->agi256_2);
|
hidden = blitCel(s->xPos, s->yPos, s->v->priority, s->v->celData, s->v->viewData->agi256_2);
|
||||||
if (s->v->entry == 0) { /* if ego, update f1 */
|
|
||||||
|
if (s->v->entry == 0) { // if ego, update f1
|
||||||
_vm->setflag(fEgoInvisible, hidden);
|
_vm->setflag(fEgoInvisible, hidden);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -475,7 +472,7 @@ void SpritesMgr::commitNonupdSprites() {
|
||||||
commitSprites(_sprNonupd);
|
commitSprites(_sprNonupd);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check moves in both lists */
|
// check moves in both lists
|
||||||
void SpritesMgr::commitBoth() {
|
void SpritesMgr::commitBoth() {
|
||||||
commitUpdSprites();
|
commitUpdSprites();
|
||||||
commitNonupdSprites();
|
commitNonupdSprites();
|
||||||
|
@ -584,10 +581,8 @@ void SpritesMgr::addToPic(int view, int loop, int cel, int x, int y, int pri, in
|
||||||
|
|
||||||
_vm->recordImageStackCall(ADD_VIEW, view, loop, cel, x, y, pri, mar);
|
_vm->recordImageStackCall(ADD_VIEW, view, loop, cel, x, y, pri, mar);
|
||||||
|
|
||||||
/*
|
// Was hardcoded to 8, changed to pri_table[y] to fix Gold
|
||||||
* Was hardcoded to 8, changed to pri_table[y] to fix Gold
|
// Rush (see Sarien bug #587558)
|
||||||
* Rush (see Sarien bug #587558)
|
|
||||||
*/
|
|
||||||
if (pri == 0)
|
if (pri == 0)
|
||||||
pri = _vm->_game.priTable[y];
|
pri = _vm->_game.priTable[y];
|
||||||
|
|
||||||
|
@ -616,15 +611,13 @@ void SpritesMgr::addToPic(int view, int loop, int cel, int x, int y, int pri, in
|
||||||
debugC(4, kDebugLevelSprites, "blit_cel (%d, %d, %d, c)", x, y, pri);
|
debugC(4, kDebugLevelSprites, "blit_cel (%d, %d, %d, c)", x, y, pri);
|
||||||
blitCel(x1, y1, pri, c, _vm->_game.views[view].agi256_2);
|
blitCel(x1, y1, pri, c, _vm->_game.views[view].agi256_2);
|
||||||
|
|
||||||
/* If margin is 0, 1, 2, or 3, the base of the cel is
|
// If margin is 0, 1, 2, or 3, the base of the cel is
|
||||||
* surrounded with a rectangle of the corresponding priority.
|
// surrounded with a rectangle of the corresponding priority.
|
||||||
* If margin >= 4, this extra margin is not shown.
|
// If margin >= 4, this extra margin is not shown.
|
||||||
*/
|
|
||||||
if (mar < 4) {
|
if (mar < 4) {
|
||||||
/* add rectangle around object, don't clobber control
|
// add rectangle around object, don't clobber control
|
||||||
* info in priority data. The box extends to the end of
|
// info in priority data. The box extends to the end of
|
||||||
* its priority band!
|
// its priority band!
|
||||||
*/
|
|
||||||
y3 = (y2 / 12) * 12;
|
y3 = (y2 / 12) * 12;
|
||||||
|
|
||||||
// SQ1 needs +1 (see Sarien bug #810331)
|
// SQ1 needs +1 (see Sarien bug #810331)
|
||||||
|
@ -640,8 +633,10 @@ void SpritesMgr::addToPic(int view, int loop, int cel, int x, int y, int pri, in
|
||||||
for (y = y3; y <= y2; y++) {
|
for (y = y3; y <= y2; y++) {
|
||||||
if ((*p1 >> 4) >= 4)
|
if ((*p1 >> 4) >= 4)
|
||||||
*p1 = (mar << 4) | (*p1 & 0x0f);
|
*p1 = (mar << 4) | (*p1 & 0x0f);
|
||||||
|
|
||||||
if ((*p2 >> 4) >= 4)
|
if ((*p2 >> 4) >= 4)
|
||||||
*p2 = (mar << 4) | (*p2 & 0x0f);
|
*p2 = (mar << 4) | (*p2 & 0x0f);
|
||||||
|
|
||||||
p1 += _WIDTH;
|
p1 += _WIDTH;
|
||||||
p2 += _WIDTH;
|
p2 += _WIDTH;
|
||||||
}
|
}
|
||||||
|
@ -652,8 +647,10 @@ void SpritesMgr::addToPic(int view, int loop, int cel, int x, int y, int pri, in
|
||||||
for (x = x1; x <= x2; x++) {
|
for (x = x1; x <= x2; x++) {
|
||||||
if ((*p1 >> 4) >= 4)
|
if ((*p1 >> 4) >= 4)
|
||||||
*p1 = (mar << 4) | (*p1 & 0x0f);
|
*p1 = (mar << 4) | (*p1 & 0x0f);
|
||||||
|
|
||||||
if ((*p2 >> 4) >= 4)
|
if ((*p2 >> 4) >= 4)
|
||||||
*p2 = (mar << 4) | (*p2 & 0x0f);
|
*p2 = (mar << 4) | (*p2 & 0x0f);
|
||||||
|
|
||||||
p1++;
|
p1++;
|
||||||
p2++;
|
p2++;
|
||||||
}
|
}
|
||||||
|
@ -718,6 +715,7 @@ void SpritesMgr::commitBlock(int x1, int y1, int x2, int y2) {
|
||||||
w = x2 - x1 + 1;
|
w = x2 - x1 + 1;
|
||||||
q = &_vm->_game.sbuf16c[x1 + _WIDTH * y1];
|
q = &_vm->_game.sbuf16c[x1 + _WIDTH * y1];
|
||||||
offset = _vm->_game.lineMinPrint * CHAR_LINES;
|
offset = _vm->_game.lineMinPrint * CHAR_LINES;
|
||||||
|
|
||||||
for (i = y1; i <= y2; i++) {
|
for (i = y1; i <= y2; i++) {
|
||||||
_gfx->putPixelsA(x1, i + offset, w, q);
|
_gfx->putPixelsA(x1, i + offset, w, q);
|
||||||
q += _WIDTH;
|
q += _WIDTH;
|
||||||
|
|
|
@ -46,9 +46,9 @@ private:
|
||||||
uint8 *_spritePool;
|
uint8 *_spritePool;
|
||||||
uint8 *_poolTop;
|
uint8 *_poolTop;
|
||||||
|
|
||||||
/*
|
//
|
||||||
* Sprite management functions
|
// Sprite management functions
|
||||||
*/
|
//
|
||||||
|
|
||||||
SpriteList _sprUpd;
|
SpriteList _sprUpd;
|
||||||
SpriteList _sprNonupd;
|
SpriteList _sprNonupd;
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "agi/agi.h"
|
#include "agi/agi.h"
|
||||||
#include "agi/sprite.h" /* for commit_both() */
|
#include "agi/sprite.h" // for commit_both()
|
||||||
#include "agi/graphics.h"
|
#include "agi/graphics.h"
|
||||||
#include "agi/keyboard.h"
|
#include "agi/keyboard.h"
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ void AgiEngine::printText2(int l, const char *msg, int foff, int xoff, int yoff,
|
||||||
int x1, y1;
|
int x1, y1;
|
||||||
int maxx, minx, ofoff;
|
int maxx, minx, ofoff;
|
||||||
int update;
|
int update;
|
||||||
/* Note: Must be unsigned to use AGDS cyrillic characters! */
|
// Note: Must be unsigned to use AGDS cyrillic characters!
|
||||||
#ifdef __DS__
|
#ifdef __DS__
|
||||||
// On the DS, a compiler bug causes the text to render incorrectly, because
|
// On the DS, a compiler bug causes the text to render incorrectly, because
|
||||||
// GCC tries to optimisie out writes to this pointer (tested on DevkitARM v19b and v20)
|
// GCC tries to optimisie out writes to this pointer (tested on DevkitARM v19b and v20)
|
||||||
|
@ -45,20 +45,19 @@ void AgiEngine::printText2(int l, const char *msg, int foff, int xoff, int yoff,
|
||||||
const unsigned char *m;
|
const unsigned char *m;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* kludge! */
|
// kludge!
|
||||||
update = 1;
|
update = 1;
|
||||||
if (l == 2) {
|
if (l == 2) {
|
||||||
update = l = 0;
|
update = l = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FR: strings with len == 1 were not printed
|
// FR: strings with len == 1 were not printed
|
||||||
*/
|
|
||||||
if (len == 1) {
|
if (len == 1) {
|
||||||
_gfx->putTextCharacter(l, xoff + foff, yoff, *msg, fg, bg, checkerboard);
|
_gfx->putTextCharacter(l, xoff + foff, yoff, *msg, fg, bg, checkerboard);
|
||||||
maxx = 1;
|
maxx = 1;
|
||||||
minx = 0;
|
minx = 0;
|
||||||
ofoff = foff;
|
ofoff = foff;
|
||||||
y1 = 0; /* Check this */
|
y1 = 0; // Check this
|
||||||
} else {
|
} else {
|
||||||
maxx = 0;
|
maxx = 0;
|
||||||
minx = GFX_WIDTH;
|
minx = GFX_WIDTH;
|
||||||
|
@ -69,7 +68,7 @@ void AgiEngine::printText2(int l, const char *msg, int foff, int xoff, int yoff,
|
||||||
if (*m >= 0x20 || *m == 1 || *m == 2 || *m == 3) {
|
if (*m >= 0x20 || *m == 1 || *m == 2 || *m == 3) {
|
||||||
// FIXME: Fingolfin asks: why is there a FIXME here? Please either clarify what
|
// FIXME: Fingolfin asks: why is there a FIXME here? Please either clarify what
|
||||||
// needs fixing, or remove it!
|
// needs fixing, or remove it!
|
||||||
/* FIXME */
|
// FIXME
|
||||||
int ypos;
|
int ypos;
|
||||||
|
|
||||||
ypos = (y1 * CHAR_LINES) + yoff;
|
ypos = (y1 * CHAR_LINES) + yoff;
|
||||||
|
@ -92,7 +91,7 @@ void AgiEngine::printText2(int l, const char *msg, int foff, int xoff, int yoff,
|
||||||
|
|
||||||
x1++;
|
x1++;
|
||||||
|
|
||||||
/* DF: changed the len-1 to len... */
|
// DF: changed the len-1 to len...
|
||||||
if (x1 == len && m[len] != '\n')
|
if (x1 == len && m[len] != '\n')
|
||||||
y1++, x1 = foff = 0;
|
y1++, x1 = foff = 0;
|
||||||
} else {
|
} else {
|
||||||
|
@ -114,17 +113,18 @@ void AgiEngine::printText2(int l, const char *msg, int foff, int xoff, int yoff,
|
||||||
if (update) {
|
if (update) {
|
||||||
_gfx->scheduleUpdate(foff + xoff + minx, yoff, ofoff + xoff + maxx + CHAR_COLS - 1,
|
_gfx->scheduleUpdate(foff + xoff + minx, yoff, ofoff + xoff + maxx + CHAR_COLS - 1,
|
||||||
yoff + y1 * CHAR_LINES + CHAR_LINES + 1);
|
yoff + y1 * CHAR_LINES + CHAR_LINES + 1);
|
||||||
/* Making synchronous text updates reduces CPU load
|
|
||||||
* when updating status line and input area
|
// Making synchronous text updates reduces CPU load
|
||||||
*/
|
// when updating status line and input area
|
||||||
_gfx->doUpdate();
|
_gfx->doUpdate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* len is in characters, not pixels!!
|
//
|
||||||
*/
|
// len is in characters, not pixels!!
|
||||||
|
//
|
||||||
void AgiEngine::blitTextbox(const char *p, int y, int x, int len) {
|
void AgiEngine::blitTextbox(const char *p, int y, int x, int len) {
|
||||||
/* if x | y = -1, then centre the box */
|
// if x | y = -1, then center the box
|
||||||
int xoff, yoff, lin, h, w;
|
int xoff, yoff, lin, h, w;
|
||||||
char *msg, *m;
|
char *msg, *m;
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ void AgiEngine::blitTextbox(const char *p, int y, int x, int len) {
|
||||||
m = msg = wordWrapString(agiSprintf(p), &len);
|
m = msg = wordWrapString(agiSprintf(p), &len);
|
||||||
|
|
||||||
for (lin = 1; *m; m++) {
|
for (lin = 1; *m; m++) {
|
||||||
/* Test \r for MacOS 8 */
|
// Test \r for MacOS 8
|
||||||
if (*m == '\n' || *m == '\r')
|
if (*m == '\n' || *m == '\r')
|
||||||
lin++;
|
lin++;
|
||||||
}
|
}
|
||||||
|
@ -301,9 +301,9 @@ void AgiEngine::closeWindow() {
|
||||||
debugC(4, kDebugLevelText, "closeWindow()");
|
debugC(4, kDebugLevelText, "closeWindow()");
|
||||||
|
|
||||||
_sprites->eraseBoth();
|
_sprites->eraseBoth();
|
||||||
eraseTextbox(); /* remove window, if any */
|
eraseTextbox(); // remove window, if any
|
||||||
_sprites->blitBoth();
|
_sprites->blitBoth();
|
||||||
_sprites->commitBoth(); /* redraw sprites */
|
_sprites->commitBoth(); // redraw sprites
|
||||||
_game.hasWindow = false;
|
_game.hasWindow = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -350,7 +350,7 @@ int AgiEngine::selectionBox(const char *m, const char **b) {
|
||||||
s = _game.window.x2 - _game.window.x1 + 1 - 5 * CHAR_COLS;
|
s = _game.window.x2 - _game.window.x1 + 1 - 5 * CHAR_COLS;
|
||||||
debugC(3, kDebugLevelText, "selectionBox(): s = %d", s);
|
debugC(3, kDebugLevelText, "selectionBox(): s = %d", s);
|
||||||
|
|
||||||
/* Automatically position buttons */
|
// Automatically position buttons
|
||||||
for (i = 0; b[i]; i++) {
|
for (i = 0; b[i]; i++) {
|
||||||
numButtons++;
|
numButtons++;
|
||||||
s -= CHAR_COLS * strlen(b[i]);
|
s -= CHAR_COLS * strlen(b[i]);
|
||||||
|
@ -371,7 +371,7 @@ int AgiEngine::selectionBox(const char *m, const char **b) {
|
||||||
|
|
||||||
_sprites->blitBoth();
|
_sprites->blitBoth();
|
||||||
|
|
||||||
/* clear key queue */
|
// clear key queue
|
||||||
while (_gfx->keypress()) {
|
while (_gfx->keypress()) {
|
||||||
_gfx->getKey();
|
_gfx->getKey();
|
||||||
}
|
}
|
||||||
|
@ -383,7 +383,7 @@ int AgiEngine::selectionBox(const char *m, const char **b) {
|
||||||
for (i = 0; b[i]; i++)
|
for (i = 0; b[i]; i++)
|
||||||
_gfx->drawCurrentStyleButton(bx[i], by[i], b[i], i == active, false, i == 0);
|
_gfx->drawCurrentStyleButton(bx[i], by[i], b[i], i == active, false, i == 0);
|
||||||
|
|
||||||
_gfx->pollTimer(); /* msdos driver -> does nothing */
|
_gfx->pollTimer(); // msdos driver -> does nothing
|
||||||
key = doPollKeyboard();
|
key = doPollKeyboard();
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case KEY_ENTER:
|
case KEY_ENTER:
|
||||||
|
@ -410,7 +410,7 @@ int AgiEngine::selectionBox(const char *m, const char **b) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 0x09: /* Tab */
|
case 0x09: // Tab
|
||||||
debugC(3, kDebugLevelText, "selectionBox(): Focus change");
|
debugC(3, kDebugLevelText, "selectionBox(): Focus change");
|
||||||
active++;
|
active++;
|
||||||
active %= i;
|
active %= i;
|
||||||
|
@ -449,12 +449,12 @@ int AgiEngine::print(const char *p, int lin, int col, int len) {
|
||||||
blitTextbox(p, lin, col, len);
|
blitTextbox(p, lin, col, len);
|
||||||
|
|
||||||
if (getflag(fOutputMode)) {
|
if (getflag(fOutputMode)) {
|
||||||
/* non-blocking window */
|
// non-blocking window
|
||||||
setflag(fOutputMode, false);
|
setflag(fOutputMode, false);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* blocking */
|
// blocking
|
||||||
|
|
||||||
setflag(fNoSaveLoadAllowed, true);
|
setflag(fNoSaveLoadAllowed, true);
|
||||||
|
|
||||||
|
@ -469,7 +469,7 @@ int AgiEngine::print(const char *p, int lin, int col, int len) {
|
||||||
return k;
|
return k;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* timed window */
|
// timed window
|
||||||
|
|
||||||
debugC(3, kDebugLevelText, "f15==0, v21==%d => timed", getvar(21));
|
debugC(3, kDebugLevelText, "f15==0, v21==%d => timed", getvar(21));
|
||||||
_game.msgBoxTicks = getvar(vWindowReset) * 10;
|
_game.msgBoxTicks = getvar(vWindowReset) * 10;
|
||||||
|
@ -561,8 +561,8 @@ char *AgiEngine::agiSprintf(const char *s) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i == 99) {
|
if (i == 99) {
|
||||||
/* remove all leading 0 */
|
// remove all leading 0
|
||||||
/* don't remove the 3rd zero if 000 */
|
// don't remove the 3rd zero if 000
|
||||||
for (i = 0; z[i] == '0' && i < 14; i++)
|
for (i = 0; z[i] == '0' && i < 14; i++)
|
||||||
;
|
;
|
||||||
} else {
|
} else {
|
||||||
|
@ -683,10 +683,9 @@ void AgiEngine::writePrompt() {
|
||||||
* @param c color
|
* @param c color
|
||||||
*/
|
*/
|
||||||
void AgiEngine::clearLines(int l1, int l2, int c) {
|
void AgiEngine::clearLines(int l1, int l2, int c) {
|
||||||
/* do we need to adjust for +8 on topline?
|
// do we need to adjust for +8 on topline?
|
||||||
* inc for endline so it matches the correct num
|
// inc for endline so it matches the correct num
|
||||||
* ie, from 22 to 24 is 3 lines, not 2 lines.
|
// ie, from 22 to 24 is 3 lines, not 2 lines.
|
||||||
*/
|
|
||||||
|
|
||||||
l1 *= CHAR_LINES;
|
l1 *= CHAR_LINES;
|
||||||
l2 *= CHAR_LINES;
|
l2 *= CHAR_LINES;
|
||||||
|
|
|
@ -36,9 +36,8 @@ void AgiEngine::lSetCel(VtEntry *v, int n) {
|
||||||
|
|
||||||
currentVl = &_game.views[v->currentView].loop[v->currentLoop];
|
currentVl = &_game.views[v->currentView].loop[v->currentLoop];
|
||||||
|
|
||||||
/* Added by Amit Vainsencher <amitv@subdimension.com> to prevent
|
// Added by Amit Vainsencher <amitv@subdimension.com> to prevent
|
||||||
* crash in KQ1 -- not in the Sierra interpreter
|
// crash in KQ1 -- not in the Sierra interpreter
|
||||||
*/
|
|
||||||
if (currentVl->numCels == 0)
|
if (currentVl->numCels == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -64,9 +63,8 @@ void AgiEngine::lSetLoop(VtEntry *v, int n) {
|
||||||
ViewLoop *currentVl;
|
ViewLoop *currentVl;
|
||||||
debugC(7, kDebugLevelResources, "vt entry #%d, loop = %d", v->entry, n);
|
debugC(7, kDebugLevelResources, "vt entry #%d, loop = %d", v->entry, n);
|
||||||
|
|
||||||
/* Added to avoid crash when leaving the arcade machine in MH1
|
// Added to avoid crash when leaving the arcade machine in MH1
|
||||||
* -- not in AGI 2.917
|
// -- not in AGI 2.917
|
||||||
*/
|
|
||||||
if (n >= v->numLoops)
|
if (n >= v->numLoops)
|
||||||
n = 0;
|
n = 0;
|
||||||
|
|
||||||
|
@ -154,34 +152,35 @@ int AgiEngine::decodeView(int n) {
|
||||||
_game.views[n].agi256_2 = (READ_LE_UINT16(v) == 0xf00f); // Detect AGI256-2 views by their header bytes
|
_game.views[n].agi256_2 = (READ_LE_UINT16(v) == 0xf00f); // Detect AGI256-2 views by their header bytes
|
||||||
_game.views[n].descr = READ_LE_UINT16(v + 3) ? (char *)(v + READ_LE_UINT16(v + 3)) : (char *)(v + 3);
|
_game.views[n].descr = READ_LE_UINT16(v + 3) ? (char *)(v + READ_LE_UINT16(v + 3)) : (char *)(v + 3);
|
||||||
|
|
||||||
/* if no loops exist, return! */
|
// if no loops exist, return!
|
||||||
if ((_game.views[n].numLoops = *(v + 2)) == 0)
|
if ((_game.views[n].numLoops = *(v + 2)) == 0)
|
||||||
return errNoLoopsInView;
|
return errNoLoopsInView;
|
||||||
|
|
||||||
/* allocate memory for all views */
|
// allocate memory for all views
|
||||||
_game.views[n].loop = (ViewLoop *)
|
_game.views[n].loop = (ViewLoop *)
|
||||||
calloc(_game.views[n].numLoops, sizeof(ViewLoop));
|
calloc(_game.views[n].numLoops, sizeof(ViewLoop));
|
||||||
|
|
||||||
if (_game.views[n].loop == NULL)
|
if (_game.views[n].loop == NULL)
|
||||||
return errNotEnoughMemory;
|
return errNotEnoughMemory;
|
||||||
|
|
||||||
/* decode all of the loops in this view */
|
// decode all of the loops in this view
|
||||||
lptr = v + 5; /* first loop address */
|
lptr = v + 5; // first loop address
|
||||||
|
|
||||||
for (loop = 0; loop < _game.views[n].numLoops; loop++, lptr += 2) {
|
for (loop = 0; loop < _game.views[n].numLoops; loop++, lptr += 2) {
|
||||||
lofs = READ_LE_UINT16(lptr); /* loop header offset */
|
lofs = READ_LE_UINT16(lptr); // loop header offset
|
||||||
vl = &_game.views[n].loop[loop]; /* the loop struct */
|
vl = &_game.views[n].loop[loop]; // the loop struct
|
||||||
|
|
||||||
vl->numCels = *(v + lofs);
|
vl->numCels = *(v + lofs);
|
||||||
debugC(6, kDebugLevelResources, "view %d, num_cels = %d", n, vl->numCels);
|
debugC(6, kDebugLevelResources, "view %d, num_cels = %d", n, vl->numCels);
|
||||||
vl->cel = (ViewCel *)calloc(vl->numCels, sizeof(ViewCel));
|
vl->cel = (ViewCel *)calloc(vl->numCels, sizeof(ViewCel));
|
||||||
|
|
||||||
if (vl->cel == NULL) {
|
if (vl->cel == NULL) {
|
||||||
free(_game.views[n].loop);
|
free(_game.views[n].loop);
|
||||||
_game.views[n].numLoops = 0;
|
_game.views[n].numLoops = 0;
|
||||||
return errNotEnoughMemory;
|
return errNotEnoughMemory;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* decode the cells */
|
// decode the cells
|
||||||
for (cel = 0; cel < vl->numCels; cel++) {
|
for (cel = 0; cel < vl->numCels; cel++) {
|
||||||
cofs = lofs + READ_LE_UINT16(v + lofs + 1 + (cel * 2));
|
cofs = lofs + READ_LE_UINT16(v + lofs + 1 + (cel * 2));
|
||||||
vc = &vl->cel[cel];
|
vc = &vl->cel[cel];
|
||||||
|
@ -201,17 +200,17 @@ int AgiEngine::decodeView(int n) {
|
||||||
vc->mirror = 0;
|
vc->mirror = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* skip over width/height/trans|mirror data */
|
// skip over width/height/trans|mirror data
|
||||||
cofs += 3;
|
cofs += 3;
|
||||||
|
|
||||||
vc->data = v + cofs;
|
vc->data = v + cofs;
|
||||||
/* If mirror_loop is pointing to the current loop,
|
|
||||||
* then this is the original.
|
// If mirror_loop is pointing to the current loop,
|
||||||
*/
|
// then this is the original.
|
||||||
if (vc->mirrorLoop == loop)
|
if (vc->mirrorLoop == loop)
|
||||||
vc->mirror = 0;
|
vc->mirror = 0;
|
||||||
} /* cel */
|
} // cel
|
||||||
} /* loop */
|
} // loop
|
||||||
|
|
||||||
return errOK;
|
return errOK;
|
||||||
}
|
}
|
||||||
|
@ -227,12 +226,12 @@ void AgiEngine::unloadView(int n) {
|
||||||
if (~_game.dirView[n].flags & RES_LOADED)
|
if (~_game.dirView[n].flags & RES_LOADED)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Rebuild sprite list, see Sarien bug #779302 */
|
// Rebuild sprite list, see Sarien bug #779302
|
||||||
_sprites->eraseBoth();
|
_sprites->eraseBoth();
|
||||||
_sprites->blitBoth();
|
_sprites->blitBoth();
|
||||||
_sprites->commitBoth();
|
_sprites->commitBoth();
|
||||||
|
|
||||||
/* free all the loops */
|
// free all the loops
|
||||||
for (x = 0; x < _game.views[n].numLoops; x++)
|
for (x = 0; x < _game.views[n].numLoops; x++)
|
||||||
free(_game.views[n].loop[x].cel);
|
free(_game.views[n].loop[x].cel);
|
||||||
|
|
||||||
|
@ -253,7 +252,7 @@ void AgiEngine::setCel(VtEntry *v, int n) {
|
||||||
|
|
||||||
lSetCel(v, n);
|
lSetCel(v, n);
|
||||||
|
|
||||||
/* If position isn't appropriate, update it accordingly */
|
// If position isn't appropriate, update it accordingly
|
||||||
clipViewCoordinates(v);
|
clipViewCoordinates(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -308,6 +307,7 @@ void AgiEngine::setView(VtEntry *v, int n) {
|
||||||
if (v->currentView == 118 && v->flags & DRAWN && getGameID() == GID_SQ1) {
|
if (v->currentView == 118 && v->flags & DRAWN && getGameID() == GID_SQ1) {
|
||||||
viewFlags = v->flags; // Store the flags for the view
|
viewFlags = v->flags; // Store the flags for the view
|
||||||
_sprites->eraseUpdSprites();
|
_sprites->eraseUpdSprites();
|
||||||
|
|
||||||
if (v->flags & UPDATE) {
|
if (v->flags & UPDATE) {
|
||||||
v->flags &= ~DRAWN;
|
v->flags &= ~DRAWN;
|
||||||
} else {
|
} else {
|
||||||
|
@ -335,6 +335,7 @@ void AgiEngine::setView(VtEntry *v, int n) {
|
||||||
void AgiEngine::startUpdate(VtEntry *v) {
|
void AgiEngine::startUpdate(VtEntry *v) {
|
||||||
if (~v->flags & UPDATE) {
|
if (~v->flags & UPDATE) {
|
||||||
_sprites->eraseBoth();
|
_sprites->eraseBoth();
|
||||||
|
|
||||||
v->flags |= UPDATE;
|
v->flags |= UPDATE;
|
||||||
_sprites->blitBoth();
|
_sprites->blitBoth();
|
||||||
}
|
}
|
||||||
|
@ -347,14 +348,14 @@ void AgiEngine::startUpdate(VtEntry *v) {
|
||||||
void AgiEngine::stopUpdate(VtEntry *v) {
|
void AgiEngine::stopUpdate(VtEntry *v) {
|
||||||
if (v->flags & UPDATE) {
|
if (v->flags & UPDATE) {
|
||||||
_sprites->eraseBoth();
|
_sprites->eraseBoth();
|
||||||
|
|
||||||
v->flags &= ~UPDATE;
|
v->flags &= ~UPDATE;
|
||||||
_sprites->blitBoth();
|
_sprites->blitBoth();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* loops to use according to direction and number of loops in
|
// loops to use according to direction and number of loops in
|
||||||
* the view resource
|
// the view resource
|
||||||
*/
|
|
||||||
static int loopTable2[] = {
|
static int loopTable2[] = {
|
||||||
0x04, 0x04, 0x00, 0x00, 0x00, 0x04, 0x01, 0x01, 0x01
|
0x04, 0x04, 0x00, 0x00, 0x00, 0x04, 0x01, 0x01, 0x01
|
||||||
};
|
};
|
||||||
|
@ -391,14 +392,14 @@ void AgiEngine::updateViewtable() {
|
||||||
loop = loopTable4[v->direction];
|
loop = loopTable4[v->direction];
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
/* for KQ4 */
|
// for KQ4
|
||||||
if (agiGetRelease() == 0x3086)
|
if (agiGetRelease() == 0x3086)
|
||||||
loop = loopTable4[v->direction];
|
loop = loopTable4[v->direction];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* AGI 2.272 (ddp, xmas) doesn't test step_time_count! */
|
// AGI 2.272 (ddp, xmas) doesn't test step_time_count!
|
||||||
if (loop != 4 && loop != v->currentLoop) {
|
if (loop != 4 && loop != v->currentLoop) {
|
||||||
if (agiGetRelease() <= 0x2272 ||
|
if (agiGetRelease() <= 0x2272 ||
|
||||||
v->stepTimeCount == 1) {
|
v->stepTimeCount == 1) {
|
||||||
|
|
|
@ -120,7 +120,7 @@ struct VtEntry {
|
||||||
uint8 parm2;
|
uint8 parm2;
|
||||||
uint8 parm3;
|
uint8 parm3;
|
||||||
uint8 parm4;
|
uint8 parm4;
|
||||||
}; /* struct vt_entry */
|
}; // struct vt_entry
|
||||||
|
|
||||||
} // End of namespace Agi
|
} // End of namespace Agi
|
||||||
|
|
||||||
|
|
|
@ -23,22 +23,22 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
//
|
||||||
* New find_word algorithm by Thomas Akesson <tapilot@home.se>
|
// New find_word algorithm by Thomas Akesson <tapilot@home.se>
|
||||||
*/
|
//
|
||||||
|
|
||||||
#include "agi/agi.h"
|
#include "agi/agi.h"
|
||||||
#include "agi/keyboard.h" /* for clean_input() */
|
#include "agi/keyboard.h" // for clean_input()
|
||||||
|
|
||||||
namespace Agi {
|
namespace Agi {
|
||||||
|
|
||||||
static uint8 *words; /* words in the game */
|
static uint8 *words; // words in the game
|
||||||
static uint32 wordsFlen; /* length of word memory */
|
static uint32 wordsFlen; // length of word memory
|
||||||
|
|
||||||
/*
|
//
|
||||||
* Local implementation to avoid problems with strndup() used by
|
// Local implementation to avoid problems with strndup() used by
|
||||||
* gcc 3.2 Cygwin (see #635984)
|
// gcc 3.2 Cygwin (see #635984)
|
||||||
*/
|
//
|
||||||
static char *myStrndup(char *src, int n) {
|
static char *myStrndup(char *src, int n) {
|
||||||
char *tmp = strncpy((char *)malloc(n + 1), src, n);
|
char *tmp = strncpy((char *)malloc(n + 1), src, n);
|
||||||
tmp[n] = 0;
|
tmp[n] = 0;
|
||||||
|
@ -54,7 +54,7 @@ int AgiEngine::loadWords(const char *fname) {
|
||||||
|
|
||||||
if (!fp.open(fname)) {
|
if (!fp.open(fname)) {
|
||||||
report("Warning: can't open %s\n", fname);
|
report("Warning: can't open %s\n", fname);
|
||||||
return errOK /*err_BadFileOpen */ ;
|
return errOK; // err_BadFileOpen
|
||||||
}
|
}
|
||||||
report("Loading dictionary: %s\n", fname);
|
report("Loading dictionary: %s\n", fname);
|
||||||
|
|
||||||
|
@ -91,13 +91,14 @@ void AgiEngine::unloadWords() {
|
||||||
* Thomas Akesson, November 2001
|
* Thomas Akesson, November 2001
|
||||||
*/
|
*/
|
||||||
int AgiEngine::findWord(char *word, int *flen) {
|
int AgiEngine::findWord(char *word, int *flen) {
|
||||||
int mchr = 0; /* matched chars */
|
int mchr = 0; // matched chars
|
||||||
int len, fchr, id = -1;
|
int len, fchr, id = -1;
|
||||||
uint8 *p = words;
|
uint8 *p = words;
|
||||||
uint8 *q = words + wordsFlen;
|
uint8 *q = words + wordsFlen;
|
||||||
*flen = 0;
|
*flen = 0;
|
||||||
|
|
||||||
debugC(2, kDebugLevelScripts, "find_word(%s)", word);
|
debugC(2, kDebugLevelScripts, "find_word(%s)", word);
|
||||||
|
|
||||||
if (word[0] >= 'a' && word[0] <= 'z')
|
if (word[0] >= 'a' && word[0] <= 'z')
|
||||||
fchr = word[0] - 'a';
|
fchr = word[0] - 'a';
|
||||||
else
|
else
|
||||||
|
@ -105,22 +106,20 @@ int AgiEngine::findWord(char *word, int *flen) {
|
||||||
|
|
||||||
len = strlen(word);
|
len = strlen(word);
|
||||||
|
|
||||||
/* Get the offset to the first word beginning with the
|
// Get the offset to the first word beginning with the
|
||||||
* right character
|
// right character
|
||||||
*/
|
|
||||||
p += READ_BE_UINT16(p + 2 * fchr);
|
p += READ_BE_UINT16(p + 2 * fchr);
|
||||||
|
|
||||||
while (p[0] >= mchr) {
|
while (p[0] >= mchr) {
|
||||||
if (p[0] == mchr) {
|
if (p[0] == mchr) {
|
||||||
p++;
|
p++;
|
||||||
/* Loop through all matching characters */
|
// Loop through all matching characters
|
||||||
while ((p[0] ^ word[mchr]) == 0x7F && mchr < len) {
|
while ((p[0] ^ word[mchr]) == 0x7F && mchr < len) {
|
||||||
mchr++;
|
mchr++;
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
/* Check if this is the last character of the word
|
// Check if this is the last character of the word
|
||||||
* and if it matches
|
// and if it matches
|
||||||
*/
|
|
||||||
if ((p[0] ^ word[mchr]) == 0xFF && mchr < len) {
|
if ((p[0] ^ word[mchr]) == 0xFF && mchr < len) {
|
||||||
mchr++;
|
mchr++;
|
||||||
if (word[mchr] == 0 || word[mchr] == 0x20) {
|
if (word[mchr] == 0 || word[mchr] == 0x20) {
|
||||||
|
@ -132,9 +131,10 @@ int AgiEngine::findWord(char *word, int *flen) {
|
||||||
if (p >= q)
|
if (p >= q)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* Step to the next word */
|
// Step to the next word
|
||||||
while (p[0] < 0x80)
|
while (p[0] < 0x80)
|
||||||
p++;
|
p++;
|
||||||
|
|
||||||
p += 3;
|
p += 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,20 +164,24 @@ void AgiEngine::dictionaryWords(char *msg) {
|
||||||
case -1:
|
case -1:
|
||||||
debugC(2, kDebugLevelScripts, "unknown word");
|
debugC(2, kDebugLevelScripts, "unknown word");
|
||||||
_game.egoWords[_game.numEgoWords].word = strdup(p);
|
_game.egoWords[_game.numEgoWords].word = strdup(p);
|
||||||
|
|
||||||
q = _game.egoWords[_game.numEgoWords].word;
|
q = _game.egoWords[_game.numEgoWords].word;
|
||||||
|
|
||||||
_game.egoWords[_game.numEgoWords].id = 19999;
|
_game.egoWords[_game.numEgoWords].id = 19999;
|
||||||
setvar(vWordNotFound, 1 + _game.numEgoWords);
|
setvar(vWordNotFound, 1 + _game.numEgoWords);
|
||||||
|
|
||||||
_game.numEgoWords++;
|
_game.numEgoWords++;
|
||||||
|
|
||||||
p += strlen(p);
|
p += strlen(p);
|
||||||
break;
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
/* ignore this word */
|
// ignore this word
|
||||||
debugC(2, kDebugLevelScripts, "ignore word");
|
debugC(2, kDebugLevelScripts, "ignore word");
|
||||||
p += wlen;
|
p += wlen;
|
||||||
q = NULL;
|
q = NULL;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
/* an OK word */
|
// an OK word
|
||||||
debugC(3, kDebugLevelScripts, "ok word (%d)", wid);
|
debugC(3, kDebugLevelScripts, "ok word (%d)", wid);
|
||||||
_game.egoWords[_game.numEgoWords].id = wid;
|
_game.egoWords[_game.numEgoWords].id = wid;
|
||||||
_game.egoWords[_game.numEgoWords].word = myStrndup(p, wlen);
|
_game.egoWords[_game.numEgoWords].word = myStrndup(p, wlen);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue