Commit Graph

1949 Commits

Author SHA1 Message Date
nmlgc 8fce97ea1c [Maintenance] Add a static_assert() polyfill to platform.h
Part of P0198, funded by Lmocinemod and Ember2528.
2022-06-16 22:50:31 +02:00
nmlgc 16aba1bc9a [Readme] Update branch overview
Adding `th01_critical_fixes`, which has also become a part of
`community_choice_fixes`.
2022-06-01 02:27:52 +02:00
nmlgc 48db0b7a72 [Decompilation] [th01] Verdict screen: Title calculation
You can definitely make an argument that these if/else if branches are
easier to read than their implied formula, especially with all
variables being signed here.

Completes P0197, funded by Yanga and Ember2528.
2022-06-01 02:27:52 +02:00
nmlgc 2863a69836 [Decompilation] [th01] Verdict screen: Main function
Part of P0197, funded by Yanga and Ember2528.
2022-06-01 02:27:52 +02:00
nmlgc cde1199485 [Maintenance] [th01/th03] Don't declare an Extra rank
AKA a reaction commit to the unfounded theory from Asprey's "Unused
Content in Touhou Project" video. (Seriously though, it does help with
the code for these games.)

Part of P0197, funded by Yanga and Ember2528.
2022-05-31 23:39:34 +02:00
nmlgc e98fa0b78e [Maintenance] [th01] High score menu: Publically declare text colors
Part of P0197, funded by Yanga and Ember2528.
2022-05-31 23:39:34 +02:00
nmlgc e15942bb7c [Maintenance] [th01] Add string length calculation wrappers for VRAM typing
Part of P0197, funded by Yanga and Ember2528.
2022-05-31 23:39:34 +02:00
nmlgc 94372d2e27 [Maintenance] [th01] Move data of FUUIN.EXE segments ≥4 to a new assembly unit
Turns out that the "new idea" for handling these data slices won't work
out in reality. At least the amount of necessary manual `extern`
declarations isn't soul-crushingly large, so this way isn't bad either,
after all!

Part of P0197, funded by Yanga and Ember2528.
2022-05-31 23:39:34 +02:00
nmlgc 9cd1b04894 [Research] [th01] Find out why defeating bosses with lasers can crash the game
Brought to you by diagonal movement and the combined effect of 4 ZUN
bugs. Most commonly reported for Elis and Mima.

Part of P0197, funded by Yanga and Ember2528.
2022-05-31 23:39:34 +02:00
nmlgc b165871ece [Maintenance] [th01] graph_r_line(): Make slope calculations more explicit
The previous macros suggested optimizations that could easily lead to
crashes.

Part of P0197, funded by Yanga and Ember2528.
2022-05-31 23:39:34 +02:00
nmlgc b4033b5fe4 [Research] [th01] Document potential HP bar heap corruption in debug mode
Turns out that Konngara is also affected.

Part of P0197, funded by Yanga and Ember2528.
2022-05-31 23:29:26 +02:00
nmlgc 57c9ac5da7 [Decompilation] [th01] Elis: Move all data to C land
4th PC-98 Touhou boss completely decompiled, 27 to go!

Completes P0196, funded by Yanga.
2022-05-31 23:15:14 +02:00
nmlgc e2f7a7afc4 [Decompilation] [th01] Elis: Main function
Part of P0196, funded by Yanga.
2022-05-31 23:15:14 +02:00
nmlgc 0062826327 [Separating translation units] [th01] Additional hardware effect functions
These could have been nicely separated into per-device translations
(one for GDC, one for EGC, one for regular VRAM accesses)… if their
original order followed that classification.

OK, so let's make it one full `graph_ex.cpp` translation unit… nope,
FUUIN.EXE needs graph_2xscale_byterect_1_to_0_slow() with different
compilation flags. 🤦

Whatever, fuck it, let's go for individual translation units, with
individual headers, so that we at least get predictably organized
source code out of this.

Part of P0196, funded by Yanga.
2022-05-31 23:15:14 +02:00
nmlgc e18c53d7ac [Decompilation] [th01] Elis: Phase 5 transformation / bat pattern selection
Completes P0195, funded by Yanga.
2022-05-31 23:15:14 +02:00
nmlgc 9299df2f53 [Decompilation] [th01] Elis: Phase 5 girl pattern selection
The phase 3 selection logic was fine! No need to reinvent it with even
more convoluted logic, in a function that should not exist to begin
with. (Phase 4 is another one that only consists of a teleport and a
bat transformation.)

Part of P0195, funded by Yanga.
2022-05-31 23:15:14 +02:00
nmlgc be7e88ceaf [Decompilation] [th01] Elis: Pattern 13/13
The one where Elis fires aimed 5-spreads from her left and right wings,
togther with an aimed laser every second time, and finishes with a
32-ring of static bullets along, yet again, not quite the center
position of the big circle around her.

