Commit Graph

887 Commits

Author SHA1 Message Date
nmlgc dea40ad770 [Decompilation] [th05] Stage setup
"Yeah, let's do this real quick, how can this possibly be hard, it's
just MOVs and a few function calls"…

…except that these MOVs access quite a lot of data, which we now all
have to declare in the C world, hooray.
Once it came to midbosses and bosses, I just turned them into C structs
after all. Despite what I said in 260edd8… after all, the ASM world
doesn't care about the representation in the C world, so they don't
necessarily have to be the same.

Since these structs can't contain everything related to midbosses and
bosses (really, why did all those variables have to be spread out like
this, ZUN?), it also made for a nice occasion to continue the "stuff"
naming scheme, describing "an obviously incomplete collection of
variables related to a thing", first seen in 160d4eb.

Also, PROCDESC apparently is the only syntactically correct option to
declare an extern near proc?

Also, that `boss_phase_timed_out` variable only needs to be here
already because TCC enforces word alignment for the .data segment…
yeah, it's technically not related to this commit, but why waste time
working around it if we can just include that one variable.

Completes P0030, funded by zorg.
2019-09-15 20:35:15 +02:00
nmlgc 9d121c7cce [Decompilation] [th04/th05] Handle subpixels at the C++ type level
I've had the idea to hide this implementation detail and improve code
readability for some time now, but it obviously must still all inline,
to be indistinguishable from a direct assignment of the correct value…

… which, amazingly, it does! Even the static_cast from float to int.
The latter allows us to exclusively implement this for float, since we
do have to express the occasional value smaller than 16.

Who needs macros anyway. Yay, C++ in TH04 and TH05 after all!

Part of P0030, funded by zorg.
2019-09-15 20:30:35 +02:00
nmlgc 0abf84f450 [Maintenance] Add a few missing exports
Part of P0030, funded by zorg.
2019-09-15 20:29:52 +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 ac2117040c [Decompilation] Define generic function pointer types
Going with the classic pointer-in-typedef approach here, because the
syntax you'd otherwise have to use is terribly inconsistent. It'd be

	 farfunc_t *near near_ptr_to_far_func;

but

	nearfunc_t near *near_ptr_to_near_func;

And that'd hopefully be the last change to ReC98.h for a long time!
Those glacial compile times if every .c file is affected… Really
stands out if your build system is otherwise perfect.

Part of P0030, funded by zorg.
2019-09-15 20:29:32 +02:00
nmlgc c7fc4ca41d [Decompilation] [th05] Committing the score delta
Completes P0029, funded by zorg.
2019-09-15 20:29:09 +02:00
nmlgc 2fb2a65ea8 [Maintenance] Rename the score update/render function
Slightly different in TH04 and TH05, and the TH05 version will be
decompiled in the next push… yeah, not going to worry all too much
about this one right now.

Part of P0029, funded by zorg.
2019-09-15 20:26:38 +02:00
nmlgc 4d7261c5d3 [Reverse-engineering] [th02/th04/th05] (Mid-)Boss update/render function names
Numbers for midbosses, names for bosses, as previous commits already
implied.

Part of P0029, funded by zorg.
2019-09-15 20:26:32 +02:00
nmlgc 789c910c88 [Reverse-engineering] [th04/th05] Playfield fill-around function names
These are used from quite a few places, so it seems best to just name
them after the rect on the playfield they leave out, which is then
typically where the background picture goes.

…*except* that in doing this, we quickly run up against the symbol
length limit of 32 characters. TASM can expand it via the /mv option,
but TCC only lets you *reduce* it to even less. (Why?)
So, my initial idea of `playfield_fill_around_(x)_(y)_(w)_(h)` wouldn't
have worked. But those coordinates are kinda important, I'd say…
Well then, let's just go with `fillm` instead of `fill_around` then.
"Fill with mask at the given coordinates"… yeah, that would work.

Part of P0029, funded by zorg.
2019-09-15 20:26:21 +02:00
nmlgc 6ff427aa0a [Reverse-engineering] [th04/th05] Remaining generic boss variables
… yeah, I don't really like these ambiguous "mode" and "mode change"
variable names either, but what's the alternative? Something something
"sub-phase", to distinguish them from regular phases? Feels way too
early to decide on something more specific. And pretty much nothing I
could come up with right now would have made their inconsistent use any
clearer.
But I need to decide on *something* before moving on, so… eh, let's
just go with what uth05win chose.

