Commit Graph

265 Commits

Author SHA1 Message Date
nmlgc 5356d0e5b6 [Decompilation] [th02] High Score menu: Main function
Part of P0285, funded by [Anonymous] and iruleatgames.
2024-07-09 08:47:03 +02:00
nmlgc c85c0e2483 [Maintenance] Remove `extern "C"` from more areas of code
Much more than usual, now that we've got a snappy build system! This
commit covers
• All .PI functions across all games
• TH02's High Score entry functions
• TH03's shots_update() and shots_render()
• All functions declared in `th04/op/op.hpp`
• TH04/TH05's bb_txt_put_8_raw(), bullet_template_clip(),
  player_pos_update_and_clamp(), score_update_and_render(), and
  slowdown_frame_delay()
• TH05's reimu_stars_update_and_render(), score_delta_commit(),
  stage2_invalidate(), stage2_update(), and space_window_set()

Part of P0284, funded by [Anonymous] and Blue Bolt.
2024-07-09 08:40:43 +02:00
nmlgc 50afb0afa6 [Decompilation] [th02] Staff roll and verdict sequences
Part of P0279, funded by Yanga and Blue Bolt.
2024-04-12 00:29:10 +02:00
nmlgc c88a259568 [Decompilation] [th02] Staff roll: Rectangle animation + picture blitting
Both sub-functions could have been inlined here, and then I wouldn't
have had to comment the former.

Part of P0279, funded by Yanga and Blue Bolt.
2024-04-12 00:29:10 +02:00
nmlgc 9ce80c0c1c [Decompilation] [th02] Staff roll: Clearing text from VRAM
Part of P0279, funded by Yanga and Blue Bolt.
2024-04-12 00:29:10 +02:00
nmlgc bfeb661f69 [Decompilation] [th02] Staff roll: ENDFT.BFT sprite blitting
Part of P0279, funded by Yanga and Blue Bolt.
2024-04-12 00:29:10 +02:00
nmlgc f0fbaf667c [Decompilation] [th02] Endings: Script code for Bad and Good endings
On the list of functions yet to be decompiled, these were at number 7
and 1, respectively, which corresponds to number 7 and 22 on the total
list of functions in PC-98 Touhou.

Completes P0278, funded by Yanga.
2024-04-12 00:29:10 +02:00
nmlgc 16ddd0cc2d [Decompilation] [th02] Ending → Staff roll transition
And it has a bug 🎺

Part of P0278, funded by Yanga.
2024-04-12 00:29:10 +02:00
nmlgc f623a70929 [Decompilation] [th02] Endings: Clearing the text line
Part of P0278, funded by Yanga.
2024-04-12 00:29:10 +02:00
nmlgc ddaf8c9495 [Decompilation] [th02] Endings / Staff roll: Picture blitting
Part of P0278, funded by Yanga.
2024-04-12 00:29:10 +02:00
nmlgc 8a149db5c4 [Decompilation] [th02] Verdict: 3-digit number → gaiji string conversion
Part of P0278, funded by Yanga.
2024-04-12 00:29:10 +02:00
nmlgc 7ac1db34f0 [Decompilation] [th02] Verdict: Masked VRAM row copies from page 1→0
Part of P0278, funded by Yanga.
2024-04-12 00:29:10 +02:00
nmlgc 35f320ef80 [Decompilation] [th02] Endings / Staff roll: Text typing
Part of P0278, funded by Yanga.
2024-04-12 00:29:10 +02:00
nmlgc 31411d7743 [Decompilation] [th02] Verdict screen: Score rendering
For once, I'm glad that ZUN copy-pasted this one-off function.
Otherwise, it probably wouldn't have been that easy to factor out.

