Commit Graph

281 Commits

Author SHA1 Message Date
nmlgc 158a91e3ce [Maintenance] [th01] FUUIN.EXE: Move master.lib data back to the main ASM husk
Completes P0213, funded by Ember2528 and GhostRiderCog.
2022-08-11 23:21:23 +02:00
nmlgc 1fd32fad0f [Decompilation] [th01] FUUIN.EXE: Move the final pieces of data to C land
100%.

Part of P0213, funded by Ember2528 and GhostRiderCog.
2022-08-11 23:21:23 +02:00
nmlgc 96e18b33be [Decompilation] [th01] FUUIN.EXE: main()
The final secret of this executable: With a loaded MDRV2, enter

	fuuin t1

on the DOS prompt to view the 魔界/Makai Good Ending, or

	fuuin t

for the 地獄/Jigoku Good Ending.

(Bad Endings can only be accessed by pre-allocating the TH01 resident
structure and setting one of the `continues_per_scene` array members to
a nonzero value.)

Part of P0213, funded by Ember2528 and GhostRiderCog.
2022-08-11 23:21:23 +02:00
nmlgc 90077fdc79 [Decompilation] [th01] Move FUUIN.EXE input and High Score data to C land
Might as well figure out that horribly entangled data layout sooner
rather than later…

Part of P0213, funded by Ember2528 and GhostRiderCog.
2022-08-11 23:21:23 +02:00
nmlgc 643f662815 [Decompilation] [th01] VSync interrupt handler: Move all data to C land
Ending the data catch-up with… an unused mouse cursor graphic?!

Part of P0213, funded by Ember2528 and GhostRiderCog.
2022-08-11 23:21:23 +02:00
nmlgc c5b7f8d771 [Decompilation] [th01] Text mode functions: Move all data to C land
Part of P0213, funded by Ember2528 and GhostRiderCog.
2022-08-11 23:21:23 +02:00
nmlgc 6b3fc6c4d1 [Decompilation] [th01] Game init and exit functions: Move all data to C land
Part of P0213, funded by Ember2528 and GhostRiderCog.
2022-08-11 23:21:23 +02:00
nmlgc 443a334067 [Decompilation] [th01] Core graphics/palette functions: Move all data to C land
Part of P0213, funded by Ember2528 and GhostRiderCog.
2022-08-11 23:21:23 +02:00
nmlgc e79f6c62bf [Decompilation] [th01] .GRP / .GRZ / .PTN: Move all data to C land
Cross-executable ZUN bloat 🤮

Part of P0213, funded by Ember2528 and GhostRiderCog.
2022-08-11 23:21:23 +02:00
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