mirror of https://github.com/nmlgc/ReC98.git
[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].
This commit is contained in:
parent
46a1674250
commit
cd96b039fa
|
@ -28,8 +28,6 @@ typedef enum {
|
|||
// (DL) buffers, in KiB. These can be customized on the PMD command line
|
||||
// with the /M, /V and /E options respectively.
|
||||
PMD_GET_BUFFER_SIZES = 0x22,
|
||||
|
||||
_kaja_func_t_FORCE_UINT16 = 0xFFFF
|
||||
} kaja_func_t;
|
||||
|
||||
#define PMD 0x60
|
||||
|
|
|
@ -8,7 +8,7 @@ extern "C" {
|
|||
|
||||
extern char snd_load_fn[SND_FN_LEN];
|
||||
|
||||
void snd_load(const char fn[SND_FN_LEN], kaja_func_t func)
|
||||
void snd_load(const char fn[SND_FN_LEN], snd_load_func_t func)
|
||||
{
|
||||
int i;
|
||||
__asm { push ds; }
|
||||
|
|
|
@ -53,13 +53,7 @@ void snd_delay_until_volume(uint8_t volume);
|
|||
void snd_delay_until_measure(int measure);
|
||||
#endif
|
||||
|
||||
// Shorter symbols for the [func] parameter of snd_load()
|
||||
#define SND_LOAD_SONG (kaja_func_t)(KAJA_GET_SONG_ADDRESS << 8)
|
||||
#define SND_LOAD_SE (kaja_func_t)(PMD_GET_SE_ADDRESS << 8)
|
||||
|
||||
#define SND_FN_LEN 13
|
||||
|
||||
#if defined(PMD) && (GAME <= 3) /* requires kaja.h */
|
||||
#if defined(PMD) /* requires kaja.h */
|
||||
#if defined(__cplusplus) && (GAME <= 4)
|
||||
static inline uint16_t snd_load_size() {
|
||||
// ZUN bug: Should rather retrieve the maximum data size for song
|
||||
|
@ -73,11 +67,21 @@ void snd_delay_until_volume(uint8_t volume);
|
|||
}
|
||||
#endif
|
||||
|
||||
// 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.
|
||||
void snd_load(const char fn[SND_FN_LEN], kaja_func_t func);
|
||||
typedef enum {
|
||||
SND_LOAD_SONG = (KAJA_GET_SONG_ADDRESS << 8),
|
||||
SND_LOAD_SE = (PMD_GET_SE_ADDRESS << 8),
|
||||
} snd_load_func_t;
|
||||
|
||||
#define SND_FN_LEN 13
|
||||
|
||||
#if (GAME <= 3)
|
||||
// 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.
|
||||
void snd_load(const char fn[SND_FN_LEN], snd_load_func_t func);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
void snd_se_reset(void);
|
||||
|
|
|
@ -40,7 +40,7 @@ static inline bool16 snd_se_active() {
|
|||
int pascal snd_determine_modes(int req_bgm_mode, int req_se_mode);
|
||||
|
||||
#if defined(PMD) /* requires kaja.h */
|
||||
// Loads a song ([func] = SND_LOAD_SONG) or a sound effect bank ([func] =
|
||||
// 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:
|
||||
|
@ -60,7 +60,7 @@ int pascal snd_determine_modes(int req_bgm_mode, int req_se_mode);
|
|||
//
|
||||
// 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);
|
||||
void pascal snd_load(const char fn[SND_FN_LEN], snd_load_func_t func);
|
||||
|
||||
#if defined(__cplusplus) && (GAME == 5)
|
||||
// Refer to TH02's implementation for an explanation of how wrong this is.
|
||||
|
|
|
@ -12,7 +12,7 @@ extern "C" {
|
|||
extern char snd_load_fn[SND_FN_LEN];
|
||||
extern const char SND_LOAD_EXT[4][4];
|
||||
|
||||
void pascal snd_load(const char fn[SND_FN_LEN], int16_t func)
|
||||
void pascal snd_load(const char fn[SND_FN_LEN], snd_load_func_t func)
|
||||
{
|
||||
#define _DI reinterpret_cast<char near *>(_DI)
|
||||
#define func_local _BP
|
||||
|
|
Loading…
Reference in New Issue