Commit Graph

1949 Commits

Author SHA1 Message Date
nmlgc a78c4ff0f3 [Decompilation] [th01] Sariel: Background transition animation
One of the hardest decompilations in a long while:
• Required new research into code generation for pointer arithmetic
• ZUN needlessly calculating intermediate results over and over again,
  making the function tedious to read
• GRCG reads in TCR mode, which I haven't seen so far either

Part of P0176, funded by Ember2528.
2022-01-31 07:18:42 +01:00
nmlgc 244136c42b [Naming] [th01] Rename grcg_setcolor_tdw() to grcg_setcolor_tcr()
TDW and TCR modes share the same bit in the GRCG mode register and are
thus indistinguishable when looking at a disassembly, but only apply to
writing (TDW) or reading (TCR), respectively. TH01 only performs read
operations in this mode, so it's unambiguously TCR.

Part of P0176, funded by Ember2528.
2022-01-31 07:18:42 +01:00
nmlgc 40ac9a7aa1 [Decompilation] [th01] Sariel: Pattern 3/16
The one where red birds hatch on an ellipse arc, then fly away while
shooting a randomly selected pellet group type. Containing Sariel's
first ZUN bug, resulting in unused sprite movement.

Completes P0175, funded by Ember2528.
2022-01-31 07:18:42 +01:00
nmlgc d1627c6f56 [Decompilation] [th01] Sariel: Pattern 1/16
The one with the 10 random purple lasers.

Part of P0175, funded by Ember2528.
2022-01-31 07:18:42 +01:00
nmlgc 0054b10480 [Decompilation] [th01] Sariel: Pattern 2/16
The one where two vortex sprites wall Reimu inside a continuously fired
static 3-spread stack.

Whose per-difficulty density is only controlled by the amount of
frames they have moved towards each other, interestingly.

(And yes, second pattern in the fight, first one in the code.)

Part of P0175, funded by Ember2528.
2022-01-31 07:18:42 +01:00
nmlgc 97e7a2ff6d [Decompilation] [th01] Sariel: Dress animation
Largely identical to the shield animation, except in all the details
where it isn't.

Part of P0175, funded by Ember2528.
2022-01-31 07:18:42 +01:00
nmlgc af76839067 [Decompilation] [th01] Sariel: Lowered / initial wand sprite blitting
Surprise, this .PTN sprite isn't actually just the background, but a
complete opaque copy of the 128×128 pixels in the .GRP image that
contain the initial position of the wand. This is what allows Sariel
to lower it again after blitting the raised sprites from BOSS6_2.BOS.

Part of P0175, funded by Ember2528.
2022-01-31 07:18:42 +01:00
nmlgc cfa5428dff [Decompilation] [th01] Sariel: Wand raise animation
In which the black part in BOSS6_2.BOS's second cel is indeed meant to
unblit the purple part in the first cel, leaving a hole in both the
seal and the red HUD border. Shouldn't it rather contain the original
pixels, including the part of the seal that is covered by the sphere on
top of the wand even in the .GRP?

Part of P0175, funded by Ember2528.
2022-01-31 07:18:42 +01:00
nmlgc 5db5df4da3 [Decompilation] [th01] Sariel: Shield animation
Part of P0175, funded by Ember2528.
2022-01-31 07:18:35 +01:00
nmlgc a0fe812216 [Decompilation] [th01] Sariel: Bird reset/fire/spawn/unblit/update/blit function
I appreciate that this design allows all bird state to be scoped to
this function, but *come on*, one function doing 6 different jobs?
Also, maximum floating-point decadence… but perhaps the worst part is
that the initial bird eggs are a *different* entity.

Completes P0174, funded by Ember2528.
2022-01-31 05:15:37 +01:00
nmlgc 76ea88c0bc [Decompilation] [th01] Sariel: Move already referenced literals to C land
After the previous commit, we can already do this now, and therefore
have to do less at once in the end.

