diff --git a/drivers/vga-nextgen/vga.c b/drivers/vga-nextgen/vga.c index 3e3f45f..c0da82b 100644 --- a/drivers/vga-nextgen/vga.c +++ b/drivers/vga-nextgen/vga.c @@ -116,7 +116,8 @@ inline static void sound_callback() { adlib_cycles_per_vga = 0; } sum_adlib_samples += adlibgensample_ch(adlib_cycles_per_vga); - out += (int16_t)(sum_adlib_samples >> adlib_divider); + register uint8_t d = adlib_divider; + out += (int16_t)(sum_adlib_samples >> d); if (adlib_cycles_per_vga == 0) { sum_adlib_samples = 0; } @@ -132,21 +133,24 @@ inline static void sound_callback() { last_dss_sample = dss_sample(); dss_cycles_per_vga = 0; } - out += dss_divider > 8 ? - ((int16_t)last_dss_sample - (int16_t)0x0080) >> (dss_divider - 8): - ((int16_t)last_dss_sample - (int16_t)0x0080) << (8 - dss_divider); // 8 unsigned on LPT1 mix to signed 16 + register uint8_t d = dss_divider; + out += d > 8 ? + ((int16_t)last_dss_sample - (int16_t)0x0080) >> (d - 8): + ((int16_t)last_dss_sample - (int16_t)0x0080) << (8 - d); // 8 unsigned on LPT1 mix to signed 16 } #endif #ifdef COVOX - if (is_covox_on) { - out += covox_divider > 8 ? - ((int16_t)true_covox - (int16_t)0x0080) >> (covox_divider - 8): - ((int16_t)true_covox - (int16_t)0x0080) << (8 - covox_divider); // 8 unsigned on LPT2 mix to signed 16 + if (is_covox_on && true_covox) { + register uint8_t d = covox_divider; + out += d > 8 ? + ((int16_t)true_covox - (int16_t)0x0080) >> (d - 8): + ((int16_t)true_covox - (int16_t)0x0080) << (8 - d); // 8 unsigned on LPT2 mix to signed 16 } #endif #ifdef TANDY3V if (is_tandy3v_on) { - out += sn76489_sample() >> tandy3v_divider; // already signed 16 + register uint8_t d = tandy3v_divider; + out += sn76489_sample() >> d; // already signed 16 } #endif #ifdef CMS @@ -163,10 +167,10 @@ inline static void sound_callback() { out_l = out; out_r = out; #endif - register uint8_t r_rivider = snd_divider; // TODO: tume up divider per channel - register uint8_t l_rivider = snd_divider; - pwm_set_gpio_level(PWM_PIN0,(int16_t)((int32_t)out_r + 0x8000L) >> r_rivider); // Право signed 16 to unsigned 16 - pwm_set_gpio_level(PWM_PIN1,(int16_t)((int32_t)out_l + 0x8000L) >> l_rivider); // Лево signed 16 to unsigned 16 + register uint8_t r_divider = snd_divider; // TODO: tume up divider per channel + register uint8_t l_divider = snd_divider; + pwm_set_gpio_level(PWM_PIN0,(uint16_t)((int32_t)out_r + 0x8000L) >> r_divider); // Право signed 16 to unsigned 16 + pwm_set_gpio_level(PWM_PIN1,(uint16_t)((int32_t)out_l + 0x8000L) >> l_divider); // Лево signed 16 to unsigned 16 } #endif diff --git a/src/audio/adlib.c b/src/audio/adlib.c index d72049b..735ea39 100644 --- a/src/audio/adlib.c +++ b/src/audio/adlib.c @@ -22,7 +22,7 @@ #include #include - +#include //static double samprateadjust = 1.0; //static uint8_t optable[0x16] = { 0, 0, 0, 1, 1, 1, 255, 255, 0, 0, 0, 1, 1, 1, 255, 255, 0, 0, 0, 1, 1, 1 }; @@ -106,9 +106,11 @@ static uint8_t adlibdidattack[9], adlibpercussion = 0, adlibstatus = 0; static uint16_t adlibport = 0x388; +extern volatile bool is_adlib_on; void outadlib ( uint16_t portnum, uint8_t value ) { + if (!is_adlib_on) return; if (portnum == adlibport) { adlibaddr = value; return; @@ -153,6 +155,7 @@ void outadlib ( uint16_t portnum, uint8_t value ) uint8_t inadlib ( uint16_t portnum ) { + if (!is_adlib_on) return 0; if (!adlibregmem[4]) adlibstatus = 0; else @@ -231,6 +234,7 @@ static inline void tickadlib_ch ( uint16_t curchan ) void tickadlib ( void ) { + if (!is_adlib_on) return; for (int curchan = 0; curchan < 9; curchan++) { tickadlib_ch(curchan); } diff --git a/src/manager.c b/src/manager.c index ce31755..a4f799d 100644 --- a/src/manager.c +++ b/src/manager.c @@ -37,7 +37,7 @@ volatile uint8_t cms_divider = 12; volatile uint8_t dss_divider = 0; volatile uint8_t adlib_divider = 0; volatile uint8_t tandy3v_divider = 0; -volatile uint8_t covox_divider = 9; +volatile uint8_t covox_divider = 0; volatile bool is_xms_on = false; volatile bool is_ems_on = true;