Commit Graph

2585 Commits

Author SHA1 Message Date
nmlgc 5a79ea574c [Build] 32-bit: Refactor the Tupfile into Lua
A perfect `tup refactor`, already featuring most of the structure we're
going to use for the merged 32-bit and 16-bit build.
Also, inlining all the BCC32 stuff because we're no longer going to use
this compiler anyway.

Part of P0003, funded by GhostPhanom.
2024-07-06 18:33:24 +02:00
nmlgc f1318782f3 [Build] 32-bit: Remove duplicate backslashes from `bmp2arr.exe`
Single backslashes are still preserved as such in the `tup generate`d
batch file, and we don't need two there. This allows us to cleanly
refactor these commands into the new Lua code.

Completes P0002, funded by GhostPhanom.
2024-07-06 18:33:18 +02:00
nmlgc d7b0b13885 [Build] Emit all intermediate files into `obj/`
Finally, a clean `bin/` tree. 😌
And as for the additional complexities in the Makefile, well, we're
about to get rid of that one anyway. 🚮

Part of P0002, funded by GhostPhanom.
2024-06-30 05:53:13 +02:00
nmlgc 10db923251 [Build] [Pipeline] Compile with optimization flags
The ones we use in `Research/` and for the Anniversary Edition. Better
code generation at the cost of having to explicitly declare `main` as
`__cdecl` so that the linker can find it.

Part of P0002, funded by GhostPhanom.
2024-06-30 05:53:13 +02:00
nmlgc c95d7c5aa8 [Build] Move ZUN.COM generation code into the `Pipeline/` directory
These are just as much of a part of the PC-98 Touhou build pipeline as
the sprite compiler. The future Tupfile will use the tupblocks concept
of treating the build configuration as a branching tree, so we'd like
everything under `Pipeline/` to share a single set of configuration
flags.

Part of P0002, funded by GhostPhanom.
2024-06-30 05:53:13 +02:00
nmlgc b9d5c743a2 [Build] [th05] Use a separate translation unit for `scoreupd.asm`
Finally removing that one inconsistency that dates back to 1f1847d.
Now, every file in the `th0?/` subdirectory is meant to be assembled
with `/dGAME=?`.

Part of P0002, funded by GhostPhanom.
2024-06-30 05:53:13 +02:00
nmlgc 8d5b08306f [Build] 32-bit: Move ASM land `GAME` constants onto the build command line
More complex now, less complex in the Lua rewrite.

Part of P0002, funded by GhostPhanom.
2024-06-30 05:52:59 +02:00
nmlgc f7dbc0b497 [Build] Use a single set of `CFLAGS` in the Makefile
Turns out that all of the previous inconsistencies in the Makefile are
covered by just 8 additional `#pragma`s in the code. Most of those
applied to code that already needed way more flags than the Makefile
bothered to address, such as the extremely silly `-O-`.

Part of P0002, funded by GhostPhanom.
2024-06-24 00:21:31 +02:00
nmlgc 02b6129c51 [Build] [th02] Merge the 2nd and 3rd translation units of ZUN_RES.COM
The string literal placement issue mentioned in 942373e doesn't seem to
be an actual problem (anymore). This is also much simpler, as we get to
save tons of `extern` declarations at the cost of one additional
`#pragma option`.

