NES PPU - only update palettes & patterns if ppu values change, about a 8fps speedup on my machine
This commit is contained in:
parent
6b3d217691
commit
71833f419a
|
@ -27,6 +27,9 @@ namespace BizHawk.MultiClient
|
|||
NES Nes;
|
||||
|
||||
byte[] PPUBus = new byte[0x2000];
|
||||
byte[] PPUBusprev = new byte[0x2000];
|
||||
byte[] PALRAM = new byte[0x20];
|
||||
byte[] PALRAMprev = new byte[0x20];
|
||||
|
||||
NES.PPU.DebugCallback Callback = new NES.PPU.DebugCallback();
|
||||
|
||||
|
@ -35,6 +38,17 @@ namespace BizHawk.MultiClient
|
|||
InitializeComponent();
|
||||
Closing += (o, e) => SaveConfigSettings();
|
||||
Callback.Callback = () => Generate();
|
||||
for (int x = 0; x < 0x2000; x++)
|
||||
{
|
||||
PPUBus[x] = 0;
|
||||
PPUBusprev[x] = 0;
|
||||
}
|
||||
|
||||
for (int x = 0; x < 0x20; x++)
|
||||
{
|
||||
PALRAM[x] = 0;
|
||||
PALRAMprev[x] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private void SaveConfigSettings()
|
||||
|
@ -71,10 +85,32 @@ namespace BizHawk.MultiClient
|
|||
|
||||
if (Global.Emulator.Frame % RefreshRate.Value == 0)
|
||||
{
|
||||
bool Changed = false;
|
||||
for (int x = 0; x < 0x2000; x++)
|
||||
{
|
||||
PPUBusprev[x] = PPUBus[x];
|
||||
PPUBus[x] = Nes.ppu.ppubus_peek(x);
|
||||
if (PPUBus[x] != PPUBusprev[x])
|
||||
Changed = true;
|
||||
}
|
||||
|
||||
//Palette Viewer
|
||||
for (int x = 0; x < 0x20; x++)
|
||||
{
|
||||
PALRAMprev[x] = PALRAM[x];
|
||||
PALRAM[x] = Nes.ppu.PALRAM[x];
|
||||
if (PALRAM[x] != PALRAMprev[x])
|
||||
Changed = true;
|
||||
}
|
||||
|
||||
int b0 = 0;
|
||||
int b1 = 0;
|
||||
byte value;
|
||||
int cvalue;
|
||||
|
||||
if (Changed)
|
||||
{
|
||||
//Pattern Viewer
|
||||
int pal;
|
||||
for (int x = 0; x < 16; x++)
|
||||
{
|
||||
PaletteView.bgPalettesPrev[x].Value = PaletteView.bgPalettes[x].Value;
|
||||
|
@ -85,12 +121,7 @@ namespace BizHawk.MultiClient
|
|||
if (PaletteView.HasChanged())
|
||||
PaletteView.Refresh();
|
||||
|
||||
//Pattern Viewer
|
||||
int b0 = 0;
|
||||
int b1 = 0;
|
||||
byte value;
|
||||
int cvalue;
|
||||
int pal;
|
||||
|
||||
|
||||
System.Drawing.Imaging.BitmapData bmpdata = PatternView.pattern.LockBits(new Rectangle(new Point(0, 0), PatternView.pattern.Size), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
|
||||
int* framebuf = (int*)bmpdata.Scan0.ToPointer();
|
||||
|
@ -123,6 +154,7 @@ namespace BizHawk.MultiClient
|
|||
}
|
||||
PatternView.pattern.UnlockBits(bmpdata);
|
||||
PatternView.Refresh();
|
||||
}
|
||||
|
||||
System.Drawing.Imaging.BitmapData bmpdata2 = SpriteView.sprites.LockBits(new Rectangle(new Point(0, 0), SpriteView.sprites.Size), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
|
||||
int* framebuf2 = (int*)bmpdata2.Scan0.ToPointer();
|
||||
|
@ -131,6 +163,7 @@ namespace BizHawk.MultiClient
|
|||
int pt_add = Nes.ppu.reg_2000.obj_pattern_hi ? 0x1000 : 0;
|
||||
bool is8x16 = Nes.ppu.reg_2000.obj_size_16;
|
||||
|
||||
|
||||
//Sprite Viewer
|
||||
for (int n = 0; n < 4; n++)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue