aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/engine/vm.cpp
AgeCommit message (Collapse)Author
2018-08-25SCI32: Remove reg32_t and use reg_t in all casesFilippos Karapetis
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-23SCI32: Add workarounds for OOB reads for parametersFilippos Karapetis
These are mostly used to silence known cases, for now. Some workarounds of this type have already been addded
2017-09-28SCI: Remove resolved TODOColin Snover
2017-09-19SCI32: Put superclass address in r_acc for SCI3 super callsColin Snover
This fixes a problem in Lighthouse 2.0a where the mini-sub would fail to start playing the animation of the shipwreck when clicking on the throttle. In SSCI, in SCI3 only, r_acc was (inadvertently?) set to the superclass object ID whenever a super call was made. This happened because OP_super would call to get the superclass object ID, the calling conventions of the compiler put this return value into EAX, and then the PMachine message processing code put whatever was in EAX into r_acc before each message was processed. In the game code, there are a sequence of steps that look like this: * First, throttle::doVerb is called when throttle is clicked on; * Which calls getRobot::doit to tell the shipwreck robot to start playing; * Which calls wreckBot::init to reset the Robot for the animation; * Which calls Hiliter::hotVerbs(0) to remove cursor hotspots; * Which calls Hiliter::dispose to clean up since it is not used; * Which causes Hiliter::verbList to get set to 0. * Later, verbList is loaded into r_acc, and it is still 0; * Then, Hiliter::dispose makes a super call to Obj::dispose; * Then, Obj::dispose does nothing except call kDisposeClone, which does not mutate r_acc, so r_acc is still 0 from verbList; * Then we return back through 5 calls to throttle::doVerb; * Then throttle::doVerb checks that r_acc is non-zero, and if so, adds wreckBot to theDoits global, allowing the animation to occur. In ScummVM, without setting r_acc in the super call, the non-zero check failed and the wreckBot didn't get put into theDoits, so the entire sequence fell apart. In SSCI, the non-zero check happened to succeed because the Obj::dispose super call put the Obj class into the accumulator. So now we do that too, and now Lighthouse 2.0a works here. Earlier versions of SSCI used EAX for other things in between the OP_super call and the message processing, so would set r_acc from different data, so this change does not apply to those versions.
2017-06-10SCI: Move bpk/logkernel to main breakpoint infrastructureWillem Jan Palenstijn
This changes the syntax for bpk and logkernel: Enable breakpoint on kernel call: bpk FrameOut Enable logging for kernel call: bpk FrameOut log For backward compatibility this has an alias: logkernel FrameOut Removing a kernel call breakpoint is done with bp_del/bc now.
2017-06-10SCI: Handle selector read/write breakpoints from opcodesWillem Jan Palenstijn
2017-06-10SCI: Move scriptdebug declarations to separate headerWillem Jan Palenstijn
2017-06-09SCI: Remove some unused #includesColin Snover
2017-05-20SCI: Refactor relocation codeColin Snover
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-04-23SCI32: Exclude SCI3 code from compilation when SCI32 is disabledColin Snover
2017-04-23SCI32: Fix mustSetViewVisible for SCI3Colin Snover
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-22SCI: Improve message when crashing due to a bad selectorColin Snover
2017-04-21SCI: Improve audio volume & settings sync codeColin Snover
This patch includes enhancements to the ScummVM integration with SCI engine, with particular focus on SCI32 support. 1. Fixes audio volumes syncing erroneously to ScummVM in games that modify the audio volume without user action (e.g. SCI1.1 talkies that reduce music volume during speech playback). Now, volumes will only be synchronised when the user interacts with the game's audio settings. This mechanism works by looking for a known volume control object in the stack, and only syncing when the control object is present. (Ports and planes were researched and found unreliable.) 2. Fixes audio syncing in SCI32 games that do not set game volumes through kDoSoundMasterVolume/kDoAudioVolume, like GK1, GK2, Phant1, and Torin. 3. Fixes speech/subtitles syncing in SCI32 games that do not use global 90, like LSL6hires. 4. Fixes in-game volume controls in SCI32 games reflecting outdated audio volumes when a change is made during the game from the ScummVM launcher. 5. Fixes SCI32 games that would restore volumes from save games or reset volumes on startup, which caused game volumes to be out-of-sync with ScummVM when started. 6. ScummVM integration code for audio sync has been abstracted into a new GuestAdditions class. This keeps the ScummVM- specific code all in one place, with only small hooks into the engine code. ScummVM integrated save/load code should probably also go here in the future. Fixes Trac#9700.
2017-03-30SCI: Add clarifying comment to op_restColin Snover
2017-03-30SCI: Give kernel calls a valid stack pointerColin Snover
Some kernel calls need to be able to call back into game script code, which requires a valid stack pointer for use with invokeSelector. An example of this is the guest additions code that syncs audio volumes from ScummVM: it needs to be able to call into the game scripts responsible for managing the in-game audio volume UI.
2017-03-30SCI: Replace magic numbers in reg_t handling with symbolsColin Snover
2017-01-09SCI32: Clean up SCI3-only opcodesColin Snover
SCI3 includes four new opcodes: * op_info[0x26][0] puts -info- flag in accumulator * op_infoSP[0x26][1] pushes -info- flag to stack * op_superP[0x27][0] puts -super- reference in accumulator * op_superPSP[0x27][1] pushes -super- reference to stack The implementation of these opcodes was correct already, but the opcode names given were a bit misleading (the value is not always stored to accumulator), and magic numbers were used for these opcodes in places. A review of the opcode table in Phant2 indicates that there are no other new opcodes for SCI3.
2016-12-03SCI: Remove unnecessary duplicate shadowing variableColin Snover
2016-12-03SCI32: Fix LSL6hires text speed sliderColin Snover
For whatever reason, this game uses a different global for specifying the text speed.
2016-11-20SCI: Improve disassembly outputColin Snover
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-20SCI: Add code-address breakpoints to debuggerColin Snover
2016-11-19SCI: Warn more loudly about uninitialised parameter readsColin Snover
Silently returning zero values can cause games to break. e.g. Shivers 1 room 35170 has a script bug where vJoystick::handleEvent makes a super call which causes doVerb to be called a second time with no arguments. In the original game this happened to work because the value already on the stack happened to be 1. In ScummVM this silently (unless VM debug messages were enabled) failed because the uninitialised read value was forced to 0.
2016-11-19SCI32: Add missing updateInfoFlagViewVisible callWillem Jan Palenstijn
I missed the one for varselector sends handled by the secondary loop in op_ret. This fixes #9641.
2016-10-14SCI: Ensure export breakpoints always trigger on export callsColin Snover
Previously, export calls to non-existing functions would act like there was never an export call, and the breakpoint would never be triggered.
2016-09-30SCI32: Sync subtitle text speed with ScummVM GUIColin Snover
2016-09-29SCI: Deduplicate call origin formattingColin Snover
2016-09-29SCI: Add prefix to global variable constantsColin Snover
2016-09-29SCI: Replace magic numbers for globals with named constantsColin Snover
2016-09-29SCI: Generalize code for getting information on the current callColin Snover
2016-08-12SCI32: Implement kShowMovieColin Snover
2016-08-11SCI32: Temporarily revert kShowMovie due to buildbot failuresColin Snover
Revert "SCI32: Fix KQ7 1.51 video background" This reverts commit c8affb54cca259f37522216bad739be085bf9caa. Revert "SCI32: Fix crash when kShowMovie is called but the video cannot be found" This reverts commit 93b06f4a9e08de281ee7eb9c780ceac147c3fb23. Revert "SCI32: Fix KQ7 1.51 basic video playback" This reverts commit cdab24aa07c18ad4a25a1659f7fca15cca5e358e. Revert "SCI32: Additional Video32 documentation" This reverts commit 4ff0924e57a9bc9101ee0799a967fe3373dd2574. Revert "SCI32: Implement kShowMovie" This reverts commit 13297c19298c5ad73c9e996c5c31ca91de124911.
2016-08-11SCI32: Implement kShowMovieColin Snover
2016-07-02SCI: Remove unexpected side effect from ExecStack constructorWillem Jan Palenstijn
The ExecStack constructor set argp[0] to argc before. This is now moved to the caller, to make this action more explicit.
2016-07-02SCI: Remove unclear &rest handlingWillem Jan Palenstijn
Modifying a value above the stack pointer doesn't seem to make much sense. This was added in FreeSCI back in 2002 in a pair of commits that did not make clear what the purpose of this was. My guess is that it attempted to adjust argc, but failed. This wouldn't have been noticed since argc was always set correctly by make_exec_stack_entry (which is now the ExecStack constructor).
2016-07-02SCI: Improve kernel subfunction loggingWillem Jan Palenstijn
ExecStack now stores the kernel call number as well as the subfunction. This allows kStub and backtraces to log the actual subfunction called. The kernel call number in ExecStack used to be stored in the debugSelector field. It now has its own field, to avoid confusion.
2016-03-01SCI32: Fix index/offset mixup in updateInfoFlagViewVisibleWillem Jan Palenstijn
2016-02-27SCI32: Update InfoFlagViewVisible from send_selectorWillem Jan Palenstijn
2016-02-27SCI32: Update InfoFlagViewVisible in VM opcodesWillem Jan Palenstijn
2016-02-05SCI: Clean up the op_infoToa and op_superToa SCI3 opcodesFilippos Karapetis
2015-03-20SCI: improve debug output for signature mismatchMartin Kiewitz
dump parameter list to debugger as well
2014-02-18SCI: Make GPL headers consistent in themselves.Johannes Schickel
2013-10-31SCI: Update ScummVM's game audio options for SCI1.1 CD gamesFilippos Karapetis
This ensures that ScummVM's game audio options for speech and subtitles get updated when they are changed in the game GUI
2012-09-26JANITORIAL: Remove trailing whitespaces.Johannes Schickel
Powered by: git ls-files "*.cpp" "*.h" "*.m" "*.mm" | xargs sed -i -e 's/[ \t]*$//'
2012-07-26SCI: Add some debug code to op_lineFilippos Karapetis
2012-06-23SCI: Change the program counter (PC) to be a 32-bit variableFilippos Karapetis
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-23SCI: Clean up validateExportFunc() and related functionsFilippos Karapetis
Also renamed some SCI3 related code to indicate when it's SCI3 specific
2012-06-18SCI: Add setter/getter methods to reg_t'sFilippos Karapetis
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-15SCI: Change getClassAddress() to only require the caller segmentFilippos Karapetis
The caller offset is never actually used inside the function
2012-01-15SCI: Ignore an invalid export in a script in the demo of RAMAFilippos Karapetis
2011-11-29SCI: Fix restarting SCI engine with different SCI versionWillem Jan Palenstijn