aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/agi/agi.cpp35
-rw-r--r--engines/agi/agi.h96
-rw-r--r--engines/agi/checks.cpp47
-rw-r--r--engines/agi/console.cpp2
-rw-r--r--engines/agi/cycle.cpp44
-rw-r--r--engines/agi/font.h16
-rw-r--r--engines/agi/global.cpp8
-rw-r--r--engines/agi/graphics.cpp79
-rw-r--r--engines/agi/id.cpp16
-rw-r--r--engines/agi/inv.cpp21
-rw-r--r--engines/agi/keyboard.cpp112
-rw-r--r--engines/agi/keyboard.h28
-rw-r--r--engines/agi/loader_v2.cpp44
-rw-r--r--engines/agi/loader_v3.cpp77
-rw-r--r--engines/agi/logic.cpp38
-rw-r--r--engines/agi/lzw.cpp21
-rw-r--r--engines/agi/menu.cpp67
-rw-r--r--engines/agi/menu.h8
-rw-r--r--engines/agi/motion.cpp22
-rw-r--r--engines/agi/objects.cpp14
-rw-r--r--engines/agi/op_cmd.cpp177
-rw-r--r--engines/agi/op_dbg.cpp412
-rw-r--r--engines/agi/op_test.cpp125
-rw-r--r--engines/agi/picture.cpp10
-rw-r--r--engines/agi/preagi.cpp42
-rw-r--r--engines/agi/preagi_mickey.cpp204
-rw-r--r--engines/agi/preagi_troll.cpp10
-rw-r--r--engines/agi/preagi_winnie.cpp18
-rw-r--r--engines/agi/predictive.cpp6
-rw-r--r--engines/agi/saveload.cpp121
-rw-r--r--engines/agi/sound.cpp70
-rw-r--r--engines/agi/sprite.cpp114
-rw-r--r--engines/agi/sprite.h6
-rw-r--r--engines/agi/text.cpp59
-rw-r--r--engines/agi/view.cpp55
-rw-r--r--engines/agi/view.h2
-rw-r--r--engines/agi/words.cpp50
37 files changed, 1227 insertions, 1049 deletions
diff --git a/engines/agi/agi.cpp b/engines/agi/agi.cpp
index 79ea2a079a..07b66b9c05 100644
--- a/engines/agi/agi.cpp
+++ b/engines/agi/agi.cpp
@@ -23,7 +23,6 @@
*
*/
-
#include "common/md5.h"
#include "common/events.h"
#include "common/file.h"
@@ -291,7 +290,7 @@ void AgiEngine::agiTimerLow() {
int AgiEngine::agiGetKeypressLow() {
int k;
- while (_keyQueueStart == _keyQueueEnd) /* block */
+ while (_keyQueueStart == _keyQueueEnd) // block
agiTimerLow();
keyDequeue(k);
@@ -358,16 +357,16 @@ int AgiEngine::agiInit() {
debug(2, "initializing");
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;
- /* 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++)
_game.flags[i] = 0;
for (i = 0; i < MAX_VARS; i++)
_game.vars[i] = 0;
- /* clear all resources and events */
+ // clear all resources and events
for (i = 0; i < MAX_DIRS; i++) {
memset(&_game.views[i], 0, sizeof(struct AgiView));
memset(&_game.pictures[i], 0, sizeof(struct AgiPicture));
@@ -379,7 +378,7 @@ int AgiEngine::agiInit() {
memset(&_game.dirSound[i], 0, sizeof(struct AgiDir));
}
- /* clear view table */
+ // clear view table
for (i = 0; i < MAX_VIEWTABLE; i++)
memset(&_game.viewTable[i], 0, sizeof(VtEntry));
@@ -392,11 +391,11 @@ int AgiEngine::agiInit() {
initPriTable();
- /* clear string buffer */
+ // clear string buffer
for (i = 0; i < MAX_STRINGS; i++)
_game.strings[i][0] = 0;
- /* setup emulation */
+ // setup emulation
switch (_loader->getIntVersion() >> 12) {
case 2:
@@ -427,19 +426,19 @@ int AgiEngine::agiInit() {
if (_game.gameFlags & ID_AGDS)
report("AGDS mode enabled.\n");
- ec = _loader->init(); /* load vol files, etc */
+ ec = _loader->init(); // load vol files, etc
if (ec == errOK)
ec = _loader->loadObjects(OBJECTS);
- /* note: demogs has no words.tok */
+ // note: demogs has no words.tok
if (ec == errOK)
ec = _loader->loadWords(WORDS);
- /* FIXME: load IIgs instruments and samples */
- /* load_instruments("kq.sys16"); */
+ // FIXME: load IIgs instruments and samples
+ // load_instruments("kq.sys16");
- /* Load logic 0 into memory */
+ // Load logic 0 into memory
if (ec == errOK)
ec = _loader->loadResource(rLOGIC, 0);
@@ -459,7 +458,7 @@ int AgiEngine::agiInit() {
void AgiEngine::agiUnloadResources() {
int i;
- /* Make sure logic 0 is always loaded */
+ // Make sure logic 0 is always loaded
for (i = 1; i < MAX_DIRS; i++) {
_loader->unloadResource(rLOGIC, i);
}
@@ -473,8 +472,8 @@ void AgiEngine::agiUnloadResources() {
int AgiEngine::agiDeinit() {
int ec;
- cleanInput(); /* remove all words from memory */
- agiUnloadResources(); /* unload resources in memory */
+ cleanInput(); // remove all words from memory
+ agiUnloadResources(); // unload resources in memory
_loader->unloadResource(rLOGIC, 0);
ec = _loader->deinit();
unloadObjects();
@@ -744,7 +743,7 @@ void AgiEngine::initialize() {
_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");
@@ -805,7 +804,7 @@ Common::Error AgiEngine::go() {
mainCycle();
} while (_game.state < STATE_RUNNING);
if (_game.ver < 0)
- _game.ver = 0; /* Enable conf file warning */
+ _game.ver = 0; // Enable conf file warning
}
runGame();
diff --git a/engines/agi/agi.h b/engines/agi/agi.h
index e4461904ed..3d4cfc78ee 100644
--- a/engines/agi/agi.h
+++ b/engines/agi/agi.h
@@ -42,9 +42,9 @@ namespace Agi {
typedef signed int Err;
-/*
- * Version and other definitions
- */
+//
+// Version and other definitions
+//
#define TITLE "AGI engine"
@@ -59,9 +59,9 @@ typedef signed int Err;
#define MAX_DIRS 256
#define MAX_VARS 256
#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_STRINGS 24 /* MAX_STRINGS + 1 used for get.num */
+#define MAX_STRINGS 24 // MAX_STRINGS + 1 used for get.num
#define MAX_STRINGLEN 40
#ifndef MAX_PATH
#define MAX_PATH 260
@@ -77,12 +77,12 @@ typedef signed int Err;
#define INLINE
#endif
-#define MSG_BOX_COLOUR 0x0f /* White */
-#define MSG_BOX_TEXT 0x00 /* Black */
-#define MSG_BOX_LINE 0x04 /* Red */
-#define BUTTON_BORDER 0x00 /* Black */
-#define STATUS_FG 0x00 /* Black */
-#define STATUS_BG 0x0f /* White */
+#define MSG_BOX_COLOUR 0x0f // White
+#define MSG_BOX_TEXT 0x00 // Black
+#define MSG_BOX_LINE 0x04 // Red
+#define BUTTON_BORDER 0x00 // Black
+#define STATUS_FG 0x00 // Black
+#define STATUS_BG 0x0f // White
#define ADD_PIC 1
#define ADD_VIEW 2
@@ -113,7 +113,7 @@ enum AgiGameID {
} // End of namespace Agi
-/* AGI resources */
+// AGI resources
#include "agi/console.h"
#include "agi/view.h"
#include "agi/picture.h"
@@ -128,13 +128,13 @@ enum AgiGameType {
GType_V3 = 2
};
-/*
- * 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.
- *
- * GF_CLIPCOORDS means that views' coordinates must be clipped at least in commands
- * position and position.v.
- */
+//
+// 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.
+//
+// GF_CLIPCOORDS means that views' coordinates must be clipped at least in commands
+// position and position.v.
+//
enum AgiGameFeatures {
GF_AGIMOUSE = (1 << 0),
GF_AGDS = (1 << 1),
@@ -241,32 +241,32 @@ enum GameId {
* AGI variables.
*/
enum {
- vCurRoom = 0, /* 0 */
+ vCurRoom = 0, // 0
vPrevRoom,
vBorderTouchEgo,
vScore,
vBorderCode,
- vBorderTouchObj, /* 5 */
+ vBorderTouchObj, // 5
vEgoDir,
vMaxScore,
vFreePages,
vWordNotFound,
- vTimeDelay, /* 10 */
+ vTimeDelay, // 10
vSeconds,
vMinutes,
vHours,
vDays,
- vJoystickSensitivity, /* 15 */
+ vJoystickSensitivity, // 15
vEgoViewResource,
vAgiErrCode,
vAgiErrCodeInfo,
vKey,
- vComputer, /* 20 */
+ vComputer, // 20
vWindowReset,
vSoundgen,
vVolume,
vMaxInputChars,
- vSelItem, /* 25 */
+ vSelItem, // 25
vMonitor
};
@@ -315,22 +315,22 @@ enum AgiComputerType {
* AGI flags
*/
enum {
- fEgoWater = 0, /* 0 */
+ fEgoWater = 0, // 0
fEgoInvisible,
fEnteredCli,
fEgoTouchedP2,
fSaidAcceptedInput,
- fNewRoomExec, /* 5 */
+ fNewRoomExec, // 5
fRestartGame,
fScriptBlocked,
fJoySensitivity,
fSoundOn,
- fDebuggerOn, /* 10 */
+ fDebuggerOn, // 10
fLogicZeroFirsttime,
fRestoreJustRan,
fStatusSelectsItems,
fMenusWork,
- fOutputMode, /* 15 */
+ fOutputMode, // 15
fAutoRestart,
fNoSaveLoadAllowed
};
@@ -355,20 +355,20 @@ struct AgiDir {
uint32 offset;
uint32 len;
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;
- /* 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 {
int active;
int x1, y1;
int x2, y2;
- uint8 *buffer; /* used for window background */
+ uint8 *buffer; // used for window background
};
/** AGI text color (Background and foreground color). */
@@ -508,11 +508,11 @@ struct AgiGame {
char id[8]; /**< game id */
uint32 crc; /**< game CRC */
- /* game flags and variables */
+ // game flags and variables
uint8 flags[MAX_FLAGS]; /**< 256 1-bit flags */
uint8 vars[MAX_VARS]; /**< 256 variables */
- /* internal variables */
+ // internal variables
int horizon; /**< horizon y coordinate */
int lineStatus; /**< line number to put status on */
int lineUserInput; /**< line to put user input on */
@@ -529,7 +529,7 @@ struct AgiGame {
int inputEnabled; /**< keyboard input enabled */
int lognum; /**< current logic number */
- /* internal flags */
+ // internal flags
int playerControl; /**< player is in control */
int statusLine; /**< status line on/off */
int clockEnabled; /**< clock is on/off */
@@ -542,13 +542,13 @@ struct AgiGame {
uint8 priTable[_HEIGHT];/**< priority table */
- /* windows */
+ // windows
uint32 msgBoxTicks; /**< timed message box tick counter */
AgiBlock block;
AgiBlock window;
int hasWindow;
- /* graphics & text */
+ // graphics & text
int gfxMode;
char cursorChar;
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 *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];
int numEgoWords;
@@ -571,19 +571,19 @@ struct AgiGame {
AgiEvent evKeyp[MAX_DIRS]; /**< keyboard keypress events */
char strings[MAX_STRINGS + 1][MAX_STRINGLEN]; /**< strings */
- /* directory entries for resources */
+ // directory entries for resources
AgiDir dirLogic[MAX_DIRS];
AgiDir dirPic[MAX_DIRS];
AgiDir dirView[MAX_DIRS];
AgiDir dirSound[MAX_DIRS];
- /* resources */
+ // resources
AgiPicture pictures[MAX_DIRS]; /**< AGI picture resources */
AgiLogic logics[MAX_DIRS]; /**< AGI logic resources */
AgiView views[MAX_DIRS]; /**< AGI view resources */
AgiSound *sounds[MAX_DIRS]; /**< Pointers to AGI sound resources */
- /* view table */
+ // view table
VtEntry viewTable[MAX_VIEWTABLE];
int32 ver; /**< detected game version */
@@ -670,7 +670,7 @@ class SearchTree;
extern struct Mouse g_mouse;
-/* Image stack support */
+// Image stack support
struct ImageStackElement {
uint8 type;
uint8 pad;
@@ -792,7 +792,7 @@ private:
int _firstSlot;
public:
- AgiObject *_objects; /* objects in the game */
+ AgiObject *_objects; // objects in the game
StringData _stringdata;
@@ -817,7 +817,7 @@ public:
SpritesMgr *_sprites;
SoundMgr *_sound;
PictureMgr *_picture;
- AgiLoader *_loader; /* loader */
+ AgiLoader *_loader; // loader
Common::Stack<ImageStackElement> _imageStack;
diff --git a/engines/agi/checks.cpp b/engines/agi/checks.cpp
index 38bffca355..481ce8d18d 100644
--- a/engines/agi/checks.cpp
+++ b/engines/agi/checks.cpp
@@ -23,7 +23,6 @@
*
*/
-
#include "agi/agi.h"
namespace Agi {
@@ -41,7 +40,7 @@ int AgiEngine::checkPosition(VtEntry *v) {
return 0;
}
- /* MH1 needs this, but it breaks LSL1 */
+ // MH1 needs this, but it breaks LSL1
if (agiGetRelease() >= 0x3000) {
if (v->yPos < v->ySize)
return 0;
@@ -66,21 +65,21 @@ int AgiEngine::checkCollision(VtEntry *v) {
if (u->flags & IGNORE_OBJECTS)
continue;
- /* Same object, check next */
+ // Same object, check next
if (v->entry == u->entry)
continue;
- /* No horizontal overlap, check next */
+ // No horizontal overlap, check next
if (v->xPos + v->xSize < u->xPos || v->xPos > u->xPos + u->xSize)
continue;
- /* Same y, return error! */
+ // Same y, return error!
if (v->yPos == u->yPos) {
debugC(4, kDebugLevelSprites, "check returns 1 (object %d)", v->entry);
return 1;
}
- /* Crossed the baseline, return error! */
+ // Crossed the baseline, return error!
if ((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);
@@ -97,7 +96,7 @@ int AgiEngine::checkPriority(VtEntry *v) {
uint8 *p0;
if (~v->flags & FIXED_PRIORITY) {
- /* Priority bands */
+ // Priority bands
v->priority = _game.priTable[v->yPos];
}
@@ -122,17 +121,17 @@ int AgiEngine::checkPriority(VtEntry *v) {
for (i = 0; i < v->xSize; i++, p0++) {
pri = *p0 >> 4;
- if (pri == 0) { /* unconditional black. no go at all! */
+ if (pri == 0) { // unconditional black. no go at all!
pass = 0;
break;
}
- if (pri == 3) /* water surface */
+ if (pri == 3) // water surface
continue;
water = 0;
- if (pri == 1) { /* conditional blue */
+ if (pri == 1) { // conditional blue
if (v->flags & IGNORE_BLOCKS)
continue;
@@ -141,7 +140,7 @@ int AgiEngine::checkPriority(VtEntry *v) {
break;
}
- if (pri == 2) { /* trigger */
+ if (pri == 2) { // trigger
debugC(4, kDebugLevelSprites, "stepped on trigger");
if (!_debug.ignoretriggers)
trigger = 1;
@@ -198,7 +197,7 @@ void AgiEngine::updatePosition() {
x = oldX = v->xPos;
y = oldY = v->yPos;
- /* If object has moved, update its position */
+ // If object has moved, update its position
if (~v->flags & UPDATE_POS) {
int dx[9] = { 0, 0, 1, 1, 1, 0, -1, -1, -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];
}
- /* Now check if it touched the borders */
+ // Now check if it touched the borders
border = 0;
- /* Check left/right borders */
+ // Check left/right borders
if (x < 0) {
x = 0;
border = 4;
- } else if (x <= 0 && agiGetRelease() == 0x3086) { /* KQ4 */
- x = 0; /* See Sarien bug #590462 */
+ } else if (x <= 0 && agiGetRelease() == 0x3086) { // KQ4
+ x = 0; // See Sarien bug #590462
border = 4;
} 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;
border = 4;
} else if (x + v->xSize > _WIDTH) {
@@ -225,7 +224,7 @@ void AgiEngine::updatePosition() {
border = 2;
}
- /* Check top/bottom borders. */
+ // Check top/bottom borders.
if (y - v->ySize + 1 < 0) {
y = v->ySize - 1;
border = 1;
@@ -238,7 +237,7 @@ void AgiEngine::updatePosition() {
border = 1;
}
- /* Test new position. rollback if test fails */
+ // Test new position. rollback if test fails
v->xPos = x;
v->yPos = y;
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);
- /* test horizon */
+ // test horizon
if ((~v->flags & IGNORE_HORIZON) && v->yPos <= _game.horizon)
v->yPos = _game.horizon + 1;
@@ -288,26 +287,26 @@ void AgiEngine::fixPosition(int n) {
while (!checkPosition(v) || checkCollision(v) || !checkPriority(v)) {
switch (dir) {
- case 0: /* west */
+ case 0: // west
v->xPos--;
if (--count)
continue;
dir = 1;
break;
- case 1: /* south */
+ case 1: // south
v->yPos++;
if (--count)
continue;
dir = 2;
size++;
break;
- case 2: /* east */
+ case 2: // east
v->xPos++;
if (--count)
continue;
dir = 3;
break;
- case 3: /* north */
+ case 3: // north
v->yPos--;
if (--count)
continue;
diff --git a/engines/agi/console.cpp b/engines/agi/console.cpp
index 6548772f51..09abb47525 100644
--- a/engines/agi/console.cpp
+++ b/engines/agi/console.cpp
@@ -288,7 +288,7 @@ bool Mickey_Console::Cmd_DrawObj(int argc, const char **argv) {
Winnie_Console::Winnie_Console(PreAgiEngine *vm, Winnie *winnie) : PreAGI_Console(vm) {
_winnie = winnie;
- DCmd_Register("curRoom", WRAP_METHOD(Winnie_Console, Cmd_CurRoom));
+ DCmd_Register("curRoom", WRAP_METHOD(Winnie_Console, Cmd_CurRoom));
}
bool Winnie_Console::Cmd_CurRoom(int argc, const char **argv) {
diff --git a/engines/agi/cycle.cpp b/engines/agi/cycle.cpp
index 6ab1169bbe..2a4b9fa0c3 100644
--- a/engines/agi/cycle.cpp
+++ b/engines/agi/cycle.cpp
@@ -23,7 +23,6 @@
*
*/
-
#include "agi/agi.h"
#include "agi/sprite.h"
#include "agi/graphics.h"
@@ -68,7 +67,7 @@ void AgiEngine::newRoom(int n) {
agiLoadResource(rLOGIC, n);
- /* Reposition ego in the new room */
+ // Reposition ego in the new room
switch (_game.vars[vBorderTouchEgo]) {
case 1:
_game.viewTable[0].yPos = _HEIGHT - 1;
@@ -183,12 +182,12 @@ void AgiEngine::oldInputMode() {
_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() {
unsigned int key, kascii;
VtEntry *v = &_game.viewTable[0];
- _gfx->pollTimer(); /* msdos driver -> does nothing */
+ _gfx->pollTimer(); // msdos driver -> does nothing
updateTimer();
if (_game.ver == 0) {
@@ -198,9 +197,8 @@ int AgiEngine::mainCycle() {
key = doPollKeyboard();
- /* In AGI Mouse emulation mode we must update the mouse-related
- * vars in every interpreter cycle.
- */
+ // In AGI Mouse emulation mode we must update the mouse-related
+ // vars in every interpreter cycle.
if (getFeatures() & GF_AGIMOUSE) {
_game.vars[28] = g_mouse.x / 2;
_game.vars[29] = g_mouse.y;
@@ -220,7 +218,7 @@ int AgiEngine::mainCycle() {
key = 0;
}
- /* Click-to-walk mouse interface */
+ // Click-to-walk mouse interface
if (_game.playerControl && v->flags & ADJ_EGO_XY) {
int toX = v->parm1;
int toY = v->parm2;
@@ -257,25 +255,25 @@ process_key:
break;
handleKeys(key);
- /* if ESC pressed, activate menu before
- * accept.input from the interpreter cycle
- * sets the input mode to normal again
- * (closes: #540856)
- */
+ // if ESC pressed, activate menu before
+ // accept.input from the interpreter cycle
+ // sets the input mode to normal again
+ // (closes: #540856)
if (key == KEY_ESCAPE) {
key = 0;
goto process_key;
}
- /* commented out to close Sarien bug #438872
- * if (key) game.keypress = key;
- */
+ // commented out to close Sarien bug #438872
+ // if (key)
+ // game.keypress = key;
+
}
break;
case INPUT_GETSTRING:
handleController(key);
handleGetstring(key);
- setvar(vKey, 0); /* clear ENTER key */
+ setvar(vKey, 0); // clear ENTER key
break;
case INPUT_MENU:
_menu->keyhandler(key);
@@ -307,10 +305,10 @@ int AgiEngine::playGame() {
_game.horizon = HORIZON;
_game.playerControl = false;
- setflag(fLogicZeroFirsttime, true); /* not in 2.917 */
- setflag(fNewRoomExec, true); /* needed for MUMG and SQ2! */
- setflag(fSoundOn, true); /* enable sound */
- setvar(vTimeDelay, 2); /* "normal" speed */
+ setflag(fLogicZeroFirsttime, true); // not in 2.917
+ setflag(fNewRoomExec, true); // needed for MUMG and SQ2!
+ setflag(fSoundOn, true); // enable sound
+ setvar(vTimeDelay, 2); // "normal" speed
_game.gfxMode = true;
_game.clockEnabled = true;
@@ -378,7 +376,7 @@ int AgiEngine::runGame() {
for (i = 0; i < MAX_DIRS; i++)
memset(&_game.evKeyp[i], 0, sizeof(struct AgiEvent));
- /* Execute the game */
+ // Execute the game
do {
debugC(2, kDebugLevelMain, "game loop");
debugC(2, kDebugLevelMain, "game.ver = 0x%x", _game.ver);
@@ -411,7 +409,7 @@ int AgiEngine::runGame() {
break;
}
- setvar(vSoundgen, 1); /* IBM PC SOUND */
+ setvar(vSoundgen, 1); // IBM PC SOUND
// Set monitor type (v26 i.e. vMonitor)
switch (_renderMode) {
diff --git a/engines/agi/font.h b/engines/agi/font.h
index 8d99aa41b5..e24db80bbf 100644
--- a/engines/agi/font.h
+++ b/engines/agi/font.h
@@ -26,25 +26,23 @@
#ifndef AGI_FONT_H
#define AGI_FONT_H
-
-
#include "agi/agi.h"
namespace Agi {
-/* 8x8 font patterns */
+// 8x8 font patterns
static const uint8 curFont[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x7E, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x7E, /* cursor hollow */
- 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, /* cursor solid */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* cursor empty */
+ 0x7E, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x7E, // cursor hollow
+ 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, // cursor solid
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // cursor empty
0x10, 0x38, 0x7C, 0xFE, 0x7C, 0x38, 0x10, 0x00,
0x3C, 0x3C, 0x18, 0xFF, 0xE7, 0x18, 0x3C, 0x00,
0x10, 0x38, 0x7C, 0xFE, 0xEE, 0x10, 0x38, 0x00,
0x00, 0x00, 0x18, 0x3C, 0x3C, 0x18, 0x00, 0x00,
0xFF, 0xFF, 0xE7, 0xC3, 0xC3, 0xE7, 0xFF, 0xFF,
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,
0x3C, 0x66, 0x66, 0x66, 0x3C, 0x18, 0x7E, 0x18,
0x08, 0x0C, 0x0A, 0x0A, 0x08, 0x78, 0xF0, 0x00,
@@ -161,8 +159,8 @@ static const uint8 curFont[] = {
0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x00,
0xE0, 0x30, 0x30, 0x18, 0x30, 0x30, 0xE0, 0x00,
0x76, 0xDC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- /*0x00, 0x10, 0x38, 0x6C, 0xC6, 0xC6, 0xFE, 0x00, */
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /*replacement 0x7F */
+ //0x00, 0x10, 0x38, 0x6C, 0xC6, 0xC6, 0xFE, 0x00,
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, //replacement 0x7F
0x1E, 0x36, 0x66, 0x66, 0x7E, 0x66, 0x66, 0x00,
0x7C, 0x60, 0x60, 0x7C, 0x66, 0x66, 0x7C, 0x00,
diff --git a/engines/agi/global.cpp b/engines/agi/global.cpp
index 9f38b5d775..ed8e9e8dbe 100644
--- a/engines/agi/global.cpp
+++ b/engines/agi/global.cpp
@@ -23,8 +23,6 @@
*
*/
-
-
#include "agi/agi.h"
namespace Agi {
@@ -41,16 +39,16 @@ void AgiBase::setflag(int n, int v) {
set += n >> 3;
if (v)
- *set |= 1 << (n & 0x07); /* set bit */
+ *set |= 1 << (n & 0x07); // set bit
else
- *set &= ~(1 << (n & 0x07)); /* clear bit */
+ *set &= ~(1 << (n & 0x07)); // clear bit
}
void AgiBase::flipflag(int n) {
uint8 *set = (uint8 *)&_game.flags;
set += n >> 3;
- *set ^= 1 << (n & 0x07); /* flip bit */
+ *set ^= 1 << (n & 0x07); // flip bit
}
void AgiEngine::setvar(int var, int val) {
diff --git a/engines/agi/graphics.cpp b/engines/agi/graphics.cpp
index a4554919de..3be0318cbb 100644
--- a/engines/agi/graphics.cpp
+++ b/engines/agi/graphics.cpp
@@ -505,22 +505,22 @@ static const uint8 vgaPalette[256 * 3] = {
};
static const uint16 cgaMap[16] = {
- 0x0000, /* 0 - black */
- 0x0d00, /* 1 - blue */
- 0x0b00, /* 2 - green */
- 0x0f00, /* 3 - cyan */
- 0x000b, /* 4 - red */
- 0x0b0d, /* 5 - magenta */
- 0x000d, /* 6 - brown */
- 0x0b0b, /* 7 - gray */
- 0x0d0d, /* 8 - dark gray */
- 0x0b0f, /* 9 - light blue */
- 0x0b0d, /* 10 - light green */
- 0x0f0d, /* 11 - light cyan */
- 0x0f0d, /* 12 - light red */
- 0x0f00, /* 13 - light magenta */
- 0x0f0b, /* 14 - yellow */
- 0x0f0f /* 15 - white */
+ 0x0000, // 0 - black
+ 0x0d00, // 1 - blue
+ 0x0b00, // 2 - green
+ 0x0f00, // 3 - cyan
+ 0x000b, // 4 - red
+ 0x0b0d, // 5 - magenta
+ 0x000d, // 6 - brown
+ 0x0b0b, // 7 - gray
+ 0x0d0d, // 8 - dark gray
+ 0x0b0f, // 9 - light blue
+ 0x0b0d, // 10 - light green
+ 0x0f0d, // 11 - light cyan
+ 0x0f0d, // 12 - light red
+ 0x0f00, // 13 - light magenta
+ 0x0f0b, // 14 - yellow
+ 0x0f0f // 15 - white
};
struct UpdateBlock {
@@ -540,22 +540,22 @@ GfxMgr::GfxMgr(AgiBase *vm) : _vm(vm) {
}
-/*
- * Layer 4: 640x480? ================== User display
- * ^
- * | do_update(), put_block()
- * |
- * Layer 3: 640x480? ================== Framebuffer
- * ^
- * | flush_block(), put_pixels()
- * |
- * Layer 2: 320x200 ================== AGI engine screen (console), put_pixel()
- * |
- * Layer 1: 160x336 ================== AGI screen
- *
- * 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).
- */
+//
+// Layer 4: 640x480? ================== User display
+// ^
+// | do_update(), put_block()
+// |
+// Layer 3: 640x480? ================== Framebuffer
+// ^
+// | flush_block(), put_pixels()
+// |
+// Layer 2: 320x200 ================== AGI engine screen (console), put_pixel()
+// |
+// Layer 1: 160x336 ================== AGI screen
+//
+// 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).
+//
#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;
}
- /* FIXME: we don't want this when we're writing on the
- * console!
- */
+ // FIXME: we don't want this when we're writing on the
+ // console!
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;
uint8 *p0;
- /* top line */
+ // top line
w = x2 - x1 + 1;
p0 = &_agiScreen[x1 + y1 * GFX_WIDTH];
memset(p0, c1, w);
- /* bottom line */
+ // bottom line
p0 = &_agiScreen[x1 + y2 * GFX_WIDTH];
memset(p0, c2, w);
- /* side lines */
+ // side lines
for (y = y1; y <= y2; y++) {
_agiScreen[x1 + y * GFX_WIDTH] = c1;
_agiScreen[x2 + y * GFX_WIDTH] = c2;
@@ -890,7 +889,7 @@ int GfxMgr::getAGIPalFileNum() {
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) {
if (x1 >= GFX_WIDTH)
x1 = GFX_WIDTH - 1;
@@ -1151,7 +1150,7 @@ void GfxMgr::doUpdate() {
gfxPutBlock(update.x1, update.y1, update.x2, update.y2);
}
- /* reset update block variables */
+ // reset update block variables
update.x1 = MAX_INT;
update.y1 = MAX_INT;
update.x2 = 0;
diff --git a/engines/agi/id.cpp b/engines/agi/id.cpp
index 1ce665d900..0f53fd44db 100644
--- a/engines/agi/id.cpp
+++ b/engines/agi/id.cpp
@@ -41,13 +41,13 @@ int AgiEngine::v2IdGame() {
return setupV2Game(ver, 0);
}
-/*
- * Currently, there is no known difference between v3.002.098 -> v3.002.149
- * So version emulated;
- *
- * 0x0086,
- * 0x0149
- */
+//
+// Currently, there is no known difference between v3.002.098 -> v3.002.149
+// So version emulated;
+//
+// 0x0086,
+// 0x0149
+//
int AgiEngine::v3IdGame() {
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
// even for AGDS games? -- dsymonds
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);
diff --git a/engines/agi/inv.cpp b/engines/agi/inv.cpp
index e1b864c2b5..dad1548cd9 100644
--- a/engines/agi/inv.cpp
+++ b/engines/agi/inv.cpp
@@ -23,8 +23,6 @@
*
*/
-
-
#include "agi/agi.h"
#include "agi/sprite.h"
#include "agi/graphics.h"
@@ -32,9 +30,9 @@
namespace Agi {
-/*
- * Messages and coordinates
- */
+//
+// Messages and coordinates
+//
#define NOTHING_X 16
#define NOTHING_Y 3
@@ -92,7 +90,7 @@ int AgiEngine::showItems() {
for (x = i = 0; x < _game.numObjects; x++) {
if (objectGetLocation(x) == EGO_OWNED) {
- /* add object to our list! */
+ // add object to our list!
_intobj[i] = x;
printItem(i, STATUS_FG, STATUS_BG);
i++;
@@ -182,7 +180,7 @@ void AgiEngine::inventory() {
int oldFg, oldBg;
int n;
- /* screen is white with black text */
+ // screen is white with black text
oldFg = _game.colorFg;
oldBg = _game.colorBg;
_game.colorFg = 0;
@@ -198,7 +196,7 @@ void AgiEngine::inventory() {
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);
memset(_intobj, 0, (4 + _game.numObjects));
@@ -224,10 +222,9 @@ void AgiEngine::inventory() {
_gfx->flushScreen();
- /* If flag 13 is set, we want to highlight & select an item.
- * opon selection, put objnum in var 25. Then on esc put in
- * var 25 = 0xff.
- */
+ // If flag 13 is set, we want to highlight & select an item.
+ // opon selection, put objnum in var 25. Then on esc put in
+ // var 25 = 0xff.
if (getflag(fStatusSelectsItems))
selectItems(n);
diff --git a/engines/agi/keyboard.cpp b/engines/agi/keyboard.cpp
index 3bbdc95192..b498466442 100644
--- a/engines/agi/keyboard.cpp
+++ b/engines/agi/keyboard.cpp
@@ -35,36 +35,36 @@
namespace Agi {
-/*
- * IBM-PC keyboard scancodes
- */
+//
+// IBM-PC keyboard scancodes
+//
uint8 scancodeTable[26] = {
- 30, /* A */
- 48, /* B */
- 46, /* C */
- 32, /* D */
- 18, /* E */
- 33, /* F */
- 34, /* G */
- 35, /* H */
- 23, /* I */
- 36, /* J */
- 37, /* K */
- 38, /* L */
- 50, /* M */
- 49, /* N */
- 24, /* O */
- 25, /* P */
- 16, /* Q */
- 19, /* R */
- 31, /* S */
- 20, /* T */
- 22, /* U */
- 47, /* V */
- 17, /* W */
- 45, /* X */
- 21, /* Y */
- 44 /* Z */
+ 30, // A
+ 48, // B
+ 46, // C
+ 32, // D
+ 18, // E
+ 33, // F
+ 34, // G
+ 35, // H
+ 23, // I
+ 36, // J
+ 37, // K
+ 38, // L
+ 50, // M
+ 49, // N
+ 24, // O
+ 25, // P
+ 16, // Q
+ 19, // R
+ 31, // S
+ 20, // T
+ 22, // U
+ 47, // V
+ 17, // W
+ 45, // X
+ 21, // Y
+ 44 // Z
};
void AgiEngine::initWords() {
@@ -93,7 +93,7 @@ void AgiEngine::getString(int x, int y, int len, int str) {
int AgiEngine::doPollKeyboard() {
int key = 0;
- /* If a key is ready, rip it */
+ // If a key is ready, rip it
if (_gfx->keypress()) {
key = _gfx->getKey();
@@ -114,8 +114,9 @@ int AgiEngine::handleController(int key) {
return false;
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
+ }
debugC(3, kDebugLevelInput, "key = %04x", key);
@@ -184,7 +185,7 @@ int AgiEngine::handleController(int key) {
}
if (!(getFeatures() & GF_AGIMOUSE)) {
- /* Handle mouse button events */
+ // Handle mouse button events
if (key == BUTTON_LEFT) {
v->flags |= ADJ_EGO_XY;
v->parm1 = WIN_TO_PIC_X(g_mouse.x);
@@ -205,7 +206,7 @@ int AgiEngine::handleController(int key) {
}
void AgiEngine::handleGetstring(int key) {
- static int pos = 0; /* Cursor position */
+ static int pos = 0; // Cursor position
static char buf[40];
if (KEY_ASCII(key) == 0)
@@ -230,9 +231,11 @@ void AgiEngine::handleGetstring(int key) {
debugC(3, kDebugLevelInput, "KEY_ENTER");
_game.hasPrompt = 0;
buf[pos] = 0;
+
strcpy(_game.strings[_stringdata.str], buf);
debugC(3, kDebugLevelInput, "buffer=[%s]", buf);
buf[pos = 0] = 0;
+
newInputMode(INPUT_NORMAL);
_gfx->printCharacter(_stringdata.x + strlen(_game.strings[_stringdata.str]) + 1,
_stringdata.y, ' ', _game.colorFg, _game.colorBg);
@@ -241,11 +244,13 @@ void AgiEngine::handleGetstring(int key) {
debugC(3, kDebugLevelInput, "KEY_ESCAPE");
_game.hasPrompt = 0;
buf[pos = 0] = 0;
+
strcpy(_game.strings[_stringdata.str], buf);
newInputMode(INPUT_NORMAL);
- /* newInputMode(INPUT_MENU); */
+
+ // newInputMode(INPUT_MENU);
break;
- case KEY_BACKSPACE: /*0x08: */
+ case KEY_BACKSPACE: // 0x08
if (!pos)
break;
@@ -264,14 +269,14 @@ void AgiEngine::handleGetstring(int key) {
buf[pos++] = key;
buf[pos] = 0;
- /* Echo */
+ // Echo
_gfx->printCharacter(_stringdata.x + pos, _stringdata.y, buf[pos - 1],
_game.colorFg, _game.colorBg);
break;
}
- /* print cursor */
+ // print cursor
_gfx->printCharacter(_stringdata.x + pos + 1, _stringdata.y,
(char)_game.cursorChar, _game.colorFg, _game.colorBg);
}
@@ -293,13 +298,13 @@ void AgiEngine::handleKeys(int key) {
debugC(3, kDebugLevelInput, "KEY_ENTER");
_game.keypress = 0;
- /* Remove all leading spaces */
+ // Remove all leading spaces
for (p = _game.inputBuffer; *p && *p == 0x20; p++)
;
- /* Copy to internal buffer */
+ // Copy to internal buffer
for (; *p; p++) {
- /* Squash spaces */
+ // Squash spaces
if (*p == 0x20 && *(p + 1) == 0x20) {
p++;
continue;
@@ -308,14 +313,14 @@ void AgiEngine::handleKeys(int key) {
}
formattedEntry[c++] = 0;
- /* Handle string only if it's not empty */
+ // Handle string only if it's not empty
if (formattedEntry[0]) {
strcpy((char *)_game.echoBuffer, (const char *)_game.inputBuffer);
strcpy(_lastSentence, (const char *)formattedEntry);
dictionaryWords(_lastSentence);
}
- /* Clear to start a new line */
+ // Clear to start a new line
_game.hasPrompt = 0;
_game.inputBuffer[_game.cursorPos = 0] = 0;
debugC(3, kDebugLevelInput, "clear lines");
@@ -331,14 +336,15 @@ void AgiEngine::handleKeys(int key) {
newInputMode(INPUT_MENU);
break;
case KEY_BACKSPACE:
- /* Ignore backspace at start of line */
+ // Ignore backspace at start of line
if (_game.cursorPos == 0)
break;
- /* erase cursor */
+ // erase cursor
_gfx->printCharacter(_game.cursorPos + promptLength, l, ' ', fg, bg);
_game.inputBuffer[--_game.cursorPos] = 0;
- /* Print cursor */
+
+ // Print cursor
_gfx->printCharacter(_game.cursorPos + promptLength, l, _game.cursorChar, fg, bg);
#ifdef __DS__
@@ -346,11 +352,11 @@ void AgiEngine::handleKeys(int key) {
#endif
break;
default:
- /* Ignore invalid keystrokes */
+ // Ignore invalid keystrokes
if (key < 0x20 || key > 0x7f)
break;
- /* Maximum input size reached */
+ // Maximum input size reached
if (_game.cursorPos >= getvar(vMaxInputChars))
break;
@@ -361,10 +367,10 @@ void AgiEngine::handleKeys(int key) {
DS::findWordCompletions((char *) _game.inputBuffer);
#endif
- /* echo */
+ // echo
_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);
break;
}
@@ -373,14 +379,14 @@ void AgiEngine::handleKeys(int key) {
int AgiEngine::waitKey() {
int key = 0;
- /* clear key queue */
+ // clear key queue
while (_gfx->keypress()) {
_gfx->getKey();
}
debugC(3, kDebugLevelInput, "waiting...");
while (!(shouldQuit() || restartGame || getflag(fRestoreJustRan))) {
- _gfx->pollTimer(); /* msdos driver -> does nothing */
+ _gfx->pollTimer(); // msdos driver -> does nothing
key = doPollKeyboard();
if (key == KEY_ENTER || key == KEY_ESCAPE || key == BUTTON_LEFT)
break;
@@ -396,14 +402,14 @@ int AgiEngine::waitKey() {
int AgiEngine::waitAnyKey() {
int key = 0;
- /* clear key queue */
+ // clear key queue
while (_gfx->keypress()) {
_gfx->getKey();
}
debugC(3, kDebugLevelInput, "waiting... (any key)");
while (!(shouldQuit() || restartGame)) {
- _gfx->pollTimer(); /* msdos driver -> does nothing */
+ _gfx->pollTimer(); // msdos driver -> does nothing
key = doPollKeyboard();
if (key)
break;
diff --git a/engines/agi/keyboard.h b/engines/agi/keyboard.h
index 5a96364acd..bc1706b280 100644
--- a/engines/agi/keyboard.h
+++ b/engines/agi/keyboard.h
@@ -26,8 +26,6 @@
#ifndef AGI_KEYBOARD_H
#define AGI_KEYBOARD_H
-
-
namespace Agi {
#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
-/* Allegro defines these */
+// Allegro defines these
#undef KEY_BACKSPACE
#undef KEY_ENTER
#undef KEY_LEFT
@@ -79,24 +77,24 @@ public:
#define KEY_UP_LEFT 0x4700
#define KEY_UP_RIGHT 0x4900
-#define KEY_STATUSLN 0xd900 /* F11 */
-#define KEY_PRIORITY 0xda00 /* F12 */
+#define KEY_STATUSLN 0xd900 // F11
+#define KEY_PRIORITY 0xda00 // F12
-#define KEY_PGUP 0x4900 /* Page Up (fixed by Ziv Barber) */
-#define KEY_PGDN 0x5100 /* Page Down */
-#define KEY_HOME 0x4700 /* Home */
-#define KEY_END 0x4f00 /* End * */
+#define KEY_PGUP 0x4900 // Page Up (fixed by Ziv Barber)
+#define KEY_PGDN 0x5100 // Page Down
+#define KEY_HOME 0x4700 // Home
+#define KEY_END 0x4f00 // End *
-#define BUTTON_LEFT 0xF101 /* Left mouse button */
-#define BUTTON_RIGHT 0xF202 /* Right mouse button */
-#define WHEEL_UP 0xF203 /* Mouse wheel up */
-#define WHEEL_DOWN 0xF204 /* Mouse wheel down */
+#define BUTTON_LEFT 0xF101 // Left mouse button
+#define BUTTON_RIGHT 0xF202 // Right mouse button
+#define WHEEL_UP 0xF203 // Mouse wheel up
+#define WHEEL_DOWN 0xF204 // Mouse wheel down
#define KEY_SCAN(k) (k >> 8)
#define KEY_ASCII(k) (k & 0xff)
extern uint8 scancodeTable[];
-} // End of namespace Agi
+} // End of namespace Agi
#endif /* AGI_KEYBOARD_H */
diff --git a/engines/agi/loader_v2.cpp b/engines/agi/loader_v2.cpp
index 2ace4e7e6b..15e27f6939 100644
--- a/engines/agi/loader_v2.cpp
+++ b/engines/agi/loader_v2.cpp
@@ -48,7 +48,7 @@ int AgiLoader_v2::detectGame() {
!Common::File::exists(VIEWDIR))
return errInvalidAGIFile;
- _intVersion = 0x2917; /* setup for 2.917 */
+ _intVersion = 0x2917; // setup for 2.917
return _vm->v2IdGame();
}
@@ -75,13 +75,13 @@ int AgiLoader_v2::loadDir(AgiDir *agid, const char *fname) {
fp.read(mem, flen);
- /* set all directory resources to gone */
+ // set all directory resources to gone
for (i = 0; i < MAX_DIRS; i++) {
agid[i].volume = 0xff;
agid[i].offset = _EMPTY;
}
- /* build directory entries */
+ // build directory entries
for (i = 0; i < flen; i += 3) {
agid[i / 3].volume = *(mem + i) >> 4;
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 ec = errOK;
- /* load directory files */
+ // load directory files
ec = loadDir(_vm->_game.dirLogic, LOGDIR);
if (ec == errOK)
ec = loadDir(_vm->_game.dirPic, PICDIR);
@@ -113,10 +113,10 @@ int AgiLoader_v2::deinit() {
int ec = errOK;
#if 0
- /* unload words */
+ // unload words
agiV2UnloadWords();
- /* unload objects */
+ // unload objects
agiV2UnloadObjects();
#endif
@@ -144,7 +144,7 @@ int AgiLoader_v2::unloadResource(int t, int n) {
return errOK;
}
-/*
+/**
* This function does noting but load a raw resource into memory,
* if further decoding is required, it must be done by another
* routine. NULL is returned if unsucsessfull.
@@ -178,15 +178,15 @@ uint8 *AgiLoader_v2::loadVolRes(struct AgiDir *agid) {
}
fp.close();
} else {
- /* we have a bad volume resource */
- /* set that resource to NA */
+ // we have a bad volume resource
+ // set that resource to NA
agid->offset = _EMPTY;
}
return data;
}
-/*
+/**
* Loads a resource into memory, a raw resource is loaded in
* 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);
unloadResource(rLOGIC, n);
- /* load raw resource into data */
+ // load raw resource into data
data = loadVolRes(&_vm->_game.dirLogic[n]);
_vm->_game.logics[n].data = data;
@@ -213,22 +213,21 @@ int AgiLoader_v2::loadResource(int t, int n) {
_vm->_game.logics[n].sIP = 2;
}
- /* if logic was cached, we get here */
- /* reset code pointers incase it was cached */
+ // if logic was cached, we get here
+ // reset code pointers incase it was cached
_vm->_game.logics[n].cIP = _vm->_game.logics[n].sIP;
break;
case rPICTURE:
- /* if picture is currently NOT loaded *OR* cacheing is off,
- * unload the resource (caching == off) and reload it
- */
+ // if picture is currently NOT loaded *OR* cacheing is off,
+ // unload the resource (caching == off) and reload it
debugC(3, kDebugLevelResources, "loading picture resource %d", n);
if (_vm->_game.dirPic[n].flags & RES_LOADED)
break;
- /* if loaded but not cached, unload it */
- /* if cached but not loaded, etc */
+ // if loaded but not cached, unload it
+ // if cached but not loaded, etc
unloadResource(rPICTURE, n);
data = loadVolRes(&_vm->_game.dirPic[n]);
@@ -255,11 +254,10 @@ int AgiLoader_v2::loadResource(int t, int n) {
}
break;
case rVIEW:
- /* Load a VIEW resource into memory...
- * Since VIEWS alter the view table ALL the time
- * can we cache the view? or must we reload it all
- * the time?
- */
+ // Load a VIEW resource into memory...
+ // Since VIEWS alter the view table ALL the time
+ // can we cache the view? or must we reload it all
+ // the time?
if (_vm->_game.dirView[n].flags & RES_LOADED)
break;
diff --git a/engines/agi/loader_v3.cpp b/engines/agi/loader_v3.cpp
index e784dad323..5829476c13 100644
--- a/engines/agi/loader_v3.cpp
+++ b/engines/agi/loader_v3.cpp
@@ -89,13 +89,13 @@ int AgiLoader_v3::loadDir(struct AgiDir *agid, Common::File *fp,
if ((mem = (uint8 *)malloc(len + 32)) != NULL) {
fp->read(mem, len);
- /* set all directory resources to gone */
+ // set all directory resources to gone
for (i = 0; i < MAX_DIRS; i++) {
agid[i].volume = 0xff;
agid[i].offset = _EMPTY;
}
- /* build directory entries */
+ // build directory entries
for (i = 0; i < len; i += 3) {
agid[i / 3].volume = *(mem + i) >> 4;
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());
return errBadFileOpen;
}
- /* build offset table for v3 directory format */
+ // build offset table for v3 directory format
fp.read(&xd, 8);
fp.seek(0, SEEK_END);
@@ -153,7 +153,7 @@ int AgiLoader_v3::init() {
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);
if (ec == errOK) {
@@ -175,10 +175,10 @@ int AgiLoader_v3::deinit() {
int ec = errOK;
#if 0
- /* unload words */
+ // unload words
agiV3UnloadWords();
- /* unload objects */
+ // unload objects
agiV3UnloadObjects();
#endif
@@ -204,7 +204,7 @@ int AgiLoader_v3::unloadResource(int t, int n) {
return errOK;
}
-/*
+/**
* This function does noting but load a raw resource into memory.
* If further decoding is required, it must be done by another
* routine.
@@ -234,28 +234,27 @@ uint8 *AgiLoader_v3::loadVolRes(AgiDir *agid) {
_vm->quitGame();
}
- agid->len = READ_LE_UINT16((uint8 *) x + 3); /* uncompressed size */
- agid->clen = READ_LE_UINT16((uint8 *) x + 5); /* compressed len */
+ agid->len = READ_LE_UINT16((uint8 *) x + 3); // uncompressed size
+ agid->clen = READ_LE_UINT16((uint8 *) x + 5); // compressed len
compBuffer = (uint8 *)calloc(1, agid->clen + 32);
fp.read(compBuffer, agid->clen);
if (x[2] & 0x80 || agid->len == agid->clen) {
- /* do not decompress */
+ // do not decompress
data = compBuffer;
#if 0
- /* CM: added to avoid problems in
- * convert_v2_v3_pic() when clen > len
- * e.g. Sierra demo 4, first picture
- * (Tue Mar 16 13:13:43 EST 1999)
- */
+ // CM: added to avoid problems in
+ // convert_v2_v3_pic() when clen > len
+ // e.g. Sierra demo 4, first picture
+ // (Tue Mar 16 13:13:43 EST 1999)
agid->len = agid->clen;
- /* Now removed to fix Gold Rush! in demo4 */
+ // Now removed to fix Gold Rush! in demo4
#endif
} else {
- /* it is compressed */
+ // it is compressed
data = (uint8 *)calloc(1, agid->len + 32);
lzwExpand(compBuffer, data, agid->len);
free(compBuffer);
@@ -264,15 +263,15 @@ uint8 *AgiLoader_v3::loadVolRes(AgiDir *agid) {
fp.close();
} else {
- /* we have a bad volume resource */
- /* set that resource to NA */
+ // we have a bad volume resource
+ // set that resource to NA
agid->offset = _EMPTY;
}
return data;
}
-/*
+/**
* Loads a resource into memory, a raw resource is loaded in
* with above routine, then further decoded here.
*/
@@ -285,42 +284,40 @@ int AgiLoader_v3::loadResource(int t, int n) {
switch (t) {
case rLOGIC:
- /* load resource into memory, decrypt messages at the end
- * and build the message list (if logic is in memory)
- */
+ // load resource into memory, decrypt messages at the end
+ // and build the message list (if logic is in memory)
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);
- /* load raw resource into data */
+ // load raw resource into data
data = loadVolRes(&_vm->_game.dirLogic[n]);
_vm->_game.logics[n].data = data;
- /* uncompressed logic files need to be decrypted */
+ // uncompressed logic files need to be decrypted
if (data != NULL) {
- /* resloaded flag gets set by decode logic */
- /* needed to build string table */
+ // resloaded flag gets set by decode logic
+ // needed to build string table
ec = _vm->decodeLogic(n);
_vm->_game.logics[n].sIP = 2;
} else {
ec = errBadResource;
}
- /*logics[n].sIP=2; *//* saved IP = 2 */
- /*logics[n].cIP=2; *//* current IP = 2 */
+ // logics[n].sIP=2; // saved IP = 2
+ // logics[n].cIP=2; // current IP = 2
_vm->_game.logics[n].cIP = _vm->_game.logics[n].sIP;
}
- /* if logic was cached, we get here */
- /* reset code pointers incase it was cached */
+ // if logic was cached, we get here
+ // reset code pointers incase it was cached
_vm->_game.logics[n].cIP = _vm->_game.logics[n].sIP;
break;
case rPICTURE:
- /* if picture is currently NOT loaded *OR* cacheing is off,
- * unload the resource (caching==off) and reload it
- */
+ // if picture is currently NOT loaded *OR* cacheing is off,
+ // unload the resource (caching==off) and reload it
if (~_vm->_game.dirPic[n].flags & RES_LOADED) {
unloadResource(rPICTURE, n);
data = loadVolRes(&_vm->_game.dirPic[n]);
@@ -347,11 +344,11 @@ int AgiLoader_v3::loadResource(int t, int n) {
}
break;
case rVIEW:
- /* Load a VIEW resource into memory...
- * Since VIEWS alter the view table ALL the time can we
- * cache the view? or must we reload it all the time?
- */
- /* load a raw view from a VOL file into data */
+ // Load a VIEW resource into memory...
+ // Since VIEWS alter the view table ALL the time can we
+ // cache the view? or must we reload it all the time?
+ //
+ // load a raw view from a VOL file into data
if (_vm->_game.dirView[n].flags & RES_LOADED)
break;
diff --git a/engines/agi/logic.cpp b/engines/agi/logic.cpp
index 4d7cc330c9..cc61d3455a 100644
--- a/engines/agi/logic.cpp
+++ b/engines/agi/logic.cpp
@@ -23,8 +23,6 @@
*
*/
-
-
#include "agi/agi.h"
namespace Agi {
@@ -40,52 +38,50 @@ int AgiEngine::decodeLogic(int n) {
int mstart, mend, mc;
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;
mstart = READ_LE_UINT16(m0) + 2;
mc = *(m0 + mstart);
mend = READ_LE_UINT16(m0 + mstart + 1);
- m0 += mstart + 3; /* cover header info */
+ m0 += mstart + 3; // cover header info
mstart = mc << 1;
- /* if the logic was not compressed, decrypt the text messages
- * only if there are more than 0 messages
- */
+ // if the logic was not compressed, decrypt the text messages
+ // only if there are more than 0 messages
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;
- mstart = READ_LE_UINT16(m0) + 2; /* +2 covers pointer */
+ mstart = READ_LE_UINT16(m0) + 2; // +2 covers pointer
_game.logics[n].numTexts = *(m0 + mstart);
- /* resetp logic pointers */
+ // resetp logic pointers
_game.logics[n].sIP = 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 *));
- /* cover header info */
+ // cover header info
m0 += mstart + 3;
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++) {
mend = READ_LE_UINT16(m0 + mc * 2);
_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;
} else {
- /* unload data
- * Note that not every logic has text
- */
+ // unload data
+ // Note that not every logic has text
free(_game.logics[n].data);
ec = errNotEnoughMemory;
}
@@ -108,7 +104,7 @@ void AgiEngine::unloadLogic(int n) {
_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].cIP = 2;
}
diff --git a/engines/agi/lzw.cpp b/engines/agi/lzw.cpp
index a101ebb9f6..bc2f169322 100644
--- a/engines/agi/lzw.cpp
+++ b/engines/agi/lzw.cpp
@@ -41,21 +41,21 @@
namespace Agi {
#define MAXBITS 12
-#define TABLE_SIZE 18041 /* strange number */
+#define TABLE_SIZE 18041 // strange number
#define START_BITS 9
static int32 BITS, MAX_VALUE, MAX_CODE;
static uint32 *prefixCode;
static uint8 *appendCharacter;
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 void initLZW() {
decodeStack = (uint8 *)calloc(1, 8192);
prefixCode = (uint32 *)malloc(TABLE_SIZE * sizeof(uint32));
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;
}
@@ -141,18 +141,18 @@ void lzwExpand(uint8 *in, uint8 *out, int32 len) {
initLZW();
- setBits(START_BITS); /* Starts at 9-bits */
- lzwnext = 257; /* Next available code to define */
+ setBits(START_BITS); // Starts at 9-bits
+ lzwnext = 257; // Next available code to define
end = (uint8 *)(out + (uint32)len);
- lzwold = inputCode(&in); /* Read in the first code */
+ lzwold = inputCode(&in); // Read in the first code
c = lzwold;
lzwnew = inputCode(&in);
while ((out < end) && (lzwnew != 0x101)) {
if (lzwnew == 0x100) {
- /* Code to "start over" */
+ // Code to "start over"
lzwnext = 258;
setBits(START_BITS);
lzwold = inputCode(&in);
@@ -161,15 +161,14 @@ void lzwExpand(uint8 *in, uint8 *out, int32 len) {
lzwnew = inputCode(&in);
} else {
if (lzwnew >= lzwnext) {
- /* Handles special LZW scenario */
+ // Handles special LZW scenario
*decodeStack = c;
s = decodeString(decodeStack + 1, lzwold);
} else
s = decodeString(decodeStack, lzwnew);
- /* Reverse order of decoded string and
- * store in out buffer
- */
+ // Reverse order of decoded string and
+ // store in out buffer
c = *s;
while (s >= decodeStack)
*out++ = *s--;
diff --git a/engines/agi/menu.cpp b/engines/agi/menu.cpp
index 916c4c184f..a408999124 100644
--- a/engines/agi/menu.cpp
+++ b/engines/agi/menu.cpp
@@ -23,8 +23,6 @@
*
*/
-
-
#include "agi/agi.h"
#include "agi/sprite.h"
#include "agi/graphics.h"
@@ -66,6 +64,7 @@ AgiMenu *Menu::getMenu(int i) {
AgiMenuOption *Menu::getMenuOption(int i, int j) {
AgiMenu *m = getMenu(i);
MenuOptionList::iterator iter;
+
for (iter = m->down.begin(); iter != m->down.end(); ++iter) {
AgiMenuOption* d = *iter;
if (d->index == j)
@@ -82,6 +81,7 @@ void Menu::drawMenuBar() {
MenuList::iterator iter;
for (iter = _menubar.begin(); iter != _menubar.end(); ++iter) {
AgiMenu *m = *iter;
+
_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) {
AgiMenu *m = getMenu(curMenu);
+
debugC(6, kDebugLevelMenu, "[%s]", m->text);
+
_vm->printText(m->text, 0, m->col, 0, 40, MENU_BG, MENU_FG);
_vm->flushLines(0, 0);
}
-/* draw box and pulldowns. */
+// draw box and pulldowns.
void Menu::drawMenuOption(int hMenu) {
- /* find which vertical menu it is */
+ // find which vertical menu it is
AgiMenu *m = getMenu(hMenu);
_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);
MenuOptionList::iterator iter;
+
for (iter = m->down.begin(); iter != m->down.end(); ++iter) {
AgiMenuOption* d = *iter;
+
_vm->printText(d->text, 0, m->wincol + 1, d->index + 2, m->width + 2,
MENU_FG, MENU_BG, !d->enabled);
}
@@ -180,17 +184,24 @@ Menu::~Menu() {
MenuList::iterator iterh;
for (iterh = _menubar.reverse_begin(); iterh != _menubar.end(); ) {
AgiMenu *m = *iterh;
+
debugC(3, kDebugLevelMenu, "deiniting hmenu %s", m->text);
+
MenuOptionList::iterator iterv;
+
for (iterv = m->down.reverse_begin(); iterv != m->down.end(); ) {
AgiMenuOption *d = *iterv;
+
debugC(3, kDebugLevelMenu, " deiniting vmenu %s", d->text);
+
free(d->text);
delete d;
+
iterv = m->down.reverse_erase(iterv);
}
free(m->text);
delete m;
+
iterh = _menubar.reverse_erase(iterh);
}
}
@@ -198,8 +209,10 @@ Menu::~Menu() {
void Menu::add(const char *s) {
AgiMenu *m = new AgiMenu;
m->text = strdup(s);
+
while (m->text[strlen(m->text) - 1] == ' ')
m->text[strlen(m->text) - 1] = 0;
+
m->width = 0;
m->height = 0;
m->index = _hIndex++;
@@ -218,6 +231,7 @@ void Menu::addItem(const char *s, int code) {
int l;
AgiMenuOption* d = new AgiMenuOption;
+
d->text = strdup(s);
d->enabled = true;
d->event = code;
@@ -239,22 +253,26 @@ void Menu::addItem(const char *s, int code) {
m->width = l;
debugC(3, kDebugLevelMenu, "Adding menu item: %s (size = %d)", s, m->height);
+
m->down.push_back(d);
}
void Menu::submit() {
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;
for (iter = _menubar.reverse_begin(); iter != _menubar.end(); ) {
AgiMenu *m = *iter;
+
if (m->down.empty()) {
free(m->text);
delete m;
+
_hMaxMenu--;
+
iter = _menubar.reverse_erase(iter);
} else {
--iter;
@@ -275,20 +293,23 @@ bool Menu::keyhandler(int key) {
_vm->_game.clockEnabled = false;
drawMenuBar();
}
- /*
- * Mouse handling
- */
+ //
+ // Mouse handling
+ //
if (g_mouse.button) {
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) {
- /* on the menubar */
+ // on the menubar
hmenu = 0;
MenuList::iterator iterh;
+
for (iterh = _menubar.begin(); iterh != _menubar.end(); ++iterh) {
AgiMenu *m = *iterh;
+
if (mouseOverText(0, m->col, m->text)) {
break;
} else {
@@ -304,13 +325,16 @@ bool Menu::keyhandler(int key) {
_hCurMenu = hmenu;
}
} else {
- /* not in menubar */
+ // not in menubar
vmenu = 0;
AgiMenu *m = getMenu(_hCurMenu);
+
MenuOptionList::iterator iterv;
+
for (iterv = m->down.begin(); iterv != m->down.end(); ++iterv) {
AgiMenuOption *do1 = *iterv;
+
if (mouseOverText(2 + do1->index, m->wincol + 1, do1->text)) {
break;
} else {
@@ -327,7 +351,7 @@ bool Menu::keyhandler(int key) {
}
}
} else if (buttonUsed) {
- /* Button released */
+ // Button released
buttonUsed = 0;
debugC(6, kDebugLevelMenu | kDebugLevelInput, "button released!");
@@ -338,15 +362,17 @@ bool Menu::keyhandler(int key) {
drawMenuOptionHilite(_hCurMenu, _vCurMenu);
if (g_mouse.y <= CHAR_LINES) {
- /* on the menubar */
+ // on the menubar
} else {
- /* see which option we selected */
+ // see which option we selected
AgiMenu *m = getMenu(_hCurMenu);
MenuOptionList::iterator iterv;
+
for (iterv = m->down.begin(); iterv != m->down.end(); ++iterv) {
AgiMenuOption *d = *iterv;
+
if (mouseOverText(2 + d->index, m->wincol + 1, d->text)) {
- /* activate that option */
+ // activate that option
if (d->enabled) {
debugC(6, kDebugLevelMenu | kDebugLevelInput, "event %d registered", d->event);
_vm->_game.evKeyp[d->event].occured = true;
@@ -383,6 +409,7 @@ bool Menu::keyhandler(int key) {
{
debugC(6, kDebugLevelMenu | kDebugLevelInput, "KEY_ENTER");
AgiMenuOption* d = getMenuOption(_hCurMenu, _vCurMenu);
+
if (d->enabled) {
debugC(6, kDebugLevelMenu | kDebugLevelInput, "event %d registered", d->event);
_vm->_game.evKeyp[d->event].occured = true;
@@ -428,6 +455,7 @@ exit_menu:
_vm->_game.keypress = 0;
_vm->_game.clockEnabled = clockVal;
_vm->oldInputMode();
+
debugC(3, kDebugLevelMenu, "exit_menu: input mode reset to %d", _vm->_game.inputMode);
menuActive = false;
@@ -435,15 +463,18 @@ exit_menu:
}
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);
MenuList::iterator iterh;
+
for (iterh = _menubar.begin(); iterh != _menubar.end(); ++iterh) {
AgiMenu *m = *iterh;
MenuOptionList::iterator iterv;
+
for (iterv = m->down.begin(); iterv != m->down.end(); ++iterv) {
AgiMenuOption *d = *iterv;
+
if (d->event == event) {
d->enabled = state;
// 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) {
AgiMenu *m = *iterh;
MenuOptionList::iterator iterv;
+
for (iterv = m->down.begin(); iterv != m->down.end(); ++iterv) {
AgiMenuOption *d = *iterv;
+
d->enabled = true;
}
}
diff --git a/engines/agi/menu.h b/engines/agi/menu.h
index d27dfa497d..69c7f7f3a8 100644
--- a/engines/agi/menu.h
+++ b/engines/agi/menu.h
@@ -30,11 +30,11 @@
namespace Agi {
-#define MENU_BG 0x0f /* White */
-#define MENU_DISABLED 0x07 /* Grey */
+#define MENU_BG 0x0f // White
+#define MENU_DISABLED 0x07 // Grey
-#define MENU_FG 0x00 /* Black */
-#define MENU_LINE 0x00 /* Black */
+#define MENU_FG 0x00 // Black
+#define MENU_LINE 0x00 // Black
struct AgiMenu;
struct AgiMenuOption;
diff --git a/engines/agi/motion.cpp b/engines/agi/motion.cpp
index 58d4eb4a6d..214ebccddd 100644
--- a/engines/agi/motion.cpp
+++ b/engines/agi/motion.cpp
@@ -23,8 +23,6 @@
*
*/
-
-
#include "agi/agi.h"
namespace Agi {
@@ -76,7 +74,7 @@ void AgiEngine::motionWander(VtEntry *v) {
if (isEgoView(v)) {
_game.vars[vEgoDir] = v->direction;
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;
objY = v->yPos;
- /* Get direction to reach ego */
+ // Get direction to reach ego
dir = getDirection(objX, objY, egoX, egoY, v->parm1);
- /* Already at ego coordinates */
+ // Already at ego coordinates
if (dir == 0) {
v->direction = 0;
v->motion = MOTION_NORMAL;
@@ -126,12 +124,12 @@ void AgiEngine::motionFollowEgo(VtEntry *v) {
if (v->parm3 != 0) {
int k;
- /* DF: this is ugly and I dont know why this works, but
- * other line does not! (watcom complained about lvalue)
- *
- * if (((int8)v->parm3 -= v->step_size) < 0)
- * v->parm3 = 0;
- */
+ // DF: this is ugly and I dont know why this works, but
+ // other line does not! (watcom complained about lvalue)
+ //
+ // if (((int8)v->parm3 -= v->step_size) < 0)
+ // v->parm3 = 0;
+
k = v->parm3;
k -= v->stepSize;
v->parm3 = k;
@@ -146,7 +144,7 @@ void AgiEngine::motionFollowEgo(VtEntry *v) {
void AgiEngine::motionMoveObj(VtEntry *v) {
v->direction = getDirection(v->xPos, v->yPos, v->parm1, v->parm2, v->stepSize);
- /* Update V6 if ego */
+ // Update V6 if ego
if (isEgoView(v))
_game.vars[vEgoDir] = v->direction;
diff --git a/engines/agi/objects.cpp b/engines/agi/objects.cpp
index eb33259b82..6897c4d4d3 100644
--- a/engines/agi/objects.cpp
+++ b/engines/agi/objects.cpp
@@ -44,9 +44,8 @@ int AgiEngine::decodeObjects(uint8 *mem, uint32 flen) {
_game.numObjects = 0;
_objects = NULL;
- /* check if first pointer exceeds file size
- * if so, its encrypted, else it is not
- */
+ // check if first pointer exceeds file size
+ // if so, its encrypted, else it is not
if (READ_LE_UINT16(mem) > flen) {
report("Decrypting objects... ");
@@ -54,11 +53,10 @@ int AgiEngine::decodeObjects(uint8 *mem, uint32 flen) {
report("done.\n");
}
- /* alloc memory for object list
- * byte 3 = number of animated objects. this is ignored.. ??
- */
+ // alloc memory for object list
+ // byte 3 = number of animated objects. this is ignored.. ??
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;
}
@@ -68,7 +66,7 @@ int AgiEngine::decodeObjects(uint8 *mem, uint32 flen) {
if (allocObjects(_game.numObjects) != errOK)
return errNotEnoughMemory;
- /* build the object list */
+ // build the object list
for (i = 0, so = padsize; i < _game.numObjects; i++, so += padsize) {
int offset;
diff --git a/engines/agi/op_cmd.cpp b/engines/agi/op_cmd.cpp
index 1ac8ec5ce3..03b1accce8 100644
--- a/engines/agi/op_cmd.cpp
+++ b/engines/agi/op_cmd.cpp
@@ -57,7 +57,7 @@ namespace Agi {
static struct AgiLogic *curLogic;
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 cmd(x) static void cmd_##x (uint8 *p)
@@ -291,7 +291,7 @@ cmd(release_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) {
@@ -497,23 +497,23 @@ cmd(load_game) {
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) {
g_agi->messageBox("Enough memory");
}
-cmd(init_joy) { /* do nothing */ ;
+cmd(init_joy) { // do nothing
}
cmd(script_size) {
@@ -600,15 +600,14 @@ cmd(obj_status_f) {
g_agi->messageBox(msg);
}
-/* unknown commands:
- * unk_170: Force savegame name -- j5
- * unk_171: script save -- j5
- * unk_172: script restore -- j5
- * unk_173: Activate keypressed control (ego only moves while key is pressed)
- * unk_174: Change priority table (used in KQ4) -- j5
- * unk_177: Disable menus completely -- j5
- * unk_181: Deactivate keypressed control (default control of ego)
- */
+// unknown commands:
+// unk_170: Force savegame name -- j5
+// unk_171: script save -- j5
+// unk_172: script restore -- j5
+// unk_173: Activate keypressed control (ego only moves while key is pressed)
+// unk_174: Change priority table (used in KQ4) -- j5
+// unk_177: Disable menus completely -- j5
+// unk_181: Deactivate keypressed control (default control of ego)
cmd(set_simple) {
if (!(g_agi->getFeatures() & (GF_AGI256 | GF_AGI256_2))) {
game.simpleSave = true;
@@ -723,9 +722,8 @@ cmd(call) {
int oldCIP;
int oldLognum;
- /* CM: we don't save sIP because set.scan.start can be
- * used in a called script (fixes xmas demo)
- */
+ // CM: we don't save sIP because set.scan.start can be
+ // used in a called script (fixes xmas demo)
oldCIP = curLogic->cIP;
oldLognum = game.lognum;
@@ -766,10 +764,12 @@ cmd(draw_pic) {
cmd(show_pic) {
debugC(6, kDebugLevelScripts, "=== show pic ===");
+
g_agi->setflag(fOutputMode, false);
cmd_close_window(NULL);
g_picture->showPic();
game.pictureShown = 1;
+
debugC(6, kDebugLevelScripts, "--- end of show pic ---");
}
@@ -781,11 +781,12 @@ cmd(load_pic) {
cmd(discard_pic) {
debugC(6, kDebugLevelScripts, "--- discard pic ---");
- /* do nothing */
+ // do nothing
}
cmd(overlay_pic) {
debugC(6, kDebugLevelScripts, "--- overlay pic ---");
+
g_sprites->eraseBoth();
g_picture->decodePicture(_v[p0], false);
g_sprites->blitBoth();
@@ -798,7 +799,9 @@ cmd(show_pri_screen) {
g_sprites->eraseBoth();
g_picture->showPic();
g_sprites->blitBoth();
+
g_agi->waitKey();
+
g_agi->_debug.priority = 0;
g_sprites->eraseBoth();
g_picture->showPic();
@@ -818,6 +821,7 @@ cmd(animate_obj) {
cmd(unanimate_all) {
int i;
+
for (i = 0; i < MAX_VIEWTABLE; i++)
game.viewTable[i].flags &= ~(ANIMATED | DRAWN);
}
@@ -836,6 +840,7 @@ cmd(draw) {
g_agi->setLoop(&vt, vt.currentLoop);
g_agi->setCel(&vt, vt.currentCel);
}
+
g_agi->fixPosition(p0);
vt.xPos2 = vt.xPos;
vt.yPos2 = vt.yPos;
@@ -854,7 +859,7 @@ cmd(draw) {
// 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
// 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;
g_sprites->blitUpdSprites();
@@ -870,6 +875,7 @@ cmd(erase) {
return;
g_sprites->eraseUpdSprites();
+
if (vt.flags & UPDATE) {
vt.flags &= ~DRAWN;
} else {
@@ -1002,7 +1008,7 @@ cmd(normal_motion) {
cmd(stop_motion) {
vt.direction = 0;
vt.motion = MOTION_NORMAL;
- if (p0 == 0) { /* ego only */
+ if (p0 == 0) { // ego only
_v[vEgoDir] = 0;
game.playerControl = false;
}
@@ -1010,7 +1016,7 @@ cmd(stop_motion) {
cmd(start_motion) {
vt.motion = MOTION_NORMAL;
- if (p0 == 0) { /* ego only */
+ if (p0 == 0) { // ego only
_v[vEgoDir] = 0;
game.playerControl = true;
}
@@ -1035,7 +1041,7 @@ cmd(follow_ego) {
}
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.parm1 = p1;
@@ -1052,7 +1058,7 @@ cmd(move_obj) {
if (p0 == 0)
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)
g_agi->moveObj(&vt);
}
@@ -1073,7 +1079,7 @@ cmd(move_obj_f) {
if (p0 == 0)
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)
g_agi->moveObj(&vt);
}
@@ -1081,6 +1087,7 @@ cmd(move_obj_f) {
cmd(wander) {
if (p0 == 0)
game.playerControl = false;
+
vt.motion = MOTION_WANDER;
vt.flags |= UPDATE;
}
@@ -1114,12 +1121,14 @@ cmd(pause) {
cmd(set_menu) {
debugC(4, kDebugLevelScripts, "text %02x of %02x", p0, curLogic->numTexts);
+
if (curLogic->texts != NULL && p0 <= curLogic->numTexts)
g_agi->_menu->add(curLogic->texts[p0 - 1]);
}
cmd(set_menu_item) {
debugC(4, kDebugLevelScripts, "text %02x of %02x", p0, curLogic->numTexts);
+
if (curLogic->texts != NULL && p0 <= curLogic->numTexts)
g_agi->_menu->addItem(curLogic->texts[p0 - 1], p1);
}
@@ -1134,7 +1143,7 @@ cmd(version) {
"\n"
" \n\n"
" Emulating AGI v%x.002.%03x\n";
- /* no Sierra as it wraps textbox */
+ // no Sierra as it wraps textbox
char *r, *q;
int ver, maj, min;
char msg[256];
@@ -1150,9 +1159,10 @@ cmd(version) {
q = maj == 2 ? ver2Msg : ver3Msg;
r = strchr(q + 1, '\n');
- /* insert our version into the other version */
+ // insert our version into the other version
len = strlen(verMsg);
gap = r - q;
+
if (gap < 0)
gap = 0;
else
@@ -1172,17 +1182,18 @@ cmd(configure_screen) {
cmd(text_screen) {
debugC(4, kDebugLevelScripts, "switching to text mode");
game.gfxMode = false;
- /*
- * Simulates the "bright background bit" of the PC video
- * controller.
- */
+
+ // Simulates the "bright background bit" of the PC video
+ // controller.
if (game.colorBg)
game.colorBg |= 0x08;
+
g_gfx->clearScreen(game.colorBg);
}
cmd(graphics) {
debugC(4, kDebugLevelScripts, "switching to graphics mode");
+
if (!game.gfxMode) {
game.gfxMode = true;
g_gfx->clearScreen(0);
@@ -1290,6 +1301,7 @@ cmd(distance) {
cmd(accept_input) {
debugC(4, kDebugLevelScripts | kDebugLevelInput, "input normal");
+
g_agi->newInputMode(INPUT_NORMAL);
game.inputEnabled = true;
g_agi->writePrompt();
@@ -1297,6 +1309,7 @@ cmd(accept_input) {
cmd(prevent_input) {
debugC(4, kDebugLevelScripts | kDebugLevelInput, "no input");
+
g_agi->newInputMode(INPUT_NONE);
game.inputEnabled = false;
}
@@ -1310,9 +1323,8 @@ cmd(get_string) {
row = p2;
col = p3;
- /* Workaround for SQLC bug.
- * See Sarien bug #792125 for details
- */
+ // Workaround for SQLC bug.
+ // See Sarien bug #792125 for details
if (row > 24)
row = 24;
if (col > 39)
@@ -1322,10 +1334,11 @@ cmd(get_string) {
if (curLogic->texts != NULL && curLogic->numTexts >= tex) {
int len = strlen(curLogic->texts[tex]);
+
g_agi->printText(curLogic->texts[tex], 0, col, row, len, game.colorFg, game.colorBg);
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);
}
@@ -1336,14 +1349,16 @@ cmd(get_string) {
cmd(get_num) {
debugC(4, kDebugLevelScripts, "%d %d", p0, p1);
+
g_agi->newInputMode(INPUT_GETSTRING);
if (curLogic->texts != NULL && curLogic->numTexts >= (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->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);
}
@@ -1352,7 +1367,9 @@ cmd(get_num) {
} while (game.inputMode == INPUT_GETSTRING && !(g_agi->shouldQuit() || g_agi->restartGame));
_v[p1] = atoi(game.strings[MAX_STRINGS]);
+
debugC(4, kDebugLevelScripts, "[%s] -> %d", game.strings[MAX_STRINGS], _v[p1]);
+
g_agi->clearLines(22, 22, game.colorBg);
g_agi->flushLines(22, 22);
}
@@ -1361,7 +1378,7 @@ cmd(set_cursor_char) {
if (curLogic->texts != NULL && (p0 - 1) <= curLogic->numTexts) {
game.cursorChar = *curLogic->texts[p0 - 1];
} else {
- /* default */
+ // default
game.cursorChar = '_';
}
}
@@ -1371,7 +1388,7 @@ cmd(set_key) {
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;
key = 256 * p1 + p0;
@@ -1380,7 +1397,7 @@ cmd(set_key) {
}
cmd(set_string) {
- /* CM: to avoid crash in Groza (str = 150) */
+ // CM: to avoid crash in Groza (str = 150)
if (p0 > MAX_STRINGS)
return;
strcpy(game.strings[p0], curLogic->texts[p1 - 1]);
@@ -1406,12 +1423,13 @@ cmd(clear_text_rect) {
if ((c = p4) != 0)
c = 15;
+
x1 = p1 * CHAR_COLS;
y1 = p0 * CHAR_LINES;
x2 = (p3 + 1) * CHAR_COLS - 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)
x1 = GFX_WIDTH - 1;
if (x2 > GFX_WIDTH)
@@ -1438,7 +1456,7 @@ cmd(echo_line) {
cmd(clear_lines) {
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;
// Agent06 incorrectly calls clear.lines(1,150,0), see ScummVM bugs
@@ -1451,22 +1469,27 @@ cmd(clear_lines) {
cmd(print) {
int n = p0 < 1 ? 1 : p0;
+
g_agi->print(curLogic->texts[n - 1], 0, 0, 0);
}
cmd(print_f) {
int n = _v[p0] < 1 ? 1 : _v[p0];
+
g_agi->print(curLogic->texts[n - 1], 0, 0, 0);
}
cmd(print_at) {
int n = p0 < 1 ? 1 : p0;
+
debugC(4, kDebugLevelScripts, "%d %d %d %d", p0, p1, p2, p3);
+
g_agi->print(curLogic->texts[n - 1], p1, p2, p3);
}
cmd(print_at_v) {
int n = _v[p0] < 1 ? 1 : _v[p0];
+
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);
- /* game.alt_pri = true; */
+ // game.alt_pri = true;
x = (_HEIGHT - p0) * _HEIGHT / 10;
for (i = 0; i < _HEIGHT; i++) {
@@ -1521,7 +1544,7 @@ cmd(shake_screen) {
g_gfx->shakeStart();
- g_sprites->commitBoth(); /* Fixes SQ1 demo */
+ g_sprites->commitBoth(); // Fixes SQ1 demo
for (i = 4 * p0; i; i--) {
g_gfx->shakeScreen(i & 1);
g_gfx->flushBlock(0, 0, GFX_WIDTH - 1, GFX_HEIGHT - 1);
@@ -1529,12 +1552,12 @@ cmd(shake_screen) {
}
g_gfx->shakeEnd();
- //Sets input back to what it was
+ // Sets input back to what it was
game.inputEnabled = originalValue;
}
static void (*agiCommand[183])(uint8 *) = {
- NULL, /* 0x00 */
+ NULL, // 0x00
cmd_increment,
cmd_decrement,
cmd_assignn,
@@ -1542,7 +1565,7 @@ static void (*agiCommand[183])(uint8 *) = {
cmd_addn,
cmd_addv,
cmd_subn,
- cmd_subv, /* 0x08 */
+ cmd_subv, // 0x08
cmd_lindirectv,
cmd_rindirect,
cmd_lindirectn,
@@ -1550,7 +1573,7 @@ static void (*agiCommand[183])(uint8 *) = {
cmd_reset,
cmd_toggle,
cmd_set_v,
- cmd_reset_v, /* 0x10 */
+ cmd_reset_v, // 0x10
cmd_toggle_v,
cmd_new_room,
cmd_new_room_f,
@@ -1558,7 +1581,7 @@ static void (*agiCommand[183])(uint8 *) = {
cmd_load_logic_f,
cmd_call,
cmd_call_f,
- cmd_load_pic, /* 0x18 */
+ cmd_load_pic, // 0x18
cmd_draw_pic,
cmd_show_pic,
cmd_discard_pic,
@@ -1566,7 +1589,7 @@ static void (*agiCommand[183])(uint8 *) = {
cmd_show_pri_screen,
cmd_load_view,
cmd_load_view_f,
- cmd_discard_view, /* 0x20 */
+ cmd_discard_view, // 0x20
cmd_animate_obj,
cmd_unanimate_all,
cmd_draw,
@@ -1574,7 +1597,7 @@ static void (*agiCommand[183])(uint8 *) = {
cmd_position,
cmd_position_f,
cmd_get_posn,
- cmd_reposition, /* 0x28 */
+ cmd_reposition, // 0x28
cmd_set_view,
cmd_set_view_f,
cmd_set_loop,
@@ -1582,7 +1605,7 @@ static void (*agiCommand[183])(uint8 *) = {
cmd_fix_loop,
cmd_release_loop,
cmd_set_cel,
- cmd_set_cel_f, /* 0x30 */
+ cmd_set_cel_f, // 0x30
cmd_last_cel,
cmd_current_cel,
cmd_current_loop,
@@ -1590,7 +1613,7 @@ static void (*agiCommand[183])(uint8 *) = {
cmd_number_of_loops,
cmd_set_priority,
cmd_set_priority_f,
- cmd_release_priority, /* 0x38 */
+ cmd_release_priority, // 0x38
cmd_get_priority,
cmd_stop_update,
cmd_start_update,
@@ -1598,7 +1621,7 @@ static void (*agiCommand[183])(uint8 *) = {
cmd_ignore_horizon,
cmd_observe_horizon,
cmd_set_horizon,
- cmd_object_on_water, /* 0x40 */
+ cmd_object_on_water, // 0x40
cmd_object_on_land,
cmd_object_on_anything,
cmd_ignore_objs,
@@ -1606,7 +1629,7 @@ static void (*agiCommand[183])(uint8 *) = {
cmd_distance,
cmd_stop_cycling,
cmd_start_cycling,
- cmd_normal_cycle, /* 0x48 */
+ cmd_normal_cycle, // 0x48
cmd_end_of_loop,
cmd_reverse_cycle,
cmd_reverse_loop,
@@ -1614,7 +1637,7 @@ static void (*agiCommand[183])(uint8 *) = {
cmd_stop_motion,
cmd_start_motion,
cmd_step_size,
- cmd_step_time, /* 0x50 */
+ cmd_step_time, // 0x50
cmd_move_obj,
cmd_move_obj_f,
cmd_follow_ego,
@@ -1622,7 +1645,7 @@ static void (*agiCommand[183])(uint8 *) = {
cmd_normal_motion,
cmd_set_dir,
cmd_get_dir,
- cmd_ignore_blocks, /* 0x58 */
+ cmd_ignore_blocks, // 0x58
cmd_observe_blocks,
cmd_block,
cmd_unblock,
@@ -1630,7 +1653,7 @@ static void (*agiCommand[183])(uint8 *) = {
cmd_get_f,
cmd_drop,
cmd_put,
- cmd_put_f, /* 0x60 */
+ cmd_put_f, // 0x60
cmd_get_room_f,
cmd_load_sound,
cmd_sound,
@@ -1638,7 +1661,7 @@ static void (*agiCommand[183])(uint8 *) = {
cmd_print,
cmd_print_f,
cmd_display,
- cmd_display_f, /* 0x68 */
+ cmd_display_f, // 0x68
cmd_clear_lines,
cmd_text_screen,
cmd_graphics,
@@ -1646,7 +1669,7 @@ static void (*agiCommand[183])(uint8 *) = {
cmd_set_text_attribute,
cmd_shake_screen,
cmd_configure_screen,
- cmd_status_line_on, /* 0x70 */
+ cmd_status_line_on, // 0x70
cmd_status_line_off,
cmd_set_string,
cmd_get_string,
@@ -1654,7 +1677,7 @@ static void (*agiCommand[183])(uint8 *) = {
cmd_parse,
cmd_get_num,
cmd_prevent_input,
- cmd_accept_input, /* 0x78 */
+ cmd_accept_input, // 0x78
cmd_set_key,
cmd_add_to_pic,
cmd_add_to_pic_f,
@@ -1662,7 +1685,7 @@ static void (*agiCommand[183])(uint8 *) = {
cmd_save_game,
cmd_load_game,
cmd_init_disk,
- cmd_restart_game, /* 0x80 */
+ cmd_restart_game, // 0x80
cmd_show_obj,
cmd_random,
cmd_program_control,
@@ -1670,7 +1693,7 @@ static void (*agiCommand[183])(uint8 *) = {
cmd_obj_status_f,
cmd_quit,
cmd_show_mem,
- cmd_pause, /* 0x88 */
+ cmd_pause, // 0x88
cmd_echo_line,
cmd_cancel_line,
cmd_init_joy,
@@ -1678,7 +1701,7 @@ static void (*agiCommand[183])(uint8 *) = {
cmd_version,
cmd_script_size,
cmd_set_game_id,
- cmd_log, /* 0x90 */
+ cmd_log, // 0x90
cmd_set_scan_start,
cmd_reset_scan_start,
cmd_reposition_to,
@@ -1686,7 +1709,7 @@ static void (*agiCommand[183])(uint8 *) = {
cmd_trace_on,
cmd_trace_info,
cmd_print_at,
- cmd_print_at_v, /* 0x98 */
+ cmd_print_at_v, // 0x98
cmd_discard_view,
cmd_clear_text_rect,
cmd_set_upper_left,
@@ -1694,7 +1717,7 @@ static void (*agiCommand[183])(uint8 *) = {
cmd_set_menu_item,
cmd_submit_menu,
cmd_enable_item,
- cmd_disable_item, /* 0xa0 */
+ cmd_disable_item, // 0xa0
cmd_menu_input,
cmd_show_obj_v,
cmd_open_dialogue,
@@ -1702,7 +1725,7 @@ static void (*agiCommand[183])(uint8 *) = {
cmd_mul_n,
cmd_mul_v,
cmd_div_n,
- cmd_div_v, /* 0xa8 */
+ cmd_div_v, // 0xa8
cmd_close_window,
cmd_set_simple,
cmd_push_script,
@@ -1710,7 +1733,7 @@ static void (*agiCommand[183])(uint8 *) = {
cmd_hold_key,
cmd_set_pri_base,
cmd_discard_sound,
- cmd_hide_mouse, /* 0xb0 */
+ cmd_hide_mouse, // 0xb0
cmd_allow_menu,
cmd_show_mouse,
cmd_fence_mouse,
@@ -1732,7 +1755,7 @@ int AgiEngine::runLogic(int n) {
g_agi = this;
int num = 0;
- /* If logic not loaded, load it */
+ // If logic not loaded, load it
if (~_game.dirLogic[n].flags & RES_LOADED) {
debugC(4, kDebugLevelScripts, "logic %d not loaded!", n);
agiLoadResource(rLOGIC, n);
@@ -1762,22 +1785,22 @@ int AgiEngine::runLogic(int n) {
}
switch (op = *(code + ip++)) {
- case 0xff: /* if (open/close) */
+ case 0xff: // if (open/close)
testIfCode(n);
break;
- case 0xfe: /* goto */
- /* +2 covers goto size */
+ case 0xfe: // goto
+ // +2 covers goto size
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) {
g_gfx->pollTimer();
updateTimer();
timerHack = 0;
}
break;
- case 0x00: /* return */
+ case 0x00: // return
return 1;
default:
num = logicNamesCmd[op].numArgs;
@@ -1793,7 +1816,7 @@ int AgiEngine::runLogic(int n) {
break;
}
- return 0; /* after executing new.room() */
+ return 0; // after executing new.room()
}
void AgiEngine::executeAgiCommand(uint8 op, uint8 *p) {
diff --git a/engines/agi/op_dbg.cpp b/engines/agi/op_dbg.cpp
index cd7442c81c..7ed8e2bd17 100644
--- a/engines/agi/op_dbg.cpp
+++ b/engines/agi/op_dbg.cpp
@@ -23,8 +23,6 @@
*
*/
-
-
#include "agi/agi.h"
#include "agi/opcodes.h"
@@ -58,7 +56,7 @@ struct AgiLogicnames logicNamesTest[] = {
_L("controller", 1, 0x00),
_L("have.key", 0, 0x00),
- /* Not 0 args. Has variable number. */
+ // Not 0 args. Has variable number.
_L("said", 0, 0x00),
_L("compare.strings", 2, 0x00),
@@ -66,7 +64,7 @@ struct AgiLogicnames logicNamesTest[] = {
_L("center.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)
};
@@ -78,200 +76,200 @@ struct AgiLogicnames logicNamesIf[] = {
};
struct AgiLogicnames logicNamesCmd[] = {
- _L("return", 0, 0x00), /* 00 */
- _L("increment", 1, 0x80), /* 01 */
- _L("decrement", 1, 0x80), /* 02 */
- _L("assignn", 2, 0x80), /* 03 */
- _L("assignv", 2, 0xC0), /* 04 */
- _L("addn", 2, 0x80), /* 05 */
- _L("addv", 2, 0xC0), /* 06 */
- _L("subn", 2, 0x80), /* 07 */
- _L("subv", 2, 0xC0), /* 08 */
- _L("lindirectv", 2, 0xC0), /* 09 */
- _L("rindirect", 2, 0xC0), /* 0A */
- _L("lindirectn", 2, 0x80), /* 0B */
- _L("set", 1, 0x00), /* 0C */
- _L("reset", 1, 0x00), /* 0D */
- _L("toggle", 1, 0x00), /* 0E */
- _L("set.v", 1, 0x80), /* 0F */
- _L("reset.v", 1, 0x80), /* 10 */
- _L("toggle.v", 1, 0x80), /* 11 */
- _L("new.room", 1, 0x00), /* 12 */
- _L("new.room.v", 1, 0x80), /* 13 */
- _L("load.logics", 1, 0x00), /* 14 */
- _L("load.logics.v", 1, 0x80), /* 15 */
- _L("call", 1, 0x00), /* 16 */
- _L("call.v", 1, 0x80), /* 17 */
- _L("load.pic", 1, 0x80), /* 18 */
- _L("draw.pic", 1, 0x80), /* 19 */
- _L("show.pic", 0, 0x00), /* 1A */
- _L("discard.pic", 1, 0x80), /* 1B */
- _L("overlay.pic", 1, 0x80), /* 1C */
- _L("show.pri.screen", 0, 0x00), /* 1D */
- _L("load.view", 1, 0x00), /* 1E */
- _L("load.view.v", 1, 0x80), /* 1F */
- _L("discard.view", 1, 0x00), /* 20 */
- _L("animate.obj", 1, 0x00), /* 21 */
- _L("unanimate.all", 0, 0x00), /* 22 */
- _L("draw", 1, 0x00), /* 23 */
- _L("erase", 1, 0x00), /* 24 */
- _L("position", 3, 0x00), /* 25 */
- _L("position.v", 3, 0x60), /* 26 */
- _L("get.posn", 3, 0x60), /* 27 */
- _L("reposition", 3, 0x60), /* 28 */
- _L("set.view", 2, 0x00), /* 29 */
- _L("set.view.v", 2, 0x40), /* 2A */
- _L("set.loop", 2, 0x00), /* 2B */
- _L("set.loop.v", 2, 0x40), /* 2C */
- _L("fix.loop", 1, 0x00), /* 2D */
- _L("release.loop", 1, 0x00), /* 2E */
- _L("set.cel", 2, 0x00), /* 2F */
- _L("set.cel.v", 2, 0x40), /* 30 */
- _L("last.cel", 2, 0x40), /* 31 */
- _L("current.cel", 2, 0x40), /* 32 */
- _L("current.loop", 2, 0x40), /* 33 */
- _L("current.view", 2, 0x40), /* 34 */
- _L("number.of.loops", 2, 0x40), /* 35 */
- _L("set.priority", 2, 0x00), /* 36 */
- _L("set.priority.v", 2, 0x40), /* 37 */
- _L("release.priority", 1, 0x00), /* 38 */
- _L("get.priority", 2, 0x40), /* 39 */
- _L("stop.update", 1, 0x00), /* 3A */
- _L("start.update", 1, 0x00), /* 3B */
- _L("force.update", 1, 0x00), /* 3C */
- _L("ignore.horizon", 1, 0x00), /* 3D */
- _L("observe.horizon", 1, 0x00), /* 3E */
- _L("set.horizon", 1, 0x00), /* 3F */
- _L("object.on.water", 1, 0x00), /* 40 */
- _L("object.on.land", 1, 0x00), /* 41 */
- _L("object.on.anything", 1, 0x00), /* 42 */
- _L("ignore.objs", 1, 0x00), /* 43 */
- _L("observe.objs", 1, 0x00), /* 44 */
- _L("distance", 3, 0x20), /* 45 */
- _L("stop.cycling", 1, 0x00), /* 46 */
- _L("start.cycling", 1, 0x00), /* 47 */
- _L("normal.cycle", 1, 0x00), /* 48 */
- _L("end.of.loop", 2, 0x00), /* 49 */
- _L("reverse.cycle", 1, 0x00), /* 4A */
- _L("reverse.loop", 2, 0x00), /* 4B */
- _L("cycle.time", 2, 0x40), /* 4C */
- _L("stop.motion", 1, 0x00), /* 4D */
- _L("start.motion", 1, 0x00), /* 4E */
- _L("step.size", 2, 0x40), /* 4F */
- _L("step.time", 2, 0x40), /* 50 */
- _L("move.obj", 5, 0x00), /* 51 */
- _L("move.obj.v", 5, 0x70), /* 52 */
- _L("follow.ego", 3, 0x00), /* 53 */
- _L("wander", 1, 0x00), /* 54 */
- _L("normal.motion", 1, 0x00), /* 55 */
- _L("set.dir", 2, 0x40), /* 56 */
- _L("get.dir", 2, 0x40), /* 57 */
- _L("ignore.blocks", 1, 0x00), /* 58 */
- _L("observe.blocks", 1, 0x00), /* 59 */
- _L("block", 4, 0x00), /* 5A */
- _L("unblock", 0, 0x00), /* 5B */
- _L("get", 1, 0x00), /* 5C */
- _L("get.v", 1, 0x80), /* 5D */
- _L("drop", 1, 0x00), /* 5E */
- _L("put", 2, 0x00), /* 5F */
- _L("put.v", 2, 0x40), /* 60 */
- _L("get.room.v", 2, 0xC0), /* 61 */
- _L("load.sound", 1, 0x00), /* 62 */
- _L("sound", 2, 0x00), /* 63 */
- _L("stop.sound", 0, 0x00), /* 64 */
- _L("print", 1, 0x00), /* 65 */
- _L("print.v", 1, 0x80), /* 66 */
- _L("display", 3, 0x00), /* 67 */
- _L("display.v", 3, 0xE0), /* 68 */
- _L("clear.lines", 3, 0x00), /* 69 */
- _L("text.screen", 0, 0x00), /* 6A */
- _L("graphics", 0, 0x00), /* 6B */
- _L("set.cursor.char", 1, 0x00), /* 6C */
- _L("set.text.attribute", 2, 0x00), /* 6D */
- _L("shake.screen", 1, 0x00), /* 6E */
- _L("configure.screen", 3, 0x00), /* 6F */
- _L("status.line.on", 0, 0x00), /* 70 */
- _L("status.line.off", 0, 0x00), /* 71 */
- _L("set.string", 2, 0x00), /* 72 */
- _L("get.string", 5, 0x00), /* 73 */
- _L("word.to.string", 2, 0x00), /* 74 */
- _L("parse", 1, 0x00), /* 75 */
- _L("get.num", 2, 0x40), /* 76 */
- _L("prevent.input", 0, 0x00), /* 77 */
- _L("accept.input", 0, 0x00), /* 78 */
- _L("set.key", 3, 0x00), /* 79 */
- _L("add.to.pic", 7, 0x00), /* 7A */
- _L("add.to.pic.v", 7, 0xFE), /* 7B */
- _L("status", 0, 0x00), /* 7C */
- _L("save.game", 0, 0x00), /* 7D */
- _L("restore.game", 0, 0x00), /* 7E */
- _L("init.disk", 0, 0x00), /* 7F */
- _L("restart.game", 0, 0x00), /* 80 */
- _L("show.obj", 1, 0x00), /* 81 */
- _L("random", 3, 0x20), /* 82 */
- _L("program.control", 0, 0x00), /* 83 */
- _L("player.control", 0, 0x00), /* 84 */
- _L("obj.status.v", 1, 0x80), /* 85 */
- /* 0 args for AGI version 2.089 */
- _L("quit", 1, 0x00), /* 86 */
-
- _L("show.mem", 0, 0x00), /* 87 */
- _L("pause", 0, 0x00), /* 88 */
- _L("echo.line", 0, 0x00), /* 89 */
- _L("cancel.line", 0, 0x00), /* 8A */
- _L("init.joy", 0, 0x00), /* 8B */
- _L("toggle.monitor", 0, 0x00), /* 8C */
- _L("version", 0, 0x00), /* 8D */
- _L("script.size", 1, 0x00), /* 8E */
- _L("set.game.id", 1, 0x00), /* 8F */
- _L("log", 1, 0x00), /* 90 */
- _L("set.scan.start", 0, 0x00), /* 91 */
- _L("reset.scan.start", 0, 0x00), /* 92 */
- _L("reposition.to", 3, 0x00), /* 93 */
- _L("reposition.to.v", 3, 0x60), /* 94 */
- _L("trace.on", 0, 0x00), /* 95 */
- _L("trace.info", 3, 0x00), /* 96 */
-
- /* 3 args for AGI versions before 2.440 */
- _L("print.at", 4, 0x00), /* 97 */
- _L("print.at.v", 4, 0x80), /* 98 */
-
- _L("discard.view.v", 1, 0x80), /* 99 */
- _L("clear.text.rect", 5, 0x00), /* 9A */
- _L("set.upper.left", 2, 0x00), /* 9B */
- _L("set.menu", 1, 0x00), /* 9C */
- _L("set.menu.item", 2, 0x00), /* 9D */
- _L("submit.menu", 0, 0x00), /* 9E */
- _L("enable.item", 1, 0x00), /* 9F */
- _L("disable.item", 1, 0x00), /* A0 */
- _L("menu.input", 0, 0x00), /* A1 */
- _L("show.obj.v", 1, 0x01), /* A2 */
- _L("open.dialogue", 0, 0x00), /* A3 */
- _L("close.dialogue", 0, 0x00), /* A4 */
- _L("mul.n", 2, 0x80), /* A5 */
- _L("mul.v", 2, 0xC0), /* A6 */
- _L("div.n", 2, 0x80), /* A7 */
- _L("div.v", 2, 0xC0), /* A8 */
- _L("close.window", 0, 0x00), /* A9 */
-
- _L("set.simple", 1, 0x00), /* AA */
- _L("push.script", 0, 0x00), /* AB */
- _L("pop.script", 0, 0x00), /* AC */
- _L("hold.key", 0, 0x00), /* AD */
- _L("set.pri.base", 1, 0x00), /* AE */
- _L("discard.sound", 1, 0x00), /* AF */
-
- /* 1 arg for AGI version 3.002.086 */
- _L("hide.mouse", 0, 0x00), /* B0 */
-
- _L("allow.menu", 1, 0x00), /* B1 */
- _L("show.mouse", 0, 0x00), /* B2 */
- _L("fence.mouse", 4, 0x00), /* B3 */
- _L("mouse.posn", 2, 0x00), /* B4 */
- _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. */
- _L("adj.ego.move.to.xy", 0, 0x00), /* B6 */
+ _L("return", 0, 0x00), // 00
+ _L("increment", 1, 0x80), // 01
+ _L("decrement", 1, 0x80), // 02
+ _L("assignn", 2, 0x80), // 03
+ _L("assignv", 2, 0xC0), // 04
+ _L("addn", 2, 0x80), // 05
+ _L("addv", 2, 0xC0), // 06
+ _L("subn", 2, 0x80), // 07
+ _L("subv", 2, 0xC0), // 08
+ _L("lindirectv", 2, 0xC0), // 09
+ _L("rindirect", 2, 0xC0), // 0A
+ _L("lindirectn", 2, 0x80), // 0B
+ _L("set", 1, 0x00), // 0C
+ _L("reset", 1, 0x00), // 0D
+ _L("toggle", 1, 0x00), // 0E
+ _L("set.v", 1, 0x80), // 0F
+ _L("reset.v", 1, 0x80), // 10
+ _L("toggle.v", 1, 0x80), // 11
+ _L("new.room", 1, 0x00), // 12
+ _L("new.room.v", 1, 0x80), // 13
+ _L("load.logics", 1, 0x00), // 14
+ _L("load.logics.v", 1, 0x80), // 15
+ _L("call", 1, 0x00), // 16
+ _L("call.v", 1, 0x80), // 17
+ _L("load.pic", 1, 0x80), // 18
+ _L("draw.pic", 1, 0x80), // 19
+ _L("show.pic", 0, 0x00), // 1A
+ _L("discard.pic", 1, 0x80), // 1B
+ _L("overlay.pic", 1, 0x80), // 1C
+ _L("show.pri.screen", 0, 0x00), // 1D
+ _L("load.view", 1, 0x00), // 1E
+ _L("load.view.v", 1, 0x80), // 1F
+ _L("discard.view", 1, 0x00), // 20
+ _L("animate.obj", 1, 0x00), // 21
+ _L("unanimate.all", 0, 0x00), // 22
+ _L("draw", 1, 0x00), // 23
+ _L("erase", 1, 0x00), // 24
+ _L("position", 3, 0x00), // 25
+ _L("position.v", 3, 0x60), // 26
+ _L("get.posn", 3, 0x60), // 27
+ _L("reposition", 3, 0x60), // 28
+ _L("set.view", 2, 0x00), // 29
+ _L("set.view.v", 2, 0x40), // 2A
+ _L("set.loop", 2, 0x00), // 2B
+ _L("set.loop.v", 2, 0x40), // 2C
+ _L("fix.loop", 1, 0x00), // 2D
+ _L("release.loop", 1, 0x00), // 2E
+ _L("set.cel", 2, 0x00), // 2F
+ _L("set.cel.v", 2, 0x40), // 30
+ _L("last.cel", 2, 0x40), // 31
+ _L("current.cel", 2, 0x40), // 32
+ _L("current.loop", 2, 0x40), // 33
+ _L("current.view", 2, 0x40), // 34
+ _L("number.of.loops", 2, 0x40), // 35
+ _L("set.priority", 2, 0x00), // 36
+ _L("set.priority.v", 2, 0x40), // 37
+ _L("release.priority", 1, 0x00), // 38
+ _L("get.priority", 2, 0x40), // 39
+ _L("stop.update", 1, 0x00), // 3A
+ _L("start.update", 1, 0x00), // 3B
+ _L("force.update", 1, 0x00), // 3C
+ _L("ignore.horizon", 1, 0x00), // 3D
+ _L("observe.horizon", 1, 0x00), // 3E
+ _L("set.horizon", 1, 0x00), // 3F
+ _L("object.on.water", 1, 0x00), // 40
+ _L("object.on.land", 1, 0x00), // 41
+ _L("object.on.anything", 1, 0x00), // 42
+ _L("ignore.objs", 1, 0x00), // 43
+ _L("observe.objs", 1, 0x00), // 44
+ _L("distance", 3, 0x20), // 45
+ _L("stop.cycling", 1, 0x00), // 46
+ _L("start.cycling", 1, 0x00), // 47
+ _L("normal.cycle", 1, 0x00), // 48
+ _L("end.of.loop", 2, 0x00), // 49
+ _L("reverse.cycle", 1, 0x00), // 4A
+ _L("reverse.loop", 2, 0x00), // 4B
+ _L("cycle.time", 2, 0x40), // 4C
+ _L("stop.motion", 1, 0x00), // 4D
+ _L("start.motion", 1, 0x00), // 4E
+ _L("step.size", 2, 0x40), // 4F
+ _L("step.time", 2, 0x40), // 50
+ _L("move.obj", 5, 0x00), // 51
+ _L("move.obj.v", 5, 0x70), // 52
+ _L("follow.ego", 3, 0x00), // 53
+ _L("wander", 1, 0x00), // 54
+ _L("normal.motion", 1, 0x00), // 55
+ _L("set.dir", 2, 0x40), // 56
+ _L("get.dir", 2, 0x40), // 57
+ _L("ignore.blocks", 1, 0x00), // 58
+ _L("observe.blocks", 1, 0x00), // 59
+ _L("block", 4, 0x00), // 5A
+ _L("unblock", 0, 0x00), // 5B
+ _L("get", 1, 0x00), // 5C
+ _L("get.v", 1, 0x80), // 5D
+ _L("drop", 1, 0x00), // 5E
+ _L("put", 2, 0x00), // 5F
+ _L("put.v", 2, 0x40), // 60
+ _L("get.room.v", 2, 0xC0), // 61
+ _L("load.sound", 1, 0x00), // 62
+ _L("sound", 2, 0x00), // 63
+ _L("stop.sound", 0, 0x00), // 64
+ _L("print", 1, 0x00), // 65
+ _L("print.v", 1, 0x80), // 66
+ _L("display", 3, 0x00), // 67
+ _L("display.v", 3, 0xE0), // 68
+ _L("clear.lines", 3, 0x00), // 69
+ _L("text.screen", 0, 0x00), // 6A
+ _L("graphics", 0, 0x00), // 6B
+ _L("set.cursor.char", 1, 0x00), // 6C
+ _L("set.text.attribute", 2, 0x00), // 6D
+ _L("shake.screen", 1, 0x00), // 6E
+ _L("configure.screen", 3, 0x00), // 6F
+ _L("status.line.on", 0, 0x00), // 70
+ _L("status.line.off", 0, 0x00), // 71
+ _L("set.string", 2, 0x00), // 72
+ _L("get.string", 5, 0x00), // 73
+ _L("word.to.string", 2, 0x00), // 74
+ _L("parse", 1, 0x00), // 75
+ _L("get.num", 2, 0x40), // 76
+ _L("prevent.input", 0, 0x00), // 77
+ _L("accept.input", 0, 0x00), // 78
+ _L("set.key", 3, 0x00), // 79
+ _L("add.to.pic", 7, 0x00), // 7A
+ _L("add.to.pic.v", 7, 0xFE), // 7B
+ _L("status", 0, 0x00), // 7C
+ _L("save.game", 0, 0x00), // 7D
+ _L("restore.game", 0, 0x00), // 7E
+ _L("init.disk", 0, 0x00), // 7F
+ _L("restart.game", 0, 0x00), // 80
+ _L("show.obj", 1, 0x00), // 81
+ _L("random", 3, 0x20), // 82
+ _L("program.control", 0, 0x00), // 83
+ _L("player.control", 0, 0x00), // 84
+ _L("obj.status.v", 1, 0x80), // 85
+ // 0 args for AGI version 2.089
+ _L("quit", 1, 0x00), // 86
+
+ _L("show.mem", 0, 0x00), // 87
+ _L("pause", 0, 0x00), // 88
+ _L("echo.line", 0, 0x00), // 89
+ _L("cancel.line", 0, 0x00), // 8A
+ _L("init.joy", 0, 0x00), // 8B
+ _L("toggle.monitor", 0, 0x00), // 8C
+ _L("version", 0, 0x00), // 8D
+ _L("script.size", 1, 0x00), // 8E
+ _L("set.game.id", 1, 0x00), // 8F
+ _L("log", 1, 0x00), // 90
+ _L("set.scan.start", 0, 0x00), // 91
+ _L("reset.scan.start", 0, 0x00), // 92
+ _L("reposition.to", 3, 0x00), // 93
+ _L("reposition.to.v", 3, 0x60), // 94
+ _L("trace.on", 0, 0x00), // 95
+ _L("trace.info", 3, 0x00), // 96
+
+ // 3 args for AGI versions before 2.440
+ _L("print.at", 4, 0x00), // 97
+ _L("print.at.v", 4, 0x80), // 98
+
+ _L("discard.view.v", 1, 0x80), // 99
+ _L("clear.text.rect", 5, 0x00), // 9A
+ _L("set.upper.left", 2, 0x00), // 9B
+ _L("set.menu", 1, 0x00), // 9C
+ _L("set.menu.item", 2, 0x00), // 9D
+ _L("submit.menu", 0, 0x00), // 9E
+ _L("enable.item", 1, 0x00), // 9F
+ _L("disable.item", 1, 0x00), // A0
+ _L("menu.input", 0, 0x00), // A1
+ _L("show.obj.v", 1, 0x01), // A2
+ _L("open.dialogue", 0, 0x00), // A3
+ _L("close.dialogue", 0, 0x00), // A4
+ _L("mul.n", 2, 0x80), // A5
+ _L("mul.v", 2, 0xC0), // A6
+ _L("div.n", 2, 0x80), // A7
+ _L("div.v", 2, 0xC0), // A8
+ _L("close.window", 0, 0x00), // A9
+
+ _L("set.simple", 1, 0x00), // AA
+ _L("push.script", 0, 0x00), // AB
+ _L("pop.script", 0, 0x00), // AC
+ _L("hold.key", 0, 0x00), // AD
+ _L("set.pri.base", 1, 0x00), // AE
+ _L("discard.sound", 1, 0x00), // AF
+
+ // 1 arg for AGI version 3.002.086
+ _L("hide.mouse", 0, 0x00), // B0
+
+ _L("allow.menu", 1, 0x00), // B1
+ _L("show.mouse", 0, 0x00), // B2
+ _L("fence.mouse", 4, 0x00), // B3
+ _L("mouse.posn", 2, 0x00), // B4
+ _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.
+ _L("adj.ego.move.to.xy", 0, 0x00), // B6
_L(NULL, 0, 0x00)
};
@@ -297,15 +295,15 @@ void AgiEngine::debugConsole(int lognum, int mode, const char *str) {
if (_debug.opcodes) {
report("%02X %02X %02X %02X %02X %02X %02X %02X %02X\n"
" ",
- (uint8) * (code + (0 + ip)) & 0xFF,
- (uint8) * (code + (1 + ip)) & 0xFF,
- (uint8) * (code + (2 + ip)) & 0xFF,
- (uint8) * (code + (3 + ip)) & 0xFF,
- (uint8) * (code + (4 + ip)) & 0xFF,
- (uint8) * (code + (5 + ip)) & 0xFF,
- (uint8) * (code + (6 + ip)) & 0xFF,
- (uint8) * (code + (7 + ip)) & 0xFF,
- (uint8) * (code + (8 + ip)) & 0xFF);
+ (uint8)*(code + (0 + ip)) & 0xFF,
+ (uint8)*(code + (1 + ip)) & 0xFF,
+ (uint8)*(code + (2 + ip)) & 0xFF,
+ (uint8)*(code + (3 + ip)) & 0xFF,
+ (uint8)*(code + (4 + ip)) & 0xFF,
+ (uint8)*(code + (5 + ip)) & 0xFF,
+ (uint8)*(code + (6 + ip)) & 0xFF,
+ (uint8)*(code + (7 + ip)) & 0xFF,
+ (uint8)*(code + (8 + ip)) & 0xFF);
}
report("%s ", (x + *(code + ip) - 0xFC)->name);
break;
diff --git a/engines/agi/op_test.cpp b/engines/agi/op_test.cpp
index 2e9e4ee337..9c18bf705c 100644
--- a/engines/agi/op_test.cpp
+++ b/engines/agi/op_test.cpp
@@ -52,7 +52,7 @@ static AgiEngine *g_agi;
#define testHas(obj) (g_agi->objectGetLocation(obj) == EGO_OWNED)
#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) {
char ms1[MAX_STRINGLEN];
@@ -113,6 +113,7 @@ static uint8 testKeypressed() {
game.keypress = 0;
if (!x) {
int mode = game.inputMode;
+
game.inputMode = INPUT_NONE;
g_agi->mainCycle();
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;
}
-/* 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) {
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;
}
-/* 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) {
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;
}
-/* 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) {
int c, n = game.numEgoWords;
int z = 0;
@@ -170,33 +171,32 @@ static uint8 testSaid(uint8 nwords, uint8 *cc) {
if (g_agi->getflag(fSaidAcceptedInput) || !g_agi->getflag(fEnteredCli))
return false;
- /* FR:
- * I think the reason for the code below is to add some speed....
- *
- * if (nwords != num_ego_words)
- * return false;
- *
- * In the disco scene in Larry 1 when you type "examine blonde",
- * inside the logic is expected ( said("examine", "blonde", "rol") )
- * where word("rol") = 9999
- *
- * According to the interpreter code 9999 means that whatever the
- * 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...
- *
- * With the removal of this code, the behaviour of the scene was
- * corrected
- */
+ // FR:
+ // I think the reason for the code below is to add some speed....
+ //
+ // if (nwords != num_ego_words)
+ // return false;
+ //
+ // In the disco scene in Larry 1 when you type "examine blonde",
+ // inside the logic is expected ( said("examine", "blonde", "rol") )
+ // where word("rol") = 9999
+ //
+ // According to the interpreter code 9999 means that whatever the
+ // 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...
+ //
+ // With the removal of this code, the behaviour of the scene was
+ // corrected
for (c = 0; nwords && n; c++, nwords--, n--) {
z = READ_LE_UINT16(cc);
cc += 2;
switch (z) {
- case 9999: /* rest of line (empty string counts to...) */
+ case 9999: // rest of line (empty string counts to...)
nwords = 1;
break;
- case 1: /* any word */
+ case 1: // any word
break;
default:
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)
return false;
- /* The interpreter string shouldn't be entirely parsed, but next
- * word must be 9999.
- */
+ // The interpreter string shouldn't be entirely parsed, but next
+ // word must be 9999.
if (nwords != 0 && READ_LE_UINT16(cc) != 9999)
return false;
@@ -240,16 +239,15 @@ int AgiEngine::testIfCode(int lognum) {
memmove(p, (code + ip), 16);
switch (op) {
- case 0xFF: /* END IF, TEST true */
+ case 0xFF: // END IF, TEST true
end_test = true;
break;
case 0xFD:
notTest = !notTest;
continue;
- case 0xFC: /* OR */
- /* if or_test is ON and we hit 0xFC, end of OR, then
- * or is STILL false so break.
- */
+ case 0xFC: // OR
+ // if or_test is ON and we hit 0xFC, end of OR, then
+ // or is STILL false so break.
if (orTest) {
ec = false;
retval = false;
@@ -260,7 +258,7 @@ int AgiEngine::testIfCode(int lognum) {
continue;
case 0x00:
- /* return true? */
+ // return true?
end_test = true;
break;
case 0x01:
@@ -317,9 +315,9 @@ int AgiEngine::testIfCode(int lognum) {
case 0x0E:
ec = testSaid(p[0], (uint8 *) code + (ip + 1));
ip = lastIp;
- ip++; /* skip opcode */
- ip += p[0] * 2; /* skip num_words * 2 */
- ip++; /* skip num_words opcode */
+ ip++; // skip opcode
+ ip += p[0] * 2; // skip num_words * 2
+ ip++; // skip num_words opcode
break;
case 0x0F:
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)
ip += logicNamesTest[op].numArgs;
- /* exchange ec value */
+ // exchange ec value
if (notTest)
ec = !ec;
- /* not is only enabled for 1 test command */
+ // not is only enabled for 1 test command
notTest = false;
if (orTest && ec) {
- /* a true inside an OR statement passes
- * ENTIRE statement scan for end of OR
- */
-
- /* CM: test for opcode < 0xfc changed from 'op' to
- * '*(code+ip)', to avoid problem with the 0xfd (NOT)
- * opcode byte. Changed a bad ip += ... ip++ construct.
- * This should fix the crash with Larry's logic.0 code:
- *
- * if ((isset(4) ||
- * !isset(2) ||
- * v30 == 2 ||
- * v30 == 1)) {
- * goto Label1;
- * }
- *
- * The bytecode is:
- * ff fc 07 04 fd 07 02 01 1e 02 01 1e 01 fc ff
- */
-
- /* find end of OR */
+ // a true inside an OR statement passes
+ // ENTIRE statement scan for end of OR
+
+ // CM: test for opcode < 0xfc changed from 'op' to
+ // '*(code+ip)', to avoid problem with the 0xfd (NOT)
+ // opcode byte. Changed a bad ip += ... ip++ construct.
+ // This should fix the crash with Larry's logic.0 code:
+ //
+ // if ((isset(4) ||
+ // !isset(2) ||
+ // v30 == 2 ||
+ // v30 == 1)) {
+ // goto Label1;
+ // }
+ //
+ // The bytecode is:
+ // ff fc 07 04 fd 07 02 01 1e 02 01 1e 01 fc ff
+
+ // find end of OR
while (*(code + ip) != 0xFC) {
- if (*(code + ip) == 0x0E) { /* said */
+ if (*(code + ip) == 0x0E) { // said
ip++;
- /* cover count + ^words */
+
+ // cover count + ^words
ip += 1 + ((*(code + ip)) * 2);
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)
ip += 2;
else {
@@ -420,7 +417,7 @@ int AgiEngine::testIfCode(int lognum) {
ip++;
}
}
- ip++; /* skip over 0xFF */
+ ip++; // skip over 0xFF
ip += READ_LE_UINT16(code + ip) + 2;
}
@@ -430,4 +427,4 @@ int AgiEngine::testIfCode(int lognum) {
return retval;
}
-} // End of namespace Agi
+} // End of namespace Agi
diff --git a/engines/agi/picture.cpp b/engines/agi/picture.cpp
index 01d66296b9..20dd893a42 100644
--- a/engines/agi/picture.cpp
+++ b/engines/agi/picture.cpp
@@ -90,7 +90,7 @@ void PictureMgr::drawLine(int x1, int y1, int x2, int y2) {
#else
int i, x, y, deltaX, deltaY, stepX, stepY, errorX, errorY, detdelta;
- /* Vertical line */
+ // Vertical line
if (x1 == x2) {
if (y1 > y2) {
@@ -103,7 +103,7 @@ void PictureMgr::drawLine(int x1, int y1, int x2, int y2) {
return;
}
- /* Horizontal line */
+ // Horizontal line
if (y1 == y2) {
if (x1 > x2) {
@@ -274,7 +274,7 @@ void PictureMgr::agiFill(unsigned int x, unsigned int y) {
if (!isOkFillHere(p.x, p.y))
continue;
- /* Scan for left border */
+ // Scan for left border
for (c = p.x - 1; isOkFillHere(c, p.y); c--)
;
@@ -592,7 +592,7 @@ void PictureMgr::drawPicture() {
break;
case 0xe4: // fill (C64)
_scrColor = nextByte();
- _scrColor &= 0xF; /* for v3 drawing diff */
+ _scrColor &= 0xF; // for v3 drawing diff
fill();
break;
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
*/
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) {
free(_vm->_game.pictures[n].rdata);
_vm->_game.dirPic[n].flags &= ~RES_LOADED;
diff --git a/engines/agi/preagi.cpp b/engines/agi/preagi.cpp
index 99c2e55f4b..f1bc27ac00 100644
--- a/engines/agi/preagi.cpp
+++ b/engines/agi/preagi.cpp
@@ -54,15 +54,6 @@ PreAgiEngine::PreAgiEngine(OSystem *syst, const AGIGameDescription *gameDesc) :
_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_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();
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(&_debug, 0, sizeof(struct AgiDebug));
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() {
@@ -170,7 +138,7 @@ void PreAgiEngine::initialize() {
debugC(2, kDebugLevelMain, "Detect game");
- /* clear all resources and events */
+ // clear all resources and events
for (int i = 0; i < MAX_DIRS; i++) {
memset(&_game.pictures[i], 0, sizeof(struct AgiPicture));
memset(&_game.sounds[i], 0, sizeof(class AgiSound *)); // _game.sounds contains pointers now
@@ -190,10 +158,10 @@ PreAgiEngine::~PreAgiEngine() {
Common::Error PreAgiEngine::go() {
setflag(fSoundOn, true); // enable sound
-/*
-FIXME (Fingolfin asks): Why are Mickey, Winnie and Troll standalone classes
- instead of being subclasses of PreAgiEngine ?
-*/
+//
+// FIXME (Fingolfin asks): Why are Mickey, Winnie and Troll standalone classes
+// instead of being subclasses of PreAgiEngine ?
+//
// run preagi engine main loop
switch (getGameID()) {
diff --git a/engines/agi/preagi_mickey.cpp b/engines/agi/preagi_mickey.cpp
index 155fe1ad06..e728f2f695 100644
--- a/engines/agi/preagi_mickey.cpp
+++ b/engines/agi/preagi_mickey.cpp
@@ -92,8 +92,10 @@ void Mickey::readOfsData(int offset, int iItem, uint8 *buffer, long buflen) {
readExe(offset, buffer, buflen);
memcpy(ofs, buffer, sizeof(ofs));
+
for (int i = 0; i < 256; i++)
ofs[i] = buffer[i*2] + 256 * buffer[i*2+1];
+
readExe(ofs[iItem] + IDI_MSA_OFS_EXE, buffer, buflen);
}
@@ -375,16 +377,16 @@ bool Mickey::getMenuSelRow(MSA_MENU menu, int *sel0, int *sel1, int iRow) {
// Change cursor
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)) {
_vm->_gfx->setCursorPalette(true);
} 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)) {
_vm->_gfx->setCursorPalette(true);
} 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)) {
_vm->_gfx->setCursorPalette(true);
} 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)) {
_vm->_gfx->setCursorPalette(true);
} else {
_vm->_gfx->setCursorPalette(false);
@@ -394,27 +396,39 @@ bool Mickey::getMenuSelRow(MSA_MENU menu, int *sel0, int *sel1, int iRow) {
case Common::EVENT_LBUTTONUP:
// Click to move
if (northIndex >= 0 && (event.mouse.x >= 20 && event.mouse.x <= (IDI_MSA_PIC_WIDTH + 10) * 2) &&
- (event.mouse.y >= 0 && event.mouse.y <= 10)) {
- *sel0 = goIndex; *sel1 = northIndex;
+ (event.mouse.y >= 0 && event.mouse.y <= 10)) {
+ *sel0 = goIndex;
+ *sel1 = northIndex;
+
drawMenu(menu, *sel0, *sel1);
+
_vm->_gfx->setCursorPalette(false);
_clickToMove = true;
} 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)) {
- *sel0 = goIndex; *sel1 = southIndex;
+ (event.mouse.y >= IDI_MSA_PIC_HEIGHT - 10 && event.mouse.y <= IDI_MSA_PIC_HEIGHT)) {
+ *sel0 = goIndex;
+ *sel1 = southIndex;
+
drawMenu(menu, *sel0, *sel1);
+
_vm->_gfx->setCursorPalette(false);
_clickToMove = true;
} else if (westIndex >= 0 && (event.mouse.y >= 0 && event.mouse.y <= IDI_MSA_PIC_HEIGHT) &&
- (event.mouse.x >= 20 && event.mouse.x <= 30)) {
- *sel0 = goIndex; *sel1 = westIndex;
+ (event.mouse.x >= 20 && event.mouse.x <= 30)) {
+ *sel0 = goIndex;
+ *sel1 = westIndex;
+
drawMenu(menu, *sel0, *sel1);
+
_vm->_gfx->setCursorPalette(false);
_clickToMove = true;
} 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)) {
- *sel0 = goIndex; *sel1 = eastIndex;
+ (event.mouse.x >= IDI_MSA_PIC_WIDTH * 2 && event.mouse.x <= (IDI_MSA_PIC_WIDTH + 10) * 2)) {
+ *sel0 = goIndex;
+ *sel1 = eastIndex;
+
drawMenu(menu, *sel0, *sel1);
+
_vm->_gfx->setCursorPalette(false);
_clickToMove = true;
} else {
@@ -422,19 +436,26 @@ bool Mickey::getMenuSelRow(MSA_MENU menu, int *sel0, int *sel1, int iRow) {
}
return true;
case Common::EVENT_RBUTTONUP:
- *sel0 = 0; *sel1 = -1;
+ *sel0 = 0;
+ *sel1 = -1;
return false;
case Common::EVENT_WHEELUP:
if (iRow < 2) {
*sel -= 1;
- if (*sel < 0) *sel = nWords - 1;
+
+ if (*sel < 0)
+ *sel = nWords - 1;
+
drawMenu(menu, *sel0, *sel1);
}
break;
case Common::EVENT_WHEELDOWN:
if (iRow < 2) {
*sel += 1;
- if (*sel == nWords) *sel = 0;
+
+ if (*sel == nWords)
+ *sel = 0;
+
drawMenu(menu, *sel0, *sel1);
}
break;
@@ -458,28 +479,45 @@ bool Mickey::getMenuSelRow(MSA_MENU menu, int *sel0, int *sel1, int iRow) {
break;
case Common::KEYCODE_8:
if (event.kbd.flags & Common::KBD_CTRL) {
- *sel0 = 0; *sel1 = -1; return false;
+ *sel0 = 0;
+ *sel1 = -1;
+
+ return false;
}
break;
case Common::KEYCODE_ESCAPE:
- *sel0 = 0; *sel1 = -1; return false;
+ *sel0 = 0;
+ *sel1 = -1;
+
+ return false;
case Common::KEYCODE_s:
_vm->flipflag(fSoundOn);
break;
case Common::KEYCODE_c:
inventory();
drawRoom();
- *sel0 = 0; *sel1 = -1; return false;
+
+ *sel0 = 0;
+ *sel1 = -1;
+
+ return false;
case Common::KEYCODE_b:
printRoomDesc();
drawMenu(menu, *sel0, *sel1);
- *sel0 = 0; *sel1 = -1; return false;
+
+ *sel0 = 0;
+ *sel1 = -1;
+
+ return false;
case Common::KEYCODE_LEFT:
case Common::KEYCODE_KP4:
case Common::KEYCODE_4:
if (iRow < 2) {
*sel -= 1;
- if (*sel < 0) *sel = nWords - 1;
+
+ if (*sel < 0)
+ *sel = nWords - 1;
+
drawMenu(menu, *sel0, *sel1);
}
break;
@@ -489,7 +527,10 @@ bool Mickey::getMenuSelRow(MSA_MENU menu, int *sel0, int *sel1, int iRow) {
case Common::KEYCODE_6:
if (iRow < 2) {
*sel += 1;
- if (*sel == nWords) *sel = 0;
+
+ if (*sel == nWords)
+ *sel = 0;
+
drawMenu(menu, *sel0, *sel1);
}
break;
@@ -529,7 +570,9 @@ void Mickey::getMenuSel(char *buffer, int *sel0, int *sel1) {
if (getMenuSelRow(menu, sel0, sel1, 0)) {
if (_clickToMove)
break;
+
*sel1 = 0;
+
if (getMenuSelRow(menu, sel0, sel1, 1)) {
break;
}
@@ -557,6 +600,7 @@ void Mickey::centerMenu(MSA_MENU *menu) {
}
w += menu->row[iRow].count - 1;
x = (40 - w) / 2; // FIX
+
for (iWord = 0; iWord < menu->row[iRow].count; iWord++) {
menu->row[iRow].entry[iWord].x0 = x;
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;
if (!file.open(szFile))
return;
+
uint32 size = file.size();
file.read(buffer, size);
file.close();
@@ -709,6 +754,7 @@ void Mickey::drawPic(int iPic) {
Common::File file;
if (!file.open(szFile))
return;
+
uint32 size = file.size();
file.read(buffer, size);
file.close();
@@ -742,30 +788,32 @@ void Mickey::drawRoomAnimation() {
case IDI_MSA_PIC_SHIP_MARS:
case IDI_MSA_PIC_SHIP_URANUS:
{
- // draw blinking ship lights
+ // draw blinking ship lights
- uint8 iColor = 0;
+ uint8 iColor = 0;
- _vm->_picture->setPattern(2, 0);
+ _vm->_picture->setPattern(2, 0);
- for (int i = 0; i < 12; i++) {
- iColor = _game.nFrame + i;
- if (iColor > 15) iColor -= 15;
+ for (int i = 0; i < 12; i++) {
+ iColor = _game.nFrame + i;
+ if (iColor > 15)
+ iColor -= 15;
- objLight[1] = iColor;
- objLight[4] += 7;
+ objLight[1] = iColor;
+ objLight[4] += 7;
- _vm->_picture->setPictureData(objLight);
- _vm->_picture->setPictureFlags(kPicFCircle);
- _vm->_picture->drawPicture();
- }
- _vm->_picture->showPic(10, 0, IDI_MSA_PIC_WIDTH, IDI_MSA_PIC_HEIGHT);
+ _vm->_picture->setPictureData(objLight);
+ _vm->_picture->setPictureFlags(kPicFCircle);
+ _vm->_picture->drawPicture();
+ }
+ _vm->_picture->showPic(10, 0, IDI_MSA_PIC_WIDTH, IDI_MSA_PIC_HEIGHT);
- _game.nFrame--;
- if (_game.nFrame < 0) _game.nFrame = 15;
+ _game.nFrame--;
+ if (_game.nFrame < 0)
+ _game.nFrame = 15;
- playSound(IDI_MSA_SND_PRESS_BLUE);
+ playSound(IDI_MSA_SND_PRESS_BLUE);
}
break;
@@ -773,7 +821,9 @@ void Mickey::drawRoomAnimation() {
// draw XL30 screen
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);
_game.nFrame++;
};
@@ -787,7 +837,8 @@ void Mickey::drawRoomAnimation() {
if (!_game.fHasXtal) {
switch(_game.iPlanet) {
case IDI_MSA_PLANET_VENUS:
- if (_game.iRmMenu[_game.iRoom] != 2) break;
+ if (_game.iRmMenu[_game.iRoom] != 2)
+ break;
default:
drawObj(
IDI_MSA_OBJECT_CRYSTAL,
@@ -882,6 +933,7 @@ void Mickey::drawLogo() {
Common::File infile;
if (!infile.open(szFile))
return;
+
infile.read(buffer, infile.size());
infile.close();
@@ -947,6 +999,7 @@ bool Mickey::loadGame() {
sprintf(szFile, "%s.s%02d", _vm->getTargetName().c_str(), sel);
if (!(infile = _vm->getSaveFileMan()->openForLoading(szFile))) {
printLine("PLEASE CHECK THE DISK DRIVE");
+
if (_vm->getSelection(kSelAnyKey) == 0)
return false;
} else {
@@ -1063,6 +1116,7 @@ void Mickey::saveGame() {
sprintf(szFile, "%s.s%02d", _vm->getTargetName().c_str(), sel);
if (!(outfile = _vm->getSaveFileMan()->openForSaving(szFile))) {
printLine("PLEASE CHECK THE DISK DRIVE");
+
if (_vm->getSelection(kSelAnyKey) == 0)
return;
} else {
@@ -1658,15 +1712,18 @@ bool Mickey::parse(int cmd, int arg) {
if (_game.fItem[IDI_MSA_ITEM_WRENCH]) {
_game.iRmMenu[_game.iRoom] = 1;
}
+
printDatMessage(arg);
}
break;
case IDI_MSA_ACTION_USE_WRENCH:
_game.fItemUsed[IDI_MSA_ITEM_WRENCH] = true;
printDatString(arg);
+
if (_game.iRmPic[_game.iRoom] == IDI_MSA_PIC_VENUS_PROBE_1) {
_vm->clearRow(22);
}
+
waitAnyKey();
break;
case IDI_MSA_ACTION_GET_XTAL_VENUS:
@@ -1685,11 +1742,13 @@ bool Mickey::parse(int cmd, int arg) {
case IDI_MSA_ACTION_ENTER_OPENING:
if (_game.fItemUsed[IDI_MSA_ITEM_CROWBAR]) {
_game.iRoom = IDI_MSA_PIC_NEPTUNE_CASTLE_4;
+
return true;
} else {
if (_game.fItem[IDI_MSA_ITEM_CROWBAR]) {
_game.iRmMenu[_game.iRoom] = 2;
}
+
printDatMessage(arg);
}
break;
@@ -1707,11 +1766,13 @@ bool Mickey::parse(int cmd, int arg) {
if (_game.fItem[IDI_MSA_ITEM_SCARF]) {
_game.iRmMenu[_game.iRoom] = 1;
}
+
printDatMessage(arg);
}
break;
case IDI_MSA_ACTION_TALK_LEADER:
_game.iRoom = IDI_MSA_PIC_NEPTUNE_ENTRYWAY;
+
printDatMessage(arg);
return true;
case IDI_MSA_ACTION_GIVE_SCARF:
@@ -1721,6 +1782,7 @@ bool Mickey::parse(int cmd, int arg) {
_game.iRmMenu[_game.iRoom] = 0;
_game.iRmMenu[IDI_MSA_PIC_EARTH_BEDROOM] = 2;
_game.iRoom = IDI_MSA_PIC_NEPTUNE_ENTRYWAY;
+
return true;
// MERCURY
@@ -1740,7 +1802,9 @@ bool Mickey::parse(int cmd, int arg) {
_game.iRmObj[_game.iRoom] = 17;
_game.iRmMenu[_game.iRoom] = 2;
_game.fItem[IDI_MSA_ITEM_SUNGLASSES] = false;
+
getXtal(arg);
+
break;
// 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_2] = 1;
}
+
printDatMessage(arg);
+
break;
case IDI_MSA_ACTION_USE_MATTRESS:
_game.iRoom = IDI_MSA_PIC_SATURN_ISLAND;
+
printDatMessage(arg);
+
return true;
case IDI_MSA_ACTION_GET_XTAL_SATURN:
if (_game.fHasXtal) {
@@ -1766,7 +1834,9 @@ bool Mickey::parse(int cmd, int arg) {
break;
case IDI_MSA_ACTION_LEAVE_ISLAND:
_game.iRoom = IDI_MSA_PIC_SATURN_LAKE_1;
+
printDatMessage(arg);
+
return true;
// PLUTO
@@ -1785,7 +1855,9 @@ bool Mickey::parse(int cmd, int arg) {
_game.fItem[IDI_MSA_ITEM_BONE] = false;
_game.iRmMenu[_game.iRoom] = 0;
_game.iRmObj[_game.iRoom] = 16;
+
getXtal(arg);
+
break;
// IO (JUPITER)
@@ -1829,12 +1901,15 @@ bool Mickey::parse(int cmd, int arg) {
_game.nItems--;
_game.iRmObj[_game.iRoom]++;
_game.iRmMenu[_game.iRoom] = 0;
+
drawRoom();
+
if (_game.nRocks) {
printDatMessage(37);
} else {
printDatMessage(arg);
}
+
_game.nRocks++;
break;
@@ -1844,11 +1919,15 @@ bool Mickey::parse(int cmd, int arg) {
if (_game.fItem[IDI_MSA_ITEM_FLASHLIGHT]) {
_game.iRmMenu[_game.iRoom] = 1;
}
+
printDatMessage(arg);
+
break;
case IDI_MSA_ACTION_USE_FLASHLIGHT:
_game.iRoom = IDI_MSA_PIC_MARS_TUBE_1;
+
printDatMessage(15);
+
return true;
case IDI_MSA_ACTION_PLUTO_DIG:
if (_game.fHasXtal) {
@@ -1869,6 +1948,7 @@ bool Mickey::parse(int cmd, int arg) {
case IDI_MSA_ACTION_ENTER_TEMPLE:
_game.iRoom = IDI_MSA_PIC_URANUS_TEMPLE;
+
return true;
case IDI_MSA_ACTION_USE_CRYSTAL:
if (_game.iRmMenu[_game.iRoom]) {
@@ -1876,8 +1956,11 @@ bool Mickey::parse(int cmd, int arg) {
} else {
_game.iRmMenu[_game.iRoom] = 1;
_game.iRmPic[_game.iRoom] = IDI_MSA_PIC_URANUS_TEMPLE_1;
+
drawRoom();
+
_game.iRmPic[_game.iRoom] = IDI_MSA_PIC_URANUS_TEMPLE;
+
printDatMessage(arg);
}
break;
@@ -1887,13 +1970,16 @@ bool Mickey::parse(int cmd, int arg) {
} else {
_game.fTempleDoorOpen = 1;
_game.iRmPic[_game.iRoom] = IDI_MSA_PIC_URANUS_TEMPLE_2;
+
drawRoom();
+
printDatMessage(arg);
}
break;
case IDI_MSA_ACTION_ENTER_DOOR:
if (_game.fTempleDoorOpen) {
_game.iRoom = IDI_MSA_PIC_URANUS_STEPS;
+
return true;
} else {
printDatMessage(arg);
@@ -1911,7 +1997,9 @@ bool Mickey::parse(int cmd, int arg) {
break;
case IDI_MSA_ACTION_USE_CROWBAR_1:
_game.iRmMenu[_game.iRoom] = 0;
+
getXtal(arg);
+
break;
// 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)) {
_game.fHasXtal = false;
_game.iRoom = IDI_MSA_HOME_PLANET[_game.iPlanet];
+
if (_game.iPlanet != IDI_MSA_PLANET_EARTH)
insertDisk(1);
+
return true;
} else {
_game.iRoom = IDI_MSA_SHIP_PLANET[_game.iPlanet];
+
return true;
}
} else {
@@ -1953,13 +2044,17 @@ bool Mickey::parse(int cmd, int arg) {
} else {
_game.fShipDoorOpen = false;
_game.iRmPic[_game.iRoom]--;
+
drawRoom();
+
printDatMessage(2);
}
} else {
_game.fShipDoorOpen = true;
_game.iRmPic[_game.iRoom]++;
+
drawRoom();
+
printDatMessage(14);
}
break;
@@ -1969,7 +2064,9 @@ bool Mickey::parse(int cmd, int arg) {
_game.fSuit = false;
_game.iRmMenu[_game.iRoom] = 0;
_game.iRmPic[_game.iRoom] -= 2;
+
drawRoom();
+
printDatMessage(13);
} else {
printDatMessage(3);
@@ -1979,7 +2076,9 @@ bool Mickey::parse(int cmd, int arg) {
_game.fSuit = true;
_game.iRmMenu[_game.iRoom] = 1;
_game.iRmPic[_game.iRoom] += 2;
+
drawRoom();
+
printDatMessage(arg);
} else {
printDatMessage(12);
@@ -1988,11 +2087,11 @@ bool Mickey::parse(int cmd, int arg) {
break;
case IDI_MSA_ACTION_READ_GAUGE:
printDatString(arg);
- _vm->drawStr(21, 15, IDA_DEFAULT,
- (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, 15, IDA_DEFAULT, (const char *)IDS_MSA_TEMP_C[_game.iPlanet]);
+ _vm->drawStr(21, 23, IDA_DEFAULT, (const char *)IDS_MSA_TEMP_F[_game.iPlanet]);
+
waitAnyKey();
+
break;
case IDI_MSA_ACTION_PRESS_ORANGE:
if (_game.fFlying) {
@@ -2019,12 +2118,18 @@ bool Mickey::parse(int cmd, int arg) {
if (_game.fFlying) {
_game.fFlying = false;
_game.nButtons = 0;
+
memset(_game.szAddr, 0, sizeof(_game.szAddr));
+
drawRoom();
+
printDatString(22);
+
_vm->drawStr(IDI_MSA_ROW_PLANET, IDI_MSA_COL_PLANET, IDA_DEFAULT,
(const char *)IDS_MSA_PLANETS[_game.iPlanet]);
+
waitAnyKey(true);
+
showPlanetInfo();
} else {
printDatMessage(arg);
@@ -2037,11 +2142,15 @@ bool Mickey::parse(int cmd, int arg) {
if (getPlanet() != -1) {
_game.fFlying = true;
_game.iPlanet = getPlanet();
+
drawRoom();
+
printDatMessage(16);
} else {
_game.nButtons = 0;
+
memset(_game.szAddr, 0, sizeof(_game.szAddr));
+
printDatMessage(17);
}
}
@@ -2060,23 +2169,32 @@ bool Mickey::parse(int cmd, int arg) {
} else {
_game.iRmMenu[_game.iRoom] = 1;
_game.iRmPic[_game.iRoom] = IDI_MSA_PIC_SHIP_KITCHEN_1;
+
drawRoom();
+
printDatMessage(arg);
}
break;
case IDI_MSA_ACTION_READ_MAP:
_game.iRmPic[_game.iRoom] = IDI_MSA_PIC_STAR_MAP;
+
drawRoom();
+
printDatMessage(46);
printDatMessage(47);
printDatMessage(48);
+
_game.iRmPic[_game.iRoom] = IDI_MSA_PIC_SHIP_BEDROOM;
+
drawRoom();
break;
case IDI_MSA_ACTION_GO_WEST:
_game.nButtons = 0;
+
memset(_game.szAddr, 0, sizeof(_game.szAddr));
+
_game.iRoom = arg;
+
return true;
}
diff --git a/engines/agi/preagi_troll.cpp b/engines/agi/preagi_troll.cpp
index b72a617948..e34949c8fe 100644
--- a/engines/agi/preagi_troll.cpp
+++ b/engines/agi/preagi_troll.cpp
@@ -80,7 +80,9 @@ bool Troll::getMenuSel(const char *szMenu, int *iSel, int nSel) {
case Common::KEYCODE_t:
case Common::KEYCODE_f:
inventory();
+
return false;
+
break;
case Common::KEYCODE_DOWN:
case Common::KEYCODE_SPACE:
@@ -282,6 +284,7 @@ void Troll::tutorial() {
done = false;
while (!done && !_vm->shouldQuit()) {
getMenuSel(IDS_TRO_TUTORIAL_1, &iSel, IDI_TRO_MAX_OPTION);
+
switch(iSel) {
case IDI_TRO_SEL_OPTION_1:
_vm->clearScreen(0x22, false);
@@ -410,6 +413,7 @@ void Troll::gameOver() {
_vm->drawStr(21, 1, kColorDefault, szMoves);
_vm->drawStr(22, 1, kColorDefault, IDS_TRO_GAMEOVER_1);
_vm->_gfx->doUpdate();
+
pressAnyKey();
}
@@ -474,12 +478,6 @@ void Troll::playTune(int tune, int len) {
if (!_soundOn)
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 ptr = _tunes[tune - 1];
diff --git a/engines/agi/preagi_winnie.cpp b/engines/agi/preagi_winnie.cpp
index 1341adcef8..ac0d3625b2 100644
--- a/engines/agi/preagi_winnie.cpp
+++ b/engines/agi/preagi_winnie.cpp
@@ -150,9 +150,11 @@ void Winnie::randomize() {
for (int i = 0; i < IDI_WTP_MAX_OBJ_MISSING; i++) {
done = false;
+
while (!done) {
iObj = _vm->rnd(IDI_WTP_MAX_OBJ - 1);
done = true;
+
for (int j = 0; j < IDI_WTP_MAX_OBJ_MISSING; j++) {
if (_game.iUsedObj[j] == iObj) {
done = false;
@@ -167,6 +169,7 @@ void Winnie::randomize() {
while (!done) {
iRoom = _vm->rnd(IDI_WTP_MAX_ROOM_NORMAL);
done = true;
+
for (int j = 0; j < IDI_WTP_MAX_ROOM_OBJ; j++) {
if (_game.iObjRoom[j] == iRoom) {
done = false;
@@ -185,17 +188,23 @@ void Winnie::intro() {
_vm->_gfx->doUpdate();
_vm->_system->updateScreen();
_vm->_system->delayMillis(0x640);
+
if (_vm->getPlatform() == Common::kPlatformAmiga)
_vm->_gfx->clearScreen(0);
+
drawPic(IDS_WTP_FILE_TITLE);
+
_vm->printStr(IDS_WTP_INTRO_1);
_vm->_gfx->doUpdate();
_vm->_system->updateScreen();
_vm->_system->delayMillis(0x640);
+
if (!playSound(IDI_WTP_SND_POOH_0))
return;
+
if (!playSound(IDI_WTP_SND_POOH_1))
return;
+
if (!playSound(IDI_WTP_SND_POOH_2))
return;
}
@@ -346,6 +355,7 @@ int Winnie::parser(int pc, int index, uint8 *buffer) {
case IDI_WTP_SEL_EAST:
case IDI_WTP_SEL_WEST:
iDir = iSel - IDI_WTP_SEL_NORTH;
+
if (hdr.roomNew[iDir] == IDI_WTP_ROOM_NONE) {
_vm->printStr(IDS_WTP_CANT_GO);
_vm->getSelection(kSelAnyKey);
@@ -517,6 +527,7 @@ void Winnie::takeObj(int iRoom) {
} else {
// take object
int iObj = getObjInRoom(iRoom);
+
_game.iObjHave = iObj;
_game.iObjRoom[iObj] = 0;
@@ -590,8 +601,10 @@ void Winnie::dropObj(int iRoom) {
// object has been dropped in the wrong place
_vm->printStr(IDS_WTP_WRONG_PLACE);
_vm->getSelection(kSelAnyKey);
+
playSound(IDI_WTP_SND_DROP);
drawRoomPic();
+
_vm->printStr(IDS_WTP_WRONG_PLACE);
_vm->getSelection(kSelAnyKey);
@@ -639,6 +652,7 @@ void Winnie::wind() {
_vm->printStr(IDS_WTP_WIND_0);
playSound(IDI_WTP_SND_WIND_0);
_vm->getSelection(kSelAnyKey);
+
_vm->printStr(IDS_WTP_WIND_1);
playSound(IDI_WTP_SND_WIND_0);
_vm->getSelection(kSelAnyKey);
@@ -652,6 +666,7 @@ void Winnie::wind() {
while (!done) {
iRoom = _vm->rnd(IDI_WTP_MAX_ROOM_NORMAL);
done = true;
+
for (int j = 0; j < IDI_WTP_MAX_ROOM_OBJ; j++) {
if (_game.iObjRoom[j] == iRoom) {
done = false;
@@ -1006,11 +1021,13 @@ phase0:
drawRoomPic();
_vm->_gfx->doUpdate();
_vm->_system->updateScreen();
+
phase1:
if (getObjInRoom(_room)) {
printObjStr(getObjInRoom(_room), IDI_WTP_OBJ_DESC);
_vm->getSelection(kSelAnyKey);
}
+
phase2:
for (iBlock = 0; iBlock < IDI_WTP_MAX_BLOCK; iBlock++) {
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);
return;
}
+
uint32 size = file.size();
file.read(buffer, size);
file.close();
diff --git a/engines/agi/predictive.cpp b/engines/agi/predictive.cpp
index 59030494bd..ae8bc98ac9 100644
--- a/engines/agi/predictive.cpp
+++ b/engines/agi/predictive.cpp
@@ -176,7 +176,7 @@ bool AgiEngine::predictiveDialog(void) {
}
}
- /* clear key queue */
+ // clear key queue
while (_gfx->keypress())
_gfx->getKey();
@@ -234,7 +234,7 @@ bool AgiEngine::predictiveDialog(void) {
_gfx->doUpdate();
}
- _gfx->pollTimer(); /* msdos driver -> does nothing */
+ _gfx->pollTimer(); // msdos driver -> does nothing
key = doPollKeyboard();
processkey = false;
switch (key) {
@@ -274,7 +274,7 @@ bool AgiEngine::predictiveDialog(void) {
active = 14;
processkey = true;
break;
- case 0x09: /* Tab */
+ case 0x09: // Tab
navigationwithkeys = true;
debugC(3, kDebugLevelText, "Focus change");
lastactive = active = lastactive + 1;
diff --git a/engines/agi/saveload.cpp b/engines/agi/saveload.cpp
index c8dccf7df3..6a6281e88c 100644
--- a/engines/agi/saveload.cpp
+++ b/engines/agi/saveload.cpp
@@ -23,10 +23,10 @@
*
*/
-/*
- * Savegame support by Vasyl Tsvirkunov <vasyl@pacbell.net>
- * Multi-slots by Claudio Matsuoka <claudio@helllabs.org>
- */
+//
+// Savegame support by Vasyl Tsvirkunov <vasyl@pacbell.net>
+// Multi-slots by Claudio Matsuoka <claudio@helllabs.org>
+//
#include <time.h> // for extended infos
@@ -41,20 +41,20 @@
#define SAVEGAME_VERSION 4
-/*
- * Version 0 (Sarien): view table has 64 entries
- * Version 1 (Sarien): view table has 256 entries (needed in KQ3)
- * Version 2 (ScummVM): first ScummVM version
- * Version 3 (ScummVM): added AGIPAL save/load support
- * Version 4 (ScummVM): added thumbnails and save creation date/time
- */
+//
+// Version 0 (Sarien): view table has 64 entries
+// Version 1 (Sarien): view table has 256 entries (needed in KQ3)
+// Version 2 (ScummVM): first ScummVM version
+// Version 3 (ScummVM): added AGIPAL save/load support
+// Version 4 (ScummVM): added thumbnails and save creation date/time
+//
namespace Agi {
-static const uint32 AGIflag=MKID_BE('AGI:');
+static const uint32 AGIflag = MKID_BE('AGI:');
int AgiEngine::saveGame(const char *fileName, const char *description) {
- char gameIDstring[8]="gameIDX";
+ char gameIDstring[8] = "gameIDX";
int i;
Common::OutSaveFile *out;
int result = errOK;
@@ -128,20 +128,20 @@ int AgiEngine::saveGame(const char *fileName, const char *description) {
out->writeSint16BE((int16)_game.colorFg);
out->writeSint16BE((int16)_game.colorBg);
- /* game.hires */
- /* game.sbuf */
- /* game.ego_words */
- /* game.num_ego_words */
+ // game.hires
+ // game.sbuf
+ // game.ego_words
+ // game.num_ego_words
out->writeSint16BE((int16)_game.numObjects);
for (i = 0; i < (int16)_game.numObjects; i++)
out->writeSint16BE((int16)objectGetLocation(i));
- /* game.ev_keyp */
+ // game.ev_keyp
for (i = 0; i < MAX_STRINGS; i++)
out->write(_game.strings[i], MAX_STRINGLEN);
- /* record info about loaded resources */
+ // record info about loaded resources
for (i = 0; i < MAX_DIRS; i++) {
out->writeByte(_game.dirLogic[i].flags);
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++)
out->writeByte(_game.dirSound[i].flags);
- /* game.pictures */
- /* game.logics */
- /* game.views */
- /* game.sounds */
+ // game.pictures
+ // game.logics
+ // game.views
+ // game.sounds
for (i = 0; i < MAX_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->writeByte(v->currentView);
- /* v->view_data */
+ // v->view_data
out->writeByte(v->currentLoop);
out->writeByte(v->numLoops);
- /* v->loop_data */
+ // v->loop_data
out->writeByte(v->currentCel);
out->writeByte(v->numCels);
- /* v->cel_data */
- /* v->cel_data_2 */
+ // v->cel_data
+ // v->cel_data_2
out->writeSint16BE(v->xPos2);
out->writeSint16BE(v->yPos2);
- /* v->s */
+ // v->s
out->writeSint16BE(v->xSize);
out->writeSint16BE(v->ySize);
@@ -206,7 +206,7 @@ int AgiEngine::saveGame(const char *fileName, const char *description) {
out->writeByte(v->parm4);
}
- /* Save image stack */
+ // Save image stack
for (i = 0; i < _imageStack.size(); i++) {
ImageStackElement ise = _imageStack[i];
@@ -311,7 +311,7 @@ int AgiEngine::loadGame(const char *fileName, bool checkId) {
_game.lineUserInput = in->readSint16BE();
_game.lineMinPrint = in->readSint16BE();
- /* These are never saved */
+ // These are never saved
_game.cursorPos = 0;
_game.inputBuffer[0] = 0;
_game.echoBuffer[0] = 0;
@@ -339,25 +339,25 @@ int AgiEngine::loadGame(const char *fileName, bool checkId) {
_game.msgBoxTicks = 0;
_game.block.active = false;
- /* game.window - fixed by close_window() */
- /* game.has_window - fixed by close_window() */
+ // game.window - fixed by close_window()
+ // game.has_window - fixed by close_window()
_game.gfxMode = in->readSint16BE();
_game.cursorChar = in->readByte();
_game.colorFg = in->readSint16BE();
_game.colorBg = in->readSint16BE();
- /* game.hires - rebuilt from image stack */
- /* game.sbuf - rebuilt from image stack */
+ // game.hires - rebuilt from image stack
+ // game.sbuf - rebuilt from image stack
- /* game.ego_words - fixed by clean_input */
- /* game.num_ego_words - fixed by clean_input */
+ // game.ego_words - fixed by clean_input
+ // game.num_ego_words - fixed by clean_input
_game.numObjects = in->readSint16BE();
for (i = 0; i < (int16)_game.numObjects; i++)
objectSetLocation(i, in->readSint16BE());
- /* Those are not serialized */
+ // Those are not serialized
for (i = 0; i < MAX_DIRS; i++) {
_game.evKeyp[i].occured = false;
}
@@ -395,10 +395,10 @@ int AgiEngine::loadGame(const char *fileName, bool checkId) {
agiUnloadResource(rSOUND, i);
}
- /* game.pictures - loaded above */
- /* game.logics - loaded above */
- /* game.views - loaded above */
- /* game.sounds - loaded above */
+ // game.pictures - loaded above
+ // game.logics - loaded above
+ // game.views - loaded above
+ // game.sounds - loaded above
for (i = 0; i < vtEntries; i++) {
VtEntry *v = &_game.viewTable[i];
@@ -410,23 +410,23 @@ int AgiEngine::loadGame(const char *fileName, bool checkId) {
v->yPos = in->readSint16BE();
v->currentView = in->readByte();
- /* v->view_data - fixed below */
+ // v->view_data - fixed below
v->currentLoop = in->readByte();
v->numLoops = in->readByte();
- /* v->loop_data - fixed below */
+ // v->loop_data - fixed below
v->currentCel = in->readByte();
v->numCels = in->readByte();
- /* v->cel_data - fixed below */
- /* v->cel_data_2 - fixed below */
+ // v->cel_data - fixed below
+ // v->cel_data_2 - fixed below
v->xPos2 = in->readSint16BE();
v->yPos2 = in->readSint16BE();
- /* v->s - fixed below */
+ // v->s - fixed below
v->xSize = 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));
}
- /* Fix some pointers in viewtable */
+ // Fix some pointers in viewtable
for (i = 0; i < MAX_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))
agiLoadResource(rVIEW, v->currentView);
- setView(v, v->currentView); /* Fix v->view_data */
- setLoop(v, v->currentLoop); /* Fix v->loop_data */
- setCel(v, v->currentCel); /* Fix v->cel_data */
+ setView(v, v->currentView); // Fix v->view_data
+ setLoop(v, v->currentLoop); // Fix v->loop_data
+ setCel(v, v->currentCel); // Fix v->cel_data
v->celData2 = v->celData;
- v->s = NULL; /* not sure if it is used... */
+ v->s = NULL; // not sure if it is used...
}
_sprites->eraseBoth();
- /* Clear input line */
+ // Clear input line
_gfx->clearScreen(0);
writeStatus();
- /* Recreate background from saved image stack */
+ // Recreate background from saved image stack
clearImageStack();
while ((t = in->readByte()) != 0) {
for (i = 0; i < 7; i++)
@@ -483,7 +483,7 @@ int AgiEngine::loadGame(const char *fileName, bool checkId) {
parm[3], parm[4], parm[5], parm[6]);
}
- //Load AGIPAL Data
+ // Load AGIPAL Data
if (saveVersion >= 3)
_gfx->setAGIPal(in->readSint16BE());
@@ -492,7 +492,7 @@ int AgiEngine::loadGame(const char *fileName, bool checkId) {
setflag(fRestoreJustRan, true);
- _game.hasPrompt = 0; /* force input line repaint if necessary */
+ _game.hasPrompt = 0; // force input line repaint if necessary
cleanInput();
_sprites->eraseBoth();
@@ -524,13 +524,16 @@ void AgiEngine::getSavegameDescription(int num, char *buf, bool showEmpty) {
sprintf(fileName, "%s", getSavegameFilename(num));
if (!(in = _saveFileMan->openForLoading(fileName))) {
debugC(4, kDebugLevelMain | kDebugLevelSavegame, "File %s does not exist", fileName);
+
if (showEmpty)
strcpy(buf, " (empty slot)");
else
*buf = 0;
} else {
debugC(4, kDebugLevelMain | kDebugLevelSavegame, "Successfully opened %s for reading", fileName);
+
uint32 type = in->readUint32BE();
+
if (type == AGIflag) {
debugC(6, kDebugLevelMain | kDebugLevelSavegame, "Has AGI flag, good start");
in->read(buf, 31);
@@ -546,7 +549,7 @@ void AgiEngine::getSavegameDescription(int num, char *buf, bool showEmpty) {
int AgiEngine::selectSlot() {
int i, key, active = 0;
int rc = -1;
- int hm = 1, vm = 3; /* box margins */
+ int hm = 1, vm = 3; // box margins
int xmin, xmax, slotClicked;
char desc[NUM_VISIBLE_SLOTS][40];
int textCentre, buttonLength, buttonX[2], buttonY;
@@ -613,7 +616,7 @@ int AgiEngine::selectSlot() {
oldFirstSlot = _firstSlot;
}
- _gfx->pollTimer(); /* msdos driver -> does nothing */
+ _gfx->pollTimer(); // msdos driver -> does nothing
key = doPollKeyboard();
// It may happen that somebody will open GMM while
@@ -643,7 +646,7 @@ int AgiEngine::selectSlot() {
rc = -1;
goto getout;
}
- slotClicked = ((int)g_mouse.y-1)/CHAR_COLS-(vm+4);
+ slotClicked = ((int)g_mouse.y - 1) / CHAR_COLS - (vm + 4);
xmin = (hm + 1) * CHAR_COLS;
xmax = xmin + CHAR_COLS * 34;
if ((int)g_mouse.x >= xmin && (int)g_mouse.x <= xmax) {
@@ -840,7 +843,7 @@ int AgiEngine::saveGameSimple() {
int AgiEngine::loadGameDialog() {
char fileName[MAX_PATH];
int rc, slot = 0;
- int hm, vm, hp, vp; /* box margins */
+ int hm, vm, hp, vp; // box margins
int w;
hm = 1;
diff --git a/engines/agi/sound.cpp b/engines/agi/sound.cpp
index e93ebd7b43..b0856f6ddf 100644
--- a/engines/agi/sound.cpp
+++ b/engines/agi/sound.cpp
@@ -37,8 +37,9 @@ namespace Agi {
#define USE_INTERPOLATION
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) {
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) {
assert(voiceNum < 4);
uint16 voiceStartOffset = READ_LE_UINT16(_data + voiceNum * 2);
+
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.
warning("Apple IIGS sample (%d) too short (%d bytes. Should be %d bytes). Using the part that's left",
resnum, tailLen, _header.sampleSize);
+
_header.sampleSize = (uint16) tailLen; // Use the part that's left
}
if (_header.pitch > 0x7F) { // Check if the pitch is invalid
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
}
@@ -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
stream.seek(sampleStartPos);
_sample = new int8[_header.sampleSize];
+
if (_sample != NULL)
_isValid = SoundMgr::convertWave(stream, _sample, _header.sampleSize);
}
@@ -127,6 +132,7 @@ bool IIgsEnvelope::read(Common::SeekableReadStream &stream) {
seg[segNum].bp = stream.readByte();
seg[segNum].inc = stream.readUint16LE();
}
+
return !stream.ioFailed();
}
@@ -170,6 +176,7 @@ bool IIgsWaveInfo::finalize(Common::SeekableReadStream &uint8Wave) {
size = trueSize; // Set the true sample size
uint8Wave.seek(startPos); // Seek back to the stream's starting position
+
return true;
}
@@ -177,6 +184,7 @@ bool IIgsOscillator::finalize(Common::SeekableReadStream &uint8Wave) {
for (uint i = 0; i < WAVES_PER_OSCILLATOR; i++)
if (!waves[i].finalize(uint8Wave))
return false;
+
return true;
}
@@ -188,6 +196,7 @@ bool IIgsOscillatorList::read(Common::SeekableReadStream &stream, uint oscillato
return false;
count = oscillatorCount; // Set the oscillator count
+
return true;
}
@@ -195,6 +204,7 @@ bool IIgsOscillatorList::finalize(Common::SeekableReadStream &uint8Wave) {
for (uint i = 0; i < count; i++)
if (!osc[i].finalize(uint8Wave))
return false;
+
return true;
}
@@ -225,6 +235,7 @@ bool IIgsSampleHeader::read(Common::SeekableReadStream &stream) {
instrumentSize = stream.readUint16LE();
sampleSize = stream.readUint16LE();
// Read the instrument header *ignoring* its wave address info
+
return instrument.read(stream, true);
}
@@ -287,7 +298,7 @@ static const int16 waveformRamp[WAVEFORM_SIZE] = {
0, -248, -240, -232, -224, -216, -208, -200,
-192, -184, -176, -168, -160, -152, -144, -136,
-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] = {
@@ -298,7 +309,7 @@ static const int16 waveformSquare[WAVEFORM_SIZE] = {
-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, -110, 0, 0, 0, 0 /* Square */
+ -220, -220, -220, -110, 0, 0, 0, 0 // Square
};
static const int16 waveformMac[WAVEFORM_SIZE] = {
@@ -369,14 +380,17 @@ void SoundMgr::startSound(int resnum, int flag) {
break;
case AGI_SOUND_4CHN:
PCjrSound *pcjrSound = (PCjrSound *) _vm->_game.sounds[resnum];
- /* Initialize channel info */
+
+ // Initialize channel info
for (i = 0; i < NUM_CHANNELS; i++) {
_chn[i].type = type;
_chn[i].flags = AGI_SOUND_LOOP;
+
if (_env) {
_chn[i].flags |= AGI_SOUND_ENVELOPE;
_chn[i].adsr = AGI_SOUND_ENV_ATTACK;
}
+
_chn[i].ins = _waveform;
_chn[i].size = WAVEFORM_SIZE;
_chn[i].ptr = pcjrSound->getVoicePointer(i % 4);
@@ -390,8 +404,7 @@ void SoundMgr::startSound(int resnum, int flag) {
memset(_sndBuffer, 0, BUFFER_SIZE << 1);
_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);
}
@@ -424,9 +437,11 @@ void IIgsSoundMgr::stopSounds() {
bool IIgsSoundMgr::playSampleSound(const IIgsSampleHeader &sampleHeader, const int8 *sample) {
stopSounds();
IIgsMidiChannel &channel = _midiChannels[kSfxMidiChannel];
+
channel.setInstrument(&sampleHeader.instrument, sample);
channel.setVolume(sampleHeader.volume);
channel.noteOn(sampleHeader.pitch, 64); // Use default velocity (i.e. 64)
+
return true;
}
@@ -434,6 +449,7 @@ void IIgsMidiChannel::stopSounds() {
// Stops all sounds on this single MIDI channel
for (iterator iter = _gsChannels.begin(); iter != _gsChannels.end(); iter++)
iter->stop();
+
_gsChannels.clear();
}
@@ -476,6 +492,7 @@ int SoundMgr::initSound() {
void SoundMgr::deinitSound() {
debugC(3, kDebugLevelSound, "()");
+
_mixer->stopHandle(_soundHandle);
}
@@ -483,7 +500,7 @@ void SoundMgr::stopNote(int i) {
_chn[i].adsr = AGI_SOUND_ENV_RELEASE;
if (g_useChorus) {
- /* Stop chorus ;) */
+ // Stop chorus ;)
if (_chn[i].type == AGI_SOUND_4CHN &&
_vm->_soundemu == SOUND_EMU_NONE && i < 3) {
stopNote(i + 4);
@@ -504,12 +521,15 @@ void SoundMgr::playNote(int i, int freq, int vol) {
_chn[i].adsr = AGI_SOUND_ENV_ATTACK;
if (g_useChorus) {
- /* Add chorus ;) */
+ // Add chorus ;)
if (_chn[i].type == AGI_SOUND_4CHN &&
_vm->_soundemu == SOUND_EMU_NONE && i < 3) {
+
int newfreq = freq * 1007 / 1000;
+
if (freq == newfreq)
newfreq++;
+
playNote(i + 4, newfreq, vol * 2 / 3);
}
}
@@ -526,6 +546,7 @@ void SoundMgr::playMidiSound() {
if (_playingSound == -1 || _vm->_game.sounds[_playingSound] == NULL) {
warning("Error playing Apple IIGS MIDI sound resource");
_playing = false;
+
return;
}
@@ -543,11 +564,14 @@ void SoundMgr::playMidiSound() {
if (readByte == MIDI_BYTE_STOP_SEQUENCE) {
debugC(3, kDebugLevelSound, "End of MIDI sequence (Before reading delta-time)");
_playing = false;
+
midiObj->rewind();
+
return;
} else if (readByte == MIDI_BYTE_TIMER_SYNC) {
debugC(3, kDebugLevelSound, "Timer sync");
p++; // Jump over the timer sync byte as it's not needed
+
continue;
}
@@ -562,7 +586,9 @@ void SoundMgr::playMidiSound() {
if (*p == MIDI_BYTE_STOP_SEQUENCE) {
debugC(3, kDebugLevelSound, "End of MIDI sequence (After reading delta-time)");
_playing = false;
+
midiObj->rewind();
+
return;
}
@@ -597,6 +623,7 @@ void SoundMgr::playMidiSound() {
case MIDI_CMD_PITCH_WHEEL:
parm1 = *p++;
parm2 = *p++;
+
uint16 wheelPos = ((parm2 & 0x7F) << 7) | (parm1 & 0x7F); // 14-bit value
_gsSound.midiPitchWheel(wheelPos);
break;
@@ -675,22 +702,27 @@ void IIgsMidiChannel::removeStoppedSounds() {
uint IIgsSoundMgr::activeSounds() const {
uint result = 0;
+
for (Common::Array<IIgsMidiChannel>::const_iterator iter = _midiChannels.begin(); iter != _midiChannels.end(); iter++)
result += iter->activeSounds();
+
return result;
}
uint IIgsMidiChannel::activeSounds() const {
uint result = 0;
+
for (const_iterator iter = _gsChannels.begin(); iter != _gsChannels.end(); iter++)
if (!iter->end)
result++;
+
return result;
}
void IIgsMidiChannel::setInstrument(const IIgsInstrumentHeader *instrument, const int8 *sample) {
_instrument = instrument;
_sample = sample;
+
// Set program on each Apple IIGS channel playing on this MIDI channel
for (iterator iter = _gsChannels.begin(); iter != _gsChannels.end(); iter++)
iter->setInstrument(instrument, sample);
@@ -698,6 +730,7 @@ void IIgsMidiChannel::setInstrument(const IIgsInstrumentHeader *instrument, cons
void IIgsMidiChannel::setVolume(uint8 volume) {
_volume = volume;
+
// Set volume on each Apple IIGS channel playing on this MIDI channel
for (iterator iter = _gsChannels.begin(); iter != _gsChannels.end(); iter++)
iter->setChannelVolume(volume);
@@ -713,9 +746,11 @@ void IIgsMidiChannel::noteOff(uint8 note, uint8 velocity) {
void IIgsMidiChannel::noteOn(uint8 note, uint8 velocity) {
IIgsChannelInfo channel;
+
// Use the default channel volume and instrument
channel.setChannelVolume(_volume);
channel.setInstrument(_instrument, _sample);
+
// Set the note on and save the channel
channel.noteOn(note, velocity);
_gsChannels.push_back(channel);
@@ -742,11 +777,15 @@ void IIgsChannelInfo::noteOn(uint8 noteParam, uint8 velocity) {
this->origNote = noteParam;
this->startEnvVol = intToFrac(0);
rewind();
+
const IIgsWaveInfo *waveInfo = NULL;
+
for (uint i = 0; i < ins->oscList.count; i++)
if (ins->oscList(i).waves[0].top >= noteParam)
waveInfo = &ins->oscList(i).waves[0];
+
assert(waveInfo != NULL);
+
this->relocatedSample = this->unrelocatedSample + waveInfo->addr;
this->posAdd = intToFrac(0);
this->note = intToFrac(noteParam) + doubleToFrac(waveInfo->relPitch/256.0);
@@ -808,7 +847,7 @@ void SoundMgr::playAgiSound() {
_chn[i].env = 0;
if (g_useChorus) {
- /* chorus */
+ // chorus
if (_chn[i].type == AGI_SOUND_4CHN && _vm->_soundemu == SOUND_EMU_NONE && i < 3) {
_chn[i + 4].vol = 0;
_chn[i + 4].env = 0;
@@ -929,7 +968,7 @@ uint32 SoundMgr::mixSound(void) {
}
_gsSound.removeStoppedSounds();
return IIGS_BUFFER_SIZE;
- } /* else ... */
+ } // else ...
// Handle PCjr 4-channel sound mixing here
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
// needs fixing, or remove it!
- /* FIXME */
+ // FIXME
if (_chn[c].flags & AGI_SOUND_LOOP) {
p %= _chn[c].size << 8;
} else {
@@ -968,7 +1007,7 @@ uint32 SoundMgr::mixSound(void) {
}
_chn[c].phase = p;
} else {
- /* Add white noise */
+ // Add white noise
for (i = 0; i < BUFFER_SIZE; i++) {
b = _vm->_rnd->getRandomNumber(255) - 128;
_sndBuffer[i] += (b * m) >> 4;
@@ -977,7 +1016,7 @@ uint32 SoundMgr::mixSound(void) {
switch (_chn[c].adsr) {
case AGI_SOUND_ENV_ATTACK:
- /* not implemented */
+ // not implemented
_chn[c].adsr = AGI_SOUND_ENV_DECAY;
break;
case AGI_SOUND_ENV_DECAY:
@@ -1040,6 +1079,7 @@ bool IIgsSoundMgr::loadInstrumentHeaders(const Common::FSNode &exePath, const II
// Check instrument set's md5sum
data->seek(exeInfo.instSetStart);
+
char md5str[32+1];
Common::md5_file_string(*data, md5str, exeInfo.instSet.byteCount);
if (scumm_stricmp(md5str, exeInfo.instSet.md5)) {
@@ -1053,6 +1093,7 @@ bool IIgsSoundMgr::loadInstrumentHeaders(const Common::FSNode &exePath, const II
// Load the instruments
_instruments.clear();
_instruments.reserve(exeInfo.instSet.instCount);
+
IIgsInstrumentHeader instrument;
for (uint i = 0; i < exeInfo.instSet.instCount; i++) {
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" \
"Using the wave file as it is - music may sound weird", md5str, exeInfo.exePrefix);
}
+
uint8Wave->seek(0); // Seek wave to its start
// Convert the wave file from 8-bit unsigned to 8-bit signed and save the result
_wave.resize(uint8Wave->size());
diff --git a/engines/agi/sprite.cpp b/engines/agi/sprite.cpp
index 5ca0d5ca1e..d2ad494f4e 100644
--- a/engines/agi/sprite.cpp
+++ b/engines/agi/sprite.cpp
@@ -50,15 +50,14 @@ struct Sprite {
#undef ALLOC_DEBUG
-#define POOL_SIZE 68000 /* Gold Rush mine room needs > 50000 */
- /* Speeder bike challenge needs > 67000 */
+#define POOL_SIZE 68000 // Gold Rush mine room needs > 50000
+ // Speeder bike challenge needs > 67000
void *SpritesMgr::poolAlloc(int size) {
uint8 *x;
- /* Adjust size to 32-bit boundary to prevent data misalignment
- * errors.
- */
+ // Adjust size to 32-bit boundary to prevent data misalignment
+ // errors.
size = (size + 3) & ~3;
x = _poolTop;
@@ -73,9 +72,8 @@ void *SpritesMgr::poolAlloc(int size) {
return x;
}
-/* Note: it's critical that pool_release() is called in the exact
- reverse order of pool_alloc()
-*/
+// Note: it's critical that pool_release() is called in the exact
+// reverse order of pool_alloc()
void SpritesMgr::poolRelease(void *s) {
_poolTop = (uint8 *)s;
}
@@ -84,27 +82,25 @@ void SpritesMgr::poolRelease(void *s) {
* 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) {
- 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
- * tracking effective priority. This tweak is needed to fix
- * Sarien bug #451768, and should not affect Sierra games because
- * sprites shouldn't have priority 15 (like the AGI Mouse
- * demo "mouse pointer")
- *
- * Update: this solution breaks other games, and can't be used.
- */
+ // CM: priority 15 overrides control lines and is ignored when
+ // tracking effective priority. This tweak is needed to fix
+ // Sarien bug #451768, and should not affect Sierra games because
+ // sprites shouldn't have priority 15 (like the AGI Mouse
+ // demo "mouse pointer")
+ //
+ // Update: this solution breaks other games, and can't be used.
if (p >= end)
return;
- /* Check if we're on a control line */
+ // Check if we're on a control line
if ((pr = *p & 0xf0) < 0x30) {
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)
;
if (p1 >= end)
@@ -114,9 +110,8 @@ void SpritesMgr::blitPixel(uint8 *p, uint8 *end, uint8 col, int spr, int width,
}
if (spr >= epr) {
- /* Keep control line information visible, but put our
- * priority over water (0x30) surface
- */
+ // Keep control line information visible, but put our
+ // priority over water (0x30) surface
if (_vm->getFeatures() & (GF_AGI256 | GF_AGI256_2))
*(p + FROM_SBUF16_TO_SBUF256_OFFSET) = col; // Write to 256 color buffer
else
@@ -124,14 +119,13 @@ void SpritesMgr::blitPixel(uint8 *p, uint8 *end, uint8 col, int spr, int width,
*hidden = false;
- /* Except if our priority is 15, which should never happen
- * (fixes Sarien bug #451768)
- *
- * Update: breaks other games, can't be used
- *
- * if (spr == 0xf0)
- * *p = spr | col;
- */
+ // Except if our priority is 15, which should never happen
+ // (fixes Sarien bug #451768)
+ //
+ // Update: breaks other games, can't be used
+ //
+ // if (spr == 0xf0)
+ // *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 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)
y = 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.
*/
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)
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.
*/
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)
return false;
@@ -285,7 +279,7 @@ INLINE int SpritesMgr::prioToY(int p) {
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)
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->yPos = v->yPos - v->ySize + 1;
s->xSize = v->xSize;
s->ySize = v->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;
}
@@ -326,9 +320,8 @@ void SpritesMgr::buildList(SpriteList &l, bool (*test)(VtEntry *, AgiEngine *))
int yVal[0x100];
int minY = 0xff, minIndex = 0;
- /* fill the arrays with all sprites that satisfy the 'test'
- * condition and their y values
- */
+ // fill the arrays with all sprites that satisfy the 'test'
+ // condition and their y values
i = 0;
for (v = _vm->_game.viewTable; v < &_vm->_game.viewTable[MAX_VIEWTABLE]; v++) {
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
- * sprite in the list
- */
+ // now look for the smallest y value in the array and put that
+ // sprite in the list
for (j = 0; j < i; j++) {
minY = 0xff;
+
for (k = 0; k < i; k++) {
if (yVal[k] < minY) {
minIndex = k;
@@ -376,6 +369,7 @@ void SpritesMgr::freeList(SpriteList &l) {
SpriteList::iterator iter;
for (iter = l.reverse_begin(); iter != l.end(); ) {
Sprite* s = *iter;
+
poolRelease(s->buffer);
poolRelease(s);
iter = l.reverse_erase(iter);
@@ -452,12 +446,15 @@ void SpritesMgr::eraseSprites(SpriteList &l) {
void SpritesMgr::blitSprites(SpriteList& l) {
int hidden;
SpriteList::iterator iter;
+
for (iter = l.begin(); iter != l.end(); ++iter) {
Sprite *s = *iter;
+
objsSaveArea(s);
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);
- if (s->v->entry == 0) { /* if ego, update f1 */
+
+ if (s->v->entry == 0) { // if ego, update f1
_vm->setflag(fEgoInvisible, hidden);
}
}
@@ -475,7 +472,7 @@ void SpritesMgr::commitNonupdSprites() {
commitSprites(_sprNonupd);
}
-/* check moves in both lists */
+// check moves in both lists
void SpritesMgr::commitBoth() {
commitUpdSprites();
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);
- /*
- * Was hardcoded to 8, changed to pri_table[y] to fix Gold
- * Rush (see Sarien bug #587558)
- */
+ // Was hardcoded to 8, changed to pri_table[y] to fix Gold
+ // Rush (see Sarien bug #587558)
if (pri == 0)
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);
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
- * surrounded with a rectangle of the corresponding priority.
- * If margin >= 4, this extra margin is not shown.
- */
+ // If margin is 0, 1, 2, or 3, the base of the cel is
+ // surrounded with a rectangle of the corresponding priority.
+ // If margin >= 4, this extra margin is not shown.
if (mar < 4) {
- /* add rectangle around object, don't clobber control
- * info in priority data. The box extends to the end of
- * its priority band!
- */
+ // add rectangle around object, don't clobber control
+ // info in priority data. The box extends to the end of
+ // its priority band!
y3 = (y2 / 12) * 12;
// 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++) {
if ((*p1 >> 4) >= 4)
*p1 = (mar << 4) | (*p1 & 0x0f);
+
if ((*p2 >> 4) >= 4)
*p2 = (mar << 4) | (*p2 & 0x0f);
+
p1 += _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++) {
if ((*p1 >> 4) >= 4)
*p1 = (mar << 4) | (*p1 & 0x0f);
+
if ((*p2 >> 4) >= 4)
*p2 = (mar << 4) | (*p2 & 0x0f);
+
p1++;
p2++;
}
@@ -718,6 +715,7 @@ void SpritesMgr::commitBlock(int x1, int y1, int x2, int y2) {
w = x2 - x1 + 1;
q = &_vm->_game.sbuf16c[x1 + _WIDTH * y1];
offset = _vm->_game.lineMinPrint * CHAR_LINES;
+
for (i = y1; i <= y2; i++) {
_gfx->putPixelsA(x1, i + offset, w, q);
q += _WIDTH;
diff --git a/engines/agi/sprite.h b/engines/agi/sprite.h
index 3f9b329076..0bdb405fd5 100644
--- a/engines/agi/sprite.h
+++ b/engines/agi/sprite.h
@@ -46,9 +46,9 @@ private:
uint8 *_spritePool;
uint8 *_poolTop;
- /*
- * Sprite management functions
- */
+ //
+ // Sprite management functions
+ //
SpriteList _sprUpd;
SpriteList _sprNonupd;
diff --git a/engines/agi/text.cpp b/engines/agi/text.cpp
index 63b109ee83..6317eb0298 100644
--- a/engines/agi/text.cpp
+++ b/engines/agi/text.cpp
@@ -24,7 +24,7 @@
*/
#include "agi/agi.h"
-#include "agi/sprite.h" /* for commit_both() */
+#include "agi/sprite.h" // for commit_both()
#include "agi/graphics.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 maxx, minx, ofoff;
int update;
- /* Note: Must be unsigned to use AGDS cyrillic characters! */
+ // Note: Must be unsigned to use AGDS cyrillic characters!
#ifdef __DS__
// 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)
@@ -45,20 +45,19 @@ void AgiEngine::printText2(int l, const char *msg, int foff, int xoff, int yoff,
const unsigned char *m;
#endif
- /* kludge! */
+ // kludge!
update = 1;
if (l == 2) {
update = l = 0;
}
- /* FR: strings with len == 1 were not printed
- */
+ // FR: strings with len == 1 were not printed
if (len == 1) {
_gfx->putTextCharacter(l, xoff + foff, yoff, *msg, fg, bg, checkerboard);
maxx = 1;
minx = 0;
ofoff = foff;
- y1 = 0; /* Check this */
+ y1 = 0; // Check this
} else {
maxx = 0;
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) {
// FIXME: Fingolfin asks: why is there a FIXME here? Please either clarify what
// needs fixing, or remove it!
- /* FIXME */
+ // FIXME
int ypos;
ypos = (y1 * CHAR_LINES) + yoff;
@@ -92,7 +91,7 @@ void AgiEngine::printText2(int l, const char *msg, int foff, int xoff, int yoff,
x1++;
- /* DF: changed the len-1 to len... */
+ // DF: changed the len-1 to len...
if (x1 == len && m[len] != '\n')
y1++, x1 = foff = 0;
} else {
@@ -114,17 +113,18 @@ void AgiEngine::printText2(int l, const char *msg, int foff, int xoff, int yoff,
if (update) {
_gfx->scheduleUpdate(foff + xoff + minx, yoff, ofoff + xoff + maxx + CHAR_COLS - 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();
}
}
-/* len is in characters, not pixels!!
- */
+//
+// len is in characters, not pixels!!
+//
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;
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);
for (lin = 1; *m; m++) {
- /* Test \r for MacOS 8 */
+ // Test \r for MacOS 8
if (*m == '\n' || *m == '\r')
lin++;
}
@@ -301,9 +301,9 @@ void AgiEngine::closeWindow() {
debugC(4, kDebugLevelText, "closeWindow()");
_sprites->eraseBoth();
- eraseTextbox(); /* remove window, if any */
+ eraseTextbox(); // remove window, if any
_sprites->blitBoth();
- _sprites->commitBoth(); /* redraw sprites */
+ _sprites->commitBoth(); // redraw sprites
_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;
debugC(3, kDebugLevelText, "selectionBox(): s = %d", s);
- /* Automatically position buttons */
+ // Automatically position buttons
for (i = 0; b[i]; i++) {
numButtons++;
s -= CHAR_COLS * strlen(b[i]);
@@ -371,7 +371,7 @@ int AgiEngine::selectionBox(const char *m, const char **b) {
_sprites->blitBoth();
- /* clear key queue */
+ // clear key queue
while (_gfx->keypress()) {
_gfx->getKey();
}
@@ -383,7 +383,7 @@ int AgiEngine::selectionBox(const char *m, const char **b) {
for (i = 0; b[i]; i++)
_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();
switch (key) {
case KEY_ENTER:
@@ -410,7 +410,7 @@ int AgiEngine::selectionBox(const char *m, const char **b) {
}
}
break;
- case 0x09: /* Tab */
+ case 0x09: // Tab
debugC(3, kDebugLevelText, "selectionBox(): Focus change");
active++;
active %= i;
@@ -449,12 +449,12 @@ int AgiEngine::print(const char *p, int lin, int col, int len) {
blitTextbox(p, lin, col, len);
if (getflag(fOutputMode)) {
- /* non-blocking window */
+ // non-blocking window
setflag(fOutputMode, false);
return 1;
}
- /* blocking */
+ // blocking
setflag(fNoSaveLoadAllowed, true);
@@ -469,7 +469,7 @@ int AgiEngine::print(const char *p, int lin, int col, int len) {
return k;
}
- /* timed window */
+ // timed window
debugC(3, kDebugLevelText, "f15==0, v21==%d => timed", getvar(21));
_game.msgBoxTicks = getvar(vWindowReset) * 10;
@@ -561,8 +561,8 @@ char *AgiEngine::agiSprintf(const char *s) {
}
if (i == 99) {
- /* remove all leading 0 */
- /* don't remove the 3rd zero if 000 */
+ // remove all leading 0
+ // don't remove the 3rd zero if 000
for (i = 0; z[i] == '0' && i < 14; i++)
;
} else {
@@ -683,10 +683,9 @@ void AgiEngine::writePrompt() {
* @param c color
*/
void AgiEngine::clearLines(int l1, int l2, int c) {
- /* do we need to adjust for +8 on topline?
- * inc for endline so it matches the correct num
- * ie, from 22 to 24 is 3 lines, not 2 lines.
- */
+ // do we need to adjust for +8 on topline?
+ // inc for endline so it matches the correct num
+ // ie, from 22 to 24 is 3 lines, not 2 lines.
l1 *= CHAR_LINES;
l2 *= CHAR_LINES;
diff --git a/engines/agi/view.cpp b/engines/agi/view.cpp
index 07387161e8..69b8d82f58 100644
--- a/engines/agi/view.cpp
+++ b/engines/agi/view.cpp
@@ -36,9 +36,8 @@ void AgiEngine::lSetCel(VtEntry *v, int n) {
currentVl = &_game.views[v->currentView].loop[v->currentLoop];
- /* Added by Amit Vainsencher <amitv@subdimension.com> to prevent
- * crash in KQ1 -- not in the Sierra interpreter
- */
+ // Added by Amit Vainsencher <amitv@subdimension.com> to prevent
+ // crash in KQ1 -- not in the Sierra interpreter
if (currentVl->numCels == 0)
return;
@@ -64,9 +63,8 @@ void AgiEngine::lSetLoop(VtEntry *v, int n) {
ViewLoop *currentVl;
debugC(7, kDebugLevelResources, "vt entry #%d, loop = %d", v->entry, n);
- /* Added to avoid crash when leaving the arcade machine in MH1
- * -- not in AGI 2.917
- */
+ // Added to avoid crash when leaving the arcade machine in MH1
+ // -- not in AGI 2.917
if (n >= v->numLoops)
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].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)
return errNoLoopsInView;
- /* allocate memory for all views */
+ // allocate memory for all views
_game.views[n].loop = (ViewLoop *)
calloc(_game.views[n].numLoops, sizeof(ViewLoop));
if (_game.views[n].loop == NULL)
return errNotEnoughMemory;
- /* decode all of the loops in this view */
- lptr = v + 5; /* first loop address */
+ // decode all of the loops in this view
+ lptr = v + 5; // first loop address
for (loop = 0; loop < _game.views[n].numLoops; loop++, lptr += 2) {
- lofs = READ_LE_UINT16(lptr); /* loop header offset */
- vl = &_game.views[n].loop[loop]; /* the loop struct */
+ lofs = READ_LE_UINT16(lptr); // loop header offset
+ vl = &_game.views[n].loop[loop]; // the loop struct
vl->numCels = *(v + lofs);
debugC(6, kDebugLevelResources, "view %d, num_cels = %d", n, vl->numCels);
vl->cel = (ViewCel *)calloc(vl->numCels, sizeof(ViewCel));
+
if (vl->cel == NULL) {
free(_game.views[n].loop);
_game.views[n].numLoops = 0;
return errNotEnoughMemory;
}
- /* decode the cells */
+ // decode the cells
for (cel = 0; cel < vl->numCels; cel++) {
cofs = lofs + READ_LE_UINT16(v + lofs + 1 + (cel * 2));
vc = &vl->cel[cel];
@@ -201,17 +200,17 @@ int AgiEngine::decodeView(int n) {
vc->mirror = 0;
}
- /* skip over width/height/trans|mirror data */
+ // skip over width/height/trans|mirror data
cofs += 3;
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)
vc->mirror = 0;
- } /* cel */
- } /* loop */
+ } // cel
+ } // loop
return errOK;
}
@@ -227,12 +226,12 @@ void AgiEngine::unloadView(int n) {
if (~_game.dirView[n].flags & RES_LOADED)
return;
- /* Rebuild sprite list, see Sarien bug #779302 */
+ // Rebuild sprite list, see Sarien bug #779302
_sprites->eraseBoth();
_sprites->blitBoth();
_sprites->commitBoth();
- /* free all the loops */
+ // free all the loops
for (x = 0; x < _game.views[n].numLoops; x++)
free(_game.views[n].loop[x].cel);
@@ -253,7 +252,7 @@ void AgiEngine::setCel(VtEntry *v, int n) {
lSetCel(v, n);
- /* If position isn't appropriate, update it accordingly */
+ // If position isn't appropriate, update it accordingly
clipViewCoordinates(v);
}
@@ -308,6 +307,7 @@ void AgiEngine::setView(VtEntry *v, int n) {
if (v->currentView == 118 && v->flags & DRAWN && getGameID() == GID_SQ1) {
viewFlags = v->flags; // Store the flags for the view
_sprites->eraseUpdSprites();
+
if (v->flags & UPDATE) {
v->flags &= ~DRAWN;
} else {
@@ -335,6 +335,7 @@ void AgiEngine::setView(VtEntry *v, int n) {
void AgiEngine::startUpdate(VtEntry *v) {
if (~v->flags & UPDATE) {
_sprites->eraseBoth();
+
v->flags |= UPDATE;
_sprites->blitBoth();
}
@@ -347,14 +348,14 @@ void AgiEngine::startUpdate(VtEntry *v) {
void AgiEngine::stopUpdate(VtEntry *v) {
if (v->flags & UPDATE) {
_sprites->eraseBoth();
+
v->flags &= ~UPDATE;
_sprites->blitBoth();
}
}
-/* loops to use according to direction and number of loops in
- * the view resource
- */
+// loops to use according to direction and number of loops in
+// the view resource
static int loopTable2[] = {
0x04, 0x04, 0x00, 0x00, 0x00, 0x04, 0x01, 0x01, 0x01
};
@@ -391,14 +392,14 @@ void AgiEngine::updateViewtable() {
loop = loopTable4[v->direction];
break;
default:
- /* for KQ4 */
+ // for KQ4
if (agiGetRelease() == 0x3086)
loop = loopTable4[v->direction];
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 (agiGetRelease() <= 0x2272 ||
v->stepTimeCount == 1) {
diff --git a/engines/agi/view.h b/engines/agi/view.h
index a94de53c87..e71db6c97d 100644
--- a/engines/agi/view.h
+++ b/engines/agi/view.h
@@ -120,7 +120,7 @@ struct VtEntry {
uint8 parm2;
uint8 parm3;
uint8 parm4;
-}; /* struct vt_entry */
+}; // struct vt_entry
} // End of namespace Agi
diff --git a/engines/agi/words.cpp b/engines/agi/words.cpp
index d3726731ca..4396797e6b 100644
--- a/engines/agi/words.cpp
+++ b/engines/agi/words.cpp
@@ -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/keyboard.h" /* for clean_input() */
+#include "agi/keyboard.h" // for clean_input()
namespace Agi {
-static uint8 *words; /* words in the game */
-static uint32 wordsFlen; /* length of word memory */
+static uint8 *words; // words in the game
+static uint32 wordsFlen; // length of word memory
-/*
- * Local implementation to avoid problems with strndup() used by
- * gcc 3.2 Cygwin (see #635984)
- */
+//
+// Local implementation to avoid problems with strndup() used by
+// gcc 3.2 Cygwin (see #635984)
+//
static char *myStrndup(char *src, int n) {
char *tmp = strncpy((char *)malloc(n + 1), src, n);
tmp[n] = 0;
@@ -54,7 +54,7 @@ int AgiEngine::loadWords(const char *fname) {
if (!fp.open(fname)) {
report("Warning: can't open %s\n", fname);
- return errOK /*err_BadFileOpen */ ;
+ return errOK; // err_BadFileOpen
}
report("Loading dictionary: %s\n", fname);
@@ -91,13 +91,14 @@ void AgiEngine::unloadWords() {
* Thomas Akesson, November 2001
*/
int AgiEngine::findWord(char *word, int *flen) {
- int mchr = 0; /* matched chars */
+ int mchr = 0; // matched chars
int len, fchr, id = -1;
uint8 *p = words;
uint8 *q = words + wordsFlen;
*flen = 0;
debugC(2, kDebugLevelScripts, "find_word(%s)", word);
+
if (word[0] >= 'a' && word[0] <= 'z')
fchr = word[0] - 'a';
else
@@ -105,22 +106,20 @@ int AgiEngine::findWord(char *word, int *flen) {
len = strlen(word);
- /* Get the offset to the first word beginning with the
- * right character
- */
+ // Get the offset to the first word beginning with the
+ // right character
p += READ_BE_UINT16(p + 2 * fchr);
while (p[0] >= mchr) {
if (p[0] == mchr) {
p++;
- /* Loop through all matching characters */
+ // Loop through all matching characters
while ((p[0] ^ word[mchr]) == 0x7F && mchr < len) {
mchr++;
p++;
}
- /* Check if this is the last character of the word
- * and if it matches
- */
+ // Check if this is the last character of the word
+ // and if it matches
if ((p[0] ^ word[mchr]) == 0xFF && mchr < len) {
mchr++;
if (word[mchr] == 0 || word[mchr] == 0x20) {
@@ -132,9 +131,10 @@ int AgiEngine::findWord(char *word, int *flen) {
if (p >= q)
return -1;
- /* Step to the next word */
+ // Step to the next word
while (p[0] < 0x80)
p++;
+
p += 3;
}
@@ -164,20 +164,24 @@ void AgiEngine::dictionaryWords(char *msg) {
case -1:
debugC(2, kDebugLevelScripts, "unknown word");
_game.egoWords[_game.numEgoWords].word = strdup(p);
+
q = _game.egoWords[_game.numEgoWords].word;
+
_game.egoWords[_game.numEgoWords].id = 19999;
setvar(vWordNotFound, 1 + _game.numEgoWords);
+
_game.numEgoWords++;
+
p += strlen(p);
break;
case 0:
- /* ignore this word */
+ // ignore this word
debugC(2, kDebugLevelScripts, "ignore word");
p += wlen;
q = NULL;
break;
default:
- /* an OK word */
+ // an OK word
debugC(3, kDebugLevelScripts, "ok word (%d)", wid);
_game.egoWords[_game.numEgoWords].id = wid;
_game.egoWords[_game.numEgoWords].word = myStrndup(p, wlen);
@@ -209,4 +213,4 @@ void AgiEngine::dictionaryWords(char *msg) {
}
}
-}// End of namespace Agi
+} // End of namespace Agi