MC6850: Tie chip stepping to external clock.

Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
Adrian Conlon 2019-05-04 15:21:40 +01:00
parent 662c457dd5
commit 93122aaf1d

View File

@ -8,7 +8,7 @@ namespace EightBit
// +--------+----------------------------------------------------------------------------------+ // +--------+----------------------------------------------------------------------------------+
// | | Buffer address | // | | Buffer address |
// | +------------------+------------------+--------------------+-----------------------+ // | +------------------+------------------+--------------------+-----------------------+
// | | _ | _ | _ | _ | // | | _ | _ | _ | _ |
// | Data | RS * R/W | RS * R/W | RS * R/W | RS * R/W | // | Data | RS * R/W | RS * R/W | RS * R/W | RS * R/W |
// | Bus | (high)(low) | (high)(high) | (low)(low) | (low)(low) | // | Bus | (high)(low) | (high)(high) | (low)(low) | (low)(low) |
// | Line | Transmit | Receive | | | // | Line | Transmit | Receive | | |
@ -181,7 +181,7 @@ namespace EightBit
// character has not begun since the last write data command. // character has not begun since the last write data command.
STATUS_TDRE = 0b10, STATUS_TDRE = 0b10,
// ___ // . ___
// Data Carrier Detect (DCD), Bit 2 - The Data Carrier Detect // Data Carrier Detect (DCD), Bit 2 - The Data Carrier Detect
// bit will be high when the DCD (low) input from a modem has gone // bit will be high when the DCD (low) input from a modem has gone
// high to indicate that a carrier is not present. This bit // high to indicate that a carrier is not present. This bit
@ -195,7 +195,7 @@ namespace EightBit
// will follow the DCD (low) input. // will follow the DCD (low) input.
STATUS_DCD = 0b100, STATUS_DCD = 0b100,
// ___ // . ___
// Clear-to-Send (CTS), Bit 3 - The Clear-to-Send bit indicates // Clear-to-Send (CTS), Bit 3 - The Clear-to-Send bit indicates
// the state of the Clear-to-Send input from a modem. A low CTS (low) // the state of the Clear-to-Send input from a modem. A low CTS (low)
// indicates that there is a Clear-to-Send from the modem. In // indicates that there is a Clear-to-Send from the modem. In
@ -240,7 +240,7 @@ namespace EightBit
// parity check results are inhibited // parity check results are inhibited
STATUS_PE = 0b1000000, STATUS_PE = 0b1000000,
// ___ // . ___
// Interrupt Request (IRQ), Bit 7- The IRQ (low) bit indicates the // Interrupt Request (IRQ), Bit 7- The IRQ (low) bit indicates the
// state of the IRQ (low) output. Any interrupt condition with its // state of the IRQ (low) output. Any interrupt condition with its
// applicable enable will be indicated in this status bit. // applicable enable will be indicated in this status bit.
@ -330,7 +330,7 @@ namespace EightBit
byte status = 0; byte status = 0;
status = SetFlag(status, StatusRegister.STATUS_RDRF, this.statusRDRF); status = SetFlag(status, StatusRegister.STATUS_RDRF, this.statusRDRF);
status = SetFlag(status, StatusRegister.STATUS_TDRE, this.statusTDRE); status = SetFlag(status, StatusRegister.STATUS_TDRE, this.statusTDRE);
status = SetFlag(status, StatusRegister.STATUS_DCD, this.DCD.Lowered()); status = SetFlag(status, StatusRegister.STATUS_DCD, this.DCD.Raised());
status = SetFlag(status, StatusRegister.STATUS_CTS, this.CTS.Raised()); status = SetFlag(status, StatusRegister.STATUS_CTS, this.CTS.Raised());
status = ClearFlag(status, StatusRegister.STATUS_FE); status = ClearFlag(status, StatusRegister.STATUS_FE);
status = SetFlag(status, StatusRegister.STATUS_OVRN, this.statusOVRN); status = SetFlag(status, StatusRegister.STATUS_OVRN, this.statusOVRN);
@ -349,9 +349,12 @@ namespace EightBit
{ {
this.ResetCycles(); this.ResetCycles();
this.OnAccessing(); if (!this.Activated)
{
return;
}
this.Tick(); this.OnAccessing();
var writing = this.RW.Lowered(); var writing = this.RW.Lowered();
var reading = !writing; var reading = !writing;
@ -441,7 +444,7 @@ namespace EightBit
var value = this.Status; var value = this.Status;
var returned = string.Empty; var returned = string.Empty;
returned += "("; returned += "(";
returned += (value & (byte)StatusRegister.STATUS_IRQ) != 0 ? "IRQ" : "- "; returned += (value & (byte)StatusRegister.STATUS_IRQ) != 0 ? "IRQ " : "- ";
returned += (value & (byte)StatusRegister.STATUS_PE) != 0 ? "PE " : "- "; returned += (value & (byte)StatusRegister.STATUS_PE) != 0 ? "PE " : "- ";
returned += (value & (byte)StatusRegister.STATUS_OVRN) != 0 ? "OVRN " : "- "; returned += (value & (byte)StatusRegister.STATUS_OVRN) != 0 ? "OVRN " : "- ";
returned += (value & (byte)StatusRegister.STATUS_FE) != 0 ? "FE " : "- "; returned += (value & (byte)StatusRegister.STATUS_FE) != 0 ? "FE " : "- ";
@ -463,6 +466,12 @@ namespace EightBit
////private static byte ClearFlag(byte f, StatusRegisters flag, int condition) => ClearFlag(f, (byte)flag, condition); ////private static byte ClearFlag(byte f, StatusRegisters flag, int condition) => ClearFlag(f, (byte)flag, condition);
protected override void OnTicked()
{
base.OnTicked();
this.Step();
}
private void OnAccessing() => this.Accessing?.Invoke(this, EventArgs.Empty); private void OnAccessing() => this.Accessing?.Invoke(this, EventArgs.Empty);
private void OnAccessed() => this.Accessed?.Invoke(this, EventArgs.Empty); private void OnAccessed() => this.Accessed?.Invoke(this, EventArgs.Empty);