Skip to content

Big cast cleanup#3076

Draft
roeming wants to merge 3 commits intozeldaret:mainfrom
roeming:cast_add_cleanup
Draft

Big cast cleanup#3076
roeming wants to merge 3 commits intozeldaret:mainfrom
roeming:cast_add_cleanup

Conversation

@roeming
Copy link
Contributor

@roeming roeming commented Jan 29, 2026

I went through and cleaned up a lot of the s16 casts, but let me know if I went a little overboard. I tried to differentiate s16s from angles, don't know how necessary that was, but it was easier to fix as I went along.

@decomp-dev
Copy link

decomp-dev bot commented Jan 29, 2026

Report for Shield (00bdde3 - fe3bad7)

📈 1 improvement in an unmatched item
Unit Item Bytes Before After
d_a_npc_kn/d/actor/d_a_npc_kn daNpc_Kn_c::calcSlip() +24 95.34% 99.98%

Report for RZDJ01 (00bdde3 - fe3bad7)

No changes

Report for RZDP01 (00bdde3 - fe3bad7)

No changes

Report for GZ2J01 (00bdde3 - fe3bad7)

No changes

Report for DZDE01 (00bdde3 - fe3bad7)

No changes

Report for GZ2P01 (00bdde3 - fe3bad7)

No changes

Report for GZ2E01 (00bdde3 - fe3bad7)

No changes

Report for RZDE01_00 (00bdde3 - fe3bad7)

No changes

Report for ShieldD (00bdde3 - fe3bad7)

No changes

Report for RZDE01_02 (00bdde3 - fe3bad7)

No changes

@roeming
Copy link
Contributor Author

roeming commented Jan 30, 2026

As a thought, instead of all these macros, I could instead replace the macros with typedefs, something like typedef int Shield_s16; where the shield version instead typedefs it to s16. This would allow a cleaner cast, but at the result of seeing casts everywhere. Thoughts?

@roeming roeming marked this pull request as draft February 1, 2026 19:27
@TakaRikka
Copy link
Contributor

i prefer the macros personally

@roeming
Copy link
Contributor Author

roeming commented Feb 2, 2026

Do you think there are too many casts in this pr? I replaced all the += (s16) and related lines of code. It felt excessive, but I want to know if this is the scale of replacement you would want.

#define MULT_S32(x, y) MULT_VAR_CAST(x, y, s32)
#define MULT_U32(x, y) MULT_VAR_CAST(x, y, u32)

#define ADD_ANGLE(x, y) ADD_S16(x, y)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's data in daObjProp_c::execute called ADD_ANGLE, so it might be better to use a different name to not conflict. what about ANGLE_ADD or ANGLE_INCR? and similarly ANGLE_SUB or ANGLE_DECR, and ANGLE_MULT

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can do that, but there's no conflict currently. By defining the macro to take parameters, ADD_ANGLE[] does not become a macro and is instead resolved as a variable name.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think in general i just prefer the TYPE_METHOD naming style rather than opposite. but its just a personal preference

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants