mirror of
https://github.com/MoleskiCoder/EightBitNet.git
synced 2026-10-23 23:02:16 +00:00
So there we have it. 100% Harte single step coverage/success for MOS 6502
This commit is contained in:
1 parent
de12029c13
commit
cfc3169933
3 files changed
+736
-399
No files matched your search
+412
-182
@@ -2,8 +2,6 @@
|
||||
// Copyright (c) Adrian Conlon. All rights reserved.
|
||||
// </copyright>
|
||||
|
||||
//using EightBit;
|
||||
|
||||
namespace M6502
|
||||
{
|
||||
using EightBit;
|
||||
@@ -326,179 +324,179 @@ namespace M6502
|
||||
var cycles = this.Cycles;
|
||||
switch (this.OpCode)
|
||||
{
|
||||
case 0x00: this.SwallowFetch(); this.Interrupt(IRQ_vector, InterruptSource.software); break;// BRK (implied)
|
||||
case 0x01: this.OrR(this.IndexedIndirectXRead()); break; // ORA (indexed indirect X)
|
||||
case 0x05: this.ZeroPageRead(); this.OrR(); break; // ORA (zero page)
|
||||
case 0x06: this.ZeroPageRead(); this.ModifyWrite(this.ASL()); break; // ASL (zero page)
|
||||
case 0x08: this.SwallowRead(); this.PHP(); break; // PHP (implied)
|
||||
case 0x09: this.OrR(this.FetchByte()); break; // ORA (immediate)
|
||||
case 0x0a: this.SwallowRead(); this.A = this.ASL(this.A); break; // ASL A (implied)
|
||||
case 0x0d: this.AbsoluteRead(); this.OrR(); break; // ORA (absolute)
|
||||
case 0x0e: this.AbsoluteRead(); this.ModifyWrite(this.ASL()); break; // ASL (absolute)
|
||||
case 0x00: this.BRK(); break; // BRK (implied)
|
||||
case 0x01: this.IndexedIndirectX(); this.ORA(); break; // ORA (indexed indirect X)
|
||||
case 0x05: this.ZeroPage(); this.ORA(); break; // ORA (zero page)
|
||||
case 0x06: this.ZeroPage(); this.ASL(); break; // ASL (zero page)
|
||||
case 0x08: this.PHP(); break; // PHP (implied)
|
||||
case 0x09: this.Immediate(); this.ORA(); break; // ORA (immediate)
|
||||
case 0x0a: this.ASLA(); break; // ASL A (implied)
|
||||
case 0x0d: this.Absolute(); this.ORA(); break; // ORA (absolute)
|
||||
case 0x0e: this.Absolute(); this.ASL(); break; // ASL (absolute)
|
||||
|
||||
case 0x10: this.BranchNot(this.Negative); break; // BPL (relative)
|
||||
case 0x11: this.OrR(this.IndirectIndexedYRead()); break; // ORA (indirect indexed Y)
|
||||
case 0x15: this.ZeroPageXRead(); this.OrR(); break; // ORA (zero page, X)
|
||||
case 0x16: this.ZeroPageXRead(); this.ModifyWrite(this.ASL()); break; // ASL (zero page, X)
|
||||
case 0x18: this.SwallowRead(); this.ResetFlag(StatusBits.CF); break; // CLC (implied)
|
||||
case 0x19: this.AbsoluteYRead(); this.OrR(); break; // ORA (absolute, Y)
|
||||
case 0x1d: this.AbsoluteXRead(); this.OrR(); break; // ORA (absolute, X)
|
||||
case 0x1e: this.AbsoluteXAddress(); this.FixupRead(); this.ModifyWrite(this.ASL()); break; // ASL (absolute, X)
|
||||
case 0x10: this.BPL(); break; // BPL (relative)
|
||||
case 0x11: this.IndirectIndexedY(); this.ORA(); break; // ORA (indirect indexed Y)
|
||||
case 0x15: this.ZeroPageX(); this.ORA(); break; // ORA (zero page, X)
|
||||
case 0x16: this.ZeroPageX(); this.ASL(); break; // ASL (zero page, X)
|
||||
case 0x18: this.CLC(); break; // CLC (implied)
|
||||
case 0x19: this.AbsoluteY(); this.ORA(); break; // ORA (absolute, Y)
|
||||
case 0x1d: this.AbsoluteX(); this.ORA(); break; // ORA (absolute, X)
|
||||
case 0x1e: this.AbsoluteXAddress(); this.FixupRead(); this.ASL(); break; // ASL (absolute, X)
|
||||
|
||||
case 0x20: this.JSR(); break; // JSR (absolute)
|
||||
case 0x21: this.AndR(this.IndexedIndirectXRead()); break; // AND (indexed indirect X)
|
||||
case 0x24: this.ZeroPageRead(); this.BIT(); break; // BIT (zero page)
|
||||
case 0x25: this.ZeroPageRead(); this.AndR(); break; // AND (zero page)
|
||||
case 0x26: this.ZeroPageRead(); this.ModifyWrite(this.ROL()); break; // ROL (zero page)
|
||||
case 0x28: this.SwallowRead(); this.PLP(); break; // PLP (implied)
|
||||
case 0x29: this.AndR(this.FetchByte()); break; // AND (immediate)
|
||||
case 0x2a: this.SwallowRead(); this.A = this.ROL(this.A); break; // ROL A (implied)
|
||||
case 0x2c: this.AbsoluteRead(); this.BIT(); break; // BIT (absolute)
|
||||
case 0x2d: this.AbsoluteRead(); this.AndR(); break; // AND (absolute)
|
||||
case 0x2e: this.AbsoluteRead(); this.ModifyWrite(this.ROL()); break; // ROL (absolute)
|
||||
case 0x20: this.JSR(); break; // JSR (absolute)
|
||||
case 0x21: this.IndexedIndirectX(); this.AND(); break; // AND (indexed indirect X)
|
||||
case 0x24: this.ZeroPage(); this.BIT(); break; // BIT (zero page)
|
||||
case 0x25: this.ZeroPage(); this.AND(); break; // AND (zero page)
|
||||
case 0x26: this.ZeroPage(); this.ROL(); break; // ROL (zero page)
|
||||
case 0x28: this.PLP(); break; // PLP (implied)
|
||||
case 0x29: this.FetchByte(); this.AND(); break; // AND (immediate)
|
||||
case 0x2a: this.ROLA(); break; // ROL A (implied)
|
||||
case 0x2c: this.Absolute(); this.BIT(); break; // BIT (absolute)
|
||||
case 0x2d: this.Absolute(); this.AND(); break; // AND (absolute)
|
||||
case 0x2e: this.Absolute(); this.ROL(); break; // ROL (absolute)
|
||||
|
||||
case 0x30: this.Branch(this.Negative); break; // BMI (relative)
|
||||
case 0x31: this.AndR(this.IndirectIndexedYRead()); break; // AND (indirect indexed Y)
|
||||
case 0x35: this.ZeroPageXRead(); this.AndR(); break; // AND (zero page, X)
|
||||
case 0x36: this.ZeroPageXRead(); this.ModifyWrite(this.ROL()); break; // ROL (zero page, X)
|
||||
case 0x38: this.SwallowRead(); this.SetFlag(StatusBits.CF); break; // SEC (implied)
|
||||
case 0x39: this.AbsoluteYRead(); this.AndR(); break; // AND (absolute, Y)
|
||||
case 0x3d: this.AbsoluteXRead(); this.AndR(); break; // AND (absolute, X)
|
||||
case 0x3e: this.AbsoluteXAddress(); this.FixupRead(); this.ModifyWrite(this.ROL()); break; // ROL (absolute, X)
|
||||
case 0x30: this.BMI(); break; // BMI (relative)
|
||||
case 0x31: this.IndirectIndexedY(); this.AND(); break; // AND (indirect indexed Y)
|
||||
case 0x35: this.ZeroPageX(); this.AND(); break; // AND (zero page, X)
|
||||
case 0x36: this.ZeroPageX(); this.ROL(); break; // ROL (zero page, X)
|
||||
case 0x38: this.SEC(); break; // SEC (implied)
|
||||
case 0x39: this.AbsoluteY(); this.AND(); break; // AND (absolute, Y)
|
||||
case 0x3d: this.AbsoluteX(); this.AND(); break; // AND (absolute, X)
|
||||
case 0x3e: this.AbsoluteXAddress(); this.FixupRead(); this.ROL(); break; // ROL (absolute, X)
|
||||
|
||||
case 0x40: this.SwallowRead(); this.RTI(); break; // RTI (implied)
|
||||
case 0x41: this.EorR(this.IndexedIndirectXRead()); break; // EOR (indexed indirect X)
|
||||
case 0x44: this.ZeroPageRead(); break; // *NOP (zero page)
|
||||
case 0x45: this.ZeroPageRead(); this.EorR(); break; // EOR (zero page)
|
||||
case 0x46: this.ZeroPageRead(); this.ModifyWrite(this.LSR()); break; // LSR (zero page)
|
||||
case 0x48: this.SwallowRead(); this.Push(this.A); break; // PHA (implied)
|
||||
case 0x49: this.EorR(this.FetchByte()); break; // EOR (immediate)
|
||||
case 0x4a: this.SwallowRead(); this.A = this.LSR(this.A); break; // LSR A (implied)
|
||||
case 0x4c: this.AbsoluteAddress(); this.Jump(this.Bus.Address); break; // JMP (absolute)
|
||||
case 0x4d: this.AbsoluteRead(); this.EorR(); break; // EOR (absolute)
|
||||
case 0x4e: this.AbsoluteRead(); this.ModifyWrite(this.LSR()); break; // LSR (absolute)
|
||||
case 0x40: this.RTI(); break; // RTI (implied)
|
||||
case 0x41: this.IndexedIndirectX(); this.EOR(); break; // EOR (indexed indirect X)
|
||||
case 0x44: this.ZeroPage(); break; // *NOP (zero page)
|
||||
case 0x45: this.ZeroPage(); this.EOR(); break; // EOR (zero page)
|
||||
case 0x46: this.ZeroPage(); this.LSR(); break; // LSR (zero page)
|
||||
case 0x48: this.PHA(); break; // PHA (implied)
|
||||
case 0x49: this.Immediate(); this.EOR(); break; // EOR (immediate)
|
||||
case 0x4a: this.LSRA(); break; // LSR A (implied)
|
||||
case 0x4c: this.AbsoluteAddress(); this.JMP(); break; // JMP (absolute)
|
||||
case 0x4d: this.Absolute(); this.EOR(); break; // EOR (absolute)
|
||||
case 0x4e: this.Absolute(); this.LSR(); break; // LSR (absolute)
|
||||
|
||||
case 0x50: this.BranchNot(this.Overflow); break; // BVC (relative)
|
||||
case 0x51: this.EorR(this.IndirectIndexedYRead()); break; // EOR (indirect indexed Y)
|
||||
case 0x54: this.ZeroPageXRead(); break; // *NOP (zero page, X)
|
||||
case 0x55: this.ZeroPageXRead(); this.EorR(); break; // EOR (zero page, X)
|
||||
case 0x56: this.ZeroPageXRead(); this.ModifyWrite(this.LSR()); break; // LSR (zero page, X)
|
||||
case 0x58: this.SwallowRead(); this.ResetFlag(StatusBits.IF); break; // CLI (implied)
|
||||
case 0x59: this.AbsoluteYRead(); this.EorR(); break; // EOR (absolute, Y)
|
||||
case 0x5d: this.AbsoluteXRead(); this.EorR(); break; // EOR (absolute, X)
|
||||
case 0x5e: this.AbsoluteXAddress(); this.FixupRead(); this.ModifyWrite(this.LSR()); break; // LSR (absolute, X)
|
||||
case 0x50: this.BVC(); break; // BVC (relative)
|
||||
case 0x51: this.IndirectIndexedY(); this.EOR(); break; // EOR (indirect indexed Y)
|
||||
case 0x54: this.ZeroPageX(); break; // *NOP (zero page, X)
|
||||
case 0x55: this.ZeroPageX(); this.EOR(); break; // EOR (zero page, X)
|
||||
case 0x56: this.ZeroPageX(); this.LSR(); break; // LSR (zero page, X)
|
||||
case 0x58: this.CLI(); break; // CLI (implied)
|
||||
case 0x59: this.AbsoluteY(); this.EOR(); break; // EOR (absolute, Y)
|
||||
case 0x5d: this.AbsoluteX(); this.EOR(); break; // EOR (absolute, X)
|
||||
case 0x5e: this.AbsoluteXAddress(); this.FixupRead(); this.LSR(); break; // LSR (absolute, X)
|
||||
|
||||
case 0x60: this.SwallowRead(); this.Return(); break; // RTS (implied)
|
||||
case 0x61: this.ADC(this.IndexedIndirectXRead()); break; // ADC (indexed indirect X)
|
||||
case 0x65: this.ADC(this.ZeroPageRead()); break; // ADC (zero page)
|
||||
case 0x66: this.ZeroPageRead(); this.ModifyWrite(this.ROR()); break; // ROR (zero page)
|
||||
case 0x68: this.SwallowRead(); this.SwallowPop(); this.A = this.Through(this.Pop()); break; // PLA (implied)
|
||||
case 0x69: this.ADC(this.FetchByte()); break; // ADC (immediate)
|
||||
case 0x6a: this.SwallowRead(); this.A = this.ROR(this.A); break; // ROR A (implied)
|
||||
case 0x6c: this.IndirectAddress(); this.Jump(this.Bus.Address); break; // JMP (indirect)
|
||||
case 0x6d: this.ADC(this.AbsoluteRead()); break; // ADC (absolute)
|
||||
case 0x6e: this.AbsoluteRead(); this.ModifyWrite(this.ROR()); break; // ROR (absolute)
|
||||
case 0x60: this.RTS(); break; // RTS (implied)
|
||||
case 0x61: this.IndexedIndirectX(); this.ADC(); break; // ADC (indexed indirect X)
|
||||
case 0x65: this.ZeroPage(); this.ADC(); break; // ADC (zero page)
|
||||
case 0x66: this.ZeroPage(); this.ROR(); break; // ROR (zero page)
|
||||
case 0x68: this.PLA(); break; // PLA (implied)
|
||||
case 0x69: this.Immediate(); this.ADC(); break; // ADC (immediate)
|
||||
case 0x6a: this.RORA(); break; // ROR A (implied)
|
||||
case 0x6c: this.IndirectAddress(); this.JMP(); break; // JMP (indirect)
|
||||
case 0x6d: this.Absolute(); this.ADC(); break; // ADC (absolute)
|
||||
case 0x6e: this.Absolute(); this.ROR(); break; // ROR (absolute)
|
||||
|
||||
case 0x70: this.Branch(this.Overflow); break; // BVS (relative)
|
||||
case 0x71: this.ADC(this.IndirectIndexedYRead()); break; // ADC (indirect indexed Y)
|
||||
case 0x75: this.ADC(this.ZeroPageXRead()); break; // ADC (zero page, X)
|
||||
case 0x76: this.ZeroPageXRead(); this.ModifyWrite(this.ROR()); break; // ROR (zero page, X)
|
||||
case 0x78: this.SwallowRead(); this.SetFlag(StatusBits.IF); break; // SEI (implied)
|
||||
case 0x79: this.ADC(this.AbsoluteYRead()); break; // ADC (absolute, Y)
|
||||
case 0x7d: this.ADC(this.AbsoluteXRead()); break; // ADC (absolute, X)
|
||||
case 0x7e: this.AbsoluteXAddress(); this.FixupRead(); this.ModifyWrite(this.ROR()); break; // ROR (absolute, X)
|
||||
case 0x70: this.BVS(); break; // BVS (relative)
|
||||
case 0x71: this.IndirectIndexedY(); this.ADC(); break; // ADC (indirect indexed Y)
|
||||
case 0x75: this.ZeroPageX(); this.ADC(); break; // ADC (zero page, X)
|
||||
case 0x76: this.ZeroPageX(); this.ROR(); break; // ROR (zero page, X)
|
||||
case 0x78: this.SEI(); break; // SEI (implied)
|
||||
case 0x79: this.AbsoluteY(); this.ADC(); break; // ADC (absolute, Y)
|
||||
case 0x7d: this.AbsoluteX(); this.ADC(); break; // ADC (absolute, X)
|
||||
case 0x7e: this.AbsoluteXAddress(); this.FixupRead(); this.ROR(); break; // ROR (absolute, X)
|
||||
|
||||
case 0x81: this.IndexedIndirectXAddress(); this.MemoryWrite(this.A); break; // STA (indexed indirect X)
|
||||
case 0x82: _ = this.FetchByte(); break; // *NOP (immediate)
|
||||
case 0x84: this.ZeroPageAddress(); this.MemoryWrite(this.Y); break; // STY (zero page)
|
||||
case 0x85: this.ZeroPageAddress(); this.MemoryWrite(this.A); break; // STA (zero page)
|
||||
case 0x86: this.ZeroPageAddress(); this.MemoryWrite(this.X); break; // STX (zero page)
|
||||
case 0x88: this.SwallowRead(); this.Y = this.DEC(this.Y); break; // DEY (implied)
|
||||
case 0x8a: this.SwallowRead(); this.A = this.Through(this.X); break; // TXA (implied)
|
||||
case 0x8c: this.AbsoluteAddress(); this.MemoryWrite(this.Y); break; // STY (absolute)
|
||||
case 0x8d: this.AbsoluteAddress(); this.MemoryWrite(this.A); break; // STA (absolute)
|
||||
case 0x8e: this.AbsoluteAddress(); this.MemoryWrite(this.X); break; // STX (absolute)
|
||||
case 0x81: this.IndexedIndirectXAddress(); this.STA(); break; // STA (indexed indirect X)
|
||||
case 0x82: this.Immediate(); break; // *NOP (immediate)
|
||||
case 0x84: this.ZeroPageAddress(); this.STY(); break; // STY (zero page)
|
||||
case 0x85: this.ZeroPageAddress(); this.STA(); break; // STA (zero page)
|
||||
case 0x86: this.ZeroPageAddress(); this.STX(); break; // STX (zero page)
|
||||
case 0x88: this.DEY(); break; // DEY (implied)
|
||||
case 0x8a: this.TXA(); break; // TXA (implied)
|
||||
case 0x8c: this.AbsoluteAddress(); this.STY(); break; // STY (absolute)
|
||||
case 0x8d: this.AbsoluteAddress(); this.STA(); break; // STA (absolute)
|
||||
case 0x8e: this.AbsoluteAddress(); this.STX(); break; // STX (absolute)
|
||||
|
||||
case 0x90: this.BranchNot(this.Carry); break; // BCC (relative)
|
||||
case 0x91: this.IndirectIndexedYAddress(); this.Fixup(); this.MemoryWrite(this.A); break; // STA (indirect indexed Y)
|
||||
case 0x94: this.ZeroPageXAddress(); this.MemoryWrite(this.Y); break; // STY (zero page, X)
|
||||
case 0x95: this.ZeroPageXAddress(); this.MemoryWrite(this.A); break; // STA (zero page, X)
|
||||
case 0x96: this.ZeroPageYAddress(); this.MemoryWrite(this.X); break; // STX (zero page, Y)
|
||||
case 0x98: this.SwallowRead(); this.A = this.Through(this.Y); break; // TYA (implied)
|
||||
case 0x99: this.AbsoluteYAddress(); this.Fixup(); this.MemoryWrite(this.A); break; // STA (absolute, Y)
|
||||
case 0x9a: this.SwallowRead(); this.S = this.X; break; // TXS (implied)
|
||||
case 0x9d: this.AbsoluteXAddress(); this.Fixup(); this.MemoryWrite(this.A); break; // STA (absolute, X)
|
||||
case 0x90: this.BCC(); break; // BCC (relative)
|
||||
case 0x91: this.IndirectIndexedYAddress(); this.Fixup(); this.STA(); break; // STA (indirect indexed Y)
|
||||
case 0x94: this.ZeroPageXAddress(); this.STY(); break; // STY (zero page, X)
|
||||
case 0x95: this.ZeroPageXAddress(); this.STA(); break; // STA (zero page, X)
|
||||
case 0x96: this.ZeroPageYAddress(); this.STX(); break; // STX (zero page, Y)
|
||||
case 0x98: this.TYA(); break; // TYA (implied)
|
||||
case 0x99: this.AbsoluteYAddress(); this.Fixup(); this.STA(); break; // STA (absolute, Y)
|
||||
case 0x9a: this.TXS(); break; // TXS (implied)
|
||||
case 0x9d: this.AbsoluteXAddress(); this.Fixup(); this.STA(); break; // STA (absolute, X)
|
||||
|
||||
case 0xa0: this.Y = this.Through(this.FetchByte()); break; // LDY (immediate)
|
||||
case 0xa1: this.A = this.Through(this.IndexedIndirectXRead()); break; // LDA (indexed indirect X)
|
||||
case 0xa2: this.X = this.Through(this.FetchByte()); break; // LDX (immediate)
|
||||
case 0xa4: this.ZeroPageRead(); this.Y = this.Through(); break; // LDY (zero page)
|
||||
case 0xa5: this.ZeroPageRead(); this.A = this.Through(); break; // LDA (zero page)
|
||||
case 0xa6: this.ZeroPageRead(); this.X = this.Through(); break; // LDX (zero page)
|
||||
case 0xa8: this.SwallowRead(); this.Y = this.Through(this.A); break; // TAY (implied)
|
||||
case 0xa9: this.A = this.Through(this.FetchByte()); break; // LDA (immediate)
|
||||
case 0xaa: this.SwallowRead(); this.X = this.Through(this.A); break; // TAX (implied)
|
||||
case 0xac: this.Y = this.Through(this.AbsoluteRead()); break; // LDY (absolute)
|
||||
case 0xad: this.A = this.Through(this.AbsoluteRead()); break; // LDA (absolute)
|
||||
case 0xae: this.X = this.Through(this.AbsoluteRead()); break; // LDX (absolute)
|
||||
case 0xa0: this.Immediate(); this.LDY(); break; // LDY (immediate)
|
||||
case 0xa1: this.IndexedIndirectX(); this.LDA(); break; // LDA (indexed indirect X)
|
||||
case 0xa2: this.Immediate(); this.LDX(); break; // LDX (immediate)
|
||||
case 0xa4: this.ZeroPage(); this.LDY(); break; // LDY (zero page)
|
||||
case 0xa5: this.ZeroPage(); this.LDA(); break; // LDA (zero page)
|
||||
case 0xa6: this.ZeroPage(); this.LDX(); break; // LDX (zero page)
|
||||
case 0xa8: this.TAY(); break; // TAY (implied)
|
||||
case 0xa9: this.Immediate(); this.LDA(); break; // LDA (immediate)
|
||||
case 0xaa: this.TAX(); break; // TAX (implied)
|
||||
case 0xac: this.Absolute(); this.LDY(); break; // LDY (absolute)
|
||||
case 0xad: this.Absolute(); this.LDA(); break; // LDA (absolute)
|
||||
case 0xae: this.Absolute(); this.LDX(); break; // LDX (absolute)
|
||||
|
||||
case 0xb0: this.Branch(this.Carry); break; // BCS (relative)
|
||||
case 0xb1: this.A = this.Through(this.IndirectIndexedYRead()); break; // LDA (indirect indexed Y)
|
||||
case 0xb4: this.ZeroPageXRead(); this.Y = this.Through(); break; // LDY (zero page, X)
|
||||
case 0xb5: this.ZeroPageXRead(); this.A = this.Through(); break; // LDA (zero page, X)
|
||||
case 0xb6: this.ZeroPageYRead(); this.X = this.Through(); break; // LDX (zero page, Y)
|
||||
case 0xb8: this.SwallowRead(); this.ResetFlag(StatusBits.VF); break; // CLV (implied)
|
||||
case 0xb9: this.AbsoluteYRead(); this.A = this.Through(); break; // LDA (absolute, Y)
|
||||
case 0xba: this.SwallowRead(); this.X = this.Through(this.S); break; // TSX (implied)
|
||||
case 0xbc: this.AbsoluteXRead(); this.Y = this.Through(); break; // LDY (absolute, X)
|
||||
case 0xbd: this.AbsoluteXRead(); this.A = this.Through(); break; // LDA (absolute, X)
|
||||
case 0xbe: this.AbsoluteYRead(); this.X = this.Through(); break; // LDX (absolute, Y)
|
||||
case 0xb0: this.BCS(); break; // BCS (relative)
|
||||
case 0xb1: this.IndirectIndexedY(); this.LDA(); break; // LDA (indirect indexed Y)
|
||||
case 0xb4: this.ZeroPageX(); this.LDY(); break; // LDY (zero page, X)
|
||||
case 0xb5: this.ZeroPageX(); this.LDA(); break; // LDA (zero page, X)
|
||||
case 0xb6: this.ZeroPageY(); this.LDX(); break; // LDX (zero page, Y)
|
||||
case 0xb8: this.CLV(); break; // CLV (implied)
|
||||
case 0xb9: this.AbsoluteY(); this.LDA(); break; // LDA (absolute, Y)
|
||||
case 0xba: this.TSX(); break; // TSX (implied)
|
||||
case 0xbc: this.AbsoluteX(); this.LDY(); break; // LDY (absolute, X)
|
||||
case 0xbd: this.AbsoluteX(); this.LDA(); break; // LDA (absolute, X)
|
||||
case 0xbe: this.AbsoluteY(); this.LDX(); break; // LDX (absolute, Y)
|
||||
|
||||
case 0xc0: this.CMP(this.Y, this.FetchByte()); break; // CPY (immediate)
|
||||
case 0xc1: this.CMP(this.A, this.IndexedIndirectXRead()); break; // CMP (indexed indirect X)
|
||||
case 0xc2: _ = this.FetchByte(); break; // *NOP (immediate)
|
||||
case 0xc4: this.CMP(this.Y, this.ZeroPageRead()); break; // CPY (zero page)
|
||||
case 0xc5: this.CMP(this.A, this.ZeroPageRead()); break; // CMP (zero page)
|
||||
case 0xc6: this.ZeroPageRead(); this.ModifyWrite(this.DEC()); break; // DEC (zero page)
|
||||
case 0xc8: this.SwallowRead(); this.Y = this.INC(this.Y); break; // INY (implied)
|
||||
case 0xc9: this.CMP(this.A, this.FetchByte()); break; // CMP (immediate)
|
||||
case 0xca: this.SwallowRead(); this.X = this.DEC(this.X); break; // DEX (implied)
|
||||
case 0xcc: this.CMP(this.Y, this.AbsoluteRead()); break; // CPY (absolute)
|
||||
case 0xcd: this.CMP(this.A, this.AbsoluteRead()); break; // CMP (absolute)
|
||||
case 0xce: this.AbsoluteRead(); this.ModifyWrite(this.DEC()); break; // DEC (absolute)
|
||||
case 0xc0: this.Immediate(); this.CPY(); break; // CPY (immediate)
|
||||
case 0xc1: this.IndexedIndirectX(); this.CMP(); break; // CMP (indexed indirect X)
|
||||
case 0xc2: this.Immediate(); break; // *NOP (immediate)
|
||||
case 0xc4: this.ZeroPage(); this.CPY(); break; // CPY (zero page)
|
||||
case 0xc5: this.ZeroPage(); this.CMP(); break; // CMP (zero page)
|
||||
case 0xc6: this.ZeroPage(); this.DEC(); break; // DEC (zero page)
|
||||
case 0xc8: this.INY(); break; // INY (implied)
|
||||
case 0xc9: this.Immediate(); this.CMP(); break; // CMP (immediate)
|
||||
case 0xca: this.DEX(); break; // DEX (implied)
|
||||
case 0xcc: this.Absolute(); this.CPY(); break; // CPY (absolute)
|
||||
case 0xcd: this.Absolute(); this.CMP(); break; // CMP (absolute)
|
||||
case 0xce: this.Absolute(); this.DEC(); break; // DEC (absolute)
|
||||
|
||||
case 0xd0: this.BranchNot(this.Zero); break; // BNE (relative)
|
||||
case 0xd1: this.CMP(this.A, this.IndirectIndexedYRead()); break; // CMP (indirect indexed Y)
|
||||
case 0xd4: this.ZeroPageXRead(); break; // *NOP (zero page, X)
|
||||
case 0xd5: this.CMP(this.A, this.ZeroPageXRead()); break; // CMP (zero page, X)
|
||||
case 0xd6: this.ZeroPageXRead(); this.ModifyWrite(this.DEC()); break; // DEC (zero page, X)
|
||||
case 0xd8: this.SwallowRead(); this.ResetFlag(StatusBits.DF); break; // CLD (implied)
|
||||
case 0xd9: this.CMP(this.A, this.AbsoluteYRead()); break; // CMP (absolute, Y)
|
||||
case 0xdd: this.CMP(this.A, this.AbsoluteXRead()); break; // CMP (absolute, X)
|
||||
case 0xde: this.AbsoluteXAddress(); this.FixupRead(); this.ModifyWrite(this.DEC()); break; // DEC (absolute, X)
|
||||
case 0xd0: this.BNE(); break; // BNE (relative)
|
||||
case 0xd1: this.IndirectIndexedY(); this.CMP(); break; // CMP (indirect indexed Y)
|
||||
case 0xd4: this.ZeroPageX(); break; // *NOP (zero page, X)
|
||||
case 0xd5: this.ZeroPageX(); this.CMP(); break; // CMP (zero page, X)
|
||||
case 0xd6: this.ZeroPageX(); this.DEC(); break; // DEC (zero page, X)
|
||||
case 0xd8: this.CLD(); break; // CLD (implied)
|
||||
case 0xd9: this.AbsoluteY(); this.CMP(); break; // CMP (absolute, Y)
|
||||
case 0xdd: this.AbsoluteX(); this.CMP(); break; // CMP (absolute, X)
|
||||
case 0xde: this.AbsoluteXAddress(); this.FixupRead(); this.DEC(); break; // DEC (absolute, X)
|
||||
|
||||
case 0xe0: this.CMP(this.X, this.FetchByte()); break; // CPX (immediate)
|
||||
case 0xe1: this.IndexedIndirectXRead(); this.SBC(); break; // SBC (indexed indirect X)
|
||||
case 0xe2: _ = this.FetchByte(); break; // *NOP (immediate)
|
||||
case 0xe4: this.CMP(this.X, this.ZeroPageRead()); break; // CPX (zero page)
|
||||
case 0xe5: this.ZeroPageRead(); this.SBC(); break; // SBC (zero page)
|
||||
case 0xe6: this.ZeroPageRead(); this.ModifyWrite(this.INC()); break; // INC (zero page)
|
||||
case 0xe8: this.SwallowRead(); this.X = this.INC(this.X); break; // INX (implied)
|
||||
case 0xe9: _ = this.FetchByte(); this.SBC(); break; // SBC (immediate)
|
||||
case 0xea: this.SwallowRead(); break; // NOP (implied)
|
||||
case 0xec: this.CMP(this.X, this.AbsoluteRead()); break; // CPX (absolute)
|
||||
case 0xed: this.AbsoluteRead(); this.SBC(); break; // SBC (absolute)
|
||||
case 0xee: this.AbsoluteRead(); this.ModifyWrite(this.INC()); break; // INC (absolute)
|
||||
case 0xe0: this.Immediate(); this.CPX(); break; // CPX (immediate)
|
||||
case 0xe1: this.IndexedIndirectX(); this.SBC(); break; // SBC (indexed indirect X)
|
||||
case 0xe2: this.Immediate(); break; // *NOP (immediate)
|
||||
case 0xe4: this.ZeroPage(); this.CPX(); break; // CPX (zero page)
|
||||
case 0xe5: this.ZeroPage(); this.SBC(); break; // SBC (zero page)
|
||||
case 0xe6: this.ZeroPage(); this.INC(); break; // INC (zero page)
|
||||
case 0xe8: this.INX(); break; // INX (implied)
|
||||
case 0xe9: this.Immediate(); this.SBC(); break; // SBC (immediate)
|
||||
case 0xea: this.NOP(); break; // NOP (implied)
|
||||
case 0xec: this.Absolute(); this.CPX(); break; // CPX (absolute)
|
||||
case 0xed: this.Absolute(); this.SBC(); break; // SBC (absolute)
|
||||
case 0xee: this.Absolute(); this.INC(); break; // INC (absolute)
|
||||
|
||||
case 0xf0: this.Branch(this.Zero); break; // BEQ (relative)
|
||||
case 0xf1: this.IndirectIndexedYRead(); this.SBC(); break; // SBC (indirect indexed Y)
|
||||
case 0xf4: this.ZeroPageXRead(); break; // *NOP (zero page, X)
|
||||
case 0xf5: this.ZeroPageXRead(); this.SBC(); break; // SBC (zero page, X)
|
||||
case 0xf6: this.ZeroPageXRead(); this.ModifyWrite(this.INC()); break; // INC (zero page, X)
|
||||
case 0xf8: this.SwallowRead(); this.SetFlag(StatusBits.DF); break; // SED (implied)
|
||||
case 0xf9: this.AbsoluteYRead(); this.SBC(); break; // SBC (absolute, Y)
|
||||
case 0xfd: this.AbsoluteXRead(); this.SBC(); break; // SBC (absolute, X)
|
||||
case 0xfe: this.AbsoluteXAddress(); this.FixupRead(); this.ModifyWrite(this.INC()); break; // INC (absolute, X)
|
||||
case 0xf0: this.BEQ(); break; // BEQ (relative)
|
||||
case 0xf1: this.IndirectIndexedY(); this.SBC(); break; // SBC (indirect indexed Y)
|
||||
case 0xf4: this.ZeroPageX(); break; // *NOP (zero page, X)
|
||||
case 0xf5: this.ZeroPageX(); this.SBC(); break; // SBC (zero page, X)
|
||||
case 0xf6: this.ZeroPageX(); this.INC(); break; // INC (zero page, X)
|
||||
case 0xf8: this.SED(); break; // SED (implied)
|
||||
case 0xf9: this.AbsoluteY(); this.SBC(); break; // SBC (absolute, Y)
|
||||
case 0xfd: this.AbsoluteX(); this.SBC(); break; // SBC (absolute, X)
|
||||
case 0xfe: this.AbsoluteXAddress(); this.FixupRead(); this.INC(); break; // INC (absolute, X)
|
||||
|
||||
default:
|
||||
break;
|
||||
@@ -678,7 +676,7 @@ namespace M6502
|
||||
|
||||
protected void ZeroPageWithIndexAddress(byte index)
|
||||
{
|
||||
this.ZeroPageRead();
|
||||
this.ZeroPage();
|
||||
this.Bus.Address.Low += index;
|
||||
}
|
||||
|
||||
@@ -712,49 +710,51 @@ namespace M6502
|
||||
|
||||
#region Address and read
|
||||
|
||||
protected byte AbsoluteRead()
|
||||
protected byte Immediate() => this.FetchByte();
|
||||
|
||||
protected byte Absolute()
|
||||
{
|
||||
this.AbsoluteAddress();
|
||||
return this.MemoryRead();
|
||||
}
|
||||
|
||||
protected byte ZeroPageRead()
|
||||
protected byte ZeroPage()
|
||||
{
|
||||
this.ZeroPageAddress();
|
||||
return this.MemoryRead();
|
||||
}
|
||||
|
||||
protected byte ZeroPageXRead()
|
||||
protected byte ZeroPageX()
|
||||
{
|
||||
this.ZeroPageXAddress();
|
||||
return this.MemoryRead();
|
||||
}
|
||||
|
||||
protected byte ZeroPageYRead()
|
||||
protected byte ZeroPageY()
|
||||
{
|
||||
this.ZeroPageYAddress();
|
||||
return this.MemoryRead();
|
||||
}
|
||||
|
||||
protected byte IndexedIndirectXRead()
|
||||
protected byte IndexedIndirectX()
|
||||
{
|
||||
this.IndexedIndirectXAddress();
|
||||
return this.MemoryRead();
|
||||
}
|
||||
|
||||
protected byte AbsoluteXRead()
|
||||
protected byte AbsoluteX()
|
||||
{
|
||||
this.AbsoluteXAddress();
|
||||
return this.MaybeFixupRead();
|
||||
}
|
||||
|
||||
protected byte AbsoluteYRead()
|
||||
protected byte AbsoluteY()
|
||||
{
|
||||
this.AbsoluteYAddress();
|
||||
return this.MaybeFixupRead();
|
||||
}
|
||||
|
||||
protected byte IndirectIndexedYRead()
|
||||
protected byte IndirectIndexedY()
|
||||
{
|
||||
this.IndirectIndexedYAddress();
|
||||
return this.MaybeFixupRead();
|
||||
@@ -812,6 +812,150 @@ namespace M6502
|
||||
|
||||
#region Instruction implementations
|
||||
|
||||
#region Miscellaneous
|
||||
|
||||
private void NOP() => this.SwallowRead();
|
||||
|
||||
protected void JMP() => this.Jump(this.Bus.Address);
|
||||
|
||||
private void BRK()
|
||||
{
|
||||
this.SwallowFetch();
|
||||
this.Interrupt(IRQ_vector, InterruptSource.software);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Register to register transfer
|
||||
|
||||
private void TAX()
|
||||
{
|
||||
this.SwallowRead();
|
||||
this.X = this.Through(this.A);
|
||||
}
|
||||
|
||||
private void TXA()
|
||||
{
|
||||
this.SwallowRead();
|
||||
this.A = this.Through(this.X);
|
||||
}
|
||||
|
||||
private void TAY()
|
||||
{
|
||||
this.SwallowRead();
|
||||
this.Y = this.Through(this.A);
|
||||
}
|
||||
|
||||
private void TYA()
|
||||
{
|
||||
this.SwallowRead();
|
||||
this.A = this.Through(this.Y);
|
||||
}
|
||||
|
||||
private void TXS()
|
||||
{
|
||||
this.SwallowRead();
|
||||
this.S = this.X;
|
||||
}
|
||||
|
||||
private void TSX()
|
||||
{
|
||||
this.SwallowRead();
|
||||
this.X = this.Through(this.S);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Load and store
|
||||
|
||||
protected void LDA() => this.A = this.Through();
|
||||
|
||||
protected void STA() => this.MemoryWrite(this.A);
|
||||
|
||||
protected void LDX() => this.X = this.Through();
|
||||
|
||||
private void STX() => this.MemoryWrite(this.X);
|
||||
|
||||
private void LDY() => this.Y = this.Through();
|
||||
|
||||
private void STY() => this.MemoryWrite(this.Y);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Branching
|
||||
|
||||
private void BCS() => this.Branch(this.Carry);
|
||||
|
||||
private void BCC() => this.BranchNot(this.Carry);
|
||||
|
||||
private void BVC() => this.BranchNot(this.Overflow);
|
||||
|
||||
private void BMI() => this.Branch(this.Negative);
|
||||
|
||||
private void BPL() => this.BranchNot(this.Negative);
|
||||
|
||||
private void BVS() => this.Branch(this.Overflow);
|
||||
|
||||
private void BEQ() => this.Branch(this.Zero);
|
||||
|
||||
private void BNE() => this.BranchNot(this.Zero);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Status flag operations
|
||||
|
||||
private void SEI()
|
||||
{
|
||||
this.SwallowRead();
|
||||
this.SetFlag(StatusBits.IF);
|
||||
}
|
||||
|
||||
private void CLI()
|
||||
{
|
||||
this.SwallowRead();
|
||||
this.ResetFlag(StatusBits.IF);
|
||||
}
|
||||
|
||||
private void CLV()
|
||||
{
|
||||
this.SwallowRead();
|
||||
this.ResetFlag(StatusBits.VF);
|
||||
}
|
||||
|
||||
protected void SetCarry() => this.SetFlag(StatusBits.CF);
|
||||
|
||||
private void SEC()
|
||||
{
|
||||
this.SwallowRead();
|
||||
this.SetCarry();
|
||||
}
|
||||
|
||||
protected void ClearCarry() => this.ResetFlag(StatusBits.CF);
|
||||
|
||||
private void CLC()
|
||||
{
|
||||
this.SwallowRead();
|
||||
this.ClearCarry();
|
||||
}
|
||||
|
||||
protected void SetDecimal() => this.SetFlag(StatusBits.DF);
|
||||
|
||||
private void SED()
|
||||
{
|
||||
this.SwallowRead();
|
||||
this.SetDecimal();
|
||||
}
|
||||
|
||||
protected void ClearDecimal() => this.ResetFlag(StatusBits.DF);
|
||||
|
||||
private void CLD()
|
||||
{
|
||||
this.SwallowRead();
|
||||
this.ClearDecimal();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Instructions with BCD effects
|
||||
|
||||
#region Addition/subtraction
|
||||
@@ -877,6 +1021,8 @@ namespace M6502
|
||||
this.SetFlag(StatusBits.VF, NegativeTest((byte)(~(operand ^ data) & (operand ^ intermediate))));
|
||||
}
|
||||
|
||||
protected void ADC() => this.ADC(this.Bus.Data);
|
||||
|
||||
protected void ADC(byte data) => this.A = this.DecimalMasked != 0 ? this.DecimalADC(data) : this.BinaryADC(data);
|
||||
|
||||
private byte BinaryADC(byte data)
|
||||
@@ -928,17 +1074,17 @@ namespace M6502
|
||||
|
||||
#region Bitwise operations
|
||||
|
||||
protected void OrR(byte data) => this.A = this.Through(this.A | data);
|
||||
protected void ORA() => this.ORA(this.Bus.Data);
|
||||
|
||||
protected void OrR() => this.OrR(this.Bus.Data);
|
||||
protected void ORA(byte data) => this.A = this.Through(this.A | data);
|
||||
|
||||
protected void AndR(byte data) => this.A = this.Through(this.A & data);
|
||||
protected void AND() => this.AND(this.Bus.Data);
|
||||
|
||||
protected void AndR() => this.AndR(this.Bus.Data);
|
||||
protected void AND(byte data) => this.A = this.Through(this.A & data);
|
||||
|
||||
protected void EorR(byte data) => this.A = this.Through(this.A ^ data);
|
||||
protected void EOR() => this.EOR(this.Bus.Data);
|
||||
|
||||
protected void EorR() => this.EorR(this.Bus.Data);
|
||||
protected void EOR(byte data) => this.A = this.Through(this.A ^ data);
|
||||
|
||||
protected void BIT()
|
||||
{
|
||||
@@ -950,6 +1096,14 @@ namespace M6502
|
||||
|
||||
#endregion
|
||||
|
||||
#region Comparison operations
|
||||
|
||||
protected void CMP() => this.CMP(this.A, this.Bus.Data);
|
||||
|
||||
private void CPX() => this.CMP(this.X, this.Bus.Data);
|
||||
|
||||
private void CPY() => this.CMP(this.Y, this.Bus.Data);
|
||||
|
||||
protected void CMP(byte first, byte second)
|
||||
{
|
||||
this.Intermediate.Word = (ushort)(first - second);
|
||||
@@ -957,13 +1111,39 @@ namespace M6502
|
||||
this.ResetFlag(StatusBits.CF, this.Intermediate.High);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Increment/decrement
|
||||
|
||||
protected byte DEC() => this.DEC(this.Bus.Data);
|
||||
private void DEX()
|
||||
{
|
||||
this.SwallowRead();
|
||||
this.X = this.DEC(this.X);
|
||||
}
|
||||
|
||||
private void DEY()
|
||||
{
|
||||
this.SwallowRead();
|
||||
this.Y = this.DEC(this.Y);
|
||||
}
|
||||
|
||||
protected void DEC() => this.ModifyWrite(this.DEC(this.Bus.Data));
|
||||
|
||||
protected byte DEC(byte value) => this.Through(value - 1);
|
||||
|
||||
protected byte INC() => this.INC(this.Bus.Data);
|
||||
private void INX()
|
||||
{
|
||||
this.SwallowRead();
|
||||
this.X = this.INC(this.X);
|
||||
}
|
||||
|
||||
private void INY()
|
||||
{
|
||||
this.SwallowRead();
|
||||
this.Y = this.INC(this.Y);
|
||||
}
|
||||
|
||||
protected void INC() => this.ModifyWrite(this.INC(this.Bus.Data));
|
||||
|
||||
protected byte INC(byte value) => this.Through(value + 1);
|
||||
|
||||
@@ -980,10 +1160,28 @@ namespace M6502
|
||||
this.PC.Assign(low, high);
|
||||
}
|
||||
|
||||
private void PHP() => this.Push(SetBit(this.P, StatusBits.BF));
|
||||
private void PHA()
|
||||
{
|
||||
this.SwallowRead();
|
||||
this.Push(this.A);
|
||||
}
|
||||
|
||||
private void PLA()
|
||||
{
|
||||
this.SwallowRead();
|
||||
this.SwallowPop();
|
||||
this.A = this.Through(this.Pop());
|
||||
}
|
||||
|
||||
private void PHP()
|
||||
{
|
||||
this.SwallowRead();
|
||||
this.Push(SetBit(this.P, StatusBits.BF));
|
||||
}
|
||||
|
||||
private void PLP()
|
||||
{
|
||||
this.SwallowRead();
|
||||
this.SwallowPop();
|
||||
this.Pop();
|
||||
this.P = ClearBit(SetBit(this.Bus.Data, StatusBits.RF), StatusBits.BF);
|
||||
@@ -995,6 +1193,12 @@ namespace M6502
|
||||
base.Return();
|
||||
}
|
||||
|
||||
protected void RTS()
|
||||
{
|
||||
this.SwallowRead();
|
||||
this.Return();
|
||||
}
|
||||
|
||||
protected override void Return()
|
||||
{
|
||||
this.SwallowPop();
|
||||
@@ -1008,7 +1212,13 @@ namespace M6502
|
||||
|
||||
#region Shift
|
||||
|
||||
protected byte ASL() => this.ASL(this.Bus.Data);
|
||||
private void ASLA()
|
||||
{
|
||||
this.SwallowRead();
|
||||
this.A = this.ASL(this.A);
|
||||
}
|
||||
|
||||
protected void ASL() => this.ModifyWrite(this.ASL(this.Bus.Data));
|
||||
|
||||
protected byte ASL(byte value)
|
||||
{
|
||||
@@ -1016,7 +1226,15 @@ namespace M6502
|
||||
return this.Through(value << 1);
|
||||
}
|
||||
|
||||
protected byte LSR() => this.LSR(this.Bus.Data);
|
||||
protected void ImplementLSRA() => this.A = this.LSR(this.A);
|
||||
|
||||
private void LSRA()
|
||||
{
|
||||
this.SwallowRead();
|
||||
ImplementLSRA();
|
||||
}
|
||||
|
||||
protected void LSR() => this.ModifyWrite(this.LSR(this.Bus.Data));
|
||||
|
||||
protected byte LSR(byte value)
|
||||
{
|
||||
@@ -1028,7 +1246,13 @@ namespace M6502
|
||||
|
||||
#region Rotate
|
||||
|
||||
protected byte ROL() => this.ROL(this.Bus.Data);
|
||||
private void ROLA()
|
||||
{
|
||||
this.SwallowRead();
|
||||
this.A = this.ROL(this.A);
|
||||
}
|
||||
|
||||
protected void ROL() => this.ModifyWrite(this.ROL(this.Bus.Data));
|
||||
|
||||
protected byte ROL(byte value)
|
||||
{
|
||||
@@ -1036,7 +1260,13 @@ namespace M6502
|
||||
return this.Through(this.ASL(value) | carryIn);
|
||||
}
|
||||
|
||||
protected byte ROR() => this.ROR(this.Bus.Data);
|
||||
private void RORA()
|
||||
{
|
||||
this.SwallowRead();
|
||||
this.A = this.ROR(this.A);
|
||||
}
|
||||
|
||||
protected void ROR() => this.ModifyWrite(this.ROR(this.Bus.Data));
|
||||
|
||||
protected byte ROR(byte value)
|
||||
{
|
||||
|
||||
+122
-132
@@ -20,119 +20,119 @@ namespace M6502
|
||||
var cycles = this.Cycles;
|
||||
switch (this.OpCode)
|
||||
{
|
||||
case 0x02: this.Jam(); break; // *JAM
|
||||
case 0x03: this.IndexedIndirectXRead(); this.SLO(); break; // *SLO (indexed indirect X)
|
||||
case 0x04: this.ZeroPageRead(); break; // *NOP (zero page)
|
||||
case 0x07: this.ZeroPageRead(); this.SLO(); break; // *SLO (zero page)
|
||||
case 0x0b: this.FetchByte(); this.ANC(); break; // *ANC (immediate)
|
||||
case 0x0c: this.AbsoluteRead(); break; // *NOP (absolute)
|
||||
case 0x0f: this.AbsoluteRead(); this.SLO(); break; // *SLO (absolute)
|
||||
case 0x02: this.JAM(); break; // *JAM
|
||||
case 0x03: this.IndexedIndirectX(); this.SLO(); break; // *SLO (indexed indirect X)
|
||||
case 0x04: this.ZeroPage(); break; // *NOP (zero page)
|
||||
case 0x07: this.ZeroPage(); this.SLO(); break; // *SLO (zero page)
|
||||
case 0x0b: this.FetchByte(); this.ANC(); break; // *ANC (immediate)
|
||||
case 0x0c: this.Absolute(); break; // *NOP (absolute)
|
||||
case 0x0f: this.Absolute(); this.SLO(); break; // *SLO (absolute)
|
||||
|
||||
case 0x12: this.Jam(); break; // *JAM
|
||||
case 0x13: this.IndirectIndexedYAddress(); this.FixupRead(); this.SLO(); break; // *SLO (indirect indexed Y)
|
||||
case 0x14: this.ZeroPageXRead(); break; // *NOP (zero page, X)
|
||||
case 0x17: this.ZeroPageXRead(); this.SLO(); break; // *SLO (zero page, X)
|
||||
case 0x1a: this.SwallowRead(); break; // *NOP (implied)
|
||||
case 0x1b: this.AbsoluteYAddress(); this.FixupRead(); this.SLO(); break; // *SLO (absolute, Y)
|
||||
case 0x1c: this.AbsoluteXAddress(); this.MaybeFixupRead(); break; // *NOP (absolute, X)
|
||||
case 0x1f: this.AbsoluteXAddress(); this.FixupRead(); this.SLO(); break; // *SLO (absolute, X)
|
||||
case 0x12: this.JAM(); break; // *JAM
|
||||
case 0x13: this.IndirectIndexedYAddress(); this.FixupRead(); this.SLO(); break; // *SLO (indirect indexed Y)
|
||||
case 0x14: this.ZeroPageX(); break; // *NOP (zero page, X)
|
||||
case 0x17: this.ZeroPageX(); this.SLO(); break; // *SLO (zero page, X)
|
||||
case 0x1a: this.SwallowRead(); break; // *NOP (implied)
|
||||
case 0x1b: this.AbsoluteYAddress(); this.FixupRead(); this.SLO(); break; // *SLO (absolute, Y)
|
||||
case 0x1c: this.AbsoluteXAddress(); this.MaybeFixupRead(); break; // *NOP (absolute, X)
|
||||
case 0x1f: this.AbsoluteXAddress(); this.FixupRead(); this.SLO(); break; // *SLO (absolute, X)
|
||||
|
||||
case 0x22: this.Jam(); break; // *JAM
|
||||
case 0x23: this.IndexedIndirectXRead(); this.RLA(); ; break; // *RLA (indexed indirect X)
|
||||
case 0x27: this.ZeroPageRead(); this.RLA(); ; break; // *RLA (zero page)
|
||||
case 0x2b: this.FetchByte(); this.ANC(); break; // *ANC (immediate)
|
||||
case 0x2f: this.AbsoluteRead(); this.RLA(); break; // *RLA (absolute)
|
||||
case 0x22: this.JAM(); break; // *JAM
|
||||
case 0x23: this.IndexedIndirectX(); this.RLA(); ; break; // *RLA (indexed indirect X)
|
||||
case 0x27: this.ZeroPage(); this.RLA(); ; break; // *RLA (zero page)
|
||||
case 0x2b: this.FetchByte(); this.ANC(); break; // *ANC (immediate)
|
||||
case 0x2f: this.Absolute(); this.RLA(); break; // *RLA (absolute)
|
||||
|
||||
case 0x32: this.Jam(); break; // *JAM
|
||||
case 0x33: this.IndirectIndexedYAddress(); this.FixupRead(); this.RLA(); break; // *RLA (indirect indexed Y)
|
||||
case 0x34: this.ZeroPageXRead(); break; // *NOP (zero page, X)
|
||||
case 0x37: this.ZeroPageXRead(); this.RLA(); ; break; // *RLA (zero page, X)
|
||||
case 0x3a: this.SwallowRead(); break; // *NOP (implied)
|
||||
case 0x3b: this.AbsoluteYAddress(); this.FixupRead(); this.RLA(); break; // *RLA (absolute, Y)
|
||||
case 0x3c: this.AbsoluteXAddress(); this.MaybeFixupRead(); break; // *NOP (absolute, X)
|
||||
case 0x3f: this.AbsoluteXAddress(); this.FixupRead(); this.RLA(); break; // *RLA (absolute, X)
|
||||
case 0x32: this.JAM(); break; // *JAM
|
||||
case 0x33: this.IndirectIndexedYAddress(); this.FixupRead(); this.RLA(); break; // *RLA (indirect indexed Y)
|
||||
case 0x34: this.ZeroPageX(); break; // *NOP (zero page, X)
|
||||
case 0x37: this.ZeroPageX(); this.RLA(); ; break; // *RLA (zero page, X)
|
||||
case 0x3a: this.SwallowRead(); break; // *NOP (implied)
|
||||
case 0x3b: this.AbsoluteYAddress(); this.FixupRead(); this.RLA(); break; // *RLA (absolute, Y)
|
||||
case 0x3c: this.AbsoluteXAddress(); this.MaybeFixupRead(); break; // *NOP (absolute, X)
|
||||
case 0x3f: this.AbsoluteXAddress(); this.FixupRead(); this.RLA(); break; // *RLA (absolute, X)
|
||||
|
||||
case 0x42: this.Jam(); break; // *JAM
|
||||
case 0x43: this.IndexedIndirectXRead(); this.SRE(); break; // *SRE (indexed indirect X)
|
||||
case 0x47: this.ZeroPageRead(); this.SRE(); break; // *SRE (zero page)
|
||||
case 0x4b: this.FetchByte(); this.ASR(); break; // *ASR (immediate)
|
||||
case 0x4f: this.AbsoluteRead(); this.SRE(); break; // *SRE (absolute)
|
||||
case 0x42: this.JAM(); break; // *JAM
|
||||
case 0x43: this.IndexedIndirectX(); this.SRE(); break; // *SRE (indexed indirect X)
|
||||
case 0x47: this.ZeroPage(); this.SRE(); break; // *SRE (zero page)
|
||||
case 0x4b: this.FetchByte(); this.ASR(); break; // *ASR (immediate)
|
||||
case 0x4f: this.Absolute(); this.SRE(); break; // *SRE (absolute)
|
||||
|
||||
case 0x52: this.Jam(); break; // *JAM
|
||||
case 0x53: this.IndirectIndexedYAddress(); this.FixupRead(); this.SRE(); break; // *SRE (indirect indexed Y)
|
||||
case 0x57: this.ZeroPageXRead(); this.SRE(); break; // *SRE (zero page, X)
|
||||
case 0x5a: this.SwallowRead(); break; // *NOP (implied)
|
||||
case 0x5b: this.AbsoluteYAddress(); this.FixupRead(); this.SRE(); break; // *SRE (absolute, Y)
|
||||
case 0x5c: this.AbsoluteXAddress(); this.MaybeFixupRead(); break; // *NOP (absolute, X)
|
||||
case 0x5f: this.AbsoluteXAddress(); this.FixupRead(); this.SRE(); break; // *SRE (absolute, X)
|
||||
case 0x52: this.JAM(); break; // *JAM
|
||||
case 0x53: this.IndirectIndexedYAddress(); this.FixupRead(); this.SRE(); break; // *SRE (indirect indexed Y)
|
||||
case 0x57: this.ZeroPageX(); this.SRE(); break; // *SRE (zero page, X)
|
||||
case 0x5a: this.SwallowRead(); break; // *NOP (implied)
|
||||
case 0x5b: this.AbsoluteYAddress(); this.FixupRead(); this.SRE(); break; // *SRE (absolute, Y)
|
||||
case 0x5c: this.AbsoluteXAddress(); this.MaybeFixupRead(); break; // *NOP (absolute, X)
|
||||
case 0x5f: this.AbsoluteXAddress(); this.FixupRead(); this.SRE(); break; // *SRE (absolute, X)
|
||||
|
||||
case 0x62: this.Jam(); break; // *JAM
|
||||
case 0x63: this.IndexedIndirectXRead(); this.RRA(); break; // *RRA (indexed indirect X)
|
||||
case 0x64: this.ZeroPageRead(); break; // *NOP (zero page)
|
||||
case 0x67: this.ZeroPageRead(); this.RRA(); break; // *RRA (zero page)
|
||||
case 0x6b: this.FetchByte(); this.ARR(); break; // *ARR (immediate)
|
||||
case 0x6f: this.AbsoluteRead(); this.RRA(); break; // *RRA (absolute)
|
||||
case 0x62: this.JAM(); break; // *JAM
|
||||
case 0x63: this.IndexedIndirectX(); this.RRA(); break; // *RRA (indexed indirect X)
|
||||
case 0x64: this.ZeroPage(); break; // *NOP (zero page)
|
||||
case 0x67: this.ZeroPage(); this.RRA(); break; // *RRA (zero page)
|
||||
case 0x6b: this.FetchByte(); this.ARR(); break; // *ARR (immediate)
|
||||
case 0x6f: this.Absolute(); this.RRA(); break; // *RRA (absolute)
|
||||
|
||||
case 0x72: this.Jam(); break; // *JAM
|
||||
case 0x73: this.IndirectIndexedYAddress(); this.FixupRead(); this.RRA(); break; // *RRA (indirect indexed Y)
|
||||
case 0x74: this.ZeroPageXRead(); break; // *NOP (zero page, X)
|
||||
case 0x77: this.ZeroPageXRead(); this.RRA(); break; // *RRA (zero page, X)
|
||||
case 0x7a: this.SwallowRead(); break; // *NOP (implied)
|
||||
case 0x7b: this.AbsoluteYAddress(); this.FixupRead(); this.RRA(); break; // *RRA (absolute, Y)
|
||||
case 0x7c: this.AbsoluteXAddress(); this.MaybeFixupRead(); break; // *NOP (absolute, X)
|
||||
case 0x7f: this.AbsoluteXAddress(); this.FixupRead(); this.RRA(); break; // *RRA (absolute, X)
|
||||
case 0x72: this.JAM(); break; // *JAM
|
||||
case 0x73: this.IndirectIndexedYAddress(); this.FixupRead(); this.RRA(); break; // *RRA (indirect indexed Y)
|
||||
case 0x74: this.ZeroPageX(); break; // *NOP (zero page, X)
|
||||
case 0x77: this.ZeroPageX(); this.RRA(); break; // *RRA (zero page, X)
|
||||
case 0x7a: this.SwallowRead(); break; // *NOP (implied)
|
||||
case 0x7b: this.AbsoluteYAddress(); this.FixupRead(); this.RRA(); break; // *RRA (absolute, Y)
|
||||
case 0x7c: this.AbsoluteXAddress(); this.MaybeFixupRead(); break; // *NOP (absolute, X)
|
||||
case 0x7f: this.AbsoluteXAddress(); this.FixupRead(); this.RRA(); break; // *RRA (absolute, X)
|
||||
|
||||
case 0x80: this.FetchByte(); break; // *NOP (immediate)
|
||||
case 0x83: this.IndexedIndirectXAddress(); this.SAX(); break; // *SAX (indexed indirect X)
|
||||
case 0x87: this.ZeroPageAddress(); this.SAX(); break; // *SAX (zero page)
|
||||
case 0x89: this.FetchByte(); break; // *NOP (immediate)
|
||||
case 0x8b: this.FetchByte(); this.ANE(); break; // *ANE (immediate)
|
||||
case 0x8f: this.AbsoluteAddress(); this.SAX(); break; // *SAX (absolute)
|
||||
case 0x80: this.FetchByte(); break; // *NOP (immediate)
|
||||
case 0x83: this.IndexedIndirectXAddress(); this.SAX(); break; // *SAX (indexed indirect X)
|
||||
case 0x87: this.ZeroPageAddress(); this.SAX(); break; // *SAX (zero page)
|
||||
case 0x89: this.FetchByte(); break; // *NOP (immediate)
|
||||
case 0x8b: this.FetchByte(); this.ANE(); break; // *ANE (immediate)
|
||||
case 0x8f: this.AbsoluteAddress(); this.SAX(); break; // *SAX (absolute)
|
||||
|
||||
case 0x92: this.Jam(); break; // *JAM
|
||||
case 0x93: this.IndirectIndexedYAddress(); this.Fixup(); this.SHA(); break; // *SHA (indirect indexed, Y) (XXXX)
|
||||
case 0x97: this.ZeroPageYAddress(); this.SAX(); break; // *SAX (zero page, Y)
|
||||
case 0x9b: this.AbsoluteYAddress(); this.Fixup(); this.TAS(); break; // *TAS (absolute, Y) (XXXX)
|
||||
case 0x9c: this.AbsoluteXAddress(); this.Fixup(); this.SYA(); break; // *SYA (absolute, X) (XXXX)
|
||||
case 0x9e: this.AbsoluteYAddress(); this.Fixup(); this.SXA(); break; // *SXA (absolute, Y) (XXXX)
|
||||
case 0x9f: this.AbsoluteYAddress(); this.Fixup(); this.SHA(); break; // *SHA (absolute, Y) (XXXX)
|
||||
case 0x92: this.JAM(); break; // *JAM
|
||||
case 0x93: this.IndirectIndexedYAddress(); this.Fixup(); this.SHA(); break; // *SHA (indirect indexed, Y)
|
||||
case 0x97: this.ZeroPageYAddress(); this.SAX(); break; // *SAX (zero page, Y)
|
||||
case 0x9b: this.AbsoluteYAddress(); this.Fixup(); this.TAS(); break; // *TAS (absolute, Y)
|
||||
case 0x9c: this.AbsoluteXAddress(); this.Fixup(); this.SYA(); break; // *SYA (absolute, X)
|
||||
case 0x9e: this.AbsoluteYAddress(); this.Fixup(); this.SXA(); break; // *SXA (absolute, Y)
|
||||
case 0x9f: this.AbsoluteYAddress(); this.Fixup(); this.SHA(); break; // *SHA (absolute, Y)
|
||||
|
||||
case 0xa3: this.IndexedIndirectXRead(); this.LAX(); break; // *LAX (indexed indirect X)
|
||||
case 0xa7: this.ZeroPageRead(); this.LAX(); break; // *LAX (zero page)
|
||||
case 0xab: this.FetchByte(); this.ATX(); break; // *ATX (immediate)
|
||||
case 0xaf: this.AbsoluteRead(); this.LAX(); break; // *LAX (absolute)
|
||||
case 0xa3: this.IndexedIndirectX(); this.LAX(); break; // *LAX (indexed indirect X)
|
||||
case 0xa7: this.ZeroPage(); this.LAX(); break; // *LAX (zero page)
|
||||
case 0xab: this.FetchByte(); this.ATX(); break; // *ATX (immediate)
|
||||
case 0xaf: this.Absolute(); this.LAX(); break; // *LAX (absolute)
|
||||
|
||||
case 0xb2: this.Jam(); break; // *JAM
|
||||
case 0xb3: this.IndirectIndexedYRead(); this.LAX(); break; // *LAX (indirect indexed Y)
|
||||
case 0xb7: this.ZeroPageYRead(); this.LAX(); break; // *LAX (zero page, Y)
|
||||
case 0xbb: this.AbsoluteYAddress(); this.MaybeFixup(); this.LAS(); break; // *LAS (absolute, Y)
|
||||
case 0xbf: this.AbsoluteYRead(); this.LAX(); break; // *LAX (absolute, Y)
|
||||
case 0xb2: this.JAM(); break; // *JAM
|
||||
case 0xb3: this.IndirectIndexedY(); this.LAX(); break; // *LAX (indirect indexed Y)
|
||||
case 0xb7: this.ZeroPageY(); this.LAX(); break; // *LAX (zero page, Y)
|
||||
case 0xbb: this.AbsoluteYAddress(); this.MaybeFixup(); this.LAS(); break; // *LAS (absolute, Y)
|
||||
case 0xbf: this.AbsoluteY(); this.LAX(); break; // *LAX (absolute, Y)
|
||||
|
||||
case 0xc3: this.IndexedIndirectXRead(); this.DCP(); break; // *DCP (indexed indirect X)
|
||||
case 0xc7: this.ZeroPageRead(); this.DCP(); break; // *DCP (zero page)
|
||||
case 0xcb: this.FetchByte(); this.AXS(); break; // *AXS (immediate)
|
||||
case 0xcf: this.AbsoluteRead(); this.DCP(); break; // *DCP (absolute)
|
||||
case 0xc3: this.IndexedIndirectX(); this.DCP(); break; // *DCP (indexed indirect X)
|
||||
case 0xc7: this.ZeroPage(); this.DCP(); break; // *DCP (zero page)
|
||||
case 0xcb: this.FetchByte(); this.AXS(); break; // *AXS (immediate)
|
||||
case 0xcf: this.Absolute(); this.DCP(); break; // *DCP (absolute)
|
||||
|
||||
case 0xd2: this.Jam(); break; // *JAM
|
||||
case 0xd3: this.IndirectIndexedYAddress(); this.FixupRead(); this.DCP(); break; // *DCP (indirect indexed Y)
|
||||
case 0xd7: this.ZeroPageXRead(); this.DCP(); break; // *DCP (zero page, X)
|
||||
case 0xda: this.SwallowRead(); break; // *NOP (implied)
|
||||
case 0xdb: this.AbsoluteYAddress(); this.FixupRead(); this.DCP(); break; // *DCP (absolute, Y)
|
||||
case 0xdc: this.AbsoluteXAddress(); this.MaybeFixupRead(); break; // *NOP (absolute, X)
|
||||
case 0xdf: this.AbsoluteXAddress(); this.FixupRead(); this.DCP(); break; // *DCP (absolute, X)
|
||||
case 0xd2: this.JAM(); break; // *JAM
|
||||
case 0xd3: this.IndirectIndexedYAddress(); this.FixupRead(); this.DCP(); break; // *DCP (indirect indexed Y)
|
||||
case 0xd7: this.ZeroPageX(); this.DCP(); break; // *DCP (zero page, X)
|
||||
case 0xda: this.SwallowRead(); break; // *NOP (implied)
|
||||
case 0xdb: this.AbsoluteYAddress(); this.FixupRead(); this.DCP(); break; // *DCP (absolute, Y)
|
||||
case 0xdc: this.AbsoluteXAddress(); this.MaybeFixupRead(); break; // *NOP (absolute, X)
|
||||
case 0xdf: this.AbsoluteXAddress(); this.FixupRead(); this.DCP(); break; // *DCP (absolute, X)
|
||||
|
||||
case 0xe3: this.IndexedIndirectXRead(); this.ISB(); break; // *ISB (indexed indirect X)
|
||||
case 0xe7: this.ZeroPageRead(); this.ISB(); break; // *ISB (zero page)
|
||||
case 0xeb: this.FetchByte(); this.SBC(); break; // *SBC (immediate)
|
||||
case 0xef: this.AbsoluteRead(); this.ISB(); break; // *ISB (absolute)
|
||||
case 0xe3: this.IndexedIndirectX(); this.ISB(); break; // *ISB (indexed indirect X)
|
||||
case 0xe7: this.ZeroPage(); this.ISB(); break; // *ISB (zero page)
|
||||
case 0xeb: this.FetchByte(); this.SBC(); break; // *SBC (immediate)
|
||||
case 0xef: this.Absolute(); this.ISB(); break; // *ISB (absolute)
|
||||
|
||||
case 0xf2: this.Jam(); break; // *JAM
|
||||
case 0xf3: this.IndirectIndexedYAddress(); this.FixupRead(); this.ISB(); break; // *ISB (indirect indexed Y)
|
||||
case 0xf7: this.ZeroPageXRead(); this.ISB(); break; // *ISB (zero page, X)
|
||||
case 0xfa: this.SwallowRead(); break; // *NOP (implied)
|
||||
case 0xfb: this.AbsoluteYAddress(); this.FixupRead(); this.ISB(); break; // *ISB (absolute, Y)
|
||||
case 0xfc: this.AbsoluteXAddress(); this.MaybeFixupRead(); break; // *NOP (absolute, X)
|
||||
case 0xff: this.AbsoluteXAddress(); this.FixupRead(); this.ISB(); break; // *ISB (absolute, X)
|
||||
case 0xf2: this.JAM(); break; // *JAM
|
||||
case 0xf3: this.IndirectIndexedYAddress(); this.FixupRead(); this.ISB(); break; // *ISB (indirect indexed Y)
|
||||
case 0xf7: this.ZeroPageX(); this.ISB(); break; // *ISB (zero page, X)
|
||||
case 0xfa: this.SwallowRead(); break; // *NOP (implied)
|
||||
case 0xfb: this.AbsoluteYAddress(); this.FixupRead(); this.ISB(); break; // *ISB (absolute, Y)
|
||||
case 0xfc: this.AbsoluteXAddress(); this.MaybeFixupRead(); break; // *NOP (absolute, X)
|
||||
case 0xff: this.AbsoluteXAddress(); this.FixupRead(); this.ISB(); break; // *ISB (absolute, X)
|
||||
}
|
||||
|
||||
return cycles != this.Cycles;
|
||||
@@ -225,28 +225,14 @@ namespace M6502
|
||||
|
||||
private void StoreFixupEffect(byte data)
|
||||
{
|
||||
////var fixedAddress = (byte)(this.Bus.Address.High + 1);
|
||||
//var fixedAddress = this.FixedPage + 1;
|
||||
//var updated = (byte)(data & fixedAddress);
|
||||
//if (this.Fixed)
|
||||
//{
|
||||
// this.Bus.Address.High = updated;
|
||||
//}
|
||||
var mask = (byte)(this.UnfixedPage + 1); // base_hi + 1, always
|
||||
var updated = (byte)(data & mask);
|
||||
|
||||
//this.MemoryWrite(updated);
|
||||
|
||||
byte updated;
|
||||
if (this.Fixed)
|
||||
{
|
||||
updated = (byte)(data & this.FixedPage);
|
||||
//this.Bus.Address.High = updated;
|
||||
this.Bus.Address.High = updated;
|
||||
}
|
||||
else
|
||||
{
|
||||
updated = (byte)(data & this.UnfixedPage);
|
||||
//this.Bus.Address.High = updated;
|
||||
}
|
||||
this.Bus.Address.High = updated;
|
||||
|
||||
this.MemoryWrite(updated);
|
||||
}
|
||||
|
||||
@@ -260,11 +246,15 @@ namespace M6502
|
||||
|
||||
private void SAX() => this.MemoryWrite((byte)(this.A & this.X));
|
||||
|
||||
private void LAX() => this.A = this.X = this.Through();
|
||||
private void LAX()
|
||||
{
|
||||
this.LDA();
|
||||
this.LDX();
|
||||
}
|
||||
|
||||
private void ANC()
|
||||
{
|
||||
this.AndR();
|
||||
this.AND();
|
||||
this.SetFlag(StatusBits.CF, NegativeTest(this.A));
|
||||
}
|
||||
|
||||
@@ -274,7 +264,7 @@ namespace M6502
|
||||
this.ResetFlag(StatusBits.CF, this.Intermediate.High);
|
||||
}
|
||||
|
||||
private void Jam()
|
||||
private void JAM()
|
||||
{
|
||||
this.SwallowRead();
|
||||
this.MemoryRead(0xff, 0xff);
|
||||
@@ -304,44 +294,44 @@ namespace M6502
|
||||
|
||||
private void ASR()
|
||||
{
|
||||
this.AndR();
|
||||
this.A = this.LSR(this.A);
|
||||
this.AND();
|
||||
this.ImplementLSRA();
|
||||
}
|
||||
|
||||
private void ISB()
|
||||
{
|
||||
this.ModifyWrite(this.INC());
|
||||
this.INC();
|
||||
this.SBC();
|
||||
}
|
||||
|
||||
private void RLA()
|
||||
{
|
||||
this.ModifyWrite(this.ROL());
|
||||
this.AndR();
|
||||
this.ROL();
|
||||
this.AND();
|
||||
}
|
||||
|
||||
private void RRA()
|
||||
{
|
||||
this.ModifyWrite(this.ROR());
|
||||
this.ADC(this.Bus.Data);
|
||||
this.ROR();
|
||||
this.ADC();
|
||||
}
|
||||
|
||||
private void SLO()
|
||||
{
|
||||
this.ModifyWrite(this.ASL());
|
||||
this.OrR();
|
||||
this.ASL();
|
||||
this.ORA();
|
||||
}
|
||||
|
||||
private void SRE()
|
||||
{
|
||||
this.ModifyWrite(this.LSR());
|
||||
this.EorR();
|
||||
this.LSR();
|
||||
this.EOR();
|
||||
}
|
||||
|
||||
private void DCP()
|
||||
{
|
||||
this.ModifyWrite(this.DEC());
|
||||
this.CMP(this.A, this.Bus.Data);
|
||||
this.DEC();
|
||||
this.CMP();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
+202
-85
@@ -36,7 +36,7 @@ namespace M6502
|
||||
protected override void Interrupt(byte vector, InterruptSource source, InterruptType type)
|
||||
{
|
||||
base.Interrupt(vector, source, type);
|
||||
this.ResetFlag(StatusBits.DF); // Disable decimal mode (Change from MOS6502)
|
||||
this.ClearDecimal(); // Disable decimal mode (Change from MOS6502)
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -55,120 +55,120 @@ namespace M6502
|
||||
{
|
||||
case 0x02: this.SwallowFetch(); break; // NOP
|
||||
case 0x03: break; // null
|
||||
case 0x04: this.ZeroPageRead(); this.TSB(); break; // TSB zp
|
||||
case 0x07: this.ZeroPageRead(); this.RMB(Bit(0)); break; // RMB0 zp
|
||||
case 0x04: this.ZeroPage(); this.TSB(); break; // TSB zp
|
||||
case 0x07: this.ZeroPage(); this.RMB0(); break; // RMB0 zp
|
||||
case 0x0b: break; // null
|
||||
case 0x0c: this.AbsoluteRead(); this.TSB(); break; // TSB a
|
||||
case 0x0f: this.ZeroPageRead(); this.BBR(Bit(0)); break; // BBR0 r
|
||||
case 0x0c: this.Absolute(); this.TSB(); break; // TSB a
|
||||
case 0x0f: this.ZeroPage(); this.BBR0(); break; // BBR0 r
|
||||
|
||||
case 0x12: this.OrR(this.ZeroPageIndirectRead()); break; // ORA (zp),y
|
||||
case 0x12: this.ZeroPageIndirect(); this.ORA(); break; // ORA (zp),y
|
||||
case 0x13: break; // null
|
||||
case 0x14: this.ZeroPageRead(); this.TRB(); break; // TRB zp
|
||||
case 0x17: this.ZeroPageRead(); this.RMB(Bit(1)); break; // RMB1 zp
|
||||
case 0x1a: this.SwallowRead(); this.A = this.INC(this.A); break; // INC A
|
||||
case 0x14: this.ZeroPage(); this.TRB(); break; // TRB zp
|
||||
case 0x17: this.ZeroPage(); this.RMB1(); break; // RMB1 zp
|
||||
case 0x1a: this.INCA(); break; // INC A
|
||||
case 0x1b: break; // null
|
||||
case 0x1c: this.AbsoluteRead(); this.TRB(); break; // TRB a
|
||||
//case 0x1e: break; // ???
|
||||
case 0x1f: this.ZeroPageRead(); this.BBR(Bit(1)); break; // BBR1 r
|
||||
case 0x1c: this.Absolute(); this.TRB(); break; // TRB a
|
||||
//case 0x1e: this.AbsoluteX(); this.ASL(); break; // ???
|
||||
case 0x1f: this.ZeroPage(); this.BBR1(); break; // BBR1 r
|
||||
|
||||
case 0x22: this.SwallowFetch(); break; // NOP
|
||||
case 0x23: break; // null
|
||||
case 0x27: this.ZeroPageRead(); this.RMB(Bit(2)); break; // RMB2 zp
|
||||
case 0x27: this.ZeroPage(); this.RMB2(); break; // RMB2 zp
|
||||
case 0x2b: break; // null
|
||||
case 0x2f: this.ZeroPageRead(); this.BBR(Bit(2)); break; // BBR2 r
|
||||
case 0x2f: this.ZeroPage(); this.BBR2(); break; // BBR2 r
|
||||
|
||||
case 0x32: this.ZeroPageIndirectRead(); this.AndR(); break; // AND (zp)
|
||||
case 0x32: this.ZeroPageIndirect(); this.AND(); break; // AND (zp)
|
||||
case 0x33: break; // null
|
||||
case 0x34: ZeroPageXRead(); this.BIT(); break; // BIT zp,x
|
||||
case 0x37: this.ZeroPageRead(); this.RMB(Bit(3)); break; // RMB3 zp
|
||||
case 0x3a: this.SwallowRead(); this.A = this.DEC(this.A); break; // DEC A
|
||||
case 0x34: ZeroPageX(); this.BIT(); break; // BIT zp,x
|
||||
case 0x37: this.ZeroPage(); this.RMB3(); break; // RMB3 zp
|
||||
case 0x3a: this.DECA(); break; // DEC A
|
||||
case 0x3b: break; // null
|
||||
case 0x3c: AbsoluteXRead(); BIT(); break; // BIT abs,x
|
||||
case 0x3c: AbsoluteX(); BIT(); break; // BIT abs,x
|
||||
//case 0x3e: break;// ????
|
||||
case 0x3f: this.ZeroPageRead(); this.BBR(Bit(3)); break; // BBR3 r
|
||||
case 0x3f: this.ZeroPage(); this.BBR3(); break; // BBR3 r
|
||||
|
||||
case 0x42: this.SwallowFetch(); break; // NOP
|
||||
case 0x43: break; // null
|
||||
case 0x47: this.ZeroPageRead(); this.RMB(Bit(4)); break; // RMB4 zp
|
||||
case 0x4b: break; // null
|
||||
case 0x4f: this.ZeroPageRead(); this.BBR(Bit(4)); break; // BBR4 r
|
||||
case 0x42: this.SwallowFetch(); break; // NOP
|
||||
case 0x43: break; // null
|
||||
case 0x47: this.ZeroPage(); this.RMB4(); break; // RMB4 zp
|
||||
case 0x4b: break; // null
|
||||
case 0x4f: this.ZeroPage(); this.BBR4(); break; // BBR4 r
|
||||
|
||||
case 0x52: this.ZeroPageIndirectRead(); this.EorR(); break; // EOR (zp)
|
||||
case 0x53: break; // null
|
||||
case 0x57: this.ZeroPageRead(); this.RMB(Bit(5)); break; // RMB5 zp
|
||||
case 0x5a: this.SwallowRead(); this.Push(this.Y); break; // PHY s
|
||||
case 0x5b: break; // null
|
||||
case 0x5c: this.SwallowFetch(); this.SwallowRead(); this.SwallowFetch(); break; // ???
|
||||
case 0x52: this.ZeroPageIndirect(); this.EOR(); break; // EOR (zp)
|
||||
case 0x53: break; // null
|
||||
case 0x57: this.ZeroPage(); this.RMB5(); break; // RMB5 zp
|
||||
case 0x5a: this.PHY(); break; // PHY s
|
||||
case 0x5b: break; // null
|
||||
case 0x5c: this.SwallowFetch(); this.SwallowRead(); this.SwallowFetch(); break; // ???
|
||||
//case 0x5e: break;// ????
|
||||
case 0x5f: this.ZeroPageRead(); this.BBR(Bit(5)); break; // BBR5 r
|
||||
case 0x5f: this.ZeroPage(); this.BBR5(); break; // BBR5 r
|
||||
|
||||
case 0x62: this.SwallowFetch(); break; // *NOP
|
||||
case 0x62: this.SwallowFetch(); break; // *NOP
|
||||
case 0x63: break; // null
|
||||
case 0x64: this.ZeroPageAddress(); this.MemoryWrite(0); break; // STZ zp
|
||||
case 0x67: this.ZeroPageRead(); this.RMB(Bit(6)); break; // RMB6 zp
|
||||
case 0x6b: break; // null
|
||||
case 0x6f: this.ZeroPageRead(); this.BBR(Bit(6)); break; // BBR6 r
|
||||
case 0x64: this.ZeroPageAddress(); this.STZ(); break; // STZ zp
|
||||
case 0x67: this.ZeroPage(); this.RMB6(); break; // RMB6 zp
|
||||
case 0x6b: break; // null
|
||||
case 0x6f: this.ZeroPage(); this.BBR6(); break; // BBR6 r
|
||||
|
||||
case 0x72: this.ADC(this.ZeroPageIndirectRead()); break; // ADC (zp)
|
||||
case 0x72: this.ZeroPageIndirect(); this.ADC(); break; // ADC (zp)
|
||||
case 0x73: break; // null
|
||||
case 0x74: this.ZeroPageXAddress(); this.MemoryWrite(0); break; // STZ zp,x
|
||||
case 0x77: this.ZeroPageRead(); this.RMB(Bit(7)); break; // RMB7 zp
|
||||
case 0x7a: this.SwallowRead(); this.SwallowPop(); this.Pop(); this.Y = this.Through(); break; // PLY s
|
||||
case 0x74: this.ZeroPageXAddress(); this.STZ(); break; // STZ zp,x
|
||||
case 0x77: this.ZeroPage(); this.RMB7(); break; // RMB7 zp
|
||||
case 0x7a: this.PLY(); break; // PLY s
|
||||
case 0x7b: break; // null
|
||||
case 0x7c: this.AbsoluteXAddress(); this.Bus.Address.Assign(this.Intermediate); this.GetAddressPaged(); this.Jump(this.Bus.Address); break; // JMP (a,x)
|
||||
case 0x7f: this.ZeroPageRead(); this.BBR(Bit(7)); break; // BBR7 r
|
||||
case 0x7c: this.AbsoluteXAddress(); this.JumpIndirect(); break; // JMP (a,x)
|
||||
case 0x7f: this.ZeroPage(); this.BBR7(); break; // BBR7 r
|
||||
|
||||
case 0x80: this.Branch(true); break; // BRA r
|
||||
case 0x80: this.BRA(); break; // BRA r
|
||||
case 0x83: break; // null
|
||||
case 0x87: this.ZeroPageRead(); this.SMB(Bit(0)); break; // SMB0 zp
|
||||
case 0x89: break; // BIT # (TBC)
|
||||
case 0x8b: break; // null
|
||||
case 0x8f: this.ZeroPageRead(); this.BBS(Bit(0)); break; // BBS0 r
|
||||
case 0x87: this.ZeroPage(); this.SMB0(); break; // SMB0 zp
|
||||
case 0x89: break; // BIT # (TBC)
|
||||
case 0x8b: break; // null
|
||||
case 0x8f: this.ZeroPage(); this.BBS0(); break; // BBS0 r
|
||||
|
||||
case 0x92: this.ZeroPageIndirectAddress(); this.MemoryWrite(this.A); break; // STA (zp)
|
||||
case 0x92: this.ZeroPageIndirectAddress(); this.STA(); break; // STA (zp)
|
||||
case 0x93: break; // null
|
||||
case 0x97: this.ZeroPageRead(); this.SMB(Bit(1)); break; // SMB1 zp
|
||||
case 0x9b: break; // null
|
||||
case 0x9c: this.AbsoluteAddress(); this.MemoryWrite(0); break; // STZ a
|
||||
case 0x9e: this.AbsoluteXAddress(); this.MemoryWrite(0); break; // STZ a,x
|
||||
case 0x9f: this.ZeroPageRead(); this.BBS(Bit(1)); break; // BBS1 r
|
||||
case 0x97: this.ZeroPage(); this.SMB1(); break; // SMB1 zp
|
||||
case 0x9b: break; // null
|
||||
case 0x9c: this.AbsoluteAddress(); this.STZ(); break; // STZ a
|
||||
case 0x9e: this.AbsoluteXAddress(); this.STZ(); break; // STZ a,x
|
||||
case 0x9f: this.ZeroPage(); this.BBS1(); break; // BBS1 r
|
||||
|
||||
case 0xa3: break; // null
|
||||
case 0xa7: this.ZeroPageRead(); this.SMB(Bit(2)); break; // SMB2 zp
|
||||
case 0xab: break; // null
|
||||
case 0xaf: this.ZeroPageRead(); this.BBS(Bit(2)); break; // BBS2 r
|
||||
case 0xa7: this.ZeroPage(); this.SMB2(); break; // SMB2 zp
|
||||
case 0xab: break; // null
|
||||
case 0xaf: this.ZeroPage(); this.BBS2(); break; // BBS2 r
|
||||
|
||||
case 0xb2: this.ZeroPageIndirectRead(); this.A = this.Through(); break; // LDA (zp)
|
||||
case 0xb3: break; // null
|
||||
case 0xb7: this.ZeroPageRead(); this.SMB(Bit(3)); break; // SMB3 zp
|
||||
case 0xbb: break; // null
|
||||
case 0xbf: this.ZeroPageRead(); this.BBS(Bit(3)); break; // BBS3 r
|
||||
case 0xb2: this.ZeroPageIndirect(); this.LDA(); break; // LDA (zp)
|
||||
case 0xb3: break; // null
|
||||
case 0xb7: this.ZeroPage(); this.SMB3(); break; // SMB3 zp
|
||||
case 0xbb: break; // null
|
||||
case 0xbf: this.ZeroPage(); this.BBS3(); break; // BBS3 r
|
||||
|
||||
case 0xc3: break; // null
|
||||
case 0xc7: this.ZeroPageRead(); this.SMB(Bit(4)); break; // SMB4 zp
|
||||
case 0xcb: this.SwallowRead(); this.Waiting = true; break; // WAI i
|
||||
case 0xcf: this.ZeroPageRead(); this.BBS(Bit(4)); break; // BBS4 r
|
||||
case 0xc3: break; // null
|
||||
case 0xc7: this.ZeroPage(); this.SMB4(); break; // SMB4 zp
|
||||
case 0xcb: this.WAI(); break; // WAI i
|
||||
case 0xcf: this.ZeroPage(); this.BBS4(); break; // BBS4 r
|
||||
|
||||
case 0xd2: this.CMP(this.A, this.ZeroPageIndirectRead()); break; // CMP (zp)
|
||||
case 0xd2: this.ZeroPageIndirect(); this.CMP(); break; // CMP (zp)
|
||||
case 0xd3: break; // null
|
||||
case 0xd7: this.ZeroPageRead(); this.SMB(Bit(5)); break; // SMB5 zp
|
||||
case 0xda: this.SwallowRead(); this.Push(this.X); break; // PHX s
|
||||
case 0xdb: this.SwallowRead(); this.Stopped = true; break; // STP i
|
||||
case 0xdc: this.SwallowRead(); break; // null
|
||||
case 0xdf: this.ZeroPageRead(); this.BBS(Bit(5)); break; // BBS5 r
|
||||
case 0xd7: this.ZeroPage(); this.SMB5(); break; // SMB5 zp
|
||||
case 0xda: this.PHX(); break; // PHX s
|
||||
case 0xdb: this.STP(); break; // STP i
|
||||
case 0xdc: this.SwallowRead(); break; // null
|
||||
case 0xdf: this.ZeroPage(); this.BBS5(); break; // BBS5 r
|
||||
|
||||
case 0xe3: break; // null
|
||||
case 0xe7: this.ZeroPageRead(); this.SMB(Bit(6)); break; // SMB6 zp
|
||||
case 0xeb: break; // null
|
||||
case 0xef: this.ZeroPageRead(); this.BBS(Bit(6)); break; // BBS6 r
|
||||
case 0xe3: break; // null
|
||||
case 0xe7: this.ZeroPage(); this.SMB6(); break; // SMB6 zp
|
||||
case 0xeb: break; // null
|
||||
case 0xef: this.ZeroPage(); this.BBS6(); break; // BBS6 r
|
||||
|
||||
case 0xf2: this.ZeroPageIndirectRead(); this.SBC(); break; // SBC (zp)
|
||||
case 0xf3: break; // null
|
||||
case 0xf7: this.ZeroPageRead(); this.SMB(Bit(7)); break; // SMB7 zp
|
||||
case 0xfa: this.SwallowRead(); this.SwallowPop(); this.Pop(); this.X = this.Through(); break; // PLX s
|
||||
case 0xfb: break; // null
|
||||
case 0xfc: break; // null
|
||||
case 0xff: this.ZeroPageRead(); this.BBS(Bit(7)); break; // BBS7 r
|
||||
case 0xf2: this.ZeroPageIndirect(); this.SBC(); break; // SBC (zp)
|
||||
case 0xf3: break; // null
|
||||
case 0xf7: this.ZeroPage(); this.SMB7(); break; // SMB7 zp
|
||||
case 0xfa: this.PLX(); break; // PLX s
|
||||
case 0xfb: break; // null
|
||||
case 0xfc: break; // null
|
||||
case 0xff: this.ZeroPage(); this.BBS7(); break; // BBS7 r
|
||||
}
|
||||
|
||||
return cycles != this.Cycles;
|
||||
@@ -263,7 +263,7 @@ namespace M6502
|
||||
|
||||
#region Address and read
|
||||
|
||||
private byte ZeroPageIndirectRead()
|
||||
private byte ZeroPageIndirect()
|
||||
{
|
||||
this.ZeroPageIndirectAddress();
|
||||
return this.MemoryRead();
|
||||
@@ -273,6 +273,83 @@ namespace M6502
|
||||
|
||||
#endregion
|
||||
|
||||
private void INCA()
|
||||
{
|
||||
this.SwallowRead();
|
||||
this.A = this.INC(this.A);
|
||||
}
|
||||
|
||||
private void DECA()
|
||||
{
|
||||
this.SwallowRead();
|
||||
this.A = this.DEC(this.A);
|
||||
}
|
||||
|
||||
private void PHX()
|
||||
{
|
||||
this.SwallowRead();
|
||||
this.Push(this.X);
|
||||
}
|
||||
|
||||
private void PLX()
|
||||
{
|
||||
this.SwallowRead();
|
||||
this.SwallowPop();
|
||||
this.X = this.Through(this.Pop());
|
||||
}
|
||||
|
||||
private void PHY()
|
||||
{
|
||||
this.SwallowRead();
|
||||
this.Push(this.Y);
|
||||
}
|
||||
|
||||
private void PLY()
|
||||
{
|
||||
this.SwallowRead();
|
||||
this.SwallowPop();
|
||||
this.Y = this.Through(this.Pop());
|
||||
}
|
||||
|
||||
private void JumpIndirect()
|
||||
{
|
||||
this.Bus.Address.Assign(this.Intermediate);
|
||||
this.GetAddressPaged();
|
||||
this.JMP();
|
||||
}
|
||||
|
||||
private void BRA() => this.Branch(true);
|
||||
|
||||
private void WAI()
|
||||
{
|
||||
this.SwallowRead();
|
||||
this.Waiting = true;
|
||||
}
|
||||
|
||||
private void STP()
|
||||
{
|
||||
this.SwallowRead();
|
||||
this.Stopped = true;
|
||||
}
|
||||
|
||||
private void STZ() => this.MemoryWrite(0);
|
||||
|
||||
private void RMB0() => this.RMB(Bit(0));
|
||||
|
||||
private void RMB1() => this.RMB(Bit(1));
|
||||
|
||||
private void RMB2() => this.RMB(Bit(2));
|
||||
|
||||
private void RMB3() => this.RMB(Bit(3));
|
||||
|
||||
private void RMB4() => this.RMB(Bit(4));
|
||||
|
||||
private void RMB5() => this.RMB(Bit(5));
|
||||
|
||||
private void RMB6() => this.RMB(Bit(6));
|
||||
|
||||
private void RMB7() => this.RMB(Bit(7));
|
||||
|
||||
private void RMB(byte flag)
|
||||
{
|
||||
this.MemoryRead();
|
||||
@@ -280,6 +357,22 @@ namespace M6502
|
||||
this.MemoryWrite();
|
||||
}
|
||||
|
||||
private void SMB0() => this.SMB(Bit(0));
|
||||
|
||||
private void SMB1() => this.SMB(Bit(1));
|
||||
|
||||
private void SMB2() => this.SMB(Bit(2));
|
||||
|
||||
private void SMB3() => this.SMB(Bit(3));
|
||||
|
||||
private void SMB4() => this.SMB(Bit(4));
|
||||
|
||||
private void SMB5() => this.SMB(Bit(5));
|
||||
|
||||
private void SMB6() => this.SMB(Bit(6));
|
||||
|
||||
private void SMB7() => this.SMB(Bit(7));
|
||||
|
||||
private void SMB(byte flag)
|
||||
{
|
||||
this.MemoryRead();
|
||||
@@ -287,7 +380,6 @@ namespace M6502
|
||||
this.MemoryWrite();
|
||||
}
|
||||
|
||||
|
||||
private void BranchBit(bool condition)
|
||||
{
|
||||
_ = this.FetchByte();
|
||||
@@ -304,12 +396,37 @@ namespace M6502
|
||||
}
|
||||
}
|
||||
|
||||
private void BBS0() => this.BBS(Bit(0));
|
||||
|
||||
private void BBS1() => this.BBS(Bit(1));
|
||||
|
||||
private void BBS2() => this.BBS(Bit(2));
|
||||
|
||||
private void BBS3() => this.BBS(Bit(3));
|
||||
|
||||
private void BBS4() => this.BBS(Bit(4));
|
||||
|
||||
private void BBS5() => this.BBS(Bit(5));
|
||||
|
||||
private void BBS6() => this.BBS(Bit(6));
|
||||
|
||||
private void BBS7() => this.BBS(Bit(7));
|
||||
|
||||
private void BBS(byte flag)
|
||||
{
|
||||
this.MemoryRead();
|
||||
this.BranchBit((this.Bus.Data & flag) != 0);
|
||||
}
|
||||
|
||||
private void BBR0() => this.BBR(Bit(0));
|
||||
private void BBR1() => this.BBR(Bit(1));
|
||||
private void BBR2() => this.BBR(Bit(2));
|
||||
private void BBR3() => this.BBR(Bit(3));
|
||||
private void BBR4() => this.BBR(Bit(4));
|
||||
private void BBR5() => this.BBR(Bit(5));
|
||||
private void BBR6() => this.BBR(Bit(6));
|
||||
private void BBR7() => this.BBR(Bit(7));
|
||||
|
||||
private void BBR(byte flag)
|
||||
{
|
||||
this.MemoryRead();
|
||||
|
||||
Reference in new issue
Block a user