diff options
author | StapleButter <thetotalworm@gmail.com> | 2017-02-04 00:07:25 +0100 |
---|---|---|
committer | StapleButter <thetotalworm@gmail.com> | 2017-02-04 00:07:25 +0100 |
commit | 67f0c7b123e0df3334e2a5c7c2ba889acab4cf10 (patch) | |
tree | 440c4723a180be70911099db032d8a54f90ca69d | |
parent | 4b3f635c9f4d19bbb643c9f0a9686a8339405f86 (diff) |
256-color sprites. code's weird tho. check it later.
-rw-r--r-- | GPU2D.cpp | 49 | ||||
-rw-r--r-- | NDS.cpp | 2 | ||||
-rw-r--r-- | melonDS.depend | 2 |
3 files changed, 49 insertions, 4 deletions
@@ -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 { @@ -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" |