Commit Graph

289 Commits

Author SHA1 Message Date
nmlgc a186074af3 [Separate translation units] [th01] .PTN, .GRP, and .GRZ formats
Since I'd still prefer to not use include guards *and* to have that
standalone .GRZ viewer, these would have actually caused somewhat of
an issue with the upcoming final stretch of the master.hpp transition.

Part of P0133, funded by [Anonymous].
2021-01-30 19:17:16 +01:00
nmlgc 0d137ee526 [Maintenance] Move the vram_planes_set() declaration to its own header file
Might seem inconsistent, given that the function initializes pointers
that are declared in planar.h… but it's always called from other game
initialization functions that don't require pc98.h or planar.h.

Part of P0133, funded by [Anonymous].
2021-01-30 19:11:55 +01:00
nmlgc d3a1335e35 [Maintenance] master.hpp transition: Resident palette functions
Final one! Now we only need to get all translation units to use this
header…

Part of P0133, funded by [Anonymous].
2021-01-30 18:51:29 +01:00
nmlgc 27bf06751a [Maintenance] master.hpp transition: Keyboard functions
Part of P0133, funded by [Anonymous].
2021-01-30 18:34:14 +01:00
nmlgc d1f1b7d405 [Maintenance] Move twobyte_t into its own header file
And hope that there won't be any more generic utility types like it…

Part of P0133, funded by [Anonymous].
2021-01-30 18:31:54 +01:00
nmlgc ec8be31cd3 [Maintenance] Move PC-98 keyboard declarations to their own header file
140 lines that are only used in, like, 7 translation units.

Part of P0133, funded by [Anonymous].
2021-01-30 18:26:46 +01:00
nmlgc 3f61342898 [Decompilation] [th03] graph_putsa_fx()
Part of P0132, funded by [Anonymous].
2021-01-05 22:08:56 +01:00
nmlgc dc9e3ee475 [Decompilation] [th01] Bosses: Collision handling
Functions with 12 parameters are hard to describe, y'know. Looking
forward to decompiling these giant expressions for the actual
boss↔orb collision parameter passed to this function…

Oh well, at least we're now totally ready for some boss code next
year. 😌

Completes P0131, funded by Yanga.
2020-12-18 01:38:52 +01:00
nmlgc bcdc073403 [Reverse-engineering] [th01] Frame-based random number
Yes, no "generator", just a single number. Used to add some very
minimal randomness to certain things, by taking it modulo a small
number.

Part of P0131, funded by Yanga.
2020-12-18 01:38:51 +01:00
nmlgc 21da5a330d [Reverse-engineering] [th01] Bomb damage flag
Part of P0131, funded by Yanga.
2020-12-18 01:38:50 +01:00
nmlgc 89fbec0a79 [Reverse-engineering] [th01] Test mode damage flag
Part of P0131, funded by Yanga.
2020-12-18 01:38:50 +01:00
nmlgc f80001d34b [Reverse-engineering] [th01] Bosses: Current HP
And once again, SinGyoku is the only boss to get its own variable.
Maybe this means that it was the first boss to be implemented after
all?

Part of P0131, funded by Yanga.
2020-12-18 01:38:49 +01:00
nmlgc d5fd70c458 [Decompilation] [th01] HUD: HP rendering
And we're right back to things not being nice. Because yeah, why
shouldn't these three distinct rendering functions be part of a single
function, selected by magic numbers?
Or why shouldn't the 16×16 wrapper around a 32×32 set of graphics
functions be used to handle backgrounds for 16×8 sprites, resulting in
needlessly complex parameter calculations that lead to sloppy code?

Part of P0131, funded by Yanga.
2020-12-18 01:38:48 +01:00
nmlgc 576def5293 [Decompilation] [th01] HUD: Blitting individual hit points
Nice GRCG use! The 8 dots of its tile register, which are commonly just
set to the same color value, can of course hold an arbitrary bit
pattern for every bitplane. This allows you to get different colors for
every pixel, with still just a single VRAM write of the alpha mask to
one bitplane.

And I thought TH01 only suffered the drawbacks of PC-98 hardware, and
made so little use of its actual features that it's perhaps not even
fair to call it "a PC-98 game"…

Completes P0130, funded by Yanga.
2020-12-18 01:38:48 +01:00
nmlgc b4d500b2de [Decompilation] [th01] Bosses: Generic no-op callback
Made truly generic by its use in both the upcoming boss collision
handling, as well as some SinGyoku pellet spawning function.

Part of P0130, funded by Yanga.
2020-12-18 01:38:46 +01:00
nmlgc 64f872e5c5 [Decompilation] [th01] Difficulty-based value selection
And with that, TH01 is pushed over the 50% completion mark! 🎉

This time, it's only YuugenMagan who gets no own copy. Giant RE% gains
from all these calls, but let's hope I don't regret already decompiling
this one for all bosses. It's not quite at the beginning of SinGyoku's,
Mima's, and Elis' code segment, after all…

