From 4b72a05b5177bd34b5648cf9c8091afb6fd9c517 Mon Sep 17 00:00:00 2001 From: Alexandre Rocha Lima e Marcondes Date: Mon, 25 Feb 2019 10:57:29 +0100 Subject: [PATCH] Code analysis fixes --- Chip8.Sharp/Chip8.Tests/Test.cs | 14 +++++--------- Chip8.Sharp/Chip8.WindowsForms/MainForm.cs | 8 ++++---- .../PictureBoxWithInterpolationMode.cs | 8 ++++---- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/Chip8.Sharp/Chip8.Tests/Test.cs b/Chip8.Sharp/Chip8.Tests/Test.cs index 2aaa6be..104b8fb 100644 --- a/Chip8.Sharp/Chip8.Tests/Test.cs +++ b/Chip8.Sharp/Chip8.Tests/Test.cs @@ -2790,7 +2790,7 @@ public void Opcode_RND_Vx_byte() break; } - emptyMemory[testAddress] = unchecked((byte)(0xC0 | (0x00 & 0x0F))); + emptyMemory[testAddress] = 0xC0 | (0x00 & 0x0F); emptyMemory[testAddress + 1] = unchecked((byte)value); } @@ -3490,10 +3490,8 @@ private void Test_SKP_Vx(byte[] emptyMemory, int testAddress) Assert.Throws(cpu.EmulateCycle); continue; } - else - { - cpu.EmulateCycle(); - } + + cpu.EmulateCycle(); Assert.AreEqual(opcode, cpu.Opcode, $"Opcode shoud be 0x{opcode.ToString("X4", NumberFormatInfo.CurrentInfo)} - SKNP V{registerX.ToString("X1", NumberFormatInfo.CurrentInfo)}"); @@ -3571,10 +3569,8 @@ private void Test_SKNP_Vx(byte[] emptyMemory, int testAddress) Assert.Throws(cpu.EmulateCycle); continue; } - else - { - cpu.EmulateCycle(); - } + + cpu.EmulateCycle(); Assert.AreEqual(opcode, cpu.Opcode, $"Opcode shoud be 0x{opcode.ToString("X4", NumberFormatInfo.CurrentInfo)} - SKNP V{registerX.ToString("X1", NumberFormatInfo.CurrentInfo)}"); diff --git a/Chip8.Sharp/Chip8.WindowsForms/MainForm.cs b/Chip8.Sharp/Chip8.WindowsForms/MainForm.cs index 7390e87..24c65dc 100644 --- a/Chip8.Sharp/Chip8.WindowsForms/MainForm.cs +++ b/Chip8.Sharp/Chip8.WindowsForms/MainForm.cs @@ -20,10 +20,10 @@ public partial class MainForm : Form private readonly Bitmap screenImage; private readonly ICPU myChip8; - private bool quit = false; - private bool pause = false; - private bool debugKeys = false; - private bool debugPixels = false; + private bool quit; + private bool pause; + private bool debugKeys; + private bool debugPixels; private float zoom = 9.5f; // For timing.. diff --git a/Chip8.Sharp/Chip8.WindowsForms/PictureBoxWithInterpolationMode.cs b/Chip8.Sharp/Chip8.WindowsForms/PictureBoxWithInterpolationMode.cs index 2693603..df74550 100644 --- a/Chip8.Sharp/Chip8.WindowsForms/PictureBoxWithInterpolationMode.cs +++ b/Chip8.Sharp/Chip8.WindowsForms/PictureBoxWithInterpolationMode.cs @@ -8,11 +8,11 @@ class PictureBoxWithInterpolationMode : PictureBox // http://stackoverflow.com/a/13484101/25124 public InterpolationMode InterpolationMode { get; set; } - protected override void OnPaint(PaintEventArgs paintEventArgs) + protected override void OnPaint(PaintEventArgs pe) { - paintEventArgs.Graphics.PixelOffsetMode = PixelOffsetMode.Half; - paintEventArgs.Graphics.InterpolationMode = InterpolationMode; - base.OnPaint(paintEventArgs); + pe.Graphics.PixelOffsetMode = PixelOffsetMode.Half; + pe.Graphics.InterpolationMode = InterpolationMode; + base.OnPaint(pe); } } }