Commit Graph

280 Commits

Author SHA1 Message Date
nmlgc 38eb77c828 [Decompilation] [th04/th05] Bosses: Item drops
Part of P0188, funded by [Anonymous] and nrook.
2022-03-27 01:35:40 +01:00
nmlgc 16254c62e3 [Decompilation] [th04/th05] Text overlay: Stage transitions
Rotating black squares in TH05, and something much more fancy in TH04.

Part of P0186, funded by [Anonymous] and Blue Bolt.
2022-03-27 00:39:00 +01:00
nmlgc 39fd88d728 [Maintenance] [th02/th04/th05] Text overlay: Adopt "playfield TRAM" code
Part of P0186, funded by [Anonymous] and Blue Bolt.
2022-03-27 00:33:51 +01:00
nmlgc bb4a99dd05 [Naming] [th02/th04/th05] Stage clear bonus calculation and rendering
Oh hey, TH02!

Part of P0186, funded by [Anonymous] and Blue Bolt.
2022-03-27 00:33:51 +01:00
nmlgc 2efd1fb29d [Maintenance] Get rid of ReC98.h
… and this mistake.

Part of P0186, funded by [Anonymous] and Blue Bolt.
2022-03-26 20:44:54 +01:00
nmlgc 7211d4deeb [Maintenance] [th02] Get rid of th02.h
… remove the last of the game-specific header files, …

Part of P0186, funded by [Anonymous] and Blue Bolt.
2022-03-26 20:44:54 +01:00
nmlgc f4a73bba3f [Maintenance] Move the ring increment/decrement macros to clamp.hpp
That means we can finally…

Part of P0186, funded by [Anonymous] and Blue Bolt.
2022-03-26 20:44:54 +01:00
nmlgc 1c468eef21 [Maintenance] [th02] Put OP/MAINE globals into a single translation unit
Part of P0186, funded by [Anonymous] and Blue Bolt.
2022-03-26 20:44:42 +01:00
nmlgc 4242480b9a [Maintenance] Move the contents of `music/` subdirectories under `op/`
Making it more obvious that it's Music *Room* code, not BGM code.

Part of P0186, funded by [Anonymous] and Blue Bolt.
2022-03-25 14:10:59 +01:00
nmlgc 9432e0d2bf [Maintenance] Macros: Update to current coding standards
Less fancy token pasting, replacing them with inline functions where
possible, entirely removing unnecessary ones, and fixing smaller
issues here and there.

Part of P0186, funded by [Anonymous] and Blue Bolt.
2022-03-25 14:05:36 +01:00
nmlgc ea54e59f93 [Maintenance] Macros: Avoid references to implicit local variables
If the macro itself is local to a function, these can work in certain
scenarios, but never for global ones.

Part of P0186, funded by [Anonymous] and Blue Bolt.
2022-03-25 14:03:53 +01:00
nmlgc ff3d2cafe4 [Maintenance] Highlight dependencies on pseudoregisters with the `asm` keyword
These make up 41% of all our current inline ASM blocks, and *should*
break on other compilers.

Part of P0183, funded by Yanga and [Anonymous].
2022-02-18 09:36:34 +01:00
nmlgc ba9fe94b42 [Maintenance] Consistently use { brackets } for inline assembly
Part of P0183, funded by Yanga and [Anonymous].
2022-02-18 09:36:34 +01:00
nmlgc 6058395372 [Maintenance] Change the inline assembly keyword to `_asm`
The single underscore version is actually slightly more supported among
the compilers I've seen so far. Also added the exact list now.

Part of P0183, funded by Yanga and [Anonymous].
2022-02-18 09:36:34 +01:00
nmlgc 9ec31feef6 [Maintenance] Replace unnecessary inline assembly with pseudo-registers
Part of P0183, funded by Yanga and [Anonymous].
2022-02-18 09:36:34 +01:00
nmlgc efff8d61bb [Maintenance] Change line endings in old C/C++ files to LF
Yup, even a DOS compiler from 1994 considered CRLF line endings as
stupid.

