[Scummvm-cvs-logs] SF.net SVN: scummvm:[50020] scummvm/trunk/engines/sci

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Fri Jun 18 16:48:40 CEST 2010


Revision: 50020
          http://scummvm.svn.sourceforge.net/scummvm/?rev=50020&view=rev
Author:   thebluegr
Date:     2010-06-18 14:48:39 +0000 (Fri, 18 Jun 2010)

Log Message:
-----------
Added hints inside validate_arithmetic(), together with some code useful for debugging. Some cleanup

Modified Paths:
--------------
    scummvm/trunk/engines/sci/engine/vm.cpp
    scummvm/trunk/engines/sci/sound/drivers/adlib.cpp

Modified: scummvm/trunk/engines/sci/engine/vm.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/vm.cpp	2010-06-18 14:36:22 UTC (rev 50019)
+++ scummvm/trunk/engines/sci/engine/vm.cpp	2010-06-18 14:48:39 UTC (rev 50020)
@@ -128,8 +128,10 @@
 
 static int validate_arithmetic(reg_t reg) {
 	if (reg.segment) {
-		// The results of this are likely unpredictable...
-		error("[VM] Attempt to read arithmetic value from non-zero segment [%04x]", reg.segment);
+		// The results of this are likely unpredictable... It most likely means that a kernel function is returning something wrong.
+		// If such an error occurs, we usually need to find the last kernel function called and check its return value. Check
+		// callKernelFunc() below
+		error("[VM] Attempt to read arithmetic value from non-zero segment [%04x]. Address: %04x:%04x", reg.segment, PRINT_REG(reg));
 		return 0;
 	}
 
@@ -137,13 +139,7 @@
 }
 
 static int signed_validate_arithmetic(reg_t reg) {
-	if (reg.segment) {
-		// The results of this are likely unpredictable...
-		error("[VM] Attempt to read arithmetic value from non-zero segment [%04x]", reg.segment);
-		return 0;
-	}
-
-	return (int16)reg.offset;
+	return (int16)validate_arithmetic(reg);
 }
 
 static bool validate_variable(reg_t *r, reg_t *stack_base, int type, int max, int index, int line) {
@@ -617,6 +613,22 @@
 		} else {
 			// Call kernel function
 			s->r_acc = kernelFunc.func(s, argc, argv);
+
+#if 0
+			// Used for debugging
+			Common::String debugMsg = kernelFunc.origName +
+										Common::String::printf("[0x%x]", kernelFuncNum) +
+										Common::String::printf(", %d params: ", argc) + 
+										" (";
+
+			for (int i = 0; i < argc; i++) {
+				debugMsg +=  Common::String::printf("%04x:%04x", PRINT_REG(argv[i]));
+				debugMsg += (i == argc - 1 ? ")" : ", ");
+			}
+
+			debugMsg += ", result: " + Common::String::printf("%04x:%04x", PRINT_REG(s->r_acc));
+			debug("%s", debugMsg.c_str());
+#endif
 		}
 
 		// Remove callk stack frame again

Modified: scummvm/trunk/engines/sci/sound/drivers/adlib.cpp
===================================================================
--- scummvm/trunk/engines/sci/sound/drivers/adlib.cpp	2010-06-18 14:36:22 UTC (rev 50019)
+++ scummvm/trunk/engines/sci/sound/drivers/adlib.cpp	2010-06-18 14:48:39 UTC (rev 50020)
@@ -705,7 +705,7 @@
 	if ((patch < 0) || ((uint)patch >= _patches.size())) {
 		// This happens a lot at least in PQ2. This game has a small patch.003 (1344 bytes),
 		// containing 48 instruments. However it has several songs which use instruments
-		// not specified in that patch (namely, songs 1, 3, 5, 9, 15,  16, 17, 23, 25, 27,
+		// not specified in that patch (namely, songs 1, 3, 5, 9, 15, 16, 17, 23, 25, 27,
 		// 29, 32, 36, 38, 44, 45, 46 all use instruments not specified in patch.003).
 		// These were probably written for MT32. These warnings in PQ2 can probably go away
 		// if a bigger patch.003 file is used (one that contains all the instruments used


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list