Skip to content

Commit fe1120f

Browse files
committed
more interactable documentation, name player collision funcs
1 parent 9524d5e commit fe1120f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+467
-504
lines changed

include/constants/player_transitions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#define GUARD_PLAYER_TRANSITIONS_H
33

44
// 0x07 = Set in Egg Utopia - Launcher
5-
// 0x08 = Set in Collision_AdjustPlayerSpeed (0x0800CB18 - collision.c)
5+
// 0x08 = Set in Player_AdjustSpeedAfterBossCollision (0x0800CB18 - collision.c)
66
// 0x0A = Player cleared the stage (only for Acts, not Bosses?)
77
// 0x0B = Something Grinding
88
// 0x0C = Something Grinding

include/game/entity.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,6 @@ typedef struct {
5858
Sprite s;
5959
} EnemyBase;
6060

61-
u32 sub_800CDBC(Sprite *, s32, s32, Player *);
62-
63-
u32 sub_800DF38(Sprite *, s32, s32, Player *);
64-
6561
// After a MapEntity is initialized, its x-value in the layout-data gets set to -2.
6662
// TODO:
6763
// Find out whether casting these to u8 can work while still matching!
@@ -196,13 +192,13 @@ u32 sub_800DF38(Sprite *, s32, s32, Player *);
196192
}
197193

