From 02b4919005a3bab00a2b0aa9e62ae50541ef6513 Mon Sep 17 00:00:00 2001 From: Arisotura Date: Sun, 12 May 2019 17:43:39 +0200 Subject: resolution switch somewhat functional --- src/GPU2D.cpp | 8 +-- src/libui_sdl/DlgVideoSettings.cpp | 9 +-- src/libui_sdl/main.cpp | 109 ++++++++++++++++++++++++++----------- 3 files changed, 85 insertions(+), 41 deletions(-) (limited to 'src') diff --git a/src/GPU2D.cpp b/src/GPU2D.cpp index 521d86a..3a99964 100644 --- a/src/GPU2D.cpp +++ b/src/GPU2D.cpp @@ -1489,8 +1489,8 @@ void GPU2D::DrawBG_3D() { for (; i < iend; i++) { - int is = i << 1; - int xs = xoff << 1; + int is = i << 2; + int xs = xoff << 2; u32 c; xoff++; @@ -1511,8 +1511,8 @@ void GPU2D::DrawBG_3D() xs++; } - is += 1021; - xs += 1021; + is += 1020; + xs += 1020; } } } diff --git a/src/libui_sdl/DlgVideoSettings.cpp b/src/libui_sdl/DlgVideoSettings.cpp index 4d5de71..aee6d51 100644 --- a/src/libui_sdl/DlgVideoSettings.cpp +++ b/src/libui_sdl/DlgVideoSettings.cpp @@ -28,7 +28,7 @@ #include "DlgVideoSettings.h" -// +void ApplyNewSettings(int type); namespace DlgVideoSettings @@ -50,7 +50,8 @@ void OnResolutionChanged(uiRadioButtons* rb, void* blarg) { int id = uiRadioButtonsSelected(rb); - printf("res=%d\n", id); + Config::ScreenScale = id; + ApplyNewSettings(2); } void OnCancel(uiButton* btn, void* blarg) @@ -167,8 +168,8 @@ void Open() uiRadioButtons* rbApplyScalingTo = uiNewRadioButtons(); uiRadioButtonsAppend(rbApplyScalingTo, "Both screens"); uiRadioButtonsAppend(rbApplyScalingTo, "Emphasized screen (see 'Screen sizing')"); - uiRadioButtonsAppend(rbApplyScalingTo, "Top screen"); - uiRadioButtonsAppend(rbApplyScalingTo, "Bottom screen"); + //uiRadioButtonsAppend(rbApplyScalingTo, "Top screen"); + //uiRadioButtonsAppend(rbApplyScalingTo, "Bottom screen"); uiBoxAppend(in_ctrl, uiControl(rbApplyScalingTo), 0); } diff --git a/src/libui_sdl/main.cpp b/src/libui_sdl/main.cpp index b79853e..6fcb1ae 100644 --- a/src/libui_sdl/main.cpp +++ b/src/libui_sdl/main.cpp @@ -96,10 +96,9 @@ bool SavestateLoaded; bool ScreenDrawInited = false; uiDrawBitmap* ScreenBitmap[2] = {NULL,NULL}; -SDL_mutex* ScreenMutex; -u32* ScreenBuffer; -int ScreenScale; +int ScreenScale[3]; +int ScreenScaleMode; int ScreenGap = 0; int ScreenLayout = 0; @@ -400,13 +399,18 @@ int EmuThreadFunc(void* burp) uiGLMakeContextCurrent(GLContext); NDS::Init(); - ScreenBuffer = new u32[(256*ScreenScale) * (384*ScreenScale)]; - MainScreenPos[0] = 0; MainScreenPos[1] = 0; MainScreenPos[2] = 0; AutoScreenSizing = 0; + // FIXME + ScreenScale[2] = Config::ScreenScale; + ScreenScale[0] = ScreenScale[2]; + ScreenScale[1] = ScreenScale[2]; + + int lastscale[2] = {-1, -1}; + Touching = false; KeyInputMask = 0xFFF; HotkeyMask = 0; @@ -522,11 +526,6 @@ int EmuThreadFunc(void* burp) // microphone input FeedMicInput(); - // emulate - u32 nlines = NDS::RunFrame(); - - if (EmuRunning == 0) break; - // auto screen layout { MainScreenPos[2] = MainScreenPos[1]; @@ -556,7 +555,18 @@ int EmuThreadFunc(void* burp) } } - //memcpy(ScreenBuffer, GPU::Framebuffer, (256*ScreenScale)*(384*ScreenScale)*4); + if (ScreenScale[0] != lastscale[0] || + ScreenScale[1] != lastscale[1]) + { + GPU::SetFramebufferScale(ScreenScale[0], ScreenScale[1]); + ScreenDrawInited = false; + } + + // emulate + u32 nlines = NDS::RunFrame(); + + if (EmuRunning == 0) break; + uiAreaQueueRedrawAll(MainDrawArea); // framerate limiter based off SDL2_gfx @@ -622,8 +632,6 @@ int EmuThreadFunc(void* burp) if (joybuttons) delete[] joybuttons; - delete[] ScreenBuffer; - NDS::DeInit(); Platform::LAN_DeInit(); @@ -636,16 +644,19 @@ void OnAreaDraw(uiAreaHandler* handler, uiArea* area, uiAreaDrawParams* params) // TODO: recreate bitmap if screen scale changed if (!ScreenDrawInited) { + if (ScreenBitmap[0]) uiDrawFreeBitmap(ScreenBitmap[0]); + if (ScreenBitmap[1]) uiDrawFreeBitmap(ScreenBitmap[1]); + ScreenDrawInited = true; - ScreenBitmap[0] = uiDrawNewBitmap(params->Context, 256*ScreenScale, 192*ScreenScale); - ScreenBitmap[1] = uiDrawNewBitmap(params->Context, 256*ScreenScale, 192*ScreenScale); + ScreenBitmap[0] = uiDrawNewBitmap(params->Context, 256<Context, 256<