Commit Graph

2519 Commits

Author SHA1 Message Date
nmlgc 66d83aa183 [Separating translation units] [th04/th05] graph_putsa_fx()
Almost three years after the big SHARED segment separation got
unfortunately stuck thanks to this function, it's finally done!

Part of P0265, funded by [Anonymous] and iruleatgames.
2024-02-03 08:59:48 +01:00
nmlgc 5a65324625 [Maintenance] [th04/th05] Split OP and MAINE data before graph_putsa_fx()
Part of P0265, funded by [Anonymous] and iruleatgames.
2024-02-03 08:59:48 +01:00
nmlgc fd0c95dcd1 [Decompilation] [th04/th05] MAINE.EXE: main()
So anticlimactic, again…
Also, note how renaming the `end_sequence_t` constants to better match
their usage also simplifies the explanatory comment for TH04's
not-quirk.

Part of P0265, funded by [Anonymous] and iruleatgames.
2024-02-03 08:59:48 +01:00
nmlgc 1de8585136 [Decompilation] [th04/th05] MAINE.EXE: Top-level ending function
Part of P0265, funded by [Anonymous] and iruleatgames.
2024-02-03 08:59:48 +01:00
nmlgc 1350a60e3f [Decompilation] [th04/th05] MAINE.EXE: Binary switching
Part of P0265, funded by [Anonymous] and iruleatgames.
2024-02-03 08:59:48 +01:00
nmlgc 09c324fbed [Maintenance] [th04/th05] MAINE.EXE: Duplicate resident pointer loading
With the implementation moved to the header, it makes sense to
duplicate the function in the unfortunate place where the filename is
supposed to be.

Part of P0265, funded by [Anonymous] and iruleatgames.
2024-02-03 08:59:48 +01:00
nmlgc c57992caa9 [Maintenance] [th03/th04/th05] Move resident pointer loading to its own header
Which also highlights that TH05 uses both a master.lib and raw DOS
implementation.

Part of P0265, funded by [Anonymous] and iruleatgames.
2024-02-03 08:59:48 +01:00
nmlgc 2480c76a56 [Naming] [th04/th05] MAINE.EXE: Top-level menu and scene functions
Also formalizing the `*_menu()` naming convention I've been following
for a while.

Part of P0265, funded by [Anonymous] and iruleatgames.
2024-02-03 08:59:48 +01:00
nmlgc 1bb0a92d2d [Research] [th02/th03/th04/th05] Music Room: Text color logic
Part of P0265, funded by [Anonymous] and iruleatgames.
2024-02-03 08:59:48 +01:00
nmlgc f30fa98be8 [Decompilation] [th03/th04/th05] Music Room: Move all remaining data to C land
Part of P0265, funded by [Anonymous] and iruleatgames.
2024-02-03 08:59:48 +01:00
nmlgc b7c8f13d19 [Decompilation] [th03/th04/th05] Music Room: Main function
Part of P0265, funded by [Anonymous] and iruleatgames.
2024-02-03 08:59:47 +01:00
nmlgc 78728f6780 [Decompilation] [th03/th04/th05] Music Room: Comment rendering
Last instance of VRAM-rendered font ROM glyphs in OP.EXE!

Completes P0264, funded by [Anonymous] and Blue Bolt.
2024-02-03 08:59:47 +01:00
nmlgc f1d6ce9a39 [Decompilation] [th03] Music Room: Comment background blitting and freeing
Part of P0264, funded by [Anonymous] and Blue Bolt.
2024-02-03 08:59:47 +01:00
nmlgc cbcb540c54 [Decompilation] [th03/th04/th05] Music Room: Comment loading
Part of P0264, funded by [Anonymous] and Blue Bolt.
2024-02-03 08:59:47 +01:00
nmlgc ee5c7c56d1 [Decompilation] [th03] Music Room: Comment background snapping
Also renaming to `cmt_bg`, because `back` means "back page", which this
is not related to at all.

