gate bit fixes?

This commit is contained in:
LTVA1 2024-08-01 09:07:16 +03:00
parent c8c082977d
commit 46e41b5fb4
2 changed files with 13 additions and 4 deletions

View file

@ -159,6 +159,7 @@ void DivPlatformSID3::tick(bool sysTick)
chan[i].duty = 0x1000;
updateDuty(i);
rWrite(i * SID3_REGISTERS_PER_CHANNEL, 0); //gate off TODO: make it properly?
rWrite(i * SID3_REGISTERS_PER_CHANNEL, SID3_CHAN_ENABLE_GATE); //gate on
}
if (chan[i].keyOff)

View file

@ -2455,15 +2455,23 @@ void sid3_write(SID3* sid3, uint8_t address, uint8_t data)
{
if(channel != SID3_NUM_CHANNELS - 1)
{
//uint8_t prev_flags = sid3->chan[channel].flags & SID3_CHAN_ENABLE_GATE;
uint8_t prev_flags = sid3->chan[channel].flags;
sid3->chan[channel].flags = data;
sid3_gate_bit(sid3->chan[channel].flags & SID3_CHAN_ENABLE_GATE, &sid3->chan[channel].adsr);
if((prev_flags & SID3_CHAN_ENABLE_GATE) != (sid3->chan[channel].flags & SID3_CHAN_ENABLE_GATE))
{
sid3_gate_bit(sid3->chan[channel].flags & SID3_CHAN_ENABLE_GATE, &sid3->chan[channel].adsr);
}
}
else
{
//uint8_t prev_flags = sid3->chan[channel].flags & SID3_CHAN_ENABLE_GATE;
uint8_t prev_flags = sid3->chan[channel].flags;
sid3->wave_chan.flags = data;
sid3_gate_bit(sid3->wave_chan.flags & SID3_CHAN_ENABLE_GATE, &sid3->wave_chan.adsr);
if((prev_flags & SID3_CHAN_ENABLE_GATE) != (sid3->wave_chan.flags & SID3_CHAN_ENABLE_GATE))
{
sid3_gate_bit(sid3->wave_chan.flags & SID3_CHAN_ENABLE_GATE, &sid3->wave_chan.adsr);
}
}
break;
}