Pissed about trying to fix a number of bugs

This commit is contained in:
2026-05-12 01:34:05 +01:00
parent 95ac0ec7c1
commit edb41bdb3a
8 changed files with 75 additions and 20 deletions

View File

@@ -40,6 +40,8 @@ namespace Desktop
this.KeyPreview = true;
this.KeyDown += Form1_KeyDown;
this.KeyUp += Form1_KeyUp;
this.DoubleBuffered = true;
this.ResizeRedraw = true;
}
private void DrawScreen()
@@ -48,11 +50,34 @@ namespace Desktop
var data = _screenBitmap.LockBits(new Rectangle(0, 0, 256, 192), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
Marshal.Copy(_machine.VideoProcessor.FrameBuffer, 0, data.Scan0, _machine.VideoProcessor.FrameBuffer.Length);
_screenBitmap.UnlockBits(data);
// Update the PictureBox
pbScreen.Image = _screenBitmap;
this.Invalidate();
TotalFrameCount++;
}
protected override void OnPaint(PaintEventArgs e)
{
// Always call the base method so Windows can draw your MenuStrip!
base.OnPaint(e);
if (_screenBitmap != null)
{
// 1. Set the rendering mode for perfect, chunky retro pixels!
e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
e.Graphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.Half;
// 2. Calculate the drawing area.
// We start drawing BELOW the MenuStrip so it doesn't get covered up.
int topOffset = menuStrip1.Height; // Change 'menuStrip1' if your menu has a different (Name)
Rectangle renderArea = new Rectangle(
0,
topOffset,
this.ClientSize.Width,
this.ClientSize.Height - topOffset
);
// 3. Blast the bitmap directly onto the graphics card buffer!
e.Graphics.DrawImage(_screenBitmap, renderArea);
}
}
public void StartEmulator()
{