mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-07-21 05:09:46 -06:00
double-buffer framebuffer, eliminates artifacts
This commit is contained in:
@ -45,8 +45,8 @@ bool RunningSomething;
|
|||||||
char ROMPath[1024];
|
char ROMPath[1024];
|
||||||
|
|
||||||
bool ScreenDrawInited = false;
|
bool ScreenDrawInited = false;
|
||||||
SDL_mutex* ScreenMutex;
|
|
||||||
uiDrawBitmap* ScreenBitmap = NULL;
|
uiDrawBitmap* ScreenBitmap = NULL;
|
||||||
|
u32 ScreenBuffer[256*384];
|
||||||
|
|
||||||
bool Touching = false;
|
bool Touching = false;
|
||||||
|
|
||||||
@ -98,12 +98,11 @@ int EmuThreadFunc(void* burp)
|
|||||||
if (EmuRunning == 1)
|
if (EmuRunning == 1)
|
||||||
{
|
{
|
||||||
// emulate
|
// emulate
|
||||||
//SDL_LockMutex(ScreenMutex);
|
|
||||||
u32 nlines = NDS::RunFrame();
|
u32 nlines = NDS::RunFrame();
|
||||||
//SDL_UnlockMutex(ScreenMutex);
|
|
||||||
|
|
||||||
if (EmuRunning == 0) break;
|
if (EmuRunning == 0) break;
|
||||||
|
|
||||||
|
memcpy(ScreenBuffer, GPU::Framebuffer, 256*384*4);
|
||||||
uiAreaQueueRedrawAll(MainDrawArea);
|
uiAreaQueueRedrawAll(MainDrawArea);
|
||||||
|
|
||||||
// framerate limiter based off SDL2_gfx
|
// framerate limiter based off SDL2_gfx
|
||||||
@ -180,12 +179,9 @@ void OnAreaDraw(uiAreaHandler* handler, uiArea* area, uiAreaDrawParams* params)
|
|||||||
|
|
||||||
uiRect dorp = {0, 0, 256, 384};
|
uiRect dorp = {0, 0, 256, 384};
|
||||||
|
|
||||||
//SDL_LockMutex(ScreenMutex);
|
uiDrawBitmapUpdate(ScreenBitmap, ScreenBuffer);
|
||||||
uiDrawBitmapUpdate(ScreenBitmap, GPU::Framebuffer);
|
|
||||||
//SDL_UnlockMutex(ScreenMutex);
|
|
||||||
|
|
||||||
uiDrawBitmapDraw(params->Context, ScreenBitmap, &dorp, &dorp);
|
uiDrawBitmapDraw(params->Context, ScreenBitmap, &dorp, &dorp);
|
||||||
//printf("draw\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnAreaMouseEvent(uiAreaHandler* handler, uiArea* area, uiAreaMouseEvent* evt)
|
void OnAreaMouseEvent(uiAreaHandler* handler, uiArea* area, uiAreaMouseEvent* evt)
|
||||||
@ -248,7 +244,6 @@ int OnAreaKeyEvent(uiAreaHandler* handler, uiArea* area, uiAreaKeyEvent* evt)
|
|||||||
}
|
}
|
||||||
else if (!evt->Repeat)
|
else if (!evt->Repeat)
|
||||||
{
|
{
|
||||||
//printf("key event: %08X %08X - %s\n", evt->Scancode, evt->Modifiers, uiKeyName(evt->Scancode));
|
|
||||||
for (int i = 0; i < 10; i++)
|
for (int i = 0; i < 10; i++)
|
||||||
if (evt->Scancode == Config::KeyMapping[i]) NDS::PressKey(i);
|
if (evt->Scancode == Config::KeyMapping[i]) NDS::PressKey(i);
|
||||||
if (evt->Scancode == Config::KeyMapping[10]) NDS::PressKey(16);
|
if (evt->Scancode == Config::KeyMapping[10]) NDS::PressKey(16);
|
||||||
@ -271,7 +266,12 @@ void Run()
|
|||||||
|
|
||||||
void Stop()
|
void Stop()
|
||||||
{
|
{
|
||||||
// TODO
|
EmuRunning = 2;
|
||||||
|
RunningSomething = false;
|
||||||
|
|
||||||
|
uiMenuItemDisable(MenuItem_Pause);
|
||||||
|
uiMenuItemDisable(MenuItem_Reset);
|
||||||
|
uiMenuItemSetChecked(MenuItem_Pause, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -283,7 +283,8 @@ int OnCloseWindow(uiWindow* window, void* blarg)
|
|||||||
|
|
||||||
void OnCloseByMenu(uiMenuItem* item, uiWindow* window, void* blarg)
|
void OnCloseByMenu(uiMenuItem* item, uiWindow* window, void* blarg)
|
||||||
{
|
{
|
||||||
uiQuit();
|
// TODO????
|
||||||
|
// uiQuit() crashes
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnOpenFile(uiMenuItem* item, uiWindow* window, void* blarg)
|
void OnOpenFile(uiMenuItem* item, uiWindow* window, void* blarg)
|
||||||
@ -368,8 +369,6 @@ int main(int argc, char** argv)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//ScreenMutex = SDL_CreateMutex();
|
|
||||||
|
|
||||||
uiInitOptions ui_opt;
|
uiInitOptions ui_opt;
|
||||||
memset(&ui_opt, 0, sizeof(uiInitOptions));
|
memset(&ui_opt, 0, sizeof(uiInitOptions));
|
||||||
const char* ui_err = uiInit(&ui_opt);
|
const char* ui_err = uiInit(&ui_opt);
|
||||||
@ -431,7 +430,6 @@ int main(int argc, char** argv)
|
|||||||
EmuRunning = 0;
|
EmuRunning = 0;
|
||||||
SDL_WaitThread(EmuThread, NULL);
|
SDL_WaitThread(EmuThread, NULL);
|
||||||
|
|
||||||
//SDL_DestroyMutex(ScreenMutex);
|
|
||||||
if (ScreenBitmap) uiDrawFreeBitmap(ScreenBitmap);
|
if (ScreenBitmap) uiDrawFreeBitmap(ScreenBitmap);
|
||||||
|
|
||||||
uiUninit();
|
uiUninit();
|
||||||
|
Reference in New Issue
Block a user