From 5af1ccbac66925f4521419a36a970bff4259e984 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 26 May 2012 16:41:11 +0300 Subject: SCI: Implement kGetConfig and kGetSierraProfileInt This fixes the sluggish game speed in Phantasmagoria (DOS/Windows) --- engines/sci/engine/kmisc.cpp | 46 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) (limited to 'engines/sci/engine/kmisc.cpp') diff --git a/engines/sci/engine/kmisc.cpp b/engines/sci/engine/kmisc.cpp index a32480c168..2be9432521 100644 --- a/engines/sci/engine/kmisc.cpp +++ b/engines/sci/engine/kmisc.cpp @@ -356,10 +356,52 @@ reg_t kGetConfig(EngineState *s, int argc, reg_t *argv) { Common::String setting = s->_segMan->getString(argv[0]); reg_t data = readSelector(s->_segMan, argv[1], SELECTOR(data)); - warning("Get config setting %s", setting.c_str()); - s->_segMan->strcpy(data, ""); + // This function is used to get the benchmarked results stored in the + // resource.cfg configuration file in Phantasmagoria 1. Normally, + // the configuration file contains values stored by the installer + // regarding audio and video settings, which are then used by the + // executable. In Phantasmagoria, two extra executable files are used + // to perform system benchmarks: + // - CPUID for the CPU benchmarks, sets the cpu and cpuspeed settings + // - HDDTEC for the graphics and CD-ROM benchmarks, sets the videospeed setting + // + // These settings are then used by the game scripts directly to modify + // the game speed and graphics output. The result of this call is stored + // in global 178. The scripts check these values against the value 425. + // Anything below that makes Phantasmagoria awfully sluggish, so we're + // setting everything to 500, which makes the game playable. + + if (setting == "videospeed") { + s->_segMan->strcpy(data, "500"); + } else if (setting == "cpu") { + // We always return the fastest CPU setting that CPUID can detect + // (i.e. 586). + s->_segMan->strcpy(data, "586"); + } else if (setting == "cpuspeed") { + s->_segMan->strcpy(data, "500"); + } else { + error("GetConfig: Unknown configuration setting %s", setting.c_str()); + } + return argv[1]; } + +reg_t kGetSierraProfileInt(EngineState *s, int argc, reg_t *argv) { + Common::String category = s->_segMan->getString(argv[0]); // always "config" + if (category != "config") + error("GetSierraProfileInt: category isn't 'config', it's '%s'", category.c_str()); + + Common::String setting = s->_segMan->getString(argv[1]); + if (setting != "videospeed") + error("GetSierraProfileInt: setting isn't 'videospeed', it's '%s'", setting.c_str()); + + // The game scripts pass 425 as the third parameter for some unknown reason, + // as after the call they compare the result to 425 anyway... + + // We return the same fake value for videospeed as with kGetConfig + return make_reg(0, 500); +} + #endif // kIconBar is really a subop of kMacPlatform for SCI1.1 Mac -- cgit v1.2.3 From 403b646c13f0729a32c21f89a2e9284d84df34cf Mon Sep 17 00:00:00 2001 From: Lars Skovlund Date: Wed, 30 May 2012 18:43:39 +0200 Subject: SCI32: Case-insensitive configuration getters --- engines/sci/engine/kmisc.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'engines/sci/engine/kmisc.cpp') diff --git a/engines/sci/engine/kmisc.cpp b/engines/sci/engine/kmisc.cpp index 2be9432521..2911af97df 100644 --- a/engines/sci/engine/kmisc.cpp +++ b/engines/sci/engine/kmisc.cpp @@ -371,6 +371,8 @@ reg_t kGetConfig(EngineState *s, int argc, reg_t *argv) { // Anything below that makes Phantasmagoria awfully sluggish, so we're // setting everything to 500, which makes the game playable. + setting.toLowercase(); + if (setting == "videospeed") { s->_segMan->strcpy(data, "500"); } else if (setting == "cpu") { @@ -388,10 +390,12 @@ reg_t kGetConfig(EngineState *s, int argc, reg_t *argv) { reg_t kGetSierraProfileInt(EngineState *s, int argc, reg_t *argv) { Common::String category = s->_segMan->getString(argv[0]); // always "config" + category.toLowercase(); if (category != "config") error("GetSierraProfileInt: category isn't 'config', it's '%s'", category.c_str()); Common::String setting = s->_segMan->getString(argv[1]); + setting.toLowercase(); if (setting != "videospeed") error("GetSierraProfileInt: setting isn't 'videospeed', it's '%s'", setting.c_str()); -- cgit v1.2.3 From c1dd3d5c2986f6c688eaf5ea80034658840b2828 Mon Sep 17 00:00:00 2001 From: Lars Skovlund Date: Sat, 2 Jun 2012 18:50:46 +0200 Subject: SCI32: Implement GetConfig("language") --- engines/sci/engine/kmisc.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'engines/sci/engine/kmisc.cpp') diff --git a/engines/sci/engine/kmisc.cpp b/engines/sci/engine/kmisc.cpp index 2911af97df..9a113bc5f9 100644 --- a/engines/sci/engine/kmisc.cpp +++ b/engines/sci/engine/kmisc.cpp @@ -381,6 +381,9 @@ reg_t kGetConfig(EngineState *s, int argc, reg_t *argv) { s->_segMan->strcpy(data, "586"); } else if (setting == "cpuspeed") { s->_segMan->strcpy(data, "500"); + } else if (setting == "language") { + Common::String languageId = Common::String::format("%d", g_sci->getSciLanguage()); + s->_segMan->strcpy(data, languageId.c_str()); } else { error("GetConfig: Unknown configuration setting %s", setting.c_str()); } -- cgit v1.2.3 From ca3ea849d808b7f184cb05c42c317ed19edb73fc Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 9 Jun 2012 16:29:14 +0300 Subject: SCI: Update information on kGetSierraProfileInt Thanks to LePhilousophe for his feedback and observations on this --- engines/sci/engine/kmisc.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'engines/sci/engine/kmisc.cpp') diff --git a/engines/sci/engine/kmisc.cpp b/engines/sci/engine/kmisc.cpp index 9a113bc5f9..f243cf2ffe 100644 --- a/engines/sci/engine/kmisc.cpp +++ b/engines/sci/engine/kmisc.cpp @@ -391,6 +391,8 @@ reg_t kGetConfig(EngineState *s, int argc, reg_t *argv) { return argv[1]; } +// Likely modelled after the Windows 3.1 function GetPrivateProfileInt: +// http://msdn.microsoft.com/en-us/library/windows/desktop/ms724345%28v=vs.85%29.aspx reg_t kGetSierraProfileInt(EngineState *s, int argc, reg_t *argv) { Common::String category = s->_segMan->getString(argv[0]); // always "config" category.toLowercase(); @@ -402,8 +404,7 @@ reg_t kGetSierraProfileInt(EngineState *s, int argc, reg_t *argv) { if (setting != "videospeed") error("GetSierraProfileInt: setting isn't 'videospeed', it's '%s'", setting.c_str()); - // The game scripts pass 425 as the third parameter for some unknown reason, - // as after the call they compare the result to 425 anyway... + // The third parameter is 425 (the default if the configuration key is missing) // We return the same fake value for videospeed as with kGetConfig return make_reg(0, 500); -- cgit v1.2.3 From 15306bc554b926e7d50f6a443766065e684557f3 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 11 Jun 2012 20:28:28 +0300 Subject: SCI: Return the default value for unknown configuration settings Based on a patch by LePhilousophe --- engines/sci/engine/kmisc.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'engines/sci/engine/kmisc.cpp') diff --git a/engines/sci/engine/kmisc.cpp b/engines/sci/engine/kmisc.cpp index f243cf2ffe..1cbaf0708d 100644 --- a/engines/sci/engine/kmisc.cpp +++ b/engines/sci/engine/kmisc.cpp @@ -396,18 +396,17 @@ reg_t kGetConfig(EngineState *s, int argc, reg_t *argv) { reg_t kGetSierraProfileInt(EngineState *s, int argc, reg_t *argv) { Common::String category = s->_segMan->getString(argv[0]); // always "config" category.toLowercase(); - if (category != "config") - error("GetSierraProfileInt: category isn't 'config', it's '%s'", category.c_str()); - Common::String setting = s->_segMan->getString(argv[1]); setting.toLowercase(); - if (setting != "videospeed") - error("GetSierraProfileInt: setting isn't 'videospeed', it's '%s'", setting.c_str()); + // The third parameter is the default value returned if the configuration key is missing - // The third parameter is 425 (the default if the configuration key is missing) + if (category == "config" && setting == "videospeed") { + // We return the same fake value for videospeed as with kGetConfig + return make_reg(0, 500); + } - // We return the same fake value for videospeed as with kGetConfig - return make_reg(0, 500); + warning("kGetSierraProfileInt: Returning default value %d for unknown setting %s.%s", argv[2].toSint16(), category.c_str(), setting.c_str()); + return argv[2]; } #endif -- cgit v1.2.3 From 93024c073be6d93c9369a83e4b4468bb0aaeeadd Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 13 Jun 2012 12:26:13 +0300 Subject: SCI: Handle the torindebug config setting for Torin's Passage French Thanks to LePhilousophe for testing and providing a patch --- engines/sci/engine/kmisc.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'engines/sci/engine/kmisc.cpp') diff --git a/engines/sci/engine/kmisc.cpp b/engines/sci/engine/kmisc.cpp index 1cbaf0708d..47c891eefd 100644 --- a/engines/sci/engine/kmisc.cpp +++ b/engines/sci/engine/kmisc.cpp @@ -384,6 +384,10 @@ reg_t kGetConfig(EngineState *s, int argc, reg_t *argv) { } else if (setting == "language") { Common::String languageId = Common::String::format("%d", g_sci->getSciLanguage()); s->_segMan->strcpy(data, languageId.c_str()); + } else if (setting == "torindebug") { + // Used to enable the debug mode in Torin's Passage (French). + // If true, the debug mode is enabled. + s->_segMan->strcpy(data, ""); } else { error("GetConfig: Unknown configuration setting %s", setting.c_str()); } -- cgit v1.2.3 From 0a3fb38bc728c11654810d426819853d86ae609c Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 14 Jun 2012 12:10:39 +0300 Subject: SCI: Add handling of two more configuration settings for LSL7 --- engines/sci/engine/kmisc.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'engines/sci/engine/kmisc.cpp') diff --git a/engines/sci/engine/kmisc.cpp b/engines/sci/engine/kmisc.cpp index 47c891eefd..2e80764d01 100644 --- a/engines/sci/engine/kmisc.cpp +++ b/engines/sci/engine/kmisc.cpp @@ -388,6 +388,12 @@ reg_t kGetConfig(EngineState *s, int argc, reg_t *argv) { // Used to enable the debug mode in Torin's Passage (French). // If true, the debug mode is enabled. s->_segMan->strcpy(data, ""); + } else if (setting == "leakdump") { + // An unknown setting in LSL7. Likely used for debugging. + s->_segMan->strcpy(data, ""); + } else if (setting == "startroom") { + // Debug setting in LSL7, specifies the room to start from. + s->_segMan->strcpy(data, ""); } else { error("GetConfig: Unknown configuration setting %s", setting.c_str()); } -- cgit v1.2.3 From 2b50824133ced47f1d8fb6407a1e0212a7eeb41c Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 18 Jun 2012 05:21:59 +0300 Subject: SCI: Add setter/getter methods to reg_t's No functionality change has been made with this commit. This avoids setting and getting the reg_t members directly, and is the basis of any future work on large SCI3 scripts (larger than 64KB) --- engines/sci/engine/kmisc.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'engines/sci/engine/kmisc.cpp') diff --git a/engines/sci/engine/kmisc.cpp b/engines/sci/engine/kmisc.cpp index 2e80764d01..12c830f622 100644 --- a/engines/sci/engine/kmisc.cpp +++ b/engines/sci/engine/kmisc.cpp @@ -128,7 +128,7 @@ reg_t kMemoryInfo(EngineState *s, int argc, reg_t *argv) { // fragmented const uint16 size = 0x7fea; - switch (argv[0].offset) { + switch (argv[0].getOffset()) { case K_MEMORYINFO_LARGEST_HEAP_BLOCK: // In order to prevent "Memory fragmented" dialogs from // popping up in some games, we must return FREE_HEAP - 2 here. @@ -140,7 +140,7 @@ reg_t kMemoryInfo(EngineState *s, int argc, reg_t *argv) { return make_reg(0, size); default: - error("Unknown MemoryInfo operation: %04x", argv[0].offset); + error("Unknown MemoryInfo operation: %04x", argv[0].getOffset()); } return NULL_REG; @@ -304,7 +304,7 @@ reg_t kMemory(EngineState *s, int argc, reg_t *argv) { break; } case K_MEMORY_PEEK : { - if (!argv[1].segment) { + if (!argv[1].getSegment()) { // This occurs in KQ5CD when interacting with certain objects warning("Attempt to peek invalid memory at %04x:%04x", PRINT_REG(argv[1])); return s->r_acc; @@ -334,11 +334,11 @@ reg_t kMemory(EngineState *s, int argc, reg_t *argv) { } if (ref.isRaw) { - if (argv[2].segment) { + if (argv[2].getSegment()) { error("Attempt to poke memory reference %04x:%04x to %04x:%04x", PRINT_REG(argv[2]), PRINT_REG(argv[1])); return s->r_acc; } - WRITE_SCIENDIAN_UINT16(ref.raw, argv[2].offset); // Amiga versions are BE + WRITE_SCIENDIAN_UINT16(ref.raw, argv[2].getOffset()); // Amiga versions are BE } else { if (ref.skipByte) error("Attempt to poke memory at odd offset %04X:%04X", PRINT_REG(argv[1])); -- cgit v1.2.3 From 5a47afea9ed5d0cca89ca01d48be937dcba02bbd Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 3 Jul 2012 18:11:41 +0300 Subject: SCI: Move kGetWindowsOption together with the other misc kernel functions --- engines/sci/engine/kmisc.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'engines/sci/engine/kmisc.cpp') diff --git a/engines/sci/engine/kmisc.cpp b/engines/sci/engine/kmisc.cpp index 12c830f622..8b7fc4ffec 100644 --- a/engines/sci/engine/kmisc.cpp +++ b/engines/sci/engine/kmisc.cpp @@ -419,6 +419,18 @@ reg_t kGetSierraProfileInt(EngineState *s, int argc, reg_t *argv) { return argv[2]; } +reg_t kGetWindowsOption(EngineState *s, int argc, reg_t *argv) { + uint16 windowsOption = argv[0].toUint16(); + switch (windowsOption) { + case 0: + // Title bar on/off in Phantasmagoria, we return 0 (off) + return NULL_REG; + default: + warning("GetWindowsOption: Unknown option %d", windowsOption); + return NULL_REG; + } +} + #endif // kIconBar is really a subop of kMacPlatform for SCI1.1 Mac -- cgit v1.2.3