Added an option "Enable Loop Audio Hack" in DSP config.

I know hack is not good but before we find a better way to detect different games, at least this option allows some games to output normal sound without breaking other games.

Besides, this commit will hopefully fix the "Unknown device: /dev/usb/hid" issue, but not sure as I have no game to test on this issue.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4623 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
ayuanx 2009-11-28 11:40:04 +00:00
parent 60352d92eb
commit 0f7b1a2f95
7 changed files with 42 additions and 15 deletions

View File

@ -98,7 +98,7 @@ void Init()
g_DeviceMap[i] = new CWII_IPC_HLE_Device_usb_oh0(i, std::string("/dev/usb/oh0")); i++;
g_DeviceMap[i] = new CWII_IPC_HLE_Device_usb_kbd(i, std::string("/dev/usb/kbd")); i++;
g_DeviceMap[i] = new CWII_IPC_HLE_Device_sdio_slot0(i, std::string("/dev/sdio/slot0")); i++;
//g_DeviceMap[i] = new CWII_IPC_HLE_Device_Error(i, std::string("_Unknown_Device_")); i++;
g_DeviceMap[i] = new CWII_IPC_HLE_Device_Error(i, std::string("_Unknown_Device_")); i++;
g_LastDeviceID = IPC_FIRST_FILEIO_ID;
}
@ -287,7 +287,10 @@ void ExecuteCommand(u32 _Address)
if (DeviceName.find("/dev/") != std::string::npos)
{
ERROR_LOG(WII_IPC_FILEIO, "Unknown device: %s", DeviceName.c_str());
PanicAlert("Unknown device: %s", DeviceName.c_str());
PanicAlert("Unknown device: %s\n\nMaybe you can continue to play or maybe the game will freeze.", DeviceName.c_str());
pDevice = AccessDeviceByID(GetDeviceIDByName(std::string("_Unknown_Device_")));
CmdSuccess = pDevice->Open(_Address, Mode);
}
else
{

View File

@ -33,8 +33,9 @@ public:
virtual bool Open(u32 _CommandAddress, u32 _Mode)
{
PanicAlert("CWII_IPC_HLE_Device_Error");
Memory::Write_U32(GetDeviceID(), _CommandAddress+4);
//PanicAlert("CWII_IPC_HLE_Device_Error");
//Memory::Write_U32(GetDeviceID(), _CommandAddress+4);
Memory::Write_U32(0, _CommandAddress+4);
m_Active = true;
return true;
}

View File

@ -35,6 +35,7 @@ void CConfig::Load()
file.Load(FULL_CONFIG_DIR "DSP.ini");
file.Get("Config", "EnableHLEAudio", &m_EnableHLEAudio, true); // Sound Settings
file.Get("Config", "EnableRE0AudioFix", &m_EnableRE0Fix, false); // RE0 Hack
file.Get("Config", "EnableLoopAudioFix", &m_EnableLoopFix, false); // Loop Hack
ac_Config.Load(file);
}
@ -44,6 +45,7 @@ void CConfig::Save()
file.Load(FULL_CONFIG_DIR "DSP.ini");
file.Set("Config", "EnableHLEAudio", m_EnableHLEAudio); // Sound Settings
file.Set("Config", "EnableRE0AudioFix", m_EnableRE0Fix); // RE0 Hack
file.Set("Config", "EnableLoopAudioFix", m_EnableLoopFix); // Loop Hack
ac_Config.Set(file);
file.Save(FULL_CONFIG_DIR "DSP.ini");
@ -51,11 +53,17 @@ void CConfig::Save()
void CConfig::GameIniLoad(const char *game_ini)
{
// This game config will affect global system config
// Need a better way to seperate system config from game config
//
/*
if (game_ini && strlen(game_ini))
{
IniFile iniFile;
iniFile.Load(game_ini);
iniFile.Get("HLEaudio", "UseRE0Fix", &m_EnableRE0Fix, 0);
//iniFile.Get("HLEaudio", "UseRE0Fix", &m_EnableRE0Fix, 0);
//iniFile.Get("HLEaudio", "UseLoopFix", &m_EnableLoopFix, 0);
}
*/
}

View File

