Commit Graph

67 Commits

Author SHA1 Message Date
nmlgc 607200d0ed [Maintenance] Move the space-changing point union to a separate header
Yup, there's more! About time we started a general coordinate header
that will ultimately be independent of `pc98.h`.

Part of P0264, funded by [Anonymous] and Blue Bolt.
2024-02-02 23:52:26 +01:00
nmlgc 8943b52167 [Maintenance] Introduce types for VRAM colors and their components
Finally differentiating between colors and columns at least at the type
level.

Part of P0245, funded by [Anonymous], Blue Bolt, Ember2528, and Yanga.
2023-06-30 19:59:11 +02:00
nmlgc 51b2df231a [Maintenance] Remove `extern "C"` from vector header inclusions
Part of P0244, funded by Blue Bolt and [Anonymous].
2023-06-10 18:32:25 +02:00
nmlgc 9aad9ad114 [Maintenance] Declare 8-bit pixel delta and length types
Part of P0242, funded by Yanga.
2023-06-06 21:02:47 +02:00
nmlgc 5303c37de2 [Maintenance] [th04/th05] Custom entities: Move declarations to TH04
Part of P0240, funded by JonathKane.
2023-05-25 15:11:50 +02:00
nmlgc 45c9e71533 [Maintenance] Fix another bunch of accumulated typos and dead code
Part of P0239, funded by Ember2528.
2023-04-28 22:21:21 +02:00
nmlgc 1f962c865e [Maintenance] Introduce a generic entity flag enum
Part of P0236, funded by Yanga.
2023-03-29 12:36:55 +02:00
nmlgc c6e2955e06 [Maintenance] Declare missing entity-specific flags in ASM land
Part of P0236, funded by Yanga.
2023-03-29 12:36:55 +02:00
nmlgc 49a6834c4a [Maintenance] Move OUT for 8-bit port numbers to x86real.h
We'd like to use this optimization in the platform layer as well.
Turning it into an inline function via __emit__() also allows us to
turn a bunch of other macros into proper inline functions.

Part of P0232, funded by [Anonymous].
2023-02-28 08:08:17 +01:00
nmlgc c22299e0c8 [Contributing] Introduce a new "ZUN landmine" label for invisible bugs
Thanks to Clerish for the naming inspiration:

	https://twitter.com/Clerish/status/1623990678937034752

Part of P0231, funded by [Anonymous].
2023-02-28 08:08:10 +01:00
nmlgc 739e1d8ccd [Decompilation] [th05] Lasers: High-level rendering
And that's it, TH05 lasers finalized!

Completes P0228, funded by [Anonymous] and nrook.
2023-01-17 12:19:32 +01:00
nmlgc 034a7db98c [Decompilation] [th05] Lasers: Update function
In which the shrink types """conveniently""" use a signed comparison
that effectively limits their width to 127 pixels, which forces a
shrink/nonshrink distinction upon the entire rest of the code. 🙄

Part of P0228, funded by [Anonymous] and nrook.
2023-01-17 12:16:49 +01:00
nmlgc c8997cd500 [Maintenance] [th05] Lasers: Prepare for two segments in one translation unit
Part of P0228, funded by [Anonymous] and nrook.
2023-01-17 12:10:52 +01:00
nmlgc bb42f673e9 [Decompilation] [th05] Lasers: Collision detection
Started out with the usual amount of decompilation workarounds for this
low-level laser code, but ended up requiring one on almost every line
just because ZUN reversed the function prolog… 🙄

Part of P0228, funded by [Anonymous] and nrook.
2023-01-17 11:58:17 +01:00
nmlgc 15a047fc74 [Decompilation] [th05] Lasers: Ray rendering
A year ago, I would have considered this undecompilable. Turns out that
this function really benefitted from a decompilation against all odds,
especially with these 4 different views on the same 8 local variables.

Part of P0228, funded by [Anonymous] and nrook.
2023-01-17 11:53:47 +01:00
nmlgc b989076579 [Decompilation] [th05] Lasers: Line construction
Part of P0228, funded by [Anonymous] and nrook.
2023-01-17 11:47:01 +01:00
nmlgc ee58546025 [Decompilation] [th05] Lasers: 2D vector construction
More custom code generation!

Part of P0228, funded by [Anonymous] and nrook.
2023-01-17 11:46:25 +01:00
nmlgc 40b66c46eb [Maintenance] [th05] Bullets: Rearrange comments for circular group types
VS Code doesn't seem to properly syntax-highlight C-style comments that
start on a #define line and end in the line below. But even apart from
that, this rearrangement ensures that IntelliSense correctly assigns
both lines to BGCC_SPREAD as I intended it.

Part of P0227, funded by nrook.
2023-01-17 10:35:57 +01:00
nmlgc 2458172c98 [Maintenance] [th02/th03/th04/th05] Define a constant for a white VRAM color
Part of P0223, funded by Blue Bolt and rosenrose.
2022-11-30 17:00:42 +01:00
nmlgc 650c1e3364 [Maintenance] Review any redundancies and label them as ZUN bloat
Or quirk, in the case of the slow TH01 ending picture blitting.

