Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/game/shared/stage/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ extern bool32 sub_8020700(Sprite *s, s32 worldX, s32 worldY, s16 p3, Player *p,
// Collision - 'p5' might be hitbox ID?
extern u32 sub_8020874(Sprite *s, s32 worldX, s32 worldY, s16 p3, Player *p, s16 p5, u8 p6);
u32 sub_8020950(Sprite *s, s32 worldX, s32 worldY, Player *p, u8 param4); // collision
bool32 sub_8020A58(Sprite *s, s16 param1, s32 worldX, s32 worldY, Rect8 *param4, Player *p, u8 param6);
bool32 sub_8020A58(Sprite *s, s16 hbIndex, s32 worldX, s32 worldY, Rect8 *param4, Player *p, u8 param6);
bool32 sub_8020CE0(Sprite *s, s32 worldX, s32 worldY, s16 hbIndex, Player *p);
bool32 sub_8020E3C(Sprite *s, s32 param1, s32 param2, s16 param3, Player *p);

Expand Down
123 changes: 46 additions & 77 deletions src/game/sa3/stage/player.c
Original file line number Diff line number Diff line change
Expand Up @@ -22650,9 +22650,8 @@ u32 sub_8020950(Sprite *s, s32 worldX, s32 worldY, Player *p, u8 param4)
return temp_r0;
}

