Commit Graph
9148 Commits
Author SHA1 Message Date
sluicebox 97b93c9f5f SCI: Remove dead code from findGameObject()
This code attempted to skip calling the function that finds script 0's
export block, but this never happened because it tests the wrong offset.
Even if it tested the right offset, it would have just been duplicating
what the function does.
2023-01-13 18:13:02 -08:00
sluicebox 51f1d4dc73 SCI: Fix LB2 reporter message 2023-01-10 14:50:51 -08:00
sluicebox 6eea9e517b SCI: Detect SCI16 unthrottled inner loops
This restores kGetEvent throttling (10ms delay) during inner loops that
don't throttle themselves. For example, the event processing loop in
Dialog:doit doesn't include a kWait(1) call in some games.
In these games, dialogs max out CPU, and if they run animations then
they run too fast. This happens in the CD version of JONES, bug #14020.

I had considered doing something like this earlier, but it wasn't clear
how to best detect these loops. What I didn't realize is that the SCI32
code already does this by counting kGetEvent calls in between kFrameout.
Now that technique is adapted for SCI16. Combined with the existing
"fast cast" detection, this throttles event-polling inner loops while
keeping the kGetEvent and kGameIsRestarting throttling separate so that
they don't overlap and conflict.

See: e09010f7d8
2023-01-10 14:50:51 -08:00
sluicebox 4e4c184990 SCI: Prefer fallback detection for unknown variants 2023-01-09 18:42:26 +01:00
sluicebox 046356c85a SCI: Convert LSL1 polygon workaround to script patch 2023-01-08 17:01:01 -08:00
sluicebox ad63bed648 SCI: Include matched files in fallback detection
SCI's fallback detection didn't populate ADDetectedGame::matchedFiles.
Now it does, and the Unknown Game report that it generates includes all
the relevant files.
2023-01-08 11:41:19 -08:00
sluicebox d18f24f4a6 SCI: Improve fallback language detection
RESOURCE.CFG and RESOURCE.WIN are now parsed for language codes
2023-01-08 11:41:02 -08:00
sluicebox 3f3344a8c5 SCI32: Remove incorrect GK2 German detection entry
These files were mistaken as a pirate release, but they're just the
output of the popular "GK2 HD/DVD Installer" fan tool when used on
GK2 German. Anyone can produce these files from original files.
They are not the "GOG.com version with German data", GOG just used
the same tool to produce their version from GK2 English files.
2023-01-08 11:41:02 -08:00
sluicebox a316bde435 SCI: Use default parameter in Path::toString() 2023-01-08 11:41:01 -08:00
sluicebox 47fbb31c08 SCI: Disable LSL1 speed test
This was missing from: ea48986006

Fixes bug #14004
2023-01-02 01:16:06 -08:00
sluicebox d10fd9f124 SCI: Revert disabling LB2 control panel in tunnel
These rooms disabled the control panel to prevent the player from
accessing the game's speed setting. Ego is set to a fixed speed and
the timing of the room scripts depend on that speed.

See: 11ca903f60
2022-12-21 12:26:52 -08:00
sluicebox c7099d137e SCI: Add detection for another GK1 DEMO variant
Thanks to @einstein95 for finding this
2022-12-21 12:26:52 -08:00
sluicebox 76044dc51a SCI: Fix CNICK_LONGBOW uninit read workaround
This uninitialized variable read wasn't being detected until the
variable layout was fixed in: 30fad94e9a
2022-12-21 12:26:51 -08:00
sluicebox 2c01722f9b SCI: Fix QFG1VGA Sierra logo animation speed
The previous commit fixed inconsistent animation speed in
this room due to our throttling.

This patch fixes slow animation due to Sierra's throttling.
2022-12-21 12:26:51 -08:00
sluicebox ae5db52c2e SCI: Remove speed test detector
This heuristic was originally how all SCI16 speed tests were handled.
It has been gradually replaced with script patches, until all games
were patched in: ea48986006

At the time, I left this in because it had the benefit of speeding up
the SCI11 test variants so that they didn't produce a startup delay.
Now we know that this heuristic has been identifying regular rooms as
speed tests and unthrottling them too, causing unintended effects.
Some of this behavior was masked by fast-cast throttling occurring
everywhere, until: e09010f7d8

For example, the QFG1VGA Sierra logo animation changes speed and runs
very fast as soon as the sparkle is finished. The Longbow map rooms
were also detected as speed test rooms and animated too fast. Cast-less
rooms like LB2's title screen run unthrottled and consume CPU.

There are only a few SCI11 speed test rooms, so now they're explicitly
unthrottled in kGameIsRestarting with the other throttling exceptions.
2022-12-21 12:26:51 -08:00
sluicebox e46767b8f8 SCI: Fix LONGBOW map animation speed
Speed throttling was disabled on LONGBOW maps because they were treated
as speed tests by the heuristic in GfxAnimate::throttleSpeed. This bug
was masked by fast-cast throttling being applied everywhere, but that
was changed in e09010f7d8

