From a08ad7007d20259d2454dcfae095ac5caaf752d5 Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Tue, 30 Aug 2022 16:47:32 -0400 Subject: [PATCH 1/4] Use defines for roms --- src/sound/midi_mt32.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/sound/midi_mt32.c b/src/sound/midi_mt32.c index bb7cb97c2..ec0850282 100644 --- a/src/sound/midi_mt32.c +++ b/src/sound/midi_mt32.c @@ -15,6 +15,10 @@ #include <86box/ui.h> #include +#define MT32_CTRL_ROM "roms/sound/mt32/MT32_CONTROL.ROM" +#define MT32_PCM_ROM "roms/sound/mt32/MT32_PCM.ROM" +#define CM32L_CTRL_ROM "roms/sound/cm32l/CM32L_CONTROL.ROM" +#define CM32L_PCM_ROM "roms/sound/cm32l/CM32L_PCM.ROM" extern void givealbuffer_midi(void *buf, uint32_t size); extern void al_set_midi(int freq, int buf_size); @@ -114,7 +118,7 @@ int mt32_available() { if (roms_present[0] < 0) - roms_present[0] = (rom_present("roms/sound/mt32/MT32_CONTROL.ROM") && rom_present("roms/sound/mt32/MT32_PCM.ROM")); + roms_present[0] = (rom_present(MT32_CTRL_ROM) && rom_present(MT32_PCM_ROM)); return roms_present[0]; } @@ -122,7 +126,7 @@ int cm32l_available() { if (roms_present[1] < 0) - roms_present[1] = (rom_present("roms/sound/cm32l/CM32L_CONTROL.ROM") && rom_present("roms/sound/cm32l/CM32L_PCM.ROM")); + roms_present[1] = (rom_present(CM32L_CTRL_ROM) && rom_present(CM32L_PCM_ROM)); return roms_present[1]; } @@ -299,13 +303,13 @@ mt32emu_init(char *control_rom, char *pcm_rom) void * mt32_init(const device_t *info) { - return mt32emu_init("roms/sound/mt32/MT32_CONTROL.ROM", "roms/sound/mt32/MT32_PCM.ROM"); + return mt32emu_init(MT32_CTRL_ROM, MT32_PCM_ROM); } void * cm32l_init(const device_t *info) { - return mt32emu_init("roms/sound/cm32l/CM32L_CONTROL.ROM", "roms/sound/cm32l/CM32L_PCM.ROM"); + return mt32emu_init(CM32L_CTRL_ROM, CM32L_PCM_ROM); } void From b59f8ab14d57ee9a10a31f55f53796f262350fad Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Tue, 30 Aug 2022 16:50:29 -0400 Subject: [PATCH 2/4] Add CM-32LN Update midi_mt32.c --- src/include/86box/midi.h | 1 + src/sound/midi.c | 1 + src/sound/midi_mt32.c | 35 +++++++++++++++++++++++++++++++++-- 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/src/include/86box/midi.h b/src/include/86box/midi.h index 01ec88881..0ae167ace 100644 --- a/src/include/86box/midi.h +++ b/src/include/86box/midi.h @@ -98,6 +98,7 @@ extern const device_t fluidsynth_device; # ifdef USE_MUNT extern const device_t mt32_device; extern const device_t cm32l_device; +extern const device_t cm32ln_device; # endif #endif diff --git a/src/sound/midi.c b/src/sound/midi.c index ae5cdc456..9d3306603 100644 --- a/src/sound/midi.c +++ b/src/sound/midi.c @@ -94,6 +94,7 @@ static const MIDI_OUT_DEVICE devices[] = { #ifdef USE_MUNT { &mt32_device }, { &cm32l_device }, + { &cm32ln_device }, #endif #ifdef USE_RTMIDI { &rtmidi_output_device }, diff --git a/src/sound/midi_mt32.c b/src/sound/midi_mt32.c index ec0850282..6bc26c849 100644 --- a/src/sound/midi_mt32.c +++ b/src/sound/midi_mt32.c @@ -19,6 +19,9 @@ #define MT32_PCM_ROM "roms/sound/mt32/MT32_PCM.ROM" #define CM32L_CTRL_ROM "roms/sound/cm32l/CM32L_CONTROL.ROM" #define CM32L_PCM_ROM "roms/sound/cm32l/CM32L_PCM.ROM" +#define CM32LN_CTRL_ROM "roms/sound/cm32ln/CM32LN_CONTROL.ROM" +#define CM32LN_PCM_ROM "roms/sound/cm32ln/CM32LN_PCM.ROM" + extern void givealbuffer_midi(void *buf, uint32_t size); extern void al_set_midi(int freq, int buf_size); @@ -62,7 +65,7 @@ static const mt32emu_report_handler_i_v0 handler_mt32_v0 = { NULL, // void (*onProgramChanged)(void *instance_data, mt32emu_bit8u part_num, const char *sound_group_name, const char *patch_name); }; -/** Alternate report handler for Roland CM-32L */ +/** Alternate report handler for Roland CM-32L/CM-32LN */ static const mt32emu_report_handler_i_v0 handler_cm32l_v0 = { /** Returns the actual interface version ID */ get_mt32_report_handler_version, // mt32emu_report_handler_version (*getVersionID)(mt32emu_report_handler_i i); @@ -130,6 +133,14 @@ cm32l_available() return roms_present[1]; } +int +cm32ln_available() +{ + if (roms_present[1] < 0) + roms_present[1] = (rom_present(CM32LN_CTRL_ROM) && rom_present(CM32LN_PCM_ROM)); + return roms_present[1]; +} + static thread_t *thread_h = NULL; static event_t *event = NULL; static event_t *start_event = NULL; @@ -244,7 +255,7 @@ mt32emu_init(char *control_rom, char *pcm_rom) midi_device_t *dev; char fn[512]; - context = mt32emu_create_context(strstr(control_rom, "CM32L_CONTROL.ROM") ? handler_cm32l : handler_mt32, NULL); + context = mt32emu_create_context(strstr(control_rom, "MT32_CONTROL.ROM") ? handler_mt32 : handler_cm32l, NULL); if (!rom_getfile(control_rom, fn, 512)) return 0; @@ -312,6 +323,12 @@ cm32l_init(const device_t *info) return mt32emu_init(CM32L_CTRL_ROM, CM32L_PCM_ROM); } +void * +cm32ln_init(const device_t *info) +{ + return mt32emu_init(CM32LN_CTRL_ROM, CM32LN_PCM_ROM); +} + void mt32_close(void *p) { @@ -414,3 +431,17 @@ const device_t cm32l_device = { .force_redraw = NULL, .config = mt32_config }; + +const device_t cm32ln_device = { + .name = "Roland CM-32LN Emulation", + .internal_name = "cm32ln", + .flags = 0, + .local = 0, + .init = cm32ln_init, + .close = mt32_close, + .reset = NULL, + { .available = cm32ln_available }, + .speed_changed = NULL, + .force_redraw = NULL, + .config = mt32_config +}; From 1e201dce09c9164a60e1a1f5852f9d5db6b6e233 Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Tue, 30 Aug 2022 16:56:47 -0400 Subject: [PATCH 3/4] Rename rom define for old mt32 --- src/include/86box/midi.h | 2 +- src/sound/midi.c | 2 +- src/sound/midi_mt32.c | 26 +++++++++++++------------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/include/86box/midi.h b/src/include/86box/midi.h index 0ae167ace..9aae23f55 100644 --- a/src/include/86box/midi.h +++ b/src/include/86box/midi.h @@ -96,7 +96,7 @@ extern const device_t rtmidi_input_device; extern const device_t fluidsynth_device; # endif # ifdef USE_MUNT -extern const device_t mt32_device; +extern const device_t mt32_old_device; extern const device_t cm32l_device; extern const device_t cm32ln_device; # endif diff --git a/src/sound/midi.c b/src/sound/midi.c index 9d3306603..851e9cfad 100644 --- a/src/sound/midi.c +++ b/src/sound/midi.c @@ -92,7 +92,7 @@ static const MIDI_OUT_DEVICE devices[] = { { &fluidsynth_device }, #endif #ifdef USE_MUNT - { &mt32_device }, + { &mt32_old_device }, { &cm32l_device }, { &cm32ln_device }, #endif diff --git a/src/sound/midi_mt32.c b/src/sound/midi_mt32.c index 6bc26c849..05002b1f3 100644 --- a/src/sound/midi_mt32.c +++ b/src/sound/midi_mt32.c @@ -15,12 +15,12 @@ #include <86box/ui.h> #include -#define MT32_CTRL_ROM "roms/sound/mt32/MT32_CONTROL.ROM" -#define MT32_PCM_ROM "roms/sound/mt32/MT32_PCM.ROM" -#define CM32L_CTRL_ROM "roms/sound/cm32l/CM32L_CONTROL.ROM" -#define CM32L_PCM_ROM "roms/sound/cm32l/CM32L_PCM.ROM" -#define CM32LN_CTRL_ROM "roms/sound/cm32ln/CM32LN_CONTROL.ROM" -#define CM32LN_PCM_ROM "roms/sound/cm32ln/CM32LN_PCM.ROM" +#define MT32_OLD_CTRL_ROM "roms/sound/mt32/MT32_CONTROL.ROM" +#define MT32_OLD_PCM_ROM "roms/sound/mt32/MT32_PCM.ROM" +#define CM32L_CTRL_ROM "roms/sound/cm32l/CM32L_CONTROL.ROM" +#define CM32L_PCM_ROM "roms/sound/cm32l/CM32L_PCM.ROM" +#define CM32LN_CTRL_ROM "roms/sound/cm32ln/CM32LN_CONTROL.ROM" +#define CM32LN_PCM_ROM "roms/sound/cm32ln/CM32LN_PCM.ROM" extern void givealbuffer_midi(void *buf, uint32_t size); extern void al_set_midi(int freq, int buf_size); @@ -118,10 +118,10 @@ mt32_check(const char *func, mt32emu_return_code ret, mt32emu_return_code expect } int -mt32_available() +mt32_old_available() { if (roms_present[0] < 0) - roms_present[0] = (rom_present(MT32_CTRL_ROM) && rom_present(MT32_PCM_ROM)); + roms_present[0] = (rom_present(MT32_OLD_CTRL_ROM) && rom_present(MT32_OLD_PCM_ROM)); return roms_present[0]; } @@ -312,9 +312,9 @@ mt32emu_init(char *control_rom, char *pcm_rom) } void * -mt32_init(const device_t *info) +mt32_old_init(const device_t *info) { - return mt32emu_init(MT32_CTRL_ROM, MT32_PCM_ROM); + return mt32emu_init(MT32_OLD_CTRL_ROM, MT32_OLD_PCM_ROM); } void * @@ -404,15 +404,15 @@ static const device_config_t mt32_config[] = { // clang-format on }; -const device_t mt32_device = { +const device_t mt32_old_device = { .name = "Roland MT-32 Emulation", .internal_name = "mt32", .flags = 0, .local = 0, - .init = mt32_init, + .init = mt32_old_init, .close = mt32_close, .reset = NULL, - { .available = mt32_available }, + { .available = mt32_old_available }, .speed_changed = NULL, .force_redraw = NULL, .config = mt32_config From 4a759e5f98c5e35a4edc114e995d42626e7f2d0c Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Tue, 30 Aug 2022 17:08:02 -0400 Subject: [PATCH 4/4] Add Roland MT-32 2.x device --- src/include/86box/midi.h | 1 + src/sound/midi.c | 1 + src/sound/midi_mt32.c | 30 ++++++++++++++++++++++++++++++ 3 files changed, 32 insertions(+) diff --git a/src/include/86box/midi.h b/src/include/86box/midi.h index 9aae23f55..d3ed78af4 100644 --- a/src/include/86box/midi.h +++ b/src/include/86box/midi.h @@ -97,6 +97,7 @@ extern const device_t fluidsynth_device; # endif # ifdef USE_MUNT extern const device_t mt32_old_device; +extern const device_t mt32_new_device; extern const device_t cm32l_device; extern const device_t cm32ln_device; # endif diff --git a/src/sound/midi.c b/src/sound/midi.c index 851e9cfad..b150c423b 100644 --- a/src/sound/midi.c +++ b/src/sound/midi.c @@ -93,6 +93,7 @@ static const MIDI_OUT_DEVICE devices[] = { #endif #ifdef USE_MUNT { &mt32_old_device }, + { &mt32_new_device }, { &cm32l_device }, { &cm32ln_device }, #endif diff --git a/src/sound/midi_mt32.c b/src/sound/midi_mt32.c index 05002b1f3..914680010 100644 --- a/src/sound/midi_mt32.c +++ b/src/sound/midi_mt32.c @@ -17,6 +17,8 @@ #define MT32_OLD_CTRL_ROM "roms/sound/mt32/MT32_CONTROL.ROM" #define MT32_OLD_PCM_ROM "roms/sound/mt32/MT32_PCM.ROM" +#define MT32_NEW_CTRL_ROM "roms/sound/mt32_new/MT32_CONTROL.ROM" +#define MT32_NEW_PCM_ROM "roms/sound/mt32_new/MT32_PCM.ROM" #define CM32L_CTRL_ROM "roms/sound/cm32l/CM32L_CONTROL.ROM" #define CM32L_PCM_ROM "roms/sound/cm32l/CM32L_PCM.ROM" #define CM32LN_CTRL_ROM "roms/sound/cm32ln/CM32LN_CONTROL.ROM" @@ -125,6 +127,14 @@ mt32_old_available() return roms_present[0]; } +int +mt32_new_available() +{ + if (roms_present[0] < 0) + roms_present[0] = (rom_present(MT32_NEW_CTRL_ROM) && rom_present(MT32_NEW_PCM_ROM)); + return roms_present[0]; +} + int cm32l_available() { @@ -317,6 +327,12 @@ mt32_old_init(const device_t *info) return mt32emu_init(MT32_OLD_CTRL_ROM, MT32_OLD_PCM_ROM); } +void * +mt32_new_init(const device_t *info) +{ + return mt32emu_init(MT32_NEW_CTRL_ROM, MT32_NEW_PCM_ROM); +} + void * cm32l_init(const device_t *info) { @@ -418,6 +434,20 @@ const device_t mt32_old_device = { .config = mt32_config }; +const device_t mt32_new_device = { + .name = "Roland MT-32 (New) Emulation", + .internal_name = "mt32", + .flags = 0, + .local = 0, + .init = mt32_new_init, + .close = mt32_close, + .reset = NULL, + { .available = mt32_new_available }, + .speed_changed = NULL, + .force_redraw = NULL, + .config = mt32_config +}; + const device_t cm32l_device = { .name = "Roland CM-32L Emulation", .internal_name = "cm32l",