Fixed Wii AX sound, for real this time

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1169 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
John Peterson 2008-11-14 11:47:17 +00:00
parent 09e168beac
commit 2976f3f1e3
16 changed files with 111 additions and 74 deletions

View File

@ -59,7 +59,7 @@ std::string GetLastErrorAsString()
bool DynamicLibrary::Load(const char* filename)
{
if (!filename || strlen(filename) == 0)
{
{
LOG(MASTER_LOG, "Missing filename of dynamic library to load");
return false;
}
@ -85,7 +85,7 @@ bool DynamicLibrary::Load(const char* filename)
LOG(MASTER_LOG, "Error loading DLL %s: %s", filename, dlerror());
#else
printf("Error loading DLL %s: %s", filename, dlerror());
#endif
#endif
return false;
}
#endif

View File

@ -166,7 +166,7 @@ struct ARDMA
// STATE_TO_SAVE
u8 *g_ARAM = NULL;
u8 *g_ARAM = NULL, *g_MEM2 = NULL;
DSPState g_dspState;
AudioDMA g_audioDMA;
ARDMA g_arDMA;
@ -206,6 +206,7 @@ void Init()
{
// On the Wii, ARAM is simply mapped to EXRAM.
g_ARAM = Memory::GetPointer(0x00000000);
g_MEM2 = Memory::GetPointer(0x10000000);
}
else
{
@ -615,7 +616,9 @@ void Update_ARAM_DMA()
// =============================================================
// This is how it works: The game has written sound to RAM, the DSP will read it with
// this function. SamplePos in the plugin is double the value given here because it
// works on a nibble level.
// works on a nibble level. In Wii addresses can eather be for MEM1 or MEM2, when it wants
// to read from MEM2 it adds 0x2000000 (in nibble terms) to get up to the MEM2 hardware
// address. But in our case we use a second pointer and adjust the value down to 0x00...
// -------------------
u8 ReadARAM(u32 _iAddress)
{
@ -624,9 +627,21 @@ u8 ReadARAM(u32 _iAddress)
// _dbg_assert_(DSPINTERFACE,(_iAddress) < ARAM_SIZE);
if(Core::GetStartupParameter().bWii)
{
//LOGV(DSPINTERFACE, 0, "ARAM (r) 0x%08x 0x%08x 0x%08x", WII_MASK, _iAddress, (_iAddress & WII_MASK));
// Does this make any sense?
if(_iAddress > WII_MASK)
_iAddress = (_iAddress & WII_MASK);
return g_ARAM[_iAddress];
{
if(_iAddress > WII_MASK)
_iAddress = (_iAddress & WII_MASK);
return g_MEM2[_iAddress];
}
else
{
if(_iAddress > WII_MASK)
_iAddress = (_iAddress & WII_MASK);
return g_ARAM[_iAddress];
}
}
else
return g_ARAM[_iAddress & ARAM_MASK];
@ -636,7 +651,7 @@ u8* GetARAMPtr()
{
return g_ARAM;
}
// ===================
void WriteARAM(u8 _iValue, u32 _iAddress)
@ -650,4 +665,4 @@ void WriteARAM(u8 _iValue, u32 _iAddress)
}
} // end of namespace DSP
// ===================

View File

@ -112,7 +112,7 @@ void CPluginManager::OpenDebug(void* _Parent, const char *_rFilename)
if (Common::CPlugin::Load(_rFilename))
{
Common::CPlugin::Debug((HWND)_Parent);
Common::CPlugin::Release();
//Common::CPlugin::Release(); // this is only if the wx dialog is called with ShowModal()
}
}

View File