Part of P0130, funded by Yanga.
2020-12-18 00:59:41 +01:00
nmlgc 2c180c3825 [Reverse-engineering] [th01] Bosses: Current phase frame
One shared variable for all bosses except SinGyoku. Maybe the
biggest single set of PI false positives left in TH01?

Part of P0130, funded by Yanga.
2020-12-18 00:55:23 +01:00
nmlgc aaea18aa8f [Decompilation] [th01] Retrieving and setting the default boss palette
The placement at the beginning of Kikuri's code segment makes you think
this is only used for the barely noticeable white-in effect during
Kikuri's entrance animation. It's also used to periodically reset boss
sprite colors during the flashing effect after getting hit by the Orb,
though.

Part of P0130, funded by Yanga.
2020-12-18 00:55:21 +01:00
nmlgc 0bfff60a0a [Maintenance] Define `bool` as unsigned
Wait, we can just do that, and nothing breaks?! All this time, we
could have avoided the `unsigned char` workaround???

Part of P0130, funded by Yanga.
2020-12-18 00:45:54 +01:00
nmlgc f4c2e45671 [Decompilation] [th01] Stage objects: Initialization
Lol @ Konngara decompilation being blocked by this giant card-flipping
function that took 2 pushes to understand, only for it to start with

	if((stage % 5) == 4) {
		return;
	}

…

Completes P0129, funded by Yanga.
2020-12-01 00:34:22 +01:00
nmlgc dd74e8a3cd [Reverse-engineering] [th01] Stage objects: Sprite IDs
Part of P0129, funded by Yanga.
2020-12-01 00:34:22 +01:00
nmlgc 35b4461b22 [Decompilation] [th01] Stage objects: VRAM page 0 → 1 copies
This is where the code generation actually confirms the SoA layout of
the global obstacle structure, rather than it being distinct pointers.

Part of P0129, funded by Yanga.
2020-12-01 00:34:21 +01:00
nmlgc 4b24c13d3d [Decompilation] [th01] Stage objects: Obstacle initialization
Part of P0129, funded by Yanga.
2020-12-01 00:34:21 +01:00
nmlgc 9f9d27554b [Decompilation] [th01] Stage objects: STAGE?.DAT loading
Final set of file loading calls in TH01!

Part of P0129, funded by Yanga.
2020-12-01 00:34:20 +01:00
nmlgc dde36f7f89 [Decompilation] [th01] Stage objects: Background snapping
Completes P0128, funded by Yanga.
2020-12-01 00:34:20 +01:00
nmlgc 73f62a5ba2 [Decompilation] [th01] Stage objects: Background allocation and blitting
Continuing the good error handling from the .PTN functions they're
based on… if only its sole caller actually cared.

Also: A sort-of limit of 102 objects per stage, just because someone
didn't use huge pointers where they would have been necessary…
:tannedcirno:

Part of P0128, funded by Yanga.
2020-12-01 00:34:18 +01:00
nmlgc 27b3f29a0a [Reverse-engineering] [th01] Stage objects: Card flip scores
Case in point: This structure member, which is located after all the
obstacle members. Sure, it'll look weird to see this one initialized by
a class method, but it'll be much weirder to somehow group both cards
and obstacles into one class.

Part of P0128, funded by Yanga.
2020-11-29 18:03:39 +01:00
nmlgc 7df4e0517b [Reverse-engineering] [th01] Stage objects: Obstacle class
And another one for all the obstacle types we saw earlier. The original
game probably combined all SoA pointers for both cards and obstacles
into a single "stage object". But that'll get way too unwieldy in the
functions later, given that those aren't even methods, and simply
reference one global variable. `stageobjs.obstacles.member`… yeah, no.

Part of P0128, funded by Yanga.
2020-11-29 17:59:03 +01:00
nmlgc 8e43f48b69 [Reverse-engineering] [th01] Stage objects: Card class
Sure, a SoA layout might actually be genius and what you should be
doing most of the time on modern systems, but you still wouldn't
allocate every member separately.

Part of P0128, funded by Yanga.
2020-11-29 17:59:01 +01:00
nmlgc 0ea53cf841 [Reverse-engineering] [th01] Stage objects: Obstacle types
An enum to distinguish between bumpers, turrets, portals, bumper bars…
and cards that have to be flipped more than once?!

Part of P0128, funded by Yanga.
2020-11-29 17:01:14 +01:00
nmlgc 3fc43a3dba [Maintenance] [th01] Start a new header file for stage objects
As we're going to see, some of these share some of the allocations.

Part of P0128, funded by Yanga.
2020-11-29 16:53:58 +01:00
nmlgc baac3f7682 [Decompilation] [th04/th05] EGC-powered page 1→0 rectangle blitting
Actually fairly average, as far as unreasonable decompilations are
concerned. No `goto`, at least! Another place that would benefit from
EGC raster op documentation, though.

Also, got one more padding byte in TH05's MAINE.EXE correct. 🙂

