malon OK. made functions.h. fixed typos in format.sh. tidied up epona.c

This commit is contained in:
chandler 2020-06-14 01:49:21 -04:00
parent 66fcdf6186
commit ce030bc8ac
6 changed files with 112 additions and 224 deletions

View File

@ -1,204 +0,0 @@
.include "asm/macros.inc"
.include "constants/constants.inc"
.syntax unified
.text
thumb_func_start sub_0806581C
sub_0806581C: @ 0x0806581C
push {r4, lr}
adds r4, r0, #0
ldrb r1, [r4, #0x10]
movs r0, #2
ands r0, r1
cmp r0, #0
beq _08065840
ldr r0, _0806583C @ =gUnk_0810FF64
ldrb r1, [r4, #0xc]
lsls r1, r1, #2
adds r1, r1, r0
ldr r1, [r1]
adds r0, r4, #0
bl _call_via_r1
b _0806585C
.align 2, 0
_0806583C: .4byte gUnk_0810FF64
_08065840:
ldr r1, _08065860 @ =gUnk_0810FF5C
ldrb r0, [r4, #0xc]
lsls r0, r0, #2
adds r0, r0, r1
ldr r1, [r0]
adds r0, r4, #0
bl _call_via_r1
ldrb r0, [r4, #0xc]
cmp r0, #0
beq _0806585C
adds r0, r4, #0
bl sub_0806ED78
_0806585C:
pop {r4, pc}
.align 2, 0
_08065860: .4byte gUnk_0810FF5C
thumb_func_start sub_08065864
sub_08065864: @ 0x08065864
push {lr}
movs r3, #1
movs r1, #1
strb r1, [r0, #0xc]
ldrb r2, [r0, #0x18]
subs r1, #5
ands r1, r2
orrs r1, r3
strb r1, [r0, #0x18]
movs r1, #0xc
bl LoadAnimation
pop {pc}
.align 2, 0
thumb_func_start sub_08065880
sub_08065880: @ 0x08065880
push {lr}
bl sub_080042B8
pop {pc}
thumb_func_start sub_08065888
sub_08065888: @ 0x08065888
push {r4, lr}
adds r4, r0, #0
movs r2, #1
movs r0, #1
strb r0, [r4, #0xc]
ldrb r1, [r4, #0x18]
subs r0, #5
ands r0, r1
orrs r0, r2
strb r0, [r4, #0x18]
movs r0, #4
strb r0, [r4, #0x14]
adds r0, r4, #0
bl sub_0801E99C
adds r1, r4, #0
adds r1, #0x68
strb r0, [r1]
ldrb r1, [r1]
adds r0, r4, #0
bl sub_08078784
adds r0, r4, #0
bl sub_0807DD50
pop {r4, pc}
thumb_func_start sub_080658BC
sub_080658BC: @ 0x080658BC
push {r4, lr}
adds r4, r0, #0
adds r2, r4, #0
adds r2, #0x39
movs r1, #0
ldrsb r1, [r2, r1]
cmp r1, #2
bne _080658F4
movs r0, #0
strb r1, [r4, #0xc]
strb r0, [r2]
ldr r1, _080658F0 @ =gLinkEntity
adds r0, r4, #0
bl sub_080045C4
bl sub_0806F5A4
adds r1, r0, #0
adds r0, r4, #0
bl LoadAnimation
adds r0, r4, #0
bl sub_0806F118
b _080658FC
.align 2, 0
_080658F0: .4byte gLinkEntity
_080658F4:
adds r0, r4, #0
movs r1, #0
bl sub_0807DD94
_080658FC:
pop {r4, pc}
.align 2, 0
thumb_func_start sub_08065900
sub_08065900: @ 0x08065900
push {r4, lr}
adds r4, r0, #0
bl UpdateFuseInteraction
cmp r0, #0
beq _08065910
movs r0, #1
strb r0, [r4, #0xc]
_08065910:
pop {r4, pc}
.align 2, 0
thumb_func_start sub_08065914
sub_08065914: @ 0x08065914
push {r4, r5, lr}
adds r5, r0, #0
movs r0, #7
movs r1, #0x1f
movs r2, #7
bl sub_0805EB00
adds r4, r0, #0
cmp r4, #0
beq _08065938
movs r2, #0xc0
lsls r2, r2, #0xd
ldr r3, _0806595C @ =0xFFFF0000
adds r0, r5, #0
adds r1, r4, #0
bl PositionRelative
str r5, [r4, #0x50]
_08065938:
movs r0, #7
movs r1, #0x20
movs r2, #7
bl sub_0805EB00
adds r4, r0, #0
cmp r4, #0
beq _08065958
movs r2, #0xa0
lsls r2, r2, #0xe
adds r0, r5, #0
adds r1, r4, #0
movs r3, #0
bl PositionRelative
str r5, [r4, #0x50]
_08065958:
pop {r4, r5, pc}
.align 2, 0
_0806595C: .4byte 0xFFFF0000
thumb_func_start sub_08065960
sub_08065960: @ 0x08065960
push {lr}
adds r2, r0, #0
ldrb r0, [r2, #0xc]
cmp r0, #0
bne _08065986
adds r0, #1
strb r0, [r2, #0xc]
ldrb r1, [r2, #0x18]
movs r0, #4
rsbs r0, r0, #0
ands r0, r1
movs r1, #1
orrs r0, r1
strb r0, [r2, #0x18]
adds r0, r2, #0
movs r1, #0xc
bl LoadAnimation
b _0806598C
_08065986:
adds r0, r2, #0
bl sub_080042B8
_0806598C:
pop {pc}
.align 2, 0

2
format.sh Normal file → Executable file
View File

@ -24,7 +24,7 @@ clang-format ${FORMAT_OPTS} src/**/*.c
clang-format ${FORMAT_OPTS} include/**/*.h clang-format ${FORMAT_OPTS} include/**/*.h
echo "Running clang-tidy..." echo "Running clang-tidy..."
clang-tidy ${TIDY_OPTS} src/**/*.c -- ${COMPILER_OPTS} &> /dev/null clang-tidy ${TIDY_OPTS} src/**/*.c -- ${COMPILER_OPTS} &> /dev/null
clang-format ${FORMAT_OPTS} include/**/*.h clang-tidy ${TIDY_OPTS} include/**/*.h -- ${COMPILER_OPTS} &> /dev/null
echo "Adding missing final new lines..." echo "Adding missing final new lines..."
find src/ -type f -name "*.c" -exec sed -i -e '$a\' {} \; find src/ -type f -name "*.c" -exec sed -i -e '$a\' {} \;
echo "Done formatting all files." echo "Done formatting all files."

27
include/functions.h Normal file
View File

@ -0,0 +1,27 @@
#ifndef _FUNCTIONS_H_
#define _FUNCTIONS_H_
#include "global.h"
#include "entity.h"
void LoadAnimation(Entity*, u32);
void sub_080042B8(Entity*);
u32 sub_080045C4(Entity*, Entity*);
u32 sub_0801E99C(Entity*);
void sub_0805E3A0(Entity*, u32);
Entity* sub_0805EB00(u32, u32, u32);
void sub_0806ED78(Entity*);
void sub_0806F118(Entity*);
u32 UpdateFuseInteraction(void);
void ShowNPCDialogue(Entity*, u64*);
u32 sub_0806F5A4(u32);
void PositionRelative(Entity*, Entity*, s32, s32);
void sub_08078778(Entity*);
void sub_08078784(Entity*, u32);
void sub_080787A8(Entity*, u32);
void sub_080791D0(void);
void sub_0807DD50(Entity*);
void sub_0807DD94(Entity*, u32);
void PlaySFX(u32);
#endif

View File

@ -489,7 +489,7 @@ SECTIONS {
asm/tingleSiblings.o(.text); asm/tingleSiblings.o(.text);
asm/stockwell.o(.text); asm/stockwell.o(.text);
asm/talon.o(.text); asm/talon.o(.text);
asm/malon.o(.text); src/malon.o(.text);
src/epona.o(.text); src/epona.o(.text);
src/milkCart.o(.text); src/milkCart.o(.text);
asm/ghostBrothers.o(.text); asm/ghostBrothers.o(.text);

View File

@ -2,28 +2,14 @@
#include "entity.h" #include "entity.h"
#include "textbox.h" #include "textbox.h"
#include "link.h" #include "link.h"
#include "functions.h"
extern void sub_0806ED78(Entity*);
extern u32 sub_0801E99C(Entity*);
extern void LoadAnimation(Entity*, u32);
extern void sub_080042B8(Entity*);
extern void sub_08065AA4(Entity*);
extern u32 UpdateFuseInteraction(void);
extern void ShowNPCDialogue(Entity*, u64*);
extern void sub_08078778(Entity*);
extern void sub_080787A8(Entity*, u32);
extern void sub_0806F118(Entity*);
extern void sub_0805E3A0(Entity*, u8);
extern u32 sub_080045C4(Entity*, Entity*);
extern u32 sub_0806F5A4(void);
extern void sub_080791D0(void);
extern void PlaySFX(u32);
extern TextBox gTextBox; extern TextBox gTextBox;
extern LinkState gLinkState; extern LinkState gLinkState;
extern Entity gLinkEntity; extern Entity gLinkEntity;
void sub_08065A64(Entity* this); void sub_08065A64(Entity* this);
void sub_08065AA4(Entity*);
extern void (*gUnk_0811006C[])(Entity*); extern void (*gUnk_0811006C[])(Entity*);
extern u64 gUnk_08110080[]; extern u64 gUnk_08110080[];
@ -96,8 +82,7 @@ void sub_08065AA4(Entity* this) {
sub_0805E3A0(this, 2); sub_0805E3A0(this, 2);
sub_08065A50(this); sub_08065A50(this);
} }
sub_080045C4(this, &gLinkEntity); LoadAnimation(this, sub_0806F5A4(sub_080045C4(this, &gLinkEntity)));
LoadAnimation(this, sub_0806F5A4());
} else { } else {
sub_08065A50(this); sub_08065A50(this);
sub_080791D0(); sub_080791D0();

80
src/malon.c Normal file
View File

@ -0,0 +1,80 @@
#include "global.h"
#include "functions.h"
#include "entity.h"
extern Entity gLinkEntity;
extern void (*gUnk_0810FF5C[])(Entity* this);
extern void (*gUnk_0810FF64[])(Entity* this);
void sub_0806581C(Entity* this) {
if (this->flags & 0x2) {
gUnk_0810FF64[this->action](this);
} else {
gUnk_0810FF5C[this->action](this);
if (this->action != 0) {
sub_0806ED78(this);
}
}
}
void sub_08065864(Entity* this) {
this->action = 1;
this->spriteSettings.b.ss0 = 1;
LoadAnimation(this, 0xC);
}
void sub_08065880(Entity* this) {
sub_080042B8(this);
}
void sub_08065888(Entity* this) {
this->action = 1;
this->spriteSettings.b.ss0 = 1;
this->animationState = 4;
this->field_0x68 = sub_0801E99C(this);
sub_08078784(this, this->field_0x68);
sub_0807DD50(this);
}
void sub_080658BC(Entity* this) {
if (this->interactType == 2) {
this->action = 2;
this->interactType = 0;
LoadAnimation(this, sub_0806F5A4(sub_080045C4(this, &gLinkEntity)));
sub_0806F118(this);
} else {
sub_0807DD94(this, 0);
}
}
void sub_08065900(Entity* this) {
if (UpdateFuseInteraction() != 0) {
this->action = 1;
}
}
void sub_08065914(Entity* this) {
Entity* target;
target = sub_0805EB00(7, 0x1F, 7);
if (target != NULL) {
PositionRelative(this, target, 0x180000, -0x10000);
target->parent = this;
}
target = sub_0805EB00(7, 0x20, 7);
if (target != NULL) {
PositionRelative(this, target, 0x280000, 0);
target->parent = this;
}
}
void sub_08065960(Entity* this) {
if (this->action == 0) {
this->action++;
this->spriteSettings.b.ss0 = 1;
LoadAnimation(this, 0xC);
} else {
sub_080042B8(this);
}
}