MOHAWK: Convert all printf to debugN calls

This involves some nasty decisions, like mixing debugN and DebugPrintf
calls in the RivenConsole. I added FIXME comments about this.

svn-id: r54107
This commit is contained in:
Max Horn 2010-11-07 01:03:29 +00:00
parent 90b6cdfbdf
commit b4787d9430
4 changed files with 58 additions and 53 deletions

View file

@ -545,8 +545,12 @@ bool RivenConsole::Cmd_DumpScript(int argc, const char **argv) {
// Get CARD/HSPT data and dump their scripts
if (!scumm_stricmp(argv[2], "CARD")) {
printf ("\n\nDumping scripts for %s\'s card %d!\n", argv[1], (uint16)atoi(argv[3]));
printf ("==================================\n\n");
// FIXME: It's weird to use debugN here and not DebugPrintf. But
// then again, dumpScript() uses debugN, and it is non-trivial
// to modify that to use DebugPrintf. Hence for now we gotta
// make do...
debugN("\n\nDumping scripts for %s\'s card %d!\n", argv[1], (uint16)atoi(argv[3]));
debugN("==================================\n\n");
Common::SeekableReadStream *cardStream = _vm->getRawData(MKID_BE('CARD'), (uint16)atoi(argv[3]));
cardStream->seek(4);
RivenScriptList scriptList = _vm->_scriptMan->readScripts(cardStream, false);
@ -556,15 +560,16 @@ bool RivenConsole::Cmd_DumpScript(int argc, const char **argv) {
}
delete cardStream;
} else if (!scumm_stricmp(argv[2], "HSPT")) {
printf ("\n\nDumping scripts for %s\'s card %d hotspots!\n", argv[1], (uint16)atoi(argv[3]));
printf ("===========================================\n\n");
// FIXME: It's weird to use debugN here and not DebugPrintf. See above!
debugN("\n\nDumping scripts for %s\'s card %d hotspots!\n", argv[1], (uint16)atoi(argv[3]));
debugN("===========================================\n\n");
Common::SeekableReadStream *hsptStream = _vm->getRawData(MKID_BE('HSPT'), (uint16)atoi(argv[3]));
uint16 hotspotCount = hsptStream->readUint16BE();
for (uint16 i = 0; i < hotspotCount; i++) {
printf ("Hotspot %d:\n", i);
debugN("Hotspot %d:\n", i);
hsptStream->seek(22, SEEK_CUR); // Skip non-script related stuff
RivenScriptList scriptList = _vm->_scriptMan->readScripts(hsptStream, false);
for (uint32 j = 0; j < scriptList.size(); j++) {
@ -578,7 +583,8 @@ bool RivenConsole::Cmd_DumpScript(int argc, const char **argv) {
DebugPrintf("%s doesn't have any scripts!\n", argv[2]);
}
printf("\n\n");
// FIXME: It's weird to use debugN here and not DebugPrintf. See above!
debugN("\n\n");
_vm->changeToStack(oldStack);

View file

@ -1396,9 +1396,9 @@ MystResourceType10::MystResourceType10(MohawkEngine_Myst *vm, Common::SeekableRe
// TODO: Not sure about order of Mouse Down, Mouse Drag and Mouse Up
// Or whether this is slightly different...
printf("Type 10 _mouseDownOpcode: %d\n", _mouseDownOpcode);
printf("Type 10 _mouseDragOpcode: %d\n", _mouseDragOpcode);
printf("Type 10 _mouseUpOpcode: %d\n", _mouseUpOpcode);
debugCN(kDebugResource, "Type 10 _mouseDownOpcode: %d\n", _mouseDownOpcode);
debugCN(kDebugResource, "Type 10 _mouseDragOpcode: %d\n", _mouseDragOpcode);
debugCN(kDebugResource, "Type 10 _mouseUpOpcode: %d\n", _mouseUpOpcode);
for (byte i = 0; i < 4; i++) {
debugC(kDebugResource, "\tList %d:", i);
@ -1452,9 +1452,9 @@ MystResourceType11::MystResourceType11(MohawkEngine_Myst *vm, Common::SeekableRe
// TODO: Not sure about order of Mouse Down, Mouse Drag and Mouse Up
// Or whether this is slightly different...
printf("Type 11 _mouseDownOpcode: %d\n", _mouseDownOpcode);
printf("Type 11 _mouseDragOpcode: %d\n", _mouseDragOpcode);
printf("Type 11 _mouseUpOpcode: %d\n", _mouseUpOpcode);
debugCN(kDebugResource, "Type 11 _mouseDownOpcode: %d\n", _mouseDownOpcode);
debugCN(kDebugResource, "Type 11 _mouseDragOpcode: %d\n", _mouseDragOpcode);
debugCN(kDebugResource, "Type 11 _mouseUpOpcode: %d\n", _mouseUpOpcode);
for (byte i = 0; i < 3; i++) {
debugC(kDebugResource, "\tList %d:", i);
@ -1511,14 +1511,14 @@ MystResourceType12::MystResourceType12(MohawkEngine_Myst *vm, Common::SeekableRe
// TODO: Think that u0 and u1 are animation frames to be
// drawn for var == 0 and var == 1
printf("Type 12 _state0Frame: %d\n", _state0Frame);
printf("Type 12 _state1Frame: %d\n", _state1Frame);
debugCN(kDebugResource, "Type 12 _state0Frame: %d\n", _state0Frame);
debugCN(kDebugResource, "Type 12 _state1Frame: %d\n", _state1Frame);
// TODO: Not sure about order of Mouse Down, Mouse Drag and Mouse Up
// Or whether this is slightly different...
printf("Type 12 _mouseDownOpcode: %d\n", _mouseDownOpcode);
printf("Type 12 _mouseDragOpcode: %d\n", _mouseDragOpcode);
printf("Type 12 _mouseUpOpcode: %d\n", _mouseUpOpcode);
debugCN(kDebugResource, "Type 12 _mouseDownOpcode: %d\n", _mouseDownOpcode);
debugCN(kDebugResource, "Type 12 _mouseDragOpcode: %d\n", _mouseDragOpcode);
debugCN(kDebugResource, "Type 12 _mouseUpOpcode: %d\n", _mouseUpOpcode);
for (byte i = 0; i < 3; i++) {
debugC(kDebugResource, "\tList %d:", i);

View file

@ -294,17 +294,16 @@ void MystScriptParser::varUnusedCheck(uint16 op, uint16 var) {
}
void MystScriptParser::unknown(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
// NOTE: printf used here instead of debug, so unknown opcodes are always reported...
printf("Unimplemented opcode 0x%02x (%d)\n", op, op);
printf("\tUses var %d\n", var);
printf("\tArg count = %d\n", argc);
if (argc)
printf("\tArgs: ");
for (uint16 i = 0; i < argc; i++) {
if (i == argc - 1)
printf("%d\n", argv[i]);
else
printf("%d, ", argv[i]);
warning("Unimplemented opcode 0x%02x (%d)", op, op);
warning("\tUses var %d", var);
warning("\tArg count = %d", argc);
if (argc) {
Common::String str;
str += Common::String::format("%d", argv[0]);
for (uint16 i = 1; i < argc; i++) {
str += Common::String::format(", %d", argv[i]);
}
warning("\tArgs: %s\n", str.c_str());
}
}
@ -1529,7 +1528,7 @@ void MystScriptParser::opcode_102(uint16 op, uint16 var, uint16 argc, uint16 *ar
debugC(kDebugScript, "\tstartTime: %d", startTime);
debugC(kDebugScript, "\tendTime: %d", endTime);
printf("TODO: Opcode %d Movie Time Index %d to %d\n", op, startTime, endTime);
warning("TODO: Opcode %d Movie Time Index %d to %d", op, startTime, endTime);
// TODO: Need version of playMovie blocking which allows selection
// of start and finish points.
_vm->_video->playMovie(_vm->wrapMovieFilename("bkroom", kStoneshipStack), 159, 99);
@ -2488,7 +2487,7 @@ void MystScriptParser::opcode_121(uint16 op, uint16 var, uint16 argc, uint16 *ar
uint16 startTime = argv[0];
uint16 endTime = argv[1];
printf("TODO: Opcode %d Movie Time Index %d to %d\n", op, startTime, endTime);
warning("TODO: Opcode %d Movie Time Index %d to %d\n", op, startTime, endTime);
// TODO: Need version of playMovie blocking which allows selection
// of start and finish points.
_vm->_video->playMovie(_vm->wrapMovieFilename("ewindow", kMechanicalStack), 253, 0);
@ -2550,7 +2549,7 @@ void MystScriptParser::opcode_123(uint16 op, uint16 var, uint16 argc, uint16 *ar
uint16 start_time = argv[0];
uint16 end_time = argv[1];
printf("TODO: Opcode %d Movie Time Index %d to %d\n", op, start_time, end_time);
warning("TODO: Opcode %d Movie Time Index %d to %d\n", op, start_time, end_time);
// TODO: Need version of playMovie blocking which allows selection
// of start and finish points.
// TODO: Not 100% sure about movie position

View file

@ -157,14 +157,14 @@ void RivenScript::setupOpcodes() {
static void printTabs(byte tabs) {
for (byte i = 0; i < tabs; i++)
printf ("\t");
debugN("\t");
}
void RivenScript::dumpScript(Common::StringArray varNames, Common::StringArray xNames, byte tabs) {
if (_stream->pos() != 0)
_stream->seek(0);
printTabs(tabs); printf ("Stream Type %d:\n", _scriptType);
printTabs(tabs); debugN("Stream Type %d:\n", _scriptType);
dumpCommands(varNames, xNames, tabs + 1);
}
@ -178,50 +178,50 @@ void RivenScript::dumpCommands(Common::StringArray varNames, Common::StringArray
if (_stream->readUint16BE() != 2)
warning ("if-then-else unknown value is not 2");
uint16 var = _stream->readUint16BE();
printTabs(tabs); printf("switch (%s) {\n", varNames[var].c_str());
printTabs(tabs); debugN("switch (%s) {\n", varNames[var].c_str());
uint16 logicBlockCount = _stream->readUint16BE();
for (uint16 j = 0; j < logicBlockCount; j++) {
uint16 varCheck = _stream->readUint16BE();
printTabs(tabs + 1);
if (varCheck == 0xFFFF)
printf("default:\n");
debugN("default:\n");
else
printf("case %d:\n", varCheck);
debugN("case %d:\n", varCheck);
dumpCommands(varNames, xNames, tabs + 2);
printTabs(tabs + 2); printf("break;\n");
printTabs(tabs + 2); debugN("break;\n");
}
printTabs(tabs); printf("}\n");
printTabs(tabs); debugN("}\n");
} else if (command == 7) { // Use the variable name
_stream->readUint16BE(); // Skip the opcode var count
printTabs(tabs);
uint16 var = _stream->readUint16BE();
printf("%s = %d;\n", varNames[var].c_str(), _stream->readUint16BE());
debugN("%s = %d;\n", varNames[var].c_str(), _stream->readUint16BE());
} else if (command == 17) { // Use the external command name
_stream->readUint16BE(); // Skip the opcode var count
printTabs(tabs);
printf("%s(", xNames[_stream->readUint16BE()].c_str());
debugN("%s(", xNames[_stream->readUint16BE()].c_str());
uint16 varCount = _stream->readUint16BE();
for (uint16 j = 0; j < varCount; j++) {
printf("%d", _stream->readUint16BE());
debugN("%d", _stream->readUint16BE());
if (j != varCount - 1)
printf(", ");
debugN(", ");
}
printf (");\n");
debugN(");\n");
} else if (command == 24) { // Use the variable name
_stream->readUint16BE(); // Skip the opcode var count
printTabs(tabs);
uint16 var = _stream->readUint16BE();
printf ("%s += %d;\n", varNames[var].c_str(), _stream->readUint16BE());
debugN("%s += %d;\n", varNames[var].c_str(), _stream->readUint16BE());
} else {
printTabs(tabs);
uint16 varCount = _stream->readUint16BE();
printf("%s(", _opcodes[command].desc);
debugN("%s(", _opcodes[command].desc);
for (uint16 j = 0; j < varCount; j++) {
printf("%d", _stream->readUint16BE());
debugN("%d", _stream->readUint16BE());
if (j != varCount - 1)
printf(", ");
debugN(", ");
}
printf(");\n");
debugN(");\n");
}
}
}
@ -513,12 +513,12 @@ void RivenScript::fadeAmbientSounds(uint16 op, uint16 argc, uint16 *argv) {
// Command 38: Play a movie with extra parameters (movie id, delay high, delay low, record type, record id)
void RivenScript::complexPlayMovie(uint16 op, uint16 argc, uint16 *argv) {
warning("STUB: complexPlayMovie");
printf ("\tMovie ID = %d\n", argv[0]);
printf ("\tDelay = %d\n", (argv[1] << 16) + argv[2]);
debugN("\tMovie ID = %d\n", argv[0]);
debugN("\tDelay = %d\n", (argv[1] << 16) + argv[2]);
if (argv[3] == 0) {
printf ("\tDraw PLST %d\n", argv[4]);
debugN("\tDraw PLST %d\n", argv[4]);
} else if (argv[3] == 40) {
printf ("\tPlay SLST %d\n", argv[4]);
debugN("\tPlay SLST %d\n", argv[4]);
} else {
error("Unknown complexPlayMovie record type %d", argv[3]);
}