mirror of
https://github.com/dborth/vbagx.git
synced 2024-12-27 03:01:50 +01:00
add separate zoom options for hor and vert, for both GBA and GB
This commit is contained in:
parent
49ecf15912
commit
44d7390b15
@ -54,6 +54,7 @@ static GuiSound * enterSound = NULL;
|
||||
static GuiSound * exitSound = NULL;
|
||||
static GuiWindow * mainWindow = NULL;
|
||||
static GuiText * settingText = NULL;
|
||||
static GuiText * settingText2 = NULL;
|
||||
static int lastMenu = MENU_NONE;
|
||||
static int mapMenuCtrl = 0;
|
||||
|
||||
@ -2448,26 +2449,42 @@ static int MenuSettingsMappingsMap()
|
||||
* MenuSettingsVideo
|
||||
***************************************************************************/
|
||||
|
||||
static void ScreenZoomWindowUpdate(void * ptr, float amount)
|
||||
static void ScreenZoomWindowUpdate(void * ptr, float h, float v)
|
||||
{
|
||||
GuiButton * b = (GuiButton *)ptr;
|
||||
if(b->GetState() == STATE_CLICKED)
|
||||
{
|
||||
GCSettings.ZoomLevel += amount;
|
||||
char zoom[10], zoom2[10];
|
||||
|
||||
if(IsGBAGame())
|
||||
{
|
||||
GCSettings.gbaZoomHor += h;
|
||||
GCSettings.gbaZoomVert += v;
|
||||
sprintf(zoom, "%.2f%%", GCSettings.gbaZoomHor*100);
|
||||
sprintf(zoom2, "%.2f%%", GCSettings.gbaZoomVert*100);
|
||||
}
|
||||
else
|
||||
{
|
||||
GCSettings.gbZoomHor += h;
|
||||
GCSettings.gbZoomVert += v;
|
||||
sprintf(zoom, "%.2f%%", GCSettings.gbZoomHor*100);
|
||||
sprintf(zoom2, "%.2f%%", GCSettings.gbZoomVert*100);
|
||||
}
|
||||
|
||||
char zoom[10];
|
||||
sprintf(zoom, "%.2f%%", GCSettings.ZoomLevel*100);
|
||||
settingText->SetText(zoom);
|
||||
settingText2->SetText(zoom2);
|
||||
b->ResetState();
|
||||
}
|
||||
}
|
||||
|
||||
static void ScreenZoomWindowLeftClick(void * ptr) { ScreenZoomWindowUpdate(ptr, -0.01); }
|
||||
static void ScreenZoomWindowRightClick(void * ptr) { ScreenZoomWindowUpdate(ptr, +0.01); }
|
||||
static void ScreenZoomWindowLeftClick(void * ptr) { ScreenZoomWindowUpdate(ptr, -0.01, 0); }
|
||||
static void ScreenZoomWindowRightClick(void * ptr) { ScreenZoomWindowUpdate(ptr, +0.01, 0); }
|
||||
static void ScreenZoomWindowUpClick(void * ptr) { ScreenZoomWindowUpdate(ptr, 0, +0.01); }
|
||||
static void ScreenZoomWindowDownClick(void * ptr) { ScreenZoomWindowUpdate(ptr, 0, -0.01); }
|
||||
|
||||
static void ScreenZoomWindow()
|
||||
{
|
||||
GuiWindow * w = new GuiWindow(250,250);
|
||||
GuiWindow * w = new GuiWindow(200,200);
|
||||
w->SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
|
||||
|
||||
GuiTrigger trigA;
|
||||
@ -2482,6 +2499,12 @@ static void ScreenZoomWindow()
|
||||
GuiTrigger trigRight;
|
||||
trigRight.SetButtonOnlyInFocusTrigger(-1, WPAD_BUTTON_RIGHT | WPAD_CLASSIC_BUTTON_RIGHT, PAD_BUTTON_RIGHT);
|
||||
|
||||
GuiTrigger trigUp;
|
||||
trigUp.SetButtonOnlyInFocusTrigger(-1, WPAD_BUTTON_UP | WPAD_CLASSIC_BUTTON_UP, PAD_BUTTON_UP);
|
||||
|
||||
GuiTrigger trigDown;
|
||||
trigDown.SetButtonOnlyInFocusTrigger(-1, WPAD_BUTTON_DOWN | WPAD_CLASSIC_BUTTON_DOWN, PAD_BUTTON_DOWN);
|
||||
|
||||
GuiImageData arrowLeft(button_arrow_left_png);
|
||||
GuiImage arrowLeftImg(&arrowLeft);
|
||||
GuiImageData arrowLeftOver(button_arrow_left_over_png);
|
||||
@ -2489,7 +2512,8 @@ static void ScreenZoomWindow()
|
||||
GuiButton arrowLeftBtn(arrowLeft.GetWidth(), arrowLeft.GetHeight());
|
||||
arrowLeftBtn.SetImage(&arrowLeftImg);
|
||||
arrowLeftBtn.SetImageOver(&arrowLeftOverImg);
|
||||
arrowLeftBtn.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
|
||||
arrowLeftBtn.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
|
||||
arrowLeftBtn.SetPosition(50, 0);
|
||||
arrowLeftBtn.SetTrigger(0, &trigA);
|
||||
arrowLeftBtn.SetTrigger(1, &trigLeft);
|
||||
arrowLeftBtn.SetSelectable(false);
|
||||
@ -2502,28 +2526,103 @@ static void ScreenZoomWindow()
|
||||
GuiButton arrowRightBtn(arrowRight.GetWidth(), arrowRight.GetHeight());
|
||||
arrowRightBtn.SetImage(&arrowRightImg);
|
||||
arrowRightBtn.SetImageOver(&arrowRightOverImg);
|
||||
arrowRightBtn.SetAlignment(ALIGN_RIGHT, ALIGN_MIDDLE);
|
||||
arrowRightBtn.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
|
||||
arrowRightBtn.SetPosition(164, 0);
|
||||
arrowRightBtn.SetTrigger(0, &trigA);
|
||||
arrowRightBtn.SetTrigger(1, &trigRight);
|
||||
arrowRightBtn.SetSelectable(false);
|
||||
arrowRightBtn.SetUpdateCallback(ScreenZoomWindowRightClick);
|
||||
|
||||
settingText = new GuiText(NULL, 22, (GXColor){0, 0, 0, 255});
|
||||
char zoom[10];
|
||||
sprintf(zoom, "%.2f%%", GCSettings.ZoomLevel*100);
|
||||
settingText->SetText(zoom);
|
||||
GuiImageData arrowUp(button_arrow_up_png);
|
||||
GuiImage arrowUpImg(&arrowUp);
|
||||
GuiImageData arrowUpOver(button_arrow_up_over_png);
|
||||
GuiImage arrowUpOverImg(&arrowUpOver);
|
||||
GuiButton arrowUpBtn(arrowUp.GetWidth(), arrowUp.GetHeight());
|
||||
arrowUpBtn.SetImage(&arrowUpImg);
|
||||
arrowUpBtn.SetImageOver(&arrowUpOverImg);
|
||||
arrowUpBtn.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
|
||||
arrowUpBtn.SetPosition(-76, -27);
|
||||
arrowUpBtn.SetTrigger(0, &trigA);
|
||||
arrowUpBtn.SetTrigger(1, &trigUp);
|
||||
arrowUpBtn.SetSelectable(false);
|
||||
arrowUpBtn.SetUpdateCallback(ScreenZoomWindowUpClick);
|
||||
|
||||
float currentZoom = GCSettings.ZoomLevel;
|
||||
GuiImageData arrowDown(button_arrow_down_png);
|
||||
GuiImage arrowDownImg(&arrowDown);
|
||||
GuiImageData arrowDownOver(button_arrow_down_over_png);
|
||||
GuiImage arrowDownOverImg(&arrowDownOver);
|
||||
GuiButton arrowDownBtn(arrowDown.GetWidth(), arrowDown.GetHeight());
|
||||
arrowDownBtn.SetImage(&arrowDownImg);
|
||||
arrowDownBtn.SetImageOver(&arrowDownOverImg);
|
||||
arrowDownBtn.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
|
||||
arrowDownBtn.SetPosition(-76, 27);
|
||||
arrowDownBtn.SetTrigger(0, &trigA);
|
||||
arrowDownBtn.SetTrigger(1, &trigDown);
|
||||
arrowDownBtn.SetSelectable(false);
|
||||
arrowDownBtn.SetUpdateCallback(ScreenZoomWindowDownClick);
|
||||
|
||||
GuiImageData screenPosition(screen_position_png);
|
||||
GuiImage screenPositionImg(&screenPosition);
|
||||
screenPositionImg.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
|
||||
screenPositionImg.SetPosition(0, 0);
|
||||
|
||||
settingText = new GuiText(NULL, 22, (GXColor){0, 0, 0, 255});
|
||||
settingText2 = new GuiText(NULL, 22, (GXColor){0, 0, 0, 255});
|
||||
char zoom[10], zoom2[10];
|
||||
float currentZoomHor, currentZoomVert;
|
||||
|
||||
if(IsGBAGame())
|
||||
{
|
||||
sprintf(zoom, "%.2f%%", GCSettings.gbaZoomHor*100);
|
||||
sprintf(zoom2, "%.2f%%", GCSettings.gbaZoomVert*100);
|
||||
currentZoomHor = GCSettings.gbaZoomHor;
|
||||
currentZoomVert = GCSettings.gbaZoomVert;
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(zoom, "%.2f%%", GCSettings.gbZoomHor*100);
|
||||
sprintf(zoom2, "%.2f%%", GCSettings.gbZoomVert*100);
|
||||
currentZoomHor = GCSettings.gbZoomHor;
|
||||
currentZoomVert = GCSettings.gbZoomVert;
|
||||
}
|
||||
|
||||
settingText->SetText(zoom);
|
||||
settingText->SetPosition(108, 0);
|
||||
settingText2->SetText(zoom2);
|
||||
settingText2->SetPosition(-76, 0);
|
||||
|
||||
w->Append(&arrowLeftBtn);
|
||||
w->Append(&arrowRightBtn);
|
||||
w->Append(&arrowUpBtn);
|
||||
w->Append(&arrowDownBtn);
|
||||
w->Append(&screenPositionImg);
|
||||
w->Append(settingText);
|
||||
w->Append(settingText2);
|
||||
|
||||
if(!SettingWindow("Screen Zoom",w))
|
||||
GCSettings.ZoomLevel = currentZoom; // undo changes
|
||||
char windowName[20];
|
||||
if(IsGBAGame())
|
||||
sprintf(windowName, "GBA Screen Zoom");
|
||||
else
|
||||
sprintf(windowName, "GB Screen Zoom");
|
||||
|
||||
if(!SettingWindow(windowName,w))
|
||||
{
|
||||
// undo changes
|
||||
if(IsGBAGame())
|
||||
{
|
||||
GCSettings.gbaZoomHor = currentZoomHor;
|
||||
GCSettings.gbaZoomVert = currentZoomVert;
|
||||
}
|
||||
else
|
||||
{
|
||||
GCSettings.gbZoomHor = currentZoomHor;
|
||||
GCSettings.gbZoomVert = currentZoomVert;
|
||||
}
|
||||
}
|
||||
|
||||
delete(w);
|
||||
delete(settingText);
|
||||
delete(settingText2);
|
||||
}
|
||||
|
||||
static void ScreenPositionWindowUpdate(void * ptr, int x, int y)
|
||||
@ -2643,7 +2742,8 @@ static void ScreenPositionWindow()
|
||||
|
||||
if(!SettingWindow("Screen Position",w))
|
||||
{
|
||||
GCSettings.xshift = currentX; // undo changes
|
||||
// undo changes
|
||||
GCSettings.xshift = currentX;
|
||||
GCSettings.yshift = currentY;
|
||||
}
|
||||
|
||||
@ -2661,16 +2761,22 @@ static int MenuSettingsVideo()
|
||||
|
||||
sprintf(options.name[i++], "Rendering");
|
||||
sprintf(options.name[i++], "Scaling");
|
||||
sprintf(options.name[i++], "Screen Zoom");
|
||||
if(IsGBAGame())
|
||||
sprintf(options.name[i++], "GBA Screen Zoom");
|
||||
else
|
||||
sprintf(options.name[i++], "GB Screen Zoom");
|
||||
sprintf(options.name[i++], "Screen Position");
|
||||
sprintf(options.name[i++], "Video Mode");
|
||||
sprintf(options.name[i++], "Colorize Mono GB");
|
||||
sprintf(options.name[i++], "GB Mono Colorization");
|
||||
sprintf(options.name[i++], "GB Palette");
|
||||
options.length = i;
|
||||
|
||||
for(i=0; i < options.length; i++)
|
||||
options.value[i][0] = 0;
|
||||
|
||||
if(IsGBAGame())
|
||||
options.name[5][0] = 0;
|
||||
|
||||
if(!IsGameboyGame())
|
||||
options.name[6][0] = 0; // disable palette option for GBA/GBC
|
||||
|
||||
@ -2784,8 +2890,10 @@ static int MenuSettingsVideo()
|
||||
else if (GCSettings.scaling == 3)
|
||||
sprintf (options.value[1], "16:9 Correction");
|
||||
|
||||
sprintf (options.value[2], "%.2f%%", GCSettings.ZoomLevel*100);
|
||||
|
||||
if(IsGBAGame())
|
||||
sprintf (options.value[2], "%.2f%%, %.2f%%", GCSettings.gbaZoomHor*100, GCSettings.gbaZoomVert*100);
|
||||
else
|
||||
sprintf (options.value[2], "%.2f%%, %.2f%%", GCSettings.gbZoomHor*100, GCSettings.gbZoomVert*100);
|
||||
sprintf (options.value[3], "%d, %d", GCSettings.xshift, GCSettings.yshift);
|
||||
|
||||
switch(GCSettings.videomode)
|
||||
|
@ -180,7 +180,10 @@ preparePrefsData ()
|
||||
createXMLSection("Video", "Video Settings");
|
||||
|
||||
createXMLSetting("videomode", "Video Mode", toStr(GCSettings.videomode));
|
||||
createXMLSetting("ZoomLevel", "Zoom Level", FtoStr(GCSettings.ZoomLevel));
|
||||
createXMLSetting("gbaZoomHor", "GBA Horizontal Zoom Level", FtoStr(GCSettings.gbaZoomHor));
|
||||
createXMLSetting("gbaZoomVert", "GBA Vertical Zoom Level", FtoStr(GCSettings.gbaZoomVert));
|
||||
createXMLSetting("gbZoomHor", "GB Horizontal Zoom Level", FtoStr(GCSettings.gbZoomHor));
|
||||
createXMLSetting("gbZoomVert", "GB Vertical Zoom Level", FtoStr(GCSettings.gbZoomVert));
|
||||
createXMLSetting("render", "Video Filtering", toStr(GCSettings.render));
|
||||
createXMLSetting("scaling", "Aspect Ratio Correction", toStr(GCSettings.scaling));
|
||||
createXMLSetting("xshift", "Horizontal Video Shift", toStr(GCSettings.xshift));
|
||||
@ -477,7 +480,10 @@ decodePrefsData ()
|
||||
// Video Settings
|
||||
|
||||
loadXMLSetting(&GCSettings.videomode, "videomode");
|
||||
loadXMLSetting(&GCSettings.ZoomLevel, "ZoomLevel");
|
||||
loadXMLSetting(&GCSettings.gbaZoomHor, "gbaZoomHor");
|
||||
loadXMLSetting(&GCSettings.gbaZoomVert, "gbaZoomVert");
|
||||
loadXMLSetting(&GCSettings.gbZoomHor, "gbaZoomHor");
|
||||
loadXMLSetting(&GCSettings.gbZoomVert, "gbaZoomVert");
|
||||
loadXMLSetting(&GCSettings.render, "render");
|
||||
loadXMLSetting(&GCSettings.scaling, "scaling");
|
||||
loadXMLSetting(&GCSettings.xshift, "xshift");
|
||||
|
@ -16,7 +16,7 @@
|
||||
#include "filelist.h"
|
||||
|
||||
#define APPNAME "Visual Boy Advance GX"
|
||||
#define APPVERSION "2.0.8"
|
||||
#define APPVERSION "2.0.9"
|
||||
#define APPFOLDER "vbagx"
|
||||
#define PREF_FILE_NAME "settings.xml"
|
||||
#define PAL_FILE_NAME "palettes.xml"
|
||||
@ -60,7 +60,10 @@ struct SGCSettings{
|
||||
char smbpwd[20];
|
||||
char smbshare[20];
|
||||
|
||||
float ZoomLevel; // zoom amount
|
||||
float gbaZoomHor; // GBA horizontal zoom amount
|
||||
float gbaZoomVert; // GBA vertical zoom amount
|
||||
float gbZoomHor; // GB horizontal zoom amount
|
||||
float gbZoomVert; // GB vertical zoom amount
|
||||
int videomode; // 0 - automatic, 1 - NTSC (480i), 2 - Progressive (480p), 3 - PAL (50Hz), 4 - PAL (60Hz)
|
||||
int scaling; // 0 - default, 1 - partial stretch, 2 - stretch to fit, 3 - widescreen correction
|
||||
int render; // 0 - original, 1 - filtered, 2 - unfiltered
|
||||
|
@ -24,8 +24,14 @@ struct SGCSettings GCSettings;
|
||||
***************************************************************************/
|
||||
void FixInvalidSettings()
|
||||
{
|
||||
if(!(GCSettings.ZoomLevel > 0.5 && GCSettings.ZoomLevel < 1.5))
|
||||
GCSettings.ZoomLevel = 1.0;
|
||||
if(!(GCSettings.gbaZoomHor > 0.5 && GCSettings.gbaZoomHor < 1.5))
|
||||
GCSettings.gbaZoomHor = 1.0;
|
||||
if(!(GCSettings.gbaZoomVert > 0.5 && GCSettings.gbaZoomVert < 1.5))
|
||||
GCSettings.gbaZoomVert = 1.0;
|
||||
if(!(GCSettings.gbZoomHor > 0.5 && GCSettings.gbZoomHor < 1.5))
|
||||
GCSettings.gbZoomHor = 1.0;
|
||||
if(!(GCSettings.gbZoomVert > 0.5 && GCSettings.gbZoomVert < 1.5))
|
||||
GCSettings.gbZoomVert = 1.0;
|
||||
if(!(GCSettings.xshift > -50 && GCSettings.xshift < 50))
|
||||
GCSettings.xshift = 0;
|
||||
if(!(GCSettings.yshift > -50 && GCSettings.yshift < 50))
|
||||
@ -73,7 +79,10 @@ DefaultSettings ()
|
||||
GCSettings.WiimoteOrientation = 0;
|
||||
|
||||
GCSettings.VerifySaves = 0;
|
||||
GCSettings.ZoomLevel = 1.0; // zoom level
|
||||
GCSettings.gbaZoomHor = 1.0; // GBA horizontal zoom level
|
||||
GCSettings.gbaZoomVert = 1.0; // GBA vertical zoom level
|
||||
GCSettings.gbZoomHor = 1.0; // GBA horizontal zoom level
|
||||
GCSettings.gbZoomVert = 1.0; // GBA vertical zoom level
|
||||
GCSettings.videomode = 0; // automatic video mode detection
|
||||
GCSettings.render = 1; // Filtered
|
||||
GCSettings.scaling = 1; // partial stretch
|
||||
|
@ -720,6 +720,13 @@ bool IsGameboyGame()
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IsGBAGame()
|
||||
{
|
||||
if(cartridgeType == 2)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
static void gbApplyPerImagePreferences()
|
||||
{
|
||||
// Only works for some GB Colour roms
|
||||
|
@ -23,6 +23,7 @@ extern char RomTitle[];
|
||||
bool LoadVBAROM();
|
||||
void InitialisePalette();
|
||||
bool IsGameboyGame();
|
||||
bool IsGBAGame();
|
||||
bool LoadBatteryOrState(char * filepath, int action, bool silent);
|
||||
bool LoadBatteryOrStateAuto(int action, bool silent);
|
||||
bool SaveBatteryOrState(char * filepath, int action, bool silent);
|
||||
|
@ -463,8 +463,16 @@ static inline void UpdateScaling()
|
||||
}
|
||||
|
||||
// change zoom
|
||||
xscale *= GCSettings.ZoomLevel;
|
||||
yscale *= GCSettings.ZoomLevel;
|
||||
if (vwidth == 240) // GBA
|
||||
{
|
||||
xscale *= GCSettings.gbaZoomHor;
|
||||
yscale *= GCSettings.gbaZoomVert;
|
||||
}
|
||||
else
|
||||
{
|
||||
xscale *= GCSettings.gbZoomHor;
|
||||
yscale *= GCSettings.gbZoomVert;
|
||||
}
|
||||
|
||||
// Set new aspect
|
||||
square[0] = square[9] = -xscale + GCSettings.xshift;
|
||||
@ -641,29 +649,6 @@ void GX_Render(int width, int height, u8 * buffer, int pitch)
|
||||
LWP_ResumeThread (vbthread);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Zoom Functions
|
||||
***************************************************************************/
|
||||
void
|
||||
zoom (float speed)
|
||||
{
|
||||
if (GCSettings.ZoomLevel > 1)
|
||||
GCSettings.ZoomLevel += (speed / -100.0);
|
||||
else
|
||||
GCSettings.ZoomLevel += (speed / -200.0);
|
||||
|
||||
if (GCSettings.ZoomLevel < 0.5)
|
||||
GCSettings.ZoomLevel = 0.5;
|
||||
else if (GCSettings.ZoomLevel > 2.0)
|
||||
GCSettings.ZoomLevel = 2.0;
|
||||
}
|
||||
|
||||
void
|
||||
zoom_reset ()
|
||||
{
|
||||
GCSettings.ZoomLevel = 1.0;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* TakeScreenshot
|
||||
*
|
||||
|
@ -19,9 +19,6 @@ void GX_Render_Init(int width, int height);
|
||||
void GX_Render(int width, int height, u8 * buffer, int pitch);
|
||||
void StopGX();
|
||||
void ResetVideo_Emu();
|
||||
void zoom (float speed);
|
||||
void zoom_reset ();
|
||||
|
||||
void ResetVideo_Menu();
|
||||
void TakeScreenshot();
|
||||
void Menu_Render();
|
||||
|
Loading…
Reference in New Issue
Block a user