misc changes, part ?/? (#441)

* gui: add option to boot a game by choosing elf file

* core: some small implementations

* fs: implement open func

* add some validations

* spirv: add image format

* video_core: add eR16Uint to formats
This commit is contained in:
Dzmitry Dubrova 2024-08-16 20:16:15 +03:00 committed by GitHub
parent 9e810b7524
commit dcb057dd7f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 75 additions and 0 deletions

View File

@ -208,4 +208,7 @@ int PS4_SYSV_ABI sceKernelDeleteUserEvent(SceKernelEqueue eq, int id) {
return ORBIS_OK;
}
s16 PS4_SYSV_ABI sceKernelGetEventFilter(const SceKernelEvent* ev) {
return ev->filter;
}
} // namespace Libraries::Kernel

View File

@ -21,5 +21,6 @@ int PS4_SYSV_ABI sceKernelDeleteUserEvent(SceKernelEqueue eq, int id);
int PS4_SYSV_ABI sceKernelAddUserEvent(SceKernelEqueue eq, int id);
int PS4_SYSV_ABI sceKernelAddUserEventEdge(SceKernelEqueue eq, int id);
s32 PS4_SYSV_ABI sceKernelAddHRTimerEvent(SceKernelEqueue eq, int id, timespec* ts, void* udata);
s16 PS4_SYSV_ABI sceKernelGetEventFilter(const SceKernelEvent* ev);
} // namespace Libraries::Kernel

View File

