Added a macro for NES header size to avoid having magic number 16 all over code. Fixed ld65 bank calculation to account for header.
This commit is contained in:
parent
b33b27c25b
commit
53cf1eaf2a
|
@ -266,7 +266,7 @@ int getBank(int offs)
|
|||
//Anything over FFFFF will kill it.
|
||||
|
||||
//GetNesFileAddress doesn't work well with Unif files
|
||||
int addr = GetNesFileAddress(offs)-16;
|
||||
int addr = GetNesFileAddress(offs)-NES_HEADER_SIZE;
|
||||
|
||||
if (GameInfo && GameInfo->type==GIT_NSF)
|
||||
return addr != -1 ? addr / 0x1000 : -1;
|
||||
|
@ -278,12 +278,12 @@ int GetNesFileAddress(int A){
|
|||
if((A < 0x6000) || (A > 0xFFFF))return -1;
|
||||
result = &Page[A>>11][A]-PRGptr[0];
|
||||
if((result > (int)(PRGsize[0])) || (result < 0))return -1;
|
||||
else return result+16; //16 bytes for the header remember
|
||||
else return result+NES_HEADER_SIZE; //16 bytes for the header remember
|
||||
}
|
||||
|
||||
int GetRomAddress(int A){
|
||||
int i;
|
||||
uint8 *p = GetNesPRGPointer(A-=16);
|
||||
uint8 *p = GetNesPRGPointer(A-=NES_HEADER_SIZE);
|
||||
for(i = 16;i < 32;i++){
|
||||
if((&Page[i][i<<11] <= p) && (&Page[i][(i+1)<<11] > p))break;
|
||||
}
|
||||
|
|
|
@ -749,7 +749,7 @@ int debugSymbolTable_t::loadGameSymbols(void)
|
|||
|
||||
if ( GameInfo != nullptr )
|
||||
{
|
||||
romSize = 16 + CHRsize[0] + PRGsize[0];
|
||||
romSize = NES_HEADER_SIZE + CHRsize[0] + PRGsize[0];
|
||||
}
|
||||
|
||||
loadFileNL( -1 );
|
||||
|
@ -934,7 +934,7 @@ void debugSymbolTable_t::ld65_SymbolLoad( ld65::sym *s )
|
|||
//printf("Symbol Label Load: name:\"%s\" val:%i 0x%x\n", s->name(), s->value(), s->value() );
|
||||
if (seg)
|
||||
{
|
||||
int romAddr = seg->ofs();
|
||||
int romAddr = seg->ofs() - NES_HEADER_SIZE;
|
||||
|
||||
bank = romAddr >= 0 ? romAddr / (1<<debuggerPageSize) : -1;
|
||||
|
||||
|
@ -968,7 +968,7 @@ void debugSymbolTable_t::ld65_SymbolLoad( ld65::sym *s )
|
|||
|
||||
if ( page->addSymbol( sym ) )
|
||||
{
|
||||
//printf("Failed to load sym: '%s'\n", s->name() );
|
||||
//printf("Failed to load sym: id:%i name:'%s' bank:%i \n", s->id(), s->name(), bank );
|
||||
delete sym;
|
||||
}
|
||||
}
|
||||
|
@ -982,6 +982,7 @@ int debugSymbolTable_t::ld65LoadDebugFile( const char *dbgFilePath )
|
|||
{
|
||||
return -1;
|
||||
}
|
||||
FCEU::autoScopedLock alock(cs);
|
||||
|
||||
db.iterateSymbols( this, ld65_iterate_cb );
|
||||
|
||||
|
|
|
@ -185,4 +185,5 @@ extern uint8 vsdip;
|
|||
#define EMULATIONPAUSED_FA 2
|
||||
|
||||
#define FRAMEADVANCE_DELAY_DEFAULT 10
|
||||
#define NES_HEADER_SIZE 16
|
||||
|
||||
|
|
|
@ -70,6 +70,8 @@ namespace ld65
|
|||
|
||||
sym( int id, const char *name = nullptr, int size = 0, int value = 0, int type = IMPORT);
|
||||
|
||||
int id(void){ return _id; };
|
||||
|
||||
const char *name(void){ return _name.c_str(); };
|
||||
|
||||
int size(void){ return _size; };
|
||||
|
|
Loading…
Reference in New Issue