Commit Graph

73 Commits

Author SHA1 Message Date
nmlgc 9943f2f7ef [Reverse-engineering] [th03] Currently processed player ID
Probably going to refine those `pid_other` variables later; it almost
seems as if there's one to store the attacked player for every entity
type?

Part of P0070, funded by KirbyComment.
2020-01-19 22:11:01 +01:00
nmlgc 8924a4a0aa [Reverse-engineering] [th03] Current score manipulation
Little-endian BCD, again… Far less crazy than in TH04 and TH05,
though, thanks to updating and rendering being two different functions
here.

Part of P0070, funded by KirbyComment.
2020-01-19 22:10:11 +01:00
nmlgc 761a0f48a2 [Reverse-engineering] [th03] Five-digit powers of 10
Part of P0070, funded by KirbyComment.
2020-01-19 22:08:58 +01:00
wintiger0222 a93175828c [Reverse-engineering] [th03] In-game score font
More related to the TH05 Music Room piano label font than to the small
popup numbers --Nmlgc
2020-01-19 22:07:31 +01:00
nmlgc 0e19e52572 [Maintenance] Templatize RGB and palette types for 4- and 8-bit components
Right, PC-98 hardware only supports 4 bits per RGB component, for a
total of 4,096 possible colors. The 8-bit RGB color values we've been
seeing throughout the later games are a master.lib extension, to allow
for more toning precision. Which TH01, with all its NIH syndrome,
doesn't use.

And yup, that means templates in the most basic header files… Since
that would have meant renaming *everything* to compile as C++, I simply
made these types exclusive to C++ code, thcrap style.

Part of P0066, funded by Keyblade Wiedling Neko and Splashman.
2020-01-05 19:06:32 +01:00
nmlgc b5d56e5df2 [Reverse-engineering] [th03/th04/th05] Frame counters
Of which there are quite a lot!

Part of P0065, funded by Touhou Patch Center.
2020-01-03 21:30:02 +01:00
wintiger0222 87f2cd1103 [Maintenance] [th04/th05] Unused setup and Music Room data 2019-12-29 21:15:43 +01:00
nmlgc 80cec5b231 [Reverse-engineering] [th03] 1P/2P selection gaiji cursor
Part of P0064, funded by Touhou Patch Center.
2019-12-29 20:59:34 +01:00
nmlgc 765eae82e8 [Maintenance] [th05] Minimize #includes for the shot type translation units
Since a few annoying alignment bytes suggested more translation units
than previously expected, using many small headers has proved to be
better than one big shared TH04/TH05 header file. Or should we *really*
pepper the code with lots of `#pragma codestring`? 😛

And in case we have multiple translation units which all #include the
same set of headers, we'll just go with situational shared headers,
using a common prefix.

Part of P0062, funded by Touhou Patch Center.
2019-12-22 15:32:44 +01:00
nmlgc c5b07b746e [Maintenance] `#pragma once` has no effect?
Should have remembered this from all the times I've looked at the list
of #pragma directives supported by Turbo C++… Still, I would have at
least expected a warning, but not even the `ill` warning covers this.

Part of P0062, funded by Touhou Patch Center.
2019-12-22 15:31:24 +01:00
wintiger0222 1d6fbb8108 [Reverse-engineering] [th05] Masked PI display
As used for the title screen fade-in effect. Another function that
apparently was deliberately written to run not that fast, by blitting
each row individually to the 400th VRAM row just so that it can then
turn on the EGC, perform the *actual* masked blit to the VRAM
destination, and then turn the EGC off before moving to the next now.
The same effect could have entirely been accomplished by copying
graph_pack_put_8() and applying the mask there; it's not like ZUN
didn't know how to modify master.lib…

(See also 44ad3eb4) --Nmlgc
2019-12-17 23:27:02 +01:00
nmlgc 75a779e82a [Maintenance] Clean up PI function declarations and comments 2019-12-17 23:27:01 +01:00
nmlgc deb1b73016 [Maintenance] Use a single DEFCONV definition file to cover all games
This makes a lot more sense in C land, where we can then #include this
tiny file in front of all DEFCONV declarations.
2019-12-17 23:27:01 +01:00
wintiger0222 04f0491885 [Naming] [th03/th04/th05] .cfg file functions 2019-12-17 23:27:00 +01:00
nmlgc 9cb6cc527a [Decompilation] Finally declare <stdint.h> types
*Finally*. We already used `(unsigned) int` in quite a few places where
we actually want a 16-bit value, which was bound to annoy future port
developers.
2019-12-17 23:26:58 +01:00
wintiger0222 0dcfc445b8 [Reverse-engineering] [th03] input_wait_for_ok_or_measure()
Moving this into hardware/, since we already have an
input_wait_for_change() function there. --Nmlgc
2019-12-17 23:26:58 +01:00
wintiger0222 590436dfa8 [Reduction] [th03] graph_putsa_fx
Fine, let's drag that ASM slice along, instead of immediately reusing
the already decompiled TH02 version… The website really needs a
decompilation metric soon, anyway. --Nmlgc
2019-12-17 23:26:58 +01:00
wintiger0222 c0705c395c [Naming] [th03/th04/th05] Music Room functions changed from TH02 2019-12-17 23:26:57 +01:00
wintiger0222 9684cf5312 [Reduction] [th03] Music Room comment back buffer
I think cmt_back_* type functions need more universal name
Because at th04 and th05, it used in zunsoft opening animation
--WindowsTiger

