Whoops: missed bus read/write clock ticks in the 6502 emulator.

Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
Adrian Conlon
2019-02-18 00:52:45 +00:00
parent ea82c58777
commit a144cf19a1
3 changed files with 15 additions and 3 deletions

View File

@@ -68,6 +68,8 @@ namespace EightBit
public ref PinLevel HALT() => ref this.haltLine; public ref PinLevel HALT() => ref this.haltLine;
public IntelOpCodeDecoded GetDecodedOpCode(byte opCode) => this.decodedOpCodes[opCode];
public override void RaisePOWER() public override void RaisePOWER()
{ {
base.RaisePOWER(); base.RaisePOWER();
@@ -212,7 +214,5 @@ namespace EightBit
++this.PC(); ++this.PC();
this.RaiseHALT(); this.RaiseHALT();
} }
protected IntelOpCodeDecoded GetDecodedOpCode(byte opCode) => this.decodedOpCodes[opCode];
} }
} }

View File

@@ -20,7 +20,7 @@ namespace EightBit
public override int Size => this.bytes.Length; public override int Size => this.bytes.Length;
public static int Load(FileStream file, ref byte[] output, int writeOffset = 0, int readOffset = 0, int limit = -1, int maximumSize = -1) public static int Load(Stream file, ref byte[] output, int writeOffset = 0, int readOffset = 0, int limit = -1, int maximumSize = -1)
{ {
var size = (int)file.Length; var size = (int)file.Length;

View File

@@ -533,6 +533,18 @@ namespace EightBit
this.OpCode = 0x00; // BRK this.OpCode = 0x00; // BRK
} }
protected override sealed void BusWrite()
{
this.Tick();
base.BusWrite();
}
protected override sealed byte BusRead()
{
this.Tick();
return base.BusRead();
}
private static byte SetFlag(byte f, StatusBits flag) => SetFlag(f, (byte)flag); private static byte SetFlag(byte f, StatusBits flag) => SetFlag(f, (byte)flag);
private static byte SetFlag(byte f, StatusBits flag, int condition) => SetFlag(f, (byte)flag, condition); private static byte SetFlag(byte f, StatusBits flag, int condition) => SetFlag(f, (byte)flag, condition);