From e98da5856f2984577b1448dff2ea4691a9662c2e Mon Sep 17 00:00:00 2001 From: adelikat Date: Wed, 20 Nov 2013 01:37:54 +0000 Subject: [PATCH] misc code refactoring --- BizHawk.Client.EmuHawk/tools/GB/GBGPUView.cs | 191 ++++++------ .../tools/GB/GBGameGenie.cs | 88 +++--- .../tools/GBA/GBAGPUView.cs | 137 ++++----- .../tools/GBA/MobileBmpView.Designer.cs | 16 +- .../tools/GBA/MobileBmpView.cs | 21 +- .../tools/GBA/MobileDetailView.Designer.cs | 17 +- .../tools/GBA/MobileDetailView.cs | 10 +- .../tools/Genesis/GenGameGenie.cs | 35 +-- .../tools/HexEditor/HexColor.Designer.cs | 4 +- .../tools/HexEditor/HexColor.cs | 4 +- .../tools/HexEditor/HexEditor.cs | 4 +- .../tools/HexEditor/HexFind.cs | 12 +- .../tools/HexEditor/MemoryViewer.cs | 291 +++++++++--------- .../tools/PCE/PCEBGCanvas.cs | 12 +- .../tools/PCE/PCEBGViewer.cs | 20 +- 15 files changed, 420 insertions(+), 442 deletions(-) diff --git a/BizHawk.Client.EmuHawk/tools/GB/GBGPUView.cs b/BizHawk.Client.EmuHawk/tools/GB/GBGPUView.cs index 19b3aece7e..c1008fa6af 100644 --- a/BizHawk.Client.EmuHawk/tools/GB/GBGPUView.cs +++ b/BizHawk.Client.EmuHawk/tools/GB/GBGPUView.cs @@ -26,20 +26,21 @@ namespace BizHawk.Client.EmuHawk // g' = 8.25g // b' = 8.25b - Gameboy gb; + private Gameboy _gb; // gambatte doesn't modify these memory locations unless you reconstruct, so we can store - IntPtr vram; - IntPtr bgpal; - IntPtr sppal; - IntPtr oam; + private IntPtr _vram; + private IntPtr _bgpal; + private IntPtr _sppal; + private IntPtr _oam; - bool cgb; // set once at start - int _lcdc; // set at each callback + private bool _cgb; // set once at start + private int _lcdc; // set at each callback - IntPtr tilespal; // current palette to use on tiles + private IntPtr tilespal; // current palette to use on tiles - Color _spriteback; + private Color _spriteback; + Color spriteback { get { return _spriteback; } @@ -73,8 +74,8 @@ namespace BizHawk.Client.EmuHawk KeyPreview = true; - messagetimer.Interval = 5000; - messagetimer.Tick += messagetimer_Tick; + _messagetimer.Interval = 5000; + _messagetimer.Tick += messagetimer_Tick; checkBoxAutoLoad.Checked = Global.Config.AutoLoadGBGPUView; checkBoxSavePos.Checked = Global.Config.GBGPUViewSaveWindowPosition; @@ -87,18 +88,18 @@ namespace BizHawk.Client.EmuHawk { if (Global.Emulator is Gameboy) { - gb = Global.Emulator as Gameboy; - cgb = gb.IsCGBMode(); + _gb = Global.Emulator as Gameboy; + _cgb = _gb.IsCGBMode(); _lcdc = 0; - if (!gb.GetGPUMemoryAreas(out vram, out bgpal, out sppal, out oam)) + if (!_gb.GetGPUMemoryAreas(out _vram, out _bgpal, out _sppal, out _oam)) { - gb = null; + _gb = null; if (Visible) Close(); } - tilespal = bgpal; + tilespal = _bgpal; - if (cgb) + if (_cgb) label4.Enabled = true; else label4.Enabled = false; @@ -115,7 +116,7 @@ namespace BizHawk.Client.EmuHawk } else { - gb = null; + _gb = null; if (Visible) Close(); } @@ -160,7 +161,7 @@ namespace BizHawk.Client.EmuHawk /// 4 palette colors /// true to flip horizontally /// true to flip vertically - static unsafe void DrawTileHV(byte* tile, int* dest, int pitch, int* pal, bool hflip, bool vflip) + static unsafe void DrawTileHv(byte* tile, int* dest, int pitch, int* pal, bool hflip, bool vflip) { if (vflip) dest += pitch * 7; @@ -223,7 +224,7 @@ namespace BizHawk.Client.EmuHawk int* thispal = pal + 4 * (tileext & 7); - DrawTileHV(tile, dest, pitch, thispal, tileext.Bit(5), tileext.Bit(6)); + DrawTileHv(tile, dest, pitch, thispal, tileext.Bit(5), tileext.Bit(6)); map++; dest += 8; } @@ -329,9 +330,9 @@ namespace BizHawk.Client.EmuHawk int* thispal = pal + 4 * (cgb ? flags & 7 : flags >> 4 & 1); if (cgb && flags.Bit(3)) tile += 8192; - DrawTileHV(tile, dest, pitch, thispal, hflip, vflip); + DrawTileHv(tile, dest, pitch, thispal, hflip, vflip); if (tall) - DrawTileHV((byte*)((int)tile ^ 16), dest + pitch * 8, pitch, thispal, hflip, vflip); + DrawTileHv((byte*)((int)tile ^ 16), dest + pitch * 8, pitch, thispal, hflip, vflip); dest += 8; } b.UnlockBits(lockdata); @@ -371,10 +372,10 @@ namespace BizHawk.Client.EmuHawk // set alpha on all pixels unsafe { - int* p = (int*)bgpal; + int* p = (int*)_bgpal; for (int i = 0; i < 32; i++) p[i] |= unchecked((int)0xff000000); - p = (int*)sppal; + p = (int*)_sppal; for (int i = 0; i < 32; i++) p[i] |= unchecked((int)0xff000000); int c = spriteback.ToArgb(); @@ -383,37 +384,37 @@ namespace BizHawk.Client.EmuHawk } // bg maps - if (!cgb) + if (!_cgb) { DrawBGDMG( bmpViewBG.bmp, - vram + (lcdc.Bit(3) ? 0x1c00 : 0x1800), - vram + (lcdc.Bit(4) ? 0x0000 : 0x1000), + _vram + (lcdc.Bit(3) ? 0x1c00 : 0x1800), + _vram + (lcdc.Bit(4) ? 0x0000 : 0x1000), !lcdc.Bit(4), - bgpal); + _bgpal); DrawBGDMG( bmpViewWin.bmp, - vram + (lcdc.Bit(6) ? 0x1c00 : 0x1800), - vram + 0x1000, // force win to second tile bank??? + _vram + (lcdc.Bit(6) ? 0x1c00 : 0x1800), + _vram + 0x1000, // force win to second tile bank??? true, - bgpal); + _bgpal); } else { DrawBGCGB( bmpViewBG.bmp, - vram + (lcdc.Bit(3) ? 0x1c00 : 0x1800), - vram + (lcdc.Bit(4) ? 0x0000 : 0x1000), + _vram + (lcdc.Bit(3) ? 0x1c00 : 0x1800), + _vram + (lcdc.Bit(4) ? 0x0000 : 0x1000), !lcdc.Bit(4), - bgpal); + _bgpal); DrawBGCGB( bmpViewWin.bmp, - vram + (lcdc.Bit(6) ? 0x1c00 : 0x1800), - vram + 0x1000, // force win to second tile bank??? + _vram + (lcdc.Bit(6) ? 0x1c00 : 0x1800), + _vram + 0x1000, // force win to second tile bank??? true, - bgpal); + _bgpal); } bmpViewBG.Refresh(); bmpViewWin.Refresh(); @@ -421,16 +422,16 @@ namespace BizHawk.Client.EmuHawk // tile display // TODO: user selects palette to use, instead of fixed palette 0 // or possibly "smart" where, if a tile is in use, it's drawn with one of the palettes actually being used with it? - DrawTiles(bmpViewTiles1.bmp, vram, tilespal); + DrawTiles(bmpViewTiles1.bmp, _vram, tilespal); bmpViewTiles1.Refresh(); - if (cgb) + if (_cgb) { - DrawTiles(bmpViewTiles2.bmp, vram + 0x2000, tilespal); + DrawTiles(bmpViewTiles2.bmp, _vram + 0x2000, tilespal); bmpViewTiles2.Refresh(); } // palettes - if (cgb) + if (_cgb) { bmpViewBGPal.ChangeBitmapSize(8, 4); if (bmpViewBGPal.Width != 128) @@ -438,8 +439,8 @@ namespace BizHawk.Client.EmuHawk bmpViewSPPal.ChangeBitmapSize(8, 4); if (bmpViewSPPal.Width != 128) bmpViewSPPal.Width = 128; - DrawPal(bmpViewBGPal.bmp, bgpal, 8); - DrawPal(bmpViewSPPal.bmp, sppal, 8); + DrawPal(bmpViewBGPal.bmp, _bgpal, 8); + DrawPal(bmpViewSPPal.bmp, _sppal, 8); } else { @@ -449,8 +450,8 @@ namespace BizHawk.Client.EmuHawk bmpViewSPPal.ChangeBitmapSize(2, 4); if (bmpViewSPPal.Width != 32) bmpViewSPPal.Width = 32; - DrawPal(bmpViewBGPal.bmp, bgpal, 1); - DrawPal(bmpViewSPPal.bmp, sppal, 2); + DrawPal(bmpViewBGPal.bmp, _bgpal, 1); + DrawPal(bmpViewSPPal.bmp, _sppal, 2); } bmpViewBGPal.Refresh(); bmpViewSPPal.Refresh(); @@ -468,21 +469,21 @@ namespace BizHawk.Client.EmuHawk if (bmpViewOAM.Height != 8) bmpViewOAM.Height = 8; } - DrawOam(bmpViewOAM.bmp, oam, vram, sppal, lcdc.Bit(2), cgb); + DrawOam(bmpViewOAM.bmp, _oam, _vram, _sppal, lcdc.Bit(2), _cgb); bmpViewOAM.Refresh(); // try to run the current mouseover, to refresh if the mouse is being held over a pane while the emulator runs // this doesn't really work well; the update rate seems to be throttled - MouseEventArgs e = new MouseEventArgs(System.Windows.Forms.MouseButtons.None, 0, System.Windows.Forms.Cursor.Position.X, System.Windows.Forms.Cursor.Position.Y, 0); + MouseEventArgs e = new MouseEventArgs(MouseButtons.None, 0, Cursor.Position.X, System.Windows.Forms.Cursor.Position.Y, 0); OnMouseMove(e); } private void GBGPUView_FormClosed(object sender, FormClosedEventArgs e) { - if (gb != null) + if (_gb != null) { - gb.SetScanlineCallback(null, 0); - gb = null; + _gb.SetScanlineCallback(null, 0); + _gb = null; } Global.Config.GBGPUSpriteBack = spriteback; } @@ -531,8 +532,8 @@ namespace BizHawk.Client.EmuHawk private void buttonRefresh_Click(object sender, EventArgs e) { - if (cbscanline == -2 && gb != null) - gb.SetScanlineCallback(ScanlineCallback, -2); + if (cbscanline == -2 && _gb != null) + _gb.SetScanlineCallback(ScanlineCallback, -2); } private void hScrollBarScanline_ValueChanged(object sender, EventArgs e) @@ -559,14 +560,14 @@ namespace BizHawk.Client.EmuHawk { return; } - else if (gb != null) + else if (_gb != null) { if (!Visible) { if (cbscanline_emu != -2) { cbscanline_emu = -2; - gb.SetScanlineCallback(null, 0); + _gb.SetScanlineCallback(null, 0); } } else @@ -575,9 +576,9 @@ namespace BizHawk.Client.EmuHawk { cbscanline_emu = cbscanline; if (cbscanline == -2) - gb.SetScanlineCallback(null, 0); + _gb.SetScanlineCallback(null, 0); else - gb.SetScanlineCallback(ScanlineCallback, cbscanline); + _gb.SetScanlineCallback(ScanlineCallback, cbscanline); } } } @@ -587,31 +588,31 @@ namespace BizHawk.Client.EmuHawk #region mouseovers - string freeze_label; - Bitmap freeze_bmp; - string freeze_details; + private string _freezeLabel; + private Bitmap _freezeBmp; + private string _freezeDetails; - void SaveDetails() + private void SaveDetails() { - freeze_label = groupBoxDetails.Text; - if (freeze_bmp != null) - freeze_bmp.Dispose(); - freeze_bmp = (Bitmap)bmpViewDetails.bmp.Clone(); - freeze_details = labelDetails.Text; + _freezeLabel = groupBoxDetails.Text; + if (_freezeBmp != null) + _freezeBmp.Dispose(); + _freezeBmp = (Bitmap)bmpViewDetails.bmp.Clone(); + _freezeDetails = labelDetails.Text; } - void LoadDetails() + private void LoadDetails() { - groupBoxDetails.Text = freeze_label; - bmpViewDetails.Height = freeze_bmp.Height * 8; - bmpViewDetails.ChangeBitmapSize(freeze_bmp.Size); + groupBoxDetails.Text = _freezeLabel; + bmpViewDetails.Height = _freezeBmp.Height * 8; + bmpViewDetails.ChangeBitmapSize(_freezeBmp.Size); using (var g = Graphics.FromImage(bmpViewDetails.bmp)) - g.DrawImageUnscaled(freeze_bmp, 0, 0); - labelDetails.Text = freeze_details; + g.DrawImageUnscaled(_freezeBmp, 0, 0); + labelDetails.Text = _freezeDetails; bmpViewDetails.Refresh(); } - void SetFreeze() + private void SetFreeze() { groupBoxMemory.Text = groupBoxDetails.Text; bmpViewMemory.Size = bmpViewDetails.Size; @@ -622,7 +623,7 @@ namespace BizHawk.Client.EmuHawk bmpViewMemory.Refresh(); } - unsafe void PaletteMouseover(int x, int y, bool sprite) + private unsafe void PaletteMouseover(int x, int y, bool sprite) { bmpViewDetails.ChangeBitmapSize(8, 10); if (bmpViewDetails.Height != 80) @@ -630,7 +631,7 @@ namespace BizHawk.Client.EmuHawk var sb = new StringBuilder(); x /= 16; y /= 16; - int* pal = (int*)(sprite ? sppal : bgpal) + x * 4; + int* pal = (int*)(sprite ? _sppal : _bgpal) + x * 4; int color = pal[y]; sb.AppendLine(string.Format("Palette {0}", x)); @@ -669,13 +670,13 @@ namespace BizHawk.Client.EmuHawk y /= 8; int tileindex = y * 16 + x; int tileoffs = tileindex * 16; - if (cgb) + if (_cgb) sb.AppendLine(string.Format("Tile #{0} @{2}:{1:x4}", tileindex, tileoffs + 0x8000, secondbank ? 1 : 0)); else sb.AppendLine(string.Format("Tile #{0} @{1:x4}", tileindex, tileoffs + 0x8000)); var lockdata = bmpViewDetails.bmp.LockBits(new Rectangle(0, 0, 8, 8), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); - DrawTile((byte*)vram + tileoffs + (secondbank ? 8192 : 0), (int*)lockdata.Scan0, lockdata.Stride / sizeof(int), (int*)tilespal); + DrawTile((byte*)_vram + tileoffs + (secondbank ? 8192 : 0), (int*)lockdata.Scan0, lockdata.Stride / sizeof(int), (int*)tilespal); bmpViewDetails.bmp.UnlockBits(lockdata); labelDetails.Text = sb.ToString(); bmpViewDetails.Refresh(); @@ -692,18 +693,18 @@ namespace BizHawk.Client.EmuHawk x /= 8; y /= 8; mapoffs += y * 32 + x; - byte* mapbase = (byte*)vram + mapoffs; + byte* mapbase = (byte*)_vram + mapoffs; int tileindex = mapbase[0]; if (win || !_lcdc.Bit(4)) // 0x9000 base if (tileindex < 128) tileindex += 256; // compute all if from 0x8000 base int tileoffs = tileindex * 16; var lockdata = bmpViewDetails.bmp.LockBits(new Rectangle(0, 0, 8, 8), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); - if (!cgb) + if (!_cgb) { sb.AppendLine(string.Format("{0} Map ({1},{2}) @{3:x4}", win ? "Win" : "BG", x, y, mapoffs + 0x8000)); sb.AppendLine(string.Format(" Tile #{0} @{1:x4}", tileindex, tileoffs + 0x8000)); - DrawTile((byte*)vram + tileoffs, (int*)lockdata.Scan0, lockdata.Stride / sizeof(int), (int*)bgpal); + DrawTile((byte*)_vram + tileoffs, (int*)lockdata.Scan0, lockdata.Stride / sizeof(int), (int*)_bgpal); } else { @@ -713,7 +714,7 @@ namespace BizHawk.Client.EmuHawk sb.AppendLine(string.Format(" Tile #{0} @{2}:{1:x4}", tileindex, tileoffs + 0x8000, tileext.Bit(3) ? 1 : 0)); sb.AppendLine(string.Format(" Palette {0}", tileext & 7)); sb.AppendLine(string.Format(" Flags {0}{1}{2}", tileext.Bit(5) ? 'H' : ' ', tileext.Bit(6) ? 'V' : ' ', tileext.Bit(7) ? 'P' : ' ')); - DrawTileHV((byte*)vram + tileoffs + (tileext.Bit(3) ? 8192 : 0), (int*)lockdata.Scan0, lockdata.Stride / sizeof(int), (int*)bgpal + 4 * (tileext & 7), tileext.Bit(5), tileext.Bit(6)); + DrawTileHv((byte*)_vram + tileoffs + (tileext.Bit(3) ? 8192 : 0), (int*)lockdata.Scan0, lockdata.Stride / sizeof(int), (int*)_bgpal + 4 * (tileext & 7), tileext.Bit(5), tileext.Bit(6)); } bmpViewDetails.bmp.UnlockBits(lockdata); labelDetails.Text = sb.ToString(); @@ -730,7 +731,7 @@ namespace BizHawk.Client.EmuHawk bmpViewDetails.Height = bmpViewDetails.bmp.Height * 8; var sb = new StringBuilder(); - byte* oament = (byte*)oam + 4 * x; + byte* oament = (byte*)_oam + 4 * x; int sy = oament[0]; int sx = oament[1]; int tilenum = oament[2]; @@ -743,21 +744,21 @@ namespace BizHawk.Client.EmuHawk sb.AppendLine(string.Format("Sprite #{0} @{1:x4}", x, 4 * x + 0xfe00)); sb.AppendLine(string.Format(" (x,y) = ({0},{1})", sx, sy)); var lockdata = bmpViewDetails.bmp.LockBits(new Rectangle(0, 0, 8, tall ? 16 : 8), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); - if (cgb) + if (_cgb) { sb.AppendLine(string.Format(" Tile #{0} @{2}:{1:x4}", y == 1 ? tilenum ^ 1 : tilenum, tileoffs + 0x8000, flags.Bit(3) ? 1 : 0)); sb.AppendLine(string.Format(" Palette {0}", flags & 7)); - DrawTileHV((byte*)vram + tileoffs + (flags.Bit(3) ? 8192 : 0), (int*)lockdata.Scan0, lockdata.Stride / sizeof(int), (int*)sppal + 4 * (flags & 7), hflip, vflip); + DrawTileHv((byte*)_vram + tileoffs + (flags.Bit(3) ? 8192 : 0), (int*)lockdata.Scan0, lockdata.Stride / sizeof(int), (int*)_sppal + 4 * (flags & 7), hflip, vflip); if (tall) - DrawTileHV((byte*)vram + (tileoffs ^ 16) + (flags.Bit(3) ? 8192 : 0), (int*)(lockdata.Scan0 + lockdata.Stride * 8), lockdata.Stride / sizeof(int), (int*)sppal + 4 * (flags & 7), hflip, vflip); + DrawTileHv((byte*)_vram + (tileoffs ^ 16) + (flags.Bit(3) ? 8192 : 0), (int*)(lockdata.Scan0 + lockdata.Stride * 8), lockdata.Stride / sizeof(int), (int*)_sppal + 4 * (flags & 7), hflip, vflip); } else { sb.AppendLine(string.Format(" Tile #{0} @{1:x4}", y == 1 ? tilenum ^ 1 : tilenum, tileoffs + 0x8000)); sb.AppendLine(string.Format(" Palette {0}", flags.Bit(4) ? 1 : 0)); - DrawTileHV((byte*)vram + tileoffs, (int*)lockdata.Scan0, lockdata.Stride / sizeof(int), (int*)sppal + (flags.Bit(4) ? 4 : 0), hflip, vflip); + DrawTileHv((byte*)_vram + tileoffs, (int*)lockdata.Scan0, lockdata.Stride / sizeof(int), (int*)_sppal + (flags.Bit(4) ? 4 : 0), hflip, vflip); if (tall) - DrawTileHV((byte*)vram + (tileoffs ^ 16), (int*)(lockdata.Scan0 + lockdata.Stride * 8), lockdata.Stride / sizeof(int), (int*)sppal + 4 * (flags.Bit(4) ? 4 : 0), hflip, vflip); + DrawTileHv((byte*)_vram + (tileoffs ^ 16), (int*)(lockdata.Scan0 + lockdata.Stride * 8), lockdata.Stride / sizeof(int), (int*)_sppal + 4 * (flags.Bit(4) ? 4 : 0), hflip, vflip); } sb.AppendLine(string.Format(" Flags {0}{1}{2}", hflip ? 'H' : ' ', vflip ? 'V' : ' ', flags.Bit(7) ? 'P' : ' ')); bmpViewDetails.bmp.UnlockBits(lockdata); @@ -815,7 +816,7 @@ namespace BizHawk.Client.EmuHawk private void bmpViewTiles2_MouseEnter(object sender, EventArgs e) { - if (!cgb) + if (!_cgb) return; SaveDetails(); groupBoxDetails.Text = "Details - Tiles"; @@ -823,14 +824,14 @@ namespace BizHawk.Client.EmuHawk private void bmpViewTiles2_MouseLeave(object sender, EventArgs e) { - if (!cgb) + if (!_cgb) return; LoadDetails(); } private void bmpViewTiles2_MouseMove(object sender, MouseEventArgs e) { - if (!cgb) + if (!_cgb) return; TileMouseover(e.X, e.Y, true); } @@ -892,15 +893,15 @@ namespace BizHawk.Client.EmuHawk else if (e.Button == MouseButtons.Left) { if (sender == bmpViewBGPal) - tilespal = bgpal + e.X / 16 * 16; + tilespal = _bgpal + e.X / 16 * 16; else if (sender == bmpViewSPPal) - tilespal = sppal + e.X / 16 * 16; + tilespal = _sppal + e.X / 16 * 16; } } #region copyimage - private readonly Timer messagetimer = new Timer(); + private readonly Timer _messagetimer = new Timer(); private void GBGPUView_KeyDown(object sender, KeyEventArgs e) { @@ -921,8 +922,8 @@ namespace BizHawk.Client.EmuHawk var bv = found as BmpView; Clipboard.SetImage(bv.bmp); labelClipboard.Text = found.Text + " copied to clipboard."; - messagetimer.Stop(); - messagetimer.Start(); + _messagetimer.Stop(); + _messagetimer.Start(); } } @@ -930,7 +931,7 @@ namespace BizHawk.Client.EmuHawk void messagetimer_Tick(object sender, EventArgs e) { - messagetimer.Stop(); + _messagetimer.Stop(); labelClipboard.Text = "CTRL+C copies the pane under the mouse."; } diff --git a/BizHawk.Client.EmuHawk/tools/GB/GBGameGenie.cs b/BizHawk.Client.EmuHawk/tools/GB/GBGameGenie.cs index 99962ee0a9..7aa4fa6dfc 100644 --- a/BizHawk.Client.EmuHawk/tools/GB/GBGameGenie.cs +++ b/BizHawk.Client.EmuHawk/tools/GB/GBGameGenie.cs @@ -11,11 +11,13 @@ namespace BizHawk.Client.EmuHawk { public partial class GBGameGenie : Form, IToolForm { - private readonly Dictionary GameGenieTable = new Dictionary(); - private bool Processing = false; + private readonly Dictionary _gameGenieTable = new Dictionary(); + private bool _processing; public bool AskSave() { return true; } + public bool UpdateBefore { get { return false; } } + public void Restart() { if ((Global.Emulator.SystemId != "GB") && (Global.Game.System != "GG")) @@ -23,6 +25,7 @@ namespace BizHawk.Client.EmuHawk Close(); } } + public void UpdateValues() { if ((Global.Emulator.SystemId != "GB") && (Global.Game.System != "GG")) @@ -36,22 +39,22 @@ namespace BizHawk.Client.EmuHawk InitializeComponent(); Closing += (o, e) => SaveConfigSettings(); - GameGenieTable.Add('0', 0); //0000 - GameGenieTable.Add('1', 1); //0001 - GameGenieTable.Add('2', 2); //0010 - GameGenieTable.Add('3', 3); //0011 - GameGenieTable.Add('4', 4); //0100 - GameGenieTable.Add('5', 5); //0101 - GameGenieTable.Add('6', 6); //0110 - GameGenieTable.Add('7', 7); //0111 - GameGenieTable.Add('8', 8); //1000 - GameGenieTable.Add('9', 9); //1001 - GameGenieTable.Add('A', 10); //1010 - GameGenieTable.Add('B', 11); //1011 - GameGenieTable.Add('C', 12); //1100 - GameGenieTable.Add('D', 13); //1101 - GameGenieTable.Add('E', 14); //1110 - GameGenieTable.Add('F', 15); //1111 + _gameGenieTable.Add('0', 0); //0000 + _gameGenieTable.Add('1', 1); //0001 + _gameGenieTable.Add('2', 2); //0010 + _gameGenieTable.Add('3', 3); //0011 + _gameGenieTable.Add('4', 4); //0100 + _gameGenieTable.Add('5', 5); //0101 + _gameGenieTable.Add('6', 6); //0110 + _gameGenieTable.Add('7', 7); //0111 + _gameGenieTable.Add('8', 8); //1000 + _gameGenieTable.Add('9', 9); //1001 + _gameGenieTable.Add('A', 10); //1010 + _gameGenieTable.Add('B', 11); //1011 + _gameGenieTable.Add('C', 12); //1100 + _gameGenieTable.Add('D', 13); //1101 + _gameGenieTable.Add('E', 14); //1110 + _gameGenieTable.Add('F', 15); //1111 } public void GBGGDecode(string code, ref int val, ref int add, ref int cmp) @@ -67,19 +70,19 @@ namespace BizHawk.Client.EmuHawk // Getting Value if (code.Length > 0) { - GameGenieTable.TryGetValue(code[0], out x); + _gameGenieTable.TryGetValue(code[0], out x); val = x << 4; } if (code.Length > 1) { - GameGenieTable.TryGetValue(code[1], out x); + _gameGenieTable.TryGetValue(code[1], out x); val |= x; } //Address if (code.Length > 2) { - GameGenieTable.TryGetValue(code[2], out x); + _gameGenieTable.TryGetValue(code[2], out x); add = (x << 8); } else @@ -87,29 +90,29 @@ namespace BizHawk.Client.EmuHawk if (code.Length > 3) { - GameGenieTable.TryGetValue(code[3], out x); + _gameGenieTable.TryGetValue(code[3], out x); add |= (x << 4); } if (code.Length > 4) { - GameGenieTable.TryGetValue(code[4], out x); + _gameGenieTable.TryGetValue(code[4], out x); add |= x; } if (code.Length > 5) { - GameGenieTable.TryGetValue(code[5], out x); + _gameGenieTable.TryGetValue(code[5], out x); add |= ((x ^ 0xF) << 12); } // compare need to be full if (code.Length > 8) { int comp = 0; - GameGenieTable.TryGetValue(code[6], out x); + _gameGenieTable.TryGetValue(code[6], out x); comp = (x << 2); // 8th character ignored - GameGenieTable.TryGetValue(code[8], out x); + _gameGenieTable.TryGetValue(code[8], out x); comp |= ((x & 0xC) >> 2); comp |= ((x & 0x3) << 6); cmp = comp ^ 0xBA; @@ -176,9 +179,9 @@ namespace BizHawk.Client.EmuHawk private void GGCodeMaskBox_TextChanged(object sender, EventArgs e) { - if (Processing == false) + if (_processing == false) { - Processing = true; + _processing = true; //insert REGEX Remove non HEXA char if (Regex.IsMatch(GGCodeMaskBox.Text, @"[^a-fA-F0-9]")) { @@ -210,7 +213,7 @@ namespace BizHawk.Client.EmuHawk CompareBox.Text = ""; addcheatbt.Enabled = false; } - Processing = false; + _processing = false; } } @@ -246,9 +249,9 @@ namespace BizHawk.Client.EmuHawk private void AddressBox_TextChanged(object sender, EventArgs e) { //remove invalid character when pasted - if (Processing == false) + if (_processing == false) { - Processing = true; + _processing = true; if (Regex.IsMatch(AddressBox.Text, @"[^a-fA-F0-9]")) { string temp = Regex.Replace(AddressBox.Text, @"[^a-fA-F0-9]", string.Empty); @@ -274,7 +277,7 @@ namespace BizHawk.Client.EmuHawk GGCodeMaskBox.Text = ""; addcheatbt.Enabled = false; } - Processing = false; + _processing = false; } } @@ -282,9 +285,9 @@ namespace BizHawk.Client.EmuHawk private void ValueBox_TextChanged(object sender, EventArgs e) { - if (Processing == false) + if (_processing == false) { - Processing = true; + _processing = true; //remove invalid character when pasted if (Regex.IsMatch(ValueBox.Text, @"[^a-fA-F0-9]")) { @@ -311,16 +314,16 @@ namespace BizHawk.Client.EmuHawk GGCodeMaskBox.Text = ""; addcheatbt.Enabled = false; } - Processing = false; + _processing = false; } } private void CompareBox_TextChanged(object sender, EventArgs e) { - if (Processing == false) + if (_processing == false) { - Processing = true; + _processing = true; //remove invalid character when pasted if (Regex.IsMatch(CompareBox.Text, @"[^a-fA-F0-9]")) { @@ -350,7 +353,7 @@ namespace BizHawk.Client.EmuHawk addcheatbt.Enabled = false; } } - Processing = false; + _processing = false; } } @@ -367,7 +370,7 @@ namespace BizHawk.Client.EmuHawk { if ((Global.Emulator.SystemId == "GB") || (Global.Game.System == "GG")) { - string NAME = String.Empty; + string NAME; int ADDRESS = 0; int VALUE = 0; int? COMPARE = null; @@ -379,11 +382,11 @@ namespace BizHawk.Client.EmuHawk } else { - Processing = true; + _processing = true; GGCodeMaskBox.TextMaskFormat = MaskFormat.IncludeLiterals; NAME = GGCodeMaskBox.Text; GGCodeMaskBox.TextMaskFormat = MaskFormat.ExcludePromptAndLiterals; - Processing = false; + _processing = false; } if (!String.IsNullOrWhiteSpace(AddressBox.Text)) @@ -428,8 +431,7 @@ namespace BizHawk.Client.EmuHawk Global.CheatList.Add(new Cheat( watch, VALUE, - COMPARE, - enabled: true)); + COMPARE)); } } diff --git a/BizHawk.Client.EmuHawk/tools/GBA/GBAGPUView.cs b/BizHawk.Client.EmuHawk/tools/GBA/GBAGPUView.cs index d780c09130..4b1210a7d2 100644 --- a/BizHawk.Client.EmuHawk/tools/GBA/GBAGPUView.cs +++ b/BizHawk.Client.EmuHawk/tools/GBA/GBAGPUView.cs @@ -168,7 +168,7 @@ namespace BizHawk.Client.EmuHawk case 2: mbv.ChangeAllSizes(256, 512); break; case 3: mbv.ChangeAllSizes(512, 512); break; } - Bitmap bmp = mbv.bmpView.bmp; + Bitmap bmp = mbv.BmpView.bmp; var lockdata = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); int* pixels = (int*)lockdata.Scan0; @@ -213,7 +213,7 @@ namespace BizHawk.Client.EmuHawk } bmp.UnlockBits(lockdata); - mbv.bmpView.Refresh(); + mbv.BmpView.Refresh(); } unsafe void DrawAffineBG(int n, MobileBmpView mbv) @@ -227,7 +227,7 @@ namespace BizHawk.Client.EmuHawk case 2: mbv.ChangeAllSizes(512, 512); break; case 3: mbv.ChangeAllSizes(1024, 1024); break; } - Bitmap bmp = mbv.bmpView.bmp; + Bitmap bmp = mbv.BmpView.bmp; var lockdata = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); int* pixels = (int*)lockdata.Scan0; @@ -249,13 +249,13 @@ namespace BizHawk.Client.EmuHawk } bmp.UnlockBits(lockdata); - mbv.bmpView.Refresh(); + mbv.BmpView.Refresh(); } unsafe void DrawM3BG(MobileBmpView mbv) { mbv.ChangeAllSizes(240, 160); - Bitmap bmp = mbv.bmpView.bmp; + Bitmap bmp = mbv.BmpView.bmp; var lockdata = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); int* pixels = (int*)lockdata.Scan0; @@ -272,13 +272,13 @@ namespace BizHawk.Client.EmuHawk } bmp.UnlockBits(lockdata); - mbv.bmpView.Refresh(); + mbv.BmpView.Refresh(); } unsafe void DrawM4BG(MobileBmpView mbv, bool secondframe) { mbv.ChangeAllSizes(240, 160); - Bitmap bmp = mbv.bmpView.bmp; + Bitmap bmp = mbv.BmpView.bmp; var lockdata = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); int* pixels = (int*)lockdata.Scan0; @@ -296,13 +296,13 @@ namespace BizHawk.Client.EmuHawk } bmp.UnlockBits(lockdata); - mbv.bmpView.Refresh(); + mbv.BmpView.Refresh(); } unsafe void DrawM5BG(MobileBmpView mbv, bool secondframe) { mbv.ChangeAllSizes(160, 128); - Bitmap bmp = mbv.bmpView.bmp; + Bitmap bmp = mbv.BmpView.bmp; var lockdata = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); int* pixels = (int*)lockdata.Scan0; @@ -319,7 +319,7 @@ namespace BizHawk.Client.EmuHawk } bmp.UnlockBits(lockdata); - mbv.bmpView.Refresh(); + mbv.BmpView.Refresh(); } static readonly int[, ,] spritesizes = { { { 1, 1 }, { 2, 2 }, { 4, 4 }, { 8, 8 } }, { { 2, 1 }, { 4, 1 }, { 4, 2 }, { 8, 4 } }, { { 1, 2 }, { 1, 4 }, { 2, 4 }, { 4, 8 } } }; @@ -392,8 +392,8 @@ namespace BizHawk.Client.EmuHawk unsafe void DrawSprites(MobileBmpView mbv) { - mbv.bmpView.ChangeBitmapSize(1024, 512); - Bitmap bmp = mbv.bmpView.bmp; + mbv.BmpView.ChangeBitmapSize(1024, 512); + Bitmap bmp = mbv.BmpView.bmp; var lockdata = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); // Clear() Win32.MemSet(lockdata.Scan0, 0xff, (uint)(lockdata.Height * lockdata.Stride)); @@ -420,13 +420,13 @@ namespace BizHawk.Client.EmuHawk } bmp.UnlockBits(lockdata); - mbv.bmpView.Refresh(); + mbv.BmpView.Refresh(); } unsafe void DrawPalette(MobileBmpView mbv, bool sprite) { - mbv.bmpView.ChangeBitmapSize(16, 16); - Bitmap bmp = mbv.bmpView.bmp; + mbv.BmpView.ChangeBitmapSize(16, 16); + Bitmap bmp = mbv.BmpView.bmp; var lockdata = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); int* pixels = (int*)lockdata.Scan0; @@ -443,7 +443,7 @@ namespace BizHawk.Client.EmuHawk } bmp.UnlockBits(lockdata); - mbv.bmpView.Refresh(); + mbv.BmpView.Refresh(); } unsafe void DrawTileRange(int* dest, int pitch, byte* tiles, ushort* palette, int tw, int th, bool eightbit) @@ -475,8 +475,8 @@ namespace BizHawk.Client.EmuHawk int tw = eightbit ? 16 : 32; int th = tophalfonly ? 16 : 32; - mbv.bmpView.ChangeBitmapSize(tw * 8, 256); - Bitmap bmp = mbv.bmpView.bmp; + mbv.BmpView.ChangeBitmapSize(tw * 8, 256); + Bitmap bmp = mbv.BmpView.bmp; var lockdata = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); int* pixels = (int*)lockdata.Scan0; @@ -494,7 +494,7 @@ namespace BizHawk.Client.EmuHawk } DrawTileRange(pixels, pitch, tiles, palette, tw, th, eightbit); bmp.UnlockBits(lockdata); - mbv.bmpView.Refresh(); + mbv.BmpView.Refresh(); } unsafe void DrawBGTiles(MobileBmpView mbv, bool eightbit) @@ -502,8 +502,8 @@ namespace BizHawk.Client.EmuHawk int tw = eightbit ? 32 : 64; int th = 32; - mbv.bmpView.ChangeBitmapSize(tw * 8, th * 8); - Bitmap bmp = mbv.bmpView.bmp; + mbv.BmpView.ChangeBitmapSize(tw * 8, th * 8); + Bitmap bmp = mbv.BmpView.bmp; var lockdata = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); int* pixels = (int*)lockdata.Scan0; @@ -514,7 +514,7 @@ namespace BizHawk.Client.EmuHawk ushort* palette = (ushort*)palram; DrawTileRange(pixels, pitch, tiles, palette, tw, th, eightbit); bmp.UnlockBits(lockdata); - mbv.bmpView.Refresh(); + mbv.BmpView.Refresh(); } @@ -541,15 +541,15 @@ namespace BizHawk.Client.EmuHawk if (bg0.ShouldDraw) DrawTextBG(0, bg0); if (bg1.ShouldDraw) DrawTextBG(1, bg1); if (bg2.ShouldDraw) DrawAffineBG(2, bg2); - if (bg3.ShouldDraw) bg3.bmpView.Clear(); + if (bg3.ShouldDraw) bg3.BmpView.Clear(); if (bgtiles16.ShouldDraw) DrawBGTiles(bgtiles16, false); if (bgtiles256.ShouldDraw) DrawBGTiles(bgtiles256, true); if (sptiles16.ShouldDraw) DrawSpriteTiles(sptiles16, false, false); if (sptiles256.ShouldDraw) DrawSpriteTiles(sptiles256, false, true); break; case 2: - if (bg0.ShouldDraw) bg0.bmpView.Clear(); - if (bg1.ShouldDraw) bg1.bmpView.Clear(); + if (bg0.ShouldDraw) bg0.BmpView.Clear(); + if (bg1.ShouldDraw) bg1.BmpView.Clear(); if (bg2.ShouldDraw) DrawAffineBG(2, bg2); if (bg3.ShouldDraw) DrawAffineBG(3, bg3); // while there are no 4bpp tiles possible in mode 2, there might be some in memory @@ -561,46 +561,46 @@ namespace BizHawk.Client.EmuHawk if (sptiles256.ShouldDraw) DrawSpriteTiles(sptiles256, false, true); break; case 3: - if (bg0.ShouldDraw) bg0.bmpView.Clear(); - if (bg1.ShouldDraw) bg1.bmpView.Clear(); + if (bg0.ShouldDraw) bg0.BmpView.Clear(); + if (bg1.ShouldDraw) bg1.BmpView.Clear(); if (bg2.ShouldDraw) DrawM3BG(bg2); - if (bg3.ShouldDraw) bg3.bmpView.Clear(); - if (bgtiles16.ShouldDraw) bgtiles16.bmpView.Clear(); - if (bgtiles256.ShouldDraw) bgtiles256.bmpView.Clear(); + if (bg3.ShouldDraw) bg3.BmpView.Clear(); + if (bgtiles16.ShouldDraw) bgtiles16.BmpView.Clear(); + if (bgtiles256.ShouldDraw) bgtiles256.BmpView.Clear(); if (sptiles16.ShouldDraw) DrawSpriteTiles(sptiles16, true, false); if (sptiles256.ShouldDraw) DrawSpriteTiles(sptiles256, true, true); break; //in modes 4, 5, bg3 is repurposed as bg2 invisible frame case 4: - if (bg0.ShouldDraw) bg0.bmpView.Clear(); - if (bg1.ShouldDraw) bg1.bmpView.Clear(); + if (bg0.ShouldDraw) bg0.BmpView.Clear(); + if (bg1.ShouldDraw) bg1.BmpView.Clear(); if (bg2.ShouldDraw) DrawM4BG(bg2, dispcnt.Bit(4)); if (bg3.ShouldDraw) DrawM4BG(bg3, !dispcnt.Bit(4)); - if (bgtiles16.ShouldDraw) bgtiles16.bmpView.Clear(); - if (bgtiles256.ShouldDraw) bgtiles256.bmpView.Clear(); + if (bgtiles16.ShouldDraw) bgtiles16.BmpView.Clear(); + if (bgtiles256.ShouldDraw) bgtiles256.BmpView.Clear(); if (sptiles16.ShouldDraw) DrawSpriteTiles(sptiles16, true, false); if (sptiles256.ShouldDraw) DrawSpriteTiles(sptiles256, true, true); break; case 5: - if (bg0.ShouldDraw) bg0.bmpView.Clear(); - if (bg1.ShouldDraw) bg1.bmpView.Clear(); + if (bg0.ShouldDraw) bg0.BmpView.Clear(); + if (bg1.ShouldDraw) bg1.BmpView.Clear(); if (bg2.ShouldDraw) DrawM5BG(bg2, dispcnt.Bit(4)); if (bg3.ShouldDraw) DrawM5BG(bg3, !dispcnt.Bit(4)); - if (bgtiles16.ShouldDraw) bgtiles16.bmpView.Clear(); - if (bgtiles256.ShouldDraw) bgtiles256.bmpView.Clear(); + if (bgtiles16.ShouldDraw) bgtiles16.BmpView.Clear(); + if (bgtiles256.ShouldDraw) bgtiles256.BmpView.Clear(); if (sptiles16.ShouldDraw) DrawSpriteTiles(sptiles16, true, false); if (sptiles256.ShouldDraw) DrawSpriteTiles(sptiles256, true, true); break; default: // shouldn't happen, but shouldn't be our problem either - if (bg0.ShouldDraw) bg0.bmpView.Clear(); - if (bg1.ShouldDraw) bg1.bmpView.Clear(); - if (bg2.ShouldDraw) bg2.bmpView.Clear(); - if (bg3.ShouldDraw) bg3.bmpView.Clear(); - if (bgtiles16.ShouldDraw) bgtiles16.bmpView.Clear(); - if (bgtiles256.ShouldDraw) bgtiles256.bmpView.Clear(); - if (sptiles16.ShouldDraw) sptiles16.bmpView.Clear(); - if (sptiles256.ShouldDraw) sptiles256.bmpView.Clear(); + if (bg0.ShouldDraw) bg0.BmpView.Clear(); + if (bg1.ShouldDraw) bg1.BmpView.Clear(); + if (bg2.ShouldDraw) bg2.BmpView.Clear(); + if (bg3.ShouldDraw) bg3.BmpView.Clear(); + if (bgtiles16.ShouldDraw) bgtiles16.BmpView.Clear(); + if (bgtiles256.ShouldDraw) bgtiles256.BmpView.Clear(); + if (sptiles16.ShouldDraw) sptiles16.BmpView.Clear(); + if (sptiles256.ShouldDraw) sptiles256.BmpView.Clear(); break; } @@ -614,10 +614,10 @@ namespace BizHawk.Client.EmuHawk { var mbv = new MobileBmpView(); mbv.Text = text; - mbv.bmpView.Text = text; + mbv.BmpView.Text = text; mbv.TopLevel = false; mbv.ChangeViewSize(w, h); - mbv.bmpView.Clear(); + mbv.BmpView.Clear(); panel1.Controls.Add(mbv); listBoxWidgets.Items.Add(mbv); return mbv; @@ -627,10 +627,10 @@ namespace BizHawk.Client.EmuHawk { var mdv = new MobileDetailView(); mdv.Text = text; - mdv.bmpView.Text = text; + mdv.BmpView.Text = text; mdv.TopLevel = false; mdv.ClientSize = new Size(w, h); - mdv.bmpView.Clear(); + mdv.BmpView.Clear(); panel1.Controls.Add(mdv); listBoxWidgets.Items.Add(mdv); return mdv; @@ -699,20 +699,20 @@ namespace BizHawk.Client.EmuHawk return; if (gba != null) { - if (cbscanline_emu != cbscanline) + if (_cbscanlineEmu != _cbscanline) { - cbscanline_emu = cbscanline; - if (cbscanline == -2) // manual, do nothing + _cbscanlineEmu = _cbscanline; + if (_cbscanline == -2) // manual, do nothing { gba.SetScanlineCallback(null, null); } - else if (cbscanline == -1) // end of frame + else if (_cbscanline == -1) // end of frame { gba.SetScanlineCallback(DrawEverything, null); } else { - gba.SetScanlineCallback(DrawEverything, cbscanline); + gba.SetScanlineCallback(DrawEverything, _cbscanline); } } } @@ -746,28 +746,28 @@ namespace BizHawk.Client.EmuHawk #region refresh control - int cbscanline; - int cbscanline_emu = 500; + private int _cbscanline; + private int _cbscanlineEmu = 500; - void RecomputeRefresh() + private void RecomputeRefresh() { if (radioButtonFrame.Checked) { hScrollBar1.Enabled = false; buttonRefresh.Enabled = false; - cbscanline = -1; + _cbscanline = -1; } else if (radioButtonScanline.Checked) { hScrollBar1.Enabled = true; buttonRefresh.Enabled = false; - cbscanline = (hScrollBar1.Value + 160) % 228; + _cbscanline = (hScrollBar1.Value + 160) % 228; } else if (radioButtonManual.Checked) { hScrollBar1.Enabled = false; buttonRefresh.Enabled = true; - cbscanline = -2; + _cbscanline = -2; } } @@ -783,8 +783,8 @@ namespace BizHawk.Client.EmuHawk private void hScrollBar1_ValueChanged(object sender, EventArgs e) { - cbscanline = (hScrollBar1.Value + 160) % 228; - radioButtonScanline.Text = "Scanline " + cbscanline; + _cbscanline = (hScrollBar1.Value + 160) % 228; + radioButtonScanline.Text = "Scanline " + _cbscanline; } private void radioButtonManual_CheckedChanged(object sender, EventArgs e) @@ -818,22 +818,21 @@ namespace BizHawk.Client.EmuHawk private void GBAGPUView_KeyDown(object sender, KeyEventArgs e) { - if (Control.ModifierKeys.HasFlag(Keys.Control) && e.KeyCode == Keys.C) + if (ModifierKeys.HasFlag(Keys.Control) && e.KeyCode == Keys.C) { // find the control under the mouse - Point m = System.Windows.Forms.Cursor.Position; + Point m = Cursor.Position; Control top = this; - Control found = null; + Control found; do { found = top.GetChildAtPoint(top.PointToClient(m)); top = found; } while (found != null && found.HasChildren); - if (found != null && found is BmpView) + if (found is BmpView) { - var bv = found as BmpView; - Clipboard.SetImage(bv.bmp); + Clipboard.SetImage((found as BmpView).bmp); labelClipboard.Text = found.Text + " copied to clipboard."; timerMessage.Stop(); timerMessage.Start(); diff --git a/BizHawk.Client.EmuHawk/tools/GBA/MobileBmpView.Designer.cs b/BizHawk.Client.EmuHawk/tools/GBA/MobileBmpView.Designer.cs index e33564fd34..21751a024b 100644 --- a/BizHawk.Client.EmuHawk/tools/GBA/MobileBmpView.Designer.cs +++ b/BizHawk.Client.EmuHawk/tools/GBA/MobileBmpView.Designer.cs @@ -28,23 +28,23 @@ /// private void InitializeComponent() { - this.bmpView1 = new BizHawk.Client.EmuHawk.BmpView(); + this.BmpView = new BizHawk.Client.EmuHawk.BmpView(); this.SuspendLayout(); // // bmpView1 // - this.bmpView1.Location = new System.Drawing.Point(0, 0); - this.bmpView1.Name = "bmpView1"; - this.bmpView1.Size = new System.Drawing.Size(64, 64); - this.bmpView1.TabIndex = 0; - this.bmpView1.Text = "bmpView1"; + this.BmpView.Location = new System.Drawing.Point(0, 0); + this.BmpView.Name = "bmpView"; + this.BmpView.Size = new System.Drawing.Size(64, 64); + this.BmpView.TabIndex = 0; + this.BmpView.Text = "bmpView1"; // // MobileBmpView // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(292, 273); - this.Controls.Add(this.bmpView1); + this.Controls.Add(this.BmpView); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; this.MaximizeBox = false; this.MinimizeBox = false; @@ -56,7 +56,5 @@ } #endregion - - private BmpView bmpView1; } } \ No newline at end of file diff --git a/BizHawk.Client.EmuHawk/tools/GBA/MobileBmpView.cs b/BizHawk.Client.EmuHawk/tools/GBA/MobileBmpView.cs index ebfcf83190..df719f9689 100644 --- a/BizHawk.Client.EmuHawk/tools/GBA/MobileBmpView.cs +++ b/BizHawk.Client.EmuHawk/tools/GBA/MobileBmpView.cs @@ -1,10 +1,5 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; +using System.ComponentModel; using System.Drawing; -using System.Linq; -using System.Text; using System.Windows.Forms; namespace BizHawk.Client.EmuHawk @@ -16,10 +11,10 @@ namespace BizHawk.Client.EmuHawk InitializeComponent(); } - public BmpView bmpView { get { return bmpView1; } } + public BmpView BmpView { get; private set; } [Browsable(false)] - public bool ShouldDraw { get { return this.Visible; } } + public bool ShouldDraw { get { return Visible; } } public override string ToString() { @@ -28,22 +23,24 @@ namespace BizHawk.Client.EmuHawk public void ChangeViewSize(Size size) { - bmpView1.Size = size; - this.ClientSize = size; + BmpView.Size = ClientSize = size; } + public void ChangeViewSize(int w, int h) { ChangeViewSize(new Size(w, h)); } + public void ChangeAllSizes(int w, int h) { ChangeViewSize(w, h); - bmpView1.ChangeBitmapSize(w, h); + BmpView.ChangeBitmapSize(w, h); } + public void ChangeAllSizes(Size size) { ChangeViewSize(size); - bmpView1.ChangeBitmapSize(size); + BmpView.ChangeBitmapSize(size); } } } diff --git a/BizHawk.Client.EmuHawk/tools/GBA/MobileDetailView.Designer.cs b/BizHawk.Client.EmuHawk/tools/GBA/MobileDetailView.Designer.cs index 29da7361ee..959e894150 100644 --- a/BizHawk.Client.EmuHawk/tools/GBA/MobileDetailView.Designer.cs +++ b/BizHawk.Client.EmuHawk/tools/GBA/MobileDetailView.Designer.cs @@ -29,7 +29,7 @@ private void InitializeComponent() { this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); - this.bmpView1 = new BizHawk.Client.EmuHawk.BmpView(); + this.BmpView = new BizHawk.Client.EmuHawk.BmpView(); this.listView1 = new System.Windows.Forms.ListView(); this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); @@ -40,7 +40,7 @@ // this.tableLayoutPanel1.ColumnCount = 1; this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tableLayoutPanel1.Controls.Add(this.bmpView1, 0, 0); + this.tableLayoutPanel1.Controls.Add(this.BmpView, 0, 0); this.tableLayoutPanel1.Controls.Add(this.listView1, 0, 1); this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); @@ -53,12 +53,12 @@ // // bmpView1 // - this.bmpView1.Dock = System.Windows.Forms.DockStyle.Fill; - this.bmpView1.Location = new System.Drawing.Point(3, 3); - this.bmpView1.Name = "bmpView1"; - this.bmpView1.Size = new System.Drawing.Size(136, 134); - this.bmpView1.TabIndex = 0; - this.bmpView1.Text = "bmpView1"; + this.BmpView.Dock = System.Windows.Forms.DockStyle.Fill; + this.BmpView.Location = new System.Drawing.Point(3, 3); + this.BmpView.Name = "bmpView"; + this.BmpView.Size = new System.Drawing.Size(136, 134); + this.BmpView.TabIndex = 0; + this.BmpView.Text = "bmpView1"; // // listView1 // @@ -96,7 +96,6 @@ #endregion private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; - private BmpView bmpView1; private System.Windows.Forms.ListView listView1; private System.Windows.Forms.ColumnHeader columnHeader1; private System.Windows.Forms.ColumnHeader columnHeader2; diff --git a/BizHawk.Client.EmuHawk/tools/GBA/MobileDetailView.cs b/BizHawk.Client.EmuHawk/tools/GBA/MobileDetailView.cs index ad95d73f3b..0a78bc29db 100644 --- a/BizHawk.Client.EmuHawk/tools/GBA/MobileDetailView.cs +++ b/BizHawk.Client.EmuHawk/tools/GBA/MobileDetailView.cs @@ -1,10 +1,6 @@ using System; using System.Collections.Generic; using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; using System.Windows.Forms; namespace BizHawk.Client.EmuHawk @@ -16,10 +12,10 @@ namespace BizHawk.Client.EmuHawk InitializeComponent(); } - public BmpView bmpView { get { return bmpView1; } } + public BmpView BmpView { get; private set; } [Browsable(false)] - public bool ShouldDraw { get { return this.Visible; } } + public bool ShouldDraw { get { return Visible; } } public override string ToString() { @@ -31,7 +27,7 @@ namespace BizHawk.Client.EmuHawk listView1.Items.Clear(); foreach (var t in details) { - listView1.Items.Add(new ListViewItem(new string[] { t.Item1, t.Item2 })); + listView1.Items.Add(new ListViewItem(new[] { t.Item1, t.Item2 })); } } diff --git a/BizHawk.Client.EmuHawk/tools/Genesis/GenGameGenie.cs b/BizHawk.Client.EmuHawk/tools/Genesis/GenGameGenie.cs index 3ca75db454..18a9524f7c 100644 --- a/BizHawk.Client.EmuHawk/tools/Genesis/GenGameGenie.cs +++ b/BizHawk.Client.EmuHawk/tools/Genesis/GenGameGenie.cs @@ -14,7 +14,7 @@ namespace BizHawk.Client.EmuHawk { public partial class GenGameGenie : Form, IToolForm { - bool Processing = false; + bool _processing; private readonly Dictionary GameGenieTable = new Dictionary(); public bool AskSave() { return true; } @@ -82,10 +82,10 @@ namespace BizHawk.Client.EmuHawk int y = 0; //convert code to a long binary string - for (int x = 0; x < code.Length; x++) + foreach (char t in code) { hexcode <<= 5; - GameGenieTable.TryGetValue(code[x], out y); + GameGenieTable.TryGetValue(t, out y); hexcode |= y; } @@ -139,9 +139,9 @@ namespace BizHawk.Client.EmuHawk private void GGCodeMaskBox_TextChanged(object sender, EventArgs e) { - if (Processing == false) + if (_processing == false) { - Processing = true; + _processing = true; //remove Invalid I O Q P if pasted GGCodeMaskBox.Text = GGCodeMaskBox.Text.Replace("I", string.Empty); GGCodeMaskBox.Text = GGCodeMaskBox.Text.Replace("O", string.Empty); @@ -164,7 +164,7 @@ namespace BizHawk.Client.EmuHawk ValueBox.Text = ""; addcheatbt.Enabled = false; } - Processing = false; + _processing = false; } } @@ -179,9 +179,9 @@ namespace BizHawk.Client.EmuHawk private void AddressBox_TextChanged(object sender, EventArgs e) { //remove invalid character when pasted - if (Processing == false) + if (_processing == false) { - Processing = true; + _processing = true; if (Regex.IsMatch(AddressBox.Text, @"[^a-fA-F0-9]")) { string temp = Regex.Replace(AddressBox.Text, @"[^a-fA-F0-9]", string.Empty); @@ -203,15 +203,15 @@ namespace BizHawk.Client.EmuHawk GGCodeMaskBox.Text = ""; addcheatbt.Enabled = false; } - Processing = false; + _processing = false; } } private void ValueBox_TextChanged(object sender, EventArgs e) { - if (Processing == false) + if (_processing == false) { - Processing = true; + _processing = true; //remove invalid character when pasted if (Regex.IsMatch(ValueBox.Text, @"[^a-fA-F0-9]")) { @@ -235,7 +235,7 @@ namespace BizHawk.Client.EmuHawk GGCodeMaskBox.Text = ""; addcheatbt.Enabled = false; } - Processing = false; + _processing = false; } } @@ -255,11 +255,11 @@ namespace BizHawk.Client.EmuHawk } else { - Processing = true; + _processing = true; GGCodeMaskBox.TextMaskFormat = MaskFormat.IncludeLiterals; NAME = GGCodeMaskBox.Text; GGCodeMaskBox.TextMaskFormat = MaskFormat.ExcludePromptAndLiterals; - Processing = false; + _processing = false; } if (!String.IsNullOrWhiteSpace(AddressBox.Text)) @@ -285,15 +285,12 @@ namespace BizHawk.Client.EmuHawk ADDRESS, Watch.WatchSize.Word, Watch.DisplayType.Hex, - NAME, - bigEndian: true + NAME, true ); Global.CheatList.Add(new Cheat( watch, - VALUE, - compare: null, - enabled: true + VALUE )); } diff --git a/BizHawk.Client.EmuHawk/tools/HexEditor/HexColor.Designer.cs b/BizHawk.Client.EmuHawk/tools/HexEditor/HexColor.Designer.cs index 63f8c73c40..ed639b1d37 100644 --- a/BizHawk.Client.EmuHawk/tools/HexEditor/HexColor.Designer.cs +++ b/BizHawk.Client.EmuHawk/tools/HexEditor/HexColor.Designer.cs @@ -1,6 +1,6 @@ namespace BizHawk.Client.EmuHawk { - partial class HexColors_Form + partial class HexColorsForm { /// /// Required designer variable. @@ -182,7 +182,7 @@ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.MaximizeBox = false; this.MinimizeBox = false; - this.Name = "HexColors_Form"; + this.Name = "HexColorsForm"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "Colors"; this.Load += new System.EventHandler(this.HexColors_Form_Load); diff --git a/BizHawk.Client.EmuHawk/tools/HexEditor/HexColor.cs b/BizHawk.Client.EmuHawk/tools/HexEditor/HexColor.cs index d81180b109..583405a594 100644 --- a/BizHawk.Client.EmuHawk/tools/HexEditor/HexColor.cs +++ b/BizHawk.Client.EmuHawk/tools/HexEditor/HexColor.cs @@ -5,9 +5,9 @@ using BizHawk.Client.Common; namespace BizHawk.Client.EmuHawk { - public partial class HexColors_Form : Form + public partial class HexColorsForm : Form { - public HexColors_Form() + public HexColorsForm() { InitializeComponent(); } diff --git a/BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.cs b/BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.cs index d548a6f52a..fa0bf17c33 100644 --- a/BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.cs +++ b/BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.cs @@ -2065,13 +2065,13 @@ namespace BizHawk.Client.EmuHawk private void setColorsToolStripMenuItem_Click(object sender, EventArgs e) { - HexColors_Form h = new HexColors_Form(); + HexColorsForm h = new HexColorsForm(); h.Show(); } private void setColorsToolStripMenuItem1_Click(object sender, EventArgs e) { - HexColors_Form h = new HexColors_Form(); + HexColorsForm h = new HexColorsForm(); GlobalWin.Sound.StopSound(); h.ShowDialog(); GlobalWin.Sound.StartSound(); diff --git a/BizHawk.Client.EmuHawk/tools/HexEditor/HexFind.cs b/BizHawk.Client.EmuHawk/tools/HexEditor/HexFind.cs index 77d8014aff..1e4683be56 100644 --- a/BizHawk.Client.EmuHawk/tools/HexEditor/HexFind.cs +++ b/BizHawk.Client.EmuHawk/tools/HexEditor/HexFind.cs @@ -9,7 +9,7 @@ namespace BizHawk.Client.EmuHawk { public partial class HexFind : Form { - private Point location; + private Point _location; public HexFind() { InitializeComponent(); @@ -22,15 +22,15 @@ namespace BizHawk.Client.EmuHawk public void SetLocation(Point p) { - location = p; + _location = p; } private void HexFind_Load(object sender, EventArgs e) { - if (location.X > 0 && location.Y > 0) + if (_location.X > 0 && _location.Y > 0) { - Location = location; + Location = _location; } } @@ -38,7 +38,7 @@ namespace BizHawk.Client.EmuHawk { if (String.IsNullOrWhiteSpace(FindBox.Text)) { - return ""; + return String.Empty; } else if (HexRadio.Checked) { @@ -46,7 +46,7 @@ namespace BizHawk.Client.EmuHawk } else { - List bytes = FindBox.Text.Select(c => Convert.ToByte(c)).ToList(); + List bytes = FindBox.Text.Select(Convert.ToByte).ToList(); StringBuilder bytestring = new StringBuilder(); foreach (byte b in bytes) diff --git a/BizHawk.Client.EmuHawk/tools/HexEditor/MemoryViewer.cs b/BizHawk.Client.EmuHawk/tools/HexEditor/MemoryViewer.cs index 8207675c90..21bc11c617 100644 --- a/BizHawk.Client.EmuHawk/tools/HexEditor/MemoryViewer.cs +++ b/BizHawk.Client.EmuHawk/tools/HexEditor/MemoryViewer.cs @@ -17,23 +17,26 @@ namespace BizHawk.Client.EmuHawk //Multi-highlight //different back color for frozen addresses - public VScrollBar vScrollBar1; - public Brush highlightBrush = Brushes.LightBlue; + public VScrollBar VScrollBar1; + public Brush HighlightBrush = Brushes.LightBlue; public bool BigEndian = false; public bool BlazingFast = false; - private string info = ""; - private MemoryDomain Domain = new MemoryDomain("NULL", 1024, MemoryDomain.Endian.Little, addr => 0, (a, v) => { v = 0; }); - private readonly Font font = new Font("Courier New", 8); - private int _rows_visible; - private int _data_size = 1; - private string _header = ""; - private int _num_digits = 4; - private readonly char[] nibbles = { 'G', 'G', 'G', 'G' }; //G = off 0-9 & A-F are acceptable values - private int addressHighlighted = -1; - private int addressOver = -1; - private int addrOffset; //If addresses are > 4 digits, this offset is how much the columns are moved to the right - private int maxRow; + private string _info = String.Empty; + private MemoryDomain _domain = new MemoryDomain("NULL", 1024, MemoryDomain.Endian.Little, addr => 0, + delegate(int a, byte v) { v = 0; }); + private readonly Font _font = new Font("Courier New", 8); + private int _rowsVisible; + private int _dataSize = 1; + private string _header = String.Empty; + private int _numDigits = 4; + private readonly char[] _nibbles = { 'G', 'G', 'G', 'G' }; //G = off 0-9 & A-F are acceptable values + private int _addressHighlighted = -1; + private int _addressOver = -1; + private int _addrOffset; //If addresses are > 4 digits, this offset is how much the columns are moved to the right + private int _maxRow; + private int _row; + private int _addr; private const int ROWX = 1; private const int ROWY = 4; @@ -46,19 +49,19 @@ namespace BizHawk.Client.EmuHawk BorderStyle = BorderStyle.Fixed3D; MouseMove += MemoryViewer_MouseMove; MouseClick += MemoryViewer_MouseClick; - vScrollBar1 = new VScrollBar(); + VScrollBar1 = new VScrollBar(); Point n = new Point(Size); - vScrollBar1.Location = new Point(n.X - 16, n.Y - Height + 7); - vScrollBar1.Height = Height - 8; - vScrollBar1.Width = 16; - vScrollBar1.Visible = true; - vScrollBar1.Anchor = (AnchorStyles.Top | AnchorStyles.Bottom) + VScrollBar1.Location = new Point(n.X - 16, n.Y - Height + 7); + VScrollBar1.Height = Height - 8; + VScrollBar1.Width = 16; + VScrollBar1.Visible = true; + VScrollBar1.Anchor = (AnchorStyles.Top | AnchorStyles.Bottom) | AnchorStyles.Right; - vScrollBar1.LargeChange = 16; - vScrollBar1.Name = "vScrollBar1"; - vScrollBar1.TabIndex = 0; - vScrollBar1.Scroll += vScrollBar1_Scroll; - Controls.Add(vScrollBar1); + VScrollBar1.LargeChange = 16; + VScrollBar1.Name = "vScrollBar1"; + VScrollBar1.TabIndex = 0; + VScrollBar1.Scroll += vScrollBar1_Scroll; + Controls.Add(VScrollBar1); SetHeader(); } @@ -67,38 +70,38 @@ namespace BizHawk.Client.EmuHawk { if (keyData == Keys.Up) { - GoToAddress(addressHighlighted - 16); + GoToAddress(_addressHighlighted - 16); } else if (keyData == Keys.Down) { - GoToAddress(addressHighlighted + 16); + GoToAddress(_addressHighlighted + 16); } else if (keyData == Keys.Left) { - GoToAddress(addressHighlighted - 1); + GoToAddress(_addressHighlighted - 1); } else if (keyData == Keys.Right) { - GoToAddress(addressHighlighted + 1); + GoToAddress(_addressHighlighted + 1); } else if (keyData == Keys.Tab) { - addressHighlighted += 8; + _addressHighlighted += 8; Refresh(); } else if (keyData == Keys.PageDown) { - GoToAddress(addressHighlighted + (_rows_visible * 16)); + GoToAddress(_addressHighlighted + (_rowsVisible * 16)); } else if (keyData == Keys.PageUp) { - GoToAddress(addressHighlighted - (_rows_visible * 16)); + GoToAddress(_addressHighlighted - (_rowsVisible * 16)); } else if (keyData == Keys.Home) @@ -117,7 +120,7 @@ namespace BizHawk.Client.EmuHawk private void ClearNibbles() { for (int x = 0; x < 4; x++) - nibbles[x] = 'G'; + _nibbles[x] = 'G'; } protected override void OnKeyUp(KeyEventArgs e) @@ -131,18 +134,18 @@ namespace BizHawk.Client.EmuHawk } //TODO: 2 byte & 4 byte - if (nibbles[0] == 'G') + if (_nibbles[0] == 'G') { - nibbles[0] = (char)e.KeyCode; - info = nibbles[0].ToString(); + _nibbles[0] = (char)e.KeyCode; + _info = _nibbles[0].ToString(); } else { - string temp = nibbles[0].ToString() + ((char)e.KeyCode).ToString(); + string temp = _nibbles[0].ToString() + ((char)e.KeyCode).ToString(); int x = int.Parse(temp, NumberStyles.HexNumber); - Domain.PokeByte(addressHighlighted, (byte)x); + _domain.PokeByte(_addressHighlighted, (byte)x); ClearNibbles(); - SetHighlighted(addressHighlighted + 1); + SetHighlighted(_addressHighlighted + 1); Refresh(); } @@ -153,103 +156,100 @@ namespace BizHawk.Client.EmuHawk { if (address < 0) address = 0; - if (address >= Domain.Size) - address = Domain.Size - 1; + if (address >= _domain.Size) + address = _domain.Size - 1; if (!IsVisible(address)) { - int v = (address / 16) - _rows_visible + 1; + int v = (address / 16) - _rowsVisible + 1; if (v < 0) v = 0; - vScrollBar1.Value = v; + VScrollBar1.Value = v; } - addressHighlighted = address; - addressOver = address; - info = String.Format("{0:X4}", addressOver); + _addressHighlighted = address; + _addressOver = address; + _info = String.Format("{0:X4}", _addressOver); Refresh(); } - int row; - int addr; - protected override void OnPaint(PaintEventArgs e) { unchecked { - row = 0; - addr = 0; + _row = 0; + _addr = 0; StringBuilder rowStr = new StringBuilder(""); - addrOffset = (_num_digits % 4) * 9; + _addrOffset = (_numDigits % 4) * 9; - if (addressHighlighted >= 0 && IsVisible(addressHighlighted)) + if (_addressHighlighted >= 0 && IsVisible(_addressHighlighted)) { - int left = ((addressHighlighted % 16) * 20) + 52 + addrOffset - (addressHighlighted % 4); - int top = (((addressHighlighted / 16) - vScrollBar1.Value) * (font.Height - 1)) + 36; + int left = ((_addressHighlighted % 16) * 20) + 52 + _addrOffset - (_addressHighlighted % 4); + int top = (((_addressHighlighted / 16) - VScrollBar1.Value) * (_font.Height - 1)) + 36; Rectangle rect = new Rectangle(left, top, 16, 14); - e.Graphics.DrawRectangle(new Pen(highlightBrush), rect); - e.Graphics.FillRectangle(highlightBrush, rect); + e.Graphics.DrawRectangle(new Pen(HighlightBrush), rect); + e.Graphics.FillRectangle(HighlightBrush, rect); } - rowStr.Append(Domain.Name + " " + info + '\n'); + rowStr.Append(_domain.Name + " " + _info + '\n'); rowStr.Append(_header + '\n'); - for (int i = 0; i < _rows_visible; i++) + for (int i = 0; i < _rowsVisible; i++) { - row = i + vScrollBar1.Value; - if (row * 16 >= Domain.Size) + _row = i + VScrollBar1.Value; + if (_row * 16 >= _domain.Size) break; - rowStr.AppendFormat("{0:X" + _num_digits + "} ", row * 16); - switch (_data_size) + rowStr.AppendFormat("{0:X" + _numDigits + "} ", _row * 16); + switch (_dataSize) { default: case 1: - addr = (row * 16); + _addr = (_row * 16); for (int j = 0; j < 16; j++) { - if (addr + j < Domain.Size) - rowStr.AppendFormat("{0:X2} ", Domain.PeekByte(addr + j)); + if (_addr + j < _domain.Size) + rowStr.AppendFormat("{0:X2} ", _domain.PeekByte(_addr + j)); } rowStr.Append(" | "); for (int k = 0; k < 16; k++) { - rowStr.Append(Remap(Domain.PeekByte(addr + k))); + rowStr.Append(Remap(_domain.PeekByte(_addr + k))); } rowStr.AppendLine(); break; case 2: - addr = (row * 16); + _addr = (_row * 16); for (int j = 0; j < 16; j += 2) { - if (addr + j < Domain.Size) - rowStr.AppendFormat("{0:X4} ", MakeValue(addr + j, _data_size, BigEndian)); + if (_addr + j < _domain.Size) + rowStr.AppendFormat("{0:X4} ", MakeValue(_addr + j, _dataSize, BigEndian)); } rowStr.AppendLine(); rowStr.Append(" | "); for (int k = 0; k < 16; k++) { - rowStr.Append(Remap(Domain.PeekByte(addr + k))); + rowStr.Append(Remap(_domain.PeekByte(_addr + k))); } break; case 4: - addr = (row * 16); + _addr = (_row * 16); for (int j = 0; j < 16; j += 4) { - if (addr < Domain.Size) - rowStr.AppendFormat("{0:X8} ", MakeValue(addr + j, _data_size, BigEndian)); + if (_addr < _domain.Size) + rowStr.AppendFormat("{0:X8} ", MakeValue(_addr + j, _dataSize, BigEndian)); } rowStr.AppendLine(); rowStr.Append(" | "); for (int k = 0; k < 16; k++) { - rowStr.Append(Remap(Domain.PeekByte(addr + k))); + rowStr.Append(Remap(_domain.PeekByte(_addr + k))); } break; } } - e.Graphics.DrawString(rowStr.ToString(), font, Brushes.Black, new Point(ROWX, ROWY)); + e.Graphics.DrawString(rowStr.ToString(), _font, Brushes.Black, new Point(ROWX, ROWY)); } } @@ -263,85 +263,72 @@ namespace BizHawk.Client.EmuHawk } } - private int MakeValue(int address, int size, bool Bigendian) + private int MakeValue(int address, int size, bool bigendian) { - unchecked + int x = 0; + if (size == 1 || size == 2 || size == 4) { - int x = 0; - if (size == 1 || size == 2 || size == 4) + switch (size) { - switch (size) - { - case 1: - x = Domain.PeekByte(address); - break; - case 2: - x = MakeWord(address, Bigendian); - break; - case 4: - x = (MakeWord(address, Bigendian) * 65536) + - MakeWord(address + 2, Bigendian); - break; - } - return x; + case 1: + x = _domain.PeekByte(address); + break; + case 2: + x = _domain.PeekWord(address, bigendian); + break; + case 4: + x = (int) _domain.PeekDWord(address, bigendian); + break; } - else - return 0; //fail + return x; } - } - - private int MakeWord(int address, bool endian) - { - unchecked + else { - if (endian) - { - return Domain.PeekByte(address) + (Domain.PeekByte(address + 1)*255); - } - else - { - return (Domain.PeekByte(address)*255) + Domain.PeekByte(address + 1); - } + return 0; //fail } } public void ResetScrollBar() { - vScrollBar1.Value = 0; + VScrollBar1.Value = 0; SetUpScrollBar(); Refresh(); } public void SetUpScrollBar() { - _rows_visible = ((Height - 8) / 13) - 1; - int totalRows = Domain.Size / 16; - int MaxRows = (totalRows - _rows_visible) + 16; + _rowsVisible = ((Height - 8) / 13) - 1; + int totalRows = _domain.Size / 16; + int MaxRows = (totalRows - _rowsVisible) + 16; if (MaxRows > 0) { - vScrollBar1.Visible = true; - if (vScrollBar1.Value > MaxRows) - vScrollBar1.Value = MaxRows; - vScrollBar1.Maximum = MaxRows; + VScrollBar1.Visible = true; + if (VScrollBar1.Value > MaxRows) + { + VScrollBar1.Value = MaxRows; + } + VScrollBar1.Maximum = MaxRows; } else - vScrollBar1.Visible = false; + { + VScrollBar1.Visible = false; + } } public void SetMemoryDomain(MemoryDomain d) { - Domain = d; - maxRow = Domain.Size / 2; + _domain = d; + _maxRow = _domain.Size / 2; SetUpScrollBar(); - vScrollBar1.Value = 0; + VScrollBar1.Value = 0; Refresh(); } - public string GetMemoryDomainStr() + public string DomainName() { - return Domain.ToString(); + return _domain.ToString(); } private void vScrollBar1_Scroll(object sender, ScrollEventArgs e) @@ -353,14 +340,14 @@ namespace BizHawk.Client.EmuHawk public void SetDataSize(int size) { if (size == 1 || size == 2 || size == 4) - _data_size = size; + _dataSize = size; SetHeader(); } private void SetHeader() { - switch (_data_size) + switch (_dataSize) { case 1: _header = " 0 1 2 3 4 5 6 7 8 9 A B C D E F"; @@ -372,12 +359,12 @@ namespace BizHawk.Client.EmuHawk _header = " 0 4 8 C"; break; } - _num_digits = GetNumDigits(Domain.Size); + _numDigits = GetNumDigits(_domain.Size); } public int GetDataSize() { - return _data_size; + return _dataSize; } private int GetNumDigits(Int32 i) @@ -393,21 +380,21 @@ namespace BizHawk.Client.EmuHawk private void SetAddressOver(int x, int y) { //Scroll value determines the first row - int i = vScrollBar1.Value; - i += (y - 36) / (font.Height - 1); - int column = (x - (49 + addrOffset)) / 20; + int i = VScrollBar1.Value; + i += (y - 36) / (_font.Height - 1); + int column = (x - (49 + _addrOffset)) / 20; //TODO: 2 & 4 byte views - if (i >= 0 && i <= maxRow && column >= 0 && column < 16) + if (i >= 0 && i <= _maxRow && column >= 0 && column < 16) { - addressOver = i * 16 + column; - info = String.Format("{0:X4}", addressOver); + _addressOver = i * 16 + column; + _info = String.Format("{0:X4}", _addressOver); } else { - addressOver = -1; - info = ""; + _addressOver = -1; + _info = String.Empty; } } @@ -418,12 +405,12 @@ namespace BizHawk.Client.EmuHawk public void HighlightPointed() { - if (addressOver >= 0) + if (_addressOver >= 0) { - addressHighlighted = addressOver; + _addressHighlighted = _addressOver; } else - addressHighlighted = -1; + _addressHighlighted = -1; ClearNibbles(); Focus(); Refresh(); @@ -432,9 +419,9 @@ namespace BizHawk.Client.EmuHawk private void MemoryViewer_MouseClick(object sender, MouseEventArgs e) { SetAddressOver(e.X, e.Y); - if (addressOver == addressHighlighted && addressOver >= 0) + if (_addressOver == _addressHighlighted && _addressOver >= 0) { - addressHighlighted = -1; + _addressHighlighted = -1; Refresh(); } else @@ -445,17 +432,21 @@ namespace BizHawk.Client.EmuHawk public int GetPointedAddress() { - if (addressOver >= 0) - return addressOver; + if (_addressOver >= 0) + { + return _addressOver; + } else + { return -1; //Negative = no address pointed + } } public int GetHighlightedAddress() { - if (addressHighlighted >= 0) + if (_addressHighlighted >= 0) { - return addressHighlighted; + return _addressHighlighted; } else { @@ -469,7 +460,7 @@ namespace BizHawk.Client.EmuHawk { int i = address >> 4; - if (i >= vScrollBar1.Value && i < (_rows_visible + vScrollBar1.Value)) + if (i >= VScrollBar1.Value && i < (_rowsVisible + VScrollBar1.Value)) { return true; } @@ -483,23 +474,23 @@ namespace BizHawk.Client.EmuHawk public void PokeHighlighted(int value) { //TODO: 2 byte & 4 byte - if (addressHighlighted >= 0) - Domain.PokeByte(addressHighlighted, (byte)value); + if (_addressHighlighted >= 0) + _domain.PokeByte(_addressHighlighted, (byte)value); } public int GetSize() { - return Domain.Size; + return _domain.Size; } public byte GetPointedValue() { - return Domain.PeekByte(addressOver); + return _domain.PeekByte(_addressOver); } public MemoryDomain GetDomain() { - return Domain; + return _domain; } public void GoToAddress(int address) diff --git a/BizHawk.Client.EmuHawk/tools/PCE/PCEBGCanvas.cs b/BizHawk.Client.EmuHawk/tools/PCE/PCEBGCanvas.cs index d9f73b2826..1ef8cca1e9 100644 --- a/BizHawk.Client.EmuHawk/tools/PCE/PCEBGCanvas.cs +++ b/BizHawk.Client.EmuHawk/tools/PCE/PCEBGCanvas.cs @@ -4,28 +4,26 @@ using System.Drawing.Imaging; namespace BizHawk.Client.EmuHawk { - public partial class PCEBGCanvas : Control + public class PCEBGCanvas : Control { - public Bitmap bat; + public Bitmap Bat; private const int BAT_WIDTH = 1024; - private const int BAT_HEIGHT = 512; + private const int BAT_HEIGHT = 512; public PCEBGCanvas() { - bat = new Bitmap(BAT_WIDTH, BAT_HEIGHT, PixelFormat.Format32bppArgb); + Bat = new Bitmap(BAT_WIDTH, BAT_HEIGHT, PixelFormat.Format32bppArgb); SetStyle(ControlStyles.AllPaintingInWmPaint, true); SetStyle(ControlStyles.UserPaint, true); SetStyle(ControlStyles.DoubleBuffer, true); - //SetStyle(ControlStyles.SupportsTransparentBackColor, true); Size = new Size(BAT_WIDTH, BAT_HEIGHT); - //this.BackColor = Color.Transparent; Paint += BGViewer_Paint; } private void BGViewer_Paint(object sender, PaintEventArgs e) { - e.Graphics.DrawImageUnscaled(bat, 0, 0); + e.Graphics.DrawImageUnscaled(Bat, 0, 0); } } } diff --git a/BizHawk.Client.EmuHawk/tools/PCE/PCEBGViewer.cs b/BizHawk.Client.EmuHawk/tools/PCE/PCEBGViewer.cs index 730b199851..fc25aba914 100644 --- a/BizHawk.Client.EmuHawk/tools/PCE/PCEBGViewer.cs +++ b/BizHawk.Client.EmuHawk/tools/PCE/PCEBGViewer.cs @@ -10,7 +10,7 @@ namespace BizHawk.Client.EmuHawk { public partial class PCEBGViewer : Form, IToolForm { - private PCEngine pce; + private PCEngine _pce; private int VDCtype; public bool AskSave() { return true; } @@ -27,11 +27,11 @@ namespace BizHawk.Client.EmuHawk { if (Global.Emulator.Frame % RefreshRate.Value != 0) return; - VDC vdc = VDCtype == 0 ? pce.VDC1 : pce.VDC2; + VDC vdc = VDCtype == 0 ? _pce.VDC1 : _pce.VDC2; int width = 8 * vdc.BatWidth; int height = 8 * vdc.BatHeight; - BitmapData buf = canvas.bat.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.WriteOnly, canvas.bat.PixelFormat); + BitmapData buf = canvas.Bat.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.WriteOnly, canvas.Bat.PixelFormat); int pitch = buf.Stride / 4; int* begin = (int*)buf.Scan0.ToPointer(); @@ -54,16 +54,16 @@ namespace BizHawk.Client.EmuHawk byte c = vdc.PatternBuffer[(tileNo * 64) + (yOfs * 8) + xOfs]; if (c == 0) - *p = pce.VCE.Palette[0]; + *p = _pce.VCE.Palette[0]; else { - *p = pce.VCE.Palette[paletteBase + c]; + *p = _pce.VCE.Palette[paletteBase + c]; } } p += pitch - width; } - canvas.bat.UnlockBits(buf); + canvas.Bat.UnlockBits(buf); canvas.Refresh(); } @@ -71,7 +71,7 @@ namespace BizHawk.Client.EmuHawk { if (Global.Emulator is PCEngine) { - pce = Global.Emulator as PCEngine; + _pce = Global.Emulator as PCEngine; } else { @@ -106,7 +106,7 @@ namespace BizHawk.Client.EmuHawk private void PCEBGViewer_Load(object sender, EventArgs e) { - pce = Global.Emulator as PCEngine; + _pce = Global.Emulator as PCEngine; LoadConfigSettings(); if (Global.Config.PCEBGViewerRefreshRate >= RefreshRate.Minimum && Global.Config.PCEBGViewerRefreshRate <= RefreshRate.Maximum) { @@ -151,7 +151,7 @@ namespace BizHawk.Client.EmuHawk private void fileToolStripMenuItem_DropDownOpened(object sender, EventArgs e) { - if (pce.SystemId == "SGX") + if (_pce.SystemId == "SGX") vCD2ToolStripMenuItem.Enabled = true; else vCD2ToolStripMenuItem.Enabled = false; @@ -172,7 +172,7 @@ namespace BizHawk.Client.EmuHawk private void canvas_MouseMove(object sender, MouseEventArgs e) { - VDC vdc = VDCtype == 0 ? pce.VDC1 : pce.VDC2; + VDC vdc = VDCtype == 0 ? _pce.VDC1 : _pce.VDC2; int xTile = e.X / 8; int yTile = e.Y / 8; int tileNo = vdc.VRAM[(ushort)(((yTile * vdc.BatWidth) + xTile))] & 0x07FF;