Part of P0264, funded by [Anonymous] and Blue Bolt.
2024-02-03 08:59:47 +01:00
nmlgc 7ef318fcbc [Decompilation] [th03/th04/th05] Music Room: Page flipping
Part of P0264, funded by [Anonymous] and Blue Bolt.
2024-02-03 08:59:47 +01:00
nmlgc cb7fd94789 [Decompilation] [th03/th04/th05] Music Room: Falling polygon animation
Part of P0264, funded by [Anonymous] and Blue Bolt.
2024-02-03 08:59:47 +01:00
nmlgc 44598e0e9a [Decompilation] [th03/th04/th05] Music Room: B plane snapping and blitting
Might as well give a more descriptive name to the variable than
something involving the generic `screen` (which we've started using for
coordinates) and the inconsistent `back` (which always means "back page
of VRAM", which has nothing to do with this bitplane).
Also, turns out that this was in fact the only place that did a 32-wide
memcpy() of a full VRAM bitplane.

Part of P0264, funded by [Anonymous] and Blue Bolt.
2024-02-03 08:59:47 +01:00
nmlgc dce8ba3ea1 [Decompilation] [th03/th04/th05] Music Room: Rendering the full track list
Part of P0264, funded by [Anonymous] and Blue Bolt.
2024-02-03 08:59:47 +01:00
nmlgc a520b0c283 [Decompilation] [th03/th04/th05] Music Room: Rendering a single title
Part of P0264, funded by [Anonymous] and Blue Bolt.
2024-02-03 08:59:47 +01:00
nmlgc 5b4f24aa0c [Decompilation] [th03/th04/th05] Music Room: Move titles and files to C land
Featuring a return of the recently developed `$ -` tech, along with
some unfortunate PI breaks… But hey, at least it makes sense to start
out with this move!

Part of P0264, funded by [Anonymous] and Blue Bolt.
2024-02-03 08:59:47 +01:00
nmlgc 9651bcf7ee [Naming] [th04/th05] bgimage_put_rect(): Annotate the 16-pixel alignment
This will later become relevant in a piece of ZUN bloat.

Part of P0264, funded by [Anonymous] and Blue Bolt.
2024-02-02 23:59:35 +01:00
nmlgc 05721ea8fb [Maintenance] [th05] Music Room piano: Move shared coordinates into the header
Part of P0264, funded by [Anonymous] and Blue Bolt.
2024-02-02 23:59:35 +01:00
nmlgc 062aa7ae1d [Maintenance] Purge the C-style `typedef struct` syntax
I might change this convention again in the future, particularly once
someone wants to fund C89 conformance, but let's stay consistent for
now.

Part of P0264, funded by [Anonymous] and Blue Bolt.
2024-02-02 23:59:34 +01:00
nmlgc 26926080bc [Maintenance] Remove `extern "C"` from more areas of code
This commit covers
• TH02/TH03/TH04/TH05's frame_delay() and frame_delay_2() (finally!)
• TH02/TH03/TH04/TH05's game_init_main()
• TH02's graph_copy_rect_1_to_0_16()
• TH03/TH04/TH05's cfg_load_resident_ptr()
• TH05's piano_setup_and_put_initial() and piano_render()

Part of P0264, funded by [Anonymous] and Blue Bolt.
2024-02-02 23:59:34 +01:00
nmlgc 607200d0ed [Maintenance] Move the space-changing point union to a separate header
Yup, there's more! About time we started a general coordinate header
that will ultimately be independent of `pc98.h`.

Part of P0264, funded by [Anonymous] and Blue Bolt.
2024-02-02 23:52:26 +01:00
nmlgc ef57125be2 [Maintenance] [th02/th03/th04/th05] Split segment #1 before the Music Room
Yup, TH02 as well.

Part of P0264, funded by [Anonymous] and Blue Bolt.
2024-02-02 23:49:04 +01:00
nmlgc 46cd6e74bd [Decompilation] [th05] Title screen animation
And with that, we end up exactly in front of the Music Room data in all
three remaining games.

Completes P0263, funded by [Anonymous].
2023-11-30 23:34:24 +01:00
nmlgc 49c1cda526 [Decompilation] [th05] OP.EXE: .CDG loading and freeing
It's absolutely not worth decompiling the TH04 counterpart right now.

Part of P0263, funded by [Anonymous].
2023-11-30 20:55:36 +01:00
nmlgc f5d14ca7ec [Decompilation] [th05] MIKO.CFG: Move all data to C land
Part of P0263, funded by [Anonymous].
2023-11-30 20:54:46 +01:00
nmlgc 17ef96772c [Decompilation] [th04/th05] ZUN Soft logo: Move data to C land
Ah, the first time I encountered Q12.4 subpixels, way back in early
2018… I'd like this to be the final piece of code decompiled in either
of these games, but its data needs to be moved to C land now since it
blocks the Music Room.
And yes, we even have to compile this one twice.

Part of P0263, funded by [Anonymous].
2023-11-30 20:53:29 +01:00
nmlgc cf44223d80 [Decompilation] [th04/th05] Setup menu: Entry point
Part of P0263, funded by [Anonymous].
2023-11-30 20:28:27 +01:00
nmlgc 7aa0459306 [Decompilation] [th04/th05] Setup menu: BGM and SE mode menus
I think this is the first time that function pointers as `inline`
function parameters actually inlined perfectly?

Part of P0263, funded by [Anonymous].
2023-11-30 20:27:19 +01:00
nmlgc 449aa37343 [Decompilation] [th04/th05] Setup menu: Text blitting
Been a while since I abused string constants for temporary alignment
hacks! Almost forgot about that technique. This time around though, I'm
using `$` to address the extra string in C land, which only *slightly*
breaks position independence.

Part of P0263, funded by [Anonymous].
2023-11-30 20:25:50 +01:00
nmlgc 52b74439bc [Decompilation] [th04/th05] Setup menu: Rollup animation
Part of P0263, funded by [Anonymous].
2023-11-30 20:25:50 +01:00
nmlgc 46fa5befb1 [Decompilation] [th04/th05] Setup menu: Single-line window blitting
Kind of redundant… but hey, final egc_copy_rect_1_to_0_16() call to be
moved to C land!

Part of P0263, funded by [Anonymous].
2023-11-30 20:25:50 +01:00
nmlgc 3d77be66b3 [Decompilation] [th04/th05] Setup menu: Dropdown animation
Breaking the usual naming convention as I'm going to use these
functions names more like constants in the final code.

Part of P0263, funded by [Anonymous].
2023-11-30 20:25:50 +01:00
nmlgc 2aacf1c9d2 [Decompilation] [th04/th05] Setup menu: Dropdown and rollup blitting
Part of P0263, funded by [Anonymous].
2023-11-30 20:25:50 +01:00
nmlgc 7c3160c38d [Reverse-engineering] [th04/th05] Setup menu: MSWIN.BFT sprite IDs
And yes, replicating them in ASM land does speed up decompilation, as I
don't have to pause and manually look up each value.
Too bad that the two resident structure assignments and the different
.PI freeing functions are the only reasons why we have to compile the
entire thing twice. Would have been nicer if ZUN had directly saved the
selection to MIKO.CFG instead 😛

Part of P0263, funded by [Anonymous].
2023-11-30 20:25:50 +01:00
nmlgc cc1eea41ad [Maintenance] [th04/th05] Move OP.EXE clear flags to their own header
Removes `op.hpp`'s dependency on the headers that declare RANK_COUNT
and PLAYCHAR_COUNT.

Part of P0263, funded by [Anonymous].
2023-11-30 20:00:53 +01:00
nmlgc d55c2cbad0 [Maintenance] [th03/th04/th05] Split OP.EXE into two assembly units
Wow, that was unexpectedly painless – even for TH03 where we have to
deal with a significant number of un-RE'd pieces of data. And for TH04
and TH05, it turns out that we not only *want* to move the entire _TEXT
segment into the new unit to keep the amount of `extern` declarations
to a minimum, but in fact *have* to because of graph_putsa_fx()'s fancy
labels in the data segment.

Part of P0263, funded by [Anonymous].
2023-11-30 20:00:39 +01:00
nmlgc cafdd6ee3e [Maintenance] [th05] #include `common.h` directly inside `resident.hpp`
The asymmetry of having to do this for TH05's resident structure but
not for TH04's has finally become annoying enough.

Part of P0263, funded by [Anonymous].
2023-11-30 19:55:18 +01:00
nmlgc 7e56d22785 [Maintenance] Only define `address_0` for the main ASM unit of a binary
Yeah, it's a hack, but it allows us to include `ReC98.inc` from more
than one unit per binary.

Part of P0263, funded by [Anonymous].
2023-11-30 19:52:46 +01:00
nmlgc a308c486d6 [Maintenance] Move the snd_load() constants into a separate ASM include file
And place it at a position where I don't forget to remove it once it's
no longer necessary.

Part of P0263, funded by [Anonymous].
2023-11-30 19:50:55 +01:00
nmlgc 741d889c07 [Decompilation] [th04/th05] Main menu: Move decompiled data to C land
Completes P0262, funded by [Anonymous] and Blue Bolt.
2023-11-30 19:50:52 +01:00
nmlgc b4980bbd8a [Decompilation] [th04/th05] OP.EXE: main()
Not the final function to be decompiled this time around!

Part of P0262, funded by [Anonymous] and Blue Bolt.
2023-11-30 19:43:57 +01:00
nmlgc c6c07e2c4d [Decompilation] [th04/th05] Main menu: Option menu update/render function
Part of P0262, funded by [Anonymous] and Blue Bolt.
2023-11-30 19:43:53 +01:00
nmlgc ad4cd15bb6 [Decompilation] [th04/th05] Main menu: Top-level menu update/render function
Part of P0262, funded by [Anonymous] and Blue Bolt.
2023-11-30 19:37:58 +01:00
nmlgc 1a64de731f [Decompilation] [th04/th05] Main menu: Cursor movement and re-rendering
Part of P0262, funded by [Anonymous] and Blue Bolt.
2023-11-30 19:36:52 +01:00
nmlgc 61079a3acc [Decompilation] [th04/th05] Main menu: Option menu choice rendering
Part of P0262, funded by [Anonymous] and Blue Bolt.
2023-11-30 19:36:44 +01:00