23 #ifndef WAVEFORMGENERATOR_H
24 #define WAVEFORMGENERATOR_H
26 #include "siddefs-fp.h"
59 int shift_register_reset;
69 int no_noise_or_noise_output;
78 int floating_output_ttl;
104 void clock_shift_register();
106 void write_shift_register();
108 void reset_shift_register();
110 void set_noise_output();
146 shift_register_reset(0),
151 no_noise_or_noise_output(no_noise | noise_output),
155 floating_output_ttl(0),
169 void writeFREQ_LO(
unsigned char freq_lo) { freq = (freq & 0xff00) | (freq_lo & 0xff); }
176 void writeFREQ_HI(
unsigned char freq_hi) { freq = (freq_hi << 8 & 0xff00) | (freq & 0xff); }
186 void writePW_LO(
unsigned char pw_lo) { pw = (pw & 0xf00) | (pw_lo & 0x0ff); }
193 void writePW_HI(
unsigned char pw_hi) { pw = (pw_hi << 8 & 0xf00) | (pw & 0x0ff); }
220 unsigned char readOSC()
const {
return (
unsigned char)(waveform_output >> 4); }
245 #if RESID_INLINING || defined(WAVEFORMGENERATOR_CPP)
255 if (shift_register_reset != 0 && -- shift_register_reset == 0)
257 reset_shift_register();
261 pulse_output = 0xfff;
266 const int accumulator_next = (accumulator + freq) & 0xffffff;
267 const int accumulator_bits_set = ~accumulator & accumulator_next;
268 accumulator = accumulator_next;
271 msb_rising = (accumulator_bits_set & 0x800000) != 0;
275 if ((accumulator_bits_set & 0x080000) != 0)
280 else if (shift_pipeline != 0 && -- shift_pipeline == 0)
282 clock_shift_register();
295 const int ix = (accumulator ^ (ringModulator->accumulator & ring_msb_mask)) >> 12;
296 waveform_output = wave[ix] & (no_pulse | pulse_output) & no_noise_or_noise_output;
301 write_shift_register();
307 if (floating_output_ttl != 0 && -- floating_output_ttl == 0)
325 pulse_output = ((accumulator >> 12) >= pw) ? 0xfff : 0x000;
329 return dac[waveform_output];