Creating tag for first 0.9 release candidate.
This commit is contained in:
parent
c0284f63f6
commit
0e7d46a55e
|
@ -1,9 +1,3 @@
|
|||
0.9+
|
||||
Graphics:
|
||||
bug: Fix some errors in rendering 512 tall BG [zeromus,CrazyMax] (still not fully resolved)
|
||||
bug: 3d compositing integrated into GPU engine (more precision and speed in cases where no compositing needed) [luigi__]
|
||||
bug: Add optional fragment shading pipeline (more precision) [luigi__]
|
||||
|
||||
0.8 -> 0.9
|
||||
There have been so many changes that this list can hardly be considered complete.
|
||||
For this release, we have formatted the list into a high level overview of big changes and bad bugs relative to the previous release. Hopefully what you're interested in.
|
||||
|
@ -44,7 +38,6 @@ Graphics:
|
|||
. Move entire GE to core emu.
|
||||
. Move OpenGL renderer to emu core for optional use by platforms, removing ogl_collector. Now every platform shares the same 3d code.
|
||||
. Reorganize 3d code to defer rendering to after 3d vblank. Eliminates tearing, and texturing artifacts. [zeromus]
|
||||
. Add optional fragment shading pipeline (more precision) [luigi__]
|
||||
. Move lighting model to software instead of using opengl's fixed function model [zeromus]
|
||||
. Render shadow volumes; toon shading and highlight table [zeromus, luigi__]
|
||||
. Added texture caching! big speed up. [CrazyMax]
|
||||
|
@ -61,7 +54,6 @@ Graphics:
|
|||
bug: Add 3d layer h-scrolling [zeromus]
|
||||
bug: Added transparency and fixed material alpha support and alpha testing on the 3D core [shash]
|
||||
bug: Rewrite VRAM mapping control and rendering (more accurate) [CrazyMax,luigi__]
|
||||
|
||||
bug: convert colors to opengl better to prevent alpha=31 polys from being ever so slightly transparent [zeromus]
|
||||
enh: Add MMU->GPU signal for when vram mappings change to function as a texture cache invalidate signal [zeromus]
|
||||
enh: Make matrix 4x4 multiply routines use W-coordinate; carry w coord through pipeline [zeromus]
|
|
@ -1,7 +1,7 @@
|
|||
dnl --- Package name is first argument to AC_INIT
|
||||
dnl --- Release version is second argument to AC_INIT
|
||||
|
||||
AC_INIT(desmume, [0.8])
|
||||
AC_INIT(desmume, [0.9])
|
||||
|
||||
dnl -- find target architecture for some os specific libraries
|
||||
AC_CANONICAL_TARGET
|
|
@ -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];
|
||||
|
@ -192,73 +172,49 @@ u16 fadeOutColors[17][0x8000];
|
|||
// INITIALIZATION
|
||||
/*****************************************************************************/
|
||||
|
||||
static void GPU_InitFadeColors()
|
||||
{
|
||||
/*
|
||||
NOTE: gbatek (in the reference above) seems to expect 6bit values
|
||||
per component, but as desmume works with 5bit per component,
|
||||
we use 31 as top, instead of 63. Testing it on a few games,
|
||||
using 63 seems to give severe color wraping, and 31 works
|
||||
nicely, so for now we'll just that, until proven wrong.
|
||||
|
||||
i have seen pics of pokemon ranger getting white with 31, with 63 it is nice.
|
||||
it could be pb of alpha or blending or...
|
||||
|
||||
MightyMax> created a test NDS to check how the brightness values work,
|
||||
and 31 seems to be correct. FactorEx is a override for max brighten/darken
|
||||
See: http://mightymax.org/gfx_test_brightness.nds
|
||||
The Pokemon Problem could be a problem with 8/32 bit writes not recognized yet,
|
||||
i'll add that so you can check back.
|
||||
|
||||
*/
|
||||
|
||||
for(int i = 0; i <= 16; i++)
|
||||
{
|
||||
for(int j = 0x8000; j < 0x10000; j++)
|
||||
{
|
||||
COLOR cur;
|
||||
|
||||
cur.val = j;
|
||||
cur.bits.red = (cur.bits.red + ((31 - cur.bits.red) * i / 16));
|
||||
cur.bits.green = (cur.bits.green + ((31 - cur.bits.green) * i / 16));
|
||||
cur.bits.blue = (cur.bits.blue + ((31 - cur.bits.blue) * i / 16));
|
||||
fadeInColors[i][j & 0x7FFF] = cur.val;
|
||||
|
||||
cur.val = j;
|
||||
cur.bits.red = (cur.bits.red - (cur.bits.red * i / 16));
|
||||
cur.bits.green = (cur.bits.green - (cur.bits.green * i / 16));
|
||||
cur.bits.blue = (cur.bits.blue - (cur.bits.blue * i / 16));
|
||||
fadeOutColors[i][j & 0x7FFF] = cur.val;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
GPU * GPU_Init(u8 l)
|
||||
{
|
||||
GPU * g;
|
||||
int i, j;
|
||||
|
||||
if ((g = (GPU *) malloc(sizeof(GPU))) == NULL)
|
||||
return NULL;
|
||||
GPU * g;
|
||||
|
||||
GPU_Reset(g, l);
|
||||
GPU_InitFadeColors();
|
||||
if ((g = (GPU *) malloc(sizeof(GPU))) == NULL)
|
||||
return NULL;
|
||||
|
||||
g->setFinalColorBck = setFinalBGColorSpecialNone;
|
||||
g->setFinalColorSpr = setFinalBGColorSpecialNone;
|
||||
g->setFinalColor3D = setFinal3DColorSpecialNone;
|
||||
GPU_Reset(g, l);
|
||||
|
||||
return g;
|
||||
for(i = 0; i <= 16; i++)
|
||||
{
|
||||
for(j = 0x8000; j < 0x10000; j++)
|
||||
{
|
||||
COLOR cur;
|
||||
|
||||
cur.val = j;
|
||||
cur.bits.red = (cur.bits.red + ((31 - cur.bits.red) * i / 16));
|
||||
cur.bits.green = (cur.bits.green + ((31 - cur.bits.green) * i / 16));
|
||||
cur.bits.blue = (cur.bits.blue + ((31 - cur.bits.blue) * i / 16));
|
||||
fadeInColors[i][j & 0x7FFF] = cur.val;
|
||||
|
||||
cur.val = j;
|
||||
cur.bits.red = (cur.bits.red - (cur.bits.red * i / 16));
|
||||
cur.bits.green = (cur.bits.green - (cur.bits.green * i / 16));
|
||||
cur.bits.blue = (cur.bits.blue - (cur.bits.blue * i / 16));
|
||||
fadeOutColors[i][j & 0x7FFF] = cur.val;
|
||||
}
|
||||
}
|
||||
|
||||
g->setFinalColorBck = setFinalColorSpecialNone;
|
||||
g->setFinalColorSpr = setFinalColorSpecialNone;
|
||||
|
||||
return g;
|
||||
}
|
||||
|
||||
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;
|
||||
|
@ -363,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 */
|
||||
|
@ -580,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;
|
||||
|
@ -592,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)
|
||||
{
|
||||
|
@ -627,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
|
||||
{
|
||||
|
@ -658,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
|
||||
{
|
||||
|
@ -688,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;
|
||||
|
||||
|
@ -708,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;
|
||||
|
||||
|
@ -758,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;
|
||||
|
||||
|
@ -796,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;
|
||||
|
||||
|
@ -833,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;
|
||||
|
@ -1077,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;
|
||||
|
@ -1100,18 +806,12 @@ INLINE void renderline_textBG(GPU * gpu, u8 num, u8 * dst, u32 Y, u16 XBG, u16 Y
|
|||
TILEENTRY tileentry;
|
||||
|
||||
|
||||
//zero 30-dec-2008 - if you mask by 31 here, you lose the ability to correctly map the bottom half of 512-tall BG.
|
||||
//the masking to keep it to a reasonable value was already done when tmp was calculated
|
||||
// this is broke some games
|
||||
//map = (u8 *)MMU_RenderMapToLCD(gpu->BG_map_ram[num] + (tmp) * 64);
|
||||
|
||||
u32 tmp_map = gpu->BG_map_ram[num] + (tmp&31) * 64;
|
||||
if(tmp>31)
|
||||
tmp_map+= ADDRESS_STEP_512B << bgCnt->ScreenSize ;
|
||||
|
||||
map = (u8 *)MMU_RenderMapToLCD(tmp_map);
|
||||
if(!map) return; // no map
|
||||
map = (u8 *)MMU_RenderMapToLCD(gpu->BG_map_ram[num] + (tmp&31) * 64);
|
||||
if (!map) return;
|
||||
|
||||
if(tmp>31)
|
||||
map+= ADDRESS_STEP_512B << bgCnt->ScreenSize ;
|
||||
|
||||
tile = (u8*) MMU_RenderMapToLCD(gpu->BG_tile_ram[num]);
|
||||
if(!tile) return; // no tiles
|
||||
|
||||
|
@ -1257,7 +957,6 @@ INLINE void renderline_textBG(GPU * gpu, u8 num, u8 * dst, u32 Y, u16 XBG, u16 Y
|
|||
}
|
||||
|
||||
yoff = ((YBG&7)<<3);
|
||||
|
||||
xfin = 8 - (xoff&7);
|
||||
for(x = 0; x < LG; xfin = std::min<u16>(x+8, LG))
|
||||
{
|
||||
|
@ -1489,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)
|
||||
|
@ -2416,10 +2115,52 @@ void GPU_set_DISPCAPCNT(u32 val)
|
|||
gpu->dispCapCnt.capSrc, gpu->dispCapCnt.dst - ARM9Mem.ARM9_LCD, gpu->dispCapCnt.src - ARM9Mem.ARM9_LCD,
|
||||
gpu->dispCapCnt.srcA, gpu->dispCapCnt.srcB);*/
|
||||
}
|
||||
|
||||
// trade off for speed is 1MB
|
||||
u16 bright_more_colors[16][0x8000];
|
||||
u16 bright_less_colors[16][0x8000];
|
||||
BOOL bright_init=FALSE;
|
||||
|
||||
// comment this if want to use formulas instead
|
||||
// #define BRIGHT_TABLES
|
||||
|
||||
#ifdef BRIGHT_TABLES
|
||||
static void calc_bright_colors() {
|
||||
int base = 31 ;
|
||||
int factor;
|
||||
u16 red, green, blue;
|
||||
COLOR color_more, color_less, color_ref;
|
||||
|
||||
static void GPU_ligne_layer(NDS_Screen * screen, u16 l)
|
||||
#define FORMULA_MORE(x) x + ((base-x)*factor)/16
|
||||
#define FORMULA_LESS(x) x - (x*factor)/16
|
||||
|
||||
if (bright_init) return;
|
||||
for (factor=0; factor<16; factor++)
|
||||
for (red =0; red <32; red++) {
|
||||
color_ref.bits.red = red;
|
||||
color_more.bits.red = FORMULA_MORE(red);
|
||||
color_less.bits.red = FORMULA_LESS(red);
|
||||
for (green=0; green<32; green++) {
|
||||
color_ref.bits.green = green;
|
||||
color_more.bits.green = FORMULA_MORE(green);
|
||||
color_less.bits.green = FORMULA_LESS(green);
|
||||
for (blue =0; blue <32; blue++) {
|
||||
color_ref.bits.blue = blue;
|
||||
color_more.bits.blue = FORMULA_MORE(blue);
|
||||
color_less.bits.blue = FORMULA_LESS(blue);
|
||||
bright_more_colors[factor][color_ref.bitx.bgr] = color_more.val;
|
||||
bright_less_colors[factor][color_ref.bitx.bgr] = color_less.val;
|
||||
}
|
||||
}
|
||||
}
|
||||
bright_init=TRUE;
|
||||
|
||||
#undef FORMULA_MORE
|
||||
#undef FORMULA_LESS
|
||||
}
|
||||
#endif
|
||||
|
||||
static INLINE void GPU_ligne_layer(NDS_Screen * screen, u16 l)
|
||||
{
|
||||
GPU * gpu = screen->gpu;
|
||||
struct _DISPCNT * dispCnt = &(gpu->dispx_st)->dispx_DISPCNT.bits;
|
||||
|
@ -2451,9 +2192,6 @@ static 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;
|
||||
|
@ -2507,11 +2245,6 @@ static void GPU_ligne_layer(NDS_Screen * screen, u16 l)
|
|||
{
|
||||
if (i16 == 0 && dispCnt->BG0_3D)
|
||||
{
|
||||
u16 line3Dcolor[256];
|
||||
u8 line3Dalpha[256];
|
||||
|
||||
memset(line3Dcolor, 0, sizeof(line3Dcolor));
|
||||
memset(line3Dalpha, 0, sizeof(line3Dalpha));
|
||||
//determine the 3d range to grab
|
||||
BGxOFS * bgofs = &gpu->dispx_st->dispx_BGxOFS[i16];
|
||||
s16 hofs = (s16)T1ReadWord((u8 *)&bgofs->BGxHOFS, 0);
|
||||
|
@ -2520,13 +2253,7 @@ static 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;
|
||||
}
|
||||
}
|
||||
|
@ -2547,9 +2274,10 @@ static void GPU_ligne_layer(NDS_Screen * screen, u16 l)
|
|||
}
|
||||
|
||||
// TODO: capture emulated not fully
|
||||
static void GPU_ligne_DispCapture(u16 l)
|
||||
static INLINE void GPU_ligne_DispCapture(u16 l)
|
||||
{
|
||||
GPU * gpu = MainScreen.gpu;
|
||||
struct _DISPCNT * dispCnt = &(gpu->dispx_st)->dispx_DISPCNT.bits;
|
||||
|
||||
if (l == 0)
|
||||
{
|
||||
|
@ -2685,11 +2413,15 @@ static void GPU_ligne_DispCapture(u16 l)
|
|||
static INLINE void GPU_ligne_MasterBrightness(NDS_Screen * screen, u16 l)
|
||||
{
|
||||
GPU * gpu = screen->gpu;
|
||||
|
||||
u8 * dst = GPU_screen + (screen->offset + l) * 512;
|
||||
u16 i16;
|
||||
|
||||
if (!gpu->MasterBrightFactor) return;
|
||||
#ifndef HAVE_LIBGDKGLEXT_X11_1_0
|
||||
// damdoum :
|
||||
// brightness done with opengl
|
||||
// test are ok (gfx_test_brightness)
|
||||
// now, if we are going to support 3D, this becomes dead code
|
||||
// because it is obvious we'll use openGL / mesa3D
|
||||
|
||||
#ifdef BRIGHT_TABLES
|
||||
calc_bright_colors();
|
||||
|
@ -2709,11 +2441,36 @@ static INLINE void GPU_ligne_MasterBrightness(NDS_Screen * screen, u16 l)
|
|||
// Bright up
|
||||
case 1:
|
||||
{
|
||||
// when we wont do anything, we dont need to loop
|
||||
#if 0
|
||||
COLOR dstColor;
|
||||
unsigned int masterBrightFactor = gpu->MasterBrightFactor;
|
||||
u16 * colors = bright_more_colors[masterBrightFactor];
|
||||
#endif
|
||||
|
||||
/* when we wont do anything, we dont need to loop */
|
||||
if (!(gpu->MasterBrightFactor)) break ;
|
||||
|
||||
for(i16 = 0; i16 < 256; ++i16)
|
||||
{
|
||||
#if 0
|
||||
#ifndef BRIGHT_TABLES
|
||||
u8 base ;
|
||||
u8 r,g,b; // get components, 5bit each
|
||||
dstColor.val = *((u16 *) (dst + (i16 << 1)));
|
||||
r = dstColor.bits.red;
|
||||
g = dstColor.bits.green;
|
||||
b = dstColor.bits.blue;
|
||||
// Bright up and clamp to 5bit <-- automatic
|
||||
base = 31 ;
|
||||
dstColor.bits.red = r + ((base-r)*masterBrightFactor)/16;
|
||||
dstColor.bits.green = g + ((base-g)*masterBrightFactor)/16;
|
||||
dstColor.bits.blue = b + ((base-b)*masterBrightFactor)/16;
|
||||
#else
|
||||
dstColor.val = T1ReadWord(dst, i16 << 1);
|
||||
dstColor.bitx.bgr = colors[dstColor.bitx.bgr];
|
||||
#endif
|
||||
*((u16 *) (dst + (i16 << 1))) = dstColor.val;
|
||||
#endif
|
||||
((u16*)dst)[i16] = fadeInColors[gpu->MasterBrightFactor][((u16*)dst)[i16]&0x7FFF];
|
||||
}
|
||||
break;
|
||||
|
@ -2722,11 +2479,51 @@ static INLINE void GPU_ligne_MasterBrightness(NDS_Screen * screen, u16 l)
|
|||
// Bright down
|
||||
case 2:
|
||||
{
|
||||
// when we wont do anything, we dont need to loop
|
||||
/*
|
||||
NOTE: gbatek (in the reference above) seems to expect 6bit values
|
||||
per component, but as desmume works with 5bit per component,
|
||||
we use 31 as top, instead of 63. Testing it on a few games,
|
||||
using 63 seems to give severe color wraping, and 31 works
|
||||
nicely, so for now we'll just that, until proven wrong.
|
||||
|
||||
i have seen pics of pokemon ranger getting white with 31, with 63 it is nice.
|
||||
it could be pb of alpha or blending or...
|
||||
|
||||
MightyMax> created a test NDS to check how the brightness values work,
|
||||
and 31 seems to be correct. FactorEx is a override for max brighten/darken
|
||||
See: http://mightymax.org/gfx_test_brightness.nds
|
||||
The Pokemon Problem could be a problem with 8/32 bit writes not recognized yet,
|
||||
i'll add that so you can check back.
|
||||
|
||||
*/
|
||||
#if 0
|
||||
COLOR dstColor;
|
||||
unsigned int masterBrightFactor = gpu->MasterBrightFactor;
|
||||
u16 * colors = bright_less_colors[masterBrightFactor];
|
||||
#endif
|
||||
|
||||
/* when we wont do anything, we dont need to loop */
|
||||
if (!gpu->MasterBrightFactor) break;
|
||||
|
||||
for(i16 = 0; i16 < 256; ++i16)
|
||||
{
|
||||
#if 0
|
||||
#ifndef BRIGHT_TABLES
|
||||
u8 r,g,b;
|
||||
dstColor.val = *((u16 *) (dst + (i16 << 1)));
|
||||
r = dstColor.bits.red;
|
||||
g = dstColor.bits.green;
|
||||
b = dstColor.bits.blue;
|
||||
// Bright up and clamp to 5bit <- automatic
|
||||
dstColor.bits.red = r - (r*masterBrightFactor)/16;
|
||||
dstColor.bits.green = g - (g*masterBrightFactor)/16;
|
||||
dstColor.bits.blue = b - (b*masterBrightFactor)/16;
|
||||
#else
|
||||
dstColor.val = T1ReadWord(dst, i16 << 1);
|
||||
dstColor.bitx.bgr = colors[dstColor.bitx.bgr];
|
||||
#endif
|
||||
*((u16 *) (dst + (i16 << 1))) = dstColor.val;
|
||||
#endif
|
||||
((u16*)dst)[i16] = fadeOutColors[gpu->MasterBrightFactor][((u16*)dst)[i16]&0x7FFF];
|
||||
}
|
||||
break;
|
||||
|
@ -2736,7 +2533,7 @@ static INLINE void GPU_ligne_MasterBrightness(NDS_Screen * screen, u16 l)
|
|||
case 3:
|
||||
break;
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
void GPU_ligne(NDS_Screen * screen, u16 l)
|
|
@ -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);
|
|
@ -761,13 +761,18 @@ char txt[80];
|
|||
static void execsqrt() {
|
||||
u32 ret;
|
||||
u16 cnt = T1ReadWord(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2B0);
|
||||
|
||||
if (cnt&1) {
|
||||
u64 v = T1ReadQuad(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2B8);
|
||||
ret = isqrt(v);
|
||||
} else {
|
||||
switch(cnt&1)
|
||||
{
|
||||
case 0: {
|
||||
u32 v = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2B8);
|
||||
ret = isqrt(v);
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
u64 v = T1ReadQuad(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2B8);
|
||||
ret = isqrt(v);
|
||||
break;
|
||||
}
|
||||
}
|
||||
T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2B4, 0);
|
||||
T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2B0, cnt | 0x8000);
|
||||
|
@ -782,22 +787,20 @@ static void execdiv() {
|
|||
u16 cnt = T1ReadWord(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x280);
|
||||
s64 num,den;
|
||||
s64 res,mod;
|
||||
|
||||
switch(cnt&3)
|
||||
{
|
||||
case 0:
|
||||
num = (s64) (s32) T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x290);
|
||||
den = (s64) (s32) T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x298);
|
||||
MMU.divCycles = (nds.cycles + 36);
|
||||
break;
|
||||
case 1:
|
||||
break;
|
||||
case 3: //gbatek says this is same as mode 1
|
||||
case 1:
|
||||
num = (s64) T1ReadQuad(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x290);
|
||||
den = (s64) (s32) T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x298);
|
||||
MMU.divCycles = (nds.cycles + 68);
|
||||
break;
|
||||
break;
|
||||
case 2:
|
||||
default:
|
||||
num = (s64) T1ReadQuad(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x290);
|
||||
den = (s64) T1ReadQuad(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x298);
|
||||
MMU.divCycles = (nds.cycles + 68);
|
||||
|
@ -2228,67 +2231,35 @@ static void FASTCALL _MMU_ARM9_write32(u32 adr, u32 val)
|
|||
|
||||
if((adr>>24)==4)
|
||||
{
|
||||
|
||||
// MightyMax: no need to do several ifs, when only one can happen
|
||||
// switch/case instead
|
||||
// both comparison >=,< per if can be replaced by one bit comparison since
|
||||
// they are 2^4 aligned and 2^4n wide
|
||||
// this looks ugly but should reduce load on register writes, they are done as
|
||||
// lookups by the compiler
|
||||
switch (adr >> 4)
|
||||
if( (adr >= 0x04000330) && (adr < 0x04000340) ) //edge color table
|
||||
{
|
||||
case 0x400033: //edge color table
|
||||
((u32 *)(MMU.MMU_MEM[ARMCPU_ARM9][0x40]))[(adr & 0xFFF) >> 2] = val;
|
||||
return;
|
||||
case 0x400036: //fog table
|
||||
case 0x400037:
|
||||
((u32 *)(MMU.MMU_MEM[ARMCPU_ARM9][0x40]))[(adr & 0xFFF) >> 2] = val;
|
||||
return;
|
||||
case 0x400038:
|
||||
case 0x400039:
|
||||
case 0x40003A:
|
||||
case 0x40003B: //toon table
|
||||
((u32 *)(MMU.MMU_MEM[ARMCPU_ARM9][0x40]))[(adr & 0xFFF) >> 2] = val;
|
||||
gfx3d_UpdateToonTable(&((MMU.MMU_MEM[ARMCPU_ARM9][0x40]))[(0x380)]);
|
||||
return;
|
||||
case 0x400040:
|
||||
case 0x400041:
|
||||
case 0x400042:
|
||||
case 0x400043: // FIFO Commands
|
||||
gfx3d_sendCommandToFIFO(val);
|
||||
return;
|
||||
case 0x400044:
|
||||
case 0x400045:
|
||||
case 0x400046:
|
||||
case 0x400047:
|
||||
case 0x400048:
|
||||
case 0x400049:
|
||||
case 0x40004A:
|
||||
case 0x40004B:
|
||||
case 0x40004C:
|
||||
case 0x40004D:
|
||||
case 0x40004E:
|
||||
case 0x40004F:
|
||||
case 0x400050:
|
||||
case 0x400051:
|
||||
case 0x400052:
|
||||
case 0x400053:
|
||||
case 0x400054:
|
||||
case 0x400055:
|
||||
case 0x400056:
|
||||
case 0x400057:
|
||||
case 0x400058:
|
||||
case 0x400059:
|
||||
case 0x40005A:
|
||||
case 0x40005B:
|
||||
case 0x40005C:
|
||||
case 0x40005D:
|
||||
case 0x40005E:
|
||||
case 0x40005F: // Individual Commands
|
||||
gfx3d_sendCommand(adr, val);
|
||||
return;
|
||||
default:
|
||||
break;
|
||||
((u32 *)(MMU.MMU_MEM[ARMCPU_ARM9][0x40]))[(adr & 0xFFF) >> 2] = val;
|
||||
return;
|
||||
}
|
||||
|
||||
if( (adr >= 0x04000360) && (adr < 0x04000380) ) //fog table
|
||||
{
|
||||
((u32 *)(MMU.MMU_MEM[ARMCPU_ARM9][0x40]))[(adr & 0xFFF) >> 2] = val;
|
||||
return;
|
||||
}
|
||||
|
||||
if( (adr >= 0x04000380) && (adr <= 0x40003BC) ) //toon table
|
||||
{
|
||||
((u32 *)(MMU.MMU_MEM[ARMCPU_ARM9][0x40]))[(adr & 0xFFF) >> 2] = val;
|
||||
gfx3d_UpdateToonTable(&((MMU.MMU_MEM[ARMCPU_ARM9][0x40]))[(0x380)]);
|
||||
return;
|
||||
}
|
||||
|
||||
if ( (adr >= 0x04000400) && (adr < 0x04000440) )
|
||||
{
|
||||
gfx3d_sendCommandToFIFO(val);
|
||||
return;
|
||||
}
|
||||
|
||||
if ( (adr >= 0x04000440) && (adr < 0x04000600) )
|
||||
{
|
||||
gfx3d_sendCommand(adr, val);
|
||||
return;
|
||||
}
|
||||
|
||||
switch(adr)
|
|
@ -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 };
|
||||
|
@ -217,12 +217,12 @@ static void _xglDisable(GLenum cap) {
|
|||
|
||||
//================================================= Textures
|
||||
#define MAX_TEXTURE 500
|
||||
#ifdef SSE2
|
||||
struct ALIGN(16) TextureCache
|
||||
#else
|
||||
struct ALIGN(8) TextureCache
|
||||
#endif
|
||||
struct TextureCache
|
||||
{
|
||||
TextureCache()
|
||||
: suspectedInvalid(true)
|
||||
{}
|
||||
|
||||
GLenum id;
|
||||
unsigned int frm;
|
||||
unsigned int mode;
|
||||
|
@ -233,14 +233,16 @@ struct ALIGN(8) TextureCache
|
|||
int coord;
|
||||
float invSizeX;
|
||||
float invSizeY;
|
||||
#ifdef SSE2
|
||||
ALIGN(16) unsigned char texture[128*1024]; // 128Kb texture slot
|
||||
#else
|
||||
unsigned char texture[128*1024]; // 128Kb texture slot
|
||||
u8 palette[256*2];
|
||||
u16 palSize;
|
||||
#endif
|
||||
|
||||
//set if this texture is suspected be invalid due to a vram reconfigure
|
||||
bool suspectedInvalid;
|
||||
|
||||
};
|
||||
} ;
|
||||
|
||||
TextureCache texcache[MAX_TEXTURE+1];
|
||||
u32 texcache_count;
|
||||
|
@ -364,13 +366,9 @@ static void OGLReset()
|
|||
texcache_start=0;
|
||||
texcache_stop=MAX_TEXTURE<<1;
|
||||
|
||||
for(i=0;i<MAX_TEXTURE+1;i++)
|
||||
texcache[i].suspectedInvalid = true;
|
||||
|
||||
//clear the framebuffers
|
||||
// memset(GPU_screenStencil,0,sizeof(GPU_screenStencil));
|
||||
memset(GPU_screenStencil,0,sizeof(GPU_screenStencil));
|
||||
memset(GPU_screen3D,0,sizeof(GPU_screen3D));
|
||||
|
||||
}
|
||||
|
||||
static char OGLInit(void)
|
||||
|
@ -428,7 +426,9 @@ static char OGLInit(void)
|
|||
#endif
|
||||
|
||||
/* Create the shaders */
|
||||
createShaders();
|
||||
//as a hack for 0.9 release, we're disabling shaders.
|
||||
hasShaders = false;
|
||||
//createShaders();
|
||||
|
||||
/* Assign the texture units : 0 for main textures, 1 for toon table */
|
||||
/* Also init the locations for some variables in the shaders */
|
||||
|
@ -574,31 +574,6 @@ static void setTexture(unsigned int format, unsigned int texpal)
|
|||
|
||||
txt_slot_current=(format>>14)&0x03;
|
||||
adr=(unsigned char *)(ARM9Mem.textureSlotAddr[txt_slot_current]+((format&0x3FFF)<<3));
|
||||
|
||||
switch (textureMode)
|
||||
{
|
||||
case 1: //a3i5
|
||||
pal = (unsigned short *)(ARM9Mem.texPalSlot[0] + (texturePalette<<4));
|
||||
break;
|
||||
case 2: //i2
|
||||
pal = (unsigned short *)(ARM9Mem.texPalSlot[0] + (texturePalette<<3));
|
||||
break;
|
||||
case 3: //i4
|
||||
pal = (unsigned short *)(ARM9Mem.texPalSlot[0] + (texturePalette<<4));
|
||||
break;
|
||||
case 4: //i8
|
||||
pal = (unsigned short *)(ARM9Mem.texPalSlot[0] + (texturePalette<<4));
|
||||
break;
|
||||
case 5: //4x4
|
||||
pal = (unsigned short *)(ARM9Mem.texPalSlot[0] + (texturePalette<<4));
|
||||
break;
|
||||
case 6: //a5i3
|
||||
pal = (unsigned short *)(ARM9Mem.texPalSlot[0] + (texturePalette<<4));
|
||||
break;
|
||||
case 7: //16bpp
|
||||
pal = (unsigned short *)(ARM9Mem.texPalSlot[0] + (texturePalette<<4));
|
||||
break;
|
||||
}
|
||||
|
||||
i=texcache_start;
|
||||
|
||||
|
@ -607,31 +582,11 @@ static void setTexture(unsigned int format, unsigned int texpal)
|
|||
{
|
||||
if (texcache_stop==i) break;
|
||||
if (texcache[i].frm==0) break;
|
||||
if ( (texcache[i].frm == format) && (texcache[i].pal == texpal) )
|
||||
if ((texcache[i].frm==format)&&(texcache[i].pal==texpal))
|
||||
{
|
||||
|
||||
if ((texcache[i].mode == 5) ||
|
||||
(texcache[i].mode == 7) ||
|
||||
!memcmp(texcache[i].palette, pal, texcache[i].palSize) )
|
||||
{
|
||||
//TODO - this doesnt correctly span bank boundaries. in fact, it seems quite dangerous.
|
||||
if (!memcmp(adr, texcache[i].texture, std::min((size_t)imageSize,sizeof(texcache[i].texture))) )
|
||||
{
|
||||
texcache[i].suspectedInvalid = false;
|
||||
texcache_count=i;
|
||||
if(lastTexture == -1 || (int)i != lastTexture)
|
||||
{
|
||||
lastTexture = i;
|
||||
glBindTexture(GL_TEXTURE_2D,texcache[i].id);
|
||||
glMatrixMode (GL_TEXTURE);
|
||||
glLoadIdentity ();
|
||||
glScaled (texcache[i].invSizeX, texcache[i].invSizeY, 1.0f);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
if (!texcache[i].suspectedInvalid)
|
||||
//TODO - we need to compare the palette also.
|
||||
//TODO - this doesnt correctly span bank boundaries. in fact, it seems quite dangerous.
|
||||
if (!texcache[i].suspectedInvalid || !memcmp(adr,texcache[i].texture,std::min((size_t)imageSize,sizeof(texcache[i].texture))))
|
||||
{
|
||||
texcache[i].suspectedInvalid = false;
|
||||
texcache_count=i;
|
||||
|
@ -645,7 +600,6 @@ static void setTexture(unsigned int format, unsigned int texpal)
|
|||
}
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
i++;
|
||||
if (i>MAX_TEXTURE)
|
||||
|
@ -673,14 +627,7 @@ static void setTexture(unsigned int format, unsigned int texpal)
|
|||
texcache[i].coord=(format>>30);
|
||||
texcache[i].invSizeX=1.0f/((float)(sizeX*(1<<4)));
|
||||
texcache[i].invSizeY=1.0f/((float)(sizeY*(1<<4)));
|
||||
memcpy(texcache[i].texture,adr,std::min((size_t)imageSize,sizeof(texcache[i].texture)));
|
||||
texcache[i].palSize = 0;
|
||||
if ( (textureMode != 5) || (textureMode != 7) )
|
||||
{
|
||||
texcache[i].palSize = 256*2;
|
||||
memcpy(texcache[i].palette, pal, texcache[i].palSize);
|
||||
}
|
||||
|
||||
memcpy (texcache[i].texture,adr,std::min((size_t)imageSize,sizeof(texcache[i].texture)));
|
||||
texcache[i].numcolors=palSize[texcache[i].mode];
|
||||
|
||||
texcache[i].frm=format;
|
||||
|
@ -696,223 +643,229 @@ static void setTexture(unsigned int format, unsigned int texpal)
|
|||
palZeroTransparent = (1-((format>>29)&1))*255; // shash: CONVERT THIS TO A TABLE :)
|
||||
txt_slot_size=(txt_slot_current_size=0x020000-((format & 0x3FFF)<<3));
|
||||
|
||||
switch (texcache[i].mode)
|
||||
{
|
||||
case 1: //a3i5
|
||||
switch (texcache[i].mode)
|
||||
{
|
||||
for(x = 0; x < imageSize; x++, dst += 4)
|
||||
case 1: //a3i5
|
||||
{
|
||||
u16 c = pal[adr[x]&31];
|
||||
u8 alpha = adr[x]>>5;
|
||||
*dwdst++ = RGB15TO32(c,material_3bit_to_8bit[alpha]);
|
||||
CHECKSLOT;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 2: //i2
|
||||
{
|
||||
for(x = 0; x < imageSize>>2; ++x)
|
||||
{
|
||||
unsigned short c = pal[(adr[x])&0x3];
|
||||
dst[0] = ((c & 0x1F)<<3);
|
||||
dst[1] = ((c & 0x3E0)>>2);
|
||||
dst[2] = ((c & 0x7C00)>>7);
|
||||
dst[3] = ((adr[x]&3) == 0) ? palZeroTransparent : 255;//(c>>15)*255;
|
||||
dst += 4;
|
||||
|
||||
c = pal[((adr[x])>>2)&0x3];
|
||||
dst[0] = ((c & 0x1F)<<3);
|
||||
dst[1] = ((c & 0x3E0)>>2);
|
||||
dst[2] = ((c & 0x7C00)>>7);
|
||||
dst[3] = (((adr[x]>>2)&3) == 0) ? palZeroTransparent : 255;//(c>>15)*255;
|
||||
dst += 4;
|
||||
|
||||
c = pal[((adr[x])>>4)&0x3];
|
||||
dst[0] = ((c & 0x1F)<<3);
|
||||
dst[1] = ((c & 0x3E0)>>2);
|
||||
dst[2] = ((c & 0x7C00)>>7);
|
||||
dst[3] = (((adr[x]>>4)&3) == 0) ? palZeroTransparent : 255;//(c>>15)*255;
|
||||
dst += 4;
|
||||
|
||||
c = pal[(adr[x])>>6];
|
||||
dst[0] = ((c & 0x1F)<<3);
|
||||
dst[1] = ((c & 0x3E0)>>2);
|
||||
dst[2] = ((c & 0x7C00)>>7);
|
||||
dst[3] = (((adr[x]>>6)&3) == 0) ? palZeroTransparent : 255;//(c>>15)*255;
|
||||
dst += 4;
|
||||
CHECKSLOT;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 3: //i4
|
||||
{
|
||||
for(x = 0; x < (imageSize>>1); x++)
|
||||
pal = (unsigned short *)(ARM9Mem.texPalSlot[0] + (texturePalette<<4));
|
||||
for(x = 0; x < imageSize; x++, dst += 4)
|
||||
{
|
||||
unsigned short c = pal[adr[x]&0xF];
|
||||
u16 c = pal[adr[x]&31];
|
||||
u8 alpha = adr[x]>>5;
|
||||
*dwdst++ = RGB15TO32(c,material_3bit_to_8bit[alpha]);
|
||||
CHECKSLOT;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 2: //i2
|
||||
{
|
||||
pal = (unsigned short *)(ARM9Mem.texPalSlot[0] + (texturePalette<<3));
|
||||
for(x = 0; x < imageSize>>2; ++x)
|
||||
{
|
||||
unsigned short c = pal[(adr[x])&0x3];
|
||||
dst[0] = ((c & 0x1F)<<3);
|
||||
dst[1] = ((c & 0x3E0)>>2);
|
||||
dst[2] = ((c & 0x7C00)>>7);
|
||||
dst[3] = (((adr[x])&0xF) == 0) ? palZeroTransparent : 255;//(c>>15)*255;
|
||||
dst[3] = ((adr[x]&3) == 0) ? palZeroTransparent : 255;//(c>>15)*255;
|
||||
dst += 4;
|
||||
|
||||
c = pal[((adr[x])>>4)];
|
||||
c = pal[((adr[x])>>2)&0x3];
|
||||
dst[0] = ((c & 0x1F)<<3);
|
||||
dst[1] = ((c & 0x3E0)>>2);
|
||||
dst[2] = ((c & 0x7C00)>>7);
|
||||
dst[3] = (((adr[x]>>4)&0xF) == 0) ? palZeroTransparent : 255;//(c>>15)*255;
|
||||
dst[3] = (((adr[x]>>2)&3) == 0) ? palZeroTransparent : 255;//(c>>15)*255;
|
||||
dst += 4;
|
||||
|
||||
c = pal[((adr[x])>>4)&0x3];
|
||||
dst[0] = ((c & 0x1F)<<3);
|
||||
dst[1] = ((c & 0x3E0)>>2);
|
||||
dst[2] = ((c & 0x7C00)>>7);
|
||||
dst[3] = (((adr[x]>>4)&3) == 0) ? palZeroTransparent : 255;//(c>>15)*255;
|
||||
dst += 4;
|
||||
|
||||
c = pal[(adr[x])>>6];
|
||||
dst[0] = ((c & 0x1F)<<3);
|
||||
dst[1] = ((c & 0x3E0)>>2);
|
||||
dst[2] = ((c & 0x7C00)>>7);
|
||||
dst[3] = (((adr[x]>>6)&3) == 0) ? palZeroTransparent : 255;//(c>>15)*255;
|
||||
dst += 4;
|
||||
CHECKSLOT;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 4: //i8
|
||||
{
|
||||
for(x = 0; x < imageSize; ++x)
|
||||
case 3: //i4
|
||||
{
|
||||
u16 c = pal[adr[x]];
|
||||
*dwdst++ = RGB15TO32(c,(adr[x] == 0) ? palZeroTransparent : 255);
|
||||
CHECKSLOT;
|
||||
pal = (unsigned short *)(ARM9Mem.texPalSlot[0] + (texturePalette<<4));
|
||||
for(x = 0; x < (imageSize>>1); x++)
|
||||
{
|
||||
unsigned short c = pal[adr[x]&0xF];
|
||||
dst[0] = ((c & 0x1F)<<3);
|
||||
dst[1] = ((c & 0x3E0)>>2);
|
||||
dst[2] = ((c & 0x7C00)>>7);
|
||||
dst[3] = (((adr[x])&0xF) == 0) ? palZeroTransparent : 255;//(c>>15)*255;
|
||||
dst += 4;
|
||||
|
||||
c = pal[((adr[x])>>4)];
|
||||
dst[0] = ((c & 0x1F)<<3);
|
||||
dst[1] = ((c & 0x3E0)>>2);
|
||||
dst[2] = ((c & 0x7C00)>>7);
|
||||
dst[3] = (((adr[x]>>4)&0xF) == 0) ? palZeroTransparent : 255;//(c>>15)*255;
|
||||
dst += 4;
|
||||
CHECKSLOT;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 5: //4x4
|
||||
{
|
||||
unsigned short * slot1;
|
||||
unsigned int * map = (unsigned int *)adr;
|
||||
unsigned int d = 0;
|
||||
if ( (texcache[i].frm & 0xc000) == 0x8000)
|
||||
// texel are in slot 2
|
||||
slot1=(unsigned short*)&ARM9Mem.textureSlotAddr[1][((texcache[i].frm&0x3FFF)<<2)+0x010000];
|
||||
else
|
||||
slot1=(unsigned short*)&ARM9Mem.textureSlotAddr[1][(texcache[i].frm&0x3FFF)<<2];
|
||||
|
||||
bool dead = false;
|
||||
u16 yTmpSize = (texcache[i].sizeY>>2);
|
||||
u16 xTmpSize = (texcache[i].sizeX>>2);
|
||||
|
||||
for (y = 0; y < yTmpSize; y ++)
|
||||
case 4: //i8
|
||||
{
|
||||
pal = (unsigned short *)(ARM9Mem.texPalSlot[0] + (texturePalette<<4));
|
||||
for(x = 0; x < imageSize; ++x)
|
||||
{
|
||||
u16 c = pal[adr[x]];
|
||||
*dwdst++ = RGB15TO32(c,(adr[x] == 0) ? palZeroTransparent : 255);
|
||||
CHECKSLOT;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 5: //4x4
|
||||
{
|
||||
u32 tmpPos[4]={(y<<2)*texcache[i].sizeX,((y<<2)+1)*texcache[i].sizeX,
|
||||
((y<<2)+2)*texcache[i].sizeX,((y<<2)+3)*texcache[i].sizeX};
|
||||
for (x = 0; x < xTmpSize; x ++, d++)
|
||||
{
|
||||
u32 currBlock = map[d], sy;
|
||||
u16 pal1 = slot1[d];
|
||||
u16 pal1offset = (pal1 & 0x3FFF)<<1;
|
||||
u8 mode = pal1>>14;
|
||||
u32 tmp_col[4];
|
||||
pal = (unsigned short *)(ARM9Mem.texPalSlot[0] + (texturePalette<<4));
|
||||
unsigned short * slot1;
|
||||
unsigned int * map = (unsigned int *)adr;
|
||||
unsigned int d = 0;
|
||||
if ( (texcache[i].frm & 0xc000) == 0x8000)
|
||||
// texel are in slot 2
|
||||
slot1=(unsigned short*)&ARM9Mem.textureSlotAddr[1][((texcache[i].frm&0x3FFF)<<2)+0x010000];
|
||||
else
|
||||
slot1=(unsigned short*)&ARM9Mem.textureSlotAddr[1][(texcache[i].frm&0x3FFF)<<2];
|
||||
|
||||
tmp_col[0]=RGB16TO32(pal[pal1offset],255);
|
||||
tmp_col[1]=RGB16TO32(pal[pal1offset+1],255);
|
||||
bool dead = false;
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case 0:
|
||||
tmp_col[2]=RGB16TO32(pal[pal1offset+2],255);
|
||||
tmp_col[3]=RGB16TO32(0x7FFF,0);
|
||||
break;
|
||||
case 1:
|
||||
tmp_col[2]=(((tmp_col[0]&0xFF)+(tmp_col[1]&0xff))>>1)|
|
||||
(((tmp_col[0]&(0xFF<<8))+(tmp_col[1]&(0xFF<<8)))>>1)|
|
||||
(((tmp_col[0]&(0xFF<<16))+(tmp_col[1]&(0xFF<<16)))>>1)|
|
||||
(0xff<<24);
|
||||
tmp_col[3]=RGB16TO32(0x7FFF,0);
|
||||
break;
|
||||
case 2:
|
||||
tmp_col[2]=RGB16TO32(pal[pal1offset+2],255);
|
||||
tmp_col[3]=RGB16TO32(pal[pal1offset+3],255);
|
||||
break;
|
||||
case 3:
|
||||
for (y = 0; y < (texcache[i].sizeY>>2); y ++)
|
||||
{
|
||||
u32 tmpPos[4]={(y<<2)*texcache[i].sizeX,((y<<2)+1)*texcache[i].sizeX,
|
||||
((y<<2)+2)*texcache[i].sizeX,((y<<2)+3)*texcache[i].sizeX};
|
||||
for (x = 0; x < (texcache[i].sizeX>>2); x ++, d++)
|
||||
{
|
||||
u32 red1, red2;
|
||||
u32 green1, green2;
|
||||
u32 blue1, blue2;
|
||||
u16 tmp1, tmp2;
|
||||
u32 currBlock = map[d], sy;
|
||||
u16 pal1 = slot1[d];
|
||||
u16 pal1offset = (pal1 & 0x3FFF)<<1;
|
||||
u8 mode = pal1>>14;
|
||||
u32 tmp_col[4];
|
||||
|
||||
red1=tmp_col[0]&0xff;
|
||||
green1=(tmp_col[0]>>8)&0xff;
|
||||
blue1=(tmp_col[0]>>16)&0xff;
|
||||
red2=tmp_col[1]&0xff;
|
||||
green2=(tmp_col[1]>>8)&0xff;
|
||||
blue2=(tmp_col[1]>>16)&0xff;
|
||||
tmp_col[0]=RGB16TO32(pal[pal1offset],255);
|
||||
tmp_col[1]=RGB16TO32(pal[pal1offset+1],255);
|
||||
|
||||
tmp1=((red1*5+red2*3)>>6)|
|
||||
(((green1*5+green2*3)>>6)<<5)|
|
||||
(((blue1*5+blue2*3)>>6)<<10);
|
||||
tmp2=((red2*5+red1*3)>>6)|
|
||||
(((green2*5+green1*3)>>6)<<5)|
|
||||
(((blue2*5+blue1*3)>>6)<<10);
|
||||
|
||||
tmp_col[2]=RGB16TO32(tmp1,255);
|
||||
tmp_col[3]=RGB16TO32(tmp2,255);
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (sy = 0; sy < 4; sy++)
|
||||
switch (mode)
|
||||
{
|
||||
// Texture offset
|
||||
u32 currentPos = (x<<2) + tmpPos[sy];
|
||||
u8 currRow = (u8)((currBlock>>(sy<<3))&0xFF);
|
||||
|
||||
dwdst[currentPos] = tmp_col[currRow&3];
|
||||
dwdst[currentPos+1] = tmp_col[(currRow>>2)&3];
|
||||
dwdst[currentPos+2] = tmp_col[(currRow>>4)&3];
|
||||
dwdst[currentPos+3] = tmp_col[(currRow>>6)&3];
|
||||
|
||||
if(dead) {
|
||||
memset(dwdst, 0, sizeof(dwdst[0]) * 4);
|
||||
}
|
||||
|
||||
txt_slot_current_size-=4;;
|
||||
if (txt_slot_current_size<=0)
|
||||
case 0:
|
||||
tmp_col[2]=RGB16TO32(pal[pal1offset+2],255);
|
||||
tmp_col[3]=RGB16TO32(0x7FFF,0);
|
||||
break;
|
||||
case 1:
|
||||
tmp_col[2]=(((tmp_col[0]&0xFF)+(tmp_col[1]&0xff))>>1)|
|
||||
(((tmp_col[0]&(0xFF<<8))+(tmp_col[1]&(0xFF<<8)))>>1)|
|
||||
(((tmp_col[0]&(0xFF<<16))+(tmp_col[1]&(0xFF<<16)))>>1)|
|
||||
(0xff<<24);
|
||||
tmp_col[3]=RGB16TO32(0x7FFF,0);
|
||||
break;
|
||||
case 2:
|
||||
tmp_col[2]=RGB16TO32(pal[pal1offset+2],255);
|
||||
tmp_col[3]=RGB16TO32(pal[pal1offset+3],255);
|
||||
break;
|
||||
case 3:
|
||||
{
|
||||
//dead = true;
|
||||
txt_slot_current++;
|
||||
map=(unsigned int*)ARM9Mem.textureSlotAddr[txt_slot_current];
|
||||
map-=txt_slot_size>>2; //this is weird, but necessary since we use map[d] above
|
||||
txt_slot_size=txt_slot_current_size=0x020000;
|
||||
u32 red1, red2;
|
||||
u32 green1, green2;
|
||||
u32 blue1, blue2;
|
||||
u16 tmp1, tmp2;
|
||||
|
||||
red1=tmp_col[0]&0xff;
|
||||
green1=(tmp_col[0]>>8)&0xff;
|
||||
blue1=(tmp_col[0]>>16)&0xff;
|
||||
red2=tmp_col[1]&0xff;
|
||||
green2=(tmp_col[1]>>8)&0xff;
|
||||
blue2=(tmp_col[1]>>16)&0xff;
|
||||
|
||||
tmp1=((red1*5+red2*3)>>6)|
|
||||
(((green1*5+green2*3)>>6)<<5)|
|
||||
(((blue1*5+blue2*3)>>6)<<10);
|
||||
tmp2=((red2*5+red1*3)>>6)|
|
||||
(((green2*5+green1*3)>>6)<<5)|
|
||||
(((blue2*5+blue1*3)>>6)<<10);
|
||||
|
||||
tmp_col[2]=RGB16TO32(tmp1,255);
|
||||
tmp_col[3]=RGB16TO32(tmp2,255);
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (sy = 0; sy < 4; sy++)
|
||||
{
|
||||
// Texture offset
|
||||
u32 currentPos = (x<<2) + tmpPos[sy];
|
||||
u8 currRow = (u8)((currBlock>>(sy<<3))&0xFF);
|
||||
|
||||
dwdst[currentPos] = tmp_col[currRow&3];
|
||||
dwdst[currentPos+1] = tmp_col[(currRow>>2)&3];
|
||||
dwdst[currentPos+2] = tmp_col[(currRow>>4)&3];
|
||||
dwdst[currentPos+3] = tmp_col[(currRow>>6)&3];
|
||||
|
||||
if(dead) {
|
||||
memset(dwdst, 0, sizeof(dwdst[0]) * 4);
|
||||
}
|
||||
|
||||
txt_slot_current_size-=4;;
|
||||
if (txt_slot_current_size<=0)
|
||||
{
|
||||
//dead = true;
|
||||
txt_slot_current++;
|
||||
map=(unsigned int*)ARM9Mem.textureSlotAddr[txt_slot_current];
|
||||
map-=txt_slot_size>>2; //this is weird, but necessary since we use map[d] above
|
||||
txt_slot_size=txt_slot_current_size=0x020000;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
case 6: //a5i3
|
||||
{
|
||||
for(x = 0; x < imageSize; x++)
|
||||
{
|
||||
u16 c = pal[adr[x]&0x07];
|
||||
u8 alpha = (adr[x]>>3);
|
||||
*dwdst++ = RGB15TO32(c,material_5bit_to_8bit[alpha]);
|
||||
CHECKSLOT;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 7: //16bpp
|
||||
{
|
||||
unsigned short * map = ((unsigned short *)adr);
|
||||
|
||||
for(x = 0; x < imageSize; ++x)
|
||||
case 6: //a5i3
|
||||
{
|
||||
u16 c = map[x];
|
||||
int alpha = ((c&0x8000)?255:0);
|
||||
*dwdst++ = RGB15TO32(c&0x7FFF,alpha);
|
||||
|
||||
txt_slot_current_size-=2;;
|
||||
if (txt_slot_current_size<=0)
|
||||
pal = (unsigned short *)(ARM9Mem.texPalSlot[0] + (texturePalette<<4));
|
||||
for(x = 0; x < imageSize; x++)
|
||||
{
|
||||
txt_slot_current++;
|
||||
map=(unsigned short *)ARM9Mem.textureSlotAddr[txt_slot_current];
|
||||
map-=txt_slot_size>>1;
|
||||
txt_slot_size=txt_slot_current_size=0x020000;
|
||||
u16 c = pal[adr[x]&0x07];
|
||||
u8 alpha = (adr[x]>>3);
|
||||
*dwdst++ = RGB15TO32(c,material_5bit_to_8bit[alpha]);
|
||||
CHECKSLOT;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 7: //16bpp
|
||||
{
|
||||
unsigned short * map = ((unsigned short *)adr);
|
||||
pal = (unsigned short *)(ARM9Mem.texPalSlot[0] + (texturePalette<<4));
|
||||
|
||||
for(x = 0; x < imageSize; ++x)
|
||||
{
|
||||
u16 c = map[x];
|
||||
int alpha = ((c&0x8000)?255:0);
|
||||
*dwdst++ = RGB15TO32(c&0x7FFF,alpha);
|
||||
|
||||
txt_slot_current_size-=2;;
|
||||
if (txt_slot_current_size<=0)
|
||||
{
|
||||
txt_slot_current++;
|
||||
map=(unsigned short *)ARM9Mem.textureSlotAddr[txt_slot_current];
|
||||
map-=txt_slot_size>>1;
|
||||
txt_slot_size=txt_slot_current_size=0x020000;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
|
||||
texcache[i].sizeX, texcache[i].sizeY, 0,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE, texMAP);
|
||||
|
@ -1086,7 +1039,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);
|
||||
|
||||
|
@ -1167,7 +1120,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();
|
||||
|
||||
|
@ -1209,31 +1162,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);
|
||||
|
||||
|
@ -1243,7 +1195,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
|
||||
|
@ -1257,18 +1209,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];
|
||||
|
@ -1277,7 +1226,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];
|
||||
|
@ -1300,7 +1249,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;
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -32,11 +32,11 @@
|
|||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>0.8</string>
|
||||
<string>0.9</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>0.8</string>
|
||||
<string>0.9</string>
|
||||
<key>NSMainNibFile</key>
|
||||
<string>MainMenu</string>
|
||||
<key>NSPrincipalClass</key>
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue