diff --git a/src/lang/language.h b/src/lang/language.h index b32251d..8a15ac7 100644 --- a/src/lang/language.h +++ b/src/lang/language.h @@ -10,7 +10,7 @@ * * NOTE: FIXME: Strings 2176 and 2193 are same. * - * Version: @(#)language.h 1.0.1 2018/02/14 + * Version: @(#)language.h 1.0.2 2018/02/24 * * Author: Fred N. van Kempen, * @@ -181,6 +181,7 @@ #define IDS_2175 2175 // "ZIP images (*.IM?)\0*.IM..." #define IDS_2176 2176 // "ZIP images (*.IM?)\0*.IM..." #define IDS_2177 2177 // "ZIP %i (%03i): %ls" +#define IDS_2178 2178 // "Unable to initialize OpenAL.." #define IDS_4096 4096 // "Hard disk (%s)" #define IDS_4097 4097 // "%01i:%01i" @@ -261,7 +262,7 @@ #define IDS_LANG_ENUS IDS_7168 -#define STR_NUM_2048 130 +#define STR_NUM_2048 131 #define STR_NUM_3072 11 #define STR_NUM_4096 20 #define STR_NUM_4352 7 diff --git a/src/machine/machine.c b/src/machine/machine.c index 8ce8a7a..4f90c03 100644 --- a/src/machine/machine.c +++ b/src/machine/machine.c @@ -8,7 +8,7 @@ * * Handling of the emulated machines. * - * Version: @(#)machine.c 1.0.1 2018/02/14 + * Version: @(#)machine.c 1.0.2 2018/02/24 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -51,17 +51,24 @@ #include "../serial.h" #include "../disk/hdc.h" #include "../disk/hdc_ide.h" +#include "../plat.h" #include "machine.h" -int machine; -int AT, PCI; -int romset; +#define PATH_ROM_BIOS "roms/machines" + + +int romset; +int machine; +int AT, PCI; void machine_init(void) { + char temp[1024]; + int i; + pclog("Initializing as \"%s\"\n", machine_getname()); ide_set_bus_master(NULL, NULL, NULL); @@ -71,7 +78,21 @@ machine_init(void) PCI = IS_ARCH(machine, MACHINE_PCI); /* Load the machine's ROM BIOS. */ +#if 0 + strcpy(temp, PATH_ROM_BIOS); + i = strlen(temp); +#ifdef _WIN32 + temp[i++] = '\\'; +#else + temp[i++] = '/'; +#endif + strcpy(&temp[i], machines[machine].bios_path); + rom_load_bios(temp); +#else rom_load_bios(romset); +#endif + + /* Activate the ROM BIOS. */ mem_add_bios(); /* All good, boot the machine! */ diff --git a/src/machine/machine.h b/src/machine/machine.h index 4041a23..270b178 100644 --- a/src/machine/machine.h +++ b/src/machine/machine.h @@ -8,7 +8,7 @@ * * Handling of the emulated machines. * - * Version: @(#)machine.h 1.0.2 2018/02/22 + * Version: @(#)machine.h 1.0.3 2018/02/24 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -60,16 +60,16 @@ typedef struct _machine_ { - const char *name; - int id; - const char *internal_name; - const char *bios_path; + const char *name; + int id; + const char *internal_name; + const char *bios_path; struct { - const char *name; + const char *name; #ifdef EMU_CPU_H - CPU *cpus; + CPU *cpus; #else - void *cpus; + void *cpus; #endif } cpu[5]; int fixed_gfxcard; diff --git a/src/network/net_pcap.c b/src/network/net_pcap.c index c135c07..caca158 100644 --- a/src/network/net_pcap.c +++ b/src/network/net_pcap.c @@ -49,7 +49,7 @@ #include #include #include -#include +#include #include "../emu.h" #include "../config.h" #include "../device.h" diff --git a/src/network/pcap_if.c b/src/network/pcap_if.c index 3faa02c..b1606ef 100644 --- a/src/network/pcap_if.c +++ b/src/network/pcap_if.c @@ -10,7 +10,7 @@ * * Based on the "libpcap" examples. * - * Version: @(#)pcap_if.c 1.0.8 2018/02/14 + * Version: @(#)pcap_if.c 1.0.9 2018/02/24 * * Author: Fred N. van Kempen, * @@ -52,7 +52,7 @@ #include #include #include -#include +#include #include #include "../emu.h" #include "../plat.h" diff --git a/src/rom.h b/src/rom.h index e0dee2f..60a0de3 100644 --- a/src/rom.h +++ b/src/rom.h @@ -8,7 +8,7 @@ * * Definitions for the ROM image handler. * - * Version: @(#)rom.h 1.0.1 2018/02/14 + * Version: @(#)rom.h 1.0.2 2018/02/23 * * Authors: Fred N. van Kempen, * @@ -60,6 +60,8 @@ romset==ROM_WIN486) #endif +#define ROMDEF_NFILES 8 /* max number of rom image files */ + typedef struct { uint8_t *rom; @@ -67,6 +69,19 @@ typedef struct { mem_mapping_t mapping; } rom_t; +typedef struct { + int mode; + int nfiles; + uint32_t offset; + uint32_t total; + struct romfile { + char path[1024]; + int mode; + uint32_t offset; + uint32_t skip; + } files[ROMDEF_NFILES]; +} romdef_t; + enum { ROM_IBMPC = 0, /* 301 keyboard error, 131 cassette (!!!) error */ @@ -212,7 +227,7 @@ extern int rom_init_interleaved(rom_t *rom, wchar_t *fn_low, int size, int mask, int file_offset, uint32_t flags); -extern int rom_load_bios(int rom_id); +extern int rom_load_bios(int romset); #endif /*EMU_ROM_H*/ diff --git a/src/sound/midi_fluidsynth.c b/src/sound/midi_fluidsynth.c index fb68fac..e403b6a 100644 --- a/src/sound/midi_fluidsynth.c +++ b/src/sound/midi_fluidsynth.c @@ -8,7 +8,7 @@ * * Interface to FluidSynth MIDI. * - * Version: @(#)midi_fluidsynth.c 1.0.1 2018/02/14 + * Version: @(#)midi_fluidsynth.c 1.0.2 2018/02/24 * * Code borrowed from scummvm. * @@ -58,543 +58,549 @@ #define RENDER_RATE 100 #define BUFFER_SEGMENTS 10 +#ifdef _WIN32 +# define PATH_FS_DLL "libfluidsynth.dll" +#else +# define PATH_FS_DLL "libfluidsynth.so" +#endif + extern void givealbuffer_midi(void *buf, uint32_t size); -extern void pclog(const char *format, ...); extern void al_set_midi(int freq, int buf_size); extern int soundon; + static void *fluidsynth_handle; /* handle to FluidSynth DLL */ /* Pointers to the real functions. */ static fluid_settings_t*(*f_new_fluid_settings)(void); -static void (*f_delete_fluid_settings)(fluid_settings_t *settings); -static int (*f_fluid_settings_setnum)(fluid_settings_t *settings, const char *name, double val); -static int (*f_fluid_settings_getnum)(fluid_settings_t *settings, const char *name, double *val); -static fluid_synth_t * (*f_new_fluid_synth)(fluid_settings_t *settings); -static int (*f_delete_fluid_synth)(fluid_synth_t *synth); -static int (*f_fluid_synth_noteon)(fluid_synth_t *synth, int chan, int key, int vel); -static int (*f_fluid_synth_noteoff)(fluid_synth_t *synth, int chan, int key); -static int (*f_fluid_synth_cc)(fluid_synth_t *synth, int chan, int ctrl, int val); -static int (*f_fluid_synth_sysex)(fluid_synth_t *synth, const char *data, int len, char *response, int *response_len, int *handled, int dryrun); -static int (*f_fluid_synth_pitch_bend)(fluid_synth_t *synth, int chan, int val); -static int (*f_fluid_synth_program_change)(fluid_synth_t *synth, int chan, int program); -static int (*f_fluid_synth_sfload)(fluid_synth_t *synth, const char *filename, int reset_presets); -static int (*f_fluid_synth_sfunload)(fluid_synth_t *synth, unsigned int id, int reset_presets); -static int (*f_fluid_synth_set_interp_method)(fluid_synth_t *synth, int chan, int interp_method); -static void (*f_fluid_synth_set_reverb)(fluid_synth_t *synth, double roomsize, double damping, double width, double level); -static void (*f_fluid_synth_set_reverb_on)(fluid_synth_t *synth, int on); -static void (*f_fluid_synth_set_chorus)(fluid_synth_t *synth, int nr, double level, double speed, double depth_ms, int type); -static void (*f_fluid_synth_set_chorus_on)(fluid_synth_t *synth, int on); -static int (*f_fluid_synth_write_s16)(fluid_synth_t *synth, int len, void *lout, int loff, int lincr, void *rout, int roff, int rincr); -static int (*f_fluid_synth_write_float)(fluid_synth_t *synth, int len, void *lout, int loff, int lincr, void *rout, int roff, int rincr); -static char* (*f_fluid_version_str)(void); +static void (*f_delete_fluid_settings)(fluid_settings_t *settings); +static int (*f_fluid_settings_setnum)(fluid_settings_t *settings, const char *name, double val); +static int (*f_fluid_settings_getnum)(fluid_settings_t *settings, const char *name, double *val); +static fluid_synth_t *(*f_new_fluid_synth)(fluid_settings_t *settings); +static int (*f_delete_fluid_synth)(fluid_synth_t *synth); +static int (*f_fluid_synth_noteon)(fluid_synth_t *synth, int chan, int key, int vel); +static int (*f_fluid_synth_noteoff)(fluid_synth_t *synth, int chan, int key); +static int (*f_fluid_synth_cc)(fluid_synth_t *synth, int chan, int ctrl, int val); +static int (*f_fluid_synth_sysex)(fluid_synth_t *synth, const char *data, int len, char *response, int *response_len, int *handled, int dryrun); +static int (*f_fluid_synth_pitch_bend)(fluid_synth_t *synth, int chan, int val); +static int (*f_fluid_synth_program_change)(fluid_synth_t *synth, int chan, int program); +static int (*f_fluid_synth_sfload)(fluid_synth_t *synth, const char *filename, int reset_presets); +static int (*f_fluid_synth_sfunload)(fluid_synth_t *synth, unsigned int id, int reset_presets); +static int (*f_fluid_synth_set_interp_method)(fluid_synth_t *synth, int chan, int interp_method); +static void (*f_fluid_synth_set_reverb)(fluid_synth_t *synth, double roomsize, double damping, double width, double level); +static void (*f_fluid_synth_set_reverb_on)(fluid_synth_t *synth, int on); +static void (*f_fluid_synth_set_chorus)(fluid_synth_t *synth, int nr, double level, double speed, double depth_ms, int type); +static void (*f_fluid_synth_set_chorus_on)(fluid_synth_t *synth, int on); +static int (*f_fluid_synth_write_s16)(fluid_synth_t *synth, int len, void *lout, int loff, int lincr, void *rout, int roff, int rincr); +static int (*f_fluid_synth_write_float)(fluid_synth_t *synth, int len, void *lout, int loff, int lincr, void *rout, int roff, int rincr); +static char *(*f_fluid_version_str)(void); + static dllimp_t fluidsynth_imports[] = { - { "new_fluid_settings", &f_new_fluid_settings }, - { "delete_fluid_settings", &f_delete_fluid_settings }, - { "fluid_settings_setnum", &f_fluid_settings_setnum }, - { "fluid_settings_getnum", &f_fluid_settings_getnum }, - { "new_fluid_synth", &f_new_fluid_synth }, - { "delete_fluid_synth", &f_delete_fluid_synth }, - { "fluid_synth_noteon", &f_fluid_synth_noteon }, - { "fluid_synth_noteoff", &f_fluid_synth_noteoff }, - { "fluid_synth_cc", &f_fluid_synth_cc }, - { "fluid_synth_sysex", &f_fluid_synth_sysex }, - { "fluid_synth_pitch_bend", &f_fluid_synth_pitch_bend }, - { "fluid_synth_program_change", &f_fluid_synth_program_change }, - { "fluid_synth_sfload", &f_fluid_synth_sfload }, - { "fluid_synth_sfunload", &f_fluid_synth_sfunload }, - { "fluid_synth_set_interp_method", &f_fluid_synth_set_interp_method }, - { "fluid_synth_set_reverb", &f_fluid_synth_set_reverb }, - { "fluid_synth_set_reverb_on", &f_fluid_synth_set_reverb_on }, - { "fluid_synth_set_chorus", &f_fluid_synth_set_chorus }, - { "fluid_synth_set_chorus_on", &f_fluid_synth_set_chorus_on }, - { "fluid_synth_write_s16", &f_fluid_synth_write_s16 }, - { "fluid_synth_write_float", &f_fluid_synth_write_float }, - { "fluid_version_str", &f_fluid_version_str }, - { NULL, NULL }, + { "new_fluid_settings", &f_new_fluid_settings }, + { "delete_fluid_settings", &f_delete_fluid_settings }, + { "fluid_settings_setnum", &f_fluid_settings_setnum }, + { "fluid_settings_getnum", &f_fluid_settings_getnum }, + { "new_fluid_synth", &f_new_fluid_synth }, + { "delete_fluid_synth", &f_delete_fluid_synth }, + { "fluid_synth_noteon", &f_fluid_synth_noteon }, + { "fluid_synth_noteoff", &f_fluid_synth_noteoff }, + { "fluid_synth_cc", &f_fluid_synth_cc }, + { "fluid_synth_sysex", &f_fluid_synth_sysex }, + { "fluid_synth_pitch_bend", &f_fluid_synth_pitch_bend }, + { "fluid_synth_program_change", &f_fluid_synth_program_change }, + { "fluid_synth_sfload", &f_fluid_synth_sfload }, + { "fluid_synth_sfunload", &f_fluid_synth_sfunload }, + { "fluid_synth_set_interp_method", &f_fluid_synth_set_interp_method}, + { "fluid_synth_set_reverb", &f_fluid_synth_set_reverb }, + { "fluid_synth_set_reverb_on", &f_fluid_synth_set_reverb_on }, + { "fluid_synth_set_chorus", &f_fluid_synth_set_chorus }, + { "fluid_synth_set_chorus_on", &f_fluid_synth_set_chorus_on }, + { "fluid_synth_write_s16", &f_fluid_synth_write_s16 }, + { "fluid_synth_write_float", &f_fluid_synth_write_float }, + { "fluid_version_str", &f_fluid_version_str }, + { NULL, NULL } }; -typedef struct fluidsynth -{ - fluid_settings_t* settings; - fluid_synth_t* synth; - int samplerate; - int sound_font; - - thread_t* thread_h; - event_t* event; - int buf_size; - float* buffer; - int16_t* buffer_int16; - int midi_pos; +typedef struct fluidsynth { + fluid_settings_t* settings; + fluid_synth_t* synth; + int samplerate; + int sound_font; + thread_t* thread_h; + event_t* event; + int buf_size; + float* buffer; + int16_t* buffer_int16; + int midi_pos; } fluidsynth_t; + fluidsynth_t fsdev; -int fluidsynth_available(void) + +static int +fluidsynth_available(void) { - return 1; + return(1); } -void fluidsynth_poll(void) + +static void +fluidsynth_poll(void) { - fluidsynth_t* data = &fsdev; - data->midi_pos++; - if (data->midi_pos == 48000/RENDER_RATE) - { - data->midi_pos = 0; - thread_set_event(data->event); - } + fluidsynth_t* data = &fsdev; + + data->midi_pos++; + if (data->midi_pos == 48000/RENDER_RATE) { + data->midi_pos = 0; + thread_set_event(data->event); + } } -static void fluidsynth_thread(void *param) + +static void +fluidsynth_thread(void *param) { - fluidsynth_t* data = (fluidsynth_t*)param; - int buf_pos = 0; - int buf_size = data->buf_size / BUFFER_SEGMENTS; - while (1) - { - thread_wait_event(data->event, -1); - if (sound_is_float) - { - float *buf = (float*)((uint8_t*)data->buffer + buf_pos); - memset(buf, 0, buf_size); - if (data->synth) - f_fluid_synth_write_float(data->synth, buf_size/(2 * sizeof(float)), buf, 0, 2, buf, 1, 2); - buf_pos += buf_size; - if (buf_pos >= data->buf_size) - { - if (soundon) - givealbuffer_midi(data->buffer, data->buf_size / sizeof(float)); - buf_pos = 0; - } + fluidsynth_t* data = (fluidsynth_t*)param; + int buf_pos = 0; + int buf_size = data->buf_size / BUFFER_SEGMENTS; + + while (1) { + thread_wait_event(data->event, -1); + if (sound_is_float) { + float *buf = (float*)((uint8_t*)data->buffer + buf_pos); + memset(buf, 0, buf_size); + if (data->synth) + f_fluid_synth_write_float(data->synth, buf_size/(2 * sizeof(float)), buf, 0, 2, buf, 1, 2); + buf_pos += buf_size; + if (buf_pos >= data->buf_size) { + if (soundon) + givealbuffer_midi(data->buffer, data->buf_size / sizeof(float)); + buf_pos = 0; } - else - { - int16_t *buf = (int16_t*)((uint8_t*)data->buffer_int16 + buf_pos); - memset(buf, 0, buf_size); - if (data->synth) - f_fluid_synth_write_s16(data->synth, buf_size/(2 * sizeof(int16_t)), buf, 0, 2, buf, 1, 2); - buf_pos += buf_size; - if (buf_pos >= data->buf_size) - { - if (soundon) - givealbuffer_midi(data->buffer_int16, data->buf_size / sizeof(int16_t)); - buf_pos = 0; - } + } else { + int16_t *buf = (int16_t*)((uint8_t*)data->buffer_int16 + buf_pos); + memset(buf, 0, buf_size); + if (data->synth) + f_fluid_synth_write_s16(data->synth, buf_size/(2 * sizeof(int16_t)), buf, 0, 2, buf, 1, 2); + buf_pos += buf_size; + if (buf_pos >= data->buf_size) { + if (soundon) + givealbuffer_midi(data->buffer_int16, data->buf_size / sizeof(int16_t)); + buf_pos = 0; } + } #if 0 - if (sound_is_float) - { - memset(data->buffer, 0, data->buf_size * sizeof(float)); - if (data->synth) - f_fluid_synth_write_float(data->synth, data->buf_size/2, data->buffer, 0, 2, data->buffer, 1, 2); - if (soundon) - givealbuffer_midi(data->buffer, data->buf_size); - } - else - { - memset(data->buffer, 0, data->buf_size * sizeof(int16_t)); - if (data->synth) - f_fluid_synth_write_s16(data->synth, data->buf_size/2, data->buffer_int16, 0, 2, data->buffer_int16, 1, 2); - if (soundon) - givealbuffer_midi(data->buffer_int16, data->buf_size); - } + if (sound_is_float) { + memset(data->buffer, 0, data->buf_size * sizeof(float)); + if (data->synth) + f_fluid_synth_write_float(data->synth, data->buf_size/2, data->buffer, 0, 2, data->buffer, 1, 2); + if (soundon) + givealbuffer_midi(data->buffer, data->buf_size); + } else { + memset(data->buffer, 0, data->buf_size * sizeof(int16_t)); + if (data->synth) + f_fluid_synth_write_s16(data->synth, data->buf_size/2, data->buffer_int16, 0, 2, data->buffer_int16, 1, 2); + if (soundon) + givealbuffer_midi(data->buffer_int16, data->buf_size); + } #endif - } + } } -void fluidsynth_msg(uint8_t *msg) + +void +fluidsynth_msg(uint8_t *msg) { - fluidsynth_t* data = &fsdev; + fluidsynth_t* data = &fsdev; + uint32_t val = *((uint32_t*)msg); + uint32_t param2 = (uint8_t) ((val >> 16) & 0xFF); + uint32_t param1 = (uint8_t) ((val >> 8) & 0xFF); + uint8_t cmd = (uint8_t) (val & 0xF0); + uint8_t chan = (uint8_t) (val & 0x0F); - uint32_t val = *((uint32_t*)msg); + switch (cmd) { + case 0x80: /* Note Off */ + f_fluid_synth_noteoff(data->synth, chan, param1); + break; - uint32_t param2 = (uint8_t) ((val >> 16) & 0xFF); - uint32_t param1 = (uint8_t) ((val >> 8) & 0xFF); - uint8_t cmd = (uint8_t) (val & 0xF0); - uint8_t chan = (uint8_t) (val & 0x0F); + case 0x90: /* Note On */ + f_fluid_synth_noteon(data->synth, chan, param1, param2); + break; - switch (cmd) { - case 0x80: /* Note Off */ - f_fluid_synth_noteoff(data->synth, chan, param1); - break; - case 0x90: /* Note On */ - f_fluid_synth_noteon(data->synth, chan, param1, param2); - break; - case 0xA0: /* Aftertouch */ - break; - case 0xB0: /* Control Change */ - f_fluid_synth_cc(data->synth, chan, param1, param2); - break; - case 0xC0: /* Program Change */ - f_fluid_synth_program_change(data->synth, chan, param1); - break; - case 0xD0: /* Channel Pressure */ - break; - case 0xE0: /* Pitch Bend */ - f_fluid_synth_pitch_bend(data->synth, chan, (param2 << 7) | param1); - break; - case 0xF0: /* SysEx */ - break; - default: - /* pclog("fluidsynth: unknown send() command 0x%02X", cmd); */ - break; - } -} + case 0xA0: /* Aftertouch */ + break; -void fluidsynth_sysex(uint8_t* data, unsigned int len) -{ - fluidsynth_t* d = &fsdev; + case 0xB0: /* Control Change */ + f_fluid_synth_cc(data->synth, chan, param1, param2); + break; - f_fluid_synth_sysex(d->synth, (const char *) data, len, 0, 0, 0, 0); -} + case 0xC0: /* Program Change */ + f_fluid_synth_program_change(data->synth, chan, param1); + break; -void* fluidsynth_init(device_t *info) -{ - fluidsynth_t* data = &fsdev; - memset(data, 0, sizeof(fluidsynth_t)); + case 0xD0: /* Channel Pressure */ + break; - /* Try loading the DLL. */ -#ifdef _WIN32 - fluidsynth_handle = dynld_module("libfluidsynth.dll", fluidsynth_imports); -#else - fluidsynth_handle = dynld_module("libfluidsynth.so", fluidsynth_imports); + case 0xE0: /* Pitch Bend */ + f_fluid_synth_pitch_bend(data->synth, chan, (param2 << 7) | param1); + break; + + case 0xF0: /* SysEx */ + break; + + default: +#if 0 + pclog("fluidsynth: unknown send() command 0x%02X", cmd); #endif - if (fluidsynth_handle == NULL) - { - ui_msgbox(MBX_ERROR, (wchar_t *)IDS_2171); - return NULL; + break; } - - data->settings = f_new_fluid_settings(); - - f_fluid_settings_setnum(data->settings, "synth.sample-rate", 44100); - f_fluid_settings_setnum(data->settings, "synth.gain", device_get_config_int("output_gain")/100.0f); - - data->synth = f_new_fluid_synth(data->settings); - - char* sound_font = device_get_config_string("sound_font"); - data->sound_font = f_fluid_synth_sfload(data->synth, sound_font, 1); - - if (device_get_config_int("chorus")) - { - f_fluid_synth_set_chorus_on(data->synth, 1); - - int chorus_voices = device_get_config_int("chorus_voices"); - double chorus_level = device_get_config_int("chorus_level") / 100.0; - double chorus_speed = device_get_config_int("chorus_speed") / 100.0; - double chorus_depth = device_get_config_int("chorus_depth") / 10.0; - - int chorus_waveform = FLUID_CHORUS_MOD_SINE; - if (device_get_config_int("chorus_waveform") == 0) - chorus_waveform = FLUID_CHORUS_MOD_SINE; - else - chorus_waveform = FLUID_CHORUS_MOD_TRIANGLE; - - f_fluid_synth_set_chorus(data->synth, chorus_voices, chorus_level, chorus_speed, chorus_depth, chorus_waveform); - } - else - f_fluid_synth_set_chorus_on(data->synth, 0); - - if (device_get_config_int("reverb")) - { - f_fluid_synth_set_reverb_on(data->synth, 1); - - double reverb_room_size = device_get_config_int("reverb_room_size") / 100.0; - double reverb_damping = device_get_config_int("reverb_damping") / 100.0; - int reverb_width = device_get_config_int("reverb_width"); - double reverb_level = device_get_config_int("reverb_level") / 100.0; - - f_fluid_synth_set_reverb(data->synth, reverb_room_size, reverb_damping, reverb_width, reverb_level); - } - else - f_fluid_synth_set_reverb_on(data->synth, 0); - - int interpolation = device_get_config_int("interpolation"); - int fs_interpolation = FLUID_INTERP_4THORDER; - - if (interpolation == 0) - fs_interpolation = FLUID_INTERP_NONE; - else if (interpolation == 1) - fs_interpolation = FLUID_INTERP_LINEAR; - else if (interpolation == 2) - fs_interpolation = FLUID_INTERP_4THORDER; - else if (interpolation == 3) - fs_interpolation = FLUID_INTERP_7THORDER; - - f_fluid_synth_set_interp_method(data->synth, -1, fs_interpolation); - - double samplerate; - f_fluid_settings_getnum(data->settings, "synth.sample-rate", &samplerate); - data->samplerate = (int)samplerate; - if (sound_is_float) - { - data->buf_size = (data->samplerate/RENDER_RATE)*2*sizeof(float)*BUFFER_SEGMENTS; - data->buffer = malloc(data->buf_size); - data->buffer_int16 = NULL; - } - else - { - data->buf_size = (data->samplerate/RENDER_RATE)*2*sizeof(int16_t)*BUFFER_SEGMENTS; - data->buffer = NULL; - data->buffer_int16 = malloc(data->buf_size); - } - data->event = thread_create_event(); - data->thread_h = thread_create(fluidsynth_thread, data); - - al_set_midi(data->samplerate, data->buf_size); - - /* pclog("fluidsynth (%s) initialized, samplerate %d, buf_size %d\n", f_fluid_version_str(), data->samplerate, data->buf_size); */ - - midi_device_t* dev = malloc(sizeof(midi_device_t)); - memset(dev, 0, sizeof(midi_device_t)); - - dev->play_msg = fluidsynth_msg; - dev->play_sysex = fluidsynth_sysex; - dev->poll = fluidsynth_poll; - - midi_init(dev); - - return dev; } -void fluidsynth_close(void* p) + +void +fluidsynth_sysex(uint8_t *data, unsigned int len) { - if (!p) return; + fluidsynth_t* d = &fsdev; - fluidsynth_t* data = &fsdev; - - if (data->sound_font != -1) { - f_fluid_synth_sfunload(data->synth, data->sound_font, 1); - data->sound_font = -1; - } - - if (data->synth) { - f_delete_fluid_synth(data->synth); - data->synth = NULL; - } - - if (data->settings) { - f_delete_fluid_settings(data->settings); - data->settings = NULL; - } - - midi_close(); - - if (data->buffer) - { - free(data->buffer); - data->buffer = NULL; - } - - if (data->buffer_int16) - { - free(data->buffer_int16); - data->buffer_int16 = NULL; - } - - /* Unload the DLL if possible. */ - if (fluidsynth_handle != NULL) - { - dynld_close(fluidsynth_handle); - fluidsynth_handle = NULL; - } - - /* pclog("fluidsynth closed\n"); */ + f_fluid_synth_sysex(d->synth, (const char *)data, len, 0, 0, 0, 0); } -static device_config_t fluidsynth_config[] = + +static void * +fluidsynth_init(device_t *info) { - { - .name = "sound_font", - .description = "Sound Font", - .type = CONFIG_FNAME, - .default_string = "", - .file_filter = - { - { - .description = "SF2 Sound Fonts", - .extensions = - { - "sf2" - } - } - } - }, - { - .name = "output_gain", - .description = "Output Gain", - .type = CONFIG_SPINNER, - .spinner = - { - .min = 0, - .max = 100 - }, - .default_int = 100 - }, - { - .name = "chorus", - .description = "Chorus", - .type = CONFIG_BINARY, - .default_int = 0 - }, - { - .name = "chorus_voices", - .description = "Chorus Voices", - .type = CONFIG_SPINNER, - .spinner = - { - .min = 0, - .max = 99 - }, - .default_int = 3 - }, - { - .name = "chorus_level", - .description = "Chorus Level", - .type = CONFIG_SPINNER, - .spinner = - { - .min = 0, - .max = 100 - }, - .default_int = 100 - }, - { - .name = "chorus_speed", - .description = "Chorus Speed", - .type = CONFIG_SPINNER, - .spinner = - { - .min = 30, - .max = 500 - }, - .default_int = 30 - }, - { - .name = "chorus_depth", - .description = "Chorus Depth", - .type = CONFIG_SPINNER, - .spinner = - { - .min = 0, - .max = 210 - }, - .default_int = 80 - }, - { - .name = "chorus_waveform", - .description = "Chorus Waveform", - .type = CONFIG_SELECTION, - .selection = - { - { - .description = "Sine", - .value = 0 - }, - { - .description = "Triangle", - .value = 1 - } - }, - .default_int = 0 - }, - { - .name = "reverb", - .description = "Reverb", - .type = CONFIG_BINARY, - .default_int = 0 - }, - { - .name = "reverb_room_size", - .description = "Reverb Room Size", - .type = CONFIG_SPINNER, - .spinner = - { - .min = 0, - .max = 120 - }, - .default_int = 20 - }, - { - .name = "reverb_damping", - .description = "Reverb Damping", - .type = CONFIG_SPINNER, - .spinner = - { - .min = 0, - .max = 100 - }, - .default_int = 0 - }, - { - .name = "reverb_width", - .description = "Reverb Width", - .type = CONFIG_SPINNER, - .spinner = - { - .min = 0, - .max = 100 - }, - .default_int = 1 - }, - { - .name = "reverb_level", - .description = "Reverb Level", - .type = CONFIG_SPINNER, - .spinner = - { - .min = 0, - .max = 100 - }, - .default_int = 90 - }, - { - .name = "interpolation", - .description = "Interpolation Method", - .type = CONFIG_SELECTION, - .selection = - { - { - .description = "None", - .value = 0 - }, - { - .description = "Linear", - .value = 1 - }, - { - .description = "4th Order", - .value = 2 - }, - { - .description = "7th Order", - .value = 3 - } - }, - .default_int = 2 - }, - { - .type = -1 - } + fluidsynth_t* data = &fsdev; + + memset(data, 0x00, sizeof(fluidsynth_t)); + + /* Try loading the DLL. */ + fluidsynth_handle = dynld_module(PATH_FS_DLL, fluidsynth_imports); + if (fluidsynth_handle == NULL) { + ui_msgbox(MBX_ERROR, (wchar_t *)IDS_2171); + return(NULL); + } + + data->settings = f_new_fluid_settings(); + + f_fluid_settings_setnum(data->settings, "synth.sample-rate", 44100); + f_fluid_settings_setnum(data->settings, "synth.gain", device_get_config_int("output_gain")/100.0f); + + data->synth = f_new_fluid_synth(data->settings); + + char* sound_font = device_get_config_string("sound_font"); + data->sound_font = f_fluid_synth_sfload(data->synth, sound_font, 1); + + if (device_get_config_int("chorus")) { + f_fluid_synth_set_chorus_on(data->synth, 1); + + int chorus_voices = device_get_config_int("chorus_voices"); + double chorus_level = device_get_config_int("chorus_level") / 100.0; + double chorus_speed = device_get_config_int("chorus_speed") / 100.0; + double chorus_depth = device_get_config_int("chorus_depth") / 10.0; + + int chorus_waveform = FLUID_CHORUS_MOD_SINE; + if (device_get_config_int("chorus_waveform") == 0) + chorus_waveform = FLUID_CHORUS_MOD_SINE; + else + chorus_waveform = FLUID_CHORUS_MOD_TRIANGLE; + + f_fluid_synth_set_chorus(data->synth, chorus_voices, chorus_level, chorus_speed, chorus_depth, chorus_waveform); + } else + f_fluid_synth_set_chorus_on(data->synth, 0); + + if (device_get_config_int("reverb")) { + f_fluid_synth_set_reverb_on(data->synth, 1); + + double reverb_room_size = device_get_config_int("reverb_room_size") / 100.0; + double reverb_damping = device_get_config_int("reverb_damping") / 100.0; + int reverb_width = device_get_config_int("reverb_width"); + double reverb_level = device_get_config_int("reverb_level") / 100.0; + + f_fluid_synth_set_reverb(data->synth, reverb_room_size, reverb_damping, reverb_width, reverb_level); + } else + f_fluid_synth_set_reverb_on(data->synth, 0); + + int interpolation = device_get_config_int("interpolation"); + int fs_interpolation = FLUID_INTERP_4THORDER; + + if (interpolation == 0) + fs_interpolation = FLUID_INTERP_NONE; + else if (interpolation == 1) + fs_interpolation = FLUID_INTERP_LINEAR; + else if (interpolation == 2) + fs_interpolation = FLUID_INTERP_4THORDER; + else if (interpolation == 3) + fs_interpolation = FLUID_INTERP_7THORDER; + + f_fluid_synth_set_interp_method(data->synth, -1, fs_interpolation); + + double samplerate; + f_fluid_settings_getnum(data->settings, "synth.sample-rate", &samplerate); + data->samplerate = (int)samplerate; + if (sound_is_float) { + data->buf_size = (data->samplerate/RENDER_RATE)*2*sizeof(float)*BUFFER_SEGMENTS; + data->buffer = malloc(data->buf_size); + data->buffer_int16 = NULL; + } else { + data->buf_size = (data->samplerate/RENDER_RATE)*2*sizeof(int16_t)*BUFFER_SEGMENTS; + data->buffer = NULL; + data->buffer_int16 = malloc(data->buf_size); + } + data->event = thread_create_event(); + data->thread_h = thread_create(fluidsynth_thread, data); + + al_set_midi(data->samplerate, data->buf_size); + +#if 0 + pclog("fluidsynth (%s) initialized, samplerate %d, buf_size %d\n", f_fluid_version_str(), data->samplerate, data->buf_size); +#endif + + midi_device_t* dev = malloc(sizeof(midi_device_t)); + memset(dev, 0, sizeof(midi_device_t)); + + dev->play_msg = fluidsynth_msg; + dev->play_sysex = fluidsynth_sysex; + dev->poll = fluidsynth_poll; + + midi_init(dev); + + return(dev); +} + + +static void +fluidsynth_close(void* priv) +{ + if (priv == NULL) return; + + fluidsynth_t* data = &fsdev; + + if (data->sound_font != -1) { + f_fluid_synth_sfunload(data->synth, data->sound_font, 1); + data->sound_font = -1; + } + + if (data->synth) { + f_delete_fluid_synth(data->synth); + data->synth = NULL; + } + + if (data->settings) { + f_delete_fluid_settings(data->settings); + data->settings = NULL; + } + + midi_close(); + + if (data->buffer) { + free(data->buffer); + data->buffer = NULL; + } + + if (data->buffer_int16) { + free(data->buffer_int16); + data->buffer_int16 = NULL; + } + + /* Unload the DLL if possible. */ + if (fluidsynth_handle != NULL) { + dynld_close(fluidsynth_handle); + fluidsynth_handle = NULL; + } +} + + +static device_config_t +fluidsynth_config[] = { + { + .name = "sound_font", + .description = "Sound Font", + .type = CONFIG_FNAME, + .default_string = "", + .file_filter = + { + { + .description = "SF2 Sound Fonts", + .extensions = + { + "sf2" + } + } + } + }, + { + .name = "output_gain", + .description = "Output Gain", + .type = CONFIG_SPINNER, + .spinner = + { + .min = 0, + .max = 100 + }, + .default_int = 100 + }, + { + .name = "chorus", + .description = "Chorus", + .type = CONFIG_BINARY, + .default_int = 0 + }, + { + .name = "chorus_voices", + .description = "Chorus Voices", + .type = CONFIG_SPINNER, + .spinner = + { + .min = 0, + .max = 99 + }, + .default_int = 3 + }, + { + .name = "chorus_level", + .description = "Chorus Level", + .type = CONFIG_SPINNER, + .spinner = + { + .min = 0, + .max = 100 + }, + .default_int = 100 + }, + { + .name = "chorus_speed", + .description = "Chorus Speed", + .type = CONFIG_SPINNER, + .spinner = + { + .min = 30, + .max = 500 + }, + .default_int = 30 + }, + { + .name = "chorus_depth", + .description = "Chorus Depth", + .type = CONFIG_SPINNER, + .spinner = + { + .min = 0, + .max = 210 + }, + .default_int = 80 + }, + { + .name = "chorus_waveform", + .description = "Chorus Waveform", + .type = CONFIG_SELECTION, + .selection = + { + { + .description = "Sine", + .value = 0 + }, + { + .description = "Triangle", + .value = 1 + } + }, + .default_int = 0 + }, + { + .name = "reverb", + .description = "Reverb", + .type = CONFIG_BINARY, + .default_int = 0 + }, + { + .name = "reverb_room_size", + .description = "Reverb Room Size", + .type = CONFIG_SPINNER, + .spinner = + { + .min = 0, + .max = 120 + }, + .default_int = 20 + }, + { + .name = "reverb_damping", + .description = "Reverb Damping", + .type = CONFIG_SPINNER, + .spinner = + { + .min = 0, + .max = 100 + }, + .default_int = 0 + }, + { + .name = "reverb_width", + .description = "Reverb Width", + .type = CONFIG_SPINNER, + .spinner = + { + .min = 0, + .max = 100 + }, + .default_int = 1 + }, + { + .name = "reverb_level", + .description = "Reverb Level", + .type = CONFIG_SPINNER, + .spinner = + { + .min = 0, + .max = 100 + }, + .default_int = 90 + }, + { + .name = "interpolation", + .description = "Interpolation Method", + .type = CONFIG_SELECTION, + .selection = + { + { + .description = "None", + .value = 0 + }, + { + .description = "Linear", + .value = 1 + }, + { + .description = "4th Order", + .value = 2 + }, + { + .description = "7th Order", + .value = 3 + } + }, + .default_int = 2 + }, + { + .type = -1 + } }; -device_t fluidsynth_device = -{ - "FluidSynth", - 0, - 0, - fluidsynth_init, - fluidsynth_close, - NULL, - fluidsynth_available, - NULL, - NULL, - NULL, - fluidsynth_config + +device_t fluidsynth_device = { + "FluidSynth", + 0, 0, + fluidsynth_init, + fluidsynth_close, + NULL, + fluidsynth_available, + NULL, + NULL, + NULL, + fluidsynth_config }; diff --git a/src/sound/openal.c b/src/sound/openal.c index 1caeb72..b92b17a 100644 --- a/src/sound/openal.c +++ b/src/sound/openal.c @@ -8,7 +8,7 @@ * * Interface to the OpenAL sound processing library. * - * Version: @(#)openal.c 1.0.1 2018/02/14 + * Version: @(#)openal.c 1.0.2 2018/02/24 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -52,24 +52,76 @@ # include #endif #include "../emu.h" +#include "../plat.h" +#include "../plat_dynld.h" +#include "../ui.h" #include "sound.h" #define FREQ 48000 #define BUFLEN SOUNDBUFLEN +#ifdef _WIN32 +# define PATH_AL_DLL "libopenal-1.dll" +#else +# define PATH_AL_DLL "libopenal.so.1" +#endif + #ifdef USE_OPENAL -ALuint buffers[4]; /* front and back buffers */ -ALuint buffers_cd[4]; /* front and back buffers */ -ALuint buffers_midi[4]; /* front and back buffers */ -static ALuint source[3]; /* audio source */ +ALuint buffers[4]; /* front and back buffers */ +ALuint buffers_cd[4]; /* front and back buffers */ +ALuint buffers_midi[4]; /* front and back buffers */ + +static ALuint source[3]; /* audio source */ +static void *openal_handle = NULL; /* handle to (open) DLL */ + +/* Pointers to the real functions. */ +static ALC_API ALCdevice* ALC_APIENTRY (*f_alcOpenDevice)(const ALCchar *devicename); +static ALC_API ALCboolean ALC_APIENTRY (*f_alcCloseDevice)(ALCdevice *device); +static ALC_API ALCcontext* ALC_APIENTRY (*f_alcCreateContext)(ALCdevice *device, const ALCint* attrlist); +static ALC_API void ALC_APIENTRY (*f_alcDestroyContext)(ALCcontext *context); +static ALC_API ALCboolean ALC_APIENTRY (*f_alcMakeContextCurrent)(ALCcontext *context); +static ALC_API ALCcontext* ALC_APIENTRY (*f_alcGetCurrentContext)(void); +static ALC_API ALCdevice* ALC_APIENTRY (*f_alcGetContextsDevice)(ALCcontext *context); +static AL_API void AL_APIENTRY (*f_alSource3f)(ALuint source, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3); +static AL_API void AL_APIENTRY (*f_alSourcef)(ALuint source, ALenum param, ALfloat value); +static AL_API void AL_APIENTRY (*f_alSourcei)(ALuint source, ALenum param, ALint value); +static AL_API void AL_APIENTRY (*f_alBufferData)(ALuint buffer, ALenum format, const ALvoid *data, ALsizei size, ALsizei freq); +static AL_API void AL_APIENTRY (*f_alSourceQueueBuffers)(ALuint source, ALsizei nb, const ALuint *buffers); +static AL_API void AL_APIENTRY (*f_alSourceUnqueueBuffers)(ALuint source, ALsizei nb, ALuint *buffers); +static AL_API void AL_APIENTRY (*f_alSourcePlay)(ALuint source); +static AL_API void AL_APIENTRY (*f_alGetSourcei)(ALuint source, ALenum param, ALint *value); +static AL_API void AL_APIENTRY (*f_alListenerf)(ALenum param, ALfloat value); +static AL_API void AL_APIENTRY (*f_alGenBuffers)(ALsizei n, ALuint *buffers); +static AL_API void AL_APIENTRY (*f_alGenSources)(ALsizei n, ALuint *sources); + +static dllimp_t openal_imports[] = { + { "alcOpenDevice", &f_alcOpenDevice }, + { "alcCloseDevice", &f_alcCloseDevice }, + { "alcCreateContext", &f_alcCreateContext }, + { "alcDestroyContext", &f_alcDestroyContext }, + { "alcMakeContextCurrent", &f_alcMakeContextCurrent }, + { "alcGetCurrentContext", &f_alcGetCurrentContext }, + { "alcGetContextsDevice", &f_alcGetContextsDevice }, + { "alSource3f", &f_alSource3f }, + { "alSourcef", &f_alSourcef }, + { "alSourcei", &f_alSourcei }, + { "alBufferData", &f_alBufferData }, + { "alSourceQueueBuffers", &f_alSourceQueueBuffers }, + { "alSourceUnqueueBuffers", &f_alSourceUnqueueBuffers }, + { "alSourcePlay", &f_alSourcePlay }, + { "alGetSourcei", &f_alGetSourcei }, + { "alListenerf", &f_alListenerf }, + { "alGenBuffers", &f_alGenBuffers }, + { "alGenSources", &f_alGenSources }, + { NULL, NULL } +}; #endif static int midi_freq = 44100; static int midi_buf_size = 4410; -static int initialized = 0; void @@ -81,20 +133,21 @@ al_set_midi(int freq, int buf_size) #ifdef USE_OPENAL -void closeal(void); -ALvoid alutInit(ALint *argc,ALbyte **argv) +ALvoid alutInit(ALint *argc, ALbyte **argv) { ALCcontext *Context; ALCdevice *Device; - + + if (openal_handle == NULL) return; + /* Open device */ - Device = alcOpenDevice((ALCchar *)""); + Device = f_alcOpenDevice((ALCchar *)""); if (Device != NULL) { /* Create context(s) */ - Context = alcCreateContext(Device, NULL); + Context = f_alcCreateContext(Device, NULL); if (Context != NULL) { /* Set active context */ - alcMakeContextCurrent(Context); + f_alcMakeContextCurrent(Context); } } } @@ -106,21 +159,29 @@ alutExit(ALvoid) ALCcontext *Context; ALCdevice *Device; + if (openal_handle == NULL) return; + /* Get active context */ - Context = alcGetCurrentContext(); + Context = f_alcGetCurrentContext(); if (Context != NULL) { /* Get device for active context */ - Device = alcGetContextsDevice(Context); + Device = f_alcGetContextsDevice(Context); if (Device != NULL) { /* Disable context */ - alcMakeContextCurrent(NULL); + f_alcMakeContextCurrent(NULL); /* Close device */ - alcCloseDevice(Device); + f_alcCloseDevice(Device); } /* Release context(s) */ - alcDestroyContext(Context); + f_alcDestroyContext(Context); + } + + /* Unload the DLL if possible. */ + if (openal_handle != NULL) { + dynld_close((void *)openal_handle); + openal_handle = NULL; } } #endif @@ -138,26 +199,34 @@ closeal(void) void initalmain(int argc, char *argv[]) { - if (! initialized) return; - #ifdef USE_OPENAL - alutInit(0,0); - atexit(closeal); + if (openal_handle != NULL) return; + + /* Try loading the DLL. */ + openal_handle = dynld_module(PATH_AL_DLL, openal_imports); + if (openal_handle != NULL) { + pclog("SOUND: OpenAL module '%s' loaded.\n", PATH_AL_DLL); + alutInit(NULL, NULL); + atexit(closeal); + } else { + pclog("SOUND: unable to load OpenAL module '%s' !\n", PATH_AL_DLL); + ui_msgbox(MBX_ERROR, (wchar_t *)IDS_2178); + return; + } #endif - initialized = 0; } void inital(void) { - if (initialized) return; - #ifdef USE_OPENAL float *buf = NULL, *cd_buf = NULL, *midi_buf = NULL; int16_t *buf_int16 = NULL, *cd_buf_int16 = NULL, *midi_buf_int16 = NULL; int c; + if (openal_handle == NULL) return; + if (sound_is_float) { buf = (float *) malloc((BUFLEN << 1) * sizeof(float)); cd_buf = (float *) malloc((CD_BUFLEN << 1) * sizeof(float)); @@ -168,27 +237,27 @@ inital(void) midi_buf_int16 = (int16_t *) malloc(midi_buf_size * sizeof(int16_t)); } - alGenBuffers(4, buffers); - alGenBuffers(4, buffers_cd); - alGenBuffers(4, buffers_midi); + f_alGenBuffers(4, buffers); + f_alGenBuffers(4, buffers_cd); + f_alGenBuffers(4, buffers_midi); - alGenSources(3, source); + f_alGenSources(3, source); - alSource3f(source[0], AL_POSITION, 0.0, 0.0, 0.0); - alSource3f(source[0], AL_VELOCITY, 0.0, 0.0, 0.0); - alSource3f(source[0], AL_DIRECTION, 0.0, 0.0, 0.0); - alSourcef (source[0], AL_ROLLOFF_FACTOR, 0.0 ); - alSourcei (source[0], AL_SOURCE_RELATIVE, AL_TRUE ); - alSource3f(source[1], AL_POSITION, 0.0, 0.0, 0.0); - alSource3f(source[1], AL_VELOCITY, 0.0, 0.0, 0.0); - alSource3f(source[1], AL_DIRECTION, 0.0, 0.0, 0.0); - alSourcef (source[1], AL_ROLLOFF_FACTOR, 0.0 ); - alSourcei (source[1], AL_SOURCE_RELATIVE, AL_TRUE ); - alSource3f(source[2], AL_POSITION, 0.0, 0.0, 0.0); - alSource3f(source[2], AL_VELOCITY, 0.0, 0.0, 0.0); - alSource3f(source[2], AL_DIRECTION, 0.0, 0.0, 0.0); - alSourcef (source[2], AL_ROLLOFF_FACTOR, 0.0 ); - alSourcei (source[2], AL_SOURCE_RELATIVE, AL_TRUE ); + f_alSource3f(source[0], AL_POSITION, 0.0, 0.0, 0.0); + f_alSource3f(source[0], AL_VELOCITY, 0.0, 0.0, 0.0); + f_alSource3f(source[0], AL_DIRECTION, 0.0, 0.0, 0.0); + f_alSourcef (source[0], AL_ROLLOFF_FACTOR, 0.0 ); + f_alSourcei (source[0], AL_SOURCE_RELATIVE, AL_TRUE ); + f_alSource3f(source[1], AL_POSITION, 0.0, 0.0, 0.0); + f_alSource3f(source[1], AL_VELOCITY, 0.0, 0.0, 0.0); + f_alSource3f(source[1], AL_DIRECTION, 0.0, 0.0, 0.0); + f_alSourcef (source[1], AL_ROLLOFF_FACTOR, 0.0 ); + f_alSourcei (source[1], AL_SOURCE_RELATIVE, AL_TRUE ); + f_alSource3f(source[2], AL_POSITION, 0.0, 0.0, 0.0); + f_alSource3f(source[2], AL_VELOCITY, 0.0, 0.0, 0.0); + f_alSource3f(source[2], AL_DIRECTION, 0.0, 0.0, 0.0); + f_alSourcef (source[2], AL_ROLLOFF_FACTOR, 0.0 ); + f_alSourcei (source[2], AL_SOURCE_RELATIVE, AL_TRUE ); if (sound_is_float) { memset(buf,0,BUFLEN*2*sizeof(float)); @@ -202,22 +271,22 @@ inital(void) for (c=0; c<4; c++) { if (sound_is_float) { - alBufferData(buffers[c], AL_FORMAT_STEREO_FLOAT32, buf, BUFLEN*2*sizeof(float), FREQ); - alBufferData(buffers_cd[c], AL_FORMAT_STEREO_FLOAT32, cd_buf, CD_BUFLEN*2*sizeof(float), CD_FREQ); - alBufferData(buffers_midi[c], AL_FORMAT_STEREO_FLOAT32, midi_buf, midi_buf_size*sizeof(float), midi_freq); + f_alBufferData(buffers[c], AL_FORMAT_STEREO_FLOAT32, buf, BUFLEN*2*sizeof(float), FREQ); + f_alBufferData(buffers_cd[c], AL_FORMAT_STEREO_FLOAT32, cd_buf, CD_BUFLEN*2*sizeof(float), CD_FREQ); + f_alBufferData(buffers_midi[c], AL_FORMAT_STEREO_FLOAT32, midi_buf, midi_buf_size*sizeof(float), midi_freq); } else { - alBufferData(buffers[c], AL_FORMAT_STEREO16, buf_int16, BUFLEN*2*sizeof(int16_t), FREQ); - alBufferData(buffers_cd[c], AL_FORMAT_STEREO16, cd_buf_int16, CD_BUFLEN*2*sizeof(int16_t), CD_FREQ); - alBufferData(buffers_midi[c], AL_FORMAT_STEREO16, midi_buf_int16, midi_buf_size*sizeof(int16_t), midi_freq); + f_alBufferData(buffers[c], AL_FORMAT_STEREO16, buf_int16, BUFLEN*2*sizeof(int16_t), FREQ); + f_alBufferData(buffers_cd[c], AL_FORMAT_STEREO16, cd_buf_int16, CD_BUFLEN*2*sizeof(int16_t), CD_FREQ); + f_alBufferData(buffers_midi[c], AL_FORMAT_STEREO16, midi_buf_int16, midi_buf_size*sizeof(int16_t), midi_freq); } } - alSourceQueueBuffers(source[0], 4, buffers); - alSourceQueueBuffers(source[1], 4, buffers_cd); - alSourceQueueBuffers(source[2], 4, buffers_midi); - alSourcePlay(source[0]); - alSourcePlay(source[1]); - alSourcePlay(source[2]); + f_alSourceQueueBuffers(source[0], 4, buffers); + f_alSourceQueueBuffers(source[1], 4, buffers_cd); + f_alSourceQueueBuffers(source[2], 4, buffers_midi); + f_alSourcePlay(source[0]); + f_alSourcePlay(source[1]); + f_alSourcePlay(source[2]); if (sound_is_float) { free(midi_buf); @@ -228,8 +297,6 @@ inital(void) free(cd_buf_int16); free(buf_int16); } - - initialized = 1; #endif } @@ -243,26 +310,28 @@ givealbuffer_common(void *buf, uint8_t src, int size, int freq) ALuint buffer; double gain; - alGetSourcei(source[src], AL_SOURCE_STATE, &state); + if (openal_handle == NULL) return; + + f_alGetSourcei(source[src], AL_SOURCE_STATE, &state); if (state == 0x1014) { - alSourcePlay(source[src]); + f_alSourcePlay(source[src]); } - alGetSourcei(source[src], AL_BUFFERS_PROCESSED, &processed); + f_alGetSourcei(source[src], AL_BUFFERS_PROCESSED, &processed); if (processed >= 1) { gain = pow(10.0, (double)sound_gain / 20.0); - alListenerf(AL_GAIN, gain); + f_alListenerf(AL_GAIN, gain); - alSourceUnqueueBuffers(source[src], 1, &buffer); + f_alSourceUnqueueBuffers(source[src], 1, &buffer); if (sound_is_float) { - alBufferData(buffer, AL_FORMAT_STEREO_FLOAT32, buf, size * sizeof(float), freq); + f_alBufferData(buffer, AL_FORMAT_STEREO_FLOAT32, buf, size * sizeof(float), freq); } else { - alBufferData(buffer, AL_FORMAT_STEREO16, buf, size * sizeof(int16_t), freq); + f_alBufferData(buffer, AL_FORMAT_STEREO16, buf, size * sizeof(int16_t), freq); } - alSourceQueueBuffers(source[src], 1, &buffer); + f_alSourceQueueBuffers(source[src], 1, &buffer); } #endif } diff --git a/src/win/Makefile.mingw b/src/win/Makefile.mingw index 0861262..c44e022 100644 --- a/src/win/Makefile.mingw +++ b/src/win/Makefile.mingw @@ -6,9 +6,9 @@ # # This file is part of the VARCem Project. # -# Makefile for Win32 (MinGW32) environment. +# Makefile for Windows systems using the MinGW32 environment. # -# Version: @(#)Makefile.mingw 1.0.3 2018/02/22 +# Version: @(#)Makefile.mingw 1.0.4 2018/02/24 # # Author: Fred N. van Kempen, # @@ -62,6 +62,9 @@ endif ifndef CRASHDUMP CRASHDUMP := n endif +ifndef CROSS +CROSS := n +endif ifndef DEBUG DEBUG := n endif @@ -143,7 +146,6 @@ ifeq ($(DEV_BUILD), y) DEBUG := y CRASHDUMP := y DEV_BRANCH := y -VNC := y I686 := y AMD_K := y GREENB := y @@ -197,14 +199,45 @@ VPATH := $(EXPATH) . cpu \ sound/munt/srchelper \ sound/resid-fp \ scsi video lzf network network/slirp win -ifeq ($(X64), y) -CPP := g++ -m64 -CC := gcc -m64 + +# +# Select the required build environment. We have, uhm, many.. +# +# +ifneq ($(CROSS), n) + # Cross-compiling (under Linux), select proper version. + ifeq ($(X64), y) + MINGW := x86_64-w64-mingw32 + else + MINGW := i686-w64-mingw32 + endif + + ifeq ($(X64), y) + CPP := /usr/bin/$(MINGW)-g++ -m64 + CC := /usr/bin/$(MINGW)-gcc -m64 + else + CPP := /usr/bin/$(MINGW)-g++ -m32 + CC := /usr/bin/$(MINGW)-gcc -m32 + endif + WINDRES := /usr/bin/$(MINGW)-windres + + SYSINC := -I/usr/$(MINGW)/include -I../mingw/include + SYSLIB := -L/usr/$(MINGW)/lib else -CPP := g++ -m32 -CC := gcc -m32 + # Native compilation using MinGW for Windows. + ifeq ($(X64), y) + CPP := g++ -m64 + CC := gcc -m64 + else + CPP := g++ -m32 + CC := gcc -m32 + endif + WINDRES := windres + + SYSINC := + SYSLIB := endif -WINDRES := windres + DEPS = -MMD -MF $*.d -c $< DEPFILE := win/.depends @@ -216,6 +249,10 @@ endif ifdef EXINC OPTS += -I$(EXINC) endif +OPTS += $(SYSINC) +ifneq ($(CROSS), n) + OPTS += -DUSE_CROSS +endif ifeq ($(X64), y) ifeq ($(OPTIM), y) DFLAGS := -march=native @@ -550,7 +587,6 @@ endif LZFOBJ := lzf_c.o lzf_d.o LIBS := -mwindows \ - -lopenal.dll \ -lddraw -ldinput8 -ldxguid -ld3d9 -ld3dx9 \ -lcomctl32 -lwinmm ifeq ($(VNC), y) diff --git a/src/win/VARCem.rc b/src/win/VARCem.rc index 28dcb0b..959d811 100644 --- a/src/win/VARCem.rc +++ b/src/win/VARCem.rc @@ -8,7 +8,7 @@ * * Application resource script for Windows. * - * Version: @(#)VARCem.rc 1.0.2 2018/02/21 + * Version: @(#)VARCem.rc 1.0.3 2018/02/24 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -974,6 +974,7 @@ BEGIN IDS_2175 "ZIP images (*.IM?;*.ZDI)\0*.IM?;*.ZDI\0All files (*.*)\0*.*\0" IDS_2176 "ZIP images (*.IM?;*.ZDI)\0*.IM?;*.ZDI\0" IDS_2177 "ZIP %i (%03i): %ls" + IDS_2178 "Unable to initialize OpenAL, make sure you have the following library\nin your program folder:\n\nlibopenal-1.dll" IDS_4096 "Hard disk (%s)" IDS_4097 "%01i:%01i"