Skip to content
Open
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
4 changes: 2 additions & 2 deletions asm/src/code_08001A7C.s
Original file line number Diff line number Diff line change
Expand Up @@ -862,12 +862,12 @@ _080026A0: .4byte gUnk_08002342

gUnk_080026A4::
@ normal entities
.4byte gUnk_020000B0 @ enemy target? (player)
.4byte gEnemyTarget @ enemy target? (player)
.4byte gEntityLists - 8 @ first linked list
.4byte gEntityLists + 64 @ last linked list
.4byte ram_sub_080B2248 @ entity table
@ managers
.4byte gUnk_020000B0
.4byte gEnemyTarget
.4byte gEntityLists + 56
.4byte gCollidableCount
.4byte ram_sub_080B2248
Expand Down
2 changes: 1 addition & 1 deletion assets/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -3931,7 +3931,7 @@
"type": "animation"
},
{
"path": "peahat/gUnk_080CA5D4.bin",
"path": "peahat/gPeahatChargeDirectionOffsets.bin",
"start": 828884,
"size": 2
},
Expand Down
4 changes: 2 additions & 2 deletions data/animations/enemy/peahat.s
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
.section .rodata
.align 2

gUnk_080CA5D4:: @ 080CA5D4
.incbin "peahat/gUnk_080CA5D4.bin"
gPeahatChargeDirectionOffsets:: @ 080CA5D4
.incbin "peahat/gPeahatChargeDirectionOffsets.bin"

gSpriteAnimations_Peahat_0:: @ 080CA5D6
.include "animations/gSpriteAnimations_Peahat_0.s"
Expand Down
6 changes: 6 additions & 0 deletions include/enemy.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,4 +288,10 @@ void Enemy66();

extern void (*const gUnk_080012C8[])(Entity*);

/**
* The Entity targeted by enemies.
* This is usually the player.
*/
extern Entity* gEnemyTarget;