Part of P0174, funded by Ember2528.
2022-01-31 05:15:33 +01:00
nmlgc 8b01702aa5 [Decompilation] [th01] Sariel: Move compiler-generated data to C land
Very helpful at this small scale, as it allows us to directly decompile
floating-point literals. These will be added to Sariel's regular
translation unit in the same order, so we merely have to remove them
from this temporary translation unit then.

Part of P0174, funded by Ember2528.
2022-01-31 05:15:29 +01:00
nmlgc b1ec7fce28 [Decompilation] [th01] Sariel: Spawn ray rendering
So if Sariel's version of this function is worse than Konngara's, can
we conclude that Sariel's code was written first?

(Edit, after having decompiled more of the fight: Sariel's functions
are predominantly `near` in contrast to Konngara's 100% `far` ones,
which is just as much of an indicator for the opposite.)

Part of P0174, funded by Ember2528.
2022-01-31 05:15:25 +01:00
nmlgc c8636aed9b [Decompilation] [th01] Sariel: Sprite freeing
Part of P0174, funded by Ember2528.
2022-01-31 05:15:21 +01:00
nmlgc 55fe56544b [Reverse-engineering] [th01] Sariel: .GRC slots
Part of P0174, funded by Ember2528.
2022-01-31 05:15:17 +01:00
nmlgc 9979a0fe83 [Naming] [th01] Sariel: Generic pattern state variable
Part of P0174, funded by Ember2528.
2022-01-31 05:15:13 +01:00
nmlgc 4f63210c8a [Maintenance] [th01] Move boss entity loading calls next to their freeing calls
With loading and freeing code physically close together, it almost
looks like C++ classes.

Part of P0174, funded by Ember2528.
2022-01-31 05:15:08 +01:00
nmlgc e4343b2c95 [Maintenance] [th01] Better distinguish boss "entities" from "other sprites"
Part of P0174, funded by Ember2528.
2022-01-31 05:15:04 +01:00
nmlgc e1de05288b [Maintenance] [th01] Move one-off GRCG macros to planar.h
We're going to see them again after all.

Part of P0174, funded by Ember2528.
2022-01-31 05:15:00 +01:00
nmlgc 210476f34d [Maintenance] [th01] Start a new header file for direction types
Copy-pasting `x_direction_t` once was OK, but since we're about to do
that again… not so much.

Part of P0174, funded by Ember2528.
2022-01-31 05:14:55 +01:00
nmlgc 07fa6cb4d3 [Maintenance] [th01] Set PM_NORMAL as the default pellet motion type parameter
Every other motion type requires the other parameters to make sense.
If none of those are given, PM_NORMAL is redundant as well.

Part of P0174, funded by Ember2528.
2022-01-31 05:14:28 +01:00
nmlgc 27f901c48d [Decompilation] [th03] High score menu: Name entering loop
Not jank-free by far, but thankfully much better than TH01's.

Completes P0173, funded by [Anonymous].
2021-12-27 18:38:32 +01:00
nmlgc 1465731780 [Decompilation] [th03] High score menu: High-level row rendering functions
Part of P0173, funded by [Anonymous].
2021-12-27 18:38:32 +01:00
nmlgc d452fc0f3d [Decompilation] [th03] High score menu: Rendering a single row
Oh, so the high score name is only stored backwards for aesthetic
reasons, to make both the name and score blitting loops look identical.

Part of P0173, funded by [Anonymous].
2021-12-27 18:38:32 +01:00
nmlgc a823bec801 [Decompilation] [th03] High score menu: REGI*.BFT glyph blitting
Part of P0173, funded by [Anonymous].
2021-12-27 18:38:32 +01:00
nmlgc ace067fd07 [Decompilation] [th03] High score menu: REGI*.BFT glyph unblitting
What's a EGC?

Part of P0173, funded by [Anonymous].
2021-12-27 03:59:33 +01:00
nmlgc bb4a9d7301 [Decompilation] [th03] High score menu: Alphabet ID → screen space transform
Nice, ZUN learned something from TH01's terrible high score menu code!

