Commit Graph

272 Commits

Author SHA1 Message Date
nmlgc e97a869e90 [Maintenance] [th01] Compile all remaining C code as C++
And all that it needed was a few ellipses.

Part of P0212, funded by GhostRiderCog, Lmocinemod, and LeyDud.
2022-08-11 15:50:19 +02:00
nmlgc d398a949fc [Decompilation] High score menu: Move all data to C land
Completes P0211, funded by Lmocinemod and Arandui.
2022-08-08 20:16:29 +02:00
nmlgc 6e36dfd93b [Decompilation] [th01] Verdict screen: Move all data to C land
Part of P0211, funded by Lmocinemod and Arandui.
2022-08-08 20:16:25 +02:00
nmlgc 64fe9bbff9 [Decompilation] [th01] Endings: Common beginning
Part of P0211, funded by Lmocinemod and Arandui.
2022-08-08 20:16:21 +02:00
nmlgc 57835690e8 [Maintenance] [th01] Move BSS data of FUUIN.EXE segments ≥4 to the data unit
Part of P0207, funded by GhostPhanom.
2022-08-08 20:11:05 +02:00
nmlgc 001033d15a [Maintenance] [th01] Remove `extern "C"` from more areas of code
The .GRC and .GRP functions, to be specific.

Part of P0203, funded by [Anonymous] and GhostRiderCog.
2022-07-10 13:09:12 +02:00
nmlgc bfdb1e33f4 [Decompilation] [th01] Endings: Bad
Part of P0200, funded by Yanga.
2022-06-17 15:30:30 +02:00
nmlgc cfb0b5f21b [Decompilation] [th01] Endings: Good
100 functions remaining in all of TH01!

Part of P0200, funded by Yanga.
2022-06-17 15:30:30 +02:00
nmlgc f1dbf5f13f [Decompilation] [th01] Endings: Boss slideshow
Alignment hacks! Alignment hacks everywhere.
(The translation unit layout workarounds are temporary, at least.)

Part of P0200, funded by Yanga.
2022-06-17 15:30:30 +02:00
nmlgc 7bdf35a22b [Maintenance] [th01] Remove `extern "C"` from more areas of code
The .BOS freeing funtions, others that are close to them in the typical
#include order, and the ending picture functions.

Part of P0198, funded by Lmocinemod and Ember2528.
2022-06-16 22:51:07 +02:00
nmlgc 48db0b7a72 [Decompilation] [th01] Verdict screen: Title calculation
You can definitely make an argument that these if/else if branches are
easier to read than their implied formula, especially with all
variables being signed here.

Completes P0197, funded by Yanga and Ember2528.
2022-06-01 02:27:52 +02:00
nmlgc 2863a69836 [Decompilation] [th01] Verdict screen: Main function
Part of P0197, funded by Yanga and Ember2528.
2022-06-01 02:27:52 +02:00
nmlgc e15942bb7c [Maintenance] [th01] Add string length calculation wrappers for VRAM typing
Part of P0197, funded by Yanga and Ember2528.
2022-05-31 23:39:34 +02:00
nmlgc 94372d2e27 [Maintenance] [th01] Move data of FUUIN.EXE segments ≥4 to a new assembly unit
Turns out that the "new idea" for handling these data slices won't work
out in reality. At least the amount of necessary manual `extern`
declarations isn't soul-crushingly large, so this way isn't bad either,
after all!

Part of P0197, funded by Yanga and Ember2528.
2022-05-31 23:39:34 +02:00
nmlgc 0062826327 [Separating translation units] [th01] Additional hardware effect functions
These could have been nicely separated into per-device translations
(one for GDC, one for EGC, one for regular VRAM accesses)… if their
original order followed that classification.

OK, so let's make it one full `graph_ex.cpp` translation unit… nope,
FUUIN.EXE needs graph_2xscale_byterect_1_to_0_slow() with different
compilation flags. 🤦

Whatever, fuck it, let's go for individual translation units, with
individual headers, so that we at least get predictably organized
source code out of this.

Part of P0196, funded by Yanga.
2022-05-31 23:15:14 +02:00
nmlgc 91984de4b2 [Maintenance] [th01] Remove `extern "C"` from more areas of code
The additional hardware effect functions, as well as the High Score
menu code.

Part of P0193, funded by Ember2528.
2022-05-31 22:55:33 +02: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 692e8d1c42 [Naming] [th01] Remove "back/front" terminology from inter-page copy functions
TH01 doesn't use "back" and "front" pages in the way the later games
do, after all. Indicating that the source page of this parameter-less
function is the one that was previously set via graph_accesspage_func()
is going to make pretty much all its call sites way clearer, and stops
implying any further state.