And in MAINE.EXE. So I agree for TH04 and TH05, but TH03 still only
allocates, snaps, and recovers only the VRAM area occupied by the music
comments. --Nmlgc
2019-12-17 23:26:56 +01:00
wintiger0222 811ba84e3f [Reverse-engineering] [th03/th04/th05] snd_delay_until_measure 2019-12-17 22:44:27 +01:00
nmlgc 5f4f5d87dc [Decompilation] [th03] Shot update and render functions
Meh, can't overload arithmetic operators that take a Subpixel without
generating a needless load and store, even with -Z. But heck, slightly
uglifying subpixel/subpixel arithmetic is exactly the right trade-off.

Completes P0061, funded by Touhou Patch Center.
2019-12-05 21:41:31 +01:00
nmlgc 5c1a864432 [Reverse-engineering] [th03] Shot pair structure
Yup, one structure instance describes one *pair* of shot sprites in
TH03.

Part of P0061, funded by Touhou Patch Center.
2019-12-05 21:38:32 +01:00
nmlgc 296f9f61c2 [Reverse-engineering] [th03] Playfield shaking
Which only applies to the set of sprites considered to be in the
foreground, so no EGC acceleration.

Part of P0061, funded by Touhou Patch Center.
2019-12-05 21:36:02 +01:00
nmlgc 4030ef737a [Reverse-engineering] [th03] Character movement and gauge charge speeds
Part of P0061, funded by Touhou Patch Center.
2019-12-05 21:35:02 +01:00
nmlgc 4d3d6acd28 [Decompilation] Templatize subpixels to offer both 16-bit and 8-bit variants
Yup, TH03 actually uses a 4.4 fixed-point format.

Part of P0061, funded by Touhou Patch Center.
2019-12-05 21:27:53 +01:00
nmlgc bb6b0f1cc3 [Maintenance] Move the Subpixel class to a separate header, under TH03
Part of P0061, funded by Touhou Patch Center.
2019-12-05 21:21:56 +01:00
nmlgc 04d24ccf1c [Reverse-engineering] [th03] Character IDs
Part of P0061, funded by Touhou Patch Center.
2019-12-05 21:21:49 +01:00
nmlgc 30e6b7c3db [Maintenance] Correctly declare all input functions
The pascal calling convention for TH03's input mode functions actually
sort of matters, since we have this nice function pointer type that
expects pascal.
2019-11-30 19:34:55 +01:00
nmlgc 73f5ae79a0 [Reverse-engineering] [th03] Demo frame counter
My dumb parser identified this as a reference to the PI header slots,
which is why it's here now!

Completes P0060, funded by Touhou Patch Center.
2019-11-28 23:23:30 +01:00
nmlgc b6e0330ff6 [Decompilation] [th03] Sprite display calls
Yes, decompilation, of something that was so obviously originally
written in ASM. We're still left with two un-decompilable instructions
here, but I'm amazed at how nicely I was able to abstract away all of
the gory register details, leading to pretty clear, readable, and dare
I say *portable* code?! Turbo C++ was once again pretty helpful here:

• `static_cast<char>(_BX) = _AL` actually compiles into `MOV BL, AL`,
  as you would have intended,
• and no-op assignments like _DI = _DI are optimized away, allowing
  us to leave them in for clarity, so that we can have all parameter
  assignments for the SPRITE16 display call in a single place.

I love this compiler.

Part of P0060, funded by Touhou Patch Center.
2019-11-28 23:14:21 +01:00
nmlgc 2269d0c29c [Reverse-engineering] [th03] Playfield sprite clipping coordinates
Part of P0060, funded by Touhou Patch Center.
2019-11-28 23:12:10 +01:00
nmlgc 71c737c4ee [Maintenance] Move DOS memory assignment sizes to separate files
Ideally, these could be calculated from some other game-specific
parameters? Anyone else who wants to look into this?
2019-11-24 14:04:36 +01:00
nmlgc 8b627803a3 [Position independence] Vector calls and variables
Raw, uninteresting position independence work. Or maybe not, given that
this was one of the few things that also apply to TH01, and reveal just
how chaotically this game was coded. And so we've got three ways that
ZUN stored regular 2D points: Regularly (X first, Y second), Y first
and X second, and multiple points stored in a structure of arrays…

Completes P0059, funded by [Anonymous] and -Tom-.
2019-11-18 22:24:24 +01:00
nmlgc c09446a1f4 [Reverse-engineering] [th03] SPRITE16 calls
Aha! TH03's in-game graphics run in line-doubled 640×200 simply because
that's what this SPRITE16.COM version was written for, making use of
the PC-98 EGC for optimized blitting.

