From 87cdb6ac2892aa3e5a9525d7c21ea595f8ae131d Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Tue, 9 Jul 2024 23:15:51 -0400 Subject: [PATCH] Add toggle to disable uneven L/R sample timing quirk Co-Authored-By: Evan Ramos <1585791+hendricks266@users.noreply.github.com> --- src/sound/snd_opl_nuked.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/sound/snd_opl_nuked.c b/src/sound/snd_opl_nuked.c index 6134910b9..9468622f4 100644 --- a/src/sound/snd_opl_nuked.c +++ b/src/sound/snd_opl_nuked.c @@ -51,6 +51,11 @@ #include <86box/device.h> #include <86box/snd_opl.h> +/* Quirk: Some FM channels are output one sample later on the left side than the right. */ +#ifndef OPL_QUIRK_CHANNELSAMPLEDELAY +#define OPL_QUIRK_CHANNELSAMPLEDELAY 1 +#endif + #define WRBUF_SIZE 1024 #define WRBUF_DELAY 1 #define RSM_FRAC 10 @@ -1287,7 +1292,11 @@ nuked_generate(void *priv, int32_t *bufp) bufp[1] = dev->mixbuff[1]; +#if OPL_QUIRK_CHANNELSAMPLEDELAY for (i = 0; i < 15; i++) +#else + for (i = 0; i < 36; i++) +#endif process_slot(&dev->slot[i]); mix = 0; @@ -1301,13 +1310,17 @@ nuked_generate(void *priv, int32_t *bufp) dev->mixbuff[0] = mix; +#if OPL_QUIRK_CHANNELSAMPLEDELAY for (i = 15; i < 18; i++) process_slot(&dev->slot[i]); +#endif bufp[0] = dev->mixbuff[0]; +#if OPL_QUIRK_CHANNELSAMPLEDELAY for (i = 18; i < 33; i++) process_slot(&dev->slot[i]); +#endif mix = 0; @@ -1320,8 +1333,10 @@ nuked_generate(void *priv, int32_t *bufp) dev->mixbuff[1] = mix; +#if OPL_QUIRK_CHANNELSAMPLEDELAY for (i = 33; i < 36; i++) process_slot(&dev->slot[i]); +#endif if ((dev->timer & 0x3f) == 0x3f) dev->tremolopos = (dev->tremolopos + 1) % 210;