Commit Graph

1814 Commits

Author SHA1 Message Date
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
nmlgc 7211d4deeb [Maintenance] [th02] Get rid of th02.h
… remove the last of the game-specific header files, …

Part of P0186, funded by [Anonymous] and Blue Bolt.
2022-03-26 20:44:54 +01:00
nmlgc f4a73bba3f [Maintenance] Move the ring increment/decrement macros to clamp.hpp
That means we can finally…

Part of P0186, funded by [Anonymous] and Blue Bolt.
2022-03-26 20:44:54 +01:00
nmlgc 1c468eef21 [Maintenance] [th02] Put OP/MAINE globals into a single translation unit
Part of P0186, funded by [Anonymous] and Blue Bolt.
2022-03-26 20:44:42 +01:00
nmlgc 4242480b9a [Maintenance] Move the contents of `music/` subdirectories under `op/`
Making it more obvious that it's Music *Room* code, not BGM code.

Part of P0186, funded by [Anonymous] and Blue Bolt.
2022-03-25 14:10:59 +01:00
nmlgc 9432e0d2bf [Maintenance] Macros: Update to current coding standards
Less fancy token pasting, replacing them with inline functions where
possible, entirely removing unnecessary ones, and fixing smaller
issues here and there.

Part of P0186, funded by [Anonymous] and Blue Bolt.
2022-03-25 14:05:36 +01:00
nmlgc ea54e59f93 [Maintenance] Macros: Avoid references to implicit local variables
If the macro itself is local to a function, these can work in certain
scenarios, but never for global ones.

Part of P0186, funded by [Anonymous] and Blue Bolt.
2022-03-25 14:03:53 +01:00
nmlgc a21ab3d225 [Decompilation] [th04/th05] Midbosses: Defeat animation update function
This code structure is driving me insane.

Completes P0185, funded by [Anonymous], -Tom-, and Blue Bolt.
2022-03-05 17:50:33 +01:00
nmlgc b3e61807a1 [Decompilation] [th04/th05] Playfield shaking
Part of P0185, funded by [Anonymous], -Tom-, and Blue Bolt.
2022-03-05 17:50:33 +01:00
nmlgc 6bf40d71cb [Maintenance] [th04/th05] Split segment #1 before the playfield shake function
We have finally run out of letters to remove from the first segment
name in TH05! 🎉 But we surely won't have to decompile any other
function from the middle of any of these 7 segments soon, right?
Right…?

Part of P0185, funded by [Anonymous], -Tom-, and Blue Bolt.
2022-03-05 17:50:33 +01:00
nmlgc a907feacf8 [Decompilation] [th05] Lasers: Spawn and control functions
Part of P0185, funded by [Anonymous], -Tom-, and Blue Bolt.
2022-03-05 17:50:27 +01:00
nmlgc 360e07a413 [Maintenance] Add a new typedef for unsigned Q4.4 values
Part of P0185, funded by [Anonymous], -Tom-, and Blue Bolt.
2022-03-05 15:31:50 +01:00
nmlgc 3850f8aafb [Maintenance] [th05] Declare laser symbols in C land, using current conventions
Oh hey, these 2018 variable names weren't completely bad!

Part of P0185, funded by [Anonymous], -Tom-, and Blue Bolt.
2022-03-05 15:31:50 +01:00
nmlgc 96ed07f31e [Maintenance] [th05] Move laser-related code to the `main/bullets` subdirectory
Following the choice I made for TH01.

Part of P0185, funded by [Anonymous], -Tom-, and Blue Bolt.
2022-03-05 15:31:50 +01:00
nmlgc 78dcbf4b75 [Maintenance] master.hpp transition: EGC-accelerated VRAM shift functions
Part of P0185, funded by [Anonymous], -Tom-, and Blue Bolt.
2022-03-05 15:31:50 +01:00
nmlgc c63e05ed2d [Decompilation] [th05] Curved bullets: Spawn function
Part of P0185, funded by [Anonymous], -Tom-, and Blue Bolt.
2022-03-05 15:31:50 +01:00
nmlgc 944654596d [Decompilation] [th05] Curved bullets: Update function
The algorithm for gradually rotating these clockwise or counterclockwise
towards the player could have been 5 lines long. ZUN blows it up to 26
lines.

Also, a 16×16 killbox for the head node, and a 12×12 one for trail
nodes.

Part of P0185, funded by [Anonymous], -Tom-, and Blue Bolt.
2022-03-05 15:31:50 +01:00
nmlgc f918298770 [Decompilation] [th04/th05] Items: Splash circle spawn/update functions
Completes P0184, funded by -Tom-.
2022-03-05 15:31:50 +01:00
nmlgc 9e0eda1d19 [Maintenance] [th04] Split segment #3 before the item splash functions
Part of P0184, funded by -Tom-.
2022-03-05 15:31:50 +01:00
nmlgc 07b956b3ad [Maintenance] [th04/th05] Move bullet code into dedicated segments
Too bad that alignment constraints do in fact force us to compile
th04/bullet_u.cpp and th04/bullet_a.cpp separately. 😕

