diff options
author | Max Horn | 2010-11-02 09:49:47 +0000 |
---|---|---|
committer | Max Horn | 2010-11-02 09:49:47 +0000 |
commit | ba3e826872d8456a3bca171bf5613f7802e9582a (patch) | |
tree | c3b4f245c111d6931ddb13f68a6171dd9615041c /engines/sci | |
parent | 31bf3a413756dd55a3b89ec0b2ec798e360f7d49 (diff) | |
download | scummvm-rg350-ba3e826872d8456a3bca171bf5613f7802e9582a.tar.gz scummvm-rg350-ba3e826872d8456a3bca171bf5613f7802e9582a.tar.bz2 scummvm-rg350-ba3e826872d8456a3bca171bf5613f7802e9582a.zip |
SCI: Remove any use of printf
svn-id: r54037
Diffstat (limited to 'engines/sci')
-rw-r--r-- | engines/sci/console.cpp | 60 | ||||
-rw-r--r-- | engines/sci/engine/kernel.cpp | 28 | ||||
-rw-r--r-- | engines/sci/engine/kmisc.cpp | 2 | ||||
-rw-r--r-- | engines/sci/engine/kparse.cpp | 4 | ||||
-rw-r--r-- | engines/sci/engine/scriptdebug.cpp | 132 | ||||
-rw-r--r-- | engines/sci/engine/seg_manager.cpp | 4 | ||||
-rw-r--r-- | engines/sci/engine/selector.cpp | 4 | ||||
-rw-r--r-- | engines/sci/engine/vm.cpp | 66 | ||||
-rw-r--r-- | engines/sci/graphics/menu.cpp | 2 | ||||
-rw-r--r-- | engines/sci/parser/grammar.cpp | 40 | ||||
-rw-r--r-- | engines/sci/parser/said.cpp | 2 | ||||
-rw-r--r-- | engines/sci/parser/vocabulary.cpp | 56 | ||||
-rw-r--r-- | engines/sci/parser/vocabulary.h | 2 | ||||
-rw-r--r-- | engines/sci/resource.cpp | 2 | ||||
-rw-r--r-- | engines/sci/sound/drivers/amigamac.cpp | 18 |
15 files changed, 211 insertions, 211 deletions
diff --git a/engines/sci/console.cpp b/engines/sci/console.cpp index 0dac0729cc..42b1d06e11 100644 --- a/engines/sci/console.cpp +++ b/engines/sci/console.cpp @@ -1383,9 +1383,9 @@ bool Console::cmdSaid(int argc, const char **argv) { } spec[len++] = 0xFF; - printf("Matching '%s' against:", string); + debugN("Matching '%s' against:", string); _engine->getVocabulary()->debugDecipherSaidBlock(spec); - printf("\n"); + debugN("\n"); ResultWordListList words; bool res = _engine->getVocabulary()->tokenizeString(words, string, &error); @@ -3154,24 +3154,24 @@ static void midi_hexdump(byte *data, int size, int notational_offset) { int blanks = 0; offset += offset_mod; - printf(" [%04x] %d\t", + debugN(" [%04x] %d\t", old_offset + notational_offset, time); cmd = data[offset]; if (!(cmd & 0x80)) { cmd = prev; if (prev < 0x80) { - printf("Track broken at %x after" + debugN("Track broken at %x after" " offset mod of %d\n", offset + notational_offset, offset_mod); Common::hexdump(data, size, 16, notational_offset); return; } - printf("(rs %02x) ", cmd); + debugN("(rs %02x) ", cmd); blanks += 8; } else { ++offset; - printf("%02x ", cmd); + debugN("%02x ", cmd); blanks += 3; } prev = cmd; @@ -3183,37 +3183,37 @@ static void midi_hexdump(byte *data, int size, int notational_offset) { for (i = 0; i < pleft; i++) { if (i == 0) firstarg = data[offset]; - printf("%02x ", data[offset++]); + debugN("%02x ", data[offset++]); blanks += 3; } while (blanks < 16) { blanks += 4; - printf(" "); + debugN(" "); } while (blanks < 20) { ++blanks; - printf(" "); + debugN(" "); } if (cmd == SCI_MIDI_EOT) - printf(";; EOT"); + debugN(";; EOT"); else if (cmd == SCI_MIDI_SET_SIGNAL) { if (firstarg == SCI_MIDI_SET_SIGNAL_LOOP) - printf(";; LOOP point"); + debugN(";; LOOP point"); else - printf(";; CUE (%d)", firstarg); + debugN(";; CUE (%d)", firstarg); } else if (SCI_MIDI_CONTROLLER(cmd)) { if (firstarg == SCI_MIDI_CUMULATIVE_CUE) - printf(";; CUE (cumulative)"); + debugN(";; CUE (cumulative)"); else if (firstarg == SCI_MIDI_RESET_ON_SUSPEND) - printf(";; RESET-ON-SUSPEND flag"); + debugN(";; RESET-ON-SUSPEND flag"); } - printf("\n"); + debugN("\n"); if (old_offset >= offset) { - printf("-- Not moving forward anymore," + debugN("-- Not moving forward anymore," " aborting (%x/%x)\n", offset, old_offset); return; } @@ -3692,22 +3692,22 @@ void Console::hexDumpReg(const reg_t *data, int len, int regsPerLine, int startO byte c; int offset = startOffset; while (len >= regsPerLine) { - printf("%06x: ", offset); + debugN("%06x: ", offset); for (i = 0; i < regsPerLine; i++) { - printf("%04x:%04x ", PRINT_REG(data[i])); + debugN("%04x:%04x ", PRINT_REG(data[i])); } - printf(" |"); + debugN(" |"); for (i = 0; i < regsPerLine; i++) { c = data[i].toUint16() & 0xff; if (c < 32 || c >= 127) c = '.'; - printf("%c", c); + debugN("%c", c); c = data[i].toUint16() >> 8; if (c < 32 || c >= 127) c = '.'; - printf("%c", c); + debugN("%c", c); } - printf("|\n"); + debugN("|\n"); data += regsPerLine; len -= regsPerLine; offset += regsPerLine * (isArray ? 1 : 2); @@ -3716,27 +3716,27 @@ void Console::hexDumpReg(const reg_t *data, int len, int regsPerLine, int startO if (len <= 0) return; - printf("%06x: ", offset); + debugN("%06x: ", offset); for (i = 0; i < regsPerLine; i++) { if (i < len) - printf("%04x:%04x ", PRINT_REG(data[i])); + debugN("%04x:%04x ", PRINT_REG(data[i])); else - printf(" "); + debugN(" "); } - printf(" |"); + debugN(" |"); for (i = 0; i < len; i++) { c = data[i].toUint16() & 0xff; if (c < 32 || c >= 127) c = '.'; - printf("%c", c); + debugN("%c", c); c = data[i].toUint16() >> 8; if (c < 32 || c >= 127) c = '.'; - printf("%c", c); + debugN("%c", c); } for (; i < regsPerLine; i++) - printf(" "); - printf("|\n"); + debugN(" "); + debugN("|\n"); } } // End of namespace Sci diff --git a/engines/sci/engine/kernel.cpp b/engines/sci/engine/kernel.cpp index d17d4f3fb3..408dc5f150 100644 --- a/engines/sci/engine/kernel.cpp +++ b/engines/sci/engine/kernel.cpp @@ -138,7 +138,7 @@ void Kernel::loadSelectorNames() { Common::String tmp((const char *)r->data + offset + 2, len); _selectorNames.push_back(tmp); - //printf("%s\n", tmp.c_str()); // debug + //debug("%s", tmp.c_str()); // Early SCI versions used the LSB in the selector ID as a read/write // toggle. To compensate for that, we add every selector name twice. @@ -430,8 +430,8 @@ static void kernelSignatureDebugType(const uint16 type) { while (list->typeCheck) { if (type & list->typeCheck) { if (!firstPrint) - printf(", "); - printf("%s", list->text); + debugN(", "); + debugN("%s", list->text); firstPrint = false; } list++; @@ -442,38 +442,38 @@ static void kernelSignatureDebugType(const uint16 type) { void Kernel::signatureDebug(const uint16 *sig, int argc, const reg_t *argv) { int argnr = 0; while (*sig || argc) { - printf("parameter %d: ", argnr++); + debugN("parameter %d: ", argnr++); if (argc) { reg_t parameter = *argv; - printf("%04x:%04x (", PRINT_REG(parameter)); + debugN("%04x:%04x (", PRINT_REG(parameter)); int regType = findRegType(parameter); if (regType) kernelSignatureDebugType(regType); else - printf("unknown type of %04x:%04x", PRINT_REG(parameter)); - printf(")"); + debugN("unknown type of %04x:%04x", PRINT_REG(parameter)); + debugN(")"); argv++; argc--; } else { - printf("not passed"); + debugN("not passed"); } if (*sig) { const uint16 signature = *sig; if ((signature & SIG_MAYBE_ANY) == SIG_MAYBE_ANY) { - printf(", may be any"); + debugN(", may be any"); } else { - printf(", should be "); + debugN(", should be "); kernelSignatureDebugType(signature); } if (signature & SIG_IS_OPTIONAL) - printf(" (optional)"); + debugN(" (optional)"); if (signature & SIG_NEEDS_MORE) - printf(" (needs more)"); + debugN(" (needs more)"); if (signature & SIG_MORE_MAY_FOLLOW) - printf(" (more may follow)"); + debugN(" (more may follow)"); sig++; } - printf("\n"); + debugN("\n"); } } diff --git a/engines/sci/engine/kmisc.cpp b/engines/sci/engine/kmisc.cpp index 13fe14a995..a92a7a2645 100644 --- a/engines/sci/engine/kmisc.cpp +++ b/engines/sci/engine/kmisc.cpp @@ -164,7 +164,7 @@ reg_t kFlushResources(EngineState *s, int argc, reg_t *argv) { } reg_t kSetDebug(EngineState *s, int argc, reg_t *argv) { - printf("Debug mode activated\n"); + debug("Debug mode activated"); g_sci->_debugState.seeking = kDebugSeekNothing; g_sci->_debugState.runningStep = 0; diff --git a/engines/sci/engine/kparse.cpp b/engines/sci/engine/kparse.cpp index 6a052a582d..0b55c0fce7 100644 --- a/engines/sci/engine/kparse.cpp +++ b/engines/sci/engine/kparse.cpp @@ -62,7 +62,7 @@ reg_t kSaid(EngineState *s, int argc, reg_t *argv) { } #ifdef DEBUG_PARSER - printf("Said block: "); + debugN("Said block: "); g_sci->getVocabulary()->debugDecipherSaidBlock(said_block); #endif @@ -74,7 +74,7 @@ reg_t kSaid(EngineState *s, int argc, reg_t *argv) { if (new_lastmatch != SAID_NO_MATCH) { /* Build and possibly display a parse tree */ #ifdef DEBUG_PARSER - printf("kSaid: Match.\n"); + debugN("kSaid: Match.\n"); #endif s->r_acc = make_reg(0, 1); diff --git a/engines/sci/engine/scriptdebug.cpp b/engines/sci/engine/scriptdebug.cpp index 9c08526fbb..d587db26b4 100644 --- a/engines/sci/engine/scriptdebug.cpp +++ b/engines/sci/engine/scriptdebug.cpp @@ -95,7 +95,7 @@ reg_t disassemble(EngineState *s, reg_t pos, int print_bw_tag, int print_bytecod opsize &= 1; // byte if true, word if false - printf("%04x:%04x: ", PRINT_REG(pos)); + debugN("%04x:%04x: ", PRINT_REG(pos)); if (print_bytecode) { if (pos.offset + bytecount > scr_size) { @@ -104,16 +104,16 @@ reg_t disassemble(EngineState *s, reg_t pos, int print_bw_tag, int print_bytecod } for (i = 0; i < bytecount; i++) - printf("%02x ", scr[pos.offset + i]); + debugN("%02x ", scr[pos.offset + i]); for (i = bytecount; i < 5; i++) - printf(" "); + debugN(" "); } if (print_bw_tag) - printf("[%c] ", opsize ? 'B' : 'W'); + debugN("[%c] ", opsize ? 'B' : 'W'); - printf("%s", opcodeNames[opcode]); + debugN("%s", opcodeNames[opcode]); i = 0; while (g_opcode_formats[opcode][i]) { @@ -124,12 +124,12 @@ reg_t disassemble(EngineState *s, reg_t pos, int print_bw_tag, int print_bytecod case Script_SByte: case Script_Byte: - printf(" %02x", scr[retval.offset++]); + debugN(" %02x", scr[retval.offset++]); break; case Script_Word: case Script_SWord: - printf(" %04x", READ_SCI11ENDIAN_UINT16(&scr[retval.offset])); + debugN(" %04x", READ_SCI11ENDIAN_UINT16(&scr[retval.offset])); retval.offset += 2; break; @@ -148,11 +148,11 @@ reg_t disassemble(EngineState *s, reg_t pos, int print_bw_tag, int print_bytecod } if (opcode == op_callk) - printf(" %s[%x]", (param_value < kernel->_kernelFuncs.size()) ? + debugN(" %s[%x]", (param_value < kernel->_kernelFuncs.size()) ? ((param_value < kernel->getKernelNamesSize()) ? kernel->getKernelName(param_value).c_str() : "[Unknown(postulated)]") : "<invalid>", param_value); else - printf(opsize ? " %02x" : " %04x", param_value); + debugN(opsize ? " %02x" : " %04x", param_value); break; @@ -163,7 +163,7 @@ reg_t disassemble(EngineState *s, reg_t pos, int print_bw_tag, int print_bytecod param_value = READ_SCI11ENDIAN_UINT16(&scr[retval.offset]); retval.offset += 2; } - printf(opsize ? " %02x" : " %04x", param_value); + debugN(opsize ? " %02x" : " %04x", param_value); break; case Script_SRelative: @@ -173,7 +173,7 @@ reg_t disassemble(EngineState *s, reg_t pos, int print_bw_tag, int print_bytecod param_value = READ_SCI11ENDIAN_UINT16(&scr[retval.offset]); retval.offset += 2; } - printf(opsize ? " %02x [%04x]" : " %04x [%04x]", param_value, (0xffff) & (retval.offset + param_value)); + debugN(opsize ? " %02x [%04x]" : " %04x [%04x]", param_value, (0xffff) & (retval.offset + param_value)); break; case Script_End: @@ -193,11 +193,11 @@ reg_t disassemble(EngineState *s, reg_t pos, int print_bw_tag, int print_bytecod if (!obj) warning("Attempted to reference on non-object at %04x:%04x", PRINT_REG(s->xs->objp)); else - printf(" (%s)", g_sci->getKernel()->getSelectorName(obj->propertyOffsetToId(s->_segMan, scr[pos.offset + 1])).c_str()); + debugN(" (%s)", g_sci->getKernel()->getSelectorName(obj->propertyOffsetToId(s->_segMan, scr[pos.offset + 1])).c_str()); } } - printf("\n"); + debugN("\n"); if (pos == s->xs->addr.pc) { // Extra information if debugging the current opcode if (opcode == op_callk) { @@ -208,14 +208,14 @@ reg_t disassemble(EngineState *s, reg_t pos, int print_bw_tag, int print_bytecod if (!oldScriptHeader) argc += (s->restAdjust); - printf(" Kernel params: ("); + debugN(" Kernel params: ("); for (int j = 0; j < argc; j++) { - printf("%04x:%04x", PRINT_REG((s->xs->sp)[j - stackframe])); + debugN("%04x:%04x", PRINT_REG((s->xs->sp)[j - stackframe])); if (j + 1 < argc) - printf(", "); + debugN(", "); } - printf(")\n"); + debugN(")\n"); } else if ((opcode == op_send) || (opcode == op_self)) { int restmod = s->restAdjust; int stackframe = (scr[pos.offset + 1] >> 1) + restmod; @@ -240,32 +240,32 @@ reg_t disassemble(EngineState *s, reg_t pos, int print_bw_tag, int print_bytecod if (!name) name = "<invalid>"; - printf(" %s::%s[", name, g_sci->getKernel()->getSelectorName(selector).c_str()); + debugN(" %s::%s[", name, g_sci->getKernel()->getSelectorName(selector).c_str()); switch (lookupSelector(s->_segMan, called_obj_addr, selector, 0, &fun_ref)) { case kSelectorMethod: - printf("FUNCT"); + debugN("FUNCT"); argc += restmod; restmod = 0; break; case kSelectorVariable: - printf("VAR"); + debugN("VAR"); break; case kSelectorNone: - printf("INVALID"); + debugN("INVALID"); break; } - printf("]("); + debugN("]("); while (argc--) { - printf("%04x:%04x", PRINT_REG(sb[- stackframe + 2])); + debugN("%04x:%04x", PRINT_REG(sb[- stackframe + 2])); if (argc) - printf(", "); + debugN(", "); stackframe--; } - printf(")\n"); + debugN(")\n"); stackframe -= 2; } // while (stackframe > 0) } // Send-like opcodes @@ -334,7 +334,7 @@ void SciEngine::scriptDebug() { // OK, found whatever we were looking for } - printf("Step #%d\n", s->scriptStepCounter); + debugN("Step #%d\n", s->scriptStepCounter); disassemble(s, s->xs->addr.pc, 0, 1); if (_debugState.runningStep) { @@ -354,27 +354,27 @@ void Kernel::dumpScriptObject(char *data, int seeker, int objsize) { int namepos = (int16)READ_SCI11ENDIAN_UINT16((unsigned char *) data + 14 + seeker); int i = 0; - printf("Object\n"); + debugN("Object\n"); Common::hexdump((unsigned char *) data + seeker, objsize - 4, 16, seeker); //-4 because the size includes the two-word header - printf("Name: %s\n", namepos ? ((char *)(data + namepos)) : "<unknown>"); - printf("Superclass: %x\n", superclass); - printf("Species: %x\n", species); - printf("-info-:%x\n", (int16)READ_SCI11ENDIAN_UINT16((unsigned char *) data + 12 + seeker) & 0xffff); + debugN("Name: %s\n", namepos ? ((char *)(data + namepos)) : "<unknown>"); + debugN("Superclass: %x\n", superclass); + debugN("Species: %x\n", species); + debugN("-info-:%x\n", (int16)READ_SCI11ENDIAN_UINT16((unsigned char *) data + 12 + seeker) & 0xffff); - printf("Function area offset: %x\n", (int16)READ_SCI11ENDIAN_UINT16((unsigned char *) data + seeker + 4)); - printf("Selectors [%x]:\n", selectors = (selectorsize = (int16)READ_SCI11ENDIAN_UINT16((unsigned char *) data + seeker + 6))); + debugN("Function area offset: %x\n", (int16)READ_SCI11ENDIAN_UINT16((unsigned char *) data + seeker + 4)); + debugN("Selectors [%x]:\n", selectors = (selectorsize = (int16)READ_SCI11ENDIAN_UINT16((unsigned char *) data + seeker + 6))); seeker += 8; while (selectors--) { - printf(" [#%03x] = 0x%x\n", i++, (int16)READ_SCI11ENDIAN_UINT16((unsigned char *)data + seeker) & 0xffff); + debugN(" [#%03x] = 0x%x\n", i++, (int16)READ_SCI11ENDIAN_UINT16((unsigned char *)data + seeker) & 0xffff); seeker += 2; } - printf("Overridden functions: %x\n", selectors = overloads = (int16)READ_SCI11ENDIAN_UINT16((unsigned char *)data + seeker)); + debugN("Overridden functions: %x\n", selectors = overloads = (int16)READ_SCI11ENDIAN_UINT16((unsigned char *)data + seeker)); seeker += 2; @@ -382,8 +382,8 @@ void Kernel::dumpScriptObject(char *data, int seeker, int objsize) { while (overloads--) { int selector = (int16)READ_SCI11ENDIAN_UINT16((unsigned char *) data + (seeker)); - printf(" [%03x] %s: @", selector & 0xffff, (selector >= 0 && selector < (int)_selectorNames.size()) ? _selectorNames[selector].c_str() : "<?>"); - printf("%04x\n", (int16)READ_SCI11ENDIAN_UINT16((unsigned char *)data + seeker + selectors*2 + 2) & 0xffff); + debugN(" [%03x] %s: @", selector & 0xffff, (selector >= 0 && selector < (int)_selectorNames.size()) ? _selectorNames[selector].c_str() : "<?>"); + debugN("%04x\n", (int16)READ_SCI11ENDIAN_UINT16((unsigned char *)data + seeker + selectors*2 + 2) & 0xffff); seeker += 2; } @@ -395,17 +395,17 @@ void Kernel::dumpScriptClass(char *data, int seeker, int objsize) { int superclass = (int16)READ_SCI11ENDIAN_UINT16((unsigned char *) data + 10 + seeker); int namepos = (int16)READ_SCI11ENDIAN_UINT16((unsigned char *) data + 14 + seeker); - printf("Class\n"); + debugN("Class\n"); Common::hexdump((unsigned char *) data + seeker, objsize - 4, 16, seeker); - printf("Name: %s\n", namepos ? ((char *)data + namepos) : "<unknown>"); - printf("Superclass: %x\n", superclass); - printf("Species: %x\n", species); - printf("-info-:%x\n", (int16)READ_SCI11ENDIAN_UINT16((unsigned char *)data + 12 + seeker) & 0xffff); + debugN("Name: %s\n", namepos ? ((char *)data + namepos) : "<unknown>"); + debugN("Superclass: %x\n", superclass); + debugN("Species: %x\n", species); + debugN("-info-:%x\n", (int16)READ_SCI11ENDIAN_UINT16((unsigned char *)data + 12 + seeker) & 0xffff); - printf("Function area offset: %x\n", (int16)READ_SCI11ENDIAN_UINT16((unsigned char *)data + seeker + 4)); - printf("Selectors [%x]:\n", selectors = (selectorsize = (int16)READ_SCI11ENDIAN_UINT16((unsigned char *)data + seeker + 6))); + debugN("Function area offset: %x\n", (int16)READ_SCI11ENDIAN_UINT16((unsigned char *)data + seeker + 4)); + debugN("Selectors [%x]:\n", selectors = (selectorsize = (int16)READ_SCI11ENDIAN_UINT16((unsigned char *)data + seeker + 6))); seeker += 8; selectorsize <<= 1; @@ -413,7 +413,7 @@ void Kernel::dumpScriptClass(char *data, int seeker, int objsize) { while (selectors--) { int selector = (int16)READ_SCI11ENDIAN_UINT16((unsigned char *) data + (seeker) + selectorsize); - printf(" [%03x] %s = 0x%x\n", 0xffff & selector, (selector >= 0 && selector < (int)_selectorNames.size()) ? _selectorNames[selector].c_str() : "<?>", + debugN(" [%03x] %s = 0x%x\n", 0xffff & selector, (selector >= 0 && selector < (int)_selectorNames.size()) ? _selectorNames[selector].c_str() : "<?>", (int16)READ_SCI11ENDIAN_UINT16((unsigned char *)data + seeker) & 0xffff); seeker += 2; @@ -421,16 +421,16 @@ void Kernel::dumpScriptClass(char *data, int seeker, int objsize) { seeker += selectorsize; - printf("Overloaded functions: %x\n", selectors = overloads = (int16)READ_SCI11ENDIAN_UINT16((unsigned char *)data + seeker)); + debugN("Overloaded functions: %x\n", selectors = overloads = (int16)READ_SCI11ENDIAN_UINT16((unsigned char *)data + seeker)); seeker += 2; while (overloads--) { int selector = (int16)READ_SCI11ENDIAN_UINT16((unsigned char *)data + (seeker)); - fprintf(stderr, "selector=%d; selectorNames.size() =%d\n", selector, _selectorNames.size()); - printf(" [%03x] %s: @", selector & 0xffff, (selector >= 0 && selector < (int)_selectorNames.size()) ? + debugN("selector=%d; selectorNames.size() =%d\n", selector, _selectorNames.size()); + debugN(" [%03x] %s: @", selector & 0xffff, (selector >= 0 && selector < (int)_selectorNames.size()) ? _selectorNames[selector].c_str() : "<?>"); - printf("%04x\n", (int16)READ_SCI11ENDIAN_UINT16((unsigned char *)data + seeker + selectors * 2 + 2) & 0xffff); + debugN("%04x\n", (int16)READ_SCI11ENDIAN_UINT16((unsigned char *)data + seeker + selectors * 2 + 2) & 0xffff); seeker += 2; } @@ -452,17 +452,17 @@ void Kernel::dissectScript(int scriptNumber, Vocabulary *vocab) { unsigned int seeker = _seeker + 4; if (!objType) { - printf("End of script object (#0) encountered.\n"); - printf("Classes: %i, Objects: %i, Export: %i,\n Var: %i (all base 10)", + debugN("End of script object (#0) encountered.\n"); + debugN("Classes: %i, Objects: %i, Export: %i,\n Var: %i (all base 10)", objectctr[6], objectctr[1], objectctr[7], objectctr[10]); return; } - printf("\n"); + debugN("\n"); objsize = (int16)READ_SCI11ENDIAN_UINT16(script->data + _seeker + 2); - printf("Obj type #%x, size 0x%x: ", objType, objsize); + debugN("Obj type #%x, size 0x%x: ", objType, objsize); _seeker += objsize; @@ -474,28 +474,28 @@ void Kernel::dissectScript(int scriptNumber, Vocabulary *vocab) { break; case SCI_OBJ_CODE: - printf("Code\n"); + debugN("Code\n"); Common::hexdump(script->data + seeker, objsize - 4, 16, seeker); break; case 3: - printf("<unknown>\n"); + debugN("<unknown>\n"); Common::hexdump(script->data + seeker, objsize - 4, 16, seeker); break; case SCI_OBJ_SAID: - printf("Said\n"); + debugN("Said\n"); Common::hexdump(script->data + seeker, objsize - 4, 16, seeker); - printf("%04x: ", seeker); + debugN("%04x: ", seeker); vocab->debugDecipherSaidBlock(script->data + seeker); - printf("\n"); + debugN("\n"); break; case SCI_OBJ_STRINGS: - printf("Strings\n"); + debugN("Strings\n"); while (script->data [seeker]) { - printf("%04x: %s\n", seeker, script->data + seeker); + debugN("%04x: %s\n", seeker, script->data + seeker); seeker += strlen((char *)script->data + seeker) + 1; } seeker++; // the ending zero byte @@ -506,33 +506,33 @@ void Kernel::dissectScript(int scriptNumber, Vocabulary *vocab) { break; case SCI_OBJ_EXPORTS: - printf("Exports\n"); + debugN("Exports\n"); Common::hexdump((unsigned char *)script->data + seeker, objsize - 4, 16, seeker); break; case SCI_OBJ_POINTERS: - printf("Pointers\n"); + debugN("Pointers\n"); Common::hexdump(script->data + seeker, objsize - 4, 16, seeker); break; case 9: - printf("<unknown>\n"); + debugN("<unknown>\n"); Common::hexdump(script->data + seeker, objsize - 4, 16, seeker); break; case SCI_OBJ_LOCALVARS: - printf("Local vars\n"); + debugN("Local vars\n"); Common::hexdump(script->data + seeker, objsize - 4, 16, seeker); break; default: - printf("Unsupported!\n"); + debugN("Unsupported!\n"); return; } } - printf("Script ends without terminator\n"); + debugN("Script ends without terminator\n"); } } // End of namespace Sci diff --git a/engines/sci/engine/seg_manager.cpp b/engines/sci/engine/seg_manager.cpp index 1cbe9a56f4..d509046a15 100644 --- a/engines/sci/engine/seg_manager.cpp +++ b/engines/sci/engine/seg_manager.cpp @@ -301,9 +301,9 @@ reg_t SegManager::findObjectByName(const Common::String &name, int index) { return NULL_REG; if (result.size() > 1 && index < 0) { - printf("Ambiguous:\n"); + debug("findObjectByName(%s): multiple matches:", name.c_str()); for (i = 0; i < result.size(); i++) - printf(" %3x: [%04x:%04x] %s\n", i, PRINT_REG(result[i]), name.c_str()); + debug(" %3x: [%04x:%04x]", i, PRINT_REG(result[i])); return NULL_REG; // Ambiguous } diff --git a/engines/sci/engine/selector.cpp b/engines/sci/engine/selector.cpp index b31f52aa13..798dbf529c 100644 --- a/engines/sci/engine/selector.cpp +++ b/engines/sci/engine/selector.cpp @@ -40,10 +40,10 @@ namespace Sci { // The defines below can be used to construct static selector tables for games which don't have // a vocab.997 resource, by dumping the selector table from other similar versions or games #define FIND_SELECTOR(_slc_) _selectorCache._slc_ = findSelector(#_slc_); \ - printf("\t{ \"%s\", %d },\n", #_slc_, _selectorCache._slc_) + debugN("\t{ \"%s\", %d },\n", #_slc_, _selectorCache._slc_) #define FIND_SELECTOR2(_slc_, _slcstr_) _selectorCache._slc_ = findSelector(_slcstr_); \ - printf("\t{ \"%s\", %d },\n", _slcstr_, _selectorCache._slc_) + debugN("\t{ \"%s\", %d },\n", _slcstr_, _selectorCache._slc_) #endif diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp index 650f01469a..cefb228c13 100644 --- a/engines/sci/engine/vm.cpp +++ b/engines/sci/engine/vm.cpp @@ -423,7 +423,7 @@ ExecStack *send_selector(EngineState *s, reg_t send_obj, reg_t work_obj, StackPt } #ifdef VM_DEBUG_SEND - printf("Send to %04x:%04x (%s), selector %04x (%s):", PRINT_REG(send_obj), + debugN("Send to %04x:%04x (%s), selector %04x (%s):", PRINT_REG(send_obj), s->_segMan->getObjectName(send_obj), selector, g_sci->getKernel()->getSelectorName(selector).c_str()); #endif // VM_DEBUG_SEND @@ -438,9 +438,9 @@ ExecStack *send_selector(EngineState *s, reg_t send_obj, reg_t work_obj, StackPt #ifdef VM_DEBUG_SEND if (argc) - printf("Varselector: Write %04x:%04x\n", PRINT_REG(argp[1])); + debugN("Varselector: Write %04x:%04x\n", PRINT_REG(argp[1])); else - printf("Varselector: Read\n"); + debugN("Varselector: Read\n"); #endif // VM_DEBUG_SEND // argc == 0: read selector @@ -496,39 +496,39 @@ ExecStack *send_selector(EngineState *s, reg_t send_obj, reg_t work_obj, StackPt #ifndef VM_DEBUG_SEND if (activeBreakpointTypes & BREAK_SELECTOREXEC) { if (g_sci->checkSelectorBreakpoint(BREAK_SELECTOREXEC, send_obj, selector)) { - printf("[execute selector]"); + debugN("[execute selector]"); int displaySize = 0; for (int argNr = 1; argNr <= argc; argNr++) { if (argNr == 1) - printf(" - "); + debugN(" - "); reg_t curParam = argp[argNr]; if (curParam.segment) { - printf("[%04x:%04x] ", PRINT_REG(curParam)); + debugN("[%04x:%04x] ", PRINT_REG(curParam)); displaySize += 12; } else { - printf("[%04x] ", curParam.offset); + debugN("[%04x] ", curParam.offset); displaySize += 7; } if (displaySize > 50) { if (argNr < argc) - printf("..."); + debugN("..."); break; } } - printf("\n"); + debugN("\n"); } } #else // VM_DEBUG_SEND if (activeBreakpointTypes & BREAK_SELECTOREXEC) g_sci->checkSelectorBreakpoint(BREAK_SELECTOREXEC, send_obj, selector); - printf("Funcselector("); + debugN("Funcselector("); for (int i = 0; i < argc; i++) { - printf("%04x:%04x", PRINT_REG(argp[i+1])); + debugN("%04x:%04x", PRINT_REG(argp[i+1])); if (i + 1 < argc) - printf(", "); + debugN(", "); } - printf(") at %04x:%04x\n", PRINT_REG(funcp)); + debugN(") at %04x:%04x\n", PRINT_REG(funcp)); #endif // VM_DEBUG_SEND { @@ -583,7 +583,7 @@ static ExecStack *add_exec_stack_entry(Common::List<ExecStack> &execStack, reg_t // Returns new TOS element for the execution stack // _localsSegment may be -1 if derived from the called object - //printf("Exec stack: [%d/%d], origin %d, at %p\n", s->execution_stack_pos, s->_executionStack.size(), origin, s->execution_stack); + //debug("Exec stack: [%d/%d], origin %d, at %p", s->execution_stack_pos, s->_executionStack.size(), origin, s->execution_stack); ExecStack xstack; @@ -655,46 +655,46 @@ static void addKernelCallToExecStack(EngineState *s, int kernelCallNr, int argc, static void logKernelCall(const KernelFunction *kernelCall, const KernelSubFunction *kernelSubCall, EngineState *s, int argc, reg_t *argv, reg_t result) { Kernel *kernel = g_sci->getKernel(); if (!kernelSubCall) { - printf("k%s: ", kernelCall->name); + debugN("k%s: ", kernelCall->name); } else { int callNameLen = strlen(kernelCall->name); if (strncmp(kernelCall->name, kernelSubCall->name, callNameLen) == 0) { const char *subCallName = kernelSubCall->name + callNameLen; - printf("k%s(%s): ", kernelCall->name, subCallName); + debugN("k%s(%s): ", kernelCall->name, subCallName); } else { - printf("k%s(%s): ", kernelCall->name, kernelSubCall->name); + debugN("k%s(%s): ", kernelCall->name, kernelSubCall->name); } } for (int parmNr = 0; parmNr < argc; parmNr++) { if (parmNr) - printf(", "); + debugN(", "); uint16 regType = kernel->findRegType(argv[parmNr]); if (regType & SIG_TYPE_NULL) - printf("0"); + debugN("0"); else if (regType & SIG_TYPE_UNINITIALIZED) - printf("UNINIT"); + debugN("UNINIT"); else if (regType & SIG_IS_INVALID) - printf("INVALID"); + debugN("INVALID"); else if (regType & SIG_TYPE_INTEGER) - printf("%d", argv[parmNr].offset); + debugN("%d", argv[parmNr].offset); else { - printf("%04x:%04x", PRINT_REG(argv[parmNr])); + debugN("%04x:%04x", PRINT_REG(argv[parmNr])); switch (regType) { case SIG_TYPE_OBJECT: - printf(" (%s)", s->_segMan->getObjectName(argv[parmNr])); + debugN(" (%s)", s->_segMan->getObjectName(argv[parmNr])); break; case SIG_TYPE_REFERENCE: if (kernelCall->function == kSaid) { SegmentRef saidSpec = s->_segMan->dereference(argv[parmNr]); if (saidSpec.isRaw) { - printf(" ('"); + debugN(" ('"); g_sci->getVocabulary()->debugDecipherSaidBlock(saidSpec.raw); - printf("')"); + debugN("')"); } else { - printf(" (non-raw said-spec)"); + debugN(" (non-raw said-spec)"); } } else { - printf(" ('%s')", s->_segMan->getString(argv[parmNr]).c_str()); + debugN(" ('%s')", s->_segMan->getString(argv[parmNr]).c_str()); } default: break; @@ -702,9 +702,9 @@ static void logKernelCall(const KernelFunction *kernelCall, const KernelSubFunct } } if (result.segment) - printf(" = %04x:%04x\n", PRINT_REG(result)); + debugN(" = %04x:%04x\n", PRINT_REG(result)); else - printf(" = %d\n", result.offset); + debugN(" = %d\n", result.offset); } static void callKernelFunc(EngineState *s, int kernelCallNr, int argc) { @@ -749,7 +749,7 @@ static void callKernelFunc(EngineState *s, int kernelCallNr, int argc) { if (kernelCall.debugLogging) logKernelCall(&kernelCall, NULL, s, argc, argv, s->r_acc); if (kernelCall.debugBreakpoint) { - printf("Break on k%s\n", kernelCall.name); + debugN("Break on k%s\n", kernelCall.name); g_sci->_debugState.debugging = true; g_sci->_debugState.breakpointWasHit = true; } @@ -804,7 +804,7 @@ static void callKernelFunc(EngineState *s, int kernelCallNr, int argc) { if (kernelSubCall.debugLogging) logKernelCall(&kernelCall, &kernelSubCall, s, argc, argv, s->r_acc); if (kernelSubCall.debugBreakpoint) { - printf("Break on k%s\n", kernelSubCall.name); + debugN("Break on k%s\n", kernelSubCall.name); g_sci->_debugState.debugging = true; g_sci->_debugState.breakpointWasHit = true; } @@ -830,7 +830,7 @@ int readPMachineInstruction(const byte *src, byte &extOpcode, int16 opparams[4]) memset(opparams, 0, sizeof(opparams)); for (int i = 0; g_opcode_formats[opcode][i]; ++i) { - //printf("Opcode: 0x%x, Opnumber: 0x%x, temp: %d\n", opcode, opcode, temp); + //debugN("Opcode: 0x%x, Opnumber: 0x%x, temp: %d\n", opcode, opcode, temp); assert(i < 3); switch (g_opcode_formats[opcode][i]) { diff --git a/engines/sci/graphics/menu.cpp b/engines/sci/graphics/menu.cpp index 06470bc560..92644db037 100644 --- a/engines/sci/graphics/menu.cpp +++ b/engines/sci/graphics/menu.cpp @@ -296,7 +296,7 @@ void GfxMenu::kernelSetAttribute(uint16 menuId, uint16 itemId, uint16 attributeI itemEntry->keyPress = tolower(value.offset); itemEntry->keyModifier = 0; // TODO: Find out how modifier is handled - printf("setAttr keypress %X %X\n", value.segment, value.offset); + debug("setAttr keypress %X %X", value.segment, value.offset); break; case SCI_MENU_ATTRIBUTE_TAG: itemEntry->tag = value.offset; diff --git a/engines/sci/parser/grammar.cpp b/engines/sci/parser/grammar.cpp index 03e9d29660..8a6cd2dd4d 100644 --- a/engines/sci/parser/grammar.cpp +++ b/engines/sci/parser/grammar.cpp @@ -93,49 +93,49 @@ static void vocab_print_rule(ParseRule *rule) { return; } - printf("[%03x] -> ", rule->_id); + debugN("[%03x] -> ", rule->_id); if (rule->_data.empty()) - printf("e"); + debugN("e"); for (uint i = 0; i < rule->_data.size(); i++) { uint token = rule->_data[i]; if (token == TOKEN_OPAREN) { if (i == rule->_firstSpecial) - printf("_"); + debugN("_"); - printf("("); + debugN("("); wspace = 0; } else if (token == TOKEN_CPAREN) { if (i == rule->_firstSpecial) - printf("_"); + debugN("_"); - printf(")"); + debugN(")"); wspace = 0; } else { if (wspace) - printf(" "); + debugN(" "); if (i == rule->_firstSpecial) - printf("_"); + debugN("_"); if (token & TOKEN_TERMINAL_CLASS) - printf("C(%04x)", token & 0xffff); + debugN("C(%04x)", token & 0xffff); else if (token & TOKEN_TERMINAL_GROUP) - printf("G(%04x)", token & 0xffff); + debugN("G(%04x)", token & 0xffff); else if (token & TOKEN_STUFFING_LEAF) - printf("%03x", token & 0xffff); + debugN("%03x", token & 0xffff); else if (token & TOKEN_STUFFING_WORD) - printf("{%03x}", token & 0xffff); + debugN("{%03x}", token & 0xffff); else - printf("[%03x]", token); /* non-terminal */ + debugN("[%03x]", token); /* non-terminal */ wspace = 1; } if (i == rule->_firstSpecial) - printf("_"); + debugN("_"); } - printf(" [%d specials]", rule->_numSpecials); + debugN(" [%d specials]", rule->_numSpecials); } static ParseRule *_vdup(ParseRule *a) { @@ -321,13 +321,13 @@ void ParseRuleList::print() const { const ParseRuleList *list = this; int pos = 0; while (list) { - printf("R%03d: ", pos); + debugN("R%03d: ", pos); vocab_print_rule(list->rule); - printf("\n"); + debugN("\n"); list = list->next; pos++; } - printf("%d rules total.\n", pos); + debugN("%d rules total.\n", pos); } static ParseRuleList *_vocab_split_rule_list(ParseRuleList *list) { @@ -524,9 +524,9 @@ static int _vbpt_write_subexpression(ParseTreeNode *nodes, int *pos, ParseRule * else writepos = _vbpt_append_word(nodes, pos, writepos, token & 0xffff); } else { - printf("\nError in parser (grammar.cpp, _vbpt_write_subexpression()): Rule data broken in rule "); + warning("\nError in parser (grammar.cpp, _vbpt_write_subexpression()): Rule data broken in rule "); vocab_print_rule(rule); - printf(", at token position %d\n", *pos); + debugN(", at token position %d\n", *pos); return rulepos; } } diff --git a/engines/sci/parser/said.cpp b/engines/sci/parser/said.cpp index 7393874856..e9c6d9847f 100644 --- a/engines/sci/parser/said.cpp +++ b/engines/sci/parser/said.cpp @@ -39,7 +39,7 @@ namespace Sci { #ifdef SCI_DEBUG_PARSE_TREE_AUGMENTATION -#define scidprintf printf +#define scidprintf debugN #else void print_nothing(...) { } #define scidprintf print_nothing diff --git a/engines/sci/parser/vocabulary.cpp b/engines/sci/parser/vocabulary.cpp index 3e35bd652a..b1f928cdd9 100644 --- a/engines/sci/parser/vocabulary.cpp +++ b/engines/sci/parser/vocabulary.cpp @@ -458,44 +458,44 @@ void Vocabulary::debugDecipherSaidBlock(const byte *addr) { nextItem = *addr++; if (nextItem != 0xff) { if ((!first) && (nextItem != 0xf0)) - printf(" "); + debugN(" "); first = false; if (nextItem < 0xf0) { nextItem = nextItem << 8 | *addr++; - printf("%s{%03x}", getAnyWordFromGroup(nextItem), nextItem); + debugN("%s{%03x}", getAnyWordFromGroup(nextItem), nextItem); nextItem = 0; // Make sure that group 0xff doesn't abort } else switch (nextItem) { case 0xf0: - printf(","); + debugN(","); break; case 0xf1: - printf("&"); + debugN("&"); break; case 0xf2: - printf("/"); + debugN("/"); break; case 0xf3: - printf("("); + debugN("("); break; case 0xf4: - printf(")"); + debugN(")"); break; case 0xf5: - printf("["); + debugN("["); break; case 0xf6: - printf("]"); + debugN("]"); break; case 0xf7: - printf("#"); + debugN("#"); break; case 0xf8: - printf("<"); + debugN("<"); break; case 0xf9: - printf(">"); + debugN(">"); break; case 0xff: break; @@ -611,48 +611,48 @@ void _vocab_recursive_ptree_dump(ParseTreeNode *tree, int blanks) { int i; if (tree->type == kParseTreeLeafNode) { - printf("vocab_dump_parse_tree: Error: consp is nil\n"); + debugN("vocab_dump_parse_tree: Error: consp is nil\n"); return; } if (lbranch) { if (lbranch->type == kParseTreeBranchNode) { - printf("\n"); + debugN("\n"); for (i = 0; i < blanks; i++) - printf(" "); - printf("("); + debugN(" "); + debugN("("); _vocab_recursive_ptree_dump(lbranch, blanks + 1); - printf(")\n"); + debugN(")\n"); for (i = 0; i < blanks; i++) - printf(" "); + debugN(" "); } else - printf("%x", lbranch->value); - printf(" "); - }/* else printf ("nil");*/ + debugN("%x", lbranch->value); + debugN(" "); + }/* else debugN ("nil");*/ if (rbranch) { if (rbranch->type == kParseTreeBranchNode) _vocab_recursive_ptree_dump(rbranch, blanks); else { - printf("%x", rbranch->value); + debugN("%x", rbranch->value); while (rbranch->right) { rbranch = rbranch->right; - printf("/%x", rbranch->value); + debugN("/%x", rbranch->value); } } - }/* else printf("nil");*/ + }/* else debugN("nil");*/ } void vocab_dump_parse_tree(const char *tree_name, ParseTreeNode *nodes) { - printf("(setq %s \n'(", tree_name); + debugN("(setq %s \n'(", tree_name); _vocab_recursive_ptree_dump(nodes, 1); - printf("))\n"); + debugN("))\n"); } void Vocabulary::dumpParseTree() { - printf("(setq parse-tree \n'("); + debugN("(setq parse-tree \n'("); _vocab_recursive_ptree_dump(_parserNodes, 1); - printf("))\n"); + debugN("))\n"); } void Vocabulary::synonymizeTokens(ResultWordListList &words) { diff --git a/engines/sci/parser/vocabulary.h b/engines/sci/parser/vocabulary.h index 620d50c09d..baf30a03d7 100644 --- a/engines/sci/parser/vocabulary.h +++ b/engines/sci/parser/vocabulary.h @@ -243,7 +243,7 @@ public: ParseRuleList *buildGNF(bool verbose = false); /** - * Deciphers a said block and dumps its content via printf. + * Deciphers a said block and dumps its content via debugN. * For debugging only. * @param pos pointer to the data to dump */ diff --git a/engines/sci/resource.cpp b/engines/sci/resource.cpp index 768aa054a5..c94df13ead 100644 --- a/engines/sci/resource.cpp +++ b/engines/sci/resource.cpp @@ -940,7 +940,7 @@ void ResourceManager::freeOldResources() { removeFromLRU(goner); goner->unalloc(); #ifdef SCI_VERBOSE_RESMAN - printf("resMan-debug: LRU: Freeing %s.%03d (%d bytes)\n", getResourceTypeName(goner->type), goner->number, goner->size); + debug("resMan-debug: LRU: Freeing %s.%03d (%d bytes)", getResourceTypeName(goner->type), goner->number, goner->size); #endif } } diff --git a/engines/sci/sound/drivers/amigamac.cpp b/engines/sci/sound/drivers/amigamac.cpp index 4b591eb609..07c0582124 100644 --- a/engines/sci/sound/drivers/amigamac.cpp +++ b/engines/sci/sound/drivers/amigamac.cpp @@ -288,7 +288,7 @@ void MidiDriver_AmigaMac::playInstrument(int16 *dest, Voice *channel, int count) void MidiDriver_AmigaMac::changeInstrument(int channel, int instrument) { #ifdef DEBUG if (_bank.instruments[instrument][0]) - printf("[sfx:seq:amiga] Setting channel %i to \"%s\" (%i)\n", channel, _bank.instruments[instrument]->name, instrument); + debugN("[sfx:seq:amiga] Setting channel %i to \"%s\" (%i)\n", channel, _bank.instruments[instrument]->name, instrument); else warning("[sfx:seq:amiga] instrument %i does not exist (channel %i)", instrument, channel); #endif @@ -488,13 +488,13 @@ MidiDriver_AmigaMac::InstrumentSample *MidiDriver_AmigaMac::readInstrumentSCI0(C instrument->name[29] = 0; #ifdef DEBUG - printf("[sfx:seq:amiga] Reading instrument %i: \"%s\" (%i bytes)\n", + debugN("[sfx:seq:amiga] Reading instrument %i: \"%s\" (%i bytes)\n", *id, instrument->name, size); - printf(" Mode: %02x\n", instrument->mode); - printf(" Looping: %s\n", instrument->mode & kModeLoop ? "on" : "off"); - printf(" Pitch changes: %s\n", instrument->mode & kModePitch ? "on" : "off"); - printf(" Segment sizes: %i %i %i\n", seg_size[0], seg_size[1], seg_size[2]); - printf(" Segment offsets: 0 %i %i\n", loop_offset, read_int32(header + 43)); + debugN(" Mode: %02x\n", instrument->mode); + debugN(" Looping: %s\n", instrument->mode & kModeLoop ? "on" : "off"); + debugN(" Pitch changes: %s\n", instrument->mode & kModePitch ? "on" : "off"); + debugN(" Segment sizes: %i %i %i\n", seg_size[0], seg_size[1], seg_size[2]); + debugN(" Segment offsets: 0 %i %i\n", loop_offset, read_int32(header + 43)); #endif instrument->samples = (int8 *) malloc(size + 1); @@ -745,7 +745,7 @@ bool MidiDriver_AmigaMac::loadInstrumentsSCI0(Common::File &file) { strncpy(_bank.name, (char *) header + 8, 29); _bank.name[29] = 0; #ifdef DEBUG - printf("[sfx:seq:amiga] Reading %i instruments from bank \"%s\"\n", _bank.size, _bank.name); + debugN("[sfx:seq:amiga] Reading %i instruments from bank \"%s\"\n", _bank.size, _bank.name); #endif for (uint i = 0; i < _bank.size; i++) { @@ -784,7 +784,7 @@ bool MidiDriver_AmigaMac::loadInstrumentsSCI0Mac(Common::SeekableReadStream &fil strncpy(_bank.name, (char *) header + 8, 29); _bank.name[29] = 0; #ifdef DEBUG - printf("[sfx:seq:amiga] Reading %i instruments from bank \"%s\"\n", _bank.size, _bank.name); + debugN("[sfx:seq:amiga] Reading %i instruments from bank \"%s\"\n", _bank.size, _bank.name); #endif Common::Array<uint32> instrumentOffsets; |