Commit Graph

150 Commits

Author SHA1 Message Date
nmlgc a84fa33beb [Reverse-engineering] [th04/th05] Player shot cycle counter
Part of P0036, funded by zorg.
2019-10-14 23:42:02 +02:00
nmlgc f33a3ef220 [Maintenance] [th04/th05] Separate constant for the player↔option distance
Used in pretty much all shot type control functions.

Part of P0036, funded by zorg.
2019-10-14 23:41:57 +02:00
nmlgc b801d24a34 [Reverse-engineering] [th04/th05] Setting the player shot velocity
The TH05 difference: A ridiculous out-of-bounds structure field access.
Could have done safely by just passing a shot_t*, but ZUN's too cool
for that?

Also, about time we started putting the function prototypes directly
into the C headers, and the C headers *only*, upon reverse-engineering…

Part of P0036, funded by zorg.
2019-10-14 23:41:52 +02:00
nmlgc 5ebbe7bda9 [Maintenance] Move all shot-related slices to the player/ subdirectory
It seems that the main th0?/ directories should only contain actual
translation units (of which there are more than previously assumed)
as well as other not really further classifiable slices?

Part of P0036, funded by zorg.
2019-10-14 23:41:46 +02:00
nmlgc a533b5d3ea [Reverse-engineering] [th04/th05] Player sprite area invalidation
And once again, the TH05 version is un-decompilable. :/ It was pretty
close this time, though, as the entire block between PUSH DI and POP DI
kind of resembles a separate inlined function, in accordance with Turbo
C++'s  automatic backup of the DI register, as researched in 7f971a0.

Except that it contains a loop, and Turbo C++ refuses to inline any
function with `do`, `while`, `for`, or `goto`. If it didn't, it would
have totally worked.

Also, yes, C++ class methods are treated identically in this regard.

Oh well. Shot type control functions next, finally!

Completes P0035, funded by zorg.
2019-09-24 22:04:26 +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 290935fe3e [Reverse-engineering] [th04/th05] Player character display
Including options and the death explosions.

Part of P0035, funded by zorg.
2019-09-24 21:58:09 +02:00
nmlgc 6f1f36722f [Reverse-engineering] [th01/th02/th04/th05] Player invincibility frames
Completes P0034, funded by zorg.
2019-09-24 21:57:53 +02:00
nmlgc c77a9276d3 [Reverse-engineering] [th04/th05] Death-related variables
Including the confirmation that both games have an 8-frame deathbomb
window.
The placement of the variables is all over the place though, what the
hell?

Part of P0034, funded by zorg.
2019-09-24 21:57:46 +02:00
nmlgc 881f2c671e [Reverse-engineering] [th04/th05] Player option position
They are supposed to lag behind the player's movement by one frame, and
therefore have to be tracked separately.

I would have also included TH02, if it weren't for the weird sprite
indirection system (not storing X and Y positions directly in the
structure, but taking them from a buffer, with their addresses
always changing, WTF?!) that absolutely needs separate attention.

Part of P0034, funded by zorg.
2019-09-24 21:57:35 +02:00
nmlgc b7d204aeec [Reverse-engineering] [th02/th04/th05] Player option sprite number
Part of P0034, funded by zorg.
2019-09-24 21:57:29 +02:00
nmlgc 0b542125a5 [Decompilation] [th04/th05] Remove the Subpixel constructors
They just create unnecessary code when passing Subpixels by value to
functions.

Part of P0034, funded by zorg.
2019-09-24 21:57:23 +02:00
nmlgc 6cdd2296bb [Reverse-engineering] [th04/th05] Input → player movement
Completes P0033, funded by zorg.
2019-09-21 14:01:51 +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 e6294c2c1a [Reverse-engineering] [th02/th04/th05] Score update and display
The TH02 version is a piece of cake…

… but TH04 starts turning it into this un-decompilable piece of
unnecessarily micro-optimized ZUN code. Couldn't have chosen anything
better for the first separate ASM translation unit.

Aside from now having to convert names of exported *variables* to
uppercase for visibility in ASM translation units, the most notable
lesson in this was the one about avoiding fixup overflows. From the
Borland C++ Version 4.0 User's Guide:

	"In an assembly language program, a fixup overflow frequently
	 occurs if you have declared an external variable within a
	 segment definition, but this variable actually exists in a
	 different segment."

Can't be restated often enough.

