Decompile playerItemGustJar asm funcs

This commit is contained in:
Tal Hayon 2022-03-02 22:29:15 +02:00
parent 4e10e89cca
commit 1cdfd41e01
7 changed files with 118 additions and 258 deletions

View File

@ -1,165 +0,0 @@
.syntax unified
push {r4, r5, lr}
adds r4, r0, #0
ldr r3, _080ADAF4 @ =gPlayerState
ldrb r1, [r3, #0x1c]
adds r0, r1, #0
cmp r0, #3
bne _080ADAFC
ldrb r0, [r4, #0xc]
adds r0, #1
strb r0, [r4, #0xc]
ldr r0, _080ADAF8 @ =gPlayerEntity
ldrb r1, [r0, #0x14]
lsrs r1, r1, #1
adds r1, #8
b _080ADB0C
.align 2, 0
_080ADAF4: .4byte gPlayerState
_080ADAF8: .4byte gPlayerEntity
_080ADAFC:
cmp r0, #6
bne _080ADB18
movs r0, #4
strb r0, [r4, #0xc]
ldr r0, _080ADB14 @ =gPlayerEntity
ldrb r1, [r0, #0x14]
lsrs r1, r1, #1
adds r1, #4
_080ADB0C:
adds r0, r4, #0
bl InitAnimationForceUpdate
b _080ADC08
.align 2, 0
_080ADB14: .4byte gPlayerEntity
_080ADB18:
movs r5, #0
ldrb r0, [r4, #0xa]
cmp r0, #0
beq _080ADB58
cmp r0, #1
bne _080ADB36
adds r0, r4, #0
movs r1, #4
bl sub_080ADCA0
movs r0, #0x18
strb r0, [r4, #0xe]
movs r0, #2
strb r0, [r4, #0xa]
b _080ADBE0
_080ADB36:
adds r0, r4, #0
movs r1, #1
bl sub_080ADCDC
ldrb r0, [r4, #0xe]
subs r0, #1
strb r0, [r4, #0xe]
lsls r0, r0, #0x18
lsrs r0, r0, #0x18
cmp r0, #0xff
bne _080ADBE0
adds r0, r4, #0
movs r1, #0
bl sub_080ADCA0
strb r5, [r4, #0xa]
b _080ADBE0
_080ADB58:
movs r0, #0xf
ands r0, r1
cmp r0, #7
bne _080ADB68
adds r1, r4, #0
adds r1, #0x59
movs r0, #0x7f
strb r0, [r1]
_080ADB68:
ldrb r0, [r3, #0x1d]
cmp r0, #2
beq _080ADB94
cmp r0, #2
bgt _080ADB78
cmp r0, #1
beq _080ADBB0
b _080ADBCA
_080ADB78:
cmp r0, #3
bne _080ADBCA
adds r0, r4, #0
movs r1, #3
bl sub_080ADCDC
ldrb r1, [r4, #0x1a]
movs r0, #0x10
rsbs r0, r0, #0
ands r0, r1
strb r0, [r4, #0x1a]
movs r2, #3
movs r5, #0xe9
b _080ADBCA
_080ADB94:
adds r0, r4, #0
movs r1, #2
bl sub_080ADCDC
ldrb r0, [r4, #0x1a]
movs r1, #0x10
rsbs r1, r1, #0
ands r1, r0
movs r0, #4
orrs r1, r0
strb r1, [r4, #0x1a]
movs r2, #2
movs r5, #0xe8
b _080ADBCA
_080ADBB0:
adds r0, r4, #0
movs r1, #1
bl sub_080ADCDC
ldrb r0, [r4, #0x1a]
movs r1, #0x10
rsbs r1, r1, #0
ands r1, r0
movs r0, #1
orrs r1, r0
strb r1, [r4, #0x1a]
movs r2, #1
movs r5, #0xe7
_080ADBCA:
ldr r0, _080ADC0C @ =gPlayerState
ldrb r1, [r0, #0x1c]
movs r0, #0xf
ands r0, r1
cmp r0, #7
bne _080ADBDA
movs r5, #0xee
movs r2, #1
_080ADBDA:
ldrb r0, [r4, #0xf]
subs r0, r0, r2
strb r0, [r4, #0xf]
_080ADBE0:
movs r0, #0xf
ldrsb r0, [r4, r0]
cmp r0, #0
bge _080ADBF6
cmp r5, #0
beq _080ADBF2
adds r0, r5, #0
bl SoundReq
_080ADBF2:
movs r0, #0xf
strb r0, [r4, #0xf]
_080ADBF6:
ldr r2, _080ADC10 @ =gPlayerEntity
adds r0, r2, #0
adds r0, #0x5a
ldrb r0, [r0]
movs r1, #0x7f
ands r1, r0
ldrb r0, [r2, #0x1e]
subs r0, r0, r1
strb r0, [r4, #0x1e]
_080ADC08:
pop {r4, r5, pc}
.align 2, 0
_080ADC0C: .4byte gPlayerState
_080ADC10: .4byte gPlayerEntity
.syntax divided

View File

@ -1,30 +0,0 @@
.syntax unified
push {r4, lr}
ldr r3, _080ADCD4 @ =gUnk_08132714
ldr r2, _080ADCD8 @ =gPlayerEntity
ldrb r2, [r2, #0x14]
lsrs r2, r2, #1
adds r1, r1, r2
lsls r1, r1, #2
adds r1, r1, r3
ldr r2, [r1]
str r2, [r0, #0x5c]
ldrb r1, [r2]
adds r3, r0, #0
adds r3, #0x58
strb r1, [r3]
adds r1, r2, #1
str r1, [r0, #0x5c]
ldrb r2, [r2, #1]
movs r4, #0x59
strb r2, [r4, r0]
adds r1, #1
str r1, [r0, #0x5c]
ldrb r1, [r3]
ldrh r2, [r0, #0x12]
bl sub_080042D0
pop {r4, pc}
.align 2, 0
_080ADCD4: .4byte gUnk_08132714
_080ADCD8: .4byte gPlayerEntity
.syntax divided

View File

@ -1,45 +0,0 @@
.syntax unified
push {r4, r5, lr}
adds r3, r0, #0
movs r0, #0x59
adds r0, r0, r3
mov ip, r0
ldrb r0, [r0]
subs r0, r0, r1
mov r1, ip
strb r0, [r1]
lsls r0, r0, #0x18
cmp r0, #0
bgt _080ADD2E
ldr r1, [r3, #0x5c]
ldrb r0, [r1]
cmp r0, #0xff
bne _080ADD06
adds r0, r1, #1
str r0, [r3, #0x5c]
ldrb r1, [r1, #1]
subs r0, r0, r1
str r0, [r3, #0x5c]
_080ADD06:
ldr r1, [r3, #0x5c]
ldrb r0, [r1]
adds r2, r3, #0
adds r2, #0x58
strb r0, [r2]
adds r1, #1
str r1, [r3, #0x5c]
ldrb r0, [r1]
mov r4, ip
ldrb r4, [r4]
adds r0, r0, r4
mov r5, ip
strb r0, [r5]
adds r1, #1
str r1, [r3, #0x5c]
ldrb r1, [r2]
ldrh r2, [r3, #0x12]
adds r0, r3, #0
bl sub_080042D0
_080ADD2E:
pop {r4, r5, pc}
.syntax divided

View File

@ -4,12 +4,7 @@
.section .rodata
.align 2
gUnk_08132700:: @ 08132700
.4byte sub_080ADA6C
.4byte sub_080ADAA8
.4byte sub_080ADAD4
.4byte sub_080ADC14
.4byte sub_080ADC60
gUnk_08132714:: @ 08132714
.4byte gUnk_08132AF4

View File

@ -195,7 +195,7 @@ typedef struct Entity_ {
/*0x59*/ u8 frameDuration;
/*0x5a*/ u8 frame;
/*0x5b*/ u8 frameSpriteSettings;
/*0x5c*/ Frame* animPtr;
/*0x5c*/ void* animPtr;
/*0x60*/ u16 spriteVramOffset;
/*0x62*/ u8 spriteOffsetX;
/*0x63*/ s8 spriteOffsetY;

View File

@ -1675,6 +1675,7 @@ SECTIONS {
data/const/playerItem/playerItem13.o(.rodata);
src/title.o(.rodata);
src/projectile.o(.rodata);
src/playerItem/playerItemGustJar.o(.rodata);
data/const/playerItem/playerItemGustJar.o(.rodata);
data/gfx/fixed_type_gfx.o(.rodata);
data/const/movement.o(.rodata);

View File

@ -1,23 +1,32 @@
#include "entity.h"
#include "player.h"
#include "functions.h"
extern void (*const gUnk_08132700[])(Entity*);
#include "sound.h"
extern Hitbox gUnk_08132B28;
void sub_080ADC84(Entity*);
void PlayerItemGustJar_Init(Entity*);
void PlayerItemGustJar_Action1(Entity*);
void PlayerItemGustJar_Action2(Entity*);
void PlayerItemGustJar_Action3(Entity*);
void PlayerItemGustJar_Action4(Entity*);
void sub_080ADCDC(Entity*, u32);
void sub_080ADCA0(Entity*, u32);
void PlayerItemGustJar(Entity* this) {
static void (*const actionFuncs[])(Entity*) = {
PlayerItemGustJar_Init, PlayerItemGustJar_Action1, PlayerItemGustJar_Action2,
PlayerItemGustJar_Action3, PlayerItemGustJar_Action4,
};
if (((Entity*)gPlayerState.item != this) || (gPlayerState.field_0x1c == 0)) {
DeleteThisEntity();
}
gUnk_08132700[this->action](this);
actionFuncs[this->action](this);
sub_08078E84(this, &gPlayerEntity);
}
void sub_080ADA6C(Entity* this) {
void PlayerItemGustJar_Init(Entity* this) {
this->action = 1;
this->field_0xf = 0xf;
this->hitbox = &gUnk_08132B28;
@ -30,7 +39,7 @@ void sub_080ADA6C(Entity* this) {
InitAnimationForceUpdate(this, this->animationState >> 1);
}
void sub_080ADAA8(Entity* this) {
void PlayerItemGustJar_Action1(Entity* this) {
sub_080ADC84(this);
if ((this->frame & 0x80) != 0) {
this->action = 2;
@ -40,9 +49,73 @@ void sub_080ADAA8(Entity* this) {
}
}
ASM_FUNC("asm/non_matching/playerItemGustJar/sub_080ADAD4.inc", void sub_080ADAD4(Entity* this))
void PlayerItemGustJar_Action2(Entity* this) {
u32 in_r2;
int windSound;
void sub_080ADC14(Entity* this) {
if (gPlayerState.field_0x1c == 3) {
this->action++;
InitAnimationForceUpdate(this, (gPlayerEntity.animationState >> 1) + 8);
} else if (gPlayerState.field_0x1c == 6) {
this->action = 4;
InitAnimationForceUpdate(this, (gPlayerEntity.animationState >> 1) + 4);
} else {
windSound = 0;
if (this->type != 0) {
if (this->type == 1) {
sub_080ADCA0(this, 4);
this->actionDelay = 24;
this->type = 2;
} else {
sub_080ADCDC(this, 1);
if (--this->actionDelay == 0xff) {
sub_080ADCA0(this, 0);
this->type = 0;
}
}
} else {
if ((gPlayerState.field_0x1c & 0xf) == 7) {
this->frameDuration = 0x7f;
}
switch (gPlayerState.field_0x1d) {
case 3:
sub_080ADCDC(this, 3);
this->palette.b.b0 = 0;
in_r2 = 3;
windSound = SFX_WIND3;
break;
case 2:
sub_080ADCDC(this, 2);
this->palette.b.b0 = 4;
in_r2 = 2;
windSound = SFX_WIND2;
break;
case 1:
sub_080ADCDC(this, 1);
this->palette.b.b0 = 1;
in_r2 = 1;
windSound = SFX_WIND1;
break;
}
if ((gPlayerState.field_0x1c & 0xf) == 7) {
windSound = SFX_EE;
in_r2 = 1;
}
this->field_0xf = this->field_0xf - in_r2;
}
if ((s8)this->field_0xf < 0) {
if (windSound) {
SoundReq(windSound);
}
this->field_0xf = 15;
}
this->frameIndex = gPlayerEntity.frameIndex - (gPlayerEntity.frame & 0x7f);
}
}
void PlayerItemGustJar_Action3(Entity* this) {
switch (gPlayerState.field_0x1c & 0xf) {
case 6:
this->action += 1;
@ -58,7 +131,7 @@ void sub_080ADC14(Entity* this) {
}
}
void sub_080ADC60(Entity* this) {
void PlayerItemGustJar_Action4(Entity* this) {
if ((this->frame & 0x80) != 0) {
this->spriteSettings.draw = 0;
} else {
@ -70,6 +143,37 @@ void sub_080ADC84(Entity* this) {
this->spriteSettings.flipX = gPlayerEntity.spriteSettings.flipX;
}
ASM_FUNC("asm/non_matching/playerItemGustJar/sub_080ADCA0.inc", void sub_080ADCA0(Entity* this, u32 param_1))
extern const u8* gUnk_08132714[];
ASM_FUNC("asm/non_matching/playerItemGustJar/sub_080ADCDC.inc", void sub_080ADCDC(Entity* this))
void sub_080ADCA0(Entity* this, u32 param_2) {
const u8* pFVar1 = gUnk_08132714[(param_2 + (gPlayerEntity.animationState >> 1))];
const u8* pFVar2;
this->animPtr = (void*)pFVar1;
this->animIndex = *pFVar1;
pFVar2 = pFVar1 + 1;
this->animPtr = (void*)pFVar2;
this->frameDuration = *pFVar2;
this->animPtr = (void*)++pFVar2;
sub_080042D0(this, this->animIndex, this->spriteIndex);
}
void sub_080ADCDC(Entity* this, u32 param_2) {
u32 bVar1;
u8* pFVar3;
bVar1 = this->frameDuration;
this->frameDuration = (u8)(bVar1 - param_2);
if ((int)((bVar1 - param_2) * 0x1000000) < 1) {
if (*(u8*)this->animPtr == 0xff) {
this->animPtr = (u8*)this->animPtr + 1;
this->animPtr = (u8*)this->animPtr - *(u8*)this->animPtr;
}
pFVar3 = this->animPtr;
this->animIndex = *pFVar3;
this->animPtr = ++pFVar3;
this->frameDuration += *pFVar3;
this->animPtr = ++pFVar3;
sub_080042D0(this, this->animIndex, this->spriteIndex);
}
}