[Scummvm-cvs-logs] SF.net SVN: scummvm: [24808] scummvm/trunk/engines/agi
aquadran at users.sourceforge.net
aquadran at users.sourceforge.net
Wed Dec 6 20:27:07 CET 2006
Revision: 24808
http://scummvm.svn.sourceforge.net/scummvm/?rev=24808&view=rev
Author: aquadran
Date: 2006-12-06 11:27:02 -0800 (Wed, 06 Dec 2006)
Log Message:
-----------
first phase of objectisation of agi engine
Modified Paths:
--------------
scummvm/trunk/engines/agi/agi.cpp
scummvm/trunk/engines/agi/agi.h
scummvm/trunk/engines/agi/agi_v2.cpp
scummvm/trunk/engines/agi/agi_v3.cpp
scummvm/trunk/engines/agi/checks.cpp
scummvm/trunk/engines/agi/console.cpp
scummvm/trunk/engines/agi/cycle.cpp
scummvm/trunk/engines/agi/global.cpp
scummvm/trunk/engines/agi/graphics.cpp
scummvm/trunk/engines/agi/graphics.h
scummvm/trunk/engines/agi/id.cpp
scummvm/trunk/engines/agi/inv.cpp
scummvm/trunk/engines/agi/keyboard.cpp
scummvm/trunk/engines/agi/keyboard.h
scummvm/trunk/engines/agi/logic.cpp
scummvm/trunk/engines/agi/logic.h
scummvm/trunk/engines/agi/menu.cpp
scummvm/trunk/engines/agi/menu.h
scummvm/trunk/engines/agi/motion.cpp
scummvm/trunk/engines/agi/objects.cpp
scummvm/trunk/engines/agi/op_cmd.cpp
scummvm/trunk/engines/agi/op_dbg.cpp
scummvm/trunk/engines/agi/op_test.cpp
scummvm/trunk/engines/agi/opcodes.h
scummvm/trunk/engines/agi/patches.cpp
scummvm/trunk/engines/agi/picture.cpp
scummvm/trunk/engines/agi/picture.h
scummvm/trunk/engines/agi/predictive.cpp
scummvm/trunk/engines/agi/savegame.cpp
scummvm/trunk/engines/agi/savegame.h
scummvm/trunk/engines/agi/sound.cpp
scummvm/trunk/engines/agi/sound.h
scummvm/trunk/engines/agi/sprite.cpp
scummvm/trunk/engines/agi/sprite.h
scummvm/trunk/engines/agi/text.cpp
scummvm/trunk/engines/agi/text.h
scummvm/trunk/engines/agi/view.cpp
scummvm/trunk/engines/agi/view.h
scummvm/trunk/engines/agi/words.cpp
Modified: scummvm/trunk/engines/agi/agi.cpp
===================================================================
--- scummvm/trunk/engines/agi/agi.cpp 2006-12-06 15:31:35 UTC (rev 24807)
+++ scummvm/trunk/engines/agi/agi.cpp 2006-12-06 19:27:02 UTC (rev 24808)
@@ -43,78 +43,54 @@
#include "agi/keyboard.h"
#include "agi/menu.h"
#include "agi/savegame.h"
+#include "agi/sound.h"
namespace Agi {
-void gfx_set_palette();
+static uint32 g_tick_timer;
+struct Mouse g_mouse;
-extern int optind;
+#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)
-struct agi_options opt;
-struct game_id_list game_info;
-struct agi_game game;
-
-static struct agi_loader *loader; /* loader */
-
-extern struct agi_loader agi_v2;
-extern struct agi_loader agi_v3;
-
-static volatile uint32 tick_timer = 0;
-
-#define TICK_SECONDS 20
-
-static int key_control = 0;
-static int key_alt = 0;
-
-static Console *_console;
-
-#define KEY_QUEUE_SIZE 16
-
-static int key_queue[KEY_QUEUE_SIZE];
-static int key_queue_start = 0;
-static int key_queue_end = 0;
-
-#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)
-
-static void process_events() {
+void AgiEngine::processEvents() {
OSystem::Event event;
int key = 0;
while (g_system->pollEvent(event)) {
switch (event.type) {
case OSystem::EVENT_QUIT:
- deinit_video();
- deinit_machine();
+ _gfx->deinitVideo();
+ _gfx->deinitMachine();
g_system->quit();
break;
case OSystem::EVENT_LBUTTONDOWN:
key = BUTTON_LEFT;
- mouse.button = 1;
+ g_mouse.button = 1;
key_enqueue(key);
- mouse.x = event.mouse.x;
- mouse.y = event.mouse.y;
+ g_mouse.x = event.mouse.x;
+ g_mouse.y = event.mouse.y;
break;
case OSystem::EVENT_RBUTTONDOWN:
key = BUTTON_RIGHT;
- mouse.button = 2;
+ g_mouse.button = 2;
key_enqueue(key);
- mouse.x = event.mouse.x;
- mouse.y = event.mouse.y;
+ g_mouse.x = event.mouse.x;
+ g_mouse.y = event.mouse.y;
break;
case OSystem::EVENT_MOUSEMOVE:
- mouse.x = event.mouse.x;
- mouse.y = event.mouse.y;
+ g_mouse.x = event.mouse.x;
+ g_mouse.y = event.mouse.y;
break;
case OSystem::EVENT_LBUTTONUP:
case OSystem::EVENT_RBUTTONUP:
- mouse.button = 0;
+ g_mouse.button = 0;
break;
case OSystem::EVENT_KEYDOWN:
- key_control = 0;
- key_alt = 0;
+ _key_control = 0;
+ _key_alt = 0;
if (event.kbd.flags == OSystem::KBD_CTRL && event.kbd.keycode == 'd') {
_console->attach();
@@ -122,10 +98,10 @@
}
if (event.kbd.flags & OSystem::KBD_CTRL)
- key_control = 1;
+ _key_control = 1;
if (event.kbd.flags & OSystem::KBD_ALT)
- key_alt = 1;
+ _key_alt = 1;
switch (key = event.kbd.keycode) {
case 256 + 20: // left arrow
@@ -222,9 +198,9 @@
key = event.kbd.ascii;
break;
}
- if (key_control)
+ if (_key_control)
key = (key & ~0x20) - 0x40;
- else if (key_alt)
+ else if (_key_alt)
key = scancode_table[(key & ~0x20) - 0x41] << 8;
else if (event.kbd.flags & OSystem::KBD_SHIFT)
key = event.kbd.ascii;
@@ -239,43 +215,102 @@
}
}
-int agi_is_keypress_low() {
- process_events();
- return key_queue_start != key_queue_end;
+int AgiEngine::agiIsKeypressLow() {
+ processEvents();
+ return _key_queue_start != _key_queue_end;
}
-void agi_timer_low() {
+void AgiEngine::agiTimerLow() {
static uint32 m = 0;
uint32 dm;
- if (tick_timer < m)
+ if (g_tick_timer < m)
m = 0;
- while ((dm = tick_timer - m) < 5) {
- process_events();
+ while ((dm = g_tick_timer - m) < 5) {
+ processEvents();
if (_console->isAttached())
_console->onFrame();
g_system->delayMillis(10);
g_system->updateScreen();
}
- m = tick_timer;
+ m = g_tick_timer;
}
-int agi_get_keypress_low() {
+int AgiEngine::agiGetKeypressLow() {
int k;
- while (key_queue_start == key_queue_end) /* block */
- agi_timer_low();
+ while (_key_queue_start == _key_queue_end) /* block */
+ agiTimerLow();
key_dequeue(k);
return k;
}
-static void agi_timer_function_low(void *refCon) {
- tick_timer++;
+void AgiEngine::agiTimerFunctionLow(void *refCon) {
+ g_tick_timer++;
}
-static void init_pri_table() {
+void AgiEngine::clear_image_stack(void) {
+ image_stack_pointer = 0;
+}
+
+void AgiEngine::release_image_stack(void) {
+ if (image_stack)
+ free(image_stack);
+ image_stack = NULL;
+ stack_size = image_stack_pointer = 0;
+}
+
+void AgiEngine::record_image_stack_call(uint8 type, int16 p1, int16 p2, int16 p3,
+ int16 p4, int16 p5, int16 p6, int16 p7) {
+ struct image_stack_element *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;
+ } 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;
+ }
+ }
+
+ pnew = &image_stack[image_stack_pointer];
+ image_stack_pointer++;
+
+ pnew->type = type;
+ pnew->parm1 = p1;
+ pnew->parm2 = p2;
+ pnew->parm3 = p3;
+ pnew->parm4 = p4;
+ pnew->parm5 = p5;
+ pnew->parm6 = p6;
+ pnew->parm7 = p7;
+}
+
+void AgiEngine::replay_image_stack_call(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);
+ break;
+ case ADD_VIEW:
+ agiLoadResource(rVIEW, p1);
+ _sprites->add_to_pic(p1, p2, p3, p4, p5, p6, p7);
+ break;
+ }
+}
+
+void AgiEngine::initPriTable() {
int i, p, y = 0;
for (p = 1; p < 15; p++) {
@@ -285,7 +320,7 @@
}
}
-int agi_init() {
+int AgiEngine::agiInit() {
int ec, i;
debug(2, "initializing");
@@ -303,6 +338,10 @@
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));
}
/* clear view table */
@@ -312,9 +351,9 @@
init_words();
if (!menu)
- menu = new Menu();
+ menu = new Menu(this, _gfx, _picture);
- init_pri_table();
+ initPriTable();
/* clear string buffer */
for (i = 0; i < MAX_STRINGS; i++)
@@ -322,16 +361,16 @@
/* setup emulation */
- switch (loader->int_version >> 12) {
+ switch (loader->getIntVersion() >> 12) {
case 2:
report("Emulating Sierra AGI v%x.%03x\n",
- (int)(loader->int_version >> 12) & 0xF,
- (int)(loader->int_version) & 0xFFF);
+ (int)(loader->version() >> 12) & 0xF,
+ (int)(loader->version()) & 0xFFF);
break;
case 3:
report("Emulating Sierra AGI v%x.002.%03x\n",
- (int)(loader->int_version >> 12) & 0xF,
- (int)(loader->int_version) & 0xFFF);
+ (int)(loader->version() >> 12) & 0xF,
+ (int)(loader->version()) & 0xFFF);
break;
}
@@ -367,7 +406,7 @@
* Public functions
*/
-void agi_unload_resources() {
+void AgiEngine::agiUnloadResources() {
int i;
/* Make sure logic 0 is always loaded */
@@ -381,11 +420,11 @@
}
}
-int agi_deinit() {
+int AgiEngine::agiDeinit() {
int ec;
clean_input(); /* remove all words from memory */
- agi_unload_resources(); /* unload resources in memory */
+ agiUnloadResources(); /* unload resources in memory */
loader->unload_resource(rLOGIC, 0);
ec = loader->deinit();
unload_objects();
@@ -396,33 +435,33 @@
return ec;
}
-int agi_detect_game() {
+int AgiEngine::agiDetectGame() {
int ec = err_OK;
- loader = &agi_v2;
+ loader = new AgiLoader_v2(this);
ec = loader->detect_game();
if (ec != err_OK) {
- loader = &agi_v3;
+ loader = new AgiLoader_v3(this);
ec = loader->detect_game();
}
return ec;
}
-int agi_version() {
- return loader->version;
+int AgiEngine::agiVersion() {
+ return loader->version();
}
-int agi_get_release() {
- return loader->int_version;
+int AgiEngine::agiGetRelease() {
+ return loader->getIntVersion();
}
-void agi_set_release(int n) {
- loader->int_version = n;
+void AgiEngine::agiSetRelease(int n) {
+ loader->setIntVersion(n);
}
-int agi_load_resource(int r, int n) {
+int AgiEngine::agiLoadResource(int r, int n) {
int i;
i = loader->load_resource(r, n);
@@ -434,13 +473,10 @@
return i;
}
-int agi_unload_resource(int r, int n) {
+int AgiEngine::agiUnloadResource(int r, int n) {
return loader->unload_resource(r, n);
}
-const char *_savePath; // FIXME: Get rid of this
-extern AGIMusic *g_agi_music;
-
struct GameSettings {
const char *gameid;
const char *description;
@@ -456,7 +492,7 @@
Common::RandomSource * rnd;
-AgiEngine::AgiEngine(OSystem * syst) : Engine(syst) {
+AgiEngine::AgiEngine(OSystem *syst) : Engine(syst) {
// Setup mixer
if (!_mixer->isReady()) {
@@ -475,7 +511,7 @@
if (!scumm_stricmp(g->gameid, gameid))
_gameId = g->id;
- rnd = new Common::RandomSource();
+ _rnd = new Common::RandomSource();
Common::addSpecialDebugLevel(kDebugLevelMain, "Main", "Generic debug level");
Common::addSpecialDebugLevel(kDebugLevelResources, "Resources", "Resources debugging");
@@ -487,8 +523,34 @@
Common::addSpecialDebugLevel(kDebugLevelSound, "Sound", "Sound debugging");
Common::addSpecialDebugLevel(kDebugLevelText, "Text", "Text output debugging");
+
+ memset(&game, 0, sizeof(struct agi_game));
+ memset(&_debug, 0, sizeof(struct agi_debug));
+ memset(&g_mouse, 0, sizeof(struct Mouse));
+
game.clock_enabled = false;
game.state = STATE_INIT;
+
+ _key_queue_start = 0;
+ _key_queue_end = 0;
+
+ _key_control = 0;
+ _key_alt = 0;
+
+ g_tick_timer = 0;
+
+ intobj = NULL;
+
+ stack_size = 0;
+ image_stack = NULL;
+ image_stack_pointer = 0;
+
+ menu = NULL;
+
+ last_sentence[0] = 0;
+ memset(&stringdata, 0, sizeof(struct string_data));
+
+ objects = NULL;
}
void AgiEngine::initialize() {
@@ -513,29 +575,33 @@
opt.renderMode = Common::parseRenderMode(ConfMan.get("render_mode").c_str());
_console = new Console(this);
+ _gfx = new GfxMgr(this);
+ _sound = new SoundMgr(this, _mixer);
+ _picture = new PictureMgr(this, _gfx);
+ _sprites = new SpritesMgr(this, _gfx);
+ _saveGameMgr = new SaveGameMgr(this, _sprites, _gfx, _sound, _picture);
- init_machine();
+ _gfx->initMachine();
+ game.game_flags = 0;
+
game.color_fg = 15;
game.color_bg = 0;
- *game.name = 0;
+ *game.name = NULL;
- game.sbuf = (uint8 *) calloc(_WIDTH, _HEIGHT);
- game.hires = (uint8 *) calloc(_WIDTH * 2, _HEIGHT);
+ game.sbuf = (uint8 *)calloc(_WIDTH, _HEIGHT);
+ game.hires = (uint8 *)calloc(_WIDTH * 2, _HEIGHT);
- menu = 0;
- _sprites = new SpritesMan;
- _text = new TextMan;
- init_video();
+ _gfx->initVideo();
+ _sound->init_sound();
- tick_timer = 0;
- _timer->installTimerProc(agi_timer_function_low, 10 * 1000, NULL);
+ _timer->installTimerProc(agiTimerFunctionLow, 10 * 1000, NULL);
game.ver = -1; /* Don't display the conf file warning */
debugC(2, kDebugLevelMain, "Detect game");
- if (agi_detect_game() == err_OK) {
+ if (agiDetectGame() == err_OK) {
game.state = STATE_LOADED;
debugC(2, kDebugLevelMain, "game loaded");
} else {
@@ -543,19 +609,17 @@
}
debugC(2, kDebugLevelMain, "Init sound");
- init_sound();
- g_agi_music = new AGIMusic(_mixer);
}
AgiEngine::~AgiEngine() {
- agi_deinit();
- delete g_agi_music;
- deinit_sound();
- deinit_video();
+ agiDeinit();
+ _sound->deinit_sound();
+ delete _sound;
+ _gfx->deinitVideo();
delete _sprites;
free(game.hires);
free(game.sbuf);
- deinit_machine();
+ _gfx->deinitMachine();
delete rnd;
delete _console;
}
@@ -569,7 +633,7 @@
initialize();
- gfx_set_palette();
+ _gfx->gfxSetPalette();
return 0;
}
@@ -642,6 +706,7 @@
FSList fslist;
FilesystemNode dir(ConfMan.get("path"));
if (!dir.listDir(fslist, FilesystemNode::kListFilesOnly)) {
+ warning("AgiEngine: invalid game path '%s'", dir.path().c_str());
return kInvalidPathError;
}
@@ -656,7 +721,8 @@
}
}
+ warning("AgiEngine: Unable to locate game data at path '%s'", dir.path().c_str());
return kNoGameDataFoundError;
}
-REGISTER_PLUGIN(AGI, "AGI Engine", "Sierra AGI Games (C) Sierra On-Line, Inc.");
+REGISTER_PLUGIN(AGI, "AGI Engine", "TODO (C) TODO");
Modified: scummvm/trunk/engines/agi/agi.h
===================================================================
--- scummvm/trunk/engines/agi/agi.h 2006-12-06 15:31:35 UTC (rev 24807)
+++ scummvm/trunk/engines/agi/agi.h 2006-12-06 19:27:02 UTC (rev 24808)
@@ -32,6 +32,7 @@
#include "common/file.h"
#include "common/savefile.h"
#include "common/system.h"
+#include "common/hash-str.h"
#include "engines/engine.h"
@@ -95,29 +96,6 @@
namespace Agi {
-int getflag(int);
-void setflag(int, int);
-void flipflag(int);
-int getvar(int);
-void setvar(int, int);
-void decrypt(uint8 * mem, int len);
-void release_sprites(void);
-int main_cycle(void);
-int view_pictures(void);
-int parse_cli(int, char **);
-int run_game(void);
-int init_machine(void);
-int deinit_machine(void);
-int get_direction(int x, int y, int x0, int y0, int s);
-void inventory(void);
-void list_games(void);
-uint32 match_crc(uint32, char *, int);
-int v2id_game(void);
-int v3id_game(void);
-int v4id_game(uint32 ver);
-void update_timer(void);
-int get_app_dir(char *app_dir, unsigned int size);
-
enum {
NO_GAMEDIR = 0,
GAMEDIR
@@ -180,7 +158,7 @@
char *switches;
};
-struct mouse {
+struct Mouse {
int button;
unsigned int x;
unsigned int y;
@@ -207,42 +185,12 @@
int agimouse; /**< AGI Mouse 1.0 emulation */
};
-extern struct agi_options opt;
-extern uint8 *exec_name;
-
-extern volatile uint32 clock_ticks;
-extern volatile uint32 clock_count;
-extern volatile uint32 msg_box_secs2;
-
-extern struct agi_debug debug_;
-extern struct mouse mouse;
-
#define report printf
enum GameId {
GID_AGI = 1
};
-extern Common::RandomSource * rnd;
-extern const char *_savePath;
-
-class AgiEngine : public ::Engine {
- int _gameId;
-
-protected:
- int init();
- int go();
- void shutdown();
- void initialize();
-
-
-public:
- AgiEngine(OSystem * syst);
- virtual ~ AgiEngine();
- int getGameId() {
- return _gameId;
-}};
-
#define WIN_TO_PIC_X(x) ((x) / 2)
#define WIN_TO_PIC_Y(y) ((y) < 8 ? 999 : (y) >= (8 + _HEIGHT) ? 999 : (y) - 8)
@@ -436,58 +384,363 @@
int simple_save; /**< select simple savegames */
};
-/**
- *
- */
-struct agi_loader {
- int version;
+class AgiLoader {
+private:
int int_version;
- int (*init) (void);
- int (*deinit) (void);
- int (*detect_game) ();
- int (*load_resource) (int, int);
- int (*unload_resource) (int, int);
- int (*load_objects) (const char *);
- int (*load_words) (const char *);
+ AgiEngine *_vm;
+
+public:
+
+ AgiLoader() {}
+
+ 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 version() = 0;
+ virtual void setIntVersion(int) = 0;
+ virtual int getIntVersion() = 0;
};
-extern struct agi_game game;
+class AgiLoader_v2 : public AgiLoader {
+private:
+ int int_version;
+ AgiEngine *_vm;
-int agi_init(void);
-int agi_deinit(void);
-int agi_version(void);
-int agi_get_release(void);
-void agi_set_release(int);
-int agi_detect_game();
-int agi_load_resource(int, int);
-int agi_unload_resource(int, int);
-void agi_unload_resources(void);
+ int load_dir(struct agi_dir *agid, const char *fname);
+ uint8 *load_vol_res(struct agi_dir *agid);
-/* words */
-int show_words(void);
-int load_words(const char *);
-void unload_words(void);
-int find_word(char *word, int *flen);
-void dictionary_words(char *);
+public:
-/* objects */
-int show_objects(void);
-int load_objects(const char *fname);
-int alloc_objects(int);
-void unload_objects(void);
-const char *object_name(unsigned int);
-int object_get_location(unsigned int);
-void object_set_location(unsigned int, int);
+ AgiLoader_v2(AgiEngine *vm) {
+ _vm = vm;
+ int_version = 0;
+ }
-void new_input_mode(int);
-void old_input_mode(void);
+ 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 version();
+ virtual void setIntVersion(int);
+ virtual int getIntVersion();
+};
-int run_logic(int);
+class AgiLoader_v3 : public AgiLoader {
+private:
+ int int_version;
+ AgiEngine *_vm;
-void agi_timer_low();
-int agi_get_keypress_low();
-int agi_is_keypress_low();
+ int AgiLoader_v3::load_dir(agi_dir *agid, Common::File *fp,
+ uint32 offs, uint32 len);
+ uint8 *AgiLoader_v3::load_vol_res(agi_dir *agid);
+public:
+
+ AgiLoader_v3(AgiEngine *vm) {
+ _vm = vm;
+ int_version = 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 version();
+ virtual void setIntVersion(int);
+ virtual int getIntVersion();
+};
+
+class GfxMgr;
+class SpritesMgr;
+class Menu;
+class SaveGameMgr;
+
+extern struct Mouse g_mouse;
+
+/* Image stack support */
+struct image_stack_element {
+ uint8 type;
+ uint8 pad;
+ int16 parm1;
+ int16 parm2;
+ int16 parm3;
+ int16 parm4;
+ int16 parm5;
+ int16 parm6;
+ int16 parm7;
+};
+
+struct string_data {
+ int x;
+ int y;
+ int len;
+ int str;
+};
+
+#define TICK_SECONDS 20
+
+#define KEY_QUEUE_SIZE 16
+
+class AgiEngine : public ::Engine {
+ int _gameId;
+
+protected:
+ int init();
+ int go();
+ void shutdown();
+ void initialize();
+
+public:
+ AgiEngine(OSystem *syst);
+ virtual ~AgiEngine();
+ int getGameId() {
+ return _gameId;
+ }
+
+private:
+
+ int _key_queue[KEY_QUEUE_SIZE];
+ int _key_queue_start;
+ int _key_queue_end;
+
+ int check_priority(struct vt_entry *v);
+ int check_collision(struct vt_entry *v);
+ int check_position(struct vt_entry *v);
+
+ uint32 match_version(uint32 crc);
+
+public:
+ struct agi_game game;
+ struct agi_object *objects; /* objects in the game */
+
+ struct string_data stringdata;
+
+ AgiLoader *loader; /* loader */
+
+ Common::RandomSource *_rnd;
+ const char *_savePath;
+
+ volatile uint32 clock_count;
+
+ uint8 *intobj;
+
+ Menu* menu;
+
+ char last_sentence[40];
+
+ SpritesMgr *_sprites;
+ GfxMgr *_gfx;
+ SoundMgr *_sound;
+ PictureMgr *_picture;
+ SaveGameMgr *_saveGameMgr;
+
+ #define INITIAL_IMAGE_STACK_SIZE 32
+
+ int stack_size;
+ struct image_stack_element *image_stack;
+ int image_stack_pointer;
+
+ void clear_image_stack();
+ void record_image_stack_call(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,
+ int16 p4, int16 p5, int16 p6, int16 p7);
+ void release_image_stack();
+
+ struct agi_debug _debug;
+ struct agi_options opt;
+
+ int _key_control;
+ int _key_alt;
+
+ Console *_console;
+
+ int agiInit();
+ int agiDeinit();
+ int agiVersion();
+ int agiGetRelease();
+ void agiSetRelease(int);
+ int agiDetectGame();
+ int agiLoadResource(int, int);
+ int agiUnloadResource(int, int);
+ void agiUnloadResources();
+
+ void agiTimerLow();
+ int agiGetKeypressLow();
+ int agiIsKeypressLow();
+ static void agiTimerFunctionLow(void *refCon);
+ void initPriTable();
+
+ void new_input_mode(int);
+ void old_input_mode();
+
+ int getflag(int);
+ void setflag(int, int);
+ void flipflag(int);
+ 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 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 printItem(int n, int fg, int bg);
+ int findItem();
+ int showItems();
+ void selectItems(int n);
+
+ 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);
+
+ // Logic
+ int decode_logic(int);
+ void unload_logic(int);
+ int run_logic(int);
+ void patch_logic(int n);
+
+ void debug_console(int, int, const char *);
+ int test_if_code(int);
+ void execute_agi_command(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);
+
+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);
+
+ // Words
+ int show_words();
+ int load_words(const char *);
+ void unload_words();
+ int find_word(char *word, int *flen);
+ void dictionary_words(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);
+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);
+
+ // 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();
+
+ // Text
+public:
+ #define MAXWORDLEN 24
+
+ 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);
+ void print_text_console(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);
+ 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);
+ void blit_textbox(const char *p, int y, int x, int len);
+ void erase_textbox();
+ char *safe_strcat(char *s, const char *t);
+ void loadDict(void);
+ bool matchWord(void);
+
+ typedef Common::HashMap<String, String, Common::CaseSensitiveString_Hash, Common::CaseSensitiveString_EqualTo> DictMap;
+ DictMap _dict;
+ Common::StringList _dictKeys;
+ String _currentCode;
+ String _currentWord;
+ String _matchedWord;
+ int _wordNumber;
+ uint _wordPosition;
+ bool _nextIsActive;
+ bool _addIsActive;
+public:
+ char _predictiveResult[40];
+};
+
} // End of namespace Agi
#endif // AGI_H
Modified: scummvm/trunk/engines/agi/agi_v2.cpp
===================================================================
--- scummvm/trunk/engines/agi/agi_v2.cpp 2006-12-06 15:31:35 UTC (rev 24807)
+++ scummvm/trunk/engines/agi/agi_v2.cpp 2006-12-06 19:27:02 UTC (rev 24808)
@@ -29,38 +29,30 @@
namespace Agi {
-static int agi_v2_init(void);
-static int agi_v2_deinit(void);
-static int agi_v2_detect_game();
-static int agi_v2_load_resource(int, int);
-static int agi_v2_unload_resource(int, int);
-static int agi_v2_load_objects(const char *);
-static int agi_v2_load_words(const char *);
+int AgiLoader_v2::version() {
+ return 2;
+}
-struct agi_loader agi_v2 = {
- 2,
- 0,
- agi_v2_init,
- agi_v2_deinit,
- agi_v2_detect_game,
- agi_v2_load_resource,
- agi_v2_unload_resource,
- agi_v2_load_objects,
- agi_v2_load_words
-};
+void AgiLoader_v2::setIntVersion(int version) {
+ int_version = version;
+}
-static int agi_v2_detect_game() {
+int AgiLoader_v2::getIntVersion() {
+ return int_version;
+}
+
+int AgiLoader_v2::detect_game() {
if (!Common::File::exists(LOGDIR) ||
!Common::File::exists(PICDIR) ||
!Common::File::exists(SNDDIR) ||
!Common::File::exists(VIEWDIR))
return err_InvalidAGIFile;
- agi_v2.int_version = 0x2917; /* setup for 2.917 */
- return v2id_game();
+ int_version = 0x2917; /* setup for 2.917 */
+ return _vm->v2id_game();
}
-static int agi_v2_load_dir(struct agi_dir *agid, const char *fname) {
+int AgiLoader_v2::load_dir(struct agi_dir *agid, const char *fname) {
Common::File fp;
uint8 *mem;
uint32 flen;
@@ -76,7 +68,7 @@
flen = fp.pos();
fp.seek(0, SEEK_SET);
- if ((mem = (uint8 *) malloc(flen + 32)) == NULL) {
+ if ((mem = (uint8 *)malloc(flen + 32)) == NULL) {
fp.close();
return err_NotEnoughMemory;
}
@@ -102,22 +94,22 @@
return err_OK;
}
-static int agi_v2_init() {
+int AgiLoader_v2::init() {
int ec = err_OK;
/* load directory files */
- ec = agi_v2_load_dir(game.dir_logic, LOGDIR);
+ ec = load_dir(_vm->game.dir_logic, LOGDIR);
if (ec == err_OK)
- ec = agi_v2_load_dir(game.dir_pic, PICDIR);
+ ec = load_dir(_vm->game.dir_pic, PICDIR);
if (ec == err_OK)
- ec = agi_v2_load_dir(game.dir_view, VIEWDIR);
+ ec = load_dir(_vm->game.dir_view, VIEWDIR);
if (ec == err_OK)
- ec = agi_v2_load_dir(game.dir_sound, SNDDIR);
+ ec = load_dir(_vm->game.dir_sound, SNDDIR);
return ec;
}
-static int agi_v2_deinit() {
+int AgiLoader_v2::deinit() {
int ec = err_OK;
#if 0
@@ -131,21 +123,21 @@
return ec;
}
-static int agi_v2_unload_resource(int t, int n) {
+int AgiLoader_v2::unload_resource(int t, int n) {
debugC(3, kDebugLevelResources, "unload resource");
switch (t) {
case rLOGIC:
- unload_logic(n);
+ _vm->unload_logic(n);
break;
case rPICTURE:
- unload_picture(n);
+ _vm->_picture->unload_picture(n);
break;
case rVIEW:
- unload_view(n);
+ _vm->unload_view(n);
break;
case rSOUND:
- unload_sound(n);
+ _vm->_sound->unload_sound(n);
break;
}
@@ -157,7 +149,7 @@
* if further decoding is required, it must be done by another
* routine. NULL is returned if unsucsessfull.
*/
-static uint8 *agi_v2_load_vol_res(struct agi_dir *agid) {
+uint8 *AgiLoader_v2::load_vol_res(struct agi_dir *agid) {
uint8 *data = NULL;
char x[MAX_PATH], *path;
Common::File fp;
@@ -204,7 +196,7 @@
* Loads a resource into memory, a raw resource is loaded in
* with above routine, then further decoded here.
*/
-int agi_v2_load_resource(int t, int n) {
+int AgiLoader_v2::load_resource(int t, int n) {
int ec = err_OK;
uint8 *data = NULL;
@@ -214,23 +206,23 @@
switch (t) {
case rLOGIC:
- if (~game.dir_logic[n].flags & RES_LOADED) {
+ if (~_vm->game.dir_logic[n].flags & RES_LOADED) {
debugC(3, kDebugLevelResources, "loading logic resource %d", n);
- agi_v2.unload_resource(rLOGIC, n);
+ unload_resource(rLOGIC, n);
/* load raw resource into data */
- data = agi_v2_load_vol_res(&game.dir_logic[n]);
+ data = load_vol_res(&_vm->game.dir_logic[n]);
- game.logics[n].data = data;
- ec = data ? decode_logic(n) : err_BadResource;
+ _vm->game.logics[n].data = data;
+ ec = data ? _vm->decode_logic(n) : err_BadResource;
- 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 */
- game.logics[n].cIP = 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,
@@ -238,32 +230,32 @@
*/
debugC(3, kDebugLevelResources, "loading picture resource %d", n);
- if (game.dir_pic[n].flags & RES_LOADED)
+ if (_vm->game.dir_pic[n].flags & RES_LOADED)
break;
/* if loaded but not cached, unload it */
/* if cached but not loaded, etc */
- agi_v2.unload_resource(rPICTURE, n);
- data = agi_v2_load_vol_res(&game.dir_pic[n]);
+ unload_resource(rPICTURE, n);
+ data = load_vol_res(&_vm->game.dir_pic[n]);
if (data != NULL) {
- game.pictures[n].rdata = data;
- game.dir_pic[n].flags |= RES_LOADED;
+ _vm->game.pictures[n].rdata = data;
+ _vm->game.dir_pic[n].flags |= RES_LOADED;
} else {
ec = err_BadResource;
}
break;
case rSOUND:
debugC(3, kDebugLevelResources, "loading sound resource %d", n);
- if (game.dir_sound[n].flags & RES_LOADED)
+ if (_vm->game.dir_sound[n].flags & RES_LOADED)
break;
- data = agi_v2_load_vol_res(&game.dir_sound[n]);
+ data = load_vol_res(&_vm->game.dir_sound[n]);
if (data != NULL) {
- game.sounds[n].rdata = data;
- game.dir_sound[n].flags |= RES_LOADED;
- decode_sound(n);
+ _vm->game.sounds[n].rdata = data;
+ _vm->game.dir_sound[n].flags |= RES_LOADED;
+ _vm->_sound->decode_sound(n);
} else {
ec = err_BadResource;
}
@@ -274,16 +266,16 @@
* can we cache the view? or must we reload it all
* the time?
*/
- if (game.dir_view[n].flags & RES_LOADED)
+ if (_vm->game.dir_view[n].flags & RES_LOADED)
break;
debugC(3, kDebugLevelResources, "loading view resource %d", n);
- agi_v2.unload_resource(rVIEW, n);
- data = agi_v2_load_vol_res(&game.dir_view[n]);
+ unload_resource(rVIEW, n);
+ data = load_vol_res(&_vm->game.dir_view[n]);
if (data) {
- game.views[n].rdata = data;
- game.dir_view[n].flags |= RES_LOADED;
- ec = decode_view(n);
+ _vm->game.views[n].rdata = data;
+ _vm->game.dir_view[n].flags |= RES_LOADED;
+ ec = _vm->decode_view(n);
} else {
ec = err_BadResource;
}
@@ -296,12 +288,12 @@
return ec;
}
-static int agi_v2_load_objects(const char *fname) {
- return load_objects(fname);
+int AgiLoader_v2::load_objects(const char *fname) {
+ return _vm->load_objects(fname);
}
-static int agi_v2_load_words(const char *fname) {
- return load_words(fname);
+int AgiLoader_v2::load_words(const char *fname) {
+ return _vm->load_words(fname);
}
} // End of namespace Agi
Modified: scummvm/trunk/engines/agi/agi_v3.cpp
===================================================================
--- scummvm/trunk/engines/agi/agi_v3.cpp 2006-12-06 15:31:35 UTC (rev 24807)
+++ scummvm/trunk/engines/agi/agi_v3.cpp 2006-12-06 19:27:02 UTC (rev 24808)
@@ -32,27 +32,19 @@
namespace Agi {
-static int agi_v3_init(void);
-static int agi_v3_deinit(void);
-static int agi_v3_detect_game();
-static int agi_v3_load_resource(int, int);
-static int agi_v3_unload_resource(int, int);
-static int agi_v3_load_objects(const char *);
-static int agi_v3_load_words(const char *);
+int AgiLoader_v3::version() {
+ return 3;
+}
-struct agi_loader agi_v3 = {
- 3,
- 0,
- agi_v3_init,
- agi_v3_deinit,
- agi_v3_detect_game,
- agi_v3_load_resource,
- agi_v3_unload_resource,
- agi_v3_load_objects,
- agi_v3_load_words
-};
+void AgiLoader_v3::setIntVersion(int version) {
+ int_version = version;
+}
-int agi_v3_detect_game() {
+int AgiLoader_v3::getIntVersion() {
+ return int_version;
+}
+
+int AgiLoader_v3::detect_game() {
int ec = err_Unk;
bool found = false;
@@ -71,10 +63,10 @@
f.toLowercase();
if (f.hasSuffix("vol.0")) {
- strncpy(game.name, f.c_str(), f.size() > 5 ? f.size() - 5 : f.size());
- debugC(3, kDebugLevelMain, "game.name = %s", game.name);
- agi_v3.int_version = 0x3149; // setup for 3.002.149
- ec = 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);
+ int_version = 0x3149; // setup for 3.002.149
+ ec = _vm->v3id_game();
found = true;
}
@@ -88,7 +80,7 @@
return ec;
}
-static int agi_v3_load_dir(struct agi_dir *agid, Common::File *fp,
+int AgiLoader_v3::load_dir(struct agi_dir *agid, Common::File *fp,
uint32 offs, uint32 len) {
int ec = err_OK;
uint8 *mem;
@@ -123,7 +115,7 @@
uint32 len;
};
-int agi_v3_init(void) {
+int AgiLoader_v3::init() {
int ec = err_OK;
struct agi3vol agi_vol3[4];
int i;
@@ -131,7 +123,7 @@
Common::File fp;
Common::String path;
- path = Common::String(game.name) + DIR_;
+ path = Common::String(_vm->game.name) + DIR_;
if (!fp.open(path)) {
printf("Failed to open \"%s\"\n", path.c_str());
@@ -155,25 +147,25 @@
fp.seek(0, SEEK_SET);
/* read in directory files */
- ec = agi_v3_load_dir(game.dir_logic, &fp, agi_vol3[0].sddr,
+ ec = load_dir(_vm->game.dir_logic, &fp, agi_vol3[0].sddr,
agi_vol3[0].len);
if (ec == err_OK) {
- ec = agi_v3_load_dir(game.dir_pic, &fp, agi_vol3[1].sddr, agi_vol3[1].len);
+ ec = load_dir(_vm->game.dir_pic, &fp, agi_vol3[1].sddr, agi_vol3[1].len);
}
if (ec == err_OK) {
- ec = agi_v3_load_dir(game.dir_view, &fp, agi_vol3[2].sddr, agi_vol3[2].len);
+ ec = load_dir(_vm->game.dir_view, &fp, agi_vol3[2].sddr, agi_vol3[2].len);
}
if (ec == err_OK) {
- ec = agi_v3_load_dir(game.dir_sound, &fp, agi_vol3[3].sddr, agi_vol3[3].len);
+ ec = load_dir(_vm->game.dir_sound, &fp, agi_vol3[3].sddr, agi_vol3[3].len);
}
return ec;
}
-int agi_v3_deinit() {
+int AgiLoader_v3::deinit() {
int ec = err_OK;
#if 0
@@ -187,19 +179,19 @@
return ec;
}
-int agi_v3_unload_resource(int t, int n) {
+int AgiLoader_v3::unload_resource(int t, int n) {
switch (t) {
case rLOGIC:
- unload_logic(n);
+ _vm->unload_logic(n);
break;
case rPICTURE:
- unload_picture(n);
+ _vm->_picture->unload_picture(n);
break;
case rVIEW:
- unload_view(n);
+ _vm->unload_view(n);
break;
case rSOUND:
- unload_sound(n);
+ _vm->_sound->unload_sound(n);
break;
}
@@ -213,7 +205,7 @@
*
* NULL is returned if unsucsessful.
*/
-uint8 *agi_v3_load_vol_res(struct agi_dir *agid) {
+uint8 *AgiLoader_v3::load_vol_res(struct agi_dir *agid) {
char x[MAX_PATH];
uint8 *data = NULL, *comp_buffer;
Common::File fp;
@@ -221,7 +213,7 @@
debugC(3, kDebugLevelResources, "(%p)", (void *)agid);
sprintf(x, "vol.%i", agid->volume);
- path = Common::String(game.name) + x;
+ path = Common::String(_vm->game.name) + x;
if (agid->offset != _EMPTY && fp.open(path)) {
fp.seek(agid->offset, SEEK_SET);
@@ -282,7 +274,7 @@
* Loads a resource into memory, a raw resource is loaded in
* with above routine, then further decoded here.
*/
-int agi_v3_load_resource(int t, int n) {
+int AgiLoader_v3::load_resource(int t, int n) {
int ec = err_OK;
uint8 *data = NULL;
@@ -294,20 +286,20 @@
/* load resource into memory, decrypt messages at the end
* and build the message list (if logic is in memory)
*/
- if (~game.dir_logic[n].flags & RES_LOADED) {
+ if (~_vm->game.dir_logic[n].flags & RES_LOADED) {
/* if logic is already in memory, unload it */
- agi_v3.unload_resource(rLOGIC, n);
+ unload_resource(rLOGIC, n);
/* load raw resource into data */
- data = agi_v3_load_vol_res(&game.dir_logic[n]);
- game.logics[n].data = data;
+ data = load_vol_res(&_vm->game.dir_logic[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 = decode_logic(n);
- game.logics[n].sIP = 2;
+ ec = _vm->decode_logic(n);
+ _vm->game.logics[n].sIP = 2;
} else {
ec = err_BadResource;
}
@@ -315,38 +307,39 @@
/*logics[n].sIP=2; *//* saved IP = 2 */
/*logics[n].cIP=2; *//* current IP = 2 */
- game.logics[n].cIP = 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 */
- game.logics[n].cIP = 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 (~game.dir_pic[n].flags & RES_LOADED) {
- agi_v3.unload_resource(rPICTURE, n);
- data = agi_v3_load_vol_res(&game.dir_pic[n]);
+ if (~_vm->game.dir_pic[n].flags & RES_LOADED) {
+ unload_resource(rPICTURE, n);
+ data = load_vol_res(&_vm->game.dir_pic[n]);
if (data != NULL) {
- data = convert_v3_pic(data, game.dir_pic[n].len);
- game.pictures[n].rdata = data;
- game.dir_pic[n].flags |= RES_LOADED;
+ 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;
} else {
ec = err_BadResource;
}
}
break;
case rSOUND:
- if (game.dir_sound[n].flags & RES_LOADED)
+ if (_vm->game.dir_sound[n].flags & RES_LOADED)
break;
- if ((data = agi_v3_load_vol_res(&game.dir_sound[n])) != NULL) {
- game.sounds[n].rdata = data;
- game.dir_sound[n].flags |= RES_LOADED;
- decode_sound(n);
+ data = load_vol_res(&_vm->game.dir_sound[n]);
+ if (data != NULL) {
+ _vm->game.sounds[n].rdata = data;
+ _vm->game.dir_sound[n].flags |= RES_LOADED;
+ _vm->_sound->decode_sound(n);
} else {
ec = err_BadResource;
}
@@ -357,14 +350,15 @@
* cache the view? or must we reload it all the time?
*/
/* load a raw view from a VOL file into data */
- if (game.dir_view[n].flags & RES_LOADED)
+ if (_vm->game.dir_view[n].flags & RES_LOADED)
break;
- agi_v3.unload_resource(rVIEW, n);
- if ((data = agi_v3_load_vol_res(&game.dir_view[n])) != NULL) {
- game.views[n].rdata = data;
- game.dir_view[n].flags |= RES_LOADED;
- ec = decode_view(n);
+ unload_resource(rVIEW, n);
+ data = load_vol_res(&_vm->game.dir_view[n]);
+ if (data != NULL) {
+ _vm->game.views[n].rdata = data;
+ _vm->game.dir_view[n].flags |= RES_LOADED;
+ ec = _vm->decode_view(n);
} else {
ec = err_BadResource;
}
@@ -377,12 +371,12 @@
return ec;
}
-static int agi_v3_load_objects(const char *fname) {
- return load_objects(fname);
+int AgiLoader_v3::load_objects(const char *fname) {
+ return _vm->load_objects(fname);
}
-static int agi_v3_load_words(const char *fname) {
- return load_words(fname);
+int AgiLoader_v3::load_words(const char *fname) {
+ return _vm->load_words(fname);
}
} // End of namespace Agi
Modified: scummvm/trunk/engines/agi/checks.cpp
===================================================================
--- scummvm/trunk/engines/agi/checks.cpp 2006-12-06 15:31:35 UTC (rev 24807)
+++ scummvm/trunk/engines/agi/checks.cpp 2006-12-06 19:27:02 UTC (rev 24808)
@@ -27,7 +27,7 @@
namespace Agi {
-static int check_position(struct vt_entry *v) {
+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 ||
@@ -41,7 +41,7 @@
}
/* MH1 needs this, but it breaks LSL1 */
- if (agi_get_release() >= 0x3000) {
+ if (agiGetRelease() >= 0x3000) {
if (v->y_pos < v->y_size)
return 0;
}
@@ -52,7 +52,7 @@
/**
* Check if there's another object on the way
*/
-static int check_collision(struct vt_entry *v) {
+int AgiEngine::check_collision(struct vt_entry *v) {
struct vt_entry *u;
if (v->flags & IGNORE_OBJECTS)
@@ -92,7 +92,7 @@
return 1;
}
-static int check_priority(struct vt_entry *v) {
+int AgiEngine::check_priority(struct vt_entry *v) {
int i, trigger, water, pass, pri;
uint8 *p0;
@@ -136,7 +136,7 @@
if (pri == 2) { /* trigger */
debugC(4, kDebugLevelSprites, "stepped on trigger");
- if (!debug_.ignoretriggers)
+ if (!_debug.ignoretriggers)
trigger = 1;
}
}
@@ -168,7 +168,7 @@
* new position must be valid according to the sprite positioning
* rules, otherwise the previous position will be kept.
*/
-void update_position() {
+void AgiEngine::update_position() {
struct vt_entry *v;
int x, y, old_x, old_y, border;
@@ -206,7 +206,7 @@
if (x < 0) {
x = 0;
border = 4;
- } else if (x <= 0 && agi_get_release() == 0x3086) { /* KQ4 */
+ } else if (x <= 0 && agiGetRelease() == 0x3086) { /* KQ4 */
x = 0; /* See bug #590462 */
border = 4;
} else if (v->entry == 0 && x == 0 && v->flags & ADJ_EGO_XY) {
@@ -266,7 +266,7 @@
*
* @param n view table entry number
*/
-void fix_position(int n) {
+void AgiEngine::fix_position(int n) {
struct vt_entry *v = &game.view_table[n];
int count, dir, size;
Modified: scummvm/trunk/engines/agi/console.cpp
===================================================================
--- scummvm/trunk/engines/agi/console.cpp 2006-12-06 15:31:35 UTC (rev 24807)
+++ scummvm/trunk/engines/agi/console.cpp 2006-12-06 19:27:02 UTC (rev 24808)
@@ -34,8 +34,6 @@
namespace Agi {
-struct agi_debug debug_;
-
Console::Console(AgiEngine *vm) : GUI::Debugger() {
_vm = vm;
@@ -72,7 +70,7 @@
}
int p1 = (int)atoi(argv[1]);
int p2 = (int)atoi(argv[2]);
- setvar(p1, p2);
+ _vm->setvar(p1, p2);
return true;
}
@@ -84,7 +82,7 @@
}
int p1 = (int)atoi(argv[1]);
int p2 = (int)atoi(argv[2]);
- setflag(p1, !!p2);
+ _vm->setflag(p1, !!p2);
return true;
}
@@ -96,7 +94,7 @@
}
int p1 = (int)atoi(argv[1]);
int p2 = (int)atoi(argv[2]);
- object_set_location(p1, p2);
+ _vm->object_set_location(p1, p2);
return true;
}
@@ -117,7 +115,7 @@
debugC(5, kDebugLevelMain, "Opcode: %s %s %s %s", logic_names_cmd[i].name, argv[1], argv[2], argv[3]);
- execute_agi_command(i, p);
+ _vm->execute_agi_command(i, p);
return true;
}
@@ -128,8 +126,8 @@
bool Console::Cmd_Crc(int argc, const char **argv) {
char name[80];
- DebugPrintf("0x%05x\n", game.crc);
- if (match_crc(game.crc, name, 80))
+ DebugPrintf("0x%05x\n", _vm->game.crc);
+ if (_vm->match_crc(_vm->game.crc, name, 80))
DebugPrintf("%s\n", name);
else
DebugPrintf("Unknown game\n");
@@ -140,7 +138,7 @@
bool Console::Cmd_Agiver(int argc, const char **argv) {
int ver, maj, min;
- ver = agi_get_release();
+ ver = _vm->agiGetRelease();
maj = (ver >> 12) & 0xf;
min = ver & 0xfff;
@@ -160,7 +158,7 @@
for (i = 0; i < 255;) {
DebugPrintf("%3d ", i);
for (j = 0; j < 10; j++, i++) {
- DebugPrintf("%c ", getflag(i) ? 'T' : 'F');
+ DebugPrintf("%c ", _vm->getflag(i) ? 'T' : 'F');
}
report("\n");
}
@@ -173,7 +171,7 @@
for (i = 0; i < 255;) {
for (j = 0; j < 5; j++, i++) {
- DebugPrintf("%03d:%3d ", i, getvar(i));
+ DebugPrintf("%03d:%3d ", i, _vm->getvar(i));
}
DebugPrintf("\n");
}
@@ -184,8 +182,8 @@
bool Console::Cmd_Objs(int argc, const char **argv) {
unsigned int i;
- for (i = 0; i < game.num_objects; i++) {
- DebugPrintf("%3d]%-24s(%3d)\n", i, object_name(i), object_get_location(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));
}
return true;
@@ -197,7 +195,7 @@
return false;
}
- debug_.opcodes = !strcmp(argv[1], "on");
+ _vm->_debug.opcodes = !strcmp(argv[1], "on");
return true;
}
@@ -208,7 +206,7 @@
return false;
}
- debug_.logic0 = !strcmp(argv[1], "on");
+ _vm->_debug.logic0 = !strcmp(argv[1], "on");
return true;
}
@@ -218,34 +216,34 @@
DebugPrintf("Usage: trigger on|off\n");
return false;
}
- debug_.ignoretriggers = strcmp (argv[1], "on");
+ _vm->_debug.ignoretriggers = strcmp (argv[1], "on");
return true;
}
bool Console::Cmd_Step(int argc, const char **argv) {
- debug_.enabled = 1;
+ _vm->_debug.enabled = 1;
if (argc == 0) {
- debug_.steps = 1;
+ _vm->_debug.steps = 1;
return true;
}
- debug_.steps = strtoul(argv[1], NULL, 0);
+ _vm->_debug.steps = strtoul(argv[1], NULL, 0);
return true;
}
bool Console::Cmd_Debug(int argc, const char **argv) {
- debug_.enabled = 1;
- debug_.steps = 0;
+ _vm->_debug.enabled = 1;
+ _vm->_debug.steps = 0;
return true;
}
bool Console::Cmd_Cont(int argc, const char **argv) {
- debug_.enabled = 0;
- debug_.steps = 0;
+ _vm->_debug.enabled = 0;
+ _vm->_debug.steps = 0;
return true;
}
Modified: scummvm/trunk/engines/agi/cycle.cpp
===================================================================
--- scummvm/trunk/engines/agi/cycle.cpp 2006-12-06 15:31:35 UTC (rev 24807)
+++ scummvm/trunk/engines/agi/cycle.cpp 2006-12-06 19:27:02 UTC (rev 24808)
@@ -34,24 +34,17 @@
namespace Agi {
-#define TICK_SECONDS 20
-
-struct mouse mouse;
-
-volatile uint32 clock_ticks;
-volatile uint32 clock_count;
-
/**
* Set up new room.
* This function is called when ego enters a new room.
* @param n room number
*/
-void new_room(int n) {
+void AgiEngine::new_room(int n) {
struct vt_entry *v;
int i;
debugC(4, kDebugLevelMain, "*** room %d ***", n);
- stop_sound();
+ _sound->stop_sound();
i = 0;
for (v = game.view_table; v < &game.view_table[MAX_VIEWTABLE]; v++) {
@@ -64,7 +57,7 @@
v->cycle_time_count = 1;
v->step_size = 1;
}
- agi_unload_resources();
+ agiUnloadResources();
game.player_control = true;
game.block.active = false;
@@ -75,7 +68,7 @@
game.vars[V_border_code] = 0;
game.vars[V_ego_view_resource] = game.view_table[0].current_view;
- agi_load_resource(rLOGIC, n);
+ agiLoadResource(rLOGIC, n);
/* Reposition ego in the new room */
switch (game.vars[V_border_touch_ego]) {
@@ -98,11 +91,11 @@
game.exit_all_logics = true;
- _text->write_status();
- _text->write_prompt();
+ write_status();
+ write_prompt();
}
-static void reset_controllers() {
+void AgiEngine::reset_controllers() {
int i;
for (i = 0; i < MAX_DIRS; i++) {
@@ -110,7 +103,7 @@
}
}
-static void interpret_cycle() {
+void AgiEngine::interpret_cycle() {
int old_sound, old_score;
if (game.player_control)
@@ -138,7 +131,7 @@
game.view_table[0].direction = game.vars[V_ego_dir];
if (game.vars[V_score] != old_score || getflag(F_sound_on) != old_sound)
- _text->write_status();
+ write_status();
game.vars[V_border_touch_obj] = 0;
game.vars[V_border_code] = 0;
@@ -148,14 +141,14 @@
if (game.gfx_mode) {
update_viewtable();
- do_update();
+ _gfx->doUpdate();
}
}
/**
* Update AGI interpreter timer.
*/
-void update_timer() {
+void AgiEngine::update_timer() {
clock_count++;
if (clock_count <= TICK_SECONDS)
return;
@@ -185,25 +178,25 @@
static int old_mode = -1;
-void new_input_mode(int i) {
+void AgiEngine::new_input_mode(int i) {
old_mode = game.input_mode;
game.input_mode = i;
}
-void old_input_mode() {
+void AgiEngine::old_input_mode() {
game.input_mode = old_mode;
}
/* If main_cycle returns false, don't process more events! */
-int main_cycle() {
+int AgiEngine::main_cycle() {
unsigned int key, kascii;
struct vt_entry *v = &game.view_table[0];
- poll_timer(); /* msdos driver -> does nothing */
+ _gfx->pollTimer(); /* msdos driver -> does nothing */
update_timer();
if (game.ver == 0) {
- _text->message_box("Warning: game CRC not listed, assuming AGI version 2.917.");
+ message_box("Warning: game CRC not listed, assuming AGI version 2.917.");
game.ver = -1;
}
@@ -213,22 +206,21 @@
* vars in every interpreter cycle.
*/
if (opt.agimouse) {
- game.vars[28] = mouse.x / 2;
- game.vars[29] = mouse.y;
+ game.vars[28] = g_mouse.x / 2;
+ game.vars[29] = g_mouse.y;
}
-
if (key == KEY_PRIORITY) {
_sprites->erase_both();
- debug_.priority = !debug_.priority;
- show_pic();
+ _debug.priority = !_debug.priority;
+ _picture->show_pic();
_sprites->blit_both();
_sprites->commit_both();
key = 0;
}
if (key == KEY_STATUSLN) {
- debug_.statusline = !debug_.statusline;
- _text->write_status();
+ _debug.statusline = !_debug.statusline;
+ write_status();
key = 0;
}
@@ -274,7 +266,7 @@
break;
case INPUT_MENU:
menu->keyhandler(key);
- do_update();
+ _gfx->doUpdate();
return false;
case INPUT_NONE:
handle_controller(key);
@@ -282,23 +274,22 @@
game.keypress = key;
break;
}
+ _gfx->doUpdate();
- do_update();
-
if (game.msg_box_ticks > 0)
game.msg_box_ticks--;
return true;
}
-static int play_game() {
+int AgiEngine::play_game() {
int ec = err_OK;
debugC(2, kDebugLevelMain, "initializing...");
debugC(2, kDebugLevelMain, "game.ver = 0x%x", game.ver);
- stop_sound();
- clear_screen(0);
+ _sound->stop_sound();
+ _gfx->clearScreen(0);
game.horizon = HORIZON;
game.player_control = false;
@@ -329,14 +320,12 @@
if (!main_cycle())
continue;
- if (getvar(V_time_delay) == 0 ||
- (1 + clock_count) % getvar(V_time_delay) == 0) {
+ if (getvar(V_time_delay) == 0 || (1 + clock_count) % getvar(V_time_delay) == 0) {
if (!game.has_prompt && game.input_mode == INPUT_NORMAL) {
- _text->write_prompt();
+ write_prompt();
game.has_prompt = 1;
- } else
- if (game.has_prompt && game.input_mode == INPUT_NONE) {
- _text->write_prompt();
+ } else if (game.has_prompt && game.input_mode == INPUT_NONE) {
+ write_prompt();
game.has_prompt = 0;
}
@@ -353,12 +342,12 @@
} while (game.quit_prog_now == 0);
- stop_sound();
+ _sound->stop_sound();
return ec;
}
-int run_game() {
+int AgiEngine::run_game() {
int i, ec = err_OK;
if (opt.renderMode == Common::kRenderCGA)
@@ -372,7 +361,7 @@
debugC(2, kDebugLevelMain, "game loop");
debugC(2, kDebugLevelMain, "game.ver = 0x%x", game.ver);
- if (agi_init() != err_OK)
+ if (agiInit() != err_OK)
break;
if (ec == err_RestartGame)
setflag(F_restart_game, true);
@@ -388,7 +377,7 @@
game.state = STATE_RUNNING;
ec = play_game();
game.state = STATE_LOADED;
- agi_deinit();
+ agiDeinit();
} while (ec == err_RestartGame);
delete menu;
Modified: scummvm/trunk/engines/agi/global.cpp
===================================================================
--- scummvm/trunk/engines/agi/global.cpp 2006-12-06 15:31:35 UTC (rev 24807)
+++ scummvm/trunk/engines/agi/global.cpp 2006-12-06 19:27:02 UTC (rev 24808)
@@ -28,14 +28,14 @@
namespace Agi {
-int getflag(int n) {
+int AgiEngine::getflag(int n) {
uint8 *set = (uint8 *) &game.flags;
set += n >> 3;
return (*set & (1 << (n & 0x07))) != 0;
}
-void setflag(int n, int v) {
+void AgiEngine::setflag(int n, int v) {
uint8 *set = (uint8 *) &game.flags;
set += n >> 3;
@@ -45,22 +45,22 @@
*set &= ~(1 << (n & 0x07)); /* clear bit */
}
-void flipflag(int n) {
+void AgiEngine::flipflag(int n) {
uint8 *set = (uint8 *) & game.flags;
set += n >> 3;
*set ^= 1 << (n & 0x07); /* flip bit */
}
-void setvar(int var, int val) {
+void AgiEngine::setvar(int var, int val) {
game.vars[var] = val;
}
-int getvar(int var) {
+int AgiEngine::getvar(int var) {
return game.vars[var];
}
-void decrypt(uint8 *mem, int len) {
+void AgiEngine::decrypt(uint8 *mem, int len) {
const uint8 *key;
int i;
Modified: scummvm/trunk/engines/agi/graphics.cpp
===================================================================
--- scummvm/trunk/engines/agi/graphics.cpp 2006-12-06 15:31:35 UTC (rev 24807)
+++ scummvm/trunk/engines/agi/graphics.cpp 2006-12-06 19:27:02 UTC (rev 24808)
@@ -39,10 +39,6 @@
# define MAX_INT (int)((unsigned)~0 >> 1)
#endif
-static uint8 *agi_screen;
-
-static unsigned char *screen;
-
extern uint8 cur_font[];
/**
@@ -91,8 +87,6 @@
0x3F, 0x3F, 0x3F
};
-uint8 palette[32 * 3];
-
static uint16 cga_map[16] = {
0x0000, /* 0 - black */
0x0d00, /* 1 - blue */
@@ -136,9 +130,8 @@
*/
#define SHAKE_MAG 3
-static uint8 *shake_h, *shake_v;
-void shake_start() {
+void GfxMgr::shakeStart() {
int i;
if ((shake_h = (uint8 *)malloc(GFX_WIDTH * SHAKE_MAG)) == NULL)
@@ -158,7 +151,7 @@
}
}
-void shake_screen(int n) {
+void GfxMgr::shakeScreen(int n) {
int i;
if (n == 0) {
@@ -175,7 +168,7 @@
}
}
-void shake_end() {
+void GfxMgr::shakeEnd() {
int i;
for (i = 0; i < GFX_HEIGHT - SHAKE_MAG; i++) {
@@ -186,13 +179,13 @@
memcpy(agi_screen + i * GFX_WIDTH, shake_h + i * GFX_WIDTH, GFX_WIDTH);
}
- flush_block(0, 0, GFX_WIDTH - 1, GFX_HEIGHT - 1);
+ flushBlock(0, 0, GFX_WIDTH - 1, GFX_HEIGHT - 1);
free(shake_v);
free(shake_h);
}
-void put_text_character(int l, int x, int y, unsigned int c, int fg, int bg) {
+void GfxMgr::putTextCharacter(int l, int x, int y, unsigned int c, int fg, int bg) {
int x1, y1, xx, yy, cc;
uint8 *p;
@@ -210,10 +203,10 @@
/* FIXME: we don't want this when we're writing on the
* console!
*/
- flush_block(x, y, x + CHAR_COLS - 1, y + CHAR_LINES - 1);
+ flushBlock(x, y, x + CHAR_COLS - 1, y + CHAR_LINES - 1);
}
-void draw_rectangle(int x1, int y1, int x2, int y2, int c) {
+void GfxMgr::drawRectangle(int x1, int y1, int x2, int y2, int c) {
int y, w, h;
uint8 *p0;
@@ -235,7 +228,7 @@
}
}
-static void draw_frame(int x1, int y1, int x2, int y2, int c1, int c2) {
+void GfxMgr::drawFrame(int x1, int y1, int x2, int y2, int c1, int c2) {
int y, w;
uint8 *p0;
@@ -255,22 +248,22 @@
}
}
-void draw_box(int x1, int y1, int x2, int y2, int colour1, int colour2, int m) {
+void GfxMgr::drawBox(int x1, int y1, int x2, int y2, int colour1, int colour2, int m) {
x1 += m;
y1 += m;
x2 -= m;
y2 -= m;
- draw_rectangle(x1, y1, x2, y2, colour1);
- draw_frame(x1 + 2, y1 + 2, x2 - 2, y2 - 2, colour2, colour2);
- flush_block(x1, y1, x2, y2);
+ drawRectangle(x1, y1, x2, y2, colour1);
+ drawFrame(x1 + 2, y1 + 2, x2 - 2, y2 - 2, colour2, colour2);
+ flushBlock(x1, y1, x2, y2);
}
-void print_character(int x, int y, char c, int fg, int bg) {
+void GfxMgr::printCharacter(int x, int y, char c, int fg, int bg) {
x *= CHAR_COLS;
y *= CHAR_LINES;
- put_text_character(0, x, y, c, fg, bg);
+ putTextCharacter(0, x, y, c, fg, bg);
// redundant! already inside put_text_character!
// flush_block (x, y, x + CHAR_COLS - 1, y + CHAR_LINES - 1);
}
@@ -282,7 +275,7 @@
* @param a set if the button has focus
* @param p set if the button is pressed
*/
-void draw_button(int x, int y, const char *s, int a, int p, int fgcolor, int bgcolor) {
+void GfxMgr::drawButton(int x, int y, const char *s, int a, int p, int fgcolor, int bgcolor) {
int len = strlen(s);
int x1, y1, x2, y2;
@@ -292,7 +285,7 @@
y2 = y + CHAR_LINES + 2;
while (*s) {
- put_text_character(0, x + (!!p), y + (!!p), *s++, a ? fgcolor : bgcolor, a ? bgcolor : fgcolor);
+ putTextCharacter(0, x + (!!p), y + (!!p), *s++, a ? fgcolor : bgcolor, a ? bgcolor : fgcolor);
x += CHAR_COLS;
}
@@ -301,10 +294,10 @@
x2 += 2;
y2 += 2;
- flush_block(x1, y1, x2, y2);
+ flushBlock(x1, y1, x2, y2);
}
-int test_button(int x, int y, const char *s) {
+int GfxMgr::testButton(int x, int y, const char *s) {
int len = strlen(s);
int x1, y1, x2, y2;
@@ -313,30 +306,30 @@
x2 = x + CHAR_COLS * len + 2;
y2 = y + CHAR_LINES + 2;
- if ((int)mouse.x >= x1 && (int)mouse.y >= y1 && (int)mouse.x <= x2 && (int)mouse.y <= y2)
+ if ((int)g_mouse.x >= x1 && (int)g_mouse.y >= y1 && (int)g_mouse.x <= x2 && (int)g_mouse.y <= y2)
return true;
return false;
}
-void put_block(int x1, int y1, int x2, int y2) {
- gfx_putblock(x1, y1, x2, y2);
+void GfxMgr::putBlock(int x1, int y1, int x2, int y2) {
+ gfxPutBlock(x1, y1, x2, y2);
}
-void put_screen() {
- put_block(0, 0, GFX_WIDTH - 1, GFX_HEIGHT - 1);
+void GfxMgr::putScreen() {
+ putBlock(0, 0, GFX_WIDTH - 1, GFX_HEIGHT - 1);
}
-void poll_timer() {
- agi_timer_low();
+void GfxMgr::pollTimer() {
+ _vm->agiTimerLow();
}
-int get_key() {
- return agi_get_keypress_low();
+int GfxMgr::getKey() {
+ return _vm->agiGetKeypressLow();
}
-int keypress() {
- return agi_is_keypress_low();
+int GfxMgr::keypress() {
+ return _vm->agiIsKeypressLow();
}
/*
@@ -350,7 +343,7 @@
* for the interpreter console.
* @param p A pointer to the 16-color RGB palette.
*/
-void init_palette(uint8 *p) {
+void GfxMgr::initPalette(uint8 *p) {
int i;
for (i = 0; i < 48; i++) {
@@ -359,7 +352,7 @@
}
}
-void gfx_set_palette() {
+void GfxMgr::gfxSetPalette() {
int i;
byte pal[32 * 4];
@@ -373,7 +366,7 @@
}
/* put a block onto the screen */
-void gfx_putblock(int x1, int y1, int x2, int y2) {
+void GfxMgr::gfxPutBlock(int x1, int y1, int x2, int y2) {
if (x1 >= GFX_WIDTH)
x1 = GFX_WIDTH - 1;
if (y1 >= GFX_HEIGHT)
@@ -384,7 +377,6 @@
y2 = GFX_HEIGHT - 1;
g_system->copyRectToScreen(screen + y1 * 320 + x1, 320, x1, y1, x2 - x1 + 1, y2 - y1 + 1);
- //g_system->copyRectToScreen(screen, 320, 0, 0, 320, 200);
}
static const byte mouseCursorArrow[] = {
@@ -403,16 +395,16 @@
*
* @see deinit_video()
*/
-int init_video() {
- if (opt.renderMode == Common::kRenderEGA)
- init_palette(ega_palette);
+int GfxMgr::initVideo() {
+ if (_vm->opt.renderMode == Common::kRenderEGA)
+ initPalette(ega_palette);
else
- init_palette(new_palette);
+ initPalette(new_palette);
if ((agi_screen = (uint8 *)calloc(GFX_WIDTH, GFX_HEIGHT)) == NULL)
return err_NotEnoughMemory;
- gfx_set_palette();
+ gfxSetPalette();
byte mouseCursor[16 * 16];
const byte *src = mouseCursorArrow;
@@ -440,21 +432,20 @@
*
* @see init_video()
*/
-int deinit_video() {
+int GfxMgr::deinitVideo() {
free(agi_screen);
return err_OK;
}
-int init_machine() {
+int GfxMgr::initMachine() {
screen = (unsigned char *)malloc(320 * 200);
- clock_count = 0;
- clock_ticks = 0;
+ _vm->clock_count = 0;
return err_OK;
}
-int deinit_machine() {
+int GfxMgr::deinitMachine() {
free(screen);
return err_OK;
@@ -470,29 +461,29 @@
* @param n number of pixels in the row
* @param p pointer to the row start in the AGI screen
*/
-void put_pixels_a(int x, int y, int n, uint8 *p) {
- if (opt.renderMode == Common::kRenderCGA) {
+void GfxMgr::putPixelsA(int x, int y, int n, uint8 *p) {
+ 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];
- if (debug_.priority)
+ if (_vm->_debug.priority)
q >>= 4;
*(uint16 *)&agi_screen[x + y * GFX_WIDTH] = q & 0x0f0f;
}
} else {
for (x *= 2; n--; p++, x += 2) {
register uint16 q = ((uint16) * p << 8) | *p;
- if (debug_.priority)
+ if (_vm->_debug.priority)
q >>= 4;
*(uint16 *)&agi_screen[x + y * GFX_WIDTH] = q & 0x0f0f;
}
}
}
-void put_pixels_hires(int x, int y, int n, uint8 *p) {
+void GfxMgr::putPixelsHires(int x, int y, int n, uint8 *p) {
//y += CHAR_LINES;
for (; n--; p++, x++) {
uint8 q = *p;
- if (debug_.priority)
+ if (_vm->_debug.priority)
q >>= 4;
agi_screen[x + y * GFX_WIDTH] = q & 0x0f;
}
@@ -509,7 +500,7 @@
*
* @see do_update()
*/
-void schedule_update(int x1, int y1, int x2, int y2) {
+void GfxMgr::scheduleUpdate(int x1, int y1, int x2, int y2) {
if (x1 < update.x1)
update.x1 = x1;
if (y1 < update.y1)
@@ -527,9 +518,9 @@
*
* @see schedule_update()
*/
-void do_update() {
+void GfxMgr::doUpdate() {
if (update.x1 <= update.x2 && update.y1 <= update.y2) {
- gfx_putblock(update.x1, update.y1, update.x2, update.y2);
+ gfxPutBlock(update.x1, update.y1, update.x2, update.y2);
}
/* reset update block variables */
@@ -550,11 +541,11 @@
*
* @see flush_block_a()
*/
-void flush_block(int x1, int y1, int x2, int y2) {
+void GfxMgr::flushBlock(int x1, int y1, int x2, int y2) {
int y, w;
uint8 *p0;
- schedule_update(x1, y1, x2, y2);
+ scheduleUpdate(x1, y1, x2, y2);
p0 = &agi_screen[x1 + y1 * GFX_WIDTH];
w = x2 - x1 + 1;
@@ -574,10 +565,10 @@
*
* @see flush_block()
*/
-void flush_block_a(int x1, int y1, int x2, int y2) {
+void GfxMgr::flushBlockA(int x1, int y1, int x2, int y2) {
//y1 += 8;
//y2 += 8;
- flush_block(DEV_X0(x1), DEV_Y(y1), DEV_X1(x2), DEV_Y(y2));
+ flushBlock(DEV_X0(x1), DEV_Y(y1), DEV_X1(x2), DEV_Y(y2));
}
/**
@@ -585,8 +576,8 @@
* This function updates the output device with the contents of the AGI
* screen, handling console transparency.
*/
-void flush_screen() {
- flush_block(0, 0, GFX_WIDTH - 1, GFX_HEIGHT - 1);
+void GfxMgr::flushScreen() {
+ flushBlock(0, 0, GFX_WIDTH - 1, GFX_HEIGHT - 1);
}
/**
@@ -597,15 +588,15 @@
* a graphic-only device.
* @param c color to clear the screen
*/
-void clear_screen(int c) {
+void GfxMgr::clearScreen(int c) {
memset(agi_screen, c, GFX_WIDTH * GFX_HEIGHT);
- flush_screen();
+ flushScreen();
}
/**
* Save a block of the AGI engine screen
*/
-void save_block(int x1, int y1, int x2, int y2, uint8 *b) {
+void GfxMgr::saveBlock(int x1, int y1, int x2, int y2, uint8 *b) {
uint8 *p0;
int w, h;
@@ -622,7 +613,7 @@
/**
* Restore a block of the AGI engine screen
*/
-void restore_block(int x1, int y1, int x2, int y2, uint8 *b) {
+void GfxMgr::restoreBlock(int x1, int y1, int x2, int y2, uint8 *b) {
uint8 *p0;
int w, h;
@@ -634,7 +625,7 @@
b += w;
p0 += GFX_WIDTH;
}
- flush_block(x1, y1, x2, y2);
+ flushBlock(x1, y1, x2, y2);
}
} // End of namespace Agi
Modified: scummvm/trunk/engines/agi/graphics.h
===================================================================
--- scummvm/trunk/engines/agi/graphics.h 2006-12-06 15:31:35 UTC (rev 24807)
+++ scummvm/trunk/engines/agi/graphics.h 2006-12-06 19:27:02 UTC (rev 24808)
@@ -27,8 +27,6 @@
#include "common/stdafx.h"
-#include "agi/agi.h"
-
namespace Agi {
#define GFX_WIDTH 320
@@ -36,48 +34,67 @@
#define CHAR_COLS 8
#define CHAR_LINES 8
-extern uint8 palette[];
+class AgiEngine;
-/* Transparent layer */
-extern uint8 layer1_data[];
-extern uint8 layer2_data[];
+class GfxMgr {
+private:
+ AgiEngine *_vm;
-void gfx_putblock(int x1, int y1, int x2, int y2);
+ uint8 palette[32 * 3];
+ uint8 *agi_screen;
+ unsigned char *screen;
-void put_text_character(int, int, int, unsigned int, int, int);
-void shake_screen(int);
-void shake_start(void);
-void shake_end(void);
-void save_screen(void);
-void restore_screen(void);
+ uint8 *shake_h, *shake_v;
-int init_video(void);
-int deinit_video(void);
-void schedule_update(int, int, int, int);
-void do_update(void);
-void put_screen(void);
-void flush_block(int, int, int, int);
-void flush_block_a(int, int, int, int);
-void put_pixels_a(int, int, int, uint8 *);
-void flush_screen(void);
-void clear_screen(int);
-void clear_console_screen(int);
-void draw_box(int, int, int, int, int, int, int);
-void draw_button(int, int, const char *, int, int, int fgcolor = 0, int bgcolor = 0);
-int test_button(int, int, const char *);
-void draw_rectangle(int, int, int, int, int);
-void save_block(int, int, int, int, uint8 *);
-void restore_block(int, int, int, int, uint8 *);
-void init_palette(uint8 *);
+public:
+ GfxMgr(AgiEngine *vm) {
+ _vm = vm;
+ shake_h = NULL;
+ shake_v = NULL;
+ }
-void put_pixel(int, int, int);
+ void gfxPutBlock(int x1, int y1, int x2, int y2);
-void put_pixels_hires(int x, int y, int n, uint8 * p);
-int keypress(void);
-int get_key(void);
-void print_character(int, int, char, int, int);
-void poll_timer(void);
+ void putTextCharacter(int, int, int, unsigned int, int, int);
+ void shakeScreen(int);
+ void shakeStart();
+ void shakeEnd();
+ void saveScreen();
+ void restoreScreen();
+ int initVideo();
+ int deinitVideo();
+ void scheduleUpdate(int, int, int, int);
+ void doUpdate();
+ void putScreen();
+ void flushBlock(int, int, int, int);
+ void flushBlockA(int, int, int, int);
+ void putPixelsA(int, int, int, uint8 *);
+ void flushScreen();
+ void clearScreen(int);
+ void clearConsoleScreen(int);
+ void drawBox(int, int, int, int, int, int, int);
+ void drawButton(int, int, const char *, int, int, int fgcolor = 0, int bgcolor = 0);
+ int testButton(int, int, const char *);
+ void drawRectangle(int, int, int, int, int);
+ void saveBlock(int, int, int, int, uint8 *);
+ void restoreBlock(int, int, int, int, uint8 *);
+ void initPalette(uint8 *);
+ void drawFrame(int x1, int y1, int x2, int y2, int c1, int c2);
+
+ void putPixel(int, int, int);
+ void putBlock(int x1, int y1, int x2, int y2);
+ void gfxSetPalette();
+ void putPixelsHires(int x, int y, int n, uint8 *p);
+
+ int keypress();
+ int getKey();
+ void printCharacter(int, int, char, int, int);
+ void pollTimer();
+ int initMachine();
+ int deinitMachine();
+};
+
} // End of namespace Agi
#endif /* AGI_GRAPHICS_H */
Modified: scummvm/trunk/engines/agi/id.cpp
===================================================================
--- scummvm/trunk/engines/agi/id.cpp 2006-12-06 15:31:35 UTC (rev 24807)
+++ scummvm/trunk/engines/agi/id.cpp 2006-12-06 19:27:02 UTC (rev 24808)
@@ -75,7 +75,7 @@
"0x53971 0x3149 Manhunter SF (PC 3.5) 3.02 7/26/89 [AGI 3.002.149] \n"
"0x584F9 0x3149 Manhunter SF (PC 5.25) 3.03 8/17/89 [AGI 3.002.149] \n"
"0x5D77C 0x2917 Mixed-Up Mother Goose (PC) [AGI 2.915] \n"
-"0x5D7C6 0x2917 Mixed Up Mother Goose (PC) [AGI 2.915] (Broken) \n"
+"0x5D7C6 0x2917 Mixed Up Mother Goose (PC) [AGI 2.915] (Broken) \n"
"0x7F18B 0x2917 Police Quest 1 (PC) 2.0A 10/23/87 [AGI 2.903/2.911] \n"
"0x7EF35 0x2917 Police Quest 1 (PC) 2.0E 11/17/87 [AGI 2.915] \n"
"0x7EF06 0x2917 Police Quest 1 (PC 5.25/ST) 2.0G 12/03/87 [AGI 2.917] \n"
@@ -111,7 +111,7 @@
"0xAF778 0x3086 King's Quest 4 (IIgs) 1.0K 11/22/88 (CE) \n"
"0x6E41E 0x2440 Leisure Suit Larry 1 (IIgs) 1.0E \n"
"0x4C705 0x3149 Manhunter NY (IIgs) 2.0E 10/05/88 (CE) \n"
-"0x5F4E8 0x2917 Mixed Up Mother Goose (IIgs) \n"
+"0x5F4E8 0x2917 Mixed Up Mother Goose (IIgs) \n"
"0x7DB3F 0x2917 Police Quest 1 (IIgs) 2.0A-88318 \n"
"0x7DBE5 0x2917 Police Quest 1 (IIgs) 2.0B-88421 \n"
"0x69EC0 0x2917 Space Quest 1 (IIgs) 2.2 \n"
@@ -160,7 +160,7 @@
"0xB3E1A 0x3149 [A] Gold Rush! (Amiga) 1.01 1/13/89 aka 2.05 3/9/89 # 2.316 \n"
"0x49C6B 0x2440 [A] King's Quest 1 (Amiga) 1.0U # 2.082 \n"
"0x5D395 0x2440 [A] King's Quest 2 (Amiga) 2.0J # guessed int \n"
-"0x5BCE6 0x2440 [A] King's Quest 2 (Amiga) 2.0J (Broken) \n"
+"0x5BCE6 0x2440 [A] King's Quest 2 (Amiga) 2.0J (Broken) \n"
"0x5F4B9 0x2440 [A] King's Quest 2 (Amiga) 2.0J (Broken) # 2.176 \n"
"0x888C1 0x2440 [A] King's Quest 3 (Amiga) 1.01 11/8/86 \n"
"0x84793 0x3086 [A] King's Quest 3 (Amiga) 2.15 11/15/89 # 2.333 \n"
@@ -196,8 +196,8 @@
"#---------------------------------------------------------------------------- \n"
" \n"
"0x3F2F7 0x2917 [m] AGI Mouse 0.7 Demo \n"
-"0x3F744 0x2917 [m] AGI Mouse 1.0 Demo # 2.917 6/24/00 \n"
-"0x3F74F 0x2917 [m] AGI Mouse 1.1 Demo # 2.917 1/01/01 \n"
+"0x3F744 0x2917 [m] AGI Mouse 1.0 Demo # 2.917 6/24/00 \n"
+"0x3F74F 0x2917 [m] AGI Mouse 1.1 Demo # 2.917 1/01/01 \n"
"0x17599 0x2917 [m] Sliding Tile Game v1.00 # 2.917 6/02/01 \n"
"0x785c4 0x2936 [m] Jolimie v0.6 # 2.936 2000 \n"
"#Jolimie uses AGIPal only and not AGIMouse; no way to separate these currently \n"
@@ -226,11 +226,7 @@
"0x4EE64 0x2917 Monkey Man \n"
"";
-int setup_v2_game(int ver, uint32 crc);
-int setup_v3_game(int ver, uint32 crc);
-int v4id_game(uint32 crc);
-
-uint32 match_crc(uint32 crc, char *name, int len) {
+uint32 AgiEngine::match_crc(uint32 crc, char *name, int len) {
char *c, *t, buf[256];
uint32 id, ver;
@@ -296,7 +292,7 @@
return 0;
}
-static uint32 match_version(uint32 crc) {
+uint32 AgiEngine::match_version(uint32 crc) {
int ver;
char name[80];
@@ -306,7 +302,7 @@
return ver;
}
-int v2id_game() {
+int AgiEngine::v2id_game() {
int y, ver;
uint32 len, c, crc;
uint8 *buff;
@@ -333,7 +329,7 @@
game.crc = crc;
game.ver = ver;
debugC(2, kDebugLevelMain, "game.ver = 0x%x", game.ver);
- agi_set_release(ver);
+ agiSetRelease(ver);
return setup_v2_game(ver, crc);
}
@@ -345,7 +341,7 @@
* 0x0149
*/
-int v3id_game() {
+int AgiEngine::v3id_game() {
int ec = err_OK, y, ver;
uint32 len, c, crc;
uint8 *buff;
@@ -388,7 +384,7 @@
ver = match_version(crc);
game.crc = crc;
game.ver = ver;
- agi_set_release(ver);
+ agiSetRelease(ver);
ec = setup_v3_game(ver, crc);
@@ -398,24 +394,24 @@
/**
*
*/
-int setup_v2_game(int ver, uint32 crc) {
+int AgiEngine::setup_v2_game(int ver, uint32 crc) {
int ec = err_OK;
if (ver == 0) {
report("Unknown v2 Sierra game: %08x\n\n", crc);
- agi_set_release(0x2917);
+ agiSetRelease(0x2917);
}
/* setup the differences in the opcodes and other bits in the
* AGI v2 specs
*/
if (opt.emuversion)
- agi_set_release(opt.emuversion);
+ agiSetRelease(opt.emuversion);
if (opt.agds)
- agi_set_release(0x2440); /* ALL AGDS games built for 2.440 */
+ agiSetRelease(0x2440); /* ALL AGDS games built for 2.440 */
- switch (agi_get_release()) {
+ switch (agiGetRelease()) {
case 0x2089:
logic_names_cmd[0x86].num_args = 0; /* quit: 0 args */
logic_names_cmd[0x97].num_args = 3; /* print.at: 3 args */
@@ -442,16 +438,16 @@
/**
*
*/
-int setup_v3_game(int ver, uint32 crc) {
+int AgiEngine::setup_v3_game(int ver, uint32 crc) {
int ec = err_OK;
if (ver == 0) {
report("Unknown v3 Sierra game: %08x\n\n", crc);
- agi_set_release(ver = 0x3149);
+ agiSetRelease(ver = 0x3149);
}
if (opt.emuversion)
- agi_set_release(ver = opt.emuversion);
+ agiSetRelease(ver = opt.emuversion);
switch (ver) {
case 0x3086:
Modified: scummvm/trunk/engines/agi/inv.cpp
===================================================================
--- scummvm/trunk/engines/agi/inv.cpp 2006-12-06 15:31:35 UTC (rev 24807)
+++ scummvm/trunk/engines/agi/inv.cpp 2006-12-06 19:27:02 UTC (rev 24808)
@@ -53,19 +53,16 @@
#define SELECT_Y 24
#define SELECT_MSG "Press ENTER to select, ESC to cancel"
-static uint8 *intobj = NULL;
-
-static void print_item(int n, int fg, int bg)
-{
- _text->print_text(object_name(intobj[n]), 0, n % 2 ? 39 - strlen(object_name(intobj[n])) : 1,
+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,
(n / 2) + 2, 40, fg, bg);
}
-static int find_item() {
+int AgiEngine::findItem() {
int r, c;
- r = mouse.y / CHAR_LINES;
- c = mouse.x / CHAR_COLS;
+ r = g_mouse.y / CHAR_LINES;
+ c = g_mouse.x / CHAR_COLS;
debugC(6, kDebugLevelInventory, "r = %d, c = %d", r, c);
@@ -75,31 +72,31 @@
return (r - 2) * 2 + (c > 20);
}
-static int show_items() {
+int AgiEngine::showItems() {
unsigned int x, i;
for (x = i = 0; x < game.num_objects; x++) {
if (object_get_location(x) == EGO_OWNED) {
/* add object to our list! */
intobj[i] = x;
- print_item(i, STATUS_FG, STATUS_BG);
+ printItem(i, STATUS_FG, STATUS_BG);
i++;
}
}
if (i == 0) {
- _text->print_text(NOTHING_MSG, 0, NOTHING_X, NOTHING_Y, 40, STATUS_FG, STATUS_BG);
+ print_text(NOTHING_MSG, 0, NOTHING_X, NOTHING_Y, 40, STATUS_FG, STATUS_BG);
}
return i;
}
-static void select_items(int n) {
+void AgiEngine::selectItems(int n) {
int fsel = 0;
- while (42) {
+ for (;;) {
if (n > 0)
- print_item(fsel, STATUS_BG, STATUS_FG);
+ printItem(fsel, STATUS_BG, STATUS_FG);
switch (wait_any_key()) {
case KEY_ENTER:
@@ -125,13 +122,13 @@
fsel++;
break;
case BUTTON_LEFT:{
- int i = find_item();
+ int i = findItem();
if (i >= 0 && i < n) {
setvar(V_sel_item, intobj[fsel = i]);
debugC(6, kDebugLevelInventory, "item found: %d", fsel);
- show_items();
- print_item(fsel, STATUS_BG, STATUS_FG);
- do_update();
+ showItems();
+ printItem(fsel, STATUS_BG, STATUS_FG);
+ _gfx->doUpdate();
goto exit_select;
}
break;
@@ -140,11 +137,11 @@
break;
}
- show_items();
- do_update();
+ showItems();
+ _gfx->doUpdate();
}
- exit_select:
+exit_select:
debugC(6, kDebugLevelInventory, "selected: %d", fsel);
}
@@ -155,7 +152,7 @@
/**
* Display inventory items.
*/
-void inventory() {
+void AgiEngine::inventory() {
int old_fg, old_bg;
int n;
@@ -164,24 +161,24 @@
old_bg = game.color_bg;
game.color_fg = 0;
game.color_bg = 15;
- clear_screen(game.color_bg);
+ _gfx->clearScreen(game.color_bg);
- _text->print_text(YOUHAVE_MSG, 0, YOUHAVE_X, YOUHAVE_Y, 40, STATUS_FG, STATUS_BG);
+ print_text(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));
- n = show_items();
+ n = showItems();
if (getflag(F_status_selects_items)) {
- _text->print_text(SELECT_MSG, 0, SELECT_X, SELECT_Y, 40, STATUS_FG, STATUS_BG);
+ print_text(SELECT_MSG, 0, SELECT_X, SELECT_Y, 40, STATUS_FG, STATUS_BG);
} else {
- _text->print_text(ANY_KEY_MSG, 0, ANY_KEY_X, ANY_KEY_Y, 40, STATUS_FG, STATUS_BG);
+ print_text(ANY_KEY_MSG, 0, ANY_KEY_X, ANY_KEY_Y, 40, STATUS_FG, STATUS_BG);
}
- flush_screen();
+ _gfx->flushScreen();
/* If flag 13 is set, we want to highlight & select an item.
* opon selection, put objnum in var 25. Then on esc put in
@@ -189,20 +186,20 @@
*/
if (getflag(F_status_selects_items))
- select_items(n);
+ selectItems(n);
free(intobj);
if (!getflag(F_status_selects_items))
wait_any_key();
- clear_screen(0);
- _text->write_status();
- show_pic();
+ _gfx->clearScreen(0);
+ write_status();
+ _picture->show_pic();
game.color_fg = old_fg;
game.color_bg = old_bg;
game.has_prompt = 0;
- _text->flush_lines(game.line_user_input, 24);
+ flush_lines(game.line_user_input, 24);
}
} // End of namespace Agi
Modified: scummvm/trunk/engines/agi/keyboard.cpp
===================================================================
--- scummvm/trunk/engines/agi/keyboard.cpp 2006-12-06 15:31:35 UTC (rev 24807)
+++ scummvm/trunk/engines/agi/keyboard.cpp 2006-12-06 19:27:02 UTC (rev 24808)
@@ -32,20 +32,6 @@
namespace Agi {
-char last_sentence[40];
-
-/* FIXME */
-extern int open_dialogue;
-
-struct string_data {
- int x;
- int y;
- int len;
- int str;
-};
-
-struct string_data stringdata;
-
/*
* IBM-PC keyboard scancodes
*/
@@ -78,16 +64,16 @@
44 /* Z */
};
-void init_words() {
+void AgiEngine::init_words() {
game.num_ego_words = 0;
}
-void clean_input() {
+void AgiEngine::clean_input() {
while (game.num_ego_words)
free(game.ego_words[--game.num_ego_words].word);
}
-void get_string(int x, int y, int len, int str) {
+void AgiEngine::get_string(int x, int y, int len, int str) {
new_input_mode(INPUT_GETSTRING);
stringdata.x = x;
stringdata.y = y;
@@ -101,19 +87,19 @@
* It handles console keys and insulates AGI from the console. In the main
* loop, handle_keys() handles keyboard input and ego movement.
*/
-int do_poll_keyboard() {
+int AgiEngine::do_poll_keyboard() {
int key = 0;
/* If a key is ready, rip it */
- if (keypress()) {
- key = get_key();
+ if (_gfx->keypress()) {
+ key = _gfx->getKey();
debugC(3, kDebugLevelInput, "key %02x pressed", key);
}
return key;
}
-int handle_controller(int key) {
+int AgiEngine::handle_controller(int key) {
struct vt_entry *v = &game.view_table[0];
int i;
@@ -133,7 +119,7 @@
}
if (key == BUTTON_LEFT) {
- if (getflag(F_menus_work) && mouse.y <= CHAR_LINES) {
+ if (getflag(F_menus_work) && g_mouse.y <= CHAR_LINES) {
new_input_mode(INPUT_MENU);
return true;
}
@@ -172,10 +158,10 @@
}
if (key == BUTTON_LEFT &&
- (int)mouse.y >= game.line_user_input * CHAR_LINES &&
- (int)mouse.y <= (game.line_user_input + 1) * CHAR_LINES) {
- if (_text->predictiveDialog()) {
- strcpy((char *)game.input_buffer, _text->_predictiveResult);
+ (int)g_mouse.y >= game.line_user_input * CHAR_LINES &&
+ (int)g_mouse.y <= (game.line_user_input + 1) * CHAR_LINES) {
+ if (predictiveDialog()) {
+ strcpy((char *)game.input_buffer, _predictiveResult);
handle_keys(KEY_ENTER);
}
return true;
@@ -185,8 +171,8 @@
/* Handle mouse button events */
if (key == BUTTON_LEFT) {
v->flags |= ADJ_EGO_XY;
- v->parm1 = WIN_TO_PIC_X(mouse.x);
- v->parm2 = WIN_TO_PIC_Y(mouse.y);
+ v->parm1 = WIN_TO_PIC_X(g_mouse.x);
+ v->parm2 = WIN_TO_PIC_Y(g_mouse.y);
return true;
}
}
@@ -202,7 +188,7 @@
return false;
}
-void handle_getstring(int key) {
+void AgiEngine::handle_getstring(int key) {
static int pos = 0; /* Cursor position */
static char buf[40];
@@ -213,12 +199,12 @@
switch (key) {
case BUTTON_LEFT:
- if ((int)mouse.y >= stringdata.y * CHAR_LINES &&
- (int)mouse.y <= (stringdata.y + 1) * CHAR_LINES) {
- if (_text->predictiveDialog()) {
- strcpy(game.strings[stringdata.str], _text->_predictiveResult);
+ 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);
- print_character(stringdata.x + strlen(game.strings[stringdata.str]) + 1,
+ _gfx->printCharacter(stringdata.x + strlen(game.strings[stringdata.str]) + 1,
stringdata.y, ' ', game.color_fg, game.color_bg);
return;
}
@@ -232,7 +218,7 @@
debugC(3, kDebugLevelInput, "buffer=[%s]", buf);
buf[pos = 0] = 0;
new_input_mode(INPUT_NORMAL);
- print_character(stringdata.x + strlen(game.strings[stringdata.str]) + 1,
+ _gfx->printCharacter(stringdata.x + strlen(game.strings[stringdata.str]) + 1,
stringdata.y, ' ', game.color_fg, game.color_bg);
return;
case KEY_ESCAPE:
@@ -247,9 +233,8 @@
if (!pos)
break;
- print_character(stringdata.x + (pos + 1), stringdata.y,
+ _gfx->printCharacter(stringdata.x + (pos + 1), stringdata.y,
' ', game.color_fg, game.color_bg);
-
pos--;
buf[pos] = 0;
break;
@@ -264,18 +249,18 @@
buf[pos] = 0;
/* Echo */
- print_character(stringdata.x + pos, stringdata.y, buf[pos - 1],
+ _gfx->printCharacter(stringdata.x + pos, stringdata.y, buf[pos - 1],
game.color_fg, game.color_bg);
break;
}
/* print cursor */
- print_character(stringdata.x + pos + 1, stringdata.y,
+ _gfx->printCharacter(stringdata.x + pos + 1, stringdata.y,
(char)game.cursor_char, game.color_fg, game.color_bg);
}
-void handle_keys(int key) {
+void AgiEngine::handle_keys(int key) {
uint8 *p = NULL;
int c = 0;
static uint8 formated_entry[256];
@@ -316,8 +301,8 @@
game.has_prompt = 0;
game.input_buffer[game.cursor_pos = 0] = 0;
debugC(3, kDebugLevelInput, "clear lines");
- _text->clear_lines(l, l + 1, bg);
- _text->flush_lines(l, l + 1);
+ clear_lines(l, l + 1, bg);
+ flush_lines(l, l + 1);
break;
case KEY_ESCAPE:
@@ -330,10 +315,10 @@
break;
/* erase cursor */
- print_character(game.cursor_pos + 1, l, ' ', fg, bg);
+ _gfx->printCharacter(game.cursor_pos + 1, l, ' ', fg, bg);
game.input_buffer[--game.cursor_pos] = 0;
/* Print cursor */
- print_character(game.cursor_pos + 1, l, game.cursor_char, fg, bg);
+ _gfx->printCharacter(game.cursor_pos + 1, l, game.cursor_char, fg, bg);
break;
default:
/* Ignore invalid keystrokes */
@@ -348,48 +333,48 @@
game.input_buffer[game.cursor_pos] = 0;
/* echo */
- print_character(game.cursor_pos, l, game.input_buffer[game.cursor_pos - 1], fg, bg);
+ _gfx->printCharacter(game.cursor_pos, l, game.input_buffer[game.cursor_pos - 1], fg, bg);
/* Print cursor */
- print_character(game.cursor_pos + 1, l, game.cursor_char, fg, bg);
+ _gfx->printCharacter(game.cursor_pos + 1, l, game.cursor_char, fg, bg);
break;
}
}
-int wait_key() {
+int AgiEngine::wait_key() {
int key;
/* clear key queue */
- while (keypress()) {
- get_key();
+ while (_gfx->keypress()) {
+ _gfx->getKey();
}
debugC(3, kDebugLevelInput, "waiting...");
- while (42) {
- poll_timer(); /* msdos driver -> does nothing */
+ for (;;) {
+ _gfx->pollTimer(); /* msdos driver -> does nothing */
key = do_poll_keyboard();
if (key == KEY_ENTER || key == KEY_ESCAPE || key == BUTTON_LEFT)
break;
- do_update();
+ _gfx->doUpdate();
}
return key;
}
-int wait_any_key() {
+int AgiEngine::wait_any_key() {
int key;
/* clear key queue */
- while (keypress()) {
- get_key();
+ while (_gfx->keypress()) {
+ _gfx->getKey();
}
debugC(3, kDebugLevelInput, "waiting...");
- while (42) {
- poll_timer(); /* msdos driver -> does nothing */
+ for (;;) {
+ _gfx->pollTimer(); /* msdos driver -> does nothing */
key = do_poll_keyboard();
if (key)
break;
- do_update();
+ _gfx->doUpdate();
}
return key;
}
Modified: scummvm/trunk/engines/agi/keyboard.h
===================================================================
--- scummvm/trunk/engines/agi/keyboard.h 2006-12-06 15:31:35 UTC (rev 24807)
+++ scummvm/trunk/engines/agi/keyboard.h 2006-12-06 19:27:02 UTC (rev 24808)
@@ -27,8 +27,6 @@
#include "common/stdafx.h"
-#include "agi/agi.h"
-
namespace Agi {
/* QNX4 has a KEY_DOWN defined which we don't need to care about */
@@ -75,18 +73,6 @@
extern uint8 scancode_table[];
-void init_words(void);
-void clean_input(void);
-int do_poll_keyboard(void);
-void clean_keyboard(void);
-void handle_keys(int);
-void handle_getstring(int);
-int handle_controller(int);
-void get_string(int, int, int, int);
-uint16 agi_get_keypress(void);
-int wait_key(void);
-int wait_any_key(void);
-
} // End of namespace Agi
#endif /* AGI_KEYBOARD_H */
Modified: scummvm/trunk/engines/agi/logic.cpp
===================================================================
--- scummvm/trunk/engines/agi/logic.cpp 2006-12-06 15:31:35 UTC (rev 24807)
+++ scummvm/trunk/engines/agi/logic.cpp 2006-12-06 19:27:02 UTC (rev 24808)
@@ -34,7 +34,7 @@
* into a message list.
* @param n The number of the logic resource to decode.
*/
-int decode_logic(int n) {
+int AgiEngine::decode_logic(int n) {
int ec = err_OK;
int mstart, mend, mc;
uint8 *m0;
@@ -99,7 +99,7 @@
* memory chunks allocated for this resource.
* @param n The number of the logic resource to unload
*/
-void unload_logic(int n) {
+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)
Modified: scummvm/trunk/engines/agi/logic.h
===================================================================
--- scummvm/trunk/engines/agi/logic.h 2006-12-06 15:31:35 UTC (rev 24807)
+++ scummvm/trunk/engines/agi/logic.h 2006-12-06 19:27:02 UTC (rev 24808)
@@ -25,7 +25,8 @@
#ifndef AGI_LOGIC_H
#define AGI_LOGIC_H
-#include "agi/agi.h"
+#include "common/stdafx.h"
+#include "common/scummsys.h"
namespace Agi {
@@ -41,9 +42,6 @@
const char **texts; /**< message list */
};
-int decode_logic(int);
-void unload_logic(int);
-
} // End of namespace Agi
#endif /* AGI_LOGIC_H */
Modified: scummvm/trunk/engines/agi/menu.cpp
===================================================================
--- scummvm/trunk/engines/agi/menu.cpp 2006-12-06 15:31:35 UTC (rev 24807)
+++ scummvm/trunk/engines/agi/menu.cpp 2006-12-06 19:27:02 UTC (rev 24808)
@@ -34,8 +34,6 @@
namespace Agi {
-Menu* menu;
-
// TODO: add constructor/destructor for agi_menu, agi_menu_option
struct agi_menu_option {
@@ -78,13 +76,13 @@
}
void Menu::draw_menu_bar() {
- _text->clear_lines(0, 0, MENU_BG);
- _text->flush_lines(0, 0);
+ _vm->clear_lines(0, 0, MENU_BG);
+ _vm->flush_lines(0, 0);
MenuList::iterator iter;
for (iter = menubar.begin(); iter != menubar.end(); ++iter) {
agi_menu *m = *iter;
- _text->print_text(m->text, 0, m->col, 0, 40, MENU_FG, MENU_BG);
+ _vm->print_text(m->text, 0, m->col, 0, 40, MENU_FG, MENU_BG);
}
}
@@ -92,8 +90,8 @@
void Menu::draw_menu_hilite(int cur_menu) {
agi_menu *m = get_menu(cur_menu);
debugC(6, kDebugLevelMenu, "[%s]", m->text);
- _text->print_text(m->text, 0, m->col, 0, 40, MENU_BG, MENU_FG);
- _text->flush_lines(0, 0);
+ _vm->print_text(m->text, 0, m->col, 0, 40, MENU_BG, MENU_FG);
+ _vm->flush_lines(0, 0);
}
/* draw box and pulldowns. */
@@ -101,13 +99,13 @@
/* find which vertical menu it is */
agi_menu *m = get_menu(h_menu);
- draw_box(m->wincol * CHAR_COLS, 1 * CHAR_LINES, (m->wincol + m->width + 2) * CHAR_COLS,
+ _gfx->drawBox(m->wincol * CHAR_COLS, 1 * CHAR_LINES, (m->wincol + m->width + 2) * CHAR_COLS,
(1 + m->height + 2) * CHAR_LINES, MENU_BG, MENU_LINE, 0);
MenuOptionList::iterator iter;
for (iter = m->down.begin(); iter != m->down.end(); ++iter) {
agi_menu_option* d = *iter;
- _text->print_text(d->text, 0, m->wincol + 1, d->index + 2, m->width + 2,
+ _vm->print_text(d->text, 0, m->wincol + 1, d->index + 2, m->width + 2,
d->enabled ? MENU_FG : MENU_DISABLED, MENU_BG);
}
}
@@ -116,28 +114,28 @@
agi_menu *m = get_menu(h_menu);
agi_menu_option *d = get_menu_option(h_menu, v_menu);
- _text->print_text(d->text, 0, m->wincol + 1, v_menu + 2, m->width + 2,
+ _vm->print_text(d->text, 0, m->wincol + 1, v_menu + 2, m->width + 2,
MENU_BG, d->enabled ? MENU_FG : MENU_DISABLED);
}
void Menu::new_menu_selected(int i) {
- show_pic();
+ _picture->show_pic();
draw_menu_bar();
draw_menu_hilite(i);
draw_menu_option(i);
}
bool Menu::mouse_over_text(unsigned int line, unsigned int col, char *s) {
- if (mouse.x < col * CHAR_COLS)
+ if (g_mouse.x < col * CHAR_COLS)
return false;
- if (mouse.x > (col + strlen(s)) * CHAR_COLS)
+ if (g_mouse.x > (col + strlen(s)) * CHAR_COLS)
return false;
- if (mouse.y < line * CHAR_LINES)
+ if (g_mouse.y < line * CHAR_LINES)
return false;
- if (mouse.y >= (line + 1) * CHAR_LINES)
+ if (g_mouse.y >= (line + 1) * CHAR_LINES)
return false;
return true;
@@ -165,9 +163,13 @@
* Public functions
*/
-Menu::Menu() {
+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;
}
@@ -263,22 +265,22 @@
static int menu_active = false;
static int button_used = 0;
- if (!getflag(F_menus_work))
+ if (!_vm->getflag(F_menus_work))
return false;
if (!menu_active) {
- clock_val = game.clock_enabled;
- game.clock_enabled = false;
+ clock_val = _vm->game.clock_enabled;
+ _vm->game.clock_enabled = false;
draw_menu_bar();
}
/*
* Mouse handling
*/
- if (mouse.button) {
+ if (g_mouse.button) {
int hmenu, vmenu;
button_used = 1; /* Button has been used at least once */
- if (mouse.y <= CHAR_LINES) {
+ if (g_mouse.y <= CHAR_LINES) {
/* on the menubar */
hmenu = 0;
@@ -333,7 +335,7 @@
draw_menu_option_hilite(h_cur_menu, v_cur_menu);
- if (mouse.y <= CHAR_LINES) {
+ if (g_mouse.y <= CHAR_LINES) {
/* on the menubar */
} else {
/* see which option we selected */
@@ -345,8 +347,8 @@
/* activate that option */
if (d->enabled) {
debugC(6, kDebugLevelMenu | kDebugLevelInput, "event %d registered", d->event);
- game.ev_keyp[d->event].occured = true;
- game.ev_keyp[d->event].data = d->event;
+ _vm->game.ev_keyp[d->event].occured = true;
+ _vm->game.ev_keyp[d->event].data = d->event;
goto exit_menu;
}
}
@@ -375,7 +377,7 @@
agi_menu_option* d = get_menu_option(h_cur_menu, v_cur_menu);
if (d->enabled) {
debugC(6, kDebugLevelMenu | kDebugLevelInput, "event %d registered", d->event);
- game.ev_keyp[d->event].occured = true;
+ _vm->game.ev_keyp[d->event].occured = true;
goto exit_menu;
}
break;
@@ -411,14 +413,14 @@
exit_menu:
button_used = 0;
- show_pic();
- _text->write_status();
+ _picture->show_pic();
+ _vm->write_status();
- setvar(V_key, 0);
- game.keypress = 0;
- game.clock_enabled = clock_val;
- old_input_mode();
- debugC(3, kDebugLevelMenu, "exit_menu: input mode reset to %d", game.input_mode);
+ _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;
return true;
Modified: scummvm/trunk/engines/agi/menu.h
===================================================================
--- scummvm/trunk/engines/agi/menu.h 2006-12-06 15:31:35 UTC (rev 24807)
+++ scummvm/trunk/engines/agi/menu.h 2006-12-06 19:27:02 UTC (rev 24808)
@@ -40,9 +40,17 @@
typedef Common::List<agi_menu*> MenuList;
typedef Common::List<agi_menu_option*> MenuOptionList;
+class GfxMgr;
+class PictureMgr;
+
class Menu {
+private:
+ AgiEngine *_vm;
+ GfxMgr *_gfx;
+ PictureMgr *_picture;
+
public:
- Menu();
+ Menu(AgiEngine *vm, GfxMgr *gfx, PictureMgr *picture);
~Menu();
void add(const char *s);
@@ -75,8 +83,6 @@
};
-extern Menu* menu;
-
} // End of namespace Agi
#endif /* AGI_MENU_H */
Modified: scummvm/trunk/engines/agi/motion.cpp
===================================================================
--- scummvm/trunk/engines/agi/motion.cpp 2006-12-06 15:31:35 UTC (rev 24807)
+++ scummvm/trunk/engines/agi/motion.cpp 2006-12-06 19:27:02 UTC (rev 24808)
@@ -28,11 +28,11 @@
namespace Agi {
-static int check_step(int delta, int step) {
+int AgiEngine::check_step(int delta, int step) {
return (-step >= delta) ? 0 : (step <= delta) ? 2 : 1;
}
-static int check_block(int x, int y) {
+int AgiEngine::check_block(int x, int y) {
if (x <= game.block.x1 || x >= game.block.x2)
return false;
@@ -42,7 +42,7 @@
return true;
}
-static void changepos(struct vt_entry *v) {
+void AgiEngine::changepos(struct vt_entry *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 };
@@ -64,23 +64,23 @@
}
}
-static void motion_wander(struct vt_entry *v) {
+void AgiEngine::motion_wander(struct vt_entry *v) {
if (v->parm1--) {
if (~v->flags & DIDNT_MOVE)
return;
}
- v->direction = rnd->getRandomNumber(8);
+ v->direction = _rnd->getRandomNumber(8);
if (is_ego_view(v)) {
game.vars[V_ego_dir] = v->direction;
while (v->parm1 < 6) {
- v->parm1 = rnd->getRandomNumber(50); /* huh? */
+ v->parm1 = _rnd->getRandomNumber(50); /* huh? */
}
}
}
-static void motion_followego(struct vt_entry *v) {
+void AgiEngine::motion_followego(struct vt_entry *v) {
int ego_x, ego_y;
int obj_x, obj_y;
int dir;
@@ -107,7 +107,7 @@
} else if (v->flags & DIDNT_MOVE) {
int d;
- while ((v->direction = rnd->getRandomNumber(8)) == 0) {
+ while ((v->direction = _rnd->getRandomNumber(8)) == 0) {
}
d = (abs(ego_y - obj_y) + abs(ego_x - obj_x)) / 2;
@@ -117,7 +117,7 @@
return;
}
- while ((v->parm3 = rnd->getRandomNumber(d)) < v->step_size) {
+ while ((v->parm3 = _rnd->getRandomNumber(d)) < v->step_size) {
}
return;
}
@@ -142,7 +142,7 @@
}
}
-static void motion_moveobj(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);
/* Update V6 if ego */
@@ -153,7 +153,7 @@
in_destination(v);
}
-static void check_motion(struct vt_entry *v) {
+void AgiEngine::check_motion(struct vt_entry *v) {
switch (v->motion) {
case MOTION_WANDER:
motion_wander(v);
@@ -177,7 +177,7 @@
/**
*
*/
-void check_all_motions() {
+void AgiEngine::check_all_motions() {
struct vt_entry *v;
for (v = game.view_table; v < &game.view_table[MAX_VIEWTABLE]; v++) {
@@ -194,7 +194,7 @@
* type motion that * has reached its final destination coordinates.
* @param v Pointer to view table entry
*/
-void in_destination(struct vt_entry *v) {
+void AgiEngine::in_destination(struct vt_entry *v) {
if (v->motion == MOTION_MOVE_OBJ) {
v->step_size = v->parm3;
setflag(v->parm4, true);
@@ -210,7 +210,7 @@
* after setting the motion mode to MOTION_MOVE_OBJ.
* @param v Pointer to view table entry
*/
-void move_obj(struct vt_entry *v) {
+void AgiEngine::move_obj(struct vt_entry *v) {
motion_moveobj(v);
}
@@ -224,7 +224,7 @@
* @param y y coordinate of the object
* @param s step size
*/
-int get_direction(int x0, int y0, int x, int y, int s) {
+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)];
}
Modified: scummvm/trunk/engines/agi/objects.cpp
===================================================================
--- scummvm/trunk/engines/agi/objects.cpp 2006-12-06 15:31:35 UTC (rev 24807)
+++ scummvm/trunk/engines/agi/objects.cpp 2006-12-06 19:27:02 UTC (rev 24808)
@@ -28,18 +28,14 @@
namespace Agi {
-extern int decode_objects(uint8 *mem, uint32 flen);
-
-static struct agi_object *objects; /* objects in the game */
-
-int alloc_objects(int n) {
- if ((objects = (agi_object *) calloc(n, sizeof(struct agi_object))) == NULL)
+int AgiEngine::alloc_objects(int n) {
+ if ((objects = (agi_object *)calloc(n, sizeof(struct agi_object))) == NULL)
return err_NotEnoughMemory;
return err_OK;
}
-int decode_objects(uint8 *mem, uint32 flen) {
+int AgiEngine::decode_objects(uint8 *mem, uint32 flen) {
unsigned int i, so, padsize;
padsize = game.game_flags & ID_AMIGA ? 4 : 3;
@@ -92,7 +88,7 @@
}
-int load_objects(const char *fname) {
+int AgiEngine::load_objects(const char *fname) {
Common::File fp;
uint32 flen;
uint8 *mem;
@@ -110,7 +106,7 @@
flen = fp.pos();
fp.seek(0, SEEK_SET);
- if ((mem = (uint8 *) calloc(1, flen + 32)) == NULL) {
+ if ((mem = (uint8 *)calloc(1, flen + 32)) == NULL) {
fp.close();
return err_NotEnoughMemory;
}
@@ -123,7 +119,7 @@
return err_OK;
}
-void unload_objects() {
+void AgiEngine::unload_objects() {
unsigned int i;
if (objects != NULL) {
@@ -136,7 +132,7 @@
}
}
-void object_set_location(unsigned int n, int i) {
+void AgiEngine::object_set_location(unsigned int n, int i) {
if (n >= game.num_objects) {
report("Error: Can't access object %d.\n", n);
return;
@@ -144,7 +140,7 @@
objects[n].location = i;
}
-int object_get_location(unsigned int n) {
+int AgiEngine::object_get_location(unsigned int n) {
if (n >= game.num_objects) {
report("Error: Can't access object %d.\n", n);
return 0;
@@ -152,7 +148,7 @@
return objects[n].location;
}
-const char *object_name(unsigned int n) {
+const char *AgiEngine::object_name(unsigned int n) {
if (n >= game.num_objects) {
report("Error: Can't access object %d.\n", n);
return "";
Modified: scummvm/trunk/engines/agi/op_cmd.cpp
===================================================================
--- scummvm/trunk/engines/agi/op_cmd.cpp 2006-12-06 15:31:35 UTC (rev 24807)
+++ scummvm/trunk/engines/agi/op_cmd.cpp 2006-12-06 19:27:02 UTC (rev 24808)
@@ -43,10 +43,18 @@
#define p5 (p[5])
#define p6 (p[6])
+#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]
static struct agi_logic *cur_logic;
+static AgiEngine *g_agi;
int timer_hack; /* Workaround for timer loop in MH1 */
@@ -104,7 +112,7 @@
}
cmd(random) {
- _v[p2] = rnd->getRandomNumber(p1 - p0) + p0;
+ _v[p2] = g_agi->_rnd->getRandomNumber(p1 - p0) + p0;
}
cmd(lindirectn) {
@@ -120,59 +128,59 @@
}
cmd(set) {
- setflag(*p, true);
+ g_agi->setflag(*p, true);
}
cmd(reset) {
- setflag(*p, false);
+ g_agi->setflag(*p, false);
}
cmd(toggle) {
- setflag(*p, !getflag(*p));
+ g_agi->setflag(*p, !g_agi->getflag(*p));
}
cmd(set_v) {
- setflag(_v[p0], true);
+ g_agi->setflag(_v[p0], true);
}
cmd(reset_v) {
- setflag(_v[p0], false);
+ g_agi->setflag(_v[p0], false);
}
cmd(toggle_v) {
- setflag(_v[p0], !getflag(_v[p0]));
+ g_agi->setflag(_v[p0], !g_agi->getflag(_v[p0]));
}
cmd(new_room) {
- new_room(p0);
+ g_agi->new_room(p0);
}
cmd(new_room_f) {
- new_room(_v[p0]);
+ g_agi->new_room(_v[p0]);
}
cmd(load_view) {
- agi_load_resource(rVIEW, p0);
+ g_agi->agiLoadResource(rVIEW, p0);
}
cmd(load_logic) {
- agi_load_resource(rLOGIC, p0);
+ g_agi->agiLoadResource(rLOGIC, p0);
}
cmd(load_sound) {
- agi_load_resource(rSOUND, p0);
+ g_agi->agiLoadResource(rSOUND, p0);
}
cmd(load_view_f) {
- agi_load_resource(rVIEW, _v[p0]);
+ g_agi->agiLoadResource(rVIEW, _v[p0]);
}
cmd(load_logic_f) {
- agi_load_resource(rLOGIC, _v[p0]);
+ g_agi->agiLoadResource(rLOGIC, _v[p0]);
}
cmd(discard_view) {
- agi_unload_resource(rVIEW, p0);
+ g_agi->agiUnloadResource(rVIEW, p0);
}
cmd(object_on_anything) {
@@ -246,11 +254,11 @@
}
cmd(start_update) {
- start_update(&vt);
+ g_agi->start_update(&vt);
}
cmd(stop_update) {
- stop_update(&vt);
+ g_agi->stop_update(&vt);
}
cmd(current_view) {
@@ -271,30 +279,30 @@
}
cmd(set_cel) {
- set_cel(&vt, p1);
+ g_agi->set_cel(&vt, p1);
vt.flags &= ~DONTUPDATE;
}
cmd(set_cel_f) {
- set_cel(&vt, _v[p1]);
+ g_agi->set_cel(&vt, _v[p1]);
vt.flags &= ~DONTUPDATE;
}
cmd(set_view) {
debugC(4, kDebugLevelScripts, "o%d, %d", p0, p1);
- set_view(&vt, p1);
+ g_agi->set_view(&vt, p1);
}
cmd(set_view_f) {
- set_view(&vt, _v[p1]);
+ g_agi->set_view(&vt, _v[p1]);
}
cmd(set_loop) {
- set_loop(&vt, p1);
+ g_agi->set_loop(&vt, p1);
}
cmd(set_loop_f) {
- set_loop(&vt, _v[p1]);
+ g_agi->set_loop(&vt, _v[p1]);
}
cmd(number_of_loops) {
@@ -348,27 +356,27 @@
}
cmd(get_room_f) {
- _v[p1] = object_get_location(_v[p0]);
+ _v[p1] = g_agi->object_get_location(_v[p0]);
}
cmd(put) {
- object_set_location(p0, _v[p1]);
+ g_agi->object_set_location(p0, _v[p1]);
}
cmd(put_f) {
- object_set_location(_v[p0], _v[p1]);
+ g_agi->object_set_location(_v[p0], _v[p1]);
}
cmd(drop) {
- object_set_location(p0, 0);
+ g_agi->object_set_location(p0, 0);
}
cmd(get) {
- object_set_location(p0, EGO_OWNED);
+ g_agi->object_set_location(p0, EGO_OWNED);
}
cmd(get_f) {
- object_set_location(_v[p0], EGO_OWNED);
+ g_agi->object_set_location(_v[p0], EGO_OWNED);
}
cmd(word_to_string) {
@@ -386,49 +394,49 @@
}
cmd(close_window) {
- _text->close_window();
+ g_agi->close_window();
}
cmd(status_line_on) {
game.status_line = true;
- _text->write_status();
+ g_agi->write_status();
}
cmd(status_line_off) {
game.status_line = false;
- _text->write_status();
+ g_agi->write_status();
}
cmd(show_obj) {
- _sprites->show_obj(p0);
+ g_sprites->show_obj(p0);
}
cmd(show_obj_v) {
- _sprites->show_obj(_v[p0]);
+ g_sprites->show_obj(_v[p0]);
}
cmd(sound) {
- start_sound(p0, p1);
+ g_sound->start_sound(p0, p1);
}
cmd(stop_sound) {
- stop_sound();
+ g_sound->stop_sound();
}
cmd(menu_input) {
- new_input_mode(INPUT_MENU);
+ g_agi->new_input_mode(INPUT_MENU);
}
cmd(enable_item) {
- menu->set_item(p0, true);
+ g_agi->menu->set_item(p0, true);
}
cmd(disable_item) {
- menu->set_item(p0, false);
+ g_agi->menu->set_item(p0, false);
}
cmd(submit_menu) {
- menu->submit();
+ g_agi->menu->submit();
}
cmd(set_scan_start) {
@@ -440,12 +448,12 @@
}
cmd(save_game) {
- game.simple_save ? savegame_simple() : savegame_dialog();
+ game.simple_save ? g_agi->_saveGameMgr->savegame_simple() : g_agi->_saveGameMgr->savegame_dialog();
}
cmd(load_game) {
assert(1);
- game.simple_save ? loadgame_simple() : loadgame_dialog();
+ game.simple_save ? g_agi->_saveGameMgr->loadgame_simple() : g_agi->_saveGameMgr->loadgame_dialog();
}
cmd(init_disk) { /* do nothing */
@@ -461,7 +469,7 @@
}
cmd(show_mem) {
- _text->message_box("Enough memory");
+ g_agi->message_box("Enough memory");
}
cmd(init_joy) { /* do nothing */ ;
@@ -530,10 +538,10 @@
cmd(parse) {
_v[V_word_not_found] = 0;
- setflag(F_entered_cli, false);
- setflag(F_said_accepted_input, false);
+ g_agi->setflag(F_entered_cli, false);
+ g_agi->setflag(F_said_accepted_input, false);
- dictionary_words(_text->agi_sprintf(game.strings[p0]));
+ g_agi->dictionary_words(g_agi->agi_sprintf(game.strings[p0]));
}
cmd(call) {
@@ -546,7 +554,7 @@
old_cIP = cur_logic->cIP;
old_lognum = game.lognum;
- run_logic(p0);
+ g_agi->run_logic(p0);
game.lognum = old_lognum;
cur_logic = &game.logics[game.lognum];
@@ -559,26 +567,26 @@
cmd(draw_pic) {
debugC(6, kDebugLevelScripts, "=== draw pic %d ===", _v[p0]);
- _sprites->erase_both();
- decode_picture(_v[p0], true);
- _sprites->blit_both();
+ g_sprites->erase_both();
+ g_picture->decode_picture(_v[p0], true);
+ g_sprites->blit_both();
game.picture_shown = 0;
debugC(6, kDebugLevelScripts, "--- end of draw pic %d ---", _v[p0]);
}
cmd(show_pic) {
debugC(6, kDebugLevelScripts, "=== show pic ===");
- setflag(F_output_mode, false);
+ g_agi->setflag(F_output_mode, false);
cmd_close_window(NULL);
- show_pic();
+ g_picture->show_pic();
game.picture_shown = 1;
debugC(6, kDebugLevelScripts, "--- end of show pic ---");
}
cmd(load_pic) {
- _sprites->erase_both();
- agi_load_resource(rPICTURE, _v[p0]);
- _sprites->blit_both();
+ g_sprites->erase_both();
+ g_agi->agiLoadResource(rPICTURE, _v[p0]);
+ g_sprites->blit_both();
}
cmd(discard_pic) {
@@ -588,23 +596,23 @@
cmd(overlay_pic) {
debugC(6, kDebugLevelScripts, "--- overlay pic ---");
- _sprites->erase_both();
- decode_picture(_v[p0], false);
- _sprites->blit_both();
+ g_sprites->erase_both();
+ g_picture->decode_picture(_v[p0], false);
+ g_sprites->blit_both();
game.picture_shown = 0;
- _sprites->commit_both();
+ g_sprites->commit_both();
}
cmd(show_pri_screen) {
- debug_.priority = 1;
- _sprites->erase_both();
- show_pic();
- _sprites->blit_both();
- wait_key();
- debug_.priority = 0;
- _sprites->erase_both();
- show_pic();
- _sprites->blit_both();
+ g_agi->_debug.priority = 1;
+ g_sprites->erase_both();
+ g_picture->show_pic();
+ g_sprites->blit_both();
+ g_agi->wait_key();
+ g_agi->_debug.priority = 0;
+ g_sprites->erase_both();
+ g_picture->show_pic();
+ g_sprites->blit_both();
}
cmd(animate_obj) {
@@ -634,24 +642,24 @@
debugC(4, kDebugLevelScripts, "draw entry %d", vt.entry);
vt.flags |= UPDATE;
- if (agi_get_release() >= 0x3000) {
- set_loop(&vt, vt.current_loop);
- set_cel(&vt, vt.current_cel);
+ if (g_agi->agiGetRelease() >= 0x3000) {
+ g_agi->set_loop(&vt, vt.current_loop);
+ g_agi->set_cel(&vt, vt.current_cel);
}
- fix_position(p0);
+ g_agi->fix_position(p0);
vt.x_pos2 = vt.x_pos;
vt.y_pos2 = vt.y_pos;
vt.cel_data_2 = vt.cel_data;
- _sprites->erase_upd_sprites();
+ g_sprites->erase_upd_sprites();
vt.flags |= DRAWN;
- if (agi_get_release() <= 0x2440) /* See bug #546562 */
+ if (g_agi->agiGetRelease() <= 0x2440) /* See bug #546562 */
@@ Diff output truncated at 100000 characters. @@
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list