Commit Graph

57 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 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 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 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 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 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 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
nmlgc eb89330f64 [Build] [th01] Move the -Z and -3 options onto the command line
Deactivating them is the exception, not the norm.

Part of P0122, funded by Yanga.
2020-10-06 13:27:33 +02:00
nmlgc 1610d7b63d [Maintenance] Decide on a consistent place for file-wide `#pragma`s
(Maintenance mode commit)
2020-10-01 16:35:56 +02:00
nmlgc b974c1a915 [Maintenance] Add separate macros for GRCG/EGC-accelerated reads and writes
Not only getting rid of the "useless" (and thankfully, consistent)
bitplane parameter, but also allowing those shortened macros to be
redefined for the upcoming little ZUN inconsistency.

Part of P0120, funded by Yanga.
2020-09-28 12:51:01 +02:00
nmlgc 9738ba921a [Decompilation] [th01] Boss entities: .BOS slot freeing function
Still no need for the classic `if(ptr) { delete[] ptr; ptr = NULL }`
macro, since the `ptr` is unconditionally set to NULL here…

Part of P0120, funded by Yanga.
2020-09-28 12:37:33 +02:00
nmlgc d48e553d9e [Maintenance] [th01] Move shared .BOS loading snippets to separate functions
Part of P0120, funded by Yanga.
2020-09-28 12:33:02 +02:00
nmlgc 0fe23cb8a0 [Maintenance] [th01] Clearly distinguish entity and animation .BOS slots
… now that we have a better idea about the differences of both classes.
Also, no transitive dependency on bos.hpp for either class.

Part of P0120, funded by Yanga.
2020-09-28 12:32:52 +02:00
nmlgc 84baa1d477 [Maintenance] Rename the `_FORCE_INT` enum members to indicate signedness
Part of P0116, funded by [Anonymous] and Lmocinemod.
2020-09-12 12:09:30 +02:00
nmlgc ba29539fc7 [Maintenance] Declare a distinct type for VRAM offsets
… and this one, while I'm at it. I've been using pretty much every
possible type for VRAM offset variables, depending on my mood that day,
since signedness apparently never matters for those.
Except that it does. And so, just like with most of our high-level
types, we also have to account for ZUN's little signedness
inconsistencies here. Oh well, at least it's now only one of two types,
and there's no need to choose between `int` or `unsigned int` or
`short` or `unsigned short` or `int16_t` or `uint16_t` or `size_t` or…

Part of P0111, funded by [Anonymous] and Blue Bolt.
2020-08-28 14:53:33 +02:00
nmlgc d6f634631f [Maintenance] Declare distinct types for pixel and VRAM sizes
Oh wait, we also need one of those for an upcoming structure!

Part of P0111, funded by [Anonymous] and Blue Bolt.
2020-08-28 14:53:33 +02:00
nmlgc 368f151759 [Maintenance] Declare distinct types for screen, VRAM, and TRAM coordinates
Whew, time to look at every `int` variable we ever declared! The best
moment to do this would have been a year ago, but well, better late
than never. No need to communicate that in comments anymore.

These shouldn't be used for widths, heights, or sprite-space
coordinates. Maybe we'll cover that another time, this commit is
already large enough.

Part of P0111, funded by [Anonymous] and Blue Bolt.
2020-08-28 14:53:30 +02:00
nmlgc 342e6450bc [Decompilation] [th01] Boss entities: .BOS load function
"Hm, I have this format that specifies sprite width in multiples of 8,
but *actually*, I'd like to blit 16 pixels at a time… well, time to
pepper the code with divisions and casts, I guess :zunpet:"

Which becomes even more hilarious once you realize that the `operator
new` function does require bytes after all. Which leads

	new dots16_t[image_size / 2];

to compile to

	operator new((image_size / 2) * 2);

:tannedcirno:

Part of P0106, funded by Yanga.
2020-08-12 17:49:35 +02:00
nmlgc 96e06fc746 [Decompilation] [th01] .GRC: Freeing images in a single slot
Part of P0105, funded by Yanga.
2020-08-12 16:20:54 +02:00
nmlgc 7ca525ba5c [Decompilation] [th01] .GRC: Byte-aligned blitting
And that's all? No unblitting or non-aligned functions? Oh well, at
least this one correctly clips the sprite at all 4 edges of VRAM, for
once.

Part of P0105, funded by Yanga.
2020-08-12 16:20:18 +02:00
nmlgc 72538610ba [Decompilation] [th01] .GRC: Load function
Still no idea what those 7 unknown bytes in the .GRC and .BOS headers
could be.

Part of P0105, funded by Yanga.
2020-08-12 16:19:39 +02:00
nmlgc b22bc80e98 [Reverse-engineering] [th01] .GRC: Slot structure
Part of P0105, funded by Yanga.
2020-08-12 16:17:58 +02:00
nmlgc bd1c2ee7de [Maintenance] #define the number of dots in a byte
One fewer magic number. And one more deliberate dependency on a
PC-98-specific hardware constant, to further drive home just how
unportable these games are, even once decompilation will be complete.

Part of P0105, funded by Yanga.
2020-08-12 16:16:58 +02:00
nmlgc 74b834fd7f [Maintenance] Use a distinct name for arc_file_get()'s sizeof() macro
We not only actually still need the (pointer, size) function to fill
heap-allocated memory, but we also need to differentiate between near
and far pointers, to move those pesky `PUSH DS` instructions to their
original places?!

Part of P0105, funded by Yanga.
2020-08-12 16:12:02 +02:00
nmlgc 8367a41d46 [Maintenance] Decide on *_id for 0-based, and *_num for 1-based IDs
Which we've been already subconciously doing with the resident
`demo_num` variable.

