Commit Graph

26 Commits

Author SHA1 Message Date
nmlgc 650c1e3364 [Maintenance] Review any redundancies and label them as ZUN bloat
Or quirk, in the case of the slow TH01 ending picture blitting.

Part of P0216, funded by JonathKane.
2022-08-16 01:43:14 +02:00
nmlgc c4302b4ab7 [Maintenance] [th01] #include common.h from the resident structure header
Part of P0216, funded by JonathKane.
2022-08-16 01:41:14 +02:00
nmlgc b60a23e737 [Naming] [th01] Rename `done` to `player_is_hit`
One disgusting abuse of this flag shouldn't ruin a perfectly adequate
variable name, and force a dependency on input variables on every
gameplay-related translation unit. Especially since the "ZUN bloat"
convention allows us to clearly highlight it.

Part of P0214, funded by Ember2528.
2022-08-14 23:16:40 +02:00
nmlgc cf95cc8717 [Maintenance] [th01] Remove `extern "C"` from all remaining areas of code
Nothing says "we're getting things done" quite as much as this.

Part of P0214, funded by Ember2528.
2022-08-14 23:03:15 +02:00
nmlgc 515b4c6315 [Decompilation] [th01] YuugenMagan: Move all data to C land
And that's it! All TH01 bosses fully decompiled, which makes 8 PC-98
Touhou bosses in total with 23 to go! And now, time to move a whole lot
of other data…

Completes P0210, funded by Arandui and Yanga.
2022-08-08 20:15:10 +02:00
nmlgc 149fbca7bd [Decompilation] [th01] YuugenMagan: Eye open/close + 邪 recoloring function
Where ZUN manages to sneak in an integer overflow that, whether
intended or not, ends up defining the on-screen 邪 color in every phase
starting from the 6th one. What a great final piece of TH01 boss code…

Completes of P0210, funded by Arandui and Yanga.
2022-08-08 20:15:04 +02:00
nmlgc 5030867f75 [Decompilation] [th01] YuugenMagan: Main function
Whew, here we go, the beast. 1 function in ZUN's binary that really
should have been at least 49 functions.

Completes of P0209, funded by Yanga.
2022-08-08 20:14:55 +02:00
nmlgc 239a3ecd86 [Naming] [th01] YuugenMagan: Eye open/close + 邪 recoloring function
But of course, we still have to name this one, because ZUN just had to
put its definition after the main function. Speaking of which though,
now it's time for the big one…

Completes P0208, funded by GhostPhanom and Yanga.
2022-08-08 20:14:08 +02:00
nmlgc 3770b0c403 [Decompilation] [th01] YuugenMagan: Regular pentagram unblit/render function
Second to last helper function in this fight. 50 functions remaining in
all of TH01!

Part of P0208, funded by GhostPhanom and Yanga.
2022-08-08 20:13:29 +02:00
nmlgc f186169e59 [Decompilation] [th01] YuugenMagan: Spawning missiles from the southern eyes
Part of P0208, funded by GhostPhanom and Yanga.
2022-08-08 20:13:23 +02:00
nmlgc 8ee20b1938 [Decompilation] [th01] YuugenMagan: Phase 1 pellet pattern
The one where the lateral eyes fire aimed 2-spread pellets with
increasing speeds at various intervals, ending with a single aimed
pellet.

Part of P0208, funded by GhostPhanom and Yanga.
2022-08-08 20:13:17 +02:00
nmlgc 68562bb006 [Decompilation] [th01] YuugenMagan: Downwards 1-pixel lasers during phase 0
Fun fact: The laser from the rightmost eye has a hitbox that's 24
pixels larger than the other ones…
But yeah, nothing that resembles the pattern functions from the other
fights in this one, and even the functions that sort of do leave their
cleanup to the big main function. No sense in numbering them this time.

Part of P0208, funded by GhostPhanom and Yanga.
2022-08-08 20:13:10 +02:00
nmlgc b3921f34a6 [Decompilation] [th01] YuugenMagan: Sprite freeing
Part of P0208, funded by GhostPhanom and Yanga.
2022-08-08 20:13:04 +02:00
nmlgc 37968b9c4b [Decompilation] [th01] YuugenMagan: Unused formula
(((a - b) × √3) / 2)? Mysterious.

Part of P0208, funded by GhostPhanom and Yanga.
2022-08-08 20:12:59 +02:00
nmlgc 6f05a1bbf8 [Reverse-engineering] [th01] YuugenMagan: Eye distances
Turns out that we can define the magic numbers used in the pentagram
shrink effect in terms of the distances between the eyes and the
pentagram's target position in the center of the playfield. Therefore,
specifying the eye positions in raw pixel coordinates won't give the
full picture (who would have thought).

