Commit Graph

17 Commits

Author SHA1 Message Date
nmlgc 270d376089 [Maintenance] Add min/max abstractions for constrained random numbers
Way easier to read compared to the mental gymnastics of the original
"offset + range" form, especially since we can also abstract away
subpixels with another layer of wrapper functions. Also brings a bunch
of new speed/angle symmetries to light.

Part of P0190, funded by nrook.
2022-04-30 14:37:23 +02: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 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 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 5fac2006ff [Maintenance] Consistently use "score" instead of "points"
Or at least in addition.

Part of P0172, funded by [Anonymous] and Blue Bolt.
2021-12-27 00:50:39 +01: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 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 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 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 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 0eb7e38543 [Naming] [th04/th05] Bullets: Low-level spawn functions
Part of P0149, funded by Blue Bolt, Ember2528, and -Tom-.
2021-07-31 09:33:51 +02:00