Compare commits

..

5 Commits

Author SHA1 Message Date
MatthewBiskas 0713565850
Merge 6e3e2400fb into 5486eed151 2024-09-19 01:25:55 +00:00
Matthew 6e3e2400fb Changes to work for windows + linux 2024-09-19 03:25:47 +02:00
Matthew 06513d81f8 Changes to work for windows + linux 2024-09-19 03:22:52 +02:00
lightningterror 5486eed151 GS/HW: Merge blend ad a mask separate conditions in to one.
Duplicate code.
2024-09-19 00:19:05 +02:00
Ty Lamontagne d1721360ff
DebugInterface: Fix formatting 2024-09-18 16:57:20 -04:00
4 changed files with 53 additions and 27 deletions

View File

@ -11,7 +11,13 @@
#include "common/Path.h" #include "common/Path.h"
#include "common/StringUtil.h" #include "common/StringUtil.h"
#include <unistd.h> // Platform-specific includes
#ifdef _WIN32
#include <windows.h>
#else
#include <unistd.h>
#include <sys/stat.h>
#endif
MemoryCardConvertDialog::MemoryCardConvertDialog(QWidget* parent, QString selectedCard) MemoryCardConvertDialog::MemoryCardConvertDialog(QWidget* parent, QString selectedCard)
: QDialog(parent) : QDialog(parent)
@ -38,7 +44,7 @@ MemoryCardConvertDialog::MemoryCardConvertDialog(QWidget* parent, QString select
m_ui.progressBar->setRange(0, 100); m_ui.progressBar->setRange(0, 100);
m_ui.progressBar->setValue(0); m_ui.progressBar->setValue(0);
connect(m_ui.conversionTypeSelect, &QComboBox::currentIndexChanged, this, [this]() connect(m_ui.conversionTypeSelect, &QComboBox::currentIndexChanged, this, [this]()
{ {
switch (m_srcCardInfo.type) switch (m_srcCardInfo.type)
{ {
@ -73,7 +79,7 @@ MemoryCardConvertDialog::MemoryCardConvertDialog(QWidget* parent, QString select
} }
} }
); );
disconnect(m_ui.buttonBox, &QDialogButtonBox::accepted, this, nullptr); disconnect(m_ui.buttonBox, &QDialogButtonBox::accepted, this, nullptr);
connect(m_ui.buttonBox->button(QDialogButtonBox::Ok), &QPushButton::clicked, this, &MemoryCardConvertDialog::ConvertCard); connect(m_ui.buttonBox->button(QDialogButtonBox::Ok), &QPushButton::clicked, this, &MemoryCardConvertDialog::ConvertCard);
@ -156,7 +162,7 @@ bool MemoryCardConvertDialog::SetupPicklist()
for (auto dirEntry : rootDir) for (auto dirEntry : rootDir)
{ {
const std::string_view fileName = Path::GetFileName(dirEntry.FileName); const std::string_view fileName = Path::GetFileName(dirEntry.FileName);
if (fileName.size() >= 7 && fileName.substr(0, 7).compare("_pcsx2_") == 0) if (fileName.size() >= 7 && fileName.substr(0, 7).compare("_pcsx2_") == 0)
{ {
continue; continue;
@ -178,7 +184,7 @@ bool MemoryCardConvertDialog::SetupPicklist()
if (sizeBytes < CardCapacity::_8_MB) if (sizeBytes < CardCapacity::_8_MB)
{ {
m_ui.conversionTypeSelect->addItem(tr("8 MB File"), 8); m_ui.conversionTypeSelect->addItem(tr("8 MB File"), 8);
if (!typeSet) if (!typeSet)
{ {
SetType_8(); SetType_8();
@ -189,7 +195,7 @@ bool MemoryCardConvertDialog::SetupPicklist()
if (sizeBytes < CardCapacity::_16_MB) if (sizeBytes < CardCapacity::_16_MB)
{ {
m_ui.conversionTypeSelect->addItem(tr("16 MB File"), 16); m_ui.conversionTypeSelect->addItem(tr("16 MB File"), 16);
if (!typeSet) if (!typeSet)
{ {
SetType_16(); SetType_16();
@ -200,7 +206,7 @@ bool MemoryCardConvertDialog::SetupPicklist()
if (sizeBytes < CardCapacity::_32_MB) if (sizeBytes < CardCapacity::_32_MB)
{ {
m_ui.conversionTypeSelect->addItem(tr("32 MB File"), 32); m_ui.conversionTypeSelect->addItem(tr("32 MB File"), 32);
if (!typeSet) if (!typeSet)
{ {
SetType_32(); SetType_32();
@ -211,7 +217,7 @@ bool MemoryCardConvertDialog::SetupPicklist()
if (sizeBytes < CardCapacity::_64_MB) if (sizeBytes < CardCapacity::_64_MB)
{ {
m_ui.conversionTypeSelect->addItem(tr("64 MB File"), 64); m_ui.conversionTypeSelect->addItem(tr("64 MB File"), 64);
if (!typeSet) if (!typeSet)
{ {
SetType_64(); SetType_64();
@ -244,7 +250,7 @@ void MemoryCardConvertDialog::ConvertCard()
else else
{ {
QString baseName = m_selectedCard; QString baseName = m_selectedCard;
// Get our destination file name // Get our destination file name
size_t extensionPos = baseName.lastIndexOf(".ps2", -1); size_t extensionPos = baseName.lastIndexOf(".ps2", -1);
// Strip the extension off of it // Strip the extension off of it
@ -260,14 +266,34 @@ void MemoryCardConvertDialog::ConvertCard()
QDir destinationDir(fullPath); QDir destinationDir(fullPath);
QString absolutePath = destinationDir.absolutePath(); // Get the absolute path QString absolutePath = destinationDir.absolutePath(); // Get the absolute path
if (access(absolutePath.toStdString().c_str(), R_OK | W_OK | X_OK) != 0) // Check for read/write/execute permissions on the directory
{ // We only need to check the parent directory where the file will be created
QMessageBox::critical(this, tr("Cannot Convert Memory Card"), QFileInfo dirInfo(destinationDir.absolutePath());
tr("You have insufficient permissions to convert this Memory Card. Please ensure that your user owns the directory of your Memory Cards. \n \"%1\".") QString dirPath = dirInfo.absolutePath();
.arg(absolutePath));
return; #ifdef _WIN32
} // Windows systems
DWORD fileAttributes = GetFileAttributes(dirPath.toStdString().c_str());
// Windows has no direct R/W/X permission model like Linux. We check for basic file existence.
bool canRead = !(fileAttributes & FILE_ATTRIBUTE_READONLY);
bool canWrite = true; // If not read-only, assume write is possible.
if !(canRead && canWrite)
{
PermissionError(absolutePath);
return;
}
#else
// Linux/Unix systems
if (access(dirPath.toStdString().c_str(), R_OK | W_OK | X_OK) != 0)
{
PermissionError(absolutePath);
return;
}
#endif
// If a match is found, revert back to the base name, add a number and the extension, and try again. // If a match is found, revert back to the base name, add a number and the extension, and try again.
// Keep incrementing the number until we get a unique result. // Keep incrementing the number until we get a unique result.
while (m_srcCardInfo.type == MemoryCardType::File ? FileSystem::DirectoryExists(Path::Combine(EmuFolders::MemoryCards, destName.toStdString()).c_str()) : FileSystem::FileExists(Path::Combine(EmuFolders::MemoryCards, destName.toStdString()).c_str())) while (m_srcCardInfo.type == MemoryCardType::File ? FileSystem::DirectoryExists(Path::Combine(EmuFolders::MemoryCards, destName.toStdString()).c_str()) : FileSystem::FileExists(Path::Combine(EmuFolders::MemoryCards, destName.toStdString()).c_str()))
@ -275,7 +301,7 @@ void MemoryCardConvertDialog::ConvertCard()
destName = baseName; destName = baseName;
destName.append(StringUtil::StdStringFromFormat("_%02zd.ps2", ++num).c_str()); destName.append(StringUtil::StdStringFromFormat("_%02zd.ps2", ++num).c_str());
} }
m_destCardName = destName; m_destCardName = destName;
StartThread(); StartThread();
} }
@ -317,3 +343,8 @@ void MemoryCardConvertDialog::SetType_Folder()
{ {
SetType(MemoryCardType::Folder, MemoryCardFileType::Unknown, tr("Uses a folder on your PC filesystem, instead of a file. Infinite capacity, while keeping the same compatibility as an 8 MB Memory Card.")); SetType(MemoryCardType::Folder, MemoryCardFileType::Unknown, tr("Uses a folder on your PC filesystem, instead of a file. Infinite capacity, while keeping the same compatibility as an 8 MB Memory Card."));
} }
void MemoryCardConvertDialog::PermissionError(QString absolutePath)
{
QMessageBox::critical(this, tr("Cannot Convert Memory Card"),tr("You have insufficient permissions to convert this Memory Card. Please ensure that your user owns the directory of your Memory Cards. \n \"%1\".").arg(absolutePath));
}

View File

@ -41,6 +41,7 @@ private:
void SetType_32(); void SetType_32();
void SetType_64(); void SetType_64();
void SetType_Folder(); void SetType_Folder();
void PermissionError(QString absolutePath);
Ui::MemoryCardConvertDialog m_ui; Ui::MemoryCardConvertDialog m_ui;

View File

@ -829,7 +829,7 @@ bool R5900DebugInterface::isValidAddress(u32 addr)
break; break;
case 8: case 8:
case 0xA: case 0xA:
if(lopart <= 0xFFFFF) if (lopart <= 0xFFFFF)
return true; return true;
break; break;
case 9: case 9:

View File

@ -4208,14 +4208,8 @@ void GSRendererHW::EmulateBlending(int rt_alpha_min, int rt_alpha_max, const boo
const bool alpha_mask = (m_cached_ctx.FRAME.FBMSK & 0xFF000000) == 0xFF000000; const bool alpha_mask = (m_cached_ctx.FRAME.FBMSK & 0xFF000000) == 0xFF000000;
bool blend_ad_alpha_masked = blend_ad && alpha_mask; bool blend_ad_alpha_masked = blend_ad && alpha_mask;
const bool is_basic_blend = GSConfig.AccurateBlendingUnit >= AccBlendLevel::Basic; const bool is_basic_blend = GSConfig.AccurateBlendingUnit >= AccBlendLevel::Basic;
if ((is_basic_blend || (COLCLAMP.CLAMP == 0)) && features.texture_barrier && blend_ad_alpha_masked) if (blend_ad_alpha_masked && (((is_basic_blend || (COLCLAMP.CLAMP == 0)) && features.texture_barrier)
{ || ((GSConfig.AccurateBlendingUnit >= AccBlendLevel::Medium) || m_conf.require_one_barrier)))
// Swap Ad with As for hw blend.
m_conf.ps.a_masked = 1;
m_conf.ps.blend_c = 0;
m_conf.require_one_barrier |= true;
}
else if (((GSConfig.AccurateBlendingUnit >= AccBlendLevel::Medium) || m_conf.require_one_barrier) && blend_ad_alpha_masked)
{ {
// Swap Ad with As for hw blend. // Swap Ad with As for hw blend.
m_conf.ps.a_masked = 1; m_conf.ps.a_masked = 1;