From 0b829be79830f449b41081af06427ec2abdd33db Mon Sep 17 00:00:00 2001 From: brian218 Date: Wed, 26 Jul 2023 17:36:44 +0800 Subject: [PATCH] sys_fs: Fixed up sys_fs_fcntl(0xc0000007) aka cellFsArcadeHddSerialNumber according to real hardware testing --- rpcs3/Emu/Cell/lv2/sys_fs.cpp | 29 ++++++++++------------------- rpcs3/Emu/Cell/lv2/sys_fs.h | 4 ++-- rpcs3/Emu/Io/usio.cpp | 2 +- 3 files changed, 13 insertions(+), 22 deletions(-) diff --git a/rpcs3/Emu/Cell/lv2/sys_fs.cpp b/rpcs3/Emu/Cell/lv2/sys_fs.cpp index 2f41a8f360..575000565f 100644 --- a/rpcs3/Emu/Cell/lv2/sys_fs.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_fs.cpp @@ -2064,27 +2064,18 @@ error_code sys_fs_fcntl(ppu_thread& ppu, u32 fd, u32 op, vm::ptr _arg, u32 { const auto arg = vm::static_ptr_cast(_arg); - std::string_view device{arg->device.get_ptr(), arg->device_size}; - - // Trim trailing '\0' - if (const auto trim_pos = device.find('\0'); trim_pos != umax) - device.remove_suffix(device.size() - trim_pos); - - if (device != "CELL_FS_IOS:ATA_HDD"sv) - { - arg->out_code = CELL_ENOTSUP; - return {CELL_ENOTSUP, device}; - } - - const auto model = g_cfg.sys.hdd_model.to_string(); - const auto serial = g_cfg.sys.hdd_serial.to_string(); - - strcpy_trunc(std::span(arg->model.get_ptr(), arg->model_size), model); - strcpy_trunc(std::span(arg->serial.get_ptr(), arg->serial_size), serial); - arg->out_code = CELL_OK; - sys_fs.trace("sys_fs_fcntl(0xc0000007): found device \"%s\" (model=\"%s\", serial=\"%s\")", device, model, serial); + if (const auto size = arg->model_size; size > 0) + strcpy_trunc(std::span(arg->model.get_ptr(), size), + fmt::format("%-*s", size - 1, g_cfg.sys.hdd_model.to_string())); // Example: "TOSHIBA MK3265GSX H " + + if (const auto size = arg->serial_size; size > 0) + strcpy_trunc(std::span(arg->serial.get_ptr(), size), + fmt::format("%*s", size - 1, g_cfg.sys.hdd_serial.to_string())); // Example: " 0A1B2C3D4" + else + return CELL_EFAULT; // CELL_EFAULT is returned only when arg->serial_size == 0 + return CELL_OK; } diff --git a/rpcs3/Emu/Cell/lv2/sys_fs.h b/rpcs3/Emu/Cell/lv2/sys_fs.h index 0f5c9a3be3..1f1e2c2ec1 100644 --- a/rpcs3/Emu/Cell/lv2/sys_fs.h +++ b/rpcs3/Emu/Cell/lv2/sys_fs.h @@ -529,8 +529,8 @@ CHECK_SIZE(lv2_file_c0000006, 0x20); // sys_fs_fcntl: cellFsArcadeHddSerialNumber struct lv2_file_c0000007 : lv2_file_op { - be_t out_code; - vm::bcptr device; + be_t out_code; // set to 0 + vm::bcptr device; // CELL_FS_IOS:ATA_HDD be_t device_size; // 0x14 vm::bptr model; be_t model_size; // 0x29 diff --git a/rpcs3/Emu/Io/usio.cpp b/rpcs3/Emu/Io/usio.cpp index 0da11170fc..a5b4348937 100644 --- a/rpcs3/Emu/Io/usio.cpp +++ b/rpcs3/Emu/Io/usio.cpp @@ -334,7 +334,7 @@ void usb_device_usio::translate_input_tekken() } break; case usio_btn::down: - if ( pressed) + if (pressed) { digital_input |= 0x100000ULL << shift; if (player == 0)