23 #ifndef WAVEFORMGENERATOR_H
24 #define WAVEFORMGENERATOR_H
26 #include "siddefs-fp.h"
95 unsigned int shift_register;
98 int shift_register_reset;
106 int no_noise_or_noise_output;
113 int floating_output_ttl;
137 void clock_shift_register();
139 void write_shift_register();
141 void reset_shift_register();
143 void set_noise_output();
146 void setWaveformModels(
matrix_t* models);
179 shift_register_reset(0),
184 no_noise_or_noise_output(no_noise | noise_output),
188 floating_output_ttl(0),
202 void writeFREQ_LO(
unsigned char freq_lo) { freq = (freq & 0xff00) | (freq_lo & 0xff); }
209 void writeFREQ_HI(
unsigned char freq_hi) { freq = (freq_hi << 8 & 0xff00) | (freq & 0xff); }
219 void writePW_LO(
unsigned char pw_lo) { pw = (pw & 0xf00) | (pw_lo & 0x0ff); }
226 void writePW_HI(
unsigned char pw_hi) { pw = (pw_hi << 8 & 0xf00) | (pw & 0x0ff); }
252 unsigned char readOSC()
const {
return (
unsigned char)(waveform_output >> 4); }
277 #if RESID_INLINING || defined(WAVEFORMGENERATOR_CPP)
287 if (unlikely(shift_register_reset != 0) && unlikely(--shift_register_reset == 0))
289 reset_shift_register();
293 pulse_output = 0xfff;
298 const int accumulator_next = (accumulator + freq) & 0xffffff;
299 const int accumulator_bits_set = ~accumulator & accumulator_next;
300 accumulator = accumulator_next;
303 msb_rising = (accumulator_bits_set & 0x800000) != 0;
307 if (unlikely((accumulator_bits_set & 0x080000) != 0))
312 else if (unlikely(shift_pipeline) != 0 && --shift_pipeline == 0)
314 clock_shift_register();
323 if (likely(waveform != 0))
327 const int ix = (accumulator ^ (ringModulator->accumulator & ring_msb_mask)) >> 12;
328 waveform_output = wave[ix] & (no_pulse | pulse_output) & no_noise_or_noise_output;
330 if (unlikely(waveform > 0x8))
334 write_shift_register();
340 if (likely(floating_output_ttl != 0) && unlikely(--floating_output_ttl == 0))
358 pulse_output = ((accumulator >> 12) >= pw) ? 0xfff : 0x000;
362 return dac[waveform_output];