Commit Graph

35 Commits

Author SHA1 Message Date
nmlgc 2c180c3825 [Reverse-engineering] [th01] Bosses: Current phase frame
One shared variable for all bosses except SinGyoku. Maybe the
biggest single set of PI false positives left in TH01?

Part of P0130, funded by Yanga.
2020-12-18 00:55:23 +01:00
nmlgc aaea18aa8f [Decompilation] [th01] Retrieving and setting the default boss palette
The placement at the beginning of Kikuri's code segment makes you think
this is only used for the barely noticeable white-in effect during
Kikuri's entrance animation. It's also used to periodically reset boss
sprite colors during the flashing effect after getting hit by the Orb,
though.

Part of P0130, funded by Yanga.
2020-12-18 00:55:21 +01:00
nmlgc d391dd4a3b [Decompilation] [th01] Reimu's animations: Byte-aligned unblitting
"Let's add a row to the offset, and then subtract it again" :zunpet:
This could only *possibly* have been intended as a DoS attack against a
future manual decompilation, right?

Part of P0123, funded by Yanga.
2020-10-13 21:34:35 +02:00
nmlgc b75556c06e [Maintenance] [th01] Reorder shared .BOS code
Part of P0123, funded by Yanga.
2020-10-13 21:34:24 +02:00
nmlgc cacb9361c7 [Decompilation] [th01] Skipping past the palette when loading .BOS files
At least the upcoming player animation load function was smart enough
to do that.

Part of P0123, funded by Yanga.
2020-10-13 20:51:52 +02:00
nmlgc b974c1a915 [Maintenance] Add separate macros for GRCG/EGC-accelerated reads and writes
Not only getting rid of the "useless" (and thankfully, consistent)
bitplane parameter, but also allowing those shortened macros to be
redefined for the upcoming little ZUN inconsistency.

Part of P0120, funded by Yanga.
2020-09-28 12:51:01 +02:00
nmlgc 95c6936d99 [Decompilation] [th01] Non-entity boss animations: .BOS slot freeing function
What was the thought process behind this inconsistency?! Oh well, that
was still an entire class decompiled for almost free.

Part of P0120, funded by Yanga.
2020-09-28 12:42:24 +02:00
nmlgc 8d39276732 [Decompilation] [th01] Non-entity boss animations: Byte-aligned blitting
And that's all we have for this class. Again, ever so slightly not
identical to the same CBossEntity function.

Part of P0120, funded by Yanga.
2020-09-28 12:38:31 +02:00
nmlgc 719668d51e [Decompilation] [th01] Non-entity boss animations: .BOS load function
Only adding a single stupidly placed `for` loop into the CBossEntity
version of the same function…

Part of P0120, funded by Yanga.
2020-09-28 12:37:42 +02:00
nmlgc 1efa34ce05 [Reverse-engineering] [th01] Non-entity boss animation classes
I did consider calling them "boss aesthetics" instead, but
that didn't really seem to fit Sariel's dress and wand animations,
which are the only things this class is used for. Or does it?

Part of P0120, funded by Yanga.
2020-09-28 12:37:34 +02:00
nmlgc 9738ba921a [Decompilation] [th01] Boss entities: .BOS slot freeing function
Still no need for the classic `if(ptr) { delete[] ptr; ptr = NULL }`
macro, since the `ptr` is unconditionally set to NULL here…

Part of P0120, funded by Yanga.
2020-09-28 12:37:33 +02:00
nmlgc d48e553d9e [Maintenance] [th01] Move shared .BOS loading snippets to separate functions
Part of P0120, funded by Yanga.
2020-09-28 12:33:02 +02:00
nmlgc 0fe23cb8a0 [Maintenance] [th01] Clearly distinguish entity and animation .BOS slots
… now that we have a better idea about the differences of both classes.
Also, no transitive dependency on bos.hpp for either class.

Part of P0120, funded by Yanga.
2020-09-28 12:32:52 +02:00
nmlgc 4bf2e41faf [Decompilation] [th01] Boss entities: Orb collision detection
Why does it use the Orb's position from the previous frame though?

Part of P0120, funded by Yanga.
2020-09-28 12:29:37 +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 2fbde57631 [Maintenance] Turn the left/right/top/bottom area structure into a template
Part of P0109, funded by [Anonymous] and Blue Bolt.
2020-08-16 21:40:35 +02:00
nmlgc dcf4e2cadd [Decompilation] [th01] Boss entities: Clamped movement + blitting
And here, the whole clamped movement part remains entirely unused.

Completes P0108, funded by Yanga.
2020-08-12 18:02:19 +02:00
nmlgc 52def53fd3 [Decompilation] [th01] Boss entities: Clamped movement + unblitting + blitting
A function which does so many individual things that I can't even
summarize it in a comment without spelling out each line of code. And
then, this entire clamped movement system is only used for Kikuri's
soul sprites. The usage code for every other entity just parties on
the [cur_left] and [cur_top] members, and passes a delta of (0, 0) to
this function. 🤷

Part of P0108, funded by Yanga.
2020-08-12 18:02:18 +02:00
nmlgc 2a091eed3b [Decompilation] [th01] Boss entities: Sloppy unblitting function
Unused, thankfully!

Part of P0108, funded by Yanga.
2020-08-12 18:02:18 +02:00
nmlgc d9bc75d28e [Decompilation] [th01] Boss entities: Position and movement clamp area setter
Yay, 7 parameters.

