internal infrastructure for video presentation changes (aspect ratio, apparent size, etc)

This commit is contained in:
goyuken 2014-04-30 23:48:37 +00:00
parent 72595b73bb
commit b0970451aa
26 changed files with 91 additions and 18 deletions

View File

@ -90,17 +90,19 @@ namespace BizHawk.Client.EmuHawk
class VideoCopy : IVideoProvider class VideoCopy : IVideoProvider
{ {
int[] vb; int[] vb;
int bw, bh, bc; public int VirtualWidth { get; private set; }
public int VirtualWidth { get { return bw; } } public int VirtualHeight { get; private set; }
public int BufferWidth { get { return bw; } } public int BufferWidth { get; private set; }
public int BufferHeight { get { return bh; } } public int BufferHeight { get; private set; }
public int BackgroundColor { get { return bc; } } public int BackgroundColor { get; private set; }
public VideoCopy(IVideoProvider c) public VideoCopy(IVideoProvider c)
{ {
vb = (int[])c.GetVideoBuffer().Clone(); vb = (int[])c.GetVideoBuffer().Clone();
bw = c.BufferWidth; BufferWidth = c.BufferWidth;
bh = c.BufferHeight; BufferHeight= c.BufferHeight;
bc = c.BackgroundColor; BackgroundColor = c.BackgroundColor;
VirtualWidth = c.VirtualWidth;
VirtualHeight = c.VirtualHeight;
} }
public int[] GetVideoBuffer() public int[] GetVideoBuffer()
{ {

View File

@ -47,6 +47,12 @@ namespace BizHawk.Client.EmuHawk
get { return bmp.Width; } get { return bmp.Width; }
} }
public int VirtualHeight
{
// todo: Bitmap actually has size metric data; use it
get { return bmp.Height; }
}
public int BufferWidth public int BufferWidth
{ {
get { return bmp.Width; } get { return bmp.Width; }

View File

@ -75,6 +75,7 @@ namespace BizHawk.Emulation.Common
public bool BinarySaveStatesPreferred { get { return false; } } public bool BinarySaveStatesPreferred { get { return false; } }
public int[] GetVideoBuffer() { return frameBuffer; } public int[] GetVideoBuffer() { return frameBuffer; }
public int VirtualWidth { get { return 256; } } public int VirtualWidth { get { return 256; } }
public int VirtualHeight { get { return 192; } }
public int BufferWidth { get { return 256; } } public int BufferWidth { get { return 256; } }
public int BufferHeight { get { return 192; } } public int BufferHeight { get { return 192; } }
public int BackgroundColor { get { return 0; } } public int BackgroundColor { get { return 0; } }

View File

@ -4,7 +4,12 @@
{ {
int[] GetVideoBuffer(); int[] GetVideoBuffer();
int VirtualWidth { get; } // Used for controlling aspect ratio. Just return BufferWidth if you dont know what to do with this. // put together, these describe a metric on the screen
// they should define the smallest size that the buffer can be placed inside such that:
// 1. no actual pixel data is lost
// 2. aspect ratio is accurate
int VirtualWidth { get; }
int VirtualHeight { get; }
int BufferWidth { get; } int BufferWidth { get; }
int BufferHeight { get; } int BufferHeight { get; }

View File

@ -414,6 +414,7 @@ namespace BizHawk.Emulation.Cores.Calculators
return pixels; return pixels;
} }
public int VirtualWidth { get { return 96; } } public int VirtualWidth { get { return 96; } }
public int VirtualHeight { get { return 64; } }
public int BufferWidth { get { return 96; } } public int BufferWidth { get { return 96; } }
public int BufferHeight { get { return 64; } } public int BufferHeight { get { return 64; } }
public int BackgroundColor { get { return 0; } } public int BackgroundColor { get { return 0; } }

View File

@ -47,6 +47,11 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Experimental
get { return screenWidth; } get { return screenWidth; }
} }
public int VirtualHeight
{
get { return screenHeight; }
}
public int BufferWidth public int BufferWidth
{ {
get { return screenWidth; } get { return screenWidth; }

View File

@ -61,5 +61,10 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64
{ {
get { return bufWidth; } get { return bufWidth; }
} }
public int VirtualHeight
{
get { return bufHeight; }
}
} }
} }

