mirror of
https://github.com/rafaelvcaetano/melonDS-android-lib.git
synced 2024-11-30 09:01:20 +00:00
correct VRAM emulation.
there is room for optimizations esp. in the GPU drawing routines.
This commit is contained in:
parent
dadf1eb5a5
commit
8c2572e354
551
GPU.cpp
551
GPU.cpp
@ -50,17 +50,37 @@ u8* VRAM[9] = {VRAM_A, VRAM_B, VRAM_C, VRAM_D, VRAM_E, VRAM_F, VRAM_G, VRAM_H, V
|
||||
u8 VRAMCNT[9];
|
||||
u8 VRAMSTAT;
|
||||
|
||||
u8* VRAM_ABG[128];
|
||||
//u32 VRAM_Base[9];
|
||||
//u32 VRAM_Mask[9];
|
||||
|
||||
u32 VRAMMap_LCDC;
|
||||
|
||||
u32 VRAMMap_ABG[0x20];
|
||||
u32 VRAMMap_AOBJ[0x10];
|
||||
u32 VRAMMap_BBG[0x8];
|
||||
u32 VRAMMap_BOBJ[0x8];
|
||||
|
||||
u32 VRAMMap_ABGExtPal[4];
|
||||
u32 VRAMMap_AOBJExtPal;
|
||||
u32 VRAMMap_BBGExtPal[4];
|
||||
u32 VRAMMap_BOBJExtPal;
|
||||
|
||||
u32 VRAMMap_Texture[4];
|
||||
u32 VRAMMap_TexPal[6];
|
||||
|
||||
u32 VRAMMap_ARM7[2];
|
||||
|
||||
/*u8* VRAM_ABG[128];
|
||||
u8* VRAM_AOBJ[128];
|
||||
u8* VRAM_BBG[128];
|
||||
u8* VRAM_BOBJ[128];
|
||||
u8* VRAM_LCD[128];
|
||||
u8* VRAM_ARM7[2];
|
||||
u8* VRAM_LCD[128];*/
|
||||
/*u8* VRAM_ARM7[2];
|
||||
|
||||
u8* VRAM_ABGExtPal[4];
|
||||
u8* VRAM_AOBJExtPal;
|
||||
u8* VRAM_BBGExtPal[4];
|
||||
u8* VRAM_BOBJExtPal;
|
||||
u8* VRAM_BOBJExtPal;*/
|
||||
|
||||
u32 Framebuffer[256*192*2];
|
||||
|
||||
@ -109,17 +129,38 @@ void Reset()
|
||||
memset(VRAMCNT, 0, 9);
|
||||
VRAMSTAT = 0;
|
||||
|
||||
memset(VRAM_ABG, 0, sizeof(u8*)*128);
|
||||
VRAMMap_LCDC = 0;
|
||||
|
||||
memset(VRAMMap_ABG, 0, sizeof(VRAMMap_ABG));
|
||||
memset(VRAMMap_AOBJ, 0, sizeof(VRAMMap_AOBJ));
|
||||
memset(VRAMMap_BBG, 0, sizeof(VRAMMap_BBG));
|
||||
memset(VRAMMap_BOBJ, 0, sizeof(VRAMMap_BOBJ));
|
||||
|
||||
memset(VRAMMap_ABGExtPal, 0, sizeof(VRAMMap_ABGExtPal));
|
||||
VRAMMap_AOBJExtPal = 0;
|
||||
memset(VRAMMap_BBGExtPal, 0, sizeof(VRAMMap_BBGExtPal));
|
||||
VRAMMap_BOBJExtPal = 0;
|
||||
|
||||
memset(VRAMMap_Texture, 0, sizeof(VRAMMap_Texture));
|
||||
memset(VRAMMap_TexPal, 0, sizeof(VRAMMap_TexPal));
|
||||
|
||||
VRAMMap_ARM7[0] = 0;
|
||||
VRAMMap_ARM7[1] = 0;
|
||||
|
||||
//memset(VRAM_Base, 0, sizeof(VRAM_Base));
|
||||
//memset(VRAM_Mask, 0, sizeof(VRAM_Mask));
|
||||
|
||||
/*memset(VRAM_ABG, 0, sizeof(u8*)*128);
|
||||
memset(VRAM_AOBJ, 0, sizeof(u8*)*128);
|
||||
memset(VRAM_BBG, 0, sizeof(u8*)*128);
|
||||
memset(VRAM_BOBJ, 0, sizeof(u8*)*128);
|
||||
memset(VRAM_LCD, 0, sizeof(u8*)*128);
|
||||
memset(VRAM_ARM7, 0, sizeof(u8*)*2);
|
||||
memset(VRAM_LCD, 0, sizeof(u8*)*128);*/
|
||||
/*memset(VRAM_ARM7, 0, sizeof(u8*)*2);
|
||||
|
||||
memset(VRAM_ABGExtPal, 0, sizeof(u8*)*4);
|
||||
VRAM_AOBJExtPal = NULL;
|
||||
memset(VRAM_BBGExtPal, 0, sizeof(u8*)*4);
|
||||
VRAM_BOBJExtPal = NULL;
|
||||
VRAM_BOBJExtPal = NULL;*/
|
||||
|
||||
for (int i = 0; i < 256*192*2; i++)
|
||||
{
|
||||
@ -165,6 +206,9 @@ void Reset()
|
||||
// when reading: values are read from each bank and ORed together
|
||||
// when writing: value is written to each bank
|
||||
|
||||
#define MAP_RANGE(map, base, n) for (int i = 0; i < n; i++) map[(base)+i] |= bankmask;
|
||||
#define UNMAP_RANGE(map, base, n) for (int i = 0; i < n; i++) map[(base)+i] &= ~bankmask;
|
||||
|
||||
void MapVRAM_AB(u32 bank, u8 cnt)
|
||||
{
|
||||
u8 oldcnt = VRAMCNT[bank];
|
||||
@ -174,81 +218,52 @@ void MapVRAM_AB(u32 bank, u8 cnt)
|
||||
|
||||
u8 oldofs = (oldcnt >> 3) & 0x3;
|
||||
u8 ofs = (cnt >> 3) & 0x3;
|
||||
|
||||
u8* vram = VRAM[bank];
|
||||
u32 bankmask = 1 << bank;
|
||||
|
||||
if (oldcnt & (1<<7))
|
||||
{
|
||||
u8** vrammap = NULL;
|
||||
|
||||
switch (oldcnt & 0x3)
|
||||
{
|
||||
case 0:
|
||||
vrammap = &VRAM_LCD[bank<<3];
|
||||
case 0: // LCDC
|
||||
VRAMMap_LCDC &= ~bankmask;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
vrammap = &VRAM_ABG[oldofs<<3];
|
||||
case 1: // ABG
|
||||
UNMAP_RANGE(VRAMMap_ABG, oldofs<<3, 8);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
case 2: // AOBJ
|
||||
oldofs &= 0x1;
|
||||
vrammap = &VRAM_AOBJ[oldofs<<3];
|
||||
UNMAP_RANGE(VRAMMap_AOBJ, oldofs<<3, 8);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
// not mapped to memory
|
||||
case 3: // texture
|
||||
VRAMMap_Texture[oldofs] &= ~bankmask;
|
||||
break;
|
||||
}
|
||||
|
||||
if (vrammap && *vrammap == vram)
|
||||
{
|
||||
*vrammap++ = NULL;
|
||||
*vrammap++ = NULL;
|
||||
*vrammap++ = NULL;
|
||||
*vrammap++ = NULL;
|
||||
*vrammap++ = NULL;
|
||||
*vrammap++ = NULL;
|
||||
*vrammap++ = NULL;
|
||||
*vrammap = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (cnt & (1<<7))
|
||||
{
|
||||
u8** vrammap = NULL;
|
||||
|
||||
switch (cnt & 0x3)
|
||||
{
|
||||
case 0:
|
||||
vrammap = &VRAM_LCD[bank<<3];
|
||||
case 0: // LCDC
|
||||
VRAMMap_LCDC |= bankmask;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
vrammap = &VRAM_ABG[ofs<<3];
|
||||
case 1: // ABG
|
||||
MAP_RANGE(VRAMMap_ABG, ofs<<3, 8);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
case 2: // AOBJ
|
||||
ofs &= 0x1;
|
||||
vrammap = &VRAM_AOBJ[ofs<<3];
|
||||
MAP_RANGE(VRAMMap_AOBJ, ofs<<3, 8);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
// not mapped to memory
|
||||
case 3: // texture
|
||||
VRAMMap_Texture[ofs] |= bankmask;
|
||||
break;
|
||||
}
|
||||
|
||||
if (vrammap)
|
||||
{
|
||||
*vrammap++ = vram; vram += 0x4000;
|
||||
*vrammap++ = vram; vram += 0x4000;
|
||||
*vrammap++ = vram; vram += 0x4000;
|
||||
*vrammap++ = vram; vram += 0x4000;
|
||||
*vrammap++ = vram; vram += 0x4000;
|
||||
*vrammap++ = vram; vram += 0x4000;
|
||||
*vrammap++ = vram; vram += 0x4000;
|
||||
*vrammap = vram;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -263,96 +278,75 @@ void MapVRAM_CD(u32 bank, u8 cnt)
|
||||
|
||||
u8 oldofs = (oldcnt >> 3) & 0x7;
|
||||
u8 ofs = (cnt >> 3) & 0x7;
|
||||
|
||||
u8* vram = VRAM[bank];
|
||||
u32 bankmask = 1 << bank;
|
||||
|
||||
if (oldcnt & (1<<7))
|
||||
{
|
||||
u8** vrammap = NULL;
|
||||
|
||||
switch (oldcnt & 0x7)
|
||||
{
|
||||
case 0:
|
||||
vrammap = &VRAM_LCD[bank<<3];
|
||||
case 0: // LCDC
|
||||
VRAMMap_LCDC &= ~bankmask;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
vrammap = &VRAM_ABG[oldofs<<3];
|
||||
case 1: // ABG
|
||||
UNMAP_RANGE(VRAMMap_ABG, oldofs<<3, 8);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
case 2: // ARM7 VRAM
|
||||
oldofs &= 0x1;
|
||||
VRAM_ARM7[oldofs] = NULL;
|
||||
VRAMMap_ARM7[oldofs] &= ~bankmask;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
// not mapped to memory
|
||||
case 3: // texture
|
||||
VRAMMap_Texture[oldofs] &= ~bankmask;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
case 4: // BBG/BOBJ
|
||||
if (bank == 2)
|
||||
vrammap = &VRAM_BBG[0];
|
||||
{
|
||||
UNMAP_RANGE(VRAMMap_BBG, 0, 8);
|
||||
}
|
||||
else
|
||||
vrammap = &VRAM_BOBJ[0];
|
||||
{
|
||||
UNMAP_RANGE(VRAMMap_BOBJ, 0, 8);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (vrammap && *vrammap == vram)
|
||||
{
|
||||
*vrammap++ = NULL;
|
||||
*vrammap++ = NULL;
|
||||
*vrammap++ = NULL;
|
||||
*vrammap++ = NULL;
|
||||
*vrammap++ = NULL;
|
||||
*vrammap++ = NULL;
|
||||
*vrammap++ = NULL;
|
||||
*vrammap = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (cnt & (1<<7))
|
||||
{
|
||||
u8** vrammap = NULL;
|
||||
|
||||
switch (cnt & 0x7)
|
||||
{
|
||||
case 0:
|
||||
vrammap = &VRAM_LCD[bank<<3];
|
||||
case 0: // LCDC
|
||||
VRAMMap_LCDC |= bankmask;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
vrammap = &VRAM_ABG[ofs<<3];
|
||||
case 1: // ABG
|
||||
MAP_RANGE(VRAMMap_ABG, ofs<<3, 8);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
case 2: // ARM7 VRAM
|
||||
ofs &= 0x1;
|
||||
VRAM_ARM7[ofs] = vram;
|
||||
VRAMMap_ARM7[ofs] |= bankmask;
|
||||
VRAMSTAT |= (1 << (bank-2));
|
||||
break;
|
||||
|
||||
case 3:
|
||||
// not mapped to memory
|
||||
case 3: // texture
|
||||
VRAMMap_Texture[ofs] |= bankmask;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
case 4: // BBG/BOBJ
|
||||
if (bank == 2)
|
||||
vrammap = &VRAM_BBG[0];
|
||||
{
|
||||
MAP_RANGE(VRAMMap_BBG, 0, 8);
|
||||
}
|
||||
else
|
||||
vrammap = &VRAM_BOBJ[0];
|
||||
{
|
||||
MAP_RANGE(VRAMMap_BOBJ, 0, 8);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (vrammap)
|
||||
{
|
||||
*vrammap++ = vram; vram += 0x4000;
|
||||
*vrammap++ = vram; vram += 0x4000;
|
||||
*vrammap++ = vram; vram += 0x4000;
|
||||
*vrammap++ = vram; vram += 0x4000;
|
||||
*vrammap++ = vram; vram += 0x4000;
|
||||
*vrammap++ = vram; vram += 0x4000;
|
||||
*vrammap++ = vram; vram += 0x4000;
|
||||
*vrammap = vram;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -363,105 +357,62 @@ void MapVRAM_E(u32 bank, u8 cnt)
|
||||
|
||||
if (oldcnt == cnt) return;
|
||||
|
||||
u8 oldofs = (oldcnt >> 3) & 0x7;
|
||||
u8 ofs = (cnt >> 3) & 0x7;
|
||||
|
||||
u8* vram = VRAM[bank];
|
||||
u32 bankmask = 1 << bank;
|
||||
|
||||
if (oldcnt & (1<<7))
|
||||
{
|
||||
u8** vrammap = NULL;
|
||||
|
||||
switch (oldcnt & 0x7)
|
||||
{
|
||||
case 0:
|
||||
VRAM_LCD[0x20] = NULL;
|
||||
VRAM_LCD[0x21] = NULL;
|
||||
VRAM_LCD[0x22] = NULL;
|
||||
VRAM_LCD[0x23] = NULL;
|
||||
case 0: // LCDC
|
||||
VRAMMap_LCDC &= ~bankmask;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
vrammap = &VRAM_ABG[0];
|
||||
case 1: // ABG
|
||||
UNMAP_RANGE(VRAMMap_ABG, 0, 4);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
vrammap = &VRAM_AOBJ[0];
|
||||
case 2: // AOBJ
|
||||
UNMAP_RANGE(VRAMMap_AOBJ, 0, 4);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
// not mapped to memory
|
||||
case 3: // texture palette
|
||||
UNMAP_RANGE(VRAMMap_TexPal, 0, 4);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
VRAM_ABGExtPal[0] = NULL;
|
||||
VRAM_ABGExtPal[1] = NULL;
|
||||
VRAM_ABGExtPal[2] = NULL;
|
||||
VRAM_ABGExtPal[3] = NULL;
|
||||
case 4: // ABG ext palette
|
||||
UNMAP_RANGE(VRAMMap_ABGExtPal, 0, 4);
|
||||
GPU2D_A->BGExtPalDirty(0);
|
||||
GPU2D_A->BGExtPalDirty(2);
|
||||
break;
|
||||
}
|
||||
|
||||
if (vrammap && *vrammap == vram)
|
||||
{
|
||||
*vrammap++ = NULL;
|
||||
*vrammap++ = NULL;
|
||||
*vrammap++ = NULL;
|
||||
*vrammap++ = NULL;
|
||||
}
|
||||
else if (vrammap) vrammap += 4;
|
||||
if (vrammap && *vrammap == vram)
|
||||
{
|
||||
*vrammap++ = NULL;
|
||||
*vrammap++ = NULL;
|
||||
*vrammap++ = NULL;
|
||||
*vrammap = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (cnt & (1<<7))
|
||||
{
|
||||
u8** vrammap = NULL;
|
||||
|
||||
switch (cnt & 0x7)
|
||||
{
|
||||
case 0:
|
||||
VRAM_LCD[0x20] = &vram[0x0000];
|
||||
VRAM_LCD[0x21] = &vram[0x4000];
|
||||
VRAM_LCD[0x22] = &vram[0x8000];
|
||||
VRAM_LCD[0x23] = &vram[0xC000];
|
||||
case 0: // LCDC
|
||||
VRAMMap_LCDC |= bankmask;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
vrammap = &VRAM_ABG[0];
|
||||
case 1: // ABG
|
||||
MAP_RANGE(VRAMMap_ABG, 0, 4);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
vrammap = &VRAM_AOBJ[0];
|
||||
case 2: // AOBJ
|
||||
MAP_RANGE(VRAMMap_AOBJ, 0, 4);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
// not mapped to memory
|
||||
case 3: // texture palette
|
||||
MAP_RANGE(VRAMMap_TexPal, 0, 4);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
VRAM_ABGExtPal[0] = &vram[0x0000];
|
||||
VRAM_ABGExtPal[1] = &vram[0x2000];
|
||||
VRAM_ABGExtPal[2] = &vram[0x4000];
|
||||
VRAM_ABGExtPal[3] = &vram[0x6000];
|
||||
case 4: // ABG ext palette
|
||||
MAP_RANGE(VRAMMap_ABGExtPal, 0, 4);
|
||||
GPU2D_A->BGExtPalDirty(0);
|
||||
GPU2D_A->BGExtPalDirty(2);
|
||||
break;
|
||||
}
|
||||
|
||||
if (vrammap)
|
||||
{
|
||||
*vrammap++ = &vram[0x0000];
|
||||
*vrammap++ = &vram[0x4000];
|
||||
*vrammap++ = &vram[0x8000];
|
||||
*vrammap++ = &vram[0xC000];
|
||||
*vrammap++ = &vram[0x0000];
|
||||
*vrammap++ = &vram[0x4000];
|
||||
*vrammap++ = &vram[0x8000];
|
||||
*vrammap = &vram[0xC000];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -474,98 +425,78 @@ void MapVRAM_FG(u32 bank, u8 cnt)
|
||||
|
||||
u8 oldofs = (oldcnt >> 3) & 0x7;
|
||||
u8 ofs = (cnt >> 3) & 0x7;
|
||||
|
||||
u8* vram = VRAM[bank];
|
||||
bank -= 5;
|
||||
u32 bankmask = 1 << bank;
|
||||
|
||||
if (oldcnt & (1<<7))
|
||||
{
|
||||
u8** vrammap = NULL;
|
||||
|
||||
switch (oldcnt & 0x7)
|
||||
{
|
||||
case 0:
|
||||
VRAM_LCD[0x24 + bank] = NULL;
|
||||
case 0: // LCDC
|
||||
VRAMMap_LCDC &= ~bankmask;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
vrammap = &VRAM_ABG[(oldofs & 0x1) | ((oldofs & 0x2) << 1)];
|
||||
case 1: // ABG
|
||||
VRAMMap_ABG[(oldofs & 0x1) + ((oldofs & 0x2) << 1)] &= ~bankmask;
|
||||
VRAMMap_ABG[(oldofs & 0x1) + ((oldofs & 0x2) << 1) + 2] &= ~bankmask;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
vrammap = &VRAM_AOBJ[(oldofs & 0x1) | ((oldofs & 0x2) << 1)];
|
||||
case 2: // AOBJ
|
||||
VRAMMap_AOBJ[(oldofs & 0x1) + ((oldofs & 0x2) << 1)] &= ~bankmask;
|
||||
VRAMMap_AOBJ[(oldofs & 0x1) + ((oldofs & 0x2) << 1) + 2] &= ~bankmask;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
// not mapped to memory
|
||||
case 3: // texture palette
|
||||
VRAMMap_TexPal[(oldofs & 0x1) + ((oldofs & 0x2) << 1)] &= ~bankmask;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
VRAM_ABGExtPal[(oldofs<<1)+0] = NULL;
|
||||
VRAM_ABGExtPal[(oldofs<<1)+1] = NULL;
|
||||
case 4: // ABG ext palette
|
||||
VRAMMap_ABGExtPal[((oldofs & 0x1) << 1)] &= ~bankmask;
|
||||
VRAMMap_ABGExtPal[((oldofs & 0x1) << 1) + 1] &= ~bankmask;
|
||||
GPU2D_A->BGExtPalDirty(0);
|
||||
GPU2D_A->BGExtPalDirty(2);
|
||||
break;
|
||||
|
||||
case 5:
|
||||
VRAM_AOBJExtPal = NULL;
|
||||
case 5: // AOBJ ext palette
|
||||
VRAMMap_AOBJExtPal &= ~bankmask;
|
||||
GPU2D_A->OBJExtPalDirty();
|
||||
break;
|
||||
}
|
||||
|
||||
if (vrammap)
|
||||
{
|
||||
if (*vrammap == vram) *vrammap++ = NULL; else vrammap++;
|
||||
if (*vrammap == vram) *vrammap++ = NULL; else vrammap++;
|
||||
if (*vrammap == vram) *vrammap++ = NULL; else vrammap++;
|
||||
if (*vrammap == vram) *vrammap++ = NULL; else vrammap++;
|
||||
if (*vrammap == vram) *vrammap++ = NULL; else vrammap++;
|
||||
if (*vrammap == vram) *vrammap++ = NULL; else vrammap++;
|
||||
if (*vrammap == vram) *vrammap++ = NULL; else vrammap++;
|
||||
if (*vrammap == vram) *vrammap = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (cnt & (1<<7))
|
||||
{
|
||||
u8** vrammap = NULL;
|
||||
|
||||
switch (cnt & 0x7)
|
||||
{
|
||||
case 0:
|
||||
VRAM_LCD[0x24 + bank] = vram;
|
||||
case 0: // LCDC
|
||||
VRAMMap_LCDC |= bankmask;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
vrammap = &VRAM_ABG[(ofs & 0x1) | ((ofs & 0x2) << 1)];
|
||||
case 1: // ABG
|
||||
VRAMMap_ABG[(ofs & 0x1) + ((ofs & 0x2) << 1)] |= bankmask;
|
||||
VRAMMap_ABG[(ofs & 0x1) + ((ofs & 0x2) << 1) + 2] |= bankmask;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
vrammap = &VRAM_AOBJ[(ofs & 0x1) | ((ofs & 0x2) << 1)];
|
||||
case 2: // AOBJ
|
||||
VRAMMap_AOBJ[(ofs & 0x1) + ((ofs & 0x2) << 1)] |= bankmask;
|
||||
VRAMMap_AOBJ[(ofs & 0x1) + ((ofs & 0x2) << 1) + 2] |= bankmask;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
// not mapped to memory
|
||||
case 3: // texture palette
|
||||
VRAMMap_TexPal[(ofs & 0x1) + ((ofs & 0x2) << 1)] |= bankmask;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
VRAM_ABGExtPal[(ofs<<1)+0] = &vram[0x0000];
|
||||
VRAM_ABGExtPal[(ofs<<1)+1] = &vram[0x2000];
|
||||
case 4: // ABG ext palette
|
||||
VRAMMap_ABGExtPal[((ofs & 0x1) << 1)] |= bankmask;
|
||||
VRAMMap_ABGExtPal[((ofs & 0x1) << 1) + 1] |= bankmask;
|
||||
GPU2D_A->BGExtPalDirty(0);
|
||||
GPU2D_A->BGExtPalDirty(2);
|
||||
break;
|
||||
|
||||
case 5:
|
||||
VRAM_AOBJExtPal = vram;
|
||||
case 5: // AOBJ ext palette
|
||||
VRAMMap_AOBJExtPal |= bankmask;
|
||||
GPU2D_A->OBJExtPalDirty();
|
||||
break;
|
||||
}
|
||||
|
||||
if (vrammap)
|
||||
{
|
||||
*vrammap++ = vram;
|
||||
*vrammap++ = vram;
|
||||
*vrammap++ = vram;
|
||||
*vrammap++ = vram;
|
||||
*vrammap++ = vram;
|
||||
*vrammap++ = vram;
|
||||
*vrammap++ = vram;
|
||||
*vrammap = vram;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -576,90 +507,52 @@ void MapVRAM_H(u32 bank, u8 cnt)
|
||||
|
||||
if (oldcnt == cnt) return;
|
||||
|
||||
u8 oldofs = (oldcnt >> 3) & 0x7;
|
||||
u8 ofs = (cnt >> 3) & 0x7;
|
||||
|
||||
u8* vram = VRAM[bank];
|
||||
u32 bankmask = 1 << bank;
|
||||
|
||||
if (oldcnt & (1<<7))
|
||||
{
|
||||
u8** vrammap = NULL;
|
||||
|
||||
switch (oldcnt & 0x3)
|
||||
{
|
||||
case 0:
|
||||
VRAM_LCD[0x26] = NULL;
|
||||
VRAM_LCD[0x27] = NULL;
|
||||
case 0: // LCDC
|
||||
VRAMMap_LCDC &= ~bankmask;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
vrammap = &VRAM_BBG[0x00];
|
||||
case 1: // BBG
|
||||
VRAMMap_BBG[0] &= ~bankmask;
|
||||
VRAMMap_BBG[1] &= ~bankmask;
|
||||
VRAMMap_BBG[4] &= ~bankmask;
|
||||
VRAMMap_BBG[5] &= ~bankmask;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
VRAM_BBGExtPal[0] = NULL;
|
||||
VRAM_BBGExtPal[1] = NULL;
|
||||
VRAM_BBGExtPal[2] = NULL;
|
||||
VRAM_BBGExtPal[3] = NULL;
|
||||
case 2: // BBG ext palette
|
||||
UNMAP_RANGE(VRAMMap_BBGExtPal, 0, 4);
|
||||
GPU2D_B->BGExtPalDirty(0);
|
||||
GPU2D_B->BGExtPalDirty(2);
|
||||
break;
|
||||
}
|
||||
|
||||
if (vrammap && *vrammap == vram)
|
||||
{
|
||||
*vrammap++ = NULL;
|
||||
*vrammap++ = NULL;
|
||||
} else if (vrammap) vrammap += 2;
|
||||
if (vrammap && *vrammap == vram)
|
||||
{
|
||||
*vrammap++ = NULL;
|
||||
*vrammap++ = NULL;
|
||||
} else if (vrammap) vrammap += 2;
|
||||
if (vrammap && *vrammap == vram)
|
||||
{
|
||||
*vrammap++ = NULL;
|
||||
*vrammap++ = NULL;
|
||||
} else if (vrammap) vrammap += 2;
|
||||
if (vrammap && *vrammap == vram)
|
||||
{
|
||||
*vrammap++ = NULL;
|
||||
*vrammap = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (cnt & (1<<7))
|
||||
{
|
||||
u8** vrammap = NULL;
|
||||
|
||||
switch (cnt & 0x3)
|
||||
{
|
||||
case 0:
|
||||
VRAM_LCD[0x26] = &vram[0x0000];
|
||||
VRAM_LCD[0x27] = &vram[0x4000];
|
||||
case 0: // LCDC
|
||||
VRAMMap_LCDC |= bankmask;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
vrammap = &VRAM_BBG[0x00];
|
||||
case 1: // BBG
|
||||
VRAMMap_BBG[0] |= bankmask;
|
||||
VRAMMap_BBG[1] |= bankmask;
|
||||
VRAMMap_BBG[4] |= bankmask;
|
||||
VRAMMap_BBG[5] |= bankmask;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
VRAM_BBGExtPal[0] = &vram[0x0000];
|
||||
VRAM_BBGExtPal[1] = &vram[0x2000];
|
||||
VRAM_BBGExtPal[2] = &vram[0x4000];
|
||||
VRAM_BBGExtPal[3] = &vram[0x6000];
|
||||
case 2: // BBG ext palette
|
||||
MAP_RANGE(VRAMMap_BBGExtPal, 0, 4);
|
||||
GPU2D_B->BGExtPalDirty(0);
|
||||
GPU2D_B->BGExtPalDirty(2);
|
||||
break;
|
||||
}
|
||||
|
||||
if (vrammap)
|
||||
{
|
||||
*vrammap++ = &vram[0x0000];
|
||||
*vrammap++ = &vram[0x4000];
|
||||
*vrammap++ = &vram[0x0000];
|
||||
*vrammap++ = &vram[0x4000];
|
||||
*vrammap++ = &vram[0x0000];
|
||||
*vrammap++ = &vram[0x4000];
|
||||
*vrammap++ = &vram[0x0000];
|
||||
*vrammap = &vram[0x4000];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -670,82 +563,58 @@ void MapVRAM_I(u32 bank, u8 cnt)
|
||||
|
||||
if (oldcnt == cnt) return;
|
||||
|
||||
u8 oldofs = (oldcnt >> 3) & 0x7;
|
||||
u8 ofs = (cnt >> 3) & 0x7;
|
||||
|
||||
u8* vram = VRAM[bank];
|
||||
bank -= 5;
|
||||
u32 bankmask = 1 << bank;
|
||||
|
||||
if (oldcnt & (1<<7))
|
||||
{
|
||||
u8** vrammap = NULL;
|
||||
|
||||
switch (oldcnt & 0x3)
|
||||
{
|
||||
case 0:
|
||||
VRAM_LCD[0x28] = NULL;
|
||||
case 0: // LCDC
|
||||
VRAMMap_LCDC &= ~bankmask;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
vrammap = &VRAM_BBG[0x02];
|
||||
case 1: // BBG
|
||||
VRAMMap_BBG[2] &= ~bankmask;
|
||||
VRAMMap_BBG[3] &= ~bankmask;
|
||||
VRAMMap_BBG[6] &= ~bankmask;
|
||||
VRAMMap_BBG[7] &= ~bankmask;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
vrammap = &VRAM_BOBJ[0x00];
|
||||
case 2: // BOBJ
|
||||
UNMAP_RANGE(VRAMMap_BOBJ, 0, 8);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
VRAM_BOBJExtPal = NULL;
|
||||
case 3: // BOBJ ext palette
|
||||
VRAMMap_BOBJExtPal &= ~bankmask;
|
||||
GPU2D_B->OBJExtPalDirty();
|
||||
break;
|
||||
}
|
||||
|
||||
if (vrammap)
|
||||
{
|
||||
if (*vrammap == vram) *vrammap++ = NULL; else vrammap++;
|
||||
if (*vrammap == vram) *vrammap++ = NULL; else vrammap++;
|
||||
if (*vrammap == vram) *vrammap++ = NULL; else vrammap++;
|
||||
if (*vrammap == vram) *vrammap++ = NULL; else vrammap++;
|
||||
if (*vrammap == vram) *vrammap++ = NULL; else vrammap++;
|
||||
if (*vrammap == vram) *vrammap++ = NULL; else vrammap++;
|
||||
if (*vrammap == vram) *vrammap++ = NULL; else vrammap++;
|
||||
if (*vrammap == vram) *vrammap = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (cnt & (1<<7))
|
||||
{
|
||||
u8** vrammap = NULL;
|
||||
|
||||
switch (cnt & 0x3)
|
||||
{
|
||||
case 0:
|
||||
VRAM_LCD[0x28] = vram;
|
||||
case 0: // LCDC
|
||||
VRAMMap_LCDC |= bankmask;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
vrammap = &VRAM_BBG[0x02];
|
||||
case 1: // BBG
|
||||
VRAMMap_BBG[2] |= bankmask;
|
||||
VRAMMap_BBG[3] |= bankmask;
|
||||
VRAMMap_BBG[6] |= bankmask;
|
||||
VRAMMap_BBG[7] |= bankmask;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
vrammap = &VRAM_BOBJ[0x00];
|
||||
case 2: // BOBJ
|
||||
MAP_RANGE(VRAMMap_BOBJ, 0, 8);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
VRAM_BOBJExtPal = vram;
|
||||
case 3: // BOBJ ext palette
|
||||
VRAMMap_BOBJExtPal |= bankmask;
|
||||
GPU2D_B->OBJExtPalDirty();
|
||||
break;
|
||||
}
|
||||
|
||||
if (vrammap)
|
||||
{
|
||||
*vrammap++ = vram;
|
||||
*vrammap++ = vram;
|
||||
*vrammap++ = vram;
|
||||
*vrammap++ = vram;
|
||||
*vrammap++ = vram;
|
||||
*vrammap++ = vram;
|
||||
*vrammap++ = vram;
|
||||
*vrammap = vram;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
311
GPU.h
311
GPU.h
@ -35,18 +35,30 @@ extern u8 VRAMSTAT;
|
||||
extern u8 Palette[2*1024];
|
||||
extern u8 OAM[2*1024];
|
||||
|
||||
extern u8* VRAM[9];
|
||||
extern u8* VRAM_ABG[128];
|
||||
extern u8* VRAM_AOBJ[128];
|
||||
extern u8* VRAM_BBG[128];
|
||||
extern u8* VRAM_BOBJ[128];
|
||||
extern u8* VRAM_LCD[128];
|
||||
extern u8* VRAM_ARM7[2];
|
||||
extern u8 VRAM_A[128*1024];
|
||||
extern u8 VRAM_B[128*1024];
|
||||
extern u8 VRAM_C[128*1024];
|
||||
extern u8 VRAM_D[128*1024];
|
||||
extern u8 VRAM_E[ 64*1024];
|
||||
extern u8 VRAM_F[ 16*1024];
|
||||
extern u8 VRAM_G[ 16*1024];
|
||||
extern u8 VRAM_H[ 32*1024];
|
||||
extern u8 VRAM_I[ 16*1024];
|
||||
|
||||
extern u8* VRAM_ABGExtPal[4];
|
||||
extern u8* VRAM_AOBJExtPal;
|
||||
extern u8* VRAM_BBGExtPal[4];
|
||||
extern u8* VRAM_BOBJExtPal;
|
||||
extern u8* VRAM[9];
|
||||
|
||||
extern u32 VRAMMap_LCDC;
|
||||
extern u32 VRAMMap_ABG[0x20];
|
||||
extern u32 VRAMMap_AOBJ[0x10];
|
||||
extern u32 VRAMMap_BBG[0x8];
|
||||
extern u32 VRAMMap_BOBJ[0x8];
|
||||
extern u32 VRAMMap_ABGExtPal[4];
|
||||
extern u32 VRAMMap_AOBJExtPal;
|
||||
extern u32 VRAMMap_BBGExtPal[4];
|
||||
extern u32 VRAMMap_BOBJExtPal;
|
||||
extern u32 VRAMMap_Texture[4];
|
||||
extern u32 VRAMMap_TexPal[6];
|
||||
extern u32 VRAMMap_ARM7[2];
|
||||
|
||||
extern u32 Framebuffer[256*192*2];
|
||||
|
||||
@ -65,6 +77,283 @@ void MapVRAM_FG(u32 bank, u8 cnt);
|
||||
void MapVRAM_H(u32 bank, u8 cnt);
|
||||
void MapVRAM_I(u32 bank, u8 cnt);
|
||||
|
||||
|
||||
template<typename T>
|
||||
T ReadVRAM_LCDC(u32 addr)
|
||||
{
|
||||
int bank;
|
||||
|
||||
switch (addr & 0xFF8FC000)
|
||||
{
|
||||
case 0x06800000: case 0x06804000: case 0x06808000: case 0x0680C000:
|
||||
case 0x06810000: case 0x06814000: case 0x06818000: case 0x0681C000:
|
||||
bank = 0;
|
||||
addr &= 0x1FFFF;
|
||||
break;
|
||||
|
||||
case 0x06820000: case 0x06824000: case 0x06828000: case 0x0682C000:
|
||||
case 0x06830000: case 0x06834000: case 0x06838000: case 0x0683C000:
|
||||
bank = 1;
|
||||
addr &= 0x1FFFF;
|
||||
break;
|
||||
|
||||
case 0x06840000: case 0x06844000: case 0x06848000: case 0x0684C000:
|
||||
case 0x06850000: case 0x06854000: case 0x06858000: case 0x0685C000:
|
||||
bank = 2;
|
||||
addr &= 0x1FFFF;
|
||||
break;
|
||||
|
||||
case 0x06860000: case 0x06864000: case 0x06868000: case 0x0686C000:
|
||||
case 0x06870000: case 0x06874000: case 0x06878000: case 0x0687C000:
|
||||
bank = 3;
|
||||
addr &= 0x1FFFF;
|
||||
break;
|
||||
|
||||
case 0x06880000: case 0x06884000: case 0x06888000: case 0x0688C000:
|
||||
bank = 4;
|
||||
addr &= 0xFFFF;
|
||||
break;
|
||||
|
||||
case 0x06890000:
|
||||
bank = 5;
|
||||
addr &= 0x3FFF;
|
||||
break;
|
||||
|
||||
case 0x06894000:
|
||||
bank = 6;
|
||||
addr &= 0x3FFF;
|
||||
break;
|
||||
|
||||
case 0x06898000:
|
||||
case 0x0689C000:
|
||||
bank = 7;
|
||||
addr &= 0x7FFF;
|
||||
break;
|
||||
|
||||
case 0x068A0000:
|
||||
bank = 8;
|
||||
addr &= 0x3FFF;
|
||||
break;
|
||||
|
||||
default: return 0;
|
||||
}
|
||||
|
||||
if (VRAMMap_LCDC & (1<<bank)) return *(T*)&VRAM[bank][addr];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void WriteVRAM_LCDC(u32 addr, T val)
|
||||
{
|
||||
int bank;
|
||||
|
||||
switch (addr & 0xFF8FC000)
|
||||
{
|
||||
case 0x06800000: case 0x06804000: case 0x06808000: case 0x0680C000:
|
||||
case 0x06810000: case 0x06814000: case 0x06818000: case 0x0681C000:
|
||||
bank = 0;
|
||||
addr &= 0x1FFFF;
|
||||
break;
|
||||
|
||||
case 0x06820000: case 0x06824000: case 0x06828000: case 0x0682C000:
|
||||
case 0x06830000: case 0x06834000: case 0x06838000: case 0x0683C000:
|
||||
bank = 1;
|
||||
addr &= 0x1FFFF;
|
||||
break;
|
||||
|
||||
case 0x06840000: case 0x06844000: case 0x06848000: case 0x0684C000:
|
||||
case 0x06850000: case 0x06854000: case 0x06858000: case 0x0685C000:
|
||||
bank = 2;
|
||||
addr &= 0x1FFFF;
|
||||
break;
|
||||
|
||||
case 0x06860000: case 0x06864000: case 0x06868000: case 0x0686C000:
|
||||
case 0x06870000: case 0x06874000: case 0x06878000: case 0x0687C000:
|
||||
bank = 3;
|
||||
addr &= 0x1FFFF;
|
||||
break;
|
||||
|
||||
case 0x06880000: case 0x06884000: case 0x06888000: case 0x0688C000:
|
||||
bank = 4;
|
||||
addr &= 0xFFFF;
|
||||
break;
|
||||
|
||||
case 0x06890000:
|
||||
bank = 5;
|
||||
addr &= 0x3FFF;
|
||||
break;
|
||||
|
||||
case 0x06894000:
|
||||
bank = 6;
|
||||
addr &= 0x3FFF;
|
||||
break;
|
||||
|
||||
case 0x06898000:
|
||||
case 0x0689C000:
|
||||
bank = 7;
|
||||
addr &= 0x7FFF;
|
||||
break;
|
||||
|
||||
case 0x068A0000:
|
||||
bank = 8;
|
||||
addr &= 0x3FFF;
|
||||
break;
|
||||
|
||||
default: return;
|
||||
}
|
||||
|
||||
if (VRAMMap_LCDC & (1<<bank)) *(T*)&VRAM[bank][addr] = val;
|
||||
}
|
||||
|
||||
|
||||
template<typename T>
|
||||
T ReadVRAM_ABG(u32 addr)
|
||||
{
|
||||
u32 ret = 0;
|
||||
u32 mask = VRAMMap_ABG[(addr >> 14) & 0x1F];
|
||||
|
||||
if (mask & (1<<0)) ret |= *(T*)&VRAM_A[addr & 0x1FFFF];
|
||||
if (mask & (1<<1)) ret |= *(T*)&VRAM_B[addr & 0x1FFFF];
|
||||
if (mask & (1<<2)) ret |= *(T*)&VRAM_C[addr & 0x1FFFF];
|
||||
if (mask & (1<<3)) ret |= *(T*)&VRAM_D[addr & 0x1FFFF];
|
||||
if (mask & (1<<4)) ret |= *(T*)&VRAM_E[addr & 0xFFFF];
|
||||
if (mask & (1<<5)) ret |= *(T*)&VRAM_F[addr & 0x3FFF];
|
||||
if (mask & (1<<6)) ret |= *(T*)&VRAM_G[addr & 0x3FFF];
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void WriteVRAM_ABG(u32 addr, T val)
|
||||
{
|
||||
u32 mask = VRAMMap_ABG[(addr >> 14) & 0x1F];
|
||||
|
||||
if (mask & (1<<0)) *(T*)&VRAM_A[addr & 0x1FFFF] = val;
|
||||
if (mask & (1<<1)) *(T*)&VRAM_B[addr & 0x1FFFF] = val;
|
||||
if (mask & (1<<2)) *(T*)&VRAM_C[addr & 0x1FFFF] = val;
|
||||
if (mask & (1<<3)) *(T*)&VRAM_D[addr & 0x1FFFF] = val;
|
||||
if (mask & (1<<4)) *(T*)&VRAM_E[addr & 0xFFFF] = val;
|
||||
if (mask & (1<<5)) *(T*)&VRAM_F[addr & 0x3FFF] = val;
|
||||
if (mask & (1<<6)) *(T*)&VRAM_G[addr & 0x3FFF] = val;
|
||||
}
|
||||
|
||||
|
||||
template<typename T>
|
||||
T ReadVRAM_AOBJ(u32 addr)
|
||||
{
|
||||
u32 ret = 0;
|
||||
u32 mask = VRAMMap_AOBJ[(addr >> 14) & 0xF];
|
||||
|
||||
if (mask & (1<<0)) ret |= *(T*)&VRAM_A[addr & 0x1FFFF];
|
||||
if (mask & (1<<1)) ret |= *(T*)&VRAM_B[addr & 0x1FFFF];
|
||||
if (mask & (1<<4)) ret |= *(T*)&VRAM_E[addr & 0xFFFF];
|
||||
if (mask & (1<<5)) ret |= *(T*)&VRAM_F[addr & 0x3FFF];
|
||||
if (mask & (1<<6)) ret |= *(T*)&VRAM_G[addr & 0x3FFF];
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void WriteVRAM_AOBJ(u32 addr, T val)
|
||||
{
|
||||
u32 mask = VRAMMap_AOBJ[(addr >> 14) & 0xF];
|
||||
|
||||
if (mask & (1<<0)) *(T*)&VRAM_A[addr & 0x1FFFF] = val;
|
||||
if (mask & (1<<1)) *(T*)&VRAM_B[addr & 0x1FFFF] = val;
|
||||
if (mask & (1<<4)) *(T*)&VRAM_E[addr & 0xFFFF] = val;
|
||||
if (mask & (1<<5)) *(T*)&VRAM_F[addr & 0x3FFF] = val;
|
||||
if (mask & (1<<6)) *(T*)&VRAM_G[addr & 0x3FFF] = val;
|
||||
}
|
||||
|
||||
|
||||
template<typename T>
|
||||
T ReadVRAM_BBG(u32 addr)
|
||||
{
|
||||
u32 ret = 0;
|
||||
u32 mask = VRAMMap_BBG[(addr >> 14) & 0x7];
|
||||
|
||||
if (mask & (1<<2)) ret |= *(T*)&VRAM_C[addr & 0x1FFFF];
|
||||
if (mask & (1<<7)) ret |= *(T*)&VRAM_H[addr & 0x7FFF];
|
||||
if (mask & (1<<8)) ret |= *(T*)&VRAM_I[addr & 0x3FFF];
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void WriteVRAM_BBG(u32 addr, T val)
|
||||
{
|
||||
u32 mask = VRAMMap_BBG[(addr >> 14) & 0x7];
|
||||
|
||||
if (mask & (1<<2)) *(T*)&VRAM_C[addr & 0x1FFFF] = val;
|
||||
if (mask & (1<<7)) *(T*)&VRAM_H[addr & 0x7FFF] = val;
|
||||
if (mask & (1<<8)) *(T*)&VRAM_I[addr & 0x3FFF] = val;
|
||||
}
|
||||
|
||||
|
||||
template<typename T>
|
||||
T ReadVRAM_BOBJ(u32 addr)
|
||||
{
|
||||
u32 ret = 0;
|
||||
u32 mask = VRAMMap_BOBJ[(addr >> 14) & 0x7];
|
||||
|
||||
if (mask & (1<<3)) ret |= *(T*)&VRAM_D[addr & 0x1FFFF];
|
||||
if (mask & (1<<8)) ret |= *(T*)&VRAM_I[addr & 0x3FFF];
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void WriteVRAM_BOBJ(u32 addr, T val)
|
||||
{
|
||||
u32 mask = VRAMMap_BOBJ[(addr >> 14) & 0x7];
|
||||
|
||||
if (mask & (1<<3)) *(T*)&VRAM_D[addr & 0x1FFFF] = val;
|
||||
if (mask & (1<<8)) *(T*)&VRAM_I[addr & 0x3FFF] = val;
|
||||
}
|
||||
|
||||
|
||||
template<typename T>
|
||||
T ReadVRAM_ARM7(u32 addr)
|
||||
{
|
||||
u32 ret = 0;
|
||||
u32 mask = VRAMMap_ARM7[(addr >> 17) & 0x1];
|
||||
|
||||
if (mask & (1<<2)) ret |= *(T*)&VRAM_C[addr & 0x1FFFF];
|
||||
if (mask & (1<<3)) ret |= *(T*)&VRAM_D[addr & 0x1FFFF];
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void WriteVRAM_ARM7(u32 addr, T val)
|
||||
{
|
||||
u32 mask = VRAMMap_BOBJ[(addr >> 17) & 0x1];
|
||||
|
||||
if (mask & (1<<2)) *(T*)&VRAM_C[addr & 0x1FFFF] = val;
|
||||
if (mask & (1<<3)) *(T*)&VRAM_D[addr & 0x1FFFF] = val;
|
||||
}
|
||||
|
||||
|
||||
template<typename T>
|
||||
T ReadVRAM_BG(u32 addr)
|
||||
{
|
||||
if ((addr & 0xFFE00000) == 0x06000000)
|
||||
return ReadVRAM_ABG<T>(addr);
|
||||
else
|
||||
return ReadVRAM_BBG<T>(addr);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T ReadVRAM_OBJ(u32 addr)
|
||||
{
|
||||
if ((addr & 0xFFE00000) == 0x06400000)
|
||||
return ReadVRAM_AOBJ<T>(addr);
|
||||
else
|
||||
return ReadVRAM_BOBJ<T>(addr);
|
||||
}
|
||||
|
||||
|
||||
void DisplaySwap(u32 val);
|
||||
|
||||
void StartFrame();
|
||||
|
347
GPU2D.cpp
347
GPU2D.cpp
@ -35,6 +35,8 @@
|
||||
// oh also, changing DISPCNT bit16-17 midframe doesn't work (ignored? applied for next frame?)
|
||||
// TODO, eventually: check whether other DISPCNT bits can be changed midframe
|
||||
//
|
||||
// for VRAM display mode, VRAM must be mapped to LCDC
|
||||
//
|
||||
// sprite blending rules
|
||||
// * destination must be selected as 2nd target
|
||||
// * sprite must be semitransparent or bitmap sprite
|
||||
@ -80,6 +82,12 @@ void GPU2D::Reset()
|
||||
memset(BGRotB, 0, 2*2);
|
||||
memset(BGRotC, 0, 2*2);
|
||||
memset(BGRotD, 0, 2*2);
|
||||
|
||||
BGExtPalStatus[0] = 0;
|
||||
BGExtPalStatus[1] = 0;
|
||||
BGExtPalStatus[2] = 0;
|
||||
BGExtPalStatus[3] = 0;
|
||||
OBJExtPalStatus = 0;
|
||||
}
|
||||
|
||||
void GPU2D::SetFramebuffer(u32* buf)
|
||||
@ -224,17 +232,28 @@ void GPU2D::DrawScanline(u32 line)
|
||||
|
||||
case 2: // VRAM display
|
||||
{
|
||||
u32* vram = (u32*)GPU::VRAM[(DispCnt >> 18) & 0x3];
|
||||
vram = &vram[line << 7];
|
||||
|
||||
for (int i = 0; i < 256; i++)
|
||||
u32 vrambank = (DispCnt >> 18) & 0x3;
|
||||
if (GPU::VRAMMap_LCDC & (1<<vrambank))
|
||||
{
|
||||
u16 color = vram[i];
|
||||
u8 r = (color & 0x001F) << 1;
|
||||
u8 g = (color & 0x03E0) >> 4;
|
||||
u8 b = (color & 0x7C00) >> 9;
|
||||
u16* vram = (u16*)GPU::VRAM[vrambank];
|
||||
vram = &vram[line * 256];
|
||||
|
||||
dst[i] = r | (g << 8) | (b << 16);
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
u16 color = vram[i];
|
||||
u8 r = (color & 0x001F) << 1;
|
||||
u8 g = (color & 0x03E0) >> 4;
|
||||
u8 b = (color & 0x7C00) >> 9;
|
||||
|
||||
dst[i] = r | (g << 8) | (b << 16);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
dst[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -259,6 +278,87 @@ void GPU2D::VBlank()
|
||||
}
|
||||
|
||||
|
||||
void GPU2D::BGExtPalDirty(u32 base)
|
||||
{
|
||||
BGExtPalStatus[base] = 0;
|
||||
BGExtPalStatus[base+1] = 0;
|
||||
}
|
||||
|
||||
void GPU2D::OBJExtPalDirty()
|
||||
{
|
||||
OBJExtPalStatus = 0;
|
||||
}
|
||||
|
||||
|
||||
u16* GPU2D::GetBGExtPal(u32 slot, u32 pal)
|
||||
{
|
||||
u16* dst = &BGExtPalCache[slot][pal << 8];
|
||||
|
||||
if (!(BGExtPalStatus[slot] & (1<<pal)))
|
||||
{
|
||||
if (Num)
|
||||
{
|
||||
if (GPU::VRAMMap_BBGExtPal[slot] & (1<<7))
|
||||
memcpy(dst, &GPU::VRAM_H[(slot << 13) + (pal << 9)], 256*2);
|
||||
else
|
||||
memset(dst, 0, 256*2);
|
||||
}
|
||||
else
|
||||
{
|
||||
memset(dst, 0, 256*2);
|
||||
|
||||
if (GPU::VRAMMap_ABGExtPal[slot] & (1<<4))
|
||||
for (int i = 0; i < 256; i+=2)
|
||||
*(u32*)&dst[i] |= *(u32*)&GPU::VRAM_E[(slot << 13) + (pal << 9) + (i << 1)];
|
||||
|
||||
if (GPU::VRAMMap_ABGExtPal[slot] & (1<<5))
|
||||
for (int i = 0; i < 256; i+=2)
|
||||
*(u32*)&dst[i] |= *(u32*)&GPU::VRAM_F[((slot&1) << 13) + (pal << 9) + (i << 1)];
|
||||
|
||||
if (GPU::VRAMMap_ABGExtPal[slot] & (1<<6))
|
||||
for (int i = 0; i < 256; i+=2)
|
||||
*(u32*)&dst[i] |= *(u32*)&GPU::VRAM_G[((slot&1) << 13) + (pal << 9) + (i << 1)];
|
||||
}
|
||||
|
||||
BGExtPalStatus[slot] |= (1<<pal);
|
||||
}
|
||||
|
||||
return dst;
|
||||
}
|
||||
|
||||
u16* GPU2D::GetOBJExtPal(u32 pal)
|
||||
{
|
||||
u16* dst = &OBJExtPalCache[pal << 8];
|
||||
|
||||
if (!(OBJExtPalStatus & (1<<pal)))
|
||||
{
|
||||
if (Num)
|
||||
{
|
||||
if (GPU::VRAMMap_BOBJExtPal & (1<<7))
|
||||
memcpy(dst, &GPU::VRAM_I[(pal << 9)], 256*2);
|
||||
else
|
||||
memset(dst, 0, 256*2);
|
||||
}
|
||||
else
|
||||
{
|
||||
memset(dst, 0, 256*2);
|
||||
|
||||
if (GPU::VRAMMap_AOBJExtPal & (1<<5))
|
||||
for (int i = 0; i < 256; i+=2)
|
||||
*(u32*)&dst[i] |= *(u32*)&GPU::VRAM_F[(pal << 9) + (i << 1)];
|
||||
|
||||
if (GPU::VRAMMap_AOBJExtPal & (1<<6))
|
||||
for (int i = 0; i < 256; i+=2)
|
||||
*(u32*)&dst[i] |= *(u32*)&GPU::VRAM_G[(pal << 9) + (i << 1)];
|
||||
}
|
||||
|
||||
OBJExtPalStatus |= (1<<pal);
|
||||
}
|
||||
|
||||
return dst;
|
||||
}
|
||||
|
||||
|
||||
template<u32 bgmode>
|
||||
void GPU2D::DrawScanlineBGMode(u32 line, u32* spritebuf, u32* dst)
|
||||
{
|
||||
@ -385,10 +485,9 @@ void GPU2D::DrawBG_Text(u32 line, u32* dst, u32 bgnum)
|
||||
{
|
||||
u16 bgcnt = BGCnt[bgnum];
|
||||
|
||||
u8* tileset;
|
||||
u16* tilemap;
|
||||
u32 tilesetaddr, tilemapaddr;
|
||||
u16* pal;
|
||||
u32 extpal;
|
||||
u32 extpal, extpalslot;
|
||||
|
||||
u16 xoff = BGXPos[bgnum];
|
||||
u16 yoff = BGYPos[bgnum] + line;
|
||||
@ -397,62 +496,37 @@ void GPU2D::DrawBG_Text(u32 line, u32* dst, u32 bgnum)
|
||||
|
||||
DrawPixelFunc drawpixelfn = DrawPixel_Normal;
|
||||
|
||||
extpal = (bgcnt & 0x0080) && (DispCnt & 0x40000000);
|
||||
extpal = (DispCnt & 0x40000000);
|
||||
if (extpal) extpalslot = ((bgnum<2) && (bgcnt&0x2000)) ? (2+bgnum) : bgnum;
|
||||
|
||||
if (Num)
|
||||
{
|
||||
tileset = (u8*)GPU::VRAM_BBG[((bgcnt & 0x003C) >> 2)];
|
||||
tilemap = (u16*)GPU::VRAM_BBG[((bgcnt & 0x1800) >> 11)];
|
||||
if (!tileset || !tilemap) return;
|
||||
tilemap += ((bgcnt & 0x0700) << 2);
|
||||
tilesetaddr = 0x06200000 + ((bgcnt & 0x003C) << 12);
|
||||
tilemapaddr = 0x06200000 + ((bgcnt & 0x1F00) << 3);
|
||||
|
||||
if (extpal)
|
||||
{
|
||||
if ((bgnum<2) && (bgcnt&0x2000))
|
||||
pal = (u16*)GPU::VRAM_BBGExtPal[2+bgnum];
|
||||
else
|
||||
pal = (u16*)GPU::VRAM_BBGExtPal[bgnum];
|
||||
|
||||
// derp
|
||||
if (!pal) pal = (u16*)&GPU::Palette[0x400];
|
||||
}
|
||||
else
|
||||
pal = (u16*)&GPU::Palette[0x400];
|
||||
pal = (u16*)&GPU::Palette[0x400];
|
||||
}
|
||||
else
|
||||
{
|
||||
tileset = (u8*)GPU::VRAM_ABG[((DispCnt & 0x07000000) >> 22) + ((bgcnt & 0x003C) >> 2)];
|
||||
tilemap = (u16*)GPU::VRAM_ABG[((DispCnt & 0x38000000) >> 25) + ((bgcnt & 0x1800) >> 11)];
|
||||
if (!tileset || !tilemap) return;
|
||||
tilemap += ((bgcnt & 0x0700) << 2);
|
||||
tilesetaddr = 0x06000000 + ((DispCnt & 0x07000000) >> 8) + ((bgcnt & 0x003C) << 12);
|
||||
tilemapaddr = 0x06000000 + ((DispCnt & 0x38000000) >> 11) + ((bgcnt & 0x1F00) << 3);
|
||||
|
||||
if (extpal)
|
||||
{
|
||||
if ((bgnum<2) && (bgcnt&0x2000))
|
||||
pal = (u16*)GPU::VRAM_ABGExtPal[2+bgnum];
|
||||
else
|
||||
pal = (u16*)GPU::VRAM_ABGExtPal[bgnum];
|
||||
|
||||
// derp
|
||||
if (!pal) pal = (u16*)&GPU::Palette[0];
|
||||
}
|
||||
else
|
||||
pal = (u16*)&GPU::Palette[0];
|
||||
pal = (u16*)&GPU::Palette[0];
|
||||
}
|
||||
|
||||
// adjust Y position in tilemap
|
||||
if (bgcnt & 0x8000)
|
||||
{
|
||||
tilemap += ((yoff & 0x1F8) << 2);
|
||||
tilemapaddr += ((yoff & 0x1F8) << 3);
|
||||
if (bgcnt & 0x4000)
|
||||
tilemap += ((yoff & 0x100) << 2);
|
||||
tilemapaddr += ((yoff & 0x100) << 3);
|
||||
}
|
||||
else
|
||||
tilemap += ((yoff & 0xF8) << 2);
|
||||
tilemapaddr += ((yoff & 0xF8) << 3);
|
||||
|
||||
u16 curtile;
|
||||
u16* curpal;
|
||||
u8* pixels;
|
||||
u32 pixelsaddr;
|
||||
|
||||
if (bgcnt & 0x0080)
|
||||
{
|
||||
@ -462,11 +536,13 @@ void GPU2D::DrawBG_Text(u32 line, u32* dst, u32 bgnum)
|
||||
if (xoff & 0x7)
|
||||
{
|
||||
// load a new tile
|
||||
curtile = tilemap[((xoff & 0xFF) >> 3) + ((xoff & widexmask) << 2)];
|
||||
curpal = pal;
|
||||
if (extpal) curpal += ((curtile & 0xF000) >> 4);
|
||||
pixels = tileset + ((curtile & 0x03FF) << 6);
|
||||
pixels += (((curtile & 0x0800) ? (7-(yoff&0x7)) : (yoff&0x7)) << 3);
|
||||
curtile = GPU::ReadVRAM_BG<u16>(tilemapaddr + ((xoff & 0xF8) >> 2) + ((xoff & widexmask) << 3));
|
||||
|
||||
if (extpal) curpal = GetBGExtPal(extpalslot, curtile>>12);
|
||||
else curpal = pal;
|
||||
|
||||
pixelsaddr = tilesetaddr + ((curtile & 0x03FF) << 6)
|
||||
+ (((curtile & 0x0800) ? (7-(yoff&0x7)) : (yoff&0x7)) << 3);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 256; i++)
|
||||
@ -474,17 +550,19 @@ void GPU2D::DrawBG_Text(u32 line, u32* dst, u32 bgnum)
|
||||
if (!(xoff & 0x7))
|
||||
{
|
||||
// load a new tile
|
||||
curtile = tilemap[((xoff & 0xFF) >> 3) + ((xoff & widexmask) << 2)];
|
||||
curpal = pal;
|
||||
if (extpal) curpal += ((curtile & 0xF000) >> 4);
|
||||
pixels = tileset + ((curtile & 0x03FF) << 6);
|
||||
pixels += (((curtile & 0x0800) ? (7-(yoff&0x7)) : (yoff&0x7)) << 3);
|
||||
curtile = GPU::ReadVRAM_BG<u16>(tilemapaddr + ((xoff & 0xF8) >> 2) + ((xoff & widexmask) << 3));
|
||||
|
||||
if (extpal) curpal = GetBGExtPal(extpalslot, curtile>>12);
|
||||
else curpal = pal;
|
||||
|
||||
pixelsaddr = tilesetaddr + ((curtile & 0x03FF) << 6)
|
||||
+ (((curtile & 0x0800) ? (7-(yoff&0x7)) : (yoff&0x7)) << 3);
|
||||
}
|
||||
|
||||
// draw pixel
|
||||
u8 color;
|
||||
u32 tilexoff = (curtile & 0x0400) ? (7-(xoff&0x7)) : (xoff&0x7);
|
||||
color = pixels[tilexoff];
|
||||
color = GPU::ReadVRAM_BG<u8>(pixelsaddr + tilexoff);
|
||||
|
||||
if (color)
|
||||
drawpixelfn(bgnum, &dst[i], curpal[color], BlendFunc);
|
||||
@ -500,10 +578,10 @@ void GPU2D::DrawBG_Text(u32 line, u32* dst, u32 bgnum)
|
||||
if (xoff & 0x7)
|
||||
{
|
||||
// load a new tile
|
||||
curtile = tilemap[((xoff & 0xFF) >> 3) + ((xoff & widexmask) << 2)];
|
||||
curtile = GPU::ReadVRAM_BG<u16>(tilemapaddr + ((xoff & 0xF8) >> 2) + ((xoff & widexmask) << 3));
|
||||
curpal = pal + ((curtile & 0xF000) >> 8);
|
||||
pixels = tileset + ((curtile & 0x03FF) << 5);
|
||||
pixels += (((curtile & 0x0800) ? (7-(yoff&0x7)) : (yoff&0x7)) << 2);
|
||||
pixelsaddr = tilesetaddr + ((curtile & 0x03FF) << 5)
|
||||
+ (((curtile & 0x0800) ? (7-(yoff&0x7)) : (yoff&0x7)) << 2);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 256; i++)
|
||||
@ -511,22 +589,23 @@ void GPU2D::DrawBG_Text(u32 line, u32* dst, u32 bgnum)
|
||||
if (!(xoff & 0x7))
|
||||
{
|
||||
// load a new tile
|
||||
curtile = tilemap[((xoff & 0xFF) >> 3) + ((xoff & widexmask) << 2)];
|
||||
curtile = GPU::ReadVRAM_BG<u16>(tilemapaddr + ((xoff & 0xF8) >> 2) + ((xoff & widexmask) << 3));
|
||||
curpal = pal + ((curtile & 0xF000) >> 8);
|
||||
pixels = tileset + ((curtile & 0x03FF) << 5);
|
||||
pixels += (((curtile & 0x0800) ? (7-(yoff&0x7)) : (yoff&0x7)) << 2);
|
||||
pixelsaddr = tilesetaddr + ((curtile & 0x03FF) << 5)
|
||||
+ (((curtile & 0x0800) ? (7-(yoff&0x7)) : (yoff&0x7)) << 2);
|
||||
}
|
||||
|
||||
// draw pixel
|
||||
// TODO: optimize VRAM access
|
||||
u8 color;
|
||||
u32 tilexoff = (curtile & 0x0400) ? (7-(xoff&0x7)) : (xoff&0x7);
|
||||
if (tilexoff & 0x1)
|
||||
{
|
||||
color = pixels[tilexoff>>1] >> 4;
|
||||
color = GPU::ReadVRAM_BG<u8>(pixelsaddr + (tilexoff >> 1)) >> 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
color = pixels[tilexoff>>1] & 0x0F;
|
||||
color = GPU::ReadVRAM_BG<u8>(pixelsaddr + (tilexoff >> 1)) & 0x0F;
|
||||
}
|
||||
|
||||
if (color)
|
||||
@ -541,8 +620,7 @@ void GPU2D::DrawBG_Extended(u32 line, u32* dst, u32 bgnum)
|
||||
{
|
||||
u16 bgcnt = BGCnt[bgnum];
|
||||
|
||||
u8* tileset;
|
||||
u16* tilemap;
|
||||
u32 tilesetaddr, tilemapaddr;
|
||||
u16* pal;
|
||||
u32 extpal;
|
||||
|
||||
@ -580,9 +658,8 @@ void GPU2D::DrawBG_Extended(u32 line, u32* dst, u32 bgnum)
|
||||
{
|
||||
// bitmap modes
|
||||
|
||||
if (Num) tileset = (u8*)GPU::VRAM_BBG[((bgcnt & 0x003C) >> 2)];
|
||||
else tileset = (u8*)GPU::VRAM_ABG[((bgcnt & 0x003C) >> 2)];
|
||||
if (!tileset) return;
|
||||
if (Num) tilesetaddr = 0x06200000 + ((bgcnt & 0x003C) << 12);
|
||||
else tilesetaddr = 0x06000000 + ((bgcnt & 0x003C) << 12);
|
||||
|
||||
coordmask |= 0x7FF;
|
||||
|
||||
@ -590,13 +667,11 @@ void GPU2D::DrawBG_Extended(u32 line, u32* dst, u32 bgnum)
|
||||
{
|
||||
// direct color bitmap
|
||||
|
||||
u16* bitmap = (u16*)tileset;
|
||||
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
if (!((rotX|rotY) & overflowmask))
|
||||
{
|
||||
u16 color = bitmap[(((rotY & coordmask) >> 8) << yshift) + ((rotX & coordmask) >> 8)];
|
||||
u16 color = GPU::ReadVRAM_BG<u16>(tilesetaddr + (((((rotY & coordmask) >> 8) << yshift) + ((rotX & coordmask) >> 8)) << 1));
|
||||
|
||||
if (color & 0x8000)
|
||||
drawpixelfn(bgnum, &dst[i], color, BlendFunc);
|
||||
@ -617,7 +692,7 @@ void GPU2D::DrawBG_Extended(u32 line, u32* dst, u32 bgnum)
|
||||
{
|
||||
if (!((rotX|rotY) & overflowmask))
|
||||
{
|
||||
u8 color = tileset[(((rotY & coordmask) >> 8) << yshift) + ((rotX & coordmask) >> 8)];
|
||||
u8 color = GPU::ReadVRAM_BG<u8>(tilesetaddr + (((rotY & coordmask) >> 8) << yshift) + ((rotX & coordmask) >> 8));
|
||||
|
||||
if (color)
|
||||
drawpixelfn(bgnum, &dst[i], pal[color], BlendFunc);
|
||||
@ -630,46 +705,25 @@ void GPU2D::DrawBG_Extended(u32 line, u32* dst, u32 bgnum)
|
||||
}
|
||||
else
|
||||
{
|
||||
// shitty mode
|
||||
// mixed affine/text mode
|
||||
|
||||
if (Num)
|
||||
{
|
||||
tileset = (u8*)GPU::VRAM_BBG[((bgcnt & 0x003C) >> 2)];
|
||||
tilemap = (u16*)GPU::VRAM_BBG[((bgcnt & 0x1800) >> 11)];
|
||||
if (!tileset || !tilemap) return;
|
||||
tilemap += ((bgcnt & 0x0700) << 2);
|
||||
tilesetaddr = 0x06200000 + ((bgcnt & 0x003C) << 12);
|
||||
tilemapaddr = 0x06200000 + ((bgcnt & 0x1F00) << 3);
|
||||
|
||||
if (extpal)
|
||||
{
|
||||
pal = (u16*)GPU::VRAM_BBGExtPal[bgnum];
|
||||
|
||||
// derp
|
||||
if (!pal) pal = (u16*)&GPU::Palette[0x400];
|
||||
}
|
||||
else
|
||||
pal = (u16*)&GPU::Palette[0x400];
|
||||
pal = (u16*)&GPU::Palette[0x400];
|
||||
}
|
||||
else
|
||||
{
|
||||
tileset = (u8*)GPU::VRAM_ABG[((DispCnt & 0x07000000) >> 22) + ((bgcnt & 0x003C) >> 2)];
|
||||
tilemap = (u16*)GPU::VRAM_ABG[((DispCnt & 0x38000000) >> 25) + ((bgcnt & 0x1800) >> 11)];
|
||||
if (!tileset || !tilemap) return;
|
||||
tilemap += ((bgcnt & 0x0700) << 2);
|
||||
tilesetaddr = 0x06000000 + ((DispCnt & 0x07000000) >> 8) + ((bgcnt & 0x003C) << 12);
|
||||
tilemapaddr = 0x06000000 + ((DispCnt & 0x38000000) >> 11) + ((bgcnt & 0x1F00) << 3);
|
||||
|
||||
if (extpal)
|
||||
{
|
||||
pal = (u16*)GPU::VRAM_ABGExtPal[bgnum];
|
||||
|
||||
// derp
|
||||
if (!pal) pal = (u16*)&GPU::Palette[0];
|
||||
}
|
||||
else
|
||||
pal = (u16*)&GPU::Palette[0];
|
||||
pal = (u16*)&GPU::Palette[0];
|
||||
}
|
||||
|
||||
u16 curtile;
|
||||
u16* curpal;
|
||||
u8* pixels;
|
||||
|
||||
yshift -= 3;
|
||||
|
||||
@ -677,10 +731,10 @@ void GPU2D::DrawBG_Extended(u32 line, u32* dst, u32 bgnum)
|
||||
{
|
||||
if (!((rotX|rotY) & overflowmask))
|
||||
{
|
||||
curtile = tilemap[(((rotY & coordmask) >> 11) << yshift) + ((rotX & coordmask) >> 11)];
|
||||
curpal = pal;
|
||||
if (extpal) curpal += ((curtile & 0xF000) >> 4);
|
||||
pixels = tileset + ((curtile & 0x03FF) << 6);
|
||||
curtile = GPU::ReadVRAM_BG<u16>(tilemapaddr + (((((rotY & coordmask) >> 11) << yshift) + ((rotX & coordmask) >> 11)) << 1));
|
||||
|
||||
if (extpal) curpal = GetBGExtPal(bgnum, curtile>>12);
|
||||
else curpal = pal;
|
||||
|
||||
// draw pixel
|
||||
u8 color;
|
||||
@ -690,7 +744,7 @@ void GPU2D::DrawBG_Extended(u32 line, u32* dst, u32 bgnum)
|
||||
if (curtile & 0x0400) tilexoff = 7-tilexoff;
|
||||
if (curtile & 0x0800) tileyoff = 7-tileyoff;
|
||||
|
||||
color = pixels[(tileyoff << 3) + tilexoff];
|
||||
color = GPU::ReadVRAM_BG<u8>(tilesetaddr + ((curtile & 0x03FF) << 6) + (tileyoff << 3) + tilexoff);
|
||||
|
||||
if (color)
|
||||
drawpixelfn(bgnum, &dst[i], curpal[color], BlendFunc);
|
||||
@ -853,9 +907,7 @@ void GPU2D::DrawSprite_Rotscale(u16* attrib, u16* rotparams, u32 boundwidth, u32
|
||||
// 16-color
|
||||
tilenum <<= 5;
|
||||
ytilefactor <<= 5;
|
||||
u8* pixels = (Num ? GPU::VRAM_BOBJ : GPU::VRAM_AOBJ)[tilenum >> 14];
|
||||
if (!pixels) return;
|
||||
pixels += (tilenum & 0x3FFF);
|
||||
u32 pixelsaddr = (Num ? 0x06600000 : 0x06400000) + tilenum;
|
||||
|
||||
u16* pal = (u16*)&GPU::Palette[Num ? 0x600 : 0x200];
|
||||
pal += (attrib[2] & 0xF000) >> 8;
|
||||
@ -867,7 +919,7 @@ void GPU2D::DrawSprite_Rotscale(u16* attrib, u16* rotparams, u32 boundwidth, u32
|
||||
u8 color;
|
||||
|
||||
// blaaaarg
|
||||
color = pixels[((rotY>>11)*ytilefactor) + ((rotY&0x700)>>6) + ((rotX>>11)*32) + ((rotX&0x700)>>9)];
|
||||
color = GPU::ReadVRAM_OBJ<u8>(pixelsaddr + ((rotY>>11)*ytilefactor) + ((rotY&0x700)>>6) + ((rotX>>11)*32) + ((rotX&0x700)>>9));
|
||||
|
||||
if (rotX & 0x100)
|
||||
color >>= 4;
|
||||
@ -919,58 +971,49 @@ void GPU2D::DrawSprite_Normal(u16* attrib, u32 width, s32 xpos, u32 ypos, u32* d
|
||||
{
|
||||
// 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);
|
||||
u32 pixelsaddr = (Num ? 0x06600000 : 0x06400000) + tilenum;
|
||||
pixelsaddr += ((ypos & 0x7) << 3);
|
||||
|
||||
u32 extpal = (DispCnt & 0x80000000);
|
||||
|
||||
u16* pal;
|
||||
if (extpal)
|
||||
{
|
||||
pal = (u16*)(Num ? GPU::VRAM_BOBJExtPal : GPU::VRAM_AOBJExtPal);
|
||||
pal += (attrib[2] & 0xF000) >> 4;
|
||||
}
|
||||
else
|
||||
pal = (u16*)&GPU::Palette[Num ? 0x600 : 0x200];
|
||||
|
||||
if (!pal) pal = (u16*)&GPU::Palette[Num ? 0x600 : 0x200]; // derp
|
||||
if (extpal) pal = GetOBJExtPal(attrib[2] >> 12);
|
||||
else pal = (u16*)&GPU::Palette[Num ? 0x600 : 0x200];
|
||||
|
||||
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);
|
||||
pixelsaddr += (((width-1 - xoff) & wmask) << 3);
|
||||
pixelsaddr += ((width-1 - xoff) & 0x7);
|
||||
|
||||
for (; xoff < width;)
|
||||
{
|
||||
u8 color = *pixels;
|
||||
pixels--;
|
||||
u8 color = GPU::ReadVRAM_OBJ<u8>(pixelsaddr);
|
||||
pixelsaddr--;
|
||||
|
||||
if (color)
|
||||
dst[xpos] = pal[color] | prio;
|
||||
|
||||
xoff++;
|
||||
xpos++;
|
||||
if (!(xoff & 0x7)) pixels -= 56;
|
||||
if (!(xoff & 0x7)) pixelsaddr -= 56;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pixels += ((xoff & wmask) << 3);
|
||||
pixels += (xoff & 0x7);
|
||||
pixelsaddr += ((xoff & wmask) << 3);
|
||||
pixelsaddr += (xoff & 0x7);
|
||||
|
||||
for (; xoff < width;)
|
||||
{
|
||||
u8 color = *pixels;
|
||||
pixels++;
|
||||
u8 color = GPU::ReadVRAM_OBJ<u8>(pixelsaddr);
|
||||
pixelsaddr++;
|
||||
|
||||
if (color)
|
||||
dst[xpos] = pal[color] | prio;
|
||||
|
||||
xoff++;
|
||||
xpos++;
|
||||
if (!(xoff & 0x7)) pixels += 56;
|
||||
if (!(xoff & 0x7)) pixelsaddr += 56;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -978,30 +1021,28 @@ void GPU2D::DrawSprite_Normal(u16* attrib, u32 width, s32 xpos, u32 ypos, u32* d
|
||||
{
|
||||
// 16-color
|
||||
tilenum <<= 5;
|
||||
u8* pixels = (Num ? GPU::VRAM_BOBJ : GPU::VRAM_AOBJ)[tilenum >> 14];
|
||||
if (!pixels) return;
|
||||
pixels += (tilenum & 0x3FFF);
|
||||
pixels += ((ypos & 0x7) << 2);
|
||||
u32 pixelsaddr = (Num ? 0x06600000 : 0x06400000) + tilenum;
|
||||
pixelsaddr += ((ypos & 0x7) << 2);
|
||||
|
||||
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) << 2);
|
||||
pixels += (((width-1 - xoff) & 0x7) >> 1);
|
||||
pixelsaddr += (((width-1 - xoff) & wmask) << 2);
|
||||
pixelsaddr += (((width-1 - xoff) & 0x7) >> 1);
|
||||
|
||||
for (; xoff < width;)
|
||||
{
|
||||
u8 color;
|
||||
if (xoff & 0x1)
|
||||
{
|
||||
color = *pixels & 0x0F;
|
||||
pixels--;
|
||||
color = GPU::ReadVRAM_OBJ<u8>(pixelsaddr) & 0x0F;
|
||||
pixelsaddr--;
|
||||
}
|
||||
else
|
||||
{
|
||||
color = *pixels >> 4;
|
||||
color = GPU::ReadVRAM_OBJ<u8>(pixelsaddr) >> 4;
|
||||
}
|
||||
|
||||
if (color)
|
||||
@ -1009,25 +1050,25 @@ void GPU2D::DrawSprite_Normal(u16* attrib, u32 width, s32 xpos, u32 ypos, u32* d
|
||||
|
||||
xoff++;
|
||||
xpos++;
|
||||
if (!(xoff & 0x7)) pixels -= 28;
|
||||
if (!(xoff & 0x7)) pixelsaddr -= 28;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pixels += ((xoff & wmask) << 2);
|
||||
pixels += ((xoff & 0x7) >> 1);
|
||||
pixelsaddr += ((xoff & wmask) << 2);
|
||||
pixelsaddr += ((xoff & 0x7) >> 1);
|
||||
|
||||
for (; xoff < width;)
|
||||
{
|
||||
u8 color;
|
||||
if (xoff & 0x1)
|
||||
{
|
||||
color = *pixels >> 4;
|
||||
pixels++;
|
||||
color = GPU::ReadVRAM_OBJ<u8>(pixelsaddr) >> 4;
|
||||
pixelsaddr++;
|
||||
}
|
||||
else
|
||||
{
|
||||
color = *pixels & 0x0F;
|
||||
color = GPU::ReadVRAM_OBJ<u8>(pixelsaddr) & 0x0F;
|
||||
}
|
||||
|
||||
if (color)
|
||||
@ -1035,7 +1076,7 @@ void GPU2D::DrawSprite_Normal(u16* attrib, u32 width, s32 xpos, u32 ypos, u32* d
|
||||
|
||||
xoff++;
|
||||
xpos++;
|
||||
if (!(xoff & 0x7)) pixels += 28;
|
||||
if (!(xoff & 0x7)) pixelsaddr += 28;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
11
GPU2D.h
11
GPU2D.h
@ -39,6 +39,12 @@ public:
|
||||
void DrawScanline(u32 line);
|
||||
void VBlank();
|
||||
|
||||
void BGExtPalDirty(u32 base);
|
||||
void OBJExtPalDirty();
|
||||
|
||||
u16* GetBGExtPal(u32 slot, u32 pal);
|
||||
u16* GetOBJExtPal(u32 pal);
|
||||
|
||||
private:
|
||||
u32 Num;
|
||||
u32* Framebuffer;
|
||||
@ -58,6 +64,11 @@ private:
|
||||
|
||||
u32 BlendFunc;
|
||||
|
||||
u16 BGExtPalCache[4][16*256];
|
||||
u16 OBJExtPalCache[16*256];
|
||||
u32 BGExtPalStatus[4];
|
||||
u32 OBJExtPalStatus;
|
||||
|
||||
template<u32 bgmode> void DrawScanlineBGMode(u32 line, u32* spritebuf, u32* dst);
|
||||
void DrawScanline_Mode1(u32 line, u32* dst);
|
||||
|
||||
|
@ -72,6 +72,7 @@ void RenderPixel(u32 attr, s32 x, s32 y, s32 z, u8 vr, u8 vg, u8 vb)
|
||||
pixel[3] = 31; // TODO: alpha
|
||||
|
||||
// TODO: optional update for translucent pixels
|
||||
if (z > 0xFFFFFF) z = 0xFFFFFF;
|
||||
*depth = z;
|
||||
}
|
||||
|
||||
@ -128,9 +129,12 @@ void RenderPolygon(Polygon* polygon)
|
||||
vtx->FinalPosition[2] = posZ;
|
||||
vtx->FinalPosition[3] = posW;
|
||||
|
||||
vtx->FinalColor[0] = vtx->Color[0] ? (((vtx->Color[0] >> 12) << 4) + 0xF) : 0;
|
||||
vtx->FinalColor[1] = vtx->Color[1] ? (((vtx->Color[1] >> 12) << 4) + 0xF) : 0;
|
||||
vtx->FinalColor[2] = vtx->Color[2] ? (((vtx->Color[2] >> 12) << 4) + 0xF) : 0;
|
||||
vtx->FinalColor[0] = vtx->Color[0] >> 12;
|
||||
if (vtx->FinalColor[0]) vtx->FinalColor[0] = ((vtx->FinalColor[0] << 4) + 0xF);
|
||||
vtx->FinalColor[1] = vtx->Color[1] >> 12;
|
||||
if (vtx->FinalColor[1]) vtx->FinalColor[1] = ((vtx->FinalColor[1] << 4) + 0xF);
|
||||
vtx->FinalColor[2] = vtx->Color[2] >> 12;
|
||||
if (vtx->FinalColor[2]) vtx->FinalColor[2] = ((vtx->FinalColor[2] << 4) + 0xF);
|
||||
|
||||
vtx->ViewportTransformDone = true;
|
||||
}
|
||||
@ -238,19 +242,24 @@ void RenderPolygon(Polygon* polygon)
|
||||
|
||||
s32 lfactor, rfactor;
|
||||
|
||||
// TODO: work out the actual division bias there. 0x400 was found to make things look good.
|
||||
// but actually, it isn't right. so what's going on there?
|
||||
// seems vertical slopes are interpolated starting from the bottom and not the top. maybe.
|
||||
// also seems lfactor/rfactor are rounded
|
||||
|
||||
if (vlnext->FinalPosition[1] == vlcur->FinalPosition[1])
|
||||
lfactor = 0;
|
||||
else
|
||||
lfactor = ((y - vlcur->FinalPosition[1]) << 12) / (vlnext->FinalPosition[1] - vlcur->FinalPosition[1]);
|
||||
lfactor = (((y - 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) / (vrnext->FinalPosition[1] - vrcur->FinalPosition[1]);
|
||||
rfactor = (((y - 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);
|
||||
|
||||
//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
|
||||
{
|
||||
Vertex* vtmp;
|
||||
@ -270,7 +279,7 @@ void RenderPolygon(Polygon* polygon)
|
||||
continue; // hax
|
||||
}
|
||||
|
||||
s32 zl = vlcur->FinalPosition[2] + (((s64)(vlnext->FinalPosition[2] -vlcur->FinalPosition[2]) * lfactor) >> 12);
|
||||
s32 zl = vlcur->FinalPosition[2] + (((s64)(vlnext->FinalPosition[2] - vlcur->FinalPosition[2]) * lfactor) >> 12);
|
||||
s32 zr = vrcur->FinalPosition[2] + (((s64)(vrnext->FinalPosition[2] - vrcur->FinalPosition[2]) * rfactor) >> 12);
|
||||
|
||||
s32 wl = vlcur->FinalPosition[3] + (((s64)(vlnext->FinalPosition[3] - vlcur->FinalPosition[3]) * lfactor) >> 12);
|
||||
@ -303,8 +312,11 @@ void RenderPolygon(Polygon* polygon)
|
||||
if (xr == xl) xr++;
|
||||
s32 xdiv = 0x1000 / (xr - xl);
|
||||
|
||||
//printf("y%d: %d->%d %08X %08X\n", y, xl, xr, lfactor, rfactor);
|
||||
|
||||
for (s32 x = xl; x < xr; x++)
|
||||
{
|
||||
//s32 xfactor = ((x - xl) << 12) / (xr - xl);
|
||||
s32 xfactor = (x - xl) * xdiv;
|
||||
|
||||
s32 z = zl + (((s64)(zr - zl) * xfactor) >> 12);
|
||||
@ -327,12 +339,6 @@ void RenderPolygon(Polygon* polygon)
|
||||
u32 vb = ((perspfactor1 * bl) + (perspfactor2 * br)) / (perspfactor1 + perspfactor2);
|
||||
|
||||
RenderPixel(polygon->Attr, x, y, z, vr>>3, vg>>3, vb>>3);
|
||||
|
||||
// Z debug
|
||||
/*u8 zerp = (w * 63) / 0xFFFFFF;
|
||||
pixel[0] = zerp;
|
||||
pixel[1] = zerp;
|
||||
pixel[2] = zerp;*/
|
||||
}
|
||||
}
|
||||
|
||||
|
126
NDS.cpp
126
NDS.cpp
@ -311,7 +311,8 @@ void Reset()
|
||||
// test
|
||||
//LoadROM();
|
||||
//LoadFirmware();
|
||||
if (NDSCart::LoadROM("rom/sm64ds.nds"))
|
||||
// a_interp2.nds a_rounding (10) (11)
|
||||
if (NDSCart::LoadROM("rom/nsmb.nds"))
|
||||
Running = true; // hax
|
||||
}
|
||||
|
||||
@ -803,18 +804,14 @@ u8 ARM9Read8(u32 addr)
|
||||
|
||||
case 0x06000000:
|
||||
{
|
||||
u32 chunk = (addr >> 14) & 0x7F;
|
||||
u8* vram = NULL;
|
||||
switch (addr & 0x00E00000)
|
||||
{
|
||||
case 0x00000000: vram = GPU::VRAM_ABG[chunk]; break;
|
||||
case 0x00200000: vram = GPU::VRAM_BBG[chunk]; break;
|
||||
case 0x00400000: vram = GPU::VRAM_AOBJ[chunk]; break;
|
||||
case 0x00600000: vram = GPU::VRAM_BOBJ[chunk]; break;
|
||||
case 0x00800000: vram = GPU::VRAM_LCD[chunk]; break;
|
||||
case 0x00000000: return GPU::ReadVRAM_ABG<u8>(addr);
|
||||
case 0x00200000: return GPU::ReadVRAM_BBG<u8>(addr);
|
||||
case 0x00400000: return GPU::ReadVRAM_AOBJ<u8>(addr);
|
||||
case 0x00600000: return GPU::ReadVRAM_BOBJ<u8>(addr);
|
||||
default: return GPU::ReadVRAM_LCDC<u8>(addr);
|
||||
}
|
||||
if (vram)
|
||||
return *(u8*)&vram[addr & 0x3FFF];
|
||||
}
|
||||
return 0;
|
||||
|
||||
@ -854,18 +851,14 @@ u16 ARM9Read16(u32 addr)
|
||||
|
||||
case 0x06000000:
|
||||
{
|
||||
u32 chunk = (addr >> 14) & 0x7F;
|
||||
u8* vram = NULL;
|
||||
switch (addr & 0x00E00000)
|
||||
{
|
||||
case 0x00000000: vram = GPU::VRAM_ABG[chunk]; break;
|
||||
case 0x00200000: vram = GPU::VRAM_BBG[chunk]; break;
|
||||
case 0x00400000: vram = GPU::VRAM_AOBJ[chunk]; break;
|
||||
case 0x00600000: vram = GPU::VRAM_BOBJ[chunk]; break;
|
||||
case 0x00800000: vram = GPU::VRAM_LCD[chunk]; break;
|
||||
case 0x00000000: return GPU::ReadVRAM_ABG<u16>(addr);
|
||||
case 0x00200000: return GPU::ReadVRAM_BBG<u16>(addr);
|
||||
case 0x00400000: return GPU::ReadVRAM_AOBJ<u16>(addr);
|
||||
case 0x00600000: return GPU::ReadVRAM_BOBJ<u16>(addr);
|
||||
default: return GPU::ReadVRAM_LCDC<u16>(addr);
|
||||
}
|
||||
if (vram)
|
||||
return *(u16*)&vram[addr & 0x3FFF];
|
||||
}
|
||||
return 0;
|
||||
|
||||
@ -905,18 +898,14 @@ u32 ARM9Read32(u32 addr)
|
||||
|
||||
case 0x06000000:
|
||||
{
|
||||
u32 chunk = (addr >> 14) & 0x7F;
|
||||
u8* vram = NULL;
|
||||
switch (addr & 0x00E00000)
|
||||
{
|
||||
case 0x00000000: vram = GPU::VRAM_ABG[chunk]; break;
|
||||
case 0x00200000: vram = GPU::VRAM_BBG[chunk]; break;
|
||||
case 0x00400000: vram = GPU::VRAM_AOBJ[chunk]; break;
|
||||
case 0x00600000: vram = GPU::VRAM_BOBJ[chunk]; break;
|
||||
case 0x00800000: vram = GPU::VRAM_LCD[chunk]; break;
|
||||
case 0x00000000: return GPU::ReadVRAM_ABG<u32>(addr);
|
||||
case 0x00200000: return GPU::ReadVRAM_BBG<u32>(addr);
|
||||
case 0x00400000: return GPU::ReadVRAM_AOBJ<u32>(addr);
|
||||
case 0x00600000: return GPU::ReadVRAM_BOBJ<u32>(addr);
|
||||
default: return GPU::ReadVRAM_LCDC<u32>(addr);
|
||||
}
|
||||
if (vram)
|
||||
return *(u32*)&vram[addr & 0x3FFF];
|
||||
}
|
||||
return 0;
|
||||
|
||||
@ -978,19 +967,13 @@ void ARM9Write16(u32 addr, u16 val)
|
||||
return;
|
||||
|
||||
case 0x06000000:
|
||||
switch (addr & 0x00E00000)
|
||||
{
|
||||
u32 chunk = (addr >> 14) & 0x7F;
|
||||
u8* vram = NULL;
|
||||
switch (addr & 0x00E00000)
|
||||
{
|
||||
case 0x00000000: vram = GPU::VRAM_ABG[chunk]; break;
|
||||
case 0x00200000: vram = GPU::VRAM_BBG[chunk]; break;
|
||||
case 0x00400000: vram = GPU::VRAM_AOBJ[chunk]; break;
|
||||
case 0x00600000: vram = GPU::VRAM_BOBJ[chunk]; break;
|
||||
case 0x00800000: vram = GPU::VRAM_LCD[chunk]; break;
|
||||
}
|
||||
if (vram)
|
||||
*(u16*)&vram[addr & 0x3FFF] = val;
|
||||
case 0x00000000: GPU::WriteVRAM_ABG<u16>(addr, val); break;
|
||||
case 0x00200000: GPU::WriteVRAM_BBG<u16>(addr, val); break;
|
||||
case 0x00400000: GPU::WriteVRAM_AOBJ<u16>(addr, val); break;
|
||||
case 0x00600000: GPU::WriteVRAM_BOBJ<u16>(addr, val); break;
|
||||
default: GPU::WriteVRAM_LCDC<u16>(addr, val); break;
|
||||
}
|
||||
return;
|
||||
|
||||
@ -1023,19 +1006,13 @@ void ARM9Write32(u32 addr, u32 val)
|
||||
return;
|
||||
|
||||
case 0x06000000:
|
||||
switch (addr & 0x00E00000)
|
||||
{
|
||||
u32 chunk = (addr >> 14) & 0x7F;
|
||||
u8* vram = NULL;
|
||||
switch (addr & 0x00E00000)
|
||||
{
|
||||
case 0x00000000: vram = GPU::VRAM_ABG[chunk]; break;
|
||||
case 0x00200000: vram = GPU::VRAM_BBG[chunk]; break;
|
||||
case 0x00400000: vram = GPU::VRAM_AOBJ[chunk]; break;
|
||||
case 0x00600000: vram = GPU::VRAM_BOBJ[chunk]; break;
|
||||
case 0x00800000: vram = GPU::VRAM_LCD[chunk]; break;
|
||||
}
|
||||
if (vram)
|
||||
*(u32*)&vram[addr & 0x3FFF] = val;
|
||||
case 0x00000000: GPU::WriteVRAM_ABG<u32>(addr, val); break;
|
||||
case 0x00200000: GPU::WriteVRAM_BBG<u32>(addr, val); break;
|
||||
case 0x00400000: GPU::WriteVRAM_AOBJ<u32>(addr, val); break;
|
||||
case 0x00600000: GPU::WriteVRAM_BOBJ<u32>(addr, val); break;
|
||||
default: GPU::WriteVRAM_LCDC<u32>(addr, val); break;
|
||||
}
|
||||
return;
|
||||
|
||||
@ -1079,13 +1056,7 @@ u8 ARM7Read8(u32 addr)
|
||||
|
||||
case 0x06000000:
|
||||
case 0x06800000:
|
||||
{
|
||||
u32 chunk = (addr >> 17) & 0x1;
|
||||
u8* vram = GPU::VRAM_ARM7[chunk];
|
||||
if (vram)
|
||||
return *(u8*)&vram[addr & 0x1FFFF];
|
||||
}
|
||||
return 0;
|
||||
return GPU::ReadVRAM_ARM7<u8>(addr);
|
||||
}
|
||||
|
||||
printf("unknown arm7 read8 %08X %08X %08X/%08X\n", addr, ARM7->R[15], ARM7->R[0], ARM7->R[1]);
|
||||
@ -1125,13 +1096,7 @@ u16 ARM7Read16(u32 addr)
|
||||
|
||||
case 0x06000000:
|
||||
case 0x06800000:
|
||||
{
|
||||
u32 chunk = (addr >> 17) & 0x1;
|
||||
u8* vram = GPU::VRAM_ARM7[chunk];
|
||||
if (vram)
|
||||
return *(u16*)&vram[addr & 0x1FFFF];
|
||||
}
|
||||
return 0;
|
||||
return GPU::ReadVRAM_ARM7<u16>(addr);
|
||||
}
|
||||
|
||||
printf("unknown arm7 read16 %08X %08X\n", addr, ARM7->R[15]);
|
||||
@ -1168,13 +1133,7 @@ u32 ARM7Read32(u32 addr)
|
||||
|
||||
case 0x06000000:
|
||||
case 0x06800000:
|
||||
{
|
||||
u32 chunk = (addr >> 17) & 0x1;
|
||||
u8* vram = GPU::VRAM_ARM7[chunk];
|
||||
if (vram)
|
||||
return *(u32*)&vram[addr & 0x1FFFF];
|
||||
}
|
||||
return 0;
|
||||
return GPU::ReadVRAM_ARM7<u32>(addr);
|
||||
}
|
||||
|
||||
printf("unknown arm7 read32 %08X | %08X\n", addr, ARM7->R[15]);
|
||||
@ -1205,12 +1164,7 @@ void ARM7Write8(u32 addr, u8 val)
|
||||
|
||||
case 0x06000000:
|
||||
case 0x06800000:
|
||||
{
|
||||
u32 chunk = (addr >> 17) & 0x1;
|
||||
u8* vram = GPU::VRAM_ARM7[chunk];
|
||||
if (vram)
|
||||
*(u8*)&vram[addr & 0x1FFFF] = val;
|
||||
}
|
||||
GPU::WriteVRAM_ARM7<u8>(addr, val);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1245,12 +1199,7 @@ void ARM7Write16(u32 addr, u16 val)
|
||||
|
||||
case 0x06000000:
|
||||
case 0x06800000:
|
||||
{
|
||||
u32 chunk = (addr >> 17) & 0x1;
|
||||
u8* vram = GPU::VRAM_ARM7[chunk];
|
||||
if (vram)
|
||||
*(u16*)&vram[addr & 0x1FFFF] = val;
|
||||
}
|
||||
GPU::WriteVRAM_ARM7<u16>(addr, val);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1281,12 +1230,7 @@ void ARM7Write32(u32 addr, u32 val)
|
||||
|
||||
case 0x06000000:
|
||||
case 0x06800000:
|
||||
{
|
||||
u32 chunk = (addr >> 17) & 0x1;
|
||||
u8* vram = GPU::VRAM_ARM7[chunk];
|
||||
if (vram)
|
||||
*(u32*)&vram[addr & 0x1FFFF] = val;
|
||||
}
|
||||
GPU::WriteVRAM_ARM7<u32>(addr, val);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
1481161027 c:\documents\sources\melonds\types.h
|
||||
|
||||
1487609259 source:c:\documents\sources\melonds\nds.cpp
|
||||
1488225095 source:c:\documents\sources\melonds\nds.cpp
|
||||
<stdio.h>
|
||||
<string.h>
|
||||
"NDS.h"
|
||||
@ -87,13 +87,13 @@
|
||||
"NDS.h"
|
||||
"SPI.h"
|
||||
|
||||
1487105611 source:c:\documents\sources\melonds\gpu2d.cpp
|
||||
1488226954 source:c:\documents\sources\melonds\gpu2d.cpp
|
||||
<stdio.h>
|
||||
<string.h>
|
||||
"NDS.h"
|
||||
"GPU.h"
|
||||
|
||||
1487105228 c:\documents\sources\melonds\gpu2d.h
|
||||
1488225922 c:\documents\sources\melonds\gpu2d.h
|
||||
|
||||
1481040524 c:\documents\sources\melonds\wifi.h
|
||||
|
||||
@ -119,13 +119,13 @@
|
||||
1487305393 c:\documents\sources\melonds\dma.h
|
||||
"types.h"
|
||||
|
||||
1487102235 source:c:\documents\sources\melonds\gpu.cpp
|
||||
1488226688 source:c:\documents\sources\melonds\gpu.cpp
|
||||
<stdio.h>
|
||||
<string.h>
|
||||
"NDS.h"
|
||||
"GPU.h"
|
||||
|
||||
1487102203 c:\documents\sources\melonds\gpu.h
|
||||
1488225864 c:\documents\sources\melonds\gpu.h
|
||||
"GPU2D.h"
|
||||
"GPU3D.h"
|
||||
|
||||
@ -148,14 +148,14 @@
|
||||
|
||||
1487610598 c:\documents\sources\melonds\gpu3d.h
|
||||
|
||||
1487612707 source:c:\documents\sources\melonds\gpu3d.cpp
|
||||
1487681103 source:c:\documents\sources\melonds\gpu3d.cpp
|
||||
<stdio.h>
|
||||
<string.h>
|
||||
"NDS.h"
|
||||
"GPU.h"
|
||||
"FIFO.h"
|
||||
|
||||
1487611069 source:c:\documents\sources\melonds\gpu3d_soft.cpp
|
||||
1488214777 source:c:\documents\sources\melonds\gpu3d_soft.cpp
|
||||
<stdio.h>
|
||||
<string.h>
|
||||
"NDS.h"
|
||||
|
Loading…
Reference in New Issue
Block a user