Commit Graph

1862 Commits

Author SHA1 Message Date
nmlgc c90c7d52c4 [Decompilation] [th04] Stage 4 Marisa: Point-reflected movement
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.
2022-04-17 00:00:35 +02:00
nmlgc 9f4e5ae1ac [Reverse-engineering] [th04] Discover the cause behind the Kurumi crash on Easy
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.
2022-04-16 23:53:47 +02:00
nmlgc 5bca6bed0f [Decompilation] [th04/th05] Gather circles: Update function
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.
2022-04-16 23:53:47 +02:00
nmlgc 0d703fb2e1 [Decompilation] [th05] Sara: Background rendering
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.
2022-04-16 23:53:47 +02:00
nmlgc 5655b53f10 [Decompilation] [th05] Louise / Alice / Mai & Yuki / Yumeko: Background rendering
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.
2022-04-16 23:53:47 +02:00
nmlgc fe74b31bb6 [Reverse-engineering] [th04/th05] Bosses: Clarify background rendering details
Some aspects I missed in P0147.

Part of P0189, funded by Arandui and Lmocinemod.
2022-04-16 23:53:47 +02:00
nmlgc 2ceee1df02 [Reverse-engineering] [th04/th05] .BB tile animation: Tile invalidation
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.
2022-04-16 23:53:47 +02:00
nmlgc 992cd74970 [Naming] [th04/th05] Bosses: HP fill and .BB tile animation phase constants
These phases are the same across all bosses.

Part of P0189, funded by Arandui and Lmocinemod.
2022-04-16 23:53:47 +02:00
nmlgc 71b6e66fec [Maintenance] [th05] Bosses: Start a new header for implementation macros
Part of P0189, funded by Arandui and Lmocinemod.
2022-04-16 23:53:46 +02:00
nmlgc 3836a8d262 [Maintenance] [th05] Shinki: Move backdrop coordinates to `bosses.hpp`
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.
2022-04-16 23:53:46 +02:00
nmlgc 5dca74a77c [Naming] [th04/th05] Boss-specific names for backdrop colorfill functions
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.
2022-04-16 23:53:46 +02:00
nmlgc 019405a241 [Maintenance] [th04/th05] Declare common (mid-)boss phases as proper constants
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.
2022-04-16 23:53:46 +02:00
nmlgc facc3dbdc9 [Maintenance] [th04/th05] Define grcg_setmode_tdw() with the correct name
Part of P0189, funded by Arandui and Lmocinemod.
2022-04-16 23:53:46 +02:00
nmlgc 6db32b92fe [Maintenance] [th04/th05] Remove `extern "C"` from boss functions
Part of P0189, funded by Arandui and Lmocinemod.
2022-04-16 23:53:46 +02:00
nmlgc a2358bef47 [Maintenance] Remove `extern "C"` from `x86real.h` and `decomp.hpp`
One of those per delivery now, eh?

Part of P0189, funded by Arandui and Lmocinemod.
2022-04-16 23:53:46 +02:00
nmlgc 22abdd133b [Readme] Windows 10 was the last edition to have a 32-bit version 2022-04-15 00:02:41 +02:00
nmlgc f45226f0c3 [Readme] Mention that this project does not include original game asset data
Thanks to -Tom- for the suggestion!
2022-04-15 00:02:41 +02:00
nmlgc e881f95ce1 [Decompilation] [th05] Shinki's 32×32 balls: Update function
Completes P0188, funded by [Anonymous] and nrook.
2022-03-27 01:50:07 +01:00
nmlgc adffa1ccf9 [Decompilation] [th05] Shinki's 32×32 balls: Spawn function
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.
2022-03-27 01:50:07 +01:00
nmlgc ac7822ec71 [Decompilation] [th04/th05] Boss and midboss player shot collision handling
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.
2022-03-27 01:50:07 +01:00
nmlgc f5533c700e [Reverse-engineering] [th04/th05] Player shots: Boss collision detection flag
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.
2022-03-27 01:35:40 +01:00
nmlgc 38eb77c828 [Decompilation] [th04/th05] Bosses: Item drops
Part of P0188, funded by [Anonymous] and nrook.
2022-03-27 01:35:40 +01:00
nmlgc ac497e8bc4 [Decompilation] [th04/th05] Bosses: Phase switching
Part of P0188, funded by [Anonymous] and nrook.
2022-03-27 01:35:40 +01:00
nmlgc 354a4724f3 [Decompilation] [th04/th05] Bosses: Defeat sequence
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.
2022-03-27 01:35:37 +01:00
nmlgc 0fb1a9f01e [Maintenance] [th05] Split segment #3 before Shinki
Part of P0188, funded by [Anonymous] and nrook.
2022-03-27 01:29:03 +01:00
nmlgc 08488e2594 [Maintenance] [th03/th04/th05] Drop the `_lebcd` suffix from score variables
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.
2022-03-27 01:29:03 +01:00
nmlgc 83ff3c9ec9 [Maintenance] [th04/th05] Bullets: Move clear/zap declarations to new header
Part of P0188, funded by [Anonymous] and nrook.
2022-03-27 01:29:03 +01:00
nmlgc 5206311da3 [Naming] [th04/th05] Rename `bb_stage*` to "bb_boss*"
They are boss entrance animations first and foremost, and not really
related to the stage part.

