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"
|
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 CPU6502::Processor<Machine>,
|
|
|
|
public CRTMachine::Machine,
|
|
|
|
public ConfigurationTarget::Machine {
|
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);
|
2015-08-19 00:33:24 +00:00
|
|
|
|
2016-06-01 01:23:44 +00:00
|
|
|
// to satisfy CPU6502::Processor
|
|
|
|
unsigned int perform_bus_operation(CPU6502::BusOperation operation, uint16_t address, uint8_t *value);
|
2016-06-01 23:27:04 +00:00
|
|
|
void synchronise();
|
2016-06-01 01:23:44 +00:00
|
|
|
|
|
|
|
// to satisfy CRTMachine::Machine
|
|
|
|
virtual void setup_output(float aspect_ratio);
|
|
|
|
virtual void close_output();
|
2017-01-29 02:46:40 +00:00
|
|
|
virtual std::shared_ptr<Outputs::CRT::CRT> get_crt() { return tia_->get_crt(); }
|
2016-12-03 19:07:38 +00:00
|
|
|
virtual std::shared_ptr<Outputs::Speaker> get_speaker() { return speaker_; }
|
2016-06-01 01:23:44 +00:00
|
|
|
virtual void run_for_cycles(int number_of_cycles) { CPU6502::Processor<Machine>::run_for_cycles(number_of_cycles); }
|
2015-07-22 22:15:18 +00:00
|
|
|
|
2015-07-16 23:56:02 +00:00
|
|
|
private:
|
2016-12-03 19:07:38 +00:00
|
|
|
uint8_t *rom_, *rom_pages_[4];
|
|
|
|
size_t rom_size_;
|
2015-07-16 23:56:02 +00:00
|
|
|
|
2017-01-29 02:46:40 +00:00
|
|
|
// the RIOT and TIA
|
2016-12-03 19:07:38 +00:00
|
|
|
PIA mos6532_;
|
2017-01-29 02:46:40 +00:00
|
|
|
std::unique_ptr<TIA> tia_;
|
2016-05-17 22:21:49 +00:00
|
|
|
|
2015-08-19 00:33:24 +00:00
|
|
|
// joystick state
|
2016-12-03 19:07:38 +00:00
|
|
|
uint8_t tia_input_value_[2];
|
2015-08-19 00:33:24 +00:00
|
|
|
|
2016-06-01 23:27:04 +00:00
|
|
|
// outputs
|
2016-12-03 19:07:38 +00:00
|
|
|
std::shared_ptr<Speaker> speaker_;
|
2015-07-19 20:48:14 +00:00
|
|
|
|
2016-06-01 23:27:04 +00:00
|
|
|
// speaker backlog accumlation counter
|
2016-12-03 19:07:38 +00:00
|
|
|
unsigned int cycles_since_speaker_update_;
|
2016-06-01 23:27:04 +00:00
|
|
|
void update_audio();
|
|
|
|
|
2017-01-29 02:46:40 +00:00
|
|
|
// video backlog accumulation counter
|
|
|
|
unsigned int cycles_since_video_update_;
|
|
|
|
void update_video();
|
2015-07-16 23:56:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* Atari2600_cpp */
|