Commit Graph

10 Commits

Author SHA1 Message Date
nmlgc b61e612fdf [Maintenance] #include each header's dependencies within the header itself
OK, this is the big one. We still keep using `#include` guards only
where we absolutely need to, but with each header now being valid in
isolation, this can now actually help *minimize* the length of each
translation unit's `#include` list. Turns out that after removing all
the duplicates, we only *actually* need to guard 29 headers across all
5 games.

Part of P0285, funded by [Anonymous] and iruleatgames.
2024-07-09 08:46:42 +02:00
nmlgc 87eed57ade [Decompilation] [th03] Hit circles: Rendering
Completes P0280, funded by [Anonymous], Blue Bolt, and JonathKane.
2024-04-23 05:52:53 +02:00
nmlgc 9b28791c7f [Maintenance] [th03] Add a separate type for SPRITE16 sprite area offsets
Part of P0182, funded by Lmocinemod and [Anonymous].
2022-02-18 09:36:34 +01: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 f6a3246071 [Reverse-engineering] Enabling and disabling the EGC
Which involves temporarily enabling a GDC mode change bit.

Completes P0125, funded by [Anonymous].
2020-11-02 23:42:04 +01:00
nmlgc 50b17d640b [Reverse-engineering] [th03] SPRITE16 setup for double-buffered blitting
Part of P0114, funded by Lmocinemod.
2020-09-07 21:18:39 +02:00
nmlgc b6e0330ff6 [Decompilation] [th03] Sprite display calls
Yes, decompilation, of something that was so obviously originally
written in ASM. We're still left with two un-decompilable instructions
here, but I'm amazed at how nicely I was able to abstract away all of
the gory register details, leading to pretty clear, readable, and dare
I say *portable* code?! Turbo C++ was once again pretty helpful here:

• `static_cast<char>(_BX) = _AL` actually compiles into `MOV BL, AL`,
  as you would have intended,
• and no-op assignments like _DI = _DI are optimized away, allowing
  us to leave them in for clarity, so that we can have all parameter
  assignments for the SPRITE16 display call in a single place.

I love this compiler.

Part of P0060, funded by Touhou Patch Center.
2019-11-28 23:14:21 +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 c09446a1f4 [Reverse-engineering] [th03] SPRITE16 calls
Aha! TH03's in-game graphics run in line-doubled 640×200 simply because
that's what this SPRITE16.COM version was written for, making use of
the PC-98 EGC for optimized blitting.

Doesn't seem all *too* optimized though, given that it chooses to
effectively draw every sprite twice, just in case it might overlap with
something that's already in VRAM. It first clears the previous VRAM
content at the drawing position according to the sprite's alpha mask,
then ORs in the actual sprite data. The EGC can do monochrome alpha-
tested blitting just as well as the GRCG, but once the sprite data
covers all bitplanes, ORing is apparently the best it can do by itself?
More technical details on the raster operations in the next push!

Completes P0056, funded by rosenrose and [Anonymous].
2019-11-06 23:36:47 +01:00
nmlgc 772897c8f5 [th03] Identify ZUNSP.COM as a rebrand of Promisence Soft's SPRITE16.COM driver
Which was actually found out by @m1yur1 last year, who thankfully
tweeted this in reference to ReC98:

	https://twitter.com/m1yur1/status/1018855232371998720

Thanks a lot! But what makes this more than a piece of trivia is the
fact that the StormySpace release actually *was* bundled with
documentation. Shoutout to the Neo Kobe PC-98 collection for preserving
the original release! This should now greatly simplify any RE efforts
related to TH03's INT 42h calls. (Not *trivialize*, because there's
still all this EGC hardware to be understood…)

And sure, you *were* allowed to use this driver in your own game, but
replacing the copyright with your own isn't exactly the nicest thing to
do… That now makes three library programmers that ZUN didn't credit.
Makes me wonder what makes M. Kajihara so special. Probably the fact
that Touhou has always been about the music for ZUN, first and
foremost.

Part of P0056, funded by rosenrose and [Anonymous].
2019-11-06 23:30:43 +01:00