diff --git a/BizHawk.Client.EmuHawk/tools/NES/NESNameTableViewer.Designer.cs b/BizHawk.Client.EmuHawk/tools/NES/NESNameTableViewer.Designer.cs
index 7f9f56a32b..10753f142d 100644
--- a/BizHawk.Client.EmuHawk/tools/NES/NESNameTableViewer.Designer.cs
+++ b/BizHawk.Client.EmuHawk/tools/NES/NESNameTableViewer.Designer.cs
@@ -184,7 +184,7 @@
this.txtScanline.Size = new System.Drawing.Size(60, 20);
this.txtScanline.TabIndex = 2;
this.txtScanline.Text = "0";
- this.txtScanline.TextChanged += new System.EventHandler(this.ScanlineTextbox_TextChanged);
+ this.txtScanline.TextChanged += new System.EventHandler(this.ScanlineTextBox_TextChanged);
//
// rbNametableNW
//
diff --git a/BizHawk.Client.EmuHawk/tools/NES/NESNameTableViewer.cs b/BizHawk.Client.EmuHawk/tools/NES/NESNameTableViewer.cs
index 2f8d37f9fd..c49aaee196 100644
--- a/BizHawk.Client.EmuHawk/tools/NES/NESNameTableViewer.cs
+++ b/BizHawk.Client.EmuHawk/tools/NES/NESNameTableViewer.cs
@@ -23,7 +23,7 @@ namespace BizHawk.Client.EmuHawk
set => RefreshRate.Value = value;
}
- int scanline;
+ private int _scanline;
public NESNameTableViewer()
{
@@ -37,7 +37,7 @@ namespace BizHawk.Client.EmuHawk
#region Public API
- public bool AskSaveChanges() { return true; }
+ public bool AskSaveChanges() => true;
public bool UpdateBefore => true;
public void Restart()
@@ -49,7 +49,7 @@ namespace BizHawk.Client.EmuHawk
public void UpdateValues()
{
- _ppu.InstallCallback1(() => Generate(), scanline);
+ _ppu.InstallCallback1(() => Generate(), _scanline);
}
public void FastUpdate()
@@ -59,56 +59,56 @@ namespace BizHawk.Client.EmuHawk
#endregion
- private unsafe void DrawTile(int* dst, int pitch, byte* pal, byte* tile, int* finalpal)
+ private unsafe void DrawTile(int* dst, int pitch, byte* pal, byte* tile, int* finalPal)
{
dst += 7;
- int vinc = pitch + 8;
+ int verticalInc = pitch + 8;
for (int j = 0; j < 8; j++)
{
int lo = tile[0];
int hi = tile[8] << 1;
for (int i = 0; i < 8; i++)
{
- *dst-- = finalpal[pal[lo & 1 | hi & 2]];
+ *dst-- = finalPal[pal[lo & 1 | hi & 2]];
lo >>= 1;
hi >>= 1;
}
- dst += vinc;
+ dst += verticalInc;
tile++;
}
}
- 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 = _ppu.GetExTiles();
- int chr_mask = chr.Length - 1;
+ int chrMask = chr.Length - 1;
- fixed (byte* chrptr = chr, palptr = palram, ppuptr = ppumem, exptr = exram)
- fixed (int* finalpal = _ppu.GetPalette())
+ fixed (byte* chrPtr = chr, palPtr = palRam, ppuPtr = ppuMem, exPtr = exRam)
+ 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);
+ DrawExNT(dst, pitch, palPtr, ppuPtr + 0x2000, exPtr, chrPtr, chrMask, finalPal);
+ DrawExNT(dst + 256, pitch, palPtr, ppuPtr + 0x2400, exPtr, chrPtr, chrMask, finalPal);
dst += pitch * 240;
- DrawExNT(dst, pitch, palptr, ppuptr + 0x2800, exptr, chrptr, chr_mask, finalpal);
- DrawExNT(dst + 256, pitch, palptr, ppuptr + 0x2c00, exptr, chrptr, chr_mask, finalpal);
+ DrawExNT(dst, pitch, palPtr, ppuPtr + 0x2800, exPtr, chrPtr, chrMask, finalPal);
+ DrawExNT(dst + 256, pitch, palPtr, ppuPtr + 0x2c00, exPtr, chrPtr, chrMask, finalPal);
}
}
- 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 (int* finalpal = _ppu.GetPalette())
+ fixed (byte* palPtr = palRam, ppuPtr = ppuMem)
+ fixed (int* finalPal = _ppu.GetPalette())
{
- byte* chrptr = ppuptr + (_ppu.BGBaseHigh ? 0x1000 : 0);
- DrawNT(dst, pitch, palptr, ppuptr + 0x2000, chrptr, finalpal);
- DrawNT(dst + 256, pitch, palptr, ppuptr + 0x2400, chrptr, finalpal);
+ 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;
- DrawNT(dst, pitch, palptr, ppuptr + 0x2800, chrptr, finalpal);
- DrawNT(dst + 256, pitch, palptr, ppuptr + 0x2c00, chrptr, finalpal);
+ 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, int* finalpal)
+ private unsafe void DrawNT(int* dst, int pitch, byte* palRam, byte* nt, byte* chr, int* finalPal)
{
byte* at = nt + 0x3c0;
@@ -120,10 +120,10 @@ namespace BizHawk.Client.EmuHawk
byte a = at[ty >> 2 << 3 | tx >> 2];
a >>= tx & 2;
a >>= (ty & 2) << 1;
- int palnum = a & 3;
+ int palNum = a & 3;
- int tileaddr = t << 4;
- DrawTile(dst, pitch, palram + palnum * 4, chr + tileaddr, finalpal);
+ int tileAddr = t << 4;
+ DrawTile(dst, pitch, palRam + palNum * 4, chr + tileAddr, finalPal);
dst += 8;
}
dst -= 256;
@@ -131,20 +131,20 @@ namespace BizHawk.Client.EmuHawk
}
}
- private unsafe void DrawExNT(int* dst, int pitch, byte* palram, byte* nt, byte* exnt, byte* chr, int chr_mask, int* finalpal)
+ private unsafe void DrawExNT(int* dst, int pitch, byte* palRam, byte* nt, byte* exNt, byte* chr, int chrMask, int* finalPal)
{
for (int ty = 0; ty < 30; ty++)
{
for (int tx = 0; tx < 32; tx++)
{
byte t = *nt++;
- byte ex = *exnt++;
+ byte ex = *exNt++;
- int tilenum = t | (ex & 0x3f) << 8;
- int palnum = ex >> 6;
+ int tileNum = t | (ex & 0x3f) << 8;
+ int palNum = ex >> 6;
- int tileaddr = tilenum << 4 & chr_mask;
- DrawTile(dst, pitch, palram + palnum * 4, chr + tileaddr, finalpal);
+ int tileAddr = tileNum << 4 & chrMask;
+ DrawTile(dst, pitch, palRam + palNum * 4, chr + tileAddr, finalPal);
dst += 8;
}
dst -= 256;
@@ -164,30 +164,30 @@ namespace BizHawk.Client.EmuHawk
return;
}
- var bmpdata = NameTableView.Nametables.LockBits(
+ var bmpData = NameTableView.Nametables.LockBits(
new Rectangle(0, 0, 512, 480),
ImageLockMode.WriteOnly,
PixelFormat.Format32bppArgb);
- var dptr = (int*)bmpdata.Scan0.ToPointer();
- var pitch = bmpdata.Stride / 4;
+ var dPtr = (int*)bmpData.Scan0.ToPointer();
+ 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 = _ppu.GetPPUBus();
- var palram = _ppu.GetPalRam();
+ var palRam = _ppu.GetPalRam();
if (_ppu.ExActive)
{
- byte[] exram = _ppu.GetExRam();
- GenerateExAttr(dptr, pitch, palram, ppuBuffer, exram);
+ byte[] exRam = _ppu.GetExRam();
+ GenerateExAttr(dPtr, pitch, palRam, ppuBuffer, exRam);
}
else
{
- GenerateAttr(dptr, pitch, palram, ppuBuffer);
+ GenerateAttr(dPtr, pitch, palRam, ppuBuffer);
}
- NameTableView.Nametables.UnlockBits(bmpdata);
+ NameTableView.Nametables.UnlockBits(bmpData);
NameTableView.Refresh();
}
@@ -239,11 +239,11 @@ namespace BizHawk.Client.EmuHawk
_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))
{
- _ppu.InstallCallback1(() => Generate(), scanline);
+ _ppu.InstallCallback1(() => Generate(), _scanline);
}
}
@@ -277,12 +277,12 @@ namespace BizHawk.Client.EmuHawk
private void NameTableView_MouseMove(object sender, MouseEventArgs e)
{
- int TileX, TileY, NameTable;
+ int tileX, tileY, nameTable;
if (NameTableView.Which == NameTableViewer.WhichNametable.NT_ALL)
{
- TileX = e.X / 8;
- TileY = e.Y / 8;
- NameTable = (TileX / 32) + ((TileY / 30) * 2);
+ tileX = e.X / 8;
+ tileY = e.Y / 8;
+ nameTable = (tileX / 32) + ((tileY / 30) * 2);
}
else
{
@@ -290,44 +290,44 @@ namespace BizHawk.Client.EmuHawk
{
default:
case NameTableViewer.WhichNametable.NT_2000:
- NameTable = 0;
+ nameTable = 0;
break;
case NameTableViewer.WhichNametable.NT_2400:
- NameTable = 1;
+ nameTable = 1;
break;
case NameTableViewer.WhichNametable.NT_2800:
- NameTable = 2;
+ nameTable = 2;
break;
case NameTableViewer.WhichNametable.NT_2C00:
- NameTable = 3;
+ nameTable = 3;
break;
}
- TileX = e.X / 16;
- TileY = e.Y / 16;
+ tileX = e.X / 16;
+ tileY = e.Y / 16;
}
- XYLabel.Text = $"{TileX} : {TileY}";
- int PPUAddress = 0x2000 + (NameTable * 0x400) + ((TileY % 30) * 32) + (TileX % 32);
- PPUAddressLabel.Text = $"{PPUAddress:X4}";
- int TileID = _ppu.PeekPPU(PPUAddress);
- TileIDLabel.Text = $"{TileID:X2}";
- TableLabel.Text = NameTable.ToString();
+ XYLabel.Text = $"{tileX} : {tileY}";
+ int ppuAddress = 0x2000 + (nameTable * 0x400) + ((tileY % 30) * 32) + (tileX % 32);
+ PPUAddressLabel.Text = $"{ppuAddress:X4}";
+ int tileID = _ppu.PeekPPU(ppuAddress);
+ TileIDLabel.Text = $"{tileID:X2}";
+ TableLabel.Text = nameTable.ToString();
- int ytable = 0, yline = 0;
+ int yTable = 0, yLine = 0;
if (e.Y >= 240)
{
- ytable += 2;
- yline = 240;
+ yTable += 2;
+ yLine = 240;
}
- int table = (e.X >> 8) + ytable;
- int ntaddr = (table << 10);
+ int table = (e.X >> 8) + yTable;
+ int ntAddr = (table << 10);
int px = e.X & 255;
- int py = e.Y - yline;
+ int py = e.Y - yLine;
int tx = px >> 3;
int ty = py >> 3;
- int atbyte_ptr = ntaddr + 0x3C0 + ((ty >> 2) << 3) + (tx >> 2);
- int at = _ppu.PeekPPU(atbyte_ptr + 0x2000);
+ int atBytePtr = ntAddr + 0x3C0 + ((ty >> 2) << 3) + (tx >> 2);
+ int at = _ppu.PeekPPU(atBytePtr + 0x2000);
if ((ty & 2) != 0) at >>= 4;
if ((tx & 2) != 0) at >>= 2;
at &= 0x03;
diff --git a/BizHawk.Client.EmuHawk/tools/NES/NESPPU.Designer.cs b/BizHawk.Client.EmuHawk/tools/NES/NESPPU.Designer.cs
index ba4751f4f1..937a052889 100644
--- a/BizHawk.Client.EmuHawk/tools/NES/NESPPU.Designer.cs
+++ b/BizHawk.Client.EmuHawk/tools/NES/NESPPU.Designer.cs
@@ -435,7 +435,7 @@
this.txtScanline.Size = new System.Drawing.Size(79, 22);
this.txtScanline.TabIndex = 6;
this.txtScanline.Text = "0";
- this.txtScanline.TextChanged += new System.EventHandler(this.ScanlineTextbox_TextChanged);
+ this.txtScanline.TextChanged += new System.EventHandler(this.ScanlineTextBox_TextChanged);
//
// groupBox1
//
@@ -754,7 +754,7 @@
this.cHRROMTileViewerToolStripMenuItem.Name = "cHRROMTileViewerToolStripMenuItem";
this.cHRROMTileViewerToolStripMenuItem.Size = new System.Drawing.Size(227, 26);
this.cHRROMTileViewerToolStripMenuItem.Text = "CHR ROM Tile Viewer";
- this.cHRROMTileViewerToolStripMenuItem.Click += new System.EventHandler(this.cHRROMTileViewerToolStripMenuItem_Click);
+ this.cHRROMTileViewerToolStripMenuItem.Click += new System.EventHandler(this.ChrROMTileViewerToolStripMenuItem_Click);
//
// NesPPUStatusBar
//
@@ -812,7 +812,7 @@
this.numericUpDownCHRROMBank.Name = "numericUpDownCHRROMBank";
this.numericUpDownCHRROMBank.Size = new System.Drawing.Size(160, 22);
this.numericUpDownCHRROMBank.TabIndex = 1;
- this.numericUpDownCHRROMBank.ValueChanged += new System.EventHandler(this.numericUpDownCHRROMBank_ValueChanged);
+ this.numericUpDownCHRROMBank.ValueChanged += new System.EventHandler(this.NumericUpDownChrRomBank_ValueChanged);
//
// CHRROMView
//
diff --git a/BizHawk.Client.EmuHawk/tools/NES/NESPPU.cs b/BizHawk.Client.EmuHawk/tools/NES/NESPPU.cs
index ec28b1c2cd..ccf0d86115 100644
--- a/BizHawk.Client.EmuHawk/tools/NES/NESPPU.cs
+++ b/BizHawk.Client.EmuHawk/tools/NES/NESPPU.cs
@@ -10,14 +10,14 @@ namespace BizHawk.Client.EmuHawk
public partial class NesPPU : Form, IToolFormAutoConfig
{
// TODO:
- // If 8/16 sprite mode, mouse over should put 32x64 version of prite
+ // If 8/16 sprite mode, mouse over should put 32x64 version of sprite
// Speedups
// Smarter refreshing? only refresh when things of changed, perhaps peek at the ppu to when the pattern table has changed, or sprites have moved
// Maybe 48 individual bitmaps for sprites is faster than the overhead of redrawing all that transparent space
- private readonly byte[] _ppuBusprev = new byte[0x3000];
+ private readonly byte[] _ppuBusPrev = new byte[0x3000];
private readonly byte[] _palRamPrev = new byte[0x20];
- int scanline;
+ private int _scanline;
private Bitmap _zoomBoxDefaultImage = new Bitmap(64, 64);
private bool _forceChange;
@@ -34,12 +34,12 @@ namespace BizHawk.Client.EmuHawk
set => RefreshRate.Value = value;
}
- private bool _chrromview;
+ private bool _chrRomView;
[ConfigPersist]
private bool ChrRomView
{
- get => _chrromview;
- set { _chrromview = value; CalculateFormSize(); }
+ get => _chrRomView;
+ set { _chrRomView = value; CalculateFormSize(); }
}
public NesPPU()
@@ -52,18 +52,18 @@ namespace BizHawk.Client.EmuHawk
{
ClearDetails();
Generate(true);
- CHRROMViewReload();
+ ChrRomViewReload();
}
#region Public API
- public bool AskSaveChanges() { return true; }
+ public bool AskSaveChanges() => true;
public bool UpdateBefore => true;
public void NewUpdate(ToolFormUpdateType type) { }
public void UpdateValues()
{
- _ppu.InstallCallback2(() => Generate(), scanline);
+ _ppu.InstallCallback2(() => Generate(), _scanline);
}
public void FastUpdate()
@@ -74,22 +74,22 @@ namespace BizHawk.Client.EmuHawk
public void Restart()
{
Generate(true);
- CHRROMViewReload();
+ ChrRomViewReload();
}
#endregion
- private byte GetBit(byte[] PPUBus, int address, int bit)
+ private byte GetBit(byte[] ppuBus, int address, int bit)
{
- return (byte)((PPUBus[address] >> (7 - bit)) & 1);
+ return (byte)((ppuBus[address] >> (7 - bit)) & 1);
}
- private bool CheckChange(byte[] PALRAM, byte[] PPUBus)
+ private bool CheckChange(byte[] palRam, byte[] ppuBus)
{
bool changed = false;
for (int i = 0; i < 0x20; i++)
{
- if (_palRamPrev[i] != PALRAM[i])
+ if (_palRamPrev[i] != palRam[i])
{
changed = true;
break;
@@ -100,7 +100,7 @@ namespace BizHawk.Client.EmuHawk
{
for (int i = 0; i < 0x2000; i++)
{
- if (_ppuBusprev[i] != PPUBus[i])
+ if (_ppuBusPrev[i] != ppuBus[i])
{
changed = true;
break;
@@ -108,8 +108,8 @@ namespace BizHawk.Client.EmuHawk
}
}
- Buffer.BlockCopy(PALRAM, 0, _palRamPrev, 0, 0x20);
- Buffer.BlockCopy(PPUBus, 0, _ppuBusprev, 0, 0x3000);
+ Buffer.BlockCopy(palRam, 0, _palRamPrev, 0, 0x20);
+ Buffer.BlockCopy(ppuBus, 0, _ppuBusPrev, 0, 0x3000);
if (_forceChange)
{
@@ -126,12 +126,12 @@ namespace BizHawk.Client.EmuHawk
byte value;
int cvalue;
- var bmpdata = dest.pattern.LockBits(
- new Rectangle(new Point(0, 0), dest.pattern.Size),
+ var bmpdata = dest.Pattern.LockBits(
+ new Rectangle(new Point(0, 0), dest.Pattern.Size),
ImageLockMode.WriteOnly,
PixelFormat.Format32bppArgb);
- int* framebuf = (int*)bmpdata.Scan0;
+ int* frameBuf = (int*)bmpdata.Scan0;
for (int z = 0; z < 2; z++)
{
int pal;
@@ -152,14 +152,14 @@ namespace BizHawk.Client.EmuHawk
value = (byte)(b0 + (b1 << 1));
cvalue = FinalPalette[PALRAM[value + (pal << 2)]];
int adr = (x + (j << 3)) + (y + (i << 3)) * (bmpdata.Stride >> 2);
- framebuf[adr + (z << 7)] = cvalue;
+ frameBuf[adr + (z << 7)] = cvalue;
}
}
}
}
}
- dest.pattern.UnlockBits(bmpdata);
+ dest.Pattern.UnlockBits(bmpdata);
dest.Refresh();
}
@@ -173,17 +173,17 @@ namespace BizHawk.Client.EmuHawk
if (_emu.Frame % RefreshRate.Value != 0 && !now)
return;
- byte[] PALRAM = _ppu.GetPalRam();
- int[] FinalPalette = _ppu.GetPalette();
- byte[] OAM = _ppu.GetOam();
- byte[] PPUBus = _ppu.GetPPUBus();
+ byte[] palRam = _ppu.GetPalRam();
+ int[] finalPalette = _ppu.GetPalette();
+ byte[] oam = _ppu.GetOam();
+ byte[] ppuBus = _ppu.GetPPUBus();
int b0;
int b1;
byte value;
int cvalue;
- if (CheckChange(PALRAM, PPUBus))
+ if (CheckChange(palRam, ppuBus))
{
_forceChange = false;
@@ -192,8 +192,8 @@ namespace BizHawk.Client.EmuHawk
{
PaletteView.BgPalettesPrev[i].Value = PaletteView.BgPalettes[i].Value;
PaletteView.SpritePalettesPrev[i].Value = PaletteView.SpritePalettes[i].Value;
- PaletteView.BgPalettes[i].Value = FinalPalette[PALRAM[PaletteView.BgPalettes[i].Address]];
- PaletteView.SpritePalettes[i].Value = FinalPalette[PALRAM[PaletteView.SpritePalettes[i].Address]];
+ PaletteView.BgPalettes[i].Value = finalPalette[palRam[PaletteView.BgPalettes[i].Address]];
+ PaletteView.SpritePalettes[i].Value = finalPalette[palRam[PaletteView.SpritePalettes[i].Address]];
}
if (PaletteView.HasChanged())
@@ -201,13 +201,13 @@ namespace BizHawk.Client.EmuHawk
PaletteView.Refresh();
}
- DrawPatternView(PatternView, PPUBus, FinalPalette, PALRAM);
+ DrawPatternView(PatternView, ppuBus, finalPalette, palRam);
}
- 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 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 = _ppu.SPBaseHigh ? 0x1000 : 0;
+ int ptAdd = _ppu.SPBaseHigh ? 0x1000 : 0;
bool is8x16 = _ppu.SPTall;
@@ -216,36 +216,36 @@ namespace BizHawk.Client.EmuHawk
{
for (int r = 0; r < 16; r++)
{
- int BaseAddr = (r << 2) + (n << 6);
- int TileNum = OAM[BaseAddr + 1];
+ int baseAddr = (r << 2) + (n << 6);
+ int tileNum = oam[baseAddr + 1];
int patternAddr;
if (is8x16)
{
- patternAddr = (TileNum >> 1) * 0x20;
- patternAddr += 0x1000 * (TileNum & 1);
+ patternAddr = (tileNum >> 1) * 0x20;
+ patternAddr += 0x1000 * (tileNum & 1);
}
else
{
- patternAddr = TileNum * 0x10;
- patternAddr += pt_add;
+ patternAddr = tileNum * 0x10;
+ patternAddr += ptAdd;
}
- int Attributes = OAM[BaseAddr + 2];
- int Palette = Attributes & 0x03;
+ int attributes = oam[baseAddr + 2];
+ int palette = attributes & 0x03;
for (int x = 0; x < 8; x++)
{
for (int y = 0; y < 8; y++)
{
int address = patternAddr + y;
- b0 = (byte)((PPUBus[address] >> (7 - x)) & 1);
- b1 = (byte)((PPUBus[address + 8] >> (7 - x)) & 1);
+ b0 = (byte)((ppuBus[address] >> (7 - x)) & 1);
+ b1 = (byte)((ppuBus[address + 8] >> (7 - x)) & 1);
value = (byte)(b0 + (b1 << 1));
- cvalue = FinalPalette[PALRAM[16 + value + (Palette << 2)]];
+ cvalue = finalPalette[palRam[16 + value + (palette << 2)]];
- int adr = (x + (r * 16)) + (y + (n * 24)) * (bmpdata2.Stride >> 2);
- framebuf2[adr] = cvalue;
+ int adr = (x + (r * 16)) + (y + (n * 24)) * (bmpData2.Stride >> 2);
+ frameBuf2[adr] = cvalue;
}
if (is8x16)
@@ -254,13 +254,13 @@ namespace BizHawk.Client.EmuHawk
for (int y = 0; y < 8; y++)
{
int address = patternAddr + y;
- b0 = (byte)((PPUBus[address] >> (7 - x)) & 1);
- b1 = (byte)((PPUBus[address + 8] >> (7 - x)) & 1);
+ b0 = (byte)((ppuBus[address] >> (7 - x)) & 1);
+ b1 = (byte)((ppuBus[address + 8] >> (7 - x)) & 1);
value = (byte)(b0 + (b1 << 1));
- cvalue = FinalPalette[PALRAM[16 + value + (Palette << 2)]];
+ cvalue = finalPalette[palRam[16 + value + (palette << 2)]];
- int adr = (x + (r << 4)) + ((y + 8) + (n * 24)) * (bmpdata2.Stride >> 2);
- framebuf2[adr] = cvalue;
+ int adr = (x + (r << 4)) + ((y + 8) + (n * 24)) * (bmpData2.Stride >> 2);
+ frameBuf2[adr] = cvalue;
}
patternAddr -= 0x10;
@@ -269,7 +269,7 @@ namespace BizHawk.Client.EmuHawk
}
}
- SpriteView.sprites.UnlockBits(bmpdata2);
+ SpriteView.Sprites.UnlockBits(bmpData2);
SpriteView.Refresh();
HandleSpriteViewMouseMove(SpriteView.PointToClient(MousePosition));
@@ -515,14 +515,14 @@ namespace BizHawk.Client.EmuHawk
if (found != null)
{
- var meth = found.GetType().GetMethod("ScreenshotToClipboard", Type.EmptyTypes);
- if (meth != null)
+ var method = found.GetType().GetMethod("ScreenshotToClipboard", Type.EmptyTypes);
+ if (method != null)
{
- meth.Invoke(found, null);
+ method.Invoke(found, null);
}
- else if (found is PictureBox)
+ else if (found is PictureBox box)
{
- Clipboard.SetImage((found as PictureBox).Image);
+ Clipboard.SetImage(box.Image);
}
else
{
@@ -575,20 +575,20 @@ namespace BizHawk.Client.EmuHawk
if (e.X >= SpriteView.ClientRectangle.Right) return;
if (e.Y >= SpriteView.ClientRectangle.Bottom) return;
- byte[] OAM = _ppu.GetOam();
- byte[] PPUBus = _ppu.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 = _ppu.SPTall;
var spriteNumber = ((e.Y / 24) * 16) + (e.X / 16);
- int x = OAM[(spriteNumber * 4) + 3];
- int y = OAM[spriteNumber * 4];
- var color = OAM[(spriteNumber * 4) + 2] & 0x03;
- var attributes = OAM[(spriteNumber * 4) + 2];
+ int x = oam[(spriteNumber * 4) + 3];
+ int y = oam[spriteNumber * 4];
+ var color = oam[(spriteNumber * 4) + 2] & 0x03;
+ var attributes = oam[(spriteNumber * 4) + 2];
var flags = "Flags: ";
- int h = GetBit(PPUBus, attributes, 6);
- int v = GetBit(PPUBus, attributes, 7);
- int priority = GetBit(PPUBus, attributes, 5);
+ int h = GetBit(ppuBus, attributes, 6);
+ int v = GetBit(ppuBus, attributes, 7);
+ int priority = GetBit(ppuBus, attributes, 5);
if (h > 0)
{
flags += "H ";
@@ -608,7 +608,7 @@ namespace BizHawk.Client.EmuHawk
flags += "Front";
}
- int tile = OAM[spriteNumber * 4 + 1];
+ int tile = oam[spriteNumber * 4 + 1];
if (is8x16)
{
if ((tile & 1) != 0)
@@ -626,12 +626,12 @@ namespace BizHawk.Client.EmuHawk
if (is8x16)
{
ZoomBox.Image = Section(
- SpriteView.sprites, new Rectangle(new Point((e.X / 8) * 8, (e.Y / 24) * 24), new Size(8, 16)), true);
+ SpriteView.Sprites, new Rectangle(new Point((e.X / 8) * 8, (e.Y / 24) * 24), new Size(8, 16)), true);
}
else
{
ZoomBox.Image = Section(
- SpriteView.sprites, new Rectangle(new Point((e.X / 8) * 8, (e.Y / 8) * 8), new Size(8, 8)), false);
+ SpriteView.Sprites, new Rectangle(new Point((e.X / 8) * 8, (e.Y / 8) * 8), new Size(8, 8)), false);
}
}
@@ -671,17 +671,17 @@ namespace BizHawk.Client.EmuHawk
var bmp = new Bitmap(64, 64);
var g = Graphics.FromImage(bmp);
- byte[] PALRAM = _ppu.GetPalRam();
+ byte[] palRam = _ppu.GetPalRam();
if (baseAddr == 0x3F00)
{
- val = PALRAM[PaletteView.BgPalettes[column].Address];
+ val = palRam[PaletteView.BgPalettes[column].Address];
ValueLabel.Text = $"ID: BG{column / 4}";
g.FillRectangle(new SolidBrush(PaletteView.BgPalettes[column].Color), 0, 0, 64, 64);
}
else
{
- val = PALRAM[PaletteView.SpritePalettes[column].Address];
+ val = palRam[PaletteView.SpritePalettes[column].Address];
ValueLabel.Text = $"ID: SPR{column / 4}";
g.FillRectangle(new SolidBrush(PaletteView.SpritePalettes[column].Color), 0, 0, 64, 64);
}
@@ -774,14 +774,14 @@ namespace BizHawk.Client.EmuHawk
Value3Label.Text = $"Tile {tile:X2}";
Value4Label.Text = usage;
- ZoomBox.Image = Section(PatternView.pattern, new Rectangle(new Point((e.X / 8) * 8, (e.Y / 8) * 8), new Size(8, 8)), false);
+ ZoomBox.Image = Section(PatternView.Pattern, new Rectangle(new Point((e.X / 8) * 8, (e.Y / 8) * 8), new Size(8, 8)), false);
}
- 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))
{
- _ppu.InstallCallback2(() => Generate(), scanline);
+ _ppu.InstallCallback2(() => Generate(), _scanline);
}
}
@@ -792,10 +792,10 @@ namespace BizHawk.Client.EmuHawk
#endregion
- MemoryDomain CHRROM;
- readonly byte[] chrromcache = new byte[8192];
+ private MemoryDomain _chrRom;
+ private readonly byte[] _chrRomCache = new byte[8192];
- private void cHRROMTileViewerToolStripMenuItem_Click(object sender, EventArgs e)
+ private void ChrROMTileViewerToolStripMenuItem_Click(object sender, EventArgs e)
{
ChrRomView ^= true;
}
@@ -805,41 +805,41 @@ namespace BizHawk.Client.EmuHawk
Width = ChrRomView ? 861 : 580;
}
- private void CHRROMViewReload()
+ private void ChrRomViewReload()
{
- CHRROM = _ppu.GetCHRROM();
- if (CHRROM == null)
+ _chrRom = _ppu.GetCHRROM();
+ if (_chrRom == null)
{
numericUpDownCHRROMBank.Enabled = false;
- Array.Clear(chrromcache, 0, 8192);
+ Array.Clear(_chrRomCache, 0, 8192);
}
else
{
numericUpDownCHRROMBank.Enabled = true;
numericUpDownCHRROMBank.Minimum = 0;
- numericUpDownCHRROMBank.Maximum = CHRROM.Size / 8192 - 1;
+ numericUpDownCHRROMBank.Maximum = _chrRom.Size / 8192 - 1;
numericUpDownCHRROMBank.Value = Math.Min(numericUpDownCHRROMBank.Value, numericUpDownCHRROMBank.Maximum);
}
- CHRROMViewRefresh();
+ ChrRomViewRefresh();
}
- private void CHRROMViewRefresh()
+ private void ChrRomViewRefresh()
{
- if (CHRROM != null)
+ if (_chrRom != null)
{
int offs = 8192 * (int)numericUpDownCHRROMBank.Value;
for (int i = 0; i < 8192; i++)
- chrromcache[i] = CHRROM.PeekByte(offs + i);
+ _chrRomCache[i] = _chrRom.PeekByte(offs + i);
- DrawPatternView(CHRROMView, chrromcache, _ppu.GetPalette(), _ppu.GetPalRam());
+ DrawPatternView(CHRROMView, _chrRomCache, _ppu.GetPalette(), _ppu.GetPalRam());
}
}
#endregion
- private void numericUpDownCHRROMBank_ValueChanged(object sender, EventArgs e)
+ private void NumericUpDownChrRomBank_ValueChanged(object sender, EventArgs e)
{
- CHRROMViewRefresh();
+ ChrRomViewRefresh();
}
}
}
diff --git a/BizHawk.Client.EmuHawk/tools/NES/NameTableViewer.cs b/BizHawk.Client.EmuHawk/tools/NES/NameTableViewer.cs
index 541542d680..1ca7e0eb4f 100644
--- a/BizHawk.Client.EmuHawk/tools/NES/NameTableViewer.cs
+++ b/BizHawk.Client.EmuHawk/tools/NES/NameTableViewer.cs
@@ -12,15 +12,13 @@ namespace BizHawk.Client.EmuHawk
{
public Bitmap Nametables;
- private readonly Size pSize;
-
public NameTableViewer()
{
- pSize = new Size(512, 480);
+ var pSize = new Size(512, 480);
Nametables = new Bitmap(pSize.Width, pSize.Height);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.UserPaint, true);
- SetStyle(ControlStyles.DoubleBuffer, true);
+ SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
SetStyle(ControlStyles.SupportsTransparentBackColor, true);
SetStyle(ControlStyles.Opaque, true);
Size = new Size(256, 224);
@@ -84,36 +82,32 @@ namespace BizHawk.Client.EmuHawk
}
var file = new FileInfo(sfd.FileName);
- using (Bitmap b = new Bitmap(Width, Height))
+ using Bitmap b = new Bitmap(Width, Height);
+ Rectangle rect = new Rectangle(new Point(0, 0), Size);
+ DrawToBitmap(b, rect);
+
+ ImageFormat i;
+ string extension = file.Extension.ToUpper();
+ switch (extension)
{
- Rectangle rect = new Rectangle(new Point(0, 0), Size);
- DrawToBitmap(b, rect);
-
- ImageFormat i;
- string extension = file.Extension.ToUpper();
- switch (extension)
- {
- default:
- case ".PNG":
- i = ImageFormat.Png;
- break;
- case ".BMP":
- i = ImageFormat.Bmp;
- break;
- }
-
- b.Save(file.FullName, i);
+ default:
+ case ".PNG":
+ i = ImageFormat.Png;
+ break;
+ case ".BMP":
+ i = ImageFormat.Bmp;
+ break;
}
+
+ b.Save(file.FullName, i);
}
public void ScreenshotToClipboard()
{
- using(var b = new Bitmap(Width, Height))
- {
- Rectangle rect = new Rectangle(new Point(0, 0), Size);
- DrawToBitmap(b, rect);
- Clipboard.SetImage(b);
- }
+ using var b = new Bitmap(Width, Height);
+ var rect = new Rectangle(new Point(0, 0), Size);
+ DrawToBitmap(b, rect);
+ Clipboard.SetImage(b);
}
}
}
diff --git a/BizHawk.Client.EmuHawk/tools/NES/PaletteViewer.cs b/BizHawk.Client.EmuHawk/tools/NES/PaletteViewer.cs
index 0f8b22c0a7..b527785d53 100644
--- a/BizHawk.Client.EmuHawk/tools/NES/PaletteViewer.cs
+++ b/BizHawk.Client.EmuHawk/tools/NES/PaletteViewer.cs
@@ -23,11 +23,11 @@ namespace BizHawk.Client.EmuHawk
}
}
- public Palette[] BgPalettes = new Palette[16];
- public Palette[] SpritePalettes = new Palette[16];
+ public Palette[] BgPalettes { get; set; } = new Palette[16];
+ public Palette[] SpritePalettes { get; set; } = new Palette[16];
- public Palette[] BgPalettesPrev = new Palette[16];
- public Palette[] SpritePalettesPrev = new Palette[16];
+ public Palette[] BgPalettesPrev { get; set; } = new Palette[16];
+ public Palette[] SpritePalettesPrev { get; set; } = new Palette[16];
public PaletteViewer()
{
@@ -88,8 +88,8 @@ namespace BizHawk.Client.EmuHawk
}
var file = new FileInfo(sfd.FileName);
- Bitmap b = new Bitmap(Width, Height);
- Rectangle rect = new Rectangle(new Point(0, 0), Size);
+ var b = new Bitmap(Width, Height);
+ var rect = new Rectangle(new Point(0, 0), Size);
DrawToBitmap(b, rect);
ImageFormat i;
@@ -110,14 +110,12 @@ namespace BizHawk.Client.EmuHawk
public void ScreenshotToClipboard()
{
- Bitmap b = new Bitmap(Width, Height);
- Rectangle rect = new Rectangle(new Point(0, 0), Size);
+ var b = new Bitmap(Width, Height);
+ var rect = new Rectangle(new Point(0, 0), Size);
DrawToBitmap(b, rect);
- using (var img = b)
- {
- Clipboard.SetImage(img);
- }
+ using var img = b;
+ Clipboard.SetImage(img);
}
}
}
diff --git a/BizHawk.Client.EmuHawk/tools/NES/PatternViewer.cs b/BizHawk.Client.EmuHawk/tools/NES/PatternViewer.cs
index 6ae8bddff3..7ff09e6f63 100644
--- a/BizHawk.Client.EmuHawk/tools/NES/PatternViewer.cs
+++ b/BizHawk.Client.EmuHawk/tools/NES/PatternViewer.cs
@@ -10,16 +10,14 @@ namespace BizHawk.Client.EmuHawk
{
public sealed class PatternViewer : Control
{
- public Bitmap pattern;
- public int Pal0 = 0; //0-7 Palette choice
- public int Pal1 = 0;
-
- private readonly Size pSize;
+ public Bitmap Pattern { get; set; }
+ public int Pal0 { get; set; } = 0; // 0-7 Palette choice
+ public int Pal1 { get; set; } = 0;
public PatternViewer()
{
- pSize = new Size(256, 128);
- pattern = new Bitmap(pSize.Width, pSize.Height);
+ var pSize = new Size(256, 128);
+ Pattern = new Bitmap(pSize.Width, pSize.Height);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
@@ -32,7 +30,7 @@ namespace BizHawk.Client.EmuHawk
private void PatternViewer_Paint(object sender, PaintEventArgs e)
{
- e.Graphics.DrawImage(pattern, 0, 0);
+ e.Graphics.DrawImage(Pattern, 0, 0);
}
public void Screenshot()
@@ -52,8 +50,8 @@ namespace BizHawk.Client.EmuHawk
}
var file = new FileInfo(sfd.FileName);
- Bitmap b = new Bitmap(Width, Height);
- Rectangle rect = new Rectangle(new Point(0, 0), Size);
+ var b = new Bitmap(Width, Height);
+ var rect = new Rectangle(new Point(0, 0), Size);
DrawToBitmap(b, rect);
ImageFormat i;
@@ -74,14 +72,12 @@ namespace BizHawk.Client.EmuHawk
public void ScreenshotToClipboard()
{
- Bitmap b = new Bitmap(Width, Height);
- Rectangle rect = new Rectangle(new Point(0, 0), Size);
+ var b = new Bitmap(Width, Height);
+ var rect = new Rectangle(new Point(0, 0), Size);
DrawToBitmap(b, rect);
- using (var img = b)
- {
- Clipboard.SetImage(img);
- }
+ using var img = b;
+ Clipboard.SetImage(img);
}
}
}
diff --git a/BizHawk.Client.EmuHawk/tools/NES/SpriteViewer.cs b/BizHawk.Client.EmuHawk/tools/NES/SpriteViewer.cs
index fe7d3aaea5..95f6ceda64 100644
--- a/BizHawk.Client.EmuHawk/tools/NES/SpriteViewer.cs
+++ b/BizHawk.Client.EmuHawk/tools/NES/SpriteViewer.cs
@@ -10,15 +10,13 @@ namespace BizHawk.Client.EmuHawk
{
public sealed class SpriteViewer : Control
{
- public Bitmap sprites;
-
- private readonly Size pSize;
+ public Bitmap Sprites { get; set; }
public SpriteViewer()
{
SetStyle(ControlStyles.SupportsTransparentBackColor, true);
- pSize = new Size(256, 96);
- sprites = new Bitmap(pSize.Width, pSize.Height);
+ var pSize = new Size(256, 96);
+ Sprites = new Bitmap(pSize.Width, pSize.Height);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.DoubleBuffer, true);
@@ -29,7 +27,7 @@ namespace BizHawk.Client.EmuHawk
private void Display(Graphics g)
{
- g.DrawImage(sprites, 1, 1);
+ g.DrawImage(Sprites, 1, 1);
}
private void SpriteViewer_Paint(object sender, PaintEventArgs e)
@@ -54,8 +52,8 @@ namespace BizHawk.Client.EmuHawk
}
var file = new FileInfo(sfd.FileName);
- Bitmap b = new Bitmap(Width, Height);
- Rectangle rect = new Rectangle(new Point(0, 0), Size);
+ var b = new Bitmap(Width, Height);
+ var rect = new Rectangle(new Point(0, 0), Size);
DrawToBitmap(b, rect);
ImageFormat i;
@@ -76,14 +74,12 @@ namespace BizHawk.Client.EmuHawk
public void ScreenshotToClipboard()
{
- Bitmap b = new Bitmap(Width, Height);
- Rectangle rect = new Rectangle(new Point(0, 0), Size);
+ var b = new Bitmap(Width, Height);
+ var rect = new Rectangle(new Point(0, 0), Size);
DrawToBitmap(b, rect);
- using (var img = b)
- {
- Clipboard.SetImage(img);
- }
+ using var img = b;
+ Clipboard.SetImage(img);
}
}
}
diff --git a/BizHawk.sln.DotSettings b/BizHawk.sln.DotSettings
index ed855fae33..f611c6aeba 100644
--- a/BizHawk.sln.DotSettings
+++ b/BizHawk.sln.DotSettings
@@ -90,6 +90,7 @@
MGBA
NES
NMI
+ NT
NTSC
OBJ
OR