From e82af37a36b9c97f37c05ec12fb02284a9d3b5ed Mon Sep 17 00:00:00 2001 From: yabause Date: Tue, 27 Jun 2006 09:28:02 +0000 Subject: [PATCH] Changed #include dependencies again. Fixed a bug in GPU (xfin could be greater than LG causing a segfault). Moved GPUs from NDS to global. --- desmume/src/GPU.c | 20 ++++++++++++++++++-- desmume/src/GPU.h | 11 +++++++++++ desmume/src/armcpu.h | 2 +- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/desmume/src/GPU.c b/desmume/src/GPU.c index fe81338ed..2abf0db01 100644 --- a/desmume/src/GPU.c +++ b/desmume/src/GPU.c @@ -28,6 +28,8 @@ #include "nds/video.h" extern BOOL click; +Screen MainScreen; +Screen SubScreen; //#define DEBUG_TRI @@ -124,14 +126,14 @@ GPU * GPUInit(u8 l) memset(g, 0, sizeof(GPU)); g->lcd = l; - g->core = l; + g->core = l; g->BGSize[0][0] = g->BGSize[1][0] = g->BGSize[2][0] = g->BGSize[3][0] = 256; g->BGSize[0][1] = g->BGSize[1][1] = g->BGSize[2][1] = g->BGSize[3][1] = 256; g->dispBG[0] = g->dispBG[1] = g->dispBG[2] = g->dispBG[3] = TRUE; g->spriteRender = sprite1D; - if(g->core == GPU_SUB) + if(g->core == GPU_SUB) { g->oam = (OAM *)(ARM9.ARM9_OAM + 0x400); g->sprMem = ARM9.ARM9_BOBJ; @@ -660,6 +662,8 @@ INLINE void textBG2(GPU * gpu, u8 num, u16 * DST, u16 X, u16 Y, u16 LG) mapinfo += 32*32; u8 * ligne = (u8 * )tile + (((*mapinfo)&0x3FF)*0x20) + (((*mapinfo)& 0x800 ? (7*4)-yoff : yoff)); u16 xfin = x + (8 - (xoff&7)); + if (xfin > LG) + xfin = LG; if((*mapinfo)& 0x400) { @@ -711,6 +715,8 @@ INLINE void textBG2(GPU * gpu, u8 num, u16 * DST, u16 X, u16 Y, u16 LG) mapinfo += 32*32; u8 * ligne = (u8 * )tile + (((*mapinfo)&0x3FF)*0x40) + (((*mapinfo)& 0x800 ? (7*8)-yoff : yoff)); u16 xfin = x + (8 - (xoff&7)); + if (xfin > LG) + xfin = LG; if((*mapinfo)& 0x400) { @@ -1460,3 +1466,13 @@ void sprite2D(GPU * gpu, u16 l, u16 * dst, u8 * prioTab) } } } + +void ScreenInit(void) { + MainScreen.gpu = GPUInit(0); + SubScreen.gpu = GPUInit(1); +} + +void ScreenDeInit(void) { + GPUDeInit(MainScreen.gpu); + GPUDeInit(SubScreen.gpu); +} diff --git a/desmume/src/GPU.h b/desmume/src/GPU.h index 361f981c8..3fbbc0884 100644 --- a/desmume/src/GPU.h +++ b/desmume/src/GPU.h @@ -105,6 +105,17 @@ extern size sprSizeTab[4][4]; extern s8 mode2type[8][4]; extern void (*modeRender[8][4])(GPU * gpu, u8 num, u16 l, u16 * DST); +typedef struct { + GPU * gpu; + u16 offset; +} Screen; + +extern Screen MainScreen; +extern Screen SubScreen; + +void ScreenInit(void); +void ScreenDeInit(void); + INLINE void GPU_ligne(GPU * gpu, u16 * buffer, u16 l) { u16 * dst = buffer + l*256; diff --git a/desmume/src/armcpu.h b/desmume/src/armcpu.h index 66a43c429..52d692946 100644 --- a/desmume/src/armcpu.h +++ b/desmume/src/armcpu.h @@ -22,7 +22,7 @@ #ifndef ARM_CPU #define ARM_CPU -#include "MMU.hpp" +#include "types.h" #include "bits.h"