diff options
-rw-r--r-- | GPU.cpp | 52 | ||||
-rw-r--r-- | GPU.h | 5 | ||||
-rw-r--r-- | GPU2D.cpp | 35 | ||||
-rw-r--r-- | melonDS.depend | 8 |
4 files changed, 74 insertions, 26 deletions
@@ -56,6 +56,11 @@ u8* VRAM_BOBJ[128]; u8* VRAM_LCD[128]; u8* VRAM_ARM7[2]; +u8* VRAM_ABGExtPal[4]; +u8* VRAM_AOBJExtPal; +u8* VRAM_BBGExtPal[4]; +u8* VRAM_BOBJExtPal; + u16 Framebuffer[256*192*2]; GPU2D* GPU2D_A; @@ -100,6 +105,11 @@ void Reset() 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; + for (int i = 0; i < 256*192*2; i++) { Framebuffer[i] = 0x7FFF; @@ -370,11 +380,10 @@ void MapVRAM_E(u32 bank, u8 cnt) break; case 4: - // BG EXTPAL -- TODO - break; - - case 5: - // OBJ EXTPAL -- TODO + VRAM_ABGExtPal[0] = NULL; + VRAM_ABGExtPal[1] = NULL; + VRAM_ABGExtPal[2] = NULL; + VRAM_ABGExtPal[3] = NULL; break; } @@ -421,11 +430,10 @@ void MapVRAM_E(u32 bank, u8 cnt) break; case 4: - // BG EXTPAL -- TODO - break; - - case 5: - // OBJ EXTPAL -- TODO + VRAM_ABGExtPal[0] = &vram[0x0000]; + VRAM_ABGExtPal[1] = &vram[0x2000]; + VRAM_ABGExtPal[2] = &vram[0x4000]; + VRAM_ABGExtPal[3] = &vram[0x6000]; break; } @@ -479,11 +487,12 @@ void MapVRAM_FG(u32 bank, u8 cnt) break; case 4: - // BG EXTPAL TODO + VRAM_ABGExtPal[(oldofs<<1)+0] = NULL; + VRAM_ABGExtPal[(oldofs<<1)+1] = NULL; break; case 5: - // OBJ EXTPAL TODO + VRAM_AOBJExtPal = NULL; break; } @@ -523,11 +532,12 @@ void MapVRAM_FG(u32 bank, u8 cnt) break; case 4: - // BG EXTPAL TODO + VRAM_ABGExtPal[(ofs<<1)+0] = &vram[0x0000]; + VRAM_ABGExtPal[(ofs<<1)+1] = &vram[0x2000]; break; case 5: - // OBJ EXTPAL TODO + VRAM_AOBJExtPal = vram; break; } @@ -573,7 +583,10 @@ void MapVRAM_H(u32 bank, u8 cnt) break; case 2: - // BG EXTPAL TODO + VRAM_BBGExtPal[0] = NULL; + VRAM_BBGExtPal[1] = NULL; + VRAM_BBGExtPal[2] = NULL; + VRAM_BBGExtPal[3] = NULL; break; } @@ -615,7 +628,10 @@ void MapVRAM_H(u32 bank, u8 cnt) break; case 2: - // BG EXTPAL TODO + VRAM_BBGExtPal[0] = &vram[0x0000]; + VRAM_BBGExtPal[1] = &vram[0x2000]; + VRAM_BBGExtPal[2] = &vram[0x4000]; + VRAM_BBGExtPal[3] = &vram[0x6000]; break; } @@ -665,7 +681,7 @@ void MapVRAM_I(u32 bank, u8 cnt) break; case 3: - // not mapped to memory + VRAM_BOBJExtPal = NULL; break; } @@ -701,7 +717,7 @@ void MapVRAM_I(u32 bank, u8 cnt) break; case 3: - // not mapped to memory + VRAM_BOBJExtPal = vram; break; } @@ -42,6 +42,11 @@ extern u8* VRAM_BOBJ[128]; extern u8* VRAM_LCD[128]; extern u8* VRAM_ARM7[2]; +extern u8* VRAM_ABGExtPal[4]; +extern u8* VRAM_AOBJExtPal; +extern u8* VRAM_BBGExtPal[4]; +extern u8* VRAM_BOBJExtPal; + extern u16 Framebuffer[256*192*2]; extern GPU2D* GPU2D_A; @@ -265,6 +265,7 @@ void GPU2D::DrawBG_Text_4bpp(u32 line, u16* dst, u32 bgnum) u8* tileset; u16* tilemap; u16* pal; + u32 extpal; u16 xoff = BGXPos[bgnum]; u16 yoff = BGYPos[bgnum] + line; @@ -272,6 +273,8 @@ void GPU2D::DrawBG_Text_4bpp(u32 line, u16* dst, u32 bgnum) u32 widexmask = (bgcnt & 0x4000) ? 0x100 : 0; //u32 ymask = (bgcnt & 0x8000) ? 0x1FF : 0xFF; + extpal = (bgcnt & 0x0080) && (DispCnt & 0x40000000); + if (Num) { tileset = (u8*)GPU::VRAM_BBG[((bgcnt & 0x003C) >> 2)]; @@ -279,7 +282,18 @@ void GPU2D::DrawBG_Text_4bpp(u32 line, u16* dst, u32 bgnum) if (!tileset || !tilemap) return; tilemap += ((bgcnt & 0x0700) << 2); - pal = (u16*)&GPU::Palette[0x400]; + 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]; } else { @@ -288,7 +302,18 @@ void GPU2D::DrawBG_Text_4bpp(u32 line, u16* dst, u32 bgnum) if (!tileset || !tilemap) return; tilemap += ((bgcnt & 0x0700) << 2); - pal = (u16*)&GPU::Palette[0]; + 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]; } // adjust Y position in tilemap @@ -314,7 +339,8 @@ void GPU2D::DrawBG_Text_4bpp(u32 line, u16* dst, u32 bgnum) { // load a new tile curtile = tilemap[((xoff & 0xFF) >> 3) + ((xoff & widexmask) << 2)]; - curpal = pal;// + ((curtile & 0xF000) >> 8); // TODO: this applies to ext palettes + curpal = pal; + if (extpal) curpal += ((curtile & 0xF000) >> 4); pixels = tileset + ((curtile & 0x03FF) << 6); pixels += (((curtile & 0x0800) ? (7-(yoff&0x7)) : (yoff&0x7)) << 3); } @@ -325,7 +351,8 @@ void GPU2D::DrawBG_Text_4bpp(u32 line, u16* dst, u32 bgnum) { // load a new tile curtile = tilemap[((xoff & 0xFF) >> 3) + ((xoff & widexmask) << 2)]; - curpal = pal;// + ((curtile & 0xF000) >> 8); + curpal = pal; + if (extpal) curpal += ((curtile & 0xF000) >> 4); pixels = tileset + ((curtile & 0x03FF) << 6); pixels += (((curtile & 0x0800) ? (7-(yoff&0x7)) : (yoff&0x7)) << 3); } diff --git a/melonDS.depend b/melonDS.depend index 66d5ae2..c918c7e 100644 --- a/melonDS.depend +++ b/melonDS.depend @@ -10,7 +10,7 @@ 1481161027 c:\documents\sources\melonds\types.h -1485988849 source:c:\documents\sources\melonds\nds.cpp +1485988923 source:c:\documents\sources\melonds\nds.cpp <stdio.h> <string.h> "NDS.h" @@ -86,7 +86,7 @@ "NDS.h" "SPI.h" -1485988879 source:c:\documents\sources\melonds\gpu2d.cpp +1485990245 source:c:\documents\sources\melonds\gpu2d.cpp <stdio.h> <string.h> "NDS.h" @@ -117,13 +117,13 @@ 1484698068 c:\documents\sources\melonds\dma.h "types.h" -1485982457 source:c:\documents\sources\melonds\gpu.cpp +1485989904 source:c:\documents\sources\melonds\gpu.cpp <stdio.h> <string.h> "NDS.h" "GPU.h" -1485982310 c:\documents\sources\melonds\gpu.h +1485989497 c:\documents\sources\melonds\gpu.h "GPU2D.h" 1484848282 c:\documents\sources\melonds\rtc.h |