Commit Graph

98 Commits

Author SHA1 Message Date
nmlgc d6f356da45 [Maintenance] Use a single per-game, per-binary file for super_*() patnum IDs
Since they're determined by the order of sprites in a .BFT file,
they're best auto-generated by an enum as much as possible.

Part of P0074, funded by Myles.
2020-02-16 21:43:08 +01:00
nmlgc 0f3359e1b3 [Maintenance] Use @@locals for self-modifying code in bfnt_entry_pat()
Which finally allows us to use the PLANE_SIZE macro in ASM land. Yeah,
(ROW_SIZE * RES_Y) has finally got old.

Part of P0073, funded by [Anonymous] and -Tom-.
2020-02-16 21:35:16 +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
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 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 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 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 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 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 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
nmlgc 417ba80c00 [Decompilation] Add a separate segment type
At least wherever Turbo C++ and master.lib want us to use a
non-pointer, since both use uint16_t for segment values throughout
their APIs instead of the more sensible void __seg*. Maybe, integer
arithmetic on segment values was widely considered more important than
dereferencing?
2019-12-17 23:26:59 +01:00
nmlgc 59bbe313ad [Decompilation] Add separate types for 1bpp planar pixel lines 2019-12-17 23:26:59 +01:00
nmlgc 9cb6cc527a [Decompilation] Finally declare <stdint.h> types
*Finally*. We already used `(unsigned) int` in quite a few places where
we actually want a 16-bit value, which was bound to annoy future port
developers.
2019-12-17 23:26:58 +01:00
wintiger0222 1317273aa0 [Reduction] [th03/th04/th05] Music Room code identical to TH02 2019-12-17 23:26:56 +01:00
wintiger0222 25903719a3 [Naming] [th02] Current and high score 2019-12-17 23:26:55 +01:00
wintiger0222 1ffa121821 [Naming] [th02] Gaiji loading
Renaming these to gaiji_load() and gaiji_free() for consistency with
other functions that load files. --Nmlgc
2019-12-17 23:26:54 +01:00
wintiger0222 0b084b83c3 [Reverse-engineering] [th04/th05] graph_putsa_fx 2019-12-17 23:26:54 +01:00
nmlgc a23dab3154 [Reverse-engineering] MMD ticks-per-quarter-note constant
And then, ZUN hardcodes all measure-related functions to 4/4…
2019-12-17 22:40:05 +01:00
nmlgc a6a805f008 [ZUN symbols] key_det / shiftkey
Not applying this leak to TH03 since it would have more than one
`key_det` variable, resulting in names that are as much fanfiction as
the current ones…
2019-11-30 19:32:10 +01:00
nmlgc 5bffab4f43 [Position independence] [th04/th05] Remaining references to PI slots
Part of P0060, funded by Touhou Patch Center.
2019-11-28 23:23:30 +01:00
wintiger0222 37fb6eba32 [Naming] [th02/th04/th05] Demo loading and playback 2019-11-24 14:14:13 +01:00
wintiger0222 22bf71d170 [Reduction] [th03/th04/th05] game_init_main 2019-11-24 14:14:13 +01:00
wintiger0222 09edcab744 [Reduction] [th03/th04/th05] game_init_op 2019-11-24 14:04:36 +01:00
nmlgc 71c737c4ee [Maintenance] Move DOS memory assignment sizes to separate files
Ideally, these could be calculated from some other game-specific
parameters? Anyone else who wants to look into this?
2019-11-24 14:04:36 +01:00
nmlgc 3f25caa5df [Reverse-engineering] [th02/th03/th04/th05] DOS memory assignment sizes
Changing the variable suffix to _paras rather than _siz here, since
master.lib uses the latter for byte sizes, while these are paragraphs.
2019-11-24 14:04:34 +01:00
wintiger0222 0009c3c161 [Reduction] [th03/th04/th05] game_exit_to_dos 2019-11-24 12:45:25 +01:00
wintiger0222 34b7b61964 [Reduction] [th03/th04/th05] game_exit 2019-11-24 12:45:17 +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 db4de240e9 [Decompilation] Prepare the C side for the shot type control functions
That should make this convoluted copypasta a bit easier to read. And
sure, I could have done something about the loop as well, but
SHOT_FUNC_INIT already hides enough control flow behind a macro…

Part of P0037, funded by zorg.
2019-10-14 23:42:20 +02:00
nmlgc f33a3ef220 [Maintenance] [th04/th05] Separate constant for the player↔option distance
Used in pretty much all shot type control functions.

Part of P0036, funded by zorg.
2019-10-14 23:41:57 +02:00
nmlgc 7887f53ea8 [Maintenance] Move the playfield constants to a separate .inc file
With both 16- and 32-bit build parts soon having full dependency
tracking, having more small includes wins out over having fewer, larger
ones – and also, over having to fix tons of macro conflicts that stem
from most .inc files assuming the context of the big .asm files.

