Commit Graph

399 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 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 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 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 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 576f49129a [Decompilation] [th05] Cutscenes: Return key wait animation
Needlessly blitting glyphs to VRAM until the very end, eh?

Part of P0223, funded by Blue Bolt and rosenrose.
2022-11-30 19:08:05 +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 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 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 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 1d05642866 [Maintenance] [th03/th04/th05] .CDG: Mirror implementation macros in ASM land
We introduced those in 25caa85.

Part of P0137, funded by [Anonymous].
2021-04-03 22:16:01 +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 25caa85ef8 [Decompilation] [th04/th05] cdg_put_noalpha_8()
Getting better at making this more readable…

Part of P0136, funded by [Anonymous].
2021-03-20 02:36:40 +01:00
nmlgc 16899204df [Decompilation] [th04/th05] Sound effect playback
At least it's decompilable in these games, and quite nicely so!

Part of P0136, funded by [Anonymous].
2021-03-20 02:36:38 +01:00
nmlgc 8164c71d22 [Decompilation] [th04/th05] bgimage_snap(), bgimage_put(), bgimage_free()
Eh, REP MOVSD is used too inconsistently across the games to justify
replacing these macros with an `inline` function. Still can use a
custom one here to make the register usage a bit more explicit, though.

Part of P0136, funded by [Anonymous].
2021-03-20 02:36:36 +01:00
nmlgc 46359e643e [Translation unit catch-up] [th05] game_exit()
Part of P0136, funded by [Anonymous].
2021-03-20 02:36:32 +01:00
nmlgc 0263439fac [Decompilation] [th04/th05] vector1_at(), vector2_at()
Almost undecompilable, until you remember that you can inhibit the
optimization of keeping a function parameter in a register by having an
`inline` function take a reference. Yet another function that wouldn't
have decompiled that nicely if we had restricted us to C…

Part of P0136, funded by [Anonymous].
2021-03-19 23:29:26 +01:00
nmlgc f35b051edd [Separate translation units] [th04/th05] bgimage_put_rect() (undecompilable)
Reason: Self-modifying. -.-

Part of P0135, funded by [Anonymous].
2021-03-19 23:19:48 +01:00
nmlgc 88c019eb91 [Maintenance] Move the bgimage_*() functions to the hardware/ directory
Not that it really fits there either, but I've been trying to keep the
th0?/ directories free from any actual code. They should only contain
the distinct translation units within the original three .EXE binaries,
`#include`ing files from subdirectories, along with maybe game-specific
`#pragma`s, but contain no code on their own. Port authors would simply
ignore those, and link everything from the subdirectories into one
binary. That approach has seemed to make the most sense for all of this
so far.

Part of P0135, funded by [Anonymous].
2021-03-19 20:06:54 +01:00
nmlgc 01c92da1ac [Decompilation] [th05] snd_load()
A decompilation of ZUN-written ASM that was almost worth it, for once!
Too bad that those aren't the <string.h> intrinsics that the
Wolfenstein 3D disassembly hinted at, though.

Part of P0135, funded by [Anonymous].
2021-03-19 19:22:57 +01:00
nmlgc 903f5b55de [Separate translation units] [th05] snd_kaja_interrupt() (undecompilable)
Reason: Pascal calling convention with function parameters but no stack
frame.

Part of P0135, funded by [Anonymous].
2021-03-19 19:16:01 +01:00
nmlgc a6eed55258 [Decompilation] [th05] pi_put_masked_8(), pi_put_quarter_masked_8()
Completes P0135, funded by [Anonymous].
2021-02-21 14:04:52 +01:00
nmlgc 76cefb1e37 [Decompilation] [th05] pi_load()
That assembly is *worse* than what you would have gotten out of your
1994 C++ compiler with the 386 code generation switch!

Part of P0134, funded by [Anonymous].
2021-02-21 14:04:48 +01:00