1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-12-26 09:29:45 +00:00

Reintroduced clocking of the AY and boxed in the range of the master divider a little further.

This commit is contained in:
Thomas Harte 2016-10-30 22:51:08 -04:00
parent 1333a42a78
commit 21604376e6
3 changed files with 33 additions and 12 deletions

View File

@ -15,6 +15,7 @@ AY38910::AY38910() :
_tone_counters{0, 0, 0}, _tone_periods{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_period(0), _noise_counter(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),
_master_divider(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}
{ {
_output_registers[8] = _output_registers[9] = _output_registers[10] = 0; _output_registers[8] = _output_registers[9] = _output_registers[10] = 0;
@ -137,6 +138,8 @@ void AY38910::get_samples(unsigned int number_of_samples, int16_t *target)
_master_divider++; _master_divider++;
} }
} }
_master_divider &= 15;
} }
void AY38910::evaluate_output_volume() void AY38910::evaluate_output_volume()

View File

@ -123,8 +123,25 @@ void Machine::tape_did_change_input(Storage::Tape::BinaryTapePlayer *tape_player
_via.set_control_line_input(VIA::Port::B, VIA::Line::One, tape_player->get_input()); _via.set_control_line_input(VIA::Port::B, VIA::Line::One, tape_player->get_input());
} }
std::shared_ptr<Outputs::CRT::CRT> Machine::get_crt()
{
return _videoOutput->get_crt();
}
std::shared_ptr<Outputs::Speaker> Machine::get_speaker()
{
return _via.ay8910;
}
void Machine::run_for_cycles(int number_of_cycles)
{
CPU6502::Processor<Machine>::run_for_cycles(number_of_cycles);
}
#pragma mark - The 6522 #pragma mark - The 6522
Machine::VIA::VIA() : MOS::MOS6522<Machine::VIA>(), _cycles_since_ay_update(0) {}
void Machine::VIA::set_control_line_output(Port port, Line line, bool value) void Machine::VIA::set_control_line_output(Port port, Line line, bool value)
{ {
if(line) if(line)
@ -162,19 +179,19 @@ uint8_t Machine::VIA::get_port_input(Port port)
void Machine::VIA::synchronise() void Machine::VIA::synchronise()
{ {
ay8910->run_for_cycles(_half_cycles_since_ay_update >> 1); ay8910->run_for_cycles(_cycles_since_ay_update);
_half_cycles_since_ay_update &= 1; _cycles_since_ay_update = 0;
} }
void Machine::VIA::run_for_half_cycles(unsigned int number_of_cycles) void Machine::VIA::run_for_cycles(unsigned int number_of_cycles)
{ {
_half_cycles_since_ay_update += number_of_cycles; _cycles_since_ay_update += number_of_cycles;
MOS::MOS6522<VIA>::run_for_half_cycles(number_of_cycles); MOS::MOS6522<VIA>::run_for_cycles(number_of_cycles);
} }
void Machine::VIA::update_ay() void Machine::VIA::update_ay()
{ {
ay8910->run_for_cycles(_half_cycles_since_ay_update >> 1); ay8910->run_for_cycles(_cycles_since_ay_update);
_half_cycles_since_ay_update &= 1; _cycles_since_ay_update = 0;
ay8910->set_control_lines( (GI::AY38910::ControlLines)((_ay_bdir ? GI::AY38910::BCDIR : 0) | (_ay_bc1 ? GI::AY38910::BC1 : 0) | GI::AY38910::BC2)); ay8910->set_control_lines( (GI::AY38910::ControlLines)((_ay_bdir ? GI::AY38910::BCDIR : 0) | (_ay_bc1 ? GI::AY38910::BC1 : 0) | GI::AY38910::BC2));
} }

View File

@ -71,9 +71,9 @@ class Machine:
// to satisfy CRTMachine::Machine // to satisfy CRTMachine::Machine
virtual void setup_output(float aspect_ratio); virtual void setup_output(float aspect_ratio);
virtual void close_output(); virtual void close_output();
virtual std::shared_ptr<Outputs::CRT::CRT> get_crt() { return _videoOutput->get_crt(); } virtual std::shared_ptr<Outputs::CRT::CRT> get_crt();
virtual std::shared_ptr<Outputs::Speaker> get_speaker() { return _via.ay8910; } virtual std::shared_ptr<Outputs::Speaker> get_speaker();
virtual void run_for_cycles(int number_of_cycles) { CPU6502::Processor<Machine>::run_for_cycles(number_of_cycles); } virtual void run_for_cycles(int number_of_cycles);
// to satisfy MOS::MOS6522IRQDelegate::Delegate // to satisfy MOS::MOS6522IRQDelegate::Delegate
void mos6522_did_change_interrupt_status(void *mos6522); void mos6522_did_change_interrupt_status(void *mos6522);
@ -100,12 +100,13 @@ class Machine:
// VIA (which owns the tape and the AY) // VIA (which owns the tape and the AY)
class VIA: public MOS::MOS6522<VIA>, public MOS::MOS6522IRQDelegate { class VIA: public MOS::MOS6522<VIA>, public MOS::MOS6522IRQDelegate {
public: public:
VIA();
using MOS6522IRQDelegate::set_interrupt_status; using MOS6522IRQDelegate::set_interrupt_status;
void set_control_line_output(Port port, Line line, bool value); void set_control_line_output(Port port, Line line, bool value);
void set_port_output(Port port, uint8_t value, uint8_t direction_mask); void set_port_output(Port port, uint8_t value, uint8_t direction_mask);
uint8_t get_port_input(Port port); uint8_t get_port_input(Port port);
inline void run_for_half_cycles(unsigned int number_of_cycles); inline void run_for_cycles(unsigned int number_of_cycles);
std::shared_ptr<GI::AY38910> ay8910; std::shared_ptr<GI::AY38910> ay8910;
std::shared_ptr<Storage::Tape::BinaryTapePlayer> tape; std::shared_ptr<Storage::Tape::BinaryTapePlayer> tape;
@ -116,7 +117,7 @@ class Machine:
private: private:
void update_ay(); void update_ay();
bool _ay_bdir, _ay_bc1; bool _ay_bdir, _ay_bc1;
unsigned int _half_cycles_since_ay_update; unsigned int _cycles_since_ay_update;
}; };
VIA _via; VIA _via;
std::shared_ptr<Keyboard> _keyboard; std::shared_ptr<Keyboard> _keyboard;