diff --git a/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IInputPollable.cs b/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IInputPollable.cs index 19c29a7f16..f160aff77c 100644 --- a/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IInputPollable.cs +++ b/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IInputPollable.cs @@ -12,6 +12,6 @@ namespace BizHawk.Emulation.Cores.Computers.AppleII private set { _machine.Lagged = value; } } - public IInputCallbackSystem InputCallbacks { [FeatureNotImplemented]get; private set; } + public IInputCallbackSystem InputCallbacks { get; private set; } } } diff --git a/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.cs b/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.cs index b0cae8af74..21b57a5d99 100644 --- a/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.cs +++ b/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.cs @@ -34,6 +34,7 @@ namespace BizHawk.Emulation.Cores.Computers.AppleII Tracer = new TraceBuffer(); MemoryCallbacks = new MemoryCallbackSystem(); + InputCallbacks = new InputCallbackSystem(); _disk1 = rom; RomSet.Add(rom); @@ -58,6 +59,8 @@ namespace BizHawk.Emulation.Cores.Computers.AppleII _machine.Memory.WriteCallback = MemoryCallbacks.CallWrites; _machine.Memory.ExecuteCallback = MemoryCallbacks.CallExecutes; + _machine.Memory.InputCallback = InputCallbacks.Call; + InitSaveStates(); SetupMemoryDomains(); PutSettings(settings ?? new Settings()); diff --git a/ExternalCoreProjects/Virtu/Cpu.cs b/ExternalCoreProjects/Virtu/Cpu.cs index 712730a488..71ea78caf3 100644 --- a/ExternalCoreProjects/Virtu/Cpu.cs +++ b/ExternalCoreProjects/Virtu/Cpu.cs @@ -199,163 +199,163 @@ namespace Jellyfish.Virtu if (pc <= 0xFFFD) //sanity check to make sure we don't read from outside address space. { - switch (_memory.Read(pc)) + switch (_memory.Peek(pc)) { - case 0x0C: return string.Format("NOP (${0:X4})", _memory.Read(pc + 1) | _memory.Read(pc + 2) << 8); - case 0x0D: return string.Format("ORA ${0:X4}", _memory.Read(pc + 1) | _memory.Read(pc + 2) << 8); - case 0x0E: return string.Format("ASL ${0:X4}", _memory.Read(pc + 1) | _memory.Read(pc + 2) << 8); - case 0x19: return string.Format("ORA ${0:X4},Y *", _memory.Read(pc + 1) | _memory.Read(pc + 2) << 8); - case 0x1D: return string.Format("ORA ${0:X4},X *", _memory.Read(pc + 1) | _memory.Read(pc + 2) << 8); - case 0x1E: return string.Format("ASL ${0:X4},X", _memory.Read(pc + 1) | _memory.Read(pc + 2) << 8); - case 0x20: return string.Format("JSR ${0:X4}", _memory.Read(pc + 1) | _memory.Read(pc + 2) << 8); - case 0x2C: return string.Format("BIT ${0:X4}", _memory.Read(pc + 1) | _memory.Read(pc + 2) << 8); - case 0x2D: return string.Format("AND ${0:X4}", _memory.Read(pc + 1) | _memory.Read(pc + 2) << 8); - case 0x2E: return string.Format("ROL ${0:X4}", _memory.Read(pc + 1) | _memory.Read(pc + 2) << 8); - case 0x39: return string.Format("AND ${0:X4},Y *", _memory.Read(pc + 1) | _memory.Read(pc + 2) << 8); - case 0x3D: return string.Format("AND ${0:X4},X *", _memory.Read(pc + 1) | _memory.Read(pc + 2) << 8); - case 0x3E: return string.Format("ROL ${0:X4},X", _memory.Read(pc + 1) | _memory.Read(pc + 2) << 8); - case 0x4C: return string.Format("JMP ${0:X4}", _memory.Read(pc + 1) | _memory.Read(pc + 2) << 8); - case 0x4D: return string.Format("EOR ${0:X4}", _memory.Read(pc + 1) | _memory.Read(pc + 2) << 8); - case 0x4E: return string.Format("LSR ${0:X4}", _memory.Read(pc + 1) | _memory.Read(pc + 2) << 8); - case 0x59: return string.Format("EOR ${0:X4},Y *", _memory.Read(pc + 1) | _memory.Read(pc + 2) << 8); - case 0x5D: return string.Format("EOR ${0:X4},X *", _memory.Read(pc + 1) | _memory.Read(pc + 2) << 8); - case 0x5E: return string.Format("LSR ${0:X4},X", _memory.Read(pc + 1) | _memory.Read(pc + 2) << 8); - case 0x6C: return string.Format("JMP (${0:X4})", _memory.Read(pc + 1) | _memory.Read(pc + 2) << 8); - case 0x6D: return string.Format("ADC ${0:X4}", _memory.Read(pc + 1) | _memory.Read(pc + 2) << 8); - case 0x6E: return string.Format("ROR ${0:X4}", _memory.Read(pc + 1) | _memory.Read(pc + 2) << 8); - case 0x79: return string.Format("ADC ${0:X4},Y *", _memory.Read(pc + 1) | _memory.Read(pc + 2) << 8); - case 0x7D: return string.Format("ADC ${0:X4},X *", _memory.Read(pc + 1) | _memory.Read(pc + 2) << 8); - case 0x7E: return string.Format("ROR ${0:X4},X", _memory.Read(pc + 1) | _memory.Read(pc + 2) << 8); - case 0x8C: return string.Format("STY ${0:X4}", _memory.Read(pc + 1) | _memory.Read(pc + 2) << 8); - case 0x8D: return string.Format("STA ${0:X4}", _memory.Read(pc + 1) | _memory.Read(pc + 2) << 8); - case 0x8E: return string.Format("STX ${0:X4}", _memory.Read(pc + 1) | _memory.Read(pc + 2) << 8); - case 0x99: return string.Format("STA ${0:X4},Y", _memory.Read(pc + 1) | _memory.Read(pc + 2) << 8); - case 0x9D: return string.Format("STA ${0:X4},X", _memory.Read(pc + 1) | _memory.Read(pc + 2) << 8); - case 0xAC: return string.Format("LDY ${0:X4}", _memory.Read(pc + 1) | _memory.Read(pc + 2) << 8); - case 0xAD: return string.Format("LDA ${0:X4}", _memory.Read(pc + 1) | _memory.Read(pc + 2) << 8); - case 0xAE: return string.Format("LDX ${0:X4}", _memory.Read(pc + 1) | _memory.Read(pc + 2) << 8); - case 0xB9: return string.Format("LDA ${0:X4},Y *", _memory.Read(pc + 1) | _memory.Read(pc + 2) << 8); - case 0xBC: return string.Format("LDY ${0:X4},X *", _memory.Read(pc + 1) | _memory.Read(pc + 2) << 8); - case 0xBD: return string.Format("LDA ${0:X4},X *", _memory.Read(pc + 1) | _memory.Read(pc + 2) << 8); - case 0xBE: return string.Format("LDX ${0:X4},Y *", _memory.Read(pc + 1) | _memory.Read(pc + 2) << 8); - case 0xCC: return string.Format("CPY ${0:X4}", _memory.Read(pc + 1) | _memory.Read(pc + 2) << 8); - case 0xCD: return string.Format("CMP ${0:X4}", _memory.Read(pc + 1) | _memory.Read(pc + 2) << 8); - case 0xCE: return string.Format("DEC ${0:X4}", _memory.Read(pc + 1) | _memory.Read(pc + 2) << 8); - case 0xD9: return string.Format("CMP ${0:X4},Y *", _memory.Read(pc + 1) | _memory.Read(pc + 2) << 8); - case 0xDD: return string.Format("CMP ${0:X4},X *", _memory.Read(pc + 1) | _memory.Read(pc + 2) << 8); - case 0xDE: return string.Format("DEC ${0:X4},X", _memory.Read(pc + 1) | _memory.Read(pc + 2) << 8); - case 0xEC: return string.Format("CPX ${0:X4}", _memory.Read(pc + 1) | _memory.Read(pc + 2) << 8); - case 0xED: return string.Format("SBC ${0:X4}", _memory.Read(pc + 1) | _memory.Read(pc + 2) << 8); - case 0xEE: return string.Format("INC ${0:X4}", _memory.Read(pc + 1) | _memory.Read(pc + 2) << 8); - case 0xF9: return string.Format("SBC ${0:X4},Y *", _memory.Read(pc + 1) | _memory.Read(pc + 2) << 8); - case 0xFD: return string.Format("SBC ${0:X4},X *", _memory.Read(pc + 1) | _memory.Read(pc + 2) << 8); - case 0xFE: return string.Format("INC ${0:X4},X", _memory.Read(pc + 1) | _memory.Read(pc + 2) << 8); + case 0x0C: return string.Format("NOP (${0:X4})", _memory.Peek(pc + 1) | _memory.Peek(pc + 2) << 8); + case 0x0D: return string.Format("ORA ${0:X4}", _memory.Peek(pc + 1) | _memory.Peek(pc + 2) << 8); + case 0x0E: return string.Format("ASL ${0:X4}", _memory.Peek(pc + 1) | _memory.Peek(pc + 2) << 8); + case 0x19: return string.Format("ORA ${0:X4},Y *", _memory.Peek(pc + 1) | _memory.Peek(pc + 2) << 8); + case 0x1D: return string.Format("ORA ${0:X4},X *", _memory.Peek(pc + 1) | _memory.Peek(pc + 2) << 8); + case 0x1E: return string.Format("ASL ${0:X4},X", _memory.Peek(pc + 1) | _memory.Peek(pc + 2) << 8); + case 0x20: return string.Format("JSR ${0:X4}", _memory.Peek(pc + 1) | _memory.Peek(pc + 2) << 8); + case 0x2C: return string.Format("BIT ${0:X4}", _memory.Peek(pc + 1) | _memory.Peek(pc + 2) << 8); + case 0x2D: return string.Format("AND ${0:X4}", _memory.Peek(pc + 1) | _memory.Peek(pc + 2) << 8); + case 0x2E: return string.Format("ROL ${0:X4}", _memory.Peek(pc + 1) | _memory.Peek(pc + 2) << 8); + case 0x39: return string.Format("AND ${0:X4},Y *", _memory.Peek(pc + 1) | _memory.Peek(pc + 2) << 8); + case 0x3D: return string.Format("AND ${0:X4},X *", _memory.Peek(pc + 1) | _memory.Peek(pc + 2) << 8); + case 0x3E: return string.Format("ROL ${0:X4},X", _memory.Peek(pc + 1) | _memory.Peek(pc + 2) << 8); + case 0x4C: return string.Format("JMP ${0:X4}", _memory.Peek(pc + 1) | _memory.Peek(pc + 2) << 8); + case 0x4D: return string.Format("EOR ${0:X4}", _memory.Peek(pc + 1) | _memory.Peek(pc + 2) << 8); + case 0x4E: return string.Format("LSR ${0:X4}", _memory.Peek(pc + 1) | _memory.Peek(pc + 2) << 8); + case 0x59: return string.Format("EOR ${0:X4},Y *", _memory.Peek(pc + 1) | _memory.Peek(pc + 2) << 8); + case 0x5D: return string.Format("EOR ${0:X4},X *", _memory.Peek(pc + 1) | _memory.Peek(pc + 2) << 8); + case 0x5E: return string.Format("LSR ${0:X4},X", _memory.Peek(pc + 1) | _memory.Peek(pc + 2) << 8); + case 0x6C: return string.Format("JMP (${0:X4})", _memory.Peek(pc + 1) | _memory.Peek(pc + 2) << 8); + case 0x6D: return string.Format("ADC ${0:X4}", _memory.Peek(pc + 1) | _memory.Peek(pc + 2) << 8); + case 0x6E: return string.Format("ROR ${0:X4}", _memory.Peek(pc + 1) | _memory.Peek(pc + 2) << 8); + case 0x79: return string.Format("ADC ${0:X4},Y *", _memory.Peek(pc + 1) | _memory.Peek(pc + 2) << 8); + case 0x7D: return string.Format("ADC ${0:X4},X *", _memory.Peek(pc + 1) | _memory.Peek(pc + 2) << 8); + case 0x7E: return string.Format("ROR ${0:X4},X", _memory.Peek(pc + 1) | _memory.Peek(pc + 2) << 8); + case 0x8C: return string.Format("STY ${0:X4}", _memory.Peek(pc + 1) | _memory.Peek(pc + 2) << 8); + case 0x8D: return string.Format("STA ${0:X4}", _memory.Peek(pc + 1) | _memory.Peek(pc + 2) << 8); + case 0x8E: return string.Format("STX ${0:X4}", _memory.Peek(pc + 1) | _memory.Peek(pc + 2) << 8); + case 0x99: return string.Format("STA ${0:X4},Y", _memory.Peek(pc + 1) | _memory.Peek(pc + 2) << 8); + case 0x9D: return string.Format("STA ${0:X4},X", _memory.Peek(pc + 1) | _memory.Peek(pc + 2) << 8); + case 0xAC: return string.Format("LDY ${0:X4}", _memory.Peek(pc + 1) | _memory.Peek(pc + 2) << 8); + case 0xAD: return string.Format("LDA ${0:X4}", _memory.Peek(pc + 1) | _memory.Peek(pc + 2) << 8); + case 0xAE: return string.Format("LDX ${0:X4}", _memory.Peek(pc + 1) | _memory.Peek(pc + 2) << 8); + case 0xB9: return string.Format("LDA ${0:X4},Y *", _memory.Peek(pc + 1) | _memory.Peek(pc + 2) << 8); + case 0xBC: return string.Format("LDY ${0:X4},X *", _memory.Peek(pc + 1) | _memory.Peek(pc + 2) << 8); + case 0xBD: return string.Format("LDA ${0:X4},X *", _memory.Peek(pc + 1) | _memory.Peek(pc + 2) << 8); + case 0xBE: return string.Format("LDX ${0:X4},Y *", _memory.Peek(pc + 1) | _memory.Peek(pc + 2) << 8); + case 0xCC: return string.Format("CPY ${0:X4}", _memory.Peek(pc + 1) | _memory.Peek(pc + 2) << 8); + case 0xCD: return string.Format("CMP ${0:X4}", _memory.Peek(pc + 1) | _memory.Peek(pc + 2) << 8); + case 0xCE: return string.Format("DEC ${0:X4}", _memory.Peek(pc + 1) | _memory.Peek(pc + 2) << 8); + case 0xD9: return string.Format("CMP ${0:X4},Y *", _memory.Peek(pc + 1) | _memory.Peek(pc + 2) << 8); + case 0xDD: return string.Format("CMP ${0:X4},X *", _memory.Peek(pc + 1) | _memory.Peek(pc + 2) << 8); + case 0xDE: return string.Format("DEC ${0:X4},X", _memory.Peek(pc + 1) | _memory.Peek(pc + 2) << 8); + case 0xEC: return string.Format("CPX ${0:X4}", _memory.Peek(pc + 1) | _memory.Peek(pc + 2) << 8); + case 0xED: return string.Format("SBC ${0:X4}", _memory.Peek(pc + 1) | _memory.Peek(pc + 2) << 8); + case 0xEE: return string.Format("INC ${0:X4}", _memory.Peek(pc + 1) | _memory.Peek(pc + 2) << 8); + case 0xF9: return string.Format("SBC ${0:X4},Y *", _memory.Peek(pc + 1) | _memory.Peek(pc + 2) << 8); + case 0xFD: return string.Format("SBC ${0:X4},X *", _memory.Peek(pc + 1) | _memory.Peek(pc + 2) << 8); + case 0xFE: return string.Format("INC ${0:X4},X", _memory.Peek(pc + 1) | _memory.Peek(pc + 2) << 8); } } if (pc <= 0xFFFE) //read two-byte opcodes here { - switch (_memory.Read(pc)) + switch (_memory.Peek(pc)) { - case 0x01: return string.Format("ORA (${0:X2},X)", _memory.Read(++pc)); - case 0x04: return string.Format("NOP ${0:X2}", _memory.Read(++pc)); - case 0x05: return string.Format("ORA ${0:X2}", _memory.Read(++pc)); - case 0x06: return string.Format("ASL ${0:X2}", _memory.Read(++pc)); - case 0x09: return string.Format("ORA #${0:X2}", _memory.Read(++pc)); - case 0x10: return string.Format("BPL ${0:X4}", pc + 2 + (sbyte)_memory.Read(pc + 1)); - case 0x11: return string.Format("ORA (${0:X2}),Y *", _memory.Read(++pc)); - case 0x14: return string.Format("NOP ${0:X2},X", _memory.Read(++pc)); - case 0x15: return string.Format("ORA ${0:X2},X", _memory.Read(++pc)); - case 0x16: return string.Format("ASL ${0:X2},X", _memory.Read(++pc)); - case 0x1C: return string.Format("NOP (${0:X2},X)", _memory.Read(++pc)); - case 0x21: return string.Format("AND (${0:X2},X)", _memory.Read(++pc)); - case 0x24: return string.Format("BIT ${0:X2}", _memory.Read(++pc)); - case 0x25: return string.Format("AND ${0:X2}", _memory.Read(++pc)); - case 0x26: return string.Format("ROL ${0:X2}", _memory.Read(++pc)); - case 0x29: return string.Format("AND #${0:X2}", _memory.Read(++pc)); - case 0x30: return string.Format("BMI ${0:X4}", pc + 2 + (sbyte)_memory.Read(pc + 1)); - case 0x31: return string.Format("AND (${0:X2}),Y *", _memory.Read(++pc)); - case 0x34: return string.Format("NOP ${0:X2},X", _memory.Read(++pc)); - case 0x35: return string.Format("AND ${0:X2},X", _memory.Read(++pc)); - case 0x36: return string.Format("ROL ${0:X2},X", _memory.Read(++pc)); - case 0x3C: return string.Format("NOP (${0:X2},X)", _memory.Read(++pc)); - case 0x41: return string.Format("EOR (${0:X2},X)", _memory.Read(++pc)); - case 0x44: return string.Format("NOP ${0:X2}", _memory.Read(++pc)); - case 0x45: return string.Format("EOR ${0:X2}", _memory.Read(++pc)); - case 0x46: return string.Format("LSR ${0:X2}", _memory.Read(++pc)); - case 0x49: return string.Format("EOR #${0:X2}", _memory.Read(++pc)); - case 0x50: return string.Format("BVC ${0:X4}", pc + 2 + (sbyte)_memory.Read(pc + 1)); - case 0x51: return string.Format("EOR (${0:X2}),Y *", _memory.Read(++pc)); - case 0x54: return string.Format("NOP ${0:X2},X", _memory.Read(++pc)); - case 0x55: return string.Format("EOR ${0:X2},X", _memory.Read(++pc)); - case 0x56: return string.Format("LSR ${0:X2},X", _memory.Read(++pc)); - case 0x5C: return string.Format("NOP (${0:X2},X)", _memory.Read(++pc)); - case 0x61: return string.Format("ADC (${0:X2},X)", _memory.Read(++pc)); - case 0x64: return string.Format("NOP ${0:X2}", _memory.Read(++pc)); - case 0x65: return string.Format("ADC ${0:X2}", _memory.Read(++pc)); - case 0x66: return string.Format("ROR ${0:X2}", _memory.Read(++pc)); - case 0x69: return string.Format("ADC #${0:X2}", _memory.Read(++pc)); - case 0x70: return string.Format("BVS ${0:X4}", pc + 2 + (sbyte)_memory.Read(pc + 1)); - case 0x71: return string.Format("ADC (${0:X2}),Y *", _memory.Read(++pc)); - case 0x74: return string.Format("NOP ${0:X2},X", _memory.Read(++pc)); - case 0x75: return string.Format("ADC ${0:X2},X", _memory.Read(++pc)); - case 0x76: return string.Format("ROR ${0:X2},X", _memory.Read(++pc)); - case 0x7C: return string.Format("NOP (${0:X2},X)", _memory.Read(++pc)); - case 0x80: return string.Format("NOP #${0:X2}", _memory.Read(++pc)); - case 0x81: return string.Format("STA (${0:X2},X)", _memory.Read(++pc)); - case 0x82: return string.Format("NOP #${0:X2}", _memory.Read(++pc)); - case 0x84: return string.Format("STY ${0:X2}", _memory.Read(++pc)); - case 0x85: return string.Format("STA ${0:X2}", _memory.Read(++pc)); - case 0x86: return string.Format("STX ${0:X2}", _memory.Read(++pc)); - case 0x89: return string.Format("NOP #${0:X2}", _memory.Read(++pc)); - case 0x90: return string.Format("BCC ${0:X4}", pc + 2 + (sbyte)_memory.Read(pc + 1)); - case 0x91: return string.Format("STA (${0:X2}),Y", _memory.Read(++pc)); - case 0x94: return string.Format("STY ${0:X2},X", _memory.Read(++pc)); - case 0x95: return string.Format("STA ${0:X2},X", _memory.Read(++pc)); - case 0x96: return string.Format("STX ${0:X2},Y", _memory.Read(++pc)); - case 0xA0: return string.Format("LDY #${0:X2}", _memory.Read(++pc)); - case 0xA1: return string.Format("LDA (${0:X2},X)", _memory.Read(++pc)); - case 0xA2: return string.Format("LDX #${0:X2}", _memory.Read(++pc)); - case 0xA4: return string.Format("LDY ${0:X2}", _memory.Read(++pc)); - case 0xA5: return string.Format("LDA ${0:X2}", _memory.Read(++pc)); - case 0xA6: return string.Format("LDX ${0:X2}", _memory.Read(++pc)); - case 0xA9: return string.Format("LDA #${0:X2}", _memory.Read(++pc)); - case 0xB0: return string.Format("BCS ${0:X4}", pc + 2 + (sbyte)_memory.Read(pc + 1)); - case 0xB1: return string.Format("LDA (${0:X2}),Y *", _memory.Read(++pc)); - case 0xB4: return string.Format("LDY ${0:X2},X", _memory.Read(++pc)); - case 0xB5: return string.Format("LDA ${0:X2},X", _memory.Read(++pc)); - case 0xB6: return string.Format("LDX ${0:X2},Y", _memory.Read(++pc)); - case 0xC0: return string.Format("CPY #${0:X2}", _memory.Read(++pc)); - case 0xC1: return string.Format("CMP (${0:X2},X)", _memory.Read(++pc)); - case 0xC2: return string.Format("NOP #${0:X2}", _memory.Read(++pc)); - case 0xC4: return string.Format("CPY ${0:X2}", _memory.Read(++pc)); - case 0xC5: return string.Format("CMP ${0:X2}", _memory.Read(++pc)); - case 0xC6: return string.Format("DEC ${0:X2}", _memory.Read(++pc)); - case 0xC9: return string.Format("CMP #${0:X2}", _memory.Read(++pc)); - case 0xD0: return string.Format("BNE ${0:X4}", pc + 2 + (sbyte)_memory.Read(pc + 1)); - case 0xD1: return string.Format("CMP (${0:X2}),Y *", _memory.Read(++pc)); - case 0xD4: return string.Format("NOP ${0:X2},X", _memory.Read(++pc)); - case 0xD5: return string.Format("CMP ${0:X2},X", _memory.Read(++pc)); - case 0xD6: return string.Format("DEC ${0:X2},X", _memory.Read(++pc)); - case 0xDC: return string.Format("NOP (${0:X2},X)", _memory.Read(++pc)); - case 0xE0: return string.Format("CPX #${0:X2}", _memory.Read(++pc)); - case 0xE1: return string.Format("SBC (${0:X2},X)", _memory.Read(++pc)); - case 0xE2: return string.Format("NOP #${0:X2}", _memory.Read(++pc)); - case 0xE4: return string.Format("CPX ${0:X2}", _memory.Read(++pc)); - case 0xE5: return string.Format("SBC ${0:X2}", _memory.Read(++pc)); - case 0xE6: return string.Format("INC ${0:X2}", _memory.Read(++pc)); - case 0xE9: return string.Format("SBC #${0:X2}", _memory.Read(++pc)); - case 0xF0: return string.Format("BEQ ${0:X4}", pc + 2 + (sbyte)_memory.Read(pc + 1)); - case 0xF1: return string.Format("SBC (${0:X2}),Y *", _memory.Read(++pc)); - case 0xF4: return string.Format("NOP ${0:X2},X", _memory.Read(++pc)); - case 0xF5: return string.Format("SBC ${0:X2},X", _memory.Read(++pc)); - case 0xF6: return string.Format("INC ${0:X2},X", _memory.Read(++pc)); - case 0xFC: return string.Format("NOP (${0:X2},X)", _memory.Read(++pc)); + case 0x01: return string.Format("ORA (${0:X2},X)", _memory.Peek(++pc)); + case 0x04: return string.Format("NOP ${0:X2}", _memory.Peek(++pc)); + case 0x05: return string.Format("ORA ${0:X2}", _memory.Peek(++pc)); + case 0x06: return string.Format("ASL ${0:X2}", _memory.Peek(++pc)); + case 0x09: return string.Format("ORA #${0:X2}", _memory.Peek(++pc)); + case 0x10: return string.Format("BPL ${0:X4}", pc + 2 + (sbyte)_memory.Peek(pc + 1)); + case 0x11: return string.Format("ORA (${0:X2}),Y *", _memory.Peek(++pc)); + case 0x14: return string.Format("NOP ${0:X2},X", _memory.Peek(++pc)); + case 0x15: return string.Format("ORA ${0:X2},X", _memory.Peek(++pc)); + case 0x16: return string.Format("ASL ${0:X2},X", _memory.Peek(++pc)); + case 0x1C: return string.Format("NOP (${0:X2},X)", _memory.Peek(++pc)); + case 0x21: return string.Format("AND (${0:X2},X)", _memory.Peek(++pc)); + case 0x24: return string.Format("BIT ${0:X2}", _memory.Peek(++pc)); + case 0x25: return string.Format("AND ${0:X2}", _memory.Peek(++pc)); + case 0x26: return string.Format("ROL ${0:X2}", _memory.Peek(++pc)); + case 0x29: return string.Format("AND #${0:X2}", _memory.Peek(++pc)); + case 0x30: return string.Format("BMI ${0:X4}", pc + 2 + (sbyte)_memory.Peek(pc + 1)); + case 0x31: return string.Format("AND (${0:X2}),Y *", _memory.Peek(++pc)); + case 0x34: return string.Format("NOP ${0:X2},X", _memory.Peek(++pc)); + case 0x35: return string.Format("AND ${0:X2},X", _memory.Peek(++pc)); + case 0x36: return string.Format("ROL ${0:X2},X", _memory.Peek(++pc)); + case 0x3C: return string.Format("NOP (${0:X2},X)", _memory.Peek(++pc)); + case 0x41: return string.Format("EOR (${0:X2},X)", _memory.Peek(++pc)); + case 0x44: return string.Format("NOP ${0:X2}", _memory.Peek(++pc)); + case 0x45: return string.Format("EOR ${0:X2}", _memory.Peek(++pc)); + case 0x46: return string.Format("LSR ${0:X2}", _memory.Peek(++pc)); + case 0x49: return string.Format("EOR #${0:X2}", _memory.Peek(++pc)); + case 0x50: return string.Format("BVC ${0:X4}", pc + 2 + (sbyte)_memory.Peek(pc + 1)); + case 0x51: return string.Format("EOR (${0:X2}),Y *", _memory.Peek(++pc)); + case 0x54: return string.Format("NOP ${0:X2},X", _memory.Peek(++pc)); + case 0x55: return string.Format("EOR ${0:X2},X", _memory.Peek(++pc)); + case 0x56: return string.Format("LSR ${0:X2},X", _memory.Peek(++pc)); + case 0x5C: return string.Format("NOP (${0:X2},X)", _memory.Peek(++pc)); + case 0x61: return string.Format("ADC (${0:X2},X)", _memory.Peek(++pc)); + case 0x64: return string.Format("NOP ${0:X2}", _memory.Peek(++pc)); + case 0x65: return string.Format("ADC ${0:X2}", _memory.Peek(++pc)); + case 0x66: return string.Format("ROR ${0:X2}", _memory.Peek(++pc)); + case 0x69: return string.Format("ADC #${0:X2}", _memory.Peek(++pc)); + case 0x70: return string.Format("BVS ${0:X4}", pc + 2 + (sbyte)_memory.Peek(pc + 1)); + case 0x71: return string.Format("ADC (${0:X2}),Y *", _memory.Peek(++pc)); + case 0x74: return string.Format("NOP ${0:X2},X", _memory.Peek(++pc)); + case 0x75: return string.Format("ADC ${0:X2},X", _memory.Peek(++pc)); + case 0x76: return string.Format("ROR ${0:X2},X", _memory.Peek(++pc)); + case 0x7C: return string.Format("NOP (${0:X2},X)", _memory.Peek(++pc)); + case 0x80: return string.Format("NOP #${0:X2}", _memory.Peek(++pc)); + case 0x81: return string.Format("STA (${0:X2},X)", _memory.Peek(++pc)); + case 0x82: return string.Format("NOP #${0:X2}", _memory.Peek(++pc)); + case 0x84: return string.Format("STY ${0:X2}", _memory.Peek(++pc)); + case 0x85: return string.Format("STA ${0:X2}", _memory.Peek(++pc)); + case 0x86: return string.Format("STX ${0:X2}", _memory.Peek(++pc)); + case 0x89: return string.Format("NOP #${0:X2}", _memory.Peek(++pc)); + case 0x90: return string.Format("BCC ${0:X4}", pc + 2 + (sbyte)_memory.Peek(pc + 1)); + case 0x91: return string.Format("STA (${0:X2}),Y", _memory.Peek(++pc)); + case 0x94: return string.Format("STY ${0:X2},X", _memory.Peek(++pc)); + case 0x95: return string.Format("STA ${0:X2},X", _memory.Peek(++pc)); + case 0x96: return string.Format("STX ${0:X2},Y", _memory.Peek(++pc)); + case 0xA0: return string.Format("LDY #${0:X2}", _memory.Peek(++pc)); + case 0xA1: return string.Format("LDA (${0:X2},X)", _memory.Peek(++pc)); + case 0xA2: return string.Format("LDX #${0:X2}", _memory.Peek(++pc)); + case 0xA4: return string.Format("LDY ${0:X2}", _memory.Peek(++pc)); + case 0xA5: return string.Format("LDA ${0:X2}", _memory.Peek(++pc)); + case 0xA6: return string.Format("LDX ${0:X2}", _memory.Peek(++pc)); + case 0xA9: return string.Format("LDA #${0:X2}", _memory.Peek(++pc)); + case 0xB0: return string.Format("BCS ${0:X4}", pc + 2 + (sbyte)_memory.Peek(pc + 1)); + case 0xB1: return string.Format("LDA (${0:X2}),Y *", _memory.Peek(++pc)); + case 0xB4: return string.Format("LDY ${0:X2},X", _memory.Peek(++pc)); + case 0xB5: return string.Format("LDA ${0:X2},X", _memory.Peek(++pc)); + case 0xB6: return string.Format("LDX ${0:X2},Y", _memory.Peek(++pc)); + case 0xC0: return string.Format("CPY #${0:X2}", _memory.Peek(++pc)); + case 0xC1: return string.Format("CMP (${0:X2},X)", _memory.Peek(++pc)); + case 0xC2: return string.Format("NOP #${0:X2}", _memory.Peek(++pc)); + case 0xC4: return string.Format("CPY ${0:X2}", _memory.Peek(++pc)); + case 0xC5: return string.Format("CMP ${0:X2}", _memory.Peek(++pc)); + case 0xC6: return string.Format("DEC ${0:X2}", _memory.Peek(++pc)); + case 0xC9: return string.Format("CMP #${0:X2}", _memory.Peek(++pc)); + case 0xD0: return string.Format("BNE ${0:X4}", pc + 2 + (sbyte)_memory.Peek(pc + 1)); + case 0xD1: return string.Format("CMP (${0:X2}),Y *", _memory.Peek(++pc)); + case 0xD4: return string.Format("NOP ${0:X2},X", _memory.Peek(++pc)); + case 0xD5: return string.Format("CMP ${0:X2},X", _memory.Peek(++pc)); + case 0xD6: return string.Format("DEC ${0:X2},X", _memory.Peek(++pc)); + case 0xDC: return string.Format("NOP (${0:X2},X)", _memory.Peek(++pc)); + case 0xE0: return string.Format("CPX #${0:X2}", _memory.Peek(++pc)); + case 0xE1: return string.Format("SBC (${0:X2},X)", _memory.Peek(++pc)); + case 0xE2: return string.Format("NOP #${0:X2}", _memory.Peek(++pc)); + case 0xE4: return string.Format("CPX ${0:X2}", _memory.Peek(++pc)); + case 0xE5: return string.Format("SBC ${0:X2}", _memory.Peek(++pc)); + case 0xE6: return string.Format("INC ${0:X2}", _memory.Peek(++pc)); + case 0xE9: return string.Format("SBC #${0:X2}", _memory.Peek(++pc)); + case 0xF0: return string.Format("BEQ ${0:X4}", pc + 2 + (sbyte)_memory.Peek(pc + 1)); + case 0xF1: return string.Format("SBC (${0:X2}),Y *", _memory.Peek(++pc)); + case 0xF4: return string.Format("NOP ${0:X2},X", _memory.Peek(++pc)); + case 0xF5: return string.Format("SBC ${0:X2},X", _memory.Peek(++pc)); + case 0xF6: return string.Format("INC ${0:X2},X", _memory.Peek(++pc)); + case 0xFC: return string.Format("NOP (${0:X2},X)", _memory.Peek(++pc)); } } if (pc <= 0xFFFF) //read one-byte opcodes here { - switch (_memory.Read(pc)) + switch (_memory.Peek(pc)) { case 0x00: return "BRK"; case 0x08: return "PHP"; diff --git a/ExternalCoreProjects/Virtu/Memory.cs b/ExternalCoreProjects/Virtu/Memory.cs index 1465aac15c..13a299c799 100644 --- a/ExternalCoreProjects/Virtu/Memory.cs +++ b/ExternalCoreProjects/Virtu/Memory.cs @@ -5,6 +5,7 @@ using System.Globalization; using System.IO; using Jellyfish.Library; using Jellyfish.Virtu.Services; +using Newtonsoft.Json; namespace Jellyfish.Virtu { @@ -291,7 +292,15 @@ namespace Jellyfish.Virtu private int ReadIoRegionC0C0(int address) { - Machine.Lagged = false; + if ((0xC000 <= address && address <= 0xC00F) || (0xC061 <= address && address <= 0xC067) || (0xC069 <= address && address <= 0xC06F)) + { + Machine.Lagged = false; + if (InputCallback != null) + { + InputCallback(); + } + } + switch (address) { case 0xC000: @@ -2130,10 +2139,18 @@ namespace Jellyfish.Virtu private Action _writeIoRegionC8CF; private Action _writeRomRegionD0FF; + [JsonIgnore] public Action ReadCallback; + + [JsonIgnore] public Action WriteCallback; + + [JsonIgnore] public Action ExecuteCallback; + [JsonIgnore] + public Action InputCallback; + private Keyboard _keyboard; private GamePort _gamePort; private Cassette _cassette; diff --git a/References/Virtu.dll b/References/Virtu.dll index d4d121b9d9..bcea43dda8 100644 Binary files a/References/Virtu.dll and b/References/Virtu.dll differ