* slightly better 3D polygons.
* fix sprite-related bugs. implement 256-color rotscaled sprites.
This commit is contained in:
parent
e5a4aa7c84
commit
bc335e31cb
34
GPU2D.cpp
34
GPU2D.cpp
|
@ -334,7 +334,7 @@ u16* GPU2D::GetOBJExtPal(u32 pal)
|
||||||
{
|
{
|
||||||
if (Num)
|
if (Num)
|
||||||
{
|
{
|
||||||
if (GPU::VRAMMap_BOBJExtPal & (1<<7))
|
if (GPU::VRAMMap_BOBJExtPal & (1<<8))
|
||||||
memcpy(dst, &GPU::VRAM_I[(pal << 9)], 256*2);
|
memcpy(dst, &GPU::VRAM_I[(pal << 9)], 256*2);
|
||||||
else
|
else
|
||||||
memset(dst, 0, 256*2);
|
memset(dst, 0, 256*2);
|
||||||
|
@ -864,7 +864,7 @@ void GPU2D::DrawSprite_Rotscale(u16* attrib, u16* rotparams, u32 boundwidth, u32
|
||||||
if (DispCnt & 0x10)
|
if (DispCnt & 0x10)
|
||||||
{
|
{
|
||||||
tilenum <<= ((DispCnt >> 20) & 0x3);
|
tilenum <<= ((DispCnt >> 20) & 0x3);
|
||||||
ytilefactor = (width >> 3);
|
ytilefactor = (width >> 3) << ((attrib[0] & 0x2000) ? 1:0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -901,6 +901,34 @@ void GPU2D::DrawSprite_Rotscale(u16* attrib, u16* rotparams, u32 boundwidth, u32
|
||||||
if (attrib[0] & 0x2000)
|
if (attrib[0] & 0x2000)
|
||||||
{
|
{
|
||||||
// 256-color
|
// 256-color
|
||||||
|
tilenum <<= 5;
|
||||||
|
ytilefactor <<= 5;
|
||||||
|
u32 pixelsaddr = (Num ? 0x06600000 : 0x06400000) + tilenum;
|
||||||
|
|
||||||
|
u32 extpal = (DispCnt & 0x80000000);
|
||||||
|
|
||||||
|
u16* pal;
|
||||||
|
if (extpal) pal = GetOBJExtPal(attrib[2] >> 12);
|
||||||
|
else pal = (u16*)&GPU::Palette[Num ? 0x600 : 0x200];
|
||||||
|
|
||||||
|
for (; xoff < boundwidth;)
|
||||||
|
{
|
||||||
|
if ((u32)rotX < width && (u32)rotY < height)
|
||||||
|
{
|
||||||
|
u8 color;
|
||||||
|
|
||||||
|
// blaaaarg
|
||||||
|
color = GPU::ReadVRAM_OBJ<u8>(pixelsaddr + ((rotY>>11)*ytilefactor) + ((rotY&0x700)>>5) + ((rotX>>11)*64) + ((rotX&0x700)>>8));
|
||||||
|
|
||||||
|
if (color)
|
||||||
|
dst[xpos] = pal[color] | prio;
|
||||||
|
}
|
||||||
|
|
||||||
|
rotX += rotA;
|
||||||
|
rotY += rotC;
|
||||||
|
xoff++;
|
||||||
|
xpos++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -949,7 +977,7 @@ void GPU2D::DrawSprite_Normal(u16* attrib, u32 width, s32 xpos, u32 ypos, u32* d
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
tilenum += ((ypos >> 3) * 0x20) << ((attrib[0] & 0x2000) ? 1:0);
|
tilenum += ((ypos >> 3) * 0x20);
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 wmask = width - 8; // really ((width - 1) & ~0x7)
|
u32 wmask = width - 8; // really ((width - 1) & ~0x7)
|
||||||
|
|
|
@ -250,15 +250,15 @@ void RenderPolygon(Polygon* polygon)
|
||||||
if (vlnext->FinalPosition[1] == vlcur->FinalPosition[1])
|
if (vlnext->FinalPosition[1] == vlcur->FinalPosition[1])
|
||||||
lfactor = 0;
|
lfactor = 0;
|
||||||
else
|
else
|
||||||
lfactor = (((y - vlcur->FinalPosition[1]) << 12) + 0x00) / (vlnext->FinalPosition[1] - vlcur->FinalPosition[1]);
|
lfactor = (((y+1 - vlcur->FinalPosition[1]) << 12) + 0x00) / (vlnext->FinalPosition[1] - vlcur->FinalPosition[1]);
|
||||||
|
|
||||||
if (vrnext->FinalPosition[1] == vrcur->FinalPosition[1])
|
if (vrnext->FinalPosition[1] == vrcur->FinalPosition[1])
|
||||||
rfactor = 0;
|
rfactor = 0;
|
||||||
else
|
else
|
||||||
rfactor = (((y - vrcur->FinalPosition[1]) << 12) + 0x00) / (vrnext->FinalPosition[1] - vrcur->FinalPosition[1]);
|
rfactor = (((y+1 - vrcur->FinalPosition[1]) << 12) + 0x00) / (vrnext->FinalPosition[1] - vrcur->FinalPosition[1]);
|
||||||
|
|
||||||
s32 xl = vlcur->FinalPosition[0] + (((vlnext->FinalPosition[0] - vlcur->FinalPosition[0]) * lfactor) >> 12);
|
s32 xl = vlcur->FinalPosition[0] + ((((vlnext->FinalPosition[0] - vlcur->FinalPosition[0]) * lfactor) + 0x800) >> 12);
|
||||||
s32 xr = vrcur->FinalPosition[0] + (((vrnext->FinalPosition[0] - vrcur->FinalPosition[0]) * rfactor) >> 12);
|
s32 xr = vrcur->FinalPosition[0] + ((((vrnext->FinalPosition[0] - vrcur->FinalPosition[0]) * rfactor) + 0x800) >> 12);
|
||||||
//printf("y:%d xl:%d xr:%d %08X\n", y, xl, xr, rfactor); // y: 48 143
|
//printf("y:%d xl:%d xr:%d %08X\n", y, xl, xr, rfactor); // y: 48 143
|
||||||
if (xl > xr) // TODO: handle it in a more elegant way
|
if (xl > xr) // TODO: handle it in a more elegant way
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
1481161027 c:\documents\sources\melonds\types.h
|
1481161027 c:\documents\sources\melonds\types.h
|
||||||
|
|
||||||
1488237361 source:c:\documents\sources\melonds\nds.cpp
|
1488281931 source:c:\documents\sources\melonds\nds.cpp
|
||||||
<stdio.h>
|
<stdio.h>
|
||||||
<string.h>
|
<string.h>
|
||||||
"NDS.h"
|
"NDS.h"
|
||||||
|
@ -87,7 +87,7 @@
|
||||||
"NDS.h"
|
"NDS.h"
|
||||||
"SPI.h"
|
"SPI.h"
|
||||||
|
|
||||||
1488226954 source:c:\documents\sources\melonds\gpu2d.cpp
|
1488281814 source:c:\documents\sources\melonds\gpu2d.cpp
|
||||||
<stdio.h>
|
<stdio.h>
|
||||||
<string.h>
|
<string.h>
|
||||||
"NDS.h"
|
"NDS.h"
|
||||||
|
@ -146,16 +146,16 @@
|
||||||
"NDS.h"
|
"NDS.h"
|
||||||
"NDSCart.h"
|
"NDSCart.h"
|
||||||
|
|
||||||
1488238607 c:\documents\sources\melonds\gpu3d.h
|
1488239485 c:\documents\sources\melonds\gpu3d.h
|
||||||
|
|
||||||
1488239360 source:c:\documents\sources\melonds\gpu3d.cpp
|
1488239513 source:c:\documents\sources\melonds\gpu3d.cpp
|
||||||
<stdio.h>
|
<stdio.h>
|
||||||
<string.h>
|
<string.h>
|
||||||
"NDS.h"
|
"NDS.h"
|
||||||
"GPU.h"
|
"GPU.h"
|
||||||
"FIFO.h"
|
"FIFO.h"
|
||||||
|
|
||||||
1488237540 source:c:\documents\sources\melonds\gpu3d_soft.cpp
|
1488244847 source:c:\documents\sources\melonds\gpu3d_soft.cpp
|
||||||
<stdio.h>
|
<stdio.h>
|
||||||
<string.h>
|
<string.h>
|
||||||
"NDS.h"
|
"NDS.h"
|
||||||
|
|
Loading…
Reference in New Issue