Commit Graph

418 Commits

Author SHA1 Message Date
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 f918298770 [Decompilation] [th04/th05] Items: Splash circle spawn/update functions
Completes 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 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 4d8392ce9c [Maintenance] [th03/th04/th05] Rename `playchars_t` to `playchar_t`
Part of P0172, funded by [Anonymous] and Blue Bolt.
2021-12-27 00:52:20 +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 9ae4f7726e [Decompilation] [th05] EMS / Dialog: Face loading and rendering
Aha! TH05 actually loads every single rendered dialog image
individually before rendering it, either from the EMS area or disk.
That's one way to save memory, I guess?

Part of P0169, funded by Blue Bolt.
2021-11-29 02:01:10 +01:00
nmlgc 90a2e367bc [Decompilation] [th04] EMS / Dialog: Exit function
That's where TH04 crashes in Stage 5 without an EMS driver, but the
code is fine?! (Well, apart from its silly behavior in the Extra
Stage.)

Part of P0169, funded by Blue Bolt.
2021-11-29 02:01:10 +01:00
nmlgc 7673456ab3 [Decompilation] [th04] EMS / Dialog: Loading the remaining images
What the hell is TH05 doing there…?

Part of P0169, funded by Blue Bolt.
2021-11-29 02:01:10 +01:00
nmlgc d48479ce1b [Reverse-engineering] [th04/th05] Dialog: Face unblitting
TH01-style unblitting from the back page of VRAM, in my TH04/TH05?!
It does make sense to suspend double buffering during dialog though,
and you probably don't want to call any custom stage rendering
functions just to effectively unblit a 128×128 pixel area.

Part of P0169, funded by Blue Bolt.
2021-11-29 02:01:10 +01:00
nmlgc a1ebba2fae [Reverse-engineering] [th04/th05] Dialog: Currently speaking side
Part of P0169, funded by Blue Bolt.
2021-11-29 02:01:09 +01:00
nmlgc 1b3755c592 [Maintenance] [th04/th05] Dialog: Move UI code to a subdirectory under main/
Why did I put all that under formats/?! This doesn't even contain
anything about the format yet.

Part of P0169, funded by Blue Bolt.
2021-11-29 02:01:09 +01:00
nmlgc 8b046dad0f [Decompilation] [th04/th05] EMS: Rendering the eyecatch image
Copied in from EMS memory if available.

Completes P0168, funded by Blue Bolt and rosenrose.
2021-11-29 02:01:01 +01:00
nmlgc bd77463f59 [Decompilation] [th05] EMS: Preloading boss facesets
Oh, an EMS function that does one single thing, and is not potentially
bugged within TH05's original sprite limits?! (Although that last part
might have just been a happy accident.)

Part of P0168, funded by Blue Bolt and rosenrose.
2021-11-29 02:00:58 +01:00
nmlgc 3e99a30c17 [Decompilation] [th04/th05] EMS: Preloading player character .CDG images
Stupid one-off functions deserve stupid names, Part 3. This time also
coming with an unnecessary precondition.

Part of P0168, funded by Blue Bolt and rosenrose.
2021-11-29 02:00:03 +01:00
nmlgc fe33d49e0a [Decompilation] [th04/th05] EMS: Allocation + Preloading the eyecatch image
No, I'm not copying exactly what was on ZUN's monitor during the 2010
MAG・ネット documentary. Also, this one was very lucky not to receive
a stupid function name.

Part of P0168, funded by Blue Bolt and rosenrose.
2021-11-29 01:53:43 +01:00
nmlgc ccca7bf6ee [Reverse-engineering] [th04/th05] EMS: Cache area layout
Part of P0168, funded by Blue Bolt and rosenrose.
2021-11-29 01:53:13 +01:00
nmlgc dbd9e23bf9 [Maintenance] [th04/th05] Split segment #1 before the EMS functions
Well, except for GameCore(), which has nothing of interest.

Part of P0168, funded by Blue Bolt and rosenrose.
2021-11-28 19:15:22 +01:00
nmlgc 99aee2bdbe [Maintenance] Consistently use singular for entity structure and file names
Not too sure about "chars" yet, with TH03 and all.

Part of P0168, funded by Blue Bolt and rosenrose.
2021-11-28 19:14:02 +01:00
nmlgc a317cb49fc [Maintenance] Fix another bunch of accumulated typos
Part of P0161, funded by [Anonymous].
2021-10-09 23:26:02 +02:00
nmlgc 31d7f166b9 [Maintenance] Force the difficulty level enum to `int`
That should finally get it right, with no more casts anywhere.

Part of P0159, funded by Yanga.
2021-09-28 18:05:25 +02:00
nmlgc af2c0e14a4 [Maintenance] Adopt the peek() and poke() inline functions from <dos.h>
Which still allows us to replace a bunch of manual MK_FP() macros with
calls to these functions.

Part of P0157, funded by Yanga.
2021-09-12 17:50:41 +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 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 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 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