Commit Graph

272 Commits

Author SHA1 Message Date
nmlgc 8d5b08306f [Build] 32-bit: Move ASM land `GAME` constants onto the build command line
More complex now, less complex in the Lua rewrite.

Part of P0002, funded by GhostPhanom.
2024-06-30 05:52:59 +02:00
nmlgc a0ff3f13d2 [Maintenance] [th01] OP.EXE: Move master.lib data back to the ASM husk
Completes P0216, funded by JonathKane.
2022-08-16 01:54:03 +02:00
nmlgc ab7dbf0462 [Decompilation] [th01] OP.EXE: Move the final pieces of data to C land
100%.

Part of P0216, funded by JonathKane.
2022-08-16 01:54:03 +02:00
nmlgc 77832e9e72 [Decompilation] [th01] OP.EXE: main()
0.

Part of P0216, funded by JonathKane.
2022-08-16 01:47:51 +02:00
nmlgc 2beb55d0c4 [Decompilation] [th01] Main menu: Music Test update/render function
1.

Part of P0216, funded by JonathKane.
2022-08-16 01:47:40 +02:00
nmlgc f00093f7c4 [Decompilation] [th01] Main menu: Playing the selected Music Test track
2.

Part of P0216, funded by JonathKane.
2022-08-16 01:47:26 +02:00
nmlgc 97a60b64fc [Decompilation] [th01] Main menu: Option menu update/render function
3.

Part of P0216, funded by JonathKane.
2022-08-16 01:46:55 +02:00
nmlgc a4b72d448d [Decompilation] [th01] Main menu: Top-level menu update/render function
4.

Part of P0216, funded by JonathKane.
2022-08-16 01:46:17 +02:00
nmlgc c714c53310 [Decompilation] [th01] Main menu, part 1 (reviewed)
5.

Part of P0216, funded by JonathKane.
2022-08-16 01:45:46 +02:00
32th-System cc77dc0f19 [Decompilation] [th01] Main menu, part 1
With just the amount of changes to get everything compiling again.
Thank you! --Nmlgc
2022-08-16 01:45:23 +02:00
nmlgc 201722d25a [Maintenance] [th01] Finally add a BGM mode type
And name the FM state in a way that already prepares modded PMD
support. That's the number 1 TH01 mod idea, after all.

Part of P0216, funded by JonathKane.
2022-08-16 01:42:29 +02:00
nmlgc cf95cc8717 [Maintenance] [th01] Remove `extern "C"` from all remaining areas of code
Nothing says "we're getting things done" quite as much as this.

Part of P0214, funded by Ember2528.
2022-08-14 23:03:15 +02:00
nmlgc 40051f5ae2 [Maintenance] [th01] Move remaining non-literal data into a new assembly unit
Yeah, no, I'm not going to declare all of those as `extern` and then
"Move all data to C land" after decompiling the entire segment. Once
again (94372d2), it's not too bad – heck, in REIIDEN.EXE, it's less
than a screen worth of identifiers that are still being referenced.

Part of P0214, funded by Ember2528.
2022-08-14 23:02:39 +02:00
nmlgc 643f662815 [Decompilation] [th01] VSync interrupt handler: Move all data to C land
Ending the data catch-up with… an unused mouse cursor graphic?!

Part of P0213, funded by Ember2528 and GhostRiderCog.
2022-08-11 23:21:23 +02:00
nmlgc c5b7f8d771 [Decompilation] [th01] Text mode functions: Move all data to C land
Part of P0213, funded by Ember2528 and GhostRiderCog.
2022-08-11 23:21:23 +02:00
nmlgc 6b3fc6c4d1 [Decompilation] [th01] Game init and exit functions: Move all data to C land
Part of P0213, funded by Ember2528 and GhostRiderCog.
2022-08-11 23:21:23 +02:00
nmlgc 443a334067 [Decompilation] [th01] Core graphics/palette functions: Move all data to C land
Part of P0213, funded by Ember2528 and GhostRiderCog.
2022-08-11 23:21:23 +02:00
nmlgc e79f6c62bf [Decompilation] [th01] .GRP / .GRZ / .PTN: Move all data to C land
Cross-executable ZUN bloat 🤮

Part of P0213, funded by Ember2528 and GhostRiderCog.
2022-08-11 23:21:23 +02:00
nmlgc ce9f1ed0c0 [Maintenance] [th01] Move OP and REIIDEN master.lib data to new assembly units
Part of P0213, funded by Ember2528 and GhostRiderCog.
2022-08-11 23:21:23 +02:00
nmlgc 738964a451 [Decompilation] [th01] Random resident structure stuff: Move all data to C land
Part of P0213, funded by Ember2528 and GhostRiderCog.
2022-08-11 23:21:23 +02:00
nmlgc a3bc614e68 [Decompilation] [th01] MDRV2: Move all data to C land
Part of P0213, funded by Ember2528 and GhostRiderCog.
2022-08-11 23:21:23 +02:00
nmlgc e97a869e90 [Maintenance] [th01] Compile all remaining C code as C++
And all that it needed was a few ellipses.

