Commit Graph

504 Commits

Author SHA1 Message Date
nmlgc 6d702988af [Maintenance] Remove `extern "C"` from more areas of code
Covering every input function across all games.

Part of P0278, funded by Yanga.
2024-04-11 23:17:45 +02:00
nmlgc 311138a2d9 [Naming] .PI: Mention palette mutation and 640×400 in the load→put→free macro
Also dropping the `_8` as it's irrelevant to a fullscreen image.
And yes, we'll see a version without palette mutation.

Part of P0278, funded by Yanga.
2024-04-11 23:16:21 +02:00
nmlgc c9c3b621ec [Maintenance] Remove the SHARED_ segment and all related workarounds
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 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 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 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 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 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 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 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 050afe83b5 [Decompilation] [th04/th05] Main menu: Top-level menu blitting
We don't really gain anything from pretending that these description
IDs are anything other than raw array indices.

Part of P0262, funded by [Anonymous] and Blue Bolt.
2023-11-30 19:30:31 +01:00
nmlgc 1d047a504b [Reverse-engineering] [th04/th05] Main menu: Sprite IDs
Part of P0262, funded by [Anonymous] and Blue Bolt.
2023-11-30 19:30:17 +01:00
nmlgc dfb48561d6 [Maintenance] [th04] Move MIKO.CFG code into the main menu translation unit
Wait, *what*, the alignment issues even stretch up to those functions?
And since TH05's version of the MIKO.CFG code lies much further down,
we now end up with this horrible #include placement asymmetry between
the two games. At least we now don't need a cross-TU workaround for
TH04's "MIKO.CFG" string either.

Part of P0262, funded by [Anonymous] and Blue Bolt.
2023-11-30 19:30:17 +01:00
nmlgc 86f1f44522 [Maintenance] [th04/th05] #include game start code from a shared source file
Once again, word alignment of a `switch` jump table forces us to put
both the game start and main menu code into the same translation unit,
despite the former being fundamentally different between the two games.
Oh well, this also avoids the need for a cross-TU workaround for the
"main" and "deb" binary filename strings.

Part of P0262, funded by [Anonymous] and Blue Bolt.
2023-11-30 19:22:42 +01:00
nmlgc f294ccb158 [Naming] [th04/th05] Rename the initial rank value to highlight its effect
`RANK_DEFAULT` raised the question why ZUN just didn't directly assign
the apparent default of `RANK_NORMAL`. Turns out that this is what
triggers the first-launch setup menu.

Part of P0262, funded by [Anonymous] and Blue Bolt.
2023-11-30 19:16:56 +01:00
nmlgc 214c404ef5 [Maintenance] Introduce a type for PC-98 text RAM attributes
No need for signed variants this time!

Part of P0262, funded by [Anonymous] and Blue Bolt.
2023-11-30 18:47:20 +01:00
nmlgc ae2fc2865a [Decompilation] [th04] Starting the game
Completes P0261, funded by [Anonymous] and Yanga.
2023-11-01 23:17:52 +01:00
nmlgc 0ded9d46f3 [Decompilation] [th04/th05] MIKO.CFG loading and saving
Part of P0261, funded by [Anonymous] and Yanga.
2023-11-01 23:17:52 +01:00
nmlgc 412df0c961 [Maintenance] [th05] Assign proper names to decompiled OP.EXE segments
Having to comb through them and change their `#pragma option -zC` names
after adding a new one is pretty annoying, after all. This way, we also
get to move some of those 2020 decompilations out of the `th05/`
subdirectory, matching the more consistent directory hierarchy that
this project has converged on in the years since.

Part of P0261, funded by [Anonymous] and Yanga.
2023-11-01 23:17:52 +01:00
nmlgc 580c0ff3cd [Maintenance] [th04/th05] Dialog: Merge the lower two translation units
Part of P0259, funded by Splashman and Yanga.
2023-11-01 23:17:51 +01:00
nmlgc 63e9257279 [Decompilation] [th04/th05] Dialog: Blocking main function
Part of P0259, funded by Splashman and Yanga.
2023-11-01 23:17:51 +01:00
nmlgc 0f45a5a89f [Decompilation] [th04/th05] Dialog: Main script parsing loop
Last occurrence of anything related to <ctype.h>! 🙌

Part of P0259, funded by Splashman and Yanga.
2023-11-01 23:17:51 +01:00
nmlgc 1f2ea181f6 [Decompilation] [th04/th05] Dialog: Script opcode interpreter
Part of P0259, funded by Splashman and Yanga.
2023-11-01 23:17:50 +01:00
nmlgc 78a9e7b4b4 [Decompilation] [th04/th05] Dialog: Activation
Stupid one-off functions deserve stupid names, Part 6.

Part of P0258, funded by [Anonymous] and Blue Bolt.
2023-10-31 22:33:54 +01:00
nmlgc 4d11848671 [Naming] [th04/th05] Dialog: Drop the `DIALOG_` prefix from constants
It's rather noisy, the header isn't supposed to be publicly used
anyway, and the TH03/TH04/TH05 cutscene system uses the same
conventions. Also shortening the `CURSOR_` constants to `TEXT_`.

Part of P0258, funded by [Anonymous] and Blue Bolt.
2023-10-31 22:33:32 +01:00
nmlgc 641cdec9f2 [Maintenance] [th04/th05] Dialog: Start a new translation unit with shared code
Thanks to the required word alignment of the `switch` jump table in
TH05's dialog_op(), we do in fact have to slice dialog code into
exactly two* translation units. Three might have been better because we
would have only needed to compile this shared code once, but TH05 also
has one exclusive function in the area covered by this new shared
translation unit anyway. At least we can meaningfully share the actual
source files between games here.

* With an additional one at the end for now, because I absolutely had
  to RE that EMS code in late 2021, but we'll catch up with that one in
  the end.

Part of P0258, funded by [Anonymous] and Blue Bolt.
2023-10-31 22:33:29 +01:00
nmlgc 757ee718c4 [Maintenance] Remove `extern "C"` from more areas of code
This commit covers
• TH02's ZUNINIT errors,
• TH02's main menu,
• the init/exit functions in all 4 remaining games,
• TH03/TH04/TH05's configuration file functions, and
• TH04/TH05's tile rendering functions.

Part of P0258, funded by [Anonymous] and Blue Bolt.
2023-10-31 22:33:16 +01:00
nmlgc a4fb2cf067 [Maintenance] [th04/th05] Remove unnecessary segment splits
Reclaiming a few letters.

Part of P0258, funded by [Anonymous] and Blue Bolt.
2023-10-31 22:33:13 +01:00
nmlgc f5da2a50a5 [Maintenance] [th02/th04/th05] Stage tiles: Move metrics to a separate header
The vertical shmup counterpart to 841d8be. Cleans up the subsystem
hierarchy by ensuring that at least all tile /formats/ code does not
depend on /main/ code.

Part of P0258, funded by [Anonymous] and Blue Bolt.
2023-10-31 22:33:10 +01:00
nmlgc 6515661dc8 [Decompilation] [th04/th05] Boss explosions
Part of P0245, funded by [Anonymous], Blue Bolt, Ember2528, and Yanga.
2023-07-01 05:22:23 +02:00
nmlgc 31b535d678 [Decompilation] [th05] EX-Alice: 16×16 sprite overrides
Part of P0245, funded by [Anonymous], Blue Bolt, Ember2528, and Yanga.
2023-07-01 05:22:23 +02:00