Commit graph

268 commits

Author SHA1 Message Date
Scott Percival
34a60f7911 DIRECTOR: Only clean sprites when there has been a frame swap
Most of the time we'll be looping to the same frame, where we want
to update the sprites, but not clobber them with the contents of the
current frame.

Fixes the paint splodges on the easel in the A room of Cyber Grannies.
Fixes the menu system in Cosmology of Kyoto.
2025-02-27 21:01:03 +01:00
Scott Percival
29e2397bf8 DIRECTOR: LINGO: Improve accuracy of "play done"
After a script reaches "play done", that script gets aborted.
The Lingo frozen play script (aka the script that initially invoked
play) will be thawed before stopMovie.

Fixes director-tests/D4-unit/T_PLAY01.DIR.
Fixes movie switching in Cyber Grannies.
2025-02-27 21:01:03 +01:00
Scott Percival
151d52f938 DIRECTOR: Move Lingo stack into LingoState, fix c_tell infinite loops
Fixes crashes when starting a new game in Zeddas: Servant of Sheol.
2025-02-04 15:24:17 +01:00
Scott Percival
3cef329523
DIRECTOR: Fix film loop playback
Previously, film loops were incremented from Score::updateSprites() by
Channel::setClean(), however this wasn't guaranteed to be run only once
per frame and lead to animation frames being skipped.
This has now been moved into Score::renderFrame.
2024-06-24 22:33:25 +08:00
Scott Percival
cb0aeaed94 DIRECTOR: Only check stepMovie/enterFrame for freeze recursion
Fixes director-tests/D4-unit/T_EVNT18.DIR
2024-06-15 02:04:30 +02:00
Scott Percival
cfda6aaf2c DIRECTOR: Update freezing logic to match test suite
Fixes director-tests/D4-unit/T_EVNT13.DIR to T_EVNT17.DIR
2024-06-15 02:04:30 +02:00
Scott Percival
ff7cdff562 DIRECTOR: Ensure channel sprite information is up to date
Previously there was a gap between loading a new frame, and copying the
sprite information from that new frame back to the channels (if
required). Scripts could run in this gap, and in this case they would
be operating on the old sprite information instead of the new.

Score::renderFrame has been renamed to Score::updateFrame; the method
doesn't actually render anything, it reconciles the difference
between the frame data and the channel data, updates the channel data,
and produces a list of dirty rects.

Fixes the menu screen of Majestic: Alien Encounter.
Fixes director-tests/D4-unit/T_SPRT02 and T_SPRT03
2024-05-25 16:25:18 +02:00
Scott Percival
523d31590e DIRECTOR: Prevent exitFrame handler from running twice
It is possible to call "pause" in the exitFrame handler, then rely on
another handler (e.g. mouseDown) to call "continue" to start the movie
playback. exitFrame should not be called again once playback is resumed.

Fixes entering the first hatch in L-Zone.
Fixes D4-unit/T_EVNT12.DIR in director-tests.
2024-05-22 17:24:31 +02:00
Eugene Sandulenko
35d1fc8ae2
DIRECTOR: DEBUGGER: Initial code for score viewing 2024-05-18 15:42:36 +02:00
Scott Percival
a08934a95e DIRECTOR: Update current frame before running startMovie
The startMovie handler needs "the frame" to return the starting frame,
which isn't necessarily 1. Easiest way to fix this is to set up the
frame data in the Score::startPlay() handler.

Fixes the broken navigation in the Empire State Building in Hell Cab.
2024-05-12 22:00:19 +02:00
Scott Percival
54c6bd2636 DIRECTOR: Add framework for duplicating cast members 2024-04-25 00:54:17 +02:00
Scott Percival
12cf67948d DIRECTOR: Allow multiple concurrent sound fades
Fixes collecting the orange heart in The Seven Colors.
2024-03-31 16:58:31 +02:00
Scott Percival
a1b16fa399 DIRECTOR: Preserve trails on screen
Several Director titles make use of the "trails" sprite feature to
draw graphics to the framebuffer, strobing multiple sprites with a
single channel. In order for this to work, we need to be careful that
the dirty rectangles list is only updating the bare minimum area.

Extra rectangles were being added by Score::renderSprites; an invalid
cast reference would still add the channel's bbox to the list. This has
been fixed.

Previously, the end of a transition would force a full screen refresh,
even if the update was partial. This should be unneccesary; transitions
shouldn't leave artifacts on the screen.

Fixes many instances of inventory items disappearing in Team Xtreme:
Operation Weather disaster (e.g. clicking the compass in Stonehenge,
clicking an item on the memory game in Stonehenge).
2024-03-11 01:04:43 +01:00
Scott Percival
5d69024aa4 DIRECTOR: Clean up Score methods that previously needed frameId 2024-01-30 23:30:11 +01:00
Scott Percival
27f0e8f8bb DIRECTOR: Rework event ordering to be closer to original
Confirmed to work with:
- darkeye (race condition when viewing cutscenes or switching scenes in
  the menu)
