[Scummvm-git-logs] scummvm master -> 35792058b058f86308edf0572dbdc6c1b2d34fca
dreammaster
noreply at scummvm.org
Tue Oct 29 04:40:25 UTC 2024
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:
d436a6bc1d M4: RIDDLE: Added named global/reg params to script instruction output
35792058b0 M4: RIDDLE: Guard against invalid facings in ws_get_walker_info
Commit: d436a6bc1d846c32099c4e67514275caa94b6e45
https://github.com/scummvm/scummvm/commit/d436a6bc1d846c32099c4e67514275caa94b6e45
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2024-10-28T21:40:12-07:00
Commit Message:
M4: RIDDLE: Added named global/reg params to script instruction output
Changed paths:
engines/m4/dbg/dbg_wscript.cpp
engines/m4/dbg/dbg_wscript.h
engines/m4/riddle/triggers.cpp
engines/m4/wscript/ws_cruncher.cpp
diff --git a/engines/m4/dbg/dbg_wscript.cpp b/engines/m4/dbg/dbg_wscript.cpp
index b323a75bb1a..1932de3103f 100644
--- a/engines/m4/dbg/dbg_wscript.cpp
+++ b/engines/m4/dbg/dbg_wscript.cpp
@@ -101,6 +101,84 @@ static const char *PCODE_OPCODES[40] = {
"op_CLOSE_STREAM_SS"
};
+static const char *GLOBAL_NAMES[39] = {
+ "GLB_TIM",
+ "GLB_WATCH_DOG",
+ "GLB_MIN_Y",
+ "GLB_MAX_Y",
+ "GLB_MIN_SCALE",
+ "GLB_MAX_SCALE",
+ "GLB_SCALER",
+ "GLB_TEMP_1",
+ "GLB_TEMP_2",
+ "GLB_TEMP_3",
+ "GLB_TEMP_4",
+ "GLB_TEMP_5",
+ "GLB_TEMP_6",
+ "GLB_TEMP_7",
+ "GLB_TEMP_8",
+ "GLB_TEMP_9",
+ "GLB_TEMP_10",
+ "GLB_TEMP_11",
+ "GLB_TEMP_12",
+ "GLB_TEMP_13",
+ "GLB_TEMP_14",
+ "GLB_TEMP_15",
+ "GLB_TEMP_16",
+ "GLB_TEMP_17",
+ "GLB_TEMP_18",
+ "GLB_TEMP_19",
+ "GLB_TEMP_20",
+ "GLB_TEMP_21",
+ "GLB_TEMP_22",
+ "GLB_TEMP_23",
+ "GLB_TEMP_24",
+ "GLB_TEMP_25",
+ "GLB_TEMP_26",
+ "GLB_TEMP_27",
+ "GLB_TEMP_28",
+ "GLB_TEMP_29",
+ "GLB_TEMP_30",
+ "GLB_TEMP_31",
+ "GLB_TEMP_32",
+};
+
+static const char *REG_NAMES[33] = {
+ "IDX_TIMER",
+ "IDX_TAG",
+ "IDX_LAYER",
+ "IDX_W",
+ "IDX_H",
+ "IDX_X",
+ "IDX_Y",
+ "IDX_S",
+ "IDX_R",
+ "IDX_CELS_HASH",
+ "IDX_CELS_INDEX",
+ "IDX_CELS_COUNT",
+ "IDX_CELS_FRAME_RATE",
+ "IDX_CELS_PIX_SPEED",
+ "IDX_TARG_S",
+ "IDX_TARG_R",
+ "IDX_TARG_X",
+ "IDX_TARG_Y",
+ "IDX_DELTA_S",
+ "IDX_DELTA_R",
+ "IDX_DELTA_X",
+ "IDX_DELTA_Y",
+ "IDX_VELOCITY",
+ "IDX_THETA",
+ "IDX_ZTEMP1",
+ "IDX_ZTEMP2",
+ "IDX_ZTEMP3",
+ "IDX_ZTEMP4",
+ "IDX_ZTEMP5",
+ "IDX_ZTEMP6",
+ "IDX_ZTEMP7",
+ "IDX_ZTEMP8",
+ "IDX_MACH_ID"
+};
+
static char g_instructionText[256];
bool g_hasParams;
bool g_isPcode;
@@ -144,6 +222,28 @@ void dbg_AddParamToCurrMachInstr(const char *param) {
}
}
+void dbg_AddGlobalParamToCurrMachInstr(int num, const char *prefix) {
+ if (debugChannelSet(1, kDebugScripts)) {
+ Common::String param;
+ if (prefix && *prefix)
+ param = Common::String::format("%s ", prefix);
+ param += (num < 39) ? GLOBAL_NAMES[num] :
+ Common::String::format("REG %d", num);
+ dbg_AddParamToCurrMachInstr(param.c_str());
+ }
+}
+
+void dbg_AddRegParamToCurrMachInstr(int num, const char *prefix) {
+ if (debugChannelSet(1, kDebugScripts)) {
+ Common::String param;
+ if (prefix && *prefix)
+ param = Common::String::format("%s ", prefix);
+ param += (num < 33) ? REG_NAMES[num] :
+ Common::String::format("REG %d", num);
+ dbg_AddParamToCurrMachInstr(param.c_str());
+ }
+}
+
void dbg_EndCurrMachInstr() {
debugC(1, kDebugScripts, "%s", g_instructionText);
}
diff --git a/engines/m4/dbg/dbg_wscript.h b/engines/m4/dbg/dbg_wscript.h
index fe61b18d82c..cde792be1c8 100644
--- a/engines/m4/dbg/dbg_wscript.h
+++ b/engines/m4/dbg/dbg_wscript.h
@@ -36,6 +36,9 @@ extern void dbg_SetCurrMachInstr(machine *m, int32 pcOffset, bool isPcode);
extern void dbg_EndCurrMachInstr();
extern void dbg_AddOpcodeToMachineInstr(int instruction);
extern void dbg_AddParamToCurrMachInstr(const char *param);
+extern void dbg_AddGlobalParamToCurrMachInstr(int num, const char *prefix = nullptr);
+extern void dbg_AddRegParamToCurrMachInstr(int num, const char *prefix = nullptr);
+
extern void dbg_ws_update();
extern void dbg_LaunchSequence(Anim8 *myAnim8);
diff --git a/engines/m4/riddle/triggers.cpp b/engines/m4/riddle/triggers.cpp
index 36e59ae8ff4..e8d48df552a 100644
--- a/engines/m4/riddle/triggers.cpp
+++ b/engines/m4/riddle/triggers.cpp
@@ -24,6 +24,7 @@
#include "m4/adv_r/adv_control.h"
#include "m4/core/imath.h"
#include "m4/graphics/gr_series.h"
+#include "m4/detection.h"
namespace M4 {
namespace Riddle {
@@ -119,6 +120,8 @@ void sendWSMessage_10000(machine *mach, int destX, int destY, int facing, int tr
_G(globals)[GLB_TEMP_5] = kernel_trigger_create(trigger);
_G(globals)[GLB_TEMP_6] = complete_walk << 16;
+ debugC(1, kDebugMessages, "STARTWALK dest=(%d,%d), facing=%d, trigger=%d, complete_walk=%d",
+ destX, destY, facing, trigger, complete_walk);
sendWSMessage(STARTWALK << 16, 0, mach, 0, nullptr, 1);
}
diff --git a/engines/m4/wscript/ws_cruncher.cpp b/engines/m4/wscript/ws_cruncher.cpp
index 1e8725b8d58..1b33f762289 100644
--- a/engines/m4/wscript/ws_cruncher.cpp
+++ b/engines/m4/wscript/ws_cruncher.cpp
@@ -391,7 +391,7 @@ static bool ExtractArg(Anim8 *myAnim8, int32 myFormat, int32 myData, frac16 **ar
int32 myIndex;
Anim8 *parentAnim8;
uint32 *dataArray;
- Common::String param;
+ Common::String prefix;
// If the format indicates the argument is a local source (parent, register, or data)
if (myFormat == FMT_LOCAL_SRC) {
@@ -403,7 +403,7 @@ static bool ExtractArg(Anim8 *myAnim8, int32 myFormat, int32 myData, frac16 **ar
// Find out if the index has been previously stored in a special index register
if (myData & REG_SET_IDX_REG) {
myIndex = _GWS(indexReg);
- param = "S";
+ prefix = "S";
} else {
// Else the index is part of the data segment for this arg
myIndex = myData & REG_SET_IDX;
@@ -425,7 +425,8 @@ static bool ExtractArg(Anim8 *myAnim8, int32 myFormat, int32 myData, frac16 **ar
return false;
}
*argPtr = &parentAnim8->myRegs[myIndex];
- param += Common::String::format("PREG %d", myIndex);
+ prefix += "P";
+ dbg_AddRegParamToCurrMachInstr(myIndex, prefix.c_str());
break;
case LOCAL_FMT_REG:
@@ -436,7 +437,7 @@ static bool ExtractArg(Anim8 *myAnim8, int32 myFormat, int32 myData, frac16 **ar
return false;
}
*argPtr = &myAnim8->myRegs[myIndex];
- param = Common::String::format("REG %d", myIndex);
+ dbg_AddRegParamToCurrMachInstr(myIndex, prefix.c_str());
break;
case LOCAL_FMT_DATA:
@@ -452,7 +453,8 @@ static bool ExtractArg(Anim8 *myAnim8, int32 myFormat, int32 myData, frac16 **ar
// Copy the data field into dataArg1, and set myArg1 to point to this location
*argValue = (int32)FROM_LE_32(dataArray[myIndex]);
*argPtr = argValue;
- param = Common::String::format("DATA %d", myIndex);
+ prefix += Common::String::format("DATA %d", myIndex);
+ dbg_AddParamToCurrMachInstr(prefix.c_str());
break;
}
} else if (myFormat == FMT_GLOBAL_SRC) {
@@ -460,7 +462,7 @@ static bool ExtractArg(Anim8 *myAnim8, int32 myFormat, int32 myData, frac16 **ar
// Find out if the index has been previously stored in a special index register
if (myData & REG_SET_IDX_REG) {
myIndex = _GWS(indexReg);
- param = "S";
+ prefix = "S";
} else {
// Else the index is part of the data segment for this arg
myIndex = myData & REG_SET_IDX;
@@ -468,7 +470,7 @@ static bool ExtractArg(Anim8 *myAnim8, int32 myFormat, int32 myData, frac16 **ar
// Finally, set myArg1 to point to the location in the ws_globals array, whichever index
*argPtr = &(_GWS(ws_globals)[myIndex]);
- param += Common::String::format("GLOB %d", myIndex);
+ dbg_AddGlobalParamToCurrMachInstr(myIndex, prefix.c_str());
} else {
// Else the argument is not a variable, but an actual value
@@ -483,11 +485,10 @@ static bool ExtractArg(Anim8 *myAnim8, int32 myFormat, int32 myData, frac16 **ar
// myArg1 will point to this location
*argPtr = argValue;
- param += Common::String::format("%d", *argValue);
+ prefix += Common::String::format("%d", *argValue);
+ dbg_AddParamToCurrMachInstr(prefix.c_str());
}
- dbg_AddParamToCurrMachInstr(param.c_str());
-
return true;
}
Commit: 35792058b058f86308edf0572dbdc6c1b2d34fca
https://github.com/scummvm/scummvm/commit/35792058b058f86308edf0572dbdc6c1b2d34fca
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2024-10-28T21:40:13-07:00
Commit Message:
M4: RIDDLE: Guard against invalid facings in ws_get_walker_info
Changed paths:
engines/m4/adv_r/adv_walk.cpp
diff --git a/engines/m4/adv_r/adv_walk.cpp b/engines/m4/adv_r/adv_walk.cpp
index bf6cfe5d4c1..3a9c930cb70 100644
--- a/engines/m4/adv_r/adv_walk.cpp
+++ b/engines/m4/adv_r/adv_walk.cpp
@@ -395,16 +395,16 @@ void ws_get_walker_info(machine *myWalker, int32 *x, int32 *y, int32 *s, int32 *
*layer = myAnim8->myRegs[IDX_LAYER] >> 16;
}
if (facing) {
- int index;
- if (myAnim8->myRegs[IDX_W] < 0) {
- // Currently walker final facing can be found in 55
- index = 9 - (myAnim8->myRegs[IDX_CELS_HASH] >> 24);
- } else {
- // Currently walker final facing can be found in 55
- index = myAnim8->myRegs[IDX_CELS_HASH] >> 24;
- }
+ int index = myAnim8->myRegs[IDX_CELS_HASH] >> 24;
+
+ // WORKAROUND: At the very least, Mei Chen in Riddle room 201
+ // produces a negative index value. This ensures indexes are valid
+ if (index < 0 || index > 9)
+ index = 0;
+
+ if (myAnim8->myRegs[IDX_W] < 0)
+ index = 9 - index;
- assert(index >= 0 && index < 10);
*facing = facings[index];
}
}
More information about the Scummvm-git-logs
mailing list