Commit Graph

69 Commits

Author SHA1 Message Date
nmlgc 0310154789 [Maintenance] Commit .bat files with LF line endings, but check out as CRLF
Windows 9x requires CRLF for batch files to work at all. While Windows
XP and later appear to work with LF line endings, they introduce
devious glitches with certain commands:

	https://www.dostips.com/forum/viewtopic.php?t=8988

However, we still want to use LF endings in the repo to prevent the
annoying ^M whitespace errors.

Part of P0002, funded by GhostPhanom.
2024-06-24 00:21:11 +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 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 d55c2cbad0 [Maintenance] [th03/th04/th05] Split OP.EXE into two assembly units
Wow, that was unexpectedly painless – even for TH03 where we have to
deal with a significant number of un-RE'd pieces of data. And for TH04
and TH05, it turns out that we not only *want* to move the entire _TEXT
segment into the new unit to keep the amount of `extern` declarations
to a minimum, but in fact *have* to because of graph_putsa_fx()'s fancy
labels in the data segment.

Part of P0263, funded by [Anonymous].
2023-11-30 20:00:39 +01:00
nmlgc a6a3aaeb0a [Reverse-engineering] [th02] Bombs: Particle sprites
The circle point sprite is technically identical to the pellet sprite,
but logically different.

Part of P0237, funded by Yanga.
2023-03-29 18:03:05 +02:00
nmlgc 4837ec7ec9 [Research] Benchmark various sprite blitting approaches
Running this on various PC-98 models confirms that unchecked blitting
(i.e., what you would intuitively consider to be the best method) is in
fact faster than checking either byte of a 16-pixel-wide sprite
beforehand, and has been throughout the PC-98's lifespan. For optimal
performance on the 286 and 386, we might want to use MOVS instead of
MOV, but even that difference is way too small to truly matter.
Also, nice to see turns out that our blitter outperforms a naive pure C
implementation by 2-4×, depending on the model. And master.lib is not
*that* much faster…

The gaiji in `Research/blitperf.bmp` were taken from the Unifont
version 15.0.01 glyphs for:

	• U+2022 BULLET •
	• U+23F1 STOPWATCH ⏱
	• U+1F40C SNAIL 🐌

Part of P0233, funded by [Anonymous].
2023-03-04 19:40:55 +01: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 3123c9d3fd [Maintenance] [th01] REIIDEN.EXE: Move master.lib data back to the ASM husk
Completes P0215, funded by Ember2528 and Yanga.
2022-08-15 00:44:05 +02:00
nmlgc 65ce43443c [Decompilation] [th01] REIIDEN.EXE: Move the final pieces of data to C land
100%. What a giant, uncategorizable mess of data.

Part of P0215, funded by Ember2528.
2022-08-15 00:44:05 +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 158a91e3ce [Maintenance] [th01] FUUIN.EXE: Move master.lib data back to the main ASM husk
Completes P0213, funded by Ember2528 and GhostRiderCog.
2022-08-11 23:21:23 +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 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 774c97e31d [Decompilation] [th01] Pellet delay clouds: Move all data to C land
That's all hardcoded sprites transferred to C land! Yeah, I know,
what a significant milestone… except…

Part of P0213, funded by Ember2528 and GhostRiderCog.
2022-08-11 23:21:23 +02:00
nmlgc 1971682309 [Decompilation] [th01] VRAM page transitions: Move all data to C land
Part of P0213, funded by Ember2528 and GhostRiderCog.
2022-08-11 23:21:23 +02:00
nmlgc 1031815450 [Decompilation] [th01] Shootout lasers: Move all data to C land
Part of P0213, funded by Ember2528 and GhostRiderCog.
2022-08-11 23:21:23 +02:00
nmlgc 04f5c27d13 [Maintenance] [th01] Move FUUIN.EXE's master.lib data to a new assembly unit
Part of P0213, funded by Ember2528 and GhostRiderCog.
2022-08-11 23:21:22 +02:00
nmlgc d79f06b66a [Decompilation] [th01] Bonus screens: Move all data to C land
Part of P0213, funded by Ember2528 and GhostRiderCog.
2022-08-11 23:21:22 +02:00
nmlgc 06379be894 [Decompilation] [th01] Stage bonus: Background box opening animation
40 functions left in TH01!

