Commit Graph
756 Commits
Author SHA1 Message Date
Donovan Watteau 5d8be78b72 DIRECTOR: Fix -Wformat warning 2024-08-11 16:33:53 +02:00
Donovan Watteau d59f66dfe1 DIRECTOR: Properly fix -Wformat warnings with PRId64
As discussed in Discord, in PR#5998 and other places, we can just use PRId64
from <inttypes.h> as a reliable way of printing int64 values on all
platforms, now that this header is guaranteed to be available everywhere.

Fixes build warnings on some 64-bit platforms, which were introduced by my
own previous commit 6ce2ba98f8.
2024-08-10 01:01:16 +02:00
Donovan Watteau 6ce2ba98f8 DIRECTOR: Fix -Wformat warnings on 32-bit platforms 2024-08-03 18:53:28 +03:00
Scott Percival f5b9dda781 DIRECTOR: Fix detection of builtin palettes 2024-06-24 22:34:30 +08: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 554b9a9987 DIRECTOR: Validate all palette cast member IDs before use
Fixes the avalanche of error messages when entering the mirror
in AMBER: Journeys Beyond.
2024-06-22 15:07:37 +08:00
Scott Percival eb86d2794c DIRECTOR: Check output of thawLingoPlayState 2024-06-18 18:24:08 +08:00
Scott Percival 86c5098169 DIRECTOR: Add separate execution freeze for "play" calls
According to the Director documentation, "play" acts in a very different
way to "go". Instead of freezing execution of the handler as part of the
stack, it will freeze the handler and defer it until "play done" is
called by something else. This adds a method for doing this, plus
workarounds to not impact the event processing pipeline.

Fixes picking up most of the time trumpets in Virtual Nightclub
(1580:winASWarp in shared.dxr).
2024-06-15 02:04:30 +02: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 2ce1715c07 DIRECTOR: Move stepMovie handler in front of enterFrame handler
Fixes director-tests/D4-unit/T_EVNT01.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
Eugene Sandulenko 37ba8b175c DIRECTOR: Added more debug output when loading score 2024-06-03 14:00:07 +02:00
Scott Percival 524303e122 DIRECTOR: Move frame timing debug messages to events channel 2024-05-28 11:49:14 +08: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 41cea48a9e DIRECTOR: Reset sprite contents when loading frames from start
Fixes _blendAmount state leak in w_tonnel of Eastern Mind (activate the
magatama dragon, then look at the creature embedded in the wall).
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 2ff3357dac DIRECTOR: Refactor Channel to remove overlay position/dimensions
The original logic doesn't hold up to testing. The position/width/height
of a sprite can be changed at any time without any extra flags; although
the screen needs to be redrawn before you can see any change.

The main thing that the sprite puppet flag does is determine if sprites
are updated from the score data when the frame changes.

Fixes the broken mouse cursor tracking sprite in Chop Suey.

Fixes the sprite scaling in the Doc Martens minigame in Virtual
Nightclub.

Fixes director-tests/D4-unit/T_SPRT01.DIR
2024-05-18 13:56:01 +02:00
Scott Percival 6a0fb37616 DIRECTOR: Allow only one input event to execute at a time
If you trigger e.g. a mouseDown and a mouseUp event, the mouseUp event
should not be run until the mouseDown event has returned.

Fixes director-tests/D4-unit/T_EVNT03.DIR
2024-05-12 22:00:19 +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 d1a739fbce DIRECTOR: Fix scaling of sprites in score frames
Sprites in a score frame have a width and a height; it appears these
values are only to be used if the "stretch" flag is set. Otherwise, the
cast dimensions are used.

Fixes the scaling when picking up the photo album from the filing
cabinet in P.A.W.S.
2024-05-12 22:00:19 +02:00
Eugene Sandulenko 9fef247242 DIRECTOR: DEBUGGER: Implement Start/Stop 2024-05-03 20:03:13 +02:00
Scott Percival 54c6bd2636 DIRECTOR: Add framework for duplicating cast members 2024-04-25 00:54:17 +02:00
Scott Percival 565be3d3c9 DIRECTOR: Cache cast member when processing mouseDown/mouseUp
Fixes clicking the movement buttons in P.A.W.S.
2024-04-25 00:54:17 +02:00
Scott Percival c49c10e881 DIRECTOR: Enable kLPPTrimGarbage for D2/D3 scripts
With D2/D3 action and movie scripts, if there is a syntax error,
the compiler seems to truncate the script at the first unreadable
character, then attempt to compile again.

Fixes the machine gun minigame in Hell Cab.
2024-04-25 00:54:17 +02:00
Scott Percival 8ebfb3a2ea DIRECTOR: Fix digital video playback state leak
Playing two digital videos back to back in the same channel was not
working; both videos thought they controlled the channel, which meant
that the first video would complete, then set _movieRate in the channel
to 0, which would then be misinterpreted by e.g.
Score::isWaitingForNextFrame() as a sign that the second video had
finished.

Fixes the introductory videos in Eastern Mind.

