mirror of
https://github.com/RPCS3/rpcs3.git
synced 2026-07-09 17:25:18 -06:00
Use pos param of read_from_ptr and write_to_ptr where possible
This commit is contained in:
parent
cffd02bb35
commit
d63273c473
@ -289,8 +289,8 @@ error_code cellGifDecReadHeader(vm::ptr<GifDecoder> mainHandle, vm::ptr<GifStrea
|
|||||||
default: break; // TODO
|
default: break; // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
if (read_from_ptr<be_t<u32>>(buffer + 0) != 0x47494638u ||
|
if (read_from_ptr<be_t<u32>>(buffer, 0) != 0x47494638u ||
|
||||||
(read_from_ptr<le_t<u16>>(buffer + 4) != 0x6139u && read_from_ptr<le_t<u16>>(buffer + 4) != 0x6137u)) // Error: The first 6 bytes are not a valid GIF signature
|
(read_from_ptr<le_t<u16>>(buffer, 4) != 0x6139u && read_from_ptr<le_t<u16>>(buffer, 4) != 0x6137u)) // Error: The first 6 bytes are not a valid GIF signature
|
||||||
{
|
{
|
||||||
return CELL_GIFDEC_ERROR_STREAM_FORMAT; // Surprisingly there is no error code related with headerss
|
return CELL_GIFDEC_ERROR_STREAM_FORMAT; // Surprisingly there is no error code related with headerss
|
||||||
}
|
}
|
||||||
|
|||||||
@ -125,26 +125,26 @@ error_code cellJpgDecReadHeader(u32 mainHandle, u32 subHandle, vm::ptr<CellJpgDe
|
|||||||
CellJpgDecInfo& current_info = subHandle_data->info;
|
CellJpgDecInfo& current_info = subHandle_data->info;
|
||||||
|
|
||||||
// Write the header to buffer
|
// Write the header to buffer
|
||||||
std::unique_ptr<u8[]> buffer(new u8[fileSize]);
|
std::vector<u8> buffer(fileSize);
|
||||||
|
|
||||||
switch (subHandle_data->src.srcSelect)
|
switch (subHandle_data->src.srcSelect)
|
||||||
{
|
{
|
||||||
case CELL_JPGDEC_BUFFER:
|
case CELL_JPGDEC_BUFFER:
|
||||||
std::memcpy(buffer.get(), vm::base(subHandle_data->src.streamPtr), fileSize);
|
std::memcpy(buffer.data(), vm::base(subHandle_data->src.streamPtr), fileSize);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CELL_JPGDEC_FILE:
|
case CELL_JPGDEC_FILE:
|
||||||
{
|
{
|
||||||
auto file = idm::get_unlocked<lv2_fs_object, lv2_file>(fd);
|
auto file = idm::get_unlocked<lv2_fs_object, lv2_file>(fd);
|
||||||
file->file.seek(0);
|
file->file.seek(0);
|
||||||
file->file.read(buffer.get(), fileSize);
|
file->file.read(buffer.data(), fileSize);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: break; // TODO
|
default: break; // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
if (read_from_ptr<le_t<u32>>(buffer.get() + 0) != 0xE0FFD8FF || // Error: Not a valid SOI header
|
if (read_from_ptr<le_t<u32>>(buffer, 0) != 0xE0FFD8FF || // Error: Not a valid SOI header
|
||||||
read_from_ptr<u32>(buffer.get() + 6) != "JFIF"_u32) // Error: Not a valid JFIF string
|
read_from_ptr<u32>(buffer, 6) != "JFIF"_u32) // Error: Not a valid JFIF string
|
||||||
{
|
{
|
||||||
return CELL_JPGDEC_ERROR_HEADER;
|
return CELL_JPGDEC_ERROR_HEADER;
|
||||||
}
|
}
|
||||||
@ -154,7 +154,7 @@ error_code cellJpgDecReadHeader(u32 mainHandle, u32 subHandle, vm::ptr<CellJpgDe
|
|||||||
if (i >= fileSize)
|
if (i >= fileSize)
|
||||||
return CELL_JPGDEC_ERROR_HEADER;
|
return CELL_JPGDEC_ERROR_HEADER;
|
||||||
|
|
||||||
u16 block_length = buffer[i] * 0xFF + buffer[i + 1];
|
u16 block_length = ::at32(buffer, i) * 0xFF + ::at32(buffer, i + 1);
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
@ -165,15 +165,16 @@ error_code cellJpgDecReadHeader(u32 mainHandle, u32 subHandle, vm::ptr<CellJpgDe
|
|||||||
return CELL_JPGDEC_ERROR_HEADER;
|
return CELL_JPGDEC_ERROR_HEADER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buffer[i + 1] == 0xC0)
|
const u8 next = ::at32(buffer, i + 1);
|
||||||
|
if (next == 0xC0)
|
||||||
break; // 0xFFC0 is the "Start of frame" marker which contains the file size
|
break; // 0xFFC0 is the "Start of frame" marker which contains the file size
|
||||||
|
|
||||||
i += 2; // Skip the block marker
|
i += 2; // Skip the block marker
|
||||||
block_length = buffer[i] * 0xFF + buffer[i + 1]; // Go to the next block
|
block_length = ::at32(buffer, i) * 0xFF + next; // Go to the next block
|
||||||
}
|
}
|
||||||
|
|
||||||
current_info.imageWidth = buffer[i + 7] * 0x100 + buffer[i + 8];
|
current_info.imageWidth = ::at32(buffer, i + 7) * 0x100 + ::at32(buffer, i + 8);
|
||||||
current_info.imageHeight = buffer[i + 5] * 0x100 + buffer[i + 6];
|
current_info.imageHeight = ::at32(buffer, i + 5) * 0x100 + ::at32(buffer, i + 6);
|
||||||
current_info.numComponents = 3; // Unimplemented
|
current_info.numComponents = 3; // Unimplemented
|
||||||
current_info.colorSpace = CELL_JPG_RGB;
|
current_info.colorSpace = CELL_JPG_RGB;
|
||||||
|
|
||||||
|
|||||||
@ -2368,7 +2368,7 @@ std::vector<u32> spu_thread::discover_functions(u32 base_addr, std::span<const u
|
|||||||
{
|
{
|
||||||
// Search for BRSL LR and BRASL LR or BR
|
// Search for BRSL LR and BRASL LR or BR
|
||||||
// TODO: BISL
|
// TODO: BISL
|
||||||
const v128 inst = read_from_ptr<be_t<v128>>(ls.data(), i - base_addr);
|
const v128 inst = read_from_ptr<be_t<v128>>(ls, i - base_addr);
|
||||||
const v128 cleared_i16 = gv_and32(inst, v128::from32p(std::rotl<u32>(~0xffff, 7)));
|
const v128 cleared_i16 = gv_and32(inst, v128::from32p(std::rotl<u32>(~0xffff, 7)));
|
||||||
const v128 eq_brsl = gv_eq32(cleared_i16, v128::from32p(0x66u << 23));
|
const v128 eq_brsl = gv_eq32(cleared_i16, v128::from32p(0x66u << 23));
|
||||||
const v128 eq_brasl = gv_eq32(cleared_i16, brasl_mask);
|
const v128 eq_brasl = gv_eq32(cleared_i16, brasl_mask);
|
||||||
|
|||||||
@ -658,7 +658,7 @@ void lv2_file::save(utils::serial& ar)
|
|||||||
sys_fs.error("Read less than expected! (new-size=0x%x)", read_size);
|
sys_fs.error("Read less than expected! (new-size=0x%x)", read_size);
|
||||||
stats.size = read_size;
|
stats.size = read_size;
|
||||||
ar.data.resize(old_end + stats.size);
|
ar.data.resize(old_end + stats.size);
|
||||||
write_to_ptr<fs::stat_t>(&ar.data[patch_stats_pos], stats);
|
write_to_ptr<fs::stat_t>(ar.data, patch_stats_pos, stats);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -214,7 +214,7 @@ u32 dimensions_toypad::scramble(const std::array<u8, 7>& uid, u8 count)
|
|||||||
}
|
}
|
||||||
::at32(to_scramble, count * 4 - 1) = 0xaa;
|
::at32(to_scramble, count * 4 - 1) = 0xaa;
|
||||||
|
|
||||||
return read_from_ptr<be_t<u32>>(dimensions_randomize(to_scramble, count).data());
|
return read_from_ptr<be_t<u32>>(dimensions_randomize(to_scramble, count));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::array<u8, 4> dimensions_toypad::dimensions_randomize(const std::vector<u8>& key, u8 count)
|
std::array<u8, 4> dimensions_toypad::dimensions_randomize(const std::vector<u8>& key, u8 count)
|
||||||
@ -522,7 +522,7 @@ bool dimensions_toypad::create_blank_character(std::array<u8, 0x2D * 0x04>& buf,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Page 38 is used as verification for blank tags
|
// Page 38 is used as verification for blank tags
|
||||||
write_to_ptr<be_t<u16>>(buf.data(), 38 * 4, 1);
|
write_to_ptr<be_t<u16>>(buf, 38 * 4, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@ -359,7 +359,7 @@ namespace np
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 given_size = read_from_ptr<be_t<u32>>(data() + 4);
|
u32 given_size = read_from_ptr<be_t<u32>>(data(), 4);
|
||||||
if ((given_size + 8) != size())
|
if ((given_size + 8) != size())
|
||||||
{
|
{
|
||||||
ticket_log.error("Size mismatch (gs: %d vs s: %d)", given_size, size());
|
ticket_log.error("Size mismatch (gs: %d vs s: %d)", given_size, size());
|
||||||
|
|||||||
@ -503,8 +503,8 @@ namespace rpcn
|
|||||||
{
|
{
|
||||||
if (msg.size() == 6)
|
if (msg.size() == 6)
|
||||||
{
|
{
|
||||||
const u32 new_addr_sig = read_from_ptr<le_t<u32>>(&msg[0]);
|
const u32 new_addr_sig = read_from_ptr<le_t<u32>>(msg, 0);
|
||||||
const u16 new_port_sig = read_from_ptr<be_t<u16>>(&msg[4]);
|
const u16 new_port_sig = read_from_ptr<be_t<u16>>(msg, 4);
|
||||||
const u32 old_addr_sig = addr_sig;
|
const u32 old_addr_sig = addr_sig;
|
||||||
const u32 old_port_sig = port_sig;
|
const u32 old_port_sig = port_sig;
|
||||||
|
|
||||||
@ -533,7 +533,7 @@ namespace rpcn
|
|||||||
// We don't really need ipv6 info stored so we just update the pong data
|
// We don't really need ipv6 info stored so we just update the pong data
|
||||||
// std::array<u8, 16> new_ipv6_addr;
|
// std::array<u8, 16> new_ipv6_addr;
|
||||||
// std::memcpy(new_ipv6_addr.data(), &msg[3], 16);
|
// std::memcpy(new_ipv6_addr.data(), &msg[3], 16);
|
||||||
// const u32 new_ipv6_port = read_from_ptr<be_t<u16>>(&msg[16]);
|
// const u32 new_ipv6_port = read_from_ptr<be_t<u16>>(msg, 16);
|
||||||
|
|
||||||
last_pong_time_ipv6 = now;
|
last_pong_time_ipv6 = now;
|
||||||
}
|
}
|
||||||
@ -626,9 +626,9 @@ namespace rpcn
|
|||||||
}
|
}
|
||||||
|
|
||||||
const u8 packet_type = header[0];
|
const u8 packet_type = header[0];
|
||||||
const auto command = static_cast<rpcn::CommandType>(static_cast<u16>(read_from_ptr<le_t<u16>>(&header[1])));
|
const auto command = static_cast<rpcn::CommandType>(static_cast<u16>(read_from_ptr<le_t<u16>>(header, 1)));
|
||||||
const u32 packet_size = read_from_ptr<le_t<u32>>(&header[3]);
|
const u32 packet_size = read_from_ptr<le_t<u32>>(header, 3);
|
||||||
const u64 packet_id = read_from_ptr<le_t<u64>>(&header[7]);
|
const u64 packet_id = read_from_ptr<le_t<u64>>(header, 7);
|
||||||
|
|
||||||
if (packet_size < RPCN_HEADER_SIZE)
|
if (packet_size < RPCN_HEADER_SIZE)
|
||||||
return error_and_disconnect("Invalid packet size");
|
return error_and_disconnect("Invalid packet size");
|
||||||
|
|||||||
@ -67,7 +67,7 @@ public:
|
|||||||
error = true;
|
error = true;
|
||||||
return static_cast<T>(0);
|
return static_cast<T>(0);
|
||||||
}
|
}
|
||||||
T res = read_from_ptr<le_t<T>>(&vec[i]);
|
T res = read_from_ptr<le_t<T>>(vec, i);
|
||||||
i += sizeof(T);
|
i += sizeof(T);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -183,11 +183,11 @@ namespace rsx
|
|||||||
const usz first_index_off = 0;
|
const usz first_index_off = 0;
|
||||||
const usz second_index_off = (((rcount / 4) - 1) / 2) * 4;
|
const usz second_index_off = (((rcount / 4) - 1) / 2) * 4;
|
||||||
|
|
||||||
const u64 src_op1_2 = read_from_ptr<be_t<u64>>(fifo_span.data() + first_index_off);
|
const u64 src_op1_2 = read_from_ptr<be_t<u64>>(fifo_span, first_index_off);
|
||||||
const u64 src_op2_2 = read_from_ptr<be_t<u64>>(fifo_span.data() + second_index_off);
|
const u64 src_op2_2 = read_from_ptr<be_t<u64>>(fifo_span, second_index_off);
|
||||||
|
|
||||||
// Fast comparison
|
// Fast comparison
|
||||||
if (src_op1_2 != read_from_ptr<u64>(out_ptr + first_index_off) || src_op2_2 != read_from_ptr<u64>(out_ptr + second_index_off))
|
if (src_op1_2 != read_from_ptr<u64>(out_ptr, first_index_off) || src_op2_2 != read_from_ptr<u64>(out_ptr, second_index_off))
|
||||||
{
|
{
|
||||||
to_set_dirty = rsx::pipeline_state::vertex_program_ucode_dirty;
|
to_set_dirty = rsx::pipeline_state::vertex_program_ucode_dirty;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -234,7 +234,7 @@ kamen_rider_creator_dialog::kamen_rider_creator_dialog(QWidget* parent)
|
|||||||
std::array<u8, 16> figure_data = {static_cast<u8>(dist(mt)), 0x03, 0x00, 0x00, 0x01, 0x0e, 0x0a, 0x0a,
|
std::array<u8, 16> figure_data = {static_cast<u8>(dist(mt)), 0x03, 0x00, 0x00, 0x01, 0x0e, 0x0a, 0x0a,
|
||||||
static_cast<u8>(fig_id & 0xff), static_cast<u8>((fig_id >> 8) & 0xff),
|
static_cast<u8>(fig_id & 0xff), static_cast<u8>((fig_id >> 8) & 0xff),
|
||||||
static_cast<u8>((fig_id >> 16) & 0xff), static_cast<u8>((fig_id >> 24) & 0xff)};
|
static_cast<u8>((fig_id >> 16) & 0xff), static_cast<u8>((fig_id >> 24) & 0xff)};
|
||||||
write_to_ptr<le_t<u32>>(figure_data.data(), 0xC, kamen_rider_crc32(figure_data));
|
write_to_ptr<le_t<u32>>(figure_data, 0xC, kamen_rider_crc32(figure_data));
|
||||||
memcpy(&buf[16], figure_data.data(), figure_data.size());
|
memcpy(&buf[16], figure_data.data(), figure_data.size());
|
||||||
fig_file.write(buf.data(), buf.size());
|
fig_file.write(buf.data(), buf.size());
|
||||||
fig_file.close();
|
fig_file.close();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user