From 2c1e691c1ade0e3d5901fa9f46f89e74d1696e4d Mon Sep 17 00:00:00 2001 From: TomW Date: Sun, 10 Nov 2013 16:40:52 +0000 Subject: [PATCH] Workaround for bad AWE32 ROM dumps created by AWE-DUMP - Win95 AWE32 drivers now work with these dumps. EMU8000 now updates CVCF/VTFT with current/target volume - Win95 AWE32 drivers now no longer cut off notes early. Set SB DSP version for AWE32 to v4.13. --- src/sound_emu8k.c | 15 +++++++++++++++ src/sound_sb.c | 2 +- src/sound_sb_dsp.c | 2 +- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/sound_emu8k.c b/src/sound_emu8k.c index 9fa4e38..08118d6 100644 --- a/src/sound_emu8k.c +++ b/src/sound_emu8k.c @@ -554,6 +554,7 @@ void emu8k_poll(void *p) { case ENV_ATTACK: emu8k->voice[c].env_vol += emu8k->voice[c].env_attack; + emu8k->voice[c].vtft |= 0xffff0000; if (emu8k->voice[c].env_vol >= (1 << 21)) { emu8k->voice[c].env_vol = 1 << 21; @@ -563,6 +564,7 @@ void emu8k_poll(void *p) case ENV_DECAY: emu8k->voice[c].env_vol -= emu8k->voice[c].env_decay; + emu8k->voice[c].vtft = (emu8k->voice[c].vtft & ~0xffff0000) | ((emu8k->voice[c].env_sustain >> 5) << 16); if (emu8k->voice[c].env_vol <= emu8k->voice[c].env_sustain) { emu8k->voice[c].env_vol = emu8k->voice[c].env_sustain; @@ -572,6 +574,7 @@ void emu8k_poll(void *p) case ENV_RELEASE: emu8k->voice[c].env_vol -= emu8k->voice[c].env_release; + emu8k->voice[c].vtft &= ~0xffff0000; if (emu8k->voice[c].env_vol <= 0) { emu8k->voice[c].env_vol = 0; @@ -580,6 +583,11 @@ void emu8k_poll(void *p) break; } + if (emu8k->voice[c].env_vol >= (1 << 21)) + emu8k->voice[c].cvcf &= ~0xffff0000; + else + emu8k->voice[c].cvcf = (emu8k->voice[c].cvcf & ~0xffff0000) | ((emu8k->voice[c].env_vol >> 5) << 16); + switch (emu8k->voice[c].menv_state) { case ENV_ATTACK: @@ -649,6 +657,13 @@ void emu8k_init(emu8k_t *emu8k) fread(emu8k->rom, 1024 * 1024, 1, f); fclose(f); + /*AWE-DUMP creates ROM images offset by 2 bytes, so if we detect this + then correct it*/ + if (emu8k->rom[3] == 0x314d && emu8k->rom[4] == 0x474d) + { + memcpy(&emu8k->rom[0], &emu8k->rom[1], (1024 * 1024) - 2); + emu8k->rom[0x7ffff] = 0; + } io_sethandler(0x0620, 0x0004, emu8k_inb, emu8k_inw, NULL, emu8k_outb, emu8k_outw, NULL, emu8k); io_sethandler(0x0a20, 0x0004, emu8k_inb, emu8k_inw, NULL, emu8k_outb, emu8k_outw, NULL, emu8k); io_sethandler(0x0e20, 0x0004, emu8k_inb, emu8k_inw, NULL, emu8k_outb, emu8k_outw, NULL, emu8k); diff --git a/src/sound_sb.c b/src/sound_sb.c index 1c652f2..7f4318e 100644 --- a/src/sound_sb.c +++ b/src/sound_sb.c @@ -387,7 +387,7 @@ void *sb_awe32_init() memset(sb, 0, sizeof(sb_t)); opl3_init(&sb->opl); - sb_dsp_init(&sb->dsp, SB16); + sb_dsp_init(&sb->dsp, SB16 + 1); sb_dsp_setaddr(&sb->dsp, 0x0220); sb_mixer_init(&sb->mixer); io_sethandler(0x0220, 0x0004, opl3_read, NULL, NULL, opl3_write, NULL, NULL, &sb->opl); diff --git a/src/sound_sb_dsp.c b/src/sound_sb_dsp.c index 7f63e6e..affc609 100644 --- a/src/sound_sb_dsp.c +++ b/src/sound_sb_dsp.c @@ -49,7 +49,7 @@ static int sb_commands[256]= }; char sb16_copyright[] = "COPYRIGHT (C) CREATIVE TECHNOLOGY LTD, 1992."; -uint16_t sb_dsp_versions[] = {0, 0, 0x105, 0x200, 0x201, 0x300, 0x302, 0x405}; +uint16_t sb_dsp_versions[] = {0, 0, 0x105, 0x200, 0x201, 0x300, 0x302, 0x405, 0x40d}; /*These tables were 'borrowed' from DOSBox*/ int8_t scaleMap4[64] = {