Commit Graph

266 Commits

Author SHA1 Message Date
nmlgc 453dd3ca7e [Decompilation] [th05] Starting the game
And that's the intended way to play back the hidden DEMO5.REC. Unlock
the Extra Stage with all 4 characters, then hold the left and right
arrow keys in the main menu while waiting the usual demo replay.

For a recording of that replay, see

	https://www.youtube.com/watch?v=iP2ywlW2u4U

Completes P0119, funded by [Anonymous] and -Tom-.
2020-09-21 15:00:44 +02:00
nmlgc 6b06be2b3e [Maintenance] [th04/th05] Declare all public OP.EXE functions in C land
Part of P0119, funded by [Anonymous] and -Tom-.
2020-09-21 15:00:40 +02:00
nmlgc 3dd741ce98 [Decompilation] [th05] Game clear/extra unlock variable initialization
Why does this function also have to load sprites for the viewing mode
of the high score menu?! Oh well, ridiculous functions deserve
ridiculous names…

Part of P0119, funded by [Anonymous] and -Tom-.
2020-09-21 15:00:15 +02:00
nmlgc 799b801720 [Reverse-engineering] [th04/th05] GENSOU.SCR loading
That's almost one distinct function per binary. What a mess.

Part of P0119, funded by [Anonymous] and -Tom-.
2020-09-21 15:00:10 +02:00
nmlgc 3c27fbc3bd [Decompilation] [th05] Player character selection menu
The TH04 one might have the same function structure, but the only thing
that's actually identical in both games is the picture darkening loop.

Part of P0119, funded by [Anonymous] and -Tom-.
2020-09-21 15:00:05 +02:00
nmlgc 5990ccd3b9 [Maintenance] Declare CDG blitting functions in C land
Part of P0119, funded by [Anonymous] and -Tom-.
2020-09-21 15:00:01 +02:00
nmlgc 485477bd56 [Maintenance] [th04/th05] Declare snd_se_update() as __cdecl
Part of P0119, funded by [Anonymous] and -Tom-.
2020-09-21 14:59:50 +02:00
nmlgc 1535aa7dd2 [Reverse-engineering] [th04/th05] X/Y turning for bouncing bullets
Part of P0118, funded by -Tom- and Ember2528.
2020-09-17 22:27:19 +02:00
nmlgc a417b01634 [Reverse-engineering] [th04] Player shots: Option laser blitting
Used for Marisa's shot in TH04, but still present in TH05, so it makes
sense to cover it now.

Part of P0118, funded by -Tom- and Ember2528.
2020-09-17 22:25:11 +02:00
nmlgc c790f5fba1 [Position independence] [th01/th02/th04/th05] False positives: Score values
Part of P0118, funded by -Tom- and Ember2528.
2020-09-17 22:23:26 +02:00
nmlgc a3723364d6 [Reverse-engineering] [th04/th05] HUD: HP bar rendering
Part of P0118, funded by -Tom- and Ember2528.
2020-09-17 22:23:14 +02:00
nmlgc 03048c318d [Decompilation] [th04/th05] Cutscenes: Text blending
Completes P0116, funded by [Anonymous] and Lmocinemod.
2020-09-12 12:09:31 +02:00
nmlgc 0b7d541e30 [Reverse-engineering] [th03/th04/th05] Cutscene script buffer
Part of P0116, funded by [Anonymous] and Lmocinemod.
2020-09-12 11:35:44 +02:00
nmlgc 041b3a4f28 [Position independence] [th04/th05] Remaining references to the name alphabet
Part of P0116, funded by [Anonymous] and Lmocinemod.
2020-09-12 11:29:35 +02:00
nmlgc 10b60b3824 [Maintenance] [th03/th04/th05] Declare the symbol gaiji inherited from TH02
Part of P0116, funded by [Anonymous] and Lmocinemod.
2020-09-12 11:29:20 +02:00
nmlgc 716a925636 [Decompilation] [th03] YUME.CFG loading and saving
Oh, I just needed something in TH03's OP.EXE before code segment 2.

Part of P0114, funded by Lmocinemod.
2020-09-07 21:18:40 +02:00
nmlgc f6757fe76a [Maintenance] Fix DEFCONV declarations, and remove them where possible
Wow, this is the first time we're about to call any of these from C
land in ≥TH03? Found no built-in way to just uppercase an identifier
in TASM, so apparently we have to spell out the names in both lower-
and uppercase.
So, let's go back to regular, non-macro PUBLIC / PROC / ENDP code
wherever we can – for all functions introduced in ≥TH03, and for
everything that takes no parameters. It's simply not worth the
trouble.

Part of P0114, funded by Lmocinemod.
2020-09-07 21:18:39 +02:00
nmlgc d40547e601 [Maintenance] Drop the `slot` infix for PI-related identifiers
ZUN doesn't ever use PI functions without these slots, making that infix
kind of redundant.

