Decompile smallPesto.c

This commit is contained in:
TauNeutrino 2020-10-29 16:39:13 +01:00
parent f1bfe499de
commit fbf7f49146
3 changed files with 84 additions and 184 deletions

View File

@ -1,183 +0,0 @@
.include "asm/macros.inc"
.include "constants/constants.inc"
.syntax unified
.text
thumb_func_start sub_08031714
sub_08031714: @ 0x08031714
push {r4, lr}
adds r4, r0, #0
bl sub_080317B4
ldrb r0, [r4, #0xf]
subs r0, #1
strb r0, [r4, #0xf]
lsls r0, r0, #0x18
cmp r0, #0
bne _0803176E
bl Random
movs r1, #0xf
ands r0, r1
adds r0, #0x10
strb r0, [r4, #0xf]
adds r0, r4, #0
bl sub_08049FA0
cmp r0, #0
bne _08031750
ldrb r1, [r4, #0xf]
movs r0, #1
ands r0, r1
cmp r0, #0
beq _08031750
adds r0, r4, #0
bl sub_08049EE4
b _08031766
_08031750:
ldrb r0, [r4, #0x15]
adds r0, #0x18
strb r0, [r4, #0x15]
bl Random
movs r1, #0xe
ands r0, r1
ldrb r1, [r4, #0x15]
adds r0, r0, r1
movs r1, #0x1f
ands r0, r1
_08031766:
strb r0, [r4, #0x15]
adds r0, r4, #0
bl sub_080317E0
_0803176E:
pop {r4, pc}
thumb_func_start sub_08031770
sub_08031770: @ 0x08031770
push {r4, lr}
adds r1, r0, #0
adds r4, r1, #0
adds r4, #0x80
ldrh r0, [r4]
cmp r0, #0
beq _08031790
subs r0, #1
strh r0, [r4]
lsls r0, r0, #0x10
cmp r0, #0
bne _080317B2
adds r0, r1, #0
bl sub_08031840
b _080317B2
_08031790:
ldr r0, [r1, #0x54]
cmp r0, #0
bne _080317AA
bl Random
movs r1, #0x7f
ands r0, r1
movs r2, #0x80
lsls r2, r2, #2
adds r1, r2, #0
orrs r0, r1
strh r0, [r4]
b _080317B2
_080317AA:
ldr r0, [r0, #4]
cmp r0, #0
bne _080317B2
str r0, [r1, #0x54]
_080317B2:
pop {r4, pc}
thumb_func_start sub_080317B4
sub_080317B4: @ 0x080317B4
push {r4, lr}
adds r4, r0, #0
bl Random
movs r1, #0x30
ands r1, r0
movs r2, #0xd
rsbs r2, r2, #0
adds r0, r2, #0
cmp r1, #0
beq _080317D0
movs r1, #0xc
rsbs r1, r1, #0
adds r0, r1, #0
_080317D0:
strh r0, [r4, #0x36]
adds r0, r4, #0
bl sub_0806F69C
adds r0, r4, #0
bl GetNextFrame
pop {r4, pc}
thumb_func_start sub_080317E0
sub_080317E0: @ 0x080317E0
push {lr}
ldrb r1, [r0, #0x15]
adds r1, #2
movs r2, #0x1c
ands r1, r2
lsrs r1, r1, #2
strb r1, [r0, #0x14]
ldrb r1, [r0, #0x14]
bl InitializeAnimation
pop {pc}
.align 2, 0
thumb_func_start sub_080317F8
sub_080317F8: @ 0x080317F8
push {r4, r5, r6, lr}
adds r4, r0, #0
bl Random
movs r1, #0x18
ands r0, r1
movs r5, #1
strb r5, [r4, #0xc]
movs r6, #0
ldr r1, _08031838 @ =0x0000FFF4
strh r1, [r4, #0x36]
adds r1, r4, #0
adds r1, #0x38
strb r5, [r1]
adds r3, r4, #0
adds r3, #0x3c
ldrb r2, [r3]
movs r1, #0x10
orrs r1, r2
strb r1, [r3]
strb r5, [r4, #0x1c]
strb r0, [r4, #0x15]
ldr r0, _0803183C @ =gUnk_080CE560
str r0, [r4, #0x48]
adds r0, r4, #0
bl sub_080317E0
strb r6, [r4, #0xe]
movs r0, #0x20
strb r0, [r4, #0xf]
pop {r4, r5, r6, pc}
.align 2, 0
_08031838: .4byte 0x0000FFF4
_0803183C: .4byte gUnk_080CE560
thumb_func_start sub_08031840
sub_08031840: @ 0x08031840
push {r4, r5, lr}
adds r5, r0, #0
ldrb r1, [r5, #0xa]
movs r0, #0x2d
bl CreateEnemy
adds r4, r0, #0
cmp r4, #0
beq _08031862
adds r0, r5, #0
adds r1, r4, #0
bl CopyPosition
str r5, [r4, #0x50]
str r4, [r5, #0x54]
movs r0, #1
strb r0, [r4, #0xb]
_08031862:
pop {r4, r5, pc}

View File

@ -304,6 +304,7 @@ SECTIONS {
src/code_08018C58.o(.text);
src/item11.o(.text);
asm/item11.o(.text);
src/createBowEntity.o(.text);
asm/createBowEntity.o(.text);
asm/bowUse.o(.text);
asm/sub_08019410.o(.text);
@ -373,7 +374,6 @@ SECTIONS {
asm/eyegore.o(.text);
asm/rope.o(.text);
src/enemy/smallPesto.o(.text);
asm/smallPesto.o(.text);
src/enemy/acroBandits.o(.text);
src/enemy/bladeTrap.o(.text);
src/enemy/keaton.o(.text);

View File

@ -8,11 +8,22 @@ extern u32 sub_0806F3E4();
extern void sub_0804A7D4(Entity*);
extern void sub_0804A720(Entity*);
extern void sub_080317F8(Entity*);
extern u32 sub_08049FA0(Entity*);
extern u32 Random();
extern u32 sub_08049EE4(Entity*);
extern void sub_0806F69C(Entity*);
extern void (*gUnk_080CE530[])(Entity*);
extern void (*gUnk_080CE548[])(Entity*);
extern void (*gUnk_080CE554[])(Entity*);
void sub_080317B4(Entity*);
void sub_080317E0(Entity*);
void sub_080317F8(Entity*);
void sub_08031840(Entity*);
extern BoundingBox gUnk_080CE560;
void SmallPesto(Entity *this)
{
gUnk_080CE530[GetNextFunction(this)](this);
@ -66,3 +77,75 @@ void sub_08031704(Entity *this)
sub_0804A720(this);
sub_080317F8(this);
}
void sub_08031714(Entity* entity){
u8 newDirection;
sub_080317B4(entity);
if(--entity->field_0xf == 0){
entity->field_0xf = (Random() & 0xf) + 0x10;
if(sub_08049FA0(entity) == 0){
if((entity->field_0xf & 1) != 0){
entity->direction = sub_08049EE4(entity);
goto _08031766;
}
}
entity->direction += 0x18;
entity->direction = ((Random() & 0xe) + entity->direction) & 0x1f;
_08031766:
sub_080317E0(entity);
}
}
void sub_08031770(Entity* entity){
if(entity->field_0x80.HWORD != 0){
if(--entity->field_0x80.HWORD == 0){
sub_08031840(entity);
}
}else if(entity->attachedEntity == NULL){
entity->field_0x80.HWORD = (Random() & 0x7f) | (0x80 << 2);
}else{
if(entity->attachedEntity->next == NULL){
entity->attachedEntity = NULL;
}
}
return;
}
void sub_080317B4(Entity* entity){
entity->height.HALF.HI = ((Random() & 0x30) != 0) ? -0xc : -0xd;
sub_0806F69C(entity);
GetNextFrame(entity);
}
void sub_080317E0(Entity *entity){
entity->animationState = ((u8)(entity->direction + 2) & 0x1c) >> 2;
InitializeAnimation(entity, entity->animationState);
}
void sub_080317F8(Entity *entity){
u8 newDirection = Random() & 0x18;
entity->action = 1;
entity->height.HALF.HI = 0x0000FFF4;
entity->collisionLayer = 1;
entity->field_0x3c |= 0x10;
entity->field_0x1c = 1;
entity->direction = newDirection;
entity->boundingBox = &gUnk_080CE560;
sub_080317E0(entity);
entity->actionDelay = 0;
entity->field_0xf = 0x20;
}
void sub_08031840(Entity* entity){
Entity *enemy = CreateEnemy(0x2d, entity->entityType.form);
if(enemy!= NULL){
CopyPosition(entity, enemy);
enemy->parent = entity;
entity->attachedEntity = enemy;
enemy->entityType.parameter = 1;
}
}