@ -24,6 +24,7 @@ struct CConfig
{
bool m_EnableHLEAudio;
bool m_EnableRE0Fix;
bool m_EnableLoopFix;
CConfig();

View File

@ -25,6 +25,7 @@ EVT_CHECKBOX(ID_ENABLE_HLE_AUDIO, DSPConfigDialogHLE::SettingsChanged)
EVT_CHECKBOX(ID_ENABLE_DTK_MUSIC, DSPConfigDialogHLE::SettingsChanged)
EVT_CHECKBOX(ID_ENABLE_THROTTLE, DSPConfigDialogHLE::SettingsChanged)
EVT_CHECKBOX(ID_ENABLE_RE0_FIX, DSPConfigDialogHLE::SettingsChanged)
EVT_CHECKBOX(ID_ENABLE_LOOP_FIX, DSPConfigDialogHLE::SettingsChanged)
EVT_COMMAND_SCROLL(ID_VOLUME, DSPConfigDialogHLE::VolumeChanged)
END_EVENT_TABLE()
@ -40,7 +41,8 @@ DSPConfigDialogHLE::DSPConfigDialogHLE(wxWindow *parent, wxWindowID id, const wx
m_buttonEnableHLEAudio = new wxCheckBox(this, ID_ENABLE_HLE_AUDIO, wxT("Enable HLE Audio"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_buttonEnableDTKMusic = new wxCheckBox(this, ID_ENABLE_DTK_MUSIC, wxT("Enable DTK Music"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_buttonEnableThrottle = new wxCheckBox(this, ID_ENABLE_THROTTLE, wxT("Enable Other Audio (Throttle)"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_buttonEnableRE0Fix = new wxCheckBox(this, ID_ENABLE_RE0_FIX, wxT("Enable RE0 Audio Fix"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_buttonEnableRE0Fix = new wxCheckBox(this, ID_ENABLE_RE0_FIX, wxT("Enable RE0 Audio Hack"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_buttonEnableLoopFix = new wxCheckBox(this, ID_ENABLE_LOOP_FIX, wxT("Enable Loop Audio Hack"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
wxStaticText *BackendText = new wxStaticText(this, wxID_ANY, wxT("Audio Backend"), wxDefaultPosition, wxDefaultSize, 0);
m_BackendSelection = new wxComboBox(this, ID_BACKEND, wxEmptyString, wxDefaultPosition, wxSize(90, 20), wxArrayBackends, wxCB_READONLY, wxDefaultValidator);
@ -49,9 +51,10 @@ DSPConfigDialogHLE::DSPConfigDialogHLE(wxWindow *parent, wxWindowID id, const wx
// Update values
m_buttonEnableHLEAudio->SetValue(g_Config.m_EnableHLEAudio ? true : false);
m_buttonEnableRE0Fix->SetValue(g_Config.m_EnableRE0Fix ? true : false);
m_buttonEnableDTKMusic->SetValue(ac_Config.m_EnableDTKMusic ? true : false);
m_buttonEnableThrottle->SetValue(ac_Config.m_EnableThrottle ? true : false);
m_buttonEnableRE0Fix->SetValue(g_Config.m_EnableRE0Fix ? true : false);
m_buttonEnableLoopFix->SetValue(g_Config.m_EnableLoopFix ? true : false);
// Add tooltips
m_buttonEnableHLEAudio->SetToolTip(wxT("This is the most common sound type"));
@ -59,7 +62,10 @@ DSPConfigDialogHLE::DSPConfigDialogHLE(wxWindow *parent, wxWindowID id, const wx
m_buttonEnableThrottle->SetToolTip(wxT("This is sometimes used together with pre-rendered movies.\n")
wxT("Disabling this also disables the speed throttle which this causes,\n")
wxT("meaning that there will be no upper limit on your FPS."));
m_buttonEnableRE0Fix->SetToolTip(wxT("This fixes audo in RE0 and maybe some other games."));
m_buttonEnableRE0Fix->SetToolTip(wxT("This fixes audio in Resident Evil Zero and maybe some other games."));
m_buttonEnableLoopFix->SetToolTip(wxT("This fixes audio loops in some games, by default it should be disabled.\n")
wxT("Unless you are experiencing strange sound loops, don't enable it,\n")
wxT("or it will cause some games to hang up."));
m_BackendSelection->SetToolTip(wxT("Changing this will have no effect while the emulator is running!"));
// Create sizer and add items to dialog
@ -73,6 +79,7 @@ DSPConfigDialogHLE::DSPConfigDialogHLE(wxWindow *parent, wxWindowID id, const wx
sbSettings->Add(m_buttonEnableDTKMusic, 0, wxALL, 5);
sbSettings->Add(m_buttonEnableThrottle, 0, wxALL, 5);
sbSettings->Add(m_buttonEnableRE0Fix, 0, wxALL, 5);
sbSettings->Add(m_buttonEnableLoopFix, 0, wxALL, 5);
sBackend->Add(BackendText, 0, wxALIGN_CENTER|wxALL, 5);
sBackend->Add(m_BackendSelection, 0, wxALL, 1);
sbSettings->Add(sBackend, 0, wxALL, 2);
@ -129,9 +136,10 @@ void DSPConfigDialogHLE::VolumeChanged(wxScrollEvent& WXUNUSED(event))
void DSPConfigDialogHLE::SettingsChanged(wxCommandEvent& event)
{
g_Config.m_EnableHLEAudio = m_buttonEnableHLEAudio->GetValue();
g_Config.m_EnableRE0Fix = m_buttonEnableRE0Fix->GetValue();
ac_Config.m_EnableDTKMusic = m_buttonEnableDTKMusic->GetValue();
ac_Config.m_EnableThrottle = m_buttonEnableThrottle->GetValue();
g_Config.m_EnableRE0Fix = m_buttonEnableRE0Fix->GetValue();
g_Config.m_EnableLoopFix = m_buttonEnableLoopFix->GetValue();
#ifdef __APPLE__
strncpy(ac_Config.sBackend, m_BackendSelection->GetValue().mb_str(), 128);

View File

@ -47,7 +47,8 @@ private:
wxCheckBox *m_buttonEnableDTKMusic;
wxCheckBox *m_buttonEnableThrottle;
wxCheckBox *m_buttonEnableRE0Fix;
wxArrayString wxArrayBackends;
wxCheckBox *m_buttonEnableLoopFix;
wxArrayString wxArrayBackends;
wxComboBox *m_BackendSelection;
enum
@ -57,6 +58,7 @@ private:
ID_ENABLE_DTK_MUSIC,
ID_ENABLE_THROTTLE,
ID_ENABLE_RE0_FIX,
ID_ENABLE_LOOP_FIX,
ID_BACKEND,
ID_VOLUME
};

View File

@ -21,8 +21,9 @@
#include "UCodes.h"
#include "UCode_AX_ADPCM.h"
#include "UCode_AX.h"
#include "../main.h"
#include "Mixer.h"
#include "../main.h"
#include "../Config.h"
// ----------------------------------------------------
// Externals
@ -92,7 +93,6 @@ inline void MixAddVoice(ParamBlockType &pb, int *templbuffer, int *temprbuffer,
// =============
if (pb.running)
{
// Read initial parameters
// ------------
//constants
@ -191,7 +191,9 @@ inline void MixAddVoice(ParamBlockType &pb, int *templbuffer, int *temprbuffer,
break;
case AUDIOFORMAT_ADPCM:
sample = ADPCM_Step(pb.adpcm, samplePos, newSamplePos, frac);
u32 toSamplePos;
toSamplePos = (newSamplePos > sampleEnd) ? sampleEnd : newSamplePos;
sample = ADPCM_Step(pb.adpcm, samplePos, toSamplePos, frac);
break;
default:
@ -246,7 +248,7 @@ inline void MixAddVoice(ParamBlockType &pb, int *templbuffer, int *temprbuffer,
}
else
{
if (Wii && (_uCode == UCODE_AXWII))
if (!g_Config.m_EnableLoopFix && Wii && (_uCode == UCODE_AXWII))
{
// This accurate boundary wrapping will fix the hangup in many AXWii games like:
// New Super Mario Bros.Wii, Fatal Frame 4, Resident Evil Darkside Chronicles
@ -261,7 +263,9 @@ inline void MixAddVoice(ParamBlockType &pb, int *templbuffer, int *temprbuffer,
{
pb.running = 0;
}
// not sure if this will mute the unwanted over looping sound
pb.mixer.volume_left = 0;
pb.mixer.volume_right = 0;
break;
}
}