104 Commits

Author SHA1 Message Date
Ben Castricum
34df7b9891 SCUMM: ZAKFM Add script bug workaround, fixes bug #5624
Due to poor translation of the v2 script to v5 an if statement jumps in the
middle of a cutscene causing a endCutscene() without a begin cutscene()

Previous "fixes" do improve the code, but do not fix this cutscene issue.

See also

https://bugs.scummvm.org/ticket/3099
https://bugs.scummvm.org/ticket/5624

and commits

1d40f7849965e8b758b88197820daf9c6af4d120
Fixes the mistranslation of getState08(465) into classOfIs(465,[0]) at 001A

0725be325f60fa578b918aaaaef1d5f4008d310a
Fixes several mistranslations of setClass
2020-12-25 23:14:36 +01:00
D G Turner
59b639ed4d SCUMM: Fix Missing Default Switch Cases
These are flagged by GCC if -Wswitch-default is enabled.
2019-12-23 11:56:16 +00:00
Colin Snover
4d3f05ae79 SCUMM: Fix array overflow writing var when no current script is set
This situation is triggered normally when _currentScript is 0xFF,
but it could potentially also happen if _currentScript is some
other number >= NUM_SCRIPT_SLOT, so the check is a bit more
conservative than it might appear to need to be.
2017-12-01 19:39:30 -06:00
Robert Crossfield
814d9b1153 SCUMM: Maniac V0: Correctly handle 'slanted' walk-boxes, Add new variables to save-games, Bump the SaveGame Version number, remove obsolete V0 code in V2 functions 2014-12-02 16:25:03 +11:00
Robert Crossfield
2dbd99d572 SCUMM: Maniac V0: Implement the original Walk Code (to fix some anim glitches), fix opcode to use _moving correctly (as V0 is different) 2014-11-28 22:24:45 +11:00
Kirben
aca10de1b5 SCUMM: Add support for quit script in HE90+ games. 2014-08-20 09:26:39 +10:00
Johannes Schickel
3847465163 SCUMM: Make GPL headers consistent in themselves. 2014-02-18 02:39:38 +01:00
Torbjörn Andersson
ce79ff4f2e SCUMM: Change NUM_SCRIPT_LOCALS to NUM_SCRIPT_LOCAL
For consistency with NUM_SCRIPT_SLOT.
2013-05-01 07:47:56 +02:00
Torbjörn Andersson
f70087dc90 SCUMM: Fix out-of-bounds access in runScript() debug messages
I believe this fixes CID 1003954, 1003957, 1003958, 1003962 and
1003966.
2013-05-01 07:33:05 +02:00
Torbjörn Andersson
0638d85ada SCUMM: Cleanup
We only need to initialize 'args' in runInventoryScript() when we
are actually using them.
2013-04-30 22:46:36 +02:00
Torbjörn Andersson
2284aba719 SCUMM: Use correct array size when calling initializeLocals()
The initializeLocals() function assumes that it can copy 25
elements when being provided an array of values. But this array
was frequently a lot smaller than that. I've introduced a constant
for the number of locals (though VirtualMachineState has one more
for some reason), and fixed the array sizes in a number of places.

