Skip to content

Commit

Permalink
Merge pull request RPCS3#1144 from tambry/tea
Browse files Browse the repository at this point in the history
Saving fix and improvements to sceNp2 and cellCamera
  • Loading branch information
Hykem committed Jul 14, 2015
2 parents 3896c39 + 2e3113b commit 93e8504
Show file tree
Hide file tree
Showing 10 changed files with 410 additions and 92 deletions.
3 changes: 2 additions & 1 deletion rpcs3/Emu/SysCalls/ModuleManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ extern Module cellVoice;
extern Module cellVpost;
extern Module libmixer;
extern Module sceNp;
extern Module sceNp2;
extern Module sceNpClans;
extern Module sceNpCommerce2;
extern Module sceNpSns;
Expand Down Expand Up @@ -117,7 +118,7 @@ static const g_module_list[] =
{ 0x0035, "cellSysutilRec", nullptr },
{ 0x0036, "cellVideoExport", nullptr },
{ 0x0037, "cellGameExec", nullptr },
{ 0x0038, "sceNp2", nullptr },
{ 0x0038, "sceNp2", &sceNp2 },
{ 0x0039, "cellSysutilAp", &cellSysutilAp },
{ 0x003a, "cellSysutilNpClans", nullptr },
{ 0x003b, "cellSysutilOskExt", nullptr },
Expand Down
16 changes: 11 additions & 5 deletions rpcs3/Emu/SysCalls/Modules/cellCamera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,25 +121,31 @@ s32 cellCameraGetType(s32 dev_num, vm::ptr<s32> type)

s32 cellCameraIsAvailable(s32 dev_num)
{
UNIMPLEMENTED_FUNC(cellCamera);
cellCamera.Todo("cellCameraIsAvailable(dev_num=%d)", dev_num);
return CELL_OK;
}

s32 cellCameraIsAttached(s32 dev_num)
{
UNIMPLEMENTED_FUNC(cellCamera);
return CELL_OK;
cellCamera.Warning("cellCameraIsAttached(dev_num=%d)", dev_num);

if (Ini.Camera.GetValue() == 1)
{
return 1;
}

return CELL_OK; // CELL_OK means that no camera is attached
}

s32 cellCameraIsOpen(s32 dev_num)
{
UNIMPLEMENTED_FUNC(cellCamera);
cellCamera.Todo("cellCameraIsOpen(dev_num=%d)", dev_num);
return CELL_OK;
}

s32 cellCameraIsStarted(s32 dev_num)
{
UNIMPLEMENTED_FUNC(cellCamera);
cellCamera.Todo("cellCameraIsStarted(dev_num=%d)", dev_num);
return CELL_OK;
}