u32 sub_8020A58(Sprite *s, s16 param1, s32 worldX, s32 worldY, Rect8 *playerBox, Player *p, u8 param6)
u32 sub_8020A58(Sprite *s, s16 hbIndex, s32 worldX, s32 worldY, Rect8 *playerBox, Player *p, u8 param6)
{
s32 var_r2;
s32 var_r1;
s32 var_r5;
s32 midX;
Expand All @@ -22661,97 +22660,67 @@ u32 sub_8020A58(Sprite *s, s16 param1, s32 worldX, s32 worldY, Rect8 *playerBox,
s32 playerY = I(p->qWorldY);
u32 var_r6 = 0;
if ((p->charFlags.anim0 == 92) || (p->charFlags.anim0 == 93)) {
if (p->moveState & 0x10000) {
if (p->moveState & MOVESTATE_GRAVITY_SWITCHED) {
playerY -= 32;
} else {
playerY += 32;
}
}
#define RETURN_ZERO goto FINAL_RETURN
if ((worldX + s->hitboxes[param1].b.left) <= (playerX + playerBox->left)) {
if (((worldX + s->hitboxes[param1].b.left) + (s->hitboxes[param1].b.right - s->hitboxes[param1].b.left))
< (playerX + playerBox->left)) {
if ((worldX + s->hitboxes[param1].b.left) < (playerX + playerBox->left)) {
RETURN_ZERO;
}
goto ELSE1;
}
} else {
ELSE1:
if (((playerX + playerBox->left) + RECT_WIDTH(playerBox)) < (worldX + s->hitboxes[param1].b.left)) {
RETURN_ZERO;
if (HB_COLLISION(worldX, worldY, s->hitboxes[hbIndex].b, playerX, playerY, (*playerBox))) {
s32 var_r2 = ((s->hitboxes[hbIndex].b.left + s->hitboxes[hbIndex].b.right) >> 1) + worldX;
midY = worldY + ((s->hitboxes[hbIndex].b.top + s->hitboxes[hbIndex].b.bottom) >> 1);
if (var_r2 <= playerX) {
var_r5 = (worldX + s->hitboxes[hbIndex].b.right) - (playerBox->left + playerX);
var_r6 |= 0x40000;
} else {
var_r5 = (worldX + s->hitboxes[hbIndex].b.left) - (playerBox->right + playerX);
var_r6 |= 0x80000;
}
}
if ((worldY + s->hitboxes[param1].b.top) <= (playerY + playerBox->top)) {
if (((worldY + s->hitboxes[param1].b.top) + (s->hitboxes[param1].b.bottom - s->hitboxes[param1].b.top))
< (playerY + playerBox->top)) {
if ((worldY + s->hitboxes[param1].b.top) < (playerY + playerBox->top)) {
RETURN_ZERO;
if (midY > playerY) {
midY = (worldY + s->hitboxes[hbIndex].b.top) - (playerY + playerBox->bottom);
if (p->moveState & MOVESTATE_GRAVITY_SWITCHED) {
var_r1 = MIN(midY - 2, 0);
var_r6 |= 0x20000;
} else {
var_r1 = MIN(midY + 5, 0);
var_r6 |= 0x10000;
}
goto ELSE2;
}
} else {
ELSE2:
if (((playerY + playerBox->top) + RECT_HEIGHT(playerBox)) < (worldY + s->hitboxes[param1].b.top)) {
RETURN_ZERO;
}
}
#undef RETURN_ZERO

var_r2 = ((s->hitboxes[param1].b.left + s->hitboxes[param1].b.right) >> 1) + worldX;
midY = worldY + ((s->hitboxes[param1].b.top + s->hitboxes[param1].b.bottom) >> 1);
if (var_r2 <= playerX) {
var_r5 = (worldX + s->hitboxes[param1].b.right) - (playerBox->left + playerX);
var_r6 |= 0x40000;
} else {
var_r5 = (worldX + s->hitboxes[param1].b.left) - (playerBox->right + playerX);
var_r6 |= 0x80000;
}
if (midY > playerY) {
midY = (worldY + s->hitboxes[param1].b.top) - (playerY + playerBox->bottom);
if (p->moveState & 0x00010000) {
var_r1 = MIN(midY - 2, 0);
var_r6 = var_r6 | 0x20000;
} else {
var_r1 = MIN(midY + 5, 0);
var_r6 = var_r6 | 0x10000;
midY = (worldY + s->hitboxes[hbIndex].b.bottom) - (playerY + playerBox->top);
if (p->moveState & MOVESTATE_GRAVITY_SWITCHED) {
var_r1 = MAX(midY - 5, 0);
var_r6 |= 0x10000;
} else {
var_r1 = MAX(midY + 2, 0);
var_r6 |= 0x20000;
}
}
} else {
midY = (worldY + s->hitboxes[param1].b.bottom) - (playerY + playerBox->top);
if (p->moveState & 0x00010000) {
var_r1 = MAX(midY - 5, 0);
var_r6 = var_r6 | 0x10000;
if (ABS(var_r5) < ABS(var_r1)) {
var_r6 &= 0xC0000;
} else {
var_r1 = MAX(midY + 2, 0);
var_r6 = var_r6 | 0x20000;
}
}
if (ABS(var_r5) < ABS(var_r1)) {
var_r6 &= 0xC0000;
} else {
var_r6 &= 0x30000;
if (var_r6 & 0x10000) {
if ((p->qSpeedAirY < 0) && (param6 == 0)) {
return 0;
var_r6 &= 0x30000;
if (var_r6 & 0x10000) {
if ((p->qSpeedAirY < 0) && (param6 == 0)) {
return 0;
}
if ((!(p->moveState & MOVESTATE_IN_AIR)) && ((p->unk26 + 0x20) & 0x40)) {
p->qSpeedGround = 0;
}
}
if ((!(p->moveState & 4)) && ((p->unk26 + 0x20) & 0x40)) {
p->qSpeedGround = 0;
}
var_r6 |= ((var_r5 << 8) & 0xFF00) | (midY & 0xFF);
if (var_r6 & 0xC0000) {
if (!(var_r6 & 0xFF00)) {
var_r6 &= 0xFFF300FF;
}
} else {
var_r6 &= 0xFFFF00FF;
}
}
var_r6 |= ((var_r5 << 8) & 0xFF00) | (midY & 0xFF);
if (var_r6 & 0xC0000) {
if (!(var_r6 & 0xFF00)) {
var_r6 &= 0xFFF300FF;
if (!(var_r6 & 0x30000)) {
var_r6 &= 0xFFFFFF00;
}
} else {
var_r6 &= 0xFFFF00FF;
}
if (!(var_r6 & 0x30000)) {
var_r6 &= 0xFFFFFF00;
}

FINAL_RETURN:
return var_r6;
}

Expand Down