View File

@ -118,6 +118,11 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
get { return 320; } get { return 320; }
} }
public int VirtualHeight
{
get { return 262; }
}
public int BufferWidth public int BufferWidth
{ {
get { return 320; } get { return 320; }

View File

@ -406,7 +406,8 @@ namespace BizHawk.Emulation.Cores.Atari.Atari7800
return vidbuffer; return vidbuffer;
} }
public int VirtualWidth { get { return BufferWidth; } } public int VirtualWidth { get { return 275; } }
public int VirtualHeight { get { return BufferHeight; } }
public int BufferWidth { get; private set; } public int BufferWidth { get; private set; }
public int BufferHeight { get; private set; } public int BufferHeight { get; private set; }
public int BackgroundColor { get { return unchecked((int)0xff000000); } } public int BackgroundColor { get { return unchecked((int)0xff000000); } }

View File

@ -445,7 +445,8 @@ namespace BizHawk.Emulation.Cores.ColecoVision
public int[] FrameBuffer = new int[256 * 192]; public int[] FrameBuffer = new int[256 * 192];
public int[] GetVideoBuffer() { return FrameBuffer; } public int[] GetVideoBuffer() { return FrameBuffer; }
public int VirtualWidth { get { return 256; } } public int VirtualWidth { get { return 293; } }
public int VirtualHeight { get { return 192; } }
public int BufferWidth { get { return 256; } } public int BufferWidth { get { return 256; } }
public int BufferHeight { get { return 192; } } public int BufferHeight { get { return 192; } }
public int BackgroundColor { get { return 0; } } public int BackgroundColor { get { return 0; } }

View File

@ -535,6 +535,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
public int[] GetVideoBuffer() { return videobuffer; } public int[] GetVideoBuffer() { return videobuffer; }
public int VirtualWidth { get { return 240; } } public int VirtualWidth { get { return 240; } }
public int VirtualHeight { get { return 160; } }
public int BufferWidth { get { return 240; } } public int BufferWidth { get { return 240; } }
public int BufferHeight { get { return 160; } } public int BufferHeight { get { return 160; } }
public int BackgroundColor { get { return unchecked((int)0xff000000); } } public int BackgroundColor { get { return unchecked((int)0xff000000); } }

View File

@ -807,6 +807,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
get { return 160; } get { return 160; }
} }
public int VirtualHeight
{
get { return 144; }
}
public int BufferWidth public int BufferWidth
{ {
get { return 160; } get { return 160; }

View File

@ -361,6 +361,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
int[] VideoBuffer = new int[160 * 2 * 144]; int[] VideoBuffer = new int[160 * 2 * 144];
public int[] GetVideoBuffer() { return VideoBuffer; } public int[] GetVideoBuffer() { return VideoBuffer; }
public int VirtualWidth { get { return 320; } } public int VirtualWidth { get { return 320; } }
public int VirtualHeight { get { return 144; } }
public int BufferWidth { get { return 320; } } public int BufferWidth { get { return 320; } }
public int BufferHeight { get { return 144; } } public int BufferHeight { get { return 144; } }
public int BackgroundColor { get { return unchecked((int)0xff000000); } } public int BackgroundColor { get { return unchecked((int)0xff000000); } }

View File

@ -30,6 +30,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
} }
public int VirtualWidth { get { return BufferWidth; } } public int VirtualWidth { get { return BufferWidth; } }
public int VirtualHeight { get { return BufferHeight; } }
public int BufferWidth { get; private set; } public int BufferWidth { get; private set; }
public int BufferHeight { get; private set; } public int BufferHeight { get; private set; }
public int BackgroundColor { get { return 0; } } public int BackgroundColor { get { return 0; } }

View File

