tweak scanline filter to be more versatile

This commit is contained in:
zeromus 2012-07-12 05:49:13 +00:00
parent faf986b559
commit 0ea0e94ab4
2 changed files with 25 additions and 46 deletions

View File

@ -28,7 +28,7 @@
#include "NDSSystem.h"
#include "utils/xstring.h"
int scanline_filter_a = 2, scanline_filter_b = 4;
int scanline_filter_a = 0, scanline_filter_b = 2, scanline_filter_c = 2, scanline_filter_d = 4;
int _commandline_linux_nojoy = 0;
CommandLine::CommandLine()
@ -91,8 +91,10 @@ void CommandLine::loadCommonOptions()
{ "bios-swi", 0, 0, G_OPTION_ARG_INT, &_bios_swi, "Uses SWI from the provided bios files", "BIOS_SWI"},
{ "spu-advanced", 0, 0, G_OPTION_ARG_INT, &_spu_advanced, "Uses advanced SPU capture functions", "SPU_ADVANCED"},
{ "num-cores", 0, 0, G_OPTION_ARG_INT, &_num_cores, "Override numcores detection and use this many", "NUM_CORES"},
{ "scanline-filter-a", 0, 0, G_OPTION_ARG_INT, &scanline_filter_a, "Intensity of fadeout for scanlines filter (edge) (default 2)", "SCANLINE_FILTER_A"},
{ "scanline-filter-b", 0, 0, G_OPTION_ARG_INT, &scanline_filter_b, "Intensity of fadeout for scanlines filter (corner) (default 4)", "SCANLINE_FILTER_B"},
{ "scanline-filter-a", 0, 0, G_OPTION_ARG_INT, &scanline_filter_a, "Intensity of fadeout for scanlines filter (topleft) (default 0)", "SCANLINE_FILTER_A"},
{ "scanline-filter-b", 0, 0, G_OPTION_ARG_INT, &scanline_filter_b, "Intensity of fadeout for scanlines filter (topright) (default 2)", "SCANLINE_FILTER_B"},
{ "scanline-filter-c", 0, 0, G_OPTION_ARG_INT, &scanline_filter_c, "Intensity of fadeout for scanlines filter (bottomleft) (default 2)", "SCANLINE_FILTER_C"},
{ "scanline-filter-d", 0, 0, G_OPTION_ARG_INT, &scanline_filter_d, "Intensity of fadeout for scanlines filter (bottomright) (default 4)", "SCANLINE_FILTER_D"},
{ "rigorous-timing", 0, 0, G_OPTION_ARG_INT, &_rigorous_timing, "Use some rigorous timings instead of unrealistically generous (default 0)", "RIGOROUS_TIMING"},
{ "advanced-timing", 0, 0, G_OPTION_ARG_INT, &_advanced_timing, "Use advanced BUS-level timing (default 1)", "ADVANCED_TIMING"},
{ "slot1", 0, 0, G_OPTION_ARG_STRING, &_slot1, "Device to load in slot 1 (default retail)", "SLOT1"},

View File

@ -24,57 +24,29 @@
typedef u64 uint64;
extern CACHE_ALIGN u16 fadeOutColors[17][0x8000];
extern int scanline_filter_a, scanline_filter_b, scanline_filter_c, scanline_filter_d;
static int fac_a, fac_b, fac_c, fac_d;
extern int scanline_filter_a, scanline_filter_b;
static int fac_a, fac_b;
FORCEINLINE void ScanLine16( uint16 *lpDst, uint16 *lpSrc, unsigned int Width){
while(Width--){
*lpDst++ = *lpSrc;
*lpDst++ = fadeOutColors[scanline_filter_a][(*lpSrc++)];
}
}
FORCEINLINE void ScanLine16_2( uint16 *lpDst, uint16 *lpSrc, unsigned int Width){
while(Width--){
*lpDst++ = fadeOutColors[scanline_filter_a][(*lpSrc)];
*lpDst++ = fadeOutColors[scanline_filter_b][(*lpSrc++)];
}
}
FORCEINLINE void ScanLine32( uint32 *lpDst, uint32 *lpSrc, unsigned int Width){
while(Width--){
*lpDst++ = *lpSrc;
FORCEINLINE void ScanLine32( uint32 *lpDst, uint32 *lpSrc, unsigned int Width, int fac_left, int fac_right)
{
while(Width--)
{
u8* u8dst = (u8*)lpDst;
u8* u8src = (u8*)lpSrc;
*u8dst++ = *u8src++ * fac_a / 16;
*u8dst++ = *u8src++ * fac_a / 16;
*u8dst++ = *u8src++ * fac_a / 16;
lpDst++;
lpSrc++;
}
}
FORCEINLINE void ScanLine32_2( uint32 *lpDst, uint32 *lpSrc, unsigned int Width){
while(Width--){
u8* u8dst = (u8*)lpDst;
u8* u8src = (u8*)lpSrc;
*u8dst++ = *u8src++ * fac_a / 16;
*u8dst++ = *u8src++ * fac_a / 16;
*u8dst++ = *u8src++ * fac_a / 16;
*u8dst++ = *u8src++ * fac_left / 16;
*u8dst++ = *u8src++ * fac_left / 16;
*u8dst++ = *u8src++ * fac_left / 16;
u8dst++;
u8src = (u8*)lpSrc;
*u8dst++ = *u8src++ * fac_b / 16;
*u8dst++ = *u8src++ * fac_b / 16;
*u8dst++ = *u8src++ * fac_b / 16;
*u8dst++ = *u8src++ * fac_right / 16;
*u8dst++ = *u8src++ * fac_right / 16;
*u8dst++ = *u8src++ * fac_right / 16;
u8dst++; u8src++;
lpDst+=2;
lpSrc++;
}
}
FORCEINLINE void DoubleLine32( uint32 *lpDst, uint32 *lpSrc, unsigned int Width){
while(Width--){
*lpDst++ = *lpSrc;
@ -86,6 +58,8 @@ void RenderScanline( SSurface Src, SSurface Dst)
{
fac_a = (16-scanline_filter_a);
fac_b = (16-scanline_filter_b);
fac_c = (16-scanline_filter_c);
fac_d = (16-scanline_filter_d);
unsigned int H;
const uint32 srcHeight = Src.Height;
@ -96,9 +70,12 @@ void RenderScanline( SSurface Src, SSurface Dst)
const unsigned int dstPitch = Dst.Pitch >> 1;
u32 *lpDst = (u32*)Dst.Surface;
for (H = 0; H < srcHeight; H++, lpSrc += srcPitch)
ScanLine32 (lpDst, lpSrc, Src.Width), lpDst += dstPitch,
ScanLine32_2 (lpDst, lpSrc, Src.Width), lpDst += dstPitch;
//memset (lpDst, 0, 512*2), lpDst += dstPitch;
{
ScanLine32(lpDst, lpSrc, Src.Width, fac_a, fac_b);
lpDst += dstPitch;
ScanLine32(lpDst, lpSrc, Src.Width, fac_c, fac_d);
lpDst += dstPitch;
}
}
void RenderNearest2X (SSurface Src, SSurface Dst)