From edc4aa0be4551b261ba606be99ed14b132e3b6c9 Mon Sep 17 00:00:00 2001 From: Olivia!! Date: Sun, 24 May 2026 05:31:19 +0200 Subject: [PATCH] Fixes linux credits crash (#1780) alpha comparison mID is u16, but indexes into a 256-item table. this causes MAT3 materials with an alpha comparison index of 0xFF crashes on linux closes #1073 closes #1531 --- libs/JSystem/include/JSystem/J3DGraphBase/J3DMatBlock.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libs/JSystem/include/JSystem/J3DGraphBase/J3DMatBlock.h b/libs/JSystem/include/JSystem/J3DGraphBase/J3DMatBlock.h index a959609f45..859bd6943e 100644 --- a/libs/JSystem/include/JSystem/J3DGraphBase/J3DMatBlock.h +++ b/libs/JSystem/include/JSystem/J3DGraphBase/J3DMatBlock.h @@ -1575,6 +1575,12 @@ struct J3DAlphaComp { u8 getRef1() const { return mRef1; } void load() const { +#ifdef AVOID_UB + if (mID > 255) { + J3DGDSetAlphaCompare(GX_ALWAYS, 0, GX_AOP_OR, GX_ALWAYS, 0); + return; + } +#endif J3DGDSetAlphaCompare((GXCompare)getComp0(), mRef0, (GXAlphaOp)getOp(), (GXCompare)getComp1(), mRef1); }