198194
#define ENEMY_DESTROY_IF_PLAYER_HIT(_s, _pos) \
199-
if (sub_800C4FC(_s, _pos.x, _pos.y, 0) == TRUE) { \
195+
if (Enemy_PlayerAttackCollision(_s, _pos.x, _pos.y, 0) == TRUE) { \
200196
TaskDestroy(gCurTask); \
201197
return; \
202198
}
203199

204200
#define ENEMY_DESTROY_IF_PLAYER_HIT_2(_s, _pos) \
205-
if (sub_800C4FC(_s, _pos.x, _pos.y, 0)) { \
201+
if (Enemy_PlayerAttackCollision(_s, _pos.x, _pos.y, 0)) { \
206202
TaskDestroy(gCurTask); \
207203
return; \
208204
}

include/game/sa1_sa2_shared/collision.h

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,31 @@
1919
u32 CheckRectCollision_SpritePlayer(Sprite *s, s32 sx, s32 sy, Player *p, Rect8 *rectPlayer);
2020

2121
// TODO: Include header this belongs to
22-
u32 sub_800C944(Sprite *, s32, s32);
22+
u32 Player_ItemBoxCollision(Sprite *, s32, s32);
2323

24-
bool32 sub_800C204(Sprite *, s32, s32, s16, Player *, s16);
25-
bool32 sub_800C320(Sprite *s, s32 sx, s32 sy, s16 hbIndex, Player *p);
26-
bool32 sub_800CA20(Sprite *s, s32 sx, s32 sy, s16 hbIndex, Player *p);
27-
bool32 IsColliding_Cheese(Sprite *sprTarget, s32 sx, s32 sy, s16 hbIndex, Player *p);
24+
bool32 Player_HitboxCollision(Sprite *, s32, s32, s16, Player *, s16);
25+
bool32 Player_AttackBossCollision(Sprite *s, s32 sx, s32 sy, s16 hbIndex, Player *p);
26+
bool32 Player_EnemyCollision(Sprite *s, s32 sx, s32 sy, s16 hbIndex, Player *p);
27+
bool32 Cheese_IsSpriteColliding(Sprite *sprTarget, s32 sx, s32 sy, s16 hbIndex, Player *p);
2828
u32 sub_800DA4C(Sprite *opponent, s16 oppX, s16 oppY, UNUSED s32 param3, UNUSED s32 param4, u8 layer);
29+
u32 sub_800CDBC(Sprite *, s32, s32, Player *);
30+
u32 Player_IsSpriteColliding(Sprite *, s32, s32, Player *);
31+
u32 Player_InteractableCollision(Sprite *s, s32 sx, s32 sy, Player *p);
2932

30-
// Lose rings?
31-
bool32 sub_800CBA4(Player *);
32-
void Collision_AdjustPlayerSpeed(Player *);
33+
bool32 Player_CollisionDamage(Player *);
34+
void Player_AdjustSpeedAfterBossCollision(Player *);
3335

34-
u32 sub_800CCB8(Sprite *, s32 x, s32 y, Player *);
36+
u32 Player_PlatformCollision(Sprite *, s32 x, s32 y, Player *);
3537

3638
u32 sub_800CE94(Sprite *s, s32 sx, s32 sy, Rect8 *param3, Player *p);
3739
bool32 sub_800DD54(Player *p);
3840
bool32 sub_800DE44(Player *p);
3941
u32 sub_800D0A0(Sprite *, s16, s16, s16, s16, u8, u32);
4042

4143
// HandlePlayerDestroy?
42-
bool32 sub_800C4FC(Sprite *, s32, s32, u8);
44+
bool32 Enemy_PlayerAttackCollision(Sprite *, s32, s32, u8);
4345

4446
// HandleHitPlayer
45-
u32 sub_800C84C(Sprite *, s32, s32);
47+
u32 Player_EnemySpriteCollision(Sprite *, s32, s32);
4648

4749
#endif // GUARD_STAGE_ENTITIES_0_H

src/game/bosses/boss_1.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ static void Task_803CA1C(void);
114114
static void sub_803CB18(EggHammerTankII *);
115115
static void sub_803AC2C(EggHammerTankII *);
116116
static void sub_803CBFC(EggHammerTankII *boss);
117-
static void sub_803B6AC(EggHammerTankII *boss);
117+
static void HandleBossHit(EggHammerTankII *boss);
118118
static void sub_803CC3C(EggHammerTankII *boss);
119119
static void sub_803B17C(EggHammerTankII *boss);
120120
static void sub_803B264(EggHammerTankII *boss);
@@ -367,7 +367,7 @@ static void sub_803A8E4(EggHammerTankII *boss)
367367
pos.y -= I(gPlayer.qWorldY);
368368
if ((SQUARE(pos.x) + SQUARE(pos.y)) < 0x1A4) {
369369
sub_803CBFC(boss);
370-
sub_800CBA4(&gPlayer);
370+
Player_CollisionDamage(&gPlayer);
371371
}
372372
}
373373

@@ -378,18 +378,18 @@ static void sub_803A8E4(EggHammerTankII *boss)
378378
s->x = pos.x - gCamera.x;
379379
s->y = pos.y - gCamera.y;
380380

381-
sub_800CA20(s, pos.x, pos.y, 1, &gPlayer);
381+
Player_EnemyCollision(s, pos.x, pos.y, 1, &gPlayer);
382382
Player_UpdateHomingPosition(QS(pos.x), QS(pos.y));
383383

384384
if (boss->unkB1 == 0 || ((gPlayer.qSpeedAirY > 0 || !(gPlayer.moveState & 2)) && (gPlayer.moveState & 2))) {
385-
if (sub_800C320(s, pos.x, pos.y, 0, &gPlayer) == 1) {
386-
sub_803B6AC(boss);
385+
if (Player_AttackBossCollision(s, pos.x, pos.y, 0, &gPlayer) == 1) {
386+
HandleBossHit(boss);
387387
} else {
388-
sub_800CA20(s, pos.x, pos.y, 0, &gPlayer);
388+
Player_EnemyCollision(s, pos.x, pos.y, 0, &gPlayer);
389389
}
390390

391-
if (boss->unkB1 == 0 && IsColliding_Cheese(s, pos.x, pos.y, 0, &gPlayer) == TRUE) {
392-
sub_803B6AC(boss);
391+
if (boss->unkB1 == 0 && Cheese_IsSpriteColliding(s, pos.x, pos.y, 0, &gPlayer) == TRUE) {
392+
HandleBossHit(boss);
393393
}
394394
}
395395
}
@@ -840,7 +840,7 @@ static void sub_803B62C(EggHammerTankII *boss)
840840
}
841841
}
842842

843-
static void sub_803B6AC(EggHammerTankII *boss)
843+
static void HandleBossHit(EggHammerTankII *boss)
844844
{
845845
Sprite *s;
846846

src/game/bosses/boss_2.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@ static bool8 HandleCannonCollision(EggBomberTank *boss)
782782
if (distance < 600) {
783783
Sprite *s = &gPlayer.spriteInfoBody->s;
784784
if (!PLAYER_IS_ALIVE || s->hitboxes[1].index == -1) {
785-
sub_800CBA4(&gPlayer);
785+
Player_CollisionDamage(&gPlayer);
786786
return 0;
787787
}
788788

@@ -800,7 +800,7 @@ static bool8 HandleCannonCollision(EggBomberTank *boss)
800800
ret = 1;
801801
}
802802

803-
Collision_AdjustPlayerSpeed(&gPlayer);
803+
Player_AdjustSpeedAfterBossCollision(&gPlayer);
804804
boss->cannonHitTimer = 30;
805805
}
806806

@@ -842,8 +842,8 @@ static u8 CheckBossDestruction(EggBomberTank *boss, Player *player)
842842
return 1;
843843
}
844844

