decompile businessScrub

This commit is contained in:
Behemoth
2020-09-18 18:35:25 +02:00
parent 34d16a7db5
commit 99605c8504
8 changed files with 800 additions and 1444 deletions
-1281
View File
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,30 @@
.syntax unified
.text
push {r4, lr}
adds r4, r0, #0
movs r0, #0
movs r1, #6
strb r1, [r4, #0xc]
adds r1, r4, #0
adds r1, #0x81
strb r0, [r1]
ldr r0, [r4, #0x7c]
ldrb r0, [r0, #8]
cmp r0, #0x6c
beq _08029252
cmp r0, #0x6c
bgt _08029252
cmp r0, #0x1c
bne _08029252
movs r0, #0x5a
bl SetGlobalFlag
_08029252:
adds r0, r4, #0
movs r1, #3
bl sub_080290E0
pop {r4, pc}
.syntax divided
+86
View File
@@ -0,0 +1,86 @@
.include "asm/macros.inc"
.include "constants/constants.inc"
.section .rodata
gUnk_080CCA0A:: @ 080CCA0A
.incbin "baserom.gba", 0x0CCA0A, 0x0000015
gUnk_080CCA1F:: @ 080CCA1F
.incbin "baserom.gba", 0x0CCA1F, 0x0000015
gUnk_080CCA34:: @ 080CCA34
.incbin "baserom.gba", 0x0CCA34, 0x0000015
gUnk_080CCA49:: @ 080CCA49
.incbin "baserom.gba", 0x0CCA49, 0x0000015
gUnk_080CCA5E:: @ 080CCA5E
.incbin "baserom.gba", 0x0CCA5E, 0x0000011
gUnk_080CCA6F:: @ 080CCA6F
.incbin "baserom.gba", 0x0CCA6F, 0x0000011
gUnk_080CCA80:: @ 080CCA80
.incbin "baserom.gba", 0x0CCA80, 0x0000011
gUnk_080CCA91:: @ 080CCA91
.incbin "baserom.gba", 0x0CCA91, 0x0000011
gUnk_080CCAA2:: @ 080CCAA2
.incbin "baserom.gba", 0x0CCAA2, 0x0000005
gUnk_080CCAA7:: @ 080CCAA7
.incbin "baserom.gba", 0x0CCAA7, 0x0000005
gUnk_080CCAAC:: @ 080CCAAC
.incbin "baserom.gba", 0x0CCAAC, 0x0000005
gUnk_080CCAB1:: @ 080CCAB1
.incbin "baserom.gba", 0x0CCAB1, 0x0000005
gUnk_080CCAB6:: @ 080CCAB6
.incbin "baserom.gba", 0x0CCAB6, 0x0000010
gUnk_080CCAC6:: @ 080CCAC6
.incbin "baserom.gba", 0x0CCAC6, 0x0000010
gUnk_080CCAD6:: @ 080CCAD6
.incbin "baserom.gba", 0x0CCAD6, 0x0000010
gUnk_080CCAE6:: @ 080CCAE6
.incbin "baserom.gba", 0x0CCAE6, 0x0000010
gUnk_080CCAF6:: @ 080CCAF6
.incbin "baserom.gba", 0x0CCAF6, 0x0000011
gUnk_080CCB07:: @ 080CCB07
.incbin "baserom.gba", 0x0CCB07, 0x0000011
gUnk_080CCB18:: @ 080CCB18
.incbin "baserom.gba", 0x0CCB18, 0x0000011
gUnk_080CCB29:: @ 080CCB29
.incbin "baserom.gba", 0x0CCB29, 0x0000011
gUnk_080CCB3A:: @ 080CCB3A
.incbin "baserom.gba", 0x0CCB3A, 0x000000D
gUnk_080CCB47:: @ 080CCB47
.incbin "baserom.gba", 0x0CCB47, 0x000000D
gUnk_080CCB54:: @ 080CCB54
.incbin "baserom.gba", 0x0CCB54, 0x000000D
gUnk_080CCB61:: @ 080CCB61
.incbin "baserom.gba", 0x0CCB61, 0x000000D
gUnk_080CCB6E:: @ 080CCB6E
.incbin "baserom.gba", 0x0CCB6E, 0x0000011
gUnk_080CCB7F:: @ 080CCB7F
.incbin "baserom.gba", 0x0CCB7F, 0x0000015
gUnk_080CCB94:: @ 080CCB94
.incbin "baserom.gba", 0x0CCB94, 0x000006C
+71
View File
@@ -0,0 +1,71 @@
.include "asm/macros.inc"
.include "constants/constants.inc"
.section .rodata
gUnk_080CC7E0:: @ 080CC7E0
.incbin "baserom.gba", 0x0CC7E0, 0x0000009
gUnk_080CC7E9:: @ 080CC7E9
.incbin "baserom.gba", 0x0CC7E9, 0x0000009
gUnk_080CC7F2:: @ 080CC7F2
.incbin "baserom.gba", 0x0CC7F2, 0x0000009
gUnk_080CC7FB:: @ 080CC7FB
.incbin "baserom.gba", 0x0CC7FB, 0x0000009
gUnk_080CC804:: @ 080CC804
.incbin "baserom.gba", 0x0CC804, 0x0000011
gUnk_080CC815:: @ 080CC815
.incbin "baserom.gba", 0x0CC815, 0x0000011
gUnk_080CC826:: @ 080CC826
.incbin "baserom.gba", 0x0CC826, 0x0000011
gUnk_080CC837:: @ 080CC837
.incbin "baserom.gba", 0x0CC837, 0x0000011
gUnk_080CC848:: @ 080CC848
.incbin "baserom.gba", 0x0CC848, 0x0000011
gUnk_080CC859:: @ 080CC859
.incbin "baserom.gba", 0x0CC859, 0x0000011
gUnk_080CC86A:: @ 080CC86A
.incbin "baserom.gba", 0x0CC86A, 0x0000011
gUnk_080CC87B:: @ 080CC87B
.incbin "baserom.gba", 0x0CC87B, 0x0000011
gUnk_080CC88C:: @ 080CC88C
.incbin "baserom.gba", 0x0CC88C, 0x0000015
gUnk_080CC8A1:: @ 080CC8A1
.incbin "baserom.gba", 0x0CC8A1, 0x0000015
gUnk_080CC8B6:: @ 080CC8B6
.incbin "baserom.gba", 0x0CC8B6, 0x0000015
gUnk_080CC8CB:: @ 080CC8CB
.incbin "baserom.gba", 0x0CC8CB, 0x0000015
gUnk_080CC8E0:: @ 080CC8E0
.incbin "baserom.gba", 0x0CC8E0, 0x0000044
gUnk_080CC924:: @ 080CC924
.incbin "baserom.gba", 0x0CC924, 0x0000008
gUnk_080CC92C:: @ 080CC92C
.incbin "baserom.gba", 0x0CC92C, 0x0000008
gUnk_080CC934:: @ 080CC934
.incbin "baserom.gba", 0x0CC934, 0x0000008
gUnk_080CC93C:: @ 080CC93C
.incbin "baserom.gba", 0x0CC93C, 0x0000008
gUnk_080CC944:: @ 080CC944
.incbin "baserom.gba", 0x0CC944, 0x0000010
-162
View File
@@ -3,168 +3,6 @@
.section .rodata
gUnk_080CC7E0:: @ 080CC7E0
.incbin "baserom.gba", 0x0CC7E0, 0x0000009
gUnk_080CC7E9:: @ 080CC7E9
.incbin "baserom.gba", 0x0CC7E9, 0x0000009
gUnk_080CC7F2:: @ 080CC7F2
.incbin "baserom.gba", 0x0CC7F2, 0x0000009
gUnk_080CC7FB:: @ 080CC7FB
.incbin "baserom.gba", 0x0CC7FB, 0x0000009
gUnk_080CC804:: @ 080CC804
.incbin "baserom.gba", 0x0CC804, 0x0000011
gUnk_080CC815:: @ 080CC815
.incbin "baserom.gba", 0x0CC815, 0x0000011
gUnk_080CC826:: @ 080CC826
.incbin "baserom.gba", 0x0CC826, 0x0000011
gUnk_080CC837:: @ 080CC837
.incbin "baserom.gba", 0x0CC837, 0x0000011
gUnk_080CC848:: @ 080CC848
.incbin "baserom.gba", 0x0CC848, 0x0000011
gUnk_080CC859:: @ 080CC859
.incbin "baserom.gba", 0x0CC859, 0x0000011
gUnk_080CC86A:: @ 080CC86A
.incbin "baserom.gba", 0x0CC86A, 0x0000011
gUnk_080CC87B:: @ 080CC87B
.incbin "baserom.gba", 0x0CC87B, 0x0000011
gUnk_080CC88C:: @ 080CC88C
.incbin "baserom.gba", 0x0CC88C, 0x0000015
gUnk_080CC8A1:: @ 080CC8A1
.incbin "baserom.gba", 0x0CC8A1, 0x0000015
gUnk_080CC8B6:: @ 080CC8B6
.incbin "baserom.gba", 0x0CC8B6, 0x0000015
gUnk_080CC8CB:: @ 080CC8CB
.incbin "baserom.gba", 0x0CC8CB, 0x0000015
gUnk_080CC8E0:: @ 080CC8E0
.incbin "baserom.gba", 0x0CC8E0, 0x0000044
gUnk_080CC924:: @ 080CC924
.incbin "baserom.gba", 0x0CC924, 0x0000008
gUnk_080CC92C:: @ 080CC92C
.incbin "baserom.gba", 0x0CC92C, 0x0000008
gUnk_080CC934:: @ 080CC934
.incbin "baserom.gba", 0x0CC934, 0x0000008
gUnk_080CC93C:: @ 080CC93C
.incbin "baserom.gba", 0x0CC93C, 0x0000008
gUnk_080CC944:: @ 080CC944
.incbin "baserom.gba", 0x0CC944, 0x0000010
gUnk_080CC954:: @ 080CC954
.incbin "baserom.gba", 0x0CC954, 0x000006C
gUnk_080CC9C0:: @ 080CC9C0
.incbin "baserom.gba", 0x0CC9C0, 0x0000008
gUnk_080CC9C8:: @ 080CC9C8
.incbin "baserom.gba", 0x0CC9C8, 0x0000018
gUnk_080CC9E0:: @ 080CC9E0
.incbin "baserom.gba", 0x0CC9E0, 0x0000024
gUnk_080CCA04:: @ 080CCA04
.incbin "baserom.gba", 0x0CCA04, 0x0000006
gUnk_080CCA0A:: @ 080CCA0A
.incbin "baserom.gba", 0x0CCA0A, 0x0000015
gUnk_080CCA1F:: @ 080CCA1F
.incbin "baserom.gba", 0x0CCA1F, 0x0000015
gUnk_080CCA34:: @ 080CCA34
.incbin "baserom.gba", 0x0CCA34, 0x0000015
gUnk_080CCA49:: @ 080CCA49
.incbin "baserom.gba", 0x0CCA49, 0x0000015
gUnk_080CCA5E:: @ 080CCA5E
.incbin "baserom.gba", 0x0CCA5E, 0x0000011
gUnk_080CCA6F:: @ 080CCA6F
.incbin "baserom.gba", 0x0CCA6F, 0x0000011
gUnk_080CCA80:: @ 080CCA80
.incbin "baserom.gba", 0x0CCA80, 0x0000011
gUnk_080CCA91:: @ 080CCA91
.incbin "baserom.gba", 0x0CCA91, 0x0000011
gUnk_080CCAA2:: @ 080CCAA2
.incbin "baserom.gba", 0x0CCAA2, 0x0000005
gUnk_080CCAA7:: @ 080CCAA7
.incbin "baserom.gba", 0x0CCAA7, 0x0000005
gUnk_080CCAAC:: @ 080CCAAC
.incbin "baserom.gba", 0x0CCAAC, 0x0000005
gUnk_080CCAB1:: @ 080CCAB1
.incbin "baserom.gba", 0x0CCAB1, 0x0000005
gUnk_080CCAB6:: @ 080CCAB6
.incbin "baserom.gba", 0x0CCAB6, 0x0000010
gUnk_080CCAC6:: @ 080CCAC6
.incbin "baserom.gba", 0x0CCAC6, 0x0000010
gUnk_080CCAD6:: @ 080CCAD6
.incbin "baserom.gba", 0x0CCAD6, 0x0000010
gUnk_080CCAE6:: @ 080CCAE6
.incbin "baserom.gba", 0x0CCAE6, 0x0000010
gUnk_080CCAF6:: @ 080CCAF6
.incbin "baserom.gba", 0x0CCAF6, 0x0000011
gUnk_080CCB07:: @ 080CCB07
.incbin "baserom.gba", 0x0CCB07, 0x0000011
gUnk_080CCB18:: @ 080CCB18
.incbin "baserom.gba", 0x0CCB18, 0x0000011
gUnk_080CCB29:: @ 080CCB29
.incbin "baserom.gba", 0x0CCB29, 0x0000011
gUnk_080CCB3A:: @ 080CCB3A
.incbin "baserom.gba", 0x0CCB3A, 0x000000D
gUnk_080CCB47:: @ 080CCB47
.incbin "baserom.gba", 0x0CCB47, 0x000000D
gUnk_080CCB54:: @ 080CCB54
.incbin "baserom.gba", 0x0CCB54, 0x000000D
gUnk_080CCB61:: @ 080CCB61
.incbin "baserom.gba", 0x0CCB61, 0x000000D
gUnk_080CCB6E:: @ 080CCB6E
.incbin "baserom.gba", 0x0CCB6E, 0x0000011
gUnk_080CCB7F:: @ 080CCB7F
.incbin "baserom.gba", 0x0CCB7F, 0x0000015
gUnk_080CCB94:: @ 080CCB94
.incbin "baserom.gba", 0x0CCB94, 0x000006C
gUnk_080CCC00:: @ 080CCC00
.incbin "baserom.gba", 0x0CCC00, 0x0000018
+1
View File
@@ -106,6 +106,7 @@ typedef struct {
} ItemBehavior;
extern u8 gBombBagSizes[];
extern u8 gQuiverSizes[];
extern PlayerState gPlayerState;
extern Stats gStats;
+4 -1
View File
@@ -347,7 +347,7 @@ SECTIONS {
asm/chuchuBoss.o(.text);
src/enemy/likeLike.o(.text);
src/enemy/spearMoblin.o(.text);
asm/businessScrub.o(.text);
src/enemy/businessScrub.o(.text);
src/enemy/rupeeLike.o(.text);
src/enemy/madderpillar.o(.text);
asm/waterDrop.o(.text);
@@ -946,6 +946,9 @@ SECTIONS {
src/enemy/likeLike.o(.rodata);
data/animations/likeLike.o(.rodata);
src/enemy/spearMoblin.o(.rodata);
data/animations/spearMoblin.o(.rodata);
src/enemy/businessScrub.o(.rodata);
data/animations/businessScrub.o(.rodata);
data/data_080CC6FC.o(.rodata);
src/enemy.o(.rodata);
data/data_080D3D94.o(.rodata);
+608
View File
@@ -0,0 +1,608 @@
#include "enemy.h"
#include "entity.h"
#include "flags.h"
#include "functions.h"
#include "textbox.h"
extern void sub_0801D040(Entity*, u32);
extern Entity* sub_08049DF4(u32);
extern bool32 sub_08056338(void);
extern void UnloadOBJPalette(Entity*);
bool32 sub_0802915C(Entity*);
bool32 sub_080291DC(Entity*);
void sub_0802922C(Entity*);
void sub_08028E9C(Entity*);
u32 sub_080001DA(u32, u32);
void sub_08028FFC(Entity*);
void sub_0802925C(Entity*);
void sub_080290E0(Entity*, u32);
bool32 sub_08028F98(Entity*, u32);
void sub_08029078(Entity*);
bool32 sub_08028FDC(Entity*);
void sub_080290FC(Entity*);
void sub_08028EDC(Entity*);
extern const struct SalesOffering gUnk_080CC954[];
extern const u8 gUnk_080CC9C0[];
extern void (*const gUnk_080CC9C8[])(Entity*);
extern void (*const gUnk_080CC9E0[])(Entity*);
extern const u8 gUnk_080CCA04[];
struct SalesOffering {
u8 field_0x0;
u8 field_0x1;
u16 price;
u16 field_0x4;
u16 field_0x6;
u8 field_0x8;
u8 field_0x9;
u16 field_0xa;
};
void BusinessScrub(Entity* this) {
EnemyFunctionHandler(this, gUnk_080CC9C8);
}
void sub_0802891C(Entity* this) {
gUnk_080CC9E0[this->action](this);
}
void sub_08028934(Entity* this) {
Entity* pEVar1;
if (this->damageType == 1 && (this->bitfield & 0x7f) == 0x42) {
this->action = 3;
this->previousActionFlag = 0;
this->actionDelay = 0x28;
this->flags &= ~0x80;
sub_080290E0(this, 4);
pEVar1 = CreateFx(this, 3, 0);
if (pEVar1 != NULL) {
pEVar1->height.HALF.HI -= 8;
}
EnqueueSFX(0x1bb);
}
}
void nullsub_140(Entity* this) {
/* ... */
}
void sub_08028994(Entity* this) {
this->field_0xf = 0;
this->field_0x78.HWORD = this->x.HALF.HI;
this->field_0x7a.HWORD = this->y.HALF.HI;
this->animationState = 0;
this->direction = 0x10;
sub_08028E9C(this);
if ((*(u8*)this->field_0x7c.WORD & 1) || CheckFlags(this->field_0x86.HWORD)) {
this->action = 4;
this->actionDelay = 0x78;
this->spritePriority.b1 = 1;
sub_0802925C(this);
sub_080290E0(this, 0);
} else {
this->actionDelay = 0;
this->field_0x76.HWORD = COORD_TO_TILE(this);
this->field_0x74.HWORD = sub_080001DA(this->field_0x76.HWORD, this->collisionLayer);
this->field_0x40 = 0x41;
sub_08028FFC(this);
}
}
void sub_08028A48(Entity* this) {
if (this->actionDelay) {
this->actionDelay--;
} else if (sub_08028F98(this, 0)) {
sub_08029078(this);
this->previousActionFlag = 0;
this->field_0xf = 1;
}
}
void sub_08028A74(Entity* this) {
u32 unk;
GetNextFrame(this);
switch (this->previousActionFlag) {
case 0:
unk = 1;
if (this->frames.all & 0x80) {
this->previousActionFlag = 1;
this->actionDelay = 0x3c;
this->field_0xf = 0x10;
sub_08028FDC(this);
sub_080290E0(this, 1);
}
break;
case 1:
unk = 1;
if (--this->actionDelay == 0) {
this->previousActionFlag = 2;
this->actionDelay = 0x20;
this->field_0xf = 0;
sub_08028FDC(this);
sub_080290E0(this, 2);
} else if (--this->field_0xf == 0) {
if (sub_08028FDC(this)) {
sub_080290E0(this, 1);
}
this->field_0xf = 0x10;
}
break;
case 2:
unk = 1;
sub_080290FC(this);
if (this->frames.all & 1) {
Entity* ent = sub_0804A98C(this, 4, 0);
if (ent != NULL) {
ent->parent = this;
ent->direction = this->direction;
this->frames.all &= ~1;
this->previousActionFlag = 3;
}
}
break;
case 3:
unk = 2;
if (this->frames.all & 0x80) {
this->previousActionFlag = 4;
this->actionDelay = 0x50;
sub_080290E0(this, 1);
}
break;
case 4:
unk = 2;
if (--this->actionDelay == 0) {
if (sub_08028F98(this, 0)) {
this->previousActionFlag = 1;
this->actionDelay = 0x3c;
this->field_0xf = 0x10;
sub_08028FDC(this);
} else {
sub_08028FFC(this);
this->previousActionFlag = 0;
this->actionDelay = 0x50;
this->field_0xf = 0;
}
return;
}
break;
}
if (!sub_08028F98(this, unk)) {
sub_08028FFC(this);
this->previousActionFlag = 0;
this->actionDelay = 0x50;
this->field_0xf = 0;
}
}
void sub_08028BC4(Entity* this) {
Entity* iVar1;
switch (this->previousActionFlag) {
case 0:
if (this->actionDelay == 0) {
if (this->frames.all & 0x80) {
this->previousActionFlag = 1;
sub_08028FDC(this);
sub_080290E0(this, 5);
this->spritePriority.b1 = 1;
}
} else {
this->actionDelay--;
}
break;
case 1:
if (this->frames.all & 0x80) {
this->action = 4;
this->previousActionFlag = 0;
this->actionDelay = 0x1e;
this->field_0xf = 5;
sub_080290E0(this, 0);
iVar1 = sub_0804A9FC(this, 0x1c);
if (iVar1 != NULL) {
iVar1->spritePriority.b0 = 3;
iVar1->height.HALF.HI -= 12;
sub_0805E3A0(iVar1, 2);
}
SetFlag(this->field_0x86.HWORD);
sub_0802925C(this);
}
break;
}
GetNextFrame(this);
sub_0800445C(this);
}
extern void sub_0804AA1C(Entity*);
void sub_08028F0C(Entity*);
void sub_08028C84(Entity* this) {
if (--this->actionDelay == 0) {
this->actionDelay = 0x30;
if (this->field_0xf) {
if (--this->field_0xf == 0) {
sub_0804AA1C(this);
}
} else if (sub_08028FDC(this) || this->field_0x80.HALF.LO) {
this->field_0x80.HALF.LO = 0;
sub_080290E0(this, 0);
}
}
GetNextFrame(this);
sub_0800445C(this);
sub_08028F0C(this);
}
void sub_08028CE8(Entity* this) {
struct SalesOffering* offer = (struct SalesOffering*)this->field_0x7c.WORD;
u32 subtype;
if ((gTextBox.doTextBox & 0x7f) == 0 && sub_0802915C(this) && !sub_08056338()) {
if (offer->price <= gUnk_02002A40.stats.rupees) {
if (sub_080291DC(this)) {
/* Bag full. */
TextboxNoOverlapFollow(0x2904);
sub_08078A90(0);
} else {
ModRupees(-offer->price);
switch (offer->field_0x0 >> 2) {
case 0:
subtype = offer->field_0x9;
if (subtype == 0xff) {
subtype = gUnk_080CC9C0[Random() & 7];
}
CreateItemEntity(offer->field_0x8, subtype, 0);
this->action = 6;
this->actionDelay = 4;
this->field_0x80.HALF.HI = 0;
sub_080290E0(this, 3);
SetLocalFlag(0x87);
return;
case 1:
CreateItemEntity(offer->field_0x8, offer->field_0x9, 0);
this->actionDelay = 4;
sub_0802922C(this);
return;
case 2:
CreateItemEntity(offer->field_0x8, offer->field_0x9, 0);
this->actionDelay = 8;
sub_0802922C(this);
return;
}
}
} else {
/* Not enough money. */
TextboxNoOverlapFollow(0x2903);
sub_08078A90(0);
}
}
sub_0800445C(this);
this->action = 4;
this->actionDelay = 0x30;
sub_080290E0(this, 0);
}
void sub_08028DE8(Entity* this) {
if (gPlayerEntity.action == 8) {
if (this->field_0x80.HALF.HI == 0) {
sub_08078A90(1);
this->field_0x80.HALF.HI = 1;
}
} else {
TextboxNoOverlapFollow(0x2902);
this->action = 4;
this->field_0x80.HALF.HI = 0;
this->actionDelay = 1;
sub_08028EDC(this);
sub_08078A90(0);
sub_0800445C(this);
GetNextFrame(this);
}
}
void sub_08028E40(Entity* this) {
if ((gTextBox.doTextBox & 0x7f) == 0) {
struct SalesOffering* offer = (struct SalesOffering*)this->field_0x7c.WORD;
this->action = 4;
this->previousActionFlag = gTextBox.doTextBox & 0x7f;
this->actionDelay = 1;
if (CheckLocalFlag(offer->field_0xa) == 0) {
SetLocalFlag(offer->field_0xa);
}
sub_08078A90(0);
}
sub_0800445C(this);
GetNextFrame(this);
}
void sub_08028E84(Entity* this) {
if (UpdateFuseInteraction()) {
this->action = 4;
this->actionDelay = 1;
}
}
bool32 sub_08029198(const struct SalesOffering*);
void sub_08028E9C(Entity* this) {
const struct SalesOffering* offer = &gUnk_080CC954[this->entityType.form];
if (sub_08029198(offer) && (offer->field_0x0 & 2)) {
offer = &gUnk_080CC954[offer->field_0xa];
}
this->field_0x7c.WORD = (u32)offer;
this->field_0x80.HALF.LO = 0;
}
void sub_08028EDC(Entity* this) {
const struct SalesOffering* offer = (const struct SalesOffering*)this->field_0x7c.WORD;
if (sub_08029198(offer) && (offer->field_0x0 & 2)) {
offer = &gUnk_080CC954[offer->field_0xa];
this->field_0x7c.WORD = (u32)offer;
}
}
void sub_08028F0C(Entity* this) {
if (this->interactType == 2) {
this->action = 8;
this->interactType = 0;
sub_0806F118(this);
} else if (this->interactType != 0) {
u16 dialog;
const struct SalesOffering* offer = (const struct SalesOffering*)this->field_0x7c.WORD;
this->interactType = 0;
sub_0804AA1C(this);
this->direction = (GetAnimationState(this) << 3);
sub_080290E0(this, 3);
this->field_0x80.HALF.LO = 1;
this->actionDelay = 0x20;
this->field_0xf = 0;
if (sub_08029198(offer)) {
dialog = offer->field_0x6;
} else {
if ((offer->field_0x0 & 0xfc) != 0xc) {
this->action = 5;
} else {
this->action = 7;
}
dialog = offer->field_0x4;
sub_08078A90(1);
}
TextboxNoOverlapFollow(dialog);
gTextBox.field_0x10 = offer->price;
}
}
bool32 sub_08028F98(Entity* this, u32 param_2) {
Entity* ent = sub_08049DF4(1);
if (ent == NULL || sub_080041A0(this, ent, 0x28, 0x28)) {
return FALSE;
}
if (param_2 != 2) {
u32 distance = param_2 ? 0x58 : 0x50;
if (!sub_080041A0(this, ent, distance, distance)) {
return FALSE;
}
}
return TRUE;
}
bool32 sub_08028FDC(Entity* this) {
u32 direction = DirectionRoundUp(sub_08049F84(this, 1));
if (direction == this->direction) {
return FALSE;
} else {
this->direction = direction;
return TRUE;
}
}
void sub_08028FFC(Entity* this) {
this->action = 1;
this->flags &= ~0x80;
this->spritePriority.b1 = 0;
sub_080AE068(this);
UnloadOBJPalette(this);
this->spriteVramOffset = 0xe8;
this->palette.b.b0 = 2;
this->palette.b.b4 = 2;
this->spriteIndex = 0xa7;
this->x.HALF.HI = this->field_0x78.HWORD;
this->y.HALF.HI = this->field_0x7a.HWORD;
InitializeAnimation(this, 0);
SetTile(0x4022, this->field_0x76.HWORD, this->collisionLayer);
}
void sub_08029078(Entity* this) {
this->action = 2;
this->flags = this->flags | 0x80;
this->spritePriority.b1 = 1;
if (LoadFixedGFX(this, 0x72) == 0) {
DeleteEntity(this);
} else {
sub_0801D040(this, 0x6e);
this->spriteIndex = 0xd0;
sub_08028FDC(this);
sub_080290E0(this, 1);
SetTile(this->field_0x74.HWORD, this->field_0x76.HWORD, this->collisionLayer);
}
}
void sub_080290E0(Entity* this, u32 param_2) {
InitializeAnimation(this, this->direction >> 3 | gUnk_080CCA04[param_2]);
}
void sub_080290FC(Entity* this) {
if (this->actionDelay != 0) {
if (--this->actionDelay < 0x10 && (this->actionDelay & 1) == 0) {
s32 sVar3 = (this->direction & 0x10) ? -1 : 1;
if ((this->direction & 8)) {
this->x.HALF.HI += (this->actionDelay & 8) ? -sVar3 : sVar3;
} else {
this->y.HALF.HI += (this->actionDelay & 8) ? sVar3 : -sVar3;
}
}
}
}
bool32 sub_0802915C(Entity* this) {
const struct SalesOffering* offer = (const struct SalesOffering*)this->field_0x7c.WORD;
switch (offer->field_0x8) {
case 0x44:
if (GetInventoryValue(0x44) == 0)
return TRUE;
break;
case 0x1c:
if (CheckGlobalFlag(0x5a) == 0)
return TRUE;
break;
case 0x5c:
case 0x6c:
case 0x6f:
return TRUE;
}
return FALSE;
}
bool32 sub_08029198(const struct SalesOffering* offer) {
u32 tmp;
if ((offer->field_0x0 & 0xfc) != 0xc) {
switch (offer->field_0x8) {
case 0x1c:
tmp = CheckGlobalFlag(0x5a);
break;
case 0x9:
case 0x44:
tmp = GetInventoryValue(offer->field_0x8);
break;
default:
return 0;
}
} else {
tmp = CheckLocalFlag(offer->field_0xa);
}
if (tmp == 0) {
return FALSE;
}
return TRUE;
}
bool32 sub_080291DC(Entity* this) {
const struct SalesOffering* offer = (const struct SalesOffering*)this->field_0x7c.WORD;
switch (offer->field_0x8) {
case 0x6c:
if (gBombBagSizes[gUnk_02002A40.stats.bombBagType] <= gUnk_02002A40.stats.bombCount)
return TRUE;
break;
case 0x6f:
if (gQuiverSizes[gUnk_02002A40.stats.quiverType] <= gUnk_02002A40.stats.arrowCount)
return TRUE;
break;
}
return FALSE;
}
#if NON_MATCHING
void sub_0802922C(Entity* this) {
const struct SalesOffering* offer = (const struct SalesOffering*)this->field_0x7c.WORD;
this->action = 6;
this->field_0x80.HALF.HI = 0;
switch (offer->field_0x8) {
case 0x1c:
SetGlobalFlag(0x5a);
break;
}
sub_080290E0(this, 3);
}
#else
NAKED
void sub_0802922C(Entity* this) {
asm(".include \"asm/non_matching/businessScrub/sub_0802925C.inc\"");
}
#endif
void sub_0802925C(Entity* this) {
sub_08078784(this, sub_0801E99C(this));
}
void sub_08029270(Entity* this) {
if (this->action == 0) {
this->action++;
this->spriteSettings.b.draw = 1;
InitializeAnimation(this, 0xe);
} else {
GetNextFrame(this);
}
}
// clang-format off
const struct SalesOffering gUnk_080CC954[] = {
{0x06, 0x00, 0xffff, 0x290f, 0x2902, 0x09, 0xff, 0x0001},
{0x04, 0x00, 0x001e, 0x290e, 0x2902, 0x6f, 0xff, 0xffff},
{0x04, 0x00, 0x001e, 0x290b, 0x2902, 0x6c, 0xff, 0xffff},
{0x08, 0x00, 0x0028, 0x290c, 0x2911, 0x44, 0xff, 0xffff},
{0x00, 0x00, 0x0064, 0x290d, 0x2902, 0x5c, 0xff, 0xffff},
{0x04, 0x00, 0x0014, 0x2910, 0x2911, 0x1c, 0xff, 0xffff},
{0x0c, 0x00, 0xffff, 0x2912, 0x2913, 0xff, 0xff, 0x0046},
{0x04, 0x00, 0x0064, 0x2913, 0x2902, 0x5c, 0x75, 0xffff},
{0x00, 0x00, 0x00C8, 0x290d, 0x2902, 0x5c, 0xff, 0xffff},
};
const u8 gUnk_080CC9C0[] = {
0x6e,
0x6f,
0x70,
0x71,
0x72,
0x73,
0x74,
0x75,
};
void (*const gUnk_080CC9C8[])(Entity*) = {
sub_0802891C,
sub_08028934,
sub_08001324,
sub_0804A7D4,
sub_08001242,
nullsub_140,
};
void (*const gUnk_080CC9E0[])(Entity*) = {
sub_08028994,
sub_08028A48,
sub_08028A74,
sub_08028BC4,
sub_08028C84,
sub_08028CE8,
sub_08028DE8,
sub_08028E40,
sub_08028E84,
};
const u8 gUnk_080CCA04[] = {
0, 4, 8, 12, 16, 20,
};
// clang-format on