diff options
author | StapleButter <thetotalworm@gmail.com> | 2017-01-20 15:27:56 +0100 |
---|---|---|
committer | StapleButter <thetotalworm@gmail.com> | 2017-01-20 15:27:56 +0100 |
commit | 711375c0be60bb3bba679dfff44e5ccebe501f52 (patch) | |
tree | 044fe418943fe8d6a33b09e3480ae4c7fc526664 | |
parent | 7dba0121cbadcfadb6651ec37ad95241dd94b296 (diff) |
BG scroll. also fix silly bug.
-rw-r--r-- | GPU2D.cpp | 20 | ||||
-rw-r--r-- | GPU2D.h | 3 | ||||
-rw-r--r-- | NDS.cpp | 11 | ||||
-rw-r--r-- | melonDS.depend | 6 |
4 files changed, 23 insertions, 17 deletions
@@ -35,6 +35,8 @@ void GPU2D::Reset() { DispCnt = 0; memset(BGCnt, 0, 4*2); + memset(BGXPos, 0, 4*2); + memset(BGYPos, 0, 4*2); } void GPU2D::SetFramebuffer(u16* buf) @@ -100,6 +102,15 @@ void GPU2D::Write16(u32 addr, u16 val) case 0x00A: BGCnt[1] = val; return; case 0x00C: BGCnt[2] = val; return; case 0x00E: BGCnt[3] = val; return; + + case 0x010: BGXPos[0] = val; return; + case 0x012: BGYPos[0] = val; return; + case 0x014: BGXPos[1] = val; return; + case 0x016: BGYPos[1] = val; return; + case 0x018: BGXPos[2] = val; return; + case 0x01A: BGYPos[2] = val; return; + case 0x01C: BGXPos[3] = val; return; + case 0x01E: BGYPos[3] = val; return; } printf("unknown GPU write16 %08X %04X\n", addr, val); @@ -213,9 +224,8 @@ void GPU2D::DrawBG_Text_4bpp(u32 line, u16* dst, u32 bgnum) u16* tilemap; u16* pal; - // TODO scroll - u16 xoff = 0; - u16 yoff = line; + u16 xoff = BGXPos[bgnum]; + u16 yoff = BGYPos[bgnum] + line; u32 widexmask = (bgcnt & 0x4000) ? 0x100 : 0; //u32 ymask = (bgcnt & 0x8000) ? 0x1FF : 0xFF; @@ -257,7 +267,7 @@ 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); - pixels = tileset + ((curtile & 0x01FF) << 5) + ((yoff & 0x7) << 2); + pixels = tileset + ((curtile & 0x03FF) << 5) + ((yoff & 0x7) << 2); pixels += ((xoff & 0x7) >> 1); } @@ -268,7 +278,7 @@ 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); - pixels = tileset + ((curtile & 0x01FF) << 5) + ((yoff & 0x7) << 2); + pixels = tileset + ((curtile & 0x03FF) << 5) + ((yoff & 0x7) << 2); } // draw pixel @@ -45,6 +45,9 @@ private: u32 DispCnt; u16 BGCnt[4]; + u16 BGXPos[4]; + u16 BGYPos[4]; + void DrawScanline_Mode1(u32 line, u16* dst); void DrawBG_Text_4bpp(u32 line, u16* dst, u32 num); }; @@ -970,13 +970,7 @@ void ARM9Write8(u32 addr, u8 val) void ARM9Write16(u32 addr, u16 val) { if (addr == ARM9->R[15]) printf("!!!!!!!!!!!!9999 %08X %04X\n", addr, val); - if (addr == 0x02331B44) printf("!! PAL !! %04X %08X\n", val, ARM9->R[15]); - /*if (addr >= 0x06218000 && addr < 0x06218000+0x6000 && val) - { - printf("WRITE TO LAME VRAM %08X %04X %08X, %08X %08X, %08X\n", addr, val, ARM9->R[15], ARM9->R[4], ARM9->R[3], - ARM9Read32(ARM9->R[13]+12)); - //Halt(); - }*/ + if (addr < ARM9ITCMSize) { *(u16*)&ARM9ITCM[addr & 0x7FFF] = val; @@ -1034,8 +1028,7 @@ void ARM9Write16(u32 addr, u16 val) void ARM9Write32(u32 addr, u32 val) { if (addr == ARM9->R[15]) printf("!!!!!!!!!!!!9999 %08X %08X\n", addr, val); - if (addr == 0x023549F0) printf("%08X STATE=%08X\n", ARM9->R[15], val); - if (addr == 0x02331B44) printf("!! PAL !! %04X %08X %08X\n", val, ARM9->R[15], ARM9Read32(0x23312E8)); + if (addr < ARM9ITCMSize) { *(u32*)&ARM9ITCM[addr & 0x7FFF] = val; diff --git a/melonDS.depend b/melonDS.depend index 89df6a0..00d1b5d 100644 --- a/melonDS.depend +++ b/melonDS.depend @@ -10,7 +10,7 @@ 1481161027 c:\documents\sources\melonds\types.h -1484919120 source:c:\documents\sources\melonds\nds.cpp +1484922190 source:c:\documents\sources\melonds\nds.cpp <stdio.h> <string.h> "NDS.h" @@ -83,13 +83,13 @@ "NDS.h" "SPI.h" -1484920777 source:c:\documents\sources\melonds\gpu2d.cpp +1484922144 source:c:\documents\sources\melonds\gpu2d.cpp <stdio.h> <string.h> "NDS.h" "GPU.h" -1484711212 c:\documents\sources\melonds\gpu2d.h +1484922330 c:\documents\sources\melonds\gpu2d.h 1481040524 c:\documents\sources\melonds\wifi.h |