Part of P0104, funded by Ember2528.
2020-07-27 17:22:28 +02:00
nmlgc edd9a14273 [Decompilation] [th01] HUD: Background (MASK.GRF) loading and rendering
Look, it's a memory leak!

Part of P0104, funded by Ember2528.
2020-07-27 17:17:59 +02:00
nmlgc 57a2294f7a [Maintenance] Add a Planar<> template for any type of 4-plane value
Part of P0103, funded by Ember2528.
2020-07-27 17:10:00 +02:00
nmlgc d840841a2b [Naming] Rename egc_copy_rect_1_to_0() to emphasize its 16-dot alignment
ZUN might have gotten the impression that the EGC can *only* work with
multiples of 16 pixels per load or store? Which might explain why…

Part of P0102, funded by Yanga.
2020-07-12 16:27:56 +02:00
nmlgc f612c40dce [Maintenance] Move generic VRAM macros from REIIDEN.EXE's PTN code to planar.h
C++ templates would be *so nice* here, but code generation… 😢

Part of P0099, funded by Ember2528.
2020-07-12 15:08:38 +02:00
nmlgc 97dce75446 [Maintenance] Proofread all comments in C land 2020-06-21 22:14:08 +02:00
nmlgc 8283c5eec8 [Decompilation] [th01] .PTN: Unaligned 16×16 blitting
But no corresponding unblitting function…?

Completes P0096, funded by Ember2528.
2020-06-13 21:13:50 +02:00
nmlgc 979f401515 [Maintenance] [th01] .PTN: Define the transparent color in a single place
Inlined template functions! \o/

Part of P0096, funded by Ember2528.
2020-06-13 21:13:50 +02:00
nmlgc 9cd54f1b13 [Decompilation] [th01] .PTN: Byte-aligned 16×16 blitting
Part of P0096, funded by Ember2528.
2020-06-13 21:13:49 +02:00
nmlgc f6c668dafc [Decompilation] [th01] .PTN: Byte-aligned 16×16 unblitting
Part of P0096, funded by Ember2528.
2020-06-13 21:13:49 +02:00
nmlgc 71970f57c6 [Decompilation] [th01] .PTN: Byte-aligned 32×32 blitting
Part of P0096, funded by Ember2528.
2020-06-13 21:13:49 +02:00
nmlgc a55c5ced81 [Decompilation] [th01] .PTN: Byte-aligned 32×32 unblitting
Part of P0096, funded by Ember2528.
2020-06-13 21:13:48 +02:00
nmlgc 416aa4ccef [Reverse-engineering] [th01] .BOS bitplane pointers
No idea why ZUN split the 6 slots into 4 with a regular alpha plane,
and 2 with a negated alpha plane. The latter are only used for Sariel's
animations.

Part of P0095, funded by Yanga.
2020-05-31 17:31:07 +02:00
nmlgc 026fff63a5 [Decompilation] [th01] Ending picture loading and display
Aww, how far we've come with inlining and helpful macros.

Part of P0094, funded by Yanga.
2020-05-25 15:18:44 +02:00
nmlgc 7ad14db394 [Decompilation] [th01] REIIDEN.CFG loading and saving
That's where the backwards `goto` for .CFG file error handling
originated!

Part of P0090, funded by Yanga.
2020-05-12 14:36:43 +02:00
nmlgc 02f0a0afcc [Build] Don't word-align everything by default
Again, 11 necessary workarounds, vs. forcing byte aligment in at least
18 places, and that number would have significantly grown in the
future.

Part of P0085, funded by -Tom-.
2020-04-03 17:35:57 +02:00
nmlgc ffad8cc897 [Build] Use the minimum possible size for enums by default
5 enums where code generation wants an `int`, vs. 11 cases where using
the minimum size is exactly the right default. So it's way more
idiomatic to force those 5 to 16 bits via a dummy element… except that
we can't give it a single, consistent name, because you can't redeclare
the same element in a different enum later.

Oh well, let's have this ugly naming convention instead, which makes it
totally clear that the force element not, in fact, a valid value of
that enum.

Part of P0085, funded by -Tom-.
2020-04-03 17:33:58 +02:00
nmlgc 1cc9cefa26 [Decompilation] [th01] PTN-sized page 0→1 copies
Final shared function in TH01's OP.EXE.

Part of P0084, funded by Yanga.
2020-03-22 09:59:24 +01:00
nmlgc 9e676ce3ef [Decompilation] [th01] .PTN snap functions
Which repurpose the .PTN image slots to store the background of
frequently updated VRAM sections, like all the numbers in the HUD.
Future games would simply use the text RAM and gaiji for numbers. Which
would have worked just fine for TH01 as well (especially since all the
functions we've seen so far are aligned to the 8-pixel byte grid), but
it looks as if ZUN simply wasn't aware of gaiji during the development
of TH01.

Part of P0083, funded by Yanga.
2020-03-18 20:33:58 +01:00
nmlgc a184413f27 [Decompilation] [th01] .PTN file loading and non-transparent display
What is this, error checking in a ZUN game?! And surprisingly good code
for deriving the alpha plane?!

Part of P0083, funded by Yanga.
2020-03-18 20:33:58 +01:00
nmlgc d79f4c1171 [Maintenance] [th01] Correctly declare the packfile functions in C land
Mangled C++ function names would *not* have been a mistake if I hadn't
made the other mistake of restricting parts of the code to C…

Part of P0083, funded by Yanga.
2020-03-18 20:33:53 +01:00
nmlgc 2546c5dfcb [Reverse-engineering] [th01] .PTN slot structure
Part of P0083, funded by Yanga.
2020-03-18 20:09:57 +01:00