Part of P0278, funded by Yanga.
2024-04-12 00:29:10 +02:00
nmlgc 962564db49 [Decompilation] [th02] Endings: Text file loading
Part of P0278, funded by Yanga.
2024-04-12 00:29:10 +02:00
nmlgc 5359bff77b [Naming] [th02] Add a `_reset` infix to `input_sense()`
Matching TH04 and TH05 functions, which differentiate between raw
sensing and resetting+sensing. In that light, the previous name for
TH02's function was rather misleading for leaving out that crucial
detail…

Part of P0278, funded by Yanga.
2024-04-12 00:29:09 +02:00
nmlgc 536ededecd [Maintenance] [th02] Declare rectangle rotation using current conventions
Including a move to the `th02/end/` directory, and a `staffroll_`
prefix because of those hardcoded positions.

Part of P0278, funded by Yanga.
2024-04-12 00:29:09 +02:00
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 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 c5e51e6cb2 [Maintenance] [th02] Properly declare lives and bombs, and their limits
Completes P0237, funded by Yanga.
2023-03-29 18:03:06 +02: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 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 f005eb023b [Maintenance] Remove all unused externs in ASM land
Part of P0158, funded by Yanga.
2021-09-28 18:05:24 +02:00
nmlgc 68d9419e8e [Maintenance] [th02] Remove ranks_center[data].asm
Part of P0141, funded by [Anonymous] and rosenrose.
2021-05-27 19:08:57 +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 b9c24cf931 [Separate translation units] [th02] snd_delay_until_measure()
How was this game even *built*, originally, if it uses *both* a common
shared set of library functions *and* obviously copy-pasted and
separately compiled versions of some of these functions?

Part of P0132, funded by [Anonymous].
2021-01-05 19:32:18 +01:00
nmlgc 52fdb33d1d [Separate translation units] [th02] frame_delay()
Part of P0132, funded by [Anonymous].
2021-01-05 19:23:31 +01:00
nmlgc 4850d6d457 [Maintenance] Rename "seg2" to "SHARED"
There's the better name, in ALLCAPS for improved grepping. TH01 is also
going to need a pseudo-binary to bundle translation units that appear
in more than one .EXE, and since "segment 2" would be wrong for that
game, it makes more sense to have one consistent name for these
pseudo-binaries in all games.

(Maintenance mode commit)
2020-11-03 17:01:26 +01:00
nmlgc deecfeb0d1 [Position independence] [th02] graph_putsa_fx() calls in MAINE.EXE
Part of P0125, funded by [Anonymous].
2020-11-02 23:00:54 +01:00
nmlgc 30462cc64f [Maintenance] Indicate byte alignment for all .PI blitting functions
Part of P0124, funded by [Anonymous] and Blue Bolt.
2020-11-02 22:19:12 +01:00
nmlgc 6e61b07055 [Position independence] False positives: Divisions
Part of P0118, funded by -Tom- and Ember2528.
2020-09-17 22:35:44 +02:00
nmlgc 65c72929af [Position independence] False positives: I/O port accesses
… with either the port or the argument in registers. This is one of the
few actually dumb concessions to the PI counter on the website.
Then again, binary *is* a better representation for the contents of the
GRCG tile register than hex…

Part of P0117, funded by [Anonymous].
2020-09-16 22:30:56 +02:00
nmlgc d40547e601 [Maintenance] Drop the `slot` infix for PI-related identifiers
ZUN doesn't ever use PI functions without these slots, making that infix
kind of redundant.

Part of P0114, funded by Lmocinemod.
2020-09-07 21:18:39 +02:00
nmlgc f0511221b7 [Maintenance] [th02/th03/th04/th05] Establish a common name for code segment 2
About time I finally developed this piece of tech. Towards TH05, this
segment got more and more undecompilable ASM functions mixed inbetween
C ones. Which means that pretty much all of the current ASM land
`#include`s in that segment will have to become translation units. And
we *really* don't want an additional layer of numbered, per-binary
translation units that just `#include` maybe one or two functions.

Also yeah, no _TEXT suffix, to drive home the point that this is a
"library" segment, and not really "owned" by any one file.

