NESHawk: Remove GOTOs

This commit is contained in:
alyosha-tas 2019-01-27 17:18:16 -06:00
parent 76070cd89d
commit 1981877487
2 changed files with 33 additions and 12 deletions

View File

@ -255,7 +255,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
// top 2 bits of address come from chr_reg_high
bank_1k += chr_reg_high << 8;
ofs = addr & (4 * 1024 - 1);
goto MAPPED;
bank_1k &= chr_bank_mask_1k;
addr = (bank_1k << 10) | ofs;
return addr;
}
if (NES.ppu.reg_2000.obj_size_16)
@ -278,7 +281,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
bank_1k = a_banks_1k[bank_1k];
}
MAPPED:
bank_1k &= chr_bank_mask_1k;
addr = (bank_1k<<10)|ofs;
return addr;

View File

@ -105,6 +105,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
int sum = 0;
int ymin = Math.Max(Math.Max(y - radius, ppur.status.sl - 20), 0);
if (ymin > 239) { ymin = 239; }
int ymax = Math.Min(y + radius, 239);
int xmin = Math.Max(x - radius, 0);
int xmax = Math.Min(x + radius, 255);
@ -112,21 +113,39 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
int ystop = ppur.status.sl - 2;
int xstop = ppur.status.cycle - 20;
for (int j = ymin; j <= ymax; j++)
bool all_stop = false;
int j = ymin;
int i = xmin;
short s = 0;
short palcolor = 0;
short intensity = 0;
if (j >= ystop && i >= xstop || j > ystop) { all_stop = true; }
while (!all_stop)
{
for (int i = xmin; i <= xmax; i++)
s = xbuf[j * 256 + i];
palcolor = (short)(s & 0x3F);
intensity = (short)((s >> 6) & 0x7);
sum += _currentLuma[palcolor];
i++;
if (i > xmax)
{
if (j >= ystop && i >= xstop || j > ystop)
goto loopout;
i = xmin;
j++;
short s = xbuf[j * 256 + i];
short palcolor = (short)(s & 0x3F);
short intensity = (short)((s >> 6) & 0x7);
sum += _currentLuma[palcolor];
if (j > ymax)
{
all_stop = true;
}
}
if (j >= ystop && i >= xstop || j > ystop) { all_stop = true; }
}
loopout:
return sum >= 2000;
}