Commit Graph

44 Commits

Author SHA1 Message Date
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 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 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 e7a9262f50 [Contributing] Remove trailing commas from `public` in a pre-commit hook
Starting more ore less simple with a shell script calling `sed`, which
should work anywhere Git is used.
2023-03-20 01:55:06 +01:00
nmlgc c22299e0c8 [Contributing] Introduce a new "ZUN landmine" label for invisible bugs
Thanks to Clerish for the naming inspiration:

	https://twitter.com/Clerish/status/1623990678937034752

Part of P0231, funded by [Anonymous].
2023-02-28 08:08:10 +01:00
nmlgc 3ba44f08a4 [Contributing] Document the `ZUN bloat`, `ZUN bug`, and `ZUN quirk` labels
In even more detail than we've previously had on the blog.

Part of P0231, funded by [Anonymous].
2023-02-28 08:07:53 +01:00
nmlgc 990588a4ea [Research] Finally figure out relativity of near references
Biggest decompilation breakthrough of the year already? Completely
removes the need for the "set near pointer to far function" hack, and
solves quite a few upcoming issues.
The TASM manuals did have a few pages on the topic of segments and
groups, but there's absolutely nothing about it in the TCC ones beyond
the three-sentence description of `#pragma codeseg` and that completely
unhelpful "🤷" of an explanation for the `Fixup overflow` error…

Part of P0227, funded by nrook.
2023-01-16 12:05:29 +01:00
nmlgc 944a66cf77 [Maintenance] [th04/th05] Bosses: Single-file, multi-segment code structure
As implied in adffa1c, a single segment-switching translation unit for
both rendering functions and game logic is the most straightforward
solution for those two games. Especially once you look at TH04, and
realize that the wildly chaotic order of the *_fg_render() functions in
the first code segment exactly matches the order of the *_update()
functions in the third.

Part of P0225, funded by Enderwolf, Blue Bolt, 32th System, and Yanga.
2022-11-30 22:46:22 +01:00
nmlgc 690b4df14b [Maintenance] Fix another bunch of accumulated typos and dead code
Part of P0216, funded by JonathKane.
2022-08-16 01:38:12 +02:00
nmlgc 386d9cd4cb [Contributing] Establish a more greppable convention for space-saving `union`s
How did I end up with x86 registers of all things?

Part of P0207, funded by GhostPhanom.
2022-08-08 20:10:47 +02:00
nmlgc 456768a4ff [Contributing] Define `struct`, `class` and `template` naming conventions
Again, these are what I've been mostly following, apart from a few
inconsistencies which this commit also fixes.

Part of P0207, funded by GhostPhanom.
2022-08-08 20:10:38 +02:00
nmlgc 3e79deeb3a [Contributing] Define function brace placement rules
I've been following them pretty consistently for a while now, time to
finally write them down.

Part of P0204, funded by [Anonymous] and Yanga.
2022-07-10 13:45:18 +02:00
nmlgc 719baa3a5e [Naming] [th04/th05] Dialog: Main function
The `_animate()` convention doesn't *really* fit for a function that
also handles input, but I'd rather continue using the same convention
for every blocking multi-frame function.

Part of P0186, funded by [Anonymous] and Blue Bolt.
2022-03-27 00:33:46 +01:00
nmlgc ff3d2cafe4 [Maintenance] Highlight dependencies on pseudoregisters with the `asm` keyword
These make up 41% of all our current inline ASM blocks, and *should*
break on other compilers.

Part of P0183, funded by Yanga and [Anonymous].
2022-02-18 09:36:34 +01:00
nmlgc ba9fe94b42 [Maintenance] Consistently use { brackets } for inline assembly
Part of P0183, funded by Yanga and [Anonymous].
2022-02-18 09:36:34 +01:00
nmlgc 6058395372 [Maintenance] Change the inline assembly keyword to `_asm`
The single underscore version is actually slightly more supported among
the compilers I've seen so far. Also added the exact list now.

Part of P0183, funded by Yanga and [Anonymous].
2022-02-18 09:36:34 +01:00
nmlgc 9c99bc0eb1 [Contributing] Don't enforce preservation of symbol names from leaked ZUN code
We can do much better ourselves.

Part of P0168, funded by Blue Bolt and rosenrose.
2021-11-28 21:51:28 +01:00
nmlgc a317cb49fc [Maintenance] Fix another bunch of accumulated typos
Part of P0161, funded by [Anonymous].
2021-10-09 23:26:02 +02:00
nmlgc 2406533713 [Contributing] Officially decide on UTF-8 as the default encoding
It's been like this since the beginning, I just hadn't written it down.
So yeah, sorry to everyone who likes to edit code in period correct
90's DOS terminal editors.

