Commit Graph

803 Commits

Author SHA1 Message Date
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
wintiger0222 daa6b7bb95 [Reverse-engineering] [th04/th05] End sequence constants 2019-12-29 20:59:24 +01:00
nmlgc 8dbb45050f [Reverse-engineering] [th04/th05] GENSOU.SCR decoding, encoding, and defaults
WTF. Fine, let's have separate, micro-optimized ASM implementations for
decoding and encoding inr MAIN.EXE, but still, all those minute
difference between OP.EXE and MAINE.EXE…
This is as far as anyone should reasonably go before decompilation;
things will get really ugly with the loading functions once the file
name is involved as well…

Completes P0063, funded by -Tom-.
2019-12-28 12:27:52 +01:00
nmlgc f46fc914c1 [Maintenance] [th04/th05] Define a OP/MAIN/MAINE macro
Seems to be the best way to handle all those implementation differences
in the GENSOU.SCR functions.

Part of P0063, funded by -Tom-.
2019-12-28 12:27:47 +01:00
nmlgc 5eeed67113 [Reverse-engineering] [th04/th05] GENSOU.SCR structure
Funny how the actual scores are stored as little-endian gaiji strings
in the bold font, yet never actually used as such.

Part of P0063, funded by -Tom-.
2019-12-28 12:18:43 +01:00
nmlgc b7de999705 [Maintenance] Improve score data file-related type and function names
So many things named `score_*`, so many things named `hiscore_*`…
Let's go with `scoredat_*`, which clearly indicates that this stuff is
saved into a file, while still being only 8 characters.

Part of P0063, funded by -Tom-.
2019-12-28 12:14:02 +01:00
nmlgc 9791ea55cf [Maintenance] [th04] Move gaiji.inc to its own subdirectory
The other games also have their own directory.

Part of P0063, funded by -Tom-.
2019-12-28 12:12:36 +01:00
nmlgc 034ae4ba94 [Contributing] Padding bytes should be rewritten into `even` or `align` 2019-12-26 10:54:43 +01:00
nmlgc f275e041e9 [Position independence] master.lib superimpose function calls
Completes P0062, funded by Touhou Patch Center.
2019-12-22 15:39:34 +01:00
nmlgc 7d329202e7 [Position independence] graph_putsa_fx() calls
Waiting with the `fx` parameter in TH01's calls for the decompilation
of this game's version of this function…

Part of P0062, funded by Touhou Patch Center.
2019-12-22 15:38:31 +01:00
nmlgc 705e942ca0 [Reverse-engineering] [th04/th05] BGM/SE mode setup strings
Part of P0062, funded by Touhou Patch Center.
2019-12-22 15:37:45 +01:00
nmlgc 83f422c61a [Decompilation] [th05] Character-independent shot type functions
Part of P0062, funded by Touhou Patch Center.
2019-12-22 15:37:36 +01:00
nmlgc c060df171e [Decompilation] [th05] Reimu's shot control functions
That took less than 1½ hours, even with deduplication. Too easy.

Part of P0062, funded by Touhou Patch Center.
2019-12-22 15:35:58 +01:00
nmlgc 36f1727f82 [Maintenance] [th05] Abstract away randring for shot angles
Part of P0062, funded by Touhou Patch Center.
2019-12-22 15:34:19 +01:00
nmlgc 765eae82e8 [Maintenance] [th05] Minimize #includes for the shot type translation units
Since a few annoying alignment bytes suggested more translation units
than previously expected, using many small headers has proved to be
better than one big shared TH04/TH05 header file. Or should we *really*
pepper the code with lots of `#pragma codestring`? 😛

And in case we have multiple translation units which all #include the
same set of headers, we'll just go with situational shared headers,
using a common prefix.

Part of P0062, funded by Touhou Patch Center.
2019-12-22 15:32:44 +01:00
nmlgc c5b07b746e [Maintenance] `#pragma once` has no effect?
Should have remembered this from all the times I've looked at the list
of #pragma directives supported by Turbo C++… Still, I would have at
least expected a warning, but not even the `ill` warning covers this.

Part of P0062, funded by Touhou Patch Center.
2019-12-22 15:31:24 +01:00
wintiger0222 1d6fbb8108 [Reverse-engineering] [th05] Masked PI display
As used for the title screen fade-in effect. Another function that
apparently was deliberately written to run not that fast, by blitting
each row individually to the 400th VRAM row just so that it can then
turn on the EGC, perform the *actual* masked blit to the VRAM
destination, and then turn the EGC off before moving to the next now.
The same effect could have entirely been accomplished by copying
graph_pack_put_8() and applying the mask there; it's not like ZUN
didn't know how to modify master.lib…

(See also 44ad3eb4) --Nmlgc
2019-12-17 23:27:02 +01:00
nmlgc a5e714b165 [Maintenance] [th05] Clarify pi_slot_put() a bit
Can't blame WindowsTiger for writing hard-to-review code when he just
adapted what I wrote in 2014…
2019-12-17 23:27:01 +01:00
nmlgc 75a779e82a [Maintenance] Clean up PI function declarations and comments 2019-12-17 23:27:01 +01:00
nmlgc deb1b73016 [Maintenance] Use a single DEFCONV definition file to cover all games
This makes a lot more sense in C land, where we can then #include this
tiny file in front of all DEFCONV declarations.
2019-12-17 23:27:01 +01:00
wintiger0222 13e4476cc8 [Naming] [th04/th05] MPTN functions 2019-12-17 23:27:01 +01:00
wintiger0222 67ab2f4a41 [Naming] [th01] Game init and exit functions 2019-12-17 23:27:01 +01:00
wintiger0222 990a1e2c94 [Naming] [th03/th04/th05] Main and option menu functions 2019-12-17 23:27:00 +01:00
wintiger0222 04f0491885 [Naming] [th03/th04/th05] .cfg file functions 2019-12-17 23:27:00 +01:00
wintiger0222 e219527964 [Naming] [th03/th04/th05] High score menu functions 2019-12-17 23:27:00 +01:00
wintiger0222 b95a625d87 [Naming] [th04/th05] Character select screens 2019-12-17 23:27:00 +01:00
wintiger0222 02d1c04858 [Reverse-engineering] [th05] Character selection and unlock variables 2019-12-17 23:27:00 +01:00
nmlgc 50c36f5551 [Reverse-engineering] Player character constants 2019-12-17 23:26:59 +01:00
wintiger0222 6e741bb1e1 [Reverse-engineering] [th04] cdg_put_plane_roll
Used for the falling blue stars in TH04 Stage 5 --Nmlgc
2019-12-17 23:26:59 +01:00