Added AI FIFO wave logging to HLE plugin. Same for LLE plugin is coming soon. Plus some extra critical section locks in LLE plugin.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@797 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
hrydgard
2008-10-08 18:57:33 +00:00
parent 8dc32f5dee
commit 49534ca586
7 changed files with 227 additions and 35 deletions

View File

@ -163,7 +163,7 @@ void CUCode_AX::Logging(short* _pBuffer, int _iSize, int a)
for (int i = 0; i < numberOfPBs; i++)
{
vector1.at(i).at(vectorLength-1) = PBs[i].running;
vector1.at(i).at(vectorLength-1) = PBs[i].running ? true : false;
}
// ==============

View File

@ -15,9 +15,9 @@
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include "Debugger/Debugger.h" // for the CDebugger class
#include "ChunkFile.h"
#include "WaveFile.h"
#include "resource.h"
#ifdef _WIN32
@ -34,15 +34,14 @@
#include "Config.h"
#include "Logging/Console.h" // for startConsoleWin, wprintf, GetConsoleHwnd
// ===================
// =======================================================================================
// DSP struct
// -------------------
DSPInitialize g_dspInitialize;
u8* g_pMemory;
// Set this if you want to log audio. search for log_ai in this file to see the filename.
static bool log_ai = false;
static WaveFileWriter g_wave_writer;
struct DSPState
{
u32 CPUMailbox;
@ -168,7 +167,7 @@ void GetDllInfo(PLUGIN_INFO* _PluginInfo)
#ifndef _DEBUG
sprintf(_PluginInfo->Name, "Dolphin DSP-HLE Plugin ");
#else
sprintf(_PluginInfo->Name, "Dolphin DSP-HLE Plugin (Debug) ");
sprintf(_PluginInfo ->Name, "Dolphin DSP-HLE Plugin (Debug) ");
#endif
#endif
}
@ -211,10 +210,16 @@ void DSP_Initialize(DSPInitialize _dspInitialize)
#else
AOSound::AOSound_StartSound(48000, Mixer);
#endif
if (log_ai) {
g_wave_writer.Start("D:\\ai_log.wav");
g_wave_writer.SetSkipSilence(false);
}
}
void DSP_Shutdown()
{
if (log_ai)
g_wave_writer.Stop();
// delete the UCodes
#ifdef _WIN32
DSound::DSound_StopSound();
@ -315,6 +320,8 @@ void DSP_SendAIBuffer(unsigned int address, int sample_rate)
for (int i = 0; i < 16; i++) {
samples[i] = Memory_Read_U16(address + i * 2);
}
if (log_ai)
g_wave_writer.AddStereoSamples(samples, 8);
}
Mixer_PushSamples(samples, 32 / 4, sample_rate);

View File

@ -14,13 +14,13 @@
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include "Globals.h"
#include "gdsp_interface.h"
extern uint16 dsp_swap16(uint16 x);
// the hardware adpcm decoder :)
// The hardware adpcm decoder :)
sint16 ADPCM_Step(uint32& _rSamplePos, uint32 _BaseAddress)
{
sint16* pCoefTable = (sint16*)&gdsp_ifx_regs[DSP_COEF_A1_0];
@ -42,30 +42,25 @@ sint16 ADPCM_Step(uint32& _rSamplePos, uint32 _BaseAddress)
(g_dspInitialize.pARAM_Read_U8(_rSamplePos >> 1) >> 4);
if (temp >= 8)
{
temp -= 16; //temp += 0xFFFFFFF0;
}
temp -= 16;
//0x400 = 0.5 in 11-bit fixed point
// 0x400 = 0.5 in 11-bit fixed point
int val = (scale * temp) + ((0x400 + coef1 * (sint16)gdsp_ifx_regs[DSP_YN1] + coef2 * (sint16)gdsp_ifx_regs[DSP_YN2]) >> 11);
// Clamp values.
if (val > 0x7FFF)
{
val = 0x7FFF;
}
else if (val < -0x7FFF)
{
val = -0x7FFF;
}
gdsp_ifx_regs[DSP_YN2] = gdsp_ifx_regs[DSP_YN1];
gdsp_ifx_regs[DSP_YN1] = val;
_rSamplePos++;
return(val);
// I think the interpolation (linear, polyphase,...) is done by the UCode
// The advanced interpolation (linear, polyphase,...) is done by the UCode, so we don't
// need to bother with it here.
return val;
}
@ -104,8 +99,12 @@ uint16 dsp_read_aram()
if (Address > EndAddress)
{
Address = (gdsp_ifx_regs[DSP_ACSAH] << 16) | gdsp_ifx_regs[DSP_ACSAL];
//ErrorLog("Should we generate a lvl5 exception !??!");
//gdsp_exception(5);
// ErrorLog("Should we generate a lvl5 exception !??!");
// gdsp_exception(5);
// Somehow, YN1 and YN2 must be initialized with their "loop" values, so yeah,
// it seems likely that we should raise an exception to let the DSP program do that,
// at least if DSP_FORMAT == 0x0A.
}
gdsp_ifx_regs[DSP_ACCAH] = Address >> 16;