Part of P0195, funded by Yanga.
2022-05-31 23:15:14 +02:00
nmlgc 387431ed15 [Decompilation] [th01] Elis: Pattern 12/13
The one where Elis creates a safety zone of 256 pixels around the
initial position of the player, indicated by a circle, and then fires
pellets from random positions at the top edge of the playfield for a
while.

Followed by 5 aimed pellets from her center position.

Followed by… 7 aimed pellets from the bat entity's center position?!
Except that those aren't even correctly centered relative to the bat,
and still use the center offset of the girl sprite.

Part of P0195, funded by Yanga.
2022-05-31 23:15:14 +02:00
nmlgc a25abad9c4 [Decompilation] [th01] Elis: Pattern 11/13
The one where Elis fires three symmetric 4-stacks followed by one
symmetric 10-pellet arc.

Part of P0195, funded by Yanga.
2022-05-31 23:15:14 +02:00
nmlgc 0c19af8864 [Decompilation] [th01] Elis: Pattern 10/13
The bat form's "random pellet rain" pattern.

Part of P0195, funded by Yanga.
2022-05-31 23:15:14 +02:00
nmlgc f6a1711883 [Decompilation] [th01] Elis: Pattern 9/13
The one where Elis' bat form fires pellets in a
𝄆 22----33----22----333---2 𝄇-spread loop.

Part of P0195, funded by Yanga.
2022-05-31 23:15:14 +02:00
nmlgc 4e9c39c9f7 [Decompilation] [th01] Elis: Pattern 8/13
The one where Elis' bat form fires fast 2-spreads every 4 frames,
randomly switching between narrow and wide angles.

Part of P0195, funded by Yanga.
2022-05-31 23:15:14 +02:00
nmlgc 1ea836f4b7 [Decompilation] [th01] Elis: Pattern 7/13
The one where Elis' bat form fires a slow spread group every 16 frames.
Interestingly, it's easiest on Lunatic, where the pellets are always
fired downwards and you just have to not stand below Elis. On every
other difficulty, the pellets are aimed to the player.

And what's this, an appropriately used local variable?!

Part of P0195, funded by Yanga.
2022-05-31 23:15:14 +02:00
nmlgc 5d93a5038b [Decompilation] [th01] Elis: Random bat movement
Which would look even nicer if the bat wasn't exclusively rendered on
the byte-aligned 8×1-pixel grid.

Completes P0194, funded by Ember2528.
2022-05-31 23:15:07 +02:00
nmlgc dfb0c43b86 [Decompilation] [th01] Elis: Bat→girl transformation
Part of P0194, funded by Ember2528.
2022-05-31 22:55:33 +02:00
nmlgc 520e488701 [Decompilation] [th01] Elis: Girl→bat transformation
That's 75% of TH01 RE'd!

Part of P0194, funded by Ember2528.
2022-05-31 22:55:33 +02:00
nmlgc 3272375991 [Decompilation] [th01] Elis: Phase 3 pattern selection
If you were wondering where Phase 2 was: That one just consists of a
wavy teleport back to Elis' base position.

Part of P0194, funded by Ember2528.
2022-05-31 22:55:33 +02:00
nmlgc 31aa78a2d1 [Decompilation] [th01] Elis: Pattern 6/13
The one where Elis fires pellets from 5 random blue rifts around her
sprite, first with random angles firing downwards, then with random
angles in all directions.

A~nd we've reached Konngara levels of copy-pasta again. 🍝

Part of P0194, funded by Ember2528.
2022-05-31 22:55:33 +02:00
nmlgc 603931baf1 [Decompilation] [th01] Elis: Pattern 5/13
The one where Elis spawns 10 spheres that fire dense clusters of random
pellets.

Part of P0194, funded by Ember2528.
2022-05-31 22:55:33 +02:00
nmlgc b2006b5042 [Decompilation] [th01] Elis: Pattern 4/13
The one where Elis fires a curved 5-stack of static rings.

Part of P0194, funded by Ember2528.
2022-05-31 22:55:33 +02:00
nmlgc 23dbb7fd61 [Decompilation] [th01] Elis: Star of David rendering
Nice that this is a dedicated function. ZUN could have easily
copy-pasted it into every pattern, just as we've seen with Konngara… 🎺

Part of P0194, funded by Ember2528.
2022-05-31 22:55:33 +02:00
nmlgc 8088f2fd35 [Decompilation] [th01] Elis: Phase 1 pattern selection
Part of P0194, funded by Ember2528.
2022-05-31 22:55:33 +02:00
nmlgc 0a4a6adda5 [Decompilation] [th01] Elis: Sprite-relative polar line blitting and unblitting
Oh hey, ZUN wrote a function to help with the very meaningful task of
expressing the Star of David's point coordinates in polar form!

Part of P0194, funded by Ember2528.
2022-05-31 22:55:33 +02:00
nmlgc 183d7a2b57 [Decompilation] [th01] Elis: Pattern 3/13
The one where Elis, on Lunatic, runs past the pellet cap of 100 by
spawning 160 slow aimed pellets along a circle in a single frame, and
that's not the only janky quirk in there.

