2009-07-28 21:32:10 +00:00
|
|
|
// Copyright (C) 2003 Dolphin Project.
|
2008-12-08 05:25:12 +00:00
|
|
|
|
|
|
|
// 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 13:37:13 +00:00
|
|
|
#include <iostream>
|
|
|
|
|
2009-01-17 14:28:09 +00:00
|
|
|
#include "Globals.h" // Local
|
2009-01-17 21:42:43 +00:00
|
|
|
|
2008-12-14 23:52:01 +00:00
|
|
|
#if defined(HAVE_WX) && HAVE_WX
|
2009-01-29 00:57:55 +00:00
|
|
|
#include "ConfigDlg.h"
|
2009-07-02 19:00:27 +00:00
|
|
|
DSPConfigDialogHLE* m_ConfigFrame = NULL;
|
2009-01-29 00:57:55 +00:00
|
|
|
#include "Debugger/File.h" // For file logging
|
2009-07-02 19:00:27 +00:00
|
|
|
#include "Debugger/Debugger.h"
|
|
|
|
DSPDebuggerHLE* m_DebuggerFrame = NULL;
|
2008-12-14 23:52:01 +00:00
|
|
|
#endif
|
|
|
|
|
2008-12-08 05:25:12 +00:00
|
|
|
#include "ChunkFile.h"
|
2009-03-26 09:29:14 +00:00
|
|
|
#include "HLEMixer.h"
|
2008-12-08 05:25:12 +00:00
|
|
|
#include "DSPHandler.h"
|
|
|
|
#include "Config.h"
|
2009-02-14 01:07:20 +00:00
|
|
|
#include "Setup.h"
|
|
|
|
#include "StringUtil.h"
|
2009-07-12 21:58:32 +00:00
|
|
|
#include "LogManager.h"
|
2009-01-17 14:28:09 +00:00
|
|
|
|
2009-03-26 09:29:14 +00:00
|
|
|
|
2009-01-17 14:28:09 +00:00
|
|
|
// Declarations and definitions
|
2009-03-18 17:17:58 +00:00
|
|
|
PLUGIN_GLOBALS* globals = NULL;
|
2008-12-08 05:25:12 +00:00
|
|
|
DSPInitialize g_dspInitialize;
|
|
|
|
u8* g_pMemory;
|
|
|
|
extern std::vector<std::string> sMailLog, sMailTime;
|
|
|
|
|
2009-12-23 15:34:14 +00:00
|
|
|
bool g_InitMixer = false;
|
2009-01-29 00:57:55 +00:00
|
|
|
SoundStream *soundStream = NULL;
|
|
|
|
|
2009-01-17 14:28:09 +00:00
|
|
|
// Mailbox utility
|
2008-12-08 05:25:12 +00:00
|
|
|
struct DSPState
|
|
|
|
{
|
2009-01-29 01:53:07 +00:00
|
|
|
u32 CPUMailbox;
|
|
|
|
u32 DSPMailbox;
|
|
|
|
|
2009-08-12 01:15:57 +00:00
|
|
|
void Reset() {
|
2009-01-29 01:53:07 +00:00
|
|
|
CPUMailbox = 0x00000000;
|
|
|
|
DSPMailbox = 0x00000000;
|
|
|
|
}
|
2009-08-12 01:15:57 +00:00
|
|
|
|
|
|
|
DSPState()
|
|
|
|
{
|
|
|
|
Reset();
|
|
|
|
}
|
2008-12-08 05:25:12 +00:00
|
|
|
};
|
|
|
|
DSPState g_dspState;
|
|
|
|
|
2009-07-02 19:00:27 +00:00
|
|
|
// Standard crap to make wxWidgets happy
|
|
|
|
#ifdef _WIN32
|
|
|
|
HINSTANCE g_hInstance;
|
|
|
|
|
2009-01-17 14:28:09 +00:00
|
|
|
#if defined(HAVE_WX) && HAVE_WX
|
2008-12-08 05:25:12 +00:00
|
|
|
class wxDLLApp : public wxApp
|
|
|
|
{
|
2009-01-29 01:53:07 +00:00
|
|
|
bool OnInit()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
2008-12-08 05:25:12 +00:00
|
|
|
};
|
2009-07-02 19:00:27 +00:00
|
|
|
IMPLEMENT_APP_NO_MAIN(wxDLLApp)
|
2008-12-08 05:25:12 +00:00
|
|
|
WXDLLIMPEXP_BASE void wxSetInstance(HINSTANCE hInst);
|
2008-12-14 23:52:01 +00:00
|
|
|
#endif
|
2009-01-17 14:28:09 +00:00
|
|
|
|
2009-07-02 19:00:27 +00:00
|
|
|
BOOL APIENTRY DllMain(HINSTANCE hinstDLL, // DLL module handle
|
|
|
|
DWORD dwReason, // reason called
|
|
|
|
LPVOID lpvReserved) // reserved
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
2009-01-29 01:53:07 +00:00
|
|
|
switch (dwReason)
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
2009-01-29 00:57:55 +00:00
|
|
|
case DLL_PROCESS_ATTACH:
|
2009-01-29 01:53:07 +00:00
|
|
|
{
|
2009-07-02 19:00:27 +00:00
|
|
|
#if defined(HAVE_WX) && HAVE_WX
|
2009-01-29 01:53:07 +00:00
|
|
|
wxSetInstance((HINSTANCE)hinstDLL);
|
|
|
|
int argc = 0;
|
|
|
|
char **argv = NULL;
|
|
|
|
wxEntryStart(argc, argv);
|
2009-07-02 19:00:27 +00:00
|
|
|
if (!wxTheApp || !wxTheApp->CallOnInit())
|
2009-01-29 01:53:07 +00:00
|
|
|
return FALSE;
|
2009-07-02 19:00:27 +00:00
|
|
|
#endif
|
2009-01-29 01:53:07 +00:00
|
|
|
}
|
2009-07-02 19:00:27 +00:00
|
|
|
break;
|
2009-01-29 00:57:55 +00:00
|
|
|
|
|
|
|
case DLL_PROCESS_DETACH:
|
2009-07-02 19:00:27 +00:00
|
|
|
#if defined(HAVE_WX) && HAVE_WX
|
|
|
|
wxEntryCleanup();
|
|
|
|
#endif
|
2009-01-29 01:53:07 +00:00
|
|
|
break;
|
2009-01-29 00:57:55 +00:00
|
|
|
default:
|
2009-01-29 01:53:07 +00:00
|
|
|
break;
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
|
|
|
|
2009-01-29 01:53:07 +00:00
|
|
|
g_hInstance = hinstDLL;
|
2009-07-02 19:00:27 +00:00
|
|
|
return TRUE;
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-07-02 19:00:27 +00:00
|
|
|
#if defined(HAVE_WX) && HAVE_WX
|
|
|
|
wxWindow* GetParentedWxWindow(HWND Parent)
|
|
|
|
{
|
|
|
|
#ifdef _WIN32
|
|
|
|
wxSetInstance((HINSTANCE)g_hInstance);
|
|
|
|
#endif
|
|
|
|
wxWindow *win = new wxWindow();
|
|
|
|
#ifdef _WIN32
|
|
|
|
win->SetHWND((WXHWND)Parent);
|
|
|
|
win->AdoptAttributesFromHWND();
|
|
|
|
#endif
|
|
|
|
return win;
|
|
|
|
}
|
|
|
|
#endif
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2009-01-17 14:28:09 +00:00
|
|
|
|
2008-12-08 05:25:12 +00:00
|
|
|
void DllDebugger(HWND _hParent, bool Show)
|
|
|
|
{
|
2008-12-14 23:52:01 +00:00
|
|
|
#if defined(HAVE_WX) && HAVE_WX
|
2009-07-02 19:00:27 +00:00
|
|
|
if (Show)
|
2009-09-07 12:40:43 +00:00
|
|
|
{
|
|
|
|
if (!m_DebuggerFrame)
|
|
|
|
m_DebuggerFrame = new DSPDebuggerHLE(NULL);
|
|
|
|
//m_DebuggerFrame = new DSPDebuggerHLE(GetParentedWxWindow(_hParent));
|
2009-07-02 19:00:27 +00:00
|
|
|
m_DebuggerFrame->Show();
|
2009-09-07 12:40:43 +00:00
|
|
|
}
|
2009-07-02 19:00:27 +00:00
|
|
|
else
|
2009-09-07 12:40:43 +00:00
|
|
|
{
|
|
|
|
if (m_DebuggerFrame) m_DebuggerFrame->Close();
|
|
|
|
}
|
2008-12-14 23:52:01 +00:00
|
|
|
#endif
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GetDllInfo(PLUGIN_INFO* _PluginInfo)
|
|
|
|
{
|
2009-01-29 01:53:07 +00:00
|
|
|
_PluginInfo->Version = 0x0100;
|
|
|
|
_PluginInfo->Type = PLUGIN_TYPE_DSP;
|
2009-01-15 06:48:15 +00:00
|
|
|
#ifdef DEBUGFAST
|
2009-01-29 01:53:07 +00:00
|
|
|
sprintf(_PluginInfo->Name, "Dolphin DSP-HLE Plugin (DebugFast) ");
|
2008-12-08 05:25:12 +00:00
|
|
|
#else
|
|
|
|
#ifndef _DEBUG
|
2009-01-29 01:53:07 +00:00
|
|
|
sprintf(_PluginInfo->Name, "Dolphin DSP-HLE Plugin ");
|
2008-12-08 05:25:12 +00:00
|
|
|
#else
|
2009-01-29 01:53:07 +00:00
|
|
|
sprintf(_PluginInfo ->Name, "Dolphin DSP-HLE Plugin (Debug) ");
|
2008-12-08 05:25:12 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2009-03-18 17:17:58 +00:00
|
|
|
|
|
|
|
void SetDllGlobals(PLUGIN_GLOBALS* _pPluginGlobals)
|
|
|
|
{
|
|
|
|
globals = _pPluginGlobals;
|
|
|
|
LogManager::SetInstance((LogManager *)globals->logManager);
|
2009-01-08 12:12:15 +00:00
|
|
|
}
|
|
|
|
|
2008-12-08 05:25:12 +00:00
|
|
|
void DllConfig(HWND _hParent)
|
|
|
|
{
|
2009-01-17 21:42:43 +00:00
|
|
|
#if defined(HAVE_WX) && HAVE_WX
|
2009-09-13 08:54:46 +00:00
|
|
|
// Load config settings
|
|
|
|
g_Config.Load();
|
|
|
|
g_Config.GameIniLoad(globals->game_ini);
|
|
|
|
|
2009-07-02 19:00:27 +00:00
|
|
|
if (!m_ConfigFrame)
|
2010-01-01 03:55:39 +00:00
|
|
|
{
|
2010-02-14 14:06:33 +00:00
|
|
|
wxWindow *frame = GetParentedWxWindow(_hParent);
|
|
|
|
m_ConfigFrame = new DSPConfigDialogHLE(frame);
|
2009-07-13 13:37:52 +00:00
|
|
|
|
2010-01-01 03:55:39 +00:00
|
|
|
// add backends
|
|
|
|
std::vector<std::string> backends = AudioCommon::GetSoundBackends();
|
2009-02-14 01:07:20 +00:00
|
|
|
|
2010-01-01 03:55:39 +00:00
|
|
|
for (std::vector<std::string>::const_iterator iter = backends.begin();
|
|
|
|
iter != backends.end(); ++iter)
|
|
|
|
{
|
|
|
|
m_ConfigFrame->AddBackend((*iter).c_str());
|
|
|
|
}
|
2009-07-02 19:00:27 +00:00
|
|
|
|
2010-01-01 03:55:39 +00:00
|
|
|
// Only allow one open at a time
|
2009-07-02 19:00:27 +00:00
|
|
|
m_ConfigFrame->ShowModal();
|
2010-01-01 03:55:39 +00:00
|
|
|
|
|
|
|
delete m_ConfigFrame;
|
2010-02-14 16:44:16 +00:00
|
|
|
#ifdef _WIN32
|
2010-02-14 16:33:53 +00:00
|
|
|
frame->SetHWND(NULL);
|
2010-02-14 16:44:16 +00:00
|
|
|
#endif
|
2010-02-14 14:06:33 +00:00
|
|
|
delete frame;
|
2010-01-01 03:55:39 +00:00
|
|
|
m_ConfigFrame = 0;
|
|
|
|
}
|
2008-12-08 05:25:12 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2009-03-26 09:29:14 +00:00
|
|
|
|
2009-01-15 06:48:15 +00:00
|
|
|
void Initialize(void *init)
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
2009-12-23 15:34:14 +00:00
|
|
|
g_InitMixer = false;
|
2009-01-29 01:53:07 +00:00
|
|
|
g_dspInitialize = *(DSPInitialize*)init;
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2009-02-20 22:04:52 +00:00
|
|
|
g_Config.Load();
|
2009-01-29 01:53:07 +00:00
|
|
|
g_pMemory = g_dspInitialize.pGetMemoryPointer(0);
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2009-08-12 01:15:57 +00:00
|
|
|
g_dspState.Reset();
|
|
|
|
|
2009-01-29 01:53:07 +00:00
|
|
|
CDSPHandler::CreateInstance();
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
|
|
|
|
2009-02-20 22:04:52 +00:00
|
|
|
void DSP_StopSoundStream()
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
2009-02-20 22:04:52 +00:00
|
|
|
}
|
2009-01-29 00:57:55 +00:00
|
|
|
|
2009-02-20 22:04:52 +00:00
|
|
|
void Shutdown()
|
|
|
|
{
|
2009-03-27 14:26:44 +00:00
|
|
|
AudioCommon::ShutdownSoundStream();
|
2009-02-20 22:04:52 +00:00
|
|
|
|
|
|
|
// Delete the UCodes
|
2009-01-29 01:53:07 +00:00
|
|
|
CDSPHandler::Destroy();
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2009-02-20 22:04:52 +00:00
|
|
|
#if defined(HAVE_WX) && HAVE_WX
|
|
|
|
// Reset mails
|
2009-09-07 12:40:43 +00:00
|
|
|
/*
|
2009-07-02 19:00:27 +00:00
|
|
|
if (m_DebuggerFrame)
|
2009-02-20 22:04:52 +00:00
|
|
|
{
|
|
|
|
sMailLog.clear();
|
|
|
|
sMailTime.clear();
|
2009-07-02 19:00:27 +00:00
|
|
|
m_DebuggerFrame->sMail.clear();
|
|
|
|
m_DebuggerFrame->sMailEnd.clear();
|
2009-02-20 22:04:52 +00:00
|
|
|
}
|
2009-09-07 12:40:43 +00:00
|
|
|
*/
|
|
|
|
#endif
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
|
|
|
|
2009-02-14 01:07:20 +00:00
|
|
|
void DoState(unsigned char **ptr, int mode)
|
|
|
|
{
|
2009-01-29 01:53:07 +00:00
|
|
|
PointerWrap p(ptr, mode);
|
2009-12-23 15:34:14 +00:00
|
|
|
p.Do(g_InitMixer);
|
2009-06-20 10:24:49 +00:00
|
|
|
CDSPHandler::GetInstance().GetUCode()->DoState(p);
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
2009-01-17 14:28:09 +00:00
|
|
|
|
Now you can switch between Emulated and Real WiiMotes, connect more Real Wiimotes and even pair them up (if you have MS BT Stack) during gameplay!
All you gotta do is Pause the emulation! That's useful for when your batteries run out during gameplay, for example...
But if you change the WiiMote source (between Emulated, Real or Inactive) you must disconnect and reconnect (Menu Tools -> Connect WiiMote) the WiiMotes affected by the change...
Thanks to jack.fr0st who did all the emulation state notification work!
Now every plugin has a way to know the current emulation state (paused, stopped or playing)
@ayuanx: I thought about doing a PostMessage(g_WiimoteInitialize.hWnd, WM_USER, WIIMOTE_DISCONNECT, current_number); so that the user gets asked to reconnect that WiiMote, trying to avoid having to disconnect and reconnect, but it didn't work because shooting that message only asks to reconnect, doesn't do a disconnect... Do you have any ideas on how to accomplish that?
Also, if anyone could check if Issue 1916 is finally fixed... Or at least when is the cursor being hidden or not...
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4789 8ced0084-cf51-0410-be5f-012b33b47a6e
2010-01-06 19:26:52 +00:00
|
|
|
void EmuStateChange(PLUGIN_EMUSTATE newState)
|
|
|
|
{
|
2010-01-13 14:18:13 +00:00
|
|
|
DSP_ClearAudioBuffer((newState == PLUGIN_EMUSTATE_PLAY) ? false : true);
|
Now you can switch between Emulated and Real WiiMotes, connect more Real Wiimotes and even pair them up (if you have MS BT Stack) during gameplay!
All you gotta do is Pause the emulation! That's useful for when your batteries run out during gameplay, for example...
But if you change the WiiMote source (between Emulated, Real or Inactive) you must disconnect and reconnect (Menu Tools -> Connect WiiMote) the WiiMotes affected by the change...
Thanks to jack.fr0st who did all the emulation state notification work!
Now every plugin has a way to know the current emulation state (paused, stopped or playing)
@ayuanx: I thought about doing a PostMessage(g_WiimoteInitialize.hWnd, WM_USER, WIIMOTE_DISCONNECT, current_number); so that the user gets asked to reconnect that WiiMote, trying to avoid having to disconnect and reconnect, but it didn't work because shooting that message only asks to reconnect, doesn't do a disconnect... Do you have any ideas on how to accomplish that?
Also, if anyone could check if Issue 1916 is finally fixed... Or at least when is the cursor being hidden or not...
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4789 8ced0084-cf51-0410-be5f-012b33b47a6e
2010-01-06 19:26:52 +00:00
|
|
|
}
|
2009-02-14 01:07:20 +00:00
|
|
|
|
2009-01-17 14:28:09 +00:00
|
|
|
// Mailbox fuctions
|
2008-12-08 05:25:12 +00:00
|
|
|
unsigned short DSP_ReadMailboxHigh(bool _CPUMailbox)
|
|
|
|
{
|
2009-01-29 01:53:07 +00:00
|
|
|
if (_CPUMailbox)
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
2009-01-29 01:53:07 +00:00
|
|
|
return (g_dspState.CPUMailbox >> 16) & 0xFFFF;
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
2009-01-29 01:53:07 +00:00
|
|
|
else
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
2009-01-29 01:53:07 +00:00
|
|
|
return CDSPHandler::GetInstance().AccessMailHandler().ReadDSPMailboxHigh();
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned short DSP_ReadMailboxLow(bool _CPUMailbox)
|
|
|
|
{
|
2009-01-29 01:53:07 +00:00
|
|
|
if (_CPUMailbox)
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
2009-01-29 01:53:07 +00:00
|
|
|
return g_dspState.CPUMailbox & 0xFFFF;
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
2009-01-29 01:53:07 +00:00
|
|
|
else
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
2009-01-29 01:53:07 +00:00
|
|
|
return CDSPHandler::GetInstance().AccessMailHandler().ReadDSPMailboxLow();
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DSP_WriteMailboxHigh(bool _CPUMailbox, unsigned short _Value)
|
|
|
|
{
|
2009-01-29 01:53:07 +00:00
|
|
|
if (_CPUMailbox)
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
2009-01-29 01:53:07 +00:00
|
|
|
g_dspState.CPUMailbox = (g_dspState.CPUMailbox & 0xFFFF) | (_Value << 16);
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
2009-01-29 01:53:07 +00:00
|
|
|
else
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
2009-01-29 01:53:07 +00:00
|
|
|
PanicAlert("CPU can't write %08x to DSP mailbox", _Value);
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DSP_WriteMailboxLow(bool _CPUMailbox, unsigned short _Value)
|
|
|
|
{
|
2009-01-29 01:53:07 +00:00
|
|
|
if (_CPUMailbox)
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
2009-01-29 01:53:07 +00:00
|
|
|
g_dspState.CPUMailbox = (g_dspState.CPUMailbox & 0xFFFF0000) | _Value;
|
2009-11-27 15:07:52 +00:00
|
|
|
CDSPHandler::GetInstance().SendMailToDSP(g_dspState.CPUMailbox);
|
|
|
|
// Mail sent so clear MSB to show that it is progressed
|
|
|
|
g_dspState.CPUMailbox &= 0x7FFFFFFF;
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
2009-01-29 01:53:07 +00:00
|
|
|
else
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
2009-01-29 01:53:07 +00:00
|
|
|
PanicAlert("CPU can't write %08x to DSP mailbox", _Value);
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
|
|
|
}
|
2009-02-14 01:07:20 +00:00
|
|
|
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2009-01-17 14:28:09 +00:00
|
|
|
// Other DSP fuctions
|
2008-12-08 05:25:12 +00:00
|
|
|
unsigned short DSP_WriteControlRegister(unsigned short _Value)
|
|
|
|
{
|
2009-12-23 15:34:14 +00:00
|
|
|
UDSPControl Temp(_Value);
|
|
|
|
if (!g_InitMixer)
|
|
|
|
{
|
|
|
|
if (!Temp.DSPHalt && Temp.DSPInit)
|
|
|
|
{
|
2009-12-25 11:59:04 +00:00
|
|
|
unsigned int AISampleRate, DACSampleRate;
|
|
|
|
g_dspInitialize.pGetSampleRate(AISampleRate, DACSampleRate);
|
|
|
|
soundStream = AudioCommon::InitSoundStream(new HLEMixer(AISampleRate, DACSampleRate));
|
2009-12-23 15:34:14 +00:00
|
|
|
if(!soundStream) PanicAlert("Error starting up sound stream");
|
|
|
|
// Mixer is initialized
|
|
|
|
g_InitMixer = true;
|
|
|
|
}
|
|
|
|
}
|
2009-01-29 01:53:07 +00:00
|
|
|
return CDSPHandler::GetInstance().WriteControlRegister(_Value);
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned short DSP_ReadControlRegister()
|
|
|
|
{
|
2009-01-29 01:53:07 +00:00
|
|
|
return CDSPHandler::GetInstance().ReadControlRegister();
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DSP_Update(int cycles)
|
|
|
|
{
|
2009-04-08 18:36:53 +00:00
|
|
|
// This is called OFTEN - better not do anything expensive!
|
|
|
|
CDSPHandler::GetInstance().Update(cycles);
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
|
|
|
|
2009-03-23 20:55:32 +00:00
|
|
|
/* Other Audio will pass through here. The kind of audio that sometimes are
|
|
|
|
used together with pre-drawn movies. This audio can be disabled further
|
|
|
|
inside Mixer_PushSamples(), the reason that we don't disable this entire
|
|
|
|
function when Other Audio is disabled is that then we can't turn it back on
|
|
|
|
again once the game has started. */
|
2009-12-25 11:59:04 +00:00
|
|
|
void DSP_SendAIBuffer(unsigned int address, unsigned int num_samples)
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
2009-12-23 15:34:14 +00:00
|
|
|
if (!soundStream)
|
2009-02-20 22:04:52 +00:00
|
|
|
return;
|
|
|
|
|
2009-03-27 15:33:35 +00:00
|
|
|
CMixer* pMixer = soundStream->GetMixer();
|
2009-12-23 15:34:14 +00:00
|
|
|
|
2009-12-22 07:26:30 +00:00
|
|
|
if (pMixer && address)
|
2009-02-14 01:07:20 +00:00
|
|
|
{
|
2009-12-22 07:26:30 +00:00
|
|
|
short* samples = (short*)Memory_Get_Pointer(address);
|
2009-12-25 11:59:04 +00:00
|
|
|
// Internal sample rate is always 32khz
|
|
|
|
pMixer->PushSamples(samples, num_samples);
|
2009-12-23 15:34:14 +00:00
|
|
|
|
|
|
|
// FIXME: Write the audio to a file
|
|
|
|
//if (log_ai)
|
|
|
|
// g_wave_writer.AddStereoSamples(samples, 8);
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
|
|
|
|
2009-12-23 15:34:14 +00:00
|
|
|
soundStream->Update();
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
2009-03-23 20:55:32 +00:00
|
|
|
|
2010-01-13 14:18:13 +00:00
|
|
|
void DSP_ClearAudioBuffer(bool mute)
|
2009-11-07 20:01:39 +00:00
|
|
|
{
|
2009-11-07 23:51:12 +00:00
|
|
|
if (soundStream)
|
2010-01-13 14:18:13 +00:00
|
|
|
soundStream->Clear(mute);
|
2009-11-07 20:01:39 +00:00
|
|
|
}
|