1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-02-02 16:38:51 +00:00

Ensured propagation of synchronise messages, added enough to do plain tone. Probably. So: noise and envelopes missing. And it's all far too quiet.

This commit is contained in:
Thomas Harte 2016-10-15 21:04:21 -04:00
parent 51bdac27ae
commit 9730e8247f
4 changed files with 33 additions and 3 deletions

View File

@ -10,8 +10,9 @@
using namespace GI; using namespace GI;
AY38910::AY38910() : _selected_register(0) AY38910::AY38910() : _selected_register(0), _channel_ouput{0, 0, 0}
{ {
_output_registers[8] = _output_registers[9] = _output_registers[10] = 0;
} }
void AY38910::set_clock_rate(double clock_rate) void AY38910::set_clock_rate(double clock_rate)
@ -19,17 +20,39 @@ void AY38910::set_clock_rate(double clock_rate)
set_input_rate((float)clock_rate); set_input_rate((float)clock_rate);
} }
#define step(c) \
_channel_dividers[c] -= resulting_steps; \
if(!_channel_dividers[c]) \
{ \
_channel_dividers[c] = (int)_tone_generator_controls[c] + 1; \
_channel_ouput[c] ^= 1; \
}
void AY38910::get_samples(unsigned int number_of_samples, int16_t *target) void AY38910::get_samples(unsigned int number_of_samples, int16_t *target)
{ {
printf("%d\n", number_of_samples);
for(int c = 0; c < number_of_samples; c++) for(int c = 0; c < number_of_samples; c++)
{ {
*target++ = (c & 64) * 64; // a master divider divides the clock by 16
int former_master_divider = _master_divider;
_master_divider++;
int resulting_steps = ((_master_divider ^ former_master_divider) >> 4) & 1;
// from that the three channels count down
step(0);
step(1);
step(2);
*target++ = (int16_t)((
((_output_registers[8]&0xf) * _channel_ouput[0]) +
((_output_registers[9]&0xf) * _channel_ouput[1]) +
((_output_registers[10]&0xf) * _channel_ouput[2])
) * 512);
} }
} }
void AY38910::skip_samples(unsigned int number_of_samples) void AY38910::skip_samples(unsigned int number_of_samples)
{ {
// TODO
} }
void AY38910::select_register(uint8_t r) void AY38910::select_register(uint8_t r)

View File

@ -33,6 +33,10 @@ class AY38910: public ::Outputs::Filter<AY38910> {
uint16_t _tone_generator_controls[3]; uint16_t _tone_generator_controls[3];
uint16_t _envelope_period; uint16_t _envelope_period;
int _master_divider;
int _channel_dividers[3];
int _channel_ouput[3];
}; };
}; };

View File

@ -61,6 +61,7 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin
void Machine::synchronise() void Machine::synchronise()
{ {
update_video(); update_video();
_via.synchronise();
} }
void Machine::update_video() void Machine::update_video()

View File

@ -138,6 +138,8 @@ class Machine:
std::shared_ptr<GI::AY38910> ay8910; std::shared_ptr<GI::AY38910> ay8910;
std::shared_ptr<Keyboard> keyboard; std::shared_ptr<Keyboard> keyboard;
inline void synchronise() { update_ay(); }
private: private:
void update_ay() void update_ay()
{ {