diff --git a/rpcs3/Emu/Cell/Modules/sceNp.cpp b/rpcs3/Emu/Cell/Modules/sceNp.cpp index c3e3c3afb9..1b1a6dee88 100644 --- a/rpcs3/Emu/Cell/Modules/sceNp.cpp +++ b/rpcs3/Emu/Cell/Modules/sceNp.cpp @@ -3962,7 +3962,7 @@ error_code sceNpScoreSetPlayerCharacterId(s32 ctxId, SceNpScorePcId pcId) error_code sceNpScoreWaitAsync(s32 transId, vm::ptr result) { - sceNp.todo("sceNpScoreWaitAsync(transId=%d, result=*0x%x)", transId, result); + sceNp.warning("sceNpScoreWaitAsync(transId=%d, result=*0x%x)", transId, result); auto& nph = g_fxo->get>(); @@ -3977,7 +3977,7 @@ error_code sceNpScoreWaitAsync(s32 transId, vm::ptr result) return SCE_NP_COMMUNITY_ERROR_INVALID_ID; } - trans->wait_for_completion(); + *result = trans->wait_for_completion(); return CELL_OK; } @@ -4194,14 +4194,14 @@ error_code scenp_score_record_game_data(s32 transId, SceNpScoreBoardId boardId, error_code sceNpScoreRecordGameData(s32 transId, SceNpScoreBoardId boardId, SceNpScoreValue score, u32 totalSize, u32 sendSize, vm::cptr data, vm::ptr option) { - sceNp.todo("sceNpScoreRecordGameData(transId=%d, boardId=%d, score=%d, totalSize=%d, sendSize=%d, data=*0x%x, option=*0x%x)", transId, boardId, score, totalSize, sendSize, data, option); + sceNp.warning("sceNpScoreRecordGameData(transId=%d, boardId=%d, score=%d, totalSize=%d, sendSize=%d, data=*0x%x, option=*0x%x)", transId, boardId, score, totalSize, sendSize, data, option); return scenp_score_record_game_data(transId, boardId, score, totalSize, sendSize, data, option, false); } error_code sceNpScoreRecordGameDataAsync(s32 transId, SceNpScoreBoardId boardId, SceNpScoreValue score, u32 totalSize, u32 sendSize, vm::cptr data, s32 prio, vm::ptr option) { - sceNp.todo("sceNpScoreRecordGameDataAsync(transId=%d, boardId=%d, score=%d, totalSize=%d, sendSize=%d, data=*0x%x, prio=%d, option=*0x%x)", transId, boardId, score, totalSize, sendSize, data, prio, option); + sceNp.warning("sceNpScoreRecordGameDataAsync(transId=%d, boardId=%d, score=%d, totalSize=%d, sendSize=%d, data=*0x%x, prio=%d, option=*0x%x)", transId, boardId, score, totalSize, sendSize, data, prio, option); return scenp_score_record_game_data(transId, boardId, score, totalSize, sendSize, data, option, true); } @@ -4244,15 +4244,15 @@ error_code scenp_score_get_game_data(s32 transId, SceNpScoreBoardId boardId, vm: error_code sceNpScoreGetGameData(s32 transId, SceNpScoreBoardId boardId, vm::cptr npId, vm::ptr totalSize, u32 recvSize, vm::ptr data, vm::ptr option) { - sceNp.todo("sceNpScoreGetGameDataAsync(transId=%d, boardId=%d, npId=*0x%x, totalSize=*0x%x, recvSize=%d, data=*0x%x, option=*0x%x)", transId, boardId, npId, totalSize, recvSize, data, option); + sceNp.warning("sceNpScoreGetGameData(transId=%d, boardId=%d, npId=*0x%x, totalSize=*0x%x, recvSize=%d, data=*0x%x, option=*0x%x)", transId, boardId, npId, totalSize, recvSize, data, option); return scenp_score_get_game_data(transId, boardId, npId, totalSize, recvSize, data, option, false); } error_code sceNpScoreGetGameDataAsync(s32 transId, SceNpScoreBoardId boardId, vm::cptr npId, vm::ptr totalSize, u32 recvSize, vm::ptr data, s32 prio, vm::ptr option) { - sceNp.todo("sceNpScoreGetGameDataAsync(transId=%d, boardId=%d, npId=*0x%x, totalSize=*0x%x, recvSize=%d, data=*0x%x, prio=%d, option=*0x%x)", transId, boardId, npId, totalSize, recvSize, data, prio, - option); + sceNp.warning("sceNpScoreGetGameDataAsync(transId=%d, boardId=%d, npId=*0x%x, totalSize=*0x%x, recvSize=%d, data=*0x%x, prio=%d, option=*0x%x)", transId, boardId, npId, totalSize, recvSize, data, prio, + option); return scenp_score_get_game_data(transId, boardId, npId, totalSize, recvSize, data, option, true); } diff --git a/rpcs3/Emu/NP/np_contexts.cpp b/rpcs3/Emu/NP/np_contexts.cpp index 58d1dff8a2..9b358ada5b 100644 --- a/rpcs3/Emu/NP/np_contexts.cpp +++ b/rpcs3/Emu/NP/np_contexts.cpp @@ -68,16 +68,18 @@ void score_transaction_ctx::abort_score_transaction() result = SCE_NP_COMMUNITY_ERROR_ABORTED; wake_cond.notify_one(); } -void score_transaction_ctx::wait_for_completion() +error_code score_transaction_ctx::wait_for_completion() { std::unique_lock lock(mutex); if (result) { - return; + return *result; } completion_cond.wait(lock); + + return *result; } bool score_transaction_ctx::set_result_and_wake(error_code err) diff --git a/rpcs3/Emu/NP/np_contexts.h b/rpcs3/Emu/NP/np_contexts.h index 42a39b7a1f..a1e928a0ed 100644 --- a/rpcs3/Emu/NP/np_contexts.h +++ b/rpcs3/Emu/NP/np_contexts.h @@ -80,7 +80,7 @@ struct score_transaction_ctx ~score_transaction_ctx(); std::optional get_score_transaction_status(); void abort_score_transaction(); - void wait_for_completion(); + error_code wait_for_completion(); bool set_result_and_wake(error_code err); static const u32 id_base = 0x1001; diff --git a/rpcs3/Emu/NP/np_requests.cpp b/rpcs3/Emu/NP/np_requests.cpp index 32aced5f75..f0bc99066a 100644 --- a/rpcs3/Emu/NP/np_requests.cpp +++ b/rpcs3/Emu/NP/np_requests.cpp @@ -1,5 +1,6 @@ #include "stdafx.h" #include "Emu/Cell/PPUModule.h" +#include "Emu/Cell/lv2/sys_sync.h" #include "Emu/system_config.h" #include "Emu/Cell/Modules/cellSysutil.h" #include "Emu/Memory/vm_ptr.h" @@ -774,7 +775,10 @@ namespace np return; } - return worker_function(std::move(lock)); + auto& cpu_thread = *get_current_cpu_thread(); + lv2_obj::sleep(cpu_thread); + worker_function(std::move(lock)); + cpu_thread.check_state(); } void np_handler::get_board_infos(std::shared_ptr& trans_ctx, SceNpScoreBoardId boardId, vm::ptr boardInfo, bool async) @@ -967,8 +971,16 @@ namespace np return; } - // If here the data has already been acquired and the client is just asking for part of it + // Check if the transaction has actually completed, otherwise adjust tdata parameters + if (!trans_ctx->result) + { + tdata->totalSize = totalSize; + tdata->recvSize = recvSize; + tdata->score_data = score_data; + return; + } + // If here the data has already been acquired and the client is just asking for part of it usz to_copy = std::min(tdata->game_data.size(), static_cast(recvSize)); std::memcpy(score_data.get_ptr(), tdata->game_data.data(), to_copy); tdata->game_data.erase(tdata->game_data.begin(), tdata->game_data.begin() + to_copy);