Commit Graph

845 Commits

Author SHA1 Message Date
nmlgc 2200c77e60 [Maintenance] Fix another bunch of accumulated typos
Part of P0285, funded by [Anonymous] and iruleatgames.
2024-07-09 08:46:59 +02:00
nmlgc e0eb5cb1be [Maintenance] Turn `vram_offset_divmul` into a template
Has been on the todo list of small features for over two years.

Part of P0285, funded by [Anonymous] and iruleatgames.
2024-07-09 08:46:55 +02:00
nmlgc 1e41fa0617 [Maintenance] Remove redundant `#include`s
Part of P0285, funded by [Anonymous] and iruleatgames.
2024-07-09 08:46:51 +02:00
nmlgc b61e612fdf [Maintenance] #include each header's dependencies within the header itself
OK, this is the big one. We still keep using `#include` guards only
where we absolutely need to, but with each header now being valid in
isolation, this can now actually help *minimize* the length of each
translation unit's `#include` list. Turns out that after removing all
the duplicates, we only *actually* need to guard 29 headers across all
5 games.

Part of P0285, funded by [Anonymous] and iruleatgames.
2024-07-09 08:46:42 +02:00
nmlgc 8a63c2ae53 [Maintenance] Hidden #include dependency removal: TH01
Part of P0284, funded by [Anonymous] and Blue Bolt.
2024-07-09 08:42:17 +02:00
nmlgc 7c0f05f735 [Maintenance] Hidden #include dependency removal: Rank
Part of P0284, funded by [Anonymous] and Blue Bolt.
2024-07-09 08:42:13 +02:00
nmlgc dba448965e [Maintenance] Hidden #include dependency removal: Subpixels
Part of P0284, funded by [Anonymous] and Blue Bolt.
2024-07-09 08:42:09 +02:00
nmlgc d625833696 [Maintenance] Hidden #include dependency removal: Global headers
Part of P0284, funded by [Anonymous] and Blue Bolt.
2024-07-09 08:42:02 +02:00
nmlgc b44c74886e [Maintenance] EGC: Move implementation macros into a separate header
Avoids the `decomp.hpp` dependency in `th01/hardware/egc.h`.

Part of P0284, funded by [Anonymous] and Blue Bolt.
2024-07-09 08:41:54 +02:00
nmlgc dda1af97ea [Maintenance] [th01] .PTN: Move data declarations into a separate header
These declarations (and the associated `planar.h` dependency) are
needed by a lot fewer translation units than the rest of `ptn.hpp`.

Part of P0284, funded by [Anonymous] and Blue Bolt.
2024-07-09 08:41:50 +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 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 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 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 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 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 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 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 ddaf8c9495 [Decompilation] [th02] Endings / Staff roll: Picture blitting
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
nmlgc e4ff9dae97 [Maintenance] Cutscenes: Centrally define picture coordinates
Part of P0278, funded by Yanga.
2024-04-12 00:29:09 +02:00
nmlgc 2181fa22ba [Maintenance] [th02] graph_putsa_fx(): Explicitly declare as `extern "C"`
Needed for a constness overloading hack later. A certain single place
in TH02 will need the `str` parameter to not be `const` for code
generation reasons, but we don't want to force every call site into
passing non-`const` pointers for such a silly reason.

Part of P0278, funded by Yanga.
2024-04-12 00:29:09 +02:00
nmlgc 2480c76a56 [Naming] [th04/th05] MAINE.EXE: Top-level menu and scene functions
Also formalizing the `*_menu()` naming convention I've been following
for a while.

Part of P0265, funded by [Anonymous] and iruleatgames.
2024-02-03 08:59:48 +01:00
nmlgc cb7fd94789 [Decompilation] [th03/th04/th05] Music Room: Falling polygon animation
Part of P0264, funded by [Anonymous] and Blue Bolt.
2024-02-03 08:59:47 +01:00
nmlgc 062aa7ae1d [Maintenance] Purge the C-style `typedef struct` syntax
I might change this convention again in the future, particularly once
someone wants to fund C89 conformance, but let's stay consistent for
now.

Part of P0264, funded by [Anonymous] and Blue Bolt.
2024-02-02 23:59:34 +01:00
nmlgc c6c07e2c4d [Decompilation] [th04/th05] Main menu: Option menu update/render function
Part of P0262, funded by [Anonymous] and Blue Bolt.
2023-11-30 19:43:53 +01:00
nmlgc f294ccb158 [Naming] [th04/th05] Rename the initial rank value to highlight its effect
`RANK_DEFAULT` raised the question why ZUN just didn't directly assign
the apparent default of `RANK_NORMAL`. Turns out that this is what
triggers the first-launch setup menu.

