Commit Graph

136 Commits

Author SHA1 Message Date
nmlgc da6b856dc5 [Reverse-engineering] [th04/th05] Stage enemy structure
Last one of the shared entity types! The TH05 version of the .STD enemy
VM would now be ready for decompilation in one single future push.

Completes P0088, funded by -Tom-.
2020-05-03 23:21:30 +02:00
nmlgc ba66fcc801 [Reverse-engineering] [th04/th05] Currently alive player shots
Copying out the shot position might have actually been a decent
optimization for hit detection, to avoid the indirection if the shot
is not colliding with anything.

Part of P0088, funded by -Tom-.
2020-05-03 23:18:56 +02:00
wintiger0222 c6b17b0c24 [Reverse-engineering] [th04/th05] Point number popup add functions
Reviewed and merged as part of P0087, funded by -Tom-.
2020-04-15 21:34:32 +02:00
wintiger0222 ff56f162ea [Reverse-engineering] [th04/th05] Point number popup update/render functions
Reviewed and merged as part of P0087, funded by -Tom-.
2020-04-15 21:34:23 +02:00
nmlgc 24b96cd9da [Reverse-engineering] [th05] Curve bullet rendering
TH04's z_super_roll_put_tiny_32x32(), which this is based on, had
checks for not writing empty rows to VRAM. Why would ZUN remove them
here?

Completes P0086, funded by [Anonymous] and Blue Bolt.
2020-04-15 21:34:20 +02:00
nmlgc 8098b62285 [Reverse-engineering] [th05] Aiming to the player
Yes, this only became a dedicated function in TH05, probably due to all
the custom bullet types.

Part of P0086, funded by [Anonymous] and Blue Bolt.
2020-04-15 21:34:19 +02:00
nmlgc cf68f49803 [Reverse-engineering] [th04/th05] Boss phase end functions
…which I'd like to cover all at once.

Part of P0086, funded by [Anonymous] and Blue Bolt.
2020-04-15 21:34:19 +02:00
nmlgc 4bab289d8a [Maintenance] [th04/th05] Declare boss explosions in C land
Part of P0086, funded by [Anonymous] and Blue Bolt.
2020-04-15 21:34:13 +02:00
nmlgc cb8da961c9 [Reverse-engineering] [th04/th05] Boss item drops
Part of P0086, funded by [Anonymous] and Blue Bolt.
2020-04-15 21:01:59 +02:00
nmlgc d1f3dcd620 [Maintenance] Move all features exclusive to MAIN.EXE to a main/ subdirectory
Adding op/, main/, and end/ directories does nicely cover a great
majority of the "not really further classifiable slices" implied in
d56bd45.

Part of P0086, funded by [Anonymous] and Blue Bolt.
2020-04-15 20:58:01 +02:00
nmlgc 48203add0a [Reverse-engineering] [th04/th05] Gather circle structure
Part of P0085, funded by -Tom-.
2020-04-03 17:41:04 +02:00
nmlgc 02f0a0afcc [Build] Don't word-align everything by default
Again, 11 necessary workarounds, vs. forcing byte aligment in at least
18 places, and that number would have significantly grown in the
future.

Part of P0085, funded by -Tom-.
2020-04-03 17:35:57 +02:00
nmlgc ffad8cc897 [Build] Use the minimum possible size for enums by default
5 enums where code generation wants an `int`, vs. 11 cases where using
the minimum size is exactly the right default. So it's way more
idiomatic to force those 5 to 16 bits via a dummy element… except that
we can't give it a single, consistent name, because you can't redeclare
the same element in a different enum later.

Oh well, let's have this ugly naming convention instead, which makes it
totally clear that the force element not, in fact, a valid value of
that enum.

