diff options
author | Torbjörn Andersson | 2004-03-29 06:37:46 +0000 |
---|---|---|
committer | Torbjörn Andersson | 2004-03-29 06:37:46 +0000 |
commit | bf10f5a616532efee386ba1a5a838736932adfa5 (patch) | |
tree | 6f5316fdd22e06c5a4534ae7a774579083700fcd | |
parent | 6cb86c641ff52220aebd21e322a029c996beb99d (diff) | |
download | scummvm-rg350-bf10f5a616532efee386ba1a5a838736932adfa5.tar.gz scummvm-rg350-bf10f5a616532efee386ba1a5a838736932adfa5.tar.bz2 scummvm-rg350-bf10f5a616532efee386ba1a5a838736932adfa5.zip |
Cleanup.
This removes a bunch of debugging code/commands that either didn't do
anything useful under ScummVM (e.g. "soft" and "hard"), or which did things
that was already easily avaiable elsewhere (e.g. "save" and "restore").
I didn't have the heart to remove the "tony" command, though. :-)
svn-id: r13422
-rw-r--r-- | sword2/console.cpp | 215 | ||||
-rw-r--r-- | sword2/console.h | 7 | ||||
-rw-r--r-- | sword2/events.cpp | 118 | ||||
-rw-r--r-- | sword2/interpreter.cpp | 4 | ||||
-rw-r--r-- | sword2/logic.h | 23 | ||||
-rw-r--r-- | sword2/sword2.cpp | 8 | ||||
-rw-r--r-- | sword2/sword2.h | 1 |
7 files changed, 72 insertions, 304 deletions
diff --git a/sword2/console.cpp b/sword2/console.cpp index a9497ae361..d6ece7c1ac 100644 --- a/sword2/console.cpp +++ b/sword2/console.cpp @@ -93,23 +93,15 @@ Debugger::Debugger(Sword2Engine *vm) DCmd_Register("debugon", &Debugger::Cmd_DebugOn); DCmd_Register("debugoff", &Debugger::Cmd_DebugOn); DCmd_Register("saverest", &Debugger::Cmd_SaveRest); - DCmd_Register("saves", &Debugger::Cmd_ListSaveGames); - DCmd_Register("save", &Debugger::Cmd_SaveGame); - DCmd_Register("restore", &Debugger::Cmd_RestoreGame); - DCmd_Register("bltfxon", &Debugger::Cmd_BltFxOn); - DCmd_Register("bltfxoff", &Debugger::Cmd_BltFxOff); DCmd_Register("timeon", &Debugger::Cmd_TimeOn); DCmd_Register("timeoff", &Debugger::Cmd_TimeOff); DCmd_Register("text", &Debugger::Cmd_Text); DCmd_Register("showvar", &Debugger::Cmd_ShowVar); DCmd_Register("hidevar", &Debugger::Cmd_HideVar); DCmd_Register("version", &Debugger::Cmd_Version); - DCmd_Register("soft", &Debugger::Cmd_SoftHard); - DCmd_Register("hard", &Debugger::Cmd_SoftHard); DCmd_Register("animtest", &Debugger::Cmd_AnimTest); DCmd_Register("texttest", &Debugger::Cmd_TextTest); DCmd_Register("linetest", &Debugger::Cmd_LineTest); - DCmd_Register("grab", &Debugger::Cmd_Grab); DCmd_Register("events", &Debugger::Cmd_Events); DCmd_Register("sfx", &Debugger::Cmd_Sfx); DCmd_Register("english", &Debugger::Cmd_English); @@ -150,10 +142,7 @@ void Debugger::postEnter() { } } -/////////////////////////////////////////////////// -// Now the fun stuff: - -// Commands +// Now the fun stuff: Commands bool Debugger::Cmd_Exit(int argc, const char **argv) { _detach_now = true; @@ -161,15 +150,15 @@ bool Debugger::Cmd_Exit(int argc, const char **argv) { } bool Debugger::Cmd_Help(int argc, const char **argv) { - // console normally has 39 line width + // console normally has 78 line width // wrap around nicely - int width = 0, size, i; + int width = 0; DebugPrintf("Commands are:\n"); - for (i = 0 ; i < _dcmd_count ; i++) { - size = strlen(_dcmds[i].name) + 1; + for (int i = 0 ; i < _dcmd_count ; i++) { + int size = strlen(_dcmds[i].name) + 1; - if ((width + size) >= 39) { + if (width + size >= 75) { DebugPrintf("\n"); width = size; } else @@ -355,117 +344,6 @@ bool Debugger::Cmd_SaveRest(int argc, const char **argv) { return true; } -bool Debugger::Cmd_ListSaveGames(int argc, const char **argv) { - DebugPrintf("Savegames:\n"); - - for (int i = 0; i < 100; i++) { - uint8 description[SAVE_DESCRIPTION_LEN]; - - // if there is a save game print the name - if (_vm->getSaveDescription(i, description) == SR_OK) - DebugPrintf("%d: \"%s\"\n", i, description); - } - - return true; -} - -bool Debugger::Cmd_SaveGame(int argc, const char **argv) { - char description[SAVE_DESCRIPTION_LEN]; - int len = 0; - uint16 slotNo; - uint32 rv; - - if (argc < 3) { - DebugPrintf("Usage: %s slot description\n", argv[0]); - return true; - } - - // if mouse if off, or system menu is locked off - if (_vm->_mouseStatus || _vm->_mouseModeLocked) { - DebugPrintf("WARNING: Cannot save game while control menu unavailable!\n"); - return true; - } - - description[0] = 0; - - // FIXME: Strange things seem to happen if use too long savegame names, - // even when they're shorter than the maximum allowed length - - for (int i = 2; i < argc; i++) { - if (len + strlen(argv[i]) + 1 > SAVE_DESCRIPTION_LEN) - break; - - if (i == 2) { - strcpy(description, argv[i]); - len = strlen(argv[i]); - } else { - strcat(description, " "); - strcat(description, argv[i]); - len += (strlen(argv[i]) + 1); - } - } - - slotNo = atoi(argv[1]); - rv = _vm->saveGame(slotNo, (uint8 *) description); - - if (rv == SR_OK) - DebugPrintf("Saved game \"%s\" to file \"savegame.%.3d\"\n", description, slotNo); - else if (rv == SR_ERR_FILEOPEN) - DebugPrintf("ERROR: Cannot open file \"savegame.%.3d\"\n", slotNo); - else // SR_ERR_WRITEFAIL - DebugPrintf("ERROR: Write error on file \"savegame.%.3d\"\n", slotNo); - - return true; -} - -bool Debugger::Cmd_RestoreGame(int argc, const char **argv) { - uint16 slotNo; - uint8 description[SAVE_DESCRIPTION_LEN]; - uint32 rv; - - if (argc != 2) { - DebugPrintf("Usage: %s slot\n", argv[0]); - return true; - } - - // if mouse if off, or system menu is locked off - if (_vm->_mouseStatus || _vm->_mouseModeLocked) { - DebugPrintf("WARNING: Cannot restore game while control menu unavailable!\n"); - return true; - } - - slotNo = atoi(argv[1]); - rv = _vm->restoreGame(slotNo); - - if (rv == SR_OK) { - _vm->getSaveDescription(slotNo, description); - DebugPrintf("Restored game \"%s\" from file \"savegame.%.3d\"\n", description, slotNo); - } else if (rv == SR_ERR_FILEOPEN) - DebugPrintf("ERROR: Cannot open file \"savegame.%.3d\"\n", slotNo); - else if (rv == SR_ERR_INCOMPATIBLE) - DebugPrintf("ERROR: \"savegame.%.3d\" is no longer compatible with current player/variable resources\n", slotNo); - else // SR_ERR_READFAIL - DebugPrintf("ERROR: Read error on file \"savegame.%.3d\"\n", slotNo); - - return true; -} - -// FIXME: Replace these with a command to modify the graphics detail setting - -bool Debugger::Cmd_BltFxOn(int argc, const char **argv) { - // _vm->_graphics->setBltFx(); - // DebugPrintf("Blit fx enabled\n"); - DebugPrintf("FIXME: The setBltFx() function no longer exists\n"); - return true; -} - -bool Debugger::Cmd_BltFxOff(int argc, const char **argv) { - // _vm->_graphics->clearBltFx(); - // DebugPrintf("Blit fx disabled\n"); - DebugPrintf("FIXME: The clearBltFx() function no longer exists\n"); - return true; -} - bool Debugger::Cmd_TimeOn(int argc, const char **argv) { if (argc == 2) _startTime = _vm->_system->get_msecs() - atoi(argv[1]) * 1000; @@ -550,59 +428,10 @@ bool Debugger::Cmd_HideVar(int argc, const char **argv) { } bool Debugger::Cmd_Version(int argc, const char **argv) { - - // The version string is incomplete, so we may as well remove the code - // to extract information from it. - -#if 0 - - #define HEAD_LEN 8 - - // version & owner details - - // So version string is 18 bytes long : - // Version String = <8 byte header,5 character version, \0, INT32 time> - uint8 version_string[HEAD_LEN + 10] = { 1, 255, 37, 22, 45, 128, 34, 67 }; - uint8 unencoded_name[HEAD_LEN + 48] = { - 76, 185, 205, 23, 44, 34, 24, 34, - 'R','e','v','o','l','u','t','i','o','n',' ', - 'S','o','f','t','w','a','r','e',' ','L','t','d', - 0 }; - - struct tm *time; - time_t t; - char dateStamp[255]; - char version[6]; - - strcpy(version, (char *) version_string + HEAD_LEN); - *(((unsigned char *) &t)) = *(version_string + 14); - *(((unsigned char *) &t) + 1) = *(version_string + 15); - *(((unsigned char *) &t) + 2) = *(version_string + 16); - *(((unsigned char *) &t) + 3) = *(version_string + 17); - - time = localtime(&t); - sprintf(dateStamp, "%s", asctime(time)); - dateStamp[24] = 0; // fudge over the newline character! -#endif + // This function used to print more information, but nothing we + // particularly care about. DebugPrintf("\"Broken Sword II\" (c) Revolution Software 1997.\n"); - -#if 0 - DebugPrintf("v%s created on %s for %s\n", version, dateStamp, unencoded_name + HEAD_LEN); -#endif - -#if 0 - // THE FOLLOWING LINES ARE TO BE COMMENTED OUT OF THE FINAL VERSION - DebugPrintf("This program has a personalised fingerprint encrypted into the code.\n"); - DebugPrintf("If this CD was not sent directly to you by Virgin Interactive or Revolution Software\n"); - DebugPrintf("then please contact James Long at Revolution on (+44) 1904 639698.\n"); -#endif - - return true; -} - -bool Debugger::Cmd_SoftHard(int argc, const char **argv) { - DebugPrintf("ScummVM doesn't distinguish between software and hardware rendering.\n"); return true; } @@ -664,34 +493,8 @@ bool Debugger::Cmd_LineTest(int argc, const char **argv) { return true; } -bool Debugger::Cmd_Grab(int argc, const char **argv) { - DebugPrintf("FIXME: Continuous screen-grabbing not implemented\n"); - -#if 0 - _vm->_grabbingSequences = !_vm->_grabbingSequences; - - if (_vm->_grabbingSequences) - DebugPrintf("PCX-grabbing enabled\n"); - else - DebugPrintf("PCX-grabbing disabled\n"); -#endif - - return true; -} - bool Debugger::Cmd_Events(int argc, const char **argv) { - DebugPrintf("EVENT LIST:\n"); - - for (uint32 i = 0; i < MAX_events; i++) { - if (_vm->_logic->_eventList[i].id) { - uint32 target = _vm->_logic->_eventList[i].id; - uint32 script = _vm->_logic->_eventList[i].interact_id; - - DebugPrintf("slot %d: id = %s (%d)\n", i, _vm->fetchObjectName(target), target); - DebugPrintf(" script = %s (%d) pos %d\n", _vm->fetchObjectName(script / 65536), script / 65536, script % 65536); - } - } - + _vm->_logic->printEventList(); return true; } diff --git a/sword2/console.h b/sword2/console.h index 10dd542559..f25645dd49 100644 --- a/sword2/console.h +++ b/sword2/console.h @@ -102,22 +102,15 @@ protected: bool Cmd_DebugOn(int argc, const char **argv); bool Cmd_DebugOff(int argc, const char **argv); bool Cmd_SaveRest(int argc, const char **argv); - bool Cmd_ListSaveGames(int argc, const char **argv); - bool Cmd_SaveGame(int argc, const char **argv); - bool Cmd_RestoreGame(int argc, const char **argv); - bool Cmd_BltFxOn(int argc, const char **argv); - bool Cmd_BltFxOff(int argc, const char **argv); bool Cmd_TimeOn(int argc, const char **argv); bool Cmd_TimeOff(int argc, const char **argv); bool Cmd_Text(int argc, const char **argv); bool Cmd_ShowVar(int argc, const char **argv); bool Cmd_HideVar(int argc, const char **argv); bool Cmd_Version(int argc, const char **argv); - bool Cmd_SoftHard(int argc, const char **argv); bool Cmd_AnimTest(int argc, const char **argv); bool Cmd_TextTest(int argc, const char **argv); bool Cmd_LineTest(int argc, const char **argv); - bool Cmd_Grab(int argc, const char **argv); bool Cmd_Events(int argc, const char **argv); bool Cmd_Sfx(int argc, const char **argv); bool Cmd_English(int argc, const char **argv); diff --git a/sword2/events.cpp b/sword2/events.cpp index e704897ac6..683c3cdcec 100644 --- a/sword2/events.cpp +++ b/sword2/events.cpp @@ -20,43 +20,25 @@ #include "common/stdafx.h" #include "sword2/sword2.h" #include "sword2/defs.h" +#include "sword2/console.h" #include "sword2/interpreter.h" #include "sword2/logic.h" #include "sword2/resman.h" -namespace Sword2 { - -uint32 Logic::countEvents(void) { - uint32 count = 0; +#define Debug_Printf _vm->_debugger->DebugPrintf - for (int i = 0; i < MAX_events; i++) { - if (_eventList[i].id) - count++; - } - - return count; -} +namespace Sword2 { void Logic::sendEvent(uint32 id, uint32 interact_id) { - int i; - - for (i = 0; i < MAX_events; i++) { - if (_eventList[i].id == id) - break; - - if (!_eventList[i].id) - break; + for (int i = 0; i < MAX_events; i++) { + if (_eventList[i].id == id || !_eventList[i].id) { + _eventList[i].id = id; + _eventList[i].interact_id = interact_id; + return; + } } - assert(i < MAX_events); - - // found that slot - - // id of person to stop - _eventList[i].id = id; - - // full script id - _eventList[i].interact_id = interact_id; + error("sendEvent() ran out of event slots"); } void Logic::setPlayerActionEvent(uint32 id, uint32 interact_id) { @@ -64,13 +46,13 @@ void Logic::setPlayerActionEvent(uint32 id, uint32 interact_id) { sendEvent(id, (interact_id << 16) | 2); } -bool Logic::checkEventWaiting(void) { +int Logic::checkEventWaiting(void) { for (int i = 0; i < MAX_events; i++) { if (_eventList[i].id == _scriptVars[ID]) - return true; + return 1; } - return false; + return 0; } void Logic::startEvent(void) { @@ -79,23 +61,18 @@ void Logic::startEvent(void) { for (int i = 0; i < MAX_events; i++) { if (_eventList[i].id == _scriptVars[ID]) { - // run 3rd script of target object on level 1 logicOne(_eventList[i].interact_id); - - // clear the slot _eventList[i].id = 0; return; } } - // oh dear - stop the system - error("Start_event can't find event for id %d", _scriptVars[ID]); + error("startEvent() can't find event for id %d", _scriptVars[ID]); } void Logic::clearEvent(uint32 id) { for (int i = 0; i < MAX_events; i++) { if (_eventList[i].id == id) { - // clear the slot _eventList[i].id = 0; return; } @@ -104,10 +81,8 @@ void Logic::clearEvent(uint32 id) { void Logic::killAllIdsEvents(uint32 id) { for (int i = 0; i < MAX_events; i++) { - if (_eventList[i].id == id) { - // clear the slot + if (_eventList[i].id == id) _eventList[i].id = 0; - } } } @@ -149,15 +124,9 @@ int32 Logic::fnSendEvent(int32 *params) { } int32 Logic::fnCheckEventWaiting(int32 *params) { - // returns yes/no in _scriptVars[RESULT] - // params: none - if (checkEventWaiting()) - _scriptVars[RESULT] = 1; - else - _scriptVars[RESULT] = 0; - + _scriptVars[RESULT] = checkEventWaiting(); return IR_CONT; } @@ -167,53 +136,41 @@ int32 Logic::fnCheckEventWaiting(int32 *params) { int32 Logic::fnCheckForEvent(int32 *params) { // params: none - if (!checkEventWaiting()) - return IR_CONT; + if (checkEventWaiting()) { + startEvent(); + return IR_TERMINATE; + } - startEvent(); - return IR_TERMINATE; + return IR_CONT; } // combination of fnPause and fnCheckForEvent // - ie. does a pause, but also checks for event each cycle int32 Logic::fnPauseForEvent(int32 *params) { - // returns yes/no in RESULT - // params: 0 pointer to object's logic structure // 1 number of game-cycles to pause ObjectLogic *ob_logic = (ObjectLogic *) _vm->_memory->intToPtr(params[0]); - // first, check for an event - if (checkEventWaiting()) { - // reset the 'looping' flag ob_logic->looping = 0; - - // start the event - run 3rd script of target object on level 1 startEvent(); return IR_TERMINATE; } - // no event, so do the fnPause bit - - // start the pause if (ob_logic->looping == 0) { ob_logic->looping = 1; ob_logic->pause = params[1]; } - // if non-zero if (ob_logic->pause) { - // decrement the pause count ob_logic->pause--; return IR_REPEAT; - } else { - // pause count is zero - ob_logic->looping = 0; - return IR_CONT; } + + ob_logic->looping = 0; + return IR_CONT; } int32 Logic::fnClearEvent(int32 *params) { @@ -230,4 +187,31 @@ int32 Logic::fnStartEvent(int32 *params) { return IR_TERMINATE; } +// For the debugger + +uint32 Logic::countEvents(void) { + uint32 count = 0; + + for (int i = 0; i < MAX_events; i++) { + if (_eventList[i].id) + count++; + } + + return count; +} + +void Logic::printEventList(void) { + Debug_Printf("EVENT LIST:\n"); + + for (uint32 i = 0; i < MAX_events; i++) { + if (_eventList[i].id) { + uint32 target = _eventList[i].id; + uint32 script = _eventList[i].interact_id; + + Debug_Printf("slot %2d: id = %s (%d)\n", i, _vm->fetchObjectName(target), target); + Debug_Printf(" script = %s (%d) pos %d\n", _vm->fetchObjectName(script / 65536), script / 65536, script % 65536); + } + } +} + } // End of namespace Sword2 diff --git a/sword2/interpreter.cpp b/sword2/interpreter.cpp index b12692e03c..151034a5ad 100644 --- a/sword2/interpreter.cpp +++ b/sword2/interpreter.cpp @@ -609,11 +609,9 @@ int Logic::runScript(char *scriptData, char *objectData, uint32 *offset) { case CP_DEBUGON: // Turn debugging on - _debugFlag = true; break; case CP_DEBUGOFF: - // Turn debugging on - _debugFlag = false; + // Turn debugging off break; case CP_TEMP_TEXT_PROCESS: // Process a text line diff --git a/sword2/logic.h b/sword2/logic.h index cae30e379f..67c860c911 100644 --- a/sword2/logic.h +++ b/sword2/logic.h @@ -53,9 +53,6 @@ private: // keeps note of no. of objects in the kill list uint32 _kills; - // Set this to turn debugging on - bool _debugFlag; - // denotes the res id of the game-object-list in current use uint32 _currentRunList; @@ -67,6 +64,13 @@ private: void processKillList(void); + struct EventUnit { + uint32 id; + uint32 interact_id; + }; + + EventUnit _eventList[MAX_events]; + // Stores resource id of the wav to use as lead-out from smacker uint32 _smackerLeadOut; @@ -160,7 +164,7 @@ private: public: Logic(Sword2Engine *vm) : - _vm(vm), _kills(0), _debugFlag(false), _smackerLeadOut(0), + _vm(vm), _kills(0), _smackerLeadOut(0), _sequenceTextLines(0), _speechTime(0), _animId(0), _speechAnimType(0), _leftClickDelay(0), _rightClickDelay(0), _defaultResponseId(0), _totalStartups(0), @@ -209,17 +213,10 @@ public: int runScript(char *scriptData, char *objectData, uint32 *offset); - struct EventUnit { - uint32 id; - uint32 interact_id; - }; - - EventUnit _eventList[MAX_events]; - void sendEvent(uint32 id, uint32 interact_id); void setPlayerActionEvent(uint32 id, uint32 interact_id); void startEvent(void); - bool checkEventWaiting(void); + int checkEventWaiting(void); void clearEvent(uint32 id); void killAllIdsEvents(uint32 id); @@ -374,6 +371,8 @@ public: void totalRestart(void); void examineRunList(void); void resetKillList(void); + + void printEventList(void); }; } // End of namespace Sword2 diff --git a/sword2/sword2.cpp b/sword2/sword2.cpp index b52c8983ae..a0407af4fb 100644 --- a/sword2/sword2.cpp +++ b/sword2/sword2.cpp @@ -153,7 +153,6 @@ Sword2Engine::Sword2Engine(GameDetector *detector, OSystem *syst) _frameCount = 0; _wantSfxDebug = false; - _grabbingSequences = false; // For the menus @@ -345,13 +344,6 @@ void Sword2Engine::go() { if (_debugger->isAttached()) _debugger->onFrame(); -#ifdef _SWORD2_DEBUG -// FIXME: If we want this, we should re-work it to use the backend's -// screenshot functionality. -// if (_debugger->_grabbingSequences && !console_status) -// GrabScreenShot(); -#endif - // the screen is build. Mostly because of first scroll // cycle stuff diff --git a/sword2/sword2.h b/sword2/sword2.h index 3f0145a533..c71f351f8f 100644 --- a/sword2/sword2.h +++ b/sword2/sword2.h @@ -187,7 +187,6 @@ public: uint32 _frameCount; bool _wantSfxDebug; - bool _grabbingSequences; int32 _gameCycle; bool _renderSkip; |