Case in point, including ReC98.inc doesn't work right now without
defining a .MODEL, which is counter-productive for ASM compilation
units.

Part of P0035, funded by zorg.
2019-09-24 22:00:48 +02:00
nmlgc e65cf0d05d [Maintenance] Change a few ASM .inc files to use 8.3 names
Part of P0035, funded by zorg.
2019-09-24 21:58:18 +02:00
nmlgc 290935fe3e [Reverse-engineering] [th04/th05] Player character display
Including options and the death explosions.

Part of P0035, funded by zorg.
2019-09-24 21:58:09 +02:00
nmlgc 6f1f36722f [Reverse-engineering] [th01/th02/th04/th05] Player invincibility frames
Completes P0034, funded by zorg.
2019-09-24 21:57:53 +02:00
nmlgc e6294c2c1a [Reverse-engineering] [th02/th04/th05] Score update and display
The TH02 version is a piece of cake…

… but TH04 starts turning it into this un-decompilable piece of
unnecessarily micro-optimized ZUN code. Couldn't have chosen anything
better for the first separate ASM translation unit.

Aside from now having to convert names of exported *variables* to
uppercase for visibility in ASM translation units, the most notable
lesson in this was the one about avoiding fixup overflows. From the
Borland C++ Version 4.0 User's Guide:

	"In an assembly language program, a fixup overflow frequently
	 occurs if you have declared an external variable within a
	 segment definition, but this variable actually exists in a
	 different segment."

Can't be restated often enough.

Completes P0032, funded by zorg.
2019-09-21 14:01:47 +02:00
nmlgc 88c05e48e5 [Maintenance] Move a few more ASM definitions to their own .inc files
Part of P0032, funded by zorg.
2019-09-21 13:05:54 +02:00
nmlgc f07089017f [Maintenance] Rename the extension of game-specific ASM includes to .inc
Rule of thumb going forward: Everything that emits data is .asm,
everything that doesn't is .inc.
(Let's hope that th01_reiiden_2.inc won't exist for that much longer!)

Part of P0032, funded by zorg.
2019-09-21 13:03:56 +02:00
nmlgc 3b7561a711 [Maintenance] Export all pascal functions with their proper uppercase names
Yup, that was one massive screw-up.

Part of P0030, funded by zorg.
2019-09-15 20:29:47 +02:00
nmlgc fac879f8e6 [Reverse-engineering] [th05] Number display using the bold gaiji font
Many thanks to http://bytepointer.com/tasm/index.htm for providing a
better searchable resource for TASM's default `LEA imm16` → `MOV imm16`
optimization, which we initially had to hack around here.

Funded by -Tom-.
2019-03-06 19:32:38 +01:00
nmlgc d9e9b38736 [Reverse-engineering] [th04/th05] Spark animation
Also seen when midbosses explode. Class CSparkEffect in uth05win.

Funded by -Tom-.
2019-02-28 17:43:15 +01:00
nmlgc da284cacaf [Reverse-engineering] [th02/th04/th05] Hardcoded spark sprites
As seen when killing stage enemies or grazing.

Funded by -Tom-.
2019-02-28 17:43:15 +01:00
nmlgc c2ef9d51b6 [Reverse-engineering] [th02/th03/th04/th05] Back/front page pairs
Because using just one variable would have totally been too
straightforward.

Funded by -Tom-.
2018-12-30 00:16:18 +01:00
nmlgc e1e4f819ed [Reverse-engineering] [th02/th04/th05] Stage background tile ring buffer
Funded by -Tom-.
2018-12-29 17:03:24 +01:00
nmlgc 8ee87233b8 [Reverse-engineering] [th02/th05] Player movement speed
Yes, both characters in TH04 have the same speed!

Funded by -Tom-.
2018-12-26 22:07:34 +01:00
nmlgc b62a8b29a6 [Reverse-engineering] [th02/th04/th05] Boss-related function pointers
No idea what these other ones in TH02 are.

Funded by zorg.
2018-12-18 19:52:41 +01:00
nmlgc b487d6fc20 [Reverse-engineering] [th02/th04/th05] Power overflow bonus
Funded by zorg.
2018-09-02 20:48:31 +02:00
nmlgc 4b8baf1413 [Reverse-engineering] [th02/th03/th04/th05] Random number ring buffer
Yes, you're reading that correctly. If the cursor is at 255, reading a
16-bit value will fill the upper 8 bits with the neighboring cursor
value, which always is 0xFF.

Funded by -Tom-.
2018-03-16 18:12:21 +01:00