work harder to update mednafen gpu.cpp from 1.24.0-UNSTABLE more exactly

This commit is contained in:
zeromus 2020-04-09 15:38:24 -04:00
parent 8e5aefb376
commit 4201a9d382
2 changed files with 1444 additions and 1468 deletions

View File

@ -51,6 +51,8 @@ typedef __uint16_t uint16;
typedef __uint8_t uint8;
#endif
#define MDFN_HIDE
//#if MDFN_GCC_VERSION >= MDFN_MAKE_GCCV(4,7,0)
// #define MDFN_ASSUME_ALIGNED(p, align) __builtin_assume_aligned((p), (align))

View File

@ -69,15 +69,15 @@
namespace MDFN_IEN_PSX
{
PS_GPU GPU;
PS_GPU GPU;
namespace PS_GPU_INTERNAL
{
namespace PS_GPU_INTERNAL
{
#include "gpu_common.inc"
}
using namespace PS_GPU_INTERNAL;
}
using namespace PS_GPU_INTERNAL;
void GPU_Init(bool pal_clock_and_tv)
void GPU_Init(bool pal_clock_and_tv)
{
static const int8 dither_table[4][4] =
{
@ -127,11 +127,10 @@ namespace MDFN_IEN_PSX
memcpy(&Commands[0x80], Commands_80_FF, sizeof(Commands_80_FF));
}
void GPU_Kill(void)
{
}
}
/*
2640: 528.000000 660.000000 377.142853 --- 8.000000 10.000000 11.428572
@ -504,10 +503,8 @@ static void Command_FBCopy(const uint32 *cb)
}
}
}
}
static void Command_FBWrite(const uint32 *cb)
{
assert(InCmd == PS_GPU::INCMD_NONE);
@ -556,6 +553,8 @@ static void Command_FBRead(const uint32 *cb)
FBRW_CurX = FBRW_X;
FBRW_CurY = FBRW_Y;
InvalidateTexCache();
if(FBRW_W != 0 && FBRW_H != 0)
InCmd = PS_GPU::INCMD_FBREAD;
}
@ -668,8 +667,8 @@ static void Command_IRQ(const uint32 *cb)
namespace PS_GPU_INTERNAL
{
extern const CTEntry Commands_00_1F[0x20] =
{
MDFN_HIDE extern const CTEntry Commands_00_1F[0x20] =
{
/* 0x00 */
NULLCMD(),
OTHER_HELPER(1, 2, false, Command_ClearCache),
@ -684,10 +683,10 @@ namespace PS_GPU_INTERNAL
/* 0x1F */
OTHER_HELPER(1, 1, false, Command_IRQ)
};
};
extern const CTEntry Commands_80_FF[0x80] =
{
MDFN_HIDE extern const CTEntry Commands_80_FF[0x80] =
{
/* 0x80 ... 0x9F */
OTHER_HELPER_X32(4, 2, false, Command_FBCopy),
@ -713,7 +712,7 @@ namespace PS_GPU_INTERNAL
/* 0xF0 */
NULLCMD(), NULLCMD(), NULLCMD(), NULLCMD(), NULLCMD(), NULLCMD(), NULLCMD(), NULLCMD(),
NULLCMD(), NULLCMD(), NULLCMD(), NULLCMD(), NULLCMD(), NULLCMD(), NULLCMD(), NULLCMD()
};
};
}
static void ProcessFIFO(void)
@ -830,7 +829,7 @@ static void ProcessFIFO(void)
if(!command->ss_cmd)
DrawTimeAvail -= 2;
#if 0
#if 0
PSX_WARNING("[GPU] Command: %08x %s %d %d %d", CB[0], command->name, command->len, scanline, DrawTimeAvail);
if(1)
{
@ -839,7 +838,7 @@ static void ProcessFIFO(void)
printf("0x%08x ", CB[i]);
printf("\n");
}
#endif
#endif
// A very very ugly kludge to support texture mode specialization. fixme/cleanup/SOMETHING in the future.
if(cc >= 0x20 && cc <= 0x3F && (cc & 0x4))
{
@ -1126,13 +1125,13 @@ static INLINE void ReorderRGB_Var(uint32 out_Rshift, uint32 out_Gshift, uint32 o
{
uint32 srcpix = src[fb_x >> 1];
#if 1
#if 1
dest[x] = OutputLUT[(uint8)srcpix] | (OutputLUT + 256)[(srcpix >> 8) & 0x7F];
#else
#else
dest[x] = ShiftHelper(srcpix, out_Rshift + 3 - 0, (0xF8 << out_Rshift)) |
ShiftHelper(srcpix, out_Gshift + 3 - 5, (0xF8 << out_Gshift)) |
ShiftHelper(srcpix, out_Bshift + 3 - 10, (0xF8 << out_Bshift));
#endif
#endif
fb_x = (fb_x + 2) & 0x7FF;
}
}
@ -1151,6 +1150,7 @@ MDFN_FASTCALL pscpu_timestamp_t GPU_Update(const pscpu_timestamp_t sys_timestamp
const uint32 dmc = (DisplayMode & 0x40) ? 4 : (DisplayMode & 0x3);
const uint32 dmw = HVisMax / DotClockRatios[dmc]; // Must be <= (768 - drxbo)
const uint32 dmpa = HVisOffs / DotClockRatios[dmc]; // Must be <= drxbo
int32 sys_clocks = sys_timestamp - lastts;
int32 gpu_clocks;
@ -1221,9 +1221,9 @@ MDFN_FASTCALL pscpu_timestamp_t GPU_Update(const pscpu_timestamp_t sys_timestamp
scanline = (scanline + 1) % LinesPerField;
PhaseChange = !PhaseChange;
#ifdef WANT_DEBUGGER
#ifdef WANT_DEBUGGER
DBG_GPUScanlineHook(scanline);
#endif
#endif
//
//
@ -1300,9 +1300,10 @@ MDFN_FASTCALL pscpu_timestamp_t GPU_Update(const pscpu_timestamp_t sys_timestamp
if(!DisplayOff)
{
printf("VIDEO STANDARD MISMATCH");
/*DrawText(surface, 0, (DisplayRect->h / 2) - (13 / 2), buffer,
surface->MakeColor(0x00, 0xFF, 0x00), MDFN_FONT_6x13_12x13, DisplayRect->w);*/
char buffer[256];
printf(("VIDEO STANDARD MISMATCH"));
// DrawText(surface, 0, (DisplayRect->h / 2) - (13 / 2), buffer,
//surface->MakeColor(0x00, 0xFF, 0x00), MDFN_FONT_6x13_12x13, DisplayRect->w);
}
}
else
@ -1435,31 +1436,6 @@ 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];
@ -1513,11 +1489,11 @@ MDFN_FASTCALL pscpu_timestamp_t GPU_Update(const pscpu_timestamp_t sys_timestamp
PSX_SetEventNT(PSX_EVENT_TIMER, TIMER_Update(sys_timestamp)); // Mostly so the next event time gets recalculated properly in regards to our calls
// to TIMER_SetVBlank() and TIMER_SetHRetrace().
} // end if(!LineClockCounter)
} // end while(gpu_clocks > 0)
} // end while(gpu_clocks > 0)
//puts("GPU Update End");
TheEnd:
TheEnd:
lastts = sys_timestamp;
{
@ -1553,7 +1529,6 @@ void GPU_GetGunXTranslation(float* scale, float* offs)
//printf("%f %d %d\n", *scale, lw, nca_lw);
}
}
void GPU_StartFrame(EmulateSpecStruct *espec_arg)
{
sl_zero_reached = false;
@ -1574,7 +1549,6 @@ void GPU_StartFrame(EmulateSpecStruct *espec_arg)
DisplayRect = &espec->DisplayRect;
LineWidths = espec->LineWidths;
skip = espec->skip;
GPU.FirstLine = -99;
if(espec->VideoFormatChanged)
{