This is the function that causes Marisa's `Divide Error` crash when
called during a 4-frame window during the end of certain patterns.
Just like with Kurumi's division by zero, it's just as undefined here
what should happen instead, and any possible fix can only ever be a
fan-fiction interpretation of the code. And since the community will
have an easier time understanding and debating a C++-level hack instead
of an ASM-level one, it makes sense to first decompile this function…
…and document it, which is actually much harder!
Part of P0189, funded by Arandui and Lmocinemod.
Major thanks to Colin Douglas Howell, who looked into the issue and
provided instructions for reliably reproducing it:
https://github.com/nmlgc/rec98.nmlgc.net/issues/2
Part of P0189, funded by Arandui and Lmocinemod.
Featuring a stupid variant of Turbo C++'s __memcpy__() intrinsic that
does the exact same thing, but just with reordered instructions. What a
waste of time.
Part of P0189, funded by Arandui and Lmocinemod.
Using the .BB entrance animation as a transition between stage tiles
and the backdrop image. Also implemented in a much better way.
Part of P0189, funded by Arandui and Lmocinemod.
It's basically the same function copy-pasted 4 times, differing only in
the backdrop image coordinates and some other inconsequential details.
Part of P0189, funded by Arandui and Lmocinemod.
Using the .BB cels as a transition mask between stage tiles and the
boss backdrop, nice. Seen in the entrance animations of TH04's
Orange, Kurumi, and Elly, and TH05's Sara.
Part of P0189, funded by Arandui and Lmocinemod.
Would have been nice if we could have kept them in `render.cpp`, but
the colorfill function definitions surely won't be part of this
translation unit…
Part of P0189, funded by Arandui and Lmocinemod.
Once we decompile whatever can be decompiled of those, we're going to
use the same coordinate constants for both these and the backdrop
image. Ideally, we can even macro (or inline-function) away the entire
implementation, so that the redundancy between TH04's and TH05's Stage
4 bosses won't matter as much.
Part of P0189, funded by Arandui and Lmocinemod.
The fanciness of expressing these as signed constants probably hurted
the understandability of the code more than it helped.
Part of P0189, funded by Arandui and Lmocinemod.
Wait, wouldn't it be cool if we could keep the render, spawn, and
update functions in the same translation unit, by switching code
segments in the middle of the file? Let's hope this works out, and give
the source file an all-encompassing generic name.
Part of P0188, funded by [Anonymous] and nrook.
Awesome! The last of the shared TH04/TH05 boss functions, completed
just as the money for that sort of thing ran out. Time to decompile
some actual bosses!
Part of P0188, funded by [Anonymous] and nrook.
Does some interesting damage manipulation for Reimu and Yuuka in TH05.
More specifics on that once we actually decompile that function.
Part of P0188, funded by [Anonymous] and nrook.
With TH04's version hardcoding not only Gengetsu's dialog and
initialization, but also the Bad Ending after having clearing Stage 5
with continues or on Easy difficulty.
Part of P0188, funded by [Anonymous] and nrook.
What is this, reversed Hungarian notation? For gaiji strings, it makes
sense because there's no difference in the access code to regular
strings, but you can't really do anything with a union itself.
(Besides passing it to a function in a type-safe way, but that's cool.)
Part of P0186, funded by [Anonymous] and Blue Bolt.
With a different meaning (and sometimes, even type) every time they are
used, forcing me to look at details of boss fights way before I wanted…
wonderful. Not sure yet whether they're involved in Kurumi's and
Marisa's division-by-0 crashes, but that kind of wildly shared state is
exactly what causes bugs like these to happen. I did manage to
reproduce the Marisa crash during this research!
Temporarily breaking the rule of immediately reflecting ASM land
declarations in C land, because it makes more sense to render these as
macros, local to their respective pattern functions, and it's way too
early for declaring these. Or late, given that I've now got to add a
third push to this stretch…
Completes P0187, funded by [Anonymous] and Blue Bolt.
Given how close the string literals of TH04's boss defeat sequence
function are to the end of its data segment, it makes sense to figure
out the three values after it right now.
Part of P0187, funded by [Anonymous] and Blue Bolt.
Pretty much required to sort out the upcoming unnecessary complexity
that TH04 throws our way, and due to their random order inside
MAIN.EXE.
Part of P0187, funded by [Anonymous] and Blue Bolt.
One of the rare cases where explicitly spelling out the FP_SEG() cast
is better than just calling the C++ wrapper: To drive home the point
that this code relies on `far` pointer semantics. Running the dialog
script performs arithmetic on only the offset part of this pointer, and
the segment part must remain unchanged for this hmem_free() call to
work as intended.
Completes P0186, funded by [Anonymous] and Blue Bolt.
Slightly more tricky semantics than necessary, thanks to the Game Over
menu, even in such a supposedly simple type…
Part of P0186, funded by [Anonymous] and Blue Bolt.
This term encompasses both the event popups, the Stage and BGM titles
(which have nothing to do with the former), and the upcoming transition
effect.
Part of P0186, funded by [Anonymous] and Blue Bolt.
The `_animate()` convention doesn't *really* fit for a function that
also handles input, but I'd rather continue using the same convention
for every blocking multi-frame function.
Part of P0186, funded by [Anonymous] and Blue Bolt.
Mostly centered around the HUD, popup, overlay, boss, and player shot
functions we're about to reference in the upcoming decompilations.
Part of P0186, funded by [Anonymous] and Blue Bolt.