cleanup NES ppu\nt stuff

This commit is contained in:
goyuken 2014-12-17 17:26:47 +00:00
parent 4569a3697b
commit 02b799b491
2 changed files with 33 additions and 33 deletions

View File

@ -14,7 +14,7 @@ namespace BizHawk.Client.EmuHawk
// TODO: // TODO:
// Show Scroll Lines + UI Toggle // Show Scroll Lines + UI Toggle
[RequiredService] [RequiredService]
private INESPPUViewable xxx { get; set; } private INESPPUViewable _ppu { get; set; }
[RequiredService] [RequiredService]
private IEmulator _emu { get; set; } private IEmulator _emu { get; set; }
@ -55,7 +55,7 @@ namespace BizHawk.Client.EmuHawk
public void UpdateValues() public void UpdateValues()
{ {
xxx.InstallCallback1(() => Generate(), scanline); _ppu.InstallCallback1(() => Generate(), scanline);
} }
public void FastUpdate() public void FastUpdate()
@ -86,11 +86,11 @@ namespace BizHawk.Client.EmuHawk
private unsafe void GenerateExAttr(int* dst, int pitch, byte[] palram, byte[] ppumem, byte[] exram) private unsafe void GenerateExAttr(int* dst, int pitch, byte[] palram, byte[] ppumem, byte[] exram)
{ {
byte[] chr = xxx.GetExTiles(); byte[] chr = _ppu.GetExTiles();
int chr_mask = chr.Length - 1; int chr_mask = chr.Length - 1;
fixed (byte* chrptr = chr, palptr = palram, ppuptr = ppumem, exptr = exram) fixed (byte* chrptr = chr, palptr = palram, ppuptr = ppumem, exptr = exram)
fixed (int* finalpal = xxx.GetPalette()) fixed (int* finalpal = _ppu.GetPalette())
{ {
DrawExNT(dst, pitch, palptr, ppuptr + 0x2000, exptr, chrptr, chr_mask, finalpal); DrawExNT(dst, pitch, palptr, ppuptr + 0x2000, exptr, chrptr, chr_mask, finalpal);
DrawExNT(dst + 256, pitch, palptr, ppuptr + 0x2400, exptr, chrptr, chr_mask, finalpal); DrawExNT(dst + 256, pitch, palptr, ppuptr + 0x2400, exptr, chrptr, chr_mask, finalpal);
@ -103,9 +103,9 @@ namespace BizHawk.Client.EmuHawk
private unsafe void GenerateAttr(int* dst, int pitch, byte[] palram, byte[] ppumem) private unsafe void GenerateAttr(int* dst, int pitch, byte[] palram, byte[] ppumem)
{ {
fixed (byte* palptr = palram, ppuptr = ppumem) fixed (byte* palptr = palram, ppuptr = ppumem)
fixed (int* finalpal = xxx.GetPalette()) fixed (int* finalpal = _ppu.GetPalette())
{ {
byte* chrptr = ppuptr + (xxx.BGBaseHigh ? 0x1000 : 0); byte* chrptr = ppuptr + (_ppu.BGBaseHigh ? 0x1000 : 0);
DrawNT(dst, pitch, palptr, ppuptr + 0x2000, chrptr, finalpal); DrawNT(dst, pitch, palptr, ppuptr + 0x2000, chrptr, finalpal);
DrawNT(dst + 256, pitch, palptr, ppuptr + 0x2400, chrptr, finalpal); DrawNT(dst + 256, pitch, palptr, ppuptr + 0x2400, chrptr, finalpal);
dst += pitch * 240; dst += pitch * 240;
@ -179,13 +179,13 @@ namespace BizHawk.Client.EmuHawk
var pitch = bmpdata.Stride / 4; var pitch = bmpdata.Stride / 4;
// 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
var ppuBuffer = xxx.GetPPUBus(); var ppuBuffer = _ppu.GetPPUBus();
var palram = xxx.GetPalRam(); var palram = _ppu.GetPalRam();
if (xxx.ExActive) if (_ppu.ExActive)
{ {
byte[] exram = xxx.GetExRam(); byte[] exram = _ppu.GetExRam();
GenerateExAttr(dptr, pitch, palram, ppuBuffer, exram); GenerateExAttr(dptr, pitch, palram, ppuBuffer, exram);
} }
else else
@ -283,14 +283,14 @@ namespace BizHawk.Client.EmuHawk
private void NESNameTableViewer_FormClosed(object sender, FormClosedEventArgs e) private void NESNameTableViewer_FormClosed(object sender, FormClosedEventArgs e)
{ {
xxx.RemoveCallback1(); _ppu.RemoveCallback1();
} }
private void ScanlineTextbox_TextChanged(object sender, EventArgs e) private void ScanlineTextbox_TextChanged(object sender, EventArgs e)
{ {
if (int.TryParse(txtScanline.Text, out scanline)) if (int.TryParse(txtScanline.Text, out scanline))
{ {
xxx.InstallCallback1(() => Generate(), scanline); _ppu.InstallCallback1(() => Generate(), scanline);
} }
} }
@ -357,7 +357,7 @@ namespace BizHawk.Client.EmuHawk
XYLabel.Text = TileX + " : " + TileY; XYLabel.Text = TileX + " : " + TileY;
int PPUAddress = 0x2000 + (NameTable * 0x400) + ((TileY % 30) * 32) + (TileX % 32); int PPUAddress = 0x2000 + (NameTable * 0x400) + ((TileY % 30) * 32) + (TileX % 32);
PPUAddressLabel.Text = string.Format("{0:X4}", PPUAddress); PPUAddressLabel.Text = string.Format("{0:X4}", PPUAddress);
int TileID = xxx.PeekPPU(PPUAddress); int TileID = _ppu.PeekPPU(PPUAddress);
TileIDLabel.Text = string.Format("{0:X2}", TileID); TileIDLabel.Text = string.Format("{0:X2}", TileID);
TableLabel.Text = NameTable.ToString(); TableLabel.Text = NameTable.ToString();
@ -374,7 +374,7 @@ namespace BizHawk.Client.EmuHawk
int tx = px >> 3; int tx = px >> 3;
int ty = py >> 3; int ty = py >> 3;
int atbyte_ptr = ntaddr + 0x3C0 + ((ty >> 2) << 3) + (tx >> 2); int atbyte_ptr = ntaddr + 0x3C0 + ((ty >> 2) << 3) + (tx >> 2);
int at = xxx.PeekPPU(atbyte_ptr + 0x2000); int at = _ppu.PeekPPU(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;

View File

@ -26,7 +26,7 @@ namespace BizHawk.Client.EmuHawk
private bool _forceChange; private bool _forceChange;
[RequiredService] [RequiredService]
private INESPPUViewable xxx { get; set; } private INESPPUViewable _ppu { get; set; }
[RequiredService] [RequiredService]
private IEmulator _emu { get; set; } private IEmulator _emu { get; set; }
@ -59,7 +59,7 @@ namespace BizHawk.Client.EmuHawk
public void UpdateValues() public void UpdateValues()
{ {
xxx.InstallCallback2(() => Generate(), scanline); _ppu.InstallCallback2(() => Generate(), scanline);
} }
public void FastUpdate() public void FastUpdate()
@ -177,10 +177,10 @@ namespace BizHawk.Client.EmuHawk
if (_emu.Frame % RefreshRate.Value != 0 && !now) if (_emu.Frame % RefreshRate.Value != 0 && !now)
return; return;
byte[] PALRAM = xxx.GetPalRam(); byte[] PALRAM = _ppu.GetPalRam();
int[] FinalPalette = xxx.GetPalette(); int[] FinalPalette = _ppu.GetPalette();
byte[] OAM = xxx.GetOam(); byte[] OAM = _ppu.GetOam();
byte[] PPUBus = xxx.GetPPUBus(); byte[] PPUBus = _ppu.GetPPUBus();
int b0; int b0;
int b1; int b1;
@ -211,8 +211,8 @@ namespace BizHawk.Client.EmuHawk
var bmpdata2 = SpriteView.sprites.LockBits(new Rectangle(new Point(0, 0), SpriteView.sprites.Size), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb); var bmpdata2 = SpriteView.sprites.LockBits(new Rectangle(new Point(0, 0), SpriteView.sprites.Size), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
var framebuf2 = (int*)bmpdata2.Scan0.ToPointer(); var framebuf2 = (int*)bmpdata2.Scan0.ToPointer();
int pt_add = xxx.SPBaseHigh ? 0x1000 : 0; int pt_add = _ppu.SPBaseHigh ? 0x1000 : 0;
bool is8x16 = xxx.SPTall; bool is8x16 = _ppu.SPTall;
// Sprite Viewer // Sprite Viewer
@ -616,10 +616,10 @@ namespace BizHawk.Client.EmuHawk
if (e.X >= SpriteView.ClientRectangle.Right) return; if (e.X >= SpriteView.ClientRectangle.Right) return;
if (e.Y >= SpriteView.ClientRectangle.Bottom) return; if (e.Y >= SpriteView.ClientRectangle.Bottom) return;
byte[] OAM = xxx.GetOam(); byte[] OAM = _ppu.GetOam();
byte[] PPUBus = xxx.GetPPUBus(); // caching is quicker, but not really correct in this case byte[] PPUBus = _ppu.GetPPUBus(); // caching is quicker, but not really correct in this case
bool is8x16 = xxx.SPTall; bool is8x16 = _ppu.SPTall;
var spriteNumber = ((e.Y / 24) * 16) + (e.X / 16); var spriteNumber = ((e.Y / 24) * 16) + (e.X / 16);
int x = OAM[(spriteNumber * 4) + 3]; int x = OAM[(spriteNumber * 4) + 3];
int y = OAM[spriteNumber * 4]; int y = OAM[spriteNumber * 4];
@ -712,7 +712,7 @@ namespace BizHawk.Client.EmuHawk
var bmp = new Bitmap(64, 64); var bmp = new Bitmap(64, 64);
var g = Graphics.FromImage(bmp); var g = Graphics.FromImage(bmp);
byte[] PALRAM = xxx.GetPalRam(); byte[] PALRAM = _ppu.GetPalRam();
if (baseAddr == 0x3F00) if (baseAddr == 0x3F00)
{ {
@ -796,16 +796,16 @@ namespace BizHawk.Client.EmuHawk
tile += (e.Y / 8) * 16; tile += (e.Y / 8) * 16;
var usage = "Usage: "; var usage = "Usage: ";
if (xxx.BGBaseHigh == address >= 0x1000) // bghigh if (_ppu.BGBaseHigh == address >= 0x1000) // bghigh
{ {
usage = "BG"; usage = "BG";
} }
else if (xxx.SPBaseHigh == address >= 0x1000) // sphigh else if (_ppu.SPBaseHigh == address >= 0x1000) // sphigh
{ {
usage = "SPR"; usage = "SPR";
} }
if (xxx.SPTall) // spbig if (_ppu.SPTall) // spbig
{ {
usage += " (SPR16)"; usage += " (SPR16)";
} }
@ -822,13 +822,13 @@ namespace BizHawk.Client.EmuHawk
{ {
if (int.TryParse(txtScanline.Text, out scanline)) if (int.TryParse(txtScanline.Text, out scanline))
{ {
xxx.InstallCallback2(() => Generate(), scanline); _ppu.InstallCallback2(() => Generate(), scanline);
} }
} }
private void NesPPU_FormClosed(object sender, FormClosedEventArgs e) private void NesPPU_FormClosed(object sender, FormClosedEventArgs e)
{ {
xxx.RemoveCallback2(); _ppu.RemoveCallback2();
} }
#endregion #endregion
@ -849,7 +849,7 @@ namespace BizHawk.Client.EmuHawk
private void CHRROMViewReload() private void CHRROMViewReload()
{ {
CHRROM = xxx.GetCHRROM(); CHRROM = _ppu.GetCHRROM();
if (CHRROM == null) if (CHRROM == null)
{ {
numericUpDownCHRROMBank.Enabled = false; numericUpDownCHRROMBank.Enabled = false;
@ -873,7 +873,7 @@ namespace BizHawk.Client.EmuHawk
for (int i = 0; i < 8192; i++) for (int i = 0; i < 8192; i++)
chrromcache[i] = CHRROM.PeekByte(offs + i); chrromcache[i] = CHRROM.PeekByte(offs + i);
DrawPatternView(CHRROMView, chrromcache, xxx.GetPalette(), xxx.GetPalRam()); DrawPatternView(CHRROMView, chrromcache, _ppu.GetPalette(), _ppu.GetPalRam());
} }
} }