Also, yeah, dealing with those 0xFE and 0xFD boss_phase constants some
other time 😛

Also, today in "Weird TASM crashes": Trailing commas at the end of
`public` lines…

Completes P0028, funded by zorg.
2019-09-11 23:19:10 +02:00
nmlgc 260edd8683 [Reverse-engineering] [th04/th05] Remaining generic midboss variables
Turning these into a struct will be very painful with all the
collisions. Not going to do that until we decompiled every single
reference to those.

Part of P0028, funded by zorg.
2019-09-11 18:27:46 +02:00
nmlgc e1714da563 [Maintenance] Move the midboss function pointer slice into its own directory
Part of P0028, funded by zorg.
2019-09-09 18:40:13 +02:00
nmlgc 6023f5c937 [Maintenance] Fix the case of `nearheap[data].asm`'s path
Previously broke the build on repository checkouts created by WSL git,
which enables per-directory case sensitivity for all directories within
the repo:

	https://devblogs.microsoft.com/commandline/per-directory-case-sensitivity-and-wsl/

Nice that this was the only path case issue in the entire repo!
2019-08-14 20:45:05 +02:00
nmlgc 3ba536a2d8 [Reverse-engineering] [th04/th05] Text popups
As in, "HiScore Entry!!", "Extend!!", "Full PowerUp!!", etc.
Class CFloatingText in uth05win… but I decided against naming it like
that because of some stage/BGM title-related variables in the middle.

Funded by -Tom-.
2019-03-06 19:57:23 +01:00
nmlgc fac879f8e6 [Reverse-engineering] [th05] Number display using the bold gaiji font
Many thanks to http://bytepointer.com/tasm/index.htm for providing a
better searchable resource for TASM's default `LEA imm16` → `MOV imm16`
optimization, which we initially had to hack around here.

Funded by -Tom-.
2019-03-06 19:32:38 +01:00
nmlgc ba3a6f7158 [Reverse-engineering] [th05] Shared HUD gaiji row
Yup, yet another random not really needed global.

Funded by -Tom-.
2019-03-06 18:32:07 +01:00
nmlgc 058595b1d9 [Reverse-engineering] [th04/th05] Score variables
In which ZUN uses little-endian BCD as the exclusive internal storage
for both the current and the high score. Which are then updated using,
once again, ridiculously micro-optimized ASM code that uses the
venerable x86 BCD instructions.

Funded by -Tom-.
2019-03-04 21:42:11 +01:00
nmlgc 308d1bc785 [Reverse-engineering] [th04/th05] Boss explosions
So apparently, this way of distorting a circle into an ellipse (?) by
adding a value to the angle for one of the two coordinates isn't
actually widely known in math and doesn't have a name. Fair enough.

Funded by -Tom-.
2019-03-03 14:03:41 +01:00
nmlgc 1cb2c0acbc [Reverse-engineering] [th03/th04/th05] Palette change flag
Funded by -Tom-.
2019-03-03 13:32:55 +01:00
nmlgc 6ed8e60334 [Reverse-engineering] [th04/th05] Boss phase timeout flag
Funded by -Tom-.
2019-03-01 23:20:52 +01:00
nmlgc b02147b5c0 [Reverse-engineering] [th05] Yumeko's Phase 4/7 knife/laser intervals
Which are set in the regular stage init function for some reason,
which is why I have to cover them right now.

Funded by -Tom-.
2019-03-01 23:20:52 +01:00
nmlgc ae9651c693 [Reverse-engineering] [th04/th05] Difficulty/character-based value selection
Funded by -Tom-.
2019-03-01 23:20:51 +01:00
nmlgc c241af414f [Reverse-engineering] Current difficulty
Funded by -Tom-.
2019-03-01 23:07:42 +01:00
nmlgc 17a05b1b71 [Reverse-engineering] [th05] Secondary boss position and sprite ID
Sure, I like me some global variables too. If you have to temporarily
replace them for a single function call though, it's pretty much the
textbook example of where *not* to use them.

