Fixed Wii Sound

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1160 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
John Peterson 2008-11-13 13:45:32 +00:00
parent 11053cb1f7
commit 1184d16864
19 changed files with 430 additions and 124 deletions

View File

@ -238,7 +238,6 @@ void Host_UpdateLogDisplay();
#ifdef LOGGING
#define LOG(t, ...) __Log(LogTypes::t, __VA_ARGS__);
//#define LOGV(t,v, ...) __Log(LogTypes::t + v*100, __VA_ARGS__);
#define LOGV(t,v, ...) __Logv(LogTypes::t, v, __VA_ARGS__);
#define _dbg_assert_(_t_, _a_) \

View File

@ -72,7 +72,7 @@ namespace Core
//void Callback_VideoRequestWindowSize(int _iWidth, int _iHeight, BOOL _bFullscreen);
void Callback_VideoLog(const TCHAR* _szMessage, BOOL _bDoBreak);
void Callback_VideoCopiedToXFB();
void Callback_DSPLog(const TCHAR* _szMessage);
void Callback_DSPLog(const TCHAR* _szMessage, int _v);
char * Callback_ISOName(void);
void Callback_DSPInterrupt();
void Callback_PADLog(const TCHAR* _szMessage);
@ -537,9 +537,9 @@ void Callback_VideoCopiedToXFB()
// __________________________________________________________________________________________________
// Callback_DSPLog
// WARNING - THIS MAY EXECUTED FROM DSP THREAD
void Callback_DSPLog(const TCHAR* _szMessage)
void Callback_DSPLog(const TCHAR* _szMessage, int _v)
{
LOG(AUDIO, _szMessage);
LOGV(AUDIO, _v, _szMessage);
}
// __________________________________________________________________________________________________

View File

