diff options
Diffstat (limited to 'engines/sci')
-rw-r--r-- | engines/sci/engine/vm.cpp | 30 | ||||
-rw-r--r-- | engines/sci/sound/drivers/adlib.cpp | 2 |
2 files changed, 22 insertions, 10 deletions
diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp index c3f27b77b3..706d2ceb22 100644 --- a/engines/sci/engine/vm.cpp +++ b/engines/sci/engine/vm.cpp @@ -128,8 +128,10 @@ static StackPtr validate_stack_addr(EngineState *s, StackPtr sp) { 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 validate_arithmetic(reg_t reg) { } 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 @@ static void callKernelFunc(EngineState *s, int kernelFuncNum, int argc) { } 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 diff --git a/engines/sci/sound/drivers/adlib.cpp b/engines/sci/sound/drivers/adlib.cpp index 2e56b023e0..d0ca00fe0f 100644 --- a/engines/sci/sound/drivers/adlib.cpp +++ b/engines/sci/sound/drivers/adlib.cpp @@ -705,7 +705,7 @@ void MidiDriver_AdLib::setPatch(int voice, int patch) { 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 |