(Mednafen PSX) Reimplement dithering core option

This commit is contained in:
twinaphex 2014-05-02 00:53:56 +02:00
parent 45f34c7043
commit cfbaac2a73
3 changed files with 50 additions and 7 deletions

View File

@ -543,6 +543,25 @@ static void check_variables(void)
log_cb(RETRO_LOG_INFO, "PCE CD Audio settings changed.\n");
}
#elif defined(WANT_PSX_EMU)
extern void PSXDitherApply(bool);
var.key = "psx_dithering";
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var))
{
static bool old_apply_dither = false;
bool apply_dither = true;
if (strcmp(var.value, "enabled") == 0)
apply_dither = true;
else if (strcmp(var.value, "disabled") == 0)
apply_dither = false;
if (apply_dither != old_apply_dither)
{
PSXDitherApply(apply_dither);
old_apply_dither = apply_dither;
}
}
var.key = "psx_enable_analog_toggle";
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var))

View File

@ -87,11 +87,6 @@
Vertical start and end can be changed during active display, with effect(though it needs to be vs0->ve0->vs1->ve1->..., vs0->vs1->ve0 doesn't apparently do anything
different from vs0->ve0.
*/
namespace MDFN_IEN_PSX
{
//FILE *fp;
static const int32 dither_table[4][4] =
{
{ -4, 0, -3, 1 },
@ -100,6 +95,37 @@ static const int32 dither_table[4][4] =
{ 3, -1, 2, -2 },
};
uint8 DitherLUT[4][4][512]; // Y, X, 8-bit source value(256 extra for saturation)
void PSXDitherApply(bool enable)
{
for(int y = 0; y < 4; y++)
for(int x = 0; x < 4; x++)
for(int v = 0; v < 512; v++)
{
int value = v;
if (enable)
value += dither_table[y][x];
value >>= 3;
if(value < 0)
value = 0;
if(value > 0x1F)
value = 0x1F;
DitherLUT[y][x][v] = value;
}
}
namespace MDFN_IEN_PSX
{
//FILE *fp;
PS_GPU::PS_GPU(bool pal_clock_and_tv, int sls, int sle) : BlitterFIFO(0x20) // 0x10 on actual PS1 GPU, 0x20 here(see comment at top of gpu.h) // 0x10)
{
HardwarePALType = pal_clock_and_tv;

View File

@ -160,8 +160,6 @@ class PS_GPU
uint8 RGB8SAT_Over[256];
};
uint8 DitherLUT[4][4][512]; // Y, X, 8-bit source value(256 extra for saturation)
bool LineSkipTest(unsigned y);
template<int BlendMode, bool MaskEval_TA, bool textured>