cleanup screenshot memory management. fixes preview image not displaying

on gamecube
This commit is contained in:
Daryl Borth 2019-03-02 16:38:53 -07:00
parent 8421d23baa
commit 70076aff41
4 changed files with 17 additions and 20 deletions

View File

@ -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

View File

@ -956,6 +956,16 @@ void TakeScreenshot()
}
}
void ClearScreenshot()
{
if(gameScreenPng)
{
gameScreenPngSize = 0;
free(gameScreenPng);
gameScreenPng = NULL;
}
}
/****************************************************************************
* ResetVideo_Menu
*

View File

@ -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);

View File

@ -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())
{