* Play sample should be one-shot (don't replay every frame)
* TTM op 0020 should save to background differently (fixes double-drawing)
* Disabled areas still change mouse cursor and hold clicks until enabled,
properly fixes eg exiting detention at the start
* Fix the way "used" sequences are calculated so Willy can enter his house,
removing the previous hack
* Refactor scene condition check to separate file
* Small const correctness improvements
The background and composition buffers were the wrong way around. This fixes
various black backgrounds that were seen during the intro and start of Willy
Beamish.
This fixes the intro cinematic after it zooms in on Willy and his opponent.
The sequence goes something like:
Frame N
FREE SHAPE
SELECT SHAPE
LOAD SHAPE
Frame N+1
DRAW BMP
The first frame is executed multiple times. If LOAD is one-shot but FREE is
not, then it frees the image the second time and does not reload it.
Some game timing events are based on ms elapsed, but we were just getting the
current ms when it was evaluated. This was not very consistent and could
potentially lead to weird problems, although in practice they were unlikely
Record the elapsed ms at the start of each frame so we can use the same
comparison point in every operation.
Although RotD only checks against a sequence being Stopped for IF_NOT_RUNNING,
from HoC onward the check also included Finished as not running.
This fixes flashing characters in Willy Beamish.
The underlying issue was that we tracked used sequences for each ADS segment
using sequence pointers, but the 0x4000 and 0x4010 ADS opcodes re-arranged the
array of sequences. Because arrays don't get re-allocated much this by chance
left the usage pointers valid but now pointing to the wrong sequence, so the
correct sequences were not started and stopped after a re-order operation.
Replaced the array of sequence objects and the used sequence tracker with
shared pointers so we can reorder the sequences without breaking the usage
pointers.
The tap and coat rendering in RotD now both work right and so does the
bar scroll in HoC.
This is a partial revert of 4bb1410079 and
36fe1cdff4. I can't seem to make up my mind
here, but after looking at Ghidra for a really long time I'm now 99% sure that
0x4000 is move to back and 0x4010 is move to front. You can tell because the
0x4000 function in the original finishes with setting the next pointer of the
found element to 0.
I confirmed this in both the RotD and HoC Ghidra outputs.
This re-breaks the tap in the apartment in RotD, I will need to fix that again.
On the up-side, it fixes the scroll left/right in the bar at the start of HoC.
These move operations appear to actually work off the index of the sequence
within the list, not the sequence number. This finally fixes the drawing of
the clothes in Blade's apartment without breaking the tap.
Still need to test through the games to make sure but I think this will now
give the correct execution order.
Closer inspection shows the "move to front" and "move to back" ADS ops were the
wrong way around.
Unfortunately this breaks the rendering a bit - blade's shirt flashes on the
floor of the apartment at the start of dragon.
However, it's more correct and fixes other things - eg, turning off the tap in
the apartment. The rendering problem will need a different fix.