Expand Up @@ -161,15 +161,15 @@ struct PBDpopWii

struct PBDpopWM
{
s16 aMain0;
s16 aMain1;
s16 aMain2;
s16 aMain3;

s16 aAux0;
s16 aAux1;
s16 aAux2;
s16 aAux3;
s16 main0;
s16 main1;
s16 main2;
s16 main3;

s16 aux0;
s16 aux1;
s16 aux2;
s16 aux3;
};

struct PBVolumeEnvelope
Expand Down Expand Up @@ -211,13 +211,13 @@ struct PBSampleRateConverter
u16 ratio_hi; // integer part of sampling ratio
u16 ratio_lo; // fraction part of sampling ratio
u16 cur_addr_frac;
u16 last_samples[4];
s16 last_samples[4];
};

struct PBSampleRateConverterWM
{
u16 currentAddressFrac;
u16 last_samples[4];
u16 cur_addr_frac;
s16 last_samples[4];
};

struct PBADPCMLoopInfo
Expand All @@ -230,7 +230,7 @@ struct PBADPCMLoopInfo
struct PBLowPassFilter
{
u16 enabled;
u16 yn1;
s16 yn1;
u16 a0;
u16 b0;
};
Expand Down Expand Up @@ -324,52 +324,6 @@ struct AXPBWii
u16 pad[12]; // align us, captain! (32B)
};

// Seems like nintendo used an early version of AXWii and forgot to remove the update functionality ;p
struct PBUpdatesWiiSports
{
u16 num_updates[3];
u16 data_hi;
u16 data_lo;
};

struct AXPBWiiSports
{
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, 4-tap, linear)
u16 coef_select; // coef for the 4-tap src
u32 mixer_control;

u16 running; // 1=RUN 0=STOP
u16 is_stream; // 1 = stream, 0 = one shot

PBMixerWii mixer;
PBInitialTimeDelay initial_time_delay;
PBUpdatesWiiSports updates;
PBDpopWii dpop;
PBVolumeEnvelope vol_env;
PBAudioAddr audio_addr;
PBADPCMInfo adpcm;
PBSampleRateConverter src;
PBADPCMLoopInfo adpcm_loop_info;
PBLowPassFilter lpf;
PBBiquadFilter biquad;

// WIIMOTE :D
u16 remote;
u16 remote_mixer_control;

PBMixerWM remote_mixer;
PBDpopWM remote_dpop;
PBSampleRateConverterWM remote_src;
PBInfImpulseResponseWM remote_iir;

u16 pad[7]; // align us, captain! (32B)
};

