Commit Graph
7940 Commits
Author SHA1 Message Date
Colin Snover 092a809c78 SCI32: Fix bad interpolation of Robot audio samples
Previously, this code was interpolating samples if the previous
block had missing samples, instead of interpolating when samples
are missing in the upcoming block of samples.
2017-04-22 19:38:12 -05:00
Colin Snover 5231541e7c SCI32: Add and divide instead of performing two divisions
This should make things trivially faster, and matches more
accurately how the original engine worked.
2017-04-22 19:38:12 -05:00
Colin Snover f6c4e0c7c7 SCI: Improve message when crashing due to a bad selector 2017-04-22 19:38:12 -05:00
Colin Snover 8a5eb0c784 SCI32: Fix dumb typo in CelInfo32::toString
The typo was `if (kCelTypeColor)` instead of
`if (type == kCelTypeColor)`. Changed to use a switch instead for
improved clarity and code intelligence.
2017-04-22 19:28:36 -05:00
Colin Snover 3ab1f5f4cc SCI: Display class names in disassembly 2017-04-22 19:28:35 -05:00
Colin Snover 086fab741a SCI: Remove #undef for a macro that does not exist 2017-04-22 19:28:35 -05:00
Colin Snover 2ccef4a476 SCI32: Implement support for QFG4 autosave 2017-04-22 19:28:35 -05:00
Colin Snover 6c44106083 SCI32: Add workarounds & patches for QFG4 2017-04-22 19:28:35 -05:00
Colin Snover 8817e8e3bf SCI: Explicitly label slot 0 as the autosave slot in the ScummVM UI 2017-04-22 19:28:34 -05:00
Colin Snover 41c633f0c5 SCI: Fix whitespace errors 2017-04-22 19:28:34 -05:00
Colin Snover 848bce47e1 SCI: Fix typo in debug message 2017-04-22 19:25:21 -05:00
Colin Snover 8105984703 SCI32: Fix broken final step of 2.1mid+ pixel dissolve 2017-04-22 19:25:20 -05:00
Colin Snover ede7976ede SCI32: Fix bad kPointSize implementation
Fixes text scaling gone mad in Phant2.
2017-04-22 19:25:20 -05:00
Colin Snover c6cf7215f0 SCI32: Fix kStringFormat signatures 2017-04-22 19:25:20 -05:00
Colin Snover ecc446da84 SCI: Accept 32-bit values to reg_t::incOffset
This fixes bad variable relocation in Phant2 causing the game to
crash when reading object names.
2017-04-22 18:53:40 -05:00
Colin Snover 9527139deb SCI32: Enable support for SCI2-2.1 games in release!
Some games are not moved to ADGF_TESTING yet because they have
not been played through completely:

* QFG4
* PQ:SWAT

Some games are not moved to ADGF_TESTING yet because they are
broken:

* Chest (fails to read/parse its custom archive files)
* Hoyle5 (Poker DLL needs to be reverse-engineered; main menu
  needs to be "fixed" for budget derivatives that only contain
  some of the games and used Windows shortcuts to bypass the menu)
