From 6b49906cf591dea2bc6330bc46eade85c813dfe2 Mon Sep 17 00:00:00 2001 From: mtabachenko Date: Thu, 18 Dec 2008 13:16:21 +0000 Subject: [PATCH] core: - fixed Master Brightness (this is fix games with black screens ex. "Pirates of the Caribbean At Worlds End"); --- desmume/ChangeLog | 5 ++++- desmume/src/GPU.cpp | 9 ++++----- desmume/src/MMU.cpp | 15 +++++++++++++++ 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/desmume/ChangeLog b/desmume/ChangeLog index 01130caac..5fc72ea33 100644 --- a/desmume/ChangeLog +++ b/desmume/ChangeLog @@ -7,7 +7,10 @@ - Added transparency and fixed material alpha support and alpha testing on the 3D core [shash] - Changed how depth initial values are calculated (fixes SM64DS skybox) [shash] - Added SSE2 version for some matrix routines [CrazyMax] - - Some fixes in core (New SMB don't freeze now) [CrazyMax] + - Fixes in IPC FIFO [CrazyMax] + - Add Geometry FIFO simulation (New SMB and others games not freeze now) [CrazyMax] + - Fix in capture display (many games with both 3D screen not blinking now) [CrazyMax] + - Fix in master brightness (this is fix games with black screens) [CrazyMax] - Some optimizations in code [CrazyMax] - Make matrix 4x4 multiply routines use W-coordinate. [zeromus] - Add many matrix and vector functions to matrix.cpp [zeromus] diff --git a/desmume/src/GPU.cpp b/desmume/src/GPU.cpp index 27ee8395d..586a1242b 100644 --- a/desmume/src/GPU.cpp +++ b/desmume/src/GPU.cpp @@ -277,9 +277,7 @@ static void GPU_resortBGs(GPU *gpu) void GPU_setMasterBrightness (GPU *gpu, u16 val) { - u8 temp = (val&31); - - gpu->MasterBrightFactor = (temp > 16 ? 16 : temp); + gpu->MasterBrightFactor = (val & 0x1F); gpu->MasterBrightMode = (val>>14); } @@ -2244,11 +2242,12 @@ static INLINE void GPU_ligne_DispCapture(u16 l) } } -static INLINE void GPU_ligne_Brightness(NDS_Screen * screen, u16 l) +static INLINE void GPU_ligne_MasterBrightness(NDS_Screen * screen, u16 l) { GPU * gpu = screen->gpu; u8 * dst = GPU_screen + (screen->offset + l) * 512; u16 i16; + if (!gpu->MasterBrightFactor) return; #ifndef HAVE_LIBGDKGLEXT_X11_1_0 // damdoum : // brightness done with opengl @@ -2412,7 +2411,7 @@ void GPU_ligne(NDS_Screen * screen, u16 l) if (gpu->core == GPU_MAIN) GPU_ligne_DispCapture(l); - GPU_ligne_Brightness(screen, l); + GPU_ligne_MasterBrightness(screen, l); } void gpu_savestate(std::ostream* os) diff --git a/desmume/src/MMU.cpp b/desmume/src/MMU.cpp index 8c62b8db9..85fa113f7 100644 --- a/desmume/src/MMU.cpp +++ b/desmume/src/MMU.cpp @@ -1670,6 +1670,14 @@ static void FASTCALL _MMU_ARM9_write16(u32 adr, u16 val) case REG_POWCNT1 : { +// TODO: make this later +#if 0 + u8 _LCD = (val) & 0x01; + u8 _2DEngineA = (val>>1) & 0x01; + u8 _2DEngineB = (val>>9) & 0x01; + u8 _3DRender = (val>>2) & 0x01; + u8 _3DGeometry = (val>>3) & 0x01; +#endif if(val & (1<<15)) { LOG("Main core on top\n"); @@ -2187,6 +2195,13 @@ static void FASTCALL _MMU_ARM9_write32(u32 adr, u32 val) break; } + case REG_DISPA_MASTERBRIGHT: + GPU_setMasterBrightness(MainScreen.gpu, val & 0xFFFF); + break; + case REG_DISPB_MASTERBRIGHT: + GPU_setMasterBrightness(SubScreen.gpu, val & 0xFFFF); + break; + case REG_DISPA_BLDCNT: { GPU_setBLDCNT (MainScreen.gpu,val&0xffff);