nes: squeeze a few more percent out of the nametable viewer

This commit is contained in:
goyuken 2014-03-01 23:43:04 +00:00
parent 877d81b0ff
commit 92c934b9a9
2 changed files with 25 additions and 14 deletions
BizHawk.Client.EmuHawk/tools/NES
BizHawk.Emulation.Cores/Consoles/Nintendo/NES

View File

@ -72,7 +72,7 @@ namespace BizHawk.Client.EmuHawk
#endregion
private unsafe void DrawTile(int* dst, int pitch, byte* pal, byte* tile)
private unsafe void DrawTile(int* dst, int pitch, byte* pal, byte* tile, int* finalpal)
{
dst += 7;
int vinc = pitch + 8;
@ -82,7 +82,7 @@ namespace BizHawk.Client.EmuHawk
int hi = tile[8] << 1;
for (int i = 0; i < 8; i++)
{
*dst-- = _nes.LookupColor(pal[lo & 1 | hi & 2]);
*dst-- = finalpal[pal[lo & 1 | hi & 2]];
lo >>= 1;
hi >>= 1;
}
@ -97,29 +97,31 @@ namespace BizHawk.Client.EmuHawk
int chr_mask = chr.Length - 1;
fixed (byte* chrptr = chr, palptr = palram, ppuptr = ppumem, exptr = exram)
fixed (int* finalpal = _nes.GetCompiledPalette())
{
DrawExNT(dst, pitch, palptr, ppuptr + 0x2000, exptr, chrptr, chr_mask);
DrawExNT(dst + 256, pitch, palptr, ppuptr + 0x2400, exptr, chrptr, chr_mask);
DrawExNT(dst, pitch, palptr, ppuptr + 0x2000, exptr, chrptr, chr_mask, finalpal);
DrawExNT(dst + 256, pitch, palptr, ppuptr + 0x2400, exptr, chrptr, chr_mask, finalpal);
dst += pitch * 240;
DrawExNT(dst, pitch, palptr, ppuptr + 0x2800, exptr, chrptr, chr_mask);
DrawExNT(dst + 256, pitch, palptr, ppuptr + 0x2c00, exptr, chrptr, chr_mask);
DrawExNT(dst, pitch, palptr, ppuptr + 0x2800, exptr, chrptr, chr_mask, finalpal);
DrawExNT(dst + 256, pitch, palptr, ppuptr + 0x2c00, exptr, chrptr, chr_mask, finalpal);
}
}
private unsafe void GenerateAttr(int* dst, int pitch, byte[] palram, byte[] ppumem)
{
fixed (byte* palptr = palram, ppuptr = ppumem)
fixed (int* finalpal = _nes.GetCompiledPalette())
{
byte* chrptr = ppuptr + (_nes.ppu.reg_2000.bg_pattern_hi ? 0x1000 : 0);
DrawNT(dst, pitch, palptr, ppuptr + 0x2000, chrptr);
DrawNT(dst + 256, pitch, palptr, ppuptr + 0x2400, chrptr);
DrawNT(dst, pitch, palptr, ppuptr + 0x2000, chrptr, finalpal);
DrawNT(dst + 256, pitch, palptr, ppuptr + 0x2400, chrptr, finalpal);
dst += pitch * 240;
DrawNT(dst, pitch, palptr, ppuptr + 0x2800, chrptr);
DrawNT(dst + 256, pitch, palptr, ppuptr + 0x2c00, chrptr);
DrawNT(dst, pitch, palptr, ppuptr + 0x2800, chrptr, finalpal);
DrawNT(dst + 256, pitch, palptr, ppuptr + 0x2c00, chrptr, finalpal);
}
}
private unsafe void DrawNT(int* dst, int pitch, byte* palram, byte* nt, byte* chr)
private unsafe void DrawNT(int* dst, int pitch, byte* palram, byte* nt, byte* chr, int* finalpal)
{
byte* at = nt + 0x3c0;
@ -134,7 +136,7 @@ namespace BizHawk.Client.EmuHawk
int palnum = a & 3;
int tileaddr = t << 4;
DrawTile(dst, pitch, palram + palnum * 4, chr + tileaddr);
DrawTile(dst, pitch, palram + palnum * 4, chr + tileaddr, finalpal);
dst += 8;
}
dst -= 256;
@ -142,7 +144,7 @@ namespace BizHawk.Client.EmuHawk
}
}
private unsafe void DrawExNT(int* dst, int pitch, byte* palram, byte* nt, byte* exnt, byte* chr, int chr_mask)
private unsafe void DrawExNT(int* dst, int pitch, byte* palram, byte* nt, byte* exnt, byte* chr, int chr_mask, int* finalpal)
{
for (int ty = 0; ty < 30; ty++)
{
@ -155,7 +157,7 @@ namespace BizHawk.Client.EmuHawk
int palnum = ex >> 6;
int tileaddr = tilenum << 4 & chr_mask;
DrawTile(dst, pitch, palram + palnum * 4, chr + tileaddr);
DrawTile(dst, pitch, palram + palnum * 4, chr + tileaddr, finalpal);
dst += 8;
}
dst -= 256;

View File

@ -63,6 +63,15 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
return board;
}
/// <summary>
/// for debugging only!
/// </summary>
/// <returns></returns>
public int[] GetCompiledPalette()
{
return palette_compiled;
}
public void Dispose()
{
if (magicSoundProvider != null) magicSoundProvider.Dispose();