diff --git a/CMakeLists.txt b/CMakeLists.txt index 161394778..a632b71ce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -175,7 +175,6 @@ endif() cmake_dependent_option(AMD_K5 "AMD K5" ON "DEV_BRANCH" OFF) cmake_dependent_option(CDROM_MITSUMI "Mitsumi CDROM" ON "DEV_BRANCH" OFF) cmake_dependent_option(G100 "Matrox Productiva G100" ON "DEV_BRANCH" OFF) -cmake_dependent_option(GUSMAX "Gravis UltraSound MAX" ON "DEV_BRANCH" OFF) cmake_dependent_option(ISAMEM_RAMPAGE "AST Rampage" ON "DEV_BRANCH" OFF) cmake_dependent_option(ISAMEM_IAB "Intel Above Board" ON "DEV_BRANCH" OFF) cmake_dependent_option(ISAMEM_BRAT "BocaRAM/AT" ON "DEV_BRANCH" OFF) diff --git a/src/include/86box/sound.h b/src/include/86box/sound.h index b2e202ddb..985abe777 100644 --- a/src/include/86box/sound.h +++ b/src/include/86box/sound.h @@ -197,6 +197,7 @@ extern const device_t ct5880_onboard_device; /* Gravis UltraSound and UltraSound Max */ extern const device_t gus_device; +extern const device_t gus_max_device; /* IBM PS/1 Audio Card */ extern const device_t ps1snd_device; diff --git a/src/sound/CMakeLists.txt b/src/sound/CMakeLists.txt index fb3c9b43d..66a0ee4e3 100644 --- a/src/sound/CMakeLists.txt +++ b/src/sound/CMakeLists.txt @@ -185,10 +185,6 @@ target_link_libraries(86Box esfmu) add_subdirectory(ymfm) target_link_libraries(86Box ymfm) -if(GUSMAX) - target_compile_definitions(snd PRIVATE USE_GUSMAX) -endif() - if(OPL4ML) target_compile_definitions(snd PRIVATE USE_OPL4ML) target_sources(snd PRIVATE midi_opl4.c midi_opl4_yrw801.c) diff --git a/src/sound/snd_gus.c b/src/sound/snd_gus.c index 1885581a5..fff679e81 100644 --- a/src/sound/snd_gus.c +++ b/src/sound/snd_gus.c @@ -17,9 +17,7 @@ #include <86box/sound.h> #include "cpu.h" #include <86box/timer.h> -#ifdef USE_GUSMAX -# include <86box/snd_ad1848.h> -#endif /*USE_GUSMAX */ +#include <86box/snd_ad1848.h> #include <86box/plat_fallthrough.h> #include <86box/plat_unused.h> @@ -145,11 +143,9 @@ typedef struct gus_t { uint8_t usrr; -#ifdef USE_GUSMAX uint8_t max_ctrl; ad1848_t ad1848; -#endif /*USE_GUSMAX */ } gus_t; static int gus_gf1_irqs[8] = { -1, 2, 5, 3, 7, 11, 12, 15 }; @@ -257,9 +253,7 @@ writegus(uint16_t addr, uint8_t val, void *priv) int d; int old; uint16_t port; -#ifdef USE_GUSMAX uint16_t csioport; -#endif /*USE_GUSMAX */ if ((addr == 0x388) || (addr == 0x389)) port = addr; @@ -607,10 +601,9 @@ writegus(uint16_t addr, uint8_t val, void *priv) gus->irq_midi = gus->irq; } else gus->irq_midi = gus_midi_irqs[(val >> 3) & 7]; -#ifdef USE_GUSMAX + if (gus->type == GUS_MAX) ad1848_setirq(&gus->ad1848, gus->irq); -#endif /*USE_GUSMAX */ gus->sb_nmi = val & 0x80; } else { @@ -623,10 +616,9 @@ writegus(uint16_t addr, uint8_t val, void *priv) gus->dma2 = gus->dma; } else gus->dma2 = gus_dmas[(val >> 3) & 7]; -#ifdef USE_GUSMAX + if (gus->type == GUS_MAX) ad1848_setdma(&gus->ad1848, gus->dma2); -#endif /*USE_GUSMAX */ } break; case 1: @@ -684,7 +676,6 @@ writegus(uint16_t addr, uint8_t val, void *priv) break; case 0x306: case 0x706: -#ifdef USE_GUSMAX if (gus->type == GUS_MAX) { if (gus->dma >= 4) val |= 0x10; @@ -704,7 +695,6 @@ writegus(uint16_t addr, uint8_t val, void *priv) } } } -#endif /*USE_GUSMAX */ break; default: @@ -756,11 +746,9 @@ readgus(uint16_t addr, void *priv) return val; case 0x20F: -#ifdef USE_GUSMAX if (gus->type == GUS_MAX) val = 0x02; else -#endif /*USE_GUSMAX */ val = 0x00; break; @@ -879,11 +867,9 @@ readgus(uint16_t addr, void *priv) break; case 0x306: case 0x706: -#ifdef USE_GUSMAX if (gus->type == GUS_MAX) val = 0x0a; /* GUS MAX */ else -#endif /*USE_GUSMAX */ val = 0xff; /*Pre 3.7 - no mixer*/ break; @@ -1183,24 +1169,20 @@ gus_get_buffer(int32_t *buffer, int len, void *priv) { gus_t *gus = (gus_t *) priv; -#ifdef USE_GUSMAX if ((gus->type == GUS_MAX) && (gus->max_ctrl)) ad1848_update(&gus->ad1848); -#endif /*USE_GUSMAX */ + gus_update(gus); for (int c = 0; c < len * 2; c++) { -#ifdef USE_GUSMAX if ((gus->type == GUS_MAX) && (gus->max_ctrl)) buffer[c] += (int32_t) (gus->ad1848.buffer[c] / 2); -#endif /*USE_GUSMAX */ buffer[c] += (int32_t) gus->buffer[c & 1][c >> 1]; } -#ifdef USE_GUSMAX if ((gus->type == GUS_MAX) && (gus->max_ctrl)) gus->ad1848.pos = 0; -#endif /*USE_GUSMAX */ + gus->pos = 0; } @@ -1333,9 +1315,7 @@ gus_reset(void *priv) gus->usrr = 0; -#ifdef USE_GUSMAX gus->max_ctrl = 0; -#endif /*USE_GUSMAX */ gus->irq_state = 0; gus->midi_irq_state = 0; @@ -1373,7 +1353,7 @@ gus_init(UNUSED(const device_t *info)) gus->uart_out = 1; - gus->type = device_get_config_int("type"); + gus->type = info->local; gus->base = device_get_config_hex16("base"); @@ -1382,7 +1362,6 @@ gus_init(UNUSED(const device_t *info)) io_sethandler(0x0506 + gus->base, 0x0001, readgus, NULL, NULL, writegus, NULL, NULL, gus); io_sethandler(0x0388, 0x0002, readgus, NULL, NULL, writegus, NULL, NULL, gus); -#ifdef USE_GUSMAX if (gus->type == GUS_MAX) { ad1848_init(&gus->ad1848, AD1848_TYPE_CS4231); ad1848_setirq(&gus->ad1848, 5); @@ -1390,7 +1369,6 @@ gus_init(UNUSED(const device_t *info)) io_sethandler(0x10C + gus->base, 4, ad1848_read, NULL, NULL, ad1848_write, NULL, NULL, &gus->ad1848); } -#endif /*USE_GUSMAX */ timer_add(&gus->samp_timer, gus_poll_wave, gus, 1); timer_add(&gus->timer_1, gus_poll_timer_1, gus, 1); @@ -1423,31 +1401,12 @@ gus_speed_changed(void *priv) else gus->samp_latch = (uint64_t) (TIMER_USEC * (1000000.0 / gusfreqs[gus->voices - 14])); -#ifdef USE_GUSMAX if ((gus->type == GUS_MAX) && (gus->max_ctrl)) ad1848_speed_changed(&gus->ad1848); -#endif /*USE_GUSMAX */ } static const device_config_t gus_config[] = { // clang-format off - { - .name = "type", - .description = "GUS type", - .type = CONFIG_SELECTION, - .default_string = NULL, - .default_int = 0, - .file_filter = NULL, - .spinner = { 0 }, - .selection = { - { .description = "Classic", .value = GUS_CLASSIC }, -#ifdef USE_GUSMAX - { .description = "MAX", .value = GUS_MAX }, -#endif /*USE_GUSMAX */ - { NULL } - }, - .bios = { { 0 } } - }, { .name = "base", .description = "Address", @@ -1502,7 +1461,21 @@ const device_t gus_device = { .name = "Gravis UltraSound", .internal_name = "gus", .flags = DEVICE_ISA16, - .local = 0, + .local = GUS_CLASSIC, + .init = gus_init, + .close = gus_close, + .reset = gus_reset, + .available = NULL, + .speed_changed = gus_speed_changed, + .force_redraw = NULL, + .config = gus_config +}; + +const device_t gus_max_device = { + .name = "Gravis UltraSound MAX", + .internal_name = "gus", + .flags = DEVICE_ISA16, + .local = GUS_MAX, .init = gus_init, .close = gus_close, .reset = gus_reset, diff --git a/src/sound/sound.c b/src/sound/sound.c index c3ecc8632..7bf27a136 100644 --- a/src/sound/sound.c +++ b/src/sound/sound.c @@ -115,6 +115,7 @@ static const SOUND_CARD sound_cards[] = { { &ess_ess0102_pnp_device }, { &ess_ess0968_pnp_device }, { &gus_device }, + { &gus_max_device }, { &sb_1_device }, { &sb_15_device }, { &sb_2_device },