Decompile castleMaid functions

This commit is contained in:
Tal Hayon 2022-01-07 08:06:47 +02:00
parent 7c082fc55a
commit 6d7e13c63c
3 changed files with 78 additions and 244 deletions

View File

@ -1,105 +0,0 @@
.syntax unified
push {r4, r5, lr}
adds r4, r0, #0
ldrb r5, [r4, #0xc]
cmp r5, #1
beq _080645EA
cmp r5, #1
bgt _08064584
cmp r5, #0
beq _0806458A
b _0806463C
_08064584:
cmp r5, #2
beq _0806462C
b _0806463C
_0806458A:
ldrb r1, [r4, #9]
movs r0, #0x16
eors r1, r0
rsbs r0, r1, #0
orrs r0, r1
lsrs r0, r0, #0x1f
lsls r1, r0, #1
adds r1, r1, r0
lsls r1, r1, #2
ldr r0, _080645D0 @ =gUnk_0810F874
adds r1, r1, r0
adds r0, r4, #0
bl LoadExtraSpriteData
cmp r0, #0
beq _0806463C
ldrb r0, [r4, #0xc]
adds r0, #1
strb r0, [r4, #0xc]
strb r5, [r4, #0xe]
adds r0, r4, #0
bl sub_0805ACC0
adds r2, r0, #0
cmp r2, #0
bne _080645D4
ldrh r0, [r4, #0x2e]
adds r1, r4, #0
adds r1, #0x6c
strh r0, [r1]
ldrh r0, [r4, #0x32]
adds r1, #2
strh r0, [r1]
b _080645E0
.align 2, 0
_080645D0: .4byte gUnk_0810F874
_080645D4:
lsrs r1, r2, #0x10
adds r0, r4, #0
adds r0, #0x6c
strh r1, [r0]
adds r0, #2
strh r2, [r0]
_080645E0:
movs r0, #0
str r0, [r4, #0x68]
adds r0, r4, #0
bl sub_0807DD50
_080645EA:
adds r0, r4, #0
movs r1, #0
bl sub_0807DD94
adds r2, r4, #0
adds r2, #0x39
movs r0, #0
ldrsb r0, [r2, r0]
cmp r0, #0
beq _0806463C
ldrb r0, [r4, #0xc]
adds r0, #1
movs r1, #0
strb r0, [r4, #0xc]
strb r1, [r2]
ldr r1, _08064628 @ =gPlayerEntity
adds r0, r4, #0
bl GetFacingDirection
bl sub_0806F5A4
adds r1, r0, #0
adds r0, r4, #0
bl InitializeAnimation
ldr r0, [r4, #0x68]
cmp r0, #0
beq _0806463C
bl _call_via_r0
b _0806463C
.align 2, 0
_08064628: .4byte gPlayerEntity
_0806462C:
ldr r0, _08064640 @ =gMessage
ldrb r1, [r0]
movs r0, #0x7f
ands r0, r1
cmp r0, #0
bne _0806463C
movs r0, #1
strb r0, [r4, #0xc]
_0806463C:
pop {r4, r5, pc}
.align 2, 0
_08064640: .4byte gMessage
.syntax divided

View File

@ -1,127 +0,0 @@
.syntax unified
push {r4, r5, r6, lr}
adds r4, r0, #0
adds r5, r1, #0
ldrb r0, [r5, #0x18]
cmp r0, #0
bne _08064710
adds r0, #1
strb r0, [r5, #0x18]
bl Random
movs r1, #0x3f
ands r0, r1
adds r0, #0x20
strh r0, [r5, #0x12]
bl Random
adds r1, r0, #0
movs r0, #0x18
ands r1, r0
ldrb r0, [r4, #0x15]
cmp r0, #8
beq _080646EC
cmp r0, #8
bgt _080646DA
cmp r0, #0
beq _080646E4
b _08064702
_080646DA:
cmp r0, #0x10
beq _080646F4
cmp r0, #0x18
beq _080646FC
b _08064702
_080646E4:
cmp r1, #0x10
bne _08064702
movs r1, #8
b _08064702
_080646EC:
cmp r1, #0x18
bne _08064702
movs r1, #0x10
b _08064702
_080646F4:
cmp r1, #0
bne _08064702
movs r1, #0x18
b _08064702
_080646FC:
cmp r1, #8
bne _08064702
movs r1, #0
_08064702:
strb r1, [r4, #0x15]
adds r0, r1, #0
bl sub_0806F5B0
strb r0, [r4, #0x14]
movs r0, #0x80
strh r0, [r4, #0x24]
_08064710:
ldr r0, [r5, #8]
movs r1, #2
orrs r0, r1
str r0, [r5, #8]
adds r0, r4, #0
bl ProcessMovement
movs r0, #0x2e
ldrsh r1, [r4, r0]
adds r2, r4, #0
adds r2, #0x6c
movs r3, #0
ldrsh r0, [r2, r3]
subs r1, r1, r0
cmp r1, #0x10
ble _0806473A
ldrh r0, [r2]
adds r0, #0x10
strh r0, [r4, #0x2e]
movs r0, #1
strh r0, [r5, #0x12]
_0806473A:
movs r3, #0x10
rsbs r3, r3, #0
cmp r1, r3
bge _0806474C
ldrh r0, [r2]
subs r0, #0x10
strh r0, [r4, #0x2e]
movs r0, #1
strh r0, [r5, #0x12]
_0806474C:
movs r6, #0x32
ldrsh r1, [r4, r6]
adds r2, r4, #0
adds r2, #0x6e
movs r6, #0
ldrsh r0, [r2, r6]
subs r1, r1, r0
cmp r1, #0x10
ble _08064768
ldrh r0, [r2]
adds r0, #0x10
strh r0, [r4, #0x32]
movs r0, #1
strh r0, [r5, #0x12]
_08064768:
cmp r1, r3
bge _08064776
ldrh r0, [r2]
subs r0, #0x10
strh r0, [r4, #0x32]
movs r0, #1
strh r0, [r5, #0x12]
_08064776:
ldrh r0, [r5, #0x12]
subs r0, #1
strh r0, [r5, #0x12]
lsls r0, r0, #0x10
cmp r0, #0
beq _08064788
ldr r1, _0806478C @ =gActiveScriptInfo
movs r0, #0
strb r0, [r1, #6]
_08064788:
pop {r4, r5, r6, pc}
.align 2, 0
_0806478C: .4byte gActiveScriptInfo
.syntax divided

View File

@ -5,6 +5,7 @@
#include "message.h"
#include "npc.h"
#include "manager.h"
#include "functions.h"
extern Dialog gUnk_0810F894[];
@ -45,26 +46,28 @@ void Maid_Head(Entity* this) {
sub_0807000C(this);
}
NONMATCH("asm/non_matching/castleMaid/sub_08064570.inc", void sub_08064570(Entity* this)) {
void sub_08064570(Entity* this) {
u32 tmp;
u32 tmp2;
SpriteLoadData* data;
switch (this->action) {
case 0:
// (&gUnk_0810F874[((s32)-(this->id ^ 0x16) >> 0x1f) * -0xc]))
// TODO fix this array access
tmp = -(this->id ^ 0x16);
if (LoadExtraSpriteData(this, &gUnk_0810F874[(BOOLCAST(tmp)) * 2 + tmp]) == 0) {
tmp = this->id;
tmp ^= 0x16;
data = &gUnk_0810F874[BOOLCAST(tmp) * 3];
if (LoadExtraSpriteData(this, data) == 0) {
return;
}
this->action += 1;
this->actionDelay = 0;
tmp = sub_0805ACC0(this);
if (tmp == 0) {
tmp2 = sub_0805ACC0(this);
if (tmp2 == 0) {
this->field_0x6c.HWORD = this->x.HALF.HI;
this->field_0x6e.HWORD = this->y.HALF.HI;
} else {
this->field_0x6c.HWORD = tmp >> 0x10;
this->field_0x6e.HWORD = tmp;
this->field_0x6c.HWORD = tmp2 >> 0x10;
this->field_0x6e.HWORD = tmp2;
}
*(u32*)&this->field_0x68 = 0;
sub_0807DD50(this);
@ -87,7 +90,6 @@ NONMATCH("asm/non_matching/castleMaid/sub_08064570.inc", void sub_08064570(Entit
break;
}
}
END_NONMATCH
void sub_08064644(Entity* this, ScriptExecutionContext* context) {
*(u32*)&this->field_0x68 = context->intVariable;
@ -110,5 +112,69 @@ void sub_08064688(Entity* this) {
ShowNPCDialogue(this, &gUnk_0810F894[gSave.global_progress]);
}
ASM_FUNC("asm/non_matching/castleMaid/sub_080646A4.inc",
void sub_080646A4(Entity* this, ScriptExecutionContext* context))
void sub_080646A4(Entity* this, ScriptExecutionContext* context) {
u8 dir;
s32 x,y;
s32 diff;
if (context->unk_18 == 0) {
context->unk_18++;
context->unk_12 = (Random() & 0x3f) + 0x20;
dir = Random() & 0x18;
switch (this->direction) {
case 0:
if (dir == 0x10) {
dir = 0x8;
}
break;
case 0x8:
if (dir == 0x18) {
dir = 0x10;
}
break;
case 0x10:
if (dir == 0) {
dir = 0x18;
}
break;
case 0x18:
if (dir == 0x8) {
dir = 0;
}
break;
}
this->direction = dir;
this->animationState = sub_0806F5B0(dir);
this->speed = 0x80;
}
context->postScriptActions |= 0x2;
ProcessMovement(this);
x = this->x.HALF.HI;
diff = x - (s16)this->field_0x6c.HWORD;
if (diff > 0x10) {
this->x.HALF.HI = this->field_0x6c.HWORD + 0x10;
context->unk_12 = 1;
}
if (diff < -0x10) {
this->x.HALF.HI = this->field_0x6c.HWORD - 0x10;
context->unk_12 = 1;
}
y = this->y.HALF.HI;
diff = y - (s16)this->field_0x6e.HWORD;
if (diff > 0x10) {
this->y.HALF.HI = this->field_0x6e.HWORD + 0x10;
context->unk_12 = 1;
}
if (diff < -0x10) {
this->y.HALF.HI = this->field_0x6e.HWORD - 0x10;
context->unk_12 = 1;
}
if (--context->unk_12) {
gActiveScriptInfo.commandSize = 0;
}
}