From 04d777506c30292597a7911f81912f627430e24b Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Wed, 27 Nov 2024 03:58:47 -0500 Subject: [PATCH] Add "The Entertainer" sound device --- src/include/86box/sound.h | 1 + src/sound/snd_ssi2001.c | 67 +++++++++++++++++++++++++++++++++++++++ src/sound/sound.c | 1 + 3 files changed, 69 insertions(+) diff --git a/src/include/86box/sound.h b/src/include/86box/sound.h index bcf7f2ae5..2a41b98f8 100644 --- a/src/include/86box/sound.h +++ b/src/include/86box/sound.h @@ -192,6 +192,7 @@ extern const device_t ps1snd_device; /* Innovation SSI-2001 */ extern const device_t ssi2001_device; +extern const device_t entertainer_device; /* Pro Audio Spectrum Plus, 16, and 16D */ extern const device_t pasplus_device; diff --git a/src/sound/snd_ssi2001.c b/src/sound/snd_ssi2001.c index e7f053ea8..11a10473c 100644 --- a/src/sound/snd_ssi2001.c +++ b/src/sound/snd_ssi2001.c @@ -21,6 +21,10 @@ typedef struct ssi2001_t { int gameport_enabled; } ssi2001_t; +typedef struct entertainer_t { + uint8_t regs; +} entertainer_t; + static void ssi2001_update(ssi2001_t *ssi2001) { @@ -90,6 +94,48 @@ ssi2001_close(void *priv) free(ssi2001); } +static uint8_t +entertainer_read(uint16_t addr, void *priv) +{ + return 0xa5; +} + +static void +entertainer_write(uint16_t addr, uint8_t val, void *priv) +{ + entertainer_t *entertainer = (entertainer_t *) priv; + entertainer->regs = val; +} + +void * +entertainer_init(UNUSED(const device_t *info)) +{ + ssi2001_t *ssi2001 = malloc(sizeof(ssi2001_t)); + entertainer_t *entertainer = malloc(sizeof(entertainer_t)); + memset(ssi2001, 0, sizeof(ssi2001_t)); + memset(entertainer, 0, sizeof(entertainer_t)); + + ssi2001->psid = sid_init(0); + sid_reset(ssi2001->psid); + ssi2001->gameport_enabled = device_get_config_int("gameport"); + io_sethandler(0x200, 0x0001, entertainer_read, NULL, NULL, entertainer_write, NULL, NULL, entertainer); + io_sethandler(0x280, 0x0020, ssi2001_read, NULL, NULL, ssi2001_write, NULL, NULL, ssi2001); + if (ssi2001->gameport_enabled) + gameport_remap(gameport_add(&gameport_201_device), 0x201); + sound_add_handler(ssi2001_get_buffer, ssi2001); + return ssi2001; +} + +void +entertainer_close(void *priv) +{ + ssi2001_t *ssi2001 = (ssi2001_t *) priv; + + sid_close(ssi2001->psid); + + free(ssi2001); +} + static const device_config_t ssi2001_config[] = { // clang-format off { @@ -125,6 +171,13 @@ static const device_config_t ssi2001_config[] = { // clang-format off }; +static const device_config_t entertainer_config[] = { + // clang-format off + { "gameport", "Enable Game port", CONFIG_BINARY, "", 1 }, + { "", "", -1 } +// clang-format off +}; + const device_t ssi2001_device = { .name = "Innovation SSI-2001", .internal_name = "ssi2001", @@ -138,3 +191,17 @@ const device_t ssi2001_device = { .force_redraw = NULL, .config = ssi2001_config }; + +const device_t entertainer_device = { + .name = "The Entertainer", + .internal_name = "Entertainer", + .flags = DEVICE_ISA, + .local = 1, + .init = entertainer_init, + .close = entertainer_close, + .reset = NULL, + { .available = NULL }, + .speed_changed = NULL, + .force_redraw = NULL, + .config = entertainer_config +}; diff --git a/src/sound/sound.c b/src/sound/sound.c index 7e6a1ac1c..d2d3dc313 100644 --- a/src/sound/sound.c +++ b/src/sound/sound.c @@ -132,6 +132,7 @@ static const SOUND_CARD sound_cards[] = { { &sb_vibra16s_device }, { &sb_vibra16xv_device }, { &ssi2001_device }, + { &entertainer_device }, { &pasplus_device }, { &pas16_device }, { &pas16d_device },