Commit graph

4058 commits

Author SHA1 Message Date
Colin Snover
7a41b6f023 SCI: Add support for keyup events
Basic keyup event support appears to have been added in the SCI1.1
IBM keyboard driver, and more robust support was provided in SCI32
which actually gets used by at least Lighthouse. This patch adds
support for keyup events in SCI1.1+.

Fixes Trac#10242.
2017-09-27 20:27:34 -05:00
Colin Snover
4bd31dae9b SCI: Fix use-after-free when kernel call debugging is active during a save game restore 2017-09-27 20:27:33 -05:00
Colin Snover
9a8070da3c SCI: Do some clean-up of event handling system
Convert macros and vars to enums, rename keyboard events in
preparation for adding key up events, clean up unnecessary nested
conditionals, add TODOs for potential future work.
2017-09-27 20:27:33 -05:00
David Fioramonti
c88d5519c2 SCI: Add uninitialized read workaround for shoplifting in SQ4CD
When in Galaxy Galleria, going into the software store and trying
to shoplift the SQ4 Hintbook will crash the game after you leave
and are electrocuted.

Fixes Trac#10229. Closes gh-1031.
2017-09-27 20:27:33 -05:00
Colin Snover
ba380ac28e SCI32: Dummy kPlayVMDSetFrameRate
This subop is used only by RAMA.