Expand Down
36 changes: 28 additions & 8 deletions rpcs3/Emu/SysCalls/Modules/cellSaveData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ never_inline s32 savedata_op(

if (!lock)
{
cellSysutil.Error("savedata_op(): failed to lock the mutex.");
return CELL_SAVEDATA_ERROR_BUSY;
}

Expand Down Expand Up @@ -191,6 +192,7 @@ never_inline s32 savedata_op(

if (result->result < 0)
{
cellSysutil.Error("savedata_op(): funcList returned result < 0.");
return CELL_SAVEDATA_ERROR_CBRESULT;
}

Expand Down Expand Up @@ -302,6 +304,7 @@ never_inline s32 savedata_op(

if (result->result < 0)
{
cellSysutil.Error("savedata_op(): funcFixed returned result < 0.");
return CELL_SAVEDATA_ERROR_CBRESULT;
}

Expand Down Expand Up @@ -343,10 +346,31 @@ never_inline s32 savedata_op(

PSFLoader psf;

// Create save directory if necessary
if (save_entry.isNew)
{
if (!Emu.GetVFS().ExistsDir(dir_path) && !Emu.GetVFS().CreateDir(dir_path))
{
cellSysutil.Error("savedata_op(): Savedata directory creation failed.");
}
else
{
// Is loading the PARAM.SFO really necessary? Setting empty stuff seems to fix a couple games.
psf.SetInteger("ATTRIBUTE", 0);
psf.SetString("TITLE", "");
psf.SetString("SUB_TITLE", "");
psf.SetString("DETAIL", "");
psf.SetString("SAVEDATA_LIST_PARAM", "");
}
}

// Load PARAM.SFO
{
vfsFile f(sfo_path);
psf.Load(f);
if (!save_entry.isNew)
{
vfsFile f(sfo_path);
psf.Load(f);
}
}

// Get save stats
Expand Down Expand Up @@ -436,6 +460,7 @@ never_inline s32 savedata_op(

if (result->result < 0)
{
cellSysutil.Error("savedata_op(): funcStat returned result < 0.");
return CELL_SAVEDATA_ERROR_CBRESULT;
}

Expand Down Expand Up @@ -485,12 +510,6 @@ never_inline s32 savedata_op(
}
}

// Create save directory if necessary
if (save_entry.isNew && !Emu.GetVFS().CreateDir(dir_path))
{
// Let's ignore this error for now
}

// Enter the loop where the save files are read/created/deleted
vm::stackvar<CellSaveDataFileGet> fileGet(CPU);
vm::stackvar<CellSaveDataFileSet> fileSet(CPU);
Expand All @@ -504,6 +523,7 @@ never_inline s32 savedata_op(

if (result->result < 0)
{
cellSysutil.Error("savedata_op(): funcFile returned result < 0.");
return CELL_SAVEDATA_ERROR_CBRESULT;
}

Expand Down
88 changes: 26 additions & 62 deletions rpcs3/Emu/SysCalls/Modules/sceNp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,46 +12,36 @@

extern Module sceNp;

struct sceNpInternal
{
bool m_bSceNpInitialized;
bool m_bSceNp2Initialized;
bool m_bScoreInitialized;
bool m_bLookupInitialized;
bool m_bSceNpUtilBandwidthTestInitialized;

sceNpInternal()
: m_bSceNpInitialized(false),
m_bSceNp2Initialized(false),
m_bScoreInitialized(false),
m_bLookupInitialized(false),
m_bSceNpUtilBandwidthTestInitialized(false)
{
}
};

sceNpInternal sceNpInstance;

s32 sceNpInit(u32 mem_size, u32 mem_addr)
s32 sceNpInit(u32 poolsize, vm::ptr<u32> poolptr)
{
sceNp.Warning("sceNpInit(mem_size=0x%x, mem_addr=0x%x)", mem_size, mem_addr);
sceNp.Warning("sceNpInit(poolsize=%d, poolptr=0x%x)", poolsize, poolptr);

if (sceNpInstance.m_bSceNpInitialized)
{
sceNp.Error("sceNpInit(): sceNp has been already initialized.");
return SCE_NP_ERROR_ALREADY_INITIALIZED;
}

sceNpInstance.m_bSceNpInitialized = true;

return CELL_OK;
}

s32 sceNp2Init(u32 mem_size, u32 mem_addr)
{
sceNp.Warning("sceNp2Init(mem_size=0x%x, mem_addr=0x%x)", mem_size, mem_addr);
if (poolsize == 0)
{
sceNp.Error("sceNpInit(): poolsize given is 0.");
return SCE_NP_ERROR_INVALID_ARGUMENT;
}
else if (poolsize < 128 * 1024)
{
sceNp.Error("sceNp2Init(): poolsize given is under 131072 bytes.");
return SCE_NP_ERROR_INSUFFICIENT_BUFFER;
}

if (sceNpInstance.m_bSceNp2Initialized)
return SCE_NP_ERROR_ALREADY_INITIALIZED;
if (!poolptr)
{
sceNp.Error("sceNpInit(): poolptr is invalid.");
return SCE_NP_ERROR_INVALID_ARGUMENT;
}

sceNpInstance.m_bSceNp2Initialized = true;
sceNpInstance.m_bSceNpInitialized = true;

return CELL_OK;
}
Expand All @@ -61,25 +51,16 @@ s32 sceNpTerm()
sceNp.Warning("sceNpTerm()");

if (!sceNpInstance.m_bSceNpInitialized)
{
sceNp.Error("sceNpTerm(): sceNp has not been intialized.");
return SCE_NP_ERROR_NOT_INITIALIZED;
}

sceNpInstance.m_bSceNpInitialized = false;

return CELL_OK;
}

s32 sceNp2Term()
{
sceNp.Warning("sceNp2Term()");

if (!sceNpInstance.m_bSceNp2Initialized)
return SCE_NP_ERROR_NOT_INITIALIZED;

sceNpInstance.m_bSceNp2Initialized = false;

return CELL_OK;
}

s32 npDrmIsAvailable(u32 k_licensee_addr, vm::cptr<char> drm_path)
{
if (!Emu.GetVFS().ExistsFile(drm_path.get_ptr()))
Expand Down Expand Up @@ -191,14 +172,7 @@ s32 sceNpDrmGetTimelimit(vm::ptr<const char> path, vm::ptr<u64> time_remain)

s32 sceNpDrmProcessExitSpawn(vm::cptr<char> path, u32 argv_addr, u32 envp_addr, u32 data_addr, u32 data_size, u32 prio, u64 flags)
{
sceNp.Warning("sceNpDrmProcessExitSpawn()");
sceNp.Warning("path: %s", path.get_ptr());
sceNp.Warning("argv: 0x%x", argv_addr);
sceNp.Warning("envp: 0x%x", envp_addr);
sceNp.Warning("data: 0x%x", data_addr);
sceNp.Warning("data_size: 0x%x", data_size);
sceNp.Warning("prio: %d", prio);
sceNp.Warning("flags: %d", flags);
sceNp.Warning("sceNpDrmProcessExitSpawn() -> sys_game_process_exitspawn");

sys_game_process_exitspawn(path, argv_addr, envp_addr, data_addr, data_size, prio, flags);

Expand All @@ -207,14 +181,7 @@ s32 sceNpDrmProcessExitSpawn(vm::cptr<char> path, u32 argv_addr, u32 envp_addr,

s32 sceNpDrmProcessExitSpawn2(vm::cptr<char> path, u32 argv_addr, u32 envp_addr, u32 data_addr, u32 data_size, u32 prio, u64 flags)
{
sceNp.Warning("sceNpDrmProcessExitSpawn2()");
sceNp.Warning("path: %s", path.get_ptr());
sceNp.Warning("argv: 0x%x", argv_addr);
sceNp.Warning("envp: 0x%x", envp_addr);
sceNp.Warning("data: 0x%x", data_addr);
sceNp.Warning("data_size: 0x%x", data_size);
sceNp.Warning("prio: %d", prio);
sceNp.Warning("flags: %d", flags);
sceNp.Warning("sceNpDrmProcessExitSpawn2() -> sys_game_process_exitspawn2");

sys_game_process_exitspawn2(path, argv_addr, envp_addr, data_addr, data_size, prio, flags);

Expand Down Expand Up @@ -1639,16 +1606,13 @@ s32 _sceNpSysutilClientFree()
Module sceNp("sceNp", []()
{
sceNpInstance.m_bSceNpInitialized = false;
sceNpInstance.m_bSceNp2Initialized = false;
sceNpInstance.m_bScoreInitialized = false;
sceNpInstance.m_bLookupInitialized = false;
sceNpInstance.m_bSceNpUtilBandwidthTestInitialized = false;

REG_FUNC(sceNp, sceNpInit);
REG_FUNC(sceNp, sceNp2Init);
REG_FUNC(sceNp, sceNpUtilBandwidthTestInitStart);
REG_FUNC(sceNp, sceNpTerm);
REG_FUNC(sceNp, sceNp2Term);
REG_FUNC(sceNp, sceNpUtilBandwidthTestShutdown);
REG_FUNC(sceNp, sceNpDrmIsAvailable);
REG_FUNC(sceNp, sceNpDrmIsAvailable2);
Expand Down
Loading

0 comments on commit 93e8504

Please sign in to comment.