Match: Parts of src/66250.c#36
Conversation
Drahsid
left a comment
There was a problem hiding this comment.
minor issues: mostly not labeling flags with the enums, missing use of FIXED_POINT, and minor style.
| gActors[actor_index].velocityX.raw = Math_ApproachS32(gActors[actor_index].velocityX.raw, 0, 0x4000); | ||
| gActors[actor_index].velocityY.raw = Math_ApproachS32(gActors[actor_index].velocityY.raw, 0, 0x4000); |
| void func_8007A8B0(u16 actor_index) { | ||
| u16 sp1E; | ||
|
|
||
| if (!(gActors[actor_index].flags_098 & 2) || (gActors[actor_index].var_150 & 0x100000)) { |
There was a problem hiding this comment.
| if (!(gActors[actor_index].flags_098 & 2) || (gActors[actor_index].var_150 & 0x100000)) { | |
| if (!(gActors[actor_index].flags_098 & ACTOR_FLAG3_UNK1) || (gActors[actor_index].var_150 & 0x100000)) { |
| } | ||
|
|
||
| sp1E = gActors[actor_index].unk_0D6; | ||
| gActors[actor_index].graphicFlags &= ~8; |
There was a problem hiding this comment.
| gActors[actor_index].graphicFlags &= ~8; | |
| gActors[actor_index].graphicFlags &= ~ACTOR_GFLAG_ROTZ; |
| gActors[arg0].flags |= 0x1000; | ||
| gActors[arg0].var_150 &= ~0x300000; | ||
| D_800BE704 = 0x10; | ||
| gActors[arg0 + 1].flags = 2; |
There was a problem hiding this comment.
| gActors[arg0 + 1].flags = 2; | |
| gActors[arg0 + 1].flags = ACTOR_FLAG_ACTIVE; |
| } | ||
| else { | ||
| gActors[arg0].state = 0x10; | ||
| gActors[arg0].flags |= 0x1000; |
There was a problem hiding this comment.
| gActors[arg0].flags |= 0x1000; | |
| gActors[arg0].flags |= ACTOR_FLAG_UNK12; |
| var_f0 = -var_f0; | ||
| } | ||
| gActors[arg0].rotateZ = var_f0; | ||
| if (gActors[arg0].flags & 0x20) { |
There was a problem hiding this comment.
| if (gActors[arg0].flags & 0x20) { | |
| if (gActors[arg0].flags & ACTOR_FLAG_FLIPPED) { |
| gActors[arg0].flags &= ~0x20; | ||
| gActors[0].flags &= ~0x20; | ||
| } | ||
| if (gActors[arg0].velocityX.raw < FIXED_UNIT(-1.5)) { | ||
| gActors[arg0].flags |= 0x20; | ||
| gActors[0].flags |= 0x20; |
There was a problem hiding this comment.
| gActors[arg0].flags &= ~0x20; | |
| gActors[0].flags &= ~0x20; | |
| } | |
| if (gActors[arg0].velocityX.raw < FIXED_UNIT(-1.5)) { | |
| gActors[arg0].flags |= 0x20; | |
| gActors[0].flags |= 0x20; | |
| gActors[arg0].flags &= ~ACTOR_FLAG_FLIPPED; | |
| gActors[0].flags &= ~ACTOR_FLAG_FLIPPED; | |
| } | |
| if (gActors[arg0].velocityX.raw < FIXED_UNIT(-1.5)) { | |
| gActors[arg0].flags |= ACTOR_FLAG_FLIPPED; | |
| gActors[0].flags |= ACTOR_FLAG_FLIPPED; |
| gActors[arg0].flags_098 |= gActors[arg0 + 1].flags_098; | ||
| if (gActors[arg0].flags_098 & 0x10) { | ||
| gActors[arg0].velocityY.raw = -FIXED_UNIT(2); | ||
| gActors[arg0].posY.whole = gActors[arg0 + 1].posY.whole; | ||
| } | ||
| if (gActors[arg0].flags_098 & 0x20) { | ||
| gActors[arg0].velocityY.raw = FIXED_UNIT(2); | ||
| gActors[arg0].posY.whole = gActors[arg0 + 1].posY.whole; | ||
| } | ||
| if ((gActors[arg0].flags_098 & 4) || (func_80012AB4(gActors[arg0 + 1].posX.whole + gActors[arg0 + 1].hitboxBX0, (gActors[arg0 + 1].posY.whole + gActors[arg0 + 1].hitboxBY0) - 8) & 0x80)) { | ||
| gActors[arg0].velocityX.raw = FIXED_UNIT(2); | ||
| gActors[arg0].posX.whole = gActors[arg0 + 1].posX.whole; | ||
| gActors[arg0].var_15C = 0; | ||
| } | ||
| if ((gActors[arg0].flags_098 & 8) || (func_80012AB4(gActors[arg0 + 1].posX.whole + gActors[arg0 + 1].hitboxBX1, (gActors[arg0 + 1].posY.whole + gActors[arg0 + 1].hitboxBY0) - 8) & 0x80)) { |
There was a problem hiding this comment.
| gActors[arg0].flags_098 |= gActors[arg0 + 1].flags_098; | |
| if (gActors[arg0].flags_098 & 0x10) { | |
| gActors[arg0].velocityY.raw = -FIXED_UNIT(2); | |
| gActors[arg0].posY.whole = gActors[arg0 + 1].posY.whole; | |
| } | |
| if (gActors[arg0].flags_098 & 0x20) { | |
| gActors[arg0].velocityY.raw = FIXED_UNIT(2); | |
| gActors[arg0].posY.whole = gActors[arg0 + 1].posY.whole; | |
| } | |
| if ((gActors[arg0].flags_098 & 4) || (func_80012AB4(gActors[arg0 + 1].posX.whole + gActors[arg0 + 1].hitboxBX0, (gActors[arg0 + 1].posY.whole + gActors[arg0 + 1].hitboxBY0) - 8) & 0x80)) { | |
| gActors[arg0].velocityX.raw = FIXED_UNIT(2); | |
| gActors[arg0].posX.whole = gActors[arg0 + 1].posX.whole; | |
| gActors[arg0].var_15C = 0; | |
| } | |
| if ((gActors[arg0].flags_098 & 8) || (func_80012AB4(gActors[arg0 + 1].posX.whole + gActors[arg0 + 1].hitboxBX1, (gActors[arg0 + 1].posY.whole + gActors[arg0 + 1].hitboxBY0) - 8) & 0x80)) { | |
| gActors[arg0].flags_098 |= gActors[arg0 + 1].flags_098; | |
| if (gActors[arg0].flags_098 & ACTOR_FLAG3_UNK4) { | |
| gActors[arg0].velocityY.raw = -FIXED_UNIT(2); | |
| gActors[arg0].posY.whole = gActors[arg0 + 1].posY.whole; | |
| } | |
| if (gActors[arg0].flags_098 & ACTOR_FLAG3_UNK5) { | |
| gActors[arg0].velocityY.raw = FIXED_UNIT(2); | |
| gActors[arg0].posY.whole = gActors[arg0 + 1].posY.whole; | |
| } | |
| if ((gActors[arg0].flags_098 & ACTOR_FLAG3_UNK2) || (func_80012AB4(gActors[arg0 + 1].posX.whole + gActors[arg0 + 1].hitboxBX0, (gActors[arg0 + 1].posY.whole + gActors[arg0 + 1].hitboxBY0) - 8) & 0x80)) { | |
| gActors[arg0].velocityX.raw = FIXED_UNIT(2); | |
| gActors[arg0].posX.whole = gActors[arg0 + 1].posX.whole; | |
| gActors[arg0].var_15C = 0; | |
| } | |
| if ((gActors[arg0].flags_098 & ACTOR_FLAG3_UNK3) || (func_80012AB4(gActors[arg0 + 1].posX.whole + gActors[arg0 + 1].hitboxBX1, (gActors[arg0 + 1].posY.whole + gActors[arg0 + 1].hitboxBY0) - 8) & 0x80)) { |
| } else { | ||
| if (gButtonHold & gButton_DLeft) { | ||
| gActors[arg0].var_15C -= 0x4000; | ||
| } else if (gButtonHold & gButton_DRight) { | ||
| gActors[arg0].var_15C += 0x4000; | ||
| } else if (gActors[arg0].flags & 0x20) { | ||
| gActors[arg0].var_15C = Math_ApproachS32(gActors[arg0].var_15C, -0x8000, 0x1000); | ||
| } else { | ||
| gActors[arg0].var_15C = Math_ApproachS32(gActors[arg0].var_15C, 0x8000, 0x1000); | ||
| } | ||
| } | ||
| var_a3 = gButtonHold & gButton_LTrig; | ||
| if (var_a3 || (gButtonHold & gButton_RTrig)) { | ||
| gActors[arg0].var_15C = Math_ClampLimit(gActors[arg0].var_15C, 0x28000); | ||
| var_a3 = 0x40000; | ||
| var_a3 |= 0x8000; | ||
| } else { | ||
| gActors[arg0].var_15C = Math_ClampLimit(gActors[arg0].var_15C, FIXED_UNIT(8)); | ||
| var_a3 = 0x30000; | ||
| var_a3 |= 0x8000; | ||
| } | ||
|
|
||
| if (gActors[arg0].unk_118 >= 0.0f) { | ||
| gActors[arg0].velocityY.raw = Math_ApproachS32(gActors[arg0].velocityY.raw, 0, 0x1000); | ||
| } else if (gButtonHold & gButton_DUp) { | ||
| gActors[arg0].velocityY.raw = Math_ApproachS32(gActors[arg0].velocityY.raw, var_a3, 0x4000); | ||
| } else if (gButtonHold & gButton_DDown) { | ||
| gActors[arg0].velocityY.raw = Math_ApproachS32(gActors[arg0].velocityY.raw, -var_a3, 0x4000); | ||
| } else if ((gActors[arg0].velocityX.raw > FIXED_UNIT(2)) || (gActors[arg0].velocityX.raw < FIXED_UNIT(-2))) { | ||
| gActors[arg0].velocityY.raw = Math_ApproachS32(gActors[arg0].velocityY.raw, 0, 0x4000); | ||
| } else if (gActiveFrames & 0x10) { | ||
| gActors[arg0].velocityY.raw = Math_ApproachS32(gActors[arg0].velocityY.raw, 0x18000, 0x4000); | ||
| } else { | ||
| gActors[arg0].velocityY.raw = Math_ApproachS32(gActors[arg0].velocityY.raw, -0x18000, 0x4000); | ||
| } |
There was a problem hiding this comment.
| } else { | |
| if (gButtonHold & gButton_DLeft) { | |
| gActors[arg0].var_15C -= 0x4000; | |
| } else if (gButtonHold & gButton_DRight) { | |
| gActors[arg0].var_15C += 0x4000; | |
| } else if (gActors[arg0].flags & 0x20) { | |
| gActors[arg0].var_15C = Math_ApproachS32(gActors[arg0].var_15C, -0x8000, 0x1000); | |
| } else { | |
| gActors[arg0].var_15C = Math_ApproachS32(gActors[arg0].var_15C, 0x8000, 0x1000); | |
| } | |
| } | |
| var_a3 = gButtonHold & gButton_LTrig; | |
| if (var_a3 || (gButtonHold & gButton_RTrig)) { | |
| gActors[arg0].var_15C = Math_ClampLimit(gActors[arg0].var_15C, 0x28000); | |
| var_a3 = 0x40000; | |
| var_a3 |= 0x8000; | |
| } else { | |
| gActors[arg0].var_15C = Math_ClampLimit(gActors[arg0].var_15C, FIXED_UNIT(8)); | |
| var_a3 = 0x30000; | |
| var_a3 |= 0x8000; | |
| } | |
| if (gActors[arg0].unk_118 >= 0.0f) { | |
| gActors[arg0].velocityY.raw = Math_ApproachS32(gActors[arg0].velocityY.raw, 0, 0x1000); | |
| } else if (gButtonHold & gButton_DUp) { | |
| gActors[arg0].velocityY.raw = Math_ApproachS32(gActors[arg0].velocityY.raw, var_a3, 0x4000); | |
| } else if (gButtonHold & gButton_DDown) { | |
| gActors[arg0].velocityY.raw = Math_ApproachS32(gActors[arg0].velocityY.raw, -var_a3, 0x4000); | |
| } else if ((gActors[arg0].velocityX.raw > FIXED_UNIT(2)) || (gActors[arg0].velocityX.raw < FIXED_UNIT(-2))) { | |
| gActors[arg0].velocityY.raw = Math_ApproachS32(gActors[arg0].velocityY.raw, 0, 0x4000); | |
| } else if (gActiveFrames & 0x10) { | |
| gActors[arg0].velocityY.raw = Math_ApproachS32(gActors[arg0].velocityY.raw, 0x18000, 0x4000); | |
| } else { | |
| gActors[arg0].velocityY.raw = Math_ApproachS32(gActors[arg0].velocityY.raw, -0x18000, 0x4000); | |
| } | |
| } | |
| else { | |
| if (gButtonHold & gButton_DLeft) { | |
| gActors[arg0].var_15C -= 0x4000; | |
| } | |
| else if (gButtonHold & gButton_DRight) { | |
| gActors[arg0].var_15C += 0x4000; | |
| } | |
| else if (gActors[arg0].flags & 0x20) { | |
| gActors[arg0].var_15C = Math_ApproachS32(gActors[arg0].var_15C, -0x8000, 0x1000); | |
| } | |
| else { | |
| gActors[arg0].var_15C = Math_ApproachS32(gActors[arg0].var_15C, 0x8000, 0x1000); | |
| } | |
| } | |
| var_a3 = gButtonHold & gButton_LTrig; | |
| if (var_a3 || (gButtonHold & gButton_RTrig)) { | |
| gActors[arg0].var_15C = Math_ClampLimit(gActors[arg0].var_15C, 0x28000); | |
| var_a3 = 0x40000; | |
| var_a3 |= 0x8000; | |
| } | |
| else { | |
| gActors[arg0].var_15C = Math_ClampLimit(gActors[arg0].var_15C, FIXED_UNIT(8)); | |
| var_a3 = 0x30000; | |
| var_a3 |= 0x8000; | |
| } | |
| if (gActors[arg0].unk_118 >= 0.0f) { | |
| gActors[arg0].velocityY.raw = Math_ApproachS32(gActors[arg0].velocityY.raw, 0, 0x1000); | |
| } | |
| else if (gButtonHold & gButton_DUp) { | |
| gActors[arg0].velocityY.raw = Math_ApproachS32(gActors[arg0].velocityY.raw, var_a3, 0x4000); | |
| } | |
| else if (gButtonHold & gButton_DDown) { | |
| gActors[arg0].velocityY.raw = Math_ApproachS32(gActors[arg0].velocityY.raw, -var_a3, 0x4000); | |
| } | |
| else if ((gActors[arg0].velocityX.raw > FIXED_UNIT(2)) || (gActors[arg0].velocityX.raw < FIXED_UNIT(-2))) { | |
| gActors[arg0].velocityY.raw = Math_ApproachS32(gActors[arg0].velocityY.raw, 0, 0x4000); | |
| } | |
| else if (gActiveFrames & 0x10) { | |
| gActors[arg0].velocityY.raw = Math_ApproachS32(gActors[arg0].velocityY.raw, 0x18000, 0x4000); | |
| } | |
| else { | |
| gActors[arg0].velocityY.raw = Math_ApproachS32(gActors[arg0].velocityY.raw, -0x18000, 0x4000); | |
| } |
Code style: no cuddled else
| } else { | ||
| func_80035A20(arg0); |
There was a problem hiding this comment.
| } else { | |
| func_80035A20(arg0); | |
| } | |
| else { | |
| func_80035A20(arg0); |
| Actor* temp_v0; | ||
| s32 var_v1; | ||
|
|
||
| temp_v0 = &gActors[arg0]; |
There was a problem hiding this comment.
Only calling this out since using Actor pointers sometimes prevents matches. Devs seemed to prefer using indexes instead of pointers so I'd recommend matching with: https://decomp.me/scratch/HZDfG
Otherwise, aside from the Drahsid's recommendations. this looks great!
No description provided.