From 383b598c5cde4c64729d89a7ca84039dc5fabb58 Mon Sep 17 00:00:00 2001 From: Paweł Kołodziejski Date: Wed, 24 May 2006 21:40:24 +0000 Subject: converted to scummvm console style svn-id: r22618 --- engines/agi/agi.cpp | 12 +- engines/agi/agi.h | 9 - engines/agi/checks.cpp | 2 - engines/agi/console.cpp | 871 ++++++++--------------------------------------- engines/agi/console.h | 57 ++-- engines/agi/cycle.cpp | 89 ++--- engines/agi/graphics.cpp | 91 +---- engines/agi/keyboard.cpp | 14 +- engines/agi/op_cmd.cpp | 12 - engines/agi/op_dbg.cpp | 14 - engines/agi/op_test.cpp | 4 - engines/agi/opcodes.h | 2 - engines/agi/savegame.cpp | 41 ++- engines/agi/sprite.cpp | 5 - engines/agi/text.cpp | 41 +-- engines/agi/view.cpp | 26 +- 16 files changed, 269 insertions(+), 1021 deletions(-) (limited to 'engines') diff --git a/engines/agi/agi.cpp b/engines/agi/agi.cpp index fbdcbb86c1..4d2f2e7da9 100644 --- a/engines/agi/agi.cpp +++ b/engines/agi/agi.cpp @@ -65,6 +65,8 @@ static volatile uint32 tick_timer = 0; 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]; @@ -187,7 +189,7 @@ static void process_events() { key = 0x4300; break; case 291: - key = 0x4400; + _console->attach(); break; case 292: key = KEY_STATUSLN; @@ -234,6 +236,8 @@ void agi_timer_low() { while ((dm = tick_timer - m) < 5) { process_events(); + if (_console->isAttached()) + _console->onFrame(); g_system->delayMillis(10); g_system->updateScreen(); } @@ -455,6 +459,8 @@ AgiEngine::AgiEngine(OSystem * syst) : Engine(syst) { rnd = new Common::RandomSource(); + _console = new Console(this); + Common::addSpecialDebugLevel(kDebugLevelMain, "Main", "Generic debug level"); Common::addSpecialDebugLevel(kDebugLevelResources, "Resources", "Resources debugging"); Common::addSpecialDebugLevel(kDebugLevelSprites, "Sprites", "Sprites debugging"); @@ -491,8 +497,6 @@ void AgiEngine::initialize() { tick_timer = 0; Common::g_timer->installTimerProc((Common::Timer::TimerProc) agi_timer_function_low, 10 * 1000, NULL); - console_init(); - game.ver = -1; /* Don't display the conf file warning */ debugC(2, kDebugLevelMain, "Detect game"); @@ -518,6 +522,7 @@ AgiEngine::~AgiEngine() { free(game.sbuf); deinit_machine(); delete rnd; + delete _console; } void AgiEngine::errorString(const char *buf1, char *buf2) { @@ -543,7 +548,6 @@ int AgiEngine::go() { report(" \nAGI engine " VERSION " is ready.\n"); if (game.state < STATE_LOADED) { - console_prompt(); do { main_cycle(); } while (game.state < STATE_RUNNING); diff --git a/engines/agi/agi.h b/engines/agi/agi.h index a9511c1e8b..3d61c0e990 100644 --- a/engines/agi/agi.h +++ b/engines/agi/agi.h @@ -44,7 +44,6 @@ typedef signed int Err; */ #define VERSION __DATE__ " " __TIME__ -#define USE_CONSOLE //#define USE_IIGS_SOUND #define TITLE "AGI engine" @@ -217,17 +216,9 @@ extern volatile uint32 clock_ticks; extern volatile uint32 clock_count; extern volatile uint32 msg_box_secs2; -#ifdef USE_CONSOLE extern struct agi_debug debug_; -#endif - extern struct mouse mouse; -int console_keyhandler(int); -int console_init(void); -void console_cycle(void); -void console_lock(void); -void console_prompt(void); #define report printf enum GameId { diff --git a/engines/agi/checks.cpp b/engines/agi/checks.cpp index 1042ef1579..189d1395a5 100644 --- a/engines/agi/checks.cpp +++ b/engines/agi/checks.cpp @@ -136,9 +136,7 @@ static int check_priority(struct vt_entry *v) { if (pri == 2) { /* trigger */ debugC(4, kDebugLevelSprites, "stepped on trigger"); -#ifdef USE_CONSOLE if (!debug_.ignoretriggers) -#endif trigger = 1; } } diff --git a/engines/agi/console.cpp b/engines/agi/console.cpp index 4a6b439867..83137a2a10 100644 --- a/engines/agi/console.cpp +++ b/engines/agi/console.cpp @@ -32,832 +32,255 @@ #include "agi/opcodes.h" #include "agi/console.h" +#include "common/debugger.cpp" + namespace Agi { -#ifdef USE_CONSOLE +struct agi_debug debug_; -/* - * The main interpreter engine has not been designed to have a console, and a few - * kludges were needed to make the console work. First of all, the main - * interpreter loop works at cycle level, not instruction level. To keep - * the illusion that the console is threaded, a console updating function - * is called from loops inside instructions such as get.string(). - */ +Console::Console(AgiEngine *vm) : Common::Debugger() { + _vm = vm; -#define CONSOLE_LINES_ONSCREEN 20 -#define CONSOLE_PROMPT "$" -#define CONSOLE_CURSOR_HOLLOW 1 -#define CONSOLE_CURSOR_SOLID 2 -#define CONSOLE_CURSOR_EMPTY 3 -#define CONSOLE_COLOR 14 -#define CONSOLE_SCROLLUP_KEY KEY_PGUP -#define CONSOLE_SCROLLDN_KEY KEY_PGDN -#define CONSOLE_START_KEY KEY_HOME -#define CONSOLE_END_KEY KEY_END -#define CONSOLE_INPUT_SIZE 39 - -struct console_command { - char cmd[8]; - char dsc[40]; - void (*handler) (void); -}; - -struct agi_console console; -struct agi_debug debug_; + DCmd_Register("debug", &Console::Cmd_Debug); + DCmd_Register("cont", &Console::Cmd_Cont); + DCmd_Register("exit", &Console::Cmd_Exit); + DCmd_Register("quit", &Console::Cmd_Exit); + DCmd_Register("help", &Console::Cmd_Help); + DCmd_Register("agiver", &Console::Cmd_Agiver); + DCmd_Register("crc", &Console::Cmd_Crc); + DCmd_Register("flags", &Console::Cmd_Flags); + DCmd_Register("logic0", &Console::Cmd_Logic0); + DCmd_Register("objs", &Console::Cmd_Objs); + DCmd_Register("runopcode", &Console::Cmd_RunOpcode); + DCmd_Register("opcode", &Console::Cmd_Opcode); + DCmd_Register("step", &Console::Cmd_Step); + DCmd_Register("trigger", &Console::Cmd_Trigger); + DCmd_Register("vars", &Console::Cmd_Vars); + DCmd_Register("setvar", &Console::Cmd_SetVar); + DCmd_Register("setflag", &Console::Cmd_SetFlag); + DCmd_Register("setobj", &Console::Cmd_SetObj); +} -/* This used to be a linked list, but we reduce total memory footprint - * by implementing it as a statically allocated array. - */ -#define MAX_CCMD 16 -static struct console_command ccmd_list[MAX_CCMD]; -static int num_ccmd = 0; +Console::~Console() { +} -static uint8 has_console = 0; -static uint8 console_input = 0; +void Console::preEnter() { +} -static char *_p0, *_p1, *_p2, *_p3, *_p4, *_p5; /* FIXME: array */ -static char _p[80]; -static int _pn; +void Console::postEnter() { +} -/* - * Console line management - */ +bool Console::Cmd_Exit(int argc, const char **argv) { + _detach_now = true; + return false; +} -static int first_line = 0; +bool Console::Cmd_Help(int argc, const char **argv) { + // console normally has 39 line width + // wrap around nicely + int width = 0, size, i; -static void add_console_line(char *s) { - int last_line; + DebugPrintf("Commands are:\n"); + for (i = 0 ; i < _dcmd_count ; i++) { + size = strlen(_dcmds[i].name) + 1; - last_line = (CONSOLE_LINES_BUFFER - 1 + first_line) % CONSOLE_LINES_BUFFER; + if ((width + size) >= 39) { + DebugPrintf("\n"); + width = size; + } else + width += size; - strncpy(console.line[last_line], s, CONSOLE_LINE_SIZE); - first_line %= CONSOLE_LINES_BUFFER; -} + DebugPrintf("%s ", _dcmds[i].name); + } + + DebugPrintf("\n"); -static char *get_console_line(int n) { - return console.line[(n + first_line) % CONSOLE_LINES_BUFFER]; + return true; } -static char *get_last_console_line() { - int last_line = (CONSOLE_LINES_BUFFER - 1 + first_line) % CONSOLE_LINES_BUFFER; +bool Console::Cmd_SetVar(int argc, const char **argv) { + if (argc != 3) { + DebugPrintf("Usage: setvar "); + return false; + } + int p1 = (int)atoi(argv[1]); + int p2 = (int)atoi(argv[2]); + setvar(p1, p2); - return console.line[last_line]; + return true; } -/* - * Console command parsing - * 'o' commands added by Shaun Jackman , 11 Apr 2002 - */ +bool Console::Cmd_SetFlag(int argc, const char **argv) { + if (argc != 3) { + DebugPrintf("Usage: setvar "); + return false; + } + int p1 = (int)atoi(argv[1]); + int p2 = (int)atoi(argv[2]); + setflag(p1, !!p2); -static int console_parse(char *b) { - struct console_command *d; - int i; + return true; +} - for (; *b && *b == ' '; b++) { - } /* eat spaces */ - for (; *b && b[strlen(b) - 1] == ' '; b[strlen(b) - 1] = 0) { - } - if (!*b) - return 0; - - /* get or set flag/var/obj values */ - if ((b[0] == 'f' || b[0] == 'v' || b[0] == 'o') && isdigit(b[1])) { - char *e; - int f = (int)strtoul(&b[1], &e, 10); - if (*e == 0) { - if (f >= 0 && f <= 255) { - switch (b[0]) { - case 'f': - report(getflag(f) ? "true\n" : "false\n"); - break; - case 'v': - report("%3d\n", getvar(f)); - break; - case 'o': - report("%3d]%-24s(%3d)\n", f, object_name(f), object_get_location(f)); - break; - } - return 0; - } - return -1; - } else if (*e == '=') { - int n = (int)strtoul(e + 1, NULL, 0); - switch (b[0]) { - case 'f': - setflag(f, !!n); - break; - case 'v': - setvar(f, n); - break; - case 'o': - object_set_location(f, n); - break; - } - return 0; - } +bool Console::Cmd_SetObj(int argc, const char **argv) { + if (argc != 3) { + DebugPrintf("Usage: setvar "); + return false; } + int p1 = (int)atoi(argv[1]); + int p2 = (int)atoi(argv[2]); + object_set_location(p1, p2); - /* tokenize the input line */ - if (strchr(b, ' ')) - strcpy(_p, strchr(b, ' ') + 1); - _p0 = strtok(b, " "); - _p1 = strtok(NULL, " "); - _p2 = strtok(NULL, " "); - _p3 = strtok(NULL, " "); - _p4 = strtok(NULL, " "); - _p5 = strtok(NULL, " "); - - /* set number of parameters. ugh, must rewrite this later */ - _pn = 5; - if (!_p5) - _pn = 4; - if (!_p4) - _pn = 3; - if (!_p3) - _pn = 2; - if (!_p2) - _pn = 1; - if (!_p1) - _pn = 0; - - debugC(5, kDebugLevelMain, "number of parameters: %d", _pn); - - for (i = 0; i < num_ccmd; i++) { - d = &ccmd_list[i]; - if (!strcmp(_p0, d->cmd) && d->handler) { - d->handler(); - return 0; - } - } + return true; +} - for (i = 0; logic_names_cmd[i].name; i++) { - if (!strcmp(_p0, logic_names_cmd[i].name)) { +bool Console::Cmd_RunOpcode(int argc, const char **argv) { + for (int i = 0; logic_names_cmd[i].name; i++) { + if (!strcmp(argv[1], logic_names_cmd[i].name)) { uint8 p[16]; - if (_pn != logic_names_cmd[i].num_args) { - report("AGI command wants %d arguments\n", logic_names_cmd[i].num_args); + if ((argc - 2)!= logic_names_cmd[i].num_args) { + DebugPrintf("AGI command wants %d arguments\n", logic_names_cmd[i].num_args); return 0; } - p[0] = _p1 ? (char)strtoul(_p1, NULL, 0) : 0; - p[1] = _p2 ? (char)strtoul(_p2, NULL, 0) : 0; - p[2] = _p3 ? (char)strtoul(_p3, NULL, 0) : 0; - p[3] = _p4 ? (char)strtoul(_p4, NULL, 0) : 0; - p[4] = _p5 ? (char)strtoul(_p5, NULL, 0) : 0; + p[0] = argv[2] ? (char)strtoul(argv[2], NULL, 0) : 0; + p[1] = argv[3] ? (char)strtoul(argv[3], NULL, 0) : 0; + p[2] = argv[4] ? (char)strtoul(argv[4], NULL, 0) : 0; + p[3] = argv[5] ? (char)strtoul(argv[5], NULL, 0) : 0; + p[4] = argv[6] ? (char)strtoul(argv[6], NULL, 0) : 0; - debugC(5, kDebugLevelMain, "ccmd: %s %d %d %d", logic_names_cmd[i].name, p[0], p[1], p[2]); + debugC(5, kDebugLevelMain, "Opcode: %s %d %d %d", logic_names_cmd[i].name, argv[1], argv[2], argv[3]); execute_agi_command(i, p); - return 0; - } - } - - return -1; -} - -/* - * Console commands - */ - -static void ccmd_help() { - int i; - - if (!_p1) { - report("Command Description\n"); - report("------- --------------------------------\n"); - for (i = 0; i < num_ccmd; i++) - report("%-8s%s\n", ccmd_list[i].cmd, ccmd_list[i].dsc); - return; - } - - for (i = 0; i < num_ccmd; i++) { - if (!strcmp(ccmd_list[i].cmd, _p1) && ccmd_list[i].handler) { - report("%s\n", ccmd_list[i].dsc); - return; + return true; } } - report("Unknown command or no help available\n"); - - return; -} - -static void ccmd_ver() { - report(VERSION "\n"); - return; + return false; } -static void ccmd_crc() { +bool Console::Cmd_Crc(int argc, const char **argv) { char name[80]; - report("0x%05x\n", game.crc); + DebugPrintf("0x%05x\n", game.crc); if (match_crc(game.crc, name, 80)) - report("%s\n", name); + DebugPrintf("%s\n", name); else - report("Unknown game\n"); - return; -} + DebugPrintf("Unknown game\n"); -static void ccmd_quit() { - deinit_video(); - /* deinit_machine (); */ - exit(0); -} - -#if 0 -static void ccmd_exec() { - if (game.state < STATE_LOADED) { - report("No game loaded.\n"); - return; - } - - if (game.state >= STATE_RUNNING) { - report("Game already running.\n"); - return; - } - - report("Executing AGI game.\n"); - game.state = STATE_RUNNING; -} -#endif - -static void ccmd_hires() { - if (_pn != 1 || (strcmp(_p1, "on") && strcmp(_p1, "off"))) { - report("Usage: hires on|off\n"); - return; - } - - opt.hires = !strcmp(_p1, "on"); - erase_both(); - show_pic(); - blit_both(); - return; + return true; } -static void ccmd_agiver() { +bool Console::Cmd_Agiver(int argc, const char **argv) { int ver, maj, min; ver = agi_get_release(); maj = (ver >> 12) & 0xf; min = ver & 0xfff; - report(maj <= 2 ? "%x.%03x\n" : "%x.002.%03x\n", maj, min); - return; + DebugPrintf(maj <= 2 ? "%x.%03x\n" : "%x.002.%03x\n", maj, min); + + return true; } -static void ccmd_flags() { +bool Console::Cmd_Flags(int argc, const char **argv) { int i, j; - report(" "); + DebugPrintf(" "); for (j = 0; j < 10; j++) - report("%d ", j); - report("\n"); + DebugPrintf("%d ", j); + DebugPrintf("\n"); for (i = 0; i < 255;) { - report("%3d ", i); + DebugPrintf("%3d ", i); for (j = 0; j < 10; j++, i++) { - report("%c ", getflag(i) ? 'T' : 'F'); + DebugPrintf("%c ", getflag(i) ? 'T' : 'F'); } report("\n"); } - return; + + return true; } -static void ccmd_vars() { +bool Console::Cmd_Vars(int argc, const char **argv) { int i, j; for (i = 0; i < 255;) { for (j = 0; j < 5; j++, i++) { - report("%03d:%3d ", i, getvar(i)); + DebugPrintf("%03d:%3d ", i, getvar(i)); } - report("\n"); + DebugPrintf("\n"); } - return; -} - -#if 0 - -static void ccmd_say() { - setflag(F_entered_cli, true); - dictionary_words(_p); -} -static void ccmd_inv() { - unsigned int i, j; - - for (j = i = 0; i < game.num_objects; i++) { - if (object_get_location(i) == EGO_OWNED) { - report("%3d]%-16.16s", i, object_name(i)); - if (j % 2) - report("\n"); - j++; - } - } - if (j == 0) { - report("none\n"); - return; - } - if (j % 2) - report("\n"); + return true; } -#endif - -static void ccmd_objs() { +bool Console::Cmd_Objs(int argc, const char **argv) { unsigned int i; for (i = 0; i < game.num_objects; i++) { - report("%3d]%-24s(%3d)\n", i, object_name(i), object_get_location(i)); - } - return; -} - -static void ccmd_opcode() { - if (_pn != 1 || (strcmp(_p1, "on") && strcmp(_p1, "off"))) { - report("Usage: opcode on|off\n"); - return; - } - - debug_.opcodes = !strcmp(_p1, "on"); - return; -} - -static void ccmd_logic0() { - if (_pn != 1 || (strcmp(_p1, "on") && strcmp(_p1, "off"))) { - report("Usage: logic0 on|off\n"); - return; - } - - debug_.logic0 = !strcmp(_p1, "on"); - return; -} - -static void ccmd_trigger() { - if (_pn != 1 || (strcmp(_p1, "on") && strcmp(_p1, "off"))) { - report("Usage: trigger on|off\n"); - return; - } - - debug_.ignoretriggers = strcmp(_p1, "on"); - return; -} - -static void ccmd_step() { - debug_.enabled = 1; - - if (_pn == 0) { - debug_.steps = 1; - return; - } - - debug_.steps = strtoul(_p1, NULL, 0); - return; -} - -static void ccmd_debug() { - debug_.enabled = 1; - debug_.steps = 0; - return; -} - -static void ccmd_cont() { - debug_.enabled = 0; - debug_.steps = 0; - return; -} - -/* - * Register console commands - */ -static void console_cmd(const char *cmd, const char *dsc, void (*handler) (void)) { - assert(num_ccmd < MAX_CCMD); - - strcpy(ccmd_list[num_ccmd].cmd, cmd); - strcpy(ccmd_list[num_ccmd].dsc, dsc); - ccmd_list[num_ccmd].handler = handler; - - num_ccmd++; -} - -/* Console reporting */ - -/* A slightly modified strtok() for report() */ -static char *get_token(char *s, char d) { - static char *x; - char *n, *m; - - if (s) - x = s; - - m = x; - n = strchr(x, d); - - if (n) { - *n = 0; - x = n + 1; - } else { - x = strchr(x, 0); + DebugPrintf("%3d]%-24s(%3d)\n", i, object_name(i), object_get_location(i)); } - return m; -} - -static void build_console_lines(int n) { - int j, y1; - char *line; - - clear_console_screen(GFX_HEIGHT - n * 10); - - for (j = CONSOLE_LINES_ONSCREEN - n; j < CONSOLE_LINES_ONSCREEN; j++) { - line = get_console_line(console.first_line + j); - print_text_console(line, 0, j, strlen(line) + 1, CONSOLE_COLOR, 0); - } - - y1 = console.y - n * 10; - if (y1 < 0) - y1 = 0; - - /* CM: - * This will cause blinking when using menus+console, but this - * function is called by report() which can be called from any - * point with or without sprites placed. If we protect the - * flush_block() call with redraw/release sprites cloning will - * happen when activating the console. This could be fixed by - * keeping a control flag in redraw/release to not do the - * actions twice, but I don't want to do that -- not yet. - */ - flush_block(0, y1, GFX_WIDTH - 1, console.y); -} - -/* - * Public functions - */ - -int console_init() { - console_cmd("agiver", "Show emulated Sierra AGI version", ccmd_agiver); - console_cmd("cont", "Resume interpreter execution", ccmd_cont); - console_cmd("debug", "Stop interpreter execution", ccmd_debug); - console_cmd("crc", "Show AGI game CRC", ccmd_crc); -#if 0 - console_cmd("exec", "Execute loaded AGI game", ccmd_exec); -#endif - console_cmd("flags", "Dump all AGI flags", ccmd_flags); - console_cmd("help", "List available commands", ccmd_help); - console_cmd("hires", "Turn hi-res mode on/off", ccmd_hires); - console_cmd("logic0", "Turn logic 0 debugging on/off", ccmd_logic0); - console_cmd("objs", "List all objects and locations", ccmd_objs); - console_cmd("opcode", "Turn opcodes on/off in debug", ccmd_opcode); - console_cmd("quit", "Quit the interpreter", ccmd_quit); -#if 0 - console_cmd("inv", "List current inventory", ccmd_inv); - console_cmd("say", "Pass argument to the AGI parser", ccmd_say); -#endif - console_cmd("step", "Execute the next AGI instruction", ccmd_step); - console_cmd("trigger", "Turn trigger lines on/off", ccmd_trigger); - console_cmd("vars", "Dump all AGI variables", ccmd_vars); - console_cmd("ver", "Show interpreter version", ccmd_ver); - - console.active = 1; - console.input_active = 1; - console.index = 0; - console.max_y = 150; - console.y = console.max_y; - console.first_line = CONSOLE_LINES_BUFFER - CONSOLE_LINES_ONSCREEN; - - debug_.enabled = 0; - debug_.opcodes = 0; - debug_.logic0 = 1; - debug_.priority = 0; - - has_console = 1; - clear_screen(0); - - return err_OK; -} - -static void build_console_layer() { - build_console_lines(console.max_y / 10); + return true; } -void report(const char *message, ...) { - char x[512], y[512], z[64], *msg, *n; - va_list args; - int i, s, len; - - if (!has_console) - return; - - va_start(args, message); -#ifdef HAVE_VSNPRINTF - vsnprintf(y, 510, message, args); -#else - vsprintf(y, message, args); -#endif - va_end(args); - - if (console_input) { - strcpy(z, get_last_console_line()); - strcpy(x, ">"); - } else { - strcpy(x, get_last_console_line()); - } - - strcat(x, y); - - len = 40; - msg = n = word_wrap_string(x, &len); - - for (s = 1; *n; n++) - if (*n == '\n') - s++; - - add_console_line(get_token(msg, '\n')); - for (i = 1; i < s; i++) { - first_line++; - n = get_token(NULL, '\n'); - add_console_line(n); - } - - console.first_line = CONSOLE_LINES_BUFFER - CONSOLE_LINES_ONSCREEN; - - if (console_input) { - add_console_line(z); - } - - /* Build layer */ - if (console.y) { - if (s > 1) - build_console_layer(); - else - build_console_lines(1); +bool Console::Cmd_Opcode(int argc, const char **argv) { + if (argc != 1 || (strcmp(argv[1], "on") && strcmp(argv[1], "off"))) { + DebugPrintf("Usage: opcode on|off\n"); + return false; } - free(msg); + debug_.opcodes = !strcmp(argv[1], "on"); - do_update(); + return true; } -void console_cycle() { - static int old_y = 0; - static int blink = 0; - static char cursor[] = " "; - - /* If no game has been loaded, keep the console visible! */ - if (game.state < STATE_RUNNING) { - console.active = 1; - console.count = 10; - } - - /* Initial console auto-hide timer */ - if (console.count > 0) - console.count--; - if (console.count == 0) { - console.active = 0; - console.count = -1; - } - - if (console.active) { - if (console.y < console.max_y) - console.y += 15; - else - console.y = console.max_y; - } else { - console.count = -1; - - if (console.y > 0) - console.y -= 15; - else - console.y = 0; - } - - /* console shading animation */ - if (old_y != console.y) { - int y = console.y; - if (old_y > console.y) { - /* going up */ - y = old_y; - } - flush_block(0, 0, GFX_WIDTH - 1, y); - old_y = console.y; +bool Console::Cmd_Logic0(int argc, const char **argv) { + if (argc != 1 || (strcmp(argv[1], "on") && strcmp(argv[1], "off"))) { + DebugPrintf("Usage: logic0 on|off\n"); + return false; } - blink++; - blink %= 16; - if (console.input_active) { - *cursor = blink < 8 ? - CONSOLE_CURSOR_SOLID : CONSOLE_CURSOR_EMPTY; - } else { - *cursor = CONSOLE_CURSOR_HOLLOW; - } - if (console.y > 0 - && console.first_line == - CONSOLE_LINES_BUFFER - CONSOLE_LINES_ONSCREEN) { - int16 y1 = console.y - 10, y2 = console.y - 1; - if (y1 < 0) - y1 = 0; - if (y2 < 0) - y2 = 0; - print_text_console(cursor, (1 + console.index), 19, 2, CONSOLE_COLOR, 0); - flush_block((1 + console.index) * 8, y1, (1 + console.index) * 8 + 7, y2 - 1); - } + debug_.logic0 = !strcmp(argv[1], "on"); - do_update(); + return true; } -/* Return true if key was handled */ -int console_keyhandler(int k) { - static char buffer[CONSOLE_INPUT_SIZE]; - int16 y1, y2; - char m[2]; - - /* Right button switches console on/off */ - if (!opt.agimouse) /* AGI Mouse uses right button */ - if (k == BUTTON_RIGHT) - k = CONSOLE_ACTIVATE_KEY; - - if (!console.active) { - if (k == CONSOLE_ACTIVATE_KEY) { - console.active = 1; - return true; - } +bool Console::Cmd_Trigger(int argc, const char **argv) { + if (argc != 1 || (strcmp(argv[1], "on") && strcmp(argv[1], "off"))) { + DebugPrintf("Usage: trigger on|off\n"); return false; } + debug_.ignoretriggers = strcmp (argv[1], "on"); - if (!console.input_active) { - if (k == CONSOLE_SWITCH_KEY) { - console.input_active = 1; - return true; - } - if (k == CONSOLE_ACTIVATE_KEY) { - console.active = 0; - return true; - } - return false; - } - - y1 = console.y - 10; - y2 = console.y - 1; + return true; +} - if (y1 < 0) - y1 = 0; - if (y2 < 0) - y2 = 0; +bool Console::Cmd_Step(int argc, const char **argv) { + debug_.enabled = 1; - /* Ignore left button in console */ - if (k == BUTTON_LEFT) + if (argc == 0) { + debug_.steps = 1; return true; - - /* this code breaks scrolling up, maybe it shoud only be executed - * in the default case? - */ - if (k) { - /* make sure it's not enter or a scroll key */ - if ((k != KEY_ENTER) && (k != CONSOLE_SCROLLUP_KEY) && (k != CONSOLE_SCROLLDN_KEY) - && (k != CONSOLE_START_KEY)) { - /* on any other input reset the console to the bottom */ - if (console.first_line != CONSOLE_LINES_BUFFER - CONSOLE_LINES_ONSCREEN) { - console.first_line = CONSOLE_LINES_BUFFER - CONSOLE_LINES_ONSCREEN; - build_console_layer(); - } - console.count = -1; - } - } - - switch (k) { - case KEY_ENTER: - console_lock(); - console.index = 0; - report("\n"); - - if (console_parse(buffer) != 0) - report("What? Where?\n"); - - buffer[0] = 0; - console_prompt(); - break; - case KEY_BACKSPACE:{ - char *x; - if (!console.index) - break; - x = get_last_console_line(); - x[console.index] = 0; - *m = CONSOLE_CURSOR_EMPTY; - print_text_console(m, (console.index + 1), 19, 2, CONSOLE_COLOR, 0); - flush_block((console.index + 1) * CHAR_COLS, y1, (console.index + 1 + 1) * CHAR_COLS - 1, y2); - console.index--; - buffer[console.index] = 0; - } - break; - case CONSOLE_ACTIVATE_KEY: - console.active = !console.active; - if (console.active) - build_console_layer(); - break; - case CONSOLE_SWITCH_KEY: - console.count = -1; - if (console.y) - console.input_active = !console.input_active; - break; - case CONSOLE_SCROLLUP_KEY: - console.count = -1; - if (!console.y) - break; - if (console.first_line > (CONSOLE_LINES_ONSCREEN / 2)) - console.first_line -= CONSOLE_LINES_ONSCREEN / 2; - else - console.first_line = 0; - build_console_layer(); - break; - case CONSOLE_SCROLLDN_KEY: - console.count = -1; - if (!console.y) - break; - if (console.first_line < (CONSOLE_LINES_BUFFER - CONSOLE_LINES_ONSCREEN - CONSOLE_LINES_ONSCREEN / 2)) - console.first_line += CONSOLE_LINES_ONSCREEN / 2; - else - console.first_line = CONSOLE_LINES_BUFFER - CONSOLE_LINES_ONSCREEN; - build_console_layer(); - break; - case CONSOLE_START_KEY: - console.count = -1; - if (console.y) - console.first_line = 0; - break; - case CONSOLE_END_KEY: - console.count = -1; - if (console.y) - console.first_line = CONSOLE_LINES_BUFFER - CONSOLE_LINES_ONSCREEN; - break; - default: - if (k >= 0x20 && k <= 0x7f && (console.index < CONSOLE_INPUT_SIZE - 2)) { - char l[42]; - buffer[console.index] = k; - *m = k; - m[1] = 0; - console.index++; - - sprintf(l, "%s%c", get_last_console_line(), k); - strncpy(get_last_console_line(), l, CONSOLE_LINE_SIZE); - - buffer[console.index] = 0; - print_text_console(m, console.index, 19, 2, CONSOLE_COLOR, 0); - flush_block(console.index * 8, y1, console.index * 8 + 7, y2); - } - break; } - do_update(); + debug_.steps = strtoul(argv[1], NULL, 0); return true; } -void console_prompt() { - report(CONSOLE_PROMPT); - console_input = 1; -} - -void console_lock() { - console_input = 0; -} - -#else - -void *debug; - -void report(const char *message, ...) { - /* dummy */ -} - -int console_init() { - return 0; -} - -/* Date: Sun, 14 Oct 2001 23:02:02 -0700 - * From: Vasyl Tsvirkunov - * - * This one was rather harmless and affected only builds without console. - * In SQ1&2 (and likely some others) name entry screen did not update - * properly. The bug caused by implicit assumption in cycle.c that - * console_cycle() updates the screen. Well, it does, if console is enabled. - * The fix is simple. In the second version of console_cycle() in console.c - * (the "dummy" one) add call to do_update(). The thing raises some - * questions about overall architecture of main cycle, but otherwise the fix - * works just fine. - */ -void console_cycle() { - do_update(); -} +bool Console::Cmd_Debug(int argc, const char **argv) { + debug_.enabled = 1; + debug_.steps = 0; -void console_lock() { - /* dummy */ + return true; } -void console_prompt() { - /* dummy */ -} +bool Console::Cmd_Cont(int argc, const char **argv) { + debug_.enabled = 0; + debug_.steps = 0; -int console_keyhandler(int i) { - return false; + return true; } -#endif /* USE_CONSOLE */ - } // End of namespace Agi diff --git a/engines/agi/console.h b/engines/agi/console.h index d2d694a181..c94a9099e5 100644 --- a/engines/agi/console.h +++ b/engines/agi/console.h @@ -25,25 +25,11 @@ #ifndef AGI_CONSOLE_H #define AGI_CONSOLE_H -namespace Agi { - -#ifdef USE_CONSOLE +#include "common/debugger.h" -#define CONSOLE_LINES_BUFFER 80 -#define CONSOLE_LINE_SIZE (GFX_WIDTH / 8) -#define CONSOLE_ACTIVATE_KEY '`' -#define CONSOLE_SWITCH_KEY '~' +namespace Agi { -struct agi_console { - int active; - int input_active; - int index; - int y; - int max_y; - int first_line; - int count; - char *line[CONSOLE_LINES_BUFFER]; -}; +class AgiEngine; struct agi_debug { int enabled; @@ -55,16 +41,37 @@ struct agi_debug { int ignoretriggers; }; -extern struct agi_console console; +class Console : public Common::Debugger { +public: + Console(AgiEngine *vm); + virtual ~Console(void); + +protected: + virtual void preEnter(); + virtual void postEnter(); -#endif /* USE_CONSOLE */ +private: + bool Cmd_Exit(int argc, const char **argv); + bool Cmd_Help(int argc, const char **argv); + bool Cmd_SetVar(int argc, const char **argv); + bool Cmd_SetFlag(int argc, const char **argv); + bool Cmd_SetObj(int argc, const char **argv); + bool Cmd_RunOpcode(int argc, const char **argv); + bool Cmd_Crc(int argc, const char **argv); + bool Cmd_Agiver(int argc, const char **argv); + bool Cmd_Flags(int argc, const char **argv); + bool Cmd_Vars(int argc, const char **argv); + bool Cmd_Objs(int argc, const char **argv); + bool Cmd_Opcode(int argc, const char **argv); + bool Cmd_Logic0(int argc, const char **argv); + bool Cmd_Trigger(int argc, const char **argv); + bool Cmd_Step(int argc, const char **argv); + bool Cmd_Debug(int argc, const char **argv); + bool Cmd_Cont(int argc, const char **argv); -int console_keyhandler(int); -int console_init(void); -void console_cycle(void); -void console_lock(void); -void console_prompt(void); -void report(const char *, ...); +private: + AgiEngine *_vm; +}; } // End of namespace Agi diff --git a/engines/agi/cycle.cpp b/engines/agi/cycle.cpp index 2374d0dccd..2057189cd6 100644 --- a/engines/agi/cycle.cpp +++ b/engines/agi/cycle.cpp @@ -217,7 +217,6 @@ int main_cycle() { game.vars[29] = mouse.y; } -#ifdef USE_CONSOLE if (key == KEY_PRIORITY) { erase_both(); debug_.priority = !debug_.priority; @@ -232,7 +231,6 @@ int main_cycle() { write_status(); key = 0; } -#endif /* Click-to-walk mouse interface */ if (game.player_control && v->flags & ADJ_EGO_XY) { @@ -244,56 +242,46 @@ int main_cycle() { kascii = KEY_ASCII(key); - if (!console_keyhandler(key)) { - if (kascii) - setvar(V_key, kascii); - process_key: - switch (game.input_mode) { - case INPUT_NORMAL: - if (!handle_controller(key)) { - if (key == 0 || !game.input_enabled) - break; - handle_keys(key); - - /* if ESC pressed, activate menu before - * accept.input from the interpreter cycle - * sets the input mode to normal again - * (closes: #540856) - */ - if (key == KEY_ESCAPE) { - key = 0; - goto process_key; - } - - /* commented out to close bug #438872 - * if (key) game.keypress = key; - */ + if (kascii) + setvar(V_key, kascii); + process_key: + switch (game.input_mode) { + case INPUT_NORMAL: + if (!handle_controller(key)) { + if (key == 0 || !game.input_enabled) + break; + handle_keys(key); + + /* if ESC pressed, activate menu before + * accept.input from the interpreter cycle + * sets the input mode to normal again + * (closes: #540856) + */ + if (key == KEY_ESCAPE) { + key = 0; + goto process_key; } - break; - case INPUT_GETSTRING: - handle_controller(key); - handle_getstring(key); - setvar(V_key, 0); /* clear ENTER key */ - break; - case INPUT_MENU: - menu_keyhandler(key); - console_cycle(); - return false; - case INPUT_NONE: - handle_controller(key); - if (key) - game.keypress = key; - break; - } - } else { - if (game.input_mode == INPUT_MENU) { - console_cycle(); - return false; + + /* commented out to close bug #438872 + * if (key) game.keypress = key; + */ } + break; + case INPUT_GETSTRING: + handle_controller(key); + handle_getstring(key); + setvar(V_key, 0); /* clear ENTER key */ + break; + case INPUT_MENU: + menu_keyhandler(key); + return false; + case INPUT_NONE: + handle_controller(key); + if (key) + game.keypress = key; + break; } - console_cycle(); - if (game.msg_box_ticks > 0) game.msg_box_ticks--; @@ -327,11 +315,6 @@ static int play_game() { report("Running AGI script.\n"); -#ifdef USE_CONSOLE - console.count = 5; - console_prompt(); -#endif - setflag(F_entered_cli, false); setflag(F_said_accepted_input, false); game.vars[V_word_not_found] = 0; diff --git a/engines/agi/graphics.cpp b/engines/agi/graphics.cpp index 6dfb00825f..e6cb046f88 100644 --- a/engines/agi/graphics.cpp +++ b/engines/agi/graphics.cpp @@ -38,9 +38,6 @@ namespace Agi { #endif static uint8 *agi_screen; -#ifdef USE_CONSOLE -static uint8 *console_screen; -#endif static unsigned char *screen; @@ -136,54 +133,6 @@ static struct update_block update = { * Layer 1: 160x168 ================== AGI screen */ -#ifdef USE_CONSOLE - -/** - * Draws a row of pixels in the output device framebuffer. - * This function adds the console layer using transparent colors if - * appropriate. - */ -static void put_pixels(const int x, const int y, const int w, uint8 *p) { - int i; - uint8 _b[GFX_WIDTH] = { 0 }; - uint8 *b, *c = NULL; - - if (console.y <= y) { - memcpy(screen + x + y * 320, p, w); - return; - } - - b = &_b[0]; - c = &console_screen[x + (y + GFX_HEIGHT - 1 - console.y) * GFX_WIDTH]; - - for (i = 0; i < w; i++, c++, p++) { - *b++ = *c ? *c : *p + 16; - } - - memcpy(screen + x + y * 320, _b, w); -} - -static void init_console() { - int i; - - /* Console */ - console.line[0] = (char *)calloc(CONSOLE_LINES_BUFFER, CONSOLE_LINE_SIZE + 1); - for (i = 1; i < CONSOLE_LINES_BUFFER; i++) - console.line[i] = console.line[i - 1] + CONSOLE_LINE_SIZE + 1; -} - -#else - -static void put_pixels(const int x, const int y, const int w, uint8 *p) { - gfx->put_pixels(x, y, w, p); -} - -static void init_console() -{ -} - -#endif /* USE_CONSOLE */ - #define SHAKE_MAG 3 static uint8 *shake_h, *shake_v; @@ -251,14 +200,7 @@ void put_text_character(int l, int x, int y, unsigned int c, int fg, int bg) { xx = x + x1; yy = y + y1; cc = (*p & (1 << (7 - x1))) ? fg : bg; -#ifdef USE_CONSOLE - if (l) { - console_screen[xx + yy * GFX_WIDTH] = cc; - } else -#endif - { - agi_screen[xx + yy * GFX_WIDTH] = cc; - } + agi_screen[xx + yy * GFX_WIDTH] = cc; } p++; @@ -464,18 +406,9 @@ int init_video() { else init_palette(new_palette); - init_console(); - if ((agi_screen = (uint8 *)calloc(GFX_WIDTH, GFX_HEIGHT)) == NULL) return err_NotEnoughMemory; -#ifdef USE_CONSOLE - if ((console_screen = (uint8 *)calloc(GFX_WIDTH, GFX_HEIGHT)) == NULL) { - free(agi_screen); - return err_NotEnoughMemory; - } -#endif - gfx_set_palette(); byte mouseCursor[16 * 16]; @@ -506,9 +439,6 @@ int init_video() { */ int deinit_video() { free(agi_screen); -#ifdef USE_CONSOLE - free(console_screen); -#endif return err_OK; } @@ -541,19 +471,15 @@ void put_pixels_a(int x, int y, int n, uint8 *p) { if (opt.cgaemu) { for (x *= 2; n--; p++, x += 2) { register uint16 q = (cga_map[(*p & 0xf0) >> 4] << 4) | cga_map[*p & 0x0f]; -#ifdef USE_CONSOLE if (debug_.priority) q >>= 4; -#endif *(uint16 *)&agi_screen[x + y * GFX_WIDTH] = q & 0x0f0f; } } else { for (x *= 2; n--; p++, x += 2) { register uint16 q = ((uint16) * p << 8) | *p; -#ifdef USE_CONSOLE if (debug_.priority) q >>= 4; -#endif *(uint16 *)&agi_screen[x + y * GFX_WIDTH] = q & 0x0f0f; } } @@ -563,10 +489,8 @@ void put_pixels_hires(int x, int y, int n, uint8 *p) { //y += CHAR_LINES; for (; n--; p++, x++) { uint8 q = *p; -#ifdef USE_CONSOLE if (debug_.priority) q >>= 4; -#endif agi_screen[x + y * GFX_WIDTH] = q & 0x0f; } } @@ -633,7 +557,7 @@ void flush_block(int x1, int y1, int x2, int y2) { w = x2 - x1 + 1; for (y = y1; y <= y2; y++) { - put_pixels(x1, y, w, p0); + memcpy(screen + 320 * y + x1, p0, w); p0 += GFX_WIDTH; } } @@ -675,17 +599,6 @@ void clear_screen(int c) { flush_screen(); } -#ifdef USE_CONSOLE -/** - * Clear the console screen. - * This function clears the top n lines of the console screen. - * @param n number of lines to clear (in pixels) - */ -void clear_console_screen(int n) { - memset(console_screen + n * GFX_WIDTH, 0, (GFX_HEIGHT - n) * GFX_WIDTH); -} -#endif - /** * Save a block of the AGI engine screen */ diff --git a/engines/agi/keyboard.cpp b/engines/agi/keyboard.cpp index 540d188bba..d73e1d1914 100644 --- a/engines/agi/keyboard.cpp +++ b/engines/agi/keyboard.cpp @@ -34,10 +34,6 @@ namespace Agi { char last_sentence[40]; -#ifdef USE_CONSOLE -extern struct agi_console console; -#endif - /* FIXME */ extern int open_dialogue; @@ -349,11 +345,8 @@ int wait_key() { while (42) { poll_timer(); /* msdos driver -> does nothing */ key = do_poll_keyboard(); - if (!console_keyhandler(key)) { - if (key == KEY_ENTER || key == KEY_ESCAPE || key == BUTTON_LEFT) - break; - } - console_cycle(); + if (key == KEY_ENTER || key == KEY_ESCAPE || key == BUTTON_LEFT) + break; } return key; } @@ -370,9 +363,8 @@ int wait_any_key() { while (42) { poll_timer(); /* msdos driver -> does nothing */ key = do_poll_keyboard(); - if (!console_keyhandler(key) && key) + if (key) break; - console_cycle(); } return key; } diff --git a/engines/agi/op_cmd.cpp b/engines/agi/op_cmd.cpp index 9b30b0eacd..94b27ef368 100644 --- a/engines/agi/op_cmd.cpp +++ b/engines/agi/op_cmd.cpp @@ -595,7 +595,6 @@ cmd(overlay_pic) { } cmd(show_pri_screen) { -#ifdef USE_CONSOLE debug_.priority = 1; erase_both(); show_pic(); @@ -605,7 +604,6 @@ cmd(show_pri_screen) { erase_both(); show_pic(); blit_both(); -#endif } cmd(animate_obj) { @@ -1137,10 +1135,6 @@ cmd(clear_text_rect) { cmd(toggle_monitor) { report("toggle.monitor\n"); - opt.hires = !opt.hires; - erase_both(); - show_pic(); - blit_both(); } cmd(echo_line) { @@ -1443,7 +1437,6 @@ int run_logic(int n) { timer_hack = 0; while (ip < game.logics[n].size && !game.quit_prog_now) { -#ifdef USE_CONSOLE if (debug_.enabled) { if (debug_.steps > 0) { if (debug_.logic0 || n) { @@ -1452,15 +1445,12 @@ int run_logic(int n) { } } else { blit_both(); - console_prompt(); do { main_cycle(); } while (!debug_.steps && debug_.enabled); - console_lock(); erase_both(); } } -#endif switch (op = *(code + ip++)) { case 0xff: /* if (open/close) */ @@ -1496,9 +1486,7 @@ int run_logic(int n) { } void execute_agi_command(uint8 op, uint8 *p) { -#ifdef USE_CONSOLE debugC(2, kDebugLevelScripts, "%s %d %d %d", logic_names_cmd[op].name, p[0], p[1], p[2]); -#endif agi_command[op] (p); } diff --git a/engines/agi/op_dbg.cpp b/engines/agi/op_dbg.cpp index dcf6e75b01..79d2d2403d 100644 --- a/engines/agi/op_dbg.cpp +++ b/engines/agi/op_dbg.cpp @@ -36,11 +36,7 @@ namespace Agi { #undef _L #endif -#ifdef USE_CONSOLE #define _L(a,b,c) { a, b, c } -#else -#define _L(a,b,c) { b, c } -#endif struct agi_logicnames logic_names_test[] = { _L("", 0, 0x00), @@ -270,8 +266,6 @@ struct agi_logicnames logic_names_cmd[] = { _L(NULL, 0, 0x00) }; -#ifdef USE_CONSOLE - void debug_console(int lognum, int mode, const char *str) { struct agi_logicnames *x; uint8 a, c, z; @@ -342,12 +336,4 @@ void debug_console(int lognum, int mode, const char *str) { report("\n"); } -#else - -void debug_console(int lognum, int mode, char *str) { - /* dummy */ -} - -#endif /* USE_CONSOLE */ - } // End of namespace Agi diff --git a/engines/agi/op_test.cpp b/engines/agi/op_test.cpp index 94bd7ffd88..8ead659263 100644 --- a/engines/agi/op_test.cpp +++ b/engines/agi/op_test.cpp @@ -227,10 +227,8 @@ int test_if_code(int lognum) { uint8 p[16] = { 0 }; while (retval && !game.quit_prog_now) { -#ifdef USE_CONSOLE if (debug_.enabled && (debug_.logic0 || lognum)) debug_console(lognum, lTEST_MODE, NULL); -#endif last_ip = ip; op = *(code + ip++); @@ -408,10 +406,8 @@ int test_if_code(int lognum) { ip += READ_LE_UINT16(code + ip) + 2; } -#ifdef USE_CONSOLE if (debug_.enabled && (debug_.logic0 || lognum)) debug_console(lognum, 0xFF, retval ? "=true" : "=false"); -#endif return retval; } diff --git a/engines/agi/opcodes.h b/engines/agi/opcodes.h index 2a1b9b87d0..4a8951d072 100644 --- a/engines/agi/opcodes.h +++ b/engines/agi/opcodes.h @@ -30,9 +30,7 @@ namespace Agi { struct agi_logicnames { -#ifdef USE_CONSOLE /* ifndef NO_DEBUG */ const char *name; -#endif uint16 num_args; uint16 arg_mask; }; diff --git a/engines/agi/savegame.cpp b/engines/agi/savegame.cpp index 8ec2454298..7037a3d133 100644 --- a/engines/agi/savegame.cpp +++ b/engines/agi/savegame.cpp @@ -614,29 +614,26 @@ static int select_slot() { poll_timer(); /* msdos driver -> does nothing */ key = do_poll_keyboard(); - if (!console_keyhandler(key)) { - switch (key) { - case KEY_ENTER: - rc = active; - strncpy(game.strings[MAX_STRINGS], desc[i], MAX_STRINGLEN); - goto press; - case KEY_ESCAPE: - rc = -1; - goto getout; - case BUTTON_LEFT: - break; - case KEY_DOWN: - active++; - active %= NUM_SLOTS; - break; - case KEY_UP: - active--; - if (active < 0) - active = NUM_SLOTS - 1; - break; - } + switch (key) { + case KEY_ENTER: + rc = active; + strncpy(game.strings[MAX_STRINGS], desc[i], MAX_STRINGLEN); + goto press; + case KEY_ESCAPE: + rc = -1; + goto getout; + case BUTTON_LEFT: + break; + case KEY_DOWN: + active++; + active %= NUM_SLOTS; + break; + case KEY_UP: + active--; + if (active < 0) + active = NUM_SLOTS - 1; + break; } - console_cycle(); } press: diff --git a/engines/agi/sprite.cpp b/engines/agi/sprite.cpp index af8588a84d..26e6f52238 100644 --- a/engines/agi/sprite.cpp +++ b/engines/agi/sprite.cpp @@ -497,11 +497,6 @@ static void commit_sprites(struct list_head *head) { s->v->y_pos2 = s->v->y_pos; s->v->flags &= ~DIDNT_MOVE; } - -#ifdef USE_CONSOLE - if (debug_.statusline) - write_status(); -#endif } /** diff --git a/engines/agi/text.cpp b/engines/agi/text.cpp index 2b837c2237..b9a70b9dff 100644 --- a/engines/agi/text.cpp +++ b/engines/agi/text.cpp @@ -356,30 +356,27 @@ int selection_box(const char *m, const char **b) { poll_timer(); /* msdos driver -> does nothing */ key = do_poll_keyboard(); - if (!console_keyhandler(key)) { - switch (key) { - case KEY_ENTER: - rc = active; - goto press; - case KEY_ESCAPE: - rc = -1; - goto getout; - case BUTTON_LEFT: - for (i = 0; b[i]; i++) { - if (test_button(bx[i], by[i], b[i])) { - rc = active = i; - goto press; - } + switch (key) { + case KEY_ENTER: + rc = active; + goto press; + case KEY_ESCAPE: + rc = -1; + goto getout; + case BUTTON_LEFT: + for (i = 0; b[i]; i++) { + if (test_button(bx[i], by[i], b[i])) { + rc = active = i; + goto press; } - break; - case 0x09: /* Tab */ - debugC(3, kDebugLevelText, "Focus change"); - active++; - active %= i; - break; } + break; + case 0x09: /* Tab */ + debugC(3, kDebugLevelText, "Focus change"); + active++; + active %= i; + break; } - console_cycle(); } press: @@ -573,7 +570,6 @@ char *agi_sprintf(const char *s) { void write_status() { char x[64]; -#ifdef USE_CONSOLE if (debug_.statusline) { print_status("%3d(%03d) %3d,%3d(%3d,%3d) ", getvar(0), getvar(1), game.view_table[0].x_pos, @@ -581,7 +577,6 @@ void write_status() { WIN_TO_PIC_Y(mouse.y)); return; } -#endif /* USE_CONSOLE */ if (!game.status_line) { int l = game.line_status; diff --git a/engines/agi/view.cpp b/engines/agi/view.cpp index b8fc559b84..536cf3a47f 100644 --- a/engines/agi/view.cpp +++ b/engines/agi/view.cpp @@ -367,28 +367,10 @@ void update_viewtable() { } if (i) { -#ifdef USE_CONSOLE - /* To correctly update sprites when we use the console - * we must work with all sprites. - */ - if (console.y > 0) { - erase_both(); - update_position(); - blit_both(); - commit_both(); - } else -#endif - /* If we're not using the console, updating only - * the active sprites lets us save some CPU cycles. - * This is how the original Sierra AGI works. - */ - { - erase_upd_sprites(); - update_position(); - blit_upd_sprites(); - commit_upd_sprites(); - } - + erase_upd_sprites(); + update_position(); + blit_upd_sprites(); + commit_upd_sprites(); game.view_table[0].flags &= ~(ON_WATER | ON_LAND); } } -- cgit v1.2.3