mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-07-23 14:19:55 -06:00
256-color sprites. code's weird tho. check it later.
This commit is contained in:
49
GPU2D.cpp
49
GPU2D.cpp
@ -793,11 +793,11 @@ void GPU2D::DrawSprite_Normal(u16* attrib, u32 width, s32 xpos, u32 ypos, u32* d
|
|||||||
if (DispCnt & 0x10)
|
if (DispCnt & 0x10)
|
||||||
{
|
{
|
||||||
tilenum <<= ((DispCnt >> 20) & 0x3);
|
tilenum <<= ((DispCnt >> 20) & 0x3);
|
||||||
tilenum += ((ypos >> 3) * (width >> 3));
|
tilenum += ((ypos >> 3) * (width >> 3)) << ((attrib[0] & 0x2000) ? 1:0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
tilenum += ((ypos >> 3) * 0x20);
|
tilenum += ((ypos >> 3) * 0x20) << ((attrib[0] & 0x2000) ? 1:0);
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 wmask = width - 8; // really ((width - 1) & ~0x7)
|
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)
|
if (attrib[0] & 0x2000)
|
||||||
{
|
{
|
||||||
// 256-color
|
// 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
|
else
|
||||||
{
|
{
|
||||||
|
2
NDS.cpp
2
NDS.cpp
@ -274,7 +274,7 @@ void Reset()
|
|||||||
// test
|
// test
|
||||||
//LoadROM();
|
//LoadROM();
|
||||||
//LoadFirmware();
|
//LoadFirmware();
|
||||||
NDSCart::LoadROM("rom/raving.nds");
|
NDSCart::LoadROM("rom/nsmb.nds");
|
||||||
|
|
||||||
Running = true; // hax
|
Running = true; // hax
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,7 @@
|
|||||||
"NDS.h"
|
"NDS.h"
|
||||||
"SPI.h"
|
"SPI.h"
|
||||||
|
|
||||||
1486162082 source:c:\documents\sources\melonds\gpu2d.cpp
|
1486163016 source:c:\documents\sources\melonds\gpu2d.cpp
|
||||||
<stdio.h>
|
<stdio.h>
|
||||||
<string.h>
|
<string.h>
|
||||||
"NDS.h"
|
"NDS.h"
|
||||||
|
Reference in New Issue
Block a user