* MGDX (missing MIDI playback)
2017-04-22 15:42:16 -05:00
Colin Snover 5b0c20da94 SCI32: Provide more detail in console when a save game fails checks 2017-04-22 15:34:31 -05:00
Colin Snover a2fb53790b SCI32: Make version 41 the first supported save game version
Save games created by earlier versions of ScummVM are prone to
having subtle graphics problems or other corruption caused by
incomplete save/load code.
2017-04-22 13:01:38 -05:00
Colin Snover e504efe4da SCI32: Add palette code for late SCI2.1mid+ games
Sometime during SCI2.1mid, the palette manager was changed to
save and restore the source palette, and to add in-game gamma
correction. Previously, only the vary start and target palettes
were saved, and gamma correction was only configurable in SSCI by
editing RESOURCE.CFG.
2017-04-22 13:01:37 -05:00
Colin Snover 399551af09 SCI: Fix compilation when SCI32 is disabled 2017-04-22 13:01:37 -05:00
Colin Snover 93b337b833 SCI: Do not sync objects when saving games
Commit 5de2668939 silently changed
behaviour from running this code only when restoring a game, to
running all the time, in an apparent copy-paste error.
2017-04-22 13:01:37 -05:00
Colin Snover a22e461208 SCI: Improve comments in GuestAdditions 2017-04-22 13:01:37 -05:00
Colin Snover 2df939d33b SCI32: Add workaround for SQ6 invalid read after a failed save game restore 2017-04-22 13:01:36 -05:00
Colin Snover f8703ae48d SCI32: Fix infinite recursion when loading invalid save from launcher 2017-04-22 13:01:36 -05:00
Colin Snover 2862e51068 SCI32: Fix launcher load for Shivers 2017-04-22 13:01:36 -05:00
Colin Snover a2c48eff4c SCI32: Only activate the Load button in the launcher when it is usable 2017-04-22 13:01:36 -05:00
Colin Snover 1ed185bbbb SCI: Implement delayed restore for SCI32 and move implementations to GuestAdditions 2017-04-22 13:01:35 -05:00
Colin Snover 6f75bed90c SCI32: Remove original save/load option from games without ScummVM save integration 2017-04-22 13:01:35 -05:00
Colin Snover 4c0f2a3738 SCI: Move ScummVM kernel calls to 0xe0 2017-04-22 13:01:35 -05:00
Colin Snover c8486395fa SCI: Clean up unnecessary delayed restore flags
_delayedRestoreGame is always set and cleared at the same time as
_delayedRestoreGameId, and _delayedRestoreFromLauncher is written
but never read.
2017-04-22 13:01:35 -05:00
Colin Snover ec12c5a342 SCI: Move ScummVM save/restore to GuestAdditions and reimplement for SCI32 2017-04-22 13:01:16 -05:00
Colin Snover 3303a88139 SCI: Improve audio volume & settings sync code
This patch includes enhancements to the ScummVM integration with
SCI engine, with particular focus on SCI32 support.

1. Fixes audio volumes syncing erroneously to ScummVM in games
   that modify the audio volume without user action (e.g. SCI1.1
   talkies that reduce music volume during speech playback). Now,
   volumes will only be synchronised when the user interacts with
   the game's audio settings. This mechanism works by looking for
   a known volume control object in the stack, and only syncing
   when the control object is present. (Ports and planes were
   researched and found unreliable.)

2. Fixes audio syncing in SCI32 games that do not set game
   volumes through kDoSoundMasterVolume/kDoAudioVolume, like GK1,
   GK2, Phant1, and Torin.

3. Fixes speech/subtitles syncing in SCI32 games that do not use
   global 90, like LSL6hires.

4. Fixes in-game volume controls in SCI32 games reflecting
   outdated audio volumes when a change is made during the game
   from the ScummVM launcher.

5. Fixes SCI32 games that would restore volumes from save games
   or reset volumes on startup, which caused game volumes to be
   out-of-sync with ScummVM when started.

6. ScummVM integration code for audio sync has been abstracted
   into a new GuestAdditions class. This keeps the ScummVM-
   specific code all in one place, with only small hooks into the
   engine code. ScummVM integrated save/load code should probably
   also go here in the future.

Fixes Trac#9700.
2017-04-21 19:00:27 -05:00
Colin Snover a620b6c354 SCI: Fix handling of buggy SCI0 export tables
The previous fix for this bug was incorrect; it only happened
to work because of another bug: the number of exports was being
read incorrectly (reading the byte size of the export block, not
the number of exports), so the validation check for the export
number always passed. Then, the "small" offsets that were seen
were actually either invalid reads into the header of the next
block in the script (KQ4), or reads into the bad first export
table which contained an unfilled offset (Camelot).

Once the incorrect number of exports was fixed, the previous "fix"
broke in KQ4 because the export number validation started to work
correctly and the first export table does not have enough entries
(needs 2, has 1).

This patch fixes the bug by using the last export table in SCI0
scripts instead of the first export table. (This does not affect
most scripts, since only the buggy scripts have more than one
export table.)