The VMD objects in RAMA's game code contain a frame rate field,
which is usually -1, but occasionally is not. In the cases where
it is not -1, it appears to be either set for a video with sound
(so the value doesn't do anything to that video), or it is just
resetting back to the baked-in frame rate of the video file (so
it doesn't need to exist, except to fix videos broken by earlier
played videos with explicit frame rates).

Since this is a global state flag that does not get reset in SSCI,
the ultimate effect of kPlayVMDSetFrameRate in RAMA is that it does
nothing to any of the videos where the explicit frame rate is set,
but it does inadvertently cause *other* videos with no sound and no
explicit frame rate to have a different frame rate depending upon
what was played earlier in the game (and whether or not the engine
was restarted in the meantime).

This bad transferring of frame rates is most noticeable with the
exit-video of the vidmail player, which is played when you back out
after selecting a vidmail. Its nominal framerate is 10fps, but it
will play at whatever frame rate was last set by some other video
that happened to have an explicit frame rate, even if that frame
rate was bogus.

So, just ignore all calls to this subop, as it is fatally buggy.
2017-09-24 23:49:37 -05:00
Colin Snover
24c8a26c75 SCI32: Remove unnecessary negative assertion check on unsigned integer
Fixes CID 1381416.
2017-09-24 22:56:59 -05:00
Colin Snover
743082ac8c SCI32: Disable all SCI32 Mac code
This code is currently untestable and is almost certainly at least
partly based on guesswork & not actual reverse-engineering (as was
the case for all other pre-2015 SCI32 code), so future developers
interested in adding SCI32 Mac support should use it only as an
intermediate reference rather than as known good code.
2017-09-24 22:56:59 -05:00
Colin Snover
76806732e0 SCI: Remove Mac SCI32 code from SCI16 code 2017-09-24 22:56:58 -05:00
Colin Snover
663d845d63 SCI32: Add workarounds for uninitialized reads in RAMA 2017-09-24 22:56:58 -05:00
Colin Snover
3e107c1eb0 SCI32: Allow invalid references to be passed to kFileIO
Near the end of the game, RAMA will start trying to store some
invalid references. This does not affect the save game negatively
in any way, but it was causing the kernel to assert a signature
failure.
2017-09-24 22:56:58 -05:00
Colin Snover
817887216d SCI32: Fix RAMA auto-save game
Despite what game script disassembly lead me to believe, the game
seems to create only one auto-save, which ends up being saved as
911.sg (not autorama.sg). This save file is created just before
entering the underground Avian Lair in New York, and seems to be
designed as some emergency backup since entering the Avian Lair is
a one-way trip.
2017-09-24 22:56:58 -05:00
Colin Snover
21337e4cf6 SCI32: Implement per-channel audio panning
Used by RAMA, in various places, starting with the refrigerator
at base camp after the cable car at the beginning of the game.
2017-09-24 22:56:57 -05:00
Martin Kiewitz
26183f7289 SCI: Add SQ4CD script patch to add audio for universal remote control
for Hk So Good store catalog.
Implements enhancement #10227
2017-09-24 19:00:12 +02:00
Colin Snover
d73ada9088 SCI: Fix generation of save games 2017-09-24 11:12:45 -05:00
Colin Snover
fcf707e20a SCI32: Flush stub RAMA save game to disk
If this is not done and the file is buffered, it will not show up
in the list of save games, and the new save will fail.
2017-09-23 21:39:58 -05:00
Colin Snover
d2364cb9bb SCI32: Fix bad data cube text priority calculation in RAMA 2017-09-23 20:57:04 -05:00
Colin Snover
f83c61fcb6 SCI32: Fix relocation of locals in SCI3
Somehow, up until trying to view an encrypted data cube in RAMA,
the missing relocation of locals did not seem to cause any trouble
in any of the other SCI3 games.
2017-09-23 20:57:03 -05:00
Colin Snover
643a572610 Revert "SCI: Fix Warnings about Copy Constructor Failing to Call Base Class."
This reverts commit d2dd942ad7.

The Serializable class is an interface class and has only the
empty default copy constructor. There is no reason to call this
explicitly. Whatever is warning about this should be fixed to stop
warning about it, rather than adding such unnecessary calls to the
engine code.
2017-09-23 20:57:03 -05:00
Colin Snover
dced2fb9f5 SCI32: Fix handling of array copies
kArrayCopy would perform an unnecessary memory copy of the source
array, the treatment of the count value as unsigned was clearly
not correct since it was being sign-extended and checked against
-1.
2017-09-23 20:57:03 -05:00
Colin Snover
6972c9ae46 SCI32: Fix bad default text scaling in RAMA 2017-09-23 20:57:02 -05:00
Colin Snover
602de8363b SCI32: Fix infinite reload in RAMA when loading from launcher 2017-09-23 20:57:02 -05:00
Colin Snover
9c28c25b67 SCI32: Add guest additions save/restore support for RAMA 2017-09-23 20:57:01 -05:00
Colin Snover
475bb5f91a SCI32: Remove unnecessary use of strncmp
One of the strings is a static string of the same size as the size
passed to strncmp so there is no point in not just using strcmp.
2017-09-23 20:57:01 -05:00
Colin Snover
a63f516df0 SCI32: Replace magic number with kAutoSaveId in QFG4 save code 2017-09-23 20:57:00 -05:00
Colin Snover
b038432952 SCI32: Support RAMA's custom save games through kFileIO 2017-09-23 20:56:48 -05:00
Colin Snover
9298f6a81e SCI: Split save game metadata writing to separate function
RAMA has its own custom save game format that game scripts write,
but we still want to be able to use these save game files from the
ScummVM launcher, so the metadata has to be able to be written
separately from the rest of the game saving.
2017-09-23 20:56:48 -05:00
Colin Snover
d17ae077dd SCI: Use reference instead of pointer for required out-data in metadata save function 2017-09-23 20:56:48 -05:00
Colin Snover
b3c27c2159 SCI: Clean-ups to file handling code
Preparations for adding support for RAMA's custom save game format.
2017-09-23 20:37:51 -05:00
Colin Snover
0ceab96e91 SCI32: Remove unused shrink-to-fit function for string arrays 2017-09-23 20:37:51 -05:00
Colin Snover
50cfb7ad46 SCI32: Fix size for dereferencing non-raw SCI32 arrays
The maxSize given when generating a SegmentRef is supposed to be
the maximum size of raw data that can be held inside the offset-
part of a reg_t, not the entire size including the segment.

This fixes a buffer overflow in "Inside the Chest", which still
does not work, but at least doesn't cause heap overflows anymore
with this change.
2017-09-23 20:37:51 -05:00
Colin Snover
52d9d04919 SCI32: Fix inconsistent patch instruction comments
I missed these lines when going through things earlier.
2017-09-19 20:00:28 -05:00
Colin Snover
6af5133061 SCI32: Put superclass address in r_acc for SCI3 super calls
This fixes a problem in Lighthouse 2.0a where the mini-sub would
fail to start playing the animation of the shipwreck when clicking
on the throttle.

In SSCI, in SCI3 only, r_acc was (inadvertently?) set to the
superclass object ID whenever a super call was made. This happened
because OP_super would call to get the superclass object ID, the
calling conventions of the compiler put this return value into EAX,
and then the PMachine message processing code put whatever was in
EAX into r_acc before each message was processed.

In the game code, there are a sequence of steps that look like
this:

* First, throttle::doVerb is called when throttle is clicked on;
* Which calls getRobot::doit to tell the shipwreck robot to start
  playing;
* Which calls wreckBot::init to reset the Robot for the animation;
* Which calls Hiliter::hotVerbs(0) to remove cursor hotspots;
* Which calls Hiliter::dispose to clean up since it is not used;
* Which causes Hiliter::verbList to get set to 0.
* Later, verbList is loaded into r_acc, and it is still 0;
* Then, Hiliter::dispose makes a super call to Obj::dispose;
* Then, Obj::dispose does nothing except call kDisposeClone,
  which does not mutate r_acc, so r_acc is still 0 from verbList;
* Then we return back through 5 calls to throttle::doVerb;
* Then throttle::doVerb checks that r_acc is non-zero, and if so,
  adds wreckBot to theDoits global, allowing the animation to
  occur.

In ScummVM, without setting r_acc in the super call, the non-zero
check failed and the wreckBot didn't get put into theDoits, so the
entire sequence fell apart. In SSCI, the non-zero check happened
to succeed because the Obj::dispose super call put the Obj class
into the accumulator. So now we do that too, and now Lighthouse
2.0a works here.

Earlier versions of SSCI used EAX for other things in between the
OP_super call and the message processing, so would set r_acc from
different data, so this change does not apply to those versions.
2017-09-19 19:54:30 -05:00
Colin Snover
eba9526fdd SCI32: Remove never-read default values 2017-09-19 19:54:30 -05:00
Colin Snover
b0b1e89abe SCI32: Hide warning about CD-ROM speed setting in kGetSierraProfileInt
In the DOS interpreters, this function is a no-op. Lighthouse calls
it regardless of platform, so dummy it out for non-Windows
platforms. This is not known to address any particular issue, and
is really just to eliminate the warning about an unknown
configuration setting when starting Lighthouse in a manner that is
compatible with the original interpreter.
2017-09-19 19:54:29 -05:00
Colin Snover
2f9967524f SCI: Stop EngineState::wait mutating r_acc
This wait function is used by kernel calls other than kWait, and
those other functions do not mutate r_acc in SSCI.
2017-09-19 19:54:29 -05:00
Martin Kiewitz
4a9098d083 SCI32: Heap patch for Phantasmagoria 2 to fix DocuStore placements
This fixes placement of "File", "Note", "From" and "Subject"
content.
See bug #10034
2017-09-17 19:13:03 +02:00
Martin Kiewitz
294503f516 SCI32: GK1CD: script for vine swing issue bug #9820
Gabriel's "I can't believe I'm doing this..." line was cut off.
This script patch stops that from happening.
2017-09-17 14:43:27 +02:00
Martin Kiewitz
1d018d65c8 SCI32: Clean-up pass on GK1,GK2,KQ7,PQ4,QfG4,Torin script patches
comments only
2017-09-17 01:51:50 +02:00
Colin Snover
a9316560ab SCI: Remove unused selector from script patcher selectors list 2017-09-16 16:33:09 -05:00
Colin Snover
e400f1aec2 SCI32: Clean-up pass on Torin script patches
* Convert selector literals to SIG_SELECTOR/PATCH_SELECTOR
2017-09-16 16:33:09 -05:00
Colin Snover
d1c43b24ea SCI32: Clean-up pass on GK1 script patches
* Make alignment of operation comments consistent
* Make patch descriptions consistent
2017-09-16 16:33:09 -05:00
Colin Snover
4e6fa4d690 SCI32: Clean-up pass on Shivers script patches
* Convert selector literals to SIG_SELECTOR/PATCH_SELECTOR
* Wrap comments at 80 columns
* Rewrite comments for clarity and brevity
* Make identifier suffixes, patch descriptions, and patch table
  ordering consistent
2017-09-16 16:33:09 -05:00
Colin Snover
4dcf88ef4f SCI32: Clean-up pass on Rama script patches
* Make alignment of operation comments consistent
2017-09-16 16:33:09 -05:00
Colin Snover
3b7e610364 SCI32: Clean-up pass on QFG4 script patches
* Convert selector literals to SIG_SELECTOR/PATCH_SELECTOR
* Make identifier suffixes and patch descriptions consistent
2017-09-16 16:33:09 -05:00
Colin Snover
c5dce17b1f SCI32: Clean-up pass on PQ4 script patches
* Convert selector literals to SIG_SELECTOR/PATCH_SELECTOR
* Convert word-size numeric literals to SIG_UINT16/PATCH_UINT16
* Wrap comments at 80 columns
* Rewrite comments for clarity and brevity
* Make alignment of operation comments consistent
* Make identifier suffixes, patch descriptions, and patch table
  ordering consistent
2017-09-16 16:33:08 -05:00
Colin Snover
34683f1725 SCI32: Clean-up pass on PQ:SWAT script patches
* Make patch descriptions consistent
2017-09-16 16:33:08 -05:00
Colin Snover
b9600bf466 SCI32: Clean-up pass on Phant2 script patches
* Minor clarity fixes to comments
* Make patch descriptions and patch table ordering consistent
2017-09-16 16:33:08 -05:00
Colin Snover
6fc09ae7c9 SCI32: Clean-up pass on Phant1 script patches
* Convert selector literals to SIG_SELECTOR/PATCH_SELECTOR
* Make identifier suffixes, patch descriptions, and patch table
  ordering consistent
2017-09-16 16:33:08 -05:00
Colin Snover
bfb87389f7 SCI32: Clean-up pass on MGDX script patches
* Convert selector literals to SIG_SELECTOR/PATCH_SELECTOR
* Fix a patch to use jmp instead of waste bytes
* Make identifier suffixes and patch descriptions consistent
2017-09-16 16:33:08 -05:00
Colin Snover
f7d20dc2e7 SCI32: Clean-up pass on LSL7 script patches
* Convert selector literals to SIG_SELECTOR/PATCH_SELECTOR
* Convert word-size numeric literals to SIG_UINT16/PATCH_UINT16
* Wrap comments at 80 columns
* Rewrite comments for clarity and brevity
* Make alignment of operation comments consistent
* Make identifier suffixes and patch descriptions consistent
2017-09-16 16:33:08 -05:00