From 02b799b491b19a1edf4d57cd7692ab1a6f77a104 Mon Sep 17 00:00:00 2001 From: goyuken Date: Wed, 17 Dec 2014 17:26:47 +0000 Subject: [PATCH] cleanup NES ppu\nt stuff --- .../tools/NES/NESNameTableViewer.cs | 28 +++++++------- BizHawk.Client.EmuHawk/tools/NES/NESPPU.cs | 38 +++++++++---------- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/BizHawk.Client.EmuHawk/tools/NES/NESNameTableViewer.cs b/BizHawk.Client.EmuHawk/tools/NES/NESNameTableViewer.cs index 28017fadbe..49d48ee18b 100644 --- a/BizHawk.Client.EmuHawk/tools/NES/NESNameTableViewer.cs +++ b/BizHawk.Client.EmuHawk/tools/NES/NESNameTableViewer.cs @@ -14,7 +14,7 @@ namespace BizHawk.Client.EmuHawk // TODO: // Show Scroll Lines + UI Toggle [RequiredService] - private INESPPUViewable xxx { get; set; } + private INESPPUViewable _ppu { get; set; } [RequiredService] private IEmulator _emu { get; set; } @@ -55,7 +55,7 @@ namespace BizHawk.Client.EmuHawk public void UpdateValues() { - xxx.InstallCallback1(() => Generate(), scanline); + _ppu.InstallCallback1(() => Generate(), scanline); } 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) { - byte[] chr = xxx.GetExTiles(); + byte[] chr = _ppu.GetExTiles(); int chr_mask = chr.Length - 1; 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 + 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) { 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 + 256, pitch, palptr, ppuptr + 0x2400, chrptr, finalpal); dst += pitch * 240; @@ -179,13 +179,13 @@ namespace BizHawk.Client.EmuHawk var pitch = bmpdata.Stride / 4; // 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); } else @@ -283,14 +283,14 @@ namespace BizHawk.Client.EmuHawk private void NESNameTableViewer_FormClosed(object sender, FormClosedEventArgs e) { - xxx.RemoveCallback1(); + _ppu.RemoveCallback1(); } private void ScanlineTextbox_TextChanged(object sender, EventArgs e) { 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; int PPUAddress = 0x2000 + (NameTable * 0x400) + ((TileY % 30) * 32) + (TileX % 32); PPUAddressLabel.Text = string.Format("{0:X4}", PPUAddress); - int TileID = xxx.PeekPPU(PPUAddress); + int TileID = _ppu.PeekPPU(PPUAddress); TileIDLabel.Text = string.Format("{0:X2}", TileID); TableLabel.Text = NameTable.ToString(); @@ -374,7 +374,7 @@ namespace BizHawk.Client.EmuHawk int tx = px >> 3; int ty = py >> 3; 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 ((tx & 2) != 0) at >>= 2; at &= 0x03; diff --git a/BizHawk.Client.EmuHawk/tools/NES/NESPPU.cs b/BizHawk.Client.EmuHawk/tools/NES/NESPPU.cs index e05aedce13..00da1ab956 100644 --- a/BizHawk.Client.EmuHawk/tools/NES/NESPPU.cs +++ b/BizHawk.Client.EmuHawk/tools/NES/NESPPU.cs @@ -26,7 +26,7 @@ namespace BizHawk.Client.EmuHawk private bool _forceChange; [RequiredService] - private INESPPUViewable xxx { get; set; } + private INESPPUViewable _ppu { get; set; } [RequiredService] private IEmulator _emu { get; set; } @@ -59,7 +59,7 @@ namespace BizHawk.Client.EmuHawk public void UpdateValues() { - xxx.InstallCallback2(() => Generate(), scanline); + _ppu.InstallCallback2(() => Generate(), scanline); } public void FastUpdate() @@ -177,10 +177,10 @@ namespace BizHawk.Client.EmuHawk if (_emu.Frame % RefreshRate.Value != 0 && !now) return; - byte[] PALRAM = xxx.GetPalRam(); - int[] FinalPalette = xxx.GetPalette(); - byte[] OAM = xxx.GetOam(); - byte[] PPUBus = xxx.GetPPUBus(); + byte[] PALRAM = _ppu.GetPalRam(); + int[] FinalPalette = _ppu.GetPalette(); + byte[] OAM = _ppu.GetOam(); + byte[] PPUBus = _ppu.GetPPUBus(); int b0; 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 framebuf2 = (int*)bmpdata2.Scan0.ToPointer(); - int pt_add = xxx.SPBaseHigh ? 0x1000 : 0; - bool is8x16 = xxx.SPTall; + int pt_add = _ppu.SPBaseHigh ? 0x1000 : 0; + bool is8x16 = _ppu.SPTall; // Sprite Viewer @@ -616,10 +616,10 @@ namespace BizHawk.Client.EmuHawk if (e.X >= SpriteView.ClientRectangle.Right) return; if (e.Y >= SpriteView.ClientRectangle.Bottom) return; - byte[] OAM = xxx.GetOam(); - byte[] PPUBus = xxx.GetPPUBus(); // caching is quicker, but not really correct in this case + byte[] OAM = _ppu.GetOam(); + 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); int x = OAM[(spriteNumber * 4) + 3]; int y = OAM[spriteNumber * 4]; @@ -712,7 +712,7 @@ namespace BizHawk.Client.EmuHawk var bmp = new Bitmap(64, 64); var g = Graphics.FromImage(bmp); - byte[] PALRAM = xxx.GetPalRam(); + byte[] PALRAM = _ppu.GetPalRam(); if (baseAddr == 0x3F00) { @@ -796,16 +796,16 @@ namespace BizHawk.Client.EmuHawk tile += (e.Y / 8) * 16; var usage = "Usage: "; - if (xxx.BGBaseHigh == address >= 0x1000) // bghigh + if (_ppu.BGBaseHigh == address >= 0x1000) // bghigh { usage = "BG"; } - else if (xxx.SPBaseHigh == address >= 0x1000) // sphigh + else if (_ppu.SPBaseHigh == address >= 0x1000) // sphigh { usage = "SPR"; } - if (xxx.SPTall) // spbig + if (_ppu.SPTall) // spbig { usage += " (SPR16)"; } @@ -822,13 +822,13 @@ namespace BizHawk.Client.EmuHawk { if (int.TryParse(txtScanline.Text, out scanline)) { - xxx.InstallCallback2(() => Generate(), scanline); + _ppu.InstallCallback2(() => Generate(), scanline); } } private void NesPPU_FormClosed(object sender, FormClosedEventArgs e) { - xxx.RemoveCallback2(); + _ppu.RemoveCallback2(); } #endregion @@ -849,7 +849,7 @@ namespace BizHawk.Client.EmuHawk private void CHRROMViewReload() { - CHRROM = xxx.GetCHRROM(); + CHRROM = _ppu.GetCHRROM(); if (CHRROM == null) { numericUpDownCHRROMBank.Enabled = false; @@ -873,7 +873,7 @@ namespace BizHawk.Client.EmuHawk for (int i = 0; i < 8192; i++) chrromcache[i] = CHRROM.PeekByte(offs + i); - DrawPatternView(CHRROMView, chrromcache, xxx.GetPalette(), xxx.GetPalRam()); + DrawPatternView(CHRROMView, chrromcache, _ppu.GetPalette(), _ppu.GetPalRam()); } }