mirror of https://github.com/stella-emu/stella.git
Updated the Sound class so it has a new set method which also takes as an
argument the number of CPU cycles elapsed since the last TIA sound update. The default implementation of this method invokes the old set method for backwards compatibility with derived classes. This new set method will be used in the 1.3 release to improve the quality of the sound emulation (e.g., to support games like Pitfall II which update the sound registers many times during a frame). The TIA class was updated to invoke the new set method of the Sound class. Finally, the TIA pauseState data member was renamed to myPauseState to be consistent with the other data members. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@55 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
e24dd2c994
commit
36ed979ece
|
@ -8,12 +8,12 @@
|
|||
// SS SS tt ee ll ll aa aa
|
||||
// SSSS ttt eeeee llll llll aaaaa
|
||||
//
|
||||
// Copyright (c) 1995-1998 by Bradford W. Mott
|
||||
// Copyright (c) 1995-2002 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.1.1.1 2001-12-27 19:54:23 bwmott Exp $
|
||||
// $Id: Sound.cxx,v 1.2 2002-03-28 02:02:24 bwmott Exp $
|
||||
//============================================================================
|
||||
|
||||
#include "Sound.hxx"
|
||||
|
@ -29,7 +29,15 @@ Sound::~Sound()
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Sound::set(Sound::Register, uInt8)
|
||||
void Sound::set(Sound::Register r, uInt8 v, uInt32)
|
||||
{
|
||||
// For backwards compatibility we invoke the two argument version of this
|
||||
// method. This should keep all of the old derived sound classes happy.
|
||||
set(r, v);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Sound::set(Sound::Register r, uInt8 v)
|
||||
{
|
||||
// This sound class doesn't do anything when a register is set
|
||||
// since we're not handling sound
|
||||
|
|
|
@ -8,12 +8,12 @@
|
|||
// SS SS tt ee ll ll aa aa
|
||||
// SSSS ttt eeeee llll llll aaaaa
|
||||
//
|
||||
// Copyright (c) 1995-1998 by Bradford W. Mott
|
||||
// Copyright (c) 1995-2002 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.hxx,v 1.1.1.1 2001-12-27 19:54:23 bwmott Exp $
|
||||
// $Id: Sound.hxx,v 1.2 2002-03-28 02:02:24 bwmott Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef SOUND_HXX
|
||||
|
@ -27,7 +27,7 @@
|
|||
for a specific operating system.
|
||||
|
||||
@author Bradford W. Mott
|
||||
@version $Id: Sound.hxx,v 1.1.1.1 2001-12-27 19:54:23 bwmott Exp $
|
||||
@version $Id: Sound.hxx,v 1.2 2002-03-28 02:02:24 bwmott Exp $
|
||||
*/
|
||||
class Sound
|
||||
{
|
||||
|
@ -53,8 +53,19 @@ class Sound
|
|||
|
||||
public:
|
||||
/**
|
||||
Set the value of the specified sound register
|
||||
Set the value of the specified sound register.
|
||||
|
||||
@param reg The sound register to set
|
||||
@param val The new value for the sound register
|
||||
@param cycles The number of elapsed CPU cycles since the last set
|
||||
*/
|
||||
virtual void set(Sound::Register reg, uInt8 val, uInt32 cycles);
|
||||
|
||||
/**
|
||||
Set the value of the specified sound register. This method is being
|
||||
kept for backwards compatibility. There's a good chance it will be
|
||||
removed in the 1.3 release of Stella as the sound system is overhauled.
|
||||
|
||||
@param reg The sound register to set
|
||||
@param val The new value for the sound register
|
||||
*/
|
||||
|
|
|
@ -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.8 2002-03-18 14:38:34 gunfight Exp $
|
||||
// $Id: TIA.cxx,v 1.9 2002-03-28 02:02:24 bwmott Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <assert.h>
|
||||
|
@ -31,13 +31,14 @@
|
|||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
TIA::TIA(const Console& console, Sound& sound)
|
||||
: myConsole(console)
|
||||
,mySound(sound)
|
||||
,myCOLUBK(myColor[0])
|
||||
,myCOLUPF(myColor[1])
|
||||
,myCOLUP0(myColor[2])
|
||||
,myCOLUP1(myColor[3])
|
||||
,pauseState(false)
|
||||
: myConsole(console),
|
||||
mySound(sound),
|
||||
myPauseState(false),
|
||||
myLastSoundUpdateCycle(0),
|
||||
myCOLUBK(myColor[0]),
|
||||
myCOLUPF(myColor[1]),
|
||||
myCOLUP0(myColor[2]),
|
||||
myCOLUP1(myColor[3])
|
||||
{
|
||||
// Allocate buffers for two frame buffers
|
||||
myCurrentFrameBuffer = new uInt8[160 * 300];
|
||||
|
@ -111,6 +112,9 @@ const char* TIA::name() const
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void TIA::reset()
|
||||
{
|
||||
// Reset sound cycle indicator
|
||||
myLastSoundUpdateCycle = 0;
|
||||
|
||||
// Clear frame buffers
|
||||
for(uInt32 i = 0; i < 160 * 300; ++i)
|
||||
{
|
||||
|
@ -219,6 +223,9 @@ void TIA::systemCyclesReset()
|
|||
// Get the current system cycle
|
||||
uInt32 cycles = mySystem->cycles();
|
||||
|
||||
// Adjust the sound cycle indicator
|
||||
myLastSoundUpdateCycle -= cycles;
|
||||
|
||||
// Adjust the dump cycle
|
||||
myDumpDisabledCycle -= cycles;
|
||||
|
||||
|
@ -264,8 +271,10 @@ void TIA::install(System& system)
|
|||
void TIA::update()
|
||||
{
|
||||
// Don't do an update if the emulator is paused
|
||||
if(pauseState)
|
||||
if(myPauseState)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
uInt8* tmp = myCurrentFrameBuffer;
|
||||
myCurrentFrameBuffer = myPreviousFrameBuffer;
|
||||
|
@ -303,16 +312,20 @@ void TIA::update()
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool TIA::pause(bool state)
|
||||
{
|
||||
// Ignore multiple calls to do the same thing
|
||||
if(pauseState == state)
|
||||
if(myPauseState == state)
|
||||
{
|
||||
// Ignore multiple calls to do the same thing
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
myPauseState = state;
|
||||
|
||||
pauseState = state;
|
||||
// Propagate the pause state to the sound object
|
||||
mySound.mute(myPauseState);
|
||||
|
||||
// Now pause the Sound device
|
||||
mySound.mute(pauseState);
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -2079,37 +2092,49 @@ void TIA::poke(uInt16 addr, uInt8 value)
|
|||
|
||||
case 0x15: // Audio control 0
|
||||
{
|
||||
mySound.set(Sound::AUDC0, value);
|
||||
mySound.set(Sound::AUDC0, value,
|
||||
mySystem->cycles() - myLastSoundUpdateCycle);
|
||||
myLastSoundUpdateCycle = mySystem->cycles();
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x16: // Audio control 1
|
||||
{
|
||||
mySound.set(Sound::AUDC1, value);
|
||||
mySound.set(Sound::AUDC1, value,
|
||||
mySystem->cycles() - myLastSoundUpdateCycle);
|
||||
myLastSoundUpdateCycle = mySystem->cycles();
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x17: // Audio frequency 0
|
||||
{
|
||||
mySound.set(Sound::AUDF0, value);
|
||||
mySound.set(Sound::AUDF0, value,
|
||||
mySystem->cycles() - myLastSoundUpdateCycle);
|
||||
myLastSoundUpdateCycle = mySystem->cycles();
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x18: // Audio frequency 1
|
||||
{
|
||||
mySound.set(Sound::AUDF1, value);
|
||||
mySound.set(Sound::AUDF1, value,
|
||||
mySystem->cycles() - myLastSoundUpdateCycle);
|
||||
myLastSoundUpdateCycle = mySystem->cycles();
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x19: // Audio volume 0
|
||||
{
|
||||
mySound.set(Sound::AUDV0, value);
|
||||
mySound.set(Sound::AUDV0, value,
|
||||
mySystem->cycles() - myLastSoundUpdateCycle);
|
||||
myLastSoundUpdateCycle = mySystem->cycles();
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x1A: // Audio volume 1
|
||||
{
|
||||
mySound.set(Sound::AUDV1, value);
|
||||
mySound.set(Sound::AUDV1, value,
|
||||
mySystem->cycles() - myLastSoundUpdateCycle);
|
||||
myLastSoundUpdateCycle = mySystem->cycles();
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -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.2 2002-03-17 19:37:00 stephena Exp $
|
||||
// $Id: TIA.hxx,v 1.3 2002-03-28 02:02:24 bwmott Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef TIA_HXX
|
||||
|
@ -38,7 +38,7 @@ class System;
|
|||
be displayed on screen.
|
||||
|
||||
@author Bradford W. Mott
|
||||
@version $Id: TIA.hxx,v 1.2 2002-03-17 19:37:00 stephena Exp $
|
||||
@version $Id: TIA.hxx,v 1.3 2002-03-28 02:02:24 bwmott Exp $
|
||||
*/
|
||||
class TIA : public Device , public MediaSource
|
||||
{
|
||||
|
@ -197,6 +197,13 @@ class TIA : public Device , public MediaSource
|
|||
// Sound object used by the TIA
|
||||
Sound& mySound;
|
||||
|
||||
// Indicates whether the emulation is paused or not
|
||||
bool myPauseState;
|
||||
|
||||
private:
|
||||
// Indicates the CPU cycle when a TIA sound register was last updated
|
||||
Int32 myLastSoundUpdateCycle;
|
||||
|
||||
private:
|
||||
// Pointer to the current frame buffer
|
||||
uInt8* myCurrentFrameBuffer;
|
||||
|
@ -426,8 +433,5 @@ class TIA : public Device , public MediaSource
|
|||
|
||||
// Assignment operator isn't supported by this class so make it private
|
||||
TIA& operator = (const TIA&);
|
||||
|
||||
// Indicates whether the current emulation cycle should is paused
|
||||
bool pauseState;
|
||||
};
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue