Commit Graph

1590 Commits

Author SHA1 Message Date
nmlgc e1fcd75cb4 [Decompilation] [th01] Konngara: Move all data to C land
And that's it! No Konngara-related code left in ASM land, first boss
complete! 30 to go :P

Part of P0156, funded by Ember2528.
2021-08-22 23:56:59 +02:00
nmlgc 6ffe87f35b [Decompilation] [th01] Konngara: Main function
Third longest function in all of PC-98 Touhou, and it's even more of a
copy-pasta than the patterns we've seen earlier. Certainly didn't feel
that long.

Part of P0156, funded by Ember2528.
2021-08-22 23:56:58 +02:00
nmlgc 8aa2b6a405 [Maintenance] [th01] Fix boss_hit_update_and_render() declarations
Part of P0156, funded by Ember2528.
2021-08-22 18:50:20 +02:00
nmlgc 9ad578ea93 [Reverse-engineering] [th01] Game clear flag
Completes P0155, funded by Ember2528.
2021-08-22 18:50:20 +02:00
nmlgc 40846cab45 [Decompilation] [th01] Konngara: Pattern 12/12
The one where 10-way spreads of pellets rain from Konngara's sleeve
every 10 frames.

Part of P0155, funded by Ember2528.
2021-08-22 18:50:20 +02:00
nmlgc 26f019385f [Decompilation] [th01] Konngara: Pattern 11/12
The one where Konngara swings their sword and fires fast aimed pellets
towards the player.
The third time we've seen the exact same basic function layout…

Part of P0155, funded by Ember2528.
2021-08-22 18:50:20 +02:00
nmlgc 9c7981fc59 [Decompilation] [th01] Konngara: Pattern 10/12
The one with lasers fired from the sword across the whole playfield,
either from left to right or from right to left, together with aimed
3-way spreads, every 10 frames.

Part of P0155, funded by Ember2528.
2021-08-22 18:50:20 +02:00
nmlgc 27c7ffaaa3 [Maintenance] [th01] Fix the type of CShootoutLaser::spawn()'s `col` parameter
Similarly to cb6367a, you also can't tell from a function's ASM whether
a parameter that's assigned to an 8-bit destination is actually an 8-bit
parameter, or a narrowed 16-bit parameter. That can really only be
gleaned from looking at all call sites…

Part of P0155, funded by Ember2528.
2021-08-22 18:50:20 +02:00
nmlgc 4fe260f7d5 [Decompilation] [th01] Konngara: Pattern 9/12
The one where Konngara swings their sword and spawns triangle-shaped
subpatterns along the slash path.
At least no randomness in that one.

Part of P0155, funded by Ember2528.
2021-08-22 18:50:20 +02:00
nmlgc 031b526421 [Decompilation] [th01] Konngara: Pattern 8/12
The one where Konngara swings their sword and lets pellets rain along
the (surprisingly triangular) slash path.
Yeah… not worth expressing these coordinates in playfield space when
they clearly correspond to specific locations in the background image.

Completes P0154, funded by Ember2528.
2021-08-22 18:50:20 +02:00
nmlgc 6647e3ed5f [Decompilation] [th01] Konngara: Sword slash animation
Switches are bad, right?

Part of P0154, funded by Ember2528.
2021-08-22 18:50:05 +02:00
nmlgc 2b84f81b53 [Decompilation] [th01] Konngara: Pattern 7/12
The one where Konngara shoots rays in a semicircle motion from their
sword to the edge of the playfield, with pellets raining down from the
ray's end point.

Insert "if… else if… else if…" joke. And hey, I've finally had the idea
to use function-local enums in place of #define!

Part of P0154, funded by Ember2528.
2021-08-22 18:47:26 +02:00
nmlgc eb3d214eca [Decompilation] [th01] Konngara: Pattern 6/12
The one with four homing snakes. Almost entirely copy-pasted from the
two-snake version.

Part of P0154, funded by Ember2528.
2021-08-22 18:46:24 +02:00
nmlgc f023655599 [Decompilation] [th01] Konngara: Pattern 5/12
The one with lots of single bullets being sprayed from Konngara's cup.
Featuring ridiculous aiming.

