Commit Graph

1295 Commits

Author SHA1 Message Date
nmlgc f6a3246071 [Reverse-engineering] Enabling and disabling the EGC
Which involves temporarily enabling a GDC mode change bit.

Completes P0125, funded by [Anonymous].
2020-11-02 23:42:04 +01:00
nmlgc 6a8de71720 [Maintenance] master.hpp transition: EGC declarations
Part of P0125, funded by [Anonymous].
2020-11-02 23:33:09 +01:00
nmlgc e8ae29ca4e [Maintenance] Remove the old `planar(8|16|32)_t` types
All code that used them has transitioned to C++, and can use the
Planar<> template.

Part of P0125, funded by [Anonymous].
2020-11-02 23:04:54 +01:00
nmlgc deecfeb0d1 [Position independence] [th02] graph_putsa_fx() calls in MAINE.EXE
Part of P0125, funded by [Anonymous].
2020-11-02 23:00:54 +01:00
nmlgc 8eb0d33e80 [Decompilation] [th04] Character selection: Raised top/left edge background
Yup, no trick there. If the selection moves to the other character, the
original background behind the raised top and left edges has to be
blitted back to VRAM, which means that it also has to be stored
somewhere. TH04 backs up exactly the two 256×8 and 8×244 strips behind
Reimu and Marisa, requiring 2 KB of heap memory, whereas TH05 simply
gave up, and backs up the entire 640×400 screen, totalling 128 KB.

Part of P0125, funded by [Anonymous].
2020-11-02 22:43:05 +01:00
nmlgc 056b1c77c1 [Decompilation] [th04] Player character and shot type selection menu
Significantly more complex than the single menu in TH05!

Completes P0124, funded by [Anonymous] and Blue Bolt.
2020-11-02 22:41:51 +01:00
nmlgc f1c63ab3a1 [Reverse-engineering] Assign names to all graph_putsa_fx() effects
And get rid of the constraining FX() macro, with its spacing parameter
that we haven't even seen used so far.

Part of P0124, funded by [Anonymous] and Blue Bolt.
2020-11-02 22:33:50 +01:00
nmlgc 774b172028 [Maintenance] Only define pi_load_put_8_free() a single time
The change of pi_free() from a macro to a function in TH05 doesn't
require a complete redefinition.

Part of P0124, funded by [Anonymous] and Blue Bolt.
2020-11-02 22:30:39 +01:00
nmlgc 3ee848f456 [Maintenance] [th05] Use master.hpp for the character selection menu
6149 LoC with the original master.h, vs. 2524 LoC *and* additional
semantic sugar with master.hpp. Nice!

(Yes, *semantic* sugar.)

Part of P0124, funded by [Anonymous] and Blue Bolt.
2020-11-02 22:21:51 +01:00
nmlgc 30462cc64f [Maintenance] Indicate byte alignment for all .PI blitting functions
Part of P0124, funded by [Anonymous] and Blue Bolt.
2020-11-02 22:19:12 +01:00
nmlgc b674adff18 [Maintenance] master.hpp transition: Heap functions
Part of P0124, funded by [Anonymous] and Blue Bolt.
2020-11-02 22:17:48 +01:00
nmlgc 327f68a8d2 [Maintenance] Fix the names for DEFCONV functions in ASM land -.-
Part of P0124, funded by [Anonymous] and Blue Bolt.
2020-11-02 22:15:42 +01:00
nmlgc 65a12d13a8 [Maintenance] master.hpp transition: .PI declarations
Part of P0124, funded by [Anonymous] and Blue Bolt.
2020-11-02 22:09:17 +01:00
nmlgc c8fa62d0c2 [Maintenance] master.hpp transition: GRCG declarations
Part of P0124, funded by [Anonymous] and Blue Bolt.
2020-11-02 21:50:51 +01:00
nmlgc e78f73d779 [Maintenance] master.hpp transition: Graphics declarations
Part of P0124, funded by [Anonymous] and Blue Bolt.
2020-11-02 21:48:51 +01:00
nmlgc 02cd7f4acc [Maintenance] master.hpp transition: Palette declarations
Since we can't even change whitespace inside a preprocessor macro
without getting a `redefinition is not identical` warning, these have
to be wrapped in `#if !defined(__MASTER_H)` blocks for now.

Part of P0124, funded by [Anonymous] and Blue Bolt.
2020-11-02 21:45:56 +01:00
nmlgc 7306a4b185 [Maintenance] master.hpp transition: VSync declarations
Merely applying our coding style for now.

