Commit Graph

685 Commits

Author SHA1 Message Date
nmlgc e97a869e90 [Maintenance] [th01] Compile all remaining C code as C++
And all that it needed was a few ellipses.

Part of P0212, funded by GhostRiderCog, Lmocinemod, and LeyDud.
2022-08-11 15:50:19 +02:00
nmlgc d398a949fc [Decompilation] High score menu: Move all data to C land
Completes P0211, funded by Lmocinemod and Arandui.
2022-08-08 20:16:29 +02:00
nmlgc 6e36dfd93b [Decompilation] [th01] Verdict screen: Move all data to C land
Part of P0211, funded by Lmocinemod and Arandui.
2022-08-08 20:16:25 +02:00
nmlgc 64fe9bbff9 [Decompilation] [th01] Endings: Common beginning
Part of P0211, funded by Lmocinemod and Arandui.
2022-08-08 20:16:21 +02:00
nmlgc 54653a33c3 [Decompilation] [th01] Boss entities and animations: Move all data to C land
Part of P0211, funded by Lmocinemod and Arandui.
2022-08-08 20:16:16 +02:00
nmlgc 00f3cacc5e [Translation unit catch-up] [th01] Archive functions
That was the one piece of technical debt in TH01 we've been carrying
around since March 2015! (0fd7f14)

Part of P0211, funded by Lmocinemod and Arandui.
2022-08-08 20:16:11 +02:00
nmlgc 5fa0cd5a86 [Decompilation] [th01] .GRC / 8×8 shapes: Move all data to C land
Part of P0211, funded by Lmocinemod and Arandui.
2022-08-08 20:16:05 +02:00
nmlgc 624799bff2 [Decompilation] [th01] Items: Move all data to C land
Part of P0211, funded by Lmocinemod and Arandui.
2022-08-08 20:16:01 +02:00
nmlgc 459f3db4bd [Decompilation] [th01] HUD: Move all data to C land
Part of P0211, funded by Lmocinemod and Arandui.
2022-08-08 20:15:57 +02:00
nmlgc a2200fef28 [Decompilation] [th01] Stage timer: Move all data to C land
Part of P0211, funded by Lmocinemod and Arandui.
2022-08-08 20:15:53 +02:00
nmlgc d29b128915 [Decompilation] [th01] Player / REIIDEN.EXE .PTN: Move most data to C land
Part of P0211, funded by Lmocinemod and Arandui.
2022-08-08 20:15:45 +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 813d54fd0d [Decompilation] [th01] Line bullets
Not really "lasers", as they're also what YuugenMagan's pentagram is
made out of.

Part of P0207, funded by GhostPhanom.
2022-08-08 20:11:57 +02:00
nmlgc abe7d4f1ba [Maintenance] [th01] Pellets: Clarify the bounce-from-top motion types
They really are no different from regular pellet motion until they
reach the top of the playfield. Also, part 2 of 5a8bbd2.

Part of P0207, funded by GhostPhanom.
2022-08-08 20:11:51 +02:00
nmlgc 11dd60e67e [Maintenance] [th01] Define select_for_rank() as `static`
Part of P0207, funded by GhostPhanom.
2022-08-08 20:11:45 +02:00
nmlgc 45a9463def [Maintenance] [th01] Elis: Move pattern data section before the *_load() call
That's the same place it is (and will be) declared for all other
bosses in this game.

Part of P0207, funded by GhostPhanom.
2022-08-08 20:11:38 +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 55ced3bada [Naming] [th01] Boss entities: Clarify that the lock also applies to rendering
You don't get the full picture of YuugenMagan's rendering calls
otherwise.
It's also really stupid in how it trades performance for flickering.

Part of P0207, funded by GhostPhanom.
2022-08-08 20:11:27 +02:00
nmlgc fb72ea5be6 [Maintenance] [th01] Boss entities: Move Orb hitbox setter to collision section
Part of P0207, funded by GhostPhanom.
2022-08-08 20:11:22 +02:00
nmlgc e5ca2928d2 [Maintenance] [th01] Text mode functions: ZUN's proprietary attribute bits
Again (2113031), very helpful for debugging.

Part of P0207, funded by GhostPhanom.
2022-08-08 20:11:16 +02:00
nmlgc cfea4971ee [Maintenance] [th01] Publicly define clock direction constants
Part of P0207, funded by GhostPhanom.
2022-08-08 20:11:11 +02:00
nmlgc a10fe95b31 [Maintenance] Fix comment↔code associations
• Comments that describe all lines of code until a blank one are placed
  into the lines immediately above
• Comments that describe an entire demarcated block are placed
  immediately below the dash row at the top
• In any case, there should be a blank line after the top comment of
  a demarcated block, to keep IntelliSense-style systems from applying
  the block comment to the first actual line of code…
• …but there shouldn't be one before the dash row at the bottom, where
  it'd be redundant.

