Commit Graph
466 Commits
Author SHA1 Message Date
Colin Snover 31daa956d6 SCI: Implement bounds-checked reads of game resources 2017-03-27 19:42:31 -05:00
Willem Jan Palenstijn cdfe5a3107 SCI: Remove check that is never triggered
Since blockSize is asserted to be positive, buf can never be equal to _buf.
2017-02-18 15:20:57 +01:00
D G Turner 657e5414fe SCI: Fix Possible Uninitialized Variable Usages. 2017-01-16 07:22:32 +00:00
Willem Jan Palenstijn 740b0bb0ca SCI: Unconditionally save palvary state
Additionally, add workaround to fix up old QfG3 saves with broken
_palVaryPaused state. Fixes bug #9674.
2017-01-06 19:03:50 +01:00
Colin Snover aa0836816d SCI32: Fix missing digital audio playback on save game restore
Fixes Trac#9581.
2016-11-02 15:43:07 -05:00
Colin Snover 8c555200d9 SCI32: Change storage type of int16 arrays to hold reg_ts instead
Memory references and integers in SSCI are both 16-bit numbers,
so game scripts frequently (incorrectly) use an IntArray instead
of an IDArray for holding references. Since references in ScummVM
are 32-bit reg_ts, IntArray entries must be large enough to hold
reg_ts in order to be compatible with game scripts that store
references in integer arrays.