Part of P0216, funded by JonathKane.
2022-08-16 01:43:14 +02:00
nmlgc a10fe95b31 [Maintenance] Fix comment↔code associations
• Comments that describe all lines of code until a blank one are placed
  into the lines immediately above
• Comments that describe an entire demarcated block are placed
  immediately below the dash row at the top
• In any case, there should be a blank line after the top comment of
  a demarcated block, to keep IntelliSense-style systems from applying
  the block comment to the first actual line of code…
• …but there shouldn't be one before the dash row at the bottom, where
  it'd be redundant.

Part of P0207, funded by GhostPhanom.
2022-08-08 20:10:53 +02:00
nmlgc 456768a4ff [Contributing] Define `struct`, `class` and `template` naming conventions
Again, these are what I've been mostly following, apart from a few
inconsistencies which this commit also fixes.

Part of P0207, funded by GhostPhanom.
2022-08-08 20:10:38 +02:00
nmlgc 0c682b5bc0 [Maintenance] Declare the optimization_barrier() a single time
And put that single instance into the compiler optimization workaround
section of `decomp.hpp`.

Part of P0204, funded by [Anonymous].
2022-07-10 13:45:18 +02:00
nmlgc 3e79deeb3a [Contributing] Define function brace placement rules
I've been following them pretty consistently for a while now, time to
finally write them down.

Part of P0204, funded by [Anonymous] and Yanga.
2022-07-10 13:45:18 +02:00
nmlgc 6f2881f056 [Maintenance] Remove `extern "C"` from more areas of code
The .PTN functions, vector functions, and egc_copy_rect_1_to_0_1()
(finally!) from TH01, as well as playfld.hpp from all games(finally!),
together with a bunch of other functions in their vicinity.

Part of P0201, funded by Ember2528 and Yanga.
2022-06-24 23:28:19 +02:00
nmlgc 8fce97ea1c [Maintenance] Add a static_assert() polyfill to platform.h
Part of P0198, funded by Lmocinemod and Ember2528.
2022-06-16 22:50:31 +02:00
nmlgc 04de2fddd9 [Decompilation] [th05] Bullets: Sprite selection by angle
And we're right back to dumb micro-optimizations.

Part of P0192, funded by [Anonymous], nrook, and -Tom-.
2022-05-01 00:22:04 +02:00
nmlgc 852f2dd176 [Maintenance] [th04/th05] Drop the `_seg1` suffix from the GRCG functions
It's the `_seg3` variants that are the anomaly here.

Part of P0192, funded by [Anonymous], nrook, and -Tom-.
2022-05-01 00:22:03 +02:00
nmlgc 71cb7b5e93 [Decompilation] [th05] Shinki: Main function
3rd PC-98 Touhou boss completely decompiled, 28 to go… and the code
quality is taking a nosedive again, especially with that unnecessary
"relative phase" variable that collides with the laser activation flag
in the Devil pattern.
(The nearfunc_t_near workarounds are our fault, though!)

Completes P0191, funded by nrook.
2022-05-01 00:22:03 +02:00
nmlgc 9ef178431a [Maintenance] [th05] Shinki: #include 32×32 ball code from the boss script
We won't get that one padding byte in front of the shinki_update()
switch table otherwise.

Part of P0191, funded by nrook.
2022-05-01 00:22:03 +02:00
nmlgc 37fac9a2a0 [Maintenance] [th05] Custom entities: Introduce separate template structures
Since the game uses global state to define its patterns, we'd really
like to see immediately which of the structure fields are relevant for
spawning bullets. This makes it easier to spot which of the patterns
rely on fields set in previous patterns – and there are several that
do.

Part of P0190, funded by nrook.
2022-05-01 00:22:02 +02:00
nmlgc c963e2a1e4 [Maintenance] [th04/th05] Bullets: Move pellet rendering to its own header
Removes an unneeded transitive dependency on planar.h from all but one
translation unit.

Part of P0190, funded by nrook.
2022-04-30 14:37:46 +02:00
nmlgc 63091686e2 [Maintenance] [th04/th05] Remove `extern "C"` from more areas of code
hud_hp_put(), hud_hp_update_and_render(), player_angle_from(),
select_for_playchar(), and the midboss functions.

Part of P0190, funded by nrook.
2022-04-30 14:37:28 +02:00
nmlgc 306a504ef5 [Naming] [th05] Officially rename "curve bullets" to "cheetos"
Short, sweet, fits more nicely into 8.3 filenames than "curve bullets"
does, and 76.7% of fans agree:

	https://twitter.com/ReC98Project/status/1500256959785746434

OMAKE.TXT calls them "homing lasers", but… eh, nah.

Part of P0190, funded by nrook.
2022-04-29 03:28:44 +02:00
nmlgc e881f95ce1 [Decompilation] [th05] Shinki's 32×32 balls: Update function
Completes P0188, funded by [Anonymous] and nrook.
2022-03-27 01:50:07 +01:00
nmlgc adffa1ccf9 [Decompilation] [th05] Shinki's 32×32 balls: Spawn function
Wait, wouldn't it be cool if we could keep the render, spawn, and
update functions in the same translation unit, by switching code
segments in the middle of the file? Let's hope this works out, and give
the source file an all-encompassing generic name.