Part of P0212, funded by GhostRiderCog, Lmocinemod, and LeyDud.
2022-08-11 15:50:19 +02:00
nmlgc 001033d15a [Maintenance] [th01] Remove `extern "C"` from more areas of code
The .GRC and .GRP functions, to be specific.

Part of P0203, funded by [Anonymous] and GhostRiderCog.
2022-07-10 13:09:12 +02:00
nmlgc 6f2881f056 [Maintenance] Remove `extern "C"` from more areas of code
The .PTN functions, vector functions, and egc_copy_rect_1_to_0_1()
(finally!) from TH01, as well as playfld.hpp from all games(finally!),
together with a bunch of other functions in their vicinity.

Part of P0201, funded by Ember2528 and Yanga.
2022-06-24 23:28:19 +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 692e8d1c42 [Naming] [th01] Remove "back/front" terminology from inter-page copy functions
TH01 doesn't use "back" and "front" pages in the way the later games
do, after all. Indicating that the source page of this parameter-less
function is the one that was previously set via graph_accesspage_func()
is going to make pretty much all its call sites way clearer, and stops
implying any further state.

Part of P0167, funded by Ember2528.
2021-11-07 23:27:30 +01:00
nmlgc be29850887 [Maintenance] [th01] Rename the resident debug flags
MODE_REGULAR is an awfully generic name for a global constant.

Part of P0162, funded by Ember2528.
2021-10-20 00:06:16 +02: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 e5dffdd9b6 [Maintenance] [th01] Move frame_delay() to consistently named files
It didn't bother me during all of 2020 that TH01's version was
inconsistently part of vsync.h?!

Part of P0140, funded by [Anonymous].
2021-05-27 18:49:29 +02:00
nmlgc 7b3b6fd4e7 [Separate translation units] [th01] ptn_copy_8_0_to_1()
So, we have a problem. The ridiculously optimized graph_putsa_fx() used
in TH04 and TH05 swaps out the target of two CALL instructions at
run-time… because there *really* wasn't any free register left for an
indirect CALL, eh? Therefore, the necessary relative addresses have to
be calculated at assembly time, by subtracting the target function
label from the call site label.
Unfortunately, the resulting values are stored in the .DATA segment,
which we can't move out right now. Declaring the labels as EXTERN
wouldn't work either, since the linker can't do fancy arithmetic and is
limited to simply replacing address placeholders with one single
address. This is explained pretty well at:

	http://computer-programming-forum.com/46-asm/48f3d4a463bb38d1.htm

Which means we're stuck, and can't separate out this function for the
foreseeable future.

So, time to approach the SHARED segment from the top instead, to at
least get everything around graph_putsa_fx() done now. 🤷
vram_planes_set() is the first common function there. But since it was
introduced in TH01, we've got some maintenance to do for that game
first…

Part of P0138, funded by [Anonymous] and Blue Bolt.
2021-04-21 17:35:39 +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 a186074af3 [Separate translation units] [th01] .PTN, .GRP, and .GRZ formats
Since I'd still prefer to not use include guards *and* to have that
standalone .GRZ viewer, these would have actually caused somewhat of
an issue with the upcoming final stretch of the master.hpp transition.

Part of P0133, funded by [Anonymous].
2021-01-30 19:17:16 +01:00
nmlgc 6c22af7e83 [Build] [th01] Only compile shared single-file translation units a single time
Which gets rid of 13 redundant translation units. Definitely a good
start, before I figure out how to best handle the more complicated
cases.

(Maintenance mode commit)
2020-11-04 14:47:52 +01:00
nmlgc f1c63ab3a1 [Reverse-engineering] Assign names to all graph_putsa_fx() effects
And get rid of the constraining FX() macro, with its spacing parameter
that we haven't even seen used so far.

Part of P0124, funded by [Anonymous] and Blue Bolt.
2020-11-02 22:33:50 +01:00
nmlgc 8c1d4bf41b [Maintenance] Locate the BSS segment of master.lib's `clip.asm`
By now, it's become obvious where it has to be. Apparently, the order
of translation units inside ZUN's modified master.lib did somehow
change with TH02?

(Maintenance mode commit)
2020-09-29 07:03:06 +02:00
nmlgc d840841a2b [Naming] Rename egc_copy_rect_1_to_0() to emphasize its 16-dot alignment
ZUN might have gotten the impression that the EGC can *only* work with
multiples of 16 pixels per load or store? Which might explain why…

