Merge pull request #6147 from jriwanek-forks/miscclean
Some misc cleanups and code formatting
This commit is contained in:
@@ -103,8 +103,29 @@ if(INSTRUMENT)
|
||||
add_compile_definitions(USE_INSTRUMENT)
|
||||
endif()
|
||||
|
||||
target_link_libraries(86Box cpu chipset mch dev mem fdd game cdrom rdisk mo hdd
|
||||
net print scsi sio snd utils vid voodoo plat ui)
|
||||
target_link_libraries(86Box
|
||||
cpu
|
||||
chipset
|
||||
mch
|
||||
dev
|
||||
mem
|
||||
fdd
|
||||
game
|
||||
cdrom
|
||||
rdisk
|
||||
mo
|
||||
hdd
|
||||
net
|
||||
print
|
||||
scsi
|
||||
sio
|
||||
snd
|
||||
utils
|
||||
vid
|
||||
voodoo
|
||||
plat
|
||||
ui
|
||||
)
|
||||
|
||||
if(HAIKU)
|
||||
target_link_libraries(86Box be)
|
||||
|
||||
@@ -92,8 +92,8 @@ cart_image_close(int drive)
|
||||
static void
|
||||
cart_image_load(int drive, char *fn)
|
||||
{
|
||||
FILE *fp;
|
||||
uint32_t size;
|
||||
FILE *fp = NULL;
|
||||
uint32_t size = 0;
|
||||
uint32_t base = 0x00000000;
|
||||
|
||||
cart_image_close(drive);
|
||||
@@ -137,7 +137,7 @@ cart_image_load(int drive, char *fn)
|
||||
static void
|
||||
cart_load_common(int drive, char *fn, uint8_t hard_reset)
|
||||
{
|
||||
FILE *fp;
|
||||
FILE *fp = NULL;
|
||||
|
||||
cartridge_log("Cartridge: loading drive %d with '%s'\n", drive, fn);
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
extern char *path_get_basename(const char *path);
|
||||
extern void path_get_dirname(char *dest, const char *path);
|
||||
extern char *path_get_filename(char *s);
|
||||
extern char *path_get_extension(char *s);
|
||||
|
||||
@@ -199,8 +199,8 @@ typedef struct emu8k_voice_t {
|
||||
* something, similarly to targets and current, but... of what?
|
||||
* what is curious is that if they are already zero, they are not written to, so it really
|
||||
* looks like they are information about the status of the channel. (lfo position maybe?) */
|
||||
uint32_t unknown_data0_4;
|
||||
uint32_t unknown_data0_5;
|
||||
uint32_t z2;
|
||||
uint32_t z1;
|
||||
union {
|
||||
uint32_t psst;
|
||||
struct {
|
||||
@@ -229,7 +229,7 @@ typedef struct emu8k_voice_t {
|
||||
};
|
||||
#define CCCA_FILTQ_GET(ccca) (ccca >> 28)
|
||||
#define CCCA_FILTQ_SET(ccca, q) ccca = (ccca & 0x0FFFFFFF) | (q << 28)
|
||||
/* Bit 27 should always be zero */
|
||||
/* Bit 27 should always be zero on EMU8000 */
|
||||
#define CCCA_DMA_ACTIVE(ccca) (ccca & 0x04000000)
|
||||
#define CCCA_DMA_WRITE_MODE(ccca) (ccca & 0x02000000)
|
||||
#define CCCA_DMA_WRITE_RIGHT(ccca) (ccca & 0x01000000)
|
||||
@@ -316,7 +316,9 @@ typedef struct emu8k_voice_t {
|
||||
|
||||
int env_engine_on;
|
||||
|
||||
emu8k_mem_internal_t addr, loop_start, loop_end;
|
||||
emu8k_mem_internal_t addr;
|
||||
emu8k_mem_internal_t loop_start;
|
||||
emu8k_mem_internal_t loop_end;
|
||||
|
||||
int32_t initial_att;
|
||||
int32_t initial_filter;
|
||||
|
||||
@@ -777,9 +777,9 @@ static const device_config_t pcjr_config[] = {
|
||||
.name = "display_type",
|
||||
.description = "Display type",
|
||||
.type = CONFIG_SELECTION,
|
||||
.default_string = "",
|
||||
.default_string = NULL,
|
||||
.default_int = PCJR_RGB,
|
||||
.file_filter = "",
|
||||
.file_filter = NULL,
|
||||
.spinner = { 0 },
|
||||
.selection = {
|
||||
{ .description = "RGB", .value = PCJR_RGB },
|
||||
@@ -810,7 +810,7 @@ static const device_config_t pcjr_config[] = {
|
||||
.name = "apply_hd",
|
||||
.description = "Apply overscan deltas",
|
||||
.type = CONFIG_BINARY,
|
||||
.default_string = "",
|
||||
.default_string = NULL,
|
||||
.default_int = 1
|
||||
},
|
||||
{ .name = "", .description = "", .type = CONFIG_END }
|
||||
|
||||
@@ -267,6 +267,13 @@ plat_getcwd(char *bufp, int max)
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *
|
||||
path_get_basename(const char *path)
|
||||
{
|
||||
QFileInfo fi(path);
|
||||
return fi.fileName().toUtf8().data();
|
||||
}
|
||||
|
||||
void
|
||||
path_get_dirname(char *dest, const char *path)
|
||||
{
|
||||
|
||||
@@ -50,9 +50,13 @@ joystick_init(void)
|
||||
SDL_SetHint(SDL_HINT_JOYSTICK_THREAD, "1");
|
||||
#endif
|
||||
|
||||
if (SDL_InitSubSystem(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) != 0) {
|
||||
#ifdef __APPLE__
|
||||
if (SDL_InitSubSystem(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) != 0)
|
||||
#else
|
||||
if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) != 0)
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
joysticks_present = SDL_NumJoysticks();
|
||||
|
||||
memset(sdl_joy, 0, sizeof(sdl_joy));
|
||||
|
||||
@@ -47,21 +47,24 @@ static audio_info_t info[5];
|
||||
#endif
|
||||
static int freqs[5] = { SOUND_FREQ, MUSIC_FREQ, WT_FREQ, CD_FREQ, 0 };
|
||||
|
||||
void closeal(void){
|
||||
int i;
|
||||
for(i = 0; i < sizeof(audio) / sizeof(audio[0]); i++){
|
||||
if(audio[i] != -1){
|
||||
void
|
||||
closeal(void)
|
||||
{
|
||||
for (int i = 0; i < sizeof(audio) / sizeof(audio[0]); i++) {
|
||||
if (audio[i] != -1)
|
||||
close(audio[i]);
|
||||
}
|
||||
|
||||
audio[i] = -1;
|
||||
}
|
||||
}
|
||||
|
||||
void inital(void){
|
||||
int i;
|
||||
for(i = 0; i < sizeof(audio) / sizeof(audio[0]); i++){
|
||||
void
|
||||
inital(void)
|
||||
{
|
||||
for (int i = 0; i < sizeof(audio) / sizeof(audio[0]); i++) {
|
||||
audio[i] = open("/dev/audio", O_WRONLY);
|
||||
if(audio[i] == -1) audio[i] = open("/dev/audio0", O_WRONLY);
|
||||
if (audio[i] == -1)
|
||||
audio[i] = open("/dev/audio0", O_WRONLY);
|
||||
if (audio[i] != -1) {
|
||||
#ifdef USE_NEW_API
|
||||
AUDIO_INITPAR(&info[i]);
|
||||
@@ -89,16 +92,19 @@ void inital(void){
|
||||
}
|
||||
}
|
||||
|
||||
void givealbuffer_common(const void *buf, const uint8_t src, const int size){
|
||||
void
|
||||
givealbuffer_common(const void *buf, const uint8_t src, const int size)
|
||||
{
|
||||
const int freq = freqs[src];
|
||||
int16_t* output;
|
||||
int output_size;
|
||||
int16_t* conv;
|
||||
int conv_size;
|
||||
int i;
|
||||
double gain;
|
||||
int target_rate;
|
||||
if(audio[src] == -1) return;
|
||||
|
||||
if(audio[src] == -1)
|
||||
return;
|
||||
|
||||
gain = sound_muted ? 0.0 : pow(10.0, (double) sound_gain / 20.0);
|
||||
|
||||
@@ -106,9 +112,8 @@ void givealbuffer_common(const void *buf, const uint8_t src, const int size){
|
||||
float* input = (float*)buf;
|
||||
conv_size = sizeof(int16_t) * size;
|
||||
conv = malloc(conv_size);
|
||||
for(i = 0; i < conv_size / sizeof(int16_t); i++){
|
||||
for (int i = 0; i < conv_size / sizeof(int16_t); i++)
|
||||
conv[i] = 32767 * input[i];
|
||||
}
|
||||
} else {
|
||||
conv_size = size * sizeof(int16_t);
|
||||
conv = malloc(conv_size);
|
||||
@@ -125,7 +130,7 @@ void givealbuffer_common(const void *buf, const uint8_t src, const int size){
|
||||
output_size -= output_size % 4;
|
||||
output = malloc(output_size);
|
||||
|
||||
for(i = 0; i < output_size / sizeof(int16_t) / 2; i++){
|
||||
for (int i = 0; i < output_size / sizeof(int16_t) / 2; i++) {
|
||||
int ind = i * freq / target_rate * 2;
|
||||
output[i * 2 + 0] = conv[ind + 0] * gain;
|
||||
output[i * 2 + 1] = conv[ind + 1] * gain;
|
||||
@@ -137,25 +142,38 @@ void givealbuffer_common(const void *buf, const uint8_t src, const int size){
|
||||
free(output);
|
||||
}
|
||||
|
||||
void givealbuffer(const void *buf){
|
||||
void
|
||||
givealbuffer(const void *buf)
|
||||
{
|
||||
givealbuffer_common(buf, I_NORMAL, SOUNDBUFLEN << 1);
|
||||
}
|
||||
|
||||
void givealbuffer_music(const void *buf){
|
||||
void
|
||||
givealbuffer_music(const void *buf)
|
||||
{
|
||||
givealbuffer_common(buf, I_MUSIC, MUSICBUFLEN << 1);
|
||||
}
|
||||
|
||||
void givealbuffer_wt(const void *buf){
|
||||
void
|
||||
givealbuffer_wt(const void *buf)
|
||||
{
|
||||
givealbuffer_common(buf, I_WT, WTBUFLEN << 1);
|
||||
}
|
||||
|
||||
void givealbuffer_cd(const void *buf){
|
||||
void
|
||||
givealbuffer_cd(const void *buf)
|
||||
{
|
||||
givealbuffer_common(buf, I_CD, CD_BUFLEN << 1);
|
||||
}
|
||||
void givealbuffer_midi(const void *buf, const uint32_t size){
|
||||
|
||||
void
|
||||
givealbuffer_midi(const void *buf, const uint32_t size)
|
||||
{
|
||||
givealbuffer_common(buf, I_MIDI, (int) size);
|
||||
}
|
||||
|
||||
void al_set_midi(const int freq, UNUSED(const int buf_size)){
|
||||
void
|
||||
al_set_midi(const int freq, UNUSED(const int buf_size))
|
||||
{
|
||||
freqs[I_MIDI] = freq;
|
||||
}
|
||||
|
||||
@@ -37,6 +37,12 @@
|
||||
#define FREQ SOUND_FREQ
|
||||
#define BUFLEN SOUNDBUFLEN
|
||||
|
||||
#define I_NORMAL 0
|
||||
#define I_MUSIC 1
|
||||
#define I_WT 2
|
||||
#define I_CD 3
|
||||
#define I_MIDI 4
|
||||
|
||||
ALuint buffers[4]; /* front and back buffers */
|
||||
ALuint buffers_music[4]; /* front and back buffers */
|
||||
ALuint buffers_wt[4]; /* front and back buffers */
|
||||
@@ -166,32 +172,36 @@ inital(void)
|
||||
else
|
||||
alGenSources(4, source);
|
||||
|
||||
alSource3f(source[0], AL_POSITION, 0.0f, 0.0f, 0.0f);
|
||||
alSource3f(source[0], AL_VELOCITY, 0.0f, 0.0f, 0.0f);
|
||||
alSource3f(source[0], AL_DIRECTION, 0.0f, 0.0f, 0.0f);
|
||||
alSourcef(source[0], AL_ROLLOFF_FACTOR, 0.0f);
|
||||
alSourcei(source[0], AL_SOURCE_RELATIVE, AL_TRUE);
|
||||
alSource3f(source[1], AL_POSITION, 0.0f, 0.0f, 0.0f);
|
||||
alSource3f(source[1], AL_VELOCITY, 0.0f, 0.0f, 0.0f);
|
||||
alSource3f(source[1], AL_DIRECTION, 0.0f, 0.0f, 0.0f);
|
||||
alSourcef(source[1], AL_ROLLOFF_FACTOR, 0.0f);
|
||||
alSourcei(source[1], AL_SOURCE_RELATIVE, AL_TRUE);
|
||||
alSource3f(source[2], AL_POSITION, 0.0f, 0.0f, 0.0f);
|
||||
alSource3f(source[2], AL_VELOCITY, 0.0f, 0.0f, 0.0f);
|
||||
alSource3f(source[2], AL_DIRECTION, 0.0f, 0.0f, 0.0f);
|
||||
alSourcef(source[2], AL_ROLLOFF_FACTOR, 0.0f);
|
||||
alSourcei(source[2], AL_SOURCE_RELATIVE, AL_TRUE);
|
||||
alSource3f(source[3], AL_POSITION, 0.0f, 0.0f, 0.0f);
|
||||
alSource3f(source[3], AL_VELOCITY, 0.0f, 0.0f, 0.0f);
|
||||
alSource3f(source[3], AL_DIRECTION, 0.0f, 0.0f, 0.0f);
|
||||
alSourcef(source[3], AL_ROLLOFF_FACTOR, 0.0f);
|
||||
alSourcei(source[3], AL_SOURCE_RELATIVE, AL_TRUE);
|
||||
alSource3f(source[I_NORMAL], AL_POSITION, 0.0f, 0.0f, 0.0f);
|
||||
alSource3f(source[I_NORMAL], AL_VELOCITY, 0.0f, 0.0f, 0.0f);
|
||||
alSource3f(source[I_NORMAL], AL_DIRECTION, 0.0f, 0.0f, 0.0f);
|
||||
alSourcef(source[I_NORMAL], AL_ROLLOFF_FACTOR, 0.0f);
|
||||
alSourcei(source[I_NORMAL], AL_SOURCE_RELATIVE, AL_TRUE);
|
||||
|
||||
alSource3f(source[I_MUSIC], AL_POSITION, 0.0f, 0.0f, 0.0f);
|
||||
alSource3f(source[I_MUSIC], AL_VELOCITY, 0.0f, 0.0f, 0.0f);
|
||||
alSource3f(source[I_MUSIC], AL_DIRECTION, 0.0f, 0.0f, 0.0f);
|
||||
alSourcef(source[I_MUSIC], AL_ROLLOFF_FACTOR, 0.0f);
|
||||
alSourcei(source[I_MUSIC], AL_SOURCE_RELATIVE, AL_TRUE);
|
||||
|
||||
alSource3f(source[I_WT], AL_POSITION, 0.0f, 0.0f, 0.0f);
|
||||
alSource3f(source[I_WT], AL_VELOCITY, 0.0f, 0.0f, 0.0f);
|
||||
alSource3f(source[I_WT], AL_DIRECTION, 0.0f, 0.0f, 0.0f);
|
||||
alSourcef(source[I_WT], AL_ROLLOFF_FACTOR, 0.0f);
|
||||
alSourcei(source[I_WT], AL_SOURCE_RELATIVE, AL_TRUE);
|
||||
|
||||
alSource3f(source[I_CD], AL_POSITION, 0.0f, 0.0f, 0.0f);
|
||||
alSource3f(source[I_CD], AL_VELOCITY, 0.0f, 0.0f, 0.0f);
|
||||
alSource3f(source[I_CD], AL_DIRECTION, 0.0f, 0.0f, 0.0f);
|
||||
alSourcef(source[I_CD], AL_ROLLOFF_FACTOR, 0.0f);
|
||||
alSourcei(source[I_CD], AL_SOURCE_RELATIVE, AL_TRUE);
|
||||
|
||||
if (init_midi) {
|
||||
alSource3f(source[4], AL_POSITION, 0.0f, 0.0f, 0.0f);
|
||||
alSource3f(source[4], AL_VELOCITY, 0.0f, 0.0f, 0.0f);
|
||||
alSource3f(source[4], AL_DIRECTION, 0.0f, 0.0f, 0.0f);
|
||||
alSourcef(source[4], AL_ROLLOFF_FACTOR, 0.0f);
|
||||
alSourcei(source[4], AL_SOURCE_RELATIVE, AL_TRUE);
|
||||
alSource3f(source[I_MIDI], AL_POSITION, 0.0f, 0.0f, 0.0f);
|
||||
alSource3f(source[I_MIDI], AL_VELOCITY, 0.0f, 0.0f, 0.0f);
|
||||
alSource3f(source[I_MIDI], AL_DIRECTION, 0.0f, 0.0f, 0.0f);
|
||||
alSourcef(source[I_MIDI], AL_ROLLOFF_FACTOR, 0.0f);
|
||||
alSourcei(source[I_MIDI], AL_SOURCE_RELATIVE, AL_TRUE);
|
||||
}
|
||||
|
||||
if (sound_is_float) {
|
||||
@@ -228,18 +238,18 @@ inital(void)
|
||||
}
|
||||
}
|
||||
|
||||
alSourceQueueBuffers(source[0], 4, buffers);
|
||||
alSourceQueueBuffers(source[1], 4, buffers_music);
|
||||
alSourceQueueBuffers(source[2], 4, buffers_wt);
|
||||
alSourceQueueBuffers(source[3], 4, buffers_cd);
|
||||
alSourceQueueBuffers(source[I_NORMAL], 4, buffers);
|
||||
alSourceQueueBuffers(source[I_MUSIC], 4, buffers_music);
|
||||
alSourceQueueBuffers(source[I_WT], 4, buffers_wt);
|
||||
alSourceQueueBuffers(source[I_CD], 4, buffers_cd);
|
||||
if (init_midi)
|
||||
alSourceQueueBuffers(source[4], 4, buffers_midi);
|
||||
alSourcePlay(source[0]);
|
||||
alSourcePlay(source[1]);
|
||||
alSourcePlay(source[2]);
|
||||
alSourcePlay(source[3]);
|
||||
alSourceQueueBuffers(source[I_MIDI], 4, buffers_midi);
|
||||
alSourcePlay(source[I_NORMAL]);
|
||||
alSourcePlay(source[I_MUSIC]);
|
||||
alSourcePlay(source[I_WT]);
|
||||
alSourcePlay(source[I_CD]);
|
||||
if (init_midi)
|
||||
alSourcePlay(source[4]);
|
||||
alSourcePlay(source[I_MIDI]);
|
||||
|
||||
if (sound_is_float) {
|
||||
if (init_midi)
|
||||
|
||||
@@ -556,11 +556,11 @@ emu8k_inw(uint16_t addr, void *priv)
|
||||
return ret;
|
||||
|
||||
case 4:
|
||||
READ16(addr, emu8k->voice[emu8k->cur_voice].unknown_data0_4);
|
||||
READ16(addr, emu8k->voice[emu8k->cur_voice].z2);
|
||||
return ret;
|
||||
|
||||
case 5:
|
||||
READ16(addr, emu8k->voice[emu8k->cur_voice].unknown_data0_5);
|
||||
READ16(addr, emu8k->voice[emu8k->cur_voice].z1);
|
||||
return ret;
|
||||
|
||||
case 6:
|
||||
@@ -888,11 +888,11 @@ emu8k_outw(uint16_t addr, uint16_t val, void *priv)
|
||||
return;
|
||||
|
||||
case 4:
|
||||
WRITE16(addr, emu8k->voice[emu8k->cur_voice].unknown_data0_4, val);
|
||||
WRITE16(addr, emu8k->voice[emu8k->cur_voice].z2, val);
|
||||
return;
|
||||
|
||||
case 5:
|
||||
WRITE16(addr, emu8k->voice[emu8k->cur_voice].unknown_data0_5, val);
|
||||
WRITE16(addr, emu8k->voice[emu8k->cur_voice].z1, val);
|
||||
return;
|
||||
|
||||
case 6:
|
||||
@@ -1811,11 +1811,10 @@ emu8k_update(emu8k_t *emu8k)
|
||||
emu_voice->filt_buffer[1] += (emu_voice->filt_buffer[0] * coef0) >> 24;
|
||||
emu_voice->filt_buffer[0] += (vhp * coef0) >> 24;
|
||||
dat = (int32_t) (emu_voice->filt_buffer[1] >> 8);
|
||||
if (dat > 32767) {
|
||||
if (dat > 32767)
|
||||
dat = 32767;
|
||||
} else if (dat < -32768) {
|
||||
else if (dat < -32768)
|
||||
dat = -32768;
|
||||
}
|
||||
|
||||
#elif defined FILTER_MOOG
|
||||
|
||||
@@ -1841,11 +1840,10 @@ emu8k_update(emu8k_t *emu8k)
|
||||
emu_voice->filt_buffer[0] = ClipBuffer(dat);
|
||||
|
||||
dat = (int32_t) (emu_voice->filt_buffer[4] >> 8);
|
||||
if (dat > 32767) {
|
||||
if (dat > 32767)
|
||||
dat = 32767;
|
||||
} else if (dat < -32768) {
|
||||
else if (dat < -32768)
|
||||
dat = -32768;
|
||||
}
|
||||
|
||||
#elif defined FILTER_CONSTANT
|
||||
|
||||
@@ -1864,11 +1862,10 @@ emu8k_update(emu8k_t *emu8k)
|
||||
emu_voice->filt_buffer[1] = ClipBuffer(emu_voice->filt_buffer[1]);
|
||||
|
||||
dat = (int32_t) (emu_voice->filt_buffer[1] >> 8);
|
||||
if (dat > 32767) {
|
||||
if (dat > 32767)
|
||||
dat = 32767;
|
||||
} else if (dat < -32768) {
|
||||
else if (dat < -32768)
|
||||
dat = -32768;
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
@@ -2372,6 +2369,8 @@ emu8k_init(emu8k_t *emu8k, uint16_t emu_addr, int onboard_ram)
|
||||
void
|
||||
emu8k_close(emu8k_t *emu8k)
|
||||
{
|
||||
if (emu8k->rom)
|
||||
free(emu8k->rom);
|
||||
if (emu8k->ram)
|
||||
free(emu8k->ram);
|
||||
}
|
||||
|
||||
@@ -36,19 +36,21 @@ static struct sio_hdl* audio[5] = {NULL, NULL, NULL, NULL, NULL};
|
||||
static struct sio_par info[5];
|
||||
static int freqs[5] = { SOUND_FREQ, MUSIC_FREQ, WT_FREQ, CD_FREQ, 0 };
|
||||
|
||||
void closeal(void){
|
||||
int i;
|
||||
for(i = 0; i < sizeof(audio) / sizeof(audio[0]); i++){
|
||||
if(audio[i] != NULL){
|
||||
void
|
||||
closeal(void)
|
||||
{
|
||||
for (int i = 0; i < sizeof(audio) / sizeof(audio[0]); i++) {
|
||||
if (audio[i] != NULL)
|
||||
sio_close(audio[i]);
|
||||
}
|
||||
|
||||
audio[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void inital(void){
|
||||
int i;
|
||||
for(i = 0; i < sizeof(audio) / sizeof(audio[0]); i++){
|
||||
void
|
||||
inital(void)
|
||||
{
|
||||
for (int i = 0; i < sizeof(audio) / sizeof(audio[0]); i++) {
|
||||
audio[i] = sio_open(SIO_DEVANY, SIO_PLAY, 0);
|
||||
if (audio[i] != NULL) {
|
||||
int rate;
|
||||
@@ -72,16 +74,18 @@ void inital(void){
|
||||
}
|
||||
}
|
||||
|
||||
void givealbuffer_common(const void *buf, const uint8_t src, const int size){
|
||||
void
|
||||
givealbuffer_common(const void *buf, const uint8_t src, const int size)
|
||||
{
|
||||
const int freq = freqs[src];
|
||||
int16_t* output;
|
||||
int output_size;
|
||||
int16_t* conv;
|
||||
int conv_size;
|
||||
int i;
|
||||
double gain;
|
||||
int target_rate;
|
||||
if(audio[src] == NULL) return;
|
||||
if (audio[src] == NULL)
|
||||
return;
|
||||
|
||||
gain = sound_muted ? 0.0 : pow(10.0, (double) sound_gain / 20.0);
|
||||
|
||||
@@ -89,9 +93,8 @@ void givealbuffer_common(const void *buf, const uint8_t src, const int size){
|
||||
float* input = (float*) buf;
|
||||
conv_size = sizeof(int16_t) * size;
|
||||
conv = malloc(conv_size);
|
||||
for(i = 0; i < conv_size / sizeof(int16_t); i++){
|
||||
for (int i = 0; i < conv_size / sizeof(int16_t); i++)
|
||||
conv[i] = 32767 * input[i];
|
||||
}
|
||||
} else {
|
||||
conv_size = size * sizeof(int16_t);
|
||||
conv = malloc(conv_size);
|
||||
@@ -104,7 +107,7 @@ void givealbuffer_common(const void *buf, const uint8_t src, const int size){
|
||||
output_size -= output_size % 4;
|
||||
output = malloc(output_size);
|
||||
|
||||
for(i = 0; i < output_size / sizeof(int16_t) / 2; i++){
|
||||
for (int i = 0; i < output_size / sizeof(int16_t) / 2; i++) {
|
||||
int ind = i * freq / target_rate * 2;
|
||||
output[i * 2 + 0] = conv[ind + 0] * gain;
|
||||
output[i * 2 + 1] = conv[ind + 1] * gain;
|
||||
@@ -116,25 +119,38 @@ void givealbuffer_common(const void *buf, const uint8_t src, const int size){
|
||||
free(output);
|
||||
}
|
||||
|
||||
void givealbuffer(const void *buf){
|
||||
void
|
||||
givealbuffer(const void *buf)
|
||||
{
|
||||
givealbuffer_common(buf, I_NORMAL, SOUNDBUFLEN << 1);
|
||||
}
|
||||
|
||||
void givealbuffer_music(const void *buf){
|
||||
void
|
||||
givealbuffer_music(const void *buf)
|
||||
{
|
||||
givealbuffer_common(buf, I_MUSIC, MUSICBUFLEN << 1);
|
||||
}
|
||||
|
||||
void givealbuffer_wt(const void *buf){
|
||||
void
|
||||
givealbuffer_wt(const void *buf)
|
||||
{
|
||||
givealbuffer_common(buf, I_WT, WTBUFLEN << 1);
|
||||
}
|
||||
|
||||
void givealbuffer_cd(const void *buf){
|
||||
void
|
||||
givealbuffer_cd(const void *buf)
|
||||
{
|
||||
givealbuffer_common(buf, I_CD, CD_BUFLEN << 1);
|
||||
}
|
||||
void givealbuffer_midi(const void *buf, const uint32_t size){
|
||||
|
||||
void
|
||||
givealbuffer_midi(const void *buf, const uint32_t size)
|
||||
{
|
||||
givealbuffer_common(buf, I_MIDI, (int) size);
|
||||
}
|
||||
|
||||
void al_set_midi(const int freq, UNUSED(const int buf_size)){
|
||||
void
|
||||
al_set_midi(const int freq, UNUSED(const int buf_size))
|
||||
{
|
||||
freqs[I_MIDI] = freq;
|
||||
}
|
||||
|
||||
@@ -55,7 +55,6 @@ int wavetable_pos_global = 0;
|
||||
int sound_gain = 0;
|
||||
|
||||
static sound_handler_t sound_handlers[8];
|
||||
|
||||
static sound_handler_t music_handlers[8];
|
||||
static sound_handler_t wavetable_handlers[8];
|
||||
|
||||
|
||||
@@ -119,22 +119,18 @@ void
|
||||
inital(void)
|
||||
{
|
||||
#if defined(_WIN32) && !defined(USE_FAUDIO)
|
||||
if (xaudio2_handle == NULL) {
|
||||
if (xaudio2_handle == NULL)
|
||||
xaudio2_handle = dynld_module("xaudio2_9.dll", xaudio2_imports);
|
||||
}
|
||||
|
||||
if (xaudio2_handle == NULL) {
|
||||
if (xaudio2_handle == NULL)
|
||||
xaudio2_handle = dynld_module("xaudio2_9redist.dll", xaudio2_imports);
|
||||
}
|
||||
|
||||
if (xaudio2_handle == NULL) {
|
||||
if (xaudio2_handle == NULL)
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (XAudio2Create(&xaudio2, 0, XAUDIO2_DEFAULT_PROCESSOR)) {
|
||||
if (XAudio2Create(&xaudio2, 0, XAUDIO2_DEFAULT_PROCESSOR))
|
||||
return;
|
||||
}
|
||||
|
||||
if (IXAudio2_CreateMasteringVoice(xaudio2, &mastervoice, 2, FREQ, 0, 0, NULL, 0)) {
|
||||
IXAudio2_Release(xaudio2);
|
||||
@@ -209,6 +205,7 @@ closeal(void)
|
||||
{
|
||||
if (!initialized)
|
||||
return;
|
||||
|
||||
initialized = 0;
|
||||
(void) IXAudio2SourceVoice_Stop(srcvoice, 0, XAUDIO2_COMMIT_NOW);
|
||||
(void) IXAudio2SourceVoice_FlushSourceBuffers(srcvoice);
|
||||
@@ -229,7 +226,9 @@ closeal(void)
|
||||
IXAudio2SourceVoice_DestroyVoice(srcvoice);
|
||||
IXAudio2MasteringVoice_DestroyVoice(mastervoice);
|
||||
IXAudio2_Release(xaudio2);
|
||||
srcvoice = srcvoicecd = srcvoicemidi = NULL;
|
||||
srcvoice = NULL;
|
||||
srcvoicecd = NULL;
|
||||
srcvoicemidi = NULL;
|
||||
mastervoice = NULL;
|
||||
xaudio2 = NULL;
|
||||
|
||||
|
||||
@@ -351,7 +351,7 @@ plat_put_backslash(char *s)
|
||||
|
||||
/* Return the last element of a pathname. */
|
||||
char *
|
||||
plat_get_basename(const char *path)
|
||||
path_get_basename(const char *path)
|
||||
{
|
||||
int c = (int) strlen(path);
|
||||
|
||||
@@ -1420,6 +1420,7 @@ main(int argc, char **argv)
|
||||
f_rl_callback_handler_remove();
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *
|
||||
plat_vidapi_name(UNUSED(int i))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user