Commit Graph

173 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 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 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 8426f3e13f [Maintenance] Make the playfield fraction functions available to ≥TH02
Part of P0146, funded by -Tom- and Ember2528.
2021-06-09 23:10:01 +02:00
nmlgc 08bc188e7d [Decompilation] [th01] Konngara: Pattern 1/12
The one where Konngara fires 4 diamonds in a cross-shaped motion
towards the edges of the screen, with random pellets raining down for
200 frames afterwards.

Completes P0142, funded by Yanga.
2021-05-27 20:21:21 +02:00
nmlgc 06c4694501 [Decompilation] Add inline functions to calculate playfield fractions
Oh no, another place in which I'm going too far?! Just because I'm sick
of hardcoded number literals after 6 years? Hm…

Part of P0142, funded by Yanga.
2021-05-27 20:21:21 +02:00
nmlgc a2bc97c413 [Naming] [th01] Konngara: Generic pattern state variable
Correctly typed local variables still weren't quite in fashion yet.

Part of P0142, funded by Yanga.
2021-05-27 20:21:20 +02:00
nmlgc 09231dc23f [Decompilation] [th01] Konngara: Sword slash rendering
"Rendering".

Part of P0142, funded by Yanga.
2021-05-27 20:21:20 +02:00
nmlgc 499472e8e4 [Decompilation] [th01] Konngara: Face rendering
And that's everything about it already.

Part of P0142, funded by Yanga.
2021-05-27 20:21:19 +02:00
nmlgc 94c1796869 [Decompilation] [th01] Konngara: Sprite freeing
Part of P0142, funded by Yanga.
2021-05-27 20:21:18 +02:00
nmlgc 4fe93d3699 [Decompilation] [th01] Konngara: Initial variables
Part of P0142, funded by Yanga.
2021-05-27 20:21:17 +02:00
nmlgc 8a5a9accd6 [Maintenance] Rename pellet/bullet "patterns" to "groups"
We're going to need some name for the longer, boss-specific danmaku
animations. Turns out that these are exactly called "patterns" in
Sparen's glossary:

	https://sparen.github.io/ph3tutorials/ddsg0.html#sub4

So what we called a "pattern" is actually called a "group". Whoops!

Part of P0142, funded by Yanga.
2021-05-27 20:21:09 +02:00
nmlgc cb6367a54b [Maintenance] [th01] Fix the type of CPellets::add_single()'s `angle` parameter
Amazing how both an `int` and an `unsigned char` parameter generate the
exact same ASM if they're only passed on to a single function that
widens them to a 16-bit type.

Part of P0142, funded by Yanga.
2021-05-27 19:36:04 +02:00
nmlgc 76a1d8d65e [Reverse-engineering] [th01] Bosses: Current phase
Part of P0142, funded by Yanga.
2021-05-27 19:36:04 +02:00
nmlgc 5afee78f33 [Decompilation] [th01] Konngara: Loading and entrance animation
It's script-like code, what can you say. Maybe minimally sloppy in some
places, but ultimately harmless.

Oh, the Siddhaṃ seed syllables are supposed to show up immediately, with
no delay between them? Good to know – clocking your emulator too low
tends to roll them down from the top of the screen, and does add a
noticeable delay between the individual images.

… Wait, but this means that ZUN could have *intended* this "effect".
Why else would he not only put those syllables into four individual
images, but also show them on the foreground VRAM page?

Completes P0141, funded by [Anonymous] and rosenrose.
2021-05-27 19:36:03 +02:00
nmlgc 6c21ba15dc [Decompilation] [th01] Konngara: Pellet spawn ray rendering
Part of P0141, funded by [Anonymous] and rosenrose.
2021-05-27 19:36:03 +02:00
nmlgc eba61444ce [Decompilation] [th01] Boss entities: Outer loading function
ASM land had a macro for this, which suggested a corresponding inlined
class method in C++ land. We couldn't use that macro for Konngara's
third boss entity though. So I probably wanted to wait with that inline
function until the decompilation of that Konngara load call, which
could verify the existence of said inline function. And it did!

Part of P0141, funded by [Anonymous] and rosenrose.
2021-05-27 19:36:02 +02:00
nmlgc d856f7df16 [Reverse-engineering] [th01] Escape sequences
We've got to move all of Konngara's escape sequences to C land right
now, to get them out of the way of the filenames, so we might as well
look at all of them, in the entire binary.