@ -176,13 +176,13 @@ void CISOProperties::CreateGUIControls()
{
m_Close = new wxButton(this, ID_CLOSE, _("Close"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
// Notebook
m_Notebook = new wxNotebook(this, ID_NOTEBOOK, wxDefaultPosition, wxDefaultSize);
m_GameConfig = new wxPanel(m_Notebook, ID_GAMECONFIG, wxDefaultPosition, wxDefaultSize);
m_Notebook->AddPage(m_GameConfig, _("GameConfig"));
m_Information = new wxPanel(m_Notebook, ID_INFORMATION, wxDefaultPosition, wxDefaultSize);
// Notebook
m_Notebook = new wxNotebook(this, ID_NOTEBOOK, wxDefaultPosition, wxDefaultSize);
m_GameConfig = new wxPanel(m_Notebook, ID_GAMECONFIG, wxDefaultPosition, wxDefaultSize);
m_Notebook->AddPage(m_GameConfig, _("GameConfig"));
m_Information = new wxPanel(m_Notebook, ID_INFORMATION, wxDefaultPosition, wxDefaultSize);
m_Notebook->AddPage(m_Information, _("Info"));
m_Filesystem = new wxPanel(m_Notebook, ID_FILESYSTEM, wxDefaultPosition, wxDefaultSize);
m_Filesystem = new wxPanel(m_Notebook, ID_FILESYSTEM, wxDefaultPosition, wxDefaultSize);
m_Notebook->AddPage(m_Filesystem, _("Filesystem"));
wxBoxSizer* sButtons;

View File

@ -26,10 +26,10 @@
#include <wx/treectrl.h>
#include <wx/gbsizer.h>
#include <wx/notebook.h>
#include <string>
#include "Filesystem.h"
#include "IniFile.h"
#include <string>
#include "Filesystem.h"
#include "IniFile.h"
#undef ISOPROPERTIES_STYLE
#define ISOPROPERTIES_STYLE wxCAPTION | wxSYSTEM_MENU | wxDIALOG_NO_PARENT | wxCLOSE_BOX

View File

@ -11,8 +11,8 @@
typedef unsigned char (*TARAM_Read_U8)(const unsigned int _uAddress);
typedef unsigned char* (*TGetMemoryPointer)(const unsigned int _uAddress);
typedef unsigned char* (*TGetARAMPointer)(void);
typedef void (*TLog)(const char* _szMessage);
typedef char * (*TName)(void);
typedef void (*TLogv)(const char* _szMessage, int _v);
typedef char* (*TName)(void);
typedef void (*TDebuggerBreak)(void);
typedef void (*TGenerateDSPInt)(void);
typedef unsigned int(*TAudioGetStreaming)(short* _pDestBuffer, unsigned int _numSamples);
@ -23,7 +23,7 @@ typedef struct
TARAM_Read_U8 pARAM_Read_U8;
TGetMemoryPointer pGetMemoryPointer;
TGetARAMPointer pGetARAMPointer;
TLog pLog;
TLogv pLog;
TName pName;
TDebuggerBreak pDebuggerBreak;
TGenerateDSPInt pGenerateDSPInterrupt;

View File

@ -132,7 +132,7 @@
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\..\Externals\wxWidgets\Include; ..\..\..\Externals\wxWidgets\Include\msvc;../../../Externals/WTL80;../../Core/Common/Src;../../PluginSpecs"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;DSP_HLE_EXPORTS;_SECURE_SCL=0"
PreprocessorDefinitions="LOGGING;WIN32;_DEBUG;_WINDOWS;_USRDLL;DSP_HLE_EXPORTS;_SECURE_SCL=0"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
@ -492,7 +492,7 @@
FavorSizeOrSpeed="1"
OmitFramePointers="true"
AdditionalIncludeDirectories="..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;../../../Externals/WTL80;../../Core/Common/Src;../../PluginSpecs"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;DSP_HLE_EXPORTS;DEBUGFAST;_SECURE_SCL=0"
PreprocessorDefinitions="LOGGING;WIN32;NDEBUG;_WINDOWS;_USRDLL;DSP_HLE_EXPORTS;DEBUGFAST;_SECURE_SCL=0"
RuntimeLibrary="0"
BufferSecurityCheck="false"
FloatingPointModel="0"

View File

@ -70,6 +70,14 @@ BEGIN_EVENT_TABLE(CDebugger,wxDialog)
EVT_CHECKLISTBOX(IDC_CHECKLIST2, CDebugger::OnGameChange) // gc
EVT_CHECKLISTBOX(IDC_CHECKLIST3, CDebugger::OnGameChange) // wii
EVT_CHECKLISTBOX(IDC_CHECKLIST4, CDebugger::MailSettings) // settings
//EVT_RIGHT_DOWN(CDebugger::ScrollBlocks)
//EVT_LEFT_DOWN(CDebugger::ScrollBlocks)
//EVT_MOUSE_EVENTS(CDebugger::ScrollBlocks)
//EVT_MOTION(CDebugger::ScrollBlocks)
//EVT_SCROLL(CDebugger::ScrollBlocks)
//EVT_SCROLLWIN(CDebugger::ScrollBlocks)
END_EVENT_TABLE()
// =======================================================================================
@ -81,6 +89,11 @@ CDebugger::CDebugger(wxWindow *parent, wxWindowID id, const wxString &title,
//, gUpdFreq(5) // loaded from file
, gPreset(0)
, giShowAll(-1)
, upd95(false) // block view settings
, upd94(false)
, upd93(false)
, upd92(false)
{
CreateGUIControls();
@ -88,6 +101,58 @@ CDebugger::CDebugger(wxWindow *parent, wxWindowID id, const wxString &title,
IniFile file;
file.Load(DEBUGGER_CONFIG_FILE);
this->Load(file);
// append block names
PBn.resize(266/2);
PBn[10] = "mixer";
PBn[34] = "initial_time_delay";
PBn[41] = "updates";
PBn[46] = "dpop";
PBn[58] = "vol_env";
PBn[60] = "audio_addr";
PBn[68] = "adpcm";
PBn[88] = "src";
PBn[95] = "adpcm_loop_info";
PBn[98] = "lpf";
PBn[102] = "hpf";
PBn[106] = "pad";
PBp.resize(266/2);
PBp[10] = "volume_left, unknown";
PBp[58] = "cur_volume, cur_volume_delta"; // PBVolumeEnvelope
PBp[60] = "looping, sample_format"; // PBAudioAddr
PBp[62] = "loop_addr_hi, loop_addr_lo";
PBp[64] = "end_addr_hi, end_addr_lo";
PBp[66] = "cur_addr_hi, cur_addr_lo";
PBp[68] = "coef[0], coef[1]"; // PBADPCMInfo
PBp[94] = "cur_addr_frac, last_samples[0]";
PBp[94] = "last_samples[3], pred_scale";
PBp[96] = "yn1, yn2";
//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,
wxScrollWinEventHandler(CDebugger::ScrollBlocksCursor), (wxObject*)NULL, this);
m_bl95->Connect(wxID_ANY, wxEVT_MOTION,
wxMouseEventHandler(CDebugger::ScrollBlocksMouse), (wxObject*)NULL, this);
m_bl95->Connect(wxID_ANY, wxEVT_MOUSEWHEEL,
wxMouseEventHandler(CDebugger::ScrollBlocksMouse), (wxObject*)NULL, this);
}
CDebugger::~CDebugger()
@ -159,8 +224,9 @@ SetTitle(wxT("Sound Debugging"));
Center();
// Declarations
wxBoxSizer * sMAIN, * sMain, * sMail;
// Declarations
wxBoxSizer * sMAIN, * sMain, * sMail, * sBlock;
wxButton* m_Upd;
wxButton* m_SelC;
wxButton* m_Presets;
@ -176,6 +242,31 @@ SetTitle(wxT("Sound Debugging"));
m_Notebook->AddPage(m_PageMain, wxT("Main"));
m_PageMail = new wxPanel(m_Notebook, ID_PAGEMAIL, wxDefaultPosition, wxDefaultSize);
m_Notebook->AddPage(m_PageMail, wxT("Mail"));
m_PageBlock = new wxPanel(m_Notebook, ID_PAGEBLOCK, wxDefaultPosition, wxDefaultSize);
m_Notebook->AddPage(m_PageBlock, wxT("Blocks"));
// ===================================================================
// Blocks Page
wxStaticBoxSizer * m_bl0Sizer = new wxStaticBoxSizer (wxVERTICAL, m_PageBlock, wxT("Block"));
m_bl0 = new wxTextCtrl(m_PageBlock, ID_BL0, _T(""), wxDefaultPosition, wxSize(250, 120),
wxTE_RICH | wxTE_MULTILINE | wxTE_READONLY | wxTE_DONTWRAP | wxNO_BORDER);
m_bl0Sizer->Add(m_bl0, 1, wxEXPAND | wxALL, 0);
wxStaticBoxSizer * m_bl1Sizer = new wxStaticBoxSizer (wxVERTICAL, m_PageBlock, wxT("Block 95"));
m_bl95 = new wxTextCtrl(m_PageBlock, ID_BL95, _T(""), wxDefaultPosition, wxSize(300, 120),
wxTE_RICH | wxTE_MULTILINE | wxTE_READONLY | wxTE_DONTWRAP | wxNO_BORDER);
m_bl1Sizer->Add(m_bl95, 1, wxEXPAND | wxALL, 0);
wxStaticBoxSizer * m_bl2Sizer = new wxStaticBoxSizer (wxVERTICAL, m_PageBlock, wxT("Block 94"));
m_bl94 = new wxTextCtrl(m_PageBlock, ID_BL94, _T(""), wxDefaultPosition, wxSize(300, 120),
wxTE_RICH | wxTE_MULTILINE | wxTE_DONTWRAP | wxNO_BORDER );
m_bl2Sizer->Add(m_bl94, 1, wxEXPAND | wxALL, 0);
@ -377,6 +468,11 @@ SetTitle(wxT("Sound Debugging"));
wxLC_REPORT | wxSUNKEN_BORDER | wxLC_ALIGN_LEFT | wxLC_SINGLE_SEL | wxLC_SORT_ASCENDING);
sLeft->Add(m_GPRListView, 1, wxEXPAND|wxALL, 5);
sMain = new wxBoxSizer(wxHORIZONTAL);
sMain->Add(sLeft, 1, wxEXPAND | wxALL, 5); // margin = 5
sMain->Add(sButtons, 0, wxALL, 0);
sMain->Add(sButtons2, 0, wxALL, 5); // margin = 5
// --------------------------------------------------------------------
@ -399,25 +495,41 @@ SetTitle(wxT("Sound Debugging"));
// --------------------------------------------------------------------
// --------------------------------------------------------------------
// The blocks view container (BLOCKS)
// -----------------------------
// For the buttons on the right
//wxBoxSizer * sMailRight = new wxBoxSizer(wxVERTICAL);
//wxStaticBoxSizer * sMailRight = new wxStaticBoxSizer(wxVERTICAL, m_PageMail, wxT("Current"));
sBlock = new wxBoxSizer(wxHORIZONTAL);
sBlock->Add(m_bl0Sizer, 0, wxEXPAND | (wxUP | wxDOWN), 5); // margin = 5
sBlock->Add(m_bl1Sizer, 1, wxEXPAND | (wxUP | wxDOWN | wxLEFT), 5); // margin = 5
sBlock->Add(m_bl2Sizer, 1, wxEXPAND | (wxUP | wxDOWN | wxRIGHT), 5); // margin = 5
//sBlock->Add(sMailRight, 0, wxEXPAND | wxALL, 0); // margin = 0
/*sMailRight->Add(m_RadioBox[3], 0, wxALL, 5); // margin = 5
sMailRight->Add(m_gameSizer1, 1, wxEXPAND | wxALL, 5); // margin = 5
sMailRight->Add(m_gameSizer2, 1, wxEXPAND | wxALL, 5); // margin = 5
sMailRight->Add(m_gameSizer3, 0, wxALL, 5); // margin = 5*/
// --------------------------------------------------------------------
// --------------------------------------------------------------------
// Main containers
// -----------------------------
sMain = new wxBoxSizer(wxHORIZONTAL);
sMain->Add(sLeft, 1, wxEXPAND | wxALL, 5); // margin = 5
sMain->Add(sButtons, 0, wxALL, 0);
sMain->Add(sButtons2, 0, wxALL, 5); // margin = 5
sMAIN = new wxBoxSizer(wxVERTICAL);
sMAIN->Add(m_Notebook, 1, wxEXPAND | wxALL, 5);
//sMAIN->SetSizeHints(this);
this->SetSizer(sMAIN);
//this->Layout();
m_PageMain->SetSizer(sMain);
m_PageMail->SetSizer(sMail);
m_PageBlock->SetSizer(sBlock);
//sMain->Layout();
this->SetSizer(sMAIN);
//this->Layout();
NotifyUpdate();
// --------------------------------------------------------------------
}
@ -818,4 +930,53 @@ void CDebugger::MailSettings(wxCommandEvent& event)
ScanMails = m_gcwiiset->IsChecked(0);
StoreMails = m_gcwiiset->IsChecked(1);
}
//double A;
void CDebugger::DoScrollBlocks()
{
// ShowPosition = in letters
// GetScrollPos = number of lines from the top
// GetLineLength = letters in one line
// SetScrollPos = only set the scrollbar, doesn't update the text,
// Update() or Refresh() doesn't help
double pos = m_bl95->GetScrollPos(wxVERTICAL)*(m_bl95->GetLineLength(0)+12.95); // annoying :(
m_bl0->ShowPosition((int)pos);
/*
if(GetAsyncKeyState(VK_NUMPAD1))
A -= 0.1;
else if(GetAsyncKeyState(VK_NUMPAD2))
A += 0.11;
wprintf("GetScrollPos:%i GetScrollRange:%i GetPosition:%i GetLastPosition:%i GetMaxWidth:%i \
GetLineLength:%i XYToPosition:%i\n \
GetScrollPos * GetLineLength + GetScrollRange:%i A:%f\n",
m_bl95->GetScrollPos(wxVERTICAL), m_bl95->GetScrollRange(wxVERTICAL),
m_bl95->GetPosition().y, m_bl95->GetLastPosition(), m_bl95->GetMaxWidth(),
m_bl95->GetLineLength(0), m_bl95->XYToPosition(0,25),
pos, A
);
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));
}*/
}
void CDebugger::ScrollBlocksMouse(wxMouseEvent& event)
{
DoScrollBlocks();
event.Skip(); // otherwise we remove the regular behavior, for example scrolling
}
void CDebugger::ScrollBlocksCursor(wxScrollWinEvent& event)
{
DoScrollBlocks();
event.Skip(); // otherwise we remove the regular behavior, for example scrolling
}
// ==============

View File

@ -97,7 +97,13 @@ class CDebugger : public wxDialog
void MailSettings(wxCommandEvent& event);
void Readfile(std::string FileName, bool GC);
std::string Readfile_(std::string FileName);
int CountFiles(std::string FileName);
int CountFiles(std::string FileName);
// ============== Blocks
void DoScrollBlocks();
void ScrollBlocksMouse(wxMouseEvent& event);
void ScrollBlocksCursor(wxScrollWinEvent& event);
CPBView* m_GPRListView;
std::vector<std::string> sMail, sMailEnd, sFullMail;
@ -114,14 +120,19 @@ class CDebugger : public wxDialog
bool ScanMails; // mail settings
bool StoreMails;
bool upd95; bool upd94; bool upd93; bool upd92; // block view settings
std::string str0; std::string str95; std::string str94; std::string str93; std::string str92;
std::vector<std::string> PBn; std::vector<std::string> PBp;
// members
wxTextCtrl * m_log, * m_log1, // mail
* m_bl0, * m_bl95, * m_bl94; // blocks
private:
// declarations
wxNotebook *m_Notebook; // notebook
wxPanel *m_PageMain;
wxPanel *m_PageMail;
wxTextCtrl * m_log, * m_log1; // mail
wxPanel *m_PageMain, *m_PageMail, *m_PageBlock;
wxCheckBox *m_Check[9];
wxRadioButton *m_Radio[5];
@ -145,11 +156,9 @@ class CDebugger : public wxDialog
ID_SELC,
ID_PRESETS,
ID_GPR,
ID_NOTEBOOK, // notebook
ID_PAGEMAIN,
ID_PAGEMAIL,
ID_LOG, // mails
ID_LOG1,
ID_NOTEBOOK, ID_PAGEMAIN, ID_PAGEMAIL, ID_PAGEBLOCK, // notebook
ID_LOG, ID_LOG1, // mails
ID_BL0, ID_BL95, ID_BL94, ID_BL93, ID_BL92,
ID_DUMMY_VALUE_ //don't remove this value unless you have other enum values
};

