Added window scaling
This commit is contained in:
@@ -1303,6 +1303,35 @@ namespace Core.Cpu
|
|||||||
|
|
||||||
switch (extendedOpcode)
|
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
|
case 0x41: // OUT (C), B
|
||||||
_simpleIoBus.WritePort(BC.Word, BC.High);
|
_simpleIoBus.WritePort(BC.Word, BC.High);
|
||||||
return 12;
|
return 12;
|
||||||
|
|||||||
@@ -15,6 +15,14 @@
|
|||||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||||
<StartupObject>Desktop.Program</StartupObject>
|
<StartupObject>Desktop.Program</StartupObject>
|
||||||
<AssemblyName>Parsons Master System</AssemblyName>
|
<AssemblyName>Parsons Master System</AssemblyName>
|
||||||
|
<ApplicationIcon>favicon.ico</ApplicationIcon>
|
||||||
|
<Title>Sega Master System EMulator 2026</Title>
|
||||||
|
<Version>0.9</Version>
|
||||||
|
<Authors>Marc Parsons</Authors>
|
||||||
|
<Company>Parsons Limited</Company>
|
||||||
|
<Description>Parsons Master System 2026</Description>
|
||||||
|
<Copyright>Copyright 2026 Marc Parsons</Copyright>
|
||||||
|
<PackageIcon>logo1.bmp</PackageIcon>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@@ -103,6 +111,10 @@
|
|||||||
<None Remove="ROMS\zexdoc.sms" />
|
<None Remove="ROMS\zexdoc.sms" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="favicon.ico" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<EmbeddedResource Include="ROMS\After Burner (UE) [!].sms">
|
<EmbeddedResource Include="ROMS\After Burner (UE) [!].sms">
|
||||||
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
|
||||||
@@ -353,6 +365,13 @@
|
|||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="..\logo1.bmp">
|
||||||
|
<Pack>True</Pack>
|
||||||
|
<PackagePath>\</PackagePath>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="NAudio" Version="2.3.0" />
|
<PackageReference Include="NAudio" Version="2.3.0" />
|
||||||
<PackageReference Include="Vortice.XInput" Version="3.8.3" />
|
<PackageReference Include="Vortice.XInput" Version="3.8.3" />
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ namespace Desktop
|
|||||||
|
|
||||||
this.Text = $"Parsons Master System - {_currentRomName}";
|
this.Text = $"Parsons Master System - {_currentRomName}";
|
||||||
|
|
||||||
// Safe to initialize hardware and files here!
|
this.BackColor = Color.Black;
|
||||||
_machine = new SmsMachine();
|
_machine = new SmsMachine();
|
||||||
_audioPlayer = new NAudioPlayer();
|
_audioPlayer = new NAudioPlayer();
|
||||||
_machine.AudioProcessor.AudioDevice = _audioPlayer;
|
_machine.AudioProcessor.AudioDevice = _audioPlayer;
|
||||||
@@ -72,27 +72,37 @@ namespace Desktop
|
|||||||
}
|
}
|
||||||
protected override void OnPaint(PaintEventArgs e)
|
protected override void OnPaint(PaintEventArgs e)
|
||||||
{
|
{
|
||||||
// Always call the base method so Windows can draw your MenuStrip!
|
|
||||||
base.OnPaint(e);
|
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)
|
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.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
|
||||||
e.Graphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.Half;
|
e.Graphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.Half;
|
||||||
|
|
||||||
// 2. Calculate the drawing area.
|
// 2. Calculate the actual usable window space
|
||||||
// We start drawing BELOW the MenuStrip so it doesn't get covered up.
|
|
||||||
int topOffset = menuStrip1.Height;
|
int topOffset = menuStrip1.Height;
|
||||||
Rectangle renderArea = new Rectangle(
|
int availableWidth = this.ClientSize.Width;
|
||||||
0,
|
int availableHeight = this.ClientSize.Height - topOffset;
|
||||||
topOffset,
|
|
||||||
this.ClientSize.Width,
|
|
||||||
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);
|
e.Graphics.DrawImage(_screenBitmap, renderArea);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
Desktop/favicon.ico
Normal file
BIN
Desktop/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.3 KiB |
BIN
favicon.ico
Normal file
BIN
favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.3 KiB |
Reference in New Issue
Block a user