Part of P0167, funded by Ember2528.
2021-11-07 23:27:30 +01:00
nmlgc f005eb023b [Maintenance] Remove all unused externs in ASM land
Part of P0158, funded by Yanga.
2021-09-28 18:05:24 +02:00
nmlgc 531b044cb9 [Separate translation units] [th01/th02/th03/th04] vram_planes_set()
Boom! Clever segment renaming allows us to link the same .OBJ into 12
binaries.
(Well, 10 for now, due to alignment issues in TH04's OP.EXE and
MAINE.EXE.)

Part of P0138, funded by [Anonymous] and Blue Bolt.
2021-04-21 17:40:11 +02:00
nmlgc 8bcf5d7b84 [Regression] Explicitly request 16-bit default segments when using .MODEL
Whoops, turns out that the build has been broken on TASM32 version 5.3
(the one in the DevKit) ever since 7897bf1. In contrast to version 5.0
(which I use for my development), 5.3 actually defines 32-bit segments
if you specify a .386 CPU before using .MODEL.

That might have been the reason for the .286 workaround all along?
Turns out there's the USE16 modifier, which makes this much more
explicit than switching CPUs.
2021-03-29 22:39:11 +02:00
nmlgc a186074af3 [Separate translation units] [th01] .PTN, .GRP, and .GRZ formats
Since I'd still prefer to not use include guards *and* to have that
standalone .GRZ viewer, these would have actually caused somewhat of
an issue with the upcoming final stretch of the master.hpp transition.

Part of P0133, funded by [Anonymous].
2021-01-30 19:17:16 +01:00
nmlgc 0d137ee526 [Maintenance] Move the vram_planes_set() declaration to its own header file
Might seem inconsistent, given that the function initializes pointers
that are declared in planar.h… but it's always called from other game
initialization functions that don't require pc98.h or planar.h.

Part of P0133, funded by [Anonymous].
2021-01-30 19:11:55 +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 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 40b8325cc3 [Maintenance] [th01] Move MDRV2 files to a separate `snd/` directory
Consistency… even though we won't have more of those in this game.

Part of P0098, funded by Yanga.
2020-06-13 21:15:30 +02:00
nmlgc 6b2a54d8d2 [Position independence] [th01] Final false positives in OP.EXE and FUUIN.EXE
100% PI for both! Now, where are all the modders who wanted to replace
MDRV2 with PMD… because you can now prototype that, without worring
about x86 instruction lengths, at least inside the main menu.

Part of P0095, funded by Yanga.
2020-05-31 17:29:05 +02:00
nmlgc e1a728f9e3 [Position independence] [th01] Remaining graph_printf_fx() calls
Part of P0095, funded by Yanga.
2020-05-31 17:25:14 +02:00
nmlgc 57a8487084 [Decompilation] [th01] FUUIN.EXE resident structure data retrieval
Completes P0094, funded by Yanga.
2020-05-25 15:22:53 +02:00
nmlgc 026fff63a5 [Decompilation] [th01] Ending picture loading and display
Aww, how far we've come with inlining and helpful macros.

Part of P0094, funded by Yanga.
2020-05-25 15:18:44 +02:00
nmlgc 5c77db08ca [Decompilation] [th01] High score registration
Completing the high score menu with a final stupid set of
inconsistencies between REIIDEN.EXE and FUUIN.EXE. Oh well.

Part of P0094, funded by Yanga.
2020-05-25 15:16:40 +02:00
nmlgc 3bd824b5be [Maintenance] [th01] Add a header for the slow 2× rectangle scale function
Part of P0094, funded by Yanga.
2020-05-25 15:14:19 +02:00
nmlgc 0e73029276 [Decompilation] [th01] High score menu: Name entering loop
The REIIDEN.EXE version (which is only shown when game-overing) has a
completely invisible timeout that force-enters a high score name after
1000... *keyboard inputs*? Not frames? Why. Like, how do even you
realistically to such a number.
(Best guess: It's a hidden easter egg to amuse players who place
drinking glasses on cursor keys. Or beer bottles.)

And hey, that initialization of the name variable with ASCII spaces.
The only actually meaningful byte-wise access… except that it's not,
because ZUN could have just used the Shift-JIS ideographic space for
the exact same effect.

Completes P0093, funded by Ember2528.
2020-05-25 15:11:12 +02:00
nmlgc bbef9b0bdb [Decompilation] [th01] REYHI*.DAT saving
Now with POSIX file I/O in both executables. And the confirmation that
the name array is indeed exclusively accessed per-byte.

Part of P0093, funded by Ember2528.
2020-05-25 15:10:07 +02:00
nmlgc 6e0c33a8bf [Decompilation] [th01] High score menu: Input handling
It's exactly as terrible as you would have expected after hearing
"alphabet cursor actually stored as on-screen position". Nothing gained
in reducing redundancy any further here, any meaningful change would
pretty much have to rewrite the entire thing.