- gadget (race condition after climbing the stairs in GA28)
- the7colors (intro cutscene timed with b_delay)
- wallobee (hotspot select gated with b_delay)
2024-01-30 23:30:11 +01:00
Scott Percival
8b9d989c73 DIRECTOR: Re-add tracking of current tempo
Re-adds the support removed in e13eba2162

Fixes the puppetTempo example in Lingo Dictionary.
2024-01-08 02:54:14 +01:00
Harishankar Kumar
ffd515fe6a DIRECTOR: Refactor score loading and remove framesOffset
This patch completely removes framesOffset and rebuildChannelData()
The framesOffset was used to store the number of frames and their
starting position in frame stream, however this information is not
needed as when in frames jumping, all the channels needed to be built
from frame 1, thus only position of first frame is needed.
2023-08-13 10:57:23 +02:00
Harishankar Kumar
4e1cdb73b4 DIRECTOR: Refactor loading cast when building framesOffset
This patch refactors the code that builds the framesOffsets table,
initially each frame of movie was being parsed and sprite casts loaded
then was being discarded, this was not very efficient.  Refactored code
to load cast only when they are required, thus reducing the time to load
a movie.

Fixed slow loading of large movies in `totaldistortion-win`

--start-movie="ATD/HD/ADTDVSVF/TDVIDDB1.DIR" totaldistortion-win
2023-08-13 10:57:23 +02:00
Eugene Sandulenko
8bccc12786
DIRECTOR: Reduce header dependency 2023-08-02 21:05:06 +02:00
Harishankar Kumar
a7a41273cf DIRECTOR: Improve screenshot comparison of previous builds
This patch adds simple pixel by pixel comparison of screenshots
between builds. It is useful to detect regressions in graphics
rendering.
2023-07-26 23:37:37 +02:00
Harishankar Kumar
e13eba2162 DIRECTOR: Refactor tempo, remove scoreCachedTempo
This removes the scoreCachedTempo from main channel struct, it was
observed that with advent of on demand frame loading, the tempo is
automatically being overwritten when found in score, this renders
previous logic to cache tempo and carry to forward useless.

`More Puppets` of 'theapartment-4` is now working.
2023-07-19 14:57:59 +02:00
Eugene Sandulenko
cd3be9ac18 DIRECTOR: Remove Score::_channelData. We now read frames dynamically 2023-07-10 16:03:11 +02:00
Eugene Sandulenko
30fdc2a9e2 DIRECTOR: Do not process frame actions multiple times
Also drop now impossible check for unreferenced actions
2023-07-10 16:03:11 +02:00
Harishankar Kumar
aeac3e2d21 DIRECTOR: Refactor loadOneFrame() to remove clutter 2023-07-10 16:03:11 +02:00
Harishankar Kumar
5c3f4b837b DIRECTOR: Refactored score class, changed comments 2023-07-10 16:03:11 +02:00
Harishankar Kumar
5ec6a62fe8 DIRECTOR: Change _frameStream to read and wrap stream data 2023-07-10 16:03:11 +02:00
Harishankar Kumar
fdd8c34691 DIRECTOR: Rename _frame, getCurrentFrame(), getTotalFrames() to improve readability 2023-07-10 16:03:11 +02:00
Harishankar Kumar
bcc3ad7f66 DIRECTOR: Refactored quickSelect to getFrameData
Earlier quickSelect was modifying and contaminating current state
of the score. This was causing problems with the frame demand.
Now quickSelect is only used for previewing one frame and it
doesn't modify the score.
2023-07-10 16:03:11 +02:00
Harishankar Kumar
2b331582aa DIRECTOR: Change preloading of frames to demand loading
Frames are now loaded on demand, when they are first accessed. Also
the starting offsets of each frames are stored in a special array, so
any previously visited frame might have quick access time. Much of the
work is done in Score class itself.

Warning: This commit is not yet complete. There are various issues
and crashes on the way.

Demand loading of frames is implemented to replicate the behavior of
the original engine. The original engine does not load frames until
it is accessed, this property when used with lingo is exploited to
allow changes in sprite properties when there is no next frame changes
of that property. In essential what happened was that for a non puppet
sprites, the game can have its property changed and rendered until there
was full refresh (in form of jumps, etc) of screen. This was not possible
with precached frames.

The first example use was seen in movie `ATD\HD\bdDREAMA.DXR` of game
'totaldistortion-win'.
2023-07-10 16:03:11 +02:00
Scott Percival
da06ecad9b DIRECTOR: Move _lastPalette to DirectorEngine
If the destination movie uses a palette cast member in the same location
as the source, but with different data; Director will assume that the old
palette is correct right up until it has to switch to something else via
the score.

