win32: cut ext height from top and botton, center regular (fixes #443)

This commit is contained in:
OV2 2018-11-01 22:36:31 +01:00
parent 63126dfc48
commit 24c29e281a
3 changed files with 33 additions and 12 deletions

View File

@ -1038,9 +1038,9 @@ void InitSnes9X( void)
extern void S9xPostRomInit();
Memory.PostRomInitFunc = S9xPostRomInit;
ScreenBuf = new BYTE [EXT_PITCH * EXT_HEIGHT];
ScreenBuffer = ScreenBuf + EXT_OFFSET;
memset (ScreenBuf, 0, EXT_PITCH * EXT_HEIGHT);
ScreenBuf = new BYTE [EXT_PITCH * EXT_HEIGHT_WITH_CENTERING];
ScreenBuffer = ScreenBuf + EXT_OFFSET_WITH_CENTERING;
memset (ScreenBuf, 0, EXT_PITCH * EXT_HEIGHT_WITH_CENTERING);
GFX.Pitch = EXT_PITCH;
GFX.RealPPL = EXT_PITCH;

View File

@ -232,6 +232,29 @@ IS9xDisplayOutput *S9xDisplayOutput=&Direct3D;
bool8 S9xDeinitUpdate (int, int);
void DoAVIVideoFrame();
// cut off both top and bottom if overscan is disabled and game outputs extended height,
// center image if overscan is enabled and game outputs regular height
static void CheckOverscanOffset()
{
int lines_to_skip = 0;
if (!GUI.HeightExtend)
{
if (Src.Height == SNES_HEIGHT_EXTENDED)
lines_to_skip = 7;
else if (Src.Height == SNES_HEIGHT_EXTENDED << 1)
lines_to_skip = 15;
}
else
{
if (Src.Height == SNES_HEIGHT)
lines_to_skip = -8;
else if (Src.Height == SNES_HEIGHT << 1)
lines_to_skip = -16;
}
Src.Surface = (BYTE*)(GFX.Screen + lines_to_skip * (int)GFX.RealPPL);
}
/* WinRefreshDisplay
repeats the last rendered frame
*/
@ -240,6 +263,8 @@ void WinRefreshDisplay(void)
if(!Src.Width)
return;
CheckOverscanOffset();
SelectRenderMethod ();
S9xDisplayOutput->Render(Src);
@ -391,16 +416,10 @@ bool8 S9xContinueUpdate(int Width, int Height)
bool8 S9xDeinitUpdate (int Width, int Height)
{
Src.Width = Width;
if(Height%SNES_HEIGHT)
Src.Height = Height;
else
{
if(Height==SNES_HEIGHT)
Src.Height=SNES_HEIGHT_EXTENDED;
else Src.Height=SNES_HEIGHT_EXTENDED<<1;
}
Src.Height = Height;
Src.Pitch = GFX.Pitch;
Src.Surface = (BYTE*)GFX.Screen;
CheckOverscanOffset();
// avi writing
DoAVIVideoFrame();

View File

@ -619,10 +619,12 @@ enum
#define EXT_WIDTH (MAX_SNES_WIDTH + 4)
#define EXT_PITCH (EXT_WIDTH * 2)
#define EXT_HEIGHT (MAX_SNES_HEIGHT + 4)
#define EXT_HEIGHT_WITH_CENTERING (EXT_HEIGHT + 16) // extra lines to center non ext height images
// Offset into buffer to allow a two pixel border around the whole rendered
// SNES image. This is a speed up hack to allow some of the image processing
// routines to access black pixel data outside the normal bounds of the buffer.
#define EXT_OFFSET (EXT_PITCH * 2 + 2 * 2)
#define EXT_OFFSET_WITH_CENTERING (EXT_OFFSET + EXT_PITCH * 16) // same as above
#define WIN32_WHITE RGB(255,255,255)