Reworked snapshot support for the SDL version. Imlib is no longer needed

for SDL version, just the PNG library.  Fullscreen snapshot support is
working again.

Removed choice of adding snapshot to SDL version; now it is always added.
As a result, the 'libpng' library is needed to compile SDL version.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@42 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2002-02-17 04:41:42 +00:00
parent 24050a1ce6
commit 5a8ca97c59
5 changed files with 377 additions and 152 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.7 2002-02-03 16:51:21 stephena Exp $
## $Id: makefile,v 1.8 2002-02-17 04:41:41 stephena Exp $
##============================================================================
##============================================================================
@ -23,16 +23,20 @@
## Comment a line out to disable that option, remove comment to enable it.
##============================================================================
### this should work with all compilers
OPTIMIZATIONS =
### for normal optimization, full warnings
# OPTIMIZATIONS = -O -Wall
### for common optimizations, full warnings except unused vars
# OPTIMIZATIONS = -O2 -Wall -Wno-unused
### this should work with all compilers
OPTIMIZATIONS =
### to get full optimization under gcc/x Intel based OS's..
# OPTIMIZATIONS = -O3 -mcpu=pentiumpro -march=pentiumpro -Wall -Wno-unused \
# -funroll-loops -fstrength-reduce -fomit-frame-pointer -ffast-math \
# -malign-functions=2 -malign-jumps=2 -malign-loops=2
### to get full optimization under gcc/x Athlon based OS's..
# OPTIMIZATIONS = -O3 -march=athlon -Wall -Wno-unused \
# -funroll-loops -fstrength-reduce -fomit-frame-pointer -ffast-math \
# -malign-functions=2 -malign-jumps=2 -malign-loops=2
### if your C++ compiler doesn't support the bool type
@ -49,9 +53,8 @@ OPTIMIZATIONS =
# LINUX_JOYSTICK = 1
### to include support for saving snapshots in png format
### (X and SDL versions only)
### (requires you to install Imlib)
# IMLIB_SNAPSHOT = 1
### (X version requires Imlib)
# X11_SNAPSHOT = 1
##============================================================================
## All done, type make to get a list of frontends
@ -104,16 +107,12 @@ ifdef LINUX_JOYSTICK
OPTS.X11 += -DLINUX_JOYSTICK
endif
ifdef IMLIB_SNAPSHOT
OPTS.X11 += -DIMLIB_SNAPSHOT
ifdef X11_SNAPSHOT
OPTS.X11 += -DHAVE_IMLIB
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
default:
@echo ""
@echo "To build Stella type: 'make <version>'"
@ -174,9 +173,9 @@ linux-sdl:
OPTIONS+="$(OPTS.SDL)" \
LDFLAGS="-L/usr/X11R6/lib" \
LDFLAGS+="$(CFLAGS.SDL)" \
LDLIBS="-lX11 -lXext" \
LDLIBS="-lX11 -lXext -lpng" \
LDLIBS+="$(LIBS.SDL)" \
OBJS="mainSDL.o SndUnix.o"
OBJS="mainSDL.o SndUnix.o SnapSDL.o"
bsdi-x:
make stella.x11 \
@ -383,6 +382,9 @@ mainX11.o: $(UI)/x11/mainX11.cxx
mainSDL.o: $(UI)/sdl/mainSDL.cxx
$(CXX) -c $(CXXFLAGS) $(OPTIONS) $(LDFLAGS) $(UI)/sdl/mainSDL.cxx
SnapSDL.o: $(UI)/sdl/SnapSDL.cxx $(UI)/sdl/SnapSDL.hxx
$(CXX) -c $(CXXFLAGS) $(OPTIONS) $(LDFLAGS) $(UI)/sdl/SnapSDL.cxx
SndUnix.o: $(UI)/sound/SndUnix.cxx
$(CXX) -c $(CXXFLAGS) $(OPTIONS) $(UI)/sound/SndUnix.cxx

View File

