1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-01-26 15:32:04 +00:00

Causes the Atari 2600 to obey normal flush semantics.

This stuff is going to become more important with run_until.
This commit is contained in:
Thomas Harte 2020-01-22 22:05:51 -05:00
parent a5f285b4ce
commit 8404409c0d
3 changed files with 10 additions and 4 deletions

View File

@ -174,6 +174,10 @@ class ConcreteMachine:
bus_->apply_confidence(confidence_counter_);
}
void flush() {
bus_->flush();
}
// to satisfy Outputs::CRT::Delegate
void crt_did_end_batch_of_frames(Outputs::CRT::CRT *crt, int number_of_frames, int number_of_unexpected_vertical_syncs) override {
const std::size_t number_of_frame_records = sizeof(frame_records_) / sizeof(frame_records_[0]);

View File

@ -33,6 +33,7 @@ class Bus {
virtual void run_for(const Cycles cycles) = 0;
virtual void apply_confidence(Analyser::Dynamic::ConfidenceCounter &confidence_counter) = 0;
virtual void set_reset_line(bool state) = 0;
virtual void flush() = 0;
// the RIOT, TIA and speaker
PIA mos6532_;

View File

@ -39,7 +39,7 @@ template<class T> class Cartridge:
// consider doing something less fragile.
}
void run_for(const Cycles cycles) {
void run_for(const Cycles cycles) override {
// Horizontal counter resets are used as a proxy for whether this really is an Atari 2600
// title. Random memory accesses are likely to trigger random counter resets.
horizontal_counter_resets_ = 0;
@ -50,13 +50,13 @@ template<class T> class Cartridge:
/*!
Adjusts @c confidence_counter according to the results of the most recent run_for.
*/
void apply_confidence(Analyser::Dynamic::ConfidenceCounter &confidence_counter) {
void apply_confidence(Analyser::Dynamic::ConfidenceCounter &confidence_counter) override {
if(cycle_count_.as_integral() < 200) return;
if(horizontal_counter_resets_ > 10)
confidence_counter.add_miss();
}
void set_reset_line(bool state) { m6502_.set_reset_line(state); }
void set_reset_line(bool state) override { m6502_.set_reset_line(state); }
// to satisfy CPU::MOS6502::Processor
Cycles perform_bus_operation(CPU::MOS6502::BusOperation operation, uint16_t address, uint8_t *value) {
@ -197,10 +197,11 @@ template<class T> class Cartridge:
return Cycles(cycles_run_for / 3);
}
void flush() {
void flush() override {
update_audio();
update_video();
audio_queue_.perform();
audio_queue_.flush();
}
protected: