Commit Graph
4076 Commits
Author SHA1 Message Date
Willem Jan Palenstijn d832a23241 SCI32: Add SaveFileRewriteStream for read/write access to files
At least Phantasmagoria and PQ:SWAT require this.

This adds a ReadStream/WriteStream to support this. It replaces
the previous VirtualIndexFile which required reimplementation of
most read/write functions.
2016-07-06 21:06:12 +02:00
Martin Kiewitz 20ccd3affc SCI: Fix typo in script patch comment (longbow arithmetic bug)
Wasn't bug #6571, but bug #6751
Thanks to omer_mor for spotting it
2016-07-06 19:57:26 +02:00
Martin Kiewitz ee41f6456e SCI: Adding script patch for longbow arithmetic berry bush bug
Fixes bug #6571
2016-07-04 18:31:40 +02:00
Willem Jan Palenstijn 4b72a42da9 SCI: Remove presumably long-outdated FIXME 2016-07-02 21:31:29 +02:00
Willem Jan Palenstijn d643cb651f SCI: Remove unexpected side effect from ExecStack constructor
The ExecStack constructor set argp[0] to argc before. This is now moved
to the caller, to make this action more explicit.
2016-07-02 21:25:53 +02:00
Willem Jan Palenstijn 7f12638763 SCI: Remove unclear &rest handling
Modifying a value above the stack pointer doesn't seem to make much
sense. This was added in FreeSCI back in 2002 in a pair of commits that
did not make clear what the purpose of this was. My guess is that it
attempted to adjust argc, but failed. This wouldn't have been noticed
since argc was always set correctly by make_exec_stack_entry (which is
now the ExecStack constructor).
2016-07-02 21:25:53 +02:00
Willem Jan Palenstijn 08f1727b08 SCI: Improve kernel subfunction logging
ExecStack now stores the kernel call number as well as the subfunction.
This allows kStub and backtraces to log the actual subfunction called.

The kernel call number in ExecStack used to be stored in the
debugSelector field. It now has its own field, to avoid confusion.
2016-07-02 21:25:53 +02:00
Willem Jan Palenstijn 9f2fff4f66 SCI: Remove unneeded copy 2016-07-02 21:25:53 +02:00
Martin Kiewitz 17b3dc4584 SCI: Fix script patcher, so that it works on BE systems 2016-07-01 15:23:50 +02:00
Filippos Karapetis 9cf3566e27 Merge pull request #766 from OmerMor/qfg3_bounds
SCI: Script patch for QfG3 giant tree bounds
2016-07-01 07:58:55 +03:00
Filippos Karapetis a40e43f777 Merge pull request #770 from OmerMor/kgettime
SCI: Fixed KGetTime with SYSDATE subop in SCI0-LATE.
2016-07-01 00:54:44 +03:00
Martin Kiewitz 9f789038b0 SCI: Add script patch for another Colonel's Bequest game bug
Command input stays disabled, when oiling the arm of the armor.
We fix this.
This script bug also happens, when using the original interpreter.

Fixes bug #7154
2016-06-27 21:42:18 +02:00
Omer Mor 36c7e7d252 SCI: Fixed KGetTime with SYSDATE subop in SCI0-LATE.
SSCI implementation of the SYSDATE subop of the GetTime kernel function was
changed between SCI0-LATE and SCI01: The base year used was changed from 1920 to
1980.
This subop is used in "Codename: Iceman" (Say "ask for date" to a passing girl
on the beach).

The Atari ST version of "Codename: Iceman" use the 1980 base year.
The Amiga version of "Codename: Iceman" appears to return the time instead of
date, with 0 for the YEAR part.
2016-06-27 08:16:58 +03:00
Colin Snover 6feec9ed72 SCI32: Add more workarounds for SCI2.1early games
These games all share the same bad system script that always sends
NULL as a second argument to kDoSound(play).
2016-06-26 12:44:35 -05:00
Colin Snover cfda8b9ecd SCI32: Fix broken Remap implementation
Remap would crash SCI2.1early games with 19 remap slots, and
did not actually work in most cases in SCI2.1mid+ games.

The SCI16 implementation was moved to its own separate file but
was otherwise touched as little as possible, so may still have
similar problems to the SCI32 code.

1. Split SCI16 and SCI32 code into separate files
2. Use -32 prefixes for SCI32 code and no prefix for SCI16 code,
   where possible, to match other existing code
3. Avoid accidental corruption of values from the VM that may be
   valid when signed or larger than 8 bits
