From 484c94df984223cb23dec694d2fded62342e09e4 Mon Sep 17 00:00:00 2001 From: Brad Grantham Date: Sun, 6 Nov 2016 14:10:46 -0800 Subject: [PATCH] another SBC and another CPY --- apple2e.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/apple2e.cpp b/apple2e.cpp index 4756a26..45d1ad6 100644 --- a/apple2e.cpp +++ b/apple2e.cpp @@ -573,6 +573,19 @@ struct CPU6502 break; } + case 0xED: { + int addr = read_pc_inc(bus) + read_pc_inc(bus) * 256; + if(debug & DEBUG_DECODE) printf("SBC %04X\n", addr); + unsigned char imm = bus.read(addr); + int borrow = isset(C) ? 0 : 1; + flag_change(C, !(a < imm - borrow)); + a = a - imm - borrow; + flag_change(N, a & 0x80); + flag_change(V, isset(C) != isset(N)); + flag_change(Z, a == 0); + break; + } + case 0xE9: { unsigned char imm = read_pc_inc(bus); if(debug & DEBUG_DECODE) printf("SBC %02X\n", imm); @@ -809,6 +822,17 @@ struct CPU6502 break; } + case 0xCC: { + int addr = read_pc_inc(bus) + read_pc_inc(bus) * 256; + if(debug & DEBUG_DECODE) printf("CPY %04X\n", addr); + unsigned char imm = bus.read(addr); + flag_change(C, imm <= a); + imm = a - imm; + flag_change(N, imm & 0x80); + flag_change(Z, imm == 0); + break; + } + case 0xC0: { unsigned char imm = read_pc_inc(bus); if(debug & DEBUG_DECODE) printf("CPY %02X\n", imm);