Part of P0085, funded by -Tom-.
2020-04-03 17:33:58 +02:00
nmlgc 54e5bf39fc [Maintenance] Use `dots` for 1bpp lines, and `planar` for B/R/G/E dot structs
I tried `brge` for the latter, but that had *the* most horrible
ergonomics, and I misspelled it as `bgre` 100% of the times I typed it
manually. Turns out that `dots` is also consistent with master.lib's
naming scheme, leaving `planar` to *actually* refer to types storing
multiple planes worth of pixels. These types are showing up more and
more, and deserve something better than their previous long-winded and
misleading name.

Part of P0081, funded by Ember2528.
2020-03-07 21:19:25 +01:00
nmlgc 8a9cb158b6 [Reverse-engineering] [th05] Custom entity 6: Shinki's 32×32 balls
Which need to be separate from Mai's and Yuki's 32×32 balls because…
they have a delay cloud, whose radius absolutely has to be stored
redundantly, rather then deriving it from the [age]? Same for the decay
frame count. And the _update() function was copy-pasted from the knife
one…

Part of P0079, funded by -Tom-.
2020-02-29 16:00:30 +01:00
nmlgc 1764700729 [Reverse-engineering] [th05] Custom entity 5: Yumeko's knives
Immediately understandable just by applying the structure fields.

Part of P0079, funded by -Tom-.
2020-02-29 15:57:18 +01:00
nmlgc 3bcc62ecbc [Position independence] [th05] Custom entity 4: Mai's and Yuki's 32×32 balls
Part of P0079, funded by -Tom-.
2020-02-29 15:56:03 +01:00
nmlgc 9e52cb15cf [Reverse-engineering] [th05] Custom entity 3: Curve bullet head structure
"Wait, the template has to store the color… hey, let's just overload
the sprite ID field!" :zunpet:

Completes P0078, funded by iruleatgames and -Tom-.
2020-02-29 15:55:17 +01:00
nmlgc dba8f15dc7 [Position independence] [th05] Custom entity 2: Alice's puppets
Heavily hardcoded for only two of them, even though there'd be space
for 65, even without position independence. Puppet army mod when?

Part of P0078, funded by iruleatgames and -Tom-.
2020-02-29 15:54:09 +01:00
nmlgc 42f2dd790b [Position independence] [th05] Custom entity 1: Stage 2 star particle structure
Part of P0078, funded by iruleatgames and -Tom-.
2020-02-29 15:53:32 +01:00
nmlgc 5000bc07d7 [Reverse-engineering] [th05] Custom entity structure
On the surface, TH05 uses one single 26-byte structure for
• the Stage 2 starfield,
• Alice's puppets,
• curve bullet heads,
• Mai's snowballs and Yuki's fireballs,
• Yumeko's knives,
• and Shinki's 32×32 bullets.
But looking closer, it turns out that the fields of all these have very
different semantics, and in some cases, even different types. uth05win
treated all of those as distinct structures, and we're going to do the
same, merely overlaying the pointers onto the same generic array.

Part of P0078, funded by iruleatgames and -Tom-.
2020-02-29 15:51:17 +01:00
nmlgc 012a84de1f [Reverse-engineering] [th05] Curve bullet trail structure
7 individually moving curve bullets × (16 trail points + 1 head point)
= 117 effective hitboxes. And yes, the game only renders half of them.

Part of P0078, funded by iruleatgames and -Tom-.
2020-02-29 15:47:37 +01:00
nmlgc f99d7a571c [Maintenance] Remove all dependencies on Borland C++ run-time source headers
And with all possible .COM executables decompiled, this set of changes
reaches an acceptable scope, allowing us to *finally*…

Part of P0077, funded by Splashman and -Tom-.
2020-02-23 17:53:18 +01:00
nmlgc ebd214bbb2 [Decompilation] [th05] RES_KSO.COM
And of course, TH05 ruins the consistency once again. Sure, the added
file error handling is nice, but we also have changes in the playful
messages (lol), and now need a third distinct optimization barrier
(🤦)… But as it turns out, inlined calls to empty functions work as
well. They also seem closer to what ZUN might have actually written
there, given that their function body could have been removed by the
preprocessor, similar to the logging functions in the Windows Touhou
games. (With the difference that the latter infamously *aren't*
inlined…)