The alternative solution is to find and patch all incorrect use of
IntArray across all games. This is possible, but a bit risky from
a save game stability perspective, since incorrect IntArray usage
is sometimes not apparent until well after the array is
instantiated (like GK1's global interview array).

This change invalidates existing SCI32 save games.
2016-10-09 11:21:13 -05:00
Willem Jan Palenstijn 379e3b80da SCI: Release SCI music mutex earlier in reconstructPlayList
This avoids a deadlock where the main thread (via reconstructPlayList)
tries to acquire the mixer lock (in soundPlay) while holding the SCI
music lock, and the audio thread is holding the mixer lock and tries to
acquire the SCI music lock (in miditimerCallback). Bug #6691.
2016-10-08 22:32:13 +02:00
Colin Snover 60be24d973 SCI: Bump save game number to fix save game compatibility
Version 38 save games were added to the 1.9 release branch with
only changes to SCI32 cursor support; shortly thereafter, changes
to the general (SCI16+SCI32) save game metadata were committed to
master -- without bumping the save game version number. This
prevented SCI16 save games from loading correctly in 1.10pre, since
the engine expected that version 38 games would have this extra
metadata, but they don't.
2016-09-30 19:05:14 -05:00
Colin Snover b6b9e2fce4 SCI32: Give savegame-only methods internal linkage 2016-09-30 13:54:10 -05:00
Colin Snover 988865cdc7 SCI32: Reset saved parts of GfxPalette32 when loading save games 2016-09-30 13:54:10 -05:00
Colin Snover 5baff4a1e5 SCI32: Fix some buildbot compiler warnings 2016-09-30 13:54:06 -05:00
Colin Snover 6290f1e5fc SCI: Add prefix to global variable constants 2016-09-29 19:39:16 -05:00
Colin Snover 1847b0f705 SCI32: Fix warnings and incompatible save games when built without SCI32 2016-09-29 19:39:16 -05:00
Colin Snover 0c9d423497 SCI32: Emulate MGDX ego view metadata 2016-09-29 19:39:16 -05:00
Colin Snover 2629269212 SCI32: Emulate Shivers 1 game score metadata 2016-09-29 19:39:16 -05:00
Colin Snover 64dc37cfe2 SCI32: Start implementing kSave for SCI32 2016-09-29 19:39:16 -05:00
Colin Snover 3f91726765 SCI32: Rewrite kArray & kString
This change invalidates earlier SCI32 save games, which separated
arrays and strings in an incompatible manner. Old save games
contain invalid references to a string segment which no longer
exists, and contain incompatible array structures that lack
critical type information.
2016-09-29 19:39:16 -05:00
Colin Snover 1760fb3e0d SCI32: Fix incorrect/missing cursor after restoring a save game 2016-08-28 13:06:34 -05:00
Colin Snover 80d9182554 SCI32: Implement SCI32 cursor support 2016-08-19 13:57:40 -05:00
Colin Snover 22c7be2c86 SCI: Fix sign comparison warning 2016-08-13 16:29:24 -05:00
Colin Snover 741ac22e17 SCI: Fix pointer invalidation caused by array storage moves
When objects are added to a SegmentObjTable, it may cause the
internal storage for the table to expand and move to a new
region of memory. When this happens, all pointers to objects held
by a SegmentObjTable of the same type would be invalidated, due
to an implementation detail that should not be exposed. To prevent
this, objects are now allocated separately on the heap, so even if
the table's storage moves due to insertions, the objects owned by
the table will not, so references remain valid for the lifetime of
the object.
2016-08-13 15:41:31 -05:00
Colin Snover 6a7ddd8ba1 SCI32: Actually save and load remaps 2016-08-06 11:23:18 -05:00
Colin Snover d5d42d5066 SCI32: Implement bitmap save routine 2016-08-01 10:37:14 -05:00
Colin Snover 6d1f8e8c87 SCI32: Fix invalid memory access after BitmapTable is extended
When new bitmaps are added and the underlying Common::Array needs
to move to expand, this invalidates all pointers to bitmaps, which
makes it basically impossible to use the bitmap segment since you
never know if a reference is going to be invalidated due to an
array move.

To solve this, BitmapTable is changed to hold pointers to
SciBitmaps that are allocated separately on the heap instead, so
when those bitmaps are looked up, the resulting pointers are valid
for the lifetime of the bitmap, instead of the lifetime of the
Common::Array used internally by BitmapTable.
2016-08-01 10:37:14 -05:00
Colin Snover 2071196f42 SCI32: Add bitmap segment and remove GC option from hunk segment 2016-08-01 10:37:14 -05:00
Colin Snover 4cfc387602 SCI32: Split GfxPalette and GfxPalette32 + HunkPalette 2016-07-11 10:39:50 -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
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
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 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
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
Martin Kiewitz 8588592947 SCI32: Don't do a syncWithScripts on restore from launcher
Causes issues in at least gk1 (option + inventory plane are shown)
Game::restore is not called, when doing restores from launcher,
so in the original interpreter this script code wasn't called
either.

Fixes option + inventory planes etc. being shown right after
restoring via launcher, when original save/load dialogs were
disabled.
2016-03-02 19:34:40 +01:00
Martin Kiewitz 480035d6aa SCI32: Do not clear screen when restoring for SCI32
Fixes graphical issues, when restoring saved games.
SCI32 did not clear the screen and also did not even redraw the
screen on restore. It only redraws elements that have changed.
Behavior verified using TSR in DOSBox (see comments).
Also added comment about clearing the screen for SCI16.
2016-02-22 21:38:01 +01:00
Martin Kiewitz 1ac8533b1f SCI32: Fix save patching for ScummVM dialog
- Patch game super object for saving instead of game object
- Remove re-adding planes+screen items, game::replay does that
We would only have to do that for soft-failing on restore
- Change debug levels of kNumLoops/kNumCels to 9
- Add special comment about -info- selector in syncWithScripts()

This should now make ScummVM menu saving work properly at
least in SQ6.
2016-02-21 20:33:17 +01:00
Martin Kiewitz 3e4efdbd27 SCI32: Implement syncing planes+screen items from VM for restore
Fixes restoring saved games, when ScummVM dialogs are patched in
Removing clearing planes+screen items as well, because the scripts
actually did that, but did not clear everything.
Fixes "Invalid screen item" message when entering options menu,
after restoring in SQ6.
2016-02-21 17:21:48 +01:00
Martin Kiewitz ce595cb92d SCI: Script patch for Mixed Up Mother Goose SCI1
+ Mother Goose SCI1.1
Fixes graphic issues when restoring from GMM
Also make the fix ups for Mixed Up Mother Goose, Jones + PQ2
get applied all the time (debugger command not included)
2016-02-09 01:28:34 +01:00
Filippos Karapetis 7ffc4f9816 SCI: Silence false positive warning in MSVC 2016-02-05 23:50:53 +02:00
Colin Snover 76bd2eeb2e SCI: Use tick-based timing more consistently
This means tick-based times are saved to save games, as in SCI32
engine, instead of seconds, which are not accurate enough. It
also means places in SCI engine that need to access game ticks
should do so through g_sci instead of g_system or g_engine.
2016-01-14 16:13:22 -06:00
Colin Snover fb891e4c08 SCI: Implement SCI32 kPalVary and kPalette setFade
This also fixes kPalCycle signatures to be more accurate.
2016-01-14 16:13:22 -06:00
Colin Snover aeee621e44 SCI32: Add initial support for palette cycling (kPalCycle) and fading (kPalFade)
Graphics palette code was rewritten between SCI1 and SCI2, so
SCI32 palette engine code has been moved to a separate GfxPalette32
class.
2016-01-07 16:35:09 -06: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 30b5497e24 SCI: Clarify function name 2015-05-03 13:45:05 +02:00
Martin Kiewitz 02dd8cffcc SCI: move SCI32 plane clear to gamestate_restore() 2015-04-27 20:50:37 +02:00
Martin Kiewitz 031b9b8ced SCI: restore: clear screen when restoring
primarily to clear kPortrait graphics in kq6
when restoring during portrait animation
2015-04-26 15:50:12 +02:00
Martin Kiewitz 5f53b9255e SCI: restore: reset ports before loading memory
otherwise we could free hunk space of the
loaded saved game
2015-04-26 15:29:02 +02:00
Martin Kiewitz bfba28c335 SCI: implement delayed restore via ScummVM menu
will delay restoring a saved game until the next
 kGetEvent or kWait
also implement aborting playback for kPortrait
 and kShowMovie
2015-04-26 09:08:46 +02:00
Martin Kiewitz 179ef7adb2 SCI: fix Camelot save on map screen bug #6744
don't put restored script windows into
_windowList[]
2015-04-23 18:54:07 +02: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