support for non-rotscaled bitmap sprites

This commit is contained in:
StapleButter 2017-03-01 23:02:50 +01:00
parent 247558a354
commit f7c481b2a1
2 changed files with 149 additions and 91 deletions

View File

@ -1081,6 +1081,8 @@ void GPU2D::DrawSprite_Rotscale(u16* attrib, u16* rotparams, u32 boundwidth, u32
{
u32 prio = ((attrib[2] & 0x0C00) << 6) | 0x8000;
u32 tilenum = attrib[2] & 0x03FF;
u32 spritemode = (attrib[0] >> 10) & 0x3;
u32 ytilefactor;
if (DispCnt & 0x10)
{
@ -1119,6 +1121,8 @@ void GPU2D::DrawSprite_Rotscale(u16* attrib, u16* rotparams, u32 boundwidth, u32
width <<= 8;
height <<= 8;
//if (spritemode == 3) printf("BAKA");
if (attrib[0] & 0x2000)
{
// 256-color
@ -1191,15 +1195,7 @@ void GPU2D::DrawSprite_Normal(u16* attrib, u32 width, s32 xpos, u32 ypos, u32* d
{
u32 prio = ((attrib[2] & 0x0C00) << 6) | 0x8000;
u32 tilenum = attrib[2] & 0x03FF;
if (DispCnt & 0x10)
{
tilenum <<= ((DispCnt >> 20) & 0x3);
tilenum += ((ypos >> 3) * (width >> 3)) << ((attrib[0] & 0x2000) ? 1:0);
}
else
{
tilenum += ((ypos >> 3) * 0x20);
}
u32 spritemode = (attrib[0] >> 10) & 0x3;
u32 wmask = width - 8; // really ((width - 1) & ~0x7)
@ -1216,6 +1212,67 @@ void GPU2D::DrawSprite_Normal(u16* attrib, u32 width, s32 xpos, u32 ypos, u32* d
xpos = 0;
}
if (spritemode == 3)
{
// bitmap sprite
if (DispCnt & 0x40)
{
if (DispCnt & 0x20)
{
// TODO ("reserved")
}
else
{
tilenum <<= (7 + ((DispCnt >> 22) & 0x1));
tilenum += (ypos * width * 2);
}
}
else
{
if (DispCnt & 0x20)
{
tilenum = ((tilenum & 0x01F) << 4) + ((tilenum & 0x3E0) << 7);
tilenum += (ypos * 256 * 2);
}
else
{
tilenum = ((tilenum & 0x00F) << 4) + ((tilenum & 0x3F0) << 7);
tilenum += (ypos * 128 * 2);
}
}
u32 alpha = attrib[2] >> 12;
if (!alpha) return;
alpha++;
u32 pixelsaddr = (Num ? 0x06600000 : 0x06400000) + tilenum;
pixelsaddr += (xoff << 1);
for (; xoff < width;)
{
u16 color = GPU::ReadVRAM_OBJ<u16>(pixelsaddr);
pixelsaddr += 2;
if (color & 0x8000)
dst[xpos] = color | prio;
xoff++;
xpos++;
}
}
else
{
if (DispCnt & 0x10)
{
tilenum <<= ((DispCnt >> 20) & 0x3);
tilenum += ((ypos >> 3) * (width >> 3)) << ((attrib[0] & 0x2000) ? 1:0);
}
else
{
tilenum += ((ypos >> 3) * 0x20);
}
if (attrib[0] & 0x2000)
{
// 256-color
@ -1329,4 +1386,5 @@ void GPU2D::DrawSprite_Normal(u16* attrib, u32 width, s32 xpos, u32 ypos, u32* d
}
}
}
}
}

View File

@ -10,7 +10,7 @@
1481161027 c:\documents\sources\melonds\types.h
1488396811 source:c:\documents\sources\melonds\nds.cpp
1488405583 source:c:\documents\sources\melonds\nds.cpp
<stdio.h>
<string.h>
"NDS.h"
@ -87,7 +87,7 @@
"NDS.h"
"SPI.h"
1488396037 source:c:\documents\sources\melonds\gpu2d.cpp
1488405475 source:c:\documents\sources\melonds\gpu2d.cpp
<stdio.h>
<string.h>
"NDS.h"