Part of P0172, funded by [Anonymous] and Blue Bolt.
2021-12-27 01:06:32 +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 99aee2bdbe [Maintenance] Consistently use singular for entity structure and file names
Not too sure about "chars" yet, with TH03 and all.

Part of P0168, funded by Blue Bolt and rosenrose.
2021-11-28 19:14:02 +01:00
nmlgc a317cb49fc [Maintenance] Fix another bunch of accumulated typos
Part of P0161, funded by [Anonymous].
2021-10-09 23:26:02 +02:00
nmlgc 403fbcc37f [Maintenance] Remove `extern "C"` from more areas of decompiled code
Most notably from `th01/core/str_val`, where it's really in the way.
That mistake will haunt me until this all is done, probably…

Part of P0158, funded by Yanga.
2021-09-28 18:05:24 +02:00
nmlgc e07624a7be [Maintenance] [th01] Start a new header for clamping macros
Part of P0158, funded by Yanga.
2021-09-28 18:05:24 +02:00
nmlgc 4d24ca53bd [Decompilation] [th04/th05] Bullets: Update function
… (24 + (difficulty * 8) + rank) in TH04, and (42 + (difficulty * 8))
in TH05. Also, TH05 only doesn't have TH04's bullet zap animation
because ZUN didn't consistently use constants…

Completes P0151, funded by Blue Bolt and -Tom-.
2021-07-31 20:19:33 +02:00
nmlgc d876eeb7bd [Decompilation] [th04] Bullets: Clipping and pre-spawn hit test
First place to confirm the hitbox of both the 8×8 pellets and the 16×16
sprite bullets!

Well, "hitbox". It's really more of a kill delta of 8×8 pixels between
the center points of a bullet and the player. You can distribute these
pixels to any combination of bullet and player "hitboxes" that make up
8×8. 4×4 around both the player and bullets? 1×1 for bullets, and 8×8
for the player? All equally valid… or perhaps none of them, once you
keep in mind that other entity types might have different kill deltas,
which turns the concept of a "hitbox" into just a confusing abstraction.

Part of P0150, funded by Blue Bolt.
2021-07-31 20:19:26 +02:00
nmlgc 48c67d5e14 [Decompilation] [th04/th05] Common transformations from playfield space to VRAM
… quite some readability improvements in this regard.

Part of P0149, funded by Blue Bolt, Ember2528, and -Tom-.
2021-07-31 09:33:50 +02:00
nmlgc db05bffca3 [Maintenance] Turn motion_t into a template
motion_t is also used for certain animations in MAINE.EXE, so not all
instances refer to entities in playfield space. Explicitly specifying
the latter now allows us to gain…

Part of P0149, funded by Blue Bolt, Ember2528, and -Tom-.
2021-07-31 09:33:50 +02:00
nmlgc a99cda80fd [Maintenance] Point out that player_invincible_via_bomb is exclusive to TH02
Will make it easier to comprehend that the bullet update function is
actually correct with regards to only looking at a single variable.
(Yes, I know, hard to believe!)

Part of P0149, funded by Blue Bolt, Ember2528, and -Tom-.
2021-07-31 09:33:49 +02:00
nmlgc 53920309a1 [Decompilation] [th05] snd_kaja_interrupt()
Boom! Decompilable after all. And look what that made us finally point
out: In all 4 games that use this function, its return value is
undefined if BGM is inactive. (That is, if the user disabled it, or if
no FM sound board is installed.)

Part of P0148, funded by [Anonymous].
2021-07-21 00:35:03 +02:00
nmlgc f3d59bc324 [Decompilation] [th04/th05] Applying VRAM scrolling to Y coordinates (segment 3)
… Wait, we *can* decompile functions with both parameters, no stack
frame, and a Pascal calling convention?! Good that I already forgot how
impossible it was to decompile the first function I looked at that fell
into this category!