4. Added documentation
5. Add missing remap CelObj calls
6. Inline where possible in performance-critical code paths
7. Fix bad `matchColor` function, and move it from GfxPalette to
   GfxRemap32 since it is only used by GfxRemap32
8. Fix bad capitalisation in getCycleMap
9. Remove unnecessary initialisation of SingleRemaps
10. Update architecture to more closely mirror how SSCI worked
11. Clarify the purpose of each type of remap type (and
    associated variable names)
12. Split large `apply` function into smaller units
13. Fix buffer overrun when loading a SCI2.1early game with remap
14. Remove use of `#define` constants
15. Warn instead of crashing with an error on invalid input (to
    match SSCI more closely)
16. Change the collision avoidance mechanism between the RemapType
    enum and remap kernel functions
17. Add save/load function
2016-06-26 12:42:58 -05:00
Martin Kiewitz 80462b3f87 SCI: Fix auto-saving in the fan-made Cascade Quest
Script patch to change the fixed slot 999 to fixed slot 99 in the
game scripts and additional code for kSaveGame, that checks for
Cascade Quest + slot 99 and will then use ScummVM slot 0, which
is our auto-save slot.

Fixes bug #7007

Also added the game name to the other fan-made script patch.
2016-06-25 23:59:01 +02:00
Martin Kiewitz 5385b4eda7 SCI: Script patch for critical Colonel's Bequest game bug
This patch is about an issue, when interacting with the
armor in room 37 (main house, downstairs).

This bug also happened, when using the original interpreter
and effectively froze the game depending on the coordinate
of Laura Bow, when the command was entered.

Fixes bug #7119

Versions affected: English PC/Atari ST/Amiga Floppy
2016-06-25 14:37:49 +02:00
Martin Kiewitz 09d314d3d7 SCI: Fix SQ1VGA script patch, fixes bug #7145
Script patch used "lsg" for one instruction, which should have
been "lag" instead.
Caused issues with the spider droid.
Added more details about this script patch in comments.

Also specified the method for a qfg3 script patch in comments.
2016-06-25 02:24:09 +02:00
Colin Snover 5b6114f4cc SCI32: Implement kBitmapDrawView 2016-06-21 16:12:33 -05:00
Colin Snover d6d0e00dc5 SCI32: Expose a draw buffer on BitmapResource objects
Most of the time, we get a bitmap to draw on it. Exposing a buffer
avoids consumers having to create their own all the time, and
encourages use of common drawing code exposed by the buffer.
2016-06-21 16:11:43 -05:00
Colin Snover 52505dc57f SCI32: Implement basic kMessageBox
This kernel call seems only to be used by KQ7 1.51 (which was
Windows-only) to send warnings to the user.

It was easy enough to do a basic implementation in the ScummVM
GUI rather than just make it an empty call, so now it is a thing.
2016-06-21 08:14:12 -05:00
Willem Jan Palenstijn ceee33ba2c SCI32: Add workaround for kScrollWindowAdd call in Phantasmagoria 2016-06-21 08:14:12 -05:00
Willem Jan PalenstijnandColin Snover ab864ba366 SCI32: Implement kScrollWindow
These should be all the actually used subfunctions.

Co-authored-by: Colin Snover <github.com@zetafleet.com>
2016-06-21 08:14:12 -05:00
Colin Snover a613a27b44 SCI32: Implement line drawing (kAddLine/kUpdateLine/kRemoveLine)
This line drawing code lives in a remodelled GfxPaint32 class
that is totally separate from GfxPaint16.
2016-06-21 08:14:12 -05:00
Colin Snover f939868f3a SCI32: Add kDoSound(play) workaround for LSL6hires 2016-06-20 21:52:41 -05:00
Colin Snover f02107f682 SCI: Minor cleanup of kDoSound
Replaces unused kernel calls to use kEmpty, and set correct
signatures for SCI32 kernel calls.
2016-06-20 21:02:21 -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
Colin Snover 5d3385750d SCI: Split audio sync to its own class
SCI32 has its own audio handling code, but audio sync code is the
same as SCI16.
2016-06-19 14:48:33 -05:00
Colin Snover b56266d28d SCI32: Fix video performance benchmarking in most SCI32 games
Most SCI32 games draw a "fred" object to the screen when the game
first starts to benchmark video performance. When framerate
throttling is enabled (which fixes many/most timing-related bugs
and reduces system load caused by unnecessary graphics updates),
the game's performance check will think that video card is slow,
causing some "high-performance" game features to be disabled.

