aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--GPU2D.cpp34
-rw-r--r--GPU3D_Soft.cpp8
-rw-r--r--melonDS.depend10
3 files changed, 40 insertions, 12 deletions
diff --git a/GPU2D.cpp b/GPU2D.cpp
index 8479d97..de3636e 100644
--- a/GPU2D.cpp
+++ b/GPU2D.cpp
@@ -334,7 +334,7 @@ u16* GPU2D::GetOBJExtPal(u32 pal)
{
if (Num)
{
- if (GPU::VRAMMap_BOBJExtPal & (1<<7))
+ if (GPU::VRAMMap_BOBJExtPal & (1<<8))
memcpy(dst, &GPU::VRAM_I[(pal << 9)], 256*2);
else
memset(dst, 0, 256*2);
@@ -864,7 +864,7 @@ void GPU2D::DrawSprite_Rotscale(u16* attrib, u16* rotparams, u32 boundwidth, u32
if (DispCnt & 0x10)
{
tilenum <<= ((DispCnt >> 20) & 0x3);
- ytilefactor = (width >> 3);
+ ytilefactor = (width >> 3) << ((attrib[0] & 0x2000) ? 1:0);
}
else
{
@@ -901,6 +901,34 @@ void GPU2D::DrawSprite_Rotscale(u16* attrib, u16* rotparams, u32 boundwidth, u32
if (attrib[0] & 0x2000)
{
// 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
{
@@ -949,7 +977,7 @@ void GPU2D::DrawSprite_Normal(u16* attrib, u32 width, s32 xpos, u32 ypos, u32* d
}
else
{
- tilenum += ((ypos >> 3) * 0x20) << ((attrib[0] & 0x2000) ? 1:0);
+ tilenum += ((ypos >> 3) * 0x20);
}
u32 wmask = width - 8; // really ((width - 1) & ~0x7)
diff --git a/GPU3D_Soft.cpp b/GPU3D_Soft.cpp
index 4549d4d..6ea1ba4 100644
--- a/GPU3D_Soft.cpp
+++ b/GPU3D_Soft.cpp
@@ -250,15 +250,15 @@ void RenderPolygon(Polygon* polygon)
if (vlnext->FinalPosition[1] == vlcur->FinalPosition[1])
lfactor = 0;
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])
rfactor = 0;
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 xr = vrcur->FinalPosition[0] + (((vrnext->FinalPosition[0] - vrcur->FinalPosition[0]) * rfactor) >> 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) + 0x800) >> 12);
//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
{
diff --git a/melonDS.depend b/melonDS.depend
index f479ee8..adc1947 100644
--- a/melonDS.depend
+++ b/melonDS.depend
@@ -10,7 +10,7 @@
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>
<string.h>
"NDS.h"
@@ -87,7 +87,7 @@
"NDS.h"
"SPI.h"
-1488226954 source:c:\documents\sources\melonds\gpu2d.cpp
+1488281814 source:c:\documents\sources\melonds\gpu2d.cpp
<stdio.h>
<string.h>
"NDS.h"
@@ -146,16 +146,16 @@
"NDS.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>
<string.h>
"NDS.h"
"GPU.h"
"FIFO.h"
-1488237540 source:c:\documents\sources\melonds\gpu3d_soft.cpp
+1488244847 source:c:\documents\sources\melonds\gpu3d_soft.cpp
<stdio.h>
<string.h>
"NDS.h"