View File

@ -14,6 +14,10 @@
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#pragma once
#ifndef _GDSP_ARAM_H
#define _GDSP_ARAM_H
uint16 dsp_read_aram();
#endif

View File

@ -25,6 +25,7 @@
#include <stdlib.h>
#include "Globals.h"
#include "Thread.h"
#include "gdsp_aram.h"
#include "gdsp_interpreter.h"
@ -66,9 +67,8 @@ const char* reg_names[] =
void gdsp_dma();
#ifdef _WIN32
extern CRITICAL_SECTION g_CriticalSection;
#ifdef WITH_DSP_ON_THREAD
Common::CriticalSection g_CriticalSection;
#endif
static volatile uint16 gdsp_mbox[2][2];
@ -93,20 +93,27 @@ void gdsp_ifx_init()
uint32 gdsp_mbox_peek(uint8 mbx)
{
return((gdsp_mbox[mbx][0] << 16) | gdsp_mbox[mbx][1]);
#if WITH_DSP_ON_THREAD
g_CriticalSection.Enter();
#endif
uint32 value = ((gdsp_mbox[mbx][0] << 16) | gdsp_mbox[mbx][1]);
#if WITH_DSP_ON_THREAD
g_CriticalSection.Leave();
#endif
return value;
}
void gdsp_mbox_write_h(uint8 mbx, uint16 val)
{
#if WITH_DSP_ON_THREAD
EnterCriticalSection(&g_CriticalSection);
g_CriticalSection.Enter();
#endif
gdsp_mbox[mbx][0] = val & 0x7fff;
#if WITH_DSP_ON_THREAD
LeaveCriticalSection(&g_CriticalSection);
g_CriticalSection.Leave();
#endif
}
@ -114,14 +121,14 @@ void gdsp_mbox_write_h(uint8 mbx, uint16 val)
void gdsp_mbox_write_l(uint8 mbx, uint16 val)
{
#if WITH_DSP_ON_THREAD
EnterCriticalSection(&g_CriticalSection);
g_CriticalSection.Enter();
#endif
gdsp_mbox[mbx][1] = val;
gdsp_mbox[mbx][0] |= 0x8000;
#if WITH_DSP_ON_THREAD
LeaveCriticalSection(&g_CriticalSection);
g_CriticalSection.Leave();
#endif
if (mbx == GDSP_MBOX_DSP)
@ -133,7 +140,7 @@ void gdsp_mbox_write_l(uint8 mbx, uint16 val)
uint16 gdsp_mbox_read_h(uint8 mbx)
{
return(gdsp_mbox[mbx][0]);
return (gdsp_mbox[mbx][0]);
}
@ -141,14 +148,14 @@ uint16 gdsp_mbox_read_l(uint8 mbx)
{
uint16 val;
#if WITH_DSP_ON_THREAD
EnterCriticalSection(&g_CriticalSection);
g_CriticalSection.Enter();
#endif
val = gdsp_mbox[mbx][1];
gdsp_mbox[mbx][0] &= ~0x8000;
#if WITH_DSP_ON_THREAD
LeaveCriticalSection(&g_CriticalSection);
g_CriticalSection.Leave();
#endif
return(val);
}