@ -250,7 +250,6 @@ Global
{48AD7E0A-25B1-4974-A1E3-03F8C438D34F}.DebugFast|Win32.ActiveCfg = DebugFast|Win32
{48AD7E0A-25B1-4974-A1E3-03F8C438D34F}.DebugFast|Win32.Build.0 = DebugFast|Win32
{48AD7E0A-25B1-4974-A1E3-03F8C438D34F}.DebugFast|x64.ActiveCfg = DebugFast|x64
{48AD7E0A-25B1-4974-A1E3-03F8C438D34F}.DebugFast|x64.Build.0 = DebugFast|x64
{48AD7E0A-25B1-4974-A1E3-03F8C438D34F}.Release|Win32.ActiveCfg = Release|Win32
{48AD7E0A-25B1-4974-A1E3-03F8C438D34F}.Release|Win32.Build.0 = Release|Win32
{48AD7E0A-25B1-4974-A1E3-03F8C438D34F}.Release|x64.ActiveCfg = Release|x64
@ -262,7 +261,6 @@ Global
{0318BA30-EF48-441A-9E10-DC85EFAE39F0}.DebugFast|Win32.ActiveCfg = DebugFast|Win32
{0318BA30-EF48-441A-9E10-DC85EFAE39F0}.DebugFast|Win32.Build.0 = DebugFast|Win32
{0318BA30-EF48-441A-9E10-DC85EFAE39F0}.DebugFast|x64.ActiveCfg = DebugFast|x64
{0318BA30-EF48-441A-9E10-DC85EFAE39F0}.DebugFast|x64.Build.0 = DebugFast|x64
{0318BA30-EF48-441A-9E10-DC85EFAE39F0}.Release|Win32.ActiveCfg = Release|Win32
{0318BA30-EF48-441A-9E10-DC85EFAE39F0}.Release|Win32.Build.0 = Release|Win32
{0318BA30-EF48-441A-9E10-DC85EFAE39F0}.Release|x64.ActiveCfg = Release|x64

View File