Part of P0173, funded by [Anonymous].
2021-12-27 03:59:33 +01:00
nmlgc 1658c0acd3 [Decompilation] [th03] High score menu: Initial alphabet rendering
Part of P0173, funded by [Anonymous].
2021-12-27 03:59:33 +01:00
nmlgc 8750e9e079 [Decompilation] [th03] High score menu: Making room for a new high score
Yup, that 10th score digit stored for every place is in fact unused.

Part of P0173, funded by [Anonymous].
2021-12-27 03:59:33 +01:00
nmlgc da3617a219 [Decompilation] [th03] High score menu: Loading and background blitting
Part of P0173, funded by [Anonymous].
2021-12-27 03:59:33 +01:00
nmlgc 2d5491e4a9 [Decompilation] [th03] YUME.NEM: Loading
"I don't need the return value in MAINL.EXE? Let's copy-paste the
function and remove all of its `return` statements then!" :zunpet:

Completes P0172, funded by [Anonymous] and Blue Bolt.
2021-12-27 03:59:33 +01:00
nmlgc 4b7028c9d3 [Decompilation] [th03] YUME.NEM: Checksum verification
Part of P0172, funded by [Anonymous] and Blue Bolt.
2021-12-27 03:59:33 +01:00
nmlgc b20bf944be [Decompilation] [th03] YUME.NEM: Default data
Part of P0172, funded by [Anonymous] and Blue Bolt.
2021-12-27 03:59:33 +01:00
nmlgc 6d5918881f [Decompilation] [th03] YUME.NEM: Encryption and saving
Also "intransparently setting the clear flag, but only in the MAINL.EXE
version".

Part of P0172, funded by [Anonymous] and Blue Bolt.
2021-12-27 03:59:30 +01:00
nmlgc 79aeb8dccc [Decompilation] [th03] YUME.NEM: Decryption
Featuring inline assembly for a single ROR instruction. Turbo C++ 4.0J
unfortunately only offers intrinsics for 16-bit rotations.

Part of P0172, funded by [Anonymous] and Blue Bolt.
2021-12-27 03:59:02 +01:00
nmlgc 3361cd6991 [Reverse-engineering] [th03] YUME.NEM: Structure
Part of P0172, funded by [Anonymous] and Blue Bolt.
2021-12-27 01:16:03 +01:00
nmlgc 53ccdca29a [Reverse-engineering] [th03] YUME.NEM: File name
Part of P0172, funded by [Anonymous] and Blue Bolt.
2021-12-27 01:16:03 +01:00
nmlgc e3d611fa42 [Reverse-engineering] [th03] REGI1.BFT / REGI2.BFT sprite IDs
A score format that stores all its data in terms of the internal sprite
IDs…

Part of P0172, funded by [Anonymous] and Blue Bolt.
2021-12-27 01:16:03 +01:00
nmlgc 38f9db0592 [Maintenance] [th03] Assign segment #1 in OP and MAINL to a common group name
The YUME.NEM functions won't be decompilable in their natural order
otherwise.

Part of P0172, funded by [Anonymous] and Blue Bolt.
2021-12-27 01:15:59 +01:00
nmlgc efff8d61bb [Maintenance] Change line endings in old C/C++ files to LF
Yup, even a DOS compiler from 1994 considered CRLF line endings as
stupid.

Part of P0172, funded by [Anonymous] and Blue Bolt.
2021-12-27 01:06:32 +01:00
nmlgc b95450b026 [Maintenance] Remove the .ALPHA segment ordering workaround
We could have just abused the _TEXT segment all this time?!

Part of P0172, funded by [Anonymous] and Blue Bolt.
2021-12-27 01:06:26 +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 e95ff108e3 [Maintenance] [th01] Remove no longer used score declarations in ASM land
Part of P0172, funded by [Anonymous] and Blue Bolt.
2021-12-27 00:47:56 +01:00
nmlgc 49e67893cf [Badges] Add the new set of finalization badges
Part of P0171, funded by [Anonymous].
2021-12-16 00:30:12 +01:00
nmlgc 479b76609a [Decompilation] [th05] EMS / Dialog: Exit function
Only reloads the bomb background image from either the EMS area or disk
in this game. Plain and simple.

Completes P0169, funded by Blue Bolt.
2021-11-29 02:01:10 +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