Part of P0212, funded by GhostRiderCog, Lmocinemod, and LeyDud.
2022-08-11 23:18:29 +02:00
nmlgc 5fa0cd5a86 [Decompilation] [th01] .GRC / 8×8 shapes: Move all data to C land
Part of P0211, funded by Lmocinemod and Arandui.
2022-08-08 20:16:05 +02:00
nmlgc f933b619b5 [Decompilation] [th01] Mima: Move all data to C land
7th PC-98 Touhou boss completely decompiled, 24 to go!

Part of P0206, funded by Yanga and [Anonymous].
2022-07-17 20:46:02 +02:00
nmlgc 6b1329d6cf [Decompilation] [th01] Mima: Flame pillar rendering
Part of P0206, funded by Yanga and [Anonymous].
2022-07-17 20:15:54 +02:00
nmlgc 73670108ae [Pipeline] bmp2arr: Add a C++ output format
This one will use the DotRect template from `planar.h` and generate a
single 16- or 32-dot value per row. Since this converter has a goal of
maximum portability, it makes sense to keep raw the multidimensional
C-style arrays around as a possible output format.

Part of P0205, funded by [Anonymous] and Yanga.
2022-07-17 19:45:14 +02:00
nmlgc 94372d2e27 [Maintenance] [th01] Move data of FUUIN.EXE segments ≥4 to a new assembly unit
Turns out that the "new idea" for handling these data slices won't work
out in reality. At least the amount of necessary manual `extern`
declarations isn't soul-crushingly large, so this way isn't bad either,
after all!

Part of P0197, funded by Yanga and Ember2528.
2022-05-31 23:39:34 +02:00
nmlgc 8e06497d4b [Separate translation units] [th04/th05] vector2_near (undecompilable)
Reason: Too much micro-optimization using 32-bit registers, which
aren't supported by Turbo C++'s inline assembler. It's also just
another variation on a common function we've decompiled time and time
again.

Part of P0192, funded by [Anonymous], nrook, and -Tom-.
2022-05-01 00:22:04 +02:00
nmlgc c41bfbaf3e [Separate translation units] [th04/th05] Spark sprite spawning (undecompilable)
Reason: Saving SI and DI on the stack way too late. Just because ZUN
absolutely *had* to move the clipping condition before these two PUSH
instructions… Was it really necessary to save a total of 4 instructions
for an unlikely worst case in a function that's maybe called like 10-20
times per frame *at worst*?

Part of P0192, funded by [Anonymous], nrook, and -Tom-.
2022-05-01 00:22:04 +02:00
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 313450f00a [Decompilation] [th01] Sariel: Move all data to C land
Second PC-98 Touhou boss completely decompiled, 29 to go! But meh,
ZUN's original code did in fact force the three leaf pattern sprites
into separate 1-sprite sheets…

Completes P0181, funded by Ember2528.
2022-01-31 08:31:18 +01:00
nmlgc 091f19f69b [Decompilation] [th01] Sariel: Pattern 16/16
The one where Sariel's second form shoots sparks towards the top of the
playfield, which then turn into leaf-like sprites that sway towards the
bottom, killing Reimu on contact.

And wow, what a finish! A weird "decimal subpixel" type, hardcoded
sprites, and effectively unused non-hardcoded sprites. Too bad that it
also ruins the nice `dot_rect_t(w, h)` parameter abstraction for
grcg_put_8x8_mono()…

Completes P0180, funded by Yanga.
2022-01-31 08:31:18 +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 308b73524d [Maintenance] [th01] Merge invincibility sprites into the regular 8×8 shapes
They have the same size, their hardcoded sprites are stored next to
each other in the code, and…

