diff --git a/changelog.txt b/changelog.txt index 76ae96da..98226d31 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,4 @@ +08-april-2010 - ugetab - Win32 - Added conditional debugging option 'K', for bank PC is on 07-april-2010 - adelikat - fix bug that caused zapper.read() to crash when movie playback ends ---r1767 - FCEUX 2.1.3 Released--- diff --git a/src/conddebug.cpp b/src/conddebug.cpp index 1a66e1ae..c93b4c0c 100644 --- a/src/conddebug.cpp +++ b/src/conddebug.cpp @@ -36,6 +36,7 @@ * Address -> '$' [1-9A-F]* | '$' '[' Connect ']' * Register -> 'A' | 'X' | 'Y' | 'R' * Flag -> 'N' | 'C' | 'Z' | 'I' | 'B' | 'V' +* PC Bank -> 'K' */ #include @@ -131,6 +132,12 @@ int isRegister(char c) return c == 'A' || c == 'X' || c == 'Y' || c == 'P'; } +// Determines if a character is for bank +int isBank(char c) +{ + return c == 'K'; +} + // Reads a hexadecimal number from str int getNumber(unsigned int* number, const char** str) { @@ -217,6 +224,23 @@ Condition* Primitive(const char** str, Condition* c) return c; } + else if (isBank(next)) /* Registers */ + { + if (c->type1 == TYPE_NO) + { + c->type1 = TYPE_BANK; + c->value1 = next; + } + else + { + c->type2 = TYPE_BANK; + c->value2 = next; + } + + scan(str); + + return c; + } else if (next == '#') /* Numbers */ { unsigned int number = 0; diff --git a/src/conddebug.h b/src/conddebug.h index 20ed106c..463d5e34 100644 --- a/src/conddebug.h +++ b/src/conddebug.h @@ -26,6 +26,7 @@ #define TYPE_FLAG 2 #define TYPE_NUM 3 #define TYPE_ADDR 4 +#define TYPE_BANK 5 #define OP_NO 0 #define OP_EQ 1 diff --git a/src/debug.cpp b/src/debug.cpp index e293e0e5..7c420d02 100644 --- a/src/debug.cpp +++ b/src/debug.cpp @@ -202,6 +202,29 @@ int GetPRGAddress(int A){ else return result; } +/** +* Returns the bank for a given offset. +* Technically speaking this function does not calculate the actual bank +* where the offset resides but the 0x4000 bytes large chunk of the ROM of the offset. +* +* @param offs The offset +* @return The bank of that offset or -1 if the offset is not part of the ROM. +**/ +int getBank(int offs) +{ + //NSF data is easy to overflow the return on. + //Anything over FFFFF will kill it. + + + //GetNesFileAddress doesn't work well with Unif files + int addr = GetNesFileAddress(offs)-16; + + if (GameInfo && GameInfo->type==GIT_NSF) { + return addr != -1 ? addr / 0x1000 : -1; + } + return addr != -1 ? addr / 0x4000 : -1; +} + int GetNesFileAddress(int A){ unsigned int result; if((A < 0x8000) || (A > 0xFFFF))return -1; @@ -278,9 +301,10 @@ int evaluate(Condition* c) } } - if (c->type1 == TYPE_ADDR) + switch(c->type1) { - value1 = GetMem(value1); + case TYPE_ADDR: value1 = GetMem(value1); + case TYPE_BANK: value1 = getBank(_PC); } f = value1; @@ -301,10 +325,11 @@ int evaluate(Condition* c) } } - if (c->type2 == TYPE_ADDR) - { - value2 = GetMem(value2); - } + switch(c->type2) + { + case TYPE_ADDR: value2 = GetMem(value2); + case TYPE_BANK: value2 = getBank(_PC); + } switch (c->op) { diff --git a/src/debug.h b/src/debug.h index dc4b360e..35f34a15 100644 --- a/src/debug.h +++ b/src/debug.h @@ -55,6 +55,7 @@ typedef struct { //mbg merge 7/18/06 had to make this extern extern watchpointinfo watchpoint[65]; //64 watchpoints, + 1 reserved for step over +int getBank(int offs); int GetNesFileAddress(int A); int GetPRGAddress(int A); int GetRomAddress(int A); diff --git a/src/drivers/win/debuggersp.cpp b/src/drivers/win/debuggersp.cpp index 1957999f..ceec93a4 100644 --- a/src/drivers/win/debuggersp.cpp +++ b/src/drivers/win/debuggersp.cpp @@ -89,29 +89,6 @@ void replaceString(char* src, const char* r, const char* w) strcpy(beg, buff); } -/** -* Returns the bank for a given offset. -* Technically speaking this function does not calculate the actual bank -* where the offset resides but the 0x4000 bytes large chunk of the ROM of the offset. -* -* @param offs The offset -* @return The bank of that offset or -1 if the offset is not part of the ROM. -**/ -int getBank(int offs) -{ - //NSF data is easy to overflow the return on. - //Anything over FFFFF will kill it. - - - //GetNesFileAddress doesn't work well with Unif files - int addr = GetNesFileAddress(offs)-16; - - if (GameInfo && GameInfo->type==GIT_NSF) { - return addr != -1 ? addr / 0x1000 : -1; - } - return addr != -1 ? addr / 0x4000 : -1; -} - /** * Parses a line from a NL file. * @param line The line to parse diff --git a/src/drivers/win/debuggersp.h b/src/drivers/win/debuggersp.h index 30cd3210..dacd723b 100644 --- a/src/drivers/win/debuggersp.h +++ b/src/drivers/win/debuggersp.h @@ -42,6 +42,5 @@ void AddDebuggerBookmark(HWND hwnd); void AddDebuggerBookmark2(HWND hwnd, char* buffer); void DeleteDebuggerBookmark(HWND hwnd); void GoToDebuggerBookmark(HWND hwnd); -int getBank(int offs); void dumpBookmarks(HWND hwmd); int isHex(char c);