Completes P0032, funded by zorg.
2019-09-21 14:01:47 +02:00
nmlgc 88c05e48e5 [Maintenance] Move a few more ASM definitions to their own .inc files
Part of P0032, funded by zorg.
2019-09-21 13:05:54 +02:00
nmlgc d19f91914e [Maintenance] Mirror the TH04/TH05 C header sharing on the ASM side
Part of P0032, funded by zorg.
2019-09-21 13:04:28 +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 9f764fa6fb [Maintenance] [th04] Split code segment #1 into two
So yes, we *can* technically decompile from anywhere, by splitting the
segment after the function we want, then .SEQuentially GROUPing the two
segments back together into one virtual segment matching the original
one. This gives us one more point where we can slot in new compilation
units that emit their code into the same segment, in the order given on
the link command line.

*But* since all ASM in ReC98 heavily relies on being assembled in MASM
mode, we then start to suffer from MASM's group addressing quirk,
described in the "Accessing data in a segment belonging to a group"
section in the Turbo Assembler Version 5 User's Guide.
Which then forces us to manually prefix every single function call

• from inside the group
• to anywhere else within the newly created segment

with the group name. It's stupidly boring busywork, because of all the
function calls you *mustn't* prefix. Special tooling might make this
easier, but I don't have it, and I'm not getting crowdfunded for it.

And while this is faster than porting the entire codebase to Ideal
mode, I'll only do this on rare occasions.
Like the upcoming, particularly awful piece of reverse-engineering.

Completes P0031, funded by zorg.
2019-09-21 13:02:09 +02:00
nmlgc 3383a4558b [Decompilation] [th05] Resetting boss-related variables
Part of P0031, funded by zorg.
2019-09-21 13:01:30 +02:00
nmlgc b0c2122eec [Decompilation] [th05] Stage-related .BB file loading boilerplate
Yay for alignment, allowing us once again to only move unrelated
variable declarations over to C…

Part of P0031, funded by zorg.
2019-09-21 12:59:22 +02:00
nmlgc e33ccd7ea6 [Maintenance] [th04/th05] Move boss slices into the boss directory
Part of P0031, funded by zorg.
2019-09-21 12:58:09 +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 9d121c7cce [Decompilation] [th04/th05] Handle subpixels at the C++ type level
I've had the idea to hide this implementation detail and improve code
readability for some time now, but it obviously must still all inline,
to be indistinguishable from a direct assignment of the correct value…

… which, amazingly, it does! Even the static_cast from float to int.
The latter allows us to exclusively implement this for float, since we
do have to express the occasional value smaller than 16.

Who needs macros anyway. Yay, C++ in TH04 and TH05 after all!

Part of P0030, funded by zorg.
2019-09-15 20:30:35 +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 c7fc4ca41d [Decompilation] [th05] Committing the score delta
Completes P0029, funded by zorg.
2019-09-15 20:29:09 +02:00
nmlgc 789c910c88 [Reverse-engineering] [th04/th05] Playfield fill-around function names
These are used from quite a few places, so it seems best to just name
them after the rect on the playfield they leave out, which is then
typically where the background picture goes.

…*except* that in doing this, we quickly run up against the symbol
length limit of 32 characters. TASM can expand it via the /mv option,
but TCC only lets you *reduce* it to even less. (Why?)
So, my initial idea of `playfield_fill_around_(x)_(y)_(w)_(h)` wouldn't
have worked. But those coordinates are kinda important, I'd say…
Well then, let's just go with `fillm` instead of `fill_around` then.
"Fill with mask at the given coordinates"… yeah, that would work.

Part of P0029, funded by zorg.
2019-09-15 20:26:21 +02:00
nmlgc 6ff427aa0a [Reverse-engineering] [th04/th05] Remaining generic boss variables
… yeah, I don't really like these ambiguous "mode" and "mode change"
variable names either, but what's the alternative? Something something
"sub-phase", to distinguish them from regular phases? Feels way too
early to decide on something more specific. And pretty much nothing I
could come up with right now would have made their inconsistent use any
clearer.
But I need to decide on *something* before moving on, so… eh, let's
just go with what uth05win chose.

Also, yeah, dealing with those 0xFE and 0xFD boss_phase constants some
other time 😛

Also, today in "Weird TASM crashes": Trailing commas at the end of
`public` lines…