Part of P0124, funded by [Anonymous] and Blue Bolt.
2020-11-02 21:43:39 +01:00
nmlgc 0a25a0ac01 [Maintenance] Remove the RES_ID_LEN macro
And no longer force translation units that access the resident
structure into #including that mistake that was ReC98.h.

Part of P0124, funded by [Anonymous] and Blue Bolt.
2020-11-02 21:17:55 +01:00
nmlgc 8266bbd83e [Maintenance] Start a C++ master.lib header file
The regular master.h is big, uncomfortable in C++ mode, and bloated
with all those portability `#define`s that effectively only cover a
small portion of the PC-98-specific code anyway. So, let's gradually
transition to a new smaller header that is more integrated into the
ReC98 codebase, by simply no longer #including `master.h` in new code.

Which also explains its weird place in the root directory. Even though
`libs/master.lib/` contains plenty of game-specific modifications, it
didn't feel right to have anything in this directory refer to types
from `pc98.h`.

Part of P0124, funded by [Anonymous] and Blue Bolt.
2020-11-02 21:12:59 +01:00
nmlgc 72dfa096d1 [Decompilation] [th01] Setting the default stage palette
Completes P0123, funded by Yanga.
2020-10-13 21:48:54 +02:00
nmlgc 7b2653fcab [Decompilation] [th01] Reimu's animations: .BOS freeing function
*Still* no need for the classic `if(ptr) { delete[] ptr; ptr = NULL }`
macro, because who cares about dangling pointers anyway, right?
:zunpet:

Part of P0123, funded by Yanga.
2020-10-13 21:48:07 +02:00
nmlgc d2ba0c7b3b [Decompilation] [th01] Reimu's animations: Byte-aligned overlapped blitting
All this CPU time spent optimizing the unblitting mask, yet the code
still ends up glitching if the two sprites are more than 2 horizontal
bytes away. So, Reimu's slide speed can only be as high as 8 pixels per
frame, before this function fails to unblit the previous sprite and
leaves little Reimu parts in VRAM.

Part of P0123, funded by Yanga.
2020-10-13 21:36:07 +02:00
nmlgc 0be79aa641 [Decompilation] [th01] Reimu's animations: Byte-aligned blitting
Part of P0123, funded by Yanga.
2020-10-13 21:34:41 +02: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 10666131ec [Decompilation] [th01] Reimu's animations: .BOS load function
Part of P0123, funded by Yanga.
2020-10-13 21:15:19 +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 11f65e4afb [Reverse-engineering] [th01] Reimu's animations: Structure
Part of P0123, funded by Yanga.
2020-10-13 20:50:09 +02:00
nmlgc 4406c3d815 [Decompilation] [th01] Shootout lasers: Broken reset function
Two ZUN bugs in a single function call! These end up causing
effectively random sprite pixels to disappear during the transition to
the boss clear tally screen, if the boss was killed while any shootout
lasers were on screen. And once again, one of those bugs would have
been a non-issue with strong enough typing…

Oh well, that's all there is to this class.

Completes P0122, funded by Yanga.
2020-10-06 18:35:30 +02:00
nmlgc 60c1031d31 [Decompilation] [th01] Shootout lasers: Update/collision/render function
A public interface of two functions… nice.

Part of P0122, funded by Yanga.
2020-10-06 18:35:27 +02:00
nmlgc 243dbf8d0d [Decompilation] [th01] Shootout lasers: Rendering and collision detection
Part of P0122, funded by Yanga.
2020-10-06 18:35:24 +02:00
nmlgc 61559859e3 [Decompilation] [th01] Shootout lasers: Spawn function
Part of P0122, funded by Yanga.
2020-10-06 14:16:40 +02:00
nmlgc 800d7173aa [Reverse-engineering] [th01] Shootout lasers: Structure
Not to be confused with stationary lasers (as used by YuugenMagan, for
example), which are just regular lines with collision detection. 🥴

Also, 22 unused bytes out of 69, with another 11 that could have easily
been exchanged for better code…

Part of P0122, funded by Yanga.
2020-10-06 14:16:13 +02:00
nmlgc 50c498a549 [Reverse-engineering] [th01] Shootout lasers: Hardcoded sprites
First ZUN bug in sprite preshifting! One wrongly shifted pixel means
that we can't use the auto-preshift feature of our sprite converter -.-

Also, why did these even have to be hardcoded sprites to begin with.
These dot patterns could have been easily generated procedurally… but
even *that* wouldn't have been necessary, given that there's this nice
function called, uh, graph_r_line_patterned()? Which could have
rendered all of the lasers in the upcoming class and more?

