mirror of https://github.com/stella-emu/stella.git
Preparations for addition of the Snapshot class to the core.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@182 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
b1c31fdd1a
commit
14de7f7e62
|
@ -13,7 +13,7 @@
|
||||||
## See the file "license" for information on usage and redistribution of
|
## See the file "license" for information on usage and redistribution of
|
||||||
## this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
## this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
##
|
##
|
||||||
## $Id: makefile,v 1.37 2003-09-11 20:53:51 stephena Exp $
|
## $Id: makefile,v 1.38 2003-09-12 18:08:52 stephena Exp $
|
||||||
##============================================================================
|
##============================================================================
|
||||||
|
|
||||||
##============================================================================
|
##============================================================================
|
||||||
|
@ -30,9 +30,9 @@ OPTIMIZATIONS = $(CXXFLAGS) -Wall -Wno-unused
|
||||||
### SDL sound not yet supported in the X11 version
|
### SDL sound not yet supported in the X11 version
|
||||||
### comment out all lines to completely disable sound
|
### comment out all lines to completely disable sound
|
||||||
###
|
###
|
||||||
SOUND_ALSA = 1
|
#SOUND_ALSA = 1
|
||||||
SOUND_OSS = 1
|
#SOUND_OSS = 1
|
||||||
SOUND_SDL = 1
|
#SOUND_SDL = 1
|
||||||
|
|
||||||
### if your C++ compiler doesn't support the bool type
|
### if your C++ compiler doesn't support the bool type
|
||||||
# BSPF_BOOL = 1
|
# BSPF_BOOL = 1
|
||||||
|
@ -47,8 +47,8 @@ SOUND_SDL = 1
|
||||||
JOYSTICK_SUPPORT = 1
|
JOYSTICK_SUPPORT = 1
|
||||||
|
|
||||||
### to include support for saving snapshots in png format
|
### to include support for saving snapshots in png format
|
||||||
### (requires PNG library)
|
### (requires PNG library) FIXME
|
||||||
### Only X11 and SDL ports supported for now
|
### Only X11 and SDL ports supported for now FIXME
|
||||||
SNAPSHOT_SUPPORT = 1
|
SNAPSHOT_SUPPORT = 1
|
||||||
|
|
||||||
### comment this out if your system doesn't
|
### comment this out if your system doesn't
|
||||||
|
@ -118,11 +118,11 @@ endif
|
||||||
|
|
||||||
ifdef SNAPSHOT_SUPPORT
|
ifdef SNAPSHOT_SUPPORT
|
||||||
OBJS.X11 += Snapshot.o
|
OBJS.X11 += Snapshot.o
|
||||||
OPTS.X11 += -DHAVE_PNG=1
|
OPTS.X11 += -DSNAPSHOT_SUPPORT=1
|
||||||
LIBS.X11 += -lpng -lz
|
LIBS.X11 += -lpng -lz
|
||||||
|
|
||||||
OBJS.SDL += Snapshot.o
|
OBJS.SDL += Snapshot.o
|
||||||
OPTS.SDL += -DHAVE_PNG=1
|
OPTS.SDL += -DSNAPSHOT_SUPPORT=1
|
||||||
LIBS.SDL += -lpng -lz
|
LIBS.SDL += -lpng -lz
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
// See the file "license" for information on usage and redistribution of
|
// See the file "license" for information on usage and redistribution of
|
||||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
//
|
//
|
||||||
// $Id: Console.cxx,v 1.13 2003-09-07 18:30:28 stephena Exp $
|
// $Id: Console.cxx,v 1.14 2003-09-12 18:08:53 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
@ -44,6 +44,10 @@
|
||||||
#include "System.hxx"
|
#include "System.hxx"
|
||||||
#include "TIA.hxx"
|
#include "TIA.hxx"
|
||||||
|
|
||||||
|
#ifdef SNAPSHOT_SUPPORT
|
||||||
|
#include "Snapshot.hxx"
|
||||||
|
#endif
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
Console::Console(const uInt8* image, uInt32 size, const char* filename,
|
Console::Console(const uInt8* image, uInt32 size, const char* filename,
|
||||||
Settings& rcsettings, PropertiesSet& propertiesSet, Frontend& frontend,
|
Settings& rcsettings, PropertiesSet& propertiesSet, Frontend& frontend,
|
||||||
|
@ -69,6 +73,11 @@ Console::Console(const uInt8* image, uInt32 size, const char* filename,
|
||||||
myEventHandler = new EventHandler(this);
|
myEventHandler = new EventHandler(this);
|
||||||
myEvent = myEventHandler->event();
|
myEvent = myEventHandler->event();
|
||||||
|
|
||||||
|
#ifdef SNAPSHOT_SUPPORT
|
||||||
|
// Create a snapshot object which will handle taking snapshots
|
||||||
|
mySnapshot = new Snapshot();
|
||||||
|
#endif
|
||||||
|
|
||||||
// Get the MD5 message-digest for the ROM image
|
// Get the MD5 message-digest for the ROM image
|
||||||
string md5 = MD5(image, size);
|
string md5 = MD5(image, size);
|
||||||
|
|
||||||
|
@ -163,9 +172,6 @@ Console::Console(const uInt8* image, uInt32 size, const char* filename,
|
||||||
// Remember what my media source is
|
// Remember what my media source is
|
||||||
myMediaSource = tia;
|
myMediaSource = tia;
|
||||||
|
|
||||||
// Let the event handler know about the mediasource
|
|
||||||
myEventHandler->setMediaSource(myMediaSource);
|
|
||||||
|
|
||||||
// Reset, the system to its power-on state
|
// Reset, the system to its power-on state
|
||||||
mySystem->reset();
|
mySystem->reset();
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
// See the file "license" for information on usage and redistribution of
|
// See the file "license" for information on usage and redistribution of
|
||||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
//
|
//
|
||||||
// $Id: Console.hxx,v 1.9 2003-09-07 18:30:28 stephena Exp $
|
// $Id: Console.hxx,v 1.10 2003-09-12 18:08:53 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#ifndef CONSOLE_HXX
|
#ifndef CONSOLE_HXX
|
||||||
|
@ -27,6 +27,7 @@ class Frontend;
|
||||||
class MediaSource;
|
class MediaSource;
|
||||||
class PropertiesSet;
|
class PropertiesSet;
|
||||||
class Settings;
|
class Settings;
|
||||||
|
class Snapshot;
|
||||||
class Sound;
|
class Sound;
|
||||||
class Switches;
|
class Switches;
|
||||||
class System;
|
class System;
|
||||||
|
@ -35,11 +36,12 @@ class System;
|
||||||
#include "Control.hxx"
|
#include "Control.hxx"
|
||||||
#include "Props.hxx"
|
#include "Props.hxx"
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This class represents the entire game console.
|
This class represents the entire game console.
|
||||||
|
|
||||||
@author Bradford W. Mott
|
@author Bradford W. Mott
|
||||||
@version $Id: Console.hxx,v 1.9 2003-09-07 18:30:28 stephena Exp $
|
@version $Id: Console.hxx,v 1.10 2003-09-12 18:08:53 stephena Exp $
|
||||||
*/
|
*/
|
||||||
class Console
|
class Console
|
||||||
{
|
{
|
||||||
|
@ -160,6 +162,22 @@ class Console
|
||||||
*/
|
*/
|
||||||
static const Properties& defaultProperties();
|
static const Properties& defaultProperties();
|
||||||
|
|
||||||
|
#ifdef SNAPSHOT_SUPPORT
|
||||||
|
public:
|
||||||
|
// Pointer to the Snapshot object
|
||||||
|
Snapshot* mySnapshot;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Get the snapshot object of the console
|
||||||
|
|
||||||
|
@return The snapshot object for this console
|
||||||
|
*/
|
||||||
|
Snapshot& snapshot() const
|
||||||
|
{
|
||||||
|
return *mySnapshot;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef DEVELOPER_SUPPORT
|
#ifdef DEVELOPER_SUPPORT
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
// See the file "license" for information on usage and redistribution of
|
// See the file "license" for information on usage and redistribution of
|
||||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
//
|
//
|
||||||
// $Id: EventHandler.cxx,v 1.5 2003-09-07 18:30:28 stephena Exp $
|
// $Id: EventHandler.cxx,v 1.6 2003-09-12 18:08:53 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
@ -29,6 +29,9 @@
|
||||||
#include "System.hxx"
|
#include "System.hxx"
|
||||||
#include "bspf.hxx"
|
#include "bspf.hxx"
|
||||||
|
|
||||||
|
#ifdef SNAPSHOT_SUPPORT
|
||||||
|
#include "Snapshot.hxx"
|
||||||
|
#endif
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
EventHandler::EventHandler(Console* console)
|
EventHandler::EventHandler(Console* console)
|
||||||
|
@ -76,12 +79,6 @@ Event* EventHandler::event()
|
||||||
return myEvent;
|
return myEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
||||||
void EventHandler::setMediaSource(MediaSource* mediaSource)
|
|
||||||
{
|
|
||||||
myMediaSource = mediaSource;
|
|
||||||
}
|
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void EventHandler::sendKeyEvent(StellaEvent::KeyCode key, Int32 state)
|
void EventHandler::sendKeyEvent(StellaEvent::KeyCode key, Int32 state)
|
||||||
{
|
{
|
||||||
|
@ -110,11 +107,11 @@ void EventHandler::sendKeyEvent(StellaEvent::KeyCode key, Int32 state)
|
||||||
loadState();
|
loadState();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// else if(event == Event::TakeSnapshot)
|
else if(event == Event::TakeSnapshot)
|
||||||
// {
|
{
|
||||||
// FIXME ... make a call to takeSnapshot()
|
takeSnapshot();
|
||||||
// return;
|
return;
|
||||||
// }
|
}
|
||||||
else if(event == Event::Pause)
|
else if(event == Event::Pause)
|
||||||
{
|
{
|
||||||
myConsole->frontend().setPauseEvent();
|
myConsole->frontend().setPauseEvent();
|
||||||
|
@ -128,7 +125,7 @@ void EventHandler::sendKeyEvent(StellaEvent::KeyCode key, Int32 state)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ourMessageTable[event] != "")
|
if(ourMessageTable[event] != "")
|
||||||
myMediaSource->showMessage(ourMessageTable[event], 120);
|
myConsole->mediaSource().showMessage(ourMessageTable[event], 120);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise, pass it to the emulation core
|
// Otherwise, pass it to the emulation core
|
||||||
|
@ -164,11 +161,11 @@ void EventHandler::sendJoyEvent(StellaEvent::JoyStick stick,
|
||||||
loadState();
|
loadState();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// else if(event == Event::TakeSnapshot)
|
else if(event == Event::TakeSnapshot)
|
||||||
// {
|
{
|
||||||
// FIXME ... make a call to takeSnapshot()
|
takeSnapshot();
|
||||||
// return;
|
return;
|
||||||
// }
|
}
|
||||||
else if(event == Event::Pause)
|
else if(event == Event::Pause)
|
||||||
{
|
{
|
||||||
myConsole->frontend().setPauseEvent();
|
myConsole->frontend().setPauseEvent();
|
||||||
|
@ -182,7 +179,7 @@ void EventHandler::sendJoyEvent(StellaEvent::JoyStick stick,
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ourMessageTable[event] != "")
|
if(ourMessageTable[event] != "")
|
||||||
myMediaSource->showMessage(ourMessageTable[event], 120);
|
myConsole->mediaSource().showMessage(ourMessageTable[event], 120);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise, pass it to the emulation core
|
// Otherwise, pass it to the emulation core
|
||||||
|
@ -408,7 +405,7 @@ void EventHandler::saveState()
|
||||||
buf << "Invalid state " << myCurrentState << " file";
|
buf << "Invalid state " << myCurrentState << " file";
|
||||||
|
|
||||||
string message = buf.str();
|
string message = buf.str();
|
||||||
myMediaSource->showMessage(message, 120);
|
myConsole->mediaSource().showMessage(message, 120);
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -423,7 +420,7 @@ void EventHandler::changeState()
|
||||||
ostringstream buf;
|
ostringstream buf;
|
||||||
buf << "Changed to slot " << myCurrentState;
|
buf << "Changed to slot " << myCurrentState;
|
||||||
string message = buf.str();
|
string message = buf.str();
|
||||||
myMediaSource->showMessage(message, 120);
|
myConsole->mediaSource().showMessage(message, 120);
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -444,5 +441,24 @@ void EventHandler::loadState()
|
||||||
buf << "Invalid state " << myCurrentState << " file";
|
buf << "Invalid state " << myCurrentState << " file";
|
||||||
|
|
||||||
string message = buf.str();
|
string message = buf.str();
|
||||||
myMediaSource->showMessage(message, 120);
|
myConsole->mediaSource().showMessage(message, 120);
|
||||||
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
void EventHandler::takeSnapshot()
|
||||||
|
{
|
||||||
|
#ifdef SNAPSHOT_SUPPORT
|
||||||
|
string message, filename;
|
||||||
|
|
||||||
|
// Now save the snapshot file
|
||||||
|
filename = myConsole->frontend().snapshotFilename();
|
||||||
|
myConsole->snapshot().savePNG(filename, myConsole->mediaSource(),
|
||||||
|
myConsole->settings().theZoomLevel);
|
||||||
|
|
||||||
|
message = "Snapshot saved";
|
||||||
|
myConsole->mediaSource().showMessage(message, 120);
|
||||||
|
#else
|
||||||
|
string message = "Snapshots unsupported";
|
||||||
|
myConsole->mediaSource().showMessage(message, 120);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
// See the file "license" for information on usage and redistribution of
|
// See the file "license" for information on usage and redistribution of
|
||||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
//
|
//
|
||||||
// $Id: EventHandler.hxx,v 1.5 2003-09-07 18:30:28 stephena Exp $
|
// $Id: EventHandler.hxx,v 1.6 2003-09-12 18:08:53 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#ifndef EVENTHANDLER_HXX
|
#ifndef EVENTHANDLER_HXX
|
||||||
|
@ -40,7 +40,7 @@ class MediaSource;
|
||||||
unchanged to the remap class, where key remapping can take place.
|
unchanged to the remap class, where key remapping can take place.
|
||||||
|
|
||||||
@author Stephen Anthony
|
@author Stephen Anthony
|
||||||
@version $Id: EventHandler.hxx,v 1.5 2003-09-07 18:30:28 stephena Exp $
|
@version $Id: EventHandler.hxx,v 1.6 2003-09-12 18:08:53 stephena Exp $
|
||||||
*/
|
*/
|
||||||
class EventHandler
|
class EventHandler
|
||||||
{
|
{
|
||||||
|
@ -122,6 +122,7 @@ class EventHandler
|
||||||
void saveState();
|
void saveState();
|
||||||
void changeState();
|
void changeState();
|
||||||
void loadState();
|
void loadState();
|
||||||
|
void takeSnapshot();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Array of key events
|
// Array of key events
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
// See the file "license" for information on usage and redistribution of
|
// See the file "license" for information on usage and redistribution of
|
||||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
//
|
//
|
||||||
// $Id: Frontend.hxx,v 1.4 2003-09-11 20:53:51 stephena Exp $
|
// $Id: Frontend.hxx,v 1.5 2003-09-12 18:08:53 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#ifndef FRONTEND_HXX
|
#ifndef FRONTEND_HXX
|
||||||
|
@ -27,7 +27,7 @@ class Console;
|
||||||
This class provides an interface for accessing frontend specific data.
|
This class provides an interface for accessing frontend specific data.
|
||||||
|
|
||||||
@author Stephen Anthony
|
@author Stephen Anthony
|
||||||
@version $Id: Frontend.hxx,v 1.4 2003-09-11 20:53:51 stephena Exp $
|
@version $Id: Frontend.hxx,v 1.5 2003-09-12 18:08:53 stephena Exp $
|
||||||
*/
|
*/
|
||||||
class Frontend
|
class Frontend
|
||||||
{
|
{
|
||||||
|
@ -84,12 +84,11 @@ class Frontend
|
||||||
virtual string stateFilename(string& md5, uInt32 state) = 0;
|
virtual string stateFilename(string& md5, uInt32 state) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This method should be called to get the filename of a snapshot
|
This method should be called to get the filename of a snapshot.
|
||||||
file given the md5 and state number.
|
|
||||||
|
|
||||||
@return String representing the full path of the snapshot filename.
|
@return String representing the full path of the snapshot filename.
|
||||||
*/
|
*/
|
||||||
virtual string snapshotFilename(string& md5, uInt32 state) = 0;
|
virtual string snapshotFilename() = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This method should be called to get the filename of the users
|
This method should be called to get the filename of the users
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
// See the file "license" for information on usage and redistribution of
|
// See the file "license" for information on usage and redistribution of
|
||||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
//
|
//
|
||||||
// $Id: Settings.cxx,v 1.3 2003-09-11 20:53:51 stephena Exp $
|
// $Id: Settings.cxx,v 1.4 2003-09-12 18:08:53 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#include "bspf.hxx"
|
#include "bspf.hxx"
|
||||||
|
@ -22,6 +22,12 @@
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
Settings::Settings()
|
Settings::Settings()
|
||||||
{
|
{
|
||||||
|
theKeymapList = "";
|
||||||
|
theJoymapList = "";
|
||||||
|
theSnapshotDir = "";
|
||||||
|
theSnapshotName = "romname";
|
||||||
|
theMultipleSnapshotFlag = true;
|
||||||
|
theZoomLevel = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
// See the file "license" for information on usage and redistribution of
|
// See the file "license" for information on usage and redistribution of
|
||||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
//
|
//
|
||||||
// $Id: Settings.hxx,v 1.3 2003-09-11 20:53:51 stephena Exp $
|
// $Id: Settings.hxx,v 1.4 2003-09-12 18:08:53 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#ifndef SETTINGS_HXX
|
#ifndef SETTINGS_HXX
|
||||||
|
@ -32,7 +32,7 @@ class Console;
|
||||||
This class provides an interface for accessing frontend specific settings.
|
This class provides an interface for accessing frontend specific settings.
|
||||||
|
|
||||||
@author Stephen Anthony
|
@author Stephen Anthony
|
||||||
@version $Id: Settings.hxx,v 1.3 2003-09-11 20:53:51 stephena Exp $
|
@version $Id: Settings.hxx,v 1.4 2003-09-12 18:08:53 stephena Exp $
|
||||||
*/
|
*/
|
||||||
class Settings
|
class Settings
|
||||||
{
|
{
|
||||||
|
@ -68,7 +68,7 @@ class Settings
|
||||||
virtual void setConsole(Console* console) = 0;
|
virtual void setConsole(Console* console) = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// The following settings are used by the emulation core and are
|
// The following settings are needed by the emulation core and are
|
||||||
// common among all settings objects
|
// common among all settings objects
|
||||||
|
|
||||||
// The keymap to use
|
// The keymap to use
|
||||||
|
@ -77,6 +77,19 @@ class Settings
|
||||||
// The joymap to use
|
// The joymap to use
|
||||||
string theJoymapList;
|
string theJoymapList;
|
||||||
|
|
||||||
|
// The path to save snapshot files
|
||||||
|
string theSnapshotDir;
|
||||||
|
|
||||||
|
// What the snapshot should be called (romname or md5sum)
|
||||||
|
string theSnapshotName;
|
||||||
|
|
||||||
|
// Indicates whether to generate multiple snapshots or keep
|
||||||
|
// overwriting the same file.
|
||||||
|
bool theMultipleSnapshotFlag;
|
||||||
|
|
||||||
|
// The amount the of zoom for the window/screen
|
||||||
|
uInt32 theZoomLevel;
|
||||||
|
|
||||||
#ifdef DEVELOPER_SUPPORT
|
#ifdef DEVELOPER_SUPPORT
|
||||||
// User-modified properties
|
// User-modified properties
|
||||||
Properties userDefinedProperties;
|
Properties userDefinedProperties;
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
// See the file "license" for information on usage and redistribution of
|
// See the file "license" for information on usage and redistribution of
|
||||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
//
|
//
|
||||||
// $Id: SettingsUNIX.cxx,v 1.1 2003-09-11 20:53:51 stephena Exp $
|
// $Id: SettingsUNIX.cxx,v 1.2 2003-09-12 18:08:53 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
@ -34,24 +34,18 @@ SettingsUNIX::SettingsUNIX(const string& infile, const string& outfile)
|
||||||
: mySettingsInputFilename(infile),
|
: mySettingsInputFilename(infile),
|
||||||
mySettingsOutputFilename(outfile)
|
mySettingsOutputFilename(outfile)
|
||||||
{
|
{
|
||||||
theKeymapList = "";
|
|
||||||
theJoymapList = "";
|
|
||||||
theUseFullScreenFlag = false;
|
theUseFullScreenFlag = false;
|
||||||
theGrabMouseFlag = false;
|
theGrabMouseFlag = false;
|
||||||
theCenterWindowFlag = false;
|
theCenterWindowFlag = false;
|
||||||
theShowInfoFlag = false;
|
theShowInfoFlag = false;
|
||||||
theHideCursorFlag = false;
|
theHideCursorFlag = false;
|
||||||
theUsePrivateColormapFlag = false;
|
theUsePrivateColormapFlag = false;
|
||||||
theMultipleSnapShotFlag = true;
|
|
||||||
theAccurateTimingFlag = true;
|
theAccurateTimingFlag = true;
|
||||||
theDesiredVolume = -1;
|
theDesiredVolume = -1;
|
||||||
theDesiredFrameRate = 60;
|
theDesiredFrameRate = 60;
|
||||||
thePaddleMode = 0;
|
thePaddleMode = 0;
|
||||||
theAlternateProFile = "";
|
theAlternateProFile = "";
|
||||||
theSnapShotDir = "";
|
|
||||||
theSnapShotName = "";
|
|
||||||
theSoundDriver = "oss";
|
theSoundDriver = "oss";
|
||||||
theWindowSize = 1;
|
|
||||||
theLeftJoystickNumber = 0;
|
theLeftJoystickNumber = 0;
|
||||||
theRightJoystickNumber = 1;
|
theRightJoystickNumber = 1;
|
||||||
|
|
||||||
|
@ -146,8 +140,8 @@ void SettingsUNIX::parseArg(string& key, string& value)
|
||||||
{
|
{
|
||||||
// They're setting the desired frame rate
|
// They're setting the desired frame rate
|
||||||
uInt32 rate = atoi(value.c_str());
|
uInt32 rate = atoi(value.c_str());
|
||||||
if((rate < 1) || (rate > 300))
|
if(rate < 1)
|
||||||
cout << "Invalid rate " << rate << " (1-300)\n";
|
cout << "Invalid rate " << rate << endl;
|
||||||
else
|
else
|
||||||
theDesiredFrameRate = rate;
|
theDesiredFrameRate = rate;
|
||||||
}
|
}
|
||||||
|
@ -225,11 +219,11 @@ void SettingsUNIX::parseArg(string& key, string& value)
|
||||||
else if(key == "zoom")
|
else if(key == "zoom")
|
||||||
{
|
{
|
||||||
// They're setting the initial window size
|
// They're setting the initial window size
|
||||||
uInt32 size = atoi(value.c_str());
|
uInt32 zoom = atoi(value.c_str());
|
||||||
if((size < 1) || (size > 4))
|
if(zoom < 1)
|
||||||
cout << "Invalid zoom value " << size << " (1-4)\n";
|
cout << "Invalid zoom value " << zoom << endl;
|
||||||
else
|
else
|
||||||
theWindowSize = size;
|
theZoomLevel = zoom;
|
||||||
}
|
}
|
||||||
else if(key == "volume")
|
else if(key == "volume")
|
||||||
{
|
{
|
||||||
|
@ -244,19 +238,22 @@ void SettingsUNIX::parseArg(string& key, string& value)
|
||||||
}
|
}
|
||||||
else if(key == "ssdir")
|
else if(key == "ssdir")
|
||||||
{
|
{
|
||||||
theSnapShotDir = value;
|
theSnapshotDir = value;
|
||||||
}
|
}
|
||||||
else if(key == "ssname")
|
else if(key == "ssname")
|
||||||
{
|
{
|
||||||
theSnapShotName = value;
|
if((value != "md5sum") && (value != "romname"))
|
||||||
|
cout << "Invalid snapshot name " << value << endl;
|
||||||
|
else
|
||||||
|
theSnapshotName = value;
|
||||||
}
|
}
|
||||||
else if(key == "sssingle")
|
else if(key == "sssingle")
|
||||||
{
|
{
|
||||||
uInt32 option = atoi(value.c_str());
|
uInt32 option = atoi(value.c_str());
|
||||||
if(option == 1)
|
if(option == 1)
|
||||||
theMultipleSnapShotFlag = false;
|
theMultipleSnapshotFlag = false;
|
||||||
else if(option == 0)
|
else if(option == 0)
|
||||||
theMultipleSnapShotFlag = true;
|
theMultipleSnapshotFlag = true;
|
||||||
}
|
}
|
||||||
else if(key == "sound")
|
else if(key == "sound")
|
||||||
{
|
{
|
||||||
|
@ -324,11 +321,11 @@ void SettingsUNIX::save()
|
||||||
<< "center = " << theCenterWindowFlag << endl
|
<< "center = " << theCenterWindowFlag << endl
|
||||||
<< "showinfo = " << theShowInfoFlag << endl
|
<< "showinfo = " << theShowInfoFlag << endl
|
||||||
<< "accurate = " << theAccurateTimingFlag << endl
|
<< "accurate = " << theAccurateTimingFlag << endl
|
||||||
<< "zoom = " << theWindowSize << endl
|
<< "zoom = " << theZoomLevel << endl
|
||||||
<< "volume = " << theDesiredVolume << endl
|
<< "volume = " << theDesiredVolume << endl
|
||||||
<< "ssdir = " << theSnapShotDir << endl
|
<< "ssdir = " << theSnapshotDir << endl
|
||||||
<< "ssname = " << theSnapShotName << endl
|
<< "ssname = " << theSnapshotName << endl
|
||||||
<< "sssingle = " << theMultipleSnapShotFlag << endl
|
<< "sssingle = " << theMultipleSnapshotFlag << endl
|
||||||
<< "sound = " << theSoundDriver << endl
|
<< "sound = " << theSoundDriver << endl
|
||||||
#ifdef DEVELOPER_SUPPORT
|
#ifdef DEVELOPER_SUPPORT
|
||||||
<< "Dmerge = " << theMergePropertiesFlag << endl
|
<< "Dmerge = " << theMergePropertiesFlag << endl
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
// See the file "license" for information on usage and redistribution of
|
// See the file "license" for information on usage and redistribution of
|
||||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
//
|
//
|
||||||
// $Id: SettingsUNIX.hxx,v 1.1 2003-09-11 20:53:51 stephena Exp $
|
// $Id: SettingsUNIX.hxx,v 1.2 2003-09-12 18:08:54 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#ifndef SETTINGS_UNIX_HXX
|
#ifndef SETTINGS_UNIX_HXX
|
||||||
|
@ -28,7 +28,7 @@ class Console;
|
||||||
This class defines UNIX-like OS's (Linux) system specific settings.
|
This class defines UNIX-like OS's (Linux) system specific settings.
|
||||||
|
|
||||||
@author Stephen Anthony
|
@author Stephen Anthony
|
||||||
@version $Id: SettingsUNIX.hxx,v 1.1 2003-09-11 20:53:51 stephena Exp $
|
@version $Id: SettingsUNIX.hxx,v 1.2 2003-09-12 18:08:54 stephena Exp $
|
||||||
*/
|
*/
|
||||||
class SettingsUNIX : public Settings
|
class SettingsUNIX : public Settings
|
||||||
{
|
{
|
||||||
|
@ -86,10 +86,6 @@ class SettingsUNIX : public Settings
|
||||||
// Indicates whether to allocate colors from a private color map
|
// Indicates whether to allocate colors from a private color map
|
||||||
bool theUsePrivateColormapFlag;
|
bool theUsePrivateColormapFlag;
|
||||||
|
|
||||||
// Indicates whether to generate multiple snapshots or keep
|
|
||||||
// overwriting the same file. Set to true by default.
|
|
||||||
bool theMultipleSnapShotFlag;
|
|
||||||
|
|
||||||
// Indicates whether to use more/less accurate emulation,
|
// Indicates whether to use more/less accurate emulation,
|
||||||
// resulting in more/less CPU usage.
|
// resulting in more/less CPU usage.
|
||||||
bool theAccurateTimingFlag;
|
bool theAccurateTimingFlag;
|
||||||
|
@ -111,18 +107,9 @@ class SettingsUNIX : public Settings
|
||||||
// An alternate properties file to use
|
// An alternate properties file to use
|
||||||
string theAlternateProFile;
|
string theAlternateProFile;
|
||||||
|
|
||||||
// The path to save snapshot files
|
|
||||||
string theSnapShotDir;
|
|
||||||
|
|
||||||
// What the snapshot should be called (romname or md5sum)
|
|
||||||
string theSnapShotName;
|
|
||||||
|
|
||||||
// Indicates which sound driver to use at run-time
|
// Indicates which sound driver to use at run-time
|
||||||
string theSoundDriver;
|
string theSoundDriver;
|
||||||
|
|
||||||
// The size of the window/screen
|
|
||||||
uInt32 theWindowSize;
|
|
||||||
|
|
||||||
// The left joystick number (0 .. StellaEvent::LastJSTICK)
|
// The left joystick number (0 .. StellaEvent::LastJSTICK)
|
||||||
Int32 theLeftJoystickNumber;
|
Int32 theLeftJoystickNumber;
|
||||||
|
|
||||||
|
|
|
@ -13,13 +13,14 @@
|
||||||
// See the file "license" for information on usage and redistribution of
|
// See the file "license" for information on usage and redistribution of
|
||||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
//
|
//
|
||||||
// $Id: Snapshot.cxx,v 1.4 2002-12-05 16:44:56 stephena Exp $
|
// $Id: Snapshot.cxx,v 1.5 2003-09-12 18:08:54 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#include <png.h>
|
#include <png.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
|
#include "bspf.hxx"
|
||||||
#include "Snapshot.hxx"
|
#include "Snapshot.hxx"
|
||||||
|
|
||||||
|
|
||||||
|
@ -60,7 +61,7 @@ void Snapshot::png_user_error(png_structp ctx, png_const_charp str)
|
||||||
This routine saves the current frame buffer to a 256 color PNG file,
|
This routine saves the current frame buffer to a 256 color PNG file,
|
||||||
appropriately scaled by the amount specified in 'multiplier'.
|
appropriately scaled by the amount specified in 'multiplier'.
|
||||||
*/
|
*/
|
||||||
int Snapshot::savePNG(string filename, MediaSource& mediaSource, int multiplier)
|
int Snapshot::savePNG(string filename, MediaSource& mediaSource, uInt32 multiplier)
|
||||||
{
|
{
|
||||||
png_structp png_ptr = 0;
|
png_structp png_ptr = 0;
|
||||||
png_infop info_ptr = 0;
|
png_infop info_ptr = 0;
|
||||||
|
|
|
@ -13,15 +13,15 @@
|
||||||
// See the file "license" for information on usage and redistribution of
|
// See the file "license" for information on usage and redistribution of
|
||||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
//
|
//
|
||||||
// $Id: Snapshot.hxx,v 1.1 2002-03-10 01:29:54 stephena Exp $
|
// $Id: Snapshot.hxx,v 1.2 2003-09-12 18:08:54 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#ifndef SNAPSHOT_HXX
|
#ifndef SNAPSHOT_HXX
|
||||||
#define SNAPSHOT_HXX
|
#define SNAPSHOT_HXX
|
||||||
|
|
||||||
#include <png.h>
|
#include <png.h>
|
||||||
#include <string>
|
|
||||||
|
|
||||||
|
#include "bspf.hxx"
|
||||||
#include "MediaSrc.hxx"
|
#include "MediaSrc.hxx"
|
||||||
|
|
||||||
class Snapshot
|
class Snapshot
|
||||||
|
@ -30,7 +30,7 @@ class Snapshot
|
||||||
Snapshot();
|
Snapshot();
|
||||||
~Snapshot();
|
~Snapshot();
|
||||||
|
|
||||||
int savePNG(string filename, MediaSource& mediaSource, int multiplier = 1);
|
int savePNG(string filename, MediaSource& mediaSource, uInt32 multiplier = 1);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void png_write_data(png_structp ctx, png_bytep area, png_size_t size);
|
static void png_write_data(png_structp ctx, png_bytep area, png_size_t size);
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
// See the file "license" for information on usage and redistribution of
|
// See the file "license" for information on usage and redistribution of
|
||||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
//
|
//
|
||||||
// $Id: FrontendUNIX.cxx,v 1.2 2003-09-06 21:17:48 stephena Exp $
|
// $Id: FrontendUNIX.cxx,v 1.3 2003-09-12 18:08:54 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
@ -26,11 +26,13 @@
|
||||||
#include "bspf.hxx"
|
#include "bspf.hxx"
|
||||||
#include "Console.hxx"
|
#include "Console.hxx"
|
||||||
#include "FrontendUNIX.hxx"
|
#include "FrontendUNIX.hxx"
|
||||||
|
#include "Settings.hxx"
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
FrontendUNIX::FrontendUNIX()
|
FrontendUNIX::FrontendUNIX()
|
||||||
: myPauseIndicator(false),
|
: myPauseIndicator(false),
|
||||||
myQuitIndicator(false)
|
myQuitIndicator(false),
|
||||||
|
myConsole(0)
|
||||||
{
|
{
|
||||||
myHomeDir = getenv("HOME");
|
myHomeDir = getenv("HOME");
|
||||||
string path = myHomeDir + "/.stella";
|
string path = myHomeDir + "/.stella";
|
||||||
|
@ -97,8 +99,45 @@ string FrontendUNIX::stateFilename(string& md5, uInt32 state)
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
string FrontendUNIX::snapshotFilename(string& md5, uInt32 state)
|
string FrontendUNIX::snapshotFilename()
|
||||||
{
|
{
|
||||||
|
if(!myConsole)
|
||||||
|
return "";
|
||||||
|
|
||||||
|
string path = myConsole->settings().theSnapshotDir;
|
||||||
|
string filename;
|
||||||
|
|
||||||
|
if(myConsole->settings().theSnapshotName == "romname")
|
||||||
|
path = path + "/" + myConsole->properties().get("Cartridge.Name");
|
||||||
|
else if(myConsole->settings().theSnapshotName == "md5sum")
|
||||||
|
path = path + "/" + myConsole->properties().get("Cartridge.MD5");
|
||||||
|
|
||||||
|
// Replace all spaces in name with underscores
|
||||||
|
replace(path.begin(), path.end(), ' ', '_');
|
||||||
|
|
||||||
|
// Check whether we want multiple snapshots created
|
||||||
|
if(myConsole->settings().theMultipleSnapshotFlag)
|
||||||
|
{
|
||||||
|
// Determine if the file already exists, checking each successive filename
|
||||||
|
// until one doesn't exist
|
||||||
|
filename = path + ".png";
|
||||||
|
if(access(filename.c_str(), F_OK) == 0 )
|
||||||
|
{
|
||||||
|
ostringstream buf;
|
||||||
|
for(uInt32 i = 1; ;++i)
|
||||||
|
{
|
||||||
|
buf.str("");
|
||||||
|
buf << path << "_" << i << ".png";
|
||||||
|
if(access(buf.str().c_str(), F_OK) == -1 )
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
filename = buf.str();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
filename = path + ".png";
|
||||||
|
|
||||||
|
mySnapshotFile = filename;
|
||||||
return mySnapshotFile;
|
return mySnapshotFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
// See the file "license" for information on usage and redistribution of
|
// See the file "license" for information on usage and redistribution of
|
||||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
//
|
//
|
||||||
// $Id: FrontendUNIX.hxx,v 1.3 2003-09-07 18:30:28 stephena Exp $
|
// $Id: FrontendUNIX.hxx,v 1.4 2003-09-12 18:08:54 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#ifndef FRONTEND_UNIX_HXX
|
#ifndef FRONTEND_UNIX_HXX
|
||||||
|
@ -29,7 +29,7 @@ class Console;
|
||||||
and events.
|
and events.
|
||||||
|
|
||||||
@author Stephen Anthony
|
@author Stephen Anthony
|
||||||
@version $Id: FrontendUNIX.hxx,v 1.3 2003-09-07 18:30:28 stephena Exp $
|
@version $Id: FrontendUNIX.hxx,v 1.4 2003-09-12 18:08:54 stephena Exp $
|
||||||
*/
|
*/
|
||||||
class FrontendUNIX : public Frontend
|
class FrontendUNIX : public Frontend
|
||||||
{
|
{
|
||||||
|
@ -80,13 +80,11 @@ class FrontendUNIX : public Frontend
|
||||||
virtual string stateFilename(string& md5, uInt32 state);
|
virtual string stateFilename(string& md5, uInt32 state);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Returns the UNIX filename representing a state file.
|
Returns the UNIX filename representing a snapshot file.
|
||||||
|
|
||||||
@param md5 The md5 string to use as part of the filename.
|
|
||||||
@param state The state number to use as part of the filename.
|
|
||||||
@return The full path and filename of the snapshot file.
|
@return The full path and filename of the snapshot file.
|
||||||
*/
|
*/
|
||||||
virtual string snapshotFilename(string& md5, uInt32 state);
|
virtual string snapshotFilename();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Returns the UNIX filename representing a users properties file.
|
Returns the UNIX filename representing a users properties file.
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
// See the file "license" for information on usage and redistribution of
|
// See the file "license" for information on usage and redistribution of
|
||||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
//
|
//
|
||||||
// $Id: mainSDL.cxx,v 1.49 2003-09-11 20:53:51 stephena Exp $
|
// $Id: mainSDL.cxx,v 1.50 2003-09-12 18:08:54 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
@ -54,10 +54,6 @@
|
||||||
#include "SoundSDL.hxx"
|
#include "SoundSDL.hxx"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_PNG
|
|
||||||
#include "Snapshot.hxx"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef UNIX
|
#ifdef UNIX
|
||||||
#include "FrontendUNIX.hxx"
|
#include "FrontendUNIX.hxx"
|
||||||
#include "SettingsUNIX.hxx"
|
#include "SettingsUNIX.hxx"
|
||||||
|
@ -112,8 +108,6 @@ static bool setupProperties(PropertiesSet& set);
|
||||||
static void handleRCFile();
|
static void handleRCFile();
|
||||||
static void usage();
|
static void usage();
|
||||||
|
|
||||||
static string theSnapShotDir, theSnapShotName;
|
|
||||||
|
|
||||||
#ifdef HAVE_JOYSTICK
|
#ifdef HAVE_JOYSTICK
|
||||||
static SDL_Joystick* theLeftJoystick = (SDL_Joystick*) NULL;
|
static SDL_Joystick* theLeftJoystick = (SDL_Joystick*) NULL;
|
||||||
static SDL_Joystick* theRightJoystick = (SDL_Joystick*) NULL;
|
static SDL_Joystick* theRightJoystick = (SDL_Joystick*) NULL;
|
||||||
|
@ -123,10 +117,6 @@ static string theSnapShotDir, theSnapShotName;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_PNG
|
|
||||||
static Snapshot* theSnapshot;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Pointer to the console object or the null pointer
|
// Pointer to the console object or the null pointer
|
||||||
static Console* theConsole = (Console*) NULL;
|
static Console* theConsole = (Console*) NULL;
|
||||||
|
|
||||||
|
@ -323,10 +313,10 @@ bool setupDisplay()
|
||||||
theMaxWindowSize = maxWindowSizeForScreen();
|
theMaxWindowSize = maxWindowSizeForScreen();
|
||||||
|
|
||||||
// Check to see if window size will fit in the screen
|
// Check to see if window size will fit in the screen
|
||||||
if(theSettings->theWindowSize > theMaxWindowSize)
|
if(theSettings->theZoomLevel > theMaxWindowSize)
|
||||||
theWindowSize = theMaxWindowSize;
|
theWindowSize = theMaxWindowSize;
|
||||||
else
|
else
|
||||||
theWindowSize = theSettings->theWindowSize;
|
theWindowSize = theSettings->theZoomLevel;
|
||||||
|
|
||||||
// Set up the rectangle list to be used in updateDisplay
|
// Set up the rectangle list to be used in updateDisplay
|
||||||
rectList = new RectList();
|
rectList = new RectList();
|
||||||
|
@ -870,10 +860,6 @@ void handleEvents()
|
||||||
{
|
{
|
||||||
toggleFullscreen();
|
toggleFullscreen();
|
||||||
}
|
}
|
||||||
else if(key == SDLK_F12)
|
|
||||||
{
|
|
||||||
takeSnapshot();
|
|
||||||
}
|
|
||||||
else if((mod & KMOD_CTRL) && key == SDLK_g)
|
else if((mod & KMOD_CTRL) && key == SDLK_g)
|
||||||
{
|
{
|
||||||
// don't change grabmouse in fullscreen mode
|
// don't change grabmouse in fullscreen mode
|
||||||
|
@ -1098,88 +1084,6 @@ void handleEvents()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Called when the user wants to take a snapshot of the current display.
|
|
||||||
Images are stored in png format in the directory specified by the 'ssdir'
|
|
||||||
argument, or in $HOME by default.
|
|
||||||
Images are named consecutively as "NAME".png, where name is specified by
|
|
||||||
the 'ssname' argument. If that name exists, they are named as "Name"_x.png,
|
|
||||||
where x starts with 1 and increases if the previous name already exists.
|
|
||||||
All spaces in filenames are converted to underscore '_'.
|
|
||||||
If theMultipleSnapShotFlag is false, then consecutive images are overwritten.
|
|
||||||
*/
|
|
||||||
void takeSnapshot()
|
|
||||||
{
|
|
||||||
#ifdef HAVE_PNG
|
|
||||||
string message;
|
|
||||||
|
|
||||||
if(!theSnapshot)
|
|
||||||
{
|
|
||||||
message = "Snapshots disabled";
|
|
||||||
theConsole->mediaSource().showMessage(message, 120);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now find the correct name for the snapshot
|
|
||||||
string path = theSnapShotDir;
|
|
||||||
string filename;
|
|
||||||
|
|
||||||
if(theSnapShotName == "romname")
|
|
||||||
path = path + "/" + theConsole->properties().get("Cartridge.Name");
|
|
||||||
else if(theSnapShotName == "md5sum")
|
|
||||||
path = path + "/" + theConsole->properties().get("Cartridge.MD5");
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cerr << "ERROR: unknown name " << theSnapShotName
|
|
||||||
<< " for snapshot type" << endl;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Replace all spaces in name with underscores
|
|
||||||
replace(path.begin(), path.end(), ' ', '_');
|
|
||||||
|
|
||||||
// Check whether we want multiple snapshots created
|
|
||||||
if(theSettings->theMultipleSnapShotFlag)
|
|
||||||
{
|
|
||||||
// Determine if the file already exists, checking each successive filename
|
|
||||||
// until one doesn't exist
|
|
||||||
filename = path + ".png";
|
|
||||||
if(access(filename.c_str(), F_OK) == 0 )
|
|
||||||
{
|
|
||||||
ostringstream buf;
|
|
||||||
for(uInt32 i = 1; ;++i)
|
|
||||||
{
|
|
||||||
buf.str("");
|
|
||||||
buf << path << "_" << i << ".png";
|
|
||||||
if(access(buf.str().c_str(), F_OK) == -1 )
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
filename = buf.str();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
filename = path + ".png";
|
|
||||||
|
|
||||||
// Now save the snapshot file
|
|
||||||
theSnapshot->savePNG(filename, theConsole->mediaSource(), theWindowSize);
|
|
||||||
|
|
||||||
if(access(filename.c_str(), F_OK) == 0)
|
|
||||||
{
|
|
||||||
message = "Snapshot saved";
|
|
||||||
theConsole->mediaSource().showMessage(message, 120);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
message = "Snapshot not saved";
|
|
||||||
theConsole->mediaSource().showMessage(message, 120);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
string message = "Snapshots unsupported";
|
|
||||||
theConsole->mediaSource().showMessage(message, 120);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Calculate the maximum window size that the current screen can hold.
|
Calculate the maximum window size that the current screen can hold.
|
||||||
Only works in X11 for now. If not running under X11, always return 3.
|
Only works in X11 for now. If not running under X11, always return 3.
|
||||||
|
@ -1217,7 +1121,7 @@ uInt32 maxWindowSizeForScreen()
|
||||||
}
|
}
|
||||||
|
|
||||||
if(found)
|
if(found)
|
||||||
return (multiplier > 4 ? 4 : multiplier);
|
return multiplier;
|
||||||
else
|
else
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -1282,11 +1186,6 @@ void cleanup()
|
||||||
if(theConsole)
|
if(theConsole)
|
||||||
delete theConsole;
|
delete theConsole;
|
||||||
|
|
||||||
#ifdef HAVE_PNG
|
|
||||||
if(theSnapshot)
|
|
||||||
delete theSnapshot;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if(theSound)
|
if(theSound)
|
||||||
{
|
{
|
||||||
theSound->closeDevice();
|
theSound->closeDevice();
|
||||||
|
@ -1347,21 +1246,6 @@ int main(int argc, char* argv[])
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_PNG
|
|
||||||
// Take care of the snapshot stuff.
|
|
||||||
theSnapshot = new Snapshot();
|
|
||||||
|
|
||||||
if(theSettings->theSnapShotDir == "")
|
|
||||||
theSnapShotDir = theFrontend->userHomeDir();
|
|
||||||
else
|
|
||||||
theSnapShotDir = theSettings->theSnapShotDir;
|
|
||||||
|
|
||||||
if(theSettings->theSnapShotName == "")
|
|
||||||
theSnapShotName = "romname";
|
|
||||||
else
|
|
||||||
theSnapShotName = theSettings->theSnapShotName;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Get a pointer to the file which contains the cartridge ROM
|
// Get a pointer to the file which contains the cartridge ROM
|
||||||
const char* file = argv[argc - 1];
|
const char* file = argv[argc - 1];
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
// See the file "license" for information on usage and redistribution of
|
// See the file "license" for information on usage and redistribution of
|
||||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
//
|
//
|
||||||
// $Id: mainX11.cxx,v 1.40 2003-09-11 20:53:51 stephena Exp $
|
// $Id: mainX11.cxx,v 1.41 2003-09-12 18:08:54 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
@ -22,8 +22,6 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#ifdef HAVE_GETTIMEOFDAY
|
#ifdef HAVE_GETTIMEOFDAY
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
@ -55,10 +53,6 @@
|
||||||
#include "SoundOSS.hxx"
|
#include "SoundOSS.hxx"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_PNG
|
|
||||||
#include "Snapshot.hxx"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_JOYSTICK
|
#ifdef HAVE_JOYSTICK
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
@ -104,23 +98,11 @@ static void cleanup();
|
||||||
static bool setupJoystick();
|
static bool setupJoystick();
|
||||||
static void handleEvents();
|
static void handleEvents();
|
||||||
|
|
||||||
static void takeSnapshot();
|
|
||||||
|
|
||||||
static uInt32 getTicks();
|
static uInt32 getTicks();
|
||||||
static bool setupProperties(PropertiesSet& set);
|
static bool setupProperties(PropertiesSet& set);
|
||||||
static void handleRCFile();
|
static void handleRCFile();
|
||||||
static void usage();
|
static void usage();
|
||||||
|
|
||||||
static void loadState();
|
|
||||||
static void saveState();
|
|
||||||
static void changeState(int direction);
|
|
||||||
|
|
||||||
static string theSnapShotDir, theSnapShotName;
|
|
||||||
|
|
||||||
#ifdef HAVE_PNG
|
|
||||||
static Snapshot* theSnapshot;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_JOYSTICK
|
#ifdef HAVE_JOYSTICK
|
||||||
// File descriptors for the joystick devices
|
// File descriptors for the joystick devices
|
||||||
static int theLeftJoystickFd;
|
static int theLeftJoystickFd;
|
||||||
|
@ -327,10 +309,10 @@ bool setupDisplay()
|
||||||
theMaxWindowSize = maxWindowSizeForScreen();
|
theMaxWindowSize = maxWindowSizeForScreen();
|
||||||
|
|
||||||
// Check to see if window size will fit in the screen
|
// Check to see if window size will fit in the screen
|
||||||
if(theSettings->theWindowSize > theMaxWindowSize)
|
if(theSettings->theZoomLevel > theMaxWindowSize)
|
||||||
theWindowSize = theMaxWindowSize;
|
theWindowSize = theMaxWindowSize;
|
||||||
else
|
else
|
||||||
theWindowSize = theSettings->theWindowSize;
|
theWindowSize = theSettings->theZoomLevel;
|
||||||
|
|
||||||
// Figure out the desired size of the window
|
// Figure out the desired size of the window
|
||||||
int width = theWidth * theWindowSize * 2;
|
int width = theWidth * theWindowSize * 2;
|
||||||
|
@ -673,10 +655,6 @@ void handleEvents()
|
||||||
{
|
{
|
||||||
resizeWindow(0);
|
resizeWindow(0);
|
||||||
}
|
}
|
||||||
else if((key == XK_F12) && (event.type == KeyPress))
|
|
||||||
{
|
|
||||||
takeSnapshot();
|
|
||||||
}
|
|
||||||
// FIXME - change x to Ctrl-x
|
// FIXME - change x to Ctrl-x
|
||||||
else if((key == XK_g) && (event.type == KeyPress))
|
else if((key == XK_g) && (event.type == KeyPress))
|
||||||
{
|
{
|
||||||
|
@ -1091,86 +1069,6 @@ bool createCursors()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
Called when the user wants to take a snapshot of the current display.
|
|
||||||
Images are stored in png format in the directory specified by the 'ssdir'
|
|
||||||
argument, or in $HOME by default.
|
|
||||||
Images are named consecutively as "NAME".png, where name is specified by
|
|
||||||
the 'ssname' argument. If that name exists, they are named as "Name"_x.png,
|
|
||||||
where x starts with 1 and increases if the previous name already exists.
|
|
||||||
All spaces in filenames are converted to underscore '_'.
|
|
||||||
If theMultipleSnapShotFlag is false, then consecutive images are overwritten.
|
|
||||||
*/
|
|
||||||
void takeSnapshot()
|
|
||||||
{
|
|
||||||
#ifdef HAVE_PNG
|
|
||||||
string message;
|
|
||||||
|
|
||||||
if(!theSnapshot)
|
|
||||||
{
|
|
||||||
message = "Snapshots disabled";
|
|
||||||
theConsole->mediaSource().showMessage(message, 120);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now find the correct name for the snapshot
|
|
||||||
string path = theSettings->theSnapShotDir;
|
|
||||||
string filename;
|
|
||||||
|
|
||||||
if(theSettings->theSnapShotName == "romname")
|
|
||||||
path = path + "/" + theConsole->properties().get("Cartridge.Name");
|
|
||||||
else if(theSettings->theSnapShotName == "md5sum")
|
|
||||||
path = path + "/" + theConsole->properties().get("Cartridge.MD5");
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cerr << "ERROR: unknown name " << theSettings->theSnapShotName
|
|
||||||
<< " for snapshot type" << endl;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Replace all spaces in name with underscores
|
|
||||||
replace(path.begin(), path.end(), ' ', '_');
|
|
||||||
|
|
||||||
// Check whether we want multiple snapshots created
|
|
||||||
if(theSettings->theMultipleSnapShotFlag)
|
|
||||||
{
|
|
||||||
// Determine if the file already exists, checking each successive filename
|
|
||||||
// until one doesn't exist
|
|
||||||
filename = path + ".png";
|
|
||||||
if(access(filename.c_str(), F_OK) == 0 )
|
|
||||||
{
|
|
||||||
ostringstream buf;
|
|
||||||
for(uInt32 i = 1; ;++i)
|
|
||||||
{
|
|
||||||
buf.str("");
|
|
||||||
buf << path << "_" << i << ".png";
|
|
||||||
if(access(buf.str().c_str(), F_OK) == -1 )
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
filename = buf.str();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
filename = path + ".png";
|
|
||||||
|
|
||||||
// Now save the snapshot file
|
|
||||||
theSnapshot->savePNG(filename, theConsole->mediaSource(), theSettings->theWindowSize);
|
|
||||||
|
|
||||||
if(access(filename.c_str(), F_OK) == 0)
|
|
||||||
{
|
|
||||||
message = "Snapshot saved";
|
|
||||||
theConsole->mediaSource().showMessage(message, 120);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
message = "Snapshot not saved";
|
|
||||||
theConsole->mediaSource().showMessage(message, 120);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
string message = "Snapshots unsupported";
|
|
||||||
theConsole->mediaSource().showMessage(message, 120);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Calculate the maximum window size that the current screen can hold
|
Calculate the maximum window size that the current screen can hold
|
||||||
|
@ -1261,11 +1159,6 @@ void cleanup()
|
||||||
if(theConsole)
|
if(theConsole)
|
||||||
delete theConsole;
|
delete theConsole;
|
||||||
|
|
||||||
#ifdef HAVE_PNG
|
|
||||||
if(theSnapshot)
|
|
||||||
delete theSnapshot;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if(theSound)
|
if(theSound)
|
||||||
{
|
{
|
||||||
theSound->closeDevice();
|
theSound->closeDevice();
|
||||||
|
@ -1333,21 +1226,6 @@ int main(int argc, char* argv[])
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_PNG
|
|
||||||
// Take care of the snapshot stuff.
|
|
||||||
theSnapshot = new Snapshot();
|
|
||||||
|
|
||||||
if(theSettings->theSnapShotDir == "")
|
|
||||||
theSnapShotDir = theFrontend->userHomeDir();
|
|
||||||
else
|
|
||||||
theSnapShotDir = theSettings->theSnapShotDir;
|
|
||||||
|
|
||||||
if(theSettings->theSnapShotName == "")
|
|
||||||
theSnapShotName = "romname";
|
|
||||||
else
|
|
||||||
theSnapShotName = theSettings->theSnapShotName;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Get a pointer to the file which contains the cartridge ROM
|
// Get a pointer to the file which contains the cartridge ROM
|
||||||
const char* file = argv[argc - 1];
|
const char* file = argv[argc - 1];
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue