Commit Graph

312 Commits

Author SHA1 Message Date
nmlgc 4242480b9a [Maintenance] Move the contents of `music/` subdirectories under `op/`
Making it more obvious that it's Music *Room* code, not BGM code.

Part of P0186, funded by [Anonymous] and Blue Bolt.
2022-03-25 14:10:59 +01:00
nmlgc 2d5491e4a9 [Decompilation] [th03] YUME.NEM: Loading
"I don't need the return value in MAINL.EXE? Let's copy-paste the
function and remove all of its `return` statements then!" :zunpet:

Completes P0172, funded by [Anonymous] and Blue Bolt.
2021-12-27 03:59:33 +01:00
nmlgc 4b7028c9d3 [Decompilation] [th03] YUME.NEM: Checksum verification
Part of P0172, funded by [Anonymous] and Blue Bolt.
2021-12-27 03:59:33 +01:00
nmlgc b20bf944be [Decompilation] [th03] YUME.NEM: Default data
Part of P0172, funded by [Anonymous] and Blue Bolt.
2021-12-27 03:59:33 +01:00
nmlgc 6d5918881f [Decompilation] [th03] YUME.NEM: Encryption and saving
Also "intransparently setting the clear flag, but only in the MAINL.EXE
version".

Part of P0172, funded by [Anonymous] and Blue Bolt.
2021-12-27 03:59:30 +01:00
nmlgc 79aeb8dccc [Decompilation] [th03] YUME.NEM: Decryption
Featuring inline assembly for a single ROR instruction. Turbo C++ 4.0J
unfortunately only offers intrinsics for 16-bit rotations.

Part of P0172, funded by [Anonymous] and Blue Bolt.
2021-12-27 03:59:02 +01:00
nmlgc 3361cd6991 [Reverse-engineering] [th03] YUME.NEM: Structure
Part of P0172, funded by [Anonymous] and Blue Bolt.
2021-12-27 01:16:03 +01:00
nmlgc 53ccdca29a [Reverse-engineering] [th03] YUME.NEM: File name
Part of P0172, funded by [Anonymous] and Blue Bolt.
2021-12-27 01:16:03 +01:00
nmlgc 38f9db0592 [Maintenance] [th03] Assign segment #1 in OP and MAINL to a common group name
The YUME.NEM functions won't be decompilable in their natural order
otherwise.

Part of P0172, funded by [Anonymous] and Blue Bolt.
2021-12-27 01:15:59 +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 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 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 531b044cb9 [Separate translation units] [th01/th02/th03/th04] vram_planes_set()
Boom! Clever segment renaming allows us to link the same .OBJ into 12
binaries.
(Well, 10 for now, due to alignment issues in TH04's OP.EXE and
MAINE.EXE.)

Part of P0138, funded by [Anonymous] and Blue Bolt.
2021-04-21 17:40:11 +02:00
nmlgc 9d2cce16a2 [Translation unit catch-up] [th03] snd_determine_mode()
Wow, it's -WX, and no workaround necessary!

Part of P0138, funded by [Anonymous] and Blue Bolt.
2021-04-21 17:28:59 +02:00
nmlgc e43e3a3fbb [Translation unit catch-up] [th03] snd_pmd_resident()
Not even used in this game.

Part of P0138, funded by [Anonymous] and Blue Bolt.
2021-04-21 17:27:55 +02:00
nmlgc 0e11d33520 [Translation unit catch-up] [th03] snd_load()
Exhibit B for the theory that ZUN did *not* set the default calling
convention to `pascal` for TH03.

Part of P0138, funded by [Anonymous] and Blue Bolt.
2021-04-21 16:28:29 +02:00
nmlgc 6264ca743c [Translation unit catch-up] [th03/th04] game_exit()
Part of P0137, funded by [Anonymous].
2021-04-03 22:29:12 +02:00
nmlgc 731990b0aa [Decompilation] [th03] 1D vector construction
Exhibit A for the theory that ZUN did *not* set the default calling
convention to `pascal` for TH03.
… Then again, at this point, it's way more likely that ZUN simply
didn't have a unified build setup for any of the games, and rather
pieced them together with manually compiled .OBJ files.

Part of P0137, funded by [Anonymous].
2021-04-03 22:27:12 +02:00
nmlgc f7da96a504 [Separate translation units] [th03] .CDG display (undecompilable)
Reason: Self-modifying. -.-

Part of P0137, funded by [Anonymous].
2021-04-03 22:19:51 +02:00
nmlgc 2527e6ee7c [Translation unit catch-up] [th03] frame_delay()
Also requires more workarounds for TH02 so that we can share this
translation unit across the two games.

Part of P0137, funded by [Anonymous].
2021-04-03 22:15:51 +02:00
nmlgc f1a8d98dbc [Decompilation] [th03] Low-level input
Lovely. Turns out that all it needed to motivate the previous research
was one function that is simply too precious to be kept in ASM…