Part of P0108, funded by Yanga.
2020-08-12 18:02:18 +02:00
nmlgc 9ce0034934 [Decompilation] [th01] Boss entities: 16×8 section unblitting + blitting
Yet another unused function. No idea what it could have been intended
for – no boss sprite has animated sections that small.

But come on, out of all places that could have required the macro form
of a VRAM offset function, it had to be a unused one…

Anyway, that completes the low-level blitting functions for boss
entities!

Part of P0108, funded by Yanga.
2020-08-12 18:02:17 +02:00
nmlgc a2c4aadda9 [Decompilation] [th01] Boss entities: Broken wavy unblitting of two sprites
Another unused function! This might indicate that Elis could originally
split herself into two sprites, similar to TH04 Stage 6 Yuuka?
Or it might just have been some other kind of animation effect, who
knows.

Part of P0108, funded by Yanga.
2020-08-12 18:02:16 +02:00
nmlgc bc9b7cdfcd [Decompilation] [th01] Boss entities: Wavy blitting
Used for Elis' entrance animation. Including an unused unblitting +
blitting function – apparently, ZUN wrote that one before the sloppy
EGC-accelerated wavy unblitting function that I decompiled way back in
6d2fa9f.
Oh well, the latter one is fine in context, since there are no other
sprites on screen during the animation.

Part of P0108, funded by Yanga.
2020-08-12 18:01:33 +02:00
nmlgc 1650241f07 [Decompilation] [th01] Boss entities: Byte-aligned unblitting
A precise unblitting function, actually using the alpha plane of the
sprite… and it's unused.

Completes P0107, funded by Yanga.
2020-08-12 17:51:44 +02:00
nmlgc de688ddc20 [Decompilation] [th01] Boss entities: Byte-aligned unblitting + blitting
And we're back to not using functions, and needing our own VRAM access
macros…

Part of P0107, funded by Yanga.
2020-08-12 17:51:43 +02:00
nmlgc 96f3b1057c [Decompilation] [th01] Boss entities: Unaligned 1-line unblitting + blitting
… except that those single-plane functions provide basically no
useful abstraction in the context of a 4-plane image format. Should
have just gone all the way and directly take something like our
Planar<dots16_t> type to operate on all 4 planes, so that I wouldn't
have had to add that layer of abstraction myself.

Apparently, early ZUN was allergic to passing structures by reference?

Part of P0107, funded by Yanga.
2020-08-12 17:51:43 +02:00
nmlgc 816ba8342c [Decompilation] [th01] Background + foreground VRAM blit functions
Yes, functions! Those would have been nice earlier!
Also documented another overly specific Borland C++ code generation
quirk with regard to assigning expression results to elements of 16-bit
arrays…

Part of P0107, funded by Yanga.
2020-08-12 17:51:42 +02:00
nmlgc 34a5f4d183 [Decompilation] [th01] Boss entities: Unaligned 1-line blitting
"Oh wait, actually, I *do* want to blit 8 pixels at a time in some
cases" :zunpet:

First time in a long while that the VRAM access macros couldn't do the
job, because code generation wants *both* pointer arithmetic *and*
subscripts within the same expression.

But *come on*, just blit the 16 pixels for the byte-aligned case!

Part of P0107, funded by Yanga.
2020-08-12 17:51:42 +02:00
nmlgc 32c57c32e7 [Decompilation] [th01] Boss entities: Regular, byte-aligned blitting
That attempt at clipping the sprite at the left and right edges of
VRAM… is serviceable, I guess?

Part of P0107, funded by Yanga.
2020-08-12 17:51:42 +02:00
nmlgc 1f1829d2d8 [Decompilation] [th01] Boss entities: Copying .BOS metadata
So if the boss entity class stores all non-pixel metadata for its
associated .BOS file, how can YuugenMagan have 5 independent eye
sprites, or Kikuri have more than one soul and tear sprite?
By duplicating that data, of course!

Those structure copies to local variables seen in the load functions
of these bosses still remain pointless, though.

Completes P0106, funded by Yanga.
2020-08-12 17:51:40 +02:00
nmlgc 342e6450bc [Decompilation] [th01] Boss entities: .BOS load function
"Hm, I have this format that specifies sprite width in multiples of 8,
but *actually*, I'd like to blit 16 pixels at a time… well, time to
pepper the code with divisions and casts, I guess :zunpet:"

Which becomes even more hilarious once you realize that the `operator
new` function does require bytes after all. Which leads

	new dots16_t[image_size / 2];

to compile to

	operator new((image_size / 2) * 2);

:tannedcirno:

Part of P0106, funded by Yanga.
2020-08-12 17:49:35 +02:00
nmlgc 5f5eb8aa4e [Decompilation] [th01] .BOS: Unused and broken plane pointer reset function
Because that's not how you free dynamically allocated memory?

Part of P0106, funded by Yanga.
2020-08-12 17:49:34 +02:00
nmlgc 1a595cf60c [Reverse-engineering] [th01] Boss entity classes
What else to call something a boss can have multiple of, that may or
may not be part of a larger boss sprite, may or may not be animated,
and that may or may not have a orb hitbox?

Needed to be RE'd before the .BOS loading functions, because those are
actually methods of this class. And because renaming all these
variables in ASM land is tedious anyway, we might as well name each
individual entity of every boss.

Still, what's with the pointless local variable copies in the
YuugenMagan and Kikuri functions?

Part of P0106, funded by Yanga.
2020-08-12 17:49:34 +02:00