mirror of https://github.com/stella-emu/stella.git
Finally added the required modifications to the SDL port for
compilation in Windows. There's still some work to do in the SettingsWin32 class, and tweaking of the sound, but it's pretty close. I think its the best that Stella has ever sounded on Windows ... I use the MingW32 environment with the Ming SDL libs from libsdl,org. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@226 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
083245cf9c
commit
41556196e4
|
@ -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.45 2003-11-09 23:53:19 stephena Exp $
|
## $Id: makefile,v 1.46 2003-12-04 22:22:53 stephena Exp $
|
||||||
##============================================================================
|
##============================================================================
|
||||||
|
|
||||||
##============================================================================
|
##============================================================================
|
||||||
|
@ -30,14 +30,14 @@ OPTIMIZATIONS = $(CXXFLAGS) -Wall -Wunused
|
||||||
### 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
|
||||||
|
|
||||||
### to include OpenGL video support (SDL)
|
### to include OpenGL video support (SDL)
|
||||||
# OPENGL_SUPPORT = 1
|
OPENGL_SUPPORT = 1
|
||||||
|
|
||||||
### to include joystick support (SDL)
|
### to include joystick support (SDL)
|
||||||
# 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) FIXME
|
### (requires PNG library) FIXME
|
||||||
|
@ -46,13 +46,13 @@ SOUND_OSS = 1
|
||||||
|
|
||||||
### comment this out if your system doesn't
|
### comment this out if your system doesn't
|
||||||
### have the gettimeofday function
|
### have the gettimeofday function
|
||||||
HAVE_GETTIMEOFDAY = 1
|
#HAVE_GETTIMEOFDAY = 1
|
||||||
|
|
||||||
### to include support for game developers
|
### to include support for game developers
|
||||||
### enables some extra commandline options that allow the user
|
### enables some extra commandline options that allow the user
|
||||||
### to override some emulation defaults
|
### to override some emulation defaults
|
||||||
### Only SDL port supported for now
|
### Only SDL port supported for now
|
||||||
# DEVELOPER_SUPPORT = 1
|
DEVELOPER_SUPPORT = 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
|
||||||
|
@ -124,7 +124,7 @@ OPTS.SDL += -DDEVELOPER_SUPPORT=1
|
||||||
OPTS.DOS += -DDEVELOPER_SUPPORT=1
|
OPTS.DOS += -DDEVELOPER_SUPPORT=1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(SOUND_OSS), 1)
|
ifeq ($(sounD_OSS), 1)
|
||||||
OPTS.SDL += -DSOUND_OSS=1
|
OPTS.SDL += -DSOUND_OSS=1
|
||||||
OBJS.SDL += SoundOSS.o
|
OBJS.SDL += SoundOSS.o
|
||||||
endif
|
endif
|
||||||
|
@ -143,7 +143,7 @@ endif
|
||||||
ifeq ($(OPENGL_SUPPORT), 1)
|
ifeq ($(OPENGL_SUPPORT), 1)
|
||||||
OPTS.SDL += -DDISPLAY_OPENGL=1
|
OPTS.SDL += -DDISPLAY_OPENGL=1
|
||||||
OBJS.SDL += FrameBufferGL.o
|
OBJS.SDL += FrameBufferGL.o
|
||||||
LIBS.SDL += -lGL -lGLU
|
LIBS.SDL += -lopengl32
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -156,6 +156,7 @@ default:
|
||||||
@echo ""
|
@echo ""
|
||||||
@echo " dos DOS version using DJGPP"
|
@echo " dos DOS version using DJGPP"
|
||||||
@echo " linux-sdl Linux SDL version"
|
@echo " linux-sdl Linux SDL version"
|
||||||
|
@echo " win32-sdl Windows SDL version"
|
||||||
@echo ""
|
@echo ""
|
||||||
@echo "Hopefully new versions will be added soon!"
|
@echo "Hopefully new versions will be added soon!"
|
||||||
@echo ""
|
@echo ""
|
||||||
|
@ -184,6 +185,20 @@ linux-sdl:
|
||||||
OBJS="mainSDL.o SettingsUNIX.o FrameBufferSDL.o FrameBufferSoft.o" \
|
OBJS="mainSDL.o SettingsUNIX.o FrameBufferSDL.o FrameBufferSoft.o" \
|
||||||
OBJS+="$(OBJS.SDL)"
|
OBJS+="$(OBJS.SDL)"
|
||||||
|
|
||||||
|
win32-sdl:
|
||||||
|
make stella.sdl \
|
||||||
|
INCLUDES="$(INCLUDES) -I$(UI)/sdl -I$(UI)/sound" \
|
||||||
|
SYS_INCLUDES="" \
|
||||||
|
OPTIONS="-DBSPF_UNIX=1 -DWIN32" \
|
||||||
|
OPTIONS+="$(OPTS.SDL)" \
|
||||||
|
LDFLAGS="" \
|
||||||
|
LDFLAGS+="$(CFLAGS.SDL)" \
|
||||||
|
LDLIBS="" \
|
||||||
|
LDLIBS+="$(LIBS.SDL)" \
|
||||||
|
OBJS="mainSDL.o SettingsWin32.o FrameBufferSDL.o FrameBufferSoft.o" \
|
||||||
|
OBJS+="$(OBJS.SDL)"
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
## List of "core" object files
|
## List of "core" object files
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
@ -360,6 +375,9 @@ Settings.o: $(CORE)/Settings.cxx $(CORE)/Settings.hxx
|
||||||
SettingsUNIX.o: $(UI)/sdl/SettingsUNIX.cxx $(UI)/sdl/SettingsUNIX.hxx
|
SettingsUNIX.o: $(UI)/sdl/SettingsUNIX.cxx $(UI)/sdl/SettingsUNIX.hxx
|
||||||
$(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(UI)/sdl/SettingsUNIX.cxx
|
$(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(UI)/sdl/SettingsUNIX.cxx
|
||||||
|
|
||||||
|
SettingsWin32.o: $(UI)/sdl/SettingsWin32.cxx $(UI)/sdl/SettingsWin32.hxx
|
||||||
|
$(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(UI)/sdl/SettingsWin32.cxx
|
||||||
|
|
||||||
Terminal.o: $(UI)/x11/Terminal.cxx $(UI)/x11/Terminal.hxx
|
Terminal.o: $(UI)/x11/Terminal.cxx $(UI)/x11/Terminal.hxx
|
||||||
$(CXX) -c $(FLAGS) $(OPTIONS) $(UI)/x11/Terminal.cxx
|
$(CXX) -c $(FLAGS) $(OPTIONS) $(UI)/x11/Terminal.cxx
|
||||||
|
|
||||||
|
|
|
@ -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: FrameBufferSDL.cxx,v 1.8 2003-12-03 18:11:25 stephena Exp $
|
// $Id: FrameBufferSDL.cxx,v 1.9 2003-12-04 22:22:53 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
|
@ -155,7 +155,7 @@ void FrameBufferSDL::grabMouse(bool grab)
|
||||||
uInt32 FrameBufferSDL::maxWindowSizeForScreen()
|
uInt32 FrameBufferSDL::maxWindowSizeForScreen()
|
||||||
{
|
{
|
||||||
if(!x11Available)
|
if(!x11Available)
|
||||||
return 3;
|
return 4;
|
||||||
|
|
||||||
#ifdef UNIX
|
#ifdef UNIX
|
||||||
// Otherwise, lock the screen and get the width and height
|
// Otherwise, lock the screen and get the width and height
|
||||||
|
@ -186,6 +186,8 @@ uInt32 FrameBufferSDL::maxWindowSizeForScreen()
|
||||||
else
|
else
|
||||||
return 1;
|
return 1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
return 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
|
@ -0,0 +1,213 @@
|
||||||
|
//============================================================================
|
||||||
|
//
|
||||||
|
// SSSS tt lll lll
|
||||||
|
// SS SS tt ll ll
|
||||||
|
// SS tttttt eeee ll ll aaaa
|
||||||
|
// SSSS tt ee ee ll ll aa
|
||||||
|
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
|
||||||
|
// SS SS tt ee ll ll aa aa
|
||||||
|
// SSSS ttt eeeee llll llll aaaaa
|
||||||
|
//
|
||||||
|
// Copyright (c) 1995-1999 by Bradford W. Mott
|
||||||
|
//
|
||||||
|
// See the file "license" for information on usage and redistribution of
|
||||||
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
|
//
|
||||||
|
// $Id: SettingsWin32.cxx,v 1.1 2003-12-04 22:22:53 stephena Exp $
|
||||||
|
//============================================================================
|
||||||
|
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <sstream>
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include "bspf.hxx"
|
||||||
|
#include "Console.hxx"
|
||||||
|
#include "EventHandler.hxx"
|
||||||
|
#include "StellaEvent.hxx"
|
||||||
|
|
||||||
|
#include "Settings.hxx"
|
||||||
|
#include "SettingsWin32.hxx"
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
SettingsWin32::SettingsWin32()
|
||||||
|
{
|
||||||
|
// First set variables that the parent class needs
|
||||||
|
myBaseDir = ".\\";
|
||||||
|
string stelladir = myBaseDir;
|
||||||
|
|
||||||
|
// if(access(stelladir.c_str(), R_OK|W_OK|X_OK) != 0 )
|
||||||
|
// mkdir(stelladir.c_str(), 0777);
|
||||||
|
|
||||||
|
myStateDir = stelladir + "state\\";
|
||||||
|
// if(access(myStateDir.c_str(), R_OK|W_OK|X_OK) != 0 )
|
||||||
|
// mkdir(myStateDir.c_str(), 0777);
|
||||||
|
|
||||||
|
myUserPropertiesFile = stelladir + "stella.pro";
|
||||||
|
mySystemPropertiesFile = stelladir + "stella.pro";
|
||||||
|
myUserConfigFile = stelladir + "stellarc";
|
||||||
|
mySystemConfigFile = stelladir + "stellarc";
|
||||||
|
|
||||||
|
// Set up the names of the input and output config files
|
||||||
|
mySettingsOutputFilename = myUserConfigFile;
|
||||||
|
// if(access(myUserConfigFile.c_str(), R_OK) == 0)
|
||||||
|
mySettingsInputFilename = myUserConfigFile;
|
||||||
|
// else
|
||||||
|
// mySettingsInputFilename = mySystemConfigFile;
|
||||||
|
|
||||||
|
mySnapshotFile = "";
|
||||||
|
myStateFile = "";
|
||||||
|
|
||||||
|
// Now create UNIX specific settings
|
||||||
|
set("video", "soft");
|
||||||
|
#ifdef DISPLAY_OPENGL
|
||||||
|
set("gl_filter", "nearest");
|
||||||
|
set("gl_aspect", "2");
|
||||||
|
#endif
|
||||||
|
set("sound", "sdl");
|
||||||
|
set("fullscreen", "false");
|
||||||
|
set("grabmouse", "false");
|
||||||
|
set("hidecursor", "false");
|
||||||
|
set("volume", "-1");
|
||||||
|
set("accurate", "false"); // Don't change this, or the sound will skip
|
||||||
|
#ifdef SNAPSHOT_SUPPORT
|
||||||
|
set("ssname", "romname");
|
||||||
|
set("ssdir", ".\\");
|
||||||
|
set("ssingle", "false");
|
||||||
|
#endif
|
||||||
|
set("joyleft", "0");
|
||||||
|
set("joyright", "1");
|
||||||
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
SettingsWin32::~SettingsWin32()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
void SettingsWin32::usage(string& message)
|
||||||
|
{
|
||||||
|
cout << endl
|
||||||
|
<< message << endl
|
||||||
|
<< endl
|
||||||
|
<< "Valid options are:" << endl
|
||||||
|
<< endl
|
||||||
|
<< " -video <type> Type is one of the following:\n"
|
||||||
|
<< " soft SDL software mode\n"
|
||||||
|
#ifdef DISPLAY_OPENGL
|
||||||
|
<< " gl SDL OpenGL mode\n"
|
||||||
|
<< endl
|
||||||
|
<< " -gl_filter <type> Type is one of the following:\n"
|
||||||
|
<< " nearest Normal scaling (GL_NEAREST)\n"
|
||||||
|
<< " linear Blurred scaling (GL_LINEAR)\n"
|
||||||
|
<< " -gl_aspect <number> Scale the width by the given amount\n"
|
||||||
|
<< endl
|
||||||
|
#endif
|
||||||
|
<< " -sound <type> Type is one of the following:\n"
|
||||||
|
<< " 0 Disables all sound generation\n"
|
||||||
|
#ifdef SOUND_ALSA
|
||||||
|
<< " alsa ALSA version 0.9 driver\n"
|
||||||
|
#endif
|
||||||
|
#ifdef SOUND_OSS
|
||||||
|
<< " oss Open Sound System driver\n"
|
||||||
|
#endif
|
||||||
|
#ifdef SOUND_SDL
|
||||||
|
<< " sdl Native SDL driver\n"
|
||||||
|
#endif
|
||||||
|
<< endl
|
||||||
|
<< " -framerate <number> Display the given number of frames per second\n"
|
||||||
|
<< " -zoom <size> Makes window be 'size' times normal\n"
|
||||||
|
<< " -fullscreen <0|1> Play the game in fullscreen mode\n"
|
||||||
|
<< " -grabmouse <0|1> Keeps the mouse in the game window\n"
|
||||||
|
<< " -hidecursor <0|1> Hides the mouse cursor in the game window\n"
|
||||||
|
<< " -volume <number> Set the volume (0 - 100)\n"
|
||||||
|
#ifdef HAVE_JOYSTICK
|
||||||
|
<< " -paddle <0|1|2|3|real> Indicates which paddle the mouse should emulate\n"
|
||||||
|
<< " or that real Atari 2600 paddles are being used\n"
|
||||||
|
<< " -joyleft <number> The joystick number representing the left controller\n"
|
||||||
|
<< " -joyright <number> The joystick number representing the right controller\n"
|
||||||
|
#else
|
||||||
|
<< " -paddle <0|1|2|3> Indicates which paddle the mouse should emulate\n"
|
||||||
|
#endif
|
||||||
|
<< " -altpro <props file> Use the given properties file instead of stella.pro\n"
|
||||||
|
<< " -showinfo <0|1> Shows some game info\n"
|
||||||
|
<< " -accurate <0|1> Accurate game timing (uses more CPU)\n"
|
||||||
|
#ifdef SNAPSHOT_SUPPORT
|
||||||
|
<< " -ssdir <path> The directory to save snapshot files to\n"
|
||||||
|
<< " -ssname <name> How to name the snapshot (romname or md5sum)\n"
|
||||||
|
<< " -sssingle <0|1> Generate single snapshot instead of many\n"
|
||||||
|
#endif
|
||||||
|
<< endl
|
||||||
|
#ifdef DEVELOPER_SUPPORT
|
||||||
|
<< " DEVELOPER options (see Stella manual for details)\n"
|
||||||
|
<< " -Dformat Sets \"Display.Format\"\n"
|
||||||
|
<< " -Dxstart Sets \"Display.XStart\"\n"
|
||||||
|
<< " -Dwidth Sets \"Display.Width\"\n"
|
||||||
|
<< " -Dystart Sets \"Display.YStart\"\n"
|
||||||
|
<< " -Dheight Sets \"Display.Height\"\n"
|
||||||
|
<< " -mergeprops <0|1> Merge changed properties into properties file,\n"
|
||||||
|
<< " or save into a separate file\n"
|
||||||
|
#endif
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
string SettingsWin32::stateFilename(uInt32 state)
|
||||||
|
{
|
||||||
|
if(!myConsole)
|
||||||
|
return "";
|
||||||
|
|
||||||
|
ostringstream buf;
|
||||||
|
buf << myStateDir << myConsole->properties().get("Cartridge.MD5")
|
||||||
|
<< ".st" << state;
|
||||||
|
|
||||||
|
myStateFile = buf.str();
|
||||||
|
return myStateFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
string SettingsWin32::snapshotFilename()
|
||||||
|
{
|
||||||
|
if(!myConsole)
|
||||||
|
return "";
|
||||||
|
|
||||||
|
string filename;
|
||||||
|
string path = getString("ssdir");
|
||||||
|
string theSnapshotName = getString("ssname");
|
||||||
|
|
||||||
|
if(theSnapshotName == "romname")
|
||||||
|
path = path + "/" + myConsole->properties().get("Cartridge.Name");
|
||||||
|
else if(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(!getBool("sssingle"))
|
||||||
|
{
|
||||||
|
// 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;
|
||||||
|
}
|
|
@ -0,0 +1,70 @@
|
||||||
|
//============================================================================
|
||||||
|
//
|
||||||
|
// SSSS tt lll lll
|
||||||
|
// SS SS tt ll ll
|
||||||
|
// SS tttttt eeee ll ll aaaa
|
||||||
|
// SSSS tt ee ee ll ll aa
|
||||||
|
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
|
||||||
|
// SS SS tt ee ll ll aa aa
|
||||||
|
// SSSS ttt eeeee llll llll aaaaa
|
||||||
|
//
|
||||||
|
// Copyright (c) 1995-1999 by Bradford W. Mott
|
||||||
|
//
|
||||||
|
// See the file "license" for information on usage and redistribution of
|
||||||
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
|
//
|
||||||
|
// $Id: SettingsWin32.hxx,v 1.1 2003-12-04 22:22:53 stephena Exp $
|
||||||
|
//============================================================================
|
||||||
|
|
||||||
|
#ifndef SETTINGS_WIN32_HXX
|
||||||
|
#define SETTINGS_WIN32_HXX
|
||||||
|
|
||||||
|
#include "bspf.hxx"
|
||||||
|
|
||||||
|
class Console;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
This class defines Windows system specific settings.
|
||||||
|
|
||||||
|
@author Stephen Anthony
|
||||||
|
@version $Id: SettingsWin32.hxx,v 1.1 2003-12-04 22:22:53 stephena Exp $
|
||||||
|
*/
|
||||||
|
class SettingsWin32 : public Settings
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
Create a new UNIX settings object
|
||||||
|
*/
|
||||||
|
SettingsWin32();
|
||||||
|
|
||||||
|
/**
|
||||||
|
Destructor
|
||||||
|
*/
|
||||||
|
virtual ~SettingsWin32();
|
||||||
|
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
This method should be called to get the filename of a state file
|
||||||
|
given the state number.
|
||||||
|
|
||||||
|
@return String representing the full path of the state filename.
|
||||||
|
*/
|
||||||
|
virtual string stateFilename(uInt32 state);
|
||||||
|
|
||||||
|
/**
|
||||||
|
This method should be called to get the filename of a snapshot.
|
||||||
|
|
||||||
|
@return String representing the full path of the snapshot filename.
|
||||||
|
*/
|
||||||
|
virtual string snapshotFilename();
|
||||||
|
|
||||||
|
/**
|
||||||
|
Display the commandline settings for this UNIX version of Stella.
|
||||||
|
|
||||||
|
@param message A short message about this version of Stella
|
||||||
|
*/
|
||||||
|
virtual void usage(string& message);
|
||||||
|
};
|
||||||
|
|
||||||
|
#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: mainSDL.cxx,v 1.63 2003-12-04 19:18:45 stephena Exp $
|
// $Id: mainSDL.cxx,v 1.64 2003-12-04 22:22:53 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
@ -61,6 +61,10 @@
|
||||||
#include "SettingsUNIX.hxx"
|
#include "SettingsUNIX.hxx"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
#include "SettingsWin32.hxx"
|
||||||
|
#endif
|
||||||
|
|
||||||
static void cleanup();
|
static void cleanup();
|
||||||
static bool setupJoystick();
|
static bool setupJoystick();
|
||||||
static void handleEvents();
|
static void handleEvents();
|
||||||
|
@ -664,6 +668,9 @@ int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
#ifdef UNIX
|
#ifdef UNIX
|
||||||
theSettings = new SettingsUNIX();
|
theSettings = new SettingsUNIX();
|
||||||
|
#endif
|
||||||
|
#ifdef WIN32
|
||||||
|
theSettings = new SettingsWin32();
|
||||||
#endif
|
#endif
|
||||||
if(!theSettings)
|
if(!theSettings)
|
||||||
{
|
{
|
||||||
|
@ -687,13 +694,13 @@ int main(int argc, char* argv[])
|
||||||
|
|
||||||
// Request that the SDL window be centered, if possible
|
// Request that the SDL window be centered, if possible
|
||||||
// This will probably only work under Linux
|
// This will probably only work under Linux
|
||||||
setenv("SDL_VIDEO_CENTERED", "1", 1);
|
putenv("SDL_VIDEO_CENTERED");
|
||||||
|
|
||||||
// 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];
|
||||||
|
|
||||||
// Open the cartridge image and read it in
|
// Open the cartridge image and read it in
|
||||||
ifstream in(file);
|
ifstream in(file, ios_base::binary);
|
||||||
if(!in)
|
if(!in)
|
||||||
{
|
{
|
||||||
cerr << "ERROR: Couldn't open " << file << "..." << endl;
|
cerr << "ERROR: Couldn't open " << file << "..." << 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: SoundSDL.cxx,v 1.5 2003-11-19 15:57:11 stephena Exp $
|
// $Id: SoundSDL.cxx,v 1.6 2003-12-04 22:22:53 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
|
@ -23,11 +23,12 @@
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
SoundSDL::SoundSDL()
|
SoundSDL::SoundSDL()
|
||||||
: myCurrentVolume(SDL_MIX_MAXVOLUME),
|
: myCurrentVolume(SDL_MIX_MAXVOLUME),
|
||||||
myFragmentSize(1024),
|
myFragmentSize(2048),
|
||||||
myIsInitializedFlag(false),
|
myIsInitializedFlag(false),
|
||||||
myIsMuted(false),
|
myIsMuted(false),
|
||||||
mySampleRate(31400),
|
mySampleRate(31400),
|
||||||
mySampleQueue(mySampleRate)
|
mySampleQueueSize(8000),
|
||||||
|
mySampleQueue(mySampleQueueSize)//mySampleRate)
|
||||||
{
|
{
|
||||||
if(1)
|
if(1)
|
||||||
{
|
{
|
||||||
|
@ -172,10 +173,10 @@ void SoundSDL::update()
|
||||||
SDL_LockAudio();
|
SDL_LockAudio();
|
||||||
|
|
||||||
// Move all of the generated samples into the our private sample queue
|
// Move all of the generated samples into the our private sample queue
|
||||||
uInt8 buffer[4096];
|
uInt8 buffer[2048];
|
||||||
while(myMediaSource->numberOfAudioSamples() > 0)
|
while(myMediaSource->numberOfAudioSamples() > 0)
|
||||||
{
|
{
|
||||||
uInt32 size = myMediaSource->dequeueAudioSamples(buffer, 4096);
|
uInt32 size = myMediaSource->dequeueAudioSamples(buffer, 2048);
|
||||||
mySampleQueue.enqueue(buffer, size);
|
mySampleQueue.enqueue(buffer, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,7 +185,7 @@ void SoundSDL::update()
|
||||||
|
|
||||||
// Block until the sound thread has consumed all but 142 milliseconds
|
// Block until the sound thread has consumed all but 142 milliseconds
|
||||||
// of the available audio samples
|
// of the available audio samples
|
||||||
uInt32 leave = mySampleRate / 7;
|
uInt32 left = mySampleRate / 3;
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
uInt32 size = 0;
|
uInt32 size = 0;
|
||||||
|
@ -193,12 +194,12 @@ void SoundSDL::update()
|
||||||
size = mySampleQueue.size();
|
size = mySampleQueue.size();
|
||||||
SDL_UnlockAudio();
|
SDL_UnlockAudio();
|
||||||
|
|
||||||
if(size <= leave)
|
if(size < left)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_Delay(5);
|
SDL_Delay(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -214,7 +215,7 @@ void SoundSDL::callback(void* udata, uInt8* stream, int len)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't use samples unless there's at least 76 milliseconds worth of data
|
// Don't use samples unless there's at least 76 milliseconds worth of data
|
||||||
if(sound->mySampleQueue.size() < (sound->mySampleRate / 13))
|
if(sound->mySampleQueue.size() < (sound->mySampleRate / 16))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -224,11 +225,11 @@ void SoundSDL::callback(void* udata, uInt8* stream, int len)
|
||||||
if(sound->mySampleQueue.size() > 0)
|
if(sound->mySampleQueue.size() > 0)
|
||||||
{
|
{
|
||||||
Int32 offset;
|
Int32 offset;
|
||||||
uInt8 buffer[4096];
|
uInt8 buffer[2048];
|
||||||
for(offset = 0; (offset < len) && (sound->mySampleQueue.size() > 0); )
|
for(offset = 0; (offset < len) && (sound->mySampleQueue.size() > 0); )
|
||||||
{
|
{
|
||||||
uInt32 s = sound->mySampleQueue.dequeue(buffer,
|
uInt32 s = sound->mySampleQueue.dequeue(buffer,
|
||||||
(4096 > (len - offset) ? (len - offset) : 4096));
|
(2048 > (len - offset) ? (len - offset) : 2048));
|
||||||
SDL_MixAudio(stream + offset, buffer, s, sound->myCurrentVolume);
|
SDL_MixAudio(stream + offset, buffer, s, sound->myCurrentVolume);
|
||||||
offset += s;
|
offset += s;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.hxx,v 1.5 2003-11-19 15:57:11 stephena Exp $
|
// $Id: SoundSDL.hxx,v 1.6 2003-12-04 22:22:53 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#ifndef SOUNDSDL_HXX
|
#ifndef SOUNDSDL_HXX
|
||||||
|
@ -29,7 +29,7 @@
|
||||||
This class implements the sound API for SDL.
|
This class implements the sound API for SDL.
|
||||||
|
|
||||||
@author Stephen Anthony and Bradford W. Mott
|
@author Stephen Anthony and Bradford W. Mott
|
||||||
@version $Id: SoundSDL.hxx,v 1.5 2003-11-19 15:57:11 stephena Exp $
|
@version $Id: SoundSDL.hxx,v 1.6 2003-12-04 22:22:53 stephena Exp $
|
||||||
*/
|
*/
|
||||||
class SoundSDL : public Sound
|
class SoundSDL : public Sound
|
||||||
{
|
{
|
||||||
|
@ -160,6 +160,9 @@ class SoundSDL : public Sound
|
||||||
// DSP sample rate
|
// DSP sample rate
|
||||||
uInt32 mySampleRate;
|
uInt32 mySampleRate;
|
||||||
|
|
||||||
|
// The sample queue size (which is auto-adapting)
|
||||||
|
uInt32 mySampleQueueSize;
|
||||||
|
|
||||||
// Queue which holds samples from the media source before they are played
|
// Queue which holds samples from the media source before they are played
|
||||||
SampleQueue mySampleQueue;
|
SampleQueue mySampleQueue;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue