From 0b28f0fa14127dbc5f6c951fc4b760a4b26e720d Mon Sep 17 00:00:00 2001 From: Megamouse Date: Fri, 15 Nov 2019 20:15:00 +0100 Subject: [PATCH] HLE: add more error_code --- rpcs3/Emu/Cell/Modules/cellAudioIn.h | 14 +-- rpcs3/Emu/Cell/Modules/cellAudioOut.cpp | 117 ++++++++++++++++------- rpcs3/Emu/Cell/Modules/cellAudioOut.h | 16 ++-- rpcs3/Emu/Cell/Modules/cellAvconfExt.cpp | 68 +++++++++---- rpcs3/Emu/Cell/Modules/cellVideoOut.cpp | 12 +-- 5 files changed, 152 insertions(+), 75 deletions(-) diff --git a/rpcs3/Emu/Cell/Modules/cellAudioIn.h b/rpcs3/Emu/Cell/Modules/cellAudioIn.h index 728a0724b1..126cdac86c 100644 --- a/rpcs3/Emu/Cell/Modules/cellAudioIn.h +++ b/rpcs3/Emu/Cell/Modules/cellAudioIn.h @@ -3,16 +3,16 @@ #include "Utilities/BEType.h" // Error codes -enum +enum CellAudioInError { - 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_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_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, + CELL_AUDIO_IN_ERROR_CONDITION_BUSY = 0x8002b267, }; enum diff --git a/rpcs3/Emu/Cell/Modules/cellAudioOut.cpp b/rpcs3/Emu/Cell/Modules/cellAudioOut.cpp index eec8547c76..a83300da70 100644 --- a/rpcs3/Emu/Cell/Modules/cellAudioOut.cpp +++ b/rpcs3/Emu/Cell/Modules/cellAudioOut.cpp @@ -1,11 +1,32 @@ -#include "stdafx.h" +#include "stdafx.h" #include "Emu/Cell/PPUModule.h" #include "cellAudioOut.h" extern logs::channel cellSysutil; -s32 cellAudioOutGetSoundAvailability(u32 audioOut, u32 type, u32 fs, u32 option) +template<> +void fmt_class_string::format(std::string& out, u64 arg) +{ + format_enum(out, arg, [](auto error) + { + switch (error) + { + STR_CASE(CELL_AUDIO_OUT_ERROR_NOT_IMPLEMENTED); + STR_CASE(CELL_AUDIO_OUT_ERROR_ILLEGAL_CONFIGURATION); + STR_CASE(CELL_AUDIO_OUT_ERROR_ILLEGAL_PARAMETER); + STR_CASE(CELL_AUDIO_OUT_ERROR_PARAMETER_OUT_OF_RANGE); + STR_CASE(CELL_AUDIO_OUT_ERROR_DEVICE_NOT_FOUND); + STR_CASE(CELL_AUDIO_OUT_ERROR_UNSUPPORTED_AUDIO_OUT); + STR_CASE(CELL_AUDIO_OUT_ERROR_UNSUPPORTED_SOUND_MODE); + STR_CASE(CELL_AUDIO_OUT_ERROR_CONDITION_BUSY); + } + + return unknown; + }); +} + +error_code cellAudioOutGetSoundAvailability(u32 audioOut, u32 type, u32 fs, u32 option) { cellSysutil.warning("cellAudioOutGetSoundAvailability(audioOut=%d, type=%d, fs=0x%x, option=%d)", audioOut, type, fs, option); @@ -36,14 +57,14 @@ s32 cellAudioOutGetSoundAvailability(u32 audioOut, u32 type, u32 fs, u32 option) switch (audioOut) { - case CELL_AUDIO_OUT_PRIMARY: return available; - case CELL_AUDIO_OUT_SECONDARY: return 0; + case CELL_AUDIO_OUT_PRIMARY: return not_an_error(available); + case CELL_AUDIO_OUT_SECONDARY: return not_an_error(0); } return CELL_AUDIO_OUT_ERROR_ILLEGAL_CONFIGURATION; } -s32 cellAudioOutGetSoundAvailability2(u32 audioOut, u32 type, u32 fs, u32 ch, u32 option) +error_code cellAudioOutGetSoundAvailability2(u32 audioOut, u32 type, u32 fs, u32 ch, u32 option) { cellSysutil.warning("cellAudioOutGetSoundAvailability2(audioOut=%d, type=%d, fs=0x%x, ch=%d, option=%d)", audioOut, type, fs, ch, option); @@ -83,17 +104,24 @@ s32 cellAudioOutGetSoundAvailability2(u32 audioOut, u32 type, u32 fs, u32 ch, u3 switch (audioOut) { - case CELL_AUDIO_OUT_PRIMARY: return available; - case CELL_AUDIO_OUT_SECONDARY: return 0; + case CELL_AUDIO_OUT_PRIMARY: return not_an_error(available); + case CELL_AUDIO_OUT_SECONDARY: return not_an_error(0); + default: + break; } return CELL_AUDIO_OUT_ERROR_ILLEGAL_CONFIGURATION; } -s32 cellAudioOutGetState(u32 audioOut, u32 deviceIndex, vm::ptr state) +error_code cellAudioOutGetState(u32 audioOut, u32 deviceIndex, vm::ptr state) { cellSysutil.warning("cellAudioOutGetState(audioOut=0x%x, deviceIndex=0x%x, state=*0x%x)", audioOut, deviceIndex, state); + if (!state) + { + return CELL_AUDIO_OUT_ERROR_ILLEGAL_PARAMETER; + } + *state = {}; switch (audioOut) @@ -119,10 +147,15 @@ s32 cellAudioOutGetState(u32 audioOut, u32 deviceIndex, vm::ptr config, vm::ptr option, u32 waitForEvent) +error_code cellAudioOutConfigure(u32 audioOut, vm::ptr config, vm::ptr option, u32 waitForEvent) { cellSysutil.warning("cellAudioOutConfigure(audioOut=%d, config=*0x%x, option=*0x%x, waitForEvent=%d)", audioOut, config, option, waitForEvent); + if (!config) + { + return CELL_AUDIO_OUT_ERROR_ILLEGAL_PARAMETER; + } + switch (audioOut) { case CELL_AUDIO_OUT_PRIMARY: @@ -147,11 +180,20 @@ s32 cellAudioOutConfigure(u32 audioOut, vm::ptr confi return CELL_AUDIO_OUT_ERROR_UNSUPPORTED_AUDIO_OUT; } -s32 cellAudioOutGetConfiguration(u32 audioOut, vm::ptr config, vm::ptr option) +error_code cellAudioOutGetConfiguration(u32 audioOut, vm::ptr config, vm::ptr option) { cellSysutil.warning("cellAudioOutGetConfiguration(audioOut=%d, config=*0x%x, option=*0x%x)", audioOut, config, option); - if (option) *option = {}; + if (!config) + { + return CELL_AUDIO_OUT_ERROR_ILLEGAL_PARAMETER; + } + + if (option) + { + *option = {}; + } + *config = {}; switch (audioOut) @@ -166,29 +208,43 @@ s32 cellAudioOutGetConfiguration(u32 audioOut, vm::ptr info) +error_code cellAudioOutGetDeviceInfo(u32 audioOut, u32 deviceIndex, vm::ptr info) { cellSysutil.todo("cellAudioOutGetDeviceInfo(audioOut=%d, deviceIndex=%d, info=*0x%x)", audioOut, deviceIndex, info); - if (deviceIndex) return CELL_AUDIO_OUT_ERROR_DEVICE_NOT_FOUND; + if (!info) + { + return CELL_AUDIO_OUT_ERROR_ILLEGAL_PARAMETER; + } + + if (deviceIndex) + { + return CELL_AUDIO_OUT_ERROR_DEVICE_NOT_FOUND; + } info->portType = CELL_AUDIO_OUT_PORT_HDMI; info->availableModeCount = 2; @@ -206,51 +262,46 @@ s32 cellAudioOutGetDeviceInfo(u32 audioOut, u32 deviceIndex, vm::ptr CELL_AUDIO_OUT_COPY_CONTROL_COPY_NEVER) + { + return CELL_AUDIO_OUT_ERROR_ILLEGAL_PARAMETER; + } + switch (audioOut) { case CELL_AUDIO_OUT_PRIMARY: case CELL_AUDIO_OUT_SECONDARY: break; - - default: return 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: return CELL_AUDIO_OUT_ERROR_ILLEGAL_PARAMETER; + default: + return CELL_AUDIO_OUT_ERROR_UNSUPPORTED_AUDIO_OUT; } return CELL_OK; } -s32 cellAudioOutConfigure2() +error_code cellAudioOutConfigure2() { cellSysutil.todo("cellAudioOutConfigure2()"); return CELL_OK; } -s32 cellAudioOutGetConfiguration2() +error_code cellAudioOutGetConfiguration2() { cellSysutil.todo("cellAudioOutGetConfiguration2()"); return CELL_OK; } -s32 cellAudioOutRegisterCallback() +error_code cellAudioOutRegisterCallback() { cellSysutil.todo("cellAudioOutRegisterCallback()"); return CELL_OK; } -s32 cellAudioOutUnregisterCallback() +error_code cellAudioOutUnregisterCallback() { cellSysutil.todo("cellAudioOutUnregisterCallback()"); return CELL_OK; diff --git a/rpcs3/Emu/Cell/Modules/cellAudioOut.h b/rpcs3/Emu/Cell/Modules/cellAudioOut.h index eff14f2063..b06940c8e2 100644 --- a/rpcs3/Emu/Cell/Modules/cellAudioOut.h +++ b/rpcs3/Emu/Cell/Modules/cellAudioOut.h @@ -1,18 +1,18 @@ -#pragma once +#pragma once #include "Emu/Memory/vm_ptr.h" // Error codes -enum +enum CellAudioOutError { - 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_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_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_OUT_ERROR_CONDITION_BUSY = 0x8002b247, }; diff --git a/rpcs3/Emu/Cell/Modules/cellAvconfExt.cpp b/rpcs3/Emu/Cell/Modules/cellAvconfExt.cpp index 14ac209a62..124a5db7ce 100644 --- a/rpcs3/Emu/Cell/Modules/cellAvconfExt.cpp +++ b/rpcs3/Emu/Cell/Modules/cellAvconfExt.cpp @@ -12,6 +12,27 @@ LOG_CHANNEL(cellAvconfExt); +template<> +void fmt_class_string::format(std::string& out, u64 arg) +{ + format_enum(out, arg, [](auto error) + { + switch (error) + { + STR_CASE(CELL_AUDIO_IN_ERROR_NOT_IMPLEMENTED); + STR_CASE(CELL_AUDIO_IN_ERROR_ILLEGAL_CONFIGURATION); + STR_CASE(CELL_AUDIO_IN_ERROR_ILLEGAL_PARAMETER); + STR_CASE(CELL_AUDIO_IN_ERROR_PARAMETER_OUT_OF_RANGE); + STR_CASE(CELL_AUDIO_IN_ERROR_DEVICE_NOT_FOUND); + STR_CASE(CELL_AUDIO_IN_ERROR_UNSUPPORTED_AUDIO_IN); + STR_CASE(CELL_AUDIO_IN_ERROR_UNSUPPORTED_SOUND_MODE); + STR_CASE(CELL_AUDIO_IN_ERROR_CONDITION_BUSY); + } + + return unknown; + }); +} + struct avconf_manager { std::vector devices; @@ -121,31 +142,31 @@ void avconf_manager::copy_device_info(u32 num, vm::ptr in strcpy(info->name, devices[num].name); } -s32 cellAudioOutUnregisterDevice(u32 deviceNumber) +error_code cellAudioOutUnregisterDevice(u32 deviceNumber) { cellAvconfExt.todo("cellAudioOutUnregisterDevice(deviceNumber=0x%x)", deviceNumber); return CELL_OK; } -s32 cellAudioOutGetDeviceInfo2(u32 deviceNumber, u32 deviceIndex, vm::ptr info) +error_code cellAudioOutGetDeviceInfo2(u32 deviceNumber, u32 deviceIndex, vm::ptr info) { cellAvconfExt.todo("cellAudioOutGetDeviceInfo2(deviceNumber=0x%x, deviceIndex=0x%x, info=*0x%x)", deviceNumber, deviceIndex, info); return CELL_OK; } -s32 cellVideoOutSetXVColor() +error_code cellVideoOutSetXVColor() { UNIMPLEMENTED_FUNC(cellAvconfExt); return CELL_OK; } -s32 cellVideoOutSetupDisplay() +error_code cellVideoOutSetupDisplay() { UNIMPLEMENTED_FUNC(cellAvconfExt); return CELL_OK; } -s32 cellAudioInGetDeviceInfo(u32 deviceNumber, u32 deviceIndex, vm::ptr info) +error_code cellAudioInGetDeviceInfo(u32 deviceNumber, u32 deviceIndex, vm::ptr info) { cellAvconfExt.todo("cellAudioInGetDeviceInfo(deviceNumber=0x%x, deviceIndex=0x%x, info=*0x%x)", deviceNumber, deviceIndex, info); @@ -159,14 +180,14 @@ s32 cellAudioInGetDeviceInfo(u32 deviceNumber, u32 deviceIndex, vm::ptr src_addr, vm::ptr dest_addr, s32 num) +error_code cellVideoOutConvertCursorColor(u32 videoOut, s32 displaybuffer_format, f32 gamma, s32 source_buffer_format, vm::ptr src_addr, vm::ptr dest_addr, s32 num) { cellAvconfExt.todo("cellVideoOutConvertCursorColor(videoOut=%d, displaybuffer_format=0x%x, gamma=0x%x, source_buffer_format=0x%x, src_addr=*0x%x, dest_addr=*0x%x, num=0x%x)", videoOut, displaybuffer_format, gamma, source_buffer_format, src_addr, dest_addr, num); return CELL_OK; } -s32 cellVideoOutGetGamma(u32 videoOut, vm::ptr gamma) +error_code cellVideoOutGetGamma(u32 videoOut, vm::ptr gamma) { cellAvconfExt.warning("cellVideoOutGetGamma(videoOut=%d, gamma=*0x%x)", videoOut, gamma); @@ -181,7 +202,7 @@ s32 cellVideoOutGetGamma(u32 videoOut, vm::ptr gamma) return CELL_OK; } -s32 cellAudioInGetAvailableDeviceInfo(u32 count, vm::ptr device_info) +error_code cellAudioInGetAvailableDeviceInfo(u32 count, vm::ptr device_info) { cellAvconfExt.todo("cellAudioInGetAvailableDeviceInfo(count=0x%x, info=*0x%x)", count, device_info); @@ -199,16 +220,16 @@ s32 cellAudioInGetAvailableDeviceInfo(u32 count, vm::ptr av_manager->copy_device_info(index, device_info + index); } - return (s32)num_devices_returned; + return not_an_error((s32)num_devices_returned); } -s32 cellAudioOutGetAvailableDeviceInfo(u32 count, vm::ptr info) +error_code cellAudioOutGetAvailableDeviceInfo(u32 count, vm::ptr info) { cellAvconfExt.todo("cellAudioOutGetAvailableDeviceInfo(count=0x%x, info=*0x%x)", count, info); - return 0; // number of available devices + return not_an_error(0); // number of available devices } -s32 cellVideoOutSetGamma(u32 videoOut, f32 gamma) +error_code cellVideoOutSetGamma(u32 videoOut, f32 gamma) { cellAvconfExt.warning("cellVideoOutSetGamma(videoOut=%d, gamma=%f)", videoOut, gamma); @@ -228,38 +249,43 @@ s32 cellVideoOutSetGamma(u32 videoOut, f32 gamma) return CELL_OK; } -s32 cellAudioOutRegisterDevice(u64 deviceType, vm::cptr name, vm::ptr option, vm::ptr config) +error_code cellAudioOutRegisterDevice(u64 deviceType, vm::cptr name, vm::ptr option, vm::ptr config) { cellAvconfExt.todo("cellAudioOutRegisterDevice(deviceType=0x%llx, name=%s, option=*0x%x, config=*0x%x)", deviceType, name, option, config); - return 0; // device number + return not_an_error(0); // device number } -s32 cellAudioOutSetDeviceMode(u32 deviceMode) +error_code cellAudioOutSetDeviceMode(u32 deviceMode) { cellAvconfExt.todo("cellAudioOutSetDeviceMode(deviceMode=0x%x)", deviceMode); return CELL_OK; } -s32 cellAudioInSetDeviceMode(u32 deviceMode) +error_code cellAudioInSetDeviceMode(u32 deviceMode) { cellAvconfExt.todo("cellAudioInSetDeviceMode(deviceMode=0x%x)", deviceMode); return CELL_OK; } -s32 cellAudioInRegisterDevice(u64 deviceType, vm::cptr name, vm::ptr option, vm::ptr config) +error_code cellAudioInRegisterDevice(u64 deviceType, vm::cptr name, vm::ptr option, vm::ptr config) { cellAvconfExt.todo("cellAudioInRegisterDevice(deviceType=0x%llx, name=%s, option=*0x%x, config=*0x%x)", deviceType, name, option, config); - return 0; // device number + if (!option || !config || !name) // TODO: check first member of option for > 5 ? + { + return CELL_AUDIO_IN_ERROR_ILLEGAL_PARAMETER; + } + + return not_an_error(0); // device number } -s32 cellAudioInUnregisterDevice(u32 deviceNumber) +error_code cellAudioInUnregisterDevice(u32 deviceNumber) { cellAvconfExt.todo("cellAudioInUnregisterDevice(deviceNumber=0x%x)", deviceNumber); return CELL_OK; } -s32 cellVideoOutGetScreenSize(u32 videoOut, vm::ptr screenSize) +error_code cellVideoOutGetScreenSize(u32 videoOut, vm::ptr screenSize) { cellAvconfExt.warning("cellVideoOutGetScreenSize(videoOut=%d, screenSize=*0x%x)", videoOut, screenSize); @@ -280,7 +306,7 @@ s32 cellVideoOutGetScreenSize(u32 videoOut, vm::ptr screenSize) return CELL_VIDEO_OUT_ERROR_VALUE_IS_NOT_SET; } -s32 cellVideoOutSetCopyControl(u32 videoOut, u32 control) +error_code cellVideoOutSetCopyControl(u32 videoOut, u32 control) { cellAvconfExt.todo("cellVideoOutSetCopyControl(videoOut=%d, control=0x%x)", videoOut, control); return CELL_OK; diff --git a/rpcs3/Emu/Cell/Modules/cellVideoOut.cpp b/rpcs3/Emu/Cell/Modules/cellVideoOut.cpp index 47cc42272a..76c9957ac6 100644 --- a/rpcs3/Emu/Cell/Modules/cellVideoOut.cpp +++ b/rpcs3/Emu/Cell/Modules/cellVideoOut.cpp @@ -263,37 +263,37 @@ error_code cellVideoOutGetResolutionAvailability(u32 videoOut, u32 resolutionId, return CELL_VIDEO_OUT_ERROR_UNSUPPORTED_VIDEO_OUT; } -s32 cellVideoOutConfigure2() +error_code cellVideoOutConfigure2() { cellSysutil.todo("cellVideoOutConfigure2()"); return CELL_OK; } -s32 cellVideoOutGetResolutionAvailability2() +error_code cellVideoOutGetResolutionAvailability2() { cellSysutil.todo("cellVideoOutGetResolutionAvailability2()"); return CELL_OK; } -s32 cellVideoOutGetConvertCursorColorInfo(vm::ptr rgbOutputRange) +error_code cellVideoOutGetConvertCursorColorInfo(vm::ptr rgbOutputRange) { cellSysutil.todo("cellVideoOutGetConvertCursorColorInfo()"); return CELL_OK; } -s32 cellVideoOutDebugSetMonitorType(u32 videoOut, u32 monitorType) +error_code cellVideoOutDebugSetMonitorType(u32 videoOut, u32 monitorType) { cellSysutil.todo("cellVideoOutDebugSetMonitorType()"); return CELL_OK; } -s32 cellVideoOutRegisterCallback(u32 slot, vm::ptr function, vm::ptr userData) +error_code cellVideoOutRegisterCallback(u32 slot, vm::ptr function, vm::ptr userData) { cellSysutil.todo("cellVideoOutRegisterCallback()"); return CELL_OK; } -s32 cellVideoOutUnregisterCallback(u32 slot) +error_code cellVideoOutUnregisterCallback(u32 slot) { cellSysutil.todo("cellVideoOutUnregisterCallback()"); return CELL_OK;