Part of P0208, funded by GhostPhanom and Yanga.
2022-08-08 20:12:51 +02:00
nmlgc c26ef4bdeb [Reverse-engineering] [th01] YuugenMagan: Eye sprite IDs
Completes P0207, funded by GhostPhanom.
2022-08-08 20:12:03 +02:00
nmlgc 2db58cb3d9 [Maintenance] [th01] Boss entities: Rewrite the entity array as 5 variables
Nooooo, the static initialization code proves that `boss_entities`
couldn't have been an array in ZUN's code! 😢 Which in turn explains
why YuugenMagan's and Elis' code looks the way it does. We could go
into undefined behavior territory and just cast `boss_entity_0` to a
pointer, but let's better not annoy future port authors just for my
personal convenience. In turn, we need to get a bit clever with some of
Elis' code to replace the now wholly redundant `elis_entity_t` type,
but it's not all too bad.

Part of P0207, funded by GhostPhanom.
2022-08-08 20:11:33 +02:00
nmlgc cac520e466 [Maintenance] [th01] Bosses: Rewrite Orb hitboxes in a visually correct way
You know that things are complicated when you have to resort to Unicode
box drawing character art to explain how two hitboxes relate to each
other. I *hope* this makes enough sense, and that I won't be rewriting
this in terms of ORB_W and ORB_H after all in the future. For now
though, it's immediately obvious when the hitbox reaches outside the
entity. In the case of YuugenMagan, it even simplifies the coordinates
so much that we don't need separate constants.

Part of P0205, funded by [Anonymous] and Yanga.
2022-07-17 19:29:04 +02:00
nmlgc 853952b610 [Maintenance] [th01] Boss entities: The hitbox method relates to the *orb*
I keep getting confused when reading the code.

Part of P0205, funded by [Anonymous] and Yanga.
2022-07-17 19:27:47 +02:00
nmlgc 001033d15a [Maintenance] [th01] Remove `extern "C"` from more areas of code
The .GRC and .GRP functions, to be specific.

Part of P0203, funded by [Anonymous] and GhostRiderCog.
2022-07-10 13:09:12 +02:00
nmlgc 3f52d9a16f [Decompilation] [th01] YuugenMagan: Sprite loading and initial variables
Doing this one now allows us to completely get rid of a bunch of ASM
land declations…

Part of P0202, funded by [Anonymous] and Yanga.
2022-06-25 18:21:08 +02:00
nmlgc 6f2881f056 [Maintenance] Remove `extern "C"` from more areas of code
The .PTN functions, vector functions, and egc_copy_rect_1_to_0_1()
(finally!) from TH01, as well as playfld.hpp from all games(finally!),
together with a bunch of other functions in their vicinity.

Part of P0201, funded by Ember2528 and Yanga.
2022-06-24 23:28:19 +02:00
nmlgc e4343b2c95 [Maintenance] [th01] Better distinguish boss "entities" from "other sprites"
Part of P0174, funded by Ember2528.
2022-01-31 05:15:04 +01:00
nmlgc 7bf183621c [Reverse-engineering] [th01] Bosses: .PTN slot IDs
Common sense: Entity backgrounds always go into slot X, missile sprites
into slot Y, and wave sprites into slot Z
ZUN: "Nah, let's set aside two slots, and bosses can just freely use
them as they want 🎺"

Part of P0165, funded by Ember2528.
2021-11-07 22:50:28 +01:00
nmlgc dc9e3ee475 [Decompilation] [th01] Bosses: Collision handling
Functions with 12 parameters are hard to describe, y'know. Looking
forward to decompiling these giant expressions for the actual
boss↔orb collision parameter passed to this function…

Oh well, at least we're now totally ready for some boss code next
year. 😌

Completes P0131, funded by Yanga.
2020-12-18 01:38:52 +01:00
nmlgc d5fd70c458 [Decompilation] [th01] HUD: HP rendering
And we're right back to things not being nice. Because yeah, why
shouldn't these three distinct rendering functions be part of a single
function, selected by magic numbers?
Or why shouldn't the 16×16 wrapper around a 32×32 set of graphics
functions be used to handle backgrounds for 16×8 sprites, resulting in
needlessly complex parameter calculations that lead to sloppy code?

Part of P0131, funded by Yanga.
2020-12-18 01:38:48 +01:00