Commit Graph

1776 Commits

Author SHA1 Message Date
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
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
nmlgc c4cc31ee6f [Maintenance] [th05] Split segment #3 before the bullet update function
Part of P0149, funded by Blue Bolt, Ember2528, and -Tom-.
2021-07-31 09:33:50 +02:00
nmlgc 48c67d5e14 [Decompilation] [th04/th05] Common transformations from playfield space to VRAM
… quite some readability improvements in this regard.

Part of P0149, funded by Blue Bolt, Ember2528, and -Tom-.
2021-07-31 09:33:50 +02:00
nmlgc db05bffca3 [Maintenance] Turn motion_t into a template
motion_t is also used for certain animations in MAINE.EXE, so not all
instances refer to entities in playfield space. Explicitly specifying
the latter now allows us to gain…

Part of P0149, funded by Blue Bolt, Ember2528, and -Tom-.
2021-07-31 09:33:50 +02:00
nmlgc 69a3ecf8f1 [Maintenance] [th04/th05] Get rid of th04/shared.hpp
Wow, we really only used it in that first big decompilation of 2019.

Part of P0149, funded by Blue Bolt, Ember2528, and -Tom-.
2021-07-31 09:33:50 +02:00
nmlgc 7f19c72550 [Maintenance] [th04/th05] Move MAIN-specific score declarations to a new header
th04/shared.hpp was also a bad idea.

Part of P0149, funded by Blue Bolt, Ember2528, and -Tom-.
2021-07-31 09:33:49 +02:00
nmlgc a99cda80fd [Maintenance] Point out that player_invincible_via_bomb is exclusive to TH02
Will make it easier to comprehend that the bullet update function is
actually correct with regards to only looking at a single variable.
(Yes, I know, hard to believe!)

Part of P0149, funded by Blue Bolt, Ember2528, and -Tom-.
2021-07-31 09:33:49 +02:00
nmlgc 6233a3c3e3 [Research] Assigning near functions from other groups to near function pointers
Yup, P0148 didn't actually solve the issue it was meant to solve, and
I still had to research this workaround.

Part of P0149, funded by Blue Bolt, Ember2528, and -Tom-.
2021-07-31 09:33:49 +02:00
nmlgc 3e658b590d [Naming] Improve overlap macros
At least I *hope* it's an improvement. `point` should be reserved for
actual structures with .x and .y members.

Part of P0149, funded by Blue Bolt, Ember2528, and -Tom-.
2021-07-31 09:33:49 +02:00
nmlgc 3019c293e4 [Maintenance] [th04] Bullets: Rename the unused "spread + random angle" group
Well. The more random bullets at constrained angles are added to a
bullet group, the closer that group will invariably approximate a
spread shape. That's why it probably appeared as a "spread" to me in
2020. But the implementation for this group type
• neither uses any of the spread code,
• nor does it ensure a consistent angle between the bullets (which a
  hypothetical "random angle spread" group type would probably do).
Also, look at its number within the enum! How could I ever get that
confused?!

Part of P0149, funded by Blue Bolt, Ember2528, and -Tom-.
2021-07-31 09:33:49 +02:00
nmlgc b855592c0a [Maintenance] [th04/th05] Bullets: Document the random speed range
Part of P0149, funded by Blue Bolt, Ember2528, and -Tom-.
2021-07-31 09:33:49 +02:00
nmlgc af5d9c421a [Reverse-engineering] [th04/th05] Bullets: Turn zap_trigger into a union
Probably a smart choice on part of ZUN, actually.

Part of P0149, funded by Blue Bolt, Ember2528, and -Tom-.
2021-07-31 09:33:48 +02:00
nmlgc 75c4f2d3cc [Reverse-engineering] [th04/th05] Bullets: Distinguish clear and zap mechanics
And actually document them correctly.

Clear: Custom duration, awards constant points per bullet during the
       entire duration, plays a decay animation
  Zap: Fixed duration, awards a semi-exponential bonus for all bullets
       alive on the first frame, plays a, um, "zapping" animation… in
       TH04, because it's bugged in TH05 :zunpet:

Part of P0149, funded by Blue Bolt, Ember2528, and -Tom-.
2021-07-31 09:33:35 +02:00
nmlgc e1a26bb9b1 [Decompilation] [th04/th05] Player position clamping
Completes P0148, funded by [Anonymous].
2021-07-21 00:35:03 +02:00