applied endian fixes in GPU thanks to Phazz
This commit is contained in:
parent
abd5e1bcb3
commit
e2936e40b2
|
@ -19,6 +19,7 @@
|
||||||
- Fixed possible segfault in ROMReader on ia64 and amd64. [evilynux]
|
- Fixed possible segfault in ROMReader on ia64 and amd64. [evilynux]
|
||||||
- Fixed a crash bug with 2D background corrupting memory [shash]
|
- Fixed a crash bug with 2D background corrupting memory [shash]
|
||||||
- Flag check optimization [carlo_bramini]
|
- Flag check optimization [carlo_bramini]
|
||||||
|
- Applied some endian fixes in GPU (thanks to Phazz) [Jeff B]
|
||||||
gtk-glade:
|
gtk-glade:
|
||||||
- Added DeSmuME version in about dialog. [evilynux]
|
- Added DeSmuME version in about dialog. [evilynux]
|
||||||
- Updated website url in about dialog. [evilynux]
|
- Updated website url in about dialog. [evilynux]
|
||||||
|
|
|
@ -1272,7 +1272,7 @@ INLINE void render_sprite_BMP (GPU * gpu, u16 l, u8 * dst, u16 * src, u8 * prioT
|
||||||
int i; u16 color;
|
int i; u16 color;
|
||||||
for(i = 0; i < lg; i++, ++sprX, x+=xdir)
|
for(i = 0; i < lg; i++, ++sprX, x+=xdir)
|
||||||
{
|
{
|
||||||
color = src[x];
|
color = LE_TO_LOCAL_16(src[x]);
|
||||||
|
|
||||||
// alpha bit = invisible
|
// alpha bit = invisible
|
||||||
if ((color&0x8000)&&(prio<=prioTab[sprX]))
|
if ((color&0x8000)&&(prio<=prioTab[sprX]))
|
||||||
|
@ -1301,7 +1301,7 @@ INLINE void render_sprite_256 ( GPU * gpu, u16 l, u8 * dst, u8 * src, u16 * pal,
|
||||||
for(i = 0; i < lg; i++, ++sprX, x+=xdir)
|
for(i = 0; i < lg; i++, ++sprX, x+=xdir)
|
||||||
{
|
{
|
||||||
palette_entry = src[(x&0x7) + ((x&0xFFF8)<<3)];
|
palette_entry = src[(x&0x7) + ((x&0xFFF8)<<3)];
|
||||||
color = pal[palette_entry];
|
color = LE_TO_LOCAL_16(pal[palette_entry]);
|
||||||
|
|
||||||
// palette entry = 0 means backdrop
|
// palette entry = 0 means backdrop
|
||||||
if ((palette_entry>0)&&(prio<=prioTab[sprX]))
|
if ((palette_entry>0)&&(prio<=prioTab[sprX]))
|
||||||
|
@ -1337,7 +1337,7 @@ INLINE void render_sprite_16 ( GPU * gpu, u16 l, u8 * dst, u8 * src, u16 * pal,
|
||||||
palette = src[(x1&0x3) + ((x1&0xFFFC)<<3)];
|
palette = src[(x1&0x3) + ((x1&0xFFFC)<<3)];
|
||||||
if (x & 1) palette_entry = palette >> 4;
|
if (x & 1) palette_entry = palette >> 4;
|
||||||
else palette_entry = palette & 0xF;
|
else palette_entry = palette & 0xF;
|
||||||
color = pal[palette_entry];
|
color = LE_TO_LOCAL_16(pal[palette_entry]);
|
||||||
|
|
||||||
// palette entry = 0 means backdrop
|
// palette entry = 0 means backdrop
|
||||||
if ((palette_entry>0)&&(prio<=prioTab[sprX]))
|
if ((palette_entry>0)&&(prio<=prioTab[sprX]))
|
||||||
|
@ -1436,13 +1436,26 @@ void sprite1D(GPU * gpu, u16 l, u8 * dst, u8 * prioTab)
|
||||||
u8 block = gpu->sprBoundary;
|
u8 block = gpu->sprBoundary;
|
||||||
u16 i;
|
u16 i;
|
||||||
|
|
||||||
for(i = 0; i<nbShow; ++i, --spriteInfo) /* check all sprites */
|
//for(i = 0; i<nbShow; ++i, --spriteInfo) /* check all sprites */
|
||||||
|
#ifdef WORDS_BIGENDIAN
|
||||||
|
*(((u16*)spriteInfo)+1) = (*(((u16*)spriteInfo)+1) >> 1) | *(((u16*)spriteInfo)+1) << 15;
|
||||||
|
*(((u16*)spriteInfo)+2) = (*(((u16*)spriteInfo)+2) >> 2) | *(((u16*)spriteInfo)+2) << 14;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
for(i = 0; i<nbShow; ++i, --spriteInfo
|
||||||
|
#ifdef WORDS_BIGENDIAN
|
||||||
|
,*(((u16*)(spriteInfo+1))+1) = (*(((u16*)(spriteInfo+1))+1) << 1) | *(((u16*)(spriteInfo+1))+1) >> 15
|
||||||
|
,*(((u16*)(spriteInfo+1))+2) = (*(((u16*)(spriteInfo+1))+2) << 2) | *(((u16*)(spriteInfo+1))+2) >> 14
|
||||||
|
,*(((u16*)spriteInfo)+1) = (*(((u16*)spriteInfo)+1) >> 1) | *(((u16*)spriteInfo)+1) << 15
|
||||||
|
,*(((u16*)spriteInfo)+2) = (*(((u16*)spriteInfo)+2) >> 2) | *(((u16*)spriteInfo)+2) << 14
|
||||||
|
#endif
|
||||||
|
) /* check all sprites */
|
||||||
{
|
{
|
||||||
size sprSize;
|
size sprSize;
|
||||||
s32 sprX, sprY, x, y, lg;
|
s32 sprX, sprY, x, y, lg;
|
||||||
int xdir;
|
int xdir;
|
||||||
u8 prio, * src;
|
u8 prio, * src;
|
||||||
u16 i,j;
|
u16 i;
|
||||||
|
|
||||||
// Check if sprite is disabled before everything
|
// Check if sprite is disabled before everything
|
||||||
if (spriteInfo->RotScale == 2)
|
if (spriteInfo->RotScale == 2)
|
||||||
|
@ -1671,6 +1684,11 @@ void sprite1D(GPU * gpu, u16 l, u8 * dst, u8 * prioTab)
|
||||||
render_sprite_16 (gpu, l, dst, src, pal, prioTab, prio, lg, sprX, x, xdir, spriteInfo->Mode == 1);
|
render_sprite_16 (gpu, l, dst, src, pal, prioTab, prio, lg, sprX, x, xdir, spriteInfo->Mode == 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef WORDS_BIGENDIAN
|
||||||
|
*(((u16*)spriteInfo)+1) = (*(((u16*)spriteInfo)+1) << 1) | *(((u16*)spriteInfo)+1) >> 15;
|
||||||
|
*(((u16*)spriteInfo)+2) = (*(((u16*)spriteInfo)+2) << 2) | *(((u16*)spriteInfo)+2) >> 14;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void sprite2D(GPU * gpu, u16 l, u8 * dst, u8 * prioTab)
|
void sprite2D(GPU * gpu, u16 l, u8 * dst, u8 * prioTab)
|
||||||
|
@ -1679,7 +1697,19 @@ void sprite2D(GPU * gpu, u16 l, u8 * dst, u8 * prioTab)
|
||||||
_OAM_ * spriteInfo = (_OAM_*)(gpu->oam + (nbShow-1));// + 127;
|
_OAM_ * spriteInfo = (_OAM_*)(gpu->oam + (nbShow-1));// + 127;
|
||||||
u16 i;
|
u16 i;
|
||||||
|
|
||||||
for(i = 0; i<nbShow; ++i, --spriteInfo)
|
#ifdef WORDS_BIGENDIAN
|
||||||
|
*(((u16*)spriteInfo)+1) = (*(((u16*)spriteInfo)+1) >> 1) | *(((u16*)spriteInfo)+1) << 15;
|
||||||
|
*(((u16*)spriteInfo)+2) = (*(((u16*)spriteInfo)+2) >> 2) | *(((u16*)spriteInfo)+2) << 14;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
for(i = 0; i<nbShow; ++i, --spriteInfo
|
||||||
|
#ifdef WORDS_BIGENDIAN
|
||||||
|
,*(((u16*)(spriteInfo+1))+1) = (*(((u16*)(spriteInfo+1))+1) << 1) | *(((u16*)(spriteInfo+1))+1) >> 15
|
||||||
|
,*(((u16*)(spriteInfo+1))+2) = (*(((u16*)(spriteInfo+1))+2) << 2) | *(((u16*)(spriteInfo+1))+2) >> 14
|
||||||
|
,*(((u16*)spriteInfo)+1) = (*(((u16*)spriteInfo)+1) >> 1) | *(((u16*)spriteInfo)+1) << 15
|
||||||
|
,*(((u16*)spriteInfo)+2) = (*(((u16*)spriteInfo)+2) >> 2) | *(((u16*)spriteInfo)+2) << 14
|
||||||
|
#endif
|
||||||
|
) /* check all sprites */
|
||||||
{
|
{
|
||||||
size sprSize;
|
size sprSize;
|
||||||
s32 sprX, sprY, x, y, lg;
|
s32 sprX, sprY, x, y, lg;
|
||||||
|
@ -1915,6 +1945,11 @@ void sprite2D(GPU * gpu, u16 l, u8 * dst, u8 * prioTab)
|
||||||
prioTab, prio, lg, sprX, x, xdir, spriteInfo->Mode == 1);
|
prioTab, prio, lg, sprX, x, xdir, spriteInfo->Mode == 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef WORDS_BIGENDIAN
|
||||||
|
*(((u16*)spriteInfo)+1) = (*(((u16*)spriteInfo)+1) << 1) | *(((u16*)spriteInfo)+1) >> 15;
|
||||||
|
*(((u16*)spriteInfo)+2) = (*(((u16*)spriteInfo)+2) << 2) | *(((u16*)spriteInfo)+2) >> 14;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -2415,7 +2450,7 @@ void GPU_ligne(NDS_Screen * screen, u16 l)
|
||||||
#ifndef BRIGHT_TABLES
|
#ifndef BRIGHT_TABLES
|
||||||
u8 base ;
|
u8 base ;
|
||||||
u8 r,g,b; // get components, 5bit each
|
u8 r,g,b; // get components, 5bit each
|
||||||
dstColor.val = T1ReadWord(dst, i16 << 1);
|
dstColor.val = *((u16 *) (dst + (i16 << 1)));
|
||||||
r = dstColor.bits.red;
|
r = dstColor.bits.red;
|
||||||
g = dstColor.bits.green;
|
g = dstColor.bits.green;
|
||||||
b = dstColor.bits.blue;
|
b = dstColor.bits.blue;
|
||||||
|
@ -2428,7 +2463,7 @@ void GPU_ligne(NDS_Screen * screen, u16 l)
|
||||||
dstColor.val = T1ReadWord(dst, i16 << 1);
|
dstColor.val = T1ReadWord(dst, i16 << 1);
|
||||||
dstColor.bitx.bgr = colors[dstColor.bitx.bgr];
|
dstColor.bitx.bgr = colors[dstColor.bitx.bgr];
|
||||||
#endif
|
#endif
|
||||||
T2WriteWord (dst, i16 << 1, dstColor.val);
|
*((u16 *) (dst + (i16 << 1))) = dstColor.val;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2464,7 +2499,7 @@ void GPU_ligne(NDS_Screen * screen, u16 l)
|
||||||
{
|
{
|
||||||
#ifndef BRIGHT_TABLES
|
#ifndef BRIGHT_TABLES
|
||||||
u8 r,g,b;
|
u8 r,g,b;
|
||||||
dstColor.val = T1ReadWord(dst, i16 << 1);
|
dstColor.val = *((u16 *) (dst + (i16 << 1)));
|
||||||
r = dstColor.bits.red;
|
r = dstColor.bits.red;
|
||||||
g = dstColor.bits.green;
|
g = dstColor.bits.green;
|
||||||
b = dstColor.bits.blue;
|
b = dstColor.bits.blue;
|
||||||
|
@ -2476,7 +2511,7 @@ void GPU_ligne(NDS_Screen * screen, u16 l)
|
||||||
dstColor.val = T1ReadWord(dst, i16 << 1);
|
dstColor.val = T1ReadWord(dst, i16 << 1);
|
||||||
dstColor.bitx.bgr = colors[dstColor.bitx.bgr];
|
dstColor.bitx.bgr = colors[dstColor.bitx.bgr];
|
||||||
#endif
|
#endif
|
||||||
T2WriteWord (dst, i16 << 1, dstColor.val);
|
*((u16 *) (dst + (i16 << 1))) = dstColor.val;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -466,10 +466,17 @@ typedef union
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct _COLOR { // abgr x555
|
struct _COLOR { // abgr x555
|
||||||
|
#ifdef WORDS_BIGENDIAN
|
||||||
|
unsigned alpha:1; // sometimes it is unused (pad)
|
||||||
|
unsigned blue:5;
|
||||||
|
unsigned green:5;
|
||||||
|
unsigned red:5;
|
||||||
|
#else
|
||||||
unsigned red:5;
|
unsigned red:5;
|
||||||
unsigned green:5;
|
unsigned green:5;
|
||||||
unsigned blue:5;
|
unsigned blue:5;
|
||||||
unsigned alpha:1; // sometimes it is unused (pad)
|
unsigned alpha:1; // sometimes it is unused (pad)
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
struct _COLORx { // abgr x555
|
struct _COLORx { // abgr x555
|
||||||
unsigned bgr:15;
|
unsigned bgr:15;
|
||||||
|
@ -521,6 +528,27 @@ ref: http://www.bottledlight.com/ds/index.php/Video/Sprites
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
#ifdef WORDS_BIGENDIAN
|
||||||
|
// attr0
|
||||||
|
/* 0*/ unsigned Y:8;
|
||||||
|
/*14*/ unsigned Shape:2; // (00: Square, 01: Wide, 10: Tall, 11: Illegal)
|
||||||
|
/*13*/ unsigned Depth:1; // (0: 16, 1: 256)
|
||||||
|
/*12*/ unsigned Mosaic:1; // (1: Enabled)
|
||||||
|
/*10*/ unsigned Mode:2; // (00: Normal, 01: Transparent, 10: Object window, 11: Bitmap)
|
||||||
|
/* 8*/ unsigned RotScale:2; // (00: Normal, 01: Rot/scale, 10: Disabled, 11: Double-size rot/scale)
|
||||||
|
// attr1
|
||||||
|
/* 0*/ signed X:9;
|
||||||
|
/*14*/ unsigned Size:2;
|
||||||
|
/*13*/ unsigned VFlip:1;
|
||||||
|
/*12*/ unsigned HFlip:1;
|
||||||
|
/* 9*/ unsigned RotScalIndex:3; // Rot/scale matrix index
|
||||||
|
// attr2
|
||||||
|
/* 0*/ unsigned TileIndex:10;
|
||||||
|
/*12*/ unsigned PaletteIndex:4;
|
||||||
|
/*10*/ unsigned Priority:2;
|
||||||
|
// attr3
|
||||||
|
unsigned attr3:16;
|
||||||
|
#else
|
||||||
// attr0
|
// attr0
|
||||||
/* 0*/ unsigned Y:8;
|
/* 0*/ unsigned Y:8;
|
||||||
/* 8*/ unsigned RotScale:2; // (00: Normal, 01: Rot/scale, 10: Disabled, 11: Double-size rot/scale)
|
/* 8*/ unsigned RotScale:2; // (00: Normal, 01: Rot/scale, 10: Disabled, 11: Double-size rot/scale)
|
||||||
|
@ -540,6 +568,7 @@ typedef struct
|
||||||
/*12*/ unsigned PaletteIndex:4;
|
/*12*/ unsigned PaletteIndex:4;
|
||||||
// attr3
|
// attr3
|
||||||
unsigned attr3:16;
|
unsigned attr3:16;
|
||||||
|
#endif
|
||||||
} _OAM_;
|
} _OAM_;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
|
Loading…
Reference in New Issue