Commit Graph

1234 Commits

Author SHA1 Message Date
nmlgc d40547e601 [Maintenance] Drop the `slot` infix for PI-related identifiers
ZUN doesn't ever use PI functions without these slots, making that infix
kind of redundant.

Part of P0114, funded by Lmocinemod.
2020-09-07 21:18:39 +02:00
nmlgc 50b17d640b [Reverse-engineering] [th03] SPRITE16 setup for double-buffered blitting
Part of P0114, funded by Lmocinemod.
2020-09-07 21:18:39 +02:00
nmlgc 5a6ac29f50 [Separate translation units] [th03] CDG: Non-alpha display (undecompilable)
Reason: Self-modifying. -.-

Part of P0114, funded by Lmocinemod.
2020-09-07 21:18:39 +02:00
nmlgc 97ce07bfc9 [Reverse-engineering] [th03] CDG: VRAM plane iteration
Which is where ZUN adds those additional 0x2000 to make the jump from
the 0xB800 plane to the 0xE000 plane.

Part of P0114, funded by Lmocinemod.
2020-09-07 21:18:38 +02:00
nmlgc ecc1372842 [Decompilation] [th03] Lookup table for horizontally flipping planar pixels
In which we exchange variable names for the ability to decompile more
than just 3 instructions here.
… yeah, "decompilation" is still a stretch.

Part of P0114, funded by Lmocinemod.
2020-09-07 21:18:38 +02:00
nmlgc 6204fdd450 [Separate translation units] [th02/th03/th04] frame_delay_2()
Completes P0113, funded by Lmocinemod.
2020-09-07 21:18:38 +02:00
nmlgc f0511221b7 [Maintenance] [th02/th03/th04/th05] Establish a common name for code segment 2
About time I finally developed this piece of tech. Towards TH05, this
segment got more and more undecompilable ASM functions mixed inbetween
C ones. Which means that pretty much all of the current ASM land
`#include`s in that segment will have to become translation units. And
we *really* don't want an additional layer of numbered, per-binary
translation units that just `#include` maybe one or two functions.

Also yeah, no _TEXT suffix, to drive home the point that this is a
"library" segment, and not really "owned" by any one file.

Part of P0113, funded by Lmocinemod.
2020-09-07 21:18:38 +02:00
nmlgc 687752160c [Maintenance] Start a new file for x86 FLAGS comparison macros
Part of P0113, funded by Lmocinemod.
2020-09-07 21:18:38 +02:00
nmlgc be22a72b25 [Maintenance] [th03/th04/th05] Declare CDG loading/freeing functions in C land
No need to make the function names more complicated if we already
expressed the one subtle format difference between TH03 and TH04/TH05
in the plane layout enum.

Part of P0113, funded by Lmocinemod.
2020-09-07 21:18:38 +02:00
nmlgc d1ba6306cc [Maintenance] [th03/th04/th05] Declare the CDG slot structure in C land
Third iteration on the field names, now consistent with how the naming
has evolved since 2017…

Part of P0113, funded by Lmocinemod.
2020-09-07 21:18:37 +02:00
nmlgc ec8668264c [Pipeline] bmp2arr: Fail if any non-#000/#FFF pixels are found
And that's all the minimum functionality I wanted to have.
Closes #8.

Part of P0113, funded by Lmocinemod.
2020-09-07 21:18:34 +02:00
nmlgc fea00067d7 [Pipeline] bmp2arr: Extend debug output to cover *all* relevant fields
And with that, we might even get away with not having command-line
help 😛

Part of P0113, funded by Lmocinemod.
2020-09-07 17:36:01 +02:00
nmlgc 23bf61b773 [Pipeline] bmp2arr: Add -q for silencing debug output on stderr
Part of P0113, funded by Lmocinemod.
2020-09-07 17:32:04 +02:00
nmlgc ea8d2466fe [Pipeline] bmp2arr: Require the output type to be provided explicitly
Part of P0113, funded by Lmocinemod.
2020-09-07 17:29:45 +02:00
nmlgc 24699942e6 [Pipeline] bmp2arr: Introduce error codes, and a separate reporting function
Part of P0113, funded by Lmocinemod.
2020-09-07 17:29:44 +02:00
nmlgc 66b72477d2 [Pipeline] bmp2arr: Use bitflags for the preshift/upside-down/debug BMP options
More ergonomic in initializer lists when used as a library.

Part of P0113, funded by Lmocinemod.
2020-09-07 17:29:43 +02:00
nmlgc 1f1847de48 [Build] Assemble all .ASM files in the 32-bit build part
Yeah, why *were* we assembling them in the 16-bit part before?!
Possible reasons:
• In a time before Tup, it made no actual difference whether these
  little files were assembled in the 32-bit or 16-bit part. Now it sort
  of does, since we've temporarily given up on minimal rebuilds in the
  16-bit part.
• Emphasizing the temporary nature of the 32-bit part by deliberately
  moving everything to the 16-bit part as early as possible?
• It all started with the ZUN.COM ASM code, which doesn't include any
  other files, and can therefore be perfectly tracked by a Makefile.
  Which *was* superior than the exclusive dumb batch file we had in the
  past. And then I've simply cargo-culted all new .ASM translation
  units into the 16-bit part well.

