From 286254a10a01f605259219e7d8341f37c31eecbc Mon Sep 17 00:00:00 2001 From: O1L Date: Fri, 27 Dec 2013 14:55:11 +0400 Subject: [PATCH] Implemented some cellSysutil audio functions, added configurable controls (draft/ugly implementation), and minor changes in cellAudio and ConLog --- rpcs3/Emu/Audio/AudioManager.cpp | 19 ++ rpcs3/Emu/Audio/AudioManager.h | 44 ++++ rpcs3/Emu/Audio/cellAudio.h | 33 +++ rpcs3/Emu/Audio/sysutil_audio.h | 259 +++++++++++++++++++++ rpcs3/Emu/SysCalls/Modules/cellAudio.cpp | 158 +++++++++---- rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp | 259 +++++++++++++++++++++ rpcs3/Emu/System.cpp | 2 + rpcs3/Emu/System.h | 3 + rpcs3/Gui/ConLog.cpp | 12 + rpcs3/Gui/ConLog.h | 1 + rpcs3/Gui/MainFrame.cpp | 229 +++++++++++++++++- rpcs3/Gui/MainFrame.h | 1 + rpcs3/Ini.h | 75 ++++++ rpcs3/rpcs3.vcxproj | 5 +- rpcs3/rpcs3.vcxproj.filters | 12 + 15 files changed, 1057 insertions(+), 55 deletions(-) create mode 100644 rpcs3/Emu/Audio/AudioManager.cpp create mode 100644 rpcs3/Emu/Audio/AudioManager.h create mode 100644 rpcs3/Emu/Audio/cellAudio.h create mode 100644 rpcs3/Emu/Audio/sysutil_audio.h diff --git a/rpcs3/Emu/Audio/AudioManager.cpp b/rpcs3/Emu/Audio/AudioManager.cpp new file mode 100644 index 0000000000..94d7bbda1e --- /dev/null +++ b/rpcs3/Emu/Audio/AudioManager.cpp @@ -0,0 +1,19 @@ +#include "stdafx.h" +#include "AudioManager.h" + +AudioManager::AudioManager() +{ +} + +void AudioManager::Init() +{ +} + +void AudioManager::Close() +{ +} + +u8 AudioManager::GetState() +{ + return CELL_AUDIO_OUT_OUTPUT_STATE_ENABLED; +} diff --git a/rpcs3/Emu/Audio/AudioManager.h b/rpcs3/Emu/Audio/AudioManager.h new file mode 100644 index 0000000000..4fe6080864 --- /dev/null +++ b/rpcs3/Emu/Audio/AudioManager.h @@ -0,0 +1,44 @@ +#pragma once +#include "sysutil_audio.h" + +struct AudioInfo +{ + struct + { + u8 type; + u8 channel; + u8 encoder; + u8 fs; + u32 layout; + u32 downMixer; + } mode; + + AudioInfo() + { + } + + void Init() + { + mode.type = CELL_AUDIO_OUT_CODING_TYPE_LPCM; + mode.channel = CELL_AUDIO_OUT_CHNUM_2; + mode.fs = CELL_AUDIO_OUT_FS_48KHZ; + mode.layout = CELL_AUDIO_OUT_SPEAKER_LAYOUT_2CH; + mode.encoder = CELL_AUDIO_OUT_CODING_TYPE_LPCM; + mode.downMixer = CELL_AUDIO_OUT_DOWNMIXER_NONE; + } +}; + +class AudioManager +{ + AudioInfo m_audio_info; + +public: + AudioManager(); + + void Init(); + void Close(); + + AudioInfo& GetInfo() { return m_audio_info; } + + u8 GetState(); +}; \ No newline at end of file diff --git a/rpcs3/Emu/Audio/cellAudio.h b/rpcs3/Emu/Audio/cellAudio.h new file mode 100644 index 0000000000..73804b2dfd --- /dev/null +++ b/rpcs3/Emu/Audio/cellAudio.h @@ -0,0 +1,33 @@ +#pragma once + +enum +{ + CELL_AUDIO_BLOCK_16 = 16, + CELL_AUDIO_BLOCK_8 = 8, + CELL_AUDIO_BLOCK_SAMPLES = 256, + CELL_AUDIO_CREATEEVENTFLAG_SPU = 0x00000001, + CELL_AUDIO_EVENT_HEADPHONE = 1, + CELL_AUDIO_EVENT_MIX = 0, + CELL_AUDIO_EVENTFLAG_BEFOREMIX = 0x80000000, + CELL_AUDIO_EVENTFLAG_DECIMATE_2 = 0x08000000, + CELL_AUDIO_EVENTFLAG_DECIMATE_4 = 0x10000000, + CELL_AUDIO_EVENTFLAG_HEADPHONE = 0x20000000, + CELL_AUDIO_EVENTFLAG_NOMIX = 0x40000000, + CELL_AUDIO_MAX_PORT = 4, + CELL_AUDIO_MAX_PORT_2 = 8, + CELL_AUDIO_MISC_ACCVOL_ALLDEVICE = 0x0000ffffUL, + CELL_AUDIO_PERSONAL_DEVICE_PRIMARY = 0x8000, + CELL_AUDIO_PORT_2CH = 2, + CELL_AUDIO_PORT_8CH = 8, + CELL_AUDIO_PORTATTR_BGM = 0x0000000000000010ULL, + CELL_AUDIO_PORTATTR_INITLEVEL = 0x0000000000001000ULL, + CELL_AUDIO_PORTATTR_OUT_NO_ROUTE = 0x0000000000100000ULL, + CELL_AUDIO_PORTATTR_OUT_PERSONAL_0 = 0x0000000001000000ULL, + CELL_AUDIO_PORTATTR_OUT_PERSONAL_1 = 0x0000000002000000ULL, + CELL_AUDIO_PORTATTR_OUT_PERSONAL_2 = 0x0000000004000000ULL, + CELL_AUDIO_PORTATTR_OUT_PERSONAL_3 = 0x0000000008000000ULL, + CELL_AUDIO_PORTATTR_OUT_SECONDARY = 0x0000000000000001ULL, + CELL_AUDIO_STATUS_CLOSE = 0x1010, + CELL_AUDIO_STATUS_READY = 1, + CELL_AUDIO_STATUS_RUN = 2, +}; diff --git a/rpcs3/Emu/Audio/sysutil_audio.h b/rpcs3/Emu/Audio/sysutil_audio.h new file mode 100644 index 0000000000..b8c1061e54 --- /dev/null +++ b/rpcs3/Emu/Audio/sysutil_audio.h @@ -0,0 +1,259 @@ +#pragma once + +//error codes +enum AudioErrorCode +{ + CELL_AUDIO_OUT_SUCCEEDED = 0, + CELL_AUDIO_OUT_ERROR_NOT_IMPLEMENTED = 0x8002b240, + CELL_AUDIO_OUT_ERROR_ILLEGAL_CONFIGURATION = 0x8002b241, + CELL_AUDIO_OUT_ERROR_ILLEGAL_PARAMETER = 0x8002b242, + CELL_AUDIO_OUT_ERROR_PARAMETER_OUT_OF_RANGE = 0x8002b243, + CELL_AUDIO_OUT_ERROR_DEVICE_NOT_FOUND = 0x8002b244, + CELL_AUDIO_OUT_ERROR_UNSUPPORTED_AUDIO_OUT = 0x8002b245, + CELL_AUDIO_OUT_ERROR_UNSUPPORTED_SOUND_MODE = 0x8002b246, + CELL_AUDIO_OUT_ERROR_CONDITION_BUSY = 0x8002b247, + CELL_AUDIO_IN_ERROR_NOT_IMPLEMENTED = 0x8002b260, + CELL_AUDIO_IN_ERROR_ILLEGAL_CONFIGURATION = 0x8002b261, + CELL_AUDIO_IN_ERROR_ILLEGAL_PARAMETER = 0x8002b262, + CELL_AUDIO_IN_ERROR_PARAMETER_OUT_OF_RANGE = 0x8002b263, + CELL_AUDIO_IN_ERROR_DEVICE_NOT_FOUND = 0x8002b264, + CELL_AUDIO_IN_ERROR_UNSUPPORTED_AUDIO_IN = 0x8002b265, + CELL_AUDIO_IN_ERROR_UNSUPPORTED_SOUND_MODE = 0x8002b266, + CELL_AUDIO_IN_ERROR_CONDITION_BUSY = 0x8002b267, +}; + +enum CellAudioOut +{ + CELL_AUDIO_OUT_PRIMARY = 0, + CELL_AUDIO_OUT_SECONDARY = 1, +}; + +enum CellAudioOutDownMixer +{ + CELL_AUDIO_OUT_DOWNMIXER_NONE = 0, + CELL_AUDIO_OUT_DOWNMIXER_TYPE_A = 1, + CELL_AUDIO_OUT_DOWNMIXER_TYPE_B = 2, +}; + +enum +{ + CELL_AUDIO_OUT_SINGLE_DEVICE_MODE = 0, + CELL_AUDIO_OUT_MULTI_DEVICE_MODE = 1, + CELL_AUDIO_OUT_MULTI_DEVICE_MODE_2 = 2, +}; + +enum CellAudioOutPortType +{ + CELL_AUDIO_OUT_PORT_HDMI = 0, + CELL_AUDIO_OUT_PORT_SPDIF = 1, + CELL_AUDIO_OUT_PORT_ANALOG = 2, + CELL_AUDIO_OUT_PORT_USB = 3, + CELL_AUDIO_OUT_PORT_BLUETOOTH = 4, + CELL_AUDIO_OUT_PORT_NETWORK = 5, +}; + +enum CellAudioOutDeviceState +{ + CELL_AUDIO_OUT_DEVICE_STATE_UNAVAILABLE = 0, + CELL_AUDIO_OUT_DEVICE_STATE_AVAILABLE = 1, +}; + +enum CellAudioOutOutputState +{ + CELL_AUDIO_OUT_OUTPUT_STATE_ENABLED = 0, + CELL_AUDIO_OUT_OUTPUT_STATE_DISABLED = 1, + CELL_AUDIO_OUT_OUTPUT_STATE_PREPARING = 2, +}; + +enum CellAudioOutCodingType +{ + CELL_AUDIO_OUT_CODING_TYPE_LPCM = 0, + CELL_AUDIO_OUT_CODING_TYPE_AC3 = 1, + CELL_AUDIO_OUT_CODING_TYPE_MPEG1 = 2, + CELL_AUDIO_OUT_CODING_TYPE_MP3 = 3, + CELL_AUDIO_OUT_CODING_TYPE_MPEG2 = 4, + CELL_AUDIO_OUT_CODING_TYPE_AAC = 5, + CELL_AUDIO_OUT_CODING_TYPE_DTS = 6, + CELL_AUDIO_OUT_CODING_TYPE_ATRAC = 7, + CELL_AUDIO_OUT_CODING_TYPE_BITSTREAM = 0xff, +}; + +enum CellAudioOutChnum +{ + CELL_AUDIO_OUT_CHNUM_2 = 2, + CELL_AUDIO_OUT_CHNUM_4 = 4, + CELL_AUDIO_OUT_CHNUM_6 = 6, + CELL_AUDIO_OUT_CHNUM_8 = 8, +}; + +enum CellAudioOutFs +{ + CELL_AUDIO_OUT_FS_32KHZ = 0x01, + CELL_AUDIO_OUT_FS_44KHZ = 0x02, + CELL_AUDIO_OUT_FS_48KHZ = 0x04, + CELL_AUDIO_OUT_FS_88KHZ = 0x08, + CELL_AUDIO_OUT_FS_96KHZ = 0x10, + CELL_AUDIO_OUT_FS_176KHZ = 0x20, + CELL_AUDIO_OUT_FS_192KHZ = 0x40, +}; + +enum +{ + CELL_AUDIO_OUT_SPEAKER_LAYOUT_2CH = 0x00000001, + CELL_AUDIO_OUT_SPEAKER_LAYOUT_6CH_LREClr = 0x00010000, + CELL_AUDIO_OUT_SPEAKER_LAYOUT_8CH_LREClrxy = 0x40000000, +}; + +enum +{ + CELL_AUDIO_OUT_COPY_CONTROL_COPY_FREE = 0, + CELL_AUDIO_OUT_COPY_CONTROL_COPY_ONCE = 1, + CELL_AUDIO_OUT_COPY_CONTROL_COPY_NEVER = 2, +}; + +enum +{ + CELL_AUDIO_IN_SINGLE_DEVICE_MODE = 0, + CELL_AUDIO_IN_MULTI_DEVICE_MODE = 1, + CELL_AUDIO_IN_MULTI_DEVICE_MODE_2 = 2, +}; + +enum CellAudioInPortType +{ + CELL_AUDIO_IN_PORT_USB = 3, + CELL_AUDIO_IN_PORT_BLUETOOTH = 4, +}; + +enum CellAudioInDeviceState +{ + CELL_AUDIO_IN_DEVICE_STATE_UNAVAILABLE = 0, + CELL_AUDIO_IN_DEVICE_STATE_AVAILABLE = 1, +}; + +enum CellAudioInCodingType +{ + CELL_AUDIO_IN_CODING_TYPE_LPCM = 0, +}; + +enum CellAudioInChnum +{ + CELL_AUDIO_IN_CHNUM_NONE = 0, + CELL_AUDIO_IN_CHNUM_1 = 1, + CELL_AUDIO_IN_CHNUM_2 = 2, +}; + +enum CellAudioInFs +{ + CELL_AUDIO_IN_FS_UNDEFINED = 0x00, + CELL_AUDIO_IN_FS_8KHZ = 0x01, + CELL_AUDIO_IN_FS_12KHZ = 0x02, + CELL_AUDIO_IN_FS_16KHZ = 0x04, + CELL_AUDIO_IN_FS_24KHZ = 0x08, + CELL_AUDIO_IN_FS_32KHZ = 0x10, + CELL_AUDIO_IN_FS_48KHZ = 0x20, +}; + +struct CellAudioOutConfiguration +{ + u8 channel; + u8 encoder; + u8 reserved[10]; + u32 downMixer; +}; + +struct CellAudioOutSoundMode +{ + u8 type; + u8 channel; + u8 fs; + u8 reserved; + u32 layout; +}; + +struct CellAudioOutDeviceInfo +{ + u8 portType; + u8 availableModeCount; + u8 state; + u8 reserved[3]; + u16 latency; + CellAudioOutSoundMode availableModes[16]; +}; + +struct CellAudioOutState +{ + u8 state; + u8 encoder; + u8 reserved[6]; + u32 downMixer; + CellAudioOutSoundMode soundMode; +}; + +struct CellAudioOutSoundMode2 +{ + u8 type; + u8 channel; + u16 fs; + u8 reserved[4]; +}; + +struct CellAudioOutDeviceInfo2 +{ + u8 portType; + u8 availableModeCount; + u8 state; + u8 deviceNumber; + u8 reserved[12]; + u64 deviceId; + u64 type; + char name[64]; + CellAudioOutSoundMode2 availableModes2[16]; +}; + +struct CellAudioOutOption +{ + //(Omitted) +}; + +struct CellAudioOutRegistrationOption +{ + //(Omitted) +}; + +struct CellAudioOutDeviceConfiguration +{ + //(Omitted) +}; + +struct CellAudioInSoundMode +{ + u8 type; + u8 channel; + u16 fs; + u8 reserved[4]; +}; + +struct CellAudioInDeviceInfo +{ + u8 portType; + u8 availableModeCount; + u8 state; + u8 deviceNumber; + u8 reserved[12]; + u64 deviceId; + u64 type; + char name[64]; + CellAudioInSoundMode availableModes[16]; +}; + +struct CellAudioInRegistrationOption +{ + //(Omitted) +}; + +struct CellAudioInDeviceConfiguration +{ + u8 volume; + u8 reserved[31]; +}; + diff --git a/rpcs3/Emu/SysCalls/Modules/cellAudio.cpp b/rpcs3/Emu/SysCalls/Modules/cellAudio.cpp index 0b33d9eedf..556d73b040 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellAudio.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellAudio.cpp @@ -1,6 +1,7 @@ #include "stdafx.h" #include "Emu/SysCalls/SysCalls.h" #include "Emu/SysCalls/SC_FUNC.h" +#include "Emu/Audio/cellAudio.h" void cellAudio_init(); Module cellAudio(0x0011, cellAudio_init); @@ -78,8 +79,16 @@ struct CellAudioPortConfig be_t portAddr; }; -CellAudioPortParam current_AudioPortParam; -CellAudioPortConfig current_AudioPortConfig; +struct CellAudioConfig //custom structure +{ + bool g_is_audio_initialized; + bool g_is_audio_port_open; + bool g_is_audio_port_started; +}; + +CellAudioPortParam* m_param = new CellAudioPortParam; + +CellAudioConfig* m_config = new CellAudioConfig; //libmixer datatypes typedef void * CellAANHandle; @@ -183,171 +192,218 @@ struct CellSoundSynth2EffectAttr }; // libaudio Functions -bool g_is_audio_initialized = false; int cellAudioInit() { - UNIMPLEMENTED_FUNC(cellAudio); - if(g_is_audio_initialized) return CELL_AUDIO_ERROR_ALREADY_INIT; - g_is_audio_initialized = true; + cellAudio.Warning("cellAudioInit()"); + if(m_config->g_is_audio_initialized == true) return CELL_AUDIO_ERROR_ALREADY_INIT; + m_config->g_is_audio_initialized = true; return CELL_OK; } int cellAudioQuit() { - UNIMPLEMENTED_FUNC(cellAudio); - if (g_is_audio_initialized) return CELL_AUDIO_ERROR_NOT_INIT; - g_is_audio_initialized = false; + cellAudio.Warning("cellAudioQuit()"); + if (m_config->g_is_audio_initialized == false) return CELL_AUDIO_ERROR_NOT_INIT; + m_config->g_is_audio_initialized = false; + + delete m_config; return CELL_OK; } -// Audio Ports Setting/Operation Functions -bool g_is_audio_port_open = false; -bool g_is_audio_port_start = false; - int cellAudioPortOpen(mem_ptr_t audioParam, mem32_t portNum) { + cellAudio.Warning("cellAudioPortOpen(audioParam_addr=0x%x,portNum_addr=0x%x)",audioParam.GetAddr(),portNum.GetAddr()); UNIMPLEMENTED_FUNC(cellAudio); - if(g_is_audio_port_open) return CELL_AUDIO_ERROR_PORT_OPEN; - g_is_audio_port_open = true; + + if(!audioParam.IsGood() || !portNum.IsGood()) return CELL_AUDIO_ERROR_PORT_OPEN; + m_config->g_is_audio_port_open == true; + + m_param->nChannel = audioParam->nChannel; + m_param->nBlock = audioParam->nBlock; + m_param->attr = audioParam->attr; + m_param->level = audioParam->level; + + //TODO: implementation of ring buffer + return CELL_OK; +} + +int cellAudioGetPortConfig(u32 portNum, mem_ptr_t portConfig) +{ + cellAudio.Warning("cellAudioGetPortConfig(portNum=0x%x,portConfig_addr=0x%x)",portNum,portConfig.GetAddr()); + + if(!portConfig.IsGood()) + { + return CELL_AUDIO_ERROR_PARAM; + }; + + //if(portNum > 7) return CELL_AUDIO_ERROR_PORT_FULL; + + if(m_config->g_is_audio_port_open == false) + { + portConfig->status = CELL_AUDIO_STATUS_CLOSE; + return CELL_OK; + }; + + if(m_config->g_is_audio_port_started == true) + portConfig->status = CELL_AUDIO_STATUS_RUN; + + else + portConfig->status = CELL_AUDIO_STATUS_READY; + portConfig->nChannel = m_param->nChannel; + portConfig->nBlock = m_param->nBlock; + portConfig->portSize = sizeof(float)*256*(m_param->nChannel)*(m_param->nBlock); + portConfig->portAddr = Memory.Alloc(portConfig->portSize, 4); // 0x20020000 WARNING: Memory leak. + portConfig->readIndexAddr = Memory.Alloc(m_param->nBlock, 4); // 0x20010010 on ps3 WARNING: Memory leak. + + // portAddr - readIndexAddr == 0xFFF0 on ps3 + Memory.Write64(portConfig->readIndexAddr, 1); + return CELL_OK; +} + +int cellAudioPortStart(u32 portNum) +{ + cellAudio.Warning("cellAudioPortStart(portNum=0x%x)",portNum); + + if (m_config->g_is_audio_port_open == false) return CELL_AUDIO_ERROR_PORT_NOT_OPEN; + m_config->g_is_audio_port_started = true; + return CELL_OK; } int cellAudioPortClose(u32 portNum) { - UNIMPLEMENTED_FUNC(cellAudio); - if(g_is_audio_port_open) return CELL_AUDIO_ERROR_PORT_NOT_OPEN; - g_is_audio_port_open = false; - return CELL_OK; -} + cellAudio.Warning("cellAudioPortClose(portNum=0x%x)",portNum); + if (m_config->g_is_audio_port_open == false) return CELL_AUDIO_ERROR_PORT_NOT_OPEN; + m_config->g_is_audio_port_open = false; -int cellAudioPortStart(u32 portNum) -{ UNIMPLEMENTED_FUNC(cellAudio); - if(g_is_audio_port_start) return CELL_AUDIO_ERROR_PORT_ALREADY_RUN; - g_is_audio_port_start = true; return CELL_OK; } int cellAudioPortStop(u32 portNum) { - UNIMPLEMENTED_FUNC(cellAudio); - if(g_is_audio_port_start) return CELL_AUDIO_ERROR_PORT_NOT_RUN; - g_is_audio_port_start = false; - return CELL_OK; -} + cellAudio.Warning("cellAudioPortStop(portNum=0x%x)",portNum); + if (m_config->g_is_audio_port_started == false) return CELL_AUDIO_ERROR_PORT_NOT_OPEN; + m_config->g_is_audio_port_started = false; -int cellAudioGetPortTimestamp() //u32 portNum, u64 tag, u64 *stamp -{ UNIMPLEMENTED_FUNC(cellAudio); return CELL_OK; } -int cellAudioGetPortConfig(mem32_t portNum, mem_ptr_t portConfig) +int cellAudioGetPortTimestamp(u32 portNum, u64 tag, mem64_t stamp) { + cellAudio.Warning("cellAudioGetPortTimestamp(portNum=0x%x,tag=0x%x,stamp=0x%x)",portNum,tag,stamp.GetAddr()); UNIMPLEMENTED_FUNC(cellAudio); - //TODO - portConfig->nBlock = 8; - portConfig->nChannel = 2; - portConfig->portSize = 256 * portConfig->nBlock * portConfig->nChannel; - portConfig->portAddr = Memory.Alloc(portConfig->portSize, 4); //WARNING: Memory leak. - portConfig->readIndexAddr = Memory.Alloc(8, 4); //WARNING: Memory leak. - portConfig->status = 2; - Memory.Write64(portConfig->readIndexAddr, 1); - return CELL_OK; } -int cellAudioGetPortBlockTag() //u32 portNum, u64 blockNo, u64 *tag +int cellAudioGetPortBlockTag(u32 portNum, u64 blockNo, mem64_t tag) { + cellAudio.Warning("cellAudioGetPortBlockTag(portNum=0x%x,blockNo=0x%x,tag=0x%x)",portNum,blockNo,tag.GetAddr()); UNIMPLEMENTED_FUNC (cellAudio); return CELL_OK; } int cellAudioSetPortLevel(u32 portNum, float level) { + cellAudio.Warning("cellAudioSetPortLevel(portNum=0x%x,level=0x%x)",portNum,level); UNIMPLEMENTED_FUNC(cellAudio); return CELL_OK; } // Utility Functions -int cellAudioCreateNotifyEventQueue() //u32 *id, u64 *key +int cellAudioCreateNotifyEventQueue(mem32_t id, mem64_t key) { + cellAudio.Warning("cellAudioCreateNotifyEventQueue(id=0x%x,key=0x%x)",id.GetAddr(),key.GetAddr()); UNIMPLEMENTED_FUNC(cellAudio); return CELL_OK; } -int cellAudioCreateNotifyEventQueueEx(u32 *id, u64 *key, u32 iFlags) +int cellAudioCreateNotifyEventQueueEx(mem32_t id, mem64_t key, u32 iFlags) { + cellAudio.Warning("cellAudioCreateNotifyEventQueueEx(id=0x%x,key=0x%x,iFlags=0x%x)",id.GetAddr(),key.GetAddr(),iFlags); UNIMPLEMENTED_FUNC(cellAudio); return CELL_OK; } int cellAudioSetNotifyEventQueue(u64 key) { + cellAudio.Warning("cellAudioSetNotifyEventQueue(key=0x%x)",key); UNIMPLEMENTED_FUNC(cellAudio); return CELL_OK; } int cellAudioSetNotifyEventQueueEx(u64 key, u32 iFlags) { + cellAudio.Warning("cellAudioSetNotifyEventQueueEx(key=0x%x,iFlags=0x%x)",key,iFlags); UNIMPLEMENTED_FUNC(cellAudio); return CELL_OK; } int cellAudioRemoveNotifyEventQueue(u64 key) { + cellAudio.Warning("cellAudioRemoveNotifyEventQueue(key=0x%x)",key); UNIMPLEMENTED_FUNC(cellAudio); return CELL_OK; } int cellAudioRemoveNotifyEventQueueEx(u64 key, u32 iFlags) { + cellAudio.Warning("cellAudioRemoveNotifyEventQueueEx(key=0x%x,iFlags=0x%x)",key,iFlags); UNIMPLEMENTED_FUNC(cellAudio); return CELL_OK; } -int cellAudioAddData() //u32 portNum, float *src, unsigned int samples, float volume +int cellAudioAddData(u32 portNum, mem32_t src, uint samples, float volume) { + cellAudio.Warning("cellAudioAddData(portNum=0x%x,src=0x%x,samples=0x%x,volume=0x%x)",portNum,src.GetAddr(),samples,volume); UNIMPLEMENTED_FUNC(cellAudio); return CELL_OK; } -int cellAudioAdd2chData() //u32 portNum, float *src, unsigned int samples, float volume +int cellAudioAdd2chData(u32 portNum, mem32_t src, uint samples, float volume) { + cellAudio.Warning("cellAudioAdd2chData(portNum=0x%x,src=0x%x,samples=0x%x,volume=0x%x)",portNum,src.GetAddr(),samples,volume); + UNIMPLEMENTED_FUNC(cellAudio); + return CELL_OK; +} + +int cellAudioAdd6chData(u32 portNum, mem32_t src, float volume) +{ + cellAudio.Warning("cellAudioAdd6chData(portNum=0x%x,src=0x%x,volume=0x%x)",portNum,src.GetAddr(),volume); UNIMPLEMENTED_FUNC(cellAudio); return CELL_OK; } int cellAudioMiscSetAccessoryVolume(u32 devNum, float volume) { + cellAudio.Warning("cellAudioMiscSetAccessoryVolume(devNum=0x%x,volume=0x%x)",devNum,volume); UNIMPLEMENTED_FUNC(cellAudio); return CELL_OK; } int cellAudioSendAck(u64 data3) { + cellAudio.Warning("cellAudioSendAck(data3=0x%x)",data3); UNIMPLEMENTED_FUNC(cellAudio); return CELL_OK; } int cellAudioSetPersonalDevice(int iPersonalStream, int iDevice) { + cellAudio.Warning("cellAudioSetPersonalDevice(iPersonalStream=0x%x,iDevice=0x%x)",iPersonalStream,iDevice); UNIMPLEMENTED_FUNC(cellAudio); return CELL_OK; } int cellAudioUnsetPersonalDevice(int iPersonalStream) { + cellAudio.Warning("cellAudioUnsetPersonalDevice(iPersonalStream=0x%x)",iPersonalStream); UNIMPLEMENTED_FUNC(cellAudio); return CELL_OK; } -int cellAudioAdd6chData(u32 portNum, float *src, float volume) -{ - UNIMPLEMENTED_FUNC(cellAudio); - return CELL_OK; -} //Callback Functions typedef int (*CellSurMixerNotifyCallbackFunction)(void *arg, u32 counter, u32 samples); //Currently unused. diff --git a/rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp b/rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp index 18ff6343a6..fce3c5960f 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp @@ -1,6 +1,7 @@ #include "stdafx.h" #include "Emu/SysCalls/SysCalls.h" #include "Emu/SysCalls/SC_FUNC.h" +#include "Emu/Audio/sysutil_audio.h" // Parameter IDs enum @@ -526,6 +527,255 @@ int cellMsgDialogOpen2(u32 type, char* msgString, u32 callback_addr, u32 userDat return CELL_OK; } + +int cellAudioOutGetSoundAvailability(u32 audioOut, u32 type, u32 fs, u32 option) +{ + cellSysutil.Warning("cellAudioOutGetSoundAvailability(audioOut=%d,type=%d,fs=%d,option=%d)", + audioOut,type,fs,option); + + option = 0; + + switch(fs) + { + case CELL_AUDIO_OUT_FS_32KHZ: + case CELL_AUDIO_OUT_FS_44KHZ: + case CELL_AUDIO_OUT_FS_48KHZ: + case CELL_AUDIO_OUT_FS_88KHZ: + case CELL_AUDIO_OUT_FS_96KHZ: + case CELL_AUDIO_OUT_FS_176KHZ: + case CELL_AUDIO_OUT_FS_192KHZ: + break; + + default: CELL_AUDIO_OUT_ERROR_UNSUPPORTED_SOUND_MODE; + } + + switch(type) + { + case CELL_AUDIO_OUT_CODING_TYPE_LPCM: + case CELL_AUDIO_OUT_CODING_TYPE_AC3: + case CELL_AUDIO_OUT_CODING_TYPE_DTS: + break; + + default: CELL_AUDIO_OUT_ERROR_UNSUPPORTED_SOUND_MODE; + } + + switch(audioOut) + { + case CELL_AUDIO_OUT_PRIMARY: return 1; + case CELL_AUDIO_OUT_SECONDARY: return 0; + } + + CELL_AUDIO_OUT_ERROR_ILLEGAL_CONFIGURATION; + +} + +int cellAudioOutGetSoundAvailability2(u32 audioOut, u32 type, u32 fs, u32 ch, u32 option) +{ + cellSysutil.Warning("cellAudioOutGetSoundAvailability(audioOut=%d,type=%d,fs=%d,ch=%d,option=%d)", + audioOut,type,fs,ch,option); + + option = 0; + + switch(fs) + { + case CELL_AUDIO_OUT_FS_32KHZ: + case CELL_AUDIO_OUT_FS_44KHZ: + case CELL_AUDIO_OUT_FS_48KHZ: + case CELL_AUDIO_OUT_FS_88KHZ: + case CELL_AUDIO_OUT_FS_96KHZ: + case CELL_AUDIO_OUT_FS_176KHZ: + case CELL_AUDIO_OUT_FS_192KHZ: + break; + + default: CELL_AUDIO_OUT_ERROR_UNSUPPORTED_SOUND_MODE; + } + + switch(ch) + { + case 2: + case 6: + case 8: + break; + + default: CELL_AUDIO_OUT_ERROR_UNSUPPORTED_SOUND_MODE; + } + + switch(type) + { + case CELL_AUDIO_OUT_CODING_TYPE_LPCM: + case CELL_AUDIO_OUT_CODING_TYPE_AC3: + case CELL_AUDIO_OUT_CODING_TYPE_DTS: + break; + + default: CELL_AUDIO_OUT_ERROR_UNSUPPORTED_SOUND_MODE; + } + + switch(audioOut) + { + case CELL_AUDIO_OUT_PRIMARY: return 1; + case CELL_AUDIO_OUT_SECONDARY: return 0; + } + + CELL_AUDIO_OUT_ERROR_ILLEGAL_CONFIGURATION; + +} + +int cellAudioOutGetState(u32 audioOut, u32 deviceIndex, u32 state_addr) +{ + cellSysutil.Warning("cellAudioOutGetState(audioOut=0x%x,deviceIndex=0x%x,state_addr=0x%x)",audioOut,deviceIndex,state_addr); + CellAudioOutState state; + memset(&state, 0, sizeof(CellAudioOutState)); + + switch(audioOut) + { + case CELL_AUDIO_OUT_PRIMARY: + { + state.state = Emu.GetAudioManager().GetState(); + state.soundMode.type = Emu.GetAudioManager().GetInfo().mode.type; + state.soundMode.channel = Emu.GetAudioManager().GetInfo().mode.channel; + state.soundMode.fs = Emu.GetAudioManager().GetInfo().mode.fs; + state.soundMode.layout = Emu.GetAudioManager().GetInfo().mode.layout; + + Memory.WriteData(state_addr, state); + } + return CELL_AUDIO_OUT_SUCCEEDED; + + case CELL_AUDIO_OUT_SECONDARY: + { + state.state = CELL_AUDIO_OUT_OUTPUT_STATE_ENABLED; + + Memory.WriteData(state_addr, state); + } + return CELL_AUDIO_OUT_SUCCEEDED; + } + + return CELL_AUDIO_OUT_ERROR_UNSUPPORTED_AUDIO_OUT; +} + +int cellAudioOutConfigure(u32 audioOut, u32 config_addr, u32 option_addr, u32 waitForEvent) +{ + cellSysutil.Warning("cellAudioOutConfigure(audioOut=%d, config_addr=0x%x, option_addr=0x%x, waitForEvent=0x%x)", + audioOut, config_addr, option_addr, waitForEvent); + + if(!Memory.IsGoodAddr(config_addr, sizeof(CellAudioOutConfiguration))) + { + return CELL_EFAULT; + } + + CellAudioOutConfiguration& config = (CellAudioOutConfiguration&)Memory[config_addr]; + + switch(audioOut) + { + case CELL_AUDIO_OUT_PRIMARY: + if(config.channel) + { + Emu.GetAudioManager().GetInfo().mode.channel = config.channel; + } + + Emu.GetAudioManager().GetInfo().mode.encoder = config.encoder; + + if(config.downMixer) + { + Emu.GetAudioManager().GetInfo().mode.downMixer = config.downMixer; + } + + return CELL_AUDIO_OUT_SUCCEEDED; + + case CELL_AUDIO_OUT_SECONDARY: + return CELL_AUDIO_OUT_SUCCEEDED; + } + + return CELL_AUDIO_OUT_ERROR_UNSUPPORTED_AUDIO_OUT; +} + +int cellAudioOutGetConfiguration(u32 audioOut, u32 config_addr, u32 option_addr) +{ + cellSysutil.Warning("cellAudioOutGetConfiguration(audioOut=%d, config_addr=0x%x, option_addr=0x%x)", + audioOut, config_addr, option_addr); + + if(!Memory.IsGoodAddr(config_addr, sizeof(CellAudioOutConfiguration))) return CELL_EFAULT; + + CellAudioOutConfiguration config; + memset(&config, 0, sizeof(CellAudioOutConfiguration)); + + switch(audioOut) + { + case CELL_AUDIO_OUT_PRIMARY: + config.channel = Emu.GetAudioManager().GetInfo().mode.channel; + config.encoder = Emu.GetAudioManager().GetInfo().mode.encoder; + config.downMixer = Emu.GetAudioManager().GetInfo().mode.downMixer; + + Memory.WriteData(config_addr, config); + + return CELL_AUDIO_OUT_SUCCEEDED; + + case CELL_AUDIO_OUT_SECONDARY: + Memory.WriteData(config_addr, config); + + return CELL_AUDIO_OUT_SUCCEEDED; + } + + return CELL_AUDIO_OUT_ERROR_UNSUPPORTED_AUDIO_OUT; +} + +int cellAudioOutGetNumberOfDevice(u32 audioOut) +{ + cellSysutil.Warning("cellAudioOutGetNumberOfDevice(videoOut=%d)",audioOut); + + switch(audioOut) + { + case CELL_AUDIO_OUT_PRIMARY: return 1; + case CELL_AUDIO_OUT_SECONDARY: return 0; + } + + CELL_AUDIO_OUT_ERROR_UNSUPPORTED_AUDIO_OUT; +} + +int cellAudioOutGetDeviceInfo(u32 audioOut, u32 deviceIndex, mem_ptr_t info) +{ + cellSysutil.Error("Unimplemented function: cellAudioOutGetDeviceInfo(audioOut=%u, deviceIndex=%u, info_addr=0x%x)", + audioOut, deviceIndex, info.GetAddr()); + + if(deviceIndex) return CELL_AUDIO_OUT_ERROR_DEVICE_NOT_FOUND; + + info->portType = CELL_AUDIO_OUT_PORT_HDMI; + info->availableModeCount = 1; + info->state = CELL_AUDIO_OUT_DEVICE_STATE_AVAILABLE; + info->latency = 1000; + info->availableModes[0].type = CELL_AUDIO_IN_CODING_TYPE_LPCM; + info->availableModes[0].channel = CELL_AUDIO_OUT_CHNUM_2; + info->availableModes[0].fs = CELL_AUDIO_OUT_FS_48KHZ; + info->availableModes[0].layout = CELL_AUDIO_OUT_SPEAKER_LAYOUT_2CH; + + return CELL_AUDIO_OUT_SUCCEEDED; +} + +int cellAudioOutSetCopyControl(u32 audioOut, u32 control) +{ + cellSysutil.Warning("cellAudioOutSetCopyControl(audioOut=%d,control=%d)",audioOut,control); + + switch(audioOut) + { + case CELL_AUDIO_OUT_PRIMARY: + case CELL_AUDIO_OUT_SECONDARY: + break; + + default: CELL_AUDIO_OUT_ERROR_UNSUPPORTED_AUDIO_OUT; + } + + switch(control) + { + case CELL_AUDIO_OUT_COPY_CONTROL_COPY_FREE: + case CELL_AUDIO_OUT_COPY_CONTROL_COPY_ONCE: + case CELL_AUDIO_OUT_COPY_CONTROL_COPY_NEVER: + break; + + default: CELL_AUDIO_OUT_ERROR_ILLEGAL_PARAMETER; + } + + return CELL_AUDIO_OUT_SUCCEEDED; +} + void cellSysutil_init() { cellSysutil.AddFunc(0x40e895d3, cellSysutilGetSystemParamInt); @@ -544,4 +794,13 @@ void cellSysutil_init() cellSysutil.AddFunc(0x02ff3c1b, cellSysutilUnregisterCallback); cellSysutil.AddFunc(0x7603d3db, cellMsgDialogOpen2); + + cellSysutil.AddFunc(0xf4e3caa0, cellAudioOutGetState); + cellSysutil.AddFunc(0x4692ab35, cellAudioOutConfigure); + cellSysutil.AddFunc(0xc01b4e7c, cellAudioOutGetSoundAvailability); + cellSysutil.AddFunc(0x2beac488, cellAudioOutGetSoundAvailability2); + cellSysutil.AddFunc(0x7663e368, cellAudioOutGetDeviceInfo); + cellSysutil.AddFunc(0xe5e2b09d, cellAudioOutGetNumberOfDevice); + cellSysutil.AddFunc(0xed5d96af, cellAudioOutGetConfiguration); + cellSysutil.AddFunc(0xc96e89e9, cellAudioOutSetCopyControl); } \ No newline at end of file diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index 368ac13a8e..8baf56e9ed 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -351,6 +351,7 @@ void Emulator::Load() GetGSManager().Init(); GetCallbackManager().Init(); + GetAudioManager().Init(); thread.Run(); @@ -450,6 +451,7 @@ void Emulator::Stop() m_vfs.UnMountAll(); GetGSManager().Close(); + GetAudioManager().Close(); GetCPU().Close(); //SysCallsManager.Close(); GetIdManager().Clear(); diff --git a/rpcs3/Emu/System.h b/rpcs3/Emu/System.h index 04da0a30e8..f49200814a 100644 --- a/rpcs3/Emu/System.h +++ b/rpcs3/Emu/System.h @@ -6,6 +6,7 @@ #include "Emu/Io/Keyboard.h" #include "Emu/Io/Mouse.h" #include "Emu/GS/GSManager.h" +#include "Emu/Audio/AudioManager.h" #include "Emu/FS/VFS.h" #include "Emu/DbgConsole.h" #include "Loader/Loader.h" @@ -85,6 +86,7 @@ class Emulator IdManager m_id_manager; DbgConsole* m_dbg_console; GSManager m_gs_manager; + AudioManager m_audio_manager; CallbackManager m_callback_manager; VFS m_vfs; @@ -118,6 +120,7 @@ public: IdManager& GetIdManager() { return m_id_manager; } DbgConsole& GetDbgCon() { return *m_dbg_console; } GSManager& GetGSManager() { return m_gs_manager; } + AudioManager& GetAudioManager() { return m_audio_manager; } CallbackManager& GetCallbackManager() { return m_callback_manager; } VFS& GetVFS() { return m_vfs; } Array& GetBreakPoints() { return m_break_points; } diff --git a/rpcs3/Gui/ConLog.cpp b/rpcs3/Gui/ConLog.cpp index c505691d17..34d6e1a6b9 100644 --- a/rpcs3/Gui/ConLog.cpp +++ b/rpcs3/Gui/ConLog.cpp @@ -198,6 +198,18 @@ void LogWriter::Warning(const wxString fmt, ...) WriteToLog("W", frmt.mb_str(), "Yellow"); } +void LogWriter::Success(const wxString fmt, ...) +{ + va_list list; + va_start(list, fmt); + + const wxString& frmt = FormatV(fmt, list); + + va_end(list); + + WriteToLog("S", frmt.mb_str(), "Green"); +} + void LogWriter::SkipLn() { WriteToLog("", "", "Black"); diff --git a/rpcs3/Gui/ConLog.h b/rpcs3/Gui/ConLog.h index 65ddda6531..6d2535e04f 100644 --- a/rpcs3/Gui/ConLog.h +++ b/rpcs3/Gui/ConLog.h @@ -19,6 +19,7 @@ public: virtual void Write(const wxString fmt, ...); virtual void Error(const wxString fmt, ...); virtual void Warning(const wxString fmt, ...); + virtual void Success(const wxString fmt, ...); virtual void SkipLn(); }; diff --git a/rpcs3/Gui/MainFrame.cpp b/rpcs3/Gui/MainFrame.cpp index a8c1bac8fc..f2fb857920 100644 --- a/rpcs3/Gui/MainFrame.cpp +++ b/rpcs3/Gui/MainFrame.cpp @@ -28,6 +28,7 @@ enum IDs id_sys_send_open_menu, id_sys_send_exit, id_config_emu, + id_config_pad, id_config_vfs_manager, id_config_vhdd_manager, id_tools_compiler, @@ -36,6 +37,26 @@ enum IDs id_update_dbg, }; +enum PadIDs +{ + id_pad_left, + id_pad_down, + id_pad_right, + id_pad_up, + id_pad_start, + id_pad_r3, + id_pad_l3, + id_pad_select, + id_pad_square, + id_pad_cross, + id_pad_circle, + id_pad_triangle, + id_pad_r1, + id_pad_l1, + id_pad_r2, + id_pad_l2, +}; + wxString GetPaneName() { static int pane_num = 0; @@ -122,6 +143,7 @@ MainFrame::MainFrame() menu_sys.Append(id_sys_send_exit, "Send exit cmd")->Enable(false); menu_conf.Append(id_config_emu, "Settings"); + menu_conf.Append(id_config_pad, "PAD Settings"); menu_conf.AppendSeparator(); menu_conf.Append(id_config_vfs_manager, "Virtual File System Manager"); menu_conf.Append(id_config_vhdd_manager, "Virtual HDD Manager"); @@ -146,6 +168,7 @@ MainFrame::MainFrame() Connect( id_sys_send_exit, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::SendExit) ); Connect( id_config_emu, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::Config) ); + Connect( id_config_pad, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::ConfigPad) ); Connect( id_config_vfs_manager, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::ConfigVFS) ); Connect( id_config_vhdd_manager,wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::ConfigVHDD) ); @@ -208,7 +231,7 @@ void MainFrame::BootGame(wxCommandEvent& WXUNUSED(event)) if(Emu.BootGame(ctrl.GetPath().c_str())) { - ConLog.Write("Game: boot done."); + ConLog.Success("Game: boot done."); } else { @@ -274,7 +297,7 @@ void MainFrame::InstallPkg(wxCommandEvent& WXUNUSED(event)) // Save the title ID. Emu.SetTitleID(titleID); - ConLog.Write("PKG: extract done."); + ConLog.Success("PKG: extract done."); // Travel to the main dir. wxSetWorkingDirectory(mainDir); @@ -315,7 +338,7 @@ void MainFrame::BootElf(wxCommandEvent& WXUNUSED(event)) Emu.SetPath(ctrl.GetPath()); Emu.Load(); - ConLog.Write("(S)ELF: boot done."); + ConLog.Success("(S)ELF: boot done."); } void MainFrame::Pause(wxCommandEvent& WXUNUSED(event)) @@ -382,6 +405,9 @@ void MainFrame::Config(wxCommandEvent& WXUNUSED(event)) wxStaticBoxSizer* s_round_pad_handler( new wxStaticBoxSizer( wxVERTICAL, &diag, _("Pad Handler") ) ); wxStaticBoxSizer* s_round_keyboard_handler( new wxStaticBoxSizer( wxVERTICAL, &diag, _("Keyboard Handler") ) ); wxStaticBoxSizer* s_round_mouse_handler( new wxStaticBoxSizer( wxVERTICAL, &diag, _("Mouse Handler") ) ); + + wxStaticBoxSizer* s_round_audio( new wxStaticBoxSizer( wxVERTICAL, &diag, _("Audio") ) ); + wxStaticBoxSizer* s_round_audio_out( new wxStaticBoxSizer( wxVERTICAL, &diag, _("Audio Out") ) ); wxComboBox* cbox_cpu_decoder = new wxComboBox(&diag, wxID_ANY); wxComboBox* cbox_gs_render = new wxComboBox(&diag, wxID_ANY); @@ -390,6 +416,7 @@ void MainFrame::Config(wxCommandEvent& WXUNUSED(event)) wxComboBox* cbox_pad_handler = new wxComboBox(&diag, wxID_ANY); wxComboBox* cbox_keyboard_handler = new wxComboBox(&diag, wxID_ANY); wxComboBox* cbox_mouse_handler = new wxComboBox(&diag, wxID_ANY); + wxComboBox* cbox_audio_out = new wxComboBox(&diag, wxID_ANY); wxCheckBox* chbox_cpu_ignore_rwerrors = new wxCheckBox(&diag, wxID_ANY, "Ignore Read/Write errors"); wxCheckBox* chbox_gs_dump_depth = new wxCheckBox(&diag, wxID_ANY, "Dump Depth Buffer"); @@ -424,6 +451,8 @@ void MainFrame::Config(wxCommandEvent& WXUNUSED(event)) cbox_mouse_handler->Append("Windows"); //cbox_mouse_handler->Append("DirectInput"); + cbox_audio_out->Append("Null"); + chbox_cpu_ignore_rwerrors->SetValue(Ini.CPUIgnoreRWErrors.GetValue()); chbox_gs_dump_depth->SetValue(Ini.GSDumpDepthBuffer.GetValue()); chbox_gs_dump_color->SetValue(Ini.GSDumpColorBuffers.GetValue()); @@ -436,6 +465,7 @@ void MainFrame::Config(wxCommandEvent& WXUNUSED(event)) cbox_pad_handler->SetSelection(Ini.PadHandlerMode.GetValue()); cbox_keyboard_handler->SetSelection(Ini.KeyboardHandlerMode.GetValue()); cbox_mouse_handler->SetSelection(Ini.MouseHandlerMode.GetValue()); + cbox_audio_out->SetSelection(Ini.AudioOutMode.GetValue()); s_round_cpu_decoder->Add(cbox_cpu_decoder, wxSizerFlags().Border(wxALL, 5).Expand()); s_round_cpu->Add(s_round_cpu_decoder, wxSizerFlags().Border(wxALL, 5).Expand()); @@ -458,6 +488,9 @@ void MainFrame::Config(wxCommandEvent& WXUNUSED(event)) s_round_io->Add(s_round_keyboard_handler, wxSizerFlags().Border(wxALL, 5).Expand()); s_round_io->Add(s_round_mouse_handler, wxSizerFlags().Border(wxALL, 5).Expand()); + s_round_audio_out->Add(cbox_audio_out, wxSizerFlags().Border(wxALL, 5).Expand()); + s_round_audio->Add(s_round_audio_out, wxSizerFlags().Border(wxALL, 5).Expand()); + wxBoxSizer* s_b_panel(new wxBoxSizer(wxHORIZONTAL)); s_b_panel->Add(new wxButton(&diag, wxID_OK), wxSizerFlags().Border(wxALL, 5).Center()); @@ -468,6 +501,7 @@ void MainFrame::Config(wxCommandEvent& WXUNUSED(event)) s_subpanel1->Add(s_round_cpu, wxSizerFlags().Border(wxALL, 5).Expand()); s_subpanel1->Add(s_round_gs, wxSizerFlags().Border(wxALL, 5).Expand()); s_subpanel2->Add(s_round_io, wxSizerFlags().Border(wxALL, 5).Expand()); + s_subpanel2->Add(s_round_audio, wxSizerFlags().Border(wxALL, 5).Expand()); s_subpanel1->Add(s_b_panel, wxSizerFlags().Border(wxALL, 8).Expand()); s_subpanel2->AddSpacer(180); @@ -489,6 +523,195 @@ void MainFrame::Config(wxCommandEvent& WXUNUSED(event)) Ini.PadHandlerMode.SetValue(cbox_pad_handler->GetSelection()); Ini.KeyboardHandlerMode.SetValue(cbox_keyboard_handler->GetSelection()); Ini.MouseHandlerMode.SetValue(cbox_mouse_handler->GetSelection()); + Ini.AudioOutMode.SetValue(cbox_audio_out->GetSelection()); + + Ini.Save(); + } + + if(paused) Emu.Resume(); +} + +void MainFrame::ConfigPad(wxCommandEvent& WXUNUSED(event)) +{ + bool paused = false; + + if(Emu.IsRunning()) + { + Emu.Pause(); + paused = true; + } + + wxDialog diag(this, wxID_ANY, "PAD Settings", wxDefaultPosition); + + wxBoxSizer* s_panel(new wxBoxSizer(wxHORIZONTAL)); + wxBoxSizer* s_subpanel1(new wxBoxSizer(wxVERTICAL)); + wxBoxSizer* s_subpanel2(new wxBoxSizer(wxVERTICAL)); + wxBoxSizer* s_subpanel3(new wxBoxSizer(wxVERTICAL)); + wxBoxSizer* s_subpanel4(new wxBoxSizer(wxVERTICAL)); + wxBoxSizer* s_subpanel5(new wxBoxSizer(wxVERTICAL)); + + wxStaticBoxSizer* s_round_pad_controls( new wxStaticBoxSizer( wxVERTICAL, &diag, _("Controls") ) ); + wxStaticBoxSizer* s_round_pad_left( new wxStaticBoxSizer( wxVERTICAL, &diag, _("LEFT") ) ); + wxStaticBoxSizer* s_round_pad_down( new wxStaticBoxSizer( wxVERTICAL, &diag, _("DOWN") ) ); + wxStaticBoxSizer* s_round_pad_right( new wxStaticBoxSizer( wxVERTICAL, &diag, _("RIGHT") ) ); + wxStaticBoxSizer* s_round_pad_up( new wxStaticBoxSizer( wxVERTICAL, &diag, _("UP") ) ); + + wxStaticBoxSizer* s_round_pad_shifts_l( new wxStaticBoxSizer( wxVERTICAL, &diag, _("Shifts") ) ); + wxStaticBoxSizer* s_round_pad_l1( new wxStaticBoxSizer( wxVERTICAL, &diag, _("L1") ) ); + wxStaticBoxSizer* s_round_pad_l2( new wxStaticBoxSizer( wxVERTICAL, &diag, _("L2") ) ); + wxStaticBoxSizer* s_round_pad_l3( new wxStaticBoxSizer( wxVERTICAL, &diag, _("L3") ) ); + + wxStaticBoxSizer* s_round_pad_system( new wxStaticBoxSizer( wxVERTICAL, &diag, _("System") ) ); + wxStaticBoxSizer* s_round_pad_select( new wxStaticBoxSizer( wxVERTICAL, &diag, _("SELECT") ) ); + wxStaticBoxSizer* s_round_pad_start( new wxStaticBoxSizer( wxVERTICAL, &diag, _("START") ) ); + + wxStaticBoxSizer* s_round_pad_shifts_r( new wxStaticBoxSizer( wxVERTICAL, &diag, _("Shifts") ) ); + wxStaticBoxSizer* s_round_pad_r1( new wxStaticBoxSizer( wxVERTICAL, &diag, _("R1") ) ); + wxStaticBoxSizer* s_round_pad_r2( new wxStaticBoxSizer( wxVERTICAL, &diag, _("R2") ) ); + wxStaticBoxSizer* s_round_pad_r3( new wxStaticBoxSizer( wxVERTICAL, &diag, _("R3") ) ); + + wxStaticBoxSizer* s_round_pad_buttons( new wxStaticBoxSizer( wxVERTICAL, &diag, _("Buttons") ) ); + wxStaticBoxSizer* s_round_pad_square( new wxStaticBoxSizer( wxVERTICAL, &diag, _("SQUARE") ) ); + wxStaticBoxSizer* s_round_pad_cross( new wxStaticBoxSizer( wxVERTICAL, &diag, _("CROSS") ) ); + wxStaticBoxSizer* s_round_pad_circle( new wxStaticBoxSizer( wxVERTICAL, &diag, _("CIRCLE") ) ); + wxStaticBoxSizer* s_round_pad_triangle( new wxStaticBoxSizer( wxVERTICAL, &diag, _("TRIANGLE") ) ); + + + wxComboBox* cbox_pad_left = new wxComboBox(&diag, wxID_ANY); + wxComboBox* cbox_pad_down = new wxComboBox(&diag, wxID_ANY); + wxComboBox* cbox_pad_right = new wxComboBox(&diag, wxID_ANY); + wxComboBox* cbox_pad_up = new wxComboBox(&diag, wxID_ANY); + wxComboBox* cbox_pad_start = new wxComboBox(&diag, wxID_ANY); + wxComboBox* cbox_pad_r3 = new wxComboBox(&diag, wxID_ANY); + wxComboBox* cbox_pad_l3 = new wxComboBox(&diag, wxID_ANY); + wxComboBox* cbox_pad_select = new wxComboBox(&diag, wxID_ANY); + wxComboBox* cbox_pad_square = new wxComboBox(&diag, wxID_ANY); + wxComboBox* cbox_pad_cross = new wxComboBox(&diag, wxID_ANY); + wxComboBox* cbox_pad_circle = new wxComboBox(&diag, wxID_ANY); + wxComboBox* cbox_pad_triangle = new wxComboBox(&diag, wxID_ANY); + wxComboBox* cbox_pad_r1 = new wxComboBox(&diag, wxID_ANY); + wxComboBox* cbox_pad_l1 = new wxComboBox(&diag, wxID_ANY); + wxComboBox* cbox_pad_r2 = new wxComboBox(&diag, wxID_ANY); + wxComboBox* cbox_pad_l2 = new wxComboBox(&diag, wxID_ANY); + + for(int i=0; i<128; i++) + { + cbox_pad_left->Append (wxString::Format("%c", static_cast(i) ) ); + cbox_pad_down->Append (wxString::Format("%c", static_cast(i) ) ); + cbox_pad_right->Append (wxString::Format("%c", static_cast(i) ) ); + cbox_pad_up->Append (wxString::Format("%c", static_cast(i) ) ); + cbox_pad_r3->Append (wxString::Format("%c", static_cast(i) ) ); + cbox_pad_l3->Append (wxString::Format("%c", static_cast(i) ) ); + cbox_pad_square->Append (wxString::Format("%c", static_cast(i) ) ); + cbox_pad_cross->Append (wxString::Format("%c", static_cast(i) ) ); + cbox_pad_circle->Append (wxString::Format("%c", static_cast(i) ) ); + cbox_pad_triangle->Append (wxString::Format("%c", static_cast(i) ) ); + cbox_pad_r1->Append (wxString::Format("%c", static_cast(i) ) ); + cbox_pad_l1->Append (wxString::Format("%c", static_cast(i) ) ); + cbox_pad_r2->Append (wxString::Format("%c", static_cast(i) ) ); + cbox_pad_l2->Append (wxString::Format("%c", static_cast(i) ) ); + } + + cbox_pad_start->Append("Enter"); + cbox_pad_select->Append("Space"); + + cbox_pad_left->SetSelection (Ini.PadHandlerLeft.GetValue()); + cbox_pad_down->SetSelection (Ini.PadHandlerDown.GetValue()); + cbox_pad_right->SetSelection (Ini.PadHandlerRight.GetValue()); + cbox_pad_up->SetSelection (Ini.PadHandlerUp.GetValue()); + cbox_pad_start->SetSelection (Ini.PadHandlerStart.GetValue()); + cbox_pad_r3->SetSelection (Ini.PadHandlerR3.GetValue()); + cbox_pad_l3->SetSelection (Ini.PadHandlerL3.GetValue()); + cbox_pad_select->SetSelection (Ini.PadHandlerSelect.GetValue()); + cbox_pad_square->SetSelection (Ini.PadHandlerSquare.GetValue()); + cbox_pad_cross->SetSelection (Ini.PadHandlerCross.GetValue()); + cbox_pad_circle->SetSelection (Ini.PadHandlerCircle.GetValue()); + cbox_pad_triangle->SetSelection (Ini.PadHandlerTriangle.GetValue()); + cbox_pad_r1->SetSelection (Ini.PadHandlerR1.GetValue()); + cbox_pad_l1->SetSelection (Ini.PadHandlerL1.GetValue()); + cbox_pad_r2->SetSelection (Ini.PadHandlerR2.GetValue()); + cbox_pad_l2->SetSelection (Ini.PadHandlerL2.GetValue()); + + s_round_pad_left->Add(cbox_pad_left, wxSizerFlags().Border(wxALL, 5).Expand()); + s_round_pad_down->Add(cbox_pad_down, wxSizerFlags().Border(wxALL, 5).Expand()); + s_round_pad_right->Add(cbox_pad_right, wxSizerFlags().Border(wxALL, 5).Expand()); + s_round_pad_up->Add(cbox_pad_up, wxSizerFlags().Border(wxALL, 5).Expand()); + s_round_pad_start->Add(cbox_pad_start, wxSizerFlags().Border(wxALL, 5).Expand()); + s_round_pad_r3->Add(cbox_pad_r3, wxSizerFlags().Border(wxALL, 5).Expand()); + s_round_pad_l3->Add(cbox_pad_l3, wxSizerFlags().Border(wxALL, 5).Expand()); + s_round_pad_select->Add(cbox_pad_select, wxSizerFlags().Border(wxALL, 5).Expand()); + s_round_pad_square->Add(cbox_pad_square, wxSizerFlags().Border(wxALL, 5).Expand()); + s_round_pad_cross->Add(cbox_pad_cross, wxSizerFlags().Border(wxALL, 5).Expand()); + s_round_pad_circle->Add(cbox_pad_circle, wxSizerFlags().Border(wxALL, 5).Expand()); + s_round_pad_triangle->Add(cbox_pad_triangle, wxSizerFlags().Border(wxALL, 5).Expand()); + s_round_pad_r1->Add(cbox_pad_r1, wxSizerFlags().Border(wxALL, 5).Expand()); + s_round_pad_l1->Add(cbox_pad_l1, wxSizerFlags().Border(wxALL, 5).Expand()); + s_round_pad_r2->Add(cbox_pad_r2, wxSizerFlags().Border(wxALL, 5).Expand()); + s_round_pad_l2->Add(cbox_pad_l2, wxSizerFlags().Border(wxALL, 5).Expand()); + + + s_round_pad_controls->Add(s_round_pad_left, wxSizerFlags().Border(wxALL, 5).Expand()); + s_round_pad_controls->Add(s_round_pad_down, wxSizerFlags().Border(wxALL, 5).Expand()); + s_round_pad_controls->Add(s_round_pad_right, wxSizerFlags().Border(wxALL, 5).Expand()); + s_round_pad_controls->Add(s_round_pad_up, wxSizerFlags().Border(wxALL, 5).Expand()); + + + s_round_pad_shifts_l->Add(s_round_pad_l1, wxSizerFlags().Border(wxALL, 5).Expand()); + s_round_pad_shifts_l->Add(s_round_pad_l2, wxSizerFlags().Border(wxALL, 5).Expand()); + s_round_pad_shifts_l->Add(s_round_pad_l3, wxSizerFlags().Border(wxALL, 5).Expand()); + + s_round_pad_system->Add(s_round_pad_start, wxSizerFlags().Border(wxALL, 5).Expand()); + s_round_pad_system->Add(s_round_pad_select, wxSizerFlags().Border(wxALL, 5).Expand()); + + s_round_pad_shifts_r->Add(s_round_pad_r1, wxSizerFlags().Border(wxALL, 5).Expand()); + s_round_pad_shifts_r->Add(s_round_pad_r2, wxSizerFlags().Border(wxALL, 5).Expand()); + s_round_pad_shifts_r->Add(s_round_pad_r3, wxSizerFlags().Border(wxALL, 5).Expand()); + + + s_round_pad_buttons->Add(s_round_pad_square, wxSizerFlags().Border(wxALL, 5).Expand()); + s_round_pad_buttons->Add(s_round_pad_cross, wxSizerFlags().Border(wxALL, 5).Expand()); + s_round_pad_buttons->Add(s_round_pad_circle, wxSizerFlags().Border(wxALL, 5).Expand()); + s_round_pad_buttons->Add(s_round_pad_triangle, wxSizerFlags().Border(wxALL, 5).Expand()); + + wxBoxSizer* s_b_panel(new wxBoxSizer(wxHORIZONTAL)); + + s_b_panel->Add(new wxButton(&diag, wxID_OK), wxSizerFlags().Border(wxALL, 5).Center()); + s_b_panel->Add(new wxButton(&diag, wxID_CANCEL), wxSizerFlags().Border(wxALL, 5).Center()); + + s_subpanel1->Add(s_round_pad_controls, wxSizerFlags().Border(wxALL, 5).Expand()); + s_subpanel2->Add(s_round_pad_shifts_l, wxSizerFlags().Border(wxALL, 5).Expand()); + s_subpanel3->Add(s_round_pad_system, wxSizerFlags().Border(wxALL, 5).Expand()); + s_subpanel3->Add(s_b_panel, wxSizerFlags().Border(wxALL, 8).Expand()); + s_subpanel4->Add(s_round_pad_shifts_r, wxSizerFlags().Border(wxALL, 5).Expand()); + s_subpanel5->Add(s_round_pad_buttons, wxSizerFlags().Border(wxALL, 5).Expand()); + + + s_panel->Add(s_subpanel1, wxSizerFlags().Border(wxALL, 5).Expand()); + s_panel->Add(s_subpanel2, wxSizerFlags().Border(wxALL, 5).Expand()); + s_panel->Add(s_subpanel3, wxSizerFlags().Border(wxALL, 5).Expand()); + s_panel->Add(s_subpanel4, wxSizerFlags().Border(wxALL, 5).Expand()); + s_panel->Add(s_subpanel5, wxSizerFlags().Border(wxALL, 5).Expand()); + + diag.SetSizerAndFit( s_panel ); + + if(diag.ShowModal() == wxID_OK) + { + Ini.PadHandlerLeft.SetValue(cbox_pad_left->GetSelection()); + Ini.PadHandlerDown.SetValue(cbox_pad_down->GetSelection()); + Ini.PadHandlerRight.SetValue(cbox_pad_right->GetSelection()); + Ini.PadHandlerUp.SetValue(cbox_pad_up->GetSelection()); + Ini.PadHandlerStart.SetValue(cbox_pad_start->GetSelection()); + Ini.PadHandlerR3.SetValue(cbox_pad_r3->GetSelection()); + Ini.PadHandlerL3.SetValue(cbox_pad_l3->GetSelection()); + Ini.PadHandlerSelect.SetValue(cbox_pad_select->GetSelection()); + Ini.PadHandlerSquare.SetValue(cbox_pad_square->GetSelection()); + Ini.PadHandlerCross.SetValue(cbox_pad_cross->GetSelection()); + Ini.PadHandlerCircle.SetValue(cbox_pad_circle->GetSelection()); + Ini.PadHandlerTriangle.SetValue(cbox_pad_triangle->GetSelection()); + Ini.PadHandlerR1.SetValue(cbox_pad_r1->GetSelection()); + Ini.PadHandlerL1.SetValue(cbox_pad_l1->GetSelection()); + Ini.PadHandlerR2.SetValue(cbox_pad_r2->GetSelection()); + Ini.PadHandlerL2.SetValue(cbox_pad_l2->GetSelection()); Ini.Save(); } diff --git a/rpcs3/Gui/MainFrame.h b/rpcs3/Gui/MainFrame.h index bc90b3485b..b27e029ea7 100644 --- a/rpcs3/Gui/MainFrame.h +++ b/rpcs3/Gui/MainFrame.h @@ -27,6 +27,7 @@ private: void SendExit(wxCommandEvent& event); void SendOpenCloseSysMenu(wxCommandEvent& event); void Config(wxCommandEvent& event); + void ConfigPad(wxCommandEvent& event); void ConfigVFS(wxCommandEvent& event); void ConfigVHDD(wxCommandEvent& event); void OpenELFCompiler(wxCommandEvent& evt); diff --git a/rpcs3/Ini.h b/rpcs3/Ini.h index dcbfb4f0fb..88a05ccf82 100644 --- a/rpcs3/Ini.h +++ b/rpcs3/Ini.h @@ -103,6 +103,24 @@ public: IniEntry PadHandlerMode; IniEntry KeyboardHandlerMode; IniEntry MouseHandlerMode; + IniEntry AudioOutMode; + + IniEntry PadHandlerLeft; + IniEntry PadHandlerDown; + IniEntry PadHandlerRight; + IniEntry PadHandlerUp; + IniEntry PadHandlerStart; + IniEntry PadHandlerR3; + IniEntry PadHandlerL3; + IniEntry PadHandlerSelect; + IniEntry PadHandlerSquare; + IniEntry PadHandlerCross; + IniEntry PadHandlerCircle; + IniEntry PadHandlerTriangle; + IniEntry PadHandlerR1; + IniEntry PadHandlerL1; + IniEntry PadHandlerR2; + IniEntry PadHandlerL2; public: Inis() : DefPath("EmuSettings") @@ -125,6 +143,27 @@ public: PadHandlerMode.Init("PadHandlerMode", path); KeyboardHandlerMode.Init("KeyboardHandlerMode", path); MouseHandlerMode.Init("MouseHandlerMode", path); + + path = DefPath + "\\" + "ControlSetings"; + PadHandlerLeft.Init("PadHandlerLeft", path); + PadHandlerDown.Init("PadHandlerDown", path); + PadHandlerRight.Init("PadHandlerRight", path); + PadHandlerUp.Init("PadHandlerUp", path); + PadHandlerStart.Init("PadHandlerStart", path); + PadHandlerR3.Init("PadHandlerR3", path); + PadHandlerL3.Init("PadHandlerL3", path); + PadHandlerSelect.Init("PadHandlerSelect", path); + PadHandlerSquare.Init("PadHandlerSquare", path); + PadHandlerCross.Init("PadHandlerCross", path); + PadHandlerCircle.Init("PadHandlerCircle", path); + PadHandlerTriangle.Init("PadHandlerTriangle", path); + PadHandlerR1.Init("PadHandlerR1", path); + PadHandlerL1.Init("PadHandlerL1", path); + PadHandlerR2.Init("PadHandlerR2", path); + PadHandlerL2.Init("PadHandlerL2", path); + + path = DefPath + "\\" + "Audio"; + AudioOutMode.Init("AudioOutMode", path); } void Load() @@ -140,6 +179,24 @@ public: PadHandlerMode.Load(1); KeyboardHandlerMode.Load(0); MouseHandlerMode.Load(0); + AudioOutMode.Load(0); + + PadHandlerLeft.Load(static_cast('A')); + PadHandlerDown.Load(static_cast('S')); + PadHandlerRight.Load(static_cast('D')); + PadHandlerUp.Load(static_cast('W')); + PadHandlerStart.Load(0); + PadHandlerR3.Load(static_cast('C')); + PadHandlerL3.Load(static_cast('Z')); + PadHandlerSelect.Load(0); + PadHandlerSquare.Load(static_cast('L')); + PadHandlerCross.Load(static_cast('K')); + PadHandlerCircle.Load(static_cast('J')); + PadHandlerTriangle.Load(static_cast('I')); + PadHandlerR1.Load(static_cast('3')); + PadHandlerL1.Load(static_cast('1')); + PadHandlerR2.Load(static_cast('E')); + PadHandlerL2.Load(static_cast('Q')); } void Save() @@ -155,6 +212,24 @@ public: PadHandlerMode.Save(); KeyboardHandlerMode.Save(); MouseHandlerMode.Save(); + AudioOutMode.Save(); + + PadHandlerLeft.Save(); + PadHandlerDown.Save(); + PadHandlerRight.Save(); + PadHandlerUp.Save(); + PadHandlerStart.Save(); + PadHandlerR3.Save(); + PadHandlerL3.Save(); + PadHandlerSelect.Save(); + PadHandlerSquare.Save(); + PadHandlerCross.Save(); + PadHandlerCircle.Save(); + PadHandlerTriangle.Save(); + PadHandlerR1.Save(); + PadHandlerL1.Save(); + PadHandlerR2.Save(); + PadHandlerL2.Save(); } }; diff --git a/rpcs3/rpcs3.vcxproj b/rpcs3/rpcs3.vcxproj index 7ab3caffda..64533cf4a3 100644 --- a/rpcs3/rpcs3.vcxproj +++ b/rpcs3/rpcs3.vcxproj @@ -1,4 +1,4 @@ - + @@ -207,6 +207,7 @@ + @@ -318,6 +319,8 @@ + + diff --git a/rpcs3/rpcs3.vcxproj.filters b/rpcs3/rpcs3.vcxproj.filters index 8dd7906d15..d9cf039b7b 100644 --- a/rpcs3/rpcs3.vcxproj.filters +++ b/rpcs3/rpcs3.vcxproj.filters @@ -56,6 +56,9 @@ {52b11fe8-a967-4d52-bf88-a3210d4ffb27} + + {46cb6261-7ba2-4511-b576-4b491c04bed8} + @@ -352,6 +355,9 @@ Emu\SysCalls\Modules + + Emu\Audio + @@ -525,5 +531,11 @@ Include + + Include + + + Include + \ No newline at end of file