Commit Graph
513 Commits
Author SHA1 Message Date
sluicebox 30fad94e9a SCI: Track correct location and size of temp variables
The VM has been treating the entire area between the frame pointer and
the stack pointer as temp variables for the current function. There are
two problems with this:

1. The VM hasn't been updating the frame pointer correctly when multiple
   methods are called within the same send/self/super instruction.
2. The VM has been recalculating the number of temp variables on every
   instruction as the difference between the two pointers.
   This is incorrect, as this changes with almost every instruction in
   ways have nothing to do with the number of temp variables allocated
   by the link instruction. Meanwhile, the VM has not been recording
   the number of variables allocated by the link instruction.

The first discrepancy caused scripts to behave differently than in SSCI
when reading parameters out of bounds in certain situations.
It also prevented our uninitialized variable detection from detecting
certain reads. The second made the temp-count used for out of bounds
detection too large, made debugger output such as `stack` incorrect,
and made stepping through the link instruction in the debugger appear
to do nothing until stepping through the following instruction.

When multiple methods are called by a send/self/super instruction, each
method's link instruction increases the stack pointer further.
Method B's variables appear after method A's. The VM has been setting
the stack pointer correctly but it kept using the previous frame
pointer, so method B would re-use method A's stack area instead of the
area the VM had just allocated for B. If a script correctly initializes
variables before using them and doesn't use out of bounds parameters or
temp variables then this discrepancy doesn't make a difference.
But a lot of scripts do these bad things and accidentally rely on the
undefined values they read.

Now we update the frame pointer correctly when "carrying over" to
subsequent method calls from the same send/self/super instruction.
This matches SSCI behavior. We also now record the number of temp
variables that have been allocated by the link instruction and use
that instead of incorrectly recalculating on every instruction.

Fixes the KQ6 black widow lockup, and other KQ6 music bugs, where
scripts call Sound:fade without the required fourth parameter.
Sound:fade expects a fourth parameter, so reads it out of bounds,
and passes it as the stop-after-completion boolean to kDoSoundFade.
Scripts that called Sound:fade as the only method in a send got the same
results as in SSCI, but scripts that called Sound:play first didn't.

Fixes bugs #5625 #5653 #6120 #6210 #6252 #13944
2022-11-30 23:13:00 +02:00
Le Philousophe f54bdf989a SCI: Don't use unsafe sprintf and vsprintf 2022-10-23 22:46:19 +02:00
sluicebox 12576e29fb SCI: Add name filtering to functions debug command 2022-08-19 07:12:27 -04:00
sluicebox 9be84837b3 SCI: Add speed_throttle debug command
Allows testing the speed throttler for possible improvements
and to demonstrate what it affects and what it doesn't.

`speed_throttle 0` disables kGameIsRestarting throttling.
(Except for game-specific workarounds.)

This command is possible due to several recent cleanups of other
throttling mechanisms that overlapped and were absorbed by this one.
2022-08-12 00:33:20 -04:00
sluicebox 55c719aea9 SCI: Handle alternate bit orders in game flag debug commands
Five games store flags in a different bit order than the rest
2022-07-30 16:39:24 -04:00
sluicebox 82a16d71a9 SCI: Add debugging commands for Game Flags 2022-05-22 11:20:41 +03:00
sluicebox 3e1ecd2ea4 SCI: Remove "Dummy" from kernel functions debug command
There a lot of these entries due to our custom functions
2022-04-08 22:42:04 -04:00
D G Turner 006c4fe8f4 SCI: Fix Redundant Declaration
This causes GCC Compiler Warnings when -Wredundant-decls is enabled.
2022-03-06 13:56:15 +00:00
Eugene Sandulenko abea37c9bb ALL: Update ScummVM project license to GPLv3+ 2021-12-26 18:48:43 +01:00
Orgad Shaneh 940c7bfc14 SCI: Use nullptr
Using clang-tidy modernize-use-nullptr
2021-11-14 15:51:59 +02:00
Ralph Caraveo III 686c8dcaad SCI: Update help documentation for the new stack alias named: "st"
Nit: I forgot to also update the help context for this new alias.
2021-11-07 20:17:42 -06:00
Ralph Caraveo III 214e0a9979 SCI: add "st" as an alias to the debug "stack" command
While constantly evaluating the stack when debugging please consider:
  * adding a "st" alias to the "stack" command which also nicely represents the stack based addresses such as: `ST:0000`.
  * I introduced a previous alias for evaluating registers with the addition to "reg" so I'm hoping this is reasonable.