Oh, and another positive side effect of temporarily not using 16-bit
TASM: The build process now also runs on Windows 95.

Part of P0113, funded by Lmocinemod.
2020-09-07 17:25:56 +02:00
nmlgc 150d2c66d8 [Readme] Document the fix for TLINK's `Loader error (0000)` on 32-bit Windows
We have a winner! This turns 32-bit Windows ≥Vista into the optimal OS
to build ReC98 on.

Completes P0001, funded by GhostPhanom.
2020-09-03 22:50:29 +02:00
nmlgc b18866232b [Build] 32-bit: Fall back on a dumb full .bat rebuild if Tup can't run
And that's how we can still have a reliable 32-bit build part that runs
on XP or earlier.

Completes P0001, funded by GhostPhanom.
2020-09-03 19:04:20 +02:00
nmlgc a39a76bf99 [Build] 32-bit: Fix bin/th0? directory creation for Windows 9x
Part of P0001, funded by GhostPhanom.
2020-09-03 19:04:19 +02:00
nmlgc 953e957f00 [Build] 32-bit: Fix tool checks and remove stderr redirection for Windows 9x
Containing ridiculous ERRORLEVEL hacks, because Windows 9x leaves it
untouched for nonexistent commands…

Part of P0001, funded by GhostPhanom.
2020-09-03 19:04:18 +02:00
nmlgc e31d232584 [Build] 32-bit: Use Tup as a proper build system for the 32-bit part
This Tupfile does in fact date back to January 2017, and I've been
using it myself ever since. Time to finally deliver it on master!

Part of P0001, funded by GhostPhanom.
2020-09-03 19:04:17 +02:00
nmlgc 51b775bd41 [Build] 16-bit: Don't explictly specify the .OBJ extension in TASM rules
If the output file already exists, TASM interprets a filename with
extension as a directory, and then concatenates the implicitly
generated output file name to that path… yup.

Part of P0001, funded by GhostPhanom.
2020-09-03 19:04:16 +02:00
nmlgc 61358c1082 [Build] 16-bit: Unconditionally rebuild everything by default
Yup, let's completely avoid any of the benefits a Makefile might have
had, because they're completely unreliable without spelling out every
single #include. Such a trash technology, unsuited for pretty much
anything it's touted for.

Oh well, you can still call `maker` manually without the -B flag, if
you know for a fact that you've only modified the dependencies
currently listed. 🤷
At least this flag exists, and we don't have to add something like a
dummy .OBJ to each and every list of dependencies, so that we then can
force rebuilds by simply `touch`ing that one file…

Part of P0001, funded by GhostPhanom.
2020-09-03 19:04:15 +02:00
nmlgc e5f28204a5 [Build] 32-bit: Actually create `bin/Pipeline` during the 32-bit part -.-
Lol, this led the bmp2arr compilation to fail on a clean checkout.
Lesson learned: Always test on a clean clone, not in your separate test
repo that you just `git pull` up to the final commit in a push, but
with all the build artifacts still in there…

Also, yes, `mkdir` only supports backslashes.

Part of P0001, funded by GhostPhanom.
2020-09-03 19:04:15 +02:00
nmlgc e9cba933bb [Build] 32-bit: Sanely reorder the initialization steps
Part of P0001, funded by GhostPhanom.
2020-09-03 19:04:10 +02:00
nmlgc e447a2d687 [Position independence] [th04/th05] Final data references in TH05's MAIN.EXE
And that's it, actual position dependence achieved! 🎉 Again, the
website won't quite show 100% PI, but that (again) are all false
positives, to be covered in an upcoming push…

Completes P0112, funded by [Anonymous] and Blue Bolt.
2020-08-28 16:21:20 +02:00
wintiger0222 db206f9d41 [Reverse-engineering] [th02/th04/th05] HUD: Bar colors
Reviewed and merged as part of P0112, funded by [Anonymous] and Blue
Bolt.
2020-08-28 16:21:13 +02:00
nmlgc 6cd11b0a44 [Reverse-engineering] [th05] Bullets: Pellet delay cloud render list
Making sure that we don't ever have to iterate over the 8×8 pellet part
of the bullet array during rendering… sure, but why not give the same
optimization treatment to the 16×16 bullets?

Part of P0112, funded by [Anonymous] and Blue Bolt.
2020-08-28 15:31:02 +02:00
nmlgc db0adbc58f [Maintenance] [th02/th04/th05] Rename `HUD_TRAM_W` to `HUD_KANJI_W`
Right, *_TRAM_W refers to 8-pixel halfwidth characters, and *_KANJI_W
to 16-pixel full-width characters… which also include gaiji, which are
what the entire HUD is made out of.

Part of P0112, funded by [Anonymous] and Blue Bolt.
2020-08-28 15:30:34 +02:00
nmlgc ed113d9c30 [Reverse-engineering] [th04/th05] Stage tiles: Initial ring buffer filling
…Wow. A 32-element lookup table for the very computationally expensive
operation of (i * 320), needlessly limiting the amount of unique 384×80
tile sections in a stage to 32… and then TH05 further "optimizes" this
lookup by pre-multiplying all section IDs in the .STD file with the
element size of that table, to save a grand total of 1 x86 instruction.

