[Scummvm-git-logs] scummvm master -> b2b75baad5f6fe0c72b6c08334b59775cceb1419
OMGPizzaGuy
noreply at scummvm.org
Fri Dec 30 04:10:11 UTC 2022
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
a9297cbb45 ULTIMA: Move debug channels to detection
b2b75baad5 ULTIMA8: Update and enable commands for usecode tracing
Commit: a9297cbb45e2a81af7abc8b0635eae537cf0fd5e
https://github.com/scummvm/scummvm/commit/a9297cbb45e2a81af7abc8b0635eae537cf0fd5e
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2022-12-29T22:09:12-06:00
Commit Message:
ULTIMA: Move debug channels to detection
Changed paths:
engines/ultima/detection.cpp
engines/ultima/detection.h
engines/ultima/shared/engine/ultima.cpp
diff --git a/engines/ultima/detection.cpp b/engines/ultima/detection.cpp
index 580275e6562..86111c0812b 100644
--- a/engines/ultima/detection.cpp
+++ b/engines/ultima/detection.cpp
@@ -25,6 +25,7 @@
#include "ultima/detection.h"
#include "ultima/detection_tables.h"
+#include "ultima/ultima.h"
namespace Ultima {
@@ -49,6 +50,13 @@ static const PlainGameDescriptor ULTIMA_GAMES[] = {
} // End of namespace Ultima
+const DebugChannelDef UltimaMetaEngineDetection::debugFlagList[] = {
+ {Ultima::kDebugPath, "Path", "Pathfinding debug level"},
+ {Ultima::kDebugGraphics, "Graphics", "Graphics debug level"},
+ {Ultima::kDebugVideo, "Video", "Video playback debug level"},
+ DEBUG_CHANNEL_END
+};
+
UltimaMetaEngineDetection::UltimaMetaEngineDetection() : AdvancedMetaEngineDetection(Ultima::GAME_DESCRIPTIONS,
sizeof(Ultima::UltimaGameDescription), Ultima::ULTIMA_GAMES) {
static const char *const DIRECTORY_GLOBS[2] = { "usecode", 0 };
diff --git a/engines/ultima/detection.h b/engines/ultima/detection.h
index ee85c1f4cec..2f92fc05ffc 100644
--- a/engines/ultima/detection.h
+++ b/engines/ultima/detection.h
@@ -83,6 +83,8 @@ struct UltimaGameDescription {
} // End of namespace Ultima
class UltimaMetaEngineDetection : public AdvancedMetaEngineDetection {
+ static const DebugChannelDef debugFlagList[];
+
public:
UltimaMetaEngineDetection();
~UltimaMetaEngineDetection() override {}
@@ -98,6 +100,10 @@ public:
const char *getOriginalCopyright() const override {
return "Ultima Games (C) 1980-1995 Origin Systems Inc.";
}
+
+ const DebugChannelDef *getDebugChannels() const override {
+ return debugFlagList;
+ }
};
#endif
diff --git a/engines/ultima/shared/engine/ultima.cpp b/engines/ultima/shared/engine/ultima.cpp
index 2a77bad4a46..dce15cf0b69 100644
--- a/engines/ultima/shared/engine/ultima.cpp
+++ b/engines/ultima/shared/engine/ultima.cpp
@@ -48,10 +48,6 @@ bool UltimaEngine::initialize() {
Common::String folder;
int reqMajorVersion, reqMinorVersion;
- DebugMan.addDebugChannel(kDebugPath, "Path", "Pathfinding debug level");
- DebugMan.addDebugChannel(kDebugGraphics, "Graphics", "Graphics debug level");
- DebugMan.addDebugChannel(kDebugVideo, "Video", "Debug video and audio playback");
-
// Call syncSoundSettings to get default volumes set
syncSoundSettings();
Commit: b2b75baad5f6fe0c72b6c08334b59775cceb1419
https://github.com/scummvm/scummvm/commit/b2b75baad5f6fe0c72b6c08334b59775cceb1419
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2022-12-29T22:09:12-06:00
Commit Message:
ULTIMA8: Update and enable commands for usecode tracing
Basic infomation logged in usecode tracing, Define DEBUG_USECODE for detailed opcode tracing.
Changed paths:
engines/ultima/ultima8/misc/debugger.cpp
engines/ultima/ultima8/misc/debugger.h
engines/ultima/ultima8/usecode/uc_machine.cpp
engines/ultima/ultima8/usecode/uc_machine.h
diff --git a/engines/ultima/ultima8/misc/debugger.cpp b/engines/ultima/ultima8/misc/debugger.cpp
index fdd6098fdc7..90d54b2468c 100644
--- a/engines/ultima/ultima8/misc/debugger.cpp
+++ b/engines/ultima/ultima8/misc/debugger.cpp
@@ -190,14 +190,11 @@ Debugger::Debugger() : Shared::Debugger() {
registerCmd("UCMachine::getGlobal", WRAP_METHOD(Debugger, cmdGetGlobal));
registerCmd("UCMachine::setGlobal", WRAP_METHOD(Debugger, cmdSetGlobal));
-#ifdef DEBUG
registerCmd("UCMachine::traceObjID", WRAP_METHOD(Debugger, cmdTraceObjID));
registerCmd("UCMachine::tracePID", WRAP_METHOD(Debugger, cmdTracePID));
registerCmd("UCMachine::traceClass", WRAP_METHOD(Debugger, cmdTraceClass));
- registerCmd("UCMachine::traceEvents", WRAP_METHOD(Debugger, cmdTraceEvents));
registerCmd("UCMachine::traceAll", WRAP_METHOD(Debugger, cmdTraceAll));
registerCmd("UCMachine::stopTrace", WRAP_METHOD(Debugger, cmdStopTrace));
-#endif
registerCmd("FastAreaVisGump::toggle", WRAP_METHOD(Debugger, cmdToggleFastArea));
registerCmd("InverterProcess::invertScreen", WRAP_METHOD(Debugger, cmdInvertScreen));
@@ -1618,8 +1615,6 @@ bool Debugger::cmdSetGlobal(int argc, const char **argv) {
return true;
}
-#ifdef DEBUG
-
bool Debugger::cmdTracePID(int argc, const char **argv) {
if (argc != 2) {
debugPrintf("Usage: UCMachine::tracePID _pid\n");
@@ -1677,15 +1672,6 @@ bool Debugger::cmdTraceAll(int argc, const char **argv) {
return true;
}
-bool Debugger::cmdTraceEvents(int argc, const char **argv) {
- UCMachine *uc = UCMachine::get_instance();
- uc->_tracingEnabled = true;
- uc->_traceEvents = true;
-
- debugPrintf("UCMachine: tracing usecode events\n");
- return true;
-}
-
bool Debugger::cmdStopTrace(int argc, const char **argv) {
UCMachine *uc = UCMachine::get_instance();
uc->_traceObjIDs.clear();
@@ -1693,15 +1679,11 @@ bool Debugger::cmdStopTrace(int argc, const char **argv) {
uc->_traceClasses.clear();
uc->_tracingEnabled = false;
uc->_traceAll = false;
- uc->_traceEvents = false;
debugPrintf("Trace stopped\n");
return true;
}
-#endif
-
-
bool Debugger::cmdVerifyQuit(int argc, const char **argv) {
QuitGump::verifyQuit();
return false;
diff --git a/engines/ultima/ultima8/misc/debugger.h b/engines/ultima/ultima8/misc/debugger.h
index cca6b5fd64b..b8a4d1c0ccb 100644
--- a/engines/ultima/ultima8/misc/debugger.h
+++ b/engines/ultima/ultima8/misc/debugger.h
@@ -234,14 +234,11 @@ private:
// UCMachine
bool cmdGetGlobal(int argc, const char **argv);
bool cmdSetGlobal(int argc, const char **argv);
-#ifdef DEBUG
bool cmdTracePID(int argc, const char **argv);
bool cmdTraceObjID(int argc, const char **argv);
bool cmdTraceClass(int argc, const char **argv);
bool cmdTraceAll(int argc, const char **argv);
- bool cmdTraceEvents(int argc, const char **argv);
bool cmdStopTrace(int argc, const char **argv);
-#endif
// Miscellaneous
bool cmdToggleFastArea(int argc, const char **argv);
diff --git a/engines/ultima/ultima8/usecode/uc_machine.cpp b/engines/ultima/ultima8/usecode/uc_machine.cpp
index e52b238aee1..139fe130450 100644
--- a/engines/ultima/ultima8/usecode/uc_machine.cpp
+++ b/engines/ultima/ultima8/usecode/uc_machine.cpp
@@ -43,13 +43,15 @@
namespace Ultima {
namespace Ultima8 {
-#ifdef DEBUG
-#define LOGPF(X) do { if (trace_show(trace_pid, trace_objid, trace_classid)) pout.Print X; } while (0)
+//#define DEBUG_USECODE
+
+#ifdef DEBUG_USECODE
+#define TRACE_OP(format, ...) if (trace) debug(format, __VA_ARGS__)
#else
-#define LOGPF(X)
+#define TRACE_OP(format, ...)
#endif
-#ifdef DEBUG
+#ifdef DEBUG_USECODE
static const char *print_bp(const int16 offset) {
static char str[32];
snprintf(str, 32, "[BP%c%02Xh]", offset < 0 ? '-' : '+',
@@ -81,7 +83,7 @@ enum UCSegments {
UCMachine *UCMachine::_ucMachine = nullptr;
UCMachine::UCMachine(Intrinsic *iset, unsigned int icount) {
- debugN(MM_INFO, "Creating UCMachine...\n");
+ debug(MM_INFO, "Creating UCMachine...");
_ucMachine = this;
@@ -107,15 +109,13 @@ UCMachine::UCMachine(Intrinsic *iset, unsigned int icount) {
_listIDs = new idMan(1, 65534, 128);
_stringIDs = new idMan(1, 65534, 256);
-#ifdef DEBUG
_tracingEnabled = false;
_traceAll = false;
-#endif
}
UCMachine::~UCMachine() {
- debugN(MM_INFO, "Destroying UCMachine...\n");
+ debug(MM_INFO, "Destroying UCMachine...");
_ucMachine = nullptr;
delete _globals;
@@ -125,7 +125,7 @@ UCMachine::~UCMachine() {
}
void UCMachine::reset() {
- debugN(MM_INFO, "Resetting UCMachine\n");
+ debug(MM_INFO, "Resetting UCMachine");
// clear _globals
_globals->setSize(0x1000);
@@ -159,15 +159,11 @@ void UCMachine::execProcess(UCProcess *p) {
p->_usecode->get_class_size(p->_classId) - base);
cs->seek(p->_ip);
-#ifdef DEBUG
- if (trace_show(p->_pid, p->_itemNum, p->_classId)) {
- pout << "tick " << Kernel::get_instance()->getTickNum()
- << ConsoleStream::hex << " running process " << p->_pid
- << ", item " << p->_itemNum << ", type " << p->_type
- << ", class " << p->_classId << ", offset " << p->_ip
- << ConsoleStream::dec << Std::endl;
+ bool trace = trace_show(p->_pid, p->_itemNum, p->_classId);
+ if (trace) {
+ debug("tick %u running process %u, item %u, type %u, class %u, offset %u",
+ Kernel::get_instance()->getTickNum(), p->_pid, p->_itemNum, p->_type, p->_classId, p->_ip);
}
-#endif
bool cede = false;
bool error = false;
@@ -179,15 +175,13 @@ void UCMachine::execProcess(UCProcess *p) {
uint8 opcode = cs->readByte();
-#ifdef DEBUG
- uint16 trace_classid = p->_classId;
- ObjId trace_objid = p->_itemNum;
- ProcId trace_pid = p->_pid;
+#ifdef DEBUG_USECODE
+ char op_info[32];
+ if (trace) {
+ snprintf(op_info, 32, "sp = %02X; %04X:%04X: %02X",
+ p->_stack.stacksize(), p->_classId, p->_ip, opcode);
+ }
#endif
-
- LOGPF(("sp = %02X; %04X:%04X: %02X\t",
- p->_stack.stacksize(), p->_classId, p->_ip, opcode));
-
int8 si8a, si8b;
uint8 ui8a;
uint16 ui16a, ui16b;
@@ -204,7 +198,7 @@ void UCMachine::execProcess(UCProcess *p) {
si8a = cs->readSByte();
ui16a = p->_stack.pop2();
p->_stack.assign1(p->_bp + si8a, static_cast<uint8>(ui16a));
- LOGPF(("pop byte\t%s = %02Xh\n", print_bp(si8a), ui16a));
+ TRACE_OP("%s\tpop byte\t%s = %02Xh", op_info, print_bp(si8a), ui16a);
break;
case 0x01:
@@ -213,7 +207,7 @@ void UCMachine::execProcess(UCProcess *p) {
si8a = cs->readSByte();
ui16a = p->_stack.pop2();
p->_stack.assign2(p->_bp + si8a, ui16a);
- LOGPF(("pop\t\t%s = %04Xh\n", print_bp(si8a), ui16a));
+ TRACE_OP("%s\tpop\t\t%s = %04Xh", op_info, print_bp(si8a), ui16a);
break;
case 0x02:
@@ -222,7 +216,7 @@ void UCMachine::execProcess(UCProcess *p) {
si8a = cs->readSByte();
ui32a = p->_stack.pop4();
p->_stack.assign4(p->_bp + si8a, ui32a);
- LOGPF(("pop dword\t%s = %08Xh\n", print_bp(si8a), ui32a));
+ TRACE_OP("%s\tpop dword\t%s = %08Xh", op_info, print_bp(si8a), ui32a);
break;
case 0x03: {
@@ -233,7 +227,7 @@ void UCMachine::execProcess(UCProcess *p) {
uint8 buf[256];
p->_stack.pop(buf, size);
p->_stack.assign(p->_bp + si8a, buf, size);
- LOGPF(("pop huge\t%s %i\n", print_bp(si8a), size));
+ TRACE_OP("%s\tpop huge\t%s %i", op_info, print_bp(si8a), size);
break;
}
@@ -245,7 +239,7 @@ void UCMachine::execProcess(UCProcess *p) {
case 0x08:
// 08
// pop 32bits into process result register
- LOGPF(("pop dword\tprocess result\n"));
+ TRACE_OP("%s\tpop dword\tprocess result", op_info);
p->_result = p->_stack.pop4();
break;
@@ -255,8 +249,8 @@ void UCMachine::execProcess(UCProcess *p) {
si8a = cs->readSByte();
ui32a = cs->readByte();
si8b = cs->readSByte();
- LOGPF(("assign element\t%s (%02X) (slist==%02X)\n",
- print_bp(si8a), ui32a, si8b));
+ TRACE_OP("%s\tassign element\t%s (%02X) (slist==%02X)",
+ op_info, print_bp(si8a), ui32a, si8b);
ui16a = p->_stack.pop2() - 1; // index
ui16b = p->_stack.access2(p->_bp + si8a);
UCList *l = getList(ui16b);
@@ -288,7 +282,7 @@ void UCMachine::execProcess(UCProcess *p) {
// push sign-extended 8 bit xx onto the stack as 16 bit
ui16a = cs->readSByte();
p->_stack.push2(ui16a);
- LOGPF(("push byte\t%04Xh\n", ui16a));
+ TRACE_OP("%s\tpush byte\t%04Xh", op_info, ui16a);
break;
case 0x0B:
@@ -296,7 +290,7 @@ void UCMachine::execProcess(UCProcess *p) {
// push 16 bit xxxx onto the stack
ui16a = cs->readUint16LE();
p->_stack.push2(ui16a);
- LOGPF(("push\t\t%04Xh\n", ui16a));
+ TRACE_OP("%s\tpush\t\t%04Xh", op_info, ui16a);
break;
case 0x0C:
@@ -304,7 +298,7 @@ void UCMachine::execProcess(UCProcess *p) {
// push 32 bit xxxxxxxx onto the stack
ui32a = cs->readUint32LE();
p->_stack.push4(ui32a);
- LOGPF(("push dword\t%08Xh\n", ui32a));
+ TRACE_OP("%s\tpush dword\t%08Xh", op_info, ui32a);
break;
case 0x0D: {
@@ -324,7 +318,7 @@ void UCMachine::execProcess(UCProcess *p) {
}
}
- LOGPF(("push string\t\"%s\"\n", str));
+ TRACE_OP("%s\tpush string\t\"%s\"", op_info, str);
ui16b = cs->readByte();
if (ui16b != 0) {
warning("Zero terminator missing in push string");
@@ -349,7 +343,7 @@ void UCMachine::execProcess(UCProcess *p) {
}
p->_stack.addSP(ui16a * (ui16b + 1));
p->_stack.push2(assignList(l));
- LOGPF(("create list\t%02X (%02X)\n", ui16b, ui16a));
+ TRACE_OP("%s\tcreate list\t%02X (%02X)", op_info, ui16b, ui16a);
break;
}
@@ -362,7 +356,8 @@ void UCMachine::execProcess(UCProcess *p) {
// NB: do not actually pop these argument bytes
uint16 arg_bytes = cs->readByte();
uint16 func = cs->readUint16LE();
- LOGPF(("calli\t\t%04Xh (%02Xh arg bytes) %s\n", func, arg_bytes, _convUse->intrinsics()[func]));
+ TRACE_OP("%s\tcalli\t\t%04Xh (%02Xh arg bytes) %s",
+ op_info, func, arg_bytes, _convUse->intrinsics()[func]);
// !constants
if (func >= _intrinsicCount || _intrinsics[func] == 0) {
@@ -431,7 +426,7 @@ void UCMachine::execProcess(UCProcess *p) {
// call function number yy yy of class xx xx
uint16 new_classid = cs->readUint16LE();
uint16 new_offset = cs->readUint16LE();
- LOGPF(("call\t\t%04X:%04X\n", new_classid, new_offset));
+ TRACE_OP("%s\tcall\t\t%04X:%04X", op_info, new_classid, new_offset);
if (GAME_IS_CRUSADER) {
new_offset = p->_usecode->get_class_event(new_classid,
new_offset);
@@ -455,14 +450,14 @@ void UCMachine::execProcess(UCProcess *p) {
// 12
// pop 16bits into temp register
p->_temp32 = p->_stack.pop2();
- LOGPF(("pop\t\ttemp = %04X\n", (p->_temp32 & 0xFFFF)));
+ TRACE_OP("%s\tpop\t\ttemp = %04X", op_info, (p->_temp32 & 0xFFFF));
break;
case 0x13:
// 13
// pop 32bits into temp register. (Not actually used in U8 or Crusader)
p->_temp32 = p->_stack.pop4();
- LOGPF(("pop long\t\ttemp = %08X\n", p->_temp32));
+ TRACE_OP("%s\tpop long\t\ttemp = %08X", op_info, p->_temp32);
break;
// Arithmetic
@@ -473,7 +468,7 @@ void UCMachine::execProcess(UCProcess *p) {
si16a = static_cast<int16>(p->_stack.pop2());
si16b = static_cast<int16>(p->_stack.pop2());
p->_stack.push2(static_cast<uint16>(si16a + si16b));
- LOGPF(("add\n"));
+ TRACE_OP("%s\tadd", op_info);
break;
case 0x15:
@@ -482,7 +477,7 @@ void UCMachine::execProcess(UCProcess *p) {
si32a = static_cast<int32>(p->_stack.pop4());
si32b = static_cast<int32>(p->_stack.pop4());
p->_stack.push4(static_cast<uint32>(si32a + si32b));
- LOGPF(("add long\n"));
+ TRACE_OP("%s\tadd long", op_info);
break;
case 0x16:
@@ -499,7 +494,7 @@ void UCMachine::execProcess(UCProcess *p) {
_stringHeap[ui16b] += getString(ui16a);
freeString(ui16a);
p->_stack.push2(ui16b);
- LOGPF(("concat\t\t= %s\n", _stringHeap[ui16b].c_str()));
+ TRACE_OP("%s\tconcat\t\t= %s", op_info, _stringHeap[ui16b].c_str());
break;
case 0x17: {
@@ -536,7 +531,7 @@ void UCMachine::execProcess(UCProcess *p) {
p->_stack.push2(0);
}
}
- LOGPF(("append\n"));
+ TRACE_OP("%s\tappend", op_info);
break;
}
// 0x18 EXCLUSIVE_ADD_LIST (Unused in U8 and Crusader)
@@ -561,7 +556,7 @@ void UCMachine::execProcess(UCProcess *p) {
freeStringList(ui16a); // contents are actually freed in unionSL
}
p->_stack.push2(ui16b);
- LOGPF(("union slist\t(%02X)\n", ui32a));
+ TRACE_OP("%s\tunion slist\t(%02X)", op_info, ui32a);
break;
}
case 0x1A: {
@@ -581,7 +576,7 @@ void UCMachine::execProcess(UCProcess *p) {
freeStringList(ui16a);
}
p->_stack.push2(ui16b);
- LOGPF(("remove slist\t(%02X)\n", ui32a));
+ TRACE_OP("%s\tremove slist\t(%02X)", op_info, ui32a);
break;
}
case 0x1B: {
@@ -602,7 +597,7 @@ void UCMachine::execProcess(UCProcess *p) {
freeList(ui16a);
}
p->_stack.push2(ui16b);
- LOGPF(("remove list\t(%02X)\n", ui32a));
+ TRACE_OP("%s\tremove list\t(%02X)", op_info, ui32a);
break;
}
case 0x1C:
@@ -611,7 +606,7 @@ void UCMachine::execProcess(UCProcess *p) {
si16a = static_cast<int16>(p->_stack.pop2());
si16b = static_cast<int16>(p->_stack.pop2());
p->_stack.push2(static_cast<uint16>(si16b - si16a));
- LOGPF(("sub\n"));
+ TRACE_OP("%s\tsub", op_info);
break;
case 0x1D:
@@ -620,7 +615,7 @@ void UCMachine::execProcess(UCProcess *p) {
si32a = static_cast<int32>(p->_stack.pop4());
si32b = static_cast<int32>(p->_stack.pop4());
p->_stack.push4(static_cast<uint32>(si32b - si32a));
- LOGPF(("sub long\n"));
+ TRACE_OP("%s\tsub long", op_info);
break;
case 0x1E:
@@ -629,7 +624,7 @@ void UCMachine::execProcess(UCProcess *p) {
si16a = static_cast<int16>(p->_stack.pop2());
si16b = static_cast<int16>(p->_stack.pop2());
p->_stack.push2(static_cast<uint16>(si16a * si16b));
- LOGPF(("mul\n"));
+ TRACE_OP("%s\tmul", op_info);
break;
case 0x1F:
@@ -638,7 +633,7 @@ void UCMachine::execProcess(UCProcess *p) {
si32a = static_cast<int32>(p->_stack.pop4());
si32b = static_cast<int32>(p->_stack.pop4());
p->_stack.push4(static_cast<uint32>(si32a * si32b));
- LOGPF(("mul long\n"));
+ TRACE_OP("%s\tmul long", op_info);
break;
case 0x20:
@@ -652,7 +647,7 @@ void UCMachine::execProcess(UCProcess *p) {
warning("0x20 division by zero.");
p->_stack.push2(0);
}
- LOGPF(("div\n"));
+ TRACE_OP("%s\tdiv", op_info);
break;
case 0x21:
@@ -666,7 +661,7 @@ void UCMachine::execProcess(UCProcess *p) {
warning("0x21 division by zero.");
p->_stack.push4(0);
}
- LOGPF(("div\n"));
+ TRACE_OP("%s\tdiv", op_info);
break;
case 0x22:
@@ -681,7 +676,7 @@ void UCMachine::execProcess(UCProcess *p) {
warning("0x22 division by zero.");
p->_stack.push2(0);
}
- LOGPF(("mod\n"));
+ TRACE_OP("%s\tmod", op_info);
break;
case 0x23:
@@ -695,7 +690,7 @@ void UCMachine::execProcess(UCProcess *p) {
warning("0x23 division by zero.");
p->_stack.push4(0);
}
- LOGPF(("mod long\n"));
+ TRACE_OP("%s\tmod long", op_info);
break;
case 0x24:
@@ -708,7 +703,7 @@ void UCMachine::execProcess(UCProcess *p) {
} else {
p->_stack.push2(0);
}
- LOGPF(("cmp\n"));
+ TRACE_OP("%s\tcmp", op_info);
break;
case 0x25:
@@ -721,7 +716,7 @@ void UCMachine::execProcess(UCProcess *p) {
} else {
p->_stack.push2(0);
}
- LOGPF(("cmp long\n"));
+ TRACE_OP("%s\tcmp long", op_info);
break;
case 0x26:
@@ -736,7 +731,7 @@ void UCMachine::execProcess(UCProcess *p) {
p->_stack.push2(0);
freeString(ui16a);
freeString(ui16b);
- LOGPF(("strcmp\n"));
+ TRACE_OP("%s\tstrcmp", op_info);
break;
// 0x27 EQUALS_HUGE (Unused in U8 and Crusader)
@@ -751,7 +746,7 @@ void UCMachine::execProcess(UCProcess *p) {
} else {
p->_stack.push2(0);
}
- LOGPF(("lt\n"));
+ TRACE_OP("%s\tlt", op_info);
break;
case 0x29:
@@ -764,7 +759,7 @@ void UCMachine::execProcess(UCProcess *p) {
} else {
p->_stack.push2(0);
}
- LOGPF(("lt long\n"));
+ TRACE_OP("%s\tlt long", op_info);
break;
case 0x2A:
@@ -777,7 +772,7 @@ void UCMachine::execProcess(UCProcess *p) {
} else {
p->_stack.push2(0);
}
- LOGPF(("le\n"));
+ TRACE_OP("%s\tle", op_info);
break;
case 0x2B:
@@ -790,7 +785,7 @@ void UCMachine::execProcess(UCProcess *p) {
} else {
p->_stack.push2(0);
}
- LOGPF(("le long\n"));
+ TRACE_OP("%s\tle long", op_info);
break;
case 0x2C:
@@ -803,7 +798,7 @@ void UCMachine::execProcess(UCProcess *p) {
} else {
p->_stack.push2(0);
}
- LOGPF(("gt\n"));
+ TRACE_OP("%s\tgt", op_info);
break;
case 0x2D:
@@ -816,7 +811,7 @@ void UCMachine::execProcess(UCProcess *p) {
} else {
p->_stack.push2(0);
}
- LOGPF(("gt long\n"));
+ TRACE_OP("%s\tgt long", op_info);
break;
case 0x2E:
@@ -829,7 +824,7 @@ void UCMachine::execProcess(UCProcess *p) {
} else {
p->_stack.push2(0);
}
- LOGPF(("ge\n"));
+ TRACE_OP("%s\tge", op_info);
break;
case 0x2F:
@@ -842,7 +837,7 @@ void UCMachine::execProcess(UCProcess *p) {
} else {
p->_stack.push2(0);
}
- LOGPF(("ge long\n"));
+ TRACE_OP("%s\tge long", op_info);
break;
case 0x30:
@@ -854,7 +849,7 @@ void UCMachine::execProcess(UCProcess *p) {
} else {
p->_stack.push2(0);
}
- LOGPF(("not\n"));
+ TRACE_OP("%s\tnot", op_info);
break;
case 0x31:
@@ -866,7 +861,7 @@ void UCMachine::execProcess(UCProcess *p) {
} else {
p->_stack.push2(0);
}
- LOGPF(("not long\n"));
+ TRACE_OP("%s\tnot long", op_info);
break;
case 0x32:
@@ -879,7 +874,7 @@ void UCMachine::execProcess(UCProcess *p) {
} else {
p->_stack.push2(0);
}
- LOGPF(("and\n"));
+ TRACE_OP("%s\tand", op_info);
break;
case 0x33:
@@ -892,7 +887,7 @@ void UCMachine::execProcess(UCProcess *p) {
} else {
p->_stack.push4(0);
}
- LOGPF(("and long\n"));
+ TRACE_OP("%s\tand long", op_info);
break;
case 0x34:
@@ -905,7 +900,7 @@ void UCMachine::execProcess(UCProcess *p) {
} else {
p->_stack.push2(0);
}
- LOGPF(("or\n"));
+ TRACE_OP("%s\tor", op_info);
break;
case 0x35:
@@ -918,7 +913,7 @@ void UCMachine::execProcess(UCProcess *p) {
} else {
p->_stack.push4(0);
}
- LOGPF(("or long\n"));
+ TRACE_OP("%s\tor long", op_info);
break;
case 0x36:
@@ -931,7 +926,7 @@ void UCMachine::execProcess(UCProcess *p) {
} else {
p->_stack.push2(0);
}
- LOGPF(("ne\n"));
+ TRACE_OP("%s\tne", op_info);
break;
case 0x37:
@@ -944,7 +939,7 @@ void UCMachine::execProcess(UCProcess *p) {
} else {
p->_stack.push2(0);
}
- LOGPF(("ne long\n"));
+ TRACE_OP("%s\tne long", op_info);
break;
case 0x38: {
@@ -979,7 +974,7 @@ void UCMachine::execProcess(UCProcess *p) {
freeList(ui16b);
}
- LOGPF(("in list\t\t%s slist==%02X\n", print_bp(ui16a), ui32a));
+ TRACE_OP("%s\tin list\t\t%s slist==%02X", op_info, print_bp(ui16a), ui32a);
break;
}
case 0x39:
@@ -988,7 +983,7 @@ void UCMachine::execProcess(UCProcess *p) {
ui16a = p->_stack.pop2();
ui16b = p->_stack.pop2();
p->_stack.push2(ui16a & ui16b);
- LOGPF(("bit_and\n"));
+ TRACE_OP("%s\tbit_and", op_info);
break;
case 0x3A:
@@ -997,7 +992,7 @@ void UCMachine::execProcess(UCProcess *p) {
ui16a = p->_stack.pop2();
ui16b = p->_stack.pop2();
p->_stack.push2(ui16a | ui16b);
- LOGPF(("bit_or\n"));
+ TRACE_OP("%s\tbit_or", op_info);
break;
case 0x3B:
@@ -1005,7 +1000,7 @@ void UCMachine::execProcess(UCProcess *p) {
// 16 bit bitwise not
ui16a = p->_stack.pop2();
p->_stack.push2(~ui16a);
- LOGPF(("bit_not\n"));
+ TRACE_OP("%s\tbit_not", op_info);
break;
case 0x3C:
@@ -1020,7 +1015,7 @@ void UCMachine::execProcess(UCProcess *p) {
si16a = static_cast<int16>(p->_stack.pop2());
}
p->_stack.push2(static_cast<uint16>(si16a << ui16b));
- LOGPF(("lsh\t%04Xh >> %xh = %xh\n", si16a, ui16b, si16a << ui16b));
+ TRACE_OP("%s\tlsh\t%04Xh >> %xh = %xh", op_info, si16a, ui16b, si16a << ui16b);
break;
case 0x3D:
@@ -1035,7 +1030,7 @@ void UCMachine::execProcess(UCProcess *p) {
si16a = static_cast<int16>(p->_stack.pop2());
}
p->_stack.push2(static_cast<uint16>(si16a >> ui16b));
- LOGPF(("rsh\t%04Xh >> %xh = %xh\n", si16a, ui16b, si16a >> ui16b));
+ TRACE_OP("%s\trsh\t%04Xh >> %xh = %xh", op_info, si16a, ui16b, si16a >> ui16b);
break;
case 0x3E:
@@ -1044,7 +1039,7 @@ void UCMachine::execProcess(UCProcess *p) {
si8a = cs->readSByte();
ui16a = static_cast<uint16>(static_cast<int8>(p->_stack.access1(p->_bp + si8a)));
p->_stack.push2(ui16a);
- LOGPF(("push byte\t%s = %02Xh\n", print_bp(si8a), ui16a));
+ TRACE_OP("%s\tpush byte\t%s = %02Xh", op_info, print_bp(si8a), ui16a);
break;
case 0x3F:
@@ -1053,7 +1048,7 @@ void UCMachine::execProcess(UCProcess *p) {
si8a = cs->readSByte();
ui16a = p->_stack.access2(p->_bp + si8a);
p->_stack.push2(ui16a);
- LOGPF(("push\t\t%s = %04Xh\n", print_bp(si8a), ui16a));
+ TRACE_OP("%s\tpush\t\t%s = %04Xh", op_info, print_bp(si8a), ui16a);
break;
case 0x40:
@@ -1062,7 +1057,7 @@ void UCMachine::execProcess(UCProcess *p) {
si8a = cs->readSByte();
ui32a = p->_stack.access4(p->_bp + si8a);
p->_stack.push4(ui32a);
- LOGPF(("push dword\t%s = %08Xh\n", print_bp(si8a), ui32a));
+ TRACE_OP("%s\tpush dword\t%s = %08Xh", op_info, print_bp(si8a), ui32a);
break;
case 0x41: {
@@ -1072,7 +1067,7 @@ void UCMachine::execProcess(UCProcess *p) {
si8a = cs->readSByte();
ui16a = p->_stack.access2(p->_bp + si8a);
p->_stack.push2(duplicateString(ui16a));
- LOGPF(("push string\t%s\n", print_bp(si8a)));
+ TRACE_OP("%s\tpush string\t%s", op_info, print_bp(si8a));
break;
}
case 0x42: {
@@ -1093,8 +1088,8 @@ void UCMachine::execProcess(UCProcess *p) {
}
uint16 newlistid = assignList(l);
p->_stack.push2(newlistid);
- LOGPF(("push list\t%s (%04X, copy %04X, %d elements)\n",
- print_bp(si8a), ui16b, newlistid, l->getSize()));
+ TRACE_OP("%s\tpush list\t%s (%04X, copy %04X, %d elements)",
+ op_info, print_bp(si8a), ui16b, newlistid, l->getSize());
break;
}
case 0x43: {
@@ -1114,7 +1109,7 @@ void UCMachine::execProcess(UCProcess *p) {
// error = true;
}
p->_stack.push2(assignList(l));
- LOGPF(("push slist\t%s\n", print_bp(si8a)));
+ TRACE_OP("%s\tpush slist\t%s", op_info, print_bp(si8a));
break;
}
case 0x44: {
@@ -1150,7 +1145,7 @@ void UCMachine::execProcess(UCProcess *p) {
}
}
}
- LOGPF(("push element\t%02X slist==%02X\n", ui32a, ui32b));
+ TRACE_OP("%s\tpush element\t%02X slist==%02X", op_info, ui32a, ui32b);
break;
}
case 0x45:
@@ -1159,7 +1154,7 @@ void UCMachine::execProcess(UCProcess *p) {
si8a = cs->readSByte();
ui16b = cs->readByte();
p->_stack.push(p->_stack.access(p->_bp + si8a), ui16b);
- LOGPF(("push huge\t%s %02X\n", print_bp(si8a), ui16b));
+ TRACE_OP("%s\tpush huge\t%s %02X", op_info, print_bp(si8a), ui16b);
break;
// 0x46 BYTE_MEMBER_REFERENCE (Unused)
@@ -1173,7 +1168,7 @@ void UCMachine::execProcess(UCProcess *p) {
// push 32 bit pointer address of BP+XX
si8a = cs->readSByte();
p->_stack.push4(stackToPtr(p->_pid, p->_bp + si8a));
- LOGPF(("push addr\t%s\n", print_bp(si8a)));
+ TRACE_OP("%s\tpush addr\t%s", op_info, print_bp(si8a));
break;
case 0x4C: {
@@ -1190,11 +1185,11 @@ void UCMachine::execProcess(UCProcess *p) {
ui16a))
error = true;
- LOGPF(("push indirect\t%02Xh bytes", ui16a));
- if (!error && ui16a == 2) {
- LOGPF((" = %04Xh\n", p->_stack.access2(p->_stack.getSP())));
+ if (!error && ui16a == 2) {
+ TRACE_OP("%s\tpush indirect\t%02Xh bytes = %04Xh",
+ op_info, ui16a, p->_stack.access2(p->_stack.getSP()));
} else {
- LOGPF(("\n"));
+ TRACE_OP("%s\tpush indirect\t%02Xh bytes", op_info, ui16a);
}
break;
}
@@ -1213,7 +1208,7 @@ void UCMachine::execProcess(UCProcess *p) {
error = true;
}
- LOGPF(("pop indirect\t%02Xh bytes\n", ui16a));
+ TRACE_OP("%s\tpop indirect\t%02Xh bytes", op_info, ui16a);
break;
}
@@ -1224,7 +1219,7 @@ void UCMachine::execProcess(UCProcess *p) {
ui16b = cs->readByte();
ui32a = _globals->getEntries(ui16a, ui16b);
p->_stack.push2(static_cast<uint16>(ui32a));
- LOGPF(("push\t\tglobal [%04X %02X] = %02X\n", ui16a, ui16b, ui32a));
+ TRACE_OP("%s\tpush\t\tglobal [%04X %02X] = %02X", op_info, ui16a, ui16b, ui32a);
break;
case 0x4F:
@@ -1246,21 +1241,21 @@ void UCMachine::execProcess(UCProcess *p) {
assert(_globals->getEntries(ui16a, ui16b) == ui32a);
}
- LOGPF(("pop\t\tglobal [%04X %02X] = %02X\n", ui16a, ui16b, ui32a));
+ TRACE_OP("%s\tpop\t\tglobal [%04X %02X] = %02X", op_info, ui16a, ui16b, ui32a);
break;
case 0x50:
// 50
// return from function
if (p->ret()) { // returning from process
- LOGPF(("ret\t\tfrom process\n"));
+ TRACE_OP("%s\tret\t\tfrom process", op_info);
p->terminateDeferred();
// return value is going to be stored somewhere,
// and some other process is probably waiting for it.
// So, we can't delete ourselves just yet.
} else {
- LOGPF(("ret\t\tto %04X:%04X\n", p->_classId, p->_ip));
+ TRACE_OP("%s\tret\t\tto %04X:%04X", op_info, p->_classId, p->_ip);
// return value is stored in _temp32 register
@@ -1284,11 +1279,9 @@ void UCMachine::execProcess(UCProcess *p) {
if (!ui16b) {
ui16a = cs->pos() + si16a;
cs->seek(ui16a);
- LOGPF(("jne\t\t%04hXh\t(to %04X) (taken)\n", si16a,
- cs->pos()));
+ TRACE_OP("%s\tjne\t\t%04hXh\t(to %04X) (taken)", op_info, si16a, cs->pos());
} else {
- LOGPF(("jne\t\t%04hXh\t(to %04X) (not taken)\n", si16a,
- cs->pos()));
+ TRACE_OP("%s\tjne\t\t%04hXh\t(to %04X) (not taken)", op_info, si16a, cs->pos());
}
break;
@@ -1298,13 +1291,13 @@ void UCMachine::execProcess(UCProcess *p) {
si16a = static_cast<int16>(cs->readUint16LE());
ui16a = cs->pos() + si16a;
cs->seek(ui16a);
- LOGPF(("jmp\t\t%04hXh\t(to %04X)\n", si16a, cs->pos()));
+ TRACE_OP("%s\tjmp\t\t%04hXh\t(to %04X)", op_info, si16a, cs->pos());
break;
case 0x53:
// 53
// suspend
- LOGPF(("suspend\n"));
+ TRACE_OP("%s\tsuspend", op_info);
go_until_cede = false;
cede = true;
break;
@@ -1334,7 +1327,7 @@ void UCMachine::execProcess(UCProcess *p) {
ui16a = p->_stack.pop2();
ui16b = p->_stack.pop2();
p->_stack.push2(ui16a); //!! which pid do we need to push!?
- LOGPF(("implies\n"));
+ TRACE_OP("%s\timplies", op_info);
Process *proc = Kernel::get_instance()->getProcess(ui16b);
Process *proc2 = Kernel::get_instance()->getProcess(ui16a);
@@ -1380,8 +1373,8 @@ void UCMachine::execProcess(UCProcess *p) {
uint32 thisptr = p->_stack.pop4();
- LOGPF(("spawn\t\t%02X %02X %04X:%04X\n",
- arg_bytes, this_size, classid, offset));
+ TRACE_OP("%s\tspawn\t\t%02X %02X %04X:%04X",
+ op_info, arg_bytes, this_size, classid, offset);
if (GAME_IS_CRUSADER) {
offset = p->_usecode->get_class_event(classid, offset);
@@ -1397,15 +1390,10 @@ void UCMachine::execProcess(UCProcess *p) {
// immediately, after which the current process resumes
p->_temp32 = Kernel::get_instance()->addProcessExec(newproc);
-#ifdef DEBUG
- if (trace_show(p->_pid, p->_itemNum, p->_classId)) {
- pout << "tick " << Kernel::get_instance()->getTickNum()
- << " (still) running process " << ConsoleStream::hex << p->_pid
- << ", item " << p->_itemNum << ", type " << p->_type
- << ", class " << p->_classId << ", offset " << p->_ip
- << ConsoleStream::dec << Std::endl;
+ if (trace) {
+ debug("tick %u (still) running process %u, item %u, type %u, class %u, offset %u",
+ Kernel::get_instance()->getTickNum(), p->_pid, p->_itemNum, p->_type, p->_classId, p->_ip);
}
-#endif
break;
}
@@ -1424,8 +1412,8 @@ void UCMachine::execProcess(UCProcess *p) {
// need the offset translation done in 0x57.
assert(GAME_IS_U8);
- debug(MM_INFO, "spawn inline\t%04X:%04X+%04X=%04X %02X %02X\n",
- classid, offset, delta, offset + delta, this_size, unknown);
+ TRACE_OP("%s\tspawn inline\t%04X:%04X+%04X=%04X %02X %02X",
+ op_info, classid, offset, delta, offset + delta, this_size, unknown);
uint32 thisptr = 0;
if (this_size > 0)
@@ -1436,14 +1424,11 @@ void UCMachine::execProcess(UCProcess *p) {
// as with 'spawn', run the spawned process once immediately
uint16 newpid = Kernel::get_instance()->addProcessExec(newproc);
-#ifdef DEBUG
- if (trace_show(p->_pid, p->_itemNum, p->_classId)) {
- pout << "tick " << Kernel::get_instance()->getTickNum()
- << ConsoleStream::hex << " (still) running process " << p->_pid
- << ", item " << p->_itemNum << ", class " << p->_classId
- << ", offset " << p->_ip << ConsoleStream::dec << Std::endl;
+ if (trace) {
+ debug("tick %u (still) running process %u, item %u, type %u, class %u, offset %u",
+ Kernel::get_instance()->getTickNum(), p->_pid, p->_itemNum, p->_type, p->_classId, p->_ip);
}
-#endif
+
p->_stack.push2(newpid); //! push pid of new proc
break;
}
@@ -1452,7 +1437,7 @@ void UCMachine::execProcess(UCProcess *p) {
// 59
// push current process id
p->_stack.push2(p->_pid);
- LOGPF(("push\t\tpid = %04Xh\n", p->_pid));
+ TRACE_OP("%s\tpush\t\tpid = %04Xh", op_info, p->_pid);
break;
case 0x5A:
@@ -1460,7 +1445,7 @@ void UCMachine::execProcess(UCProcess *p) {
// init function. xx = local var size
// sets xx bytes on stack to 0, moving sp
ui16a = cs->readByte();
- LOGPF(("init\t\t%02X\n", ui16a));
+ TRACE_OP("%s\tinit\t\t%02X", op_info, ui16a);
if (ui16a & 1) ui16a++; // 16-bit align
if (ui16a > 0) {
@@ -1472,8 +1457,7 @@ void UCMachine::execProcess(UCProcess *p) {
// 5B xx xx
// debug line no xx xx
ui16a = cs->readUint16LE(); // source line number
- debug(10, "ignore debug opcode %02X: line offset %d", opcode, ui16a);
- LOGPF(("line number %d\n", ui16a));
+ TRACE_OP("%s\tdebug\tline number %d", op_info, ui16a);
break;
case 0x5C: {
@@ -1485,8 +1469,7 @@ void UCMachine::execProcess(UCProcess *p) {
// skip over class name and null terminator
name[x] = cs->readByte();
}
- LOGPF(("line number %s %d\n", name, ui16a));
- debug(10, "ignore debug opcode %02X: %s line offset %d", opcode, name, ui16a);
+ TRACE_OP("%s\tdebug\tline number %d\t\"%s\"", op_info, opcode, ui16a, name);
break;
}
@@ -1495,7 +1478,7 @@ void UCMachine::execProcess(UCProcess *p) {
// push 8 bit value returned from function call
// (push temp8 as 16 bit value)
p->_stack.push2(static_cast<uint8>(p->_temp32 & 0xFF));
- LOGPF(("push byte\tretval = %02Xh\n", (p->_temp32 & 0xFF)));
+ TRACE_OP("%s\tpush byte\tretval = %02Xh", op_info, (p->_temp32 & 0xFF));
break;
case 0x5E:
@@ -1503,7 +1486,7 @@ void UCMachine::execProcess(UCProcess *p) {
// push 16 bit value returned from function call
// (push temp16)
p->_stack.push2(static_cast<uint16>(p->_temp32 & 0xFFFF));
- LOGPF(("push\t\tretval = %04Xh\n", (p->_temp32 & 0xFFFF)));
+ TRACE_OP("%s\tpush\t\tretval = %04Xh", op_info, (p->_temp32 & 0xFFFF));
break;
case 0x5F:
@@ -1511,7 +1494,7 @@ void UCMachine::execProcess(UCProcess *p) {
// push 32 bit value returned from function call
// (push _temp32)
p->_stack.push4(p->_temp32);
- LOGPF(("push long\t\tretval = %08Xh\n", p->_temp32));
+ TRACE_OP("%s\tpush long\t\tretval = %08Xh", op_info, p->_temp32);
break;
case 0x60:
@@ -1519,7 +1502,7 @@ void UCMachine::execProcess(UCProcess *p) {
// convert 16-bit to 32-bit int (sign extend)
si32a = static_cast<int16>(p->_stack.pop2());
p->_stack.push4(si32a);
- LOGPF(("int to long\n"));
+ TRACE_OP("%s\tint to long", op_info);
break;
case 0x61:
@@ -1527,7 +1510,7 @@ void UCMachine::execProcess(UCProcess *p) {
// convert 32-bit to 16-bit int
si16a = static_cast<int16>(p->_stack.pop4());
p->_stack.push2(si16a);
- LOGPF(("long to int\n"));
+ TRACE_OP("%s\tlong to int", op_info);
break;
case 0x62:
@@ -1536,7 +1519,7 @@ void UCMachine::execProcess(UCProcess *p) {
si8a = cs->readSByte();
ui16a = p->_stack.access2(p->_bp + si8a);
freeString(ui16a);
- LOGPF(("free string\t%s = %04X\n", print_bp(si8a), ui16a));
+ TRACE_OP("%s\tfree string\t%s = %04X", op_info, print_bp(si8a), ui16a);
break;
case 0x63:
@@ -1545,7 +1528,7 @@ void UCMachine::execProcess(UCProcess *p) {
si8a = cs->readSByte();
ui16a = p->_stack.access2(p->_bp + si8a);
freeStringList(ui16a);
- LOGPF(("free slist\t%s = %04X\n", print_bp(si8a), ui16a));
+ TRACE_OP("%s\tfree slist\t%s = %04X", op_info, print_bp(si8a), ui16a);
break;
case 0x64:
@@ -1554,7 +1537,7 @@ void UCMachine::execProcess(UCProcess *p) {
si8a = cs->readSByte();
ui16a = p->_stack.access2(p->_bp + si8a);
freeList(ui16a);
- LOGPF(("free list\t%s = %04X\n", print_bp(si8a), ui16a));
+ TRACE_OP("%s\tfree list\t%s = %04X", op_info, print_bp(si8a), ui16a);
break;
case 0x65:
@@ -1565,7 +1548,7 @@ void UCMachine::execProcess(UCProcess *p) {
si8a = cs->readSByte();
ui16a = p->_stack.access2(p->_stack.getSP() + si8a);
freeString(ui16a);
- LOGPF(("free string\t%s = %04X\n", print_sp(si8a), ui16a));
+ TRACE_OP("%s\tfree string\t%s = %04X", op_info, print_sp(si8a), ui16a);
break;
case 0x66:
@@ -1574,7 +1557,7 @@ void UCMachine::execProcess(UCProcess *p) {
si8a = cs->readSByte();
ui16a = p->_stack.access2(p->_stack.getSP() + si8a);
freeList(ui16a);
- LOGPF(("free list\t%s = %04X\n", print_sp(si8a), ui16a));
+ TRACE_OP("%s\tfree list\t%s = %04X", op_info, print_sp(si8a), ui16a);
break;
case 0x67:
@@ -1583,7 +1566,7 @@ void UCMachine::execProcess(UCProcess *p) {
si8a = cs->readSByte();
ui16a = p->_stack.access2(p->_stack.getSP() + si8a);
freeStringList(ui16a);
- LOGPF(("free slist\t%s = %04x\n", print_sp(si8a), ui16a));
+ TRACE_OP("%s\tfree slist\t%s = %04x", op_info, print_sp(si8a), ui16a);
break;
// 0x68 COPY_STRING (unused in U8 and Crusader)
@@ -1594,7 +1577,7 @@ void UCMachine::execProcess(UCProcess *p) {
si8a = cs->readSByte();
ui16a = p->_stack.access2(p->_bp + si8a);
p->_stack.push4(stringToPtr(ui16a));
- LOGPF(("str to ptr\t%s\n", print_bp(si8a)));
+ TRACE_OP("%s\tstr to ptr\t%s", op_info, print_bp(si8a));
break;
// 0x6A Convert pointer to string (unused in U8 and Crusader)
@@ -1604,7 +1587,7 @@ void UCMachine::execProcess(UCProcess *p) {
// pop a string and push 32 bit pointer to string
ui16a = p->_stack.pop2();
p->_stack.push4(stringToPtr(ui16a));
- LOGPF(("str to ptr\n"));
+ TRACE_OP("%s\tstr to ptr", op_info);
break;
case 0x6C:
@@ -1614,7 +1597,7 @@ void UCMachine::execProcess(UCProcess *p) {
// and add it to the "Free Me" list of the process
si8a = cs->readByte(); // index
ui8a = cs->readByte(); // type
- LOGPF(("param _pid chg\t%s, type=%u\n", print_bp(si8a), ui8a));
+ TRACE_OP("%s\tparam _pid chg\t%s, type=%u", op_info, print_bp(si8a), ui8a);
ui16a = p->_stack.access2(p->_bp + si8a);
switch (ui8a) {
@@ -1660,7 +1643,7 @@ void UCMachine::execProcess(UCProcess *p) {
case 0x6D:
// 6D
// push 32bit result of current process
- LOGPF(("push dword\tprocess result\n"));
+ TRACE_OP("%s\tpush dword\tprocess result", op_info);
p->_stack.push4(p->_result);
break;
@@ -1670,7 +1653,7 @@ void UCMachine::execProcess(UCProcess *p) {
// (effect on SP is the same as popping xx bytes)
si8a = cs->readSByte();
p->_stack.addSP(-si8a);
- LOGPF(("move sp\t\t%s%02Xh\n", si8a < 0 ? "-" : "", si8a < 0 ? -si8a : si8a));
+ TRACE_OP("%s\tmove sp\t\t%s%02Xh", op_info, si8a < 0 ? "-" : "", si8a < 0 ? -si8a : si8a);
break;
case 0x6F:
@@ -1678,7 +1661,7 @@ void UCMachine::execProcess(UCProcess *p) {
// push 32 pointer address of SP-xx
si8a = cs->readSByte();
p->_stack.push4(stackToPtr(p->_pid, static_cast<uint16>(p->_stack.getSP() - si8a)));
- LOGPF(("push addr\t%s\n", print_sp(-si8a)));
+ TRACE_OP("%s\tpush addr\t%s", op_info, print_sp(-si8a));
break;
// loop-related opcodes
@@ -1818,8 +1801,8 @@ void UCMachine::execProcess(UCProcess *p) {
delete[] script;
- LOGPF(("loop\t\t%s %02X %02X\n", print_bp(si16a),
- scriptsize, searchtype));
+ TRACE_OP("%s\tloop\t\t%s %02X %02X", op_info, print_bp(si16a),
+ scriptsize, searchtype);
}
}
// Intentional fall-through
@@ -1870,7 +1853,7 @@ void UCMachine::execProcess(UCProcess *p) {
}
if (opcode == 0x73) { // because of the fall-through
- LOGPF(("loopnext\n"));
+ TRACE_OP("%s\tloopnext", op_info);
}
break;
}
@@ -1880,7 +1863,7 @@ void UCMachine::execProcess(UCProcess *p) {
// add xx to the current 'loopscript'
ui8a = cs->readByte();
p->_stack.push1(ui8a);
- LOGPF(("loopscr\t\t%02X \"%c\"\n", ui8a, static_cast<char>(ui8a)));
+ TRACE_OP("%s\tloopscr\t\t%02X \"%c\"", op_info, ui8a, static_cast<char>(ui8a));
break;
case 0x75:
@@ -1915,11 +1898,11 @@ void UCMachine::execProcess(UCProcess *p) {
}
if (opcode == 0x75) {
- LOGPF(("for each\t%s (%02X) %04hX\n",
- print_bp(si8a), ui32a, si16a));
+ TRACE_OP("%s\tfor each\t%s (%02X) %04hX",
+ op_info, print_bp(si8a), ui32a, si16a);
} else {
- LOGPF(("for each str\t%s (%02X) %04hX\n",
- print_bp(si8a), ui32a, si16a));
+ TRACE_OP("%s\tfor each str\t%s (%02X) %04hX",
+ op_info, print_bp(si8a), ui32a, si16a);
}
// Increment the counter
@@ -1959,7 +1942,7 @@ void UCMachine::execProcess(UCProcess *p) {
// assigns item number and ProcessType
p->setItemNum(p->_stack.pop2());
p->setType(p->_stack.pop2());
- LOGPF(("set info itemno: %d type: %d\n", p->getItemNum(), p->getType()));
+ TRACE_OP("%s\tset info itemno: %d type: %d", op_info, p->getItemNum(), p->getType());
break;
case 0x78:
@@ -1970,15 +1953,14 @@ void UCMachine::execProcess(UCProcess *p) {
// Educated guess:
// Check if any other processes have the same (object,type) info
// set. If so, return from process.
- LOGPF(("process exclude"));
if (Kernel::get_instance()->
getNumProcesses(p->_itemNum, p->_type) > 1) {
// another process with this (object,type) is already running
p->terminateDeferred();
- LOGPF(("\t(terminating)\n"));
+ TRACE_OP("%s\tprocess exclude\t(terminating)", op_info);
} else {
- LOGPF(("\n"));
+ TRACE_OP("%s\tprocess exclude", op_info);
}
break;
@@ -1989,14 +1971,14 @@ void UCMachine::execProcess(UCProcess *p) {
ui16a = cs->readUint16LE(); // global address
ui32a = globalToPtr(ui16a);
p->_stack.push4(ui32a);
- LOGPF(("push global 0x%x (value: %x)\n", ui16a, ui32a));
+ TRACE_OP("%s\tpush global 0x%x (value: %x)", op_info, ui16a, ui32a);
break;
case 0x7A:
// 7A
// end of function
// shouldn't happen
- LOGPF(("end\n"));
+ TRACE_OP("%s\tend", op_info);
warning("end of function opcode %02X reached!", opcode);
error = true;
break;
diff --git a/engines/ultima/ultima8/usecode/uc_machine.h b/engines/ultima/ultima8/usecode/uc_machine.h
index bea27883feb..0fc9658ddb8 100644
--- a/engines/ultima/ultima8/usecode/uc_machine.h
+++ b/engines/ultima/ultima8/usecode/uc_machine.h
@@ -111,11 +111,9 @@ private:
static UCMachine *_ucMachine;
-#ifdef DEBUG
// tracing
bool _tracingEnabled;
bool _traceAll;
- bool _traceEvents;
Std::set<ObjId> _traceObjIDs;
Std::set<ProcId> _tracePIDs;
Std::set<uint16> _traceClasses;
@@ -129,11 +127,6 @@ private:
return false;
}
-public:
- bool trace_event() const {
- return (_tracingEnabled && (_traceAll || _traceEvents));
- }
-#endif
};
} // End of namespace Ultima8
More information about the Scummvm-git-logs
mailing list