Part of P0184, funded by -Tom-.
2022-03-05 15:31:50 +01:00
nmlgc 9471e133e9 [Decompilation] [th05] Bullets: Sprite selection for angled bullets
Hopelessly hardcoded.

Part of P0184, funded by -Tom-.
2022-03-05 15:31:50 +01:00
nmlgc 8ff719da91 [Decompilation] [th04/th05] Bullets: Symmetric turns
Part of P0184, funded by -Tom-.
2022-03-05 15:31:50 +01:00
nmlgc 142af8f3e4 [Decompilation] [th04/th05] Bullet: Special motion velocity calculations
Part of P0184, funded by -Tom-.
2022-03-05 15:31:50 +01:00
nmlgc 1b6012b1fc [Reverse-engineering] [th04/th05] Bullets: Special motion types
Almost exactly two years after they didn't manage to fit into P0075.
Much easier to describe than TH01's.

Part of P0184, funded by -Tom-.
2022-03-05 15:31:47 +01:00
nmlgc 24219dc897 [Reverse-engineering] [th04/th05] Bullets: Parameters for special motion types
Not just the maximum bounce count. Unsurprisingly, I also did a rather
shallow job in this part of the bullet code back in 2020…

Part of P0184, funded by -Tom-.
2022-02-28 22:13:06 +01:00
nmlgc 5a8bbd2dbd [Maintenance] [th01] Pellets: Rename PM_NORMAL to PM_REGULAR
Wow. After concluding that "normal" is a difficulty level in late July
2021 (see 05e4c4a), I then spent months looking at TH01 boss code,
without once noticing that this game was still using it!

Part of P0184, funded by -Tom-.
2022-02-28 22:13:00 +01:00
nmlgc f9d983e0c0 [Decompilation] [th03] Player: Collision detection
8×8-pixel* player hitbox confirmed.

(* 8×4 in VRAM terms)

Completes P0183, funded by Yanga and [Anonymous].
2022-02-18 09:36:34 +01:00
nmlgc ff3d2cafe4 [Maintenance] Highlight dependencies on pseudoregisters with the `asm` keyword
These make up 41% of all our current inline ASM blocks, and *should*
break on other compilers.

Part of P0183, funded by Yanga and [Anonymous].
2022-02-18 09:36:34 +01:00
nmlgc ba9fe94b42 [Maintenance] Consistently use { brackets } for inline assembly
Part of P0183, funded by Yanga and [Anonymous].
2022-02-18 09:36:34 +01:00
nmlgc 6058395372 [Maintenance] Change the inline assembly keyword to `_asm`
The single underscore version is actually slightly more supported among
the compilers I've seen so far. Also added the exact list now.

Part of P0183, funded by Yanga and [Anonymous].
2022-02-18 09:36:34 +01:00
nmlgc 9ec31feef6 [Maintenance] Replace unnecessary inline assembly with pseudo-registers
Part of P0183, funded by Yanga and [Anonymous].
2022-02-18 09:36:34 +01:00
nmlgc fa998af4ca [Maintenance] [th01] Update the MDRV2 functions to current coding standards
Part of P0183, funded by Yanga and [Anonymous].
2022-02-18 09:36:34 +01:00
nmlgc c1d8e210f6 [Reverse-engineering] [th03] Player: Useless ID / attack sprite offset variable
And doubly so, with both of the values being redundant.

Part of P0183, funded by Yanga and [Anonymous].
2022-02-18 09:36:34 +01:00
nmlgc 9b28791c7f [Maintenance] [th03] Add a separate type for SPRITE16 sprite area offsets
Part of P0182, funded by Lmocinemod and [Anonymous].
2022-02-18 09:36:34 +01:00
nmlgc 49b898b6fb [Reverse-engineering] [th03] Player: Pointer to currently updated instance
Function pointers with more than 0 parameters are hard and annoying,
am I right? 😛

Part of P0183, funded by Yanga and [Anonymous].
2022-02-18 09:36:34 +01:00
nmlgc 1e2c7ad37e [Reverse-engineering] [th03] Collision bitmap: Rectangles (undecompilable)
Reason: Self-modifying. -.-

The main shape used for drawing into this bitmap. "Stripes" would have
been a better name, with only the top 2 (screen) / 1 (VRAM) out of
every 8 (screen) / 4 (VRAM) pixels inside these rectangles being
actually set as collidable inside this bitmap. If a player's hitbox
happens to be smaller than 8 (screen) / 4 (VRAM) pixels, this would
mean that a player could dodge right through two of these stripes. Same
for the CPU, which would make it obvious how it could cheat.

