diff --git a/Core/Cpu/Z80.cs b/Core/Cpu/Z80.cs index 3f10abc..36e1489 100644 --- a/Core/Cpu/Z80.cs +++ b/Core/Cpu/Z80.cs @@ -1303,6 +1303,35 @@ namespace Core.Cpu switch (extendedOpcode) { + case 0x40: // IN B, (C) + { + byte inVal40 = ReadPort(BC.Word); + BC.High = inVal40; + + byte flags40 = (byte)(AF.Low & 0x01); // Preserve Carry + if ((inVal40 & 0x80) != 0) flags40 |= 0x80; // S + if (inVal40 == 0) flags40 |= 0x40; // Z + flags40 |= ParityTable[inVal40]; // P/V + flags40 |= (byte)(inVal40 & 0x28); // Undocumented bits 3 and 5 + + AF.Low = flags40; + return 12; + } + + case 0x50: // IN D, (C) + { + byte inVal50 = ReadPort(BC.Word); + DE.High = inVal50; + + byte flags50 = (byte)(AF.Low & 0x01); // Preserve Carry + if ((inVal50 & 0x80) != 0) flags50 |= 0x80; // S + if (inVal50 == 0) flags50 |= 0x40; // Z + flags50 |= ParityTable[inVal50]; // P/V + flags50 |= (byte)(inVal50 & 0x28); // Undocumented bits 3 and 5 + + AF.Low = flags50; + return 12; + } case 0x41: // OUT (C), B _simpleIoBus.WritePort(BC.Word, BC.High); return 12; diff --git a/Desktop/Desktop.csproj b/Desktop/Desktop.csproj index e5cba67..827aa73 100644 --- a/Desktop/Desktop.csproj +++ b/Desktop/Desktop.csproj @@ -15,6 +15,14 @@ win-x64 Desktop.Program Parsons Master System + favicon.ico + Sega Master System EMulator 2026 + 0.9 + Marc Parsons + Parsons Limited + Parsons Master System 2026 + Copyright 2026 Marc Parsons + logo1.bmp @@ -103,6 +111,10 @@ + + + + Never @@ -353,6 +365,13 @@ + + + True + \ + + + diff --git a/Desktop/Form1.cs b/Desktop/Form1.cs index 198dbcc..7a2aae1 100644 --- a/Desktop/Form1.cs +++ b/Desktop/Form1.cs @@ -53,7 +53,7 @@ namespace Desktop this.Text = $"Parsons Master System - {_currentRomName}"; - // Safe to initialize hardware and files here! + this.BackColor = Color.Black; _machine = new SmsMachine(); _audioPlayer = new NAudioPlayer(); _machine.AudioProcessor.AudioDevice = _audioPlayer; @@ -72,27 +72,37 @@ namespace Desktop } protected override void OnPaint(PaintEventArgs e) { - // Always call the base method so Windows can draw your MenuStrip! base.OnPaint(e); - // THE FIX: We MUST ensure the designer has actually built the menu strip before asking for its height! if (_screenBitmap != null && menuStrip1 != null) { - // 1. Set the rendering mode for perfect, chunky retro pixels! + // 1. Maintain 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. + // 2. Calculate the actual usable window space int topOffset = menuStrip1.Height; - Rectangle renderArea = new Rectangle( - 0, - topOffset, - this.ClientSize.Width, - this.ClientSize.Height - topOffset - ); + int availableWidth = this.ClientSize.Width; + int availableHeight = this.ClientSize.Height - topOffset; - // 3. Blast the bitmap directly onto the graphics card buffer! + // 3. Calculate the maximum scale factor that fits perfectly + float scaleX = (float)availableWidth / 256f; + float scaleY = (float)availableHeight / 192f; + + // Pick the smaller scale so the image never bleeds off the edge + float scale = Math.Min(scaleX, scaleY); + + // 4. Calculate the new physical pixel dimensions + int newWidth = (int)(256 * scale); + int newHeight = (int)(192 * scale); + + // 5. Center the image (Letterboxing / Pillarboxing) + int offsetX = (availableWidth - newWidth) / 2; + int offsetY = topOffset + ((availableHeight - newHeight) / 2); + + Rectangle renderArea = new Rectangle(offsetX, offsetY, newWidth, newHeight); + + // 6. Draw the scaled image e.Graphics.DrawImage(_screenBitmap, renderArea); } } diff --git a/Desktop/favicon.ico b/Desktop/favicon.ico new file mode 100644 index 0000000..97d0b86 Binary files /dev/null and b/Desktop/favicon.ico differ diff --git a/favicon.ico b/favicon.ico new file mode 100644 index 0000000..97d0b86 Binary files /dev/null and b/favicon.ico differ diff --git a/logo1.bmp b/logo1.bmp new file mode 100644 index 0000000..ee3dca7 Binary files /dev/null and b/logo1.bmp differ