Commit Graph

150 Commits

Author SHA1 Message Date
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 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
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 7b8b059ee7 [Reverse-engineering] [th04] Game clear variables
Part of P0064, funded by Touhou Patch Center.
2019-12-29 21:15:40 +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
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 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 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 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 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 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 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
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 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 cb45bf5a80 [Reverse-engineering] [th04/th05] EGC-powered page 1→0 region copies 2019-12-17 23:26:58 +01:00
wintiger0222 d7906ef78e [Reverse-engineering] [th04/th05] ZUN Soft logo 2019-12-17 23:26:57 +01:00
nmlgc c6ab779897 [Maintenance] [th04/th05] Correctly declare the ZUN Soft explosion functions 2019-12-17 23:26:57 +01:00
wintiger0222 38e8fd6a8d [Reverse-engineering] [th04/th05] Music Room / ending background image buffers
"bgimage" really was the best name I could come up with here, given
what it's used for. Everything else sounded way too ambiguous. Even
something like "mempage", in the meaning of "a third memory-backed
graphics page"… --Nmlgc
2019-12-17 23:26:56 +01:00
wintiger0222 0b084b83c3 [Reverse-engineering] [th04/th05] graph_putsa_fx 2019-12-17 23:26:54 +01:00
wintiger0222 75f05c8b90 [Reverse-engineering] [th04/th05] graph_putsa_fx tables 2019-12-17 23:26:54 +01:00
nmlgc bb6b0f1cc3 [Maintenance] Move the Subpixel class to a separate header, under TH03
Part of P0061, funded by Touhou Patch Center.
2019-12-05 21:21:56 +01:00
32th System 96684f45dc [Reverse-engineering] [th04/th05] Pause menu 2019-11-30 19:36:07 +01:00
nmlgc 30e6b7c3db [Maintenance] Correctly declare all input functions
The pascal calling convention for TH03's input mode functions actually
sort of matters, since we have this nice function pointer type that
expects pascal.
2019-11-30 19:34:55 +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 619203a1c9 [Position independence] [th02/th03/th04/th05] Color palettes
Part of P0060, funded by Touhou Patch Center.
2019-11-28 23:23:29 +01:00
wintiger0222 61a2df2d71 [Naming] [th04/th05] EMS area setup 2019-11-24 16:02:43 +01:00
wintiger0222 37fb6eba32 [Naming] [th02/th04/th05] Demo loading and playback 2019-11-24 14:14:13 +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
nmlgc 8b627803a3 [Position independence] Vector calls and variables
Raw, uninteresting position independence work. Or maybe not, given that
this was one of the few things that also apply to TH01, and reveal just
how chaotically this game was coded. And so we've got three ways that
ZUN stored regular 2D points: Regularly (X first, Y second), Y first
and X second, and multiple points stored in a structure of arrays…

Completes P0059, funded by [Anonymous] and -Tom-.
2019-11-18 22:24:24 +01:00
nmlgc 3d7211b128 [Position independence] Remaining motion structures and comparisons
Part of P0059, funded by [Anonymous] and -Tom-.
2019-11-18 22:21:29 +01:00
nmlgc ad22ce26c2 [Reverse-engineering] [th04/th05] Player position clamping
Part of P0059, funded by [Anonymous] and -Tom-.
2019-11-18 22:21:23 +01:00
nmlgc b37611b1be [Maintenance] Add an underscore to the player_pos variable
No need to declare them as `pascal` on the C side only because I messed
up when naming them first.

Part of P0059, funded by [Anonymous] and -Tom-.
2019-11-18 22:21:15 +01:00
nmlgc fef0299fbc [Reverse-engineering] [th04/th05] Midboss / boss explosion phase constants
In the end, the explosions remain the only constant in these phases,
everything else ("defeat"? "last phase"?) could have been
misunderstood. And yes, the algorithm really treated these 111
constants as potential memory references…

Completes P0058, funded by -Tom-.
2019-11-14 00:57:38 +01:00
nmlgc 8a250701bd [Reverse-engineering] [th04/th05] Items dropped when losing a life
> not using the Point structure, which is not only perfectly suitable
here, but would have also generated much better code

Part of P0058, funded by -Tom-.
2019-11-14 00:50:56 +01:00
nmlgc ac7540dada [Reverse-engineering] [th04/th05] Item types and sprite IDs
Completes P0057, funded by [Anonymous] and -Tom-.
2019-11-14 00:49:22 +01:00
nmlgc 2f0ca1ccf1 [Position independence] False positives in item functions
Welcome to this new [brand] of reverse-engineering, where we only fix
things that might be mistaken for addresses, without looking deeper
into what the actual functions do… unless that directly leaps into
the eye.

Part of P0057, funded by [Anonymous] and -Tom-.
2019-11-14 00:48:24 +01:00
nmlgc 34089cbe3f [Reverse-engineering] [th04/th05] Item structure
Part of P0057, funded by [Anonymous] and -Tom-.
2019-11-14 00:47:20 +01:00
nmlgc 2918e6dbd0 [Reverse-engineering] [th04/th05] Item spawn "splash" circles
"Splashes"? That's what uth05win calls them. Oh well, "circle" is
already taken, and merely keeping the slices in the item/ directory
won't avoid the name collision when looking at game code.

These are hardly visible on top of regular enemy explosion animations;
you can most clearly see them at the end of the TH04 Extra Stage
midboss. Easy enough to *almost* completely cover right now, even
during a position independence push. Struct strITEM_SPLASH in uth05win.

Part of P0057, funded by [Anonymous] and -Tom-.
2019-11-14 00:45:32 +01:00
nmlgc d1acb70cdc [Maintenance] Move the enemy item drop table to an item/ subdirectory
Part of P0057, funded by [Anonymous] and -Tom-.
2019-11-14 00:44:10 +01:00
nmlgc e7e1cbcaaf [Decompilation] [th05] Marisa's shot control functions
Yeah… such fun pretending that the original code wasn't copy-pasted.
And yes, Reimu will have to wait until the next one.

Completes P0037, funded by zorg.
2019-10-14 23:54:37 +02: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