Doesn't seem all *too* optimized though, given that it chooses to
effectively draw every sprite twice, just in case it might overlap with
something that's already in VRAM. It first clears the previous VRAM
content at the drawing position according to the sprite's alpha mask,
then ORs in the actual sprite data. The EGC can do monochrome alpha-
tested blitting just as well as the GRCG, but once the sprite data
covers all bitplanes, ORing is apparently the best it can do by itself?
More technical details on the raster operations in the next push!

Completes P0056, funded by rosenrose and [Anonymous].
2019-11-06 23:36:47 +01:00
nmlgc db4de240e9 [Decompilation] Prepare the C side for the shot type control functions
That should make this convoluted copypasta a bit easier to read. And
sure, I could have done something about the loop as well, but
SHOT_FUNC_INIT already hides enough control flow behind a macro…

Part of P0037, funded by zorg.
2019-10-14 23:42:20 +02:00
nmlgc e65cf0d05d [Maintenance] Change a few ASM .inc files to use 8.3 names
Part of P0035, funded by zorg.
2019-09-24 21:58:18 +02:00
nmlgc f8213c5a32 [Reverse-engineering] [th04/th05] HUD bar display
So it's *_put(), inherited from master.lib, for everything just writing
to text RAM, and *_render() for everything more involved? But what
about master.lib's own graphics RAM functions like super_put()? Need to
fix that inconsistency some day.

Once again no decompilation, because…

Part of P0033, funded by zorg.
2019-09-21 14:01:50 +02:00
nmlgc f07089017f [Maintenance] Rename the extension of game-specific ASM includes to .inc
Rule of thumb going forward: Everything that emits data is .asm,
everything that doesn't is .inc.
(Let's hope that th01_reiiden_2.inc won't exist for that much longer!)

Part of P0032, funded by zorg.
2019-09-21 13:03:56 +02:00
nmlgc dea40ad770 [Decompilation] [th05] Stage setup
"Yeah, let's do this real quick, how can this possibly be hard, it's
just MOVs and a few function calls"…

…except that these MOVs access quite a lot of data, which we now all
have to declare in the C world, hooray.
Once it came to midbosses and bosses, I just turned them into C structs
after all. Despite what I said in 260edd8… after all, the ASM world
doesn't care about the representation in the C world, so they don't
necessarily have to be the same.

Since these structs can't contain everything related to midbosses and
bosses (really, why did all those variables have to be spread out like
this, ZUN?), it also made for a nice occasion to continue the "stuff"
naming scheme, describing "an obviously incomplete collection of
variables related to a thing", first seen in 160d4eb.

Also, PROCDESC apparently is the only syntactically correct option to
declare an extern near proc?

Also, that `boss_phase_timed_out` variable only needs to be here
already because TCC enforces word alignment for the .data segment…
yeah, it's technically not related to this commit, but why waste time
working around it if we can just include that one variable.

Completes P0030, funded by zorg.
2019-09-15 20:35:15 +02:00
nmlgc 0abf84f450 [Maintenance] Add a few missing exports
Part of P0030, funded by zorg.
2019-09-15 20:29:52 +02:00
nmlgc 3b7561a711 [Maintenance] Export all pascal functions with their proper uppercase names
Yup, that was one massive screw-up.

Part of P0030, funded by zorg.
2019-09-15 20:29:47 +02:00
nmlgc e10502bfe6 [Maintenance] Fix the function name format of CDG/CD2 functions
No leading underscore for functions with Pascal calling convention, but
we do have one for all variables, because it's not worth it to put
keywords in front of everything for no reason.
Seemed to have forgotten this rule in 2017?

Part of P0030, funded by zorg.
2019-09-15 20:29:40 +02:00
nmlgc 1cb2c0acbc [Reverse-engineering] [th03/th04/th05] Palette change flag
Funded by -Tom-.
2019-03-03 13:32:55 +01:00
nmlgc d7483c09cc [Maintenance] Fix the TASM32 crash when assembling th03_mainl.asm
Right, the last path component in an INCLUDE file name is "limited" to 28
bytes. Turns out it only crashes on every system that *isn't* the main one I
develop on, though…
2018-12-04 19:55:18 +01:00
nmlgc 01a430d027 [Reverse-engineering] [th03/mainl] CDG line removal for upwards motion
Not *really* CDG-related, but it does use CDG slot data, and is easy
enough to be covered right now…

Funded by DTM.
2018-10-16 01:04:46 +02:00
nmlgc 4bc6da4858 [Reverse-engineering] [th03/mainl] Dissolved CDG display
Depending on two variables that… uh, aren't exactly related to this
function? Let's wait with those until we get there.

Funded by DTM.
2018-10-16 01:04:46 +02:00
nmlgc 850b8d783c [Reverse-engineering] [th03/mainl] CDG freeing
Funded by DTM.
2018-10-16 01:04:46 +02:00
nmlgc 18ae3e5cca [Reverse-engineering] [th03] Horizontally flipped CDG display 2018-10-16 01:04:46 +02:00
nmlgc 4b8d0931b9 [Reverse-engineering] [th03] Non-alpha CDG display 2018-10-16 01:04:46 +02:00
nmlgc df768ebea6 [Reverse-engineering] [th03] Normal CDG display 2018-10-16 01:04:43 +02:00