1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-01-11 08:30:55 +00:00

Experimentally turned the 6502 into a clock receiver. No problem encountered.

This commit is contained in:
Thomas Harte 2017-07-22 21:52:21 -04:00
parent 1ba3f262a2
commit 83628b285b
6 changed files with 10 additions and 9 deletions

View File

@ -22,7 +22,7 @@ template<class T> class Cartridge:
Cartridge(const std::vector<uint8_t> &rom) :
rom_(rom) {}
void run_for_cycles(int number_of_cycles) { CPU::MOS6502::Processor<Cartridge<T>>::run_for_cycles(number_of_cycles); }
void run_for_cycles(int number_of_cycles) { CPU::MOS6502::Processor<Cartridge<T>>::run_for(Cycles(number_of_cycles)); }
void set_reset_line(bool state) { CPU::MOS6502::Processor<Cartridge<T>>::set_reset_line(state); }
void advance_cycles(unsigned int cycles) {}

View File

@ -80,7 +80,7 @@ void Machine::set_disk(std::shared_ptr<Storage::Disk::Disk> disk) {
}
void Machine::run_for_cycles(int number_of_cycles) {
CPU::MOS6502::Processor<Machine>::run_for_cycles(number_of_cycles);
CPU::MOS6502::Processor<Machine>::run_for(Cycles(number_of_cycles));
set_motor_on(drive_VIA_.get_motor_enabled());
if(drive_VIA_.get_motor_enabled()) // TODO: motor speed up/down
Storage::Disk::Controller::run_for_cycles(number_of_cycles);

View File

@ -174,7 +174,7 @@ class Machine:
virtual void close_output();
virtual std::shared_ptr<Outputs::CRT::CRT> get_crt() { return mos6560_->get_crt(); }
virtual std::shared_ptr<Outputs::Speaker> get_speaker() { return mos6560_->get_speaker(); }
virtual void run_for_cycles(int number_of_cycles) { CPU::MOS6502::Processor<Machine>::run_for_cycles(number_of_cycles); }
virtual void run_for_cycles(int number_of_cycles) { CPU::MOS6502::Processor<Machine>::run_for(Cycles(number_of_cycles)); }
// to satisfy MOS::MOS6522::Delegate
virtual void mos6522_did_change_interrupt_status(void *mos6522);

View File

@ -94,7 +94,7 @@ class Machine:
virtual void close_output();
virtual std::shared_ptr<Outputs::CRT::CRT> get_crt();
virtual std::shared_ptr<Outputs::Speaker> get_speaker();
virtual void run_for_cycles(int number_of_cycles) { CPU::MOS6502::Processor<Machine>::run_for_cycles(number_of_cycles); }
virtual void run_for_cycles(int number_of_cycles) { CPU::MOS6502::Processor<Machine>::run_for(Cycles(number_of_cycles)); }
// to satisfy Tape::Delegate
virtual void tape_did_change_interrupt_status(Tape *tape);

View File

@ -199,7 +199,7 @@ std::shared_ptr<Outputs::Speaker> Machine::get_speaker() {
}
void Machine::run_for_cycles(int number_of_cycles) {
CPU::MOS6502::Processor<Machine>::run_for_cycles(number_of_cycles);
CPU::MOS6502::Processor<Machine>::run_for(Cycles(number_of_cycles));
}
#pragma mark - The 6522

View File

@ -13,6 +13,7 @@
#include <cstdint>
#include "../RegisterSizes.hpp"
#include "../../Components/ClockReceiver.hpp"
namespace CPU {
namespace MOS6502 {
@ -127,7 +128,7 @@ class ProcessorBase {
that will cause call outs when the program counter reaches those addresses. @c return_from_subroutine can be used to exit from a
jammed state.
*/
template <class T> class Processor: public ProcessorBase {
template <class T> class Processor: public ProcessorBase, public ClockReceiver<Processor<T>> {
private:
const MicroOp *scheduled_program_counter_;
@ -290,9 +291,9 @@ template <class T> class Processor: public ProcessorBase {
The 6502 will call that method for all bus accesses. The 6502 is guaranteed to perform one bus operation call per cycle.
If it is a read operation then @c value will be seeded with the value 0xff.
@param number_of_cycles The number of cycles to run the 6502 for.
@param cycles The number of cycles to run the 6502 for.
*/
void run_for_cycles(int number_of_cycles) {
void run_for(const Cycles &cycles) {
static const MicroOp doBranch[] = {
CycleReadFromPC,
CycleAddSignedOperandToPC,
@ -339,7 +340,7 @@ template <class T> class Processor: public ProcessorBase {
if(number_of_cycles <= 0) break;
checkSchedule();
number_of_cycles += cycles_left_to_run_;
int number_of_cycles = int(cycles) + cycles_left_to_run_;
while(number_of_cycles > 0) {