restore sfx

This commit is contained in:
Philippe Simons committed 2022-01-31 17:53:34 +01:00
1 parent 70cf6f1ca6
commit 1af928cc40
3 files changed
+28 -17

No files matched your search

+15 -15
View File
@@ -3,7 +3,7 @@
sfx_data sounds[NUM_SFX];
static int SAMPLECOUNT = 512;
static int SAMPLECOUNT = 735;
#define MAX_CHANNELS 32
@@ -108,7 +108,7 @@ static void updateSoundParams(int slot, int volume)
}
void mix_sound(void *unused, unsigned char *stream, int len)
void mix_sound(signed short *stream, int len)
{
/* Mix current sound data. */
/* Data, from raw sound, for right and left. */
@@ -280,22 +280,22 @@ void dj_set_sfx_volume(char volume)
void dj_play_sfx(unsigned char sfx_num, unsigned short freq, char volume, char panning, unsigned short delay, char channel)
{
// int slot;
int slot;
// if (main_info.music_no_sound || main_info.no_sound)
// return;
if (main_info.music_no_sound || main_info.no_sound)
return;
// if (channel<0) {
// for (slot=0; slot<MAX_CHANNELS; slot++)
// if (channelinfo[slot].data==NULL)
// break;
// if (slot>=MAX_CHANNELS)
// return;
// } else
// slot = channel;
if (channel<0) {
for (slot=0; slot<MAX_CHANNELS; slot++)
if (channelinfo[slot].data==NULL)
break;
if (slot>=MAX_CHANNELS)
return;
} else
slot = channel;
// addsfx((short *)sounds[sfx_num].buf, sounds[sfx_num].length, sounds[sfx_num].loop, freq, slot);
// updateSoundParams(slot, volume*2);
addsfx((short *)sounds[sfx_num].buf, sounds[sfx_num].length, sounds[sfx_num].loop, freq, slot);
updateSoundParams(slot, volume*2);
}
char dj_get_sfx_settings(unsigned char sfx_num, sfx_data *data)
+2
View File
@@ -286,6 +286,8 @@ extern char last_keys[50];
int key_pressed(int key);
int addkey(unsigned int key);
void mix_sound(signed short *stream, int len);
#ifdef __cplusplus
}
+11 -2
View File
@@ -53,14 +53,19 @@ void retro_init(void)
unsigned dummy = 0;
supports_input_bitmasks = environ_cb(RETRO_ENVIRONMENT_GET_INPUT_BITMASKS, &dummy);
for (int port = 0; port < 4; port++)
for (int port = 0; port < 4; port++) {
controller_types[port] = -1;
}
dj_init();
}
void retro_deinit(void)
{
free(frame_buf);
frame_buf = NULL;
dj_deinit();
}
unsigned retro_api_version(void)
@@ -257,9 +262,13 @@ static void check_variables(void)
}
static unsigned char audio_buffer[735 * 4];
static void audio_callback(void)
{
audio_batch_cb(0, 0);
memset(audio_buffer, 0, 735 * 4);
mix_sound((int16_t*) audio_buffer, 735 * 4);
audio_batch_cb((int16_t*) audio_buffer, 735);
}
void retro_run(void)