Changed sprite blitting to draw them directly on GPU_screen instead of a separate buffer.
We'll now be able to do proper sprite blending.
This commit is contained in:
parent
f538364e3b
commit
17f285d455
|
@ -266,6 +266,8 @@ void GPU_Reset(GPU *g, u8 l)
|
|||
|
||||
g->spriteRender = sprite1D;
|
||||
|
||||
g->bgPrio[4] = 4;
|
||||
|
||||
if(g->core == GPU_SUB)
|
||||
{
|
||||
g->oam = (OAM *)(ARM9Mem.ARM9_OAM + ADDRESS_STEP_1KB);
|
||||
|
@ -478,6 +480,8 @@ void GPU_setBGProp(GPU * gpu, u16 num, u16 p)
|
|||
mode = mode2type[dispCnt->BG_Mode][num];
|
||||
gpu->BGSize[num][0] = sizeTab[mode][cnt->ScreenSize][0];
|
||||
gpu->BGSize[num][1] = sizeTab[mode][cnt->ScreenSize][1];
|
||||
|
||||
gpu->bgPrio[num] = (p & 0x3);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -593,6 +597,7 @@ static BOOL setFinalBGColorSpecialNone (GPU *gpu, u32 passing, u8 bgnum, u8 *dst
|
|||
|
||||
T2WriteWord(dst, passing, color);
|
||||
gpu->bgPixels[x] = bgnum;
|
||||
gpu->bgPxPrio[x] = gpu->bgPrio[bgnum];
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -628,11 +633,13 @@ static BOOL setFinalBGColorSpecialBlend (GPU *gpu, u32 passing, u8 bgnum, u8 *ds
|
|||
|
||||
T2WriteWord(dst, passing, color);
|
||||
gpu->bgPixels[x] = bgnum;
|
||||
gpu->bgPxPrio[x] = gpu->bgPrio[bgnum];
|
||||
}
|
||||
else
|
||||
{
|
||||
T2WriteWord(dst, passing, color);
|
||||
gpu->bgPixels[x] = bgnum;
|
||||
gpu->bgPxPrio[x] = gpu->bgPrio[bgnum];
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
@ -659,11 +666,13 @@ static BOOL setFinalBGColorSpecialIncrease (GPU *gpu, u32 passing, u8 bgnum, u8
|
|||
|
||||
T2WriteWord(dst, passing, color) ;
|
||||
gpu->bgPixels[x] = bgnum;
|
||||
gpu->bgPxPrio[x] = gpu->bgPrio[bgnum];
|
||||
}
|
||||
else
|
||||
{
|
||||
T2WriteWord(dst, passing, color);
|
||||
gpu->bgPixels[x] = bgnum;
|
||||
gpu->bgPxPrio[x] = gpu->bgPrio[bgnum];
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
@ -689,11 +698,13 @@ static BOOL setFinalBGColorSpecialDecrease (GPU *gpu, u32 passing, u8 bgnum, u8
|
|||
}
|
||||
T2WriteWord(dst, passing, color) ;
|
||||
gpu->bgPixels[x] = bgnum;
|
||||
gpu->bgPxPrio[x] = gpu->bgPrio[bgnum];
|
||||
}
|
||||
else
|
||||
{
|
||||
T2WriteWord(dst, passing, color);
|
||||
gpu->bgPixels[x] = bgnum;
|
||||
gpu->bgPxPrio[x] = gpu->bgPrio[bgnum];
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
@ -709,6 +720,7 @@ static BOOL setFinalBGColorSpecialNoneWnd (GPU *gpu, u32 passing, u8 bgnum, u8 *
|
|||
{
|
||||
T2WriteWord(dst, passing, color);
|
||||
gpu->bgPixels[x] = bgnum;
|
||||
gpu->bgPxPrio[x] = gpu->bgPrio[bgnum];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -716,6 +728,7 @@ static BOOL setFinalBGColorSpecialNoneWnd (GPU *gpu, u32 passing, u8 bgnum, u8 *
|
|||
{
|
||||
T2WriteWord(dst, passing, color);
|
||||
gpu->bgPixels[x] = bgnum;
|
||||
gpu->bgPxPrio[x] = gpu->bgPrio[bgnum];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -759,6 +772,7 @@ static BOOL setFinalBGColorSpecialBlendWnd (GPU *gpu, u32 passing, u8 bgnum, u8
|
|||
|
||||
T2WriteWord(dst, passing, color);
|
||||
gpu->bgPixels[x] = bgnum;
|
||||
gpu->bgPxPrio[x] = gpu->bgPrio[bgnum];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -766,6 +780,7 @@ static BOOL setFinalBGColorSpecialBlendWnd (GPU *gpu, u32 passing, u8 bgnum, u8
|
|||
{
|
||||
T2WriteWord(dst, passing, color);
|
||||
gpu->bgPixels[x] = bgnum;
|
||||
gpu->bgPxPrio[x] = gpu->bgPrio[bgnum];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -797,6 +812,7 @@ static BOOL setFinalBGColorSpecialIncreaseWnd (GPU *gpu, u32 passing, u8 bgnum,
|
|||
|
||||
T2WriteWord(dst, passing, color) ;
|
||||
gpu->bgPixels[x] = bgnum;
|
||||
gpu->bgPxPrio[x] = gpu->bgPrio[bgnum];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -804,6 +820,7 @@ static BOOL setFinalBGColorSpecialIncreaseWnd (GPU *gpu, u32 passing, u8 bgnum,
|
|||
{
|
||||
T2WriteWord(dst, passing, color);
|
||||
gpu->bgPixels[x] = bgnum;
|
||||
gpu->bgPxPrio[x] = gpu->bgPrio[bgnum];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -834,6 +851,7 @@ static BOOL setFinalBGColorSpecialDecreaseWnd (GPU *gpu, u32 passing, u8 bgnum,
|
|||
}
|
||||
T2WriteWord(dst, passing, color) ;
|
||||
gpu->bgPixels[x] = bgnum;
|
||||
gpu->bgPxPrio[x] = gpu->bgPrio[bgnum];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -841,6 +859,7 @@ static BOOL setFinalBGColorSpecialDecreaseWnd (GPU *gpu, u32 passing, u8 bgnum,
|
|||
{
|
||||
T2WriteWord(dst, passing, color);
|
||||
gpu->bgPixels[x] = bgnum;
|
||||
gpu->bgPxPrio[x] = gpu->bgPrio[bgnum];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -855,6 +874,7 @@ static BOOL setFinal3DColorSpecialNone(GPU *gpu, u32 passing, u8 *dst, u16 color
|
|||
{
|
||||
T2WriteWord(dst, passing, (color | 0x8000));
|
||||
gpu->bgPixels[x] = 0;
|
||||
gpu->bgPxPrio[x] = gpu->bgPrio[0];
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -896,11 +916,13 @@ static BOOL setFinal3DColorSpecialBlend(GPU *gpu, u32 passing, u8 *dst, u16 colo
|
|||
|
||||
T2WriteWord(dst, passing, (final | 0x8000));
|
||||
gpu->bgPixels[x] = 0;
|
||||
gpu->bgPxPrio[x] = gpu->bgPrio[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
T2WriteWord(dst, passing, (color | 0x8000));
|
||||
gpu->bgPixels[x] = 0;
|
||||
gpu->bgPxPrio[x] = gpu->bgPrio[0];
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
@ -917,11 +939,13 @@ static BOOL setFinal3DColorSpecialIncrease(GPU *gpu, u32 passing, u8 *dst, u16 c
|
|||
|
||||
T2WriteWord(dst, passing, (color | 0x8000));
|
||||
gpu->bgPixels[x] = 0;
|
||||
gpu->bgPxPrio[x] = gpu->bgPrio[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
T2WriteWord(dst, passing, (color | 0x8000));
|
||||
gpu->bgPixels[x] = 0;
|
||||
gpu->bgPxPrio[x] = gpu->bgPrio[0];
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
@ -938,11 +962,13 @@ static BOOL setFinal3DColorSpecialDecrease(GPU *gpu, u32 passing, u8 *dst, u16 c
|
|||
|
||||
T2WriteWord(dst, passing, (color | 0x8000));
|
||||
gpu->bgPixels[x] = 0;
|
||||
gpu->bgPxPrio[x] = gpu->bgPrio[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
T2WriteWord(dst, passing, (color | 0x8000));
|
||||
gpu->bgPixels[x] = 0;
|
||||
gpu->bgPxPrio[x] = gpu->bgPrio[0];
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
@ -958,6 +984,7 @@ static BOOL setFinal3DColorSpecialNoneWnd(GPU *gpu, u32 passing, u8 *dst, u16 co
|
|||
{
|
||||
T2WriteWord(dst, passing, (color | 0x8000));
|
||||
gpu->bgPixels[x] = 0;
|
||||
gpu->bgPxPrio[x] = gpu->bgPrio[0];
|
||||
}
|
||||
|
||||
return windowDraw;
|
||||
|
@ -1007,11 +1034,13 @@ static BOOL setFinal3DColorSpecialBlendWnd(GPU *gpu, u32 passing, u8 *dst, u16 c
|
|||
|
||||
T2WriteWord(dst, passing, (final | 0x8000));
|
||||
gpu->bgPixels[x] = 0;
|
||||
gpu->bgPxPrio[x] = gpu->bgPrio[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
T2WriteWord(dst, passing, (color | 0x8000));
|
||||
gpu->bgPixels[x] = 0;
|
||||
gpu->bgPxPrio[x] = gpu->bgPrio[0];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1035,11 +1064,13 @@ static BOOL setFinal3DColorSpecialIncreaseWnd(GPU *gpu, u32 passing, u8 *dst, u1
|
|||
|
||||
T2WriteWord(dst, passing, (color | 0x8000));
|
||||
gpu->bgPixels[x] = 0;
|
||||
gpu->bgPxPrio[x] = gpu->bgPrio[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
T2WriteWord(dst, passing, (color | 0x8000));
|
||||
gpu->bgPixels[x] = 0;
|
||||
gpu->bgPxPrio[x] = gpu->bgPrio[0];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1063,11 +1094,13 @@ static BOOL setFinal3DColorSpecialDecreaseWnd(GPU *gpu, u32 passing, u8 *dst, u1
|
|||
|
||||
T2WriteWord(dst, passing, (color | 0x8000));
|
||||
gpu->bgPixels[x] = 0;
|
||||
gpu->bgPxPrio[x] = gpu->bgPrio[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
T2WriteWord(dst, passing, (color | 0x8000));
|
||||
gpu->bgPixels[x] = 0;
|
||||
gpu->bgPxPrio[x] = gpu->bgPrio[0];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1534,12 +1567,14 @@ INLINE void render_sprite_BMP (GPU * gpu, u16 l, u8 * dst, u16 * src, u8 * prioT
|
|||
color = LE_TO_LOCAL_16(src[x]);
|
||||
|
||||
// alpha bit = invisible
|
||||
if ((color&0x8000)&&(prio<=prioTab[sprX]))
|
||||
/*if ((color&0x8000)&&(prio<=prioTab[sprX]))
|
||||
{
|
||||
/* if we don't draw, do not set prio, or else */
|
||||
/* if we don't draw, do not set prio, or else *-/
|
||||
if (gpu->setFinalColorSpr(gpu, sprX << 1,4,dst, color, sprX))
|
||||
prioTab[sprX] = prio;
|
||||
}
|
||||
}*/
|
||||
if ((color&0x8000) && (prio <= gpu->bgPxPrio[sprX]))
|
||||
gpu->setFinalColorSpr(gpu, sprX << 1,4,dst, color, sprX);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1556,12 +1591,14 @@ INLINE void render_sprite_256 ( GPU * gpu, u16 l, u8 * dst, u8 * src, u16 * pal,
|
|||
color = LE_TO_LOCAL_16(pal[palette_entry]);
|
||||
|
||||
// palette entry = 0 means backdrop
|
||||
if ((palette_entry>0)&&(prio<=prioTab[sprX]))
|
||||
/*if ((palette_entry>0)&&(prio<=prioTab[sprX]))
|
||||
{
|
||||
/* if we don't draw, do not set prio, or else */
|
||||
/* if we don't draw, do not set prio, or else *-/
|
||||
if (gpu->setFinalColorSpr(gpu, sprX << 1,4,dst, color, sprX))
|
||||
prioTab[sprX] = prio;
|
||||
}
|
||||
}*/
|
||||
if ((palette_entry>0) && (prio <= gpu->bgPxPrio[sprX]))
|
||||
gpu->setFinalColorSpr(gpu, sprX << 1,4,dst, color, sprX);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1581,12 +1618,14 @@ INLINE void render_sprite_16 ( GPU * gpu, u16 l, u8 * dst, u8 * src, u16 * pal,
|
|||
color = LE_TO_LOCAL_16(pal[palette_entry]);
|
||||
|
||||
// palette entry = 0 means backdrop
|
||||
if ((palette_entry>0)&&(prio<=prioTab[sprX]))
|
||||
/*if ((palette_entry>0)&&(prio<=prioTab[sprX]))
|
||||
{
|
||||
/* if we don't draw, do not set prio, or else */
|
||||
/* if we don't draw, do not set prio, or else *-/
|
||||
if (gpu->setFinalColorSpr(gpu, sprX << 1,4,dst, color, sprX ))
|
||||
prioTab[sprX] = prio;
|
||||
}
|
||||
}*/
|
||||
if ((palette_entry>0) && (prio <= gpu->bgPxPrio[sprX]))
|
||||
gpu->setFinalColorSpr(gpu, sprX << 1,4,dst, color, sprX);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1790,11 +1829,13 @@ void sprite1D(GPU * gpu, u16 l, u8 * dst, u8 * prioTab)
|
|||
offset = (auxX&0x7) + ((auxX&0xFFF8)<<3) + ((auxY>>3)*sprSize.x*8) + ((auxY&0x7)*8);
|
||||
colour = src[offset];
|
||||
|
||||
if (colour && (prioTab[sprX]>=prio))
|
||||
/* if (colour && (prioTab[sprX]>=prio))
|
||||
{
|
||||
if (gpu->setFinalColorSpr(gpu, sprX << 1, 4, dst, T1ReadWord(pal, colour<<1), sprX ))
|
||||
prioTab[sprX] = prio;
|
||||
}
|
||||
}*/
|
||||
if ((colour) && (prio <= gpu->bgPxPrio[sprX]))
|
||||
gpu->setFinalColorSpr(gpu, sprX << 1,4,dst, T1ReadWord(pal, colour<<1), sprX);
|
||||
}
|
||||
|
||||
// Add the rotation/scale coeficients, here the rotation/scaling
|
||||
|
@ -1825,11 +1866,13 @@ void sprite1D(GPU * gpu, u16 l, u8 * dst, u8 * prioTab)
|
|||
offset = (auxX) + (auxY<<5);
|
||||
colour = T1ReadWord (src, offset<<1);
|
||||
|
||||
if((colour&0x8000) && (prioTab[sprX]>=prio))
|
||||
/*if((colour&0x8000) && (prioTab[sprX]>=prio))
|
||||
{
|
||||
if (gpu->setFinalColorSpr(gpu, sprX << 1, 4, dst, colour, sprX))
|
||||
prioTab[sprX] = prio;
|
||||
}
|
||||
}*/
|
||||
if ((colour&0x8000) && (prio <= gpu->bgPxPrio[sprX]))
|
||||
gpu->setFinalColorSpr(gpu, sprX << 1,4,dst, colour, sprX);
|
||||
}
|
||||
|
||||
// Add the rotation/scale coeficients, here the rotation/scaling
|
||||
|
@ -1862,11 +1905,13 @@ void sprite1D(GPU * gpu, u16 l, u8 * dst, u8 * prioTab)
|
|||
if (auxX&1) colour >>= 4;
|
||||
else colour &= 0xF;
|
||||
|
||||
if(colour && (prioTab[sprX]>=prio))
|
||||
/* if(colour && (prioTab[sprX]>=prio))
|
||||
{
|
||||
if (gpu->setFinalColorSpr(gpu, sprX << 1, 4, dst, T1ReadWord(pal, colour<<1), sprX ))
|
||||
prioTab[sprX] = prio;
|
||||
}
|
||||
}*/
|
||||
if ((colour) && (prio <= gpu->bgPxPrio[sprX]))
|
||||
gpu->setFinalColorSpr(gpu, sprX << 1,4,dst, T1ReadWord(pal, colour<<1), sprX);
|
||||
}
|
||||
|
||||
// Add the rotation/scale coeficients, here the rotation/scaling
|
||||
|
@ -2076,11 +2121,13 @@ void sprite2D(GPU * gpu, u16 l, u8 * dst, u8 * prioTab)
|
|||
offset = (auxX&0x7) + ((auxX&0xFFF8)<<3) + ((auxY>>3)<<10) + ((auxY&0x7)*8);
|
||||
colour = src[offset];
|
||||
|
||||
if (colour && (prioTab[sprX]>=prio))
|
||||
/* if (colour && (prioTab[sprX]>=prio))
|
||||
{
|
||||
if (gpu->setFinalColorSpr(gpu, sprX << 1, 4, dst, T1ReadWord(pal, colour<<1), sprX ))
|
||||
prioTab[sprX] = prio;
|
||||
}
|
||||
}*/
|
||||
if ((colour) && (prio <= gpu->bgPxPrio[sprX]))
|
||||
gpu->setFinalColorSpr(gpu, sprX << 1,4,dst, T1ReadWord(pal, colour<<1), sprX);
|
||||
}
|
||||
|
||||
// Add the rotation/scale coeficients, here the rotation/scaling
|
||||
|
@ -2111,11 +2158,13 @@ void sprite2D(GPU * gpu, u16 l, u8 * dst, u8 * prioTab)
|
|||
offset = auxX + (auxY<<8);
|
||||
colour = T1ReadWord(src, offset<<1);
|
||||
|
||||
if((colour&0x8000) && (prioTab[sprX]>=prio))
|
||||
/* if((colour&0x8000) && (prioTab[sprX]>=prio))
|
||||
{
|
||||
if (gpu->setFinalColorSpr(gpu, sprX << 1, 4, dst, colour, sprX ))
|
||||
prioTab[sprX] = prio;
|
||||
}
|
||||
}*/
|
||||
if ((colour&0x8000) && (prio <= gpu->bgPxPrio[sprX]))
|
||||
gpu->setFinalColorSpr(gpu, sprX << 1,4,dst, colour, sprX);
|
||||
}
|
||||
|
||||
// Add the rotation/scale coeficients, here the rotation/scaling
|
||||
|
@ -2147,11 +2196,13 @@ void sprite2D(GPU * gpu, u16 l, u8 * dst, u8 * prioTab)
|
|||
if (auxX&1) colour >>= 4;
|
||||
else colour &= 0xF;
|
||||
|
||||
if(colour && (prioTab[sprX]>=prio))
|
||||
/* if(colour && (prioTab[sprX]>=prio))
|
||||
{
|
||||
if (gpu->setFinalColorSpr(gpu, sprX << 1,4,dst, T1ReadWord (pal, colour<<1), sprX))
|
||||
prioTab[sprX] = prio;
|
||||
}
|
||||
}*/
|
||||
if ((colour) && (prio <= gpu->bgPxPrio[sprX]))
|
||||
gpu->setFinalColorSpr(gpu, sprX << 1,4,dst, T1ReadWord(pal, colour<<1), sprX);
|
||||
}
|
||||
|
||||
// Add the rotation/scale coeficients, here the rotation/scaling
|
||||
|
@ -2436,6 +2487,8 @@ static void GPU_ligne_layer(NDS_Screen * screen, u16 l)
|
|||
/* reset them to backdrop */
|
||||
memset(gpu->bgPixels, 5, 256);
|
||||
|
||||
memset(gpu->bgPxPrio, 0xFF, 256);
|
||||
|
||||
if (!gpu->LayersEnable[0] && !gpu->LayersEnable[1] &&
|
||||
!gpu->LayersEnable[2] && !gpu->LayersEnable[3] &&
|
||||
!gpu->LayersEnable[4]) return;
|
||||
|
@ -2450,7 +2503,7 @@ static void GPU_ligne_layer(NDS_Screen * screen, u16 l)
|
|||
}
|
||||
|
||||
// for all the pixels in the line
|
||||
if (gpu->LayersEnable[4])
|
||||
/*if (gpu->LayersEnable[4])
|
||||
{
|
||||
for(int i = 0; i< 256; ++i) T2WriteWord(spr, i << 1, c);
|
||||
gpu->spriteRender(gpu, l, spr, sprPrio);
|
||||
|
@ -2465,7 +2518,7 @@ static void GPU_ligne_layer(NDS_Screen * screen, u16 l)
|
|||
item->PixelsX[item->nbPixelsX]=i;
|
||||
item->nbPixelsX++;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
if (!gpu->LayersEnable[0] && !gpu->LayersEnable[1] && !gpu->LayersEnable[2] && !gpu->LayersEnable[3])
|
||||
|
@ -2516,15 +2569,18 @@ static void GPU_ligne_layer(NDS_Screen * screen, u16 l)
|
|||
}
|
||||
}
|
||||
// render sprite Pixels
|
||||
if (gpu->LayersEnable[4])
|
||||
/* if (gpu->LayersEnable[4])
|
||||
{
|
||||
for (int i=0; i < item->nbPixelsX; i++)
|
||||
{
|
||||
i16=item->PixelsX[i];
|
||||
T2WriteWord(dst, i16 << 1, T2ReadWord(spr, i16 << 1));
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
if(gpu->LayersEnable[4])
|
||||
gpu->spriteRender(gpu, l, dst, sprPrio);
|
||||
}
|
||||
|
||||
// TODO: capture emulated not fully
|
||||
|
|
|
@ -622,6 +622,8 @@ struct _GPU
|
|||
BOOL dispBG[4];
|
||||
BOOL dispOBJ;
|
||||
|
||||
u8 bgPrio[5];
|
||||
|
||||
OAM * oam;
|
||||
u32 sprMem;
|
||||
u8 sprBoundary;
|
||||
|
@ -662,6 +664,7 @@ struct _GPU
|
|||
u32 MasterBrightFactor;
|
||||
|
||||
u8 bgPixels[256];
|
||||
u8 bgPxPrio[256];
|
||||
u8 currLine;
|
||||
|
||||
BOOL (*setFinalColorSpr)(GPU *gpu, u32 passing, u8 bgnum, u8 *dst, u16 color, u16 x);
|
||||
|
|
Loading…
Reference in New Issue