Part of P0126, funded by [Anonymous] and Blue Bolt.
2020-11-16 20:01:09 +01:00
nmlgc b504d72301 [Maintenance] Move decomp.h out of th01/hardware/egc.h
Part of P0126, funded by [Anonymous] and Blue Bolt.
2020-11-15 21:30:58 +01:00
nmlgc 74a11d667d [Maintenance] master.hpp transition: Resident data
With a type-safe wrapper template that removes the need for ID length
and structure-size-in-paragraphs macros. *And* <dos.h>!

Part of P0126, funded by [Anonymous] and Blue Bolt.
2020-11-15 21:28:55 +01:00
nmlgc 9c36df72e5 [Maintenance] [th01] Get rid of th01.h
Part of P0126, funded by [Anonymous] and Blue Bolt.
2020-11-15 21:27:41 +01:00
nmlgc b104b3316b [Maintenance] Consistently use Borland's I/O port intrinsics
Rather than preferring either the Microsoft/Watcom `(in|out)pw?` style,
or the Borland `(in|out)portb?` style, master.lib had to introduce its
own `(OUT|IN)P[BW]` naming scheme… Insert obligatory xkcd standards
comic.

Part of P0126, funded by [Anonymous] and Blue Bolt.
2020-11-15 21:16:40 +01:00
nmlgc 6c22af7e83 [Build] [th01] Only compile shared single-file translation units a single time
Which gets rid of 13 redundant translation units. Definitely a good
start, before I figure out how to best handle the more complicated
cases.

(Maintenance mode commit)
2020-11-04 14:47:52 +01:00
nmlgc 7d83739eb8 [Build] [th01] Merge vsync_callback_clear() into vsync.c
Not really surprising why this works, and probably was how the original
code looked all along: The function is never called from anywhere, and
as long as the next function still lies on the same 16-byte paragraph,
it makes no difference whether the unused one is placed at the end of
the previous segment, or the beginning of the next.
Which means we can choose whatever leads to fewer translation units 👍

(Maintenance mode commit)
2020-11-04 14:42:37 +01:00
nmlgc f6a3246071 [Reverse-engineering] Enabling and disabling the EGC
Which involves temporarily enabling a GDC mode change bit.

Completes P0125, funded by [Anonymous].
2020-11-02 23:42:04 +01:00
nmlgc e8ae29ca4e [Maintenance] Remove the old `planar(8|16|32)_t` types
All code that used them has transitioned to C++, and can use the
Planar<> template.

Part of P0125, funded by [Anonymous].
2020-11-02 23:04:54 +01:00
nmlgc f1c63ab3a1 [Reverse-engineering] Assign names to all graph_putsa_fx() effects
And get rid of the constraining FX() macro, with its spacing parameter
that we haven't even seen used so far.

Part of P0124, funded by [Anonymous] and Blue Bolt.
2020-11-02 22:33:50 +01:00
nmlgc 0a25a0ac01 [Maintenance] Remove the RES_ID_LEN macro
And no longer force translation units that access the resident
structure into #including that mistake that was ReC98.h.

Part of P0124, funded by [Anonymous] and Blue Bolt.
2020-11-02 21:17:55 +01:00
nmlgc 72dfa096d1 [Decompilation] [th01] Setting the default stage palette
Completes P0123, funded by Yanga.
2020-10-13 21:48:54 +02:00
nmlgc 7b2653fcab [Decompilation] [th01] Reimu's animations: .BOS freeing function
*Still* no need for the classic `if(ptr) { delete[] ptr; ptr = NULL }`
macro, because who cares about dangling pointers anyway, right?
:zunpet:

Part of P0123, funded by Yanga.
2020-10-13 21:48:07 +02:00
nmlgc d2ba0c7b3b [Decompilation] [th01] Reimu's animations: Byte-aligned overlapped blitting
All this CPU time spent optimizing the unblitting mask, yet the code
still ends up glitching if the two sprites are more than 2 horizontal
bytes away. So, Reimu's slide speed can only be as high as 8 pixels per
frame, before this function fails to unblit the previous sprite and
leaves little Reimu parts in VRAM.

Part of P0123, funded by Yanga.
2020-10-13 21:36:07 +02:00
nmlgc 0be79aa641 [Decompilation] [th01] Reimu's animations: Byte-aligned blitting
Part of P0123, funded by Yanga.
2020-10-13 21:34:41 +02:00
nmlgc d391dd4a3b [Decompilation] [th01] Reimu's animations: Byte-aligned unblitting
"Let's add a row to the offset, and then subtract it again" :zunpet:
This could only *possibly* have been intended as a DoS attack against a
future manual decompilation, right?

Part of P0123, funded by Yanga.
2020-10-13 21:34:35 +02:00
nmlgc b75556c06e [Maintenance] [th01] Reorder shared .BOS code
Part of P0123, funded by Yanga.
2020-10-13 21:34:24 +02:00
nmlgc 10666131ec [Decompilation] [th01] Reimu's animations: .BOS load function
Part of P0123, funded by Yanga.
2020-10-13 21:15:19 +02:00
nmlgc cacb9361c7 [Decompilation] [th01] Skipping past the palette when loading .BOS files
At least the upcoming player animation load function was smart enough
to do that.

Part of P0123, funded by Yanga.
2020-10-13 20:51:52 +02:00