fix damage to aspect ratio management in octoshock

This commit is contained in:
zeromus 2020-04-07 23:53:33 -04:00
parent 3e452e2cc6
commit 341c67d562
2 changed files with 68 additions and 3 deletions

View File

@ -149,7 +149,7 @@ void PS_GPU::SetRenderOptions(::ShockRenderOptions* opts)
{
dump_framebuffer = opts->renderType == eShockRenderType_Framebuffer;
ShowHOverscan = !(opts->renderType == eShockRenderType_ClipOverscan);
CorrectAspect = false; //NOT USED? IMPORTANT?
CorrectAspect = true;
HVis = ShowHOverscan ? HVisMax : HVisHideOS;
HVisOffs = (HVisMax - HVis) / 2;
NCABaseW = (HVis + 6) / 7;
@ -157,6 +157,35 @@ void PS_GPU::SetRenderOptions(::ShockRenderOptions* opts)
LineVisFirst = opts->scanline_start;
LineVisLast = opts->scanline_end;
int lcm_width = HVis;
int lcm_height = (LineVisLast + 1 - LineVisFirst) * 2;
int fb_height, nominal_width;
//
// Nominal fps values are for interlaced mode(fps will be lower in progressive mode), and will be slightly higher than actual fps
// due to rounding error with GPUClockRatio.
//
if(HardwarePALType)
{
nominal_width = ((int64)lcm_width * 14750000 / 53203425 + 1) / 2;
fb_height = 576;
//gi->fb_height = 576;
//gi->fps = 838865530; // 65536*256 * 53203425 / (3405 * 312.5)
//gi->VideoSystem = VIDSYS_PAL;
}
else
{
nominal_width = ((int64)lcm_width * 12272727 / 53693182 + 1) / 2;
fb_height = 480;
//gi->fb_height = 480;
//gi->fps = 1005627336; // 65536*256 * 53693182 / (3412.5 * 262.5)
//gi->VideoSystem = VIDSYS_NTSC;
}
//printf("RESOLUTION INFO: %d %d %d %d\n", lcm_width, lcm_height, nominal_width, fb_height);
//SNIP: gi-> setup stuff INCLUDING guns (probably need to do this at some point)
}
@ -1406,6 +1435,31 @@ MDFN_FASTCALL pscpu_timestamp_t GPU_Update(const pscpu_timestamp_t sys_timestamp
dest += nca_dest_adj;
}
//adjustments for people who really just want to see the PSX framebuffer
//effectively fixes the xstart registers to be nominal values.
//it's unclear what happens to games displaying a peculiar Y range
if (dump_framebuffer)
{
//printf("%d %d %d\n", VertStart, VertEnd, DisplayOff);
//special hack: if the game (or the bios...) is set to display no range here, don't modify it
//also, as you can see just above, this condition is used to represent an 'off' display
//unfortunately, this will usually be taking effect at dest_line==0, and so the
//fully overscanned area will get set for LineWidths[0].
//so later on we'll have to use LineWidths[NN], say, as a heuristic to get the framebuffer size
if (dx_start == dx_end)
{ }
else
{
dx_start = 0;
dx_end = 2560 / DotClockRatios[dmc];
if(GPU.FirstLine == -99)
GPU.FirstLine = dest_line;
LineWidths[dest_line] = dx_end - dx_start;
}
}
{
const uint16 *src = GPURAM[DisplayFB_CurLineYReadout];
@ -1520,6 +1574,7 @@ void GPU_StartFrame(EmulateSpecStruct *espec_arg)
DisplayRect = &espec->DisplayRect;
LineWidths = espec->LineWidths;
skip = espec->skip;
GPU.FirstLine = -99;
if(espec->VideoFormatChanged)
{

View File

@ -1402,7 +1402,8 @@ EW_EXPORT s32 shock_Create(void** psx, s32 region, void* firmware512k)
SPU = new PS_SPU();
GPU_Init(region == REGION_EU);
CDC = new PS_CDC();
DMA_Init();
DMA_Init();
//setup gpu output surfaces
MDFN_PixelFormat nf(MDFN_COLORSPACE_RGB, 16, 8, 0, 24);
@ -1411,6 +1412,15 @@ EW_EXPORT s32 shock_Create(void** psx, s32 region, void* firmware512k)
VTBuffer[i] = new MDFN_Surface(NULL, FB_WIDTH, FB_HEIGHT, FB_WIDTH, nf);
VTLineWidths[i] = (int *)calloc(FB_HEIGHT, sizeof(int));
}
for(int rc = 0; rc < 0x8000; rc++)
{
const uint8 a = rc;
const uint8 b = rc >> 8;
(GPU.OutputLUT + 0)[a] = ((a & 0x1F) << (3 + nf.Rshift)) | ((a >> 5) << (3 + nf.Gshift));
(GPU.OutputLUT + 256)[b] = ((b & 0x3) << (6 + nf.Gshift)) | (((b >> 2) & 0x1F) << (3 + nf.Bshift));
}
FIO = new FrontIO();
s_ShockPeripheralState.Initialize();
@ -1526,7 +1536,7 @@ EW_EXPORT s32 shock_Step(void* psx, eShockStep step)
memset(&espec, 0, sizeof(EmulateSpecStruct));
espec.VideoFormatChanged = true; //shouldnt do this every frame..
espec.VideoFormatChanged = false;
espec.surface = (MDFN_Surface *)VTBuffer[VTBackBuffer];
espec.LineWidths = (int *)VTLineWidths[VTBackBuffer];
espec.skip = false;