View File

@ -19,17 +19,29 @@
#include <stdio.h>
#include "Globals.h"
#include "Common.h"
void __Log(int, const char *fmt, ...)
{
DebugLog(fmt);
}
void __Log_(int v, const char *fmt, ...)
{
char Msg[512];
va_list ap;
va_start(ap, fmt);
vsprintf(Msg, fmt, ap);
va_end(ap);
g_dspInitialize.pLog(Msg, v);
}
void DebugLog(const char* _fmt, ...)
{
#if defined(_DEBUG) || defined(DEBUGFAST)
if(strncmp (_fmt, "AX", 2)) // match = 0, in that case this is ignored
//if(true)
//if(strncmp (_fmt, "AX", 2)) // match = 0, in that case this is ignored
{
char Msg[512];
va_list ap;
@ -38,7 +50,7 @@ if(strncmp (_fmt, "AX", 2)) // match = 0, in that case this is ignored
vsprintf(Msg, _fmt, ap);
va_end(ap);
g_dspInitialize.pLog(Msg);
g_dspInitialize.pLog(Msg, 0);
}
#endif
}

View File

@ -23,6 +23,13 @@
extern DSPInitialize g_dspInitialize;
void DebugLog(const char* _fmt, ...);
void __Log_(int v, const char *fmt, ...);
#if defined(_DEBUG) || defined(DEBUGFAST)
#define LOG_(v, ...) __Log_(v, __VA_ARGS__);
#else
#define LOG_(_v_, ...)
#endif
u8 Memory_Read_U8(u32 _uAddress);
u16 Memory_Read_U16(u32 _uAddress);

