From b81c058c0a82d7735b4148f6169c13e263dd41d8 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sat, 3 Dec 2016 13:41:55 -0500 Subject: [PATCH] Factored out the Atari 2600's 6532 connection, as a low-hanging fruit. --- Machines/Atari2600/Atari2600.hpp | 24 +---------- Machines/Atari2600/PIA.hpp | 40 +++++++++++++++++++ .../Clock Signal.xcodeproj/project.pbxproj | 2 + 3 files changed, 43 insertions(+), 23 deletions(-) create mode 100644 Machines/Atari2600/PIA.hpp diff --git a/Machines/Atari2600/Atari2600.hpp b/Machines/Atari2600/Atari2600.hpp index c0a883e60..ad3ae4e01 100644 --- a/Machines/Atari2600/Atari2600.hpp +++ b/Machines/Atari2600/Atari2600.hpp @@ -12,8 +12,8 @@ #include #include "../../Processors/6502/CPU6502.hpp" -#include "../../Components/6532/6532.hpp" #include "../CRTMachine.hpp" +#include "PIA.hpp" #include "Speaker.hpp" #include "../ConfigurationTarget.hpp" @@ -24,28 +24,6 @@ namespace Atari2600 { const unsigned int number_of_upcoming_events = 6; const unsigned int number_of_recorded_counters = 7; -class PIA: public MOS::MOS6532 { - public: - inline uint8_t get_port_input(int port) - { - return port_values_[port]; - } - - inline void update_port_input(int port, uint8_t mask, bool set) - { - if(set) port_values_[port] &= ~mask; else port_values_[port] |= mask; - set_port_did_change(port); - } - - PIA() : - port_values_{0xff, 0xff} - {} - - private: - uint8_t port_values_[2]; - -}; - class Machine: public CPU6502::Processor, public CRTMachine::Machine, diff --git a/Machines/Atari2600/PIA.hpp b/Machines/Atari2600/PIA.hpp new file mode 100644 index 000000000..2faa80242 --- /dev/null +++ b/Machines/Atari2600/PIA.hpp @@ -0,0 +1,40 @@ +// +// PIA.h +// Clock Signal +// +// Created by Thomas Harte on 03/12/2016. +// Copyright © 2016 Thomas Harte. All rights reserved. +// + +#ifndef Atari2600_PIA_h +#define Atari2600_PIA_h + +#include "../../Components/6532/6532.hpp" + +namespace Atari2600 { + +class PIA: public MOS::MOS6532 { + public: + inline uint8_t get_port_input(int port) + { + return port_values_[port]; + } + + inline void update_port_input(int port, uint8_t mask, bool set) + { + if(set) port_values_[port] &= ~mask; else port_values_[port] |= mask; + set_port_did_change(port); + } + + PIA() : + port_values_{0xff, 0xff} + {} + + private: + uint8_t port_values_[2]; + +}; + +} + +#endif /* PIA_h */ diff --git a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj index acc5d7604..86fbb6bba 100644 --- a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj +++ b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj @@ -902,6 +902,7 @@ 4BEA52621DF339D7007E74F2 /* Speaker.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = Speaker.hpp; path = Electron/Speaker.hpp; sourceTree = ""; }; 4BEA52641DF3472B007E74F2 /* Speaker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Speaker.cpp; sourceTree = ""; }; 4BEA52651DF3472B007E74F2 /* Speaker.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Speaker.hpp; sourceTree = ""; }; + 4BEA52671DF34909007E74F2 /* PIA.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = PIA.hpp; sourceTree = ""; }; 4BEE0A6A1D72496600532C7B /* Cartridge.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Cartridge.cpp; sourceTree = ""; }; 4BEE0A6B1D72496600532C7B /* Cartridge.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Cartridge.hpp; sourceTree = ""; }; 4BEE0A6D1D72496600532C7B /* PRG.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PRG.cpp; sourceTree = ""; }; @@ -1056,6 +1057,7 @@ 4B2E2D991C3A06EC00138695 /* Atari2600Inputs.h */, 4B2E2D981C3A06EC00138695 /* Atari2600.hpp */, 4BEA52651DF3472B007E74F2 /* Speaker.hpp */, + 4BEA52671DF34909007E74F2 /* PIA.hpp */, ); path = Atari2600; sourceTree = "";