Part of P0113, funded by Lmocinemod.
2020-09-07 21:18:38 +02:00
nmlgc 8b5c1463f6 [Position independence] [th02/th03/th04/th05] References to known gaiji
Completes P0110, funded by [Anonymous] and Blue Bolt.
2020-08-19 20:12:02 +02:00
nmlgc f99d7a571c [Maintenance] Remove all dependencies on Borland C++ run-time source headers
And with all possible .COM executables decompiled, this set of changes
reaches an acceptable scope, allowing us to *finally*…

Part of P0077, funded by Splashman and -Tom-.
2020-02-23 17:53:18 +01:00
nmlgc 5a7fb6879f [Maintenance] Use the same resident structure pointer name for every game
The TH04/TH05 BGM/SE mode setup is a good example for code where
different structure field offsets will vanish completely upon reverse-
engineering. If we continued to use the per-game ID string as the
variable name, we'd only have another game-specific "difference" there.

Part of P0065, funded by Touhou Patch Center.
2020-01-03 21:26:10 +01:00
nmlgc f5f45c9420 [Position independence] [th02/th03/th04/th05] PaletteTone values
Part of P0064, funded by Touhou Patch Center.
2019-12-29 21:15:42 +01:00
nmlgc 0eaa142684 [Position independence] master.lib graph_* function calls
Part of P0064, funded by Touhou Patch Center.
2019-12-29 21:15:38 +01:00
nmlgc b7de999705 [Maintenance] Improve score data file-related type and function names
So many things named `score_*`, so many things named `hiscore_*`…
Let's go with `scoredat_*`, which clearly indicates that this stuff is
saved into a file, while still being only 8 characters.

Part of P0063, funded by -Tom-.
2019-12-28 12:14:02 +01:00
nmlgc f275e041e9 [Position independence] master.lib superimpose function calls
Completes P0062, funded by Touhou Patch Center.
2019-12-22 15:39:34 +01:00
nmlgc a6a805f008 [ZUN symbols] key_det / shiftkey
Not applying this leak to TH03 since it would have more than one
`key_det` variable, resulting in names that are as much fanfiction as
the current ones…
2019-11-30 19:32:10 +01:00
nmlgc 550bba9b3c [Position independence] False positives in master.lib EGC function calls
Mostly used for screen shaking.

Part of P0059, funded by [Anonymous] and -Tom-.
2019-11-18 22:21:34 +01:00
nmlgc 6c4852f789 [Position independence] False positives in master.lib GRCG function calls
Yup, function parameters that can clearly be identified as coordinates
are by far the fastest way to raise the calculated position
independence percentage. Kinda makes it sound like useless work, which
I'm only doing because it's dictated by some counting algorithm on a
website, but decompilation will want to un-hex all of these values
anyway. We're merely doing that right now, across all games.

Part of P0058, funded by -Tom-.
2019-11-14 00:51:48 +01:00
nmlgc f07089017f [Maintenance] Rename the extension of game-specific ASM includes to .inc
Rule of thumb going forward: Everything that emits data is .asm,
everything that doesn't is .inc.
(Let's hope that th01_reiiden_2.inc won't exist for that much longer!)

Part of P0032, funded by zorg.
2019-09-21 13:03:56 +02:00
nmlgc 35ef90f4d1 [Reduction] Page flipping
Funded by -Tom-.
2018-12-30 00:16:18 +01:00
nmlgc 7a309919aa [Reverse-engineering] [th02/maine] *Actually* identify all array references -.-
And already, the script begins to crumble, reminding me of what a
terrible idea it actually was. Like, if you did it for real, you'd get
so many false positives that the script stops being useful, since
every raw number above 0x90 (the size of the _DATA segment of the
Borland C++ DOS startup code) can potentially be a memory reference.

I do think that the script now covers the sweet spot between full-blown
emulation and shallow parsing though, so going to do at least a few
more files.
2017-01-05 23:54:17 +01:00