accurate_sprites performance improvement, PSP is untested

git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@478 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
notaz 2008-06-01 13:45:34 +00:00
parent 6850f9ec3b
commit b13a934cb8
2 changed files with 44 additions and 18 deletions

View file

@ -291,26 +291,39 @@ static void blit(const char *fps, const char *notice)
// 8bit accurate renderer // 8bit accurate renderer
if (Pico.m.dirtyPal) if (Pico.m.dirtyPal)
{ {
int pallen = 0x40;
Pico.m.dirtyPal = 0; Pico.m.dirtyPal = 0;
if(Pico.video.reg[0xC]&8) { // shadow/hilight mode if (Pico.video.reg[0xC]&8) // shadow/hilight mode
{
vidConvCpyRGB32(localPal, Pico.cram, 0x40); vidConvCpyRGB32(localPal, Pico.cram, 0x40);
vidConvCpyRGB32sh(localPal+0x40, Pico.cram, 0x40); vidConvCpyRGB32sh(localPal+0x40, Pico.cram, 0x40);
vidConvCpyRGB32hi(localPal+0x80, Pico.cram, 0x40); vidConvCpyRGB32hi(localPal+0x80, Pico.cram, 0x40);
memcpy32(localPal+0xc0, localPal+0x40, 0x40); memcpy32(localPal+0xc0, localPal+0x40, 0x40);
pallen = 0x100;
}
else if (rendstatus & PDRAW_ACC_SPRITES) {
vidConvCpyRGB32(localPal, Pico.cram, 0x40);
memcpy32(localPal+0x40, localPal, 0x40);
memcpy32(localPal+0x80, localPal, 0x40);
memcpy32(localPal+0xc0, localPal, 0x40);
pallen = 0x100;
}
else if (rendstatus & PDRAW_SONIC_MODE) { // mid-frame palette changes
vidConvCpyRGB32(localPal, Pico.cram, 0x40);
vidConvCpyRGB32(localPal+0x40, HighPal, 0x40);
vidConvCpyRGB32(localPal+0x80, HighPal+0x40, 0x40);
pallen = 0xc0;
}
else {
vidConvCpyRGB32(localPal, Pico.cram, 0x40);
}
if (pallen > 0xc0) {
localPal[0xc0] = 0x0000c000; localPal[0xc0] = 0x0000c000;
localPal[0xd0] = 0x00c00000; localPal[0xd0] = 0x00c00000;
localPal[0xe0] = 0x00000000; // reserved pixels for OSD localPal[0xe0] = 0x00000000; // reserved pixels for OSD
localPal[0xf0] = 0x00ffffff; localPal[0xf0] = 0x00ffffff;
gp2x_video_setpalette(localPal, 0x100);
} else if (rendstatus & PDRAW_SONIC_MODE) { // mid-frame palette changes
vidConvCpyRGB32(localPal, Pico.cram, 0x40);
vidConvCpyRGB32(localPal+0x40, HighPal, 0x40);
vidConvCpyRGB32(localPal+0x80, HighPal+0x40, 0x40);
gp2x_video_setpalette(localPal, 0xc0);
} else {
vidConvCpyRGB32(localPal, Pico.cram, 0x40);
gp2x_video_setpalette(localPal, 0x40);
} }
gp2x_video_setpalette(localPal, pallen);
} }
} }

View file

