Commit Graph

119 Commits

Author SHA1 Message Date
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
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 2a722db215 [Reverse-engineering] [th05] Music Room piano functions
No need to declare most of these in C land if 1) it isn't even clear
yet whether we can even decompile these functions with their 2)
complex __usercall conventions, which 3) aren't even called from
outside this slice. --Nmlgc
2019-12-17 23:26:56 +01:00
wintiger0222 53f316792f [Reverse-engineering] [th05] Music Room piano sprite data 2019-12-17 23:26:56 +01:00
wintiger0222 b25ec3d138 [Reverse-engineering] [th05] PMD work area and piano note data
Good job identifying what is bascially the QQ structure from PMDWin!
--Nmlgc
2019-12-17 23:26:55 +01:00
wintiger0222 2b617dfa75 [Reverse-engineering] [th05] Music Room piano coordinates 2019-12-17 23:26:55 +01:00
wintiger0222 b74b7f9bce [Reverse-engineering] [th05] Music Room piano label font 2019-12-17 23:26:55 +01:00
wintiger0222 811ba84e3f [Reverse-engineering] [th03/th04/th05] snd_delay_until_measure 2019-12-17 22:44:27 +01:00
wintiger0222 e8c9876bef [Reverse-engineering] [th05] Current BGM measure
Split off from the delay function in this game, since the ending syncs
a bunch of things independent from any frame delays. -Nmlgc
2019-12-17 22:44:23 +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 5bffab4f43 [Position independence] [th04/th05] Remaining references to PI slots
Part of P0060, funded by Touhou Patch Center.
2019-11-28 23:23:30 +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 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 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