Part of P0141, funded by [Anonymous] and rosenrose.
2021-05-27 19:35:59 +02:00
nmlgc 0f75a77dee [Research] Discover a workaround to word-align code segments from Turbo C++
Turns out that this is one of the effects of the -WX option ("Create
DPMI application")… along with generally messing up code generation.
Nothing we can't work around though, luckily! Finally getting to cross
that off the list of reasons that prevent decompilation.

Part of P0137, funded by [Anonymous].
2021-04-03 20:19:41 +02:00
nmlgc 1244bd74e7 [Maintenance] Prefer the -zC and -zP options over `#pragma codeseg`
Might look uglier, but has the advantage of not generating an empty
segment with the default name… *and* the default padding, which will
really come in handy with the following breakthrough.

Part of P0137, funded by [Anonymous].
2021-04-03 20:12:09 +02:00
nmlgc 8bcf5d7b84 [Regression] Explicitly request 16-bit default segments when using .MODEL
Whoops, turns out that the build has been broken on TASM32 version 5.3
(the one in the DevKit) ever since 7897bf1. In contrast to version 5.0
(which I use for my development), 5.3 actually defines 32-bit segments
if you specify a .386 CPU before using .MODEL.

That might have been the reason for the .286 workaround all along?
Turns out there's the USE16 modifier, which makes this much more
explicit than switching CPUs.
2021-03-29 22:39:11 +02:00
nmlgc 0dcd0b8136 [Maintenance] Reimplement TASM's ARG directive for `MOV BX, SP` functions
`cPtrSize` is simply the wrong constant for calculating parameter
offsets on the stack, because it corresponds to the memory model's
default distance, not the function's distance. Luckily, ARG has a
RETURNS clause, and if you declare all parameters in there, ARG won't
emit that pesky and unnecessary `ENTER 0, 0` instruction. Big discovery
right there!
Sadly, ARG is unusable for ZUN's silly functions that keep the base
pointer in BX. TASM declares the resulting equates as `[BP+offset]`,
and it's apparently impossible to only get `offset` out of such an
equate later.

So, rather than staying with numbers, let's reimplement ARG for these
functions instead. This way, we can even abstract away the stack clear
size for the `RET` instructions.
It's a bit rough around the edges though, forcing you to explicitly
specify the function distance, and to pass the parameters in reverse
order compared to the C declaration (thankfully, all of these use the
PASCAL calling convention). It also doesn't work with more complex
types yet. But certainly better than numbers.

Part of P0134, funded by [Anonymous].
2021-02-20 23:50:00 +01:00
nmlgc 59fb8753bc [Maintenance] Only use the `far` keyword to declare intent
Part of P0134, funded by [Anonymous].
2021-02-20 15:47:30 +01:00
nmlgc 604b2c83ac [Maintenance] Avoid MK_FP() where possible
It's not necessary for assigning `__seg` pointers to `far` ones, which
might even remove the <dos.h> dependency in some translation units.

Part of P0134, funded by [Anonymous].
2021-02-20 15:47:00 +01: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 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 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 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 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 43c97ccaa1 [Maintenance] Decide on __asm as the keyword for inline assembly
Which works in both Borland C++, Open Watcom, and Visual C++.

Not that we're about to port any of the games to these compilers, just
something I noticed while evaluating 32-bit compilers for ReC98's own
32-bit pipeline tools. Modders might want to look into that though,
since 100% position independence also makes it easier to change
compilers.
2020-06-21 22:18:00 +02:00
nmlgc dd89843fae [Decompilation] [th01] Pellet rendering
So even TH01 wasn't 100% C++ after all. Turns out that this function
was the only instance in all of REIIDEN.EXE where ReC98 previously had
different encodings for identical x86 instructions.

Part of P0096, funded by Ember2528.
2020-06-13 21:11:53 +02:00
nmlgc 57a8487084 [Decompilation] [th01] FUUIN.EXE resident structure data retrieval
Completes P0094, funded by Yanga.
2020-05-25 15:22:53 +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 fdf2a45baf [Maintenance] Use *_CELS to denote the number of distinct animation sprites
Which are typically lower than the amount of *_FRAMES they're shown in.

Part of P0074, funded by Myles.
2020-02-16 21:41:28 +01:00
nmlgc 2bfd7be787 [Contributing] Document how to use TASM's interfaced function call syntax
And officially allow the stdcall workaround for __cdecl calls with
optimized stack cleanup.
2020-01-19 22:05:45 +01:00
nmlgc 3a2b26c370 [Contributing] BSS padding bytes should be rewritten into `evendata` 2020-01-19 20:17:26 +01:00
nmlgc 98e07ec5e1 [Contributing] Don't require declarations of internal symbols in header files 2020-01-15 20:25:15 +01:00
nmlgc 034ae4ba94 [Contributing] Padding bytes should be rewritten into `even` or `align` 2019-12-26 10:54:43 +01:00
nmlgc 7c80fb01f2 [Contributing] Establish how to cite ZUN's source code leaks 2019-11-24 14:14:13 +01:00
nmlgc e9453bffe0 [Contributing] Add a rule against decompiling self-modifying code
Will come up soon in TH03, actually.
2019-11-20 00:22:43 +01:00
nmlgc afbc7eb381 [Contributing] Add some welcoming words for new contributors
And the explicit permission to also do something as seemingly trivial
as naming functions or data on separate branches, which apparently
still needed to be said somewhere.
2019-11-20 00:22:26 +01:00
nmlgc c196cdb41e [Contributing] Fix a few minor typos and omissions 2019-11-19 23:09:36 +01:00
nmlgc b28cefc1c1 [Readme] Start a separate contribution guideline file 2019-11-04 22:33:53 +01:00