@ -0,0 +1,178 @@
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-1999 by Bradford W. Mott
//
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: SnapSDL.cxx,v 1.1 2002-02-17 04:41:41 stephena Exp $
//============================================================================
#include <SDL.h>
#include <png.h>
#include <stdlib.h>
#include <iostream>
#include "SnapSDL.hxx"
SnapshotSDL::SnapshotSDL()
{
}
SnapshotSDL::~SnapshotSDL()
{
}
int SnapshotSDL::savePNG(SDL_Surface *surface, const char *file)
{
SDL_RWops *out = SDL_RWFromFile(file, "wb");
if(!out)
return -1;
int ret = IMG_SavePNG_RW(surface, out);
SDL_RWclose(out);
return ret;
}
/* Save a PNG type image to an SDL datasource */
void SnapshotSDL::png_write_data(png_structp ctx, png_bytep area, png_size_t size)
{
SDL_RWops *src;
src = (SDL_RWops *) png_get_io_ptr(ctx);
SDL_RWwrite(src, area, size, 1);
}
void SnapshotSDL::png_io_flush(png_structp ctx)
{
SDL_RWops *src;
src = (SDL_RWops *)png_get_io_ptr(ctx);
/* how do I flush src? */
}
int SnapshotSDL::png_colortype_from_surface(SDL_Surface *surface)
{
int colortype = PNG_COLOR_MASK_COLOR; /* grayscale not supported */
if (surface->format->palette)
colortype |= PNG_COLOR_MASK_PALETTE;
else if (surface->format->Amask)
colortype |= PNG_COLOR_MASK_ALPHA;
return colortype;
}
void SnapshotSDL::png_user_warn(png_structp ctx, png_const_charp str)
{
cerr << "SnapshotSDL: libpng warning: " << str << endl;
}
void SnapshotSDL::png_user_error(png_structp ctx, png_const_charp str)
{
cerr << "SnapshotSDL: libpng error: " << str << endl;
}
int SnapshotSDL::IMG_SavePNG_RW(SDL_Surface *surface, SDL_RWops *src)
{
png_structp png_ptr = 0;
png_infop info_ptr = 0;
png_colorp palette = 0;
png_bytep *row_pointers = 0;
int i;
int colortype;
int result = 0;
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, png_user_error, png_user_warn);
if(png_ptr == NULL)
{
cerr << "SnapshotSDL: Couldn't allocate memory for PNG file\n";
return -1;
}
/* Allocate/initialize the image information data. REQUIRED */
info_ptr = png_create_info_struct(png_ptr);
if(info_ptr == NULL)
{
cerr << "SnapshotSDL: Couldn't create image information for PNG file\n";
goto done;
}
png_set_write_fn(png_ptr, src, png_write_data, png_io_flush);
/* Set the image information here. Width and height are up to 2^31,
* bit_depth is one of 1, 2, 4, 8, or 16, but valid values also depend on
* the color_type selected. color_type is one of PNG_COLOR_TYPE_GRAY,
* PNG_COLOR_TYPE_GRAY_ALPHA, PNG_COLOR_TYPE_PALETTE, PNG_COLOR_TYPE_RGB,
* or PNG_COLOR_TYPE_RGB_ALPHA. interlace is either PNG_INTERLACE_NONE or
* PNG_INTERLACE_ADAM7, and the compression_type and filter_type MUST
* currently be PNG_COMPRESSION_TYPE_BASE and PNG_FILTER_TYPE_BASE. REQUIRED
*/
colortype = png_colortype_from_surface(surface);
png_set_IHDR(png_ptr, info_ptr, surface->w, surface->h, 8,
colortype, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE,
PNG_FILTER_TYPE_BASE);
/* set the palette if there is one. REQUIRED for indexed-color images */
if(colortype & PNG_COLOR_MASK_PALETTE)
{
palette = (png_colorp)malloc(surface->format->palette->ncolors * sizeof (png_color));
if(!palette)
{
cerr << "SnapshotSDL: Couldn't allocate memory for PNG palette\n";
goto done;
}
for(i = 0; i < surface->format->palette->ncolors; i++)
{
palette[i].red = surface->format->palette->colors[i].r;
palette[i].green = surface->format->palette->colors[i].g;
palette[i].blue = surface->format->palette->colors[i].b;
}
png_set_PLTE(png_ptr, info_ptr, palette, surface->format->palette->ncolors);
}
// Write the file header information. REQUIRED
png_write_info(png_ptr, info_ptr);
// pack pixels into bytes
png_set_packing(png_ptr);
// Create the array of pointers to image data
row_pointers = (png_bytep*) malloc(sizeof(png_bytep)*surface->h);
if((row_pointers == NULL))
{
cerr << "SnapshotSDL: Couldn't allocate PNG row pointers\n";
goto done;
}
for(i = 0; i < surface->h; i++)
row_pointers[i] = (png_bytep)(Uint8 *)surface->pixels + i*surface->pitch;
// write out the entire image data in one call
png_write_image(png_ptr, row_pointers);
png_write_end(png_ptr, info_ptr);
result = 1;
done:
if(row_pointers)
free(row_pointers);
if(info_ptr->palette)
free(info_ptr->palette);
png_destroy_write_struct(&png_ptr, (png_infopp)NULL);
return result;
}

