diff options
Diffstat (limited to 'engines/sci/console.cpp')
-rw-r--r-- | engines/sci/console.cpp | 80 |
1 files changed, 38 insertions, 42 deletions
diff --git a/engines/sci/console.cpp b/engines/sci/console.cpp index 6d75e59916..8409ca0440 100644 --- a/engines/sci/console.cpp +++ b/engines/sci/console.cpp @@ -73,7 +73,7 @@ int g_debug_simulated_key = 0; bool g_debug_track_mouse_clicks = false; // Refer to the "addresses" command on how to pass address parameters -static int parse_reg_t(EngineState *s, const char *str, reg_t *dest, bool mayBeValue); +static int parse_reg_t(EngineState *s, const char *str, reg_t *dest); Console::Console(SciEngine *engine) : GUI::Debugger(), _engine(engine), _debugState(engine->_debugState) { @@ -1462,7 +1462,7 @@ bool Console::cmdAudioDump(int argc, const char **argv) { int numChannels = 1; int bytesPerSample = 1; bool sourceIs8Bit = true; - uint32 compressedSize; + uint32 compressedSize = 0; uint32 decompressedSize; if (isSol) { @@ -1719,19 +1719,18 @@ bool Console::cmdParse(int argc, const char **argv) { } char *error; - char string[1000]; + Common::String string = argv[1]; // Construct the string - strcpy(string, argv[1]); for (int i = 2; i < argc; i++) { - strcat(string, " "); - strcat(string, argv[i]); + string += " "; + string += argv[i]; } - debugPrintf("Parsing '%s'\n", string); + debugPrintf("Parsing '%s'\n", string.c_str()); ResultWordListList words; - bool res = _engine->getVocabulary()->tokenizeString(words, string, &error); + bool res = _engine->getVocabulary()->tokenizeString(words, string.c_str(), &error); if (res && !words.empty()) { int syntax_fail = 0; @@ -1773,15 +1772,14 @@ bool Console::cmdSaid(int argc, const char **argv) { } char *error; - char string[1000]; + Common::String string = argv[1]; byte spec[1000]; int p; // Construct the string - strcpy(string, argv[1]); for (p = 2; p < argc && strcmp(argv[p],"&") != 0; p++) { - strcat(string, " "); - strcat(string, argv[p]); + string += " "; + string += argv[p]; } if (p >= argc-1) { @@ -1841,12 +1839,12 @@ bool Console::cmdSaid(int argc, const char **argv) { } spec[len++] = 0xFF; - debugN("Matching '%s' against:", string); + debugN("Matching '%s' against:", string.c_str()); _engine->getVocabulary()->debugDecipherSaidBlock(SciSpan<const byte>(spec, len)); debugN("\n"); ResultWordListList words; - bool res = _engine->getVocabulary()->tokenizeString(words, string, &error); + bool res = _engine->getVocabulary()->tokenizeString(words, string.c_str(), &error); if (res && !words.empty()) { int syntax_fail = 0; @@ -2089,7 +2087,7 @@ bool Console::cmdPlaneItemList(int argc, const char **argv) { reg_t planeObject = NULL_REG; - if (parse_reg_t(_engine->_gamestate, argv[1], &planeObject, false)) { + if (parse_reg_t(_engine->_gamestate, argv[1], &planeObject)) { debugPrintf("Invalid address passed.\n"); debugPrintf("Check the \"addresses\" command on how to use addresses\n"); return true; @@ -2117,7 +2115,7 @@ bool Console::cmdVisiblePlaneItemList(int argc, const char **argv) { reg_t planeObject = NULL_REG; - if (parse_reg_t(_engine->_gamestate, argv[1], &planeObject, false)) { + if (parse_reg_t(_engine->_gamestate, argv[1], &planeObject)) { debugPrintf("Invalid address passed.\n"); debugPrintf("Check the \"addresses\" command on how to use addresses\n"); return true; @@ -2192,7 +2190,7 @@ bool Console::cmdShowSavedBits(int argc, const char **argv) { reg_t memoryHandle = NULL_REG; - if (parse_reg_t(_engine->_gamestate, argv[1], &memoryHandle, false)) { + if (parse_reg_t(_engine->_gamestate, argv[1], &memoryHandle)) { debugPrintf("Invalid address passed.\n"); debugPrintf("Check the \"addresses\" command on how to use addresses\n"); return true; @@ -2613,7 +2611,7 @@ bool Console::cmdSongInfo(int argc, const char **argv) { reg_t addr; - if (parse_reg_t(_engine->_gamestate, argv[1], &addr, false)) { + if (parse_reg_t(_engine->_gamestate, argv[1], &addr)) { debugPrintf("Invalid address passed.\n"); debugPrintf("Check the \"addresses\" command on how to use addresses\n"); return true; @@ -2656,7 +2654,7 @@ bool Console::cmdToggleSound(int argc, const char **argv) { reg_t id; - if (parse_reg_t(_engine->_gamestate, argv[1], &id, false)) { + if (parse_reg_t(_engine->_gamestate, argv[1], &id)) { debugPrintf("Invalid address passed.\n"); debugPrintf("Check the \"addresses\" command on how to use addresses\n"); return true; @@ -2748,7 +2746,7 @@ bool Console::cmdGCShowReachable(int argc, const char **argv) { reg_t addr; - if (parse_reg_t(_engine->_gamestate, argv[1], &addr, false)) { + if (parse_reg_t(_engine->_gamestate, argv[1], &addr)) { debugPrintf("Invalid address passed.\n"); debugPrintf("Check the \"addresses\" command on how to use addresses\n"); return true; @@ -2780,7 +2778,7 @@ bool Console::cmdGCShowFreeable(int argc, const char **argv) { reg_t addr; - if (parse_reg_t(_engine->_gamestate, argv[1], &addr, false)) { + if (parse_reg_t(_engine->_gamestate, argv[1], &addr)) { debugPrintf("Invalid address passed.\n"); debugPrintf("Check the \"addresses\" command on how to use addresses\n"); return true; @@ -2813,7 +2811,7 @@ bool Console::cmdGCNormalize(int argc, const char **argv) { reg_t addr; - if (parse_reg_t(_engine->_gamestate, argv[1], &addr, false)) { + if (parse_reg_t(_engine->_gamestate, argv[1], &addr)) { debugPrintf("Invalid address passed.\n"); debugPrintf("Check the \"addresses\" command on how to use addresses\n"); return true; @@ -2934,7 +2932,7 @@ bool Console::cmdVMVars(int argc, const char **argv) { printBasicVarInfo(*curValue); debugPrintf("\n"); } else { - if (parse_reg_t(s, setValue, curValue, true)) { + if (parse_reg_t(s, setValue, curValue)) { debugPrintf("Invalid value/address passed.\n"); debugPrintf("Check the \"addresses\" command on how to use addresses\n"); debugPrintf("Or pass a decimal or hexadecimal value directly (e.g. 12, 1Ah)\n"); @@ -2981,7 +2979,7 @@ bool Console::cmdValueType(int argc, const char **argv) { reg_t val; - if (parse_reg_t(_engine->_gamestate, argv[1], &val, false)) { + if (parse_reg_t(_engine->_gamestate, argv[1], &val)) { debugPrintf("Invalid address passed.\n"); debugPrintf("Check the \"addresses\" command on how to use addresses\n"); return true; @@ -3022,7 +3020,7 @@ bool Console::cmdViewListNode(int argc, const char **argv) { reg_t addr; - if (parse_reg_t(_engine->_gamestate, argv[1], &addr, false)) { + if (parse_reg_t(_engine->_gamestate, argv[1], &addr)) { debugPrintf("Invalid address passed.\n"); debugPrintf("Check the \"addresses\" command on how to use addresses\n"); return true; @@ -3045,14 +3043,14 @@ bool Console::cmdViewReference(int argc, const char **argv) { reg_t reg = NULL_REG; reg_t reg_end = NULL_REG; - if (parse_reg_t(_engine->_gamestate, argv[1], ®, false)) { + if (parse_reg_t(_engine->_gamestate, argv[1], ®)) { debugPrintf("Invalid address passed.\n"); debugPrintf("Check the \"addresses\" command on how to use addresses\n"); return true; } if (argc > 2) { - if (parse_reg_t(_engine->_gamestate, argv[2], ®_end, false)) { + if (parse_reg_t(_engine->_gamestate, argv[2], ®_end)) { debugPrintf("Invalid address passed.\n"); debugPrintf("Check the \"addresses\" command on how to use addresses\n"); return true; @@ -3076,14 +3074,14 @@ bool Console::cmdDumpReference(int argc, const char **argv) { reg_t reg = NULL_REG; reg_t reg_end = NULL_REG; - if (parse_reg_t(_engine->_gamestate, argv[1], ®, false)) { + if (parse_reg_t(_engine->_gamestate, argv[1], ®)) { debugPrintf("Invalid address passed.\n"); debugPrintf("Check the \"addresses\" command on how to use addresses\n"); return true; } if (argc > 2) { - if (parse_reg_t(_engine->_gamestate, argv[2], ®_end, false)) { + if (parse_reg_t(_engine->_gamestate, argv[2], ®_end)) { debugPrintf("Invalid address passed.\n"); debugPrintf("Check the \"addresses\" command on how to use addresses\n"); return true; @@ -3192,7 +3190,7 @@ bool Console::cmdViewObject(int argc, const char **argv) { reg_t addr; - if (parse_reg_t(_engine->_gamestate, argv[1], &addr, false)) { + if (parse_reg_t(_engine->_gamestate, argv[1], &addr)) { debugPrintf("Invalid address passed.\n"); debugPrintf("Check the \"addresses\" command on how to use addresses\n"); return true; @@ -3536,7 +3534,7 @@ bool Console::cmdDisassemble(int argc, const char **argv) { bool printBytecode = false; bool printBWTag = false; - if (parse_reg_t(_engine->_gamestate, argv[1], &objAddr, false)) { + if (parse_reg_t(_engine->_gamestate, argv[1], &objAddr)) { debugPrintf("Invalid address passed.\n"); debugPrintf("Check the \"addresses\" command on how to use addresses\n"); return true; @@ -3601,7 +3599,7 @@ bool Console::cmdDisassembleAddress(int argc, const char **argv) { bool printBytes = false; uint32 size; - if (parse_reg_t(_engine->_gamestate, argv[1], &vpc, false)) { + if (parse_reg_t(_engine->_gamestate, argv[1], &vpc)) { debugPrintf("Invalid address passed.\n"); debugPrintf("Check the \"addresses\" command on how to use addresses\n"); return true; @@ -3789,7 +3787,7 @@ bool Console::cmdSend(int argc, const char **argv) { reg_t object; - if (parse_reg_t(_engine->_gamestate, argv[1], &object, false)) { + if (parse_reg_t(_engine->_gamestate, argv[1], &object)) { debugPrintf("Invalid address \"%s\" passed.\n", argv[1]); debugPrintf("Check the \"addresses\" command on how to use addresses\n"); return true; @@ -3825,7 +3823,7 @@ bool Console::cmdSend(int argc, const char **argv) { stackframe[0] = make_reg(0, selectorId); stackframe[1] = make_reg(0, send_argc); for (int i = 0; i < send_argc; i++) { - if (parse_reg_t(_engine->_gamestate, argv[3+i], &stackframe[2+i], false)) { + if (parse_reg_t(_engine->_gamestate, argv[3+i], &stackframe[2+i])) { debugPrintf("Invalid address \"%s\" passed.\n", argv[3+i]); debugPrintf("Check the \"addresses\" command on how to use addresses\n"); return true; @@ -4271,7 +4269,7 @@ bool Console::cmdBreakpointAddress(int argc, const char **argv) { reg_t addr; - if (parse_reg_t(_engine->_gamestate, argv[1], &addr, false)) { + if (parse_reg_t(_engine->_gamestate, argv[1], &addr)) { debugPrintf("Invalid address passed.\n"); debugPrintf("Check the \"addresses\" command on how to use addresses\n"); return true; @@ -4495,7 +4493,7 @@ bool Console::cmdMapVocab994(int argc, const char **argv) { return true; } - if (parse_reg_t(_engine->_gamestate, argv[1], ®, false)) { + if (parse_reg_t(_engine->_gamestate, argv[1], ®)) { debugPrintf("Invalid address passed.\n"); debugPrintf("Check the \"addresses\" command on how to use addresses\n"); return true; @@ -4577,7 +4575,7 @@ bool Console::cmdAddresses(int argc, const char **argv) { } // Returns 0 on success -static int parse_reg_t(EngineState *s, const char *str, reg_t *dest, bool mayBeValue) { +static int parse_reg_t(EngineState *s, const char *str, reg_t *dest) { // Pointer to the part of str which contains a numeric offset (if any) const char *offsetStr = NULL; @@ -4595,7 +4593,7 @@ static int parse_reg_t(EngineState *s, const char *str, reg_t *dest, bool mayBeV *dest = s->_executionStack.back().addr.pc; offsetStr = str + 3; } else if (!scumm_strnicmp(str + 1, "P", 1)) { - *dest = s->_executionStack.back().addr.pc;; + *dest = s->_executionStack.back().addr.pc; offsetStr = str + 2; } else if (!scumm_strnicmp(str + 1, "PREV", 4)) { *dest = s->r_prev; @@ -5006,14 +5004,12 @@ void Console::printReference(reg_t reg, reg_t reg_end) { case SIG_TYPE_REFERENCE: { switch (_engine->_gamestate->_segMan->getSegmentType(reg.getSegment())) { #ifdef ENABLE_SCI32 - case SEG_TYPE_ARRAY: { + case SEG_TYPE_ARRAY: printArray(reg); break; - } - case SEG_TYPE_BITMAP: { + case SEG_TYPE_BITMAP: printBitmap(reg); break; - } #endif default: { const SegmentRef block = _engine->_gamestate->_segMan->dereference(reg); |