[Scummvm-git-logs] scummvm master -> d7825f894fc85ea3521692128f6570925b187c28

npjg noreply at scummvm.org
Sat Jan 18 17:19:00 UTC 2025


This automated email contains information about 8 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
fd1b13a3f5 MEDIASTATION: Give the script constants header a better name
3129b6dd17 MEDIASTATION: Correct misunderstanding on float and int script var types
5de4835b2a MEDIASTATION: JANITORIAL: Clean script constant comments
2806bf4c40 MEDIASTATION: Also load child contexts when loading a context
c497af5aae MEDIASTATION: Add string representations of script constants
b99ff55763 MEDIASTATION: Implement negation (-) operator
20b47a3724 MEDIASTATION: JANITORIAL: Order module.mk
d7825f894f MEDIASTATION: Improve bytecode debug output with script constant strings


Commit: fd1b13a3f5cffe9aaa490aaa56807569b5be32b0
    https://github.com/scummvm/scummvm/commit/fd1b13a3f5cffe9aaa490aaa56807569b5be32b0
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2025-01-18T12:08:00-05:00

Commit Message:
MEDIASTATION: Give the script constants header a better name

Changed paths:
  A engines/mediastation/mediascript/scriptconstants.h
  R engines/mediastation/mediascript/builtins.h
    engines/mediastation/asset.h
    engines/mediastation/assets/canvas.h
    engines/mediastation/assets/font.h
    engines/mediastation/assets/hotspot.h
    engines/mediastation/assets/image.h
    engines/mediastation/assets/movie.h
    engines/mediastation/assets/palette.h
    engines/mediastation/assets/path.h
    engines/mediastation/assets/screen.h
    engines/mediastation/assets/sound.h
    engines/mediastation/assets/sprite.h
    engines/mediastation/assets/text.h
    engines/mediastation/assets/timer.h
    engines/mediastation/mediascript/codechunk.h
    engines/mediastation/mediascript/eventhandler.h
    engines/mediastation/mediascript/operand.h
    engines/mediastation/mediascript/variable.h
    engines/mediastation/mediastation.cpp


diff --git a/engines/mediastation/asset.h b/engines/mediastation/asset.h
index 81615ade4d1..0576152f540 100644
--- a/engines/mediastation/asset.h
+++ b/engines/mediastation/asset.h
@@ -26,7 +26,7 @@
 
 #include "mediastation/subfile.h"
 #include "mediastation/chunk.h"
-#include "mediastation/mediascript/builtins.h"
+#include "mediastation/mediascript/scriptconstants.h"
 #include "mediastation/mediascript/operand.h"
 #include "mediastation/assetheader.h"
 
diff --git a/engines/mediastation/assets/canvas.h b/engines/mediastation/assets/canvas.h
index cf3a6d86e00..514c7844fc4 100644
--- a/engines/mediastation/assets/canvas.h
+++ b/engines/mediastation/assets/canvas.h
@@ -25,7 +25,7 @@
 #include "mediastation/asset.h"
 #include "mediastation/assetheader.h"
 #include "mediastation/mediascript/operand.h"
