Commit Graph

12 Commits

Author SHA1 Message Date
nmlgc af2c0e14a4 [Maintenance] Adopt the peek() and poke() inline functions from <dos.h>
Which still allows us to replace a bunch of manual MK_FP() macros with
calls to these functions.

Part of P0157, funded by Yanga.
2021-09-12 17:50:41 +02:00
nmlgc 53920309a1 [Decompilation] [th05] snd_kaja_interrupt()
Boom! Decompilable after all. And look what that made us finally point
out: In all 4 games that use this function, its return value is
undefined if BGM is inactive. (That is, if the user disabled it, or if
no FM sound board is installed.)

Part of P0148, funded by [Anonymous].
2021-07-21 00:35:03 +02:00
nmlgc d9858113d8 [Decompilation] [th04] snd_load()
Last one! Done with the SHARED segment for the forseeable future! 🎉

Sure, not the best C++ code either, but still by far the sanest
implementation of this function in any of the 4 games.

Completes P0139, funded by [Anonymous].
2021-05-12 14:31:03 +02:00
nmlgc cd96b039fa [Maintenance] Use a dedicated enum for snd_load()'s function parameter
It's not a kaja_func_t if it's shifted left by 8 bits. Why is it
shifted left by 8 bits to begin with, though? Why not just pass a
kaja_func_t, and assign it to AH? Arrrrgh.

Part of P0139, funded by [Anonymous].
2021-05-12 14:31:02 +02:00
nmlgc 46a1674250 [Reverse-engineering] [th02/th03/th04/th05] snd_load() buffer size
Hardcoding these *might* have been acceptable if the numbers actually
matched the sizes defined in GAME.BAT, but they don't. With PMD's
AH=22h function, there's really no excuse though.
About time I looked into this, and expressed that constant as an inline
function that can easily be replaced with a proper implementation.

Part of P0139, funded by [Anonymous].
2021-05-12 14:31:00 +02:00
nmlgc 78df46af1f [Decompilation] [th04/th05] snd_determine_modes()
ZUN apparently had no trust in the sanity of Turbo C++'s code
generation?

Part of P0139, funded by [Anonymous].
2021-05-11 18:47:59 +02:00
nmlgc c85f444b07 [Decompilation] [th02/th03] Sound effect playback
Second previously undecompilable translation unit, second creative
workaround for the workaround. We can't compile snd_se_play() with -WX,
as that function needs a stack frame, and it's also illegal to disable
-WX in the middle of a translation unit. But since we only need word
alignment in front of snd_se_reset() *and* that function is identical
in all 4 games, it makes sense to move it to its own translation unit.

And then you notice that the TH02/TH03 and TH04/TH05 versions of the
other two functions are basically identical. The small differences can
easily be moved out to inline functions, leaving us with a single
implementation file for all 4 games. Nice!

Part of P0137, funded by [Anonymous].
2021-04-03 22:11:45 +02:00
nmlgc 01c92da1ac [Decompilation] [th05] snd_load()
A decompilation of ZUN-written ASM that was almost worth it, for once!
Too bad that those aren't the <string.h> intrinsics that the
Wolfenstein 3D disassembly hinted at, though.

Part of P0135, funded by [Anonymous].
2021-03-19 19:22:57 +01:00
nmlgc 4229054137 [Decompilation] [th05] snd_bgm_measure(), snd_delay_until_measure()
Umm… but this can't be in the same translation unit as frame_delay(),
because OP.EXE has cdg_put_nocolors() inbetween, which means we'd have
to compile it twice.

What probably happened there: ZUN originally wrote this in C when
frame_delay() was still next to it, then generated ASM from it,
tinkered with that, and ultimately only linked that ASM into the final
game, with the NOPCALL still in there. That might very well be the one
temporary NOPCALL workaround we can never get rid of…

Oh well, at least we got lucky with the padding, and can keep the
cdg_put_nocolors() decompilation from the last commit.

Part of P0133, funded by [Anonymous].
2021-01-30 18:23:03 +01:00
nmlgc f539cca15d [Decompilation] [th03/th04] snd_delay_until_measure()
Part of P0132, funded by [Anonymous].
2021-01-05 21:56:57 +01:00
nmlgc 8ef8f78cc9 [Maintenance] Add a PMD/MMD-independent wrapper for KAJA_GET_SONG_MEASURE
No pseudo-registers in the usage code! Awesome!

Part of P0132, funded by [Anonymous].
2021-01-05 20:02:28 +01:00
nmlgc a1c3acd9f1 [Maintenance] [th04/th05] Declare BGM and SE modes in C land
Part of P0077, funded by Splashman and -Tom-.
2020-02-23 17:53:17 +01:00