Part of P0122, funded by Yanga.
2020-10-06 13:52:22 +02:00
nmlgc eb89330f64 [Build] [th01] Move the -Z and -3 options onto the command line
Deactivating them is the exception, not the norm.

Part of P0122, funded by Yanga.
2020-10-06 13:27:33 +02:00
nmlgc 164591f9fe [Maintenance] Consistently express angle literals in signed hex format
Originally just a workaround to remove angles from the PI counter, but
having the sign indicate the Y direction also makes them a lot nicer to
read in C land.

(Maintenance mode commit)
2020-10-02 14:48:54 +02:00
nmlgc 1610d7b63d [Maintenance] Decide on a consistent place for file-wide `#pragma`s
(Maintenance mode commit)
2020-10-01 16:35:56 +02:00
nmlgc ec5b75daab [Maintenance] [th05] Yumeko's blades are actually swords, as stated in OMAKE.TXT
*Technically* also a uth05win inaccuracy. That codebase went with
"KnifeBullet", which seemed right, so I just ran with it without
researching it further… My bad.

(Maintenance mode commit)
2020-09-30 18:12:53 +02:00
nmlgc 8c1d4bf41b [Maintenance] Locate the BSS segment of master.lib's `clip.asm`
By now, it's become obvious where it has to be. Apparently, the order
of translation units inside ZUN's modified master.lib did somehow
change with TH02?

(Maintenance mode commit)
2020-09-29 07:03:06 +02:00
nmlgc 5c42fcd918 [Decompilation] [th01] VRAM page transition via interleaving 8×8 squares
Used for the blocky transition to Sariel's first and second phases.

Completes P0121, funded by Yanga.
2020-09-28 13:10:02 +02:00
nmlgc 1184f6c671 [Decompilation] [th01] Interleaving both VRAM pages in an 8×8 square
Some of the unused interleave masks are not that straightforward, so it
makes sense to have all of them as a bitmap. I'm positive that this
sort of thing could have been EGC-accelerated… although, simply
writing better C would probably already go a long way.

Part of P0121, funded by Yanga.
2020-09-28 13:09:49 +02:00
nmlgc 92725007a8 [Decompilation] [th01] EGC-accelerated VRAM page 1➜0 row blitting
Well well, the choice between sorting this function mechanically (and
putting it next to the EGC functions) or contextually (and putting it
next to the GDC SCROLL function)… Any choice would eventually turned
out suboptimal, I'm sure. 😅

Part of P0121, funded by Yanga.
2020-09-28 13:07:29 +02:00
nmlgc 1801e29cb3 [Maintenance] Rename the EGC implementation files a bit
Part of P0121, funded by Yanga.
2020-09-28 13:06:11 +02:00
nmlgc 0de07a489f [Maintenance] Mirror the egc_setup_copy() macro in C land
Part of P0121, funded by Yanga.
2020-09-28 13:05:15 +02:00
nmlgc 60ee6e94fc [Decompilation] [th01] 32×32 square inversion on a single bitplane
The main effect behind the discoloration seen in the bomb animation,
as well as the exploding squares at the end of Kikuri's and Sariel's
entrance animation.

Single-function segments are lovely, by the way!

Part of P0121, funded by Yanga.
2020-09-28 13:05:07 +02:00
nmlgc 37d191d903 [Decompilation] [th01] Player invincibility sprite rendering
So ZUN *did* want to clip those at the left and right edges of VRAM,
but accidentally tested the Y instead of the X coordinate 🎺

Part of P0121, funded by Yanga.
2020-09-28 13:02:34 +02:00
nmlgc 668b9033ab [Decompilation] [th01] Line loop unblitting
Same here.

Part of P0121, funded by Yanga.
2020-09-28 13:01:07 +02:00
nmlgc 60389473aa [Decompilation] [th01] Line loop blitting
Wait, so if this is only used for the rotating white squares around
Mima, that must mean that the white star in the YuugenMagan fight got a
completely redundant reimplementation…

Part of P0121, funded by Yanga.
2020-09-28 12:56:52 +02:00
nmlgc 3c008b6a4f [Decompilation] [th01] Invincibility sprite blitting
In which ZUN accidentally the GRCG rather than the EGC in what should
have been (?) the unblitting function. Which then ends up actually
blitting yet another randomly background-masked version of the same
sprite on top of the old one. And after just a few frames, you get
those fully filled red diamonds you don't see in the sprite sheet.

Then again, if the 16w×h rectangle unblitting function is all you
have, and you can't be bothered to actually learn the EGC, this *is*
the better option 🎺

Completes P0120, funded by Yanga.
2020-09-28 12:56:05 +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