aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaweł Kołodziejski2007-01-16 12:40:51 +0000
committerPaweł Kołodziejski2007-01-16 12:40:51 +0000
commitb47eb953160883221f02c7455cb55ca66f75198f (patch)
tree1060caa6495c20970d35dc3abb42ae7f9e513af3 /engines
parent994604527b15dbe129b5c91f26da8840f3519199 (diff)
downloadscummvm-rg350-b47eb953160883221f02c7455cb55ca66f75198f.tar.gz
scummvm-rg350-b47eb953160883221f02c7455cb55ca66f75198f.tar.bz2
scummvm-rg350-b47eb953160883221f02c7455cb55ca66f75198f.zip
Formating names in source code
svn-id: r25101
Diffstat (limited to 'engines')
-rw-r--r--engines/agi/agi.cpp287
-rw-r--r--engines/agi/agi.h515
-rw-r--r--engines/agi/agi_v2.cpp128
-rw-r--r--engines/agi/agi_v3.cpp180
-rw-r--r--engines/agi/checks.cpp137
-rw-r--r--engines/agi/console.cpp20
-rw-r--r--engines/agi/console.h4
-rw-r--r--engines/agi/cycle.cpp348
-rw-r--r--engines/agi/font.h4
-rw-r--r--engines/agi/global.cpp12
-rw-r--r--engines/agi/graphics.cpp108
-rw-r--r--engines/agi/graphics.h14
-rw-r--r--engines/agi/id.cpp50
-rw-r--r--engines/agi/inv.cpp64
-rw-r--r--engines/agi/keyboard.cpp160
-rw-r--r--engines/agi/keyboard.h2
-rw-r--r--engines/agi/logic.cpp52
-rw-r--r--engines/agi/logic.h4
-rw-r--r--engines/agi/lzw.cpp82
-rw-r--r--engines/agi/lzw.h2
-rw-r--r--engines/agi/menu.cpp274
-rw-r--r--engines/agi/menu.h56
-rw-r--r--engines/agi/motion.cpp110
-rw-r--r--engines/agi/objects.cpp87
-rw-r--r--engines/agi/op_cmd.cpp540
-rw-r--r--engines/agi/op_dbg.cpp44
-rw-r--r--engines/agi/op_test.cpp184
-rw-r--r--engines/agi/opcodes.h14
-rw-r--r--engines/agi/patches.cpp48
-rw-r--r--engines/agi/picture.cpp316
-rw-r--r--engines/agi/picture.h38
-rw-r--r--engines/agi/predictive.cpp14
-rw-r--r--engines/agi/savegame.cpp374
-rw-r--r--engines/agi/sound.cpp251
-rw-r--r--engines/agi/sound.h46
-rw-r--r--engines/agi/sprite.cpp368
-rw-r--r--engines/agi/sprite.h80
-rw-r--r--engines/agi/text.cpp204
-rw-r--r--engines/agi/text.h24
-rw-r--r--engines/agi/view.cpp224
-rw-r--r--engines/agi/view.h64
-rw-r--r--engines/agi/words.cpp54
42 files changed, 2776 insertions, 2811 deletions
diff --git a/engines/agi/agi.cpp b/engines/agi/agi.cpp
index b4ca386b37..14d4376434 100644
--- a/engines/agi/agi.cpp
+++ b/engines/agi/agi.cpp
@@ -50,13 +50,13 @@
namespace Agi {
-static uint32 g_tick_timer;
+static uint32 g_tickTimer;
struct Mouse g_mouse;
-#define key_enqueue(k) do { _key_queue[_key_queue_end++] = (k); \
- _key_queue_end %= KEY_QUEUE_SIZE; } while (0)
-#define key_dequeue(k) do { (k) = _key_queue[_key_queue_start++]; \
- _key_queue_start %= KEY_QUEUE_SIZE; } while (0)
+#define keyEnqueue(k) do { _keyQueue[_keyQueueEnd++] = (k); \
+ _keyQueueEnd %= KEY_QUEUE_SIZE; } while (0)
+#define keyDequeue(k) do { (k) = _keyQueue[_keyQueueStart++]; \
+ _keyQueueStart %= KEY_QUEUE_SIZE; } while (0)
void AgiEngine::processEvents() {
OSystem::Event event;
@@ -72,14 +72,14 @@ void AgiEngine::processEvents() {
case OSystem::EVENT_LBUTTONDOWN:
key = BUTTON_LEFT;
g_mouse.button = 1;
- key_enqueue(key);
+ keyEnqueue(key);
g_mouse.x = event.mouse.x;
g_mouse.y = event.mouse.y;
break;
case OSystem::EVENT_RBUTTONDOWN:
key = BUTTON_RIGHT;
g_mouse.button = 2;
- key_enqueue(key);
+ keyEnqueue(key);
g_mouse.x = event.mouse.x;
g_mouse.y = event.mouse.y;
break;
@@ -92,8 +92,8 @@ void AgiEngine::processEvents() {
g_mouse.button = 0;
break;
case OSystem::EVENT_KEYDOWN:
- _key_control = 0;
- _key_alt = 0;
+ _keyControl = 0;
+ _keyAlt = 0;
if (event.kbd.flags == OSystem::KBD_CTRL && event.kbd.keycode == 'd') {
_console->attach();
@@ -101,10 +101,10 @@ void AgiEngine::processEvents() {
}
if (event.kbd.flags & OSystem::KBD_CTRL)
- _key_control = 1;
+ _keyControl = 1;
if (event.kbd.flags & OSystem::KBD_ALT)
- _key_alt = 1;
+ _keyAlt = 1;
switch (key = event.kbd.keycode) {
case 256 + 20: // left arrow
@@ -201,16 +201,16 @@ void AgiEngine::processEvents() {
key = event.kbd.ascii;
break;
}
- if (_key_control)
+ if (_keyControl)
key = (key & ~0x20) - 0x40;
- else if (_key_alt)
- key = scancode_table[(key & ~0x20) - 0x41] << 8;
+ else if (_keyAlt)
+ key = scancodeTable[(key & ~0x20) - 0x41] << 8;
else if (event.kbd.flags & OSystem::KBD_SHIFT)
key = event.kbd.ascii;
break;
}
if (key)
- key_enqueue(key);
+ keyEnqueue(key);
break;
default:
break;
@@ -220,73 +220,72 @@ void AgiEngine::processEvents() {
int AgiEngine::agiIsKeypressLow() {
processEvents();
- return _key_queue_start != _key_queue_end;
+ return _keyQueueStart != _keyQueueEnd;
}
void AgiEngine::agiTimerLow() {
static uint32 m = 0;
uint32 dm;
- if (g_tick_timer < m)
+ if (g_tickTimer < m)
m = 0;
- while ((dm = g_tick_timer - m) < 5) {
+ while ((dm = g_tickTimer - m) < 5) {
processEvents();
if (_console->isAttached())
_console->onFrame();
g_system->delayMillis(10);
g_system->updateScreen();
}
- m = g_tick_timer;
+ m = g_tickTimer;
}
int AgiEngine::agiGetKeypressLow() {
int k;
- while (_key_queue_start == _key_queue_end) /* block */
+ while (_keyQueueStart == _keyQueueEnd) /* block */
agiTimerLow();
- key_dequeue(k);
+ keyDequeue(k);
return k;
}
void AgiEngine::agiTimerFunctionLow(void *refCon) {
- g_tick_timer++;
+ g_tickTimer++;
}
-void AgiEngine::clear_image_stack(void) {
- image_stack_pointer = 0;
+void AgiEngine::clearImageStack(void) {
+ _imageStackPointer = 0;
}
-void AgiEngine::release_image_stack(void) {
- if (image_stack)
- free(image_stack);
- image_stack = NULL;
- stack_size = image_stack_pointer = 0;
+void AgiEngine::releaseImageStack(void) {
+ if (_imageStack)
+ free(_imageStack);
+ _imageStack = NULL;
+ _stackSize = 0;
+ _imageStackPointer = NULL;
}
-void AgiEngine::record_image_stack_call(uint8 type, int16 p1, int16 p2, int16 p3,
+void AgiEngine::recordImageStackCall(uint8 type, int16 p1, int16 p2, int16 p3,
int16 p4, int16 p5, int16 p6, int16 p7) {
- struct image_stack_element *pnew;
+ struct ImageStackElement *pnew;
- if (image_stack_pointer == stack_size) {
- if (stack_size == 0) { /* first call */
- image_stack = (struct image_stack_element *)
- malloc(INITIAL_IMAGE_STACK_SIZE * sizeof(struct image_stack_element));
- stack_size = INITIAL_IMAGE_STACK_SIZE;
+ if (_imageStackPointer == _stackSize) {
+ if (_stackSize == 0) { /* first call */
+ _imageStack = (ImageStackElement *)malloc(INITIAL_IMAGE_STACK_SIZE * sizeof(ImageStackElement));
+ _stackSize = INITIAL_IMAGE_STACK_SIZE;
} else { /* has to grow */
- struct image_stack_element *new_stack;
- new_stack = (struct image_stack_element *)
- malloc(2 * stack_size * sizeof(struct image_stack_element));
- memcpy(new_stack, image_stack, stack_size * sizeof(struct image_stack_element));
- free(image_stack);
- image_stack = new_stack;
- stack_size *= 2;
+ struct ImageStackElement *newStack;
+ newStack = (ImageStackElement *)malloc(2 * _stackSize * sizeof(ImageStackElement));
+ memcpy(newStack, _imageStack, _stackSize * sizeof(ImageStackElement));
+ free(_imageStack);
+ _imageStack = newStack;
+ _stackSize *= 2;
}
}
- pnew = &image_stack[image_stack_pointer];
- image_stack_pointer++;
+ pnew = &_imageStack[_imageStackPointer];
+ _imageStackPointer++;
pnew->type = type;
pnew->parm1 = p1;
@@ -298,17 +297,17 @@ void AgiEngine::record_image_stack_call(uint8 type, int16 p1, int16 p2, int16 p3
pnew->parm7 = p7;
}
-void AgiEngine::replay_image_stack_call(uint8 type, int16 p1, int16 p2, int16 p3,
+void AgiEngine::replayImageStackCall(uint8 type, int16 p1, int16 p2, int16 p3,
int16 p4, int16 p5, int16 p6, int16 p7) {
switch (type) {
case ADD_PIC:
debugC(8, kDebugLevelMain, "--- decoding picture %d ---", p1);
agiLoadResource(rPICTURE, p1);
- _picture->decode_picture(p1, p2);
+ _picture->decodePicture(p1, p2);
break;
case ADD_VIEW:
agiLoadResource(rVIEW, p1);
- _sprites->add_to_pic(p1, p2, p3, p4, p5, p6, p7);
+ _sprites->addToPic(p1, p2, p3, p4, p5, p6, p7);
break;
}
}
@@ -318,7 +317,7 @@ void AgiEngine::initPriTable() {
for (p = 1; p < 15; p++) {
for (i = 0; i < 12; i++) {
- game.pri_table[y++] = p < 4 ? 4 : p;
+ _game.priTable[y++] = p < 4 ? 4 : p;
}
}
}
@@ -327,44 +326,44 @@ int AgiEngine::agiInit() {
int ec, i;
debug(2, "initializing");
- debug(2, "game.ver = 0x%x", game.ver);
+ debug(2, "game.ver = 0x%x", _game.ver);
/* reset all flags to false and all variables to 0 */
for (i = 0; i < MAX_FLAGS; i++)
- game.flags[i] = 0;
+ _game.flags[i] = 0;
for (i = 0; i < MAX_VARS; i++)
- game.vars[i] = 0;
+ _game.vars[i] = 0;
/* clear all resources and events */
for (i = 0; i < MAX_DIRS; i++) {
- memset(&game.views[i], 0, sizeof(struct agi_view));
- memset(&game.pictures[i], 0, sizeof(struct agi_picture));
- memset(&game.logics[i], 0, sizeof(struct agi_logic));
- memset(&game.sounds[i], 0, sizeof(struct agi_sound));
- memset(&game.dir_view[i], 0, sizeof(struct agi_dir));
- memset(&game.dir_pic[i], 0, sizeof(struct agi_dir));
- memset(&game.dir_logic[i], 0, sizeof(struct agi_dir));
- memset(&game.dir_sound[i], 0, sizeof(struct agi_dir));
+ memset(&_game.views[i], 0, sizeof(struct AgiView));
+ memset(&_game.pictures[i], 0, sizeof(struct AgiPicture));
+ memset(&_game.logics[i], 0, sizeof(struct AgiLogic));
+ memset(&_game.sounds[i], 0, sizeof(struct AgiSound));
+ memset(&_game.dirView[i], 0, sizeof(struct AgiDir));
+ memset(&_game.dirPic[i], 0, sizeof(struct AgiDir));
+ memset(&_game.dirLogic[i], 0, sizeof(struct AgiDir));
+ memset(&_game.dirSound[i], 0, sizeof(struct AgiDir));
}
/* clear view table */
for (i = 0; i < MAX_VIEWTABLE; i++)
- memset(&game.view_table[i], 0, sizeof(struct vt_entry));
+ memset(&_game.viewTable[i], 0, sizeof(struct VtEntry));
- init_words();
+ initWords();
- if (!menu)
- menu = new Menu(this, _gfx, _picture);
+ if (!_menu)
+ _menu = new Menu(this, _gfx, _picture);
initPriTable();
/* clear string buffer */
for (i = 0; i < MAX_STRINGS; i++)
- game.strings[i][0] = 0;
+ _game.strings[i][0] = 0;
/* setup emulation */
- switch (loader->getIntVersion() >> 12) {
+ switch (_loader->getIntVersion() >> 12) {
case 2:
report("Emulating Sierra AGI v%x.%03x\n",
(int)(agiGetRelease() >> 12) & 0xF,
@@ -377,30 +376,30 @@ int AgiEngine::agiInit() {
break;
}
- game.game_flags |= opt.amigaMode ? ID_AMIGA : 0;
- game.game_flags |= opt.agdsMode ? ID_AGDS : 0;
+ _game.gameFlags |= _opt.amigaMode ? ID_AMIGA : 0;
+ _game.gameFlags |= _opt.agdsMode ? ID_AGDS : 0;
- if (game.game_flags & ID_AMIGA)
+ if (_game.gameFlags & ID_AMIGA)
report("Amiga padded game detected.\n");
- if (game.game_flags & ID_AGDS)
+ 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 == err_OK)
- ec = loader->load_objects(OBJECTS);
+ if (ec == errOK)
+ ec = _loader->loadObjects(OBJECTS);
/* note: demogs has no words.tok */
- if (ec == err_OK)
- ec = loader->load_words(WORDS);
+ if (ec == errOK)
+ ec = _loader->loadWords(WORDS);
/* FIXME: load IIgs instruments and samples */
/* load_instruments("kq.sys16"); */
/* Load logic 0 into memory */
- if (ec == err_OK)
- ec = loader->load_resource(rLOGIC, 0);
+ if (ec == errOK)
+ ec = _loader->loadResource(rLOGIC, 0);
return ec;
}
@@ -414,76 +413,76 @@ void AgiEngine::agiUnloadResources() {
/* Make sure logic 0 is always loaded */
for (i = 1; i < MAX_DIRS; i++) {
- loader->unload_resource(rLOGIC, i);
+ _loader->unloadResource(rLOGIC, i);
}
for (i = 0; i < MAX_DIRS; i++) {
- loader->unload_resource(rVIEW, i);
- loader->unload_resource(rPICTURE, i);
- loader->unload_resource(rSOUND, i);
+ _loader->unloadResource(rVIEW, i);
+ _loader->unloadResource(rPICTURE, i);
+ _loader->unloadResource(rSOUND, i);
}
}
int AgiEngine::agiDeinit() {
int ec;
- clean_input(); /* remove all words from memory */
+ cleanInput(); /* remove all words from memory */
agiUnloadResources(); /* unload resources in memory */
- loader->unload_resource(rLOGIC, 0);
- ec = loader->deinit();
- unload_objects();
- unload_words();
+ _loader->unloadResource(rLOGIC, 0);
+ ec = _loader->deinit();
+ unloadObjects();
+ unloadWords();
- clear_image_stack();
+ clearImageStack();
return ec;
}
int AgiEngine::agiDetectGame() {
- int ec = err_OK;
+ int ec = errOK;
assert(_gameDescription != NULL);
- opt.amigaMode = ((_gameDescription->features & AGI_AMIGA) == AGI_AMIGA);
- opt.agdsMode = ((_gameDescription->features & AGI_AGDS) == AGI_AGDS);
- opt.agimouse = ((_gameDescription->features & AGI_MOUSE) == AGI_MOUSE);
+ _opt.amigaMode = ((_gameDescription->features & AGI_AMIGA) == AGI_AMIGA);
+ _opt.agdsMode = ((_gameDescription->features & AGI_AGDS) == AGI_AGDS);
+ _opt.agimouse = ((_gameDescription->features & AGI_MOUSE) == AGI_MOUSE);
if(_gameDescription->version <= 0x2999) {
- loader = new AgiLoader_v2(this);
+ _loader = new AgiLoader_v2(this);
} else {
- loader = new AgiLoader_v3(this);
+ _loader = new AgiLoader_v3(this);
}
- ec = loader->detect_game();
+ ec = _loader->detectGame();
return ec;
}
int AgiEngine::agiVersion() {
- return loader->version();
+ return _loader->version();
}
int AgiEngine::agiGetRelease() {
- return loader->getIntVersion();
+ return _loader->getIntVersion();
}
void AgiEngine::agiSetRelease(int n) {
- loader->setIntVersion(n);
+ _loader->setIntVersion(n);
}
int AgiEngine::agiLoadResource(int r, int n) {
int i;
- i = loader->load_resource(r, n);
+ i = _loader->loadResource(r, n);
#ifdef PATCH_LOGIC
if (r == rLOGIC)
- patch_logic(n);
+ patchLogic(n);
#endif
return i;
}
int AgiEngine::agiUnloadResource(int r, int n) {
- return loader->unload_resource(r, n);
+ return _loader->unloadResource(r, n);
}
struct GameSettings {
@@ -494,13 +493,11 @@ struct GameSettings {
const char *detectname;
};
-static const GameSettings agi_settings[] = {
+static const GameSettings agiSettings[] = {
{"agi", "AGI game", GID_AGI, MDT_ADLIB, "OBJECT"},
{NULL, NULL, 0, 0, NULL}
};
-Common::RandomSource * rnd;
-
AgiEngine::AgiEngine(OSystem *syst) : Engine(syst) {
// Setup mixer
@@ -516,7 +513,7 @@ AgiEngine::AgiEngine(OSystem *syst) : Engine(syst) {
const GameSettings *g;
const char *gameid = ConfMan.get("gameid").c_str();
- for (g = agi_settings; g->gameid; ++g)
+ for (g = agiSettings; g->gameid; ++g)
if (!scumm_stricmp(g->gameid, gameid))
_gameId = g->id;
@@ -534,38 +531,40 @@ AgiEngine::AgiEngine(OSystem *syst) : Engine(syst) {
Common::addSpecialDebugLevel(kDebugLevelSavegame, "Savegame", "Saving & restoring game debugging");
- memset(&game, 0, sizeof(struct agi_game));
- memset(&_debug, 0, sizeof(struct agi_debug));
+ memset(&_game, 0, sizeof(struct AgiGame));
+ memset(&_debug, 0, sizeof(struct AgiDebug));
memset(&g_mouse, 0, sizeof(struct Mouse));
- game.clock_enabled = false;
- game.state = STATE_INIT;
+ _game.clockEnabled = false;
+ _game.state = STATE_INIT;
+
+ _keyQueueStart = 0;
+ _keyQueueEnd = 0;
- _key_queue_start = 0;
- _key_queue_end = 0;
+ _keyControl = 0;
+ _keyAlt = 0;
- _key_control = 0;
- _key_alt = 0;
+ g_tickTimer = 0;
- g_tick_timer = 0;
+ _intobj = NULL;
- intobj = NULL;
+ _stackSize = 0;
+ _imageStack = NULL;
+ _imageStackPointer = 0;
- stack_size = 0;
- image_stack = NULL;
- image_stack_pointer = 0;
+ _menu = NULL;
- menu = NULL;
+ _lastSentence[0] = 0;
+ memset(&_stringdata, 0, sizeof(struct StringData));
- last_sentence[0] = 0;
- memset(&stringdata, 0, sizeof(struct string_data));
+ _objects = NULL;
- objects = NULL;
+ _oldMode = -1;
}
void AgiEngine::initialize() {
- memset(&opt, 0, sizeof(struct agi_options));
- opt.gamerun = GAMERUN_RUNGAME;
+ memset(&_opt, 0, sizeof(struct AgiOptions));
+ _opt.gamerun = GAMERUN_RUNGAME;
// TODO: Some sound emulation modes do not fit our current music
// drivers, and I'm not sure what they are. For now, they might
@@ -573,15 +572,15 @@ void AgiEngine::initialize() {
switch (MidiDriver::detectMusicDriver(MDT_PCSPK)) {
case MD_PCSPK:
- opt.soundemu = SOUND_EMU_PC;
+ _opt.soundemu = SOUND_EMU_PC;
break;
default:
- opt.soundemu = SOUND_EMU_NONE;
+ _opt.soundemu = SOUND_EMU_NONE;
break;
}
if (ConfMan.hasKey("render_mode"))
- opt.renderMode = Common::parseRenderMode(ConfMan.get("render_mode").c_str());
+ _opt.renderMode = Common::parseRenderMode(ConfMan.get("render_mode").c_str());
_console = new Console(this);
_gfx = new GfxMgr(this);
@@ -591,27 +590,27 @@ void AgiEngine::initialize() {
_gfx->initMachine();
- game.game_flags = 0;
+ _game.gameFlags = 0;
- game.color_fg = 15;
- game.color_bg = 0;
+ _game.colorFg = 15;
+ _game.colorBg = 0;
- game.name[0] = '\0';
+ _game.name[0] = '\0';
- game.sbuf = (uint8 *)calloc(_WIDTH, _HEIGHT);
+ _game.sbuf = (uint8 *)calloc(_WIDTH, _HEIGHT);
_gfx->initVideo();
- _sound->init_sound();
+ _sound->initSound();
_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");
- if (agiDetectGame() == err_OK) {
- game.state = STATE_LOADED;
+ if (agiDetectGame() == errOK) {
+ _game.state = STATE_LOADED;
debugC(2, kDebugLevelMain, "game loaded");
} else {
report("Could not open AGI game");
@@ -622,13 +621,13 @@ void AgiEngine::initialize() {
AgiEngine::~AgiEngine() {
agiDeinit();
- _sound->deinit_sound();
+ _sound->deinitSound();
delete _sound;
_gfx->deinitVideo();
delete _sprites;
- free(game.sbuf);
+ free(_game.sbuf);
_gfx->deinitMachine();
- delete rnd;
+ delete _rnd;
delete _console;
}
@@ -658,15 +657,15 @@ int AgiEngine::go() {
CursorMan.showMouse(true);
report(" \nAGI engine %s is ready.\n", gScummVMVersion);
- if (game.state < STATE_LOADED) {
+ if (_game.state < STATE_LOADED) {
do {
- main_cycle();
- } while (game.state < STATE_RUNNING);
- if (game.ver < 0)
- game.ver = 0; /* Enable conf file warning */
+ mainCycle();
+ } while (_game.state < STATE_RUNNING);
+ if (_game.ver < 0)
+ _game.ver = 0; /* Enable conf file warning */
}
- run_game();
+ runGame();
return 0;
}
diff --git a/engines/agi/agi.h b/engines/agi/agi.h
index fc245618a6..6d58d5944b 100644
--- a/engines/agi/agi.h
+++ b/engines/agi/agi.h
@@ -99,7 +99,6 @@ typedef signed int Err;
namespace Agi {
-
enum AgiGameType {
GType_V2 = 1,
GType_V3
@@ -120,29 +119,26 @@ struct AGIGameDescription {
uint16 version;
};
-
-
-
enum {
NO_GAMEDIR = 0,
GAMEDIR
};
enum AGIErrors {
- err_OK = 0,
- err_DoNothing,
- err_BadCLISwitch,
- err_InvalidAGIFile,
- err_BadFileOpen,
- err_NotEnoughMemory,
- err_BadResource,
- err_UnknownAGIVersion,
- err_RestartGame,
- err_NoLoopsInView,
- err_ViewDataError,
- err_NoGameList,
-
- err_Unk = 127
+ errOK = 0,
+ errDoNothing,
+ errBadCLISwitch,
+ errInvalidAGIFile,
+ errBadFileOpen,
+ errNotEnoughMemory,
+ errBadResource,
+ errUnknownAGIVersion,
+ errRestartGame,
+ errNoLoopsInView,
+ errViewDataError,
+ errNoGameList,
+
+ errUnk = 127
};
enum kDebugLevels {
@@ -178,8 +174,8 @@ enum {
lTEST_MODE
};
-struct game_id_list {
- struct game_id_list *next;
+struct gameIdList {
+ gameIdList *next;
uint32 version;
uint32 crc;
char *gName;
@@ -195,7 +191,7 @@ struct Mouse {
/**
* Command-line options.
*/
-struct agi_options {
+struct AgiOptions {
#define GAMERUN_RUNGAME 0
#define GAMERUN_PICVIEW 1
#define GAMERUN_WORDS 2
@@ -225,74 +221,74 @@ enum GameId {
* AGI variables.
*/
enum {
- V_cur_room = 0, /* 0 */
- V_prev_room,
- V_border_touch_ego,
- V_score,
- V_border_code,
- V_border_touch_obj, /* 5 */
- V_ego_dir,
- V_max_score,
- V_free_pages,
- V_word_not_found,
- V_time_delay, /* 10 */
- V_seconds,
- V_minutes,
- V_hours,
- V_days,
- V_joystick_sensitivity, /* 15 */
- V_ego_view_resource,
- V_agi_err_code,
- V_agi_err_code_info,
- V_key,
- V_computer, /* 20 */
- V_window_reset,
- V_soundgen,
- V_volume,
- V_max_input_chars,
- V_sel_item, /* 25 */
- V_monitor
+ vCurRoom = 0, /* 0 */
+ vPrevRoom,
+ vBorderTouchEgo,
+ vScore,
+ vBorderCode,
+ vBorderTouchObj, /* 5 */
+ vEgoDir,
+ vMaxScore,
+ vFreePages,
+ vWordNotFound,
+ vTimeDelay, /* 10 */
+ vSeconds,
+ vMinutes,
+ vHours,
+ vDays,
+ vJoystickSensitivity, /* 15 */
+ vEgoViewResource,
+ vAgiErrCode,
+ vAgiErrCodeInfo,
+ vKey,
+ vComputer, /* 20 */
+ vWindowReset,
+ vSoundgen,
+ vVolume,
+ vMaxInputChars,
+ vSelItem, /* 25 */
+ vMonitor
};
/**
* AGI flags
*/
enum {
- F_ego_water = 0, /* 0 */
- F_ego_invisible,
- F_entered_cli,
- F_ego_touched_p2,
- F_said_accepted_input,
- F_new_room_exec, /* 5 */
- F_restart_game,
- F_script_blocked,
- F_joy_sensitivity,
- F_sound_on,
- F_debugger_on, /* 10 */
- F_logic_zero_firsttime,
- F_restore_just_ran,
- F_status_selects_items,
- F_menus_work,
- F_output_mode, /* 15 */
- F_auto_restart
+ fEgoWater = 0, /* 0 */
+ fEgoInvisible,
+ fEnteredCli,
+ fEgoTouchedP2,
+ fSaidAcceptedInput,
+ fNewRoomExec, /* 5 */
+ fRestartGame,
+ fScriptBlocked,
+ fJoySensitivity,
+ fSoundOn,
+ fDebuggerOn, /* 10 */
+ fLogicZeroFirsttime,
+ fRestoreJustRan,
+ fStatusSelectsItems,
+ fMenusWork,
+ fOutputMode, /* 15 */
+ fAutoRestart
};
-struct agi_event {
+struct AgiEvent {
uint16 data;
uint8 occured;
};
-struct agi_object {
+struct AgiObject {
int location;
char *name;
};
-struct agi_word {
+struct AgiWord {
int id;
char *word;
};
-struct agi_dir {
+struct AgiDir {
uint8 volume;
uint32 offset;
uint32 len;
@@ -306,7 +302,7 @@ struct agi_dir {
*/
};
-struct agi_block {
+struct AgiBlock {
int active;
int x1, y1;
int x2, y2;
@@ -323,7 +319,7 @@ struct agi_block {
* This structure contains all global data of an AGI game executed
* by the interpreter.
*/
-struct agi_game {
+struct AgiGame {
#define STATE_INIT 0x00
#define STATE_LOADED 0x01
#define STATE_RUNNING 0x02
@@ -339,80 +335,80 @@ struct agi_game {
/* internal variables */
int horizon; /**< horizon y coordinate */
- int line_status; /**< line number to put status on */
- int line_user_input; /**< line to put user input on */
- int line_min_print; /**< num lines to print on */
- int cursor_pos; /**< column where the input cursor is */
- uint8 input_buffer[40]; /**< buffer for user input */
- uint8 echo_buffer[40]; /**< buffer for echo.line */
+ int lineStatus; /**< line number to put status on */
+ int lineUserInput; /**< line to put user input on */
+ int lineMinPrint; /**< num lines to print on */
+ int cursorPos; /**< column where the input cursor is */
+ uint8 inputBuffer[40]; /**< buffer for user input */
+ uint8 echoBuffer[40]; /**< buffer for echo.line */
int keypress;
#define INPUT_NORMAL 0x01
#define INPUT_GETSTRING 0x02
#define INPUT_MENU 0x03
#define INPUT_NONE 0x04
- int input_mode; /**< keyboard input mode */
- int input_enabled; /**< keyboard input enabled */
+ int inputMode; /**< keyboard input mode */
+ int inputEnabled; /**< keyboard input enabled */
int lognum; /**< current logic number */
/* internal flags */
- int player_control; /**< player is in control */
- int quit_prog_now; /**< quit now */
- int status_line; /**< status line on/off */
- int clock_enabled; /**< clock is on/off */
- int exit_all_logics; /**< break cycle after new.room */
- int picture_shown; /**< show.pic has been issued */
- int has_prompt; /**< input prompt has been printed */
+ int playerControl; /**< player is in control */
+ int quitProgNow; /**< quit now */
+ int statusLine; /**< status line on/off */
+ int clockEnabled; /**< clock is on/off */
+ int exitAllLogics; /**< break cycle after new.room */
+ int pictureShown; /**< show.pic has been issued */
+ int hasPrompt; /**< input prompt has been printed */
#define ID_AGDS 0x00000001
#define ID_AMIGA 0x00000002
- int game_flags; /**< agi options flags */
+ int gameFlags; /**< agi options flags */
- uint8 pri_table[_HEIGHT];/**< priority table */
+ uint8 priTable[_HEIGHT];/**< priority table */
/* windows */
- uint32 msg_box_ticks; /**< timed message box tick counter */
- struct agi_block block;
- struct agi_block window;
- int has_window;
+ uint32 msgBoxTicks; /**< timed message box tick counter */
+ AgiBlock block;
+ AgiBlock window;
+ int hasWindow;
/* graphics & text */
- int gfx_mode;
- char cursor_char;
- unsigned int color_fg;
- unsigned int color_bg;
+ int gfxMode;
+ char cursorChar;
+ unsigned int colorFg;
+ unsigned int colorBg;
uint8 *sbuf; /**< 160x168 AGI screen buffer */
/* player command line */
- struct agi_word ego_words[MAX_WORDS];
- int num_ego_words;
+ AgiWord egoWords[MAX_WORDS];
+ int numEgoWords;
- unsigned int num_objects;
+ unsigned int numObjects;
- struct agi_event ev_keyp[MAX_DIRS]; /**< keyboard keypress events */
+ AgiEvent evKeyp[MAX_DIRS]; /**< keyboard keypress events */
char strings[MAX_STRINGS + 1][MAX_STRINGLEN]; /**< strings */
/* directory entries for resources */
- struct agi_dir dir_logic[MAX_DIRS];
- struct agi_dir dir_pic[MAX_DIRS];
- struct agi_dir dir_view[MAX_DIRS];
- struct agi_dir dir_sound[MAX_DIRS];
+ AgiDir dirLogic[MAX_DIRS];
+ AgiDir dirPic[MAX_DIRS];
+ AgiDir dirView[MAX_DIRS];
+ AgiDir dirSound[MAX_DIRS];
/* resources */
- struct agi_picture pictures[MAX_DIRS]; /**< AGI picture resources */
- struct agi_logic logics[MAX_DIRS]; /**< AGI logic resources */
- struct agi_view views[MAX_DIRS]; /**< AGI view resources */
- struct agi_sound sounds[MAX_DIRS]; /**< AGI sound 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]; /**< AGI sound resources */
/* view table */
- struct vt_entry view_table[MAX_VIEWTABLE];
+ struct VtEntry viewTable[MAX_VIEWTABLE];
int32 ver; /**< detected game version */
- int simple_save; /**< select simple savegames */
+ int simpleSave; /**< select simple savegames */
};
class AgiLoader {
private:
- int int_version;
+ int intVersion;
AgiEngine *_vm;
public:
@@ -422,11 +418,11 @@ public:
virtual int init() = 0;
virtual int deinit() = 0;
- virtual int detect_game() = 0;
- virtual int load_resource(int, int) = 0;
- virtual int unload_resource(int, int) = 0;
- virtual int load_objects(const char *) = 0;
- virtual int load_words(const char *) = 0;
+ virtual int detectGame() = 0;
+ virtual int loadResource(int, int) = 0;
+ virtual int unloadResource(int, int) = 0;
+ virtual int loadObjects(const char *) = 0;
+ virtual int loadWords(const char *) = 0;
virtual int version() = 0;
virtual void setIntVersion(int) = 0;
virtual int getIntVersion() = 0;
@@ -434,26 +430,26 @@ public:
class AgiLoader_v2 : public AgiLoader {
private:
- int int_version;
+ int _intVersion;
AgiEngine *_vm;
- int load_dir(struct agi_dir *agid, const char *fname);
- uint8 *load_vol_res(struct agi_dir *agid);
+ int loadDir(AgiDir *agid, const char *fname);
+ uint8 *loadVolRes(AgiDir *agid);
public:
AgiLoader_v2(AgiEngine *vm) {
_vm = vm;
- int_version = 0;
+ _intVersion = 0;
}
virtual int init();
virtual int deinit();
- virtual int detect_game();
- virtual int load_resource(int, int);
- virtual int unload_resource(int, int);
- virtual int load_objects(const char *);
- virtual int load_words(const char *);
+ virtual int detectGame();
+ virtual int loadResource(int, int);
+ virtual int unloadResource(int, int);
+ virtual int loadObjects(const char *);
+ virtual int loadWords(const char *);
virtual int version();
virtual void setIntVersion(int);
virtual int getIntVersion();
@@ -461,26 +457,26 @@ public:
class AgiLoader_v3 : public AgiLoader {
private:
- int int_version;
+ int _intVersion;
AgiEngine *_vm;
- int load_dir(agi_dir *agid, Common::File *fp, uint32 offs, uint32 len);
- uint8 *load_vol_res(agi_dir *agid);
+ int loadDir(AgiDir *agid, Common::File *fp, uint32 offs, uint32 len);
+ uint8 *loadVolRes(AgiDir *agid);
public:
AgiLoader_v3(AgiEngine *vm) {
_vm = vm;
- int_version = 0;
+ _intVersion = 0;
}
virtual int init();
virtual int deinit();
- virtual int detect_game();
- virtual int load_resource(int, int);
- virtual int unload_resource(int, int);
- virtual int load_objects(const char *);
- virtual int load_words(const char *);
+ virtual int detectGame();
+ virtual int loadResource(int, int);
+ virtual int unloadResource(int, int);
+ virtual int loadObjects(const char *);
+ virtual int loadWords(const char *);
virtual int version();
virtual void setIntVersion(int);
virtual int getIntVersion();
@@ -493,7 +489,7 @@ class Menu;
extern struct Mouse g_mouse;
/* Image stack support */
-struct image_stack_element {
+struct ImageStackElement {
uint8 type;
uint8 pad;
int16 parm1;
@@ -505,7 +501,7 @@ struct image_stack_element {
int16 parm7;
};
-struct string_data {
+struct StringData {
int x;
int y;
int len;
@@ -538,23 +534,23 @@ public:
private:
- int _key_queue[KEY_QUEUE_SIZE];
- int _key_queue_start;
- int _key_queue_end;
+ int _keyQueue[KEY_QUEUE_SIZE];
+ int _keyQueueStart;
+ int _keyQueueEnd;
- int check_priority(struct vt_entry *v);
- int check_collision(struct vt_entry *v);
- int check_position(struct vt_entry *v);
+ int checkPriority(VtEntry *v);
+ int checkCollision(VtEntry *v);
+ int checkPosition(VtEntry *v);
- uint32 match_version(uint32 crc);
+ uint32 matchVersion(uint32 crc);
public:
- struct agi_game game;
- struct agi_object *objects; /* objects in the game */
+ AgiGame _game;
+ AgiObject *_objects; /* objects in the game */
- struct string_data stringdata;
+ StringData _stringdata;
- AgiLoader *loader; /* loader */
+ AgiLoader *_loader; /* loader */
Common::RandomSource *_rnd;
const char *_savePath;
@@ -568,13 +564,14 @@ public:
int loadGameDialog();
int loadGameSimple();
- volatile uint32 clock_count;
+ volatile uint32 _clockCount;
- uint8 *intobj;
+ uint8 *_intobj;
+ int _oldMode;
- Menu* menu;
+ Menu* _menu;
- char last_sentence[40];
+ char _lastSentence[40];
SpritesMgr *_sprites;
GfxMgr *_gfx;
@@ -583,22 +580,22 @@ public:
#define INITIAL_IMAGE_STACK_SIZE 32
- int stack_size;
- struct image_stack_element *image_stack;
- int image_stack_pointer;
+ int _stackSize;
+ ImageStackElement *_imageStack;
+ int _imageStackPointer;
- void clear_image_stack();
- void record_image_stack_call(uint8 type, int16 p1, int16 p2, int16 p3,
+ void clearImageStack();
+ void recordImageStackCall(uint8 type, int16 p1, int16 p2, int16 p3,
int16 p4, int16 p5, int16 p6, int16 p7);
- void replay_image_stack_call(uint8 type, int16 p1, int16 p2, int16 p3,
+ void replayImageStackCall(uint8 type, int16 p1, int16 p2, int16 p3,
int16 p4, int16 p5, int16 p6, int16 p7);
- void release_image_stack();
+ void releaseImageStack();
- struct agi_debug _debug;
- struct agi_options opt;
+ AgiDebug _debug;
+ AgiOptions _opt;
- int _key_control;
- int _key_alt;
+ int _keyControl;
+ int _keyAlt;
Console *_console;
@@ -618,8 +615,8 @@ public:
static void agiTimerFunctionLow(void *refCon);
void initPriTable();
- void new_input_mode(int);
- void old_input_mode();
+ void newInputMode(int);
+ void oldInputMode();
int getflag(int);
void setflag(int, int);
@@ -627,27 +624,27 @@ public:
int getvar(int);
void setvar(int, int);
void decrypt(uint8 * mem, int len);
- void release_sprites();
- int main_cycle();
- int view_pictures();
- int parse_cli(int, char **);
- int run_game();
+ void releaseSprites();
+ int mainCycle();
+ int viewPictures();
+ int parseCli(int, char **);
+ int runGame();
void inventory();
- void list_games();
- uint32 match_crc(uint32, char *, int);
- int v2id_game();
- int v3id_game();
- int v4id_game(uint32 ver);
- void update_timer();
- int get_app_dir(char *app_dir, unsigned int size);
-
- int setup_v2_game(int ver, uint32 crc);
- int setup_v3_game(int ver, uint32 crc);
-
- void new_room(int n);
- void reset_controllers();
- void interpret_cycle();
- int play_game();
+ void listGames();
+ uint32 matchCrc(uint32, char *, int);
+ int v2IdGame();
+ int v3IdGame();
+ int v4IdGame(uint32 ver);
+ void updateTimer();
+ int getAppDir(char *appDir, unsigned int size);
+
+ int setupV2Game(int ver, uint32 crc);
+ int setupV3Game(int ver, uint32 crc);
+
+ void newRoom(int n);
+ void resetControllers();
+ void interpretCycle();
+ int playGame();
void printItem(int n, int fg, int bg);
int findItem();
@@ -657,82 +654,82 @@ public:
void processEvents();
// Objects
- int show_objects();
- int decode_objects(uint8 *mem, uint32 flen);
- int load_objects(const char *fname);
- int alloc_objects(int);
- void unload_objects();
- const char *object_name(unsigned int);
- int object_get_location(unsigned int);
- void object_set_location(unsigned int, int);
+ int showObjects();
+ int decodeObjects(uint8 *mem, uint32 flen);
+ int loadObjects(const char *fname);
+ int allocObjects(int);
+ void unloadObjects();
+ const char *objectName(unsigned int);
+ int objectGetLocation(unsigned int);
+ void objectSetLocation(unsigned int, int);
// Logic
- int decode_logic(int);
- void unload_logic(int);
- int run_logic(int);
- void patch_logic(int n);
+ int decodeLogic(int);
+ void unloadLogic(int);
+ int runLogic(int);
+ void patchLogic(int n);
- void debug_console(int, int, const char *);
- int test_if_code(int);
- void execute_agi_command(uint8, uint8 *);
+ void debugConsole(int, int, const char *);
+ int testIfCode(int);
+ void executeAgiCommand(uint8, uint8 *);
// View
private:
- void _set_cel(vt_entry *v, int n);
- void _set_loop(vt_entry *v, int n);
- void update_view(vt_entry *v);
+ void lSetCel(VtEntry *v, int n);
+ void lSetLoop(VtEntry *v, int n);
+ void updateView(VtEntry *v);
public:
- void set_cel(vt_entry *, int);
- void set_loop(vt_entry *, int);
- void set_view(vt_entry *, int);
- void start_update(vt_entry *);
- void stop_update(vt_entry *);
- void update_viewtable();
- void unload_view(int);
- int decode_view(int);
- void add_to_pic(int, int, int, int, int, int, int);
- void draw_obj(int);
- bool is_ego_view(const vt_entry *v);
+ void setCel(VtEntry *, int);
+ void setLoop(VtEntry *, int);
+ void setView(VtEntry *, int);
+ void startUpdate(VtEntry *);
+ void stopUpdate(VtEntry *);
+ void updateViewtable();
+ void unloadView(int);
+ int decodeView(int);
+ void addToPic(int, int, int, int, int, int, int);
+ void drawObj(int);
+ bool isEgoView(const VtEntry *v);
// Words
- int show_words();
- int load_words(const char *);
- void unload_words();
- int find_word(char *word, int *flen);
- void dictionary_words(char *);
+ int showWords();
+ int loadWords(const char *);
+ void unloadWords();
+ int findWord(char *word, int *flen);
+ void dictionaryWords(char *);
// Motion
private:
- int check_step(int delta, int step);
- int check_block(int x, int y);
- void changepos(struct vt_entry *v);
- void motion_wander(struct vt_entry *v);
- void motion_followego(struct vt_entry *v);
- void motion_moveobj(struct vt_entry *v);
- void check_motion(struct vt_entry *v);
+ int checkStep(int delta, int step);
+ int checkBlock(int x, int y);
+ void changePos(VtEntry *v);
+ void motionWander(VtEntry *v);
+ void motionFollowEgo(VtEntry *v);
+ void motionMoveObj(VtEntry *v);
+ void checkMotion(VtEntry *v);
public:
- void check_all_motions();
- void move_obj(vt_entry *);
- void in_destination(vt_entry *);
- void fix_position(int);
- void update_position();
- int get_direction(int x0, int y0, int x, int y, int s);
+ void checkAllMotions();
+ void moveObj(VtEntry *);
+ void inDestination(VtEntry *);
+ void fixPosition(int);
+ void updatePosition();
+ int getDirection(int x0, int y0, int x, int y, int s);
// Keyboard
- void init_words();
- void clean_input();
- int do_poll_keyboard();
- void clean_keyboard();
- void handle_keys(int);
- void handle_getstring(int);
- int handle_controller(int);
- void get_string(int, int, int, int);
- uint16 agi_get_keypress();
- int wait_key();
- int wait_any_key();
+ void initWords();
+ void cleanInput();
+ int doPollKeyboard();
+ void cleanKeyboard();
+ void handleKeys(int);
+ void handleGetstring(int);
+ int handleController(int);
+ void getString(int, int, int, int);
+ uint16 agiGetKeypress();
+ int waitKey();
+ int waitAnyKey();
// Text
public:
@@ -740,27 +737,27 @@ public:
typedef Common::String String;
- int message_box(const char *);
- int selection_box(const char *, const char **);
- void close_window(void);
- void draw_window(int, int, int, int);
- void print_text(const char *, int, int, int, int, int, int, bool checkerboard = false);
- void print_text_console(const char *, int, int, int, int, int);
+ int messageBox(const char *);
+ int selectionBox(const char *, const char **);
+ void closeWindow(void);
+ void drawWindow(int, int, int, int);
+ void printText(const char *, int, int, int, int, int, int, bool checkerboard = false);
+ void printTextConsole(const char *, int, int, int, int, int);
int print(const char *, int, int, int);
- char *word_wrap_string(char *, int *);
- char *agi_sprintf(const char *);
- void write_status(void);
- void write_prompt(void);
- void clear_lines(int, int, int);
- void flush_lines(int, int);
+ char *wordWrapString(char *, int *);
+ char *agiSprintf(const char *);
+ void writeStatus(void);
+ void writePrompt(void);
+ void clearLines(int, int, int);
+ void flushLines(int, int);
bool predictiveDialog(void);
private:
- void print_status(const char *message, ...);
- void print_text2(int l, const char *msg, int foff, int xoff, int yoff, int len, int fg, int bg, bool checkerboard = false);
- void blit_textbox(const char *p, int y, int x, int len);
- void erase_textbox();
- char *safe_strcat(char *s, const char *t);
+ void printStatus(const char *message, ...);
+ void printText2(int l, const char *msg, int foff, int xoff, int yoff, int len, int fg, int bg, bool checkerboard = false);
+ void blitTextbox(const char *p, int y, int x, int len);
+ void eraseTextbox();
+ char *safeStrcat(char *s, const char *t);
void loadDict(void);
bool matchWord(void);
diff --git a/engines/agi/agi_v2.cpp b/engines/agi/agi_v2.cpp
index c2f33320f0..f9db715622 100644
--- a/engines/agi/agi_v2.cpp
+++ b/engines/agi/agi_v2.cpp
@@ -34,25 +34,25 @@ int AgiLoader_v2::version() {
}
void AgiLoader_v2::setIntVersion(int ver) {
- int_version = ver;
+ _intVersion = ver;
}
int AgiLoader_v2::getIntVersion() {
- return int_version;
+ return _intVersion;
}
-int AgiLoader_v2::detect_game() {
+int AgiLoader_v2::detectGame() {
if (!Common::File::exists(LOGDIR) ||
!Common::File::exists(PICDIR) ||
!Common::File::exists(SNDDIR) ||
!Common::File::exists(VIEWDIR))
- return err_InvalidAGIFile;
+ return errInvalidAGIFile;
- int_version = 0x2917; /* setup for 2.917 */
- return _vm->v2id_game();
+ _intVersion = 0x2917; /* setup for 2.917 */
+ return _vm->v2IdGame();
}
-int AgiLoader_v2::load_dir(struct agi_dir *agid, const char *fname) {
+int AgiLoader_v2::loadDir(AgiDir *agid, const char *fname) {
Common::File fp;
uint8 *mem;
uint32 flen;
@@ -61,7 +61,7 @@ int AgiLoader_v2::load_dir(struct agi_dir *agid, const char *fname) {
report("Loading directory: %s\n", fname);
if (!fp.open(fname)) {
- return err_BadFileOpen;
+ return errBadFileOpen;
}
fp.seek(0, SEEK_END);
@@ -70,7 +70,7 @@ int AgiLoader_v2::load_dir(struct agi_dir *agid, const char *fname) {
if ((mem = (uint8 *)malloc(flen + 32)) == NULL) {
fp.close();
- return err_NotEnoughMemory;
+ return errNotEnoughMemory;
}
fp.read(mem, flen);
@@ -91,57 +91,57 @@ int AgiLoader_v2::load_dir(struct agi_dir *agid, const char *fname) {
free(mem);
fp.close();
- return err_OK;
+ return errOK;
}
int AgiLoader_v2::init() {
- int ec = err_OK;
+ int ec = errOK;
/* load directory files */
- ec = load_dir(_vm->game.dir_logic, LOGDIR);
- if (ec == err_OK)
- ec = load_dir(_vm->game.dir_pic, PICDIR);
- if (ec == err_OK)
- ec = load_dir(_vm->game.dir_view, VIEWDIR);
- if (ec == err_OK)
- ec = load_dir(_vm->game.dir_sound, SNDDIR);
+ ec = loadDir(_vm->_game.dirLogic, LOGDIR);
+ if (ec == errOK)
+ ec = loadDir(_vm->_game.dirPic, PICDIR);
+ if (ec == errOK)
+ ec = loadDir(_vm->_game.dirView, VIEWDIR);
+ if (ec == errOK)
+ ec = loadDir(_vm->_game.dirSound, SNDDIR);
return ec;
}
int AgiLoader_v2::deinit() {
- int ec = err_OK;
+ int ec = errOK;
#if 0
/* unload words */
- agi_v2_unload_words();
+ agiV2UnloadWords();
/* unload objects */
- agi_v2_unload_objects();
+ agiV2UnloadObjects();
#endif
return ec;
}
-int AgiLoader_v2::unload_resource(int t, int n) {
+int AgiLoader_v2::unloadResource(int t, int n) {
debugC(3, kDebugLevelResources, "unload resource");
switch (t) {
case rLOGIC:
- _vm->unload_logic(n);
+ _vm->unloadLogic(n);
break;
case rPICTURE:
- _vm->_picture->unload_picture(n);
+ _vm->_picture->unloadPicture(n);
break;
case rVIEW:
- _vm->unload_view(n);
+ _vm->unloadView(n);
break;
case rSOUND:
- _vm->_sound->unload_sound(n);
+ _vm->_sound->unloadSound(n);
break;
}
- return err_OK;
+ return errOK;
}
/*
@@ -149,7 +149,7 @@ int AgiLoader_v2::unload_resource(int t, int n) {
* if further decoding is required, it must be done by another
* routine. NULL is returned if unsucsessfull.
*/
-uint8 *AgiLoader_v2::load_vol_res(struct agi_dir *agid) {
+uint8 *AgiLoader_v2::loadVolRes(struct AgiDir *agid) {
uint8 *data = NULL;
char x[MAX_PATH], *path;
Common::File fp;
@@ -176,7 +176,7 @@ uint8 *AgiLoader_v2::load_vol_res(struct agi_dir *agid) {
/* FIXME: call some panic handler instead of
* deiniting directly
*/
- deinit_video_mode();
+ deinitVideoMode();
#endif
report("Error: bad signature %04x\n", sig);
// fprintf (stderr, "ACK! BAD RESOURCE!!!\n");
@@ -196,33 +196,33 @@ uint8 *AgiLoader_v2::load_vol_res(struct agi_dir *agid) {
* Loads a resource into memory, a raw resource is loaded in
* with above routine, then further decoded here.
*/
-int AgiLoader_v2::load_resource(int t, int n) {
- int ec = err_OK;
+int AgiLoader_v2::loadResource(int t, int n) {
+ int ec = errOK;
uint8 *data = NULL;
debugC(3, kDebugLevelResources, "(t = %d, n = %d)", t, n);
if (n > MAX_DIRS)
- return err_BadResource;
+ return errBadResource;
switch (t) {
case rLOGIC:
- if (~_vm->game.dir_logic[n].flags & RES_LOADED) {
+ if (~_vm->_game.dirLogic[n].flags & RES_LOADED) {
debugC(3, kDebugLevelResources, "loading logic resource %d", n);
- unload_resource(rLOGIC, n);
+ unloadResource(rLOGIC, n);
/* load raw resource into data */
- data = load_vol_res(&_vm->game.dir_logic[n]);
+ data = loadVolRes(&_vm->_game.dirLogic[n]);
- _vm->game.logics[n].data = data;
- ec = data ? _vm->decode_logic(n) : err_BadResource;
+ _vm->_game.logics[n].data = data;
+ ec = data ? _vm->decodeLogic(n) : errBadResource;
- _vm->game.logics[n].sIP = 2;
+ _vm->_game.logics[n].sIP = 2;
}
/* if logic was cached, we get here */
/* reset code pointers incase it was cached */
- _vm->game.logics[n].cIP = _vm->game.logics[n].sIP;
+ _vm->_game.logics[n].cIP = _vm->_game.logics[n].sIP;
break;
case rPICTURE:
/* if picture is currently NOT loaded *OR* cacheing is off,
@@ -230,34 +230,34 @@ int AgiLoader_v2::load_resource(int t, int n) {
*/
debugC(3, kDebugLevelResources, "loading picture resource %d", n);
- if (_vm->game.dir_pic[n].flags & RES_LOADED)
+ if (_vm->_game.dirPic[n].flags & RES_LOADED)
break;
/* if loaded but not cached, unload it */
/* if cached but not loaded, etc */
- unload_resource(rPICTURE, n);
- data = load_vol_res(&_vm->game.dir_pic[n]);
+ unloadResource(rPICTURE, n);
+ data = loadVolRes(&_vm->_game.dirPic[n]);
if (data != NULL) {
- _vm->game.pictures[n].rdata = data;
- _vm->game.dir_pic[n].flags |= RES_LOADED;
+ _vm->_game.pictures[n].rdata = data;
+ _vm->_game.dirPic[n].flags |= RES_LOADED;
} else {
- ec = err_BadResource;
+ ec = errBadResource;
}
break;
case rSOUND:
debugC(3, kDebugLevelResources, "loading sound resource %d", n);
- if (_vm->game.dir_sound[n].flags & RES_LOADED)
+ if (_vm->_game.dirSound[n].flags & RES_LOADED)
break;
- data = load_vol_res(&_vm->game.dir_sound[n]);
+ data = loadVolRes(&_vm->_game.dirSound[n]);
if (data != NULL) {
- _vm->game.sounds[n].rdata = data;
- _vm->game.dir_sound[n].flags |= RES_LOADED;
- _vm->_sound->decode_sound(n);
+ _vm->_game.sounds[n].rdata = data;
+ _vm->_game.dirSound[n].flags |= RES_LOADED;
+ _vm->_sound->decodeSound(n);
} else {
- ec = err_BadResource;
+ ec = errBadResource;
}
break;
case rVIEW:
@@ -266,34 +266,34 @@ int AgiLoader_v2::load_resource(int t, int n) {
* can we cache the view? or must we reload it all
* the time?
*/
- if (_vm->game.dir_view[n].flags & RES_LOADED)
+ if (_vm->_game.dirView[n].flags & RES_LOADED)
break;
debugC(3, kDebugLevelResources, "loading view resource %d", n);
- unload_resource(rVIEW, n);
- data = load_vol_res(&_vm->game.dir_view[n]);
+ unloadResource(rVIEW, n);
+ data = loadVolRes(&_vm->_game.dirView[n]);
if (data) {
- _vm->game.views[n].rdata = data;
- _vm->game.dir_view[n].flags |= RES_LOADED;
- ec = _vm->decode_view(n);
+ _vm->_game.views[n].rdata = data;
+ _vm->_game.dirView[n].flags |= RES_LOADED;
+ ec = _vm->decodeView(n);
} else {
- ec = err_BadResource;
+ ec = errBadResource;
}
break;
default:
- ec = err_BadResource;
+ ec = errBadResource;
break;
}
return ec;
}
-int AgiLoader_v2::load_objects(const char *fname) {
- return _vm->load_objects(fname);
+int AgiLoader_v2::loadObjects(const char *fname) {
+ return _vm->loadObjects(fname);
}
-int AgiLoader_v2::load_words(const char *fname) {
- return _vm->load_words(fname);
+int AgiLoader_v2::loadWords(const char *fname) {
+ return _vm->loadWords(fname);
}
-} // End of namespace Agi
+} // End of namespace Agi
diff --git a/engines/agi/agi_v3.cpp b/engines/agi/agi_v3.cpp
index e545e55107..a2aac6bc86 100644
--- a/engines/agi/agi_v3.cpp
+++ b/engines/agi/agi_v3.cpp
@@ -37,24 +37,23 @@ int AgiLoader_v3::version() {
}
void AgiLoader_v3::setIntVersion(int ver) {
- int_version = ver;
+ _intVersion = ver;
}
int AgiLoader_v3::getIntVersion() {
- return int_version;
+ return _intVersion;
}
-int AgiLoader_v3::detect_game() {
- int ec = err_Unk;
+int AgiLoader_v3::detectGame() {
+ int ec = errUnk;
bool found = false;
FSList fslist;
FilesystemNode dir(ConfMan.get("path"));
if (!dir.listDir(fslist, FilesystemNode::kListFilesOnly)) {
- warning("AgiEngine: invalid game path '%s'",
- dir.path().c_str());
- return err_InvalidAGIFile;
+ warning("AgiEngine: invalid game path '%s'", dir.path().c_str());
+ return errInvalidAGIFile;
}
for (FSList::const_iterator file = fslist.begin();
@@ -63,10 +62,10 @@ int AgiLoader_v3::detect_game() {
f.toLowercase();
if (f.hasSuffix("vol.0")) {
- strncpy(_vm->game.name, f.c_str(), f.size() > 5 ? f.size() - 5 : f.size());
- debugC(3, kDebugLevelMain, "game.name = %s", _vm->game.name);
- int_version = 0x3149; // setup for 3.002.149
- ec = _vm->v3id_game();
+ strncpy(_vm->_game.name, f.c_str(), f.size() > 5 ? f.size() - 5 : f.size());
+ debugC(3, kDebugLevelMain, "game.name = %s", _vm->_game.name);
+ _intVersion = 0x3149; // setup for 3.002.149
+ ec = _vm->v3IdGame();
found = true;
}
@@ -74,20 +73,20 @@ int AgiLoader_v3::detect_game() {
if (!found) {
debugC(3, kDebugLevelMain, "not found");
- ec = err_InvalidAGIFile;
+ ec = errInvalidAGIFile;
}
return ec;
}
-int AgiLoader_v3::load_dir(struct agi_dir *agid, Common::File *fp,
+int AgiLoader_v3::loadDir(struct AgiDir *agid, Common::File *fp,
uint32 offs, uint32 len) {
- int ec = err_OK;
+ int ec = errOK;
uint8 *mem;
unsigned int i;
fp->seek(offs, SEEK_SET);
- if ((mem = (uint8 *) malloc(len + 32)) != NULL) {
+ if ((mem = (uint8 *)malloc(len + 32)) != NULL) {
fp->read(mem, len);
/* set all directory resources to gone */
@@ -104,7 +103,7 @@ int AgiLoader_v3::load_dir(struct agi_dir *agid, Common::File *fp,
free(mem);
} else {
- ec = err_NotEnoughMemory;
+ ec = errNotEnoughMemory;
}
return ec;
@@ -116,86 +115,85 @@ struct agi3vol {
};
int AgiLoader_v3::init() {
- int ec = err_OK;
- struct agi3vol agi_vol3[4];
+ int ec = errOK;
+ struct agi3vol agiVol3[4];
int i;
uint16 xd[4];
Common::File fp;
Common::String path;
- path = Common::String(_vm->game.name) + DIR_;
+ path = Common::String(_vm->_game.name) + DIR_;
if (!fp.open(path)) {
printf("Failed to open \"%s\"\n", path.c_str());
- return err_BadFileOpen;
+ return errBadFileOpen;
}
/* build offset table for v3 directory format */
fp.read(&xd, 8);
fp.seek(0, SEEK_END);
for (i = 0; i < 4; i++)
- agi_vol3[i].sddr = READ_LE_UINT16((uint8 *) & xd[i]);
+ agiVol3[i].sddr = READ_LE_UINT16((uint8 *) & xd[i]);
- agi_vol3[0].len = agi_vol3[1].sddr - agi_vol3[0].sddr;
- agi_vol3[1].len = agi_vol3[2].sddr - agi_vol3[1].sddr;
- agi_vol3[2].len = agi_vol3[3].sddr - agi_vol3[2].sddr;
- agi_vol3[3].len = fp.pos() - agi_vol3[3].sddr;
+ agiVol3[0].len = agiVol3[1].sddr - agiVol3[0].sddr;
+ agiVol3[1].len = agiVol3[2].sddr - agiVol3[1].sddr;
+ agiVol3[2].len = agiVol3[3].sddr - agiVol3[2].sddr;
+ agiVol3[3].len = fp.pos() - agiVol3[3].sddr;
- if (agi_vol3[3].len > 256 * 3)
- agi_vol3[3].len = 256 * 3;
+ if (agiVol3[3].len > 256 * 3)
+ agiVol3[3].len = 256 * 3;
fp.seek(0, SEEK_SET);
/* read in directory files */
- ec = load_dir(_vm->game.dir_logic, &fp, agi_vol3[0].sddr,
- agi_vol3[0].len);
+ ec = loadDir(_vm->_game.dirLogic, &fp, agiVol3[0].sddr, agiVol3[0].len);
- if (ec == err_OK) {
- ec = load_dir(_vm->game.dir_pic, &fp, agi_vol3[1].sddr, agi_vol3[1].len);
+ if (ec == errOK) {
+ ec = loadDir(_vm->_game.dirPic, &fp, agiVol3[1].sddr, agiVol3[1].len);
}
- if (ec == err_OK) {
- ec = load_dir(_vm->game.dir_view, &fp, agi_vol3[2].sddr, agi_vol3[2].len);
+ if (ec == errOK) {
+ ec = loadDir(_vm->_game.dirView, &fp, agiVol3[2].sddr, agiVol3[2].len);
}
- if (ec == err_OK) {
- ec = load_dir(_vm->game.dir_sound, &fp, agi_vol3[3].sddr, agi_vol3[3].len);
+ if (ec == errOK) {
+ ec = loadDir(_vm->_game.dirSound, &fp, agiVol3[3].sddr, agiVol3[3].len);
}
return ec;
}
int AgiLoader_v3::deinit() {
- int ec = err_OK;
+ int ec = errOK;
#if 0
/* unload words */
- agi_v3_unload_words();
+ agiV3UnloadWords();
/* unload objects */
- agi_v3_unload_objects();
+ agiV3UnloadObjects();
#endif
return ec;
}
-int AgiLoader_v3::unload_resource(int t, int n) {
+int AgiLoader_v3::unloadResource(int t, int n) {
switch (t) {
case rLOGIC:
- _vm->unload_logic(n);
+ _vm->unloadLogic(n);
break;
case rPICTURE:
- _vm->_picture->unload_picture(n);
+ _vm->_picture->unloadPicture(n);
break;
case rVIEW:
- _vm->unload_view(n);
+ _vm->unloadView(n);
break;
case rSOUND:
- _vm->_sound->unload_sound(n);
+ _vm->_sound->unloadSound(n);
break;
}
- return err_OK;
+ return errOK;
}
/*
@@ -205,15 +203,15 @@ int AgiLoader_v3::unload_resource(int t, int n) {
*
* NULL is returned if unsucsessful.
*/
-uint8 *AgiLoader_v3::load_vol_res(struct agi_dir *agid) {
+uint8 *AgiLoader_v3::loadVolRes(AgiDir *agid) {
char x[MAX_PATH];
- uint8 *data = NULL, *comp_buffer;
+ uint8 *data = NULL, *compBuffer;
Common::File fp;
Common::String path;
debugC(3, kDebugLevelResources, "(%p)", (void *)agid);
sprintf(x, "vol.%i", agid->volume);
- path = Common::String(_vm->game.name) + x;
+ path = Common::String(_vm->_game.name) + x;
if (agid->offset != _EMPTY && fp.open(path)) {
fp.seek(agid->offset, SEEK_SET);
@@ -222,7 +220,7 @@ uint8 *AgiLoader_v3::load_vol_res(struct agi_dir *agid) {
if (READ_BE_UINT16((uint8 *) x) != 0x1234) {
#if 0
/* FIXME */
- deinit_video_mode();
+ deinitVideoMode();
#endif
debugC(3, kDebugLevelResources, "path = %s", path.c_str());
debugC(3, kDebugLevelResources, "offset = %d", agid->offset);
@@ -235,12 +233,12 @@ uint8 *AgiLoader_v3::load_vol_res(struct agi_dir *agid) {
agid->len = READ_LE_UINT16((uint8 *) x + 3); /* uncompressed size */
agid->clen = READ_LE_UINT16((uint8 *) x + 5); /* compressed len */
- comp_buffer = (uint8 *)calloc(1, agid->clen + 32);
- fp.read(comp_buffer, agid->clen);
+ compBuffer = (uint8 *)calloc(1, agid->clen + 32);
+ fp.read(compBuffer, agid->clen);
if (x[2] & 0x80 || agid->len == agid->clen) {
/* do not decompress */
- data = comp_buffer;
+ data = compBuffer;
#if 0
/* CM: added to avoid problems in
@@ -255,8 +253,8 @@ uint8 *AgiLoader_v3::load_vol_res(struct agi_dir *agid) {
} else {
/* it is compressed */
data = (uint8 *)calloc(1, agid->len + 32);
- LZW_expand(comp_buffer, data, agid->len);
- free(comp_buffer);
+ lzwExpand(compBuffer, data, agid->len);
+ free(compBuffer);
agid->flags |= RES_COMPRESSED;
}
@@ -274,74 +272,74 @@ uint8 *AgiLoader_v3::load_vol_res(struct agi_dir *agid) {
* Loads a resource into memory, a raw resource is loaded in
* with above routine, then further decoded here.
*/
-int AgiLoader_v3::load_resource(int t, int n) {
- int ec = err_OK;
+int AgiLoader_v3::loadResource(int t, int n) {
+ int ec = errOK;
uint8 *data = NULL;
if (n > MAX_DIRS)
- return err_BadResource;
+ return errBadResource;
switch (t) {
case rLOGIC:
/* load resource into memory, decrypt messages at the end
* and build the message list (if logic is in memory)
*/
- if (~_vm->game.dir_logic[n].flags & RES_LOADED) {
+ if (~_vm->_game.dirLogic[n].flags & RES_LOADED) {
/* if logic is already in memory, unload it */
- unload_resource(rLOGIC, n);
+ unloadResource(rLOGIC, n);
/* load raw resource into data */
- data = load_vol_res(&_vm->game.dir_logic[n]);
- _vm->game.logics[n].data = data;
+ data = loadVolRes(&_vm->_game.dirLogic[n]);
+ _vm->_game.logics[n].data = data;
/* uncompressed logic files need to be decrypted */
if (data != NULL) {
/* resloaded flag gets set by decode logic */
/* needed to build string table */
- ec = _vm->decode_logic(n);
- _vm->game.logics[n].sIP = 2;
+ ec = _vm->decodeLogic(n);
+ _vm->_game.logics[n].sIP = 2;
} else {
- ec = err_BadResource;
+ ec = errBadResource;
}
/*logics[n].sIP=2; *//* saved IP = 2 */
/*logics[n].cIP=2; *//* current IP = 2 */
- _vm->game.logics[n].cIP = _vm->game.logics[n].sIP;
+ _vm->_game.logics[n].cIP = _vm->_game.logics[n].sIP;
}
/* if logic was cached, we get here */
/* reset code pointers incase it was cached */
- _vm->game.logics[n].cIP = _vm->game.logics[n].sIP;
+ _vm->_game.logics[n].cIP = _vm->_game.logics[n].sIP;
break;
case rPICTURE:
/* if picture is currently NOT loaded *OR* cacheing is off,
* unload the resource (caching==off) and reload it
*/
- if (~_vm->game.dir_pic[n].flags & RES_LOADED) {
- unload_resource(rPICTURE, n);
- data = load_vol_res(&_vm->game.dir_pic[n]);
+ if (~_vm->_game.dirPic[n].flags & RES_LOADED) {
+ unloadResource(rPICTURE, n);
+ data = loadVolRes(&_vm->_game.dirPic[n]);
if (data != NULL) {
- data = _vm->_picture->convert_v3_pic(data, _vm->game.dir_pic[n].len);
- _vm->game.pictures[n].rdata = data;
- _vm->game.dir_pic[n].flags |= RES_LOADED;
+ data = _vm->_picture->convertV3Pic(data, _vm->_game.dirPic[n].len);
+ _vm->_game.pictures[n].rdata = data;
+ _vm->_game.dirPic[n].flags |= RES_LOADED;
} else {
- ec = err_BadResource;
+ ec = errBadResource;
}
}
break;
case rSOUND:
- if (_vm->game.dir_sound[n].flags & RES_LOADED)
+ if (_vm->_game.dirSound[n].flags & RES_LOADED)
break;
- data = load_vol_res(&_vm->game.dir_sound[n]);
+ data = loadVolRes(&_vm->_game.dirSound[n]);
if (data != NULL) {
- _vm->game.sounds[n].rdata = data;
- _vm->game.dir_sound[n].flags |= RES_LOADED;
- _vm->_sound->decode_sound(n);
+ _vm->_game.sounds[n].rdata = data;
+ _vm->_game.dirSound[n].flags |= RES_LOADED;
+ _vm->_sound->decodeSound(n);
} else {
- ec = err_BadResource;
+ ec = errBadResource;
}
break;
case rVIEW:
@@ -350,33 +348,33 @@ int AgiLoader_v3::load_resource(int t, int n) {
* cache the view? or must we reload it all the time?
*/
/* load a raw view from a VOL file into data */
- if (_vm->game.dir_view[n].flags & RES_LOADED)
+ if (_vm->_game.dirView[n].flags & RES_LOADED)
break;
- unload_resource(rVIEW, n);
- data = load_vol_res(&_vm->game.dir_view[n]);
+ unloadResource(rVIEW, n);
+ data = loadVolRes(&_vm->_game.dirView[n]);
if (data != NULL) {
- _vm->game.views[n].rdata = data;
- _vm->game.dir_view[n].flags |= RES_LOADED;
- ec = _vm->decode_view(n);
+ _vm->_game.views[n].rdata = data;
+ _vm->_game.dirView[n].flags |= RES_LOADED;
+ ec = _vm->decodeView(n);
} else {
- ec = err_BadResource;
+ ec = errBadResource;
}
break;
default:
- ec = err_BadResource;
+ ec = errBadResource;
break;
}
return ec;
}
-int AgiLoader_v3::load_objects(const char *fname) {
- return _vm->load_objects(fname);
+int AgiLoader_v3::loadObjects(const char *fname) {
+ return _vm->loadObjects(fname);
}
-int AgiLoader_v3::load_words(const char *fname) {
- return _vm->load_words(fname);
+int AgiLoader_v3::loadWords(const char *fname) {
+ return _vm->loadWords(fname);
}
-} // End of namespace Agi
+} // End of namespace Agi
diff --git a/engines/agi/checks.cpp b/engines/agi/checks.cpp
index 772ef7c132..367964cd26 100644
--- a/engines/agi/checks.cpp
+++ b/engines/agi/checks.cpp
@@ -27,22 +27,22 @@
namespace Agi {
-int AgiEngine::check_position(struct vt_entry *v) {
- debugC(4, kDebugLevelSprites, "check position @ %d, %d", v->x_pos, v->y_pos);
-
- if (v->x_pos < 0 ||
- v->x_pos + v->x_size > _WIDTH ||
- v->y_pos - v->y_size + 1 < 0 ||
- v->y_pos >= _HEIGHT ||
- ((~v->flags & IGNORE_HORIZON) && v->y_pos <= game.horizon)) {
+int AgiEngine::checkPosition(struct VtEntry *v) {
+ debugC(4, kDebugLevelSprites, "check position @ %d, %d", v->xPos, v->yPos);
+
+ if (v->xPos < 0 ||
+ v->xPos + v->xSize > _WIDTH ||
+ v->yPos - v->ySize + 1 < 0 ||
+ v->yPos >= _HEIGHT ||
+ ((~v->flags & IGNORE_HORIZON) && v->yPos <= _game.horizon)) {
debugC(4, kDebugLevelSprites, "check position failed: x=%d, y=%d, h=%d, w=%d",
- v->x_pos, v->y_pos, v->x_size, v->y_size);
+ v->xPos, v->yPos, v->xSize, v->ySize);
return 0;
}
/* MH1 needs this, but it breaks LSL1 */
if (agiGetRelease() >= 0x3000) {
- if (v->y_pos < v->y_size)
+ if (v->yPos < v->ySize)
return 0;
}
@@ -52,13 +52,13 @@ int AgiEngine::check_position(struct vt_entry *v) {
/**
* Check if there's another object on the way
*/
-int AgiEngine::check_collision(struct vt_entry *v) {
- struct vt_entry *u;
+int AgiEngine::checkCollision(struct VtEntry *v) {
+ struct VtEntry *u;
if (v->flags & IGNORE_OBJECTS)
return 0;
- for (u = game.view_table; u < &game.view_table[MAX_VIEWTABLE]; u++) {
+ for (u = _game.viewTable; u < &_game.viewTable[MAX_VIEWTABLE]; u++) {
if ((u->flags & (ANIMATED | DRAWN)) != (ANIMATED | DRAWN))
continue;
@@ -70,17 +70,16 @@ int AgiEngine::check_collision(struct vt_entry *v) {
continue;
/* No horizontal overlap, check next */
- if (v->x_pos + v->x_size < u->x_pos ||
- v->x_pos > u->x_pos + u->x_size)
+ if (v->xPos + v->xSize < u->xPos || v->xPos > u->xPos + u->xSize)
continue;
/* Same y, return error! */
- if (v->y_pos == u->y_pos)
+ if (v->yPos == u->yPos)
goto return_1;
/* Crossed the baseline, return error! */
- if ((v->y_pos > u->y_pos && v->y_pos2 < u->y_pos2) ||
- (v->y_pos < u->y_pos && v->y_pos2 > u->y_pos2)) {
+ if ((v->yPos > u->yPos && v->yPos2 < u->yPos2) ||
+ (v->yPos < u->yPos && v->yPos2 > u->yPos2)) {
goto return_1;
}
}
@@ -92,13 +91,13 @@ int AgiEngine::check_collision(struct vt_entry *v) {
return 1;
}
-int AgiEngine::check_priority(struct vt_entry *v) {
+int AgiEngine::checkPriority(VtEntry *v) {
int i, trigger, water, pass, pri;
uint8 *p0;
if (~v->flags & FIXED_PRIORITY) {
/* Priority bands */
- v->priority = game.pri_table[v->y_pos];
+ v->priority = _game.priTable[v->yPos];
}
trigger = 0;
@@ -106,13 +105,13 @@ int AgiEngine::check_priority(struct vt_entry *v) {
pass = 1;
if (v->priority == 0x0f)
- goto _check_ego;
+ goto check_ego;
water = 1;
- p0 = &game.sbuf[v->x_pos + v->y_pos * _WIDTH];
+ p0 = &_game.sbuf[v->xPos + v->yPos * _WIDTH];
- for (i = 0; i < v->x_size; i++, p0++) {
+ for (i = 0; i < v->xSize; i++, p0++) {
pri = *p0 >> 4;
if (pri == 0) { /* unconditional black. no go at all! */
@@ -148,10 +147,10 @@ int AgiEngine::check_priority(struct vt_entry *v) {
pass = 0;
}
- _check_ego:
+check_ego:
if (v->entry == 0) {
- setflag(F_ego_touched_p2, trigger ? true : false);
- setflag(F_ego_water, water ? true : false);
+ setflag(fEgoTouchedP2, trigger ? true : false);
+ setflag(fEgoWater, water ? true : false);
}
return pass;
@@ -168,35 +167,35 @@ int AgiEngine::check_priority(struct vt_entry *v) {
* new position must be valid according to the sprite positioning
* rules, otherwise the previous position will be kept.
*/
-void AgiEngine::update_position() {
- struct vt_entry *v;
- int x, y, old_x, old_y, border;
+void AgiEngine::updatePosition() {
+ struct VtEntry *v;
+ int x, y, oldX, oldY, border;
- game.vars[V_border_code] = 0;
- game.vars[V_border_touch_ego] = 0;
- game.vars[V_border_touch_obj] = 0;
+ _game.vars[vBorderCode] = 0;
+ _game.vars[vBorderTouchEgo] = 0;
+ _game.vars[vBorderTouchObj] = 0;
- for (v = game.view_table; v < &game.view_table[MAX_VIEWTABLE]; v++) {
+ for (v = _game.viewTable; v < &_game.viewTable[MAX_VIEWTABLE]; v++) {
if ((v->flags & (ANIMATED | UPDATE | DRAWN)) != (ANIMATED | UPDATE | DRAWN)) {
continue;
}
- if (v->step_time_count != 0) {
- if (--v->step_time_count != 0)
+ if (v->stepTimeCount != 0) {
+ if (--v->stepTimeCount != 0)
continue;
}
- v->step_time_count = v->step_time;
+ v->stepTimeCount = v->stepTime;
- x = old_x = v->x_pos;
- y = old_y = v->y_pos;
+ x = oldX = v->xPos;
+ y = oldY = v->yPos;
/* 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 };
- x += v->step_size * dx[v->direction];
- y += v->step_size * dy[v->direction];
+ x += v->stepSize * dx[v->direction];
+ y += v->stepSize * dy[v->direction];
}
/* Now check if it touched the borders */
@@ -213,43 +212,43 @@ void AgiEngine::update_position() {
/* Extra test to walk west clicking the mouse */
x = 0;
border = 4;
- } else if (x + v->x_size > _WIDTH) {
- x = _WIDTH - v->x_size;
+ } else if (x + v->xSize > _WIDTH) {
+ x = _WIDTH - v->xSize;
border = 2;
}
/* Check top/bottom borders. */
- if (y - v->y_size + 1 < 0) {
- y = v->y_size - 1;
+ if (y - v->ySize + 1 < 0) {
+ y = v->ySize - 1;
border = 1;
} else if (y > _HEIGHT - 1) {
y = _HEIGHT - 1;
border = 3;
- } else if ((~v->flags & IGNORE_HORIZON) && y <= game.horizon) {
- debugC(4, kDebugLevelSprites, "y = %d, horizon = %d", y, game.horizon);
- y = game.horizon + 1;
+ } else if ((~v->flags & IGNORE_HORIZON) && y <= _game.horizon) {
+ debugC(4, kDebugLevelSprites, "y = %d, horizon = %d", y, _game.horizon);
+ y = _game.horizon + 1;
border = 1;
}
/* Test new position. rollback if test fails */
- v->x_pos = x;
- v->y_pos = y;
- if (check_collision(v) || !check_priority(v)) {
- v->x_pos = old_x;
- v->y_pos = old_y;
+ v->xPos = x;
+ v->yPos = y;
+ if (checkCollision(v) || !checkPriority(v)) {
+ v->xPos = oldX;
+ v->yPos = oldY;
border = 0;
- fix_position(v->entry);
+ fixPosition(v->entry);
}
if (border != 0) {
- if (is_ego_view(v)) {
- game.vars[V_border_touch_ego] = border;
+ if (isEgoView(v)) {
+ _game.vars[vBorderTouchEgo] = border;
} else {
- game.vars[V_border_code] = v->entry;
- game.vars[V_border_touch_obj] = border;
+ _game.vars[vBorderCode] = v->entry;
+ _game.vars[vBorderTouchObj] = border;
}
if (v->motion == MOTION_MOVE_OBJ) {
- in_destination(v);
+ inDestination(v);
}
}
@@ -266,42 +265,42 @@ void AgiEngine::update_position() {
*
* @param n view table entry number
*/
-void AgiEngine::fix_position(int n) {
- struct vt_entry *v = &game.view_table[n];
+void AgiEngine::fixPosition(int n) {
+ VtEntry *v = &_game.viewTable[n];
int count, dir, size;
- debugC(4, kDebugLevelSprites, "adjusting view table entry #%d (%d,%d)", n, v->x_pos, v->y_pos);
+ debugC(4, kDebugLevelSprites, "adjusting view table entry #%d (%d,%d)", n, v->xPos, v->yPos);
/* test horizon */
- if ((~v->flags & IGNORE_HORIZON) && v->y_pos <= game.horizon)
- v->y_pos = game.horizon + 1;
+ if ((~v->flags & IGNORE_HORIZON) && v->yPos <= _game.horizon)
+ v->yPos = _game.horizon + 1;
dir = 0;
count = size = 1;
- while (!check_position(v) || check_collision(v) || !check_priority(v)) {
+ while (!checkPosition(v) || checkCollision(v) || !checkPriority(v)) {
switch (dir) {
case 0: /* west */
- v->x_pos--;
+ v->xPos--;
if (--count)
continue;
dir = 1;
break;
case 1: /* south */
- v->y_pos++;
+ v->yPos++;
if (--count)
continue;
dir = 2;
size++;
break;
case 2: /* east */
- v->x_pos++;
+ v->xPos++;
if (--count)
continue;
dir = 3;
break;
case 3: /* north */
- v->y_pos--;
+ v->yPos--;
if (--count)
continue;
dir = 0;
@@ -312,7 +311,7 @@ void AgiEngine::fix_position(int n) {
count = size;
}
- debugC(4, kDebugLevelSprites, "view table entry #%d position adjusted to (%d,%d)", n, v->x_pos, v->y_pos);
+ debugC(4, kDebugLevelSprites, "view table entry #%d position adjusted to (%d,%d)", n, v->xPos, v->yPos);
}
} // End of namespace Agi
diff --git a/engines/agi/console.cpp b/engines/agi/console.cpp
index c5cf021025..5f1aaacd96 100644
--- a/engines/agi/console.cpp
+++ b/engines/agi/console.cpp
@@ -94,17 +94,17 @@ bool Console::Cmd_SetObj(int argc, const char **argv) {
}
int p1 = (int)atoi(argv[1]);
int p2 = (int)atoi(argv[2]);
- _vm->object_set_location(p1, p2);
+ _vm->objectSetLocation(p1, p2);
return true;
}
bool Console::Cmd_RunOpcode(int argc, const char **argv) {
- for (int i = 0; logic_names_cmd[i].name; i++) {
- if (!strcmp(argv[1], logic_names_cmd[i].name)) {
+ for (int i = 0; logicNamesCmd[i].name; i++) {
+ if (!strcmp(argv[1], logicNamesCmd[i].name)) {
uint8 p[16];
- if ((argc - 2)!= logic_names_cmd[i].num_args) {
- DebugPrintf("AGI command wants %d arguments\n", logic_names_cmd[i].num_args);
+ if ((argc - 2)!= logicNamesCmd[i].numArgs) {
+ DebugPrintf("AGI command wants %d arguments\n", logicNamesCmd[i].numArgs);
return 0;
}
p[0] = argv[2] ? (char)strtoul(argv[2], NULL, 0) : 0;
@@ -113,9 +113,9 @@ bool Console::Cmd_RunOpcode(int argc, const char **argv) {
p[3] = argv[5] ? (char)strtoul(argv[5], NULL, 0) : 0;
p[4] = argv[6] ? (char)strtoul(argv[6], NULL, 0) : 0;
- debugC(5, kDebugLevelMain, "Opcode: %s %s %s %s", logic_names_cmd[i].name, argv[1], argv[2], argv[3]);
+ debugC(5, kDebugLevelMain, "Opcode: %s %s %s %s", logicNamesCmd[i].name, argv[1], argv[2], argv[3]);
- _vm->execute_agi_command(i, p);
+ _vm->executeAgiCommand(i, p);
return true;
}
@@ -177,8 +177,8 @@ bool Console::Cmd_Vars(int argc, const char **argv) {
bool Console::Cmd_Objs(int argc, const char **argv) {
unsigned int i;
- for (i = 0; i < _vm->game.num_objects; i++) {
- DebugPrintf("%3d]%-24s(%3d)\n", i, _vm->object_name(i), _vm->object_get_location(i));
+ for (i = 0; i < _vm->_game.numObjects; i++) {
+ DebugPrintf("%3d]%-24s(%3d)\n", i, _vm->objectName(i), _vm->objectGetLocation(i));
}
return true;
@@ -243,4 +243,4 @@ bool Console::Cmd_Cont(int argc, const char **argv) {
return true;
}
-} // End of namespace Agi
+} // End of namespace Agi
diff --git a/engines/agi/console.h b/engines/agi/console.h
index e0f108afce..81f18b9b9f 100644
--- a/engines/agi/console.h
+++ b/engines/agi/console.h
@@ -31,7 +31,7 @@ namespace Agi {
class AgiEngine;
-struct agi_debug {
+struct AgiDebug {
int enabled;
int opcodes;
int logic0;
@@ -73,4 +73,4 @@ private:
} // End of namespace Agi
-#endif /* AGI_CONSOLE_H */
+#endif /* AGI_CONSOLE_H */
diff --git a/engines/agi/cycle.cpp b/engines/agi/cycle.cpp
index eb787949ae..ff5b4baa58 100644
--- a/engines/agi/cycle.cpp
+++ b/engines/agi/cycle.cpp
@@ -38,108 +38,108 @@ namespace Agi {
* This function is called when ego enters a new room.
* @param n room number
*/
-void AgiEngine::new_room(int n) {
- struct vt_entry *v;
+void AgiEngine::newRoom(int n) {
+ VtEntry *v;
int i;
debugC(4, kDebugLevelMain, "*** room %d ***", n);
- _sound->stop_sound();
+ _sound->stopSound();
i = 0;
- for (v = game.view_table; v < &game.view_table[MAX_VIEWTABLE]; v++) {
+ for (v = _game.viewTable; v < &_game.viewTable[MAX_VIEWTABLE]; v++) {
v->entry = i++;
v->flags &= ~(ANIMATED | DRAWN);
v->flags |= UPDATE;
- v->step_time = 1;
- v->step_time_count = 1;
- v->cycle_time = 1;
- v->cycle_time_count = 1;
- v->step_size = 1;
+ v->stepTime = 1;
+ v->stepTimeCount = 1;
+ v->cycleTime = 1;
+ v->cycleTimeCount = 1;
+ v->stepSize = 1;
}
agiUnloadResources();
- game.player_control = true;
- game.block.active = false;
- game.horizon = 36;
- game.vars[V_prev_room] = game.vars[V_cur_room];
- game.vars[V_cur_room] = n;
- game.vars[V_border_touch_obj] = 0;
- game.vars[V_border_code] = 0;
- game.vars[V_ego_view_resource] = game.view_table[0].current_view;
+ _game.playerControl = true;
+ _game.block.active = false;
+ _game.horizon = 36;
+ _game.vars[vPrevRoom] = _game.vars[vCurRoom];
+ _game.vars[vCurRoom] = n;
+ _game.vars[vBorderTouchObj] = 0;
+ _game.vars[vBorderCode] = 0;
+ _game.vars[vEgoViewResource] = _game.viewTable[0].currentView;
agiLoadResource(rLOGIC, n);
/* Reposition ego in the new room */
- switch (game.vars[V_border_touch_ego]) {
+ switch (_game.vars[vBorderTouchEgo]) {
case 1:
- game.view_table[0].y_pos = _HEIGHT - 1;
+ _game.viewTable[0].yPos = _HEIGHT - 1;
break;
case 2:
- game.view_table[0].x_pos = 0;
+ _game.viewTable[0].xPos = 0;
break;
case 3:
- game.view_table[0].y_pos = HORIZON + 1;
+ _game.viewTable[0].yPos = HORIZON + 1;
break;
case 4:
- game.view_table[0].x_pos = _WIDTH - game.view_table[0].x_size;
+ _game.viewTable[0].xPos = _WIDTH - _game.viewTable[0].xSize;
break;
}
- game.vars[V_border_touch_ego] = 0;
- setflag(F_new_room_exec, true);
+ _game.vars[vBorderTouchEgo] = 0;
+ setflag(fNewRoomExec, true);
- game.exit_all_logics = true;
+ _game.exitAllLogics = true;
- write_status();
- write_prompt();
+ writeStatus();
+ writePrompt();
}
-void AgiEngine::reset_controllers() {
+void AgiEngine::resetControllers() {
int i;
for (i = 0; i < MAX_DIRS; i++) {
- game.ev_keyp[i].occured = false;
+ _game.evKeyp[i].occured = false;
}
}
-void AgiEngine::interpret_cycle() {
- int old_sound, old_score;
+void AgiEngine::interpretCycle() {
+ int oldSound, oldScore;
- if (game.player_control)
- game.vars[V_ego_dir] = game.view_table[0].direction;
+ if (_game.playerControl)
+ _game.vars[vEgoDir] = _game.viewTable[0].direction;
else
- game.view_table[0].direction = game.vars[V_ego_dir];
-
- check_all_motions();
-
- old_score = game.vars[V_score];
- old_sound = getflag(F_sound_on);
-
- game.exit_all_logics = false;
- while (run_logic(0) == 0 && !game.quit_prog_now) {
- game.vars[V_word_not_found] = 0;
- game.vars[V_border_touch_obj] = 0;
- game.vars[V_border_code] = 0;
- old_score = game.vars[V_score];
- setflag(F_entered_cli, false);
- game.exit_all_logics = false;
- reset_controllers();
+ _game.viewTable[0].direction = _game.vars[vEgoDir];
+
+ checkAllMotions();
+
+ oldScore = _game.vars[vScore];
+ oldSound = getflag(fSoundOn);
+
+ _game.exitAllLogics = false;
+ while (runLogic(0) == 0 && !_game.quitProgNow) {
+ _game.vars[vWordNotFound] = 0;
+ _game.vars[vBorderTouchObj] = 0;
+ _game.vars[vBorderCode] = 0;
+ oldScore = _game.vars[vScore];
+ setflag(fEnteredCli, false);
+ _game.exitAllLogics = false;
+ resetControllers();
}
- reset_controllers();
+ resetControllers();
- game.view_table[0].direction = game.vars[V_ego_dir];
+ _game.viewTable[0].direction = _game.vars[vEgoDir];
- if (game.vars[V_score] != old_score || getflag(F_sound_on) != old_sound)
- write_status();
+ if (_game.vars[vScore] != oldScore || getflag(fSoundOn) != oldSound)
+ writeStatus();
- game.vars[V_border_touch_obj] = 0;
- game.vars[V_border_code] = 0;
- setflag(F_new_room_exec, false);
- setflag(F_restart_game, false);
- setflag(F_restore_just_ran, false);
+ _game.vars[vBorderTouchObj] = 0;
+ _game.vars[vBorderCode] = 0;
+ setflag(fNewRoomExec, false);
+ setflag(fRestartGame, false);
+ setflag(fRestoreJustRan, false);
- if (game.gfx_mode) {
- update_viewtable();
+ if (_game.gfxMode) {
+ updateViewtable();
_gfx->doUpdate();
}
}
@@ -147,101 +147,101 @@ void AgiEngine::interpret_cycle() {
/**
* Update AGI interpreter timer.
*/
-void AgiEngine::update_timer() {
- clock_count++;
- if (clock_count <= TICK_SECONDS)
+void AgiEngine::updateTimer() {
+ _clockCount++;
+ if (_clockCount <= TICK_SECONDS)
return;
- clock_count -= TICK_SECONDS;
+ _clockCount -= TICK_SECONDS;
- if (!game.clock_enabled)
+ if (!_game.clockEnabled)
return;
- setvar(V_seconds, getvar(V_seconds) + 1);
- if (getvar(V_seconds) < 60)
+ setvar(vSeconds, getvar(vSeconds) + 1);
+ if (getvar(vSeconds) < 60)
return;
- setvar(V_seconds, 0);
- setvar(V_minutes, getvar(V_minutes) + 1);
- if (getvar(V_minutes) < 60)
+ setvar(vSeconds, 0);
+ setvar(vMinutes, getvar(vMinutes) + 1);
+ if (getvar(vMinutes) < 60)
return;
- setvar(V_minutes, 0);
- setvar(V_hours, getvar(V_hours) + 1);
- if (getvar(V_hours) < 24)
+ setvar(vMinutes, 0);
+ setvar(vHours, getvar(vHours) + 1);
+ if (getvar(vHours) < 24)
return;
- setvar(V_hours, 0);
- setvar(V_days, getvar(V_days) + 1);
+ setvar(vHours, 0);
+ setvar(vDays, getvar(vDays) + 1);
}
-static int old_mode = -1;
-
-void AgiEngine::new_input_mode(int i) {
- old_mode = game.input_mode;
- game.input_mode = i;
+void AgiEngine::newInputMode(int i) {
+ _oldMode = _game.inputMode;
+ _game.inputMode = i;
}
-void AgiEngine::old_input_mode() {
- game.input_mode = old_mode;
+void AgiEngine::oldInputMode() {
+ _game.inputMode = _oldMode;
}
/* If main_cycle returns false, don't process more events! */
-int AgiEngine::main_cycle() {
+int AgiEngine::mainCycle() {
unsigned int key, kascii;
- struct vt_entry *v = &game.view_table[0];
+ struct VtEntry *v = &_game.viewTable[0];
_gfx->pollTimer(); /* msdos driver -> does nothing */
- update_timer();
+ updateTimer();
- if (game.ver == 0) {
- message_box("Warning: game CRC not listed, assuming AGI version 2.917.");
- game.ver = -1;
+ if (_game.ver == 0) {
+ messageBox("Warning: game CRC not listed, assuming AGI version 2.917.");
+ _game.ver = -1;
}
- key = do_poll_keyboard();
+ key = doPollKeyboard();
/* In AGI Mouse emulation mode we must update the mouse-related
* vars in every interpreter cycle.
*/
- if (opt.agimouse) {
- game.vars[28] = g_mouse.x / 2;
- game.vars[29] = g_mouse.y;
+ if (_opt.agimouse) {
+ _game.vars[28] = g_mouse.x / 2;
+ _game.vars[29] = g_mouse.y;
}
if (key == KEY_PRIORITY) {
- _sprites->erase_both();
+ _sprites->eraseBoth();
_debug.priority = !_debug.priority;
- _picture->show_pic();
- _sprites->blit_both();
- _sprites->commit_both();
+ _picture->showPic();
+ _sprites->blitBoth();
+ _sprites->commitBoth();
key = 0;
}
if (key == KEY_STATUSLN) {
_debug.statusline = !_debug.statusline;
- write_status();
+ writeStatus();
key = 0;
}
/* Click-to-walk mouse interface */
- if (game.player_control && v->flags & ADJ_EGO_XY) {
- v->direction = get_direction(v->x_pos, v->y_pos, v->parm1, v->parm2, v->step_size);
+ if (_game.playerControl && v->flags & ADJ_EGO_XY) {
+ v->direction = getDirection(v->xPos, v->yPos, v->parm1, v->parm2, v->stepSize);
if (v->direction == 0)
- in_destination(v);
+ inDestination(v);
}
kascii = KEY_ASCII(key);
if (kascii)
- setvar(V_key, kascii);
- process_key:
- switch (game.input_mode) {
+ setvar(vKey, kascii);
+
+process_key:
+
+ switch (_game.inputMode) {
case INPUT_NORMAL:
- if (!handle_controller(key)) {
- if (key == 0 || !game.input_enabled)
+ if (!handleController(key)) {
+ if (key == 0 || !_game.inputEnabled)
break;
- handle_keys(key);
+ handleKeys(key);
/* if ESC pressed, activate menu before
* accept.input from the interpreter cycle
@@ -259,129 +259,129 @@ int AgiEngine::main_cycle() {
}
break;
case INPUT_GETSTRING:
- handle_controller(key);
- handle_getstring(key);
- setvar(V_key, 0); /* clear ENTER key */
+ handleController(key);
+ handleGetstring(key);
+ setvar(vKey, 0); /* clear ENTER key */
break;
case INPUT_MENU:
- menu->keyhandler(key);
+ _menu->keyhandler(key);
_gfx->doUpdate();
return false;
case INPUT_NONE:
- handle_controller(key);
+ handleController(key);
if (key)
- game.keypress = key;
+ _game.keypress = key;
break;
}
_gfx->doUpdate();
- if (game.msg_box_ticks > 0)
- game.msg_box_ticks--;
+ if (_game.msgBoxTicks > 0)
+ _game.msgBoxTicks--;
return true;
}
-int AgiEngine::play_game() {
- int ec = err_OK;
+int AgiEngine::playGame() {
+ int ec = errOK;
debugC(2, kDebugLevelMain, "initializing...");
- debugC(2, kDebugLevelMain, "game.ver = 0x%x", game.ver);
+ debugC(2, kDebugLevelMain, "game.ver = 0x%x", _game.ver);
- _sound->stop_sound();
+ _sound->stopSound();
_gfx->clearScreen(0);
- game.horizon = HORIZON;
- game.player_control = false;
+ _game.horizon = HORIZON;
+ _game.playerControl = false;
- setflag(F_logic_zero_firsttime, true); /* not in 2.917 */
- setflag(F_new_room_exec, true); /* needed for MUMG and SQ2! */
- setflag(F_sound_on, true); /* enable sound */
- setvar(V_time_delay, 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.gfx_mode = true;
- game.quit_prog_now = false;
- game.clock_enabled = true;
- game.line_user_input = 22;
+ _game.gfxMode = true;
+ _game.quitProgNow = false;
+ _game.clockEnabled = true;
+ _game.lineUserInput = 22;
- if (opt.agimouse)
+ if (_opt.agimouse)
report("Using AGI Mouse 1.0 protocol\n");
report("Running AGI script.\n");
- setflag(F_entered_cli, false);
- setflag(F_said_accepted_input, false);
- game.vars[V_word_not_found] = 0;
- game.vars[V_key] = 0;
+ setflag(fEnteredCli, false);
+ setflag(fSaidAcceptedInput, false);
+ _game.vars[vWordNotFound] = 0;
+ _game.vars[vKey] = 0;
debugC(2, kDebugLevelMain, "Entering main loop");
do {
- if (!main_cycle())
+ if (!mainCycle())
continue;
- if (getvar(V_time_delay) == 0 || (1 + clock_count) % getvar(V_time_delay) == 0) {
- if (!game.has_prompt && game.input_mode == INPUT_NORMAL) {
- write_prompt();
- game.has_prompt = 1;
- } else if (game.has_prompt && game.input_mode == INPUT_NONE) {
- write_prompt();
- game.has_prompt = 0;
+ if (getvar(vTimeDelay) == 0 || (1 + _clockCount) % getvar(vTimeDelay) == 0) {
+ if (!_game.hasPrompt && _game.inputMode == INPUT_NORMAL) {
+ writePrompt();
+ _game.hasPrompt = 1;
+ } else if (_game.hasPrompt && _game.inputMode == INPUT_NONE) {
+ writePrompt();
+ _game.hasPrompt = 0;
}
- interpret_cycle();
+ interpretCycle();
- setflag(F_entered_cli, false);
- setflag(F_said_accepted_input, false);
- game.vars[V_word_not_found] = 0;
- game.vars[V_key] = 0;
+ setflag(fEnteredCli, false);
+ setflag(fSaidAcceptedInput, false);
+ _game.vars[vWordNotFound] = 0;
+ _game.vars[vKey] = 0;
}
- if (game.quit_prog_now == 0xff)
- ec = err_RestartGame;
+ if (_game.quitProgNow == 0xff)
+ ec = errRestartGame;
- } while (game.quit_prog_now == 0);
+ } while (_game.quitProgNow == 0);
- _sound->stop_sound();
+ _sound->stopSound();
return ec;
}
-int AgiEngine::run_game() {
- int i, ec = err_OK;
+int AgiEngine::runGame() {
+ int i, ec = errOK;
for (i = 0; i < MAX_DIRS; i++)
- memset(&game.ev_keyp[i], 0, sizeof(struct agi_event));
+ memset(&_game.evKeyp[i], 0, sizeof(struct AgiEvent));
/* Execute the game */
do {
debugC(2, kDebugLevelMain, "game loop");
- debugC(2, kDebugLevelMain, "game.ver = 0x%x", game.ver);
+ debugC(2, kDebugLevelMain, "game.ver = 0x%x", _game.ver);
- if (agiInit() != err_OK)
+ if (agiInit() != errOK)
break;
- if (ec == err_RestartGame)
- setflag(F_restart_game, true);
-
- setvar(V_computer, 0); /* IBM PC (4 = Atari ST) */
- setvar(V_soundgen, 1); /* IBM PC SOUND */
- setvar(V_monitor, 0x3); /* EGA monitor */
- setvar(V_max_input_chars, 38);
- game.input_mode = INPUT_NONE;
- game.input_enabled = 0;
- game.has_prompt = 0;
-
- game.state = STATE_RUNNING;
- ec = play_game();
- game.state = STATE_LOADED;
+ if (ec == errRestartGame)
+ setflag(fRestartGame, true);
+
+ setvar(vComputer, 0); /* IBM PC (4 = Atari ST) */
+ setvar(vSoundgen, 1); /* IBM PC SOUND */
+ setvar(vMonitor, 0x3); /* EGA monitor */
+ setvar(vMaxInputChars, 38);
+ _game.inputMode = INPUT_NONE;
+ _game.inputEnabled = 0;
+ _game.hasPrompt = 0;
+
+ _game.state = STATE_RUNNING;
+ ec = playGame();
+ _game.state = STATE_LOADED;
agiDeinit();
- } while (ec == err_RestartGame);
+ } while (ec == errRestartGame);
- delete menu;
- menu = 0;
+ delete _menu;
+ _menu = NULL;
- release_image_stack();
+ releaseImageStack();
return ec;
}
-} // End of namespace Agi
+} // End of namespace Agi
diff --git a/engines/agi/font.h b/engines/agi/font.h
index cc28a876db..f954e3ba3d 100644
--- a/engines/agi/font.h
+++ b/engines/agi/font.h
@@ -29,7 +29,7 @@
namespace Agi {
/* 8x8 font patterns */
-static const uint8 cur_font[] = {
+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 */
@@ -290,4 +290,4 @@ static const uint8 cur_font[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x7E, 0x00
};
-} // End of namespace Agi
+} // End of namespace Agi
diff --git a/engines/agi/global.cpp b/engines/agi/global.cpp
index 7c9d0c849c..8c9d33e79c 100644
--- a/engines/agi/global.cpp
+++ b/engines/agi/global.cpp
@@ -29,14 +29,14 @@
namespace Agi {
int AgiEngine::getflag(int n) {
- uint8 *set = (uint8 *) &game.flags;
+ uint8 *set = (uint8 *)&_game.flags;
set += n >> 3;
return (*set & (1 << (n & 0x07))) != 0;
}
void AgiEngine::setflag(int n, int v) {
- uint8 *set = (uint8 *) &game.flags;
+ uint8 *set = (uint8 *)&_game.flags;
set += n >> 3;
if (v)
@@ -46,25 +46,25 @@ void AgiEngine::setflag(int n, int v) {
}
void AgiEngine::flipflag(int n) {
- uint8 *set = (uint8 *) & game.flags;
+ uint8 *set = (uint8 *)&_game.flags;
set += n >> 3;
*set ^= 1 << (n & 0x07); /* flip bit */
}
void AgiEngine::setvar(int var, int val) {
- game.vars[var] = val;
+ _game.vars[var] = val;
}
int AgiEngine::getvar(int var) {
- return game.vars[var];
+ return _game.vars[var];
}
void AgiEngine::decrypt(uint8 *mem, int len) {
const uint8 *key;
int i;
- key = opt.agdsMode ? (const uint8 *)CRYPT_KEY_AGDS
+ key = _opt.agdsMode ? (const uint8 *)CRYPT_KEY_AGDS
: (const uint8 *)CRYPT_KEY_SIERRA;
for (i = 0; i < len; i++)
diff --git a/engines/agi/graphics.cpp b/engines/agi/graphics.cpp
index 29c1639d4a..a5f8425874 100644
--- a/engines/agi/graphics.cpp
+++ b/engines/agi/graphics.cpp
@@ -46,7 +46,7 @@ namespace Agi {
* This array contains the 6-bit RGB values of the EGA palette exported
* to the console drivers.
*/
-uint8 ega_palette[16 * 3] = {
+uint8 egaPalette[16 * 3] = {
0x00, 0x00, 0x00,
0x00, 0x00, 0x2a,
0x00, 0x2a, 0x00,
@@ -68,7 +68,7 @@ uint8 ega_palette[16 * 3] = {
/**
* 16 color amiga-ish palette.
*/
-uint8 new_palette[16 * 3] = {
+uint8 newPalette[16 * 3] = {
0x00, 0x00, 0x00,
0x00, 0x00, 0x3f,
0x00, 0x2A, 0x00,
@@ -87,7 +87,7 @@ uint8 new_palette[16 * 3] = {
0x3F, 0x3F, 0x3F
};
-static uint16 cga_map[16] = {
+static uint16 cgaMap[16] = {
0x0000, /* 0 - black */
0x0d00, /* 1 - blue */
0x0b00, /* 2 - green */
@@ -106,12 +106,12 @@ static uint16 cga_map[16] = {
0x0f0f /* 15 - white */
};
-struct update_block {
+struct UpdateBlock {
int x1, y1;
int x2, y2;
};
-static struct update_block update = {
+static struct UpdateBlock update = {
MAX_INT, MAX_INT, 0, 0
};
@@ -134,20 +134,20 @@ static struct update_block update = {
void GfxMgr::shakeStart() {
int i;
- if ((shake_h = (uint8 *)malloc(GFX_WIDTH * SHAKE_MAG)) == NULL)
+ if ((_shakeH = (uint8 *)malloc(GFX_WIDTH * SHAKE_MAG)) == NULL)
return;
- if ((shake_v = (uint8 *)malloc(SHAKE_MAG * (GFX_HEIGHT - SHAKE_MAG))) == NULL) {
- free(shake_h);
+ if ((_shakeV = (uint8 *)malloc(SHAKE_MAG * (GFX_HEIGHT - SHAKE_MAG))) == NULL) {
+ free(_shakeH);
return;
}
for (i = 0; i < GFX_HEIGHT - SHAKE_MAG; i++) {
- memcpy(shake_v + i * SHAKE_MAG, agi_screen + i * GFX_WIDTH, SHAKE_MAG);
+ memcpy(_shakeV + i * SHAKE_MAG, _agiScreen + i * GFX_WIDTH, SHAKE_MAG);
}
for (i = 0; i < SHAKE_MAG; i++) {
- memcpy(shake_h + i * GFX_WIDTH, agi_screen + i * GFX_WIDTH, GFX_WIDTH);
+ memcpy(_shakeH + i * GFX_WIDTH, _agiScreen + i * GFX_WIDTH, GFX_WIDTH);
}
}
@@ -156,14 +156,14 @@ void GfxMgr::shakeScreen(int n) {
if (n == 0) {
for (i = 0; i < (GFX_HEIGHT - SHAKE_MAG); i++) {
- memmove(&agi_screen[GFX_WIDTH * i],
- &agi_screen[GFX_WIDTH * (i + SHAKE_MAG) + SHAKE_MAG],
+ memmove(&_agiScreen[GFX_WIDTH * i],
+ &_agiScreen[GFX_WIDTH * (i + SHAKE_MAG) + SHAKE_MAG],
GFX_WIDTH - SHAKE_MAG);
}
} else {
for (i = GFX_HEIGHT - SHAKE_MAG - 1; i >= 0; i--) {
- memmove(&agi_screen[GFX_WIDTH * (i + SHAKE_MAG) + SHAKE_MAG],
- &agi_screen[GFX_WIDTH * i], GFX_WIDTH - SHAKE_MAG);
+ memmove(&_agiScreen[GFX_WIDTH * (i + SHAKE_MAG) + SHAKE_MAG],
+ &_agiScreen[GFX_WIDTH * i], GFX_WIDTH - SHAKE_MAG);
}
}
}
@@ -172,30 +172,30 @@ void GfxMgr::shakeEnd() {
int i;
for (i = 0; i < GFX_HEIGHT - SHAKE_MAG; i++) {
- memcpy(agi_screen + i * GFX_WIDTH, shake_v + i * SHAKE_MAG, SHAKE_MAG);
+ memcpy(_agiScreen + i * GFX_WIDTH, _shakeV + i * SHAKE_MAG, SHAKE_MAG);
}
for (i = 0; i < SHAKE_MAG; i++) {
- memcpy(agi_screen + i * GFX_WIDTH, shake_h + i * GFX_WIDTH, GFX_WIDTH);
+ memcpy(_agiScreen + i * GFX_WIDTH, _shakeH + i * GFX_WIDTH, GFX_WIDTH);
}
flushBlock(0, 0, GFX_WIDTH - 1, GFX_HEIGHT - 1);
- free(shake_v);
- free(shake_h);
+ free(_shakeV);
+ free(_shakeH);
}
void GfxMgr::putTextCharacter(int l, int x, int y, unsigned int c, int fg, int bg, bool checkerboard) {
int x1, y1, xx, yy, cc;
const uint8 *p;
- p = Agi::cur_font + ((unsigned int)c * CHAR_LINES);
+ p = Agi::curFont + ((unsigned int)c * CHAR_LINES);
for (y1 = 0; y1 < CHAR_LINES; y1++) {
for (x1 = 0; x1 < CHAR_COLS; x1++) {
xx = x + x1;
yy = y + y1;
cc = (*p & (1 << (7 - x1))) ? fg : bg;
- agi_screen[xx + yy * GFX_WIDTH] = cc;
+ _agiScreen[xx + yy * GFX_WIDTH] = cc;
}
p++;
@@ -207,7 +207,7 @@ void GfxMgr::putTextCharacter(int l, int x, int y, unsigned int c, int fg, int b
if (checkerboard) {
for (yy = y; yy < y + CHAR_LINES; yy++)
for (xx = x + (~yy & 1); xx < x + CHAR_COLS; xx += 2)
- agi_screen[xx + yy * GFX_WIDTH] = 15;
+ _agiScreen[xx + yy * GFX_WIDTH] = 15;
}
/* FIXME: we don't want this when we're writing on the
@@ -231,7 +231,7 @@ void GfxMgr::drawRectangle(int x1, int y1, int x2, int y2, int c) {
w = x2 - x1 + 1;
h = y2 - y1 + 1;
- p0 = &agi_screen[x1 + y1 * GFX_WIDTH];
+ p0 = &_agiScreen[x1 + y1 * GFX_WIDTH];
for (y = 0; y < h; y++) {
memset(p0, c, w);
p0 += GFX_WIDTH;
@@ -244,17 +244,17 @@ void GfxMgr::drawFrame(int x1, int y1, int x2, int y2, int c1, int c2) {
/* top line */
w = x2 - x1 + 1;
- p0 = &agi_screen[x1 + y1 * GFX_WIDTH];
+ p0 = &_agiScreen[x1 + y1 * GFX_WIDTH];
memset(p0, c1, w);
/* bottom line */
- p0 = &agi_screen[x1 + y2 * GFX_WIDTH];
+ p0 = &_agiScreen[x1 + y2 * GFX_WIDTH];
memset(p0, c2, w);
/* side lines */
for (y = y1; y <= y2; y++) {
- agi_screen[x1 + y * GFX_WIDTH] = c1;
- agi_screen[x2 + y * GFX_WIDTH] = c2;
+ _agiScreen[x1 + y * GFX_WIDTH] = c1;
+ _agiScreen[x2 + y * GFX_WIDTH] = c2;
}
}
@@ -357,8 +357,8 @@ void GfxMgr::initPalette(uint8 *p) {
int i;
for (i = 0; i < 48; i++) {
- palette[i] = p[i];
- palette[i + 48] = (p[i] + 0x30) >> 2;
+ _palette[i] = p[i];
+ _palette[i + 48] = (p[i] + 0x30) >> 2;
}
}
@@ -367,9 +367,9 @@ void GfxMgr::gfxSetPalette() {
byte pal[32 * 4];
for (i = 0; i < 32; i++) {
- pal[i * 4 + 0] = palette[i * 3 + 0] << 2;
- pal[i * 4 + 1] = palette[i * 3 + 1] << 2;
- pal[i * 4 + 2] = palette[i * 3 + 2] << 2;
+ pal[i * 4 + 0] = _palette[i * 3 + 0] << 2;
+ pal[i * 4 + 1] = _palette[i * 3 + 1] << 2;
+ pal[i * 4 + 2] = _palette[i * 3 + 2] << 2;
pal[i * 4 + 3] = 0;
}
g_system->setPalette(pal, 0, 32);
@@ -386,7 +386,7 @@ void GfxMgr::gfxPutBlock(int x1, int y1, int x2, int y2) {
if (y2 >= GFX_HEIGHT)
y2 = GFX_HEIGHT - 1;
- g_system->copyRectToScreen(screen + y1 * 320 + x1, 320, x1, y1, x2 - x1 + 1, y2 - y1 + 1);
+ g_system->copyRectToScreen(_screen + y1 * 320 + x1, 320, x1, y1, x2 - x1 + 1, y2 - y1 + 1);
}
static const byte mouseCursorArrow[] = {
@@ -406,13 +406,13 @@ static const byte mouseCursorArrow[] = {
* @see deinit_video()
*/
int GfxMgr::initVideo() {
- if (_vm->opt.renderMode == Common::kRenderEGA)
- initPalette(ega_palette);
+ if (_vm->_opt.renderMode == Common::kRenderEGA)
+ initPalette(egaPalette);
else
- initPalette(new_palette);
+ initPalette(newPalette);
- if ((agi_screen = (uint8 *)calloc(GFX_WIDTH, GFX_HEIGHT)) == NULL)
- return err_NotEnoughMemory;
+ if ((_agiScreen = (uint8 *)calloc(GFX_WIDTH, GFX_HEIGHT)) == NULL)
+ return errNotEnoughMemory;
gfxSetPalette();
@@ -434,7 +434,7 @@ int GfxMgr::initVideo() {
}
CursorMan.replaceCursor(mouseCursor, 16, 16, 1, 1);
- return err_OK;
+ return errOK;
}
/**
@@ -443,22 +443,22 @@ int GfxMgr::initVideo() {
* @see init_video()
*/
int GfxMgr::deinitVideo() {
- free(agi_screen);
+ free(_agiScreen);
- return err_OK;
+ return errOK;
}
int GfxMgr::initMachine() {
- screen = (unsigned char *)malloc(320 * 200);
- _vm->clock_count = 0;
+ _screen = (unsigned char *)malloc(320 * 200);
+ _vm->_clockCount = 0;
- return err_OK;
+ return errOK;
}
int GfxMgr::deinitMachine() {
- free(screen);
+ free(_screen);
- return err_OK;
+ return errOK;
}
/**
@@ -472,19 +472,19 @@ int GfxMgr::deinitMachine() {
* @param p pointer to the row start in the AGI screen
*/
void GfxMgr::putPixelsA(int x, int y, int n, uint8 *p) {
- if (_vm->opt.renderMode == Common::kRenderCGA) {
+ if (_vm->_opt.renderMode == Common::kRenderCGA) {
for (x *= 2; n--; p++, x += 2) {
- register uint16 q = (cga_map[(*p & 0xf0) >> 4] << 4) | cga_map[*p & 0x0f];
+ register uint16 q = (cgaMap[(*p & 0xf0) >> 4] << 4) | cgaMap[*p & 0x0f];
if (_vm->_debug.priority)
q >>= 4;
- *(uint16 *)&agi_screen[x + y * GFX_WIDTH] = q & 0x0f0f;
+ *(uint16 *)&_agiScreen[x + y * GFX_WIDTH] = q & 0x0f0f;
}
} else {
for (x *= 2; n--; p++, x += 2) {
register uint16 q = ((uint16) * p << 8) | *p;
if (_vm->_debug.priority)
q >>= 4;
- *(uint16 *)&agi_screen[x + y * GFX_WIDTH] = q & 0x0f0f;
+ *(uint16 *)&_agiScreen[x + y * GFX_WIDTH] = q & 0x0f0f;
}
}
}
@@ -547,11 +547,11 @@ void GfxMgr::flushBlock(int x1, int y1, int x2, int y2) {
scheduleUpdate(x1, y1, x2, y2);
- p0 = &agi_screen[x1 + y1 * GFX_WIDTH];
+ p0 = &_agiScreen[x1 + y1 * GFX_WIDTH];
w = x2 - x1 + 1;
for (y = y1; y <= y2; y++) {
- memcpy(screen + 320 * y + x1, p0, w);
+ memcpy(_screen + 320 * y + x1, p0, w);
p0 += GFX_WIDTH;
}
}
@@ -589,7 +589,7 @@ void GfxMgr::flushScreen() {
* @param c color to clear the screen
*/
void GfxMgr::clearScreen(int c) {
- memset(agi_screen, c, GFX_WIDTH * GFX_HEIGHT);
+ memset(_agiScreen, c, GFX_WIDTH * GFX_HEIGHT);
flushScreen();
}
@@ -600,7 +600,7 @@ void GfxMgr::saveBlock(int x1, int y1, int x2, int y2, uint8 *b) {
uint8 *p0;
int w, h;
- p0 = &agi_screen[x1 + GFX_WIDTH * y1];
+ p0 = &_agiScreen[x1 + GFX_WIDTH * y1];
w = x2 - x1 + 1;
h = y2 - y1 + 1;
while (h--) {
@@ -617,7 +617,7 @@ void GfxMgr::restoreBlock(int x1, int y1, int x2, int y2, uint8 *b) {
uint8 *p0;
int w, h;
- p0 = &agi_screen[x1 + GFX_WIDTH * y1];
+ p0 = &_agiScreen[x1 + GFX_WIDTH * y1];
w = x2 - x1 + 1;
h = y2 - y1 + 1;
while (h--) {
diff --git a/engines/agi/graphics.h b/engines/agi/graphics.h
index 999a2e6f98..1fdfbf7d97 100644
--- a/engines/agi/graphics.h
+++ b/engines/agi/graphics.h
@@ -40,17 +40,17 @@ class GfxMgr {
private:
AgiEngine *_vm;
- uint8 palette[32 * 3];
- uint8 *agi_screen;
- unsigned char *screen;
+ uint8 _palette[32 * 3];
+ uint8 *_agiScreen;
+ unsigned char *_screen;
- uint8 *shake_h, *shake_v;
+ uint8 *_shakeH, *_shakeV;
public:
GfxMgr(AgiEngine *vm) {
_vm = vm;
- shake_h = NULL;
- shake_v = NULL;
+ _shakeH = NULL;
+ _shakeV = NULL;
}
void gfxPutBlock(int x1, int y1, int x2, int y2);
@@ -96,4 +96,4 @@ public:
} // End of namespace Agi
-#endif /* AGI_GRAPHICS_H */
+#endif /* AGI_GRAPHICS_H */
diff --git a/engines/agi/id.cpp b/engines/agi/id.cpp
index a35d28855c..2875974faf 100644
--- a/engines/agi/id.cpp
+++ b/engines/agi/id.cpp
@@ -29,15 +29,15 @@
namespace Agi {
-int AgiEngine::v2id_game() {
+int AgiEngine::v2IdGame() {
int ver;
- ver = this->_gameDescription->version;
- game.ver = ver;
- debugC(2, kDebugLevelMain, "game.ver = 0x%x", game.ver);
+ ver = _gameDescription->version;
+ _game.ver = ver;
+ debugC(2, kDebugLevelMain, "game.ver = 0x%x", _game.ver);
agiSetRelease(ver);
- return setup_v2_game(ver, 0);
+ return setupV2Game(ver, 0);
}
/*
@@ -48,22 +48,22 @@ int AgiEngine::v2id_game() {
* 0x0149
*/
-int AgiEngine::v3id_game() {
+int AgiEngine::v3IdGame() {
int ver;
- ver = this->_gameDescription->version;
- game.ver = ver;
- debugC(2, kDebugLevelMain, "game.ver = 0x%x", game.ver);
+ ver = _gameDescription->version;
+ _game.ver = ver;
+ debugC(2, kDebugLevelMain, "game.ver = 0x%x", _game.ver);
agiSetRelease(ver);
- return setup_v3_game(ver, 0);
+ return setupV3Game(ver, 0);
}
/**
*
*/
-int AgiEngine::setup_v2_game(int ver, uint32 crc) {
- int ec = err_OK;
+int AgiEngine::setupV2Game(int ver, uint32 crc) {
+ int ec = errOK;
if (ver == 0) {
report("Unknown v2 Sierra game: %08x\n\n", crc);
@@ -73,26 +73,26 @@ int AgiEngine::setup_v2_game(int ver, uint32 crc) {
/* setup the differences in the opcodes and other bits in the
* AGI v2 specs
*/
- if (opt.emuversion)
- agiSetRelease(ver = opt.emuversion);
+ if (_opt.emuversion)
+ agiSetRelease(ver = _opt.emuversion);
// Should this go above the previous lines, so we can force emulation versions
// even for AGDS games? -- dsymonds
- if (opt.agdsMode)
+ if (_opt.agdsMode)
agiSetRelease(ver = 0x2440); /* ALL AGDS games built for 2.440 */
report("Seting up for version 0x%04X\n", ver);
// 'quit' takes 0 args for 2.089
if (ver == 0x2089)
- logic_names_cmd[0x86].num_args = 0;
+ logicNamesCmd[0x86].numArgs = 0;
// 'print.at' and 'print.at.v' take 3 args before 2.272
// This is documented in the specs as only < 2.440, but it seems
// that KQ3 (2.272) needs a 'print.at' taking 4 args.
if (ver < 0x2272) {
- logic_names_cmd[0x97].num_args = 3;
- logic_names_cmd[0x98].num_args = 3;
+ logicNamesCmd[0x97].numArgs = 3;
+ logicNamesCmd[0x98].numArgs = 3;
}
return ec;
@@ -101,16 +101,16 @@ int AgiEngine::setup_v2_game(int ver, uint32 crc) {
/**
*
*/
-int AgiEngine::setup_v3_game(int ver, uint32 crc) {
- int ec = err_OK;
+int AgiEngine::setupV3Game(int ver, uint32 crc) {
+ int ec = errOK;
if (ver == 0) {
report("Unknown v3 Sierra game: %08x\n\n", crc);
agiSetRelease(ver = 0x3149);
}
- if (opt.emuversion)
- agiSetRelease(ver = opt.emuversion);
+ if (_opt.emuversion)
+ agiSetRelease(ver = _opt.emuversion);
report("Seting up for version 0x%04X\n", ver);
@@ -118,11 +118,11 @@ int AgiEngine::setup_v3_game(int ver, uint32 crc) {
// 'unknown173' also takes 1 arg for 3.002.068, not 0 args.
// Is this actually used anywhere? -- dsymonds
if (ver == 0x3086) {
- logic_names_cmd[0xb0].num_args = 1;
- logic_names_cmd[0xad].num_args = 1;
+ logicNamesCmd[0xb0].numArgs = 1;
+ logicNamesCmd[0xad].numArgs = 1;
}
return ec;
}
-} // End of namespace Agi
+} // End of namespace Agi
diff --git a/engines/agi/inv.cpp b/engines/agi/inv.cpp
index 56f1558734..c9c6772dc5 100644
--- a/engines/agi/inv.cpp
+++ b/engines/agi/inv.cpp
@@ -54,7 +54,7 @@ namespace Agi {
#define SELECT_MSG "Press ENTER to select, ESC to cancel"
void AgiEngine::printItem(int n, int fg, int bg) {
- print_text(object_name(intobj[n]), 0, n % 2 ? 39 - strlen(object_name(intobj[n])) : 1,
+ printText(objectName(_intobj[n]), 0, n % 2 ? 39 - strlen(objectName(_intobj[n])) : 1,
(n / 2) + 2, 40, fg, bg);
}
@@ -75,17 +75,17 @@ int AgiEngine::findItem() {
int AgiEngine::showItems() {
unsigned int x, i;
- for (x = i = 0; x < game.num_objects; x++) {
- if (object_get_location(x) == EGO_OWNED) {
+ for (x = i = 0; x < _game.numObjects; x++) {
+ if (objectGetLocation(x) == EGO_OWNED) {
/* add object to our list! */
- intobj[i] = x;
+ _intobj[i] = x;
printItem(i, STATUS_FG, STATUS_BG);
i++;
}
}
if (i == 0) {
- print_text(NOTHING_MSG, 0, NOTHING_X, NOTHING_Y, 40, STATUS_FG, STATUS_BG);
+ printText(NOTHING_MSG, 0, NOTHING_X, NOTHING_Y, 40, STATUS_FG, STATUS_BG);
}
return i;
@@ -98,12 +98,12 @@ void AgiEngine::selectItems(int n) {
if (n > 0)
printItem(fsel, STATUS_BG, STATUS_FG);
- switch (wait_any_key()) {
+ switch (waitAnyKey()) {
case KEY_ENTER:
- setvar(V_sel_item, intobj[fsel]);
+ setvar(vSelItem, _intobj[fsel]);
goto exit_select;
case KEY_ESCAPE:
- setvar(V_sel_item, 0xff);
+ setvar(vSelItem, 0xff);
goto exit_select;
case KEY_UP:
if (fsel >= 2)
@@ -124,7 +124,7 @@ void AgiEngine::selectItems(int n) {
case BUTTON_LEFT:{
int i = findItem();
if (i >= 0 && i < n) {
- setvar(V_sel_item, intobj[fsel = i]);
+ setvar(vSelItem, _intobj[fsel = i]);
debugC(6, kDebugLevelInventory, "item found: %d", fsel);
showItems();
printItem(fsel, STATUS_BG, STATUS_FG);
@@ -153,29 +153,29 @@ exit_select:
* Display inventory items.
*/
void AgiEngine::inventory() {
- int old_fg, old_bg;
+ int oldFg, oldBg;
int n;
/* screen is white with black text */
- old_fg = game.color_fg;
- old_bg = game.color_bg;
- game.color_fg = 0;
- game.color_bg = 15;
- _gfx->clearScreen(game.color_bg);
+ oldFg = _game.colorFg;
+ oldBg = _game.colorBg;
+ _game.colorFg = 0;
+ _game.colorBg = 15;
+ _gfx->clearScreen(_game.colorBg);
- print_text(YOUHAVE_MSG, 0, YOUHAVE_X, YOUHAVE_Y, 40, STATUS_FG, STATUS_BG);
+ printText(YOUHAVE_MSG, 0, YOUHAVE_X, YOUHAVE_Y, 40, STATUS_FG, STATUS_BG);
/* FIXME: doesn't check if objects overflow off screen... */
- intobj = (uint8 *) malloc(4 + game.num_objects);
- memset(intobj, 0, (4 + game.num_objects));
+ _intobj = (uint8 *)malloc(4 + _game.numObjects);
+ memset(_intobj, 0, (4 + _game.numObjects));
n = showItems();
- if (getflag(F_status_selects_items)) {
- print_text(SELECT_MSG, 0, SELECT_X, SELECT_Y, 40, STATUS_FG, STATUS_BG);
+ if (getflag(fStatusSelectsItems)) {
+ printText(SELECT_MSG, 0, SELECT_X, SELECT_Y, 40, STATUS_FG, STATUS_BG);
} else {
- print_text(ANY_KEY_MSG, 0, ANY_KEY_X, ANY_KEY_Y, 40, STATUS_FG, STATUS_BG);
+ printText(ANY_KEY_MSG, 0, ANY_KEY_X, ANY_KEY_Y, 40, STATUS_FG, STATUS_BG);
}
_gfx->flushScreen();
@@ -185,21 +185,21 @@ void AgiEngine::inventory() {
* var 25 = 0xff.
*/
- if (getflag(F_status_selects_items))
+ if (getflag(fStatusSelectsItems))
selectItems(n);
- free(intobj);
+ free(_intobj);
- if (!getflag(F_status_selects_items))
- wait_any_key();
+ if (!getflag(fStatusSelectsItems))
+ waitAnyKey();
_gfx->clearScreen(0);
- write_status();
- _picture->show_pic();
- game.color_fg = old_fg;
- game.color_bg = old_bg;
- game.has_prompt = 0;
- flush_lines(game.line_user_input, 24);
+ writeStatus();
+ _picture->showPic();
+ _game.colorFg = oldFg;
+ _game.colorBg = oldBg;
+ _game.hasPrompt = 0;
+ flushLines(_game.lineUserInput, 24);
}
-} // End of namespace Agi
+} // End of namespace Agi
diff --git a/engines/agi/keyboard.cpp b/engines/agi/keyboard.cpp
index f159db3d36..198e777e2a 100644
--- a/engines/agi/keyboard.cpp
+++ b/engines/agi/keyboard.cpp
@@ -35,7 +35,7 @@ namespace Agi {
/*
* IBM-PC keyboard scancodes
*/
-uint8 scancode_table[26] = {
+uint8 scancodeTable[26] = {
30, /* A */
48, /* B */
46, /* C */
@@ -64,21 +64,21 @@ uint8 scancode_table[26] = {
44 /* Z */
};
-void AgiEngine::init_words() {
- game.num_ego_words = 0;
+void AgiEngine::initWords() {
+ _game.numEgoWords = 0;
}
-void AgiEngine::clean_input() {
- while (game.num_ego_words)
- free(game.ego_words[--game.num_ego_words].word);
+void AgiEngine::cleanInput() {
+ while (_game.numEgoWords)
+ free(_game.egoWords[--_game.numEgoWords].word);
}
-void AgiEngine::get_string(int x, int y, int len, int str) {
- new_input_mode(INPUT_GETSTRING);
- stringdata.x = x;
- stringdata.y = y;
- stringdata.len = len;
- stringdata.str = str;
+void AgiEngine::getString(int x, int y, int len, int str) {
+ newInputMode(INPUT_GETSTRING);
+ _stringdata.x = x;
+ _stringdata.y = y;
+ _stringdata.len = len;
+ _stringdata.str = str;
}
/**
@@ -87,7 +87,7 @@ void AgiEngine::get_string(int x, int y, int len, int str) {
* It handles console keys and insulates AGI from the console. In the main
* loop, handle_keys() handles keyboard input and ego movement.
*/
-int AgiEngine::do_poll_keyboard() {
+int AgiEngine::doPollKeyboard() {
int key = 0;
/* If a key is ready, rip it */
@@ -99,8 +99,8 @@ int AgiEngine::do_poll_keyboard() {
return key;
}
-int AgiEngine::handle_controller(int key) {
- struct vt_entry *v = &game.view_table[0];
+int AgiEngine::handleController(int key) {
+ struct VtEntry *v = &_game.viewTable[0];
int i;
/* The Black Cauldron needs KEY_ESCAPE to use menus */
@@ -110,22 +110,22 @@ int AgiEngine::handle_controller(int key) {
debugC(3, kDebugLevelInput, "key = %04x", key);
for (i = 0; i < MAX_DIRS; i++) {
- if (game.ev_keyp[i].data == key) {
+ if (_game.evKeyp[i].data == key) {
debugC(3, kDebugLevelInput, "event %d: key press", i);
- game.ev_keyp[i].occured = true;
+ _game.evKeyp[i].occured = true;
report("event AC:%i occured\n", i);
return true;
}
}
if (key == BUTTON_LEFT) {
- if (getflag(F_menus_work) && g_mouse.y <= CHAR_LINES) {
- new_input_mode(INPUT_MENU);
+ if (getflag(fMenusWork) && g_mouse.y <= CHAR_LINES) {
+ newInputMode(INPUT_MENU);
return true;
}
}
- if (game.player_control) {
+ if (_game.playerControl) {
int d = 0;
if (!KEY_ASCII(key)) {
@@ -158,16 +158,16 @@ int AgiEngine::handle_controller(int key) {
}
if (key == BUTTON_LEFT &&
- (int)g_mouse.y >= game.line_user_input * CHAR_LINES &&
- (int)g_mouse.y <= (game.line_user_input + 1) * CHAR_LINES) {
+ (int)g_mouse.y >= _game.lineUserInput * CHAR_LINES &&
+ (int)g_mouse.y <= (_game.lineUserInput + 1) * CHAR_LINES) {
if (predictiveDialog()) {
- strcpy((char *)game.input_buffer, _predictiveResult);
- handle_keys(KEY_ENTER);
+ strcpy((char *)_game.inputBuffer, _predictiveResult);
+ handleKeys(KEY_ENTER);
}
return true;
}
- if (!opt.agimouse) {
+ if (!_opt.agimouse) {
/* Handle mouse button events */
if (key == BUTTON_LEFT) {
v->flags |= ADJ_EGO_XY;
@@ -188,7 +188,7 @@ int AgiEngine::handle_controller(int key) {
return false;
}
-void AgiEngine::handle_getstring(int key) {
+void AgiEngine::handleGetstring(int key) {
static int pos = 0; /* Cursor position */
static char buf[40];
@@ -199,42 +199,42 @@ void AgiEngine::handle_getstring(int key) {
switch (key) {
case BUTTON_LEFT:
- if ((int)g_mouse.y >= stringdata.y * CHAR_LINES &&
- (int)g_mouse.y <= (stringdata.y + 1) * CHAR_LINES) {
+ if ((int)g_mouse.y >= _stringdata.y * CHAR_LINES &&
+ (int)g_mouse.y <= (_stringdata.y + 1) * CHAR_LINES) {
if (predictiveDialog()) {
- strcpy(game.strings[stringdata.str], _predictiveResult);
- new_input_mode(INPUT_NORMAL);
- _gfx->printCharacter(stringdata.x + strlen(game.strings[stringdata.str]) + 1,
- stringdata.y, ' ', game.color_fg, game.color_bg);
+ strcpy(_game.strings[_stringdata.str], _predictiveResult);
+ newInputMode(INPUT_NORMAL);
+ _gfx->printCharacter(_stringdata.x + strlen(_game.strings[_stringdata.str]) + 1,
+ _stringdata.y, ' ', _game.colorFg, _game.colorBg);
return;
}
}
break;
case KEY_ENTER:
debugC(3, kDebugLevelInput, "KEY_ENTER");
- game.has_prompt = 0;
+ _game.hasPrompt = 0;
buf[pos] = 0;
- strcpy(game.strings[stringdata.str], buf);
+ strcpy(_game.strings[_stringdata.str], buf);
debugC(3, kDebugLevelInput, "buffer=[%s]", buf);
buf[pos = 0] = 0;
- new_input_mode(INPUT_NORMAL);
- _gfx->printCharacter(stringdata.x + strlen(game.strings[stringdata.str]) + 1,
- stringdata.y, ' ', game.color_fg, game.color_bg);
+ newInputMode(INPUT_NORMAL);
+ _gfx->printCharacter(_stringdata.x + strlen(_game.strings[_stringdata.str]) + 1,
+ _stringdata.y, ' ', _game.colorFg, _game.colorBg);
return;
case KEY_ESCAPE:
debugC(3, kDebugLevelInput, "KEY_ESCAPE");
- game.has_prompt = 0;
+ _game.hasPrompt = 0;
buf[pos = 0] = 0;
- strcpy(game.strings[stringdata.str], buf);
- new_input_mode(INPUT_NORMAL);
- /* new_input_mode (INPUT_MENU); */
+ strcpy(_game.strings[_stringdata.str], buf);
+ newInputMode(INPUT_NORMAL);
+ /* newInputMode(INPUT_MENU); */
break;
case KEY_BACKSPACE: /*0x08: */
if (!pos)
break;
- _gfx->printCharacter(stringdata.x + (pos + 1), stringdata.y,
- ' ', game.color_fg, game.color_bg);
+ _gfx->printCharacter(_stringdata.x + (pos + 1), _stringdata.y,
+ ' ', _game.colorFg, _game.colorBg);
pos--;
buf[pos] = 0;
break;
@@ -242,42 +242,42 @@ void AgiEngine::handle_getstring(int key) {
if (key < 0x20 || key > 0x7f)
break;
- if (pos >= stringdata.len)
+ if (pos >= _stringdata.len)
break;
buf[pos++] = key;
buf[pos] = 0;
/* Echo */
- _gfx->printCharacter(stringdata.x + pos, stringdata.y, buf[pos - 1],
- game.color_fg, game.color_bg);
+ _gfx->printCharacter(_stringdata.x + pos, _stringdata.y, buf[pos - 1],
+ _game.colorFg, _game.colorBg);
break;
}
/* print cursor */
- _gfx->printCharacter(stringdata.x + pos + 1, stringdata.y,
- (char)game.cursor_char, game.color_fg, game.color_bg);
+ _gfx->printCharacter(_stringdata.x + pos + 1, _stringdata.y,
+ (char)_game.cursorChar, _game.colorFg, _game.colorBg);
}
-void AgiEngine::handle_keys(int key) {
+void AgiEngine::handleKeys(int key) {
uint8 *p = NULL;
int c = 0;
- static uint8 formated_entry[256];
- int l = game.line_user_input;
- int fg = game.color_fg, bg = game.color_bg;
+ static uint8 formatedEntry[256];
+ int l = _game.lineUserInput;
+ int fg = _game.colorFg, bg = _game.colorBg;
- setvar(V_word_not_found, 0);
+ setvar(vWordNotFound, 0);
debugC(3, kDebugLevelInput, "handling key: %02x", key);
switch (key) {
case KEY_ENTER:
debugC(3, kDebugLevelInput, "KEY_ENTER");
- game.keypress = 0;
+ _game.keypress = 0;
/* Remove all leading spaces */
- for (p = game.input_buffer; *p && *p == 0x20; p++);
+ for (p = _game.inputBuffer; *p && *p == 0x20; p++);
/* Copy to internal buffer */
for (; *p; p++) {
@@ -286,39 +286,39 @@ void AgiEngine::handle_keys(int key) {
p++;
continue;
}
- formated_entry[c++] = tolower(*p);
+ formatedEntry[c++] = tolower(*p);
}
- formated_entry[c++] = 0;
+ formatedEntry[c++] = 0;
/* Handle string only if it's not empty */
- if (formated_entry[0]) {
- strcpy((char *)game.echo_buffer, (const char *)game.input_buffer);
- strcpy(last_sentence, (const char *)formated_entry);
- dictionary_words(last_sentence);
+ if (formatedEntry[0]) {
+ strcpy((char *)_game.echoBuffer, (const char *)_game.inputBuffer);
+ strcpy(_lastSentence, (const char *)formatedEntry);
+ dictionaryWords(_lastSentence);
}
/* Clear to start a new line */
- game.has_prompt = 0;
- game.input_buffer[game.cursor_pos = 0] = 0;
+ _game.hasPrompt = 0;
+ _game.inputBuffer[_game.cursorPos = 0] = 0;
debugC(3, kDebugLevelInput, "clear lines");
- clear_lines(l, l + 1, bg);
- flush_lines(l, l + 1);
+ clearLines(l, l + 1, bg);
+ flushLines(l, l + 1);
break;
case KEY_ESCAPE:
debugC(3, kDebugLevelInput, "KEY_ESCAPE");
- new_input_mode(INPUT_MENU);
+ newInputMode(INPUT_MENU);
break;
case KEY_BACKSPACE:
/* Ignore backspace at start of line */
- if (game.cursor_pos == 0)
+ if (_game.cursorPos == 0)
break;
/* erase cursor */
- _gfx->printCharacter(game.cursor_pos + 1, l, ' ', fg, bg);
- game.input_buffer[--game.cursor_pos] = 0;
+ _gfx->printCharacter(_game.cursorPos + 1, l, ' ', fg, bg);
+ _game.inputBuffer[--_game.cursorPos] = 0;
/* Print cursor */
- _gfx->printCharacter(game.cursor_pos + 1, l, game.cursor_char, fg, bg);
+ _gfx->printCharacter(_game.cursorPos + 1, l, _game.cursorChar, fg, bg);
break;
default:
/* Ignore invalid keystrokes */
@@ -326,22 +326,22 @@ void AgiEngine::handle_keys(int key) {
break;
/* Maximum input size reached */
- if (game.cursor_pos >= getvar(V_max_input_chars))
+ if (_game.cursorPos >= getvar(vMaxInputChars))
break;
- game.input_buffer[game.cursor_pos++] = key;
- game.input_buffer[game.cursor_pos] = 0;
+ _game.inputBuffer[_game.cursorPos++] = key;
+ _game.inputBuffer[_game.cursorPos] = 0;
/* echo */
- _gfx->printCharacter(game.cursor_pos, l, game.input_buffer[game.cursor_pos - 1], fg, bg);
+ _gfx->printCharacter(_game.cursorPos, l, _game.inputBuffer[_game.cursorPos - 1], fg, bg);
/* Print cursor */
- _gfx->printCharacter(game.cursor_pos + 1, l, game.cursor_char, fg, bg);
+ _gfx->printCharacter(_game.cursorPos + 1, l, _game.cursorChar, fg, bg);
break;
}
}
-int AgiEngine::wait_key() {
+int AgiEngine::waitKey() {
int key;
/* clear key queue */
@@ -352,7 +352,7 @@ int AgiEngine::wait_key() {
debugC(3, kDebugLevelInput, "waiting...");
for (;;) {
_gfx->pollTimer(); /* msdos driver -> does nothing */
- key = do_poll_keyboard();
+ key = doPollKeyboard();
if (key == KEY_ENTER || key == KEY_ESCAPE || key == BUTTON_LEFT)
break;
_gfx->doUpdate();
@@ -360,7 +360,7 @@ int AgiEngine::wait_key() {
return key;
}
-int AgiEngine::wait_any_key() {
+int AgiEngine::waitAnyKey() {
int key;
/* clear key queue */
@@ -371,7 +371,7 @@ int AgiEngine::wait_any_key() {
debugC(3, kDebugLevelInput, "waiting...");
for (;;) {
_gfx->pollTimer(); /* msdos driver -> does nothing */
- key = do_poll_keyboard();
+ key = doPollKeyboard();
if (key)
break;
_gfx->doUpdate();
@@ -379,4 +379,4 @@ int AgiEngine::wait_any_key() {
return key;
}
-} // End of namespace Agi
+} // End of namespace Agi
diff --git a/engines/agi/keyboard.h b/engines/agi/keyboard.h
index 5a1937eed8..13d2477798 100644
--- a/engines/agi/keyboard.h
+++ b/engines/agi/keyboard.h
@@ -71,7 +71,7 @@ namespace Agi {
#define KEY_SCAN(k) (k >> 8)
#define KEY_ASCII(k) (k & 0xff)
-extern uint8 scancode_table[];
+extern uint8 scancodeTable[];
} // End of namespace Agi
diff --git a/engines/agi/logic.cpp b/engines/agi/logic.cpp
index 28d8b694f4..21a560427e 100644
--- a/engines/agi/logic.cpp
+++ b/engines/agi/logic.cpp
@@ -34,15 +34,15 @@ namespace Agi {
* into a message list.
* @param n The number of the logic resource to decode.
*/
-int AgiEngine::decode_logic(int n) {
- int ec = err_OK;
+int AgiEngine::decodeLogic(int n) {
+ int ec = errOK;
int mstart, mend, mc;
uint8 *m0;
/* decrypt messages at end of logic + build message list */
/* report ("decoding logic #%d\n", n); */
- m0 = game.logics[n].data;
+ m0 = _game.logics[n].data;
mstart = READ_LE_UINT16(m0) + 2;
mc = *(m0 + mstart);
@@ -53,41 +53,41 @@ int AgiEngine::decode_logic(int n) {
/* if the logic was not compressed, decrypt the text messages
* only if there are more than 0 messages
*/
- if ((~game.dir_logic[n].flags & RES_COMPRESSED) && mc > 0)
+ if ((~_game.dirLogic[n].flags & RES_COMPRESSED) && mc > 0)
decrypt(m0 + mstart, mend - mstart); /* decrypt messages */
/* build message list */
- m0 = game.logics[n].data;
+ m0 = _game.logics[n].data;
mstart = READ_LE_UINT16(m0) + 2; /* +2 covers pointer */
- game.logics[n].num_texts = *(m0 + mstart);
+ _game.logics[n].numTexts = *(m0 + mstart);
/* 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].sIP = 2;
+ _game.logics[n].cIP = 2;
+ _game.logics[n].size = READ_LE_UINT16(m0) + 2; /* logic end pointer */
/* allocate list of pointers to point into our data */
- game.logics[n].texts = (const char **)calloc(1 + game.logics[n].num_texts, sizeof(char *));
+ _game.logics[n].texts = (const char **)calloc(1 + _game.logics[n].numTexts, sizeof(char *));
/* cover header info */
m0 += mstart + 3;
- if (game.logics[n].texts != NULL) {
+ if (_game.logics[n].texts != NULL) {
/* move list of strings into list to make real pointers */
- for (mc = 0; mc < game.logics[n].num_texts; mc++) {
+ 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 *)"";
+ _game.logics[n].texts[mc] = mend ? (const char *)m0 + mend - 2 : (const char *)"";
}
/* set loaded flag now its all completly loaded */
- game.dir_logic[n].flags |= RES_LOADED;
+ _game.dirLogic[n].flags |= RES_LOADED;
} else {
/* unload data
* blah DF YA WANKER!!@!@# frag. i'm so dumb. not every logic
* has text
*/
- free(game.logics[n].data);
- ec = err_NotEnoughMemory;
+ free(_game.logics[n].data);
+ ec = errNotEnoughMemory;
}
return ec;
@@ -99,18 +99,18 @@ int AgiEngine::decode_logic(int n) {
* memory chunks allocated for this resource.
* @param n The number of the logic resource to unload
*/
-void AgiEngine::unload_logic(int n) {
- if (game.dir_logic[n].flags & RES_LOADED) {
- free(game.logics[n].data);
- if (game.logics[n].num_texts)
- free(game.logics[n].texts);
- game.logics[n].num_texts = 0;
- game.dir_logic[n].flags &= ~RES_LOADED;
+void AgiEngine::unloadLogic(int n) {
+ if (_game.dirLogic[n].flags & RES_LOADED) {
+ free(_game.logics[n].data);
+ if (_game.logics[n].numTexts)
+ free(_game.logics[n].texts);
+ _game.logics[n].numTexts = 0;
+ _game.dirLogic[n].flags &= ~RES_LOADED;
}
/* if cached, we end up here */
- game.logics[n].sIP = 2;
- game.logics[n].cIP = 2;
+ _game.logics[n].sIP = 2;
+ _game.logics[n].cIP = 2;
}
-} // End of namespace Agi
+} // End of namespace Agi
diff --git a/engines/agi/logic.h b/engines/agi/logic.h
index 5ceea0d661..371c384cce 100644
--- a/engines/agi/logic.h
+++ b/engines/agi/logic.h
@@ -33,12 +33,12 @@ namespace Agi {
/**
* AGI logic resource structure.
*/
-struct agi_logic {
+struct AgiLogic {
uint8 *data; /**< raw resource data */
int size; /**< size of data */
int sIP; /**< saved IP */
int cIP; /**< current IP */
- int num_texts; /**< number of messages */
+ int numTexts; /**< number of messages */
const char **texts; /**< message list */
};
diff --git a/engines/agi/lzw.cpp b/engines/agi/lzw.cpp
index 29259a5bc9..52bbd6cc00 100644
--- a/engines/agi/lzw.cpp
+++ b/engines/agi/lzw.cpp
@@ -44,33 +44,33 @@ namespace Agi {
#define START_BITS 9
static int32 BITS, MAX_VALUE, MAX_CODE;
-static uint32 *prefix_code;
-static uint8 *append_character;
-static uint8 *decode_stack;
-static int32 input_bit_count = 0; /* Number of bits in input bit buffer */
-static uint32 input_bit_buffer = 0L;
+static uint32 *prefixCode;
+static uint8 *appendCharacter;
+static uint8 *decodeStack;
+static int32 inputBitCount = 0; /* Number of bits in input bit buffer */
+static uint32 inputBitBuffer = 0L;
static void initLZW() {
- decode_stack = (uint8 *)calloc(1, 8192);
- prefix_code = (uint32 *)malloc(TABLE_SIZE * sizeof(uint32));
- append_character = (uint8 *)malloc(TABLE_SIZE * sizeof(uint8));
- input_bit_count = 0; /* Number of bits in input bit buffer */
- input_bit_buffer = 0L;
+ 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 */
+ inputBitBuffer = 0L;
}
static void closeLZW() {
- free(decode_stack);
- free(prefix_code);
- free(append_character);
+ free(decodeStack);
+ free(prefixCode);
+ free(appendCharacter);
}
/***************************************************************************
-** setBITS
+** setBits
**
** Purpose: To adjust the number of bits used to store codes to the value
** passed in.
***************************************************************************/
-int setBITS(int32 value) {
+int setBits(int32 value) {
if (value == MAXBITS)
return true;
@@ -88,12 +88,12 @@ int setBITS(int32 value) {
** represents. The string is returned as a stack, i.e. the characters are
** in reverse order.
***************************************************************************/
-static uint8 *decode_string(uint8 *buffer, uint32 code) {
+static uint8 *decodeString(uint8 *buffer, uint32 code) {
uint32 i;
for (i = 0; code > 255;) {
- *buffer++ = append_character[code];
- code = prefix_code[code];
+ *buffer++ = appendCharacter[code];
+ code = prefixCode[code];
if (i++ >= 4000) {
fprintf(stderr, "lzw: error in code expansion.\n");
abort();
@@ -109,16 +109,16 @@ static uint8 *decode_string(uint8 *buffer, uint32 code) {
**
** Purpose: To return the next code from the input buffer.
***************************************************************************/
-static uint32 input_code(uint8 **input) {
+static uint32 inputCode(uint8 **input) {
uint32 r;
- while (input_bit_count <= 24) {
- input_bit_buffer |= (uint32) * (*input)++ << input_bit_count;
- input_bit_count += 8;
+ while (inputBitCount <= 24) {
+ inputBitBuffer |= (uint32) * (*input)++ << inputBitCount;
+ inputBitCount += 8;
}
- r = (input_bit_buffer & 0x7FFF) % (1 << BITS);
- input_bit_buffer >>= BITS;
- input_bit_count -= BITS;
+ r = (inputBitBuffer & 0x7FFF) % (1 << BITS);
+ inputBitBuffer >>= BITS;
+ inputBitCount -= BITS;
return r;
}
@@ -135,57 +135,57 @@ static uint32 input_code(uint8 **input) {
** code 256 = start over
** code 257 = end of data
***************************************************************************/
-void LZW_expand(uint8 *in, uint8 *out, int32 len) {
+void lzwExpand(uint8 *in, uint8 *out, int32 len) {
int32 c, lzwnext, lzwnew, lzwold;
uint8 *s, *end;
initLZW();
- setBITS(START_BITS); /* Starts at 9-bits */
+ setBits(START_BITS); /* Starts at 9-bits */
lzwnext = 257; /* Next available code to define */
end = (unsigned char *)((long)out + (long)len);
- lzwold = input_code(&in); /* Read in the first code */
+ lzwold = inputCode(&in); /* Read in the first code */
c = lzwold;
- lzwnew = input_code(&in);
+ lzwnew = inputCode(&in);
while ((out < end) && (lzwnew != 0x101)) {
if (lzwnew == 0x100) {
/* Code to "start over" */
lzwnext = 258;
- setBITS(START_BITS);
- lzwold = input_code(&in);
+ setBits(START_BITS);
+ lzwold = inputCode(&in);
c = lzwold;
*out++ = (char)c;
- lzwnew = input_code(&in);
+ lzwnew = inputCode(&in);
} else {
if (lzwnew >= lzwnext) {
/* Handles special LZW scenario */
- *decode_stack = c;
- s = decode_string(decode_stack + 1, lzwold);
+ *decodeStack = c;
+ s = decodeString(decodeStack + 1, lzwold);
} else
- s = decode_string(decode_stack, lzwnew);
+ s = decodeString(decodeStack, lzwnew);
/* Reverse order of decoded string and
* store in out buffer
*/
c = *s;
- while (s >= decode_stack)
+ while (s >= decodeStack)
*out++ = *s--;
if (lzwnext > MAX_CODE)
- setBITS(BITS + 1);
+ setBits(BITS + 1);
- prefix_code[lzwnext] = lzwold;
- append_character[lzwnext] = c;
+ prefixCode[lzwnext] = lzwold;
+ appendCharacter[lzwnext] = c;
lzwnext++;
lzwold = lzwnew;
- lzwnew = input_code(&in);
+ lzwnew = inputCode(&in);
}
}
closeLZW();
}
-} // End of namespace Agi
+} // End of namespace Agi
diff --git a/engines/agi/lzw.h b/engines/agi/lzw.h
index 2edb947e49..509e8c65a6 100644
--- a/engines/agi/lzw.h
+++ b/engines/agi/lzw.h
@@ -27,7 +27,7 @@
namespace Agi {
-void LZW_expand(uint8 *, uint8 *, int32);
+void lzwExpand(uint8 *, uint8 *, int32);
} // End of namespace Agi
diff --git a/engines/agi/menu.cpp b/engines/agi/menu.cpp
index fb452856db..9a7e4703bb 100644
--- a/engines/agi/menu.cpp
+++ b/engines/agi/menu.cpp
@@ -36,14 +36,14 @@ namespace Agi {
// TODO: add constructor/destructor for agi_menu, agi_menu_option
-struct agi_menu_option {
+struct AgiMenuOption {
int enabled; /**< option is enabled or disabled */
int event; /**< menu event */
int index; /**< number of option in this menu */
char *text; /**< text of menu option */
};
-struct agi_menu {
+struct AgiMenu {
MenuOptionList down; /**< list head for menu options */
int index; /**< number of menu in menubar */
int width; /**< width of menu in characters */
@@ -53,21 +53,21 @@ struct agi_menu {
char *text; /**< menu name */
};
-agi_menu *Menu::get_menu(int i) {
+AgiMenu *Menu::getMenu(int i) {
MenuList::iterator iter;
- for (iter = menubar.begin(); iter != menubar.end(); ++iter) {
- agi_menu *m = *iter;
+ for (iter = _menubar.begin(); iter != _menubar.end(); ++iter) {
+ AgiMenu *m = *iter;
if (m->index == i)
return m;
}
return NULL;
}
-agi_menu_option *Menu::get_menu_option(int i, int j) {
- agi_menu *m = get_menu(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) {
- agi_menu_option* d = *iter;
+ AgiMenuOption* d = *iter;
if (d->index == j)
return d;
}
@@ -75,59 +75,59 @@ agi_menu_option *Menu::get_menu_option(int i, int j) {
return NULL;
}
-void Menu::draw_menu_bar() {
- _vm->clear_lines(0, 0, MENU_BG);
- _vm->flush_lines(0, 0);
+void Menu::drawMenuBar() {
+ _vm->clearLines(0, 0, MENU_BG);
+ _vm->flushLines(0, 0);
MenuList::iterator iter;
- for (iter = menubar.begin(); iter != menubar.end(); ++iter) {
- agi_menu *m = *iter;
- _vm->print_text(m->text, 0, m->col, 0, 40, MENU_FG, MENU_BG);
+ for (iter = _menubar.begin(); iter != _menubar.end(); ++iter) {
+ AgiMenu *m = *iter;
+ _vm->printText(m->text, 0, m->col, 0, 40, MENU_FG, MENU_BG);
}
}
-void Menu::draw_menu_hilite(int cur_menu) {
- agi_menu *m = get_menu(cur_menu);
+void Menu::drawMenuHilite(int curMenu) {
+ AgiMenu *m = getMenu(curMenu);
debugC(6, kDebugLevelMenu, "[%s]", m->text);
- _vm->print_text(m->text, 0, m->col, 0, 40, MENU_BG, MENU_FG);
- _vm->flush_lines(0, 0);
+ _vm->printText(m->text, 0, m->col, 0, 40, MENU_BG, MENU_FG);
+ _vm->flushLines(0, 0);
}
/* draw box and pulldowns. */
-void Menu::draw_menu_option(int h_menu) {
+void Menu::drawMenuOption(int hMenu) {
/* find which vertical menu it is */
- agi_menu *m = get_menu(h_menu);
+ 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) {
- agi_menu_option* d = *iter;
- _vm->print_text(d->text, 0, m->wincol + 1, d->index + 2, m->width + 2,
+ AgiMenuOption* d = *iter;
+ _vm->printText(d->text, 0, m->wincol + 1, d->index + 2, m->width + 2,
MENU_FG, MENU_BG, !d->enabled);
}
}
-void Menu::draw_menu_option_hilite(int h_menu, int v_menu) {
- agi_menu *m = get_menu(h_menu);
- agi_menu_option *d = get_menu_option(h_menu, v_menu);
+void Menu::drawMenuOptionHilite(int hMenu, int vMenu) {
+ AgiMenu *m = getMenu(hMenu);
+ AgiMenuOption *d = getMenuOption(hMenu, vMenu);
// Disabled menu items are "greyed out" with a checkerboard effect,
// rather than having a different colour. -- dsymonds
- _vm->print_text(d->text, 0, m->wincol + 1, v_menu + 2, m->width + 2,
+ _vm->printText(d->text, 0, m->wincol + 1, vMenu + 2, m->width + 2,
MENU_BG, MENU_FG, !d->enabled);
}
-void Menu::new_menu_selected(int i) {
- _picture->show_pic();
- draw_menu_bar();
- draw_menu_hilite(i);
- draw_menu_option(i);
+void Menu::newMenuSelected(int i) {
+ _picture->showPic();
+ drawMenuBar();
+ drawMenuHilite(i);
+ drawMenuOption(i);
}
-bool Menu::mouse_over_text(unsigned int line, unsigned int col, char *s) {
+bool Menu::mouseOverText(unsigned int line, unsigned int col, char *s) {
if (g_mouse.x < col * CHAR_COLS)
return false;
@@ -169,21 +169,21 @@ Menu::Menu(AgiEngine *vm, GfxMgr *gfx, PictureMgr *picture) {
_vm = vm;
_gfx = gfx;
_picture = picture;
- h_index = 0;
- h_col = 1;
- h_max_menu = 0;
- h_cur_menu = 0;
- v_cur_menu = 0;
+ _hIndex = 0;
+ _hCol = 1;
+ _hMaxMenu = 0;
+ _hCurMenu = 0;
+ _vCurMenu = 0;
}
Menu::~Menu() {
MenuList::iterator iterh;
- for (iterh = menubar.reverse_begin(); iterh != menubar.end(); ) {
- agi_menu *m = *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(); ) {
- agi_menu_option *d = *iterv;
+ AgiMenuOption *d = *iterv;
debugC(3, kDebugLevelMenu, " deiniting vmenu %s", d->text);
free(d->text);
delete d;
@@ -191,44 +191,44 @@ Menu::~Menu() {
}
free(m->text);
delete m;
- iterh = menubar.reverse_erase(iterh);
+ iterh = _menubar.reverse_erase(iterh);
}
}
void Menu::add(const char *s) {
- agi_menu *m = new agi_menu;
+ 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 = h_index++;
- m->col = h_col;
- m->wincol = h_col - 1;
- v_index = 0;
- v_max_menu[m->index] = 0;
- h_col += strlen(m->text) + 1;
- h_max_menu = m->index;
+ m->index = _hIndex++;
+ m->col = _hCol;
+ m->wincol = _hCol - 1;
+ _vIndex = 0;
+ _vMaxMenu[m->index] = 0;
+ _hCol += strlen(m->text) + 1;
+ _hMaxMenu = m->index;
debugC(3, kDebugLevelMenu, "add menu: '%s' %02x", s, m->text[strlen(m->text)]);
- menubar.push_back(m);
+ _menubar.push_back(m);
}
-void Menu::add_item(const char *s, int code) {
+void Menu::addItem(const char *s, int code) {
int l;
- agi_menu_option* d = new agi_menu_option;
+ AgiMenuOption* d = new AgiMenuOption;
d->text = strdup(s);
d->enabled = true;
d->event = code;
- d->index = v_index++;
+ d->index = _vIndex++;
// add to last menu in list
- assert(menubar.reverse_begin() != menubar.end());
- agi_menu *m = *menubar.reverse_begin();
+ assert(_menubar.reverse_begin() != _menubar.end());
+ AgiMenu *m = *_menubar.reverse_begin();
m->height++;
- v_max_menu[m->index] = d->index;
+ _vMaxMenu[m->index] = d->index;
l = strlen(d->text);
if (l > 40)
@@ -249,13 +249,13 @@ void Menu::submit() {
/* If a menu has no options, delete it */
MenuList::iterator iter;
- for (iter = menubar.reverse_begin(); iter != menubar.end(); ) {
- agi_menu *m = *iter;
+ for (iter = _menubar.reverse_begin(); iter != _menubar.end(); ) {
+ AgiMenu *m = *iter;
if (m->down.empty()) {
free(m->text);
delete m;
- h_max_menu--;
- iter = menubar.reverse_erase(iter);
+ _hMaxMenu--;
+ iter = _menubar.reverse_erase(iter);
} else {
--iter;
}
@@ -263,17 +263,17 @@ void Menu::submit() {
}
bool Menu::keyhandler(int key) {
- static int clock_val;
- static int menu_active = false;
- static int button_used = 0;
+ static int clockVal;
+ static int menuActive = false;
+ static int buttonUsed = 0;
- if (!_vm->getflag(F_menus_work))
+ if (!_vm->getflag(fMenusWork))
return false;
- if (!menu_active) {
- clock_val = _vm->game.clock_enabled;
- _vm->game.clock_enabled = false;
- draw_menu_bar();
+ if (!menuActive) {
+ clockVal = _vm->_game.clockEnabled;
+ _vm->_game.clockEnabled = false;
+ drawMenuBar();
}
/*
* Mouse handling
@@ -281,76 +281,76 @@ bool Menu::keyhandler(int key) {
if (g_mouse.button) {
int hmenu, vmenu;
- button_used = 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 */
hmenu = 0;
MenuList::iterator iterh;
- for (iterh = menubar.begin(); iterh != menubar.end(); ++iterh) {
- agi_menu *m = *iterh;
- if (mouse_over_text(0, m->col, m->text)) {
+ for (iterh = _menubar.begin(); iterh != _menubar.end(); ++iterh) {
+ AgiMenu *m = *iterh;
+ if (mouseOverText(0, m->col, m->text)) {
break;
} else {
hmenu++;
}
}
- if (hmenu <= h_max_menu) {
- if (h_cur_menu != hmenu) {
- v_cur_menu = -1;
- new_menu_selected(hmenu);
+ if (hmenu <= _hMaxMenu) {
+ if (_hCurMenu != hmenu) {
+ _vCurMenu = -1;
+ newMenuSelected(hmenu);
}
- h_cur_menu = hmenu;
+ _hCurMenu = hmenu;
}
} else {
/* not in menubar */
vmenu = 0;
- agi_menu *m = get_menu(h_cur_menu);
+ AgiMenu *m = getMenu(_hCurMenu);
MenuOptionList::iterator iterv;
for (iterv = m->down.begin(); iterv != m->down.end(); ++iterv) {
- agi_menu_option *do1 = *iterv;
- if (mouse_over_text(2 + do1->index, m->wincol + 1, do1->text)) {
+ AgiMenuOption *do1 = *iterv;
+ if (mouseOverText(2 + do1->index, m->wincol + 1, do1->text)) {
break;
} else {
vmenu++;
}
}
- if (vmenu <= v_max_menu[h_cur_menu]) {
- if (v_cur_menu != vmenu) {
- draw_menu_option(h_cur_menu);
- draw_menu_option_hilite(h_cur_menu, vmenu);
+ if (vmenu <= _vMaxMenu[_hCurMenu]) {
+ if (_vCurMenu != vmenu) {
+ drawMenuOption(_hCurMenu);
+ drawMenuOptionHilite(_hCurMenu, vmenu);
}
- v_cur_menu = vmenu;
+ _vCurMenu = vmenu;
}
}
- } else if (button_used) {
+ } else if (buttonUsed) {
/* Button released */
- button_used = 0;
+ buttonUsed = 0;
debugC(6, kDebugLevelMenu | kDebugLevelInput, "button released!");
- if (v_cur_menu < 0)
- v_cur_menu = 0;
+ if (_vCurMenu < 0)
+ _vCurMenu = 0;
- draw_menu_option_hilite(h_cur_menu, v_cur_menu);
+ drawMenuOptionHilite(_hCurMenu, _vCurMenu);
if (g_mouse.y <= CHAR_LINES) {
/* on the menubar */
} else {
/* see which option we selected */
- agi_menu *m = get_menu(h_cur_menu);
+ AgiMenu *m = getMenu(_hCurMenu);
MenuOptionList::iterator iterv;
for (iterv = m->down.begin(); iterv != m->down.end(); ++iterv) {
- agi_menu_option *d = *iterv;
- if (mouse_over_text(2 + d->index, m->wincol + 1, d->text)) {
+ AgiMenuOption *d = *iterv;
+ if (mouseOverText(2 + d->index, m->wincol + 1, d->text)) {
/* activate that option */
if (d->enabled) {
debugC(6, kDebugLevelMenu | kDebugLevelInput, "event %d registered", d->event);
- _vm->game.ev_keyp[d->event].occured = true;
- _vm->game.ev_keyp[d->event].data = d->event;
+ _vm->_game.evKeyp[d->event].occured = true;
+ _vm->_game.evKeyp[d->event].data = d->event;
goto exit_menu;
}
}
@@ -359,14 +359,14 @@ bool Menu::keyhandler(int key) {
}
}
- if (!menu_active) {
- if (h_cur_menu >= 0) {
- draw_menu_hilite(h_cur_menu);
- draw_menu_option(h_cur_menu);
- if (!button_used && v_cur_menu >= 0)
- draw_menu_option_hilite(h_cur_menu, v_cur_menu);
+ if (!menuActive) {
+ if (_hCurMenu >= 0) {
+ drawMenuHilite(_hCurMenu);
+ drawMenuOption(_hCurMenu);
+ if (!buttonUsed && _vCurMenu >= 0)
+ drawMenuOptionHilite(_hCurMenu, _vCurMenu);
}
- menu_active = true;
+ menuActive = true;
}
switch (key) {
@@ -376,68 +376,68 @@ bool Menu::keyhandler(int key) {
case KEY_ENTER:
{
debugC(6, kDebugLevelMenu | kDebugLevelInput, "KEY_ENTER");
- agi_menu_option* d = get_menu_option(h_cur_menu, v_cur_menu);
+ AgiMenuOption* d = getMenuOption(_hCurMenu, _vCurMenu);
if (d->enabled) {
debugC(6, kDebugLevelMenu | kDebugLevelInput, "event %d registered", d->event);
- _vm->game.ev_keyp[d->event].occured = true;
+ _vm->_game.evKeyp[d->event].occured = true;
goto exit_menu;
}
break;
}
case KEY_DOWN:
case KEY_UP:
- v_cur_menu += key == KEY_DOWN ? 1 : -1;
+ _vCurMenu += key == KEY_DOWN ? 1 : -1;
- if (v_cur_menu < 0)
- v_cur_menu = v_max_menu[h_cur_menu];
- if (v_cur_menu > v_max_menu[h_cur_menu])
- v_cur_menu = 0;
+ if (_vCurMenu < 0)
+ _vCurMenu = _vMaxMenu[_hCurMenu];
+ if (_vCurMenu > _vMaxMenu[_hCurMenu])
+ _vCurMenu = 0;
- draw_menu_option(h_cur_menu);
- draw_menu_option_hilite(h_cur_menu, v_cur_menu);
+ drawMenuOption(_hCurMenu);
+ drawMenuOptionHilite(_hCurMenu, _vCurMenu);
break;
case KEY_RIGHT:
case KEY_LEFT:
- h_cur_menu += key == KEY_RIGHT ? 1 : -1;
+ _hCurMenu += key == KEY_RIGHT ? 1 : -1;
- if (h_cur_menu < 0)
- h_cur_menu = h_max_menu;
- if (h_cur_menu > h_max_menu)
- h_cur_menu = 0;
+ if (_hCurMenu < 0)
+ _hCurMenu = _hMaxMenu;
+ if (_hCurMenu > _hMaxMenu)
+ _hCurMenu = 0;
- v_cur_menu = 0;
- new_menu_selected(h_cur_menu);
- draw_menu_option_hilite(h_cur_menu, v_cur_menu);
+ _vCurMenu = 0;
+ newMenuSelected(_hCurMenu);
+ drawMenuOptionHilite(_hCurMenu, _vCurMenu);
break;
}
return true;
exit_menu:
- button_used = 0;
- _picture->show_pic();
- _vm->write_status();
+ buttonUsed = 0;
+ _picture->showPic();
+ _vm->writeStatus();
- _vm->setvar(V_key, 0);
- _vm->game.keypress = 0;
- _vm->game.clock_enabled = clock_val;
- _vm->old_input_mode();
- debugC(3, kDebugLevelMenu, "exit_menu: input mode reset to %d", _vm->game.input_mode);
- menu_active = 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;
}
-void Menu::set_item(int event, int state) {
+void Menu::setItem(int event, int state) {
/* 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) {
- agi_menu *m = *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) {
- agi_menu_option *d = *iterv;
+ AgiMenuOption *d = *iterv;
if (d->event == event) {
d->enabled = state;
// keep going; we need to set the state of every menu item
@@ -447,16 +447,16 @@ void Menu::set_item(int event, int state) {
}
}
-void Menu::enable_all() {
+void Menu::enableAll() {
MenuList::iterator iterh;
- for (iterh = menubar.begin(); iterh != menubar.end(); ++iterh) {
- agi_menu *m = *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) {
- agi_menu_option *d = *iterv;
+ AgiMenuOption *d = *iterv;
d->enabled = true;
}
}
}
-} // End of namespace Agi
+} // End of namespace Agi
diff --git a/engines/agi/menu.h b/engines/agi/menu.h
index fe33e2f225..d9a10b8310 100644
--- a/engines/agi/menu.h
+++ b/engines/agi/menu.h
@@ -35,10 +35,10 @@ namespace Agi {
#define MENU_FG 0x00 /* Black */
#define MENU_LINE 0x00 /* Black */
-struct agi_menu;
-struct agi_menu_option;
-typedef Common::List<agi_menu*> MenuList;
-typedef Common::List<agi_menu_option*> MenuOptionList;
+struct AgiMenu;
+struct AgiMenuOption;
+typedef Common::List<AgiMenu*> MenuList;
+typedef Common::List<AgiMenuOption*> MenuOptionList;
class GfxMgr;
class PictureMgr;
@@ -54,35 +54,35 @@ public:
~Menu();
void add(const char *s);
- void add_item(const char *s, int code);
+ void addItem(const char *s, int code);
void submit();
- void set_item(int event, int state);
+ void setItem(int event, int state);
bool keyhandler(int key);
- void enable_all();
+ void enableAll();
private:
- MenuList menubar;
-
- int h_cur_menu;
- int v_cur_menu;
-
- int h_index;
- int v_index;
- int h_col;
- int h_max_menu;
- int v_max_menu[10];
-
- agi_menu* get_menu(int i);
- agi_menu_option *get_menu_option(int i, int j);
- void draw_menu_bar();
- void draw_menu_hilite(int cur_menu);
- void draw_menu_option(int h_menu);
- void draw_menu_option_hilite(int h_menu, int v_menu);
- void new_menu_selected(int i);
- bool mouse_over_text(unsigned int line, unsigned int col, char *s);
+ MenuList _menubar;
+
+ int _hCurMenu;
+ int _vCurMenu;
+
+ int _hIndex;
+ int _vIndex;
+ int _hCol;
+ int _hMaxMenu;
+ int _vMaxMenu[10];
+
+ AgiMenu* getMenu(int i);
+ AgiMenuOption *getMenuOption(int i, int j);
+ void drawMenuBar();
+ void drawMenuHilite(int curMenu);
+ void drawMenuOption(int hMenu);
+ void drawMenuOptionHilite(int hMenu, int vMenu);
+ void newMenuSelected(int i);
+ bool mouseOverText(unsigned int line, unsigned int col, char *s);
};
-} // End of namespace Agi
+} // End of namespace Agi
-#endif /* AGI_MENU_H */
+#endif /* AGI_MENU_H */
diff --git a/engines/agi/motion.cpp b/engines/agi/motion.cpp
index d59c02b039..3536a73605 100644
--- a/engines/agi/motion.cpp
+++ b/engines/agi/motion.cpp
@@ -28,43 +28,43 @@
namespace Agi {
-int AgiEngine::check_step(int delta, int step) {
+int AgiEngine::checkStep(int delta, int step) {
return (-step >= delta) ? 0 : (step <= delta) ? 2 : 1;
}
-int AgiEngine::check_block(int x, int y) {
- if (x <= game.block.x1 || x >= game.block.x2)
+int AgiEngine::checkBlock(int x, int y) {
+ if (x <= _game.block.x1 || x >= _game.block.x2)
return false;
- if (y <= game.block.y1 || y >= game.block.y2)
+ if (y <= _game.block.y1 || y >= _game.block.y2)
return false;
return true;
}
-void AgiEngine::changepos(struct vt_entry *v) {
+void AgiEngine::changePos(struct VtEntry *v) {
int b, x, y;
int dx[9] = { 0, 0, 1, 1, 1, 0, -1, -1, -1 };
int dy[9] = { 0, -1, -1, 0, 1, 1, 1, 0, -1 };
- x = v->x_pos;
- y = v->y_pos;
- b = check_block(x, y);
+ x = v->xPos;
+ y = v->yPos;
+ b = checkBlock(x, y);
- x += v->step_size * dx[v->direction];
- y += v->step_size * dy[v->direction];
+ x += v->stepSize * dx[v->direction];
+ y += v->stepSize * dy[v->direction];
- if (check_block(x, y) == b) {
+ if (checkBlock(x, y) == b) {
v->flags &= ~MOTION;
} else {
v->flags |= MOTION;
v->direction = 0;
- if (is_ego_view(v))
- game.vars[V_ego_dir] = 0;
+ if (isEgoView(v))
+ _game.vars[vEgoDir] = 0;
}
}
-void AgiEngine::motion_wander(struct vt_entry *v) {
+void AgiEngine::motionWander(struct VtEntry *v) {
if (v->parm1--) {
if (~v->flags & DIDNT_MOVE)
return;
@@ -72,27 +72,27 @@ void AgiEngine::motion_wander(struct vt_entry *v) {
v->direction = _rnd->getRandomNumber(8);
- if (is_ego_view(v)) {
- game.vars[V_ego_dir] = v->direction;
+ if (isEgoView(v)) {
+ _game.vars[vEgoDir] = v->direction;
while (v->parm1 < 6) {
v->parm1 = _rnd->getRandomNumber(50); /* huh? */
}
}
}
-void AgiEngine::motion_followego(struct vt_entry *v) {
- int ego_x, ego_y;
- int obj_x, obj_y;
+void AgiEngine::motionFollowEgo(struct VtEntry *v) {
+ int egoX, egoY;
+ int objX, objY;
int dir;
- ego_x = game.view_table[0].x_pos + game.view_table[0].x_size / 2;
- ego_y = game.view_table[0].y_pos;
+ egoX = _game.viewTable[0].xPos + _game.viewTable[0].xSize / 2;
+ egoY = _game.viewTable[0].yPos;
- obj_x = v->x_pos + v->x_size / 2;
- obj_y = v->y_pos;
+ objX = v->xPos + v->xSize / 2;
+ objY = v->yPos;
/* Get direction to reach ego */
- dir = get_direction(obj_x, obj_y, ego_x, ego_y, v->parm1);
+ dir = getDirection(objX, objY, egoX, egoY, v->parm1);
/* Already at ego coordinates */
if (dir == 0) {
@@ -110,14 +110,14 @@ void AgiEngine::motion_followego(struct vt_entry *v) {
while ((v->direction = _rnd->getRandomNumber(8)) == 0) {
}
- d = (abs(ego_y - obj_y) + abs(ego_x - obj_x)) / 2;
+ d = (abs(egoY - objY) + abs(egoX - objX)) / 2;
- if (d < v->step_size) {
- v->parm3 = v->step_size;
+ if (d < v->stepSize) {
+ v->parm3 = v->stepSize;
return;
}
- while ((v->parm3 = _rnd->getRandomNumber(d)) < v->step_size) {
+ while ((v->parm3 = _rnd->getRandomNumber(d)) < v->stepSize) {
}
return;
}
@@ -132,7 +132,7 @@ void AgiEngine::motion_followego(struct vt_entry *v) {
* v->parm3 = 0;
*/
k = v->parm3;
- k -= v->step_size;
+ k -= v->stepSize;
v->parm3 = k;
if ((int8) v->parm3 < 0)
@@ -142,32 +142,32 @@ void AgiEngine::motion_followego(struct vt_entry *v) {
}
}
-void AgiEngine::motion_moveobj(struct vt_entry *v) {
- v->direction = get_direction(v->x_pos, v->y_pos, v->parm1, v->parm2, v->step_size);
+void AgiEngine::motionMoveObj(struct VtEntry *v) {
+ v->direction = getDirection(v->xPos, v->yPos, v->parm1, v->parm2, v->stepSize);
/* Update V6 if ego */
- if (is_ego_view(v))
- game.vars[V_ego_dir] = v->direction;
+ if (isEgoView(v))
+ _game.vars[vEgoDir] = v->direction;
if (v->direction == 0)
- in_destination(v);
+ inDestination(v);
}
-void AgiEngine::check_motion(struct vt_entry *v) {
+void AgiEngine::checkMotion(struct VtEntry *v) {
switch (v->motion) {
case MOTION_WANDER:
- motion_wander(v);
+ motionWander(v);
break;
case MOTION_FOLLOW_EGO:
- motion_followego(v);
+ motionFollowEgo(v);
break;
case MOTION_MOVE_OBJ:
- motion_moveobj(v);
+ motionMoveObj(v);
break;
}
- if ((game.block.active && (~v->flags & IGNORE_BLOCKS)) && v->direction)
- changepos(v);
+ if ((_game.block.active && (~v->flags & IGNORE_BLOCKS)) && v->direction)
+ changePos(v);
}
/*
@@ -177,13 +177,13 @@ void AgiEngine::check_motion(struct vt_entry *v) {
/**
*
*/
-void AgiEngine::check_all_motions() {
- struct vt_entry *v;
+void AgiEngine::checkAllMotions() {
+ struct VtEntry *v;
- for (v = game.view_table; v < &game.view_table[MAX_VIEWTABLE]; v++) {
+ for (v = _game.viewTable; v < &_game.viewTable[MAX_VIEWTABLE]; v++) {
if ((v->flags & (ANIMATED | UPDATE | DRAWN)) == (ANIMATED | UPDATE | DRAWN)
- && v->step_time_count == 1) {
- check_motion(v);
+ && v->stepTimeCount == 1) {
+ checkMotion(v);
}
}
}
@@ -194,14 +194,14 @@ void AgiEngine::check_all_motions() {
* type motion that * has reached its final destination coordinates.
* @param v Pointer to view table entry
*/
-void AgiEngine::in_destination(struct vt_entry *v) {
+void AgiEngine::inDestination(struct VtEntry *v) {
if (v->motion == MOTION_MOVE_OBJ) {
- v->step_size = v->parm3;
+ v->stepSize = v->parm3;
setflag(v->parm4, true);
}
v->motion = MOTION_NORMAL;
- if (is_ego_view(v))
- game.player_control = true;
+ if (isEgoView(v))
+ _game.playerControl = true;
}
/**
@@ -210,8 +210,8 @@ void AgiEngine::in_destination(struct vt_entry *v) {
* after setting the motion mode to MOTION_MOVE_OBJ.
* @param v Pointer to view table entry
*/
-void AgiEngine::move_obj(struct vt_entry *v) {
- motion_moveobj(v);
+void AgiEngine::moveObj(struct VtEntry *v) {
+ motionMoveObj(v);
}
/**
@@ -224,9 +224,9 @@ void AgiEngine::move_obj(struct vt_entry *v) {
* @param y y coordinate of the object
* @param s step size
*/
-int AgiEngine::get_direction(int x0, int y0, int x, int y, int s) {
- int dir_table[9] = { 8, 1, 2, 7, 0, 3, 6, 5, 4 };
- return dir_table[check_step(x - x0, s) + 3 * check_step(y - y0, s)];
+int AgiEngine::getDirection(int x0, int y0, int x, int y, int s) {
+ int dirTable[9] = { 8, 1, 2, 7, 0, 3, 6, 5, 4 };
+ return dirTable[checkStep(x - x0, s) + 3 * checkStep(y - y0, s)];
}
-} // End of namespace Agi
+} // End of namespace Agi
diff --git a/engines/agi/objects.cpp b/engines/agi/objects.cpp
index 759d8b0713..8eab5eac43 100644
--- a/engines/agi/objects.cpp
+++ b/engines/agi/objects.cpp
@@ -28,20 +28,20 @@
namespace Agi {
-int AgiEngine::alloc_objects(int n) {
- if ((objects = (agi_object *)calloc(n, sizeof(struct agi_object))) == NULL)
- return err_NotEnoughMemory;
+int AgiEngine::allocObjects(int n) {
+ if ((_objects = (AgiObject *)calloc(n, sizeof(struct AgiObject))) == NULL)
+ return errNotEnoughMemory;
- return err_OK;
+ return errOK;
}
-int AgiEngine::decode_objects(uint8 *mem, uint32 flen) {
+int AgiEngine::decodeObjects(uint8 *mem, uint32 flen) {
unsigned int i, so, padsize;
- padsize = game.game_flags & ID_AMIGA ? 4 : 3;
+ padsize = _game.gameFlags & ID_AMIGA ? 4 : 3;
- game.num_objects = 0;
- objects = NULL;
+ _game.numObjects = 0;
+ _objects = NULL;
/* check if first pointer exceeds file size
* if so, its encrypted, else it is not
@@ -58,49 +58,48 @@ int AgiEngine::decode_objects(uint8 *mem, uint32 flen) {
*/
if (READ_LE_UINT16(mem) / padsize >= 256) {
/* die with no error! AGDS game needs not to die to work!! :( */
- return err_OK;
+ return errOK;
}
- game.num_objects = READ_LE_UINT16(mem) / padsize;
- debugC(5, kDebugLevelResources, "num_objects = %d (padsize = %d)", game.num_objects, padsize);
+ _game.numObjects = READ_LE_UINT16(mem) / padsize;
+ debugC(5, kDebugLevelResources, "num_objects = %d (padsize = %d)", _game.numObjects, padsize);
- if (alloc_objects(game.num_objects) != err_OK)
- return err_NotEnoughMemory;
+ if (allocObjects(_game.numObjects) != errOK)
+ return errNotEnoughMemory;
/* build the object list */
- for (i = 0, so = padsize; i < game.num_objects; i++, so += padsize) {
+ for (i = 0, so = padsize; i < _game.numObjects; i++, so += padsize) {
int offset;
- (objects + i)->location = *(mem + so + 2);
+ (_objects + i)->location = *(mem + so + 2);
offset = READ_LE_UINT16(mem + so) + padsize;
if ((uint) offset < flen) {
- (objects + i)->name = (char *)strdup((const char *)mem + offset);
+ (_objects + i)->name = (char *)strdup((const char *)mem + offset);
} else {
printf("ERROR: object %i name beyond object filesize! "
"(%04x > %04x)\n", i, offset, flen);
- (objects + i)->name = strdup("");
+ (_objects + i)->name = strdup("");
}
}
- report("Reading objects: %d objects read.\n", game.num_objects);
-
- return err_OK;
+ report("Reading objects: %d objects read.\n", _game.numObjects);
+ return errOK;
}
-int AgiEngine::load_objects(const char *fname) {
+int AgiEngine::loadObjects(const char *fname) {
Common::File fp;
uint32 flen;
uint8 *mem;
- objects = NULL;
- game.num_objects = 0;
+ _objects = NULL;
+ _game.numObjects = 0;
debugC(5, kDebugLevelResources, "(fname = %s)", fname);
report("Loading objects: %s\n", fname);
if (!fp.open(fname))
- return err_BadFileOpen;
+ return errBadFileOpen;
fp.seek(0, SEEK_END);
flen = fp.pos();
@@ -108,52 +107,52 @@ int AgiEngine::load_objects(const char *fname) {
if ((mem = (uint8 *)calloc(1, flen + 32)) == NULL) {
fp.close();
- return err_NotEnoughMemory;
+ return errNotEnoughMemory;
}
fp.read(mem, flen);
fp.close();
- decode_objects(mem, flen);
+ decodeObjects(mem, flen);
free(mem);
- return err_OK;
+ return errOK;
}
-void AgiEngine::unload_objects() {
+void AgiEngine::unloadObjects() {
unsigned int i;
- if (objects != NULL) {
- for (i = 0; i < game.num_objects; i++) {
- free(objects[i].name);
- objects[i].name = NULL;
+ if (_objects != NULL) {
+ for (i = 0; i < _game.numObjects; i++) {
+ free(_objects[i].name);
+ _objects[i].name = NULL;
}
- free(objects);
- objects = NULL;
+ free(_objects);
+ _objects = NULL;
}
}
-void AgiEngine::object_set_location(unsigned int n, int i) {
- if (n >= game.num_objects) {
+void AgiEngine::objectSetLocation(unsigned int n, int i) {
+ if (n >= _game.numObjects) {
report("Error: Can't access object %d.\n", n);
return;
}
- objects[n].location = i;
+ _objects[n].location = i;
}
-int AgiEngine::object_get_location(unsigned int n) {
- if (n >= game.num_objects) {
+int AgiEngine::objectGetLocation(unsigned int n) {
+ if (n >= _game.numObjects) {
report("Error: Can't access object %d.\n", n);
return 0;
}
- return objects[n].location;
+ return _objects[n].location;
}
-const char *AgiEngine::object_name(unsigned int n) {
- if (n >= game.num_objects) {
+const char *AgiEngine::objectName(unsigned int n) {
+ if (n >= _game.numObjects) {
report("Error: Can't access object %d.\n", n);
return "";
}
- return objects[n].name;
+ return _objects[n].name;
}
-} // End of namespace Agi
+} // End of namespace Agi
diff --git a/engines/agi/op_cmd.cpp b/engines/agi/op_cmd.cpp
index 8fa0f3762c..11f20fa7b6 100644
--- a/engines/agi/op_cmd.cpp
+++ b/engines/agi/op_cmd.cpp
@@ -43,20 +43,20 @@ namespace Agi {
#define p5 (p[5])
#define p6 (p[6])
-#define game g_agi->game
+#define game g_agi->_game
#define g_sprites g_agi->_sprites
#define g_sound g_agi->_sound
#define g_text g_agi->_text
#define g_gfx g_agi->_gfx
#define g_picture g_agi->_picture
-#define ip cur_logic->cIP
-#define vt game.view_table[p0]
+#define ip curLogic->cIP
+#define vt game.viewTable[p0]
-static struct agi_logic *cur_logic;
+static struct AgiLogic *curLogic;
static AgiEngine *g_agi;
-int timer_hack; /* 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)
@@ -152,11 +152,11 @@ cmd(toggle_v) {
}
cmd(new_room) {
- g_agi->new_room(p0);
+ g_agi->newRoom(p0);
}
cmd(new_room_f) {
- g_agi->new_room(_v[p0]);
+ g_agi->newRoom(_v[p0]);
}
cmd(load_view) {
@@ -254,59 +254,59 @@ cmd(set_upper_left) { /* do nothing (AGI 2.917) */
}
cmd(start_update) {
- g_agi->start_update(&vt);
+ g_agi->startUpdate(&vt);
}
cmd(stop_update) {
- g_agi->stop_update(&vt);
+ g_agi->stopUpdate(&vt);
}
cmd(current_view) {
- _v[p1] = vt.current_view;
+ _v[p1] = vt.currentView;
}
cmd(current_cel) {
- _v[p1] = vt.current_cel;
+ _v[p1] = vt.currentCel;
debugC(4, kDebugLevelScripts, "v%d=%d", p1, _v[p1]);
}
cmd(current_loop) {
- _v[p1] = vt.current_loop;
+ _v[p1] = vt.currentLoop;
}
cmd(last_cel) {
- _v[p1] = vt.loop_data->num_cels - 1;
+ _v[p1] = vt.loopData->numCels - 1;
}
cmd(set_cel) {
- g_agi->set_cel(&vt, p1);
+ g_agi->setCel(&vt, p1);
vt.flags &= ~DONTUPDATE;
}
cmd(set_cel_f) {
- g_agi->set_cel(&vt, _v[p1]);
+ g_agi->setCel(&vt, _v[p1]);
vt.flags &= ~DONTUPDATE;
}
cmd(set_view) {
debugC(4, kDebugLevelScripts, "o%d, %d", p0, p1);
- g_agi->set_view(&vt, p1);
+ g_agi->setView(&vt, p1);
}
cmd(set_view_f) {
- g_agi->set_view(&vt, _v[p1]);
+ g_agi->setView(&vt, _v[p1]);
}
cmd(set_loop) {
- g_agi->set_loop(&vt, p1);
+ g_agi->setLoop(&vt, p1);
}
cmd(set_loop_f) {
- g_agi->set_loop(&vt, _v[p1]);
+ g_agi->setLoop(&vt, _v[p1]);
}
cmd(number_of_loops) {
- _v[p1] = vt.num_loops;
+ _v[p1] = vt.numLoops;
}
cmd(fix_loop) {
@@ -318,15 +318,15 @@ cmd(release_loop) {
}
cmd(step_size) {
- vt.step_size = _v[p1];
+ vt.stepSize = _v[p1];
}
cmd(step_time) {
- vt.step_time = vt.step_time_count = _v[p1];
+ vt.stepTime = vt.stepTimeCount = _v[p1];
}
cmd(cycle_time) {
- vt.cycle_time = vt.cycle_time_count = _v[p1];
+ vt.cycleTime = vt.cycleTimeCount = _v[p1];
}
cmd(stop_cycling) {
@@ -356,104 +356,104 @@ cmd(get_dir) {
}
cmd(get_room_f) {
- _v[p1] = g_agi->object_get_location(_v[p0]);
+ _v[p1] = g_agi->objectGetLocation(_v[p0]);
}
cmd(put) {
- g_agi->object_set_location(p0, _v[p1]);
+ g_agi->objectSetLocation(p0, _v[p1]);
}
cmd(put_f) {
- g_agi->object_set_location(_v[p0], _v[p1]);
+ g_agi->objectSetLocation(_v[p0], _v[p1]);
}
cmd(drop) {
- g_agi->object_set_location(p0, 0);
+ g_agi->objectSetLocation(p0, 0);
}
cmd(get) {
- g_agi->object_set_location(p0, EGO_OWNED);
+ g_agi->objectSetLocation(p0, EGO_OWNED);
}
cmd(get_f) {
- g_agi->object_set_location(_v[p0], EGO_OWNED);
+ g_agi->objectSetLocation(_v[p0], EGO_OWNED);
}
cmd(word_to_string) {
- strcpy(game.strings[p0], game.ego_words[p1].word);
+ strcpy(game.strings[p0], game.egoWords[p1].word);
}
cmd(open_dialogue) {
debugC(4, kDebugLevelScripts, "p0 = %d", p0);
- game.has_window = true;
+ game.hasWindow = true;
}
cmd(close_dialogue) {
debugC(4, kDebugLevelScripts, "p0 = %d", p0);
- game.has_window = false;
+ game.hasWindow = false;
}
cmd(close_window) {
- g_agi->close_window();
+ g_agi->closeWindow();
}
cmd(status_line_on) {
- game.status_line = true;
- g_agi->write_status();
+ game.statusLine = true;
+ g_agi->writeStatus();
}
cmd(status_line_off) {
- game.status_line = false;
- g_agi->write_status();
+ game.statusLine = false;
+ g_agi->writeStatus();
}
cmd(show_obj) {
- g_sprites->show_obj(p0);
+ g_sprites->showObj(p0);
}
cmd(show_obj_v) {
- g_sprites->show_obj(_v[p0]);
+ g_sprites->showObj(_v[p0]);
}
cmd(sound) {
- g_sound->start_sound(p0, p1);
+ g_sound->startSound(p0, p1);
}
cmd(stop_sound) {
- g_sound->stop_sound();
+ g_sound->stopSound();
}
cmd(menu_input) {
- g_agi->new_input_mode(INPUT_MENU);
+ g_agi->newInputMode(INPUT_MENU);
}
cmd(enable_item) {
- g_agi->menu->set_item(p0, true);
+ g_agi->_menu->setItem(p0, true);
}
cmd(disable_item) {
- g_agi->menu->set_item(p0, false);
+ g_agi->_menu->setItem(p0, false);
}
cmd(submit_menu) {
- g_agi->menu->submit();
+ g_agi->_menu->submit();
}
cmd(set_scan_start) {
- cur_logic->sIP = cur_logic->cIP;
+ curLogic->sIP = curLogic->cIP;
}
cmd(reset_scan_start) {
- cur_logic->sIP = 2;
+ curLogic->sIP = 2;
}
cmd(save_game) {
- game.simple_save ? g_agi->saveGameSimple() : g_agi->saveGameDialog();
+ game.simpleSave ? g_agi->saveGameSimple() : g_agi->saveGameDialog();
}
cmd(load_game) {
assert(1);
- game.simple_save ? g_agi->loadGameSimple() : g_agi->loadGameDialog();
+ game.simpleSave ? g_agi->loadGameSimple() : g_agi->loadGameDialog();
}
cmd(init_disk) { /* do nothing */
@@ -469,7 +469,7 @@ cmd(trace_info) { /* do nothing */
}
cmd(show_mem) {
- g_agi->message_box("Enough memory");
+ g_agi->messageBox("Enough memory");
}
cmd(init_joy) { /* do nothing */ ;
@@ -497,7 +497,7 @@ cmd(obj_status_f) {
* unk_181: Deactivate keypressed control (default control of ego)
*/
cmd(set_simple) {
- game.simple_save = true;
+ game.simpleSave = true;
}
cmd(pop_script) {
@@ -533,32 +533,32 @@ cmd(release_key) {
}
cmd(adj_ego_move_to_x_y) {
- game.view_table[0].flags |= ADJ_EGO_XY;
+ game.viewTable[0].flags |= ADJ_EGO_XY;
}
cmd(parse) {
- _v[V_word_not_found] = 0;
- g_agi->setflag(F_entered_cli, false);
- g_agi->setflag(F_said_accepted_input, false);
+ _v[vWordNotFound] = 0;
+ g_agi->setflag(fEnteredCli, false);
+ g_agi->setflag(fSaidAcceptedInput, false);
- g_agi->dictionary_words(g_agi->agi_sprintf(game.strings[p0]));
+ g_agi->dictionaryWords(g_agi->agiSprintf(game.strings[p0]));
}
cmd(call) {
- int old_cIP;
- int old_lognum;
+ int oldCIP;
+ int oldLognum;
/* CM: we don't save sIP because set.scan.start can be
* used in a called script (fixes xmas demo)
*/
- old_cIP = cur_logic->cIP;
- old_lognum = game.lognum;
+ oldCIP = curLogic->cIP;
+ oldLognum = game.lognum;
- g_agi->run_logic(p0);
+ g_agi->runLogic(p0);
- game.lognum = old_lognum;
- cur_logic = &game.logics[game.lognum];
- cur_logic->cIP = old_cIP;
+ game.lognum = oldLognum;
+ curLogic = &game.logics[game.lognum];
+ curLogic->cIP = oldCIP;
}
cmd(call_f) {
@@ -567,26 +567,26 @@ cmd(call_f) {
cmd(draw_pic) {
debugC(6, kDebugLevelScripts, "=== draw pic %d ===", _v[p0]);
- g_sprites->erase_both();
- g_picture->decode_picture(_v[p0], true);
- g_sprites->blit_both();
- game.picture_shown = 0;
+ g_sprites->eraseBoth();
+ g_picture->decodePicture(_v[p0], true);
+ g_sprites->blitBoth();
+ game.pictureShown = 0;
debugC(6, kDebugLevelScripts, "--- end of draw pic %d ---", _v[p0]);
}
cmd(show_pic) {
debugC(6, kDebugLevelScripts, "=== show pic ===");
- g_agi->setflag(F_output_mode, false);
+ g_agi->setflag(fOutputMode, false);
cmd_close_window(NULL);
- g_picture->show_pic();
- game.picture_shown = 1;
+ g_picture->showPic();
+ game.pictureShown = 1;
debugC(6, kDebugLevelScripts, "--- end of show pic ---");
}
cmd(load_pic) {
- g_sprites->erase_both();
+ g_sprites->eraseBoth();
g_agi->agiLoadResource(rPICTURE, _v[p0]);
- g_sprites->blit_both();
+ g_sprites->blitBoth();
}
cmd(discard_pic) {
@@ -596,23 +596,23 @@ cmd(discard_pic) {
cmd(overlay_pic) {
debugC(6, kDebugLevelScripts, "--- overlay pic ---");
- g_sprites->erase_both();
- g_picture->decode_picture(_v[p0], false);
- g_sprites->blit_both();
- game.picture_shown = 0;
- g_sprites->commit_both();
+ g_sprites->eraseBoth();
+ g_picture->decodePicture(_v[p0], false);
+ g_sprites->blitBoth();
+ game.pictureShown = 0;
+ g_sprites->commitBoth();
}
cmd(show_pri_screen) {
g_agi->_debug.priority = 1;
- g_sprites->erase_both();
- g_picture->show_pic();
- g_sprites->blit_both();
- g_agi->wait_key();
+ g_sprites->eraseBoth();
+ g_picture->showPic();
+ g_sprites->blitBoth();
+ g_agi->waitKey();
g_agi->_debug.priority = 0;
- g_sprites->erase_both();
- g_picture->show_pic();
- g_sprites->blit_both();
+ g_sprites->eraseBoth();
+ g_picture->showPic();
+ g_sprites->blitBoth();
}
cmd(animate_obj) {
@@ -629,37 +629,37 @@ cmd(animate_obj) {
cmd(unanimate_all) {
int i;
for (i = 0; i < MAX_VIEWTABLE; i++)
- game.view_table[i].flags &= ~(ANIMATED | DRAWN);
+ game.viewTable[i].flags &= ~(ANIMATED | DRAWN);
}
cmd(draw) {
if (vt.flags & DRAWN)
return;
- if (vt.y_size <= 0 || vt.x_size <= 0)
+ if (vt.ySize <= 0 || vt.xSize <= 0)
return;
debugC(4, kDebugLevelScripts, "draw entry %d", vt.entry);
vt.flags |= UPDATE;
if (g_agi->agiGetRelease() >= 0x3000) {
- g_agi->set_loop(&vt, vt.current_loop);
- g_agi->set_cel(&vt, vt.current_cel);
+ g_agi->setLoop(&vt, vt.currentLoop);
+ g_agi->setCel(&vt, vt.currentCel);
}
- g_agi->fix_position(p0);
- vt.x_pos2 = vt.x_pos;
- vt.y_pos2 = vt.y_pos;
- vt.cel_data_2 = vt.cel_data;
- g_sprites->erase_upd_sprites();
+ g_agi->fixPosition(p0);
+ vt.xPos2 = vt.xPos;
+ vt.yPos2 = vt.yPos;
+ vt.celData2 = vt.celData;
+ g_sprites->eraseUpdSprites();
vt.flags |= DRAWN;
if (g_agi->agiGetRelease() <= 0x2440) /* See bug #546562 */
vt.flags |= ANIMATED;
- g_sprites->blit_upd_sprites();
+ g_sprites->blitUpdSprites();
vt.flags &= ~DONTUPDATE;
- g_sprites->commit_block(vt.x_pos, vt.y_pos - vt.y_size + 1, vt.x_pos + vt.x_size - 1, vt.y_pos);
+ g_sprites->commitBlock(vt.xPos, vt.yPos - vt.ySize + 1, vt.xPos + vt.xSize - 1, vt.yPos);
debugC(4, kDebugLevelScripts, "vt entry #%d flags = %02x", p0, vt.flags);
}
@@ -668,32 +668,32 @@ cmd(erase) {
if (~vt.flags & DRAWN)
return;
- g_sprites->erase_upd_sprites();
+ g_sprites->eraseUpdSprites();
if (vt.flags & UPDATE) {
vt.flags &= ~DRAWN;
} else {
- g_sprites->erase_nonupd_sprites();
+ g_sprites->eraseNonupdSprites();
vt.flags &= ~DRAWN;
- g_sprites->blit_nonupd_sprites();
+ g_sprites->blitNonupdSprites();
}
- g_sprites->blit_upd_sprites();
+ g_sprites->blitUpdSprites();
- g_sprites->commit_block(vt.x_pos, vt.y_pos - vt.y_size + 1, vt.x_pos + vt.x_size - 1, vt.y_pos);
+ g_sprites->commitBlock(vt.xPos, vt.yPos - vt.ySize + 1, vt.xPos + vt.xSize - 1, vt.yPos);
}
cmd(position) {
- vt.x_pos = vt.x_pos2 = p1;
- vt.y_pos = vt.y_pos2 = p2;
+ vt.xPos = vt.xPos2 = p1;
+ vt.yPos = vt.yPos2 = p2;
}
cmd(position_f) {
- vt.x_pos = vt.x_pos2 = _v[p1];
- vt.y_pos = vt.y_pos2 = _v[p2];
+ vt.xPos = vt.xPos2 = _v[p1];
+ vt.yPos = vt.yPos2 = _v[p2];
}
cmd(get_posn) {
- game.vars[p1] = (unsigned char)vt.x_pos;
- game.vars[p2] = (unsigned char)vt.y_pos;
+ game.vars[p1] = (unsigned char)vt.xPos;
+ game.vars[p2] = (unsigned char)vt.yPos;
}
cmd(reposition) {
@@ -702,45 +702,45 @@ cmd(reposition) {
debugC(4, kDebugLevelScripts, "dx=%d, dy=%d", dx, dy);
vt.flags |= UPDATE_POS;
- if (dx < 0 && vt.x_pos < -dx)
- vt.x_pos = 0;
+ if (dx < 0 && vt.xPos < -dx)
+ vt.xPos = 0;
else
- vt.x_pos += dx;
+ vt.xPos += dx;
- if (dy < 0 && vt.y_pos < -dy)
- vt.y_pos = 0;
+ if (dy < 0 && vt.yPos < -dy)
+ vt.yPos = 0;
else
- vt.y_pos += dy;
+ vt.yPos += dy;
- g_agi->fix_position(p0);
+ g_agi->fixPosition(p0);
}
cmd(reposition_to) {
- vt.x_pos = p1;
- vt.y_pos = p2;
+ vt.xPos = p1;
+ vt.yPos = p2;
vt.flags |= UPDATE_POS;
- g_agi->fix_position(p0);
+ g_agi->fixPosition(p0);
}
cmd(reposition_to_f) {
- vt.x_pos = _v[p1];
- vt.y_pos = _v[p2];
+ vt.xPos = _v[p1];
+ vt.yPos = _v[p2];
vt.flags |= UPDATE_POS;
- g_agi->fix_position(p0);
+ g_agi->fixPosition(p0);
}
cmd(add_to_pic) {
- g_sprites->add_to_pic(p0, p1, p2, p3, p4, p5, p6);
+ g_sprites->addToPic(p0, p1, p2, p3, p4, p5, p6);
}
cmd(add_to_pic_f) {
- g_sprites->add_to_pic(_v[p0], _v[p1], _v[p2], _v[p3], _v[p4], _v[p5], _v[p6]);
+ g_sprites->addToPic(_v[p0], _v[p1], _v[p2], _v[p3], _v[p4], _v[p5], _v[p6]);
}
cmd(force_update) {
- g_sprites->erase_both();
- g_sprites->blit_both();
- g_sprites->commit_both();
+ g_sprites->eraseBoth();
+ g_sprites->blitBoth();
+ g_sprites->commitBoth();
}
cmd(reverse_loop) {
@@ -780,31 +780,31 @@ cmd(stop_motion) {
vt.direction = 0;
vt.motion = MOTION_NORMAL;
if (p0 == 0) { /* ego only */
- _v[V_ego_dir] = 0;
- game.player_control = false;
+ _v[vEgoDir] = 0;
+ game.playerControl = false;
}
}
cmd(start_motion) {
vt.motion = MOTION_NORMAL;
if (p0 == 0) { /* ego only */
- _v[V_ego_dir] = 0;
- game.player_control = true;
+ _v[vEgoDir] = 0;
+ game.playerControl = true;
}
}
cmd(player_control) {
- game.player_control = true;
- game.view_table[0].motion = MOTION_NORMAL;
+ game.playerControl = true;
+ game.viewTable[0].motion = MOTION_NORMAL;
}
cmd(program_control) {
- game.player_control = false;
+ game.playerControl = false;
}
cmd(follow_ego) {
vt.motion = MOTION_FOLLOW_EGO;
- vt.parm1 = p1 > vt.step_size ? p1 : vt.step_size;
+ vt.parm1 = p1 > vt.stepSize ? p1 : vt.stepSize;
vt.parm2 = p2;
vt.parm3 = 0xff;
g_agi->setflag(p2, false);
@@ -817,54 +817,54 @@ cmd(move_obj) {
vt.motion = MOTION_MOVE_OBJ;
vt.parm1 = p1;
vt.parm2 = p2;
- vt.parm3 = vt.step_size;
+ vt.parm3 = vt.stepSize;
vt.parm4 = p4;
if (p3 != 0)
- vt.step_size = p3;
+ vt.stepSize = p3;
g_agi->setflag(p4, false);
vt.flags |= UPDATE;
if (p0 == 0)
- game.player_control = false;
+ game.playerControl = false;
/* AGI 2.272 (ddp, xmas) doesn't call move_obj! */
if (g_agi->agiGetRelease() > 0x2272)
- g_agi->move_obj(&vt);
+ g_agi->moveObj(&vt);
}
cmd(move_obj_f) {
vt.motion = MOTION_MOVE_OBJ;
vt.parm1 = _v[p1];
vt.parm2 = _v[p2];
- vt.parm3 = vt.step_size;
+ vt.parm3 = vt.stepSize;
vt.parm4 = p4;
if (_v[p3] != 0)
- vt.step_size = _v[p3];
+ vt.stepSize = _v[p3];
g_agi->setflag(p4, false);
vt.flags |= UPDATE;
if (p0 == 0)
- game.player_control = false;
+ game.playerControl = false;
/* AGI 2.272 (ddp, xmas) doesn't call move_obj! */
if (g_agi->agiGetRelease() > 0x2272)
- g_agi->move_obj(&vt);
+ g_agi->moveObj(&vt);
}
cmd(wander) {
if (p0 == 0)
- game.player_control = false;
+ game.playerControl = false;
vt.motion = MOTION_WANDER;
vt.flags |= UPDATE;
}
cmd(set_game_id) {
- if (cur_logic->texts && (p0 - 1) <= cur_logic->num_texts)
- strncpy(game.id, cur_logic->texts[p0 - 1], 8);
+ if (curLogic->texts && (p0 - 1) <= curLogic->numTexts)
+ strncpy(game.id, curLogic->texts[p0 - 1], 8);
else
game.id[0] = 0;
@@ -872,33 +872,33 @@ cmd(set_game_id) {
}
cmd(pause) {
- int tmp = game.clock_enabled;
+ int tmp = game.clockEnabled;
const char *b[] = { "Continue", NULL };
- game.clock_enabled = false;
- g_agi->selection_box(" Game is paused. \n\n\n", b);
- game.clock_enabled = tmp;
+ game.clockEnabled = false;
+ g_agi->selectionBox(" Game is paused. \n\n\n", b);
+ game.clockEnabled = tmp;
}
cmd(set_menu) {
- debugC(4, kDebugLevelScripts, "text %02x of %02x", p0, cur_logic->num_texts);
- if (cur_logic->texts != NULL && p0 < cur_logic->num_texts)
- g_agi->menu->add(cur_logic->texts[p0 - 1]);
+ 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, cur_logic->num_texts);
- if (cur_logic->texts != NULL && p0 <= cur_logic->num_texts)
- g_agi->menu->add_item(cur_logic->texts[p0 - 1], p1);
+ 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);
}
cmd(version) {
- char ver_msg[64];
- char ver2_msg[] =
+ char verMsg[64];
+ char ver2Msg[] =
"\n"
" \n\n"
" Emulating Sierra AGI v%x.%03x\n";
- char ver3_msg[] =
+ char ver3Msg[] =
"\n"
" \n\n"
" Emulating AGI v%x.002.%03x\n";
@@ -909,65 +909,65 @@ cmd(version) {
int gap;
int len;
- sprintf(ver_msg, TITLE " v%s", gScummVMVersion);
+ sprintf(verMsg, TITLE " v%s", gScummVMVersion);
ver = g_agi->agiGetRelease();
maj = (ver >> 12) & 0xf;
min = ver & 0xfff;
- q = maj == 2 ? ver2_msg : ver3_msg;
+ q = maj == 2 ? ver2Msg : ver3Msg;
r = strchr(q + 1, '\n');
/* insert our version into the other version */
- len = strlen(ver_msg);
+ len = strlen(verMsg);
gap = r - q;
if(gap < 0)
gap = 0;
else
gap = (gap - len) / 2;
- strncpy(q + 1 + gap, ver_msg, strlen(ver_msg));
+ strncpy(q + 1 + gap, verMsg, strlen(verMsg));
sprintf(msg, q, maj, min);
- g_agi->message_box(msg);
+ g_agi->messageBox(msg);
}
cmd(configure_screen) {
- game.line_min_print = p0;
- game.line_user_input = p1;
- game.line_status = p2;
+ game.lineMinPrint = p0;
+ game.lineUserInput = p1;
+ game.lineStatus = p2;
}
cmd(text_screen) {
debugC(4, kDebugLevelScripts, "switching to text mode");
- game.gfx_mode = false;
+ game.gfxMode = false;
/*
* Simulates the "bright background bit" of the PC video
* controller.
*/
- if (game.color_bg)
- game.color_bg |= 0x08;
- g_gfx->clearScreen(game.color_bg);
+ if (game.colorBg)
+ game.colorBg |= 0x08;
+ g_gfx->clearScreen(game.colorBg);
}
cmd(graphics) {
debugC(4, kDebugLevelScripts, "switching to graphics mode");
- if (!game.gfx_mode) {
- game.gfx_mode = true;
+ if (!game.gfxMode) {
+ game.gfxMode = true;
g_gfx->clearScreen(0);
- g_picture->show_pic();
- g_agi->write_status();
- g_agi->write_prompt();
+ g_picture->showPic();
+ g_agi->writeStatus();
+ g_agi->writePrompt();
}
}
cmd(set_text_attribute) {
- game.color_fg = p0;
- game.color_bg = p1;
+ game.colorFg = p0;
+ game.colorBg = p1;
- if (game.gfx_mode) {
- if (game.color_bg != 0) {
- game.color_fg = 0;
- game.color_bg = 15;
+ if (game.gfxMode) {
+ if (game.colorBg != 0) {
+ game.colorFg = 0;
+ game.colorBg = 15;
}
}
}
@@ -979,13 +979,13 @@ cmd(status) {
cmd(quit) {
const char *buttons[] = { "Quit", "Continue", NULL };
- g_sound->stop_sound();
+ g_sound->stopSound();
if (p0) {
- game.quit_prog_now = true;
+ game.quitProgNow = true;
} else {
- if (g_agi->selection_box
+ if (g_agi->selectionBox
(" Quit the game, or continue? \n\n\n", buttons) == 0) {
- game.quit_prog_now = true;
+ game.quitProgNow = true;
}
}
}
@@ -994,27 +994,27 @@ cmd(restart_game) {
const char *buttons[] = { "Restart", "Continue", NULL };
int sel;
- g_sound->stop_sound();
- sel = g_agi->getflag(F_auto_restart) ? 1 :
- g_agi->selection_box(" Restart game, or continue? \n\n\n", buttons);
+ g_sound->stopSound();
+ sel = g_agi->getflag(fAutoRestart) ? 1 :
+ g_agi->selectionBox(" Restart game, or continue? \n\n\n", buttons);
if (sel == 0) {
- game.quit_prog_now = 0xff;
- g_agi->setflag(F_restart_game, true);
- g_agi->menu->enable_all();
+ game.quitProgNow = 0xff;
+ g_agi->setflag(fRestartGame, true);
+ g_agi->_menu->enableAll();
}
}
cmd(distance) {
int16 x1, y1, x2, y2, d;
- struct vt_entry *v0 = &game.view_table[p0];
- struct vt_entry *v1 = &game.view_table[p1];
+ struct VtEntry *v0 = &game.viewTable[p0];
+ struct VtEntry *v1 = &game.viewTable[p1];
if (v0->flags & DRAWN && v1->flags & DRAWN) {
- x1 = v0->x_pos + v0->x_size / 2;
- y1 = v0->y_pos;
- x2 = v1->x_pos + v1->x_size / 2;
- y2 = v1->y_pos;
+ x1 = v0->xPos + v0->xSize / 2;
+ y1 = v0->yPos;
+ x2 = v1->xPos + v1->xSize / 2;
+ y2 = v1->yPos;
d = abs(x1 - x2) + abs(y1 - y2);
if (d > 0xfe)
d = 0xfe;
@@ -1026,14 +1026,14 @@ cmd(distance) {
cmd(accept_input) {
debugC(4, kDebugLevelScripts | kDebugLevelInput, "input normal");
- g_agi->new_input_mode(INPUT_NORMAL);
- game.input_enabled = true;
+ g_agi->newInputMode(INPUT_NORMAL);
+ game.inputEnabled = true;
}
cmd(prevent_input) {
debugC(4, kDebugLevelScripts | kDebugLevelInput, "no input");
- g_agi->new_input_mode(INPUT_NONE);
- game.input_enabled = false;
+ g_agi->newInputMode(INPUT_NONE);
+ game.inputEnabled = false;
}
cmd(get_string) {
@@ -1053,51 +1053,51 @@ cmd(get_string) {
if (col > 39)
col = 39;
- g_agi->new_input_mode(INPUT_GETSTRING);
+ g_agi->newInputMode(INPUT_GETSTRING);
- if (cur_logic->texts != NULL && cur_logic->num_texts >= tex) {
- int len = strlen(cur_logic->texts[tex]);
- g_agi->print_text(cur_logic->texts[tex], 0, col, row, len, game.color_fg, game.color_bg);
- g_agi->get_string(col + len - 1, row, p4, p0);
+ 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 */
- g_gfx->printCharacter((col + len), row, game.cursor_char, game.color_fg, game.color_bg);
+ g_gfx->printCharacter((col + len), row, game.cursorChar, game.colorFg, game.colorBg);
}
do {
- g_agi->main_cycle();
- } while (game.input_mode == INPUT_GETSTRING);
+ g_agi->mainCycle();
+ } while (game.inputMode == INPUT_GETSTRING);
}
cmd(get_num) {
debugC(4, kDebugLevelScripts, "%d %d", p0, p1);
- g_agi->new_input_mode(INPUT_GETSTRING);
+ g_agi->newInputMode(INPUT_GETSTRING);
- if (cur_logic->texts != NULL && cur_logic->num_texts >= (p0 - 1)) {
- int len = strlen(cur_logic->texts[p0 - 1]);
- g_agi->print_text(cur_logic->texts[p0 - 1], 0, 0, 22, len, game.color_fg, game.color_bg);
- g_agi->get_string(len - 1, 22, 3, MAX_STRINGS);
+ 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 */
- g_gfx->printCharacter((p3 + len), 22, game.cursor_char, game.color_fg, game.color_bg);
+ g_gfx->printCharacter((p3 + len), 22, game.cursorChar, game.colorFg, game.colorBg);
}
do {
- g_agi->main_cycle();
- } while (game.input_mode == INPUT_GETSTRING);
+ g_agi->mainCycle();
+ } while (game.inputMode == INPUT_GETSTRING);
_v[p1] = atoi(game.strings[MAX_STRINGS]);
debugC(4, kDebugLevelScripts, "[%s] -> %d", game.strings[MAX_STRINGS], _v[p1]);
- g_agi->clear_lines(22, 22, game.color_bg);
- g_agi->flush_lines(22, 22);
+ g_agi->clearLines(22, 22, game.colorBg);
+ g_agi->flushLines(22, 22);
}
cmd(set_cursor_char) {
- if (cur_logic->texts != NULL && (p0 - 1) <= cur_logic->num_texts) {
- game.cursor_char = *cur_logic->texts[p0 - 1];
+ if (curLogic->texts != NULL && (p0 - 1) <= curLogic->numTexts) {
+ game.cursorChar = *curLogic->texts[p0 - 1];
} else {
/* default */
- game.cursor_char = '_';
+ game.cursorChar = '_';
}
}
@@ -1106,28 +1106,28 @@ cmd(set_key) {
debugC(4, kDebugLevelScripts, "%d %d %d", p0, p1, p2);
- if (game.ev_keyp[p2].data != 0) /* TBC sets c23 (ESC) twice! */
+ if (game.evKeyp[p2].data != 0) /* TBC sets c23 (ESC) twice! */
return;
key = 256 * p1 + p0;
- game.ev_keyp[p2].data = key;
- game.ev_keyp[p2].occured = false;
+ game.evKeyp[p2].data = key;
+ game.evKeyp[p2].occured = false;
}
cmd(set_string) {
/* CM: to avoid crash in Groza (str = 150) */
if (p0 > MAX_STRINGS)
return;
- strcpy(game.strings[p0], cur_logic->texts[p1 - 1]);
+ strcpy(game.strings[p0], curLogic->texts[p1 - 1]);
}
cmd(display) {
- g_agi->print_text(cur_logic->texts[p2 - 1], p1, 0, p0, 40, game.color_fg, game.color_bg);
+ g_agi->printText(curLogic->texts[p2 - 1], p1, 0, p0, 40, game.colorFg, game.colorBg);
}
cmd(display_f) {
debugC(4, kDebugLevelScripts, "p0 = %d", p0);
- g_agi->print_text(cur_logic->texts[_v[p2] - 1], _v[p1], 0, _v[p0], 40, game.color_fg, game.color_bg);
+ g_agi->printText(curLogic->texts[_v[p2] - 1], _v[p1], 0, _v[p0], 40, game.colorFg, game.colorBg);
}
cmd(clear_text_rect) {
@@ -1159,9 +1159,9 @@ cmd(toggle_monitor) {
}
cmd(echo_line) {
- strcpy((char *)game.input_buffer, (const char *)game.echo_buffer);
- game.cursor_pos = strlen((char *)game.input_buffer);
- game.has_prompt = 0;
+ strcpy((char *)game.inputBuffer, (const char *)game.echoBuffer);
+ game.cursorPos = strlen((char *)game.inputBuffer);
+ game.hasPrompt = 0;
}
cmd(clear_lines) {
@@ -1170,33 +1170,33 @@ cmd(clear_lines) {
/* Residence 44 calls clear.lines(24,0,0), see bug #558423 */
l = p1 ? p1 : p0;
- g_agi->clear_lines(p0, l, p2);
- g_agi->flush_lines(p0, l);
+ g_agi->clearLines(p0, l, p2);
+ g_agi->flushLines(p0, l);
}
cmd(print) {
int n = p0 < 1 ? 1 : p0;
- g_agi->print(cur_logic->texts[n - 1], 0, 0, 0);
+ g_agi->print(curLogic->texts[n - 1], 0, 0, 0);
}
cmd(print_f) {
int n = _v[p0] < 1 ? 1 : _v[p0];
- g_agi->print(cur_logic->texts[n - 1], 0, 0, 0);
+ 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(cur_logic->texts[n - 1], 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(cur_logic->texts[n - 1], p1, p2, p3);
+ g_agi->print(curLogic->texts[n - 1], p1, p2, p3);
}
cmd(push_script) {
- if (g_agi->opt.agimouse) {
+ if (g_agi->_opt.agimouse) {
game.vars[27] = g_mouse.button;
game.vars[28] = g_mouse.x / 2;
game.vars[29] = g_mouse.y;
@@ -1216,7 +1216,7 @@ cmd(set_pri_base) {
pri = (i - p0) < 0 ? 4 : (i - p0) * _HEIGHT / x + 5;
if (pri > 15)
pri = 15;
- game.pri_table[i] = pri;
+ game.priTable[i] = pri;
}
}
@@ -1231,22 +1231,22 @@ cmd(shake_screen) {
/* AGI Mouse 1.1 uses shake.screen values between 100 and 109 to
* set the palette.
*/
- if (g_agi->opt.agimouse && p0 >= 100 && p0 < 110) {
+ if (g_agi->_opt.agimouse && p0 >= 100 && p0 < 110) {
report("not implemented: AGI Mouse palettes\n");
return;
} else
g_gfx->shakeStart();
- g_sprites->commit_both(); /* 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);
- g_agi->main_cycle();
+ g_agi->mainCycle();
}
g_gfx->shakeEnd();
}
-static void (*agi_command[183]) (uint8 *) = {
+static void (*agiCommand[183])(uint8 *) = {
NULL, /* 0x00 */
cmd_increment,
cmd_decrement,
@@ -1438,7 +1438,7 @@ static void (*agi_command[183]) (uint8 *) = {
* Execute a logic script
* @param n Number of the logic resource to execute
*/
-int AgiEngine::run_logic(int n) {
+int AgiEngine::runLogic(int n) {
uint8 op = 0;
uint8 p[CMD_BSIZE] = { 0 };
uint8 *code = NULL;
@@ -1446,37 +1446,37 @@ int AgiEngine::run_logic(int n) {
int num = 0;
/* If logic not loaded, load it */
- if (~game.dir_logic[n].flags & RES_LOADED) {
+ if (~_game.dirLogic[n].flags & RES_LOADED) {
debugC(4, kDebugLevelScripts, "logic %d not loaded!", n);
agiLoadResource(rLOGIC, n);
}
- game.lognum = n;
- cur_logic = &game.logics[game.lognum];
+ _game.lognum = n;
+ curLogic = &_game.logics[game.lognum];
- code = cur_logic->data;
- cur_logic->cIP = cur_logic->sIP;
+ code = curLogic->data;
+ curLogic->cIP = curLogic->sIP;
- timer_hack = 0;
- while (ip < game.logics[n].size && !game.quit_prog_now) {
- if (g_agi->_debug.enabled) {
- if (g_agi->_debug.steps > 0) {
- if (g_agi->_debug.logic0 || n) {
- debug_console(n, lCOMMAND_MODE, NULL);
- g_agi->_debug.steps--;
+ timerHack = 0;
+ while (ip < _game.logics[n].size && !_game.quitProgNow) {
+ if (_debug.enabled) {
+ if (_debug.steps > 0) {
+ if (_debug.logic0 || n) {
+ debugConsole(n, lCOMMAND_MODE, NULL);
+ _debug.steps--;
}
} else {
- _sprites->blit_both();
+ _sprites->blitBoth();
do {
- main_cycle();
- } while (!g_agi->_debug.steps && g_agi->_debug.enabled);
- _sprites->erase_both();
+ mainCycle();
+ } while (!_debug.steps && _debug.enabled);
+ _sprites->eraseBoth();
}
}
switch (op = *(code + ip++)) {
case 0xff: /* if (open/close) */
- test_if_code(n);
+ testIfCode(n);
break;
case 0xfe: /* goto */
/* +2 covers goto size */
@@ -1484,36 +1484,36 @@ int AgiEngine::run_logic(int n) {
/* timer must keep running even in goto loops,
* but AGI engine can't do that :(
*/
- if (timer_hack > 20) {
+ if (timerHack > 20) {
g_gfx->pollTimer();
- g_agi->update_timer();
- timer_hack = 0;
+ updateTimer();
+ timerHack = 0;
}
break;
case 0x00: /* return */
return 1;
default:
- num = logic_names_cmd[op].num_args;
+ num = logicNamesCmd[op].numArgs;
memmove(p, code + ip, num);
memset(p + num, 0, CMD_BSIZE - num);
- debugC(2, kDebugLevelScripts, "%s(%d %d %d)", logic_names_cmd[op].name, p[0], p[1], p[2]);
- agi_command[op] (p);
+ debugC(2, kDebugLevelScripts, "%s(%d %d %d)", logicNamesCmd[op].name, p[0], p[1], p[2]);
+ agiCommand[op] (p);
ip += num;
}
- if (game.exit_all_logics)
+ if (_game.exitAllLogics)
break;
}
return 0; /* after executing new.room() */
}
-void AgiEngine::execute_agi_command(uint8 op, uint8 *p) {
- debugC(2, kDebugLevelScripts, "%s(%d %d %d)", logic_names_cmd[op].name, p[0], p[1], p[2]);
+void AgiEngine::executeAgiCommand(uint8 op, uint8 *p) {
+ debugC(2, kDebugLevelScripts, "%s(%d %d %d)", logicNamesCmd[op].name, p[0], p[1], p[2]);
g_agi = this;
- agi_command[op] (p);
+ agiCommand[op] (p);
}
} // End of namespace Agi
diff --git a/engines/agi/op_dbg.cpp b/engines/agi/op_dbg.cpp
index d62c12f5f6..365a0fe5e5 100644
--- a/engines/agi/op_dbg.cpp
+++ b/engines/agi/op_dbg.cpp
@@ -30,7 +30,7 @@
namespace Agi {
static AgiEngine *g_agi;
-#define game g_agi->game
+#define game g_agi->_game
#define ip (game.logics[lognum].cIP)
#define code (game.logics[lognum].data)
@@ -41,7 +41,7 @@ static AgiEngine *g_agi;
#define _L(a,b,c) { a, b, c }
-struct agi_logicnames logic_names_test[] = {
+struct AgiLogicnames logicNamesTest[] = {
_L("", 0, 0x00),
_L("equaln", 2, 0x80),
_L("equalv", 2, 0xC0),
@@ -66,14 +66,14 @@ struct agi_logicnames logic_names_test[] = {
_L("right.posn", 5, 0x00)
};
-struct agi_logicnames logic_names_if[] = {
+struct AgiLogicnames logicNamesIf[] = {
_L("OR", 0, 0x00),
_L("NOT", 0, 0x00),
_L("ELSE", 0, 0x00),
_L("IF", 0, 0x00)
};
-struct agi_logicnames logic_names_cmd[] = {
+struct AgiLogicnames logicNamesCmd[] = {
_L("return", 0, 0x00), /* 00 */
_L("increment", 1, 0x80), /* 01 */
_L("decrement", 1, 0x80), /* 02 */
@@ -269,9 +269,9 @@ struct agi_logicnames logic_names_cmd[] = {
_L(NULL, 0, 0x00)
};
-void AgiEngine::debug_console(int lognum, int mode, const char *str) {
+void AgiEngine::debugConsole(int lognum, int mode, const char *str) {
g_agi = this;
- agi_logicnames *x;
+ AgiLogicnames *x;
uint8 a, c, z;
if (str) {
@@ -286,9 +286,9 @@ void AgiEngine::debug_console(int lognum, int mode, const char *str) {
case 0xFD:
case 0xFE:
case 0xFF:
- x = logic_names_if;
+ x = logicNamesIf;
- if (g_agi->_debug.opcodes) {
+ if (_debug.opcodes) {
report("%02X %02X %02X %02X %02X %02X %02X %02X %02X\n"
" ",
(uint8) * (code + (0 + ip)) & 0xFF,
@@ -304,22 +304,22 @@ void AgiEngine::debug_console(int lognum, int mode, const char *str) {
report("%s ", (x + *(code + ip) - 0xFC)->name);
break;
default:
- x = mode == lCOMMAND_MODE ? logic_names_cmd : logic_names_test;
- a = (unsigned char)(x + *(code + ip))->num_args;
- c = (unsigned char)(x + *(code + ip))->arg_mask;
+ x = mode == lCOMMAND_MODE ? logicNamesCmd : logicNamesTest;
+ a = (unsigned char)(x + *(code + ip))->numArgs;
+ c = (unsigned char)(x + *(code + ip))->argMask;
- if (g_agi->_debug.opcodes) {
+ 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))->name);
@@ -340,4 +340,4 @@ void AgiEngine::debug_console(int lognum, int mode, const char *str) {
report("\n");
}
-} // End of namespace Agi
+} // End of namespace Agi
diff --git a/engines/agi/op_test.cpp b/engines/agi/op_test.cpp
index ecd3eb7c2f..463a51e8c1 100644
--- a/engines/agi/op_test.cpp
+++ b/engines/agi/op_test.cpp
@@ -30,31 +30,31 @@
namespace Agi {
-static uint8 test_obj_right(uint8, uint8, uint8, uint8, uint8);
-static uint8 test_obj_centre(uint8, uint8, uint8, uint8, uint8);
-static uint8 test_obj_in_box(uint8, uint8, uint8, uint8, uint8);
-static uint8 test_posn(uint8, uint8, uint8, uint8, uint8);
-static uint8 test_said(uint8, uint8 *);
-static uint8 test_controller(uint8);
-static uint8 test_keypressed(void);
-static uint8 test_compare_strings(uint8, uint8);
+static uint8 testObjRight(uint8, uint8, uint8, uint8, uint8);
+static uint8 testObjCentre(uint8, uint8, uint8, uint8, uint8);
+static uint8 testObjInBox(uint8, uint8, uint8, uint8, uint8);
+static uint8 testPosn(uint8, uint8, uint8, uint8, uint8);
+static uint8 testSaid(uint8, uint8 *);
+static uint8 testController(uint8);
+static uint8 testKeypressed(void);
+static uint8 testCompareStrings(uint8, uint8);
static AgiEngine *g_agi;
-#define game g_agi->game
+#define game g_agi->_game
#define ip (game.logics[lognum].cIP)
#define code (game.logics[lognum].data)
-#define test_equal(v1, v2) (g_agi->getvar(v1) == (v2))
-#define test_less(v1, v2) (g_agi->getvar(v1) < (v2))
-#define test_greater(v1, v2) (g_agi->getvar(v1) > (v2))
-#define test_isset(flag) (g_agi->getflag(flag))
-#define test_has(obj) (g_agi->object_get_location(obj) == EGO_OWNED)
-#define test_obj_in_room(obj, v) (g_agi->object_get_location(obj) == g_agi->getvar(v))
+#define testEqual(v1, v2) (g_agi->getvar(v1) == (v2))
+#define testLess(v1, v2) (g_agi->getvar(v1) < (v2))
+#define testGreater(v1, v2) (g_agi->getvar(v1) > (v2))
+#define testIsSet(flag) (g_agi->getflag(flag))
+#define testHas(obj) (g_agi->objectGetLocation(obj) == EGO_OWNED)
+#define testObjInRoom(obj, v) (g_agi->objectGetLocation(obj) == g_agi->getvar(v))
-extern int timer_hack; /* For the timer loop in MH1 logic 153 */
+extern int timerHack; /* For the timer loop in MH1 logic 153 */
-static uint8 test_compare_strings(uint8 s1, uint8 s2) {
+static uint8 testCompareStrings(uint8 s1, uint8 s2) {
char ms1[MAX_STRINGLEN];
char ms2[MAX_STRINGLEN];
int j, k, l;
@@ -107,15 +107,15 @@ static uint8 test_compare_strings(uint8 s1, uint8 s2) {
return !strcmp(ms1, ms2);
}
-static uint8 test_keypressed() {
+static uint8 testKeypressed() {
int x = game.keypress;
game.keypress = 0;
if (!x) {
- int mode = game.input_mode;
- game.input_mode = INPUT_NONE;
- g_agi->main_cycle();
- game.input_mode = mode;
+ int mode = game.inputMode;
+ game.inputMode = INPUT_NONE;
+ g_agi->mainCycle();
+ game.inputMode = mode;
}
if (x)
@@ -124,50 +124,50 @@ static uint8 test_keypressed() {
return x;
}
-static uint8 test_controller(uint8 cont) {
- return game.ev_keyp[cont].occured;
+static uint8 testController(uint8 cont) {
+ return game.evKeyp[cont].occured;
}
-static uint8 test_posn(uint8 n, uint8 x1, uint8 y1, uint8 x2, uint8 y2) {
- struct vt_entry *v = &game.view_table[n];
+static uint8 testPosn(uint8 n, uint8 x1, uint8 y1, uint8 x2, uint8 y2) {
+ struct VtEntry *v = &game.viewTable[n];
uint8 r;
- r = v->x_pos >= x1 && v->y_pos >= y1 && v->x_pos <= x2 && v->y_pos <= y2;
+ r = v->xPos >= x1 && v->yPos >= y1 && v->xPos <= x2 && v->yPos <= y2;
- debugC(7, kDebugLevelScripts, "(%d,%d) in (%d,%d,%d,%d): %s", v->x_pos, v->y_pos, x1, y1, x2, y2, r ? "true" : "false");
+ debugC(7, kDebugLevelScripts, "(%d,%d) in (%d,%d,%d,%d): %s", v->xPos, v->yPos, x1, y1, x2, y2, r ? "true" : "false");
return r;
}
-static uint8 test_obj_in_box(uint8 n, uint8 x1, uint8 y1, uint8 x2, uint8 y2) {
- struct vt_entry *v = &game.view_table[n];
+static uint8 testObjInBox(uint8 n, uint8 x1, uint8 y1, uint8 x2, uint8 y2) {
+ struct VtEntry *v = &game.viewTable[n];
- return v->x_pos >= x1 &&
- v->y_pos >= y1 && v->x_pos + v->x_size - 1 <= x2 && v->y_pos <= y2;
+ return v->xPos >= x1 &&
+ v->yPos >= y1 && v->xPos + v->xSize - 1 <= x2 && v->yPos <= y2;
}
/* if n is in centre of box */
-static uint8 test_obj_centre(uint8 n, uint8 x1, uint8 y1, uint8 x2, uint8 y2) {
- struct vt_entry *v = &game.view_table[n];
+static uint8 testObjCentre(uint8 n, uint8 x1, uint8 y1, uint8 x2, uint8 y2) {
+ struct VtEntry *v = &game.viewTable[n];
- return v->x_pos + v->x_size / 2 >= x1 &&
- v->x_pos + v->x_size / 2 <= x2 && v->y_pos >= y1 && v->y_pos <= y2;
+ return v->xPos + v->xSize / 2 >= x1 &&
+ v->xPos + v->xSize / 2 <= x2 && v->yPos >= y1 && v->yPos <= y2;
}
/* if nect N is in right corner */
-static uint8 test_obj_right(uint8 n, uint8 x1, uint8 y1, uint8 x2, uint8 y2) {
- struct vt_entry *v = &game.view_table[n];
+static uint8 testObjRight(uint8 n, uint8 x1, uint8 y1, uint8 x2, uint8 y2) {
+ struct VtEntry *v = &game.viewTable[n];
- return v->x_pos + v->x_size - 1 >= x1 &&
- v->x_pos + v->x_size - 1 <= x2 && v->y_pos >= y1 && v->y_pos <= y2;
+ return v->xPos + v->xSize - 1 >= x1 &&
+ v->xPos + v->xSize - 1 <= x2 && v->yPos >= y1 && v->yPos <= y2;
}
/* When player has entered something, it is parsed elsewhere */
-static uint8 test_said(uint8 nwords, uint8 *cc) {
- int c, n = game.num_ego_words;
+static uint8 testSaid(uint8 nwords, uint8 *cc) {
+ int c, n = game.numEgoWords;
int z = 0;
- if (g_agi->getflag(F_said_accepted_input) || !g_agi->getflag(F_entered_cli))
+ if (g_agi->getflag(fSaidAcceptedInput) || !g_agi->getflag(fEnteredCli))
return false;
/* FR:
@@ -199,7 +199,7 @@ static uint8 test_said(uint8 nwords, uint8 *cc) {
case 1: /* any word */
break;
default:
- if (game.ego_words[c].id != z)
+ if (game.egoWords[c].id != z)
return false;
break;
}
@@ -215,26 +215,26 @@ static uint8 test_said(uint8 nwords, uint8 *cc) {
if (nwords != 0 && READ_LE_UINT16(cc) != 9999)
return false;
- g_agi->setflag(F_said_accepted_input, true);
+ g_agi->setflag(fSaidAcceptedInput, true);
return true;
}
-int AgiEngine::test_if_code(int lognum) {
+int AgiEngine::testIfCode(int lognum) {
g_agi = this;
int ec = true;
int retval = true;
uint8 op = 0;
- uint8 not_test = false;
- uint8 or_test = false;
- uint16 last_ip = ip;
+ uint8 notTest = false;
+ uint8 orTest = false;
+ uint16 lastIp = ip;
uint8 p[16] = { 0 };
- while (retval && !game.quit_prog_now) {
- if (g_agi->_debug.enabled && (g_agi->_debug.logic0 || lognum))
- debug_console(lognum, lTEST_MODE, NULL);
+ while (retval && !game.quitProgNow) {
+ if (_debug.enabled && (_debug.logic0 || lognum))
+ debugConsole(lognum, lTEST_MODE, NULL);
- last_ip = ip;
+ lastIp = ip;
op = *(code + ip++);
memmove(p, (code + ip), 16);
@@ -242,94 +242,94 @@ int AgiEngine::test_if_code(int lognum) {
case 0xFF: /* END IF, TEST true */
goto end_test;
case 0xFD:
- not_test = !not_test;
+ 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.
*/
- if (or_test) {
+ if (orTest) {
ec = false;
retval = false;
goto end_test;
}
- or_test = true;
+ orTest = true;
continue;
case 0x00:
/* return true? */
goto end_test;
case 0x01:
- ec = test_equal(p[0], p[1]);
+ ec = testEqual(p[0], p[1]);
if (p[0] == 11)
- timer_hack++;
+ timerHack++;
break;
case 0x02:
- ec = test_equal(p[0], getvar(p[1]));
+ ec = testEqual(p[0], getvar(p[1]));
if (p[0] == 11 || p[1] == 11)
- timer_hack++;
+ timerHack++;
break;
case 0x03:
- ec = test_less(p[0], p[1]);
+ ec = testLess(p[0], p[1]);
if (p[0] == 11)
- timer_hack++;
+ timerHack++;
break;
case 0x04:
- ec = test_less(p[0], getvar(p[1]));
+ ec = testLess(p[0], getvar(p[1]));
if (p[0] == 11 || p[1] == 11)
- timer_hack++;
+ timerHack++;
break;
case 0x05:
- ec = test_greater(p[0], p[1]);
+ ec = testGreater(p[0], p[1]);
if (p[0] == 11)
- timer_hack++;
+ timerHack++;
break;
case 0x06:
- ec = test_greater(p[0], getvar(p[1]));
+ ec = testGreater(p[0], getvar(p[1]));
if (p[0] == 11 || p[1] == 11)
- timer_hack++;
+ timerHack++;
break;
case 0x07:
- ec = test_isset(p[0]);
+ ec = testIsSet(p[0]);
break;
case 0x08:
- ec = test_isset(getvar(p[0]));
+ ec = testIsSet(getvar(p[0]));
break;
case 0x09:
- ec = test_has(p[0]);
+ ec = testHas(p[0]);
break;
case 0x0A:
- ec = test_obj_in_room(p[0], p[1]);
+ ec = testObjInRoom(p[0], p[1]);
break;
case 0x0B:
- ec = test_posn(p[0], p[1], p[2], p[3], p[4]);
+ ec = testPosn(p[0], p[1], p[2], p[3], p[4]);
break;
case 0x0C:
- ec = test_controller(p[0]);
+ ec = testController(p[0]);
break;
case 0x0D:
- ec = test_keypressed();
+ ec = testKeypressed();
break;
case 0x0E:
- ec = test_said(p[0], (uint8 *) code + (ip + 1));
- ip = last_ip;
+ 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 */
break;
case 0x0F:
debugC(7, kDebugLevelScripts, "comparing [%s], [%s]", game.strings[p[0]], game.strings[p[1]]);
- ec = test_compare_strings(p[0], p[1]);
+ ec = testCompareStrings(p[0], p[1]);
break;
case 0x10:
- ec = test_obj_in_box(p[0], p[1], p[2], p[3], p[4]);
+ ec = testObjInBox(p[0], p[1], p[2], p[3], p[4]);
break;
case 0x11:
- ec = test_obj_centre(p[0], p[1], p[2], p[3], p[4]);
+ ec = testObjCentre(p[0], p[1], p[2], p[3], p[4]);
break;
case 0x12:
- ec = test_obj_right(p[0], p[1], p[2], p[3], p[4]);
+ ec = testObjRight(p[0], p[1], p[2], p[3], p[4]);
break;
default:
ec = false;
@@ -337,16 +337,16 @@ int AgiEngine::test_if_code(int lognum) {
}
if (op <= 0x12)
- ip += logic_names_test[op].num_args;
+ ip += logicNamesTest[op].numArgs;
/* exchange ec value */
- if (not_test)
+ if (notTest)
ec = !ec;
/* not is only enabled for 1 test command */
- not_test = false;
+ notTest = false;
- if (or_test && ec) {
+ if (orTest && ec) {
/* a true inside an OR statement passes
* ENTIRE statement scan for end of OR
*/
@@ -377,15 +377,15 @@ int AgiEngine::test_if_code(int lognum) {
}
if (*(code + ip) < 0xFC)
- ip += logic_names_test[*(code + ip)].num_args;
+ ip += logicNamesTest[*(code + ip)].numArgs;
ip++;
}
ip++;
- or_test = false;
+ orTest = false;
retval = true;
} else {
- retval = or_test ? retval || ec : retval && ec;
+ retval = orTest ? retval || ec : retval && ec;
}
}
end_test:
@@ -394,13 +394,13 @@ int AgiEngine::test_if_code(int lognum) {
if (retval)
ip += 2;
else {
- ip = last_ip;
+ ip = lastIp;
while (*(code + ip) != 0xff) {
if (*(code + ip) == 0x0e) {
ip++;
ip += (*(code + ip)) * 2 + 1;
} else if (*(code + ip) < 0xfc) {
- ip += logic_names_test[*(code + ip)].num_args;
+ ip += logicNamesTest[*(code + ip)].numArgs;
ip++;
} else {
ip++;
@@ -410,8 +410,8 @@ int AgiEngine::test_if_code(int lognum) {
ip += READ_LE_UINT16(code + ip) + 2;
}
- if (g_agi->_debug.enabled && (g_agi->_debug.logic0 || lognum))
- debug_console(lognum, 0xFF, retval ? "=true" : "=false");
+ if (_debug.enabled && (_debug.logic0 || lognum))
+ debugConsole(lognum, 0xFF, retval ? "=true" : "=false");
return retval;
}
diff --git a/engines/agi/opcodes.h b/engines/agi/opcodes.h
index 85d5014c83..8adffec4a4 100644
--- a/engines/agi/opcodes.h
+++ b/engines/agi/opcodes.h
@@ -29,16 +29,16 @@
namespace Agi {
-struct agi_logicnames {
+struct AgiLogicnames {
const char *name;
- uint16 num_args;
- uint16 arg_mask;
+ uint16 numArgs;
+ uint16 argMask;
};
-extern struct agi_logicnames logic_names_test[];
-extern struct agi_logicnames logic_names_cmd[];
-extern struct agi_logicnames logic_names_if[];
+extern AgiLogicnames logicNamesTest[];
+extern AgiLogicnames logicNamesCmd[];
+extern AgiLogicnames logicNamesIf[];
-} // End of namespace Agi
+} // End of namespace Agi
#endif /* AGI_OPCODES_H */
diff --git a/engines/agi/patches.cpp b/engines/agi/patches.cpp
index 806ee7c491..c0b057a158 100644
--- a/engines/agi/patches.cpp
+++ b/engines/agi/patches.cpp
@@ -31,22 +31,22 @@ namespace Agi {
#ifdef PATCH_LOGIC
-#define ip (game.logics[n].cIP)
-#define code (game.logics[n].data)
-#define size (game.logics[n].size)
+#define ip (_game.logics[n].cIP)
+#define code (_game.logics[n].data)
+#define size (_game.logics[n].size)
/*
* Patches
*/
-static const uint8 kq4data_find[] = {
+static const uint8 kq4dataFind[] = {
0x0C, 0x04, 0xFF, 0x07, 0x05, 0xFF, 0x15, 0x00,
0x03, 0x0A, 0x00, 0x77, 0x83, 0x71, 0x0D, 0x97,
0x03, 0x98, 0xCE, 0x18, 0x98, 0x19, 0x98, 0x1B,
0x98, 0x0C, 0x5A, 0x1A, 0x00
};
-static const uint8 kq4data_fix[] = {
+static const uint8 kq4dataFix[] = {
/* v19 = 0
* new.room(96)
* return
@@ -54,14 +54,14 @@ static const uint8 kq4data_fix[] = {
0x03, 0x13, 0x0, 0x12, 0x60, 0x00
};
-static const uint8 grdata_find[] = {
+static const uint8 grdataFind[] = {
0x0C, 0x04, 0xFF, 0x07, 0x05, 0xFF, 0x16, 0x00,
0x0C, 0x96, 0x03, 0x0A, 0x00, 0x77, 0x83, 0x71,
0x0D, 0xD9, 0x03, 0xDC, 0xBF, 0x18, 0xDC, 0x19,
0xDC, 0x1B, 0xDC, 0x0C, 0x95, 0x1A
};
-static const uint8 grdata_fix[] = {
+static const uint8 grdataFix[] = {
/* reset(227)
* v19 = 0
* v246 = 1
@@ -73,14 +73,14 @@ static const uint8 grdata_fix[] = {
};
#if 0
-static const uint8 lsl1data_find[] = {
+static const uint8 lsl1dataFind[] = {
0xFF, 0xFD, 0x07, 0x1E, 0xFC, 0x07, 0x6D, 0x01,
0x5F, 0x03, 0xFC, 0xFF, 0x12, 0x00, 0x0C, 0x6D,
0x78, 0x8A, 0x77, 0x69, 0x16, 0x18, 0x00, 0x0D,
0x30, 0x0D, 0x55, 0x78, 0x65, 0x0A
};
-static const uint8 lsl1data_fix[] = {
+static const uint8 lsl1dataFix[] = {
/* set(109)
* reset(48)
* reset(85)
@@ -92,7 +92,7 @@ static const uint8 lsl1data_fix[] = {
};
#endif
-static const uint8 mh1data_find[] = {
+static const uint8 mh1dataFind[] = {
0xFF, 0x07, 0x05, 0xFF, 0xE6, 0x00,
0x03, 0x0A, 0x02, 0x77, 0x83, 0x71,
0x6F, 0x01, 0x17, 0x00, 0x03, 0x00,
@@ -100,40 +100,40 @@ static const uint8 mh1data_find[] = {
0x03, 0x03, 0x3B, 0x00, 0x6C, 0x03
};
-static const uint8 mh1data_fix[] = {
+static const uint8 mh1dataFix[] = {
0x0C, 0x05, 0x16, 0x5A, 0x12, 0x99
};
-void AgiEngine::patch_logic(int n) {
+void AgiEngine::patchLogic(int n) {
switch (n) {
#if 0
/* ALT-X in the questions takes care of that */
case 6:
/* lsl1 bypass questions */
- if (!strcmp(game.id, "LLLLL")) {
- if (!memcmp(lsl1data_find, (code + ip), 30))
- memmove((code + ip), lsl1data_fix, 9);
+ if (!strcmp(_game.id, "LLLLL")) {
+ if (!memcmp(lsl1dataFind, (code + ip), 30))
+ memmove((code + ip), lsl1dataFix, 9);
}
break;
#endif
case 125:
/* gold rush code break */
- if (!strcmp(game.id, "GR")) {
- if (!memcmp(grdata_find, (code + ip), 30))
- memmove((code + ip), grdata_fix, 12);
+ if (!strcmp(_game.id, "GR")) {
+ if (!memcmp(grdataFind, (code + ip), 30))
+ memmove((code + ip), grdataFix, 12);
}
break;
case 140:
/* kings quest 4 code break */
- if (!strcmp(game.id, "KQ4")) {
- if (memcmp(kq4data_find, (code + ip), 29) == 0)
- memmove((code + ip), kq4data_fix, 6);
+ if (!strcmp(_game.id, "KQ4")) {
+ if (memcmp(kq4dataFind, (code + ip), 29) == 0)
+ memmove((code + ip), kq4dataFix, 6);
}
break;
case 159:
/* manhunter 1 amiga */
- if (ip + 30 < size && !memcmp(mh1data_find, (code + ip), 30)) {
- memmove((code + ip), mh1data_fix, 6);
+ if (ip + 30 < size && !memcmp(mh1dataFind, (code + ip), 30)) {
+ memmove((code + ip), mh1dataFix, 6);
}
break;
}
@@ -141,4 +141,4 @@ void AgiEngine::patch_logic(int n) {
#endif
-} // End of namespace Agi
+} // End of namespace Agi
diff --git a/engines/agi/picture.cpp b/engines/agi/picture.cpp
index 90b948008a..528aea3261 100644
--- a/engines/agi/picture.cpp
+++ b/engines/agi/picture.cpp
@@ -29,18 +29,18 @@
namespace Agi {
-#define next_byte data[foffs++]
+#define nextByte data[foffs++]
static uint8 *data;
static uint32 flen;
static uint32 foffs;
-static uint8 pat_code;
-static uint8 pat_num;
-static uint8 pri_on;
-static uint8 scr_on;
-static uint8 scr_colour;
-static uint8 pri_colour;
+static uint8 patCode;
+static uint8 patNum;
+static uint8 priOn;
+static uint8 scrOn;
+static uint8 scrColour;
+static uint8 priColour;
static uint8 circles[][15] = { /* agi circle bitmaps */
{0x80},
@@ -53,14 +53,14 @@ static uint8 circles[][15] = { /* agi circle bitmaps */
{0x18, 0x3c, 0x7e, 0x7e, 0x7e, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7e, 0x7e, 0x7e, 0x3c, 0x18}
};
-static uint8 splatter_map[32] = { /* splatter brush bitmaps */
+static uint8 splatterMap[32] = { /* splatter brush bitmaps */
0x20, 0x94, 0x02, 0x24, 0x90, 0x82, 0xa4, 0xa2,
0x82, 0x09, 0x0a, 0x22, 0x12, 0x10, 0x42, 0x14,
0x91, 0x4a, 0x91, 0x11, 0x08, 0x12, 0x25, 0x10,
0x22, 0xa8, 0x14, 0x24, 0x00, 0x50, 0x24, 0x04
};
-static uint8 splatter_start[128] = { /* starting bit position */
+static uint8 splatterStart[128] = { /* starting bit position */
0x00, 0x18, 0x30, 0xc4, 0xdc, 0x65, 0xeb, 0x48,
0x60, 0xbd, 0x89, 0x05, 0x0a, 0xf4, 0x7d, 0x7d,
0x85, 0xb0, 0x8e, 0x95, 0x1f, 0x22, 0x0d, 0xdf,
@@ -78,40 +78,40 @@ static uint8 splatter_start[128] = { /* starting bit position */
0x06, 0x6f, 0xc6, 0x4a, 0xa4, 0x75, 0x97, 0xe1
};
-void PictureMgr::put_virt_pixel(int x, int y) {
+void PictureMgr::putVirtPixel(int x, int y) {
uint8 *p;
if (x < 0 || y < 0 || x >= _WIDTH || y >= _HEIGHT)
return;
- p = &_vm->game.sbuf[y * _WIDTH + x];
+ p = &_vm->_game.sbuf[y * _WIDTH + x];
- if (pri_on)
- *p = (pri_colour << 4) | (*p & 0x0f);
- if (scr_on)
- *p = scr_colour | (*p & 0xf0);
+ if (priOn)
+ *p = (priColour << 4) | (*p & 0x0f);
+ if (scrOn)
+ *p = scrColour | (*p & 0xf0);
}
/* For the flood fill routines */
/* MH2 needs stack size > 300 */
#define STACK_SIZE 512
-static unsigned int stack_ptr;
+static unsigned int stackPtr;
static uint16 stack[STACK_SIZE];
-static INLINE void _PUSH(uint16 c) {
- assert(stack_ptr < STACK_SIZE);
+static INLINE void lpush(uint16 c) {
+ assert(stackPtr < STACK_SIZE);
- stack[stack_ptr] = c;
- stack_ptr++;
+ stack[stackPtr] = c;
+ stackPtr++;
}
-static INLINE uint16 _POP() {
- if (stack_ptr == 0)
+static INLINE uint16 lpop() {
+ if (stackPtr == 0)
return 0xffff;
- stack_ptr--;
- return stack[stack_ptr];
+ stackPtr--;
+ return stack[stackPtr];
}
/**
@@ -123,7 +123,7 @@ static INLINE uint16 _POP() {
* @param x2 x coordinate of end point
* @param y2 y coordinate of end point
*/
-void PictureMgr::draw_line(int x1, int y1, int x2, int y2) {
+void PictureMgr::drawLine(int x1, int y1, int x2, int y2) {
int i, x, y, deltaX, deltaY, stepX, stepY, errorX, errorY, detdelta;
/* CM: Do clipping */
@@ -143,7 +143,7 @@ void PictureMgr::draw_line(int x1, int y1, int x2, int y2) {
}
for (; y1 <= y2; y1++)
- put_virt_pixel(x1, y1);
+ putVirtPixel(x1, y1);
return;
}
@@ -157,7 +157,7 @@ void PictureMgr::draw_line(int x1, int y1, int x2, int y2) {
x2 = x;
}
for (; x1 <= x2; x1++)
- put_virt_pixel(x1, y1);
+ putVirtPixel(x1, y1);
return;
}
@@ -190,7 +190,7 @@ void PictureMgr::draw_line(int x1, int y1, int x2, int y2) {
errorY = deltaX / 2;
}
- put_virt_pixel(x, y);
+ putVirtPixel(x, y);
do {
errorY += deltaY;
@@ -205,7 +205,7 @@ void PictureMgr::draw_line(int x1, int y1, int x2, int y2) {
x += stepX;
}
- put_virt_pixel(x, y);
+ putVirtPixel(x, y);
i--;
} while (i > 0);
}
@@ -214,16 +214,16 @@ void PictureMgr::draw_line(int x1, int y1, int x2, int y2) {
* Draw a relative AGI line.
* Draws short lines relative to last position. (drawing action 0xF7)
*/
-void PictureMgr::dynamic_draw_line() {
+void PictureMgr::dynamicDrawLine() {
int x1, y1, disp, dx, dy;
- x1 = next_byte;
- y1 = next_byte;
+ x1 = nextByte;
+ y1 = nextByte;
- put_virt_pixel(x1, y1);
+ putVirtPixel(x1, y1);
for (;;) {
- if ((disp = next_byte) >= 0xf0)
+ if ((disp = nextByte) >= 0xf0)
break;
dx = ((disp & 0xf0) >> 4) & 0x0f;
@@ -234,7 +234,7 @@ void PictureMgr::dynamic_draw_line() {
if (dy & 0x08)
dy = -(dy & 0x07);
- draw_line(x1, y1, x1 + dx, y1 + dy);
+ drawLine(x1, y1, x1 + dx, y1 + dy);
x1 += dx;
y1 += dy;
}
@@ -246,21 +246,21 @@ void PictureMgr::dynamic_draw_line() {
**
** Draws long lines to actual locations (cf. relative) (drawing action 0xF6)
**************************************************************************/
-void PictureMgr::absolute_draw_line() {
+void PictureMgr::absoluteDrawLine() {
int x1, y1, x2, y2;
- x1 = next_byte;
- y1 = next_byte;
- put_virt_pixel(x1, y1);
+ x1 = nextByte;
+ y1 = nextByte;
+ putVirtPixel(x1, y1);
- while (42) {
- if ((x2 = next_byte) >= 0xf0)
+ for (;;) {
+ if ((x2 = nextByte) >= 0xf0)
break;
- if ((y2 = next_byte) >= 0xf0)
+ if ((y2 = nextByte) >= 0xf0)
break;
- draw_line(x1, y1, x2, y2);
+ drawLine(x1, y1, x2, y2);
x1 = x2;
y1 = y2;
}
@@ -270,67 +270,67 @@ void PictureMgr::absolute_draw_line() {
/**************************************************************************
** okToFill
**************************************************************************/
-INLINE int PictureMgr::is_ok_fill_here(int x, int y) {
+INLINE int PictureMgr::isOkFillHere(int x, int y) {
uint8 p;
if (x < 0 || x >= _WIDTH || y < 0 || y >= _HEIGHT)
return false;
- if (!scr_on && !pri_on)
+ if (!scrOn && !priOn)
return false;
- p = _vm->game.sbuf[y * _WIDTH + x];
+ p = _vm->_game.sbuf[y * _WIDTH + x];
- if (!pri_on && scr_on && scr_colour != 15)
+ if (!priOn && scrOn && scrColour != 15)
return (p & 0x0f) == 15;
- if (pri_on && !scr_on && pri_colour != 4)
+ if (priOn && !scrOn && priColour != 4)
return (p >> 4) == 4;
- return (scr_on && (p & 0x0f) == 15 && scr_colour != 15);
+ return (scrOn && (p & 0x0f) == 15 && scrColour != 15);
}
/**************************************************************************
** agi_fill
**************************************************************************/
-void PictureMgr::fill_scanline(int x, int y) {
+void PictureMgr::fillScanline(int x, int y) {
unsigned int c;
- int newspan_up, newspan_down;
+ int newspanUp, newspanDown;
- if (!is_ok_fill_here(x, y))
+ if (!isOkFillHere(x, y))
return;
/* Scan for left border */
- for (c = x - 1; is_ok_fill_here(c, y); c--);
-
- newspan_up = newspan_down = 1;
- for (c++; is_ok_fill_here(c, y); c++) {
- put_virt_pixel(c, y);
- if (is_ok_fill_here(c, y - 1)) {
- if (newspan_up) {
- _PUSH(c + 320 * (y - 1));
- newspan_up = 0;
+ for (c = x - 1; isOkFillHere(c, y); c--);
+
+ newspanUp = newspanDown = 1;
+ for (c++; isOkFillHere(c, y); c++) {
+ putVirtPixel(c, y);
+ if (isOkFillHere(c, y - 1)) {
+ if (newspanUp) {
+ lpush(c + 320 * (y - 1));
+ newspanUp = 0;
}
} else {
- newspan_up = 1;
+ newspanUp = 1;
}
- if (is_ok_fill_here(c, y + 1)) {
- if (newspan_down) {
- _PUSH(c + 320 * (y + 1));
- newspan_down = 0;
+ if (isOkFillHere(c, y + 1)) {
+ if (newspanDown) {
+ lpush(c + 320 * (y + 1));
+ newspanDown = 0;
}
} else {
- newspan_down = 1;
+ newspanDown = 1;
}
}
}
-void PictureMgr::agi_fill(unsigned int x, unsigned int y) {
- _PUSH(x + 320 * y);
+void PictureMgr::agiFill(unsigned int x, unsigned int y) {
+ lpush(x + 320 * y);
- while (42) {
- uint16 c = _POP();
+ for (;;) {
+ uint16 c = lpop();
/* Exit if stack is empty */
if (c == 0xffff)
@@ -339,10 +339,10 @@ void PictureMgr::agi_fill(unsigned int x, unsigned int y) {
x = c % 320;
y = c / 320;
- fill_scanline(x, y);
+ fillScanline(x, y);
}
- stack_ptr = 0;
+ stackPtr = NULL;
}
/**************************************************************************
@@ -350,27 +350,27 @@ void PictureMgr::agi_fill(unsigned int x, unsigned int y) {
**
** Draws an xCorner (drawing action 0xF5)
**************************************************************************/
-void PictureMgr::x_corner() {
+void PictureMgr::xCorner() {
int x1, x2, y1, y2;
- x1 = next_byte;
- y1 = next_byte;
- put_virt_pixel(x1, y1);
+ x1 = nextByte;
+ y1 = nextByte;
+ putVirtPixel(x1, y1);
- while (42) {
- x2 = next_byte;
+ for (;;) {
+ x2 = nextByte;
if (x2 >= 0xf0)
break;
- draw_line(x1, y1, x2, y1);
+ drawLine(x1, y1, x2, y1);
x1 = x2;
- y2 = next_byte;
+ y2 = nextByte;
if (y2 >= 0xf0)
break;
- draw_line(x1, y1, x1, y2);
+ drawLine(x1, y1, x1, y2);
y1 = y2;
}
foffs--;
@@ -381,27 +381,27 @@ void PictureMgr::x_corner() {
**
** Draws an yCorner (drawing action 0xF4)
**************************************************************************/
-void PictureMgr::y_corner() {
+void PictureMgr::yCorner() {
int x1, x2, y1, y2;
- x1 = next_byte;
- y1 = next_byte;
- put_virt_pixel(x1, y1);
+ x1 = nextByte;
+ y1 = nextByte;
+ putVirtPixel(x1, y1);
- while (42) {
- y2 = next_byte;
+ for (;;) {
+ y2 = nextByte;
if (y2 >= 0xF0)
break;
- draw_line(x1, y1, x1, y2);
+ drawLine(x1, y1, x1, y2);
y1 = y2;
- x2 = next_byte;
+ x2 = nextByte;
if (x2 >= 0xf0)
break;
- draw_line(x1, y1, x2, y1);
+ drawLine(x1, y1, x2, y1);
x1 = x2;
}
@@ -416,8 +416,8 @@ void PictureMgr::y_corner() {
void PictureMgr::fill() {
int x1, y1;
- while ((x1 = next_byte) < 0xF0 && (y1 = next_byte) < 0xf0)
- agi_fill(x1, y1);
+ while ((x1 = nextByte) < 0xF0 && (y1 = nextByte) < 0xf0)
+ agiFill(x1, y1);
foffs--;
}
@@ -429,25 +429,25 @@ void PictureMgr::fill() {
** on the pattern code.
**************************************************************************/
-int PictureMgr::plot_pattern_point(int x, int y, int bitpos) {
- if (pat_code & 0x20) {
- if ((splatter_map[bitpos >> 3] >> (7 - (bitpos & 7))) & 1) {
- put_virt_pixel(x, y);
+int PictureMgr::plotPatternPoint(int x, int y, int bitpos) {
+ if (patCode & 0x20) {
+ if ((splatterMap[bitpos >> 3] >> (7 - (bitpos & 7))) & 1) {
+ putVirtPixel(x, y);
}
bitpos++;
if (bitpos == 0xff)
bitpos = 0;
} else
- put_virt_pixel(x, y);
+ putVirtPixel(x, y);
return bitpos;
}
-void PictureMgr::plot_pattern(int x, int y) {
+void PictureMgr::plotPattern(int x, int y) {
int32 circlePos = 0;
- uint32 x1, y1, pensize, bitpos = splatter_start[pat_num];
+ uint32 x1, y1, pensize, bitpos = splatterStart[patNum];
- pensize = (pat_code & 7);
+ pensize = (patCode & 7);
if (x < (int)pensize)
x = pensize - 1;
@@ -456,11 +456,11 @@ void PictureMgr::plot_pattern(int x, int y) {
for (y1 = y - pensize; y1 <= y + pensize; y1++) {
for (x1 = x - (pensize + 1) / 2; x1 <= x + pensize / 2; x1++) {
- if (pat_code & 0x10) { /* Square */
- bitpos = plot_pattern_point (x1, y1, bitpos);
+ if (patCode & 0x10) { /* Square */
+ bitpos = plotPatternPoint (x1, y1, bitpos);
} else { /* Circle */
- if ((circles[pat_code & 7][circlePos >> 3] >> (7 - (circlePos & 7))) & 1) {
- bitpos = plot_pattern_point(x1, y1, bitpos);
+ if ((circles[patCode & 7][circlePos >> 3] >> (7 - (circlePos & 7))) & 1) {
+ bitpos = plotPatternPoint(x1, y1, bitpos);
}
circlePos++;
}
@@ -473,23 +473,23 @@ void PictureMgr::plot_pattern(int x, int y) {
**
** Plots points and various brush patterns.
**************************************************************************/
-void PictureMgr::plot_brush() {
+void PictureMgr::plotBrush() {
int x1, y1;
- while (42) {
- if (pat_code & 0x20) {
- if ((pat_num = next_byte) >= 0xF0)
+ for (;;) {
+ if (patCode & 0x20) {
+ if ((patNum = nextByte) >= 0xF0)
break;
- pat_num = (pat_num >> 1) & 0x7f;
+ patNum = (patNum >> 1) & 0x7f;
}
- if ((x1 = next_byte) >= 0xf0)
+ if ((x1 = nextByte) >= 0xf0)
break;
- if ((y1 = next_byte) >= 0xf0)
+ if ((y1 = nextByte) >= 0xf0)
break;
- plot_pattern(x1, y1);
+ plotPattern(x1, y1);
}
foffs--;
@@ -501,58 +501,58 @@ void PictureMgr::plot_brush() {
** AGI flood fill. (drawing action 0xF8)
**************************************************************************/
-void PictureMgr::draw_picture() {
+void PictureMgr::drawPicture() {
uint8 act;
int drawing;
- pat_code = 0;
- pat_num = 0;
- pri_on = scr_on = false;
- scr_colour = 0xf;
- pri_colour = 0x4;
+ patCode = 0;
+ patNum = 0;
+ priOn = scrOn = false;
+ scrColour = 0xf;
+ priColour = 0x4;
drawing = 1;
debugC(8, kDebugLevelMain, "Drawing picture");
for (drawing = 1; drawing && foffs < flen;) {
- act = next_byte;
+ act = nextByte;
switch (act) {
case 0xf0: /* set colour on screen */
- scr_colour = next_byte;
- scr_colour &= 0xF; /* for v3 drawing diff */
- scr_on = true;
+ scrColour = nextByte;
+ scrColour &= 0xF; /* for v3 drawing diff */
+ scrOn = true;
break;
case 0xf1: /* disable screen drawing */
- scr_on = false;
+ scrOn = false;
break;
case 0xf2: /* set colour on priority */
- pri_colour = next_byte;
- pri_colour &= 0xf; /* for v3 drawing diff */
- pri_on = true;
+ priColour = nextByte;
+ priColour &= 0xf; /* for v3 drawing diff */
+ priOn = true;
break;
case 0xf3: /* disable priority screen */
- pri_on = false;
+ priOn = false;
break;
case 0xf4: /* y-corner */
- y_corner();
+ yCorner();
break;
case 0xf5: /* x-corner */
- x_corner();
+ xCorner();
break;
case 0xf6: /* absolute draw lines */
- absolute_draw_line();
+ absoluteDrawLine();
break;
case 0xf7: /* dynamic draw lines */
- dynamic_draw_line();
+ dynamicDrawLine();
break;
case 0xf8: /* fill */
fill();
break;
case 0xf9: /* set pattern */
- pat_code = next_byte;
+ patCode = nextByte;
break;
case 0xfA: /* plot brush */
- plot_brush();
+ plotBrush();
break;
case 0xFF: /* end of pic data */
default:
@@ -569,11 +569,11 @@ void PictureMgr::draw_picture() {
/**
*
*/
-uint8 *PictureMgr::convert_v3_pic(uint8 *src, uint32 len) {
+uint8 *PictureMgr::convertV3Pic(uint8 *src, uint32 len) {
uint8 d, old = 0, x, *in, *xdata, *out, mode = 0;
uint32 i, ulen;
- xdata = (uint8 *) malloc(len + len / 2);
+ xdata = (uint8 *)malloc(len + len / 2);
out = xdata;
in = src;
@@ -618,29 +618,29 @@ uint8 *PictureMgr::convert_v3_pic(uint8 *src, uint32 len) {
* @param n AGI picture resource number
* @param clear clear AGI screen before drawing
*/
-int PictureMgr::decode_picture(int n, int clear) {
+int PictureMgr::decodePicture(int n, int clear) {
debugC(8, kDebugLevelResources, "(%d)", n);
- pat_code = 0;
- pat_num = 0;
- pri_on = scr_on = false;
- scr_colour = 0xF;
- pri_colour = 0x4;
+ patCode = 0;
+ patNum = 0;
+ priOn = scrOn = false;
+ scrColour = 0xF;
+ priColour = 0x4;
- data = _vm->game.pictures[n].rdata;
- flen = _vm->game.dir_pic[n].len;
+ data = _vm->_game.pictures[n].rdata;
+ flen = _vm->_game.dirPic[n].len;
foffs = 0;
if (clear)
- memset(_vm->game.sbuf, 0x4f, _WIDTH * _HEIGHT);
+ memset(_vm->_game.sbuf, 0x4f, _WIDTH * _HEIGHT);
- draw_picture();
+ drawPicture();
if (clear)
- _vm->clear_image_stack();
- _vm->record_image_stack_call(ADD_PIC, n, clear, 0, 0, 0, 0, 0);
+ _vm->clearImageStack();
+ _vm->recordImageStackCall(ADD_PIC, n, clear, 0, 0, 0, 0, 0);
- return err_OK;
+ return errOK;
}
/**
@@ -649,34 +649,34 @@ int PictureMgr::decode_picture(int n, int clear) {
* resource data.
* @param n AGI picture resource number
*/
-int PictureMgr::unload_picture(int n) {
+int PictureMgr::unloadPicture(int n) {
/* remove visual buffer & priority buffer if they exist */
- if (_vm->game.dir_pic[n].flags & RES_LOADED) {
- free(_vm->game.pictures[n].rdata);
- _vm->game.dir_pic[n].flags &= ~RES_LOADED;
+ if (_vm->_game.dirPic[n].flags & RES_LOADED) {
+ free(_vm->_game.pictures[n].rdata);
+ _vm->_game.dirPic[n].flags &= ~RES_LOADED;
}
- return err_OK;
+ return errOK;
}
/**
* Show AGI picture.
* This function copies a ``hidden'' AGI picture to the output device.
*/
-void PictureMgr::show_pic() {
+void PictureMgr::showPic() {
int i, y;
int offset;
debugC(8, kDebugLevelMain, "Show picture!");
i = 0;
- offset = _vm->game.line_min_print * CHAR_LINES;
+ offset = _vm->_game.lineMinPrint * CHAR_LINES;
for (y = 0; y < _HEIGHT; y++) {
- _gfx->putPixelsA(0, y + offset, _WIDTH, &_vm->game.sbuf[i]);
+ _gfx->putPixelsA(0, y + offset, _WIDTH, &_vm->_game.sbuf[i]);
i += _WIDTH;
}
_gfx->flushScreen();
}
-} // End of namespace Agi
+} // End of namespace Agi
diff --git a/engines/agi/picture.h b/engines/agi/picture.h
index 34b97730c5..90995be2fa 100644
--- a/engines/agi/picture.h
+++ b/engines/agi/picture.h
@@ -32,7 +32,7 @@ namespace Agi {
/**
* AGI picture resource.
*/
-struct agi_picture {
+struct AgiPicture {
uint32 flen; /**< size of raw data */
uint8 *rdata; /**< raw vector image data */
};
@@ -46,20 +46,20 @@ class PictureMgr {
private:
- void draw_line(int x1, int y1, int x2, int y2);
- void put_virt_pixel(int x, int y);
- void dynamic_draw_line();
- void absolute_draw_line();
- INLINE int is_ok_fill_here(int x, int y);
- void fill_scanline(int x, int y);
- void agi_fill(unsigned int x, unsigned int y);
- void x_corner();
- void y_corner();
+ void drawLine(int x1, int y1, int x2, int y2);
+ void putVirtPixel(int x, int y);
+ void dynamicDrawLine();
+ void absoluteDrawLine();
+ INLINE int isOkFillHere(int x, int y);
+ void fillScanline(int x, int y);
+ void agiFill(unsigned int x, unsigned int y);
+ void xCorner();
+ void yCorner();
void fill();
- int plot_pattern_point(int x, int y, int bitpos);
- void plot_pattern(int x, int y);
- void plot_brush();
- void draw_picture();
+ int plotPatternPoint(int x, int y, int bitpos);
+ void plotPattern(int x, int y);
+ void plotBrush();
+ void drawPicture();
public:
PictureMgr(AgiEngine *agi, GfxMgr *gfx) {
@@ -67,12 +67,12 @@ public:
_gfx = gfx;
}
- int decode_picture(int, int);
- int unload_picture(int);
- void show_pic();
- uint8 *convert_v3_pic(uint8 *src, uint32 len);
+ int decodePicture(int, int);
+ int unloadPicture(int);
+ void showPic();
+ uint8 *convertV3Pic(uint8 *src, uint32 len);
};
-} // End of namespace Agi
+} // End of namespace Agi
#endif /* AGI_PICTURE_H */
diff --git a/engines/agi/predictive.cpp b/engines/agi/predictive.cpp
index d75a5a38b9..e58d9a6695 100644
--- a/engines/agi/predictive.cpp
+++ b/engines/agi/predictive.cpp
@@ -69,11 +69,11 @@ bool AgiEngine::predictiveDialog(void) {
return false;
}
- draw_window(50, 40, 269, 159);
+ drawWindow(50, 40, 269, 159);
_gfx->drawRectangle(62, 54, 249, 66, MSG_BOX_TEXT);
_gfx->flushBlock(62, 54, 249, 66);
- _gfx->printCharacter(3, 11, game.cursor_char, MSG_BOX_COLOUR, MSG_BOX_TEXT);
+ _gfx->printCharacter(3, 11, _game.cursorChar, MSG_BOX_COLOUR, MSG_BOX_TEXT);
bx[15] = 73; // Zero/space
by[15] = 120;
@@ -118,7 +118,7 @@ bool AgiEngine::predictiveDialog(void) {
bool needRefresh = true;
- while (42) {
+ for (;;) {
if (needRefresh) {
for (int i = 0; buttons[i]; i++) {
int color1 = colors[i * 2];
@@ -146,13 +146,13 @@ bool AgiEngine::predictiveDialog(void) {
for (int i = prefix.size() + _currentCode.size(); i < MAXWORDLEN; i++)
temp[i] = ' ';
- print_text(temp, 0, 8, 7, MAXWORDLEN, 15, 0);
+ printText(temp, 0, 8, 7, MAXWORDLEN, 15, 0);
_gfx->flushBlock(62, 54, 249, 66);
}
}
_gfx->pollTimer(); /* msdos driver -> does nothing */
- key = do_poll_keyboard();
+ key = doPollKeyboard();
switch (key) {
case KEY_ENTER:
rc = true;
@@ -246,7 +246,7 @@ bool AgiEngine::predictiveDialog(void) {
_predictiveResult[prefix.size() + _currentCode.size() + 1] = 0;
getout:
- close_window();
+ closeWindow();
return rc;
}
@@ -349,6 +349,4 @@ bool AgiEngine::matchWord(void) {
return false;
}
-
-
} // End of namespace Agi
diff --git a/engines/agi/savegame.cpp b/engines/agi/savegame.cpp
index 7efe2b801a..b4c366c15d 100644
--- a/engines/agi/savegame.cpp
+++ b/engines/agi/savegame.cpp
@@ -52,13 +52,13 @@ static const uint32 AGIflag=MKID_BE('AGI:');
int AgiEngine::saveGame(const char *fileName, const char *description) {
char gameIDstring[8]="gameIDX";
int i;
- struct image_stack_element *ptr = image_stack;
+ struct ImageStackElement *ptr = _imageStack;
Common::OutSaveFile *out;
debugC(3, kDebugLevelMain | kDebugLevelSavegame, "AgiEngine::saveGame(%s, %s)", fileName, description);
if (!(out = _saveFileMan->openForSaving(fileName))) {
warning("Can't create file '%s', game not saved", fileName);
- return err_BadFileOpen;
+ return errBadFileOpen;
} else {
debugC(3, kDebugLevelMain | kDebugLevelSavegame, "Successfully opened %s for writing", fileName);
}
@@ -69,70 +69,70 @@ int AgiEngine::saveGame(const char *fileName, const char *description) {
out->writeByte(SAVEGAME_VERSION);
debugC(5, kDebugLevelMain | kDebugLevelSavegame, "Writing save game version (%d)", SAVEGAME_VERSION);
- out->writeByte(game.state);
- debugC(5, kDebugLevelMain | kDebugLevelSavegame, "Writing game state (%d)", game.state);
+ out->writeByte(_game.state);
+ debugC(5, kDebugLevelMain | kDebugLevelSavegame, "Writing game state (%d)", _game.state);
- strcpy(gameIDstring, game.id);
+ strcpy(gameIDstring, _game.id);
out->write(gameIDstring, 8);
- debugC(5, kDebugLevelMain | kDebugLevelSavegame, "Writing game id (%s, %s)", gameIDstring, game.id);
+ debugC(5, kDebugLevelMain | kDebugLevelSavegame, "Writing game id (%s, %s)", gameIDstring, _game.id);
for (i = 0; i < MAX_FLAGS; i++)
- out->writeByte(game.flags[i]);
+ out->writeByte(_game.flags[i]);
for (i = 0; i < MAX_VARS; i++)
- out->writeByte(game.vars[i]);
+ out->writeByte(_game.vars[i]);
- out->writeSint16BE((int8)game.horizon);
- out->writeSint16BE((int16)game.line_status);
- out->writeSint16BE((int16)game.line_user_input);
- out->writeSint16BE((int16)game.line_min_print);
+ out->writeSint16BE((int8)_game.horizon);
+ out->writeSint16BE((int16)_game.lineStatus);
+ out->writeSint16BE((int16)_game.lineUserInput);
+ out->writeSint16BE((int16)_game.lineMinPrint);
- out->writeSint16BE((int16)game.input_mode);
- out->writeSint16BE((int16)game.lognum);
+ out->writeSint16BE((int16)_game.inputMode);
+ out->writeSint16BE((int16)_game.lognum);
- out->writeSint16BE((int16)game.player_control);
- out->writeSint16BE((int16)game.quit_prog_now);
- out->writeSint16BE((int16)game.status_line);
- out->writeSint16BE((int16)game.clock_enabled);
- out->writeSint16BE((int16)game.exit_all_logics);
- out->writeSint16BE((int16)game.picture_shown);
- out->writeSint16BE((int16)game.has_prompt);
- out->writeSint16BE((int16)game.game_flags);
+ out->writeSint16BE((int16)_game.playerControl);
+ out->writeSint16BE((int16)_game.quitProgNow);
+ out->writeSint16BE((int16)_game.statusLine);
+ out->writeSint16BE((int16)_game.clockEnabled);
+ out->writeSint16BE((int16)_game.exitAllLogics);
+ out->writeSint16BE((int16)_game.pictureShown);
+ out->writeSint16BE((int16)_game.hasPrompt);
+ out->writeSint16BE((int16)_game.gameFlags);
- out->writeSint16BE((int16)game.input_enabled);
+ out->writeSint16BE((int16)_game.inputEnabled);
for (i = 0; i < _HEIGHT; i++)
- out->writeByte(game.pri_table[i]);
+ out->writeByte(_game.priTable[i]);
- out->writeSint16BE((int16)game.gfx_mode);
- out->writeByte(game.cursor_char);
- out->writeSint16BE((int16)game.color_fg);
- out->writeSint16BE((int16)game.color_bg);
+ out->writeSint16BE((int16)_game.gfxMode);
+ out->writeByte(_game.cursorChar);
+ out->writeSint16BE((int16)_game.colorFg);
+ out->writeSint16BE((int16)_game.colorBg);
/* game.hires */
/* game.sbuf */
/* game.ego_words */
/* game.num_ego_words */
- out->writeSint16BE((int16)game.num_objects);
- for (i = 0; i < (int16)game.num_objects; i++)
- out->writeSint16BE((int16)object_get_location(i));
+ out->writeSint16BE((int16)_game.numObjects);
+ for (i = 0; i < (int16)_game.numObjects; i++)
+ out->writeSint16BE((int16)objectGetLocation(i));
/* game.ev_keyp */
for (i = 0; i < MAX_STRINGS; i++)
- out->write(game.strings[i], MAX_STRINGLEN);
+ out->write(_game.strings[i], MAX_STRINGLEN);
/* record info about loaded resources */
for (i = 0; i < MAX_DIRS; i++) {
- out->writeByte(game.dir_logic[i].flags);
- out->writeSint16BE((int16)game.logics[i].sIP);
- out->writeSint16BE((int16)game.logics[i].cIP);
+ out->writeByte(_game.dirLogic[i].flags);
+ out->writeSint16BE((int16)_game.logics[i].sIP);
+ out->writeSint16BE((int16)_game.logics[i].cIP);
}
for (i = 0; i < MAX_DIRS; i++)
- out->writeByte(game.dir_pic[i].flags);
+ out->writeByte(_game.dirPic[i].flags);
for (i = 0; i < MAX_DIRS; i++)
- out->writeByte(game.dir_view[i].flags);
+ out->writeByte(_game.dirView[i].flags);
for (i = 0; i < MAX_DIRS; i++)
- out->writeByte(game.dir_sound[i].flags);
+ out->writeByte(_game.dirSound[i].flags);
/* game.pictures */
/* game.logics */
@@ -140,38 +140,38 @@ int AgiEngine::saveGame(const char *fileName, const char *description) {
/* game.sounds */
for (i = 0; i < MAX_VIEWTABLE; i++) {
- struct vt_entry *v = &game.view_table[i];
+ VtEntry *v = &_game.viewTable[i];
- out->writeByte(v->step_time);
- out->writeByte(v->step_time_count);
+ out->writeByte(v->stepTime);
+ out->writeByte(v->stepTimeCount);
out->writeByte(v->entry);
- out->writeSint16BE(v->x_pos);
- out->writeSint16BE(v->y_pos);
- out->writeByte(v->current_view);
+ out->writeSint16BE(v->xPos);
+ out->writeSint16BE(v->yPos);
+ out->writeByte(v->currentView);
/* v->view_data */
- out->writeByte(v->current_loop);
- out->writeByte(v->num_loops);
+ out->writeByte(v->currentLoop);
+ out->writeByte(v->numLoops);
/* v->loop_data */
- out->writeByte(v->current_cel);
- out->writeByte(v->num_cels);
+ out->writeByte(v->currentCel);
+ out->writeByte(v->numCels);
/* v->cel_data */
/* v->cel_data_2 */
- out->writeSint16BE(v->x_pos2);
- out->writeSint16BE(v->y_pos2);
+ out->writeSint16BE(v->xPos2);
+ out->writeSint16BE(v->yPos2);
/* v->s */
- out->writeSint16BE(v->x_size);
- out->writeSint16BE(v->y_size);
- out->writeByte(v->step_size);
- out->writeByte(v->cycle_time);
- out->writeByte(v->cycle_time_count);
+ out->writeSint16BE(v->xSize);
+ out->writeSint16BE(v->ySize);
+ out->writeByte(v->stepSize);
+ out->writeByte(v->cycleTime);
+ out->writeByte(v->cycleTimeCount);
out->writeByte(v->direction);
out->writeByte(v->motion);
@@ -188,8 +188,8 @@ int AgiEngine::saveGame(const char *fileName, const char *description) {
/* Save image stack */
- for (i = 0; i < image_stack_pointer; i++) {
- ptr = &image_stack[i];
+ for (i = 0; i < _imageStackPointer; i++) {
+ ptr = &_imageStack[i];
out->writeByte(ptr->type);
out->writeSint16BE(ptr->parm1);
out->writeSint16BE(ptr->parm2);
@@ -209,12 +209,12 @@ int AgiEngine::saveGame(const char *fileName, const char *description) {
delete out;
debugC(3, kDebugLevelMain | kDebugLevelSavegame, "Closed %s", fileName);
- return err_OK;
+ return errOK;
}
int AgiEngine::loadGame(const char *fileName) {
char description[31], saveVersion, loadId[8];
- int i, vt_entries = MAX_VIEWTABLE;
+ int i, vtEntries = MAX_VIEWTABLE;
uint8 t;
int16 parm[7];
Common::InSaveFile *in;
@@ -223,7 +223,7 @@ int AgiEngine::loadGame(const char *fileName) {
if (!(in = _saveFileMan->openForLoading(fileName))) {
warning("Can't open file '%s', game not loaded", fileName);
- return err_BadFileOpen;
+ return errBadFileOpen;
} else {
debugC(3, kDebugLevelMain | kDebugLevelSavegame, "Successfully opened %s for reading", fileName);
}
@@ -234,7 +234,7 @@ int AgiEngine::loadGame(const char *fileName) {
} else {
warning("This doesn't appear to be an AGI savegame, game not restored");
delete in;
- return err_OK;
+ return errOK;
}
in->read(description, 31);
@@ -245,59 +245,59 @@ int AgiEngine::loadGame(const char *fileName) {
if (saveVersion != SAVEGAME_VERSION)
warning("Old save game version (%d, current version is %d). Will try and read anyway, but don't be surprised if bad things happen", saveVersion, SAVEGAME_VERSION);
- game.state = in->readByte();
+ _game.state = in->readByte();
in->read(loadId, 8);
- if (strcmp(loadId, game.id)) {
+ if (strcmp(loadId, _game.id)) {
delete in;
- warning("This save seems to be from a different AGI game (save from %s, running %s), not loaded", loadId, game.id);
- return err_BadFileOpen;
+ warning("This save seems to be from a different AGI game (save from %s, running %s), not loaded", loadId, _game.id);
+ return errBadFileOpen;
}
for (i = 0; i < MAX_FLAGS; i++)
- game.flags[i] = in->readByte();
+ _game.flags[i] = in->readByte();
for (i = 0; i < MAX_VARS; i++)
- game.vars[i] = in->readByte();
+ _game.vars[i] = in->readByte();
- game.horizon = in->readSint16BE();
- game.line_status = in->readSint16BE();
- game.line_user_input = in->readSint16BE();
- game.line_min_print = in->readSint16BE();
+ _game.horizon = in->readSint16BE();
+ _game.lineStatus = in->readSint16BE();
+ _game.lineUserInput = in->readSint16BE();
+ _game.lineMinPrint = in->readSint16BE();
/* These are never saved */
- game.cursor_pos = 0;
- game.input_buffer[0] = 0;
- game.echo_buffer[0] = 0;
- game.keypress = 0;
-
- game.input_mode = in->readSint16BE();
- game.lognum = in->readSint16BE();
-
- game.player_control = in->readSint16BE();
- game.quit_prog_now = in->readSint16BE();
- game.status_line = in->readSint16BE();
- game.clock_enabled = in->readSint16BE();
- game.exit_all_logics = in->readSint16BE();
- game.picture_shown = in->readSint16BE();
- game.has_prompt = in->readSint16BE();
- game.game_flags = in->readSint16BE();
- game.input_enabled = in->readSint16BE();
+ _game.cursorPos = 0;
+ _game.inputBuffer[0] = 0;
+ _game.echoBuffer[0] = 0;
+ _game.keypress = 0;
+
+ _game.inputMode = in->readSint16BE();
+ _game.lognum = in->readSint16BE();
+
+ _game.playerControl = in->readSint16BE();
+ _game.quitProgNow = in->readSint16BE();
+ _game.statusLine = in->readSint16BE();
+ _game.clockEnabled = in->readSint16BE();
+ _game.exitAllLogics = in->readSint16BE();
+ _game.pictureShown = in->readSint16BE();
+ _game.hasPrompt = in->readSint16BE();
+ _game.gameFlags = in->readSint16BE();
+ _game.inputEnabled = in->readSint16BE();
for (i = 0; i < _HEIGHT; i++)
- game.pri_table[i] = in->readByte();
+ _game.priTable[i] = in->readByte();
- if (game.has_window)
- close_window();
+ if (_game.hasWindow)
+ closeWindow();
- game.msg_box_ticks = 0;
- game.block.active = false;
+ _game.msgBoxTicks = 0;
+ _game.block.active = false;
/* game.window - fixed by close_window() */
/* game.has_window - fixed by close_window() */
- game.gfx_mode = in->readSint16BE();
- game.cursor_char = in->readByte();
- game.color_fg = in->readSint16BE();
- game.color_bg = in->readSint16BE();
+ _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 */
@@ -305,25 +305,25 @@ int AgiEngine::loadGame(const char *fileName) {
/* game.ego_words - fixed by clean_input */
/* game.num_ego_words - fixed by clean_input */
- game.num_objects = in->readSint16BE();
- for (i = 0; i < (int16)game.num_objects; i++)
- object_set_location(i, in->readSint16BE());
+ _game.numObjects = in->readSint16BE();
+ for (i = 0; i < (int16)_game.numObjects; i++)
+ objectSetLocation(i, in->readSint16BE());
/* Those are not serialized */
for (i = 0; i < MAX_DIRS; i++) {
- game.ev_keyp[i].occured = false;
+ _game.evKeyp[i].occured = false;
}
for (i = 0; i < MAX_STRINGS; i++)
- in->read(game.strings[i], MAX_STRINGLEN);
+ in->read(_game.strings[i], MAX_STRINGLEN);
for (i = 0; i < MAX_DIRS; i++) {
if (in->readByte() & RES_LOADED)
agiLoadResource(rLOGIC, i);
else
agiUnloadResource(rLOGIC, i);
- game.logics[i].sIP = in->readSint16BE();
- game.logics[i].cIP = in->readSint16BE();
+ _game.logics[i].sIP = in->readSint16BE();
+ _game.logics[i].cIP = in->readSint16BE();
}
for (i = 0; i < MAX_DIRS; i++) {
@@ -352,39 +352,39 @@ int AgiEngine::loadGame(const char *fileName) {
/* game.views - loaded above */
/* game.sounds - loaded above */
- for (i = 0; i < vt_entries; i++) {
- struct vt_entry *v = &game.view_table[i];
+ for (i = 0; i < vtEntries; i++) {
+ struct VtEntry *v = &_game.viewTable[i];
- v->step_time = in->readByte();
- v->step_time_count = in->readByte();
+ v->stepTime = in->readByte();
+ v->stepTimeCount = in->readByte();
v->entry = in->readByte();
- v->x_pos = in->readSint16BE();
- v->y_pos = in->readSint16BE();
- v->current_view = in->readByte();
+ v->xPos = in->readSint16BE();
+ v->yPos = in->readSint16BE();
+ v->currentView = in->readByte();
/* v->view_data - fixed below */
- v->current_loop = in->readByte();
- v->num_loops = in->readByte();
+ v->currentLoop = in->readByte();
+ v->numLoops = in->readByte();
/* v->loop_data - fixed below */
- v->current_cel = in->readByte();
- v->num_cels = in->readByte();
+ v->currentCel = in->readByte();
+ v->numCels = in->readByte();
/* v->cel_data - fixed below */
/* v->cel_data_2 - fixed below */
- v->x_pos2 = in->readSint16BE();
- v->y_pos2 = in->readSint16BE();
+ v->xPos2 = in->readSint16BE();
+ v->yPos2 = in->readSint16BE();
/* v->s - fixed below */
- v->x_size = in->readSint16BE();
- v->y_size = in->readSint16BE();
- v->step_size = in->readByte();
- v->cycle_time = in->readByte();
- v->cycle_time_count = in->readByte();
+ v->xSize = in->readSint16BE();
+ v->ySize = in->readSint16BE();
+ v->stepSize = in->readByte();
+ v->cycleTime = in->readByte();
+ v->cycleTimeCount = in->readByte();
v->direction = in->readByte();
v->motion = in->readByte();
@@ -398,58 +398,58 @@ int AgiEngine::loadGame(const char *fileName) {
v->parm3 = in->readByte();
v->parm4 = in->readByte();
}
- for (i = vt_entries; i < MAX_VIEWTABLE; i++) {
- memset(&game.view_table[i], 0, sizeof(struct vt_entry));
+ for (i = vtEntries; i < MAX_VIEWTABLE; i++) {
+ memset(&_game.viewTable[i], 0, sizeof(struct VtEntry));
}
/* Fix some pointers in viewtable */
for (i = 0; i < MAX_VIEWTABLE; i++) {
- struct vt_entry *v = &game.view_table[i];
+ struct VtEntry *v = &_game.viewTable[i];
- if (game.dir_view[v->current_view].offset == _EMPTY)
+ if (_game.dirView[v->currentView].offset == _EMPTY)
continue;
- if (!(game.dir_view[v->current_view].flags & RES_LOADED))
- agiLoadResource(rVIEW, v->current_view);
+ if (!(_game.dirView[v->currentView].flags & RES_LOADED))
+ agiLoadResource(rVIEW, v->currentView);
- set_view(v, v->current_view); /* Fix v->view_data */
- set_loop(v, v->current_loop); /* Fix v->loop_data */
- set_cel(v, v->current_cel); /* Fix v->cel_data */
- v->cel_data_2 = 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... */
}
- _sprites->erase_both();
+ _sprites->eraseBoth();
/* Clear input line */
_gfx->clearScreen(0);
- write_status();
+ writeStatus();
/* Recreate background from saved image stack */
- clear_image_stack();
+ clearImageStack();
while ((t = in->readByte()) != 0) {
for (i = 0; i < 7; i++)
parm[i] = in->readSint16BE();
- replay_image_stack_call(t, parm[0], parm[1], parm[2],
+ replayImageStackCall(t, parm[0], parm[1], parm[2],
parm[3], parm[4], parm[5], parm[6]);
}
delete in;
debugC(3, kDebugLevelMain | kDebugLevelSavegame, "Closed %s", fileName);
- setflag(F_restore_just_ran, true);
+ setflag(fRestoreJustRan, true);
- game.has_prompt = 0; /* force input line repaint if necessary */
- clean_input();
+ _game.hasPrompt = 0; /* force input line repaint if necessary */
+ cleanInput();
- _sprites->erase_both();
- _sprites->blit_both();
- _sprites->commit_both();
- _picture->show_pic();
+ _sprites->eraseBoth();
+ _sprites->blitBoth();
+ _sprites->commitBoth();
+ _picture->showPic();
_gfx->doUpdate();
- return err_OK;
+ return errOK;
}
#define NUM_SLOTS 12
@@ -494,18 +494,18 @@ int AgiEngine::selectSlot() {
char dstr[64];
for (i = 0; i < NUM_SLOTS; i++) {
sprintf(dstr, "[%-32.32s]", desc[i]);
- print_text(dstr, 0, hm + 1, vm + 4 + i,
+ printText(dstr, 0, hm + 1, vm + 4 + i,
(40 - 2 * hm) - 1, i == active ? MSG_BOX_COLOUR : MSG_BOX_TEXT,
i == active ? MSG_BOX_TEXT : MSG_BOX_COLOUR);
}
_gfx->pollTimer(); /* msdos driver -> does nothing */
- key = do_poll_keyboard();
+ key = doPollKeyboard();
switch (key) {
case KEY_ENTER:
rc = active;
- strncpy(game.strings[MAX_STRINGS], desc[i], MAX_STRINGLEN);
+ strncpy(_game.strings[MAX_STRINGS], desc[i], MAX_STRINGLEN);
goto press;
case KEY_ESCAPE:
rc = -1;
@@ -529,7 +529,7 @@ press:
debugC(8, kDebugLevelMain | kDebugLevelInput, "Button pressed: %d", rc);
getout:
- close_window();
+ closeWindow();
return rc;
}
@@ -550,41 +550,41 @@ int AgiEngine::saveGameDialog() {
sprintf(fileName, "%s", getSavegameFilename(slot));
- draw_window(hp, vp, GFX_WIDTH - hp, GFX_HEIGHT - vp);
- print_text("Select a slot in which you wish to save the game:",
+ drawWindow(hp, vp, GFX_WIDTH - hp, GFX_HEIGHT - vp);
+ printText("Select a slot in which you wish to save the game:",
0, hm + 1, vm + 1, w, MSG_BOX_TEXT, MSG_BOX_COLOUR);
- print_text("Press ENTER to select, ESC cancels",
+ printText("Press ENTER to select, ESC cancels",
0, hm + 1, vm + 17, w, MSG_BOX_TEXT, MSG_BOX_COLOUR);
slot = selectSlot();
if (slot < 0)
- return err_OK;
+ return errOK;
- draw_window(hp, vp + 5 * CHAR_LINES, GFX_WIDTH - hp,
+ drawWindow(hp, vp + 5 * CHAR_LINES, GFX_WIDTH - hp,
GFX_HEIGHT - vp - 9 * CHAR_LINES);
- print_text("Enter a description for this game:",
+ printText("Enter a description for this game:",
0, hm + 1, vm + 6, w, MSG_BOX_TEXT, MSG_BOX_COLOUR);
_gfx->drawRectangle(3 * CHAR_COLS, 11 * CHAR_LINES - 1,
37 * CHAR_COLS, 12 * CHAR_LINES, MSG_BOX_TEXT);
_gfx->flushBlock(3 * CHAR_COLS, 11 * CHAR_LINES - 1,
37 * CHAR_COLS, 12 * CHAR_LINES);
- get_string(2, 11, 33, MAX_STRINGS);
- _gfx->printCharacter(3, 11, game.cursor_char, MSG_BOX_COLOUR, MSG_BOX_TEXT);
+ getString(2, 11, 33, MAX_STRINGS);
+ _gfx->printCharacter(3, 11, _game.cursorChar, MSG_BOX_COLOUR, MSG_BOX_TEXT);
do {
- main_cycle();
- } while (game.input_mode == INPUT_GETSTRING);
- close_window();
+ mainCycle();
+ } while (_game.inputMode == INPUT_GETSTRING);
+ closeWindow();
- desc = game.strings[MAX_STRINGS];
+ desc = _game.strings[MAX_STRINGS];
sprintf(dstr, "Are you sure you want to save the game "
"described as:\n\n%s\n\nin slot %d?\n\n\n", desc, slot);
- rc = selection_box(dstr, buttons);
+ rc = selectionBox(dstr, buttons);
if (rc != 0) {
- message_box("Game NOT saved.");
- return err_OK;
+ messageBox("Game NOT saved.");
+ return errOK;
}
sprintf(fileName, "%s", getSavegameFilename(slot));
@@ -592,9 +592,9 @@ int AgiEngine::saveGameDialog() {
saveGame(fileName, desc);
- message_box("Game saved.");
+ messageBox("Game saved.");
- return err_OK;
+ return errOK;
}
int AgiEngine::saveGameSimple() {
@@ -603,7 +603,7 @@ int AgiEngine::saveGameSimple() {
sprintf(fileName, "%s", getSavegameFilename(0));
saveGame(fileName, "Default savegame");
- return err_OK;
+ return errOK;
}
int AgiEngine::loadGameDialog() {
@@ -620,30 +620,30 @@ int AgiEngine::loadGameDialog() {
sprintf(fileName, "%s", getSavegameFilename(slot));
- _sprites->erase_both();
- _sound->stop_sound();
+ _sprites->eraseBoth();
+ _sound->stopSound();
- draw_window(hp, vp, GFX_WIDTH - hp, GFX_HEIGHT - vp);
- print_text("Select a game which you wish to\nrestore:",
+ drawWindow(hp, vp, GFX_WIDTH - hp, GFX_HEIGHT - vp);
+ printText("Select a game which you wish to\nrestore:",
0, hm + 1, vm + 1, w, MSG_BOX_TEXT, MSG_BOX_COLOUR);
- print_text("Press ENTER to select, ESC cancels",
+ printText("Press ENTER to select, ESC cancels",
0, hm + 1, vm + 17, w, MSG_BOX_TEXT, MSG_BOX_COLOUR);
slot = selectSlot();
if (slot < 0) {
- message_box("Game NOT restored.");
- return err_OK;
+ messageBox("Game NOT restored.");
+ return errOK;
}
sprintf(fileName, "%s", getSavegameFilename(slot));
- if ((rc = loadGame(fileName)) == err_OK) {
- message_box("Game restored.");
- game.exit_all_logics = 1;
- menu->enable_all();
+ if ((rc = loadGame(fileName)) == errOK) {
+ messageBox("Game restored.");
+ _game.exitAllLogics = 1;
+ _menu->enableAll();
} else {
- message_box("Error restoring game.");
+ messageBox("Error restoring game.");
}
return rc;
@@ -655,19 +655,19 @@ int AgiEngine::loadGameSimple() {
sprintf(fileName, "%s", getSavegameFilename(0));
- _sprites->erase_both();
- _sound->stop_sound();
- close_window();
+ _sprites->eraseBoth();
+ _sound->stopSound();
+ closeWindow();
- if ((rc = loadGame(fileName)) == err_OK) {
- message_box("Game restored.");
- game.exit_all_logics = 1;
- menu->enable_all();
+ if ((rc = loadGame(fileName)) == errOK) {
+ messageBox("Game restored.");
+ _game.exitAllLogics = 1;
+ _menu->enableAll();
} else {
- message_box("Error restoring game.");
+ messageBox("Error restoring game.");
}
return rc;
}
-} // End of namespace Agi
+} // End of namespace Agi
diff --git a/engines/agi/sound.cpp b/engines/agi/sound.cpp
index 9ce5d33622..1c8ece04fa 100644
--- a/engines/agi/sound.cpp
+++ b/engines/agi/sound.cpp
@@ -42,23 +42,23 @@ namespace Agi {
/**
* AGI engine sound envelope structure.
*/
-struct sound_envelope {
+struct SoundEnvelope {
uint8 bp;
- uint8 inc_hi;
+ uint8 incHi;
uint8 inc_lo;
};
-struct sound_wavelist {
+struct SoundWavelist {
uint8 top;
uint8 addr;
uint8 size;
uint8 mode;
- uint8 rel_hi;
- uint8 rel_lo;
+ uint8 relHi;
+ uint8 relLo;
};
-struct sound_instrument {
- struct sound_envelope env[8];
+struct SoundInstrument {
+ struct SoundEnvelope env[8];
uint8 relseg;
uint8 priority;
uint8 bendrange;
@@ -67,41 +67,41 @@ struct sound_instrument {
uint8 spare;
uint8 wac;
uint8 wbc;
- struct sound_wavelist wal[8];
- struct sound_wavelist wbl[8];
+ struct SoundWavelist wal[8];
+ struct SoundWavelist wbl[8];
};
-struct sound_iigs_sample {
- uint8 type_lo;
- uint8 type_hi;
- uint8 srate_lo;
- uint8 srate_hi;
+struct SoundIIgsSample {
+ uint8 typeLo;
+ uint8 typeHi;
+ uint8 srateLo;
+ uint8 srateHi;
uint16 unknown[2];
- uint8 size_lo;
- uint8 size_hi;
+ uint8 sizeLo;
+ uint8 sizeHi;
uint16 unknown2[13];
};
#if 0
-static struct sound_instrument *instruments;
-static int num_instruments;
+static SoundInstrument *instruments;
+static int numInstruments;
static uint8 *wave;
#endif
#endif
static int playing;
-static struct channel_info chn[NUM_CHANNELS];
+static ChannelInfo chn[NUM_CHANNELS];
static int endflag = -1;
-static int playing_sound = -1;
+static int playingSound = -1;
static uint8 *song;
static uint8 env;
-static int16 *snd_buffer;
+static int16 *sndBuffer;
static int16 *waveform;
-static int16 waveform_ramp[WAVEFORM_SIZE] = {
+static int16 waveformRamp[WAVEFORM_SIZE] = {
0, 8, 16, 24, 32, 40, 48, 56,
64, 72, 80, 88, 96, 104, 112, 120,
128, 136, 144, 152, 160, 168, 176, 184,
@@ -112,7 +112,7 @@ static int16 waveform_ramp[WAVEFORM_SIZE] = {
-64, -56, -48, -40, -32, -24, -16, -8 /* Ramp up */
};
-static int16 waveform_square[WAVEFORM_SIZE] = {
+static 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,
@@ -123,7 +123,7 @@ static int16 waveform_square[WAVEFORM_SIZE] = {
-220, -220, -220, -110, 0, 0, 0, 0 /* Square */
};
-static int16 waveform_mac[WAVEFORM_SIZE] = {
+static int16 waveformMac[WAVEFORM_SIZE] = {
45, 110, 135, 161, 167, 173, 175, 176,
156, 137, 123, 110, 91, 72, 35, -2,
-60, -118, -142, -165, -170, -176, -177, -179,
@@ -141,92 +141,92 @@ static uint16 period[] = {
1448, 1534, 1625, 1722, 1825, 1933
};
-static struct agi_note play_sample[] = {
+static struct AgiNote playSample[] = {
{0xff, 0x7f, 0x18, 0x00, 0x7f},
{0xff, 0xff, 0x00, 0x00, 0x00},
{0xff, 0xff, 0x00, 0x00, 0x00},
{0xff, 0xff, 0x00, 0x00, 0x00}
};
-static int note_to_period(int note) {
+static int noteToPeriod(int note) {
return 10 * (period[note % 12] >> (note / 12 - 3));
}
-#endif /* USE_IIGS_SOUND */
+#endif /* USE_IIGS_SOUND */
-void SoundMgr::unload_sound(int resnum) {
- if (_vm->game.dir_sound[resnum].flags & RES_LOADED) {
- if (_vm->game.sounds[resnum].flags & SOUND_PLAYING)
+void SoundMgr::unloadSound(int resnum) {
+ if (_vm->_game.dirSound[resnum].flags & RES_LOADED) {
+ if (_vm->_game.sounds[resnum].flags & SOUND_PLAYING)
/* FIXME: Stop playing */
;
/* Release RAW data for sound */
- free(_vm->game.sounds[resnum].rdata);
- _vm->game.sounds[resnum].rdata = NULL;
- _vm->game.dir_sound[resnum].flags &= ~RES_LOADED;
+ free(_vm->_game.sounds[resnum].rdata);
+ _vm->_game.sounds[resnum].rdata = NULL;
+ _vm->_game.dirSound[resnum].flags &= ~RES_LOADED;
}
}
-void SoundMgr::decode_sound(int resnum) {
+void SoundMgr::decodeSound(int resnum) {
#ifdef USE_IIGS_SOUND
int type, size;
int16 *buf;
uint8 *src;
- struct sound_iigs_sample *smp;
+ struct SoundIIgsSample *smp;
debugC(3, kDebugLevelSound, "(%d)", resnum);
- type = READ_LE_UINT16(_vm->game.sounds[resnum].rdata);
+ type = READ_LE_UINT16(_vm->_game.sounds[resnum].rdata);
if (type == AGI_SOUND_SAMPLE) {
/* Convert sample data to 16 bit signed format
*/
- smp = (struct sound_iigs_sample *)_vm->game.sounds[resnum].rdata;
- size = ((int)smp->size_hi << 8) + smp->size_lo;
- src = (uint8 *) _vm->game.sounds[resnum].rdata;
- buf = (int16 *) calloc(1, 54 + (size << 1) + 100); /* FIXME */
+ smp = (struct SoundIIgsSample *)_vm->_game.sounds[resnum].rdata;
+ size = ((int)smp->sizeHi << 8) + smp->sizeLo;
+ src = (uint8 *)_vm->_game.sounds[resnum].rdata;
+ buf = (int16 *)calloc(1, 54 + (size << 1) + 100); /* FIXME */
memcpy(buf, src, 54);
- for (; size--; buf[size + 54] = ((int16) src[size + 54] - 0x80) << 4); /* FIXME */
- _vm->game.sounds[resnum].rdata = (uint8 *) buf;
+ for (; size--; buf[size + 54] = ((int16)src[size + 54] - 0x80) << 4); /* FIXME */
+ _vm->_game.sounds[resnum].rdata = (uint8 *) buf;
free(src);
}
#endif /* USE_IIGS_SOUND */
}
-void SoundMgr::start_sound(int resnum, int flag) {
+void SoundMgr::startSound(int resnum, int flag) {
int i, type;
#ifdef USE_IIGS_SOUND
- struct sound_iigs_sample *smp;
+ struct SoundIIgsSample *smp;
#endif
- if (_vm->game.sounds[resnum].flags & SOUND_PLAYING)
+ if (_vm->_game.sounds[resnum].flags & SOUND_PLAYING)
return;
- stop_sound();
+ stopSound();
- if (_vm->game.sounds[resnum].rdata == NULL)
+ if (_vm->_game.sounds[resnum].rdata == NULL)
return;
- type = READ_LE_UINT16(_vm->game.sounds[resnum].rdata);
+ type = READ_LE_UINT16(_vm->_game.sounds[resnum].rdata);
if (type != AGI_SOUND_SAMPLE && type != AGI_SOUND_MIDI && type != AGI_SOUND_4CHN)
return;
- _vm->game.sounds[resnum].flags |= SOUND_PLAYING;
- _vm->game.sounds[resnum].type = type;
- playing_sound = resnum;
- song = (uint8 *)_vm->game.sounds[resnum].rdata;
+ _vm->_game.sounds[resnum].flags |= SOUND_PLAYING;
+ _vm->_game.sounds[resnum].type = type;
+ playingSound = resnum;
+ song = (uint8 *)_vm->_game.sounds[resnum].rdata;
switch (type) {
#ifdef USE_IIGS_SOUND
case AGI_SOUND_SAMPLE:
debugC(3, kDebugLevelSound, "IIGS sample");
- smp = (struct sound_iigs_sample *)_vm->game.sounds[resnum].rdata;
+ smp = (struct SoundIIgsSample *)_vm->_game.sounds[resnum].rdata;
for (i = 0; i < NUM_CHANNELS; i++) {
chn[i].type = type;
chn[i].flags = 0;
- chn[i].ins = (int16 *) & _vm->game.sounds[resnum].rdata[54];
- chn[i].size = ((int)smp->size_hi << 8) + smp->size_lo;
- chn[i].ptr = &play_sample[i];
+ chn[i].ins = (int16 *)&_vm->_game.sounds[resnum].rdata[54];
+ chn[i].size = ((int)smp->sizeHi << 8) + smp->sizeLo;
+ chn[i].ptr = &playSample[i];
chn[i].timer = 0;
chn[i].vol = 0;
chn[i].end = 0;
@@ -245,7 +245,7 @@ void SoundMgr::start_sound(int resnum, int flag) {
}
chn[0].timer = *(song + 2);
- chn[0].ptr = (struct agi_note *)(song + 3);
+ chn[0].ptr = (struct AgiNote *)(song + 3);
break;
#endif
case AGI_SOUND_4CHN:
@@ -259,7 +259,7 @@ void SoundMgr::start_sound(int resnum, int flag) {
}
chn[i].ins = waveform;
chn[i].size = WAVEFORM_SIZE;
- chn[i].ptr = (struct agi_note *)(song + (song[i << 1] | (song[(i << 1) + 1] << 8)));
+ chn[i].ptr = (struct AgiNote *)(song + (song[i << 1] | (song[(i << 1) + 1] << 8)));
chn[i].timer = 0;
chn[i].vol = 0;
chn[i].end = 0;
@@ -267,7 +267,7 @@ void SoundMgr::start_sound(int resnum, int flag) {
break;
}
- memset(snd_buffer, 0, BUFFER_SIZE << 1);
+ memset(sndBuffer, 0, BUFFER_SIZE << 1);
endflag = flag;
/* Nat Budin reports that the flag should be reset when sound starts
@@ -277,45 +277,45 @@ void SoundMgr::start_sound(int resnum, int flag) {
/* FIXME: should wait for sound time instead of setting the flag
* immediately
*/
- if (_vm->opt.nosound) {
+ if (_vm->_opt.nosound) {
_vm->setflag(endflag, true);
- stop_sound();
+ stopSound();
}
}
-void SoundMgr::stop_sound() {
+void SoundMgr::stopSound() {
int i;
endflag = -1;
for (i = 0; i < NUM_CHANNELS; i++)
- stop_note(i);
+ stopNote(i);
- if (playing_sound != -1) {
- _vm->game.sounds[playing_sound].flags &= ~SOUND_PLAYING;
- playing_sound = -1;
+ if (playingSound != -1) {
+ _vm->_game.sounds[playingSound].flags &= ~SOUND_PLAYING;
+ playingSound = -1;
}
}
static int16 *buffer;
-int SoundMgr::init_sound() {
+int SoundMgr::initSound() {
int r = -1;
- buffer = snd_buffer = (int16 *)calloc(2, BUFFER_SIZE);
+ buffer = sndBuffer = (int16 *)calloc(2, BUFFER_SIZE);
env = false;
- switch (_vm->opt.soundemu) {
+ switch (_vm->_opt.soundemu) {
case SOUND_EMU_NONE:
- waveform = waveform_ramp;
+ waveform = waveformRamp;
env = true;
break;
case SOUND_EMU_AMIGA:
case SOUND_EMU_PC:
- waveform = waveform_square;
+ waveform = waveformSquare;
break;
case SOUND_EMU_MAC:
- waveform = waveform_mac;
+ waveform = waveformMac;
break;
}
@@ -329,33 +329,33 @@ int SoundMgr::init_sound() {
}
#ifdef USE_IIGS_SOUND
- /*load_instruments ("demo.sys"); */
+ /*loadInstruments("demo.sys"); */
#endif
return r;
}
-void SoundMgr::deinit_sound(void) {
+void SoundMgr::deinitSound() {
debugC(3, kDebugLevelSound, "()");
- free(snd_buffer);
+ free(sndBuffer);
}
-void SoundMgr::stop_note(int i) {
+void SoundMgr::stopNote(int i) {
chn[i].adsr = AGI_SOUND_ENV_RELEASE;
#ifdef USE_CHORUS
/* Stop chorus ;) */
if (chn[i].type == AGI_SOUND_4CHN &&
- _vm->opt.soundemu == SOUND_EMU_NONE && i < 3) {
- stop_note(i + 4);
+ _vm->_opt.soundemu == SOUND_EMU_NONE && i < 3) {
+ stopNote(i + 4);
}
#endif
}
-void SoundMgr::play_note(int i, int freq, int vol) {
- if (!_vm->getflag(F_sound_on))
+void SoundMgr::playNote(int i, int freq, int vol) {
+ if (!_vm->getflag(fSoundOn))
vol = 0;
- else if (vol && _vm->opt.soundemu == SOUND_EMU_PC)
+ else if (vol && _vm->_opt.soundemu == SOUND_EMU_PC)
vol = 160;
chn[i].phase = 0;
@@ -367,19 +367,18 @@ void SoundMgr::play_note(int i, int freq, int vol) {
#ifdef USE_CHORUS
/* Add chorus ;) */
if (chn[i].type == AGI_SOUND_4CHN &&
- _vm->opt.soundemu == SOUND_EMU_NONE && i < 3) {
+ _vm->_opt.soundemu == SOUND_EMU_NONE && i < 3) {
int newfreq = freq * 1007 / 1000;
if (freq == newfreq)
newfreq++;
- play_note(i + 4, newfreq, vol * 2 / 3);
+ playNote(i + 4, newfreq, vol * 2 / 3);
}
#endif
-
}
#ifdef USE_IIGS_SOUND
-void SoundMgr::play_midi_sound() {
+void SoundMgr::playMidiSound() {
uint8 *p;
uint8 parm1, parm2;
static uint8 cmd, ch;
@@ -391,7 +390,7 @@ void SoundMgr::play_midi_sound() {
return;
}
- p = (uint8 *) chn[0].ptr;
+ p = (uint8 *)chn[0].ptr;
if (*p & 0x80) {
cmd = *p++;
@@ -404,13 +403,13 @@ void SoundMgr::play_midi_sound() {
parm1 = *p++;
parm2 = *p++;
if (ch < NUM_CHANNELS)
- stop_note(ch);
+ stopNote(ch);
break;
case 0x09:
parm1 = *p++;
parm2 = *p++;
if (ch < NUM_CHANNELS)
- play_note(ch, note_to_period(parm1), 127);
+ playNote(ch, noteToPeriod(parm1), 127);
break;
case 0x0b:
parm1 = *p++;
@@ -421,7 +420,7 @@ void SoundMgr::play_midi_sound() {
parm1 = *p++;
#if 0
if (ch < NUM_CHANNELS) {
- chn[ch].ins = (uint16 *) & wave[waveaddr[parm1]];
+ chn[ch].ins = (uint16 *)&wave[waveaddr[parm1]];
chn[ch].size = wavesize[parm1];
}
debugC(3, kDebugLevelSound, "set patch %02x (%d,%d), ch %02x",
@@ -431,7 +430,7 @@ void SoundMgr::play_midi_sound() {
}
chn[0].timer = *p++;
- chn[0].ptr = (struct agi_note *)p;
+ chn[0].ptr = (struct AgiNote *)p;
if (*p >= 0xfc) {
debugC(3, kDebugLevelSound, "end of sequence");
@@ -440,32 +439,32 @@ void SoundMgr::play_midi_sound() {
}
}
-void SoundMgr::play_sample_sound() {
- play_note(0, 11025 * 10, 200);
+void SoundMgr::playSampleSound() {
+ playNote(0, 11025 * 10, 200);
playing = 1;
}
-#endif /* USE_IIGS_SOUND */
+#endif /* USE_IIGS_SOUND */
-void SoundMgr::play_agi_sound() {
+void SoundMgr::playAgiSound() {
int i, freq;
- for (playing = i = 0; i < (_vm->opt.soundemu == SOUND_EMU_PC ? 1 : 4); i++) {
+ for (playing = i = 0; i < (_vm->_opt.soundemu == SOUND_EMU_PC ? 1 : 4); i++) {
playing |= !chn[i].end;
if (chn[i].end)
continue;
if ((--chn[i].timer) <= 0) {
- stop_note(i);
- freq = ((chn[i].ptr->frq_0 & 0x3f) << 4) | (int)(chn[i].ptr->frq_1 & 0x0f);
+ stopNote(i);
+ freq = ((chn[i].ptr->frq0 & 0x3f) << 4) | (int)(chn[i].ptr->frq1 & 0x0f);
if (freq) {
uint8 v = chn[i].ptr->vol & 0x0f;
- play_note(i, freq * 10, v == 0xf ? 0 : 0xff - (v << 1));
+ playNote(i, freq * 10, v == 0xf ? 0 : 0xff - (v << 1));
}
- chn[i].timer = ((int)chn[i].ptr->dur_hi << 8) | chn[i].ptr->dur_lo;
+ chn[i].timer = ((int)chn[i].ptr->durHi << 8) | chn[i].ptr->durLo;
if (chn[i].timer == 0xffff) {
chn[i].end = 1;
@@ -473,7 +472,7 @@ void SoundMgr::play_agi_sound() {
chn[i].env = 0;
#ifdef USE_CHORUS
/* chorus */
- if (chn[i].type == AGI_SOUND_4CHN && _vm->opt.soundemu == SOUND_EMU_NONE && i < 3) {
+ if (chn[i].type == AGI_SOUND_4CHN && _vm->_opt.soundemu == SOUND_EMU_NONE && i < 3) {
chn[i + 4].vol = 0;
chn[i + 4].env = 0;
}
@@ -484,7 +483,7 @@ void SoundMgr::play_agi_sound() {
}
}
-void SoundMgr::play_sound() {
+void SoundMgr::playSound() {
int i;
if (endflag == -1)
@@ -495,10 +494,10 @@ void SoundMgr::play_sound() {
/* play_midi_sound (); */
playing = 0;
} else if (chn[0].type == AGI_SOUND_SAMPLE) {
- play_sample_sound();
+ playSampleSound();
} else
#endif
- play_agi_sound();
+ playAgiSound();
if (!playing) {
for (i = 0; i < NUM_CHANNELS; chn[i++].vol = 0);
@@ -506,19 +505,19 @@ void SoundMgr::play_sound() {
if (endflag != -1)
_vm->setflag(endflag, true);
- if (playing_sound != -1)
- _vm->game.sounds[playing_sound].flags &= ~SOUND_PLAYING;
- playing_sound = -1;
+ if (playingSound != -1)
+ _vm->_game.sounds[playingSound].flags &= ~SOUND_PLAYING;
+ playingSound = -1;
endflag = -1;
}
}
-uint32 SoundMgr::mix_sound(void) {
+uint32 SoundMgr::mixSound(void) {
register int i, p;
int16 *src;
int c, b, m;
- memset(snd_buffer, 0, BUFFER_SIZE << 1);
+ memset(sndBuffer, 0, BUFFER_SIZE << 1);
for (c = 0; c < NUM_CHANNELS; c++) {
if (!chn[c].vol)
@@ -536,7 +535,7 @@ uint32 SoundMgr::mix_sound(void) {
#ifdef USE_INTERPOLATION
b += ((src[((p >> 8) + 1) % chn[c].size] - src[p >> 8]) * (p & 0xff)) >> 8;
#endif
- snd_buffer[i] += (b * m) >> 4;
+ sndBuffer[i] += (b * m) >> 4;
p += (uint32) 118600 *4 / chn[c].freq;
@@ -557,7 +556,7 @@ uint32 SoundMgr::mix_sound(void) {
/* Add white noise */
for (i = 0; i < BUFFER_SIZE; i++) {
b = _vm->_rnd->getRandomNumber(255) - 128;
- snd_buffer[i] += (b * m) >> 4;
+ sndBuffer[i] += (b * m) >> 4;
}
}
@@ -591,26 +590,26 @@ uint32 SoundMgr::mix_sound(void) {
#ifdef USE_IIGS_SOUND
#if 0
-int SoundMgr::load_instruments(char *fname) {
+int SoundMgr::loadInstruments(char *fname) {
Common::File fp;
int i, j, k;
- struct sound_instrument ai;
- int num_wav;
+ struct SoundInstrument ai;
+ int numWav;
char *path;
path = "sierrast";
if (!fp.open(path))
- return err_BadFileOpen;
+ return errBadFileOpen;
report("Loading samples: %s\n", path);
if ((wave = malloc(0x10000 * 2)) == NULL)
- return err_NotEnoughMemory;
+ return errNotEnoughMemory;
fp.read(wave, 0x10000);
fp.close();
for (i = 0x10000; i--;) {
- ((int16 *) wave)[i] = 2 * ((int16) wave[i] - 128);
+ ((int16 *)wave)[i] = 2 * ((int16)wave[i] - 128);
}
fp = fopen("bla", "w");
@@ -620,11 +619,11 @@ int SoundMgr::load_instruments(char *fname) {
report("Loading instruments: %s\n", path);
if ((fp = fopen(path, "rb")) == NULL)
- return err_BadFileOpen;
+ return errBadFileOpen;
fseek(fp, 0x8469, SEEK_SET);
- for (num_wav = j = 0; j < 40; j++) {
+ for (numWav = j = 0; j < 40; j++) {
fread(&ai, 1, 32, fp);
if (ai.env[0].bp > 0x7f)
@@ -669,20 +668,20 @@ int SoundMgr::load_instruments(char *fname) {
#endif
}
- num_instruments = j;
+ numInstruments = j;
printf("%d Ensoniq 5503 instruments loaded. (%d waveforms)\n", num_instruments, num_wav);
fclose(fp);
- return err_OK;
+ return errOK;
}
-void Sound::unload_instruments() {
+void Sound::unloadInstruments() {
free(instruments);
}
#endif
-#endif /* USE_IIGS_SOUND */
+#endif /* USE_IIGS_SOUND */
static void fillAudio(void *udata, int16 *stream, uint len) {
SoundMgr *soundMgr = (SoundMgr *)udata;
@@ -694,8 +693,8 @@ static void fillAudio(void *udata, int16 *stream, uint len) {
debugC(5, kDebugLevelSound, "(%p, %p, %d)", (void *)udata, (void *)stream, len);
memcpy(stream, (uint8 *)buffer + s, p = n);
for (n = 0, len -= p; n < len; p += n, len -= n) {
- soundMgr->play_sound();
- n = soundMgr->mix_sound() << 1;
+ soundMgr->playSound();
+ n = soundMgr->mixSound() << 1;
if (len < n) {
memcpy((uint8 *)stream + p, buffer, len);
s = len;
@@ -705,8 +704,8 @@ static void fillAudio(void *udata, int16 *stream, uint len) {
memcpy((uint8 *)stream + p, buffer, n);
}
}
- soundMgr->play_sound();
- n = soundMgr->mix_sound() << 1;
+ soundMgr->playSound();
+ n = soundMgr->mixSound() << 1;
memcpy((uint8 *)stream + p, buffer, s = len);
n -= s;
}
diff --git a/engines/agi/sound.h b/engines/agi/sound.h
index 8af71161d4..415b891762 100644
--- a/engines/agi/sound.h
+++ b/engines/agi/sound.h
@@ -52,7 +52,7 @@ namespace Agi {
/**
* AGI sound resource structure.
*/
-struct agi_sound {
+struct AgiSound {
uint32 flen; /**< size of raw data */
uint8 *rdata; /**< raw sound data */
uint8 flags; /**< sound flags */
@@ -62,23 +62,23 @@ struct agi_sound {
/**
* AGI sound note structure.
*/
-struct agi_note {
- uint8 dur_lo; /**< LSB of note duration */
- uint8 dur_hi; /**< MSB of note duration */
- uint8 frq_0; /**< LSB of note frequency */
- uint8 frq_1; /**< MSB of note frequency */
+struct AgiNote {
+ uint8 durLo; /**< LSB of note duration */
+ uint8 durHi; /**< MSB of note duration */
+ uint8 frq0; /**< LSB of note frequency */
+ uint8 frq1; /**< MSB of note frequency */
uint8 vol; /**< note volume */
};
/**
* AGI engine sound channel structure.
*/
-struct channel_info {
+struct ChannelInfo {
#define AGI_SOUND_SAMPLE 0x0001
#define AGI_SOUND_MIDI 0x0002
#define AGI_SOUND_4CHN 0x0008
uint32 type;
- struct agi_note *ptr;
+ struct AgiNote *ptr;
int16 *ins;
int32 size;
uint32 phase;
@@ -134,24 +134,24 @@ private:
public:
- void decode_sound(int);
- void unload_sound(int);
- void play_sound();
- int init_sound();
- void deinit_sound();
- void start_sound(int, int);
- void stop_sound();
- void stop_note(int i);
- void play_note(int i, int freq, int vol);
- void play_agi_sound();
- uint32 mix_sound();
- int load_instruments(char *fname);
+ void decodeSound(int);
+ void unloadSound(int);
+ void playSound();
+ int initSound();
+ void deinitSound();
+ void startSound(int, int);
+ void stopSound();
+ void stopNote(int i);
+ void playNote(int i, int freq, int vol);
+ void playAgiSound();
+ uint32 mixSound();
+ int loadInstruments(char *fname);
#ifdef USE_IIGS_SOUND
- void play_midi_sound();
- void play_sample_sound();
+ void playMidiSound();
+ void playSampleSound();
#endif
};
} // End of namespace Agi
-#endif /* AGI_SOUND_H */
+#endif /* AGI_SOUND_H */
diff --git a/engines/agi/sprite.cpp b/engines/agi/sprite.cpp
index a1c10e7f65..2f0fbed9ee 100644
--- a/engines/agi/sprite.cpp
+++ b/engines/agi/sprite.cpp
@@ -35,12 +35,12 @@ namespace Agi {
* a rectangular area of the AGI screen. Sprites are chained in two
* circular lists, one for updating and other for non-updating sprites.
*/
-struct sprite {
- vt_entry *v; /**< pointer to view table entry */
- int16 x_pos; /**< x coordinate of the sprite */
- int16 y_pos; /**< y coordinate of the sprite */
- int16 x_size; /**< width of the sprite */
- int16 y_size; /**< height of the sprite */
+struct Sprite {
+ VtEntry *v; /**< pointer to view table entry */
+ int16 xPos; /**< x coordinate of the sprite */
+ int16 yPos; /**< y coordinate of the sprite */
+ int16 xSize; /**< width of the sprite */
+ int16 ySize; /**< height of the sprite */
uint8 *buffer; /**< buffer to store background data */
};
@@ -53,7 +53,7 @@ struct sprite {
#define POOL_SIZE 68000 /* Gold Rush mine room needs > 50000 */
/* Speeder bike challenge needs > 67000 */
-void *SpritesMgr::pool_alloc(int size) {
+void *SpritesMgr::poolAlloc(int size) {
uint8 *x;
/* Adjust size to 32-bit boundary to prevent data misalignment
@@ -61,12 +61,12 @@ void *SpritesMgr::pool_alloc(int size) {
*/
size = (size + 3) & ~3;
- x = pool_top;
- pool_top += size;
+ x = _poolTop;
+ _poolTop += size;
- if (pool_top >= (uint8 *)sprite_pool + POOL_SIZE) {
+ if (_poolTop >= (uint8 *)_spritePool + POOL_SIZE) {
debugC(1, kDebugLevelMain | kDebugLevelResources, "not enough memory");
- pool_top = x;
+ _poolTop = x;
return NULL;
}
@@ -76,8 +76,8 @@ void *SpritesMgr::pool_alloc(int size) {
/* Note: it's critical that pool_release() is called in the exact
reverse order of pool_alloc()
*/
-void SpritesMgr::pool_release(void *s) {
- pool_top = (uint8 *)s;
+void SpritesMgr::poolRelease(void *s) {
+ _poolTop = (uint8 *)s;
}
/*
@@ -86,7 +86,7 @@ void SpritesMgr::pool_release(void *s) {
/* Blit one pixel considering the priorities */
-void SpritesMgr::blit_pixel(uint8 *p, uint8 *end, uint8 col, int spr, int width, int *hidden) {
+void SpritesMgr::blitPixel(uint8 *p, uint8 *end, uint8 col, int spr, int width, int *hidden) {
int epr = 0, pr = 0; /* effective and real priorities */
/* CM: priority 15 overrides control lines and is ignored when
@@ -132,7 +132,7 @@ void SpritesMgr::blit_pixel(uint8 *p, uint8 *end, uint8 col, int spr, int width,
}
-int SpritesMgr::blit_cel(int x, int y, int spr, view_cel *c) {
+int SpritesMgr::blitCel(int x, int y, int spr, ViewCel *c) {
uint8 *p0, *p, *q = NULL, *end;
int i, j, t, m, col;
int hidden = true;
@@ -151,9 +151,9 @@ int SpritesMgr::blit_cel(int x, int y, int spr, view_cel *c) {
t = c->transparency;
m = c->mirror;
spr <<= 4;
- p0 = &_vm->game.sbuf[x + y * _WIDTH + m * (c->width - 1)];
+ p0 = &_vm->_game.sbuf[x + y * _WIDTH + m * (c->width - 1)];
- end = _vm->game.sbuf + _WIDTH * _HEIGHT;
+ end = _vm->_game.sbuf + _WIDTH * _HEIGHT;
for (i = 0; i < c->height; i++) {
p = p0;
@@ -161,7 +161,7 @@ int SpritesMgr::blit_cel(int x, int y, int spr, view_cel *c) {
col = (*q & 0xf0) >> 4;
for (j = *q & 0x0f; j; j--, p += 1 - 2 * m) {
if (col != t) {
- blit_pixel(p, end, col, spr, _WIDTH, &hidden);
+ blitPixel(p, end, col, spr, _WIDTH, &hidden);
}
}
q++;
@@ -173,72 +173,72 @@ int SpritesMgr::blit_cel(int x, int y, int spr, view_cel *c) {
return hidden;
}
-void SpritesMgr::objs_savearea(sprite *s) {
+void SpritesMgr::objsSaveArea(Sprite *s) {
int y;
- int16 x_pos = s->x_pos, y_pos = s->y_pos;
- int16 x_size = s->x_size, y_size = s->y_size;
+ int16 xPos = s->xPos, yPos = s->yPos;
+ int16 xSize = s->xSize, ySize = s->ySize;
uint8 *p0, *q;
- if (x_pos + x_size > _WIDTH)
- x_size = _WIDTH - x_pos;
+ if (xPos + xSize > _WIDTH)
+ xSize = _WIDTH - xPos;
- if (x_pos < 0) {
- x_size += x_pos;
- x_pos = 0;
+ if (xPos < 0) {
+ xSize += xPos;
+ xPos = 0;
}
- if (y_pos + y_size > _HEIGHT)
- y_size = _HEIGHT - y_pos;
+ if (yPos + ySize > _HEIGHT)
+ ySize = _HEIGHT - yPos;
- if (y_pos < 0) {
- y_size += y_pos;
- y_pos = 0;
+ if (yPos < 0) {
+ ySize += yPos;
+ yPos = 0;
}
- if (x_size <= 0 || y_size <= 0)
+ if (xSize <= 0 || ySize <= 0)
return;
- p0 = &_vm->game.sbuf[x_pos + y_pos * _WIDTH];
+ p0 = &_vm->_game.sbuf[xPos + yPos * _WIDTH];
q = s->buffer;
- for (y = 0; y < y_size; y++) {
- memcpy(q, p0, x_size);
- q += x_size;
+ for (y = 0; y < ySize; y++) {
+ memcpy(q, p0, xSize);
+ q += xSize;
p0 += _WIDTH;
}
}
-void SpritesMgr::objs_restorearea(sprite *s) {
+void SpritesMgr::objsRestoreArea(Sprite *s) {
int y, offset;
- int16 x_pos = s->x_pos, y_pos = s->y_pos;
- int16 x_size = s->x_size, y_size = s->y_size;
+ int16 xPos = s->xPos, yPos = s->yPos;
+ int16 xSize = s->xSize, ySize = s->ySize;
uint8 *p0, *q;
- if (x_pos + x_size > _WIDTH)
- x_size = _WIDTH - x_pos;
+ if (xPos + xSize > _WIDTH)
+ xSize = _WIDTH - xPos;
- if (x_pos < 0) {
- x_size += x_pos;
- x_pos = 0;
+ if (xPos < 0) {
+ xSize += xPos;
+ xPos = 0;
}
- if (y_pos + y_size > _HEIGHT)
- y_size = _HEIGHT - y_pos;
+ if (yPos + ySize > _HEIGHT)
+ ySize = _HEIGHT - yPos;
- if (y_pos < 0) {
- y_size += y_pos;
- y_pos = 0;
+ if (yPos < 0) {
+ ySize += yPos;
+ yPos = 0;
}
- if (x_size <= 0 || y_size <= 0)
+ if (xSize <= 0 || ySize <= 0)
return;
- p0 = &_vm->game.sbuf[x_pos + y_pos * _WIDTH];
+ p0 = &_vm->_game.sbuf[xPos + yPos * _WIDTH];
q = s->buffer;
- offset = _vm->game.line_min_print * CHAR_LINES;
- for (y = 0; y < y_size; y++) {
- memcpy(p0, q, x_size);
- _gfx->putPixelsA(x_pos, y_pos + y + offset, x_size, p0);
- q += x_size;
+ offset = _vm->_game.lineMinPrint * CHAR_LINES;
+ for (y = 0; y < ySize; y++) {
+ memcpy(p0, q, xSize);
+ _gfx->putPixelsA(xPos, yPos + y + offset, xSize, p0);
+ q += xSize;
p0 += _WIDTH;
}
}
@@ -247,9 +247,9 @@ void SpritesMgr::objs_restorearea(sprite *s) {
/**
* Condition to determine whether a sprite will be in the 'updating' list.
*/
-bool SpritesMgr::test_updating(vt_entry *v, AgiEngine *agi) {
+bool SpritesMgr::testUpdating(VtEntry *v, AgiEngine *agi) {
/* Sanity check (see bug #779302) */
- if (~agi->game.dir_view[v->current_view].flags & RES_LOADED)
+ if (~agi->_game.dirView[v->currentView].flags & RES_LOADED)
return false;
return (v->flags & (ANIMATED | UPDATE | DRAWN)) == (ANIMATED | UPDATE | DRAWN);
@@ -258,9 +258,9 @@ bool SpritesMgr::test_updating(vt_entry *v, AgiEngine *agi) {
/**
* Condition to determine whether a sprite will be in the 'non-updating' list.
*/
-bool SpritesMgr::test_not_updating(vt_entry *v, AgiEngine *agi) {
+bool SpritesMgr::testNotUpdating(VtEntry *v, AgiEngine *vm) {
/* Sanity check (see bug #779302) */
- if (~agi->game.dir_view[v->current_view].flags & RES_LOADED)
+ if (~vm->_game.dirView[v->currentView].flags & RES_LOADED)
return false;
return (v->flags & (ANIMATED | UPDATE | DRAWN)) == (ANIMATED | DRAWN);
@@ -269,14 +269,14 @@ bool SpritesMgr::test_not_updating(vt_entry *v, AgiEngine *agi) {
/**
* Convert sprite priority to y value.
*/
-INLINE int SpritesMgr::prio_to_y(int p) {
+INLINE int SpritesMgr::prioToY(int p) {
int i;
if (p == 0)
return -1;
for (i = 167; i >= 0; i--) {
- if (_vm->game.pri_table[i] < p)
+ if (_vm->_game.priTable[i] < p)
return i;
}
@@ -286,18 +286,18 @@ INLINE int SpritesMgr::prio_to_y(int p) {
/**
* Create and initialize a new sprite structure.
*/
-sprite *SpritesMgr::new_sprite(vt_entry *v) {
- sprite *s;
- s = (sprite *)pool_alloc(sizeof(sprite));
+Sprite *SpritesMgr::newSprite(VtEntry *v) {
+ Sprite *s;
+ s = (Sprite *)poolAlloc(sizeof(Sprite));
if (s == NULL)
return NULL;
s->v = v; /* link sprite to associated view table entry */
- s->x_pos = v->x_pos;
- s->y_pos = v->y_pos - v->y_size + 1;
- s->x_size = v->x_size;
- s->y_size = v->y_size;
- s->buffer = (uint8 *) pool_alloc(s->x_size * s->y_size);
+ 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 */
return s;
@@ -306,29 +306,29 @@ sprite *SpritesMgr::new_sprite(vt_entry *v) {
/**
* Insert sprite in the specified sprite list.
*/
-void SpritesMgr::spr_addlist(SpriteList& l, vt_entry *v) {
- sprite *s = new_sprite(v);
+void SpritesMgr::sprAddlist(SpriteList &l, VtEntry *v) {
+ Sprite *s = newSprite(v);
l.push_back(s);
}
/**
* Sort sprites from lower y values to build a sprite list.
*/
-void SpritesMgr::build_list(SpriteList& l, bool (*test) (vt_entry *, AgiEngine *)) {
+void SpritesMgr::buildList(SpriteList &l, bool (*test)(VtEntry *, AgiEngine *)) {
int i, j, k;
- vt_entry *v;
- vt_entry *entry[0x100];
- int y_val[0x100];
- int min_y = 0xff, min_index = 0;
+ VtEntry *v;
+ VtEntry *entry[0x100];
+ int yVal[0x100];
+ int minY = 0xff, minIndex = 0;
/* fill the arrays with all sprites that satisfy the 'test'
* condition and their y values
*/
i = 0;
- for (v = _vm->game.view_table; v < &_vm->game.view_table[MAX_VIEWTABLE]; v++) {
+ for (v = _vm->_game.viewTable; v < &_vm->_game.viewTable[MAX_VIEWTABLE]; v++) {
if ((*test)(v, _vm)) {
entry[i] = v;
- y_val[i] = v->flags & FIXED_PRIORITY ? prio_to_y(v->priority) : v->y_pos;
+ yVal[i] = v->flags & FIXED_PRIORITY ? prioToY(v->priority) : v->yPos;
i++;
}
}
@@ -337,42 +337,42 @@ void SpritesMgr::build_list(SpriteList& l, bool (*test) (vt_entry *, AgiEngine *
* sprite in the list
*/
for (j = 0; j < i; j++) {
- min_y = 0xff;
+ minY = 0xff;
for (k = 0; k < i; k++) {
- if (y_val[k] < min_y) {
- min_index = k;
- min_y = y_val[k];
+ if (yVal[k] < minY) {
+ minIndex = k;
+ minY = yVal[k];
}
}
- y_val[min_index] = 0xff;
- spr_addlist(l, entry[min_index]);
+ yVal[minIndex] = 0xff;
+ sprAddlist(l, entry[minIndex]);
}
}
/**
* Build list of updating sprites.
*/
-void SpritesMgr::build_upd_blitlist() {
- build_list(spr_upd, test_updating);
+void SpritesMgr::buildUpdBlitlist() {
+ buildList(_sprUpd, testUpdating);
}
/**
* Build list of non-updating sprites.
*/
-void SpritesMgr::build_nonupd_blitlist() {
- build_list(spr_nonupd, test_not_updating);
+void SpritesMgr::buildNonupdBlitlist() {
+ buildList(_sprNonupd, testNotUpdating);
}
/**
* Clear the given sprite list.
*/
-void SpritesMgr::free_list(SpriteList& l) {
+void SpritesMgr::freeList(SpriteList &l) {
SpriteList::iterator iter;
for (iter = l.reverse_begin(); iter != l.end(); ) {
- sprite* s = *iter;
- pool_release(s->buffer);
- pool_release(s);
+ Sprite* s = *iter;
+ poolRelease(s->buffer);
+ poolRelease(s);
iter = l.reverse_erase(iter);
}
}
@@ -381,49 +381,49 @@ void SpritesMgr::free_list(SpriteList& l) {
* Copy sprites from the pic buffer to the screen buffer, and check if
* sprites of the given list have moved.
*/
-void SpritesMgr::commit_sprites(SpriteList& l) {
+void SpritesMgr::commitSprites(SpriteList &l) {
SpriteList::iterator iter;
for (iter = l.begin(); iter != l.end(); ++iter) {
- sprite *s = *iter;
+ Sprite *s = *iter;
int x1, y1, x2, y2, w, h;
- w = (s->v->cel_data->width > s->v->cel_data_2->width) ?
- s->v->cel_data->width : s->v->cel_data_2->width;
+ w = (s->v->celData->width > s->v->celData2->width) ?
+ s->v->celData->width : s->v->celData2->width;
- h = (s->v->cel_data->height >
- s->v->cel_data_2->height) ? s->v->cel_data->
- height : s->v->cel_data_2->height;
+ h = (s->v->celData->height >
+ s->v->celData2->height) ? s->v->celData->
+ height : s->v->celData2->height;
- s->v->cel_data_2 = s->v->cel_data;
+ s->v->celData2 = s->v->celData;
- if (s->v->x_pos < s->v->x_pos2) {
- x1 = s->v->x_pos;
- x2 = s->v->x_pos2 + w - 1;
+ if (s->v->xPos < s->v->xPos2) {
+ x1 = s->v->xPos;
+ x2 = s->v->xPos2 + w - 1;
} else {
- x1 = s->v->x_pos2;
- x2 = s->v->x_pos + w - 1;
+ x1 = s->v->xPos2;
+ x2 = s->v->xPos + w - 1;
}
- if (s->v->y_pos < s->v->y_pos2) {
- y1 = s->v->y_pos - h + 1;
- y2 = s->v->y_pos2;
+ if (s->v->yPos < s->v->yPos2) {
+ y1 = s->v->yPos - h + 1;
+ y2 = s->v->yPos2;
} else {
- y1 = s->v->y_pos2 - h + 1;
- y2 = s->v->y_pos;
+ y1 = s->v->yPos2 - h + 1;
+ y2 = s->v->yPos;
}
- commit_block(x1, y1, x2, y2);
+ commitBlock(x1, y1, x2, y2);
- if (s->v->step_time_count != s->v->step_time)
+ if (s->v->stepTimeCount != s->v->stepTime)
continue;
- if (s->v->x_pos == s->v->x_pos2 && s->v->y_pos == s->v->y_pos2) {
+ if (s->v->xPos == s->v->xPos2 && s->v->yPos == s->v->yPos2) {
s->v->flags |= DIDNT_MOVE;
continue;
}
- s->v->x_pos2 = s->v->x_pos;
- s->v->y_pos2 = s->v->y_pos;
+ s->v->xPos2 = s->v->xPos;
+ s->v->yPos2 = s->v->yPos;
s->v->flags &= ~DIDNT_MOVE;
}
}
@@ -431,29 +431,29 @@ void SpritesMgr::commit_sprites(SpriteList& l) {
/**
* Erase all sprites in the given list.
*/
-void SpritesMgr::erase_sprites(SpriteList& l) {
+void SpritesMgr::eraseSprites(SpriteList &l) {
SpriteList::iterator iter;
for (iter = l.reverse_begin(); iter != l.end(); --iter) {
- sprite *s = *iter;
- objs_restorearea(s);
+ Sprite *s = *iter;
+ objsRestoreArea(s);
}
- free_list(l);
+ freeList(l);
}
/**
* Blit all sprites in the given list.
*/
-void SpritesMgr::blit_sprites(SpriteList& l) {
+void SpritesMgr::blitSprites(SpriteList& l) {
int hidden;
SpriteList::iterator iter;
for (iter = l.begin(); iter != l.end(); ++iter) {
- sprite *s = *iter;
- objs_savearea(s);
+ Sprite *s = *iter;
+ objsSaveArea(s);
debugC(8, kDebugLevelSprites, "s->v->entry = %d (prio %d)", s->v->entry, s->v->priority);
- hidden = blit_cel(s->x_pos, s->y_pos, s->v->priority, s->v->cel_data);
+ hidden = blitCel(s->xPos, s->yPos, s->v->priority, s->v->celData);
if (s->v->entry == 0) { /* if ego, update f1 */
- _vm->setflag(F_ego_invisible, hidden);
+ _vm->setflag(fEgoInvisible, hidden);
}
}
}
@@ -462,18 +462,18 @@ void SpritesMgr::blit_sprites(SpriteList& l) {
* Public functions
*/
-void SpritesMgr::commit_upd_sprites() {
- commit_sprites(spr_upd);
+void SpritesMgr::commitUpdSprites() {
+ commitSprites(_sprUpd);
}
-void SpritesMgr::commit_nonupd_sprites() {
- commit_sprites(spr_nonupd);
+void SpritesMgr::commitNonupdSprites() {
+ commitSprites(_sprNonupd);
}
/* check moves in both lists */
-void SpritesMgr::commit_both() {
- commit_upd_sprites();
- commit_nonupd_sprites();
+void SpritesMgr::commitBoth() {
+ commitUpdSprites();
+ commitNonupdSprites();
}
/**
@@ -485,8 +485,8 @@ void SpritesMgr::commit_both() {
* @see erase_nonupd_sprites()
* @see erase_both()
*/
-void SpritesMgr::erase_upd_sprites() {
- erase_sprites(spr_upd);
+void SpritesMgr::eraseUpdSprites() {
+ eraseSprites(_sprUpd);
}
/**
@@ -498,8 +498,8 @@ void SpritesMgr::erase_upd_sprites() {
* @see erase_upd_sprites()
* @see erase_both()
*/
-void SpritesMgr::erase_nonupd_sprites() {
- erase_sprites(spr_nonupd);
+void SpritesMgr::eraseNonupdSprites() {
+ eraseSprites(_sprNonupd);
}
/**
@@ -511,9 +511,9 @@ void SpritesMgr::erase_nonupd_sprites() {
* @see erase_upd_sprites()
* @see erase_nonupd_sprites()
*/
-void SpritesMgr::erase_both() {
- erase_upd_sprites();
- erase_nonupd_sprites();
+void SpritesMgr::eraseBoth() {
+ eraseUpdSprites();
+ eraseNonupdSprites();
}
/**
@@ -524,10 +524,10 @@ void SpritesMgr::erase_both() {
* @see blit_nonupd_sprites()
* @see blit_both()
*/
-void SpritesMgr::blit_upd_sprites() {
+void SpritesMgr::blitUpdSprites() {
debugC(7, kDebugLevelSprites, "blit updating");
- build_upd_blitlist();
- blit_sprites(spr_upd);
+ buildUpdBlitlist();
+ blitSprites(_sprUpd);
}
/**
@@ -538,10 +538,10 @@ void SpritesMgr::blit_upd_sprites() {
* @see blit_upd_sprites()
* @see blit_both()
*/
-void SpritesMgr::blit_nonupd_sprites() {
+void SpritesMgr::blitNonupdSprites() {
debugC(7, kDebugLevelSprites, "blit non-updating");
- build_nonupd_blitlist();
- blit_sprites(spr_nonupd);
+ buildNonupdBlitlist();
+ blitSprites(_sprNonupd);
}
/**
@@ -552,9 +552,9 @@ void SpritesMgr::blit_nonupd_sprites() {
* @see blit_upd_sprites()
* @see blit_nonupd_sprites()
*/
-void SpritesMgr::blit_both() {
- blit_nonupd_sprites();
- blit_upd_sprites();
+void SpritesMgr::blitBoth() {
+ blitNonupdSprites();
+ blitUpdSprites();
}
/**
@@ -570,23 +570,23 @@ void SpritesMgr::blit_both() {
* @param pri priority to use
* @param mar if < 4, create a margin around the the base of the cel
*/
-void SpritesMgr::add_to_pic(int view, int loop, int cel, int x, int y, int pri, int mar) {
- view_cel *c = NULL;
+void SpritesMgr::addToPic(int view, int loop, int cel, int x, int y, int pri, int mar) {
+ ViewCel *c = NULL;
int x1, y1, x2, y2, y3;
uint8 *p1, *p2;
debugC(3, kDebugLevelSprites, "v=%d, l=%d, c=%d, x=%d, y=%d, p=%d, m=%d", view, loop, cel, x, y, pri, mar);
- _vm->record_image_stack_call(ADD_VIEW, view, loop, cel, x, y, pri, mar);
+ _vm->recordImageStackCall(ADD_VIEW, view, loop, cel, x, y, pri, mar);
/*
* Was hardcoded to 8, changed to pri_table[y] to fix Gold
* Rush (see bug #587558)
*/
if (pri == 0)
- pri = _vm->game.pri_table[y];
+ pri = _vm->_game.priTable[y];
- c = &_vm->game.views[view].loop[loop].cel[cel];
+ c = &_vm->_game.views[view].loop[loop].cel[cel];
x1 = x;
y1 = y - c->height + 1;
@@ -606,10 +606,10 @@ void SpritesMgr::add_to_pic(int view, int loop, int cel, int x, int y, int pri,
if (y2 >= _HEIGHT)
y2 = _HEIGHT - 1;
- erase_both();
+ eraseBoth();
debugC(4, kDebugLevelSprites, "blit_cel (%d, %d, %d, c)", x, y, pri);
- blit_cel(x1, y1, pri, c);
+ blitCel(x1, y1, pri, c);
/* If margin is 0, 1, 2, or 3, the base of the cel is
* surrounded with a rectangle of the corresponding priority.
@@ -627,8 +627,8 @@ void SpritesMgr::add_to_pic(int view, int loop, int cel, int x, int y, int pri,
// don't let box extend below y.
if (y3 > y2) y3 = y2;
- p1 = &_vm->game.sbuf[x1 + y3 * _WIDTH];
- p2 = &_vm->game.sbuf[x2 + y3 * _WIDTH];
+ p1 = &_vm->_game.sbuf[x1 + y3 * _WIDTH];
+ p2 = &_vm->_game.sbuf[x2 + y3 * _WIDTH];
for (y = y3; y <= y2; y++) {
if ((*p1 >> 4) >= 4)
@@ -640,8 +640,8 @@ void SpritesMgr::add_to_pic(int view, int loop, int cel, int x, int y, int pri,
}
debugC(4, kDebugLevelSprites, "pri box: %d %d %d %d (%d)", x1, y3, x2, y2, mar);
- p1 = &_vm->game.sbuf[x1 + y3 * _WIDTH];
- p2 = &_vm->game.sbuf[x1 + y2 * _WIDTH];
+ p1 = &_vm->_game.sbuf[x1 + y3 * _WIDTH];
+ p2 = &_vm->_game.sbuf[x1 + y2 * _WIDTH];
for (x = x1; x <= x2; x++) {
if ((*p1 >> 4) >= 4)
*p1 = (mar << 4) | (*p1 & 0x0f);
@@ -652,10 +652,10 @@ void SpritesMgr::add_to_pic(int view, int loop, int cel, int x, int y, int pri,
}
}
- blit_both();
+ blitBoth();
debugC(4, kDebugLevelSprites, "commit_block (%d, %d, %d, %d)", x1, y1, x2, y2);
- commit_block(x1, y1, x2, y2);
+ commitBlock(x1, y1, x2, y2);
}
/**
@@ -664,13 +664,13 @@ void SpritesMgr::add_to_pic(int view, int loop, int cel, int x, int y, int pri,
* a message box with the object description.
* @param n Number of the object to show
*/
-void SpritesMgr::show_obj(int n) {
- view_cel *c;
- sprite s;
+void SpritesMgr::showObj(int n) {
+ ViewCel *c;
+ Sprite s;
int x1, y1, x2, y2;
_vm->agiLoadResource(rVIEW, n);
- if (!(c = &_vm->game.views[n].loop[0].cel[0]))
+ if (!(c = &_vm->_game.views[n].loop[0].cel[0]))
return;
x1 = (_WIDTH - c->width) / 2;
@@ -678,27 +678,27 @@ void SpritesMgr::show_obj(int n) {
x2 = x1 + c->width - 1;
y2 = y1 + c->height - 1;
- s.x_pos = x1;
- s.y_pos = y1;
- s.x_size = c->width;
- s.y_size = c->height;
- s.buffer = (uint8 *)malloc(s.x_size * s.y_size);
+ s.xPos = x1;
+ s.yPos = y1;
+ s.xSize = c->width;
+ s.ySize = c->height;
+ s.buffer = (uint8 *)malloc(s.xSize * s.ySize);
- objs_savearea(&s);
- blit_cel(x1, y1, s.x_size, c);
- commit_block(x1, y1, x2, y2);
- _vm->message_box(_vm->game.views[n].descr);
- objs_restorearea(&s);
- commit_block(x1, y1, x2, y2);
+ objsSaveArea(&s);
+ blitCel(x1, y1, s.xSize, c);
+ commitBlock(x1, y1, x2, y2);
+ _vm->messageBox(_vm->_game.views[n].descr);
+ objsRestoreArea(&s);
+ commitBlock(x1, y1, x2, y2);
free(s.buffer);
}
-void SpritesMgr::commit_block(int x1, int y1, int x2, int y2) {
+void SpritesMgr::commitBlock(int x1, int y1, int x2, int y2) {
int i, w, offset;
uint8 *q;
- if (!_vm->game.picture_shown)
+ if (!_vm->_game.pictureShown)
return;
/* Clipping */
@@ -722,8 +722,8 @@ void SpritesMgr::commit_block(int x1, int y1, int x2, int y2) {
debugC(7, kDebugLevelSprites, "%d, %d, %d, %d", x1, y1, x2, y2);
w = x2 - x1 + 1;
- q = &_vm->game.sbuf[x1 + _WIDTH * y1];
- offset = _vm->game.line_min_print * CHAR_LINES;
+ q = &_vm->_game.sbuf[x1 + _WIDTH * y1];
+ offset = _vm->_game.lineMinPrint * CHAR_LINES;
for (i = y1; i <= y2; i++) {
_gfx->putPixelsA(x1, i + offset, w, q);
q += _WIDTH;
@@ -736,12 +736,12 @@ SpritesMgr::SpritesMgr(AgiEngine *agi, GfxMgr *gfx) {
_vm = agi;
_gfx = gfx;
- sprite_pool = (uint8 *)malloc(POOL_SIZE);
- pool_top = sprite_pool;
+ _spritePool = (uint8 *)malloc(POOL_SIZE);
+ _poolTop = _spritePool;
}
SpritesMgr::~SpritesMgr() {
- free(sprite_pool);
+ free(_spritePool);
}
-} // End of namespace Agi
+} // End of namespace Agi
diff --git a/engines/agi/sprite.h b/engines/agi/sprite.h
index 243d72f058..d818365adc 100644
--- a/engines/agi/sprite.h
+++ b/engines/agi/sprite.h
@@ -30,8 +30,8 @@
namespace Agi {
-struct sprite;
-typedef Common::List<sprite*> SpriteList;
+struct Sprite;
+typedef Common::List<Sprite*> SpriteList;
class AgiEngine;
class GfxMgr;
@@ -42,56 +42,56 @@ private:
GfxMgr *_gfx;
AgiEngine *_vm;
- uint8 *sprite_pool;
- uint8 *pool_top;
+ uint8 *_spritePool;
+ uint8 *_poolTop;
/*
* Sprite management functions
*/
- SpriteList spr_upd;
- SpriteList spr_nonupd;
+ SpriteList _sprUpd;
+ SpriteList _sprNonupd;
- void *pool_alloc(int size);
- void pool_release(void *s);
- void blit_pixel(uint8 *p, uint8 *end, uint8 col, int spr, int width, int *hidden);
- int blit_cel(int x, int y, int spr, view_cel *c);
- void objs_savearea(sprite *s);
- void objs_restorearea(sprite *s);
+ void *poolAlloc(int size);
+ void poolRelease(void *s);
+ void blitPixel(uint8 *p, uint8 *end, uint8 col, int spr, int width, int *hidden);
+ int blitCel(int x, int y, int spr, ViewCel *c);
+ void objsSaveArea(Sprite *s);
+ void objsRestoreArea(Sprite *s);
- FORCEINLINE int prio_to_y(int p);
- sprite *new_sprite(vt_entry *v);
- void spr_addlist(SpriteList& l, vt_entry *v);
- void build_list(SpriteList& l, bool (*test) (vt_entry *, AgiEngine *));
- void build_upd_blitlist();
- void build_nonupd_blitlist();
- void free_list(SpriteList& l);
- void commit_sprites(SpriteList& l);
- void erase_sprites(SpriteList& l);
- void blit_sprites(SpriteList& l);
- static bool test_updating(vt_entry *v, AgiEngine *);
- static bool test_not_updating(vt_entry *v, AgiEngine *);
+ FORCEINLINE int prioToY(int p);
+ Sprite *newSprite(VtEntry *v);
+ void sprAddlist(SpriteList &l, VtEntry *v);
+ void buildList(SpriteList &l, bool (*test)(VtEntry *, AgiEngine *));
+ void buildUpdBlitlist();
+ void buildNonupdBlitlist();
+ void freeList(SpriteList &l);
+ void commitSprites(SpriteList &l);
+ void eraseSprites(SpriteList &l);
+ void blitSprites(SpriteList &l);
+ static bool testUpdating(VtEntry *v, AgiEngine *);
+ static bool testNotUpdating(VtEntry *v, AgiEngine *);
public:
SpritesMgr(AgiEngine *agi, GfxMgr *gfx);
~SpritesMgr();
- int init_sprites(void);
- void deinit_sprites(void);
- void erase_upd_sprites(void);
- void erase_nonupd_sprites(void);
- void erase_both(void);
- void blit_upd_sprites(void);
- void blit_nonupd_sprites(void);
- void blit_both(void);
- void commit_upd_sprites(void);
- void commit_nonupd_sprites(void);
- void commit_both(void);
- void add_to_pic(int, int, int, int, int, int, int);
- void show_obj(int);
- void commit_block(int, int, int, int);
+ int initSprites();
+ void deinitSprites();
+ void eraseUpdSprites();
+ void eraseNonupdSprites();
+ void eraseBoth();
+ void blitUpdSprites();
+ void blitNonupdSprites();
+ void blitBoth();
+ void commitUpdSprites();
+ void commitNonupdSprites();
+ void commitBoth();
+ void addToPic(int, int, int, int, int, int, int);
+ void showObj(int);
+ void commitBlock(int, int, int, int);
};
-} // End of namespace Agi
+} // End of namespace Agi
-#endif /* AGI_SPRITE_H */
+#endif /* AGI_SPRITE_H */
diff --git a/engines/agi/text.cpp b/engines/agi/text.cpp
index b0ef2a630b..735f58129c 100644
--- a/engines/agi/text.cpp
+++ b/engines/agi/text.cpp
@@ -30,7 +30,7 @@
namespace Agi {
-void AgiEngine::print_text2(int l, const char *msg, int foff, int xoff, int yoff,
+void AgiEngine::printText2(int l, const char *msg, int foff, int xoff, int yoff,
int len, int fg, int bg, bool checkerboard) {
int x1, y1;
int maxx, minx, ofoff;
@@ -113,14 +113,14 @@ void AgiEngine::print_text2(int l, const char *msg, int foff, int xoff, int yoff
/* len is in characters, not pixels!!
*/
-void AgiEngine::blit_textbox(const char *p, int y, int x, int len) {
+void AgiEngine::blitTextbox(const char *p, int y, int x, int len) {
/* if x | y = -1, then centre the box */
int xoff, yoff, lin, h, w;
char *msg, *m;
debugC(3, kDebugLevelText, "x=%d, y=%d, len=%d", x, y, len);
- if (game.window.active)
- close_window();
+ if (_game.window.active)
+ closeWindow();
if (x == 0 && y == 0 && len == 0)
x = y = -1;
@@ -132,7 +132,7 @@ void AgiEngine::blit_textbox(const char *p, int y, int x, int len) {
yoff = y * CHAR_LINES;
len--;
- m = msg = word_wrap_string(agi_sprintf(p), &len);
+ m = msg = wordWrapString(agiSprintf(p), &len);
for (lin = 1; *m; m++) {
/* Test \r for MacOS 8 */
@@ -154,9 +154,9 @@ void AgiEngine::blit_textbox(const char *p, int y, int x, int len) {
if (yoff < 0)
yoff = (GFX_HEIGHT - 3 * CHAR_LINES - h) / 2;
- draw_window(xoff, yoff, xoff + w - 1, yoff + h - 1);
+ drawWindow(xoff, yoff, xoff + w - 1, yoff + h - 1);
- print_text2(2, msg, 0, CHAR_COLS + xoff, CHAR_LINES + yoff,
+ printText2(2, msg, 0, CHAR_COLS + xoff, CHAR_LINES + yoff,
len + 1, MSG_BOX_TEXT, MSG_BOX_COLOUR);
free(msg);
@@ -164,20 +164,20 @@ void AgiEngine::blit_textbox(const char *p, int y, int x, int len) {
_gfx->doUpdate();
}
-void AgiEngine::erase_textbox() {
- if (!game.window.active) {
+void AgiEngine::eraseTextbox() {
+ if (!_game.window.active) {
debugC(3, kDebugLevelText, "no window active");
return;
}
- debugC(4, kDebugLevelText, "x1=%d, y1=%d, x2=%d, y2=%d", game.window.x1,
- game.window.y1, game.window.x2, game.window.y2);
+ debugC(4, kDebugLevelText, "x1=%d, y1=%d, x2=%d, y2=%d", _game.window.x1,
+ _game.window.y1, _game.window.x2, _game.window.y2);
- _gfx->restoreBlock(game.window.x1, game.window.y1,
- game.window.x2, game.window.y2, game.window.buffer);
+ _gfx->restoreBlock(_game.window.x1, _game.window.y1,
+ _game.window.x2, _game.window.y2, _game.window.buffer);
- free(game.window.buffer);
- game.window.active = false;
+ free(_game.window.buffer);
+ _game.window.active = false;
_gfx->doUpdate();
}
@@ -189,23 +189,23 @@ void AgiEngine::erase_textbox() {
/**
* Print text in the AGI engine screen.
*/
-void AgiEngine::print_text(const char *msg, int f, int x, int y, int len, int fg, int bg, bool checkerboard) {
+void AgiEngine::printText(const char *msg, int f, int x, int y, int len, int fg, int bg, bool checkerboard) {
f *= CHAR_COLS;
x *= CHAR_COLS;
y *= CHAR_LINES;
debugC(4, kDebugLevelText, "%s, %d, %d, %d, %d, %d, %d", msg, f, x, y, len, fg, bg);
- print_text2(0, agi_sprintf(msg), f, x, y, len, fg, bg, checkerboard);
+ printText2(0, agiSprintf(msg), f, x, y, len, fg, bg, checkerboard);
}
/**
* Print text in the AGI engine console.
*/
-void AgiEngine::print_text_console(const char *msg, int x, int y, int len, int fg, int bg) {
+void AgiEngine::printTextConsole(const char *msg, int x, int y, int len, int fg, int bg) {
x *= CHAR_COLS;
y *= 10;
- print_text2(1, msg, 0, x, y, len, fg, bg);
+ printText2(1, msg, 0, x, y, len, fg, bg);
}
/**
@@ -213,7 +213,7 @@ void AgiEngine::print_text_console(const char *msg, int x, int y, int len, int f
* @param str String to wrap.
* @param len Length of line.
*/
-char *AgiEngine::word_wrap_string(char *str, int *len) {
+char *AgiEngine::wordWrapString(char *str, int *len) {
/* If the message has a long word (longer than 31 character) then
* loop in line 239 (for (; *v != ' '; v--, c--);) can wrap
* around 0 and write large number in c. This causes returned
@@ -275,13 +275,13 @@ char *AgiEngine::word_wrap_string(char *str, int *len) {
/**
* Remove existing window, if any.
*/
-void AgiEngine::close_window() {
+void AgiEngine::closeWindow() {
debugC(4, kDebugLevelText, "close window");
- _sprites->erase_both();
- erase_textbox(); /* remove window, if any */
- _sprites->blit_both();
- _sprites->commit_both(); /* redraw sprites */
- game.has_window = false;
+ _sprites->eraseBoth();
+ eraseTextbox(); /* remove window, if any */
+ _sprites->blitBoth();
+ _sprites->commitBoth(); /* redraw sprites */
+ _game.hasWindow = false;
}
/**
@@ -290,15 +290,15 @@ void AgiEngine::close_window() {
* centered in the screen and waits until a key is pressed.
* @param p The text to be displayed
*/
-int AgiEngine::message_box(const char *s) {
+int AgiEngine::messageBox(const char *s) {
int k;
- _sprites->erase_both();
- blit_textbox(s, -1, -1, -1);
- _sprites->blit_both();
- k = wait_key();
+ _sprites->eraseBoth();
+ blitTextbox(s, -1, -1, -1);
+ _sprites->blitBoth();
+ k = waitKey();
debugC(4, kDebugLevelText, "wait_key returned %02x", k);
- close_window();
+ closeWindow();
return k;
}
@@ -310,18 +310,18 @@ int AgiEngine::message_box(const char *s) {
* @param p The text to be displayed
* @param b NULL-terminated list of button labels
*/
-int AgiEngine::selection_box(const char *m, const char **b) {
+int AgiEngine::selectionBox(const char *m, const char **b) {
int x, y, i, s;
int key, active = 0;
int rc = -1;
int bx[5], by[5];
- _sprites->erase_both();
- blit_textbox(m, -1, -1, -1);
+ _sprites->eraseBoth();
+ blitTextbox(m, -1, -1, -1);
- x = game.window.x1 + 5 * CHAR_COLS / 2;
- y = game.window.y2 - 5 * CHAR_LINES / 2;
- s = game.window.x2 - game.window.x1 + 1 - 5 * CHAR_COLS;
+ x = _game.window.x1 + 5 * CHAR_COLS / 2;
+ y = _game.window.y2 - 5 * CHAR_LINES / 2;
+ s = _game.window.x2 - _game.window.x1 + 1 - 5 * CHAR_COLS;
debugC(3, kDebugLevelText, "s = %d", s);
/* Automatically position buttons */
@@ -342,7 +342,7 @@ int AgiEngine::selection_box(const char *m, const char **b) {
x += CHAR_COLS * strlen(b[i]) + s;
}
- _sprites->blit_both();
+ _sprites->blitBoth();
/* clear key queue */
while (_gfx->keypress()) {
@@ -355,7 +355,7 @@ int AgiEngine::selection_box(const char *m, const char **b) {
_gfx->drawButton(bx[i], by[i], b[i], i == active, 0, MSG_BOX_TEXT, MSG_BOX_COLOUR);
_gfx->pollTimer(); /* msdos driver -> does nothing */
- key = do_poll_keyboard();
+ key = doPollKeyboard();
switch (key) {
case KEY_ENTER:
rc = active;
@@ -384,7 +384,7 @@ press:
debugC(4, kDebugLevelText, "Button pressed: %d", rc);
getout:
- close_window();
+ closeWindow();
debugC(2, kDebugLevelText, "Result = %d", rc);
return rc;
@@ -405,43 +405,43 @@ int AgiEngine::print(const char *p, int lin, int col, int len) {
if (len == 0)
len = 30;
- blit_textbox(p, lin, col, len);
+ blitTextbox(p, lin, col, len);
- if (getflag(F_output_mode)) {
+ if (getflag(fOutputMode)) {
/* non-blocking window */
- setflag(F_output_mode, false);
+ setflag(fOutputMode, false);
return 1;
}
/* blocking */
- if (game.vars[V_window_reset] == 0) {
+ if (_game.vars[vWindowReset] == 0) {
int k;
- setvar(V_key, 0);
- k = wait_key();
- close_window();
+ setvar(vKey, 0);
+ k = waitKey();
+ closeWindow();
return k;
}
/* timed window */
debugC(3, kDebugLevelText, "f15==0, v21==%d => timed", getvar(21));
- game.msg_box_ticks = getvar(V_window_reset) * 10;
- setvar(V_key, 0);
+ _game.msgBoxTicks = getvar(vWindowReset) * 10;
+ setvar(vKey, 0);
do {
- main_cycle();
- if (game.keypress == KEY_ENTER) {
+ mainCycle();
+ if (_game.keypress == KEY_ENTER) {
debugC(4, kDebugLevelText, "KEY_ENTER");
- setvar(V_window_reset, 0);
- game.keypress = 0;
+ setvar(vWindowReset, 0);
+ _game.keypress = 0;
break;
}
- } while (game.msg_box_ticks > 0);
+ } while (_game.msgBoxTicks > 0);
- setvar(V_window_reset, 0);
+ setvar(vWindowReset, 0);
- close_window();
+ closeWindow();
return 0;
}
@@ -449,7 +449,7 @@ int AgiEngine::print(const char *p, int lin, int col, int len) {
/**
*
*/
-void AgiEngine::print_status(const char *message, ...) {
+void AgiEngine::printStatus(const char *message, ...) {
char x[42];
va_list args;
@@ -460,10 +460,10 @@ void AgiEngine::print_status(const char *message, ...) {
va_end(args);
debugC(4, kDebugLevelText, "fg=%d, bg=%d", STATUS_FG, STATUS_BG);
- print_text(x, 0, 0, game.line_status, 40, STATUS_FG, STATUS_BG);
+ printText(x, 0, 0, _game.lineStatus, 40, STATUS_FG, STATUS_BG);
}
-char *AgiEngine::safe_strcat(char *s, const char *t) {
+char *AgiEngine::safeStrcat(char *s, const char *t) {
if (t != NULL)
strcat(s, t);
@@ -478,12 +478,12 @@ char *AgiEngine::safe_strcat(char *s, const char *t) {
* @param n logic number
*/
#define MAX_LEN 768
-char *AgiEngine::agi_sprintf(const char *s) {
+char *AgiEngine::agiSprintf(const char *s) {
static char y[MAX_LEN];
char x[MAX_LEN];
char z[16], *p;
- debugC(3, kDebugLevelText, "logic %d, '%s'", game.lognum, s);
+ debugC(3, kDebugLevelText, "logic %d, '%s'", _game.lognum, s);
p = x;
for (*p = 0; *s;) {
@@ -517,28 +517,28 @@ char *AgiEngine::agi_sprintf(const char *s) {
} else {
i = 15 - i;
}
- safe_strcat(p, z + i);
+ safeStrcat(p, z + i);
break;
case '0':
i = strtoul(s, NULL, 10) - 1;
- safe_strcat(p, object_name(i));
+ safeStrcat(p, objectName(i));
break;
case 'g':
i = strtoul(s, NULL, 10) - 1;
- safe_strcat(p, game.logics[0].texts[i]);
+ safeStrcat(p, _game.logics[0].texts[i]);
break;
case 'w':
i = strtoul(s, NULL, 10) - 1;
- safe_strcat(p, game.ego_words[i].word);
+ safeStrcat(p, _game.egoWords[i].word);
break;
case 's':
i = strtoul(s, NULL, 10);
- safe_strcat(p, game.strings[i]);
+ safeStrcat(p, _game.strings[i]);
break;
case 'm':
i = strtoul(s, NULL, 10) - 1;
- if (game.logics[game.lognum].num_texts > i)
- safe_strcat(p, agi_sprintf(game. logics[game.lognum].texts[i]));
+ if (_game.logics[_game.lognum].numTexts > i)
+ safeStrcat(p, agiSprintf(_game. logics[_game.lognum].texts[i]));
break;
}
@@ -564,51 +564,51 @@ literal:
/**
* Write the status line.
*/
-void AgiEngine::write_status() {
+void AgiEngine::writeStatus() {
char x[64];
if (_debug.statusline) {
- print_status("%3d(%03d) %3d,%3d(%3d,%3d) ",
- getvar(0), getvar(1), game.view_table[0].x_pos,
- game.view_table[0].y_pos, WIN_TO_PIC_X(g_mouse.x),
+ printStatus("%3d(%03d) %3d,%3d(%3d,%3d) ",
+ getvar(0), getvar(1), _game.viewTable[0].xPos,
+ _game.viewTable[0].yPos, WIN_TO_PIC_X(g_mouse.x),
WIN_TO_PIC_Y(g_mouse.y));
return;
}
- if (!game.status_line) {
- int l = game.line_status;
- clear_lines(l, l, 0);
- flush_lines(l, l);
+ if (!_game.statusLine) {
+ int l = _game.lineStatus;
+ clearLines(l, l, 0);
+ flushLines(l, l);
return;
}
- sprintf(x, " Score:%i of %-3i", game.vars[V_score], game.vars[V_max_score]);
- print_status("%-17s Sound:%s ", x, getflag(F_sound_on) ? "on " : "off");
+ sprintf(x, " Score:%i of %-3i", _game.vars[vScore], _game.vars[vMaxScore]);
+ printStatus("%-17s Sound:%s ", x, getflag(fSoundOn) ? "on " : "off");
}
/**
* Print user input prompt.
*/
-void AgiEngine::write_prompt() {
+void AgiEngine::writePrompt() {
int l, fg, bg, pos;
- if (!game.input_enabled || game.input_mode != INPUT_NORMAL)
+ if (!_game.inputEnabled || _game.inputMode != INPUT_NORMAL)
return;
- l = game.line_user_input;
- fg = game.color_fg;
- bg = game.color_bg;
- pos = game.cursor_pos;
+ l = _game.lineUserInput;
+ fg = _game.colorFg;
+ bg = _game.colorBg;
+ pos = _game.cursorPos;
debugC(4, kDebugLevelText, "erase line %d", l);
- clear_lines(l, l, game.color_bg);
+ clearLines(l, l, _game.colorBg);
- debugC(4, kDebugLevelText, "prompt = '%s'", agi_sprintf(game.strings[0]));
- print_text(game.strings[0], 0, 0, l, 1, fg, bg);
- print_text((char *)game.input_buffer, 0, 1, l, pos + 1, fg, bg);
- _gfx->printCharacter(pos + 1, l, game.cursor_char, fg, bg);
+ debugC(4, kDebugLevelText, "prompt = '%s'", agiSprintf(_game.strings[0]));
+ printText(_game.strings[0], 0, 0, l, 1, fg, bg);
+ printText((char *)_game.inputBuffer, 0, 1, l, pos + 1, fg, bg);
+ _gfx->printCharacter(pos + 1, l, _game.cursorChar, fg, bg);
- flush_lines(l, l);
+ flushLines(l, l);
_gfx->doUpdate();
}
@@ -618,7 +618,7 @@ void AgiEngine::write_prompt() {
* @param l2 end line
* @param c color
*/
-void AgiEngine::clear_lines(int l1, int l2, int c) {
+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.
@@ -634,7 +634,7 @@ void AgiEngine::clear_lines(int l1, int l2, int c) {
/**
*
*/
-void AgiEngine::flush_lines(int l1, int l2) {
+void AgiEngine::flushLines(int l1, int l2) {
l1 *= CHAR_LINES;
l2 *= CHAR_LINES;
l2 += CHAR_LINES - 1;
@@ -645,17 +645,17 @@ void AgiEngine::flush_lines(int l1, int l2) {
/**
*
*/
-void AgiEngine::draw_window(int x1, int y1, int x2, int y2) {
- game.window.active = true;
- game.window.x1 = x1;
- game.window.y1 = y1;
- game.window.x2 = x2;
- game.window.y2 = y2;
- game.window.buffer = (uint8 *)malloc((x2 - x1 + 1) * (y2 - y1 + 1));
+void AgiEngine::drawWindow(int x1, int y1, int x2, int y2) {
+ _game.window.active = true;
+ _game.window.x1 = x1;
+ _game.window.y1 = y1;
+ _game.window.x2 = x2;
+ _game.window.y2 = y2;
+ _game.window.buffer = (uint8 *)malloc((x2 - x1 + 1) * (y2 - y1 + 1));
debugC(4, kDebugLevelText, "x1=%d, y1=%d, x2=%d, y2=%d", x1, y1, x2, y2);
- _gfx->saveBlock(x1, y1, x2, y2, game.window.buffer);
+ _gfx->saveBlock(x1, y1, x2, y2, _game.window.buffer);
_gfx->drawBox(x1, y1, x2, y2, MSG_BOX_COLOUR, MSG_BOX_LINE, 2);
}
-} // End of namespace Agi
+} // End of namespace Agi
diff --git a/engines/agi/text.h b/engines/agi/text.h
deleted file mode 100644
index 5c3d5144dc..0000000000
--- a/engines/agi/text.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/* ScummVM - Scumm Interpreter
- * Copyright (C) 2006 The ScummVM project
- *
- * Copyright (C) 1999-2001 Sarien Team
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
diff --git a/engines/agi/view.cpp b/engines/agi/view.cpp
index cdb98bd45e..ea3f2be9bd 100644
--- a/engines/agi/view.cpp
+++ b/engines/agi/view.cpp
@@ -27,73 +27,73 @@
namespace Agi {
-void AgiEngine::_set_cel(vt_entry *v, int n) {
- view_loop *current_vl;
- view_cel *current_vc;
+void AgiEngine::lSetCel(VtEntry *v, int n) {
+ ViewLoop *currentVl;
+ ViewCel *currentVc;
- v->current_cel = n;
+ v->currentCel = n;
- current_vl = &game.views[v->current_view].loop[v->current_loop];
+ 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
*/
- if (current_vl->num_cels == 0)
+ if (currentVl->numCels == 0)
return;
if (!(v->flags & UPDATE)
&& (agiGetRelease() >= 0x3000))
return;
- current_vc = &current_vl->cel[n];
- v->cel_data = current_vc;
- v->x_size = current_vc->width;
- v->y_size = current_vc->height;
+ currentVc = &currentVl->cel[n];
+ v->celData = currentVc;
+ v->xSize = currentVc->width;
+ v->ySize = currentVc->height;
}
-void AgiEngine::_set_loop(vt_entry *v, int n) {
- view_loop *current_vl;
+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
*/
- if (n >= v->num_loops)
+ if (n >= v->numLoops)
n = 0;
- v->current_loop = n;
- current_vl = &game.views[v->current_view].loop[v->current_loop];
+ v->currentLoop = n;
+ currentVl = &_game.views[v->currentView].loop[v->currentLoop];
- v->num_cels = current_vl->num_cels;
- if (v->current_cel >= v->num_cels)
- v->current_cel = 0;
+ v->numCels = currentVl->numCels;
+ if (v->currentCel >= v->numCels)
+ v->currentCel = 0;
if (!(v->flags & UPDATE) && (agiGetRelease() >= 0x3000))
return;
- v->loop_data = &game.views[v->current_view].loop[n];
+ v->loopData = &_game.views[v->currentView].loop[n];
}
-void AgiEngine::update_view(vt_entry *v) {
- int cel, last_cel;
+void AgiEngine::updateView(VtEntry *v) {
+ int cel, lastCel;
if (v->flags & DONTUPDATE) {
v->flags &= ~DONTUPDATE;
return;
}
- cel = v->current_cel;
- last_cel = v->num_cels - 1;
+ cel = v->currentCel;
+ lastCel = v->numCels - 1;
switch (v->cycle) {
case CYCLE_NORMAL:
- if (++cel > last_cel)
+ if (++cel > lastCel)
cel = 0;
break;
case CYCLE_END_OF_LOOP:
- if (cel < last_cel) {
- debugC(5, kDebugLevelResources, "cel %d (last = %d)", cel + 1, last_cel);
- if (++cel != last_cel)
+ if (cel < lastCel) {
+ debugC(5, kDebugLevelResources, "cel %d (last = %d)", cel + 1, lastCel);
+ if (++cel != lastCel)
break;
}
setflag(v->parm1, true);
@@ -113,14 +113,14 @@ void AgiEngine::update_view(vt_entry *v) {
break;
case CYCLE_REVERSE:
if (cel == 0) {
- cel = last_cel;
+ cel = lastCel;
} else {
cel--;
}
break;
}
- set_cel(v, cel);
+ setCel(v, cel);
}
/*
@@ -133,56 +133,56 @@ void AgiEngine::update_view(vt_entry *v) {
* and fills the corresponding views array element.
* @param n number of view resource to decode
*/
-int AgiEngine::decode_view(int n) {
+int AgiEngine::decodeView(int n) {
int loop, cel;
uint8 *v, *lptr;
uint16 lofs, cofs;
- view_loop *vl;
- view_cel *vc;
+ ViewLoop *vl;
+ ViewCel *vc;
debugC(5, kDebugLevelResources, "decode_view(%d)", n);
- v = game.views[n].rdata;
+ v = _game.views[n].rdata;
assert(v != NULL);
- game.views[n].descr = READ_LE_UINT16(v + 3) ? (char *)(v + READ_LE_UINT16(v + 3)) : (char *)(v + 3);
+ _game.views[n].descr = READ_LE_UINT16(v + 3) ? (char *)(v + READ_LE_UINT16(v + 3)) : (char *)(v + 3);
/* if no loops exist, return! */
- if ((game.views[n].num_loops = *(v + 2)) == 0)
- return err_NoLoopsInView;
+ if ((_game.views[n].numLoops = *(v + 2)) == 0)
+ return errNoLoopsInView;
/* allocate memory for all views */
- game.views[n].loop = (view_loop *)
- calloc(game.views[n].num_loops, sizeof(view_loop));
+ _game.views[n].loop = (ViewLoop *)
+ calloc(_game.views[n].numLoops, sizeof(ViewLoop));
- if (game.views[n].loop == NULL)
- return err_NotEnoughMemory;
+ if (_game.views[n].loop == NULL)
+ return errNotEnoughMemory;
/* decode all of the loops in this view */
lptr = v + 5; /* first loop address */
- for (loop = 0; loop < game.views[n].num_loops; loop++, lptr += 2) {
+ 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 */
+ vl = &_game.views[n].loop[loop]; /* the loop struct */
- vl->num_cels = *(v + lofs);
- debugC(6, kDebugLevelResources, "view %d, num_cels = %d", n, vl->num_cels);
- vl->cel = (view_cel *) calloc(vl->num_cels, sizeof(view_cel));
+ 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].num_loops = 0;
- return err_NotEnoughMemory;
+ free(_game.views[n].loop);
+ _game.views[n].numLoops = 0;
+ return errNotEnoughMemory;
}
/* decode the cells */
- for (cel = 0; cel < vl->num_cels; cel++) {
+ for (cel = 0; cel < vl->numCels; cel++) {
cofs = lofs + READ_LE_UINT16(v + lofs + 1 + (cel * 2));
vc = &vl->cel[cel];
vc->width = *(v + cofs);
vc->height = *(v + cofs + 1);
vc->transparency = *(v + cofs + 2) & 0xf;
- vc->mirror_loop = (*(v + cofs + 2) >> 4) & 0x7;
+ vc->mirrorLoop = (*(v + cofs + 2) >> 4) & 0x7;
vc->mirror = (*(v + cofs + 2) >> 7) & 0x1;
/* skip over width/height/trans|mirror data */
@@ -192,38 +192,38 @@ int AgiEngine::decode_view(int n) {
/* If mirror_loop is pointing to the current loop,
* then this is the original.
*/
- if (vc->mirror_loop == loop)
+ if (vc->mirrorLoop == loop)
vc->mirror = 0;
} /* cel */
} /* loop */
- return err_OK;
+ return errOK;
}
/**
* Unloads all data in a view resource
* @param n number of view resource
*/
-void AgiEngine::unload_view(int n) {
+void AgiEngine::unloadView(int n) {
int x;
debugC(5, kDebugLevelResources, "discard view %d", n);
- if (~game.dir_view[n].flags & RES_LOADED)
+ if (~_game.dirView[n].flags & RES_LOADED)
return;
/* Rebuild sprite list, see bug #779302 */
- _sprites->erase_both();
- _sprites->blit_both();
- _sprites->commit_both();
+ _sprites->eraseBoth();
+ _sprites->blitBoth();
+ _sprites->commitBoth();
/* free all the loops */
- for (x = 0; x < game.views[n].num_loops; x++)
- free(game.views[n].loop[x].cel);
+ for (x = 0; x < _game.views[n].numLoops; x++)
+ free(_game.views[n].loop[x].cel);
- free(game.views[n].loop);
- free(game.views[n].rdata);
+ free(_game.views[n].loop);
+ free(_game.views[n].rdata);
- game.dir_view[n].flags &= ~RES_LOADED;
+ _game.dirView[n].flags &= ~RES_LOADED;
}
/**
@@ -231,24 +231,24 @@ void AgiEngine::unload_view(int n) {
* @param v pointer to view table entry
* @param n number of cel
*/
-void AgiEngine::set_cel(vt_entry *v, int n) {
- assert(v->view_data != NULL);
- assert(v->num_cels >= n);
+void AgiEngine::setCel(VtEntry *v, int n) {
+ assert(v->viewData != NULL);
+ assert(v->numCels >= n);
- _set_cel(v, n);
+ lSetCel(v, n);
/* If position isn't appropriate, update it accordingly */
- if (v->x_pos + v->x_size > _WIDTH) {
+ if (v->xPos + v->xSize > _WIDTH) {
v->flags |= UPDATE_POS;
- v->x_pos = _WIDTH - v->x_size;
+ v->xPos = _WIDTH - v->xSize;
}
- if (v->y_pos - v->y_size + 1 < 0) {
+ if (v->yPos - v->ySize + 1 < 0) {
v->flags |= UPDATE_POS;
- v->y_pos = v->y_size - 1;
+ v->yPos = v->ySize - 1;
}
- if (v->y_pos <= game.horizon && (~v->flags & IGNORE_HORIZON)) {
+ if (v->yPos <= _game.horizon && (~v->flags & IGNORE_HORIZON)) {
v->flags |= UPDATE_POS;
- v->y_pos = game.horizon + 1;
+ v->yPos = _game.horizon + 1;
}
}
@@ -257,11 +257,11 @@ void AgiEngine::set_cel(vt_entry *v, int n) {
* @param v pointer to view table entry
* @param n number of loop
*/
-void AgiEngine::set_loop(vt_entry *v, int n) {
- assert(v->view_data != NULL);
- assert(v->num_loops >= n);
- _set_loop(v, n);
- set_cel(v, v->current_cel);
+void AgiEngine::setLoop(VtEntry *v, int n) {
+ assert(v->viewData != NULL);
+ assert(v->numLoops >= n);
+ lSetLoop(v, n);
+ setCel(v, v->currentCel);
}
/**
@@ -269,22 +269,22 @@ void AgiEngine::set_loop(vt_entry *v, int n) {
* @param v pointer to view table entry
* @param n number of AGI view resource
*/
-void AgiEngine::set_view(vt_entry *v, int n) {
- v->view_data = &game.views[n];
- v->current_view = n;
- v->num_loops = v->view_data->num_loops;
- set_loop(v, v->current_loop >= v->num_loops ? 0 : v->current_loop);
+void AgiEngine::setView(VtEntry *v, int n) {
+ v->viewData = &_game.views[n];
+ v->currentView = n;
+ v->numLoops = v->viewData->numLoops;
+ setLoop(v, v->currentLoop >= v->numLoops ? 0 : v->currentLoop);
}
/**
* Set the view table entry as updating.
* @param v pointer to view table entry
*/
-void AgiEngine::start_update(vt_entry *v) {
+void AgiEngine::startUpdate(VtEntry *v) {
if (~v->flags & UPDATE) {
- _sprites->erase_both();
+ _sprites->eraseBoth();
v->flags |= UPDATE;
- _sprites->blit_both();
+ _sprites->blitBoth();
}
}
@@ -292,22 +292,22 @@ void AgiEngine::start_update(vt_entry *v) {
* Set the view table entry as non-updating.
* @param v pointer to view table entry
*/
-void AgiEngine::stop_update(vt_entry *v) {
+void AgiEngine::stopUpdate(VtEntry *v) {
if (v->flags & UPDATE) {
- _sprites->erase_both();
+ _sprites->eraseBoth();
v->flags &= ~UPDATE;
- _sprites->blit_both();
+ _sprites->blitBoth();
}
}
/* loops to use according to direction and number of loops in
* the view resource
*/
-static int loop_table_2[] = {
+static int loopTable2[] = {
0x04, 0x04, 0x00, 0x00, 0x00, 0x04, 0x01, 0x01, 0x01
};
-static int loop_table_4[] = {
+static int loopTable4[] = {
0x04, 0x03, 0x00, 0x00, 0x00, 0x02, 0x01, 0x01, 0x01
};
@@ -316,12 +316,12 @@ static int loop_table_4[] = {
* This function is called at the end of each interpreter cycle
* to update the view table entries and blit the sprites.
*/
-void AgiEngine::update_viewtable() {
- vt_entry *v;
+void AgiEngine::updateViewtable() {
+ VtEntry *v;
int i, loop;
i = 0;
- for (v = game.view_table; v < &game.view_table[MAX_VIEWTABLE]; v++) {
+ for (v = _game.viewTable; v < &_game.viewTable[MAX_VIEWTABLE]; v++) {
if ((v->flags & (ANIMATED | UPDATE | DRAWN)) != (ANIMATED | UPDATE | DRAWN)) {
continue;
}
@@ -330,53 +330,53 @@ void AgiEngine::update_viewtable() {
loop = 4;
if (~v->flags & FIX_LOOP) {
- switch (v->num_loops) {
+ switch (v->numLoops) {
case 2:
case 3:
- loop = loop_table_2[v->direction];
+ loop = loopTable2[v->direction];
break;
case 4:
- loop = loop_table_4[v->direction];
+ loop = loopTable4[v->direction];
break;
default:
/* for KQ4 */
if (agiGetRelease() == 0x3086)
- loop = loop_table_4[v->direction];
+ loop = loopTable4[v->direction];
break;
}
}
/* AGI 2.272 (ddp, xmas) doesn't test step_time_count! */
- if (loop != 4 && loop != v->current_loop) {
+ if (loop != 4 && loop != v->currentLoop) {
if (agiGetRelease() <= 0x2272 ||
- v->step_time_count == 1) {
- set_loop(v, loop);
+ v->stepTimeCount == 1) {
+ setLoop(v, loop);
}
}
if (~v->flags & CYCLING)
continue;
- if (v->cycle_time_count == 0)
+ if (v->cycleTimeCount == 0)
continue;
- if (--v->cycle_time_count == 0) {
- update_view(v);
- v->cycle_time_count = v->cycle_time;
+ if (--v->cycleTimeCount == 0) {
+ updateView(v);
+ v->cycleTimeCount = v->cycleTime;
}
}
if (i) {
- _sprites->erase_upd_sprites();
- update_position();
- _sprites->blit_upd_sprites();
- _sprites->commit_upd_sprites();
- game.view_table[0].flags &= ~(ON_WATER | ON_LAND);
+ _sprites->eraseUpdSprites();
+ updatePosition();
+ _sprites->blitUpdSprites();
+ _sprites->commitUpdSprites();
+ _game.viewTable[0].flags &= ~(ON_WATER | ON_LAND);
}
}
-bool AgiEngine::is_ego_view(const vt_entry* v) {
- return v == game.view_table;
+bool AgiEngine::isEgoView(const VtEntry* v) {
+ return v == _game.viewTable;
}
-} // End of namespace Agi
+} // End of namespace Agi
diff --git a/engines/agi/view.h b/engines/agi/view.h
index 8671c65d04..ecc9fd65a9 100644
--- a/engines/agi/view.h
+++ b/engines/agi/view.h
@@ -30,26 +30,26 @@
namespace Agi {
-struct view_cel {
+struct ViewCel {
uint8 height;
uint8 width;
uint8 transparency;
- uint8 mirror_loop;
+ uint8 mirrorLoop;
uint8 mirror;
uint8 *data;
};
-struct view_loop {
- int num_cels;
- struct view_cel *cel;
+struct ViewLoop {
+ int numCels;
+ struct ViewCel *cel;
};
/**
* AGI view resource structure.
*/
-struct agi_view {
- int num_loops;
- struct view_loop *loop;
+struct AgiView {
+ int numLoops;
+ struct ViewLoop *loop;
char *descr;
uint8 *rdata;
};
@@ -57,29 +57,29 @@ struct agi_view {
/**
* AGI view table entry
*/
-struct vt_entry {
- uint8 step_time;
- uint8 step_time_count;
+struct VtEntry {
+ uint8 stepTime;
+ uint8 stepTimeCount;
uint8 entry;
- int16 x_pos;
- int16 y_pos;
- uint8 current_view;
- struct agi_view *view_data;
- uint8 current_loop;
- uint8 num_loops;
- struct view_loop *loop_data;
- uint8 current_cel;
- uint8 num_cels;
- struct view_cel *cel_data;
- struct view_cel *cel_data_2;
- int16 x_pos2;
- int16 y_pos2;
+ int16 xPos;
+ int16 yPos;
+ uint8 currentView;
+ struct AgiView *viewData;
+ uint8 currentLoop;
+ uint8 numLoops;
+ struct ViewLoop *loopData;
+ uint8 currentCel;
+ uint8 numCels;
+ struct ViewCel *celData;
+ struct ViewCel *celData2;
+ int16 xPos2;
+ int16 yPos2;
void *s;
- int16 x_size;
- int16 y_size;
- uint8 step_size;
- uint8 cycle_time;
- uint8 cycle_time_count;
+ int16 xSize;
+ int16 ySize;
+ uint8 stepSize;
+ uint8 cycleTime;
+ uint8 cycleTimeCount;
uint8 direction;
#define MOTION_NORMAL 0
@@ -118,8 +118,8 @@ struct vt_entry {
uint8 parm2;
uint8 parm3;
uint8 parm4;
-}; /* struct vt_entry */
+}; /* struct vt_entry */
-} // End of namespace Agi
+} // End of namespace Agi
-#endif /* AGI_VIEW_H */
+#endif /* AGI_VIEW_H */
diff --git a/engines/agi/words.cpp b/engines/agi/words.cpp
index e9279e6a1d..caa1863c9c 100644
--- a/engines/agi/words.cpp
+++ b/engines/agi/words.cpp
@@ -32,19 +32,19 @@
namespace Agi {
static uint8 *words; /* words in the game */
-static uint32 words_flen; /* length of word memory */
+static uint32 wordsFlen; /* length of word memory */
/*
* Local implementation to avoid problems with strndup() used by
* gcc 3.2 Cygwin (see #635984)
*/
-static char *my_strndup(char *src, int n) {
+static char *myStrndup(char *src, int n) {
char *tmp = strncpy((char *)malloc(n + 1), src, n);
tmp[n] = 0;
return tmp;
}
-int AgiEngine::load_words(const char *fname) {
+int AgiEngine::loadWords(const char *fname) {
Common::File fp;
uint32 flen;
uint8 *mem = NULL;
@@ -53,18 +53,18 @@ int AgiEngine::load_words(const char *fname) {
if (!fp.open(fname)) {
report("Warning: can't open %s\n", fname);
- return err_OK /*err_BadFileOpen */ ;
+ return errOK /*err_BadFileOpen */ ;
}
report("Loading dictionary: %s\n", fname);
fp.seek(0, SEEK_END);
flen = fp.pos();
- words_flen = flen;
+ wordsFlen = flen;
fp.seek(0, SEEK_SET);
if ((mem = (uint8 *)calloc(1, flen + 32)) == NULL) {
fp.close();
- return err_NotEnoughMemory;
+ return errNotEnoughMemory;
}
fp.read(mem, flen);
@@ -72,10 +72,10 @@ int AgiEngine::load_words(const char *fname) {
words = mem;
- return err_OK;
+ return errOK;
}
-void AgiEngine::unload_words() {
+void AgiEngine::unloadWords() {
if (words != NULL) {
free(words);
words = NULL;
@@ -89,11 +89,11 @@ void AgiEngine::unload_words() {
*
* Thomas Åkesson, November 2001
*/
-int AgiEngine::find_word(char *word, int *flen) {
+int AgiEngine::findWord(char *word, int *flen) {
int mchr = 0; /* matched chars */
int len, fchr, id = -1;
uint8 *p = words;
- uint8 *q = words + words_flen;
+ uint8 *q = words + wordsFlen;
*flen = 0;
debugC(2, kDebugLevelScripts, "find_word(%s)", word);
@@ -140,33 +140,33 @@ int AgiEngine::find_word(char *word, int *flen) {
return id;
}
-void AgiEngine::dictionary_words(char *msg) {
+void AgiEngine::dictionaryWords(char *msg) {
char *p = NULL;
char *q = NULL;
int wid, wlen;
debugC(2, kDebugLevelScripts, "msg = \"%s\"", msg);
- clean_input();
+ cleanInput();
- for (p = msg; p && *p && getvar(V_word_not_found) == 0;) {
+ for (p = msg; p && *p && getvar(vWordNotFound) == 0;) {
if (*p == 0x20)
p++;
if (*p == 0)
break;
- wid = find_word(p, &wlen);
+ wid = findWord(p, &wlen);
debugC(2, kDebugLevelScripts, "find_word(p) == %d", wid);
switch (wid) {
case -1:
debugC(2, kDebugLevelScripts, "unknown word");
- game.ego_words[game.num_ego_words].word = strdup(p);
- q = game.ego_words[game.num_ego_words].word;
- game.ego_words[game.num_ego_words].id = 19999;
- setvar(V_word_not_found, 1 + game.num_ego_words);
- game.num_ego_words++;
+ _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:
@@ -178,9 +178,9 @@ void AgiEngine::dictionary_words(char *msg) {
default:
/* an OK word */
debugC(3, kDebugLevelScripts, "ok word (%d)", wid);
- game.ego_words[game.num_ego_words].id = wid;
- game.ego_words[game.num_ego_words].word = my_strndup(p, wlen);
- game.num_ego_words++;
+ _game.egoWords[_game.numEgoWords].id = wid;
+ _game.egoWords[_game.numEgoWords].word = myStrndup(p, wlen);
+ _game.numEgoWords++;
p += wlen;
break;
}
@@ -200,11 +200,11 @@ void AgiEngine::dictionary_words(char *msg) {
}
}
- debugC(4, kDebugLevelScripts, "num_ego_words = %d", game.num_ego_words);
- if (game.num_ego_words > 0) {
- setflag(F_entered_cli, true);
- setflag(F_said_accepted_input, false);
+ debugC(4, kDebugLevelScripts, "num_ego_words = %d", _game.numEgoWords);
+ if (_game.numEgoWords > 0) {
+ setflag(fEnteredCli, true);
+ setflag(fSaidAcceptedInput, false);
}
}
-} // End of namespace Agi
+}// End of namespace Agi