Commit Graph

2619 Commits

Author SHA1 Message Date
nmlgc 3b46fd9138 [Maintenance] [th04/th05] Move `PlayfieldPoint` into TH04's playfield header
It has a hidden dependency on TH04's scroll functions, and TH02 seems
to use screen coordinates throughout.

Part of P0284, funded by [Anonymous] and Blue Bolt.
2024-07-09 08:41:37 +02:00
nmlgc 15f89da4ee [Maintenance] master.hpp: Split off all PC-98 graphics-related declarations
Part of P0284, funded by [Anonymous] and Blue Bolt.
2024-07-09 08:41:33 +02:00
nmlgc f92936f9bb [Maintenance] master.hpp: Move memory model definitions into a separate header
Part of P0284, funded by [Anonymous] and Blue Bolt.
2024-07-09 08:41:29 +02:00
nmlgc 3fad323d14 [Maintenance] master.hpp: Move into the master.lib directory
With the upcoming `#include` cleanup, it finally makes sense to split
off all graphics-related code into its own header. In turn, it makes
more sense to store all of these future master.lib headers in, well,
the master.lib directory, which provides a new 8 characters for their
file names. Turns out that the rationale I gave for the root directory
placement in 8266bbd didn't hold up 3½ years later…
(Also, the `pc98.h` declarations will eventually be split into
`game/coords.hpp` and something in `platform/x86real/pc98/`.)

Part of P0284, funded by [Anonymous] and Blue Bolt.
2024-07-09 08:41:24 +02:00
nmlgc a9c3825ce3 [Maintenance] master.hpp: Remove `egc_selectpat()` and `egc_setrop()`
egc_setrop() delivers nothing of value, just obscures the single thing
it does, and disrupts the visual flow of the code.
egc_selectpat() isn't much better, is used a total of two times, says
almost nothing from its name alone, and MASTER.MAN's documentation adds
so little of value that you'd want to consult hardware documentation
anyway once you try to understand it.
Not to mention that both add a dependency on master.hpp for what are
actually PC-98 hardware constants.

Part of P0284, funded by [Anonymous] and Blue Bolt.
2024-07-09 08:41:19 +02:00
nmlgc bb419fa649 [Maintenance] [th04/th05] OP.EXE: Move page synchronization into its own header
Three `#include`s for such a small function… (And soon it's going to be
4!)

Part of P0284, funded by [Anonymous] and Blue Bolt.
2024-07-09 08:41:15 +02:00
nmlgc c95323c259 [Maintenance] Packfiles: Declare file name length in a separate header
The upcoming `#include` cleanup is going to spell out all implicit
dependencies of every header file. This would
• `#include "master.hpp"` in every header that uses `PF_FN_LEN`, and
• `#include "pc98.h"` in `master.hpp`, adding lots of graphics
  declarations to translation units that don't need them.

Moving `PF_FN_LEN` to its own file not only avoids needless inclusions
of `master.hpp` and all of its future dependencies later, but already
removes `master.hpp` from 6 translation units – not to mention that we
no longer need to preprocessor-guard some of the usages of `PF_FN_LEN`.

Part of P0284, funded by [Anonymous] and Blue Bolt.
2024-07-09 08:41:08 +02:00
nmlgc 1aff43bca6 [Maintenance] Spell out master.lib's RNG functions
`irand()` and `rand()` are only identical on Borland compilers. The
specific RNG implementation is an integral part of the original game
logic, so we actually never want to use the generic libc `rand()`. Any
future replays recorded on PC-98 builds should play back identically on
whatever system we port the games to, after all.

Part of P0284, funded by [Anonymous] and Blue Bolt.
2024-07-09 08:41:04 +02:00
nmlgc 7b6984b9ad [Maintenance] [th04/th05] ZUN Soft logo: Move private declarations to the .cpp
Part of P0284, funded by [Anonymous] and Blue Bolt.
2024-07-09 08:41:00 +02:00
nmlgc 110d0534ed [Maintenance] Move `extern "C"` into the headers it applies to
The translation units were probably a better place back when most of
the codebase was still compiled in C mode, we only had a few C++ TUs,
almost everything needed to be declared as `extern "C"`, and moving
these declarations into the headers would have been really noisy with
all the `#ifdef __cplusplus` / `#endif` required. Nowadays though,
we've greatly reduced that surface area. And given that headers will
include even more headers as part of the upcoming `#include` cleanup,
it makes sense to make the jump now.

