aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStapleButter <thetotalworm@gmail.com>2017-02-04 00:07:25 +0100
committerStapleButter <thetotalworm@gmail.com>2017-02-04 00:07:25 +0100
commit67f0c7b123e0df3334e2a5c7c2ba889acab4cf10 (patch)
tree440c4723a180be70911099db032d8a54f90ca69d
parent4b3f635c9f4d19bbb643c9f0a9686a8339405f86 (diff)
256-color sprites. code's weird tho. check it later.
-rw-r--r--GPU2D.cpp49
-rw-r--r--NDS.cpp2
-rw-r--r--melonDS.depend2
3 files changed, 49 insertions, 4 deletions
diff --git a/GPU2D.cpp b/GPU2D.cpp
index ac60d45..e456f79 100644
--- a/GPU2D.cpp
+++ b/GPU2D.cpp
@@ -793,11 +793,11 @@ void GPU2D::DrawSprite_Normal(u16* attrib, u32 width, s32 xpos, u32 ypos, u32* d
if (DispCnt & 0x10)
{
tilenum <<= ((DispCnt >> 20) & 0x3);
- tilenum += ((ypos >> 3) * (width >> 3));
+ tilenum += ((ypos >> 3) * (width >> 3)) << ((attrib[0] & 0x2000) ? 1:0);
}
else
{
- tilenum += ((ypos >> 3) * 0x20);
+ tilenum += ((ypos >> 3) * 0x20) << ((attrib[0] & 0x2000) ? 1:0);
}
u32 wmask = width - 8; // really ((width - 1) & ~0x7)
@@ -818,6 +818,51 @@ void GPU2D::DrawSprite_Normal(u16* attrib, u32 width, s32 xpos, u32 ypos, u32* d
if (attrib[0] & 0x2000)
{
// 256-color
+ tilenum <<= 5;
+ u8* pixels = (Num ? GPU::VRAM_BOBJ : GPU::VRAM_AOBJ)[tilenum >> 14];
+ if (!pixels) return;
+ pixels += (tilenum & 0x3FFF);
+ pixels += ((ypos & 0x7) << 3);
+
+ u16* pal = (u16*)&GPU::Palette[Num ? 0x600 : 0x200];
+ //pal += (attrib[2] & 0xF000) >> 8;
+
+ if (attrib[1] & 0x1000) // xflip. TODO: do better? oh well for now this works
+ {
+ pixels += (((width-1 - xoff) & wmask) << 3);
+ pixels += ((width-1 - xoff) & 0x7);
+
+ for (; xoff < width;)
+ {
+ u8 color = *pixels;
+ pixels--;
+
+ if (color)
+ dst[xpos] = pal[color] | prio;
+
+ xoff++;
+ xpos++;
+ if (!(xoff & 0x7)) pixels -= 56;
+ }
+ }
+ else
+ {
+ pixels += ((xoff & wmask) << 3);
+ pixels += (xoff & 0x7);
+
+ for (; xoff < width;)
+ {
+ u8 color = *pixels;
+ pixels++;
+
+ if (color)
+ dst[xpos] = pal[color] | prio;
+
+ xoff++;
+ xpos++;
+ if (!(xoff & 0x7)) pixels += 56;
+ }
+ }
}
else
{
diff --git a/NDS.cpp b/NDS.cpp
index 7439c8c..d1d0c4b 100644
--- a/NDS.cpp
+++ b/NDS.cpp
@@ -274,7 +274,7 @@ void Reset()
// test
//LoadROM();
//LoadFirmware();
- NDSCart::LoadROM("rom/raving.nds");
+ NDSCart::LoadROM("rom/nsmb.nds");
Running = true; // hax
}
diff --git a/melonDS.depend b/melonDS.depend
index 6cd824f..5da2753 100644
--- a/melonDS.depend
+++ b/melonDS.depend
@@ -86,7 +86,7 @@
"NDS.h"
"SPI.h"
-1486162082 source:c:\documents\sources\melonds\gpu2d.cpp
+1486163016 source:c:\documents\sources\melonds\gpu2d.cpp
<stdio.h>
<string.h>
"NDS.h"