From 3c0558c8225087cd6a4e14a18641e87b3102b798 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Fri, 12 Dec 2025 09:30:28 +0100 Subject: [PATCH] cellGem: Implement CELL_CAMERA_RAW8 to CELL_GEM_BAYER_RESTORED_RGGB --- rpcs3/Emu/Cell/Modules/cellGem.cpp | 45 +++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/rpcs3/Emu/Cell/Modules/cellGem.cpp b/rpcs3/Emu/Cell/Modules/cellGem.cpp index f11e3d89f8..f4cfb1db8d 100644 --- a/rpcs3/Emu/Cell/Modules/cellGem.cpp +++ b/rpcs3/Emu/Cell/Modules/cellGem.cpp @@ -1150,6 +1150,43 @@ namespace gem break; } case CELL_GEM_BAYER_RESTORED_RGGB: // Restored Bayer output, 2x2 pixels rearranged into 320x240 RG1G2B + { + if (input_format == CELL_CAMERA_RAW8) + { + const u32 dst_w = std::min(320u, width / 2); + const u32 dst_h = std::min(240u, height / 2); + const u32 in_pitch = width; + constexpr u32 out_pitch = 320 * 4; + + for (u32 y = 0; y < dst_h; y++) + { + const u8* src0 = &video_data_in[y * 2 * in_pitch]; + const u8* src1 = src0 + in_pitch; + + u8* dst = video_data_out + y * out_pitch; + + for (u32 x = 0; x < dst_w; x++, src0 += 2, src1 += 2, dst += 4) + { + const u8 b = src0[0]; + const u8 g0 = src0[1]; + const u8 g1 = src1[0]; + const u8 r = src1[1]; + + dst[0] = r; + dst[1] = g0; + dst[2] = g1; + dst[3] = b; + } + } + } + else + { + cellGem.error("Unimplemented: Converting %s to %s (called from %s)", input_format, output_format, caller); + std::memcpy(video_data_out, video_data_in.data(), std::min(required_in_size, required_out_size)); + return false; + } + break; + } case CELL_GEM_BAYER_RESTORED_RASTERIZED: // Restored Bayer output, R,G1,G2,B rearranged into 4 contiguous 320x240 1-channel rasters { cellGem.error("Unimplemented: Converting %s to %s (called from %s)", input_format, output_format, caller); @@ -1705,10 +1742,10 @@ static inline void pos_to_gem_state(u32 gem_num, gem_config::gem_controller& con // Calculate orientation if (g_cfg.io.move == move_handler::real || (g_cfg.io.move == move_handler::fake && move_data.orientation_enabled)) { - gem_state->quat[0] = move_data.quaternion[0]; // x - gem_state->quat[1] = move_data.quaternion[1]; // y - gem_state->quat[2] = move_data.quaternion[2]; // z - gem_state->quat[3] = move_data.quaternion[3]; // w + gem_state->quat[0] = move_data.quaternion.x(); + gem_state->quat[1] = move_data.quaternion.y(); + gem_state->quat[2] = move_data.quaternion.z(); + gem_state->quat[3] = move_data.quaternion.w(); } else {