Part of P0137, funded by [Anonymous].
2021-04-03 22:09:26 +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 af13720486 [Translation unit catch-up] [th03] .PI blitting
Part of P0136, funded by [Anonymous].
2021-03-20 02:36:43 +01:00
nmlgc 0929d91e50 [Translation unit catch-up] [th03] snd_kaja_interrupt()
Part of P0136, funded by [Anonymous].
2021-03-20 02:17:05 +01:00
nmlgc 1d5db7155a [Separate translation units] [th02/th03/th05] game_init_op()
Completes P0133, funded by [Anonymous].
2021-01-31 16:53:59 +01:00
nmlgc 045450c788 [Decompilation] [th03] .CDG: Loading and freeing
Completes P0132, funded by [Anonymous].
2021-01-05 22:17:48 +01:00
nmlgc 3f61342898 [Decompilation] [th03] graph_putsa_fx()
Part of P0132, funded by [Anonymous].
2021-01-05 22:08:56 +01:00
nmlgc 3bf078b68c [Separate translation units] [th02/th03/th04] pi_load()
Part of P0132, funded by [Anonymous].
2021-01-05 20:01:44 +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 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 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 5990ccd3b9 [Maintenance] Declare CDG blitting functions in C land
Part of P0119, funded by [Anonymous] and -Tom-.
2020-09-21 15:00:01 +02:00
nmlgc 0bb5bc39d9 [Position independence] False positives: Palette color arithmetic
Completes P0117, funded by [Anonymous].
2020-09-16 22:30:57 +02:00
nmlgc 967bb8b633 [Decompilation] [th03] Input mode and delay functions
Nice to see that Borland C++ optimizes bit-tests to cover just the high
or low byte of a word if possible, and that these don't have to be
two-byte structures after all.

Completes P0114, funded by Lmocinemod.
2020-09-07 21:18:40 +02:00
nmlgc f467b6818f [Maintenance] Declare game_exit() and game_exit_to_dos() as __cdecl
Again, no `pascal` convention unless necessary…

Part of P0114, funded by Lmocinemod.
2020-09-07 21:18:40 +02:00
nmlgc 716a925636 [Decompilation] [th03] YUME.CFG loading and saving
Oh, I just needed something in TH03's OP.EXE before code segment 2.

Part of P0114, funded by Lmocinemod.
2020-09-07 21:18:40 +02:00
nmlgc f6757fe76a [Maintenance] Fix DEFCONV declarations, and remove them where possible
Wow, this is the first time we're about to call any of these from C
land in ≥TH03? Found no built-in way to just uppercase an identifier
in TASM, so apparently we have to spell out the names in both lower-
and uppercase.
So, let's go back to regular, non-macro PUBLIC / PROC / ENDP code
wherever we can – for all functions introduced in ≥TH03, and for
everything that takes no parameters. It's simply not worth the
trouble.

Part of P0114, funded by Lmocinemod.
2020-09-07 21:18:39 +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 5a6ac29f50 [Separate translation units] [th03] CDG: Non-alpha display (undecompilable)
Reason: Self-modifying. -.-

Part of P0114, funded by Lmocinemod.
2020-09-07 21:18:39 +02:00
nmlgc ecc1372842 [Decompilation] [th03] Lookup table for horizontally flipping planar pixels
In which we exchange variable names for the ability to decompile more
than just 3 instructions here.
… yeah, "decompilation" is still a stretch.

Part of P0114, funded by Lmocinemod.
2020-09-07 21:18:38 +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 be22a72b25 [Maintenance] [th03/th04/th05] Declare CDG loading/freeing functions in C land
No need to make the function names more complicated if we already
expressed the one subtle format difference between TH03 and TH04/TH05
in the plane layout enum.

Part of P0113, funded by Lmocinemod.
2020-09-07 21:18:38 +02:00
nmlgc 287687b9f4 [Position independence] master.lib Sin8() and Cos8() macros
I'm expecting no PI gains at all from this push, so here's some
quick low-hanging fruit instead.

Part of P0103, funded by Ember2528.
2020-07-27 17:03:59 +02:00
nmlgc e3a78bd19b [Maintenance] Fix vector creation function declarations and calls
Part of P0099, funded by Ember2528.
2020-07-12 15:22:50 +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 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 a2961b02da [Reverse-engineering] [th03/th04/th05] Configuration file
The supposedly low-hanging fruit that almost every outside contributor
wanted to grab a lot earlier, but (of course) always just for a single
game… Comprehensively covering all of them has only started to make
sense recently 😛

Also, yes, the variable with the uppercase .CFG filename has itself a
lowercase name and vice versa…

Part of P0077, funded by Splashman and -Tom-.
2020-02-23 17:24:17 +01:00
nmlgc a1f36ffa04 [Reverse-engineering] [th03] Demo initialization
Something small that came out of the resident structure review.
Including more research to suggest that we probably can't ever use C++
constructors for anything in ReC98.

Part of P0076, funded by [Anonymous] and -Tom-.
2020-02-23 16:58:30 +01:00
nmlgc 484730e319 [Reverse-engineering] [th03] Resident structure, reviewed
Now with the correct types, more consistency with the other games with
some field names (rank, is_cpu, rand, bgm_mode, demo_num), and some
more research to improve some of the TH03-specific fields.

Part of P0076, funded by [Anonymous] and -Tom-.
2020-02-23 16:57:35 +01:00
nmlgc 4340b5d6ae [Maintenance] [th01/th02] Split graph_putsa_fx() into its shared parts
I did consider not doing this, because "well, can't anyone who's
*actually* interested just diff the TH01 and TH02 implementations to
figure out the differences themselves", but that duplication ended up
feeling too filthy after all.

And hey, it's a nice excuse to update TH02's version to current naming
standards! 😛

Part of P0068, funded by Yanga.
2020-01-14 22:03:00 +01:00