Commit graph

191 commits

Author SHA1 Message Date
Colin Snover
a799cb3462 SCI: Fix SCI3 exports
Export functions may be relocated above 64k in SCI3, but exports
that do not have an entry in the relocation table must be handled
the same as SCI1.1-2.1.
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
0394fd44e8 SCI: Fix whitespace errors 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
d0a143fa87 SCI32: Fix locals offset in SCI3
Locals offset needs to be set even when the script has no exports.
2017-04-23 13:07:25 -05:00
Colin Snover
7997451384 SCI32: Remove TODO from relocateOffsetSci3
The field at +8 is for the MemID associated with a relocation.
2017-04-23 13:07:25 -05:00
Colin Snover
c9342beca9 SCI: Remove unused commented code 2017-04-23 13:07:25 -05:00
Colin Snover
a620b6c354 SCI: Fix handling of buggy SCI0 export tables
The previous fix for this bug was incorrect; it only happened
to work because of another bug: the number of exports was being
read incorrectly (reading the byte size of the export block, not
the number of exports), so the validation check for the export
number always passed. Then, the "small" offsets that were seen
were actually either invalid reads into the header of the next
block in the script (KQ4), or reads into the bad first export
table which contained an unfilled offset (Camelot).

Once the incorrect number of exports was fixed, the previous "fix"
broke in KQ4 because the export number validation started to work
correctly and the first export table does not have enough entries
(needs 2, has 1).

This patch fixes the bug by using the last export table in SCI0
scripts instead of the first export table. (This does not affect
most scripts, since only the buggy scripts have more than one
export table.)

Fixes Trac#9731.
2017-04-18 11:47:18 -05:00
Willem Jan Palenstijn
ee86a74cd3 SCI: Fix remaining format string warning 2017-03-30 22:00:27 +02:00
Colin Snover
a233696212 SCI: Update formatting strings to match updated Span API 2017-03-30 14:23:41 -05:00
Colin Snover
323e74bda9 SCI: Simplify calculation of locals size in SCI0/1 2017-03-27 19:42:31 -05:00
Colin Snover
31daa956d6 SCI: Implement bounds-checked reads of game resources 2017-03-27 19:42:31 -05:00
Colin Snover
4814682d5f SCI: Improve disassembly output
1. pushi opcode now displays decimal value and selector value (if
   one exists) in-line
2. lofsa, lofss, and super opcodes now display resolved
   object/class names
3. Opcode arguments are visually aligned
2016-11-20 12:31:44 -06:00
Colin Snover
55222ec06c SCI32: Fix zero-offset exports
Exports with a zero offset are supposed to point to the start of
the code block in the script hunk, but they were being ignored.

This may also apply to SCI1.1 games, but until that can be
verified, this fixes the zero-offset in only SCI32 games for now.
2016-10-20 11:33:08 -05:00
Willem Jan Palenstijn
699a147348 SCI: Make -propDict- unique for each class
Previously, this was using the offset of the property dict inside the
script. However, this isn't unique. For example, SQ6's DPath and
PolyPath classes both have their property dict at offset 8 of their
respective scripts. This would break Obj::isMemberOf.