Additionally, ensure that all palettes are loaded into the index when
the Cast is loaded, not just single ones that haven't been loaded before.

Fixes movie transitions and palette rendering in Phibos: Following the Comet.
2023-05-14 14:10:22 +02:00
Scott Percival
5426729bf4 DIRECTOR: Fix zoom transitions 2023-05-10 09:48:50 +02:00
Scott Percival
ec76e5dfc6 DIRECTOR: Refactor palette loading for D5
Previously, the palette ID namespace was shared between cast ID, builtin
ID and resource fork ID. This was quite messy.

The new approach is to use CastMemberID; builtin palettes are libId -1,
cast palettes use their respective libId, and a null CastMemberID
indicates a blank entry.
2023-05-10 09:48:50 +02:00
Scott Percival
f703ee6ecf DIRECTOR: Split CastMember classes into files 2023-04-29 14:20:05 +02:00
Eugene Sandulenko
e866ba2fc0
DIRECTOR: Properly search for previous screenshots, support for the first run 2023-04-08 12:31:08 +02:00
Scott Percival
32b878b694 DIRECTOR: Attempt to unfreeze scripts more often
Score::update() has several branches that quit early, e.g. if the frame
is waiting for a click or a sound. All of these should try to unfreeze
any contexts that are waiting.

Fixes opening the inventory screen in Hell Cab.
2023-02-08 13:30:58 +01:00
Eugene Sandulenko
63a57c1ba3
DIRECTOR: Made fewframesonly count global frames.
If the movie is switching during the first few frames, we were
resetting the counter which led to buildbot hanging.
2023-01-27 22:25:19 +01:00
Scott Percival
fb4d1f3bfe DIRECTOR: Make bitmap color correction ignore color cycling operations
Fixes the logo sequence in Alice: An Interactive Museum.
2023-01-10 13:41:53 +01:00
Scott Percival
f61e06a752 DIRECTOR: Fix Score::getCurrentPalette()
Previously, this would return the palette for the current frame (if it
was specified). Real Director behaviour is to return the current
palette in use, i.e. taking into account changes made in previous
frames.
2023-01-10 13:41:53 +01:00
Scott Percival
9a10fe51d3 DIRECTOR: Provide live channel information for current frame 2022-11-18 16:28:05 +01:00
Scott Percival
2a261d0fba DIRECTOR: Allow for tempo changes when seeking to arbitrary frames
In Director, FPS entries in the tempo channel apply to all subsequent
frames. If we seek to an arbitrary frame, the correct tempo settings
should be applied.

Fixes the animation speeds of the cauldron and the walking teapot in
Chop Suey.
2022-10-06 00:05:17 +02:00
Scott Percival
7de1d320a0 DIRECTOR: Add more palette transition modes 2022-09-12 15:52:18 +02:00
Scott Percival
076423de8a DIRECTOR: Implement color cycling 2022-09-12 15:52:18 +02:00
Scott Percival
0e847c42bd DIRECTOR: LINGO: Limit sound updates in b_updateStage()
Previously it was possible for a Lingo script to stop a score sound channel,
then call updateStage, which would immediately start it again. To fix
this, updateStage() will now only update puppet sounds.

Fixes the sound playback when going from the map to the exit screen in
Chop Suey.
2022-09-12 15:52:18 +02:00
djsrv
d7f9e3601e DIRECTOR: Simplify redraw logic for kTheRegPoint
We only need to add dirty rects for the sprites with this cast member,
not force redraw every sprite.
2022-07-09 18:22:50 -05:00
Eugene Sandulenko
abea37c9bb
ALL: Update ScummVM project license to GPLv3+ 2021-12-26 18:48:43 +01:00
ysj1173886760
ecce34593e DIRECTOR: combine renderVideo and updateWidgets. 2021-08-20 20:59:48 +08:00
ysj1173886760
d69144fa18 DIRECTOR: introduce updateWidget to fix updateStage. 2021-08-20 20:53:44 +08:00
djsrv
19dab8f130 DIRECTOR: Set cursors per-movie, not globally 2021-08-06 01:11:49 -04:00
djsrv
ff16d808c7 DIRECTOR: LINGO: Play puppet sounds in updateStage 2021-07-27 22:54:25 -04:00
djsrv
a16d823201 DIRECTOR: Improve puppetSound
Most variants of puppetSounds don't actually start the sound immediately
but wait until the frame is updated. So I've created a SoundID struct
which stores a reference to a cast member or externals sound, and that
is used to store the puppetSound until it's actually supposed to start.
In addition, puppet status is now per-channel instead of a universal
flag.
2021-07-27 22:54:16 -04:00