From 86ba586d000f3376d26c31f28cea1cf1a1fffeee Mon Sep 17 00:00:00 2001 From: mightymax Date: Sat, 13 Jan 2007 13:43:07 +0000 Subject: [PATCH] framebuffer mode now also works from LCD memory --- desmume/src/GPU.c | 17 +++++++++++------ desmume/src/GPU.h | 26 ++++++++++++-------------- desmume/src/MMU.c | 3 +++ 3 files changed, 26 insertions(+), 20 deletions(-) diff --git a/desmume/src/GPU.c b/desmume/src/GPU.c index 432355fa7..5074ad65e 100644 --- a/desmume/src/GPU.c +++ b/desmume/src/GPU.c @@ -105,6 +105,11 @@ void GPU_Reset(GPU *g, u8 l) g->BGSize[0][1] = g->BGSize[1][1] = g->BGSize[2][1] = g->BGSize[3][1] = 256; g->dispOBJ = g->dispBG[0] = g->dispBG[1] = g->dispBG[2] = g->dispBG[3] = TRUE; + MMU.vram_mode[0] = 4 ; + MMU.vram_mode[1] = 5 ; + MMU.vram_mode[2] = 6 ; + MMU.vram_mode[3] = 7 ; + g->spriteRender = sprite1D; if(g->core == GPU_SUB) @@ -1210,7 +1215,7 @@ INLINE void extRotBG2(GPU * gpu, u8 num, u8 * DST, u16 H, s32 X, s32 Y, s16 PA, y1 = (mapinfo & 0x800) ? 7 - (auxY&7) : (auxY&7); coul = tile[(mapinfo&0x3FF)*64 + x1 + (y1<<3)]; if(coul) - renderline_setFinalColor(gpu,0,num,dst, T1ReadWord(pal, (coul + (mapinfo>>12)*0x100) << 1),x,Y); + renderline_setFinalColor(gpu,0,num,dst, T1ReadWord(pal, (coul + (mapinfo>>12)*0x100) << 1),i,Y); }) } @@ -1223,7 +1228,7 @@ INLINE void extRotBG2(GPU * gpu, u8 num, u8 * DST, u16 H, s32 X, s32 Y, s16 PA, { mapinfo = map[auxX + auxY * lg]; if(mapinfo) - renderline_setFinalColor(gpu,0,num,dst, T1ReadWord(pal, mapinfo << 1),x,Y); + renderline_setFinalColor(gpu,0,num,dst, T1ReadWord(pal, mapinfo << 1),i,Y); }) } return; @@ -1234,7 +1239,7 @@ INLINE void extRotBG2(GPU * gpu, u8 num, u8 * DST, u16 H, s32 X, s32 Y, s16 PA, { mapinfo = T1ReadWord(map, (auxX + auxY * lg) << 1); if ((mapinfo) && (mapinfo & 0x8000)) - renderline_setFinalColor(gpu,0,num,dst, mapinfo,x,Y); + renderline_setFinalColor(gpu,0,num,dst, mapinfo,i,Y); }) } return; @@ -1298,19 +1303,19 @@ void extRotBG(GPU * gpu, u8 num, u8 * DST) #define RENDERS_A(a) \ if((a)&&(prioTab[sprX]>=prio)) \ { \ - renderline_setFinalColor(gpu, sprX << 1,4,dst, c,sprX,l); \ + renderline_setFinalColor(gpu, sprX << 1,4,dst, c,i,l); \ prioTab[sprX] = prio; \ } #define RENDERS_B(c) \ if((c)&&(prioTab[sprX]>=prio)) \ { \ - renderline_setFinalColor(gpu, sprX << 1,4,dst, T1ReadWord(pal, (c) << 1),sprX,l); \ + renderline_setFinalColor(gpu, sprX << 1,4,dst, T1ReadWord(pal, (c) << 1),i,l); \ prioTab[sprX] = prio; \ } #define RENDERS_C(c,d) \ if((c)&&(prioTab[sprX]>=prio)) \ { \ - renderline_setFinalColor(gpu, (sprX d) << 1,4,dst, T1ReadWord(pal, ((c)+(spriteInfo->PaletteIndex<<4)) << 1),(sprX d),l); \ + renderline_setFinalColor(gpu, (sprX d) << 1,4,dst, T1ReadWord(pal, ((c)+(spriteInfo->PaletteIndex<<4)) << 1),i,l); \ prioTab[sprX d] = prio; \ } diff --git a/desmume/src/GPU.h b/desmume/src/GPU.h index e0f6a87b2..998b7f10d 100644 --- a/desmume/src/GPU.h +++ b/desmume/src/GPU.h @@ -422,6 +422,7 @@ static INLINE void GPU_ligne(Screen * screen, u16 l) GPU * gpu = screen->gpu; u8 * dst = GPU_screen + (screen->offset + l) * 512; u8 * mdst = GPU_screen + (MainScreen.offset + l) * 512; + u8 * sdst = GPU_screen + (SubScreen.offset + l) * 512; itemsForPriority_t * item; u8 spr[512]; u8 sprPrio[256]; @@ -454,29 +455,26 @@ static INLINE void GPU_ligne(Screen * screen, u16 l) /* we only draw one of the VRAM blocks */ vram_bank = gpu->dispCnt.bits.VRAM_Block ; - if(!(MMU.vScreen&1)) dest = mdst; else dest = dst; - - switch (MMU.vram_mode[vram_bank]) - { - case 0: - case 1: - case 2: - case 3: +// if(!(gpu->lcd)) dest = mdst; else dest = sdst; + dest = dst ; { int ii = l * 256 * 2; for (i=0; i<(256 * 2); i+=2) { - u8 * vram = ARM9Mem.ARM9_ABG + MMU.vram_mode[vram_bank] * 0x20000; + u8 * vram ; + if (MMU.vram_mode[vram_bank] & 4) + { + vram = ARM9Mem.ARM9_LCD + (MMU.vram_mode[vram_bank] & 3) * 0x20000; + } else + { + vram = ARM9Mem.ARM9_ABG + MMU.vram_mode[vram_bank] * 0x20000; + } + T2WriteWord(dest, i, T1ReadWord(vram, ii)); ii+=2; } return; } - break; - - default: - break; - } } return; case 3: diff --git a/desmume/src/MMU.c b/desmume/src/MMU.c index eb3f16980..ba056dc27 100644 --- a/desmume/src/MMU.c +++ b/desmume/src/MMU.c @@ -881,6 +881,9 @@ void FASTCALL MMU_write8(u32 proc, u32 adr, u8 val) MMU.vram_mode[adr-REG_VRAMCNTA] = 3; // BG-VRAM //MMU.vram_offset[0] = ARM9Mem.ARM9_ABG+(0x20000*3); // BG-VRAM break; + case 0: /* mapped to lcd */ + MMU.vram_mode[adr-REG_VRAMCNTA] = 4 | (adr-REG_VRAMCNTA) ; + break ; } MMU_VRAMReloadFromLCD(adr-REG_VRAMCNTA,val) ; }