@@ -242,6 +242,65 @@ void CemuHooks::hook_CreateNewScreen(PPCInterpreter_t* hCPU) {
242242 }
243243}
244244
245+
246+ enum class GX2_BLENDFACTOR {
247+ ZERO = 0x00 ,
248+ ONE = 0x01 ,
249+ SRC_COLOR = 0x02 ,
250+ ONE_MINUS_SRC_COLOR = 0x03 ,
251+ SRC_ALPHA = 0x04 ,
252+ ONE_MINUS_SRC_ALPHA = 0x05 ,
253+ DST_ALPHA = 0x06 ,
254+ ONE_MINUS_DST_ALPHA = 0x07 ,
255+ DST_COLOR = 0x08 ,
256+ ONE_MINUS_DST_COLOR = 0x09 ,
257+ SRC_ALPHA_SATURATE = 0x0A ,
258+ BOTH_SRC_ALPHA = 0x0B ,
259+ BOTH_INV_SRC_ALPHA = 0x0C ,
260+ CONST_COLOR = 0x0D ,
261+ ONE_MINUS_CONST_COLOR = 0x0E ,
262+ SRC1_COLOR = 0x0F ,
263+ INV_SRC1_COLOR = 0x10 ,
264+ SRC1_ALPHA = 0x11 ,
265+ INV_SRC1_ALPHA = 0x12 ,
266+ CONST_ALPHA = 0x13 ,
267+ ONE_MINUS_CONST_ALPHA = 0x14
268+ };
269+
270+ enum class GX2_COMBINEFUNC {
271+ DST_PLUS_SRC = 0 ,
272+ SRC_MINUS_DST = 1 ,
273+ MIN_DST_SRC = 2 ,
274+ MAX_DST_SRC = 3 ,
275+ DST_MINUS_SRC = 4
276+ };
277+
278+ void CemuHooks::hook_FixUIBlending (PPCInterpreter_t* hCPU) {
279+ hCPU->instructionPointer = hCPU->sprNew .LR ;
280+
281+ uint32_t renderTargetIndex = hCPU->gpr [3 ];
282+ GX2_BLENDFACTOR colorSrcFactor = (GX2_BLENDFACTOR )hCPU->gpr [4 ];
283+ GX2_BLENDFACTOR colorDstFactor = (GX2_BLENDFACTOR )hCPU->gpr [5 ];
284+ GX2_COMBINEFUNC colorCombineFunc = (GX2_COMBINEFUNC )hCPU->gpr [6 ];
285+ uint32_t separateAlphaBlend = hCPU->gpr [7 ];
286+ GX2_BLENDFACTOR alphaSrcFactor = (GX2_BLENDFACTOR )hCPU->gpr [8 ];
287+ GX2_BLENDFACTOR alphaDstFactor = (GX2_BLENDFACTOR )hCPU->gpr [9 ];
288+ GX2_COMBINEFUNC alphaCombineFunc = (GX2_COMBINEFUNC )hCPU->gpr [10 ];
289+
290+ {
291+ bool matchesColorSettings = colorSrcFactor == GX2_BLENDFACTOR ::DST_COLOR && colorDstFactor == GX2_BLENDFACTOR ::SRC_ALPHA && colorCombineFunc == GX2_COMBINEFUNC ::DST_PLUS_SRC ;
292+ bool matchesAlpha = alphaSrcFactor == GX2_BLENDFACTOR ::SRC_ALPHA && alphaDstFactor == GX2_BLENDFACTOR ::ONE_MINUS_SRC_ALPHA && alphaCombineFunc == GX2_COMBINEFUNC ::DST_PLUS_SRC ;
293+
294+ if (matchesColorSettings && matchesAlpha) {
295+ hCPU->gpr [7 ] = 1 ;
296+ hCPU->gpr [8 ] = std::to_underlying (GX2_BLENDFACTOR ::ZERO );
297+ hCPU->gpr [9 ] = std::to_underlying (GX2_BLENDFACTOR ::DST_ALPHA );
298+
299+ // Log::print<VERBOSE>("FixUIBlending called with renderTargetIndex: {}, colorSrcFactor: {}, colorDstFactor: {}, colorCombineFunc: {}, separateAlphaBlend: {}, alphaSrcFactor: {}, alphaDstFactor: {}, alphaCombineFunc: {}", renderTargetIndex, std::to_underlying(colorSrcFactor), std::to_underlying(colorDstFactor), std::to_underlying(colorCombineFunc), separateAlphaBlend, std::to_underlying(alphaSrcFactor), std::to_underlying(alphaDstFactor), std::to_underlying(alphaCombineFunc));
300+ }
301+ }
302+ }
303+
245304// todo: this function does nothing, we use ChangeWeaponMtx instead
246305void CemuHooks::hook_DropEquipment (PPCInterpreter_t* hCPU) {
247306 hCPU->instructionPointer = hCPU->sprNew .LR ;
0 commit comments