NES Nametable Viewer - more pre-reading of ppu bus data, about another 5 fps bump

This commit is contained in:
andres.delikat 2011-09-04 03:23:00 +00:00
parent 04b5cafe3a
commit 353e1dbcd8
1 changed files with 9 additions and 8 deletions

View File

@ -50,10 +50,11 @@ namespace BizHawk.MultiClient
int pitch = bmpdata.Stride / 4; int pitch = bmpdata.Stride / 4;
int pt_add = Nes.ppu.reg_2000.bg_pattern_hi ? 0x1000 : 0; int pt_add = Nes.ppu.reg_2000.bg_pattern_hi ? 0x1000 : 0;
//TODO - buffer all the data from the ppu, because it will be read multiple times and that is slow //buffer all the data from the ppu, because it will be read multiple times and that is slow
int[] p = new int[0x1000]; int[] p = new int[0x3000];
for (int x = 0; x < 0x1000; x++) for (int x = 0; x < 0x3000; x++)
p[x] = Nes.ppu.ppubus_peek(0x2000 + x); p[x] = Nes.ppu.ppubus_peek(x);
int ytable = 0, yline = 0; int ytable = 0, yline = 0;
for (int y = 0; y < 480; y++) for (int y = 0; y < 480; y++)
{ {
@ -72,9 +73,9 @@ namespace BizHawk.MultiClient
int ty = py >> 3; int ty = py >> 3;
int ntbyte_ptr = ntaddr + (ty * 32) + tx; int ntbyte_ptr = ntaddr + (ty * 32) + tx;
int atbyte_ptr = ntaddr + 0x3C0 + ((ty >> 2) << 3) + (tx >> 2); int atbyte_ptr = ntaddr + 0x3C0 + ((ty >> 2) << 3) + (tx >> 2);
int nt = p[ntbyte_ptr]; int nt = p[ntbyte_ptr + 0x2000];
int at = p[atbyte_ptr]; int at = p[atbyte_ptr + 0x2000];
if ((ty & 2) != 0) at >>= 4; if ((ty & 2) != 0) at >>= 4;
if ((tx & 2) != 0) at >>= 2; if ((tx & 2) != 0) at >>= 2;
at &= 0x03; at &= 0x03;
@ -83,8 +84,8 @@ namespace BizHawk.MultiClient
int bgpx = x & 7; int bgpx = x & 7;
int bgpy = y & 7; int bgpy = y & 7;
int pt_addr = (nt << 4) + bgpy + pt_add; int pt_addr = (nt << 4) + bgpy + pt_add;
int pt_0 = Nes.ppu.ppubus_peek(pt_addr); int pt_0 = p[pt_addr];
int pt_1 = Nes.ppu.ppubus_peek(pt_addr + 8); int pt_1 = p[pt_addr + 8];
int pixel = ((pt_0 >> (7 - bgpx)) & 1) | (((pt_1 >> (7 - bgpx)) & 1) << 1); int pixel = ((pt_0 >> (7 - bgpx)) & 1) | (((pt_1 >> (7 - bgpx)) & 1) << 1);
//if the pixel is transparent, draw the backdrop color //if the pixel is transparent, draw the backdrop color