diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ULABase.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ULABase.cs
index 9bdab42b2f..657a255adf 100644
--- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ULABase.cs
+++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ULABase.cs
@@ -325,6 +325,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
public ULABase(SpectrumBase machine)
{
_machine = machine;
+ borderType = _machine.Spectrum.SyncSettings.BorderType;
}
#endregion
@@ -554,9 +555,158 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
public int[] GetVideoBuffer()
{
+ switch (borderType)
+ {
+ // Full side borders, no top or bottom border (giving *almost* 16:9 output)
+ case ZXSpectrum.BorderType.Widescreen:
+ // we are cropping out the top and bottom borders
+ var startPixelsToCrop = ScanLineWidth * BorderTopHeight;
+ var endPixelsToCrop = ScanLineWidth * BorderBottomHeight;
+ int index = 0;
+ for (int i = startPixelsToCrop; i < ScreenBuffer.Length - endPixelsToCrop; i++)
+ {
+ croppedBuffer[index++] = ScreenBuffer[i];
+ }
+ return croppedBuffer;
+
+ // The full spectrum border
+ case ZXSpectrum.BorderType.Full:
+ return ScreenBuffer;
+
+ case ZXSpectrum.BorderType.Medium:
+ // all border sizes now 24
+ var lR = BorderLeftWidth - 24;
+ var rR = BorderRightWidth - 24;
+ var tR = BorderTopHeight - 24;
+ var bR = BorderBottomHeight - 24;
+ var startP = ScanLineWidth * tR;
+ var endP = ScanLineWidth * bR;
+
+ int index2 = 0;
+ // line by line
+ for (int i = startP; i < ScreenBuffer.Length - endP; i += ScreenWidth + BorderLeftWidth + BorderRightWidth)
+ {
+ // each pixel in each line
+ for (int p = lR; p < ScreenWidth + BorderLeftWidth + BorderRightWidth - rR; p++)
+ {
+ if (index2 == croppedBuffer.Length)
+ break;
+ croppedBuffer[index2++] = ScreenBuffer[i + p];
+ }
+ }
+
+ return croppedBuffer;
+
+ case ZXSpectrum.BorderType.Small:
+ // all border sizes now 24
+ var lR_ = BorderLeftWidth - 10;
+ var rR_ = BorderRightWidth - 10;
+ var tR_ = BorderTopHeight - 10;
+ var bR_ = BorderBottomHeight - 10;
+ var startP_ = ScanLineWidth * tR_;
+ var endP_ = ScanLineWidth * bR_;
+
+ int index2_ = 0;
+ // line by line
+ for (int i = startP_; i < ScreenBuffer.Length - endP_; i += ScreenWidth + BorderLeftWidth + BorderRightWidth)
+ {
+ // each pixel in each line
+ for (int p = lR_; p < ScreenWidth + BorderLeftWidth + BorderRightWidth - rR_; p++)
+ {
+ if (index2_ == croppedBuffer.Length)
+ break;
+ croppedBuffer[index2_++] = ScreenBuffer[i + p];
+ }
+ }
+
+ return croppedBuffer;
+
+ case ZXSpectrum.BorderType.None:
+ // all border sizes now 24
+ var lR__ = BorderLeftWidth;
+ var rR__ = BorderRightWidth;
+ var tR__ = BorderTopHeight;
+ var bR__ = BorderBottomHeight;
+ var startP__ = ScanLineWidth * tR__;
+ var endP__ = ScanLineWidth * bR__;
+
+ int index2__ = 0;
+ // line by line
+ for (int i = startP__; i < ScreenBuffer.Length - endP__; i += ScreenWidth + BorderLeftWidth + BorderRightWidth)
+ {
+ // each pixel in each line
+ for (int p = lR__; p < ScreenWidth + BorderLeftWidth + BorderRightWidth - rR__; p++)
+ {
+ if (index2__ == croppedBuffer.Length)
+ break;
+ croppedBuffer[index2__++] = ScreenBuffer[i + p];
+ }
+ }
+
+ return croppedBuffer;
+ }
+
return ScreenBuffer;
}
+ protected void SetupScreenSize()
+ {
+ switch (borderType)
+ {
+ case ZXSpectrum.BorderType.Full:
+ BufferWidth = ScreenWidth + BorderLeftWidth + BorderRightWidth;
+ BufferHeight = ScreenHeight + BorderTopHeight + BorderBottomHeight;
+ VirtualHeight = BufferHeight;
+ VirtualWidth = BufferWidth;
+ ScreenBuffer = new int[BufferWidth * BufferHeight];
+ break;
+
+ case ZXSpectrum.BorderType.Widescreen:
+ BufferWidth = ScreenWidth + BorderLeftWidth + BorderRightWidth;
+ BufferHeight = ScreenHeight;
+ VirtualHeight = BufferHeight;
+ VirtualWidth = BufferWidth;
+ croppedBuffer = new int[BufferWidth * BufferHeight];
+ break;
+
+ case ZXSpectrum.BorderType.Medium:
+ BufferWidth = ScreenWidth + (24) + (24);
+ BufferHeight = ScreenHeight + (24) + (24);
+ VirtualHeight = BufferHeight;
+ VirtualWidth = BufferWidth;
+ croppedBuffer = new int[BufferWidth * BufferHeight];
+ break;
+
+ case ZXSpectrum.BorderType.Small:
+ BufferWidth = ScreenWidth + (10) + (10);
+ BufferHeight = ScreenHeight + (10) + (10);
+ VirtualHeight = BufferHeight;
+ VirtualWidth = BufferWidth;
+ croppedBuffer = new int[BufferWidth * BufferHeight];
+ break;
+
+ case ZXSpectrum.BorderType.None:
+ BufferWidth = ScreenWidth;
+ BufferHeight = ScreenHeight;
+ VirtualHeight = BufferHeight;
+ VirtualWidth = BufferWidth;
+ croppedBuffer = new int[BufferWidth * BufferHeight];
+ break;
+ }
+ }
+
+ protected int[] croppedBuffer;
+
+ private ZXSpectrum.BorderType _borderType;
+
+ public ZXSpectrum.BorderType borderType
+ {
+ get { return _borderType; }
+ set { _borderType = value; }
+ }
+
+
+
#endregion
#region IStatable
diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128K/ZX128.ULA.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128K/ZX128.ULA.cs
index 090cd9c7be..d7cc8f4941 100644
--- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128K/ZX128.ULA.cs
+++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128K/ZX128.ULA.cs
@@ -43,10 +43,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
attr = new short[DisplayLength]; //6144 bytes of display memory will be mapped
- BufferWidth = ScreenWidth + BorderLeftWidth + BorderRightWidth;
- BufferHeight = ScreenHeight + BorderTopHeight + BorderBottomHeight;
- VirtualHeight = BufferHeight;
- VirtualWidth = BufferWidth;
+ SetupScreenSize();
Reset();
}
diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128K/ZX128.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128K/ZX128.cs
index 65117acdfe..74df0bba39 100644
--- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128K/ZX128.cs
+++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum128K/ZX128.cs
@@ -29,7 +29,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
// init addressable memory from ROM and RAM banks
ReInitMemory();
- ULADevice = new ULA48(this);
+ ULADevice = new ULA128(this);
BuzzerDevice = new Buzzer(this);
BuzzerDevice.Init(44100, ULADevice.FrameLength);
diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum48K/ZX48.ULA.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum48K/ZX48.ULA.cs
index d6ca8b4565..a093a33aad 100644
--- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum48K/ZX48.ULA.cs
+++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Machine/ZXSpectrum48K/ZX48.ULA.cs
@@ -43,12 +43,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
attr = new short[DisplayLength]; //6144 bytes of display memory will be mapped
- BufferWidth = ScreenWidth + BorderLeftWidth + BorderRightWidth;
- BufferHeight = ScreenHeight + BorderTopHeight + BorderBottomHeight;
- VirtualHeight = BufferHeight;
- VirtualWidth = BufferWidth;
-
-
+ SetupScreenSize();
Reset();
}
diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.ISettable.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.ISettable.cs
index ba6a944346..6266d7e021 100644
--- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.ISettable.cs
+++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/ZXSpectrum.ISettable.cs
@@ -108,6 +108,21 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
///
Full,
+ ///
+ /// All borders 24px
+ ///
+ Medium,
+
+ ///
+ /// All borders 10px
+ ///
+ Small,
+
+ ///
+ /// No border at all
+ ///
+ None,
+
///
/// Top and bottom border removed so that the result is *almost* 16:9
///