Part of P0284, funded by [Anonymous] and Blue Bolt.
2024-07-09 08:40:49 +02:00
nmlgc c85c0e2483 [Maintenance] Remove `extern "C"` from more areas of code
Much more than usual, now that we've got a snappy build system! This
commit covers
• All .PI functions across all games
• TH02's High Score entry functions
• TH03's shots_update() and shots_render()
• All functions declared in `th04/op/op.hpp`
• TH04/TH05's bb_txt_put_8_raw(), bullet_template_clip(),
  player_pos_update_and_clamp(), score_update_and_render(), and
  slowdown_frame_delay()
• TH05's reimu_stars_update_and_render(), score_delta_commit(),
  stage2_invalidate(), stage2_update(), and space_window_set()

Part of P0284, funded by [Anonymous] and Blue Bolt.
2024-07-09 08:40:43 +02:00
nmlgc 6629d7cb8a [Maintenance] [th04/th05] Turn the SFT2.CDG sanity check into a `static_assert`
Borland's C preprocessor does not track enum values, so this check
always failed when running the code through just `CPP.EXE`.

Part of P0284, funded by [Anonymous] and Blue Bolt.
2024-07-09 08:40:39 +02:00
nmlgc f7c37b500a [Maintenance] [th03] Music Room: Remove the ASM version of comment rendering
Should have been removed in 78728f6.

Part of P0284, funded by [Anonymous] and Blue Bolt.
2024-07-09 08:40:35 +02:00
nmlgc 17a50c7c16 [Maintenance] [th01/th02/th03] graph_putsa_fx: Fix bracketing in FX_SPACING
Which no one ever noticed because this macro is unused.

Part of P0284, funded by [Anonymous] and Blue Bolt.
2024-07-09 08:40:31 +02:00
nmlgc ccc2b541fe [Maintenance] [th01] Pellets: Move documentation and types into `pellet_s.hpp`
Everything related to the definition concept should be in one place.
The resident structure is merely where it's all stored, and the
`debloated` branch will get rid of that structure eventually.

Part of P0284, funded by [Anonymous] and Blue Bolt.
2024-07-09 08:40:27 +02:00
nmlgc d1708c6fe9 [Maintenance] [th01] Declare score types in `score.h`
Yeah, why weren't they?!

Part of P0284, funded by [Anonymous] and Blue Bolt.
2024-07-09 08:40:23 +02:00
nmlgc 975787676e [Maintenance] Move PC-98 keyboard constants into the platform layer
Part of P0284, funded by [Anonymous] and Blue Bolt.
2024-07-09 08:40:18 +02:00
nmlgc 1bc91fd93b [Maintenance] Move the `grcg_off` macro override into an explicit header
Not only would the `(GAME != 2)` need to include TH03 in the future,
but this `#undef` trickery will blow up once we start reorganizing the
`#include`s in the next few commits.
Sadly, a few source files use master.lib's grcg_off() function in one
game and the macro in the other, which makes it infeasible to assign a
distinct name for every function.

Part of P0284, funded by [Anonymous] and Blue Bolt.
2024-07-09 08:40:14 +02:00
nmlgc cc01af3e57 [Readme] Define support tiers for build platforms
Part of P0284, funded by [Anonymous] and Blue Bolt.
2024-07-09 08:40:10 +02:00
nmlgc f7b257aa61 [Build] Mention that Turbo C++ 4.0J must be placed into a legacy codepage path
MS-DOS Player translates long names to the 8.3 format via
GetShortPathNameA(), but it fundamentally can't do Unicode.

Part of P0284, funded by [Anonymous] and Blue Bolt.
2024-07-09 08:40:06 +02:00
nmlgc fa5c820fbe [Build] Display the current PATH if a tool can't be found
Especially helpful on Linux where there's the Linux-native `PATH`, the
completely unrelated `PATH` inside Wine, and `WINEPATH` to prefill the
latter from the former.

