Decompile EnemyItem

This commit is contained in:
octorock 2022-02-26 19:58:11 +01:00
parent f252083539
commit 7a596ed3a2
5 changed files with 86 additions and 159 deletions

View File

@ -1,156 +0,0 @@
.include "asm/macros.inc"
.include "constants/constants.inc"
.syntax unified
.text
thumb_func_start EnemyItem
EnemyItem: @ 0x080A2448
push {r4, r5, lr}
adds r5, r0, #0
adds r0, #0x86
ldrh r0, [r0]
bl CheckFlags
cmp r0, #0
beq _080A245E
adds r0, r5, #0
bl sub_080A2500
_080A245E:
ldrb r0, [r5, #0xc]
adds r1, r0, #0
cmp r1, #0
bne _080A24CE
adds r0, #1
strb r0, [r5, #0xc]
ldrb r0, [r5, #0xe]
strb r0, [r5, #0xa]
str r1, [r5, #0x54]
ldr r2, _080A24B4 @ =gEntityLists + 32
ldr r4, [r2, #4]
cmp r4, r2
beq _080A24BE
_080A2478:
ldrb r0, [r4, #8]
cmp r0, #3
bne _080A24B8
ldrb r0, [r5, #0xb]
ldrb r1, [r4, #9]
cmp r0, r1
bne _080A24B8
movs r3, #0x2e
ldrsh r0, [r4, r3]
movs r3, #0x2e
ldrsh r1, [r5, r3]
subs r0, r0, r1
adds r0, #0x10
lsls r0, r0, #0x10
lsrs r0, r0, #0x10
cmp r0, #0x1f
bhi _080A24B8
movs r1, #0x32
ldrsh r0, [r4, r1]
movs r3, #0x32
ldrsh r1, [r5, r3]
subs r0, r0, r1
adds r0, #0x10
lsls r0, r0, #0x10
lsrs r0, r0, #0x10
cmp r0, #0x1f
bhi _080A24B8
str r4, [r5, #0x54]
b _080A24BE
.align 2, 0
_080A24B4: .4byte gEntityLists + 32
_080A24B8:
ldr r4, [r4, #4]
cmp r4, r2
bne _080A2478
_080A24BE:
ldr r0, [r5, #0x54]
cmp r0, #0
bne _080A24CA
adds r0, r5, #0
bl sub_080A2534
_080A24CA:
bl sub_08054564
_080A24CE:
ldr r4, [r5, #0x54]
cmp r4, #0
beq _080A24F6
movs r2, #0x80
lsls r2, r2, #0xb
movs r3, #0x80
lsls r3, r3, #9
adds r0, r4, #0
adds r1, r5, #0
bl PositionRelative
ldrh r0, [r5, #0x36]
subs r0, #4
strh r0, [r5, #0x36]
ldr r0, [r4, #4]
cmp r0, #0
bne _080A24F6
adds r0, r5, #0
bl sub_080A2508
_080A24F6:
adds r0, r5, #0
bl sub_08080CB4
pop {r4, r5, pc}
.align 2, 0
thumb_func_start sub_080A2500
sub_080A2500: @ 0x080A2500
push {lr}
bl DeleteThisEntity
pop {pc}
thumb_func_start sub_080A2508
sub_080A2508: @ 0x080A2508
push {r4, lr}
adds r4, r0, #0
ldrb r2, [r4, #0xa]
movs r1, #0
movs r3, #0
bl CreateObjectWithParent
adds r2, r0, #0
cmp r2, #0
beq _080A252C
movs r0, #5
strb r0, [r2, #0xe]
adds r0, r4, #0
adds r0, #0x86
ldrh r1, [r0]
adds r0, r2, #0
adds r0, #0x86
strh r1, [r0]
_080A252C:
adds r0, r4, #0
bl sub_080A2500
pop {r4, pc}
thumb_func_start sub_080A2534
sub_080A2534: @ 0x080A2534
push {r4, lr}
adds r4, r0, #0
ldrb r2, [r4, #0xa]
movs r1, #0
movs r3, #0
bl CreateObjectWithParent
adds r2, r0, #0
cmp r2, #0
beq _080A2558
movs r0, #4
strb r0, [r2, #0xe]
adds r0, r4, #0
adds r0, #0x86
ldrh r1, [r0]
adds r0, r2, #0
adds r0, #0x86
strh r1, [r0]
_080A2558:
adds r0, r4, #0
bl sub_080A2500
pop {r4, pc}

View File

@ -418,7 +418,7 @@ void LitArea(Entity*);
void ObjectBD(Entity*);
void Pinwheel(Entity*);
void ObjectBF(Entity*);
void EnemyItem(Entity*);
void EnemyItem();
void ObjectC1(Entity*);
extern void (*const gObjectFunctions[194])(Entity*);

View File

@ -839,7 +839,7 @@ SECTIONS {
asm/object/objectBD.o(.text);
src/object/pinwheel.o(.text);
asm/object/objectBF.o(.text);
asm/object/enemyItem.o(.text);
src/object/enemyItem.o(.text);
asm/object/objectC1.o(.text);
/* END objects */
src/objectUtils.o(.text);

View File

@ -297,7 +297,7 @@ bool32 sub_0803EF20(Enemy4DEntity* this) {
sub_0803EF70, sub_0803EFAC, sub_0803EFAC, sub_0803EFAC, sub_0803EF70, sub_0803EF70, sub_0803EFAC,
};
Entity* it;
LinkedList* list = ((LinkedList*)&gEntityLists + 2);
LinkedList* list = &gEntityLists[2];
for (it = list->first; it != (Entity*)list; it = it->next) {
if ((it->kind == 8) && gUnk_080D08C8[it->id](super, it)) {

83
src/object/enemyItem.c Normal file
View File

@ -0,0 +1,83 @@
/**
* @file enemyItem.c
* @ingroup Objects
*
* @brief Enemy Item object
*/
#define NENT_DEPRECATED
#include "global.h"
#include "object.h"
#include "functions.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unk_68[0x1e];
/*0x86*/ u16 unk_86;
} EnemyItemEntity;
void sub_080A2500(EnemyItemEntity*);
void sub_080A2534(EnemyItemEntity*);
void sub_080A2508(EnemyItemEntity*);
void EnemyItem(EnemyItemEntity* this) {
Entity* entity;
LinkedList* list;
if (CheckFlags(this->unk_86)) {
sub_080A2500(this);
}
if (super->action == 0) {
super->action++;
super->type = super->actionDelay;
super->child = NULL;
list = &gEntityLists[4];
for (entity = list->first; entity != (Entity*)list; entity = entity->next) {
if ((((entity->kind == 3) && (super->type2 == entity->id)) &&
(((entity->x.HALF.HI - super->x.HALF.HI) + 0x10U) << 0x10 >> 0x10 < 0x20)) &&
(((entity->y.HALF.HI - super->y.HALF.HI) + 0x10U) << 0x10 >> 0x10 < 0x20)) {
super->child = entity;
break;
}
}
if (super->child == NULL) {
sub_080A2534(this);
}
sub_08054564();
}
entity = super->child;
if (entity != NULL) {
PositionRelative(entity, super, 0x40000, 0x10000);
super->z.HALF.HI -= 4;
if (entity->next == NULL) {
sub_080A2508(this);
}
}
sub_08080CB4(super);
}
void sub_080A2500(EnemyItemEntity* this) {
DeleteThisEntity();
}
void sub_080A2508(EnemyItemEntity* this) {
EnemyItemEntity* entity;
entity = (EnemyItemEntity*)CreateObjectWithParent(super, GROUND_ITEM, super->type, 0);
if (entity != NULL) {
(entity->base).actionDelay = 5;
entity->unk_86 = this->unk_86;
}
sub_080A2500(this);
}
void sub_080A2534(EnemyItemEntity* this) {
EnemyItemEntity* entity;
entity = (EnemyItemEntity*)CreateObjectWithParent(super, GROUND_ITEM, super->type, 0);
if (entity != NULL) {
(entity->base).actionDelay = 4;
entity->unk_86 = this->unk_86;
}
sub_080A2500(this);
}