Commit Graph

1234 Commits

Author SHA1 Message Date
nmlgc 808a5b94d3 [Reverse-engineering] [th05] Line sets: Structure
Not just used for the zooming lines in Shinki's background, but also
for the pentagram (and circle!) in EX-Alice's background.

Part of P0110, funded by [Anonymous] and Blue Bolt.
2020-08-19 20:10:06 +02:00
nmlgc 3821333a7f [Reverse-engineering] [th05] Bosses: Background particle structure
Straightforward even without looking at the functions more closely.

Part of P0110, funded by [Anonymous] and Blue Bolt.
2020-08-19 20:10:04 +02:00
nmlgc 40aea2d171 [Maintenance] [th05] Declare the particle sprite size in a single place
Because it's used by more than one entity type.

Part of P0110, funded by [Anonymous] and Blue Bolt.
2020-08-19 19:33:32 +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 2c7d86bc5b [Decompilation] [th05] Mai & Yuki: Smooth random movement
Wow, so the boss_stuff_t structure did exist in the original code after
all. This is the only function in all of TH04 and TH05 that confirms
it – in dea40ad, it just seemed like something I made up, out of
convenience.

Completes P0109, funded by [Anonymous] and Blue Bolt.
2020-08-16 21:41:34 +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 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 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 4f7a3a28c3 [Reverse-engineering] [th05] Difficulty- and rank-based bullet pattern tuning
If C allowed labels of other functions as `goto` targets, this *might*
have been decompilable into something useful to modders. But like this,
there's no point in even trying.

Yeah, you *really* don't want to base your fangame mod on TH05.

Part of P0109, funded by [Anonymous] and Blue Bolt.
2020-08-16 21:40:33 +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 0644857fcb [Decompilation] [th05] Bosses: Smoothly flying towards a point
Found a uth05win inaccuracy! Once the Y coordinate gets close enough to
the target point, it actually speeds up twice as much as the X
coordinate would. This might make uth05win a couple of frames slower in
all boss fights from Stage 3 on.

And yeah, got too used to decompilation to go back to splitting off
RE'd functions in ASM land 😛

Part of P0109, funded by [Anonymous] and Blue Bolt.
2020-08-16 21:40:31 +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
nmlgc 11b776b32e [Decompilation] [th01] 8×8 diamond, star, and snowflake sprite blitting
More hardcoded sprites! These are prominently seen in the Konngara,
Elis, and Sariel battles, respectively.

Completes P0105, funded by Yanga.
2020-08-12 16:24:04 +02:00
nmlgc 757f00e063 [Decompilation] [th01] Unaligned monochrome 8×8 sprite blitting
This is a perfectly fine generic sprite blitting function. Why doesn't
this game have more of these?

Part of P0105, funded by Yanga.
2020-08-12 16:21:28 +02:00
nmlgc 96e06fc746 [Decompilation] [th01] .GRC: Freeing images in a single slot
Part of P0105, funded by Yanga.
2020-08-12 16:20:54 +02:00
nmlgc 7ca525ba5c [Decompilation] [th01] .GRC: Byte-aligned blitting
And that's all? No unblitting or non-aligned functions? Oh well, at
least this one correctly clips the sprite at all 4 edges of VRAM, for
once.

Part of P0105, funded by Yanga.
2020-08-12 16:20:18 +02:00
nmlgc 72538610ba [Decompilation] [th01] .GRC: Load function
Still no idea what those 7 unknown bytes in the .GRC and .BOS headers
could be.

Part of P0105, funded by Yanga.
2020-08-12 16:19:39 +02:00
nmlgc b22bc80e98 [Reverse-engineering] [th01] .GRC: Slot structure
Part of P0105, funded by Yanga.
2020-08-12 16:17:58 +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 67d35115e6 [Maintenance] Use inline functions for all VRAM offset calculations
At least those can all be moved to a single place.

Part of P0105, funded by Yanga.
2020-08-12 16:16:18 +02:00
nmlgc a75e0f8f53 [Maintenance] Compile all VRAM-accessing translation units as C++
Leading to slight complications in TH02's Music Room and shot type
selection menus. Thought about leaving those in C for a while, but I
still think it's worth it for the consistency we get with the VRAM
offset functions. Also, we'll have similar code for the main menus of
later games, and I'll surely won't be using C++ when starting out with
these.

Part of P0105, funded by Yanga.
2020-08-12 16:16:09 +02:00
nmlgc 22b019db05 [Decompilation] Declare a trivially constructible Point type
Well, if master.lib insists on defining constructors and therefore make
its `Point` type unusable in C++ mode… This new type might replace some
of the typically separate X and Y function parameters, and reduce our
overall dependence on <master.h>.

… yeah, too bad that you can't simply #undef and then re-#define
`__cplusplus`, but what can you do.

Part of P0105, funded by Yanga.
2020-08-12 16:13:18 +02:00
nmlgc 74b834fd7f [Maintenance] Use a distinct name for arc_file_get()'s sizeof() macro
We not only actually still need the (pointer, size) function to fill
heap-allocated memory, but we also need to differentiate between near
and far pointers, to move those pesky `PUSH DS` instructions to their
original places?!

Part of P0105, funded by Yanga.
2020-08-12 16:12:02 +02:00
nmlgc 3622eb6298 [Decompilation] [th01] HUD: Stage number rendering
Completes P0104, funded by Ember2528.
2020-07-27 17:23:06 +02:00
nmlgc 8367a41d46 [Maintenance] Decide on *_id for 0-based, and *_num for 1-based IDs
Which we've been already subconciously doing with the resident
`demo_num` variable.

Part of P0104, funded by Ember2528.
2020-07-27 17:22:28 +02:00
nmlgc afd74fb8aa [Decompilation] [th01] 16-bit integer to string conversion
"Hey, let's have separate functions for uint16_t and int16_t… and then
just *not* support negative numbers in the latter" :zunpet:

Part of P0104, funded by Ember2528.
2020-07-27 17:22:16 +02:00
nmlgc a0215ea85c [Decompilation] [th01] HUD: Life and bomb count rendering
If you've ever cheated more than 6 lives in TH01, you might have
noticed that those additional lives appear in additional rows in the
HUD. And well, that had to be coded somewhere…

Part of P0104, funded by Ember2528.
2020-07-27 17:20:29 +02:00
nmlgc e0bcdafb00 [Maintenance] [th01] Declare proper IDs for all .PTN sprites seen so far
Part of P0104, funded by Ember2528.
2020-07-27 17:19:48 +02:00
nmlgc f3093a802c [Decompilation] [th01] HUD: Inter-page row-sized rectangle blitting
Both inlined and non-inlined page switching within the same function,
together with an approach that doesn't correspond to our other planar
access macros? That code must have been written during a very
experimental phase very early in the development of this game.

Part of P0104, funded by Ember2528.
2020-07-27 17:19:12 +02:00
nmlgc edd9a14273 [Decompilation] [th01] HUD: Background (MASK.GRF) loading and rendering
Look, it's a memory leak!

Part of P0104, funded by Ember2528.
2020-07-27 17:17:59 +02:00