Commit Graph

374 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 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 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 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 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 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 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 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 97f0c3b4f5 [Position independence] [th04] Congratulation picture file name
What a fitting memory reference to pick as the final one to be labeled
and made position-independent. That's 100% for TH04!

Completes P0244, funded by Blue Bolt and [Anonymous].
2023-06-13 04:26:26 +02:00
nmlgc 64495ca98a [Naming] [th04/th05] Verdict screen: Number rendering
One of which also has the convenient responsibility of adding or
subtracting a number from the skill metric…

Part of P0244, funded by Blue Bolt and [Anonymous].
2023-06-13 04:26:26 +02:00
nmlgc 5de2186e57 [Reverse-engineering] [th04] Staff roll: State
And that's it…? All staff roll-related false positives removed, and we
didn't even have to decompile any of the staff roll blitting functions?

Part of P0244, funded by Blue Bolt and [Anonymous].
2023-06-12 02:09:21 +02:00
nmlgc 0efe76ab77 [Naming] Rename vector1_at() to polar()
"1D polar vectors" are a weird concept to wrap your head around,
especially if their constructor function takes a sine or cosine ratio
instead of an angle. This function is way closer to the polar_*()
family, which has these convenient `_x` and _y` suffixes that we could
just remove for this generic function to fit into there.

Part of P0244, funded by Blue Bolt and [Anonymous].
2023-06-12 02:08:41 +02:00
nmlgc 3862e989c7 [Position independence] [th03/th04] False positives: snd_delay_until_measure()
Part of P0241, funded by [Anonymous] and Blue Bolt.
2023-05-30 01:31:46 +02:00
nmlgc 6d977a9df7 [Decompilation] [th03/th04/th05] Cutscenes: Main script parsing loop
Part of P0225, funded by Enderwolf, Blue Bolt, 32th System, and Yanga.
2022-11-30 22:46:22 +01:00
nmlgc 8118e61c77 [Decompilation] [th03/th04/th05] Cutscenes: Script opcode interpreter
Even that part's the same in these three games… except for the 27 small
places where it isn't, 7 of which are purely coding style cosmetics.

Completes P0224, funded by Splashman and -Tom-.
2022-11-30 22:46:22 +01:00
nmlgc f01e46700d [Maintenance] [th04/th05] Cutscenes: Move box code to the main translation unit
With the script parsing and picture/box rendering functions being as
interleaved as they are, it makes little sense to keep the cutscene
code in more than one translation unit. How would those translation
units even be called? This time, having everything in one file should
beat the few hundred preprocessor-removed lines of code that we end up
adding to each one of the three affected games – and ultimately, you'd
want to merge those systems into one translation unit anyway.

Part of P0224, funded by Splashman and -Tom-.
2022-11-30 19:31:14 +01:00
nmlgc ac3fba3dce [Decompilation] [th03/th04/th05] Cutscenes: Line and box feeds
Part of P0224, funded by Splashman and -Tom-.
2022-11-30 19:26:55 +01:00
nmlgc 0d85265931 [Decompilation] [th03/th04/th05] Cutscenes: 3-digit number parsing
Used for all ASCII number parameters to script functions, as well as
for TH04's dialog script.

Part of P0224, funded by Splashman and -Tom-.
2022-11-30 19:22:48 +01:00
nmlgc 371292dab2 [Decompilation] [th03/th04] Cutscenes: Box background blitting and unblitting
Completes P0223, funded by Blue Bolt and rosenrose.
2022-11-30 19:16:47 +01:00
nmlgc 6f8b32ca4a [Decompilation] [th03/th04/th05] Cutscenes: Masked blitting of new pictures
Part of P0223, funded by Blue Bolt and rosenrose.
2022-11-30 19:16:35 +01:00
nmlgc 684c149bef [Decompilation] [th03/th04] Cutscenes: Copying pictures from VRAM page 0→1
And another variation of an EGC-accelerated inter-page copy. At least
it's slightly more optimized compared to TH01's horribly slow one.
But wait, page *0* to page *1*? That seems kind of backwards…

Part of P0223, funded by Blue Bolt and rosenrose.
2022-11-30 19:11:06 +01:00
nmlgc fb9f18e967 [Decompilation] [th03/th04/th05] Cutscenes: EGC initialization
That only leaves the TH02 versions of this function that really should
have been defined at one central location.

Part of P0223, funded by Blue Bolt and rosenrose.
2022-11-30 19:08:52 +01:00
nmlgc 023cdacc36 [Decompilation] [th03/th04/th05] Cutscenes: Script loading and freeing
Part of P0223, funded by Blue Bolt and rosenrose.
2022-11-30 19:08:28 +01:00
nmlgc 7cda9e28b2 [Decompilation] [th04/th05] Cutscenes: Text blending animation
Part of P0223, funded by Blue Bolt and rosenrose.
2022-11-30 17:11:00 +01:00
nmlgc ee717c1d19 [Reverse-engineering] [th03/th04/th05] Cutscenes: State variables
You can fast-forward through cutscenes by holding Escape in these
games?! And the script interpreter adds automatic line breaks?!

Part of P0223, funded by Blue Bolt and rosenrose.
2022-11-30 17:10:19 +01:00
nmlgc ccd5b70b9f [Maintenance] [th03/th04/th05] Cutscenes: Move into a separate subdirectory
Thanks to TH03 having text-below-picture cutscenes before stages 8 and
9, the `/end/` directory is the wrong place to keep this code. And as
we're soon going to see, this feature did evolve during these three
games.

Part of P0223, funded by Blue Bolt and rosenrose.
2022-11-30 17:02:34 +01:00
nmlgc 2458172c98 [Maintenance] [th02/th03/th04/th05] Define a constant for a white VRAM color
Part of P0223, funded by Blue Bolt and rosenrose.
2022-11-30 17:00:42 +01:00
nmlgc d3abb3b3ec [Maintenance] Correctly declare egc_start_copy_*()
Part of P0223, funded by Blue Bolt and rosenrose.
2022-11-30 16:40:12 +01:00
nmlgc a2358bef47 [Maintenance] Remove `extern "C"` from `x86real.h` and `decomp.hpp`
One of those per delivery now, eh?

Part of P0189, funded by Arandui and Lmocinemod.
2022-04-16 23:53:46 +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 5fac2006ff [Maintenance] Consistently use "score" instead of "points"
Or at least in addition.

Part of P0172, funded by [Anonymous] and Blue Bolt.
2021-12-27 00:50:39 +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 6333643222 [Decompilation] [th03/th04/th05] cfg_load_resident_ptr()
Including the pointless DOS I/O variation in TH05's MAIN.EXE.
I'm slowly running out of characters to remove from the first segment
name in that file, though…

Part of P0148, funded by [Anonymous].
2021-07-21 00:34:59 +02:00
nmlgc 06dbb6335c [Naming] [th03/th04/th05] Clarify that cfg_load_resident() only loads a pointer
It shouldn't need a comment to communicate that this function does in
fact not load all values from the .CFG file that are part of the
resident structure, but only loads and sets the global pointer to that
structure.

Part of P0148, funded by [Anonymous].
2021-07-20 23:35:50 +02:00
nmlgc 241b61e808 [Maintenance] Distinguish between Shift-JIS and gaiji strings
The main point of the previous strings/ subdirectory was to bundle all
hardcoded strings for translators. And sure, *technically*, gaiji
strings are *both* strings *and* something you might want to translate.
But mainly, they're sprites with an attached enum, and their own
directory. Changes to the enum quickly tend to involve changes to the
strings that use these values, so it makes sense to keep both in the
same directory.

Especially since 82% of the previous strings/ directories consisted of
such gaiji strings.

That leaves the strings/ directory rather empty and nondescript though.
Recently though, I've been wanting to generally move all Shift-JIS text
to this directory. While that wouldn't *solve* the typical "text editor
accidentally a file upon save, due to wrongly detected encoding" issue,
it's at least a mitigation: If all Shift-JIS strings are in files that
contain nothing *but* Shift-JIS strings, a wrongly detected encoding
becomes immediately noticeable.

For that job, strings/ can have a more descriptive name though. Hence,
shiftjis/.

Part of P0141, funded by [Anonymous] and rosenrose.
2021-05-27 19:10:26 +02:00
nmlgc d9858113d8 [Decompilation] [th04] snd_load()
Last one! Done with the SHARED segment for the forseeable future! 🎉

Sure, not the best C++ code either, but still by far the sanest
implementation of this function in any of the 4 games.

Completes P0139, funded by [Anonymous].
2021-05-12 14:31:03 +02:00
nmlgc ca4bf5002a [Separate translation units] [th04] cdg_put_plane() (undecompilable)
Reason: Self-modifying. -.-

Part of P0139, funded by [Anonymous].
2021-05-11 18:48:00 +02:00
nmlgc 62e0167e20 [Translation unit catch-up] [th03/th04/th05] snd_delay_until_measure(), game_exit_to_dos()
Segment alignment issues once again… but that completes the SHARED
segments of all TH03 and TH05 binaries, for now!

Part of P0139, funded by [Anonymous].
2021-05-11 18:48:00 +02:00
nmlgc 78df46af1f [Decompilation] [th04/th05] snd_determine_modes()
ZUN apparently had no trust in the sanity of Turbo C++'s code
generation?

Part of P0139, funded by [Anonymous].
2021-05-11 18:47:59 +02:00
nmlgc 7761f4e804 [Decompilation] [th04] snd_kaja_interrupt()
4 games, 4 different versions of this function. Interestingly,
moving the game-specific differences to inline functions makes it
obvious that this function was only intended for BGM, not sound
effects.

Part of P0139, funded by [Anonymous].
2021-05-11 18:47:57 +02:00
nmlgc 4c0e76ab89 [Decompilation] [th04/th05] snd_mmd_resident()
Part of P0139, funded by [Anonymous].
2021-05-11 18:47:57 +02:00
nmlgc 4c8a3cb353 [Decompilation] [th04/th05] snd_pmd_resident()
Part of P0139, funded by [Anonymous].
2021-05-11 18:47:56 +02:00
nmlgc 8e16481e27 [Translation unit catch-up] [th04] vector1_at(), vector2_at()
Part of P0139, funded by [Anonymous].
2021-05-11 18:47:54 +02:00
nmlgc aaa37c7081 [Decompilation] [th04] input_wait_for_change(), .MPN: Freeing / palette setting
Another three functions in one commit, forced by segment alignment…

Part of P0138, funded by [Anonymous] and Blue Bolt.
2021-04-22 19:27:08 +02:00
nmlgc 04038449c1 [Translation unit catch-up] [th04] frame_delay() / .PI display and loading
Segment alignment forces us to do all of those at once… but now, we've
not only caught up with the segment split point in TH04's OP.EXE and
MAINE.EXE, but also decompiled all instances of DEFCONV functions!

Part of P0138, funded by [Anonymous] and Blue Bolt.
2021-04-21 17:44:15 +02:00