Commit Graph

881 Commits

Author SHA1 Message Date
nmlgc e478ceef87 [Reverse-engineering] [th03] Hyper function pointers
夢時空.TXT calls this a "Gauge Power-Up", but that's both misleading
and too verbose, so let's go with how scoreplayers call it.

Part of P0071, funded by KirbyComment and -Tom-.
2020-01-29 09:11:41 +01:00
nmlgc 5ad9d83686 [Reverse-engineering] [th03] Charge Shot function pointers
The _add function pointer is part of the 128-byte player structure,
that's why it's already named differently here 🙃

Part of P0071, funded by KirbyComment and -Tom-.
2020-01-29 09:10:20 +01:00
nmlgc e6601fb27f [Reverse-engineering] [th03] Stage-dependent additional CPU damage per hit
Yup, in the first 6 stages, the CPU always takes more damage per hit
than P1. 1½ hearts in stages 1 and 2, 1 heart in stages 3 and 4, and
½ heart in stages 5 and 6.

Part of P0071, funded by KirbyComment and -Tom-.
2020-01-29 09:10:18 +01:00
nmlgc 327021bf16 [Position independence] [th03] Hit combo ring buffer
Completes P0070, funded by KirbyComment.
2020-01-20 22:49:33 +01:00
nmlgc 17cbe2ad62 [Reverse-engineering] [th03] Combo structure
Hey, look, it's a 0FFFFh constant that *doesn't* get RE'd as -1!

Part of P0070, funded by KirbyComment.
2020-01-20 22:49:31 +01:00
nmlgc 9943f2f7ef [Reverse-engineering] [th03] Currently processed player ID
Probably going to refine those `pid_other` variables later; it almost
seems as if there's one to store the attacked player for every entity
type?

Part of P0070, funded by KirbyComment.
2020-01-19 22:11:01 +01:00
nmlgc 8924a4a0aa [Reverse-engineering] [th03] Current score manipulation
Little-endian BCD, again… Far less crazy than in TH04 and TH05,
though, thanks to updating and rendering being two different functions
here.

Part of P0070, funded by KirbyComment.
2020-01-19 22:10:11 +01:00
nmlgc 761a0f48a2 [Reverse-engineering] [th03] Five-digit powers of 10
Part of P0070, funded by KirbyComment.
2020-01-19 22:08:58 +01:00
wintiger0222 a93175828c [Reverse-engineering] [th03] In-game score font
More related to the TH05 Music Room piano label font than to the small
popup numbers --Nmlgc
2020-01-19 22:07:31 +01:00
nmlgc 2bfd7be787 [Contributing] Document how to use TASM's interfaced function call syntax
And officially allow the stdcall workaround for __cdecl calls with
optimized stack cleanup.
2020-01-19 22:05:45 +01:00
nmlgc 3a2b26c370 [Contributing] BSS padding bytes should be rewritten into `evendata` 2020-01-19 20:17:26 +01:00
nmlgc 98e07ec5e1 [Contributing] Don't require declarations of internal symbols in header files 2020-01-15 20:25:15 +01:00
nmlgc 0f18dbc4bd [Decompilation] [th01] Single-point drawing and retrieval
In which our typedefs mercilessly reveal ZUN's original sloppiness, and
the unncessary sign extension taking place here. Also,  unused…

Completes P0069, funded by [Anonymous] and Yanga.
2020-01-14 22:12:18 +01:00
nmlgc b0c832bdee [Decompilation] [th01] Restorable line drawing
Yes, when clipping the start and end points to the screen area, ZUN
uses an integer division to calculate the line slopes, rather than a
floating-point one. Doesn't seem like it actually causes any incorrect
lines to be drawn, though; that case is only hit in the Mima boss
fight, which draws a few lines with a bottom coordinate of 400 rather
than 399. It *might* also restore the wrong pixels at parts of the
YuugenMagan fight, causing weird flickering, but seriously, that's an
issue everywhere you look in this game.

Part of P0069, funded by [Anonymous] and Yanga.
2020-01-14 22:12:08 +01:00
nmlgc b5cef6eb69 [Maintenance] Define VRAM access macros for arbitrary bit counts
Templates would have been nicer, but as soon as you add just one
non-immediate parameter, Turbo C++ generates a useless store to a new
local variable, ruining the generated code.