2021-11-06 17:55:51 +02:00
Alexandre Detiste 6044504762 JANITORIAL: typos
some in the variable names, some in the comments;
no change for the strings that interract with original games assets
2021-10-31 20:46:31 +01:00
sluicebox 98acee333a SCI: Fix class_table debugging command output 2021-10-22 12:53:48 -05:00
Ralph Caraveo III a272a6b578 SCI: Clarify passing of parameter: pass instead of parse for class_table debug command.
Minor wording change to say pass instead of parse.
2021-10-22 12:51:19 -05:00
Orgad Shaneh a05e54f00c JANITORIAL: Remove trailing whitespaces 2021-05-04 11:46:30 +03:00
Filippos Karapetis 2c4b4c6cd5 SCI: Add missing class member initializers 2021-02-08 03:11:46 +02:00
sluicebox 51137b8864 SCI: Improve "opcodes" debug command output
Fixes third column not appearing on default GUI console size
2021-02-07 16:31:46 -08:00
sluicebox dac6babb81 SCI: Remove non-existent debug command from Help 2021-02-07 16:31:46 -08:00
sluicebox b205bc0e8a SCI: Add missing newlines to console output 2020-12-20 12:09:06 -08:00
Ralph Caraveo III b0dc2ad01d SCI: add a shortcut alias for the registers debug console command
When debugging, I'm constantly inspecting the SCI VM registers and thought this would be a great command to have an alias for.
I am proposing the following alias: `reg` for the command `registers` and also updated the help docs.
2020-12-16 19:29:31 +02:00
Filippos Karapetis bd7e708fc3 SCI: Move resource related functionality into a separate folder 2020-11-29 14:34:55 +02:00
Henrik "Henke37" Andersson d26655dc4d SCI: Debugger, call base preEnter & postEnter 2020-05-10 23:39:31 +02:00
sluicebox 267317f650 SCI: Add script_said debug command to help text, regroup
Add another missing command to debug help text, remove a duplicate,
fix a typo, update the grouping to match internal organization.
2020-05-07 21:15:08 -07:00
Ralph Caraveo III c17e82c1aa SCI: added missing but implemented help commands for scripts
These commands have already been implemented by a previous committer.
This commit simply adds the commands to the console debug `help` command for the SCI engine.
2020-05-08 04:31:49 +01:00
sluicebox 23fc7f52e0 SCI: Fix SoundResource error handling, ctor, dtor
Fixes several problems with the SoundResource class:

- Constructor doesn't fully initialize object if resource doesn't exist
- Destructor crashes if object not fully initialized
- Constructor has no mechanism to report failure
- Callers believe failure is reported by constructor returning null
- SoundCommandParser::initSoundResource attempts to pre-detect failure
  insufficiently in the absence of a formal mechanism.

SoundResource now always fully initializes, the destructor no longer
accesses uninitialized memory, and an exists() method has been added
which callers now test.

