Commit Graph
49 Commits
Author SHA1 Message Date
sluicebox 695b7f9229 SCI32: Improve SCI3 object parsing
Adjust the parsing code to more accurately reflect the
resource format. Adds more comments and less allocations.
2022-03-03 22:26:09 -05:00
Eugene Sandulenko abea37c9bb ALL: Update ScummVM project license to GPLv3+ 2021-12-26 18:48:43 +01:00
sluicebox 9982c761a2 SCI: Update all old bug tracker ticket numbers 2021-02-25 01:18:52 -08:00
Filippos Karapetis 9dd63b12b1 SCI: Add more script patcher checks for games without a selector vocab
Fixes the LSL1 demo
2019-09-14 11:39:35 +03:00
Filippos Karapetis 941869c466 SCI32: Remove reg32_t and use reg_t in all cases
reg32_t was a transitive solution, before reg_t's were
adapted to use 32-bit addresses internally, and before
support for SCI3 was added. It was introduced as another
way to handle large script offsets in SCI3, and was only
used for the program counter (PC). It's no longer
needed, as we now support SCI3 script offsets using
reg_t's, so we can use make_reg32 in all cases where
we need to access offsets over 64KB
2018-08-25 12:39:12 +03:00
Colin Snover 3bc00e6633 SCI: Stop double-initialization of SCI0/1 objects
These objects should have been initialized only during the first
pass. Double-initialization does not cause any visible problem
problem during normal operation (mostly it just causes memory
waste by making Object::_baseVars/_baseMethod double up their
data), but could have silently allowed games to receive bogus data
for an out-of-bounds property or method index, instead of raising
an error.
2017-07-15 20:29:36 -05:00
Colin Snover 051366a48a SCI: Fix up Object::_baseMethod implementation
1. In SCI0/1, selectors and offsets in the method block are
   stored contiguously (all selectors, then all offsets), with a
   null separator between the two runs. All the later versions of
   SCI instead interleave selectors & offsets. Since these values
   are already being copied into a new array anyway, code for
   reading method selectors/offsets is now simplified by
   interleaving this data when it is written into _baseMethod
   for SCI0/1, so the same equation for retrieving method
   selectors/offsets can be used across all SCI versions.

2. In SCI1.1-2.1 branch, the method count was being copied into
   the first entry of the array, which meant that SCI1.1-2.1 had
   extra code for dealing with the fact that the first entry was
   not an entry. This has been fixed, and the extra code removed.

3. Data was being overread into _baseMethod in all games SCI0-2.1.
   (SCI0/1 had an extra magic value of 2, and SCI1.1-2.1 had an
   extra magic value of 3). Reviewing history, it's not clear why
   this happened, other than that it appears to have been
   introduced at 7b0760f1bc. My best
   guess is that this was a confusion between byte count and record
   count, where the intent was to read an extra 2 bytes for the
   null separator in SCI0/1, but it actually read 2 records
   instead. (I do not have a guess on why SCI1.1 ended up with a
   3.) This overreading has been removed.
2017-07-15 20:10:38 -05:00
Colin Snover d0040dc8ef SCI32: Fix SCI3 object names > 0xFFFF 2017-05-25 19:25:50 -05:00
Colin Snover 4917330038 SCI: Find and store the original static names of objects
See code comment in Object::init for more details.

Fixes Trac#9780.
2017-05-20 21:14:18 -05:00
Colin Snover 1f29e6f241 SCI: Refactor relocation code
This groundwork enables an object to look up its static name
separately from the normal process that is used to populate
Object::_variables when an object is first constructed.

(The static name property needs to be able to be retrieved from
objects inside of earlier save games whose name properties may
have already been modified at runtime, so the code cannot simply
pluck the value out of Object::_variables when they are first
initialised and then persisted into the save game, as nice and
easy as that would have been.)

This commit also helps to clarify the situation with relocation
tables in SCI1 games that start with a zero entry.

