winport - fix memory of custom palettes (part of #711)

This commit is contained in:
zeromus 2015-09-16 22:01:33 +00:00
parent aaf41d9c78
commit fe687d30f3
4 changed files with 10 additions and 6 deletions

View File

@ -227,6 +227,7 @@ static CFGSTRUCT fceuconfig[] =
AC(goptions),
NAC("eoptions",eoptions),
NACA("cpalette",cpalette),
NAC("cpalette_count",cpalette_count),
NACA("InputType",InputType),

View File

@ -683,11 +683,11 @@ int main(int argc,char *argv[])
DoVideoConfigFix();
DoTimingConfigFix();
//TODO - how can this do anything? we havent set a palette yet
//if(eoptions & EO_CPALETTE)
//{
// FCEUI_SetUserPalette(cpalette);
//}
//restore the last user-set palette (cpalette and cpalette_count are preserved in the config file)
if(eoptions & EO_CPALETTE)
{
FCEUI_SetUserPalette(cpalette,cpalette_count);
}
if(!t)
{

View File

@ -107,6 +107,7 @@ extern int soundquality;
extern bool muteTurbo;
extern bool swapDuty;
extern int cpalette_count;
extern uint8 cpalette[64*8*3];
extern int srendlinen;
extern int erendlinen;

View File

@ -4,6 +4,7 @@
#include "window.h"
#include "gui.h"
int cpalette_count = 0;
u8 cpalette[64*8*3] = {0};
extern int palhue;
extern bool palhdtv;
@ -17,7 +18,8 @@ bool SetPalette(const char* nameo)
{
int readed = fread(cpalette, 1, sizeof(cpalette), fp);
fclose(fp);
FCEUI_SetUserPalette(cpalette,readed/3);
cpalette_count = readed/3;
FCEUI_SetUserPalette(cpalette,cpalette_count);
eoptions |= EO_CPALETTE;
return true;
}