Part of P0207, funded by GhostPhanom.
2022-08-08 20:10:53 +02:00
nmlgc 386d9cd4cb [Contributing] Establish a more greppable convention for space-saving `union`s
How did I end up with x86 registers of all things?

Part of P0207, funded by GhostPhanom.
2022-08-08 20:10:47 +02:00
nmlgc 456768a4ff [Contributing] Define `struct`, `class` and `template` naming conventions
Again, these are what I've been mostly following, apart from a few
inconsistencies which this commit also fixes.

Part of P0207, funded by GhostPhanom.
2022-08-08 20:10:38 +02:00
nmlgc 454c105483 [Research] [th01] Konngara: Discover the cause behind the green discoloration
Yup, if it weren't for that one boss function periodically resetting
the palette to the other global one, this discoloration would be
permanent.

Completes P0206, funded by Yanga and [Anonymous].
2022-07-17 20:46:02 +02:00
nmlgc f629b45ce7 [Research] [th01] Mima: Explain the palette resets in the hop pattern
The source: The boss invincibility flash effect, which ends up
unconditionally resetting the palette periodically. But wait, could
that maybe…?

Part of P0206, funded by Yanga and [Anonymous].
2022-07-17 20:46:02 +02:00
nmlgc fa46d71f2e [Decompilation] [th01] Merge segment 32 into a single translation unit
Part of P0206, funded by Yanga and [Anonymous].
2022-07-17 20:46:02 +02:00
nmlgc f933b619b5 [Decompilation] [th01] Mima: Move all data to C land
7th PC-98 Touhou boss completely decompiled, 24 to go!

Part of P0206, funded by Yanga and [Anonymous].
2022-07-17 20:46:02 +02:00
nmlgc 04d12e8d5f [Decompilation] [th01] Mima: Main function
Part of P0206, funded by Yanga and [Anonymous].
2022-07-17 20:32:20 +02:00
nmlgc 6fb3f11c98 [Decompilation] [th01] Mima: Pattern 8/8
The one where ZUN finally uses the corner points for the current frame
as the spawn point for Mima's aimed lasers. 60 functions remaining in
TH01!

Part of P0206, funded by Yanga and [Anonymous].
2022-07-17 20:26:51 +02:00
nmlgc 0d85cfa44d [Decompilation] [th01] Mima: Pattern 7/8
The one where Mima sprays slow pellets from the corner points of the
rotating square around her from 8 frames ago, aimed in a half-circle
motion from her left to her right side and back.

Part of P0206, funded by Yanga and [Anonymous].
2022-07-17 20:23:28 +02:00
nmlgc 33481c857e [Decompilation] [th01] Mima: Pattern 6/8
The one where Mima fires missiles from the corner points of the
rotating square around her from 8 frames ago, aimed along a static
downwards half-circle from her right to her left side, with 16 frames
between the individual missile groups.

Part of P0206, funded by Yanga and [Anonymous].
2022-07-17 20:19:01 +02:00
nmlgc e2c82d8ebe [Decompilation] [th01] Mima: Pattern 5/8
The one where Mima spawns 8 flame pillars, 20 frames apart, at very
specifically calculated random positions, followed by an aimed 3-spread
after each pillar has reached its maximum height.

Part of P0206, funded by Yanga and [Anonymous].
2022-07-17 20:16:12 +02:00
nmlgc 6b1329d6cf [Decompilation] [th01] Mima: Flame pillar rendering
Part of P0206, funded by Yanga and [Anonymous].
2022-07-17 20:15:54 +02:00
nmlgc 327730fca5 [Decompilation] [th01] Mima: Pattern 4/8
The one where Mima hops over ⅕ of the playfield 4 times in a row,
starting at either the left or right edge, while darkening the screen…
or not?

Completes P0205, funded by [Anonymous] and Yanga.
2022-07-17 20:09:42 +02:00
nmlgc 1772a2907a [Decompilation] [th01] Mima: Pattern 3/8
The one where Mima takes the final static part from the first pattern,
and replicates it with two squares that rotate in opposite directions.
Also demonstrates the 34th unblitting bug in this game.

Part of P0205, funded by [Anonymous] and Yanga.
2022-07-17 20:05:47 +02:00
nmlgc 12eb04cc9c [Decompilation] [th01] Mima: Pattern 2/8
The one where Mima spawns missiles from the corner points of the
rotating square around her from 8 frames ago, aimed to Reimu's position
before any missiles were spawned.

Part of P0205, funded by [Anonymous] and Yanga.
2022-07-17 20:03:00 +02:00
nmlgc 6a6b800882 [Decompilation] [th01] Mima: Pattern 1/8
The one where Mima spawns aimed and later static pellets from the
corner points of the rotating square around her from 8 frames ago.

Part of P0205, funded by [Anonymous] and Yanga.
2022-07-17 19:57:42 +02:00
nmlgc 5896752e93 [Decompilation] [th01] Mima: Regular polygon construction
Looks like we've got another massive copy-pasta incoming…

Part of P0205, funded by [Anonymous] and Yanga.
2022-07-17 19:56:36 +02:00