Refs Trac#9780.
2017-05-20 21:14:18 -05:00
Colin Snover d09ae57fd8 SCI32: Remove bad assertion in relocateSci3
While extremely rare (only Rama script 64948 seems to have this
profile), it *is* possible for an object to have zero properties
(and thus, zero property offsets).
2017-05-20 21:14:18 -05:00
Colin Snover eda836f21a SCI: Nitpicky cleanup of some magic numbers and what-not-why comments 2017-05-20 21:14:18 -05:00
Colin Snover 71630a7cb2 SCI: Remove duplicate relocateBlock function 2017-05-20 21:14:18 -05:00
Colin Snover e15a4c806a SCI: Use the var count from the instance's class in SCI1.1-2.1 when looking up selectors
At least some versions of Island of Dr Brain have a bMessager
instance in script 0 with a var count greater than that of its
class. This probably should never happen since it means the
object has a variable with no corresponding selector.

The next commit adds some extra sanity checking code to object
initialization, to warn on any other games where this happens.
2017-04-24 21:39:30 -05:00
Colin Snover d53f3f6095 SCI32: Exclude SCI3 code from compilation when SCI32 is disabled 2017-04-23 13:07:25 -05:00
Colin Snover 3d4fb4ccb4 SCI32: Fix mustSetViewVisible for SCI3
In SCI2/2.1, variable indexes are used along with a range encoded
in the interpreter executable to determine whether an object
variable is a view-related variable. Operands to aTop, sTop, ipToa,
dpToa, ipTos, and dpTos are byte offsets into an object, which
are divided by two to get the varindex to check against the
interpreter range.

In SCI3, objects in game scripts contain groups of 32 selectors,
and each group has a flag that says whether or not the selectors
in that group are view-related. Operands to aTop, sTop, ipToa,
dpToa, ipTos, and dpTos are selectors.
2017-04-23 13:07:25 -05:00
Colin Snover 1962b1bb6d SCI32: Replace magic numbers in SCI3 selector init 2017-04-23 13:07:25 -05:00
Colin Snover fc02b34215 SCI: Deduplicate Object::locateVarSelector code
The variable count returned by Object::getVarCount is populated
by variable 1 in SCI1.1, so specially reading the variable
explicitly for that engine version is not necessary.
2017-04-23 13:07:25 -05:00
Colin Snover eadf5d818f SCI: Fix support for 32-bit SCI3 script offsets 2017-04-23 13:07:25 -05:00
Colin Snover 6b95528b49 SCI32: Fix bad relocations of SCI3 objects 2017-04-23 13:07:25 -05:00
Colin Snover 90c6c0580e SCI: Convert Object to use Common::Array for SCI3
In SCI3, index-to-selector tables no longer exist in compiled
object data (instead, the SCI3 VM uses selectors directly and
object data contains a bit map of valid selectors). In ScummVM,
the table is generated by Object::initSelectorsSci3 for
compatibility with the design of the ScummVM SCI VM. For
consistency, _baseVars is converted to use a standard container,
which works for all SCI versions.

The table for SCI3 property offsets is also changed to use a
standard container instead of manually managing the memory with
malloc/free.
2017-04-23 13:07:25 -05:00
Colin Snover 8299460917 SCI32: Hook up mustSetViewVisible for SCI3 2017-04-23 13:07:25 -05:00
Colin Snover 41c633f0c5 SCI: Fix whitespace errors 2017-04-22 19:28:34 -05:00
Colin Snover 31daa956d6 SCI: Implement bounds-checked reads of game resources 2017-03-27 19:42:31 -05:00
Filippos Karapetis e317958d4c SCI: Remove superfluous cast to boolean and fix code styling 2016-03-01 01:23:55 +02:00
Lars Skovlund a375cbf42b SCI3: Collect bits for managing kInfoFlagViewVisible 2016-02-29 16:00:13 +01: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
Johannes Schickel 8fc7d60feb SCI: Make GPL headers consistent in themselves. 2014-02-18 02:39:37 +01:00
Willem Jan Palenstijn 78e7f5b51c SCI: Make second pass when loading objects
This is because objects may be loaded before their base objects,
which causes initBaseObject to fail for SCI0.

