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.
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
In the original engine, the enterFrame handler can only be called
recursively upto second depth, and the third call will be ignored.
This was formerly implemented by counting number of frozen lingo
states, however there are cases where the lingo state is frozen,
while enterFrame handler not called, so the count is not accurate.
This patch improves the logic by counting the number of enterFrame
in frozen lingo states as well, so it can be identified that these
previous frames are indeed of `enterFrame` handler.
Fixes bug where the elevator when jumping to next floor (yellow one)
broke dimensional movement in `totaldistortion-win`.
Games can load movies without a score; e.g. with a MovieScript
which performs a check then bounces to a different movie.
In these cases, we can reuse the frame loader code and inject
a Score with one empty frame.
Fixes the EXE movie in Maniac Sports.
Initially, the frames data were only being reset and rebuild when
jumps were made to frame that is different than current one, ie
this in case when `_nextFrame != _curFrameNumber`, this however
had problems with `majestic-mac` not opening and stuck on loading
screen.
Fixed problem where `majestic-mac` would constantly jump to main-menu
screen (ie same frame) and would not load the game.
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.
Without this the lingo modified non puppet sprites properties were not
being reflected in the frame. Now what happens is if you modify a non
puppet property then lingo will temporarily override the score (ie that
property is remain the same until an update from score is encountered)
This closely resembles the behaviour of the original engine.
When frame jumping instructions like `go to frame` is used, it should pause
lingo execution before changing frames and then executing remaining lingo code,
This fixes the problem where lingo was executed before the frame was updated.
`ATD\HD\bdDREAMA.DXR` of 'totaldistortion' uses this to set puppetSprite after
calling go to frame.
Total number of frames were being read from VWSC resource
(version > kFileVer400), however it has been found that for some movies
there is mismatch between version and total frames. Therefore now changed
the code to load all frames initially to read total number of frames.
`ATD\HD\ABPOPUP1.DXR` of `totaldistortion` is one such example.
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.
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'.
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.
When fading a palette, Director lets you pick a "frame rate" between 1
and 30. These each correspond to a fixed transition time, with the
higher framerates converging to zero.
In D4 and under the slowest of these frame rates is half a second.
After some user feedback they changed this in D5 to be a range
of times, ranging from a leisurely 16.5 seconds all the way to
instantaneous.
Fixes the intro fade in The Cute machine.
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.