-
Notifications
You must be signed in to change notification settings - Fork 126
AI-assisted decompilation: 8 new 100% matches #2373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -576,15 +576,20 @@ void grIceMt_801F7EE8(Ground_GObj* arg0) | |
| } | ||
|
|
||
| /// #grIceMt_801F7F1C | ||
| void grIceMt_801F7F1C(Ground_GObj* arg0) | ||
| void grIceMt_801F7F1C(HSD_GObj* gobj) | ||
| { | ||
| int i = 0; | ||
| Ground* gp = GET_GROUND(arg0); | ||
| u8 _[8]; | ||
| void* ptr; | ||
| s32 i; | ||
|
|
||
| i = 0; | ||
| ptr = gobj->user_data; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Most GObj types have an associated getter macro, which we try to use everywhere. |
||
| do { | ||
| if (42 != 0) { | ||
| grMaterial_801C8CDC(arg0); | ||
| if (*(void**)((u8*)ptr + 0xF8) != NULL) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ptr should be a Ground*, not a void* |
||
| grMaterial_801C8CDC(*(void**)((u8*)ptr + 0xF8)); | ||
| } | ||
| i++; | ||
| i += 1; | ||
| ptr = (void*)((u8*)ptr + 4); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks like a compiler optimization. for (int i = 0; i < 2; i++) {
foo(arr[i]);
}
// can compile to:
for (int i = 0; i < 2; i++) {
foo(arr++);
} |
||
| } while (i < 2); | ||
| } | ||
|
|
||
|
|
@@ -631,13 +636,19 @@ void grIceMt_801F815C(Ground_GObj* param1) | |
| /// #grIceMt_801F81B4 | ||
| void grIceMt_801F81B4(Ground_GObj* arg0) | ||
| { | ||
| int i = 0; | ||
| Ground* gp = GET_GROUND(arg0); | ||
| Ground* gp; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function looks like a copypaste of |
||
| int i; | ||
| PAD_STACK(8); | ||
|
|
||
| i = 0; | ||
| gp = arg0->user_data; | ||
|
|
||
| do { | ||
| if (42 != 0) { | ||
| grMaterial_801C8CDC(arg0); | ||
| if (*(HSD_GObj**)((u8*)gp + 0xF8) != NULL) { | ||
| grMaterial_801C8CDC(*(HSD_GObj**)((u8*)gp + 0xF8)); | ||
| } | ||
| i++; | ||
| gp = (Ground*)((u8*)gp + 4); | ||
| } while (i < 2); | ||
| } | ||
|
|
||
|
|
@@ -1007,28 +1018,73 @@ void grIceMt_801F91EC(HSD_GObj* param_1, s16* param_2, int param_3, | |
| /// #grIceMt_801F929C | ||
| void grIceMt_801F929C(HSD_GObj* arg0, void* arg1) | ||
| { | ||
| mpLib_80057BC0(2); | ||
| mpJointListAdd(2); | ||
| grAnime_801C83D0(arg0, 2, 7); | ||
| s16 temp_r3; | ||
|
|
||
| if (*(s16*)((u8*)arg1 + 0x0) != 0) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a lot of pointer math here. Need to use struct grIceMt_801F929C_arg1 { /// @todo this should be an internal struct within grIceMt_GroundVars
s16 x0;
s16 x2;
// ...
}* p = arg1;I'd prefer: actual struct > m2c_field = temporary struct > pointer math. |
||
| *(s16*)((u8*)arg1 + 0x2) = (s16) (*(s16*)((u8*)arg1 + 0x2) + 1); | ||
| temp_r3 = *(s16*)((u8*)arg1 + 0x2); | ||
| if (temp_r3 == *(s16*)((u8*)arg1 + 0xA)) { | ||
| mpLib_80057BC0(*(s16*)((u8*)arg1 + 0x8)); | ||
| } else if (temp_r3 == *(s16*)((u8*)arg1 + 0xC)) { | ||
| mpJointListAdd(*(s16*)((u8*)arg1 + 0x8)); | ||
| } | ||
| if (grAnime_801C83D0(arg0, *(s16*)((u8*)arg1 + 0x4), 7) != 0) { | ||
| *(s16*)((u8*)arg1 + 0x0) = 0; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /// #fn_801F9338 | ||
| void fn_801F9338(Ground* gp, int arg1, CollData* arg2, s32 arg3, | ||
| mpLib_GroundEnum arg4, float arg8) | ||
| { | ||
| // mpLib_80057BC0(2); | ||
| // mpJointListAdd(2); | ||
| // grAnime_801C83D0(arg0,2,7); | ||
| HSD_GObj* temp_r3; | ||
| s16* temp_r30; | ||
| s16 temp_r4; | ||
| u8 flag_byte; | ||
|
|
||
| temp_r30 = (s16*)((u8*)gp + 0x100); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. More pointer math. 0x100 is a HSD_GObj* in icemt, which doesn't seem right for this usage. Perhaps this shares a struct with 801F929C above? icemt3 might be the way to go until we can figure out what's going on. |
||
| flag_byte = *(u8*)((u8*)arg2 + 0x34); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer struct access by name: |
||
| if (((flag_byte >> 3) & 0xF) == 1 && *temp_r30 == 0) { | ||
| temp_r3 = Ground_801C2BA4(2); | ||
| *temp_r30 = 1; | ||
| temp_r30[1] = 0; | ||
| grAnime_801C7A04(temp_r3, temp_r30[2], 7, 1.0f); | ||
| grAnime_801C7B24(temp_r3, temp_r30[2], 7, 0.0f); | ||
| grAnime_801C78FC(temp_r3, temp_r30[2], 7); | ||
| temp_r4 = temp_r30[3]; | ||
| if (temp_r4 != -1) { | ||
| grAnime_801C7A04(temp_r3, temp_r4, 7, 1.0f); | ||
| grAnime_801C7B24(temp_r3, temp_r30[3], 7, 0.0f); | ||
| grAnime_801C78FC(temp_r3, temp_r30[3], 7); | ||
| } | ||
| } | ||
| grIceMt_801FA7F0(gp, arg1, arg2, arg3, arg4, arg8); | ||
| } | ||
|
|
||
| /// #fn_801F9448 | ||
| void fn_801F9448(Ground* gp, int arg1, CollData* arg2, s32 arg3, | ||
| mpLib_GroundEnum arg4, float arg8) | ||
| { | ||
| // mpLib_80057BC0(2); | ||
| // mpJointListAdd(2); | ||
| // grAnime_801C83D0(arg0,2,7); | ||
| HSD_GObj* gobj; | ||
| s16* icemt_ptr = &gp->gv.icemt.x10E; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There could be some inlines afoot here, this looks very similar to |
||
| s16 temp_r4; | ||
| u8 flag_byte = *(u8*)((u8*)arg2 + 0x34); | ||
|
|
||
| if (((flag_byte >> 3) & 0xF) == 1 && icemt_ptr[0] == 0) { | ||
| gobj = Ground_801C2BA4(2); | ||
| icemt_ptr[0] = 1; | ||
| icemt_ptr[1] = 0; | ||
| grAnime_801C7A04(gobj, icemt_ptr[2], 7, 1.0f); | ||
| grAnime_801C7B24(gobj, icemt_ptr[2], 7, 0.0f); | ||
| grAnime_801C78FC(gobj, icemt_ptr[2], 7); | ||
| temp_r4 = icemt_ptr[3]; | ||
| if (temp_r4 != -1) { | ||
| grAnime_801C7A04(gobj, temp_r4, 7, 1.0f); | ||
| grAnime_801C7B24(gobj, icemt_ptr[3], 7, 0.0f); | ||
| grAnime_801C78FC(gobj, icemt_ptr[3], 7); | ||
| } | ||
| } | ||
| grIceMt_801FA7F0(gp, arg1, arg2, arg3, arg4, arg8); | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -239,14 +239,18 @@ void grPura_8021228C(Ground_GObj* arg0) {} | |
| /// #grPura_80212290 | ||
| void grPura_80212290(Ground_GObj* arg0) | ||
| { | ||
| Ground* gp = GET_GROUND(arg0); | ||
| HSD_JObj* jobj = arg0->hsd_obj; | ||
| HSD_ImageDesc* image = grPu_803E6E20; | ||
| HSD_MObjSetToonTextureImage(image); | ||
| lb_80011C18(jobj, 0x1000); | ||
| grPura_80213250(jobj); | ||
| HSD_MObjSetToonTextureImage(0); | ||
| grAnime_801C8138(arg0, gp->map_id, 0); | ||
| Ground* temp_r31; | ||
| HSD_JObj* temp_r30; | ||
| PAD_STACK(8); | ||
|
|
||
| temp_r31 = arg0->user_data; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. GET_GROUND (we are pretty sure they used it everywhere, and not having it can affect codegen in strange ways. this time it didn't but good to stay consistent) |
||
| temp_r30 = arg0->hsd_obj; | ||
| *(void (**)(HSD_GObj*, int))((u8*)arg0 + 0x1C) = fn_802130D0; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| HSD_MObjSetToonTextureImage(&grPu_803E7620); | ||
| lb_80011C18(temp_r30, 0x1000U); | ||
| grPura_80213250(temp_r30); | ||
| HSD_MObjSetToonTextureImage(NULL); | ||
| grAnime_801C8138((HSD_GObj* ) arg0, temp_r31->map_id, 0); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no cast required between HSD_GObj and Ground_GObj, they're the same type |
||
| } | ||
|
|
||
| bool grPura_80212314(Ground_GObj* arg0) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,7 +38,14 @@ void it_802D73F0(Item_GObj* gobj) | |
| it_802D747C(gobj); | ||
| } | ||
|
|
||
| void it_802D747C(Item_GObj* gobj) {} | ||
| void it_802D747C(Item_GObj* gobj) | ||
| { | ||
| u8 _[8]; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| it_8027CAD8(gobj); | ||
| it_8027C0A8(gobj, 0.0f, 5.0f); | ||
| it_802756E0(gobj); | ||
| it_802D848C(gobj, 0, 2); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 2 = ITEM_ANIM_UPDATE |
||
| } | ||
|
|
||
| bool itOldkuri_UnkMotion0_Anim(Item_GObj* gobj) | ||
| { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ground_GObj is a typedef for HSD_GObj, but leaving it as a Ground_GObj gives more information to readers (and m2c, our decompiler).