From 99e23f239ce6df7744782d66d20a1d6c62d3f2c3 Mon Sep 17 00:00:00 2001 From: dborth Date: Wed, 17 Jun 2009 07:47:22 +0000 Subject: [PATCH] only update battery images when required, GB mono changes --- source/ngc/menu.cpp | 55 +++++++++++++++++++++++++++------------ source/ngc/vba.cpp | 2 +- source/ngc/vbasupport.cpp | 10 ++++++- source/ngc/vbasupport.h | 1 + source/vba/gb/gbMono.cpp | 1 + 5 files changed, 50 insertions(+), 19 deletions(-) diff --git a/source/ngc/menu.cpp b/source/ngc/menu.cpp index a425b2b..92c2d01 100644 --- a/source/ngc/menu.cpp +++ b/source/ngc/menu.cpp @@ -1165,8 +1165,12 @@ static int MenuGame() closeBtn.SetEffectGrow(); #ifdef HW_RVL - int i, level; + int i; char txt[3]; + bool status[4] = { false, false, false, false }; + int level[4] = { 0, 0, 0, 0 }; + bool newStatus; + int newLevel; GuiText * batteryTxt[4]; GuiImage * batteryImg[4]; GuiImage * batteryBarImg[4]; @@ -1274,24 +1278,38 @@ static int MenuGame() #ifdef HW_RVL for(i=0; i < 4; i++) { - if(WPAD_Probe(i, NULL) == WPAD_ERR_NONE) // controller connected + if(WPAD_Probe(i, NULL) == WPAD_ERR_NONE) { - level = (userInput[i].wpad.battery_level / 100.0) * 4; - if(level > 4) level = 4; - batteryBarImg[i]->SetTile(level); - - if(level == 0) - batteryImg[i]->SetImage(&batteryRed); - else - batteryImg[i]->SetImage(&battery); - - batteryBtn[i]->SetAlpha(255); + newStatus = true; + newLevel = (userInput[i].wpad.battery_level / 100.0) * 4; + if(newLevel > 4) newLevel = 4; } - else // controller not connected + else { - batteryBarImg[i]->SetTile(0); - batteryImg[i]->SetImage(&battery); - batteryBtn[i]->SetAlpha(150); + newStatus = false; + newLevel = 0; + } + + if(status[i] != newStatus || level[i] != newLevel) + { + if(newStatus == true) // controller connected + { + batteryBtn[i]->SetAlpha(255); + batteryBarImg[i]->SetTile(newLevel); + + if(newLevel == 0) + batteryImg[i]->SetImage(&batteryRed); + else + batteryImg[i]->SetImage(&battery); + } + else // controller not connected + { + batteryBtn[i]->SetAlpha(150); + batteryBarImg[i]->SetTile(0); + batteryImg[i]->SetImage(&battery); + } + status[i] = newStatus; + level[i] = newLevel; } } #endif @@ -2658,6 +2676,9 @@ static int MenuSettingsVideo() sprintf(options.name[i++], "GB Palette"); options.length = i; + if(!IsGameboyGame()) + options.name[6][0] = 0; // disable palette option for GBA/GBC + GuiText titleTxt("Game Settings - Video", 28, (GXColor){255, 255, 255, 255}); titleTxt.SetAlignment(ALIGN_LEFT, ALIGN_TOP); titleTxt.SetPosition(50,50); @@ -2743,7 +2764,7 @@ static int MenuSettingsVideo() else sprintf (options.value[5], "Off"); - if(strcmp(CurrentPalette.gameName,"default")) + if(strcmp(CurrentPalette.gameName, "default")) sprintf(options.value[6], "Custom"); else sprintf(options.value[6], "Default"); diff --git a/source/ngc/vba.cpp b/source/ngc/vba.cpp index 451be9d..770edad 100644 --- a/source/ngc/vba.cpp +++ b/source/ngc/vba.cpp @@ -291,7 +291,7 @@ int main(int argc, char *argv[]) ResetVideo_Emu(); // GB colorizing - set palette - if(cartridgeType == 1) + if(IsGameboyGame()) { if(GCSettings.colorize && strcmp(RomTitle, "MEGAMAN") != 0) gbSetPalette(CurrentPalette.palette); diff --git a/source/ngc/vbasupport.cpp b/source/ngc/vbasupport.cpp index c150881..8e3133b 100644 --- a/source/ngc/vbasupport.cpp +++ b/source/ngc/vbasupport.cpp @@ -719,7 +719,7 @@ void systemDrawScreen() GX_Render( srcWidth, srcHeight, pix, srcPitch ); } -bool ValidGameId(u32 id) +static bool ValidGameId(u32 id) { if (id == 0) return false; @@ -733,6 +733,14 @@ bool ValidGameId(u32 id) return true; } +bool IsGameboyGame() +{ + if(cartridgeType == 1 && !gbCgbMode && !gbSgbMode) + return true; + else + return false; +} + static void gbApplyPerImagePreferences() { // Only works for some GB Colour roms diff --git a/source/ngc/vbasupport.h b/source/ngc/vbasupport.h index ee27e97..b41ccb4 100644 --- a/source/ngc/vbasupport.h +++ b/source/ngc/vbasupport.h @@ -22,6 +22,7 @@ extern char RomTitle[]; bool LoadVBAROM(int method); void InitialisePalette(); +bool IsGameboyGame(); bool LoadBatteryOrState(char * filepath, int method, int action, bool silent); bool LoadBatteryOrStateAuto(int method, int action, bool silent); bool SaveBatteryOrState(char * filepath, int method, int action, bool silent); diff --git a/source/vba/gb/gbMono.cpp b/source/vba/gb/gbMono.cpp index eb05915..985383f 100644 --- a/source/vba/gb/gbMono.cpp +++ b/source/vba/gb/gbMono.cpp @@ -453,6 +453,7 @@ bool StartColorizing() { } void StopColorizing() { + if(!ColorizeGameboy || gbSgbMode || gbCgbMode) return; for(int i = 0; i < 12; i++) gbPalette[i] = systemGbPalette[gbPaletteOption*12+i]; ColorizeGameboy = false;