- got rid of the EXTGUI define and associated code

- commented sdl-video.cpp
This commit is contained in:
gimmedonutnow 2006-08-01 06:47:01 +00:00
parent 2d30eb6daf
commit 4025828176
5 changed files with 433 additions and 408 deletions

View File

@ -57,10 +57,6 @@ void ParseGIInput(FCEUGI *gi)
if(gi->inputfc>=0) if(gi->inputfc>=0)
InputType[2]=gi->inputfc; InputType[2]=gi->inputfc;
cspec = gi->cspecial; cspec = gi->cspecial;
#ifdef EXTGUI
Giggles(gi->cspecial);
#endif
} }
@ -83,23 +79,17 @@ static void UpdateTopRider(void);
static uint32 JSreturn=0; static uint32 JSreturn=0;
int NoWaiting=1; int NoWaiting=1;
#ifndef EXTGUI
static void DoCheatSeq(void) static void DoCheatSeq(void)
{ {
#if defined(DOS) || defined(SDL)
SilenceSound(1); SilenceSound(1);
#endif
KillKeyboard(); KillKeyboard();
KillVideo(); KillVideo();
DoConsoleCheatConfig(); DoConsoleCheatConfig();
InitVideo(CurGame); InitVideo(CurGame);
InitKeyboard(); InitKeyboard();
#if defined(DOS) || defined(SDL)
SilenceSound(0); SilenceSound(0);
#endif
} }
#endif
#include "keyscan.h" #include "keyscan.h"
static char *keys=0; static char *keys=0;
@ -171,9 +161,7 @@ static void KeyboardCommands(void)
if(keyonly(F9)) FCEUI_SaveSnapshot(); if(keyonly(F9)) FCEUI_SaveSnapshot();
if(gametype!=GIT_NSF) if(gametype!=GIT_NSF)
{ {
#ifndef EXTGUI
if(keyonly(F2)) DoCheatSeq(); if(keyonly(F2)) DoCheatSeq();
#endif
if(keyonly(F5)) if(keyonly(F5))
{ {
if(is_shift) if(is_shift)
@ -201,13 +189,7 @@ static void KeyboardCommands(void)
if(keyonly(F10)) FCEUI_ResetNES(); if(keyonly(F10)) FCEUI_ResetNES();
if(keyonly(F11)) FCEUI_PowerNES(); if(keyonly(F11)) FCEUI_PowerNES();
#ifdef EXTGUI
if(keyonly(F3)) GUI_Hide(-1);
if(KEY(F12)) GUI_RequestExit();
if(KEY(ESCAPE)) CloseGame();
#else
if(KEY(F12) || KEY(ESCAPE)) CloseGame(); if(KEY(F12) || KEY(ESCAPE)) CloseGame();
#endif
if(gametype==GIT_VSUNI) if(gametype==GIT_VSUNI)
{ {

View File

@ -80,7 +80,6 @@ static void ParseGI(FCEUGI *gi)
gametype=gi->type; gametype=gi->type;
} }
#ifndef EXTGUI
void FCEUD_PrintError(char *s) void FCEUD_PrintError(char *s)
{ {
puts(s); puts(s);
@ -90,7 +89,6 @@ void FCEUD_Message(char *s)
{ {
fputs(s,stdout); fputs(s,stdout);
} }
#endif
static char *cpalette=0; static char *cpalette=0;
static void LoadCPalette(void) static void LoadCPalette(void)
@ -107,9 +105,6 @@ static void LoadCPalette(void)
FCEUI_SetPaletteArray(tmpp); FCEUI_SetPaletteArray(tmpp);
fclose(fp); fclose(fp);
} }
#ifdef EXTGUI
extern CFGSTRUCT GUIConfig;
#endif
static CFGSTRUCT fceuconfig[]={ static CFGSTRUCT fceuconfig[]={
AC(soundrate), AC(soundrate),
AC(soundq), AC(soundq),
@ -125,9 +120,6 @@ static CFGSTRUCT fceuconfig[]={
ACA(erendlinev), ACA(erendlinev),
ADDCFGSTRUCT(InputConfig), ADDCFGSTRUCT(InputConfig),
ADDCFGSTRUCT(DriverConfig), ADDCFGSTRUCT(DriverConfig),
#ifdef EXTGUI
ADDCFGSTRUCT(GUIConfig),
#endif
ENDCFGSTRUCT ENDCFGSTRUCT
}; };
@ -297,9 +289,6 @@ int LoadGame(const char *path)
} }
} }
isloaded=1; isloaded=1;
#ifdef EXTGUI
if(eoptions&EO_AUTOHIDE) GUI_Hide(1);
#endif
FCEUD_NetworkConnect(); FCEUD_NetworkConnect();
return 1; return 1;
@ -317,9 +306,6 @@ int CloseGame(void)
if(soundrecfn) if(soundrecfn)
FCEUI_EndWaveRecord(); FCEUI_EndWaveRecord();
#ifdef EXTGUI
GUI_Hide(0);
#endif
InputUserActiveFix(); InputUserActiveFix();
return(1); return(1);
} }
@ -361,11 +347,7 @@ int CLImain(int argc, char *argv[])
CreateDirs(); CreateDirs();
#ifdef EXTGUI
if(argc==2 && !strcmp(argv[1],"-help")) // I hope no one has a game named "-help" :b
#else
if(argc<=1) if(argc<=1)
#endif
{ {
ShowUsage(argv[0]); ShowUsage(argv[0]);
return(0); return(0);
@ -378,10 +360,6 @@ int CLImain(int argc, char *argv[])
LoadCPalette(); LoadCPalette();
/* All the config files and arguments are parsed now. */ /* All the config files and arguments are parsed now. */
#ifdef EXTGUI
return(1);
#else
if(!LoadGame(argv[argc-1])) if(!LoadGame(argv[argc-1]))
{ {
DriverKill(); DriverKill();
@ -391,13 +369,6 @@ int CLImain(int argc, char *argv[])
while(CurGame) while(CurGame)
DoFun(); DoFun();
#if(0)
{
int x;
for(x=1;x<argc;x++)
{ LoadGame(argv[x]); while(CurGame) DoFun(); }
}
#endif
CloseGame(); CloseGame();
@ -405,7 +376,6 @@ int CLImain(int argc, char *argv[])
FCEUI_Kill(); FCEUI_Kill();
#endif
return(1); return(1);
} }

View File

@ -65,7 +65,7 @@ int KillJoysticks (void)
{ {
int n; /* joystick index */ int n; /* joystick index */
if(!jinited) return(0); if(!jinited) return(-1);
for (n = 0; n < MAX_JOYSTICKS; n++) for (n = 0; n < MAX_JOYSTICKS; n++)
{ {
if (Joysticks[n] != 0) if (Joysticks[n] != 0)
@ -73,7 +73,7 @@ int KillJoysticks (void)
Joysticks[n]=0; Joysticks[n]=0;
} }
SDL_QuitSubSystem(SDL_INIT_JOYSTICK); SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
return(1); return(0);
} }
/* Initialize joysticks. */ /* Initialize joysticks. */

View File

@ -18,6 +18,9 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
/// \file
/// \brief Handles the graphical game display for the SDL implementation.
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
@ -36,15 +39,13 @@ SDL_Surface *IconSurface=NULL;
static int curbpp; static int curbpp;
static int srendline,erendline; static int srendline,erendline;
static int tlines; static int tlines;
static int inited=0; static int inited;
#ifdef OPENGL #ifdef OPENGL
extern int sdlhaveogl; extern int sdlhaveogl;
static int usingogl; static int usingogl;
static double exs,eys;
#else
static double exs,eys;
#endif #endif
static double exs,eys;
static int eefx; static int eefx;
#define NWIDTH (256-((eoptions&EO_CLIPSIDES)?16:0)) #define NWIDTH (256-((eoptions&EO_CLIPSIDES)?16:0))
@ -53,386 +54,470 @@ static int eefx;
static int paletterefresh; static int paletterefresh;
/* Return 1 if video was killed, 0 otherwise(video wasn't initialized). */ /**
int KillVideo(void) * Attempts to destroy the graphical video display. Returns 0 on
* success, -1 on failure.
*/
int
KillVideo()
{ {
if(IconSurface) // if the IconSurface has been initialized, destroy it
{ if(IconSurface) {
SDL_FreeSurface(IconSurface); SDL_FreeSurface(IconSurface);
IconSurface=0; IconSurface=0;
} }
if(inited&1) // if the rest of the system has been initialized, shut it down
{ if(inited) {
#ifdef OPENGL #ifdef OPENGL
if(usingogl) // check for OpenGL and shut it down
KillOpenGL(); if(usingogl)
else KillOpenGL();
#endif else
if(curbpp>8) #endif
KillBlitToHigh(); // shut down the system that converts from 8 to 16/32 bpp
SDL_QuitSubSystem(SDL_INIT_VIDEO); if(curbpp > 8)
inited&=~1; KillBlitToHigh();
return(1);
} // shut down the SDL video sub-system
inited=0; SDL_QuitSubSystem(SDL_INIT_VIDEO);
return(0);
inited = 0;
return 0;
}
// return failure, since the system was not initialized
// XXX soules - this seems odd to me... why is it doing this?
return -1;
} }
static int sponge; static int sponge;
int InitVideo(FCEUGI *gi) /**
* Attempts to initialize the graphical video display. Returns 0 on
* success, -1 on failure.
*/
int
InitVideo(FCEUGI *gi)
{ {
const SDL_VideoInfo *vinf; // XXX soules - const? is this necessary?
int flags=0; const SDL_VideoInfo *vinf;
int error, flags = 0;
FCEUI_printf("Initializing video..."); FCEUI_printf("Initializing video...");
FCEUI_GetCurrentVidSystem(&srendline,&erendline); // check the starting, ending, and total scan lines
FCEUI_GetCurrentVidSystem(&srendline, &erendline);
tlines = erendline - srendline + 1;
if(_fullscreen) sponge=Settings.specialfs; // XXX soules - what is the sponge variable?
else sponge=Settings.special; if(_fullscreen) {
sponge = Settings.specialfs;
} else {
sponge = Settings.special;
}
// check for OpenGL and set the global flags
#ifdef OPENGL
usingogl = 0;
if(_opengl && sdlhaveogl && !sponge) {
flags = SDL_OPENGL;
usingogl = 1;
}
#endif
// initialize the SDL video subsystem if it is not already active
if(!SDL_WasInit(SDL_INIT_VIDEO)) {
error = SDL_InitSubSystem(SDL_INIT_VIDEO);
if(error) {
FCEUD_PrintError(SDL_GetError());
return -1;
}
}
inited = 1;
// shows the cursor within the display window
SDL_ShowCursor(0);
// determine if we can allocate the display on the video card
vinf=SDL_GetVideoInfo();
if(vinf->hw_available) {
flags |= SDL_HWSURFACE;
}
// check if we are rendering fullscreen
if(_fullscreen) {
flags |= SDL_FULLSCREEN;
}
// gives the SDL exclusive palette control... ensures the requested colors
flags |= SDL_HWPALETTE;
#ifdef OPENGL // enable double buffering if requested and we have hardware support
usingogl=0; #ifdef OPENGL
if(_opengl && sdlhaveogl && !sponge) if(usingogl) {
{ FCEU_printf("Initializing with OpenGL (Disable with '-opengl 0').\n");
flags=SDL_OPENGL; if(_doublebuf) {
usingogl=1; SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
} }
#endif } else
#endif
if(_doublebuf && (flags & SDL_HWSURFACE)) {
flags |= SDL_DOUBLEBUF;
}
#ifdef EXTGUI if(_fullscreen) {
GUI_SetVideo(_fullscreen, 0, 0); int desbpp = _bpp;
#endif
if(!(SDL_WasInit(SDL_INIT_VIDEO)&SDL_INIT_VIDEO)) exs = _xscalefs;
if(SDL_InitSubSystem(SDL_INIT_VIDEO)==-1) eys = _yscalefs;
{ eefx = _efxfs;
FCEUD_PrintError(SDL_GetError());
return(0);
}
inited|=1;
SDL_ShowCursor(0); #ifdef OPENGL
tlines=erendline-srendline+1; if(!usingogl) {exs=(int)exs;eys=(int)eys;}
else desbpp=0;
vinf=SDL_GetVideoInfo(); if(sponge) {
exs = eys = 2;
if(vinf->hw_available) if(sponge == 3 || sponge == 4) {
flags|=SDL_HWSURFACE; exs = eys = 3;
}
if(_fullscreen) eefx=0;
flags|=SDL_FULLSCREEN; if(sponge == 1 || sponge == 3) {
desbpp = 32;
flags|=SDL_HWPALETTE; }
}
//flags|=SDL_DOUBLEBUF;
#ifdef OPENGL
if(usingogl)
{
FCEU_printf("\n Initializing with OpenGL(Use \"-opengl 0\" to disable).\n");
if(_doublebuf)
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
}
else
#endif
if(_doublebuf && (flags&SDL_HWSURFACE))
flags|=SDL_DOUBLEBUF;
if(_fullscreen)
{
int desbpp=_bpp;
exs=_xscalefs;
eys=_yscalefs;
eefx=_efxfs;
#ifdef OPENGL
if(!usingogl) {exs=(int)exs;eys=(int)eys;}
else desbpp=0;
if(sponge)
{
exs=eys=2;
if(sponge == 3 || sponge == 4) exs = eys = 3;
eefx=0;
if(sponge == 1 || sponge == 3) desbpp = 32;
}
if( (usingogl && !_stretchx) || !usingogl) if( (usingogl && !_stretchx) || !usingogl)
#endif #endif
if(_xres<NWIDTH*exs || exs <= 0.01) if(_xres < (NWIDTH * exs) || exs <= 0.01) {
{ FCEUD_PrintError("xscale out of bounds.");
FCEUD_PrintError("xscale out of bounds."); KillVideo();
KillVideo(); return -1;
return(0); }
}
#ifdef OPENGL #ifdef OPENGL
if( (usingogl && !_stretchy) || !usingogl) if( (usingogl && !_stretchy) || !usingogl)
#endif #endif
if(_yres<tlines*eys || eys <= 0.01) if(_yres<tlines*eys || eys <= 0.01) {
{ FCEUD_PrintError("yscale out of bounds.");
FCEUD_PrintError("yscale out of bounds."); KillVideo();
KillVideo(); return -1;
return(0); }
}
#ifdef EXTGUI
GUI_SetVideo(_fullscreen, _xres, _yres);
#endif
#ifdef OPENGL screen = SDL_SetVideoMode(_xres, _yres, desbpp, flags);
if(!(screen = SDL_SetVideoMode(_xres, _yres, desbpp, flags))) if(!screen) {
#else FCEUD_PrintError(SDL_GetError());
if(!(screen = SDL_SetVideoMode(_xres, _yres, desbpp, flags))) return -1;
#endif }
{ } else {
FCEUD_PrintError(SDL_GetError()); int desbpp=0;
return(0);
}
}
else
{
int desbpp=0;
exs=_xscale; exs=_xscale;
eys=_yscale; eys=_yscale;
eefx=_efx; eefx=_efx;
if(sponge) if(sponge) {
{ exs = eys = 2;
exs=eys=2; if(sponge >= 3) {
if(sponge >= 3) exs=eys=3; exs = eys = 3;
eefx=0; }
// SDL's 32bpp->16bpp code is slighty faster than mine, at least :/ eefx = 0;
if(sponge == 1 || sponge == 3) desbpp=32; // SDL's 32bpp->16bpp code is slighty faster than mine, at least :/
} if(sponge == 1 || sponge == 3) {
desbpp=32;
}
}
#ifdef OPENGL #ifdef OPENGL
if(!usingogl) {exs=(int)exs;eys=(int)eys;} if(!usingogl) {exs=(int)exs;eys=(int)eys;}
if(exs <= 0.01) if(exs <= 0.01)
{ {
FCEUD_PrintError("xscale out of bounds."); FCEUD_PrintError("xscale out of bounds.");
KillVideo(); KillVideo();
return(0); return -1;
} }
if(eys <= 0.01) if(eys <= 0.01)
{ {
FCEUD_PrintError("yscale out of bounds."); FCEUD_PrintError("yscale out of bounds.");
KillVideo(); KillVideo();
return(0); return -1;
} }
#endif #endif
#ifdef EXTGUI screen = SDL_SetVideoMode((int)(NWIDTH*exs), (int)(tlines*eys),
GUI_SetVideo(_fullscreen, (NWIDTH*exs), tlines*eys); desbpp, flags);
#endif if(!screen) {
FCEUD_PrintError(SDL_GetError());
return -1;
}
}
curbpp=screen->format->BitsPerPixel;
if(!screen) {
FCEUD_PrintError(SDL_GetError());
KillVideo();
return -1;
}
screen = SDL_SetVideoMode((int)(NWIDTH*exs), (int)(tlines*eys), // XXX soules - this would be creating a surface on the video
desbpp, flags); // card, but was commented out for some reason...
} //BlitBuf=SDL_CreateRGBSurface(SDL_HWSURFACE,256,240,screen->format->BitsPerPixel,screen->format->Rmask,screen->format->Gmask,screen->format->Bmask,0);
curbpp=screen->format->BitsPerPixel;
if(!screen)
{
FCEUD_PrintError(SDL_GetError());
KillVideo();
return(0);
}
//BlitBuf=SDL_CreateRGBSurface(SDL_HWSURFACE,256,240,screen->format->BitsPerPixel,screen->format->Rmask,screen->format->Gmask,screen->format->Bmask,0);
inited=1; FCEU_printf(" Video Mode: %d x %d x %d bpp %s\n",
screen->w, screen->h, screen->format->BitsPerPixel,
_fullscreen ? "full screen" : "");
FCEU_printf(" Video Mode: %d x %d x %d bpp %s\n",screen->w,screen->h,screen->format->BitsPerPixel,_fullscreen?"full screen":""); if(curbpp != 8 && curbpp != 16 && curbpp != 24 && curbpp != 32) {
if(curbpp!=16 && curbpp!=24 && curbpp!=8 && curbpp!=32) FCEU_printf(" Sorry, %dbpp modes are not supported by FCE Ultra. Supported bit depths are 8bpp, 16bpp, and 32bpp.\n", curbpp);
{ KillVideo();
FCEU_printf(" Sorry, %dbpp modes are not supported by FCE Ultra. Supported bit depths are 8bpp, 16bpp, and 32bpp.\n",curbpp); return -1;
KillVideo(); }
return(0);
}
if(gi->name) // if the game being run has a name, set it as the window name
SDL_WM_SetCaption((const char *)gi->name, (const char *)gi->name); if(gi->name) {
else SDL_WM_SetCaption((const char *)gi->name, (const char *)gi->name);
SDL_WM_SetCaption("FCE Ultra","FCE Ultra"); } else {
SDL_WM_SetCaption("FCE Ultra","FCE Ultra");
}
#ifdef LSB_FIRST // create the surface for displaying graphical messages
IconSurface=SDL_CreateRGBSurfaceFrom((void *)fceu_playicon.pixel_data,32,32,24,32*3,0xFF,0xFF00,0xFF0000,0x00); #ifdef LSB_FIRST
#else IconSurface = SDL_CreateRGBSurfaceFrom((void *)fceu_playicon.pixel_data,
IconSurface=SDL_CreateRGBSurfaceFrom((void *)fceu_playicon.pixel_data,32,32,24,32*3,0xFF0000,0xFF00,0xFF,0x00); 32, 32, 24, 32*3,
#endif 0xFF, 0xFF00, 0xFF0000, 0x00);
#else
IconSurface = SDL_CreateRGBSurfaceFrom((void *)fceu_playicon.pixel_data,
32, 32, 24, 32*3,
0xFF0000, 0xFF00, 0xFF, 0x00);
#endif
SDL_WM_SetIcon(IconSurface,0);
paletterefresh = 1;
SDL_WM_SetIcon(IconSurface,0); // XXX soules - can't SDL do this for us?
// if using more than 8bpp, initialize the conversion routines
paletterefresh=1; if(curbpp > 8)
#ifdef OPENGL
if(curbpp>8) if(!usingogl)
#ifdef OPENGL #endif
if(!usingogl) InitBlitToHigh(curbpp>>3,screen->format->Rmask,screen->format->Gmask,screen->format->Bmask,eefx,sponge);
#endif #ifdef OPENGL
InitBlitToHigh(curbpp>>3,screen->format->Rmask,screen->format->Gmask,screen->format->Bmask,eefx,sponge); if(usingogl)
#ifdef OPENGL if(!InitOpenGL((eoptions&EO_CLIPSIDES)?8:0,256-((eoptions&EO_CLIPSIDES)?8:0),srendline,erendline+1,exs,eys,eefx,_openglip,_stretchx,_stretchy,screen)) {
if(usingogl) FCEUD_PrintError("Error initializing OpenGL.");
if(!InitOpenGL((eoptions&EO_CLIPSIDES)?8:0,256-((eoptions&EO_CLIPSIDES)?8:0),srendline,erendline+1,exs,eys,eefx,_openglip,_stretchx,_stretchy,screen)) KillVideo();
{ return -1;
FCEUD_PrintError("Error initializing OpenGL."); }
KillVideo(); #endif
return(0); return 0;
}
#endif
return 1;
} }
void ToggleFS(void) /**
* Toggles the full-screen display.
*/
void
ToggleFS()
{ {
extern FCEUGI *CurGame; int error;
KillVideo(); extern FCEUGI *CurGame;
_fullscreen=!_fullscreen;
if(!InitVideo(CurGame)) // shut down the current video system
{ KillVideo();
_fullscreen=!_fullscreen;
InitVideo(CurGame); // flip the fullscreen flag
} _fullscreen = !_fullscreen;
// try to initialize the video
error = InitVideo(CurGame);
if(error) {
// if we fail, just continue with what worked before
_fullscreen = !_fullscreen;
InitVideo(CurGame);
}
} }
static SDL_Color psdl[256]; static SDL_Color psdl[256];
void FCEUD_SetPalette(uint8 index, uint8 r, uint8 g, uint8 b)
{
psdl[index].r=r;
psdl[index].g=g;
psdl[index].b=b;
paletterefresh=1; /**
* Sets the color for a particular index in the palette.
*/
void
FCEUD_SetPalette(uint8 index,
uint8 r,
uint8 g,
uint8 b)
{
psdl[index].r = r;
psdl[index].g = g;
psdl[index].b = b;
paletterefresh = 1;
} }
void FCEUD_GetPalette(uint8 index, uint8 *r, uint8 *g, uint8 *b) /**
* Gets the color for a particular index in the palette.
*/
void
FCEUD_GetPalette(uint8 index,
uint8 *r,
uint8 *g,
uint8 *b)
{ {
*r=psdl[index].r; *r = psdl[index].r;
*g=psdl[index].g; *g = psdl[index].g;
*b=psdl[index].b; *b = psdl[index].b;
} }
static void RedoPalette(void) /**
* Pushes the palette structure into the underlying video subsystem.
*/
static void
RedoPalette()
{ {
#ifdef OPENGL #ifdef OPENGL
if(usingogl) if(usingogl)
SetOpenGLPalette((uint8*)psdl); SetOpenGLPalette((uint8*)psdl);
else else
#endif #endif
{ {
if(curbpp>8) if(curbpp > 8) {
SetPaletteBlitToHigh((uint8*)psdl); SetPaletteBlitToHigh((uint8*)psdl);
else } else {
{ SDL_SetPalette(screen, SDL_PHYSPAL, psdl, 0, 256);
SDL_SetPalette(screen,SDL_PHYSPAL,psdl,0,256); }
} }
}
} }
// XXX soules - console lock/unlock unimplemented?
///Currently unimplemented.
void LockConsole(){} void LockConsole(){}
///Currently unimplemented.
void UnlockConsole(){} void UnlockConsole(){}
void BlitScreen(uint8 *XBuf)
/**
* Pushes the given buffer of bits to the screen.
*/
void
BlitScreen(uint8 *XBuf)
{ {
SDL_Surface *TmpScreen; SDL_Surface *TmpScreen;
uint8 *dest; uint8 *dest;
int xo=0,yo=0; int xo = 0, yo = 0;
if(!screen) return; if(!screen) {
return;
}
if(paletterefresh) // refresh the palette if required
{ if(paletterefresh) {
RedoPalette(); RedoPalette();
paletterefresh=0; paletterefresh=0;
} }
#ifdef OPENGL #ifdef OPENGL
if(usingogl) // OpenGL is handled separately
{ if(usingogl) {
BlitOpenGL(XBuf); BlitOpenGL(XBuf);
return; return;
} }
#endif #endif
XBuf+=srendline*256; // XXX soules - not entirely sure why this is being done yet
XBuf += srendline * 256;
if(BlitBuf) TmpScreen=BlitBuf; if(BlitBuf) {
else TmpScreen=screen; TmpScreen = BlitBuf;
} else {
TmpScreen = screen;
}
if(SDL_MUSTLOCK(TmpScreen)) // lock the display, if necessary
if(SDL_LockSurface(TmpScreen)) if(SDL_MUSTLOCK(TmpScreen)) {
{ if(SDL_LockSurface(TmpScreen) < 0) {
return; return;
} }
}
dest=(uint8*)TmpScreen->pixels; dest = (uint8*)TmpScreen->pixels;
if(_fullscreen) if(_fullscreen) {
{ xo = (int)(((TmpScreen->w - NWIDTH * exs)) / 2);
xo=(int)(((TmpScreen->w-NWIDTH*exs))/2); dest += xo * (curbpp >> 3);
dest+=xo*(curbpp>>3); if(TmpScreen->h > (tlines * eys)) {
if(TmpScreen->h>(tlines*eys)) yo = (int)((TmpScreen->h - tlines * eys) / 2);
{ dest += yo * TmpScreen->pitch;
yo=(int)((TmpScreen->h-tlines*eys)/2); }
dest+=yo*TmpScreen->pitch; }
}
}
if(curbpp>8) // XXX soules - again, I'm surprised SDL can't handle this
{ // perform the blit, converting bpp if necessary
if(BlitBuf) { if(curbpp > 8) {
Blit8ToHigh(XBuf+NOFFSET,dest, NWIDTH, tlines, TmpScreen->pitch,1,1); if(BlitBuf) {
} else { Blit8ToHigh(XBuf + NOFFSET, dest, NWIDTH, tlines,
Blit8ToHigh(XBuf+NOFFSET,dest, NWIDTH, tlines, TmpScreen->pitch, TmpScreen->pitch, 1, 1);
(int)exs,(int)eys); } else {
} Blit8ToHigh(XBuf + NOFFSET,dest, NWIDTH, tlines,
} TmpScreen->pitch, (int)exs, (int)eys);
else }
{ } else {
if(BlitBuf) { if(BlitBuf) {
Blit8To8(XBuf+NOFFSET,dest, NWIDTH, tlines, Blit8To8(XBuf + NOFFSET, dest, NWIDTH, tlines,
TmpScreen->pitch, 1, 1, 0, sponge); TmpScreen->pitch, 1, 1, 0, sponge);
} else { } else {
Blit8To8(XBuf+NOFFSET, dest, NWIDTH, tlines, Blit8To8(XBuf + NOFFSET, dest, NWIDTH, tlines,
TmpScreen->pitch, (int)exs, (int)eys, eefx, sponge); TmpScreen->pitch, (int)exs, (int)eys, eefx, sponge);
} }
} }
if(SDL_MUSTLOCK(TmpScreen))
SDL_UnlockSurface(TmpScreen);
if(BlitBuf) // unlock the display, if necessary
{ if(SDL_MUSTLOCK(TmpScreen)) {
SDL_Rect srect; SDL_UnlockSurface(TmpScreen);
SDL_Rect drect; }
srect.x=0; // if we have a hardware video buffer, do a fast video->video copy
srect.y=0; if(BlitBuf) {
srect.w=NWIDTH; SDL_Rect srect;
srect.h=tlines; SDL_Rect drect;
drect.x=0; srect.x = 0;
drect.y=0; srect.y = 0;
drect.w=(Uint16)(exs*NWIDTH); srect.w = NWIDTH;
drect.h=(Uint16)(eys*tlines); srect.h = tlines;
SDL_BlitSurface(BlitBuf, &srect,screen,&drect); drect.x = 0;
} drect.y = 0;
drect.w = (Uint16)(exs * NWIDTH);
drect.h = (Uint16)(eys * tlines);
SDL_UpdateRect(screen, xo, yo, (Uint32)(NWIDTH*exs), (Uint32)(tlines*eys)); SDL_BlitSurface(BlitBuf, &srect, screen, &drect);
}
if(screen->flags&SDL_DOUBLEBUF) // ensure that the display is updated
SDL_Flip(screen); SDL_UpdateRect(screen, xo, yo, (Uint32)(NWIDTH*exs), (Uint32)(tlines*eys));
// have to flip the displayed buffer in the case of double buffering
if(screen->flags & SDL_DOUBLEBUF) {
SDL_Flip(screen);
}
} }
uint32 PtoV(uint16 x, uint16 y) /**
* Converts an x-y coordinate in the window manager into an x-y
* coordinate on FCEU's screen.
*/
uint32
PtoV(uint16 x,
uint16 y)
{ {
y=(uint16)((double)y/eys); y = (uint16)((double)y / eys);
x=(uint16)((double)x/exs); x = (uint16)((double)x / exs);
if(eoptions&EO_CLIPSIDES) if(eoptions & EO_CLIPSIDES) {
x+=8; x += 8;
y+=srendline; }
return(x|(y<<16)); y += srendline;
return (x | (y << 16));
} }