@ -162,6 +162,9 @@ void emu_setDefaultConfig(void)
extern void amips_clut(unsigned short *dst, unsigned char *src, unsigned short *pal, int count); extern void amips_clut(unsigned short *dst, unsigned char *src, unsigned short *pal, int count);
extern void amips_clut_6bit(unsigned short *dst, unsigned char *src, unsigned short *pal, int count);
extern void (*amips_clut_f)(unsigned short *dst, unsigned char *src, unsigned short *pal, int count) = NULL;
struct Vertex struct Vertex
{ {
@ -235,7 +238,7 @@ static void set_scaling_params(void)
*/ */
} }
static void do_pal_update(int allow_sh) static void do_pal_update(int allow_sh, int allow_as)
{ {
unsigned int *dpal=(void *)localPal; unsigned int *dpal=(void *)localPal;
int i; int i;
@ -244,6 +247,9 @@ static void do_pal_update(int allow_sh)
// dpal[i] = ((spal[i]&0x000f000f)<< 1)|((spal[i]&0x00f000f0)<<3)|((spal[i]&0x0f000f00)<<4); // dpal[i] = ((spal[i]&0x000f000f)<< 1)|((spal[i]&0x00f000f0)<<3)|((spal[i]&0x0f000f00)<<4);
do_pal_convert(localPal, Pico.cram, currentConfig.gamma, currentConfig.gamma2); do_pal_convert(localPal, Pico.cram, currentConfig.gamma, currentConfig.gamma2);
Pico.m.dirtyPal = 0;
need_pal_upload = 1;
if (allow_sh && (Pico.video.reg[0xC]&8)) // shadow/hilight? if (allow_sh && (Pico.video.reg[0xC]&8)) // shadow/hilight?
{ {
// shadowed pixels // shadowed pixels
@ -260,8 +266,12 @@ static void do_pal_update(int allow_sh)
} }
localPal[0xe0] = 0; localPal[0xe0] = 0;
} }
Pico.m.dirtyPal = 0; else if (allow_as && (rendstatus & PDRAW_ACC_SPRITES))
need_pal_upload = 1; {
memcpy32(localPal+0x40, localPal, 0x40);
memcpy32(localPal+0x80, localPal, 0x40);
memcpy32(localPal+0xc0, localPal, 0x40);
}
} }
static void do_slowmode_lines(int line_to) static void do_slowmode_lines(int line_to)
@ -272,7 +282,7 @@ static void do_slowmode_lines(int line_to)
if (!(Pico.video.reg[1]&8)) { line = 8; dst += 512*8; src += 512*8; } if (!(Pico.video.reg[1]&8)) { line = 8; dst += 512*8; src += 512*8; }
for (; line < line_to; line++, dst+=512, src+=512) for (; line < line_to; line++, dst+=512, src+=512)
amips_clut(dst, src, localPal, line_len); amips_clut_f(dst, src, localPal, line_len);
} }
static void EmuScanPrepare(void) static void EmuScanPrepare(void)
@ -282,7 +292,10 @@ static void EmuScanPrepare(void)
dynamic_palette = 0; dynamic_palette = 0;
if (Pico.m.dirtyPal) if (Pico.m.dirtyPal)
do_pal_update(1); do_pal_update(1, 1);
if ((rendstatus & PDRAW_ACC_SPRITES) && !(Pico.video.reg[0xC]&8))
amips_clut_f = amips_clut_6bit;
else amips_clut_f = amips_clut;
} }
static int EmuScanSlowBegin(unsigned int num) static int EmuScanSlowBegin(unsigned int num)
@ -304,13 +317,13 @@ static int EmuScanSlowEnd(unsigned int num)
do_slowmode_lines(num); do_slowmode_lines(num);
dynamic_palette = 1; dynamic_palette = 1;
} }
do_pal_update(1); do_pal_update(1, 0);
} }
if (dynamic_palette) { if (dynamic_palette) {
int line_len = (Pico.video.reg[12]&1) ? 320 : 256; int line_len = (Pico.video.reg[12]&1) ? 320 : 256;
void *dst = (char *)VRAM_STUFF + 512*240 + 512*2*num; void *dst = (char *)VRAM_STUFF + 512*240 + 512*2*num;
amips_clut(dst, HighCol + 8, localPal, line_len); amips_clut_f(dst, HighCol + 8, localPal, line_len);
} }
return 0; return 0;
@ -344,7 +357,7 @@ static void blitscreen_clut(void)
} }
if ((PicoOpt&0x10) && Pico.m.dirtyPal) if ((PicoOpt&0x10) && Pico.m.dirtyPal)
do_pal_update(0); do_pal_update(0, 0);
sceKernelDcacheWritebackAll(); sceKernelDcacheWritebackAll();