Forgot to include these new files in the last commit. The SoundNull

class is used when compiling Stella without any sound support whatsoever.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@400 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2005-04-28 19:30:27 +00:00
parent c8fd06bc69
commit 56c69d428a
3 changed files with 229 additions and 136 deletions

View File

@ -0,0 +1,83 @@
//============================================================================
//
// 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-2004 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: SoundNull.cxx,v 1.1 2005-04-28 19:30:26 stephena Exp $
//============================================================================
#include "Serializer.hxx"
#include "Deserializer.hxx"
#include "bspf.hxx"
#include "OSystem.hxx"
#include "Settings.hxx"
#include "SoundNull.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SoundNull::SoundNull(OSystem* osystem)
: Sound(osystem)
{
// Add the sound object to the system
myOSystem->attach(this);
// Show some info
if(myOSystem->settings().getBool("showinfo"))
cout << "Sound support not available." << endl << endl;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SoundNull::~SoundNull()
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool SoundNull::load(Deserializer& in)
{
string soundDevice = "TIASound";
if(in.getString() != soundDevice)
return false;
uInt8 reg;
reg = (uInt8) in.getLong();
reg = (uInt8) in.getLong();
reg = (uInt8) in.getLong();
reg = (uInt8) in.getLong();
reg = (uInt8) in.getLong();
reg = (uInt8) in.getLong();
// myLastRegisterSetCycle
in.getLong();
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool SoundNull::save(Serializer& out)
{
out.putString("TIASound");
uInt8 reg = 0;
out.putLong(reg);
out.putLong(reg);
out.putLong(reg);
out.putLong(reg);
out.putLong(reg);
out.putLong(reg);
// myLastRegisterSetCycle
out.putLong(0);
return true;
}

View File

@ -0,0 +1,146 @@
//============================================================================
//
// 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-2005 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: SoundNull.hxx,v 1.1 2005-04-28 19:30:26 stephena Exp $
//============================================================================
#ifndef SOUND_NULL_HXX
#define SOUND_NULL_HXX
class OSystem;
class Serializer;
class Deserializer;
#include "bspf.hxx"
#include "Sound.hxx"
/**
This class implements a Null sound object, where-by sound generation
is completely disabled.
@author Stephen Anthony
@version $Id: SoundNull.hxx,v 1.1 2005-04-28 19:30:26 stephena Exp $
*/
class SoundNull : public Sound
{
public:
/**
Create a new sound object. The init method must be invoked before
using the object.
*/
SoundNull(OSystem* osystem);
/**
Destructor
*/
virtual ~SoundNull();
public:
/**
Enables/disables the sound subsystem.
@param enable Either true or false, to enable or disable the sound system
@return Whether the sound system was enabled or disabled
*/
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
calls are made to derived methods.
@param forcerestart Do a soft or hard reset of the sound subsystem
*/
void initialize(bool forcerestart = false) { }
/**
Return true iff the sound device was successfully initialized.
@return true iff the sound device was successfully initialized.
*/
bool isSuccessfullyInitialized() const { return false; }
/**
Set the mute state of the sound object. While muted no sound is played.
@param state Mutes sound if true, unmute if false
*/
void mute(bool state) { }
/**
Reset the sound device.
*/
void reset() { }
/**
Sets the sound register to a given value.
@param addr The register address
@param value The value to save into the register
@param cycle The system cycle at which the register is being updated
*/
void set(uInt16 addr, uInt8 value, Int32 cycle) { }
/**
Sets the volume of the sound device to the specified level. The
volume is given as a percentage from 0 to 100. Values outside
this range indicate that the volume shouldn't be changed at all.
@param percent The new volume percentage level for the sound device
*/
void setVolume(Int32 percent) { }
/**
Adjusts the volume of the sound device based on the given direction.
@param direction Increase or decrease the current volume by a predefined
amount based on the direction (1 = increase, -1 =decrease)
*/
void adjustVolume(Int8 direction) { }
public:
/**
Loads the current state of this device from the given Deserializer.
@param in The deserializer device to load from.
@return The result of the load. True on success, false on failure.
*/
bool load(Deserializer& in);
/**
Saves the current state of this device to the given Serializer.
@param out The serializer device to save to.
@return The result of the save. True on success, false on failure.
*/
bool save(Serializer& out);
};
#endif

View File

@ -1,136 +0,0 @@
//============================================================================
//
// 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-2004 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: Sound.cxx,v 1.18 2005-03-26 19:26:47 stephena Exp $
//============================================================================
#include "Serializer.hxx"
#include "Deserializer.hxx"
#include "bspf.hxx"
#include "OSystem.hxx"
#include "Settings.hxx"
#include "Sound.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Sound::Sound(OSystem* osystem)
: myOSystem(osystem),
myIsInitializedFlag(false),
myLastRegisterSetCycle(0)
{
// Add the sound object to the system
myOSystem->attach(this);
// Show some info
if(myOSystem->settings().getBool("showinfo") &&
!myOSystem->settings().getBool("sound"))
cout << "Sound disabled." << endl << endl;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Sound::~Sound()
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Sound::adjustCycleCounter(Int32 amount)
{
myLastRegisterSetCycle += amount;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Sound::setFrameRate(uInt32 framerate)
{
myDisplayFrameRate = framerate;
myLastRegisterSetCycle = 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Sound::mute(bool state)
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Sound::initialize(bool forcerestart)
{
myLastRegisterSetCycle = 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Sound::isSuccessfullyInitialized() const
{
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Sound::reset()
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Sound::set(uInt16 addr, uInt8 value, Int32 cycle)
{
myLastRegisterSetCycle = cycle;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Sound::setVolume(Int32 volume)
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Sound::adjustVolume(Int8 direction)
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Sound::load(Deserializer& in)
{
string soundDevice = "TIASound";
if(in.getString() != soundDevice)
return false;
uInt8 reg;
reg = (uInt8) in.getLong();
reg = (uInt8) in.getLong();
reg = (uInt8) in.getLong();
reg = (uInt8) in.getLong();
reg = (uInt8) in.getLong();
reg = (uInt8) in.getLong();
myLastRegisterSetCycle = (Int32)in.getLong();
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Sound::save(Serializer& out)
{
out.putString("TIASound");
uInt8 reg = 0;
out.putLong(reg);
out.putLong(reg);
out.putLong(reg);
out.putLong(reg);
out.putLong(reg);
out.putLong(reg);
out.putLong(myLastRegisterSetCycle);
return true;
}