Part of P0069, funded by [Anonymous] and Yanga.
2020-01-14 22:09:51 +01:00
wintiger0222 e0d0dcd51d [Maintenance] [th02] Move remaining OP.EXE variables from ASM land to C land 2020-01-14 22:09:01 +01:00
wintiger0222 4d13d7f7e9 [Decompilation] [th01] graph_printf_fx 2020-01-14 22:08:44 +01:00
nmlgc 2ac00d47bf [Decompilation] [th01] Box and rectangle drawing
Completes P0068, funded by Yanga.
2020-01-14 22:06:58 +01:00
nmlgc a6d292a62c [Decompilation] [th01] graph_putsa_fx
TH01's (original) version also replicates the PC-98 text RAM's reverse
and underline attributes. Which was removed in later games,
interestingly and inconsistently enough.

Part of P0068, funded by Yanga.
2020-01-14 22:04:12 +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
nmlgc 4372b90ed0 [Maintenance] [th01] Fix the function name format of graph_putsa_fx
Part of P0068, funded by Yanga.
2020-01-14 22:02:10 +01:00
nmlgc add988f203 [Position independence] [th01_reiiden_2.inc] Main color palette references
Not that I'm much better at this in 2020! -.-

Part of P0068, funded by Yanga.
2020-01-14 22:01:33 +01:00
nmlgc aac5bec3bd [Position independence] [th01_reiiden_2.inc] Sine and cosine table references
Yup… missed them back in cae1be46, because I forgot about REIIDEN.EXE
using two files.

Part of P0068, funded by Yanga.
2020-01-14 22:00:49 +01:00
nmlgc d66416afb2 [Position independence] [th01] Restorable line and box drawing calls
Separate commit this time, because it's a lot!

Part of P0068, funded by Yanga.
2020-01-14 21:59:20 +01:00
nmlgc ebb30ce170 [Reverse-engineering] [th01] Restorable line and box drawing
Including the longest function present in more than one game among all
of PC-98 Touhou, and #23 on the list of longest functions overall,
which draws a 1-pixel line between two arbitrary pixels.

Completes P0067, funded by Splashman.
2020-01-14 21:53:00 +01:00
nmlgc 9f7dde8953 [Decompilation] [th01] Inter-page rectangle moves
Semi-unused, that is, the one use of this function doesn't actually
move the rectangle to a different position. Ironically, the non-moving
back-to-front function immediately above *is* unused…

Also, too bad that stack order is the only reason we can't use structs
to combine all plane variables into a single object.

Part of P0067, funded by Splashman.
2020-01-14 21:50:23 +01:00
nmlgc f87b0d4f9e [Maintenance] [th01] Don't #define away master.lib's graph_accesspage() macro
We will in fact have to use both the function call and the macro
version, even within the same translation unit.

Part of P0067, funded by Splashman.
2020-01-14 21:49:38 +01:00
nmlgc 6222b78514 [Reverse-engineering] [th01] Current back page
Previously sloppily mis-RE'd as "some page variable, idk", back in
2015…
Now also with a page number typedef. And yeah, restricting bool to C++
has now proven to be stupid after all.

Part of P0067, funded by Splashman.
2020-01-14 21:48:40 +01:00
nmlgc 22ebc48eea [Decompilation] [th01] Blocking palette fade-ins from a custom start color
 Unused…

Part of P0067, funded by Splashman.
2020-01-14 21:47:17 +01:00
nmlgc e55a48b700 [Decompilation] [th01] master.lib resident palette function reimplementations
Which store colors as GRB, as suggested by the structure's ID string.
Even master.lib's own functions add an additional XCHG AH, AL
instruction to get colors into and out of this format. MASTER.MAN
suggests that it's some sort of standard on PC-98. It does match the
order of ths hardware's palette register ports, after all.
(0AAh = green, 0ACh = red, 0AEh = blue)

Now we also know why __seg* wasn't used more commonly, as lamented in
c8e8e98. Turbo C++ simply doesn't support a lot of arithmetic on
segment pointers.

And then that undecompilable far call to a function within the same
segment, but inside a different translation unit…
Also, thanks again to Egor for the SCOPY@ hack that debuted in 0460072.
Would have probably struggled with this a lot more without that.

And *then* you realize that TH01 effectively doesn't even use the
resident palette. 😐

And yes, we're procrastinating the whole issue of potentially using
a single translation unit for all three binaries by using a common
segment name, because it *really* isn't that easy.

Completes P0066, funded by Keyblade Wiedling Neko and Splashman.
2020-01-05 20:23:27 +01:00
nmlgc 6a274436db [Reverse-engineering] [th01] Basic hardware palette functions
Part of P0066, funded by Keyblade Wiedling Neko and Splashman.
2020-01-05 19:08:31 +01:00
nmlgc a3bba96a26 [Reverse-engineering] [th01] Main color palette
Part of P0066, funded by Keyblade Wiedling Neko and Splashman.
2020-01-05 19:07:48 +01:00
nmlgc 0e19e52572 [Maintenance] Templatize RGB and palette types for 4- and 8-bit components
Right, PC-98 hardware only supports 4 bits per RGB component, for a
total of 4,096 possible colors. The 8-bit RGB color values we've been
seeing throughout the later games are a master.lib extension, to allow
for more toning precision. Which TH01, with all its NIH syndrome,
doesn't use.

