aboutsummaryrefslogtreecommitdiff
path: root/engines/agi
diff options
context:
space:
mode:
authorWillem Jan Palenstijn2013-04-18 23:35:23 +0200
committerWillem Jan Palenstijn2013-05-08 20:40:58 +0200
commit9c2341678ef4984bf92b3878295250faf980b066 (patch)
tree2fb4805e05e16b9924e80c9947e6bad723b28c4b /engines/agi
parent8172d679df5148a4a32f46074b20cb6caf91844f (diff)
parenta5f4ff36ffc386d48f2da49387a9655ce9295a4d (diff)
downloadscummvm-rg350-9c2341678ef4984bf92b3878295250faf980b066.tar.gz
scummvm-rg350-9c2341678ef4984bf92b3878295250faf980b066.tar.bz2
scummvm-rg350-9c2341678ef4984bf92b3878295250faf980b066.zip
Merge branch 'master'
Diffstat (limited to 'engines/agi')
-rw-r--r--engines/agi/agi.cpp14
-rw-r--r--engines/agi/agi.h5
-rw-r--r--engines/agi/checks.cpp16
-rw-r--r--engines/agi/cycle.cpp82
-rw-r--r--engines/agi/detection_tables.h18
-rw-r--r--engines/agi/graphics.cpp4
-rw-r--r--engines/agi/menu.cpp129
-rw-r--r--engines/agi/menu.h4
-rw-r--r--engines/agi/objects.cpp2
-rw-r--r--engines/agi/op_cmd.cpp9
-rw-r--r--engines/agi/opcodes.cpp4
-rw-r--r--engines/agi/picture.h2
-rw-r--r--engines/agi/preagi_mickey.h2
-rw-r--r--engines/agi/preagi_troll.cpp4
-rw-r--r--engines/agi/preagi_winnie.cpp61
-rw-r--r--engines/agi/predictive.cpp66
-rw-r--r--engines/agi/saveload.cpp197
-rw-r--r--engines/agi/sound_2gs.cpp16
-rw-r--r--engines/agi/sound_2gs.h2
-rw-r--r--engines/agi/sound_sarien.cpp4
-rw-r--r--engines/agi/sprite.cpp2
-rw-r--r--engines/agi/sprite.h2
-rw-r--r--engines/agi/text.cpp23
-rw-r--r--engines/agi/wagparser.cpp4
-rw-r--r--engines/agi/words.cpp2
25 files changed, 361 insertions, 313 deletions
diff --git a/engines/agi/agi.cpp b/engines/agi/agi.cpp
index 4ed606c3ba..e9c9645768 100644
--- a/engines/agi/agi.cpp
+++ b/engines/agi/agi.cpp
@@ -250,19 +250,7 @@ void AgiEngine::processEvents() {
// Not a special key, so get the ASCII code for it
key = event.kbd.ascii;
- // Function isalpha is defined in <ctype.h> so the following applies to it:
- //
- // The C Programming Language Standard states:
- // The header <ctype.h> declares several functions useful for classifying
- // and mapping characters. In all cases the argument is an int, the value
- // of which shall be representable as an unsigned char or shall equal the
- // value of the macro EOF. If the argument has any other value, the
- // behavior is undefined.
- //
- // For a concrete example (e.g. in Microsoft Visual Studio 2003):
- // When used with a debug CRT library, isalpha will display a CRT assert
- // if passed a parameter that isn't EOF or in the range of 0 through 0xFF.
- if (key >= 0 && key <= 0xFF && isalpha(key)) {
+ if (Common::isAlpha(key)) {
// Key is A-Z.
// Map Ctrl-A to 1, Ctrl-B to 2, etc.
if (event.kbd.flags & Common::KBD_CTRL) {
diff --git a/engines/agi/agi.h b/engines/agi/agi.h
index 6bb3beec78..55b4805022 100644
--- a/engines/agi/agi.h
+++ b/engines/agi/agi.h
@@ -28,6 +28,7 @@
#include "common/util.h"
#include "common/file.h"
#include "common/rect.h"
+#include "common/rendermode.h"
#include "common/stack.h"
#include "common/system.h"
@@ -631,7 +632,7 @@ struct AgiGame {
AgiLogic *_curLogic;
// words
- Common::Array<AgiWord*> words[26];
+ Common::Array<AgiWord *> words[26];
// view table
VtEntry viewTable[MAX_VIEWTABLE];
@@ -809,8 +810,6 @@ public:
virtual void replayImageStackCall(uint8 type, int16 p1, int16 p2, int16 p3,
int16 p4, int16 p5, int16 p6, int16 p7) = 0;
virtual void releaseImageStack() = 0;
- virtual int saveGame(const Common::String &fileName, const Common::String &saveName) = 0;
- virtual int loadGame(const Common::String &fileName, bool checkId = true) = 0;
int _soundemu;
diff --git a/engines/agi/checks.cpp b/engines/agi/checks.cpp
index c3b31f6ba9..624476509e 100644
--- a/engines/agi/checks.cpp
+++ b/engines/agi/checks.cpp
@@ -113,6 +113,22 @@ int AgiEngine::checkPriority(VtEntry *v) {
water = 1;
+ // Check if any picture is loaded before checking for priority below.
+ // If no picture has been loaded, the priority buffer won't be initialized,
+ // thus the check below will always fail. This case causes an infinite loop
+ // in the fanmade game Nick's Quest (bug #3451122), as the game attempts to
+ // draw a sprite (view 4, floating Nick) before it loads any picture. This
+ // causes the checks below to always fail, and the engine keeps readjusting
+ // the sprite's position in fixPosition() forever, as there is no valid
+ // position to place it (the default visual and priority screen is set to
+ // zero, i.e. unconditional black). To remedy this situation, we always
+ // return true here if no picture has been loaded and no priority screen
+ // has been set up.
+ if (!_game._vm->_picture->isPictureLoaded()) {
+ warning("checkPriority: no picture loaded");
+ return pass;
+ }
+
p0 = &_game.sbuf16c[v->xPos + v->yPos * _WIDTH];
for (i = 0; i < v->xSize; i++, p0++) {
diff --git a/engines/agi/cycle.cpp b/engines/agi/cycle.cpp
index 9cbab1f3c4..5daadbd1df 100644
--- a/engines/agi/cycle.cpp
+++ b/engines/agi/cycle.cpp
@@ -200,10 +200,11 @@ int AgiEngine::mainCycle() {
// vars in every interpreter cycle.
//
// We run AGIMOUSE always as a side effect
- if (getFeatures() & GF_AGIMOUSE || true) {
+ //if (getFeatures() & GF_AGIMOUSE) {
_game.vars[28] = _mouse.x / 2;
_game.vars[29] = _mouse.y;
- }
+ //}
+
if (key == KEY_PRIORITY) {
_sprites->eraseBoth();
_debug.priority = !_debug.priority;
@@ -247,44 +248,47 @@ int AgiEngine::mainCycle() {
if (kascii)
setvar(vKey, kascii);
-process_key:
-
- switch (_game.inputMode) {
- case INPUT_NORMAL:
- if (!handleController(key)) {
- if (key == 0 || !_game.inputEnabled)
- 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 (key == KEY_ESCAPE) {
- key = 0;
- goto process_key;
+ bool restartProcessKey;
+ do {
+ restartProcessKey = false;
+
+ switch (_game.inputMode) {
+ case INPUT_NORMAL:
+ if (!handleController(key)) {
+ if (key == 0 || !_game.inputEnabled)
+ 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 (key == KEY_ESCAPE) {
+ key = 0;
+ restartProcessKey = true;
+ }
+
+ // 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
+ break;
+ case INPUT_MENU:
+ _menu->keyhandler(key);
+ _gfx->doUpdate();
+ return false;
+ case INPUT_NONE:
+ handleController(key);
+ if (key)
+ _game.keypress = key;
+ break;
}
- break;
- case INPUT_GETSTRING:
- handleController(key);
- handleGetstring(key);
- setvar(vKey, 0); // clear ENTER key
- break;
- case INPUT_MENU:
- _menu->keyhandler(key);
- _gfx->doUpdate();
- return false;
- case INPUT_NONE:
- handleController(key);
- if (key)
- _game.keypress = key;
- break;
- }
+ } while (restartProcessKey);
_gfx->doUpdate();
if (_game.msgBoxTicks > 0)
@@ -315,7 +319,7 @@ int AgiEngine::playGame() {
_game.lineUserInput = 22;
// We run AGIMOUSE always as a side effect
- if (getFeatures() & GF_AGIMOUSE || true)
+ //if (getFeatures() & GF_AGIMOUSE)
debug(1, "Using AGI Mouse 1.0 protocol");
if (getFeatures() & GF_AGIPAL)
diff --git a/engines/agi/detection_tables.h b/engines/agi/detection_tables.h
index 081cb39668..ab0e9a1fe4 100644
--- a/engines/agi/detection_tables.h
+++ b/engines/agi/detection_tables.h
@@ -30,7 +30,7 @@ namespace Agi {
lang, \
platform, \
ADGF_NO_FLAGS, \
- GUIO1(GUIO_NONE) \
+ GUIO0() \
}, \
gid, \
interp, \
@@ -46,7 +46,7 @@ namespace Agi {
lang, \
platform, \
ADGF_USEEXTRAASTITLE, \
- GUIO1(GUIO_NONE) \
+ GUIO0() \
}, \
gid, \
interp, \
@@ -130,7 +130,7 @@ static const AGIGameDescription gameDescriptions[] = {
Common::EN_ANY,
Common::kPlatformPC,
ADGF_NO_FLAGS,
- GUIO1(GUIO_NONE)
+ GUIO0()
},
GID_BC,
GType_V1,
@@ -151,7 +151,7 @@ static const AGIGameDescription gameDescriptions[] = {
Common::EN_ANY,
Common::kPlatformPC,
ADGF_NO_FLAGS,
- GUIO1(GUIO_NONE)
+ GUIO0()
},
GID_BC,
GType_V1,
@@ -172,7 +172,7 @@ static const AGIGameDescription gameDescriptions[] = {
Common::EN_ANY,
Common::kPlatformPC,
ADGF_NO_FLAGS,
- GUIO1(GUIO_NONE)
+ GUIO0()
},
GID_BC,
GType_V1,
@@ -252,7 +252,7 @@ static const AGIGameDescription gameDescriptions[] = {
Common::EN_ANY,
Common::kPlatformMacintosh,
ADGF_NO_FLAGS,
- GUIO1(GUIO_NONE)
+ GUIO0()
},
GID_GOLDRUSH,
GType_V3,
@@ -570,7 +570,7 @@ static const AGIGameDescription gameDescriptions[] = {
Common::EN_ANY,
Common::kPlatformAmiga,
ADGF_NO_FLAGS,
- GUIO1(GUIO_NONE)
+ GUIO0()
},
GID_SQ2,
GType_V2,
@@ -859,7 +859,7 @@ static const AGIGameDescription gameDescriptions[] = {
Common::EN_ANY,
Common::kPlatformPC,
ADGF_USEEXTRAASTITLE,
- GUIO1(GUIO_NONE)
+ GUIO0()
},
GID_FANMADE,
GType_V3,
@@ -887,7 +887,7 @@ static AGIGameDescription g_fallbackDesc = {
Common::UNK_LANG,
Common::kPlatformPC,
ADGF_NO_FLAGS,
- GUIO1(GUIO_NONE)
+ GUIO0()
},
GID_FANMADE,
GType_V2,
diff --git a/engines/agi/graphics.cpp b/engines/agi/graphics.cpp
index 074e5570d5..4bb3877f7d 100644
--- a/engines/agi/graphics.cpp
+++ b/engines/agi/graphics.cpp
@@ -1083,7 +1083,7 @@ void GfxMgr::putPixelsA(int x, int y, int n, uint8 *p) {
// Choose the correct screen to read from. If AGI256 or AGI256-2 is used and we're not trying to show the priority information,
// then choose the 256 color screen, otherwise choose the 16 color screen (Which also has the priority information).
- p += _vm->getFeatures() & (GF_AGI256 | GF_AGI256_2) && !_vm->_debug.priority ? FROM_SBUF16_TO_SBUF256_OFFSET : 0;
+ p += ((_vm->getFeatures() & (GF_AGI256 | GF_AGI256_2)) && !_vm->_debug.priority) ? FROM_SBUF16_TO_SBUF256_OFFSET : 0;
if (_vm->_renderMode == Common::kRenderCGA) {
for (x *= 2; n--; p++, x += 2) {
@@ -1091,7 +1091,7 @@ void GfxMgr::putPixelsA(int x, int y, int n, uint8 *p) {
*(uint16 *)&_agiScreen[x + y * GFX_WIDTH] = (q >> rShift) & 0x0f0f;
}
} else {
- const uint16 mask = _vm->getFeatures() & (GF_AGI256 | GF_AGI256_2) && !_vm->_debug.priority ? 0xffff : 0x0f0f;
+ const uint16 mask = ((_vm->getFeatures() & (GF_AGI256 | GF_AGI256_2)) && !_vm->_debug.priority) ? 0xffff : 0x0f0f;
for (x *= 2; n--; p++, x += 2) {
register uint16 q = ((uint16)*p << 8) | *p;
*(uint16 *)&_agiScreen[x + y * GFX_WIDTH] = (q >> rShift) & mask;
diff --git a/engines/agi/menu.cpp b/engines/agi/menu.cpp
index b504cd3e30..cac1701596 100644
--- a/engines/agi/menu.cpp
+++ b/engines/agi/menu.cpp
@@ -279,6 +279,7 @@ bool Menu::keyhandler(int key) {
static int clockVal;
static int menuActive = false;
static int buttonUsed = 0;
+ bool exitMenu = false;
if (!_vm->getflag(fMenusWork) && !(_vm->getFeatures() & GF_MENUS))
return false;
@@ -288,9 +289,8 @@ bool Menu::keyhandler(int key) {
_vm->_game.clockEnabled = false;
drawMenuBar();
}
- //
+
// Mouse handling
- //
if (_vm->_mouse.button) {
int hmenu, vmenu;
@@ -372,83 +372,84 @@ bool Menu::keyhandler(int key) {
debugC(6, kDebugLevelMenu | kDebugLevelInput, "event %d registered", d->event);
_vm->_game.controllerOccured[d->event] = true;
_vm->_menuSelected = true;
-
- goto exit_menu;
+ break;
}
}
}
- goto exit_menu;
+ exitMenu = true;
}
}
- if (!menuActive) {
- if (_hCurMenu >= 0) {
- drawMenuHilite(_hCurMenu);
- drawMenuOption(_hCurMenu);
- if (!buttonUsed && _vCurMenu >= 0)
- drawMenuOptionHilite(_hCurMenu, _vCurMenu);
+ if (!exitMenu) {
+ if (!menuActive) {
+ if (_hCurMenu >= 0) {
+ drawMenuHilite(_hCurMenu);
+ drawMenuOption(_hCurMenu);
+ if (!buttonUsed && _vCurMenu >= 0)
+ drawMenuOptionHilite(_hCurMenu, _vCurMenu);
+ }
+ menuActive = true;
}
- menuActive = true;
- }
- switch (key) {
- case KEY_ESCAPE:
- debugC(6, kDebugLevelMenu | kDebugLevelInput, "KEY_ESCAPE");
- goto exit_menu;
- case KEY_ENTER:
- {
- 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.controllerOccured[d->event] = true;
- _vm->_menuSelected = true;
- goto exit_menu;
+ switch (key) {
+ case KEY_ESCAPE:
+ debugC(6, kDebugLevelMenu | kDebugLevelInput, "KEY_ESCAPE");
+ exitMenu = true;
+ break;
+ case KEY_ENTER:
+ {
+ 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.controllerOccured[d->event] = true;
+ _vm->_menuSelected = true;
+ exitMenu = true;
+ }
+ break;
}
- break;
- }
- case KEY_DOWN:
- case KEY_UP:
- _vCurMenu += key == KEY_DOWN ? 1 : -1;
+ case KEY_DOWN:
+ case KEY_UP:
+ _vCurMenu += key == KEY_DOWN ? 1 : -1;
- if (_vCurMenu < 0)
- _vCurMenu = _vMaxMenu[_hCurMenu];
- if (_vCurMenu > _vMaxMenu[_hCurMenu])
- _vCurMenu = 0;
+ if (_vCurMenu < 0)
+ _vCurMenu = _vMaxMenu[_hCurMenu];
+ if (_vCurMenu > _vMaxMenu[_hCurMenu])
+ _vCurMenu = 0;
- drawMenuOption(_hCurMenu);
- drawMenuOptionHilite(_hCurMenu, _vCurMenu);
- break;
- case KEY_RIGHT:
- case KEY_LEFT:
- _hCurMenu += key == KEY_RIGHT ? 1 : -1;
-
- if (_hCurMenu < 0)
- _hCurMenu = _hMaxMenu;
- if (_hCurMenu > _hMaxMenu)
- _hCurMenu = 0;
-
- _vCurMenu = 0;
- newMenuSelected(_hCurMenu);
- drawMenuOptionHilite(_hCurMenu, _vCurMenu);
- break;
- }
+ drawMenuOption(_hCurMenu);
+ drawMenuOptionHilite(_hCurMenu, _vCurMenu);
+ break;
+ case KEY_RIGHT:
+ case KEY_LEFT:
+ _hCurMenu += key == KEY_RIGHT ? 1 : -1;
- return true;
+ if (_hCurMenu < 0)
+ _hCurMenu = _hMaxMenu;
+ if (_hCurMenu > _hMaxMenu)
+ _hCurMenu = 0;
-exit_menu:
- buttonUsed = 0;
- _picture->showPic();
- _vm->writeStatus();
+ _vCurMenu = 0;
+ newMenuSelected(_hCurMenu);
+ drawMenuOptionHilite(_hCurMenu, _vCurMenu);
+ break;
+ }
+ }
- _vm->setvar(vKey, 0);
- _vm->_game.keypress = 0;
- _vm->_game.clockEnabled = clockVal;
- _vm->oldInputMode();
+ if (exitMenu) {
+ buttonUsed = 0;
+ _picture->showPic();
+ _vm->writeStatus();
- debugC(3, kDebugLevelMenu, "exit_menu: input mode reset to %d", _vm->_game.inputMode);
- menuActive = false;
+ _vm->setvar(vKey, 0);
+ _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;
+ }
return true;
}
diff --git a/engines/agi/menu.h b/engines/agi/menu.h
index e659c71fab..1d5828d78a 100644
--- a/engines/agi/menu.h
+++ b/engines/agi/menu.h
@@ -33,8 +33,8 @@ namespace Agi {
struct AgiMenu;
struct AgiMenuOption;
-typedef Common::List<AgiMenu*> MenuList;
-typedef Common::List<AgiMenuOption*> MenuOptionList;
+typedef Common::List<AgiMenu *> MenuList;
+typedef Common::List<AgiMenuOption *> MenuOptionList;
class GfxMgr;
class PictureMgr;
diff --git a/engines/agi/objects.cpp b/engines/agi/objects.cpp
index 94eef92579..447cff2a3f 100644
--- a/engines/agi/objects.cpp
+++ b/engines/agi/objects.cpp
@@ -52,7 +52,7 @@ int AgiEngine::decodeObjects(uint8 *mem, uint32 flen) {
// alloc memory for object list
// byte 3 = number of animated objects. this is ignored.. ??
- if (READ_LE_UINT16(mem) / padsize >= 256) {
+ if (READ_LE_UINT16(mem) / padsize > 256) {
// die with no error! AGDS game needs not to die to work!! :(
return errOK;
}
diff --git a/engines/agi/op_cmd.cpp b/engines/agi/op_cmd.cpp
index 72f60e2516..7e04328a67 100644
--- a/engines/agi/op_cmd.cpp
+++ b/engines/agi/op_cmd.cpp
@@ -1622,15 +1622,15 @@ void cmdPrintAtV(AgiGame *state, uint8 *p) {
void cmdPushScript(AgiGame *state, uint8 *p) {
// We run AGIMOUSE always as a side effect
- if (getFeatures() & GF_AGIMOUSE || true) {
+ //if (getFeatures() & GF_AGIMOUSE || true) {
state->vars[27] = state->_vm->_mouse.button;
state->vars[28] = state->_vm->_mouse.x / 2;
state->vars[29] = state->_vm->_mouse.y;
- } else {
+ /*} else {
if (getVersion() >= 0x2915) {
debug(0, "push.script");
}
- }
+ }*/
}
void cmdSetPriBase(AgiGame *state, uint8 *p) {
@@ -1702,6 +1702,9 @@ void cmdSetItemView(AgiGame *state, uint8 *p) {
void cmdCallV1(AgiGame *state, uint8 *p) {
state->_vm->agiLoadResource(rLOGIC, p0);
+ // FIXME: The following instruction looks incomplete.
+ // Maybe something is meant to be assigned to, or read from,
+ // the logic_list entry?
state->logic_list[++state->max_logics];
_v[13] = 1;
}
diff --git a/engines/agi/opcodes.cpp b/engines/agi/opcodes.cpp
index d1baab93e1..29fb860635 100644
--- a/engines/agi/opcodes.cpp
+++ b/engines/agi/opcodes.cpp
@@ -360,7 +360,7 @@ AgiInstruction insV2[] = {
void AgiEngine::setupOpcodes() {
if (getVersion() >= 0x2000) {
- for (int i = 0; i <= ARRAYSIZE(insV2Test); ++i)
+ for (int i = 0; i < ARRAYSIZE(insV2Test); ++i)
_agiCondCommands[i] = insV2Test[i].func;
for (int i = 0; i < ARRAYSIZE(insV2); ++i)
_agiCommands[i] = insV2[i].func;
@@ -368,7 +368,7 @@ void AgiEngine::setupOpcodes() {
logicNamesTest = insV2Test;
logicNamesCmd = insV2;
} else {
- for (int i = 0; i <= ARRAYSIZE(insV1Test); ++i)
+ for (int i = 0; i < ARRAYSIZE(insV1Test); ++i)
_agiCondCommands[i] = insV1Test[i].func;
for (int i = 0; i < ARRAYSIZE(insV1); ++i)
_agiCommands[i] = insV1[i].func;
diff --git a/engines/agi/picture.h b/engines/agi/picture.h
index f2a6586b93..45a95202e5 100644
--- a/engines/agi/picture.h
+++ b/engines/agi/picture.h
@@ -115,6 +115,8 @@ public:
putVirtPixel(x, y);
}
+ bool isPictureLoaded() { return _data != NULL; }
+
private:
uint8 *_data;
uint32 _flen;
diff --git a/engines/agi/preagi_mickey.h b/engines/agi/preagi_mickey.h
index 673839a592..18b0593d78 100644
--- a/engines/agi/preagi_mickey.h
+++ b/engines/agi/preagi_mickey.h
@@ -704,7 +704,7 @@ protected:
void readOfsData(int, int, uint8*, long);
bool chooseY_N(int, bool);
int choose1to9(int);
- void printStr(char*);
+ void printStr(char *);
void printLine(const char*);
void printExeStr(int);
void printExeMsg(int);
diff --git a/engines/agi/preagi_troll.cpp b/engines/agi/preagi_troll.cpp
index 50b2945383..b7d2801076 100644
--- a/engines/agi/preagi_troll.cpp
+++ b/engines/agi/preagi_troll.cpp
@@ -455,7 +455,7 @@ int TrollEngine::drawRoom(char *menu) {
_gfx->doUpdate();
char tmp[10];
- strncat(menu, (char*)_gameData + _locMessagesIdx[_currentRoom], 39);
+ strncat(menu, (char *)_gameData + _locMessagesIdx[_currentRoom], 39);
for (int i = 0; i < 3; i++) {
if (_roomDescs[_roomPicture - 1].options[i]) {
@@ -725,7 +725,7 @@ void TrollEngine::fillOffsets() {
void TrollEngine::init() {
_picture->setPictureVersion(AGIPIC_V15);
- //SetScreenPar(320, 200, (char*)ibm_fontdata);
+ //SetScreenPar(320, 200, (char *)ibm_fontdata);
const int gaps[] = { 0x3A40, 0x4600, 0x4800, 0x5800, 0x5a00, 0x6a00,
0x6c00, 0x7400, 0x7600, 0x7c00, 0x7e00, 0x8e00,
diff --git a/engines/agi/preagi_winnie.cpp b/engines/agi/preagi_winnie.cpp
index cc5c2470ae..53863a8c7e 100644
--- a/engines/agi/preagi_winnie.cpp
+++ b/engines/agi/preagi_winnie.cpp
@@ -1006,36 +1006,47 @@ void WinnieEngine::gameLoop() {
WTP_ROOM_HDR hdr;
uint8 *roomdata = (uint8 *)malloc(4096);
int iBlock;
+ uint8 decodePhase = 0;
-phase0:
- if (!_gameStateWinnie.nObjMiss && (_room == IDI_WTP_ROOM_PICNIC))
- _room = IDI_WTP_ROOM_PARTY;
+ while (!shouldQuit()) {
+ if (decodePhase == 0) {
+ if (!_gameStateWinnie.nObjMiss && (_room == IDI_WTP_ROOM_PICNIC))
+ _room = IDI_WTP_ROOM_PARTY;
- readRoom(_room, roomdata, hdr);
- drawRoomPic();
- _gfx->doUpdate();
+ readRoom(_room, roomdata, hdr);
+ drawRoomPic();
+ _gfx->doUpdate();
+ decodePhase = 1;
+ }
-phase1:
- if (getObjInRoom(_room)) {
- printObjStr(getObjInRoom(_room), IDI_WTP_OBJ_DESC);
- getSelection(kSelAnyKey);
- }
+ if (decodePhase == 1) {
+ if (getObjInRoom(_room)) {
+ printObjStr(getObjInRoom(_room), IDI_WTP_OBJ_DESC);
+ getSelection(kSelAnyKey);
+ }
+ decodePhase = 2;
+ }
-phase2:
- for (iBlock = 0; iBlock < IDI_WTP_MAX_BLOCK; iBlock++) {
- if (parser(hdr.ofsDesc[iBlock] - _roomOffset, iBlock, roomdata) == IDI_WTP_PAR_BACK)
- goto phase1;
- }
+ if (decodePhase == 2) {
+ for (iBlock = 0; iBlock < IDI_WTP_MAX_BLOCK; iBlock++) {
+ if (parser(hdr.ofsDesc[iBlock] - _roomOffset, iBlock, roomdata) == IDI_WTP_PAR_BACK) {
+ decodePhase = 1;
+ break;
+ }
+ }
+ if (decodePhase == 2)
+ decodePhase = 3;
+ }
- while (!shouldQuit()) {
- for (iBlock = 0; iBlock < IDI_WTP_MAX_BLOCK; iBlock++) {
- switch (parser(hdr.ofsBlock[iBlock] - _roomOffset, iBlock, roomdata)) {
- case IDI_WTP_PAR_GOTO:
- goto phase0;
- break;
- case IDI_WTP_PAR_BACK:
- goto phase2;
- break;
+ if (decodePhase == 3) {
+ for (iBlock = 0; iBlock < IDI_WTP_MAX_BLOCK; iBlock++) {
+ if (parser(hdr.ofsBlock[iBlock] - _roomOffset, iBlock, roomdata) == IDI_WTP_PAR_GOTO) {
+ decodePhase = 0;
+ break;
+ } else if (parser(hdr.ofsBlock[iBlock] - _roomOffset, iBlock, roomdata) == IDI_WTP_PAR_BACK) {
+ decodePhase = 2;
+ break;
+ }
}
}
}
diff --git a/engines/agi/predictive.cpp b/engines/agi/predictive.cpp
index edfe83b1cb..4bb378934d 100644
--- a/engines/agi/predictive.cpp
+++ b/engines/agi/predictive.cpp
@@ -96,8 +96,6 @@ void bringWordtoTop(char *str, int wordnum) {
}
bool AgiEngine::predictiveDialog() {
- int key = 0, active = -1, lastactive = 0;
- bool rc = false;
uint8 x;
int y;
int bx[17], by[17];
@@ -105,7 +103,6 @@ bool AgiEngine::predictiveDialog() {
char temp[MAXWORDLEN + 1], repeatcount[MAXWORDLEN];
AgiBlock tmpwindow;
bool navigationwithkeys = false;
- bool processkey;
const char *buttonStr[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "0" };
const char *buttons[] = {
@@ -115,7 +112,7 @@ bool AgiEngine::predictiveDialog() {
"(#)next", "add",
"<",
"Cancel", "OK",
- "Pre", "(0) ", NULL
+ "(*)Pre", "(0) ", NULL
};
const int colors[] = {
15, 0, 15, 0, 15, 0,
@@ -189,8 +186,11 @@ bool AgiEngine::predictiveDialog() {
int mode = kModePre;
bool needRefresh = true;
-
- while (!shouldQuit()) {
+ int active = -1, lastactive = 0;
+ bool rc = false;
+ bool closeDialog = false;
+ bool enterPredictiveResult = false;
+ while (!closeDialog && !shouldQuit()) {
if (needRefresh) {
for (int i = 0; buttons[i]; i++) {
int color1 = colors[i * 2];
@@ -234,9 +234,10 @@ bool AgiEngine::predictiveDialog() {
_gfx->doUpdate();
}
+ bool processkey = false;
+
pollTimer();
- key = doPollKeyboard();
- processkey = false;
+ int key = doPollKeyboard();
switch (key) {
case KEY_ENTER:
if (navigationwithkeys) {
@@ -251,7 +252,8 @@ bool AgiEngine::predictiveDialog() {
break;
case KEY_ESCAPE:
rc = false;
- goto getout;
+ closeDialog = true;
+ break;
case BUTTON_LEFT:
navigationwithkeys = false;
for (int i = 0; buttons[i]; i++) {
@@ -361,7 +363,7 @@ bool AgiEngine::predictiveDialog() {
break;
}
- if (processkey) {
+ if (processkey && !closeDialog) {
if (active >= 0) {
needRefresh = true;
lastactive = active;
@@ -442,7 +444,8 @@ bool AgiEngine::predictiveDialog() {
if (mode == kModePre && _predictiveDictActLine && numMatchingWords > 1 && _wordNumber != 0)
bringWordtoTop(_predictiveDictActLine, _wordNumber);
rc = true;
- goto press;
+ enterPredictiveResult = true;
+ closeDialog = true;
} else if (active == 14) { // Mode
mode++;
if (mode > kModeAbc)
@@ -455,18 +458,20 @@ bool AgiEngine::predictiveDialog() {
_currentCode.clear();
_currentWord.clear();
memset(repeatcount, 0, sizeof(repeatcount));
+ _predictiveDictActLine = NULL;
} else {
- goto press;
+ enterPredictiveResult = true;
+ closeDialog = true;
}
}
}
}
- press:
- Common::strlcpy(_predictiveResult, prefix.c_str(), sizeof(_predictiveResult));
- Common::strlcat(_predictiveResult, _currentWord.c_str(), sizeof(_predictiveResult));
+ if (enterPredictiveResult) {
+ Common::strlcpy(_predictiveResult, prefix.c_str(), sizeof(_predictiveResult));
+ Common::strlcat(_predictiveResult, _currentWord.c_str(), sizeof(_predictiveResult));
+ }
- getout:
// if another window was shown, bring it up again
if (!tmpwindow.active)
closeWindow();
@@ -561,37 +566,50 @@ bool AgiEngine::matchWord() {
if (_currentCode.size() > MAXWORDLEN)
return false;
- // Perform a binary search on the dictionary to find the first
- // entry that has _currentCode as a prefix.
+ // The entries in the dictionary consist of a code, a space, and then
+ // a space-separated list of words matching this code.
+ // To exactly match a code, we therefore match the code plus the trailing
+ // space in the dictionary.
+ Common::String code = _currentCode + " ";
+
+ // Perform a binary search on the dictionary.
int hi = _predictiveDictLineCount - 1;
int lo = 0;
int line = 0;
- while (lo < hi) {
+ while (lo <= hi) {
line = (lo + hi) / 2;
- int cmpVal = strncmp(_predictiveDictLine[line], _currentCode.c_str(), _currentCode.size());
+ int cmpVal = strncmp(_predictiveDictLine[line], code.c_str(), code.size());
if (cmpVal > 0)
hi = line - 1;
else if (cmpVal < 0)
lo = line + 1;
else {
- hi = line;
break;
}
}
+ bool partial = hi < lo;
+ if (partial) {
+ // Didn't find an exact match, but 'lo' now points to the first entry
+ // lexicographically greater than the current code, so that will
+ // be the first entry with the current code as a prefix, if it exists.
+ line = lo;
+ _predictiveDictActLine = NULL;
+ } else {
+ _predictiveDictActLine = _predictiveDictLine[line];
+ }
+
_currentWord.clear();
_wordNumber = 0;
if (0 == strncmp(_predictiveDictLine[line], _currentCode.c_str(), _currentCode.size())) {
- _predictiveDictActLine = _predictiveDictLine[line];
char tmp[MAXLINELEN];
- strncpy(tmp, _predictiveDictActLine, MAXLINELEN);
+ strncpy(tmp, _predictiveDictLine[line], MAXLINELEN);
tmp[MAXLINELEN - 1] = 0;
char *tok = strtok(tmp, " ");
tok = strtok(NULL, " ");
_currentWord = Common::String(tok, _currentCode.size());
return true;
} else {
- _predictiveDictActLine = NULL;
return false;
}
}
diff --git a/engines/agi/saveload.cpp b/engines/agi/saveload.cpp
index 3cebbf50c8..0ef6230374 100644
--- a/engines/agi/saveload.cpp
+++ b/engines/agi/saveload.cpp
@@ -221,8 +221,8 @@ int AgiEngine::saveGame(const Common::String &fileName, const Common::String &de
// Save image stack
- for (i = 0; i < _imageStack.size(); i++) {
- ImageStackElement ise = _imageStack[i];
+ for (Common::Stack<ImageStackElement>::size_type j = 0; j < _imageStack.size(); ++j) {
+ const ImageStackElement &ise = _imageStack[j];
out->writeByte(ise.type);
out->writeSint16BE(ise.parm1);
out->writeSint16BE(ise.parm2);
@@ -300,7 +300,7 @@ int AgiEngine::loadGame(const Common::String &fileName, bool checkId) {
_game.state = (State)in->readByte();
in->read(loadId, 8);
- if (strcmp(loadId, _game.id) && checkId) {
+ if (strcmp(loadId, _game.id) != 0 && checkId) {
delete in;
warning("This save seems to be from a different AGI game (save from %s, running %s), not loaded", loadId, _game.id);
return errBadFileOpen;
@@ -331,7 +331,7 @@ int AgiEngine::loadGame(const Common::String &fileName, bool checkId) {
warning("Since your game was only detected via the fallback detector, there is no possibility to assure the save is compatible with your game version");
debug(0, "The game used for saving is \"%s\".", md5);
- } else if (strcmp(md5, getGameMD5())) {
+ } else if (strcmp(md5, getGameMD5()) != 0) {
warning("Game was saved with different gamedata - you may encounter problems");
debug(0, "Your game is \"%s\" and save is \"%s\".", getGameMD5(), md5);
@@ -609,8 +609,8 @@ int AgiEngine::selectSlot() {
AllowSyntheticEvents on(this);
int oldFirstSlot = _firstSlot + 1;
int oldActive = active + 1;
-
- while (!(shouldQuit() || _restartGame)) {
+ bool exitSelectSlot = false;
+ while (!exitSelectSlot && !(shouldQuit() || _restartGame)) {
int sbPos = 0;
// Use the extreme scrollbar positions only if the extreme
@@ -661,119 +661,122 @@ int AgiEngine::selectSlot() {
// out of the dead loop
if (getflag(fRestoreJustRan)) {
rc = -2;
- goto getout;
+ exitSelectSlot = true;
}
- switch (key) {
- case KEY_ENTER:
- rc = active;
- strncpy(_game.strings[MAX_STRINGS], desc[i], MAX_STRINGLEN);
- goto press;
- case KEY_ESCAPE:
- rc = -1;
- goto getout;
- case BUTTON_LEFT:
- if (_gfx->testButton(buttonX[0], buttonY, buttonText[0])) {
+ if (!exitSelectSlot) {
+ switch (key) {
+ case KEY_ENTER:
rc = active;
strncpy(_game.strings[MAX_STRINGS], desc[i], MAX_STRINGLEN);
- goto press;
- }
- if (_gfx->testButton(buttonX[1], buttonY, buttonText[1])) {
+ debugC(8, kDebugLevelMain | kDebugLevelInput, "Button pressed: %d", rc);
+ exitSelectSlot = true;
+ break;
+ case KEY_ESCAPE:
rc = -1;
- goto getout;
- }
- slotClicked = ((int)_mouse.y - 1) / CHAR_COLS - (vm + 4);
- xmin = (hm + 1) * CHAR_COLS;
- xmax = xmin + CHAR_COLS * 34;
- if ((int)_mouse.x >= xmin && (int)_mouse.x <= xmax) {
- if (slotClicked >= 0 && slotClicked < NUM_VISIBLE_SLOTS)
- active = slotClicked;
- }
- xmin = (hm + 36) * CHAR_COLS;
- xmax = xmin + CHAR_COLS;
- if ((int)_mouse.x >= xmin && (int)_mouse.x <= xmax) {
- if (slotClicked >= 0 && slotClicked < NUM_VISIBLE_SLOTS) {
- if (slotClicked == 0)
- keyEnqueue(KEY_UP);
- else if (slotClicked == NUM_VISIBLE_SLOTS - 1)
- keyEnqueue(KEY_DOWN);
- else if (slotClicked < sbPos)
- keyEnqueue(KEY_UP_RIGHT);
- else if (slotClicked > sbPos)
- keyEnqueue(KEY_DOWN_RIGHT);
+ exitSelectSlot = true;
+ break;
+ case BUTTON_LEFT:
+ if (_gfx->testButton(buttonX[0], buttonY, buttonText[0])) {
+ rc = active;
+ strncpy(_game.strings[MAX_STRINGS], desc[i], MAX_STRINGLEN);
+ debugC(8, kDebugLevelMain | kDebugLevelInput, "Button pressed: %d", rc);
+ exitSelectSlot = true;
+ } else if (_gfx->testButton(buttonX[1], buttonY, buttonText[1])) {
+ rc = -1;
+ exitSelectSlot = true;
+ } else {
+ slotClicked = ((int)_mouse.y - 1) / CHAR_COLS - (vm + 4);
+ xmin = (hm + 1) * CHAR_COLS;
+ xmax = xmin + CHAR_COLS * 34;
+ if ((int)_mouse.x >= xmin && (int)_mouse.x <= xmax) {
+ if (slotClicked >= 0 && slotClicked < NUM_VISIBLE_SLOTS)
+ active = slotClicked;
+ }
+ xmin = (hm + 36) * CHAR_COLS;
+ xmax = xmin + CHAR_COLS;
+ if ((int)_mouse.x >= xmin && (int)_mouse.x <= xmax) {
+ if (slotClicked >= 0 && slotClicked < NUM_VISIBLE_SLOTS) {
+ if (slotClicked == 0)
+ keyEnqueue(KEY_UP);
+ else if (slotClicked == NUM_VISIBLE_SLOTS - 1)
+ keyEnqueue(KEY_DOWN);
+ else if (slotClicked < sbPos)
+ keyEnqueue(KEY_UP_RIGHT);
+ else if (slotClicked > sbPos)
+ keyEnqueue(KEY_DOWN_RIGHT);
+ }
+ }
}
- }
- break;
- case KEY_DOWN:
- active++;
- if (active >= NUM_VISIBLE_SLOTS) {
- if (_firstSlot + NUM_VISIBLE_SLOTS < NUM_SLOTS) {
+ break;
+
+ case KEY_DOWN:
+ active++;
+ if (active >= NUM_VISIBLE_SLOTS) {
+ if (_firstSlot + NUM_VISIBLE_SLOTS < NUM_SLOTS) {
+ _firstSlot++;
+ for (i = 1; i < NUM_VISIBLE_SLOTS; i++)
+ memcpy(desc[i - 1], desc[i], sizeof(desc[0]));
+ getSavegameDescription(_firstSlot + NUM_VISIBLE_SLOTS - 1, desc[NUM_VISIBLE_SLOTS - 1]);
+ }
+ active = NUM_VISIBLE_SLOTS - 1;
+ }
+ break;
+ case KEY_UP:
+ active--;
+ if (active < 0) {
+ active = 0;
+ if (_firstSlot > 0) {
+ _firstSlot--;
+ for (i = NUM_VISIBLE_SLOTS - 1; i > 0; i--)
+ memcpy(desc[i], desc[i - 1], sizeof(desc[0]));
+ getSavegameDescription(_firstSlot, desc[0]);
+ }
+ }
+ break;
+
+ // Page Up/Down and mouse wheel scrolling all leave 'active'
+ // unchanged so that a visible slot will remain selected.
+
+ case WHEEL_DOWN:
+ if (_firstSlot < NUM_SLOTS - NUM_VISIBLE_SLOTS) {
_firstSlot++;
for (i = 1; i < NUM_VISIBLE_SLOTS; i++)
memcpy(desc[i - 1], desc[i], sizeof(desc[0]));
getSavegameDescription(_firstSlot + NUM_VISIBLE_SLOTS - 1, desc[NUM_VISIBLE_SLOTS - 1]);
}
- active = NUM_VISIBLE_SLOTS - 1;
- }
- break;
- case KEY_UP:
- active--;
- if (active < 0) {
- active = 0;
+ break;
+ case WHEEL_UP:
if (_firstSlot > 0) {
_firstSlot--;
for (i = NUM_VISIBLE_SLOTS - 1; i > 0; i--)
memcpy(desc[i], desc[i - 1], sizeof(desc[0]));
getSavegameDescription(_firstSlot, desc[0]);
}
+ break;
+ case KEY_DOWN_RIGHT:
+ // This is probably triggered by Page Down.
+ _firstSlot += NUM_VISIBLE_SLOTS;
+ if (_firstSlot > NUM_SLOTS - NUM_VISIBLE_SLOTS) {
+ _firstSlot = NUM_SLOTS - NUM_VISIBLE_SLOTS;
+ }
+ for (i = 0; i < NUM_VISIBLE_SLOTS; i++)
+ getSavegameDescription(_firstSlot + i, desc[i]);
+ break;
+ case KEY_UP_RIGHT:
+ // This is probably triggered by Page Up.
+ _firstSlot -= NUM_VISIBLE_SLOTS;
+ if (_firstSlot < 0) {
+ _firstSlot = 0;
+ }
+ for (i = 0; i < NUM_VISIBLE_SLOTS; i++)
+ getSavegameDescription(_firstSlot + i, desc[i]);
+ break;
}
- break;
-
- // Page Up/Down and mouse wheel scrolling all leave 'active'
- // unchanged so that a visible slot will remain selected.
-
- case WHEEL_DOWN:
- if (_firstSlot < NUM_SLOTS - NUM_VISIBLE_SLOTS) {
- _firstSlot++;
- for (i = 1; i < NUM_VISIBLE_SLOTS; i++)
- memcpy(desc[i - 1], desc[i], sizeof(desc[0]));
- getSavegameDescription(_firstSlot + NUM_VISIBLE_SLOTS - 1, desc[NUM_VISIBLE_SLOTS - 1]);
- }
- break;
- case WHEEL_UP:
- if (_firstSlot > 0) {
- _firstSlot--;
- for (i = NUM_VISIBLE_SLOTS - 1; i > 0; i--)
- memcpy(desc[i], desc[i - 1], sizeof(desc[0]));
- getSavegameDescription(_firstSlot, desc[0]);
- }
- break;
- case KEY_DOWN_RIGHT:
- // This is probably triggered by Page Down.
- _firstSlot += NUM_VISIBLE_SLOTS;
- if (_firstSlot > NUM_SLOTS - NUM_VISIBLE_SLOTS) {
- _firstSlot = NUM_SLOTS - NUM_VISIBLE_SLOTS;
- }
- for (i = 0; i < NUM_VISIBLE_SLOTS; i++)
- getSavegameDescription(_firstSlot + i, desc[i]);
- break;
- case KEY_UP_RIGHT:
- // This is probably triggered by Page Up.
- _firstSlot -= NUM_VISIBLE_SLOTS;
- if (_firstSlot < 0) {
- _firstSlot = 0;
- }
- for (i = 0; i < NUM_VISIBLE_SLOTS; i++)
- getSavegameDescription(_firstSlot + i, desc[i]);
- break;
}
_gfx->doUpdate();
}
-press:
- debugC(8, kDebugLevelMain | kDebugLevelInput, "Button pressed: %d", rc);
-
-getout:
closeWindow();
_noSaveLoadAllowed = false;
diff --git a/engines/agi/sound_2gs.cpp b/engines/agi/sound_2gs.cpp
index c5cfa125d6..bfc8d4d8f3 100644
--- a/engines/agi/sound_2gs.cpp
+++ b/engines/agi/sound_2gs.cpp
@@ -68,10 +68,10 @@ int SoundGen2GS::readBuffer(int16 *buffer, const int numSamples) {
static uint data_available = 0;
static uint data_offset = 0;
uint n = numSamples << 1;
- uint8 *p = (uint8*)buffer;
+ uint8 *p = (uint8 *)buffer;
while (n > data_available) {
- memcpy(p, (uint8*)_out + data_offset, data_available);
+ memcpy(p, (uint8 *)_out + data_offset, data_available);
p += data_available;
n -= data_available;
@@ -81,7 +81,7 @@ int SoundGen2GS::readBuffer(int16 *buffer, const int numSamples) {
data_offset = 0;
}
- memcpy(p, (uint8*)_out + data_offset, n);
+ memcpy(p, (uint8 *)_out + data_offset, n);
data_offset += n;
data_available -= n;
@@ -719,7 +719,10 @@ bool SoundGen2GS::loadInstrumentHeaders(Common::String &exePath, const IIgsExeIn
}
// Read the whole executable file into memory
- Common::SharedPtr<Common::SeekableReadStream> data(file.readStream(file.size()));
+ // CHECKME: Why do we read the file into memory first? It does not seem to be
+ // kept outside of this function. Is the processing of the data too slow
+ // otherwise?
+ Common::ScopedPtr<Common::SeekableReadStream> data(file.readStream(file.size()));
file.close();
// Check that we got enough data to be able to parse the instruments
@@ -769,8 +772,11 @@ bool SoundGen2GS::loadWaveFile(Common::String &wavePath, const IIgsExeInfo &exeI
Common::File file;
// Open the wave file and read it into memory
+ // CHECKME: Why do we read the file into memory first? It does not seem to be
+ // kept outside of this function. Is the processing of the data too slow
+ // otherwise?
file.open(wavePath);
- Common::SharedPtr<Common::SeekableReadStream> uint8Wave(file.readStream(file.size()));
+ Common::ScopedPtr<Common::SeekableReadStream> uint8Wave(file.readStream(file.size()));
file.close();
// Check that we got the whole wave file
diff --git a/engines/agi/sound_2gs.h b/engines/agi/sound_2gs.h
index 89ffc3fe11..404f4a47a1 100644
--- a/engines/agi/sound_2gs.h
+++ b/engines/agi/sound_2gs.h
@@ -247,7 +247,7 @@ private:
void midiNoteOff(int channel, int note, int velocity);
void midiNoteOn(int channel, int note, int velocity);
double midiKeyToFreq(int key, double finetune);
- IIgsInstrumentHeader* getInstrument(uint8 program) { return &_instruments[_progToInst->map(program)]; };
+ IIgsInstrumentHeader* getInstrument(uint8 program) { return &_instruments[_progToInst->map(program)]; }
IIgsGenerator* allocateGenerator() { IIgsGenerator* g = &_generators[_nextGen++]; _nextGen %= 16; return g; }
bool _disableMidi; ///< Disable MIDI if loading instruments fail
diff --git a/engines/agi/sound_sarien.cpp b/engines/agi/sound_sarien.cpp
index a2baf89d12..576801bc56 100644
--- a/engines/agi/sound_sarien.cpp
+++ b/engines/agi/sound_sarien.cpp
@@ -330,7 +330,7 @@ void SoundGenSarien::fillAudio(int16 *stream, uint len) {
debugC(5, kDebugLevelSound, "(%p, %d)", (void *)stream, len);
while (len > data_available) {
- memcpy((uint8 *)stream + p, (uint8*)_sndBuffer + data_offset, data_available);
+ memcpy((uint8 *)stream + p, (uint8 *)_sndBuffer + data_offset, data_available);
p += data_available;
len -= data_available;
@@ -339,7 +339,7 @@ void SoundGenSarien::fillAudio(int16 *stream, uint len) {
data_offset = 0;
}
- memcpy((uint8 *)stream + p, (uint8*)_sndBuffer + data_offset, len);
+ memcpy((uint8 *)stream + p, (uint8 *)_sndBuffer + data_offset, len);
data_offset += len;
data_available -= len;
}
diff --git a/engines/agi/sprite.cpp b/engines/agi/sprite.cpp
index 8d13be3f68..ea2d329fb0 100644
--- a/engines/agi/sprite.cpp
+++ b/engines/agi/sprite.cpp
@@ -55,7 +55,7 @@ void *SpritesMgr::poolAlloc(int size) {
// Adjust size to sizeof(void *) boundary to prevent data misalignment
// errors.
- const int alignPadding = sizeof(void*) - 1;
+ const int alignPadding = sizeof(void *) - 1;
size = (size + alignPadding) & ~alignPadding;
x = _poolTop;
diff --git a/engines/agi/sprite.h b/engines/agi/sprite.h
index 68f0e32b86..851c2438fb 100644
--- a/engines/agi/sprite.h
+++ b/engines/agi/sprite.h
@@ -27,7 +27,7 @@ namespace Agi {
struct Sprite;
-typedef Common::List<Sprite*> SpriteList;
+typedef Common::List<Sprite *> SpriteList;
class AgiEngine;
class GfxMgr;
diff --git a/engines/agi/text.cpp b/engines/agi/text.cpp
index d5027588f9..1886a74ab1 100644
--- a/engines/agi/text.cpp
+++ b/engines/agi/text.cpp
@@ -240,7 +240,6 @@ char *AgiEngine::wordWrapString(const char *s, int *len) {
while (*s) {
pWord = s;
- wLen = 0;
while (*s != '\0' && *s != ' ' && *s != '\n' && *s != '\r')
s++;
@@ -341,8 +340,6 @@ int AgiEngine::messageBox(const char *s) {
int AgiEngine::selectionBox(const char *m, const char **b) {
int numButtons = 0;
int x, y, i, s;
- int key, active = 0;
- int rc = -1;
int bx[5], by[5];
_noSaveLoadAllowed = true;
@@ -381,7 +378,9 @@ int AgiEngine::selectionBox(const char *m, const char **b) {
AllowSyntheticEvents on(this);
debugC(4, kDebugLevelText, "selectionBox(): waiting...");
- while (!(shouldQuit() || _restartGame)) {
+ int key, active = 0;
+ int rc = -1;
+ while (rc == -1 && !(shouldQuit() || _restartGame)) {
for (i = 0; b[i]; i++)
_gfx->drawCurrentStyleButton(bx[i], by[i], b[i], i == active, false, i == 0);
@@ -390,10 +389,8 @@ int AgiEngine::selectionBox(const char *m, const char **b) {
switch (key) {
case KEY_ENTER:
rc = active;
- goto press;
- case KEY_ESCAPE:
- rc = -1;
- goto getout;
+ debugC(4, kDebugLevelText, "selectionBox(): Button pressed: %d", rc);
+ break;
case KEY_RIGHT:
active++;
if (active >= numButtons)
@@ -408,7 +405,8 @@ int AgiEngine::selectionBox(const char *m, const char **b) {
for (i = 0; b[i]; i++) {
if (_gfx->testButton(bx[i], by[i], b[i])) {
rc = active = i;
- goto press;
+ debugC(4, kDebugLevelText, "selectionBox(): Button pressed: %d", rc);
+ break;
}
}
break;
@@ -419,12 +417,11 @@ int AgiEngine::selectionBox(const char *m, const char **b) {
break;
}
_gfx->doUpdate();
- }
-press:
- debugC(4, kDebugLevelText, "selectionBox(): Button pressed: %d", rc);
+ if (key == KEY_ESCAPE)
+ break;
+ }
-getout:
closeWindow();
debugC(2, kDebugLevelText, "selectionBox(): Result = %d", rc);
diff --git a/engines/agi/wagparser.cpp b/engines/agi/wagparser.cpp
index 39f9e0dd92..61feac5d17 100644
--- a/engines/agi/wagparser.cpp
+++ b/engines/agi/wagparser.cpp
@@ -112,11 +112,11 @@ WagFileParser::~WagFileParser() {
bool WagFileParser::checkAgiVersionProperty(const WagProperty &version) const {
if (version.getCode() == WagProperty::PC_INTVERSION && // Must be AGI interpreter version property
version.getSize() >= 3 && // Need at least three characters for a version number like "X.Y"
- isdigit(static_cast<unsigned char>(version.getData()[0])) && // And the first character must be a digit
+ Common::isDigit(version.getData()[0]) && // And the first character must be a digit
(version.getData()[1] == ',' || version.getData()[1] == '.')) { // And the second a comma or a period
for (int i = 2; i < version.getSize(); i++) // And the rest must all be digits
- if (!isdigit(static_cast<unsigned char>(version.getData()[i])))
+ if (!Common::isDigit(version.getData()[i]))
return false; // Bail out if found a non-digit after the decimal point
return true;
diff --git a/engines/agi/words.cpp b/engines/agi/words.cpp
index 1001c66b20..4400112247 100644
--- a/engines/agi/words.cpp
+++ b/engines/agi/words.cpp
@@ -130,7 +130,7 @@ int AgiEngine::findWord(const char *word, int *flen) {
return -1;
*flen = 0;
- Common::Array<AgiWord*> &a = _game.words[c];
+ Common::Array<AgiWord *> &a = _game.words[c];
for (int i = 0; i < (int)a.size(); i++) {
int wlen = strlen(a[i]->word);