SQ6 Mac can now progress past the main menu.
2020-04-12 01:47:15 -07:00
Zvika Haramaty f2345cc372 SCI: debugger: disasm_addr - fixed 'bcc' parameter 2020-03-04 02:53:14 +02:00
Paul Gilbert ba147f5ad5 SCI: Refactor to use Engine debugger 2020-02-16 13:07:19 +02:00
Zvika Haramaty ac87c01895 SCI: debugger: disasm - added 'bcc' parameter, to use in C code
'bcc' is based on 'bc', but prints in format that's can be used in
C code for patches - just copy and paste (without the address column).
2020-02-13 23:42:06 +02:00
D G Turner d11c61db14 SCI: Fix Missing Default Switch Cases
These are flagged by GCC if -Wswitch-default is enabled.
2019-12-01 05:06:31 +00:00
Filippos Karapetis 9da3d22703 SCI: Fix MSVC warnings
- Remove unused parameters
- Initialize potentially uninitialized variables
- Use Common::String instead of a fixed buffer
- Remove redundant parentheses
- Change float suffix to be uppercase
- Fix spacing
- Fix integer left shifts with boolean variables
- Fix potential division by zero
- Fix missing breaks
2019-05-27 14:53:41 +03:00
Vhati 75daa49d11 SCI: Fix inconsistent debugger breakpoint messages
Fixes bp_function and bp_address not printing the created breakpoint, as
happens with the other bp_ commands.
2019-02-03 10:51:10 +02:00
Vhati ff45b1da20 SCI: Fix debugger bp_action help message
Fixes the help for bp_action: 'none' arg should be 'ignore'
2019-01-17 14:03:49 +02:00
Lars Skovlund ff7e490593 SCI32: Display plane id base in version console command 2018-12-28 11:55:32 +02:00
D G Turner 9173223999 SCI: Fix Segfault When Using Console "show_map" Command on SCI32 games.
The _gfxScreen instance is nullptr for SCI32 games, thus this console
command previously caused a segfault.
2018-10-18 22:25:21 +01: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
Willem Jan Palenstijn 2e74fd8f22 SCI: Avoid (false positive) uninitialized use warning 2018-02-01 20:19:27 +01:00
Colin Snover 57db3f7535 SCI: Partially clean up SCI16 video playback code 2017-12-01 18:48:35 -06:00
Colin Snover 432fd522d2 ENGINES: Remove default1x scaler flag
This flag is removed for a few reasons:

* Engines universally set this flag to true for widths > 320,
  which made it redundant everywhere;
* This flag functioned primarily as a "force 1x scaler" flag,
  since its behaviour was almost completely undocumented and users
  would need to figure out that they'd need an explicit non-default
  scaler set to get a scaler to operate at widths > 320;
* (Most importantly) engines should not be in the business of
  deciding how the backend may choose to render its virtual screen.
  The choice of rendering behaviour belongs to the user, and the
  backend, in that order.

A nearby future commit restores the default1x scaler behaviour in
the SDL backend code for the moment, but in the future it is my
hope that there will be a better configuration UI to allow users
to specify how they want scaling to work for high resolutions.
2017-10-07 12:30:29 -05:00
Colin Snover 60bdb7936f SCI: Fix disassembly of 32-bit addresses 2017-10-04 00:27:18 -05:00
Colin Snover 2203386ce6 SCI32: Fix audio dumper decompressed size calculation for 16-bit audio 2017-10-03 18:56:35 -05:00
Colin Snover 682b8790fd SCI: Allow multi-step tracing with step-over in debugger 2017-09-19 19:54:30 -05:00
Colin Snover 836f1bdf44 SCI32: Add audio dump debugger command 2017-09-19 19:54:29 -05:00
Colin Snover 29b338fff7 SCI: Add resource integrity dump command to debugger 2017-09-08 16:02:32 -05:00
Colin Snover 109d870990 SCI: Remove already-finished TODO 2017-09-04 15:19:59 -05:00
Colin Snover 67fcb0bdaf SCI: Allow deep inspection of objects in debugger 2017-09-04 15:19:59 -05:00
Colin Snover 8bab5a3467 SCI: Resolve offset names when disassembling object methods 2017-07-23 10:35:13 -05:00
Colin Snover f6dd8ad290 SCI: Fix audio_list debug command engine version info 2017-07-07 13:25:02 -05:00
Willem Jan Palenstijn c7d631cb66 SCI: Expand kernel breakpoint pattern matching for negative matches
See matchKernelBreakpointPattern() for samples. The main envisioned use is

DoSound*,!DoSoundUpdateCues

to match all DoSound sub-functions except DoSoundUpdateCues.
2017-06-10 21:32:35 +02:00
Willem Jan Palenstijn e7b6a257b9 SCI: Change 'none' breakpoint action to 'ignore' for consistency 2017-06-10 21:32:35 +02:00