Part of P0154, funded by Ember2528.
2021-08-22 18:41:39 +02:00
nmlgc d05c9ba688 [Decompilation] [th01] Konngara: Pattern 4/12
The one where a gray diamond first flies from Konngara's left sleeve to
the top of the playfield, and then moves downwards in rows from left to
right and back, shooting aimed pellets along the way.

Completes P0153, funded by Ember2528.
2021-08-22 18:37:32 +02:00
nmlgc f679574389 [Decompilation] [th01] Konngara: Pattern 3/12
The one with two homing snakes, and pellets fired in a semicircle
spread. And yes, Reimu really has a 30×30-pixel hitbox against the
snakes.

Much simpler than its instruction count might suggest. Recalculating
array element addresses over and over is certainly a way to add bloat…
And yes, we're going to see all of this exact same code again in the
four-snake pattern.

Part of P0153, funded by Ember2528.
2021-08-22 16:14:33 +02:00
nmlgc e5a76f873b [Decompilation] [th01] Konngara: Pattern 2/12
The one where Konngara fires symmetrical bullets from their cup,
downwards, every 8 frames over 200 frames.

Part of P0153, funded by Ember2528.
2021-08-22 15:31:20 +02:00
nmlgc a99eb4ed44 [Decompilation] [th01] select_for_rank: Don't redeclare the rank variable
Otherwise, it gets quite annoying to use that variable in the rest of
the translation unit.

Part of P0153, funded by Ember2528.
2021-08-22 15:07:17 +02:00
nmlgc 945f7991a1 [Decompilation] [th01] Add inline functions for the player's center position
Part of P0153, funded by Ember2528.
2021-08-22 15:06:08 +02:00
nmlgc 18757c33f9 [Maintenance] [th01] Use a common macro for sloppy unblitting of 8×8 sprites
… treating them as conceptually the same thing allows us to deduplicate
these macros.

Part of P0153, funded by Ember2528.
2021-08-22 15:03:15 +02:00
nmlgc 308b73524d [Maintenance] [th01] Merge invincibility sprites into the regular 8×8 shapes
They have the same size, their hardcoded sprites are stored next to
each other in the code, and…

Part of P0153, funded by Ember2528.
2021-08-22 14:55:54 +02:00
nmlgc cd969d543b [Decompilation] [th01] Add width and height getters for DotRect
Would be a lot more useful if ZUN's code were better.

Part of P0153, funded by Ember2528.
2021-08-22 14:52:00 +02:00
nmlgc 624e0cbff6 [Readme] Add a workaround for `Error: Unable to execute command 'tlink.exe'`
Caused by TCC needlessly copying the PATH variable into a 128-byte
buffer.
2021-08-02 22:59:03 +02:00
nmlgc a54fef59d6 [Readme] Move the TLINK `Loader error` fix to a new Troubleshooting section
There will be more trouble in need to be shot.
2021-08-02 21:47:01 +02:00
nmlgc 81fc86150d [Decompilation] [th05] Aiming to the player
Completes P0152, funded by -Tom- and [Anonymous].
2021-07-31 21:09:37 +02:00
nmlgc 101684c235 [Separate translation units] [th05] Rank-based speed tuning
Also not worth decompiling, because:
• It would break return value semantics
• The algorithm is identical to TH04 (except for that one divisor)
• Small function
• Next to a bunch of more critical, undecompiled functions
• Decompilation would be messy anyway

Part of P0152, funded by -Tom- and [Anonymous].
2021-07-31 21:09:37 +02:00
nmlgc 18d4aa43f8 [Reverse-engineering] [th05] Bullets: Spawn wrappers
And that's it! Finally RE'd every bullet spawning function in TH04 and
TH05! 🎉
These really aren't worth adding a translation unit for either, in the
end. Not least because they decide to keep bullet_template.speed from
being mutated via PUSH and POP, which we can only express via inline
assembly in C land.

