[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-08 18:20:04 +00:00
|
|
|
#include "th03/snd/snd.h"
|
2020-02-22 16:59:46 +00:00
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
SND_BGM_OFF = 0,
|
|
|
|
SND_BGM_FM26 = 1,
|
|
|
|
SND_BGM_FM86 = 2,
|
|
|
|
SND_BGM_MODE_COUNT = 3,
|
|
|
|
SND_BGM_MIDI = 3, // unsupported
|
|
|
|
} snd_bgm_mode_t;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
SND_SE_OFF = 0,
|
|
|
|
SND_SE_FM = 1,
|
|
|
|
SND_SE_BEEP = 2,
|
|
|
|
SND_SE_MODE_COUNT = 3,
|
|
|
|
} snd_se_mode_t;
|
|
|
|
|
|
|
|
extern unsigned char snd_se_mode;
|
|
|
|
extern unsigned char snd_bgm_mode;
|
|
|
|
|
2020-12-31 16:22:48 +00:00
|
|
|
#ifdef __cplusplus
|
2021-03-25 16:09:57 +00:00
|
|
|
static inline bool snd_bgm_active() {
|
2020-12-31 16:22:48 +00:00
|
|
|
return snd_bgm_mode;
|
|
|
|
}
|
2021-03-25 16:09:57 +00:00
|
|
|
|
|
|
|
static inline bool16 snd_se_active() {
|
|
|
|
return (snd_se_mode != SND_SE_OFF);
|
|
|
|
}
|
2020-12-31 16:22:48 +00:00
|
|
|
#endif
|
|
|
|
|
2020-12-29 20:05:57 +00:00
|
|
|
#define snd_bgm_is_fm() \
|
|
|
|
(snd_bgm_mode != SND_BGM_MIDI)
|
|
|
|
|
2020-02-22 16:59:46 +00:00
|
|
|
// Checks the requested BGM and SE modes against the available hardware and
|
|
|
|
// sets [snd_se_mode] and [snd_bgm_mode] accordingly. Returns [snd_bgm_mode].
|
|
|
|
unsigned char pascal snd_determine_modes(int req_bgm_mode, int req_se_mode);
|
2021-02-23 16:46:23 +00:00
|
|
|
|
|
|
|
// Loads a song ([func] = SND_LOAD_SONG) or a sound effect bank ([func] =
|
|
|
|
// SND_LOAD_SE) into the respective work buffer of the sound driver. [fn] must
|
|
|
|
// not have any extension. Depending on [snd_bgm_mode], [snd_se_mode], and
|
|
|
|
// game, the following file is loaded:
|
|
|
|
//
|
|
|
|
// | | TH04 | TH05 |
|
|
|
|
// |----------------+------------+-----------|
|
|
|
|
// | [snd_bgm_mode] | [func] = SND_LOAD_SONG |
|
|
|
|
// |----------------+------------+-----------|
|
|
|
|
// | SND_BGM_FM26 | [fn].m26 | [fn].m |
|
|
|
|
// | SND_BGM_FM86 | [fn].m86 | [fn].m2 |
|
|
|
|
// | SND_BGM_MIDI | [fn].mmd | [fn].md | (yes, see TH05's load[data].asm)
|
|
|
|
// |----------------+------------+-----------|
|
|
|
|
// | [snd_se_mode] | [func] = SND_LOAD_SE |
|
|
|
|
// |----------------+------------+-----------|
|
|
|
|
// | SND_SE_FM | [fn].efc | [fn].efc |
|
|
|
|
// | SND_SE_BEEP | [fn].efs | [fn].efs | (using master.lib's BGM driver)
|
|
|
|
//
|
|
|
|
// Note that the TH05 version will infinitely loop if neither the file for the
|
|
|
|
// current [snd_bgm_mode] nor "[fn].m" exist.
|
|
|
|
void pascal snd_load(const char fn[SND_FN_LEN], int16_t func);
|