diff --git a/EightBit/Device.cs b/EightBit/Device.cs index 1e22f16..5da0c17 100644 --- a/EightBit/Device.cs +++ b/EightBit/Device.cs @@ -22,21 +22,21 @@ namespace EightBit public event EventHandler LoweredPOWER; - public bool Powered => this.POWER().Raised(); + public bool Powered => this.POWER.Raised(); - public ref PinLevel POWER() => ref this.powerLine; + public ref PinLevel POWER => ref this.powerLine; public virtual void RaisePOWER() { this.OnRaisingPOWER(); - this.POWER().Raise(); + this.POWER.Raise(); this.OnRaisedPOWER(); } public virtual void LowerPOWER() { this.OnLoweringPOWER(); - this.POWER().Lower(); + this.POWER.Lower(); this.OnLoweredPOWER(); } diff --git a/EightBit/IntelProcessor.cs b/EightBit/IntelProcessor.cs index c2199ab..429f42e 100644 --- a/EightBit/IntelProcessor.cs +++ b/EightBit/IntelProcessor.cs @@ -60,9 +60,9 @@ namespace EightBit public byte L { get => this.HL.Low; set => this.HL.Low = value; } - protected bool Halted => this.HALT().Lowered(); + public ref PinLevel HALT => ref this.haltLine; - public ref PinLevel HALT() => ref this.haltLine; + protected bool Halted => this.HALT.Lowered(); public IntelOpCodeDecoded GetDecodedOpCode(byte opCode) => this.decodedOpCodes[opCode]; @@ -76,14 +76,14 @@ namespace EightBit public virtual void RaiseHALT() { this.OnRaisingHALT(); - this.HALT().Raise(); + this.HALT.Raise(); this.OnRaisedHALT(); } public virtual void LowerHALT() { this.OnLoweringHALT(); - this.HALT().Lower(); + this.HALT.Lower(); this.OnLoweredHALT(); } diff --git a/EightBit/Processor.cs b/EightBit/Processor.cs index 4eb64ac..e57f244 100644 --- a/EightBit/Processor.cs +++ b/EightBit/Processor.cs @@ -29,6 +29,10 @@ namespace EightBit public event EventHandler LoweredINT; + public ref PinLevel RESET => ref this.resetLine; + + public ref PinLevel INT => ref this.intLine; + public Bus Bus { get; } public Register16 PC { get; } = new Register16(); @@ -44,10 +48,6 @@ namespace EightBit return (sbyte)result; } - public ref PinLevel RESET() => ref this.resetLine; - - public ref PinLevel INT() => ref this.intLine; - public abstract int Step(); public abstract int Execute(); @@ -78,28 +78,28 @@ namespace EightBit public virtual void RaiseRESET() { this.OnRaisingRESET(); - this.RESET().Raise(); + this.RESET.Raise(); this.OnRaisedRESET(); } public virtual void LowerRESET() { this.OnLoweringRESET(); - this.RESET().Lower(); + this.RESET.Lower(); this.OnLoweredRESET(); } public virtual void RaiseINT() { this.OnRaisingINT(); - this.INT().Raise(); + this.INT.Raise(); this.OnRaisedINT(); } public virtual void LowerINT() { this.OnLoweringINT(); - this.INT().Lower(); + this.INT.Lower(); this.OnLoweredINT(); } diff --git a/Intel8080/Intel8080.cs b/Intel8080/Intel8080.cs index ae4a04b..1eed3ba 100644 --- a/Intel8080/Intel8080.cs +++ b/Intel8080/Intel8080.cs @@ -59,11 +59,11 @@ namespace EightBit this.OnExecutingInstruction(); if (this.Powered) { - if (this.RESET().Lowered()) + if (this.RESET.Lowered()) { this.HandleRESET(); } - else if (this.INT().Lowered()) + else if (this.INT.Lowered()) { this.HandleINT(); } diff --git a/M6502/M6502.cs b/M6502/M6502.cs index ccb713d..0b91483 100644 --- a/M6502/M6502.cs +++ b/M6502/M6502.cs @@ -64,6 +64,14 @@ namespace EightBit public event EventHandler LoweredRDY; + public ref PinLevel NMI => ref this.nmiLine; + + public ref PinLevel SO => ref this.soLine; + + public ref PinLevel SYNC => ref this.syncLine; + + public ref PinLevel RDY => ref this.rdyLine; + public byte X { get; set; } = 0; public byte Y { get; set; } = 0; @@ -86,14 +94,6 @@ namespace EightBit private int Carry => this.P & (byte)StatusBits.CF; - public ref PinLevel NMI() => ref this.nmiLine; - - public ref PinLevel SO() => ref this.soLine; - - public ref PinLevel SYNC() => ref this.syncLine; - - public ref PinLevel RDY() => ref this.rdyLine; - public override void RaisePOWER() { base.RaisePOWER(); @@ -108,42 +108,42 @@ namespace EightBit public virtual void RaiseNMI() { this.OnRaisingNMI(); - this.NMI().Raise(); + this.NMI.Raise(); this.OnRaisedNMI(); } public virtual void LowerNMI() { this.OnLoweringNMI(); - this.NMI().Lower(); + this.NMI.Lower(); this.OnLoweredNMI(); } public virtual void RaiseSO() { this.OnRaisingSO(); - this.SO().Raise(); + this.SO.Raise(); this.OnRaisedSO(); } public virtual void LowerSO() { this.OnLoweringSO(); - this.SO().Lower(); + this.SO.Lower(); this.OnLoweredSO(); } public virtual void RaiseRDY() { this.OnRaisingRDY(); - this.RDY().Raise(); + this.RDY.Raise(); this.OnRaisedRDY(); } public virtual void LowerRDY() { this.OnLoweringRDY(); - this.RDY().Lower(); + this.RDY.Lower(); this.OnLoweredRDY(); } @@ -435,24 +435,24 @@ namespace EightBit if (this.Powered) { this.Tick(); - if (this.SO().Lowered()) + if (this.SO.Lowered()) { this.HandleSO(); } - if (this.RDY().Raised()) + if (this.RDY.Raised()) { this.LowerSYNC(); // Instruction fetch beginning this.OpCode = this.Bus.Read(this.PC.Word++); // can't use fetchByte - if (this.RESET().Lowered()) + if (this.RESET.Lowered()) { this.HandleRESET(); } - else if (this.NMI().Lowered()) + else if (this.NMI.Lowered()) { this.HandleNMI(); } - else if (this.INT().Lowered() && (this.InterruptMasked == 0)) + else if (this.INT.Lowered() && (this.InterruptMasked == 0)) { this.HandleINT(); } @@ -508,14 +508,14 @@ namespace EightBit protected virtual void RaiseSYNC() { this.OnRaisingSYNC(); - this.SYNC().Raise(); + this.SYNC.Raise(); this.OnRaisedSYNC(); } protected virtual void LowerSYNC() { this.OnLoweringSYNC(); - this.SYNC().Lower(); + this.SYNC.Lower(); this.OnLoweredSYNC(); } diff --git a/MC6809/MC6809.cs b/MC6809/MC6809.cs index 5116696..0b23b1f 100644 --- a/MC6809/MC6809.cs +++ b/MC6809/MC6809.cs @@ -169,7 +169,7 @@ { this.HandleHALT(); } - else if (this.RESET().Lowered()) + else if (this.RESET.Lowered()) { this.HandleRESET(); } @@ -181,7 +181,7 @@ { this.HandleFIRQ(); } - else if (this.INT().Lowered() && (this.InterruptMasked == 0)) + else if (this.INT.Lowered() && (this.InterruptMasked == 0)) { this.HandleINT(); } diff --git a/Z80/Disassembler.cs b/Z80/Disassembler.cs index 2bfdb6a..7a7c33b 100644 --- a/Z80/Disassembler.cs +++ b/Z80/Disassembler.cs @@ -45,7 +45,7 @@ namespace EightBit var l = cpu.L; var i = cpu.IV; - var r = cpu.REFRESH(); + var r = cpu.REFRESH; var im = cpu.IM; @@ -226,7 +226,7 @@ namespace EightBit private string DisassembleED(Z80 cpu, ushort pc, ref string specification, ref int dumpCount, int x, int y, int z, int p, int q) { - string output = string.Empty; + var output = string.Empty; switch (x) { case 0: @@ -377,7 +377,7 @@ namespace EightBit private string DisassembleOther(Z80 cpu, ushort pc, ref string specification, ref int dumpCount, int x, int y, int z, int p, int q) { - string output = string.Empty; + var output = string.Empty; switch (x) { case 0: diff --git a/Z80/Z80.cs b/Z80/Z80.cs index 2005986..1c57f75 100644 --- a/Z80/Z80.cs +++ b/Z80/Z80.cs @@ -89,6 +89,12 @@ namespace EightBit public byte IYL { get => this.IY.Low; set => this.IY.Low = value; } + public ref RefreshRegister REFRESH => ref this.refresh; + + public ref PinLevel NMI => ref this.nmiLine; + + public ref PinLevel M1 => ref this.m1Line; + private ushort DisplacedAddress { get @@ -98,12 +104,6 @@ namespace EightBit } } - public ref RefreshRegister REFRESH() => ref this.refresh; - - public ref PinLevel NMI() => ref this.nmiLine; - - public ref PinLevel M1() => ref this.m1Line; - public void Exx() => this.registerSet ^= 1; public void ExxAF() => this.accumulatorFlagsSet ^= 1; @@ -117,7 +117,7 @@ namespace EightBit this.DisableInterrupts(); this.IM = 0; - this.REFRESH() = new RefreshRegister(0); + this.REFRESH = new RefreshRegister(0); this.IV = (byte)Mask.Mask8; this.ExxAF(); @@ -132,28 +132,28 @@ namespace EightBit public virtual void RaiseNMI() { this.OnRaisingNMI(); - this.NMI().Raise(); + this.NMI.Raise(); this.OnRaisedNMI(); } public virtual void LowerNMI() { this.OnLoweringNMI(); - this.NMI().Lower(); + this.NMI.Lower(); this.OnLoweredNMI(); } public virtual void RaiseM1() { this.OnRaisingM1(); - this.M1().Raise(); + this.M1.Raise(); this.OnRaisedM1(); } public virtual void LowerM1() { this.OnLoweringM1(); - this.M1().Lower(); + this.M1.Lower(); this.OnLoweredM1(); } @@ -161,7 +161,7 @@ namespace EightBit { if (!(this.prefixCB && this.displaced)) { - ++this.REFRESH(); + ++this.REFRESH; this.RaiseM1(); } @@ -202,15 +202,15 @@ namespace EightBit { this.displaced = this.prefixCB = this.prefixDD = this.prefixED = false; this.LowerM1(); - if (this.RESET().Lowered()) + if (this.RESET.Lowered()) { this.HandleRESET(); } - else if (this.NMI().Lowered()) + else if (this.NMI.Lowered()) { this.HandleNMI(); } - else if (this.INT().Lowered()) + else if (this.INT.Lowered()) { this.HandleINT(); } @@ -695,7 +695,7 @@ namespace EightBit this.Tick(9); break; case 1: // LD R,A - this.REFRESH() = this.A; + this.REFRESH = this.A; this.Tick(9); break; case 2: // LD A,I @@ -705,7 +705,7 @@ namespace EightBit this.Tick(9); break; case 3: // LD A,R - this.F = AdjustSZXY(this.F, this.A = this.REFRESH()); + this.F = AdjustSZXY(this.F, this.A = this.REFRESH); this.F = ClearFlag(this.F, StatusBits.NF | StatusBits.HC); this.F = SetFlag(this.F, StatusBits.PF, this.IFF2); this.Tick(9);