From 17a5e0bc98ff2fb049d0dbf8abfcaa8b149d4937 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Sun, 20 Jan 2019 22:57:13 +0100 Subject: [PATCH] cellGame: add error_code --- rpcs3/Emu/Cell/Modules/cellGame.cpp | 64 ++++++++++++++++-------- rpcs3/Emu/Cell/Modules/cellGame.h | 22 +++++--- rpcs3/Emu/Cell/Modules/cellMsgDialog.cpp | 2 +- rpcs3/Emu/Cell/Modules/cellMsgDialog.h | 2 +- rpcs3/Emu/RSX/Overlays/overlays.h | 2 +- 5 files changed, 59 insertions(+), 33 deletions(-) diff --git a/rpcs3/Emu/Cell/Modules/cellGame.cpp b/rpcs3/Emu/Cell/Modules/cellGame.cpp index bd0f181db8..dd731365d0 100644 --- a/rpcs3/Emu/Cell/Modules/cellGame.cpp +++ b/rpcs3/Emu/Cell/Modules/cellGame.cpp @@ -1,4 +1,4 @@ -#include "stdafx.h" +#include "stdafx.h" #include "Emu/System.h" #include "Emu/IdManager.h" #include "Emu/Cell/PPUModule.h" @@ -79,6 +79,26 @@ void fmt_class_string::format(std::string& out, u64 arg) }); } +template<> +void fmt_class_string::format(std::string& out, u64 arg) +{ + format_enum(out, arg, [](auto error) + { + switch (error) + { + STR_CASE(CELL_HDDGAME_ERROR_CBRESULT); + STR_CASE(CELL_HDDGAME_ERROR_ACCESS_ERROR); + STR_CASE(CELL_HDDGAME_ERROR_INTERNAL); + STR_CASE(CELL_HDDGAME_ERROR_PARAM); + STR_CASE(CELL_HDDGAME_ERROR_NOSPACE); + STR_CASE(CELL_HDDGAME_ERROR_BROKEN); + STR_CASE(CELL_HDDGAME_ERROR_FAILURE); + } + + return unknown; + }); +} + // If dir is empty: // contentInfo = "/dev_bdvd/PS3_GAME" // usrdir = "/dev_bdvd/PS3_GAME/USRDIR" @@ -125,7 +145,7 @@ struct content_permission final } }; -s32 cellHddGameCheck(ppu_thread& ppu, u32 version, vm::cptr dirName, u32 errDialog, vm::ptr funcStat, u32 container) +error_code cellHddGameCheck(ppu_thread& ppu, u32 version, vm::cptr dirName, u32 errDialog, vm::ptr funcStat, u32 container) { cellGame.error("cellHddGameCheck(version=%d, dirName=%s, errDialog=%d, funcStat=*0x%x, container=%d)", version, dirName, errDialog, funcStat, container); @@ -133,7 +153,7 @@ s32 cellHddGameCheck(ppu_thread& ppu, u32 version, vm::cptr dirName, u32 e if (dir.size() != 9) { - return (s32)CELL_HDDGAME_ERROR_PARAM; + return CELL_HDDGAME_ERROR_PARAM; } vm::var result; @@ -189,7 +209,7 @@ s32 cellHddGameCheck(ppu_thread& ppu, u32 version, vm::cptr dirName, u32 e if (result->result != CELL_HDDGAME_CBRESULT_OK && result->result != CELL_HDDGAME_CBRESULT_OK_CANCEL) { - return (s32)CELL_HDDGAME_ERROR_CBRESULT; + return CELL_HDDGAME_ERROR_CBRESULT; } // TODO ? @@ -197,12 +217,12 @@ s32 cellHddGameCheck(ppu_thread& ppu, u32 version, vm::cptr dirName, u32 e return CELL_OK; } -s32 cellHddGameCheck2() +error_code cellHddGameCheck2() { fmt::throw_exception("Unimplemented" HERE); } -s32 cellHddGameGetSizeKB(vm::ptr size) +error_code cellHddGameGetSizeKB(vm::ptr size) { cellGame.warning("cellHddGameGetSizeKB(size=*0x%x)", size); @@ -210,7 +230,7 @@ s32 cellHddGameGetSizeKB(vm::ptr size) if (!fs::is_dir(local_dir)) { - return (s32)CELL_HDDGAME_ERROR_FAILURE; + return CELL_HDDGAME_ERROR_FAILURE; } *size = ::narrow(fs::get_dir_size(local_dir) / 1024); @@ -218,7 +238,7 @@ s32 cellHddGameGetSizeKB(vm::ptr size) return CELL_OK; } -s32 cellHddGameSetSystemVer(vm::cptr systemVersion) +error_code cellHddGameSetSystemVer(vm::cptr systemVersion) { cellGame.todo("cellHddGameSetSystemVer(systemVersion=%s)", systemVersion); @@ -230,7 +250,7 @@ s32 cellHddGameSetSystemVer(vm::cptr systemVersion) return CELL_OK; } -s32 cellHddGameExitBroken() +error_code cellHddGameExitBroken() { cellGame.warning("cellHddGameExitBroken()"); @@ -246,7 +266,7 @@ s32 cellHddGameExitBroken() return CELL_OK; } -s32 cellGameDataGetSizeKB(vm::ptr size) +error_code cellGameDataGetSizeKB(vm::ptr size) { cellGame.warning("cellGameDataGetSizeKB(size=*0x%x)", size); @@ -267,7 +287,7 @@ s32 cellGameDataGetSizeKB(vm::ptr size) return CELL_OK; } -s32 cellGameDataSetSystemVer(vm::cptr systemVersion) +error_code cellGameDataSetSystemVer(vm::cptr systemVersion) { cellGame.todo("cellGameDataSetSystemVer(systemVersion=%s)", systemVersion); @@ -279,7 +299,7 @@ s32 cellGameDataSetSystemVer(vm::cptr systemVersion) return CELL_OK; } -s32 cellGameDataExitBroken() +error_code cellGameDataExitBroken() { cellGame.warning("cellGameDataExitBroken()"); @@ -607,7 +627,7 @@ error_code cellGameDataCheckCreate2(ppu_thread& ppu, u32 version, vm::cptr } } -s32 cellGameDataCheckCreate(ppu_thread& ppu, u32 version, vm::cptr dirName, u32 errDialog, vm::ptr funcStat, u32 container) +error_code cellGameDataCheckCreate(ppu_thread& ppu, u32 version, vm::cptr dirName, u32 errDialog, vm::ptr funcStat, u32 container) { cellGame.warning("cellGameDataCheckCreate(version=0x%x, dirName=%s, errDialog=0x%x, funcStat=*0x%x, container=%d)", version, dirName, errDialog, funcStat, container); @@ -667,7 +687,7 @@ error_code cellGameCreateGameData(vm::ptr init, vm::ptr dirName) +error_code cellGameDeleteGameData(vm::cptr dirName) { cellGame.todo("cellGameDeleteGameData(dirName=%s)", dirName); @@ -853,7 +873,7 @@ error_code cellGameGetSizeKB(vm::ptr size) return CELL_OK; } -s32 cellGameGetDiscContentInfoUpdatePath(vm::ptr updatePath) +error_code cellGameGetDiscContentInfoUpdatePath(vm::ptr updatePath) { cellGame.todo("cellGameGetDiscContentInfoUpdatePath(updatePath=*0x%x)", updatePath); @@ -865,7 +885,7 @@ s32 cellGameGetDiscContentInfoUpdatePath(vm::ptr updatePath) return CELL_OK; } -s32 cellGameGetLocalWebContentPath(vm::ptr contentPath) +error_code cellGameGetLocalWebContentPath(vm::ptr contentPath) { cellGame.todo("cellGameGetLocalWebContentPath(contentPath=*0x%x)", contentPath); @@ -925,14 +945,14 @@ s32 cellGameThemeInstall(vm::cptr usrdirPath, vm::cptr fileName, u32 return CELL_OK; } -s32 cellGameThemeInstallFromBuffer(u32 fileSize, u32 bufSize, vm::ptr buf, vm::ptr func, u32 option) +error_code cellGameThemeInstallFromBuffer(u32 fileSize, u32 bufSize, vm::ptr buf, vm::ptr func, u32 option) { cellGame.todo("cellGameThemeInstallFromBuffer(fileSize=%d, bufSize=%d, buf=*0x%x, func=*0x%x, option=0x%x)", fileSize, bufSize, buf, func, option); return CELL_OK; } -s32 cellDiscGameGetBootDiscInfo(vm::ptr getParam) +error_code cellDiscGameGetBootDiscInfo(vm::ptr getParam) { cellGame.warning("cellDiscGameGetBootDiscInfo(getParam=*0x%x)", getParam); @@ -958,28 +978,28 @@ s32 cellDiscGameGetBootDiscInfo(vm::ptr getParam) return CELL_OK; } -s32 cellDiscGameRegisterDiscChangeCallback(vm::ptr funcEject, vm::ptr funcInsert) +error_code cellDiscGameRegisterDiscChangeCallback(vm::ptr funcEject, vm::ptr funcInsert) { cellGame.todo("cellDiscGameRegisterDiscChangeCallback(funcEject=*0x%x, funcInsert=*0x%x)", funcEject, funcInsert); return CELL_OK; } -s32 cellDiscGameUnregisterDiscChangeCallback() +error_code cellDiscGameUnregisterDiscChangeCallback() { cellGame.todo("cellDiscGameUnregisterDiscChangeCallback()"); return CELL_OK; } -s32 cellGameRegisterDiscChangeCallback(vm::ptr funcEject, vm::ptr funcInsert) +error_code cellGameRegisterDiscChangeCallback(vm::ptr funcEject, vm::ptr funcInsert) { cellGame.todo("cellGameRegisterDiscChangeCallback(funcEject=*0x%x, funcInsert=*0x%x)", funcEject, funcInsert); return CELL_OK; } -s32 cellGameUnregisterDiscChangeCallback() +error_code cellGameUnregisterDiscChangeCallback() { cellGame.todo("cellGameUnregisterDiscChangeCallback()"); diff --git a/rpcs3/Emu/Cell/Modules/cellGame.h b/rpcs3/Emu/Cell/Modules/cellGame.h index 91d01bc5d1..2f104f17fd 100644 --- a/rpcs3/Emu/Cell/Modules/cellGame.h +++ b/rpcs3/Emu/Cell/Modules/cellGame.h @@ -242,17 +242,23 @@ struct CellGameDataStatSet typedef void(CellGameDataStatCallback)(vm::ptr cbResult, vm::ptr get, vm::ptr set); // cellSysutil: cellHddGame + +enum CellHddGameError : u32 +{ + CELL_HDDGAME_ERROR_CBRESULT = 0x8002ba01, + CELL_HDDGAME_ERROR_ACCESS_ERROR = 0x8002ba02, + CELL_HDDGAME_ERROR_INTERNAL = 0x8002ba03, + CELL_HDDGAME_ERROR_PARAM = 0x8002ba04, + CELL_HDDGAME_ERROR_NOSPACE = 0x8002ba05, + CELL_HDDGAME_ERROR_BROKEN = 0x8002ba06, + CELL_HDDGAME_ERROR_FAILURE = 0x8002ba07, +}; + enum { // Return Codes - CELL_HDDGAME_RET_CANCEL = 1, - CELL_HDDGAME_ERROR_CBRESULT = 0x8002ba01, - CELL_HDDGAME_ERROR_ACCESS_ERROR = 0x8002ba02, - CELL_HDDGAME_ERROR_INTERNAL = 0x8002ba03, - CELL_HDDGAME_ERROR_PARAM = 0x8002ba04, - CELL_HDDGAME_ERROR_NOSPACE = 0x8002ba05, - CELL_HDDGAME_ERROR_BROKEN = 0x8002ba06, - CELL_HDDGAME_ERROR_FAILURE = 0x8002ba07, + CELL_HDDGAME_RET_OK = 0, + CELL_HDDGAME_RET_CANCEL = 1, // Callback Result CELL_HDDGAME_CBRESULT_OK_CANCEL = 1, diff --git a/rpcs3/Emu/Cell/Modules/cellMsgDialog.cpp b/rpcs3/Emu/Cell/Modules/cellMsgDialog.cpp index 087eb41cd9..015b5b6254 100644 --- a/rpcs3/Emu/Cell/Modules/cellMsgDialog.cpp +++ b/rpcs3/Emu/Cell/Modules/cellMsgDialog.cpp @@ -34,7 +34,7 @@ MsgDialogBase::~MsgDialogBase() error_code cellMsgDialogOpen2(u32 type, vm::cptr msgString, vm::ptr callback, vm::ptr userData, vm::ptr extParam); // wrapper to call for other hle dialogs -s32 open_msg_dialog(u32 type, vm::cptr msgString, vm::ptr callback, vm::ptr userData, vm::ptr extParam) +error_code open_msg_dialog(u32 type, vm::cptr msgString, vm::ptr callback, vm::ptr userData, vm::ptr extParam) { cellSysutil.warning("open_msg_dialog called. This will call cellMsgDialogOpen2"); return cellMsgDialogOpen2(type, msgString, callback, userData, extParam); diff --git a/rpcs3/Emu/Cell/Modules/cellMsgDialog.h b/rpcs3/Emu/Cell/Modules/cellMsgDialog.h index 077c07cb1d..5e7df5416f 100644 --- a/rpcs3/Emu/Cell/Modules/cellMsgDialog.h +++ b/rpcs3/Emu/Cell/Modules/cellMsgDialog.h @@ -82,7 +82,7 @@ enum class MsgDialogState Close, }; -s32 open_msg_dialog(u32 type, vm::cptr msgString, vm::ptr callback = vm::null, vm::ptr userData = vm::null, vm::ptr extParam = vm::null); +error_code open_msg_dialog(u32 type, vm::cptr msgString, vm::ptr callback = vm::null, vm::ptr userData = vm::null, vm::ptr extParam = vm::null); class MsgDialogBase { diff --git a/rpcs3/Emu/RSX/Overlays/overlays.h b/rpcs3/Emu/RSX/Overlays/overlays.h index 5fa3c54c0e..7c9f3378d6 100644 --- a/rpcs3/Emu/RSX/Overlays/overlays.h +++ b/rpcs3/Emu/RSX/Overlays/overlays.h @@ -925,7 +925,7 @@ namespace rsx close(); } - s32 show(const std::string& text, const MsgDialogType &type, std::function on_close) + error_code show(const std::string text, const MsgDialogType &type, std::function on_close) { num_progress_bars = type.progress_bar_count; if (num_progress_bars)