Completes P0028, funded by zorg.
2019-09-11 23:19:10 +02:00
nmlgc 260edd8683 [Reverse-engineering] [th04/th05] Remaining generic midboss variables
Turning these into a struct will be very painful with all the
collisions. Not going to do that until we decompiled every single
reference to those.

Part of P0028, funded by zorg.
2019-09-11 18:27:46 +02:00
nmlgc e1714da563 [Maintenance] Move the midboss function pointer slice into its own directory
Part of P0028, funded by zorg.
2019-09-09 18:40:13 +02:00
nmlgc 3ba536a2d8 [Reverse-engineering] [th04/th05] Text popups
As in, "HiScore Entry!!", "Extend!!", "Full PowerUp!!", etc.
Class CFloatingText in uth05win… but I decided against naming it like
that because of some stage/BGM title-related variables in the middle.

Funded by -Tom-.
2019-03-06 19:57:23 +01:00
nmlgc fac879f8e6 [Reverse-engineering] [th05] Number display using the bold gaiji font
Many thanks to http://bytepointer.com/tasm/index.htm for providing a
better searchable resource for TASM's default `LEA imm16` → `MOV imm16`
optimization, which we initially had to hack around here.

Funded by -Tom-.
2019-03-06 19:32:38 +01:00
nmlgc 058595b1d9 [Reverse-engineering] [th04/th05] Score variables
In which ZUN uses little-endian BCD as the exclusive internal storage
for both the current and the high score. Which are then updated using,
once again, ridiculously micro-optimized ASM code that uses the
venerable x86 BCD instructions.

Funded by -Tom-.
2019-03-04 21:42:11 +01:00
nmlgc 308d1bc785 [Reverse-engineering] [th04/th05] Boss explosions
So apparently, this way of distorting a circle into an ellipse (?) by
adding a value to the angle for one of the two coordinates isn't
actually widely known in math and doesn't have a name. Fair enough.

Funded by -Tom-.
2019-03-03 14:03:41 +01:00
nmlgc 6ed8e60334 [Reverse-engineering] [th04/th05] Boss phase timeout flag
Funded by -Tom-.
2019-03-01 23:20:52 +01:00
nmlgc ae9651c693 [Reverse-engineering] [th04/th05] Difficulty/character-based value selection
Funded by -Tom-.
2019-03-01 23:20:51 +01:00
nmlgc 08ffcb0737 [Reverse-engineering] [th04/th05] Boss hitboxes
Funded by -Tom-.
2019-03-01 16:18:02 +01:00
nmlgc 062e775f41 [Reverse-engineering] [th04/th05] .BB file loading boilerplate
Yup, nothing interesting in here.
Except for maybe the confirmation that LS00.BB is used for the curved
bullets used by Shinki and EX-Alice?

Funded by -Tom-.
2019-03-01 16:17:52 +01:00
nmlgc 893bd46969 [Reverse-engineering] [th04/th05] Stage-specific invalidate/render functions
Used only sparingly, like for the starfield in TH05 Stage 2.

Funded by -Tom-.
2019-02-28 17:56:26 +01:00
nmlgc d9e9b38736 [Reverse-engineering] [th04/th05] Spark animation
Also seen when midbosses explode. Class CSparkEffect in uth05win.

Funded by -Tom-.
2019-02-28 17:43:15 +01:00
nmlgc da284cacaf [Reverse-engineering] [th02/th04/th05] Hardcoded spark sprites
As seen when killing stage enemies or grazing.

Funded by -Tom-.
2019-02-28 17:43:15 +01:00
nmlgc b9f3d86e44 [Reverse-engineering] [th04/th05] Adding new player shots
Funded by -Tom-.
2019-02-28 17:43:14 +01:00
nmlgc 9a2c6f72ba [Reverse-engineering] [th04/th05] Second, unused field of the .map header
Thanks to -Tom- for telling me what this obviously had to be.
2019-01-11 00:28:56 +01:00
nmlgc deb45ea14e [Reverse-engineering] [th04/th05] Player shot structure
And that's enough for now, see you in February!

Funded by -Tom-.
2019-01-01 02:29:12 +01:00
nmlgc 35f9bd71e8 [Reduction] [th04/th05] Micro-optimized version of super_roll_put_tiny()
Y'know, maybe ZUN measured and all of this actually mattered? What do I
know?