@ -112,6 +112,15 @@ int PS4_SYSV_ABI posix_open(const char* path, int flags, /* SceKernelMode*/ u16
return result;
}
int PS4_SYSV_ABI open(const char* filename, const char* mode) {
LOG_INFO(Kernel_Fs, "open redirect to sceKernelOpen");
int result = sceKernelOpen(filename, ORBIS_KERNEL_O_RDWR, 0);
if (result < 0) {
return -1;
}
return result;
}
int PS4_SYSV_ABI sceKernelClose(int d) {
if (d < 3) { // d probably hold an error code
return ORBIS_KERNEL_ERROR_EPERM;
@ -498,6 +507,7 @@ void fileSystemSymbolsRegister(Core::Loader::SymbolsResolver* sym) {
std::srand(std::time(nullptr));
LIB_FUNCTION("1G3lF1Gg1k8", "libkernel", 1, "libkernel", 1, 1, sceKernelOpen);
LIB_FUNCTION("wuCroIGjt2g", "libScePosix", 1, "libkernel", 1, 1, posix_open);
LIB_FUNCTION("wuCroIGjt2g", "libkernel", 1, "libkernel", 1, 1, open);
LIB_FUNCTION("UK2Tl2DWUns", "libkernel", 1, "libkernel", 1, 1, sceKernelClose);
LIB_FUNCTION("bY-PO6JhzhQ", "libkernel", 1, "libkernel", 1, 1, posix_close);
LIB_FUNCTION("bY-PO6JhzhQ", "libScePosix", 1, "libkernel", 1, 1, posix_close);

View File

@ -423,6 +423,7 @@ void LibKernel_Register(Core::Loader::SymbolsResolver* sym) {
LIB_FUNCTION("F6e0kwo4cnk", "libkernel", 1, "libkernel", 1, 1, sceKernelTriggerUserEvent);
LIB_FUNCTION("LJDwdSNTnDg", "libkernel", 1, "libkernel", 1, 1, sceKernelDeleteUserEvent);
LIB_FUNCTION("mJ7aghmgvfc", "libkernel", 1, "libkernel", 1, 1, sceKernelGetEventId);
LIB_FUNCTION("23CPPI1tyBY", "libkernel", 1, "libkernel", 1, 1, sceKernelGetEventFilter);
// misc
LIB_FUNCTION("WslcK1FQcGI", "libkernel", 1, "libkernel", 1, 1, sceKernelIsNeoMode);

View File

@ -151,6 +151,28 @@ s32 PS4_SYSV_ABI sceVideoOutSubmitFlip(s32 handle, s32 bufferIndex, s32 flipMode
return ORBIS_OK;
}
int PS4_SYSV_ABI sceVideoOutGetEventId(const Kernel::SceKernelEvent* ev) {
if (ev == nullptr) {
return SCE_VIDEO_OUT_ERROR_INVALID_ADDRESS;
}
if (ev->filter != Kernel::SceKernelEvent::Filter::VideoOut) {
return ORBIS_VIDEO_OUT_ERROR_INVALID_EVENT_QUEUE;
}
return ev->ident;
}
int PS4_SYSV_ABI sceVideoOutGetEventData(const Kernel::SceKernelEvent* ev, int64_t* data) {
if (ev == nullptr || data == nullptr) {
return SCE_VIDEO_OUT_ERROR_INVALID_ADDRESS;
}
if (ev->filter != Kernel::SceKernelEvent::Filter::VideoOut) {
return ORBIS_VIDEO_OUT_ERROR_INVALID_EVENT_QUEUE;
}
*data = ev->data;
return ORBIS_OK;
}
s32 PS4_SYSV_ABI sceVideoOutGetFlipStatus(s32 handle, FlipStatus* status) {
if (!status) {
LOG_ERROR(Lib_VideoOut, "Flip status is null");
@ -302,6 +324,9 @@ void RegisterLib(Core::Loader::SymbolsResolver* sym) {
LIB_FUNCTION("kGVLc3htQE8", "libSceVideoOut", 1, "libSceVideoOut", 0, 0,
sceVideoOutGetDeviceCapabilityInfo);
LIB_FUNCTION("j6RaAUlaLv0", "libSceVideoOut", 1, "libSceVideoOut", 0, 0, sceVideoOutWaitVblank);
LIB_FUNCTION("U2JJtSqNKZI", "libSceVideoOut", 1, "libSceVideoOut", 0, 0, sceVideoOutGetEventId);
LIB_FUNCTION("rWUTcKdkUzQ", "libSceVideoOut", 1, "libSceVideoOut", 0, 0,
sceVideoOutGetEventData);
// openOrbis appears to have libSceVideoOut_v1 module libSceVideoOut_v1.1
LIB_FUNCTION("Up36PTk687E", "libSceVideoOut", 1, "libSceVideoOut", 1, 1, sceVideoOutOpen);

View File

@ -104,6 +104,8 @@ s32 PS4_SYSV_ABI sceVideoOutGetResolutionStatus(s32 handle, SceVideoOutResolutio
s32 PS4_SYSV_ABI sceVideoOutOpen(SceUserServiceUserId userId, s32 busType, s32 index,
const void* param);
s32 PS4_SYSV_ABI sceVideoOutClose(s32 handle);
int PS4_SYSV_ABI sceVideoOutGetEventId(const Kernel::SceKernelEvent* ev);
int PS4_SYSV_ABI sceVideoOutGetEventData(const Kernel::SceKernelEvent* ev, int64_t* data);
// Internal system functions
void sceVideoOutGetBufferLabelAddress(s32 handle, uintptr_t* label_addr);

View File

@ -328,6 +328,7 @@ void MainWindow::CreateConnects() {
// Package install.
connect(ui->bootInstallPkgAct, &QAction::triggered, this, &MainWindow::InstallPkg);
connect(ui->bootGameAct, &QAction::triggered, this, &MainWindow::BootGame);
connect(ui->gameInstallPathAct, &QAction::triggered, this, &MainWindow::InstallDirectory);
// elf viewer
@ -484,6 +485,27 @@ void MainWindow::InstallPkg() {
}
}
void MainWindow::BootGame() {
QFileDialog dialog;
dialog.setFileMode(QFileDialog::ExistingFile);
dialog.setNameFilter(tr("ELF files (*.bin *.elf *.oelf)"));
if (dialog.exec()) {
QStringList fileNames = dialog.selectedFiles();
int nFiles = fileNames.size();
if (nFiles > 1) {
QMessageBox::critical(nullptr, "Game Boot", QString("Only one file can be selected!"));
} else {
std::filesystem::path path(fileNames[0].toStdString());
#ifdef _WIN64
path = std::filesystem::path(fileNames[0].toStdWString());
#endif
Core::Emulator emulator;
emulator.Run(path);
}
}
}
void MainWindow::InstallDragDropPkg(std::filesystem::path file, int pkgNum, int nPkg) {
if (Loader::DetectFileType(file) == Loader::FileTypes::Pkg) {
pkg = PKG();

View File

@ -61,6 +61,7 @@ private:
void SetLastIconSizeBullet();
void SetUiIcons(bool isWhite);
void InstallPkg();
void BootGame();
void AddRecentFiles(QString filePath);
QIcon RecolorIcon(const QIcon& icon, bool isWhite);
bool isIconBlack = false;

View File

@ -30,6 +30,7 @@ QT_BEGIN_NAMESPACE
class Ui_MainWindow {
public:
QAction* bootInstallPkgAct;
QAction* bootGameAct;
QAction* addElfFolderAct;
QAction* exitAct;
QAction* showGameListAct;
@ -92,6 +93,8 @@ public:
bootInstallPkgAct = new QAction(MainWindow);
bootInstallPkgAct->setObjectName("bootInstallPkgAct");
bootInstallPkgAct->setIcon(QIcon(":images/file_icon.png"));
bootGameAct = new QAction(MainWindow);
bootGameAct->setObjectName("bootGameAct");
addElfFolderAct = new QAction(MainWindow);
addElfFolderAct->setObjectName("addElfFolderAct");
exitAct = new QAction(MainWindow);
@ -251,6 +254,7 @@ public:
menuBar->addAction(menuView->menuAction());
menuBar->addAction(menuSettings->menuAction());
menuFile->addAction(bootInstallPkgAct);
menuFile->addAction(bootGameAct);
menuFile->addAction(addElfFolderAct);
menuFile->addSeparator();
menuFile->addAction(menuRecent->menuAction());
@ -290,6 +294,7 @@ public:
QCoreApplication::translate("MainWindow", "Open/Add Elf Folder", nullptr));
bootInstallPkgAct->setText(
QCoreApplication::translate("MainWindow", "Install Packages (PKG)", nullptr));
bootGameAct->setText(QCoreApplication::translate("MainWindow", "Boot Game", nullptr));
#if QT_CONFIG(tooltip)
bootInstallPkgAct->setToolTip(QCoreApplication::translate(
"MainWindow", "Install application from a .pkg file", nullptr));

View File

@ -397,6 +397,10 @@ spv::ImageFormat GetFormat(const AmdGpu::Image& image) {
image.GetNumberFmt() == AmdGpu::NumberFormat::Float) {
return spv::ImageFormat::R16f;
}
if (image.GetDataFmt() == AmdGpu::DataFormat::Format16 &&
image.GetNumberFmt() == AmdGpu::NumberFormat::Uint) {
return spv::ImageFormat::R16ui;
}
if (image.GetDataFmt() == AmdGpu::DataFormat::Format16_16 &&
image.GetNumberFmt() == AmdGpu::NumberFormat::Float) {
return spv::ImageFormat::Rg16f;

View File

@ -329,6 +329,7 @@ std::span<const vk::Format> GetAllFormats() {
vk::Format::eR16G16Sint,
vk::Format::eR16G16Snorm,
vk::Format::eR16Sfloat,
vk::Format::eR16Uint,
vk::Format::eR16Unorm,
vk::Format::eR32G32B32A32Sfloat,
vk::Format::eR32G32B32A32Sint,