diff --git a/rpcs3/Emu/Cell/Modules/cellGem.cpp b/rpcs3/Emu/Cell/Modules/cellGem.cpp index 2cca183988..cf50741942 100644 --- a/rpcs3/Emu/Cell/Modules/cellGem.cpp +++ b/rpcs3/Emu/Cell/Modules/cellGem.cpp @@ -526,6 +526,11 @@ error_code cellGemConvertVideoStart(vm::cptr video_frame) return CELL_GEM_ERROR_INVALID_PARAMETER; } + if (!video_frame.aligned(128)) + { + return CELL_GEM_ERROR_INVALID_ALIGNMENT; + } + if (std::exchange(gem.video_conversion_started, true)) { return CELL_GEM_ERROR_CONVERT_NOT_FINISHED; @@ -567,11 +572,22 @@ error_code cellGemEnableMagnetometer(u32 gem_num, u32 enable) return CELL_GEM_ERROR_UNINITIALIZED; } + if (!check_gem_num(gem_num)) + { + return CELL_GEM_ERROR_INVALID_PARAMETER; + } + if (!gem.is_controller_ready(gem_num)) { return CELL_GEM_NOT_CONNECTED; } + // NOTE: RE doesn't show this check but it is mentioned in the docs, so I'll leave it here for now. + //if (!gem.controllers[gem_num].calibrated_magnetometer) + //{ + // return CELL_GEM_NOT_CALIBRATED; + //} + gem.controllers[gem_num].enabled_magnetometer = !!enable; return CELL_OK; @@ -673,6 +689,8 @@ error_code cellGemGetAccelerometerPositionInDevice(u32 gem_num, vm::ptr pos return CELL_GEM_ERROR_INVALID_PARAMETER; } + // TODO + return CELL_OK; } @@ -747,6 +765,12 @@ error_code cellGemGetEnvironmentLightingColor(vm::ptr r, vm::ptr g, vm *g = 128; *b = 128; + // NOTE: RE doesn't show this check but it is mentioned in the docs, so I'll leave it here for now. + //if (!gem.controllers[gem_num].calibrated_magnetometer) + //{ + // return CELL_GEM_ERROR_LIGHTING_NOT_CALIBRATED; // This error doesn't really seem to be a real thing. + //} + return CELL_OK; } @@ -766,6 +790,8 @@ error_code cellGemGetHuePixels(vm::cptr camera_frame, u32 hue, vm::ptr return CELL_GEM_ERROR_INVALID_PARAMETER; } + // TODO + return CELL_OK; } @@ -829,6 +855,11 @@ error_code cellGemGetInertialState(u32 gem_num, u32 state_flag, u64 timestamp, v return CELL_GEM_ERROR_INVALID_PARAMETER; } + if (false) // TODO + { + return CELL_GEM_TIME_OUT_OF_RANGE; + } + if (g_cfg.io.move == move_handler::fake || g_cfg.io.move == move_handler::mouse) { ds3_input_to_ext(gem_num, gem.controllers[gem_num], inertial_state->ext); @@ -984,6 +1015,11 @@ error_code cellGemGetState(u32 gem_num, u32 flag, u64 time_parameter, vm::ptrext); @@ -1010,6 +1046,11 @@ error_code cellGemGetState(u32 gem_num, u32 flag, u64 time_parameter, vm::ptr(CELL_GEM_MIN_CAMERA_EXPOSURE), static_cast(CELL_GEM_MAX_CAMERA_EXPOSURE)); image_quality = std::clamp(image_quality, 0.0f, 1.0f); @@ -1519,6 +1565,11 @@ error_code cellGemUpdateStart(vm::cptr camera_frame, u64 timestamp) return CELL_GEM_ERROR_UPDATE_NOT_FINISHED; } + if (!camera_frame.aligned(128)) + { + return CELL_GEM_ERROR_INVALID_ALIGNMENT; + } + gem.camera_frame = camera_frame.addr(); if (!camera_frame) { @@ -1544,6 +1595,16 @@ error_code cellGemWriteExternalPort(u32 gem_num, vm::ptr