Pass sound reference directly into the TIA class, eliminating the use

of pointers.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1657 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2009-01-24 18:17:34 +00:00
parent 771108ad3b
commit dec6efccdd
3 changed files with 23 additions and 34 deletions

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: Console.cxx,v 1.155 2009-01-24 18:11:47 stephena Exp $
// $Id: Console.cxx,v 1.156 2009-01-24 18:17:34 stephena Exp $
//============================================================================
#include <cassert>
@ -108,8 +108,7 @@ Console::Console(OSystem* osystem, Cartridge* cart, const Properties& props)
myCart = cart;
myRiot = new M6532(*this);
myTIA = new TIA(*this, myOSystem->settings());
myTIA->setSound(myOSystem->sound());
myTIA = new TIA(*this, myOSystem->sound(), myOSystem->settings());
mySystem->attach(m6502);
mySystem->attach(myRiot);

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: TIA.cxx,v 1.102 2009-01-19 16:57:54 stephena Exp $
// $Id: TIA.cxx,v 1.103 2009-01-24 18:17:34 stephena Exp $
//============================================================================
//#define DEBUG_HMOVE
@ -40,10 +40,10 @@
#define HBLANK 68
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TIA::TIA(Console& console, Settings& settings)
TIA::TIA(Console& console, Sound& sound, Settings& settings)
: myConsole(console),
mySound(sound),
mySettings(settings),
mySound(NULL),
myMaximumNumberOfScanlines(262),
myCOLUBK(myColor[0]),
myCOLUPF(myColor[1]),
@ -117,7 +117,7 @@ TIA::~TIA()
void TIA::reset()
{
// Reset the sound device
mySound->reset();
mySound.reset();
// Currently no objects are enabled
myEnabledObjects = 0;
@ -228,7 +228,7 @@ void TIA::systemCyclesReset()
uInt32 cycles = mySystem->cycles();
// Adjust the sound cycle indicator
mySound->adjustCycleCounter(-1 * cycles);
mySound.adjustCycleCounter(-1 * cycles);
// Adjust the dump cycle
myDumpDisabledCycle -= cycles;
@ -357,7 +357,7 @@ bool TIA::save(Serializer& out) const
out.putInt(myDumpDisabledCycle);
// Save the sound sample stuff ...
mySound->save(out);
mySound.save(out);
}
catch(char *msg)
{
@ -454,7 +454,7 @@ bool TIA::load(Deserializer& in)
myDumpDisabledCycle = (Int32) in.getInt();
// Load the sound sample stuff ...
mySound->load(in);
mySound.load(in);
// Reset TIA bits to be on
enableBits(true);
@ -670,12 +670,6 @@ void TIA::updateScanlineByTrace(int target)
}
#endif
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TIA::setSound(Sound& sound)
{
mySound = &sound;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
inline void TIA::updateFrameScanline(uInt32 clocksToUpdate, uInt32 hpos)
{
@ -2032,42 +2026,42 @@ void TIA::poke(uInt16 addr, uInt8 value)
case AUDC0: // Audio control 0
{
myAUDC0 = value & 0x0f;
mySound->set(addr, value, mySystem->cycles());
mySound.set(addr, value, mySystem->cycles());
break;
}
case AUDC1: // Audio control 1
{
myAUDC1 = value & 0x0f;
mySound->set(addr, value, mySystem->cycles());
mySound.set(addr, value, mySystem->cycles());
break;
}
case AUDF0: // Audio frequency 0
{
myAUDF0 = value & 0x1f;
mySound->set(addr, value, mySystem->cycles());
mySound.set(addr, value, mySystem->cycles());
break;
}
case AUDF1: // Audio frequency 1
{
myAUDF1 = value & 0x1f;
mySound->set(addr, value, mySystem->cycles());
mySound.set(addr, value, mySystem->cycles());
break;
}
case AUDV0: // Audio volume 0
{
myAUDV0 = value & 0x0f;
mySound->set(addr, value, mySystem->cycles());
mySound.set(addr, value, mySystem->cycles());
break;
}
case AUDV1: // Audio volume 1
{
myAUDV1 = value & 0x0f;
mySound->set(addr, value, mySystem->cycles());
mySound.set(addr, value, mySystem->cycles());
break;
}
@ -2400,8 +2394,8 @@ void TIA::poke(uInt16 addr, uInt8 value)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TIA::TIA(const TIA& c)
: myConsole(c.myConsole),
mySettings(c.mySettings),
mySound(c.mySound),
mySettings(c.mySettings),
myCOLUBK(myColor[0]),
myCOLUPF(myColor[1]),
myCOLUP0(myColor[2]),

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: TIA.hxx,v 1.51 2009-01-19 16:52:32 stephena Exp $
// $Id: TIA.hxx,v 1.52 2009-01-24 18:17:34 stephena Exp $
//============================================================================
#ifndef TIA_HXX
@ -39,7 +39,7 @@ class Settings;
be displayed on screen.
@author Bradford W. Mott
@version $Id: TIA.hxx,v 1.51 2009-01-19 16:52:32 stephena Exp $
@version $Id: TIA.hxx,v 1.52 2009-01-24 18:17:34 stephena Exp $
*/
class TIA : public Device
{
@ -50,9 +50,10 @@ class TIA : public Device
Create a new TIA for the specified console
@param console The console the TIA is associated with
@param sound The sound object the TIA is associated with
@param settings The settings object for this TIA device
*/
TIA(Console& console, Settings& settings);
TIA(Console& console, Sound& sound, Settings& settings);
/**
Destructor
@ -187,11 +188,6 @@ class TIA : public Device
inline uInt32 scanlines() const
{ return ((mySystem->cycles() * 3) - myClockWhenFrameStarted) / 228; }
/**
Sets the sound device for the TIA.
*/
void setSound(Sound& sound);
enum TIABit {
P0, // Descriptor for Player 0 Bit
P1, // Descriptor for Player 1 Bit
@ -272,12 +268,12 @@ class TIA : public Device
// Console the TIA is associated with
Console& myConsole;
// Sound object the TIA is associated with
Sound& mySound;
// Settings object the TIA is associated with
Settings& mySettings;
// Sound object the TIA is associated with
Sound* mySound;
// Pointer to the current frame buffer
uInt8* myCurrentFrameBuffer;