2015-07-16 23:56:02 +00:00
|
|
|
//
|
|
|
|
// Atari2600.hpp
|
2015-07-26 19:25:11 +00:00
|
|
|
// CLK
|
2015-07-16 23:56:02 +00:00
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 14/07/2015.
|
|
|
|
// Copyright © 2015 Thomas Harte. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef Atari2600_cpp
|
|
|
|
#define Atari2600_cpp
|
|
|
|
|
2016-06-19 22:57:40 +00:00
|
|
|
#include <stdint.h>
|
|
|
|
|
2016-01-05 04:12:47 +00:00
|
|
|
#include "../../Processors/6502/CPU6502.hpp"
|
2016-06-01 01:23:44 +00:00
|
|
|
#include "../CRTMachine.hpp"
|
2017-03-19 01:01:58 +00:00
|
|
|
#include "Bus.hpp"
|
2016-12-03 18:41:55 +00:00
|
|
|
#include "PIA.hpp"
|
2016-12-03 18:39:46 +00:00
|
|
|
#include "Speaker.hpp"
|
2017-01-29 02:46:40 +00:00
|
|
|
#include "TIA.hpp"
|
2016-06-19 22:57:40 +00:00
|
|
|
|
2016-09-15 23:34:45 +00:00
|
|
|
#include "../ConfigurationTarget.hpp"
|
2015-08-19 00:33:24 +00:00
|
|
|
#include "Atari2600Inputs.h"
|
2015-07-16 23:56:02 +00:00
|
|
|
|
|
|
|
namespace Atari2600 {
|
|
|
|
|
2016-06-03 01:22:55 +00:00
|
|
|
const unsigned int number_of_upcoming_events = 6;
|
2016-05-27 18:33:08 +00:00
|
|
|
const unsigned int number_of_recorded_counters = 7;
|
2016-05-17 11:09:18 +00:00
|
|
|
|
2016-09-15 23:34:45 +00:00
|
|
|
class Machine:
|
|
|
|
public CRTMachine::Machine,
|
2017-02-20 02:20:37 +00:00
|
|
|
public ConfigurationTarget::Machine,
|
|
|
|
public Outputs::CRT::Delegate {
|
2015-07-16 23:56:02 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
Machine();
|
2015-07-28 01:15:10 +00:00
|
|
|
~Machine();
|
2015-07-16 23:56:02 +00:00
|
|
|
|
2016-09-15 23:34:45 +00:00
|
|
|
void configure_as_target(const StaticAnalyser::Target &target);
|
2015-07-31 22:04:33 +00:00
|
|
|
void switch_region();
|
2015-07-16 23:56:02 +00:00
|
|
|
|
2015-08-19 00:33:24 +00:00
|
|
|
void set_digital_input(Atari2600DigitalInput input, bool state);
|
2016-06-19 23:36:34 +00:00
|
|
|
void set_switch_is_enabled(Atari2600Switch input, bool state);
|
2017-03-18 20:34:41 +00:00
|
|
|
void set_reset_line(bool state) { bus_->set_reset_line(state); }
|
2016-06-01 01:23:44 +00:00
|
|
|
|
|
|
|
// to satisfy CRTMachine::Machine
|
|
|
|
virtual void setup_output(float aspect_ratio);
|
|
|
|
virtual void close_output();
|
2017-03-18 18:01:04 +00:00
|
|
|
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 void run_for_cycles(int number_of_cycles) { bus_->run_for_cycles(number_of_cycles); }
|
2015-07-22 22:15:18 +00:00
|
|
|
|
2017-02-20 02:20:37 +00:00
|
|
|
// 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);
|
|
|
|
|
2015-07-16 23:56:02 +00:00
|
|
|
private:
|
2017-03-18 23:02:34 +00:00
|
|
|
// the bus
|
2017-03-18 18:01:04 +00:00
|
|
|
std::unique_ptr<Bus> bus_;
|
2017-02-20 02:20:37 +00:00
|
|
|
|
|
|
|
// output frame rate tracker
|
|
|
|
struct FrameRecord
|
|
|
|
{
|
|
|
|
unsigned int number_of_frames;
|
|
|
|
unsigned int number_of_unexpected_vertical_syncs;
|
|
|
|
|
|
|
|
FrameRecord() : number_of_frames(0), number_of_unexpected_vertical_syncs(0) {}
|
|
|
|
} frame_records_[4];
|
|
|
|
unsigned int frame_record_pointer_;
|
|
|
|
bool is_ntsc_;
|
2015-07-16 23:56:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* Atari2600_cpp */
|