Now the map rooms trigger throttling so that they don't run too fast.
But the game scripts also attempt to throttle the animations based on
speed test results, causing them to run too slow, so that's patched out.

Fixes bug #13966
2022-12-14 05:00:42 -08:00
Vladimir Serbinenko 97bc2d843a SCI: Don't use rawString 2022-12-14 05:08:46 +01:00
athrxx 1878364c2f SCI: (CMS) - fix regression 2022-12-11 17:53:33 +01:00
sluicebox 032afca6cb SCI: Fix LB2 CD hands-off cursor 2022-12-09 23:31:17 -08:00
sluicebox 11ca903f60 SCI: Fix LB2 disabled control panel icon
Now that we allow arbitrary saving via the Global Main Menu,
we can remove the buggy restrictions that prevented saving
and restoring
2022-12-09 23:31:16 -08:00
sluicebox f3f90556d4 SCI: Remove SCI32 code from SCI16 kDoAudio 2022-12-09 23:31:16 -08:00
sluicebox 2e7c3e4f7d SCI: Update LB2 Act 5 script patch for wired door
Fixes the remaining edge cases with this buggy door
2022-12-07 16:26:09 -08:00
sluicebox e2d216013d SCI: Fix LB2 Act 5 transom bugs 2022-12-07 16:26:08 -08:00
sluicebox 334191f636 SCI: Add PATCH_GETORIGINALBYTES to script patcher
Script patches often involve moving entire sequences of existing
instructions. Now that can be done with a smaller patch definition.
2022-12-07 16:26:07 -08:00
sluicebox 903498b6dc SCI: Fix LB2 Act 5 broken timers 2022-12-07 16:26:07 -08:00
sluicebox 9641a3608b SCI Fix LB2 Act 5 trigger 2022-12-02 16:11:34 -08:00
sluicebox 60f04d4e7c SCI: Fix LB2 Act 5 timer crash 2022-12-02 16:11:34 -08:00
sluicebox 1c64c0c4c4 SCI: Fix LB2 CD mummy coffin animation glitch 2022-12-02 16:11:33 -08:00
sluicebox b9df07b465 SCI: Fix LB2 Act 5 mummy coffin lockup 2022-12-02 16:11:33 -08:00
sluicebox 4d6c2f474e SCI: Fix LB2 CD museum actors facing wrong direction 2022-12-02 16:11:32 -08:00
sluicebox 2d73220c13 SCI: Add media type to resource patch definitions 2022-12-02 16:11:32 -08:00
Eugene Sandulenko fb7095f5a4 COMMON: Move all compression-related files to a separate directory 2022-12-01 11:53:02 +01:00
sluicebox bf47637280 SCI: Remove KQ6 black widow script patch
The VM discrepancy that caused these buggy scripts to behave
differently has been fixed, so this patch is no longer needed
2022-11-30 23:13:00 +02:00
sluicebox 30fad94e9a SCI: Track correct location and size of temp variables
The VM has been treating the entire area between the frame pointer and
the stack pointer as temp variables for the current function. There are
two problems with this:

1. The VM hasn't been updating the frame pointer correctly when multiple
   methods are called within the same send/self/super instruction.
2. The VM has been recalculating the number of temp variables on every
   instruction as the difference between the two pointers.
   This is incorrect, as this changes with almost every instruction in
   ways have nothing to do with the number of temp variables allocated
   by the link instruction. Meanwhile, the VM has not been recording
   the number of variables allocated by the link instruction.

The first discrepancy caused scripts to behave differently than in SSCI
when reading parameters out of bounds in certain situations.
It also prevented our uninitialized variable detection from detecting
certain reads. The second made the temp-count used for out of bounds
detection too large, made debugger output such as `stack` incorrect,
and made stepping through the link instruction in the debugger appear
to do nothing until stepping through the following instruction.

When multiple methods are called by a send/self/super instruction, each
method's link instruction increases the stack pointer further.
Method B's variables appear after method A's. The VM has been setting
the stack pointer correctly but it kept using the previous frame
pointer, so method B would re-use method A's stack area instead of the
area the VM had just allocated for B. If a script correctly initializes
variables before using them and doesn't use out of bounds parameters or
temp variables then this discrepancy doesn't make a difference.
But a lot of scripts do these bad things and accidentally rely on the
undefined values they read.

Now we update the frame pointer correctly when "carrying over" to
subsequent method calls from the same send/self/super instruction.
This matches SSCI behavior. We also now record the number of temp
variables that have been allocated by the link instruction and use
that instead of incorrectly recalculating on every instruction.

Fixes the KQ6 black widow lockup, and other KQ6 music bugs, where
scripts call Sound:fade without the required fourth parameter.
Sound:fade expects a fourth parameter, so reads it out of bounds,
and passes it as the stop-after-completion boolean to kDoSoundFade.
Scripts that called Sound:fade as the only method in a send got the same
results as in SSCI, but scripts that called Sound:play first didn't.

