From c64c7eb4d4edd087031603df446abf271f616480 Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Fri, 3 Dec 2004 19:15:44 +0000 Subject: First pass at migrating from the old Reinherit console to the ScummVM console. Some things are likely to have broken. For instance, I believe the old console was could be visible during gameplay, while ScummVM's is modal. So any place where we output something to the console during gameplay should probably be removed. Some things I've stubbed out. Basically any code that registers a variable. Most of the debugging commands are untested. Syntax may have changed because of different command-line parsing. (I never actually used the old console, so I don't know for sure. :-) Actually, I'm not that interested in reproducing the old console commands faithfully. What we should do now is to make the immediately useful console stuff work. Anything that remains unimplemented should probably be removed. svn-id: r15976 --- saga/actionmap.cpp | 5 +- saga/actor.cpp | 108 +++------- saga/actor.h | 8 +- saga/animation.cpp | 21 +- saga/animation.h | 4 +- saga/console.cpp | 525 ++++++++++++++---------------------------------- saga/console.h | 92 +++------ saga/cvar.cpp | 483 -------------------------------------------- saga/cvar.h | 85 -------- saga/cvar_mod.h | 88 -------- saga/events.cpp | 14 +- saga/expr.cpp | 390 ----------------------------------- saga/expr.h | 37 ---- saga/game.cpp | 20 -- saga/ihnm_introproc.cpp | 1 - saga/input.cpp | 67 ++---- saga/interface.cpp | 3 +- saga/ite_introproc.cpp | 3 +- saga/module.mk | 2 - saga/objectmap.cpp | 7 +- saga/render.cpp | 9 - saga/render.h | 1 - saga/saga.cpp | 47 +---- saga/scene.cpp | 83 +++----- saga/scene.h | 8 +- saga/script.cpp | 45 +---- saga/script.h | 7 +- saga/sfuncs.cpp | 20 +- saga/sthread.cpp | 14 +- 29 files changed, 313 insertions(+), 1884 deletions(-) delete mode 100644 saga/cvar.cpp delete mode 100644 saga/cvar.h delete mode 100644 saga/cvar_mod.h delete mode 100644 saga/expr.cpp delete mode 100644 saga/expr.h (limited to 'saga') diff --git a/saga/actionmap.cpp b/saga/actionmap.cpp index c5b4e945eb..e6d467dce9 100644 --- a/saga/actionmap.cpp +++ b/saga/actionmap.cpp @@ -24,7 +24,6 @@ /* Action map module */ #include "saga/saga.h" -#include "saga/cvar_mod.h" #include "saga/gfx.h" #include "saga/console.h" @@ -182,10 +181,10 @@ int ActionMap::draw(SURFACE *ds, int color) { } void ActionMap::info(void) { - _vm->_console->print("%d exits loaded.\n", _nExits); + _vm->_console->DebugPrintf("%d exits loaded.\n\n", _nExits); for (int i = 0; i < _nExits; i++) { - _vm->_console->print ("Action %d: Exit to: %d", i, _exitsTbl[i].exitScene); + _vm->_console->DebugPrintf("Action %d: Exit to: %d\n", i, _exitsTbl[i].exitScene); } } diff --git a/saga/actor.cpp b/saga/actor.cpp index f1337a1cb6..4e1d9e2d63 100644 --- a/saga/actor.cpp +++ b/saga/actor.cpp @@ -26,7 +26,6 @@ #include "saga/gfx.h" #include "saga/game_mod.h" -#include "saga/cvar_mod.h" #include "saga/console.h" #include "saga/rscfile_mod.h" #include "saga/script.h" @@ -44,12 +43,6 @@ namespace Saga { static int zCompare(const void *elem1, const void *elem2); -static void CF_actor_add(int argc, char *argv[], void *refCon); -static void CF_actor_del(int argc, char *argv[], void *refCon); -static void CF_actor_move(int argc, char *argv[], void *refCon); -static void CF_actor_moverel(int argc, char *argv[], void *refCon); -static void CF_actor_seto(int argc, char *argv[], void *refCon); -static void CF_actor_setact(int argc, char *argv[], void *refCon); ACTIONTIMES ActionTDeltas[] = { { ACTION_IDLE, 80 }, @@ -57,17 +50,6 @@ ACTIONTIMES ActionTDeltas[] = { { ACTION_SPEAK, 200 } }; -int Actor::reg() { - CVAR_RegisterFunc(CF_actor_add, "actor_add", " ", CVAR_NONE, 3, 3, this); - CVAR_RegisterFunc(CF_actor_del, "actor_del", "", CVAR_NONE, 1, 1, this); - CVAR_RegisterFunc(CF_actor_move, "actor_move", " ", CVAR_NONE, 3, 3, this); - CVAR_RegisterFunc(CF_actor_moverel, "actor_moverel", " ", CVAR_NONE, 3, 3, this); - CVAR_RegisterFunc(CF_actor_seto, "actor_seto", " ", CVAR_NONE, 2, 2, this); - CVAR_RegisterFunc(CF_actor_setact, "actor_setact", " ", CVAR_NONE, 2, 2, this); - - return SUCCESS; -} - Actor::Actor(SagaEngine *vm) : _vm(vm), _initialized(false) { int i; @@ -1028,116 +1010,86 @@ int Actor::StoA(Point *actor, const Point screen) { return SUCCESS; } -static void CF_actor_add(int argc, char *argv[], void *refCon) { +void Actor::CF_actor_add(int argc, const char **argv) { ACTOR actor; - if (argc < 3) - return; - - actor.id = (uint16) atoi(argv[0]); + actor.id = (uint16) atoi(argv[1]); - actor.a_pt.x = atoi(argv[1]); - actor.a_pt.y = atoi(argv[2]); + actor.a_pt.x = atoi(argv[2]); + actor.a_pt.y = atoi(argv[3]); - ((Actor *)refCon)->addActor(&actor); - - return; + addActor(&actor); } -static void CF_actor_del(int argc, char *argv[], void *refCon) { +void Actor::CF_actor_del(int argc, const char **argv) { int id; - if (argc < 0) - return; - - id = atoi(argv[0]); + id = atoi(argv[1]); - ((Actor *)refCon)->deleteActor(id); - - return; + deleteActor(id); } -static void CF_actor_move(int argc, char *argv[], void *refCon) { +void Actor::CF_actor_move(int argc, const char **argv) { int id; Point move_pt; - if (argc < 2) - return; - - id = atoi(argv[0]); + id = atoi(argv[1]); - move_pt.x = atoi(argv[1]); - move_pt.y = atoi(argv[2]); + move_pt.x = atoi(argv[2]); + move_pt.y = atoi(argv[3]); - ((Actor *)refCon)->move(id, &move_pt); - - return; + move(id, &move_pt); } -static void CF_actor_moverel(int argc, char *argv[], void *refCon) { +void Actor::CF_actor_moverel(int argc, const char **argv) { int id; Point move_pt; - if (argc < 3) - return; - - id = atoi(argv[0]); + id = atoi(argv[1]); - move_pt.x = atoi(argv[1]); - move_pt.y = atoi(argv[2]); + move_pt.x = atoi(argv[2]); + move_pt.y = atoi(argv[3]); - ((Actor *)refCon)->moveRelative(id, &move_pt); - - return; + moveRelative(id, &move_pt); } -static void CF_actor_seto(int argc, char *argv[], void *refCon) { +void Actor::CF_actor_seto(int argc, const char **argv) { int id; int orient; - if (argc < 2) - return; - - id = atoi(argv[0]); - orient = atoi(argv[1]); + id = atoi(argv[1]); + orient = atoi(argv[2]); - ((Actor *)refCon)->setOrientation(id, orient); - - return; + setOrientation(id, orient); } -static void CF_actor_setact(int argc, char *argv[], void *refCon) { +void Actor::CF_actor_setact(int argc, const char **argv) { int index = 0; int action_n = 0; ACTOR *actor; - if (argc < 2) - return; - - index = atoi(argv[0]); - action_n = atoi(argv[1]); + index = atoi(argv[1]); + action_n = atoi(argv[2]); - actor = ((Actor *)refCon)->lookupActor(index); + actor = lookupActor(index); if (actor == NULL) { - _vm->_console->print("Invalid actor index."); - + _vm->_console->DebugPrintf("Invalid actor index.\n"); return; } if ((action_n < 0) || (action_n >= actor->action_ct)) { - _vm->_console->print("Invalid action number."); - + _vm->_console->DebugPrintf("Invalid action number.\n"); return; } - _vm->_console->print("Action frame counts: %d %d %d %d.", + _vm->_console->DebugPrintf("Action frame counts: %d %d %d %d.\n", actor->act_tbl[action_n].dir[0].frame_count, actor->act_tbl[action_n].dir[1].frame_count, actor->act_tbl[action_n].dir[2].frame_count, actor->act_tbl[action_n].dir[3].frame_count); - ((Actor *)refCon)->setAction(index, action_n, ACTION_LOOP); + setAction(index, action_n, ACTION_LOOP); } } // End of namespace Saga diff --git a/saga/actor.h b/saga/actor.h index 6a24646603..a1a6b7cafc 100644 --- a/saga/actor.h +++ b/saga/actor.h @@ -186,10 +186,16 @@ struct ACTIONTIMES { class Actor { public: - int reg(); Actor(SagaEngine *vm); ~Actor(); + void CF_actor_add(int argc, const char **argv); + void CF_actor_del(int argc, const char **argv); + void CF_actor_move(int argc, const char **argv); + void CF_actor_moverel(int argc, const char **argv); + void CF_actor_seto(int argc, const char **argv); + void CF_actor_setact(int argc, const char **argv); + int direct(int msec); int create(int actor_id, int x, int y); diff --git a/saga/animation.cpp b/saga/animation.cpp index 7dde34908b..7768ad2294 100644 --- a/saga/animation.cpp +++ b/saga/animation.cpp @@ -25,7 +25,6 @@ #include "saga/saga.h" #include "saga/gfx.h" -#include "saga/cvar_mod.h" #include "saga/console.h" #include "saga/game_mod.h" #include "saga/events.h" @@ -35,13 +34,6 @@ namespace Saga { -static void CF_anim_info(int argc, char *argv[], void *refCon); - -int Anim::reg() { - CVAR_RegisterFunc(CF_anim_info, "anim_info", NULL, CVAR_NONE, 0, 0, this); - return SUCCESS; -} - Anim::Anim(SagaEngine *vm) : _vm(vm) { int i; @@ -915,29 +907,22 @@ int Anim::getFrameOffset(const byte *resdata, size_t resdata_len, uint16 find_fr return SUCCESS; } -void Anim::animInfo(int argc, char *argv[]) { +void Anim::animInfo() { uint16 anim_ct; uint16 i; uint16 idx; - (void)(argc); - (void)(argv); - anim_ct = _anim_count; - _vm->_console->print("There are %d animations loaded:", anim_ct); + _vm->_console->DebugPrintf("There are %d animations loaded:\n", anim_ct); for (idx = 0, i = 0; i < anim_ct; idx++, i++) { while (_anim_tbl[idx] == NULL) { idx++; } - _vm->_console->print("%02d: Frames: %u Flags: %u", i, _anim_tbl[idx]->n_frames, _anim_tbl[idx]->flags); + _vm->_console->DebugPrintf("%02d: Frames: %u Flags: %u\n", i, _anim_tbl[idx]->n_frames, _anim_tbl[idx]->flags); } } -static void CF_anim_info(int argc, char *argv[], void *refCon) { - ((Anim *)refCon)->animInfo(argc, argv); -} - } // End of namespace Saga diff --git a/saga/animation.h b/saga/animation.h index d6a2627303..4f41d8c75a 100644 --- a/saga/animation.h +++ b/saga/animation.h @@ -94,9 +94,9 @@ enum ANIM_FLAGS { class Anim { public: - int reg(void); Anim(SagaEngine *vm); ~Anim(void); + int load(const byte *anim_resdata, size_t anim_resdata_len, uint16 *anim_id_p); int freeId(uint16 anim_id); int play(uint16 anim_id, int vector_time); @@ -105,7 +105,7 @@ public: int clearFlag(uint16 anim_id, uint16 flag); int setFrameTime(uint16 anim_id, int time); int reset(void); - void animInfo(int argc, char *argv[]); + void animInfo(void); private: int getNumFrames(const byte *anim_resource, size_t anim_resource_len, uint16 *n_frames); diff --git a/saga/console.cpp b/saga/console.cpp index a22e9aa1ea..d16ad84972 100644 --- a/saga/console.cpp +++ b/saga/console.cpp @@ -24,442 +24,211 @@ // Console module #include "saga/saga.h" -#include "saga/gfx.h" -#include "saga/font.h" -#include "saga/cvar_mod.h" -#include "saga/events.h" +#include "saga/actor.h" +#include "saga/animation.h" +#include "saga/scene.h" +#include "saga/script.h" #include "saga/console.h" -namespace Saga { - -int Console::reg() { - CVAR_Register_I(&_resize, "con_h", NULL, CVAR_NONE, 12, CON_DEFAULTPOS); - CVAR_Register_I(&_droptime, "con_droptime", NULL, CVAR_NONE, 0, 5000); - CVAR_Register_I(&_lineMax, "con_lines", NULL, CVAR_NONE, 5, 5000); - return SUCCESS; -} +#include "common/debugger.cpp" -Console::Console(SagaEngine *vm) : _vm(vm) { - memset(&_scrollback, 0, sizeof(_scrollback)); - memset(&_history, 0, sizeof(_history)); - - _resize = CON_DEFAULTPOS; - _droptime = CON_DROPTIME; - - _active = false; - _yMax = CON_DEFAULTPOS; - _lineMax = CON_DEFAULTLINES; - _histMax = CON_DEFAULTCMDS; - _histPos = 0; - _linePos = 0; - _yPos = 0; - _prompt = NULL; - _promptW = 0; - *_inputBuf = 0; - _inputPos = 0; -} +namespace Saga { -Console::~Console() { - debug(0, "~Console(): Deleting console scrollback and command history."); +Console::Console(SagaEngine *vm) : Common::Debugger() { + _vm = vm; - deleteScroll(&_scrollback); - deleteScroll(&_history); -} + DCmd_Register("continue", &Console::Cmd_Exit); + DCmd_Register("exit", &Console::Cmd_Exit); + DCmd_Register("quit", &Console::Cmd_Exit); + DCmd_Register("help", &Console::Cmd_Help); -int Console::activate() { - EVENT con_event; + // CVAR_Register_I(&_soundEnabled, "sound", NULL, CVAR_CFG, 0, 1); + // CVAR_Register_I(&_musicEnabled, "music", NULL, CVAR_CFG, 0, 1); - if (_active) { - return FAILURE; - } + // Actor commands + DCmd_Register("actor_add", &Console::Cmd_ActorAdd); + DCmd_Register("actor_del", &Console::Cmd_ActorDel); + DCmd_Register("actor_move", &Console::Cmd_ActorMove); + DCmd_Register("actor_moverel", &Console::Cmd_ActorMoveRel); + DCmd_Register("actor_seto", &Console::Cmd_ActorSetO); + DCmd_Register("actor_setact", &Console::Cmd_ActorSetAct); - con_event.type = CONTINUOUS_EVENT; - con_event.code = CONSOLE_EVENT | NODESTROY; - con_event.op = EVENT_ACTIVATE; - con_event.time = 0; - con_event.duration = _droptime; + // Animation commands + DCmd_Register("anim_info", &Console::Cmd_AnimInfo); - _vm->_events->queue(&con_event); + // Game stuff - _active = true; +#if 0 + // Register "g_language" cfg cvar + strncpy(GameModule.game_language, "us", MAXPATH); - return SUCCESS; -} + CVAR_Register_S(GameModule.game_language, "g_language", NULL, CVAR_CFG, GAME_LANGSTR_LIMIT); -int Console::deactivate() { - EVENT con_event; + // Register "g_skipintro" cfg cvar + CVAR_Register_I(&GameModule.g_skipintro, "g_skipintro", NULL, CVAR_CFG, 0, 1); +#endif - if (!_active) { - return FAILURE; - } + // Scene commands + DCmd_Register("scene_change", &Console::Cmd_SceneChange); + DCmd_Register("scene_info", &Console::Cmd_SceneInfo); + DCmd_Register("action_info", &Console::Cmd_ActionInfo); + DCmd_Register("object_info", &Console::Cmd_ObjectInfo); + // CVAR_Register_I(&_sceneNumber, "scene", NULL, CVAR_READONLY, 0, 0); - con_event.type = CONTINUOUS_EVENT; - con_event.code = CONSOLE_EVENT | NODESTROY; - con_event.op = EVENT_DEACTIVATE; - con_event.time = 0; - con_event.duration = _droptime; - - _vm->_events->queue(&con_event); - - return SUCCESS; + // Script commands + DCmd_Register("script_info", &Console::Cmd_ScriptInfo); + DCmd_Register("script_exec", &Console::Cmd_ScriptExec); + DCmd_Register("script_togglestep", &Console::Cmd_ScriptToggleStep); +// CVAR_RegisterFunc(CF_script_info, "script_info", NULL, CVAR_NONE, 0, 0, this); +// CVAR_RegisterFunc(CF_script_exec, "script_exec", "