Add stub framework for .pbp demos (nowhere near working). Fix an OSK crash.

This commit is contained in:
Henrik Rydgard 2013-04-27 23:16:51 +02:00
parent b603214777
commit b9f45e4530
5 changed files with 95 additions and 24 deletions

View file

@ -220,14 +220,16 @@ int PSPOskDialog::Init(u32 oskPtr)
inputChars = L""; inputChars = L"";
u16 *src = (u16 *) Memory::GetPointer(oskData.intextPtr); if (oskData.intextPtr) {
int c; u16 *src = (u16 *) Memory::GetPointer(oskData.intextPtr);
while (c = *src++) int c;
{ while (c = *src++)
inputChars += c;
if(c == 0x00)
{ {
break; inputChars += c;
if(c == 0x00)
{
break;
}
} }
} }

View file

@ -199,3 +199,21 @@ bool CISOFileBlockDevice::ReadBlock(int blockNumber, u8 *outPtr)
} }
return true; return true;
} }
NPDRMDemoBlockDevice::NPDRMDemoBlockDevice(std::string _filename)
: filename_(_filename), pbpReader_(_filename.c_str()) {
std::string paramSfo;
pbpReader_.GetSubFileAsString(PBP_PARAM_SFO, &paramSfo);
}
NPDRMDemoBlockDevice::~NPDRMDemoBlockDevice() {
}
bool NPDRMDemoBlockDevice::ReadBlock(int blockNumber, u8 *outPtr) {
// TODO: Fill in decryption code here. Use pbpReader to read the file - might need to
// extend its functionality to do it efficiently.
return false;
}

View file

@ -23,9 +23,11 @@
// The ISOFileSystemReader reads from a BlockDevice, so it automatically works // The ISOFileSystemReader reads from a BlockDevice, so it automatically works
// with CISO images. // with CISO images.
#include "../../Globals.h"
#include <string> #include <string>
#include "../../Globals.h"
#include "Core/ELF/PBPReader.h"
class BlockDevice class BlockDevice
{ {
public: public:
@ -69,4 +71,24 @@ private:
}; };
// For encrypted ISOs in PBP files.
class NPDRMDemoBlockDevice : public BlockDevice
{
public:
NPDRMDemoBlockDevice(std::string _filename);
~NPDRMDemoBlockDevice();
bool ReadBlock(int blockNumber, u8 *outPtr);
u32 GetNumBlocks() {return (u32)numBlocks_;}
private:
std::string filename_;
PBPReader pbpReader_;
FILE *file_;
size_t size_;
size_t numBlocks_;
};
BlockDevice *constructBlockDevice(const char *filename); BlockDevice *constructBlockDevice(const char *filename);

View file

@ -683,6 +683,11 @@ bool __KernelLoadExec(const char *filename, SceKernelLoadExecParam *param, std::
__KernelInit(); __KernelInit();
PSPFileInfo info = pspFileSystem.GetFileInfo(filename); PSPFileInfo info = pspFileSystem.GetFileInfo(filename);
if (!info.exists) {
ERROR_LOG(LOADER, "Failed to load executable %s - file doesn't exist", filename);
*error_string = "Could not find executable";
return false;
}
u32 handle = pspFileSystem.OpenFile(filename, FILEACCESS_READ); u32 handle = pspFileSystem.OpenFile(filename, FILEACCESS_READ);
@ -694,6 +699,8 @@ bool __KernelLoadExec(const char *filename, SceKernelLoadExecParam *param, std::
if (!module) { if (!module) {
ERROR_LOG(LOADER, "Failed to load module %s", filename); ERROR_LOG(LOADER, "Failed to load module %s", filename);
*error_string = "Failed to load executable module";
delete [] temp;
return false; return false;
} }

View file

@ -126,25 +126,47 @@ bool Load_PSP_ISO(const char *filename, std::string *error_string)
bool Load_PSP_ELF_PBP(const char *filename, std::string *error_string) bool Load_PSP_ELF_PBP(const char *filename, std::string *error_string)
{ {
// This is really just for headless, might need tweaking later. // Figure out if this is a "DEMO" PBP. In that case we want to mount it
if (!PSP_CoreParameter().mountIso.empty()) // on UMD0:.
{ PBPReader reader(filename);
ISOFileSystem *umd2 = new ISOFileSystem(&pspFileSystem, constructBlockDevice(PSP_CoreParameter().mountIso.c_str()));
pspFileSystem.Mount("umd1:", umd2); // Hacky check, should find something better
pspFileSystem.Mount("disc0:", umd2); if (reader.GetSubFileSize(PBP_UNKNOWN_PSAR) > 0x100000) {
pspFileSystem.Mount("umd:", umd2); // Yay, got a demo.
} ISOFileSystem *umd0 = new ISOFileSystem(&pspFileSystem, new NPDRMDemoBlockDevice(filename));
pspFileSystem.Mount("umd1:", umd0);
pspFileSystem.Mount("disc0:", umd0);
pspFileSystem.Mount("umd:", umd0);
pspFileSystem.Mount("umd0:", umd0);
std::string full_path = filename; std::string bootpath = "disc0:/PSP_GAME/SYSDIR/EBOOT.BIN";
std::string path, file, extension; INFO_LOG(LOADER,"Loading %s from demo iso...", bootpath.c_str());
SplitPath(ReplaceAll(full_path, "\\", "/"), &path, &file, &extension); return __KernelLoadExec(bootpath.c_str(), 0, error_string);
} else {
// Classic homebrew PBP.
// This is really just for headless, might need tweaking later.
if (!PSP_CoreParameter().mountIso.empty())
{
ISOFileSystem *umd2 = new ISOFileSystem(&pspFileSystem, constructBlockDevice(PSP_CoreParameter().mountIso.c_str()));
pspFileSystem.Mount("umd1:", umd2);
pspFileSystem.Mount("disc0:", umd2);
pspFileSystem.Mount("umd:", umd2);
}
std::string full_path = filename;
std::string path, file, extension;
SplitPath(ReplaceAll(full_path, "\\", "/"), &path, &file, &extension);
#ifdef _WIN32 #ifdef _WIN32
path = ReplaceAll(path, "/", "\\"); path = ReplaceAll(path, "/", "\\");
#endif #endif
DirectoryFileSystem *fs = new DirectoryFileSystem(&pspFileSystem, path);
pspFileSystem.Mount("umd0:", fs);
std::string finalName = "umd0:/" + file + extension; DirectoryFileSystem *fs = new DirectoryFileSystem(&pspFileSystem, path);
return __KernelLoadExec(finalName.c_str(), 0, error_string); pspFileSystem.Mount("umd0:", fs);
std::string finalName = "umd0:/" + file + extension;
return __KernelLoadExec(finalName.c_str(), 0, error_string);
}
} }