But are player hitboxes actually small enough for that to be possible?
Gotta add another push to find out…

(Also, wow, that's some ingenious bit twiddling right there… and it's
all completely correct. 🤯 Whether all that complexity and especially
all that register overloading would have been *necessary*, on the other
hand…)

Completes P0182, funded by Lmocinemod and [Anonymous].
2022-02-18 09:36:34 +01:00
nmlgc 07561f4824 [Reverse-engineering] [th03] Collision bitmap: Drawing vertical lines
Ironically only used for pellets, which are now confirmed to have a 2×2
(screen) / 2×1 (VRAM) hitbox. Might have been "decompilable", but it's
sandwiched between undecompilable functions.

Part of P0182, funded by Lmocinemod and [Anonymous].
2022-02-18 09:36:34 +01:00
nmlgc c04ca8da91 [Reverse-engineering] [th03] Collision bitmap: Drawing slopes (undecompilable)
Reason: Self-modifying. -.-

Only used in Chiyuri's EX Attack (the one with the diagonal lasers).

Part of P0182, funded by Lmocinemod and [Anonymous].
2022-02-18 09:36:34 +01:00
nmlgc 3072208336 [Reverse-engineering] [th03] Collision bitmap: Variables and constants
Oh wow, it's exactly how I always naively imagined collision detection
to be implemented in a fixed-resolution 2D bullet hell game with small
hitboxes.

Part of P0182, funded by Lmocinemod and [Anonymous].
2022-02-18 09:36:34 +01:00
nmlgc 31b9338824 [Naming] [th03] Player: Rendering function
Just needing this one for a mod…

Part of P0182, funded by Lmocinemod and [Anonymous].
2022-02-18 09:36:34 +01:00
nmlgc 1fd9b6a0c1 [Maintenance] Introduce factor and bit count constants for subpixels
Providing that tiny bit of additional readability.

Part of P0182, funded by Lmocinemod and [Anonymous].
2022-02-18 09:36:28 +01:00
nmlgc 70cbf4bbe1 [Maintenance] [th03] Adopt the PlayfieldPoint subpixel type from TH02/TH04/TH05
Makes sense for this game as well, even if it can only serve
documentary purpose due to it not knowing which playfield it's on.

Part of P0182, funded by Lmocinemod and [Anonymous].
2022-02-14 07:03:34 +01:00
nmlgc 313450f00a [Decompilation] [th01] Sariel: Move all data to C land
Second PC-98 Touhou boss completely decompiled, 29 to go! But meh,
ZUN's original code did in fact force the three leaf pattern sprites
into separate 1-sprite sheets…

Completes P0181, funded by Ember2528.
2022-01-31 08:31:18 +01:00
nmlgc 8b24a07a09 [Decompilation] [th01] Sariel: Main function
Part of P0181, funded by Ember2528.
2022-01-31 08:31:18 +01:00
nmlgc e0454a41bb [Decompilation] [th01] Expanding 4-stack, 32-square boss entrance rings
The final part of Kikuri's and Sariel's entrance animation.

Part of P0181, funded by Ember2528.
2022-01-31 08:31:18 +01:00
nmlgc d9228e0320 [Decompilation] [th01] Shootout lasers: Broken reset function
Whoops, 4406c3d did not actually decompile it yet.

Part of P0181, funded by Ember2528.
2022-01-31 08:31:18 +01:00
nmlgc 091f19f69b [Decompilation] [th01] Sariel: Pattern 16/16
The one where Sariel's second form shoots sparks towards the top of the
playfield, which then turn into leaf-like sprites that sway towards the
bottom, killing Reimu on contact.

And wow, what a finish! A weird "decimal subpixel" type, hardcoded
sprites, and effectively unused non-hardcoded sprites. Too bad that it
also ruins the nice `dot_rect_t(w, h)` parameter abstraction for
grcg_put_8x8_mono()…

Completes P0180, funded by Yanga.
2022-01-31 08:31:18 +01:00
nmlgc 77858c1337 [Decompilation] [th01] Sariel: Pattern 15/16
The one where ZUN copy-pasted Pattern 12, removed the expanding dotted
circle, and made it twice as long.

Part of P0180, funded by Yanga.
2022-01-31 07:18:43 +01:00
nmlgc 0393af6f0f [Decompilation] [th01] Sariel: Pattern 14/16
The one where evenly spaced, randomly aimed pellets rain down from an
imaginary horizontal line at the seal's center Y coordinate. Featuring
an equally broken symmetric spawn ray variant.

Part of P0180, funded by Yanga.
2022-01-31 07:18:43 +01:00