Commit Graph

1309 Commits

Author SHA1 Message Date
nmlgc 5965930bd0 [Decompilation] [th03] .MRS: Persistent horizontal flipping
Another function consisting almost entirely of inline ASM. Still worth
it though, if only to save us from duplicating any declarations in ASM
land.

Part of P0126, funded by [Anonymous] and Blue Bolt.
2020-11-16 20:01:31 +01:00
nmlgc 08a09aabb2 [Reverse-engineering] [th03] .MRS: Bitplane pointers
Part of P0126, funded by [Anonymous] and Blue Bolt.
2020-11-16 20:01:26 +01:00
nmlgc baac3f7682 [Decompilation] [th04/th05] EGC-powered page 1→0 rectangle blitting
Actually fairly average, as far as unreasonable decompilations are
concerned. No `goto`, at least! Another place that would benefit from
EGC raster op documentation, though.

Also, got one more padding byte in TH05's MAINE.EXE correct. 🙂

Part of P0126, funded by [Anonymous] and Blue Bolt.
2020-11-16 20:01:09 +01:00
nmlgc b504d72301 [Maintenance] Move decomp.h out of th01/hardware/egc.h
Part of P0126, funded by [Anonymous] and Blue Bolt.
2020-11-15 21:30:58 +01:00
nmlgc 74a11d667d [Maintenance] master.hpp transition: Resident data
With a type-safe wrapper template that removes the need for ID length
and structure-size-in-paragraphs macros. *And* <dos.h>!

Part of P0126, funded by [Anonymous] and Blue Bolt.
2020-11-15 21:28:55 +01:00
nmlgc 9c36df72e5 [Maintenance] [th01] Get rid of th01.h
Part of P0126, funded by [Anonymous] and Blue Bolt.
2020-11-15 21:27:41 +01:00
nmlgc aea27d2221 [Maintenance] master.hpp transition: DOS functions
Part of P0126, funded by [Anonymous] and Blue Bolt.
2020-11-15 21:23:29 +01:00
nmlgc 199f73eba4 [Maintenance] master.hpp transition: Math declarations
Part of P0126, funded by [Anonymous] and Blue Bolt.
2020-11-15 21:22:15 +01:00
nmlgc d515d67c9f [Maintenance] master.hpp transition: Optionally buffered single-file I/O
Now the fact that those can be buffered is also documented outside of
MASTER.MAN.

Part of P0126, funded by [Anonymous] and Blue Bolt.
2020-11-15 21:21:04 +01:00
nmlgc 90f1c2ca93 [Maintenance] master.hpp transition: Text RAM declarations
Part of P0126, funded by [Anonymous] and Blue Bolt.
2020-11-15 21:19:42 +01:00
nmlgc b104b3316b [Maintenance] Consistently use Borland's I/O port intrinsics
Rather than preferring either the Microsoft/Watcom `(in|out)pw?` style,
or the Borland `(in|out)portb?` style, master.lib had to introduce its
own `(OUT|IN)P[BW]` naming scheme… Insert obligatory xkcd standards
comic.

Part of P0126, funded by [Anonymous] and Blue Bolt.
2020-11-15 21:16:40 +01:00
nmlgc 6c22af7e83 [Build] [th01] Only compile shared single-file translation units a single time
Which gets rid of 13 redundant translation units. Definitely a good
start, before I figure out how to best handle the more complicated
cases.

(Maintenance mode commit)
2020-11-04 14:47:52 +01:00
nmlgc 7d83739eb8 [Build] [th01] Merge vsync_callback_clear() into vsync.c
Not really surprising why this works, and probably was how the original
code looked all along: The function is never called from anywhere, and
as long as the next function still lies on the same 16-byte paragraph,
it makes no difference whether the unused one is placed at the end of
the previous segment, or the beginning of the next.
Which means we can choose whatever leads to fewer translation units 👍

(Maintenance mode commit)
2020-11-04 14:42:37 +01:00
nmlgc 4850d6d457 [Maintenance] Rename "seg2" to "SHARED"
There's the better name, in ALLCAPS for improved grepping. TH01 is also
going to need a pseudo-binary to bundle translation units that appear
in more than one .EXE, and since "segment 2" would be wrong for that
game, it makes more sense to have one consistent name for these
pseudo-binaries in all games.

(Maintenance mode commit)
2020-11-03 17:01:26 +01:00
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