mirror of
https://github.com/TomHarte/CLK.git
synced 2024-06-25 18:30:07 +00:00
Adds an IWM shim and corrects graphics output.
... now that there is some.
This commit is contained in:
parent
407bbfb379
commit
96facc103a
67
Components/DiskII/IWM.cpp
Normal file
67
Components/DiskII/IWM.cpp
Normal file
|
@ -0,0 +1,67 @@
|
|||
//
|
||||
// IWM.cpp
|
||||
// Clock Signal
|
||||
//
|
||||
// Created by Thomas Harte on 05/05/2019.
|
||||
// Copyright © 2019 Thomas Harte. All rights reserved.
|
||||
//
|
||||
|
||||
#include "IWM.hpp"
|
||||
|
||||
using namespace Apple;
|
||||
|
||||
IWM::IWM(int clock_rate) {
|
||||
|
||||
}
|
||||
|
||||
uint8_t IWM::read(int address) {
|
||||
access(address);
|
||||
|
||||
switch(q_switches_) {
|
||||
default: return 0xff; // Undefined.
|
||||
|
||||
case 0x20: return 0x00; // Data register.
|
||||
|
||||
case 0x40:
|
||||
case 0x60:
|
||||
return (mode_&0x1f); // Status register.
|
||||
|
||||
case 0x80:
|
||||
case 0xa0:
|
||||
return 0x80; // Handshake register.
|
||||
}
|
||||
}
|
||||
|
||||
void IWM::write(int address, uint8_t input) {
|
||||
access(address);
|
||||
|
||||
switch(q_switches_) {
|
||||
default:
|
||||
break;
|
||||
|
||||
case 0xc0: // Write mode register.
|
||||
mode_ = input;
|
||||
break;
|
||||
|
||||
case 0xd0: // Write data register.
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void IWM::access(int address) {
|
||||
switch(address & 0xf) {
|
||||
default:
|
||||
break;
|
||||
|
||||
case 0x8: q_switches_ &= ~0x20; break;
|
||||
case 0x9: q_switches_ |= 0x20; break;
|
||||
case 0xc: q_switches_ &= ~0x40; break;
|
||||
case 0xd: q_switches_ |= 0x40; break;
|
||||
case 0xe: q_switches_ &= ~0x80; break;
|
||||
case 0xf: q_switches_ |= 0x80; break;
|
||||
}
|
||||
}
|
||||
|
||||
void IWM::run_for(const Cycles cycles) {
|
||||
}
|
48
Components/DiskII/IWM.hpp
Normal file
48
Components/DiskII/IWM.hpp
Normal file
|
@ -0,0 +1,48 @@
|
|||
//
|
||||
// IWM.hpp
|
||||
// Clock Signal
|
||||
//
|
||||
// Created by Thomas Harte on 05/05/2019.
|
||||
// Copyright © 2019 Thomas Harte. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef IWM_hpp
|
||||
#define IWM_hpp
|
||||
|
||||
#include "../../ClockReceiver/ClockReceiver.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace Apple {
|
||||
|
||||
class IWM {
|
||||
public:
|
||||
IWM(int clock_rate);
|
||||
|
||||
/// Sets the current external value of the data bus.
|
||||
void write(int address, uint8_t value);
|
||||
|
||||
/*!
|
||||
Submits an access to address @c address.
|
||||
|
||||
@returns The 8-bit value loaded to the data bus by the IWM.
|
||||
*/
|
||||
uint8_t read(int address);
|
||||
|
||||
/// Advances the controller by @c cycles.
|
||||
void run_for(const Cycles cycles);
|
||||
|
||||
private:
|
||||
uint8_t mode_ = 0;
|
||||
bool read_write_ready_ = true;
|
||||
bool write_overran_ = false;
|
||||
|
||||
int q_switches_ = 0;
|
||||
|
||||
void access(int address);
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif /* IWM_hpp */
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
#include "../../../Processors/68000/68000.hpp"
|
||||
#include "../../../Components/6522/6522.hpp"
|
||||
#include "../../../Components/DiskII/DiskII.hpp"
|
||||
#include "../../../Components/DiskII/IWM.hpp"
|
||||
|
||||
#include "../../Utility/MemoryPacker.hpp"
|
||||
|
||||
|
@ -63,6 +63,7 @@ class ConcreteMachine:
|
|||
|
||||
HalfCycles perform_bus_operation(const Microcycle &cycle, int is_supervisor) {
|
||||
time_since_video_update_ += cycle.length;
|
||||
time_since_iwm_update_ += cycle.length;
|
||||
|
||||
// Assumption here: it's a divide by ten to derive the 6522 clock, i.e.
|
||||
// it runs off the 68000's E clock.
|
||||
|
@ -71,9 +72,6 @@ class ConcreteMachine:
|
|||
|
||||
// SCC is a divide-by-two.
|
||||
|
||||
// The IWM runs at the native rate. (TODO: almost everything here).
|
||||
iwm_.run_for(cycle.length.cycles());
|
||||
|
||||
// A null cycle leaves nothing else to do.
|
||||
if(cycle.operation) {
|
||||
auto word_address = cycle.word_address();
|
||||
|
@ -100,13 +98,15 @@ class ConcreteMachine:
|
|||
break;
|
||||
|
||||
case 0x6ff0ff:
|
||||
// IWM
|
||||
// The IWM; this is a purely polled device, so can be run on demand.
|
||||
iwm_.run_for(time_since_iwm_update_.flush_cycles());
|
||||
if(cycle.operation & Microcycle::Read) {
|
||||
cycle.value->halves.low = iwm_.read_address(register_address);
|
||||
cycle.value->halves.low = iwm_.read(register_address);
|
||||
if(cycle.operation & Microcycle::SelectWord) cycle.value->halves.high = 0xff;
|
||||
} else {
|
||||
iwm_.set_data_input(cycle.value->halves.low);
|
||||
iwm_.write(register_address, cycle.value->halves.low);
|
||||
}
|
||||
printf("IWM %d %c [%02x]\n", register_address & 0xf, (cycle.operation & Microcycle::Read) ? 'r' : 'w', cycle.value->halves.low);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -262,10 +262,11 @@ class ConcreteMachine:
|
|||
MOS::MOS6522::MOS6522<VIAPortHandler> via_;
|
||||
VIAPortHandler via_port_handler_;
|
||||
|
||||
Apple::DiskII iwm_;
|
||||
Apple::IWM iwm_;
|
||||
|
||||
HalfCycles via_clock_;
|
||||
HalfCycles time_since_video_update_;
|
||||
HalfCycles time_since_iwm_update_;
|
||||
|
||||
bool ROM_is_overlay_ = true;
|
||||
};
|
||||
|
|
|
@ -82,27 +82,27 @@ void Video::run_for(HalfCycles duration) {
|
|||
|
||||
if(pixel_buffer_) {
|
||||
for(int c = first_word; c < final_pixel_word; ++c) {
|
||||
uint16_t pixels = ram_[video_address_];
|
||||
uint16_t pixels = ram_[video_address_] ^ 0xffff;
|
||||
++video_address_;
|
||||
|
||||
pixel_buffer_[0] = pixels & 0x01;
|
||||
pixel_buffer_[1] = pixels & 0x02;
|
||||
pixel_buffer_[2] = pixels & 0x04;
|
||||
pixel_buffer_[3] = pixels & 0x08;
|
||||
pixel_buffer_[4] = pixels & 0x10;
|
||||
pixel_buffer_[5] = pixels & 0x20;
|
||||
pixel_buffer_[6] = pixels & 0x40;
|
||||
pixel_buffer_[7] = pixels & 0x80;
|
||||
pixel_buffer_[15] = pixels & 0x01;
|
||||
pixel_buffer_[14] = pixels & 0x02;
|
||||
pixel_buffer_[13] = pixels & 0x04;
|
||||
pixel_buffer_[12] = pixels & 0x08;
|
||||
pixel_buffer_[11] = pixels & 0x10;
|
||||
pixel_buffer_[10] = pixels & 0x20;
|
||||
pixel_buffer_[9] = pixels & 0x40;
|
||||
pixel_buffer_[8] = pixels & 0x80;
|
||||
|
||||
pixels >>= 8;
|
||||
pixel_buffer_[8] = pixels & 0x01;
|
||||
pixel_buffer_[9] = pixels & 0x02;
|
||||
pixel_buffer_[10] = pixels & 0x04;
|
||||
pixel_buffer_[11] = pixels & 0x08;
|
||||
pixel_buffer_[12] = pixels & 0x10;
|
||||
pixel_buffer_[13] = pixels & 0x20;
|
||||
pixel_buffer_[14] = pixels & 0x40;
|
||||
pixel_buffer_[15] = pixels & 0x80;
|
||||
pixel_buffer_[7] = pixels & 0x01;
|
||||
pixel_buffer_[6] = pixels & 0x02;
|
||||
pixel_buffer_[5] = pixels & 0x04;
|
||||
pixel_buffer_[4] = pixels & 0x08;
|
||||
pixel_buffer_[3] = pixels & 0x10;
|
||||
pixel_buffer_[2] = pixels & 0x20;
|
||||
pixel_buffer_[1] = pixels & 0x40;
|
||||
pixel_buffer_[0] = pixels & 0x80;
|
||||
|
||||
pixel_buffer_ += 16;
|
||||
}
|
||||
|
|
|
@ -654,6 +654,7 @@
|
|||
4BEBFB522002DB30000708CC /* DiskROM.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BEBFB4F2002DB30000708CC /* DiskROM.cpp */; };
|
||||
4BEE0A6F1D72496600532C7B /* Cartridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BEE0A6A1D72496600532C7B /* Cartridge.cpp */; };
|
||||
4BEE0A701D72496600532C7B /* PRG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BEE0A6D1D72496600532C7B /* PRG.cpp */; };
|
||||
4BEE149A227FC0EA00133682 /* IWM.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BEE1498227FC0EA00133682 /* IWM.cpp */; };
|
||||
4BEEE6BD20DC72EB003723BF /* CompositeOptions.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4BEEE6BB20DC72EA003723BF /* CompositeOptions.xib */; };
|
||||
4BEF6AAA1D35CE9E00E73575 /* DigitalPhaseLockedLoopBridge.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4BEF6AA91D35CE9E00E73575 /* DigitalPhaseLockedLoopBridge.mm */; };
|
||||
4BEF6AAC1D35D1C400E73575 /* DPLLTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BEF6AAB1D35D1C400E73575 /* DPLLTests.swift */; };
|
||||
|
@ -1458,6 +1459,8 @@
|
|||
4BEE0A6B1D72496600532C7B /* Cartridge.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Cartridge.hpp; sourceTree = "<group>"; };
|
||||
4BEE0A6D1D72496600532C7B /* PRG.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PRG.cpp; sourceTree = "<group>"; };
|
||||
4BEE0A6E1D72496600532C7B /* PRG.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = PRG.hpp; sourceTree = "<group>"; };
|
||||
4BEE1498227FC0EA00133682 /* IWM.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = IWM.cpp; sourceTree = "<group>"; };
|
||||
4BEE1499227FC0EA00133682 /* IWM.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = IWM.hpp; sourceTree = "<group>"; };
|
||||
4BEEE6BC20DC72EA003723BF /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = "Clock Signal/Base.lproj/CompositeOptions.xib"; sourceTree = SOURCE_ROOT; };
|
||||
4BEF6AA81D35CE9E00E73575 /* DigitalPhaseLockedLoopBridge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DigitalPhaseLockedLoopBridge.h; sourceTree = "<group>"; };
|
||||
4BEF6AA91D35CE9E00E73575 /* DigitalPhaseLockedLoopBridge.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DigitalPhaseLockedLoopBridge.mm; sourceTree = "<group>"; };
|
||||
|
@ -1758,6 +1761,8 @@
|
|||
children = (
|
||||
4B302182208A550100773308 /* DiskII.hpp */,
|
||||
4B302183208A550100773308 /* DiskII.cpp */,
|
||||
4BEE1498227FC0EA00133682 /* IWM.cpp */,
|
||||
4BEE1499227FC0EA00133682 /* IWM.hpp */,
|
||||
);
|
||||
path = DiskII;
|
||||
sourceTree = "<group>";
|
||||
|
@ -3978,6 +3983,7 @@
|
|||
4BAE495920328897004BE78E /* ZX8081OptionsPanel.swift in Sources */,
|
||||
4B89451A201967B4007DE474 /* ConfidenceSummary.cpp in Sources */,
|
||||
4B54C0C51F8D91D90050900F /* Keyboard.cpp in Sources */,
|
||||
4BEE149A227FC0EA00133682 /* IWM.cpp in Sources */,
|
||||
4B69FB441C4D941400B5F0AA /* TapeUEF.cpp in Sources */,
|
||||
4B86E25B1F8C628F006FAA45 /* Keyboard.cpp in Sources */,
|
||||
4B4518851F75E91A00926311 /* DiskController.cpp in Sources */,
|
||||
|
|
Loading…
Reference in New Issue
Block a user