Closes #846.
2016-10-14 19:43:32 -05: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
Filippos Karapetis
3a29dfaebf SCI: Fix object init in SCI3 scripts which are larger than 64kb 2015-07-13 01:35:26 +03:00
Martin Kiewitz
3b092e5d60 SCI: identifyOffsets() counter variables 2015-05-17 18:51:22 +02:00
Martin Kiewitz
3698ca8cf7 SCI: adjust SCI3 offset identify thx lskovlun 2015-05-15 23:46:25 +02:00
Martin Kiewitz
c787560acb SCI: add SCI3 support for debug cmd scro 2015-05-14 20:58:14 +02:00
Martin Kiewitz
3183ef0854 SCI: add said-details to script_said debug cmd 2015-05-14 20:41:21 +02:00
Martin Kiewitz
bfab4c4cbe SCI: debug commands scro, scrs and script_said
implement string collecting for SCI3
implement object offset collecting for SCI0-SCI2
implement said-str offset collecting for SCI0-SCI1
add new debug command scro / script_objects
add new debug command script_said
string without terminating NUL now a warning
the latter happens in qfg2 for amiga room 84
2015-05-14 20:33:21 +02:00
Martin Kiewitz
f1a75991ed SCI: fix bug in new string identifying code
fixes string identifying in mac SCI1.1 games
2015-05-04 21:50:42 +02:00
Martin Kiewitz
ed7007162a SCI: Scripts: identify strings + debug command
debug command is called "script_strings" / "scrs"
2015-05-04 21:19:05 +02:00
Martin Kiewitz
cb8e40c116 SCI: QFG3 fix priority of chief in hut bug #5173
this is a script issue and also happens
in Sierra's SCI. Gets solved by script patch.
2015-04-16 01:26:23 +02:00
Johannes Schickel
8fc7d60feb SCI: Make GPL headers consistent in themselves. 2014-02-18 02:39:37 +01:00
Martin Kiewitz
8bdffcb2fb SCI: script patcher is now a separate class 2013-12-04 20:42:16 +01:00
Martin Kiewitz
3fbbdbc2da SCI: improved script patcher
Gabriel Knight + King's Quest 6 patches now also work for Mac versions of those games
added support for selectors instead of using hardcoded values
2013-11-03 23:49:31 +01:00
Willem Jan Palenstijn
8f754ced42 SCI: Flip assert
This way the assert is checking that the allocated buffer is large enough
for the memcpy that follows it.
2012-10-07 12:27:14 +02:00
Filippos Karapetis
cc77688696 SCI: Remove an incorrect error check in validateExportFunc() 2012-06-28 03:29:34 +03:00
Filippos Karapetis
7e66cbd468 SCI: Rename a parameter in validateExportFunc()
This ensures that it won't be confused with a function with the same name
2012-06-26 11:13:14 +03:00
Filippos Karapetis
20b6770808 SCI: Change the program counter (PC) to be a 32-bit variable
This is needed for future support of large SCI3 scripts. The program
counter is isolated and does not interfere with other parts of the VM,
plus it does not get stored in saved games, so it's pretty straightforward
to convert
2012-06-23 21:45:26 +03:00
Filippos Karapetis
c1eb93bc5a SCI: Clean up validateExportFunc() and related functions
Also renamed some SCI3 related code to indicate when it's SCI3 specific
2012-06-23 21:45:24 +03: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
041b1447c0 SCI: Replace RAW_IS_OBJECT with a method 2012-06-15 22:32:15 +03:00
Filippos Karapetis
5ca22a1104 SCI: Fix warnings
Thanks to DrMcCoy for reporting them
2012-06-15 22:32:15 +03:00
Filippos Karapetis
160732b2f7 Revert "SCI: Change Script::getObject() to accept a reg_t"
This reverts commit 577d7e41c9.
2012-06-15 22:32:14 +03:00
Filippos Karapetis
562a8a980c SCI: Further cleanup of the script code
Merge the init() and load() Script methods and reset the script when
necessary
2012-06-15 12:53: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
e1ae110860 SCI: Clean up the script initialization code 2012-06-15 12:24:16 +03:00
Filippos Karapetis
577d7e41c9 SCI: Change Script::getObject() to accept a reg_t
This is needed for upcoming changes to the Script class
2012-06-15 12:24:14 +03:00
Filippos Karapetis
9c8ff41181 SCI: Add known large SCI3 scripts 2012-06-14 12:20:41 +03:00
Filippos Karapetis
267c6f1756 SCI: Made more fields of the Script class private. Some cleanup. 2011-11-05 03:00:42 +02: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
Matthew Hoops
9539017ee3 ALL: initialise -> initialize 2011-05-25 11:17:11 -04:00
Willem Jan Palenstijn
c01fed7159 SCI: Avoid incrementing lockers of deleted script
Having a deleted script with non-zero lockers had the side effect of
making the deleted script re-appear in the GC's work list, including
any (deleted) objects in the script.

This should be the root cause of bugs #3299458 and #3295849, so
also delete the workaround added for that in 35086fe1.
2011-05-13 23:09:04 +02:00
strangerke
69b1485a22 GIT: Clean up: Suppress SVN tags, now useless 2011-05-12 01:16:22 +02:00
Willem Jan Palenstijn
eb8b1a962b SCI: Fix precedence (bug #3087872) 2011-04-20 23:38:28 +02:00
md5
ca1f9a075f SCI: Got rid of VERIFY() and removed some newlines in error messages 2011-03-14 20:00:26 +02:00