View File

@ -0,0 +1,48 @@
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-1999 by Bradford W. Mott
//
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: SnapSDL.hxx,v 1.1 2002-02-17 04:41:41 stephena Exp $
//============================================================================
#ifndef SNAPSHOTSDL_HXX
#define SNAPSHOTSDL_HXX
#include <SDL.h>
#include <png.h>
class SnapshotSDL
{
public:
SnapshotSDL();
~SnapshotSDL();
int savePNG(SDL_Surface *surface, const char *file);
private:
static void png_write_data(png_structp ctx, png_bytep area, png_size_t size);
static void png_io_flush(png_structp ctx);
static void png_user_warn(png_structp ctx, png_const_charp str);
static void png_user_error(png_structp ctx, png_const_charp str);
int png_colortype_from_surface(SDL_Surface *surface);
int IMG_SavePNG_RW(SDL_Surface *surface, SDL_RWops *src);
};
#endif

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.8 2002-02-06 00:59:36 stephena Exp $
// $Id: mainSDL.cxx,v 1.9 2002-02-17 04:41:41 stephena Exp $
//============================================================================
#include <assert.h>
@ -39,18 +39,8 @@
#include "PropsSet.hxx"
#include "System.hxx"
#include "SndUnix.hxx"
#include "SnapSDL.hxx"
#ifdef IMLIB_SNAPSHOT
#include <Imlib.h>
ImlibData* imlibData;
// The path to save snapshot files
string theSnapShotDir = "";
// What the snapshot should be called (romname or md5sum)
string theSnapShotName = "";
#endif
SDL_Joystick* theLeftJoystick;
SDL_Joystick* theRightJoystick;
@ -58,6 +48,7 @@ SDL_Joystick* theRightJoystick;
// function prototypes
bool setupDisplay();
bool setupJoystick();
bool createScreen(int width, int height);
void cleanup();
void updateDisplay(MediaSource& mediaSource);
@ -81,6 +72,7 @@ void usage();
// Globals for the SDL stuff
static SDL_Surface* screen;
static Uint32 palette[256];
static int bpp;
static Display* theX11Display;
static Window theX11Window;
@ -88,9 +80,9 @@ static int theX11Screen;
static int mouseX = 0;
static bool x11Available = false;
static SDL_SysWMinfo info;
static int sdlflags;
static SnapshotSDL* snapshot;
// SDL colors palette
static Uint32 colors[256];
struct Switches
{
@ -203,12 +195,12 @@ bool theShowInfoFlag = false;
// Indicates whether to show cursor in the game window
bool theHideCursorFlag = false;
// Indicates whether the game is currently in fullscreen
bool isFullscreen = false;
// Indicates whether to allocate colors from a private color map
bool theUsePrivateColormapFlag = false;
// Indicates whether the game is currently in fullscreen
bool isFullscreen = false;
// Indicates whether the window is currently centered
bool isCentered = false;
@ -229,6 +221,12 @@ uInt32 thePaddleMode = 0;
// An alternate properties file to use
string theAlternateProFile = "";
// The path to save snapshot files
string theSnapShotDir = "";
// What the snapshot should be called (romname or md5sum)
string theSnapShotName = "";
/**
This routine should be called once the console is created to setup
@ -250,8 +248,12 @@ bool setupDisplay()
if(info.subsystem == SDL_SYSWM_X11)
x11Available = true;
int sdlflags = SDL_HWSURFACE | SDL_HWPALETTE;
sdlflags = SDL_HWSURFACE;
sdlflags |= theUseFullScreenFlag ? SDL_FULLSCREEN : 0;
sdlflags |= theUsePrivateColormapFlag ? SDL_HWPALETTE : 0;
// Always use an 8-bit screen since the Atari 2600 had less than 256 colors
bpp = 8;
// Get the desired width and height of the display
theWidth = theConsole->mediaSource().width();
@ -283,13 +285,9 @@ bool setupDisplay()
int width = theWidth * 2 * theWindowSize;
int height = theHeight * theWindowSize;
screen = SDL_SetVideoMode(width, height, 0, sdlflags);
if(screen == NULL)
{
cerr << "ERROR: Unable to open SDL window: " << SDL_GetError() << endl;
// Create the screen
if(!createScreen(width, height))
return false;
}
bpp = screen->format->BitsPerPixel;
// set the window title and icon name
char name[512];
@ -297,44 +295,6 @@ bool setupDisplay()
theConsole->properties().get("Cartridge.Name").c_str());
SDL_WM_SetCaption(name, "stella");
// Create the color palette based on screen bpp
const uInt32* palette = theConsole->mediaSource().palette();
for(uInt32 i = 0; i < 256; i += 2)
{
Uint8 r, g, b;
r = (Uint8) ((palette[i] & 0x00ff0000) >> 16);
g = (Uint8) ((palette[i] & 0x0000ff00) >> 8);
b = (Uint8) (palette[i] & 0x000000ff);
switch(bpp)
{
case 8:
SDL_Color color;
color.r = r;
color.g = g;
color.b = b;
SDL_SetColors(screen, &color, i, 1);
break;
case 15:
colors[i] = ((r >> 3) << 10) | ((g >> 3) << 5) | (b >> 3);
colors[i + 1] = colors[i];
break;
case 16:
colors[i] = ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3);
colors[i + 1] = colors[i];
break;
case 32:
colors[i] = (r << 16) | (g << 8) | b;
colors[i + 1] = colors[i];
break;
}
}
// Make sure that theUseFullScreenFlag sets up fullscreen mode correctly
if(theUseFullScreenFlag)
{
@ -355,25 +315,15 @@ bool setupDisplay()
if(theCenterWindowFlag && !theUseFullScreenFlag)
centerWindow();
#ifdef IMLIB_SNAPSHOT
if(x11Available)
{
info.info.x11.lock_func();
theX11Display = info.info.x11.display;
theX11Window = info.info.x11.wmwindow;
theX11Screen = DefaultScreen(theX11Display);
info.info.x11.unlock_func();
// Take care of the snapshot stuff
snapshot = new SnapshotSDL();
imlibData = Imlib_init(theX11Display);
// By default, snapshot dir is HOME and name is ROMNAME, assuming that
// they haven't been specified on the commandline
if(theSnapShotDir == "")
theSnapShotDir = getenv("HOME");
if(theSnapShotName == "")
theSnapShotName = "romname";
}
#endif
// By default, snapshot dir is HOME and name is ROMNAME, assuming that
// they haven't been specified on the commandline
if(theSnapShotDir == "")
theSnapShotDir = getenv("HOME");
if(theSnapShotName == "")
theSnapShotName = "romname";
return true;
}
@ -409,6 +359,55 @@ bool setupJoystick()
}
/**
This routine is called whenever the screen needs to be recreated.
It updates the global screen variable. When this happens, the
palette has to be recalculated as well.
*/
bool createScreen(int w, int h)
{
screen = SDL_SetVideoMode(w, h, bpp, sdlflags);
if(screen == NULL)
{
cerr << "ERROR: Unable to open SDL window: " << SDL_GetError() << endl;
return false;
}
// Now set the screen palette
const uInt32* gamePalette = theConsole->mediaSource().palette();
SDL_Color colors[256];
for(uInt32 i = 0; i < 256; i += 2)
{
Uint8 r, g, b;
r = (Uint8) ((gamePalette[i] & 0x00ff0000) >> 16);
g = (Uint8) ((gamePalette[i] & 0x0000ff00) >> 8);
b = (Uint8) (gamePalette[i] & 0x000000ff);
colors[i].r = colors[i+1].r = r;
colors[i].g = colors[i+1].g = g;
colors[i].b = colors[i+1].b = b;
}
SDL_SetColors(screen, colors, 0, 256);
// Now see which colors we actually got
SDL_PixelFormat* format = screen->format;
for(uInt32 i = 0; i < 256; i += 2)
{
Uint8 r, g, b;
r = format->palette->colors[i].r;
g = format->palette->colors[i].g;
b = format->palette->colors[i].b;
palette[i] = SDL_MapRGB(format, r, g, b);
palette[i+1] = palette[i];
}
return true;
}
/**
This routine is called when the program is about to quit.
*/
@ -449,13 +448,8 @@ void resizeWindow(int mode)
int width = theWidth * 2 * theWindowSize;
int height = theHeight * theWindowSize;
screen = SDL_SetVideoMode(width, height, 0, SDL_HWSURFACE | SDL_HWPALETTE);
if(screen == NULL)
{
cerr << "Unable to resize SDL window: " << SDL_GetError() << endl;
if(!createScreen(width, height))
return;
}
bpp = screen->format->BitsPerPixel;
theRedrawEntireFrameFlag = true;
@ -507,17 +501,15 @@ void toggleFullscreen()
{
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)
{
cerr << "Unable to switch screenmode: " << SDL_GetError() << endl;
isFullscreen = !isFullscreen;
if(isFullscreen)
sdlflags |= SDL_FULLSCREEN;
else
sdlflags &= ~SDL_FULLSCREEN;
if(!createScreen(width, height))
return;
}
bpp = screen->format->BitsPerPixel;
if(isFullscreen) // now in fullscreen mode
{
@ -680,7 +672,7 @@ void updateDisplay(MediaSource& mediaSource)
rect.y = active.y * screenMultiple;
rect.w = active.width * 2 * screenMultiple;
rect.h = active.height * screenMultiple;
SDL_FillRect(screen, &rect, colors[active.color]);
SDL_FillRect(screen, &rect, palette[active.color]);
++activeIndex;
}
@ -695,7 +687,7 @@ void updateDisplay(MediaSource& mediaSource)
rect.y = active.y * screenMultiple;
rect.w = active.width * 2 * screenMultiple;
rect.h = active.height * screenMultiple;
SDL_FillRect(screen, &rect, colors[active.color]);
SDL_FillRect(screen, &rect, palette[active.color]);
}
// We can now make the current rectangles into the active rectangles
@ -717,7 +709,7 @@ void updateDisplay(MediaSource& mediaSource)
rect.y = active.y * screenMultiple;
rect.w = active.width * 2 * screenMultiple;
rect.h = active.height * screenMultiple;
SDL_FillRect(screen, &rect, colors[active.color]);
SDL_FillRect(screen, &rect, palette[active.color]);
}
SDL_UpdateRect(screen, 0, 0, screen->w, screen->h);
@ -777,7 +769,7 @@ void handleEvents()
}
else if(key == SDLK_g)
{
// don't turn off grabmouse in fullscreen or we may lose the keyboard
// don't change grabmouse in fullscreen mode
if(!isFullscreen)
{
theGrabMouseFlag = !theGrabMouseFlag;
@ -786,8 +778,12 @@ void handleEvents()
}
else if(key == SDLK_h)
{
theHideCursorFlag = !theHideCursorFlag;
showCursor(!theHideCursorFlag);
// don't change hidecursor in fullscreen mode
if(!isFullscreen)
{
theHideCursorFlag = !theHideCursorFlag;
showCursor(!theHideCursorFlag);
}
}
else // check all the other keys
{
@ -1037,29 +1033,20 @@ void handleEvents()
*/
void takeSnapshot()
{
#ifdef IMLIB_SNAPSHOT
if(!x11Available)
if(!snapshot)
{
cerr << "Snapshot support only available under X11.\n";
cerr << "Snapshot support disabled.\n";
return;
}
else if(isFullscreen)
/* else if(isFullscreen)
{
cerr << "Snapshot support unavailable in fullscreen (for now).\n";
return;
}
*/
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";
return;
}
// Now find the correct name for the snapshot
string filename = theSnapShotDir;
if(theSnapShotName == "romname")
@ -1096,16 +1083,12 @@ void takeSnapshot()
filename = extFilename;
// Now save the snapshot file
Imlib_save_image(imlibData, image, (char*)filename.c_str(), NULL);
Imlib_kill_image(imlibData, image);
snapshot->savePNG(screen, filename.c_str());
if(access(filename.c_str(), F_OK) == 0)
cerr << "Snapshot saved as " << filename << endl;
else
cerr << "Couldn't create snapshot " << filename << endl;
#else
cerr << "Snapshot mode not supported.\n";
#endif
}
@ -1166,6 +1149,7 @@ void usage()
"Valid options are:",
"",
" -fps <number> Display the given number of frames per second",
" -owncmap Install a private colormap",
" -winsize <size> Makes initial window be 'size' times normal",
" -fullscreen Play the game in fullscreen mode",
" -grabmouse Keeps the mouse in the game window",
@ -1175,10 +1159,8 @@ void usage()
" -paddle <0|1|2|3|real> Indicates which paddle the mouse should emulate",
" or that real Atari 2600 paddles are being used",
" -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
" -pro <props file> Use the given properties file instead of stella.pro",
"",
0
@ -1283,6 +1265,10 @@ void handleCommandLineArguments(int argc, char* argv[])
}
++i;
}
else if(string(argv[i]) == "-owncmap")
{
theUsePrivateColormapFlag = true;
}
else if(string(argv[i]) == "-fullscreen")
{
theUseFullScreenFlag = true;
@ -1319,7 +1305,6 @@ void handleCommandLineArguments(int argc, char* argv[])
theDesiredVolume = volume;
}
#ifdef IMLIB_SNAPSHOT
else if(string(argv[i]) == "-ssdir")
{
theSnapShotDir = argv[++i];
@ -1328,7 +1313,6 @@ void handleCommandLineArguments(int argc, char* argv[])
{
theSnapShotName = argv[++i];
}
#endif
else if(string(argv[i]) == "-pro")
{
theAlternateProFile = argv[++i];
@ -1425,6 +1409,14 @@ void parseRCOptions(istream& in)
thePaddleMode = pMode;
}
}
else if(key == "owncmap")
{
uInt32 option = atoi(value.c_str());
if(option == 1)
theUsePrivateColormapFlag = true;
else if(option == 0)
theUsePrivateColormapFlag = false;
}
else if(key == "fullscreen")
{
uInt32 option = atoi(value.c_str());
@ -1483,7 +1475,6 @@ void parseRCOptions(istream& in)
theDesiredVolume = volume;
}
#ifdef IMLIB_SNAPSHOT
else if(key == "ssdir")
{
theSnapShotDir = value;
@ -1492,7 +1483,6 @@ void parseRCOptions(istream& in)
{
theSnapShotName = value;
}
#endif
}
}
@ -1505,6 +1495,9 @@ void cleanup()
if(theConsole)
delete theConsole;
if(snapshot)
delete snapshot;
if(SDL_JoystickOpened(0))
SDL_JoystickClose(theLeftJoystick);
if(SDL_JoystickOpened(1))

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.8 2002-02-06 00:59:36 stephena Exp $
// $Id: mainX11.cxx,v 1.9 2002-02-17 04:41:42 stephena Exp $
//============================================================================
#include <assert.h>
@ -43,7 +43,7 @@
#include "SndUnix.hxx"
#include "System.hxx"
#ifdef IMLIB_SNAPSHOT
#ifdef HAVE_IMLIB
#include <Imlib.h>
ImlibData* imlibData;
@ -217,12 +217,12 @@ bool theShowInfoFlag = false;
// Indicates whether to show cursor in the game window
bool theHideCursorFlag = false;
// Indicates whether the game is currently in fullscreen
bool isFullscreen = false;
// Indicates whether to allocate colors from a private color map
bool theUsePrivateColormapFlag = false;
// Indicates whether the game is currently in fullscreen
bool isFullscreen = false;
// Indicates whether the window is currently centered
bool isCentered = false;
@ -390,7 +390,7 @@ bool setupDisplay()
XSelectInput(theDisplay, theWindow, eventMask);
// If imlib snapshots are enabled, set up some imlib stuff
#ifdef IMLIB_SNAPSHOT
#ifdef HAVE_IMLIB
imlibData = Imlib_init(theDisplay);
// By default, snapshot dir is HOME and name is ROMNAME, assuming that
@ -598,7 +598,7 @@ void handleEvents()
}
else if((key == XK_g) && (event.type == KeyPress))
{
// don't turn off grabmouse in fullscreen or we may lose the keyboard
// don't change grabmouse in fullscreen mode
if(!isFullscreen)
{
theGrabMouseFlag = !theGrabMouseFlag;
@ -607,8 +607,12 @@ void handleEvents()
}
else if((key == XK_h) && (event.type == KeyPress))
{
theHideCursorFlag = !theHideCursorFlag;
showCursor(!theHideCursorFlag);
// don't change hidecursor in fullscreen mode
if(!isFullscreen)
{
theHideCursorFlag = !theHideCursorFlag;
showCursor(!theHideCursorFlag);
}
}
else
{
@ -1008,7 +1012,7 @@ bool createCursors()
*/
void takeSnapshot()
{
#ifdef IMLIB_SNAPSHOT
#ifdef HAVE_IMLIB
// Figure out the actual size of the window
int width = theWidth * 2 * theWindowSize;
int height = theHeight * theWindowSize;
@ -1127,7 +1131,7 @@ void usage()
" -paddle <0|1|2|3> Indicates which paddle the mouse should emulate",
#endif
" -showinfo Shows some game info on exit",
#ifdef IMLIB_SNAPSHOT
#ifdef HAVE_IMLIB
" -ssdir <path> The directory to save snapshot files to",
" -ssname <name> How to name the snapshot (romname or md5sum)",
#endif
@ -1277,7 +1281,7 @@ void handleCommandLineArguments(int argc, char* argv[])
theDesiredVolume = volume;
}
#ifdef IMLIB_SNAPSHOT
#ifdef HAVE_IMLIB
else if(string(argv[i]) == "-ssdir")
{
theSnapShotDir = argv[++i];
@ -1451,7 +1455,7 @@ void parseRCOptions(istream& in)
theDesiredVolume = volume;
}
#ifdef IMLIB_SNAPSHOT
#ifdef HAVE_IMLIB
else if(key == "ssdir")
{
theSnapShotDir = value;