From a4fa6225a04b5ab8d3dfca3fc9abd7190bceec85 Mon Sep 17 00:00:00 2001 From: g0me3 Date: Fri, 7 May 2021 20:11:01 +0200 Subject: [PATCH] little fix to more correct fds cdl --- src/debug.cpp | 47 +++++++++++++++++++++++++++--------- src/drivers/win/cdlogger.cpp | 13 +++++++--- 2 files changed, 45 insertions(+), 15 deletions(-) diff --git a/src/debug.cpp b/src/debug.cpp index 11f4594e..a940194b 100644 --- a/src/debug.cpp +++ b/src/debug.cpp @@ -214,11 +214,22 @@ int GetPRGAddress(int A){ int result; if(A > 0xFFFF) return -1; - result = &Page[A>>11][A]-PRGptr[0]; - if((result > (int)PRGsize[0]) || (result < 0)) - return -1; - else - return result; + if (GameInfo->type == GIT_FDS) { + if (A >= 0xE000) + return -1; + result = &Page[A >> 11][A] - PRGptr[1]; + if ((result > (int)PRGsize[1]) || (result < 0)) + return -1; + else + return result; + } + else { + result = &Page[A >> 11][A] - PRGptr[0]; + if ((result > (int)PRGsize[0]) || (result < 0)) + return -1; + else + return result; + } } /** @@ -481,13 +492,25 @@ void LogCDData(uint8 *opcode, uint16 A, int size) { } if((j = GetPRGAddress(A)) != -1) { - if(!(cdloggerdata[j] & 2)) { - cdloggerdata[j] |= 2; - cdloggerdata[j] |=(A>>11)&0x0c; - cdloggerdata[j] |= memop; - datacount++; - if(!(cdloggerdata[j] & 1))undefinedcount--; - } + if (opwrite[opcode[0]] == 0) { + if (!(cdloggerdata[j] & 2)) { + cdloggerdata[j] |= 2; + cdloggerdata[j] |= (A >> 11) & 0x0c; + cdloggerdata[j] |= memop; + datacount++; + if (!(cdloggerdata[j] & 1))undefinedcount--; + } + } /* else { + if (cdloggerdata[j] & 1) { + codecount--; + if (!(cdloggerdata[j] & 2))undefinedcount--; + } + if (cdloggerdata[j] & 2) { + datacount--; + if (!(cdloggerdata[j] & 1))undefinedcount--; + } + cdloggerdata[j] = 0; + } */ } } diff --git a/src/drivers/win/cdlogger.cpp b/src/drivers/win/cdlogger.cpp index 091bb8d8..440713f8 100644 --- a/src/drivers/win/cdlogger.cpp +++ b/src/drivers/win/cdlogger.cpp @@ -448,12 +448,16 @@ void SaveStrippedROM(int invert) fwrite(&cdlhead,1,16,fp); + int rom_sel = 0; + if (GameInfo->type == GIT_FDS) + rom_sel = 1; + cdloggerdataSize = PRGsize[rom_sel]; for(i = 0; i < (int)cdloggerdataSize; i++){ unsigned char pchar; if(cdloggerdata[i] & 3) - pchar = invert?0:PRGptr[0][i]; + pchar = invert?0:PRGptr[rom_sel][i]; else - pchar = invert?PRGptr[0][i]:0; + pchar = invert?PRGptr[rom_sel][i]:0; fputc(pchar, fp); } @@ -555,7 +559,10 @@ void FreeCDLog() void InitCDLog() { - cdloggerdataSize = PRGsize[0]; + int rom_sel = 0; + if (GameInfo->type == GIT_FDS) + rom_sel = 1; + cdloggerdataSize = PRGsize[rom_sel]; cdloggerdata = (unsigned char*)malloc(cdloggerdataSize); if(!CHRram[0] || (CHRptr[0] == PRGptr[0])) { // Some kind of workaround for my OneBus VRAM hack, will remove it if I find another solution for that cdloggerVideoDataSize = CHRsize[0];