Merge pull request #2652 from jriwanek-forks/mt32

Add MT-32 (New) and CM-32LN
This commit is contained in:
Miran Grča
2022-08-31 02:14:36 +02:00
committed by GitHub
3 changed files with 82 additions and 13 deletions

View File

@@ -96,8 +96,10 @@ extern const device_t rtmidi_input_device;
extern const device_t fluidsynth_device; extern const device_t fluidsynth_device;
# endif # endif
# ifdef USE_MUNT # ifdef USE_MUNT
extern const device_t mt32_device; extern const device_t mt32_old_device;
extern const device_t mt32_new_device;
extern const device_t cm32l_device; extern const device_t cm32l_device;
extern const device_t cm32ln_device;
# endif # endif
#endif #endif

View File

@@ -92,8 +92,10 @@ static const MIDI_OUT_DEVICE devices[] = {
{ &fluidsynth_device }, { &fluidsynth_device },
#endif #endif
#ifdef USE_MUNT #ifdef USE_MUNT
{ &mt32_device }, { &mt32_old_device },
{ &mt32_new_device },
{ &cm32l_device }, { &cm32l_device },
{ &cm32ln_device },
#endif #endif
#ifdef USE_RTMIDI #ifdef USE_RTMIDI
{ &rtmidi_output_device }, { &rtmidi_output_device },

View File

@@ -15,6 +15,15 @@
#include <86box/ui.h> #include <86box/ui.h>
#include <mt32emu/c_interface/c_interface.h> #include <mt32emu/c_interface/c_interface.h>
#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"
#define CM32LN_PCM_ROM "roms/sound/cm32ln/CM32LN_PCM.ROM"
extern void givealbuffer_midi(void *buf, uint32_t size); extern void givealbuffer_midi(void *buf, uint32_t size);
extern void al_set_midi(int freq, int buf_size); extern void al_set_midi(int freq, int buf_size);
@@ -58,7 +67,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); 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 = { static const mt32emu_report_handler_i_v0 handler_cm32l_v0 = {
/** Returns the actual interface version ID */ /** Returns the actual interface version ID */
get_mt32_report_handler_version, // mt32emu_report_handler_version (*getVersionID)(mt32emu_report_handler_i i); get_mt32_report_handler_version, // mt32emu_report_handler_version (*getVersionID)(mt32emu_report_handler_i i);
@@ -111,10 +120,18 @@ mt32_check(const char *func, mt32emu_return_code ret, mt32emu_return_code expect
} }
int int
mt32_available() mt32_old_available()
{ {
if (roms_present[0] < 0) 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_OLD_CTRL_ROM) && rom_present(MT32_OLD_PCM_ROM));
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]; return roms_present[0];
} }
@@ -122,7 +139,15 @@ int
cm32l_available() cm32l_available()
{ {
if (roms_present[1] < 0) 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];
}
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]; return roms_present[1];
} }
@@ -240,7 +265,7 @@ mt32emu_init(char *control_rom, char *pcm_rom)
midi_device_t *dev; midi_device_t *dev;
char fn[512]; 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)) if (!rom_getfile(control_rom, fn, 512))
return 0; return 0;
@@ -297,15 +322,27 @@ mt32emu_init(char *control_rom, char *pcm_rom)
} }
void * void *
mt32_init(const device_t *info) mt32_old_init(const device_t *info)
{ {
return mt32emu_init("roms/sound/mt32/MT32_CONTROL.ROM", "roms/sound/mt32/MT32_PCM.ROM"); 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 * void *
cm32l_init(const device_t *info) 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 *
cm32ln_init(const device_t *info)
{
return mt32emu_init(CM32LN_CTRL_ROM, CM32LN_PCM_ROM);
} }
void void
@@ -383,15 +420,29 @@ static const device_config_t mt32_config[] = {
// clang-format on // clang-format on
}; };
const device_t mt32_device = { const device_t mt32_old_device = {
.name = "Roland MT-32 Emulation", .name = "Roland MT-32 Emulation",
.internal_name = "mt32", .internal_name = "mt32",
.flags = 0, .flags = 0,
.local = 0, .local = 0,
.init = mt32_init, .init = mt32_old_init,
.close = mt32_close, .close = mt32_close,
.reset = NULL, .reset = NULL,
{ .available = mt32_available }, { .available = mt32_old_available },
.speed_changed = NULL,
.force_redraw = NULL,
.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, .speed_changed = NULL,
.force_redraw = NULL, .force_redraw = NULL,
.config = mt32_config .config = mt32_config
@@ -410,3 +461,17 @@ const device_t cm32l_device = {
.force_redraw = NULL, .force_redraw = NULL,
.config = mt32_config .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
};