Put const data in mailbox

This commit is contained in:
Tal Hayon 2022-04-14 19:41:22 +03:00
parent 3eb303c7c9
commit cda3d6fbe5
3 changed files with 23 additions and 28 deletions

View File

@ -1,11 +0,0 @@
.include "asm/macros.inc"
.include "constants/constants.inc"
.section .rodata
.align 2
gMailboxBehaviors:: @ 0810C804
.4byte sub_08063210
.4byte sub_08063220
.4byte sub_08063254
.4byte sub_08063278

View File

@ -1175,7 +1175,7 @@ SECTIONS {
data/animations/npc/pita.o(.rodata); data/animations/npc/pita.o(.rodata);
src/npc/minishEzlo.o(.rodata); src/npc/minishEzlo.o(.rodata);
data/animations/npc/minishEzlo.o(.rodata); data/animations/npc/minishEzlo.o(.rodata);
data/const/npc/mailbox.o(.rodata); src/npc/mailbox.o(.rodata);
data/animations/npc/mailbox.o(.rodata); data/animations/npc/mailbox.o(.rodata);
data/const/npc/beedle.o(.rodata); data/const/npc/beedle.o(.rodata);
data/animations/npc/beedle.o(.rodata); data/animations/npc/beedle.o(.rodata);

View File

@ -4,11 +4,19 @@
#include "effects.h" #include "effects.h"
#include "npc.h" #include "npc.h"
extern void sub_08063280(Entity*, u32); void sub_08063280(Entity*);
void sub_08063210(Entity*);
extern void (*gMailboxBehaviors[4])(Entity*); void sub_08063220(Entity*);
void sub_08063254(Entity*);
void sub_08063278(Entity*);
void Mailbox(Entity* this) { void Mailbox(Entity* this) {
static void (*const gMailboxBehaviors[4])(Entity*) = {
sub_08063210,
sub_08063220,
sub_08063254,
sub_08063278,
};
gMailboxBehaviors[this->action](this); gMailboxBehaviors[this->action](this);
if (this->action != 0) { if (this->action != 0) {
@ -34,30 +42,28 @@ void sub_08063220(Entity* this) {
if (this->animIndex != bVar1) { if (this->animIndex != bVar1) {
InitAnimationForceUpdate(this, bVar1); InitAnimationForceUpdate(this, bVar1);
} else { } else {
sub_08063280(this, bVar1); sub_08063280(this);
} }
} }
void sub_08063254(Entity* this, u32 unused) { void sub_08063254(Entity* this) {
sub_08063280(this, unused); sub_08063280(this);
if ((this->frame & ANIM_DONE) != 0) { if ((this->frame & ANIM_DONE) != 0) {
this->action = 3; this->action = 3;
MessageFromTarget(0); MessageFromTarget(0);
} }
} }
void sub_08063278(Entity* this, u32 unused) { void sub_08063278(Entity* this) {
sub_08063280(this, unused); sub_08063280(this);
} }
void sub_08063280(Entity* this, u32 unused) { void sub_08063280(Entity* this) {
Entity* e; // r4@1 u8 var; // r2@1
u8 var; // r2@1
e = this; UpdateAnimationSingleFrame(this);
UpdateAnimationSingleFrame(e); var = this->frame & ~ANIM_DONE;
var = e->frame & 0x7F; this->frame ^= var;
e->frame ^= var;
if (var == 2) if (var == 2)
CreateFx(e, FX_MAILBOX_UNUSED, 0); CreateFx(this, FX_MAILBOX_UNUSED, 0);
} }