Completes P0193, funded by Ember2528.
2022-05-31 22:55:33 +02:00
nmlgc 85a76f74a8 [Decompilation] [th01] Elis: Pattern 2/13
The one where Elis fires missiles from random locations around her
sprite, aimed at random angles towards the bottom of the playfield.

Part of P0193, funded by Ember2528.
2022-05-31 22:55:33 +02:00
nmlgc af7dd08626 [Decompilation] [th01] Elis: Pattern 1/13
The one where Elis fires 11 (yes, 11) evenly spaced lasers from her
left eye (?) across the whole playfield, from either the left or right
edge to the other one. First pattern you see in the fight.

Part of P0193, funded by Ember2528.
2022-05-31 22:55:33 +02:00
nmlgc 19f754f770 [Reverse-engineering] [th01] Elis: Common bullet spawn area
Part of P0193, funded by Ember2528.
2022-05-31 22:55:33 +02:00
nmlgc d34e5b90fa [Maintenance] [th01] Elis: Define constants for the individual entities
Part of P0193, funded by Ember2528.
2022-05-31 22:55:33 +02:00
nmlgc 6beb197ec2 [Decompilation] [th01] Elis: Move compiler-generated data to C land
Featuring the most disgusting alignment workaround yet.

Part of P0193, funded by Ember2528.
2022-05-31 22:55:33 +02:00
nmlgc 772c1730fd [Naming] [th01] Elis: Generic pattern state variable
Yup, assigning this one to Elis, even though its proximity to the rest
of the generic boss variables might suggest that it was intended as a
generic boss state variable. Nope, that idea has already demonstrated
its uglyness in the previous TH04 and TH05 pushes…

Part of P0193, funded by Ember2528.
2022-05-31 22:55:33 +02:00
nmlgc b26aaeaee5 [Naming] [th01] Missiles: Spawn function
Even ZUN once preferred nice floating-point syntax for subpixel values,
apparently. Still, `double` is massive overkill here.

Part of P0193, funded by Ember2528.
2022-05-31 22:55:33 +02:00
nmlgc 2c09fa4fe3 [Decompilation] [th01] Add a generic entity position template
It's slowly starting to make sense, as it eliminates the need for both
separate `*_COUNT` macros in places where the count isn't used for
anything else, as well as custom class declarations.

Part of P0193, funded by Ember2528.
2022-05-31 22:55:33 +02:00
nmlgc 91984de4b2 [Maintenance] [th01] Remove `extern "C"` from more areas of code
The additional hardware effect functions, as well as the High Score
menu code.

Part of P0193, funded by Ember2528.
2022-05-31 22:55:33 +02:00
nmlgc 1173a58289 [Maintenance] [th01] Use a common macro for sloppy unblitting of .GRC sprites
Part of P0193, funded by Ember2528.
2022-05-31 22:55:27 +02:00
nmlgc 1371c85526 [Maintenance] [th01] Add a helper function for rain pellets
Gravity is, in fact, a physical constant in the world of this game.

Part of P0193, funded by Ember2528.
2022-05-31 21:10:09 +02:00
nmlgc 365d8ea346 [Maintenance] [th01] Shootout lasers: Add a safe subscript wrapper
Part of P0193, funded by Ember2528.
2022-05-31 21:08:58 +02:00
nmlgc e1f3f9fe0b [Decompilation] [th04/th05] Demo Play: Reading the replay file
Yeah, nothing you'd want to use even as the base for a community-usable
replay format.

Completes P0192, funded by [Anonymous], nrook, and -Tom-.
2022-05-01 00:22:04 +02:00
nmlgc 0e26210d2b [Naming] [th02/th03/th04/th05] Rename GameCore() to GameExecl()
Looking back at the MAG.Net footage, that out-of-focus block of pixels
is clearly separated from the opening parenthesis with an `l`, with the
second word alone making up four monospaced ASCII characters. `Execl`
is also a much more descriptive name, given what the function does.

Part of P0192, funded by [Anonymous], nrook, and -Tom-.
2022-05-01 00:22:04 +02:00
nmlgc 8e06497d4b [Separate translation units] [th04/th05] vector2_near (undecompilable)
Reason: Too much micro-optimization using 32-bit registers, which
aren't supported by Turbo C++'s inline assembler. It's also just
another variation on a common function we've decompiled time and time
again.

Part of P0192, funded by [Anonymous], nrook, and -Tom-.
2022-05-01 00:22:04 +02:00
nmlgc c41bfbaf3e [Separate translation units] [th04/th05] Spark sprite spawning (undecompilable)
Reason: Saving SI and DI on the stack way too late. Just because ZUN
absolutely *had* to move the clipping condition before these two PUSH
instructions… Was it really necessary to save a total of 4 instructions
for an unlikely worst case in a function that's maybe called like 10-20
times per frame *at worst*?

Part of P0192, funded by [Anonymous], nrook, and -Tom-.
2022-05-01 00:22:04 +02:00