Part of P0284, funded by [Anonymous] and Blue Bolt.
2024-07-09 08:39:37 +02:00
nmlgc 62bd5b127c [Build] Remove the last remnants of the 16-bit build part
Creates at least somewhat of a better diff than if we had renamed the
batch file two commits ago.

Now that we invoke TLINK ourselves, the `tlink.exe` error can no longer
appear. Since it did take a few hours to RE this back in 624e0cb, I've
preserved the section at a more dedicated place, at

	https://gist.github.com/nmlgc/6229345c74d1a7d3c6c1b3e988beb0e9

It will also be spelled out in the blog post of this delivery.

Completes P0004, funded by GhostPhanom.
2024-07-09 08:38:39 +02:00
nmlgc 620d9cedcf [Build] Merge the research code into the Tupfile
I considered disabling it by default and only enabling it through an
optional `CONFIG_RESEARCH` variable, but that turned out to be too
annoying and inconsistent when `build_dumb.bat` generation came into
play.

Part of P0004, funded by GhostPhanom.
2024-07-09 08:38:39 +02:00
nmlgc 528a63a42e [Build] Merge the entire 16-bit build part into the Tupfile
Part of P0004, funded by GhostPhanom.
2024-07-09 08:38:39 +02:00
nmlgc 0109bc6aa3 [Build] Compile bmp2arr with Turbo C++, using MS-DOS Player on 64-bit systems
Yup, no more 32-bit C++ compiler required!

Part of P0004, funded by GhostPhanom.
2024-07-09 08:38:39 +02:00
nmlgc c5290c0c30 [Build] Move the TCC and TLINK checks to the 32-bit build part
Part of P0004, funded by GhostPhanom.
2024-07-09 08:38:39 +02:00
nmlgc b86a2b1119 [Build] Rules: Properly split TLINK response file `echo` commands
Completes P0283, funded by [Anonymous].
2024-07-09 08:38:28 +02:00
nmlgc 816f3a083a [Build] Rules: Split long `echo` lines at Windows 9x limits
I have no words.

Part of P0283, funded by [Anonymous].
2024-07-09 08:38:23 +02:00
nmlgc 056085b478 [Build] Rules: Batch TCC invocations with identical command lines
Compiling as many source files as possible within a single TCC process
is the single most important build time optimization we can do. Sadly,
it won't work with Tup's parallel nature, but it can really shine in a
dumb batch build. This is the reason why Windows 9x can compile this
entire codebase on a single core in half the time it takes MS-DOS
Player to do the same on 64-bit Windows, on the same hardware.

That weird double-spacing, however, is the most ridiculous workaround
for a bug I have seen in a long while…

Completes P0282, funded by [Anonymous].
2024-07-09 02:46:55 +02:00
nmlgc dd129f4f6f [Build] Rules: Add output directory creation to the dumb batch file
`tup generate` does this as well, but only emits the `mkdir` calls for
the directories that are missing in the current working tree, requiring
a clean checkout to actually emit all necessary ones. This is much more
convenient.

Part of P0282, funded by [Anonymous].
2024-07-09 02:46:55 +02:00
nmlgc b59ee0bb5f [Build] Skip `tup parse` invocation if the Tupfile didn't change
Saving some additional milliseconds.

Part of P0282, funded by [Anonymous].
2024-07-09 02:46:55 +02:00
nmlgc 6842b64f5c [Build] Reimplement `tup generate` in Lua and Batch
Part of P0282, funded by [Anonymous].
2024-07-09 02:46:55 +02:00
nmlgc d60fb3e66d [Build] Bundle Tup
Yup, a 64-bit build. 32-bit Tup won't make sense going forward because
it can neither inject into a 64-bit MS-DOS Player nor into 16-bit DOS
build tools.

Completes P0003, funded by GhostPhanom.
2024-07-09 02:46:52 +02:00
nmlgc 3a0ff449a5 [Build] Bundle a performance-optimized version of MS-DOS Player
Part of P0003, funded by GhostPhanom.
2024-07-06 18:33:24 +02:00
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