From 043fdacbab824a43fd9a9f2c3272e11cf4820c9b Mon Sep 17 00:00:00 2001 From: Sauraen Date: Fri, 31 May 2024 22:57:16 -0700 Subject: [PATCH 1/5] Fixed rupees and boulder particles --- include/ultra64/gbi.f3dex3.h | 43 +++++++++++++++++++ .../actors/ovl_En_Ex_Ruppy/z_en_ex_ruppy.c | 18 ++++++++ .../ovl_Effect_Ss_Stone1/z_eff_ss_stone1.c | 18 ++++++++ 3 files changed, 79 insertions(+) diff --git a/include/ultra64/gbi.f3dex3.h b/include/ultra64/gbi.f3dex3.h index 689d058ec7..15d01f9447 100644 --- a/include/ultra64/gbi.f3dex3.h +++ b/include/ultra64/gbi.f3dex3.h @@ -263,6 +263,7 @@ longer a multiple of 8 (DMA word). This was not used in any command anyway. */ #define G_MWO_ATTR_OFFSET_Z 0x14 #define G_MWO_ALPHA_COMPARE_CULL 0x16 #define G_MWO_NORMALS_MODE 0x18 +#define G_MWO_LAST_MAT_DL_ADDR 0x1A /* * RDP command argument defines @@ -1191,6 +1192,16 @@ typedef struct { short kc; } OcclusionPlane_t; +typedef struct { + /* Four vertices of a quad, XYZ components in world space */ + struct { + short x; + short y; + short z; + } v[4]; + float weight; /* Higher if there's a lot of stuff behind it */ +} OcclusionPlaneCandidate; + typedef union { Light_t l; long long int force_structure_alignment[2]; @@ -2844,6 +2855,38 @@ _DW({ \ #define gsSPNormalsMode(mode) \ gsMoveHalfwd(G_MW_FX, G_MWO_NORMALS_MODE, (mode) & 0xFF) +/* + * F3DEX3 has a basic auto-batched rendering system. At a high level, if a + * material display list being run is the same as the last material, the texture + * loads are automatically skipped the second time as they should already be in + * TMEM. + * + * This design generally works, but can break if you call a display list twice + * but in between change a segment mapping so that a referenced image inside is + * actually different the two times. In these cases, run the below command + * between the two calls (e.g. when you change the segment) and the microcode + * will not skip the second texture loads. + * + * Internally, a material is defined to start with any set image command, and + * end on any of the following: call, branch, return, vertex, all tri commands, + * modify vertex, branch Z/W, or cull. The physical address of the display list + * --not the address of the image--is stored when a material is started. If a + * material starts and its physical address is the same as the stored last start + * address, i.e. we're executing the same material display list as the last + * material, material cull mode is set. In this mode, load block, load tile, and + * load TLUT all are skipped. This mode is cleared when the material ends. + * + * This design has the benefit that it works correctly even with complex + * materials, e.g. with two CI4 textures (four loads), whereas it would be + * difficult to implement tracking all these loads separately. Furthermore, a + * design based on tracking the image addresses could break if you loaded + * different tile sections of the same image in consecutive materials. + */ +#define gSPDontSkipTexLoadsAcross(pkt) \ + gMoveWd(pkt, G_MW_FX, G_MWO_LAST_MAT_DL_ADDR, 0xFFFFFFFF) +#define gsSPDontSkipTexLoadsAcross() \ + gsMoveWd(G_MW_FX, G_MWO_LAST_MAT_DL_ADDR, 0xFFFFFFFF) + typedef union { struct { s16 intPart[3][4]; /* Fourth row containing translations is omitted. */ diff --git a/src/overlays/actors/ovl_En_Ex_Ruppy/z_en_ex_ruppy.c b/src/overlays/actors/ovl_En_Ex_Ruppy/z_en_ex_ruppy.c index ea7d242248..9a79ba0e27 100644 --- a/src/overlays/actors/ovl_En_Ex_Ruppy/z_en_ex_ruppy.c +++ b/src/overlays/actors/ovl_En_Ex_Ruppy/z_en_ex_ruppy.c @@ -379,6 +379,13 @@ void EnExRuppy_Draw(Actor* thisx, PlayState* play) { static void* rupeeTextures[] = { gRupeeGreenTex, gRupeeBlueTex, gRupeeRedTex, gRupeePinkTex, gRupeeOrangeTex, }; +#if ENABLE_F3DEX3 + // It might seem that we'd need to ensure this is reset every frame. But we + // actually only care about when this changes within a frame, as the texture + // loads would only ever be skipped between two or more rupees drawn + // consecutively. + static s16 lastColorIdx = -1; +#endif s32 pad; EnExRuppy* this = (EnExRuppy*)thisx; @@ -390,6 +397,17 @@ void EnExRuppy_Draw(Actor* thisx, PlayState* play) { gSPMatrix(POLY_OPA_DISP++, MATRIX_NEW(play->state.gfxCtx, "../z_en_ex_ruppy.c", 780), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(rupeeTextures[this->colorIdx])); +#if ENABLE_F3DEX3 + // If we have consecutive rupees rendering with different textures, + // F3DEX3's optimizer will incorrectly believe the texture loads can be + // skipped, so this command tells it not to skip them. However, if the + // rupee really is the same as last time, then we can let the optimizer + // skip the load. + if(this->colorIdx != lastColorIdx){ + gSPDontSkipTexLoadsAcross(POLY_OPA_DISP++); + lastColorIdx = this->colorIdx; + } +#endif gSPDisplayList(POLY_OPA_DISP++, gRupeeDL); CLOSE_DISPS(play->state.gfxCtx, "../z_en_ex_ruppy.c", 784); diff --git a/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.c b/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.c index 45846446fc..1f3a694f43 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.c +++ b/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.c @@ -55,6 +55,13 @@ void EffectSsStone1_Draw(PlayState* play, u32 index, EffectSs* this) { Vec3f mfVec; f32 mfW; f32 scale; +#if ENABLE_F3DEX3 + // It might seem that we'd need to ensure this is reset every frame. But we + // actually only care about when this changes within a frame, as the texture + // loads would only ever be skipped between two or more particles drawn + // consecutively. + static s16 lastTextureIndex = -1; +#endif OPEN_DISPS(gfxCtx, "../z_eff_ss_stone1.c", 154); @@ -67,6 +74,17 @@ void EffectSsStone1_Draw(PlayState* play, u32 index, EffectSs* this) { G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); Gfx_SetupDL_61Xlu(gfxCtx); gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(drawParams->texture)); +#if ENABLE_F3DEX3 + // If we have consecutive particles rendering with different textures, + // F3DEX3's optimizer will incorrectly believe the texture loads can be + // skipped, so this command tells it not to skip them. However, if the + // particle really is the same as last time, then we can let the optimizer + // skip the load. + if(this->life != lastTextureIndex){ + gSPDontSkipTexLoadsAcross(POLY_OPA_DISP++); + lastTextureIndex = this->life; + } +#endif gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, drawParams->primColor.r, drawParams->primColor.g, drawParams->primColor.b, 255); gDPSetEnvColor(POLY_XLU_DISP++, drawParams->envColor.r, drawParams->envColor.g, drawParams->envColor.b, 255); From 4d12f85a180ae8dfd9abd0c4774d96875738e476 Mon Sep 17 00:00:00 2001 From: Sauraen Date: Fri, 31 May 2024 23:08:21 -0700 Subject: [PATCH 2/5] clang-format --- src/overlays/actors/ovl_En_Ex_Ruppy/z_en_ex_ruppy.c | 2 +- src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/overlays/actors/ovl_En_Ex_Ruppy/z_en_ex_ruppy.c b/src/overlays/actors/ovl_En_Ex_Ruppy/z_en_ex_ruppy.c index 9a79ba0e27..86ee9e21b8 100644 --- a/src/overlays/actors/ovl_En_Ex_Ruppy/z_en_ex_ruppy.c +++ b/src/overlays/actors/ovl_En_Ex_Ruppy/z_en_ex_ruppy.c @@ -403,7 +403,7 @@ void EnExRuppy_Draw(Actor* thisx, PlayState* play) { // skipped, so this command tells it not to skip them. However, if the // rupee really is the same as last time, then we can let the optimizer // skip the load. - if(this->colorIdx != lastColorIdx){ + if (this->colorIdx != lastColorIdx) { gSPDontSkipTexLoadsAcross(POLY_OPA_DISP++); lastColorIdx = this->colorIdx; } diff --git a/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.c b/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.c index 1f3a694f43..f7295b3791 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.c +++ b/src/overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.c @@ -80,7 +80,7 @@ void EffectSsStone1_Draw(PlayState* play, u32 index, EffectSs* this) { // skipped, so this command tells it not to skip them. However, if the // particle really is the same as last time, then we can let the optimizer // skip the load. - if(this->life != lastTextureIndex){ + if (this->life != lastTextureIndex) { gSPDontSkipTexLoadsAcross(POLY_OPA_DISP++); lastTextureIndex = this->life; } From 42341eca127b50c4b76e6c1a1b15d08f131e56fb Mon Sep 17 00:00:00 2001 From: Sauraen Date: Sat, 1 Jun 2024 18:01:04 -0700 Subject: [PATCH 3/5] Memset Z buffer works and saves time --- F3DEX3/F3DEX3_BrW.code.bps | Bin 4491 -> 4585 bytes F3DEX3/F3DEX3_BrW.data.bps | Bin 211 -> 213 bytes F3DEX3/F3DEX3_BrW_NOC.code.bps | Bin 4357 -> 4443 bytes F3DEX3/F3DEX3_BrW_NOC.data.bps | Bin 216 -> 218 bytes F3DEX3/F3DEX3_BrW_NOC_PA.code.bps | Bin 4336 -> 4421 bytes F3DEX3/F3DEX3_BrW_NOC_PA.data.bps | Bin 219 -> 221 bytes F3DEX3/F3DEX3_BrW_NOC_PB.code.bps | Bin 4281 -> 4374 bytes F3DEX3/F3DEX3_BrW_NOC_PB.data.bps | Bin 219 -> 221 bytes F3DEX3/F3DEX3_BrW_NOC_PC.code.bps | Bin 4370 -> 4453 bytes F3DEX3/F3DEX3_BrW_NOC_PC.data.bps | Bin 219 -> 221 bytes F3DEX3/F3DEX3_BrW_PA.code.bps | Bin 4476 -> 4567 bytes F3DEX3/F3DEX3_BrW_PA.data.bps | Bin 214 -> 216 bytes F3DEX3/F3DEX3_BrW_PB.code.bps | Bin 4412 -> 4511 bytes F3DEX3/F3DEX3_BrW_PB.data.bps | Bin 214 -> 216 bytes F3DEX3/F3DEX3_BrW_PC.code.bps | Bin 4505 -> 4595 bytes F3DEX3/F3DEX3_BrW_PC.data.bps | Bin 214 -> 216 bytes include/functions.h | 1 + include/ultra64/gbi.f3dex3.h | 20 ++++++++ include/variables.h | 8 +--- src/code/z_play.c | 11 ++++- src/code/z_prenmi.c | 1 + src/code/z_rcp.c | 44 ++++++++++++++---- src/code/z_sample.c | 1 + src/debug/menu.c | 2 +- .../ovl_file_choose/z_file_choose.c | 3 ++ .../gamestates/ovl_opening/z_opening.c | 1 + src/overlays/gamestates/ovl_select/z_select.c | 13 +----- src/overlays/gamestates/ovl_title/z_title.c | 1 + 28 files changed, 75 insertions(+), 31 deletions(-) diff --git a/F3DEX3/F3DEX3_BrW.code.bps b/F3DEX3/F3DEX3_BrW.code.bps index e99491aedd56df254b9f7940caaf4c1d153d2f7f..6634c5d5c83a9d88e0a6d425a9416996036e2318 100644 GIT binary patch delta 634 zcmW-dT}V@57{}lDJv%#Rn{bY4v=Oz}9WX>8hu?jGPNT6bM4`Me7||CgA?0XN;@QW+ zubgeK+sv>Jg?Ukmc2q1Fle!VRh@{5w!la8(D+sh0MxKt{JU@Pa_&*OkeZq#o*yFoA1DVvXy)RX?Mez5&jY$rNlvDLhFL?o zLIr?D`J`CpnDJcCDF4p=M8_h zA4^is$o;rtw>p%xom&CwO*^cLwFc!HR1TqC?x1E+P0JytvYXSatl)h>8>>RgF&p|A zt47IKB}!o(Un#ms$s7e$ScijE>gM*m?9!fqFhyQ6Me6*@ z9Hvu|F_a`a)~s8OsQdn#mCZxesNBR}fT(nw%<3fgiyYTu_?9&3E8!b5qMzmx0dE*X zz`m#mx#G_fc7=K*L`He$|tz_hL%< zqr&18ri7@6K5V-*L{tySVlJ#w_)rIqTU*o-}ao&M3VwYg&*TKnojri>B)D z*6=;K=N2}FZa)gzyV|%{uMb2=1{V=u3QSAnhSwyjM3|!Z44@r2V_ECMHVUlUaA$V4 zvWsoX&%GRH`=VE8rW+K6vMgH6SlOYFTAsKf J!O7b9{{UL&=@I|{ delta 540 zcmaE<+^x*+6cB7^uv%gw`&PzN6Zgt9#WqgvWt3-}G`WCL46KhDn3*bA z68>MAm$-9UN2}nBzAsZ*6PRNse_>RRU(>66kAbZRL~@;4(fDgy)71MOR@aylruEb| z{`Z)8Pe0uazws z7>%_jn>1YHV2}u6TJ(c~je~*Z#-djY>^wkvR>+*j8Izg{8-5!w0L6DtPGwXU+oixQ zJi*Z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_G(00al%0p%k( z00A>AlQe+Q2mlyT0;2c;1_%HI*rMtH2MhoN*qT(FftZqlae(_U00;mCyOU)BBNn00c+@L8gC+vqb_b0Rcv{a09XeL~0#i|NbFs|JooD00yQ(0??*H z0@9{K0@S8J0@ff200@+}akzmHmV$)>)|!NcaFnKmfntt=?H~^fP?hWd{vqo0y0c~m zJOKgLlcNVS0oIe(2Ob61mZJjHllliA3DA~80@9YF0@RZt2q^+7le0|-R{;Vpqm!ly zg#pf!ED9h2mXl2iKmnDLjta34l8%CvAOQdftT~c(y`hqmP75mml9PH1CIP9Fq6;?y zNRG4H3r_%00T4$36CeWs1Q2Hc2_ORh)(}Sk0hb7jl>|tKbPu_@Du98Mmqo|5 z7rcc^00seA5F!LY{&bpBvpIlrAQ=DvlSB_H1&?rmb&0cb4?qDb7!gVlcTGwVeNIXc hbr0wj7!wEp1s&)V7!Uve006D*Y;3m@?ze+y@8=b^!pZ;u diff --git a/F3DEX3/F3DEX3_BrW_NOC.data.bps b/F3DEX3/F3DEX3_BrW_NOC.data.bps index 081bf4d1061d4e128e98ef1e24607a04f3a547a1..1e0fdedd7385f7b3c8b2a6b510b0740198605ad6 100644 GIT binary patch delta 107 zcmV-x0F?jO0onlvLQqpNAct6y2TTF@kyJ2NO@N>RU;x?x008&^umP|Ulos$2l)St& z051zb7kqJ9W;P!lH8sG%z`(!1zbwBiy*R(Uy}z3bhrP10vcRByPrRF%nTLs~KL9ly NBkyJ2LNr0dNU;x?x008&^umP|Ulos$2l#et3 zFAG2yw{cl!HXj}}HItK*lai8>ERrjbIFgW%lA8*LxrK#=liRpYkJi-G!o++(H60}C L9#h!}>Hm)t=h7j+99un&nk3K_whvq%=#}PaZA8 z+4kv1_M<7Bn^Ka4p~Dpfg%n*RIfhqWniY56|`%5UdwK>%z9VUC^)_xY*$Y zR9Qx=LZ9_uZNk&Lpwok9W_k-)vx*7yP%K=I4_*!bDF@XUBBsLa(Vxe@u-vJyM)-_GCk+GW7cDXp^qQVBx=@-1jq_Y88W|@D^e>$8-t@B+ zJ#8vMDcWHw!OjRBF&)O9n7nLiWeW4}69zPVCv*_3WcWJp6GmB6c{jbtm1+oTxGWEG zE)*Q?39a2c>*WW|dHG&$GvAu0Zf4!ISovi8n+2Oy^nwnx@`9#j&py#F-wP01{KlhL z-Ea@LlqyI*dAx%8YOsBvLc|tQ5fg^t&7f;<5H^O1n}JO?30i8EJ>pij_jO{qlRU66 x->fK%up*S&iSnDlv@J5*=_vd8QtLy}V*=3Y!y^P68fU-z{b0-#w8%@>{sEb3*7pDa delta 501 zcmVk<}jpO@Nc00V5!fpa%kY2ml4xfCB<}1YrN! zo?*F`h=mcLj`WoUU;|*2;Q>7aeS!Z-k@hbs!XO_L3?Ltq3?q3DxQ{ph03&M;y%Bi< z=>Qm300lq+=dSnw1P9;&?~_ge78=!}>Hr4}00h;RRGftxypn`bfcr222ml1QlYRjk z7PlY^6MQjB|M*A`+5ijy1V;furhkdEG6E_A0YsmFxfhA?ozH zvs4B=0Rh&Nkq0v*)(8Lv>yN~#N(3b;2ml5TN(C*GV}f0P1z-RYrl11WmZJjHljsK@ z3DA~80@9YF0@RZb2vh=agtKM{HUR=Qqm!NqeF4ss910)-laoCPKmn4IehRS)^p3s?g~-5>%00T4$36CeWs1Q2Hc z2_ORh)(}Sk0hb7jl>|qJbPu_@jDeh&ZO642tc6Md1_4+QA_PJHdYV$RIe>T|82|v2 rE)OaNk8pr>iL+b}Kmi085lRu0pb!=i00000t?X=UgV!(SWJFDPQSz@n diff --git a/F3DEX3/F3DEX3_BrW_NOC_PA.data.bps b/F3DEX3/F3DEX3_BrW_NOC_PA.data.bps index 4075990a341d56a821aea7dbf02976a4ea1aa101..8ec527bd7e831e3b7304b052b5687d708f0f32a4 100644 GIT binary patch delta 107 zcmV-x0F?jR0o?%yLQqpNAct6y2TuX`kykKQO@N>RU;x?x008&^umP|UoEF>>oVT|$ z051za7lLt-Gd!PPd_-pN)@bJ^(cx NBhafES&%V delta 105 zcmV-v0G9vV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1_%HI&7$f62MhoN&6-r4 zftZqlae(_U00;mCu#;s0BNne93ln59O8@vs5840>00c(?L8gC+vj+ky0Rcv{G6TN? zL~0#i|NbFs|JooD00yQ(0??*H0@9{K0@S8J0@ff200@+}akzmHmV$)>)|!NcaFnKm zfntt=?H~^fP?hWd{vqo0y0bL~JOKgLlX3?$0oIeI2Ob61mZJjHlgS4k3DA~80@9YF z0@Rc72Py%Rvm6LF0Rf_uR0(_|{MSl<|6z{2j);zkj);zkjY?-Rr;eD8h-rZ8<`R7f z00fPb^9f1;jFUbJu@8xkf|Vcv00^u(l6AeIiIe^cCIN|)B?~42sgq3$E&-0Sd<$g* zL){<(009t3023es00a|qJbPu_@EP#QOmm#~g7odeo00seA z5F!LY{(G8IvpIlrAQ=Dvllu-T1&?rmWr?#X4?qDX7!gVlcTGwVeNIXcbr0wj7!wEp V1rq2K7!a-OY-}hZ>{|{C#jIq7!FT`w diff --git a/F3DEX3/F3DEX3_BrW_NOC_PB.data.bps b/F3DEX3/F3DEX3_BrW_NOC_PB.data.bps index f8cdc3abb567f859c7fbc6ba835fb91e9cccf693..41d89c19fb9b19122259a7f878e93e7b5868bf41 100644 GIT binary patch delta 107 zcmV-x0F?jR0o?%yLQqpNAct6y2TuX`kykKQO@N>RU;x?x008&^umP|UlorGhl(Vxm z051za7kqJ8W;P!lH8r=lx3{*owk)cJhrOw(skfkgPP3btnTLsHJ^(cx NBTdLfc4N#v{ThZbZPCr4U;)CtikOZsG=?gx3dl9{pg?TEEJ{9Hut3o2)F@N~4T}15HevQ*4EHW!=WlL!!rq%4JRt<>P#W zY@u4_B|hfdeSt1_ zU5~Uv_~g_5KNHsFwQ#6feH5V>?bRIG8%yl`;eGem&gPgoP^Z{cd9+@tb*UVX8W_eg z|3e(5-!(?{%xgvxcAJI$Nt9VmQSG5Gaq57l-G)dc%E~qDNjnc9Z zjVGD8;v3W8_FBR;TUWqGdZd1WfO}RVw@yBY(6hSzC_>%3eYixTqq<^T;|ne6s+jDI z+k^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3?q3DxQ{ph03&M;y%Bi< z?En~700lq+>#q0!1P9;&^OH^i78=!}>Hr4}00h;RRGftx%#wsrfcr222ml1QlYRjk z7PlY^6MQjB|M*A`+5ijy1V;furhkdEG6FaO0YsmFxfhA?ozH zvtkB30Rh&Np9eD})(8Lv?~lZ(N(3b;2ml5XN(C*GV}f0P1z-RYrl11WmZJjHllBK6 z3DA~80@9YF0@RZp2vh=agtK%AH30%vqm!!%eF4goDGDF~laopcKmn4Iiwdz1kB)+s zAOQdftT~c(y`hhjOA96ekCSo>CIP9FnhQDtaE`Oq3r_<|JD#k03QGV005KF5O^sJ00c*ebPu_@Du98Umsz^C7&L`S00seA5F!LY{#cq) zvq6h^AQ=DvvqukZ0V)^~N)dNWN)UZcN)UAq=oJ_f2ml2f=oAw1BZP diff --git a/F3DEX3/F3DEX3_BrW_PA.data.bps b/F3DEX3/F3DEX3_BrW_PA.data.bps index c2bef5814c6b10f89426ee75c8f44c6b8181300c..c606e60fe02dd9594a4b2207f920c4c5f52bd60f 100644 GIT binary patch delta 107 zcmV-x0F?jM0oVZtLQqpNAct6y2TB3>ky0>LO@N>RU;x?x008&^umP|UoELBroVT|$ z051za7lLt-Gd!PPd_-pN)@bJ^(cx NBJNr0dNU;x?x008&^umP|UoELBroQyO8 zFAF~xw0Br&HXj}}HIR^ykdKd#ERQRVIFF5ukDCgIxq^a%kl3|OjMLH4zrkoeH60}C L^Pwve4*0uRztk!j diff --git a/F3DEX3/F3DEX3_BrW_PB.code.bps b/F3DEX3/F3DEX3_BrW_PB.code.bps index b098cb33bfbe39bd27179e1817b8ec8ee709c1ba..28d82b7cdb6baf1ad93bfdf0410a2b0e947098a3 100644 GIT binary patch delta 611 zcmW-bQAkr!7{|{!_ip!IC)}$pbCm3OZ%H#FB}|11Hv`9wLXyIlU|3y z29xdRX4Y~QT#~YsB4-!(%)2;92EDxKoYU=;vLieUutxmC2A z#9+QH`g9#|*?^6X!Uw*QkS1uq%K#5pFZl=+Q#ZEcT?noyI1%Ge2MM@iKKSL?9#My<#u<__WWw;U; zj_>0uA=HUSxQ#M^tOyv+5h|!~mZ(`%Vj`doV+i<{)u9{7Ckc{eDTWDBZYf3%jWk*u zuqUorni;v`K1Os|ssooW16ZjU^ctKpcmOkW$>2czxp)Qc8f^Dg^xQnDN?oT^>4vzr zqae=^&tJ0^NQ4tRx+8^er)`h?Dlo%FNoJjyKcjg1-Zg9sU4Iy?>uVQh=XOS-Lkmbc z3~cX7u4eNZ8)1f#vVr;T33;^-yBM(M!rj(dx{Y1*$G;p~dm_iCry3|_VYv68?CLeub(pRF5mcHrXkvu delta 512 zcmbQQyhn+{DInO;V711&i5y!PPfgq_&*a-MxtCE{p>qK{Qw0YD>-7d^rV5sX|99sl z?wr=qDmbI>%T(3`=CsKd7?oLS8~=Muyr&@fje`87H_Da#JNhjc7?iX5_X<}2 zU%?;|#=z?Ef7!Yp3@q#q7~d#cGB6rzPc~_|$iW~H#I)!K0~-ee%h^S*7}$A$^sJCM zjWZ@S6*l}fU;v75n4HR}EVf>OTR6qg>;DfA{#y({Rql+A%j!Efvol#RGP-ScVBW*z zk|mq)|DR&^|62+|3~b9BnJz4IV!E`4Xms5eU zck(|@FUFq9o?ILGJNufZDljr|tg)O_x_4pcWKM21#?HwGKyu~e2yRWrw#`l4>CAGu z%?eBmi~{Zqh6>CKECT5a>IzK%uL1e;3_vh>ia>=XC>+{L_;>CyXlR@=U2*qT35`}S z1~$eB0VNj4f046-HXC*qDM&IfZ06?AV`PyK^b(w0Cm_bN_DxPs(Y=OkIwH2N0QoSo Avj6}9 diff --git a/F3DEX3/F3DEX3_BrW_PB.data.bps b/F3DEX3/F3DEX3_BrW_PB.data.bps index 2ab8b5ac8b115a9c5d9f80a127efb6cd82608d30..cb5948acfcccba634e0d96e679e0a81009023914 100644 GIT binary patch delta 107 zcmV-x0F?jM0oVZtLQqpNAct6y2TB3>ky0>LO@N>RU;x?x008&^umP|UlownPl(Vxm z051za7kqJ8W;P!lH8r=lx3{*owk)cJh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Mwu&%66sr42k zP@{cp$wAGav=;v`95fyBaA0u+&0cy#z8W!yAUD&Gwe%3q(hb&SolP4>|5X8Z1XoeD ziaU<5Wr#+t_we7(RJRgDDY4x|N&3Ln$U5Z5&*`3Vx?%Hhm9ZI!#(iV7i1!JKB6kr4 z+{?0L%k+Rk8~8$`&^Uh>4but!1P&|eFTR>7xOJakKw>2n69!CT0~8XhYle1#F?3lB zdv_2$yemwOw9F-zh|8YpMsLTQrLiDb&}GqW@^9DmUQzu|T1h^DdQG^EJWhMi-dY_L j+b;yg7GXKh=`aB7Ti)#ycT!*dXl~xcuU6FNEu8-c92n3E diff --git a/F3DEX3/F3DEX3_BrW_PC.data.bps b/F3DEX3/F3DEX3_BrW_PC.data.bps index 3356cd5d80b179ef17d7d3923ba4851738a8795a..2756caf107f41a20ecfc48904a3cc4fe0c7610f1 100644 GIT binary patch delta 107 zcmV-x0F?jM0oVZtLQqpNAct6y2TB3>ky0>LO@N>RU;x?x008&^umP|UloxOjl(x1t z05A(c7=di1Dx4D}PhrO(W delta 105 zcmcb?c#Vj6& diff --git a/include/functions.h b/include/functions.h index 23eb5dfc30..efc2b88332 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1086,6 +1086,7 @@ Gfx* Gfx_TwoTexScrollEnvColor(GraphicsContext* gfxCtx, s32 tile1, u32 x1, u32 y1 u32 x2, u32 y2, s32 width2, s32 height2, s32 r, s32 g, s32 b, s32 a); Gfx* Gfx_EnvColor(GraphicsContext* gfxCtx, s32 r, s32 g, s32 b, s32 a); void Gfx_SetupFrame(GraphicsContext* gfxCtx, s32 clearFB, u8 r, u8 g, u8 b); +void Gfx_ClearZBuffer(GraphicsContext* gfxCtx); void func_80095974(GraphicsContext* gfxCtx); void func_80095AA0(PlayState* play, Room* room, Input* input, s32 arg3); void Room_DrawBackground2D(Gfx** gfxP, void* tex, void* tlut, u16 width, u16 height, u8 fmt, u8 siz, u16 tlutMode, diff --git a/include/ultra64/gbi.f3dex3.h b/include/ultra64/gbi.f3dex3.h index 15d01f9447..1f49fa30dd 100644 --- a/include/ultra64/gbi.f3dex3.h +++ b/include/ultra64/gbi.f3dex3.h @@ -44,6 +44,7 @@ of warnings if you use -Wpedantic. */ /*#define G_SPECIAL_3 0xD3 no-op in F3DEX2 */ /*#define G_SPECIAL_2 0xD4 no-op in F3DEX2 */ /*#define G_SPECIAL_1 0xD5 triggered MVP recalculation, not supported in F3DEX3 */ +#define G_MEMSET 0xD5 #define G_DMA_IO 0xD6 #define G_TEXTURE 0xD7 #define G_POPMTX 0xD8 @@ -2385,6 +2386,25 @@ _DW({ \ #define gSPDmaWrite(pkt,dmem,dram,size) gSPDma_io((pkt),1,(dmem),(dram),(size)) #define gsSPDmaWrite(dmem,dram,size) gsSPDma_io( 1,(dmem),(dram),(size)) +/** + * Use RSP DMAs to set a region of memory to a repeated 16-bit value. This can + * clear the color framebuffer or Z-buffer faster than the RDP can in fill mode. + * SPMemset overwrites the DMEM vertex buffer, so vertices loaded before this + * command cannot be used after it (though this would not normally be done). + * + * dram: Segmented or physical start address. Must be aligned to 16 bytes. + * value: 16-bit value to fill the memory with. e.g. 0 for color, 0xFFFC for Z. + * size: Size in bytes to fill, must be nonzero and a multiple of 16 bytes. + */ +#define gSPMemset(pkt, dram, value, size) \ +_DW({ \ + gImmp1(pkt, G_RDPHALF_1, ((value) & 0xFFFF)); \ + gDma0p(pkt, G_MEMSET, (dram), ((size) & 0xFFFFF0)); \ +}) + +#define gsSPMemset(pkt, dram, value, size) \ + gsImmp1(G_RDPHALF_1, ((value) & 0xFFFF)), \ + gsDma0p(G_MEMSET, (dram), ((size) & 0xFFFFF0)) /* * RSP short command (no DMA required) macros diff --git a/include/variables.h b/include/variables.h index 75fc491757..2a171a8c53 100644 --- a/include/variables.h +++ b/include/variables.h @@ -223,13 +223,7 @@ extern volatile s8 gLoadedF3DEX3Version; extern volatile s8 gF3DEX3ProfVersion; extern volatile s8 gF3DEX3NOCVersion; extern s8 gF3DEX3OccMode; -#endif - -#if ENABLE_F3DEX3 -extern u8 gF3DEX3TextBuffer[]; -extern volatile s8 gF3DEX3ProfVersion; -extern volatile s8 gF3DEX3NOCVersion; -extern s8 gF3DEX3OccMode; +extern u8 gUseMemsetForZBuffer; #endif extern SfxBankEntry D_8016BAD0[9]; diff --git a/src/code/z_play.c b/src/code/z_play.c index 007023d312..66634133bc 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -1258,7 +1258,7 @@ void Play_Draw(PlayState* this) { clearG = this->lightCtx.fogColor[1]; clearB = this->lightCtx.fogColor[2]; } - // Clear the fb only if we aren't drawing a skybox, but always clear zb + // Clear the fb only if we aren't drawing a skybox Gfx_SetupFrame(gfxCtx, clearFB, clearR, clearG, clearB); } @@ -1377,6 +1377,15 @@ void Play_Draw(PlayState* this) { if (!IS_DEBUG || (R_HREG_MODE != HREG_MODE_PLAY) || (R_PLAY_DRAW_ENV_FLAGS & PLAY_ENV_DRAW_SKYBOX_FILTERS)) { Environment_DrawSkyboxFilters(this); } + + // The Z buffer has to be cleared at some point before anything using it + // is drawn (lighting strike is the first which does). But if we are + // using F3DEX3's SPMemset to clear it, it should be done as late as + // possible, after the RSP has already sent commands to the RDP for the + // skybox or framebuffer clear. This is so that the RSP can clear the Z + // buffer while the RDP is working on the framebuffer, without making + // the RDP wait for new work to be available. + Gfx_ClearZBuffer(gfxCtx); if (!IS_DEBUG || (R_HREG_MODE != HREG_MODE_PLAY) || (R_PLAY_DRAW_ENV_FLAGS & PLAY_ENV_DRAW_LIGHTNING)) { Environment_UpdateLightningStrike(this); diff --git a/src/code/z_prenmi.c b/src/code/z_prenmi.c index 0e0d2ed2e7..d8b6af8e78 100644 --- a/src/code/z_prenmi.c +++ b/src/code/z_prenmi.c @@ -34,6 +34,7 @@ void PreNMI_Draw(PreNMIState* this) { gSPSegment(POLY_OPA_DISP++, 0x00, NULL); Gfx_SetupFrame(gfxCtx, true, 0, 0, 0); + Gfx_ClearZBuffer(gfxCtx); Gfx_SetupDL_36Opa(gfxCtx); gDPSetFillColor(POLY_OPA_DISP++, (GPACK_RGBA5551(255, 255, 255, 1) << 16) | GPACK_RGBA5551(255, 255, 255, 1)); gDPFillRectangle(POLY_OPA_DISP++, 0, this->timer + 100, SCREEN_WIDTH - 1, this->timer + 100); diff --git a/src/code/z_rcp.c b/src/code/z_rcp.c index adbeff3b63..75ad1fff14 100644 --- a/src/code/z_rcp.c +++ b/src/code/z_rcp.c @@ -1,5 +1,9 @@ #include "global.h" +#if ENABLE_F3DEX3 +u8 gUseMemsetForZBuffer = 1; +#endif + Gfx sSetupDL[SETUPDL_MAX][6] = { { /* SETUPDL_0 */ @@ -1472,7 +1476,6 @@ void Gfx_SetupFrame(GraphicsContext* gfxCtx, s32 clearFB, u8 r, u8 g, u8 b) { // Set up the framebuffer, primitives will be drawn here gDPSetColorImage(POLY_OPA_DISP++, G_IM_FMT_RGBA, G_IM_SIZ_16b, gScreenWidth, gfxCtx->curFrameBuffer); - gDPSetColorImage(POLY_OPA_DISP++, G_IM_FMT_RGBA, G_IM_SIZ_16b, gScreenWidth, gfxCtx->curFrameBuffer); gDPSetColorImage(POLY_XLU_DISP++, G_IM_FMT_RGBA, G_IM_SIZ_16b, gScreenWidth, gfxCtx->curFrameBuffer); gDPSetColorImage(OVERLAY_DISP++, G_IM_FMT_RGBA, G_IM_SIZ_16b, gScreenWidth, gfxCtx->curFrameBuffer); @@ -1529,17 +1532,8 @@ void Gfx_SetupFrame(GraphicsContext* gfxCtx, s32 clearFB, u8 r, u8 g, u8 b) { } #endif - // Set the whole z buffer to maximum depth - // Don't bother with pixels that are being covered by the letterbox - gDPSetColorImage(POLY_OPA_DISP++, G_IM_FMT_RGBA, G_IM_SIZ_16b, gScreenWidth, gZBuffer); - gDPSetRenderMode(POLY_OPA_DISP++, G_RM_NOOP, G_RM_NOOP2); - gDPSetFillColor(POLY_OPA_DISP++, (GPACK_ZDZ(G_MAXFBZ, 0) << 16) | GPACK_ZDZ(G_MAXFBZ, 0)); - gDPFillRectangle(POLY_OPA_DISP++, 0, letterboxSize, gScreenWidth - 1, gScreenHeight - letterboxSize - 1); - gDPPipeSync(POLY_OPA_DISP++); - // Fill the whole screen with the base color, only done when there is no skybox or if it is a solid color. // Don't bother with pixels that are being covered by the letterbox - gDPSetColorImage(POLY_OPA_DISP++, G_IM_FMT_RGBA, G_IM_SIZ_16b, gScreenWidth, gfxCtx->curFrameBuffer); if (clearFB) { gDPSetRenderMode(POLY_OPA_DISP++, G_RM_NOOP, G_RM_NOOP2); gDPSetFillColor(POLY_OPA_DISP++, (GPACK_RGBA5551(r, g, b, 1) << 16) | GPACK_RGBA5551(r, g, b, 1)); @@ -1560,6 +1554,36 @@ void Gfx_SetupFrame(GraphicsContext* gfxCtx, s32 clearFB, u8 r, u8 g, u8 b) { CLOSE_DISPS(gfxCtx, "../z_rcp.c", 2497); } +void Gfx_ClearZBuffer(GraphicsContext* gfxCtx) { + s32 letterboxSize = Letterbox_GetSize(); + OPEN_DISPS(gfxCtx, "../z_rcp.c", __LINE__); + + // Set the whole z buffer to maximum depth + // Don't bother with pixels that are being covered by the letterbox +#if ENABLE_F3DEX3 + if (gUseMemsetForZBuffer) { + s32 w2 = gScreenWidth * 2; // 2 bytes per pixel + if(letterboxSize < 0 || letterboxSize > 100){ + letterboxSize = 0; + } + gSPMemset(POLY_OPA_DISP++, (u8*)gZBuffer + letterboxSize * w2, GPACK_ZDZ(G_MAXFBZ, 0), + (gScreenHeight - 2 * letterboxSize) * w2); + }else{ +#endif + gSPDisplayList(POLY_OPA_DISP++, sFillSetupDL); + gDPSetColorImage(POLY_OPA_DISP++, G_IM_FMT_RGBA, G_IM_SIZ_16b, gScreenWidth, gZBuffer); + gDPSetRenderMode(POLY_OPA_DISP++, G_RM_NOOP, G_RM_NOOP2); + gDPSetFillColor(POLY_OPA_DISP++, (GPACK_ZDZ(G_MAXFBZ, 0) << 16) | GPACK_ZDZ(G_MAXFBZ, 0)); + gDPFillRectangle(POLY_OPA_DISP++, 0, letterboxSize, gScreenWidth - 1, gScreenHeight - letterboxSize - 1); + gDPPipeSync(POLY_OPA_DISP++); + gDPSetColorImage(POLY_OPA_DISP++, G_IM_FMT_RGBA, G_IM_SIZ_16b, gScreenWidth, gfxCtx->curFrameBuffer); +#if ENABLE_F3DEX3 + } +#endif + + CLOSE_DISPS(gfxCtx, "../z_rcp.c", __LINE__); +} + void func_80095974(GraphicsContext* gfxCtx) { OPEN_DISPS(gfxCtx, "../z_rcp.c", 2503); diff --git a/src/code/z_sample.c b/src/code/z_sample.c index 0f31fc299a..e76b7ad3e7 100644 --- a/src/code/z_sample.c +++ b/src/code/z_sample.c @@ -17,6 +17,7 @@ void Sample_Draw(SampleState* this) { gSPSegment(POLY_OPA_DISP++, 0x01, this->staticSegment); Gfx_SetupFrame(gfxCtx, true, 0, 0, 0); + Gfx_ClearZBuffer(gfxCtx); view->flags = VIEW_VIEWING | VIEW_VIEWPORT | VIEW_PROJECTION_PERSPECTIVE; View_Apply(view, VIEW_ALL); diff --git a/src/debug/menu.c b/src/debug/menu.c index 1a7570919a..c513644aab 100644 --- a/src/debug/menu.c +++ b/src/debug/menu.c @@ -39,7 +39,7 @@ void Menu_Update(Menu* this) { u8 pressDLeft = CHECK_BTN_ALL(pressBtn, BTN_DLEFT); u8 pressDRight = CHECK_BTN_ALL(pressBtn, BTN_DRIGHT); u8 i; - + if (isHoldingR && CHECK_BTN_ALL(pressBtn, BTN_L)) { this->bShow ^= 1; } diff --git a/src/overlays/gamestates/ovl_file_choose/z_file_choose.c b/src/overlays/gamestates/ovl_file_choose/z_file_choose.c index 4a8450fd00..156fd0f8f9 100644 --- a/src/overlays/gamestates/ovl_file_choose/z_file_choose.c +++ b/src/overlays/gamestates/ovl_file_choose/z_file_choose.c @@ -69,6 +69,7 @@ void FileSelect_InitModeDraw(GameState* thisx) { FileSelectState* this = (FileSelectState*)thisx; Gfx_SetupFrame(this->state.gfxCtx, true, 0, 0, 0); + Gfx_ClearZBuffer(this->state.gfxCtx); } /** @@ -1136,6 +1137,7 @@ void FileSelect_ConfigModeDraw(GameState* thisx) { Gfx_SetupFrame(this->state.gfxCtx, false, 0, 0, 0); Skybox_Draw(&this->skyboxCtx, this->state.gfxCtx, NULL, SKYBOX_NORMAL_SKY, this->envCtx.skyboxBlend, eyeX, eyeY, eyeZ); + Gfx_ClearZBuffer(this->state.gfxCtx); gDPSetTextureLUT(POLY_OPA_DISP++, G_TT_NONE); ZREG(11) += ZREG(10); Environment_UpdateSkybox(SKYBOX_NORMAL_SKY, &this->envCtx, &this->skyboxCtx); @@ -1551,6 +1553,7 @@ void FileSelect_SelectModeDraw(GameState* thisx) { Gfx_SetupFrame(this->state.gfxCtx, false, 0, 0, 0); Skybox_Draw(&this->skyboxCtx, this->state.gfxCtx, NULL, SKYBOX_NORMAL_SKY, this->envCtx.skyboxBlend, eyeX, eyeY, eyeZ); + Gfx_ClearZBuffer(this->state.gfxCtx); gDPSetTextureLUT(POLY_OPA_DISP++, G_TT_NONE); ZREG(11) += ZREG(10); Environment_UpdateSkybox(SKYBOX_NORMAL_SKY, &this->envCtx, &this->skyboxCtx); diff --git a/src/overlays/gamestates/ovl_opening/z_opening.c b/src/overlays/gamestates/ovl_opening/z_opening.c index 3ba1db3718..5b806eb904 100644 --- a/src/overlays/gamestates/ovl_opening/z_opening.c +++ b/src/overlays/gamestates/ovl_opening/z_opening.c @@ -69,6 +69,7 @@ void TitleSetup_Main(GameState* thisx) { TitleSetupState* this = (TitleSetupState*)thisx; Gfx_SetupFrame(this->state.gfxCtx, true, 0, 0, 0); + Gfx_ClearZBuffer(this->state.gfxCtx); TitleSetup_SetupTitleScreen(this); func_80803C5C(this); } diff --git a/src/overlays/gamestates/ovl_select/z_select.c b/src/overlays/gamestates/ovl_select/z_select.c index ac7dafc626..24924e418b 100644 --- a/src/overlays/gamestates/ovl_select/z_select.c +++ b/src/overlays/gamestates/ovl_select/z_select.c @@ -92,6 +92,7 @@ void MapSelect_Draw(MapSelectState* this) { Gfx_SetupFrame(gfxCtx, true, 0, 0, 0); SET_FULLSCREEN_VIEWPORT(&this->view); View_Apply(&this->view, VIEW_ALL); + Gfx_SetupDL_28Opa(gfxCtx); if (!this->state.running) { MapSelect_DrawLoadingScreen(this); @@ -333,12 +334,6 @@ void MapSelect_DrawMenu(MapSelectState* this) { OPEN_DISPS(gfxCtx, __FILE__, __LINE__); - gSPSegment(POLY_OPA_DISP++, 0x00, NULL); - Gfx_SetupFrame(gfxCtx, true, 0, 0, 0); - SET_FULLSCREEN_VIEWPORT(&this->view); - View_Apply(&this->view, VIEW_ALL); - Gfx_SetupDL_28Opa(gfxCtx); - printer = alloca(sizeof(GfxPrint)); GfxPrint_Init(printer); GfxPrint_Open(printer, POLY_OPA_DISP); @@ -366,12 +361,6 @@ void MapSelect_DrawLoadingScreen(MapSelectState* this) { OPEN_DISPS(gfxCtx, __FILE__, __LINE__); - gSPSegment(POLY_OPA_DISP++, 0x00, NULL); - Gfx_SetupFrame(gfxCtx, true, 0, 0, 0); - SET_FULLSCREEN_VIEWPORT(&this->view); - View_Apply(&this->view, VIEW_ALL); - Gfx_SetupDL_28Opa(gfxCtx); - printer = alloca(sizeof(GfxPrint)); GfxPrint_Init(printer); GfxPrint_Open(printer, POLY_OPA_DISP); diff --git a/src/overlays/gamestates/ovl_title/z_title.c b/src/overlays/gamestates/ovl_title/z_title.c index 7d7fd5b54b..748b3b1daf 100644 --- a/src/overlays/gamestates/ovl_title/z_title.c +++ b/src/overlays/gamestates/ovl_title/z_title.c @@ -155,6 +155,7 @@ void ConsoleLogo_Main(GameState* thisx) { gSPSegment(POLY_OPA_DISP++, 0, NULL); gSPSegment(POLY_OPA_DISP++, 1, this->staticSegment); Gfx_SetupFrame(this->state.gfxCtx, true, 0, 0, 0); + Gfx_ClearZBuffer(this->state.gfxCtx); ConsoleLogo_Calc(this); ConsoleLogo_Draw(this); From db15bde0d3cf262c16f50933c79b23649af3c2c4 Mon Sep 17 00:00:00 2001 From: Sauraen Date: Sun, 2 Jun 2024 14:34:42 -0700 Subject: [PATCH 4/5] lint --- src/code/z_play.c | 5 +++-- src/code/z_rcp.c | 8 ++++---- src/debug/menu.c | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/code/z_play.c b/src/code/z_play.c index 66634133bc..2fbc2d2752 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -1113,7 +1113,8 @@ extern u16 (*gWorkBuf)[SCREEN_WIDTH * SCREEN_HEIGHT]; static u8 sMotionBlurStatus; -typedef enum { +typedef enum +{ /* 0 */ MOTION_BLUR_OFF, /* 1 */ MOTION_BLUR_SETUP, /* 2 */ MOTION_BLUR_PROCESS @@ -1377,7 +1378,7 @@ void Play_Draw(PlayState* this) { if (!IS_DEBUG || (R_HREG_MODE != HREG_MODE_PLAY) || (R_PLAY_DRAW_ENV_FLAGS & PLAY_ENV_DRAW_SKYBOX_FILTERS)) { Environment_DrawSkyboxFilters(this); } - + // The Z buffer has to be cleared at some point before anything using it // is drawn (lighting strike is the first which does). But if we are // using F3DEX3's SPMemset to clear it, it should be done as late as diff --git a/src/code/z_rcp.c b/src/code/z_rcp.c index 75ad1fff14..84f27878e1 100644 --- a/src/code/z_rcp.c +++ b/src/code/z_rcp.c @@ -1557,18 +1557,18 @@ void Gfx_SetupFrame(GraphicsContext* gfxCtx, s32 clearFB, u8 r, u8 g, u8 b) { void Gfx_ClearZBuffer(GraphicsContext* gfxCtx) { s32 letterboxSize = Letterbox_GetSize(); OPEN_DISPS(gfxCtx, "../z_rcp.c", __LINE__); - + // Set the whole z buffer to maximum depth // Don't bother with pixels that are being covered by the letterbox #if ENABLE_F3DEX3 if (gUseMemsetForZBuffer) { s32 w2 = gScreenWidth * 2; // 2 bytes per pixel - if(letterboxSize < 0 || letterboxSize > 100){ + if (letterboxSize < 0 || letterboxSize > 100) { letterboxSize = 0; } gSPMemset(POLY_OPA_DISP++, (u8*)gZBuffer + letterboxSize * w2, GPACK_ZDZ(G_MAXFBZ, 0), - (gScreenHeight - 2 * letterboxSize) * w2); - }else{ + (gScreenHeight - 2 * letterboxSize) * w2); + } else { #endif gSPDisplayList(POLY_OPA_DISP++, sFillSetupDL); gDPSetColorImage(POLY_OPA_DISP++, G_IM_FMT_RGBA, G_IM_SIZ_16b, gScreenWidth, gZBuffer); diff --git a/src/debug/menu.c b/src/debug/menu.c index c513644aab..1a7570919a 100644 --- a/src/debug/menu.c +++ b/src/debug/menu.c @@ -39,7 +39,7 @@ void Menu_Update(Menu* this) { u8 pressDLeft = CHECK_BTN_ALL(pressBtn, BTN_DLEFT); u8 pressDRight = CHECK_BTN_ALL(pressBtn, BTN_DRIGHT); u8 i; - + if (isHoldingR && CHECK_BTN_ALL(pressBtn, BTN_L)) { this->bShow ^= 1; } From 49efb57c02c246692f55413a2202dd290b329407 Mon Sep 17 00:00:00 2001 From: Sauraen Date: Sun, 2 Jun 2024 15:09:41 -0700 Subject: [PATCH 5/5] more lint --- src/code/z_play.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/code/z_play.c b/src/code/z_play.c index 2fbc2d2752..d04db072f6 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -1113,8 +1113,7 @@ extern u16 (*gWorkBuf)[SCREEN_WIDTH * SCREEN_HEIGHT]; static u8 sMotionBlurStatus; -typedef enum -{ +typedef enum { /* 0 */ MOTION_BLUR_OFF, /* 1 */ MOTION_BLUR_SETUP, /* 2 */ MOTION_BLUR_PROCESS