// TODO: All these enums have changed a lot for wii
enum {
AUDIOFORMAT_ADPCM = 0,
Expand Down
783 changes: 607 additions & 176 deletions Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_AXWii.cpp

Large diffs are not rendered by default.

120 changes: 96 additions & 24 deletions Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_AXWii.h
Expand Up @@ -12,44 +12,116 @@
// 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
// Official Git repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/

#ifndef _UCODE_AXWII
#define _UCODE_AXWII
#ifndef _UCODE_AXWII_H
#define _UCODE_AXWII_H

#include "UCode_AXWii_Structs.h"
#include "UCode_AX.h"

#define NUMBER_OF_PBS 128

class CUCode_AXWii : public IUCode
class CUCode_AXWii : public CUCode_AX
{
public:
CUCode_AXWii(DSPHLE *dsp_hle, u32 _CRC);
virtual ~CUCode_AXWii();

void HandleMail(u32 _uMail);
void MixAdd(short* _pBuffer, int _iSize);
void Update(int cycles);
void DoState(PointerWrap &p);
virtual void DoState(PointerWrap &p);

private:
enum
{
MAIL_AX_ALIST = 0xBABE0000,
};
protected:
// Additional AUX buffers
int m_samples_auxC_left[32 * 3];
int m_samples_auxC_right[32 * 3];
int m_samples_auxC_surround[32 * 3];

// Wiimote buffers
int m_samples_wm0[6 * 3];
int m_samples_aux0[6 * 3];
int m_samples_wm1[6 * 3];
int m_samples_aux1[6 * 3];
int m_samples_wm2[6 * 3];
int m_samples_aux2[6 * 3];
int m_samples_wm3[6 * 3];
int m_samples_aux3[6 * 3];

// Are we implementing an old version of AXWii which still has updates?
bool m_old_axwii;

// Last volume values for MAIN and AUX. Used to generate volume ramps to
// interpolate nicely between old and new volume values.
u16 m_last_main_volume;
u16 m_last_aux_volumes[3];

// If needed, extract the updates related fields from a PB. We need to
// reinject them afterwards so that the correct PB typs is written to RAM.
bool ExtractUpdatesFields(AXPBWii& pb, u16* num_updates, u16* updates,
u32* updates_addr);
void ReinjectUpdatesFields(AXPBWii& pb, u16* num_updates, u32 updates_addr);

// PBs
u32 m_addressPBs;
// Convert a mixer_control bitfield to our internal representation for that
// value. Required because that bitfield has a different meaning in some
// versions of AX.
AXMixControl ConvertMixerControl(u32 mixer_control);

bool wiisportsHack;
// Generate a volume ramp from vol1 to vol2, interpolating n volume values.
// Uses floating point arithmetic, which isn't exactly what the UCode does,
// but this gives better precision and nicer code.
void GenerateVolumeRamp(u16* output, u16 vol1, u16 vol2, size_t nvals);

int *templbuffer;
int *temprbuffer;
virtual void HandleCommandList();

// ax task message handler
bool AXTask(u32& _uMail);
void SendMail(u32 _uMail);
void SetupProcessing(u32 init_addr);
void AddToLR(u32 val_addr, bool neg);
void AddSubToLR(u32 val_addr);
void ProcessPBList(u32 pb_addr);
void MixAUXSamples(int aux_id, u32 write_addr, u32 read_addr, u16 volume);
void UploadAUXMixLRSC(int aux_id, u32* addresses, u16 volume);
void OutputSamples(u32 lr_addr, u32 surround_addr, u16 volume,
bool upload_auxc);
void OutputWMSamples(u32* addresses); // 4 addresses

private:
enum CmdType
{
CMD_SETUP = 0x00,
CMD_ADD_TO_LR = 0x01,
CMD_SUB_TO_LR = 0x02,
CMD_ADD_SUB_TO_LR = 0x03,
CMD_PROCESS = 0x04,
CMD_MIX_AUXA = 0x05,
CMD_MIX_AUXB = 0x06,
CMD_MIX_AUXC = 0x07,
CMD_UPL_AUXA_MIX_LRSC = 0x08,
CMD_UPL_AUXB_MIX_LRSC = 0x09,
CMD_UNK_0A = 0x0A,
CMD_OUTPUT = 0x0B,
CMD_OUTPUT_DPL2 = 0x0C,
CMD_WM_OUTPUT = 0x0D,
CMD_END = 0x0E,
};

// A lot of these are similar to the new version, but there is an offset in
// the command ids due to the PB_ADDR command (which was removed from the
// new AXWii).
enum CmdTypeOld
{
CMD_SETUP_OLD = 0x00,
CMD_ADD_TO_LR_OLD = 0x01,
CMD_SUB_TO_LR_OLD = 0x02,
CMD_ADD_SUB_TO_LR_OLD = 0x03,
CMD_PB_ADDR_OLD = 0x04,
CMD_PROCESS_OLD = 0x05,
CMD_MIX_AUXA_OLD = 0x06,
CMD_MIX_AUXB_OLD = 0x07,
CMD_MIX_AUXC_OLD = 0x08,
CMD_UPL_AUXA_MIX_LRSC_OLD = 0x09,
CMD_UPL_AUXB_MIX_LRSC_OLD = 0x0a,
CMD_UNK_0B_OLD = 0x0B,
CMD_OUTPUT_OLD = 0x0C, // no volume!
CMD_OUTPUT_DPL2_OLD = 0x0D,
CMD_WM_OUTPUT_OLD = 0x0E,
CMD_END_OLD = 0x0F
};
};

#endif // _UCODE_AXWII
92 changes: 0 additions & 92 deletions Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_AXWii_ADPCM.h

This file was deleted.

365 changes: 0 additions & 365 deletions Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_AXWii_Structs.h

This file was deleted.

271 changes: 0 additions & 271 deletions Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_AXWii_Voice.h

This file was deleted.

368 changes: 268 additions & 100 deletions Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_AX_Voice.h

Large diffs are not rendered by default.

383 changes: 0 additions & 383 deletions Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_NewAXWii.cpp

This file was deleted.

80 changes: 0 additions & 80 deletions Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_NewAXWii.h

This file was deleted.

11 changes: 2 additions & 9 deletions Source/Core/Core/Src/HW/DSPHLE/UCodes/UCodes.cpp
Expand Up @@ -19,20 +19,13 @@

#include "UCode_AX.h"
#include "UCode_AXWii.h"
#include "UCode_NewAXWii.h"
#include "UCode_Zelda.h"
#include "UCode_ROM.h"
#include "UCode_CARD.h"
#include "UCode_InitAudioSystem.h"
#include "UCode_GBA.h"
#include "Hash.h"

#if 0
# define AXWII CUCode_NewAXWii
#else
# define AXWII CUCode_AXWii
#endif

IUCode* UCodeFactory(u32 _CRC, DSPHLE *dsp_hle, bool bWii)
{
switch (_CRC)
Expand Down Expand Up @@ -97,13 +90,13 @@ IUCode* UCodeFactory(u32 _CRC, DSPHLE *dsp_hle, bool bWii)
case 0x4cc52064: // Bleach: Versus Crusade
case 0xd9c4bf34: // WiiMenu
INFO_LOG(DSPHLE, "CRC %08x: Wii - AXWii chosen", _CRC);
return new AXWII(dsp_hle, _CRC);
return new CUCode_AXWii(dsp_hle, _CRC);

default:
if (bWii)
{
PanicAlert("DSPHLE: Unknown ucode (CRC = %08x) - forcing AXWii.\n\nTry LLE emulator if this is homebrew.", _CRC);
return new AXWII(dsp_hle, _CRC);
return new CUCode_AXWii(dsp_hle, _CRC);
}
else
{
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/DolphinWX/Src/ConfigMain.cpp
Expand Up @@ -508,7 +508,7 @@ void CConfigMain::InitializeGUITooltips()
InterfaceLang->SetToolTip(_("Change the language of the user interface.\nRequires restart."));

// Audio tooltips
DSPThread->SetToolTip(_("Run DSP LLE on a dedicated thread (not recommended)."));
DSPThread->SetToolTip(_("Run DSP HLE and LLE on a dedicated thread (not recommended: might cause audio glitches with HLE and freezes with LLE)."));
BackendSelection->SetToolTip(_("Changing this will have no effect while the emulator is running!"));

// Gamecube - Devices
Expand Down Expand Up @@ -651,7 +651,7 @@ void CConfigMain::CreateGUIControls()
// Audio page
DSPEngine = new wxRadioBox(AudioPage, ID_DSPENGINE, _("DSP Emulator Engine"),
wxDefaultPosition, wxDefaultSize, arrayStringFor_DSPEngine, 0, wxRA_SPECIFY_ROWS);
DSPThread = new wxCheckBox(AudioPage, ID_DSPTHREAD, _("DSP LLE on Thread"));
DSPThread = new wxCheckBox(AudioPage, ID_DSPTHREAD, _("DSP on Dedicated Thread"));
DumpAudio = new wxCheckBox(AudioPage, ID_DUMP_AUDIO, _("Dump Audio"),
wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
DPL2Decoder = new wxCheckBox(AudioPage, ID_DPL2DECODER, _("Dolby Pro Logic II decoder"));
Expand Down