845-
sub_800CA20(s, I(boss->qWorldX), I(boss->qWorldY), 1, player);
846-
if (sub_800C320(s, I(boss->qWorldX), I(boss->qWorldY), 0, player) == 1) {
845+
Player_EnemyCollision(s, I(boss->qWorldX), I(boss->qWorldY), 1, player);
846+
if (Player_AttackBossCollision(s, I(boss->qWorldX), I(boss->qWorldY), 0, player) == 1) {
847847
if (boss->cannonHealth != 0) {
848848
Sprite *s = &boss->pilot;
849849
boss->unk73 = ZONE_TIME_TO_INT(0, 0.5);
@@ -853,12 +853,12 @@ static u8 CheckBossDestruction(EggBomberTank *boss, Player *player)
853853
s->variant = 1;
854854
s->prevVariant = -1;
855855
}
856-
sub_800CBA4(player);
856+
Player_CollisionDamage(player);
857857
} else {
858858
ret = HandleBossHit(boss);
859859
}
860860
} else {
861-
if (sub_800CA20(s, I(boss->qWorldX), I(boss->qWorldY), 0, player) == 1) {
861+
if (Player_EnemyCollision(s, I(boss->qWorldX), I(boss->qWorldY), 0, player) == 1) {
862862
Sprite *s = &boss->pilot;
863863
boss->unk73 = ZONE_TIME_TO_INT(0, 0.5);
864864
if (boss->bossHitTimer == 0) {
@@ -867,14 +867,14 @@ static u8 CheckBossDestruction(EggBomberTank *boss, Player *player)
867867
s->variant = 1;
868868
s->prevVariant = -1;
869869
}
870-
sub_800CBA4(player);
870+
Player_CollisionDamage(player);
871871
}
872872
}
873873

874874
Player_UpdateHomingPosition(boss->qWorldX, boss->qWorldY);
875875

876876
if (boss->bossHitTimer == 0) {
877-
if (IsColliding_Cheese(s, I(boss->qWorldX), I(boss->qWorldY), 0, player) == 1 && boss->cannonHealth == 0) {
877+
if (Cheese_IsSpriteColliding(s, I(boss->qWorldX), I(boss->qWorldY), 0, player) == 1 && boss->cannonHealth == 0) {
878878
ret = HandleBossHit(boss);
879879
}
880880
}
@@ -1149,7 +1149,7 @@ static void Task_EggBomberTankBombExplosion(void)
11491149

11501150
if (bomb->boss->health != 0) {
11511151
// If hit player
1152-
if (sub_800CA20(s, I(bomb->x) + gCamera.x, I(bomb->y) + gCamera.y, 0, &gPlayer) == 1) {
1152+
if (Player_EnemyCollision(s, I(bomb->x) + gCamera.x, I(bomb->y) + gCamera.y, 0, &gPlayer) == 1) {
11531153
if (bomb->boss->bossHitTimer == 0) {
11541154
Sprite *s = &bomb->boss->pilot;
11551155
bomb->boss->unk73 = ZONE_TIME_TO_INT(0, 0.5);
@@ -1227,7 +1227,7 @@ static void Task_BombExplosionMain(void)
12271227
s->y = explosion->y;
12281228

12291229
if (explosion->boss->health != 0) {
1230-
if (sub_800CA20(s, explosion->x + gCamera.x, explosion->y + gCamera.y, 0, &gPlayer) == 1) {
1230+
if (Player_EnemyCollision(s, explosion->x + gCamera.x, explosion->y + gCamera.y, 0, &gPlayer) == 1) {
12311231
if (explosion->boss->bossHitTimer == 0) {
12321232
Sprite *s = &explosion->boss->pilot;
12331233
explosion->boss->unk73 = ZONE_TIME_TO_INT(0, 0.5);

src/game/bosses/boss_3.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -543,18 +543,18 @@ void sub_803F5E0(EggTotem *totem)
543543
s->x = worldX - gCamera.x;
544544
s->y = worldY - gCamera.y;
545545

546-
sub_800CA20(s, worldX, worldY, 1, &gPlayer);
546+
Player_EnemyCollision(s, worldX, worldY, 1, &gPlayer);
547547

548-
if (sub_800C320(s, worldX, worldY, 0, &gPlayer) == TRUE) {
548+
if (Player_AttackBossCollision(s, worldX, worldY, 0, &gPlayer) == TRUE) {
549549
sub_8040D74(totem);
550-
} else if (sub_800CA20(s, worldX, worldY, 0, &gPlayer) == TRUE) {
550+
} else if (Player_EnemyCollision(s, worldX, worldY, 0, &gPlayer) == TRUE) {
551551
sub_80412B4(totem);
552552
}
553553

554554
Player_UpdateHomingPosition(totem->qWorldX, totem->qWorldY - BOSS5_HEIGHT);
555555

556556
if (totem->unk35 == 0) {
557-
if (IsColliding_Cheese(s, worldX, worldY, 0, &gPlayer) == TRUE) {
557+
if (Cheese_IsSpriteColliding(s, worldX, worldY, 0, &gPlayer) == TRUE) {
558558
sub_8040D74(totem);
559559
}
560560
}
@@ -1253,8 +1253,8 @@ void sub_8040A00(EggTotem *totem)
12531253
s = &totem->sprPlatform[i].s;
12541254
t3c = &totem->unk3C[i];
12551255

1256-
if (sub_800CA20(s, I(t3c->qWorldX), I(t3c->qWorldY), 1, &gPlayer) == FALSE
1257-
&& sub_800CA20(s, I(t3c->qWorldX), I(t3c->qWorldY), 2, &gPlayer) == FALSE) {
1256+
if (Player_EnemyCollision(s, I(t3c->qWorldX), I(t3c->qWorldY), 1, &gPlayer) == FALSE
1257+
&& Player_EnemyCollision(s, I(t3c->qWorldX), I(t3c->qWorldY), 2, &gPlayer) == FALSE) {
12581258
#ifndef NON_MATCHING
12591259
register Player *p asm("r5");
12601260
#else
@@ -1271,7 +1271,7 @@ void sub_8040A00(EggTotem *totem)
12711271
x = I(t3c->qWorldX);
12721272
y = I(t3c->qWorldY);
12731273
p = &gPlayer;
1274-
coll = sub_800CCB8(s, x, y, p);
1274+
coll = Player_PlatformCollision(s, x, y, p);
12751275

12761276
if ((p->moveState & MOVESTATE_STOOD_ON_OBJ) && (coll & COLL_FLAG_10000)) {
12771277
p->qWorldX += t3c->qUnk8 + Q(5);
@@ -1321,7 +1321,7 @@ bool32 sub_8040B30(EggTotem *totem, u8 i)
13211321
t3CX = I(t3c->qWorldX);
13221322
t3CY = I(t3c->qWorldY) + t3c->unk17;
13231323

1324-
if (sub_800C320(s, t3CX, t3CY, 0, &gPlayer) == TRUE) {
1324+
if (Player_AttackBossCollision(s, t3CX, t3CY, 0, &gPlayer) == TRUE) {
13251325
t3c->unk14 -= 1;
13261326

13271327
#ifndef NON_MATCHING
@@ -1377,7 +1377,7 @@ bool32 sub_8040B30(EggTotem *totem, u8 i)
13771377

13781378
Player_UpdateHomingPosition(Q(t3CX), Q(t3CY));
13791379

1380-
if (IsColliding_Cheese(s, t3CX, t3CY, 0, &gPlayer) == TRUE) {
1380+
if (Cheese_IsSpriteColliding(s, t3CX, t3CY, 0, &gPlayer) == TRUE) {
13811381
t3c->unk14--;
13821382
#ifndef NON_MATCHING
13831383
val = 0xFF;
@@ -1423,7 +1423,7 @@ bool32 sub_8040B30(EggTotem *totem, u8 i)
14231423

14241424
m4aSongNumStart(SE_EXPLOSION);
14251425

1426-
Collision_AdjustPlayerSpeed(&gPlayer);
1426+
Player_AdjustSpeedAfterBossCollision(&gPlayer);
14271427
gCheeseTarget.task->unk15 = 0;
14281428
} else {
14291429
m4aSongNumStart(SE_143);
@@ -1721,7 +1721,7 @@ void Task_EggTotemBullet(void)
17211721
if (bullet->totem->lives != 0) {
17221722
bool32 res;
17231723

1724-
res = sub_800CA20(s, I(bullet->qScreenX) + gCamera.x, I(bullet->qScreenY) + gCamera.y, 0, &gPlayer);
1724+
res = Player_EnemyCollision(s, I(bullet->qScreenX) + gCamera.x, I(bullet->qScreenY) + gCamera.y, 0, &gPlayer);
17251725

17261726
if (res == TRUE && bullet->totem->unk35 == 0) {
17271727
Sprite *s2;

src/game/bosses/boss_4.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include "game/stage/player.h"
1414
#include "game/stage/collision.h"
1515

16-
#include "game/entity.h" // sub_800DF38
16+
#include "game/entity.h" // Player_IsSpriteColliding
1717
#include "game/bosses/common.h"
1818
#include "game/bosses/eggmobile_escape_sequence.h"
1919
#include "game/parameters/bosses.h"
@@ -351,7 +351,7 @@ static void sub_8041A08(AeroEgg *boss)
351351
Player *p = &gPlayer;
352352

353353
if ((p->qSpeedAirY > 0) && (p->moveState & MOVESTATE_IN_AIR)) {
354-
if ((!sub_800DF38(s, worldX, worldY, p)) == COLL_NONE) {
354+
if ((!Player_IsSpriteColliding(s, worldX, worldY, p)) == COLL_NONE) {
355355
s16 v = -Q(4.75);
356356
p->qSpeedAirY = v;
357357
p->moveState &= ~(MOVESTATE_100 | MOVESTATE_STOOD_ON_OBJ);
@@ -398,16 +398,16 @@ static void sub_8041B44(AeroEgg *boss)
398398
s = &boss->sub.sprBody;
399399

400400
if (PLAYER_IS_ALIVE) {
401-
if (sub_800C320(s, worldX, worldY, 0, &gPlayer) == 1) {
401+
if (Player_AttackBossCollision(s, worldX, worldY, 0, &gPlayer) == 1) {
402402
if (I(gPlayer.qWorldY) > worldY) {
403403
sub_8042774(boss);
404-
sub_800CBA4(&gPlayer);
404+
Player_CollisionDamage(&gPlayer);
405405
} else {
406406
sub_80423EC(boss);
407407
}
408408
} else {
409-
sub_800CA20(s, worldX, worldY, 0, &gPlayer);
410-
sub_800CA20(s, worldX, worldY, 1, &gPlayer);
409+
Player_EnemyCollision(s, worldX, worldY, 0, &gPlayer);
410+
Player_EnemyCollision(s, worldX, worldY, 1, &gPlayer);
411411
}
412412
}
413413

@@ -417,7 +417,7 @@ static void sub_8041B44(AeroEgg *boss)
417417
Player_UpdateHomingPosition(Q(worldX), Q(worldY));
418418

419419
if (boss->main.unk16 == 0) {
420-
if (IsColliding_Cheese(s, worldX, worldY, 0, &gPlayer) == TRUE) {
420+
if (Cheese_IsSpriteColliding(s, worldX, worldY, 0, &gPlayer) == TRUE) {
421421
sub_80423EC(boss);
422422
}
423423
}
@@ -940,7 +940,7 @@ static void Task_CreateAeroEggBombMain(void)
940940
}
941941

942942
if (eb->boss->main.lives > 0) {
943-
if (sub_800CA20(s, I(eb->screenX) + gCamera.x, I(eb->screenY) + gCamera.y, 0, &gPlayer) == TRUE) {
943+
if (Player_EnemyCollision(s, I(eb->screenX) + gCamera.x, I(eb->screenY) + gCamera.y, 0, &gPlayer) == TRUE) {
944944
if (eb->boss->main.unk16 == 0) {
945945
Sprite *s2 = &eb->boss->sub.sprPilot;
946946
eb->boss->main.unk15 = 30;
@@ -971,7 +971,7 @@ static void Task_AeroEggBombHitGround(void)
971971
s->y = I(eb->screenY);
972972

973973
if (eb->boss->main.lives > 0) {
974-
if (sub_800CA20(s, I(eb->screenX) + gCamera.x, I(eb->screenY) + gCamera.y, 0, &gPlayer) == TRUE) {
974+
if (Player_EnemyCollision(s, I(eb->screenX) + gCamera.x, I(eb->screenY) + gCamera.y, 0, &gPlayer) == TRUE) {
975975
if (eb->boss->main.unk16 == 0) {
976976
Sprite *s2 = &eb->boss->sub.sprPilot;
977977
eb->boss->main.unk15 = 30;
@@ -1048,7 +1048,7 @@ static void Task_AeroEggBombDebris(void)
10481048
}
10491049

10501050
if (deb->boss->main.lives > 0) {
1051-
if (sub_800CA20(s, I(deb->screenX) + gCamera.x, I(deb->screenY) + gCamera.y, 0, &gPlayer) == TRUE) {
1051+
if (Player_EnemyCollision(s, I(deb->screenX) + gCamera.x, I(deb->screenY) + gCamera.y, 0, &gPlayer) == TRUE) {
10521052
if (deb->boss->main.unk16 == 0) {
10531053
Sprite *s2 = &deb->boss->sub.sprPilot;
10541054
deb->boss->main.unk15 = 30;

0 commit comments

Comments
 (0)