Part of P0002, funded by GhostPhanom.
2024-06-24 00:21:28 +02:00
nmlgc b134834027 [zuncom] zungen: Allow spaces as listfile parameter separators
Not only would newlines complicate the `echo` commands in the future
Tup rules, but the sub-shell trick we'd have to use in order *to*
`echo` such newlines
(https://stackoverflow.com/questions/132799#comment10257404_132811)
won't work when running Tup through Wine:

	https://bugs.winehq.org/show_bug.cgi?id=21227

Part of P0002, funded by GhostPhanom.
2024-06-24 00:21:23 +02:00
nmlgc a214f329a7 [Maintenance] grzview: Copy-paste .GRZ stream arrays
Unfortunate, but we won't be able to reuse the same .OBJ file once we
compile all pipeline tools with the `pascal` calling convention.
Separately compiling `th01/formats/img_data.cpp` would also turn into a
mess with the upcoming `#include` cleanup:

• `img_data.cpp` requires `ptn.hpp`,
• which will require `egc.h`,
• which requires `defconv.h`,
• which requires `GAME` to be defined,
• which makes no sense for pipeline tools.

Part of P0002, funded by GhostPhanom.
2024-06-24 00:21:14 +02:00
nmlgc 0310154789 [Maintenance] Commit .bat files with LF line endings, but check out as CRLF
Windows 9x requires CRLF for batch files to work at all. While Windows
XP and later appear to work with LF line endings, they introduce
devious glitches with certain commands:

	https://www.dostips.com/forum/viewtopic.php?t=8988

However, we still want to use LF endings in the repo to prevent the
annoying ^M whitespace errors.

Part of P0002, funded by GhostPhanom.
2024-06-24 00:21:11 +02:00
nmlgc 87eed57ade [Decompilation] [th03] Hit circles: Rendering
Completes P0280, funded by [Anonymous], Blue Bolt, and JonathKane.
2024-04-23 05:52:53 +02:00
nmlgc 0c6e9e88d0 [Decompilation] [th03] Hit circles: Update function
Part of P0280, funded by [Anonymous], Blue Bolt, and JonathKane.
2024-04-23 05:52:53 +02:00
nmlgc 4005de4d58 [Decompilation] [th03] Hit circles: Spawning player circles
Part of P0280, funded by [Anonymous], Blue Bolt, and JonathKane.
2024-04-23 05:52:53 +02:00
nmlgc 179c5389a7 [Decompilation] [th03] Hit circles: Spawning enemy circles
Part of P0280, funded by [Anonymous], Blue Bolt, and JonathKane.
2024-04-23 05:52:50 +02:00
nmlgc 6f84eb612a [Reverse-engineering] [th03] Hit circles: Structure
Part of P0280, funded by [Anonymous], Blue Bolt, and JonathKane.
2024-04-23 05:52:27 +02:00
nmlgc 1cdf14ab83 [Reverse-engineering] [th03] Global shared hitbox
Featuring a semantically overloaded origin just for the hell of it, eh?

Part of P0280, funded by [Anonymous], Blue Bolt, and JonathKane.
2024-04-21 14:50:21 +02:00
nmlgc c8443b77fe [Reverse-engineering] [th03] Round-or-result frame counter
Would be ZUN bloat if it didn't actually have an effect, since way too
many things read from it 😩

Part of P0280, funded by [Anonymous], Blue Bolt, and JonathKane.
2024-04-21 14:50:21 +02:00
nmlgc 09f5292c0a [Decompilation] [th03] Player: Position update and clamping
Part of P0280, funded by [Anonymous], Blue Bolt, and JonathKane.
2024-04-21 14:50:21 +02:00
nmlgc ead31bdfe0 [Decompilation] [th03] Player: Input → movement velocity
I am once again impressed at Turbo C++ 4.0J's optimizer for still
perfectly inlining two levels of nested conditional branches if they
only depend on compile-time constants.

Part of P0280, funded by [Anonymous], Blue Bolt, and JonathKane.
2024-04-21 14:50:03 +02:00
nmlgc 30ddddb2d4 [Reverse-engineering] [th03] Player: Base speed of currently updated player
Part of P0280, funded by [Anonymous], Blue Bolt, and JonathKane.
2024-04-21 14:29:49 +02:00
nmlgc 93e5f3213d [Decompilation] [th03] Playfield: Playfield X → screen X coordinate conversion
Together with `extern "C"` removal and another pass over constants that
the `x` parameter is calculated from.

Part of P0280, funded by [Anonymous], Blue Bolt, and JonathKane.
2024-04-21 14:29:49 +02:00
nmlgc 06ad372e16 [Decompilation] [th03] Playfield: Screen X → playfield X coordinate conversion
Part of P0280, funded by [Anonymous], Blue Bolt, and JonathKane.
2024-04-21 13:49:44 +02:00
nmlgc 59064548e4 [Decompilation] [th03] Playfield: Entity clipping
Why would you ever micro-optimize this 😩

Part of P0280, funded by [Anonymous], Blue Bolt, and JonathKane.
2024-04-21 13:49:44 +02:00
nmlgc cdc7e5929a [Decompilation] [th03] SPRITE16: Inline methods for playfield clipping
Part of P0280, funded by [Anonymous], Blue Bolt, and JonathKane.
2024-04-21 13:49:37 +02:00
nmlgc 51de5ec036 [Decompilation] [th03] SPRITE16: Inline method for sprite size assignments
All but one of the writes to these globals follow the consistent scheme
of assigning hardcoded literals to first `w` and then `h`, so it makes
sense to encapsulate the conversion from display-space pixels to VRAM
words and heights in a method.
(On that note, we also need a new type to encode the notion of
VRAM-space heights as opposed to the display-space heights of
`pixel_t`.)

Part of P0280, funded by [Anonymous], Blue Bolt, and JonathKane.
2024-04-21 13:41:58 +02:00
nmlgc 415bef1176 [Maintenance] [th03] SPRITE16: Move game-level code into `main/`
We'd like t have a method to set the clipping coordinates from a player
ID, but such a method requires a dependency on `playfld.hpp` in `main`.
`SPF_DOWNWARDS_COLUMN` is kind of game-specific to begin with, too.

Part of P0280, funded by [Anonymous], Blue Bolt, and JonathKane.
2024-04-21 13:36:03 +02:00
nmlgc e93bd6d11c [Maintenance] [th03] Random number ring buffer: Declare the `_far` instance
Needs capital letters because of the `pascal` calling convention.

Part of P0280, funded by [Anonymous], Blue Bolt, and JonathKane.
2024-04-21 12:48:58 +02:00
nmlgc 20bac82005 [Decompilation] [th02] Stage bonus calculation and rendering
For both regular and extra stages.

Completes P0279, funded by Yanga and Blue Bolt.
2024-04-12 00:31:24 +02:00
nmlgc 0935e84a83 [Decompilation] [th02] Stage bonus: Table row rendering
Very unfortunate that this has to go into the overlay translation unit
due to the upcoming functions near-calling the `far overlay_wipe()`
function.

Part of P0279, funded by Yanga and Blue Bolt.
2024-04-12 00:31:24 +02:00
nmlgc 40010a655b [Decompilation] [th02] Score: Skill value calculation
This will end up at the end of Mima's translation unit. Might as well
start a separate temporary one then, which will simplify the diff once
we eventually merge it into that future Mima TU which is very likely to
grow from top to bottom.

Part of P0279, funded by Yanga and Blue Bolt.
2024-04-12 00:31:03 +02:00
nmlgc 4a7d4db25a [Reverse-engineering] [th02] Evil Eye Σ: Fight duration
Part of P0279, funded by Yanga and Blue Bolt.
2024-04-12 00:29:10 +02:00
nmlgc 0f66796fd4 [Reverse-engineering] [th02] Player performance ("rank")
Many thanks to KirbyComment and Colin Douglas Howell for documenting
their research into rank on Touhou Wiki. Just like in TH01, rank also
only affects bullet speed in this game, but let's use the `playperf`
naming scheme from TH04 and TH05 to make it less confusing – at least
until we exactly know the unit of this variable.

Part of P0279, funded by Yanga and Blue Bolt.
2024-04-12 00:29:10 +02:00
nmlgc 9bb2a3cd45 [Reverse-engineering] [th02] Total and stage-specific miss and bomb counters
The stage bonus functions require the stage-specific ones, which are
updated next to the total ones, which are required by the skill
calculation that we need to explain what we just saw in the verdict
screen… What a coincidence! (Yes, this actually wasn't planned.)

Part of P0279, funded by Yanga and Blue Bolt.
2024-04-12 00:29:10 +02:00
nmlgc 610df17856 [Maintenance] [th02] Start a new header for player performance metrics
All of these are scalar values with at most a dependency on
`platform.h`. Since these item-related values are mainly read by
score/skill calculation code, it makes sense to declare them in a
dedicated header along with the upcoming metrics.

Part of P0279, funded by Yanga and Blue Bolt.
2024-04-12 00:29:10 +02:00
nmlgc 50afb0afa6 [Decompilation] [th02] Staff roll and verdict sequences
Part of P0279, funded by Yanga and Blue Bolt.
2024-04-12 00:29:10 +02:00
nmlgc c88a259568 [Decompilation] [th02] Staff roll: Rectangle animation + picture blitting
Both sub-functions could have been inlined here, and then I wouldn't
have had to comment the former.

Part of P0279, funded by Yanga and Blue Bolt.
2024-04-12 00:29:10 +02:00
nmlgc 9ce80c0c1c [Decompilation] [th02] Staff roll: Clearing text from VRAM
Part of P0279, funded by Yanga and Blue Bolt.
2024-04-12 00:29:10 +02:00
nmlgc bfeb661f69 [Decompilation] [th02] Staff roll: ENDFT.BFT sprite blitting
Part of P0279, funded by Yanga and Blue Bolt.
2024-04-12 00:29:10 +02:00
nmlgc f0fbaf667c [Decompilation] [th02] Endings: Script code for Bad and Good endings
On the list of functions yet to be decompiled, these were at number 7
and 1, respectively, which corresponds to number 7 and 22 on the total
list of functions in PC-98 Touhou.

Completes P0278, funded by Yanga.
2024-04-12 00:29:10 +02:00
nmlgc 16ddd0cc2d [Decompilation] [th02] Ending → Staff roll transition
And it has a bug 🎺

Part of P0278, funded by Yanga.
2024-04-12 00:29:10 +02:00
nmlgc f623a70929 [Decompilation] [th02] Endings: Clearing the text line
Part of P0278, funded by Yanga.
2024-04-12 00:29:10 +02:00
nmlgc ddaf8c9495 [Decompilation] [th02] Endings / Staff roll: Picture blitting
Part of P0278, funded by Yanga.
2024-04-12 00:29:10 +02:00
nmlgc 8a149db5c4 [Decompilation] [th02] Verdict: 3-digit number → gaiji string conversion
Part of P0278, funded by Yanga.
2024-04-12 00:29:10 +02:00
nmlgc 7ac1db34f0 [Decompilation] [th02] Verdict: Masked VRAM row copies from page 1→0
Part of P0278, funded by Yanga.
2024-04-12 00:29:10 +02:00
nmlgc 35f320ef80 [Decompilation] [th02] Endings / Staff roll: Text typing
Part of P0278, funded by Yanga.
2024-04-12 00:29:10 +02:00
nmlgc 31411d7743 [Decompilation] [th02] Verdict screen: Score rendering
For once, I'm glad that ZUN copy-pasted this one-off function.
Otherwise, it probably wouldn't have been that easy to factor out.

Part of P0278, funded by Yanga.
2024-04-12 00:29:10 +02:00
nmlgc 962564db49 [Decompilation] [th02] Endings: Text file loading
Part of P0278, funded by Yanga.
2024-04-12 00:29:10 +02:00
nmlgc c96952f47b [Research] Discover how pointer constness affects pointer parameter codegen
In most cases, this discovery will mean that we have to bite the bullet
and remove `const` from pointer parameters if the generated ASM
wouldn't match otherwise. That by itself doesn't really simplify the
code, but at least we get to remove a single bloated `reinterpret_cast`
from one function call already.

Part of P0278, funded by Yanga.
2024-04-12 00:29:09 +02:00