View File

@ -42,6 +42,7 @@
#include "../UCodes/UCode_AXStructs.h"
#include "../UCodes/UCode_AX.h"
#include "../UCodes/UCode_AXWii.h"
#include "../UCodes/UCode_AX_Voice.h"
// Externals

View File

@ -143,7 +143,7 @@ if(m_frame->ScanMails)
{
TmpMailLog += Msg;
TmpMailLog += "\n";
g_dspInitialize.pLog(Msg);
LOG_(1, Msg);
}
}
}

View File

@ -74,10 +74,15 @@ struct PBDpop
s16 unknown[9];
};
struct PBDpopWii
{
s16 unknown[12];
};
struct PBDpopWii
{
s16 unknown[12];
};
struct PBDpopWii_
{
s16 unknown[7];
};
struct PBVolumeEnvelope
{
@ -199,6 +204,35 @@ struct AXParamBlockWii
/* 106 */ u16 pad[22];
};
struct AXParamBlockWii_
{
u16 next_pb_hi;
u16 next_pb_lo;
u16 this_pb_hi;
u16 this_pb_lo;
u16 src_type; // Type of sample rate converter (none, ?, linear)
u16 coef_select;
u32 mixer_control;
u16 running; // 1=RUN 0=STOP
u16 is_stream; // 1 = stream, 0 = one shot
/* 10 */ PBMixerWii mixer;
/* 34 */ PBInitialTimeDelay initial_time_delay;
/* 41 */ PBUpdatesWii updates;
/* 46 */ PBDpopWii_ dpop;
/* 53 */ PBVolumeEnvelope vol_env;
/* 55 */ PBAudioAddr audio_addr;
/* 63 */ PBADPCMInfo adpcm;
/* 83 */ PBSampleRateConverter src;
/* 90 */ PBADPCMLoopInfo adpcm_loop_info;
/* 93 */ PBLpf lpf;
/* 97 */ PBHpf hpf;
/* 101 */ u16 pad[27];
};
enum {
AUDIOFORMAT_ADPCM = 0,
AUDIOFORMAT_PCM8 = 0x19,

View File

@ -15,6 +15,8 @@
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include "StringUtil.h"
#include "../Debugger/Debugger.h"
#include "../Logging/Console.h" // for aprintf
@ -40,7 +42,7 @@ extern CDebugger * m_frame;
// -----------
CUCode_AXWii::CUCode_AXWii(CMailHandler& _rMailHandler)
CUCode_AXWii::CUCode_AXWii(CMailHandler& _rMailHandler, u32 _CRC)
: IUCode(_rMailHandler)
, m_addressPBs(0xFFFFFFFF)
{
@ -52,6 +54,7 @@ CUCode_AXWii::CUCode_AXWii(CMailHandler& _rMailHandler)
temprbuffer = new int[1024 * 1024];
lCUCode_AX = new CUCode_AX(_rMailHandler);
_CRC = _CRC;
}
CUCode_AXWii::~CUCode_AXWii()
@ -73,70 +76,27 @@ void CUCode_AXWii::HandleMail(u32 _uMail)
}
}
int ReadOutPBsWii(u32 pbs_address, AXParamBlockWii* _pPBs, int _num)
{
int count = 0;
u32 blockAddr = pbs_address;
u32 pAddr = 0;
// reading and 'halfword' swap
for (int i = 0; i < _num; i++)
{
const short *pSrc = (const short *)g_dspInitialize.pGetMemoryPointer(blockAddr);
pAddr = blockAddr;
if (pSrc != NULL)
{
short *pDest = (short *)&_pPBs[i];
for (int p = 0; p < sizeof(AXParamBlockWii) / 2; p++)
{
if(p == 6 || p == 7) pDest[p] = pSrc[p]; // control for the u32
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++;
// Detect the last mail by checking when next_pb = 0
u32 next_pb = (Common::swap16(pSrc[0]) << 16) | Common::swap16(pSrc[1]);
if(next_pb == 0) break;
}
else
break;
}
// return the number of read PBs
return count;
}
void WriteBackPBsWii(u32 pbs_address, AXParamBlockWii* _pPBs, int _num)
{
u32 blockAddr = pbs_address;
// write back and 'halfword'swap
for (int i = 0; i < _num; i++)
{
short* pSrc = (short*)&_pPBs[i];
short* pDest = (short*)g_dspInitialize.pGetMemoryPointer(blockAddr);
_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 pDest[p] = Common::swap16(pSrc[p]);
}
// next block
blockAddr = (_pPBs[i].next_pb_hi << 16) | _pPBs[i].next_pb_lo;
}
}
void CUCode_AXWii::MixAdd(short* _pBuffer, int _iSize)
{
AXParamBlockWii PBs[NUMBER_OF_PBS];
if(_CRC == 0xfa450138)
{
AXParamBlockWii PBs[NUMBER_OF_PBS];
MixAdd_( _pBuffer, _iSize, PBs);
}
else
{
AXParamBlockWii_ PBs[NUMBER_OF_PBS];
MixAdd_(_pBuffer, _iSize, PBs);
}
}
template<class ParamBlockType>
void CUCode_AXWii::MixAdd_(short* _pBuffer, int _iSize, ParamBlockType &PBs)
//void CUCode_AXWii::MixAdd_(short* _pBuffer, int _iSize)
{
//AXParamBlockWii PBs[NUMBER_OF_PBS];
// read out pbs
int numberOfPBs = ReadOutPBsWii(m_addressPBs, PBs, NUMBER_OF_PBS);
@ -152,8 +112,41 @@ void CUCode_AXWii::MixAdd(short* _pBuffer, int _iSize)
if (m_frame)
{
lCUCode_AX->Logging(_pBuffer, _iSize, 0, true);
// -------------------------------------------
// Write the first block values
int p = numberOfPBs - 1;
if(numberOfPBs > p)
{
if(PBs[p].running && !m_frame->upd95)
{
const u32 blockAddr = (u32)(PBs[p].this_pb_hi<< 16) | PBs[p].this_pb_lo;
const short *pSrc = (const short *)g_dspInitialize.pGetMemoryPointer(blockAddr);
for (int i = 0; i < sizeof(AXParamBlockWii) / 2; i+=2)
{
if(i == 10 || i == 34 || i == 41 || i == 46 || i == 46 || i == 58 || i == 60
|| i == 68 || i == 88 || i == 95)
{m_frame->str0 += "\n"; m_frame->str95 += "\n";}
std::string line = StringFromFormat("%02i|%02i : %s : %s",
i/2, i,
m_frame->PBn[i].c_str(), m_frame->PBp[i].c_str()
);
for (int i = 0; i < 50 - line.length(); ++i)
line += " ";
m_frame->str0 += line;
m_frame->str0 += "\n";
m_frame->str95 += StringFromFormat(" : %02i|%02i : %04x%04x\n",
i/2, i,
Common::swap16(pSrc[i]), Common::swap16(pSrc[i+1]));
}
m_frame->m_bl95->AppendText(m_frame->str95.c_str());
m_frame->m_bl0->AppendText(m_frame->str0.c_str());
m_frame->upd95 = true;
}
}
}
// ---------------------------------------------------------------------------------------
// Make the updates we are told to do. This code may be buggy, TODO - fix. If multiple
@ -188,8 +181,19 @@ void CUCode_AXWii::MixAdd(short* _pBuffer, int _iSize)
for (int i = 0; i < numberOfPBs; i++)
{
AXParamBlockWii& pb = PBs[i];
MixAddVoice(pb, templbuffer, temprbuffer, _iSize);
if(_CRC == 0xfa450138)
{
//ParamBlockType pb = PBs[i];
//AXParamBlockWii& pb = PBs[i];
//MixAddVoice(pb, templbuffer, temprbuffer, _iSize);
MixAddVoice(PBs[i], templbuffer, temprbuffer, _iSize);
}
else
{
//AXParamBlockWii_& pb = PBs[i];
//MixAddVoice(pb, templbuffer, temprbuffer, _iSize);
MixAddVoice(PBs[i], templbuffer, temprbuffer, _iSize);
}
}
WriteBackPBsWii(m_addressPBs, PBs, numberOfPBs);
@ -312,7 +316,7 @@ bool CUCode_AXWii::AXTask(u32& _uMail)
mixer_HLEready = true;
SaveLog("%08x : AXLIST PB address: %08x", uAddress, m_addressPBs);
#ifdef _WIN32
DebugLog("Update the SoundThread to be in sync");
//DebugLog("Update the SoundThread to be in sync");
DSound::DSound_UpdateSound(); //do it in this thread to avoid sync problems
#endif
uAddress += 4;

View File

@ -25,18 +25,20 @@
class CUCode_AXWii : public IUCode
{
public:
CUCode_AXWii(CMailHandler& _rMailHandler);
CUCode_AXWii(CMailHandler& _rMailHandler, u32 _CRC);
virtual ~CUCode_AXWii();
void HandleMail(u32 _uMail);
void MixAdd(short* _pBuffer, int _iSize);
template<class ParamBlockType>
//void Logging(short* _pBuffer, int _iSize, int a, bool Wii, ParamBlockType &PBs, int numberOfPBs);
void MixAdd_(short* _pBuffer, int _iSize, ParamBlockType &PBs);
void Update();
// this is a little ugly perhaps, feel free to move it out of here
// The logging function for the debugger
void Logging(short* _pBuffer, int _iSize, int a);
CUCode_AX * lCUCode_AX; // we need the logging functions in there
private:
enum
{
@ -45,6 +47,7 @@ private:
// PBs
u32 m_addressPBs;
u32 _CRC;
int *templbuffer;
int *temprbuffer;
@ -55,7 +58,7 @@ private:
void SendMail(u32 _uMail);
};
int ReadOutPBsWii(u32 pbs_address, AXParamBlockWii* _pPBs, int _num);
void WriteBackPBsWii(u32 pbs_address, AXParamBlockWii* _pPBs, int _num);
//int ReadOutPBsWii(u32 pbs_address, AXParamBlockWii* _pPBs, int _num);
//void WriteBackPBsWii(u32 pbs_address, AXParamBlockWii* _pPBs, int _num);
#endif // _UCODE_AXWII

View File

@ -27,6 +27,84 @@
extern bool gSequenced;
extern bool gVolume;
template<class ParamBlockType>
inline int ReadOutPBsWii(u32 pbs_address, ParamBlockType& _pPBs, int _num)
//int ReadOutPBsWii(u32 pbs_address, AXParamBlockWii* _pPBs, int _num)
{
int count = 0;
u32 blockAddr = pbs_address;
u32 pAddr = 0;
// reading and 'halfword' swap
for (int i = 0; i < _num; i++)
{
const short *pSrc = (const short *)g_dspInitialize.pGetMemoryPointer(blockAddr);
pAddr = blockAddr;
if (pSrc != NULL)
{
short *pDest = (short *)&_pPBs[i];
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++;
// Detect the last mail by checking when next_pb = 0
u32 next_pb = (Common::swap16(pSrc[0]) << 16) | Common::swap16(pSrc[1]);
if(next_pb == 0) break;
}
else
break;
}
// return the number of read PBs
return count;
}
template<class ParamBlockType>
inline void WriteBackPBsWii(u32 pbs_address, ParamBlockType& _pPBs, int _num)
//void WriteBackPBsWii(u32 pbs_address, AXParamBlockWii* _pPBs, int _num)
{
u32 blockAddr = pbs_address;
// write back and 'halfword'swap
for (int i = 0; i < _num; i++)
{
short* pSrc = (short*)&_pPBs[i];
short* pDest = (short*)g_dspInitialize.pGetMemoryPointer(blockAddr);
_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]);
}
// next block
blockAddr = (_pPBs[i].next_pb_hi << 16) | _pPBs[i].next_pb_lo;
}
}
template<class ParamBlockType>
inline void MixAddVoice(ParamBlockType &pb, int *templbuffer, int *temprbuffer, int _iSize)
{

View File

@ -76,7 +76,7 @@ IUCode* UCodeFactory(u32 _CRC, CMailHandler& _rMailHandler)
case 0x347112ba: // raving rabbits
case 0xfa450138: // wii sports - PAL
DebugLog("Wii - AXWii chosen");
return new CUCode_AXWii(_rMailHandler);
return new CUCode_AXWii(_rMailHandler, _CRC);
default:
PanicAlert("Unknown ucode (CRC = %08x) - forcing AX", _CRC);

View File

@ -43,11 +43,9 @@ char Msg[512];
// no match = -1
{
OutputDebugString(Msg);
g_dspInitialize.pLog(Msg);
g_dspInitialize.pLog(Msg,0);
}
#endif
}
// =============
@ -62,7 +60,7 @@ void ErrorLog(const char* _fmt, ...)
vsprintf(Msg, _fmt, ap);
va_end(ap);
g_dspInitialize.pLog(Msg);
g_dspInitialize.pLog(Msg,0);
#ifdef _WIN32
::MessageBox(NULL, Msg, "Error", MB_OK);
#endif

View File

@ -362,7 +362,7 @@ void WmRequestStatus(u16 _channelID, wm_request_status* rs)
pStatus->battery = 0x4F; //arbitrary number
// this gets us passed the first error, but later brings up the disconnected error
pStatus->extension = 0;
pStatus->extension = 1;
LOGV(WII_IPC_WIIMOTE, 0," SendStatusReport()");
LOGV(WII_IPC_WIIMOTE, 0, " Flags: 0x%02x", pStatus->padding1[2]);