@ -138,13 +138,6 @@ CDebugger::CDebugger(wxWindow *parent, wxWindowID id, const wxString &title,
//wxEVT_RIGHT_DOWN, wxEVT_MOUSEWHEEL, wxEVT_LEFT_UP,
//m_bl95, m_PageBlock, sBlock
/*
for (int i = 0; i < 127; ++i)
{
m_bl0->AppendText(wxString::Format("%02i|68 : 01a70144\n", i));
m_bl95->AppendText(wxString::Format("%i Mouse\n", i));
}*/
m_bl95->Connect(wxID_ANY, wxEVT_SCROLLWIN_THUMBTRACK,
wxScrollWinEventHandler(CDebugger::ScrollBlocksCursor), (wxObject*)NULL, this);
m_bl95->Connect(wxID_ANY, wxEVT_SCROLLWIN_THUMBRELEASE,
@ -729,7 +722,8 @@ void CDebugger::ChangeMail(wxCommandEvent& event)
void CDebugger::ReadDir()
{
CFileSearch::XStringVector Directories;
Directories.push_back("Logs/Mail");
//Directories.push_back("Logs/Mail");
Directories.push_back(FULL_MAIL_LOGS_DIR);
CFileSearch::XStringVector Extensions;
Extensions.push_back("*.log");
@ -857,7 +851,7 @@ std::string CDebugger::Readfile_(std::string FileName)
// Read file
void CDebugger::Readfile(std::string FileName, bool GC)
{
int n = CountFiles(FileName);
int n = CountFiles(FileName); // count how many mails we have
int curr_n = 0;
std::ifstream file;
for (int i = 0; i < m_RadioBox[3]->GetCount(); i++)
@ -897,12 +891,13 @@ void CDebugger::Readfile(std::string FileName, bool GC)
// =======================================================================================
// Only allow one selected game at a time
// Read the file to the text window
// ---------------
void CDebugger::OnGameChange(wxCommandEvent& event)
{
if(event.GetId() == 2006)
{
// Only allow one selected game at a time
for (int i = 0; i < m_gc->GetCount(); ++i)
if(i != event.GetInt()) m_gc->Check(i, false);
for (int i = 0; i < m_wii->GetCount(); ++i)

View File

@ -532,7 +532,7 @@ void CUCode_AX::Logging(short* _pBuffer, int _iSize, int a, bool Wii)
/**/
AXParamBlock PBs[64];
AXParamBlockWii PBw[NUMBER_OF_PBS];
int numberOfPBsWii = ReadOutPBsWii(m_addressPBs, PBw, NUMBER_OF_PBS - 1);
int numberOfPBsWii = ReadOutPBsWii(m_addressPBs, PBw, NUMBER_OF_PBS, true);
int numberOfPBsGC = ReadOutPBs(m_addressPBs, PBs, 64);

View File

@ -16,6 +16,7 @@
// http://code.google.com/p/dolphin-emu/
#include "FileUtil.h" // for IsDirectory
#include "StringUtil.h" // for StringFromFormat
#include "../Debugger/Debugger.h"
#include "../Logging/Console.h" // for aprintf
#include <sstream>
@ -119,7 +120,9 @@ if(m_frame->ScanMails)
ci << (saveNext - 1);
TmpMailLog += "\n\n";
TmpMailLog += "-----------------------------------------------------------------------\n";
TmpMailLog += "Current mail: " + gpName + " mail " + ci.str() + "\n\n";
TmpMailLog += "Current mail: " + gpName + " mail " + ci.str() + "\n";
if(Wii)
TmpMailLog += "Current CRC: " + StringFromFormat("0x%08x \n\n", _CRC);
for (int i = 0; i < sMailTime.size(); i++)
{
@ -143,7 +146,7 @@ if(m_frame->ScanMails)
{
TmpMailLog += Msg;
TmpMailLog += "\n";
LOG_(1, Msg);
LOG_(1, Msg); // also write it to the log
}
}
}

View File

@ -48,6 +48,7 @@ public:
// PBs
u32 m_addressPBs;
u32 _CRC;
private:
enum

View File

@ -79,7 +79,7 @@ struct PBDpop
s16 unknown[12];
};
struct PBDpopWii_
struct PBDpopWii_ // new CRC version
{
s16 unknown[7];
};
@ -204,7 +204,7 @@ struct AXParamBlockWii
/* 106 */ u16 pad[22];
};
struct AXParamBlockWii_
struct AXParamBlockWii_ // new CRC version
{
u16 next_pb_hi;
u16 next_pb_lo;

View File

@ -54,6 +54,7 @@ CUCode_AXWii::CUCode_AXWii(CMailHandler& _rMailHandler, u32 _CRC)
temprbuffer = new int[1024 * 1024];
lCUCode_AX = new CUCode_AX(_rMailHandler);
lCUCode_AX->_CRC = _CRC;
_CRC = _CRC;
}
@ -86,6 +87,7 @@ void CUCode_AXWii::MixAdd(short* _pBuffer, int _iSize)
}
else
{
//LOG_(0, "else");
AXParamBlockWii_ PBs[NUMBER_OF_PBS];
MixAdd_(_pBuffer, _iSize, PBs);
}
@ -99,7 +101,7 @@ void CUCode_AXWii::MixAdd_(short* _pBuffer, int _iSize, ParamBlockType &PBs)
//AXParamBlockWii PBs[NUMBER_OF_PBS];
// read out pbs
int numberOfPBs = ReadOutPBsWii(m_addressPBs, PBs, NUMBER_OF_PBS);
int numberOfPBs = ReadOutPBsWii(m_addressPBs, PBs, NUMBER_OF_PBS, false);
if (_iSize > 1024 * 1024)
_iSize = 1024 * 1024;
@ -194,10 +196,9 @@ void CUCode_AXWii::MixAdd_(short* _pBuffer, int _iSize, ParamBlockType &PBs)
//MixAddVoice(pb, templbuffer, temprbuffer, _iSize);
MixAddVoice(PBs[i], templbuffer, temprbuffer, _iSize);
}
}
}
WriteBackPBsWii(m_addressPBs, PBs, numberOfPBs);
// We write the sound to _pBuffer
for (int i = 0; i < _iSize; i++)
{
@ -350,7 +351,7 @@ bool CUCode_AXWii::AXTask(u32& _uMail)
Addr__AXOutSBuffer = Memory_Read_U32(uAddress);
uAddress += 10;
// uAddress += 12;
DebugLog("%08x : AXLIST OutSBuffer (0x0007) address: %08x", uAddress, Addr__AXOutSBuffer);
SaveLog("%08x : AXLIST OutSBuffer (0x0007) address: %08x", uAddress, Addr__AXOutSBuffer);
break;
/* case 0x0009:

View File

@ -26,12 +26,11 @@
// -----------
extern bool gSequenced;
extern bool gVolume;
extern float ratioFactor;
template<class ParamBlockType>
inline int ReadOutPBsWii(u32 pbs_address, ParamBlockType& _pPBs, int _num)
inline int ReadOutPBsWii(u32 pbs_address, ParamBlockType& _pPBs, int _num, int _deb)
//int ReadOutPBsWii(u32 pbs_address, AXParamBlockWii* _pPBs, int _num)
{
int count = 0;
@ -50,14 +49,13 @@ inline int ReadOutPBsWii(u32 pbs_address, ParamBlockType& _pPBs, int _num)
for (int p = 0; p < sizeof(AXParamBlockWii) / 2; p++)
{
if(p == 6 || p == 7) pDest[p] = pSrc[p]; // control for the u32
//else if(p == 62 || p == 63 || p == 64 || p == 65 || p == 66 || p == 67)
// pDest[p] = Common::swap16(pSrc[p-1]);
else pDest[p] = Common::swap16(pSrc[p]);
#if defined(_DEBUG) || defined(DEBUGFAST)
gLastBlock = blockAddr + p*2 + 2; // save last block location
#endif
}
}
_pPBs[i].mixer_control = Common::swap32(_pPBs[i].mixer_control);
blockAddr = (_pPBs[i].next_pb_hi << 16) | _pPBs[i].next_pb_lo;
count++;
@ -88,10 +86,8 @@ inline void WriteBackPBsWii(u32 pbs_address, ParamBlockType& _pPBs, int _num)
_pPBs[i].mixer_control = Common::swap32(_pPBs[i].mixer_control);
for (size_t p = 0; p < sizeof(AXParamBlockWii) / 2; p++)
{
if(p == 6 || p == 7) pDest[p] = pSrc[p]; // control for the u32
//else if(p == 62 || p == 63 || p == 64 || p == 65 || p == 66 || p == 67)
// pDest[p-1] = Common::swap16(pSrc[p]);
else pDest[p] = Common::swap16(pSrc[p]);
if(p == 6 || p == 7) pDest[p] = pSrc[p]; // control for the u32
else pDest[p] = Common::swap16(pSrc[p]);
}
// next block
@ -100,18 +96,13 @@ inline void WriteBackPBsWii(u32 pbs_address, ParamBlockType& _pPBs, int _num)
}
template<class ParamBlockType>
inline void MixAddVoice(ParamBlockType &pb, int *templbuffer, int *temprbuffer, int _iSize)
{
#ifdef _WIN32
float ratioFactor = 32000.0f / (float)DSound::DSound_GetSampleRate();
ratioFactor = 32000.0f / (float)DSound::DSound_GetSampleRate();
#else
float ratioFactor = 32000.0f / 44100.0f;
ratioFactor = 32000.0f / 44100.0f;
#endif
// DoVoiceHacks(pb);
@ -123,7 +114,7 @@ inline void MixAddVoice(ParamBlockType &pb, int *templbuffer, int *temprbuffer,
// =======================================================================================
// Read initial parameters
// ------------
//constants
//constants
const u32 ratio = (u32)(((pb.src.ratio_hi << 16) + pb.src.ratio_lo) * ratioFactor);
u32 sampleEnd = (pb.audio_addr.end_addr_hi << 16) | pb.audio_addr.end_addr_lo;
u32 loopPos = (pb.audio_addr.loop_addr_hi << 16) | pb.audio_addr.loop_addr_lo;
@ -132,7 +123,7 @@ inline void MixAddVoice(ParamBlockType &pb, int *templbuffer, int *temprbuffer,
u32 samplePos = (pb.audio_addr.cur_addr_hi << 16) | pb.audio_addr.cur_addr_lo;
u32 frac = pb.src.cur_addr_frac;
// =============
// =======================================================================================
// Handle no-src streams - No src streams have pb.src_type == 2 and have pb.src.ratio_hi = 0
// and pb.src.ratio_lo = 0. We handle that by setting the sampling ratio integer to 1. This
@ -155,6 +146,7 @@ inline void MixAddVoice(ParamBlockType &pb, int *templbuffer, int *temprbuffer,
}
// =============
// =======================================================================================
// Games that use looping to play non-looping music streams - SSBM has info in all
// pb.adpcm_loop_info parameters but has pb.audio_addr.looping = 0. If we treat these streams
@ -278,7 +270,6 @@ inline void MixAddVoice(ParamBlockType &pb, int *templbuffer, int *temprbuffer,
}
}
// ===============
} // end of the _iSize loop
// Update volume
@ -292,6 +283,7 @@ inline void MixAddVoice(ParamBlockType &pb, int *templbuffer, int *temprbuffer,
pb.src.cur_addr_frac = (u16)frac;
pb.audio_addr.cur_addr_hi = samplePos >> 16;
pb.audio_addr.cur_addr_lo = (u16)samplePos;
} // if (pb.running)
}

View File

@ -119,7 +119,6 @@ BOOL APIENTRY DllMain(HINSTANCE hinstDLL, // DLL module handle
g_hInstance = hinstDLL;
return(TRUE);
}
#endif
@ -154,7 +153,7 @@ CDebugger* m_frame;
void DllDebugger(HWND _hParent)
{
m_frame = new CDebugger(NULL);
m_frame->ShowModal();
m_frame->Show();
}
// ===================

View File

@ -16,14 +16,15 @@
#define IDC_HALT 1005
#define IDC_HALT2 1006
#define IDC_INIT 1006
#define IDC_GROUP 1007
// Next default values for new objects
//
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 202
#define _APS_NEXT_COMMAND_VALUE 32772
#define _APS_NEXT_CONTROL_VALUE 1004
#define _APS_NEXT_CONTROL_VALUE 1008
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View File

@ -52,7 +52,7 @@ LRESULT CDisAsmDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lPar
{
ws.ApplyTo(CWindow(m_hWnd), SW_SHOW);
}
m_DisAsmListViewCtrl.m_hWnd = GetDlgItem(IDC_DISASM_LIST);
UIAddChildWindowContainer(m_hWnd);
@ -79,6 +79,8 @@ LRESULT CDisAsmDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lPar
UpdateDialog();
DlgResize_Init(true, false, WS_THICKFRAME);
return(TRUE);
}
@ -257,7 +259,7 @@ void CDisAsmDlg::RebuildDisAsmListView()
m_DisAsmListViewCtrl.AddItem(Item, ColumnMenmomic, Temp2);
m_DisAsmListViewCtrl.AddItem(Item, ColumnOpcode, pOpcode);
m_DisAsmListViewCtrl.AddItem(Item, ColumnExt, pExtension);
if (!_stricmp(pOpcode, "CALL"))
{
uint32 FunctionAddress = -1;
@ -638,3 +640,28 @@ void CDisAsmDlg::UpdateDialog()
// UpdateButtonTexts();
UpdateRegisterFlags();
}
LRESULT CDisAsmDlg::OnLvnItemchangedDisasmList(int /*idCtrl*/, LPNMHDR pNMHDR, BOOL& /*bHandled*/)
{
LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
// TODO: Add your control notification handler code here
return 0;
}
// TODO: make the members adjust with the dialog
LRESULT CDisAsmDlg::OnSize(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/)
{
// we habe to make a group of the items I think
/*
CRect lpRect;
int wid = lpRect.right - lpRect.left - 100;
int hei = lpRect.bottom - lpRect.top - 20;
m_DisAsmListViewCtrl.ResizeClient(wid, hei, true);
*/
return 0;
}