Part of P0148, funded by [Anonymous].
2021-07-21 00:35:02 +02:00
nmlgc 8671340481 [Decompilation] [th04/th05] Gather circle rendering
Part of P0148, funded by [Anonymous].
2021-07-21 00:35:02 +02:00
nmlgc 3a41604314 [Decompilation] [th04/th05] Text popups
The bullet update function really needs this one declared in C land to
link without a fixup overflow? Guess we'll have another technical debt
push before then…

Part of P0148, funded by [Anonymous].
2021-07-20 23:35:46 +02:00
nmlgc ebbb5b8255 [Maintenance] Move tile-related files to their own subdirectory
The next commit will make clear that tile functionality is not a subset
of the non-boss stage code.

Part of P0147, funded by -Tom- and Ember2528.
2021-06-20 19:37:20 +02:00
nmlgc 8426f3e13f [Maintenance] Make the playfield fraction functions available to ≥TH02
Part of P0146, funded by -Tom- and Ember2528.
2021-06-09 23:10:01 +02:00
nmlgc 3e2104a164 [Maintenance] [th02] Move the packfile name constant to th02/shiftjis/
Now you can grep for it¹!

¹ Editor that's actually smart enough to not only correctly detect
  Shift-JIS during grepping, but also match the characters in a search
  regardless of file encoding, sold separately

Part of P0141, funded by [Anonymous] and rosenrose.
2021-05-27 19:35:02 +02:00
nmlgc 241b61e808 [Maintenance] Distinguish between Shift-JIS and gaiji strings
The main point of the previous strings/ subdirectory was to bundle all
hardcoded strings for translators. And sure, *technically*, gaiji
strings are *both* strings *and* something you might want to translate.
But mainly, they're sprites with an attached enum, and their own
directory. Changes to the enum quickly tend to involve changes to the
strings that use these values, so it makes sense to keep both in the
same directory.

Especially since 82% of the previous strings/ directories consisted of
such gaiji strings.

That leaves the strings/ directory rather empty and nondescript though.
Recently though, I've been wanting to generally move all Shift-JIS text
to this directory. While that wouldn't *solve* the typical "text editor
accidentally a file upon save, due to wrongly detected encoding" issue,
it's at least a mitigation: If all Shift-JIS strings are in files that
contain nothing *but* Shift-JIS strings, a wrongly detected encoding
becomes immediately noticeable.

For that job, strings/ can have a more descriptive name though. Hence,
shiftjis/.

Part of P0141, funded by [Anonymous] and rosenrose.
2021-05-27 19:10:26 +02:00
nmlgc 68d9419e8e [Maintenance] [th02] Remove ranks_center[data].asm
Part of P0141, funded by [Anonymous] and rosenrose.
2021-05-27 19:08:57 +02:00
nmlgc d9858113d8 [Decompilation] [th04] snd_load()
Last one! Done with the SHARED segment for the forseeable future! 🎉

Sure, not the best C++ code either, but still by far the sanest
implementation of this function in any of the 4 games.

Completes P0139, funded by [Anonymous].
2021-05-12 14:31:03 +02:00
nmlgc cd96b039fa [Maintenance] Use a dedicated enum for snd_load()'s function parameter
It's not a kaja_func_t if it's shifted left by 8 bits. Why is it
shifted left by 8 bits to begin with, though? Why not just pass a
kaja_func_t, and assign it to AH? Arrrrgh.

Part of P0139, funded by [Anonymous].
2021-05-12 14:31:02 +02:00
nmlgc 46a1674250 [Reverse-engineering] [th02/th03/th04/th05] snd_load() buffer size
Hardcoding these *might* have been acceptable if the numbers actually
matched the sizes defined in GAME.BAT, but they don't. With PMD's
AH=22h function, there's really no excuse though.
About time I looked into this, and expressed that constant as an inline
function that can easily be replaced with a proper implementation.

