mirror of
https://github.com/Vita3K/Vita3K.git
synced 2026-07-11 01:34:23 +02:00
vita3k: code cleanup and minor bugfixes
Fix bugs * gui/disassembly_dialog: fix bug. Can't enter addresses >= 0x80000000 * utils/vc_runtime_checker: fix almost impossible AV in vc_runtime_checker * util/net_utils: fix warning and error in parseHeaders function * patch: fix almost impossible bug, also drop unused var * modules/SceAvPlayer: fix error (wrong mutex) * kernel: more correct value of export variable __sce_libcparam (NID:0xDF084DFA) * interface.cpp/get_contents_path (Looks like mistype in duplicate search) Needs recheck of refactoring. I found something strange, but I'm not sure if it's intended or not. * renderer::vulkan/VKContext::VKContext (Looks like mistype in variable name) * spirv_recompiler/create_fragment_inputs (Variable anonimous is always false here. It's not static and reinit every loop iteration) * renderer/transfer: fix strange (and maybe never run) code if pixel format is unknown * renderer/vulkan/replacement: fix some type to type converson Refactoring and enhancements * codec/atrac9: better error logs * util/fs_utils: Function read_data which read file to vector. Also use it if possible * util/log: custom formatter for Ptr<> type (it simplifies logging) * util/tracy: set tracy_module_id variable static * util/warning.h : header to cross-platform disable warnings * renderer/transfer: fix strange (and maybe never run) code if pixel format is unknown * nids: typo fix * modules/module_parent: remove link to nids.inc from header * modules/module_parent: move macro to other such macros in bridge.h * kernel: refactoring use get_thread instead of lock_and_find * mem/ptr: set type Ptr<T> trivial (trivially copiable, movable and so on) Fix warnings: * some retype in BitmapAllocator (mem-tests are OK) * typecasts * remove unused variables and fields * push_back->emplace_back * rename duplicate variables (usually in nested loops) * drop excessive brackets * remove some unused includes * set 'static' for functions if possible * gui:home_screen/draw_home_screen: same values around ? operator. * convert declare SCE_*_ERROR_* to enums * bracket initialisation instead of memset * other compiler warnings
This commit is contained in:
@@ -157,7 +157,6 @@ static void gen_module_stubs(const Modules &modules) {
|
||||
|
||||
for (const Library &library : module.second) {
|
||||
const std::string library_cpp_path = module_path + "/" + library.first + ".cpp";
|
||||
const std::string library_h_path = module_path + "/" + library.first + ".h";
|
||||
std::ofstream library_cpp(library_cpp_path.c_str(), std::ios::binary);
|
||||
gen_library_cpp(library_cpp, library);
|
||||
}
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
|
||||
#include <renderer/functions.h>
|
||||
#include <util/fs.h>
|
||||
#include <util/lock_and_find.h>
|
||||
#include <util/log.h>
|
||||
#include <util/string_utils.h>
|
||||
|
||||
@@ -481,7 +480,7 @@ bool late_init(EmuEnvState &state) {
|
||||
LOG_CRITICAL("Unicorn backend is not supported with a page table");
|
||||
|
||||
const ResumeAudioThread resume_thread = [&state](SceUID thread_id) {
|
||||
const auto thread = lock_and_find(thread_id, state.kernel.threads, state.kernel.mutex);
|
||||
const auto thread = state.kernel.get_thread(thread_id);
|
||||
const std::lock_guard<std::mutex> lock(thread->mutex);
|
||||
if (thread->status == ThreadStatus::wait) {
|
||||
thread->update_status(ThreadStatus::run);
|
||||
|
||||
@@ -157,7 +157,7 @@ void CubebAudioAdapter::set_volume(AudioOutPort &out_port, float volume) {
|
||||
}
|
||||
|
||||
void CubebAudioAdapter::switch_state(const bool pause) {
|
||||
for (auto [_, out_port] : state.out_ports) {
|
||||
for (auto &[_, out_port] : state.out_ports) {
|
||||
CubebAudioOutPort &port = static_cast<CubebAudioOutPort &>(*out_port);
|
||||
if (pause)
|
||||
cubeb_stream_stop(port.out_stream);
|
||||
|
||||
@@ -130,7 +130,7 @@ Atrac9DecoderState::Atrac9DecoderState(uint32_t config_data)
|
||||
const int err = Atrac9InitDecoder(decoder_handle, reinterpret_cast<uint8_t *>(&config_data));
|
||||
|
||||
if (err != At9Status::ERR_SUCCESS) {
|
||||
LOG_ERROR("Error initializing decoder");
|
||||
LOG_ERROR("Error initializing decoder. Error code: {}", log_hex(err));
|
||||
}
|
||||
|
||||
Atrac9CodecInfo *info = new Atrac9CodecInfo;
|
||||
|
||||
@@ -26,26 +26,26 @@ extern "C" {
|
||||
#include <cassert>
|
||||
|
||||
void copy_yuv_data_from_frame(AVFrame *frame, uint8_t *dest, const uint32_t width, const uint32_t height, bool is_p3) {
|
||||
for (uint32_t i = 0; i < height; i++) {
|
||||
for (size_t i = 0; i < height; i++) {
|
||||
memcpy(dest, &frame->data[0][frame->linesize[0] * i], width);
|
||||
dest += width;
|
||||
}
|
||||
|
||||
if (is_p3) {
|
||||
for (uint32_t i = 0; i < height / 2; i++) {
|
||||
for (size_t i = 0; i < height / 2; i++) {
|
||||
memcpy(dest, &frame->data[1][frame->linesize[1] * i], width / 2);
|
||||
dest += width / 2;
|
||||
}
|
||||
for (uint32_t i = 0; i < height / 2; i++) {
|
||||
for (size_t i = 0; i < height / 2; i++) {
|
||||
memcpy(dest, &frame->data[2][frame->linesize[2] * i], width / 2);
|
||||
dest += width / 2;
|
||||
}
|
||||
} else {
|
||||
// p2 format, U and V are interleaved
|
||||
for (uint32_t i = 0; i < height / 2; i++) {
|
||||
for (size_t i = 0; i < height / 2; i++) {
|
||||
const uint8_t *src_u = &frame->data[1][frame->linesize[1] * i];
|
||||
const uint8_t *src_v = &frame->data[2][frame->linesize[2] * i];
|
||||
for (uint32_t j = 0; j < width / 2; j++) {
|
||||
for (size_t j = 0; j < width / 2; j++) {
|
||||
dest[0] = src_u[j];
|
||||
dest[1] = src_v[j];
|
||||
dest += 2;
|
||||
|
||||
@@ -31,25 +31,17 @@ extern "C" {
|
||||
|
||||
void convert_yuv_to_rgb(const uint8_t *yuv, uint8_t *rgba, uint32_t frame_width, const DecoderColorSpace color_space, const bool is_bgra, MJpegPitch pitch[4]) {
|
||||
AVPixelFormat format = AV_PIX_FMT_YUVJ444P;
|
||||
int strides_divisor = 1;
|
||||
int slice_position = 8;
|
||||
int width = pitch[0].x, height = pitch[0].y;
|
||||
|
||||
switch (color_space) {
|
||||
case COLORSPACE_YUV444P:
|
||||
format = AV_PIX_FMT_YUV444P;
|
||||
strides_divisor = 1;
|
||||
slice_position = 8; // 2
|
||||
break;
|
||||
case COLORSPACE_YUV422P:
|
||||
format = AV_PIX_FMT_YUV422P;
|
||||
strides_divisor = 2;
|
||||
slice_position = 6; // 1.5
|
||||
break;
|
||||
case COLORSPACE_YUV420P:
|
||||
format = AV_PIX_FMT_YUV420P;
|
||||
strides_divisor = 2;
|
||||
slice_position = 5; // 1.25
|
||||
break;
|
||||
default:
|
||||
LOG_WARN("An attempt was made to use an unsupported color space.");
|
||||
@@ -139,7 +131,7 @@ void convert_rgb_to_yuv(const uint8_t *rgba, uint8_t *yuv, uint32_t width, uint3
|
||||
assert(error == height);
|
||||
}
|
||||
|
||||
AVPixelFormat colorspace_to_av_pixel_format(DecoderColorSpace color_space) {
|
||||
static AVPixelFormat colorspace_to_av_pixel_format(DecoderColorSpace color_space) {
|
||||
switch (color_space) {
|
||||
case COLORSPACE_YUV444P:
|
||||
return AV_PIX_FMT_YUVJ444P;
|
||||
@@ -162,7 +154,7 @@ AVPixelFormat colorspace_to_av_pixel_format(DecoderColorSpace color_space) {
|
||||
}
|
||||
}
|
||||
|
||||
DecoderColorSpace av_pixel_format_to_colorspace(AVPixelFormat format) {
|
||||
static DecoderColorSpace av_pixel_format_to_colorspace(AVPixelFormat format) {
|
||||
switch (format) {
|
||||
case AV_PIX_FMT_YUVJ444P:
|
||||
return COLORSPACE_YUV444P;
|
||||
|
||||
@@ -87,7 +87,7 @@ const uint16_t mpeg_frame_samples[4][4] = {
|
||||
// Slot size (MPEG unit of measurement) - use [layer]
|
||||
const uint8_t mpeg_slot_size[4] = { 0, 1, 1, 4 }; // Rsvd, 3, 2, 1
|
||||
|
||||
uint32_t get_mp3_data_size(const uint8_t *data) {
|
||||
static uint32_t get_mp3_data_size(const uint8_t *data) {
|
||||
// Quick validity check
|
||||
if (((data[0] & 0xFF) != 0xFF)
|
||||
|| ((data[1] & 0xE0) != 0xE0) // 3 sync bits
|
||||
|
||||
@@ -220,13 +220,13 @@ bool PCMDecoderState::send(const uint8_t *data, uint32_t size) {
|
||||
|
||||
shift_factor = 20 - shift_factor;
|
||||
|
||||
for (std::uint32_t i = 0; i < samples_per_frame; i++) {
|
||||
for (std::uint32_t j = 0; j < samples_per_frame; j++) {
|
||||
int32_t sample = 0;
|
||||
|
||||
if (flag < 0x07) { /* with flag 0x07 decoded sample must be 0 */
|
||||
uint8_t nibbles = frame[0x02 + i / 2];
|
||||
uint8_t nibbles = frame[0x02 + j / 2];
|
||||
|
||||
sample = (i & 1 ? /* low nibble first */
|
||||
sample = (j & 1 ? /* low nibble first */
|
||||
nibble_lookup[nibbles >> 4]
|
||||
: nibble_lookup[nibbles & 0xF])
|
||||
<< shift_factor; /*scale*/
|
||||
@@ -235,7 +235,7 @@ bool PCMDecoderState::send(const uint8_t *data, uint32_t size) {
|
||||
}
|
||||
|
||||
// Multichannel interleaving
|
||||
buffer[i * src_ch + ch] = static_cast<std::int16_t>(std::clamp(sample, -32768, 32767));
|
||||
buffer[j * src_ch + ch] = static_cast<std::int16_t>(std::clamp(sample, -32768, 32767));
|
||||
|
||||
hist4 = hist3;
|
||||
hist3 = hist2;
|
||||
|
||||
@@ -44,16 +44,7 @@ struct Compatibility {
|
||||
struct CompatState {
|
||||
bool compat_db_loaded = false;
|
||||
std::map<std::string, Compatibility> app_compat_db;
|
||||
std::map<CompatibilityState, ImVec4> compat_color{
|
||||
{ UNKNOWN, ImVec4(0.54f, 0.54f, 0.54f, 1.f) },
|
||||
{ NOTHING, ImVec4(1.00f, 0.00f, 0.00f, 1.f) }, // #ff0000
|
||||
{ BOOTABLE, ImVec4(0.39f, 0.12f, 0.62f, 1.f) }, // #621fa5
|
||||
{ INTRO, ImVec4(0.77f, 0.08f, 0.52f, 1.f) }, // #c71585
|
||||
{ MENU, ImVec4(0.11f, 0.46f, 0.85f, 1.f) }, // #1d76db
|
||||
{ INGAME_LESS, ImVec4(0.88f, 0.54f, 0.12f, 1.f) }, // #e08a1e
|
||||
{ INGAME_MORE, ImVec4(1.00f, 0.84f, 0.00f, 1.f) }, // #ffd700
|
||||
{ PLAYABLE, ImVec4(0.05f, 0.54f, 0.09f, 1.f) }, // #0e8a16
|
||||
};
|
||||
static std::map<CompatibilityState, ImVec4> compat_color;
|
||||
};
|
||||
|
||||
} // namespace compat
|
||||
|
||||
@@ -45,10 +45,20 @@ static std::string db_updated_at;
|
||||
static const uint32_t db_version = 1;
|
||||
static uint32_t db_issue_count = 0;
|
||||
|
||||
bool extract_zip_file(const char *zip_filename, const fs::path &output_path) {
|
||||
std::map<CompatibilityState, ImVec4> CompatState::compat_color{
|
||||
{ UNKNOWN, ImVec4(0.54f, 0.54f, 0.54f, 1.f) },
|
||||
{ NOTHING, ImVec4(1.00f, 0.00f, 0.00f, 1.f) }, // #ff0000
|
||||
{ BOOTABLE, ImVec4(0.39f, 0.12f, 0.62f, 1.f) }, // #621fa5
|
||||
{ INTRO, ImVec4(0.77f, 0.08f, 0.52f, 1.f) }, // #c71585
|
||||
{ MENU, ImVec4(0.11f, 0.46f, 0.85f, 1.f) }, // #1d76db
|
||||
{ INGAME_LESS, ImVec4(0.88f, 0.54f, 0.12f, 1.f) }, // #e08a1e
|
||||
{ INGAME_MORE, ImVec4(1.00f, 0.84f, 0.00f, 1.f) }, // #ffd700
|
||||
{ PLAYABLE, ImVec4(0.05f, 0.54f, 0.09f, 1.f) }, // #0e8a16
|
||||
};
|
||||
|
||||
static bool extract_zip_file(const char *zip_filename, const fs::path &output_path) {
|
||||
// Open the ZIP file for reading
|
||||
mz_zip_archive zip_archive;
|
||||
memset(&zip_archive, 0, sizeof(zip_archive));
|
||||
mz_zip_archive zip_archive{};
|
||||
if (!mz_zip_reader_init_file(&zip_archive, zip_filename, 0)) {
|
||||
LOG_ERROR("Failed to initialize ZIP archive for reading");
|
||||
return false;
|
||||
|
||||
@@ -18,10 +18,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <dynarmic/interface/A32/a32.h>
|
||||
#include <dynarmic/interface/exclusive_monitor.h>
|
||||
|
||||
#include <cpu/functions.h>
|
||||
#include <cpu/impl/unicorn_cpu.h>
|
||||
#include <cpu/impl/interface.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
|
||||
@@ -67,5 +67,5 @@ std::string disassemble(DisasmState &state, const uint8_t *code, size_t size, ui
|
||||
}
|
||||
|
||||
bool is_returning(DisasmState &state) {
|
||||
return std::string(state.insn->mnemonic).rfind("pop", 0) == 0;
|
||||
return std::string_view(state.insn->mnemonic).starts_with("pop");
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
|
||||
#include <dynarmic/frontend/A32/a32_ir_emitter.h>
|
||||
#include <dynarmic/interface/A32/coprocessor.h>
|
||||
#include <dynarmic/interface/exclusive_monitor.h>
|
||||
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
|
||||
+28
-28
@@ -202,39 +202,39 @@ static uint8_t float_to_byte(float f) {
|
||||
|
||||
static std::array<ControllerBinding, 13> get_controller_bindings(EmuEnvState &emuenv) {
|
||||
return { {
|
||||
{ SDL_GameControllerButton(emuenv.cfg.controller_binds[SDL_CONTROLLER_BUTTON_BACK]), SCE_CTRL_SELECT },
|
||||
{ SDL_GameControllerButton(emuenv.cfg.controller_binds[SDL_CONTROLLER_BUTTON_START]), SCE_CTRL_START },
|
||||
{ SDL_GameControllerButton(emuenv.cfg.controller_binds[SDL_CONTROLLER_BUTTON_DPAD_UP]), SCE_CTRL_UP },
|
||||
{ SDL_GameControllerButton(emuenv.cfg.controller_binds[SDL_CONTROLLER_BUTTON_DPAD_RIGHT]), SCE_CTRL_RIGHT },
|
||||
{ SDL_GameControllerButton(emuenv.cfg.controller_binds[SDL_CONTROLLER_BUTTON_DPAD_DOWN]), SCE_CTRL_DOWN },
|
||||
{ SDL_GameControllerButton(emuenv.cfg.controller_binds[SDL_CONTROLLER_BUTTON_DPAD_LEFT]), SCE_CTRL_LEFT },
|
||||
{ SDL_GameControllerButton(emuenv.cfg.controller_binds[SDL_CONTROLLER_BUTTON_LEFTSHOULDER]), SCE_CTRL_L },
|
||||
{ SDL_GameControllerButton(emuenv.cfg.controller_binds[SDL_CONTROLLER_BUTTON_RIGHTSHOULDER]), SCE_CTRL_R },
|
||||
{ SDL_GameControllerButton(emuenv.cfg.controller_binds[SDL_CONTROLLER_BUTTON_Y]), SCE_CTRL_TRIANGLE },
|
||||
{ SDL_GameControllerButton(emuenv.cfg.controller_binds[SDL_CONTROLLER_BUTTON_B]), SCE_CTRL_CIRCLE },
|
||||
{ SDL_GameControllerButton(emuenv.cfg.controller_binds[SDL_CONTROLLER_BUTTON_A]), SCE_CTRL_CROSS },
|
||||
{ SDL_GameControllerButton(emuenv.cfg.controller_binds[SDL_CONTROLLER_BUTTON_X]), SCE_CTRL_SQUARE },
|
||||
{ SDL_GameControllerButton(emuenv.cfg.controller_binds[SDL_CONTROLLER_BUTTON_GUIDE]), SCE_CTRL_PSBUTTON },
|
||||
{ static_cast<SDL_GameControllerButton>(emuenv.cfg.controller_binds[SDL_CONTROLLER_BUTTON_BACK]), SCE_CTRL_SELECT },
|
||||
{ static_cast<SDL_GameControllerButton>(emuenv.cfg.controller_binds[SDL_CONTROLLER_BUTTON_START]), SCE_CTRL_START },
|
||||
{ static_cast<SDL_GameControllerButton>(emuenv.cfg.controller_binds[SDL_CONTROLLER_BUTTON_DPAD_UP]), SCE_CTRL_UP },
|
||||
{ static_cast<SDL_GameControllerButton>(emuenv.cfg.controller_binds[SDL_CONTROLLER_BUTTON_DPAD_RIGHT]), SCE_CTRL_RIGHT },
|
||||
{ static_cast<SDL_GameControllerButton>(emuenv.cfg.controller_binds[SDL_CONTROLLER_BUTTON_DPAD_DOWN]), SCE_CTRL_DOWN },
|
||||
{ static_cast<SDL_GameControllerButton>(emuenv.cfg.controller_binds[SDL_CONTROLLER_BUTTON_DPAD_LEFT]), SCE_CTRL_LEFT },
|
||||
{ static_cast<SDL_GameControllerButton>(emuenv.cfg.controller_binds[SDL_CONTROLLER_BUTTON_LEFTSHOULDER]), SCE_CTRL_L },
|
||||
{ static_cast<SDL_GameControllerButton>(emuenv.cfg.controller_binds[SDL_CONTROLLER_BUTTON_RIGHTSHOULDER]), SCE_CTRL_R },
|
||||
{ static_cast<SDL_GameControllerButton>(emuenv.cfg.controller_binds[SDL_CONTROLLER_BUTTON_Y]), SCE_CTRL_TRIANGLE },
|
||||
{ static_cast<SDL_GameControllerButton>(emuenv.cfg.controller_binds[SDL_CONTROLLER_BUTTON_B]), SCE_CTRL_CIRCLE },
|
||||
{ static_cast<SDL_GameControllerButton>(emuenv.cfg.controller_binds[SDL_CONTROLLER_BUTTON_A]), SCE_CTRL_CROSS },
|
||||
{ static_cast<SDL_GameControllerButton>(emuenv.cfg.controller_binds[SDL_CONTROLLER_BUTTON_X]), SCE_CTRL_SQUARE },
|
||||
{ static_cast<SDL_GameControllerButton>(emuenv.cfg.controller_binds[SDL_CONTROLLER_BUTTON_GUIDE]), SCE_CTRL_PSBUTTON },
|
||||
} };
|
||||
}
|
||||
|
||||
std::array<ControllerBinding, 15> get_controller_bindings_ext(EmuEnvState &emuenv) {
|
||||
return { {
|
||||
{ SDL_GameControllerButton(emuenv.cfg.controller_binds[SDL_CONTROLLER_BUTTON_BACK]), SCE_CTRL_SELECT },
|
||||
{ SDL_GameControllerButton(emuenv.cfg.controller_binds[SDL_CONTROLLER_BUTTON_LEFTSTICK]), SCE_CTRL_L3 },
|
||||
{ SDL_GameControllerButton(emuenv.cfg.controller_binds[SDL_CONTROLLER_BUTTON_RIGHTSTICK]), SCE_CTRL_R3 },
|
||||
{ SDL_GameControllerButton(emuenv.cfg.controller_binds[SDL_CONTROLLER_BUTTON_START]), SCE_CTRL_START },
|
||||
{ SDL_GameControllerButton(emuenv.cfg.controller_binds[SDL_CONTROLLER_BUTTON_DPAD_UP]), SCE_CTRL_UP },
|
||||
{ SDL_GameControllerButton(emuenv.cfg.controller_binds[SDL_CONTROLLER_BUTTON_DPAD_RIGHT]), SCE_CTRL_RIGHT },
|
||||
{ SDL_GameControllerButton(emuenv.cfg.controller_binds[SDL_CONTROLLER_BUTTON_DPAD_DOWN]), SCE_CTRL_DOWN },
|
||||
{ SDL_GameControllerButton(emuenv.cfg.controller_binds[SDL_CONTROLLER_BUTTON_DPAD_LEFT]), SCE_CTRL_LEFT },
|
||||
{ SDL_GameControllerButton(emuenv.cfg.controller_binds[SDL_CONTROLLER_BUTTON_LEFTSHOULDER]), SCE_CTRL_L1 },
|
||||
{ SDL_GameControllerButton(emuenv.cfg.controller_binds[SDL_CONTROLLER_BUTTON_RIGHTSHOULDER]), SCE_CTRL_R1 },
|
||||
{ SDL_GameControllerButton(emuenv.cfg.controller_binds[SDL_CONTROLLER_BUTTON_Y]), SCE_CTRL_TRIANGLE },
|
||||
{ SDL_GameControllerButton(emuenv.cfg.controller_binds[SDL_CONTROLLER_BUTTON_B]), SCE_CTRL_CIRCLE },
|
||||
{ SDL_GameControllerButton(emuenv.cfg.controller_binds[SDL_CONTROLLER_BUTTON_A]), SCE_CTRL_CROSS },
|
||||
{ SDL_GameControllerButton(emuenv.cfg.controller_binds[SDL_CONTROLLER_BUTTON_X]), SCE_CTRL_SQUARE },
|
||||
{ SDL_GameControllerButton(emuenv.cfg.controller_binds[SDL_CONTROLLER_BUTTON_GUIDE]), SCE_CTRL_PSBUTTON },
|
||||
{ static_cast<SDL_GameControllerButton>(emuenv.cfg.controller_binds[SDL_CONTROLLER_BUTTON_BACK]), SCE_CTRL_SELECT },
|
||||
{ static_cast<SDL_GameControllerButton>(emuenv.cfg.controller_binds[SDL_CONTROLLER_BUTTON_LEFTSTICK]), SCE_CTRL_L3 },
|
||||
{ static_cast<SDL_GameControllerButton>(emuenv.cfg.controller_binds[SDL_CONTROLLER_BUTTON_RIGHTSTICK]), SCE_CTRL_R3 },
|
||||
{ static_cast<SDL_GameControllerButton>(emuenv.cfg.controller_binds[SDL_CONTROLLER_BUTTON_START]), SCE_CTRL_START },
|
||||
{ static_cast<SDL_GameControllerButton>(emuenv.cfg.controller_binds[SDL_CONTROLLER_BUTTON_DPAD_UP]), SCE_CTRL_UP },
|
||||
{ static_cast<SDL_GameControllerButton>(emuenv.cfg.controller_binds[SDL_CONTROLLER_BUTTON_DPAD_RIGHT]), SCE_CTRL_RIGHT },
|
||||
{ static_cast<SDL_GameControllerButton>(emuenv.cfg.controller_binds[SDL_CONTROLLER_BUTTON_DPAD_DOWN]), SCE_CTRL_DOWN },
|
||||
{ static_cast<SDL_GameControllerButton>(emuenv.cfg.controller_binds[SDL_CONTROLLER_BUTTON_DPAD_LEFT]), SCE_CTRL_LEFT },
|
||||
{ static_cast<SDL_GameControllerButton>(emuenv.cfg.controller_binds[SDL_CONTROLLER_BUTTON_LEFTSHOULDER]), SCE_CTRL_L1 },
|
||||
{ static_cast<SDL_GameControllerButton>(emuenv.cfg.controller_binds[SDL_CONTROLLER_BUTTON_RIGHTSHOULDER]), SCE_CTRL_R1 },
|
||||
{ static_cast<SDL_GameControllerButton>(emuenv.cfg.controller_binds[SDL_CONTROLLER_BUTTON_Y]), SCE_CTRL_TRIANGLE },
|
||||
{ static_cast<SDL_GameControllerButton>(emuenv.cfg.controller_binds[SDL_CONTROLLER_BUTTON_B]), SCE_CTRL_CIRCLE },
|
||||
{ static_cast<SDL_GameControllerButton>(emuenv.cfg.controller_binds[SDL_CONTROLLER_BUTTON_A]), SCE_CTRL_CROSS },
|
||||
{ static_cast<SDL_GameControllerButton>(emuenv.cfg.controller_binds[SDL_CONTROLLER_BUTTON_X]), SCE_CTRL_SQUARE },
|
||||
{ static_cast<SDL_GameControllerButton>(emuenv.cfg.controller_binds[SDL_CONTROLLER_BUTTON_GUIDE]), SCE_CTRL_PSBUTTON },
|
||||
} };
|
||||
}
|
||||
|
||||
|
||||
@@ -40,8 +40,11 @@
|
||||
|
||||
#include <gdbstub/state.h>
|
||||
|
||||
#include <util/warning.h>
|
||||
|
||||
// initialize the unique_ptr then the reference each time
|
||||
// this is VERY repetitive
|
||||
DISABLE_WARNING_BEGIN(5038, "-Wreorder-ctor")
|
||||
EmuEnvState::EmuEnvState()
|
||||
: _app_info(new sfo::SfoAppInfo)
|
||||
, app_info(*_app_info)
|
||||
@@ -88,6 +91,7 @@ EmuEnvState::EmuEnvState()
|
||||
, _http(new HTTPState)
|
||||
, http(*_http) {
|
||||
}
|
||||
DISABLE_WARNING_END;
|
||||
|
||||
// this is necessary to forward declare unique_ptrs (so that they can call the appropriate destructor)
|
||||
EmuEnvState::~EmuEnvState() = default;
|
||||
|
||||
@@ -683,18 +683,6 @@ const static PacketFunctionBundle functions[] = {
|
||||
{ "S", cmd_deprecated },
|
||||
};
|
||||
|
||||
template <class T, class U>
|
||||
constexpr bool cmp_less(T t, U u) noexcept {
|
||||
using UT = std::make_unsigned_t<T>;
|
||||
using UU = std::make_unsigned_t<U>;
|
||||
if constexpr (std::is_signed_v<T> == std::is_signed_v<U>)
|
||||
return t < u;
|
||||
else if constexpr (std::is_signed_v<T>)
|
||||
return t < 0 || UT(t) < u;
|
||||
else
|
||||
return u > 0 && t < UU(u);
|
||||
}
|
||||
|
||||
static bool command_begins_with(PacketCommand &command, const std::string_view small_str) {
|
||||
// If the command's content is shorter than small_str, it can't match
|
||||
if (static_cast<size_t>(command.content_length) < small_str.size())
|
||||
|
||||
@@ -38,58 +38,54 @@ UniqueGLObject gl::load_shaders(const fs::path &vertex_file_path, const fs::path
|
||||
GLuint fs = glCreateShader(GL_FRAGMENT_SHADER);
|
||||
|
||||
// Read the vertex/fragment shader code from files
|
||||
std::string vs_code;
|
||||
fs::ifstream vs_stream(vertex_file_path, std::ios::in);
|
||||
if (vs_stream.is_open()) {
|
||||
std::stringstream sstr;
|
||||
sstr << vs_stream.rdbuf();
|
||||
vs_code = sstr.str();
|
||||
vs_stream.close();
|
||||
} else {
|
||||
std::vector<char> vs_code;
|
||||
auto res = fs_utils::read_data(vertex_file_path, vs_code);
|
||||
if (!res) {
|
||||
LOG_ERROR("Couldn't open shader: {}", vertex_file_path);
|
||||
return UniqueGLObject();
|
||||
return {};
|
||||
}
|
||||
vs_code.push_back('\0');
|
||||
|
||||
std::string fs_code;
|
||||
fs::ifstream fs_stream(fragment_file_path, std::ios::in);
|
||||
if (fs_stream.is_open()) {
|
||||
std::stringstream sstr;
|
||||
sstr << fs_stream.rdbuf();
|
||||
fs_code = sstr.str();
|
||||
fs_stream.close();
|
||||
std::vector<char> fs_code;
|
||||
res = fs_utils::read_data(fragment_file_path, fs_code);
|
||||
if (!res) {
|
||||
LOG_ERROR("Couldn't open shader: {}", fragment_file_path);
|
||||
return {};
|
||||
}
|
||||
fs_code.push_back('\0');
|
||||
|
||||
GLint result = 0;
|
||||
int info_log_length;
|
||||
|
||||
// Compile vertex shader
|
||||
char const *vs_source_pointer = vs_code.c_str();
|
||||
glShaderSource(vs, 1, &vs_source_pointer, NULL);
|
||||
char const *vs_source_pointer = vs_code.data();
|
||||
glShaderSource(vs, 1, &vs_source_pointer, nullptr);
|
||||
glCompileShader(vs);
|
||||
|
||||
// Check vertex shader
|
||||
glGetShaderiv(vs, GL_COMPILE_STATUS, &result);
|
||||
glGetShaderiv(vs, GL_INFO_LOG_LENGTH, &info_log_length);
|
||||
if (!result) {
|
||||
int info_log_length;
|
||||
glGetShaderiv(vs, GL_INFO_LOG_LENGTH, &info_log_length);
|
||||
std::vector<char> vertex_shader_error_message(info_log_length + 1);
|
||||
glGetShaderInfoLog(vs, info_log_length, NULL, &vertex_shader_error_message[0]);
|
||||
LOG_ERROR("Error compiling vertex shader: {}\n", &vertex_shader_error_message[0]);
|
||||
return UniqueGLObject();
|
||||
glGetShaderInfoLog(vs, info_log_length, nullptr, vertex_shader_error_message.data());
|
||||
LOG_ERROR("Error compiling vertex shader: {}\n", vertex_shader_error_message.data());
|
||||
return {};
|
||||
}
|
||||
|
||||
// Compile fragment shader
|
||||
char const *fs_source_pointer = fs_code.c_str();
|
||||
glShaderSource(fs, 1, &fs_source_pointer, NULL);
|
||||
char const *fs_source_pointer = fs_code.data();
|
||||
glShaderSource(fs, 1, &fs_source_pointer, nullptr);
|
||||
glCompileShader(fs);
|
||||
|
||||
// Check fragment shader
|
||||
glGetShaderiv(fs, GL_COMPILE_STATUS, &result);
|
||||
glGetShaderiv(fs, GL_INFO_LOG_LENGTH, &info_log_length);
|
||||
if (!result) {
|
||||
int info_log_length;
|
||||
glGetShaderiv(fs, GL_INFO_LOG_LENGTH, &info_log_length);
|
||||
std::vector<char> fragment_shader_error_message(info_log_length + 1);
|
||||
glGetShaderInfoLog(fs, info_log_length, NULL, &fragment_shader_error_message[0]);
|
||||
LOG_ERROR("Error compiling fragment shader: {}\n", &fragment_shader_error_message[0]);
|
||||
return UniqueGLObject();
|
||||
glGetShaderInfoLog(fs, info_log_length, nullptr, fragment_shader_error_message.data());
|
||||
LOG_ERROR("Error compiling fragment shader: {}\n", fragment_shader_error_message.data());
|
||||
return {};
|
||||
}
|
||||
|
||||
// Link the program
|
||||
@@ -100,12 +96,13 @@ UniqueGLObject gl::load_shaders(const fs::path &vertex_file_path, const fs::path
|
||||
|
||||
// Check the program
|
||||
glGetProgramiv(program, GL_LINK_STATUS, &result);
|
||||
glGetProgramiv(program, GL_INFO_LOG_LENGTH, &info_log_length);
|
||||
if (!result) {
|
||||
int info_log_length;
|
||||
glGetProgramiv(program, GL_INFO_LOG_LENGTH, &info_log_length);
|
||||
std::vector<char> program_error_message(info_log_length + 1);
|
||||
glGetProgramInfoLog(program, info_log_length, NULL, &program_error_message[0]);
|
||||
LOG_ERROR("Error linking shader program: {}\n", &program_error_message[0]);
|
||||
return UniqueGLObject();
|
||||
glGetProgramInfoLog(program, info_log_length, nullptr, program_error_message.data());
|
||||
LOG_ERROR("Error linking shader program: {}\n", program_error_message.data());
|
||||
return {};
|
||||
}
|
||||
|
||||
glDetachShader(program, vs);
|
||||
@@ -116,7 +113,7 @@ UniqueGLObject gl::load_shaders(const fs::path &vertex_file_path, const fs::path
|
||||
|
||||
UniqueGLObject program_ptr = std::make_unique<GLObject>();
|
||||
if (!program_ptr->init(program, glDeleteProgram)) {
|
||||
return UniqueGLObject();
|
||||
return {};
|
||||
}
|
||||
|
||||
return program_ptr;
|
||||
|
||||
@@ -17,8 +17,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <imgui.h>
|
||||
|
||||
#include <emuenv/window.h>
|
||||
#include <gui/imgui_impl_sdl_state.h>
|
||||
|
||||
|
||||
@@ -14,8 +14,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <imgui.h>
|
||||
|
||||
#include <gui/imgui_impl_sdl_state.h>
|
||||
#include <renderer/gl/state.h>
|
||||
|
||||
|
||||
@@ -33,19 +33,17 @@ struct ImGui_State {
|
||||
renderer::State *renderer{};
|
||||
|
||||
uint64_t time = 0;
|
||||
int mouse_buttons_down;
|
||||
SDL_Cursor *mouse_cursors[ImGuiMouseCursor_COUNT];
|
||||
int pending_mouse_leave_frame;
|
||||
bool mouse_can_use_global_state;
|
||||
int mouse_buttons_down = 0;
|
||||
SDL_Cursor *mouse_cursors[ImGuiMouseCursor_COUNT] = {};
|
||||
int pending_mouse_leave_frame = 0;
|
||||
bool mouse_can_use_global_state = false;
|
||||
|
||||
bool init = false;
|
||||
bool is_typing;
|
||||
bool is_typing = false;
|
||||
bool do_clear_screen = true;
|
||||
|
||||
ImGui_State() {
|
||||
memset((void *)this, 0, sizeof(*this));
|
||||
do_clear_screen = true;
|
||||
}
|
||||
ImGui_State() = default;
|
||||
|
||||
virtual ~ImGui_State() = default;
|
||||
};
|
||||
|
||||
|
||||
@@ -25,8 +25,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <imgui.h>
|
||||
|
||||
#include <emuenv/window.h>
|
||||
#include <gui/imgui_impl_sdl_state.h>
|
||||
#include <renderer/vulkan/state.h>
|
||||
|
||||
@@ -246,12 +246,11 @@ struct InfoMessage {
|
||||
|
||||
// 2.f is enough for the current font size.
|
||||
const float FontScaleCandidates[] = { 1.f, 1.5f, 2.f };
|
||||
const int FontScaleCandidatesSize = sizeof(FontScaleCandidates) / sizeof(FontScaleCandidates[0]);
|
||||
const int FontScaleCandidatesSize = std::size(FontScaleCandidates);
|
||||
|
||||
struct GuiState {
|
||||
std::unique_ptr<ImGui_State> imgui_state;
|
||||
|
||||
bool renderer_focused = true;
|
||||
gui::FileMenuState file_menu;
|
||||
gui::DebugMenuState debug_menu;
|
||||
gui::ConfigurationMenuState configuration_menu;
|
||||
|
||||
@@ -134,6 +134,7 @@ void get_time_apps(GuiState &gui, EmuEnvState &emuenv) {
|
||||
for (const auto &user : time_child) {
|
||||
auto user_id = user.attribute("id").as_string();
|
||||
for (const auto &app : user)
|
||||
// Can't use emplace_back due to Clang 15 for macos
|
||||
gui.time_apps[user_id].push_back({ app.text().as_string(), app.attribute("last-time-used").as_llong(), app.attribute("time-used").as_llong() });
|
||||
}
|
||||
}
|
||||
@@ -186,7 +187,7 @@ void update_last_time_app_used(GuiState &gui, EmuEnvState &emuenv, const std::st
|
||||
const auto &time_app_index = get_time_app_index(gui, emuenv, app);
|
||||
if (time_app_index != gui.time_apps[emuenv.io.user_id].end())
|
||||
time_app_index->last_time_used = std::time(nullptr);
|
||||
else
|
||||
else // Can't use emplace_back due to Clang 15 for macos
|
||||
gui.time_apps[emuenv.io.user_id].push_back({ app, std::time(nullptr), 0 });
|
||||
|
||||
get_app_index(gui, app)->last_time = std::time(nullptr);
|
||||
@@ -275,9 +276,9 @@ void open_path(const std::string &path) {
|
||||
}
|
||||
}
|
||||
|
||||
static std::string context_dialog;
|
||||
|
||||
void draw_app_context_menu(GuiState &gui, EmuEnvState &emuenv, const std::string &app_path) {
|
||||
static std::string context_dialog;
|
||||
|
||||
const auto APP_INDEX = get_app_index(gui, app_path);
|
||||
const auto &title_id = APP_INDEX->title_id;
|
||||
|
||||
@@ -623,7 +624,7 @@ void draw_app_context_menu(GuiState &gui, EmuEnvState &emuenv, const std::string
|
||||
ImGui::SameLine();
|
||||
ImGui::TextColored(GUI_COLOR_TEXT, "%d", *reinterpret_cast<const uint16_t *>(APP_INDEX->parental_level.c_str()));
|
||||
ImGui::Spacing();
|
||||
ImGui::SetCursorPosX(((display_size.x / 2.f) - ImGui::CalcTextSize((lang.info["updated"] + " ").c_str()).x));
|
||||
ImGui::SetCursorPosX((display_size.x / 2.f) - ImGui::CalcTextSize((lang.info["updated"] + " ").c_str()).x);
|
||||
auto DATE_TIME = get_date_time(gui, emuenv, gui.app_selector.app_info.updated);
|
||||
ImGui::TextColored(GUI_COLOR_TEXT, "%s %s %s", lang.info["updated"].c_str(), DATE_TIME[DateTime::DATE_MINI].c_str(), DATE_TIME[DateTime::CLOCK].c_str());
|
||||
if (is_12_hour_format) {
|
||||
|
||||
@@ -74,11 +74,11 @@ void draw_archive_install_dialog(GuiState &gui, EmuEnvState &emuenv) {
|
||||
static std::mutex install_mutex;
|
||||
static const auto progress_callback = [&](const ArchiveContents &progress_value) {
|
||||
if (progress_value.count.has_value())
|
||||
count = progress_value.count.value();
|
||||
count = *progress_value.count;
|
||||
if (progress_value.current.has_value())
|
||||
current = progress_value.current.value();
|
||||
current = *progress_value.current;
|
||||
if (progress_value.progress.has_value())
|
||||
progress = progress_value.progress.value();
|
||||
progress = *progress_value.progress;
|
||||
};
|
||||
std::lock_guard<std::mutex> lock(install_mutex);
|
||||
|
||||
|
||||
@@ -276,7 +276,7 @@ void browse_save_data_dialog(GuiState &gui, EmuEnvState &emuenv, const uint32_t
|
||||
|
||||
switch (button) {
|
||||
case SCE_CTRL_UP:
|
||||
if ((emuenv.common_dialog.savedata.draw_info_window || (save_data_slot_list.front() == current_selected_save_data_slot)))
|
||||
if (emuenv.common_dialog.savedata.draw_info_window || (save_data_slot_list.front() == current_selected_save_data_slot))
|
||||
save_data_list_type_selected = CANCEL;
|
||||
else
|
||||
current_selected_save_data_slot = prev_save_data_slot;
|
||||
|
||||
@@ -51,7 +51,7 @@ static constexpr short total_key_entries = 0 CONFIG_INDIVIDUAL(CALC_KEYBOARD_MEM
|
||||
#undef CALC_KEYBOARD_MEMBERS
|
||||
|
||||
template <typename T>
|
||||
int int_or_zero(T value) {
|
||||
static int int_or_zero(T value) {
|
||||
static_assert(std::is_same_v<T, int>);
|
||||
if constexpr (std::is_same_v<T, int>)
|
||||
return value;
|
||||
@@ -105,7 +105,6 @@ static void remapper_button(GuiState &gui, EmuEnvState &emuenv, int *button, con
|
||||
}
|
||||
|
||||
void draw_controls_dialog(GuiState &gui, EmuEnvState &emuenv) {
|
||||
const ImVec2 display_size(emuenv.logical_viewport_size.x, emuenv.logical_viewport_size.y);
|
||||
const auto RES_SCALE = ImVec2(emuenv.gui_scale.x, emuenv.gui_scale.y);
|
||||
static const auto BUTTON_SIZE = ImVec2(120.f * emuenv.manual_dpi_scale, 0.f);
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ void reevaluate_code(GuiState &gui, EmuEnvState &emuenv) {
|
||||
|
||||
uint32_t address = 0, count = 0;
|
||||
if (!address_string.empty())
|
||||
address = static_cast<uint32_t>(std::stol(address_string, nullptr, 16));
|
||||
address = static_cast<uint32_t>(std::stoll(address_string, nullptr, 16));
|
||||
if (!count_string.empty())
|
||||
count = static_cast<uint32_t>(std::stol(count_string));
|
||||
bool thumb = gui.disassembly_arch == "THUMB";
|
||||
|
||||
@@ -33,8 +33,6 @@ void draw_firmware_install_dialog(GuiState &gui, EmuEnvState &emuenv) {
|
||||
static bool delete_pup_file;
|
||||
static std::filesystem::path pup_path = "";
|
||||
|
||||
host::dialog::filesystem::Result result = host::dialog::filesystem::Result::CANCEL;
|
||||
|
||||
static std::mutex install_mutex;
|
||||
static bool draw_file_dialog = true;
|
||||
static bool finished_installing = false;
|
||||
@@ -56,7 +54,7 @@ void draw_firmware_install_dialog(GuiState &gui, EmuEnvState &emuenv) {
|
||||
ImGui::SetNextWindowPos(ImVec2(emuenv.logical_viewport_pos.x + (display_size.x / 2.f) - (WINDOW_SIZE.x / 2), emuenv.logical_viewport_pos.y + (display_size.y / 2.f) - (WINDOW_SIZE.y / 2.f)), ImGuiCond_Always);
|
||||
ImGui::SetNextWindowSize(WINDOW_SIZE);
|
||||
if (draw_file_dialog) {
|
||||
result = host::dialog::filesystem::open_file(pup_path, { { "PlayStation Vita Firmware Package", { "PUP" } } });
|
||||
auto result = host::dialog::filesystem::open_file(pup_path, { { "PlayStation Vita Firmware Package", { "PUP" } } });
|
||||
draw_file_dialog = false;
|
||||
finished_installing = false;
|
||||
|
||||
|
||||
+9
-14
@@ -203,7 +203,7 @@ static void init_font(GuiState &gui, EmuEnvState &emuenv) {
|
||||
int max_texture_size = emuenv.renderer->get_max_2d_texture_width();
|
||||
io.Fonts->TexDesiredWidth = max_texture_size;
|
||||
|
||||
for (int font_scale_count = sizeof(FontScaleCandidates) / sizeof(FontScaleCandidates[0]); font_scale_count > 0; font_scale_count--) {
|
||||
for (int font_scale_count = std::size(FontScaleCandidates); font_scale_count > 0; font_scale_count--) {
|
||||
for (int i = 0; i < font_scale_count; i++) {
|
||||
float scale = FontScaleCandidates[i];
|
||||
|
||||
@@ -316,11 +316,7 @@ vfs::FileBuffer init_default_icon(GuiState &gui, EmuEnvState &emuenv) {
|
||||
|
||||
if (fs::exists(default_fw_icon) || fs::exists(default_icon)) {
|
||||
fs::path icon_path = fs::exists(default_fw_icon) ? default_fw_icon : default_icon;
|
||||
fs::ifstream image_stream(icon_path, std::ios::binary | std::ios::ate);
|
||||
const std::size_t fsize = image_stream.tellg();
|
||||
buffer.resize(fsize);
|
||||
image_stream.seekg(0, std::ios::beg);
|
||||
image_stream.read(reinterpret_cast<char *>(buffer.data()), fsize);
|
||||
fs_utils::read_data(icon_path, buffer);
|
||||
}
|
||||
|
||||
return buffer;
|
||||
@@ -519,22 +515,22 @@ void save_apps_cache(GuiState &gui, EmuEnvState &emuenv) {
|
||||
if (apps_cache.is_open()) {
|
||||
// Write Size of apps list
|
||||
const auto size = gui.app_selector.user_apps.size();
|
||||
apps_cache.write((char *)&size, sizeof(size));
|
||||
apps_cache.write(reinterpret_cast<const char *>(&size), sizeof(size));
|
||||
|
||||
// Write version of cache
|
||||
const uint32_t versionInFile = 1;
|
||||
apps_cache.write((const char *)&versionInFile, sizeof(uint32_t));
|
||||
apps_cache.write(reinterpret_cast<const char *>(&versionInFile), sizeof(uint32_t));
|
||||
|
||||
// Write language of cache
|
||||
gui.app_selector.apps_cache_lang = emuenv.cfg.sys_lang;
|
||||
apps_cache.write((char *)&gui.app_selector.apps_cache_lang, sizeof(uint32_t));
|
||||
apps_cache.write(reinterpret_cast<const char *>(&gui.app_selector.apps_cache_lang), sizeof(uint32_t));
|
||||
|
||||
// Write Apps list
|
||||
for (const App &app : gui.app_selector.user_apps) {
|
||||
auto write = [&apps_cache](const std::string &i) {
|
||||
const auto size = i.length();
|
||||
const size_t size = i.length();
|
||||
|
||||
apps_cache.write((const char *)&size, sizeof(size));
|
||||
apps_cache.write(reinterpret_cast<const char *>(&size), sizeof(size));
|
||||
apps_cache.write(i.c_str(), size);
|
||||
};
|
||||
|
||||
@@ -633,8 +629,7 @@ void get_user_apps_title(GuiState &gui, EmuEnvState &emuenv) {
|
||||
for (const auto &app : fs::directory_iterator(app_path)) {
|
||||
if (!app.path().empty() && fs::is_directory(app.path())
|
||||
&& !app.path().filename_is_dot() && !app.path().filename_is_dot_dot()) {
|
||||
const auto app_path = app.path().stem().generic_string();
|
||||
get_app_param(gui, emuenv, app_path);
|
||||
get_app_param(gui, emuenv, app.path().stem().generic_string());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -673,7 +668,7 @@ void get_sys_apps_title(GuiState &gui, EmuEnvState &emuenv) {
|
||||
else
|
||||
emuenv.app_info.app_short_title = emuenv.app_info.app_title = lang["content_manager"];
|
||||
}
|
||||
gui.app_selector.sys_apps.push_back({ emuenv.app_info.app_version, emuenv.app_info.app_category, {}, {}, {}, {}, emuenv.app_info.app_short_title, emuenv.app_info.app_title, emuenv.app_info.app_title_id, app.data() });
|
||||
gui.app_selector.sys_apps.push_back({ emuenv.app_info.app_version, emuenv.app_info.app_category, {}, {}, {}, {}, emuenv.app_info.app_short_title, emuenv.app_info.app_title, emuenv.app_info.app_title_id, std::string(app) });
|
||||
}
|
||||
|
||||
std::sort(gui.app_selector.sys_apps.begin(), gui.app_selector.sys_apps.end(), [](const App &lhs, const App &rhs) {
|
||||
|
||||
@@ -110,7 +110,7 @@ std::vector<std::string>::iterator get_live_area_current_open_apps_list_index(Gu
|
||||
void update_live_area_current_open_apps_list(GuiState &gui, EmuEnvState &emuenv, const std::string &app_path) {
|
||||
if ((get_live_area_current_open_apps_list_index(gui, app_path) != gui.live_area_current_open_apps_list.end()) && (gui.live_area_current_open_apps_list.front() != app_path))
|
||||
gui.live_area_current_open_apps_list.erase(get_live_area_current_open_apps_list_index(gui, app_path));
|
||||
if ((get_live_area_current_open_apps_list_index(gui, app_path) == gui.live_area_current_open_apps_list.end()))
|
||||
if (get_live_area_current_open_apps_list_index(gui, app_path) == gui.live_area_current_open_apps_list.end())
|
||||
gui.live_area_current_open_apps_list.insert(gui.live_area_current_open_apps_list.begin(), app_path);
|
||||
gui.live_area_app_current_open = 0;
|
||||
if (gui.live_area_current_open_apps_list.size() > 6) {
|
||||
@@ -267,7 +267,7 @@ void draw_app_close(GuiState &gui, EmuEnvState &emuenv) {
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
inline uint64_t current_time() {
|
||||
inline static uint64_t current_time() {
|
||||
return std::chrono::duration_cast<std::chrono::seconds>(
|
||||
std::chrono::high_resolution_clock::now().time_since_epoch())
|
||||
.count();
|
||||
@@ -570,9 +570,9 @@ void draw_home_screen(GuiState &gui, EmuEnvState &emuenv) {
|
||||
last_time["home"] += emuenv.cfg.delay_background;
|
||||
|
||||
if (gui.users[emuenv.io.user_id].use_theme_bg)
|
||||
gui.current_theme_bg = ++gui.current_theme_bg % uint64_t(gui.theme_backgrounds.size());
|
||||
gui.current_theme_bg = (gui.current_theme_bg + 1) % gui.theme_backgrounds.size();
|
||||
else if (gui.user_backgrounds.size() > 1)
|
||||
gui.current_user_bg = ++gui.current_user_bg % uint64_t(gui.user_backgrounds.size());
|
||||
gui.current_user_bg = (gui.current_user_bg + 1) % gui.user_backgrounds.size();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -589,7 +589,7 @@ void draw_home_screen(GuiState &gui, EmuEnvState &emuenv) {
|
||||
|
||||
// Size of the compatibility part
|
||||
const auto compat_radius = 12.f * VIEWPORT_SCALE.x;
|
||||
const auto full_compat_radius = (3.f * VIEWPORT_SCALE.x) + compat_radius;
|
||||
const auto full_compat_radius = 3.f * VIEWPORT_SCALE.x + compat_radius;
|
||||
|
||||
auto &lang = gui.lang.home_screen;
|
||||
|
||||
|
||||
@@ -422,7 +422,7 @@ void draw_ime(Ime &ime, EmuEnvState &emuenv) {
|
||||
if (is_first)
|
||||
set_second_keyboard(ime);
|
||||
else
|
||||
init_ime_lang(ime, SceImeLanguage(emuenv.cfg.current_ime_lang));
|
||||
init_ime_lang(ime, static_cast<SceImeLanguage>(emuenv.cfg.current_ime_lang));
|
||||
current_keyboard = is_first ? SECOND : FIRST;
|
||||
}
|
||||
ImGui::PopStyleColor(2);
|
||||
@@ -462,8 +462,8 @@ void draw_ime(Ime &ime, EmuEnvState &emuenv) {
|
||||
ImGui::OpenPopup("S/K");
|
||||
if (ImGui::BeginPopup("S/K", ImGuiWindowFlags_NoMove)) {
|
||||
for (const auto &lang : emuenv.cfg.ime_langs) {
|
||||
if (ImGui::MenuItem(get_ime_lang_index(ime, SceImeLanguage(lang))->second.c_str(), nullptr, emuenv.cfg.current_ime_lang == lang)) {
|
||||
init_ime_lang(ime, SceImeLanguage(lang));
|
||||
if (ImGui::MenuItem(get_ime_lang_index(ime, static_cast<SceImeLanguage>(lang))->second.c_str(), nullptr, emuenv.cfg.current_ime_lang == lang)) {
|
||||
init_ime_lang(ime, static_cast<SceImeLanguage>(lang));
|
||||
emuenv.cfg.current_ime_lang = lang;
|
||||
config::serialize_config(emuenv.cfg, emuenv.config_path);
|
||||
}
|
||||
|
||||
@@ -387,8 +387,10 @@ static void ImGui_ImplSDL2_UpdateGamepads(ImGui_State *state) {
|
||||
// Update gamepad inputs
|
||||
#define IM_SATURATE(V) (V < 0.0f ? 0.0f : V > 1.0f ? 1.0f \
|
||||
: V)
|
||||
#define MAP_BUTTON(KEY_NO, BUTTON_NO) \
|
||||
{ io.AddKeyEvent(KEY_NO, SDL_GameControllerGetButton(game_controller, BUTTON_NO) != 0); }
|
||||
#define MAP_BUTTON(KEY_NO, BUTTON_NO) \
|
||||
{ \
|
||||
io.AddKeyEvent(KEY_NO, SDL_GameControllerGetButton(game_controller, BUTTON_NO) != 0); \
|
||||
}
|
||||
#define MAP_ANALOG(KEY_NO, AXIS_NO, V0, V1) \
|
||||
{ \
|
||||
float vn = (float)(SDL_GameControllerGetAxis(game_controller, AXIS_NO) - V0) / (float)(V1 - V0); \
|
||||
|
||||
@@ -206,7 +206,7 @@ void ImGui_ImplSdlGL3_RenderDrawData(ImGui_GLState &state) {
|
||||
glColorMask(last_color_mask[0], last_color_mask[1], last_color_mask[2], last_color_mask[3]);
|
||||
}
|
||||
|
||||
void ImGui_ImplSdlGL3_CreateFontsTexture(ImGui_GLState &state) {
|
||||
static void ImGui_ImplSdlGL3_CreateFontsTexture(ImGui_GLState &state) {
|
||||
// Build texture atlas
|
||||
ImGuiIO &io = ImGui::GetIO();
|
||||
unsigned char *pixels;
|
||||
|
||||
@@ -71,8 +71,6 @@
|
||||
|
||||
#include <SDL_vulkan.h>
|
||||
|
||||
#include <fstream>
|
||||
|
||||
// Visual Studio warnings
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable : 4127) // condition expression is constant
|
||||
@@ -187,7 +185,7 @@ static uint32_t __glsl_shader_frag_spv[] = {
|
||||
// FUNCTIONS
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
inline renderer::vulkan::VKState &get_renderer(ImGui_VulkanState &state) {
|
||||
inline static renderer::vulkan::VKState &get_renderer(ImGui_VulkanState &state) {
|
||||
return dynamic_cast<renderer::vulkan::VKState &>(*state.renderer);
|
||||
}
|
||||
|
||||
|
||||
@@ -302,7 +302,7 @@ void update_notice_info(GuiState &gui, EmuEnvState &emuenv, const std::string &t
|
||||
const auto &trophy_data = gui.trophy_unlock_display_requests.back();
|
||||
info.id = trophy_data.np_com_id;
|
||||
info.content_id = trophy_data.trophy_id;
|
||||
info.group = std::to_string(int(trophy_data.trophy_kind));
|
||||
info.group = std::to_string(static_cast<int>(trophy_data.trophy_kind));
|
||||
}
|
||||
info.type = type;
|
||||
info.time = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
|
||||
@@ -350,11 +350,11 @@ static std::string get_notice_time(GuiState &gui, EmuEnvState &emuenv, const tim
|
||||
} else {
|
||||
auto &lang = gui.lang.common.main;
|
||||
if (diff_time >= (hour * 2))
|
||||
date = fmt::format(fmt::runtime(lang["hours_ago"]), uint32_t(diff_time / hour));
|
||||
date = fmt::format(fmt::runtime(lang["hours_ago"]), static_cast<uint32_t>(diff_time / hour));
|
||||
else if (diff_time >= hour)
|
||||
date = lang["one_hour_ago"];
|
||||
else if (diff_time >= (minute * 2))
|
||||
date = fmt::format(fmt::runtime(lang["minutes_ago"]), uint32_t(diff_time / 60));
|
||||
date = fmt::format(fmt::runtime(lang["minutes_ago"]), static_cast<uint32_t>(diff_time / 60));
|
||||
else
|
||||
date = lang["one_minute_ago"];
|
||||
}
|
||||
@@ -569,7 +569,7 @@ void draw_information_bar(GuiState &gui, EmuEnvState &emuenv) {
|
||||
draw_list->AddRectFilled(VIEWPORT_POS, INFO_BAR_POS_MAX, is_theme_color ? bar_color : DEFAULT_BAR_COLOR, 0.f, ImDrawFlags_RoundCornersAll);
|
||||
|
||||
if (gui.vita_area.home_screen || gui.vita_area.live_area_screen) {
|
||||
const auto HOME_ICON_POS_CENTER = VIEWPORT_POS.x + (INFO_BAR_SIZE.x / 2.f) - (32.f * ((float(gui.live_area_current_open_apps_list.size())) / 2.f)) * SCALE.x;
|
||||
const auto HOME_ICON_POS_CENTER = VIEWPORT_POS.x + (INFO_BAR_SIZE.x / 2.f) - (32.f * (static_cast<float>(gui.live_area_current_open_apps_list.size()) / 2.f)) * SCALE.x;
|
||||
const auto APP_IS_OPEN = gui.live_area_app_current_open >= 0;
|
||||
|
||||
// Draw Home Icon
|
||||
@@ -590,7 +590,7 @@ void draw_information_bar(GuiState &gui, EmuEnvState &emuenv) {
|
||||
draw_list->AddRectFilled(ImVec2(HOME_ICON_POS_CENTER - (3.f * SCALE.x), VIEWPORT_POS.y + (18.5f * SCALE.y)), ImVec2(HOME_ICON_POS_CENTER + (3.f * SCALE.x), VIEWPORT_POS.y + (26.f * SCALE.y)), bar_color);
|
||||
|
||||
// Draw App Icon
|
||||
const float decal_app_icon_pos = 34.f * ((float(gui.live_area_current_open_apps_list.size()) - 2) / 2.f);
|
||||
const float decal_app_icon_pos = 34.f * ((static_cast<float>(gui.live_area_current_open_apps_list.size()) - 2) / 2.f);
|
||||
const auto ICON_SIZE_SCALE = 28.f * SCALE.x;
|
||||
|
||||
for (auto a = 0; a < gui.live_area_current_open_apps_list.size(); a++) {
|
||||
|
||||
@@ -456,7 +456,7 @@ void init_live_area(GuiState &gui, EmuEnvState &emuenv, const std::string &app_p
|
||||
continue;
|
||||
}
|
||||
|
||||
items_size[app_path][item.first]["background"] = ImVec2(float(width), float(height));
|
||||
items_size[app_path][item.first]["background"] = ImVec2(static_cast<float>(width), static_cast<float>(height));
|
||||
gui.live_items[app_path][item.first]["background"].emplace_back(gui.imgui_state.get(), data, width, height);
|
||||
stbi_image_free(data);
|
||||
}
|
||||
@@ -488,7 +488,7 @@ void init_live_area(GuiState &gui, EmuEnvState &emuenv, const std::string &app_p
|
||||
continue;
|
||||
}
|
||||
|
||||
items_size[app_path][item.first]["image"] = ImVec2(float(width), float(height));
|
||||
items_size[app_path][item.first]["image"] = ImVec2(static_cast<float>(width), static_cast<float>(height));
|
||||
gui.live_items[app_path][item.first]["image"].emplace_back(gui.imgui_state.get(), data, width, height);
|
||||
stbi_image_free(data);
|
||||
}
|
||||
@@ -501,7 +501,7 @@ void init_live_area(GuiState &gui, EmuEnvState &emuenv, const std::string &app_p
|
||||
type[app_path] = "a1";
|
||||
}
|
||||
|
||||
inline uint64_t current_time() {
|
||||
inline static uint64_t current_time() {
|
||||
return std::chrono::duration_cast<std::chrono::seconds>(
|
||||
std::chrono::high_resolution_clock::now().time_since_epoch())
|
||||
.count();
|
||||
@@ -679,12 +679,12 @@ void draw_live_area_screen(GuiState &gui, EmuEnvState &emuenv) {
|
||||
last_time[app_path][frame.id] += frame.autoflip;
|
||||
|
||||
if (gui.live_items[app_path][frame.id].contains("background")) {
|
||||
if (current_item[app_path][frame.id] != int(gui.live_items[app_path][frame.id]["background"].size()) - 1)
|
||||
if (current_item[app_path][frame.id] != gui.live_items[app_path][frame.id]["background"].size() - 1)
|
||||
++current_item[app_path][frame.id];
|
||||
else
|
||||
current_item[app_path][frame.id] = 0;
|
||||
} else if (gui.live_items[app_path][frame.id].contains("image")) {
|
||||
if (current_item[app_path][frame.id] != int(gui.live_items[app_path][frame.id]["image"].size()) - 1)
|
||||
if (current_item[app_path][frame.id] != gui.live_items[app_path][frame.id]["image"].size() - 1)
|
||||
++current_item[app_path][frame.id];
|
||||
else
|
||||
current_item[app_path][frame.id] = 0;
|
||||
@@ -858,15 +858,15 @@ void draw_live_area_screen(GuiState &gui, EmuEnvState &emuenv) {
|
||||
|
||||
if (liveitem[app_path][frame.id]["text"]["width"].first > 0) {
|
||||
if (liveitem[app_path][frame.id]["text"]["word-wrap"].second != "off")
|
||||
str_wrap = float(liveitem[app_path][frame.id]["text"]["width"].first) * SCALE.x;
|
||||
text_pos.x += (str_size.x - (float(liveitem[app_path][frame.id]["text"]["width"].first) * SCALE.x)) / 2.f;
|
||||
str_size.x = float(liveitem[app_path][frame.id]["text"]["width"].first) * SCALE.x;
|
||||
str_wrap = static_cast<float>(liveitem[app_path][frame.id]["text"]["width"].first) * SCALE.x;
|
||||
text_pos.x += (str_size.x - (static_cast<float>(liveitem[app_path][frame.id]["text"]["width"].first) * SCALE.x)) / 2.f;
|
||||
str_size.x = static_cast<float>(liveitem[app_path][frame.id]["text"]["width"].first) * SCALE.x;
|
||||
}
|
||||
|
||||
if ((liveitem[app_path][frame.id]["text"]["height"].first > 0)
|
||||
&& ((liveitem[app_path][frame.id]["text"]["word-scroll"].second == "on" || liveitem[app_path][frame.id]["text"]["height"].first <= FRAME_SIZE.y))) {
|
||||
text_pos.y += (str_size.y - (float(liveitem[app_path][frame.id]["text"]["height"].first) * SCALE.y)) / 2.f;
|
||||
str_size.y = float(liveitem[app_path][frame.id]["text"]["height"].first) * SCALE.y;
|
||||
&& (liveitem[app_path][frame.id]["text"]["word-scroll"].second == "on" || liveitem[app_path][frame.id]["text"]["height"].first <= FRAME_SIZE.y)) {
|
||||
text_pos.y += (str_size.y - (static_cast<float>(liveitem[app_path][frame.id]["text"]["height"].first) * SCALE.y)) / 2.f;
|
||||
str_size.y = static_cast<float>(liveitem[app_path][frame.id]["text"]["height"].first) * SCALE.y;
|
||||
}
|
||||
|
||||
const auto size_text_scale = str_tag.size != 0 ? str_tag.size / 19.2f : 1.f;
|
||||
|
||||
@@ -52,7 +52,6 @@ static void draw_file_menu(GuiState &gui, EmuEnvState &emuenv) {
|
||||
|
||||
static void draw_emulation_menu(GuiState &gui, EmuEnvState &emuenv) {
|
||||
auto &lang = gui.lang.main_menubar.emulation;
|
||||
const ImVec2 VIEWPORT_SIZE(emuenv.logical_viewport_size.x, emuenv.logical_viewport_size.y);
|
||||
const ImVec2 RES_SCALE(emuenv.gui_scale.x, emuenv.gui_scale.y);
|
||||
const ImVec2 SCALE(RES_SCALE.x * emuenv.manual_dpi_scale, RES_SCALE.y * emuenv.manual_dpi_scale);
|
||||
const ImVec2 ICON_SIZE(56.f * SCALE.x, 56.f * SCALE.y);
|
||||
@@ -152,7 +151,6 @@ static void draw_help_menu(GuiState &gui) {
|
||||
|
||||
void draw_main_menu_bar(GuiState &gui, EmuEnvState &emuenv) {
|
||||
if (ImGui::BeginMainMenuBar()) {
|
||||
const ImVec2 display_size(emuenv.logical_viewport_size.x, emuenv.logical_viewport_size.y);
|
||||
const ImVec2 RES_SCALE(emuenv.gui_scale.x, emuenv.gui_scale.y);
|
||||
|
||||
ImGui::SetWindowFontScale(RES_SCALE.x);
|
||||
|
||||
@@ -195,7 +195,7 @@ void draw_manual(GuiState &gui, EmuEnvState &emuenv) {
|
||||
|
||||
// Draw browser page button
|
||||
if (!hidden_button) {
|
||||
ImGui::SetCursorPos(ImVec2(display_size.x / 2.f - ((BUTTON_SIZE.x / 2.f)), display_size.y - (40.f * SCALE.y)));
|
||||
ImGui::SetCursorPos(ImVec2(display_size.x / 2.f - (BUTTON_SIZE.x / 2.f), display_size.y - (40.f * SCALE.y)));
|
||||
const std::string slider = fmt::format("{:0>2d}/{:0>2d}", current_page + 1, (int32_t)gui.manuals.size());
|
||||
if (ImGui::Button(slider.c_str(), BUTTON_SIZE))
|
||||
ImGui::OpenPopup("Manual Slider");
|
||||
|
||||
@@ -46,7 +46,6 @@ static ImVec2 get_perf_pos(ImVec2 window_size, EmuEnvState &emuenv) {
|
||||
void draw_perf_overlay(GuiState &gui, EmuEnvState &emuenv) {
|
||||
auto lang = gui.lang.performance_overlay;
|
||||
|
||||
const ImVec2 VIEWPORT_SIZE(emuenv.logical_viewport_size.x, emuenv.logical_viewport_size.y);
|
||||
const ImVec2 RES_SCALE(emuenv.gui_scale.x, emuenv.gui_scale.y);
|
||||
const ImVec2 SCALE(RES_SCALE.x * emuenv.manual_dpi_scale, RES_SCALE.y * emuenv.manual_dpi_scale);
|
||||
|
||||
@@ -85,7 +84,7 @@ void draw_perf_overlay(GuiState &gui, EmuEnvState &emuenv) {
|
||||
ImGui::PopStyleColor();
|
||||
if (emuenv.cfg.performance_overlay_detail == PerformanceOverlayDetail::MAXIMUM) {
|
||||
ImGui::SetCursorPosY(ImGui::GetCursorPosY() - ImGui::GetStyle().ItemSpacing.y);
|
||||
ImGui::PlotLines("##fps_graphic", emuenv.fps_values, IM_ARRAYSIZE(emuenv.fps_values), emuenv.current_fps_offset, nullptr, 0.f, float(emuenv.max_fps), WINDOW_SIZE);
|
||||
ImGui::PlotLines("##fps_graphic", emuenv.fps_values, IM_ARRAYSIZE(emuenv.fps_values), emuenv.current_fps_offset, nullptr, 0.f, static_cast<float>(emuenv.max_fps), WINDOW_SIZE);
|
||||
}
|
||||
ImGui::End();
|
||||
ImGui::PopStyleVar();
|
||||
|
||||
@@ -230,7 +230,7 @@ void draw_pkg_install_dialog(GuiState &gui, EmuEnvState &emuenv) {
|
||||
ImGui::PushStyleColor(ImGuiCol_PlotHistogram, GUI_PROGRESS_BAR);
|
||||
ImGui::ProgressBar(progress / 100.f, ImVec2(PROGRESS_BAR_WIDTH, 15.f * SCALE.x), "");
|
||||
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 16.f * SCALE.y);
|
||||
TextColoredCentered(GUI_COLOR_TEXT, std::to_string(uint32_t(progress)).append("%").c_str());
|
||||
TextColoredCentered(GUI_COLOR_TEXT, std::to_string(static_cast<uint32_t>(progress)).append("%").c_str());
|
||||
ImGui::PopStyleColor();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
namespace gui {
|
||||
|
||||
#define RGBA_TO_FLOAT(r, g, b, a) ImVec4(r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f)
|
||||
#define RGBA_TO_FLOAT(r, g, b, a) ImVec4((r) / 255.0f, (g) / 255.0f, (b) / 255.0f, (a) / 255.0f)
|
||||
|
||||
const ImVec4 GUI_COLOR_TEXT_MENUBAR = RGBA_TO_FLOAT(242, 150, 58, 255);
|
||||
const ImVec4 GUI_COLOR_TEXT_TITLE = RGBA_TO_FLOAT(247, 198, 51, 255);
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
#include <dialog/state.h>
|
||||
#include <gui/functions.h>
|
||||
|
||||
#include <imgui.h>
|
||||
#include <packages/sfo.h>
|
||||
|
||||
namespace gui {
|
||||
|
||||
@@ -157,7 +157,7 @@ static void get_themes_list(GuiState &gui, EmuEnvState &emuenv) {
|
||||
theme_preview_name["default"][LOCK] = "data/internal/theme/defaultTheme_startScreen.png";
|
||||
|
||||
themes_info["default"].title = gui.lang.settings.theme_background.main["default"];
|
||||
themes_list.push_back({ "default", {} });
|
||||
themes_list.emplace_back("default", time_t{});
|
||||
} else
|
||||
LOG_WARN("Default theme not found, install firmware fix this!");
|
||||
|
||||
@@ -691,7 +691,7 @@ void draw_settings(GuiState &gui, EmuEnvState &emuenv) {
|
||||
gui.user_backgrounds.erase(delete_user_background);
|
||||
gui.user_backgrounds_infos.erase(delete_user_background);
|
||||
if (!gui.users[emuenv.io.user_id].backgrounds.empty())
|
||||
gui.current_user_bg = gui.current_user_bg % uint64_t(gui.user_backgrounds.size());
|
||||
gui.current_user_bg = gui.current_user_bg % gui.user_backgrounds.size();
|
||||
else if (!gui.theme_backgrounds.empty())
|
||||
gui.users[emuenv.io.user_id].use_theme_bg = true;
|
||||
save_user(gui, emuenv, emuenv.io.user_id);
|
||||
@@ -784,7 +784,7 @@ void draw_settings(GuiState &gui, EmuEnvState &emuenv) {
|
||||
};
|
||||
|
||||
for (auto f = 0; f < 3; f++) {
|
||||
auto date_format_value = SceSystemParamDateFormat(f);
|
||||
auto date_format_value = static_cast<SceSystemParamDateFormat>(f);
|
||||
const auto date_format_str = get_date_format_sting(date_format_value);
|
||||
ImGui::PushID(date_format_str.c_str());
|
||||
ImGui::SetCursorPosY((WINDOW_SIZE.y / 2.f) - INFORMATION_BAR_HEIGHT - (SIZE_PUPUP_SELECT * 1.5f) + (SIZE_PUPUP_SELECT * f));
|
||||
@@ -953,7 +953,7 @@ void draw_settings(GuiState &gui, EmuEnvState &emuenv) {
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_SelectableTextAlign, ImVec2(0.f, 0.5f));
|
||||
ImGui::PushID(lang.first);
|
||||
ImGui::SetWindowFontScale(1.f);
|
||||
const auto is_lang_enable = vector_utils::contains(emuenv.cfg.ime_langs, uint64_t(lang.first));
|
||||
const auto is_lang_enable = vector_utils::contains(emuenv.cfg.ime_langs, static_cast<uint64_t>(lang.first));
|
||||
if (ImGui::Selectable(is_lang_enable ? "V" : "##lang", false, ImGuiSelectableFlags_SpanAllColumns, ImVec2(0.f, SIZE_SELECT)))
|
||||
selected = std::to_string(lang.first);
|
||||
ImGui::NextColumn();
|
||||
@@ -971,7 +971,7 @@ void draw_settings(GuiState &gui, EmuEnvState &emuenv) {
|
||||
}
|
||||
ImGui::Columns(1);
|
||||
} else {
|
||||
SceImeLanguage lang_select = SceImeLanguage(string_utils::stoi_def(selected, 0, "language"));
|
||||
SceImeLanguage lang_select = static_cast<SceImeLanguage>(string_utils::stoi_def(selected, 0, "language"));
|
||||
title = get_ime_lang_index(emuenv.ime, lang_select)->second;
|
||||
ImGui::SetWindowFontScale(1.2f);
|
||||
ImGui::Columns(2, nullptr, false);
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
// with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
#include "imgui.h"
|
||||
#include "private.h"
|
||||
|
||||
#include <app/functions.h>
|
||||
@@ -563,7 +562,7 @@ void draw_settings_dialog(GuiState &gui, EmuEnvState &emuenv) {
|
||||
const char *LIST_CPU_BACKEND_DISPLAY[] = { "Dynarmic", lang.cpu["unicorn"].c_str() };
|
||||
ImGui::TextColored(GUI_COLOR_TEXT_TITLE, "%s", lang.cpu["cpu_backend"].c_str());
|
||||
if (ImGui::Combo("##cpu_backend", reinterpret_cast<int *>(&config_cpu_backend), LIST_CPU_BACKEND_DISPLAY, IM_ARRAYSIZE(LIST_CPU_BACKEND_DISPLAY)))
|
||||
config.cpu_backend = LIST_CPU_BACKEND[int(config_cpu_backend)];
|
||||
config.cpu_backend = LIST_CPU_BACKEND[static_cast<int>(config_cpu_backend)];
|
||||
SetTooltipEx(lang.cpu["select_cpu_backend"].c_str());
|
||||
if (config_cpu_backend == CPUBackend::Dynarmic) {
|
||||
ImGui::Spacing();
|
||||
@@ -585,7 +584,7 @@ void draw_settings_dialog(GuiState &gui, EmuEnvState &emuenv) {
|
||||
#endif
|
||||
static const char *LIST_BACKEND_RENDERER[] = { "OpenGL", "Vulkan" };
|
||||
if (ImGui::Combo(lang.gpu["backend_renderer"].c_str(), reinterpret_cast<int *>(&emuenv.backend_renderer), LIST_BACKEND_RENDERER, IM_ARRAYSIZE(LIST_BACKEND_RENDERER)))
|
||||
emuenv.cfg.backend_renderer = LIST_BACKEND_RENDERER[int(emuenv.backend_renderer)];
|
||||
emuenv.cfg.backend_renderer = LIST_BACKEND_RENDERER[static_cast<int>(emuenv.backend_renderer)];
|
||||
SetTooltipEx(lang.gpu["select_backend_renderer"].c_str());
|
||||
#ifdef __APPLE__
|
||||
ImGui::EndDisabled();
|
||||
|
||||
@@ -128,7 +128,7 @@ void init_theme_start_background(GuiState &gui, EmuEnvState &emuenv, const std::
|
||||
if (!theme.child("StartScreenProperty").child("m_dateColor").empty())
|
||||
start_param.date_color = convert_hex_color(theme.child("StartScreenProperty").child("m_dateColor").text().as_string());
|
||||
if (!theme.child("StartScreenProperty").child("m_dateLayout").empty())
|
||||
start_param.date_layout = DateLayout(theme.child("StartScreenProperty").child("m_dateLayout").text().as_int());
|
||||
start_param.date_layout = static_cast<DateLayout>(theme.child("StartScreenProperty").child("m_dateLayout").text().as_int());
|
||||
|
||||
// Theme Start
|
||||
if (!theme.child("StartScreenProperty").child("m_filePath").empty()) {
|
||||
@@ -500,7 +500,7 @@ void draw_start_screen(GuiState &gui, EmuEnvState &emuenv) {
|
||||
}
|
||||
ImGui::PopFont();
|
||||
|
||||
if ((ImGui::IsWindowHovered(ImGuiFocusedFlags_RootWindow) && ImGui::IsMouseClicked(0))) {
|
||||
if (ImGui::IsWindowHovered(ImGuiFocusedFlags_RootWindow) && ImGui::IsMouseClicked(0)) {
|
||||
gui.vita_area.start_screen = false;
|
||||
gui.vita_area.home_screen = true;
|
||||
if (emuenv.cfg.show_info_bar)
|
||||
|
||||
@@ -129,7 +129,7 @@ enum class NpComIdSortType {
|
||||
PROGRESS
|
||||
};
|
||||
static NpComIdSortType np_com_id_sort;
|
||||
bool show_hidden_trophy = false;
|
||||
static bool show_hidden_trophy = false;
|
||||
|
||||
void init_trophy_collection(GuiState &gui, EmuEnvState &emuenv) {
|
||||
const auto TROPHY_PATH{ emuenv.pref_path / "ux0/user" / emuenv.io.user_id / "trophy" };
|
||||
|
||||
@@ -28,7 +28,6 @@ namespace gui {
|
||||
static constexpr int TROPHY_WINDOW_STATIC_FRAME_COUNT = 250;
|
||||
|
||||
static void draw_trophy_unlocked(GuiState &gui, EmuEnvState &emuenv, NpTrophyUnlockCallbackData &callback_data) {
|
||||
const auto display_size = ImGui::GetIO().DisplaySize;
|
||||
const auto RES_SCALE = ImVec2(emuenv.gui_scale.x, emuenv.gui_scale.y);
|
||||
const auto SCALE = ImVec2(RES_SCALE.x * emuenv.manual_dpi_scale, RES_SCALE.y * emuenv.manual_dpi_scale);
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ void get_users_list(GuiState &gui, EmuEnvState &emuenv) {
|
||||
if (fs::exists(user_path) && !fs::is_empty(user_path)) {
|
||||
for (const auto &path : fs::directory_iterator(user_path)) {
|
||||
pugi::xml_document user_xml;
|
||||
if (fs::is_directory(path) && user_xml.load_file(((path / "user.xml").c_str()))) {
|
||||
if (fs::is_directory(path) && user_xml.load_file((path / "user.xml").c_str())) {
|
||||
const auto user_child = user_xml.child("user");
|
||||
|
||||
// Load user id
|
||||
|
||||
@@ -402,7 +402,7 @@ void draw_vita3k_update(GuiState &gui, EmuEnvState &emuenv) {
|
||||
ImGui::PushStyleColor(ImGuiCol_PlotHistogram, GUI_PROGRESS_BAR);
|
||||
ImGui::ProgressBar(progress / 100.f, ImVec2(PROGRESS_BAR_WIDTH, 15.f * SCALE.y), "");
|
||||
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 16.f * emuenv.manual_dpi_scale);
|
||||
TextColoredCentered(GUI_COLOR_TEXT, std::to_string(uint32_t(progress)).append("%").c_str());
|
||||
TextColoredCentered(GUI_COLOR_TEXT, std::to_string(static_cast<uint32_t>(progress)).append("%").c_str());
|
||||
ImGui::PopStyleColor();
|
||||
|
||||
break;
|
||||
@@ -444,7 +444,6 @@ void draw_vita3k_update(GuiState &gui, EmuEnvState &emuenv) {
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 10.f * SCALE.x);
|
||||
if (ImGui::BeginPopupModal("cancel_update_popup", &progress_state.pause, ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoDecoration)) {
|
||||
const auto LARGE_BUTTON_SIZE = ImVec2(310.f * SCALE.x, 46.f * SCALE.y);
|
||||
auto &common = emuenv.common_dialog.lang.common;
|
||||
const auto str_size = ImGui::CalcTextSize(lang["cancel_update_resume"].c_str(), 0, false, POPUP_SIZE.x - (120.f * SCALE.y));
|
||||
ImGui::SetCursorPos(ImVec2(60.f * SCALE.x, (ImGui::GetWindowHeight() / 2.f) - (str_size.y / 2.f)));
|
||||
ImGui::PushTextWrapPos(POPUP_SIZE.x - (120.f * SCALE.x));
|
||||
|
||||
@@ -38,8 +38,6 @@ uint32_t get_num_components(SceGxmTextureBaseFormat fmt);
|
||||
std::pair<uint32_t, uint32_t> get_block_size(SceGxmTextureBaseFormat base_format);
|
||||
uint32_t get_stride_in_bytes(const SceGxmTexture &texture);
|
||||
uint32_t bits_per_pixel(SceGxmTextureBaseFormat base_format);
|
||||
// get the full texture size (including all mips and faces)
|
||||
uint32_t texture_size_full(const SceGxmTexture &texture);
|
||||
// get the size of the first mip of the first face
|
||||
uint32_t texture_size_first_mip(const SceGxmTexture &texture);
|
||||
bool is_bcn_format(SceGxmTextureBaseFormat base_format);
|
||||
@@ -48,7 +46,6 @@ bool is_block_compressed_format(SceGxmTextureBaseFormat base_format);
|
||||
bool is_paletted_format(SceGxmTextureBaseFormat base_format);
|
||||
bool is_yuv_format(SceGxmTextureBaseFormat base_format);
|
||||
uint32_t attribute_format_size(SceGxmAttributeFormat format);
|
||||
uint32_t index_element_size(SceGxmIndexFormat format);
|
||||
bool is_stream_instancing(SceGxmIndexSource source);
|
||||
bool convert_color_format_to_texture_format(SceGxmColorFormat format, SceGxmTextureFormat &dest_format);
|
||||
|
||||
|
||||
@@ -410,6 +410,7 @@ enum SceGxmTextureBaseFormat : uint32_t {
|
||||
SCE_GXM_TEXTURE_BASE_FORMAT_UBC6H = 0xFF000001,
|
||||
SCE_GXM_TEXTURE_BASE_FORMAT_SBC6H = 0xFF000002,
|
||||
SCE_GXM_TEXTURE_BASE_FORMAT_UBC7 = 0xFF000003,
|
||||
SCE_GXM_TEXTURE_BASE_FORMAT_INVALID = 0xFFFFFFFF,
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
|
||||
@@ -42,7 +42,4 @@ uint32_t attribute_format_size(SceGxmAttributeFormat format) {
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t index_element_size(SceGxmIndexFormat format) {
|
||||
return (format == SCE_GXM_INDEX_FORMAT_U16) ? 2 : 4;
|
||||
}
|
||||
} // namespace gxm
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
namespace gxp {
|
||||
|
||||
const char *log_parameter_semantic(const SceGxmProgramParameter ¶meter) {
|
||||
const static char *log_parameter_semantic(const SceGxmProgramParameter ¶meter) {
|
||||
// clang-format off
|
||||
switch (parameter.semantic) {
|
||||
case SCE_GXM_PARAMETER_SEMANTIC_NONE: return "NONE";
|
||||
|
||||
@@ -252,124 +252,6 @@ std::pair<uint32_t, uint32_t> get_block_size(SceGxmTextureBaseFormat base_format
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t texture_size_full(const SceGxmTexture &texture) {
|
||||
SceGxmTextureType type = texture.texture_type();
|
||||
const SceGxmTextureBaseFormat format = get_base_format(get_format(texture));
|
||||
|
||||
if (format == SCE_GXM_TEXTURE_BASE_FORMAT_YUV420P2 || format == SCE_GXM_TEXTURE_BASE_FORMAT_YUV420P3) {
|
||||
// multiplane formats must be handled differently
|
||||
assert(type == SCE_GXM_TEXTURE_LINEAR);
|
||||
|
||||
uint32_t width = align(get_width(texture), 8);
|
||||
uint32_t height = get_height(texture);
|
||||
|
||||
if (texture.mip_count != 0xF) {
|
||||
// memory footprint is the same as if rounded up
|
||||
width = next_power_of_two(width);
|
||||
height = next_power_of_two(height);
|
||||
}
|
||||
|
||||
const uint32_t mip_count = texture.true_mip_count();
|
||||
uint32_t texture_size = 0;
|
||||
for (uint32_t mip = 0; mip < mip_count; mip++) {
|
||||
texture_size += (width * height * 3) / 2;
|
||||
width /= 2;
|
||||
height /= 2;
|
||||
}
|
||||
return texture_size;
|
||||
}
|
||||
|
||||
if (type == SCE_GXM_TEXTURE_LINEAR_STRIDED) {
|
||||
return get_stride_in_bytes(texture) * get_height(texture);
|
||||
}
|
||||
|
||||
uint32_t width = get_width(texture);
|
||||
uint32_t height = get_height(texture);
|
||||
|
||||
switch (type) {
|
||||
case SCE_GXM_TEXTURE_SWIZZLED_ARBITRARY:
|
||||
case SCE_GXM_TEXTURE_CUBE_ARBITRARY:
|
||||
// turn arbitrary types into non-arbitrary with their width/height rounded up
|
||||
// that's how they are stored in memory anyway
|
||||
width = next_power_of_two(width);
|
||||
height = next_power_of_two(height);
|
||||
type = (type == SCE_GXM_TEXTURE_SWIZZLED_ARBITRARY) ? SCE_GXM_TEXTURE_SWIZZLED : SCE_GXM_TEXTURE_CUBE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
uint32_t max_possible_mip = std::bit_width(std::min(width, height));
|
||||
if (type == SCE_GXM_TEXTURE_TILED) {
|
||||
// min mip must be at least the size of a tile (32x32)
|
||||
// even if this underflows, that's not an issue because of the min below
|
||||
max_possible_mip -= 5;
|
||||
}
|
||||
uint32_t mip_count;
|
||||
if (type == SCE_GXM_TEXTURE_CUBE && texture.mip_count != 0xF) {
|
||||
// use memory as if all possible mips were there
|
||||
mip_count = max_possible_mip;
|
||||
} else {
|
||||
mip_count = std::min(texture.true_mip_count(), max_possible_mip);
|
||||
}
|
||||
|
||||
auto [block_width, block_height] = get_block_size(format);
|
||||
const uint32_t bpp = bits_per_pixel(format);
|
||||
// block size in bytes
|
||||
const uint32_t block_size = (block_width * block_height * bpp) / 8;
|
||||
|
||||
// from the number of pixels in a mipmap, we can get the number of blocks by shifting to the right by block_shift
|
||||
const uint32_t block_shift = std::bit_width(block_width * block_height) - 1;
|
||||
|
||||
// what each mip takes in memory
|
||||
uint32_t layout_width;
|
||||
uint32_t layout_height;
|
||||
if (texture.mip_count == 0xF || (texture.mip_count == 0 && type != SCE_GXM_TEXTURE_CUBE)) {
|
||||
// a mipcount of 0xF or 0 are both for only one mip, but if the texture is a cube (or multiplane, but handled above)
|
||||
// with a mipcount of 1, we must do as if all mips are present to compute the offset between faces
|
||||
layout_width = width;
|
||||
layout_height = height;
|
||||
} else {
|
||||
layout_width = next_power_of_two(width);
|
||||
layout_height = next_power_of_two(height);
|
||||
}
|
||||
|
||||
uint32_t align_width = block_width;
|
||||
uint32_t align_height = block_height;
|
||||
if (type == SCE_GXM_TEXTURE_LINEAR) {
|
||||
align_width = std::max(align_width, 8U);
|
||||
} else if (type == SCE_GXM_TEXTURE_TILED) {
|
||||
align_width = std::max(align_width, 32U);
|
||||
align_height = std::max(align_height, 32U);
|
||||
}
|
||||
|
||||
uint32_t texture_size = 0;
|
||||
for (uint32_t mip = 0; mip < mip_count; mip++) {
|
||||
const uint32_t nb_pixels = align(layout_width, align_width) * align(layout_height, align_height);
|
||||
const uint32_t mip_size = (nb_pixels >> block_shift) * block_size;
|
||||
texture_size += mip_size;
|
||||
|
||||
layout_width /= 2;
|
||||
layout_height /= 2;
|
||||
}
|
||||
|
||||
if (type == SCE_GXM_TEXTURE_CUBE) {
|
||||
// there can be an additional alignment between faces
|
||||
const bool twok_align_cond1 = width >= 32 && height >= 32 && (bpp <= 8 || is_block_compressed_format(format));
|
||||
const bool twok_align_cond2 = width >= 16 && height >= 16 && (bpp == 16 || bpp == 32);
|
||||
const bool twok_align_cond3 = width >= 8 && height >= 8 && bpp == 64;
|
||||
|
||||
// if one of these conditions is true, alignment between faces is 2K
|
||||
const uint32_t face_alignment = (twok_align_cond1 || twok_align_cond2 || twok_align_cond3) ? 2048 : 4;
|
||||
const uint32_t face_full_size = align(texture_size, face_alignment);
|
||||
|
||||
// don't take into account what is after the end of the last texture
|
||||
texture_size = 5 * face_full_size + texture_size;
|
||||
}
|
||||
|
||||
return texture_size;
|
||||
}
|
||||
|
||||
uint32_t texture_size_first_mip(const SceGxmTexture &texture) {
|
||||
SceGxmTextureType type = texture.texture_type();
|
||||
const SceGxmTextureBaseFormat format = get_base_format(get_format(texture));
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
* @param file_extensions_list File extensions list
|
||||
* @return std::string A string containing the properly formatted file extension list
|
||||
*/
|
||||
std::string format_file_filter_extension_list(const std::vector<std::string> &file_extensions_list) {
|
||||
static std::string format_file_filter_extension_list(const std::vector<std::string> &file_extensions_list) {
|
||||
// Formatted string containing the properly formatted file extension list
|
||||
//
|
||||
// In the case of nativefiledialog, the expected file extension is a single
|
||||
@@ -55,9 +55,9 @@ std::string format_file_filter_extension_list(const std::vector<std::string> &fi
|
||||
for (size_t index = 0; index < file_extensions_list.size(); index++) {
|
||||
// Don't add comma before the first file extension
|
||||
if (index == 0) {
|
||||
formatted_string += file_extensions_list.at(index);
|
||||
formatted_string += file_extensions_list[index];
|
||||
} else {
|
||||
formatted_string += "," + file_extensions_list.at(index);
|
||||
formatted_string += "," + file_extensions_list[index];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,12 +108,12 @@ Result open_file(std::filesystem::path &resulting_path, const std::vector<FileFi
|
||||
// For every file filter in file_filters vector
|
||||
for (const FileFilter &file_filter : file_filters) {
|
||||
// Format file extension list and store the result
|
||||
file_extensions_converted.push_back(format_file_filter_extension_list(file_filter.file_extensions));
|
||||
file_extensions_converted.emplace_back(format_file_filter_extension_list(file_filter.file_extensions));
|
||||
|
||||
// Convert filter and append to the list
|
||||
// File filter names can be used as they are, but the pointers of the
|
||||
// file extension lists have to point to the formatted strings
|
||||
file_filters_converted.push_back({ file_filter.display_name.c_str(), file_extensions_converted.at(file_extensions_converted.size() - 1).c_str() });
|
||||
file_filters_converted.push_back({ file_filter.display_name.c_str(), file_extensions_converted[file_extensions_converted.size() - 1].c_str() });
|
||||
}
|
||||
|
||||
/* --- Then nativefiledialog can be called --- */
|
||||
|
||||
+14
-28
@@ -125,7 +125,7 @@ static bool set_content_path(EmuEnvState &emuenv, const bool is_theme, fs::path
|
||||
return true;
|
||||
}
|
||||
|
||||
bool install_archive_content(EmuEnvState &emuenv, GuiState *gui, const ZipPtr &zip, const std::string &content_path, const std::function<void(ArchiveContents)> &progress_callback) {
|
||||
static bool install_archive_content(EmuEnvState &emuenv, GuiState *gui, const ZipPtr &zip, const std::string &content_path, const std::function<void(ArchiveContents)> &progress_callback) {
|
||||
std::string sfo_path = "sce_sys/param.sfo";
|
||||
std::string theme_path = "theme.xml";
|
||||
vfs::FileBuffer buffer, theme;
|
||||
@@ -292,7 +292,8 @@ std::vector<ContentInfo> install_archive(EmuEnvState &emuenv, GuiState *gui, con
|
||||
for (auto &path : content_path) {
|
||||
current++;
|
||||
update_progress();
|
||||
const bool state = install_archive_content(emuenv, gui, zip, path, progress_callback);
|
||||
bool state = install_archive_content(emuenv, gui, zip, path, progress_callback);
|
||||
// Can't use emplace_back due to Clang 15 for macos
|
||||
content_installed.push_back({ emuenv.app_info.app_title, emuenv.app_info.app_title_id, emuenv.app_info.app_category, emuenv.app_info.app_content_id, path, state });
|
||||
}
|
||||
|
||||
@@ -304,11 +305,12 @@ static std::vector<fs::path> get_contents_path(const fs::path &path) {
|
||||
std::vector<fs::path> contents_path;
|
||||
|
||||
for (const auto &p : fs::recursive_directory_iterator(path)) {
|
||||
const auto is_content = (p.path().filename() == "param.sfo") || (p.path().filename() == "theme.xml");
|
||||
auto filename = p.path().filename();
|
||||
const auto is_content = (filename == "param.sfo") || (filename == "theme.xml");
|
||||
if (is_content) {
|
||||
const auto content_path = (p.path().filename() == "param.sfo") ? p.path().parent_path().parent_path() : p.path().parent_path();
|
||||
if (!vector_utils::contains(content_path, p.path().parent_path()))
|
||||
contents_path.push_back(content_path);
|
||||
auto parent_path = p.path().parent_path();
|
||||
const auto content_path = (filename == "param.sfo") ? parent_path.parent_path() : parent_path;
|
||||
vector_utils::push_if_not_exists(contents_path, content_path);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -320,21 +322,9 @@ static bool install_content(EmuEnvState &emuenv, GuiState *gui, const fs::path &
|
||||
const auto theme_path{ content_path / "theme.xml" };
|
||||
vfs::FileBuffer buffer;
|
||||
|
||||
const auto get_buffer = [&](const fs::path &path) {
|
||||
fs::ifstream f{ path, fs::ifstream::binary };
|
||||
if (!f)
|
||||
return false;
|
||||
|
||||
f.unsetf(fs::ifstream::skipws);
|
||||
buffer.reserve(fs::file_size(path));
|
||||
buffer.insert(buffer.begin(), std::istream_iterator<uint8_t>(f), std::istream_iterator<uint8_t>());
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
const auto is_theme = fs::exists(content_path / "theme.xml");
|
||||
const auto is_theme = fs::exists(theme_path);
|
||||
auto dst_path{ emuenv.pref_path / "ux0" };
|
||||
if (get_buffer(sfo_path)) {
|
||||
if (fs_utils::read_data(sfo_path, buffer)) {
|
||||
sfo::get_param_info(emuenv.app_info, buffer, emuenv.cfg.sys_lang);
|
||||
if (!set_content_path(emuenv, is_theme, dst_path))
|
||||
return false;
|
||||
@@ -342,7 +332,7 @@ static bool install_content(EmuEnvState &emuenv, GuiState *gui, const fs::path &
|
||||
if (exists(dst_path))
|
||||
fs::remove_all(dst_path);
|
||||
|
||||
} else if (get_buffer(theme_path)) {
|
||||
} else if (fs_utils::read_data(theme_path, buffer)) {
|
||||
set_theme_name(emuenv, buffer);
|
||||
dst_path /= fs::path("theme") / fs_utils::utf8_to_path(emuenv.app_info.app_title_id);
|
||||
} else {
|
||||
@@ -447,11 +437,7 @@ static ExitCode load_app_impl(SceUID &main_module_id, EmuEnvState &emuenv) {
|
||||
if (vfs::read_app_file(param_sfo, emuenv.pref_path, emuenv.io.app_path, "sce_sys/param.sfo"))
|
||||
sfo::load(emuenv.sfo_handle, param_sfo);
|
||||
|
||||
// todo: VAR_NID(__sce_libcparam, 0xDF084DFA) is loaded wrong
|
||||
for (const auto &var : get_var_exports()) {
|
||||
auto addr = var.factory(emuenv);
|
||||
emuenv.kernel.export_nids.emplace(var.nid, addr);
|
||||
}
|
||||
init_exported_vars(emuenv);
|
||||
|
||||
// Load main executable
|
||||
emuenv.self_path = !emuenv.cfg.self_path.empty() ? emuenv.cfg.self_path : EBOOT_PATH;
|
||||
@@ -733,7 +719,7 @@ bool handle_events(EmuEnvState &emuenv, GuiState &gui) {
|
||||
take_screenshot(emuenv);
|
||||
|
||||
if (sce_ctrl_btn != 0) {
|
||||
if (last_buttons.find(sce_ctrl_btn) != last_buttons.end()) {
|
||||
if (last_buttons.contains(sce_ctrl_btn)) {
|
||||
continue;
|
||||
}
|
||||
last_buttons.insert(sce_ctrl_btn);
|
||||
@@ -761,7 +747,7 @@ bool handle_events(EmuEnvState &emuenv, GuiState &gui) {
|
||||
|
||||
for (const auto &binding : get_controller_bindings_ext(emuenv)) {
|
||||
if (event.cbutton.button == binding.controller) {
|
||||
if (last_buttons.find(binding.button) != last_buttons.end()) {
|
||||
if (last_buttons.contains(binding.button)) {
|
||||
continue;
|
||||
}
|
||||
last_buttons.insert(binding.button);
|
||||
|
||||
@@ -46,8 +46,7 @@ struct FileInfo {
|
||||
int access_mode;
|
||||
|
||||
FileInfo()
|
||||
: vita_loc()
|
||||
, open_mode(SCE_O_RDONLY)
|
||||
: open_mode(SCE_O_RDONLY)
|
||||
, file_mode(SCE_SO_IFREG | SCE_SO_IROTH)
|
||||
, access_mode(SCE_S_IRUSR) {}
|
||||
};
|
||||
|
||||
@@ -66,15 +66,7 @@ namespace vfs {
|
||||
|
||||
bool read_file(const VitaIoDevice device, FileBuffer &buf, const fs::path &pref_path, const fs::path &vfs_file_path) {
|
||||
const auto host_file_path = device::construct_emulated_path(device, vfs_file_path, pref_path).generic_path();
|
||||
|
||||
fs::ifstream f{ host_file_path, fs::ifstream::binary };
|
||||
if (!f)
|
||||
return false;
|
||||
|
||||
f.unsetf(fs::ifstream::skipws);
|
||||
buf.reserve(fs::file_size(host_file_path));
|
||||
buf.insert(buf.begin(), std::istream_iterator<uint8_t>(f), std::istream_iterator<uint8_t>());
|
||||
return true;
|
||||
return fs_utils::read_data(host_file_path, buf);
|
||||
}
|
||||
|
||||
bool read_app_file(FileBuffer &buf, const fs::path &pref_path, const std::string &app_path, const fs::path &vfs_file_path) {
|
||||
|
||||
@@ -77,14 +77,10 @@ typedef std::unique_ptr<ThreadDataQueue<WaitingThreadData>> WaitingThreadQueuePt
|
||||
// NOTE: uid is copied to sync primitives here for debugging,
|
||||
// not really needed since they are put in std::map's
|
||||
struct SyncPrimitive {
|
||||
SceUID uid;
|
||||
|
||||
uint32_t attr;
|
||||
|
||||
SceUID uid{};
|
||||
uint32_t attr{};
|
||||
std::mutex mutex;
|
||||
|
||||
char name[KERNELOBJECT_MAX_NAME_LENGTH + 1];
|
||||
|
||||
virtual ~SyncPrimitive() = default;
|
||||
};
|
||||
|
||||
|
||||
@@ -555,9 +555,9 @@ enum TlsItems {
|
||||
TLS_SP_TOP = 2,
|
||||
TLS_SP_BOTTOM = 3,
|
||||
TLS_VFP_EXCEPTION = 4,
|
||||
TLS_RESERVED_5,
|
||||
TLS_RESERVED_6, // libc reserved longjump addr
|
||||
TLS_RESERVED_7, // libc reserved some memory address mask
|
||||
TLS_RESERVED_5 = 5,
|
||||
TLS_RESERVED_6 = 6, // libc reserved longjump addr
|
||||
TLS_RESERVED_7 = 7, // libc reserved some memory address mask
|
||||
TLS_CURRENT_PRIORITY = 8,
|
||||
TLS_CPU_AFFINITY_MASK = 9,
|
||||
TLS_NET_ERRNO = 0x40,
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
constexpr unsigned char THUMB_BREAKPOINT[2] = { 0x00, 0xBE };
|
||||
constexpr unsigned char ARM_BREAKPOINT[4] = { 0x70, 0x00, 0x20, 0xE1 };
|
||||
|
||||
inline bool is_thumb16(uint32_t inst) {
|
||||
inline static bool is_thumb16(uint32_t inst) {
|
||||
return (inst & 0xF8000000) < 0xE8000000;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
int CorenumAllocator::new_corenum() {
|
||||
const std::lock_guard<std::mutex> guard(lock);
|
||||
|
||||
int size = 1;
|
||||
uint32_t size = 1;
|
||||
return alloc.allocate_from(0, size);
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ static int SDLCALL thread_function(void *data) {
|
||||
assert(data != nullptr);
|
||||
const ThreadParams params = *static_cast<const ThreadParams *>(data);
|
||||
SDL_SemPost(params.host_may_destroy_params.get());
|
||||
const ThreadStatePtr thread = lock_and_find(params.thid, params.kernel->threads, params.kernel->mutex);
|
||||
const ThreadStatePtr thread = params.kernel->get_thread(params.thid);
|
||||
#ifdef TRACY_ENABLE
|
||||
if (!thread->name.empty()) {
|
||||
tracy::SetThreadName(thread->name.c_str());
|
||||
@@ -104,6 +104,9 @@ void KernelState::load_process_param(MemState &mem, Ptr<uint32_t> ptr) {
|
||||
return;
|
||||
}
|
||||
process_param = ptr.cast<SceProcessParam>();
|
||||
// VAR_NID(__sce_libcparam, 0xDF084DFA)
|
||||
// no memory leak because we don't allocate memory for this variable intially
|
||||
export_nids[0xDF084DFA] = process_param.get(mem)->sce_libc_param.address();
|
||||
}
|
||||
|
||||
void KernelState::set_memory_watch(bool enabled) {
|
||||
@@ -164,14 +167,14 @@ Ptr<Ptr<void>> KernelState::get_thread_tls_addr(MemState &mem, SceUID thread_id,
|
||||
|
||||
void KernelState::exit_delete_all_threads() {
|
||||
const std::lock_guard<std::mutex> lock(mutex);
|
||||
for (auto [_, thread] : threads) {
|
||||
for (auto &[_, thread] : threads) {
|
||||
thread->exit_delete();
|
||||
}
|
||||
}
|
||||
|
||||
void KernelState::pause_threads() {
|
||||
const std::lock_guard<std::mutex> lock(mutex);
|
||||
for (auto [_, thread] : threads) {
|
||||
for (auto &[_, thread] : threads) {
|
||||
paused_threads_status[thread->id] = thread->status;
|
||||
if (thread->status == ThreadStatus::run)
|
||||
thread->suspend();
|
||||
@@ -180,7 +183,7 @@ void KernelState::pause_threads() {
|
||||
|
||||
void KernelState::resume_threads() {
|
||||
const std::lock_guard<std::mutex> lock(mutex);
|
||||
for (auto [_, thread] : threads) {
|
||||
for (auto &[_, thread] : threads) {
|
||||
if (paused_threads_status[thread->id] == ThreadStatus::run)
|
||||
thread->resume();
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
#include <util/fs.h>
|
||||
#include <util/log.h>
|
||||
|
||||
#include <spdlog/fmt/fmt.h>
|
||||
#include <util/elf.h>
|
||||
// clang-format off
|
||||
#define SCE_ELF_DEFS_TARGET
|
||||
@@ -66,7 +65,7 @@ static bool load_var_imports(const uint32_t *nids, const Ptr<uint32_t> *entries,
|
||||
|
||||
if (kernel.debugger.log_imports) {
|
||||
const char *const name = import_name(nid);
|
||||
LOG_DEBUG("\tNID {} ({}). entry: {}, *entry: {}", log_hex(nid), name, log_hex(entry.address()), log_hex(*entry.get(mem)));
|
||||
LOG_DEBUG("\tNID {} ({}). entry: {}, *entry: {}", log_hex(nid), name, entry, log_hex(*entry.get(mem)));
|
||||
}
|
||||
|
||||
VarImportsHeader *const var_reloc_header = reinterpret_cast<VarImportsHeader *>(entry.get(mem));
|
||||
@@ -115,7 +114,7 @@ static bool unload_var_imports(const uint32_t *nids, const Ptr<uint32_t> *entrie
|
||||
// remove the binding info from the map
|
||||
VarBindingInfo binding_info{ var_reloc_entries, reloc_size, module_id };
|
||||
auto range = kernel.var_binding_infos.equal_range(nid);
|
||||
for (auto it = range.first; it != range.second; it++) {
|
||||
for (auto it = range.first; it != range.second; ++it) {
|
||||
if (memcmp(&it->second, &binding_info, sizeof(VarBindingInfo)) == 0) {
|
||||
kernel.var_binding_infos.erase(it);
|
||||
break;
|
||||
@@ -173,7 +172,7 @@ static bool unload_func_imports(const uint32_t *nids, const Ptr<uint32_t> *entri
|
||||
|
||||
// remove the stub from the table
|
||||
auto range = kernel.func_binding_infos.equal_range(nid);
|
||||
for (auto it = range.first; it != range.second; it++) {
|
||||
for (auto it = range.first; it != range.second; ++it) {
|
||||
if (it->second == entry.address()) {
|
||||
kernel.func_binding_infos.erase(it);
|
||||
break;
|
||||
@@ -281,7 +280,6 @@ static bool unload_func_exports(SceKernelModuleInfo *kernel_module_info, const u
|
||||
const std::lock_guard<std::mutex> guard(kernel.export_nids_mutex);
|
||||
for (size_t i = 0; i < count; ++i) {
|
||||
const uint32_t nid = nids[i];
|
||||
const Ptr<uint32_t> entry = entries[i];
|
||||
|
||||
if (nid == NID_MODULE_START || nid == NID_MODULE_STOP || nid == NID_MODULE_EXIT)
|
||||
continue;
|
||||
@@ -289,7 +287,7 @@ static bool unload_func_exports(SceKernelModuleInfo *kernel_module_info, const u
|
||||
kernel.export_nids.erase(nid);
|
||||
// invalidate all lle nid calls
|
||||
auto range = kernel.func_binding_infos.equal_range(nid);
|
||||
for (auto it = range.first; it != range.second; it++) {
|
||||
for (auto it = range.first; it != range.second; ++it) {
|
||||
Address entry = it->second;
|
||||
uint32_t *stub = Ptr<uint32_t>(entry).get(mem);
|
||||
|
||||
@@ -340,23 +338,21 @@ static bool load_var_exports(const uint32_t *nids, const Ptr<uint32_t> *entries,
|
||||
}
|
||||
kernel.export_nids[nid] = entry.address();
|
||||
|
||||
bool reloc_success = true;
|
||||
auto range = kernel.var_binding_infos.equal_range(nid);
|
||||
for (auto i = range.first; i != range.second; ++i) {
|
||||
auto &var_binding_info = i->second;
|
||||
for (auto j = range.first; j != range.second; ++j) {
|
||||
auto &var_binding_info = j->second;
|
||||
if (var_binding_info.size == 0)
|
||||
continue;
|
||||
|
||||
SegmentInfosForReloc seg;
|
||||
const auto &module_info = kernel.loaded_modules[kernel.module_uid_by_nid[var_binding_info.module_nid]];
|
||||
if (!module_info) {
|
||||
reloc_success = false;
|
||||
LOG_ERROR("Module not found by nid: {} uid: {}", log_hex(var_binding_info.module_nid), kernel.module_uid_by_nid[var_binding_info.module_nid]);
|
||||
} else {
|
||||
for (int i = 0; i < MODULE_INFO_NUM_SEGMENTS; i++) {
|
||||
const auto &segment = module_info->info.segments[i];
|
||||
for (int k = 0; k < MODULE_INFO_NUM_SEGMENTS; k++) {
|
||||
const auto &segment = module_info->info.segments[k];
|
||||
if (segment.size > 0) {
|
||||
seg[i] = { segment.vaddr.address(), 0, segment.memsz }; // p_vaddr is not used in variable relocations
|
||||
seg[k] = { segment.vaddr.address(), 0, segment.memsz }; // p_vaddr is not used in variable relocations
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -371,7 +367,6 @@ static bool load_var_exports(const uint32_t *nids, const Ptr<uint32_t> *entries,
|
||||
|
||||
if (!seg.empty()) {
|
||||
if (!relocate(var_binding_info.entries, var_binding_info.size, seg, mem, true, entry.address())) {
|
||||
reloc_success = false;
|
||||
LOG_ERROR("Failed to relocate late binding info");
|
||||
}
|
||||
}
|
||||
@@ -402,9 +397,8 @@ static bool unload_var_exports(const uint32_t *nids, const Ptr<uint32_t> *entrie
|
||||
// Use same stub for other var imports
|
||||
kernel.export_nids[nid] = entry.address();
|
||||
|
||||
bool reloc_success = true;
|
||||
auto range = kernel.var_binding_infos.equal_range(nid);
|
||||
for (auto it = range.first; it != range.second; it++) {
|
||||
for (auto it = range.first; it != range.second; ++it) {
|
||||
auto &var_binding_info = it->second;
|
||||
if (var_binding_info.size == 0)
|
||||
continue;
|
||||
@@ -412,20 +406,18 @@ static bool unload_var_exports(const uint32_t *nids, const Ptr<uint32_t> *entrie
|
||||
SegmentInfosForReloc seg;
|
||||
const auto &module_info = kernel.loaded_modules[kernel.module_uid_by_nid[var_binding_info.module_nid]];
|
||||
if (!module_info) {
|
||||
reloc_success = false;
|
||||
LOG_ERROR("Module not found by nid: {} uid: {}", log_hex(var_binding_info.module_nid), kernel.module_uid_by_nid[var_binding_info.module_nid]);
|
||||
} else {
|
||||
for (int i = 0; i < MODULE_INFO_NUM_SEGMENTS; i++) {
|
||||
const auto &segment = module_info->info.segments[i];
|
||||
for (int k = 0; k < MODULE_INFO_NUM_SEGMENTS; k++) {
|
||||
const auto &segment = module_info->info.segments[k];
|
||||
if (segment.size > 0) {
|
||||
seg[i] = { segment.vaddr.address(), 0, segment.memsz }; // p_vaddr is not used in variable relocations
|
||||
seg[k] = { segment.vaddr.address(), 0, segment.memsz }; // p_vaddr is not used in variable relocations
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!seg.empty()) {
|
||||
if (!relocate(var_binding_info.entries, var_binding_info.size, seg, mem, true, entry.address())) {
|
||||
reloc_success = false;
|
||||
LOG_ERROR("Failed to relocate late binding info");
|
||||
}
|
||||
}
|
||||
@@ -686,9 +678,7 @@ SceUID load_self(KernelState &kernel, MemState &mem, const void *self, const std
|
||||
const auto end = dump_segments[last_index].p_vaddr + dump_segments[last_index].p_filesz;
|
||||
const auto elf_name = fs::path(self_path).filename().stem().string();
|
||||
const auto filename = dump_dir / fmt::format("{}-{}_{}.elf", log_hex_full(start), log_hex_full(end), elf_name);
|
||||
fs::ofstream out(filename, std::ios::out | std::ios::binary);
|
||||
out.write(reinterpret_cast<char *>(dump_elf.data()), dump_elf.size());
|
||||
out.close();
|
||||
fs_utils::dump_data(filename, dump_elf.data(), dump_elf.size());
|
||||
}
|
||||
|
||||
const unsigned int module_info_segment_index = elf.e_entry >> 30;
|
||||
@@ -721,7 +711,7 @@ SceUID load_self(KernelState &kernel, MemState &mem, const void *self, const std
|
||||
sceKernelModuleInfo->extab_top = Ptr<const void>(module_info->extab_top);
|
||||
sceKernelModuleInfo->extab_btm = Ptr<const void>(module_info->extab_end);
|
||||
|
||||
sceKernelModuleInfo->tlsInit = Ptr<const void>((!module_info->tls_start ? 0 : (module_info_segment_address.address() + module_info->tls_start)));
|
||||
sceKernelModuleInfo->tlsInit = Ptr<const void>(!module_info->tls_start ? 0 : (module_info_segment_address.address() + module_info->tls_start));
|
||||
sceKernelModuleInfo->tlsInitSize = module_info->tls_filesz;
|
||||
sceKernelModuleInfo->tlsAreaSize = module_info->tls_memsz;
|
||||
|
||||
|
||||
@@ -29,27 +29,27 @@ static constexpr bool LOG_SYNC_PRIMITIVES = false;
|
||||
// * Helpers *
|
||||
// ***********
|
||||
|
||||
inline int unknown_mutex_id(const char *export_name, SyncWeight weight) {
|
||||
inline static int unknown_mutex_id(const char *export_name, SyncWeight weight) {
|
||||
if (weight == SyncWeight::Light)
|
||||
return RET_ERROR(SCE_KERNEL_ERROR_UNKNOWN_LW_MUTEX_ID);
|
||||
return RET_ERROR(SCE_KERNEL_ERROR_UNKNOWN_MUTEX_ID);
|
||||
}
|
||||
|
||||
inline int unknown_cond_id(const char *export_name, SyncWeight weight) {
|
||||
inline static int unknown_cond_id(const char *export_name, SyncWeight weight) {
|
||||
if (weight == SyncWeight::Light)
|
||||
return RET_ERROR(SCE_KERNEL_ERROR_UNKNOWN_LW_COND_ID);
|
||||
return RET_ERROR(SCE_KERNEL_ERROR_UNKNOWN_COND_ID);
|
||||
}
|
||||
|
||||
inline MutexPtrs &get_mutexes(KernelState &kernel, SyncWeight weight) {
|
||||
inline static MutexPtrs &get_mutexes(KernelState &kernel, SyncWeight weight) {
|
||||
return weight == SyncWeight::Light ? kernel.lwmutexes : kernel.mutexes;
|
||||
}
|
||||
|
||||
inline CondvarPtrs &get_condvars(KernelState &kernel, SyncWeight weight) {
|
||||
inline static CondvarPtrs &get_condvars(KernelState &kernel, SyncWeight weight) {
|
||||
return weight == SyncWeight::Light ? kernel.lwcondvars : kernel.condvars;
|
||||
}
|
||||
|
||||
inline int find_mutex(MutexPtr &mutex_out, MutexPtrs **mutexes_out, KernelState &kernel, const char *export_name, SceUID mutexid, SyncWeight weight) {
|
||||
inline static int find_mutex(MutexPtr &mutex_out, MutexPtrs **mutexes_out, KernelState &kernel, const char *export_name, SceUID mutexid, SyncWeight weight) {
|
||||
MutexPtrs &mutexes = get_mutexes(kernel, weight);
|
||||
mutex_out = lock_and_find(mutexid, mutexes, kernel.mutex);
|
||||
if (!mutex_out) {
|
||||
@@ -62,7 +62,7 @@ inline int find_mutex(MutexPtr &mutex_out, MutexPtrs **mutexes_out, KernelState
|
||||
return SCE_KERNEL_OK;
|
||||
}
|
||||
|
||||
inline int find_condvar(CondvarPtr &condvar_out, CondvarPtrs **condvars_out, KernelState &kernel, const char *export_name, SceUID condid, SyncWeight weight) {
|
||||
inline static int find_condvar(CondvarPtr &condvar_out, CondvarPtrs **condvars_out, KernelState &kernel, const char *export_name, SceUID condid, SyncWeight weight) {
|
||||
CondvarPtrs &condvars = get_condvars(kernel, weight);
|
||||
condvar_out = lock_and_find(condid, condvars, kernel.mutex);
|
||||
if (!condvar_out) {
|
||||
@@ -77,7 +77,7 @@ inline int find_condvar(CondvarPtr &condvar_out, CondvarPtrs **condvars_out, Ker
|
||||
|
||||
// TODO: Write remaining time to timeout ptr when it's successfully signaled
|
||||
// Assumes primitive_lock is locked and thread_lock is unlocked
|
||||
inline int handle_timeout(const ThreadStatePtr &thread, std::unique_lock<std::mutex> &thread_lock,
|
||||
inline static int handle_timeout(const ThreadStatePtr &thread, std::unique_lock<std::mutex> &thread_lock,
|
||||
std::unique_lock<std::mutex> &primitive_lock, WaitingThreadQueuePtr &queue,
|
||||
const ThreadDataQueueInterator<WaitingThreadData> &data_it, const char *export_name,
|
||||
SceUInt *const timeout) {
|
||||
@@ -559,7 +559,7 @@ SceUID mutex_create(SceUID *uid_out, KernelState &kernel, MemState &mem, const c
|
||||
mutex->attr = attr;
|
||||
mutex->owner = nullptr;
|
||||
if (init_count > 0) {
|
||||
const ThreadStatePtr thread = lock_and_find(thread_id, kernel.threads, kernel.mutex);
|
||||
const ThreadStatePtr thread = kernel.get_thread(thread_id);
|
||||
mutex->owner = thread;
|
||||
}
|
||||
if (mutex->attr & SCE_KERNEL_ATTR_TH_PRIO) {
|
||||
@@ -611,14 +611,14 @@ SceUID mutex_find(KernelState &kernel, const char *export_name, const char *pNam
|
||||
return RET_ERROR(SCE_KERNEL_ERROR_UID_CANNOT_FIND_BY_NAME);
|
||||
}
|
||||
|
||||
inline int mutex_lock_impl(KernelState &kernel, MemState &mem, const char *export_name, SceUID thread_id, int lock_count, MutexPtr &mutex, SyncWeight weight, SceUInt *timeout, bool only_try) {
|
||||
inline static int mutex_lock_impl(KernelState &kernel, MemState &mem, const char *export_name, SceUID thread_id, int lock_count, MutexPtr &mutex, SyncWeight weight, SceUInt *timeout, bool only_try) {
|
||||
if (LOG_SYNC_PRIMITIVES) {
|
||||
LOG_DEBUG("{}: uid: {} thread_id: {} name: \"{}\" attr: {} lock_count: {} timeout: {} waiting_threads: {}",
|
||||
export_name, mutex->uid, thread_id, mutex->name, mutex->attr, mutex->lock_count, timeout ? *timeout : 0,
|
||||
mutex->waiting_threads->size());
|
||||
}
|
||||
|
||||
const ThreadStatePtr thread = lock_and_find(thread_id, kernel.threads, kernel.mutex);
|
||||
const ThreadStatePtr thread = kernel.get_thread(thread_id);
|
||||
|
||||
std::unique_lock<std::mutex> mutex_lock(mutex->mutex);
|
||||
|
||||
@@ -709,8 +709,8 @@ int mutex_try_lock(KernelState &kernel, MemState &mem, const char *export_name,
|
||||
return mutex_lock_impl(kernel, mem, export_name, thread_id, lock_count, mutex, weight, nullptr, true);
|
||||
}
|
||||
|
||||
inline int mutex_unlock_impl(KernelState &kernel, const char *export_name, SceUID thread_id, int unlock_count, MutexPtr &mutex) {
|
||||
const ThreadStatePtr current_thread = lock_and_find(thread_id, kernel.threads, kernel.mutex);
|
||||
inline static int mutex_unlock_impl(KernelState &kernel, const char *export_name, SceUID thread_id, int unlock_count, MutexPtr &mutex) {
|
||||
const ThreadStatePtr current_thread = kernel.get_thread(thread_id);
|
||||
|
||||
const std::lock_guard<std::mutex> mutex_lock(mutex->mutex);
|
||||
|
||||
@@ -886,7 +886,7 @@ SceInt32 rwlock_lock(KernelState &kernel, MemState &mem, const char *export_name
|
||||
}
|
||||
|
||||
SceInt32 rwlock_unlock(KernelState &kernel, MemState &mem, const char *export_name, SceUID thread_id, SceUID lock_id, bool is_write) {
|
||||
const ThreadStatePtr current_thread = lock_and_find(thread_id, kernel.threads, kernel.mutex);
|
||||
const ThreadStatePtr current_thread = kernel.get_thread(thread_id);
|
||||
const RWLockPtr rwlock = lock_and_find(lock_id, kernel.rwlocks, kernel.mutex);
|
||||
|
||||
if (!rwlock)
|
||||
@@ -1040,7 +1040,7 @@ SceInt32 semaphore_wait(KernelState &kernel, const char *export_name, SceUID thr
|
||||
pTimeout ? *pTimeout : 0, semaphore->waiting_threads->size());
|
||||
}
|
||||
|
||||
const ThreadStatePtr thread = lock_and_find(thread_id, kernel.threads, kernel.mutex);
|
||||
const ThreadStatePtr thread = kernel.get_thread(thread_id);
|
||||
|
||||
std::unique_lock<std::mutex> semaphore_lock(semaphore->mutex);
|
||||
|
||||
@@ -1236,7 +1236,7 @@ int condvar_wait(KernelState &kernel, MemState &mem, const char *export_name, Sc
|
||||
timeout ? *timeout : 0, condvar->waiting_threads->size());
|
||||
}
|
||||
|
||||
const ThreadStatePtr thread = lock_and_find(thread_id, kernel.threads, kernel.mutex);
|
||||
const ThreadStatePtr thread = kernel.get_thread(thread_id);
|
||||
|
||||
std::unique_lock<std::mutex> condition_variable_lock(condvar->mutex);
|
||||
|
||||
@@ -1422,7 +1422,7 @@ static int eventflag_waitorpoll(KernelState &kernel, const char *export_name, Sc
|
||||
return RET_ERROR(SCE_KERNEL_ERROR_EVF_MULTI);
|
||||
}
|
||||
|
||||
const ThreadStatePtr thread = lock_and_find(thread_id, kernel.threads, kernel.mutex);
|
||||
const ThreadStatePtr thread = kernel.get_thread(thread_id);
|
||||
|
||||
std::unique_lock<std::mutex> event_lock(event->mutex);
|
||||
|
||||
@@ -1693,7 +1693,7 @@ SceSize msgpipe_recv(KernelState &kernel, const char *export_name, SceUID thread
|
||||
}
|
||||
};
|
||||
|
||||
const ThreadStatePtr thread = lock_and_find(thread_id, kernel.threads, kernel.mutex);
|
||||
const ThreadStatePtr thread = kernel.get_thread(thread_id);
|
||||
std::unique_lock msgpipe_lock(msgpipe->mutex);
|
||||
// check in case of delete happens while waiting (un)lock
|
||||
if (msgpipe->beingDeleted) {
|
||||
@@ -1808,7 +1808,7 @@ SceSize msgpipe_send(KernelState &kernel, const char *export_name, SceUID thread
|
||||
}
|
||||
};
|
||||
|
||||
const ThreadStatePtr thread = lock_and_find(thread_id, kernel.threads, kernel.mutex);
|
||||
const ThreadStatePtr thread = kernel.get_thread(thread_id);
|
||||
std::unique_lock<std::mutex> msgpipe_lock(msgpipe->mutex);
|
||||
// check in case of delete happens while waiting (un)lock
|
||||
if (msgpipe->beingDeleted) {
|
||||
|
||||
@@ -358,7 +358,7 @@ void init_lang(LangState &lang, EmuEnvState &emuenv) {
|
||||
if (!keyboard_lang_ime.empty()) {
|
||||
lang_ime.clear();
|
||||
const auto op = [](const auto &lang) {
|
||||
return std::make_pair(SceImeLanguage(lang.attribute("id").as_ullong()), lang.text().as_string());
|
||||
return std::make_pair(static_cast<SceImeLanguage>(lang.attribute("id").as_ullong()), lang.text().as_string());
|
||||
};
|
||||
std::transform(std::begin(keyboard_lang_ime), std::end(keyboard_lang_ime), std::back_inserter(lang_ime), op);
|
||||
}
|
||||
|
||||
+1
-1
@@ -396,7 +396,7 @@ int main(int argc, char *argv[]) {
|
||||
draw_app_background(gui, emuenv);
|
||||
|
||||
emuenv.renderer->precompile_shader(hash);
|
||||
gui::draw_pre_compiling_shaders_progress(gui, emuenv, uint32_t(emuenv.renderer->shaders_cache_hashs.size()));
|
||||
gui::draw_pre_compiling_shaders_progress(gui, emuenv, static_cast<uint32_t>(emuenv.renderer->shaders_cache_hashs.size()));
|
||||
|
||||
gui::draw_end(gui);
|
||||
emuenv.renderer->swap_window(emuenv.window.get());
|
||||
|
||||
@@ -25,7 +25,7 @@ struct BitmapAllocator {
|
||||
std::size_t max_offset;
|
||||
|
||||
protected:
|
||||
int force_fill(const std::uint32_t offset, const int size, const bool or_mode = false);
|
||||
int force_fill(const std::uint32_t offset, const std::uint32_t size, const bool or_mode = false);
|
||||
|
||||
public:
|
||||
BitmapAllocator() = default;
|
||||
@@ -33,9 +33,9 @@ public:
|
||||
|
||||
void set_maximum(const std::size_t total_bits);
|
||||
|
||||
int allocate_from(const std::uint32_t start_offset, int &size, const bool best_fit = false);
|
||||
int allocate_at(const std::uint32_t start_offset, int size);
|
||||
void free(const std::uint32_t offset, const int size);
|
||||
int allocate_from(const std::uint32_t start_offset, std::uint32_t &size, const bool best_fit = false);
|
||||
int allocate_at(const std::uint32_t start_offset, std::uint32_t size);
|
||||
void free(const std::uint32_t offset, const std::uint32_t size);
|
||||
void reset();
|
||||
|
||||
// Count free bits in [offset, offset_end) (exclusive)
|
||||
|
||||
@@ -24,9 +24,7 @@
|
||||
template <class T>
|
||||
class Ptr {
|
||||
public:
|
||||
Ptr()
|
||||
: addr(0) {
|
||||
}
|
||||
Ptr() = default;
|
||||
|
||||
explicit Ptr(Address address)
|
||||
: addr(address) {
|
||||
@@ -99,7 +97,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
Address addr;
|
||||
Address addr{};
|
||||
};
|
||||
|
||||
static_assert(sizeof(Ptr<const void>) == 4, "Size of Ptr isn't 4 bytes.");
|
||||
|
||||
@@ -41,10 +41,10 @@ void BitmapAllocator::reset() {
|
||||
words.clear();
|
||||
}
|
||||
|
||||
int BitmapAllocator::force_fill(const std::uint32_t offset, const int size, const bool or_mode) {
|
||||
int BitmapAllocator::force_fill(const std::uint32_t offset, const std::uint32_t size, const bool or_mode) {
|
||||
std::uint32_t *word = &words[0] + (offset >> 5);
|
||||
const std::uint32_t set_bit = offset & 31;
|
||||
int end_bit = static_cast<int>(set_bit + size);
|
||||
std::uint32_t end_bit = set_bit + size;
|
||||
|
||||
std::uint32_t wval = *word;
|
||||
|
||||
@@ -74,21 +74,22 @@ int BitmapAllocator::force_fill(const std::uint32_t offset, const int size, cons
|
||||
}
|
||||
|
||||
word += 1;
|
||||
|
||||
if (end_bit < 32)
|
||||
break;
|
||||
// We only need to be careful with the first word, since it only fills
|
||||
// some first bits. We should fully fill with other word, so set the mask full
|
||||
mask = 0xFFFFFFFFU;
|
||||
end_bit -= 32;
|
||||
|
||||
if (end_bit < 32) {
|
||||
mask = ~(mask >> static_cast<std::uint32_t>(end_bit));
|
||||
mask = ~(mask >> end_bit);
|
||||
}
|
||||
}
|
||||
|
||||
return std::min<int>(size, (words.size() << 5) - set_bit);
|
||||
}
|
||||
|
||||
void BitmapAllocator::free(const std::uint32_t offset, const int size) {
|
||||
void BitmapAllocator::free(const std::uint32_t offset, const std::uint32_t size) {
|
||||
if (static_cast<std::size_t>(offset) >= max_offset) {
|
||||
return;
|
||||
}
|
||||
@@ -96,7 +97,7 @@ void BitmapAllocator::free(const std::uint32_t offset, const int size) {
|
||||
force_fill(offset, size, true);
|
||||
}
|
||||
|
||||
int BitmapAllocator::allocate_from(const std::uint32_t start_offset, int &size, const bool best_fit) {
|
||||
int BitmapAllocator::allocate_from(const std::uint32_t start_offset, std::uint32_t &size, const bool best_fit) {
|
||||
if (words.empty()) {
|
||||
return -1;
|
||||
}
|
||||
@@ -176,7 +177,7 @@ int BitmapAllocator::allocate_from(const std::uint32_t start_offset, int &size,
|
||||
return -1;
|
||||
}
|
||||
|
||||
int BitmapAllocator::allocate_at(const std::uint32_t start_offset, int size) {
|
||||
int BitmapAllocator::allocate_at(const std::uint32_t start_offset, std::uint32_t size) {
|
||||
if (free_slot_count(start_offset, start_offset + size) != size) {
|
||||
return -1;
|
||||
}
|
||||
@@ -185,11 +186,18 @@ int BitmapAllocator::allocate_at(const std::uint32_t start_offset, int size) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef __cpp_lib_bitops
|
||||
#include <bit>
|
||||
static int number_of_set_bits(std::uint32_t i) {
|
||||
return std::popcount(i);
|
||||
}
|
||||
#else
|
||||
static int number_of_set_bits(std::uint32_t i) {
|
||||
i = i - ((i >> 1) & 0x55555555);
|
||||
i = (i & 0x33333333) + ((i >> 2) & 0x33333333);
|
||||
return (((i + (i >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24;
|
||||
}
|
||||
#endif
|
||||
|
||||
int BitmapAllocator::free_slot_count(const std::uint32_t offset, const std::uint32_t offset_end) const {
|
||||
if (offset >= offset_end) {
|
||||
|
||||
@@ -45,7 +45,7 @@ constexpr bool PAGE_NAME_TRACKING = false;
|
||||
static AccessViolationHandler access_violation_handler;
|
||||
static void register_access_violation_handler(const AccessViolationHandler &handler);
|
||||
|
||||
static Address alloc_inner(MemState &state, uint32_t start_page, int page_count, const char *name, const bool force);
|
||||
static Address alloc_inner(MemState &state, uint32_t start_page, uint32_t page_count, const char *name, const bool force);
|
||||
static void delete_memory(uint8_t *memory);
|
||||
|
||||
#ifdef _WIN32
|
||||
@@ -152,7 +152,7 @@ bool is_valid_addr_range(const MemState &state, Address start, Address end) {
|
||||
return state.allocator.free_slot_count(start_page, end_page) == 0;
|
||||
}
|
||||
|
||||
static Address alloc_inner(MemState &state, uint32_t start_page, int page_count, const char *name, const bool force) {
|
||||
static Address alloc_inner(MemState &state, uint32_t start_page, uint32_t page_count, const char *name, const bool force) {
|
||||
int page_num;
|
||||
if (force) {
|
||||
if (state.allocator.allocate_at(start_page, page_count) < 0) {
|
||||
@@ -165,7 +165,7 @@ static Address alloc_inner(MemState &state, uint32_t start_page, int page_count,
|
||||
return 0;
|
||||
}
|
||||
|
||||
const int size = page_count * state.page_size;
|
||||
const uint32_t size = page_count * state.page_size;
|
||||
const Address addr = page_num * state.page_size;
|
||||
uint8_t *const memory = &state.memory[addr];
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ TEST(bitmap_allocator, one_bit_allocation) {
|
||||
BitmapAllocator allocator(KiB(5));
|
||||
|
||||
for (int i = 0; i < KiB(5); ++i) {
|
||||
int size = 1;
|
||||
uint32_t size = 1;
|
||||
int inoffset = 31 - i & 31;
|
||||
int bit = (allocator.words[i >> 5] & (1 << inoffset)) >> inoffset;
|
||||
ASSERT_EQ(bit, 1);
|
||||
@@ -41,7 +41,7 @@ TEST(bitmap_allocator, one_bit_free_slot) {
|
||||
|
||||
ASSERT_EQ(allocator.free_slot_count(0, KiB(5)), KiB(5));
|
||||
for (int i = 0; i < KiB(5); ++i) {
|
||||
int size = 1;
|
||||
uint32_t size = 1;
|
||||
ASSERT_EQ(allocator.free_slot_count(i, i + 1), 1);
|
||||
int ret = allocator.allocate_from(i, size, false);
|
||||
ASSERT_EQ(ret, i);
|
||||
@@ -55,7 +55,7 @@ TEST(bitmap_allocator, free_slot_count_aligned) {
|
||||
BitmapAllocator allocator(KiB(5));
|
||||
|
||||
for (int i = 0; i < KiB(5); i += 2) {
|
||||
int size = 2;
|
||||
uint32_t size = 2;
|
||||
ASSERT_EQ(allocator.free_slot_count(i, i + 2), 2);
|
||||
int ret = allocator.allocate_from(i, size, false);
|
||||
ASSERT_EQ(ret, i);
|
||||
@@ -68,7 +68,7 @@ TEST(bitmap_allocator, free_slot_count_unaligned) {
|
||||
BitmapAllocator allocator(KiB(5));
|
||||
|
||||
for (int i = 0; KiB(5) - i >= 3; i += 3) {
|
||||
int size = 3;
|
||||
uint32_t size = 3;
|
||||
ASSERT_EQ(allocator.free_slot_count(i, i + 3), 3);
|
||||
int ret = allocator.allocate_from(i, size, false);
|
||||
ASSERT_EQ(ret, i);
|
||||
@@ -82,7 +82,7 @@ TEST(bitmap_allocator, allocate_at) {
|
||||
|
||||
ASSERT_EQ(allocator.free_slot_count(0, KiB(5)), KiB(5));
|
||||
for (int i = 0; KiB(5) - i >= 4; i += 4) {
|
||||
int size = 4;
|
||||
uint32_t size = 4;
|
||||
ASSERT_EQ(allocator.free_slot_count(i, i + 4), 4);
|
||||
allocator.allocate_at(i, 4);
|
||||
ASSERT_EQ(allocator.free_slot_count(i, i + 4), 0);
|
||||
@@ -96,7 +96,7 @@ TEST(bitmap_allocator, allocate_at) {
|
||||
TEST(bitmap_allocator, alloc_32) {
|
||||
BitmapAllocator allocator(KiB(5));
|
||||
for (int i = 0; i < KiB(5); i += 32) {
|
||||
int size = 32;
|
||||
uint32_t size = 32;
|
||||
ASSERT_EQ(allocator.free_slot_count(i, i + 32), 32);
|
||||
int ret = allocator.allocate_from(i, size, false);
|
||||
ASSERT_EQ(ret, i);
|
||||
@@ -114,7 +114,7 @@ TEST(bitmap_allocator, battle_test) {
|
||||
BitmapAllocator allocator(MEM_SIZE);
|
||||
struct Page {
|
||||
int n;
|
||||
int size;
|
||||
uint32_t size;
|
||||
};
|
||||
|
||||
std::list<Page> pages;
|
||||
@@ -130,7 +130,7 @@ TEST(bitmap_allocator, battle_test) {
|
||||
};
|
||||
|
||||
for (int i = 0; i < TEST_EPOCH; ++i) {
|
||||
int size = rand() % MAX_MEM_CHUNK_SIZE + 1;
|
||||
uint32_t size = rand() % MAX_MEM_CHUNK_SIZE + 1;
|
||||
while (allocator.free_slot_count(0, MEM_SIZE) < size) {
|
||||
free_any_page();
|
||||
}
|
||||
@@ -158,7 +158,7 @@ TEST(bitmap_allocator, no_best_fit_only_one_fit) {
|
||||
// Bitmap: 1000 0101 0001 0001 0101 0001 00[11 1]001
|
||||
alloc.words[0] = 0b10000101000100010101000100111001;
|
||||
|
||||
int to_alloc = 3;
|
||||
uint32_t to_alloc = 3;
|
||||
ASSERT_EQ(alloc.allocate_from(0, to_alloc), 26);
|
||||
ASSERT_EQ(to_alloc, 3);
|
||||
|
||||
@@ -172,7 +172,7 @@ TEST(bitmap_allocator, no_best_fit_multiple_fit) {
|
||||
// Bitmap 1: 1000 0[111] 1001 0001 0101 0001 0011 1001
|
||||
alloc.words[0] = 0b10000111100100010101000100111001;
|
||||
|
||||
int to_alloc = 3;
|
||||
uint32_t to_alloc = 3;
|
||||
ASSERT_EQ(alloc.allocate_from(0, to_alloc), 5);
|
||||
ASSERT_EQ(to_alloc, 3);
|
||||
|
||||
@@ -186,7 +186,7 @@ TEST(bitmap_allocator, no_best_fit_alloc_across) {
|
||||
alloc.words[0] = 0b111;
|
||||
alloc.words[1] = 0b11100000000000000000000000000000;
|
||||
|
||||
int to_alloc = 5;
|
||||
uint32_t to_alloc = 5;
|
||||
ASSERT_EQ(alloc.allocate_from(0, to_alloc), 29);
|
||||
ASSERT_EQ(to_alloc, 5);
|
||||
|
||||
@@ -200,7 +200,7 @@ TEST(bitmap_allocator, best_fit_multiple_fit) {
|
||||
// Bitmap 1: 1000 0111 1001 0001 0101 0001 00[11 1]001
|
||||
alloc.words[0] = 0b10000111100100010101000100111001;
|
||||
|
||||
int to_alloc = 3;
|
||||
uint32_t to_alloc = 3;
|
||||
ASSERT_EQ(alloc.allocate_from(0, to_alloc, true), 26);
|
||||
ASSERT_EQ(to_alloc, 3);
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
|
||||
using ImportFn = std::function<void(EmuEnvState &emuenv, CPUState &cpu, SceUID thread_id)>;
|
||||
using ImportVarFactory = std::function<Address(EmuEnvState &emuenv)>;
|
||||
using LibraryInitFn = std::function<void(EmuEnvState &emuenv)>;
|
||||
|
||||
// Function returns a value that is written to CPU registers.
|
||||
template <typename Ret, typename... Args, size_t... indices>
|
||||
|
||||
@@ -46,3 +46,8 @@
|
||||
DECL_VAR_EXPORT(name); \
|
||||
extern const ImportVarFactory import_##name = export_##name; \
|
||||
DECL_VAR_EXPORT(name)
|
||||
|
||||
#define LIBRARY_INIT(name) \
|
||||
static void export_library_init_##name(EmuEnvState &emuenv); \
|
||||
extern const LibraryInitFn import_library_init_##name = export_library_init_##name; \
|
||||
static void export_library_init_##name(EmuEnvState &emuenv)
|
||||
|
||||
@@ -179,7 +179,7 @@ bool is_lle_module(SceSysmoduleModuleId module_id, EmuEnvState &emuenv) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<std::string> init_auto_lle_module_names() {
|
||||
static std::vector<std::string> init_auto_lle_module_names() {
|
||||
std::vector<std::string> auto_lle_module_names = { "libc", "libSceFt2", "libpvf" };
|
||||
for (const auto module_id : auto_lle_modules) {
|
||||
for (const auto module : sysmodule_paths[module_id]) {
|
||||
|
||||
@@ -22,8 +22,6 @@
|
||||
|
||||
#include <kernel/state.h>
|
||||
|
||||
#include <modules/module_parent.h>
|
||||
|
||||
#include <util/tracy.h>
|
||||
|
||||
TRACY_MODULE_NAME(SceSharedFB);
|
||||
|
||||
@@ -378,8 +378,7 @@ EXPORT(SceInt32, sceAppUtilSaveDataSlotSearch, SceAppUtilWorkBuffer *workBuf, co
|
||||
case SCE_APPUTIL_SAVEDATA_SLOT_SEARCH_TYPE_EXIST_SLOT:
|
||||
if (fd > 0) {
|
||||
if (slotList) {
|
||||
SceAppUtilSaveDataSlotParam param;
|
||||
memset(¶m, 0, sizeof(SceAppUtilSaveDataSlotParam));
|
||||
SceAppUtilSaveDataSlotParam param{};
|
||||
read_file(¶m, emuenv.io, fd, sizeof(SceAppUtilSaveDataSlotParam), export_name);
|
||||
slotList[result->hitNum].userParam = param.userParam;
|
||||
slotList[result->hitNum].status = param.status;
|
||||
|
||||
@@ -194,7 +194,7 @@ EXPORT(int, sceAudioOutOutput, int port, const void *buf) {
|
||||
return RET_ERROR(SCE_AUDIO_OUT_ERROR_INVALID_PORT);
|
||||
}
|
||||
|
||||
const ThreadStatePtr thread = lock_and_find(thread_id, emuenv.kernel.threads, emuenv.kernel.mutex);
|
||||
const ThreadStatePtr thread = emuenv.kernel.get_thread(thread_id);
|
||||
if (!thread) {
|
||||
return RET_ERROR(SCE_AUDIO_OUT_ERROR_INVALID_PORT);
|
||||
}
|
||||
|
||||
@@ -17,8 +17,6 @@
|
||||
|
||||
#include "SceAudiodecUser.h"
|
||||
|
||||
#include <modules/module_parent.h>
|
||||
|
||||
#include <audio/state.h>
|
||||
#include <codec/state.h>
|
||||
#include <kernel/state.h>
|
||||
|
||||
@@ -226,7 +226,7 @@ static Ptr<uint8_t> get_buffer(const PlayerPtr &player, MediaType media_type,
|
||||
return buffer;
|
||||
}
|
||||
|
||||
void run_event_callback(EmuEnvState &emuenv, const ThreadStatePtr &thread, const PlayerPtr &player_info, uint32_t event_id, uint32_t source_id, Ptr<void> event_data) {
|
||||
static void run_event_callback(EmuEnvState &emuenv, const ThreadStatePtr &thread, const PlayerPtr &player_info, uint32_t event_id, uint32_t source_id, Ptr<void> event_data) {
|
||||
if (player_info->event_manager.event_callback) {
|
||||
thread->run_callback(player_info->event_manager.event_callback.address(), { player_info->event_manager.user_data, event_id, source_id, event_data.address() });
|
||||
}
|
||||
@@ -240,7 +240,7 @@ EXPORT(int32_t, sceAvPlayerAddSource, SceUID player_handle, Ptr<const char> path
|
||||
return RET_ERROR(SCE_AVPLAYER_ERROR_INVALID_ARGUMENT);
|
||||
}
|
||||
|
||||
const auto thread = lock_and_find(thread_id, emuenv.kernel.threads, emuenv.kernel.mutex);
|
||||
const auto thread = emuenv.kernel.get_thread(thread_id);
|
||||
|
||||
auto file_path = expand_path(emuenv.io, path.get(emuenv.mem), emuenv.pref_path);
|
||||
if (!fs::exists(file_path) && player_info->file_manager.open_file && player_info->file_manager.close_file && player_info->file_manager.read_file && player_info->file_manager.file_size) {
|
||||
@@ -515,7 +515,7 @@ EXPORT(int, sceAvPlayerStart, SceUID player_handle) {
|
||||
|
||||
EXPORT(int, sceAvPlayerStop, SceUID player_handle) {
|
||||
const auto state = emuenv.kernel.obj_store.get<AvPlayerState>();
|
||||
const PlayerPtr &player_info = lock_and_find(player_handle, state->players, emuenv.kernel.mutex);
|
||||
const PlayerPtr &player_info = lock_and_find(player_handle, state->players, state->mutex);
|
||||
player_info->player.free_video();
|
||||
const auto thread = emuenv.kernel.get_thread(thread_id);
|
||||
run_event_callback(emuenv, thread, player_info, SCE_AVPLAYER_STATE_STOP, 0, Ptr<void>(0));
|
||||
|
||||
@@ -992,9 +992,9 @@ static void handle_sys_message(SceSaveDataDialogSystemMessageParam *sys_message,
|
||||
}
|
||||
}
|
||||
|
||||
EXPORT(int, sceSaveDataDialogContinue, const Ptr<SceSaveDataDialogParam> param) {
|
||||
TRACY_FUNC(sceSaveDataDialogContinue, param);
|
||||
if (param.get(emuenv.mem) == nullptr) {
|
||||
EXPORT(int, sceSaveDataDialogContinue, const SceSaveDataDialogParam *p) {
|
||||
TRACY_FUNC(sceSaveDataDialogContinue, p);
|
||||
if (p == nullptr) {
|
||||
return RET_ERROR(SCE_COMMON_DIALOG_ERROR_NULL);
|
||||
}
|
||||
|
||||
@@ -1010,13 +1010,11 @@ EXPORT(int, sceSaveDataDialogContinue, const Ptr<SceSaveDataDialogParam> param)
|
||||
emuenv.common_dialog.substatus = SCE_COMMON_DIALOG_STATUS_RUNNING;
|
||||
emuenv.common_dialog.savedata.has_progress_bar = false;
|
||||
|
||||
const SceSaveDataDialogParam *p = param.get(emuenv.mem);
|
||||
SceSaveDataDialogListParam *list_param;
|
||||
SceSaveDataDialogUserMessageParam *user_message;
|
||||
SceSaveDataDialogSystemMessageParam *sys_message;
|
||||
SceSaveDataDialogErrorCodeParam *error_code;
|
||||
SceSaveDataDialogProgressBarParam *progress_bar;
|
||||
SceAppUtilSaveDataSlotEmptyParam *empty_param;
|
||||
std::vector<SceAppUtilSaveDataSlot> slot_list;
|
||||
vfs::FileBuffer thumbnail_buffer;
|
||||
|
||||
@@ -1072,8 +1070,8 @@ EXPORT(int, sceSaveDataDialogContinue, const Ptr<SceSaveDataDialogParam> param)
|
||||
emuenv.common_dialog.savedata.slot_id[emuenv.common_dialog.savedata.selected_save] = progress_bar->targetSlot.id;
|
||||
emuenv.common_dialog.savedata.has_progress_bar = true;
|
||||
emuenv.common_dialog.savedata.list_empty_param[emuenv.common_dialog.savedata.selected_save] = progress_bar->targetSlot.emptyParam.get(emuenv.mem);
|
||||
if (progress_bar->msg.get(emuenv.mem) != nullptr) {
|
||||
emuenv.common_dialog.savedata.msg = reinterpret_cast<const char *>(progress_bar->msg.get(emuenv.mem));
|
||||
if (progress_bar->msg) {
|
||||
emuenv.common_dialog.savedata.msg = progress_bar->msg.cast<char>().get(emuenv.mem);
|
||||
} else {
|
||||
auto &lang = emuenv.common_dialog.lang;
|
||||
auto &save_data = lang.save_data;
|
||||
@@ -1120,7 +1118,7 @@ EXPORT(int, sceSaveDataDialogContinue, const Ptr<SceSaveDataDialogParam> param)
|
||||
return 0;
|
||||
}
|
||||
|
||||
EXPORT(int, sceSaveDataDialogFinish, Ptr<const SceSaveDataDialogFinishParam> finishParam) {
|
||||
EXPORT(int, sceSaveDataDialogFinish, const SceSaveDataDialogFinishParam *finishParam) {
|
||||
TRACY_FUNC(sceSaveDataDialogFinish, finishParam);
|
||||
if (!finishParam) {
|
||||
return RET_ERROR(SCE_COMMON_DIALOG_ERROR_NULL);
|
||||
@@ -1204,9 +1202,9 @@ static void initialize_savedata_vectors(EmuEnvState &emuenv, unsigned int size)
|
||||
emuenv.common_dialog.savedata.list_empty_param.resize(size);
|
||||
}
|
||||
|
||||
EXPORT(int, sceSaveDataDialogInit, const Ptr<SceSaveDataDialogParam> param) {
|
||||
TRACY_FUNC(sceSaveDataDialogInit, param);
|
||||
if (param.get(emuenv.mem) == nullptr) {
|
||||
EXPORT(int, sceSaveDataDialogInit, const SceSaveDataDialogParam *p) {
|
||||
TRACY_FUNC(sceSaveDataDialogInit, p);
|
||||
if (p == nullptr) {
|
||||
return RET_ERROR(SCE_COMMON_DIALOG_ERROR_NULL);
|
||||
}
|
||||
|
||||
@@ -1217,7 +1215,6 @@ EXPORT(int, sceSaveDataDialogInit, const Ptr<SceSaveDataDialogParam> param) {
|
||||
emuenv.common_dialog.status = SCE_COMMON_DIALOG_STATUS_RUNNING;
|
||||
emuenv.common_dialog.substatus = SCE_COMMON_DIALOG_STATUS_RUNNING;
|
||||
|
||||
const SceSaveDataDialogParam *p = param.get(emuenv.mem);
|
||||
SceSaveDataDialogFixedParam *fixed_param;
|
||||
SceSaveDataDialogListParam *list_param;
|
||||
SceSaveDataDialogUserMessageParam *user_message;
|
||||
@@ -1249,8 +1246,8 @@ EXPORT(int, sceSaveDataDialogInit, const Ptr<SceSaveDataDialogParam> param) {
|
||||
slot_list.resize(list_param->slotListSize);
|
||||
initialize_savedata_vectors(emuenv, list_param->slotListSize);
|
||||
|
||||
if (list_param->listTitle.get(emuenv.mem)) {
|
||||
emuenv.common_dialog.savedata.list_title = reinterpret_cast<const char *>(list_param->listTitle.get(emuenv.mem));
|
||||
if (list_param->listTitle) {
|
||||
emuenv.common_dialog.savedata.list_title = list_param->listTitle.cast<char>().get(emuenv.mem);
|
||||
} else {
|
||||
auto &lang = emuenv.common_dialog.lang;
|
||||
auto &save_data = lang.save_data;
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
TRACY_MODULE_NAME(SceErrorUser);
|
||||
|
||||
EXPORT(SceInt32, sceErrorGetExternalString, char *result, int err) {
|
||||
EXPORT(SceInt32, sceErrorGetExternalString, char *result, uint32_t err) {
|
||||
TRACY_FUNC(sceErrorGetExternalString, result, err);
|
||||
return CALL_EXPORT(_sceErrorGetExternalString, result, err);
|
||||
}
|
||||
|
||||
@@ -39,7 +39,6 @@ EXPORT(int, sceMotionGetBasicOrientation, SceFVector3 *basicOrientation) {
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> guard(emuenv.motion.mutex);
|
||||
SceFVector3 accelerometer = get_acceleration(emuenv.motion);
|
||||
|
||||
*basicOrientation = get_basic_orientation(emuenv.motion);
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
#include <util/safe_time.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
|
||||
#include <util/tracy.h>
|
||||
@@ -123,8 +124,7 @@ EXPORT(int, sceRtcFormatRFC2822LocalTime, char *pszDateTime, const SceRtcTick *u
|
||||
const auto tz_hour_diff = local_tz_hour - gmt_tz_hour;
|
||||
|
||||
if (utc) { // format utc in localtime
|
||||
SceDateTime date;
|
||||
memset(&date, 0, sizeof(date));
|
||||
SceDateTime date{};
|
||||
tm gmt = {};
|
||||
__RtcTicksToPspTime(&date, utc->tick);
|
||||
__RtcPspTimeToTm(&gmt, &date);
|
||||
@@ -502,9 +502,8 @@ EXPORT(int, sceRtcTickAddMonths, SceRtcTick *pTick0, const SceRtcTick *pTick1, S
|
||||
t.month = months % 12 + 1;
|
||||
if (t.year == 0)
|
||||
return RET_ERROR(SCE_RTC_ERROR_INVALID_YEAR);
|
||||
int days_in_month = CALL_EXPORT(sceRtcGetDaysInMonth, t.year, t.month);
|
||||
if (t.day > days_in_month)
|
||||
t.day = days_in_month;
|
||||
auto days_in_month = CALL_EXPORT(sceRtcGetDaysInMonth, t.year, t.month);
|
||||
t.day = std::min<decltype(t.day)>(t.day, days_in_month);
|
||||
pTick0->tick = __RtcPspTimeToTicks(&t);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
TRACY_MODULE_NAME(SceError);
|
||||
|
||||
EXPORT(SceInt32, _sceErrorGetExternalString, char *result, int err) {
|
||||
EXPORT(SceInt32, _sceErrorGetExternalString, char *result, uint32_t err) {
|
||||
TRACY_FUNC(_sceErrorGetExternalString, result, err);
|
||||
sprintf(result, "0x%08X", err);
|
||||
return 0;
|
||||
|
||||
@@ -20,4 +20,4 @@
|
||||
#include <module/module.h>
|
||||
#include <util/tracy.h>
|
||||
|
||||
DECL_EXPORT(SceInt32, _sceErrorGetExternalString, char *result, int err);
|
||||
DECL_EXPORT(SceInt32, _sceErrorGetExternalString, char *result, uint32_t err);
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
#include <module/module.h>
|
||||
#include <modules/module_parent.h>
|
||||
|
||||
#include <cpu/functions.h>
|
||||
#include <kernel/state.h>
|
||||
@@ -80,11 +79,11 @@ LIBRARY_INIT(SceFiber) {
|
||||
|
||||
constexpr bool LOG_FIBER = false;
|
||||
|
||||
void set_thread_fiber(FiberState &state, const SceUID &tid, SceFiber *fiber) {
|
||||
static void set_thread_fiber(FiberState &state, const SceUID &tid, SceFiber *fiber) {
|
||||
state.thread_fibers[tid] = fiber;
|
||||
}
|
||||
|
||||
SceFiber *get_thread_fiber(FiberState &state, const SceUID &tid) {
|
||||
static SceFiber *get_thread_fiber(FiberState &state, const SceUID &tid) {
|
||||
auto fiber = state.thread_fibers.find(tid);
|
||||
if (fiber == state.thread_fibers.end()) {
|
||||
return nullptr;
|
||||
@@ -92,15 +91,15 @@ SceFiber *get_thread_fiber(FiberState &state, const SceUID &tid) {
|
||||
return fiber->second;
|
||||
}
|
||||
|
||||
void set_thread_context(FiberState &state, const SceUID &tid, const CPUContext &ctx) {
|
||||
static void set_thread_context(FiberState &state, const SceUID &tid, const CPUContext &ctx) {
|
||||
state.thread_contexts[tid] = ctx;
|
||||
}
|
||||
|
||||
CPUContext get_thread_context(FiberState &state, const SceUID &tid) {
|
||||
static CPUContext get_thread_context(FiberState &state, const SceUID &tid) {
|
||||
return state.thread_contexts[tid];
|
||||
}
|
||||
|
||||
std::string describe_fiber(FiberState &state, const ThreadStatePtr &thread, SceFiber *fiber) {
|
||||
static std::string describe_fiber(FiberState &state, const ThreadStatePtr &thread, SceFiber *fiber) {
|
||||
std::stringstream ss;
|
||||
ss << fmt::format("Fiber (name: {})\n", fiber->name);
|
||||
ss << fmt::format("entry: {}\n", log_hex(fiber->cpu->get_pc()), log_hex(fiber->entry.address()));
|
||||
@@ -113,13 +112,13 @@ std::string describe_fiber(FiberState &state, const ThreadStatePtr &thread, SceF
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
void log_fiber(FiberState &state, const ThreadStatePtr &thread, SceFiber *fiber, const std::string &function_name) {
|
||||
static void log_fiber(FiberState &state, const ThreadStatePtr &thread, SceFiber *fiber, const std::string &function_name) {
|
||||
std::string log_msg = function_name + "\n";
|
||||
log_msg += describe_fiber(state, thread, fiber);
|
||||
LOG_INFO("{}", log_msg);
|
||||
}
|
||||
|
||||
void setup_fiber_to_run(EmuEnvState &emuenv, const ThreadStatePtr &thread, SceFiber *fiber, uint32_t thread_sp, const uint32_t &argOnRunTo) {
|
||||
static void setup_fiber_to_run(EmuEnvState &emuenv, const ThreadStatePtr &thread, SceFiber *fiber, uint32_t thread_sp, const uint32_t &argOnRunTo) {
|
||||
assert(fiber->status != FiberStatus::RUN);
|
||||
if (!fiber->addrContext) {
|
||||
fiber->cpu->set_sp(thread_sp);
|
||||
@@ -138,7 +137,7 @@ void setup_fiber_to_run(EmuEnvState &emuenv, const ThreadStatePtr &thread, SceFi
|
||||
fiber->status = FiberStatus::RUN;
|
||||
}
|
||||
|
||||
void initialize_fiber(EmuEnvState &emuenv, const ThreadStatePtr &thread, SceFiber *fiber, const char *name, Ptr<SceFiberEntry> entry, SceUInt32 argOnInitialize, Ptr<void> addrContext, SceSize sizeContext, SceFiberOptParam *params) {
|
||||
static void initialize_fiber(EmuEnvState &emuenv, const ThreadStatePtr &thread, SceFiber *fiber, const char *name, Ptr<SceFiberEntry> entry, SceUInt32 argOnInitialize, Ptr<void> addrContext, SceSize sizeContext, SceFiberOptParam *params) {
|
||||
fiber->entry = entry;
|
||||
strncpy(fiber->name, name, 32);
|
||||
fiber->argOnInitialize = argOnInitialize;
|
||||
@@ -162,7 +161,7 @@ EXPORT(int, _sceFiberAttachContextAndRun, SceFiber *fiber, Address addrContext,
|
||||
STUBBED("Todo: not sure for now");
|
||||
const auto state = emuenv.kernel.obj_store.get<FiberState>();
|
||||
const std::lock_guard<std::mutex> lock(state->mutex);
|
||||
const auto thread = lock_and_find(thread_id, emuenv.kernel.threads, emuenv.kernel.mutex);
|
||||
const auto thread = emuenv.kernel.get_thread(thread_id);
|
||||
assert(!get_thread_fiber(*state, thread->id));
|
||||
assert(!fiber->addrContext);
|
||||
if (LOG_FIBER) {
|
||||
@@ -189,7 +188,7 @@ EXPORT(int, _sceFiberAttachContextAndSwitch, SceFiber *fiber, Address addrContex
|
||||
STUBBED("Todo: not sure for now");
|
||||
const auto state = emuenv.kernel.obj_store.get<FiberState>();
|
||||
const std::lock_guard<std::mutex> lock(state->mutex);
|
||||
const auto thread = lock_and_find(thread_id, emuenv.kernel.threads, emuenv.kernel.mutex);
|
||||
const auto thread = emuenv.kernel.get_thread(thread_id);
|
||||
auto ctx = get_thread_context(*state, thread->id);
|
||||
SceFiber *thread_fiber = get_thread_fiber(*state, thread->id);
|
||||
if (LOG_FIBER) {
|
||||
@@ -229,7 +228,7 @@ EXPORT(SceInt32, _sceFiberInitializeImpl, SceFiber *fiber, const char *name, Ptr
|
||||
return RET_ERROR(SCE_FIBER_ERROR_INVALID);
|
||||
}
|
||||
|
||||
const ThreadStatePtr thread = lock_and_find(thread_id, emuenv.kernel.threads, emuenv.kernel.mutex);
|
||||
const ThreadStatePtr thread = emuenv.kernel.get_thread(thread_id);
|
||||
if (!thread) {
|
||||
return RET_ERROR(SCE_KERNEL_ERROR_UNKNOWN_THREAD_ID);
|
||||
}
|
||||
@@ -253,7 +252,7 @@ EXPORT(int, _sceFiberInitializeWithInternalOptionImpl, SceFiber *fiber, const ch
|
||||
return RET_ERROR(SCE_FIBER_ERROR_INVALID);
|
||||
}
|
||||
|
||||
const ThreadStatePtr thread = lock_and_find(thread_id, emuenv.kernel.threads, emuenv.kernel.mutex);
|
||||
const ThreadStatePtr thread = emuenv.kernel.get_thread(thread_id);
|
||||
if (!thread) {
|
||||
return RET_ERROR(SCE_KERNEL_ERROR_UNKNOWN_THREAD_ID);
|
||||
}
|
||||
@@ -309,7 +308,7 @@ EXPORT(SceUInt32, sceFiberGetSelf, Ptr<SceFiber> *fiber) {
|
||||
return RET_ERROR(SCE_FIBER_ERROR_NULL);
|
||||
}
|
||||
|
||||
const ThreadStatePtr thread = lock_and_find(thread_id, emuenv.kernel.threads, emuenv.kernel.mutex);
|
||||
const ThreadStatePtr thread = emuenv.kernel.get_thread(thread_id);
|
||||
SceFiber *thread_fiber = get_thread_fiber(*state, thread->id);
|
||||
if (thread_fiber)
|
||||
*fiber = Ptr<SceFiber>(thread_fiber, emuenv.mem);
|
||||
@@ -343,7 +342,7 @@ EXPORT(SceInt32, sceFiberReturnToThread, uint32_t argOnReturnTo, Ptr<uint32_t> a
|
||||
TRACY_FUNC(sceFiberReturnToThread, argOnReturnTo, argOnRun);
|
||||
const auto state = emuenv.kernel.obj_store.get<FiberState>();
|
||||
const std::lock_guard<std::mutex> lock(state->mutex);
|
||||
const ThreadStatePtr thread = lock_and_find(thread_id, emuenv.kernel.threads, emuenv.kernel.mutex);
|
||||
const ThreadStatePtr thread = emuenv.kernel.get_thread(thread_id);
|
||||
SceFiber *fiber = get_thread_fiber(*state, thread->id);
|
||||
if (!fiber) {
|
||||
return RET_ERROR(SCE_FIBER_ERROR_PERMISSION);
|
||||
@@ -374,7 +373,7 @@ EXPORT(SceUInt32, sceFiberRun, SceFiber *fiber, SceUInt32 argOnRunTo, Ptr<SceUIn
|
||||
TRACY_FUNC(sceFiberRun, fiber, argOnRunTo, argOnReturn);
|
||||
const auto state = emuenv.kernel.obj_store.get<FiberState>();
|
||||
const std::lock_guard<std::mutex> lock(state->mutex);
|
||||
const ThreadStatePtr thread = lock_and_find(thread_id, emuenv.kernel.threads, emuenv.kernel.mutex);
|
||||
const ThreadStatePtr thread = emuenv.kernel.get_thread(thread_id);
|
||||
if (!fiber) {
|
||||
return RET_ERROR(SCE_FIBER_ERROR_NULL);
|
||||
}
|
||||
@@ -413,7 +412,7 @@ EXPORT(SceUInt32, sceFiberSwitch, SceFiber *fiber, SceUInt32 argOnRunTo, Ptr<Sce
|
||||
TRACY_FUNC(sceFiberSwitch, fiber, argOnRunTo, argOnRun);
|
||||
const auto state = emuenv.kernel.obj_store.get<FiberState>();
|
||||
const std::lock_guard<std::mutex> lock(state->mutex);
|
||||
const ThreadStatePtr thread = lock_and_find(thread_id, emuenv.kernel.threads, emuenv.kernel.mutex);
|
||||
const ThreadStatePtr thread = emuenv.kernel.get_thread(thread_id);
|
||||
auto ctx = get_thread_context(*state, thread->id);
|
||||
if (!fiber) {
|
||||
return RET_ERROR(SCE_FIBER_ERROR_NULL);
|
||||
|
||||
@@ -43,7 +43,6 @@
|
||||
#include <renderer/state.h>
|
||||
#include <renderer/types.h>
|
||||
#include <util/bytes.h>
|
||||
#include <util/lock_and_find.h>
|
||||
#include <util/log.h>
|
||||
|
||||
#include <util/tracy.h>
|
||||
@@ -939,7 +938,7 @@ static Ptr<void> gxmRunDeferredMemoryCallback(KernelState &kernel, const MemStat
|
||||
const std::uint32_t size, const SceUID thread_id) {
|
||||
const std::lock_guard<std::mutex> guard(global_lock);
|
||||
|
||||
const ThreadStatePtr thread = lock_and_find(thread_id, kernel.threads, kernel.mutex);
|
||||
const ThreadStatePtr thread = kernel.get_thread(thread_id);
|
||||
const Address final_size_addr = stack_alloc(*thread->cpu, 4);
|
||||
|
||||
Ptr<void> result(thread->run_callback(callback.address(), { userdata.address(), size, final_size_addr }));
|
||||
@@ -1238,7 +1237,7 @@ static constexpr std::uint32_t DEFAULT_RING_SIZE = 4096;
|
||||
|
||||
static VertexCacheHash hash_data(const void *data, size_t size) {
|
||||
auto hash = XXH3_64bits(data, size);
|
||||
return VertexCacheHash(hash);
|
||||
return static_cast<VertexCacheHash>(hash);
|
||||
}
|
||||
|
||||
static bool operator<(const SceGxmRegisteredProgram &a, const SceGxmRegisteredProgram &b) {
|
||||
@@ -4224,7 +4223,7 @@ EXPORT(int, sceGxmSetYuvProfile) {
|
||||
return UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
Address alloc_callbacked(EmuEnvState &emuenv, SceUID thread_id, const SceGxmShaderPatcherParams &shaderPatcherParams, unsigned int size) {
|
||||
static Address alloc_callbacked(EmuEnvState &emuenv, SceUID thread_id, const SceGxmShaderPatcherParams &shaderPatcherParams, unsigned int size) {
|
||||
if (!shaderPatcherParams.hostAllocCallback) {
|
||||
LOG_ERROR("Empty hostAllocCallback");
|
||||
}
|
||||
@@ -4234,7 +4233,7 @@ Address alloc_callbacked(EmuEnvState &emuenv, SceUID thread_id, const SceGxmShad
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Ptr<T> alloc_callbacked(EmuEnvState &emuenv, SceUID thread_id, const SceGxmShaderPatcherParams &shaderPatcherParams) {
|
||||
static Ptr<T> alloc_callbacked(EmuEnvState &emuenv, SceUID thread_id, const SceGxmShaderPatcherParams &shaderPatcherParams) {
|
||||
const Address address = alloc_callbacked(emuenv, thread_id, shaderPatcherParams, sizeof(T));
|
||||
const Ptr<T> ptr(address);
|
||||
if (!ptr) {
|
||||
@@ -4246,11 +4245,11 @@ Ptr<T> alloc_callbacked(EmuEnvState &emuenv, SceUID thread_id, const SceGxmShade
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Ptr<T> alloc_callbacked(EmuEnvState &emuenv, SceUID thread_id, SceGxmShaderPatcher *shaderPatcher) {
|
||||
static Ptr<T> alloc_callbacked(EmuEnvState &emuenv, SceUID thread_id, SceGxmShaderPatcher *shaderPatcher) {
|
||||
return alloc_callbacked<T>(emuenv, thread_id, shaderPatcher->params);
|
||||
}
|
||||
|
||||
void free_callbacked(EmuEnvState &emuenv, SceUID thread_id, SceGxmShaderPatcher *shaderPatcher, Address data) {
|
||||
static void free_callbacked(EmuEnvState &emuenv, SceUID thread_id, SceGxmShaderPatcher *shaderPatcher, Address data) {
|
||||
if (!shaderPatcher->params.hostFreeCallback) {
|
||||
LOG_ERROR("Empty hostFreeCallback");
|
||||
}
|
||||
@@ -4259,7 +4258,7 @@ void free_callbacked(EmuEnvState &emuenv, SceUID thread_id, SceGxmShaderPatcher
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void free_callbacked(EmuEnvState &emuenv, SceUID thread_id, SceGxmShaderPatcher *shaderPatcher, Ptr<T> data) {
|
||||
static void free_callbacked(EmuEnvState &emuenv, SceUID thread_id, SceGxmShaderPatcher *shaderPatcher, Ptr<T> data) {
|
||||
free_callbacked(emuenv, thread_id, shaderPatcher, data.address());
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,6 @@
|
||||
#include <net/state.h>
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/ssl.h>
|
||||
#include <util/lock_and_find.h>
|
||||
#include <util/log.h>
|
||||
#include <util/net_utils.h>
|
||||
#include <util/string_utils.h>
|
||||
@@ -165,14 +164,12 @@ EXPORT(SceInt, sceHttpAddRequestHeader, SceInt reqId, const char *name, const ch
|
||||
// entry doesn't exists, we can insert it
|
||||
req.headers.insert({ name, value });
|
||||
}
|
||||
} else if (mode == SCE_HTTP_HEADER_ADD) {
|
||||
} else { // mode == SCE_HTTP_HEADER_ADD
|
||||
if (req.headers.contains(name))
|
||||
return RET_ERROR(SCE_HTTP_ERROR_INVALID_VALUE);
|
||||
|
||||
req.headers.insert({ name, value });
|
||||
} else
|
||||
return RET_ERROR(SCE_HTTP_ERROR_INVALID_VALUE);
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -267,7 +264,7 @@ EXPORT(SceInt, sceHttpCreateConnectionWithURL, SceInt tmplId, const char *url, S
|
||||
};
|
||||
addrinfo *result = { 0 };
|
||||
|
||||
const ThreadStatePtr thread = lock_and_find(thread_id, emuenv.kernel.threads, emuenv.kernel.mutex);
|
||||
const ThreadStatePtr thread = emuenv.kernel.get_thread(thread_id);
|
||||
|
||||
auto ret = getaddrinfo(parsed.hostname.c_str(), port.c_str(), &hints, &result);
|
||||
if (ret < 0) {
|
||||
@@ -431,11 +428,11 @@ EXPORT(SceInt, sceHttpCreateRequestWithURL, SceInt connId, SceHttpMethods method
|
||||
req.url = urlStr;
|
||||
req.contentLength = contentLength;
|
||||
|
||||
req.headers.insert({ "Host", parsed.hostname });
|
||||
req.headers.insert({ "User-Agent", tmpl->second.userAgent });
|
||||
req.headers.emplace("Host", parsed.hostname);
|
||||
req.headers.emplace("User-Agent", tmpl->second.userAgent);
|
||||
|
||||
if (tmpl->second.httpVersion == SCE_HTTP_VERSION_1_1 && conn->second.keepAlive)
|
||||
req.headers.insert({ "Connection", "Keep-Alive" });
|
||||
req.headers.emplace("Connection", "Keep-Alive");
|
||||
|
||||
std::string methodStr;
|
||||
switch (method) {
|
||||
@@ -1131,9 +1128,9 @@ EXPORT(SceInt, sceHttpSendRequest, SceInt reqId, const char *postData, SceSize s
|
||||
|
||||
// Now we get the body or the rest of the body
|
||||
attempts = 1; // Reset attempts
|
||||
const int responseLength = resHeadersStr.find("\r\n\r\n") + strlen("\r\n\r\n") + req->second.res.contentLength;
|
||||
int responseLength = resHeadersStr.find("\r\n\r\n") + strlen("\r\n\r\n") + req->second.res.contentLength;
|
||||
if (req->second.method == SCE_HTTP_METHOD_HEAD || req->second.method == SCE_HTTP_METHOD_OPTIONS) // even if we have content-length, there will be no body
|
||||
const int responseLength = resHeadersStr.find("\r\n\r\n") + strlen("\r\n\r\n");
|
||||
responseLength = resHeadersStr.find("\r\n\r\n") + strlen("\r\n\r\n");
|
||||
|
||||
// This is the entire response, including headers and everything
|
||||
auto reqResponse = new uint8_t[responseLength]();
|
||||
|
||||
@@ -30,7 +30,7 @@ EXPORT(void, SceImeEventHandler, Ptr<void> arg, const SceImeEvent *e) {
|
||||
TRACY_FUNC(SceImeEventHandler, arg, e);
|
||||
Ptr<SceImeEvent> e1 = Ptr<SceImeEvent>(alloc(emuenv.mem, sizeof(SceImeEvent), "ime2"));
|
||||
memcpy(e1.get(emuenv.mem), e, sizeof(SceImeEvent));
|
||||
auto thread = lock_and_find(thread_id, emuenv.kernel.threads, emuenv.kernel.mutex);
|
||||
auto thread = emuenv.kernel.get_thread(thread_id);
|
||||
thread->run_callback(emuenv.ime.param.handler.address(), { arg.address(), e1.address() });
|
||||
free(emuenv.mem, e1.address());
|
||||
}
|
||||
@@ -73,7 +73,7 @@ EXPORT(SceInt32, sceImeOpen, SceImeParam *param) {
|
||||
emuenv.ime.param.inputTextBuffer = Ptr<SceWChar16>(alloc(emuenv.mem, SCE_IME_MAX_PREEDIT_LENGTH + emuenv.ime.param.maxTextLength + 1, "ime_str"));
|
||||
emuenv.ime.str = emuenv.ime.param.initialText ? reinterpret_cast<char16_t *>(emuenv.ime.param.initialText.get(emuenv.mem)) : u"";
|
||||
if (!emuenv.ime.str.empty())
|
||||
emuenv.ime.caretIndex = emuenv.ime.edit_text.caretIndex = emuenv.ime.edit_text.preeditIndex = SceUInt32(emuenv.ime.str.length());
|
||||
emuenv.ime.caretIndex = emuenv.ime.edit_text.caretIndex = emuenv.ime.edit_text.preeditIndex = static_cast<SceUInt32>(emuenv.ime.str.length());
|
||||
else
|
||||
emuenv.ime.caps_level = 1;
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ struct SceJpegOutputInfo {
|
||||
SceJpegPitch pitch[4];
|
||||
};
|
||||
|
||||
SceJpegColorSpace convert_color_space_decoder_to_jpeg(DecoderColorSpace color_space) {
|
||||
static SceJpegColorSpace convert_color_space_decoder_to_jpeg(DecoderColorSpace color_space) {
|
||||
switch (color_space) {
|
||||
case COLORSPACE_GRAYSCALE:
|
||||
return SCE_JPEG_COLORSPACE_GRAYSCALE;
|
||||
@@ -108,7 +108,7 @@ SceJpegColorSpace convert_color_space_decoder_to_jpeg(DecoderColorSpace color_sp
|
||||
}
|
||||
}
|
||||
|
||||
DecoderColorSpace convert_color_space_jpeg_to_decoder(SceJpegColorSpace color_space) {
|
||||
static DecoderColorSpace convert_color_space_jpeg_to_decoder(SceJpegColorSpace color_space) {
|
||||
switch (color_space) {
|
||||
case SCE_JPEG_COLORSPACE_GRAYSCALE:
|
||||
return COLORSPACE_GRAYSCALE;
|
||||
@@ -130,19 +130,19 @@ DecoderColorSpace convert_color_space_jpeg_to_decoder(SceJpegColorSpace color_sp
|
||||
}
|
||||
|
||||
// Helper functions
|
||||
SceJpegDHTMode get_DHT_mode(int decodeMode) {
|
||||
static SceJpegDHTMode get_DHT_mode(int decodeMode) {
|
||||
return static_cast<SceJpegDHTMode>(decodeMode & 0b111);
|
||||
}
|
||||
|
||||
SceJpegDownscaleMode get_downscale_mode(int decodeMode) {
|
||||
static SceJpegDownscaleMode get_downscale_mode(int decodeMode) {
|
||||
return static_cast<SceJpegDownscaleMode>(decodeMode & (0b111 << 4));
|
||||
}
|
||||
|
||||
int get_downscale_ratio(SceJpegDownscaleMode downscaleMode) {
|
||||
return downscaleMode ? downscaleMode / 8 : 1;
|
||||
static int get_downscale_ratio(SceJpegDownscaleMode downscaleMode) {
|
||||
return downscaleMode != 0 ? downscaleMode / 8 : 1;
|
||||
}
|
||||
|
||||
bool is_standard_decoding(SceJpegDHTMode dhtMode) {
|
||||
static bool is_standard_decoding(SceJpegDHTMode dhtMode) {
|
||||
return dhtMode == SCE_JPEG_MJPEG_WITH_DHT || dhtMode == SCE_JPEG_MJPEG_WITHOUT_DHT;
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ static bool is_unsupported_image_size(uint32_t width, uint32_t height) {
|
||||
}
|
||||
|
||||
// Common decoder configuration
|
||||
void configure_decoder(MJpegState *state, int decodeMode) {
|
||||
static void configure_decoder(MJpegState *state, int decodeMode) {
|
||||
SceJpegDHTMode dhtMode = get_DHT_mode(decodeMode);
|
||||
SceJpegDownscaleMode downscaleMode = get_downscale_mode(decodeMode);
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ struct SceJpegEncoderContext {
|
||||
int32_t headerMode;
|
||||
};
|
||||
|
||||
int sceJpegEncoderInitImpl(SceJpegEncoderContext *context, int32_t inWidth, int32_t inHeight, int32_t pixelFormat, Ptr<uint8_t> outBuffer, uint32_t outSize, SceJpegEncoderInitParamOption option = SCE_JPEGENC_INIT_PARAM_OPTION_NONE) {
|
||||
static int sceJpegEncoderInitImpl(SceJpegEncoderContext *context, int32_t inWidth, int32_t inHeight, int32_t pixelFormat, Ptr<uint8_t> outBuffer, uint32_t outSize, SceJpegEncoderInitParamOption option = SCE_JPEGENC_INIT_PARAM_OPTION_NONE) {
|
||||
context->inWidth = inWidth;
|
||||
context->inHeight = inHeight;
|
||||
context->pixelFormat = pixelFormat;
|
||||
|
||||
@@ -152,7 +152,7 @@ EXPORT(int, sceKernelGetModuleList, int flags, SceUID *modids, int *num) {
|
||||
// for Maidump main module should be the last module
|
||||
int i = 0;
|
||||
SceUID main_module_id = 0;
|
||||
for (auto [module_id, module] : emuenv.kernel.loaded_modules) {
|
||||
for (auto &[module_id, module] : emuenv.kernel.loaded_modules) {
|
||||
if (module->info.path == "app0:" + emuenv.self_path) {
|
||||
main_module_id = module_id;
|
||||
} else {
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
#include <util/tracy.h>
|
||||
TRACY_MODULE_NAME(SceThreadmgr);
|
||||
|
||||
inline uint64_t get_current_time() {
|
||||
inline static uint64_t get_current_time() {
|
||||
return std::chrono::duration_cast<std::chrono::microseconds>(
|
||||
std::chrono::high_resolution_clock::now().time_since_epoch())
|
||||
.count();
|
||||
@@ -434,7 +434,7 @@ EXPORT(int, _sceKernelGetThreadContextForVM, SceUID threadId, Ptr<SceKernelThrea
|
||||
TRACY_FUNC(_sceKernelGetThreadContextForVM, threadId, pCpuRegisterInfo, pVfpRegisterInfo);
|
||||
STUBBED("Stub");
|
||||
|
||||
const ThreadStatePtr thread = lock_and_find(threadId, emuenv.kernel.threads, emuenv.kernel.mutex);
|
||||
const ThreadStatePtr thread = emuenv.kernel.get_thread(threadId);
|
||||
if (!thread)
|
||||
return RET_ERROR(SCE_KERNEL_ERROR_UNKNOWN_THREAD_ID);
|
||||
|
||||
@@ -490,7 +490,7 @@ EXPORT(SceInt32, _sceKernelGetThreadInfo, SceUID threadId, Ptr<SceKernelThreadIn
|
||||
TRACY_FUNC(_sceKernelGetThreadInfo, threadId, pInfo);
|
||||
STUBBED("STUB");
|
||||
|
||||
const ThreadStatePtr thread = lock_and_find(threadId ? threadId : thread_id, emuenv.kernel.threads, emuenv.kernel.mutex);
|
||||
const ThreadStatePtr thread = emuenv.kernel.get_thread(threadId ? threadId : thread_id);
|
||||
if (!thread)
|
||||
return RET_ERROR(SCE_KERNEL_ERROR_UNKNOWN_THREAD_ID);
|
||||
|
||||
@@ -655,7 +655,7 @@ EXPORT(int, _sceKernelSetEventWithNotifyCallback) {
|
||||
|
||||
EXPORT(int, _sceKernelSetThreadContextForVM, SceUID threadId, Ptr<SceKernelThreadCpuRegisterInfo> pCpuRegisterInfo, Ptr<SceKernelThreadVfpRegisterInfo> pVfpRegisterInfo) {
|
||||
TRACY_FUNC(_sceKernelSetThreadContextForVM, threadId, pCpuRegisterInfo, pVfpRegisterInfo);
|
||||
const ThreadStatePtr thread = lock_and_find(threadId, emuenv.kernel.threads, emuenv.kernel.mutex);
|
||||
const ThreadStatePtr thread = emuenv.kernel.get_thread(threadId);
|
||||
if (!thread)
|
||||
return RET_ERROR(SCE_KERNEL_ERROR_UNKNOWN_THREAD_ID);
|
||||
|
||||
@@ -709,7 +709,7 @@ EXPORT(int, _sceKernelSignalLwCondTo) {
|
||||
|
||||
EXPORT(int, _sceKernelStartThread, SceUID thid, SceSize arglen, Ptr<void> argp) {
|
||||
TRACY_FUNC(_sceKernelStartThread, thid, arglen, argp);
|
||||
auto thread = lock_and_find(thid, emuenv.kernel.threads, emuenv.kernel.mutex);
|
||||
auto thread = emuenv.kernel.get_thread(thid);
|
||||
|
||||
if (!thread) {
|
||||
return RET_ERROR(SCE_KERNEL_ERROR_UNKNOWN_THREAD_ID);
|
||||
@@ -821,7 +821,7 @@ EXPORT(SceInt32, _sceKernelWaitSemaCB, SceUID semaId, SceInt32 needCount, SceUIn
|
||||
EXPORT(int, _sceKernelWaitSignal, uint32_t unknown, uint32_t delay, uint32_t timeout) {
|
||||
TRACY_FUNC(_sceKernelWaitSignal, unknown, delay, timeout);
|
||||
STUBBED("sceKernelWaitSignal");
|
||||
const auto thread = lock_and_find(thread_id, emuenv.kernel.threads, emuenv.kernel.mutex);
|
||||
const auto thread = emuenv.kernel.get_thread(thread_id);
|
||||
thread->update_status(ThreadStatus::wait);
|
||||
thread->signal.wait();
|
||||
thread->update_status(ThreadStatus::run);
|
||||
@@ -834,7 +834,7 @@ EXPORT(int, _sceKernelWaitSignalCB, uint32_t unknown, uint32_t delay, uint32_t t
|
||||
return CALL_EXPORT(_sceKernelWaitSignal, unknown, delay, timeout);
|
||||
}
|
||||
|
||||
int wait_thread_end(ThreadStatePtr &waiter, ThreadStatePtr &target, int *stat) {
|
||||
static int wait_thread_end(ThreadStatePtr &waiter, ThreadStatePtr &target, int *stat) {
|
||||
std::unique_lock<std::mutex> waiter_lock(waiter->mutex);
|
||||
{
|
||||
const std::unique_lock<std::mutex> thread_lock(target->mutex);
|
||||
@@ -854,8 +854,8 @@ int wait_thread_end(ThreadStatePtr &waiter, ThreadStatePtr &target, int *stat) {
|
||||
|
||||
EXPORT(int, _sceKernelWaitThreadEnd, SceUID thid, int *stat, SceUInt *timeout) {
|
||||
TRACY_FUNC(_sceKernelWaitThreadEnd, thid, stat, timeout);
|
||||
auto waiter = lock_and_find(thread_id, emuenv.kernel.threads, emuenv.kernel.mutex);
|
||||
auto target = lock_and_find(thid, emuenv.kernel.threads, emuenv.kernel.mutex);
|
||||
auto waiter = emuenv.kernel.get_thread(thread_id);
|
||||
auto target = emuenv.kernel.get_thread(thid);
|
||||
if (!target) {
|
||||
return RET_ERROR(SCE_KERNEL_ERROR_UNKNOWN_THREAD_ID);
|
||||
}
|
||||
@@ -864,8 +864,8 @@ EXPORT(int, _sceKernelWaitThreadEnd, SceUID thid, int *stat, SceUInt *timeout) {
|
||||
|
||||
EXPORT(int, _sceKernelWaitThreadEndCB, SceUID thid, int *stat, SceUInt *timeout) {
|
||||
TRACY_FUNC(_sceKernelWaitThreadEndCB, thid, stat, timeout);
|
||||
auto waiter = lock_and_find(thread_id, emuenv.kernel.threads, emuenv.kernel.mutex);
|
||||
auto target = lock_and_find(thid, emuenv.kernel.threads, emuenv.kernel.mutex);
|
||||
auto waiter = emuenv.kernel.get_thread(thread_id);
|
||||
auto target = emuenv.kernel.get_thread(thid);
|
||||
if (!target) {
|
||||
return RET_ERROR(SCE_KERNEL_ERROR_UNKNOWN_THREAD_ID);
|
||||
}
|
||||
@@ -1048,7 +1048,7 @@ EXPORT(int, sceKernelCreateThreadForUser, const char *name, SceKernelThreadEntry
|
||||
return thread->id;
|
||||
}
|
||||
|
||||
int delay_thread(SceUInt delay_us) {
|
||||
static int delay_thread(SceUInt delay_us) {
|
||||
if (delay_us == 0)
|
||||
return SCE_KERNEL_ERROR_INVALID_ARGUMENT;
|
||||
|
||||
@@ -1057,7 +1057,7 @@ int delay_thread(SceUInt delay_us) {
|
||||
return SCE_KERNEL_OK;
|
||||
}
|
||||
|
||||
int delay_thread_cb(EmuEnvState &emuenv, SceUID thread_id, SceUInt delay_us) {
|
||||
static int delay_thread_cb(EmuEnvState &emuenv, SceUID thread_id, SceUInt delay_us) {
|
||||
auto start = std::chrono::high_resolution_clock::now(); // Meseaure the time taken to process callbacks
|
||||
process_callbacks(emuenv.kernel, thread_id);
|
||||
auto end = std::chrono::high_resolution_clock::now();
|
||||
@@ -1145,7 +1145,7 @@ EXPORT(int, sceKernelDeleteSimpleEvent, SceUID event_id) {
|
||||
|
||||
EXPORT(int, sceKernelDeleteThread, SceUID thid) {
|
||||
TRACY_FUNC(sceKernelDeleteThread, thid);
|
||||
const ThreadStatePtr thread = lock_and_find(thid, emuenv.kernel.threads, emuenv.kernel.mutex);
|
||||
const ThreadStatePtr thread = emuenv.kernel.get_thread(thid);
|
||||
if (!thread || thread->status != ThreadStatus::dormant) {
|
||||
return SCE_KERNEL_ERROR_NOT_DORMANT;
|
||||
}
|
||||
@@ -1163,7 +1163,7 @@ EXPORT(int, sceKernelDeleteTimer, SceUID timer_handle) {
|
||||
|
||||
EXPORT(int, sceKernelExitDeleteThread, int status) {
|
||||
TRACY_FUNC(sceKernelExitDeleteThread, status);
|
||||
const ThreadStatePtr thread = lock_and_find(thread_id, emuenv.kernel.threads, emuenv.kernel.mutex);
|
||||
const ThreadStatePtr thread = emuenv.kernel.get_thread(thread_id);
|
||||
thread->exit_delete();
|
||||
|
||||
return status;
|
||||
@@ -1320,7 +1320,7 @@ EXPORT(int, sceKernelResumeThreadForVM, SceUID threadId) {
|
||||
TRACY_FUNC(sceKernelResumeThreadForVM, threadId);
|
||||
STUBBED("STUB");
|
||||
|
||||
const ThreadStatePtr thread = lock_and_find(threadId, emuenv.kernel.threads, emuenv.kernel.mutex);
|
||||
const ThreadStatePtr thread = emuenv.kernel.get_thread(threadId);
|
||||
if (!thread)
|
||||
return RET_ERROR(SCE_KERNEL_ERROR_UNKNOWN_THREAD_ID);
|
||||
|
||||
@@ -1332,7 +1332,7 @@ EXPORT(int, sceKernelResumeThreadForVM, SceUID threadId) {
|
||||
EXPORT(int, sceKernelSendSignal, SceUID target_thread_id) {
|
||||
TRACY_FUNC(sceKernelSendSignal, target_thread_id);
|
||||
STUBBED("sceKernelSendSignal");
|
||||
const auto thread = lock_and_find(target_thread_id, emuenv.kernel.threads, emuenv.kernel.mutex);
|
||||
const auto thread = emuenv.kernel.get_thread(target_thread_id);
|
||||
if (!thread->signal.send()) {
|
||||
return SCE_KERNEL_ERROR_ALREADY_SENT;
|
||||
}
|
||||
@@ -1398,7 +1398,7 @@ EXPORT(int, sceKernelSuspendThreadForVM, SceUID threadId) {
|
||||
TRACY_FUNC(sceKernelSuspendThreadForVM, threadId);
|
||||
STUBBED("STUB");
|
||||
|
||||
const ThreadStatePtr thread = lock_and_find(threadId, emuenv.kernel.threads, emuenv.kernel.mutex);
|
||||
const ThreadStatePtr thread = emuenv.kernel.get_thread(threadId);
|
||||
if (!thread)
|
||||
return RET_ERROR(SCE_KERNEL_ERROR_UNKNOWN_THREAD_ID);
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ TRACY_MODULE_NAME(SceDbg);
|
||||
|
||||
EXPORT(int, sceDbgAssertionHandler, const char *filename, int line, bool do_stop, const char *component, module::vargs messages) {
|
||||
TRACY_FUNC(sceDbgAssertionHandler, filename, line, do_stop, component);
|
||||
const ThreadStatePtr thread = lock_and_find(thread_id, emuenv.kernel.threads, emuenv.kernel.mutex);
|
||||
const ThreadStatePtr thread = emuenv.kernel.get_thread(thread_id);
|
||||
|
||||
if (!thread) {
|
||||
return SCE_KERNEL_ERROR_UNKNOWN_THREAD_ID;
|
||||
@@ -53,7 +53,7 @@ EXPORT(int, sceDbgAssertionHandler, const char *filename, int line, bool do_stop
|
||||
|
||||
EXPORT(int, sceDbgLoggingHandler, const char *pFile, int line, int severity, const char *pComponent, module::vargs messages) {
|
||||
TRACY_FUNC(sceDbgLoggingHandler, pFile, line, severity, pComponent);
|
||||
const ThreadStatePtr thread = lock_and_find(thread_id, emuenv.kernel.threads, emuenv.kernel.mutex);
|
||||
const ThreadStatePtr thread = emuenv.kernel.get_thread(thread_id);
|
||||
|
||||
if (!thread) {
|
||||
return SCE_KERNEL_ERROR_UNKNOWN_THREAD_ID;
|
||||
|
||||
@@ -55,7 +55,7 @@ enum class TimerFlags : uint32_t {
|
||||
|
||||
TRACY_MODULE_NAME(SceLibKernel);
|
||||
|
||||
inline uint64_t get_current_time() {
|
||||
inline static uint64_t get_current_time() {
|
||||
return std::chrono::duration_cast<std::chrono::microseconds>(
|
||||
std::chrono::high_resolution_clock::now().time_since_epoch())
|
||||
.count();
|
||||
@@ -89,7 +89,7 @@ EXPORT(int, __stack_chk_fail) {
|
||||
TRACY_FUNC(__stack_chk_fail);
|
||||
LOG_CRITICAL("Stack corruption on TID: {}", thread_id);
|
||||
|
||||
const ThreadStatePtr thread = lock_and_find(thread_id, emuenv.kernel.threads, emuenv.kernel.mutex);
|
||||
const ThreadStatePtr thread = emuenv.kernel.get_thread(thread_id);
|
||||
auto ctx = save_context(*thread->cpu);
|
||||
LOG_ERROR("{}", ctx.description());
|
||||
|
||||
@@ -100,7 +100,7 @@ EXPORT(int, __stack_chk_fail) {
|
||||
|
||||
EXPORT(int, _sceKernelCreateLwMutex, Ptr<SceKernelLwMutexWork> workarea, const char *name, unsigned int attr, int init_count, Ptr<SceKernelLwMutexOptParam> opt_param) {
|
||||
TRACY_FUNC(_sceKernelCreateLwMutex, workarea, name, attr, init_count, opt_param);
|
||||
const ThreadStatePtr thread = lock_and_find(thread_id, emuenv.kernel.threads, emuenv.kernel.mutex);
|
||||
const ThreadStatePtr thread = emuenv.kernel.get_thread(thread_id);
|
||||
|
||||
Ptr<SceKernelCreateLwMutex_opt> options = Ptr<SceKernelCreateLwMutex_opt>(stack_alloc(*thread->cpu, sizeof(SceKernelCreateLwMutex_opt)));
|
||||
options.get(emuenv.mem)->init_count = init_count;
|
||||
@@ -297,7 +297,7 @@ EXPORT(int, sceClibPrintf, const char *fmt, module::vargs args) {
|
||||
TRACY_FUNC(sceClibPrintf, fmt);
|
||||
std::vector<char> buffer(KiB(1));
|
||||
|
||||
const ThreadStatePtr thread = lock_and_find(thread_id, emuenv.kernel.threads, emuenv.kernel.mutex);
|
||||
const ThreadStatePtr thread = emuenv.kernel.get_thread(thread_id);
|
||||
|
||||
if (!thread) {
|
||||
return SCE_KERNEL_ERROR_UNKNOWN_THREAD_ID;
|
||||
@@ -316,7 +316,7 @@ EXPORT(int, sceClibPrintf, const char *fmt, module::vargs args) {
|
||||
|
||||
EXPORT(int, sceClibSnprintf, char *dst, SceSize dst_max_size, const char *fmt, module::vargs args) {
|
||||
TRACY_FUNC(sceClibSnprintf, dst, dst_max_size, fmt);
|
||||
const ThreadStatePtr thread = lock_and_find(thread_id, emuenv.kernel.threads, emuenv.kernel.mutex);
|
||||
const ThreadStatePtr thread = emuenv.kernel.get_thread(thread_id);
|
||||
|
||||
if (!thread) {
|
||||
return SCE_KERNEL_ERROR_UNKNOWN_THREAD_ID;
|
||||
@@ -454,7 +454,7 @@ EXPORT(int, sceClibVdprintf) {
|
||||
|
||||
EXPORT(int, sceClibVprintf, const char *fmt, module::vargs args) {
|
||||
TRACY_FUNC(sceClibVprintf, fmt);
|
||||
const ThreadStatePtr thread = lock_and_find(thread_id, emuenv.kernel.threads, emuenv.kernel.mutex);
|
||||
const ThreadStatePtr thread = emuenv.kernel.get_thread(thread_id);
|
||||
if (!thread) {
|
||||
return SCE_KERNEL_ERROR_UNKNOWN_THREAD_ID;
|
||||
}
|
||||
@@ -473,7 +473,7 @@ EXPORT(int, sceClibVprintf, const char *fmt, module::vargs args) {
|
||||
|
||||
EXPORT(int, sceClibVsnprintf, char *dst, SceSize dst_max_size, const char *fmt, Address list) {
|
||||
TRACY_FUNC(sceClibVsnprintf, dst, dst_max_size, fmt, list);
|
||||
const ThreadStatePtr thread = lock_and_find(thread_id, emuenv.kernel.threads, emuenv.kernel.mutex);
|
||||
const ThreadStatePtr thread = emuenv.kernel.get_thread(thread_id);
|
||||
|
||||
module::vargs args(list);
|
||||
if (!thread) {
|
||||
@@ -597,7 +597,7 @@ EXPORT(int, sceIoIoctlAsync) {
|
||||
|
||||
EXPORT(SceOff, sceIoLseek, const SceUID fd, const SceOff offset, const SceIoSeekMode whence) {
|
||||
TRACY_FUNC(sceIoLseek, fd, offset, whence);
|
||||
const ThreadStatePtr thread = lock_and_find(thread_id, emuenv.kernel.threads, emuenv.kernel.mutex);
|
||||
const ThreadStatePtr thread = emuenv.kernel.get_thread(thread_id);
|
||||
|
||||
Ptr<_sceIoLseekOpt> options = Ptr<_sceIoLseekOpt>(stack_alloc(*thread->cpu, sizeof(_sceIoLseekOpt)));
|
||||
options.get(emuenv.mem)->offset = offset;
|
||||
@@ -1181,7 +1181,7 @@ EXPORT(int, sceKernelCreateEventFlag, const char *name, unsigned int attr, unsig
|
||||
|
||||
EXPORT(int, sceKernelCreateLwCond, Ptr<SceKernelLwCondWork> workarea, const char *name, SceUInt attr, Ptr<SceKernelLwMutexWork> workarea_mutex, Ptr<SceKernelLwCondOptParam> opt_param) {
|
||||
TRACY_FUNC(sceKernelCreateLwCond, workarea, name, attr, workarea_mutex, opt_param);
|
||||
const ThreadStatePtr thread = lock_and_find(thread_id, emuenv.kernel.threads, emuenv.kernel.mutex);
|
||||
const ThreadStatePtr thread = emuenv.kernel.get_thread(thread_id);
|
||||
|
||||
Ptr<SceKernelCreateLwCond_opt> options = Ptr<SceKernelCreateLwCond_opt>(stack_alloc(*thread->cpu, sizeof(SceKernelCreateLwCond_opt)));
|
||||
options.get(emuenv.mem)->workarea_mutex = workarea_mutex;
|
||||
@@ -1208,7 +1208,7 @@ EXPORT(int, sceKernelCreateMsgPipeWithLR) {
|
||||
|
||||
EXPORT(int, sceKernelCreateMutex, const char *name, SceUInt attr, int init_count, SceKernelMutexOptParam *opt_param) {
|
||||
TRACY_FUNC(sceKernelCreateMutex, name, attr, init_count, opt_param);
|
||||
if ((attr & SCE_KERNEL_MUTEX_ATTR_CEILING)) {
|
||||
if (attr & SCE_KERNEL_MUTEX_ATTR_CEILING) {
|
||||
STUBBED("priority ceiling feature is not supported");
|
||||
}
|
||||
|
||||
@@ -1226,7 +1226,7 @@ EXPORT(SceUID, sceKernelCreateRWLock, const char *name, SceUInt32 attr, SceKerne
|
||||
|
||||
EXPORT(SceUID, sceKernelCreateSema, const char *name, SceUInt attr, int initVal, int maxVal, Ptr<SceKernelSemaOptParam> option) {
|
||||
TRACY_FUNC(sceKernelCreateSema, name, attr, initVal, maxVal, option);
|
||||
const ThreadStatePtr thread = lock_and_find(thread_id, emuenv.kernel.threads, emuenv.kernel.mutex);
|
||||
const ThreadStatePtr thread = emuenv.kernel.get_thread(thread_id);
|
||||
|
||||
Ptr<SceKernelCreateSema_opt> options = Ptr<SceKernelCreateSema_opt>(stack_alloc(*thread->cpu, sizeof(SceKernelCreateSema_opt)));
|
||||
options.get(emuenv.mem)->maxVal = maxVal;
|
||||
@@ -1238,7 +1238,7 @@ EXPORT(SceUID, sceKernelCreateSema, const char *name, SceUInt attr, int initVal,
|
||||
|
||||
EXPORT(int, sceKernelCreateSema_16XX, const char *name, SceUInt attr, int initVal, int maxVal, Ptr<SceKernelSemaOptParam> option) {
|
||||
TRACY_FUNC(sceKernelCreateSema_16XX, name, attr, initVal, maxVal, option);
|
||||
const ThreadStatePtr thread = lock_and_find(thread_id, emuenv.kernel.threads, emuenv.kernel.mutex);
|
||||
const ThreadStatePtr thread = emuenv.kernel.get_thread(thread_id);
|
||||
|
||||
Ptr<SceKernelCreateSema_opt> options = Ptr<SceKernelCreateSema_opt>(stack_alloc(*thread->cpu, sizeof(SceKernelCreateSema_opt)));
|
||||
options.get(emuenv.mem)->maxVal = maxVal;
|
||||
@@ -1255,7 +1255,7 @@ EXPORT(SceUID, sceKernelCreateSimpleEvent, const char *name, SceUInt32 attr, Sce
|
||||
|
||||
EXPORT(SceUID, sceKernelCreateThread, const char *name, SceKernelThreadEntry entry, int init_priority, int stack_size, SceUInt attr, int cpu_affinity_mask, Ptr<SceKernelThreadOptParam> option) {
|
||||
TRACY_FUNC(sceKernelCreateThread, name, entry, init_priority, stack_size, attr, cpu_affinity_mask, option);
|
||||
const ThreadStatePtr thread = lock_and_find(thread_id, emuenv.kernel.threads, emuenv.kernel.mutex);
|
||||
const ThreadStatePtr thread = emuenv.kernel.get_thread(thread_id);
|
||||
|
||||
auto options = Ptr<SceKernelCreateThread_opt>(stack_alloc(*thread->cpu, sizeof(SceKernelCreateThread_opt))).get(emuenv.mem);
|
||||
options->stack_size = stack_size;
|
||||
@@ -1456,7 +1456,7 @@ EXPORT(int, sceKernelGetThreadEventInfo) {
|
||||
|
||||
EXPORT(int, sceKernelGetThreadExitStatus, SceUID thid, SceInt32 *pExitStatus) {
|
||||
TRACY_FUNC(sceKernelGetThreadExitStatus, thid, pExitStatus);
|
||||
const ThreadStatePtr thread = lock_and_find(thid ? thid : thread_id, emuenv.kernel.threads, emuenv.kernel.mutex);
|
||||
const ThreadStatePtr thread = emuenv.kernel.get_thread(thid ? thid : thread_id);
|
||||
if (!thread) {
|
||||
return SCE_KERNEL_ERROR_UNKNOWN_THREAD_ID;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
TRACY_MODULE_NAME(SceLibc);
|
||||
|
||||
Ptr<void> g_dso;
|
||||
static Ptr<void> g_dso;
|
||||
|
||||
EXPORT(int, _Assert) {
|
||||
TRACY_FUNC(_Assert);
|
||||
@@ -962,7 +962,7 @@ EXPORT(int, printf, const char *format, module::vargs args) {
|
||||
// TODO: add args to tracy func
|
||||
std::vector<char> buffer(1024);
|
||||
|
||||
const ThreadStatePtr thread = lock_and_find(thread_id, emuenv.kernel.threads, emuenv.kernel.mutex);
|
||||
const ThreadStatePtr thread = emuenv.kernel.get_thread(thread_id);
|
||||
|
||||
if (!thread) {
|
||||
return SCE_KERNEL_ERROR_UNKNOWN_THREAD_ID;
|
||||
|
||||
@@ -256,7 +256,7 @@ EXPORT(int, sceNetCtlCheckCallback) {
|
||||
|
||||
emuenv.net.state = 1;
|
||||
|
||||
const ThreadStatePtr thread = lock_and_find(thread_id, emuenv.kernel.threads, emuenv.kernel.mutex);
|
||||
const ThreadStatePtr thread = emuenv.kernel.get_thread(thread_id);
|
||||
|
||||
// TODO: Limit the number of callbacks called to 5
|
||||
// TODO: Check in which order the callbacks are executed
|
||||
|
||||
@@ -177,7 +177,7 @@ EXPORT(int, sceNgsVoiceDefGetPauserBussInternal) {
|
||||
return UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
EXPORT(int, sceNgsVoiceDefGetPitchshiftBussInternal) {
|
||||
EXPORT(int, sceNgsVoiceDefGetPitchShiftBussInternal) {
|
||||
return UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
#include "../SceProcessmgr/SceProcessmgr.h"
|
||||
|
||||
#include <modules/module_parent.h>
|
||||
#include <ngs/state.h>
|
||||
#include <ngs/system.h>
|
||||
#include <util/log.h>
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
#include <io/state.h>
|
||||
#include <kernel/state.h>
|
||||
#include <np/state.h>
|
||||
#include <util/lock_and_find.h>
|
||||
#include <util/log.h>
|
||||
|
||||
#include <np/functions.h>
|
||||
@@ -30,17 +29,22 @@
|
||||
#include <util/tracy.h>
|
||||
TRACY_MODULE_NAME(SceNpManager);
|
||||
|
||||
#define SCE_NP_ERROR_ALREADY_INITIALIZED 0x80550001
|
||||
#define SCE_NP_ERROR_NOT_INITIALIZED 0x80550002
|
||||
#define SCE_NP_ERROR_INVALID_ARGUMENT 0x80550003
|
||||
#define SCE_NP_ERROR_UNKNOWN_PLATFORM_TYPE 0x80550004
|
||||
#define SCE_NP_MANAGER_ERROR_ABORTED 0x80550507
|
||||
#define SCE_NP_MANAGER_ERROR_ALREADY_INITIALIZED 0x80550501
|
||||
#define SCE_NP_MANAGER_ERROR_OUT_OF_MEMORY 0x80550504
|
||||
#define SCE_NP_MANAGER_ERROR_NOT_INITIALIZED 0x80550502
|
||||
#define SCE_NP_MANAGER_ERROR_INVALID_ARGUMENT 0x80550503
|
||||
#define SCE_NP_MANAGER_ERROR_INVALID_STATE 0x80550506
|
||||
#define SCE_NP_MANAGER_ERROR_ID_NOT_AVAIL 0x80550509
|
||||
enum SceNpErrorCode : uint32_t {
|
||||
SCE_NP_ERROR_ALREADY_INITIALIZED = 0x80550001,
|
||||
SCE_NP_ERROR_NOT_INITIALIZED = 0x80550002,
|
||||
SCE_NP_ERROR_INVALID_ARGUMENT = 0x80550003,
|
||||
SCE_NP_ERROR_UNKNOWN_PLATFORM_TYPE = 0x80550004
|
||||
};
|
||||
|
||||
enum SceNpManagerErrorCode : uint32_t {
|
||||
SCE_NP_MANAGER_ERROR_ABORTED = 0x80550507,
|
||||
SCE_NP_MANAGER_ERROR_ALREADY_INITIALIZED = 0x80550501,
|
||||
SCE_NP_MANAGER_ERROR_OUT_OF_MEMORY = 0x80550504,
|
||||
SCE_NP_MANAGER_ERROR_NOT_INITIALIZED = 0x80550502,
|
||||
SCE_NP_MANAGER_ERROR_INVALID_ARGUMENT = 0x80550503,
|
||||
SCE_NP_MANAGER_ERROR_INVALID_STATE = 0x80550506,
|
||||
SCE_NP_MANAGER_ERROR_ID_NOT_AVAIL = 0x80550509
|
||||
};
|
||||
|
||||
EXPORT(int, sceNpAuthAbortOAuthRequest) {
|
||||
TRACY_FUNC(sceNpAuthAbortOAuthRequest);
|
||||
@@ -65,7 +69,7 @@ EXPORT(int, sceNpAuthGetAuthorizationCode) {
|
||||
EXPORT(int, sceNpCheckCallback) {
|
||||
TRACY_FUNC(sceNpCheckCallback);
|
||||
|
||||
const ThreadStatePtr thread = lock_and_find(thread_id, emuenv.kernel.threads, emuenv.kernel.mutex);
|
||||
const ThreadStatePtr thread = emuenv.kernel.get_thread(thread_id);
|
||||
const SceNpServiceState state = emuenv.cfg.current_config.psn_signed_in ? SCE_NP_SERVICE_STATE_SIGNED_IN : SCE_NP_SERVICE_STATE_SIGNED_OUT;
|
||||
for (auto &[_, np_callback] : emuenv.np.cbs) {
|
||||
thread->run_callback(np_callback.pc, { static_cast<uint32_t>(state), 0, np_callback.data });
|
||||
@@ -139,10 +143,11 @@ EXPORT(int, sceNpManagerGetNpId, np::SceNpId *id) {
|
||||
EXPORT(int, sceNpRegisterServiceStateCallback, Ptr<void> callback, Ptr<void> data) {
|
||||
TRACY_FUNC(sceNpRegisterServiceStateCallback, callback, data);
|
||||
const std::lock_guard<std::mutex> lock(emuenv.kernel.mutex);
|
||||
uint32_t cid = emuenv.kernel.get_next_uid();
|
||||
SceNpServiceStateCallback sceNpServiceStateCallback;
|
||||
sceNpServiceStateCallback.pc = callback.address();
|
||||
sceNpServiceStateCallback.data = data.address();
|
||||
SceUID cid = emuenv.kernel.get_next_uid();
|
||||
SceNpServiceStateCallback sceNpServiceStateCallback{
|
||||
.pc = callback.address(),
|
||||
.data = data.address()
|
||||
};
|
||||
emuenv.np.cbs.emplace(cid, sceNpServiceStateCallback);
|
||||
emuenv.np.state_cb_id = cid;
|
||||
return 0;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user