Part of P0112, funded by [Anonymous] and Blue Bolt.
2020-08-28 15:28:26 +02:00
nmlgc a89836c18e [Decompilation] [th05] Bombs: Reimu's blue star animation
After ternary expressions straight out of Jigoku in 57be510, we now got
pointer arithmetic straight out of Jigoku… with, unsurprisingly, two
ZUN bugs.

Part of P0112, funded by [Anonymous] and Blue Bolt.
2020-08-28 15:22:28 +02:00
nmlgc a7a053fb52 [Reverse-engineering] [th05] Bombs: Character-specific animation structures
Final structure in TH05's `MAIN.EXE`! And, just like this game's custom
entities, every character uses the same structure fields with vastly
different semantics and high-level types… yup, time for separate
structures again.

Part of P0112, funded by [Anonymous] and Blue Bolt.
2020-08-28 15:18:15 +02:00
nmlgc fb67d4d054 [Maintenance] Rename all old *_X and *_Y constants to *_LEFT and *_TOP
Part of P0112, funded by [Anonymous] and Blue Bolt.
2020-08-28 15:14:22 +02:00
nmlgc 8e686dd564 [Maintenance] [th04/th05] Declare circles in C land
No structure declaration in the header file needed, since the game
doesn't party on its members from outside, for once!

Part of P0112, funded by [Anonymous] and Blue Bolt.
2020-08-28 15:14:21 +02:00
nmlgc b034e606bc [Maintenance] Subpixels: Differentiate between pixel and subpixel types
Which does have the practical effect of communicating more information
via IntelliSense during regular development!

Part of P0112, funded by [Anonymous] and Blue Bolt.
2020-08-28 15:14:21 +02:00
nmlgc 5a1e16de60 [Maintenance] Subpixels: Rename to_screen() to to_pixel()
We've been establishing `screen` as meaning "a coordinate rooted at the
top-left corner of the display", whereas most of the Subpixels in >TH01
are rooted at the top-left of the playfield.

Part of P0112, funded by [Anonymous] and Blue Bolt.
2020-08-28 15:14:17 +02:00
nmlgc 4ef4c9eeb0 [Maintenance] [th05] Split segment #1 before Reimu's bomb star animation
Nope, not going to figure this one out on ASM level.

Completes P0111, funded by [Anonymous] and Blue Bolt.
2020-08-28 15:08:21 +02:00
nmlgc 5d76fd6f64 [Reverse-engineering] [th04] Bombs: Star animation structure
The trivial one first, while I try to wrap my head around what's going
on with Reimu's TH05 bomb animation…

Part of P0111, funded by [Anonymous] and Blue Bolt.
2020-08-28 15:04:39 +02:00
nmlgc c5b5dc0201 [Reverse-engineering] General bomb-related globals
Yup, function pointers, frame counters, and general state variables for
all 5 games.

Part of P0111, funded by [Anonymous] and Blue Bolt.
2020-08-28 15:03:03 +02:00
nmlgc 199f4de1d3 [Reverse-engineering] [th04/th05] Remaining item-related globals
Leaving the obvious "PoC always enabled" cheat as an exercise to the
reader.

Part of P0111, funded by [Anonymous] and Blue Bolt.
2020-08-28 15:00:33 +02:00
nmlgc 1c3e9097cc [Decompilation] [th05] EX-Alice: Fire wave management
Final unknown entity in TH05 that can collide with the player!
Get position independence hype!
(Also, no structure member comments necessary, thanks to the new
types!)

Part of P0111, funded by [Anonymous] and Blue Bolt.
2020-08-28 14:59:27 +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 8b5c1463f6 [Position independence] [th02/th03/th04/th05] References to known gaiji
Completes P0110, funded by [Anonymous] and Blue Bolt.
2020-08-19 20:12:02 +02:00
nmlgc 9e06c45656 [Decompilation] [th05] Line sets: Copying lines up by 1 element
Which can't be a class method, but only because CX and DX would be
swapped then… yup.

Part of P0110, funded by [Anonymous] and Blue Bolt.
2020-08-19 20:12:00 +02:00
nmlgc 2ef3db3052 [Maintenance] Remove the `operator =` overloads for Subpixels
At least we've now documented their negative effects.

Part of P0110, funded by [Anonymous] and Blue Bolt.
2020-08-19 20:10:08 +02:00
nmlgc 7c4d31c02b [Decompilation] [th05] Line sets: Rendering
With all the memmove()-style shifting of individual lines, there's
probably a point to reserving 20 lines per set, but only ever rendering
4 of them. We'll see once I get to decompile all of these functions.

Part of P0110, funded by [Anonymous] and Blue Bolt.
2020-08-19 20:10:08 +02:00
nmlgc 8cf1e74565 [Maintenance] [th05] Split segment #1 before the line set render function
Why does this suddenly break select_for_rank() in C land?!

Part of P0110, funded by [Anonymous] and Blue Bolt.
2020-08-19 20:10:07 +02:00