@ -212,7 +212,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
} }
} }
} }
public int VirtualWidth { get { return BufferWidth; } } public int VirtualWidth { get { return (int)(BufferWidth * 1.146); } }
public int VirtualHeight { get { return BufferHeight; } }
public int BufferWidth { get { return right - left + 1; } } public int BufferWidth { get { return right - left + 1; } }
public int BackgroundColor { get { return 0; } } public int BackgroundColor { get { return 0; } }
public int BufferHeight public int BufferHeight

View File

@ -536,7 +536,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
public IVideoProvider VideoProvider { get { return this; } } public IVideoProvider VideoProvider { get { return this; } }
public int[] GetVideoBuffer() { return VideoOutput; } public int[] GetVideoBuffer() { return VideoOutput; }
public int VirtualWidth { get { return (int)(BufferWidth * 1.14); } } public int VirtualWidth { get { return (int)(BufferWidth * 1.146); } }
public int VirtualHeight { get { return BufferHeight; } }
public int BufferWidth { get; private set; } public int BufferWidth { get; private set; }
public int BufferHeight { get; private set; } public int BufferHeight { get; private set; }
public int BackgroundColor { get { return unchecked((int)0xff000000); } } public int BackgroundColor { get { return unchecked((int)0xff000000); } }

View File

@ -622,6 +622,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
int IVideoProvider.BackgroundColor { get { return 0; } } int IVideoProvider.BackgroundColor { get { return 0; } }
int[] IVideoProvider.GetVideoBuffer() { return vidBuffer; } int[] IVideoProvider.GetVideoBuffer() { return vidBuffer; }
int IVideoProvider.VirtualWidth { get { return vidWidth; } } int IVideoProvider.VirtualWidth { get { return vidWidth; } }
public int VirtualHeight { get { return vidHeight; } }
int IVideoProvider.BufferWidth { get { return vidWidth; } } int IVideoProvider.BufferWidth { get { return vidWidth; } }
int IVideoProvider.BufferHeight { get { return vidHeight; } } int IVideoProvider.BufferHeight { get { return vidHeight; } }

View File

@ -427,6 +427,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
public int[] GetVideoBuffer() { return FrameBuffer; } public int[] GetVideoBuffer() { return FrameBuffer; }
public int VirtualWidth { get { return FramePitch; } } public int VirtualWidth { get { return FramePitch; } }
public int VirtualHeight { get { return FrameHeight; } }
public int BufferWidth { get { return FramePitch; } } public int BufferWidth { get { return FramePitch; } }
public int BufferHeight { get { return FrameHeight; } } public int BufferHeight { get { return FrameHeight; } }
public int BackgroundColor { get { return vce.Palette[256]; } } public int BackgroundColor { get { return vce.Palette[256]; } }

View File

@ -520,6 +520,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
public int[] GetVideoBuffer() { return FrameBuffer; } public int[] GetVideoBuffer() { return FrameBuffer; }
public int VirtualWidth { get { return FrameWidth; } } public int VirtualWidth { get { return FrameWidth; } }
public int VirtualHeight { get { return FrameHeight; } }
public int BufferWidth { get { return FrameWidth; } } public int BufferWidth { get { return FrameWidth; } }
public int BufferHeight { get { return FrameHeight; } } public int BufferHeight { get { return FrameHeight; } }
public int BackgroundColor { get { return VCE.Palette[0]; } } public int BackgroundColor { get { return VCE.Palette[0]; } }

View File

