Commit Graph

27 Commits

Author SHA1 Message Date
nmlgc 38f17af25d [Reverse-engineering] [th04/th05] Micro-optimized 32×32 sprite display
Which *looks* like a master.lib function, but only because ZUN adapted
his own micro-optimized super_roll_put_tiny() for 32×32. Good thing we
covered that one first!

Part of P0073, funded by [Anonymous] and -Tom-.
2020-02-16 21:38:38 +01:00
nmlgc e4f1718e93 [Maintenance] [th04/th05] Improve the z_super_roll_put*() naming convention
So, master.lib has:
• super_put_tiny() for tiny-format 16×n sprites
• super_roll_put_tiny() for vertically wrapped tiny-format 16×16
  sprites
• super_put_tiny_small() for tiny-format 8×n sprites
• yet *no* super_roll_put_tiny_small() function

And now we have ZUN adding micro-optimized versions of:
1) vertically-wrapped tiny-format 16×16, clearly based on master.lib's
   super_roll_put_tiny(), RE'd in 35f9bd7
2) vertically-wrapped tiny-format 32×32
3) vertically-wrapped non-tiny monochrome 16×16 (TH05 only)

Conclusion: Even though 1) does duplicate a master.lib function, trying
to continue following master.lib's inconsistent naming convention only
leads to more confusion here. master.lib also already designates the _8
suffix to mean "x will be byte-aligned, ⌊x/8⌋*8"…
So let's:
• spell out both coordinates of the sprite size directly in the
  function
• keep the z_ prefix to encode ZUN's optimized calling convention
  (left/top coordinates in registers, ES already set to the beginning
  of a VRAM plane, GRCG already on) for all of these, not just 1).
• and prefix the actual functions with _raw, since C land will want
  to handle the coordinate parameter registers in a macro.

Part of P0073, funded by [Anonymous] and -Tom-.
2020-02-16 21:36:56 +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 c3a9816e60 [Maintenance] [th04/th05] Declare a little-endian BCD score type
Only in C land though; doing the same in ASM land actually makes digit
accesses harder to read.

Part of P0065, funded by Touhou Patch Center.
2020-01-03 21:33:30 +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 7b8b059ee7 [Reverse-engineering] [th04] Game clear variables
Part of P0064, funded by Touhou Patch Center.
2019-12-29 21:15:40 +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
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 b0c2122eec [Decompilation] [th05] Stage-related .BB file loading boilerplate
Yay for alignment, allowing us once again to only move unrelated
variable declarations over to C…

Part of P0031, funded by zorg.
2019-09-21 12:59:22 +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 e10502bfe6 [Maintenance] Fix the function name format of CDG/CD2 functions
No leading underscore for functions with Pascal calling convention, but
we do have one for all variables, because it's not worth it to put
keywords in front of everything for no reason.
Seemed to have forgotten this rule in 2017?

Part of P0030, funded by zorg.
2019-09-15 20:29:40 +02:00
nmlgc 062e775f41 [Reverse-engineering] [th04/th05] .BB file loading boilerplate
Yup, nothing interesting in here.
Except for maybe the confirmation that LS00.BB is used for the curved
bullets used by Shinki and EX-Alice?

Funded by -Tom-.
2019-03-01 16:17:52 +01:00
nmlgc 9a2c6f72ba [Reverse-engineering] [th04/th05] Second, unused field of the .map header
Thanks to -Tom- for telling me what this obviously had to be.
2019-01-11 00:28:56 +01:00
nmlgc 35f9bd71e8 [Reduction] [th04/th05] Micro-optimized version of super_roll_put_tiny()
Y'know, maybe ZUN measured and all of this actually mattered? What do I
know?

Funded by -Tom-.
2018-12-31 20:41:13 +01:00
nmlgc 612beb815b [Maintenance] Clean up the confusion between "tiles" and .STD tile sections
Funded by -Tom-.
2018-12-30 02:30:16 +01:00
nmlgc 4fe4c8eed1 [Reverse-engineering] [th04/th05] Scrolling-related variables
Funded by -Tom-.
2018-12-29 18:34:51 +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 261d5037ed [Reverse-engineering] [th04/th05] .STD file loading
… because TH04's version of this takes the ASCII stage ID directly from
the resident structure.

So boss battles are simply triggered by setting the background tile
scroll speed to 0? That means…

Funded by zorg.
2018-12-26 17:59:03 +01:00
nmlgc 766a34d044 [Reverse-engineering] [th04/maine] Single-plane CDG display
Only used in the staff roll.

Funded by DTM.
2018-10-16 01:04:46 +02:00
nmlgc fc8d51c7d7 [Reverse-engineering] [th04/th05] Non-color CDG display 2018-10-16 01:04:46 +02:00
nmlgc aa47bb33d9 [Reverse-engineering] [th04/th05] Non-alpha CDG display 2018-10-16 01:04:46 +02:00
nmlgc bfef793805 [Reverse-engineering] [th04/th05] Normal CDG display
In which the th05 difference is the lack of self-modifying code.
2018-10-16 01:04:46 +02:00
nmlgc 286c6431d8 [Reverse-engineering] [th04/th05] CDG loading 2018-10-16 01:04:46 +02:00
nmlgc f98fba3c9d [Reverse-engineering] [th02/th04/th05] .map file loading
Funded by -Tom-.
2018-03-16 08:02:14 +01:00