SCUMM: Work around TurboGrafx-16 / PC Engine Loom glitch

When examining the dragon's pile of gold a second time, the "Wow!"
message was not visible. This appears to be a scripting bug particular
to this version (it works in the EGA version), and we work around it by
simulating a WaitForMessage() instruction after the message is printed.
This commit is contained in:
Torbjörn Andersson 2022-02-21 11:00:11 +01:00 committed by Torbjörn Andersson
parent 9147f74000
commit 1d71a2859c

View file

@ -361,7 +361,34 @@ void ScummEngine_v5::setupOpcodes() {
}
int ScummEngine_v5::getVar() {
return readVar(fetchScriptWord());
const byte *oldaddr = _scriptPointer - 1;
uint var = fetchScriptWord();
int result = readVar(var);
// WORKAROUND: Examining the dragon's pile of gold a second time causes
// Bobbin to animate as if he's talking, but no text is displayed. When
// running the game in an emulator, there's neither text nor animation
// when examining the pile again. While the symptoms are slightly
// different, this points to a script bug.
//
// I think this happens because in the PC Engine version the entire
// scene is a cutscene. In the EGA version, only the part where the
// dragon responds is. So the cutscene starts, the message is printed
// and then the cutscene immediately ends, which triggers an "end of
// cutscene" script. This is probably what clears the text.
//
// The script sets Bit[92] to indicate that the dragon has responded.
// If the bit has been set, we simulate a WaitForMessage() instruction
// here, so that the script pauses until the "Wow!" message is gone.
if (_game.id == GID_LOOM && _game.platform == Common::kPlatformPCEngine && vm.slot[_currentScript].number == 109 && var == 32860 && result == 1 && VAR(VAR_HAVE_MSG)) {
_scriptPointer = oldaddr;
o5_breakHere();
return 0;
}
return result;
}
int ScummEngine_v5::getVarOrDirectByte(byte mask) {