After much effort, added NTSC 2x scaler option to both Windows and SDL. Includes new config option NTSCwinspecial.

This commit is contained in:
ugetab 2010-05-21 20:36:24 +00:00
parent 4e83ad049d
commit e5f12da441
14 changed files with 1732 additions and 1601 deletions

View File

@ -1,3 +1,4 @@
20-may-2010 - ugetab - Added NTSC 2x scalar option with some CFG config options of it's own
20-may-2010 - Cah4e3 - Win32 - CDLogger - fixed bug preventing correct interrupt vectors from logging
19-may-2010 - ugetab/adelikat - Win32 - Added single-instance mode, which makes starting a second copy of FCEUX load the file into the first, then exit.Mode off by default, togglable under Config -> GUI
18-may-2010 - adelikat - Movie + loadstate errors are handled more gracefully now, more informative error messages and the movie doesn't have to stop

View File

@ -25,6 +25,11 @@
#include "../../types.h"
#include "nes_ntsc.h"
nes_ntsc_t* nes_ntsc;
uint8 burst_phase = 0;
static uint32 CBM[3];
static uint32 *palettetranslate=0;
@ -36,7 +41,7 @@ static int backBpp, backshiftr[3], backshiftl[3];
//static uint32 backmask[3];
static uint8 *specbuf8bpp = NULL; // For 2xscale, 3xscale.
uint8 *ntscblit = NULL; // For nes_ntsc
static int silt;
@ -75,16 +80,51 @@ static void CalculateShift(uint32 *CBM, int *cshiftr, int *cshiftl)
}
int InitBlitToHigh(int b, uint32 rmask, uint32 gmask, uint32 bmask, int efx, int specfilt)
int InitBlitToHigh(int b, uint32 rmask, uint32 gmask, uint32 bmask, int efx, int specfilt, int specfilteropt)
{
if(specfilt == 2 || specfilt == 4) // scale2x and scale3x
// -Video Modes Tag-
if(specfilt == 3) // NTSC 2x
{
int multi = (2 * 2);
//nes_ntsc variables
nes_ntsc_setup_t ntsc_setup = nes_ntsc_composite;
switch (specfilteropt)
{
//case 0: // Composite
//ntsc_setup = nes_ntsc_composite;
//break;
case 1: //S-Video
ntsc_setup = nes_ntsc_svideo;
break;
case 2: //RGB
ntsc_setup = nes_ntsc_rgb;
break;
case 3: //Monochrome
ntsc_setup = nes_ntsc_monochrome;
break;
}
nes_ntsc = (nes_ntsc_t*) malloc( sizeof (nes_ntsc_t) );
if ( nes_ntsc ) {
nes_ntsc_init( nes_ntsc, &ntsc_setup, b, 2 );
ntscblit = (uint8*)malloc(256*257*b*multi); //Need to add multiplier for larger sizes
}
} // -Video Modes Tag-
else if(specfilt == 2 || specfilt == 5) // scale2x and scale3x
{
int multi = ((specfilt == 2) ? 2 * 2 : 3 * 3);
specbuf8bpp = (uint8*)malloc(256*240*multi); //mbg merge 7/17/06 added cast
}
else if(specfilt == 1 || specfilt == 3) // hq2x and hq3x
} // -Video Modes Tag-
else if(specfilt == 1 || specfilt == 4) // hq2x and hq3x
{
if(b == 1)
return(0);
@ -116,8 +156,9 @@ int InitBlitToHigh(int b, uint32 rmask, uint32 gmask, uint32 bmask, int efx, int
// backshiftr[x] -= backshiftl[x];
// End iffy code
}
// -Video Modes Tag-
if(specfilt == 1) specbuf32bpp = (uint32*)malloc(256*240*4*sizeof(uint32)); //mbg merge 7/17/06 added cast
else if(specfilt == 3) specbuf32bpp = (uint32*)malloc(256*240*9*sizeof(uint32)); //mbg merge 7/17/06 added cast
else if(specfilt == 4) specbuf32bpp = (uint32*)malloc(256*240*9*sizeof(uint32)); //mbg merge 7/17/06 added cast
}
efx=0;
@ -126,7 +167,8 @@ int InitBlitToHigh(int b, uint32 rmask, uint32 gmask, uint32 bmask, int efx, int
gmask=0x3F<<5;
bmask=0x1F;
if(specfilt == 3)
// -Video Modes Tag-
if(specfilt == 4)
hq3x_InitLUTs();
else
hq2x_InitLUTs();
@ -188,12 +230,21 @@ void KillBlitToHigh(void)
}
if(specbuf)
{
if(silt == 3)
// -Video Modes Tag-
if(silt == 4)
hq3x_Kill();
else
hq2x_Kill();
specbuf=NULL;
}
if (nes_ntsc) {
free(nes_ntsc);
nes_ntsc = NULL;
}
if (ntscblit) {
free(ntscblit);
ntscblit = NULL;
}
}
@ -348,6 +399,11 @@ void Blit8To8(uint8 *src, uint8 *dest, int xr, int yr, int pitch, int xscale, in
int x,y;
int pinc;
// -Video Modes Tag-
if(special==3) //NTSC 2x
return; //Incompatible with 8-bit output. This is here for SDL.
// -Video Modes Tag-
if(special==2)
{
if(xscale!=2 || yscale!=2) return;
@ -356,7 +412,8 @@ void Blit8To8(uint8 *src, uint8 *dest, int xr, int yr, int pitch, int xscale, in
return;
}
if(special==4)
// -Video Modes Tag-
if(special==5)
{
if(xscale!=3 || yscale!=3) return;
scale(3,dest,pitch,src,256,1,xr,yr);
@ -442,6 +499,7 @@ void Blit8ToHigh(uint8 *src, uint8 *dest, int xr, int yr, int pitch,
int mult;
int base;
// -Video Modes Tag-
if(silt == 2) mult = 2;
else mult = 3;
@ -673,31 +731,43 @@ void Blit8ToHigh(uint8 *src, uint8 *dest, int xr, int yr, int pitch,
switch(Bpp)
{
case 4:
pinc=pitch-((xr*xscale)<<2);
for(y=yr;y;y--,src+=256-xr)
{
int doo=yscale;
if(highefx& FVB_SCANLINES)
doo-=yscale>>1;
do
if ( nes_ntsc ) {
burst_phase ^= 1;
nes_ntsc_blit( nes_ntsc, (unsigned char*)src, xr, burst_phase,
xr, yr, ntscblit, xr * Bpp * xscale );
//Multiply 4 by the multiplier on output, because it's 4 bpp
//Top 2 lines = line 3, due to distracting flicker
//memcpy(dest,ntscblit+(Bpp * xscale)+(Bpp * xr * xscale),(Bpp * xr * xscale));
//memcpy(dest+(Bpp * xr * xscale),ntscblit+(Bpp * xscale)+(Bpp * xr * xscale * 2),(Bpp * xr * xscale));
memcpy(dest+(Bpp * xr * xscale),ntscblit+(Bpp * xscale),(xr*yr*Bpp*xscale*yscale));
} else {
pinc=pitch-((xr*xscale)<<2);
for(y=yr;y;y--,src+=256-xr)
{
for(x=xr;x;x--,src++)
int doo=yscale;
if(highefx& FVB_SCANLINES)
doo-=yscale>>1;
do
{
int too=xscale;
do
for(x=xr;x;x--,src++)
{
*(uint32 *)dest=palettetranslate[*src];
dest+=4;
} while(--too);
}
src-=xr;
dest+=pinc;
} while(--doo);
src+=xr;
if(highefx&FVB_SCANLINES)
dest+=pitch*(yscale>>1);
}
int too=xscale;
do
{
*(uint32 *)dest=palettetranslate[*src];
dest+=4;
} while(--too);
}
src-=xr;
dest+=pinc;
} while(--doo);
src+=xr;
if(highefx&FVB_SCANLINES)
dest+=pitch*(yscale>>1);
}
}
break;
case 3:
@ -817,9 +887,10 @@ void Blit8ToHigh(uint8 *src, uint8 *dest, int xr, int yr, int pitch,
{
if(specbuf32bpp)
{
int mult = (silt == 3)?3:2;
// -Video Modes Tag-
int mult = (silt == 4)?3:2;
if(silt == 3)
if(silt == 4)
hq3x_32((uint8 *)specbuf,(uint8*)specbuf32bpp,xr,yr,xr*3*sizeof(uint32));
else
hq2x_32((uint8 *)specbuf,(uint8*)specbuf32bpp,xr,yr,xr*2*sizeof(uint32));
@ -831,7 +902,8 @@ void Blit8ToHigh(uint8 *src, uint8 *dest, int xr, int yr, int pitch,
}
else
{
if(silt == 3)
// -Video Modes Tag-
if(silt == 4)
hq3x_32((uint8 *)specbuf,destbackup,xr,yr,pitchbackup);
else
hq2x_32((uint8 *)specbuf,destbackup,xr,yr,pitchbackup);

View File

@ -18,7 +18,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
int InitBlitToHigh(int b, uint32 rmask, uint32 gmask, uint32 bmask, int eefx, int specfilt);
int InitBlitToHigh(int b, uint32 rmask, uint32 gmask, uint32 bmask, int eefx, int specfilt, int specfilteropt);
void SetPaletteBlitToHigh(uint8 *src);
void KillBlitToHigh(void);
void Blit8ToHigh(uint8 *src, uint8 *dest, int xr, int yr, int pitch, int xscale, int yscale);

File diff suppressed because it is too large Load Diff

View File

@ -216,9 +216,9 @@ InitOpenGL(int l,
HiBuffer=malloc(4*256*256);
memset(HiBuffer,0x00,4*256*256);
#ifndef LSB_FIRST
InitBlitToHigh(4,0xFF000000,0xFF0000,0xFF00,efx&2,0);
InitBlitToHigh(4,0xFF000000,0xFF0000,0xFF00,efx&2,0,0);
#else
InitBlitToHigh(4,0xFF,0xFF00,0xFF0000,efx&2,0);
InitBlitToHigh(4,0xFF,0xFF00,0xFF0000,efx&2,0,0);
#endif
}

View File

@ -279,15 +279,16 @@ InitVideo(FCEUGI *gi)
} else {
desbpp = 0;
}
// -Video Modes Tag-
if(s_sponge) {
if(s_sponge == 3 || s_sponge == 4) {
if(s_sponge == 4 || s_sponge == 5) {
s_exs = s_eys = 3;
} else {
s_exs = s_eys = 2;
}
s_eefx = 0;
if(s_sponge == 1 || s_sponge == 3) {
if(s_sponge == 1 || s_sponge == 4) {
desbpp = 32;
}
}
@ -322,9 +323,10 @@ InitVideo(FCEUGI *gi)
g_config->getOption("SDL.XScale", &s_exs);
g_config->getOption("SDL.YScale", &s_eys);
g_config->getOption("SDL.SpecialFX", &s_eefx);
// -Video Modes Tag-
if(s_sponge) {
if(s_sponge >= 3) {
if(s_sponge >= 4) {
s_exs = s_eys = 3;
} else {
s_exs = s_eys = 2;
@ -416,7 +418,7 @@ InitVideo(FCEUGI *gi)
s_screen->format->Rmask,
s_screen->format->Gmask,
s_screen->format->Bmask,
s_eefx, s_sponge);
s_eefx, s_sponge, 0);
#ifdef OPENGL
if(s_useOpenGL)
{

View File

@ -71,6 +71,7 @@ int mutecapture;
#endif
static int noconfig;
// -Video Modes Tag- : See --special
char *DriverUsage="\
Option Value Description\n\
--pal {0|1} Use PAL timing.\n\
@ -90,7 +91,7 @@ Option Value Description\n\
--fullscreen {0|1} Enable full screen mode.\n\
--noframe {0|1} Hide title bar and window decorations.\n\
--special {1-4} Use special video scaling filters\n\
(1 = hq2x 2 = Scale2x 3 = hq3x 4 = Scale3x)\n\
(1 = hq2x 2 = Scale2x 3 = NTSC 2x 4 = hq3x 5 = Scale3x)\n\
--palette f Load custom global palette from file f.\n\
--sound {0|1} Enable sound.\n\
--soundrate x Set sound playback rate to x Hz.\n\

View File

@ -168,6 +168,7 @@ static CFGSTRUCT fceuconfig[] = {
NACS("odbase",directory_names[13]),
AC(winspecial),
AC(NTSCwinspecial),
AC(winsizemulx),
AC(winsizemuly),
NAC("saspectw987",saspectw),

View File

@ -42,6 +42,7 @@ int fssync=0;
int winsync=0;
int winspecial = 0;
int NTSCwinspecial = 0;
int vmod = 0;
vmdef vmodes[11]={
@ -197,9 +198,18 @@ static int GetBPP(void)
static int InitBPPStuff(int fs)
{
int specfilteropt = 0;
switch (winspecial)
{
case 3:
specfilteropt = NTSCwinspecial;
break;
}
if(bpp >= 16)
{
InitBlitToHigh(bpp >> 3, CBM[0], CBM[1], CBM[2], 0, fs?vmodes[vmod].special:winspecial);
InitBlitToHigh(bpp >> 3, CBM[0], CBM[1], CBM[2], 0, fs?vmodes[vmod].special:winspecial,specfilteropt);
}
else if(bpp==8)
{
@ -241,9 +251,10 @@ int SetVideoMode(int fs)
if(!fs)
{
if(winspecial == 2 || winspecial == 1)
// -Video Modes Tag-
if(winspecial <= 3 && winspecial >= 1)
specmul = 2;
else if(winspecial == 3 || winspecial == 4)
else if(winspecial >= 4 && winspecial <= 5)
specmul = 3;
else
specmul = 1;
@ -334,9 +345,10 @@ int SetVideoMode(int fs)
{
if(vmod == 0)
{
if(vmodes[0].special == 2 || vmodes[0].special == 1)
// -Video Modes Tag-
if(vmodes[0].special <= 3 && vmodes[0].special >= 1)
specmul = 2;
else if(vmodes[0].special == 3 || vmodes[0].special == 4)
else if(vmodes[0].special >= 4 && vmodes[0].special <= 5)
specmul = 3;
else
specmul = 1;
@ -483,9 +495,10 @@ static void BlitScreenWindow(unsigned char *XBuf)
if (!lpDDSBack) return;
if(winspecial == 2 || winspecial == 1)
// -Video Modes Tag-
if(winspecial <= 3 && winspecial >= 1)
specialmul = 2;
else if(winspecial == 4 || winspecial == 3)
else if(winspecial >= 4 && winspecial <= 5)
specialmul = 3;
else specialmul = 1;
@ -544,9 +557,10 @@ static void BlitScreenFull(uint8 *XBuf)
RECT srect,drect;
LPDIRECTDRAWSURFACE7 lpDDSVPrimary;
int specmul; // Special scaler size multiplier
if(vmodes[0].special == 2 || vmodes[0].special == 1)
// -Video Modes Tag-
if(vmodes[0].special <= 3 && vmodes[0].special >= 1)
specmul = 2;
else if(vmodes[0].special == 3 || vmodes[0].special == 4)
else if(vmodes[0].special >= 4 && vmodes[0].special <= 5)
specmul = 3;
else
specmul = 1;
@ -739,6 +753,7 @@ static void BlitScreenFull(uint8 *XBuf)
{
if(!(vmodes[vmod].flags&VMDF_DXBLT))
{
// -Video Modes Tag-
if(vmodes[vmod].special)
ScreenLoc += (vmodes[vmod].drect.left*(bpp>>3)) + ((vmodes[vmod].drect.top)*pitch);
else
@ -752,6 +767,7 @@ static void BlitScreenFull(uint8 *XBuf)
else
{
XBuf+=FSettings.FirstSLine*256+VNSCLIP;
// -Video Modes Tag-
if(vmodes[vmod].special)
Blit8To8(XBuf,(uint8*)ScreenLoc, VNSWID, FSettings.TotalScanlines(), pitch,vmodes[vmod].xscale,vmodes[vmod].yscale,0,vmodes[vmod].special); //mbg merge 7/17/06 added cast
else
@ -887,7 +903,8 @@ static int RecalcCustom(void)
cmode->drect.right=cmode->drect.left+VNSWID*cmode->xscale;
}
if((cmode->special == 1 || cmode->special == 3) && cmode->bpp == 8)
// -Video Modes Tag-
if((cmode->special == 1 || cmode->special == 4) && cmode->bpp == 8)
{
cmode->bpp = 32;
//FCEUD_PrintError("HQ2x/HQ3x requires 16bpp or 32bpp(best).");
@ -963,9 +980,10 @@ BOOL CALLBACK VideoConCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
CheckRadioButton(hwndDlg,IDC_RADIO_SCALE,IDC_RADIO_STRETCH,(vmodes[0].flags&VMDF_STRFS)?IDC_RADIO_STRETCH:IDC_RADIO_SCALE);
{
char *str[]={"<none>","hq2x","Scale2x","hq3x","Scale3x"};
// -Video Modes Tag-
char *str[]={"<none>","hq2x","Scale2x","NTSC 2x","hq3x","Scale3x"};
int x;
for(x=0;x<5;x++)
for(x=0;x<6;x++)
{
SendDlgItemMessage(hwndDlg,IDC_VIDEOCONFIG_SCALER_FS,CB_ADDSTRING,0,(LPARAM)(LPSTR)str[x]);
SendDlgItemMessage(hwndDlg,IDC_VIDEOCONFIG_SCALER_WIN,CB_ADDSTRING,0,(LPARAM)(LPSTR)str[x]);

View File

@ -40,6 +40,7 @@ typedef struct {
// left, top, right, bottom
extern vmdef vmodes[11];
extern int winspecial;
extern int NTSCwinspecial;
extern int disvaccel;
extern int fssync;

View File

@ -2269,8 +2269,9 @@ void FixWXY(int pref)
}
if(winspecial)
{
// -Video Modes Tag-
int mult;
if(winspecial == 1 || winspecial == 2) mult = 2;
if(winspecial >= 1 && winspecial <= 3) mult = 2;
else mult = 3;
if(winsizemulx < mult)
{

View File

@ -323,6 +323,7 @@
<ClCompile Include="..\src\drivers\common\configSys.cpp" />
<ClCompile Include="..\src\drivers\common\hq2x.cpp" />
<ClCompile Include="..\src\drivers\common\hq3x.cpp" />
<ClCompile Include="..\src\drivers\common\nes_ntsc.c" />
<ClCompile Include="..\src\drivers\common\scale2x.cpp" />
<ClCompile Include="..\src\drivers\common\scale3x.cpp" />
<ClCompile Include="..\src\drivers\common\scalebit.cpp" />
@ -686,6 +687,9 @@
<ClInclude Include="..\src\drivers\common\configSys.h" />
<ClInclude Include="..\src\drivers\common\hq2x.h" />
<ClInclude Include="..\src\drivers\common\hq3x.h" />
<ClInclude Include="..\src\drivers\common\nes_ntsc.h" />
<ClInclude Include="..\src\drivers\common\nes_ntsc_config.h" />
<ClInclude Include="..\src\drivers\common\nes_ntsc_impl.h" />
<ClInclude Include="..\src\drivers\common\scale2x.h" />
<ClInclude Include="..\src\drivers\common\scale3x.h" />
<ClInclude Include="..\src\drivers\common\scalebit.h" />

View File

@ -907,6 +907,9 @@
<ClCompile Include="..\src\wave.cpp" />
<ClCompile Include="..\src\x6502.cpp" />
<ClCompile Include="..\src\emufile.cpp" />
<ClCompile Include="..\src\drivers\common\nes_ntsc.c">
<Filter>drivers\common</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\src\drivers\common\args.h">
@ -1342,6 +1345,15 @@
<Filter>drivers\win\lua</Filter>
</ClInclude>
<ClInclude Include="..\src\emufile.h" />
<ClInclude Include="..\src\drivers\common\nes_ntsc.h">
<Filter>drivers\common</Filter>
</ClInclude>
<ClInclude Include="..\src\drivers\common\nes_ntsc_config.h">
<Filter>drivers\common</Filter>
</ClInclude>
<ClInclude Include="..\src\drivers\common\nes_ntsc_impl.h">
<Filter>drivers\common</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\src\drivers\win\res.rc">

View File

@ -798,6 +798,22 @@
RelativePath="..\src\drivers\common\hq3x.h"
>
</File>
<File
RelativePath="..\src\drivers\common\nes_ntsc.c"
>
</File>
<File
RelativePath="..\src\drivers\common\nes_ntsc.h"
>
</File>
<File
RelativePath="..\src\drivers\common\nes_ntsc_config.h"
>
</File>
<File
RelativePath="..\src\drivers\common\nes_ntsc_impl.h"
>
</File>
<File
RelativePath="..\src\drivers\common\scale2x.cpp"
>