Added conditional debugging option 'K', for the bank the PC is on. A workaround-style option to address Tracker Item 2007006, which suggests 24-bit breakpoint addresses to account for bank. Testing shows that the bank evaluates to 0 on RAM code access.

This commit is contained in:
ugetab 2010-04-08 21:26:20 +00:00
parent 801f4c7d96
commit bad5a79e91
7 changed files with 58 additions and 30 deletions

View File

@ -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---

View File

@ -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 <stdio.h>
@ -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;

View File

@ -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

View File

@ -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)
{

View File

@ -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);

View File

@ -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

View File

@ -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);