mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-01 14:58:14 +00:00
Add a PSP Firmware screen under Settings > Tools
Shows what's actually in PSP/NAND - nothing, a fonts-only partial install, or a full firmware with its version, build date and region - read from flash0:/vsh/etc/version.txt, which is present both in a PSAR-unpacked install and a NAND dumped off hardware. Also offers to install an updater, erase the NAND, and launch the XMB, the last one gated on FirmwareVersionSupportsVSH() since the module patches that get vshmain.prx running are tied to 6.61's offsets. Installing a firmware now erases flash0/flash1/ipl first - two firmwares can't be merged, a file the new one doesn't have would linger and still get loaded. Co-Authored-By: Claude Opus 5 <[email protected]>
This commit is contained in:
1 parent
e5b98b07e8
commit
57e96b2d81
14 files changed
+422
-9
No files matched your search
@@ -99,6 +99,8 @@ list(APPEND UISource
|
||||
UploadScreen.cpp
|
||||
CwCheatScreen.h
|
||||
CwCheatScreen.cpp
|
||||
FirmwareScreen.h
|
||||
FirmwareScreen.cpp
|
||||
InstallUpdateScreen.h
|
||||
InstallUpdateScreen.cpp
|
||||
InstallZipScreen.h
|
||||
|
||||
@@ -0,0 +1,181 @@
|
||||
// Copyright (c) 2026- PPSSPP Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0 or later versions.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official git repository and contact information can be found at
|
||||
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
||||
|
||||
#include "Common/Data/Text/I18n.h"
|
||||
#include "Common/Data/Text/Parsers.h"
|
||||
#include "Common/Log.h"
|
||||
#include "Common/StringUtils.h"
|
||||
#include "Common/System/Request.h"
|
||||
#include "Common/System/System.h"
|
||||
#include "Common/UI/Notice.h"
|
||||
#include "Common/UI/PopupScreens.h"
|
||||
#include "Common/UI/ScreenManager.h"
|
||||
#include "Common/UI/View.h"
|
||||
#include "Common/UI/ViewGroup.h"
|
||||
|
||||
#include "Core/Config.h"
|
||||
#include "Core/System.h"
|
||||
#include "Core/Util/PathUtil.h"
|
||||
|
||||
#include "UI/FirmwareScreen.h"
|
||||
#include "UI/InstallUpdateScreen.h"
|
||||
#include "UI/MiscViews.h"
|
||||
|
||||
std::string_view FirmwareScreen::GetTitle() const {
|
||||
auto sy = GetI18NCategory(I18NCat::SYSTEM);
|
||||
return sy->T("PSP Firmware");
|
||||
}
|
||||
|
||||
void FirmwareScreen::BeforeCreateViews() {
|
||||
nandRoot_ = GetSysDirectory(DIRECTORY_NAND);
|
||||
ReadInstalledFirmwareInfo(nandRoot_, &info_);
|
||||
}
|
||||
|
||||
void FirmwareScreen::CreateContentViews(UI::ViewGroup *parent) {
|
||||
using namespace UI;
|
||||
|
||||
auto sy = GetI18NCategory(I18NCat::SYSTEM);
|
||||
auto iz = GetI18NCategory(I18NCat::INSTALLZIP);
|
||||
auto di = GetI18NCategory(I18NCat::DIALOG);
|
||||
auto st = GetI18NCategory(I18NCat::STORE); // Borrow "Size" from here, like GameScreen does.
|
||||
|
||||
LinearLayout *content = parent->Add(new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT)));
|
||||
|
||||
if (!info_.anythingInstalled) {
|
||||
content->Add(new NoticeView(NoticeLevel::INFO, sy->T("No firmware installed"),
|
||||
sy->T("FirmwareSources", "PPSSPP has its own replacements for the PSP's system files, so a firmware is optional. Installing one gets you the real fonts, and lets you launch the XMB. Most game discs carry a firmware updater - open a game's info screen to install from it.")));
|
||||
content->Add(new TextWithImage(ImageID("I_FOLDER"), GetFriendlyPath(nandRoot_)));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!info_.version.empty()) {
|
||||
std::string versionLine = std::string(sy->T("Firmware version")) + ": " + info_.version;
|
||||
content->Add(new TextView(versionLine, ALIGN_LEFT, false))->SetBig(true);
|
||||
if (!info_.buildDate.empty() || !info_.target.empty()) {
|
||||
std::string details = info_.buildDate;
|
||||
if (!info_.target.empty()) {
|
||||
if (!details.empty()) {
|
||||
details += " - ";
|
||||
}
|
||||
details += info_.target;
|
||||
}
|
||||
content->Add(new TextView(details, ALIGN_LEFT, false));
|
||||
}
|
||||
} else {
|
||||
// No flash0:/vsh/etc/version.txt, so this isn't a full firmware - most likely just the
|
||||
// fonts, which is what installing from a running game's disc leaves behind.
|
||||
content->Add(new NoticeView(NoticeLevel::INFO, sy->T("Partial firmware installed"),
|
||||
sy->T("Some system files are present, but not a complete firmware")));
|
||||
}
|
||||
|
||||
content->Add(new ItemHeader(sy->T("Contents")));
|
||||
content->Add(new InfoItem(sy->T("Fonts"), info_.fontCount));
|
||||
content->Add(new InfoItem(sy->T("Kernel modules"), info_.kernelModuleCount));
|
||||
content->Add(new InfoItem(sy->T("XMB (VSH)"), info_.hasVsh ? di->T("Yes") : di->T("No")));
|
||||
content->Add(new InfoItem(sy->T("Files"), info_.fileCount));
|
||||
content->Add(new InfoItem(st->T("Size"), NiceSizeFormat(info_.totalSize)));
|
||||
|
||||
content->Add(new ItemHeader(iz->T("Install into folder")));
|
||||
content->Add(new TextView(GetFriendlyPath(nandRoot_), ALIGN_LEFT | FLAG_WRAP_TEXT, false));
|
||||
}
|
||||
|
||||
void FirmwareScreen::CreateSettingsViews(UI::ViewGroup *parent) {
|
||||
using namespace UI;
|
||||
|
||||
auto sy = GetI18NCategory(I18NCat::SYSTEM);
|
||||
auto iz = GetI18NCategory(I18NCat::INSTALLZIP);
|
||||
|
||||
// Booting anything replaces the running game, and erasing the NAND out from under a game
|
||||
// that has flash0 mounted is worse - so while a game is running, this screen is read-only.
|
||||
const bool gameRunning = PSP_IsInited();
|
||||
|
||||
Choice *launch = parent->Add(new Choice(sy->T("Launch XMB"), ImageID("I_PLAY")));
|
||||
launch->OnClick.Add([this](UI::EventParams &) {
|
||||
LaunchVSH();
|
||||
});
|
||||
launch->SetEnabled(!gameRunning && info_.hasVsh && FirmwareVersionSupportsVSH(info_.version));
|
||||
|
||||
if (info_.hasVsh && !FirmwareVersionSupportsVSH(info_.version)) {
|
||||
parent->Add(new NoticeView(NoticeLevel::WARN, sy->T("XMB unsupported"),
|
||||
sy->T("XMBUnsupportedVersion", "Only firmware 6.61 can boot the XMB so far")));
|
||||
}
|
||||
|
||||
if (System_GetPropertyBool(SYSPROP_HAS_FILE_BROWSER)) {
|
||||
Choice *install = parent->Add(new Choice(iz->T("Install PSP firmware update"), ImageID("I_FOLDER_UPLOAD")));
|
||||
install->OnClick.Add([this](UI::EventParams &) {
|
||||
BrowseForUpdater();
|
||||
});
|
||||
install->SetEnabled(!gameRunning);
|
||||
}
|
||||
|
||||
if (info_.anythingInstalled) {
|
||||
Choice *erase = parent->Add(new Choice(sy->T("Erase firmware"), ImageID("I_TRASHCAN")));
|
||||
erase->OnClick.Add([this](UI::EventParams &) {
|
||||
AskToErase();
|
||||
});
|
||||
erase->SetEnabled(!gameRunning);
|
||||
}
|
||||
|
||||
if (System_GetPropertyBool(SYSPROP_HAS_OPEN_DIRECTORY)) {
|
||||
parent->Add(new Choice(sy->T("Show firmware folder")))->OnClick.Add([this](UI::EventParams &) {
|
||||
System_LaunchUrl(LaunchUrlType::LOCAL_FOLDER, nandRoot_.ToString());
|
||||
});
|
||||
}
|
||||
|
||||
if (gameRunning) {
|
||||
parent->Add(new NoticeView(NoticeLevel::INFO,
|
||||
sy->T("FirmwareNeedsNoGame", "Stop the game to change the installed firmware"), ""));
|
||||
}
|
||||
}
|
||||
|
||||
void FirmwareScreen::dialogFinished(const Screen *dialog, DialogResult result) {
|
||||
// Coming back from the installer (or the erase confirmation), the NAND may well look
|
||||
// different than it did when we scanned it. Rescanning is cheap, so just always redo it -
|
||||
// BeforeCreateViews does the scan.
|
||||
RecreateViews();
|
||||
UITwoPaneBaseDialogScreen::dialogFinished(dialog, result);
|
||||
}
|
||||
|
||||
void FirmwareScreen::LaunchVSH() {
|
||||
System_PostUIMessage(UIMessage::REQUEST_GAME_BOOT, (nandRoot_ / "flash0/vsh/module/vshmain.prx").ToString());
|
||||
}
|
||||
|
||||
void FirmwareScreen::BrowseForUpdater() {
|
||||
auto iz = GetI18NCategory(I18NCat::INSTALLZIP);
|
||||
System_BrowseForFile(GetRequesterToken(), iz->T("Install PSP firmware update"), BrowseFileType::BOOTABLE,
|
||||
[this](std::string_view value, int) {
|
||||
screenManager()->push(new InstallUpdateScreen(Path(value), "", false));
|
||||
});
|
||||
}
|
||||
|
||||
void FirmwareScreen::AskToErase() {
|
||||
auto sy = GetI18NCategory(I18NCat::SYSTEM);
|
||||
auto di = GetI18NCategory(I18NCat::DIALOG);
|
||||
|
||||
std::string question(sy->T("EraseFirmwareConfirm", "This deletes everything in the NAND folder, including the fonts."));
|
||||
screenManager()->push(new UI::MessagePopupScreen(sy->T("Erase firmware"), question, di->T("Delete"), di->T("Cancel"),
|
||||
[this](bool erase) {
|
||||
if (!erase) {
|
||||
return;
|
||||
}
|
||||
std::string error;
|
||||
if (!EraseInstalledFirmware(nandRoot_, &error)) {
|
||||
ERROR_LOG(Log::Loader, "Failed to erase the firmware: %s", error.c_str());
|
||||
}
|
||||
RecreateViews();
|
||||
}));
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
// Copyright (c) 2026- PPSSPP Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0 or later versions.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official git repository and contact information can be found at
|
||||
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Common/File/Path.h"
|
||||
#include "Common/UI/UIScreen.h"
|
||||
#include "Common/UI/ViewGroup.h"
|
||||
|
||||
#include "Core/Util/PSARUnpack.h"
|
||||
|
||||
#include "UI/SimpleDialogScreen.h"
|
||||
|
||||
// What's in PSP/NAND - which can be nothing at all, just the fonts we pulled off some game's
|
||||
// disc, or a full firmware unpacked from an updater. Also the place to launch the XMB from,
|
||||
// since that's what a full firmware buys you.
|
||||
class FirmwareScreen : public UITwoPaneBaseDialogScreen {
|
||||
public:
|
||||
FirmwareScreen(const Path &gamePath)
|
||||
: UITwoPaneBaseDialogScreen(gamePath, TwoPaneFlags::SettingsToTheRight | TwoPaneFlags::ContentsCanScroll) {}
|
||||
|
||||
const char *tag() const override { return "Firmware"; }
|
||||
|
||||
protected:
|
||||
std::string_view GetTitle() const override;
|
||||
void BeforeCreateViews() override;
|
||||
void CreateSettingsViews(UI::ViewGroup *parent) override;
|
||||
void CreateContentViews(UI::ViewGroup *parent) override;
|
||||
void dialogFinished(const Screen *dialog, DialogResult result) override;
|
||||
|
||||
private:
|
||||
void LaunchVSH();
|
||||
void BrowseForUpdater();
|
||||
void AskToErase();
|
||||
|
||||
Path nandRoot_;
|
||||
InstalledFirmwareInfo info_;
|
||||
};
|
||||
@@ -50,6 +50,7 @@
|
||||
#include "UI/DevScreens.h"
|
||||
#include "UI/DeveloperToolsScreen.h"
|
||||
#include "UI/DisplayLayoutScreen.h"
|
||||
#include "UI/FirmwareScreen.h"
|
||||
#include "UI/RemoteISOScreen.h"
|
||||
#include "UI/SavedataScreen.h"
|
||||
#include "UI/SystemInfoScreen.h"
|
||||
@@ -1138,6 +1139,9 @@ void GameSettingsScreen::CreateToolsSettings(UI::ViewGroup *tools) {
|
||||
tools->Add(new Choice(ri->T("Remote disc streaming")))->OnClick.Add([=](UI::EventParams &) {
|
||||
screenManager()->push(new RemoteISOScreen(gamePath_));
|
||||
});
|
||||
tools->Add(new Choice(sy->T("PSP Firmware")))->OnClick.Add([=](UI::EventParams &) {
|
||||
screenManager()->push(new FirmwareScreen(gamePath_));
|
||||
});
|
||||
}
|
||||
|
||||
void GameSettingsScreen::CreateSystemSettings(UI::ViewGroup *systemSettings) {
|
||||
|
||||
@@ -36,8 +36,8 @@
|
||||
#include "UI/MiscViews.h"
|
||||
#include "UI/EmuScreen.h"
|
||||
|
||||
InstallUpdateScreen::InstallUpdateScreen(const Path &path, std::string_view title)
|
||||
: UISimpleBaseDialogScreen(Path(), SimpleDialogFlags::ContentsCanScroll), path_(path), title_(title) {
|
||||
InstallUpdateScreen::InstallUpdateScreen(const Path &path, std::string_view title, bool allowRun)
|
||||
: UISimpleBaseDialogScreen(Path(), SimpleDialogFlags::ContentsCanScroll), path_(path), title_(title), allowRun_(allowRun) {
|
||||
destination_ = GetSysDirectory(DIRECTORY_NAND);
|
||||
|
||||
File::FileInfo fileInfo;
|
||||
@@ -80,7 +80,8 @@ void InstallUpdateScreen::CreateDialogViews(UI::ViewGroup *parent) {
|
||||
container->Add(new TextView(GetFriendlyPath(destination_)))->SetAlign(FLAG_WRAP_TEXT);
|
||||
|
||||
if (overwrites_) {
|
||||
container->Add(new NoticeView(NoticeLevel::WARN, di->T("Confirm Overwrite"), ""));
|
||||
container->Add(new NoticeView(NoticeLevel::WARN, di->T("Confirm Overwrite"),
|
||||
iz->T("The firmware already installed will be erased first")));
|
||||
}
|
||||
|
||||
container->Add(new Spacer(12.0f));
|
||||
@@ -90,10 +91,12 @@ void InstallUpdateScreen::CreateDialogViews(UI::ViewGroup *parent) {
|
||||
StartInstall();
|
||||
});
|
||||
|
||||
Choice *runChoice = container->Add(new Choice(dev->T("Run"), ImageID("I_PLAY")));
|
||||
runChoice->OnClick.Add([this](UI::EventParams &e) {
|
||||
screenManager()->switchScreen(new EmuScreen(path_));
|
||||
});
|
||||
if (allowRun_) {
|
||||
Choice *runChoice = container->Add(new Choice(dev->T("Run"), ImageID("I_PLAY")));
|
||||
runChoice->OnClick.Add([this](UI::EventParams &e) {
|
||||
screenManager()->switchScreen(new EmuScreen(path_));
|
||||
});
|
||||
}
|
||||
|
||||
progressBar_ = container->Add(new ProgressBar());
|
||||
progressBar_->SetVisibility(V_GONE);
|
||||
@@ -125,6 +128,13 @@ void InstallUpdateScreen::StartInstall() {
|
||||
options.progress = [state](float progress) {
|
||||
state->progress = progress;
|
||||
};
|
||||
// Two firmwares can't be merged - a file the new one doesn't have would linger and still
|
||||
// get loaded - so start from an empty NAND.
|
||||
if (!EraseInstalledFirmware(destination, &state->error)) {
|
||||
state->success = false;
|
||||
state->done = true;
|
||||
return;
|
||||
}
|
||||
state->success = UnpackUpdater(path, destination, options, &state->stats, &state->error);
|
||||
if (state->success && state->stats.written == 0) {
|
||||
// Nothing came out, so the archive had no file list for the model we asked for -
|
||||
|
||||
@@ -39,7 +39,9 @@
|
||||
class InstallUpdateScreen : public UISimpleBaseDialogScreen {
|
||||
public:
|
||||
// title is the updater's SFO title, which already carries the version ("PSP Update ver 6.61").
|
||||
InstallUpdateScreen(const Path &path, std::string_view title);
|
||||
// allowRun offers to boot the updater instead of unpacking it - which makes sense when the
|
||||
// user picked the updater to launch it, but not when they came here to install a firmware.
|
||||
InstallUpdateScreen(const Path &path, std::string_view title, bool allowRun);
|
||||
|
||||
void CreateDialogViews(UI::ViewGroup *parent) override;
|
||||
void update() override;
|
||||
@@ -70,6 +72,7 @@ private:
|
||||
std::string title_;
|
||||
u64 fileSize_ = 0;
|
||||
bool overwrites_ = false;
|
||||
bool allowRun_ = false;
|
||||
|
||||
std::shared_ptr<InstallState> state_;
|
||||
bool reportedDone_ = false;
|
||||
|
||||
+1
-1
@@ -101,7 +101,7 @@ static void LaunchFile(ScreenManager *screenManager, Screen *currentScreen, cons
|
||||
std::string title = info->GetTitle(); // includes the version.
|
||||
// The unpacker wants the PBP itself, not the folder it happens to sit in.
|
||||
const Path pbpPath = info->fileType == IdentifiedFileType::PSP_PBP ? path : path / "EBOOT.PBP";
|
||||
screenManager->push(new InstallUpdateScreen(pbpPath, title));
|
||||
screenManager->push(new InstallUpdateScreen(pbpPath, title, true));
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -80,6 +80,7 @@
|
||||
<ClCompile Include="TouchControlLayoutScreen.cpp" />
|
||||
<ClCompile Include="TouchControlVisibilityScreen.cpp" />
|
||||
<ClCompile Include="InstallPkgScreen.cpp" />
|
||||
<ClCompile Include="FirmwareScreen.cpp" />
|
||||
<ClCompile Include="InstallUpdateScreen.cpp" />
|
||||
<ClCompile Include="InstallZipScreen.cpp" />
|
||||
<ClCompile Include="Theme.cpp" />
|
||||
@@ -139,6 +140,7 @@
|
||||
<ClInclude Include="TouchControlLayoutScreen.h" />
|
||||
<ClInclude Include="TouchControlVisibilityScreen.h" />
|
||||
<ClInclude Include="InstallPkgScreen.h" />
|
||||
<ClInclude Include="FirmwareScreen.h" />
|
||||
<ClInclude Include="InstallUpdateScreen.h" />
|
||||
<ClInclude Include="InstallZipScreen.h" />
|
||||
<ClInclude Include="Theme.h" />
|
||||
|
||||
@@ -43,6 +43,9 @@
|
||||
<ClCompile Include="InstallPkgScreen.cpp">
|
||||
<Filter>Screens</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="FirmwareScreen.cpp">
|
||||
<Filter>Screens</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="InstallUpdateScreen.cpp">
|
||||
<Filter>Screens</Filter>
|
||||
</ClCompile>
|
||||
@@ -200,6 +203,9 @@
|
||||
<ClInclude Include="InstallPkgScreen.h">
|
||||
<Filter>Screens</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="FirmwareScreen.h">
|
||||
<Filter>Screens</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="InstallUpdateScreen.h">
|
||||
<Filter>Screens</Filter>
|
||||
</ClInclude>
|
||||
|
||||
Reference in new issue
Block a user