@ -465,6 +465,7 @@ namespace BizHawk.Emulation.Cores.Sega.Genesis
} }
public int VirtualWidth { get { return 320; } } public int VirtualWidth { get { return 320; } }
public int VirtualHeight { get { return FrameHeight; } }
public int BufferWidth public int BufferWidth
{ {

View File

@ -434,7 +434,19 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
return GameGearFrameBuffer; return GameGearFrameBuffer;
} }
public int VirtualWidth { get { return BufferWidth; } } public int VirtualWidth
{
get
{
if (mode == MasterSystem.VdpMode.SMS)
return 293;
else if (Sms.Settings.ShowClippedRegions)
return 256;
else
return 160;
}
}
public int VirtualHeight { get { return BufferHeight; } }
public int BufferWidth public int BufferWidth
{ {
get get

View File

@ -505,7 +505,8 @@ namespace BizHawk.Emulation.Cores.Sega.Saturn
public IVideoProvider VideoProvider { get { return this; } } public IVideoProvider VideoProvider { get { return this; } }
int[] VideoBuffer = new int[704 * 512]; int[] VideoBuffer = new int[704 * 512];
public int[] GetVideoBuffer() { return VideoBuffer; } public int[] GetVideoBuffer() { return VideoBuffer; }
public int VirtualWidth { get; private set; } public int VirtualWidth { get { return BufferWidth; } }
public int VirtualHeight { get { return BufferHeight; } }
public int BufferWidth { get; private set; } public int BufferWidth { get; private set; }
public int BufferHeight { get; private set; } public int BufferHeight { get; private set; }
public int BackgroundColor { get { return unchecked((int)0xff000000); } } public int BackgroundColor { get { return unchecked((int)0xff000000); } }

View File

@ -642,6 +642,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
int vheight; int vheight;
public int[] GetVideoBuffer() { return vidbuff; } public int[] GetVideoBuffer() { return vidbuff; }
public int VirtualWidth { get { return BufferWidth; } } // TODO public int VirtualWidth { get { return BufferWidth; } } // TODO
public int VirtualHeight { get { return BufferHeight; } } // TODO
public int BufferWidth { get { return vwidth; } } public int BufferWidth { get { return vwidth; } }
public int BufferHeight { get { return vheight; } } public int BufferHeight { get { return vheight; } }
public int BackgroundColor { get { return unchecked((int)0xff000000); } } public int BackgroundColor { get { return unchecked((int)0xff000000); } }

View File

@ -203,6 +203,7 @@ namespace BizHawk.Emulation.Cores.Sony.PSP
readonly int[] screenbuffer = new int[screenwidth * screenheight]; readonly int[] screenbuffer = new int[screenwidth * screenheight];
public int[] GetVideoBuffer() { return screenbuffer; } public int[] GetVideoBuffer() { return screenbuffer; }
public int VirtualWidth { get { return screenwidth; } } public int VirtualWidth { get { return screenwidth; } }
public int VirtualHeight { get { return screenheight; } }
public int BufferWidth { get { return screenwidth; } } public int BufferWidth { get { return screenwidth; } }
public int BufferHeight { get { return screenheight; } } public int BufferHeight { get { return screenheight; } }
public int BackgroundColor { get { return unchecked((int)0xff000000); } } public int BackgroundColor { get { return unchecked((int)0xff000000); } }

View File

@ -279,6 +279,7 @@ namespace BizHawk.Emulation.Cores.Sony.PSX
public bool BinarySaveStatesPreferred { get { return false; } } public bool BinarySaveStatesPreferred { get { return false; } }
public int[] GetVideoBuffer() { return frameBuffer; } public int[] GetVideoBuffer() { return frameBuffer; }
public int VirtualWidth { get; private set; } public int VirtualWidth { get; private set; }
public int VirtualHeight { get { return BufferHeight; } }
public int BufferWidth { get; private set; } public int BufferWidth { get; private set; }
public int BufferHeight { get; private set; } public int BufferHeight { get; private set; }
public int BackgroundColor { get { return 0; } } public int BackgroundColor { get { return 0; } }

View File

@ -545,12 +545,23 @@ namespace BizHawk.Emulation.Cores
{ {
get get
{ {
if (dar < 0.1f || dar > 3.0f) if (dar > 1.0f)
return BufferWidth;
else
return (int)(BufferWidth * dar); return (int)(BufferWidth * dar);
else
return BufferWidth;
} }
} }
public int VirtualHeight
{
get
{
if (dar < 1.0f)
return (int)(BufferHeight / dar);
else
return BufferHeight;
}
}
public int BufferWidth { get; private set; } public int BufferWidth { get; private set; }
public int BufferHeight { get; private set; } public int BufferHeight { get; private set; }
public int BackgroundColor { get { return unchecked((int)0xff000000); } } public int BackgroundColor { get { return unchecked((int)0xff000000); } }