-#include "mediastation/mediascript/builtins.h"
+#include "mediastation/mediascript/scriptconstants.h"
 
 namespace MediaStation {
 
diff --git a/engines/mediastation/assets/font.h b/engines/mediastation/assets/font.h
index 4810ad45ebc..246be1b7484 100644
--- a/engines/mediastation/assets/font.h
+++ b/engines/mediastation/assets/font.h
@@ -27,7 +27,7 @@
 #include "mediastation/bitmap.h"
 #include "mediastation/chunk.h"
 #include "mediastation/mediascript/operand.h"
-#include "mediastation/mediascript/builtins.h"
+#include "mediastation/mediascript/scriptconstants.h"
 
 namespace MediaStation {
 
diff --git a/engines/mediastation/assets/hotspot.h b/engines/mediastation/assets/hotspot.h
index 714382846de..6818ffd000e 100644
--- a/engines/mediastation/assets/hotspot.h
+++ b/engines/mediastation/assets/hotspot.h
@@ -25,7 +25,7 @@
 #include "mediastation/asset.h"
 #include "mediastation/assetheader.h"
 #include "mediastation/mediascript/operand.h"
-#include "mediastation/mediascript/builtins.h"
+#include "mediastation/mediascript/scriptconstants.h"
 
 namespace MediaStation {
 
diff --git a/engines/mediastation/assets/image.h b/engines/mediastation/assets/image.h
index d4518ac5af9..4a0763f9e27 100644
--- a/engines/mediastation/assets/image.h
+++ b/engines/mediastation/assets/image.h
@@ -27,7 +27,7 @@
 #include "mediastation/bitmap.h"
 #include "mediastation/assetheader.h"
 #include "mediastation/mediascript/operand.h"
-#include "mediastation/mediascript/builtins.h"
+#include "mediastation/mediascript/scriptconstants.h"
 
 namespace MediaStation {
 
diff --git a/engines/mediastation/assets/movie.h b/engines/mediastation/assets/movie.h
index d35f89de183..0fabcab5ff3 100644
--- a/engines/mediastation/assets/movie.h
+++ b/engines/mediastation/assets/movie.h
@@ -29,7 +29,7 @@
 #include "mediastation/chunk.h"
 #include "mediastation/assetheader.h"
 #include "mediastation/bitmap.h"
-#include "mediastation/mediascript/builtins.h"
+#include "mediastation/mediascript/scriptconstants.h"
 
 namespace MediaStation {
 
diff --git a/engines/mediastation/assets/palette.h b/engines/mediastation/assets/palette.h
index 0fff673b4e3..2c3d44ce20f 100644
--- a/engines/mediastation/assets/palette.h
+++ b/engines/mediastation/assets/palette.h
@@ -25,7 +25,7 @@
 #include "mediastation/assetheader.h"
 #include "mediastation/asset.h"
 #include "mediastation/mediascript/operand.h"
-#include "mediastation/mediascript/builtins.h"
+#include "mediastation/mediascript/scriptconstants.h"
 
 namespace MediaStation {
 
diff --git a/engines/mediastation/assets/path.h b/engines/mediastation/assets/path.h
index b21cd818de2..07908f53592 100644
--- a/engines/mediastation/assets/path.h
+++ b/engines/mediastation/assets/path.h
@@ -25,7 +25,7 @@
 #include "mediastation/assetheader.h"
 #include "mediastation/asset.h"
 #include "mediastation/mediascript/operand.h"
-#include "mediastation/mediascript/builtins.h"
+#include "mediastation/mediascript/scriptconstants.h"
 
 namespace MediaStation {
 
diff --git a/engines/mediastation/assets/screen.h b/engines/mediastation/assets/screen.h
index 933d9f24dc6..39d66233f0d 100644
--- a/engines/mediastation/assets/screen.h
+++ b/engines/mediastation/assets/screen.h
@@ -25,7 +25,7 @@
 #include "mediastation/assetheader.h"
 #include "mediastation/asset.h"
 #include "mediastation/mediascript/operand.h"
-#include "mediastation/mediascript/builtins.h"
+#include "mediastation/mediascript/scriptconstants.h"
 
 namespace MediaStation {
 
diff --git a/engines/mediastation/assets/sound.h b/engines/mediastation/assets/sound.h
index f84e901a512..edbfa36bb4e 100644
--- a/engines/mediastation/assets/sound.h
+++ b/engines/mediastation/assets/sound.h
@@ -31,7 +31,7 @@
 #include "mediastation/subfile.h"
 #include "mediastation/assetheader.h"
 #include "mediastation/mediascript/operand.h"
-#include "mediastation/mediascript/builtins.h"
+#include "mediastation/mediascript/scriptconstants.h"
 
 namespace MediaStation {
 
diff --git a/engines/mediastation/assets/sprite.h b/engines/mediastation/assets/sprite.h
index eafa096e4dc..ca41f754918 100644
--- a/engines/mediastation/assets/sprite.h
+++ b/engines/mediastation/assets/sprite.h
@@ -30,7 +30,7 @@
 #include "mediastation/chunk.h"
 #include "mediastation/bitmap.h"
 #include "mediastation/mediascript/operand.h"
-#include "mediastation/mediascript/builtins.h"
+#include "mediastation/mediascript/scriptconstants.h"
 
 namespace MediaStation {
 
diff --git a/engines/mediastation/assets/text.h b/engines/mediastation/assets/text.h
index 2c6dee0fe9c..4a96b13aad1 100644
--- a/engines/mediastation/assets/text.h
+++ b/engines/mediastation/assets/text.h
@@ -27,7 +27,7 @@
 #include "mediastation/asset.h"
 #include "mediastation/assetheader.h"
 #include "mediastation/mediascript/operand.h"
-#include "mediastation/mediascript/builtins.h"
+#include "mediastation/mediascript/scriptconstants.h"
 
 namespace MediaStation {
 
diff --git a/engines/mediastation/assets/timer.h b/engines/mediastation/assets/timer.h
index 5d008a37bd4..6ee247c5a78 100644
--- a/engines/mediastation/assets/timer.h
+++ b/engines/mediastation/assets/timer.h
@@ -25,7 +25,7 @@
 #include "mediastation/asset.h"
 #include "mediastation/assetheader.h"
 #include "mediastation/mediascript/operand.h"
-#include "mediastation/mediascript/builtins.h"
+#include "mediastation/mediascript/scriptconstants.h"
 
 namespace MediaStation {
 
diff --git a/engines/mediastation/mediascript/codechunk.h b/engines/mediastation/mediascript/codechunk.h
index 864d693c114..b87865b76b4 100644
--- a/engines/mediastation/mediascript/codechunk.h
+++ b/engines/mediastation/mediascript/codechunk.h
@@ -27,7 +27,7 @@
 
 #include "mediastation/mediascript/variable.h"
 #include "mediastation/mediascript/operand.h"
-#include "mediastation/mediascript/builtins.h"
+#include "mediastation/mediascript/scriptconstants.h"
 
 namespace MediaStation {
 
diff --git a/engines/mediastation/mediascript/eventhandler.h b/engines/mediastation/mediascript/eventhandler.h
index 462dcef65c4..3b2f9004c70 100644
--- a/engines/mediastation/mediascript/eventhandler.h
+++ b/engines/mediastation/mediascript/eventhandler.h
@@ -25,7 +25,7 @@
 #include "mediastation/chunk.h"
 #include "mediastation/datum.h"
 #include "mediastation/mediascript/codechunk.h"
-#include "mediastation/mediascript/builtins.h"
+#include "mediastation/mediascript/scriptconstants.h"
 
 namespace MediaStation {
 
diff --git a/engines/mediastation/mediascript/operand.h b/engines/mediastation/mediascript/operand.h
index 961a1fc204e..f4d157181f3 100644
--- a/engines/mediastation/mediascript/operand.h
+++ b/engines/mediastation/mediascript/operand.h
@@ -24,7 +24,7 @@
 
 #include "common/str.h"
 
-#include "mediastation/mediascript/builtins.h"
+#include "mediastation/mediascript/scriptconstants.h"
 #include "mediastation/mediascript/variable.h"
 
 namespace MediaStation {
diff --git a/engines/mediastation/mediascript/builtins.h b/engines/mediastation/mediascript/scriptconstants.h
similarity index 100%
rename from engines/mediastation/mediascript/builtins.h
rename to engines/mediastation/mediascript/scriptconstants.h
diff --git a/engines/mediastation/mediascript/variable.h b/engines/mediastation/mediascript/variable.h
index 8dea315341e..e7b1bb176a8 100644
--- a/engines/mediastation/mediascript/variable.h
+++ b/engines/mediastation/mediascript/variable.h
@@ -27,7 +27,7 @@
 
 #include "mediastation/chunk.h"
 #include "mediastation/datum.h"
-#include "mediastation/mediascript/builtins.h"
+#include "mediastation/mediascript/scriptconstants.h"
 
 namespace MediaStation {
 
diff --git a/engines/mediastation/mediastation.cpp b/engines/mediastation/mediastation.cpp
index 0c2435b88b8..5805442eba4 100644
--- a/engines/mediastation/mediastation.cpp
+++ b/engines/mediastation/mediastation.cpp
@@ -35,7 +35,7 @@
 #include "mediastation/context.h"
 #include "mediastation/asset.h"
 #include "mediastation/assets/movie.h"
-#include "mediastation/mediascript/builtins.h"
+#include "mediastation/mediascript/scriptconstants.h"
 
 namespace MediaStation {
 


Commit: 3129b6dd17a6d74483f3e315fe4c868d5650d161
    https://github.com/scummvm/scummvm/commit/3129b6dd17a6d74483f3e315fe4c868d5650d161
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2025-01-18T12:08:00-05:00

Commit Message:
MEDIASTATION: Correct misunderstanding on float and int script var types

These types should now be labeled correctly, and as a bonus
we got rid of the hack of storing a Datum in script variables.

Changed paths:
    engines/mediastation/mediascript/scriptconstants.h
    engines/mediastation/mediascript/variable.cpp
    engines/mediastation/mediascript/variable.h


diff --git a/engines/mediastation/mediascript/scriptconstants.h b/engines/mediastation/mediascript/scriptconstants.h
index 0ad15b85814..1e77278cb89 100644
--- a/engines/mediastation/mediascript/scriptconstants.h
+++ b/engines/mediastation/mediascript/scriptconstants.h
@@ -248,9 +248,7 @@ enum VariableType {
 	kVariableTypeCollection = 0x0007,
 	kVariableTypeString = 0x0006,
 	kVariableTypeAssetId = 0x0005,
-	// These seem to be used in Dalmatians, but I don't know what they are
-	// used for.
-	kVariableTypeUnk1 = 0x0004,
+	kVariableTypeInt = 0x0004,
 	// These seem to be constants of some sort? This is what some of these
 	// IDs look like in PROFILE._ST:
 	//  - $downEar 10026
@@ -260,7 +258,7 @@ enum VariableType {
 	//  - var_6c14_NextEncouragementSound 316
 	kVariableTypeUnk2 = 0x0003,
 	kVariableTypeBoolean = 0x0002,
-	kVariableTypeLiteral = 0x0001
+	kVariableTypeFloat = 0x0001
 };
 
 } // End of namespace MediaStation
diff --git a/engines/mediastation/mediascript/variable.cpp b/engines/mediastation/mediascript/variable.cpp
index 2995427c181..e12c46a87de 100644
--- a/engines/mediastation/mediascript/variable.cpp
+++ b/engines/mediastation/mediascript/variable.cpp
@@ -71,23 +71,24 @@ Variable::Variable(Chunk &chunk, bool readId) {
 		break;
 	}
 
-	case kVariableTypeLiteral: {
-		// Client code can worry about extracting the value.
-		_value.datum = new Datum(chunk);
-		debugC(7, kDebugLoading, "Variable::Variable(): LITERAL");
+	case kVariableTypeFloat: {
+		Datum datum = Datum(chunk);
+		if ((datum.t != kDatumTypeFloat64_1) && (datum.t != kDatumTypeFloat64_2)) {
+			error("Variable::Variable(): Got a non-float datum type 0x%x to put into a float variable", datum.t);
+		}
+		_value.d = datum.u.f;
+		debugC(7, kDebugLoading, "Variable::Variable(): FLOAT: %f", _value.d);
 		break;
 	}
 
-	case kVariableTypeUnk1: {
+	case kVariableTypeInt: {
 		_value.i = Datum(chunk).u.i;
-		debugC(7, kDebugLoading, "Variable::Variable(): UNK1: %d", _value.i);
-		warning("Variable::Variable(): Got unknown variable value type 0x%x (0x%llx)", static_cast<uint>(_type), static_cast<long long int>(chunk.pos()));
+		debugC(7, kDebugLoading, "Variable::Variable(): INT: %d", _value.i);
 		break;
 	}
 
 	default: {
 		error("Variable::Variable(): Got unknown variable value type 0x%x", static_cast<uint>(_type));
-		_value.datum = new Datum(chunk);
 	}
 	}
 }
@@ -109,13 +110,7 @@ Variable::~Variable() {
 		break;
 	}
 
-	case kVariableTypeLiteral: {
-		delete _value.datum;
-		break;
-	}
-
 	default: {
-		delete _value.datum;
 		break;
 	}
 	}
@@ -153,10 +148,11 @@ Operand Variable::getValue() {
 		return returnValue;
 	}
 
-	case kVariableTypeLiteral: {
-		// Shouldn't matter too much, though, since it's still an integer type.
-		Operand returnValue(kOperandTypeLiteral1);
-		returnValue.putInteger(_value.datum->u.i);
+	case kVariableTypeFloat: {
+		// TODO: Is this value type correct?
+		// Shouldn't matter too much, though, since it's still a floating-point type.
+		Operand returnValue(kOperandTypeFloat1);
+		returnValue.putDouble(_value.d);
 		return returnValue;
 	}
 
diff --git a/engines/mediastation/mediascript/variable.h b/engines/mediastation/mediascript/variable.h
index e7b1bb176a8..766317f247a 100644
--- a/engines/mediastation/mediascript/variable.h
+++ b/engines/mediastation/mediascript/variable.h
@@ -38,7 +38,6 @@ public:
 	uint32 _id = 0;
 	VariableType _type = kVariableTypeEmpty;
 	union {
-		Datum *datum = nullptr;
 		Common::String *string;
 		Common::Array<Variable *> *collection;
 		bool b;


Commit: 5de4835b2addb31b13fb97e47424c61eac600102
    https://github.com/scummvm/scummvm/commit/5de4835b2addb31b13fb97e47424c61eac600102
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2025-01-18T12:08:00-05:00

Commit Message:
MEDIASTATION: JANITORIAL: Clean script constant comments

Several of these were not formatted well, had old TODOs that
are now understood, or were just incorect.

Changed paths:
    engines/mediastation/mediascript/scriptconstants.h


diff --git a/engines/mediastation/mediascript/scriptconstants.h b/engines/mediastation/mediascript/scriptconstants.h
index 1e77278cb89..c235f3b2c6c 100644
--- a/engines/mediastation/mediascript/scriptconstants.h
+++ b/engines/mediastation/mediascript/scriptconstants.h
@@ -49,9 +49,6 @@ enum Opcode {
 	kOpcodeModulo = 217,
 	kOpcodeUnk2 = 218, // TODO: Likely something with ## constants like ##DOWN?
 	kOpcodeCallRoutine = 219,
-	// Method calls are like routine calls, but they have an implicit "self"
-	// parameter that is always the first. For example:
-	//  @self . mouseActivate ( TRUE ) ;
 	kOpcodeCallMethod = 220,
 	// This seems to appear at the start of a function to declare the number of
 	// local variables used in the function. It seems to be the `Declare`
@@ -213,14 +210,19 @@ enum EventType {
 
 enum EventHandlerArgumentType {
     kNullEventHandlerArgument = 0,
-    kAsciiCodeEventHandlerArgument = 1, // TODO: Why is this datum type a float?
+    kAsciiCodeEventHandlerArgument = 1,
     kTimeEventHandlerArgument = 3,
-    kUnk1EventHandlerArgument = 4, // Appars to happen with MovieStart?
+	// TODO: This argument type Appears to happen with MovieStart
+	// and nowhere else. However, this event handler shouldn't even need an
+	// argument...
+    kUnk1EventHandlerArgument = 4, 
     kContextEventHandlerArgument = 5
 };
 
 enum OperandType {
-	kOperandTypeEmpty = 0, // a flag for C++ code, not real operand type.
+	// This is an invalid type used for initialization only.
+	kOperandTypeEmpty = 0,
+
 	// TODO: Figure out the difference between these two.
 	kOperandTypeLiteral1 = 151,
 	kOperandTypeLiteral2 = 153,
@@ -228,11 +230,8 @@ enum OperandType {
 	kOperandTypeFloat1 = 152,
 	kOperandTypeFloat2 = 157,
 	kOperandTypeString = 154,
-	// TODO: This only seems to be used in effectTransition:
-	//  effectTransition ( $FadeToPalette )
-	// compiles to:
-	//  [219, 102, 1]
-	//  [155, 301]
+	// TODO: This only seems to be used in effectTransition,
+	// as in effectTransition ( $FadeToPalette )
 	kOperandTypeDollarSignVariable = 155,
 	kOperandTypeAssetId = 156,
 	kOperandTypeVariableDeclaration = 158,
@@ -243,8 +242,6 @@ enum VariableType {
 	// This is an invalid type used for initialization only.
 	kVariableTypeEmpty = 0x0000,
 
-	// This is an "array", but the IMT sources
-	// use the term "collection".
 	kVariableTypeCollection = 0x0007,
 	kVariableTypeString = 0x0006,
 	kVariableTypeAssetId = 0x0005,


Commit: 2806bf4c4093ed71e6b45017ce857ba12c58ecff
    https://github.com/scummvm/scummvm/commit/2806bf4c4093ed71e6b45017ce857ba12c58ecff
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2025-01-18T12:08:00-05:00

Commit Message:
MEDIASTATION: Also load child contexts when loading a context

Changed paths:
    engines/mediastation/mediastation.cpp


diff --git a/engines/mediastation/mediastation.cpp b/engines/mediastation/mediastation.cpp
index 5805442eba4..d94c75bd0f5 100644
--- a/engines/mediastation/mediastation.cpp
+++ b/engines/mediastation/mediastation.cpp
@@ -258,6 +258,18 @@ Context *MediaStationEngine::loadContext(uint32 contextId) {
 	}
 	Common::String *fileName = fileDeclaration->_name;
 
+	// Load any child contexts before we actually load this one. The child
+	// contexts must be unloaded explicitly later.
+	ContextDeclaration *contextDeclaration = _boot->_contextDeclarations.getValOrDefault(contextId);
+	for (uint32 childContextId : contextDeclaration->_fileReferences) {
+		// The root context is referred to by an ID of 0, regardless of what its
+		// actual ID is. The root context is already always loaded.
+		if (childContextId != 0) {
+			debugC(5, kDebugLoading, "MediaStationEngine::loadContext(): Loading child context %d", childContextId);
+			loadContext(childContextId);
+		}
+	}
+
 	// LOAD THE CONTEXT.
 	Common::Path entryCxtFilepath = Common::Path(*fileName);
 	Context *context = new Context(entryCxtFilepath);


Commit: c497af5aae621c313b9c097aad472616483c4049
    https://github.com/scummvm/scummvm/commit/c497af5aae621c313b9c097aad472616483c4049
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2025-01-18T12:08:00-05:00

Commit Message:
MEDIASTATION: Add string representations of script constants

Changed paths:
  A engines/mediastation/mediascript/scriptconstants.cpp
    engines/mediastation/mediascript/scriptconstants.h
    engines/mediastation/module.mk


diff --git a/engines/mediastation/mediascript/scriptconstants.cpp b/engines/mediastation/mediascript/scriptconstants.cpp
new file mode 100644
index 00000000000..867cbfbe7ff
--- /dev/null
+++ b/engines/mediastation/mediascript/scriptconstants.cpp
@@ -0,0 +1,349 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "mediastation/mediascript/scriptconstants.h"
+
+namespace MediaStation {
+
+const char *instructionTypeToStr(InstructionType type) {
+    switch (type) {
+    case kInstructionTypeEmpty:
+        return "Empty";
+    case kInstructionTypeFunctionCall:
+        return "FunctionCall";
+    case kInstructionTypeOperand:
+        return "Operand";
+    case kInstructionTypeVariableRef:
+        return "VariableReference";
+    default:
+        return "UNKNOWN";
+    }
+}
+
+const char *opcodeToStr(Opcode opcode) {
+    switch (opcode) {
+    case kOpcodeIfElse:
+        return "IfElse";
+    case kOpcodeAssignVariable:
+        return "AssignVariable";
+    case kOpcodeOr:
+        return "Or";
+    case kOpcodeAnd:
+        return "And";
+    case kOpcodeEquals:
+        return "==";
+    case kOpcodeNotEquals:
+        return "!=";
+    case kOpcodeLessThan:
+        return "<";
+    case kOpcodeGreaterThan:
+        return ">";
+    case kOpcodeLessThanOrEqualTo:
+        return "<=";
+    case kOpcodeGreaterThanOrEqualTo:
+        return ">=";
+    case kOpcodeAdd:
+        return "+";
+    case kOpcodeSubtract:
+        return "-";
+    case kOpcodeMultiply:
+        return "*";
+    case kOpcodeDivide:
+        return "/";
+    case kOpcodeModulo:
+        return "%";
+    case kOpcodeUnk2:
+        return "UNKNOWN (Unk2)";
+    case kOpcodeCallRoutine:
+        return "CallRoutine";
+    case kOpcodeCallMethod:
+        return "CallMethod";
+    case kOpcodeDeclareVariables:
+        return "DeclareVariables";
+    case kOpcodeReturn:
+        return "Return";
+    case kOpcodeUnk1:
+        return "UNKNOWN (Unk1)";
+    case kOpcodeWhile:
+        return "While";
+    default:
+        return "UNKNOWN";
+    }
+}
+
+const char *variableScopeToStr(VariableScope scope) {
+    switch (scope) {
+    case kVariableScopeLocal:
+        return "Local";
+    case kVariableScopeParameter:
+        return "Parameter";
+    case kVariableScopeGlobal:
+        return "Global";
+    default:
+        return "UNKNOWN";
+    }
+}
+
+const char *builtInFunctionToStr(BuiltInFunction function) {
+    switch (function) {
+    case kEffectTransitionFunction:
+        return "EffectTransition";
+    case kDrawingFunction:
+        return "Drawing";
+    case kDebugPrintFunction:
+        return "DebugPrint";
+    default:
+        return "UNKNOWN";
+    }
+}
+
+const char *builtInMethodToStr(BuiltInMethod method) {
+    switch (method) {
+    case kCursorSetMethod:
+        return "CursorSet";
+    case kSpatialHideMethod:
+        return "SpatialHide";
+    case kSpatialMoveToMethod:
+        return "SpatialMoveTo";
+    case kSpatialZMoveToMethod:
+        return "SpatialZMoveTo";
+    case kSpatialShowMethod:
+        return "SpatialShow";
+    case kTimePlayMethod:
+        return "TimePlay";
+    case kTimeStopMethod:
+        return "TimeStop";
+    case kIsPlayingMethod:
+        return "IsPlaying";
+    case kSetDissolveFactorMethod:
+        return "SetDissolveFactor";
+    case kMouseActivateMethod:
+        return "MouseActivate";
+    case kMouseDeactivateMethod:
+        return "MouseDeactivate";
+    case kXPositionMethod:
+        return "XPosition";
+    case kYPositionMethod:
+        return "YPosition";
+    case kTriggerAbsXPositionMethod:
+        return "TriggerAbsXPosition";
+    case kTriggerAbsYPositionMethod:
+        return "TriggerAbsYPosition";
+    case kIsActiveMethod:
+        return "IsActive";
+    case kWidthMethod:
+        return "Width";
+    case kHeightMethod:
+        return "Height";
+    case kIsVisibleMethod:
+        return "IsVisible";
+    case kMovieResetMethod:
+        return "MovieReset";
+    case kSetWorldSpaceExtentMethod:
+        return "SetWorldSpaceExtent";
+    case kSetBoundsMethod:
+        return "SetBounds";
+    case kStopPanMethod:
+        return "StopPan";
+    case kViewportMoveToMethod:
+        return "ViewportMoveTo";
+    case kYViewportPositionMethod:
+        return "YViewportPosition";
+    case kPanToMethod:
+        return "PanTo";
+    case kClearToPaletteMethod:
+        return "ClearToPalette";
+    case kLoadContextMethod:
+        return "LoadContext";
+    case kReleaseContextMethod:
+        return "ReleaseContext";
+    case kBranchToScreenMethod:
+        return "BranchToScreen";
+    case kIsLoadedMethod:
+        return "IsLoaded";
+    case kSetDurationMethod:
+        return "SetDuration";
+    case kPercentCompleteMethod:
+        return "PercentComplete";
+    case kTextMethod:
+        return "Text";
+    case kSetTextMethod:
+        return "SetText";
+    case kSetMaximumTextLengthMethod:
+        return "SetMaximumTextLength";
+    case kIsEmptyMethod:
+        return "IsEmpty";
+    case kEmptyMethod:
+        return "Empty";
+    case kAppendMethod:
+        return "Append";
+    case kGetAtMethod:
+        return "GetAt";
+    case kCountMethod:
+        return "Count";
+    case kSendMethod:
+        return "Send";
+    case kSeekMethod:
+        return "Seek";
+    case kSortMethod:
+        return "Sort";
+    case kDeleteAtMethod:
+        return "DeleteAt";
+    case kOpenLensMethod:
+        return "OpenLens";
+    case kCloseLensMethod:
+        return "CloseLens";
+    default:
+        return "UNKNOWN";
+    }
+}
+
+const char *eventTypeToStr(EventType type) {
+    switch (type) {
+    case kTimerEvent:
+        return "Timer";
+    case kMouseDownEvent:
+        return "MouseDown";
+    case kMouseUpEvent:
+        return "MouseUp";
+    case kMouseMovedEvent:
+        return "MouseMoved";
+    case kMouseEnteredEvent:
+        return "MouseEntered";
+    case kMouseExitedEvent:
+        return "MouseExited";
+    case kKeyDownEvent:
+        return "KeyDown";
+    case kSoundEndEvent:
+        return "SoundEnd";
+    case kSoundAbortEvent:
+        return "SoundAbort";
+    case kSoundFailureEvent:
+        return "SoundFailure";
+    case kSoundStoppedEvent:
+        return "SoundStopped";
+    case kSoundBeginEvent:
+        return "SoundBegin";
+    case kMovieEndEvent:
+        return "MovieEnd";
+    case kMovieAbortEvent:
+        return "MovieAbort";
+    case kMovieFailureEvent:
+        return "MovieFailure";
+    case kMovieStoppedEvent:
+        return "MovieStopped";
+    case kMovieBeginEvent:
+        return "MovieBegin";
+    case kSpriteMovieEndEvent:
+        return "SpriteMovieEnd";
+    case kEntryEvent:
+        return "EntryEvent";
+    case kExitEvent:
+        return "ExitEvent";
+    case kLoadCompleteEvent:
+        return "LoadComplete";
+    case kInputEvent:
+        return "Input";
+    case kErrorEvent:
+        return "Error";
+    case kPanAbortEvent:
+        return "PanAbort";
+    case kPanEndEvent:
+        return "PanEnd";
+    case kStepEvent:
+        return "StepEvent";
+    case kPathStoppedEvent:
+        return "PathStopped";
+    case kPathEndEvent:
+        return "PathEnd";
+    default:
+        return "UNKNOWN";
+    }
+}
+
+const char *eventHandlerArgumentTypeToStr(EventHandlerArgumentType type) {
+    switch (type) {
+    case kNullEventHandlerArgument:
+        return "Null";
+    case kAsciiCodeEventHandlerArgument:
+        return "AsciiCode";
+    case kTimeEventHandlerArgument:
+        return "Time";
+    case kUnk1EventHandlerArgument:
+        return "Unk1";
+    case kContextEventHandlerArgument:
+        return "Context";
+    default: 
+        return "UNKNOWN";
+    }
+}
+
+const char *operandTypeToStr(OperandType type) {
+    switch (type) {
+    case kOperandTypeEmpty:
+        return "Empty";
+    case kOperandTypeLiteral1:
+        return "Literal1";
+    case kOperandTypeLiteral2:
+        return "Literal2";
+    case kOperandTypeFloat1:
+        return "Float1";
+    case kOperandTypeFloat2:
+        return "Float2";
+    case kOperandTypeString:
+        return "String";
+    case kOperandTypeDollarSignVariable:
+        return "DollarSignVariable";
+    case kOperandTypeAssetId:
+        return "AssetId";
+    case kOperandTypeVariableDeclaration:
+        return "VariableDeclaration";
+    case kOperandTypeFunction:
+        return "Function";
+    default:
+        return "UNKNOWN";
+    }
+}
+
+const char *variableTypeToStr(VariableType type) {
+    switch (type) {
+    case kVariableTypeEmpty:
+        return "Empty";
+    case kVariableTypeCollection:
+        return "Collection";
+    case kVariableTypeString:
+        return "String";
+    case kVariableTypeAssetId:
+        return "AssetId";
+    case kVariableTypeInt:
+        return "Unknown1";
+    case kVariableTypeUnk2:
+        return "Unknown2";
+    case kVariableTypeBoolean:
+        return "Boolean";
+    case kVariableTypeFloat:
+        return "Literal";
+    default:
+        return "UNKNOWN";
+    }
+}
+
+} // End of namespace MediaStation
diff --git a/engines/mediastation/mediascript/scriptconstants.h b/engines/mediastation/mediascript/scriptconstants.h
index c235f3b2c6c..876f7e84c3a 100644
--- a/engines/mediastation/mediascript/scriptconstants.h
+++ b/engines/mediastation/mediascript/scriptconstants.h
@@ -30,6 +30,7 @@ enum InstructionType {
 	kInstructionTypeOperand = 0x0066,
 	kInstructionTypeVariableRef = 0x0065
 };
+const char *instructionTypeToStr(InstructionType type);
 
 enum Opcode {
 	kOpcodeIfElse = 202,
@@ -60,12 +61,14 @@ enum Opcode {
 	kOpcodeReturn = 222,
 	kOpcodeUnk1 = 223
 };
+const char *opcodeToStr(Opcode opcode);
 
 enum VariableScope {
 	kVariableScopeLocal = 1,
 	kVariableScopeParameter = 2,
 	kVariableScopeGlobal = 4
 };
+const char *variableScopeToStr(VariableScope scope);
 
 enum BuiltInFunction {
 	// TODO: Figure out if effectTransitionOnSync = 13 is consistent across titles?
@@ -76,6 +79,7 @@ enum BuiltInFunction {
 	// TODO: Figure out code for DebugPrint.
 	// TODO: Figure out code for Quit.
 };
+const char *builtInFunctionToStr(BuiltInFunction function);
 
 enum BuiltInMethod {
 	// TODO: What object types does CursorSet apply to?
@@ -156,6 +160,7 @@ enum BuiltInMethod {
 	kOpenLensMethod = 346, // PARAMS: 0
 	kCloseLensMethod = 347, // PARAMS: 0
 };
+const char *builtInMethodToStr(BuiltInMethod method);
 
 enum EventType {
     // TIMER EVENTS.
@@ -207,6 +212,7 @@ enum EventType {
     kPathStoppedEvent = 33,
     kPathEndEvent = 16
 };
+const char *eventTypeToStr(EventType type);
 
 enum EventHandlerArgumentType {
     kNullEventHandlerArgument = 0,
@@ -218,6 +224,7 @@ enum EventHandlerArgumentType {
     kUnk1EventHandlerArgument = 4, 
     kContextEventHandlerArgument = 5
 };
+const char *eventHandlerArgumentTypeToStr(EventHandlerArgumentType type);
 
 enum OperandType {
 	// This is an invalid type used for initialization only.
@@ -237,6 +244,7 @@ enum OperandType {
 	kOperandTypeVariableDeclaration = 158,
 	kOperandTypeFunction = 160
 };
+const char *operandTypeToStr(OperandType type);
 
 enum VariableType {
 	// This is an invalid type used for initialization only.
@@ -257,6 +265,7 @@ enum VariableType {
 	kVariableTypeBoolean = 0x0002,
 	kVariableTypeFloat = 0x0001
 };
+const char *variableTypeToStr(VariableType type);
 
 } // End of namespace MediaStation
 
diff --git a/engines/mediastation/module.mk b/engines/mediastation/module.mk
index d69678e6df4..4c070f61805 100644
--- a/engines/mediastation/module.mk
+++ b/engines/mediastation/module.mk
@@ -25,6 +25,7 @@ MODULE_OBJS = \
 	mediascript/function.o \
 	mediascript/variable.o \
 	mediascript/operand.o \
+	mediascript/scriptconstants.o \
 	subfile.o \
 	boot.o \
 	datum.o \


Commit: b99ff557633af3ef78499537e5d6617ceaf04883
    https://github.com/scummvm/scummvm/commit/b99ff557633af3ef78499537e5d6617ceaf04883
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2025-01-18T12:08:00-05:00

Commit Message:
MEDIASTATION: Implement negation (-) operator

Changed paths:
    engines/mediastation/mediascript/codechunk.cpp
    engines/mediastation/mediascript/operand.cpp
    engines/mediastation/mediascript/operand.h
    engines/mediastation/mediascript/scriptconstants.cpp
    engines/mediastation/mediascript/scriptconstants.h


diff --git a/engines/mediastation/mediascript/codechunk.cpp b/engines/mediastation/mediascript/codechunk.cpp
index 170c77d8de9..d5f6a41480f 100644
--- a/engines/mediastation/mediascript/codechunk.cpp
+++ b/engines/mediastation/mediascript/codechunk.cpp
@@ -135,11 +135,9 @@ Operand CodeChunk::executeNextStatement() {
 			return returnValue;
 		}
 
-		case kOpcodeUnk2: {
-			// TODO: Figure out what else must be done with this opcode.
+		case kOpcodeNegate: {
 			Operand value = executeNextStatement();
-			warning("CodeChunk::executeNextStatement(): Opcode kOpcodeUnk2 isn't fully implemented");
-			return value;
+			return -value;
 		}
 
 		case kOpcodeIfElse: {
diff --git a/engines/mediastation/mediascript/operand.cpp b/engines/mediastation/mediascript/operand.cpp
index eef15c218e4..f946e379ffb 100644
--- a/engines/mediastation/mediascript/operand.cpp
+++ b/engines/mediastation/mediascript/operand.cpp
@@ -310,4 +310,25 @@ Operand Operand::operator-(const Operand &other) const {
 	return returnValue;
 }
 
+Operand Operand::operator-() {
+	Operand literalValue = getLiteralValue();
+	Operand returnValue(literalValue.getType());
+	// If the types being compared end up being incompatible, the respective get
+	// method on the rhs will raise the error.
+	switch (literalValue.getType()) {
+	case kOperandTypeLiteral1: 
+	case kOperandTypeLiteral2:
+		returnValue.putInteger(-literalValue.getInteger());
+		return returnValue;
+
+	case kOperandTypeFloat1:
+	case kOperandTypeFloat2:
+		returnValue.putDouble(-literalValue.getDouble());
+		return returnValue;
+
+	default:
+		error("Operand::operator-(): Unsupported operand type %d", static_cast<uint>(literalValue.getType()));
+	}
+}
+
 } // End of namespace MediaStation
diff --git a/engines/mediastation/mediascript/operand.h b/engines/mediastation/mediascript/operand.h
index f4d157181f3..d0276e2fbf5 100644
--- a/engines/mediastation/mediascript/operand.h
+++ b/engines/mediastation/mediascript/operand.h
@@ -63,7 +63,9 @@ public:
 
 	bool operator==(Operand &other);
 	bool operator>=(Operand &other);
+
 	Operand operator-(const Operand &other) const;
+	Operand operator-();
 
 private:
 	OperandType _type = kOperandTypeEmpty;
diff --git a/engines/mediastation/mediascript/scriptconstants.cpp b/engines/mediastation/mediascript/scriptconstants.cpp
index 867cbfbe7ff..83ea7ff8593 100644
--- a/engines/mediastation/mediascript/scriptconstants.cpp
+++ b/engines/mediastation/mediascript/scriptconstants.cpp
@@ -70,8 +70,8 @@ const char *opcodeToStr(Opcode opcode) {
         return "/";
     case kOpcodeModulo:
         return "%";
-    case kOpcodeUnk2:
-        return "UNKNOWN (Unk2)";
+    case kOpcodeNegate:
+        return "-";
     case kOpcodeCallRoutine:
         return "CallRoutine";
     case kOpcodeCallMethod:
diff --git a/engines/mediastation/mediascript/scriptconstants.h b/engines/mediastation/mediascript/scriptconstants.h
index 876f7e84c3a..2e690f3e3c8 100644
--- a/engines/mediastation/mediascript/scriptconstants.h
+++ b/engines/mediastation/mediascript/scriptconstants.h
@@ -48,7 +48,7 @@ enum Opcode {
 	kOpcodeMultiply = 215,
 	kOpcodeDivide = 216,
 	kOpcodeModulo = 217,
-	kOpcodeUnk2 = 218, // TODO: Likely something with ## constants like ##DOWN?
+	kOpcodeNegate = 218,
 	kOpcodeCallRoutine = 219,
 	kOpcodeCallMethod = 220,
 	// This seems to appear at the start of a function to declare the number of


Commit: 20b47a3724d803b1ef45183524df2b99e8114f61
    https://github.com/scummvm/scummvm/commit/20b47a3724d803b1ef45183524df2b99e8114f61
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2025-01-18T12:08:00-05:00

Commit Message:
MEDIASTATION: JANITORIAL: Order module.mk

I had unfortunately been forgetting to do this.

Changed paths:
    engines/mediastation/module.mk


diff --git a/engines/mediastation/module.mk b/engines/mediastation/module.mk
index 4c070f61805..5bc2df1b8bb 100644
--- a/engines/mediastation/module.mk
+++ b/engines/mediastation/module.mk
@@ -1,36 +1,36 @@
 MODULE := engines/mediastation
 
 MODULE_OBJS = \
-	mediastation.o \
 	asset.o \
 	assetheader.o \
-	chunk.o \
-	context.o \
-	contextparameters.o \
-	bitmap.o \
+	assets/canvas.o \
+	assets/font.o \
+	assets/hotspot.o \
 	assets/image.o \
-	assets/palette.o \
-	assets/sound.o \
 	assets/movie.o \
-	assets/sprite.o \
+	assets/palette.o \
 	assets/path.o \
-	assets/hotspot.o \
-	assets/timer.o \
-	assets/canvas.o \
 	assets/screen.o \
-	assets/font.o \
+	assets/sound.o \
+	assets/sprite.o \
 	assets/text.o \
-	mediascript/eventhandler.o \
+	assets/timer.o \
+	bitmap.o \
+	boot.o \
+	chunk.o \
+	context.o \
+	contextparameters.o \
+	datafile.o \
+	datum.o \
 	mediascript/codechunk.o \
+	mediascript/eventhandler.o \
 	mediascript/function.o \
-	mediascript/variable.o \
 	mediascript/operand.o \
 	mediascript/scriptconstants.o \
-	subfile.o \
-	boot.o \
-	datum.o \
-	datafile.o \
-	metaengine.o
+	mediascript/variable.o \
+	mediastation.o \
+	metaengine.o \
+	subfile.o
 
 # This module can be built as a plugin
 ifeq ($(ENABLE_MEDIASTATION), DYNAMIC_PLUGIN)


Commit: d7825f894fc85ea3521692128f6570925b187c28
    https://github.com/scummvm/scummvm/commit/d7825f894fc85ea3521692128f6570925b187c28
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2025-01-18T12:08:00-05:00

Commit Message:
MEDIASTATION: Improve bytecode debug output with script constant strings

Changed paths:
    engines/mediastation/mediascript/codechunk.cpp
    engines/mediastation/mediascript/eventhandler.cpp
    engines/mediastation/mediascript/variable.cpp


diff --git a/engines/mediastation/mediascript/codechunk.cpp b/engines/mediastation/mediascript/codechunk.cpp
index d5f6a41480f..fcd4280b6bc 100644
--- a/engines/mediastation/mediascript/codechunk.cpp
+++ b/engines/mediastation/mediascript/codechunk.cpp
@@ -40,7 +40,6 @@ Operand CodeChunk::execute(Common::Array<Operand> *args) {
 	_args = args;
 	Operand returnValue;
 	while (_bytecode->pos() < _bytecode->size()) {
-		debugC(8, kDebugScript, "-------- Statement --------");
 		returnValue = executeNextStatement();
 	}
 
@@ -59,7 +58,7 @@ Operand CodeChunk::executeNextStatement() {
 	}
 
 	InstructionType instructionType = InstructionType(Datum(*_bytecode).u.i);
-	debugC(9, kDebugScript, " instructionType = %d", static_cast<uint>(instructionType));
+	debugCN(5, kDebugScript, "(%s) ", instructionTypeToStr(instructionType));
 	switch (instructionType) {
 	case kInstructionTypeEmpty: {
 		return Operand();
@@ -67,14 +66,15 @@ Operand CodeChunk::executeNextStatement() {
 
 	case kInstructionTypeFunctionCall: {
 		Opcode opcode = Opcode(Datum(*_bytecode).u.i);
-		debugC(8, kDebugScript, "  *** Opcode %d ***", static_cast<uint>(opcode));
+		debugCN(5, kDebugScript, "%s ", opcodeToStr(opcode));
 		switch (opcode) {
 		case kOpcodeAssignVariable: {
 			uint32 id = Datum(*_bytecode).u.i;
 			VariableScope scope = VariableScope(Datum(*_bytecode).u.i);
+			debugC(5, kDebugScript, "%d (%s) ", id, variableScopeToStr(scope));
+			debugCN(5, kDebugScript, "  Value: ");
 			Operand newValue = executeNextStatement();
-			// TODO: Print the new variable value for easier debugging.
-			debugC(5, kDebugScript, "SCRIPT: [ %d (scope: %d) ] = [ ? (showing value assigned to var not implemented yet) ]", static_cast<uint>(scope), id);
+
 			putVariable(id, scope, newValue);
 			return Operand();
 		}
@@ -83,21 +83,22 @@ Operand CodeChunk::executeNextStatement() {
 			uint functionId = Datum(*_bytecode).u.i;
 			uint32 parameterCount = Datum(*_bytecode).u.i;
 			Common::Array<Operand> args;
+			debugC(5, kDebugScript, "%d (%d params)", functionId, parameterCount);
 			for (uint i = 0; i < parameterCount; i++) {
-				debugC(8, kDebugScript, "   -- Argument %d of %d --", (i + 1), parameterCount);
+				debugCN(5, kDebugScript, "  Param %d: ", i);
 				Operand arg = executeNextStatement();
 				args.push_back(arg);
 			}
 
-			// Call the routine.
-			debugC(5, kDebugScript, "SCRIPT: [ %d ]( %d args )", functionId, parameterCount);
 			Operand returnValue;
 			Function *function = g_engine->getFunctionById(functionId);
 			if (function != nullptr) {
 				// This is a title-defined function.
 				returnValue = function->execute(args);
 			} else {
-				returnValue = callBuiltInFunction(static_cast<BuiltInFunction>(functionId), args);
+				BuiltInFunction builtInFunctionId = static_cast<BuiltInFunction>(functionId);
+				debugC(5, kDebugScript, "  Function Name: %s ", builtInFunctionToStr(builtInFunctionId));
+				returnValue = callBuiltInFunction(builtInFunctionId, args);
 			}
 			return returnValue;
 		}
@@ -109,10 +110,12 @@ Operand CodeChunk::executeNextStatement() {
 			// But here, we're only looking for built-in methods.
 			BuiltInMethod methodId = static_cast<BuiltInMethod>(Datum(*_bytecode).u.i);
 			uint32 parameterCount = Datum(*_bytecode).u.i;
+			debugC(5, kDebugScript, "%s (%d params)", builtInMethodToStr(methodId), parameterCount);
+			debugCN(5, kDebugScript, "  Self: ");
 			Operand selfObject = executeNextStatement();
 			Common::Array<Operand> args;
 			for (uint i = 0; i < parameterCount; i++) {
-				debugC(8, kDebugScript, "   -- Argument %d of %d --", (i + 1), parameterCount);
+				debugCN(5, kDebugScript, "  Param %d: ", i);
 				Operand arg = executeNextStatement();
 				args.push_back(arg);
 			}
@@ -122,13 +125,15 @@ Operand CodeChunk::executeNextStatement() {
 
 		case kOpcodeDeclareVariables: {
 			uint32 localVariableCount = Datum(*_bytecode).u.i;
-			debugC(5, kDebugScript, "   Declaring %d local variables", localVariableCount);
+			debugC(5, kDebugScript, "%d", localVariableCount);
 			_locals.resize(localVariableCount);
 			return Operand();
 		}
 
 		case kOpcodeSubtract: {
+			debugCN(5, kDebugScript, "\n    lhs: ");
 			Operand value1 = executeNextStatement();
+			debugCN(5, kDebugScript, "    rhs: ");
 			Operand value2 = executeNextStatement();
 
 			Operand returnValue = value1 - value2;
@@ -137,11 +142,15 @@ Operand CodeChunk::executeNextStatement() {
 
 		case kOpcodeNegate: {
 			Operand value = executeNextStatement();
+			debugCN(5, kDebugScript, "    value: ");
+
 			return -value;
 		}
 
 		case kOpcodeIfElse: {
+			debugCN(5, kDebugScript, "\n    condition: ");
 			Operand condition = executeNextStatement();
+
 			CodeChunk ifBlock(*_bytecode);
 			CodeChunk elseBlock(*_bytecode);
 			// Doesn't seem like there is a real bool type for values,
@@ -159,7 +168,9 @@ Operand CodeChunk::executeNextStatement() {
 		}
 
 		case kOpcodeEquals: {
+			debugCN(5, kDebugScript, "\n    lhs: ");
 			Operand value1 = executeNextStatement();
+			debugCN(5, kDebugScript, "    rhs: ");
 			Operand value2 = executeNextStatement();
 
 			// TODO: Confirm this is the correct value type?
@@ -170,7 +181,9 @@ Operand CodeChunk::executeNextStatement() {
 		}
 
 		case kOpcodeGreaterThanOrEqualTo: {
+			debugCN(5, kDebugScript, "\n    lhs: ");
 			Operand value1 = executeNextStatement();
+			debugCN(5, kDebugScript, "    rhs: ");
 			Operand value2 = executeNextStatement();
 
 			// TODO: Confirm this is the correct value type?
@@ -181,7 +194,7 @@ Operand CodeChunk::executeNextStatement() {
 		}
 
 		default: {
-			error("CodeChunk::getNextStatement(): Got unknown opcode 0x%x (%d)", opcode, opcode);
+			error("CodeChunk::getNextStatement(): Got unknown opcode %s (%d)", opcodeToStr(opcode), static_cast<uint>(opcode));
 		}
 		}
 		break;
@@ -189,12 +202,12 @@ Operand CodeChunk::executeNextStatement() {
 
 	case kInstructionTypeOperand: {
 		OperandType operandType = static_cast<OperandType>(Datum(*_bytecode).u.i);
+		debugCN(5, kDebugScript, "%s ", operandTypeToStr(operandType));
 		Operand operand(operandType);
 		switch (operandType) {
-		// TODO: Add clearer debugging printouts for these.
 		case kOperandTypeAssetId: {
 			uint32 assetId = Datum(*_bytecode).u.i;
-			debugC(8, kDebugScript, "  Asset ID: %d", assetId);
+			debugC(5, kDebugScript, "%d ", assetId);
 			operand.putAsset(assetId);
 			return operand;
 		}
@@ -203,7 +216,7 @@ Operand CodeChunk::executeNextStatement() {
 		case kOperandTypeLiteral2:
 		case kOperandTypeDollarSignVariable: {
 			int literal = Datum(*_bytecode).u.i;
-			debugC(8, kDebugScript, "  Literal: %d", literal);
+			debugC(5, kDebugScript, "%d ", literal);
 			operand.putInteger(literal);
 			return operand;
 		}
@@ -211,14 +224,14 @@ Operand CodeChunk::executeNextStatement() {
 		case kOperandTypeFloat1:
 		case kOperandTypeFloat2: {
 			double d = Datum(*_bytecode).u.f;
-			debugC(8, kDebugScript, "  Float: %f", d);
+			debugC(5, kDebugScript, "%f ", d);
 			operand.putDouble(d);
 			return operand;
 		}
 
 		case kOperandTypeFunction: {
 			uint functionId = Datum(*_bytecode).u.i;
-			debugC(8, kDebugScript, "  Function ID: %d", functionId);
+			debugC(5, kDebugScript, "%d ", functionId);
 			operand.putFunction(functionId);
 			return operand;
 		}
@@ -231,29 +244,29 @@ Operand CodeChunk::executeNextStatement() {
 			_bytecode->read(buffer, size);
 			buffer[size] = '\0';
 			Common::String *string = new Common::String(buffer);
-			debugC(8, kDebugScript, "  String: %s", string->c_str());
+			debugC(5, kDebugScript, "%s ", string->c_str());
 			operand.putString(string);
 			delete[] buffer;
 			return operand;
 		}
 
 		default: {
-			error("CodeChunk::getNextStatement(): Got unknown operand type 0x%d", operandType);
+			error("CodeChunk::getNextStatement(): Got unknown operand type %s (%d)", operandTypeToStr(operandType), static_cast<uint>(operandType));
 		}
 		}
 		break;
 	}
 
 	case kInstructionTypeVariableRef: {
-		// TODO: Add debug printout for this.
 		uint32 id = Datum(*_bytecode).u.i;
 		VariableScope scope = VariableScope(Datum(*_bytecode).u.i);
+		debugC(5, kDebugScript, "Variable %d (%s)", id, variableScopeToStr(scope));
 		Operand variable = getVariable(id, scope);
 		return variable;
 	}
 
 	default: {
-		error("CodeChunk::getNextStatement(): Got unknown instruction type 0x%x", static_cast<uint>(instructionType));
+		error("CodeChunk::getNextStatement(): Got unknown instruction type %s (%d)", instructionTypeToStr(instructionType), static_cast<uint>(instructionType));
 	}
 	}
 }
@@ -283,7 +296,7 @@ Operand CodeChunk::getVariable(uint32 id, VariableScope scope) {
 	}
 
 	default: {
-		error("CodeChunk::getVariable(): Got unknown variable scope %d", (uint)scope);
+		error("CodeChunk::getVariable(): Got unknown variable scope %s (%d)", variableScopeToStr(scope), static_cast<uint>(scope));
 	}
 	}
 }
@@ -350,7 +363,7 @@ void CodeChunk::putVariable(uint32 id, VariableScope scope, Operand value) {
 	}
 
 	default: {
-		error("VariableAssignment::evaluate(): Got unknown variable scope 0x%x", (uint)scope);
+		error("CodeChunk::getVariable(): Got unknown variable scope %s (%d)", variableScopeToStr(scope), static_cast<uint>(scope));
 	}
 	}
 }
@@ -409,7 +422,6 @@ Operand CodeChunk::callBuiltInMethod(BuiltInMethod method, Operand self, Common:
 			// active screen.
 			// HACK: This is so we don't have to implement a separate document class
 			// just to house these methods. Rather, we just call in the engine.
-			debugC(5, kDebugScript, "SCRIPT: @doc.[ %d ]()", method);
 			Operand returnValue = g_engine->callMethod(method, args);
 			return returnValue;
 		} else {
@@ -429,7 +441,7 @@ Operand CodeChunk::callBuiltInMethod(BuiltInMethod method, Operand self, Common:
 	}
 
 	default:
-		error("CodeChunk::callBuiltInMethod(): Attempt to call method on unsupported operand type 0x%x", (uint)self.getType());
+		error("CodeChunk::callBuiltInMethod(): Attempt to call method on unsupported operand type %s (%d)", operandTypeToStr(self.getType()), static_cast<uint>(self.getType()));
 		break;
 	}
 }
diff --git a/engines/mediastation/mediascript/eventhandler.cpp b/engines/mediastation/mediascript/eventhandler.cpp
index 1bb5364bb76..8acb8839e98 100644
--- a/engines/mediastation/mediascript/eventhandler.cpp
+++ b/engines/mediastation/mediascript/eventhandler.cpp
@@ -44,25 +44,25 @@ Operand EventHandler::execute(uint assetId) {
 	// a better way to handle that.
 	switch (_argumentType) {
 	case kNullEventHandlerArgument: {
-		debugC(5, kDebugScript, "\n********** EVENT HANDLER (asset %d) (type = %d) (no argument) **********", assetId, static_cast<uint>(_type));
+		debugC(5, kDebugScript, "\n********** EVENT HANDLER (asset %d) (type = %s) (no argument) **********", assetId, eventTypeToStr(_type));
 		break;
 	}
 
 	case kAsciiCodeEventHandlerArgument: {
 		// Not sure why the ASCII code isn't just stored as an integer, but it's not.
 		uint asciiCode = static_cast<uint>(_argumentValue.u.f);
-		debugC(5, kDebugScript, "\n********** EVENT HANDLER (asset %d) (type = %d) (ASCII code = %d) **********", assetId, static_cast<uint>(_type), asciiCode);
+		debugC(5, kDebugScript, "\n********** EVENT HANDLER (asset %d) (type = %s) (ASCII code = %d) **********", assetId, eventTypeToStr(_type), asciiCode);
 		break;
 	}
 
 	case kContextEventHandlerArgument: {
-		debugC(5, kDebugScript, "\n********** EVENT HANDLER (asset %d) (type = %d) (context = %d) **********", assetId, static_cast<uint>(_type), _argumentValue.u.i);
+		debugC(5, kDebugScript, "\n********** EVENT HANDLER (asset %d) (type = %s) (context = %d) **********", assetId, eventTypeToStr(_type), _argumentValue.u.i);
 		break;
 	}
 
 	case kTimeEventHandlerArgument:
 	case kUnk1EventHandlerArgument: {
-		debugC(5, kDebugScript, "\n********** EVENT HANDLER (asset %d) (type = %d) (time = %f) **********", assetId, static_cast<uint>(_type), _argumentValue.u.f);
+		debugC(5, kDebugScript, "\n********** EVENT HANDLER (asset %d) (type = %s) (time = %f) **********", assetId, eventTypeToStr(_type), _argumentValue.u.f);
 		break;
 	}
 	}
diff --git a/engines/mediastation/mediascript/variable.cpp b/engines/mediastation/mediascript/variable.cpp
index e12c46a87de..715068b52e9 100644
--- a/engines/mediastation/mediascript/variable.cpp
+++ b/engines/mediastation/mediascript/variable.cpp
@@ -33,13 +33,14 @@ Variable::Variable(Chunk &chunk, bool readId) {
 		_id = Datum(chunk).u.i;
 	}
 	_type = VariableType(Datum(chunk).u.i);
-	debugC(5, kDebugLoading, "Variable::Variable(): id = 0x%x, type 0x%x (@0x%llx)", _id, static_cast<uint>(_type), static_cast<long long int>(chunk.pos()));
+	debugC(5, kDebugLoading, "Variable::Variable(): id = 0x%x, type %s (%d) (@0x%llx)", 
+		_id, variableTypeToStr(_type), static_cast<uint>(_type), static_cast<long long int>(chunk.pos()));
 	switch ((VariableType)_type) {
 	case kVariableTypeCollection: {
 		uint totalItems = Datum(chunk).u.i;
 		_value.collection = new Common::Array<Variable *>;
 		for (uint i = 0; i < totalItems; i++) {
-			debugC(7, kDebugLoading, "Variable::Variable(): COLLECTION: Value %d of %d", i, totalItems);
+			debugC(7, kDebugLoading, "Variable::Variable(): %s: Value %d of %d", variableTypeToStr(_type), i, totalItems);
 			Variable *variableDeclaration = new Variable(chunk, readId = false);
 			_value.collection->push_back(variableDeclaration);
 		}
@@ -54,19 +55,19 @@ Variable::Variable(Chunk &chunk, bool readId) {
 		buffer[size] = '\0';
 		_value.string = new Common::String(buffer);
 		delete[] buffer;
-		debugC(7, kDebugLoading, "Variable::Variable(): STRING: %s", _value.string->c_str());
+		debugC(7, kDebugLoading, "Variable::Variable(): %s: %s", variableTypeToStr(_type), _value.string->c_str());
 		break;
 	}
 
 	case kVariableTypeAssetId: {
 		_value.assetId = Datum(chunk, kDatumTypeUint16_1).u.i;
-		debugC(7, kDebugLoading, "Variable::Variable(): ASSET ID: %d", _value.assetId);
+		debugC(7, kDebugLoading, "Variable::Variable(): %s: %d", variableTypeToStr(_type), _value.assetId);
 		break;
 	}
 
 	case kVariableTypeBoolean: {
 		uint rawValue = Datum(chunk, kDatumTypeUint8).u.i;
-		debugC(7, kDebugLoading, " Variable::Variable(): BOOL: %d", rawValue);
+		debugC(7, kDebugLoading, " Variable::Variable(): %s: %d", variableTypeToStr(_type), rawValue);
 		_value.b = (rawValue == 1);
 		break;
 	}
@@ -77,18 +78,18 @@ Variable::Variable(Chunk &chunk, bool readId) {
 			error("Variable::Variable(): Got a non-float datum type 0x%x to put into a float variable", datum.t);
 		}
 		_value.d = datum.u.f;
-		debugC(7, kDebugLoading, "Variable::Variable(): FLOAT: %f", _value.d);
+		debugC(7, kDebugLoading, "Variable::Variable(): %s: %f", variableTypeToStr(_type), _value.d);
 		break;
 	}
 
 	case kVariableTypeInt: {
 		_value.i = Datum(chunk).u.i;
-		debugC(7, kDebugLoading, "Variable::Variable(): INT: %d", _value.i);
+		debugC(7, kDebugLoading, "Variable::Variable(): %s: %d", variableTypeToStr(_type), _value.i);
 		break;
 	}
 
 	default: {
-		error("Variable::Variable(): Got unknown variable value type 0x%x", static_cast<uint>(_type));
+		error("Variable::Variable(): Got unknown variable value type %s (%d)", variableTypeToStr(_type), static_cast<uint>(_type));
 	}
 	}
 }
@@ -157,7 +158,7 @@ Operand Variable::getValue() {
 	}
 
 	default: {
-		error("Variable::getValue(): Attempt to get value from unknown variable type 0x%x", static_cast<uint>(_type));
+		error("Variable::getValue(): Attempt to get value from unknown variable type %s (%d)", variableTypeToStr(_type), static_cast<uint>(_type));
 	}
 	}
 }
@@ -178,7 +179,7 @@ Operand Variable::callMethod(BuiltInMethod method, Common::Array<Operand> &args)
 	}
 
 	default: {
-		error("Variable::callMethod(): Calling method on unknown variable type 0x%x", static_cast<uint>(_type));
+		error("Variable::callMethod(): Calling method on unknown variable type %s (%d)", variableTypeToStr(_type), static_cast<uint>(_type));
 	}
 	}
 }




More information about the Scummvm-git-logs mailing list