From 9da80206f8872138fcb5e51b68d87ccd78173103 Mon Sep 17 00:00:00 2001 From: Jay Oster Date: Thu, 12 Sep 2024 15:25:00 -0700 Subject: [PATCH 1/2] Fix PRG writes in CD Logger This code was added for FDS RAM, but it breaks PRG writes with normal cartridge-based memory controllers. The bug inappropriately resets (clears) the access mode bits previously recorded when an MMIO register is written in PRG address space. For instance, if an instruction is executed at $8000 and then some code later writes to $8000, the instruction execution would have been forgotten. --- src/debug.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/debug.cpp b/src/debug.cpp index eef528e56..217173570 100644 --- a/src/debug.cpp +++ b/src/debug.cpp @@ -569,7 +569,12 @@ void LogCDData(uint8 *opcode, uint16 A, int size) newDataHit = true; } } - else + // Unclear why the write destination's access types gets reset for FDS... + // See: + // - https://github.com/TASEmulators/fceux/commit/a4fa6225a04b5ab8d3dfca3fc9abd7190bceec85 + // - https://github.com/TASEmulators/fceux/commit/b10b6254c3d5c9519a85cb4382cdb22846d2e394 + // - https://github.com/TASEmulators/fceux/commit/67942accc72149ae028d58f36419b64ea8651db9?diff=unified&w=1 + else if(GameInfo && GameInfo->type == GIT_FDS) { if (cdloggerdata[j] & 1) { From 65f4a482d560cf9e1e04b4ee4601245da7b74695 Mon Sep 17 00:00:00 2001 From: Jay Oster Date: Fri, 13 Sep 2024 12:37:11 -0700 Subject: [PATCH 2/2] Do not treat jump destinations as data accesses The two JMP instructions have address modes that imply a data access occurs. All branch instructions and JSR have `optype` 0, so they don't have this problem. --- src/debug.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/debug.cpp b/src/debug.cpp index 217173570..c34e6cd2f 100644 --- a/src/debug.cpp +++ b/src/debug.cpp @@ -554,7 +554,7 @@ void LogCDData(uint8 *opcode, uint16 A, int size) case 4: memop = 0x20; break; } - if ((j = GetPRGAddress(A)) != -1) + if (((j = GetPRGAddress(A)) != -1) && (opcode[0] != 0x4C) && (opcode[0] != 0x6C)) { if (opwrite[opcode[0]] == 0) {