diff --git a/Analyser/Static/StaticAnalyser.cpp b/Analyser/Static/StaticAnalyser.cpp index daae232ba..00794c325 100644 --- a/Analyser/Static/StaticAnalyser.cpp +++ b/Analyser/Static/StaticAnalyser.cpp @@ -88,7 +88,7 @@ static Media GetMediaAndPlatforms(const char *file_name, TargetPlatform::IntType Format("81", result.tapes, Tape::ZX80O81P, TargetPlatform::ZX8081) // 81 Format("a26", result.cartridges, Cartridge::BinaryDump, TargetPlatform::Atari2600) // A26 Format("adf", result.disks, Disk::DiskImageHolder, TargetPlatform::Acorn) // ADF - Format("bin", result.cartridges, Cartridge::BinaryDump, TargetPlatform::Atari2600) // BIN + Format("bin", result.cartridges, Cartridge::BinaryDump, TargetPlatform::AllCartridge) // BIN Format("cas", result.tapes, Tape::CAS, TargetPlatform::MSX) // CAS Format("cdt", result.tapes, Tape::TZX, TargetPlatform::AmstradCPC) // CDT Format("col", result.cartridges, Cartridge::BinaryDump, TargetPlatform::ColecoVision) // COL @@ -117,10 +117,7 @@ static Media GetMediaAndPlatforms(const char *file_name, TargetPlatform::IntType } } - Format( "rom", - result.cartridges, - Cartridge::BinaryDump, - TargetPlatform::Acorn | TargetPlatform::MSX | TargetPlatform::ColecoVision) // ROM + Format("rom", result.cartridges, Cartridge::BinaryDump, TargetPlatform::AllCartridge) // ROM Format("ssd", result.disks, Disk::DiskImageHolder, TargetPlatform::Acorn) // SSD Format("tap", result.tapes, Tape::CommodoreTAP, TargetPlatform::Commodore) // TAP (Commodore) Format("tap", result.tapes, Tape::OricTAP, TargetPlatform::Oric) // TAP (Oric) diff --git a/Machines/Atari2600/Atari2600.cpp b/Machines/Atari2600/Atari2600.cpp index 70aa8753d..f9be6a8fc 100644 --- a/Machines/Atari2600/Atari2600.cpp +++ b/Machines/Atari2600/Atari2600.cpp @@ -74,9 +74,7 @@ class ConcreteMachine: public Machine, public Outputs::CRT::Delegate { public: - ConcreteMachine() : - frame_record_pointer_(0), - is_ntsc_(true) { + ConcreteMachine() { set_clock_rate(NTSC_clock_rate); } @@ -179,6 +177,7 @@ class ConcreteMachine: void run_for(const Cycles cycles) override { bus_->run_for(cycles); + bus_->apply_confidence(confidence_counter_); } // to satisfy Outputs::CRT::Delegate @@ -219,6 +218,10 @@ class ConcreteMachine: } } + float get_confidence() override { + return confidence_counter_.get_confidence(); + } + private: // the bus std::unique_ptr bus_; @@ -230,9 +233,12 @@ class ConcreteMachine: FrameRecord() : number_of_frames(0), number_of_unexpected_vertical_syncs(0) {} } frame_records_[4]; - unsigned int frame_record_pointer_; - bool is_ntsc_; + unsigned int frame_record_pointer_ = 0; + bool is_ntsc_ = true; std::vector> joysticks_; + + // a confidence counter + Analyser::Dynamic::ConfidenceCounter confidence_counter_; }; } diff --git a/Machines/Atari2600/Bus.hpp b/Machines/Atari2600/Bus.hpp index ffd63b64e..79d9dfbd4 100644 --- a/Machines/Atari2600/Bus.hpp +++ b/Machines/Atari2600/Bus.hpp @@ -14,6 +14,7 @@ #include "TIA.hpp" #include "TIASound.hpp" +#include "../../Analyser/Dynamic/ConfidenceCounter.hpp" #include "../../ClockReceiver/ClockReceiver.hpp" #include "../../Outputs/Speaker/Implementation/LowpassSpeaker.hpp" @@ -23,11 +24,10 @@ class Bus { public: Bus() : tia_sound_(audio_queue_), - speaker_(tia_sound_), - tia_input_value_{0xff, 0xff}, - cycles_since_speaker_update_(0) {} + speaker_(tia_sound_) {} 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; // the RIOT, TIA and speaker @@ -39,7 +39,7 @@ class Bus { Outputs::Speaker::LowpassSpeaker speaker_; // joystick state - uint8_t tia_input_value_[2]; + uint8_t tia_input_value_[2] = {0xff, 0xff}; protected: // speaker backlog accumlation counter diff --git a/Machines/Atari2600/Cartridges/Cartridge.hpp b/Machines/Atari2600/Cartridges/Cartridge.hpp index 1aa2fe0e5..44ee90109 100644 --- a/Machines/Atari2600/Cartridges/Cartridge.hpp +++ b/Machines/Atari2600/Cartridges/Cartridge.hpp @@ -39,7 +39,23 @@ template class Cartridge: // consider doing something less fragile. } - void run_for(const Cycles cycles) { m6502_.run_for(cycles); } + void run_for(const Cycles cycles) { + // 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; + cycle_count_ = cycles; + m6502_.run_for(cycles); + } + + /*! + Adjusts @c confidence_counter according to the results of the most recent run_for. + */ + void apply_confidence(Analyser::Dynamic::ConfidenceCounter &confidence_counter) { + if(cycle_count_.as_int() < 200) return; + if(horizontal_counter_resets_ > 10) + confidence_counter.add_miss(); + } + void set_reset_line(bool state) { m6502_.set_reset_line(state); } // to satisfy CPU::MOS6502::Processor @@ -108,7 +124,11 @@ template class Cartridge: case 0x01: update_video(); tia_->set_blank(*value & 0x02); break; case 0x02: m6502_.set_ready_line(true); break; - case 0x03: update_video(); tia_->reset_horizontal_counter(); break; + case 0x03: + update_video(); + tia_->reset_horizontal_counter(); + horizontal_counter_resets_++; + break; // TODO: audio will now be out of synchronisation — fix case 0x04: @@ -189,6 +209,9 @@ template class Cartridge: private: T bus_extender_; + int horizontal_counter_resets_ = 0; + Cycles cycle_count_; + }; } diff --git a/Storage/TargetPlatforms.hpp b/Storage/TargetPlatforms.hpp index b6b222cc8..b0a2ef317 100644 --- a/Storage/TargetPlatforms.hpp +++ b/Storage/TargetPlatforms.hpp @@ -29,8 +29,9 @@ enum Type: IntType { Acorn = AcornAtom | AcornElectron | BBCMaster | BBCModelA | BBCModelB, ZX8081 = ZX80 | ZX81, - AllTape = Acorn | AmstradCPC | Commodore | Oric | ZX80 | ZX81 | MSX, + AllCartridge = Atari2600 | AcornElectron | ColecoVision | MSX, AllDisk = Acorn | AmstradCPC | Commodore | Oric | MSX, + AllTape = Acorn | AmstradCPC | Commodore | Oric | ZX80 | ZX81 | MSX, }; class TypeDistinguisher {