1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-07-02 09:03:37 +00:00

Fix fillcolor processing. Fillcolor has the same bitness as the color image.

This commit is contained in:
Sergey Lipskiy 2013-06-04 22:41:56 +07:00
parent 797dfad57e
commit 657a576946
2 changed files with 23 additions and 8 deletions

28
gDP.cpp
View File

@ -465,11 +465,7 @@ void gDPSetFogColor( u32 r, u32 g, u32 b, u32 a )
void gDPSetFillColor( u32 c )
{
gDP.fillColor.r = _SHIFTR( c, 11, 5 ) * 0.032258064f;
gDP.fillColor.g = _SHIFTR( c, 6, 5 ) * 0.032258064f;
gDP.fillColor.b = _SHIFTR( c, 1, 5 ) * 0.032258064f;
gDP.fillColor.a = (f32)_SHIFTR( c, 0, 1 );
gDP.fillColor.color = c;
gDP.fillColor.z = (f32)_SHIFTR( c, 2, 14 );
gDP.fillColor.dz = (f32)_SHIFTR( c, 0, 2 );
@ -478,6 +474,22 @@ void gDPSetFillColor( u32 c )
#endif
}
void gDPGetFillColor(f32 _fillColor[4])
{
const u32 c = gDP.fillColor.color;
if (gDP.colorImage.size < 3) {
_fillColor[0] = _SHIFTR( c, 11, 5 ) * 0.032258064f;
_fillColor[1] = _SHIFTR( c, 6, 5 ) * 0.032258064f;
_fillColor[2] = _SHIFTR( c, 1, 5 ) * 0.032258064f;
_fillColor[3] = (f32)_SHIFTR( c, 0, 1 );
} else {
_fillColor[0] = _SHIFTR( c, 24, 8 ) * 0.0039215686f;
_fillColor[1] = _SHIFTR( c, 16, 8 ) * 0.0039215686f;
_fillColor[2] = _SHIFTR( c, 8, 8 ) * 0.0039215686f;
_fillColor[3] = _SHIFTR( c, 0, 8 ) * 0.0039215686f;
}
}
void gDPSetPrimColor( u32 m, u32 l, u32 r, u32 g, u32 b, u32 a )
{
gDP.primColor.m = m * 0.0039215689f;
@ -783,6 +795,8 @@ void gDPFillRectangle( s32 ulx, s32 uly, s32 lrx, s32 lry )
return;
}
f32 fillColor[4];
gDPGetFillColor(fillColor);
if (gDP.otherMode.cycleType == G_CYC_FILL)
{
//if (gDP.fillColor.a == 0.0f)
@ -793,12 +807,12 @@ void gDPFillRectangle( s32 ulx, s32 uly, s32 lrx, s32 lry )
if ((ulx == 0) && (uly == 0) && (lrx == VI.width) && (lry == VI.height))
{
OGL_ClearColorBuffer( &gDP.fillColor.r );
OGL_ClearColorBuffer( fillColor );
return;
}
}
OGL_DrawRect( ulx, uly, lrx, lry, (gDP.otherMode.cycleType == G_CYC_FILL) ? &gDP.fillColor.r : &gDP.blendColor.r );
OGL_DrawRect( ulx, uly, lrx, lry, (gDP.otherMode.cycleType == G_CYC_FILL) ? fillColor : &gDP.blendColor.r );
if (depthBuffer.top) depthBuffer.top->cleared = FALSE;
gDP.colorImage.changed = TRUE;

3
gDP.h
View File

@ -168,8 +168,8 @@ struct gDPInfo
struct
{
f32 r, g, b, a;
f32 z, dz;
u32 color;
} fillColor;
struct
@ -257,6 +257,7 @@ void gDPSetEnvColor( u32 r, u32 g, u32 b, u32 a );
void gDPSetBlendColor( u32 r, u32 g, u32 b, u32 a );
void gDPSetFogColor( u32 r, u32 g, u32 b, u32 a );
void gDPSetFillColor( u32 c );
void gDPGetFillColor(f32 _fillColor[4]);
void gDPSetPrimColor( u32 m, u32 l, u32 r, u32 g, u32 b, u32 a );
void gDPSetTile( u32 format, u32 size, u32 line, u32 tmem, u32 tile, u32 palette, u32 cmt, u32 cms, u32 maskt, u32 masks, u32 shiftt, u32 shifts );
void gDPSetTileSize( u32 tile, u32 uls, u32 ult, u32 lrs, u32 lrt );