SCUMM: Read the "enable_enhancements" setting only once

I can't change during gameplay, it's shorter to type, and we won't
accidentally involve the config manater in some tight loop.
This commit is contained in:
Torbjörn Andersson 2022-03-20 10:50:47 +01:00 committed by Torbjörn Andersson
parent afb807599b
commit cb561f462e
8 changed files with 18 additions and 17 deletions

View file

@ -20,7 +20,6 @@
*/ */
#include "common/system.h" // for setFocusRectangle/clearFocusRectangle #include "common/system.h" // for setFocusRectangle/clearFocusRectangle
#include "common/config-manager.h"
#include "scumm/scumm.h" #include "scumm/scumm.h"
#include "scumm/actor.h" #include "scumm/actor.h"
#include "scumm/actor_he.h" #include "scumm/actor_he.h"
@ -1610,7 +1609,7 @@ void Actor::putActor(int dstX, int dstY, int newRoom) {
// WORKAROUND: The green transparency of the tank in the Hall of Oddities // WORKAROUND: The green transparency of the tank in the Hall of Oddities
// is positioned one pixel too far to the left. This appears to be a bug // is positioned one pixel too far to the left. This appears to be a bug
// in the original game as well. // in the original game as well.
if (_vm->_game.id == GID_SAMNMAX && newRoom == 16 && _number == 5 && dstX == 235 && dstY == 236 && ConfMan.getBool("enable_enhancements")) if (_vm->_game.id == GID_SAMNMAX && newRoom == 16 && _number == 5 && dstX == 235 && dstY == 236 && _vm->_enableEnhancements)
dstX++; dstX++;
_pos.x = dstX; _pos.x = dstX;

View file

@ -20,7 +20,6 @@
*/ */
#include "common/system.h" #include "common/system.h"
#include "common/config-manager.h"
#include "graphics/macega.h" #include "graphics/macega.h"
#include "scumm/actor.h" #include "scumm/actor.h"
#include "scumm/charset.h" #include "scumm/charset.h"
@ -52,11 +51,9 @@ void ScummEngine::mac_drawStripToScreen(VirtScreen *vs, int top, int x, int y, i
// unmodified. At least, that's what Mini vMac did when I tried it. // unmodified. At least, that's what Mini vMac did when I tried it.
if (_renderMode == Common::kRenderMacintoshBW) { if (_renderMode == Common::kRenderMacintoshBW) {
bool enableEnhancements = ConfMan.getBool("enable_enhancements");
for (int h = 0; h < height; h++) { for (int h = 0; h < height; h++) {
for (int w = 0; w < width; w++) { for (int w = 0; w < width; w++) {
int color = enableEnhancements ? _shadowPalette[pixels[w]] : pixels[w]; int color = _enableEnhancements ? _shadowPalette[pixels[w]] : pixels[w];
if (ts[2 * w] == CHARSET_MASK_TRANSPARENCY) if (ts[2 * w] == CHARSET_MASK_TRANSPARENCY)
mac[2 * w] = Graphics::macEGADither[color][0]; mac[2 * w] = Graphics::macEGADither[color][0];
if (ts[2 * w + 1] == CHARSET_MASK_TRANSPARENCY) if (ts[2 * w + 1] == CHARSET_MASK_TRANSPARENCY)

View file

@ -1738,7 +1738,7 @@ void ScummEngine::applyWorkaroundIfNeeded(ResType type, int idx) {
// overwritten. This probably affects all CD versions, so we just have // overwritten. This probably affects all CD versions, so we just have
// to add further patches as they are reported. // to add further patches as they are reported.
if (_game.id == GID_MONKEY && type == rtRoom && idx == 25 && ConfMan.getBool("enable_enhancements")) { if (_game.id == GID_MONKEY && type == rtRoom && idx == 25 && _enableEnhancements) {
tryPatchMI1CannibalScript(getResourceAddress(type, idx), size); tryPatchMI1CannibalScript(getResourceAddress(type, idx), size);
} else } else

View file

@ -457,7 +457,7 @@ void ScummEngine_v5::o5_actorOps() {
// But in the VGA CD version, only costume 0 is used // But in the VGA CD version, only costume 0 is used
// and the close-up is missing the cigar smoke. // and the close-up is missing the cigar smoke.
if (_game.id == GID_MONKEY && _currentRoom == 76 && act == 12 && i == 0 && ConfMan.getBool("enable_enhancements")) { if (_game.id == GID_MONKEY && _currentRoom == 76 && act == 12 && i == 0 && _enableEnhancements) {
i = 76; i = 76;
} }
@ -670,7 +670,7 @@ void ScummEngine_v5::o5_add() {
// We restore the old behavior by adding 0, not 1, to the second // We restore the old behavior by adding 0, not 1, to the second
// variable when examining the clock tower. // variable when examining the clock tower.
if (_game.id == GID_MONKEY && vm.slot[_currentScript].number == 210 && _currentRoom == 35 && _resultVarNumber == 248 && a == 1 && ConfMan.getBool("enable_enhancements")) { if (_game.id == GID_MONKEY && vm.slot[_currentScript].number == 210 && _currentRoom == 35 && _resultVarNumber == 248 && a == 1 && _enableEnhancements) {
a = 0; a = 0;
} }
@ -1396,7 +1396,7 @@ void ScummEngine_v5::o5_isLessEqual() {
// together that they look like one. This adjusts the timing of the // together that they look like one. This adjusts the timing of the
// second one. // second one.
if (_game.id == GID_LOOM && _game.version >= 4 && _language == Common::EN_ANY && vm.slot[_currentScript].number == 95 && var == VAR_MUSIC_TIMER && b == 1708 && ConfMan.getBool("enable_enhancements")) { if (_game.id == GID_LOOM && _game.version >= 4 && _language == Common::EN_ANY && vm.slot[_currentScript].number == 95 && var == VAR_MUSIC_TIMER && b == 1708 && _enableEnhancements) {
b = 1815; b = 1815;
} }
@ -1650,7 +1650,7 @@ void ScummEngine_v5::o5_putActor() {
// other coordinates. The difference is never more than a single pixel, // other coordinates. The difference is never more than a single pixel,
// so there's not much reason to correct those. // so there's not much reason to correct those.
if (_game.id == GID_MONKEY && _currentRoom == 76 && act == 12 && ConfMan.getBool("enable_enhancements")) { if (_game.id == GID_MONKEY && _currentRoom == 76 && act == 12 && _enableEnhancements) {
if (x == 176 && y == 80) { if (x == 176 && y == 80) {
x = 174; x = 174;
y = 86; y = 86;
@ -1922,7 +1922,7 @@ void ScummEngine_v5::o5_roomOps() {
// we want the original color 3 for the cigar smoke. It // we want the original color 3 for the cigar smoke. It
// should be ok since there is no GUI in this scene. // should be ok since there is no GUI in this scene.
if (_game.id == GID_MONKEY && _currentRoom == 76 && d == 3 && ConfMan.getBool("enable_enhancements")) if (_game.id == GID_MONKEY && _currentRoom == 76 && d == 3 && _enableEnhancements)
break; break;
setPalColor(d, a, b, c); /* index, r, g, b */ setPalColor(d, a, b, c); /* index, r, g, b */
@ -2341,7 +2341,7 @@ void ScummEngine_v5::o5_stopSound() {
// 10001 regardless of which room it is. We figure out which one by // 10001 regardless of which room it is. We figure out which one by
// looking at which rooms we're moving between. // looking at which rooms we're moving between.
if (_game.id == GID_MONKEY && (_game.features & GF_AUDIOTRACKS) && sound == 126 && vm.slot[_currentScript].number == 10001 && VAR(VAR_ROOM) == 43 && VAR(VAR_NEW_ROOM) == 76 && ConfMan.getBool("enable_enhancements")) { if (_game.id == GID_MONKEY && (_game.features & GF_AUDIOTRACKS) && sound == 126 && vm.slot[_currentScript].number == 10001 && VAR(VAR_ROOM) == 43 && VAR(VAR_NEW_ROOM) == 76 && _enableEnhancements) {
return; return;
} }
@ -2977,7 +2977,7 @@ void ScummEngine_v5::decodeParseString() {
case 15:{ // SO_TEXTSTRING case 15:{ // SO_TEXTSTRING
const int len = resStrLen(_scriptPointer); const int len = resStrLen(_scriptPointer);
if (_game.id == GID_LOOM && vm.slot[_currentScript].number == 95 && strcmp((const char *)_scriptPointer, "I am Choas.") == 0 && ConfMan.getBool("enable_enhancements")) { if (_game.id == GID_LOOM && vm.slot[_currentScript].number == 95 && _enableEnhancements && strcmp((const char *)_scriptPointer, "I am Choas.") == 0) {
// WORKAROUND: This happens when Chaos introduces // WORKAROUND: This happens when Chaos introduces
// herself to bishop Mandible. Of all the places to put // herself to bishop Mandible. Of all the places to put
// a typo... // a typo...

View file

@ -109,7 +109,8 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr)
_currentScript(0xFF), // Let debug() work on init stage _currentScript(0xFF), // Let debug() work on init stage
_messageDialog(nullptr), _pauseDialog(nullptr), _versionDialog(nullptr), _messageDialog(nullptr), _pauseDialog(nullptr), _versionDialog(nullptr),
_rnd("scumm"), _rnd("scumm"),
_shakeTimerRate(dr.game.version <= 3 ? 236696 : 291304) _shakeTimerRate(dr.game.version <= 3 ? 236696 : 291304),
_enableEnhancements(false)
{ {
_localizer = nullptr; _localizer = nullptr;
@ -1114,6 +1115,8 @@ Common::Error ScummEngine::init() {
const Common::FSNode gameDataDir(ConfMan.get("path")); const Common::FSNode gameDataDir(ConfMan.get("path"));
_enableEnhancements = ConfMan.getBool("enable_enhancements");
// Add default file directories. // Add default file directories.
if (((_game.platform == Common::kPlatformAmiga) || (_game.platform == Common::kPlatformAtariST)) && (_game.version <= 4)) { if (((_game.platform == Common::kPlatformAmiga) || (_game.platform == Common::kPlatformAtariST)) && (_game.version <= 4)) {
// This is for the Amiga version of Indy3/Loom/Maniac/Zak // This is for the Amiga version of Indy3/Loom/Maniac/Zak

View file

@ -314,6 +314,8 @@ public:
/** Central resource data. */ /** Central resource data. */
ResourceManager *_res; ResourceManager *_res;
bool _enableEnhancements;
protected: protected:
VirtualMachineState vm; VirtualMachineState vm;

View file

@ -1496,7 +1496,7 @@ int ScummEngine::readSoundResource(ResId idx) {
// Some of the Mac MI2 music only exists as Roland tracks. The // Some of the Mac MI2 music only exists as Roland tracks. The
// original interpreter doesn't play them. I don't think there // original interpreter doesn't play them. I don't think there
// is any similarly missing FoA music. // is any similarly missing FoA music.
if (_game.id == GID_MONKEY2 && _game.platform == Common::kPlatformMacintosh && !ConfMan.getBool("enable_enhancements")) { if (_game.id == GID_MONKEY2 && _game.platform == Common::kPlatformMacintosh && !_enableEnhancements) {
pri = -1; pri = -1;
break; break;
} }

View file

@ -68,7 +68,7 @@ void ScummEngine::printString(int m, const byte *msg) {
vm.slot[_currentScript].number == 203 && vm.slot[_currentScript].number == 203 &&
_actorToPrintStrFor == 255 && strcmp((const char *)msg, " ") == 0 && _actorToPrintStrFor == 255 && strcmp((const char *)msg, " ") == 0 &&
getOwner(200) == VAR(VAR_EGO) && VAR(VAR_HAVE_MSG) && getOwner(200) == VAR(VAR_EGO) && VAR(VAR_HAVE_MSG) &&
ConfMan.getBool("enable_enhancements")) { _enableEnhancements) {
return; return;
} }