Part of P0139, funded by [Anonymous].
2021-05-12 14:31:00 +02:00
nmlgc 62e0167e20 [Translation unit catch-up] [th03/th04/th05] snd_delay_until_measure(), game_exit_to_dos()
Segment alignment issues once again… but that completes the SHARED
segments of all TH03 and TH05 binaries, for now!

Part of P0139, funded by [Anonymous].
2021-05-11 18:48:00 +02:00
nmlgc 14cb1d3665 [Maintenance] Document relevant return values of PMD's AH=09h function
I'll leave a comprehensive, fully documented enum to interested
contributors, since that would involve research into basically the
entire history of the PC-9800 series, and even the clearly out-of-scope
PC-88VA. After all, PC-98 Touhou only needs to distinguish "OPN- /
PC-9801-26K-compatible sound sources handled by PMD.COM" from
"everything else", since all other PMD varieties are OPNA- /
PC-9801-86-compatible.

Part of P0139, funded by [Anonymous].
2021-05-11 18:47:58 +02:00
nmlgc 7761f4e804 [Decompilation] [th04] snd_kaja_interrupt()
4 games, 4 different versions of this function. Interestingly,
moving the game-specific differences to inline functions makes it
obvious that this function was only intended for BGM, not sound
effects.

Part of P0139, funded by [Anonymous].
2021-05-11 18:47:57 +02:00
nmlgc 4c0e76ab89 [Decompilation] [th04/th05] snd_mmd_resident()
Part of P0139, funded by [Anonymous].
2021-05-11 18:47:57 +02:00
nmlgc acd29854c7 [Decompilation] KAJA driver ISR magic check
Down to one inline ASM instruction for these.

Part of P0139, funded by [Anonymous].
2021-05-11 18:47:55 +02:00
nmlgc 864e8643ab [Decompilation] [th04] .MPN: Load function
Basically just a copy of the TH02 one, adjusted to work with multiple
slots.

Completes P0138, funded by [Anonymous] and Blue Bolt.
2021-04-22 19:27:48 +02:00
nmlgc b1cf7ee021 [Maintenance] [th02] .MPN: Update existing decompilations to current standards
Part of P0138, funded by [Anonymous] and Blue Bolt.
2021-04-22 19:25:01 +02:00
nmlgc f635948480 [Naming] .MPN: Rename mptn_* to mpn_*
We've been using the three-letter extension names for everything else
that isn't .DAT, so it's more consistent to do the same for .MPN,
however particularly nice and readable its FOURCC may be. 8.3 filenames
also really appreciate that they'll have to accommodate one fewer
letter.

Part of P0138, funded by [Anonymous] and Blue Bolt.
2021-04-22 19:16:18 +02:00
nmlgc 9739f69729 [Maintenance] Add a 1bpp rectangle template, for custom per-row types
This gets rid of a couple of per-entity sprite bitplane types, makes
sprite declarations easier to read by putting width and height next to
each other… and points out a number of array dimension mistakes -.-
Even in places where we can't use it.

Part of P0138, funded by [Anonymous] and Blue Bolt.
2021-04-21 18:01:57 +02:00
nmlgc e1d5bdafed [Maintenance] master.hpp: Type-safe hmem_allocbyte() and hmem_free() wrappers
Sure, we can't use them everywhere, but it's really nice to get rid of
that casting madness – and any explicit references to x86 memory
segmentation – wherever we can.

Part of P0138, funded by [Anonymous] and Blue Bolt.
2021-04-21 17:50:12 +02:00
nmlgc 78b958f111 [Separate translation units] [th02] key_delay()
Part of P0138, funded by [Anonymous] and Blue Bolt.
2021-04-21 17:50:04 +02:00
nmlgc 04038449c1 [Translation unit catch-up] [th04] frame_delay() / .PI display and loading
Segment alignment forces us to do all of those at once… but now, we've
not only caught up with the segment split point in TH04's OP.EXE and
MAINE.EXE, but also decompiled all instances of DEFCONV functions!

Part of P0138, funded by [Anonymous] and Blue Bolt.
2021-04-21 17:44:15 +02:00