Funded by -Tom-.
2018-12-31 20:41:13 +01:00
nmlgc e7265ac656 [Reverse-engineering] [th04/th05] Shot X/Y velocity lookup table
Funded by -Tom-.
2018-12-31 19:45:34 +01:00
nmlgc 4770d145d6 [Reverse-engineering] [th04/th05] Target position for homing shots
Funded by -Tom-.
2018-12-30 15:31:26 +01:00
nmlgc 612beb815b [Maintenance] Clean up the confusion between "tiles" and .STD tile sections
Funded by -Tom-.
2018-12-30 02:30:16 +01:00
nmlgc 75763ccd32 [Reverse-engineering] [th04/th05] Invalidating background tiles around a point
…and *now* we can tackle all those entity types that were referencing
this function, with the help of uth05win.

Funded by -Tom-.
2018-12-30 00:19:18 +01:00
nmlgc c00b87ed4f [Reverse-engineering] [th04/th05] Redrawing dirty stage background tiles
Funded by -Tom-.
2018-12-30 00:16:16 +01:00
nmlgc bcc1b7518f [Reverse-engineering] [th04/th05] Applying VRAM scrolling to Y coordinates
Funded by -Tom-.
2018-12-29 18:34:51 +01:00
nmlgc 4fe4c8eed1 [Reverse-engineering] [th04/th05] Scrolling-related variables
Funded by -Tom-.
2018-12-29 18:34:51 +01:00
nmlgc 20d05c1653 [Reverse-engineering] [th04/th05] Rendering all stage background tiles at once
Funded by -Tom-.
2018-12-29 18:34:51 +01:00
nmlgc e1e4f819ed [Reverse-engineering] [th02/th04/th05] Stage background tile ring buffer
Funded by -Tom-.
2018-12-29 17:03:24 +01:00
nmlgc 261d5037ed [Reverse-engineering] [th04/th05] .STD file loading
… because TH04's version of this takes the ASCII stage ID directly from
the resident structure.

So boss battles are simply triggered by setting the background tile
scroll speed to 0? That means…

Funded by zorg.
2018-12-26 17:59:03 +01:00
nmlgc 4a0b973c76 [Reverse-engineering] [th04/th05] Midboss-related function pointers
Funded by zorg.
2018-12-26 17:59:03 +01:00
nmlgc 25ee5990aa [Reverse-engineering] [th04/th05] Boss battle backdrop rendering
Funded by zorg.
2018-12-26 17:59:03 +01:00
nmlgc d211a22c9f [Reverse-engineering] [th04/th05] GRCG-powered playfield row filling
Isn't it quite a bit risky to do that without a CLD in front?

Funded by zorg.
2018-12-26 17:59:01 +01:00
nmlgc b62a8b29a6 [Reverse-engineering] [th02/th04/th05] Boss-related function pointers
No idea what these other ones in TH02 are.

Funded by zorg.
2018-12-18 19:52:41 +01:00
nmlgc 8634e10b6d [Reverse-engineering] [th04/th05] Bullet clear trigger and time
Funded by zorg.
2018-12-16 01:49:55 +01:00
nmlgc 4aeb035121 [Reverse-engineering] [th04/th05] A random shared draw coordinate
Local variables are so overrated.

Funded by zorg.
2018-12-16 00:31:05 +01:00
nmlgc 0e8bbe8130 [Reverse-engineering] [th04/th05] Player performance ("rank") management
Going with uth05win's "player performance" here, since we already use
"rank" for Easy/Normal/Hard/Lunatic.

Funded by -Tom-.
2018-12-10 21:00:19 +01:00
nmlgc b03bc91357 [Reverse-engineering] [th04/th05] Growing and shrinking circles
As seen during bomb animations, and around bosses. Class CCircle in
uth05win.

Funded by -Tom-.
2018-12-06 23:29:45 +01:00
nmlgc d08a7f49b6 [Reduction] [th04/th05] Redefined GRCG mode/color setting functions
Funded by -Tom-.
2018-12-06 22:39:11 +01:00
nmlgc 766a34d044 [Reverse-engineering] [th04/maine] Single-plane CDG display
Only used in the staff roll.

Funded by DTM.
2018-10-16 01:04:46 +02:00
nmlgc fc8d51c7d7 [Reverse-engineering] [th04/th05] Non-color CDG display 2018-10-16 01:04:46 +02:00
nmlgc aa47bb33d9 [Reverse-engineering] [th04/th05] Non-alpha CDG display 2018-10-16 01:04:46 +02:00
nmlgc bfef793805 [Reverse-engineering] [th04/th05] Normal CDG display
In which the th05 difference is the lack of self-modifying code.
2018-10-16 01:04:46 +02:00
nmlgc 286c6431d8 [Reverse-engineering] [th04/th05] CDG loading 2018-10-16 01:04:46 +02:00
nmlgc 79cc3ed71c [Reverse-engineering] [th03/th04/th05] Input change delay function
With TH05 definitely being the Galaxy Brain version of this function.
You'll see once I get to push the C decompilation for that one…