Funded by -Tom-.
2019-03-01 23:07:41 +01:00
nmlgc 08ffcb0737 [Reverse-engineering] [th04/th05] Boss hitboxes
Funded by -Tom-.
2019-03-01 16:18:02 +01: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 893bd46969 [Reverse-engineering] [th04/th05] Stage-specific invalidate/render functions
Used only sparingly, like for the starfield in TH05 Stage 2.

Funded by -Tom-.
2019-02-28 17:56:26 +01:00
nmlgc 5e9aaafb8b [Reverse-engineering] [th05] Shot decay animation after a target is hit
Struct strHIT_CHARA_BULLET in uth05win. Yup, newly introduced in TH05.

Funded by -Tom-.
2019-02-28 17:43:15 +01:00
nmlgc d9e9b38736 [Reverse-engineering] [th04/th05] Spark animation
Also seen when midbosses explode. Class CSparkEffect in uth05win.

Funded by -Tom-.
2019-02-28 17:43:15 +01:00
nmlgc da284cacaf [Reverse-engineering] [th02/th04/th05] Hardcoded spark sprites
As seen when killing stage enemies or grazing.

Funded by -Tom-.
2019-02-28 17:43:15 +01:00
nmlgc 2ea2e0ddf9 [Reverse-engineering] [th05] Player shot animation types
Funded by -Tom-.
2019-02-28 17:43:15 +01:00
nmlgc b9f3d86e44 [Reverse-engineering] [th04/th05] Adding new player shots
Funded by -Tom-.
2019-02-28 17:43:14 +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 deb45ea14e [Reverse-engineering] [th04/th05] Player shot structure
And that's enough for now, see you in February!

Funded by -Tom-.
2019-01-01 02:29:12 +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 e7265ac656 [Reverse-engineering] [th04/th05] Shot X/Y velocity lookup table
Funded by -Tom-.
2018-12-31 19:45:34 +01:00
nmlgc 4770d145d6 [Reverse-engineering] [th04/th05] Target position for homing shots
Funded by -Tom-.
2018-12-30 15:31:26 +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 75763ccd32 [Reverse-engineering] [th04/th05] Invalidating background tiles around a point
…and *now* we can tackle all those entity types that were referencing
this function, with the help of uth05win.

Funded by -Tom-.
2018-12-30 00:19:18 +01:00
nmlgc c2ef9d51b6 [Reverse-engineering] [th02/th03/th04/th05] Back/front page pairs
Because using just one variable would have totally been too
straightforward.

Funded by -Tom-.
2018-12-30 00:16:18 +01:00
nmlgc 35ef90f4d1 [Reduction] Page flipping
Funded by -Tom-.
2018-12-30 00:16:18 +01:00
nmlgc c00b87ed4f [Reverse-engineering] [th04/th05] Redrawing dirty stage background tiles
Funded by -Tom-.
2018-12-30 00:16:16 +01:00
nmlgc bcc1b7518f [Reverse-engineering] [th04/th05] Applying VRAM scrolling to Y coordinates
Funded by -Tom-.
2018-12-29 18:34:51 +01:00
nmlgc dbf1e93a79 [Reverse-engineering] [th02] Current scrolling line
… and that's all that's superficially identical to TH04 and TH05. I lack
the funding to cover more. :P

Funded by -Tom-.
2018-12-29 18:34:51 +01:00
nmlgc 4fe4c8eed1 [Reverse-engineering] [th04/th05] Scrolling-related variables
Funded by -Tom-.
2018-12-29 18:34:51 +01:00
nmlgc 20d05c1653 [Reverse-engineering] [th04/th05] Rendering all stage background tiles at once
Funded by -Tom-.
2018-12-29 18:34:51 +01:00
nmlgc 6a6ce47c56 [Reduction] EGC-powered VRAM region copies
Funded by -Tom-.
2018-12-29 17:03:26 +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 8ee87233b8 [Reverse-engineering] [th02/th05] Player movement speed
Yes, both characters in TH04 have the same speed!

Funded by -Tom-.
2018-12-26 22:07:34 +01:00