mirror of
https://github.com/TomHarte/CLK.git
synced 2025-11-24 13:17:41 +00:00
Correct clock rate, triangle wave.
This commit is contained in:
@@ -35,7 +35,10 @@ void SID::write(const Numeric::SizedInt<5> address, const uint8_t value) {
|
||||
oscillator().pulse_width = (oscillator().pitch & 0xf0'00'00'00) | uint32_t(value << 20);
|
||||
break;
|
||||
case 0x03: case 0x0a: case 0x11:
|
||||
oscillator().pulse_width = (oscillator().pitch & 0x0f'f0'00'00) | uint32_t(value << 28);
|
||||
// The top bit of the phase counter is inverted; since it'll be compared directly with the
|
||||
// pulse width, invert that bit too.
|
||||
oscillator().pulse_width =
|
||||
((oscillator().pitch & 0x0f'f0'00'00) | uint32_t(value << 28)) ^ 0x8000'0000;
|
||||
break;
|
||||
case 0x04: case 0x0b: case 0x12:
|
||||
voice().control = value;
|
||||
|
||||
@@ -116,8 +116,9 @@ private:
|
||||
|
||||
uint16_t triangle_output(const Voice &prior) const {
|
||||
const uint16_t sawtooth = oscillator.sawtooth();
|
||||
const uint16_t xor_mask =
|
||||
((sawtooth ^ (ring_mod() && prior.sawtooth())) & 0x800) ? 0xfff : 0x000;
|
||||
const uint16_t xor_mask1 = sawtooth;
|
||||
const uint16_t xor_mask2 = ring_mod() ? prior.sawtooth() : 0;
|
||||
const uint16_t xor_mask = (xor_mask1 ^ xor_mask2) ? 0xfff : 0x000;
|
||||
return ((sawtooth << 1) ^ xor_mask) & 0xfff;
|
||||
}
|
||||
|
||||
|
||||
@@ -128,13 +128,13 @@ private:
|
||||
|
||||
public:
|
||||
Audio() :
|
||||
sn76489_(TI::SN76489::Personality::SN76489, audio_queue_, 2),
|
||||
sn76489_(TI::SN76489::Personality::SN76489, audio_queue_, 4),
|
||||
sid_(audio_queue_),
|
||||
compound_(sn76489_, sid_),
|
||||
speaker_(speaker_source())
|
||||
{
|
||||
// Combined with the additional divider specified above, implies this chip is clocked at 4Mhz.
|
||||
speaker_.set_input_rate(2'000'000.0f);
|
||||
// Combined with the additional divider specified above, implies the SN76489 is clocked at 4Mhz.
|
||||
speaker_.set_input_rate(1'000'000.0f);
|
||||
}
|
||||
|
||||
~Audio() {
|
||||
|
||||
Reference in New Issue
Block a user