mirror of https://github.com/stella-emu/stella.git
OpenGL mode is working again; snapshot and menuing support still MIA.
Rearranged some things from Settings to OSystem, since many things in the Settings class weren't actually related to settings at all. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@372 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
f3a31ca452
commit
aa8b0b9bdd
|
@ -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: FrameBufferGL.cxx,v 1.13 2005-02-21 02:23:48 stephena Exp $
|
// $Id: FrameBufferGL.cxx,v 1.14 2005-02-22 18:40:52 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
|
@ -22,14 +22,15 @@
|
||||||
|
|
||||||
#include "Console.hxx"
|
#include "Console.hxx"
|
||||||
#include "FrameBuffer.hxx"
|
#include "FrameBuffer.hxx"
|
||||||
#include "FrameBufferSDL.hxx"
|
|
||||||
#include "FrameBufferGL.hxx"
|
#include "FrameBufferGL.hxx"
|
||||||
#include "MediaSrc.hxx"
|
#include "MediaSrc.hxx"
|
||||||
#include "Settings.hxx"
|
#include "Settings.hxx"
|
||||||
|
#include "OSystem.hxx"
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
FrameBufferGL::FrameBufferGL()
|
FrameBufferGL::FrameBufferGL(OSystem* osystem)
|
||||||
: myTexture(0),
|
: FrameBuffer(osystem),
|
||||||
|
myTexture(0),
|
||||||
myScreenmode(0),
|
myScreenmode(0),
|
||||||
myScreenmodeCount(0),
|
myScreenmodeCount(0),
|
||||||
myFilterParam(GL_NEAREST),
|
myFilterParam(GL_NEAREST),
|
||||||
|
@ -50,42 +51,23 @@ FrameBufferGL::~FrameBufferGL()
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
bool FrameBufferGL::initSubsystem()
|
bool FrameBufferGL::initSubsystem()
|
||||||
{
|
{
|
||||||
// Get the desired width and height of the display
|
mySDLFlags |= SDL_OPENGL;
|
||||||
myWidth = myMediaSource->width() << 1;
|
|
||||||
myHeight = myMediaSource->height();
|
|
||||||
|
|
||||||
// Get the aspect ratio for the display
|
// Get the aspect ratio for the display
|
||||||
// Since the display is already doubled horizontally, we half the
|
// Since the display is already doubled horizontally, we half the
|
||||||
// ratio that is provided
|
// ratio that is provided
|
||||||
theAspectRatio = myConsole->settings().getFloat("gl_aspect") / 2;
|
theAspectRatio = myOSystem->settings().getFloat("gl_aspect") / 2;
|
||||||
if(theAspectRatio <= 0.0)
|
if(theAspectRatio <= 0.0)
|
||||||
theAspectRatio = 1.0;
|
theAspectRatio = 1.0;
|
||||||
|
|
||||||
// Now create the OpenGL SDL screen
|
|
||||||
Uint32 initflags = SDL_INIT_VIDEO | SDL_INIT_TIMER;
|
|
||||||
if(SDL_Init(initflags) < 0)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// Check which system we are running under
|
|
||||||
// Get the system-specific WM information
|
|
||||||
SDL_VERSION(&myWMInfo.version);
|
|
||||||
if(SDL_GetWMInfo(&myWMInfo) > 0)
|
|
||||||
myWMAvailable = true;
|
|
||||||
|
|
||||||
// Get the maximum size of a window for THIS screen
|
// Get the maximum size of a window for THIS screen
|
||||||
theMaxZoomLevel = maxWindowSizeForScreen();
|
theMaxZoomLevel = maxWindowSizeForScreen();
|
||||||
|
|
||||||
// Check to see if window size will fit in the screen
|
// Check to see if window size will fit in the screen
|
||||||
if((uInt32)myConsole->settings().getInt("zoom") > theMaxZoomLevel)
|
if((uInt32)myOSystem->settings().getInt("zoom") > theMaxZoomLevel)
|
||||||
theZoomLevel = theMaxZoomLevel;
|
theZoomLevel = theMaxZoomLevel;
|
||||||
else
|
else
|
||||||
theZoomLevel = myConsole->settings().getInt("zoom");
|
theZoomLevel = myOSystem->settings().getInt("zoom");
|
||||||
|
|
||||||
mySDLFlags = SDL_OPENGL;
|
|
||||||
mySDLFlags |= myConsole->settings().getBool("fullscreen") ? SDL_FULLSCREEN : 0;
|
|
||||||
|
|
||||||
// Set the window title and icon
|
|
||||||
setWindowAttributes();
|
|
||||||
|
|
||||||
// Set up the OpenGL attributes
|
// Set up the OpenGL attributes
|
||||||
myDepth = SDL_GetVideoInfo()->vfmt->BitsPerPixel;
|
myDepth = SDL_GetVideoInfo()->vfmt->BitsPerPixel;
|
||||||
|
@ -156,23 +138,8 @@ bool FrameBufferGL::initSubsystem()
|
||||||
// and the textures
|
// and the textures
|
||||||
setupPalette();
|
setupPalette();
|
||||||
|
|
||||||
// Make sure that theUseFullScreenFlag sets up fullscreen mode correctly
|
|
||||||
if(myConsole->settings().getBool("fullscreen"))
|
|
||||||
{
|
|
||||||
grabMouse(true);
|
|
||||||
showCursor(false);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Keep mouse in game window if grabmouse is selected
|
|
||||||
grabMouse(myConsole->settings().getBool("grabmouse"));
|
|
||||||
|
|
||||||
// Show or hide the cursor depending on the 'hidecursor' argument
|
|
||||||
showCursor(!myConsole->settings().getBool("hidecursor"));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Show some OpenGL info
|
// Show some OpenGL info
|
||||||
if(myConsole->settings().getBool("showinfo"))
|
if(myOSystem->settings().getBool("showinfo"))
|
||||||
{
|
{
|
||||||
cout << "Video rendering: OpenGL mode" << endl;
|
cout << "Video rendering: OpenGL mode" << endl;
|
||||||
|
|
||||||
|
@ -247,11 +214,13 @@ bool FrameBufferGL::createScreen()
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void FrameBufferGL::drawMediaSource()
|
void FrameBufferGL::drawMediaSource()
|
||||||
{
|
{
|
||||||
|
MediaSource& mediasrc = myOSystem->console().mediaSource();
|
||||||
|
|
||||||
// Copy the mediasource framebuffer to the RGB texture
|
// Copy the mediasource framebuffer to the RGB texture
|
||||||
uInt8* currentFrame = myMediaSource->currentFrameBuffer();
|
uInt8* currentFrame = mediasrc.currentFrameBuffer();
|
||||||
uInt8* previousFrame = myMediaSource->previousFrameBuffer();
|
uInt8* previousFrame = mediasrc.previousFrameBuffer();
|
||||||
uInt32 width = myMediaSource->width();
|
uInt32 width = mediasrc.width();
|
||||||
uInt32 height = myMediaSource->height();
|
uInt32 height = mediasrc.height();
|
||||||
uInt16* buffer = (uInt16*) myTexture->pixels;
|
uInt16* buffer = (uInt16*) myTexture->pixels;
|
||||||
|
|
||||||
register uInt32 y;
|
register uInt32 y;
|
||||||
|
@ -384,7 +353,7 @@ bool FrameBufferGL::createTextures()
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Create an OpenGL texture from the SDL texture
|
// Create an OpenGL texture from the SDL texture
|
||||||
string filter = myConsole->settings().getString("gl_filter");
|
string filter = myOSystem->settings().getString("gl_filter");
|
||||||
if(filter == "linear")
|
if(filter == "linear")
|
||||||
{
|
{
|
||||||
myFilterParam = GL_LINEAR;
|
myFilterParam = GL_LINEAR;
|
||||||
|
@ -471,13 +440,13 @@ void FrameBufferGL::toggleFilter()
|
||||||
if(myFilterParam == GL_NEAREST)
|
if(myFilterParam == GL_NEAREST)
|
||||||
{
|
{
|
||||||
myFilterParam = GL_LINEAR;
|
myFilterParam = GL_LINEAR;
|
||||||
myConsole->settings().setString("gl_filter", "linear");
|
myOSystem->settings().setString("gl_filter", "linear");
|
||||||
showMessage("Filtering: GL_LINEAR");
|
showMessage("Filtering: GL_LINEAR");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
myFilterParam = GL_NEAREST;
|
myFilterParam = GL_NEAREST;
|
||||||
myConsole->settings().setString("gl_filter", "nearest");
|
myOSystem->settings().setString("gl_filter", "nearest");
|
||||||
showMessage("Filtering: GL_NEAREST");
|
showMessage("Filtering: GL_NEAREST");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -523,7 +492,7 @@ void FrameBufferGL::viewport(uInt32* screenWidth, uInt32* screenHeight,
|
||||||
uInt32 desktopWidth = this->screenWidth();
|
uInt32 desktopWidth = this->screenWidth();
|
||||||
uInt32 desktopHeight = this->screenHeight();
|
uInt32 desktopHeight = this->screenHeight();
|
||||||
|
|
||||||
if(myConsole->settings().getBool("gl_fsmax") &&
|
if(myOSystem->settings().getBool("gl_fsmax") &&
|
||||||
desktopWidth != 0 && desktopHeight != 0)
|
desktopWidth != 0 && desktopHeight != 0)
|
||||||
{
|
{
|
||||||
// Use the largest available screen size
|
// Use the largest available screen size
|
||||||
|
@ -543,7 +512,7 @@ void FrameBufferGL::viewport(uInt32* screenWidth, uInt32* screenHeight,
|
||||||
iwidth = (Uint16) (scale * iwidth);
|
iwidth = (Uint16) (scale * iwidth);
|
||||||
iheight = (Uint16) (scale * iheight);
|
iheight = (Uint16) (scale * iheight);
|
||||||
}
|
}
|
||||||
else if(myConsole->settings().getBool("gl_fsmax") &&
|
else if(myOSystem->settings().getBool("gl_fsmax") &&
|
||||||
myScreenmode != (SDL_Rect**) -1)
|
myScreenmode != (SDL_Rect**) -1)
|
||||||
{
|
{
|
||||||
// Use the largest available screen size
|
// Use the largest available screen 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: FrameBufferGL.hxx,v 1.7 2005-02-21 02:23:48 stephena Exp $
|
// $Id: FrameBufferGL.hxx,v 1.8 2005-02-22 18:40:53 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#ifndef FRAMEBUFFER_GL_HXX
|
#ifndef FRAMEBUFFER_GL_HXX
|
||||||
|
@ -23,6 +23,8 @@
|
||||||
#include <SDL_opengl.h>
|
#include <SDL_opengl.h>
|
||||||
#include <SDL_syswm.h>
|
#include <SDL_syswm.h>
|
||||||
|
|
||||||
|
class OSystem;
|
||||||
|
|
||||||
#include "bspf.hxx"
|
#include "bspf.hxx"
|
||||||
#include "FrameBuffer.hxx"
|
#include "FrameBuffer.hxx"
|
||||||
|
|
||||||
|
@ -31,7 +33,7 @@
|
||||||
This class implements an SDL OpenGL framebuffer.
|
This class implements an SDL OpenGL framebuffer.
|
||||||
|
|
||||||
@author Stephen Anthony
|
@author Stephen Anthony
|
||||||
@version $Id: FrameBufferGL.hxx,v 1.7 2005-02-21 02:23:48 stephena Exp $
|
@version $Id: FrameBufferGL.hxx,v 1.8 2005-02-22 18:40:53 stephena Exp $
|
||||||
*/
|
*/
|
||||||
class FrameBufferGL : public FrameBuffer
|
class FrameBufferGL : public FrameBuffer
|
||||||
{
|
{
|
||||||
|
@ -39,22 +41,22 @@ class FrameBufferGL : public FrameBuffer
|
||||||
/**
|
/**
|
||||||
Creates a new OpenGL framebuffer
|
Creates a new OpenGL framebuffer
|
||||||
*/
|
*/
|
||||||
FrameBufferGL();
|
FrameBufferGL(OSystem* osystem);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Destructor
|
Destructor
|
||||||
*/
|
*/
|
||||||
virtual ~FrameBufferGL();
|
virtual ~FrameBufferGL();
|
||||||
|
|
||||||
/**
|
|
||||||
Switches between the two filtering options in OpenGL.
|
|
||||||
Currently, these are GL_NEAREST and GL_LINEAR.
|
|
||||||
*/
|
|
||||||
void toggleFilter();
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// The following methods are derived from FrameBuffer.hxx
|
// The following methods are derived from FrameBuffer.hxx
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
/**
|
||||||
|
This routine is called to initialize OpenGL video mode.
|
||||||
|
Return false if any operation fails, otherwise return true.
|
||||||
|
*/
|
||||||
|
virtual bool initSubsystem();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This routine is called whenever the screen needs to be recreated.
|
This routine is called whenever the screen needs to be recreated.
|
||||||
It updates the global screen variable.
|
It updates the global screen variable.
|
||||||
|
@ -69,21 +71,13 @@ class FrameBufferGL : public FrameBuffer
|
||||||
@param b The blue component of the color.
|
@param b The blue component of the color.
|
||||||
*/
|
*/
|
||||||
virtual Uint32 mapRGB(Uint8 r, Uint8 g, Uint8 b)
|
virtual Uint32 mapRGB(Uint8 r, Uint8 g, Uint8 b)
|
||||||
{ return SDL_MapRGB(myTexture->format, r, g, b); }
|
{ return SDL_MapRGB(myScreen->format, r, g, b); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This routine is called to get the specified scanline data.
|
Switches between the two filtering options in OpenGL.
|
||||||
|
Currently, these are GL_NEAREST and GL_LINEAR.
|
||||||
@param row The row we are looking for
|
|
||||||
@param data The actual pixel data (in bytes)
|
|
||||||
*/
|
*/
|
||||||
virtual void scanline(uInt32 row, uInt8* data);
|
virtual void toggleFilter();
|
||||||
|
|
||||||
/**
|
|
||||||
This routine should be called to setup the video system for us to use.
|
|
||||||
Return false if any operation fails, otherwise return true.
|
|
||||||
*/
|
|
||||||
virtual bool initSubsystem();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This routine should be called anytime the MediaSource needs to be redrawn
|
This routine should be called anytime the MediaSource needs to be redrawn
|
||||||
|
@ -130,8 +124,15 @@ class FrameBufferGL : public FrameBuffer
|
||||||
*/
|
*/
|
||||||
virtual void postFrameUpdate();
|
virtual void postFrameUpdate();
|
||||||
|
|
||||||
private:
|
/**
|
||||||
|
This routine is called to get the specified scanline data.
|
||||||
|
|
||||||
|
@param row The row we are looking for
|
||||||
|
@param data The actual pixel data (in bytes)
|
||||||
|
*/
|
||||||
|
virtual void scanline(uInt32 row, uInt8* data);
|
||||||
|
|
||||||
|
private:
|
||||||
bool createTextures();
|
bool createTextures();
|
||||||
|
|
||||||
void viewport(uInt32* screenWidth, uInt32* screenHeight,
|
void viewport(uInt32* screenWidth, uInt32* screenHeight,
|
||||||
|
|
|
@ -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: FrameBufferSoft.cxx,v 1.8 2005-02-21 20:41:18 stephena Exp $
|
// $Id: FrameBufferSoft.cxx,v 1.9 2005-02-22 18:40:55 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
|
@ -62,9 +62,6 @@ bool FrameBufferSoft::initSubsystem()
|
||||||
else
|
else
|
||||||
theZoomLevel = myOSystem->settings().getInt("zoom");
|
theZoomLevel = myOSystem->settings().getInt("zoom");
|
||||||
|
|
||||||
// Set the window title and icon
|
|
||||||
setWindowAttributes();
|
|
||||||
|
|
||||||
// Create the screen
|
// Create the screen
|
||||||
if(!createScreen())
|
if(!createScreen())
|
||||||
return false;
|
return false;
|
||||||
|
@ -95,6 +92,12 @@ bool FrameBufferSoft::createScreen()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
void FrameBufferSoft::toggleFilter()
|
||||||
|
{
|
||||||
|
// No filter added yet ...
|
||||||
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void FrameBufferSoft::drawMediaSource()
|
void FrameBufferSoft::drawMediaSource()
|
||||||
{
|
{
|
||||||
|
|
|
@ -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: FrameBufferSoft.hxx,v 1.6 2005-02-21 20:41:19 stephena Exp $
|
// $Id: FrameBufferSoft.hxx,v 1.7 2005-02-22 18:40:55 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#ifndef FRAMEBUFFER_SOFT_HXX
|
#ifndef FRAMEBUFFER_SOFT_HXX
|
||||||
|
@ -34,7 +34,7 @@ class RectList;
|
||||||
This class implements an SDL software framebuffer.
|
This class implements an SDL software framebuffer.
|
||||||
|
|
||||||
@author Stephen Anthony
|
@author Stephen Anthony
|
||||||
@version $Id: FrameBufferSoft.hxx,v 1.6 2005-02-21 20:41:19 stephena Exp $
|
@version $Id: FrameBufferSoft.hxx,v 1.7 2005-02-22 18:40:55 stephena Exp $
|
||||||
*/
|
*/
|
||||||
class FrameBufferSoft : public FrameBuffer
|
class FrameBufferSoft : public FrameBuffer
|
||||||
{
|
{
|
||||||
|
@ -74,6 +74,12 @@ class FrameBufferSoft : public FrameBuffer
|
||||||
virtual Uint32 mapRGB(Uint8 r, Uint8 g, Uint8 b)
|
virtual Uint32 mapRGB(Uint8 r, Uint8 g, Uint8 b)
|
||||||
{ return SDL_MapRGB(myScreen->format, r, g, b); }
|
{ return SDL_MapRGB(myScreen->format, r, g, b); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
Switches between the filtering options in software mode.
|
||||||
|
Currently, none exist.
|
||||||
|
*/
|
||||||
|
virtual void toggleFilter();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This routine should be called anytime the MediaSource needs to be redrawn
|
This routine should be called anytime the MediaSource needs to be redrawn
|
||||||
to the screen.
|
to the screen.
|
||||||
|
|
|
@ -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: SoundSDL.cxx,v 1.10 2005-02-22 02:59:53 stephena Exp $
|
// $Id: SoundSDL.cxx,v 1.11 2005-02-22 18:40:55 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
@ -37,9 +37,6 @@ SoundSDL::SoundSDL(OSystem* osystem)
|
||||||
myFragmentSizeLogBase2(0),
|
myFragmentSizeLogBase2(0),
|
||||||
myIsMuted(false)
|
myIsMuted(false)
|
||||||
{
|
{
|
||||||
uInt32 fragsize = myOSystem->settings().getInt("fragsize");
|
|
||||||
myVolume = myOSystem->settings().getInt("volume");
|
|
||||||
|
|
||||||
if(SDL_InitSubSystem(SDL_INIT_AUDIO) < 0)
|
if(SDL_InitSubSystem(SDL_INIT_AUDIO) < 0)
|
||||||
{
|
{
|
||||||
cerr << "WARNING: Couldn't initialize SDL audio system! " << endl;
|
cerr << "WARNING: Couldn't initialize SDL audio system! " << endl;
|
||||||
|
@ -48,6 +45,8 @@ SoundSDL::SoundSDL(OSystem* osystem)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
uInt32 fragsize = myOSystem->settings().getInt("fragsize");
|
||||||
|
|
||||||
SDL_AudioSpec desired;
|
SDL_AudioSpec desired;
|
||||||
desired.freq = 31400;
|
desired.freq = 31400;
|
||||||
desired.format = AUDIO_U8;
|
desired.format = AUDIO_U8;
|
||||||
|
@ -93,6 +92,16 @@ SoundSDL::SoundSDL(OSystem* osystem)
|
||||||
|
|
||||||
// And start the SDL sound subsystem ...
|
// And start the SDL sound subsystem ...
|
||||||
SDL_PauseAudio(0);
|
SDL_PauseAudio(0);
|
||||||
|
|
||||||
|
// Adjust volume to that defined in settings
|
||||||
|
myVolume = myOSystem->settings().getInt("volume");
|
||||||
|
setVolume(myVolume);
|
||||||
|
|
||||||
|
// Show some info
|
||||||
|
if(myOSystem->settings().getBool("showinfo"))
|
||||||
|
cout << "Sound enabled:" << endl
|
||||||
|
<< " Volume : " << myVolume << endl
|
||||||
|
<< " Frag size: " << fragsize << endl << 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: mainSDL.cxx,v 1.23 2005-02-22 02:59:53 stephena Exp $
|
// $Id: mainSDL.cxx,v 1.24 2005-02-22 18:40:56 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
@ -45,9 +45,6 @@
|
||||||
|
|
||||||
#ifdef DISPLAY_OPENGL
|
#ifdef DISPLAY_OPENGL
|
||||||
#include "FrameBufferGL.hxx"
|
#include "FrameBufferGL.hxx"
|
||||||
|
|
||||||
// Indicates whether to use OpenGL mode
|
|
||||||
static bool theUseOpenGLFlag;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(UNIX)
|
#if defined(UNIX)
|
||||||
|
@ -442,12 +439,10 @@ void HandleEvents()
|
||||||
theSound->adjustVolume(1);
|
theSound->adjustVolume(1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#ifdef DISPLAY_OPENGL
|
|
||||||
case SDLK_f:
|
case SDLK_f:
|
||||||
if(theUseOpenGLFlag)
|
theDisplay->toggleFilter();
|
||||||
((FrameBufferGL*)theDisplay)->toggleFilter();
|
|
||||||
break;
|
break;
|
||||||
#endif
|
|
||||||
#ifdef DEVELOPER_SUPPORT
|
#ifdef DEVELOPER_SUPPORT
|
||||||
case SDLK_END: // Alt-End increases XStart
|
case SDLK_END: // Alt-End increases XStart
|
||||||
theOSystem->console().changeXStart(1);
|
theOSystem->console().changeXStart(1);
|
||||||
|
@ -545,10 +540,10 @@ void HandleEvents()
|
||||||
case SDLK_s: // Ctrl-s saves properties to a file
|
case SDLK_s: // Ctrl-s saves properties to a file
|
||||||
// Attempt to merge with propertiesSet
|
// Attempt to merge with propertiesSet
|
||||||
if(theSettings->getBool("mergeprops"))
|
if(theSettings->getBool("mergeprops"))
|
||||||
theOSystem->console().saveProperties(theSettings->propertiesOutputFilename(), true);
|
theOSystem->console().saveProperties(theOSystem->propertiesOutputFilename(), true);
|
||||||
else // Save to file in home directory
|
else // Save to file in home directory
|
||||||
{
|
{
|
||||||
string newPropertiesFile = theSettings->baseDir() + "/" + \
|
string newPropertiesFile = theOSystem->baseDir() + "/" + \
|
||||||
theOSystem->console().properties().get("Cartridge.Name") + ".pro";
|
theOSystem->console().properties().get("Cartridge.Name") + ".pro";
|
||||||
theOSystem->console().saveProperties(newPropertiesFile);
|
theOSystem->console().saveProperties(newPropertiesFile);
|
||||||
}
|
}
|
||||||
|
@ -766,7 +761,7 @@ void SetupProperties(PropertiesSet& set)
|
||||||
{
|
{
|
||||||
bool useMemList = false;
|
bool useMemList = false;
|
||||||
string theAltPropertiesFile = theSettings->getString("altpro");
|
string theAltPropertiesFile = theSettings->getString("altpro");
|
||||||
string thePropertiesFile = theSettings->propertiesInputFilename();
|
string thePropertiesFile = theOSystem->propertiesInputFilename();
|
||||||
|
|
||||||
// When 'listrominfo' or 'mergeprops' is specified, we need to have the
|
// When 'listrominfo' or 'mergeprops' is specified, we need to have the
|
||||||
// full list in memory
|
// full list in memory
|
||||||
|
@ -897,20 +892,13 @@ int main(int argc, char* argv[])
|
||||||
// Create an SDL window
|
// Create an SDL window
|
||||||
string videodriver = theSettings->getString("video");
|
string videodriver = theSettings->getString("video");
|
||||||
if(videodriver == "soft")
|
if(videodriver == "soft")
|
||||||
{
|
|
||||||
theDisplay = new FrameBufferSoft(theOSystem);
|
theDisplay = new FrameBufferSoft(theOSystem);
|
||||||
}
|
|
||||||
#ifdef DISPLAY_OPENGL
|
#ifdef DISPLAY_OPENGL
|
||||||
else if(videodriver == "gl")
|
else if(videodriver == "gl")
|
||||||
{
|
theDisplay = new FrameBufferGL(theOSystem);
|
||||||
theDisplay = new FrameBufferGL();
|
|
||||||
theUseOpenGLFlag = true;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
else // a driver that doesn't exist was requested, so use software mode
|
else // a driver that doesn't exist was requested, so use software mode
|
||||||
{
|
|
||||||
theDisplay = new FrameBufferSoft(theOSystem);
|
theDisplay = new FrameBufferSoft(theOSystem);
|
||||||
}
|
|
||||||
|
|
||||||
if(!theDisplay)
|
if(!theDisplay)
|
||||||
{
|
{
|
||||||
|
@ -920,22 +908,11 @@ int main(int argc, char* argv[])
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a sound object for playing audio
|
// Create a sound object for playing audio, even if sound has been disabled
|
||||||
if(theSettings->getBool("sound"))
|
if(theSettings->getBool("sound"))
|
||||||
{
|
|
||||||
theSound = new SoundSDL(theOSystem);
|
theSound = new SoundSDL(theOSystem);
|
||||||
|
else
|
||||||
ostringstream message;
|
|
||||||
message << "Sound enabled:" << endl;
|
|
||||||
//FIXME << " Volume : " << volume << endl
|
|
||||||
// << " Frag size: " << fragsize << endl;
|
|
||||||
ShowInfo(message.str());
|
|
||||||
}
|
|
||||||
else // even if sound has been disabled, we still need a sound object
|
|
||||||
{
|
|
||||||
theSound = new Sound(theOSystem);
|
theSound = new Sound(theOSystem);
|
||||||
ShowInfo("Sound disabled");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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];
|
||||||
|
@ -954,7 +931,7 @@ int main(int argc, char* argv[])
|
||||||
uInt32 size = in.gcount();
|
uInt32 size = in.gcount();
|
||||||
in.close();
|
in.close();
|
||||||
|
|
||||||
// Create the 2600 game console
|
// Create an instance of the 2600 game console
|
||||||
Console* theConsole = (Console*) NULL;
|
Console* theConsole = (Console*) NULL;
|
||||||
theConsole = new Console(image, size, theOSystem);
|
theConsole = new Console(image, size, theOSystem);
|
||||||
|
|
||||||
|
|
|
@ -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: FrameBuffer.cxx,v 1.15 2005-02-22 02:59:54 stephena Exp $
|
// $Id: FrameBuffer.cxx,v 1.16 2005-02-22 18:40:59 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
@ -93,23 +93,33 @@ FrameBuffer::~FrameBuffer(void)
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void FrameBuffer::initialize(const string title, uInt32 width, uInt32 height)
|
void FrameBuffer::initialize(const string title, uInt32 width, uInt32 height)
|
||||||
{
|
{
|
||||||
myWidth = width;
|
bool isAlreadyInitialized = (SDL_WasInit(SDL_INIT_VIDEO) & SDL_INIT_VIDEO) > 0;
|
||||||
myHeight = height;
|
|
||||||
|
|
||||||
|
myWidth = width;
|
||||||
|
myHeight = height;
|
||||||
myFrameRate = myOSystem->settings().getInt("framerate");
|
myFrameRate = myOSystem->settings().getInt("framerate");
|
||||||
|
|
||||||
// Now initialize the SDL screen
|
// Now (re)initialize the SDL video system
|
||||||
Uint32 initflags = SDL_INIT_VIDEO | SDL_INIT_TIMER;
|
if(!isAlreadyInitialized)
|
||||||
if(SDL_Init(initflags) < 0)
|
{
|
||||||
return;
|
Uint32 initflags = SDL_INIT_VIDEO | SDL_INIT_TIMER;
|
||||||
|
|
||||||
// Get the system-specific WM information
|
if(SDL_Init(initflags) < 0)
|
||||||
SDL_VERSION(&myWMInfo.version);
|
return;
|
||||||
if(SDL_GetWMInfo(&myWMInfo) > 0)
|
|
||||||
myWMAvailable = true;
|
// Get the system-specific WM information
|
||||||
|
SDL_VERSION(&myWMInfo.version);
|
||||||
|
if(SDL_GetWMInfo(&myWMInfo) > 0)
|
||||||
|
myWMAvailable = true;
|
||||||
|
|
||||||
|
setWindowIcon();
|
||||||
|
}
|
||||||
|
|
||||||
mySDLFlags = myOSystem->settings().getBool("fullscreen") ? SDL_FULLSCREEN : 0;
|
mySDLFlags = myOSystem->settings().getBool("fullscreen") ? SDL_FULLSCREEN : 0;
|
||||||
|
|
||||||
|
// Set window title
|
||||||
|
setWindowTitle(title);
|
||||||
|
|
||||||
// Initialize video subsystem
|
// Initialize video subsystem
|
||||||
initSubsystem();
|
initSubsystem();
|
||||||
|
|
||||||
|
@ -1029,13 +1039,14 @@ uInt32 FrameBuffer::screenHeight()
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void FrameBuffer::setWindowAttributes()
|
void FrameBuffer::setWindowTitle(const string title)
|
||||||
{
|
{
|
||||||
// Set the window title
|
SDL_WM_SetCaption(title.c_str(), "stella");
|
||||||
ostringstream name;
|
}
|
||||||
name << "Stella: \"" << myOSystem->console().properties().get("Cartridge.Name") << "\"";
|
|
||||||
SDL_WM_SetCaption(name.str().c_str(), "stella");
|
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
void FrameBuffer::setWindowIcon()
|
||||||
|
{
|
||||||
#ifndef MAC_OSX
|
#ifndef MAC_OSX
|
||||||
// Set the window icon
|
// Set the window icon
|
||||||
uInt32 w, h, ncols, nbytes;
|
uInt32 w, h, ncols, nbytes;
|
||||||
|
@ -1052,7 +1063,7 @@ void FrameBuffer::setWindowAttributes()
|
||||||
for(uInt32 i = 0; i < ncols; i++)
|
for(uInt32 i = 0; i < ncols; i++)
|
||||||
{
|
{
|
||||||
unsigned char code;
|
unsigned char code;
|
||||||
char color[32];
|
char color[32];
|
||||||
uInt32 col;
|
uInt32 col;
|
||||||
|
|
||||||
sscanf(stella_icon[1 + i], "%c c %s", &code, color);
|
sscanf(stella_icon[1 + i], "%c c %s", &code, color);
|
||||||
|
|
|
@ -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: FrameBuffer.hxx,v 1.15 2005-02-21 20:43:10 stephena Exp $
|
// $Id: FrameBuffer.hxx,v 1.16 2005-02-22 18:41:11 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#ifndef FRAMEBUFFER_HXX
|
#ifndef FRAMEBUFFER_HXX
|
||||||
|
@ -39,7 +39,7 @@ FIXME This class also implements a MAME-like user interface where Stella settin
|
||||||
can be changed.
|
can be changed.
|
||||||
|
|
||||||
@author Stephen Anthony
|
@author Stephen Anthony
|
||||||
@version $Id: FrameBuffer.hxx,v 1.15 2005-02-21 20:43:10 stephena Exp $
|
@version $Id: FrameBuffer.hxx,v 1.16 2005-02-22 18:41:11 stephena Exp $
|
||||||
*/
|
*/
|
||||||
class FrameBuffer
|
class FrameBuffer
|
||||||
{
|
{
|
||||||
|
@ -55,7 +55,7 @@ class FrameBuffer
|
||||||
virtual ~FrameBuffer();
|
virtual ~FrameBuffer();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Initializes the framebuffer display. This must be called before any
|
(Re)initializes the framebuffer display. This must be called before any
|
||||||
calls are made to derived methods.
|
calls are made to derived methods.
|
||||||
|
|
||||||
@param title The title of the window
|
@param title The title of the window
|
||||||
|
@ -207,9 +207,9 @@ FIXME
|
||||||
uInt32 maxWindowSizeForScreen();
|
uInt32 maxWindowSizeForScreen();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Set the title and icon for the main SDL window.
|
Set the title for the main SDL window.
|
||||||
*/
|
*/
|
||||||
void setWindowAttributes();
|
void setWindowTitle(const string title);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Set up the palette for a screen of any depth > 8.
|
Set up the palette for a screen of any depth > 8.
|
||||||
|
@ -241,6 +241,11 @@ FIXME
|
||||||
*/
|
*/
|
||||||
virtual Uint32 mapRGB(Uint8 r, Uint8 g, Uint8 b) = 0;
|
virtual Uint32 mapRGB(Uint8 r, Uint8 g, Uint8 b) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Switches between the filtering options in the video subsystem.
|
||||||
|
*/
|
||||||
|
virtual void toggleFilter() = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This routine should be called anytime the MediaSource needs to be redrawn
|
This routine should be called anytime the MediaSource needs to be redrawn
|
||||||
to the screen.
|
to the screen.
|
||||||
|
@ -351,6 +356,11 @@ FIXME
|
||||||
float theAspectRatio;
|
float theAspectRatio;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
/**
|
||||||
|
Set the icon for the main SDL window.
|
||||||
|
*/
|
||||||
|
void setWindowIcon();
|
||||||
|
|
||||||
// Enumeration representing the different types of user interface widgets
|
// Enumeration representing the different types of user interface widgets
|
||||||
enum Widget { W_NONE, MAIN_MENU, REMAP_MENU, INFO_MENU };
|
enum Widget { W_NONE, MAIN_MENU, REMAP_MENU, INFO_MENU };
|
||||||
|
|
||||||
|
|
|
@ -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: OSystem.cxx,v 1.2 2005-02-21 20:43:20 stephena Exp $
|
// $Id: OSystem.cxx,v 1.3 2005-02-22 18:41:12 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
@ -39,9 +39,33 @@ OSystem::~OSystem()
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void OSystem::update()
|
void OSystem::setPropertiesFiles(const string& userprops,
|
||||||
|
const string& systemprops)
|
||||||
{
|
{
|
||||||
// myFrameBuffer.update();
|
// Set up the input and output properties files
|
||||||
|
myPropertiesOutputFile = userprops;
|
||||||
|
|
||||||
|
if(fileExists(userprops))
|
||||||
|
myPropertiesInputFile = userprops;
|
||||||
|
else if(fileExists(systemprops))
|
||||||
|
myPropertiesInputFile = systemprops;
|
||||||
|
else
|
||||||
|
myPropertiesInputFile = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
void OSystem::setConfigFiles(const string& userconfig,
|
||||||
|
const string& systemconfig)
|
||||||
|
{
|
||||||
|
// Set up the names of the input and output config files
|
||||||
|
myConfigOutputFile = userconfig;
|
||||||
|
|
||||||
|
if(fileExists(userconfig))
|
||||||
|
myConfigInputFile = userconfig;
|
||||||
|
else if(fileExists(systemconfig))
|
||||||
|
myConfigInputFile = systemconfig;
|
||||||
|
else
|
||||||
|
myConfigInputFile = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
|
@ -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: OSystem.hxx,v 1.2 2005-02-21 20:43:20 stephena Exp $
|
// $Id: OSystem.hxx,v 1.3 2005-02-22 18:41:12 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#ifndef OSYSTEM_HXX
|
#ifndef OSYSTEM_HXX
|
||||||
|
@ -35,7 +35,7 @@ class PropertiesSet;
|
||||||
other objects belong.
|
other objects belong.
|
||||||
|
|
||||||
@author Stephen Anthony
|
@author Stephen Anthony
|
||||||
@version $Id: OSystem.hxx,v 1.2 2005-02-21 20:43:20 stephena Exp $
|
@version $Id: OSystem.hxx,v 1.3 2005-02-22 18:41:12 stephena Exp $
|
||||||
*/
|
*/
|
||||||
class OSystem
|
class OSystem
|
||||||
{
|
{
|
||||||
|
@ -51,12 +51,6 @@ class OSystem
|
||||||
virtual ~OSystem();
|
virtual ~OSystem();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
|
||||||
Updates the osystem by one frame. Determines which subsystem should
|
|
||||||
be updated. Generally will be called 'framerate' times per second.
|
|
||||||
*/
|
|
||||||
void update();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Adds the specified eventhandler to the system.
|
Adds the specified eventhandler to the system.
|
||||||
|
|
||||||
|
@ -146,6 +140,68 @@ class OSystem
|
||||||
*/
|
*/
|
||||||
Console& console(void) const { return *myConsole; }
|
Console& console(void) const { return *myConsole; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
Set the base directory for all configuration files
|
||||||
|
*/
|
||||||
|
void setBaseDir(const string& basedir) { myBaseDir = basedir; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
Set the directory where state files are stored
|
||||||
|
*/
|
||||||
|
void setStateDir(const string& statedir) { myStateDir = statedir; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
Set the locations of game properties files
|
||||||
|
*/
|
||||||
|
void setPropertiesFiles(const string& userprops, const string& systemprops);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Set the locations of config files
|
||||||
|
*/
|
||||||
|
void setConfigFiles(const string& userconfig, const string& systemconfig);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Return the default directory for storing data.
|
||||||
|
*/
|
||||||
|
string baseDir() { return myBaseDir; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
Return the directory for storing state files.
|
||||||
|
*/
|
||||||
|
string stateDir() { return myStateDir; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
This method should be called to get the filename of the
|
||||||
|
properties (stella.pro) file for the purpose of loading.
|
||||||
|
|
||||||
|
@return String representing the full path of the properties filename.
|
||||||
|
*/
|
||||||
|
string propertiesInputFilename() { return myPropertiesInputFile; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
This method should be called to get the filename of the
|
||||||
|
properties (stella.pro) file for the purpose of saving.
|
||||||
|
|
||||||
|
@return String representing the full path of the properties filename.
|
||||||
|
*/
|
||||||
|
string propertiesOutputFilename() { return myPropertiesOutputFile; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
This method should be called to get the filename of the config file
|
||||||
|
for the purpose of loading.
|
||||||
|
|
||||||
|
@return String representing the full path of the config filename.
|
||||||
|
*/
|
||||||
|
string configInputFilename() { return myConfigInputFile; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
This method should be called to get the filename of the config file
|
||||||
|
for the purpose of saving.
|
||||||
|
|
||||||
|
@return String representing the full path of the config filename.
|
||||||
|
*/
|
||||||
|
string configOutputFilename() { return myConfigOutputFile; }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// The following methods are system-specific and must be implemented
|
// The following methods are system-specific and must be implemented
|
||||||
|
@ -171,6 +227,15 @@ class OSystem
|
||||||
*/
|
*/
|
||||||
virtual bool fileExists(const string& filename) = 0;
|
virtual bool fileExists(const string& filename) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
This method should be called to create the specified directory.
|
||||||
|
|
||||||
|
@param path The directory to create
|
||||||
|
|
||||||
|
@return boolean representing whether or not the directory was created
|
||||||
|
*/
|
||||||
|
virtual bool makeDir(const string& path) = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Pointer to the EventHandler object
|
// Pointer to the EventHandler object
|
||||||
EventHandler* myEventHandler;
|
EventHandler* myEventHandler;
|
||||||
|
@ -190,6 +255,15 @@ class OSystem
|
||||||
// Pointer to the (currently defined) Console object
|
// Pointer to the (currently defined) Console object
|
||||||
Console* myConsole;
|
Console* myConsole;
|
||||||
|
|
||||||
|
private:
|
||||||
|
string myBaseDir;
|
||||||
|
string myStateDir;
|
||||||
|
|
||||||
|
string myPropertiesInputFile;
|
||||||
|
string myPropertiesOutputFile;
|
||||||
|
string myConfigInputFile;
|
||||||
|
string myConfigOutputFile;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Copy constructor isn't supported by this class so make it private
|
// Copy constructor isn't supported by this class so make it private
|
||||||
OSystem(const OSystem&);
|
OSystem(const OSystem&);
|
||||||
|
|
|
@ -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.32 2005-02-21 20:43:20 stephena Exp $
|
// $Id: Settings.cxx,v 1.33 2005-02-22 18:41:12 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
@ -80,7 +80,7 @@ void Settings::loadConfig()
|
||||||
string line, key, value;
|
string line, key, value;
|
||||||
uInt32 equalPos;
|
uInt32 equalPos;
|
||||||
|
|
||||||
ifstream in(myConfigInputFile.c_str());
|
ifstream in(myOSystem->configInputFilename().c_str());
|
||||||
if(!in || !in.is_open())
|
if(!in || !in.is_open())
|
||||||
{
|
{
|
||||||
cout << "Error: Couldn't load settings file\n";
|
cout << "Error: Couldn't load settings file\n";
|
||||||
|
@ -217,7 +217,7 @@ void Settings::usage()
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void Settings::saveConfig()
|
void Settings::saveConfig()
|
||||||
{
|
{
|
||||||
ofstream out(myConfigOutputFile.c_str());
|
ofstream out(myOSystem->configOutputFilename().c_str());
|
||||||
if(!out || !out.is_open())
|
if(!out || !out.is_open())
|
||||||
{
|
{
|
||||||
cout << "Error: Couldn't save settings file\n";
|
cout << "Error: Couldn't save settings file\n";
|
||||||
|
|
|
@ -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.20 2005-02-21 20:43:21 stephena Exp $
|
// $Id: Settings.hxx,v 1.21 2005-02-22 18:41:14 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#ifndef SETTINGS_HXX
|
#ifndef SETTINGS_HXX
|
||||||
|
@ -28,7 +28,7 @@ class OSystem;
|
||||||
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.20 2005-02-21 20:43:21 stephena Exp $
|
@version $Id: Settings.hxx,v 1.21 2005-02-22 18:41:14 stephena Exp $
|
||||||
*/
|
*/
|
||||||
class Settings
|
class Settings
|
||||||
{
|
{
|
||||||
|
@ -138,61 +138,10 @@ class Settings
|
||||||
*/
|
*/
|
||||||
void setString(const string& key, const string& value, bool save = true);
|
void setString(const string& key, const string& value, bool save = true);
|
||||||
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
This method should be called to get the filename of the
|
|
||||||
properties (stella.pro) file for the purpose of loading.
|
|
||||||
|
|
||||||
@return String representing the full path of the properties filename.
|
|
||||||
*/
|
|
||||||
string propertiesInputFilename() { return myPropertiesInputFile; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
This method should be called to get the filename of the
|
|
||||||
properties (stella.pro) file for the purpose of saving.
|
|
||||||
|
|
||||||
@return String representing the full path of the properties filename.
|
|
||||||
*/
|
|
||||||
string propertiesOutputFilename() { return myPropertiesOutputFile; }
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
This method should be called to get the filename of the config file
|
|
||||||
for the purpose of loading.
|
|
||||||
|
|
||||||
@return String representing the full path of the config filename.
|
|
||||||
*/
|
|
||||||
string configInputFilename() { return myConfigInputFile; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
This method should be called to get the filename of the config file
|
|
||||||
for the purpose of saving.
|
|
||||||
|
|
||||||
@return String representing the full path of the config filename.
|
|
||||||
*/
|
|
||||||
string configOutputFilename() { return myConfigOutputFile; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
Return the default directory for storing data.
|
|
||||||
*/
|
|
||||||
string baseDir() { return myBaseDir; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
Set the OSystem object for this settings class
|
|
||||||
*/
|
|
||||||
void setOSystem(OSystem* osystem) { myOSystem = osystem; }
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void set(const string& key, const string& value, bool save = true);
|
void set(const string& key, const string& value, bool save = true);
|
||||||
|
|
||||||
string myBaseDir;
|
// The parent OSystem object
|
||||||
string myStateDir;
|
|
||||||
|
|
||||||
string myPropertiesInputFile;
|
|
||||||
string myPropertiesOutputFile;
|
|
||||||
string myConfigInputFile;
|
|
||||||
string myConfigOutputFile;
|
|
||||||
|
|
||||||
OSystem* myOSystem;
|
OSystem* myOSystem;
|
||||||
|
|
||||||
// Structure used for storing settings
|
// Structure used for storing settings
|
||||||
|
|
|
@ -13,13 +13,16 @@
|
||||||
// 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: Sound.cxx,v 1.16 2005-02-22 02:59:54 stephena Exp $
|
// $Id: Sound.cxx,v 1.17 2005-02-22 18:41:15 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#include "Serializer.hxx"
|
#include "Serializer.hxx"
|
||||||
#include "Deserializer.hxx"
|
#include "Deserializer.hxx"
|
||||||
|
|
||||||
|
#include "bspf.hxx"
|
||||||
|
|
||||||
#include "OSystem.hxx"
|
#include "OSystem.hxx"
|
||||||
|
#include "Settings.hxx"
|
||||||
#include "Sound.hxx"
|
#include "Sound.hxx"
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -30,6 +33,11 @@ Sound::Sound(OSystem* osystem)
|
||||||
{
|
{
|
||||||
// Add the sound object to the system
|
// Add the sound object to the system
|
||||||
myOSystem->attach(this);
|
myOSystem->attach(this);
|
||||||
|
|
||||||
|
// Show some info
|
||||||
|
if(myOSystem->settings().getBool("showinfo") &&
|
||||||
|
!myOSystem->settings().getBool("sound"))
|
||||||
|
cout << "Sound disabled." << endl << 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: OSystemUNIX.cxx,v 1.2 2005-02-21 20:43:47 stephena Exp $
|
// $Id: OSystemUNIX.cxx,v 1.3 2005-02-22 18:41:15 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
@ -42,7 +42,7 @@ OSystemUNIX::~OSystemUNIX()
|
||||||
string OSystemUNIX::stateFilename(const string& md5, uInt32 state)
|
string OSystemUNIX::stateFilename(const string& md5, uInt32 state)
|
||||||
{
|
{
|
||||||
ostringstream buf;
|
ostringstream buf;
|
||||||
//FIXME buf << myStateDir << md5 << ".st" << state;
|
buf << stateDir() << "/" << md5 << ".st" << state;
|
||||||
|
|
||||||
return buf.str();
|
return buf.str();
|
||||||
}
|
}
|
||||||
|
@ -50,5 +50,11 @@ string OSystemUNIX::stateFilename(const string& md5, uInt32 state)
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
bool OSystemUNIX::fileExists(const string& filename)
|
bool OSystemUNIX::fileExists(const string& filename)
|
||||||
{
|
{
|
||||||
return (access(filename.c_str(), F_OK) == 0);
|
return access(filename.c_str(), F_OK) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
bool OSystemUNIX::makeDir(const string& path)
|
||||||
|
{
|
||||||
|
return mkdir(path.c_str(), 0777) == 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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: OSystemUNIX.hxx,v 1.2 2005-02-21 20:43:53 stephena Exp $
|
// $Id: OSystemUNIX.hxx,v 1.3 2005-02-22 18:41:16 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#ifndef OSYSTEM_UNIX_HXX
|
#ifndef OSYSTEM_UNIX_HXX
|
||||||
|
@ -26,7 +26,7 @@
|
||||||
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: OSystemUNIX.hxx,v 1.2 2005-02-21 20:43:53 stephena Exp $
|
@version $Id: OSystemUNIX.hxx,v 1.3 2005-02-22 18:41:16 stephena Exp $
|
||||||
*/
|
*/
|
||||||
class OSystemUNIX : public OSystem
|
class OSystemUNIX : public OSystem
|
||||||
{
|
{
|
||||||
|
@ -62,6 +62,15 @@ class OSystemUNIX : public OSystem
|
||||||
@return boolean representing whether or not the file exists
|
@return boolean representing whether or not the file exists
|
||||||
*/
|
*/
|
||||||
virtual bool fileExists(const string& filename);
|
virtual bool fileExists(const string& filename);
|
||||||
|
|
||||||
|
/**
|
||||||
|
This method should be called to create the specified directory.
|
||||||
|
|
||||||
|
@param path The directory to create
|
||||||
|
|
||||||
|
@return boolean representing whether or not the directory was created
|
||||||
|
*/
|
||||||
|
virtual bool makeDir(const string& path);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -13,16 +13,10 @@
|
||||||
// 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.9 2005-02-21 20:43:53 stephena Exp $
|
// $Id: SettingsUNIX.cxx,v 1.10 2005-02-22 18:41:16 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <sstream>
|
|
||||||
#include <fstream>
|
|
||||||
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#include "bspf.hxx"
|
#include "bspf.hxx"
|
||||||
#include "OSystem.hxx"
|
#include "OSystem.hxx"
|
||||||
|
@ -33,40 +27,26 @@
|
||||||
SettingsUNIX::SettingsUNIX(OSystem* osystem)
|
SettingsUNIX::SettingsUNIX(OSystem* osystem)
|
||||||
: Settings(osystem)
|
: Settings(osystem)
|
||||||
{
|
{
|
||||||
// First set variables that the parent class needs
|
// First set variables that the OSystem needs
|
||||||
myBaseDir = getenv("HOME");
|
string basedir = getenv("HOME");
|
||||||
string stelladir = myBaseDir + "/.stella";
|
myOSystem->setBaseDir(basedir);
|
||||||
|
|
||||||
|
string stelladir = basedir + "/.stella";
|
||||||
if(!myOSystem->fileExists(stelladir))
|
if(!myOSystem->fileExists(stelladir))
|
||||||
mkdir(stelladir.c_str(), 0777);
|
myOSystem->makeDir(stelladir);
|
||||||
// FIXME - add a OSystem mkdir
|
|
||||||
|
|
||||||
myStateDir = stelladir + "/state/";
|
string statedir = stelladir + "/state/";
|
||||||
if(!myOSystem->fileExists(myStateDir))
|
if(!myOSystem->fileExists(statedir))
|
||||||
mkdir(myStateDir.c_str(), 0777);
|
myOSystem->makeDir(statedir);
|
||||||
|
myOSystem->setStateDir(statedir);
|
||||||
|
|
||||||
string userPropertiesFile = stelladir + "/stella.pro";
|
string userPropertiesFile = stelladir + "/stella.pro";
|
||||||
string systemPropertiesFile = "/etc/stella.pro";
|
string systemPropertiesFile = "/etc/stella.pro";
|
||||||
string userConfigFile = stelladir + "/stellarc";
|
myOSystem->setPropertiesFiles(userPropertiesFile, systemPropertiesFile);
|
||||||
string systemConfigFile = "/etc/stellarc";
|
|
||||||
|
|
||||||
// Set up the names of the input and output config files
|
string userConfigFile = stelladir + "/stellarc";
|
||||||
myConfigOutputFile = userConfigFile;
|
string systemConfigFile = "/etc/stellarc";
|
||||||
if(myOSystem->fileExists(userConfigFile))
|
myOSystem->setConfigFiles(userConfigFile, systemConfigFile);
|
||||||
myConfigInputFile = userConfigFile;
|
|
||||||
else if(myOSystem->fileExists(systemConfigFile))
|
|
||||||
myConfigInputFile = systemConfigFile;
|
|
||||||
else
|
|
||||||
myConfigInputFile = "";
|
|
||||||
|
|
||||||
// Set up the input and output properties files
|
|
||||||
myPropertiesOutputFile = userPropertiesFile;
|
|
||||||
if(myOSystem->fileExists(userPropertiesFile))
|
|
||||||
myPropertiesInputFile = userPropertiesFile;
|
|
||||||
else if(myOSystem->fileExists(systemPropertiesFile))
|
|
||||||
myPropertiesInputFile = systemPropertiesFile;
|
|
||||||
else
|
|
||||||
myPropertiesInputFile = "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
Loading…
Reference in New Issue