Try to make DTK rewrite handle events the same way as the old code.
This commit is contained in:
parent
a282f181cd
commit
1f604e87be
|
@ -56,6 +56,7 @@ This file mainly deals with the [Drive I/F], however [AIDFR] controls
|
||||||
#include "Core/CoreTiming.h"
|
#include "Core/CoreTiming.h"
|
||||||
#include "Core/HW/AudioInterface.h"
|
#include "Core/HW/AudioInterface.h"
|
||||||
#include "Core/HW/CPU.h"
|
#include "Core/HW/CPU.h"
|
||||||
|
#include "Core/HW/DVDInterface.h"
|
||||||
#include "Core/HW/MMIO.h"
|
#include "Core/HW/MMIO.h"
|
||||||
#include "Core/HW/ProcessorInterface.h"
|
#include "Core/HW/ProcessorInterface.h"
|
||||||
#include "Core/HW/SystemTimers.h"
|
#include "Core/HW/SystemTimers.h"
|
||||||
|
@ -202,6 +203,9 @@ void RegisterMMIO(MMIO::Mapping* mmio, u32 base)
|
||||||
m_Control.PSTAT = tmpAICtrl.PSTAT;
|
m_Control.PSTAT = tmpAICtrl.PSTAT;
|
||||||
g_LastCPUTime = CoreTiming::GetTicks();
|
g_LastCPUTime = CoreTiming::GetTicks();
|
||||||
|
|
||||||
|
// Tell Drive Interface to start/stop streaming
|
||||||
|
DVDInterface::g_bStream = tmpAICtrl.PSTAT;
|
||||||
|
|
||||||
CoreTiming::RemoveEvent(et_AI);
|
CoreTiming::RemoveEvent(et_AI);
|
||||||
CoreTiming::ScheduleEvent(((int)GetAIPeriod() / 2), et_AI);
|
CoreTiming::ScheduleEvent(((int)GetAIPeriod() / 2), et_AI);
|
||||||
}
|
}
|
||||||
|
@ -306,9 +310,4 @@ u64 GetAIPeriod()
|
||||||
return period;
|
return period;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsAISPlaying()
|
|
||||||
{
|
|
||||||
return m_Control.PSTAT;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // end of namespace AudioInterface
|
} // end of namespace AudioInterface
|
||||||
|
|
|
@ -27,6 +27,4 @@ unsigned int GetAIDSampleRate();
|
||||||
|
|
||||||
void GenerateAISInterrupt();
|
void GenerateAISInterrupt();
|
||||||
|
|
||||||
bool IsAISPlaying();
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -303,7 +303,7 @@ void DTKStreamingCallback(u64 userdata, int cyclesLate)
|
||||||
static const int NUM_SAMPLES = 48000 / 2000 * 7; // 3.5ms of 48kHz samples
|
static const int NUM_SAMPLES = 48000 / 2000 * 7; // 3.5ms of 48kHz samples
|
||||||
short tempPCM[NUM_SAMPLES * 2];
|
short tempPCM[NUM_SAMPLES * 2];
|
||||||
unsigned samples_processed;
|
unsigned samples_processed;
|
||||||
if (AudioInterface::IsAISPlaying())
|
if (g_bStream)
|
||||||
{
|
{
|
||||||
samples_processed = ProcessDTKSamples(tempPCM, NUM_SAMPLES);
|
samples_processed = ProcessDTKSamples(tempPCM, NUM_SAMPLES);
|
||||||
}
|
}
|
||||||
|
@ -314,29 +314,10 @@ void DTKStreamingCallback(u64 userdata, int cyclesLate)
|
||||||
}
|
}
|
||||||
soundStream->GetMixer()->PushStreamingSamples(tempPCM, samples_processed);
|
soundStream->GetMixer()->PushStreamingSamples(tempPCM, samples_processed);
|
||||||
|
|
||||||
// If we reached the end of the audio, stop.
|
|
||||||
if (!g_bStream)
|
|
||||||
return;
|
|
||||||
|
|
||||||
int ticks_to_dtk = int(SystemTimers::GetTicksPerSecond() * u64(samples_processed) / 48000);
|
int ticks_to_dtk = int(SystemTimers::GetTicksPerSecond() * u64(samples_processed) / 48000);
|
||||||
CoreTiming::ScheduleEvent(ticks_to_dtk - cyclesLate, dtk);
|
CoreTiming::ScheduleEvent(ticks_to_dtk - cyclesLate, dtk);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StartDTKStreaming()
|
|
||||||
{
|
|
||||||
// We wait 100ms before we actually start streaming to try to simulate
|
|
||||||
// seek time. Not completely accurate, but better than starting the
|
|
||||||
// stream instantly.
|
|
||||||
g_bStream = true;
|
|
||||||
CoreTiming::ScheduleEvent(SystemTimers::GetTicksPerSecond() / 10, dtk);
|
|
||||||
}
|
|
||||||
|
|
||||||
void StopDTKStreaming()
|
|
||||||
{
|
|
||||||
g_bStream = false;
|
|
||||||
CoreTiming::RemoveAllEvents(dtk);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Init()
|
void Init()
|
||||||
{
|
{
|
||||||
m_DISR.Hex = 0;
|
m_DISR.Hex = 0;
|
||||||
|
@ -364,6 +345,8 @@ void Init()
|
||||||
|
|
||||||
tc = CoreTiming::RegisterEvent("TransferComplete", TransferComplete);
|
tc = CoreTiming::RegisterEvent("TransferComplete", TransferComplete);
|
||||||
dtk = CoreTiming::RegisterEvent("StreamingTimer", DTKStreamingCallback);
|
dtk = CoreTiming::RegisterEvent("StreamingTimer", DTKStreamingCallback);
|
||||||
|
|
||||||
|
CoreTiming::ScheduleEvent(0, dtk);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Shutdown()
|
void Shutdown()
|
||||||
|
@ -955,11 +938,11 @@ void ExecuteCommand()
|
||||||
CurrentStart = pos;
|
CurrentStart = pos;
|
||||||
CurrentLength = length;
|
CurrentLength = length;
|
||||||
NGCADPCM::InitFilter();
|
NGCADPCM::InitFilter();
|
||||||
StartDTKStreaming();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LoopStart = pos;
|
LoopStart = pos;
|
||||||
LoopLength = length;
|
LoopLength = length;
|
||||||
|
g_bStream = (m_DICMDBUF[0].CMDBYTE1 == 0); // This command can start/stop the stream
|
||||||
|
|
||||||
// Stop stream
|
// Stop stream
|
||||||
if (m_DICMDBUF[0].CMDBYTE1 == 1)
|
if (m_DICMDBUF[0].CMDBYTE1 == 1)
|
||||||
|
@ -969,8 +952,6 @@ void ExecuteCommand()
|
||||||
LoopLength = 0;
|
LoopLength = 0;
|
||||||
CurrentStart = 0;
|
CurrentStart = 0;
|
||||||
CurrentLength = 0;
|
CurrentLength = 0;
|
||||||
if (g_bStream)
|
|
||||||
StopDTKStreaming();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WARN_LOG(DVDINTERFACE, "(Audio) Stream subcmd = %08x offset = %08x length=%08x",
|
WARN_LOG(DVDINTERFACE, "(Audio) Stream subcmd = %08x offset = %08x length=%08x",
|
||||||
|
@ -1020,11 +1001,13 @@ void ExecuteCommand()
|
||||||
if (m_DICMDBUF[0].CMDBYTE1 == 1)
|
if (m_DICMDBUF[0].CMDBYTE1 == 1)
|
||||||
{
|
{
|
||||||
// TODO: What is this actually supposed to do?
|
// TODO: What is this actually supposed to do?
|
||||||
|
g_bStream = true;
|
||||||
WARN_LOG(DVDINTERFACE, "(Audio): Audio enabled");
|
WARN_LOG(DVDINTERFACE, "(Audio): Audio enabled");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// TODO: What is this actually supposed to do?
|
// TODO: What is this actually supposed to do?
|
||||||
|
g_bStream = false;
|
||||||
WARN_LOG(DVDINTERFACE, "(Audio): Audio disabled");
|
WARN_LOG(DVDINTERFACE, "(Audio): Audio disabled");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -33,9 +33,7 @@ void ClearCoverInterrupt();
|
||||||
|
|
||||||
// DVD Access Functions
|
// DVD Access Functions
|
||||||
bool DVDRead(u32 _iDVDOffset, u32 _iRamAddress, u32 _iLength);
|
bool DVDRead(u32 _iDVDOffset, u32 _iRamAddress, u32 _iLength);
|
||||||
// For AudioInterface
|
extern bool g_bStream;
|
||||||
bool DVDReadADPCM(u8* _pDestBuffer, u32 _iNumSamples);
|
|
||||||
|
|
||||||
|
|
||||||
// Not sure about endianness here. I'll just name them like this...
|
// Not sure about endianness here. I'll just name them like this...
|
||||||
enum DIErrorLow
|
enum DIErrorLow
|
||||||
|
|
Loading…
Reference in New Issue