Bug fix for hex editor crashing when changing view to PPU or ROM with no game loaded. Fixes part of #332.

This commit is contained in:
mjbudd77 2021-02-18 19:56:19 -05:00
parent e7e6aac71d
commit 32e897479c
1 changed files with 16 additions and 1 deletions

View File

@ -239,6 +239,10 @@ static int getRAM( unsigned int i )
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
static int getPPU( unsigned int i ) static int getPPU( unsigned int i )
{ {
if (GameInfo == NULL )
{
return 0;
}
i &= 0x3FFF; i &= 0x3FFF;
if (i < 0x2000)return VPage[(i) >> 10][(i)]; if (i < 0x2000)return VPage[(i) >> 10][(i)];
//NSF PPU Viewer crash here (UGETAB) (Also disabled by 'MaxSize = 0x2000') //NSF PPU Viewer crash here (UGETAB) (Also disabled by 'MaxSize = 0x2000')
@ -260,6 +264,10 @@ static int getOAM( unsigned int i )
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
static int getROM( unsigned int offset) static int getROM( unsigned int offset)
{ {
if (GameInfo == NULL )
{
return 0;
}
if (offset < 16) if (offset < 16)
{ {
return *((unsigned char *)&head+offset); return *((unsigned char *)&head+offset);
@ -2953,7 +2961,14 @@ int QHexEdit::getRomAddrColor( int addr, QColor &fg, QColor &bg )
{ {
return -1; return -1;
} }
if ( memAccessFunc )
{
mb.buf[addr].data = memAccessFunc(addr); mb.buf[addr].data = memAccessFunc(addr);
}
else
{
mb.buf[addr].data = 0;
}
if ( (txtHlgtStartAddr != txtHlgtEndAddr) && (addr >= txtHlgtStartAddr) && (addr <= txtHlgtEndAddr) ) if ( (txtHlgtStartAddr != txtHlgtEndAddr) && (addr >= txtHlgtStartAddr) && (addr <= txtHlgtEndAddr) )
{ {