From 36a1ce556beb972a6bb8827906b33b145c817e30 Mon Sep 17 00:00:00 2001 From: cyberwarriorx Date: Mon, 27 Nov 2006 20:11:20 +0000 Subject: [PATCH] -Rewrote the framebuffer code. Now it supports VRAM blocks A-D -Added support for Display Mode 0(Display Off) -Added the basic framework for Display Mode 3(Display from Main RAM) --- desmume/src/GPU.c | 27 ++++++++++++++++++++++++--- desmume/src/GPU.h | 42 ++++++++++++++++++++++++++++++------------ 2 files changed, 54 insertions(+), 15 deletions(-) diff --git a/desmume/src/GPU.c b/desmume/src/GPU.c index 498dfbf15..4ac57af66 100644 --- a/desmume/src/GPU.c +++ b/desmume/src/GPU.c @@ -2,6 +2,8 @@ yopyop156@ifrance.com yopyop156.ifrance.com + Copyright (C) 2006 Theo Berkau + This file is part of DeSmuME DeSmuME is free software; you can redistribute it and/or modify @@ -123,11 +125,30 @@ void GPU_DeInit(GPU * gpu) free(gpu); } -/* NOTICE: the name of function is unclear, but it's about writing in DISPLAY_CR */ +/* Sets up LCD control variables for Display Engines A and B for quick reading */ void GPU_setVideoProp(GPU * gpu, u32 p) { gpu->prop = p; - + + gpu->dispMode = p >> 16; + if (gpu->lcd == 0) + gpu->dispMode &= 0x3; + else + gpu->dispMode &= 0x1; + switch (gpu->dispMode) + { + case 0: // Display Off + return; + case 1: // Display BG and OBJ layers + break; + case 2: // Display framebuffer + gpu->vramBlock = (p >> 18) & 0x3; + return; + case 3: // Display from Main RAM + LOG("FIXME: Display Mode 3 not supported(Display from Main RAM)\n"); + return; + } + gpu->nbBGActif = 0; if(p & DISPLAY_SPR_1D_LAYOUT) { @@ -1127,7 +1148,7 @@ void sprite2D(GPU * gpu, u16 l, u8 * dst, u8 * prioTab) size sprSize = sprSizeTab[(aux->attr1>>14)][(aux->attr0>>14)]; u32 lg = sprSize.x; - + if(sprY>192) sprY = (s32)((s8)(aux->attr0 & 0xFF)); diff --git a/desmume/src/GPU.h b/desmume/src/GPU.h index bca2ee99b..861a8ee73 100644 --- a/desmume/src/GPU.h +++ b/desmume/src/GPU.h @@ -2,6 +2,8 @@ yopyop156@ifrance.com yopyop156.ifrance.com + Copyright (C) 2006 Theo Berkau + This file is part of DeSmuME DeSmuME is free software; you can redistribute it and/or modify @@ -80,7 +82,10 @@ struct _GPU u8 lcd; u8 core; - + + u8 dispMode; + u8 vramBlock; + u8 nbBGActif; u8 BGIndex[4]; u8 ordre[4]; @@ -137,20 +142,33 @@ static INLINE void GPU_ligne(Screen * screen, u16 l) u8 i8; u16 i16; - /* FIXME I've just quickly added mic's framebuffer patch here. - * I'm really not sure it's correct. - */ - if (gpu->lcd == 0) { - u32 mainlcdcnt = T1ReadLong(ARM9Mem.ARM9_REG, 0); - int ii = l * 256; - - if ((mainlcdcnt & 0x10000) == 0) { - for (i=0; i<256; i++) { - T2WriteWord(dst, i << 1, T1ReadWord(ARM9Mem.ARM9_LCD, ii << 1)); - ii++; + // This could almost be changed to use function pointers + switch (gpu->dispMode) + { + case 1: // Display BG and OBJ layers + break; + case 0: // Display Off(Display white) + { + for (i=0; i<256; i++) + { + T2WriteWord(dst, i << 1, 0x7FFF); } return; } + case 2: // Display framebuffer + { + int ii = l * 256 * 2; + for (i=0; i<(256 * 2); i+=2) + { + u8 * vram = ARM9Mem.ARM9_LCD + (gpu->vramBlock * 0x20000); + + T2WriteWord(dst, i, T1ReadWord(vram, ii)); + ii+=2; + } + return; + } + case 3: // Display from Main RAM(FIX ME) + return; } u32 c = T1ReadWord(ARM9Mem.ARM9_VMEM, gpu->lcd * 0x400);