Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trophy changes #5450

Merged
merged 1 commit into from
Dec 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion rpcs3/Emu/Cell/Modules/cellSysutil.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "stdafx.h"
#include "stdafx.h"
#include "Emu/System.h"
#include "Emu/IdManager.h"
#include "Emu/Cell/PPUModule.h"
Expand Down Expand Up @@ -232,6 +232,12 @@ s32 cellSysutilGetSystemParamString(CellSysutilParamId id, vm::ptr<char> buf, u3
return CELL_OK;
}

// Note: the way we do things here is inaccurate(but maybe sufficient)
// The real function goes over a table of 0x20 entries[ event_code:u32 callback_addr:u32 ]
// Those callbacks are registered through cellSysutilRegisterCallbackDispatcher(u32 event_code, vm::ptr<void> func_addr)
// The function goes through all the callback looking for one callback associated with event 0x100, if any is found it is called with parameters r3=0x101 r4=0
// This particular CB seems to be associated with sysutil itself
// Then it checks for events on an event_queue associated with sysutil, checks if any cb is associated with that event and calls them with parameters that come from the event
error_code cellSysutilCheckCallback(ppu_thread& ppu)
{
cellSysutil.trace("cellSysutilCheckCallback()");
Expand Down
29 changes: 20 additions & 9 deletions rpcs3/Emu/Cell/Modules/sceNpTrophy.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "stdafx.h"
#include "stdafx.h"
#include "Emu/System.h"
#include "Emu/IdManager.h"
#include "Emu/Cell/PPUModule.h"
Expand All @@ -11,6 +11,7 @@

#include "sceNp.h"
#include "sceNpTrophy.h"
#include "cellSysutil.h"

#include "Utilities/StrUtil.h"

Expand Down Expand Up @@ -316,18 +317,28 @@ error_code sceNpTrophyRegisterContext(ppu_thread& ppu, u32 context, u32 handle,
// * Installed
// We will go with the easy path of Installed, and that's it.

auto statuses = {SCE_NP_TROPHY_STATUS_INSTALLED,
SCE_NP_TROPHY_STATUS_PROCESSING_SETUP,
SCE_NP_TROPHY_STATUS_PROCESSING_PROGRESS,
SCE_NP_TROPHY_STATUS_PROCESSING_FINALIZE,
SCE_NP_TROPHY_STATUS_PROCESSING_COMPLETE};
// The callback is called once and then if it returns >= 0 the cb is called through events(coming from vsh) that are passed to the CB through cellSysutilCheckCallback
if (statusCb(ppu, context, SCE_NP_TROPHY_STATUS_INSTALLED, 100, 100, arg) < 0)
{
return SCE_NP_TROPHY_ERROR_PROCESSING_ABORTED;
}

// This emulates vsh sending the events and ensures that not 2 events are processed at once
auto statuses =
{
SCE_NP_TROPHY_STATUS_PROCESSING_SETUP,
SCE_NP_TROPHY_STATUS_PROCESSING_PROGRESS,
SCE_NP_TROPHY_STATUS_PROCESSING_FINALIZE,
SCE_NP_TROPHY_STATUS_PROCESSING_COMPLETE
};

for (auto status : statuses)
{
if (statusCb(ppu, context, status, 100, 100, arg) < 0)
sysutil_register_cb([=](ppu_thread& cb_ppu) -> s32
{
return SCE_NP_TROPHY_ERROR_PROCESSING_ABORTED;
}
statusCb(cb_ppu, context, status, 100, 100, arg);
return 0;
});
}

return CELL_OK;
Expand Down