mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-04 16:32:39 +00:00
small corrections
This commit is contained in:
parent
0211fcb6b8
commit
00afb63313
@ -90,6 +90,11 @@ s32 PS4_SYSV_ABI scePngDecDecode(OrbisPngDecHandle handle, const OrbisPngDecDeco
|
|||||||
LOG_ERROR(Lib_Png, "invalid image address!");
|
LOG_ERROR(Lib_Png, "invalid image address!");
|
||||||
return ORBIS_PNG_DEC_ERROR_INVALID_ADDR;
|
return ORBIS_PNG_DEC_ERROR_INVALID_ADDR;
|
||||||
}
|
}
|
||||||
|
LOG_ERROR(Lib_Png,
|
||||||
|
"pngMemSize = {} , imageMemSize = {} , pixelFormat = {} , alphaValue = {} , "
|
||||||
|
"imagePitch = {}",
|
||||||
|
param->pngMemSize, param->imageMemSize, param->pixelFormat, param->alphaValue,
|
||||||
|
param->imagePitch);
|
||||||
|
|
||||||
auto pngh = (PngHandler*)handle;
|
auto pngh = (PngHandler*)handle;
|
||||||
|
|
||||||
@ -113,15 +118,15 @@ s32 PS4_SYSV_ABI scePngDecDecode(OrbisPngDecHandle handle, const OrbisPngDecDeco
|
|||||||
pngdata->offset += len;
|
pngdata->offset += len;
|
||||||
});
|
});
|
||||||
|
|
||||||
u32 weight, height;
|
u32 width, height;
|
||||||
int color_type, bit_depth, interlace_method;
|
int color_type, bit_depth, interlace_method;
|
||||||
png_read_info(pngh->png_ptr, pngh->info_ptr);
|
png_read_info(pngh->png_ptr, pngh->info_ptr);
|
||||||
png_get_IHDR(pngh->png_ptr, pngh->info_ptr, &weight, &height, &bit_depth, &color_type,
|
png_get_IHDR(pngh->png_ptr, pngh->info_ptr, &width, &height, &bit_depth, &color_type,
|
||||||
&interlace_method, nullptr, nullptr);
|
&interlace_method, nullptr, nullptr);
|
||||||
|
|
||||||
if (imageInfo != nullptr) {
|
if (imageInfo != nullptr) {
|
||||||
imageInfo->bitDepth = bit_depth;
|
imageInfo->bitDepth = bit_depth;
|
||||||
imageInfo->imageWidth = weight;
|
imageInfo->imageWidth = width;
|
||||||
imageInfo->imageHeight = height;
|
imageInfo->imageHeight = height;
|
||||||
imageInfo->colorSpace = MapPngColor(color_type);
|
imageInfo->colorSpace = MapPngColor(color_type);
|
||||||
imageInfo->imageFlag = 0;
|
imageInfo->imageFlag = 0;
|
||||||
@ -143,9 +148,9 @@ s32 PS4_SYSV_ABI scePngDecDecode(OrbisPngDecHandle handle, const OrbisPngDecDeco
|
|||||||
png_set_gray_to_rgb(pngh->png_ptr);
|
png_set_gray_to_rgb(pngh->png_ptr);
|
||||||
if (param->pixelFormat == OrbisPngDecPixelFormat::ORBIS_PNG_DEC_PIXEL_FORMAT_B8G8R8A8)
|
if (param->pixelFormat == OrbisPngDecPixelFormat::ORBIS_PNG_DEC_PIXEL_FORMAT_B8G8R8A8)
|
||||||
png_set_bgr(pngh->png_ptr);
|
png_set_bgr(pngh->png_ptr);
|
||||||
if (color_type == PNG_COLOR_TYPE_RGB || color_type == PNG_COLOR_TYPE_GRAY ||
|
//if (color_type == PNG_COLOR_TYPE_RGB || color_type == PNG_COLOR_TYPE_GRAY ||
|
||||||
color_type == PNG_COLOR_TYPE_PALETTE)
|
// color_type == PNG_COLOR_TYPE_PALETTE)
|
||||||
png_set_add_alpha(pngh->png_ptr, 0xFF, PNG_FILLER_AFTER);
|
// png_set_add_alpha(pngh->png_ptr, 0xFF, PNG_FILLER_AFTER);
|
||||||
png_read_update_info(pngh->png_ptr, pngh->info_ptr);
|
png_read_update_info(pngh->png_ptr, pngh->info_ptr);
|
||||||
|
|
||||||
png_bytep* row_pointers = NULL;
|
png_bytep* row_pointers = NULL;
|
||||||
@ -160,9 +165,9 @@ s32 PS4_SYSV_ABI scePngDecDecode(OrbisPngDecHandle handle, const OrbisPngDecDeco
|
|||||||
|
|
||||||
auto const numChannels = png_get_channels(pngh->png_ptr, pngh->info_ptr);
|
auto const numChannels = png_get_channels(pngh->png_ptr, pngh->info_ptr);
|
||||||
|
|
||||||
int stride = param->imagePitch > 0 ? (param->imagePitch - weight) : 0;
|
int stride = param->imagePitch > 0 ? (param->imagePitch - width) : 0;
|
||||||
for (int y = 0; y < height; y++) {
|
for (int y = 0; y < height; y++) {
|
||||||
for (int x = 0; x < numChannels * weight; x++) {
|
for (int x = 0; x < numChannels * width; x++) {
|
||||||
*ptr++ = row_pointers[y][x];
|
*ptr++ = row_pointers[y][x];
|
||||||
}
|
}
|
||||||
// ptr += stride;//doesn't work??
|
// ptr += stride;//doesn't work??
|
||||||
@ -170,7 +175,7 @@ s32 PS4_SYSV_ABI scePngDecDecode(OrbisPngDecHandle handle, const OrbisPngDecDeco
|
|||||||
}
|
}
|
||||||
png_free(pngh->png_ptr, row_pointers);
|
png_free(pngh->png_ptr, row_pointers);
|
||||||
|
|
||||||
return (weight > 32767 || height > 32767) ? 0 : ((u32)weight << 16) | (u32)height;
|
return (width > 32767 || height > 32767) ? 0 : ((u32)width << 16) | (u32)height;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 PS4_SYSV_ABI scePngDecDecodeWithInputControl() {
|
s32 PS4_SYSV_ABI scePngDecDecodeWithInputControl() {
|
||||||
|
109
src/main.cpp
109
src/main.cpp
@ -1,13 +1,7 @@
|
|||||||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
#include "functional"
|
|
||||||
#include "iostream"
|
|
||||||
#include "string"
|
|
||||||
#include "unordered_map"
|
|
||||||
|
|
||||||
#include <fmt/core.h>
|
#include <fmt/core.h>
|
||||||
#include "common/config.h"
|
|
||||||
#include "common/memory_patcher.h"
|
#include "common/memory_patcher.h"
|
||||||
#include "emulator.h"
|
#include "emulator.h"
|
||||||
|
|
||||||
@ -20,105 +14,26 @@ int main(int argc, char* argv[]) {
|
|||||||
SetConsoleOutputCP(CP_UTF8);
|
SetConsoleOutputCP(CP_UTF8);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool has_game_argument = false;
|
|
||||||
std::string game_path;
|
|
||||||
|
|
||||||
// Map of argument strings to lambda functions
|
|
||||||
std::unordered_map<std::string, std::function<void(int&)>> arg_map = {
|
|
||||||
{"-h",
|
|
||||||
[&](int&) {
|
|
||||||
std::cout << "Usage: shadps4 [options] <elf or eboot.bin path>\n"
|
|
||||||
"Options:\n"
|
|
||||||
" -g, --game <path|ID> Specify game path to launch\n"
|
|
||||||
" -p, --patch <patch_file> Apply specified patch file\n"
|
|
||||||
" -f, --fullscreen <true|false> Specify window initial fullscreen "
|
|
||||||
"state. Does not overwrite the config file."
|
|
||||||
" -h, --help Display this help message\n";
|
|
||||||
exit(0);
|
|
||||||
}},
|
|
||||||
{"--help", [&](int& i) { arg_map["-h"](i); }},
|
|
||||||
|
|
||||||
{"-g",
|
|
||||||
[&](int& i) {
|
|
||||||
if (i + 1 < argc) {
|
|
||||||
game_path = argv[++i];
|
|
||||||
has_game_argument = true;
|
|
||||||
} else {
|
|
||||||
std::cerr << "Error: Missing argument for -g/--game\n";
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}},
|
|
||||||
{"--game", [&](int& i) { arg_map["-g"](i); }},
|
|
||||||
|
|
||||||
{"-p",
|
|
||||||
[&](int& i) {
|
|
||||||
if (i + 1 < argc) {
|
|
||||||
MemoryPatcher::patchFile = argv[++i];
|
|
||||||
} else {
|
|
||||||
std::cerr << "Error: Missing argument for -p/--patch\n";
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}},
|
|
||||||
{"--patch", [&](int& i) { arg_map["-p"](i); }},
|
|
||||||
{"-f",
|
|
||||||
[&](int& i) {
|
|
||||||
if (++i >= argc) {
|
|
||||||
std::cerr << "Error: Missing argument for -f/--fullscreen\n";
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
std::string f_param(argv[i]);
|
|
||||||
bool is_fullscreen;
|
|
||||||
if (f_param == "true") {
|
|
||||||
is_fullscreen = true;
|
|
||||||
} else if (f_param == "false") {
|
|
||||||
is_fullscreen = false;
|
|
||||||
} else {
|
|
||||||
std::cerr
|
|
||||||
<< "Error: Invalid argument for -f/--fullscreen. Use 'true' or 'false'.\n";
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
// Set fullscreen mode without saving it to config file
|
|
||||||
Config::setFullscreenMode(is_fullscreen);
|
|
||||||
}},
|
|
||||||
{"--fullscreen", [&](int& i) { arg_map["-f"](i); }},
|
|
||||||
};
|
|
||||||
|
|
||||||
if (argc == 1) {
|
if (argc == 1) {
|
||||||
int dummy = 0; // one does not simply pass 0 directly
|
fmt::print("Usage: {} <elf or eboot.bin path>\n", argv[0]);
|
||||||
arg_map.at("-h")(dummy);
|
return -1;
|
||||||
|
}
|
||||||
|
// check if eboot file exists
|
||||||
|
if (!std::filesystem::exists(argv[1])) {
|
||||||
|
fmt::print("Eboot.bin file not found\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse command-line arguments using the map
|
for (int i = 0; i < argc; i++) {
|
||||||
for (int i = 1; i < argc; ++i) {
|
std::string curArg = argv[i];
|
||||||
std::string cur_arg = argv[i];
|
if (curArg == "-p") {
|
||||||
auto it = arg_map.find(cur_arg);
|
std::string patchFile = argv[i + 1];
|
||||||
if (it != arg_map.end()) {
|
MemoryPatcher::patchFile = patchFile;
|
||||||
it->second(i); // Call the associated lambda function
|
|
||||||
} else if (i == argc - 1 && !has_game_argument) {
|
|
||||||
// Assume the last argument is the game file if not specified via -g/--game
|
|
||||||
game_path = argv[i];
|
|
||||||
has_game_argument = true;
|
|
||||||
} else {
|
|
||||||
std::cerr << "Unknown argument: " << cur_arg << ", see --help for info.\n";
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!has_game_argument) {
|
|
||||||
std::cerr << "Error: Please provide a game path or ID.\n";
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if the game path or ID exists
|
|
||||||
if (!std::filesystem::exists(game_path)) {
|
|
||||||
std::cerr << "Error: Game file not found\n";
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Run the emulator with the specified game
|
|
||||||
Core::Emulator emulator;
|
Core::Emulator emulator;
|
||||||
emulator.Run(game_path);
|
emulator.Run(argv[1]);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user