But, uh… "graph mode"? That one is severely underdocumented, seemingly
even in Japanese. Turns out that it's a way to disable Shift-JIS
decoding, which makes it possible to access the half-width glyphs in
the PC-98 font ROM at the 0x81-0x9F and 0xE0-0xFF codepoints.
(In regular "kanji mode", these are interpreted as Shift-JIS lead
bytes.)
So, I did a deep dive into NEC's IO.SYS to hunt down all places where
this distinction has an effect, and then implemented it into DOSBox-X,
which was still missing everything related to it:

	https://github.com/joncampbell123/dosbox-x/pull/2547

If P0140 looks a bit empty as a result, that's why – most of the
feature work went into DOSBox-X, not ReC98. That's the beauty of
"anything" pushes. :tannedcirno:

So, after switching to graph mode, TH01 does… one of the slowest
possible memset()s over all of text RAM (one printf(" ") call for every
single one of its 80×25 half-width cells), before switching back to
kanji mode. What a waste of RE time…? Oh well, at least we've now got
plenty of documentation to prove to future port authors that these
weird escape sequences *actually* do nothing.

Completes P0140, funded by [Anonymous].
2021-05-27 18:49:29 +02:00
nmlgc 8fe3338587 [Decompilation] [th01] Unused, player shot/pellet-related boss stage flag
At least that's what we can infer from its position in the code.
Putting it into player shots for the sole reason that it's easier to
find it there.

Part of P0140, funded by [Anonymous].
2021-05-27 18:49:29 +02:00
nmlgc 00ca4ccc1f [Maintenance] Add a COMPONENT_COUNT constant for RGB colors
sizeof(RGB4), seriously?! That's *so* wrong. And also inconsistent next
to COLOR_COUNT everywhere.

Part of P0140, funded by [Anonymous].
2021-05-27 18:49:29 +02:00
nmlgc e5dffdd9b6 [Maintenance] [th01] Move frame_delay() to consistently named files
It didn't bother me during all of 2020 that TH01's version was
inconsistently part of vsync.h?!

Part of P0140, funded by [Anonymous].
2021-05-27 18:49:29 +02:00
nmlgc 794c6ab55c [Maintenance] Fix another bunch of accumulated typos
Part of P0139, funded by [Anonymous].
2021-05-11 18:47:49 +02:00
nmlgc 9739f69729 [Maintenance] Add a 1bpp rectangle template, for custom per-row types
This gets rid of a couple of per-entity sprite bitplane types, makes
sprite declarations easier to read by putting width and height next to
each other… and points out a number of array dimension mistakes -.-
Even in places where we can't use it.

Part of P0138, funded by [Anonymous] and Blue Bolt.
2021-04-21 18:01:57 +02:00
nmlgc 1c5ed4b06e [Maintenance] Copy <dos.h>'s 16-bit x86 Real Mode declarations to a new file
DOS is not the same thing as the underlying CPU, after all. A separate
file not only indicates to future port authors which parts of the code
are x86-specific, but it also speeds up build times…

… in theory, because removing 677 lines from 49 files each doesn't seem
to speed up the build as much as I had hoped? But apparently my whole
system mysteriously got faster in the meantime, and I was getting 22-23
seconds for the entire repo even before this commit. Good enough.

Part of P0134, funded by [Anonymous].
2021-02-20 23:49:45 +01:00
nmlgc 59fb8753bc [Maintenance] Only use the `far` keyword to declare intent
Part of P0134, funded by [Anonymous].
2021-02-20 15:47:30 +01:00
nmlgc 0ce869c30a [Maintenance] Complete the master.hpp transition
Part of P0133, funded by [Anonymous].
2021-01-30 19:22:29 +01:00
nmlgc d1f1b7d405 [Maintenance] Move twobyte_t into its own header file
And hope that there won't be any more generic utility types like it…

Part of P0133, funded by [Anonymous].
2021-01-30 18:31:54 +01:00
nmlgc dc9e3ee475 [Decompilation] [th01] Bosses: Collision handling
Functions with 12 parameters are hard to describe, y'know. Looking
forward to decompiling these giant expressions for the actual
boss↔orb collision parameter passed to this function…

Oh well, at least we're now totally ready for some boss code next
year. 😌

Completes P0131, funded by Yanga.
2020-12-18 01:38:52 +01:00
nmlgc bcdc073403 [Reverse-engineering] [th01] Frame-based random number
Yes, no "generator", just a single number. Used to add some very
minimal randomness to certain things, by taking it modulo a small
number.

Part of P0131, funded by Yanga.
2020-12-18 01:38:51 +01:00
nmlgc 21da5a330d [Reverse-engineering] [th01] Bomb damage flag
Part of P0131, funded by Yanga.
2020-12-18 01:38:50 +01:00