mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-04-05 22:47:03 +00:00
TRP Loader and undo few cellGame changes
This commit is contained in:
parent
f2a3db0bd8
commit
deaedcb6fa
6 changed files with 103 additions and 3 deletions
57
rpcs3/Loader/TRP.cpp
Normal file
57
rpcs3/Loader/TRP.cpp
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
#include "stdafx.h"
|
||||
#include "TRP.h"
|
||||
|
||||
TRPLoader::TRPLoader(vfsStream& f) : trp_f(f)
|
||||
{
|
||||
}
|
||||
|
||||
bool TRPLoader::Install(std::string dest, bool show)
|
||||
{
|
||||
if(!trp_f.IsOpened()) return false;
|
||||
if(!LoadHeader(show)) return false;
|
||||
|
||||
for (const TRPEntry& entry : m_entries)
|
||||
{
|
||||
char* buffer = new char [entry.size];
|
||||
vfsFile file(dest+entry.name, vfsWrite);
|
||||
trp_f.Seek(entry.offset);
|
||||
trp_f.Read(buffer, entry.size);
|
||||
file.Write(buffer, entry.size);
|
||||
file.Close();
|
||||
delete[] buffer;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TRPLoader::Close()
|
||||
{
|
||||
return trp_f.Close();
|
||||
}
|
||||
|
||||
bool TRPLoader::LoadHeader(bool show)
|
||||
{
|
||||
trp_f.Seek(0);
|
||||
if (trp_f.Read(&m_header, sizeof(TRPHeader)) != sizeof(TRPHeader))
|
||||
return false;
|
||||
|
||||
if (!m_header.CheckMagic())
|
||||
return false;
|
||||
|
||||
if (show)
|
||||
ConLog.Write("TRP version: %x", m_header.trp_version);
|
||||
|
||||
m_entries.clear();
|
||||
m_entries.resize(m_header.trp_files_count);
|
||||
|
||||
for(u32 i=0; i<m_header.trp_files_count; i++)
|
||||
{
|
||||
if (trp_f.Read(&m_entries[i], sizeof(TRPEntry)) != sizeof(TRPEntry))
|
||||
return false;
|
||||
|
||||
if (show)
|
||||
ConLog.Write("TRP entry #%d: %s", wxString(m_entries[i].name).wx_str());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue