rasterize: fix battles of prince of persia display failure regression

This commit is contained in:
zeromus 2009-06-20 17:45:39 +00:00
parent 869ecc2788
commit ec3a46782a
3 changed files with 23 additions and 8 deletions

View File

@ -382,9 +382,8 @@ void gfx3d_glFogOffset (u32 v)
void gfx3d_glClearDepth(u32 v) void gfx3d_glClearDepth(u32 v)
{ {
//formula from http://nocash.emubase.de/gbatek.htm#ds3drearplane
v &= 0x7FFF; v &= 0x7FFF;
gfx3d.clearDepth = (v*0x200)+((v+1)/0x8000)*0x01FF; gfx3d.clearDepth = gfx3d_extendDepth_15_to_24(v);
} }
void gfx3d_glMatrixMode(u32 v) void gfx3d_glMatrixMode(u32 v)

View File

@ -50,6 +50,11 @@
//produce a 15bpp color from individual 5bit components //produce a 15bpp color from individual 5bit components
#define R5G5B5TORGB15(r,g,b) ((r)|((g)<<5)|((b)<<10)) #define R5G5B5TORGB15(r,g,b) ((r)|((g)<<5)|((b)<<10))
inline u32 gfx3d_extendDepth_15_to_24(u32 depth)
{
//formula from http://nocash.emubase.de/gbatek.htm#ds3drearplane
return (depth*0x200)+((depth+1)>>15)*0x01FF;
}
#define TEXMODE_NONE 0 #define TEXMODE_NONE 0
#define TEXMODE_A3I5 1 #define TEXMODE_A3I5 1

View File

@ -467,10 +467,19 @@ static FORCEINLINE void pixel(int adr,float r, float g, float b, float invu, flo
} }
else else
{ {
float test = -1.2f; //the traditional value
u32 test2 = u32floor(test); depth = u32floor(z*0x7FFF);
//depth = u32floor(z*0x7FFF); //the traditional value
depth = u32floor(z*0xFFFFFF); //sonic chronicles uses depth clear and this makes it work //this would work in sonic chronicles but break battles of prince of persia
//depth = u32floor(z*0xFFFFFF);
//so we have this compromise:
depth = gfx3d_extendDepth_15_to_24(depth);
//some contemplation on the matter:
//it seems that everything in the ds uses 15 bit depths
//except that thedepth buffer is 24 bit. but nothing ever uses 24 bits!!!
//this makes no sense.
} }
if(polyAttr.decalMode) if(polyAttr.decalMode)
{ {
@ -481,7 +490,7 @@ static FORCEINLINE void pixel(int adr,float r, float g, float b, float invu, flo
} }
else else
{ {
if(depth>=destFragment.depth) if(depth>=destFragment.depth+1)
{ {
goto depth_fail; goto depth_fail;
} }
@ -599,6 +608,8 @@ static FORCEINLINE void pixel(int adr,float r, float g, float b, float invu, flo
destFragment.stencil = 1; destFragment.stencil = 1;
}*/ }*/
int zzz=9;
rejected_fragment: rejected_fragment:
done_with_pixel: done_with_pixel:
; ;
@ -1202,7 +1213,7 @@ static void SoftRastRender()
//masking off fog for now //masking off fog for now
depth &= 0x7FFF; depth &= 0x7FFF;
//TODO - might consider a lookup table for this //TODO - might consider a lookup table for this
dst->depth = (depth*0x200)+((depth+1)>>15)*0x01FF; dst->depth = gfx3d_extendDepth_15_to_24(depth);
clearDepth++; clearDepth++;
clearImage++; clearImage++;