Commit Graph

1536 Commits

Author SHA1 Message Date
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
nmlgc 53920309a1 [Decompilation] [th05] snd_kaja_interrupt()
Boom! Decompilable after all. And look what that made us finally point
out: In all 4 games that use this function, its return value is
undefined if BGM is inactive. (That is, if the user disabled it, or if
no FM sound board is installed.)

Part of P0148, funded by [Anonymous].
2021-07-21 00:35:03 +02:00
nmlgc ab8af79549 [Separate translation units] [th04/th05] motion_update_seg3() (undecompilable)
Reason: See previous commit.

Part of P0148, funded by [Anonymous].
2021-07-21 00:35:02 +02:00
nmlgc 751481b658 [Maintenance] Assign segment-specific names to the motion_update() variants
Well, we *could* pointlessly decompile this function into an unreadable
mess, but only if we throw away the semantics of the return value, and
replace its type with `void` or `uint32_t`.
(Turbo C++ can't cast registers to a struct value, and adding a
constructor to SPPoint would break everything else, if it even works.)
ZUN's original usage code doesn't care either way, because it only ever
accesses the returned value directly through DX:AX.

Part of P0148, funded by [Anonymous].
2021-07-21 00:35:02 +02:00
nmlgc f3d59bc324 [Decompilation] [th04/th05] Applying VRAM scrolling to Y coordinates (segment 3)
… Wait, we *can* decompile functions with both parameters, no stack
frame, and a Pascal calling convention?! Good that I already forgot how
impossible it was to decompile the first function I looked at that fell
into this category!

Part of P0148, funded by [Anonymous].
2021-07-21 00:35:02 +02:00
nmlgc 8671340481 [Decompilation] [th04/th05] Gather circle rendering
Part of P0148, funded by [Anonymous].
2021-07-21 00:35:02 +02:00
nmlgc 6333643222 [Decompilation] [th03/th04/th05] cfg_load_resident_ptr()
Including the pointless DOS I/O variation in TH05's MAIN.EXE.
I'm slowly running out of characters to remove from the first segment
name in that file, though…

Part of P0148, funded by [Anonymous].
2021-07-21 00:34:59 +02:00
nmlgc 06dbb6335c [Naming] [th03/th04/th05] Clarify that cfg_load_resident() only loads a pointer
It shouldn't need a comment to communicate that this function does in
fact not load all values from the .CFG file that are part of the
resident structure, but only loads and sets the global pointer to that
structure.

Part of P0148, funded by [Anonymous].
2021-07-20 23:35:50 +02:00
nmlgc a6ace813e4 [Decompilation] [th04] Bonus popup point display
Part of P0148, funded by [Anonymous].
2021-07-20 23:35:50 +02:00
nmlgc 3a41604314 [Decompilation] [th04/th05] Text popups
The bullet update function really needs this one declared in C land to
link without a fixup overflow? Guess we'll have another technical debt
push before then…

Part of P0148, funded by [Anonymous].
2021-07-20 23:35:46 +02:00
nmlgc e6e3c97eb3 [Maintenance] [th04/th05] Merge shared popup data into one file
Part of P0148, funded by [Anonymous].
2021-07-20 20:50:25 +02:00
nmlgc c940059037 [Decompilation] [th05] Shinki + EX-Alice: Background rendering
Palette hacks not included yet. Yup, that's how all phases can use
hardware color #0 as their background color.

Completes P0147, funded by -Tom- and Ember2528.
2021-06-21 15:48:42 +02:00
nmlgc a157739665 [Reverse-engineering] [th04/th05] .CDG slot IDs for MAIN.EXE
64 slots reserved, 16 slots actually used, another 768 bytes of
conventional RAM wasted…

(And yes, that naming convention is indeed meant as a shoutout to all
the RPG Maker veterans out there.)

Part of P0147, funded by -Tom- and Ember2528.
2021-06-21 15:48:41 +02:00
nmlgc 4eb11b55fc [Maintenance] [th04/th05] Declare playfield fill functions in playfld.hpp
Part of P0147, funded by -Tom- and Ember2528.
2021-06-21 15:48:40 +02:00
nmlgc 7fc13c24ac [Maintenance] [th04] Get rid of th04.hpp
Oh wow, we never used that one; I only added it in 042b780 to make it
easier for tool authors to #include "th04/resident.hpp". Bad idea –
if we don't ensure that it *actually works* (and it didn't, as of
d1f3dcd), it's of no help to them either.

