mirror of
https://github.com/dborth/vbagx.git
synced 2025-02-06 14:03:22 +01:00
partial cleanup of palette saving/loading disaster code
This commit is contained in:
parent
6e583296f9
commit
a8eb751e40
@ -45,12 +45,6 @@
|
|||||||
GuiImageData * pointer[4];
|
GuiImageData * pointer[4];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int MenuPalette();
|
|
||||||
void gbSetPalette(u32 RRGGBB[]);
|
|
||||||
void StopColorizing();
|
|
||||||
extern char RomTitle[17];
|
|
||||||
|
|
||||||
|
|
||||||
static GuiButton * btnLogo = NULL;
|
static GuiButton * btnLogo = NULL;
|
||||||
static GuiImage * gameScreenImg = NULL;
|
static GuiImage * gameScreenImg = NULL;
|
||||||
static GuiImage * bgImg = NULL;
|
static GuiImage * bgImg = NULL;
|
||||||
@ -1856,10 +1850,6 @@ static int MenuGameSettings()
|
|||||||
{
|
{
|
||||||
menu = MENU_GAMESETTINGS_VIDEO;
|
menu = MENU_GAMESETTINGS_VIDEO;
|
||||||
}
|
}
|
||||||
/*else if(cheatsBtn.GetState() == STATE_CLICKED)
|
|
||||||
{
|
|
||||||
menu = MENU_GAMESETTINGS_PALETTE;
|
|
||||||
}*/
|
|
||||||
else if(wiiControlsBtn.GetState() == STATE_CLICKED)
|
else if(wiiControlsBtn.GetState() == STATE_CLICKED)
|
||||||
{
|
{
|
||||||
GCSettings.WiiControls ^= 1;
|
GCSettings.WiiControls ^= 1;
|
||||||
@ -2663,7 +2653,7 @@ static int MenuSettingsVideo()
|
|||||||
sprintf(options.name[i++], "Screen Position");
|
sprintf(options.name[i++], "Screen Position");
|
||||||
sprintf(options.name[i++], "Video Mode");
|
sprintf(options.name[i++], "Video Mode");
|
||||||
sprintf(options.name[i++], "Colorize Mono GB");
|
sprintf(options.name[i++], "Colorize Mono GB");
|
||||||
sprintf(options.name[i++], "Choose Palette");
|
sprintf(options.name[i++], "GB Palette");
|
||||||
options.length = i;
|
options.length = i;
|
||||||
|
|
||||||
GuiText titleTxt("Game Settings - Video", 28, (GXColor){255, 255, 255, 255});
|
GuiText titleTxt("Game Settings - Video", 28, (GXColor){255, 255, 255, 255});
|
||||||
@ -2750,7 +2740,11 @@ static int MenuSettingsVideo()
|
|||||||
sprintf (options.value[5], "On");
|
sprintf (options.value[5], "On");
|
||||||
else
|
else
|
||||||
sprintf (options.value[5], "Off");
|
sprintf (options.value[5], "Off");
|
||||||
sprintf(options.value[6], "click here");
|
|
||||||
|
if(true) // TODO - show custom if different from the default palette
|
||||||
|
sprintf(options.value[6], "Custom");
|
||||||
|
else
|
||||||
|
sprintf(options.value[6], "Default");
|
||||||
|
|
||||||
ret = optionBrowser.GetClickedOption();
|
ret = optionBrowser.GetClickedOption();
|
||||||
|
|
||||||
@ -2788,11 +2782,7 @@ static int MenuSettingsVideo()
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 5:
|
case 5:
|
||||||
if (GCSettings.colorize) GCSettings.colorize = 0;
|
GCSettings.colorize ^= 1;
|
||||||
else GCSettings.colorize = 1;
|
|
||||||
if (strcmp(RomTitle, "MEGAMAN")==0) StopColorizing();
|
|
||||||
else if (GCSettings.colorize) LoadPalette(RomTitle);
|
|
||||||
else StopColorizing();
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 6:
|
case 6:
|
||||||
@ -3420,178 +3410,6 @@ static int MenuSettingsNetwork()
|
|||||||
return menu;
|
return menu;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* MainMenu
|
|
||||||
***************************************************************************/
|
|
||||||
void
|
|
||||||
MainMenu (int menu)
|
|
||||||
{
|
|
||||||
int currentMenu = menu;
|
|
||||||
lastMenu = MENU_NONE;
|
|
||||||
|
|
||||||
mainWindow = new GuiWindow(screenwidth, screenheight);
|
|
||||||
|
|
||||||
bgImg = new GuiImage(screenwidth, screenheight, (GXColor){236, 226, 238, 255});
|
|
||||||
bgImg->ColorStripe(10);
|
|
||||||
mainWindow->Append(bgImg);
|
|
||||||
|
|
||||||
if(gameScreenTex)
|
|
||||||
{
|
|
||||||
gameScreenImg = new GuiImage(gameScreenTex, screenwidth, screenheight);
|
|
||||||
gameScreenImg->SetAlpha(192);
|
|
||||||
gameScreenImg->ColorStripe(30);
|
|
||||||
mainWindow->Append(gameScreenImg);
|
|
||||||
bgImg->SetVisible(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
GuiTrigger trigA;
|
|
||||||
if(GCSettings.WiimoteOrientation)
|
|
||||||
trigA.SetSimpleTrigger(-1, WPAD_BUTTON_2 | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
|
|
||||||
else
|
|
||||||
trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
|
|
||||||
|
|
||||||
GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM);
|
|
||||||
GuiSound btnSoundClick(button_click_pcm, button_click_pcm_size, SOUND_PCM);
|
|
||||||
GuiImageData bgTop(bg_top_png);
|
|
||||||
bgTopImg = new GuiImage(&bgTop);
|
|
||||||
GuiImageData bgBottom(bg_bottom_png);
|
|
||||||
bgBottomImg = new GuiImage(&bgBottom);
|
|
||||||
bgBottomImg->SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM);
|
|
||||||
GuiImageData logo(logo_png);
|
|
||||||
GuiImage logoImg(&logo);
|
|
||||||
GuiImageData logoOver(logo_over_png);
|
|
||||||
GuiImage logoImgOver(&logoOver);
|
|
||||||
GuiText logoTxt(APPVERSION, 18, (GXColor){255, 255, 255, 255});
|
|
||||||
logoTxt.SetAlignment(ALIGN_RIGHT, ALIGN_TOP);
|
|
||||||
logoTxt.SetPosition(0, 4);
|
|
||||||
btnLogo = new GuiButton(logoImg.GetWidth(), logoImg.GetHeight());
|
|
||||||
btnLogo->SetAlignment(ALIGN_RIGHT, ALIGN_TOP);
|
|
||||||
btnLogo->SetPosition(-50, 24);
|
|
||||||
btnLogo->SetImage(&logoImg);
|
|
||||||
btnLogo->SetImageOver(&logoImgOver);
|
|
||||||
btnLogo->SetLabel(&logoTxt);
|
|
||||||
btnLogo->SetSoundOver(&btnSoundOver);
|
|
||||||
btnLogo->SetSoundClick(&btnSoundClick);
|
|
||||||
btnLogo->SetTrigger(&trigA);
|
|
||||||
btnLogo->SetUpdateCallback(WindowCredits);
|
|
||||||
|
|
||||||
mainWindow->Append(bgTopImg);
|
|
||||||
mainWindow->Append(bgBottomImg);
|
|
||||||
mainWindow->Append(btnLogo);
|
|
||||||
|
|
||||||
if(currentMenu == MENU_GAMESELECTION)
|
|
||||||
ResumeGui();
|
|
||||||
|
|
||||||
// Load preferences
|
|
||||||
if(!LoadPrefs())
|
|
||||||
SavePrefs(SILENT);
|
|
||||||
|
|
||||||
#ifndef NO_SOUND
|
|
||||||
bgMusic = new GuiSound(bg_music_ogg, bg_music_ogg_size, SOUND_OGG);
|
|
||||||
bgMusic->SetVolume(GCSettings.MusicVolume);
|
|
||||||
bgMusic->SetLoop(true);
|
|
||||||
enterSound = new GuiSound(enter_ogg, enter_ogg_size, SOUND_OGG);
|
|
||||||
enterSound->SetVolume(GCSettings.SFXVolume);
|
|
||||||
exitSound = new GuiSound(exit_ogg, exit_ogg_size, SOUND_OGG);
|
|
||||||
exitSound->SetVolume(GCSettings.SFXVolume);
|
|
||||||
if(currentMenu == MENU_GAMESELECTION) bgMusic->Play(); // startup music
|
|
||||||
#endif
|
|
||||||
|
|
||||||
while(currentMenu != MENU_EXIT || !ROMLoaded)
|
|
||||||
{
|
|
||||||
switch (currentMenu)
|
|
||||||
{
|
|
||||||
case MENU_GAMESELECTION:
|
|
||||||
currentMenu = MenuGameSelection();
|
|
||||||
break;
|
|
||||||
case MENU_GAME:
|
|
||||||
currentMenu = MenuGame();
|
|
||||||
break;
|
|
||||||
case MENU_GAME_LOAD:
|
|
||||||
currentMenu = MenuGameSaves(0);
|
|
||||||
break;
|
|
||||||
case MENU_GAME_SAVE:
|
|
||||||
currentMenu = MenuGameSaves(1);
|
|
||||||
break;
|
|
||||||
case MENU_GAMESETTINGS:
|
|
||||||
currentMenu = MenuGameSettings();
|
|
||||||
break;
|
|
||||||
case MENU_GAMESETTINGS_MAPPINGS:
|
|
||||||
currentMenu = MenuSettingsMappings();
|
|
||||||
break;
|
|
||||||
case MENU_GAMESETTINGS_MAPPINGS_MAP:
|
|
||||||
currentMenu = MenuSettingsMappingsMap();
|
|
||||||
break;
|
|
||||||
case MENU_GAMESETTINGS_VIDEO:
|
|
||||||
currentMenu = MenuSettingsVideo();
|
|
||||||
break;
|
|
||||||
/*case MENU_GAMESETTINGS_CHEATS:
|
|
||||||
currentMenu = MenuGameCheats();
|
|
||||||
break;*/
|
|
||||||
case MENU_GAMESETTINGS_PALETTE:
|
|
||||||
currentMenu = MenuPalette();
|
|
||||||
break;
|
|
||||||
case MENU_SETTINGS:
|
|
||||||
currentMenu = MenuSettings();
|
|
||||||
break;
|
|
||||||
case MENU_SETTINGS_FILE:
|
|
||||||
currentMenu = MenuSettingsFile();
|
|
||||||
break;
|
|
||||||
case MENU_SETTINGS_MENU:
|
|
||||||
currentMenu = MenuSettingsMenu();
|
|
||||||
break;
|
|
||||||
case MENU_SETTINGS_NETWORK:
|
|
||||||
currentMenu = MenuSettingsNetwork();
|
|
||||||
break;
|
|
||||||
default: // unrecognized menu
|
|
||||||
currentMenu = MenuGameSelection();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
lastMenu = currentMenu;
|
|
||||||
usleep(THREAD_SLEEP);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef HW_RVL
|
|
||||||
ShutoffRumble();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// wait for keys to be depressed
|
|
||||||
while(MenuRequested())
|
|
||||||
usleep(THREAD_SLEEP);
|
|
||||||
|
|
||||||
CancelAction();
|
|
||||||
HaltGui();
|
|
||||||
|
|
||||||
#ifndef NO_SOUND
|
|
||||||
delete bgMusic;
|
|
||||||
delete enterSound;
|
|
||||||
delete exitSound;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
delete btnLogo;
|
|
||||||
delete bgImg;
|
|
||||||
delete bgTopImg;
|
|
||||||
delete bgBottomImg;
|
|
||||||
delete mainWindow;
|
|
||||||
|
|
||||||
mainWindow = NULL;
|
|
||||||
|
|
||||||
if(gameScreenImg)
|
|
||||||
{
|
|
||||||
delete gameScreenImg;
|
|
||||||
gameScreenImg = NULL;
|
|
||||||
}
|
|
||||||
if(gameScreenTex)
|
|
||||||
{
|
|
||||||
free(gameScreenTex);
|
|
||||||
gameScreenTex = NULL;
|
|
||||||
}
|
|
||||||
if(gameScreenTex2)
|
|
||||||
{
|
|
||||||
free(gameScreenTex2);
|
|
||||||
gameScreenTex2 = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int redAmount=128, greenAmount=128, blueAmount=128;
|
static int redAmount=128, greenAmount=128, blueAmount=128;
|
||||||
static GuiText *redText;
|
static GuiText *redText;
|
||||||
@ -4096,7 +3914,7 @@ static int MenuPalette()
|
|||||||
|
|
||||||
while(menu == MENU_NONE)
|
while(menu == MENU_NONE)
|
||||||
{
|
{
|
||||||
VIDEO_WaitVSync ();
|
usleep(THREAD_SLEEP);
|
||||||
|
|
||||||
if(bg0Btn.GetState() == STATE_CLICKED)
|
if(bg0Btn.GetState() == STATE_CLICKED)
|
||||||
{
|
{
|
||||||
@ -4240,13 +4058,13 @@ static int MenuPalette()
|
|||||||
}
|
}
|
||||||
else if(importBtn.GetState() == STATE_CLICKED)
|
else if(importBtn.GetState() == STATE_CLICKED)
|
||||||
{
|
{
|
||||||
SavePalette(SILENT, RomTitle);
|
SavePalettes(SILENT);
|
||||||
menu = MENU_GAMESETTINGS_PALETTE;
|
menu = MENU_GAMESETTINGS_PALETTE;
|
||||||
}
|
}
|
||||||
else if(closeBtn.GetState() == STATE_CLICKED)
|
else if(closeBtn.GetState() == STATE_CLICKED)
|
||||||
{
|
{
|
||||||
menu = MENU_EXIT;
|
menu = MENU_EXIT;
|
||||||
SavePalette(SILENT, RomTitle);
|
SavePalettes(SILENT);
|
||||||
SavePrefs(NOTSILENT);
|
SavePrefs(NOTSILENT);
|
||||||
|
|
||||||
exitSound->Play();
|
exitSound->Play();
|
||||||
@ -4263,16 +4081,191 @@ static int MenuPalette()
|
|||||||
}
|
}
|
||||||
else if(backBtn.GetState() == STATE_CLICKED)
|
else if(backBtn.GetState() == STATE_CLICKED)
|
||||||
{
|
{
|
||||||
SavePalette(SILENT, RomTitle);
|
SavePalettes(SILENT);
|
||||||
menu = MENU_GAMESETTINGS_VIDEO;
|
menu = MENU_GAMESETTINGS_VIDEO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(menu == MENU_GAME)
|
if(menu == MENU_GAME)
|
||||||
SavePrefs(NOTSILENT);
|
SavePrefs(NOTSILENT);
|
||||||
gbSetPalette(CurrentPalette.palette);
|
|
||||||
|
|
||||||
HaltGui();
|
HaltGui();
|
||||||
mainWindow->Remove(&w);
|
mainWindow->Remove(&w);
|
||||||
return menu;
|
return menu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* MainMenu
|
||||||
|
***************************************************************************/
|
||||||
|
void
|
||||||
|
MainMenu (int menu)
|
||||||
|
{
|
||||||
|
int currentMenu = menu;
|
||||||
|
lastMenu = MENU_NONE;
|
||||||
|
|
||||||
|
mainWindow = new GuiWindow(screenwidth, screenheight);
|
||||||
|
|
||||||
|
bgImg = new GuiImage(screenwidth, screenheight, (GXColor){236, 226, 238, 255});
|
||||||
|
bgImg->ColorStripe(10);
|
||||||
|
mainWindow->Append(bgImg);
|
||||||
|
|
||||||
|
if(gameScreenTex)
|
||||||
|
{
|
||||||
|
gameScreenImg = new GuiImage(gameScreenTex, screenwidth, screenheight);
|
||||||
|
gameScreenImg->SetAlpha(192);
|
||||||
|
gameScreenImg->ColorStripe(30);
|
||||||
|
mainWindow->Append(gameScreenImg);
|
||||||
|
bgImg->SetVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
GuiTrigger trigA;
|
||||||
|
if(GCSettings.WiimoteOrientation)
|
||||||
|
trigA.SetSimpleTrigger(-1, WPAD_BUTTON_2 | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
|
||||||
|
else
|
||||||
|
trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
|
||||||
|
|
||||||
|
GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM);
|
||||||
|
GuiSound btnSoundClick(button_click_pcm, button_click_pcm_size, SOUND_PCM);
|
||||||
|
GuiImageData bgTop(bg_top_png);
|
||||||
|
bgTopImg = new GuiImage(&bgTop);
|
||||||
|
GuiImageData bgBottom(bg_bottom_png);
|
||||||
|
bgBottomImg = new GuiImage(&bgBottom);
|
||||||
|
bgBottomImg->SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM);
|
||||||
|
GuiImageData logo(logo_png);
|
||||||
|
GuiImage logoImg(&logo);
|
||||||
|
GuiImageData logoOver(logo_over_png);
|
||||||
|
GuiImage logoImgOver(&logoOver);
|
||||||
|
GuiText logoTxt(APPVERSION, 18, (GXColor){255, 255, 255, 255});
|
||||||
|
logoTxt.SetAlignment(ALIGN_RIGHT, ALIGN_TOP);
|
||||||
|
logoTxt.SetPosition(0, 4);
|
||||||
|
btnLogo = new GuiButton(logoImg.GetWidth(), logoImg.GetHeight());
|
||||||
|
btnLogo->SetAlignment(ALIGN_RIGHT, ALIGN_TOP);
|
||||||
|
btnLogo->SetPosition(-50, 24);
|
||||||
|
btnLogo->SetImage(&logoImg);
|
||||||
|
btnLogo->SetImageOver(&logoImgOver);
|
||||||
|
btnLogo->SetLabel(&logoTxt);
|
||||||
|
btnLogo->SetSoundOver(&btnSoundOver);
|
||||||
|
btnLogo->SetSoundClick(&btnSoundClick);
|
||||||
|
btnLogo->SetTrigger(&trigA);
|
||||||
|
btnLogo->SetUpdateCallback(WindowCredits);
|
||||||
|
|
||||||
|
mainWindow->Append(bgTopImg);
|
||||||
|
mainWindow->Append(bgBottomImg);
|
||||||
|
mainWindow->Append(btnLogo);
|
||||||
|
|
||||||
|
if(currentMenu == MENU_GAMESELECTION)
|
||||||
|
ResumeGui();
|
||||||
|
|
||||||
|
// Load preferences
|
||||||
|
if(!LoadPrefs())
|
||||||
|
SavePrefs(SILENT);
|
||||||
|
|
||||||
|
// Load palettes
|
||||||
|
LoadPalettes();
|
||||||
|
|
||||||
|
#ifndef NO_SOUND
|
||||||
|
bgMusic = new GuiSound(bg_music_ogg, bg_music_ogg_size, SOUND_OGG);
|
||||||
|
bgMusic->SetVolume(GCSettings.MusicVolume);
|
||||||
|
bgMusic->SetLoop(true);
|
||||||
|
enterSound = new GuiSound(enter_ogg, enter_ogg_size, SOUND_OGG);
|
||||||
|
enterSound->SetVolume(GCSettings.SFXVolume);
|
||||||
|
exitSound = new GuiSound(exit_ogg, exit_ogg_size, SOUND_OGG);
|
||||||
|
exitSound->SetVolume(GCSettings.SFXVolume);
|
||||||
|
if(currentMenu == MENU_GAMESELECTION) bgMusic->Play(); // startup music
|
||||||
|
#endif
|
||||||
|
|
||||||
|
while(currentMenu != MENU_EXIT || !ROMLoaded)
|
||||||
|
{
|
||||||
|
switch (currentMenu)
|
||||||
|
{
|
||||||
|
case MENU_GAMESELECTION:
|
||||||
|
currentMenu = MenuGameSelection();
|
||||||
|
break;
|
||||||
|
case MENU_GAME:
|
||||||
|
currentMenu = MenuGame();
|
||||||
|
break;
|
||||||
|
case MENU_GAME_LOAD:
|
||||||
|
currentMenu = MenuGameSaves(0);
|
||||||
|
break;
|
||||||
|
case MENU_GAME_SAVE:
|
||||||
|
currentMenu = MenuGameSaves(1);
|
||||||
|
break;
|
||||||
|
case MENU_GAMESETTINGS:
|
||||||
|
currentMenu = MenuGameSettings();
|
||||||
|
break;
|
||||||
|
case MENU_GAMESETTINGS_MAPPINGS:
|
||||||
|
currentMenu = MenuSettingsMappings();
|
||||||
|
break;
|
||||||
|
case MENU_GAMESETTINGS_MAPPINGS_MAP:
|
||||||
|
currentMenu = MenuSettingsMappingsMap();
|
||||||
|
break;
|
||||||
|
case MENU_GAMESETTINGS_VIDEO:
|
||||||
|
currentMenu = MenuSettingsVideo();
|
||||||
|
break;
|
||||||
|
/*case MENU_GAMESETTINGS_CHEATS:
|
||||||
|
currentMenu = MenuGameCheats();
|
||||||
|
break;*/
|
||||||
|
case MENU_GAMESETTINGS_PALETTE:
|
||||||
|
currentMenu = MenuPalette();
|
||||||
|
break;
|
||||||
|
case MENU_SETTINGS:
|
||||||
|
currentMenu = MenuSettings();
|
||||||
|
break;
|
||||||
|
case MENU_SETTINGS_FILE:
|
||||||
|
currentMenu = MenuSettingsFile();
|
||||||
|
break;
|
||||||
|
case MENU_SETTINGS_MENU:
|
||||||
|
currentMenu = MenuSettingsMenu();
|
||||||
|
break;
|
||||||
|
case MENU_SETTINGS_NETWORK:
|
||||||
|
currentMenu = MenuSettingsNetwork();
|
||||||
|
break;
|
||||||
|
default: // unrecognized menu
|
||||||
|
currentMenu = MenuGameSelection();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
lastMenu = currentMenu;
|
||||||
|
usleep(THREAD_SLEEP);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HW_RVL
|
||||||
|
ShutoffRumble();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// wait for keys to be depressed
|
||||||
|
while(MenuRequested())
|
||||||
|
usleep(THREAD_SLEEP);
|
||||||
|
|
||||||
|
CancelAction();
|
||||||
|
HaltGui();
|
||||||
|
|
||||||
|
#ifndef NO_SOUND
|
||||||
|
delete bgMusic;
|
||||||
|
delete enterSound;
|
||||||
|
delete exitSound;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
delete btnLogo;
|
||||||
|
delete bgImg;
|
||||||
|
delete bgTopImg;
|
||||||
|
delete bgBottomImg;
|
||||||
|
delete mainWindow;
|
||||||
|
|
||||||
|
mainWindow = NULL;
|
||||||
|
|
||||||
|
if(gameScreenImg)
|
||||||
|
{
|
||||||
|
delete gameScreenImg;
|
||||||
|
gameScreenImg = NULL;
|
||||||
|
}
|
||||||
|
if(gameScreenTex)
|
||||||
|
{
|
||||||
|
free(gameScreenTex);
|
||||||
|
gameScreenTex = NULL;
|
||||||
|
}
|
||||||
|
if(gameScreenTex2)
|
||||||
|
{
|
||||||
|
free(gameScreenTex2);
|
||||||
|
gameScreenTex2 = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -24,12 +24,9 @@
|
|||||||
#include "button_mapping.h"
|
#include "button_mapping.h"
|
||||||
#include "gamesettings.h"
|
#include "gamesettings.h"
|
||||||
|
|
||||||
static gamePalette *palettes;
|
static gamePalette *palettes = NULL;
|
||||||
static int loadedPalettes = 0;
|
static int loadedPalettes = 0;
|
||||||
|
|
||||||
void StopColorizing();
|
|
||||||
void gbSetPalette(u32 RRGGBB[]);
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Prepare Preferences Data
|
* Prepare Preferences Data
|
||||||
*
|
*
|
||||||
@ -483,69 +480,6 @@ decodePrefsData (int method)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
|
||||||
decodePalData (int method, const char *gameName)
|
|
||||||
{
|
|
||||||
bool result = false;
|
|
||||||
|
|
||||||
xml = mxmlLoadString(NULL, (char *)savebuffer, MXML_TEXT_CALLBACK);
|
|
||||||
|
|
||||||
if(xml)
|
|
||||||
{
|
|
||||||
// check settings version
|
|
||||||
// we don't do anything with the version #, but we'll store it anyway
|
|
||||||
item = mxmlFindElement(xml, xml, "palette", "version", NULL, MXML_DESCEND);
|
|
||||||
if(item) // a version entry exists
|
|
||||||
{
|
|
||||||
const char * version = mxmlElementGetAttr(item, "version");
|
|
||||||
|
|
||||||
if(version && strlen(version) == 5)
|
|
||||||
{
|
|
||||||
// this code assumes version in format X.X.X
|
|
||||||
// XX.X.X, X.XX.X, or X.X.XX will NOT work
|
|
||||||
int verMajor = version[0] - '0';
|
|
||||||
int verMinor = version[2] - '0';
|
|
||||||
int verPoint = version[4] - '0';
|
|
||||||
int curMajor = APPVERSION[0] - '0';
|
|
||||||
int curMinor = APPVERSION[2] - '0';
|
|
||||||
int curPoint = APPVERSION[4] - '0';
|
|
||||||
|
|
||||||
// first we'll check that the versioning is valid
|
|
||||||
if(!(verMajor >= 0 && verMajor <= 9 &&
|
|
||||||
verMinor >= 0 && verMinor <= 9 &&
|
|
||||||
verPoint >= 0 && verPoint <= 9))
|
|
||||||
result = false;
|
|
||||||
else if(verMajor < 2) // less than version 2.0.0
|
|
||||||
result = false; // reset settings (sorry, should update settings instead)
|
|
||||||
else if(verMajor > curMajor || verMinor > curMinor || verPoint > curPoint) // some future version
|
|
||||||
result = true; // don't reset settings!
|
|
||||||
else
|
|
||||||
result = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(result)
|
|
||||||
{
|
|
||||||
// load palette for this game
|
|
||||||
section = mxmlFindElement(xml, xml, "game", "name", gameName, MXML_DESCEND);
|
|
||||||
// if not found, load default palette
|
|
||||||
if (!section) section = mxmlFindElement(xml, xml, "game", "name", "default", MXML_DESCEND);
|
|
||||||
// we have either the XML default palette or the XML game palette
|
|
||||||
if (section) {
|
|
||||||
loadXMLPaletteFromSection(CurrentPalette);
|
|
||||||
// there is no palette for this game and no default in XML
|
|
||||||
} else {
|
|
||||||
// use the hardcoded default palette
|
|
||||||
CurrentPalette = gamePalettes[0];
|
|
||||||
}
|
|
||||||
if (CurrentPalette.use) gbSetPalette(CurrentPalette.palette);
|
|
||||||
else StopColorizing();
|
|
||||||
}
|
|
||||||
mxmlDelete(xml);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
decodePalsData (int method)
|
decodePalsData (int method)
|
||||||
{
|
{
|
||||||
@ -554,68 +488,31 @@ decodePalsData (int method)
|
|||||||
xml = mxmlLoadString(NULL, (char *) savebuffer, MXML_TEXT_CALLBACK);
|
xml = mxmlLoadString(NULL, (char *) savebuffer, MXML_TEXT_CALLBACK);
|
||||||
|
|
||||||
if (xml)
|
if (xml)
|
||||||
{
|
|
||||||
// check settings version
|
|
||||||
// we don't do anything with the version #, but we'll store it anyway
|
|
||||||
item = mxmlFindElement(xml, xml, "palette", "version", NULL, MXML_DESCEND);
|
|
||||||
if(item) // a version entry exists
|
|
||||||
{
|
|
||||||
const char * version = mxmlElementGetAttr(item, "version");
|
|
||||||
|
|
||||||
if(version && strlen(version) == 5)
|
|
||||||
{
|
|
||||||
// this code assumes version in format X.X.X
|
|
||||||
// XX.X.X, X.XX.X, or X.X.XX will NOT work
|
|
||||||
int verMajor = version[0] - '0';
|
|
||||||
int verMinor = version[2] - '0';
|
|
||||||
int verPoint = version[4] - '0';
|
|
||||||
int curMajor = APPVERSION[0] - '0';
|
|
||||||
int curMinor = APPVERSION[2] - '0';
|
|
||||||
int curPoint = APPVERSION[4] - '0';
|
|
||||||
|
|
||||||
// first we'll check that the versioning is valid
|
|
||||||
if(!(verMajor >= 0 && verMajor <= 9 &&
|
|
||||||
verMinor >= 0 && verMinor <= 9 &&
|
|
||||||
verPoint >= 0 && verPoint <= 9))
|
|
||||||
result = false;
|
|
||||||
else if(verMajor < 2) // less than version 2.0.0
|
|
||||||
result = false; // reset settings (sorry, should update settings instead)
|
|
||||||
else if(verMajor > curMajor || verMinor > curMinor || verPoint > curPoint) // some future version
|
|
||||||
result = true; // don't reset settings!
|
|
||||||
else
|
|
||||||
result = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(result)
|
|
||||||
{
|
{
|
||||||
// count number of palettes in file
|
// count number of palettes in file
|
||||||
loadedPalettes = 0;
|
loadedPalettes = 0;
|
||||||
item = mxmlFindElement(xml, xml, "palette", NULL, NULL, MXML_DESCEND);
|
item = mxmlFindElement(xml, xml, "palette", NULL, NULL, MXML_DESCEND);
|
||||||
for (section = mxmlFindElement(item, xml, "game", NULL, NULL, MXML_DESCEND);
|
for (section = mxmlFindElement(item, xml, "game", NULL, NULL,
|
||||||
section;
|
MXML_DESCEND); section; section = mxmlFindElement(section, xml,
|
||||||
section = mxmlFindElement(section, xml, "game", NULL, NULL, MXML_NO_DESCEND))
|
"game", NULL, NULL, MXML_NO_DESCEND))
|
||||||
{
|
{
|
||||||
loadedPalettes++;
|
loadedPalettes++;
|
||||||
}
|
}
|
||||||
// Allocate enough memory for all palettes in file, plus all hardcoded palettes,
|
// Allocate enough memory for all palettes in file, plus all hardcoded palettes,
|
||||||
// plus one new palette
|
// plus one new palette
|
||||||
if (palettes) {
|
if (palettes)
|
||||||
delete[] palettes;
|
free(palettes);
|
||||||
palettes = NULL;
|
|
||||||
}
|
palettes = (gamePalette *)malloc(sizeof(gamePalette)*loadedPalettes);
|
||||||
palettes = new gamePalette[loadedPalettes+1+gamePalettesCount];
|
|
||||||
// Load all palettes in file, hardcoded palettes are added later
|
// Load all palettes in file, hardcoded palettes are added later
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (section = mxmlFindElement(item, xml, "game", NULL, NULL, MXML_DESCEND);
|
for (section = mxmlFindElement(item, xml, "game", NULL, NULL,
|
||||||
section;
|
MXML_DESCEND); section; section = mxmlFindElement(section, xml,
|
||||||
section = mxmlFindElement(section, xml, "game", NULL, NULL, MXML_NO_DESCEND))
|
"game", NULL, NULL, MXML_NO_DESCEND))
|
||||||
{
|
{
|
||||||
loadXMLPaletteFromSection(palettes[i]);
|
loadXMLPaletteFromSection(palettes[i]);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
mxmlDelete(xml);
|
mxmlDelete(xml);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@ -674,123 +571,6 @@ SavePrefs (bool silent)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
|
||||||
CreateAndLoadPalette(bool silent, const char *gameName, bool load)
|
|
||||||
{
|
|
||||||
if (load) {
|
|
||||||
// Load palette from hardcoded palettes
|
|
||||||
int snum = -1;
|
|
||||||
for(int i=1; i < gamePalettesCount; i++) {
|
|
||||||
if(strcmp(gameName, gamePalettes[i].gameName)==0)
|
|
||||||
{
|
|
||||||
snum = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// match found!
|
|
||||||
if(snum >= 0)
|
|
||||||
{
|
|
||||||
CurrentPalette = gamePalettes[snum];
|
|
||||||
} else {
|
|
||||||
CurrentPalette = gamePalettes[0];
|
|
||||||
}
|
|
||||||
gbSetPalette(CurrentPalette.palette);
|
|
||||||
}
|
|
||||||
// Now create the XML palette file
|
|
||||||
char filepath[1024];
|
|
||||||
int datasize;
|
|
||||||
int offset = 0;
|
|
||||||
|
|
||||||
// We'll save using the first available method (probably SD) since this
|
|
||||||
// is the method preferences will be loaded from by default
|
|
||||||
int method = autoSaveMethod(silent);
|
|
||||||
|
|
||||||
if(method == METHOD_AUTO)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if(!MakeFilePath(filepath, FILE_PAL, method))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (!silent)
|
|
||||||
ShowAction ("Saving palette...");
|
|
||||||
|
|
||||||
AllocSaveBuffer ();
|
|
||||||
datasize = preparePalData(method, gamePalettes, gamePalettesCount);
|
|
||||||
|
|
||||||
if(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB)
|
|
||||||
{
|
|
||||||
// Set the comments
|
|
||||||
char prefscomment[2][32];
|
|
||||||
memset(prefscomment, 0, 64);
|
|
||||||
sprintf (prefscomment[0], "%s Pal", APPNAME);
|
|
||||||
sprintf (prefscomment[1], "Palette");
|
|
||||||
SetMCSaveComments(prefscomment);
|
|
||||||
}
|
|
||||||
|
|
||||||
offset = SaveFile(filepath, datasize, method, silent);
|
|
||||||
|
|
||||||
FreeSaveBuffer ();
|
|
||||||
|
|
||||||
CancelAction();
|
|
||||||
|
|
||||||
if (offset > 0)
|
|
||||||
{
|
|
||||||
if (!silent)
|
|
||||||
InfoPrompt("Palette saved");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool
|
|
||||||
SavePalettes(bool silent) {
|
|
||||||
// Now create the XML palette file
|
|
||||||
char filepath[1024];
|
|
||||||
int datasize;
|
|
||||||
int offset = 0;
|
|
||||||
|
|
||||||
// We'll save using the first available method (probably SD) since this
|
|
||||||
// is the method preferences will be loaded from by default
|
|
||||||
int method = autoSaveMethod(silent);
|
|
||||||
|
|
||||||
if(method == METHOD_AUTO)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if(!MakeFilePath(filepath, FILE_PAL, method))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (!silent)
|
|
||||||
ShowAction("Saving palette...");
|
|
||||||
|
|
||||||
AllocSaveBuffer ();
|
|
||||||
datasize = preparePalData(method, palettes, loadedPalettes);
|
|
||||||
|
|
||||||
if(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB)
|
|
||||||
{
|
|
||||||
// Set the comments
|
|
||||||
char prefscomment[2][32];
|
|
||||||
memset(prefscomment, 0, 64);
|
|
||||||
sprintf (prefscomment[0], "%s Pal", APPNAME);
|
|
||||||
sprintf (prefscomment[1], "Palette");
|
|
||||||
SetMCSaveComments(prefscomment);
|
|
||||||
}
|
|
||||||
|
|
||||||
offset = SaveFile(filepath, datasize, method, silent);
|
|
||||||
|
|
||||||
FreeSaveBuffer ();
|
|
||||||
|
|
||||||
CancelAction();
|
|
||||||
|
|
||||||
if (offset > 0)
|
|
||||||
{
|
|
||||||
if (!silent)
|
|
||||||
InfoPrompt("Palette saved");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Load Preferences from specified method
|
* Load Preferences from specified method
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
@ -816,50 +596,6 @@ LoadPrefsFromMethod (int method)
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
|
||||||
LoadPalFromMethod (int method, const char *gameName)
|
|
||||||
{
|
|
||||||
bool retval = false;
|
|
||||||
char filepath[1024];
|
|
||||||
int offset = 0;
|
|
||||||
|
|
||||||
if(!MakeFilePath(filepath, FILE_PAL, method))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
AllocSaveBuffer ();
|
|
||||||
|
|
||||||
offset = LoadFile(filepath, method, SILENT);
|
|
||||||
|
|
||||||
if (offset > 0)
|
|
||||||
retval = decodePalData (method, gameName);
|
|
||||||
|
|
||||||
FreeSaveBuffer ();
|
|
||||||
|
|
||||||
return retval;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool
|
|
||||||
LoadPalsFromMethod (int method)
|
|
||||||
{
|
|
||||||
bool retval = false;
|
|
||||||
char filepath[1024];
|
|
||||||
int offset = 0;
|
|
||||||
|
|
||||||
if(!MakeFilePath(filepath, FILE_PAL, method))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
AllocSaveBuffer ();
|
|
||||||
|
|
||||||
offset = LoadFile(filepath, method, SILENT);
|
|
||||||
|
|
||||||
if (offset > 0)
|
|
||||||
retval = decodePalsData (method);
|
|
||||||
|
|
||||||
FreeSaveBuffer ();
|
|
||||||
|
|
||||||
return retval;
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Load Preferences
|
* Load Preferences
|
||||||
* Checks sources consecutively until we find a preference file
|
* Checks sources consecutively until we find a preference file
|
||||||
@ -891,90 +627,125 @@ bool LoadPrefs()
|
|||||||
return prefFound;
|
return prefFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
bool SavePalettes(bool silent)
|
||||||
* Load Palette
|
|
||||||
* Checks sources consecutively until we find a palette file
|
|
||||||
***************************************************************************/
|
|
||||||
bool LoadPalette(const char *gameName)
|
|
||||||
{
|
{
|
||||||
bool prefFound = false;
|
char filepath[1024];
|
||||||
if(ChangeInterface(METHOD_SD, SILENT))
|
int datasize;
|
||||||
prefFound = LoadPalFromMethod(METHOD_SD, gameName);
|
int offset = 0;
|
||||||
if(!prefFound && ChangeInterface(METHOD_USB, SILENT))
|
int method = GCSettings.SaveMethod;
|
||||||
prefFound = LoadPalFromMethod(METHOD_USB, gameName);
|
|
||||||
if(!prefFound && TestMC(CARD_SLOTA, SILENT))
|
|
||||||
prefFound = LoadPalFromMethod(METHOD_MC_SLOTA, gameName);
|
|
||||||
if(!prefFound && TestMC(CARD_SLOTB, SILENT))
|
|
||||||
prefFound = LoadPalFromMethod(METHOD_MC_SLOTB, gameName);
|
|
||||||
if(!prefFound && ChangeInterface(METHOD_SMB, SILENT))
|
|
||||||
prefFound = LoadPalFromMethod(METHOD_SMB, gameName);
|
|
||||||
|
|
||||||
if(!prefFound) {
|
if(method == METHOD_AUTO)
|
||||||
return CreateAndLoadPalette(SILENT, gameName, true);
|
method = autoSaveMethod(silent);
|
||||||
|
|
||||||
|
if(method == METHOD_AUTO)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!MakeFilePath(filepath, FILE_PAL, method))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Now create the XML palette file
|
||||||
|
|
||||||
|
if (!silent)
|
||||||
|
ShowAction("Saving palette...");
|
||||||
|
|
||||||
|
AllocSaveBuffer();
|
||||||
|
datasize = preparePalData(method, palettes, loadedPalettes);
|
||||||
|
|
||||||
|
if (method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB)
|
||||||
|
{
|
||||||
|
// Set the comments
|
||||||
|
char prefscomment[2][32];
|
||||||
|
memset(prefscomment, 0, 64);
|
||||||
|
sprintf(prefscomment[0], "%s Pal", APPNAME);
|
||||||
|
sprintf(prefscomment[1], "Palette");
|
||||||
|
SetMCSaveComments(prefscomment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
offset = SaveFile(filepath, datasize, method, silent);
|
||||||
|
|
||||||
|
FreeSaveBuffer();
|
||||||
|
|
||||||
|
CancelAction();
|
||||||
|
|
||||||
|
if (offset > 0)
|
||||||
|
{
|
||||||
|
if (!silent)
|
||||||
|
InfoPrompt("Palette saved");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
static
|
static void AddPalette(gamePalette pal, const char *gameName)
|
||||||
bool LoadPalettes()
|
|
||||||
{
|
{
|
||||||
bool prefFound = false;
|
for (int i=0; i < loadedPalettes; i++)
|
||||||
if(ChangeInterface(METHOD_SD, SILENT))
|
if (strcmp(palettes[i].gameName, gameName)==0)
|
||||||
prefFound = LoadPalsFromMethod(METHOD_SD);
|
|
||||||
if(!prefFound && ChangeInterface(METHOD_USB, SILENT))
|
|
||||||
prefFound = LoadPalsFromMethod(METHOD_USB);
|
|
||||||
if(!prefFound && TestMC(CARD_SLOTA, SILENT))
|
|
||||||
prefFound = LoadPalsFromMethod(METHOD_MC_SLOTA);
|
|
||||||
if(!prefFound && TestMC(CARD_SLOTB, SILENT))
|
|
||||||
prefFound = LoadPalsFromMethod(METHOD_MC_SLOTB);
|
|
||||||
if(!prefFound && ChangeInterface(METHOD_SMB, SILENT))
|
|
||||||
prefFound = LoadPalsFromMethod(METHOD_SMB);
|
|
||||||
|
|
||||||
if(!prefFound) {
|
|
||||||
CreateAndLoadPalette(SILENT, "", false);
|
|
||||||
if(ChangeInterface(METHOD_SD, SILENT))
|
|
||||||
prefFound = LoadPalsFromMethod(METHOD_SD);
|
|
||||||
if(!prefFound && ChangeInterface(METHOD_USB, SILENT))
|
|
||||||
prefFound = LoadPalsFromMethod(METHOD_USB);
|
|
||||||
if(!prefFound && TestMC(CARD_SLOTA, SILENT))
|
|
||||||
prefFound = LoadPalsFromMethod(METHOD_MC_SLOTA);
|
|
||||||
if(!prefFound && TestMC(CARD_SLOTB, SILENT))
|
|
||||||
prefFound = LoadPalsFromMethod(METHOD_MC_SLOTB);
|
|
||||||
if(!prefFound && ChangeInterface(METHOD_SMB, SILENT))
|
|
||||||
prefFound = LoadPalsFromMethod(METHOD_SMB);
|
|
||||||
}
|
|
||||||
return prefFound;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void AddPalette(gamePalette pal, const char *gameName) {
|
|
||||||
for (int i=0; i<loadedPalettes; i++) {
|
|
||||||
if (strcmp(palettes[i].gameName, gameName)==0) {
|
|
||||||
palettes[i] = pal;
|
|
||||||
strncpy(palettes[i].gameName, gameName, 17);
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
}
|
palettes = (gamePalette *)realloc(palettes, sizeof(gamePalette)*(loadedPalettes+1));
|
||||||
palettes[loadedPalettes] = pal;
|
palettes[loadedPalettes] = pal;
|
||||||
strncpy(palettes[loadedPalettes].gameName, gameName, 17);
|
strncpy(palettes[loadedPalettes].gameName, gameName, 17);
|
||||||
loadedPalettes++;
|
loadedPalettes++;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SavePalette(bool silent, const char *gameName) {
|
/****************************************************************************
|
||||||
bool prefFound = LoadPalettes();
|
* Load Palettes
|
||||||
if (!prefFound) {
|
***************************************************************************/
|
||||||
delete[] palettes;
|
bool LoadPalettes()
|
||||||
palettes = NULL;
|
{
|
||||||
return false;
|
bool retval = false;
|
||||||
}
|
char filepath[1024];
|
||||||
|
int offset = 0;
|
||||||
|
int method = GCSettings.SaveMethod;
|
||||||
|
|
||||||
if(prefFound && palettes) {
|
if(method == METHOD_AUTO)
|
||||||
|
method = autoSaveMethod(SILENT);
|
||||||
|
|
||||||
|
if(method == METHOD_AUTO)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if(!MakeFilePath(filepath, FILE_PAL, method))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
AllocSaveBuffer ();
|
||||||
|
|
||||||
|
offset = LoadFile(filepath, method, SILENT);
|
||||||
|
|
||||||
|
if (offset > 0)
|
||||||
|
retval = decodePalsData (method);
|
||||||
|
|
||||||
|
FreeSaveBuffer ();
|
||||||
|
|
||||||
|
// add hard-coded palettes
|
||||||
for (int i=0; i<gamePalettesCount; i++)
|
for (int i=0; i<gamePalettesCount; i++)
|
||||||
AddPalette(gamePalettes[i], gamePalettes[i].gameName);
|
AddPalette(gamePalettes[i], gamePalettes[i].gameName);
|
||||||
if (!gameName) gameName = CurrentPalette.gameName;
|
|
||||||
AddPalette(CurrentPalette, gameName);
|
if (!retval)
|
||||||
SavePalettes(silent);
|
retval = SavePalettes(SILENT);
|
||||||
delete[] palettes;
|
|
||||||
palettes = NULL;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetPalette(const char *gameName)
|
||||||
|
{
|
||||||
|
// Load existing palette
|
||||||
|
int snum = -1;
|
||||||
|
for (int i = 0; i < loadedPalettes; i++)
|
||||||
|
{
|
||||||
|
if(strcmp(gameName, palettes[i].gameName)==0)
|
||||||
|
{
|
||||||
|
snum = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// match found!
|
||||||
|
if(snum >= 0)
|
||||||
|
{
|
||||||
|
CurrentPalette = gamePalettes[snum];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CurrentPalette = gamePalettes[0]; // use the default palette
|
||||||
|
AddPalette(gamePalettes[0], gameName); // add this game to the palette list
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -10,5 +10,6 @@
|
|||||||
|
|
||||||
bool SavePrefs (bool silent);
|
bool SavePrefs (bool silent);
|
||||||
bool LoadPrefs ();
|
bool LoadPrefs ();
|
||||||
bool SavePalette (bool silent, const char *gameName);
|
bool SavePalettes (bool silent);
|
||||||
bool LoadPalette (const char *gameName);
|
bool LoadPalettes();
|
||||||
|
void SetPalette(const char *gameName);
|
||||||
|
@ -36,9 +36,12 @@
|
|||||||
#include "input.h"
|
#include "input.h"
|
||||||
#include "video.h"
|
#include "video.h"
|
||||||
#include "vbaconfig.h"
|
#include "vbaconfig.h"
|
||||||
|
#include "gamesettings.h"
|
||||||
#include "wiiusbsupport.h"
|
#include "wiiusbsupport.h"
|
||||||
|
|
||||||
extern int emulating;
|
extern int emulating;
|
||||||
|
void StopColorizing();
|
||||||
|
void gbSetPalette(u32 RRGGBB[]);
|
||||||
int ScreenshotRequested = 0;
|
int ScreenshotRequested = 0;
|
||||||
int ConfigRequested = 0;
|
int ConfigRequested = 0;
|
||||||
int ShutdownRequested = 0;
|
int ShutdownRequested = 0;
|
||||||
@ -282,6 +285,15 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
ResetVideo_Emu();
|
ResetVideo_Emu();
|
||||||
|
|
||||||
|
// GB colorizing - set palette
|
||||||
|
if(cartridgeType == 1)
|
||||||
|
{
|
||||||
|
if(GCSettings.colorize && strcmp(RomTitle, "MEGAMAN") != 0)
|
||||||
|
gbSetPalette(CurrentPalette.palette);
|
||||||
|
else
|
||||||
|
StopColorizing();
|
||||||
|
}
|
||||||
|
|
||||||
while (emulating) // emulation loop
|
while (emulating) // emulation loop
|
||||||
{
|
{
|
||||||
emulator.emuMain(emulator.emuCount);
|
emulator.emuMain(emulator.emuCount);
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
#define APPNAME "Visual Boy Advance GX"
|
#define APPNAME "Visual Boy Advance GX"
|
||||||
#define APPVERSION "2.0.3"
|
#define APPVERSION "2.0.3"
|
||||||
#define PREF_FILE_NAME "settings.xml"
|
#define PREF_FILE_NAME "settings.xml"
|
||||||
#define PAL_FILE_NAME "palette.xml"
|
#define PAL_FILE_NAME "palettes.xml"
|
||||||
|
|
||||||
#define NOTSILENT 0
|
#define NOTSILENT 0
|
||||||
#define SILENT 1
|
#define SILENT 1
|
||||||
|
@ -805,10 +805,12 @@ static void gbApplyPerImagePreferences()
|
|||||||
}
|
}
|
||||||
// look for matching palettes if a monochrome gameboy game
|
// look for matching palettes if a monochrome gameboy game
|
||||||
// (or if a Super Gameboy game, but the palette will be ignored later in that case)
|
// (or if a Super Gameboy game, but the palette will be ignored later in that case)
|
||||||
if ((Colour != 0x80) && (Colour != 0xC0)) {
|
if ((Colour != 0x80) && (Colour != 0xC0))
|
||||||
if (strcmp(RomTitle, "MEGAMAN")==0) StopColorizing();
|
{
|
||||||
else if (GCSettings.colorize) LoadPalette(RomTitle);
|
if (GCSettings.colorize && strcmp(RomTitle, "MEGAMAN") != 0)
|
||||||
else StopColorizing();
|
SetPalette(RomTitle);
|
||||||
|
else
|
||||||
|
StopColorizing();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ extern int cartridgeType;
|
|||||||
extern int SunBars;
|
extern int SunBars;
|
||||||
extern u32 RomIdCode;
|
extern u32 RomIdCode;
|
||||||
extern bool TiltSideways;
|
extern bool TiltSideways;
|
||||||
|
extern char RomTitle[];
|
||||||
|
|
||||||
bool LoadVBAROM(int method);
|
bool LoadVBAROM(int method);
|
||||||
void InitialisePalette();
|
void InitialisePalette();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user