Part of P0262, funded by [Anonymous] and Blue Bolt.
2023-11-30 19:16:56 +01:00
nmlgc 214c404ef5 [Maintenance] Introduce a type for PC-98 text RAM attributes
No need for signed variants this time!

Part of P0262, funded by [Anonymous] and Blue Bolt.
2023-11-30 18:47:20 +01:00
nmlgc a874bd5408 [Decompilation] [th03] Win screen: Message rendering
A separate function just for the text? How gracious. As if it was
architected for translatability.

Part of P0261, funded by [Anonymous] and Yanga.
2023-11-01 23:17:52 +01:00
nmlgc 5876755977 [Maintenance] [th01] YuugenMagan: Turn the Phase 12 pentagram values into a bug
Part of P0245, funded by [Anonymous], Blue Bolt, Ember2528, and Yanga.
2023-07-01 05:22:23 +02:00
nmlgc 0ffa756cae [Contributing] Decide on `seg` and `off` for x86-segment-related identifiers
I could have equally argued the opposite way, and in favor of `sgm` and
`ofs`, but I've also been using `seg` and `off` more prevalently
throughout the years.

Part of P0245, funded by [Anonymous], Blue Bolt, Ember2528, and Yanga.
2023-06-30 19:59:11 +02:00
nmlgc 8943b52167 [Maintenance] Introduce types for VRAM colors and their components
Finally differentiating between colors and columns at least at the type
level.

Part of P0245, funded by [Anonymous], Blue Bolt, Ember2528, and Yanga.
2023-06-30 19:59:11 +02:00
nmlgc f6757d90ea [Maintenance] Simplify vector-related header inclusions
Part of P0244, funded by Blue Bolt and [Anonymous].
2023-06-10 18:34:16 +02:00
nmlgc 9aad9ad114 [Maintenance] Declare 8-bit pixel delta and length types
Part of P0242, funded by Yanga.
2023-06-06 21:02:47 +02:00
nmlgc be69ab6265 [Research] [th01] Document the bug that causes `game s` to work
Because it shouldn't. Thanks to mu021 for bringing this to my
attention!

Part of P0239, funded by Ember2528.
2023-04-30 17:12:57 +02:00
nmlgc 308b6bcd2c [Maintenance] [th01] Endings: Reclassify the ドカーン image tearing issue as a bug
And explicitly define observability in terms of an infinitely fast
PC-98. That's the only reasonable assumption to make when considering
ports to faster architectures that aren't bottlenecked by disappointing
blitter chips.

Part of P0239, funded by Ember2528.
2023-04-30 17:12:47 +02:00
nmlgc 0b13967de3 [Maintenance] [th01] Add some missing detail to existing comments
Part of P0239, funded by Ember2528.
2023-04-28 22:21:26 +02:00
nmlgc 45c9e71533 [Maintenance] Fix another bunch of accumulated typos and dead code
Part of P0239, funded by Ember2528.
2023-04-28 22:21:21 +02:00
nmlgc 172a6d2b2b [Maintenance] Add a macro for alternate-instruction VRAM offset calculations
Part of P0235, funded by Ember2528.
2023-03-29 12:36:54 +02:00
nmlgc f062e4b84e [Decompilation] Add a macro for faster VRAM offset calculation with bit shifts
Part of P0235, funded by Ember2528.
2023-03-25 21:28:15 +01:00
nmlgc 3afb73eada [Reverse-engineering] [th01] Pellets: Document missing resets for delay clouds
The exact reason why pellets can be carried over from Sariel's first
form to her second… and why you probably shouldn't carelessly use that
redundant count of alive pellets to skip loops in the Anniversary
Edition, because that count will be incorrect after a reset.
Thanks to mu021 for reporting this issue!
2023-03-14 00:18:23 +01:00
nmlgc 6370f96d9a [Reverse-engineering] [th01] Pellets: Correctly document interlacing
It *does* affect collision detection after all, making removal for the
Anniversary Edition slightly more tricky.

Part of P0234, funded by Ember2528.
2023-03-04 19:40:55 +01:00
nmlgc 6713b1bf9c [Maintenance] [th01] 16× TRAM letters: Fix macro copy-pasting accidents
Part of P0234, funded by Ember2528.
2023-03-04 19:40:55 +01:00
nmlgc abeaf851a4 [Platform] [PC-98] EGC rectangle copies
Yup, unaligned! The prefilling case is quite broken on T98-Next, but
given that this emulator hasn't seen any development since 2010 and
every other emulator gets it right, we can reasonably assume that to be
a bug in that emulator.

Completes P0232, funded by [Anonymous].
2023-03-04 19:40:55 +01:00