Part of P0188, funded by [Anonymous] and nrook.
2022-03-27 01:28:46 +01:00
nmlgc 426a531882 [Reverse-engineering] [th04] Bosses: 16 shared state bytes
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.
2022-03-27 00:48:12 +01:00
nmlgc a03e8a78b8 [Reverse-engineering] [th04] Stage 4 Reimu: Data segment variables
Part of P0187, funded by [Anonymous] and Blue Bolt.
2022-03-27 00:48:06 +01:00
nmlgc 5e4f1f0f1d [Reverse-engineering] [th04] Gengetsu: Wave teleport amplitude
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.
2022-03-27 00:43:03 +01:00
nmlgc 9e75a62ac9 [Naming] [th04] Bosses: Assign pattern functions to their respective fights
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.
2022-03-27 00:42:55 +01:00
nmlgc bab5634ff1 [Decompilation] [th04/th05] Dialog: Script freeing function
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.
2022-03-27 00:39:04 +01:00
nmlgc 903d824c48 [Decompilation] [th04/th05] Dialog: Script loading functions
Part of P0186, funded by [Anonymous] and Blue Bolt.
2022-03-27 00:39:04 +01:00
nmlgc b33631daf4 [Reverse-engineering] [th04/th05] Dialog: Buffer pointer
Part of P0186, funded by [Anonymous] and Blue Bolt.
2022-03-27 00:39:04 +01:00
nmlgc 6c5371da9e [Reverse-engineering] [th04/th05] Game quit flag
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.
2022-03-27 00:39:04 +01:00
nmlgc 295d5a8c6c [Decompilation] [th05] Bosses: Player sprite collision
TH05 only…? Yes, moving over a boss sprite doesn't actually kill the
player in TH04.

Part of P0186, funded by [Anonymous] and Blue Bolt.
2022-03-27 00:39:03 +01:00
nmlgc 16254c62e3 [Decompilation] [th04/th05] Text overlay: Stage transitions
Rotating black squares in TH05, and something much more fancy in TH04.

Part of P0186, funded by [Anonymous] and Blue Bolt.
2022-03-27 00:39:00 +01:00
nmlgc 73e7667f4f [Maintenance] [th04/th05] Text overlay: Use proper constants for coordinates
The macro syntax highlighting color is always a bit unnerving.

Part of P0186, funded by [Anonymous] and Blue Bolt.
2022-03-27 00:33:51 +01:00
nmlgc 787ba656b0 [Maintenance] [th04/th05] Text overlay: Correctly sort global data
Part of P0186, funded by [Anonymous] and Blue Bolt.
2022-03-27 00:33:51 +01:00
nmlgc 39fd88d728 [Maintenance] [th02/th04/th05] Text overlay: Adopt "playfield TRAM" code
Part of P0186, funded by [Anonymous] and Blue Bolt.
2022-03-27 00:33:51 +01:00
nmlgc 7d5b34d390 [Maintenance] [th04/th05] Text popups: Move to a new "text overlay" module
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.
2022-03-27 00:33:51 +01:00
nmlgc ea6cd342b7 [Maintenance] [th04/th05] Text popups: Drop `popup_` from static declarations
Or at least from the unambiguous ones.

Part of P0186, funded by [Anonymous] and Blue Bolt.
2022-03-27 00:33:51 +01:00
nmlgc e9b2a98363 [Decompilation] [th04/th05] Bosses / Midbosses: End-of-phase score bonus
Part of P0186, funded by [Anonymous] and Blue Bolt.
2022-03-27 00:33:51 +01:00
nmlgc bb4a99dd05 [Naming] [th02/th04/th05] Stage clear bonus calculation and rendering
Oh hey, TH02!

Part of P0186, funded by [Anonymous] and Blue Bolt.
2022-03-27 00:33:51 +01:00
nmlgc 719baa3a5e [Naming] [th04/th05] Dialog: Main function
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.
2022-03-27 00:33:46 +01:00
nmlgc 66bcd56272 [Naming] [th04/th05] Bosses: Rename `*_phase_end` to `*_phase_next`
Another slightly imprecise uth05win naming convention we can improve
on.

Part of P0186, funded by [Anonymous] and Blue Bolt.
2022-03-26 20:44:54 +01:00
nmlgc 718590908f [Maintenance] [th04/th05] Remove `extern "C"` from more areas of code
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.
2022-03-26 20:44:54 +01:00
nmlgc 6400e6a689 [Maintenance] [th04/th05] Boss explosions: Update to current coding standards
Part of P0186, funded by [Anonymous] and Blue Bolt.
2022-03-26 20:44:54 +01:00
nmlgc 2efd1fb29d [Maintenance] Get rid of ReC98.h
… and this mistake.

Part of P0186, funded by [Anonymous] and Blue Bolt.
2022-03-26 20:44:54 +01:00