To avoid this, we simply disable throttling during benchmarking by
detecting the "fred" object.
2016-06-14 20:58:53 -05:00
Omer Mor 1184c1d0c4 SCI: Script patch for QfG3 giant tree bounds
At the base of the giant tree, when entering from the top east path,
the hero can get out of bounds and walk freely in the room.
This is caused by an incorrect cutoff used to determine whether the
hero entered from the top or bottom path.
The patch changes this cutoff, and prevents going out of bounds.

Fixes bug #6693
2016-05-29 20:54:33 +03:00
Colin Snover d44ad1e82e SCI32: Remove invalid TODO about CLUT for 16-bit graphics
The CLUT for 16-bit graphics is not saved in SSCI (nor is it
normally even part of the palette manager).
2016-05-28 19:57:56 -05:00
Colin Snover fe7ae6087a SCI: Remove warning in kDisposeScript
The two-argument implementation is correct and works properly.
2016-05-28 11:42:17 -05:00
Colin Snover 371b50e75a SCI32: Add explicit checks for null pointers
CID 1351617, 1351618, 1351619, 1351620, 1351621, 1351622, 1354791.
2016-05-27 19:20:22 -05:00
Colin Snover c231d22c28 SCI32: Fix LSL6 hires control panel script bug
The control panel initialisation script makes an invalid two-argument
call to get the width of the settings dial; this only happens to work
because the third argument on the stack was set to zero by an earlier
call.
2016-05-25 19:16:11 -05:00
Omer Mor aaf8cbca00 SCI: Script patch for fixing 3 missing points in QfG3
The hero is unable to tell Rakeesh and Kreesha about the Simabani
initiation, which would award him 3 points.
This is caused by a heap bug in room 285: the local array of possible
messages omits this message.
The patch fixes the bug by adding this message to the array.

Fixes bug #7086
2016-05-22 00:41:32 +03:00
Ori Avtalion 253e18c440 JANITORIAL: Reduce GUI header dependencies 2016-04-14 13:30:14 +03:00
Johannes Schickel c412478a11 SCI: Fix compilation for C++98. 2016-04-06 23:22:44 +02:00
Johannes Schickel c11b09dff9 SCI: Remove commented out code line. 2016-03-25 01:15:26 +01:00
Johannes Schickel f23dd0f486 SCI: Use aggregation to store objects in SegmentObjTable.
This allows to store pointers and fundamental types in a SegmentObjTable.
2016-03-25 01:15:26 +01:00
Johannes Schickel 1c6112e121 SCI: Introduce accessors for SegmentObjTable entries.
This makes code not use _table directly whenever possible. An exception is the
save game code which is not easy to adapt due to design deficiencies.
2016-03-25 01:15:26 +01:00
Johannes Schickel 77b5ce075a SCI: Get rid of template hack for serialization.
The former template hack relied on specialized functions for various types. We
use a hand crafted set of functions for serialization functionality now.
2016-03-25 01:15:26 +01:00
Colin Snover eec95957bf SCI32: Clean up outdated/wrong comments 2016-03-20 09:33:13 -05:00
Colin Snover f4e5c6d2de SCI32: Return correct value from kSetFontHeight 2016-03-20 09:32:53 -05:00
Colin Snover 37b8bd9404 SCI32: Do not change accumulator in non-returning kernel calls
This did not cause any known bugs, but is wrong according to the
way the actual engine works.
2016-03-20 09:31:28 -05:00
Colin Snover 9335e40997 SCI32: Use signed values for displacement position 2016-03-20 09:12:43 -05:00
Colin Snover d2c0aa004b SCI32: Add workaround for invalid temp read in Torin 2016-03-18 18:55:31 -05:00
Colin Snover 856f3ae648 SCI32: More correctly fix kStringCopy overflow
This entire kString code needs to be reviewed/refactored, but
at least this fix is more complete than the last one.

Thanks to @lordhoto and @wjp for their assistance.
2016-03-18 11:10:49 -05:00
Colin Snover b7d5dd9187 SCI32: Fix heap overflow (read) in kStringCopy 2016-03-18 10:28:51 -05:00
Martin Kiewitz 54756498bc SCI: Add workaround for restoring kq6 saved games (lowres/hires)
KQ6 CD sets a global depending on lowres/hires state right at the
start and some scripts are using it instead of calling kPlatform.
This causes some graphics to be incorrect (well lowres)
in case the user saves in lowres mode, then switches to hires
mode and restores the previously saved game.
We now set that global directly after restoring saved games,
so that this issue does not happen anymore.
KQ6 CD demo did the same.
2016-03-16 14:49:21 +01:00
Filippos Karapetis 9b92960691 SCI32: Document kAddLine 2016-03-15 11:30:53 +02:00