diff --git a/rpcs3/Emu/Cell/Modules/cellRec.cpp b/rpcs3/Emu/Cell/Modules/cellRec.cpp index 4e8c34917f..1525594613 100644 --- a/rpcs3/Emu/Cell/Modules/cellRec.cpp +++ b/rpcs3/Emu/Cell/Modules/cellRec.cpp @@ -1,10 +1,22 @@ #include "stdafx.h" #include "Emu/Cell/PPUModule.h" +#include "Emu/IdManager.h" +#include "cellSysutil.h" namespace vm { using namespace ps3; } logs::channel cellRec("cellRec"); +enum +{ + CELL_REC_STATUS_UNLOAD = 0, + CELL_REC_STATUS_OPEN = 1, + CELL_REC_STATUS_START = 2, + CELL_REC_STATUS_STOP = 3, + CELL_REC_STATUS_CLOSE = 4, + CELL_REC_STATUS_ERR = 10 +}; + struct CellRecSpursParam { vm::bptr pSpurs; @@ -46,15 +58,40 @@ struct CellRecParam using CellRecCallback = void(s32 recStatus, s32 recError, vm::ptr userdata); -s32 cellRecOpen(vm::cptr pDirName, vm::cptr pFileName, vm::cptr pParam, u32 container, vm::ptr cb, vm::ptr cbUserData) +struct rec_t +{ + vm::ptr cb; + vm::ptr cbUserData; +}; + +error_code cellRecOpen(vm::cptr pDirName, vm::cptr pFileName, vm::cptr pParam, u32 container, vm::ptr cb, vm::ptr cbUserData) { cellRec.todo("cellRecOpen(pDirName=%s, pFileName=%s, pParam=*0x%x, container=0x%x, cb=*0x%x, cbUserData=*0x%x)", pDirName, pFileName, pParam, container, cb, cbUserData); + + const auto rec = fxm::make_always(); + rec->cb = cb; + rec->cbUserData = cbUserData; + + sysutil_register_cb([=](ppu_thread& ppu) -> s32 + { + cb(ppu, CELL_REC_STATUS_OPEN, CELL_OK, cbUserData); + return CELL_OK; + }); + return CELL_OK; } -s32 cellRecClose(s32 isDiscard) +error_code cellRecClose(s32 isDiscard) { cellRec.todo("cellRecClose(isDiscard=0x%x)", isDiscard); + + sysutil_register_cb([=](ppu_thread& ppu) -> s32 + { + const auto rec = fxm::get_always(); + rec->cb(ppu, CELL_REC_STATUS_CLOSE, CELL_OK, rec->cbUserData); + return CELL_OK; + }); + return CELL_OK; } @@ -63,15 +100,31 @@ void cellRecGetInfo(s32 info, vm::ptr pValue) cellRec.todo("cellRecGetInfo(info=0x%x, pValue=*0x%x)", info, pValue); } -s32 cellRecStop() +error_code cellRecStop() { cellRec.todo("cellRecStop()"); + + sysutil_register_cb([=](ppu_thread& ppu) -> s32 + { + const auto rec = fxm::get_always(); + rec->cb(ppu, CELL_REC_STATUS_STOP, CELL_OK, rec->cbUserData); + return CELL_OK; + }); + return CELL_OK; } -s32 cellRecStart() +error_code cellRecStart() { cellRec.todo("cellRecStart()"); + + sysutil_register_cb([=](ppu_thread& ppu) -> s32 + { + const auto rec = fxm::get_always(); + rec->cb(ppu, CELL_REC_STATUS_START, CELL_OK, rec->cbUserData); + return CELL_OK; + }); + return CELL_OK; } @@ -81,7 +134,7 @@ u32 cellRecQueryMemSize(vm::cptr pParam) return 1 * 1024 * 1024; // dummy memory size } -s32 cellRecSetInfo(s32 setInfo, u64 value) +error_code cellRecSetInfo(s32 setInfo, u64 value) { cellRec.todo("cellRecSetInfo(setInfo=0x%x, value=0x%x)", setInfo, value); return CELL_OK;