Part of P0114, funded by Lmocinemod.
2020-09-07 21:18:39 +02:00
nmlgc 6204fdd450 [Separate translation units] [th02/th03/th04] frame_delay_2()
Completes P0113, funded by Lmocinemod.
2020-09-07 21:18:38 +02:00
nmlgc be22a72b25 [Maintenance] [th03/th04/th05] Declare CDG loading/freeing functions in C land
No need to make the function names more complicated if we already
expressed the one subtle format difference between TH03 and TH04/TH05
in the plane layout enum.

Part of P0113, funded by Lmocinemod.
2020-09-07 21:18:38 +02:00
nmlgc d1ba6306cc [Maintenance] [th03/th04/th05] Declare the CDG slot structure in C land
Third iteration on the field names, now consistent with how the naming
has evolved since 2017…

Part of P0113, funded by Lmocinemod.
2020-09-07 21:18:37 +02:00
wintiger0222 db206f9d41 [Reverse-engineering] [th02/th04/th05] HUD: Bar colors
Reviewed and merged as part of P0112, funded by [Anonymous] and Blue
Bolt.
2020-08-28 16:21:13 +02:00
nmlgc 6cd11b0a44 [Reverse-engineering] [th05] Bullets: Pellet delay cloud render list
Making sure that we don't ever have to iterate over the 8×8 pellet part
of the bullet array during rendering… sure, but why not give the same
optimization treatment to the 16×16 bullets?

Part of P0112, funded by [Anonymous] and Blue Bolt.
2020-08-28 15:31:02 +02:00
nmlgc db0adbc58f [Maintenance] [th02/th04/th05] Rename `HUD_TRAM_W` to `HUD_KANJI_W`
Right, *_TRAM_W refers to 8-pixel halfwidth characters, and *_KANJI_W
to 16-pixel full-width characters… which also include gaiji, which are
what the entire HUD is made out of.

Part of P0112, funded by [Anonymous] and Blue Bolt.
2020-08-28 15:30:34 +02:00
nmlgc ed113d9c30 [Reverse-engineering] [th04/th05] Stage tiles: Initial ring buffer filling
…Wow. A 32-element lookup table for the very computationally expensive
operation of (i * 320), needlessly limiting the amount of unique 384×80
tile sections in a stage to 32… and then TH05 further "optimizes" this
lookup by pre-multiplying all section IDs in the .STD file with the
element size of that table, to save a grand total of 1 x86 instruction.

Part of P0112, funded by [Anonymous] and Blue Bolt.
2020-08-28 15:28:26 +02:00
nmlgc a89836c18e [Decompilation] [th05] Bombs: Reimu's blue star animation
After ternary expressions straight out of Jigoku in 57be510, we now got
pointer arithmetic straight out of Jigoku… with, unsurprisingly, two
ZUN bugs.

Part of P0112, funded by [Anonymous] and Blue Bolt.
2020-08-28 15:22:28 +02:00
nmlgc fb67d4d054 [Maintenance] Rename all old *_X and *_Y constants to *_LEFT and *_TOP
Part of P0112, funded by [Anonymous] and Blue Bolt.
2020-08-28 15:14:22 +02:00
nmlgc 8e686dd564 [Maintenance] [th04/th05] Declare circles in C land
No structure declaration in the header file needed, since the game
doesn't party on its members from outside, for once!

Part of P0112, funded by [Anonymous] and Blue Bolt.
2020-08-28 15:14:21 +02:00
nmlgc 5d76fd6f64 [Reverse-engineering] [th04] Bombs: Star animation structure
The trivial one first, while I try to wrap my head around what's going
on with Reimu's TH05 bomb animation…

Part of P0111, funded by [Anonymous] and Blue Bolt.
2020-08-28 15:04:39 +02:00
nmlgc c5b5dc0201 [Reverse-engineering] General bomb-related globals
Yup, function pointers, frame counters, and general state variables for
all 5 games.

Part of P0111, funded by [Anonymous] and Blue Bolt.
2020-08-28 15:03:03 +02:00
nmlgc 199f4de1d3 [Reverse-engineering] [th04/th05] Remaining item-related globals
Leaving the obvious "PoC always enabled" cheat as an exercise to the
reader.

Part of P0111, funded by [Anonymous] and Blue Bolt.
2020-08-28 15:00:33 +02:00
nmlgc ba29539fc7 [Maintenance] Declare a distinct type for VRAM offsets
… and this one, while I'm at it. I've been using pretty much every
possible type for VRAM offset variables, depending on my mood that day,
since signedness apparently never matters for those.
Except that it does. And so, just like with most of our high-level
types, we also have to account for ZUN's little signedness
inconsistencies here. Oh well, at least it's now only one of two types,
and there's no need to choose between `int` or `unsigned int` or
`short` or `unsigned short` or `int16_t` or `uint16_t` or `size_t` or…

Part of P0111, funded by [Anonymous] and Blue Bolt.
2020-08-28 14:53:33 +02:00
nmlgc d6f634631f [Maintenance] Declare distinct types for pixel and VRAM sizes
Oh wait, we also need one of those for an upcoming structure!

