Slightly less hacky implementation of SampleTime register
This commit is contained in:
parent
02128f1ce4
commit
03c5999359
|
@ -55,6 +55,34 @@ namespace xboxkrnl {
|
||||||
#include <process.h>
|
#include <process.h>
|
||||||
#include <clocale>
|
#include <clocale>
|
||||||
|
|
||||||
|
// Temporary APU Timer Functions
|
||||||
|
// TODO: Move these to LLE APUDevice once we have one!
|
||||||
|
|
||||||
|
#define APU_TIMER_FREQUENCY 48000
|
||||||
|
extern LARGE_INTEGER NativePerformanceFrequency;
|
||||||
|
LARGE_INTEGER APUInitialPerformanceCounter;
|
||||||
|
double NativeToXboxAPU_FactorForPerformanceFrequency = 0;
|
||||||
|
|
||||||
|
void ResetApuTimer()
|
||||||
|
{
|
||||||
|
// Measure current host performance counter and frequency
|
||||||
|
QueryPerformanceCounter(&APUInitialPerformanceCounter);
|
||||||
|
NativeToXboxAPU_FactorForPerformanceFrequency = (double)APU_TIMER_FREQUENCY / NativePerformanceFrequency.QuadPart;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t GetAPUTime()
|
||||||
|
{
|
||||||
|
::LARGE_INTEGER PerformanceCounter;
|
||||||
|
QueryPerformanceCounter(&PerformanceCounter);
|
||||||
|
|
||||||
|
// Re-Base on the time DirectSoundCreate was called
|
||||||
|
PerformanceCounter.QuadPart -= APUInitialPerformanceCounter.QuadPart;
|
||||||
|
// Apply a delta to make it appear to tick at 48khz
|
||||||
|
PerformanceCounter.QuadPart = (ULONGLONG)(NativeToXboxAPU_FactorForPerformanceFrequency * PerformanceCounter.QuadPart);
|
||||||
|
return PerformanceCounter.QuadPart;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// TODO: Tasks need to do for DirectSound HLE
|
// TODO: Tasks need to do for DirectSound HLE
|
||||||
// * Need create patches
|
// * Need create patches
|
||||||
// * Ac97CreateMediaObject (Need OOVPA)
|
// * Ac97CreateMediaObject (Need OOVPA)
|
||||||
|
@ -188,11 +216,6 @@ void CxbxInitAudio()
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define DSOUND_PERFORMANCE_FREQUENCY 48000 // GetSampleTime needs to tick at 48Khz
|
|
||||||
extern LARGE_INTEGER NativePerformanceFrequency;
|
|
||||||
LARGE_INTEGER DSoundInitialPerformanceCounter;
|
|
||||||
double NativeToXboxDSound_FactorForPerformanceFrequency = 0;
|
|
||||||
|
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
// * patch: DirectSoundCreate
|
// * patch: DirectSoundCreate
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
|
@ -220,9 +243,7 @@ HRESULT WINAPI XTL::EMUPATCH(DirectSoundCreate)
|
||||||
|
|
||||||
enterCriticalSection;
|
enterCriticalSection;
|
||||||
|
|
||||||
// Measure current host performance counter and frequency
|
ResetApuTimer();
|
||||||
QueryPerformanceCounter(&DSoundInitialPerformanceCounter);
|
|
||||||
NativeToXboxDSound_FactorForPerformanceFrequency = (double)DSOUND_PERFORMANCE_FREQUENCY / NativePerformanceFrequency.QuadPart;
|
|
||||||
|
|
||||||
// Set this flag when this function is called
|
// Set this flag when this function is called
|
||||||
g_bDSoundCreateCalled = TRUE;
|
g_bDSoundCreateCalled = TRUE;
|
||||||
|
@ -3172,15 +3193,7 @@ DWORD WINAPI XTL::EMUPATCH(DirectSoundGetSampleTime)()
|
||||||
|
|
||||||
LOG_FUNC();
|
LOG_FUNC();
|
||||||
|
|
||||||
DWORD dwRet;
|
DWORD dwRet = GetAPUTime();
|
||||||
::LARGE_INTEGER PerformanceCounter;
|
|
||||||
QueryPerformanceCounter(&PerformanceCounter);
|
|
||||||
|
|
||||||
// Re-Base on the time DirectSoundCreate was called
|
|
||||||
PerformanceCounter.QuadPart -= DSoundInitialPerformanceCounter.QuadPart;
|
|
||||||
// Apply a delta to make it appear to tick at 48khz
|
|
||||||
PerformanceCounter.QuadPart = (ULONGLONG)(NativeToXboxDSound_FactorForPerformanceFrequency * PerformanceCounter.QuadPart);
|
|
||||||
dwRet = PerformanceCounter.QuadPart;
|
|
||||||
|
|
||||||
leaveCriticalSection;
|
leaveCriticalSection;
|
||||||
|
|
||||||
|
|
|
@ -51,11 +51,11 @@
|
||||||
#include "EmuX86.h"
|
#include "EmuX86.h"
|
||||||
#include "HLEIntercept.h" // for bLLE_GPU
|
#include "HLEIntercept.h" // for bLLE_GPU
|
||||||
|
|
||||||
#include "EmuXTL.h"
|
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include "devices\Xbox.h" // For g_PCIBus
|
#include "devices\Xbox.h" // For g_PCIBus
|
||||||
|
|
||||||
|
extern uint32_t GetAPUTime();
|
||||||
|
|
||||||
//
|
//
|
||||||
// Read & write handlers handlers for I/O
|
// Read & write handlers handlers for I/O
|
||||||
//
|
//
|
||||||
|
@ -180,7 +180,8 @@ uint32_t EmuX86_Read(xbaddr addr, int size)
|
||||||
if (addr >= XBOX_FLASH_ROM_BASE) { // 0xFFF00000 - 0xFFFFFFF
|
if (addr >= XBOX_FLASH_ROM_BASE) { // 0xFFF00000 - 0xFFFFFFF
|
||||||
value = EmuFlash_Read32(addr - XBOX_FLASH_ROM_BASE); // TODO : Make flash access size-aware
|
value = EmuFlash_Read32(addr - XBOX_FLASH_ROM_BASE); // TODO : Make flash access size-aware
|
||||||
} else if(addr == 0xFE80200C) {
|
} else if(addr == 0xFE80200C) {
|
||||||
return XTL::EMUPATCH(DirectSoundGetSampleTime)();
|
// TODO: Remove this once we have an LLE APU Device
|
||||||
|
return GetAPUTime();
|
||||||
} else {
|
} else {
|
||||||
// Pass the Read to the PCI Bus, this will handle devices with BARs set to MMIO addresses
|
// Pass the Read to the PCI Bus, this will handle devices with BARs set to MMIO addresses
|
||||||
if (g_PCIBus->MMIORead(addr, &value, size)) {
|
if (g_PCIBus->MMIORead(addr, &value, size)) {
|
||||||
|
|
Loading…
Reference in New Issue