mirror of
https://github.com/TomHarte/CLK.git
synced 2024-12-25 18:30:21 +00:00
Created a 6845 class and started pushing data at it and clocking it. It doesn't currently have the concept of a bus but will do, hence the in-header implementation.
This commit is contained in:
parent
68dca9d047
commit
68ceeab610
12
Components/6845/CRTC6845.cpp
Normal file
12
Components/6845/CRTC6845.cpp
Normal file
@ -0,0 +1,12 @@
|
||||
//
|
||||
// CRTC6845.cpp
|
||||
// Clock Signal
|
||||
//
|
||||
// Created by Thomas Harte on 31/07/2017.
|
||||
// Copyright © 2017 Thomas Harte. All rights reserved.
|
||||
//
|
||||
|
||||
#include "CRTC6845.hpp"
|
||||
|
||||
using namespace Motorola;
|
||||
|
46
Components/6845/CRTC6845.hpp
Normal file
46
Components/6845/CRTC6845.hpp
Normal file
@ -0,0 +1,46 @@
|
||||
//
|
||||
// CRTC6845.hpp
|
||||
// Clock Signal
|
||||
//
|
||||
// Created by Thomas Harte on 31/07/2017.
|
||||
// Copyright © 2017 Thomas Harte. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef CRTC6845_hpp
|
||||
#define CRTC6845_hpp
|
||||
|
||||
#include "../../ClockReceiver/ClockReceiver.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace Motorola {
|
||||
|
||||
class CRTC6845 {
|
||||
public:
|
||||
void run_for(Cycles cycles) {
|
||||
}
|
||||
|
||||
void select_register(uint8_t r) {
|
||||
selected_register_ = (int)r & 15;
|
||||
}
|
||||
|
||||
uint8_t get_status() {
|
||||
return 0xff;
|
||||
}
|
||||
|
||||
uint8_t get_register() {
|
||||
return registers_[selected_register_];
|
||||
}
|
||||
|
||||
void set_register(uint8_t value) {
|
||||
registers_[selected_register_] = value;
|
||||
}
|
||||
|
||||
private:
|
||||
uint8_t registers_[16];
|
||||
int selected_register_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* CRTC6845_hpp */
|
@ -20,6 +20,15 @@ HalfCycles Machine::perform_machine_cycle(const CPU::Z80::PartialMachineCycle &c
|
||||
clock_offset_ = (clock_offset_ + cycle.length) & HalfCycles(7);
|
||||
set_wait_line(clock_offset_ >= HalfCycles(2));
|
||||
|
||||
// Update the CRTC on the final two cycles of the clock period;
|
||||
// this gives properly serialised memory accesses without having
|
||||
// to emulate a buffer.
|
||||
crtc_offset_ += cycle.length;
|
||||
while(crtc_offset_ >= HalfCycles(8)) {
|
||||
crtc_.run_for(Cycles(2));
|
||||
crtc_offset_ -= HalfCycles(8);
|
||||
}
|
||||
|
||||
// Stop now if no action is strictly required.
|
||||
if(!cycle.is_terminal()) return HalfCycles(0);
|
||||
|
||||
@ -52,8 +61,8 @@ HalfCycles Machine::perform_machine_cycle(const CPU::Z80::PartialMachineCycle &c
|
||||
// Check for a CRTC access
|
||||
if(!(address & 0x4000)) {
|
||||
switch((address >> 8) & 3) {
|
||||
case 0: printf("Select CRTC register %d\n", *cycle.value); break;
|
||||
case 1: printf("Set CRTC value %d\n", *cycle.value); break;
|
||||
case 0: crtc_.select_register(*cycle.value); break;
|
||||
case 1: crtc_.set_register(*cycle.value); break;
|
||||
case 2: case 3: printf("Illegal CRTC write?\n"); break;
|
||||
}
|
||||
}
|
||||
@ -73,8 +82,8 @@ HalfCycles Machine::perform_machine_cycle(const CPU::Z80::PartialMachineCycle &c
|
||||
if(!(address & 0x4000)) {
|
||||
switch((address >> 8) & 3) {
|
||||
case 0: case 1: printf("Illegal CRTC read?\n"); break;
|
||||
case 2: printf("CRTC status\n"); break;
|
||||
case 3: printf("CRTC data in\n"); break;
|
||||
case 2: *cycle.value = crtc_.get_status(); break;
|
||||
case 3: *cycle.value = crtc_.get_register(); break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
#include "../../Processors/Z80/Z80.hpp"
|
||||
#include "../../Components/AY38910/AY38910.hpp"
|
||||
#include "../../Components/6845/CRTC6845.hpp"
|
||||
|
||||
namespace AmstradCPC {
|
||||
|
||||
@ -47,7 +48,9 @@ class Machine:
|
||||
|
||||
private:
|
||||
std::shared_ptr<Outputs::CRT::CRT> crt_;
|
||||
Motorola::CRTC6845 crtc_;
|
||||
HalfCycles clock_offset_;
|
||||
HalfCycles crtc_offset_;
|
||||
|
||||
uint8_t ram_[65536];
|
||||
std::vector<uint8_t> os_, basic_;
|
||||
|
@ -424,6 +424,7 @@
|
||||
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 */; };
|
||||
4BE845211F2FF7F100A5EA22 /* CRTC6845.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BE8451F1F2FF7F100A5EA22 /* CRTC6845.cpp */; };
|
||||
4BE9A6B11EDE293000CBCB47 /* zexdoc.com in Resources */ = {isa = PBXBuildFile; fileRef = 4BE9A6B01EDE293000CBCB47 /* zexdoc.com */; };
|
||||
4BEA525E1DF33323007E74F2 /* Tape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BEA525D1DF33323007E74F2 /* Tape.cpp */; };
|
||||
4BEA52631DF339D7007E74F2 /* Speaker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BEA52611DF339D7007E74F2 /* Speaker.cpp */; };
|
||||
@ -1001,6 +1002,8 @@
|
||||
4BE77A2D1D84ADFB00BC3827 /* File.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = File.hpp; path = ../../StaticAnalyser/Commodore/File.hpp; sourceTree = "<group>"; };
|
||||
4BE7C9161E3D397100A5496D /* TIA.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TIA.cpp; sourceTree = "<group>"; };
|
||||
4BE7C9171E3D397100A5496D /* TIA.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = TIA.hpp; sourceTree = "<group>"; };
|
||||
4BE8451F1F2FF7F100A5EA22 /* CRTC6845.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CRTC6845.cpp; path = 6845/CRTC6845.cpp; sourceTree = "<group>"; };
|
||||
4BE845201F2FF7F100A5EA22 /* CRTC6845.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = CRTC6845.hpp; path = 6845/CRTC6845.hpp; sourceTree = "<group>"; };
|
||||
4BE9A6B01EDE293000CBCB47 /* zexdoc.com */ = {isa = PBXFileReference; lastKnownFileType = file; name = zexdoc.com; path = Zexall/zexdoc.com; sourceTree = "<group>"; };
|
||||
4BEA525D1DF33323007E74F2 /* Tape.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Tape.cpp; path = Electron/Tape.cpp; sourceTree = "<group>"; };
|
||||
4BEA525F1DF333D8007E74F2 /* Tape.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = Tape.hpp; path = Electron/Tape.hpp; sourceTree = "<group>"; };
|
||||
@ -2031,6 +2034,7 @@
|
||||
4B1E85791D174DEC001EF87D /* 6532 */,
|
||||
4BC9DF4C1D04691600F44158 /* 6560 */,
|
||||
4B4A762D1DB1A35C007AAE2E /* AY38910 */,
|
||||
4BE845221F2FF7F400A5EA22 /* 6845 */,
|
||||
);
|
||||
name = Components;
|
||||
path = ../../Components;
|
||||
@ -2128,6 +2132,15 @@
|
||||
path = Resources;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
4BE845221F2FF7F400A5EA22 /* 6845 */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
4BE8451F1F2FF7F100A5EA22 /* CRTC6845.cpp */,
|
||||
4BE845201F2FF7F100A5EA22 /* CRTC6845.hpp */,
|
||||
);
|
||||
name = 6845;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
4BE9A6B21EDE294200CBCB47 /* Zexall */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@ -2732,6 +2745,7 @@
|
||||
4B2A53A01D117D36003C6002 /* CSMachine.mm in Sources */,
|
||||
4B14978F1EE4B4D200CE2596 /* CSZX8081.mm in Sources */,
|
||||
4BC91B831D1F160E00884B76 /* CommodoreTAP.cpp in Sources */,
|
||||
4BE845211F2FF7F100A5EA22 /* CRTC6845.cpp in Sources */,
|
||||
4BCF1FAB1DADD41B0039D2E7 /* StaticAnalyser.cpp in Sources */,
|
||||
4B2A539F1D117D36003C6002 /* CSAudioQueue.m in Sources */,
|
||||
4B37EE821D7345A6006A09A4 /* BinaryDump.cpp in Sources */,
|
||||
|
Loading…
Reference in New Issue
Block a user