Anyway, that covers all shared input functions of TH02-TH05!

Funded by zorg.
2018-09-17 22:10:42 +02:00
nmlgc c592464121 [Reverse-engineering] [th03/th04/th05] Basic keyboard input functions
Funded by zorg.
2018-09-11 19:34:19 +02:00
nmlgc 5a5c347e82 [Reverse-engineering] [th04/th05] Generic motion structure and its step method
Seemingly included in every other larger structure describing anything
remotely sprite-like. Couldn't find this in the earlier games,
unfortunately…

Funded by zorg.
2018-09-02 21:06:48 +02:00
nmlgc 0052606563 [Reverse-engineering] [th04] Dream item number and score
The score table is also still present in TH05.

Funded by zorg.
2018-09-02 21:06:47 +02:00
nmlgc 746681db22 [Reverse-engineering] [th04/th05] Enemy drop table
TH02 just seems to use a sequence of branches in sub_D6CA.
I thought about keeping variable and function names consistent with
uth05win (on which most upcoming reverse-engineering commits will be
based). But as it will turn out, it ignored a certain very important
substructure, so I don't think it's worth introducing this naming style
clash.

Funded by zorg.
2018-09-02 20:42:17 +02:00
nmlgc 755a0564ae [Reverse-engineering] [th02/th04/th05] Shot power levels
Funded by -Tom-.
2018-04-20 19:33:40 +02:00
nmlgc 843905ecea [Reverse-engineering] [th04/th05] ZUN Soft logo explosions
Which seemed a nicer and more debuggable intro to how ZUN implements
sprites than starting with a random structure from MAIN.EXE.

Funded by -Tom-.
2018-03-21 23:20:04 +01:00
nmlgc 4b8baf1413 [Reverse-engineering] [th02/th03/th04/th05] Random number ring buffer
Yes, you're reading that correctly. If the cursor is at 255, reading a
16-bit value will fill the upper 8 bits with the neighboring cursor
value, which always is 0xFF.

