diff --git a/src/include/86box/snd_opl.h b/src/include/86box/snd_opl.h index 22a5473f4..f01ea0214 100644 --- a/src/include/86box/snd_opl.h +++ b/src/include/86box/snd_opl.h @@ -32,7 +32,7 @@ typedef struct { #else void *opl; #endif - int8_t is_opl3; + int8_t is_opl3, do_cycles; uint16_t port; uint8_t status; @@ -47,6 +47,8 @@ typedef struct { } opl_t; +extern void opl_set_do_cycles(opl_t *dev, int8_t do_cycles); + extern uint8_t opl2_read(uint16_t port, void *); extern void opl2_write(uint16_t port, uint8_t val, void *); extern void opl2_init(opl_t *); diff --git a/src/sound/snd_opl.c b/src/sound/snd_opl.c index 68b778d4b..07a7370fe 100644 --- a/src/sound/snd_opl.c +++ b/src/sound/snd_opl.c @@ -162,11 +162,20 @@ opl_write(opl_t *dev, uint16_t port, uint8_t val) } +void +opl_set_do_cycles(opl_t *dev, int8_t do_cycles) +{ + dev->do_cycles = do_cycles; +} + + static void opl_init(opl_t *dev, int is_opl3) { memset(dev, 0x00, sizeof(opl_t)); + dev->is_opl3 = is_opl3; + dev->do_cycles = 1; /* Create a NukedOPL object. */ dev->opl = nuked_init(48000); @@ -192,7 +201,8 @@ opl2_read(uint16_t port, void *priv) { opl_t *dev = (opl_t *)priv; - cycles -= ISA_CYCLES(8); + if (dev->do_cycles) + sub_cycles((int) (isa_timing * 8)); opl2_update(dev); @@ -240,7 +250,8 @@ opl3_read(uint16_t port, void *priv) { opl_t *dev = (opl_t *)priv; - cycles -= ISA_CYCLES(8); + if (dev->do_cycles) + sub_cycles((int)(isa_timing * 8)); opl3_update(dev); diff --git a/src/sound/snd_sb.c b/src/sound/snd_sb.c index d382fc218..e42317536 100644 --- a/src/sound/snd_sb.c +++ b/src/sound/snd_sb.c @@ -1187,6 +1187,8 @@ sb_pro_v1_opl_read(uint16_t port, void *priv) { sb_t *sb = (sb_t *)priv; + sub_cycles((int)(isa_timing * 8)); + (void)opl2_read(port, &sb->opl2); // read, but ignore return(opl2_read(port, &sb->opl)); } @@ -1225,7 +1227,9 @@ void *sb_pro_v1_init(const device_t *info) sb->opl_enabled = device_get_config_int("opl"); if (sb->opl_enabled) { opl2_init(&sb->opl); + opl_set_do_cycles(&sb->opl, 0); opl2_init(&sb->opl2); + opl_set_do_cycles(&sb->opl2, 0); } sb_dsp_init(&sb->dsp, SBPRO, SB_SUBTYPE_DEFAULT, sb); sb_dsp_setaddr(&sb->dsp, addr);