From cb890b0960943e3027cf3d0b608ec7d1c7e29bee Mon Sep 17 00:00:00 2001 From: Lauchmelder Date: Sat, 23 Oct 2021 15:55:54 +0200 Subject: [PATCH] fixed opcode table --- NES Emulator/cpu.c | 2 +- NES Emulator/log.c | 4 ++-- NES Emulator/opcodes.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/NES Emulator/cpu.c b/NES Emulator/cpu.c index c3015e9..914f6a9 100644 --- a/NES Emulator/cpu.c +++ b/NES Emulator/cpu.c @@ -403,7 +403,7 @@ void execute(struct CPU* cpu) cpu->x--; cpu->status.negative = ((cpu->x & 0x80) == 0x80); - cpu->status.zero = (cpu->x == 0x80); + cpu->status.zero = (cpu->x == 0x00); } break; case DEY: diff --git a/NES Emulator/log.c b/NES Emulator/log.c index f923fd5..eb96188 100644 --- a/NES Emulator/log.c +++ b/NES Emulator/log.c @@ -19,7 +19,7 @@ void logBusState(struct Bus* bus) sprintf(buffer + 3 * i, "%02X ", instructionBytes[i]); } - printf("%-10s%s ", buffer, bus->cpu->currentOpcode->str); + printf("%-9s%c%s ", buffer, (bus->cpu->currentOpcode->illegal ? '*' : ' '), bus->cpu->currentOpcode->str); switch (bus->cpu->currentOpcode->addr) { @@ -32,7 +32,7 @@ void logBusState(struct Bus* bus) case IND: sprintf(buffer, "($%04X) -> $%04X", (instructionBytes[2] << 8) | instructionBytes[1], bus->cpu->fetchedAddress); break; case INDX: sprintf(buffer, "($%02X, X) -> $%04X", instructionBytes[1], bus->cpu->fetchedAddress); break; case INDY: sprintf(buffer, "($%02X), Y -> $%04X", instructionBytes[1], bus->cpu->fetchedAddress); break; - case REL: sprintf(buffer, "$%02X", bus->cpu->fetchedRelAddress); break; + case REL: sprintf(buffer, "$%02X", (Byte)bus->cpu->fetchedRelAddress); break; case ZPG: sprintf(buffer, "$%02X", bus->cpu->fetchedAddress); break; case ZPX: sprintf(buffer, "$%02X, X -> $%02X", instructionBytes[1], bus->cpu->fetchedAddress); break; case ZPY: sprintf(buffer, "$%02X, Y -> $%02X", instructionBytes[1], bus->cpu->fetchedAddress); break; diff --git a/NES Emulator/opcodes.c b/NES Emulator/opcodes.c index f9ab3e9..1d632ee 100644 --- a/NES Emulator/opcodes.c +++ b/NES Emulator/opcodes.c @@ -269,9 +269,9 @@ const struct Opcode OPCODE_TABLE[256] = /* F7 */ NEW_OPCODE(ISC, ZPX, 6, 2, 1), /* F8 */ NEW_OPCODE(SED, IMP, 2, 1, 0), /* F9 */ NEW_OPCODE(SBC, ABY, 4, 3, 0), - /* FA */ NEW_OPCODE(SBC, ABY, 4, 3, 1), - /* FB */ NEW_OPCODE(NOP, IMP, 2, 1, 1), + /* FA */ NEW_OPCODE(NOP, IMP, 2, 1, 1), /* FC */ NEW_OPCODE(ISC, ABY, 7, 3, 1), + /* FB */ NEW_OPCODE(NOP, ABX, 4, 3, 1), /* FD */ NEW_OPCODE(SBC, ABX, 4, 3, 0), /* FE */ NEW_OPCODE(INC, ABX, 7, 3, 0), /* FF */ NEW_OPCODE(ISC, ABX, 7, 3, 1)