Part of P0188, funded by [Anonymous] and nrook.
2022-03-27 01:50:07 +01:00
nmlgc 83ff3c9ec9 [Maintenance] [th04/th05] Bullets: Move clear/zap declarations to new header
Part of P0188, funded by [Anonymous] and nrook.
2022-03-27 01:29:03 +01:00
nmlgc a907feacf8 [Decompilation] [th05] Lasers: Spawn and control functions
Part of P0185, funded by [Anonymous], -Tom-, and Blue Bolt.
2022-03-05 17:50:27 +01:00
nmlgc 360e07a413 [Maintenance] Add a new typedef for unsigned Q4.4 values
Part of P0185, funded by [Anonymous], -Tom-, and Blue Bolt.
2022-03-05 15:31:50 +01:00
nmlgc 3850f8aafb [Maintenance] [th05] Declare laser symbols in C land, using current conventions
Oh hey, these 2018 variable names weren't completely bad!

Part of P0185, funded by [Anonymous], -Tom-, and Blue Bolt.
2022-03-05 15:31:50 +01:00
nmlgc 96ed07f31e [Maintenance] [th05] Move laser-related code to the `main/bullets` subdirectory
Following the choice I made for TH01.

Part of P0185, funded by [Anonymous], -Tom-, and Blue Bolt.
2022-03-05 15:31:50 +01:00
nmlgc c63e05ed2d [Decompilation] [th05] Curved bullets: Spawn function
Part of P0185, funded by [Anonymous], -Tom-, and Blue Bolt.
2022-03-05 15:31:50 +01:00
nmlgc 944654596d [Decompilation] [th05] Curved bullets: Update function
The algorithm for gradually rotating these clockwise or counterclockwise
towards the player could have been 5 lines long. ZUN blows it up to 26
lines.

Also, a 16×16 killbox for the head node, and a 12×12 one for trail
nodes.

Part of P0185, funded by [Anonymous], -Tom-, and Blue Bolt.
2022-03-05 15:31:50 +01:00
nmlgc 07b956b3ad [Maintenance] [th04/th05] Move bullet code into dedicated segments
Too bad that alignment constraints do in fact force us to compile
th04/bullet_u.cpp and th04/bullet_a.cpp separately. 😕

Part of P0184, funded by -Tom-.
2022-03-05 15:31:50 +01:00
nmlgc 9471e133e9 [Decompilation] [th05] Bullets: Sprite selection for angled bullets
Hopelessly hardcoded.

Part of P0184, funded by -Tom-.
2022-03-05 15:31:50 +01:00
nmlgc 5fac2006ff [Maintenance] Consistently use "score" instead of "points"
Or at least in addition.

Part of P0172, funded by [Anonymous] and Blue Bolt.
2021-12-27 00:50:39 +01:00
nmlgc 101684c235 [Separate translation units] [th05] Rank-based speed tuning
Also not worth decompiling, because:
• It would break return value semantics
• The algorithm is identical to TH04 (except for that one divisor)
• Small function
• Next to a bunch of more critical, undecompiled functions
• Decompilation would be messy anyway

Part of P0152, funded by -Tom- and [Anonymous].
2021-07-31 21:09:37 +02:00
nmlgc 18d4aa43f8 [Reverse-engineering] [th05] Bullets: Spawn wrappers
And that's it! Finally RE'd every bullet spawning function in TH04 and
TH05! 🎉
These really aren't worth adding a translation unit for either, in the
end. Not least because they decide to keep bullet_template.speed from
being mutated via PUSH and POP, which we can only express via inline
assembly in C land.

Part of P0152, funded by -Tom- and [Anonymous].
2021-07-31 21:09:36 +02:00
nmlgc 6127ca0ec1 [Reverse-engineering] [th05] Bullets: Velocity and angle calculation (undecompilable)
Reason: That switch statement. How should we even?

Well, the code *is* fairly good. After looking very deep into it, and
spending 35% of that function on blank lines (for logical grouping) and
explanatory comments, that is…

Part of P0152, funded by -Tom- and [Anonymous].
2021-07-31 21:09:36 +02:00
nmlgc 4d3a1eace8 [Decompilation] [th05] Bullets: Clipping and pre-spawn hit test
Deciding whether to decompile this one or not seemed to be a tough
choice. Should we *really* introduce two more translation units just
for the sake of decompiling another function that's identical to its
TH04 counterpart anyway?
Well, turns out it actually isn't: TH05 does in fact *not* immediately
clip bullets that are spawned on top of the player. Which might sound
like it has a notably different effect on gameplay… except that it
doesn't.
So yeah, good we've decompiled it, and got to show that more clearly.

Part of P0152, funded by -Tom- and [Anonymous].
2021-07-31 21:09:30 +02:00