Skip to content

Commit

Permalink
SCI: Implement kGetConfig and kGetSierraProfileInt
Browse files Browse the repository at this point in the history
This fixes the sluggish game speed in Phantasmagoria (DOS/Windows)
  • Loading branch information
bluegr committed May 26, 2012
1 parent b4152bd commit 5af1ccb
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 7 deletions.
1 change: 1 addition & 0 deletions engines/sci/engine/kernel.h
Expand Up @@ -475,6 +475,7 @@ reg_t kMoveToEnd(EngineState *s, int argc, reg_t *argv);
reg_t kGetWindowsOption(EngineState *s, int argc, reg_t *argv);
reg_t kWinHelp(EngineState *s, int argc, reg_t *argv);
reg_t kGetConfig(EngineState *s, int argc, reg_t *argv);
reg_t kGetSierraProfileInt(EngineState *s, int argc, reg_t *argv);
reg_t kCelInfo(EngineState *s, int argc, reg_t *argv);
reg_t kSetLanguage(EngineState *s, int argc, reg_t *argv);
reg_t kScrollWindow(EngineState *s, int argc, reg_t *argv);
Expand Down
6 changes: 1 addition & 5 deletions engines/sci/engine/kernel_tables.h
Expand Up @@ -560,6 +560,7 @@ static SciKernelMapEntry s_kernelMap[] = {
{ MAP_CALL(GetWindowsOption), SIG_EVERYWHERE, "i", NULL, NULL },
{ MAP_CALL(WinHelp), SIG_EVERYWHERE, "(.*)", NULL, NULL },
{ MAP_CALL(GetConfig), SIG_EVERYWHERE, "ro", NULL, NULL },
{ MAP_CALL(GetSierraProfileInt), SIG_EVERYWHERE, "rri", NULL, NULL },
{ MAP_CALL(CelInfo), SIG_EVERYWHERE, "iiiiii", NULL, NULL },
{ MAP_CALL(SetLanguage), SIG_EVERYWHERE, "r", NULL, NULL },
{ MAP_CALL(ScrollWindow), SIG_EVERYWHERE, "(.*)", NULL, NULL },
Expand All @@ -579,11 +580,6 @@ static SciKernelMapEntry s_kernelMap[] = {
// the game window in Phantasmagoria 2. We ignore these settings completely.
{ MAP_EMPTY(SetWindowsOption), SIG_EVERYWHERE, "ii", NULL, NULL },

// Used by the Windows version of Phantasmagoria 1 to get the video speed setting. This is called after
// kGetConfig and overrides the setting obtained by it. It is a dummy function in the DOS Version. We can
// just use GetConfig and mark this one as empty, like the DOS version does.
{ MAP_EMPTY(GetSierraProfileInt), SIG_EVERYWHERE, "(.*)", NULL, NULL },

// Debug function called whenever the current room changes
{ MAP_EMPTY(NewRoom), SIG_EVERYWHERE, "(.*)", NULL, NULL },

Expand Down
46 changes: 44 additions & 2 deletions engines/sci/engine/kmisc.cpp
Expand Up @@ -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
Expand Down

0 comments on commit 5af1ccb

Please sign in to comment.