Part of P0077, funded by Splashman and -Tom-.
2020-02-23 17:53:17 +01:00
nmlgc a2961b02da [Reverse-engineering] [th03/th04/th05] Configuration file
The supposedly low-hanging fruit that almost every outside contributor
wanted to grab a lot earlier, but (of course) always just for a single
game… Comprehensively covering all of them has only started to make
sense recently 😛

Also, yes, the variable with the uppercase .CFG filename has itself a
lowercase name and vice versa…

Part of P0077, funded by Splashman and -Tom-.
2020-02-23 17:24:17 +01:00
nmlgc 6363a37d7a [Maintenance] Move TH02's sound functions to a separate header
Oh hey, guarding declarations with complicated types via #ifdef limits
the header files we additionally have to #include!

Part of P0076, funded by [Anonymous] and -Tom-.
2020-02-23 16:51:45 +01:00
nmlgc 222fc993d0 [Reverse-engineering] [th04/th05] Bullet spawn types
Well… how else to call a variable that handles
• pellet vs. 16×16 sprite (TH04),
• the delay cloud flags from bullet_spawn_state_t, but with different
  values (which is restricted to 16×16 sprites in TH04),
• optionally showing the gather animation before spawning the bullet
… whether the bullet uses the basic slowdown motion (TH05),
  (which is restricted to pellets in TH04),
• and defining what happens *after* the gather animation – not actually
  spawning any bullets (TH04), or using the special motion type from
  the bullet template (TH05)

🤯

Completes P0075, funded by Myles and -Tom-.
2020-02-16 21:48:33 +01:00
nmlgc 3292af086b [Reverse-engineering] [th04/th05] Bullet pattern types
uth05win TL note: "n-way all-around" means "ring"… yep, let's better
improve on the naming here, once again using established terminology
from Sparen's Danmaku Design Guide at

	https://sparen.github.io/ph3tutorials/ddsga3.html

Since TH04 only supports rings *or* spreads *or* stacks, overloading
[delta] to store both spread angle and stack speed, that enum does
serve kind of a purpose in TH04. Unlike TH05, where it could be vastly
simplified to a bitfield with 4 flags: aim to player, randomize angle,
randomize speed, force single. Which could then actually create *more*
types of patterns than these uselessly defined 14 distinct types, all
of which can already be derived from the other values of the upcoming
template structure:
• Set [stack] to 1 if you don't want a stack
• Set [spread] to 1 if you don't want a spread
• Set [spread_delta_angle] to 0 to turn a N-way spread into a ring
Easy.

Part of P0075, funded by Myles and -Tom-.
2020-02-16 21:47:28 +01:00
nmlgc 1807906400 [Reverse-engineering] [th04/th05] Sprite selection for angled bullets
Completes P0074, funded by Myles.
2020-02-16 21:46:43 +01:00
nmlgc eb0cf6820f [Reverse-engineering] [th04/th05] Bullet-related sprite IDs
IDs based on Maribel Hearn's jargon page
(https://maribelhearn.com/jargon) as well as Sparen's Danmaku Design
Guide (https://sparen.github.io/ph3tutorials/ddsga1.html#sub2).

Part of P0074, funded by Myles.
2020-02-16 21:44:51 +01:00
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 fdf2a45baf [Maintenance] Use *_CELS to denote the number of distinct animation sprites
Which are typically lower than the amount of *_FRAMES they're shown in.

Part of P0074, funded by Myles.
2020-02-16 21:41:28 +01:00
nmlgc 52864172a4 [Reverse-engineering] [th05] Micro-optimized monochrome 16×16 sprite display
Might as well cover this one while I've got this type of function in my
head. This one is used for the animated star backgrounds during Stage 2
and the Shinki battle.

Completes P0073, funded by [Anonymous] and -Tom-.
2020-02-16 21:39:27 +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 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 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 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 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
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
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
nmlgc 59bbe313ad [Decompilation] Add separate types for 1bpp planar pixel lines 2019-12-17 23:26:59 +01:00