Part of P0152, funded by -Tom- and [Anonymous].
2021-07-31 21:09:36 +02:00
nmlgc 6127ca0ec1 [Reverse-engineering] [th05] Bullets: Velocity and angle calculation (undecompilable)
Reason: That switch statement. How should we even?

Well, the code *is* fairly good. After looking very deep into it, and
spending 35% of that function on blank lines (for logical grouping) and
explanatory comments, that is…

Part of P0152, funded by -Tom- and [Anonymous].
2021-07-31 21:09:36 +02:00
nmlgc 4d3a1eace8 [Decompilation] [th05] Bullets: Clipping and pre-spawn hit test
Deciding whether to decompile this one or not seemed to be a tough
choice. Should we *really* introduce two more translation units just
for the sake of decompiling another function that's identical to its
TH04 counterpart anyway?
Well, turns out it actually isn't: TH05 does in fact *not* immediately
clip bullets that are spawned on top of the player. Which might sound
like it has a notably different effect on gameplay… except that it
doesn't.
So yeah, good we've decompiled it, and got to show that more clearly.

Part of P0152, funded by -Tom- and [Anonymous].
2021-07-31 21:09:30 +02:00
nmlgc e9788d8519 [Maintenance] [th05] Correctly declare the rank-based speed tuning function
And actually rename to "tune", which is what we use everywhere else.

Part of P0152, funded by -Tom- and [Anonymous].
2021-07-31 20:19:33 +02:00
nmlgc b0a2621296 [Reverse-engineering] [th05] Bullets: Spawn function (undecompilable)
Reason: Self-modifying. -.- And saving SI and DI on the stack way too
late.
Luckily, it's mostly identical to TH04's version I decompiled earlier,
only (thankfully) combining regular and special bullets into one
function, and integrating TH05-specific improvements.

Part of P0152, funded by -Tom- and [Anonymous].
2021-07-31 20:19:33 +02:00
nmlgc 9ff0033a0c [Reverse-engineering] [th05] Bullets: Far wrapper for regular bullet spawning
Only used for the revenge bullets fired from Stage 3 Alice's barrier.
Not worth creating a separate translation unit, especially since the
function above is undecompilable as well…

Part of P0152, funded by -Tom- and [Anonymous].
2021-07-31 20:19:33 +02:00
nmlgc 217ee589ea [Maintenance] [th04/th05] Move ASM land gather declarations to their own file
TH05's undecompilable bullet spawn code needs them, adding yet another
dumb file that we'll always have to drag along…

Part of P0152, funded by -Tom- and [Anonymous].
2021-07-31 20:19:33 +02:00
nmlgc ddc6c1aa3f [Reverse-engineering] [th05] Bullets: Fix wrongly RE'd slowdown logic
Spent 4 pushes on the basic types and constants in 2020, still ended up
up getting this wrong and documenting the opposite of what TH05 actually
does…

Part of P0152, funded by -Tom- and [Anonymous].
2021-07-31 20:19:33 +02:00
nmlgc 4d24ca53bd [Decompilation] [th04/th05] Bullets: Update function
… (24 + (difficulty * 8) + rank) in TH04, and (42 + (difficulty * 8))
in TH05. Also, TH05 only doesn't have TH04's bullet zap animation
because ZUN didn't consistently use constants…

Completes P0151, funded by Blue Bolt and -Tom-.
2021-07-31 20:19:33 +02:00
nmlgc 0d7fc5af77 [Decompilation] [th04/th05] Turbo/Slow Mode slowdown
Slow Mode only does one thing: It looks at how many 8×8 pellets or
16×16 bullets are alive, and reduces the frame rate by 33% (i.e., turns
every second frame into two frames) if that number is…

Part of P0151, funded by Blue Bolt and -Tom-.
2021-07-31 20:19:33 +02:00
nmlgc 6eecba1bea [Reverse-engineering] [th05] Bullets: Slowdown cause flag
Effectively unused.

