From 19feb3b349a007ca279395ad59e46119ac532f9c Mon Sep 17 00:00:00 2001 From: Nick Westgate Date: Sun, 12 Sep 2010 10:19:03 +1200 Subject: [PATCH] NSC now returns floating bus data on D1-D7. --- Virtu/Machine.cs | 2 +- Virtu/NoSlotClock.cs | 37 +++++++++++++++++++------------------ 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/Virtu/Machine.cs b/Virtu/Machine.cs index d337a41..1f52720 100644 --- a/Virtu/Machine.cs +++ b/Virtu/Machine.cs @@ -24,7 +24,7 @@ public Machine() Cassette = new Cassette(this); Speaker = new Speaker(this); Video = new Video(this); - NoSlotClock = new NoSlotClock(); + NoSlotClock = new NoSlotClock(this); var emptySlot = new PeripheralCard(this); Slot1 = emptySlot; diff --git a/Virtu/NoSlotClock.cs b/Virtu/NoSlotClock.cs index 8f81490..72574b6 100644 --- a/Virtu/NoSlotClock.cs +++ b/Virtu/NoSlotClock.cs @@ -3,19 +3,12 @@ namespace Jellyfish.Virtu { - public sealed class NoSlotClock + public sealed class NoSlotClock : MachineComponent { - public NoSlotClock() + public NoSlotClock(Machine machine) : + base(machine) { - Reset(); - } - - public void Reset() - { - // SmartWatch reset - whether tied to system reset is component specific - _comparisonRegister.Reset(); - _clockRegisterEnabled = false; - _writeEnabled = true; + ResetClock(); } public int Read(int address, int data) @@ -23,10 +16,10 @@ public int Read(int address, int data) // this may read or write the clock if ((address & 0x4) != 0) { - return ClockRead(data); + return ReadClock(data); } - ClockWrite(address); + WriteClock(address); return data; } @@ -35,15 +28,23 @@ public void Write(int address) // this may read or write the clock if ((address & 0x4) != 0) { - ClockRead(0); + ReadClock(0); } else { - ClockWrite(address); + WriteClock(address); } } - public int ClockRead(int data) + private void ResetClock() + { + // SmartWatch reset - whether tied to system reset is component specific + _comparisonRegister.Reset(); + _clockRegisterEnabled = false; + _writeEnabled = true; + } + + private int ReadClock(int data) { // for a ROM, A2 high = read, and data out (if any) is on D0 if (!_clockRegisterEnabled) @@ -53,7 +54,7 @@ public int ClockRead(int data) return data; } - data = _clockRegister.ReadBit(data); + data = _clockRegister.ReadBit(Machine.Video.ReadFloatingBus()); if (_clockRegister.NextBit()) { _clockRegisterEnabled = false; @@ -61,7 +62,7 @@ public int ClockRead(int data) return data; } - public void ClockWrite(int address) + private void WriteClock(int address) { // for a ROM, A2 low = write, and data in is on A0 if (!_writeEnabled)