2008-12-07 22:25:12 -07:00
|
|
|
// Copyright (C) 2003-2008 Dolphin Project.
|
|
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, version 2.0.
|
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License 2.0 for more details.
|
|
|
|
|
|
|
|
// A copy of the GPL 2.0 should have been included with the program.
|
|
|
|
// If not, see http://www.gnu.org/licenses/
|
|
|
|
|
|
|
|
// Official SVN repository and contact information can be found at
|
|
|
|
// http://code.google.com/p/dolphin-emu/
|
|
|
|
|
2009-01-11 06:37:13 -07:00
|
|
|
#include <iostream>
|
|
|
|
|
2009-01-17 07:28:09 -07:00
|
|
|
#include "Globals.h" // Local
|
2009-01-17 14:42:43 -07:00
|
|
|
|
2008-12-14 16:52:01 -07:00
|
|
|
#if defined(HAVE_WX) && HAVE_WX
|
2009-01-28 17:57:55 -07:00
|
|
|
#include "ConfigDlg.h"
|
|
|
|
#include "Debugger/File.h" // For file logging
|
|
|
|
#include "Debugger/Debugger.h" // For the CDebugger class
|
2009-02-02 15:31:31 -07:00
|
|
|
CDebugger* m_frame = NULL;
|
2008-12-14 16:52:01 -07:00
|
|
|
#endif
|
|
|
|
|
2009-01-17 07:28:09 -07:00
|
|
|
#include "ConsoleWindow.h" // Common: For the Windows console
|
2008-12-07 22:25:12 -07:00
|
|
|
#include "ChunkFile.h"
|
|
|
|
#include "WaveFile.h"
|
|
|
|
#include "PCHW/Mixer.h"
|
|
|
|
#include "DSPHandler.h"
|
|
|
|
#include "Config.h"
|
2009-01-17 07:28:09 -07:00
|
|
|
|
2009-01-28 17:57:55 -07:00
|
|
|
#include "PCHW/AOSoundStream.h"
|
|
|
|
#include "PCHW/DSoundStream.h"
|
|
|
|
#include "PCHW/NullSoundStream.h"
|
2009-01-17 07:28:09 -07:00
|
|
|
|
|
|
|
// Declarations and definitions
|
2008-12-07 22:25:12 -07:00
|
|
|
DSPInitialize g_dspInitialize;
|
|
|
|
u8* g_pMemory;
|
|
|
|
extern std::vector<std::string> sMailLog, sMailTime;
|
|
|
|
std::string gpName;
|
|
|
|
|
2009-01-28 17:57:55 -07:00
|
|
|
SoundStream *soundStream = NULL;
|
|
|
|
|
2008-12-07 22:25:12 -07:00
|
|
|
// 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;
|
|
|
|
|
2009-01-17 07:28:09 -07:00
|
|
|
|
|
|
|
|
|
|
|
// Mailbox utility
|
2008-12-07 22:25:12 -07:00
|
|
|
struct DSPState
|
|
|
|
{
|
2009-01-28 18:53:07 -07:00
|
|
|
u32 CPUMailbox;
|
|
|
|
bool CPUMailbox_Written[2];
|
|
|
|
|
|
|
|
u32 DSPMailbox;
|
|
|
|
bool DSPMailbox_Read[2];
|
|
|
|
|
|
|
|
DSPState()
|
|
|
|
{
|
|
|
|
CPUMailbox = 0x00000000;
|
|
|
|
CPUMailbox_Written[0] = false;
|
|
|
|
CPUMailbox_Written[1] = false;
|
|
|
|
|
|
|
|
DSPMailbox = 0x00000000;
|
|
|
|
DSPMailbox_Read[0] = true;
|
|
|
|
DSPMailbox_Read[1] = true;
|
|
|
|
}
|
2008-12-07 22:25:12 -07:00
|
|
|
};
|
|
|
|
DSPState g_dspState;
|
|
|
|
|
2009-01-17 07:28:09 -07:00
|
|
|
// wxWidgets: Create the wxApp
|
|
|
|
#if defined(HAVE_WX) && HAVE_WX
|
2008-12-07 22:25:12 -07:00
|
|
|
class wxDLLApp : public wxApp
|
|
|
|
{
|
2009-01-28 18:53:07 -07:00
|
|
|
bool OnInit()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
2008-12-07 22:25:12 -07:00
|
|
|
};
|
|
|
|
|
2009-01-14 23:48:15 -07:00
|
|
|
IMPLEMENT_APP_NO_MAIN(wxDLLApp)
|
2008-12-07 22:25:12 -07:00
|
|
|
WXDLLIMPEXP_BASE void wxSetInstance(HINSTANCE hInst);
|
2008-12-14 16:52:01 -07:00
|
|
|
#endif
|
2009-01-17 07:28:09 -07:00
|
|
|
|
|
|
|
// DllMain
|
2008-12-07 22:25:12 -07:00
|
|
|
#ifdef _WIN32
|
|
|
|
HINSTANCE g_hInstance = NULL;
|
|
|
|
|
|
|
|
BOOL APIENTRY DllMain(HINSTANCE hinstDLL, // DLL module handle
|
2009-01-28 18:53:07 -07:00
|
|
|
DWORD dwReason, // reason called
|
|
|
|
LPVOID lpvReserved) // reserved
|
2008-12-07 22:25:12 -07:00
|
|
|
{
|
2009-01-28 18:53:07 -07:00
|
|
|
switch (dwReason)
|
2008-12-07 22:25:12 -07:00
|
|
|
{
|
2009-01-28 17:57:55 -07:00
|
|
|
case DLL_PROCESS_ATTACH:
|
2009-01-28 18:53:07 -07:00
|
|
|
{
|
2009-01-28 17:57:55 -07:00
|
|
|
|
2009-01-28 18:53:07 -07:00
|
|
|
// more stuff wx needs
|
|
|
|
wxSetInstance((HINSTANCE)hinstDLL);
|
|
|
|
int argc = 0;
|
|
|
|
char **argv = NULL;
|
|
|
|
wxEntryStart(argc, argv);
|
2009-01-28 17:57:55 -07:00
|
|
|
|
2009-01-28 18:53:07 -07:00
|
|
|
// This is for ?
|
|
|
|
if ( !wxTheApp || !wxTheApp->CallOnInit() )
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
2009-01-28 17:57:55 -07:00
|
|
|
|
|
|
|
case DLL_PROCESS_DETACH:
|
2009-01-28 18:53:07 -07:00
|
|
|
wxEntryCleanup(); // use this or get a crash
|
|
|
|
break;
|
2009-01-28 17:57:55 -07:00
|
|
|
|
|
|
|
default:
|
2009-01-28 18:53:07 -07:00
|
|
|
break;
|
2008-12-07 22:25:12 -07:00
|
|
|
}
|
|
|
|
|
2009-01-28 18:53:07 -07:00
|
|
|
g_hInstance = hinstDLL;
|
|
|
|
return(TRUE);
|
2008-12-07 22:25:12 -07:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
// Open and close console
|
|
|
|
void OpenConsole()
|
|
|
|
{
|
2009-01-28 17:57:55 -07:00
|
|
|
#if defined (_WIN32)
|
2009-01-28 18:53:07 -07:00
|
|
|
Console::Open(155, 100, "Sound Debugging"); // give room for 100 rows
|
|
|
|
Console::Print("OpenConsole > Console opened\n");
|
|
|
|
MoveWindow(Console::GetHwnd(), 0,400, 1280,550, true); // move window, TODO: make this
|
|
|
|
// adjustable from the debugging window
|
2009-01-28 17:57:55 -07:00
|
|
|
#endif
|
2008-12-07 22:25:12 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void CloseConsole()
|
|
|
|
{
|
2009-01-28 17:57:55 -07:00
|
|
|
#if defined (_WIN32)
|
2009-01-28 18:53:07 -07:00
|
|
|
FreeConsole();
|
2009-01-28 17:57:55 -07:00
|
|
|
#endif
|
2008-12-07 22:25:12 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-01-17 07:28:09 -07:00
|
|
|
// Exported fuctions
|
|
|
|
|
2008-12-07 22:25:12 -07:00
|
|
|
// Create debugging window - We could use use wxWindow win; new CDebugger(win) like nJoy but I don't
|
|
|
|
// know why it would be better. - There's a lockup problem with ShowModal(), but Show() doesn't work
|
|
|
|
// because then DLL_PROCESS_DETACH is called immediately after DLL_PROCESS_ATTACH.
|
|
|
|
void DllDebugger(HWND _hParent, bool Show)
|
|
|
|
{
|
2008-12-14 16:52:01 -07:00
|
|
|
#if defined(HAVE_WX) && HAVE_WX
|
|
|
|
|
2009-01-28 18:53:07 -07:00
|
|
|
if(m_frame && Show) // if we have created it, let us show it again
|
2008-12-07 22:25:12 -07:00
|
|
|
{
|
2009-01-28 18:53:07 -07:00
|
|
|
m_frame->DoShow();
|
2008-12-07 22:25:12 -07:00
|
|
|
}
|
2009-01-28 18:53:07 -07:00
|
|
|
else if(!m_frame && Show)
|
2008-12-07 22:25:12 -07:00
|
|
|
{
|
2009-01-28 18:53:07 -07:00
|
|
|
m_frame = new CDebugger(NULL);
|
|
|
|
m_frame->Show();
|
2008-12-07 22:25:12 -07:00
|
|
|
}
|
2009-01-28 18:53:07 -07:00
|
|
|
else if(m_frame && !Show)
|
2008-12-07 22:25:12 -07:00
|
|
|
{
|
2009-01-28 18:53:07 -07:00
|
|
|
m_frame->DoHide();
|
2008-12-07 22:25:12 -07:00
|
|
|
}
|
2008-12-14 16:52:01 -07:00
|
|
|
#endif
|
2008-12-07 22:25:12 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GetDllInfo(PLUGIN_INFO* _PluginInfo)
|
|
|
|
{
|
2009-01-28 18:53:07 -07:00
|
|
|
_PluginInfo->Version = 0x0100;
|
|
|
|
_PluginInfo->Type = PLUGIN_TYPE_DSP;
|
2009-01-14 23:48:15 -07:00
|
|
|
#ifdef DEBUGFAST
|
2009-01-28 18:53:07 -07:00
|
|
|
sprintf(_PluginInfo->Name, "Dolphin DSP-HLE Plugin (DebugFast) ");
|
2008-12-07 22:25:12 -07:00
|
|
|
#else
|
|
|
|
#ifndef _DEBUG
|
2009-01-28 18:53:07 -07:00
|
|
|
sprintf(_PluginInfo->Name, "Dolphin DSP-HLE Plugin ");
|
2008-12-07 22:25:12 -07:00
|
|
|
#else
|
2009-01-28 18:53:07 -07:00
|
|
|
sprintf(_PluginInfo ->Name, "Dolphin DSP-HLE Plugin (Debug) ");
|
2008-12-07 22:25:12 -07:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2009-01-08 05:12:15 -07:00
|
|
|
void SetDllGlobals(PLUGIN_GLOBALS* _pPluginGlobals) {
|
|
|
|
}
|
|
|
|
|
2008-12-07 22:25:12 -07:00
|
|
|
void DllConfig(HWND _hParent)
|
|
|
|
{
|
2009-01-17 14:42:43 -07:00
|
|
|
#if defined(HAVE_WX) && HAVE_WX
|
2009-01-28 18:53:07 -07:00
|
|
|
// (shuffle2) TODO: reparent dlg with DolphinApp
|
|
|
|
ConfigDialog dlg(NULL);
|
|
|
|
if (DSound::isValid())
|
|
|
|
dlg.AddBackend("DSound");
|
|
|
|
if (AOSound::isValid())
|
|
|
|
dlg.AddBackend("AOSound");
|
|
|
|
dlg.AddBackend("NullSound");
|
|
|
|
dlg.ShowModal();
|
2008-12-07 22:25:12 -07:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2009-01-14 23:48:15 -07:00
|
|
|
void Initialize(void *init)
|
2008-12-07 22:25:12 -07:00
|
|
|
{
|
2009-01-28 18:53:07 -07:00
|
|
|
g_Config.Load();
|
2008-12-07 22:25:12 -07:00
|
|
|
|
2009-01-28 18:53:07 -07:00
|
|
|
g_dspInitialize = *(DSPInitialize*)init;
|
2008-12-07 22:25:12 -07:00
|
|
|
|
2009-01-28 18:53:07 -07:00
|
|
|
g_pMemory = g_dspInitialize.pGetMemoryPointer(0);
|
2008-12-07 22:25:12 -07:00
|
|
|
|
|
|
|
#if defined(_DEBUG) || defined(DEBUGFAST)
|
2009-01-28 18:53:07 -07:00
|
|
|
gpName = g_dspInitialize.pName(); // save the game name globally
|
|
|
|
for (u32 i = 0; i < gpName.length(); ++i) // and fix it
|
2008-12-07 22:25:12 -07:00
|
|
|
{
|
2009-01-28 18:53:07 -07:00
|
|
|
fprintf(stderr,"%c", gpName[i]);
|
|
|
|
std::cout << gpName[i];
|
|
|
|
if (gpName[i] == ':') gpName[i] = ' ';
|
2008-12-07 22:25:12 -07:00
|
|
|
}
|
2009-01-28 18:53:07 -07:00
|
|
|
fprintf(stderr, "\n");
|
2008-12-07 22:25:12 -07:00
|
|
|
#endif
|
|
|
|
|
2009-01-28 18:53:07 -07:00
|
|
|
CDSPHandler::CreateInstance();
|
|
|
|
|
|
|
|
if (strncasecmp(g_Config.sBackend, "DSound", 10) == 0) {
|
|
|
|
if (DSound::isValid()) {
|
|
|
|
soundStream = new DSound(48000, Mixer, g_dspInitialize.hWnd);
|
|
|
|
}
|
|
|
|
} else if(strncasecmp(g_Config.sBackend, "AOSound", 10) == 0) {
|
|
|
|
if (AOSound::isValid())
|
|
|
|
soundStream = new AOSound(48000, Mixer);
|
|
|
|
} else if(strncasecmp(g_Config.sBackend, "NullSound", 10) == 0) {
|
2009-02-09 12:50:06 -07:00
|
|
|
soundStream = new NullSound(48000, Mixer_MixUCode);
|
2009-01-28 18:53:07 -07:00
|
|
|
} else {
|
|
|
|
PanicAlert("Cannot recognize backend %s", g_Config.sBackend);
|
|
|
|
return;
|
2008-12-07 22:25:12 -07:00
|
|
|
}
|
2009-01-28 18:53:07 -07:00
|
|
|
|
2009-01-28 17:57:55 -07:00
|
|
|
#if defined(WIN32) && defined(_DEBUG)
|
2009-01-28 18:53:07 -07:00
|
|
|
int tmpflag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
|
|
|
|
tmpflag |= _CRTDBG_DELAY_FREE_MEM_DF;
|
|
|
|
_CrtSetDbgFlag(tmpflag);
|
2008-12-07 22:25:12 -07:00
|
|
|
#endif
|
2009-01-28 17:57:55 -07:00
|
|
|
|
2009-01-28 18:53:07 -07:00
|
|
|
if (soundStream) {
|
|
|
|
if(!soundStream->Start()) {
|
|
|
|
PanicAlert("Could not initialize backend %s, falling back to NULL",
|
|
|
|
g_Config.sBackend);
|
|
|
|
delete soundStream;
|
|
|
|
soundStream = new NullSound(48000, Mixer);
|
|
|
|
soundStream->Start();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
PanicAlert("Sound backend %s is not valid, falling back to NULL",
|
|
|
|
g_Config.sBackend);
|
|
|
|
delete soundStream;
|
|
|
|
soundStream = new NullSound(48000, Mixer);
|
|
|
|
soundStream->Start();
|
2009-01-28 17:57:55 -07:00
|
|
|
}
|
2009-01-28 18:53:07 -07:00
|
|
|
|
2008-12-07 22:25:12 -07:00
|
|
|
}
|
|
|
|
|
2009-01-14 23:48:15 -07:00
|
|
|
void Shutdown()
|
2008-12-07 22:25:12 -07:00
|
|
|
{
|
2009-01-28 18:53:07 -07:00
|
|
|
if (log_ai)
|
|
|
|
g_wave_writer.Stop();
|
|
|
|
// delete the UCodes
|
|
|
|
soundStream->Stop();
|
|
|
|
delete soundStream;
|
|
|
|
soundStream = NULL;
|
2009-01-28 17:57:55 -07:00
|
|
|
|
2009-01-28 18:53:07 -07:00
|
|
|
CDSPHandler::Destroy();
|
2008-12-07 22:25:12 -07:00
|
|
|
|
2008-12-14 16:52:01 -07:00
|
|
|
#if defined(HAVE_WX) && HAVE_WX
|
2009-01-28 18:53:07 -07:00
|
|
|
// Reset mails
|
|
|
|
if(m_frame)
|
2008-12-07 22:25:12 -07:00
|
|
|
{
|
2009-01-28 18:53:07 -07:00
|
|
|
sMailLog.clear();
|
|
|
|
sMailTime.clear();
|
|
|
|
m_frame->sMail.clear();
|
|
|
|
m_frame->sMailEnd.clear();
|
2008-12-07 22:25:12 -07:00
|
|
|
}
|
2008-12-14 16:52:01 -07:00
|
|
|
#endif
|
2008-12-07 22:25:12 -07:00
|
|
|
}
|
|
|
|
|
2009-01-14 23:48:15 -07:00
|
|
|
void DoState(unsigned char **ptr, int mode) {
|
2009-01-28 18:53:07 -07:00
|
|
|
PointerWrap p(ptr, mode);
|
2008-12-07 22:25:12 -07:00
|
|
|
}
|
2009-01-17 07:28:09 -07:00
|
|
|
|
|
|
|
// Mailbox fuctions
|
2008-12-07 22:25:12 -07:00
|
|
|
unsigned short DSP_ReadMailboxHigh(bool _CPUMailbox)
|
|
|
|
{
|
2009-01-28 18:53:07 -07:00
|
|
|
if (_CPUMailbox)
|
2008-12-07 22:25:12 -07:00
|
|
|
{
|
2009-01-28 18:53:07 -07:00
|
|
|
return (g_dspState.CPUMailbox >> 16) & 0xFFFF;
|
2008-12-07 22:25:12 -07:00
|
|
|
}
|
2009-01-28 18:53:07 -07:00
|
|
|
else
|
2008-12-07 22:25:12 -07:00
|
|
|
{
|
2009-01-28 18:53:07 -07:00
|
|
|
return CDSPHandler::GetInstance().AccessMailHandler().ReadDSPMailboxHigh();
|
2008-12-07 22:25:12 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned short DSP_ReadMailboxLow(bool _CPUMailbox)
|
|
|
|
{
|
2009-01-28 18:53:07 -07:00
|
|
|
if (_CPUMailbox)
|
2008-12-07 22:25:12 -07:00
|
|
|
{
|
2009-01-28 18:53:07 -07:00
|
|
|
return g_dspState.CPUMailbox & 0xFFFF;
|
2008-12-07 22:25:12 -07:00
|
|
|
}
|
2009-01-28 18:53:07 -07:00
|
|
|
else
|
2008-12-07 22:25:12 -07:00
|
|
|
{
|
2009-01-28 18:53:07 -07:00
|
|
|
return CDSPHandler::GetInstance().AccessMailHandler().ReadDSPMailboxLow();
|
2008-12-07 22:25:12 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Update_DSP_WriteRegister()
|
|
|
|
{
|
2009-01-28 18:53:07 -07:00
|
|
|
// check if the whole message is complete and if we can send it
|
|
|
|
if (g_dspState.CPUMailbox_Written[0] && g_dspState.CPUMailbox_Written[1])
|
2008-12-07 22:25:12 -07:00
|
|
|
{
|
2009-01-28 18:53:07 -07:00
|
|
|
CDSPHandler::GetInstance().SendMailToDSP(g_dspState.CPUMailbox);
|
|
|
|
g_dspState.CPUMailbox_Written[0] = g_dspState.CPUMailbox_Written[1] = false;
|
|
|
|
g_dspState.CPUMailbox = 0; // Mail sent so clear it to show that it is progressed
|
2008-12-07 22:25:12 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DSP_WriteMailboxHigh(bool _CPUMailbox, unsigned short _Value)
|
|
|
|
{
|
2009-01-28 18:53:07 -07:00
|
|
|
if (_CPUMailbox)
|
2008-12-07 22:25:12 -07:00
|
|
|
{
|
2009-01-28 18:53:07 -07:00
|
|
|
g_dspState.CPUMailbox = (g_dspState.CPUMailbox & 0xFFFF) | (_Value << 16);
|
|
|
|
g_dspState.CPUMailbox_Written[0] = true;
|
2008-12-07 22:25:12 -07:00
|
|
|
|
2009-01-28 18:53:07 -07:00
|
|
|
Update_DSP_WriteRegister();
|
2008-12-07 22:25:12 -07:00
|
|
|
}
|
2009-01-28 18:53:07 -07:00
|
|
|
else
|
2008-12-07 22:25:12 -07:00
|
|
|
{
|
2009-01-28 18:53:07 -07:00
|
|
|
PanicAlert("CPU can't write %08x to DSP mailbox", _Value);
|
2008-12-07 22:25:12 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DSP_WriteMailboxLow(bool _CPUMailbox, unsigned short _Value)
|
|
|
|
{
|
2009-01-28 18:53:07 -07:00
|
|
|
if (_CPUMailbox)
|
2008-12-07 22:25:12 -07:00
|
|
|
{
|
2009-01-28 18:53:07 -07:00
|
|
|
g_dspState.CPUMailbox = (g_dspState.CPUMailbox & 0xFFFF0000) | _Value;
|
|
|
|
g_dspState.CPUMailbox_Written[1] = true;
|
2008-12-07 22:25:12 -07:00
|
|
|
|
2009-01-28 18:53:07 -07:00
|
|
|
Update_DSP_WriteRegister();
|
2008-12-07 22:25:12 -07:00
|
|
|
}
|
2009-01-28 18:53:07 -07:00
|
|
|
else
|
2008-12-07 22:25:12 -07:00
|
|
|
{
|
2009-01-28 18:53:07 -07:00
|
|
|
PanicAlert("CPU can't write %08x to DSP mailbox", _Value);
|
2008-12-07 22:25:12 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-17 07:28:09 -07:00
|
|
|
// Other DSP fuctions
|
2008-12-07 22:25:12 -07:00
|
|
|
unsigned short DSP_WriteControlRegister(unsigned short _Value)
|
|
|
|
{
|
2009-01-28 18:53:07 -07:00
|
|
|
return CDSPHandler::GetInstance().WriteControlRegister(_Value);
|
2008-12-07 22:25:12 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned short DSP_ReadControlRegister()
|
|
|
|
{
|
2009-01-28 18:53:07 -07:00
|
|
|
return CDSPHandler::GetInstance().ReadControlRegister();
|
2008-12-07 22:25:12 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void DSP_Update(int cycles)
|
|
|
|
{
|
2009-01-28 18:53:07 -07:00
|
|
|
CDSPHandler::GetInstance().Update();
|
2008-12-07 22:25:12 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void DSP_SendAIBuffer(unsigned int address, int sample_rate)
|
|
|
|
{
|
2009-01-28 18:53:07 -07:00
|
|
|
if(soundStream->usesMixer()) {
|
|
|
|
short samples[16] = {0}; // interleaved stereo
|
|
|
|
if (address) {
|
|
|
|
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);
|
2008-12-07 22:25:12 -07:00
|
|
|
}
|
|
|
|
|
2009-01-28 18:53:07 -07:00
|
|
|
/*static int counter = 0;
|
|
|
|
counter++;
|
|
|
|
if ((counter & 255) == 0)*/
|
2009-01-28 17:57:55 -07:00
|
|
|
|
|
|
|
|
2009-01-28 18:53:07 -07:00
|
|
|
// SoundStream is updated only when necessary (there is no 70 ms limit
|
|
|
|
// so each sample now triggers the sound stream)
|
|
|
|
soundStream->Update();
|
2008-12-07 22:25:12 -07:00
|
|
|
}
|
2009-01-28 17:57:55 -07:00
|
|
|
|
|
|
|
|