Part of P0151, funded by Blue Bolt and -Tom-.
2021-07-31 20:19:33 +02:00
nmlgc 4ae5e471f0 [Maintenance] [th04/th05] Declare all public spark functions in C land
Part of P0151, funded by Blue Bolt and -Tom-.
2021-07-31 20:19:33 +02:00
nmlgc 3f2077e9c5 [Reverse-engineering] [th04/th05] Per-difficulty graze score
Part of P0151, funded by Blue Bolt and -Tom-.
2021-07-31 20:19:33 +02:00
nmlgc 768251d268 [Decompilation] [th04] Bullets: Special spawn function
Completes P0150, funded by Blue Bolt.
2021-07-31 20:19:33 +02:00
nmlgc 18e755d99b [Decompilation] [th04] Bullets: Regular spawn function
Part of P0150, funded by Blue Bolt.
2021-07-31 20:19:32 +02:00
nmlgc d876eeb7bd [Decompilation] [th04] Bullets: Clipping and pre-spawn hit test
First place to confirm the hitbox of both the 8×8 pellets and the 16×16
sprite bullets!

Well, "hitbox". It's really more of a kill delta of 8×8 pixels between
the center points of a bullet and the player. You can distribute these
pixels to any combination of bullet and player "hitboxes" that make up
8×8. 4×4 around both the player and bullets? 1×1 for bullets, and 8×8
for the player? All equally valid… or perhaps none of them, once you
keep in mind that other entity types might have different kill deltas,
which turns the concept of a "hitbox" into just a confusing abstraction.

Part of P0150, funded by Blue Bolt.
2021-07-31 20:19:26 +02:00
nmlgc a49c854adc [Reverse-engineering] [th04] *Actual* player hit flag -.-
Lol, what a hilarious "off-by-one" copy-pasting fail of mine 🤪

Part of P0150, funded by Blue Bolt.
2021-07-31 16:15:36 +02:00
nmlgc 4cbeadde96 [Decompilation] [th04] Bullets: Sprite selection by angle
Part of P0150, funded by Blue Bolt.
2021-07-31 16:15:36 +02:00
nmlgc 81c3de0057 [Decompilation] [th04] Bullets: Rank-based speed tuning
TH05's version, which we saw way back in ac7e6bc, is almost identical
and can be used for any speed, whereas this one is hardcoded to modify
only the speed in the bullet template.

Part of P0150, funded by Blue Bolt.
2021-07-31 16:15:36 +02:00
nmlgc bdf21f0f07 [Reverse-engineering] Clarify the effect of invalid pellet groups in TH01
Not the same as the recent TH04 discovery.

Part of P0150, funded by Blue Bolt.
2021-07-31 16:15:36 +02:00
nmlgc 2c52bb5ef3 [Decompilation] [th04] Bullets: Velocity and angle calculation
`switch` statements compiling to binary searches if the range of values
is nasty enough? That's so cool. Apart from a few places in TH02,
this is the only place in PC-98 Touhou to show off that Turbo C++
optimization.

That code's still unexpectedly janky for what you'd expect from the 4th
game in the series, though.

Part of P0150, funded by Blue Bolt.
2021-07-31 16:15:32 +02:00
nmlgc f99aa1ae29 [Decompilation] [th04] Bullets: Bypassing rank-based speed tuning
Still way premature to say things like "the base speed of a bullet
aroup is not affected by difficulty, only by rank". (Which also would
be a way less meaningful statement than you might think it is.)

Part of P0150, funded by Blue Bolt.
2021-07-31 09:33:51 +02:00
nmlgc 4d7c8bb21f [Decompilation] [th04] Bullets: Pointless per-difficulty spawn wrappers
Not even "debugging reasons" could explain the presence of these
functions adequately…

Part of P0150, funded by Blue Bolt.
2021-07-31 09:33:51 +02:00
nmlgc 05e4c4a80c [Naming] [th04/th05] Bullets: Mid-level regular/special spawn wrappers
Too bad that it would have made no sense to call them "goofy bullets".
"Regular" is also a better name than "normal" (which is a difficulty!).

Completes P0149, funded by Blue Bolt, Ember2528, and -Tom-.
2021-07-31 09:33:51 +02:00