Part of P0153, funded by Ember2528.
2021-08-22 14:55:54 +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 53920309a1 [Decompilation] [th05] snd_kaja_interrupt()
Boom! Decompilable after all. And look what that made us finally point
out: In all 4 games that use this function, its return value is
undefined if BGM is inactive. (That is, if the user disabled it, or if
no FM sound board is installed.)

Part of 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 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 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 c2f6abd091 [Translation unit catch-up] [th04] cdg_put_8()
Part of P0138, funded by [Anonymous] and Blue Bolt.
2021-04-21 16:24:18 +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 c85f444b07 [Decompilation] [th02/th03] Sound effect playback
Second previously undecompilable translation unit, second creative
workaround for the workaround. We can't compile snd_se_play() with -WX,
as that function needs a stack frame, and it's also illegal to disable
-WX in the middle of a translation unit. But since we only need word
alignment in front of snd_se_reset() *and* that function is identical
in all 4 games, it makes sense to move it to its own translation unit.

And then you notice that the TH02/TH03 and TH04/TH05 versions of the
other two functions are basically identical. The small differences can
easily be moved out to inline functions, leaving us with a single
implementation file for all 4 games. Nice!

Part of P0137, funded by [Anonymous].
2021-04-03 22:11:45 +02:00
nmlgc 8de326792c [Decompilation] [th02] snd_mmd_resident()
Now actually decompilable with the discovery of -WX… even though it
now requires additional workarounds for the drawbacks of the -WX
workaround.

Part of P0137, funded by [Anonymous].
2021-04-03 22:10:41 +02:00
nmlgc 7b9194a391 [Regression] Add th04/bgimager.asm to Tupfile.bat -.-
Need to fix `tup generate` soon…
2021-03-29 22:39:10 +02:00
nmlgc 547a9d95d8 [Separate translation units] [th04] cdg_put_plane_roll_8() (undecompilable)
Reason: Self-modifying. -.-

Also, why no GRCG? Would have allowed blitting via REP MOVSD… Might as
well optimize all the way if you're going the ASM route to begin with.

Part of P0136, funded by [Anonymous].
2021-03-20 02:36:39 +01:00
nmlgc a2e515534c [Translation unit catch-up] [th04] Low-level input
Part of P0136, funded by [Anonymous].
2021-03-20 02:36:38 +01:00
nmlgc 85019517e2 [Separate translation units] [th04/th05] cdg_put_8() (undecompilable)
Reason: Self-modifying. -.-
The TH05 version *might* be decompilable into a mess. Don't have time
for that right now, though.

Part of P0136, funded by [Anonymous].
2021-03-20 02:36:34 +01:00
nmlgc 1ad64dc514 [Translation unit catch-up] [th03] Sound effect playback
Part of P0136, funded by [Anonymous].
2021-03-20 02:17:07 +01:00
nmlgc 152ecaa496 [Separate translation units] [th05] Music Room piano (undecompilable functions)
Reasons:
• piano_fm_part_put_raw(): SI register referenced and not saved on
  the stack
• piano_current_note_from(): Would be decompilable… into a mess.
  Not worth adding a separate translation unit just for it.
• piano_part_keys_put_raw(): DI register saved before the SI register
• piano_pressed_key_put(): DI register referenced and not immediately
  saved on the stack
• piano_label_put_raw(): SI and DI registered referenced and not saved
  on the stack
• grcg_setcolor_direct_seg1_raw(): Let's procrastinate this one until
  we have to reference all of these instances in C land.

And we could have even emitted that PIANO_KEY_PRESSED_TOP pixel data
into the code segment, by using `#pragma option -z` to give identical
names to both the code and the data segment. At least we can decompile
the first two functions here.

Part of P0135, funded by [Anonymous].
2021-03-19 23:23:06 +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 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