1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-06-25 18:30:07 +00:00

Formally transferred ownership of PIO accesses to an incoming template, and decided to start being explicit about how to specify the interfaces and provide fallbacks for optional behaviour for the new, clean generation of interfaces. A full-project sweep will inevitably occur but I'll try to tie off this branch first.

This commit is contained in:
Thomas Harte 2017-08-01 16:15:19 -04:00
parent ace71280a0
commit 58b98267fc
4 changed files with 70 additions and 12 deletions

View File

@ -26,6 +26,11 @@ struct BusState {
uint16_t row_address;
};
class BusHandler {
public:
void perform_bus_cycle(const BusState &) {}
};
template <class T> class CRTC6845 {
public:
CRTC6845(T &bus_handler) : bus_handler_(bus_handler) {}

43
Components/8255/i8255.hpp Normal file
View File

@ -0,0 +1,43 @@
//
// i8255.hpp
// Clock Signal
//
// Created by Thomas Harte on 01/08/2017.
// Copyright © 2017 Thomas Harte. All rights reserved.
//
#ifndef i8255_hpp
#define i8255_hpp
namespace Intel {
namespace i8255 {
class PortHandler {
};
template <class T> class i8255 {
public:
void set_register(int address, uint8_t value) {
switch((address >> 8) & 3) {
case 0: printf("PSG data: %d\n", value); break;
case 1: printf("Vsync, etc: %02x\n", value); break;
case 2: printf("Key row, etc: %02x\n", value); break;
case 3: printf("PIO control: %02x\n", value); break;
}
}
uint8_t get_register(int address) {
switch((address >> 8) & 3) {
case 0: printf("[In] PSG data\n"); break;
case 1: printf("[In] Vsync, etc\n"); break;
case 2: printf("[In] Key row, etc\n"); break;
case 3: printf("[In] PIO control\n"); break;
}
return 0xff;
}
};
}
}
#endif /* i8255_hpp */

View File

@ -9,6 +9,8 @@
#include "AmstradCPC.hpp"
#include "../../Processors/Z80/Z80.hpp"
#include "../../Components/8255/i8255.hpp"
#include "../../Components/AY38910/AY38910.hpp"
#include "../../Components/6845/CRTC6845.hpp"
@ -247,6 +249,9 @@ struct CRTCBusHandler {
int interrupt_reset_counter_;
};
struct i8255PortHandler : public Intel::i8255::PortHandler {
};
class ConcreteMachine:
public CPU::Z80::Processor<ConcreteMachine>,
public Machine {
@ -314,12 +319,7 @@ class ConcreteMachine:
// Check for a PIO access
if(!(address & 0x800)) {
switch((address >> 8) & 3) {
case 0: printf("PSG data: %d\n", *cycle.value); break;
case 1: printf("Vsync, etc: %02x\n", *cycle.value); break;
case 2: printf("Key row, etc: %02x\n", *cycle.value); break;
case 3: printf("PIO control: %02x\n", *cycle.value); break;
}
i8255_.set_register((address >> 8) & 3, *cycle.value);
}
break;
case CPU::Z80::PartialMachineCycle::Input:
@ -334,12 +334,7 @@ class ConcreteMachine:
// Check for a PIO access
if(!(address & 0x800)) {
switch((address >> 8) & 3) {
case 0: printf("[In] PSG data\n"); break;
case 1: printf("[In] Vsync, etc\n"); break;
case 2: printf("[In] Key row, etc\n"); break;
case 3: printf("[In] PIO control\n"); break;
}
*cycle.value = i8255_.get_register((address >> 8) & 3);
}
*cycle.value = 0xff;
@ -404,6 +399,9 @@ class ConcreteMachine:
CRTCBusHandler crtc_bus_handler_;
Motorola::CRTC::CRTC6845<CRTCBusHandler> crtc_;
i8255PortHandler i8255_port_handler_;
Intel::i8255::i8255<i8255PortHandler> i8255_;
HalfCycles clock_offset_;
HalfCycles crtc_counter_;

View File

@ -421,6 +421,7 @@
4BD4A8D01E077FD20020D856 /* PCMTrackTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4BD4A8CF1E077FD20020D856 /* PCMTrackTests.mm */; };
4BD5F1951D13528900631CD1 /* CSBestEffortUpdater.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BD5F1941D13528900631CD1 /* CSBestEffortUpdater.m */; };
4BD69F941D98760000243FE1 /* AcornADF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BD69F921D98760000243FE1 /* AcornADF.cpp */; };
4BD9137B1F3115A8009BCF85 /* i8255.hpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BD913791F3115A8009BCF85 /* i8255.hpp */; };
4BDDBA991EF3451200347E61 /* Z80MachineCycleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BDDBA981EF3451200347E61 /* Z80MachineCycleTests.swift */; };
4BE77A2E1D84ADFB00BC3827 /* File.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BE77A2C1D84ADFB00BC3827 /* File.cpp */; };
4BE7C9181E3D397100A5496D /* TIA.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BE7C9161E3D397100A5496D /* TIA.cpp */; };
@ -996,6 +997,7 @@
4BD5F1941D13528900631CD1 /* CSBestEffortUpdater.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CSBestEffortUpdater.m; path = Updater/CSBestEffortUpdater.m; sourceTree = "<group>"; };
4BD69F921D98760000243FE1 /* AcornADF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AcornADF.cpp; sourceTree = "<group>"; };
4BD69F931D98760000243FE1 /* AcornADF.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = AcornADF.hpp; sourceTree = "<group>"; };
4BD913791F3115A8009BCF85 /* i8255.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = i8255.hpp; path = 8255/i8255.hpp; sourceTree = "<group>"; };
4BDDBA981EF3451200347E61 /* Z80MachineCycleTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Z80MachineCycleTests.swift; sourceTree = "<group>"; };
4BE77A2C1D84ADFB00BC3827 /* File.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = File.cpp; path = ../../StaticAnalyser/Commodore/File.cpp; sourceTree = "<group>"; };
4BE77A2D1D84ADFB00BC3827 /* File.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = File.hpp; path = ../../StaticAnalyser/Commodore/File.hpp; sourceTree = "<group>"; };
@ -2033,6 +2035,7 @@
4BC9DF4C1D04691600F44158 /* 6560 */,
4B4A762D1DB1A35C007AAE2E /* AY38910 */,
4BE845221F2FF7F400A5EA22 /* 6845 */,
4BD9137C1F3115AC009BCF85 /* 8255 */,
);
name = Components;
path = ../../Components;
@ -2121,6 +2124,14 @@
name = Updater;
sourceTree = "<group>";
};
4BD9137C1F3115AC009BCF85 /* 8255 */ = {
isa = PBXGroup;
children = (
4BD913791F3115A8009BCF85 /* i8255.hpp */,
);
name = 8255;
sourceTree = "<group>";
};
4BE5F85A1C3E1C2500C43F01 /* Resources */ = {
isa = PBXGroup;
children = (
@ -2673,6 +2684,7 @@
4B2A332A1DB8544D002876E3 /* MemoryFuzzer.cpp in Sources */,
4B55CE5F1C3B7D960093A61B /* MachineDocument.swift in Sources */,
4B2A332F1DB86869002876E3 /* OricOptionsPanel.swift in Sources */,
4BD9137B1F3115A8009BCF85 /* i8255.hpp in Sources */,
4B7913CC1DFCD80E00175A82 /* Video.cpp in Sources */,
4B2A53A11D117D36003C6002 /* CSAtari2600.mm in Sources */,
4BF829661D8F732B001BAE39 /* Disk.cpp in Sources */,