Commit Graph
113 Commits
Author SHA1 Message Date
sluicebox 56ea963cea SCI: Create message workaround system
Adds a new workaround system for known broken messages and their
corresponding audio and sync resources. This replaces all special
cases in c++ and several script patches with data structures and
generic handling.

Common message bugs:
- Wrong tuple requested by game script
- Wrong tuple in message resource
- Wrong message text that exists in another record
- Missing message text
- Audio or sync resource with different tuple than message
2019-06-09 15:35:57 -07:00
Filippos Karapetis 9da3d22703 SCI: Fix MSVC warnings
- Remove unused parameters
- Initialize potentially uninitialized variables
- Use Common::String instead of a fixed buffer
- Remove redundant parentheses
- Change float suffix to be uppercase
- Fix spacing
- Fix integer left shifts with boolean variables
- Fix potential division by zero
- Fix missing breaks
2019-05-27 14:53:41 +03:00
athrxx 037eec3144 SCI: implement SCI0 midi driver track initialization
I put this in an separate commit to make it easier to review/revert. I've tried to make this as minimum invasive as possible. That's why I put this in place of the former call to onNewSound().

SCI_0_LATE sound drivers (probably also SCI_0_EARLY, but I don't know that) do some midi track initialization, mostly resetting certain values and assigning voices (hardware channels) to midi parts. The information for this comes from the track header.

The SCI0 version of the PC-98 sound driver relies on this code. The driver checks the channel flags with two different masks and assigns different sound channel types accordingly. This can't be done with the 0x4B event. Using the 0x4B event is sort of counter intuitive anyway, since only some of the SCI0 drivers even support that event.

It seems that the only driver making use of onNewSound() was MT-32. I've adapted the driver to my changes, although I am quite sure that the sound will be unaffected. The only thing that the MT-32 driver does with the header information is checking whether a midi part should play or not and assign exactly one timbre (with exactly the same number) to that part if required.
2019-04-02 20:45:35 +03:00
Vhati 2d75c6b271 SCI32: Fix QFG4 Rusalka flowers dialogue
Fixes mixed up text/audio when giving her flowers, bug #10849
2018-12-28 18:11:31 +02:00
sluicebox 2c1661bff2 SCI32: Fix QFG4CD Look Grate missing audio
Fixes a broken message due to wrong audio tuple, bug #10848
2018-12-23 00:02:14 -08:00
Filippos Karapetis 8d4330a217 SCI: Add some TODOs for better handling of wrong / missing resources 2018-12-02 23:58:44 +02:00
sluicebox 62846769ad SCI: Fix LB2 Yvette/Tut missing sync resource (#1373)
Fixes a missing resource in the game. bug #9956
2018-12-02 23:21:28 +02:00
sluicebox 8eb334a2ab SCI32: Fix GK1 fortune teller messages, bug #10819 (#1423) 2018-11-28 02:20:34 +02:00
Colin Snover 1515bb31a6 SCI: Fix detection of end of audio map & entry size in SCI32
Torin RU map 38140 has an unusual terminator entry; instead of a
normal terminating entry of 11 FFs, its terminating entry is
03 FF FF FF FF C4 36 01 FF FF FF. So, two changes are made:

1. The end-of-map check is now the same as in SSCI1.1+ and only
   checks that the final byte of the Audio36 tuple is 0xFF,
   instead of the entire tuple;
2. The unneeded entry size heuristic has been turned off for
   all SCI32 games.

A quick check of the English versions of LB2CD, EQ1CD, SQ4CD, and
KQ6CD, as well as all English SCI32 games, indicates that this
approach seems to be working correctly.

Fixes Trac#10188.
2017-09-20 13:07:08 -05:00
Colin Snover aa20284027 SCI32: Ignore bad audio map entries on GK2 DE CD 6
This patch also cleans up the GK2 audio map blacklisting code to
reduce the number of redundant checks being made during audio map
processing.

Fixes Trac#10172.
2017-09-03 20:58:09 -05:00
Colin Snover d7d75d97fd SCI32: Ignore invalid audio maps in Phant2 FR
Fixes Trac#10049.
2017-08-26 18:09:47 -05:00
Colin Snover b17c66981e SCI32: Ignore invalid audio map in GK2 DE
Fixes Trac#10143.
2017-08-26 18:09:47 -05:00
Colin Snover c0d3d5776e SCI32: Limit existing bad audio map resource skips by language
Since audio maps change when game speech is localised, it makes
sense to limit audio map skips by language until it turns out that
the same problem exists in more than one language release, so we
do not accidentally skip a map that is bad in one language, but OK
in another language.
2017-08-26 18:09:47 -05:00
Colin Snover 4c316d45fd SCI32: Fix ResourceManager::changeAudioDirectory
Fixes Trac#9577.
2017-07-24 19:36:28 -05:00
Colin Snover 4d52b018a2 SCI: Keep audio maps out of the LRU cache 2017-07-23 16:01:19 -05:00
Colin Snover d556dcc57b SCI: Switch SCI2 games to use Audio32
Upon investigation of Sound code across SCI32 games, it was
determined that there are actually (at least) 3 different
revisions, not just a single SCI2.1 version. This patch only
changes the parts of Sound code that are relevant to the correct
use of Audio32.

Fixes Trac#9736, Trac#9756, Trac#9767, Trac#9791.
2017-06-18 21:42:58 -05:00
Colin Snover 2482a78fa3 SCI32: Fix wave resource patch offset
This bug was only reproducible when loading a game using the
multi-disc RESSFX.00x bundles.

Fixes Trac#9832.
2017-06-08 00:14:45 -05:00
Colin Snover f44d8b6da6 SCI: Dispose uncached volume file streams
The stream returned by a call to ResourceManager::getVolumeFile
either MUST (when returning an I/O stream from a Common::FSNode)
or must NOT (when returning a Common::File *) be deleted by the
caller, depending upon some internal implementation details of
ResourceSource that should never have been exposed to callers.

FSNode streams that should have been deleted were not being
deleted all the time, which leaked and eventually caused ScummVM
to run out of FDs.

This commit improves this situation by shielding callers from
these internal details by centralizing the destruction logic in
one place, so FSNode read streams stop being leaked and callers
no longer need to know stuff about the internals of the
ResourceSource they are trying to read in order to avoid leaking
or breaking the volume file cache.

Fixes Trac#9782.
2017-05-13 22:46:25 -05:00
Colin Snover ea6eebca09 SCI: Fix reading of Rave data from compressed KQ6 audio volumes
Refs Trac#9764.
2017-05-10 15:29:53 -05:00
Colin Snover dd13c3be43 SCI: Fix support for ScummVM compressed audio volumes
The runtime code for this had previously relied on hot patching
volume file offsets at the moment that a resource was loaded,
instead of correcting file offsets when reading audio maps. The
code added for sanity checking audio volumes started to report
warnings because the offsets being received were for the original
uncompressed audio volume, which (naturally) is larger than the
compressed audio volume.

This commit also deduplicates code between addResource and
updateResource, and tweaks a validation-related error message for
improved clarity.

Fixes Trac#9764.
2017-05-10 10:55:00 -05:00
Colin Snover 13925065cb SCI: Fix unnecessary copy of Common::String 2017-05-08 11:26:47 -05:00
Colin Snover 554a73e012 SCI: Improve detection and reporting of resource errors
Simple assertions in the resource manager are not sufficient to
track down resource corruption issues, and some error conditions
that were being checked already were either ignored or only raised
as warnings that casual users would be unlikely to see.

Ideally, error handling in ResourceManager would be improved to
the point where errors would correctly propagate out of it (so the
warning dialogue could be displayed from outside), but right now
error codes are dropped all over the place, and it would take more
effort to fix that without much benefit for the current situation.
If/until someone has the energy to fix that, the warning dialogue
is simply shown from ResourceManager::scanNewSources.

Refs Trac#9764.
2017-05-08 11:26:46 -05:00
Colin Snover 9a637ec324 SCI32: Skip bad map 405 on CD 1 of PQ:SWAT
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.
2017-03-30 19:46:27 -05:00
Colin Snover 0826501ef6 SCI32: Fix audio, wave, VMD, Duck, CLUT, TGA, ZZZ, Etc patches
Specifically, audio patches are used in at least PQ:SWAT
(40103.AUD), Lighthouse (9103.AUD), and the GK2 demo (300.AUD).
2017-03-30 19:46:27 -05:00
Colin Snover 65fe7bcfd8 SCI: Print more detailed information on audio header size mismatch 2017-03-30 19:46:27 -05:00
Colin Snover 0be9ace649 SCI: Fix incorrect read of LB2/MG256 audio sizes
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.
2017-03-30 19:46:27 -05:00
Colin Snover 477e31cea6 SCI32: Ignore invalid audio map entries in GK2
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.
2017-03-30 19:46:27 -05:00
Colin Snover a233696212 SCI: Update formatting strings to match updated Span API 2017-03-30 14:23:41 -05:00
Colin Snover 31daa956d6 SCI: Implement bounds-checked reads of game resources 2017-03-27 19:42:31 -05:00
Colin Snover 4eecd48c64 SCI32: Remove unnecessary call to unalloc
When the Resource is deleted, it will deallocate the memory, so
it is not necessary to do that manually.
2017-01-11 11:01:38 -06:00
Colin Snover f1ca9ccc64 SCI32: Fix kSetLanguage 2017-01-09 19:38:59 -06:00
Colin Snover 1337e82b0b SCI: Fix invalid read of LB2 audio map 448 2016-12-03 12:21:56 -06:00
Colin Snover 273695a11e SCI: Remove use of snprintf 2016-12-03 12:21:55 -06:00
Colin Snover 0e53c8e9f3 SCI32: Improve MGDX support
Audio directory switching is temporarily disabled because it
causes use-after-free in the resource manager.
2016-09-29 19:39:16 -05:00
Colin Snover c4250c05d0 SCI32: Enable multi-disc audio resources
Phant1, PQ:SWAT, GK2, and Phant2 all have different audio maps
and audio volumes on each CD. In order to make this work within
ScummVM, where CDs are never swapped, each RESOURCE.AUD for these
games must be renamed to RESAUD.00x and each RESOURCE.SFX renamed
to RESSFX.00x.
2016-08-19 15:23:10 -05:00
Colin Snover a9e2630d4e SCI: Assert on seeks past the end of audio resource bundles
This should never be allowed to happen, but currently does on
multi-CD games with different resource bundles on difference CDs
(Phant1, PQ:SWAT, GK2) because the resource manager does not yet
have the ability to handle this situation.
2016-06-22 13:05:18 -05:00
Colin Snover 46551fd4b5 SCI32: Rewrite digital audio engine
This provides a complete implementation of kDoAudio through
SCI2.1mid, plus partial implementation of SCI3 features.

Digital audio calls shunted through kDoSound have also been
updated to go through the SCI32 audio mixer, though these shunts
are a bit hacky because the ScummVM implementation of kDoSound
does not currently match how SSCI kDoSound is designed.

It is probably possible in the future to just replace the SCI1.1
audio code (audio.cpp) with the new SCI32 code, since the major
differences seem to be that (1) SCI1.1 only supported one digital
audio playback channel (this is configurable already), (2) it
had extra commands for CD audio playback and queued sample
playback.
2016-06-20 21:02:21 -05:00
Martin Kiewitz 6779340b24 SCI: Truncate channel data in case it goes beyond resource size
Fixes invalid memory access during kq5 floppy ending
2016-03-08 03:36:02 +01:00
Filippos Karapetis cdbd7c8add SCI: Use uint32 instead of unsigned int 2016-03-01 01:12:58 +02:00
Martin Kiewitz 0dd760724e SCI32: split up SCI2.1 into EARLY/MIDDLE/LATE
- Detection works via signatures (couldn't find a better way)
- new kString subcalls were introduced SCI2.1 LATE
- kString now has signatures and is split via subcall table
- kString fix, so that KQ7 doesn't crash, when starting a chapter
- Sci2StringFunctionType removed, because no longer needed
2015-12-29 01:44:11 +01:00
Willem Jan Palenstijn 5028487038 SCI: Use sound resource priority by default for songs
SCI1 sound resources can have an embedded priority. We now use that by
default, unless an explicit DoSound/SetPriority call overrides it.
Thanks waltervn.

This fixes relative priority of songs in at least PQ3 room 29.

Also increase savegame version to 33.
2015-02-15 14:05:36 +01:00
Filippos Karapetis 9783f0bbd9 SCI: Remove trailing whitespace 2014-10-28 16:17:06 +02:00
Willem Jan Palenstijn 134aa5af09 SCI: Fix reading SCI1 midi channel flags
Thanks waltervn
2014-10-03 01:19:01 +02:00
Johannes Schickel 8fc7d60feb SCI: Make GPL headers consistent in themselves. 2014-02-18 02:39:37 +01:00
Willem Jan Palenstijn 857d2e7bef SCI: Rewrite MIDI channel remapping
This adds MIDI state tracking to allow channels to be temporarily
unmapped and later re-mapped when there are free device channels
available again.
2013-12-31 13:52:15 +01:00
Willem Jan Palenstijn f777e54df2 SCI: Reduce indentation depth 2013-12-31 13:42:58 +01:00
Martin Kiewitz 693d5e6625 SCI: rave support (KQ6 hires portrait lip sync)
Thanks to wjp and [md5] for helping
2013-12-11 08:25:23 +01:00
Filippos Karapetis fa2ea4fc61 SCI: Add handling for the RAVE resource type, found in KQ6CD
This contains the sync data in the Windows version of KQ6CD.
Note that currently the sync36 resource is 2 bytes bigger
(it contains 2 bytes from the RAVE resource). Some test code
has also been added to dump the RAVE sync resources
2013-12-10 01:41:15 +02:00
Willem Jan Palenstijn 24b0b6aa43 SCI: Fix memory leak 2013-04-20 16:27:59 +02:00
Max Horn 4f8665fc83 COMMON: Move isFoo functions to namespace Common, add doxygen comments 2012-02-20 16:18:27 +01:00