Fixes the conversation with the two ladies at the river in Wrath of the
Gods.
2024-04-25 00:54:17 +02:00
Scott Percival ea089282c7 DIRECTOR: Set the _stretch Sprite flag when loading frames
Flag _inkData & 0x80 is set by Director when a Score sprite has been
stretched. Confirmed that "the stretch of sprite" is expected to reflect
this.
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 637caad1c3 DIRECTOR: Fix setting "the volume of sound"
Previously, volume changes would only be picked up by the next sound
started in the channel (if at all).

Fixes the hint music clashing in the fortune teller floor of the
department store and Club Exclaim in The Seven Colors.
2024-03-31 16:58:31 +02:00
Scott Percival 95ca062e6d DIRECTOR: Always disable puppet sounds on movie change
Previously the puppetSound flag condition would only be disabled if the
sound was playing at the time of the movie switch.

Fixes music when entering the cat room straight from the start room
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 2efa99bda9 DIRECTOR: Cap palette cycling framerate to _fpsLimit 2024-02-09 21:17:57 +08:00
Scott Percival b4737f21ce DIRECTOR: Fix regression with tempo selection
Restores all of the alternative "wait for" types of tempo instruction.
2024-02-01 00:23:19 +08:00
Scott Percival 9d7fc01ba0 DIRECTOR: Re-add sprite copy before applying delta frames 2024-01-31 11:31:28 +08:00
Scott Percival 5d69024aa4 DIRECTOR: Clean up Score methods that previously needed frameId 2024-01-30 23:30:11 +01:00
Scott Percival b50ed6ace4 DIRECTOR: Don't render transitions when movie is paused
Fixes rendering of menu screen on Cosmology of Kyoto.
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 b1e4e92ed2 DIRECTOR: Remove channel copying bodge
It is unclear what problem it was intended to solve, but it no longer
works now that 04cd1dccf9 has fixed the
frame loader to not reload if the frame hasn't changed.

Fixes movie playback in The Dark Eye.
2024-01-30 23:30:11 +01:00
threefins 04cd1dccf9 DIRECTOR: Score: restrict _curFrameNumber updates
When `Score::loadFrame(frameNum)` is called with frameNum <=
_curFrameNumber it will start by resetting frame state, then loading
previous n-l frames and then updating `_curFrameNumber to` `frameNum`.
This is by design, to allow abribtrary script-based frame jumping and debug console commands.

Previous to this change `Score::update()` incrementing `_curFrameNumber` directly before
calling `Score::loadFrame(_curFrameNumber)`. In effect, this meant that
every time the playhead moved forward one frame, all previous frames
would first be loaded from the stream first. Any state built
up by previous scripting is lost and perhaps impacts performance at
suitably high frame counts and debug levels.

In this change, `Score::update()` instead makes changes to a local
variable and passes the result to `Score::loadFrame()`.
2024-01-21 09:26:08 +08:00
Scott Percival a8fe30029d DIRECTOR: Force editable text boxes to be rendered in front
Editable text boxes don't seem to abide by the channel rendering order;
you can have a bitmap in a higher channel that entirely obscures a text
entry widget, and the widget will still be visible.

Fixes the visibility of the name entry text box in Cosmology of Kyoto.
2024-01-20 23:14:52 +01:00
Scott Percival 7cbda5c344 DIRECTOR: Only load frame data if frame has changed
Loading the frame data wipes out e.g. sprites that have been changed
while playback has been paused.

Fixes the buttons on the opening menu screen of Cosmology of Kyoto.
2024-01-20 23:14:52 +01:00
Scott Percival bfac83547e DIRECTOR: Fix linebreak format for the labelList
Fixes inability to close the database after opening it for the first
time in Team Xtreme: Operation Weather Disaster.
2024-01-11 20:41:43 +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
Le Philousophe cf3eac29c3 DIRECTOR: Migrate engine to Path 2023-12-24 13:19:25 +01:00
Scott Percival d3e3f3a714 DIRECTOR: Add D4 workaround for freezing behaviour fix
Freezing changed pretty significantly in D4, so it figures that the
conditions for a frame update would change with it.

Fixes regression where loading save games in The Dark Eye would result
in a white screen.
2023-12-14 22:48:30 +01:00
Scott Percival e84be82321 DIRECTOR: Fix freezing behaviour involving func_goto
It is possible for the following to happen:
- kEventEnterFrame/kEventStepMovie invokes a script
- script calls func_goto() to change the frame
- Lingo state gets frozen
- Lingo state gets defrosted
- script calls func_goto() to go to marker(0)

The last step -should- be a no-op, however it will only work if the
state gets defrosted -after- we change the frame. As such, if there's any
frozen Lingo states after coming back from processing
kEventEnterFrame/kEventStepMovie, we should force the engine to run
through another Score::update() cycle to update the frame.

Fixes exiting the stair climbing digital video in GA28 of GADGET: Invention,
Travel and Adventure.
2023-12-14 20:29:02 +01:00
eientei f919a12948 DIRECTOR: score.cpp: Add colon after TODO so some syntax highlighters pick up on it 2023-10-27 01:19:43 +02:00
Scott Percival 190406c8d1 DIRECTOR: Add debug timing for draw calls 2023-10-25 18:22:15 +02:00
Harishankar Kumar c963b2c3b4 DIRECTOR: Fix chan <frameNum> debugger command
This patch fixes chan command, previously when called with frameNum it
was mutating the state of frame and thus crashing.
2023-08-13 10:57:23 +02: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