Funded by -Tom-.
2018-03-16 18:12:21 +01:00
nmlgc f98fba3c9d [Reverse-engineering] [th02/th04/th05] .map file loading
Funded by -Tom-.
2018-03-16 08:02:14 +01:00
nmlgc 39c169c30d [Reduction] Separate functions for 1D and 2D vector construction
Look at that TH05 vector2_at_opt function. What the hell, the caller is
supposed to set up the stack frame for the function? How do you even get
a compiler to do this (and no, I haven't found a compiler switch)? No
way around writing a separate "optimizer" as part of the compilation
pipeline, it seems.
2017-01-08 21:01:13 +01:00
nmlgc c5f53d9cf1 [Maintenance] Rename snd_kaja_func() to snd_kaja_interrupt()
Oh, right, these functions can have parameters. So, let's turn snd_kaja_func()
into a macro that combines the function number and the parameter into the AX
value for the driver.
2015-03-15 23:51:11 +01:00
nmlgc de491f225d [Maintenance] Move the sound driver function slices from hardware/ to snd/
And renaming them all to the short filenames they will be decompiled to for
consistency. These functions aren't really immediately hardware-related, as
we've established earlier in the decompilation.
2015-03-15 23:01:31 +01:00
nmlgc 92979e8f31 [C decompilation] [th02] Code segment #2 of all three executables
Only one code segment left in both OP and FUUIN! its-happening.gif

Yeah, that commit is way larger than I'm comfortable with, but none of these
functions is particularly large or difficult to decompile (with the exception
of graph_putsa_fx(), which I actually did weeks ago), and OP and MAIN have
their own unique functions in between the shared ones, so…
2015-03-14 23:25:50 +01:00
nmlgc 404044f32b [C decompilation] [th02/op] [th03/op] [th04/op] Frame delay #1 2015-03-04 02:47:16 +01:00
nmlgc cd33367b51 [C decompilation] [th02/op] Music Room
Yes, all of it. Including the bouncing polygons, of course. And since it's
placed at the end of ZUN's code inside the executable, the code's already
position-independent and fully hackable.
2015-02-24 22:38:44 +01:00
nmlgc 22332a71fa Make all sound functions and variables available to C 2015-02-23 18:28:38 +01:00
nmlgc 46eb3792cf Move frame_delay into the hardware/ subdirectory 2015-02-23 10:29:12 +01:00
nmlgc 6d8ff6b72e Make previously reduced ZUN functions available to C 2015-02-21 14:12:22 +01:00
nmlgc 2d5d38426f Finally use standard segment names everywhere
And I guess we just have to ignore and disable that segment alignment warning
for TH01. It's not like this changes anything in the binary.
2015-02-18 14:04:43 +01:00
nmlgc 2cac434455 [Reverse-engineering] Sound effect playback 2015-02-13 12:56:51 +01:00
nmlgc 0b89233e48 [Reverse-engineering] Music Room comment loading 2014-12-24 21:39:34 +01:00
nmlgc f0ab47fd18 [Reduction] Hardware text colors and effects
Turns out we're not quite done with reduction yet, as there still are a bunch
of macros in master.h that #define PC-98-specific hardware constants and I/O
ports.
2014-12-20 22:36:38 +01:00
nmlgc bead27b781 Use TASM calling convention syntax for previously identified ZUN functions
With TH03 changing the calling convention for most of the code from __cdecl to
__pascal, I've been getting more and more confused about this myself. So,
let's settle on the following consistent syntax for function calls:

* C where the calling convention is actually __cdecl and where TASM's emitted
  __cdecl code matches the original binary
* PASCAL where the calling convention is actually __pascal
* STDCALL where the calling convention is actually __cdecl, but where
  the caller either defers stack cleanup (summing up the stack size of
  multiple functions, then cleaning it all in a single "add sp" instruction)
  or where the stack is cleared in a different way (e.g. "pop cx").

Unfortunately though, when using the ARG directive to automatically generate
an appropriate RET instruction for the given calling convention, TASM always
emits ENTER and LEAVE instructions even when no local variables are declared,
which greatly limits the number of functions where we can use that syntax. -.-
2014-12-16 05:53:56 +01:00
nmlgc 46b2d67143 [Reverse-engineering] Music and sound effect loader 2014-11-30 00:18:40 +01:00
nmlgc 08db7d6392 [Reverse-engineering] Sound mode determination
Note how it's only one *mode* in TH02/TH03, but two *modes* in TH04/TH05,
since you can't select between FM and Beep sound effect modes in TH02/TH03 (or
even disable sounds altogether). Might be a bit confusing, but it seemed
appropriate enough to distinguish the two functions.
2014-11-29 00:56:26 +01:00
nmlgc de25d6de3e [Reverse-engineering] PMD and MMD function call wrapper
Well, the naming.

Even though only TH02 actually uses MIDI (and thus, the MMD driver), every
game since then contains interrupt instructions for both functions. We could
just name it "pmd", since it seems like that's what came first - the AH
numbers of the 6 functions that make up MMD's interrupt API are identical to
those of the equivalent functions in PMD, even including gaps in the numbering
for PMD functions that don't have an equivalent in MIDI. However, except for
the FM sound effect handling and the key display in TH05's Music Room, these 6
functions are all the games actually use. Also, we already distinguish between
PMD and MMD in the driver check functions, and it might be confusing to only
imply PMD from now on?

So, "kaja" it is, collectively referring to the shared aspects of both
drivers.
2014-11-26 21:21:57 +01:00
nmlgc 98de0abfab [Reverse-engineering] Sound driver and hardware checks 2014-11-24 22:36:57 +01:00
nmlgc f40819b0e5 [Reverse-engineering] frame_delay 2014-11-23 22:32:26 +01:00
nmlgc f303222ffc Replace MASTERMOD with a per-game constant
Yup, packfiles finally proved that we really have a different set of changes
to master.lib in every game. Also, there are bound to be more of these game-
specific small changes to otherwise identical code in ZUN's own code.

And hey, no need to define that value in the build scripts anymore.

(I've also considered just copying modified versions into the individual game
subdirectories, but it's not too nice to expect people to diff them in order
to actually understand why these copies exist and where the changes actually
are.)
2014-11-15 02:03:41 +01:00
nmlgc 69f85fa2de Identify and reduce gaiji strings across all executables 2014-09-13 12:26:33 +02:00