Part of P0147, funded by -Tom- and Ember2528.
2021-06-21 15:48:39 +02:00
nmlgc 23c46c6654 [Maintenance] [th05] Get rid of th05.hpp
That was surprisingly painless!

Part of P0147, funded by -Tom- and Ember2528.
2021-06-21 15:48:39 +02:00
nmlgc b265134541 [Reverse-engineering] [th04/th05] Background rendering function pointers
That could have easily been architected without forcing every boss to
manually set the "background to be drawn while bombing" function
pointer.
And without the laziness of just redrawing all tiles during the blocky
opening animation of certain bombs…

Part of P0147, funded by -Tom- and Ember2528.
2021-06-21 15:48:38 +02:00
nmlgc 57499cea1c [Reverse-engineering] [th04/th05] .BB tile animation: Bomb cel rendering
Wait, if TH05 has .BB files for all 4 characters, but only ever shows
Reimu's and Yuuka's…

Part of P0147, funded by -Tom- and Ember2528.
2021-06-21 15:48:37 +02:00
nmlgc 8691b23716 [Reverse-engineering] [th04/th05] .BB tile animation: Cel rendering
Not exclusively used for the boss entrance animations, even though its
data is declared in that general vicinity. It's also used for all bombs
in TH04, and Reimu's and Yuuka's bomb in TH05.

Part of P0147, funded by -Tom- and Ember2528.
2021-06-21 15:48:28 +02:00
nmlgc f3afd37e8f [Reverse-engineering] [th04/th05] .BB tile animation: Filling a single tile
Sure, it's still a micro-optimization, but at least it's __fastcall for
once! And doesn't assume ES to have been set to a VRAM segment. So not
*that* optimized 😛

Part of P0147, funded by -Tom- and Ember2528.
2021-06-20 19:44:40 +02:00
nmlgc ebbb5b8255 [Maintenance] Move tile-related files to their own subdirectory
The next commit will make clear that tile functionality is not a subset
of the non-boss stage code.

Part of P0147, funded by -Tom- and Ember2528.
2021-06-20 19:37:20 +02:00
nmlgc 11b5febc5a [Maintenance] [th04/th05] Move midboss declarations to their own header file
Part of P0147, funded by -Tom- and Ember2528.
2021-06-20 19:36:14 +02:00
nmlgc 456b621c3a [Decompilation] [th05] Shinki: Background types B, C, and D
Thanks, alignment, for forcing all of these into one commit! 🙂

Completes P0146, funded by -Tom- and Ember2528.
2021-06-10 22:52:29 +02:00
nmlgc f5702a599b [Decompilation] [th05] Shinki: Background type B initialization and gravity
We're really going to have a needless "update, part 1" function for all
four background types, eh?

Part of P0146, funded by -Tom- and Ember2528.
2021-06-10 21:43:11 +02:00
nmlgc a9496fa10f [Decompilation] [th05] Shinki: Background type A rendering
The one in the first four phases, with the two parallel zooming lines
that give the impression of flying into a corridor, and random blue
particles shooting out from the center.

Part of P0146, funded by -Tom- and Ember2528.
2021-06-10 21:42:42 +02:00
nmlgc 4672f226bb [Decompilation] [th05] Shinki: Background particle rendering
We really wouldn't have wanted to start writing inline ASM in the
middle of a conditional expression just to get that janky `CMP AX, 0`
instead of TCC's sensible `OR AX, AX` optimization.

Part of P0146, funded by -Tom- and Ember2528.
2021-06-10 09:01:31 +02:00
nmlgc b66400b3d2 [Decompilation] [th05] Shinki: Background type A initialization and rotation
Oh hey, a uth05win naming convention I have no qualms about adopting,
for once!
(Note from the future: It's actually really smart! The animation you
see is dependent on the state from previous background types, so it
makes sense to reduce the names to the original sequence.)

Part of P0146, funded by -Tom- and Ember2528.
2021-06-09 23:13:00 +02:00
nmlgc aae96aec45 [Decompilation] Find out how to bypass TCC's optimization of 0 immediates
By deferring that immediate 0 to link time. 🤦

Part of P0146, funded by -Tom- and Ember2528.
2021-06-09 23:12:04 +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