Cleaned up the Video and Audio dialog boxes a little, making them waste

as little space as possible.

Added ability to enable/disable sound from within the emulation.  So you
no longer *have* to specify it on the commandline (but you still can, if
you want to).

Changed makefile to conditionally compile sound support.  It makes the app
approx 15KB smaller, if anyone really wants to do that ...


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@399 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2005-04-28 19:28:33 +00:00
parent db67ba4bb4
commit c8fd06bc69
10 changed files with 202 additions and 119 deletions

View 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: makefile,v 1.71 2005-04-04 02:19:19 stephena Exp $ ## $Id: makefile,v 1.72 2005-04-28 19:28:31 stephena Exp $
##============================================================================ ##============================================================================
##============================================================================ ##============================================================================
@ -39,6 +39,9 @@ OPTIMIZATIONS =
### to override some emulation defaults ### to override some emulation defaults
DEVELOPER_SUPPORT = 1 DEVELOPER_SUPPORT = 1
### to include sound support
SOUND_SUPPORT = 1
### to build on SMP (or distcc-based) machines ### to build on SMP (or distcc-based) machines
### change to number of CPU's you have ### change to number of CPU's you have
NUMBER_CPU = 1 NUMBER_CPU = 1
@ -53,7 +56,7 @@ LD = g++
LDFLAGS = `sdl-config --cflags` LDFLAGS = `sdl-config --cflags`
LDLIBS = `sdl-config --libs` LDLIBS = `sdl-config --libs`
OBJECTS = mainSDL.o SoundSDL.o FrameBufferSoft.o OBJECTS = mainSDL.o FrameBufferSoft.o
OPTIONS = OPTIONS =
EXE_NAME = EXE_NAME =
SMP = SMP =
@ -97,6 +100,11 @@ ifdef DEVELOPER_SUPPORT
OPTIONS += -DDEVELOPER_SUPPORT OPTIONS += -DDEVELOPER_SUPPORT
endif endif
ifdef SOUND_SUPPORT
OBJECTS += TIASound.o SoundSDL.o
OPTIONS += -DSOUND_SUPPORT
endif
default: default:
@echo "" @echo ""
@ -155,8 +163,8 @@ CORE_OBJS = Booster.o Cart.o Cart2K.o Cart3F.o Cart4K.o CartAR.o CartDPC.o \
CartF8.o CartF8SC.o CartFASC.o CartFE.o CartMC.o CartCV.o \ CartF8.o CartF8SC.o CartFASC.o CartFE.o CartMC.o CartCV.o \
CartMB.o CartUA.o Console.o Control.o Driving.o \ CartMB.o CartUA.o Console.o Control.o Driving.o \
Event.o Joystick.o Keyboard.o M6532.o MD5.o MediaSrc.o Paddles.o \ Event.o Joystick.o Keyboard.o M6532.o MD5.o MediaSrc.o Paddles.o \
Props.o PropsSet.o Random.o Sound.o Switches.o Settings.o TIA.o \ Props.o PropsSet.o Random.o SoundNull.o Switches.o Settings.o TIA.o \
Serializer.o Deserializer.o TIASound.o EventHandler.o FrameBuffer.o \ Serializer.o Deserializer.o EventHandler.o FrameBuffer.o \
OSystem.o \ OSystem.o \
$(M6502_OBJS) $(GUI_OBJS) $(M6502_OBJS) $(GUI_OBJS)
@ -290,9 +298,6 @@ Props.o: $(CORE)/Props.cxx $(CORE)/Props.hxx
Random.o: $(CORE)/Random.cxx $(CORE)/Random.hxx Random.o: $(CORE)/Random.cxx $(CORE)/Random.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/Random.cxx $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/Random.cxx
Sound.o: $(CORE)/Sound.cxx $(CORE)/Sound.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(CORE)/Sound.cxx
Switches.o: $(CORE)/Switches.cxx $(CORE)/Switches.hxx Switches.o: $(CORE)/Switches.cxx $(CORE)/Switches.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/Switches.cxx $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/Switches.cxx
@ -320,6 +325,9 @@ SettingsWin32.o: $(SRC)/win32/SettingsWin32.cxx $(SRC)/win32/SettingsWin32.hxx
OSystemWin32.o: $(SRC)/win32/OSystemWin32.cxx $(SRC)/win32/OSystemWin32.hxx OSystemWin32.o: $(SRC)/win32/OSystemWin32.cxx $(SRC)/win32/OSystemWin32.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(SRC)/win32/OSystemWin32.cxx $(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(SRC)/win32/OSystemWin32.cxx
SoundNull.o: $(COMMON)/SoundNull.cxx $(COMMON)/SoundNull.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(COMMON)/SoundNull.cxx
SoundSDL.o: $(COMMON)/SoundSDL.cxx $(COMMON)/SoundSDL.hxx SoundSDL.o: $(COMMON)/SoundSDL.cxx $(COMMON)/SoundSDL.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(COMMON)/SoundSDL.cxx $(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(COMMON)/SoundSDL.cxx

View 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: SoundSDL.cxx,v 1.12 2005-03-26 19:26:47 stephena Exp $ // $Id: SoundSDL.cxx,v 1.13 2005-04-28 19:28:32 stephena Exp $
//============================================================================ //============================================================================
#include <sstream> #include <sstream>
@ -34,9 +34,11 @@
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SoundSDL::SoundSDL(OSystem* osystem) SoundSDL::SoundSDL(OSystem* osystem)
: Sound(osystem), : Sound(osystem),
myIsEnabled(osystem->settings().getBool("sound")),
myFragmentSizeLogBase2(0), myFragmentSizeLogBase2(0),
myIsMuted(false) myIsMuted(false)
{ {
myOSystem->attach(this);
initialize(true); initialize(true);
} }
@ -44,25 +46,31 @@ SoundSDL::SoundSDL(OSystem* osystem)
SoundSDL::~SoundSDL() SoundSDL::~SoundSDL()
{ {
// Close the SDL audio system if it's initialized // Close the SDL audio system if it's initialized
if(myIsInitializedFlag) closeAudio();
{ }
SDL_PauseAudio(1);
SDL_CloseAudio();
}
myIsInitializedFlag = false; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SoundSDL::setEnabled(bool enable)
{
myIsEnabled = enable;
myOSystem->settings().setBool("sound", enable);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SoundSDL::initialize(bool forcerestart) void SoundSDL::initialize(bool forcerestart)
{ {
if(forcerestart && myIsInitializedFlag) // Check whether to start the sound subsystem
if(!myIsEnabled)
{ {
SDL_PauseAudio(1); closeAudio();
SDL_CloseAudio(); if(myOSystem->settings().getBool("showinfo"))
myIsInitializedFlag = false; cout << "Sound disabled." << endl << endl;
return;
} }
if(forcerestart && myIsInitializedFlag)
closeAudio();
bool isAlreadyInitialized = (SDL_WasInit(SDL_INIT_AUDIO) & SDL_INIT_AUDIO) > 0; bool isAlreadyInitialized = (SDL_WasInit(SDL_INIT_AUDIO) & SDL_INIT_AUDIO) > 0;
if(!isAlreadyInitialized) if(!isAlreadyInitialized)
@ -138,8 +146,6 @@ void SoundSDL::initialize(bool forcerestart)
<< " Frag size: " << fragsize << endl << endl; << " Frag size: " << fragsize << endl << endl;
} }
} }
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -186,6 +192,7 @@ void SoundSDL::setVolume(Int32 percent)
{ {
if((percent >= 0) && (percent <= 100)) if((percent >= 0) && (percent <= 100))
{ {
myOSystem->settings().setInt("volume", percent);
SDL_LockAudio(); SDL_LockAudio();
myVolume = percent; myVolume = percent;
Tia_volume(percent); Tia_volume(percent);
@ -218,7 +225,19 @@ void SoundSDL::adjustVolume(Int8 direction)
message += strval.str(); message += strval.str();
myOSystem->frameBuffer().showMessage(message); myOSystem->frameBuffer().showMessage(message);
myOSystem->settings().setInt("volume", percent); }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SoundSDL::adjustCycleCounter(Int32 amount)
{
myLastRegisterSetCycle += amount;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SoundSDL::setFrameRate(uInt32 framerate)
{
myDisplayFrameRate = framerate;
myLastRegisterSetCycle = 0;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -250,9 +269,7 @@ void SoundSDL::set(uInt16 addr, uInt8 value, Int32 cycle)
void SoundSDL::processFragment(uInt8* stream, Int32 length) void SoundSDL::processFragment(uInt8* stream, Int32 length)
{ {
if(!myIsInitializedFlag) if(!myIsInitializedFlag)
{
return; return;
}
// If there are excessive items on the queue then we'll remove some // If there are excessive items on the queue then we'll remove some
if(myRegWriteQueue.duration() > (myFragmentSizeLogBase2 / myDisplayFrameRate)) if(myRegWriteQueue.duration() > (myFragmentSizeLogBase2 / myDisplayFrameRate))
@ -334,6 +351,17 @@ void SoundSDL::callback(void* udata, uInt8* stream, int len)
sound->processFragment(stream, (Int32)len); sound->processFragment(stream, (Int32)len);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SoundSDL::closeAudio()
{
if(myIsInitializedFlag)
{
SDL_PauseAudio(1);
SDL_CloseAudio();
myIsInitializedFlag = false;
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool SoundSDL::load(Deserializer& in) bool SoundSDL::load(Deserializer& in)
{ {

View File

@ -13,11 +13,11 @@
// 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.9 2005-03-26 19:26:47 stephena Exp $ // $Id: SoundSDL.hxx,v 1.10 2005-04-28 19:28:32 stephena Exp $
//============================================================================ //============================================================================
#ifndef SOUNDSDL_HXX #ifndef SOUND_SDL_HXX
#define SOUNDSDL_HXX #define SOUND_SDL_HXX
class OSystem; class OSystem;
@ -31,7 +31,7 @@ class OSystem;
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.9 2005-03-26 19:26:47 stephena Exp $ @version $Id: SoundSDL.hxx,v 1.10 2005-04-28 19:28:32 stephena Exp $
*/ */
class SoundSDL : public Sound class SoundSDL : public Sound
{ {
@ -48,41 +48,64 @@ class SoundSDL : public Sound
virtual ~SoundSDL(); virtual ~SoundSDL();
public: public:
/**
Enables/disables the sound subsystem.
@param enable Either true or false, to enable or disable the sound system
*/
void setEnabled(bool enable);
/**
The system cycle counter is being adjusting by the specified amount. Any
members using the system cycle counter should be adjusted as needed.
@param amount The amount the cycle counter is being adjusted by
*/
void adjustCycleCounter(Int32 amount);
/**
Sets the display framerate. Sound generation for NTSC and PAL games
depends on the framerate, so we need to set it here.
@param framerate The base framerate depending on NTSC or PAL ROM
*/
void setFrameRate(uInt32 framerate);
/** /**
Initializes the sound device. This must be called before any Initializes the sound device. This must be called before any
calls are made to derived methods. calls are made to derived methods.
@param forcerestart Do a soft or hard reset of the sound subsystem @param forcerestart Do a soft or hard reset of the sound subsystem
*/ */
virtual void initialize(bool forcerestart = false); void initialize(bool forcerestart = false);
/** /**
Return true iff the sound device was successfully initialized. Return true iff the sound device was successfully initialized.
@return true iff the sound device was successfully initialized @return true iff the sound device was successfully initialized.
*/ */
virtual bool isSuccessfullyInitialized() const; bool isSuccessfullyInitialized() const;
/** /**
Set the mute state of the sound object. While muted no sound is played. Set the mute state of the sound object. While muted no sound is played.
@param state Mutes sound if true, unmute if false @param state Mutes sound if true, unmute if false
*/ */
virtual void mute(bool state); void mute(bool state);
/** /**
Resets the sound device. Reset the sound device.
*/ */
virtual void reset(); void reset();
/** /**
Sets the sound register to a given value. Sets the sound register to a given value.
@param addr The register address @param addr The register address
@param value The value to save into the register @param value The value to save into the register
@param cycle The CPU cycle at which the register is being updated @param cycle The system cycle at which the register is being updated
*/ */
virtual void set(uInt16 addr, uInt8 value, Int32 cycle); void set(uInt16 addr, uInt8 value, Int32 cycle);
/** /**
Sets the volume of the sound device to the specified level. The Sets the volume of the sound device to the specified level. The
@ -91,7 +114,7 @@ class SoundSDL : public Sound
@param percent The new volume percentage level for the sound device @param percent The new volume percentage level for the sound device
*/ */
virtual void setVolume(Int32 percent); void setVolume(Int32 percent);
/** /**
Adjusts the volume of the sound device based on the given direction. Adjusts the volume of the sound device based on the given direction.
@ -99,7 +122,7 @@ class SoundSDL : public Sound
@param direction Increase or decrease the current volume by a predefined @param direction Increase or decrease the current volume by a predefined
amount based on the direction (1 = increase, -1 =decrease) amount based on the direction (1 = increase, -1 =decrease)
*/ */
virtual void adjustVolume(Int8 direction); void adjustVolume(Int8 direction);
public: public:
/** /**
@ -203,8 +226,17 @@ class SoundSDL : public Sound
}; };
private: private:
// Audio specification structure // Indicates if the sound subsystem is to be initialized
SDL_AudioSpec myHardwareSpec; bool myIsEnabled;
// Indicates if the sound device was successfully initialized
bool myIsInitializedFlag;
// Indicates the cycle when a sound register was last set
Int32 myLastRegisterSetCycle;
// Indicates the base framerate depending on whether the ROM is NTSC or PAL
uInt32 myDisplayFrameRate;
// Log base 2 of the selected fragment size // Log base 2 of the selected fragment size
double myFragmentSizeLogBase2; double myFragmentSizeLogBase2;
@ -215,12 +247,18 @@ class SoundSDL : public Sound
// Current volume as a percentage (0 - 100) // Current volume as a percentage (0 - 100)
uInt32 myVolume; uInt32 myVolume;
// Audio specification structure
SDL_AudioSpec myHardwareSpec;
// Queue of TIA register writes // Queue of TIA register writes
RegWriteQueue myRegWriteQueue; RegWriteQueue myRegWriteQueue;
private: private:
// Callback function invoked by the SDL Audio library when it needs data // Callback function invoked by the SDL Audio library when it needs data
static void callback(void* udata, uInt8* stream, int len); static void callback(void* udata, uInt8* stream, int len);
// Closes the audio device
void closeAudio();
}; };
#endif #endif

View 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.30 2005-04-03 19:37:32 stephena Exp $ // $Id: mainSDL.cxx,v 1.31 2005-04-28 19:28:32 stephena Exp $
//============================================================================ //============================================================================
#include <fstream> #include <fstream>
@ -38,10 +38,15 @@
#include "FrameBufferSoft.hxx" #include "FrameBufferSoft.hxx"
#include "PropsSet.hxx" #include "PropsSet.hxx"
#include "Sound.hxx" #include "Sound.hxx"
#include "SoundSDL.hxx"
#include "Settings.hxx" #include "Settings.hxx"
#include "OSystem.hxx" #include "OSystem.hxx"
#ifdef SOUND_SUPPORT
#include "SoundSDL.hxx"
#else
#include "SoundNull.hxx"
#endif
#ifdef DISPLAY_OPENGL #ifdef DISPLAY_OPENGL
#include "FrameBufferGL.hxx" #include "FrameBufferGL.hxx"
#endif #endif
@ -396,10 +401,11 @@ int main(int argc, char* argv[])
} }
// Create a sound object for playing audio, even if sound has been disabled // Create a sound object for playing audio, even if sound has been disabled
if(theSettings->getBool("sound")) #ifdef SOUND_SUPPORT
theSound = new SoundSDL(theOSystem); theSound = new SoundSDL(theOSystem);
else #else
theSound = new Sound(theOSystem); theSound = new SoundNull(theOSystem);
#endif
// Setup the SDL joysticks (must be done after FrameBuffer is created) // Setup the SDL joysticks (must be done after FrameBuffer is created)
/* FIXME - don't exit if joysticks can't be initialized /* FIXME - don't exit if joysticks can't be initialized

View 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: Sound.hxx,v 1.16 2005-03-26 19:26:47 stephena Exp $ // $Id: Sound.hxx,v 1.17 2005-04-28 19:28:33 stephena Exp $
//============================================================================ //============================================================================
#ifndef SOUND_HXX #ifndef SOUND_HXX
@ -26,12 +26,11 @@ class Deserializer;
#include "bspf.hxx" #include "bspf.hxx"
/** /**
This class is a base class for the various sound objects. This class is an abstract base class for the various sound objects.
It has almost no functionality, but is useful if one wishes It has no functionality whatsoever.
to compile Stella with no sound support whatsoever.
@author Stephen Anthony and Bradford W. Mott @author Stephen Anthony
@version $Id: Sound.hxx,v 1.16 2005-03-26 19:26:47 stephena Exp $ @version $Id: Sound.hxx,v 1.17 2005-04-28 19:28:33 stephena Exp $
*/ */
class Sound class Sound
{ {
@ -40,21 +39,23 @@ class Sound
Create a new sound object. The init method must be invoked before Create a new sound object. The init method must be invoked before
using the object. using the object.
*/ */
Sound(OSystem* osystem); Sound(OSystem* osystem) { myOSystem = osystem; }
/**
Destructor
*/
virtual ~Sound();
public: public:
/**
Enables/disables the sound subsystem.
@param enable Either true or false, to enable or disable the sound system
*/
virtual void setEnabled(bool enable) = 0;
/** /**
The system cycle counter is being adjusting by the specified amount. Any The system cycle counter is being adjusting by the specified amount. Any
members using the system cycle counter should be adjusted as needed. members using the system cycle counter should be adjusted as needed.
@param amount The amount the cycle counter is being adjusted by @param amount The amount the cycle counter is being adjusted by
*/ */
virtual void adjustCycleCounter(Int32 amount); virtual void adjustCycleCounter(Int32 amount) = 0;
/** /**
Sets the display framerate. Sound generation for NTSC and PAL games Sets the display framerate. Sound generation for NTSC and PAL games
@ -62,7 +63,7 @@ class Sound
@param framerate The base framerate depending on NTSC or PAL ROM @param framerate The base framerate depending on NTSC or PAL ROM
*/ */
virtual void setFrameRate(uInt32 framerate); virtual void setFrameRate(uInt32 framerate) = 0;
/** /**
Initializes the sound device. This must be called before any Initializes the sound device. This must be called before any
@ -70,26 +71,26 @@ class Sound
@param forcerestart Do a soft or hard reset of the sound subsystem @param forcerestart Do a soft or hard reset of the sound subsystem
*/ */
virtual void initialize(bool forcerestart = false); virtual void initialize(bool forcerestart = false) = 0;
/** /**
Return true iff the sound device was successfully initialized. Return true iff the sound device was successfully initialized.
@return true iff the sound device was successfully initialized. @return true iff the sound device was successfully initialized.
*/ */
virtual bool isSuccessfullyInitialized() const; virtual bool isSuccessfullyInitialized() const = 0;
/** /**
Set the mute state of the sound object. While muted no sound is played. Set the mute state of the sound object. While muted no sound is played.
@param state Mutes sound if true, unmute if false @param state Mutes sound if true, unmute if false
*/ */
virtual void mute(bool state); virtual void mute(bool state) = 0;
/** /**
Reset the sound device. Reset the sound device.
*/ */
virtual void reset(); virtual void reset() = 0;
/** /**
Sets the sound register to a given value. Sets the sound register to a given value.
@ -98,7 +99,7 @@ class Sound
@param value The value to save into the register @param value The value to save into the register
@param cycle The system cycle at which the register is being updated @param cycle The system cycle at which the register is being updated
*/ */
virtual void set(uInt16 addr, uInt8 value, Int32 cycle); virtual void set(uInt16 addr, uInt8 value, Int32 cycle) = 0;
/** /**
Sets the volume of the sound device to the specified level. The Sets the volume of the sound device to the specified level. The
@ -107,7 +108,7 @@ class Sound
@param percent The new volume percentage level for the sound device @param percent The new volume percentage level for the sound device
*/ */
virtual void setVolume(Int32 percent); virtual void setVolume(Int32 percent) = 0;
/** /**
Adjusts the volume of the sound device based on the given direction. Adjusts the volume of the sound device based on the given direction.
@ -115,7 +116,7 @@ class Sound
@param direction Increase or decrease the current volume by a predefined @param direction Increase or decrease the current volume by a predefined
amount based on the direction (1 = increase, -1 =decrease) amount based on the direction (1 = increase, -1 =decrease)
*/ */
virtual void adjustVolume(Int8 direction); virtual void adjustVolume(Int8 direction) = 0;
public: public:
/** /**
@ -124,7 +125,7 @@ public:
@param in The deserializer device to load from. @param in The deserializer device to load from.
@return The result of the load. True on success, false on failure. @return The result of the load. True on success, false on failure.
*/ */
virtual bool load(Deserializer& in); virtual bool load(Deserializer& in) = 0;
/** /**
Saves the current state of this device to the given Serializer. Saves the current state of this device to the given Serializer.
@ -132,20 +133,11 @@ public:
@param out The serializer device to save to. @param out The serializer device to save to.
@return The result of the save. True on success, false on failure. @return The result of the save. True on success, false on failure.
*/ */
virtual bool save(Serializer& out); virtual bool save(Serializer& out) = 0;
protected: protected:
// The OSystem for this sound object // The OSystem for this sound object
OSystem* myOSystem; OSystem* myOSystem;
// Indicates if the sound device was successfully initialized
bool myIsInitializedFlag;
// Indicates the cycle when a sound register was last set
Int32 myLastRegisterSetCycle;
// Indicates the base framerate depending on whether the ROM is NTSC or PAL
uInt32 myDisplayFrameRate;
}; };
#endif #endif

View 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: AudioDialog.cxx,v 1.2 2005-03-27 03:07:34 stephena Exp $ // $Id: AudioDialog.cxx,v 1.3 2005-04-28 19:28:33 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -45,9 +45,9 @@ AudioDialog::AudioDialog(OSystem* osystem, uInt16 x, uInt16 y, uInt16 w, uInt16
: Dialog(osystem, x, y, w, h) : Dialog(osystem, x, y, w, h)
{ {
int yoff = 10, int yoff = 10,
xoff = 10, xoff = 30,
woff = _w - 100, woff = _w - 80,
labelWidth = 70; labelWidth = 80;
// Volume // Volume
myVolumeSlider = new SliderWidget(this, xoff, yoff, woff - 14, kLineHeight, myVolumeSlider = new SliderWidget(this, xoff, yoff, woff - 14, kLineHeight,
@ -69,18 +69,17 @@ AudioDialog::AudioDialog(OSystem* osystem, uInt16 x, uInt16 y, uInt16 w, uInt16
yoff += kAudioRowHeight + 4; yoff += kAudioRowHeight + 4;
// Enable sound // Enable sound
new StaticTextWidget(this, xoff+8, yoff+3, 20, kLineHeight, new StaticTextWidget(this, xoff+8, yoff+3, 20, kLineHeight, "", kTextAlignLeft);
"(*)", kTextAlignLeft);
mySoundEnableCheckbox = new CheckboxWidget(this, xoff+28, yoff, woff - 14, kLineHeight, mySoundEnableCheckbox = new CheckboxWidget(this, xoff+28, yoff, woff - 14, kLineHeight,
"Enable sound", kSoundEnableChanged); "Enable sound", kSoundEnableChanged);
yoff += kAudioRowHeight + 12; yoff += kAudioRowHeight + 12;
// Add a short message about options that need a restart // Add a short message about options that need a restart
new StaticTextWidget(this, xoff+30, yoff, 170, kLineHeight, // new StaticTextWidget(this, xoff+30, yoff, 170, kLineHeight,
"* Note that these options take effect", kTextAlignLeft); // "* Note that these options take effect", kTextAlignLeft);
yoff += kAudioRowHeight; // yoff += kAudioRowHeight;
new StaticTextWidget(this, xoff+30, yoff, 170, kLineHeight, // new StaticTextWidget(this, xoff+30, yoff, 170, kLineHeight,
"the next time you restart Stella.", kTextAlignLeft); // "the next time you restart Stella.", kTextAlignLeft);
// Add Defaults, OK and Cancel buttons // Add Defaults, OK and Cancel buttons
addButton( 10, _h - 24, "Defaults", kDefaultsCmd, 0); addButton( 10, _h - 24, "Defaults", kDefaultsCmd, 0);
@ -132,27 +131,36 @@ void AudioDialog::saveConfig()
{ {
string s; string s;
uInt32 i; uInt32 i;
bool b; bool b, restart = false;
// Volume // Volume
i = myVolumeSlider->getValue(); i = myVolumeSlider->getValue();
instance()->settings().setInt("volume", i);
instance()->sound().setVolume(i); instance()->sound().setVolume(i);
// Fragsize // Fragsize (requires a restart to take effect)
// This one requires a complete re-initialization of the sound subsystem,
// so we only do it if the fragsize really has changed
i = 1; i = 1;
i <<= (myFragsizePopup->getSelectedTag() + 7); i <<= (myFragsizePopup->getSelectedTag() + 7);
if(instance()->settings().getInt("fragsize") != (Int32)i) if(instance()->settings().getInt("fragsize") != (Int32)i)
{ {
instance()->settings().setInt("fragsize", i); instance()->settings().setInt("fragsize", i);
instance()->sound().initialize(true); // force a re-initialization restart = true;
} }
// Enable sound (requires a restart to take effect) // FIXME - let this work without a restart // Enable/disable sound (requires a restart to take effect)
b = mySoundEnableCheckbox->getState(); b = mySoundEnableCheckbox->getState();
instance()->settings().setBool("sound", b); if(instance()->settings().getBool("sound") != b)
{
instance()->sound().setEnabled(b);
restart = true;
}
// Only force a re-initialization when necessary, since it can
// be a time-consuming operation
if(restart)
{
instance()->sound().initialize(true);
instance()->sound().mute(true);
}
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -161,6 +169,7 @@ void AudioDialog::setDefaults()
myVolumeSlider->setValue(100); myVolumeSlider->setValue(100);
myVolumeLabel->setLabel("100"); myVolumeLabel->setLabel("100");
// FIXME - get defaults from OSystem or Settings
#ifdef WIN32 #ifdef WIN32
myFragsizePopup->setSelectedTag(4); myFragsizePopup->setSelectedTag(4);
#else #else

View 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: GameInfoDialog.cxx,v 1.1 2005-03-27 03:07:34 stephena Exp $ // $Id: GameInfoDialog.cxx,v 1.2 2005-04-28 19:28:33 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -45,7 +45,7 @@ GameInfoDialog::GameInfoDialog(OSystem* osystem, uInt16 x, uInt16 y, uInt16 w, u
for(uInt8 i = 0; i < LINES_PER_PAGE; i++) for(uInt8 i = 0; i < LINES_PER_PAGE; i++)
{ {
myKey[i] = new StaticTextWidget(this, 10, 18 + (10 * i), 80, 16, "", kTextAlignLeft); myKey[i] = new StaticTextWidget(this, 10, 18 + (10 * i), 80, 16, "", kTextAlignLeft);
myDesc[i] = new StaticTextWidget(this, 90, 18 + (10 * i), 210, 16, "", kTextAlignLeft); myDesc[i] = new StaticTextWidget(this, 90, 18 + (10 * i), 160, 16, "", kTextAlignLeft);
} }
displayInfo(); displayInfo();

View 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: HelpDialog.cxx,v 1.1 2005-03-27 03:07:34 stephena Exp $ // $Id: HelpDialog.cxx,v 1.2 2005-04-28 19:28:33 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -44,7 +44,7 @@ HelpDialog::HelpDialog(OSystem* osystem, uInt16 x, uInt16 y, uInt16 w, uInt16 h)
for(uInt8 i = 0; i < LINES_PER_PAGE; i++) for(uInt8 i = 0; i < LINES_PER_PAGE; i++)
{ {
myKey[i] = new StaticTextWidget(this, 10, 18 + (10 * i), 80, 16, "", kTextAlignLeft); myKey[i] = new StaticTextWidget(this, 10, 18 + (10 * i), 80, 16, "", kTextAlignLeft);
myDesc[i] = new StaticTextWidget(this, 90, 18 + (10 * i), 210, 16, "", kTextAlignLeft); myDesc[i] = new StaticTextWidget(this, 90, 18 + (10 * i), 160, 16, "", kTextAlignLeft);
} }
displayInfo(); displayInfo();

View 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: OptionsDialog.cxx,v 1.10 2005-04-05 00:40:55 stephena Exp $ // $Id: OptionsDialog.cxx,v 1.11 2005-04-28 19:28:33 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -78,11 +78,11 @@ OptionsDialog::OptionsDialog(OSystem* osystem)
uInt16 x, y, w, h; uInt16 x, y, w, h;
// Now create all the dialogs attached to each menu button // Now create all the dialogs attached to each menu button
w = 250; h = 150; w = 230; h = 150;
checkBounds(fbWidth, fbHeight, &x, &y, &w, &h); checkBounds(fbWidth, fbHeight, &x, &y, &w, &h);
myVideoDialog = new VideoDialog(myOSystem, x, y, w, h); myVideoDialog = new VideoDialog(myOSystem, x, y, w, h);
w = 220; h = 120; w = 200; h = 100;
checkBounds(fbWidth, fbHeight, &x, &y, &w, &h); checkBounds(fbWidth, fbHeight, &x, &y, &w, &h);
myAudioDialog = new AudioDialog(myOSystem, x, y, w, h); myAudioDialog = new AudioDialog(myOSystem, x, y, w, h);

View 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: VideoDialog.cxx,v 1.5 2005-03-27 03:07:34 stephena Exp $ // $Id: VideoDialog.cxx,v 1.6 2005-04-28 19:28:33 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -45,8 +45,8 @@ VideoDialog::VideoDialog(OSystem* osystem, uInt16 x, uInt16 y, uInt16 w, uInt16
{ {
int yoff = 10, int yoff = 10,
xoff = 2, xoff = 2,
woff = _w - 130, woff = 110,
labelWidth = 65; labelWidth = 55;
// Video driver (query OSystem for what's supported) // Video driver (query OSystem for what's supported)
myDriverPopup = new PopUpWidget(this, xoff, yoff, woff, kLineHeight, myDriverPopup = new PopUpWidget(this, xoff, yoff, woff, kLineHeight,
@ -61,9 +61,11 @@ VideoDialog::VideoDialog(OSystem* osystem, uInt16 x, uInt16 y, uInt16 w, uInt16
// _langPopUp->appendEntry(l->description, l->id); // _langPopUp->appendEntry(l->description, l->id);
// } // }
// FIXME - get list of renderers from OSystem
// Also, make these options work without requiring a restart
// Video renderer // Video renderer
myRendererPopup = new PopUpWidget(this, xoff, yoff, woff, kLineHeight, myRendererPopup = new PopUpWidget(this, xoff, yoff, woff, kLineHeight,
"(*)Renderer: ", labelWidth, kRendererChanged); "Renderer: ", labelWidth, kRendererChanged);
myRendererPopup->appendEntry("Software", 1); myRendererPopup->appendEntry("Software", 1);
myRendererPopup->appendEntry("OpenGL", 2); myRendererPopup->appendEntry("OpenGL", 2);
yoff += kVideoRowHeight + 4; yoff += kVideoRowHeight + 4;
@ -77,9 +79,9 @@ VideoDialog::VideoDialog(OSystem* osystem, uInt16 x, uInt16 y, uInt16 w, uInt16
// Aspect ratio // Aspect ratio
myAspectRatioSlider = new SliderWidget(this, xoff, yoff, woff - 14, kLineHeight, myAspectRatioSlider = new SliderWidget(this, xoff, yoff, woff - 14, kLineHeight,
"(*)GL Aspect: ", labelWidth, kAspectRatioChanged); "GL Aspect: ", labelWidth, kAspectRatioChanged);
myAspectRatioSlider->setMinValue(1); myAspectRatioSlider->setMaxValue(100); myAspectRatioSlider->setMinValue(1); myAspectRatioSlider->setMaxValue(100);
myAspectRatioLabel = new StaticTextWidget(this, xoff + woff - 11, yoff, 24, kLineHeight, myAspectRatioLabel = new StaticTextWidget(this, xoff + woff - 11, yoff, 15, kLineHeight,
"", kTextAlignLeft); "", kTextAlignLeft);
myAspectRatioLabel->setFlags(WIDGET_CLEARBG); myAspectRatioLabel->setFlags(WIDGET_CLEARBG);
yoff += kVideoRowHeight + 4; yoff += kVideoRowHeight + 4;
@ -96,36 +98,36 @@ VideoDialog::VideoDialog(OSystem* osystem, uInt16 x, uInt16 y, uInt16 w, uInt16
xoff = xoff + 115; xoff = xoff + 115;
// Framerate // Framerate
myFrameRateSlider = new SliderWidget(this, xoff, yoff, woff - 14, kLineHeight, myFrameRateSlider = new SliderWidget(this, xoff, yoff, woff - 25, kLineHeight,
"Framerate: ", labelWidth, kFrameRateChanged); "Framerate: ", labelWidth, kFrameRateChanged);
myFrameRateSlider->setMinValue(1); myFrameRateSlider->setMaxValue(300); myFrameRateSlider->setMinValue(1); myFrameRateSlider->setMaxValue(300);
myFrameRateLabel = new StaticTextWidget(this, xoff + woff - 11, yoff, 20, kLineHeight, myFrameRateLabel = new StaticTextWidget(this, xoff + woff - 22, yoff, 20, kLineHeight,
"", kTextAlignLeft); "", kTextAlignLeft);
myFrameRateLabel->setFlags(WIDGET_CLEARBG); myFrameRateLabel->setFlags(WIDGET_CLEARBG);
yoff += kVideoRowHeight + 4; yoff += kVideoRowHeight + 4;
// Zoom level // Zoom level
myZoomSlider = new SliderWidget(this, xoff, yoff, woff - 14, kLineHeight, myZoomSlider = new SliderWidget(this, xoff, yoff, woff - 25, kLineHeight,
"Zoom: ", labelWidth, kZoomChanged); "Zoom: ", labelWidth, kZoomChanged);
myZoomSlider->setMinValue(0); myZoomSlider->setMaxValue(50); myZoomSlider->setMinValue(0); myZoomSlider->setMaxValue(50);
myZoomLabel = new StaticTextWidget(this, xoff + woff - 11, yoff, 20, kLineHeight, myZoomLabel = new StaticTextWidget(this, xoff + woff - 22, yoff, 20, kLineHeight,
"", kTextAlignLeft); "", kTextAlignLeft);
myZoomLabel->setFlags(WIDGET_CLEARBG); myZoomLabel->setFlags(WIDGET_CLEARBG);
yoff += kVideoRowHeight + 10; yoff += kVideoRowHeight + 10;
myFullscreenCheckbox = new CheckboxWidget(this, xoff + 25, yoff, woff - 14, kLineHeight, myFullscreenCheckbox = new CheckboxWidget(this, xoff + 5, yoff, woff - 14, kLineHeight,
"Fullscreen mode"); "Fullscreen mode");
yoff += kVideoRowHeight + 4; yoff += kVideoRowHeight + 4;
myUseDeskResCheckbox = new CheckboxWidget(this, xoff + 25, yoff, woff - 14, kLineHeight, myUseDeskResCheckbox = new CheckboxWidget(this, xoff + 5, yoff, woff - 14, kLineHeight,
"Desktop Res in FS"); "Desktop Res in FS");
yoff += kVideoRowHeight + 20; yoff += kVideoRowHeight + 20;
// Add a short message about options that need a restart // Add a short message about options that need a restart
new StaticTextWidget(this, xoff-40, yoff, 170, kLineHeight, new StaticTextWidget(this, _w - 175, yoff, 170, kLineHeight,
"* Note that these options take effect", kTextAlignLeft); "* Note that these options take effect", kTextAlignLeft);
yoff += kVideoRowHeight; yoff += kVideoRowHeight;
new StaticTextWidget(this, xoff-40, yoff, 170, kLineHeight, new StaticTextWidget(this, _w - 175, yoff, 170, kLineHeight,
"the next time you restart Stella.", kTextAlignLeft); "the next time you restart Stella.", kTextAlignLeft);
// Add Defaults, OK and Cancel buttons // Add Defaults, OK and Cancel buttons