94 Commits

Author SHA1 Message Date
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
Max Horn
b8ee574e40 SCUMM: _resultVarNumber and related methods are specific to v0-v5
svn-id: r51974
2010-08-11 12:49:16 +00:00
Travis Howell
0702bdab82 Fix regressions in Let's Explore the Jungle with Buzzy.
svn-id: r47622
2010-01-28 00:28:08 +00:00
Travis Howell
4350f7b8c0 Fix objects structure and object scripts in PCE version of Loom.
svn-id: r45335
2009-10-22 11:33:05 +00:00
Max Horn
d91d68a9ca SCUMM: Fix verb/sentence handling in Indy3 mac (there, a double click must be used to trigger a verb/sentence)
svn-id: r42907
2009-07-29 20:35:50 +00:00
Max Horn
2205541e86 SCUMM: Enable looping in Indy3Mac sound effects
svn-id: r42898
2009-07-29 18:35:34 +00:00
Max Horn
fcdd3b0310 SCUMM: Rewrote ScummEngine::inventoryScriptIndy3Mac for clarity
svn-id: r42889
2009-07-29 11:48:20 +00:00
Travis Howell
c02ad3b7bf Add patch #2821100 - MM C64 Objects / Verb fixes, with minor clean up applied.
svn-id: r42737
2009-07-25 06:27:41 +00:00
Travis Howell
9c06549d31 Hack is no longer required, due to revision 42498.
svn-id: r42499
2009-07-15 05:00:59 +00:00
Johannes Schickel
59aa80b2d2 Fix mismatching format arguments.
svn-id: r42105
2009-07-04 18:54:27 +00:00
Max Horn
99df028d35 SCUMM: Got rid of o6_invalid
svn-id: r39957
2009-04-16 09:27:02 +00:00