diff --git a/source/fceugx.cpp b/source/fceugx.cpp index d0456b4..948b90a 100644 --- a/source/fceugx.cpp +++ b/source/fceugx.cpp @@ -413,12 +413,10 @@ int main(int argc, char *argv[]) #ifdef USE_VM savebuffer = (unsigned char *)vm_malloc(SAVEBUFFERSIZE); browserList = (BROWSERENTRY *)vm_malloc(sizeof(BROWSERENTRY)*MAX_BROWSER_SIZE); - gameScreenPng = (u8 *)vm_malloc(512*1024); nesrom = (unsigned char *)vm_malloc(1024*1024*4); #else savebuffer = (unsigned char *)memalign(32,SAVEBUFFERSIZE); browserList = (BROWSERENTRY *)memalign(32,sizeof(BROWSERENTRY)*MAX_BROWSER_SIZE); - gameScreenPng = (u8 *)memalign(32,512*1024); nesrom = (unsigned char *)memalign(32,1024*1024*4); #endif diff --git a/source/gcvideo.cpp b/source/gcvideo.cpp index 447b56e..e137180 100644 --- a/source/gcvideo.cpp +++ b/source/gcvideo.cpp @@ -956,6 +956,16 @@ void TakeScreenshot() } } +void ClearScreenshot() +{ + if(gameScreenPng) + { + gameScreenPngSize = 0; + free(gameScreenPng); + gameScreenPng = NULL; + } +} + /**************************************************************************** * ResetVideo_Menu * diff --git a/source/gcvideo.h b/source/gcvideo.h index 1d1b655..4ade1a8 100644 --- a/source/gcvideo.h +++ b/source/gcvideo.h @@ -30,6 +30,7 @@ void SyncSpeed(); void SetPalette(); void ResetVideo_Menu (); void TakeScreenshot(); +void ClearScreenshot(); void Menu_Render (); void Menu_DrawImg(f32 xpos, f32 ypos, u16 width, u16 height, u8 data[], f32 degrees, f32 scaleX, f32 scaleY, u8 alphaF ); void Menu_DrawRectangle(f32 x, f32 y, f32 width, f32 height, GXColor color, u8 filled); diff --git a/source/menu.cpp b/source/menu.cpp index 1ffaf6b..6bbbb7a 100644 --- a/source/menu.cpp +++ b/source/menu.cpp @@ -51,14 +51,11 @@ static GuiImageData * pointer[4]; #ifdef HW_RVL #include "mem2.h" -#endif -#ifdef USE_VM - #include "vmalloc.h" - #define MEM_ALLOC(A) (u8*)vm_malloc(A) - #define MEM_DEALLOC(A) vm_free(A) + #define MEM_ALLOC(A) (u8*)mem2_malloc(A) + #define MEM_DEALLOC(A) mem2_free(A) #else - #define MEM_ALLOC(A) (u8*)memalign(32,A) + #define MEM_ALLOC(A) (u8*)memalign(32, A) #define MEM_DEALLOC(A) free(A) #endif @@ -1571,8 +1568,7 @@ static int MenuGame() delete gameScreenImg; delete gameScreen; gameScreen = NULL; - free(gameScreenPng); - gameScreenPng = NULL; + ClearScreenshot(); if(GCSettings.AutoloadGame) { ExitApp(); } @@ -4279,16 +4275,8 @@ MainMenu (int menu) if(gameScreen) delete gameScreen; - if(gameScreenPng) - { - #ifdef USE_VM - vm_free(gameScreenPng); - #else - free(gameScreenPng); - #endif - gameScreenPng = NULL; - } - + ClearScreenshot(); + // wait for keys to be depressed while(MenuRequested()) {