mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Load unknown.png for ELFs masquerading as PBP
This commit is contained in:
parent
ebe2009124
commit
868a3d6dd5
5 changed files with 24 additions and 7 deletions
|
@ -23,9 +23,10 @@
|
|||
#include "Common/FileUtil.h"
|
||||
#include "Core/ELF/PBPReader.h"
|
||||
|
||||
PBPReader::PBPReader(const char *filename) : header_() {
|
||||
PBPReader::PBPReader(const char *filename) : header_(), isELF_(false) {
|
||||
file_ = File::OpenCFile(filename, "rb");
|
||||
if (!file_) {
|
||||
ERROR_LOG(LOADER, "Failed to open PBP file %s", filename);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -34,6 +35,12 @@ PBPReader::PBPReader(const char *filename) : header_() {
|
|||
fseek(file_, 0, SEEK_SET);
|
||||
fread((char *)&header_, 1, sizeof(header_), file_);
|
||||
if (memcmp(header_.magic, "\0PBP", 4) != 0) {
|
||||
if (memcmp(header_.magic, "\nFLE", 4) != 0) {
|
||||
DEBUG_LOG(LOADER, "%s: File actually an ELF, not a PBP", filename);
|
||||
isELF_ = true;
|
||||
} else {
|
||||
ERROR_LOG(LOADER, "Magic number in %s indicated no PBP: %s", filename, header_.magic);
|
||||
}
|
||||
fclose(file_);
|
||||
file_ = 0;
|
||||
return;
|
||||
|
|
|
@ -43,6 +43,7 @@ public:
|
|||
~PBPReader();
|
||||
|
||||
bool IsValid() const { return file_ != 0; }
|
||||
bool IsELF() const { return file_ == 0 && isELF_; }
|
||||
|
||||
// Delete the returned buffer with delete [].
|
||||
u8 *GetSubFile(PBPSubFile file, size_t *outSize);
|
||||
|
@ -61,4 +62,5 @@ private:
|
|||
FILE *file_;
|
||||
size_t fileSize_;
|
||||
const PBPHeader header_;
|
||||
};
|
||||
bool isELF_;
|
||||
};
|
||||
|
|
|
@ -236,7 +236,10 @@ public:
|
|||
return;
|
||||
|
||||
std::string filename = gamePath_;
|
||||
info_->path = gamePath_;
|
||||
info_->fileType = Identify_File(filename);
|
||||
// Fallback title
|
||||
info_->title = getFilename(info_->path);
|
||||
|
||||
switch (info_->fileType) {
|
||||
case FILETYPE_PSP_PBP:
|
||||
|
@ -247,8 +250,13 @@ public:
|
|||
pbpFile += "/EBOOT.PBP";
|
||||
|
||||
PBPReader pbp(pbpFile.c_str());
|
||||
if (!pbp.IsValid())
|
||||
if (!pbp.IsValid()) {
|
||||
if (pbp.IsELF()) {
|
||||
goto handleELF;
|
||||
}
|
||||
ERROR_LOG(LOADER, "invalid pbp %s\n", pbpFile.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
// First, PARAM.SFO.
|
||||
size_t sfoSize;
|
||||
|
@ -265,7 +273,9 @@ public:
|
|||
lock_guard lock(info_->lock);
|
||||
if (pbp.GetSubFileSize(PBP_ICON0_PNG) > 0) {
|
||||
pbp.GetSubFileAsString(PBP_ICON0_PNG, &info_->iconTextureData);
|
||||
printf("a %s\n", info_->path.c_str());
|
||||
} else {
|
||||
printf("b %s\n", info_->path.c_str());
|
||||
// Read standard icon
|
||||
size_t sz;
|
||||
DEBUG_LOG(LOADER, "Loading unknown.png because a PBP was missing an icon");
|
||||
|
@ -288,12 +298,12 @@ public:
|
|||
break;
|
||||
|
||||
case FILETYPE_PSP_ELF:
|
||||
handleELF:
|
||||
// An elf on its own has no usable information, no icons, no nothing.
|
||||
info_->title = getFilename(filename);
|
||||
info_->id = "ELF000000";
|
||||
info_->id_version = "ELF000000_1.00";
|
||||
info_->paramSFOLoaded = true;
|
||||
|
||||
{
|
||||
// Read standard icon
|
||||
size_t sz;
|
||||
|
@ -305,7 +315,6 @@ public:
|
|||
}
|
||||
delete [] contents;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case FILETYPE_PSP_DISC_DIRECTORY:
|
||||
|
@ -422,7 +431,6 @@ void GameInfoCache::Decimate() {
|
|||
}
|
||||
|
||||
void GameInfoCache::Clear() {
|
||||
ILOG("Wiping GameInfoCache: %i items", info_.size());
|
||||
if (gameInfoWQ_)
|
||||
gameInfoWQ_->Flush();
|
||||
for (auto iter = info_.begin(); iter != info_.end(); iter++) {
|
||||
|
|
|
@ -67,6 +67,7 @@ public:
|
|||
recursive_mutex lock;
|
||||
|
||||
FileInfo fileInfo;
|
||||
std::string path;
|
||||
std::string title; // for easy access, also available in paramSFO.
|
||||
std::string id;
|
||||
std::string id_version;
|
||||
|
|
|
@ -134,7 +134,6 @@ void GameButton::Draw(UIContext &dc) {
|
|||
style = dc.theme->itemDownStyle;
|
||||
|
||||
if (!gridStyle_ || !texture) {
|
||||
// w = 144 * 80 / 50;
|
||||
h = 50;
|
||||
if (HasFocus())
|
||||
style = down_ ? dc.theme->itemDownStyle : dc.theme->itemFocusedStyle;
|
||||
|
|
Loading…
Add table
Reference in a new issue