View File

@ -25,7 +25,7 @@
#include "RegisterDlg.h"
class CDisAsmDlg
: public CDialogImpl<CDisAsmDlg>, public CUpdateUI<CDisAsmDlg>
: public CDialogImpl<CDisAsmDlg>, public CUpdateUI<CDisAsmDlg>, public CDialogResize<CDisAsmDlg>
{
public:
@ -40,6 +40,10 @@ class CDisAsmDlg
BEGIN_UPDATE_UI_MAP(CDisAsmDlg)
END_UPDATE_UI_MAP()
BEGIN_DLGRESIZE_MAP(CDisAsmDlg)
DLGRESIZE_CONTROL(IDR_MAINFRAME, DLSZ_SIZE_X | DLSZ_SIZE_Y)
END_DLGRESIZE_MAP()
BEGIN_MSG_MAP(CDisAsmDlg)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
@ -50,6 +54,10 @@ class CDisAsmDlg
NOTIFY_CODE_HANDLER(NM_RETURN, OnDblClick)
NOTIFY_CODE_HANDLER(NM_RCLICK, OnRClick)
NOTIFY_CODE_HANDLER(NM_CUSTOMDRAW, OnCustomDraw)
NOTIFY_HANDLER(IDC_DISASM_LIST, LVN_ITEMCHANGED, OnLvnItemchangedDisasmList)
MESSAGE_HANDLER(WM_SIZE, OnSize)
CHAIN_MSG_MAP(CDialogResize<CDisAsmDlg>)
END_MSG_MAP()
// Handler prototypes (uncomment arguments if needed):
@ -100,6 +108,8 @@ class CDisAsmDlg
CListViewCtrl m_DisAsmListViewCtrl;
CRegisterDlg m_RegisterDlg;
//CWindow GroupLeft
CStatic GroupLeft;
uint64 m_CachedStepCounter;
uint16 m_CachedCR;
@ -147,4 +157,7 @@ class CDisAsmDlg
void UpdateDialog();
static int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort);
public:
LRESULT OnLvnItemchangedDisasmList(int /*idCtrl*/, LPNMHDR pNMHDR, BOOL& /*bHandled*/);
LRESULT OnSize(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
};

