This fixes a use-after-free in GK2 when restoring a second save
game, when the List reg_t is still considered valid but the List
has moved due to a partial game restore.
This fixes incorrect backtraces after a workaround failure or
other call to getCurrentCallOrigin when one or more stack frames
are calls to local procedures.
The eventual proper fix for this is to change the current MIDI
parser to work the same as in SSCI, but for now this workaround
allows the game to continue.
Fixes Trac#9696.
GK1 handles MIDI volume by changing the volumes of individual
sound objects, rather than by using the MIDI master volume. As a
result, the master volume needs to default to the maximum output
level in order for GK1 to play music at the correct volume.
This change does not affect earlier games, since SCI16 managed
MIDI volume via the master volume, and for these games the master
volume from ScummVM is synced at startup.
Some kernel calls need to be able to call back into game script
code, which requires a valid stack pointer for use with
invokeSelector.
An example of this is the guest additions code that syncs audio
volumes from ScummVM: it needs to be able to call into the game
scripts responsible for managing the in-game audio volume UI.
The resources on CD 1 are corrupt and point to invalid locations
in the CD 1 RESOURCE.AUD. This can be noticed during the briefing
on the Lucy Long callup, where descriptions of the map are missing
and eventually the game gets stuck waiting for missing audio to
finish playback.
This happened to work previously because the size was not checked
for validity, and because the audio player calculates its own size
so this value was never actually used.
The invalid entries, which are on CD 6, appear to correspond to
audio that's on CD 4 (though not with the correct offset for CD
4's RESOURCE.AUD).
Skipping the invalid map entries on CD 6 should cause these audio
files to be loaded from the CD 4 audio bundle if they are
requested during chapter six since ScummVM combines resources from
all CDs and matches on their IDs.
Until C++11 (which introduces the z and t length modifiers), there
is no consistent way to print size_t and ptrdiff_t types using
printf formatting across 32-bit, LLP64, and LP64 architectures
without using a cumbersome macro to select the appropriate length
modifier for the target architecture. Since ScummVM engines
currently need to support 32-bit targets, there is no reason at
the moment to support any larger memory sizes in Span anyway.
Span error output is also updated in this commit to reflect that
index values are unsigned.