Commit Graph

243 Commits

Author SHA1 Message Date
nmlgc c04ca8da91 [Reverse-engineering] [th03] Collision bitmap: Drawing slopes (undecompilable)
Reason: Self-modifying. -.-

Only used in Chiyuri's EX Attack (the one with the diagonal lasers).

Part of P0182, funded by Lmocinemod and [Anonymous].
2022-02-18 09:36:34 +01:00
nmlgc 8b24a07a09 [Decompilation] [th01] Sariel: Main function
Part of P0181, funded by Ember2528.
2022-01-31 08:31:18 +01:00
nmlgc 8b01702aa5 [Decompilation] [th01] Sariel: Move compiler-generated data to C land
Very helpful at this small scale, as it allows us to directly decompile
floating-point literals. These will be added to Sariel's regular
translation unit in the same order, so we merely have to remove them
from this temporary translation unit then.

Part of P0174, funded by Ember2528.
2022-01-31 05:15:29 +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 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 9ae4f7726e [Decompilation] [th05] EMS / Dialog: Face loading and rendering
Aha! TH05 actually loads every single rendered dialog image
individually before rendering it, either from the EMS area or disk.
That's one way to save memory, I guess?

Part of P0169, funded by Blue Bolt.
2021-11-29 02:01:10 +01:00
nmlgc 7673456ab3 [Decompilation] [th04] EMS / Dialog: Loading the remaining images
What the hell is TH05 doing there…?

Part of P0169, funded by Blue Bolt.
2021-11-29 02:01:10 +01:00
nmlgc fe33d49e0a [Decompilation] [th04/th05] EMS: Allocation + Preloading the eyecatch image
No, I'm not copying exactly what was on ZUN's monitor during the 2010
MAG・ネット documentary. Also, this one was very lucky not to receive
a stupid function name.

Part of P0168, funded by Blue Bolt and rosenrose.
2021-11-29 01:53:43 +01:00
nmlgc dbd9e23bf9 [Maintenance] [th04/th05] Split segment #1 before the EMS functions
Well, except for GameCore(), which has nothing of interest.

Part of P0168, funded by Blue Bolt and rosenrose.
2021-11-28 19:15:22 +01:00
nmlgc d5ec2220ec [Decompilation] [th01] Boss defeat sequence: Drawing white lines
Part of P0167, funded by Ember2528.
2021-11-07 23:32:04 +01:00
nmlgc 8db3dd2919 [Build] Don't compile any ZUN code directly to `bin/`
I've long moved to a convention of putting every .OBJ compiled from ZUN
code into the subdirectory of the game that introduced it. These four
are the last remaining inconsistencies from earlier in development.

Part of P0162, funded by Ember2528.
2021-10-20 00:06:16 +02:00
nmlgc 42ba4a5725 [Decompilation] [th01] Particle system
Only seen in Mima's fight, but initialized for all non-final boss
fights. Also with explicit support for all 8 origin edges, not just the
top-right one used in Mima's fight… and an off-by-one error?!

Completes P0160, funded by Yanga.
2021-10-09 23:25:59 +02:00
nmlgc 2f9304781f [Maintenance] [th01] Split segment #1 before the pellet speed modification code
There might only be three functions between the second and new third
split, but these seem to depend on the entire rest of the code for
card-flipping stages…

Part of P0160, funded by Yanga.
2021-10-08 18:39:04 +02:00
nmlgc b9bc6ac04d [Decompilation] [th01] Bomb items: Spawn function
Part of P0158, funded by Yanga.
2021-09-28 18:05:24 +02:00
nmlgc 4bc6405543 [Decompilation] [th01] HARRY UP pellet pattern
Completes P0156, funded by Ember2528.
2021-08-22 23:56:59 +02:00
nmlgc 6ffe87f35b [Decompilation] [th01] Konngara: Main function
Third longest function in all of PC-98 Touhou, and it's even more of a
copy-pasta than the patterns we've seen earlier. Certainly didn't feel
that long.

