mirror of
https://github.com/MoleskiCoder/EightBitNet.git
synced 2026-10-23 23:02:16 +00:00
No need for bus read/write events with cycle accurate cpu read/write events
This commit is contained in:
1 parent
ee9917bb7f
commit
2d145ec023
9 files changed
+20
-29
No files matched your search
@@ -11,14 +11,6 @@ namespace EightBit
|
||||
private bool _writing;
|
||||
private byte _data;
|
||||
|
||||
public event EventHandler<EventArgs>? WritingByte;
|
||||
|
||||
public event EventHandler<EventArgs>? WrittenByte;
|
||||
|
||||
public event EventHandler<EventArgs>? ReadingByte;
|
||||
|
||||
public event EventHandler<EventArgs>? ReadByte;
|
||||
|
||||
public ref byte Data => ref this._data;
|
||||
|
||||
public Register16 Address { get; } = new();
|
||||
@@ -46,20 +38,16 @@ namespace EightBit
|
||||
public void Read()
|
||||
{
|
||||
Debug.Assert(!this._writing, "Writing flag is in an invalid state");
|
||||
this.ReadingByte?.Invoke(this, EventArgs.Empty);
|
||||
this.Data = this.Reference();
|
||||
this.ReadByte?.Invoke(this, EventArgs.Empty);
|
||||
Debug.Assert(!this._writing, "Writing flag is in an invalid state");
|
||||
}
|
||||
|
||||
public void Write()
|
||||
{
|
||||
Debug.Assert(!this._writing, "Writing flag is in an invalid state");
|
||||
this.WritingByte?.Invoke(this, EventArgs.Empty);
|
||||
this._writing = true;
|
||||
this.Reference() = this.Data;
|
||||
this._writing = false;
|
||||
this.WrittenByte?.Invoke(this, EventArgs.Empty);
|
||||
Debug.Assert(!this._writing, "Writing flag is in an invalid state");
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -66,7 +66,7 @@ namespace LR35902
|
||||
this._ioMapping = new(this.IO, IoRegisters.BASE, 0xffff, AccessLevel.ReadWrite);
|
||||
this._highInternalRamMapping = new(this._highInternalRam, 0xff80, 0xffff, AccessLevel.ReadWrite);
|
||||
|
||||
this.WrittenByte += this.Bus_WrittenByte;
|
||||
this.CPU.WrittenMemory += Bus_WrittenByte;
|
||||
}
|
||||
|
||||
public LR35902 CPU { get; }
|
||||
|
||||
@@ -96,8 +96,8 @@ namespace LR35902
|
||||
this.bus = bus;
|
||||
if (triggered)
|
||||
{
|
||||
this.bus.ReadingByte += this.Bus_ReadingByte;
|
||||
this.bus.WrittenByte += this.Bus_WrittenByte;
|
||||
this.bus.CPU.ReadMemory += this.Bus_ReadingByte;
|
||||
this.bus.CPU.WrittenMemory += this.Bus_WrittenByte;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace LR35902.BlarggTest
|
||||
#if GAMEBOY_DOCTOR
|
||||
this.CPU.ExecutingInstruction += this.CPU_ExecutingInstruction_Debug;
|
||||
#else
|
||||
this.WrittenByte += this.Board_WrittenByte;
|
||||
this.CPU.WrittenMemory += this.Board_WrittenByte;
|
||||
if (this.configuration.DebugMode)
|
||||
{
|
||||
this.CPU.ExecutingInstruction += this.CPU_ExecutingInstruction_Debug;
|
||||
|
||||
+4
-1
@@ -554,7 +554,10 @@ namespace M6502
|
||||
|
||||
// Can't use "FetchByte", since that would add an extra tick.
|
||||
this.ImmediateAddress();
|
||||
this.ReadFromMemory();
|
||||
|
||||
this.OnReadingMemory();
|
||||
this.ReadFromMemory();
|
||||
this.OnReadMemory();
|
||||
|
||||
System.Diagnostics.Debug.Assert(this.Cycles == 1, "BUS read has introduced stray cycles");
|
||||
this.RaiseSYNC();
|
||||
|
||||
@@ -245,8 +245,8 @@
|
||||
|
||||
public void Initialise()
|
||||
{
|
||||
this.Runner.ReadByte += this.Runner_ReadByte;
|
||||
this.Runner.WrittenByte += this.Runner_WrittenByte;
|
||||
this.Runner.CPU.ReadMemory += this.Runner_ReadByte;
|
||||
this.Runner.CPU.WrittenMemory += this.Runner_WrittenByte;
|
||||
}
|
||||
|
||||
private void InitialiseState(Test test)
|
||||
|
||||
@@ -81,12 +81,12 @@ namespace M6502.Test
|
||||
if (this.configuration.AllowKeyRead)
|
||||
{
|
||||
this.CPU.ExecutedInstruction += this.CPU_ExecutedInstruction_Polling;
|
||||
this.ReadingByte += this.Bus_ReadingByte;
|
||||
this.ReadByte += this.Bus_ReadByte;
|
||||
this.CPU.ReadingMemory += this.Bus_ReadingByte;
|
||||
this.CPU.ReadMemory += this.Bus_ReadByte;
|
||||
}
|
||||
|
||||
this.CPU.ExecutedInstruction += this.CPU_ExecutedInstruction;
|
||||
this.WrittenByte += this.Bus_WrittenByte;
|
||||
this.CPU.WrittenMemory += this.Bus_WrittenByte;
|
||||
|
||||
if (this.configuration.Profile)
|
||||
{
|
||||
|
||||
@@ -112,10 +112,10 @@ namespace MC6809.Test
|
||||
this.CPU.ExecutedInstruction += CPU_ExecutedInstruction;
|
||||
|
||||
// Marshal data from ACIA -> memory
|
||||
this.ReadingByte += Board_ReadingByte;
|
||||
this.CPU.ReadingMemory += Board_ReadingByte;
|
||||
|
||||
// Marshal data from memory -> ACIA
|
||||
this.WrittenByte += Board_WrittenByte;
|
||||
this.CPU.WrittenMemory += Board_WrittenByte;
|
||||
|
||||
if (this._configuration.DebugMode)
|
||||
{
|
||||
|
||||
+5
-5
@@ -2151,19 +2151,19 @@ namespace Z80
|
||||
|
||||
private void AdjustBlockInFlagsIncrement()
|
||||
{
|
||||
AdjustBlockInputOutputFlags((byte)(this.C + 1) + this.Bus.Data);
|
||||
this.AdjustBlockInputOutputFlags((byte)(this.C + 1) + this.Bus.Data);
|
||||
}
|
||||
|
||||
private void AdjustBlockInFlagsDecrement()
|
||||
{
|
||||
AdjustBlockInputOutputFlags((byte)(this.C - 1) + this.Bus.Data);
|
||||
this.AdjustBlockInputOutputFlags((byte)(this.C - 1) + this.Bus.Data);
|
||||
}
|
||||
|
||||
private void AdjustBlockOutFlags()
|
||||
{
|
||||
// HL needs to have been incremented or decremented prior to this call
|
||||
this.SetBit(StatusBits.NF, SignTest(this.Bus.Data));
|
||||
AdjustBlockInputOutputFlags(this.L + this.Bus.Data);
|
||||
this.AdjustBlockInputOutputFlags(this.L + this.Bus.Data);
|
||||
}
|
||||
|
||||
#region Block input
|
||||
@@ -2302,7 +2302,7 @@ namespace Z80
|
||||
|
||||
private void RRD()
|
||||
{
|
||||
ReadMemoryIndirect(this.HL);
|
||||
this.ReadMemoryIndirect(this.HL);
|
||||
var memory = this.Bus.Data;
|
||||
this.Bus.Data = (byte)(PromoteNibble(this.A) | HighNibble(memory));
|
||||
this.MemoryUpdate(5);
|
||||
@@ -2313,7 +2313,7 @@ namespace Z80
|
||||
|
||||
private void RLD()
|
||||
{
|
||||
ReadMemoryIndirect(this.HL);
|
||||
this.ReadMemoryIndirect(this.HL);
|
||||
var memory = this.Bus.Data;
|
||||
this.Bus.Data = (byte)(PromoteNibble(memory) | LowNibble(this.A));
|
||||
this.MemoryUpdate(5);
|
||||
|
||||
Reference in new issue
Block a user