Added Left-Control key for fire button on joystick 0.

Changed the key for entering fullscreen mode on the SDL version
from F11 to Alt-Enter.  Will make the same change in the X11
version when I figure out how :)

Changed '-showfps' to '-showinfo' since it was showing more than the
fps anyway.  Added printing of the romname and md5sum to this option.

Temporarily removed support for fullscreen snapshot support in the
SDL version.  Windowed snapshot mode is still available in X and SDL.

Changed the requirements for snapshot support.  Now requires regular
Imlib instead of Imlib2.  More users have Imlib than Imlib2.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@40 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2002-02-03 16:51:22 +00:00
parent de2df715ea
commit 9fb178961d
4 changed files with 150 additions and 141 deletions

View File

@ -13,7 +13,7 @@
## See the file "license" for information on usage and redistribution of
## this file, and for a DISCLAIMER OF ALL WARRANTIES.
##
## $Id: makefile,v 1.6 2002-01-18 16:04:46 estolberg Exp $
## $Id: makefile,v 1.7 2002-02-03 16:51:21 stephena Exp $
##============================================================================
##============================================================================
@ -50,8 +50,8 @@ OPTIMIZATIONS =
### to include support for saving snapshots in png format
### (X and SDL versions only)
### (requires you to install Imlib2)
# IMLIB2_SNAPSHOT = 1
### (requires you to install Imlib)
# IMLIB_SNAPSHOT = 1
##============================================================================
## All done, type make to get a list of frontends
@ -104,13 +104,13 @@ ifdef LINUX_JOYSTICK
OPTS.X11 += -DLINUX_JOYSTICK
endif
ifdef IMLIB2_SNAPSHOT
OPTS.X11 += -DIMLIB2_SNAPSHOT
LIBS.X11 += `imlib2-config --libs`
CFLAGS.X11 += `imlib2-config --cflags`
OPTS.SDL += -DIMLIB2_SNAPSHOT
LIBS.SDL += `imlib2-config --libs`
CFLAGS.SDL += `imlib2-config --cflags`
ifdef IMLIB_SNAPSHOT
OPTS.X11 += -DIMLIB_SNAPSHOT
LIBS.X11 += `imlib-config --libs`
CFLAGS.X11 += `imlib-config --cflags`
OPTS.SDL += -DIMLIB_SNAPSHOT
LIBS.SDL += `imlib-config --libs`
CFLAGS.SDL += `imlib-config --cflags`
endif

View File