Part of P0102, funded by Yanga.
2020-07-12 16:27:56 +02:00
nmlgc 40b8325cc3 [Maintenance] [th01] Move MDRV2 files to a separate `snd/` directory
Consistency… even though we won't have more of those in this game.

Part of P0098, funded by Yanga.
2020-06-13 21:15:30 +02:00
nmlgc 6b2a54d8d2 [Position independence] [th01] Final false positives in OP.EXE and FUUIN.EXE
100% PI for both! Now, where are all the modders who wanted to replace
MDRV2 with PMD… because you can now prototype that, without worring
about x86 instruction lengths, at least inside the main menu.

Part of P0095, funded by Yanga.
2020-05-31 17:29:05 +02:00
nmlgc 55b3cb0330 [Decompilation] [th01] Main menu: White line animation
> "Sure, this is a PI push, but this second-to-last set of PI false
  positives so small, let's immediately decompile it ^.^"
> Time taken: 22 minutes
Nice when this works out!

Part of P0095, funded by Yanga.
2020-05-31 17:27:37 +02:00
nmlgc 29c5a7365f [Build] Assemble piloadc as a separate translation unit
Restoring the originally released version here as well… except for
ZUN's custom format magic ID, of course.

Completes P0091, funded by Ember2528.
2020-05-12 15:06:13 +02:00
nmlgc 389b9a1056 [Decompilation] [th01] Keyboard input in OP.EXE
Starting with the odd one out, the one that doesn't use master.lib and
has two input sense functions: one for the main menu, and one for the
option window.

Both of which also immediately perform the ring arithmetic on the menu
cursor variable… because there's nothing else to be done with these
inputs in OP.EXE? Separating input sensing from processing apparently
wasn't all too obvious of a thought, and it's only truly done in TH02
and later.

Part of P0090, funded by Yanga.
2020-05-12 14:55:09 +02:00
nmlgc 7ad14db394 [Decompilation] [th01] REIIDEN.CFG loading and saving
That's where the backwards `goto` for .CFG file error handling
originated!

Part of P0090, funded by Yanga.
2020-05-12 14:36:43 +02:00
nmlgc 05a0e9b1c8 [Decompilation] [th01] Unused function to snap all dots with hardware color #4
That's… pretty specific. The only thing on the main menu with this
color is the "1996 ZUN" text at the bottom… probably part of an
effect that we never got to see. Every other idea would be baseless
speculation, given that the snapped buffer isn't used anywhere else.

Part of P0090, funded by Yanga.
2020-05-11 22:12:51 +02:00
nmlgc c0b44ecaec [Position independence] Remaining references to _ctype
Part of P0087, funded by -Tom-.
2020-04-15 21:34:20 +02:00
nmlgc 7698f5da6d [Maintenance] Compress unknown BSS regions using byte arrays
Also something that any future ReC project should be doing right at the
start. Finally, it made sense to do it here as well, because…

Part of P0084, funded by Yanga.
2020-03-22 10:16:09 +01:00
nmlgc 1cc9cefa26 [Decompilation] [th01] PTN-sized page 0→1 copies
Final shared function in TH01's OP.EXE.

Part of P0084, funded by Yanga.
2020-03-22 09:59:24 +01:00
nmlgc dfac2f2fd4 [Position independence] [th01] EGC-powered page 1→0 region copy calls
12.4 fixed-point subpixels, in TH01?

Completes P0083, funded by Yanga.
2020-03-18 20:33:59 +01:00
nmlgc 9e676ce3ef [Decompilation] [th01] .PTN snap functions
Which repurpose the .PTN image slots to store the background of
frequently updated VRAM sections, like all the numbers in the HUD.
Future games would simply use the text RAM and gaiji for numbers. Which
would have worked just fine for TH01 as well (especially since all the
functions we've seen so far are aligned to the 8-pixel byte grid), but
it looks as if ZUN simply wasn't aware of gaiji during the development
of TH01.

Part of P0083, funded by Yanga.
2020-03-18 20:33:58 +01:00
nmlgc a184413f27 [Decompilation] [th01] .PTN file loading and non-transparent display
What is this, error checking in a ZUN game?! And surprisingly good code
for deriving the alpha plane?!

Part of P0083, funded by Yanga.
2020-03-18 20:33:58 +01:00
nmlgc d79f4c1171 [Maintenance] [th01] Correctly declare the packfile functions in C land
Mangled C++ function names would *not* have been a mistake if I hadn't
made the other mistake of restricting parts of the code to C…

Part of P0083, funded by Yanga.
2020-03-18 20:33:53 +01:00