Skip to content

Commit

Permalink
BLADERUNNER: Add engine gui option to avoid use of delayMillis()
Browse files Browse the repository at this point in the history
  • Loading branch information
antoniou79 committed Sep 16, 2019
1 parent 5453653 commit 7c20b07
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 25 deletions.
16 changes: 11 additions & 5 deletions engines/bladerunner/bladerunner.cpp
Expand Up @@ -111,9 +111,10 @@ BladeRunnerEngine::BladeRunnerEngine(OSystem *syst, const ADGameDescription *des

_subtitlesEnabled = false;

_sitcomMode = false;
_shortyMode = false;
_cutContent = Common::String(desc->gameId).contains("bladerunner-final");
_sitcomMode = false;
_shortyMode = false;
_noDelayMillisFramelimiter = false;
_cutContent = Common::String(desc->gameId).contains("bladerunner-final");

_playerLosesControlCounter = 0;

Expand Down Expand Up @@ -559,8 +560,13 @@ bool BladeRunnerEngine::startup(bool hasSavegames) {
// get value from the ScummVM configuration manager
syncSoundSettings();

_sitcomMode = ConfMan.getBool("sitcom");
_shortyMode = ConfMan.getBool("shorty");
_sitcomMode = ConfMan.getBool("sitcom");
_shortyMode = ConfMan.getBool("shorty");

if (!ConfMan.hasKey("nodelaymillisfl")) {
ConfMan.setBool("nodelaymillisfl", false);
}
_noDelayMillisFramelimiter = ConfMan.getBool("nodelaymillisfl");
// BLADE.INI was read here, but it was replaced by ScummVM configuration

_chapters = new Chapters(this);
Expand Down
1 change: 1 addition & 0 deletions engines/bladerunner/bladerunner.h
Expand Up @@ -215,6 +215,7 @@ class BladeRunnerEngine : public Engine {
bool _subtitlesEnabled; // tracks the state of whether subtitles are enabled or disabled from ScummVM GUI option or KIA checkbox (the states are synched)
bool _sitcomMode;
bool _shortyMode;
bool _noDelayMillisFramelimiter;
bool _cutContent;

int _walkSoundId;
Expand Down
9 changes: 9 additions & 0 deletions engines/bladerunner/detection.cpp
Expand Up @@ -60,6 +60,15 @@ static const ADExtraGuiOptionsMap optionsList[] = {
false
}
},
{
GAMEOPTION_FRAMELIMITER_NODELAYMILLIS,
{
_s("Frame limiter high performance mode"),
_s("This mode may result in high CPU usage! It avoids use of delayMillis() function."),
"nodelaymillisfl",
false
}
},
AD_EXTRA_GUI_OPTIONS_TERMINATOR
};

Expand Down
36 changes: 18 additions & 18 deletions engines/bladerunner/detection_tables.h
Expand Up @@ -25,9 +25,9 @@

#include "engines/advancedDetector.h"

#define GAMEOPTION_SITCOM GUIO_GAMEOPTIONS1
#define GAMEOPTION_SHORTY GUIO_GAMEOPTIONS2
#define GAMEOPTION_CUT_CONTENT GUIO_GAMEOPTIONS3
#define GAMEOPTION_SITCOM GUIO_GAMEOPTIONS1
#define GAMEOPTION_SHORTY GUIO_GAMEOPTIONS2
#define GAMEOPTION_FRAMELIMITER_NODELAYMILLIS GUIO_GAMEOPTIONS3

namespace BladeRunner {

Expand All @@ -40,7 +40,7 @@ static const ADGameDescription gameDescriptions[] = {
Common::EN_ANY,
Common::kPlatformWindows,
ADGF_TESTING,
GUIO2(GAMEOPTION_SITCOM, GAMEOPTION_SHORTY)
GUIO3(GAMEOPTION_SITCOM, GAMEOPTION_SHORTY, GAMEOPTION_FRAMELIMITER_NODELAYMILLIS)
},

// BladeRunner (German)
Expand All @@ -51,7 +51,7 @@ static const ADGameDescription gameDescriptions[] = {
Common::DE_DEU,
Common::kPlatformWindows,
ADGF_TESTING,
GUIO2(GAMEOPTION_SITCOM, GAMEOPTION_SHORTY)
GUIO3(GAMEOPTION_SITCOM, GAMEOPTION_SHORTY, GAMEOPTION_FRAMELIMITER_NODELAYMILLIS)
},

// BladeRunner (French) - Bug #9722
Expand All @@ -62,7 +62,7 @@ static const ADGameDescription gameDescriptions[] = {
Common::FR_FRA,
Common::kPlatformWindows,
ADGF_TESTING,
GUIO2(GAMEOPTION_SITCOM, GAMEOPTION_SHORTY)
GUIO3(GAMEOPTION_SITCOM, GAMEOPTION_SHORTY, GAMEOPTION_FRAMELIMITER_NODELAYMILLIS)
},

// BladeRunner (Italian)
Expand All @@ -73,7 +73,7 @@ static const ADGameDescription gameDescriptions[] = {
Common::IT_ITA,
Common::kPlatformWindows,
ADGF_TESTING,
GUIO2(GAMEOPTION_SITCOM, GAMEOPTION_SHORTY)
GUIO3(GAMEOPTION_SITCOM, GAMEOPTION_SHORTY, GAMEOPTION_FRAMELIMITER_NODELAYMILLIS)
},

// BladeRunner (Russian - Fargus Multimedia + Home Systems, Inc.)
Expand All @@ -84,7 +84,7 @@ static const ADGameDescription gameDescriptions[] = {
Common::RU_RUS,
Common::kPlatformWindows,
ADGF_TESTING,
GUIO2(GAMEOPTION_SITCOM, GAMEOPTION_SHORTY)
GUIO3(GAMEOPTION_SITCOM, GAMEOPTION_SHORTY, GAMEOPTION_FRAMELIMITER_NODELAYMILLIS)
},

// BladeRunner (Russian - Fargus Multimedia + Home Systems, Inc. + Siberian Studio, R3)
Expand All @@ -95,7 +95,7 @@ static const ADGameDescription gameDescriptions[] = {
Common::RU_RUS,
Common::kPlatformWindows,
ADGF_TESTING,
GUIO2(GAMEOPTION_SITCOM, GAMEOPTION_SHORTY)
GUIO3(GAMEOPTION_SITCOM, GAMEOPTION_SHORTY, GAMEOPTION_FRAMELIMITER_NODELAYMILLIS)
},

// BladeRunner (Russian - Fargus Multimedia + Home Systems, Inc. + Siberian Studio, R4)
Expand All @@ -106,7 +106,7 @@ static const ADGameDescription gameDescriptions[] = {
Common::RU_RUS,
Common::kPlatformWindows,
ADGF_TESTING,
GUIO2(GAMEOPTION_SITCOM, GAMEOPTION_SHORTY)
GUIO3(GAMEOPTION_SITCOM, GAMEOPTION_SHORTY, GAMEOPTION_FRAMELIMITER_NODELAYMILLIS)
},

// BladeRunner (Spanish)
Expand All @@ -117,7 +117,7 @@ static const ADGameDescription gameDescriptions[] = {
Common::ES_ESP,
Common::kPlatformWindows,
ADGF_TESTING,
GUIO2(GAMEOPTION_SITCOM, GAMEOPTION_SHORTY)
GUIO3(GAMEOPTION_SITCOM, GAMEOPTION_SHORTY, GAMEOPTION_FRAMELIMITER_NODELAYMILLIS)
},

// Versions with restored content
Expand All @@ -130,7 +130,7 @@ static const ADGameDescription gameDescriptions[] = {
Common::EN_ANY,
Common::kPlatformWindows,
ADGF_UNSTABLE,
GUIO2(GAMEOPTION_SITCOM, GAMEOPTION_SHORTY)
GUIO3(GAMEOPTION_SITCOM, GAMEOPTION_SHORTY, GAMEOPTION_FRAMELIMITER_NODELAYMILLIS)
},

// BladeRunner (German)
Expand All @@ -141,7 +141,7 @@ static const ADGameDescription gameDescriptions[] = {
Common::DE_DEU,
Common::kPlatformWindows,
ADGF_UNSTABLE,
GUIO2(GAMEOPTION_SITCOM, GAMEOPTION_SHORTY)
GUIO3(GAMEOPTION_SITCOM, GAMEOPTION_SHORTY, GAMEOPTION_FRAMELIMITER_NODELAYMILLIS)
},

// BladeRunner (French)
Expand All @@ -152,7 +152,7 @@ static const ADGameDescription gameDescriptions[] = {
Common::FR_FRA,
Common::kPlatformWindows,
ADGF_UNSTABLE,
GUIO2(GAMEOPTION_SITCOM, GAMEOPTION_SHORTY)
GUIO3(GAMEOPTION_SITCOM, GAMEOPTION_SHORTY, GAMEOPTION_FRAMELIMITER_NODELAYMILLIS)
},

// BladeRunner (Italian)
Expand All @@ -163,7 +163,7 @@ static const ADGameDescription gameDescriptions[] = {
Common::IT_ITA,
Common::kPlatformWindows,
ADGF_UNSTABLE,
GUIO2(GAMEOPTION_SITCOM, GAMEOPTION_SHORTY)
GUIO3(GAMEOPTION_SITCOM, GAMEOPTION_SHORTY, GAMEOPTION_FRAMELIMITER_NODELAYMILLIS)
},

// BladeRunner (Russian - Fargus Multimedia + Home Systems, Inc.)
Expand All @@ -174,7 +174,7 @@ static const ADGameDescription gameDescriptions[] = {
Common::RU_RUS,
Common::kPlatformWindows,
ADGF_UNSTABLE,
GUIO2(GAMEOPTION_SITCOM, GAMEOPTION_SHORTY)
GUIO3(GAMEOPTION_SITCOM, GAMEOPTION_SHORTY, GAMEOPTION_FRAMELIMITER_NODELAYMILLIS)
},

// BladeRunner (Russian - Fargus Multimedia + Home Systems, Inc. + Siberian Studio, R3)
Expand All @@ -185,7 +185,7 @@ static const ADGameDescription gameDescriptions[] = {
Common::RU_RUS,
Common::kPlatformWindows,
ADGF_UNSTABLE,
GUIO2(GAMEOPTION_SITCOM, GAMEOPTION_SHORTY)
GUIO3(GAMEOPTION_SITCOM, GAMEOPTION_SHORTY, GAMEOPTION_FRAMELIMITER_NODELAYMILLIS)
},

// BladeRunner (Russian - Fargus Multimedia + Home Systems, Inc. + Siberian Studio, R4)
Expand All @@ -196,7 +196,7 @@ static const ADGameDescription gameDescriptions[] = {
Common::RU_RUS,
Common::kPlatformWindows,
ADGF_UNSTABLE,
GUIO2(GAMEOPTION_SITCOM, GAMEOPTION_SHORTY)
GUIO3(GAMEOPTION_SITCOM, GAMEOPTION_SHORTY, GAMEOPTION_FRAMELIMITER_NODELAYMILLIS)
},

AD_TABLE_END_MARKER
Expand Down
6 changes: 5 additions & 1 deletion engines/bladerunner/framelimiter.cpp
Expand Up @@ -56,7 +56,11 @@ void Framelimiter::wait() {
uint32 frameDuration = timeNow - _timeFrameStart;
if (frameDuration < _speedLimitMs) {
uint32 waittime = _speedLimitMs - frameDuration;
_vm->_system->delayMillis(waittime);
if (_vm->_noDelayMillisFramelimiter) {
while (_vm->_time->currentSystem() - timeNow < waittime) { }
} else {
_vm->_system->delayMillis(waittime);
}
timeNow += waittime;
}
// debug("frametime %i ms", timeNow - _timeFrameStart);
Expand Down
8 changes: 7 additions & 1 deletion engines/bladerunner/ui/kia.cpp
Expand Up @@ -666,8 +666,14 @@ void KIA::mouseDownCallback(int buttonId, void *callbackData) {
int endTrackId = self->_vm->_audioPlayer->playAud(self->_vm->_gameInfo->getSfxTrack(kSfxSHUTDOWN), 70, 0, 0, 50, 0);
if (endTrackId != -1) {
// wait until the full clip has played (similar to the original)
uint32 timeNow = self->_vm->_time->currentSystem();
uint32 waittime = 16;
while (self->_vm->_audioPlayer->isActive(endTrackId)) {
self->_vm->_system->delayMillis(16);
if (self->_vm->_noDelayMillisFramelimiter) {
while (self->_vm->_time->currentSystem() - timeNow < waittime) { }
} else {
self->_vm->_system->delayMillis(waittime);
}
}
}
}
Expand Down

0 comments on commit 7c20b07

Please sign in to comment.