mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Merge pull request #18386 from hrydgard/crc-progress-bar
CRC calculation on game screen: Show progress bar
This commit is contained in:
commit
8ce639fddf
6 changed files with 37 additions and 21 deletions
|
@ -65,23 +65,6 @@ BlockDevice *constructBlockDevice(FileLoader *fileLoader) {
|
|||
return new FileBlockDevice(fileLoader);
|
||||
}
|
||||
|
||||
u32 BlockDevice::CalculateCRC(volatile bool *cancel) {
|
||||
u32 crc = crc32(0, Z_NULL, 0);
|
||||
|
||||
u8 block[2048];
|
||||
for (u32 i = 0; i < GetNumBlocks(); ++i) {
|
||||
if (cancel && *cancel)
|
||||
return 0;
|
||||
if (!ReadBlock(i, block, true)) {
|
||||
ERROR_LOG(FILESYS, "Failed to read block for CRC");
|
||||
return 0;
|
||||
}
|
||||
crc = crc32(crc, block, 2048);
|
||||
}
|
||||
|
||||
return crc;
|
||||
}
|
||||
|
||||
void BlockDevice::NotifyReadError() {
|
||||
auto err = GetI18NCategory(I18NCat::ERRORS);
|
||||
if (!reportedError_) {
|
||||
|
|
|
@ -51,7 +51,6 @@ public:
|
|||
}
|
||||
virtual bool IsDisc() const = 0;
|
||||
|
||||
u32 CalculateCRC(volatile bool *cancel = nullptr);
|
||||
void NotifyReadError();
|
||||
|
||||
protected:
|
||||
|
|
|
@ -24,12 +24,19 @@
|
|||
#include <cstdlib>
|
||||
#include <cstdarg>
|
||||
|
||||
// for crc32
|
||||
extern "C" {
|
||||
#include "zlib.h"
|
||||
}
|
||||
|
||||
#include "Core/Reporting.h"
|
||||
#include "Common/File/VFS/VFS.h"
|
||||
#include "Common/CPUDetect.h"
|
||||
#include "Common/File/FileUtil.h"
|
||||
#include "Common/Serialize/SerializeFuncs.h"
|
||||
#include "Common/StringUtils.h"
|
||||
#include "Common/System/OSD.h"
|
||||
#include "Common/Data/Text/I18n.h"
|
||||
#include "Core/Core.h"
|
||||
#include "Core/CoreTiming.h"
|
||||
#include "Core/Config.h"
|
||||
|
@ -108,6 +115,31 @@ namespace Reporting
|
|||
static volatile bool crcCancel = false;
|
||||
static std::thread crcThread;
|
||||
|
||||
static u32 CalculateCRC(BlockDevice *blockDevice, volatile bool *cancel) {
|
||||
auto ga = GetI18NCategory(I18NCat::GAME);
|
||||
|
||||
u32 crc = crc32(0, Z_NULL, 0);
|
||||
|
||||
u8 block[2048];
|
||||
u32 numBlocks = blockDevice->GetNumBlocks();
|
||||
for (u32 i = 0; i < numBlocks; ++i) {
|
||||
if (cancel && *cancel) {
|
||||
g_OSD.RemoveProgressBar("crc", false, 0.0f);
|
||||
return 0;
|
||||
}
|
||||
if (!blockDevice->ReadBlock(i, block, true)) {
|
||||
ERROR_LOG(FILESYS, "Failed to read block for CRC");
|
||||
g_OSD.RemoveProgressBar("crc", false, 0.0f);
|
||||
return 0;
|
||||
}
|
||||
crc = crc32(crc, block, 2048);
|
||||
g_OSD.SetProgressBar("crc", std::string(ga->T("Calculate CRC")), 0.0f, (float)numBlocks, (float)i, 0.5f);
|
||||
}
|
||||
|
||||
g_OSD.RemoveProgressBar("crc", true, 0.0f);
|
||||
return crc;
|
||||
}
|
||||
|
||||
static int CalculateCRCThread() {
|
||||
SetCurrentThreadName("ReportCRC");
|
||||
|
||||
|
@ -118,7 +150,7 @@ namespace Reporting
|
|||
|
||||
u32 crc = 0;
|
||||
if (blockDevice) {
|
||||
crc = blockDevice->CalculateCRC(&crcCancel);
|
||||
crc = CalculateCRC(blockDevice, &crcCancel);
|
||||
}
|
||||
|
||||
delete blockDevice;
|
||||
|
@ -128,6 +160,7 @@ namespace Reporting
|
|||
crcResults[crcFilename] = crc;
|
||||
crcPending = false;
|
||||
crcCond.notify_one();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -130,7 +130,7 @@ void GameScreen::CreateViews() {
|
|||
tvCRC_ = infoLayout->Add(new TextView("", ALIGN_LEFT, true, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT)));
|
||||
tvCRC_->SetShadow(true);
|
||||
tvCRC_->SetVisibility(Reporting::HasCRC(gamePath_) ? V_VISIBLE : V_GONE);
|
||||
tvVerified_ = infoLayout->Add(new NoticeView(NoticeLevel::INFO, ga->T("Click Calculate CRC to verify"), "", new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT)));
|
||||
tvVerified_ = infoLayout->Add(new NoticeView(NoticeLevel::INFO, ga->T("Click \"Calculate CRC\" to verify ISO"), "", new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT)));
|
||||
tvVerified_->SetVisibility(UI::V_GONE);
|
||||
} else {
|
||||
tvTitle_ = nullptr;
|
||||
|
|
|
@ -81,7 +81,7 @@ Unofficial achievements = Conquistas não oficiais
|
|||
|
||||
[Audio]
|
||||
Alternate speed volume = Velocidade alternativa do volume
|
||||
Audio backend = Backed do áudio (requer reiniciar)
|
||||
Audio backend = Backend do áudio (requer reiniciar)
|
||||
Audio file format not supported. Must be WAV. = Formato do arquivo de áudio não suportado. Deve ser WAV.
|
||||
Audio Error = Erro do Áudio
|
||||
AudioBufferingForBluetooth = Buffer amigável do Bluetooth (mais lento)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include <thread>
|
||||
#include <vector>
|
||||
#include <cstdio>
|
||||
|
||||
#include "Common/Log.h"
|
||||
#include "Common/TimeUtil.h"
|
||||
|
|
Loading…
Add table
Reference in a new issue