#endif // ENEMY_H
2 changes: 1 addition & 1 deletion linker.ld
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ SECTIONS {
. = 0x00000080; gIntroState = .;
. = 0x00000080; gChooseFileState = .;
. = 0x00000090; gUnk_02000090 = .;
. = 0x000000B0; gUnk_020000B0 = .;
. = 0x000000B0; gEnemyTarget = .;
. = 0x000000C0; gUnk_020000C0 = .;
. = 0x00000CC0; gBgAnimations = .;
. = 0x00000D00; gTextGfxBuffer = .;
Expand Down
13 changes: 6 additions & 7 deletions src/code_08049DF4.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@
#include "room.h"
#include "enemy.h"

extern Entity* gUnk_020000B0;
extern Entity* (*const gUnk_080D3BE8[])(void);

Entity* sub_08049DF4(u32 arg0) {
if (gUnk_020000B0 != NULL) {
return gUnk_020000B0;
if (gEnemyTarget != NULL) {
return gEnemyTarget;
}
return gUnk_080D3BE8[arg0]();
}
Expand All @@ -22,7 +21,7 @@ Entity* sub_08049E18(void) {
!(gPlayerState.flags &
(PL_BUSY | PL_DROWNING | PL_CAPTURED | PL_USE_PORTAL | PL_HIDDEN | PL_DISABLE_ITEMS | PL_FALLING | PL_FROZEN |
PL_IN_MINECART | PL_PIT_IS_EXIT | PL_MOLDWORM_CAPTURED | PL_IN_HOLE | PL_CONVEYOR_PUSHED | PL_CLIMBING))) {
gUnk_020000B0 = &gPlayerEntity.base;
gEnemyTarget = &gPlayerEntity.base;
return &gPlayerEntity.base;
}
return NULL;
Expand All @@ -33,7 +32,7 @@ Entity* sub_08049E4C(void) {
!(gPlayerState.flags & (PL_BUSY | PL_DROWNING | PL_CAPTURED | PL_USE_PORTAL | PL_HIDDEN | PL_MINISH |
PL_DISABLE_ITEMS | PL_FALLING | PL_FROZEN | PL_IN_MINECART | PL_PIT_IS_EXIT |
PL_MOLDWORM_CAPTURED | PL_IN_HOLE | PL_CONVEYOR_PUSHED | PL_CLIMBING))) {
gUnk_020000B0 = &gPlayerEntity.base;
gEnemyTarget = &gPlayerEntity.base;
return &gPlayerEntity.base;
}
return NULL;
Expand All @@ -43,14 +42,14 @@ Entity* sub_08049E80(void) {
if ((gPlayerState.killed != 0) || !(gPlayerState.flags & PL_MINISH)) {
return NULL;
}
gUnk_020000B0 = &gPlayerEntity.base;
gEnemyTarget = &gPlayerEntity.base;
return &gPlayerEntity.base;
}

Entity* sub_08049EB0(void) {
if ((gPlayerState.killed == 0) &&
!(gPlayerState.flags & (PL_MOLDWORM_CAPTURED | PL_DISABLE_ITEMS | PL_MINISH | PL_CAPTURED))) {
gUnk_020000B0 = &gPlayerEntity.base;
gEnemyTarget = &gPlayerEntity.base;
return &gPlayerEntity.base;
}
return NULL;
Expand Down
6 changes: 2 additions & 4 deletions src/enemy/acroBandits.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ typedef struct {
/*0x7c*/ Entity* unk_7c;
} AcroBanditEntity;

extern Entity* gUnk_020000B0;

static void sub_08031E48(AcroBanditEntity* this, AcroBanditEntity* child);
static void sub_08032290(AcroBanditEntity* this);
static bool32 sub_080322A4(AcroBanditEntity* this);
Expand Down Expand Up @@ -224,7 +222,7 @@ void AcroBandit_Type0Action2(AcroBanditEntity* this) {
void AcroBandit_Type0Action3(AcroBanditEntity* this) {
if (sub_08031E04(this)) {
super->action = 5;
if (super->x.HALF.HI > gUnk_020000B0->x.HALF.HI) {
if (super->x.HALF.HI > gEnemyTarget->x.HALF.HI) {
super->spriteSettings.flipX = 0;
} else {
super->spriteSettings.flipX = 1;
Expand Down Expand Up @@ -447,7 +445,7 @@ void AcroBandit_Type1Action4(AcroBanditEntity* this) {
if (parent == NULL) {
if (sub_08049FDC(super, 1)) {
if ((++this->unk_79 & 7) == 0) {
sub_08004596(super, GetFacingDirection(super, gUnk_020000B0));
sub_08004596(super, GetFacingDirection(super, gEnemyTarget));
}
this->unk_76.HALF.LO = 0;
} else {
Expand Down
8 changes: 3 additions & 5 deletions src/enemy/armos.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ typedef struct {
/*0x84*/ u32 unk_84;
} ArmosEntity;

extern Entity* gUnk_020000B0;

extern void (*const gUnk_080CE124[])(ArmosEntity*);
extern void (*const gUnk_080CE13C[])(ArmosEntity*);
extern const u8 gUnk_080CE160[];
Expand Down Expand Up @@ -343,15 +341,15 @@ bool32 sub_08030650(ArmosEntity* this) {
return 1;
}
} else if (this->unk_80 != 2) {
if (!sub_08049FDC(super, 1) || (0x20 < (gUnk_020000B0->x.HALF.HI - super->x.HALF.HI) + 0x10U)) {
if (!sub_08049FDC(super, 1) || (0x20 < (gEnemyTarget->x.HALF.HI - super->x.HALF.HI) + 0x10U)) {
return FALSE;
}
return TRUE;
} else {
if (!sub_08049FDC(super, 1)) {
return FALSE;
}
if (gUnk_020000B0->x.HALF.HI >= (s32)(gRoomControls.origin_x + 0xa8)) {
if (gEnemyTarget->x.HALF.HI >= (s32)(gRoomControls.origin_x + 0xa8)) {
return FALSE;
}
return TRUE;
Expand All @@ -367,7 +365,7 @@ void sub_080306C4(ArmosEntity* this) {
if (sub_08049FDC(super, 1) && this->unk_7a != 0) {

super->timer = 24;
uVar3 = sub_0800132C(super, gUnk_020000B0);
uVar3 = sub_0800132C(super, gEnemyTarget);
if (uVar3 != 0xff) {
var = 0;
if ((((Random() & 7) != 0) || (super->animationState == 0xff)) && ((this->unk_82 & 3) != 3)) {
Expand Down
12 changes: 5 additions & 7 deletions src/enemy/ballChainSoldier.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ typedef struct {
u8 unk_7f;
} BallChainSoldierEntity;

extern Entity* gUnk_020000B0;

void (*const BallChainSoldier_Functions[])(BallChainSoldierEntity*);
void (*const gUnk_080D06F8[])(BallChainSoldierEntity*);
const u8 gUnk_080D0724[];
Expand Down Expand Up @@ -210,7 +208,7 @@ void sub_0803E818(BallChainSoldierEntity* this) {

void sub_0803E86C(BallChainSoldierEntity* this) {
if (sub_08049FDC(super, 1) && sub_0803EAD0(this, 0x50)) {
super->direction = DirectionRoundUp(GetFacingDirection(super, gUnk_020000B0));
super->direction = DirectionRoundUp(GetFacingDirection(super, gEnemyTarget));
}

super->action = 1;
Expand Down Expand Up @@ -276,12 +274,12 @@ bool32 sub_0803E9D4(BallChainSoldierEntity* this) {
if (sub_08049FDC(super, 1)) {
if (sub_0803EAD0(this, 0x38)) {
super->action = 3;
super->direction = DirectionRoundUp(GetFacingDirection(super, gUnk_020000B0));
super->direction = DirectionRoundUp(GetFacingDirection(super, gEnemyTarget));
this->unk_7b = 1;
sub_0803E94C(this, 0);
return 1;
} else if (sub_0803EAD0(this, 0x4e)) {
dir = sub_0804A044(super, gUnk_020000B0, 0x12);
dir = sub_0804A044(super, gEnemyTarget, 0x12);
if (dir != 0xff) {
if (--this->unk_7a != 0)
return 0;
Expand All @@ -302,7 +300,7 @@ bool32 sub_0803EA64(BallChainSoldierEntity* this) {
u32 dir;
if (sub_08049FDC(super, 1)) {
if (sub_0803EAD0(this, 0x4e)) {
dir = sub_0804A044(super, gUnk_020000B0, 0x12);
dir = sub_0804A044(super, gEnemyTarget, 0x12);
if (dir != 0xff) {
if (--this->unk_7a != 0)
return 1;
Expand All @@ -322,7 +320,7 @@ bool32 sub_0803EA64(BallChainSoldierEntity* this) {
}

bool32 sub_0803EAD0(BallChainSoldierEntity* this, u32 distance) {
return EntityWithinDistance(super, gUnk_020000B0->x.HALF.HI, gUnk_020000B0->y.HALF.HI - 4, distance);
return EntityWithinDistance(super, gEnemyTarget->x.HALF.HI, gEnemyTarget->y.HALF.HI - 4, distance);
}

void (*const BallChainSoldier_Functions[])(BallChainSoldierEntity*) = {
Expand Down
6 changes: 2 additions & 4 deletions src/enemy/chuchu.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ typedef struct {
/*0x83*/ u8 unk_83;
} ChuchuEntity;

extern Entity* gUnk_020000B0;

void sub_0801F328(ChuchuEntity* this);
void sub_0801F340(ChuchuEntity* this);
void sub_0801F360(ChuchuEntity* this);
Expand Down Expand Up @@ -579,12 +577,12 @@ void sub_0801F8C0(ChuchuEntity* this) {
sub_0801F730(this);
} else {
u8 tmp = ++super->timer & 7;
if (tmp == 0 && sub_08049F1C(super, gUnk_020000B0, 0x38)) {
if (tmp == 0 && sub_08049F1C(super, gEnemyTarget, 0x38)) {
super->action = 5;
Chuchu_JumpAtPlayer(this);
} else {
if (tmp == 4) {
super->direction = GetFacingDirection(super, gUnk_020000B0);
super->direction = GetFacingDirection(super, gEnemyTarget);
}
ProcessMovement0(super);
GetNextFrame(super);
Expand Down
5 changes: 2 additions & 3 deletions src/enemy/crow.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ typedef struct {
void (*const Crow_Functions[])(Entity*);
void (*const gUnk_080CE990[])(CrowEntity*);
void (*const gUnk_080CE9A4[])(CrowEntity*);
extern Entity* gUnk_020000B0;

void sub_08032AF4(CrowEntity* this);
void sub_08032AB0(CrowEntity* this);
Expand Down Expand Up @@ -123,9 +122,9 @@ void sub_0803298C(CrowEntity* this) {

if (sub_08049DF4(1) == NULL)
return;
if (EntityInRectRadius(super, gUnk_020000B0, 0x88, 0x50) == 0)
if (EntityInRectRadius(super, gEnemyTarget, 0x88, 0x50) == 0)
return;
if (gUnk_020000B0->y.HALF.HI <= super->y.HALF.HI + 8)
if (gEnemyTarget->y.HALF.HI <= super->y.HALF.HI + 8)
return;

super->action = 2;
Expand Down
34 changes: 16 additions & 18 deletions src/enemy/darkNut.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ void sub_08021644(DarkNutEntity*);
u32 sub_08021664(DarkNutEntity*, Entity*);
u32 sub_0802169C(DarkNutEntity*, Entity*);

extern Entity* gUnk_020000B0;

extern void (*const DarkNut_Functions[])(DarkNutEntity*);
extern void (*const gUnk_080CAAB0[])(DarkNutEntity*);

Expand Down Expand Up @@ -197,11 +195,11 @@ void sub_08020E78(DarkNutEntity* this) {

void sub_08020E98(DarkNutEntity* this) {
if (PlayerInRange(super, 1, 56)) {
if (sub_0802169C(this, gUnk_020000B0)) {
if (sub_0802169C(this, gEnemyTarget)) {
super->action = 8;
sub_08021218(this, 7, super->animationState);
} else {
super->direction = GetFacingDirection(gUnk_020000B0, super);
super->direction = GetFacingDirection(gEnemyTarget, super);
if (ProcessMovement0(super) == 0) {
super->action = 8;
sub_08021218(this, 7, super->animationState);
Expand All @@ -212,10 +210,10 @@ void sub_08020E98(DarkNutEntity* this) {
}
}
} else {
if (gUnk_020000B0 == NULL) {
if (gEnemyTarget == NULL) {
sub_08021414(this);
} else {
super->direction = GetFacingDirection(super, gUnk_020000B0);
super->direction = GetFacingDirection(super, gEnemyTarget);
ProcessMovement0(super);
sub_0802124C(this);
sub_08021644(this);
Expand All @@ -231,8 +229,8 @@ void sub_08020F28(DarkNutEntity* this) {

void sub_08020F48(DarkNutEntity* this) {
if (PlayerInRange(super, 1, 0x48)) {
if (sub_08021664(this, gUnk_020000B0)) {
u32 uVar2 = sub_0804A044(super, gUnk_020000B0, 9);
if (sub_08021664(this, gEnemyTarget)) {
u32 uVar2 = sub_0804A044(super, gEnemyTarget, 9);
if (uVar2 == 0xff) {
sub_08021424(this);
} else {
Expand Down Expand Up @@ -510,7 +508,7 @@ void sub_08021424(DarkNutEntity* this) {
s32 x, y;
u32 tmp;

u32 dir = GetFacingDirection(super, gUnk_020000B0);
u32 dir = GetFacingDirection(super, gEnemyTarget);
tmp = sub_08021274(super->animationState, dir);
if (tmp != 0xff) {
sub_08021218(this, this->unk_74, tmp);
Expand All @@ -520,20 +518,20 @@ void sub_08021424(DarkNutEntity* this) {

switch (tmp) {
case 0:
x = gUnk_020000B0->x.HALF.HI;
y = gUnk_020000B0->y.HALF.HI + 0x2c;
x = gEnemyTarget->x.HALF.HI;
y = gEnemyTarget->y.HALF.HI + 0x2c;
break;
case 1:
x = gUnk_020000B0->x.HALF.HI - 0x24;
y = gUnk_020000B0->y.HALF.HI;
x = gEnemyTarget->x.HALF.HI - 0x24;
y = gEnemyTarget->y.HALF.HI;
break;
case 2:
x = gUnk_020000B0->x.HALF.HI;
y = gUnk_020000B0->y.HALF.HI - 0x1d;
x = gEnemyTarget->x.HALF.HI;
y = gEnemyTarget->y.HALF.HI - 0x1d;
break;
default:
x = gUnk_020000B0->x.HALF.HI + 0x24;
y = gUnk_020000B0->y.HALF.HI;
x = gEnemyTarget->x.HALF.HI + 0x24;
y = gEnemyTarget->y.HALF.HI;
break;
}

Expand All @@ -555,7 +553,7 @@ u32 sub_080214FC(DarkNutEntity* this) {
if (!sub_08049FDC(super, 1))
return 0;

direction = GetFacingDirection(super, gUnk_020000B0);
direction = GetFacingDirection(super, gEnemyTarget);
if (4 < (direction - (super->frame & 0x1f)) - 2)
return 0;

Expand Down
8 changes: 3 additions & 5 deletions src/enemy/enemy4D.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ typedef struct {
extern void sub_0803E9A4(Entity*); // ballChainSoldier
extern void sub_0803E94C(Entity*, u32); // ballChainSoldier

extern Entity* gUnk_020000B0;

void sub_0803EE8C(Enemy4DEntity*);
bool32 sub_0803EF20(Enemy4DEntity*);
bool32 sub_0803EEA4(Enemy4DEntity*);
Expand Down Expand Up @@ -120,7 +118,7 @@ void Enemy4D_Init(Enemy4DEntity* this) {
void Enemy4D_Action1(Enemy4DEntity* this) {
this->unk_7c -= 0xa;
if (sub_08049DF4(1)) {
super->direction = DirectionRoundUp(GetFacingDirection(super, gUnk_020000B0));
super->direction = DirectionRoundUp(GetFacingDirection(super, gEnemyTarget));
sub_0803E94C(super, 0);
}
sub_0803E9A4(super);
Expand Down Expand Up @@ -268,7 +266,7 @@ bool32 sub_0803EEA4(Enemy4DEntity* this) {
s32 tmp;
if (sub_08049FDC(super, 1)) {
if (sub_0803EF04(this, 0x4e) != 0) {
tmp = sub_0804A044(super, gUnk_020000B0, 0x12);
tmp = sub_0804A044(super, gEnemyTarget, 0x12);
if (tmp != 0xff) {
if (--this->unk_7a == 0) {
super->action = 5;
Expand All @@ -285,7 +283,7 @@ bool32 sub_0803EEA4(Enemy4DEntity* this) {
}

bool32 sub_0803EF04(Enemy4DEntity* this, u32 distance) {
return EntityWithinDistance(super, gUnk_020000B0->x.HALF.HI, gUnk_020000B0->y.HALF.HI - 4, distance);
return EntityWithinDistance(super, gEnemyTarget->x.HALF.HI, gEnemyTarget->y.HALF.HI - 4, distance);
}

bool32 sub_0803EF20(Enemy4DEntity* this) {
Expand Down
Loading
Loading