@ -22,7 +22,7 @@
;center = <0|1>
;volume = <number>
;paddle = <0|1|2|3|real>
;showfps = <0|1>
;showinfo = <0|1>
;fullscreen = <0|1>
;ssdir = <pathname>
;ssname = <romname|md5sum>

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: mainSDL.cxx,v 1.6 2002-02-01 02:13:08 stephena Exp $
// $Id: mainSDL.cxx,v 1.7 2002-02-03 16:51:22 stephena Exp $
//============================================================================
#include <assert.h>
@ -40,8 +40,10 @@
#include "System.hxx"
#include "SndUnix.hxx"
#ifdef IMLIB2_SNAPSHOT
#include <Imlib2.h>
#ifdef IMLIB_SNAPSHOT
#include <Imlib.h>
ImlibData* imlibData;
// The path to save snapshot files
string theSnapShotDir = "";
@ -84,6 +86,8 @@ static Display* theX11Display;
static Window theX11Window;
static int theX11Screen;
static int mouseX = 0;
static bool x11Available = false;
static SDL_SysWMinfo info;
// SDL colors palette
static Uint32 colors[256];
@ -127,6 +131,7 @@ static Switches list[] = {
{ SDLK_RIGHT, Event::JoystickZeroRight },
{ SDLK_SPACE, Event::JoystickZeroFire },
{ SDLK_RETURN, Event::JoystickZeroFire },
{ SDLK_LCTRL, Event::JoystickZeroFire },
{ SDLK_z, Event::BoosterGripZeroTrigger },
{ SDLK_x, Event::BoosterGripZeroBooster },
@ -193,7 +198,7 @@ bool theGrabMouseFlag = false;
bool theCenterWindowFlag = false;
// Indicates whether to show some game info on program exit
bool theShowFpsFlag = false;
bool theShowInfoFlag = false;
// Indicates whether to show cursor in the game window
bool theHideCursorFlag = false;
@ -235,6 +240,13 @@ bool setupDisplay()
atexit(doQuit);
// Check which system we are running under
x11Available = false;
SDL_VERSION(&info.version);
if(SDL_GetWMInfo(&info) > 0)
if(info.subsystem == SDL_SYSWM_X11)
x11Available = true;
int sdlflags = SDL_HWSURFACE | SDL_HWPALETTE;
sdlflags |= theUseFullScreenFlag ? SDL_FULLSCREEN : 0;
@ -340,13 +352,8 @@ bool setupDisplay()
if(theCenterWindowFlag && !theUseFullScreenFlag)
centerWindow();
#ifdef IMLIB2_SNAPSHOT
SDL_SysWMinfo info;
SDL_VERSION(&info.version);
if(SDL_GetWMInfo(&info) > 0)
{
if(info.subsystem == SDL_SYSWM_X11)
#ifdef IMLIB_SNAPSHOT
if(x11Available)
{
info.info.x11.lock_func();
theX11Display = info.info.x11.display;
@ -354,10 +361,7 @@ bool setupDisplay()
theX11Screen = DefaultScreen(theX11Display);
info.info.x11.unlock_func();
imlib_context_set_display(theX11Display);
imlib_context_set_drawable(theX11Window);
imlib_context_set_visual(DefaultVisual(theX11Display, theX11Screen));
imlib_context_set_colormap(DefaultColormap(theX11Display, theX11Screen));
imlibData = Imlib_init(theX11Display);
// By default, snapshot dir is HOME and name is ROMNAME, assuming that
// they haven't been specified on the commandline
@ -366,7 +370,6 @@ bool setupDisplay()
if(theSnapShotName == "")
theSnapShotName = "romname";
}
}
#endif
return true;
@ -469,15 +472,13 @@ void centerWindow()
if(isFullscreen || isCentered)
return;
SDL_SysWMinfo info;
SDL_VERSION(&info.version);
if(SDL_GetWMInfo(&info) > 0)
if(!x11Available)
{
cerr << "Window centering only available under X11.\n";
return;
}
int x, y, w, h;
if(info.subsystem == SDL_SYSWM_X11)
{
info.info.x11.lock_func();
theX11Display = info.info.x11.display;
theX11Window = info.info.x11.wmwindow;
@ -493,43 +494,43 @@ void centerWindow()
isCentered = true;
}
}
}
/**
Toggles between fullscreen and window mode. Grabmouse and hidecursor
activated when in fullscreen mode. Only works in X11 for now.
activated when in fullscreen mode.
*/
void toggleFullscreen()
{
if(isFullscreen) // changing to windowed mode
int width = theWidth * 2 * theWindowSize;
int height = theHeight * theWindowSize;
int sdlflags = SDL_HWSURFACE | SDL_HWPALETTE;
isFullscreen = !isFullscreen;
sdlflags |= isFullscreen ? SDL_FULLSCREEN : 0;
screen = SDL_SetVideoMode(width, height, 0, sdlflags);
if(screen == NULL)
{
if(SDL_WM_ToggleFullScreen(screen) == 0)
{
cerr << "Couldn't switch to windowed mode.\n";
cerr << "Unable to switch screenmode: " << SDL_GetError() << endl;
return;
}
bpp = screen->format->BitsPerPixel;
if(isFullscreen) // now in fullscreen mode
{
grabMouse(true);
showCursor(false);
}
else // now in windowed mode
{
grabMouse(theGrabMouseFlag);
showCursor(!theHideCursorFlag);
isFullscreen = false;
if(theCenterWindowFlag)
centerWindow();
}
else // changing to fullscreen mode
{
if(SDL_WM_ToggleFullScreen(screen) == 0)
{
cerr << "Couldn't switch to fullscreen mode.\n";
return;
}
grabMouse(true);
showCursor(false);
isFullscreen = true;
}
theRedrawEntireFrameFlag = true;
}
@ -735,6 +736,7 @@ void handleEvents()
Uint8 type;
Uint8 state;
SDLKey key;
SDLMod mod;
// Check for an event
while(SDL_PollEvent(&event))
@ -743,6 +745,7 @@ void handleEvents()
if(event.type == SDL_KEYDOWN)
{
key = event.key.keysym.sym;
mod = event.key.keysym.mod;
type = event.type;
if(key == SDLK_ESCAPE)
@ -757,7 +760,7 @@ void handleEvents()
{
resizeWindow(0);
}
else if(key == SDLK_F11)
else if(key == SDLK_RETURN && mod & KMOD_ALT)
{
toggleFullscreen();
}
@ -1031,13 +1034,23 @@ void handleEvents()
*/
void takeSnapshot()
{
#ifdef IMLIB2_SNAPSHOT
// Figure out the actual size of the window
int width = theWidth * 2 * theWindowSize;
int height = theHeight * theWindowSize;
#ifdef IMLIB_SNAPSHOT
if(!x11Available)
{
cerr << "Snapshot support only available under X11.\n";
return;
}
else if(isFullscreen)
{
cerr << "Snapshot support unavailable in fullscreen (for now).\n";
return;
}
Imlib_Image image = imlib_create_image_from_drawable(0, 0, 0, width, height, 1);
int width = screen->w;
int height = screen->h;
ImlibImage* image = Imlib_create_image_from_drawable(imlibData, theX11Window,
0, 0, 0, width, height);
if(image == NULL)
{
cerr << "Could not create snapshot!!\n";
@ -1079,11 +1092,9 @@ void takeSnapshot()
else
filename = extFilename;
// Now save the png snapshot file
imlib_context_set_image(image);
imlib_image_set_format("png");
imlib_save_image(filename.c_str());
imlib_free_image();
// Now save the snapshot file
Imlib_save_image(imlibData, image, (char*)filename.c_str(), NULL);
Imlib_kill_image(imlibData, image);
if(access(filename.c_str(), F_OK) == 0)
cerr << "Snapshot saved as " << filename << endl;
@ -1097,16 +1108,12 @@ void takeSnapshot()
/**
Calculate the maximum window size that the current screen can hold.
Only works in X11 for now. If not running under X11, always return 5.
Only works in X11 for now. If not running under X11, always return 3.
*/
uInt32 maxWindowSizeForScreen()
{
SDL_SysWMinfo info;
SDL_VERSION(&info.version);
if(SDL_GetWMInfo(&info) > 0)
if(info.subsystem != SDL_SYSWM_X11)
return 5;
if(!x11Available)
return 3;
// Otherwise, lock the screen and get the width and height
info.info.x11.lock_func();
@ -1164,8 +1171,8 @@ void usage()
" -volume <number> Set the volume from 0 to 100",
" -paddle <0|1|2|3|real> Indicates which paddle the mouse should emulate",
" or that real Atari 2600 paddles are being used",
" -showfps Shows some game info on exit",
#ifdef IMLIB2_SNAPSHOT
" -showinfo Shows some game info on exit",
#ifdef IMLIB_SNAPSHOT
" -ssdir <path> The directory to save snapshot files to",
" -ssname <name> How to name the snapshot (romname or md5sum)",
#endif
@ -1271,9 +1278,9 @@ void handleCommandLineArguments(int argc, char* argv[])
{
theCenterWindowFlag = true;
}
else if(string(argv[i]) == "-showfps")
else if(string(argv[i]) == "-showinfo")
{
theShowFpsFlag = true;
theShowInfoFlag = true;
}
else if(string(argv[i]) == "-winsize")
{
@ -1291,7 +1298,7 @@ void handleCommandLineArguments(int argc, char* argv[])
theDesiredVolume = volume;
}
#ifdef IMLIB2_SNAPSHOT
#ifdef IMLIB_SNAPSHOT
else if(string(argv[i]) == "-ssdir")
{
theSnapShotDir = argv[++i];
@ -1425,13 +1432,13 @@ void parseRCOptions(istream& in)
else if(option == 0)
theCenterWindowFlag = false;
}
else if(key == "showfps")
else if(key == "showinfo")
{
uInt32 option = atoi(value.c_str());
if(option == 1)
theShowFpsFlag = true;
theShowInfoFlag = true;
else if(option == 0)
theShowFpsFlag = false;
theShowInfoFlag = false;
}
else if(key == "winsize")
{
@ -1451,7 +1458,7 @@ void parseRCOptions(istream& in)
theDesiredVolume = volume;
}
#ifdef IMLIB2_SNAPSHOT
#ifdef IMLIB_SNAPSHOT
else if(key == "ssdir")
{
theSnapShotDir = value;
@ -1577,7 +1584,7 @@ int main(int argc, char* argv[])
}
}
if(theShowFpsFlag)
if(theShowInfoFlag)
{
timeval endingTime;
gettimeofday(&endingTime, 0);
@ -1590,6 +1597,10 @@ int main(int argc, char* argv[])
cout << framesPerSecond << " frames/second\n";
cout << theConsole->mediaSource().scanlines() << " scanlines in last frame\n";
cout << endl;
cout << "Cartridge Name: " << theConsole->properties().get("Cartridge.Name");
cout << endl;
cout << "Cartridge MD5: " << theConsole->properties().get("Cartridge.MD5");
cout << endl << endl;
}
// Cleanup time ...

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: mainX11.cxx,v 1.6 2002-02-01 02:13:08 stephena Exp $
// $Id: mainX11.cxx,v 1.7 2002-02-03 16:51:22 stephena Exp $
//============================================================================
#include <assert.h>
@ -43,8 +43,10 @@
#include "SndUnix.hxx"
#include "System.hxx"
#ifdef IMLIB2_SNAPSHOT
#include <Imlib2.h>
#ifdef IMLIB_SNAPSHOT
#include <Imlib.h>
ImlibData* imlibData;
// The path to save snapshot files
string theSnapShotDir = "";
@ -143,6 +145,7 @@ static Switches list[] = {
{ XK_Right, Event::JoystickZeroRight },
{ XK_space, Event::JoystickZeroFire },
{ XK_Return, Event::JoystickZeroFire },
{ XK_Control_L, Event::JoystickZeroFire },
{ XK_z, Event::BoosterGripZeroTrigger },
{ XK_x, Event::BoosterGripZeroBooster },
@ -209,7 +212,7 @@ bool theGrabMouseFlag = false;
bool theCenterWindowFlag = false;
// Indicates whether to show some game info on program exit
bool theShowFpsFlag = false;
bool theShowInfoFlag = false;
// Indicates whether to show cursor in the game window
bool theHideCursorFlag = false;
@ -355,7 +358,7 @@ bool setupDisplay()
XMapWindow(theDisplay, theWindow);
// Center the window if centering is selected and not fullscreen
if(theCenterWindowFlag && !theUseFullScreenFlag)
if(theCenterWindowFlag)// && !theUseFullScreenFlag)
centerWindow();
XEvent event;
@ -384,15 +387,8 @@ bool setupDisplay()
XSelectInput(theDisplay, theWindow, eventMask);
// If imlib snapshots are enabled, set up some imlib stuff
#ifdef IMLIB2_SNAPSHOT
imlib_context_set_display(theDisplay);
imlib_context_set_drawable(theWindow);
imlib_context_set_visual(DefaultVisual(theDisplay, theScreen));
if(theUsePrivateColormapFlag)
imlib_context_set_colormap(thePrivateColormap);
else
imlib_context_set_colormap(DefaultColormap(theDisplay, theScreen));
#ifdef IMLIB_SNAPSHOT
imlibData = Imlib_init(theDisplay);
// By default, snapshot dir is HOME and name is ROMNAME, assuming that
// they haven't been specified on the commandline
@ -1009,13 +1005,13 @@ bool createCursors()
*/
void takeSnapshot()
{
#ifdef IMLIB2_SNAPSHOT
#ifdef IMLIB_SNAPSHOT
// Figure out the actual size of the window
int width = theWidth * 2 * theWindowSize;
int height = theHeight * theWindowSize;
Imlib_Image image = imlib_create_image_from_drawable(0, 0, 0, width, height, 1);
ImlibImage* image = Imlib_create_image_from_drawable(imlibData, theWindow,
0, 0, 0, width, height);
if(image == NULL)
{
cerr << "Could not create snapshot!!\n";
@ -1057,11 +1053,9 @@ void takeSnapshot()
else
filename = extFilename;
// Now save the png snapshot file
imlib_context_set_image(image);
imlib_image_set_format("png");
imlib_save_image(filename.c_str());
imlib_free_image();
// Now save the snapshot file
Imlib_save_image(imlibData, image, (char*)filename.c_str(), NULL);
Imlib_kill_image(imlibData, image);
if(access(filename.c_str(), F_OK) == 0)
cerr << "Snapshot saved as " << filename << endl;
@ -1129,8 +1123,8 @@ void usage()
#else
" -paddle <0|1|2|3> Indicates which paddle the mouse should emulate",
#endif
" -showfps Shows some game info on exit",
#ifdef IMLIB2_SNAPSHOT
" -showinfo Shows some game info on exit",
#ifdef IMLIB_SNAPSHOT
" -ssdir <path> The directory to save snapshot files to",
" -ssname <name> How to name the snapshot (romname or md5sum)",
#endif
@ -1242,9 +1236,9 @@ void handleCommandLineArguments(int argc, char* argv[])
{
theCenterWindowFlag = true;
}
else if(string(argv[i]) == "-showfps")
else if(string(argv[i]) == "-showinfo")
{
theShowFpsFlag = true;
theShowInfoFlag = true;
}
else if(string(argv[i]) == "-winsize")
{
@ -1262,7 +1256,7 @@ void handleCommandLineArguments(int argc, char* argv[])
theDesiredVolume = volume;
}
#ifdef IMLIB2_SNAPSHOT
#ifdef IMLIB_SNAPSHOT
else if(string(argv[i]) == "-ssdir")
{
theSnapShotDir = argv[++i];
@ -1406,13 +1400,13 @@ void parseRCOptions(istream& in)
else if(option == 0)
theCenterWindowFlag = false;
}
else if(key == "showfps")
else if(key == "showinfo")
{
uInt32 option = atoi(value.c_str());
if(option == 1)
theShowFpsFlag = true;
theShowInfoFlag = true;
else if(option == 0)
theShowFpsFlag = false;
theShowInfoFlag = false;
}
else if(key == "winsize")
{
@ -1432,7 +1426,7 @@ void parseRCOptions(istream& in)
theDesiredVolume = volume;
}
#ifdef IMLIB2_SNAPSHOT
#ifdef IMLIB_SNAPSHOT
else if(key == "ssdir")
{
theSnapShotDir = value;
@ -1576,7 +1570,7 @@ int main(int argc, char* argv[])
}
}
if(theShowFpsFlag)
if(theShowInfoFlag)
{
timeval endingTime;
gettimeofday(&endingTime, 0);
@ -1589,6 +1583,10 @@ int main(int argc, char* argv[])
cout << framesPerSecond << " frames/second\n";
cout << theConsole->mediaSource().scanlines() << " scanlines in last frame\n";
cout << endl;
cout << "Cartridge Name: " << theConsole->properties().get("Cartridge.Name");
cout << endl;
cout << "Cartridge MD5: " << theConsole->properties().get("Cartridge.MD5");
cout << endl << endl;
}
// Cleanup time ...