And yup, that means templates in the most basic header files… Since
that would have meant renaming *everything* to compile as C++, I simply
made these types exclusive to C++ code, thcrap style.

Part of P0066, funded by Keyblade Wiedling Neko and Splashman.
2020-01-05 19:06:32 +01:00
nmlgc 042b7802bf [Reverse-engineering] [th04/th05] Resident structure
And yes, you can get it in your own tool by simply #including
th04/th04.hpp or th05/th05.hpp.

Completes P0065, funded by Touhou Patch Center.
2020-01-03 21:43:43 +01:00
nmlgc c3a9816e60 [Maintenance] [th04/th05] Declare a little-endian BCD score type
Only in C land though; doing the same in ASM land actually makes digit
accesses harder to read.

Part of P0065, funded by Touhou Patch Center.
2020-01-03 21:33:30 +01:00
nmlgc 23ea2d4bee [Reverse-engineering] [th04/th05] Item collection counters
Naming hell: Storing one and the same amount in two different variables
which are used in three places

Part of P0065, funded by Touhou Patch Center.
2020-01-03 21:31:25 +01:00
nmlgc b5d56e5df2 [Reverse-engineering] [th03/th04/th05] Frame counters
Of which there are quite a lot!

Part of P0065, funded by Touhou Patch Center.
2020-01-03 21:30:02 +01:00
nmlgc 658c0291d3 [Reverse-engineering] [th04/th05] Graze counter
Part of P0065, funded by Touhou Patch Center.
2020-01-03 21:29:27 +01:00
nmlgc 5a7fb6879f [Maintenance] Use the same resident structure pointer name for every game
The TH04/TH05 BGM/SE mode setup is a good example for code where
different structure field offsets will vanish completely upon reverse-
engineering. If we continued to use the per-game ID string as the
variable name, we'd only have another game-specific "difference" there.

Part of P0065, funded by Touhou Patch Center.
2020-01-03 21:26:10 +01:00
nmlgc 9faa29abbe [Position independence] [th04/th05] Final false positives in OP.EXE
And now, the website gets it as well.

Completes P0064, funded by Touhou Patch Center.
2019-12-29 21:15:44 +01:00
nmlgc 9e8fa66a7a [Reverse-engineering] [th04/th05] Stage display in the High Score menu
Part of P0064, funded by Touhou Patch Center.
2019-12-29 21:15:44 +01:00
nmlgc d3c24b5438 [Position independence] [th04/th05] egc_copy_rect_1_to_0 calls
Part of P0064, funded by Touhou Patch Center.
2019-12-29 21:15:44 +01:00
wintiger0222 87f2cd1103 [Maintenance] [th04/th05] Unused setup and Music Room data 2019-12-29 21:15:43 +01:00
nmlgc 3c1b2473dd [Reverse-engineering] [th04] BGM/SE mode setup window rendering
Part of P0064, funded by Touhou Patch Center.
2019-12-29 21:15:43 +01:00
nmlgc 24fdd31192 [Reverse-engineering] [th04] Extra Stage selectability
Final structure in TH04's OP.EXE! 🎉 Position independence now
reached here as well.

Part of P0064, funded by Touhou Patch Center.
2019-12-29 21:15:43 +01:00
nmlgc f5f45c9420 [Position independence] [th02/th03/th04/th05] PaletteTone values
Part of P0064, funded by Touhou Patch Center.
2019-12-29 21:15:42 +01:00
nmlgc 7b8b059ee7 [Reverse-engineering] [th04] Game clear variables
Part of P0064, funded by Touhou Patch Center.
2019-12-29 21:15:40 +01:00
nmlgc 4893a52ed3 [Position independence] [th04/th05] bgimage_put_rect calls
Part of P0064, funded by Touhou Patch Center.
2019-12-29 21:15:39 +01:00
nmlgc 0eaa142684 [Position independence] master.lib graph_* function calls
Part of P0064, funded by Touhou Patch Center.
2019-12-29 21:15:38 +01:00
nmlgc 80cec5b231 [Reverse-engineering] [th03] 1P/2P selection gaiji cursor
Part of P0064, funded by Touhou Patch Center.
2019-12-29 20:59:34 +01:00