Part of P0156, funded by Ember2528.
2021-08-22 23:56:58 +02:00
nmlgc 81fc86150d [Decompilation] [th05] Aiming to the player
Completes P0152, funded by -Tom- and [Anonymous].
2021-07-31 21:09:37 +02:00
nmlgc 6127ca0ec1 [Reverse-engineering] [th05] Bullets: Velocity and angle calculation (undecompilable)
Reason: That switch statement. How should we even?

Well, the code *is* fairly good. After looking very deep into it, and
spending 35% of that function on blank lines (for logical grouping) and
explanatory comments, that is…

Part of P0152, funded by -Tom- and [Anonymous].
2021-07-31 21:09:36 +02:00
nmlgc 4d24ca53bd [Decompilation] [th04/th05] Bullets: Update function
… (24 + (difficulty * 8) + rank) in TH04, and (42 + (difficulty * 8))
in TH05. Also, TH05 only doesn't have TH04's bullet zap animation
because ZUN didn't consistently use constants…

Completes P0151, funded by Blue Bolt and -Tom-.
2021-07-31 20:19:33 +02:00
nmlgc 0d7fc5af77 [Decompilation] [th04/th05] Turbo/Slow Mode slowdown
Slow Mode only does one thing: It looks at how many 8×8 pellets or
16×16 bullets are alive, and reduces the frame rate by 33% (i.e., turns
every second frame into two frames) if that number is…

Part of P0151, funded by Blue Bolt and -Tom-.
2021-07-31 20:19:33 +02:00
nmlgc c4cc31ee6f [Maintenance] [th05] Split segment #3 before the bullet update function
Part of P0149, funded by Blue Bolt, Ember2528, and -Tom-.
2021-07-31 09:33:50 +02:00
nmlgc e1a26bb9b1 [Decompilation] [th04/th05] Player position clamping
Completes P0148, funded by [Anonymous].
2021-07-21 00:35:03 +02:00
nmlgc ab8af79549 [Separate translation units] [th04/th05] motion_update_seg3() (undecompilable)
Reason: See previous commit.

Part of P0148, funded by [Anonymous].
2021-07-21 00:35:02 +02:00
nmlgc f3d59bc324 [Decompilation] [th04/th05] Applying VRAM scrolling to Y coordinates (segment 3)
… Wait, we *can* decompile functions with both parameters, no stack
frame, and a Pascal calling convention?! Good that I already forgot how
impossible it was to decompile the first function I looked at that fell
into this category!

Part of P0148, funded by [Anonymous].
2021-07-21 00:35:02 +02:00
nmlgc 8671340481 [Decompilation] [th04/th05] Gather circle rendering
Part of P0148, funded by [Anonymous].
2021-07-21 00:35:02 +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 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 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 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 d8ece227fd [Separate translation units] [th04] cdg_put_nocolors_8() (undecompilable)
Reason: Self-modifying. -.-

Part of P0139, funded by [Anonymous].
2021-05-11 18:47:58 +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 b1cf7ee021 [Maintenance] [th02] .MPN: Update existing decompilations to current standards
Part of P0138, funded by [Anonymous] and Blue Bolt.
2021-04-22 19:25:01 +02:00
nmlgc f635948480 [Naming] .MPN: Rename mptn_* to mpn_*
We've been using the three-letter extension names for everything else
that isn't .DAT, so it's more consistent to do the same for .MPN,
however particularly nice and readable its FOURCC may be. 8.3 filenames
also really appreciate that they'll have to accommodate one fewer
letter.

Part of P0138, funded by [Anonymous] and Blue Bolt.
2021-04-22 19:16:18 +02:00
nmlgc 78b958f111 [Separate translation units] [th02] key_delay()
Part of P0138, funded by [Anonymous] and Blue Bolt.
2021-04-21 17:50:04 +02:00
nmlgc aea5a20de9 [Translation unit catch-up] [th04] hflip_lut_generate()
Part of P0138, funded by [Anonymous] and Blue Bolt.
2021-04-21 17:45:20 +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
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 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 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 1e5c677ae9 [Translation unit catch-up] [th03] snd_delay_until_volume()
Part of P0138, funded by [Anonymous] and Blue Bolt.
2021-04-21 17:26:43 +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