23 #ifndef WAVEFORMGENERATOR_H
24 #define WAVEFORMGENERATOR_H
26 #include "siddefs-fp.h"
96 unsigned int shift_register;
99 int shift_register_reset;
107 int no_noise_or_noise_output;
114 int floating_output_ttl;
136 void clock_shift_register();
138 void write_shift_register();
140 void reset_shift_register();
142 void set_noise_output();
145 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),
201 void writeFREQ_LO(
unsigned char freq_lo) { freq = (freq & 0xff00) | (freq_lo & 0xff); }
208 void writeFREQ_HI(
unsigned char freq_hi) { freq = (freq_hi << 8 & 0xff00) | (freq & 0xff); }
218 void writePW_LO(
unsigned char pw_lo) { pw = (pw & 0xf00) | (pw_lo & 0x0ff); }
225 void writePW_HI(
unsigned char pw_hi) { pw = (pw_hi << 8 & 0xf00) | (pw & 0x0ff); }
251 unsigned char readOSC()
const {
return (
unsigned char)(waveform_output >> 4); }
276 #if RESID_INLINING || defined(WAVEFORMGENERATOR_CPP)
286 if (unlikely(shift_register_reset != 0) && unlikely(--shift_register_reset == 0))
288 reset_shift_register();
292 pulse_output = 0xfff;
297 const int accumulator_next = (accumulator + freq) & 0xffffff;
298 const int accumulator_bits_set = ~accumulator & accumulator_next;
299 accumulator = accumulator_next;
302 msb_rising = (accumulator_bits_set & 0x800000) != 0;
306 if (unlikely((accumulator_bits_set & 0x080000) != 0))
311 else if (unlikely(shift_pipeline) != 0 && --shift_pipeline == 0)
313 clock_shift_register();
322 if (likely(waveform != 0))
326 const int ix = (accumulator ^ (ringModulator->accumulator & ring_msb_mask)) >> 12;
327 waveform_output = wave[ix] & (no_pulse | pulse_output) & no_noise_or_noise_output;
329 if (unlikely(waveform > 0x8))
333 write_shift_register();
339 if (likely(floating_output_ttl != 0) && unlikely(--floating_output_ttl == 0))
357 pulse_output = ((accumulator >> 12) >= pw) ? 0xfff : 0x000;
361 return dac[waveform_output];