Commit graph

242 commits

Author SHA1 Message Date
Colin Snover
8d32353394 SCI32: Stop throttling of kFrameOut during interactive VMD playback
Refs Trac#9974, Trac#9975.
2017-07-23 10:35:13 -05:00
Willem Jan Palenstijn
820caf370e SCI32: Fix kObjectIntersect
It was using SCI16 calls to get the NowSeenRects.

This fixes #9855.
2017-07-09 22:56:04 +02:00
Colin Snover
7057f232d7 SCI32: Improve kPlayVMD rendering
1. Added a new game option for linear interpolation when scaling
   overlay-mode video in ScummVM builds with USE_RGB_COLOR;
2. Implemented SCI2.1-variant of the VMD player renderer (fixes
   Trac#9857), which bypasses the engine's normal rendering
   pipeline;
3. Improved accuracy of the SCI3-variant of the VMD player by
   writing HunkPalettes into the VMD's CelObjMem instead of
   submitting palettes directly to GfxPalette32.
2017-07-06 19:12:38 -05:00
Colin Snover
35346bc71b SCI32: Update mouse position for rendering in all frameOuts 2017-07-06 19:12:37 -05:00
Colin Snover
9f910535c9 SCI32: Centralise OSystem screen updates 2017-07-06 19:12:35 -05:00
Colin Snover
832cd25ef1 SCI32: Avoid out-of-bounds read of pixel data in kIsOnMe
Fixes Trac#9761, Trac#9844, Trac#9850, Trac#9851.
2017-06-17 14:35:42 -05:00
Colin Snover
8b49313af3 SCI32: Fix terrible rendering performance when vsync is enabled
More than one call to OSystem::updateScreen per frame on systems
with vsync ruins performance because the call is blocked until
the next vsync interval.

This also fixes bad rendering performance with the OpenGL backend.
2017-05-06 10:38:58 -05:00
Colin Snover
91df45c6c5 SCI32: Fix missing/incorrect game features detection 2017-05-06 10:38:58 -05:00
Colin Snover
8d94a04605 SCI32: Disable game script video benchmarking
The approach to video benchmarking used by SCI engine does not
translate very well to modern video devices -- it will either be
so slow that the games think the system is not capable of showing
normal visual effects, or so fast that the benchmarks overflow
their counters. So, game scripts that perform video benchmarking
are now patched to unconditionally return the highest speed value.

A pleasant but subtle side-effect of this change is that the extra
time sitting at a blank screen before the start of a game (while
benchmarks ran) is now gone.

Fixes Trac#9741.
2017-05-04 23:00:53 -05:00
Colin Snover
5dd9618842 SCI32: Remove unnecessary GfxFrameout::_frameNowVisible
This flag was used in SSCI to read from VRAM instead of from the
back buffer when a mouse interrupt was received in the middle of
a back buffer update. Since ScummVM controls when mouse events
are received via polling, it is not possible to receive a mouse
event in the middle of back buffer updates, so this code is
unnecessary for the engine to work properly.

This also fixes Valgrind warnings about use of uninitialized
memory at the start of the game, caused by not filling the cursor
memory buffers because `_frameNowVisible` was false until the first
frame was rendered.
2017-04-29 14:31:01 -05:00
Colin Snover
ec12c5a342 SCI: Move ScummVM save/restore to GuestAdditions and reimplement for SCI32 2017-04-22 13:01:16 -05:00
Colin Snover
739047f887 SCI32: Always reinit GfxText32 statics on game startup
Fixes bad scaling of text when switching between games with
different script resolutions.
2017-03-30 19:46:27 -05:00
Colin Snover
dd13fdfe17 SCI32: "Fix" renderer for PQ4CD
PQ4CD and several other games contain a hack in two renderer
methods to avoid rendering invalid screen items with zero or
negative-dimension target rects. This prevents PQ4CD from
crashing during the fifth phase of target practice.
2017-01-12 13:14:10 -06:00
Colin Snover
7156a82a64 SCI32: Improve mouse responsiveness
This is most noticeable at the beginning of the game during
benchmarking, where the benchmarking loop used to cause the mouse
to get stuck for the duration of the benchmark.
2017-01-11 11:01:38 -06:00
Colin Snover
126378fa26 SCI32: Fix bad coordinates in PQ:SWAT demo 2017-01-09 19:34:54 -06:00
Colin Snover
b818e54027 SCI32: Fix crashes and bad cel positioning in GK2 demo 2017-01-09 19:34:54 -06:00
Colin Snover
4cff1e400f SCI32: Add support for alternate graphics selectors
Used by at least Phantasmagoria 2.
2016-12-19 14:46:59 -06:00
Colin Snover
724385eb5e SCI32: Fix slow SCI2.1mid transitions
SSCI transitions code sends a large number of small show rects
to the graphics manager, one at a time, for each division of a
transition. Each time a rect is submitted, a call to showBits
is made. This design was used when transitions for SCI32 were
first implemented in ScummVM, and it worked OK because the
hardware surface was updated by EventManager::getSciEvent,
not showBits, so the large number of calls to showBits from the
transitions code did not adversely affect engine performance.

Later in SCI32 engine development, hardware surface updates
were changed to occur in showBits so that the hardware surface
would be updated at frame-out time, instead of at input-in time.
This change meant that now the large number of calls to showBits
from transitions became very expensive, and the engine would
stall constantly refreshing the entire hardware surface.

To fix this problem, the transitions code now (1) maximises the
size of rects coming from transitions, when possible, and (2) only
calls showBits when all the rects from one frame of a transition
have been calculated and added to the show rects list.

Additionally, there were some arithmetic errors in the
implementation of pixel dissolve that have been corrected in this
changeset.

Fixes Trac#9614.
2016-10-22 13:18:38 -05:00
Colin Snover
4b6b328bbb SCI32: Check for existence of visiblePlane before dereferencing
CID 1351620.
2016-10-10 19:35:28 -05:00
Colin Snover
40444b0aeb SCI32: Clarify some identifiers
transparentColor -> skipColor
displace -> origin
scaledWidth -> xResolution
scaledHeight -> yResolution
2016-10-09 11:21:46 -05:00
Colin Snover
6290f1e5fc SCI: Add prefix to global variable constants 2016-09-29 19:39:16 -05:00
Colin Snover
b5d0fffb8b SCI: Replace magic numbers for globals with named constants 2016-09-29 19:39:16 -05:00
Colin Snover
658fb7f8e4 SCI32: Improved game resolution detection 2016-09-29 19:39:16 -05:00
Colin Snover
d0517f515e SCI32: Update screen on frameout, instead of in the event loop 2016-09-29 19:39:16 -05:00
Colin Snover
da62a99a00 SCI32: Remove unused ResourceManager from GfxFrameout 2016-08-19 15:23:10 -05:00
Colin Snover
4e1a9be816 SCI32: Remove CoordAdjuster32, at least for the moment
This may come back in the future to deduplicate some gfx code,
but SCI32 had two different inlined ways of doing coordinate
conversions with different rounding methods, so CoordAdjuster32
didn't get used when the graphics system was rewritten.

At the moment, SCI32 code uses the mulru/mulinc methods from
helper.h for scaling up/down coordinates.
2016-08-19 15:23:10 -05:00
Colin Snover
0f2748b15a SCI32: Implement kRobot 2016-08-19 14:08:22 -05:00
Colin Snover
6e2e862d8e SCI32: Implement kShakeScreen for SCI32 2016-08-19 13:57:40 -05:00
Colin Snover
89a82f5b55 SCI32: Fix signature of kSetNowSeen 2016-08-19 13:57:40 -05:00
Colin Snover
c8a2b9af22 SCI32: Fix comment 2016-08-19 13:57:40 -05:00
Colin Snover
80d9182554 SCI32: Implement SCI32 cursor support 2016-08-19 13:57:40 -05:00
Colin Snover
9bfeb3c297 SCI32: Remove GfxScreen from GfxFrameout
Only cursor remains to be updated to go through GfxFrameout, and
then we can let GfxScreen go back to being SCI16-only.
2016-08-19 13:57:40 -05:00
Colin Snover
c28a5733e0 SCI32: Fix GfxFrameout::_isHiRes flag to be accurate for all games 2016-08-11 20:50:33 -05:00
Colin Snover
4e31c9aaf4 SCI32: Don't crash on zero-dimension show rects
In the original engine this would have simply resulted in no draw,
but ScummVM is more strict about it. It is not 100% clear whether
these are normal and should be allowed or not, so for the moment
we'll emit a warning whenever a zero-dimension show rect is seen.

For now they only seem to be generated by plane transitions, and
these zero-dimension screen items cannot simply be omitted because
the 2.1early transitions code requires a fixed number of screen
items per step.
2016-08-01 10:37:14 -05:00
Colin Snover
0f535e79f5 SCI32: Add 6-argument signature of kAddPicAt
This is used by Torin in room 50900.
2016-08-01 10:37:14 -05:00
Colin Snover
156c68fe58 SCI32: Implement plane transitions (kSetShowStyle and kSetScroll)
This commit implements all of the known plane transitions from
SCI2 through SCI2.1mid games. Because kSetShowStyle is always
called indirectly via the Styler game script, it is difficult to
find all the places where transitions are used. As such,
transitions that appeared to never be used have been added as
stubs which will trigger a game crash with a message to report
what was being done, so any missed transition types can be
identified quickly and then implemented.
2016-08-01 10:37:14 -05:00
Colin Snover
20106fff7b SCI32: Fix backwards kFrameOut throttle timings 2016-07-27 08:49:38 -05:00
Colin Snover
65ca749f0a SCI32: Improve behaviour of screen transitions
1. Use the same throttling speed as normal frameouts. The
   old throttling speed seemed a bit too slow.
2. Exit the event loop immediately if the engine is supposed to
   quit, instead of forcing the user to wait until the transition
   has finished before quitting.
2016-07-24 11:36:48 -05:00
Colin Snover
efc12ffc5c SCI32: Avoid flash of incorrect colour when palettes are changed
Avoid forcing the screen to refresh after a palette change if the
screen is also about to be drawn to, as the palette change + draw
is intended to be an atomic operation.
2016-07-12 14:41:17 -05:00
Colin Snover
593560e876 SCI32: Add detection for Hoyle 5 demo 2016-07-11 13:02:27 -05:00
Colin Snover
4d91b458e5 SCI32: Implement kPlayVMD 2016-07-10 09:35:24 -05:00
Colin Snover
57a53420c3 SCI32: Expose graphics throttling code
Controls that manage their own event loops and call frameOut
directly generally need to sleep in order to avoid 100% CPU,
just like the main VM event loop.
2016-07-02 22:29:28 -05:00
Colin Snover
a4c059b864 SCI32: Improve accuracy of frameout throttler 2016-07-02 22:28:47 -05:00
Colin Snover
948e448738 SCI32: Fix signed comparison warnings 2016-07-01 15:58:43 -05:00
Colin Snover
4ee1901706 SCI32: Add transparent pic plane type
It is not clear if this is ever actually used by game scripts,
though.
2016-06-30 14:04:57 -05:00
Colin Snover
e89bdf536d SCI32: Clean-up pass on rendering pipeline
This pass exposed two bugs, which have been fixed:

1. Checks of `_updated` and `_moved` were reversed in some areas,
   which lead to rendering bugs. In SQ6 the rendering bugs were
   subtle or non-existant, but in e.g. PQ:SWAT the Sierra logo and
   title screen animations were totally missing.

2. The renderer formerly kept reading from ScreenItemLists when
   new items were added in decrementScreenItemArrayCounts, but
   this was determined to be unnecessary.
2016-06-30 14:04:57 -05:00
Colin Snover
a785147d6c SCI32: Document & clean up extra rect argument for frameOut
This extra rect seems to probably only ever be used by VMD
playback in some SCI2.1 games.
2016-06-30 14:04:57 -05:00
Colin Snover
1632bd50c8 SCI32: Fix benchmarking for QFG4 2016-06-26 12:44:36 -05:00
Colin Snover
26e7d3d9e9 SCI32: Remove no-longer-relevant comment 2016-06-26 12:44:35 -05:00
Colin Snover
cfda8b9ecd SCI32: Fix broken Remap implementation
Remap would crash SCI2.1early games with 19 remap slots, and
did not actually work in most cases in SCI2.1mid+ games.

The SCI16 implementation was moved to its own separate file but
was otherwise touched as little as possible, so may still have
similar problems to the SCI32 code.

1. Split SCI16 and SCI32 code into separate files
2. Use -32 prefixes for SCI32 code and no prefix for SCI16 code,
   where possible, to match other existing code
3. Avoid accidental corruption of values from the VM that may be
   valid when signed or larger than 8 bits
4. Added documentation
5. Add missing remap CelObj calls
6. Inline where possible in performance-critical code paths
7. Fix bad `matchColor` function, and move it from GfxPalette to
   GfxRemap32 since it is only used by GfxRemap32
8. Fix bad capitalisation in getCycleMap
9. Remove unnecessary initialisation of SingleRemaps
10. Update architecture to more closely mirror how SSCI worked
11. Clarify the purpose of each type of remap type (and
    associated variable names)
12. Split large `apply` function into smaller units
13. Fix buffer overrun when loading a SCI2.1early game with remap
14. Remove use of `#define` constants
15. Warn instead of crashing with an error on invalid input (to
    match SSCI more closely)
16. Change the collision avoidance mechanism between the RemapType
    enum and remap kernel functions
17. Add save/load function
2016-06-26 12:42:58 -05:00