Re-creating the release branch from r1302.

This commit is contained in:
yabause 2008-12-30 14:37:44 +00:00
parent d386158e49
commit 432170a3c3
297 changed files with 62 additions and 353 deletions

View File

View File

View File

@ -3,7 +3,7 @@
#include "types.h"
struct ALIGN(16) ARM9_struct {
typedef ALIGN(16) struct {
//ARM9 mem
u8 ARM9_ITCM[0x8000];
u8 ARM9_DTCM[0x4000];
@ -25,7 +25,7 @@ struct ALIGN(16) ARM9_struct {
u8 *textureSlotAddr[4];
u8 *blank_memory[0x20000];
};
} ARM9_struct;
extern ARM9_struct ARM9Mem;

View File

@ -139,51 +139,31 @@ NULL
};
//static BOOL setFinalColorDirect (const GPU *gpu, u32 passing, u8 bgnum, u8 *dst, u16 color, u16 x, u16 y);
static BOOL setFinalBGColorSpecialNone (GPU *gpu, u32 passing, u8 bgnum, u8 *dst, u16 color, u16 x, u16 y);
static BOOL setFinalBGColorSpecialBlend (GPU *gpu, u32 passing, u8 bgnum, u8 *dst, u16 color, u16 x, u16 y);
static BOOL setFinalBGColorSpecialIncrease (GPU *gpu, u32 passing, u8 bgnum, u8 *dst, u16 color, u16 x, u16 y);
static BOOL setFinalBGColorSpecialDecrease (GPU *gpu, u32 passing, u8 bgnum, u8 *dst, u16 color, u16 x, u16 y);
static BOOL setFinalColorSpecialNone (const GPU *gpu, u32 passing, u8 bgnum, u8 *dst, u16 color, u16 x, u16 y);
static BOOL setFinalColorSpecialBlend (const GPU *gpu, u32 passing, u8 bgnum, u8 *dst, u16 color, u16 x, u16 y);
static BOOL setFinalColorSpecialIncrease (const GPU *gpu, u32 passing, u8 bgnum, u8 *dst, u16 color, u16 x, u16 y);
static BOOL setFinalColorSpecialDecrease (const GPU *gpu, u32 passing, u8 bgnum, u8 *dst, u16 color, u16 x, u16 y);
//static BOOL setFinalColorDirectWnd (const GPU *gpu, u32 passing, u8 bgnum, u8 *dst, u16 color, u16 x, u16 y);
static BOOL setFinalBGColorSpecialNoneWnd (GPU *gpu, u32 passing, u8 bgnum, u8 *dst, u16 color, u16 x, u16 y);
static BOOL setFinalBGColorSpecialBlendWnd (GPU *gpu, u32 passing, u8 bgnum, u8 *dst, u16 color, u16 x, u16 y);
static BOOL setFinalBGColorSpecialIncreaseWnd (GPU *gpu, u32 passing, u8 bgnum, u8 *dst, u16 color, u16 x, u16 y);
static BOOL setFinalBGColorSpecialDecreaseWnd (GPU *gpu, u32 passing, u8 bgnum, u8 *dst, u16 color, u16 x, u16 y);
static BOOL setFinal3DColorSpecialNone (GPU *gpu, u32 passing, u8 *dst, u16 color, u8 alpha, u16 x, u16 y);
static BOOL setFinal3DColorSpecialBlend (GPU *gpu, u32 passing, u8 *dst, u16 color, u8 alpha, u16 x, u16 y);
static BOOL setFinal3DColorSpecialIncrease (GPU *gpu, u32 passing, u8 *dst, u16 color, u8 alpha, u16 x, u16 y);
static BOOL setFinal3DColorSpecialDecrease (GPU *gpu, u32 passing, u8 *dst, u16 color, u8 alpha, u16 x, u16 y);
static BOOL setFinal3DColorSpecialNoneWnd (GPU *gpu, u32 passing, u8 *dst, u16 color, u8 alpha, u16 x, u16 y);
static BOOL setFinal3DColorSpecialBlendWnd (GPU *gpu, u32 passing, u8 *dst, u16 color, u8 alpha, u16 x, u16 y);
static BOOL setFinal3DColorSpecialIncreaseWnd (GPU *gpu, u32 passing, u8 *dst, u16 color, u8 alpha, u16 x, u16 y);
static BOOL setFinal3DColorSpecialDecreaseWnd (GPU *gpu, u32 passing, u8 *dst, u16 color, u8 alpha, u16 x, u16 y);
static BOOL setFinalColorSpecialNoneWnd (const GPU *gpu, u32 passing, u8 bgnum, u8 *dst, u16 color, u16 x, u16 y);
static BOOL setFinalColorSpecialBlendWnd (const GPU *gpu, u32 passing, u8 bgnum, u8 *dst, u16 color, u16 x, u16 y);
static BOOL setFinalColorSpecialIncreaseWnd (const GPU *gpu, u32 passing, u8 bgnum, u8 *dst, u16 color, u16 x, u16 y);
static BOOL setFinalColorSpecialDecreaseWnd (const GPU *gpu, u32 passing, u8 bgnum, u8 *dst, u16 color, u16 x, u16 y);
typedef BOOL (*FinalBGColFunct)(GPU *gpu, u32 passing, u8 bgnum, u8 *dst, u16 color, u16 x, u16 y);
typedef BOOL (*Final3DColFunct)(GPU *gpu, u32 passing, u8 *dst, u16 color, u8 alpha, u16 x, u16 y);
typedef BOOL (*FinalColFunct)(const GPU *gpu, u32 passing, u8 bgnum, u8 *dst, u16 color, u16 x, u16 y);
FinalBGColFunct pixelBlittersBG[8] = { //setFinalColorDirect,
setFinalBGColorSpecialNone,
setFinalBGColorSpecialBlend,
setFinalBGColorSpecialIncrease,
setFinalBGColorSpecialDecrease,
FinalColFunct pixelBlitters[8] = { //setFinalColorDirect,
setFinalColorSpecialNone,
setFinalColorSpecialBlend,
setFinalColorSpecialIncrease,
setFinalColorSpecialDecrease,
//setFinalColorDirectWnd,
setFinalBGColorSpecialNoneWnd,
setFinalBGColorSpecialBlendWnd,
setFinalBGColorSpecialIncreaseWnd,
setFinalBGColorSpecialDecreaseWnd};
Final3DColFunct pixelBlitters3D[8] = {
setFinal3DColorSpecialNone,
setFinal3DColorSpecialBlend,
setFinal3DColorSpecialIncrease,
setFinal3DColorSpecialDecrease,
setFinal3DColorSpecialNoneWnd,
setFinal3DColorSpecialBlendWnd,
setFinal3DColorSpecialIncreaseWnd,
setFinal3DColorSpecialDecreaseWnd};
setFinalColorSpecialNoneWnd,
setFinalColorSpecialBlendWnd,
setFinalColorSpecialIncreaseWnd,
setFinalColorSpecialDecreaseWnd};
u16 fadeInColors[17][0x8000];
u16 fadeOutColors[17][0x8000];
@ -223,9 +203,8 @@ GPU * GPU_Init(u8 l)
}
}
g->setFinalColorBck = setFinalBGColorSpecialNone;
g->setFinalColorSpr = setFinalBGColorSpecialNone;
g->setFinalColor3D = setFinal3DColorSpecialNone;
g->setFinalColorBck = setFinalColorSpecialNone;
g->setFinalColorSpr = setFinalColorSpecialNone;
return g;
}
@ -234,9 +213,8 @@ void GPU_Reset(GPU *g, u8 l)
{
memset(g, 0, sizeof(GPU));
g->setFinalColorBck = setFinalBGColorSpecialNone;
g->setFinalColorSpr = setFinalBGColorSpecialNone;
g->setFinalColor3D = setFinal3DColorSpecialNone;
g->setFinalColorBck = setFinalColorSpecialNone;
g->setFinalColorSpr = setFinalColorSpecialNone;
g->core = l;
g->BGSize[0][0] = g->BGSize[1][0] = g->BGSize[2][0] = g->BGSize[3][0] = 256;
g->BGSize[0][1] = g->BGSize[1][1] = g->BGSize[2][1] = g->BGSize[3][1] = 256;
@ -341,9 +319,8 @@ void SetupFinalPixelBlitter (GPU *gpu)
u8 windowUsed = (gpu->WIN0_ENABLED | gpu->WIN1_ENABLED | gpu->WINOBJ_ENABLED);
u8 blendMode = (gpu->BLDCNT >> 6)&3;
gpu->setFinalColorSpr = pixelBlittersBG[windowUsed*4 + blendMode];
gpu->setFinalColorBck = pixelBlittersBG[windowUsed*4 + blendMode];
gpu->setFinalColor3D = pixelBlitters3D[windowUsed*4 + blendMode];
gpu->setFinalColorSpr = pixelBlitters[windowUsed*4 + blendMode];
gpu->setFinalColorBck = pixelBlitters[windowUsed*4 + blendMode];
}
/* Sets up LCD control variables for Display Engines A and B for quick reading */
@ -558,10 +535,10 @@ static INLINE void renderline_checkWindows(const GPU *gpu, u8 bgnum, u16 x, u16
}
/*****************************************************************************/
// PIXEL RENDERING - BGS
// PIXEL RENDERING
/*****************************************************************************/
static BOOL setFinalBGColorSpecialNone (GPU *gpu, u32 passing, u8 bgnum, u8 *dst, u16 color, u16 x, u16 y)
static BOOL setFinalColorSpecialNone (const GPU *gpu, u32 passing, u8 bgnum, u8 *dst, u16 color, u16 x, u16 y)
{
//sprwin test hack - use this code
//BOOL windowDraw = TRUE, windowEffect = TRUE;
@ -570,11 +547,10 @@ static BOOL setFinalBGColorSpecialNone (GPU *gpu, u32 passing, u8 bgnum, u8 *dst
//return 1;
T2WriteWord(dst, passing, color);
gpu->bgPixels[x] = bgnum;
return 1;
}
static BOOL setFinalBGColorSpecialBlend (GPU *gpu, u32 passing, u8 bgnum, u8 *dst, u16 color, u16 x, u16 y)
static BOOL setFinalColorSpecialBlend (const GPU *gpu, u32 passing, u8 bgnum, u8 *dst, u16 color, u16 x, u16 y)
{
if ((gpu->BLDCNT >> bgnum)&1 && gpu->BLDALPHA_EVA)
{
@ -605,18 +581,16 @@ static BOOL setFinalBGColorSpecialBlend (GPU *gpu, u32 passing, u8 bgnum, u8 *ds
color = (sourceR & 0x1F) | ((sourceG & 0x1F) << 5) | ((sourceB & 0x1F) << 10) | 0x8000 ;
T2WriteWord(dst, passing, color);
gpu->bgPixels[x] = bgnum;
}
else
{
T2WriteWord(dst, passing, color);
gpu->bgPixels[x] = bgnum;
}
return 1;
}
static BOOL setFinalBGColorSpecialIncrease (GPU *gpu, u32 passing, u8 bgnum, u8 *dst, u16 color, u16 x, u16 y)
static BOOL setFinalColorSpecialIncrease (const GPU *gpu, u32 passing, u8 bgnum, u8 *dst, u16 color, u16 x, u16 y)
{
if ((gpu->BLDCNT >> bgnum)&1) // the bg to draw has a special color effect
{
@ -636,18 +610,16 @@ static BOOL setFinalBGColorSpecialIncrease (GPU *gpu, u32 passing, u8 bgnum, u8
}
T2WriteWord(dst, passing, color) ;
gpu->bgPixels[x] = bgnum;
}
else
{
T2WriteWord(dst, passing, color);
gpu->bgPixels[x] = bgnum;
}
return 1;
}
static BOOL setFinalBGColorSpecialDecrease (GPU *gpu, u32 passing, u8 bgnum, u8 *dst, u16 color, u16 x, u16 y)
static BOOL setFinalColorSpecialDecrease (const GPU *gpu, u32 passing, u8 bgnum, u8 *dst, u16 color, u16 x, u16 y)
{
if ((gpu->BLDCNT >> bgnum)&1) // the bg to draw has a special color effect
{
@ -666,18 +638,16 @@ static BOOL setFinalBGColorSpecialDecrease (GPU *gpu, u32 passing, u8 bgnum, u8
color = (fadeOutColors[gpu->BLDY_EVY][color&0x7FFF] | 0x8000);
}
T2WriteWord(dst, passing, color) ;
gpu->bgPixels[x] = bgnum;
}
else
{
T2WriteWord(dst, passing, color);
gpu->bgPixels[x] = bgnum;
}
return 1;
}
static BOOL setFinalBGColorSpecialNoneWnd (GPU *gpu, u32 passing, u8 bgnum, u8 *dst, u16 color, u16 x, u16 y)
static BOOL setFinalColorSpecialNoneWnd (const GPU *gpu, u32 passing, u8 bgnum, u8 *dst, u16 color, u16 x, u16 y)
{
BOOL windowDraw = TRUE, windowEffect = TRUE;
@ -686,21 +656,17 @@ static BOOL setFinalBGColorSpecialNoneWnd (GPU *gpu, u32 passing, u8 bgnum, u8 *
if (((gpu->BLDCNT >> bgnum)&1) && windowEffect) // the bg to draw has a special color effect
{
T2WriteWord(dst, passing, color);
gpu->bgPixels[x] = bgnum;
}
else
{
if ((windowEffect && (gpu->BLDCNT & (0x100 << bgnum))) || windowDraw)
{
T2WriteWord(dst, passing, color);
gpu->bgPixels[x] = bgnum;
}
}
return windowDraw;
}
static BOOL setFinalBGColorSpecialBlendWnd (GPU *gpu, u32 passing, u8 bgnum, u8 *dst, u16 color, u16 x, u16 y)
static BOOL setFinalColorSpecialBlendWnd (const GPU *gpu, u32 passing, u8 bgnum, u8 *dst, u16 color, u16 x, u16 y)
{
BOOL windowDraw = TRUE, windowEffect = TRUE;
@ -736,21 +702,17 @@ static BOOL setFinalBGColorSpecialBlendWnd (GPU *gpu, u32 passing, u8 bgnum, u8
color = (sourceR & 0x1F) | ((sourceG & 0x1F) << 5) | ((sourceB & 0x1F) << 10) | 0x8000 ;
T2WriteWord(dst, passing, color);
gpu->bgPixels[x] = bgnum;
}
else
{
if ((windowEffect && (gpu->BLDCNT & (0x100 << bgnum))) || windowDraw)
{
T2WriteWord(dst, passing, color);
gpu->bgPixels[x] = bgnum;
}
}
return windowDraw;
}
static BOOL setFinalBGColorSpecialIncreaseWnd (GPU *gpu, u32 passing, u8 bgnum, u8 *dst, u16 color, u16 x, u16 y)
static BOOL setFinalColorSpecialIncreaseWnd (const GPU *gpu, u32 passing, u8 bgnum, u8 *dst, u16 color, u16 x, u16 y)
{
BOOL windowDraw = TRUE, windowEffect = TRUE;
@ -774,21 +736,17 @@ static BOOL setFinalBGColorSpecialIncreaseWnd (GPU *gpu, u32 passing, u8 bgnum,
}
T2WriteWord(dst, passing, color) ;
gpu->bgPixels[x] = bgnum;
}
else
{
if ((windowEffect && (gpu->BLDCNT & (0x100 << bgnum))) || windowDraw)
{
T2WriteWord(dst, passing, color);
gpu->bgPixels[x] = bgnum;
}
}
return windowDraw;
}
static BOOL setFinalBGColorSpecialDecreaseWnd (GPU *gpu, u32 passing, u8 bgnum, u8 *dst, u16 color, u16 x, u16 y)
static BOOL setFinalColorSpecialDecreaseWnd (const GPU *gpu, u32 passing, u8 bgnum, u8 *dst, u16 color, u16 x, u16 y)
{
BOOL windowDraw = TRUE, windowEffect = TRUE;
@ -811,241 +769,11 @@ static BOOL setFinalBGColorSpecialDecreaseWnd (GPU *gpu, u32 passing, u8 bgnum,
color = (fadeOutColors[gpu->BLDY_EVY][color&0x7FFF] | 0x8000);
}
T2WriteWord(dst, passing, color) ;
gpu->bgPixels[x] = bgnum;
}
else
{
if ((windowEffect && (gpu->BLDCNT & (0x100 << bgnum))) || windowDraw)
{
T2WriteWord(dst, passing, color);
gpu->bgPixels[x] = bgnum;
}
}
return windowDraw;
}
/*****************************************************************************/
// PIXEL RENDERING - 3D
/*****************************************************************************/
static BOOL setFinal3DColorSpecialNone(GPU *gpu, u32 passing, u8 *dst, u16 color, u8 alpha, u16 x, u16 y)
{
T2WriteWord(dst, passing, (color | 0x8000));
return 1;
}
static BOOL setFinal3DColorSpecialBlend(GPU *gpu, u32 passing, u8 *dst, u16 color, u8 alpha, u16 x, u16 y)
{
/* We can blend if the 3D layer is selected as 1st target, */
/* but also if the 3D layer has the highest prio. */
if((gpu->BLDCNT & 0x1) || (gpu->dispx_st->dispx_BGxCNT[0].bits.Priority == 0))
{
int bg_under = gpu->bgPixels[x];
u16 final = color;
/* If the layer we are drawing on is selected as 2nd source, we can blend */
if(gpu->BLDCNT & (1 << (8 + bg_under)))
{
/* Test for easy cases like alpha = min or max */
if(alpha == 16)
{
final = color;
}
else if(alpha == 0)
{
final = T2ReadWord(dst, passing);
}
else
{
COLOR c1, c2, cfinal;
c1.val = color;
c2.val = T2ReadWord(dst, passing);
cfinal.bits.red = ((c1.bits.red * alpha / 16) + (c2.bits.red * (16 - alpha) / 16));
cfinal.bits.green = ((c1.bits.green * alpha / 16) + (c2.bits.green * (16 - alpha) / 16));
cfinal.bits.blue = ((c1.bits.blue * alpha / 16) + (c2.bits.blue * (16 - alpha) / 16));
final = cfinal.val;
}
}
T2WriteWord(dst, passing, (final | 0x8000));
gpu->bgPixels[x] = 0;
}
else
{
T2WriteWord(dst, passing, (color | 0x8000));
gpu->bgPixels[x] = 0;
}
return 1;
}
static BOOL setFinal3DColorSpecialIncrease(GPU *gpu, u32 passing, u8 *dst, u16 color, u8 alpha, u16 x, u16 y)
{
if(gpu->BLDCNT & 0x1)
{
if (gpu->BLDY_EVY != 0x0)
{
color = fadeInColors[gpu->BLDY_EVY][color&0x7FFF];
}
T2WriteWord(dst, passing, (color | 0x8000));
gpu->bgPixels[x] = 0;
}
else
{
T2WriteWord(dst, passing, (color | 0x8000));
gpu->bgPixels[x] = 0;
}
return 1;
}
static BOOL setFinal3DColorSpecialDecrease(GPU *gpu, u32 passing, u8 *dst, u16 color, u8 alpha, u16 x, u16 y)
{
if(gpu->BLDCNT & 0x1)
{
if (gpu->BLDY_EVY != 0x0)
{
color = fadeOutColors[gpu->BLDY_EVY][color&0x7FFF];
}
T2WriteWord(dst, passing, (color | 0x8000));
gpu->bgPixels[x] = 0;
}
else
{
T2WriteWord(dst, passing, (color | 0x8000));
gpu->bgPixels[x] = 0;
}
return 1;
}
static BOOL setFinal3DColorSpecialNoneWnd(GPU *gpu, u32 passing, u8 *dst, u16 color, u8 alpha, u16 x, u16 y)
{
BOOL windowDraw = TRUE, windowEffect = TRUE;
renderline_checkWindows(gpu, 0, x, y, &windowDraw, &windowEffect);
if(windowDraw)
{
T2WriteWord(dst, passing, (color | 0x8000));
gpu->bgPixels[x] = 0;
}
return windowDraw;
}
static BOOL setFinal3DColorSpecialBlendWnd(GPU *gpu, u32 passing, u8 *dst, u16 color, u8 alpha, u16 x, u16 y)
{
BOOL windowDraw = TRUE, windowEffect = TRUE;
renderline_checkWindows(gpu, 0, x, y, &windowDraw, &windowEffect);
if(windowDraw)
{
/* We can blend if the 3D layer is selected as 1st target, */
/* but also if the 3D layer has the highest prio. */
if(((gpu->BLDCNT & 0x1) && windowEffect) || (gpu->dispx_st->dispx_BGxCNT[0].bits.Priority == 0))
{
int bg_under = gpu->bgPixels[x];
u16 final = color;
/* If the layer we are drawing on is selected as 2nd source, we can blend */
if(gpu->BLDCNT & (1 << (8 + bg_under)))
{
/* Test for easy cases like alpha = min or max */
if(alpha == 16)
{
final = color;
}
else if(alpha == 0)
{
final = T2ReadWord(dst, passing);
}
else
{
COLOR c1, c2, cfinal;
c1.val = color;
c2.val = T2ReadWord(dst, passing);
cfinal.bits.red = ((c1.bits.red * alpha / 16) + (c2.bits.red * (16 - alpha) / 16));
cfinal.bits.green = ((c1.bits.green * alpha / 16) + (c2.bits.green * (16 - alpha) / 16));
cfinal.bits.blue = ((c1.bits.blue * alpha / 16) + (c2.bits.blue * (16 - alpha) / 16));
final = cfinal.val;
}
}
T2WriteWord(dst, passing, (final | 0x8000));
gpu->bgPixels[x] = 0;
}
else
{
T2WriteWord(dst, passing, (color | 0x8000));
gpu->bgPixels[x] = 0;
}
}
return windowDraw;
}
static BOOL setFinal3DColorSpecialIncreaseWnd(GPU *gpu, u32 passing, u8 *dst, u16 color, u8 alpha, u16 x, u16 y)
{
BOOL windowDraw = TRUE, windowEffect = TRUE;
renderline_checkWindows(gpu, 0, x, y, &windowDraw, &windowEffect);
if(windowDraw)
{
if((gpu->BLDCNT & 0x1) && windowEffect)
{
if (gpu->BLDY_EVY != 0x0)
{
color = fadeInColors[gpu->BLDY_EVY][color&0x7FFF];
}
T2WriteWord(dst, passing, (color | 0x8000));
gpu->bgPixels[x] = 0;
}
else
{
T2WriteWord(dst, passing, (color | 0x8000));
gpu->bgPixels[x] = 0;
}
}
return windowDraw;
}
static BOOL setFinal3DColorSpecialDecreaseWnd(GPU *gpu, u32 passing, u8 *dst, u16 color, u8 alpha, u16 x, u16 y)
{
BOOL windowDraw = TRUE, windowEffect = TRUE;
renderline_checkWindows(gpu, 0, x, y, &windowDraw, &windowEffect);
if(windowDraw)
{
if((gpu->BLDCNT & 0x1) && windowEffect)
{
if (gpu->BLDY_EVY != 0x0)
{
color = fadeOutColors[gpu->BLDY_EVY][color&0x7FFF];
}
T2WriteWord(dst, passing, (color | 0x8000));
gpu->bgPixels[x] = 0;
}
else
{
T2WriteWord(dst, passing, (color | 0x8000));
gpu->bgPixels[x] = 0;
}
}
return windowDraw;
@ -1055,7 +783,7 @@ static BOOL setFinal3DColorSpecialDecreaseWnd(GPU *gpu, u32 passing, u8 *dst, u1
// BACKGROUND RENDERING -TEXT-
/*****************************************************************************/
// render a text background to the combined pixelbuffer
INLINE void renderline_textBG(GPU * gpu, u8 num, u8 * dst, u32 Y, u16 XBG, u16 YBG, u16 LG)
INLINE void renderline_textBG(const GPU * gpu, u8 num, u8 * dst, u32 Y, u16 XBG, u16 YBG, u16 LG)
{
struct _BGxCNT * bgCnt = &(gpu->dispx_st)->dispx_BGxCNT[num].bits;
struct _DISPCNT * dispCnt = &(gpu->dispx_st)->dispx_DISPCNT.bits;
@ -1460,7 +1188,7 @@ void lineExtRot(GPU * gpu, u8 num, u16 l, u8 * DST)
256);
}
void textBG(GPU * gpu, u8 num, u8 * DST)
void textBG(const GPU * gpu, u8 num, u8 * DST)
{
u32 i;
for(i = 0; i < gpu->BGSize[num][1]; ++i)
@ -2464,9 +2192,6 @@ static INLINE void GPU_ligne_layer(NDS_Screen * screen, u16 l)
for(int i = 0; i< 256; ++i) T2WriteWord(dst, i << 1, c);
/* reset them to backdrop */
memset(gpu->bgPixels, 5, 256);
if (!gpu->LayersEnable[0] && !gpu->LayersEnable[1] &&
!gpu->LayersEnable[2] && !gpu->LayersEnable[3] &&
!gpu->LayersEnable[4]) return;
@ -2520,9 +2245,6 @@ static INLINE void GPU_ligne_layer(NDS_Screen * screen, u16 l)
{
if (i16 == 0 && dispCnt->BG0_3D)
{
u16 line3Dcolor[256];
u8 line3Dalpha[256];
//determine the 3d range to grab
BGxOFS * bgofs = &gpu->dispx_st->dispx_BGxOFS[i16];
s16 hofs = (s16)T1ReadWord((u8 *)&bgofs->BGxHOFS, 0);
@ -2531,13 +2253,7 @@ static INLINE void GPU_ligne_layer(NDS_Screen * screen, u16 l)
else if(hofs<0) { start = -hofs; end=255; ofs=0; }
else { start = 0; end=255-hofs; ofs=hofs; }
//gpu3D->NDS_3D_GetLine (l, start, end, (u16*)dst+ofs);
gpu3D->NDS_3D_GetLine(l, start, end, line3Dcolor + ofs, line3Dalpha + ofs);
for(int k = start; k <= end; k++)
if(line3Dcolor[k] & 0x8000)
gpu->setFinalColor3D(gpu, (k << 1), dst, line3Dcolor[k], line3Dalpha[k], k, l);
gpu3D->NDS_3D_GetLine (l, start, end, (u16*)dst+ofs);
continue;
}
}

View File

@ -661,11 +661,8 @@ struct _GPU
u8 MasterBrightMode;
u32 MasterBrightFactor;
u8 bgPixels[256];
BOOL (*setFinalColorSpr)(GPU *gpu, u32 passing, u8 bgnum, u8 *dst, u16 color, u16 x, u16 y);
BOOL (*setFinalColorBck)(GPU *gpu, u32 passing, u8 bgnum, u8 *dst, u16 color, u16 x, u16 y);
BOOL (*setFinalColor3D) (GPU *gpu, u32 passing, u8 *dst, u16 color, u8 alpha, u16 x, u16 y);
BOOL (*setFinalColorSpr)(const GPU *gpu, u32 passing, u8 bgnum, u8 *dst, u16 color, u16 x, u16 y);
BOOL (*setFinalColorBck)(const GPU *gpu, u32 passing, u8 bgnum, u8 *dst, u16 color, u16 x, u16 y);
void (*spriteRender) (GPU * gpu, u16 l, u8 * dst, u8 * prioTab);
};
/*
@ -695,7 +692,7 @@ GPU * GPU_Init(u8 l);
void GPU_Reset(GPU *g, u8 l);
void GPU_DeInit(GPU *);
void textBG(GPU * gpu, u8 num, u8 * DST); //Draw text based background
void textBG(const GPU * gpu, u8 num, u8 * DST); //Draw text based background
void rotBG(GPU * gpu, u8 num, u8 * DST);
void extRotBG(GPU * gpu, u8 num, u8 * DST);
void sprite1D(GPU * gpu, u16 l, u8 * dst, u8 * prioTab);

View File

@ -74,7 +74,7 @@ static void ENDGL() {
#endif
static ALIGN(16) unsigned char GPU_screen3D [256*256*4];
//static ALIGN(16) unsigned char GPU_screenStencil[256*256];
static ALIGN(16) unsigned char GPU_screenStencil[256*256];
static const unsigned short map3d_cull[4] = {GL_FRONT_AND_BACK, GL_FRONT, GL_BACK, 0};
static const int texEnv[4] = { GL_MODULATE, GL_DECAL, GL_MODULATE, GL_MODULATE };
@ -367,7 +367,7 @@ static void OGLReset()
texcache_stop=MAX_TEXTURE<<1;
//clear the framebuffers
// memset(GPU_screenStencil,0,sizeof(GPU_screenStencil));
memset(GPU_screenStencil,0,sizeof(GPU_screenStencil));
memset(GPU_screen3D,0,sizeof(GPU_screen3D));
}
@ -1037,7 +1037,7 @@ static void OGLRender()
//printf("%d\n",gfx3d.projlist->count);
//we're not using the alpha clear color right now
glClearColor(gfx3d.clearColor[0],gfx3d.clearColor[1],gfx3d.clearColor[2], gfx3d.clearColor[3]);
glClearColor(gfx3d.clearColor[0],gfx3d.clearColor[1],gfx3d.clearColor[2], clearAlpha);
glClearDepth(gfx3d.clearDepth);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
@ -1118,7 +1118,7 @@ static void GL_ReadFramebuffer()
{
if(!BEGINGL()) return;
glFinish();
// glReadPixels(0,0,256,192,GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, GPU_screenStencil);
glReadPixels(0,0,256,192,GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, GPU_screenStencil);
glReadPixels(0,0,256,192,GL_BGRA_EXT, GL_UNSIGNED_BYTE, GPU_screen3D);
ENDGL();
@ -1160,31 +1160,30 @@ static void OGLGetLineCaptured(int line, u16* dst)
}
u8 *screen3D = (u8*)GPU_screen3D+((191-line)<<10);
// u8 *screenStencil = (u8*)GPU_screenStencil+((191-line)<<8);
u8 *screenStencil = (u8*)GPU_screenStencil+((191-line)<<8);
for(int i = 0; i < 256; i++)
{
/* u32 stencil = screenStencil[i];
u32 stencil = screenStencil[i];
if(!stencil)
{
dst[i] = 0x0000;
continue;
}*/
}
int t=i<<2;
/* u8 r = screen3D[t+2];
u8 g = screen3D[t+1];
u8 b = screen3D[t+0];*/
u32 r = screen3D[t+2];
u32 g = screen3D[t+1];
u32 b = screen3D[t+0];
//if this math strikes you as wrong, be sure to look at GL_ReadFramebuffer() where the pixel format in screen3D is changed
//dst[i] = (b<<10) | (g<<5) | (r) | 0x8000;
dst[i] = (screen3D[t+2] | (screen3D[t+1] << 5) | (screen3D[t+0] << 10) | ((screen3D[t+3] > 0) ? 0x8000 : 0x0000));
dst[i] = (b<<10) | (g<<5) | (r) | 0x8000;
}
}
static void OGLGetLine(int line, int start, int end_inclusive, u16* dst, u8* dstAlpha)
static void OGLGetLine(int line, int start, int end_inclusive, u16* dst)
{
assert(line<192 && line>=0);
@ -1194,7 +1193,7 @@ static void OGLGetLine(int line, int start, int end_inclusive, u16* dst, u8* dst
}
u8 *screen3D = (u8*)GPU_screen3D+((191-line)<<10);
//u8 *screenStencil = (u8*)GPU_screenStencil+((191-line)<<8);
u8 *screenStencil = (u8*)GPU_screenStencil+((191-line)<<8);
//the renderer clears the stencil to 0
//then it sets it to 1 whenever it renders a pixel that passes the alpha test
@ -1208,18 +1207,15 @@ static void OGLGetLine(int line, int start, int end_inclusive, u16* dst, u8* dst
for(int i = start, j=0; i <= end_inclusive; ++i, ++j)
{
// u32 stencil = screenStencil[i];
u32 stencil = screenStencil[i];
//you would use this if you wanted to use the stencil buffer to make decisions here
// if(!stencil) continue;
if(!stencil) continue;
// u16 oldcolor = dst[j];
u16 oldcolor = dst[j];
int t=i<<2;
// u32 dstpixel;
dst[j] = (screen3D[t+2] | (screen3D[t+1] << 5) | (screen3D[t+0] << 10) | ((screen3D[t+3] > 0) ? 0x8000 : 0x0000));
dstAlpha[j] = (screen3D[t+3] / 2);
u32 dstpixel;
//old debug reminder: display alpha channel
//u32 r = screen3D[t+3];
@ -1228,7 +1224,7 @@ static void OGLGetLine(int line, int start, int end_inclusive, u16* dst, u8* dst
//if this math strikes you as wrong, be sure to look at GL_ReadFramebuffer() where the pixel format in screen3D is changed
/* u32 a = screen3D[t+3];
u32 a = screen3D[t+3];
typedef u8 mixtbl[32][32];
mixtbl & mix = mixTable555[a];
@ -1251,7 +1247,7 @@ static void OGLGetLine(int line, int start, int end_inclusive, u16* dst, u8* dst
newpix = mix[newpix][oldpix];
dstpixel |= (newpix<<10);
dst[j] = dstpixel;*/
dst[j] = dstpixel;
}
}

Some files were not shown because too many files have changed in this diff Show More