View File

@ -140,9 +140,6 @@ void GetMouseData(uint32 *d)
uint32 t; uint32 t;
t=SDL_GetMouseState(&x,&y); t=SDL_GetMouseState(&x,&y);
#ifdef EXTGUI
GUI_GetMouseState(&t,&x,&y);
#endif
d[2]=0; d[2]=0;
if(t&SDL_BUTTON(1)) if(t&SDL_BUTTON(1))
@ -192,9 +189,6 @@ static uint8 *KeyState=NULL;
char *GetKeyboard(void) char *GetKeyboard(void)
{ {
KeyState=SDL_GetKeyState(0); KeyState=SDL_GetKeyState(0);
#ifdef EXTGUI
{ char *tmp=GUI_GetKeyboard(); if(tmp) KeyState=tmp; }
#endif
return((char *)KeyState); return((char *)KeyState);
} }
@ -207,7 +201,6 @@ char *GetKeyboard(void)
//#endif //#endif
#endif #endif
#ifndef EXTGUI
uint8 *GetBaseDirectory(void) uint8 *GetBaseDirectory(void)
{ {
uint8 *ol; uint8 *ol;
@ -240,7 +233,6 @@ uint8 *GetBaseDirectory(void)
} }
return(ret); return(ret);
} }
#endif
#ifdef OPENGL #ifdef OPENGL
int sdlhaveogl; int sdlhaveogl;
@ -295,8 +287,8 @@ void ButtonConfigEnd(void)
extern FCEUGI *CurGame; extern FCEUGI *CurGame;
KillJoysticks(); KillJoysticks();
SDL_QuitSubSystem(SDL_INIT_VIDEO); SDL_QuitSubSystem(SDL_INIT_VIDEO);
if(bcpv) InitVideo(CurGame); if(!bcpv) InitVideo(CurGame);
if(bcpj) InitJoysticks(); if(!bcpj) InitJoysticks();
} }
int DWaitButton(const uint8 *text, ButtConfig *bc, int wb) int DWaitButton(const uint8 *text, ButtConfig *bc, int wb)
@ -306,9 +298,7 @@ int DWaitButton(const uint8 *text, ButtConfig *bc, int wb)
int x,y; int x,y;
SDL_WM_SetCaption((const char *)text,0); SDL_WM_SetCaption((const char *)text,0);
#ifndef EXTGUI
puts((const char *)text); puts((const char *)text);
#endif
for(x=0;x<64;x++) for(x=0;x<64;x++)
for(y=0;y<64;y++) for(y=0;y<64;y++)
LastAx[x][y]=0x100000; LastAx[x][y]=0x100000;
@ -356,41 +346,39 @@ int DWaitButton(const uint8 *text, ButtConfig *bc, int wb)
return(0); return(0);
} }
#ifdef EXTGUI int
int FCEUSDLmain(int argc, char *argv[]) main(int argc,
#else char *argv[])
int main(int argc, char *argv[])
#endif
{ {
FCEUD_Message("\nStarting "FCEU_NAME_AND_VERSION"...\n"); FCEUD_Message("\nStarting "FCEU_NAME_AND_VERSION"...\n");
#ifdef WIN32 #ifdef WIN32
/* Taken from win32 sdl_main.c */ /* Taken from win32 sdl_main.c */
SDL_SetModuleHandle(GetModuleHandle(NULL)); SDL_SetModuleHandle(GetModuleHandle(NULL));
#endif #endif
if(SDL_Init(SDL_INIT_VIDEO)) /* SDL_INIT_VIDEO Needed for (joystick config) event processing? */ if(SDL_Init(SDL_INIT_VIDEO)) /* SDL_INIT_VIDEO Needed for (joystick config) event processing? */
{ {
printf("Could not initialize SDL: %s.\n", SDL_GetError()); printf("Could not initialize SDL: %s.\n", SDL_GetError());
return(-1); return(-1);
} }
#ifdef OPENGL #ifdef OPENGL
#ifdef APPLEOPENGL #ifdef APPLEOPENGL
sdlhaveogl = 1; /* Stupid something... Hack. */ sdlhaveogl = 1; /* Stupid something... Hack. */
#else #else
if(!SDL_GL_LoadLibrary(0)) sdlhaveogl=1; if(!SDL_GL_LoadLibrary(0)) sdlhaveogl=1;
else sdlhaveogl=0; else sdlhaveogl=0;
#endif #endif
#endif #endif
SetDefaults(); SetDefaults();
{ {
int ret=CLImain(argc,argv); int ret=CLImain(argc,argv);
SDL_Quit(); SDL_Quit();
return(ret?0:-1); return(ret?0:-1);
} }
} }
@ -418,6 +406,6 @@ DUMMY(FCEUD_ToggleStatusIcon)
DUMMY(FCEUD_AviRecordTo) DUMMY(FCEUD_AviRecordTo)
DUMMY(FCEUD_AviStop) DUMMY(FCEUD_AviStop)
void FCEUI_AviVideoUpdate(const unsigned char* buffer) {FCEU_DispMessage("Not implemented.");} void FCEUI_AviVideoUpdate(const unsigned char* buffer) {FCEU_DispMessage("Not implemented.");}
int FCEUD_ShowStatusIcon(void) {FCEU_DispMessage("Not implemented."); return 0; } int FCEUD_ShowStatusIcon(void) {return 0;}
int FCEUI_AviIsRecording(void) {return 0;} int FCEUI_AviIsRecording(void) {return 0;}