diff --git a/source/sound/cdxa.cpp b/source/sound/cdxa.cpp index 86162227e..c6a790b3f 100644 --- a/source/sound/cdxa.cpp +++ b/source/sound/cdxa.cpp @@ -12,9 +12,9 @@ #include #include -#ifndef __SOUND_SNDBANK_H__ -#include "sound\sndbank.h" -#endif +//#ifndef __SOUND_SNDBANK_H__ +//#include "sound\sndbank.h" +//#endif // Add this to have CDXA on PC build!! @@ -292,15 +292,15 @@ void CXAStream::SetVolume(s32 LVol,s32 RVol) { CdlATV CDVol; SpuCommonAttr Attr; -int VolumeSetting; - - if (CurrentStream==XA_STREAM_SPEECH) - VolumeSetting=CSfxFactory::SNDVOL_SFX; - else - VolumeSetting=CSfxFactory::SNDVOL_MUSIC; - - LVol=(LVol*CSfxFactory::getVolumeLevel(VolumeSetting))/256; - RVol=(RVol*CSfxFactory::getVolumeLevel(VolumeSetting))/256; +//int VolumeSetting; +// +// if (CurrentStream==XA_STREAM_SPEECH) +// VolumeSetting=CSfxFactory::SNDVOL_SFX; +// else +// VolumeSetting=CSfxFactory::SNDVOL_MUSIC; +// +// LVol=(LVol*CSfxFactory::getVolumeLevel(VolumeSetting))/256; +// RVol=(RVol*CSfxFactory::getVolumeLevel(VolumeSetting))/256; Attr.mask = (SPU_COMMON_CDVOLL|SPU_COMMON_CDVOLR|SPU_COMMON_CDMIX); Attr.cd.volume.left =LVol; Attr.cd.volume.right=RVol; diff --git a/source/system/clickcount.cpp b/source/system/clickcount.cpp new file mode 100644 index 000000000..260183a0a --- /dev/null +++ b/source/system/clickcount.cpp @@ -0,0 +1,100 @@ +/******************/ +/*** PSX Timer ***/ +/******************/ + + +#include + +#include "system\global.h" +#include "system\clickcount.h" +#include "system/gp.h" + + +/*****************************************************************************/ +u32 CClickCount::s_currentTime=0; +bool CClickCount::s_initialised=false; +bool CClickCount::s_paused=false; + +static const int COUNT_DOWN_VAL = 17200;//2150; +static const int COUNTS_PER_FRAME_INTERNAL = 4; +static const int COUNTS_PER_FRAME_EXTERNAL = 4096; + +/*****************************************************************************/ +void clockTicker() +{ + u32 thisGp; + thisGp=ReloadGP(); + + CClickCount::updateCurrentTime(); + SetGP(thisGp); +} + +/*****************************************************************************/ +u32 CClickCount::timeSinceLast() +{ + if (!s_initialised) + { + initialise(); + m_lastTime=getCurrentTime(); + s_initialised=true; + } + + u32 timeSince; + u32 currentTime; + u32 lastTime; + + lastTime=m_lastTime; + currentTime=getCurrentTime(); + timeSince=currentTime-m_lastTime; + + m_lastTime=currentTime; + return((timeSince*COUNTS_PER_FRAME_EXTERNAL)/COUNTS_PER_FRAME_INTERNAL); + return(currentTime*4096); +} + +/*****************************************************************************/ +void CClickCount::initialise() +{ + unsigned long eventHandle; + + // set up variables and environment + + EnterCriticalSection(); + eventHandle = OpenEvent( RCntCNT2, EvSpINT, EvMdINTR,(long (*)(...)) clockTicker); + EnableEvent( eventHandle ); +// SetRCnt( RCntCNT2, COUNT_DOWN_VAL, RCntMdINTR|RCntMdSP); + SetRCnt( RCntCNT2, COUNT_DOWN_VAL, RCntMdINTR); + StartRCnt( RCntCNT2 ); + ExitCriticalSection(); +} + +/*****************************************************************************/ +u32 CClickCount::getCurrentTime() +{ + return(s_currentTime); +} + +/*****************************************************************************/ +void CClickCount::pauseClickCount() +{ + ASSERT(!s_paused); + s_paused = true; +} + +/*****************************************************************************/ +void CClickCount::restartClickCount() +{ + ASSERT(s_paused); + s_paused = false; +} + +/*****************************************************************************/ +void CClickCount::updateCurrentTime() +{ + if (!s_paused) + { + s_currentTime++; + } + +} + diff --git a/source/system/clickcount.h b/source/system/clickcount.h new file mode 100644 index 000000000..e9e301e39 --- /dev/null +++ b/source/system/clickcount.h @@ -0,0 +1,35 @@ +/******************/ +/*** PSX Timer ***/ +/******************/ + +#ifndef __SYSTEM_CLICKCOUNT_H__ +#define __SYSTEM_CLICKCOUNT_H__ + +/*****************************************************************************/ +class CClickCount +{ +private: + u32 m_lastTime; + + static u32 s_currentTime; + static bool s_initialised; + static bool s_paused; + + static u32 getCurrentTime(); + + friend void clockTicker(); + +public: + CClickCount(){}; + + u32 timeSinceLast(); + + static void initialise(); + static void pauseClickCount(); + static void restartClickCount(); + static void updateCurrentTime(); +}; + +/*****************************************************************************/ + +#endif