Part of P0093, funded by Ember2528.
2020-05-25 15:07:59 +02:00
nmlgc 440330857a [Decompilation] [th01] High score menu: Shot key handling
In which inline functions are apparently the only way to trick Turbo
C++ into not actually optimizing away the useless `AND AL, 0FFh`.

But come on. Just accessing the high score name characters in chunks of
16-bit Shift-JIS codepoints (which is what they are!) instead of
breaking them down to bytes *everywhere* would have been both more
readable (no swapping of Shift-JIS literals, no bitshifts), more
efficient (this isn't running on an 8-bit CPU after all), and less of a
waste of my time…

Completes P0092, funded by Yanga.
2020-05-25 15:06:48 +02:00
nmlgc 7a1332e1f5 [Decompilation] [th01] High score menu: Re-rendering individual characters
Lol, the internal alphabet cursor position is actually stored as the
on-screen top-left position of the selected character, which this
function then maps back to a character index. At least that gets rid of
quite a bunch of PI false positives now.

Part of P0092, funded by Yanga.
2020-05-25 15:05:43 +02:00
nmlgc 57be510056 [Decompilation] [th01] High score menu: Initial table rendering
With ternary operator expressions straight out of Jigoku.
(TL note: Jigoku means hell.)
Nice to see that Turbo C++ apparently has no nesting limit on function
call inlining in general, though!

Part of P0092, funded by Yanga.
2020-05-25 15:03:55 +02:00
nmlgc 29c5a7365f [Build] Assemble piloadc as a separate translation unit
Restoring the originally released version here as well… except for
ZUN's custom format magic ID, of course.

Completes P0091, funded by Ember2528.
2020-05-12 15:06:13 +02:00
nmlgc 16ac6b4206 [Decompilation] [th01] High score menu: Initial alphabet rendering
Completes P0091, funded by Ember2528.
2020-05-12 15:06:12 +02:00
nmlgc 4f87ec8152 [Decompilation] [th01] Blitting full-width numbers onto VRAM
Part of P0091, funded by Ember2528.
2020-05-12 15:06:12 +02:00
nmlgc 651d09f5bd [Decompilation] [th01] Keyboard input in FUUIN.EXE
The only TH01 executable not supporting the numpad?

And that's the point where you just rewrite the distinct input_prev_*
values as a single array, because they're local to input_sense()
anyway.

Part of P0091, funded by Ember2528.
2020-05-12 15:06:11 +02:00
nmlgc c0b44ecaec [Position independence] Remaining references to _ctype
Part of P0087, funded by -Tom-.
2020-04-15 21:34:20 +02:00
nmlgc 7698f5da6d [Maintenance] Compress unknown BSS regions using byte arrays
Also something that any future ReC project should be doing right at the
start. Finally, it made sense to do it here as well, because…

Part of P0084, funded by Yanga.
2020-03-22 10:16:09 +01:00
nmlgc c338305a61 [Decompilation] REYHI*.DAT loading and recreation
With master.lib file I/O in REIIDEN.EXE, and POSIX file I/O in
FUUIN.EXE… yup.

Part of P0084, funded by Yanga.
2020-03-22 10:16:08 +01:00
nmlgc e5af7a9ff5 [Maintenance] [th01] Split the REYHI*.DAT function segment into two
Painless this time, since we're only splitting off a handful of
functions there. Any future ReC project should simply assign every
function to its own segment though, to avoid having to do this…

Definitely going to do that more often now, especially for OP and
cutscenes of other games!

Part of P0084, funded by Yanga.
2020-03-22 10:02:12 +01:00
nmlgc ee9168b7eb [Reverse-engineering] [th01] REYHI*.DAT structure
Part of P0084, funded by Yanga.
2020-03-22 10:01:16 +01:00
nmlgc dfac2f2fd4 [Position independence] [th01] EGC-powered page 1→0 region copy calls
12.4 fixed-point subpixels, in TH01?

Completes P0083, funded by Yanga.
2020-03-18 20:33:59 +01:00
nmlgc f6cbff0bf9 [Decompilation] [th01] .GRP file loading and display
All the weird double returns in FUUIN.EXE just magically appear with
-O-! 😮

And yeah, it's a bowl of global state spaghetti once again. 🍝 Named
the functions in a way that would make sense to a user of the API, who
should be aware of typical side effects, like, y'know, a changed
hardware palette… That's how you end up with the supposed "main"
function getting a "_palette_show" suffix.

Completes P0082, funded by Ember2528.
2020-03-13 19:48:38 +01:00
nmlgc 76634342f1 [Reverse-engineering] [th01] Global .GRP and .PTN variables
Since we not only have the .PTN sub-image count array in the middle of
all those .GRP flags, but the .PTN loading code also reusing the
palette set flag…

Part of P0082, funded by Ember2528.
2020-03-13 19:14:45 +01:00