From e11743c5216226ffa5319612d67fbc95db99684c Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Sun, 24 Nov 2024 20:10:29 -0500 Subject: [PATCH 01/10] Add AWE64 CT4380 no IDE variant --- src/include/86box/sound.h | 1 + src/sound/snd_sb.c | 88 +++++++++++++++++++++++++++------------ src/sound/sound.c | 1 + 3 files changed, 63 insertions(+), 27 deletions(-) diff --git a/src/include/86box/sound.h b/src/include/86box/sound.h index 2a41b98f8..e83006130 100644 --- a/src/include/86box/sound.h +++ b/src/include/86box/sound.h @@ -157,6 +157,7 @@ extern const device_t sb_awe32_device; extern const device_t sb_awe32_pnp_device; extern const device_t sb_awe64_value_device; extern const device_t sb_awe64_device; +extern const device_t sb_awe64_ide_device; extern const device_t sb_awe64_gold_device; /* Crystal CS423x */ diff --git a/src/sound/snd_sb.c b/src/sound/snd_sb.c index 05cd16d0f..91b49eafc 100644 --- a/src/sound/snd_sb.c +++ b/src/sound/snd_sb.c @@ -43,13 +43,21 @@ #include <86box/snd_sb.h> #include <86box/plat_unused.h> +#define SB_32_PNP 0 +#define SB_AWE32_PNP 1 +#define SB_AWE64_VALUE 2 +#define SB_AWE64_NOIDE 3 +#define SB_AWE64_IDE 4 +#define SB_AWE64_GOLD 5 + #define PNP_ROM_SB_16_PNP "roms/sound/creative/CTL0024A.BIN" #define PNP_ROM_SB_VIBRA16XV "roms/sound/creative/CT4170 PnP.BIN" #define PNP_ROM_SB_VIBRA16C "roms/sound/creative/CT4180 PnP.BIN" #define PNP_ROM_SB_32_PNP "roms/sound/creative/CT3600 PnP.BIN" #define PNP_ROM_SB_AWE32_PNP "roms/sound/creative/CT3980 PnP.BIN" #define PNP_ROM_SB_AWE64_VALUE "roms/sound/creative/CT4520 PnP.BIN" -#define PNP_ROM_SB_AWE64 "roms/sound/creative/CTL009DA.BIN" +#define PNP_ROM_SB_AWE64_NOIDE "roms/sound/creative/CT4380 PnP noIDE.BIN" +#define PNP_ROM_SB_AWE64_IDE "roms/sound/creative/CTL009DA.BIN" #define PNP_ROM_SB_AWE64_GOLD "roms/sound/creative/CT4540 PnP.BIN" /* TODO: Find real ESS PnP ROM dumps. */ #define PNP_ROM_ESS0100 "roms/sound/ess/ESS0100.BIN" @@ -2219,7 +2227,7 @@ sb_awe32_pnp_config_changed(const uint8_t ld, isapnp_device_config_t *config, vo } static void -sb_awe64_pnp_config_changed(const uint8_t ld, isapnp_device_config_t *config, void *priv) +sb_awe64_pnp_ide_config_changed(const uint8_t ld, isapnp_device_config_t *config, void *priv) { sb_t *sb = (sb_t *) priv; @@ -2240,7 +2248,7 @@ sb_awe64_pnp_config_changed(const uint8_t ld, isapnp_device_config_t *config, vo } static void -sb_awe64_gold_pnp_config_changed(const uint8_t ld, isapnp_device_config_t *config, void *priv) +sb_awe64_pnp_noide_config_changed(const uint8_t ld, isapnp_device_config_t *config, void *priv) { sb_t *sb = (sb_t *) priv; @@ -3495,9 +3503,15 @@ sb_awe64_value_available(void) } static int -sb_awe64_available(void) +sb_awe64_noide_available(void) { - return sb_awe32_available() && rom_present(PNP_ROM_SB_AWE64); + return sb_awe32_available() && rom_present(PNP_ROM_SB_AWE64_NOIDE); +} + +static int +sb_awe64_ide_available(void) +{ + return sb_awe32_available() && rom_present(PNP_ROM_SB_AWE64_IDE); } static int @@ -3592,7 +3606,7 @@ sb_awe32_pnp_init(const device_t *info) sb->opl_enabled = 1; fm_driver_get(FM_YMF262, &sb->opl); - sb_dsp_init(&sb->dsp, ((info->local == 2) || (info->local == 3) || (info->local == 4)) ? + sb_dsp_init(&sb->dsp, (info->local >= SB_AWE64_VALUE) ? SBAWE64 : SBAWE32PNP, SB_SUBTYPE_DEFAULT, sb); sb_dsp_setdma16_supported(&sb->dsp, 1); sb_ct1745_mixer_reset(sb); @@ -3619,30 +3633,35 @@ sb_awe32_pnp_init(const device_t *info) sb->gameport = gameport_add(&gameport_pnp_device); - if ((info->local != 2) && (info->local != 4)) { + // Does it have IDE? + if ((info->local != SB_AWE64_VALUE) && (info->local != SB_AWE64_NOIDE) && (info->local != SB_AWE64_GOLD)) { device_add(&ide_qua_pnp_device); other_ide_present++; } const char *pnp_rom_file = NULL; switch (info->local) { - case 0: + case SB_32_PNP: pnp_rom_file = PNP_ROM_SB_32_PNP; break; - case 1: + case SB_AWE32_PNP: pnp_rom_file = PNP_ROM_SB_AWE32_PNP; break; - case 2: + case SB_AWE64_VALUE: pnp_rom_file = PNP_ROM_SB_AWE64_VALUE; break; - case 3: - pnp_rom_file = PNP_ROM_SB_AWE64; + case SB_AWE64_NOIDE: + pnp_rom_file = PNP_ROM_SB_AWE64_NOIDE; break; - case 4: + case SB_AWE64_IDE: + pnp_rom_file = PNP_ROM_SB_AWE64_IDE; + break; + + case SB_AWE64_GOLD: pnp_rom_file = PNP_ROM_SB_AWE64_GOLD; break; @@ -3661,21 +3680,22 @@ sb_awe32_pnp_init(const device_t *info) } switch (info->local) { - case 0: + case SB_32_PNP: isapnp_add_card(pnp_rom, sizeof(sb->pnp_rom), sb_16_pnp_config_changed, NULL, NULL, NULL, sb); break; - case 1: + case SB_AWE32_PNP: isapnp_add_card(pnp_rom, sizeof(sb->pnp_rom), sb_awe32_pnp_config_changed, NULL, NULL, NULL, sb); break; - case 3: - isapnp_add_card(pnp_rom, sizeof(sb->pnp_rom), sb_awe64_pnp_config_changed, NULL, NULL, NULL, sb); + case SB_AWE64_IDE: + isapnp_add_card(pnp_rom, sizeof(sb->pnp_rom), sb_awe64_pnp_ide_config_changed, NULL, NULL, NULL, sb); break; - case 2: - case 4: - isapnp_add_card(pnp_rom, sizeof(sb->pnp_rom), sb_awe64_gold_pnp_config_changed, NULL, NULL, NULL, sb); + case SB_AWE64_VALUE: + case SB_AWE64_NOIDE: + case SB_AWE64_GOLD: + isapnp_add_card(pnp_rom, sizeof(sb->pnp_rom), sb_awe64_pnp_noide_config_changed, NULL, NULL, NULL, sb); break; default: @@ -3688,7 +3708,7 @@ sb_awe32_pnp_init(const device_t *info) sb_dsp_setdma16(&sb->dsp, ISAPNP_DMA_DISABLED); mpu401_change_addr(sb->mpu, 0); - if ((info->local != 2) && (info->local != 4)) + if ((info->local != SB_AWE64_VALUE) && (info->local != SB_AWE64_NOIDE) && (info->local != SB_AWE64_GOLD)) ide_remove_handlers(3); emu8k_change_addr(&sb->emu8k, 0); @@ -5772,7 +5792,7 @@ const device_t sb_32_pnp_device = { .name = "Sound Blaster 32 PnP", .internal_name = "sb32_pnp", .flags = DEVICE_ISA | DEVICE_AT, - .local = 0, + .local = SB_32_PNP, .init = sb_awe32_pnp_init, .close = sb_awe32_close, .reset = NULL, @@ -5800,7 +5820,7 @@ const device_t sb_awe32_pnp_device = { .name = "Sound Blaster AWE32 PnP", .internal_name = "sbawe32_pnp", .flags = DEVICE_ISA | DEVICE_AT, - .local = 1, + .local = SB_AWE32_PNP, .init = sb_awe32_pnp_init, .close = sb_awe32_close, .reset = NULL, @@ -5814,7 +5834,7 @@ const device_t sb_awe64_value_device = { .name = "Sound Blaster AWE64 Value", .internal_name = "sbawe64_value", .flags = DEVICE_ISA | DEVICE_AT, - .local = 2, + .local = SB_AWE64_VALUE, .init = sb_awe32_pnp_init, .close = sb_awe32_close, .reset = NULL, @@ -5828,11 +5848,25 @@ const device_t sb_awe64_device = { .name = "Sound Blaster AWE64", .internal_name = "sbawe64", .flags = DEVICE_ISA | DEVICE_AT, - .local = 3, + .local = SB_AWE64_NOIDE, .init = sb_awe32_pnp_init, .close = sb_awe32_close, .reset = NULL, - .available = sb_awe64_available, + { .available = sb_awe64_noide_available }, + .speed_changed = sb_speed_changed, + .force_redraw = NULL, + .config = sb_awe64_config +}; + +const device_t sb_awe64_ide_device = { + .name = "Sound Blaster AWE64 (IDE)", + .internal_name = "sbawe64_ide", + .flags = DEVICE_ISA | DEVICE_AT, + .local = SB_AWE64_IDE, + .init = sb_awe32_pnp_init, + .close = sb_awe32_close, + .reset = NULL, + .available = sb_awe64_ide_available, .speed_changed = sb_speed_changed, .force_redraw = NULL, .config = sb_awe64_config @@ -5842,7 +5876,7 @@ const device_t sb_awe64_gold_device = { .name = "Sound Blaster AWE64 Gold", .internal_name = "sbawe64_gold", .flags = DEVICE_ISA | DEVICE_AT, - .local = 4, + .local = SB_AWE64_GOLD, .init = sb_awe32_pnp_init, .close = sb_awe32_close, .reset = NULL, diff --git a/src/sound/sound.c b/src/sound/sound.c index d2d3dc313..625c50ea1 100644 --- a/src/sound/sound.c +++ b/src/sound/sound.c @@ -127,6 +127,7 @@ static const SOUND_CARD sound_cards[] = { { &sb_awe32_pnp_device }, { &sb_awe64_value_device }, { &sb_awe64_device }, + { &sb_awe64_ide_device }, { &sb_awe64_gold_device }, { &sb_vibra16c_device }, { &sb_vibra16s_device }, From 21a98774e46fe9280b6e55d7da59b41336306ce1 Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Sun, 29 Dec 2024 21:35:09 -0500 Subject: [PATCH 02/10] Standardization for PNP ROM loading --- src/sound/snd_sb.c | 46 ++++++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/src/sound/snd_sb.c b/src/sound/snd_sb.c index 91b49eafc..a8961c2a9 100644 --- a/src/sound/snd_sb.c +++ b/src/sound/snd_sb.c @@ -3325,16 +3325,16 @@ sb_16_pnp_init(UNUSED(const device_t *info)) device_add(&ide_qua_pnp_device); other_ide_present++; - uint8_t *pnp_rom = NULL; - - FILE *fp = rom_fopen(PNP_ROM_SB_16_PNP, "rb"); + uint8_t *pnp_rom = NULL; + FILE *fp = rom_fopen(PNP_ROM_SB_16_PNP, "rb"); + uint16_t pnp_rom_len = 512; if (fp) { - if (fread(sb->pnp_rom, 1, 390, fp) == 390) + if (fread(sb->pnp_rom, 1, pnp_rom_len, fp) == pnp_rom_len) pnp_rom = sb->pnp_rom; fclose(fp); } - isapnp_add_card(pnp_rom, 390, sb_16_pnp_config_changed, + isapnp_add_card(pnp_rom, sizeof(sb->pnp_rom), sb_16_pnp_config_changed, NULL, NULL, NULL, sb); sb_dsp_set_real_opl(&sb->dsp, 1); @@ -3415,9 +3415,10 @@ sb_vibra16_pnp_init(UNUSED(const device_t *info)) uint8_t *pnp_rom = NULL; if (pnp_rom_file) { - FILE *fp = rom_fopen(pnp_rom_file, "rb"); + FILE *fp = rom_fopen(pnp_rom_file, "rb"); + uint16_t pnp_rom_len = 512; if (fp) { - if (fread(sb->pnp_rom, 1, 512, fp) == 512) + if (fread(sb->pnp_rom, 1, pnp_rom_len, fp) == pnp_rom_len) pnp_rom = sb->pnp_rom; fclose(fp); } @@ -3426,7 +3427,7 @@ sb_vibra16_pnp_init(UNUSED(const device_t *info)) switch (info->local) { case 0: case 1: - isapnp_add_card(pnp_rom, 512, sb_vibra16_pnp_config_changed, + isapnp_add_card(pnp_rom, sizeof(sb->pnp_rom), sb_vibra16_pnp_config_changed, NULL, NULL, NULL, sb); break; @@ -3671,9 +3672,10 @@ sb_awe32_pnp_init(const device_t *info) uint8_t *pnp_rom = NULL; if (pnp_rom_file) { - FILE *fp = rom_fopen(pnp_rom_file, "rb"); + FILE *fp = rom_fopen(pnp_rom_file, "rb"); + uint16_t pnp_rom_len = 512; if (fp) { - if (fread(sb->pnp_rom, 1, 512, fp) == 512) + if (fread(sb->pnp_rom, 1, pnp_rom_len, fp) == pnp_rom_len) pnp_rom = sb->pnp_rom; fclose(fp); } @@ -3681,21 +3683,25 @@ sb_awe32_pnp_init(const device_t *info) switch (info->local) { case SB_32_PNP: - isapnp_add_card(pnp_rom, sizeof(sb->pnp_rom), sb_16_pnp_config_changed, NULL, NULL, NULL, sb); + isapnp_add_card(pnp_rom, sizeof(sb->pnp_rom), sb_16_pnp_config_changed, + NULL, NULL, NULL, sb); break; case SB_AWE32_PNP: - isapnp_add_card(pnp_rom, sizeof(sb->pnp_rom), sb_awe32_pnp_config_changed, NULL, NULL, NULL, sb); + isapnp_add_card(pnp_rom, sizeof(sb->pnp_rom), sb_awe32_pnp_config_changed, + NULL, NULL, NULL, sb); break; case SB_AWE64_IDE: - isapnp_add_card(pnp_rom, sizeof(sb->pnp_rom), sb_awe64_pnp_ide_config_changed, NULL, NULL, NULL, sb); + isapnp_add_card(pnp_rom, sizeof(sb->pnp_rom), sb_awe64_pnp_ide_config_changed, + NULL, NULL, NULL, sb); break; case SB_AWE64_VALUE: case SB_AWE64_NOIDE: case SB_AWE64_GOLD: - isapnp_add_card(pnp_rom, sizeof(sb->pnp_rom), sb_awe64_pnp_noide_config_changed, NULL, NULL, NULL, sb); + isapnp_add_card(pnp_rom, sizeof(sb->pnp_rom), sb_awe64_pnp_noide_config_changed, + NULL, NULL, NULL, sb); break; default: @@ -3836,7 +3842,6 @@ static void * ess_x688_pnp_init(UNUSED(const device_t *info)) { sb_t *ess = calloc(sizeof(sb_t), 1); - int len = 512; ess->pnp = 1 + (int) info->local; @@ -3869,20 +3874,21 @@ ess_x688_pnp_init(UNUSED(const device_t *info)) other_ide_present++; const char *pnp_rom_file = NULL; + uint16_t pnp_rom_len = 512; switch (info->local) { case 0: pnp_rom_file = PNP_ROM_ESS0100; - len = 145; + pnp_rom_len = 145; break; case 1: pnp_rom_file = PNP_ROM_ESS0102; - len = 145; + pnp_rom_len = 145; break; case 2: pnp_rom_file = PNP_ROM_ESS0968; - len = 135; + pnp_rom_len = 135; break; default: @@ -3893,13 +3899,13 @@ ess_x688_pnp_init(UNUSED(const device_t *info)) if (pnp_rom_file) { FILE *fp = rom_fopen(pnp_rom_file, "rb"); if (fp) { - if (fread(ess->pnp_rom, 1, len, fp) == len) + if (fread(ess->pnp_rom, 1, pnp_rom_len, fp) == pnp_rom_len) pnp_rom = ess->pnp_rom; fclose(fp); } } - isapnp_add_card(pnp_rom, len, ess_x688_pnp_config_changed, + isapnp_add_card(pnp_rom, sizeof(ess->pnp_rom), ess_x688_pnp_config_changed, NULL, NULL, NULL, ess); sb_dsp_setaddr(&ess->dsp, 0); From 0a0c1e349fec38ff9e3d51d18dedd87aa3862ad3 Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Sun, 24 Nov 2024 20:10:29 -0500 Subject: [PATCH 03/10] Add SB16 CT2940 no IDE variant --- src/include/86box/sound.h | 1 + src/sound/snd_sb.c | 98 ++++++++++++++++++++++++++++----------- src/sound/sound.c | 1 + 3 files changed, 74 insertions(+), 26 deletions(-) diff --git a/src/include/86box/sound.h b/src/include/86box/sound.h index e83006130..b6c7dc148 100644 --- a/src/include/86box/sound.h +++ b/src/include/86box/sound.h @@ -149,6 +149,7 @@ extern const device_t sb_vibra16xv_device; extern const device_t sb_vibra16c_onboard_device; extern const device_t sb_vibra16c_device; extern const device_t sb_16_pnp_device; +extern const device_t sb_16_pnp_ide_device; extern const device_t sb_16_compat_device; extern const device_t sb_16_compat_nompu_device; extern const device_t sb_16_reply_mca_device; diff --git a/src/sound/snd_sb.c b/src/sound/snd_sb.c index a8961c2a9..169396266 100644 --- a/src/sound/snd_sb.c +++ b/src/sound/snd_sb.c @@ -43,6 +43,9 @@ #include <86box/snd_sb.h> #include <86box/plat_unused.h> +#define SB_16_PNP_NOIDE 0 +#define SB_16_PNP_IDE 1 + #define SB_32_PNP 0 #define SB_AWE32_PNP 1 #define SB_AWE64_VALUE 2 @@ -50,19 +53,20 @@ #define SB_AWE64_IDE 4 #define SB_AWE64_GOLD 5 -#define PNP_ROM_SB_16_PNP "roms/sound/creative/CTL0024A.BIN" -#define PNP_ROM_SB_VIBRA16XV "roms/sound/creative/CT4170 PnP.BIN" -#define PNP_ROM_SB_VIBRA16C "roms/sound/creative/CT4180 PnP.BIN" -#define PNP_ROM_SB_32_PNP "roms/sound/creative/CT3600 PnP.BIN" -#define PNP_ROM_SB_AWE32_PNP "roms/sound/creative/CT3980 PnP.BIN" -#define PNP_ROM_SB_AWE64_VALUE "roms/sound/creative/CT4520 PnP.BIN" -#define PNP_ROM_SB_AWE64_NOIDE "roms/sound/creative/CT4380 PnP noIDE.BIN" -#define PNP_ROM_SB_AWE64_IDE "roms/sound/creative/CTL009DA.BIN" -#define PNP_ROM_SB_AWE64_GOLD "roms/sound/creative/CT4540 PnP.BIN" +#define PNP_ROM_SB_16_PNP_NOIDE "roms/sound/creative/CT2941 PnP.BIN" +#define PNP_ROM_SB_16_PNP_IDE "roms/sound/creative/CTL0024A.BIN" /* CT2940 */ +#define PNP_ROM_SB_VIBRA16XV "roms/sound/creative/CT4170 PnP.BIN" +#define PNP_ROM_SB_VIBRA16C "roms/sound/creative/CT4180 PnP.BIN" +#define PNP_ROM_SB_32_PNP "roms/sound/creative/CT3600 PnP.BIN" +#define PNP_ROM_SB_AWE32_PNP "roms/sound/creative/CT3980 PnP.BIN" +#define PNP_ROM_SB_AWE64_VALUE "roms/sound/creative/CT4520 PnP.BIN" +#define PNP_ROM_SB_AWE64_NOIDE "roms/sound/creative/CT4380 PnP noIDE.BIN" +#define PNP_ROM_SB_AWE64_IDE "roms/sound/creative/CTL009DA.BIN" /* CT4381? */ +#define PNP_ROM_SB_AWE64_GOLD "roms/sound/creative/CT4540 PnP.BIN" /* TODO: Find real ESS PnP ROM dumps. */ -#define PNP_ROM_ESS0100 "roms/sound/ess/ESS0100.BIN" -#define PNP_ROM_ESS0102 "roms/sound/ess/ESS0102.BIN" -#define PNP_ROM_ESS0968 "roms/sound/ess/ESS0968.BIN" +#define PNP_ROM_ESS0100 "roms/sound/ess/ESS0100.BIN" +#define PNP_ROM_ESS0102 "roms/sound/ess/ESS0102.BIN" +#define PNP_ROM_ESS0968 "roms/sound/ess/ESS0968.BIN" /* 0 to 7 -> -14dB to 0dB i 2dB steps. 8 to 15 -> 0 to +14dB in 2dB steps. Note that for positive dB values, this is not amplitude, it is amplitude - 1. */ @@ -3284,9 +3288,15 @@ sb_16_reply_mca_init(UNUSED(const device_t *info)) } static int -sb_16_pnp_available(void) +sb_16_pnp_noide_available(void) { - return rom_present(PNP_ROM_SB_16_PNP); + return rom_present(PNP_ROM_SB_16_PNP_NOIDE); +} + +static int +sb_16_pnp_ide_available(void) +{ + return rom_present(PNP_ROM_SB_16_PNP_IDE); } static void * @@ -3322,16 +3332,35 @@ sb_16_pnp_init(UNUSED(const device_t *info)) sb->gameport = gameport_add(&gameport_pnp_device); - device_add(&ide_qua_pnp_device); - other_ide_present++; + // Does it have IDE? + if (info->local != SB_16_PNP_NOIDE) { + device_add(&ide_qua_pnp_device); + other_ide_present++; + } - uint8_t *pnp_rom = NULL; - FILE *fp = rom_fopen(PNP_ROM_SB_16_PNP, "rb"); - uint16_t pnp_rom_len = 512; - if (fp) { - if (fread(sb->pnp_rom, 1, pnp_rom_len, fp) == pnp_rom_len) - pnp_rom = sb->pnp_rom; - fclose(fp); + const char *pnp_rom_file = NULL; + uint16_t pnp_rom_len = 512; + switch (info->local) { + case SB_16_PNP_NOIDE: + pnp_rom_file = PNP_ROM_SB_16_PNP_NOIDE; + break; + + case SB_16_PNP_IDE: + pnp_rom_file = PNP_ROM_SB_16_PNP_IDE; + break; + + default: + break; + } + + uint8_t *pnp_rom = NULL; + if (pnp_rom_file) { + FILE *fp = rom_fopen(pnp_rom_file, "rb"); + if (fp) { + if (fread(sb->pnp_rom, 1, pnp_rom_len, fp) == pnp_rom_len) + pnp_rom = sb->pnp_rom; + fclose(fp); + } } isapnp_add_card(pnp_rom, sizeof(sb->pnp_rom), sb_16_pnp_config_changed, @@ -3344,7 +3373,9 @@ sb_16_pnp_init(UNUSED(const device_t *info)) sb_dsp_setdma16(&sb->dsp, ISAPNP_DMA_DISABLED); mpu401_change_addr(sb->mpu, 0); - ide_remove_handlers(3); + + if (info->local != SB_16_PNP_NOIDE) + ide_remove_handlers(3); sb->gameport_addr = 0; gameport_remap(sb->gameport, 0); @@ -3714,6 +3745,7 @@ sb_awe32_pnp_init(const device_t *info) sb_dsp_setdma16(&sb->dsp, ISAPNP_DMA_DISABLED); mpu401_change_addr(sb->mpu, 0); + if ((info->local != SB_AWE64_VALUE) && (info->local != SB_AWE64_NOIDE) && (info->local != SB_AWE64_GOLD)) ide_remove_handlers(3); @@ -5756,11 +5788,25 @@ const device_t sb_16_pnp_device = { .name = "Sound Blaster 16 PnP", .internal_name = "sb16_pnp", .flags = DEVICE_ISA | DEVICE_AT, - .local = 0, + .local = SB_16_PNP_NOIDE, .init = sb_16_pnp_init, .close = sb_close, .reset = NULL, - .available = sb_16_pnp_available, + { .available = sb_16_pnp_noide_available }, + .speed_changed = sb_speed_changed, + .force_redraw = NULL, + .config = sb_16_pnp_config +}; + +const device_t sb_16_pnp_ide_device = { + .name = "Sound Blaster 16 PnP (IDE)", + .internal_name = "sb16_pnp_ide", + .flags = DEVICE_ISA | DEVICE_AT, + .local = SB_16_PNP_IDE, + .init = sb_16_pnp_init, + .close = sb_close, + .reset = NULL, + .available = sb_16_pnp_ide_available, .speed_changed = sb_speed_changed, .force_redraw = NULL, .config = sb_16_pnp_config diff --git a/src/sound/sound.c b/src/sound/sound.c index 625c50ea1..9b974f022 100644 --- a/src/sound/sound.c +++ b/src/sound/sound.c @@ -122,6 +122,7 @@ static const SOUND_CARD sound_cards[] = { { &sb_pro_v2_device }, { &sb_16_device }, { &sb_16_pnp_device }, + { &sb_16_pnp_ide_device }, { &sb_32_pnp_device }, { &sb_awe32_device }, { &sb_awe32_pnp_device }, From 14d5b7e259211a18d00db517085cc47202696820 Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Thu, 5 Dec 2024 10:52:37 -0500 Subject: [PATCH 04/10] Update SB Copyright --- src/sound/snd_sb.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/sound/snd_sb.c b/src/sound/snd_sb.c index 169396266..5919418d7 100644 --- a/src/sound/snd_sb.c +++ b/src/sound/snd_sb.c @@ -13,9 +13,11 @@ * Authors: Sarah Walker, * Miran Grca, * TheCollector1995, + * Jasmine Iwanek, * * Copyright 2008-2020 Sarah Walker. * Copyright 2016-2020 Miran Grca. + * Copyright 2024 Jasmine Iwanek. */ #include #include From 7dd540db96db1341fc099b2633498bbcd2a96b79 Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Fri, 27 Dec 2024 22:08:36 -0500 Subject: [PATCH 05/10] Bring net_cards in line with other device arrays --- src/network/network.c | 92 +++++++++++++++++++++++-------------------- 1 file changed, 49 insertions(+), 43 deletions(-) diff --git a/src/network/network.c b/src/network/network.c index 7c02609ae..e60f50eb1 100644 --- a/src/network/network.c +++ b/src/network/network.c @@ -75,40 +75,46 @@ # include #endif -static const device_t *net_cards[] = { - &device_none, - &device_internal, - &threec501_device, - &threec503_device, - &pcnet_am79c960_device, - &pcnet_am79c961_device, - &de220p_device, - &ne1000_compat_device, - &ne2000_compat_device, - &ne2000_compat_8bit_device, - &ne1000_device, - &ne2000_device, - &pcnet_am79c960_eb_device, - &rtl8019as_device, - &wd8003e_device, - &wd8003eb_device, - &wd8013ebt_device, - &plip_device, - ðernext_mc_device, - &wd8003eta_device, - &wd8003ea_device, - &wd8013epa_device, - &pcnet_am79c973_device, - &pcnet_am79c970a_device, - &dec_tulip_device, - &rtl8029as_device, - &rtl8139c_plus_device, - &dec_tulip_21140_device, - &dec_tulip_21140_vpc_device, - &dec_tulip_21040_device, - &pcnet_am79c960_vlb_device, - &modem_device, - NULL +typedef struct { + const device_t *device; +} NETWORK_CARD; + +static const NETWORK_CARD net_cards[] = { + // clang-format off + { &device_none }, + { &device_internal }, + { &threec501_device }, + { &threec503_device }, + { &pcnet_am79c960_device }, + { &pcnet_am79c961_device }, + { &de220p_device }, + { &ne1000_compat_device }, + { &ne2000_compat_device }, + { &ne2000_compat_8bit_device }, + { &ne1000_device }, + { &ne2000_device }, + { &pcnet_am79c960_eb_device }, + { &rtl8019as_device }, + { &wd8003e_device }, + { &wd8003eb_device }, + { &wd8013ebt_device }, + { &plip_device }, + { ðernext_mc_device }, + { &wd8003eta_device }, + { &wd8003ea_device }, + { &wd8013epa_device }, + { &pcnet_am79c973_device }, + { &pcnet_am79c970a_device }, + { &dec_tulip_device }, + { &rtl8029as_device }, + { &rtl8139c_plus_device }, + { &dec_tulip_21140_device }, + { &dec_tulip_21140_vpc_device }, + { &dec_tulip_21040_device }, + { &pcnet_am79c960_vlb_device }, + { &modem_device }, + { NULL } + // clang-format on }; netcard_conf_t net_cards_conf[NET_CARD_MAX]; @@ -581,7 +587,7 @@ network_reset(void) net_card_current = i; if (net_cards_conf[i].device_num > NET_INTERNAL) - device_add_inst(net_cards[net_cards_conf[i].device_num], i + 1); + device_add_inst(net_cards[net_cards_conf[i].device_num].device, i + 1); } } @@ -712,8 +718,8 @@ network_available(void) int network_card_available(int card) { - if (net_cards[card]) - return (device_available(net_cards[card])); + if (net_cards[card].device) + return (device_available(net_cards[card].device)); return 1; } @@ -722,24 +728,24 @@ network_card_available(int card) const device_t * network_card_getdevice(int card) { - return (net_cards[card]); + return (net_cards[card].device); } /* UI */ int network_card_has_config(int card) { - if (!net_cards[card]) + if (!net_cards[card].device) return 0; - return (device_has_config(net_cards[card]) ? 1 : 0); + return (device_has_config(net_cards[card].device) ? 1 : 0); } /* UI */ const char * network_card_get_internal_name(int card) { - return device_get_internal_name(net_cards[card]); + return device_get_internal_name(net_cards[card].device); } /* UI */ @@ -748,8 +754,8 @@ network_card_get_from_internal_name(char *s) { int c = 0; - while (net_cards[c] != NULL) { - if (!strcmp(net_cards[c]->internal_name, s)) + while (net_cards[c].device != NULL) { + if (!strcmp(net_cards[c].device->internal_name, s)) return c; c++; } From c0e73d777af36eb5664c098ce68d0e1d7de83dbf Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Mon, 19 Aug 2024 02:40:14 -0400 Subject: [PATCH 06/10] Some additional comments in CMS --- src/sound/snd_cms.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/sound/snd_cms.c b/src/sound/snd_cms.c index 4ca735ee6..2ec81b53d 100644 --- a/src/sound/snd_cms.c +++ b/src/sound/snd_cms.c @@ -95,15 +95,15 @@ cms_write(uint16_t addr, uint8_t val, void *priv) int chip = (addr & 2) >> 1; switch (addr & 0xf) { - case 1: + case 0x1: /* SAA #1 Register Select Port */ cms->addrs[0] = val & 31; break; - case 3: + case 0x3: /* SAA #2 Register Select Port */ cms->addrs[1] = val & 31; break; - case 0: - case 2: + case 0x0: /* SAA #1 Data Port */ + case 0x2: /* SAA #2 Data Port */ cms_update(cms); cms->regs[chip][cms->addrs[chip] & 31] = val; switch (cms->addrs[chip] & 31) { @@ -145,8 +145,9 @@ cms_write(uint16_t addr, uint8_t val, void *priv) break; } break; - case 0x6: - case 0x7: + + case 0x6: /* GameBlaster Write Port */ + case 0x7: /* GameBlaster Write Port */ cms->latched_data = val; break; @@ -161,14 +162,14 @@ cms_read(uint16_t addr, void *priv) const cms_t *cms = (cms_t *) priv; switch (addr & 0xf) { - case 0x1: + case 0x1: /* SAA #1 Register Select Port */ return cms->addrs[0]; - case 0x3: + case 0x3: /* SAA #2 Register Select Port */ return cms->addrs[1]; - case 0x4: + case 0x4: /* GameBlaster Read port (Always returns 0x7F) */ return 0x7f; - case 0xa: - case 0xb: + case 0xa: /* GameBlaster Read Port */ + case 0xb: /* GameBlaster Read Port */ return cms->latched_data; default: From b449f6f31038d26c4f5b6bff618fd7cb9d0b7856 Mon Sep 17 00:00:00 2001 From: OBattler Date: Mon, 30 Dec 2024 18:55:10 +0100 Subject: [PATCH 07/10] Sound Blaster PnP: Ignore IDE PnP changes if IDE is not present, fixes #5077. --- src/include/86box/snd_sb.h | 1 + src/sound/snd_sb.c | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/include/86box/snd_sb.h b/src/include/86box/snd_sb.h index 70fcff387..33467cf25 100644 --- a/src/include/86box/snd_sb.h +++ b/src/include/86box/snd_sb.h @@ -182,6 +182,7 @@ typedef struct sb_t { void *gameport; int pnp; + int has_ide; uint8_t pos_regs[8]; uint8_t pnp_rom[512]; diff --git a/src/sound/snd_sb.c b/src/sound/snd_sb.c index 5919418d7..8db328fa9 100644 --- a/src/sound/snd_sb.c +++ b/src/sound/snd_sb.c @@ -2181,7 +2181,8 @@ sb_16_pnp_config_changed(const uint8_t ld, isapnp_device_config_t *config, void break; case 1: /* IDE */ - ide_pnp_config_changed(0, config, (void *) 3); + if (sb->has_ide) + ide_pnp_config_changed(0, config, (void *) 3); break; case 2: /* Reserved (16) / WaveTable (32+) */ @@ -3338,6 +3339,8 @@ sb_16_pnp_init(UNUSED(const device_t *info)) if (info->local != SB_16_PNP_NOIDE) { device_add(&ide_qua_pnp_device); other_ide_present++; + + sb->has_ide = 1; } const char *pnp_rom_file = NULL; @@ -3671,6 +3674,8 @@ sb_awe32_pnp_init(const device_t *info) if ((info->local != SB_AWE64_VALUE) && (info->local != SB_AWE64_NOIDE) && (info->local != SB_AWE64_GOLD)) { device_add(&ide_qua_pnp_device); other_ide_present++; + + sb->has_ide = 1; } const char *pnp_rom_file = NULL; @@ -3849,6 +3854,8 @@ ess_x688_init(UNUSED(const device_t *info)) ide_set_side(4, ide_side); ide_set_irq(4, ide_irq); other_ide_present++; + + ess->has_ide = 1; } return ess; @@ -3907,6 +3914,8 @@ ess_x688_pnp_init(UNUSED(const device_t *info)) device_add(&ide_qua_pnp_device); other_ide_present++; + ess->has_ide = 1; + const char *pnp_rom_file = NULL; uint16_t pnp_rom_len = 512; switch (info->local) { From 4b24ce53ec034813e5a8192d0042bd89bb8c3cd7 Mon Sep 17 00:00:00 2001 From: OBattler Date: Mon, 30 Dec 2024 19:01:48 +0100 Subject: [PATCH 08/10] A handful of IDE fixes. --- src/disk/hdc_ide.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/disk/hdc_ide.c b/src/disk/hdc_ide.c index b868f51a0..a212361dc 100644 --- a/src/disk/hdc_ide.c +++ b/src/disk/hdc_ide.c @@ -145,7 +145,7 @@ typedef struct mcide_t { rom_t bios_rom; } mcide_t; -ide_board_t *ide_boards[IDE_BUS_MAX]; +ide_board_t *ide_boards[IDE_BUS_MAX] = { 0 }; static uint8_t ide_ter_pnp_rom[] = { /* BOX0001, serial 0, dummy checksum (filled in by isapnp_add_card) */ @@ -618,9 +618,12 @@ ide_hd_identify(const ide_t *ide) if (!ide_boards[ide->board]->force_ata3 && (bm != NULL)) { ide->buffer[80] = 0x7e; /*ATA-1 to ATA-6 supported*/ ide->buffer[81] = 0x19; /*ATA-6 revision 3a supported*/ - } else { + } else ide->buffer[80] = 0x0e; /*ATA-1 to ATA-3 supported*/ - } + + ide->buffer[83] = ide->buffer[84] = 0x4000; + ide->buffer[86] = 0x0000; + ide->buffer[87] = 0x4000; } static void @@ -2219,9 +2222,8 @@ ide_callback(void *priv) ide->sector_pos = 0; ret = hdd_image_read(ide->hdd_num, ide_get_sector(ide), ide->tf->secount ? ide->tf->secount : 256, ide->sector_buffer); - } else { + } else ret = 0; - } memcpy(ide->buffer, &ide->sector_buffer[ide->sector_pos * 512], 512); From 50244cdb2d70a14f2e80e70cb827bc107be46fb2 Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Mon, 30 Dec 2024 13:47:54 -0500 Subject: [PATCH 09/10] Add PNP 1IO and make Vibra16XV use it --- src/game/gameport.c | 14 ++++++++++++++ src/include/86box/gameport.h | 1 + src/sound/snd_sb.c | 32 ++++++++++++++++++++++---------- 3 files changed, 37 insertions(+), 10 deletions(-) diff --git a/src/game/gameport.c b/src/game/gameport.c index e7495e365..8d2a684fc 100644 --- a/src/game/gameport.c +++ b/src/game/gameport.c @@ -674,6 +674,20 @@ const device_t gameport_pnp_device = { .config = NULL }; +const device_t gameport_pnp_1io_device = { + .name = "Game port (Plug and Play only, 1 I/O port)", + .internal_name = "gameport_pnp_1io", + .flags = 0, + .local = GAMEPORT_1ADDR, + .init = gameport_init, + .close = gameport_close, + .reset = NULL, + { .available = NULL }, + .speed_changed = NULL, + .force_redraw = NULL, + .config = NULL +}; + const device_t gameport_pnp_6io_device = { .name = "Game port (Plug and Play only, 6 I/O ports)", .internal_name = "gameport_pnp_6io", diff --git a/src/include/86box/gameport.h b/src/include/86box/gameport.h index 576d6b8e7..3d3a253e8 100644 --- a/src/include/86box/gameport.h +++ b/src/include/86box/gameport.h @@ -127,6 +127,7 @@ extern const device_t gameport_20d_device; extern const device_t gameport_20f_device; extern const device_t gameport_tm_acm_device; extern const device_t gameport_pnp_device; +extern const device_t gameport_pnp_1io_device; extern const device_t gameport_pnp_6io_device; extern const device_t gameport_sio_device; extern const device_t gameport_sio_1io_device; diff --git a/src/sound/snd_sb.c b/src/sound/snd_sb.c index 8db328fa9..af93f5d3e 100644 --- a/src/sound/snd_sb.c +++ b/src/sound/snd_sb.c @@ -48,6 +48,9 @@ #define SB_16_PNP_NOIDE 0 #define SB_16_PNP_IDE 1 +#define SB_VIBRA16XV 0 +#define SB_VIBRA16C 1 + #define SB_32_PNP 0 #define SB_AWE32_PNP 1 #define SB_AWE64_VALUE 2 @@ -3412,9 +3415,9 @@ sb_vibra16_pnp_init(UNUSED(const device_t *info)) fm_driver_get(FM_YMF262, &sb->opl); sb_dsp_set_real_opl(&sb->dsp, 1); - sb_dsp_init(&sb->dsp, (info->local == 0) ? SBAWE64 : SBAWE32PNP, SB_SUBTYPE_DEFAULT, sb); + sb_dsp_init(&sb->dsp, (info->local == SB_VIBRA16XV) ? SBAWE64 : SBAWE32PNP, SB_SUBTYPE_DEFAULT, sb); /* The ViBRA 16XV does 16-bit DMA through 8-bit DMA. */ - sb_dsp_setdma16_supported(&sb->dsp, info->local != 0); + sb_dsp_setdma16_supported(&sb->dsp, info->local != SB_VIBRA16XV); sb_ct1745_mixer_reset(sb); sb->mixer_enabled = 1; @@ -3433,15 +3436,24 @@ sb_vibra16_pnp_init(UNUSED(const device_t *info)) if (device_get_config_int("receive_input")) midi_in_handler(1, sb_dsp_input_msg, sb_dsp_input_sysex, &sb->dsp); - sb->gameport = gameport_add(&gameport_pnp_device); + switch (info->local) { + case SB_VIBRA16XV: /* CTL7005 */ + sb->gameport = gameport_add(&gameport_pnp_1io_device); + break; + + case SB_VIBRA16C: /* CTL7001/CTL7002 */ + default: + sb->gameport = gameport_add(&gameport_pnp_device); + break; + } const char *pnp_rom_file = NULL; switch (info->local) { - case 0: + case SB_VIBRA16XV: pnp_rom_file = PNP_ROM_SB_VIBRA16XV; break; - case 1: + case SB_VIBRA16C: pnp_rom_file = PNP_ROM_SB_VIBRA16C; break; @@ -3461,8 +3473,8 @@ sb_vibra16_pnp_init(UNUSED(const device_t *info)) } switch (info->local) { - case 0: - case 1: + case SB_VIBRA16XV: + case SB_VIBRA16C: isapnp_add_card(pnp_rom, sizeof(sb->pnp_rom), sb_vibra16_pnp_config_changed, NULL, NULL, NULL, sb); break; @@ -5743,7 +5755,7 @@ const device_t sb_vibra16xv_device = { .name = "Sound Blaster ViBRA 16XV", .internal_name = "sb_vibra16xv", .flags = DEVICE_ISA | DEVICE_AT, - .local = 0, + .local = SB_VIBRA16XV, .init = sb_vibra16_pnp_init, .close = sb_close, .reset = NULL, @@ -5757,7 +5769,7 @@ const device_t sb_vibra16c_onboard_device = { .name = "Sound Blaster ViBRA 16C (On-Board)", .internal_name = "sb_vibra16c_onboard", .flags = DEVICE_ISA | DEVICE_AT, - .local = 1, + .local = SB_VIBRA16C, .init = sb_vibra16_pnp_init, .close = sb_close, .reset = NULL, @@ -5771,7 +5783,7 @@ const device_t sb_vibra16c_device = { .name = "Sound Blaster ViBRA 16C", .internal_name = "sb_vibra16c", .flags = DEVICE_ISA | DEVICE_AT, - .local = 1, + .local = SB_VIBRA16C, .init = sb_vibra16_pnp_init, .close = sb_close, .reset = NULL, From 5d041d65d597df24e56606efb124d57b7c676238 Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Mon, 30 Dec 2024 14:31:36 -0500 Subject: [PATCH 10/10] Add Vibra 16XV (Onboard) For future use --- src/include/86box/sound.h | 2 ++ src/sound/snd_sb.c | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/include/86box/sound.h b/src/include/86box/sound.h index b6c7dc148..2a6347b9c 100644 --- a/src/include/86box/sound.h +++ b/src/include/86box/sound.h @@ -109,6 +109,7 @@ extern void givealbuffer_wt(const void *buf); extern void givealbuffer_cd(const void *buf); #define sb_vibra16c_onboard_relocate_base sb_vibra16s_onboard_relocate_base +#define sb_vibra16xv_onboard_relocate_base sb_vibra16s_onboard_relocate_base extern void sb_vibra16s_onboard_relocate_base(uint16_t new_addr, void *priv); #ifdef EMU_DEVICE_H @@ -145,6 +146,7 @@ extern const device_t sb_pro_compat_device; extern const device_t sb_16_device; extern const device_t sb_vibra16s_onboard_device; extern const device_t sb_vibra16s_device; +extern const device_t sb_vibra16xv_onboard_device; extern const device_t sb_vibra16xv_device; extern const device_t sb_vibra16c_onboard_device; extern const device_t sb_vibra16c_device; diff --git a/src/sound/snd_sb.c b/src/sound/snd_sb.c index af93f5d3e..70cc8708b 100644 --- a/src/sound/snd_sb.c +++ b/src/sound/snd_sb.c @@ -5751,6 +5751,20 @@ const device_t sb_vibra16s_device = { .config = sb_16_config }; +const device_t sb_vibra16xv_onboard_device = { + .name = "Sound Blaster ViBRA 16XV (On-Board)", + .internal_name = "sb_vibra16xv_onboard", + .flags = DEVICE_ISA | DEVICE_AT, + .local = SB_VIBRA16XV, + .init = sb_vibra16_pnp_init, + .close = sb_close, + .reset = NULL, + .available = sb_vibra16xv_available, + .speed_changed = sb_speed_changed, + .force_redraw = NULL, + .config = sb_16_pnp_config +}; + const device_t sb_vibra16xv_device = { .name = "Sound Blaster ViBRA 16XV", .internal_name = "sb_vibra16xv",