1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-12-25 18:30:21 +00:00

Settled on terminology.

This commit is contained in:
Thomas Harte 2016-10-23 20:42:49 -04:00
parent 7c33c34b0c
commit fd823dc222
2 changed files with 18 additions and 22 deletions

View File

@ -12,8 +12,8 @@ using namespace GI;
AY38910::AY38910() : AY38910::AY38910() :
_selected_register(0), _selected_register(0),
_tone_counters{0, 0, 0}, _tone_dividers{0, 0, 0}, _tone_outputs{0, 0, 0}, _tone_counters{0, 0, 0}, _tone_periods{0, 0, 0}, _tone_outputs{0, 0, 0},
_noise_shift_register(0xffff), _noise_divider(0), _noise_output(0), _noise_shift_register(0xffff), _noise_period(0), _noise_counter(0), _noise_output(0),
_envelope_divider(0), _envelope_period(0), _envelope_position(0), _envelope_divider(0), _envelope_period(0), _envelope_position(0),
_output_registers{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} _output_registers{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
{ {
@ -97,11 +97,9 @@ void AY38910::get_samples(unsigned int number_of_samples, int16_t *target)
else\ else\
{\ {\
_tone_outputs[c] ^= 1;\ _tone_outputs[c] ^= 1;\
_tone_counters[c] = _tone_dividers[c];\ _tone_counters[c] = _tone_periods[c];\
} }
// _tone_counters[c] = (_tone_counters[c] + 1) % (2 * (_tone_dividers[c] + 1))
// update the tone channels // update the tone channels
step_channel(0); step_channel(0);
step_channel(1); step_channel(1);
@ -111,10 +109,10 @@ void AY38910::get_samples(unsigned int number_of_samples, int16_t *target)
// ... the noise generator. This recomputes the new bit repeatedly but harmlessly, only shifting // ... the noise generator. This recomputes the new bit repeatedly but harmlessly, only shifting
// it into the official 17 upon divider underflow. // it into the official 17 upon divider underflow.
if(_noise_divider) _noise_divider--; if(_noise_counter) _noise_counter--;
else else
{ {
_noise_divider = _output_registers[6]; _noise_counter = _noise_period;
_noise_output ^= _noise_shift_register&1; _noise_output ^= _noise_shift_register&1;
_noise_shift_register |= ((_noise_shift_register ^ (_noise_shift_register >> 3))&1) << 17; _noise_shift_register |= ((_noise_shift_register ^ (_noise_shift_register >> 3))&1) << 17;
_noise_shift_register >>= 1; _noise_shift_register >>= 1;
@ -198,19 +196,17 @@ void AY38910::set_register_value(uint8_t value)
{ {
int channel = selected_register >> 1; int channel = selected_register >> 1;
// _tone_counters[channel] /= _tone_dividers[channel] + 1;
if(selected_register & 1) if(selected_register & 1)
_tone_dividers[channel] = (_tone_dividers[channel] & 0xff) | (uint16_t)((value&0xf) << 8); _tone_periods[channel] = (_tone_periods[channel] & 0xff) | (uint16_t)((value&0xf) << 8);
else else
_tone_dividers[channel] = (_tone_dividers[channel] & ~0xff) | value; _tone_periods[channel] = (_tone_periods[channel] & ~0xff) | value;
// _tone_counters[channel] *= _tone_dividers[channel] + 1; _tone_counters[channel] = _tone_periods[channel];
_tone_counters[channel] = _tone_dividers[channel];
} }
break; break;
case 6: case 6:
masked_value &= 0x1f; _noise_period = value & 0x1f;
_noise_divider = masked_value; _noise_counter = _noise_period;
break; break;
case 11: case 11:

View File

@ -54,25 +54,25 @@ class AY38910: public ::Outputs::Filter<AY38910> {
int _selected_register; int _selected_register;
uint8_t _registers[16], _output_registers[16]; uint8_t _registers[16], _output_registers[16];
int _tone_dividers[3]; int _master_divider;
int _tone_periods[3];
int _tone_counters[3]; int _tone_counters[3];
int _tone_outputs[3]; int _tone_outputs[3];
int _volumes[16]; int _noise_period;
int _noise_counter;
int _master_divider;
int _noise_divider;
int _noise_shift_register; int _noise_shift_register;
int _noise_output; int _noise_output;
int _envelope_period; int _envelope_period;
int _envelope_divider; int _envelope_divider;
int _envelope_position; int _envelope_position;
int _envelope_shapes[16][32]; int _envelope_shapes[16][32];
int _envelope_overflow_masks[16]; int _envelope_overflow_masks[16];
int _volumes[16];
enum ControlState { enum ControlState {
Inactive, Inactive,
LatchAddress, LatchAddress,
@ -87,7 +87,7 @@ class AY38910: public ::Outputs::Filter<AY38910> {
uint8_t _data_input, _data_output; uint8_t _data_input, _data_output;
int16_t _output_volume; int16_t _output_volume;
void evaluate_output_volume(); inline void evaluate_output_volume();
}; };
}; };