mirror of
https://github.com/TomHarte/CLK.git
synced 2025-08-12 09:25:19 +00:00
Merge pull request #166 from TomHarte/NoRefs
Standardises on `const [Half]Cycles`
This commit is contained in:
@@ -153,7 +153,7 @@ class HalfCycles: public WrappedInt<HalfCycles> {
|
|||||||
inline HalfCycles(int l) : WrappedInt<HalfCycles>(l) {}
|
inline HalfCycles(int l) : WrappedInt<HalfCycles>(l) {}
|
||||||
inline HalfCycles() : WrappedInt<HalfCycles>() {}
|
inline HalfCycles() : WrappedInt<HalfCycles>() {}
|
||||||
|
|
||||||
inline HalfCycles(const Cycles &cycles) : WrappedInt<HalfCycles>(cycles.as_int() << 1) {}
|
inline HalfCycles(const Cycles cycles) : WrappedInt<HalfCycles>(cycles.as_int() << 1) {}
|
||||||
inline HalfCycles(const HalfCycles &half_cycles) : WrappedInt<HalfCycles>(half_cycles.length_) {}
|
inline HalfCycles(const HalfCycles &half_cycles) : WrappedInt<HalfCycles>(half_cycles.length_) {}
|
||||||
|
|
||||||
/// @returns The number of whole cycles completely covered by this span of half cycles.
|
/// @returns The number of whole cycles completely covered by this span of half cycles.
|
||||||
@@ -178,7 +178,7 @@ template <class T> class HalfClockReceiver: public T {
|
|||||||
using T::T;
|
using T::T;
|
||||||
|
|
||||||
using T::run_for;
|
using T::run_for;
|
||||||
inline void run_for(const HalfCycles &half_cycles) {
|
inline void run_for(const HalfCycles half_cycles) {
|
||||||
half_cycles_ += half_cycles;
|
half_cycles_ += half_cycles;
|
||||||
T::run_for(half_cycles_.flush_cycles());
|
T::run_for(half_cycles_.flush_cycles());
|
||||||
}
|
}
|
||||||
|
@@ -124,7 +124,7 @@ uint8_t WD1770::get_register(int address) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WD1770::run_for(const Cycles &cycles) {
|
void WD1770::run_for(const Cycles cycles) {
|
||||||
Storage::Disk::Controller::run_for(cycles);
|
Storage::Disk::Controller::run_for(cycles);
|
||||||
|
|
||||||
if(delay_time_) {
|
if(delay_time_) {
|
||||||
|
@@ -43,7 +43,7 @@ class WD1770: public Storage::Disk::Controller {
|
|||||||
uint8_t get_register(int address);
|
uint8_t get_register(int address);
|
||||||
|
|
||||||
/// Runs the controller for @c number_of_cycles cycles.
|
/// Runs the controller for @c number_of_cycles cycles.
|
||||||
void run_for(const Cycles &cycles);
|
void run_for(const Cycles cycles);
|
||||||
using Storage::Disk::Controller::run_for;
|
using Storage::Disk::Controller::run_for;
|
||||||
|
|
||||||
enum Flag: uint8_t {
|
enum Flag: uint8_t {
|
||||||
|
@@ -253,7 +253,7 @@ template <class T> class MOS6522 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*! Runs for a specified number of half cycles. */
|
/*! Runs for a specified number of half cycles. */
|
||||||
inline void run_for(const HalfCycles &half_cycles) {
|
inline void run_for(const HalfCycles half_cycles) {
|
||||||
int number_of_half_cycles = half_cycles.as_int();
|
int number_of_half_cycles = half_cycles.as_int();
|
||||||
|
|
||||||
if(is_phase2_) {
|
if(is_phase2_) {
|
||||||
@@ -276,7 +276,7 @@ template <class T> class MOS6522 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*! Runs for a specified number of cycles. */
|
/*! Runs for a specified number of cycles. */
|
||||||
inline void run_for(const Cycles &cycles) {
|
inline void run_for(const Cycles cycles) {
|
||||||
int number_of_cycles = cycles.as_int();
|
int number_of_cycles = cycles.as_int();
|
||||||
while(number_of_cycles--) {
|
while(number_of_cycles--) {
|
||||||
phase1();
|
phase1();
|
||||||
|
@@ -106,7 +106,7 @@ template <class T> class MOS6532 {
|
|||||||
return 0xff;
|
return 0xff;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void run_for(const Cycles &cycles) {
|
inline void run_for(const Cycles cycles) {
|
||||||
unsigned int number_of_cycles = (unsigned int)cycles.as_int();
|
unsigned int number_of_cycles = (unsigned int)cycles.as_int();
|
||||||
|
|
||||||
// permit counting _to_ zero; counting _through_ zero initiates the other behaviour
|
// permit counting _to_ zero; counting _through_ zero initiates the other behaviour
|
||||||
|
@@ -150,7 +150,7 @@ template <class T> class MOS6560 {
|
|||||||
/*!
|
/*!
|
||||||
Runs for cycles. Derr.
|
Runs for cycles. Derr.
|
||||||
*/
|
*/
|
||||||
inline void run_for(const Cycles &cycles) {
|
inline void run_for(const Cycles cycles) {
|
||||||
// keep track of the amount of time since the speaker was updated; lazy updates are applied
|
// keep track of the amount of time since the speaker was updated; lazy updates are applied
|
||||||
cycles_since_speaker_update_ += cycles;
|
cycles_since_speaker_update_ += cycles;
|
||||||
|
|
||||||
|
@@ -44,7 +44,7 @@ class Machine:
|
|||||||
virtual void close_output();
|
virtual void close_output();
|
||||||
virtual std::shared_ptr<Outputs::CRT::CRT> get_crt() { return bus_->tia_->get_crt(); }
|
virtual std::shared_ptr<Outputs::CRT::CRT> get_crt() { return bus_->tia_->get_crt(); }
|
||||||
virtual std::shared_ptr<Outputs::Speaker> get_speaker() { return bus_->speaker_; }
|
virtual std::shared_ptr<Outputs::Speaker> get_speaker() { return bus_->speaker_; }
|
||||||
virtual void run_for(const Cycles &cycles) { bus_->run_for(cycles); }
|
virtual void run_for(const Cycles cycles) { bus_->run_for(cycles); }
|
||||||
|
|
||||||
// to satisfy Outputs::CRT::Delegate
|
// to satisfy Outputs::CRT::Delegate
|
||||||
virtual void crt_did_end_batch_of_frames(Outputs::CRT::CRT *crt, unsigned int number_of_frames, unsigned int number_of_unexpected_vertical_syncs);
|
virtual void crt_did_end_batch_of_frames(Outputs::CRT::CRT *crt, unsigned int number_of_frames, unsigned int number_of_unexpected_vertical_syncs);
|
||||||
|
@@ -24,7 +24,7 @@ class Bus {
|
|||||||
tia_input_value_{0xff, 0xff},
|
tia_input_value_{0xff, 0xff},
|
||||||
cycles_since_speaker_update_(0) {}
|
cycles_since_speaker_update_(0) {}
|
||||||
|
|
||||||
virtual void run_for(const Cycles &cycles) = 0;
|
virtual void run_for(const Cycles cycles) = 0;
|
||||||
virtual void set_reset_line(bool state) = 0;
|
virtual void set_reset_line(bool state) = 0;
|
||||||
|
|
||||||
// the RIOT, TIA and speaker
|
// the RIOT, TIA and speaker
|
||||||
|
@@ -22,7 +22,7 @@ template<class T> class Cartridge:
|
|||||||
Cartridge(const std::vector<uint8_t> &rom) :
|
Cartridge(const std::vector<uint8_t> &rom) :
|
||||||
rom_(rom) {}
|
rom_(rom) {}
|
||||||
|
|
||||||
void run_for(const Cycles &cycles) { CPU::MOS6502::Processor<Cartridge<T>>::run_for(cycles); }
|
void run_for(const Cycles cycles) { CPU::MOS6502::Processor<Cartridge<T>>::run_for(cycles); }
|
||||||
void set_reset_line(bool state) { CPU::MOS6502::Processor<Cartridge<T>>::set_reset_line(state); }
|
void set_reset_line(bool state) { CPU::MOS6502::Processor<Cartridge<T>>::set_reset_line(state); }
|
||||||
void advance_cycles(int cycles) {}
|
void advance_cycles(int cycles) {}
|
||||||
|
|
||||||
|
@@ -165,7 +165,7 @@ void TIA::set_output_mode(Atari2600::TIA::OutputMode output_mode) {
|
|||||||
/* speaker_->set_input_rate((float)(get_clock_rate() / 38.0));*/
|
/* speaker_->set_input_rate((float)(get_clock_rate() / 38.0));*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void TIA::run_for(const Cycles &cycles) {
|
void TIA::run_for(const Cycles cycles) {
|
||||||
int number_of_cycles = cycles.as_int();
|
int number_of_cycles = cycles.as_int();
|
||||||
|
|
||||||
// if part way through a line, definitely perform a partial, at most up to the end of the line
|
// if part way through a line, definitely perform a partial, at most up to the end of the line
|
||||||
@@ -198,7 +198,7 @@ void TIA::set_blank(bool blank) {
|
|||||||
void TIA::reset_horizontal_counter() {
|
void TIA::reset_horizontal_counter() {
|
||||||
}
|
}
|
||||||
|
|
||||||
int TIA::get_cycles_until_horizontal_blank(const Cycles &from_offset) {
|
int TIA::get_cycles_until_horizontal_blank(const Cycles from_offset) {
|
||||||
return (cycles_per_line - (horizontal_counter_ + from_offset.as_int()) % cycles_per_line) % cycles_per_line;
|
return (cycles_per_line - (horizontal_counter_ + from_offset.as_int()) % cycles_per_line) % cycles_per_line;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -30,7 +30,7 @@ class TIA {
|
|||||||
/*!
|
/*!
|
||||||
Advances the TIA by @c cycles. Any queued setters take effect in the first cycle performed.
|
Advances the TIA by @c cycles. Any queued setters take effect in the first cycle performed.
|
||||||
*/
|
*/
|
||||||
void run_for(const Cycles &cycles);
|
void run_for(const Cycles cycles);
|
||||||
void set_output_mode(OutputMode output_mode);
|
void set_output_mode(OutputMode output_mode);
|
||||||
|
|
||||||
void set_sync(bool sync);
|
void set_sync(bool sync);
|
||||||
@@ -41,7 +41,7 @@ class TIA {
|
|||||||
@returns the number of cycles between (current TIA time) + from_offset to the current or
|
@returns the number of cycles between (current TIA time) + from_offset to the current or
|
||||||
next horizontal blanking period. Returns numbers in the range [0, 227].
|
next horizontal blanking period. Returns numbers in the range [0, 227].
|
||||||
*/
|
*/
|
||||||
int get_cycles_until_horizontal_blank(const Cycles &from_offset);
|
int get_cycles_until_horizontal_blank(const Cycles from_offset);
|
||||||
|
|
||||||
void set_background_colour(uint8_t colour);
|
void set_background_colour(uint8_t colour);
|
||||||
|
|
||||||
|
@@ -43,7 +43,7 @@ class Machine {
|
|||||||
virtual std::shared_ptr<Outputs::Speaker> get_speaker() = 0;
|
virtual std::shared_ptr<Outputs::Speaker> get_speaker() = 0;
|
||||||
|
|
||||||
/// Runs the machine for @c cycles.
|
/// Runs the machine for @c cycles.
|
||||||
virtual void run_for(const Cycles &cycles) = 0;
|
virtual void run_for(const Cycles cycles) = 0;
|
||||||
|
|
||||||
// TODO: sever the clock-rate stuff.
|
// TODO: sever the clock-rate stuff.
|
||||||
double get_clock_rate() {
|
double get_clock_rate() {
|
||||||
|
@@ -79,7 +79,7 @@ void Machine::set_disk(std::shared_ptr<Storage::Disk::Disk> disk) {
|
|||||||
set_drive(drive);
|
set_drive(drive);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Machine::run_for(const Cycles &cycles) {
|
void Machine::run_for(const Cycles cycles) {
|
||||||
CPU::MOS6502::Processor<Machine>::run_for(cycles);
|
CPU::MOS6502::Processor<Machine>::run_for(cycles);
|
||||||
set_motor_on(drive_VIA_.get_motor_enabled());
|
set_motor_on(drive_VIA_.get_motor_enabled());
|
||||||
if(drive_VIA_.get_motor_enabled()) // TODO: motor speed up/down
|
if(drive_VIA_.get_motor_enabled()) // TODO: motor speed up/down
|
||||||
|
@@ -138,7 +138,7 @@ class Machine:
|
|||||||
*/
|
*/
|
||||||
void set_serial_bus(std::shared_ptr<::Commodore::Serial::Bus> serial_bus);
|
void set_serial_bus(std::shared_ptr<::Commodore::Serial::Bus> serial_bus);
|
||||||
|
|
||||||
void run_for(const Cycles &cycles);
|
void run_for(const Cycles cycles);
|
||||||
void set_disk(std::shared_ptr<Storage::Disk::Disk> disk);
|
void set_disk(std::shared_ptr<Storage::Disk::Disk> disk);
|
||||||
|
|
||||||
// to satisfy CPU::MOS6502::Processor
|
// to satisfy CPU::MOS6502::Processor
|
||||||
|
@@ -174,7 +174,7 @@ class Machine:
|
|||||||
virtual void close_output();
|
virtual void close_output();
|
||||||
virtual std::shared_ptr<Outputs::CRT::CRT> get_crt() { return mos6560_->get_crt(); }
|
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 std::shared_ptr<Outputs::Speaker> get_speaker() { return mos6560_->get_speaker(); }
|
||||||
virtual void run_for(const Cycles &cycles) { CPU::MOS6502::Processor<Machine>::run_for(cycles); }
|
virtual void run_for(const Cycles cycles) { CPU::MOS6502::Processor<Machine>::run_for(cycles); }
|
||||||
|
|
||||||
// to satisfy MOS::MOS6522::Delegate
|
// to satisfy MOS::MOS6522::Delegate
|
||||||
virtual void mos6522_did_change_interrupt_status(void *mos6522);
|
virtual void mos6522_did_change_interrupt_status(void *mos6522);
|
||||||
|
@@ -95,7 +95,7 @@ class Machine:
|
|||||||
virtual void close_output();
|
virtual void close_output();
|
||||||
virtual std::shared_ptr<Outputs::CRT::CRT> get_crt();
|
virtual std::shared_ptr<Outputs::CRT::CRT> get_crt();
|
||||||
virtual std::shared_ptr<Outputs::Speaker> get_speaker();
|
virtual std::shared_ptr<Outputs::Speaker> get_speaker();
|
||||||
virtual void run_for(const Cycles &cycles) { CPU::MOS6502::Processor<Machine>::run_for(cycles); }
|
virtual void run_for(const Cycles cycles) { CPU::MOS6502::Processor<Machine>::run_for(cycles); }
|
||||||
|
|
||||||
// to satisfy Tape::Delegate
|
// to satisfy Tape::Delegate
|
||||||
virtual void tape_did_change_interrupt_status(Tape *tape);
|
virtual void tape_did_change_interrupt_status(Tape *tape);
|
||||||
|
@@ -80,7 +80,7 @@ void Tape::acorn_shifter_output_bit(int value) {
|
|||||||
push_tape_bit((uint16_t)value);
|
push_tape_bit((uint16_t)value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tape::run_for(const Cycles &cycles) {
|
void Tape::run_for(const Cycles cycles) {
|
||||||
if(is_enabled_) {
|
if(is_enabled_) {
|
||||||
if(is_in_input_mode_) {
|
if(is_in_input_mode_) {
|
||||||
if(is_running_) {
|
if(is_running_) {
|
||||||
|
@@ -24,7 +24,7 @@ class Tape:
|
|||||||
public:
|
public:
|
||||||
Tape();
|
Tape();
|
||||||
|
|
||||||
void run_for(const Cycles &cycles);
|
void run_for(const Cycles cycles);
|
||||||
using Storage::Tape::TapePlayer::run_for;
|
using Storage::Tape::TapePlayer::run_for;
|
||||||
|
|
||||||
uint8_t get_data_register();
|
uint8_t get_data_register();
|
||||||
|
@@ -223,7 +223,7 @@ void VideoOutput::output_pixels(unsigned int number_of_cycles) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoOutput::run_for(const Cycles &cycles) {
|
void VideoOutput::run_for(const Cycles cycles) {
|
||||||
int number_of_cycles = cycles.as_int();
|
int number_of_cycles = cycles.as_int();
|
||||||
output_position_ = (output_position_ + number_of_cycles) % cycles_per_frame;
|
output_position_ = (output_position_ + number_of_cycles) % cycles_per_frame;
|
||||||
while(number_of_cycles) {
|
while(number_of_cycles) {
|
||||||
|
@@ -34,7 +34,7 @@ class VideoOutput {
|
|||||||
std::shared_ptr<Outputs::CRT::CRT> get_crt();
|
std::shared_ptr<Outputs::CRT::CRT> get_crt();
|
||||||
|
|
||||||
/// Produces the next @c cycles of video output.
|
/// Produces the next @c cycles of video output.
|
||||||
void run_for(const Cycles &cycles);
|
void run_for(const Cycles cycles);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Writes @c value to the register at @c address. May mutate the results of @c get_next_interrupt,
|
Writes @c value to the register at @c address. May mutate the results of @c get_next_interrupt,
|
||||||
|
@@ -104,7 +104,7 @@ void Microdisc::set_head_load_request(bool head_load) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Microdisc::run_for(const Cycles &cycles) {
|
void Microdisc::run_for(const Cycles cycles) {
|
||||||
if(head_load_request_counter_ < head_load_request_counter_target) {
|
if(head_load_request_counter_ < head_load_request_counter_target) {
|
||||||
head_load_request_counter_ += cycles.as_int();
|
head_load_request_counter_ += cycles.as_int();
|
||||||
if(head_load_request_counter_ >= head_load_request_counter_target) set_head_loaded(true);
|
if(head_load_request_counter_ >= head_load_request_counter_target) set_head_loaded(true);
|
||||||
|
@@ -24,7 +24,7 @@ class Microdisc: public WD::WD1770 {
|
|||||||
|
|
||||||
bool get_interrupt_request_line();
|
bool get_interrupt_request_line();
|
||||||
|
|
||||||
void run_for(const Cycles &cycles);
|
void run_for(const Cycles cycles);
|
||||||
using WD::WD1770::run_for;
|
using WD::WD1770::run_for;
|
||||||
|
|
||||||
enum PagingFlags {
|
enum PagingFlags {
|
||||||
|
@@ -196,7 +196,7 @@ std::shared_ptr<Outputs::Speaker> Machine::get_speaker() {
|
|||||||
return via_.ay8910;
|
return via_.ay8910;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Machine::run_for(const Cycles &cycles) {
|
void Machine::run_for(const Cycles cycles) {
|
||||||
CPU::MOS6502::Processor<Machine>::run_for(cycles);
|
CPU::MOS6502::Processor<Machine>::run_for(cycles);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,7 +236,7 @@ void Machine::VIA::flush() {
|
|||||||
ay8910->flush();
|
ay8910->flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Machine::VIA::run_for(const Cycles &cycles) {
|
void Machine::VIA::run_for(const Cycles cycles) {
|
||||||
cycles_since_ay_update_ += cycles;
|
cycles_since_ay_update_ += cycles;
|
||||||
MOS::MOS6522<VIA>::run_for(cycles);
|
MOS::MOS6522<VIA>::run_for(cycles);
|
||||||
tape->run_for(cycles);
|
tape->run_for(cycles);
|
||||||
|
@@ -85,7 +85,7 @@ class Machine:
|
|||||||
virtual void close_output();
|
virtual void close_output();
|
||||||
virtual std::shared_ptr<Outputs::CRT::CRT> get_crt();
|
virtual std::shared_ptr<Outputs::CRT::CRT> get_crt();
|
||||||
virtual std::shared_ptr<Outputs::Speaker> get_speaker();
|
virtual std::shared_ptr<Outputs::Speaker> get_speaker();
|
||||||
virtual void run_for(const Cycles &cyclesß);
|
virtual void run_for(const Cycles 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);
|
||||||
@@ -143,7 +143,7 @@ class Machine:
|
|||||||
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(const Cycles &cycles);
|
inline void run_for(const Cycles cycles);
|
||||||
|
|
||||||
std::shared_ptr<GI::AY38910> ay8910;
|
std::shared_ptr<GI::AY38910> ay8910;
|
||||||
std::unique_ptr<TapePlayer> tape;
|
std::unique_ptr<TapePlayer> tape;
|
||||||
|
@@ -74,7 +74,7 @@ std::shared_ptr<Outputs::CRT::CRT> VideoOutput::get_crt() {
|
|||||||
return crt_;
|
return crt_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoOutput::run_for(const Cycles &cycles) {
|
void VideoOutput::run_for(const Cycles cycles) {
|
||||||
// Vertical: 0–39: pixels; otherwise blank; 48–53 sync, 54–56 colour burst
|
// Vertical: 0–39: pixels; otherwise blank; 48–53 sync, 54–56 colour burst
|
||||||
// Horizontal: 0–223: pixels; otherwise blank; 256–259 sync
|
// Horizontal: 0–223: pixels; otherwise blank; 256–259 sync
|
||||||
|
|
||||||
|
@@ -18,7 +18,7 @@ class VideoOutput {
|
|||||||
public:
|
public:
|
||||||
VideoOutput(uint8_t *memory);
|
VideoOutput(uint8_t *memory);
|
||||||
std::shared_ptr<Outputs::CRT::CRT> get_crt();
|
std::shared_ptr<Outputs::CRT::CRT> get_crt();
|
||||||
void run_for(const Cycles &cycles);
|
void run_for(const Cycles cycles);
|
||||||
void set_colour_rom(const std::vector<uint8_t> &rom);
|
void set_colour_rom(const std::vector<uint8_t> &rom);
|
||||||
void set_output_device(Outputs::CRT::OutputDevice output_device);
|
void set_output_device(Outputs::CRT::OutputDevice output_device);
|
||||||
|
|
||||||
|
@@ -18,7 +18,7 @@ Typer::Typer(const char *string, HalfCycles delay, HalfCycles frequency, Delegat
|
|||||||
snprintf(string_, string_size, "%c%s%c", Typer::BeginString, string, Typer::EndString);
|
snprintf(string_, string_size, "%c%s%c", Typer::BeginString, string, Typer::EndString);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Typer::run_for(HalfCycles duration) {
|
void Typer::run_for(const HalfCycles duration) {
|
||||||
if(string_) {
|
if(string_) {
|
||||||
if(counter_ < 0 && counter_ + duration >= 0) {
|
if(counter_ < 0 && counter_ + duration >= 0) {
|
||||||
if(!type_next_character()) {
|
if(!type_next_character()) {
|
||||||
|
@@ -33,7 +33,7 @@ class Typer {
|
|||||||
|
|
||||||
Typer(const char *string, HalfCycles delay, HalfCycles frequency, Delegate *delegate);
|
Typer(const char *string, HalfCycles delay, HalfCycles frequency, Delegate *delegate);
|
||||||
~Typer();
|
~Typer();
|
||||||
void run_for(HalfCycles duration);
|
void run_for(const HalfCycles duration);
|
||||||
bool type_next_character();
|
bool type_next_character();
|
||||||
|
|
||||||
const char BeginString = 0x02; // i.e. ASCII start of text
|
const char BeginString = 0x02; // i.e. ASCII start of text
|
||||||
|
@@ -29,7 +29,7 @@ Video::Video() :
|
|||||||
crt_->set_visible_area(Outputs::CRT::Rect(0.1f, 0.1f, 0.8f, 0.8f));
|
crt_->set_visible_area(Outputs::CRT::Rect(0.1f, 0.1f, 0.8f, 0.8f));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Video::run_for(const HalfCycles &half_cycles) {
|
void Video::run_for(const HalfCycles half_cycles) {
|
||||||
// Just keep a running total of the amount of time that remains owed to the CRT.
|
// Just keep a running total of the amount of time that remains owed to the CRT.
|
||||||
cycles_since_update_ += (unsigned int)half_cycles.as_int();
|
cycles_since_update_ += (unsigned int)half_cycles.as_int();
|
||||||
}
|
}
|
||||||
|
@@ -32,7 +32,7 @@ class Video {
|
|||||||
std::shared_ptr<Outputs::CRT::CRT> get_crt();
|
std::shared_ptr<Outputs::CRT::CRT> get_crt();
|
||||||
|
|
||||||
/// Advances time by @c cycles.
|
/// Advances time by @c cycles.
|
||||||
void run_for(const HalfCycles &);
|
void run_for(const HalfCycles);
|
||||||
/// Forces output to catch up to the current output position.
|
/// Forces output to catch up to the current output position.
|
||||||
void flush();
|
void flush();
|
||||||
|
|
||||||
|
@@ -208,7 +208,7 @@ std::shared_ptr<Outputs::Speaker> Machine::get_speaker() {
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Machine::run_for(const Cycles &cycles) {
|
void Machine::run_for(const Cycles cycles) {
|
||||||
CPU::Z80::Processor<Machine>::run_for(cycles);
|
CPU::Z80::Processor<Machine>::run_for(cycles);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -56,7 +56,7 @@ class Machine:
|
|||||||
std::shared_ptr<Outputs::CRT::CRT> get_crt();
|
std::shared_ptr<Outputs::CRT::CRT> get_crt();
|
||||||
std::shared_ptr<Outputs::Speaker> get_speaker();
|
std::shared_ptr<Outputs::Speaker> get_speaker();
|
||||||
|
|
||||||
void run_for(const Cycles &cycles);
|
void run_for(const Cycles cycles);
|
||||||
|
|
||||||
void configure_as_target(const StaticAnalyser::Target &target);
|
void configure_as_target(const StaticAnalyser::Target &target);
|
||||||
|
|
||||||
|
@@ -141,7 +141,7 @@ template <class T> class Filter: public Speaker {
|
|||||||
_queue->flush();
|
_queue->flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
void run_for(const Cycles &cycles) {
|
void run_for(const Cycles cycles) {
|
||||||
enqueue([=]() {
|
enqueue([=]() {
|
||||||
unsigned int cycles_remaining = (unsigned int)cycles.as_int();
|
unsigned int cycles_remaining = (unsigned int)cycles.as_int();
|
||||||
if(coefficients_are_dirty_) update_filter_coefficients();
|
if(coefficients_are_dirty_) update_filter_coefficients();
|
||||||
|
@@ -292,7 +292,7 @@ template <class T> class Processor: public ProcessorBase {
|
|||||||
|
|
||||||
@param cycles The number of cycles to run the 6502 for.
|
@param cycles The number of cycles to run the 6502 for.
|
||||||
*/
|
*/
|
||||||
void run_for(const Cycles &cycles) {
|
void run_for(const Cycles cycles) {
|
||||||
static const MicroOp doBranch[] = {
|
static const MicroOp doBranch[] = {
|
||||||
CycleReadFromPC,
|
CycleReadFromPC,
|
||||||
CycleAddSignedOperandToPC,
|
CycleAddSignedOperandToPC,
|
||||||
|
@@ -36,7 +36,7 @@ class ConcreteAllRAMProcessor: public AllRAMProcessor, public Processor<Concrete
|
|||||||
return Cycles(1);
|
return Cycles(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void run_for(const Cycles &cycles) {
|
void run_for(const Cycles cycles) {
|
||||||
Processor<ConcreteAllRAMProcessor>::run_for(cycles);
|
Processor<ConcreteAllRAMProcessor>::run_for(cycles);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -22,7 +22,7 @@ class AllRAMProcessor:
|
|||||||
static AllRAMProcessor *Processor();
|
static AllRAMProcessor *Processor();
|
||||||
virtual ~AllRAMProcessor() {}
|
virtual ~AllRAMProcessor() {}
|
||||||
|
|
||||||
virtual void run_for(const Cycles &cycles) = 0;
|
virtual void run_for(const Cycles cycles) = 0;
|
||||||
virtual bool is_jammed() = 0;
|
virtual bool is_jammed() = 0;
|
||||||
virtual void set_irq_line(bool value) = 0;
|
virtual void set_irq_line(bool value) = 0;
|
||||||
virtual void set_nmi_line(bool value) = 0;
|
virtual void set_nmi_line(bool value) = 0;
|
||||||
|
@@ -872,7 +872,7 @@ template <class T> class Processor {
|
|||||||
|
|
||||||
@param cycles The number of cycles to run for.
|
@param cycles The number of cycles to run for.
|
||||||
*/
|
*/
|
||||||
void run_for(const HalfCycles &cycles) {
|
void run_for(const HalfCycles cycles) {
|
||||||
|
|
||||||
#define advance_operation() \
|
#define advance_operation() \
|
||||||
pc_increment_ = 1; \
|
pc_increment_ = 1; \
|
||||||
|
@@ -63,7 +63,7 @@ class ConcreteAllRAMProcessor: public AllRAMProcessor, public Processor<Concrete
|
|||||||
return HalfCycles(0);
|
return HalfCycles(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void run_for(const Cycles &cycles) {
|
void run_for(const Cycles cycles) {
|
||||||
CPU::Z80::Processor<ConcreteAllRAMProcessor>::run_for(cycles);
|
CPU::Z80::Processor<ConcreteAllRAMProcessor>::run_for(cycles);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -28,7 +28,7 @@ class AllRAMProcessor:
|
|||||||
delegate_ = delegate;
|
delegate_ = delegate;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void run_for(const Cycles &cycles) = 0;
|
virtual void run_for(const Cycles cycles) = 0;
|
||||||
virtual uint16_t get_value_of_register(Register r) = 0;
|
virtual uint16_t get_value_of_register(Register r) = 0;
|
||||||
virtual void set_value_of_register(Register r, uint16_t value) = 0;
|
virtual void set_value_of_register(Register r, uint16_t value) = 0;
|
||||||
virtual bool get_halt_line() = 0;
|
virtual bool get_halt_line() = 0;
|
||||||
|
@@ -20,7 +20,7 @@ DigitalPhaseLockedLoop::DigitalPhaseLockedLoop(int clocks_per_bit, size_t length
|
|||||||
offset_history_(length_of_history, 0),
|
offset_history_(length_of_history, 0),
|
||||||
offset_(0) {}
|
offset_(0) {}
|
||||||
|
|
||||||
void DigitalPhaseLockedLoop::run_for(const Cycles &cycles) {
|
void DigitalPhaseLockedLoop::run_for(const Cycles cycles) {
|
||||||
offset_ += cycles.as_int();
|
offset_ += cycles.as_int();
|
||||||
phase_ += cycles.as_int();
|
phase_ += cycles.as_int();
|
||||||
if(phase_ >= window_length_) {
|
if(phase_ >= window_length_) {
|
||||||
|
@@ -31,7 +31,7 @@ class DigitalPhaseLockedLoop {
|
|||||||
|
|
||||||
@c number_of_cycles The time to run the loop for.
|
@c number_of_cycles The time to run the loop for.
|
||||||
*/
|
*/
|
||||||
void run_for(const Cycles &cycles);
|
void run_for(const Cycles cycles);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Announces a pulse at the current time.
|
Announces a pulse at the current time.
|
||||||
|
@@ -40,7 +40,7 @@ void Controller::setup_track() {
|
|||||||
get_next_event(offset);
|
get_next_event(offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller::run_for(const Cycles &cycles) {
|
void Controller::run_for(const Cycles cycles) {
|
||||||
Time zero(0);
|
Time zero(0);
|
||||||
|
|
||||||
if(drive_ && drive_->has_disk() && motor_is_on_) {
|
if(drive_ && drive_->has_disk() && motor_is_on_) {
|
||||||
|
@@ -43,7 +43,7 @@ class Controller: public DigitalPhaseLockedLoop::Delegate, public TimedEventLoop
|
|||||||
/*!
|
/*!
|
||||||
Advances the drive by @c number_of_cycles cycles.
|
Advances the drive by @c number_of_cycles cycles.
|
||||||
*/
|
*/
|
||||||
void run_for(const Cycles &cycles);
|
void run_for(const Cycles cycles);
|
||||||
using TimedEventLoop::run_for;
|
using TimedEventLoop::run_for;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@@ -92,7 +92,7 @@ void TapePlayer::get_next_pulse() {
|
|||||||
set_next_event_time_interval(current_pulse_.length);
|
set_next_event_time_interval(current_pulse_.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TapePlayer::run_for(const Cycles &cycles) {
|
void TapePlayer::run_for(const Cycles cycles) {
|
||||||
if(has_tape()) {
|
if(has_tape()) {
|
||||||
TimedEventLoop::run_for(cycles);
|
TimedEventLoop::run_for(cycles);
|
||||||
}
|
}
|
||||||
@@ -125,7 +125,7 @@ bool BinaryTapePlayer::get_input() {
|
|||||||
return motor_is_running_ && input_level_;
|
return motor_is_running_ && input_level_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BinaryTapePlayer::run_for(const Cycles &cycles) {
|
void BinaryTapePlayer::run_for(const Cycles cycles) {
|
||||||
if(motor_is_running_) TapePlayer::run_for(cycles);
|
if(motor_is_running_) TapePlayer::run_for(cycles);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -101,7 +101,7 @@ class TapePlayer: public TimedEventLoop {
|
|||||||
bool has_tape();
|
bool has_tape();
|
||||||
std::shared_ptr<Storage::Tape::Tape> get_tape();
|
std::shared_ptr<Storage::Tape::Tape> get_tape();
|
||||||
|
|
||||||
void run_for(const Cycles &cycles);
|
void run_for(const Cycles cycles);
|
||||||
|
|
||||||
void run_for_input_pulse();
|
void run_for_input_pulse();
|
||||||
|
|
||||||
@@ -131,7 +131,7 @@ class BinaryTapePlayer: public TapePlayer {
|
|||||||
void set_tape_output(bool set);
|
void set_tape_output(bool set);
|
||||||
bool get_input();
|
bool get_input();
|
||||||
|
|
||||||
void run_for(const Cycles &cycles);
|
void run_for(const Cycles cycles);
|
||||||
|
|
||||||
class Delegate {
|
class Delegate {
|
||||||
public:
|
public:
|
||||||
|
@@ -15,7 +15,7 @@ using namespace Storage;
|
|||||||
TimedEventLoop::TimedEventLoop(unsigned int input_clock_rate) :
|
TimedEventLoop::TimedEventLoop(unsigned int input_clock_rate) :
|
||||||
input_clock_rate_(input_clock_rate) {}
|
input_clock_rate_(input_clock_rate) {}
|
||||||
|
|
||||||
void TimedEventLoop::run_for(const Cycles &cycles) {
|
void TimedEventLoop::run_for(const Cycles cycles) {
|
||||||
cycles_until_event_ -= cycles.as_int();
|
cycles_until_event_ -= cycles.as_int();
|
||||||
while(cycles_until_event_ <= 0) {
|
while(cycles_until_event_ <= 0) {
|
||||||
process_next_event();
|
process_next_event();
|
||||||
|
@@ -47,7 +47,7 @@ namespace Storage {
|
|||||||
/*!
|
/*!
|
||||||
Advances the event loop by @c number_of_cycles cycles.
|
Advances the event loop by @c number_of_cycles cycles.
|
||||||
*/
|
*/
|
||||||
void run_for(const Cycles &cycles);
|
void run_for(const Cycles cycles);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@returns the number of whole cycles remaining until the next event is triggered.
|
@returns the number of whole cycles remaining until the next event is triggered.
|
||||||
|
Reference in New Issue
Block a user