diff --git a/rpcs3/Emu/RSX/Program/CgBinaryProgram.h b/rpcs3/Emu/RSX/Program/CgBinaryProgram.h index 56d8f4d70b..f956c93035 100644 --- a/rpcs3/Emu/RSX/Program/CgBinaryProgram.h +++ b/rpcs3/Emu/RSX/Program/CgBinaryProgram.h @@ -143,10 +143,10 @@ class CgBinaryDisasm std::vector m_loop_end_offsets; // VP members - u32 m_sca_opcode; - u32 m_vec_opcode; - static const usz m_max_instr_count = 512; - usz m_instr_count; + u32 m_sca_opcode = 0; + u32 m_vec_opcode = 0; + static constexpr usz m_max_instr_count = 512; + usz m_instr_count = 0; std::vector m_data; public: diff --git a/rpcs3/Emu/RSX/RSXZCULL.h b/rpcs3/Emu/RSX/RSXZCULL.h index 4627fa2ca5..679357b457 100644 --- a/rpcs3/Emu/RSX/RSXZCULL.h +++ b/rpcs3/Emu/RSX/RSXZCULL.h @@ -18,9 +18,8 @@ namespace rsx static inline std::string_view location_tostring(u32 location) { - ensure(location < 2); constexpr const char* location_names[2] = { "CELL_GCM_LOCATION_LOCAL", "CELL_GCM_LOCATION_MAIN" }; - return location_names[location]; + return ::at32(location_names, location); } static inline u32 classify_location(u32 address) diff --git a/rpcs3/Emu/RSX/VK/vkutils/garbage_collector.h b/rpcs3/Emu/RSX/VK/vkutils/garbage_collector.h index 3ca3c5e02c..48d531f18d 100644 --- a/rpcs3/Emu/RSX/VK/vkutils/garbage_collector.h +++ b/rpcs3/Emu/RSX/VK/vkutils/garbage_collector.h @@ -16,7 +16,7 @@ namespace vk disposable_t() = delete; disposable_t(const disposable_t&) = delete; - disposable_t(disposable_t&& other) : + disposable_t(disposable_t&& other) noexcept : ptr(std::exchange(other.ptr, nullptr)), deleter(other.deleter) {} diff --git a/rpcs3/rpcs3qt/memory_viewer_panel.cpp b/rpcs3/rpcs3qt/memory_viewer_panel.cpp index c381b18404..d2d03f01b9 100644 --- a/rpcs3/rpcs3qt/memory_viewer_panel.cpp +++ b/rpcs3/rpcs3qt/memory_viewer_panel.cpp @@ -425,7 +425,7 @@ memory_viewer_panel::memory_viewer_panel(QWidget* parent, std::shared_ptrtext()).toULong(&ok, 16); @@ -433,17 +433,17 @@ memory_viewer_panel::memory_viewer_panel(QWidget* parent, std::shared_ptr(&QSpinBox::valueChanged), [=, this]() + connect(sb_words, static_cast(&QSpinBox::valueChanged), this, [=, this]() { m_colcount = 1 << sb_words->value(); ShowMemory(); }); - connect(b_prev, &QAbstractButton::clicked, [this]() { scroll(-1); }); - connect(b_next, &QAbstractButton::clicked, [this]() { scroll(1); }); - connect(b_fprev, &QAbstractButton::clicked, [this]() { scroll(m_rowcount * -1); }); - connect(b_fnext, &QAbstractButton::clicked, [this]() { scroll(m_rowcount); }); - connect(b_img, &QAbstractButton::clicked, [=, this]() + connect(b_prev, &QAbstractButton::clicked, this, [this]() { scroll(-1); }); + connect(b_next, &QAbstractButton::clicked, this, [this]() { scroll(1); }); + connect(b_fprev, &QAbstractButton::clicked, this, [this]() { scroll(m_rowcount * -1); }); + connect(b_fnext, &QAbstractButton::clicked, this, [this]() { scroll(m_rowcount); }); + connect(b_img, &QAbstractButton::clicked, this, [=, this]() { const color_format format = cbox_img_mode->currentData().value(); const int sizex = sb_img_size_x->value(); @@ -580,7 +580,7 @@ memory_viewer_panel::memory_viewer_panel(QWidget* parent, std::shared_ptr(id); - connect(this, &memory_viewer_panel::finished, [handle_ptr = std::move(handle_ptr), id, this](int) + connect(this, &memory_viewer_panel::finished, this, [handle_ptr = std::move(handle_ptr), id, this](int) { if (m_search_thread) { @@ -617,7 +617,7 @@ memory_viewer_panel::~memory_viewer_panel() void memory_viewer_panel::wheelEvent(QWheelEvent *event) { - // Set some scrollspeed modifiers: + // Set some scroll speed modifiers: u32 step_size = 1; if (event->modifiers().testFlag(Qt::ControlModifier)) step_size *= m_rowcount; @@ -986,6 +986,7 @@ void memory_viewer_panel::ShowImage(QWidget* parent, u32 addr, color_format form const u32 memsize = utils::mul_saturate(utils::mul_saturate(texel_bytes, width), height); if (memsize == 0) { + gui_log.error("Can not show image. memsize is 0 (texel_bytes=%d, width=%d, height=%d)", texel_bytes, width, height); return; } @@ -993,6 +994,7 @@ void memory_viewer_panel::ShowImage(QWidget* parent, u32 addr, color_format form if (!originalBuffer) { + gui_log.error("Can not show image. originalBuffer is null (addr=%d, memsize=%d)", addr, memsize); return; } @@ -1001,6 +1003,7 @@ void memory_viewer_panel::ShowImage(QWidget* parent, u32 addr, color_format form if (!convertedBuffer) { // OOM or invalid memory address, give up + gui_log.error("Can not show image. convertedBuffer is null (addr=%d, memsize=%d)", addr, memsize); return; } @@ -1014,7 +1017,7 @@ void memory_viewer_panel::ShowImage(QWidget* parent, u32 addr, color_format form { const u32 offset = y * pitch; const u32 offset_new = y * pitch_new; - for (u32 x = 0, x_new = 0; x < pitch; x += 3, x_new += 4) + for (u32 x = 0, x_new = 0; x < pitch && x_new < pitch_new; x += 3, x_new += 4) { convertedBuffer[offset_new + x_new + 0] = originalBuffer[offset + x + 2]; convertedBuffer[offset_new + x_new + 1] = originalBuffer[offset + x + 1]; @@ -1116,19 +1119,20 @@ void memory_viewer_panel::ShowImage(QWidget* parent, u32 addr, color_format form } // Flip vertically - if (flipv && height > 1 && memsize > 1) + if (flipv && width > 0 && height > 1 && memsize > 1) { const u32 pitch = width * 4; + std::vector tmp_row(pitch); + for (u32 y = 0; y < height / 2; y++) { - const u32 offset = y * pitch; - const u32 flip_offset = (height - y - 1) * pitch; - for (u32 x = 0; x < pitch; x++) - { - const u8 tmp = convertedBuffer[offset + x]; - convertedBuffer[offset + x] = convertedBuffer[flip_offset + x]; - convertedBuffer[flip_offset + x] = tmp; - } + u8* row_top = &convertedBuffer[y * pitch]; + u8* row_bottom = &convertedBuffer[(height - y - 1) * pitch]; + + // Swap rows + std::memcpy(tmp_row.data(), row_top, pitch); + std::memcpy(row_top, row_bottom, pitch); + std::memcpy(row_bottom, tmp_row.data(), pitch); } } diff --git a/rpcs3/rpcs3qt/midi_creator.cpp b/rpcs3/rpcs3qt/midi_creator.cpp index 0a61eeae9b..57476af3d6 100644 --- a/rpcs3/rpcs3qt/midi_creator.cpp +++ b/rpcs3/rpcs3qt/midi_creator.cpp @@ -86,13 +86,12 @@ std::array midi_creator::get_selection_list() con std::string midi_creator::set_device(u32 num, const midi_device& device) { - ensure(num < m_sel_list.size()); - - m_sel_list[num] = device; + midi_device& dev = ::at32(m_sel_list, num); + dev = device; if (device.name == get_none().toStdString()) { - m_sel_list[num].name.clear(); + dev.name.clear(); } std::string result; diff --git a/rpcs3/rpcs3qt/recvmessage_dialog_frame.h b/rpcs3/rpcs3qt/recvmessage_dialog_frame.h index 10b9bd87e9..16303daa46 100644 --- a/rpcs3/rpcs3qt/recvmessage_dialog_frame.h +++ b/rpcs3/rpcs3qt/recvmessage_dialog_frame.h @@ -11,7 +11,7 @@ struct recvmessage_signal_struct { shared_ptr> msg; - u64 msg_id; + u64 msg_id = 0; }; Q_DECLARE_METATYPE(recvmessage_signal_struct); diff --git a/rpcs3/rpcs3qt/skylander_dialog.cpp b/rpcs3/rpcs3qt/skylander_dialog.cpp index beebb8a965..94d9025a17 100644 --- a/rpcs3/rpcs3qt/skylander_dialog.cpp +++ b/rpcs3/rpcs3qt/skylander_dialog.cpp @@ -17,7 +17,7 @@ skylander_dialog* skylander_dialog::inst = nullptr; std::optional> skylander_dialog::sky_slots[UI_SKY_NUM]; QString last_skylander_path; -const std::map, const std::string> list_skylanders = { +static const std::map, const std::string> list_skylanders = { {{0, 0x0000}, "Whirlwind"}, {{0, 0x1801}, "Series 2 Whirlwind"}, {{0, 0x1C02}, "Polar Whirlwind"}, @@ -502,7 +502,8 @@ const std::map, const std::string> list_sk u16 skylander_crc16(u16 init_value, const u8* buffer, u32 size) { - const unsigned short CRC_CCITT_TABLE[256] = {0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7, 0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF, 0x1231, 0x0210, 0x3273, + constexpr unsigned short CRC_CCITT_TABLE[256] = { + 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7, 0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF, 0x1231, 0x0210, 0x3273, 0x2252, 0x52B5, 0x4294, 0x72F7, 0x62D6, 0x9339, 0x8318, 0xB37B, 0xA35A, 0xD3BD, 0xC39C, 0xF3FF, 0xE3DE, 0x2462, 0x3443, 0x0420, 0x1401, 0x64E6, 0x74C7, 0x44A4, 0x5485, 0xA56A, 0xB54B, 0x8528, 0x9509, 0xE5EE, 0xF5CF, 0xC5AC, 0xD58D, 0x3653, 0x2672, 0x1611, 0x0630, 0x76D7, 0x66F6, 0x5695, 0x46B4, 0xB75B, 0xA77A, 0x9719, 0x8738, 0xF7DF, 0xE7FE, 0xD79D, 0xC7BC, 0x48C4, 0x58E5, 0x6886, 0x78A7, 0x0840, 0x1861, 0x2802, 0x3823, 0xC9CC, 0xD9ED, 0xE98E, 0xF9AF, 0x8948, 0x9969, 0xA90A, 0xB92B, 0x5AF5, 0x4AD4, 0x7AB7, 0x6A96, 0x1A71, 0x0A50, 0x3A33, 0x2A12, 0xDBFD, 0xCBDC, 0xFBBF,