Script::initializeObjectsSci0 already did this, but
SegManager::saveLoadWithSerializer did not when calling
initBaseObject after loading a savegame.
2013-12-14 14:19:33 +01:00
Filippos Karapetis 2b50824133 SCI: Add setter/getter methods to reg_t's
No functionality change has been made with this commit. This avoids
setting and getting the reg_t members directly, and is the basis of any
future work on large SCI3 scripts (larger than 64KB)
2012-06-18 05:24:06 +03:00
Filippos Karapetis a0add53c60 SCI: Change getClassAddress() to only require the caller segment
The caller offset is never actually used inside the function
2012-06-15 22:32:17 +03:00
Filippos Karapetis 9aaefbd536 SCI: _propertyOffsetsSci3 and classpos should be 32-bit integers
These are needed for future handling of large SCI3 script files
2012-06-15 12:24:18 +03:00
Filippos Karapetis d71aec0b39 SCI: Changed a warning about wrong object variable count into a debugC 2011-10-11 01:39:56 +03:00
Max Horn 88913c0139 ALL: Remove trailing whitespaces
This tries to make our code a bit more compliant with our code formatting
conventions. For future use, this is the command I used:
  git ls-files "*.cpp" "*.h" | xargs sed -i -e 's/[ \t]*$//'
2011-06-20 00:59:48 +02:00
Max Horn 8615cecfe0 SCI: Constify Object::_baseVars
This may have to be undone if we ever want to start free'ing _baseVars again.
2011-05-25 16:44:50 +02:00
strangerke 69b1485a22 GIT: Clean up: Suppress SVN tags, now useless 2011-05-12 01:16:22 +02:00
Matthew Hoops 8f40a18146 SCI: Remove a space at the end of a warning 2011-03-14 18:48:43 -04:00
Willem Jan Palenstijn c1cdc49ac5 SCI: Add code to enumerate shadowed selectors
If an object defines more variables than its base class, some method
selectors may be hidden. This code tries to enumerate the affected
selectors. It may be useful for mass-scanning objects using
'find_callk Dummy'.

It's disabled by default currently since it does things to partially
uninitialized objects that I can't guarantee are 100% safe at this
point.
2011-03-14 20:34:16 +01:00
Willem Jan Palenstijn 0360b4ac95 SCI: Add reference to related bug to comment 2011-03-13 18:28:01 +01:00
Willem Jan Palenstijn bd6602ea6f SCI: Clarify fix for KQ5 witch freeze bug #3034714
The cause for this bug turns out to be a corrupt object that as
a side effect accidentally bypasses its own corruption. See the
added comments for details.

Also add a warning that points out similarly corrupted objects.
2011-03-11 23:09:13 +01:00
Willem Jan Palenstijn 190bd60505 SCI: Make SCI3 propertyId endianness hack a bit cleaner
svn-id: r55542
2011-01-26 16:51:18 +00:00
Max Horn fec516e2b0 SCI: cleanup
svn-id: r55539
2011-01-25 20:21:57 +00:00
Lars Skovlund e1a9c866bf SCI3: Fix script abort during startup on Big Endian platforms
svn-id: r55525
2011-01-25 10:21:44 +00:00
Lars Skovlund a03a3fd411 Fix code formatting
svn-id: r55026
2010-12-23 14:05:16 +00:00
Lars Skovlund 5b2071487f SCI: Unbreak script loading on big-endian machines. Thanks to [md5] and wjp.
svn-id: r55025
2010-12-23 14:03:58 +00:00
Filippos Karapetis 42dc70bb83 - SCI: Added code to free the _baseVars value in SCI3 as well. Both free() operations
have been commented out for now, as MSVC complains about heap corruption in SCI3 games
- Code formatting fixes

svn-id: r54991
2010-12-21 21:18:25 +00:00
Lars Skovlund 7b0760f1bc Make Object::_baseMethod a Common::Array. This is intended to clean up
the Object class, and it also plugs a leak.

svn-id: r54986
2010-12-21 15:36:27 +00:00
Filippos Karapetis eba5c441b2 SCI: Fixed bug #3044050 - "SQ4FLOPPY: Crash while flying in Skate-o-Rama"
Fixed Object::locateVarSelector() for SCI0-SCI1 games, as it wasn't checking the
class for object variables

svn-id: r54415
2010-11-22 10:23:53 +00:00
Filippos Karapetis 3b07056a47 SCI: Moved the Object class in a separate file
svn-id: r54361
2010-11-19 08:18:24 +00:00