Part of P0111, funded by [Anonymous] and Blue Bolt.
2020-08-28 14:53:33 +02:00
nmlgc 368f151759 [Maintenance] Declare distinct types for screen, VRAM, and TRAM coordinates
Whew, time to look at every `int` variable we ever declared! The best
moment to do this would have been a year ago, but well, better late
than never. No need to communicate that in comments anymore.

These shouldn't be used for widths, heights, or sprite-space
coordinates. Maybe we'll cover that another time, this commit is
already large enough.

Part of P0111, funded by [Anonymous] and Blue Bolt.
2020-08-28 14:53:30 +02:00
nmlgc 8b5c1463f6 [Position independence] [th02/th03/th04/th05] References to known gaiji
Completes P0110, funded by [Anonymous] and Blue Bolt.
2020-08-19 20:12:02 +02:00
nmlgc 2ef3db3052 [Maintenance] Remove the `operator =` overloads for Subpixels
At least we've now documented their negative effects.

Part of P0110, funded by [Anonymous] and Blue Bolt.
2020-08-19 20:10:08 +02:00
nmlgc 7c4d31c02b [Decompilation] [th05] Line sets: Rendering
With all the memmove()-style shifting of individual lines, there's
probably a point to reserving 20 lines per set, but only ever rendering
4 of them. We'll see once I get to decompile all of these functions.

Part of P0110, funded by [Anonymous] and Blue Bolt.
2020-08-19 20:10:08 +02:00
nmlgc 60a700eeda [Maintenance] Declare the "no valid point" constant (-999) in a single place
Part of P0110, funded by [Anonymous] and Blue Bolt.
2020-08-19 19:32:37 +02:00
nmlgc 61c29ba738 [Maintenance] [th04] Bullet pattern tuning: Actually specify angles in hex -.-
The kind of minor copy-pasting mistake that should have been caught by
a proper type system… which ReC98 can only simulate to an extent.

Part of P0110, funded by [Anonymous] and Blue Bolt.
2020-08-19 19:31:30 +02:00
nmlgc 18a8eccd2f [Decompilation] [th05] Bosses: Smooth random movement
Part of P0109, funded by [Anonymous] and Blue Bolt.
2020-08-16 21:41:34 +02:00
nmlgc 023417a1b4 [Maintenance] Move boss declarations to boss.hpp
Part of P0109, funded by [Anonymous] and Blue Bolt.
2020-08-16 21:40:35 +02:00
nmlgc 88cc266a24 [Maintenance] [th04/th05] Put global and stage-specific patnums into one enum
Right, because you'd also want to automatically shift the IDs for every
stage-specific sprite if you add or remove a new stage-independent one.

Part of P0109, funded by [Anonymous] and Blue Bolt.
2020-08-16 21:40:35 +02:00
nmlgc 8af732a6a5 [Reverse-engineering] [th04/th05] Player shot hitboxes
As in, the global variables describing the area that should be checked
for collisions with player shots in the next call to the shot hit test
function.

Part of P0109, funded by [Anonymous] and Blue Bolt.
2020-08-16 21:40:34 +02:00
nmlgc 401d3793b5 [Maintenance] [th04/th05] Mirror bullet.hpp structures and enums in ASM land
Because pretty much all of TH05's bullet spawn code is micro-optimized
and undecompilable ASM, we'll unfortunately have to keep those ASM
versions around forever 😕

Well, the TH05 ones at least.

Part of P0109, funded by [Anonymous] and Blue Bolt.
2020-08-16 21:40:33 +02:00
nmlgc 829946a29e [Decompilation] [th04] Difficulty- and rank-based bullet pattern tuning
Because it's at least *possible* to decompile TH04's version of these
functions.

Part of P0109, funded by [Anonymous] and Blue Bolt.
2020-08-16 21:40:32 +02:00
nmlgc bd1c2ee7de [Maintenance] #define the number of dots in a byte
One fewer magic number. And one more deliberate dependency on a
PC-98-specific hardware constant, to further drive home just how
unportable these games are, even once decompilation will be complete.

Part of P0105, funded by Yanga.
2020-08-12 16:16:58 +02:00
nmlgc d840841a2b [Naming] Rename egc_copy_rect_1_to_0() to emphasize its 16-dot alignment
ZUN might have gotten the impression that the EGC can *only* work with
multiples of 16 pixels per load or store? Which might explain why…

Part of P0102, funded by Yanga.
2020-07-12 16:27:56 +02:00
nmlgc e3a78bd19b [Maintenance] Fix vector creation function declarations and calls
Part of P0099, funded by Ember2528.
2020-07-12 15:22:50 +02:00
nmlgc 8f8940801d [Maintenance] Move the Subpixel class to TH01
At least pellets are moved at a decent precision in this game.

Part of P0099, funded by Ember2528.
2020-07-12 15:16:03 +02:00
nmlgc 1799d67782 [Build] Convert all known hardcoded sprites during the 32-bit build part
You can now mod them by simply editing .BMP files!
2020-07-09 22:28:15 +02:00