void WritePalette(void) { int x; for(x=0;x<7;x++) FCEUD_SetPalette(x,unvpalette[x].r,unvpalette[x].g,unvpalette[x].b); if(GameInfo->type==GIT_NSF) { #ifdef _S9XLUA_H FCEU_LuaUpdatePalette(); #endif //for(x=0;x<128;x++) // FCEUD_SetPalette(x,x,0,x); } else { for(x=0;x<64;x++) FCEUD_SetPalette(128+x,palo[x].r,palo[x].g,palo[x].b); SetNESDeemph(lastd,1); } }
void WritePalette(void) { int x; //set the 'unvarying' palettes to low < 64 palette entries for(x=0;x<7;x++) FCEUD_SetPalette(x,palette_unvarying[x].r,palette_unvarying[x].g,palette_unvarying[x].b); //clear everything else to a deterministic state. //it seems likely that the text rendering on NSF has been broken since the beginning of fceux, depending on palette entries 205,205,205 everywhere //this was just whatever msvc filled malloc with. on non-msvc platforms, there was no backdrop on the rendering. for(x=7;x<256;x++) FCEUD_SetPalette(x,205,205,205); //sets palette entries >= 128 with the 64 selected main colors for(x=0;x<64;x++) FCEUD_SetPalette(128+x,palo[x].r,palo[x].g,palo[x].b); SetNESDeemph_OldHacky(lastd,1); #ifdef _S9XLUA_H FCEU_LuaUpdatePalette(); #endif }
void SetNESDeemph(uint8 d, int force) { static uint16 rtmul[7]={32768*1.239,32768*.794,32768*1.019,32768*.905,32768*1.023,32768*.741,32768*.75}; static uint16 gtmul[7]={32768*.915,32768*1.086,32768*.98,32768*1.026,32768*.908,32768*.987,32768*.75}; static uint16 btmul[7]={32768*.743,32768*.882,32768*.653,32768*1.277,32768*.979,32768*.101,32768*.75}; uint32 r,g,b; int x; /* If it's not forced(only forced when the palette changes), don't waste cpu time if the same deemphasis bits are set as the last call. */ if(!force) { if(d==lastd) return; } else /* Only set this when palette has changed. */ { #ifdef _S9XLUA_H FCEU_LuaUpdatePalette(); #endif r=rtmul[6]; g=rtmul[6]; b=rtmul[6]; for(x=0;x<0x40;x++) { uint32 m,n,o; m=palo[x].r; n=palo[x].g; o=palo[x].b; m=(m*r)>>15; n=(n*g)>>15; o=(o*b)>>15; if(m>0xff) m=0xff; if(n>0xff) n=0xff; if(o>0xff) o=0xff; FCEUD_SetPalette(x|0xC0,m,n,o); } } if(!d) return; /* No deemphasis, so return. */ r=rtmul[d-1]; g=gtmul[d-1]; b=btmul[d-1]; for(x=0;x<0x40;x++) { uint32 m,n,o; m=palo[x].r; n=palo[x].g; o=palo[x].b; m=(m*r)>>15; n=(n*g)>>15; o=(o*b)>>15; if(m>0xff) m=0xff; if(n>0xff) n=0xff; if(o>0xff) o=0xff; FCEUD_SetPalette(x|0x40,m,n,o); } lastd=d; #ifdef _S9XLUA_H FCEU_LuaUpdatePalette(); #endif }