2019-12-21 16:23:03 +00:00
|
|
|
#include "defconv.h"
|
|
|
|
|
2020-02-18 18:46:34 +00:00
|
|
|
extern char snd_interrupt_if_midi;
|
2020-12-11 20:40:40 +00:00
|
|
|
extern bool snd_midi_possible;
|
2020-02-18 18:46:34 +00:00
|
|
|
#if GAME <= 3
|
|
|
|
typedef enum {
|
|
|
|
SND_BGM_OFF,
|
|
|
|
SND_BGM_FM,
|
|
|
|
SND_BGM_MIDI
|
|
|
|
} snd_bgm_mode_t;
|
|
|
|
|
2020-12-11 20:40:40 +00:00
|
|
|
extern bool snd_active;
|
|
|
|
extern bool snd_midi_active;
|
|
|
|
extern bool snd_fm_possible;
|
2020-12-29 20:05:57 +00:00
|
|
|
|
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_active;
|
|
|
|
}
|
2021-03-25 16:09:57 +00:00
|
|
|
|
|
|
|
static inline bool snd_se_active() {
|
|
|
|
return snd_fm_possible;
|
|
|
|
}
|
2021-07-18 19:58:51 +00:00
|
|
|
|
|
|
|
// MODDERS: Just use [new_se] directly.
|
|
|
|
static inline int16_t snd_get_param(int16_t ¶m) {
|
|
|
|
return param;
|
|
|
|
}
|
2020-12-31 16:22:48 +00:00
|
|
|
#endif
|
|
|
|
|
2020-12-29 20:05:57 +00:00
|
|
|
#define snd_bgm_is_fm() \
|
|
|
|
(snd_midi_active != true)
|
2020-02-18 18:46:34 +00:00
|
|
|
#endif
|
|
|
|
|
2021-01-28 18:44:41 +00:00
|
|
|
// Purely returns whether the PMD driver is resident at its interrupt. The
|
|
|
|
// check for an actual installed FM sound source is done by
|
|
|
|
// snd_determine_mode().
|
|
|
|
bool16 snd_pmd_resident(void);
|
2021-01-28 19:43:49 +00:00
|
|
|
#if (GAME != 3)
|
|
|
|
// Returns whether the MMD driver is resident at its interrupt. If it is,
|
|
|
|
// ≤TH03 sets [snd_midi_active] to true.
|
|
|
|
bool16 snd_mmd_resident(void);
|
2020-02-18 18:46:34 +00:00
|
|
|
#endif
|
|
|
|
|
2021-01-28 19:34:05 +00:00
|
|
|
// Checks whether an FM sound source is active, and sets [snd_fm_possible]
|
|
|
|
// and [snd_active]. In the absence of an FM source, [snd_active] is set to
|
|
|
|
// [snd_midi_active]. Returns the new value of [snd_active].
|
|
|
|
bool16 snd_determine_mode(void);
|
|
|
|
|
2021-07-18 19:58:51 +00:00
|
|
|
// Calls the interrupt handler of the installed sound driver with AX = [ax],
|
|
|
|
// if any. If BGM is disabled, the return value is undefined.
|
2020-02-18 18:46:34 +00:00
|
|
|
int16_t DEFCONV snd_kaja_interrupt(int16_t ax);
|
|
|
|
|
2021-01-28 18:20:27 +00:00
|
|
|
// Blocks until the active sound driver reports the given [volume] via
|
|
|
|
// KAJA_GET_VOLUME. The behavior is undefined if no sound driver is active.
|
2020-09-06 16:13:07 +00:00
|
|
|
void snd_delay_until_volume(uint8_t volume);
|
|
|
|
|
2020-12-21 16:22:49 +00:00
|
|
|
#if (GAME == 2)
|
|
|
|
void snd_delay_until_measure(int measure);
|
|
|
|
#endif
|
|
|
|
|
2021-05-11 22:49:30 +00:00
|
|
|
#if defined(PMD) /* requires kaja.h */
|
2022-11-14 02:50:49 +00:00
|
|
|
#define snd_kaja_func(func, param) ( \
|
|
|
|
snd_kaja_interrupt(((func) << 8) + (param)) \
|
|
|
|
)
|
2021-05-11 21:13:35 +00:00
|
|
|
#if defined(__cplusplus) && (GAME <= 4)
|
|
|
|
static inline uint16_t snd_load_size() {
|
|
|
|
// ZUN bug: Should rather retrieve the maximum data size for song
|
|
|
|
// or sound effect data via PMD_GET_BUFFER_SIZES, instead of
|
|
|
|
// hardcoding a random maximum and risking overflowing PMD's data
|
|
|
|
// buffer.
|
|
|
|
// (Unfortunately, MMD lacks a similar function...)
|
|
|
|
// MODDERS: When implementing this properly, rearrange the call
|
|
|
|
// sites to make sure that AX isn't destroyed.
|
|
|
|
return 0x5000;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2021-05-11 22:49:30 +00:00
|
|
|
typedef enum {
|
|
|
|
SND_LOAD_SONG = (KAJA_GET_SONG_ADDRESS << 8),
|
|
|
|
SND_LOAD_SE = (PMD_GET_SE_ADDRESS << 8),
|
|
|
|
} snd_load_func_t;
|
|
|
|
|
2022-11-13 01:58:15 +00:00
|
|
|
#if (GAME <= 3) && defined(MASTER_HPP)
|
2021-05-11 22:49:30 +00:00
|
|
|
// Loads a song in .M format ([func] == SND_LOAD_SONG) or a sound
|
|
|
|
// effect bank in EFC format ([func] == SND_LOAD_SE) into the
|
|
|
|
// respective work buffer of the sound driver. If MIDI is used, 'md'
|
|
|
|
// is appended to the file name.
|
|
|
|
// [fn] still needs to be null-terminated, despite its fixed length.
|
2022-11-13 01:58:15 +00:00
|
|
|
void snd_load(const char fn[PF_FN_LEN], snd_load_func_t func);
|
2021-05-11 22:49:30 +00:00
|
|
|
#endif
|
2020-02-18 18:46:34 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
void snd_se_reset(void);
|
2019-10-13 19:52:02 +00:00
|
|
|
void DEFCONV snd_se_play(int new_se);
|
2020-02-18 18:46:34 +00:00
|
|
|
void snd_se_update(void);
|
2020-09-19 12:30:57 +00:00
|
|
|
|
2022-11-14 02:50:49 +00:00
|
|
|
// Cancels any currently playing sound effect to play the given one.
|
|
|
|
#define snd_se_play_force(new_se) { \
|
|
|
|
snd_se_reset(); \
|
|
|
|
snd_se_play(new_se); \
|
|
|
|
snd_se_update(); \
|
|
|
|
}
|