Fixes bugs #5625 #5653 #6120 #6210 #6252 #13944
2022-11-30 23:13:00 +02:00
sluicebox ea86295e3e SCI: Update QFG3 Woo dialog script patch
Simplifies the patch and updates the description
2022-11-29 18:35:45 -08:00
Donovan Watteau 25842987ef SCI: Fix MSVC C4309 enum sign warning 2022-11-29 01:37:55 +01:00
Cameron Cawley d74516f84a SCI: Use SeekableReadStreamEndianWrapper 2022-11-29 00:06:49 +01:00
sluicebox 33c6fe1131 SCI: Fix KQ6 black widow lockup with script patch
Recent fixes to the sound fading code have exposed this bug again.
It was first fixed 12 years ago, and then again 10 years ago.

Both times, the bug was fixed by changing kDoSoundFade behavior.
But those changes added behavior that was different from SSCI, and
those differences caused problems in LB2. kDoSoundFade is now
accurate, and so the bug has returned, but it was never a sound bug.

The black widow lockup is due to a script bug that accidentally relies
on undefined values from non-existent parameters. ScummVM produces
different undefined values than SSCI in certain situations, and this
is one of them. The undefined values are then passed to kDoSoundFade
as real values in a correct kernel call.

Now this is fixed with a script patch that removes all five broken
Sound:fade calls. They were redundant because they attempted to fade in
to the same volume they had just set.

Perhaps we can replicate SSCI's undefined behavior someday, but in
the meantime this bug is fixed.

Fixes bugs #5625 #5653 #6120 #6210 #6252 #13944
2022-11-25 16:36:19 -08:00
sluicebox 2fbeecab23 SCI: Prevent script lockers from overflowing
Script::_locker is supposed to track the number of classes and objects
that use a script in order to determine when it can be safely unloaded.
But for system script 999, _locker rapidly increases throughout the game
and eventually overflows. This causes script 999 to unload and crash.
Other scripts may also be affected.

We have been provided QFG1 SCI0 saves where this occurred over the
course of hours within only three days. Logging shows this value
skyrocketing in many games even when they are just polling input or
animating the screen. Alarmingly, this suggests that many SCI games
become unplayable in ScummVM after an achievable amount of game time.

This may be a large and complex problem within the script locker system.
For now, we can mitigate this by making Script::_locker unsigned, which
its callers expected it to be, and by logging overflow attempts and
lowering the locker. This fixes existing save games, even if they have
already overflowed the signed maximum.
2022-11-22 12:37:32 -08:00
Cameron Cawley e97812c296 SCI: Move MidiDriver_CMS to the new CMS API 2022-11-22 19:19:20 +02:00
Cameron Cawley 9f4f22b3bf AUDIO: Support mono audio output in the mixer 2022-11-18 17:17:00 +01:00
sluicebox ff9e03c4bd SCI: Convert LSL5 stopGroop workaround to script path 2022-11-17 15:45:17 -08:00
Cameron Cawley 2c8a7d3900 ENGINES: Remove support for GUI options in MetaEngineDetection subclasses 2022-11-16 23:58:54 +01:00
sluicebox aaebd2aa85 SCI: Fix some comments 2022-11-12 19:33:37 -08:00
sluicebox b5b94a03da SCI: Convert LB2 German fix to message workaround 2022-11-08 16:37:18 -08:00
sluicebox ddf7b7da14 SCI: Add KQ6 Mac workaround for long About message 2022-11-08 16:37:18 -08:00
sluicebox 2d98fda2df SCI: Fix KQ6 Mac About dialog lockups
Fixes script bugs in the original that caused buttons such as
"Tips for playing King's Quest VI" to always lock up the game
2022-11-08 16:37:17 -08:00
sluicebox daed465639 SCI: Add option for high resolution Mac fonts
This adds the existing GAMEOPTION_HIGH_RESOLUTION_GRAPHICS option to
Mac games with native fonts. Default is enabled. If disabled, then the
low resolution Mac fonts are used and the game isn't upscaled.
2022-11-06 23:05:20 -08:00
sluicebox 1efdb1cb6c SCI: Add support for Macintosh fonts
High-resolution native Macintosh fonts are now supported in the
following games when the game's executable is present:

- Castle of Dr. Brain
- Freddy Pharkas
- King's Quest 6
- Leisure Suit Larry 1
- Leisure Suit Larry 5
- Space Quest 1

And in these games when classicmacfonts.dat is present:

- Leisure Suit Larry 6 (floppy)
- Quest for Glory 1
2022-11-06 23:05:20 -08:00
sluicebox 1eeb0b1f24 SCI: Add scaling for Mac icon bar
Required for Mac fonts.

This also makes the disabled icons appear as they did in the original.
Mac SSCI would draw the disabled pattern at high resolution after
upscaling the icon image, not before.
2022-11-06 23:05:20 -08:00