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 update #2655

Merged
merged 14 commits into from Apr 13, 2017
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
284 changes: 225 additions & 59 deletions rpcs3/Emu/Cell/Modules/sceNpTrophy.cpp

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions rpcs3/Emu/Cell/PPUModule.cpp
@@ -1,6 +1,7 @@
#include "stdafx.h"
#include "Utilities/Config.h"
#include "Utilities/AutoPause.h"
#include "Utilities/VirtualMemory.h"
#include "Crypto/sha1.h"
#include "Crypto/unself.h"
#include "Loader/ELF.h"
Expand Down
5 changes: 3 additions & 2 deletions rpcs3/Emu/Cell/PPUThread.cpp
Expand Up @@ -179,10 +179,11 @@ extern void ppu_register_range(u32 addr, u32 size)
}

// Register executable range at
utils::memory_commit(&ppu_ref(addr), size);
utils::memory_commit(&ppu_ref(addr), size, utils::protection::rw);

const u32 fallback = ::narrow<u32>(reinterpret_cast<std::uintptr_t>(ppu_fallback));

size &= ~3; // Loop assumes `size = n * 4`, enforce that by rounding down
while (size)
{
ppu_ref(addr) = fallback;
Expand Down Expand Up @@ -707,7 +708,7 @@ u32 ppu_thread::stack_push(u32 size, u32 align_v)

const u32 old_pos = vm::cast(context.gpr[1], HERE);
context.gpr[1] -= align(size + 4, 8); // room minimal possible size
context.gpr[1] &= ~(align_v - 1); // fix stack alignment
context.gpr[1] &= ~((u64)align_v - 1); // fix stack alignment

if (old_pos >= context.stack_addr && old_pos < context.stack_addr + context.stack_size && context.gpr[1] < context.stack_addr)
{
Expand Down
8 changes: 4 additions & 4 deletions rpcs3/Emu/RSX/RSXThread.cpp
Expand Up @@ -135,9 +135,9 @@ namespace rsx
case CELL_GCM_CONTEXT_DMA_DEVICE_R:
fmt::throw_exception("Unimplemented CELL_GCM_CONTEXT_DMA_DEVICE_R (offset=0x%x, location=0x%x)" HERE, offset, location);

fmt::throw_exception("Invalid location (offset=0x%x, location=0x%x)" HERE, offset, location);
default:
fmt::throw_exception("Invalid location (offset=0x%x, location=0x%x)" HERE, offset, location);
}

}

u32 get_vertex_type_size_on_host(vertex_base_type type, u32 size)
Expand Down Expand Up @@ -200,7 +200,7 @@ namespace rsx
{
case CELL_GCM_COMPMODE_C32_2X1:
case CELL_GCM_COMPMODE_DISABLED:
for (int y = 0; y < height; ++y)
for (u32 y = 0; y < height; ++y)
{
memcpy(ptr + (offset_y + y) * tile->pitch + offset_x, (u8*)src + pitch * y, pitch);
}
Expand Down Expand Up @@ -253,7 +253,7 @@ namespace rsx
{
case CELL_GCM_COMPMODE_C32_2X1:
case CELL_GCM_COMPMODE_DISABLED:
for (int y = 0; y < height; ++y)
for (u32 y = 0; y < height; ++y)
{
memcpy((u8*)dst + pitch * y, ptr + (offset_y + y) * tile->pitch + offset_x, pitch);
}
Expand Down
4 changes: 2 additions & 2 deletions rpcs3/Gui/RSXDebugger.cpp
Expand Up @@ -287,14 +287,14 @@ void RSXDebugger::OnChangeToolsAddr(wxCommandEvent& event)

void RSXDebugger::OnScrollMemory(wxMouseEvent& event)
{
if(vm::check_addr(m_addr))
if(vm::check_addr(m_addr, 4))
{
int items = event.ControlDown() ? m_item_count : 1;

for(int i=0; i<items; ++i)
{
u32 offset;
if(vm::check_addr(m_addr))
if(vm::check_addr(m_addr, 4))
{
u32 cmd = vm::ps3::read32(m_addr);
u32 count = ((cmd & RSX_METHOD_OLD_JUMP_CMD_MASK) == RSX_METHOD_OLD_JUMP_CMD)
Expand Down
2 changes: 2 additions & 0 deletions rpcs3/Loader/TROPUSR.h
Expand Up @@ -50,6 +50,8 @@ struct TROPUSREntry6
be_t<u64> timestamp1;
be_t<u64> timestamp2;
char unk6[64]; // Just zeroes?

//Note: One of the fields should hold a flag showing whether the trophy is hidden or not
};

class TROPUSRLoader
Expand Down
26 changes: 26 additions & 0 deletions rpcs3/Loader/TRP.cpp
@@ -1,6 +1,7 @@
#include "stdafx.h"
#include "Emu/System.h"
#include "TRP.h"
#include "Crypto/sha1.h"

TRPLoader::TRPLoader(const fs::file& f)
: trp_f(f)
Expand Down Expand Up @@ -58,6 +59,31 @@ bool TRPLoader::LoadHeader(bool show)
LOG_NOTICE(LOADER, "TRP version: 0x%x", m_header.trp_version);
}

if (m_header.trp_version >= 2)
{
unsigned char hash[20];
std::vector<unsigned char> file_contents(m_header.trp_file_size);

trp_f.seek(0);
if (!trp_f.read(file_contents))
{
LOG_NOTICE(LOADER, "Failed verifying checksum");
}
else
{
memset(&(reinterpret_cast<TRPHeader*>(file_contents.data()))->sha1, 0, 20);
sha1(reinterpret_cast<const unsigned char*>(file_contents.data()), m_header.trp_file_size, hash);

if (memcmp(hash, m_header.sha1, 20) != 0)
{
LOG_ERROR(LOADER, "Invalid checksum of TROPHY.TRP file");
return false;
}
}

trp_f.seek(sizeof(m_header));
}

m_entries.clear();
m_entries.resize(m_header.trp_files_count);

Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Loader/TRP.h
Expand Up @@ -7,7 +7,7 @@ struct TRPHeader
be_t<u64> trp_file_size;
be_t<u32> trp_files_count;
be_t<u32> trp_element_size;
be_t<u32> trp_unknown;
be_t<u32> trp_dev_flag;
unsigned char sha1[20];
unsigned char padding[16];
};
Expand Down