resize viewport on load state

This commit is contained in:
retrotalker 2018-08-23 17:35:15 -05:00 committed by GitHub
parent ade94ccac6
commit 1067b3d0ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 53 additions and 38 deletions

55
gfx.cpp
View File

@ -329,32 +329,8 @@ void S9xGraphicsDeinit (void)
if (GFX.SubZBuffer) { free(GFX.SubZBuffer); GFX.SubZBuffer = NULL; }
}
void S9xBuildDirectColourMaps (void)
void S9xGraphicsScreenResize (void)
{
IPPU.XB = mul_brightness[PPU.Brightness];
for (uint32 p = 0; p < 8; p++)
for (uint32 c = 0; c < 256; c++)
DirectColourMaps[p][c] = BUILD_PIXEL(IPPU.XB[((c & 7) << 2) | ((p & 1) << 1)], IPPU.XB[((c & 0x38) >> 1) | (p & 2)], IPPU.XB[((c & 0xc0) >> 3) | (p & 4)]);
}
void S9xStartScreenRefresh (void)
{
GFX.InterlaceFrame = !GFX.InterlaceFrame;
if (IPPU.RenderThisFrame)
{
if (!GFX.DoInterlace || !GFX.InterlaceFrame)
{
if (!S9xInitUpdate())
{
IPPU.RenderThisFrame = FALSE;
return;
}
if (GFX.DoInterlace)
GFX.DoInterlace--;
IPPU.MaxBrightness = PPU.Brightness;
IPPU.Interlace = Memory.FillRAM[0x2133] & 1;
@ -393,6 +369,35 @@ void S9xStartScreenRefresh (void)
IPPU.DoubleHeightPixels = FALSE;
IPPU.RenderedScreenHeight = PPU.ScreenHeight;
}
}
void S9xBuildDirectColourMaps (void)
{
IPPU.XB = mul_brightness[PPU.Brightness];
for (uint32 p = 0; p < 8; p++)
for (uint32 c = 0; c < 256; c++)
DirectColourMaps[p][c] = BUILD_PIXEL(IPPU.XB[((c & 7) << 2) | ((p & 1) << 1)], IPPU.XB[((c & 0x38) >> 1) | (p & 2)], IPPU.XB[((c & 0xc0) >> 3) | (p & 4)]);
}
void S9xStartScreenRefresh (void)
{
GFX.InterlaceFrame = !GFX.InterlaceFrame;
if (IPPU.RenderThisFrame)
{
if (!GFX.DoInterlace || !GFX.InterlaceFrame)
{
if (!S9xInitUpdate())
{
IPPU.RenderThisFrame = FALSE;
return;
}
if (GFX.DoInterlace)
GFX.DoInterlace--;
S9xGraphicsScreenResize();
IPPU.RenderedFramesCount++;
}

1
gfx.h
View File

@ -359,6 +359,7 @@ void S9xBuildDirectColourMaps (void);
void RenderLine (uint8);
void S9xComputeClipWindows (void);
void S9xDisplayChar (uint16 *, uint8);
void S9xGraphicsScreenResize (void);
// called automatically unless Settings.AutoDisplayMessages is false
void S9xDisplayMessages (uint16 *, int, int, int, int);
#ifdef GFX_MULTI_FORMAT

View File

@ -204,6 +204,7 @@
#include "movie.h"
#include "display.h"
#include "language.h"
#include "gfx.h"
#ifndef min
#define min(a,b) (((a) < (b)) ? (a) : (b))
@ -1844,6 +1845,14 @@ int S9xUnfreezeFromStream (STREAM stream)
IPPU.OBJChanged = TRUE;
IPPU.RenderThisFrame = TRUE;
GFX.InterlaceFrame = Timings.InterlaceField;
GFX.DoInterlace = 0;
S9xGraphicsScreenResize();
if (Settings.FastSavestates == 0)
memset(GFX.Screen,0,GFX.Pitch * MAX_SNES_HEIGHT);
uint8 hdma_byte = Memory.FillRAM[0x420c];
S9xSetCPU(hdma_byte, 0x420c);