View File

@ -127,23 +127,15 @@ void DllDebugger(HWND _hParent)
{
#ifdef _WIN32
#if defined (_DEBUG) || defined (DEBUGFAST)
if(bCanWork)
{
g_Dialog.Create(NULL); //_hParent);
g_Dialog.ShowWindow(SW_SHOW);
// Open the console window
startConsoleWin(155, 100, "Sound Debugging"); // give room for 100 rows
wprintf("DllDebugger > Console opened\n");
// TODO: Make this adjustable from the Debugging window
MoveWindow(GetConsoleHwnd(), 0,400, 1280,500, true);
}
else
{
// TODO: let us open the debugging window when we open the Dolphin-Debugger, fix the crash
// that currently occurs of you try to do that
MessageBox(0, "Can't open debugging window yet. Please start a game first", "DSP LLE", 0);
}
g_Dialog.Create(NULL); //_hParent);
g_Dialog.ShowWindow(SW_SHOW);
MoveWindow(g_Dialog.m_hWnd, 450,0, 780,530, true);
// Open the console window
startConsoleWin(155, 100, "Sound Debugging"); // give room for 100 rows
wprintf("DllDebugger > Console opened\n");
// TODO: Make this adjustable from the Debugging window
MoveWindow(GetConsoleHwnd(), 0,400, 1280,500, true);
#else
MessageBox(0, "Can't open debugging window in Release build of this plugin.", "DSP LLE", 0);
#endif