Fixes Trac#9731.
2017-04-18 11:47:18 -05:00
Colin Snover 4946f149b4 SCI: Improve MidiParser_SCI robustness against bad sound resources
1. KQ4 sound 104 has an extra 0xFC (MIDI Stop command/kEndOfTrack)
   at the end of the resource, which causes an out-of-bounds read
   because the filtering loop continues after the first 0xFC and
   unconditionally attempts to read 2 bytes (expecting there to
   always be a delta value + a command, whereas in this file there
   is only another kEndOfTrack command). This is corrected by
   exiting the filtering loop when a kEndOfTrack is encountered
   and there is not enough data remaining in the resource to
   continue reading.

2. KQ5 sound 699 is truncated, which causes the parser to attempt
   to read past the end of the resource. This is addressed by
   adding bounds checks that exit the mix loop early if there is
   no more data available to read. This allows truncated sounds
   to be played as far as possible (previously, trying to read
   truncated resources would result in a fatal error).

3. midiMixChannels allocates an arbitrary amount of raw memory
   for the mixed MIDI sequence, without performing any bounds
   checking when writing to this memory, potentially leading to
   a crash or silent corruption of adjacent memory. This is
   mitigated by using SciSpan instead of a raw pointer for the
   mixed data.

Fixes Trac#9727.
2017-04-16 12:23:35 -05:00
Thierry Crozat 1e38ca45cd SCI: Fix speech in QfG IV on big endian platforms 2017-04-14 00:01:54 +01:00
Colin Snover ee644ec01b SCI32: Check for game aborts in all kList iteration methods
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.
2017-03-30 20:49:37 -05:00
Colin Snover 3678390f3e SCI: Add clarifying comment to op_rest 2017-03-30 20:49:37 -05:00
Colin Snover a1153661c4 SCI: Stop getCurrentCallOrigin from mutating stack frames
This fixes incorrect backtraces after a workaround failure or
other call to getCurrentCallOrigin when one or more stack frames
are calls to local procedures.
2017-03-30 20:49:36 -05:00
Colin Snover 5723f2f5fe SCI32: Hack around MIDI parser causing stuck harp animation in KQ7
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.
2017-03-30 20:49:36 -05:00
Colin Snover 4284488244 SCI32: Improve bounds checking in SciString trim 2017-03-30 19:46:27 -05:00
Colin Snover 2d0c1c8ab5 SCI: Ensure object name reg_ts are valid before dereferencing them 2017-03-30 19:46:27 -05:00
Colin Snover 5e81db8fd0 SCI32: Add workaround for uninitialised read in Torin 2017-03-30 19:46:27 -05:00
Colin Snover 159438848b SCI32: Add workaround for uninitialised read in GK1 2017-03-30 19:46:27 -05:00
Colin Snover 739047f887 SCI32: Always reinit GfxText32 statics on game startup
Fixes bad scaling of text when switching between games with
different script resolutions.
2017-03-30 19:46:27 -05:00
Colin Snover 3de6f290e7 SCI: Change default master MIDI volume to 15
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.
2017-03-30 19:46:27 -05:00
Colin Snover dd23085845 SCI: Give kernel calls a valid stack pointer
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.
2017-03-30 19:46:27 -05:00
Colin Snover 4d062fc7a0 SCI32: Do not default to General MIDI for SCI2.1 games
The only SCI32 game that uses MIDI and does not support AdLib is
MGDX, and it its MIDI playback is currently broken regardless of
the synth setting.
2017-03-30 19:46:27 -05:00
Colin Snover e74adcec52 SCI: Whitespace alignment 2017-03-30 19:46:27 -05:00
Colin Snover 6b0cd955fa SCI32: Fix crash when using brightness slider in Shivers 2017-03-30 19:46:27 -05:00
Colin Snover fa9523933f SCI32: Fix broken sliders in Shivers settings
This problem is caused by the same invalid super call that broke
the CCTV joystick.
2017-03-30 19:46:27 -05:00