CID 1003951, 1003952, 1003953, 1003955, 1003956, 1003959, 1003960,
1003961, 1003963, 100394, 1003965
2013-04-30 22:26:51 +02:00
Torbjörn Andersson
69cdccd962 SCUMM: Handle double-clicks in Mac Loom (bug #3588164)
Unlike the EGA DOS version, it doesn't seem to be the scripts
that keep track of double-clicks. Instead, the engine sets a
variable to indicate them. Unlike the DOS version, we don't check
that the second click happens close enough on the screen to the
first one. We could, but it seemed needlessly complicated.
2012-12-15 00:35:00 +01:00
Travis Howell
dfa5405db8 SCUMM: Change the nest.number default to zero in stopScript and stopObjectScript too. 2012-05-31 19:01:07 +10:00
Travis Howell
de904c59c4 SCUMM: Fix global script 255 never been resumed by runScriptNested. Thanks to clone2727 for tracking down the problem in baseball2003. 2012-05-31 00:05:05 +10:00
Tobias Gunkel
9dd6105ce6 SCUMM: replace "c64" with "v0" when it applies to both C64 and AppleII v0 versions
In addition some routines (e.g. the gfx ones) that are even used in v1.
2012-02-11 08:30:08 +01:00
Tobias Gunkel
e14e4ab3b0 SCUMM: adjust to coding style-guide 2012-02-11 08:30:02 +01:00
Tobias Gunkel
434aaaf0c0 SCUMM: fix gcc compiler warnings 2012-02-11 08:30:00 +01:00
Tobias Gunkel
08e1e127e9 SCUMM: handle v0 distance check in checkPendingWalkAction() correctly 2012-02-11 08:29:43 +01:00
Robert Crossfield
f299fc295e SCUMM: Fix for V0 objects 2012-02-11 08:29:34 +01:00
Tobias Gunkel
e3f9a09d49 SCUMM: keep track of the number of nested script calls for a sentence
command in v0

If for instance an object necessary for the sentence command is not reachable or pickupable (try to use faucet (object 55) with jar with water in microwave (object 50), the pick-up script of the jar will tell the actor to pickup object 99 (jar not in microwave)) the actor will try to pick-up the jar infinitely.
This is fixed by counting the amount of nested scripts the sentence command has called (directly or indirectly) so far and aborts it if there have been too many.
2012-02-11 08:29:21 +01:00
Tobias Gunkel
fb68456541 SCUMM: complete handling of pending walkTo actions for sentence commands
in v0
2012-02-11 08:29:19 +01:00
Tobias Gunkel
1da715719c SCUMM: handle actor freeze in walkToActorOrObject() 2012-02-11 08:29:18 +01:00
Tobias Gunkel
2f1336cdf0 SCUMM: fix blank sentence line in v0 after cutscenes and remove unused parameter of resetSentence() 2012-02-11 08:29:03 +01:00
Tobias Gunkel
347035385e SCUMM: merge object v0 id and type into one object var 2012-02-11 08:28:49 +01:00
Tobias Gunkel
c138ef6709 SCUMM: merge _activeObjectNr/_activeObjectType and _cmdObjectNr/_cmdObjectType 2012-02-11 08:28:46 +01:00
Tobias Gunkel
f2309998ff SCUMM: fix debugger for v0 2012-02-11 08:28:44 +01:00
Tobias Gunkel
e89dd623ef SCUMM: pop stack in v0 if command's object1 and 2 are the same
Otherwise the command will never be removed and the stack overflows
2012-02-11 08:28:35 +01:00
Tobias Gunkel
8392d23e6b SCUMM: reset sentence line in v0 if sentence executed 2012-02-11 08:28:32 +01:00
Tobias Gunkel
b337823bab SCUMM: fix verb and script handling
- getVerbEntrypoint() should not handle walk-to differently (revert 0x0D handling back to original behavior)
- VAR_ACTIVE_ACTOR actually is VAR_ACTIVE_OBJECT2
- runSentenceScript(): "if (_cmdVerb == kVerbWalkTo)" must be "if (_cmdVerb != kVerbWalkTo)"
2012-02-11 08:28:26 +01:00
Tobias Gunkel
de0b5f7674 SCUMM: use command stack and SentenceTab in mm c64
- MM C64 uses command stack (SentenceTab, doSentence()) now
- _cmdObject... added for current SentenceTab. The _active... variables are only used to build a sentence in the inventory but never by a script.
-> many routines are not needed anymore and are removed
2012-02-11 08:28:22 +01:00
Tobias Gunkel
1c32000a00 SCUMM: start handling object type and id correctly in mm c64
- removed complicated and unnecessary _v0ObjectIndex, _v0ObjectInInventory, _v0ObjectFlag vars
- started to merge object id and type into one object value (type<<8|id)
- verb preposition ids do not dependent on language -> remove from VerbSettings

Note:
- objects with type=0 are foreground objects. They have a state, an owner and a bg overlay image.
- objects with type=1 are bg objects. They do not have a state or owner and are already contained in the bg image. The do not have an entry in objectState/OwnerTable
2012-02-11 08:28:14 +01:00
Torbjörn Andersson
28d5922cca SCUMM: Fix workaround for Dig spider lair sound glitch
The soundKludge() function assumes there are always 8 parameters
for Digital iMUSE script commands.
2012-01-14 09:25:52 +01:00
Torbjörn Andersson
209012a88e SCUMM: Work around script bug in The Dig
The sound of trickling water in the spider lair is started, but never
explicitly stopped, so it keeps going. (Possibly not forever. When I
tried it in DOSBox, it finally stopped when I got back to the Nexus.)
The same sound effect is used the underwater cavern, and in that case
the exit script does fade out the sound so this workaround emulates
that behaviour.
2012-01-08 20:11:22 +01:00
Max Horn
d020922846 SCUMM: Make REDUCE_MEMORY_USAGE slightly more effecive (saving ~1kb ram) 2011-05-17 15:50:11 +02:00
Max Horn
82343f6649 SCUMM: Remove some unused var warnings (see bug #3293800) 2011-05-14 23:50:43 +02:00
Max Horn
9ec64a66fe SCUMM: Turned ResTypeData into a Common::Array<Resource>, subsuming its _resource member 2011-05-13 14:48:01 +02:00
Max Horn
45207a52d4 SCUMM: Remove ResTypeData::_num 2011-05-13 14:12:00 +02:00
Max Horn
c02420df43 SCUMM: Add a Resource class, refactor res code around it 2011-05-13 11:47:13 +02:00
Max Horn
0342ab3f1b SCUMM: Rename ResTypeData::num to _num 2011-05-13 11:47:11 +02:00
Max Horn
75b9deb185 SCUMM: Get rid of the MemBlkHeader hack
This uncovered at least one potentially serious bug in the inventory
code, which still needs to be investigated and fixed.
2011-05-13 11:47:10 +02:00
Max Horn
45e65d7ea0 SCUMM: Refactor how resource (types) are srepresented
Previously, we had a couple of arrays of size N (where N = number of
resource types), one for each attribute of a resource type (such as as
the number of resources of that type.

Now, we have one array of size N, whose elements are a record
aggregating all the attributes of each resource type.
2011-05-13 11:47:08 +02:00
strangerke
69b1485a22 GIT: Clean up: Suppress SVN tags, now useless 2011-05-12 01:16:22 +02:00
Max Horn
0ce2ca4e00 COMMON: Replace MKID_BE by MKTAG
MKID_BE relied on unspecified behavior of the C++ compiler,
and as such was always a bit unsafe. The new MKTAG macro
is slightly less elegant, but does no longer depend on the
behavior of the compiler.
Inspired by FFmpeg, which has an almost identical macro.
2011-04-12 16:53:15 +02:00
Max Horn
55e65cee80 SCUMM: Cleanup 2011-04-05 15:18:08 +02:00
Max Horn
a12dada822 SCUMM: Fix off-by-one mistakes in out-of-bounds checks; name some constants 2011-04-05 15:18:08 +02:00
Max Horn
6eeebfb191 SCUMM: Check for cutSceneStackPointer underflows 2011-04-04 09:56:50 +02:00
Max Horn
a7248a0601 ENGINES: Replace many printfs by warning/debug/debugN
svn-id: r54031
2010-11-01 21:37:47 +00:00
Max Horn
6175c2bb19 SCUMM: Fix potential bug in ScummEngine::resStrLen.
In particular, it might happen that ScummEngine::resStrLen is called
while the _scriptPointer is stale. In that case, it would be working
with the stale pointer. If the code calling it then uses fetchScript*()
methods to read the string whose length was just computed, then it would
read potentially *different* data (e.g. copyScriptString or
loadPtrToResource could have been affected).

I am not sure if this actually could have caused bugs somewhere; it might
even be provable that a script relocation cannot happen in all places
that invoke resStrLen. But for now it's much easier to make the code
safe than to verify that theory ;).

Also simplified some related code.

svn-id: r53572
2010-10-18 18:55:24 +00:00
Max Horn
d69a63c145 SCUMM: Move common code from ScummEngine::fetchScript* to new method.
The new method is called refreshScriptPointer(). Also renamed
getScriptEntryPoint() to resetScriptPointer() in an attempt to highlight
both the similarity and difference between the two.

svn-id: r53571
2010-10-18 18:43:13 +00:00
Max Horn
5602b2cf81 SCUMM: Move setResult/getResultPos to script_v5.cpp
svn-id: r52129
2010-08-16 19:57:35 +00:00