diff --git a/asm/non_matching/npc23/sub_0806650C.inc b/asm/non_matching/npc23/sub_0806650C.inc deleted file mode 100644 index f545b4db..00000000 --- a/asm/non_matching/npc23/sub_0806650C.inc +++ /dev/null @@ -1,57 +0,0 @@ - .syntax unified - push {r4, r5, r6, r7, lr} - adds r3, r0, #0 - movs r4, #0 - ldr r1, _0806652C @ =gPlayerEntity - ldrh r5, [r1, #0x2e] - adds r7, r5, #0 - ldrh r2, [r1, #0x32] - adds r0, #0x80 - ldrh r0, [r0] - adds r0, #0x10 - adds r6, r1, #0 - cmp r2, r0 - bge _08066530 - movs r4, #4 - b _0806654C - .align 2, 0 -_0806652C: .4byte gPlayerEntity -_08066530: - adds r0, r3, #0 - adds r0, #0x7e - ldrh r1, [r0] - adds r0, r1, #2 - cmp r5, r0 - bge _0806653E - movs r4, #2 -_0806653E: - adds r0, r1, #6 - cmp r7, r0 - ble _08066546 - movs r4, #6 -_08066546: - cmp r4, #0 - bne _0806654C - strh r4, [r6, #0x24] -_0806654C: - ldrb r0, [r6, #0xc] - cmp r0, #0xf - beq _0806656A - cmp r4, #0 - bne _0806655A - movs r0, #0 - b _0806656C -_0806655A: - movs r0, #8 - movs r1, #0 - movs r2, #0 - bl sub_08078AC0 - strb r4, [r6, #0x14] - lsls r0, r4, #2 - strb r0, [r6, #0x15] -_0806656A: - movs r0, #1 -_0806656C: - pop {r4, r5, r6, r7, pc} - .align 2, 0 - .syntax divided diff --git a/assets/assets.json b/assets/assets.json index ce16dc72..7dd1364d 100644 --- a/assets/assets.json +++ b/assets/assets.json @@ -35976,31 +35976,6 @@ "size": 62, "type": "animation" }, - { - "path": "beedle/gUnk_0810C88C.bin", - "start": 1099916, - "size": 8 - }, - { - "path": "beedle/gUnk_0810C894.bin", - "start": 1099924, - "size": 8 - }, - { - "path": "beedle/gUnk_0810C89C.bin", - "start": 1099932, - "size": 56 - }, - { - "path": "beedle/gUnk_0810C8D4.bin", - "start": 1099988, - "size": 12 - }, - { - "path": "beedle/gUnk_0810C8F0.bin", - "start": 1100016, - "size": 120 - }, { "path": "animations/gSpriteAnimations_Brocco_0.bin", "start": 1100540, @@ -36025,11 +36000,6 @@ "size": 5, "type": "animation" }, - { - "path": "brocco/gUnk_0810CAAC.bin", - "start": 1100460, - "size": 80 - }, { "path": "animations/gSpriteAnimations_SittingPerson_0.bin", "start": 1101216, @@ -36194,11 +36164,6 @@ "size": 7, "type": "animation" }, - { - "path": "pina/gUnk_0810CE04.bin", - "start": 1101316, - "size": 80 - }, { "path": "guard/gUnk_0810F560.bin", "start": 1111392, @@ -36496,21 +36461,6 @@ "size": 8, "type": "animation" }, - { - "path": "maid/gUnk_0810F874.bin", - "start": 1112180, - "size": 24 - }, - { - "path": "maid/gUnk_0810F88C.bin", - "start": 1112204, - "size": 8 - }, - { - "path": "maid/gUnk_0810F894.bin", - "start": 1112212, - "size": 80 - }, { "path": "animations/gSpriteAnimations_Din_0.bin", "start": 1112428, @@ -36735,22 +36685,6 @@ "size": 40, "type": "animation" }, - { - "path": "stockwell/gUnk_0810FDA0_USA-JP-DEMO_USA-DEMO_JP.bin", - "variants": [ - "USA", - "JP", - "DEMO_USA", - "DEMO_JP" - ], - "start": 1113504, - "size": 4 - }, - { - "path": "stockwell/gUnk_0810FDB8.bin", - "start": 1113528, - "size": 16 - }, { "path": "animations/gSpriteAnimations_Talon_2.bin", "start": 1113824, @@ -36799,16 +36733,6 @@ "size": 17, "type": "animation" }, - { - "path": "talon/gUnk_0810FEB0.bin", - "start": 1113776, - "size": 12 - }, - { - "path": "talon/gUnk_0810FED8.bin", - "start": 1113816, - "size": 8 - }, { "path": "animations/gSpriteAnimations_Malon_0.bin", "start": 1113968, @@ -36893,11 +36817,6 @@ "size": 44, "type": "animation" }, - { - "path": "epona/gUnk_08110080.bin", - "start": 1114240, - "size": 8 - }, { "path": "animations/gSpriteAnimations_MilkCart_0.bin", "start": 1114400, @@ -36934,26 +36853,6 @@ "size": 9, "type": "animation" }, - { - "path": "ghostBrothers/gUnk_0811015C.bin", - "start": 1114460, - "size": 8 - }, - { - "path": "ghostBrothers/gUnk_08110188.bin", - "start": 1114504, - "size": 166 - }, - { - "path": "ghostBrothers/gUnk_0811022E.bin", - "start": 1114670, - "size": 70 - }, - { - "path": "ghostBrothers/gUnk_08110280.bin", - "start": 1114752, - "size": 128 - }, { "path": "animations/gSpriteAnimations_Smith_0.bin", "start": 1115108, diff --git a/data/const/npc/beedle.s b/data/const/npc/beedle.s deleted file mode 100644 index 4b053ebd..00000000 --- a/data/const/npc/beedle.s +++ /dev/null @@ -1,27 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - .align 2 - -gUnk_0810C88C:: @ 0810C88C - .incbin "beedle/gUnk_0810C88C.bin" - -gUnk_0810C894:: @ 0810C894 - .incbin "beedle/gUnk_0810C894.bin" - -gUnk_0810C89C:: @ 0810C89C - .incbin "beedle/gUnk_0810C89C.bin" - -gUnk_0810C8D4:: @ 0810C8D4 - .incbin "beedle/gUnk_0810C8D4.bin" - -gUnk_0810C8E0:: @ 0810C8E0 - .4byte sub_080632E0 - .4byte sub_08063314 - .4byte sub_0806336C - .4byte sub_08063390 - -gUnk_0810C8F0:: @ 0810C8F0 - .incbin "beedle/gUnk_0810C8F0.bin" - diff --git a/data/const/npc/brocco.s b/data/const/npc/brocco.s deleted file mode 100644 index 29bd4732..00000000 --- a/data/const/npc/brocco.s +++ /dev/null @@ -1,8 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - .align 2 - -gUnk_0810CAAC:: @ 0810CAAC - .incbin "brocco/gUnk_0810CAAC.bin" diff --git a/data/const/npc/epona.s b/data/const/npc/epona.s deleted file mode 100644 index e5271c7a..00000000 --- a/data/const/npc/epona.s +++ /dev/null @@ -1,15 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - .align 2 - -gUnk_0811006C:: @ 0811006C - .4byte sub_080659B8 - .4byte sub_080659F0 - .4byte sub_08065A00 - .4byte sub_08065A10 - .4byte sub_08065A34 - -gUnk_08110080:: @ 08110080 - .incbin "epona/gUnk_08110080.bin" diff --git a/data/const/npc/ghostBrothers.s b/data/const/npc/ghostBrothers.s deleted file mode 100644 index 26e7c8cb..00000000 --- a/data/const/npc/ghostBrothers.s +++ /dev/null @@ -1,35 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - .align 2 - -gUnk_0811015C:: @ 0811015C - .incbin "ghostBrothers/gUnk_0811015C.bin" - -gUnk_08110164:: @ 08110164 - .4byte sub_08065BF4 - .4byte sub_08065BF4 - .4byte sub_08065BF4 - .4byte sub_08065BF4 - .4byte sub_08065EBC - .4byte sub_08065EBC - -gUnk_0811017C:: @ 0811017C - .4byte sub_08065D18 - .4byte sub_08065D74 - .4byte sub_08065DB8 - -gUnk_08110188:: @ 08110188 - .incbin "ghostBrothers/gUnk_08110188.bin" - -gUnk_0811022E:: @ 0811022E - .incbin "ghostBrothers/gUnk_0811022E.bin" - -gUnk_08110274:: @ 08110274 - .4byte sub_08065D18 - .4byte sub_08065EDC - .4byte sub_08065F20 - -gUnk_08110280:: @ 08110280 - .incbin "ghostBrothers/gUnk_08110280.bin" diff --git a/data/const/npc/maid.s b/data/const/npc/maid.s deleted file mode 100644 index 6c8ae2c3..00000000 --- a/data/const/npc/maid.s +++ /dev/null @@ -1,14 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - .align 2 - -gUnk_0810F874:: @ 0810F874 - .incbin "maid/gUnk_0810F874.bin" - -gUnk_0810F88C:: @ 0810F88C - .incbin "maid/gUnk_0810F88C.bin" - -gUnk_0810F894:: @ 0810F894 - .incbin "maid/gUnk_0810F894.bin" diff --git a/data/const/npc/mailbox.s b/data/const/npc/mailbox.s deleted file mode 100644 index 72b8880a..00000000 --- a/data/const/npc/mailbox.s +++ /dev/null @@ -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 diff --git a/data/const/npc/malon.s b/data/const/npc/malon.s deleted file mode 100644 index 41570e1b..00000000 --- a/data/const/npc/malon.s +++ /dev/null @@ -1,14 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - .align 2 - -gUnk_0810FF5C:: @ 0810FF5C - .4byte sub_08065864 - .4byte sub_08065880 - -gUnk_0810FF64:: @ 0810FF64 - .4byte sub_08065888 - .4byte sub_080658BC - .4byte sub_08065900 diff --git a/data/const/npc/milkCart.s b/data/const/npc/milkCart.s deleted file mode 100644 index 3286faf9..00000000 --- a/data/const/npc/milkCart.s +++ /dev/null @@ -1,9 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - .align 2 - -gMilkCartBehaviors:: @ 08110118 - .4byte sub_08065B6C - .4byte sub_08065B9C diff --git a/data/const/npc/npc23.s b/data/const/npc/npc23.s deleted file mode 100644 index 873c7f80..00000000 --- a/data/const/npc/npc23.s +++ /dev/null @@ -1,13 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - .align 2 - -gUnk_081104C8:: @ 081104C8 - .4byte sub_080662F8 - .4byte sub_08066358 - .4byte nullsub_110 - .4byte sub_080663D4 - .4byte sub_0806643C - .4byte sub_08066474 diff --git a/data/const/npc/pina.s b/data/const/npc/pina.s deleted file mode 100644 index fbaff6c9..00000000 --- a/data/const/npc/pina.s +++ /dev/null @@ -1,9 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - .align 2 - -gUnk_0810CE04:: @ 0810CE04 - .incbin "pina/gUnk_0810CE04.bin" - diff --git a/data/const/npc/stockwell.s b/data/const/npc/stockwell.s deleted file mode 100644 index 6f23e1ba..00000000 --- a/data/const/npc/stockwell.s +++ /dev/null @@ -1,30 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - .align 2 - -.ifndef EU -gUnk_0810FDA0:: @ 0810FDA0 - .incbin "stockwell/gUnk_0810FDA0_USA-JP-DEMO_USA-DEMO_JP.bin" -.endif - -gUnk_0810FDA4:: @ 0810FDA4 - .4byte sub_08065080 - .4byte sub_080650CC - .4byte sub_080651AC - .4byte sub_080651D8 - .4byte sub_08065368 - -gUnk_0810FDB8:: @ 0810FDB8 - .incbin "stockwell/gUnk_0810FDB8.bin" - -gUnk_0810FDC8:: @ 0810FDC8 - .4byte sub_080651F8 - .4byte sub_0806522C - .4byte sub_08065250 - .4byte sub_0806528C - .4byte sub_080652B0 - .4byte sub_080652E4 - .4byte sub_08065314 - .4byte sub_08065338 diff --git a/data/const/npc/talon.s b/data/const/npc/talon.s deleted file mode 100644 index 1dc9e4e1..00000000 --- a/data/const/npc/talon.s +++ /dev/null @@ -1,22 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - .align 2 - -gUnk_0810FEB0:: @ 0810FEB0 - .incbin "talon/gUnk_0810FEB0.bin" - -gUnk_0810FEBC:: @ 0810FEBC - .4byte sub_08065570 - .4byte sub_0806559C - -gUnk_0810FEC4:: @ 0810FEC4 - .4byte sub_08065608 - .4byte sub_08065648 - .4byte sub_080656D4 - .4byte sub_080656A4 - .4byte sub_08065680 - -gUnk_0810FED8:: @ 0810FED8 - .incbin "talon/gUnk_0810FED8.bin" diff --git a/data/scripts/hyruleCastle/script_CastleMaid.inc b/data/scripts/hyruleCastle/script_CastleMaid.inc index 90f05aed..2ed329ca 100644 --- a/data/scripts/hyruleCastle/script_CastleMaid.inc +++ b/data/scripts/hyruleCastle/script_CastleMaid.inc @@ -5,7 +5,7 @@ SCRIPT_START script_CastleMaid SetAnimationState 0x0004 DoPostScriptAction 0x0000 DoPostScriptAction 0x000a - CallWithArg sub_08064644, sub_0806464C + CallWithArg CastleMaid_SetDialogFunc, sub_0806464C EndBlock script_0800B8D4: Wait 0x003c diff --git a/data/scripts/hyruleTown/script_MaidTown.inc b/data/scripts/hyruleTown/script_MaidTown.inc index bc708306..73a865f7 100644 --- a/data/scripts/hyruleTown/script_MaidTown.inc +++ b/data/scripts/hyruleTown/script_MaidTown.inc @@ -6,7 +6,7 @@ SCRIPT_START script_MaidTown DoPostScriptAction 0x0000 DoPostScriptAction 0x000a SetIntVariable sub_08064688 - Call sub_08064644 + Call CastleMaid_SetDialogFunc EndBlock script_08010446: Wait 0x003c diff --git a/include/player.h b/include/player.h index da70d4d1..d9c869f5 100644 --- a/include/player.h +++ b/include/player.h @@ -407,7 +407,7 @@ void PlayerSetNormalAndCollide(void); bool32 PlayerTryDropObject(ItemBehavior* arg0, u32 unk); void InitItemGetSequence(u32, u32, u32); void sub_0807B7D8(u32, u32, u32); -void sub_08078850(Entity*, u32, u32, void*); +void sub_08078850(Entity*, u32, u32, const void*); void sub_08079D84(void); u32 sub_0807953C(void); void sub_0807BB68(s16*, u32, u32); diff --git a/include/structures.h b/include/structures.h index 0b0dc185..0f77cac0 100644 --- a/include/structures.h +++ b/include/structures.h @@ -268,7 +268,7 @@ typedef struct { /*0x01*/ u8 unk_1; /*0x02*/ u8 unk_2; /*0x03*/ u8 unk_3; - /*0x04*/ u8* unk_4; + /*0x04*/ const u8* unk_4; /*0x08*/ Entity* entity; } struct_03003DF8; diff --git a/linker.ld b/linker.ld index 51e46ad6..7ee2924a 100644 --- a/linker.ld +++ b/linker.ld @@ -1175,22 +1175,20 @@ SECTIONS { data/animations/npc/pita.o(.rodata); src/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/const/npc/beedle.o(.rodata); + src/npc/beedle.o(.rodata); data/animations/npc/beedle.o(.rodata); src/npc/brocco.o(.rodata); - data/const/npc/brocco.o(.rodata); data/animations/npc/brocco.o(.rodata); data/const/npc/sittingPerson.o(.rodata); data/animations/npc/sittingPerson.o(.rodata); src/npc/pina.o(.rodata); - data/const/npc/pina.o(.rodata); data/animations/npc/pina.o(.rodata); data/const/npc/guard.o(.rodata); src/npc/guardWithSpear.o(.rodata); data/animations/npc/guardWithSpear.o(.rodata); - data/const/npc/maid.o(.rodata); + src/npc/castleMaid.o(.rodata); data/animations/npc/maid.o(.rodata); data/animations/npc/din.o(.rodata); data/animations/npc/nayru.o(.rodata); @@ -1199,21 +1197,21 @@ SECTIONS { data/animations/npc/sturgeon.o(.rodata); src/npc/tingleSiblings.o(.rodata); data/animations/npc/tingleSiblings.o(.rodata); - data/const/npc/stockwell.o(.rodata); + src/npc/stockwell.o(.rodata); data/animations/npc/stockwell.o(.rodata); - data/const/npc/talon.o(.rodata); + src/npc/talon.o(.rodata); data/animations/npc/talon.o(.rodata); - data/const/npc/malon.o(.rodata); + src/npc/malon.o(.rodata); data/animations/npc/malon.o(.rodata); - data/const/npc/epona.o(.rodata); + src/npc/epona.o(.rodata); data/animations/npc/epona.o(.rodata); - data/const/npc/milkCart.o(.rodata); + src/npc/milkCart.o(.rodata); data/animations/npc/milkCart.o(.rodata); - data/const/npc/ghostBrothers.o(.rodata); + src/npc/ghostBrothers.o(.rodata); data/animations/npc/ghostBrothers.o(.rodata); data/const/npc/smith.o(.rodata); data/animations/npc/smith.o(.rodata); - data/const/npc/npc23.o(.rodata); + src/npc/npc23.o(.rodata); data/const/npc/kingDaltus.o(.rodata); data/animations/npc/kingDaltus.o(.rodata); data/const/npc/ministerPotho.o(.rodata); diff --git a/src/npc/beedle.c b/src/npc/beedle.c index 002f3253..3660b074 100644 --- a/src/npc/beedle.c +++ b/src/npc/beedle.c @@ -8,16 +8,35 @@ #include "functions.h" typedef struct { - u32 unk_00; + s8 unk_00; + u8 unk_01; + u8 unk_02; + u8 unk_03; s8 unk_04; + s8 unk_05; + s8 unk_06; + s8 unk_07; } gUnk_0810C89C_struct; -extern u8 gUnk_0810C88C[]; -extern Hitbox gUnk_0810C894; -extern gUnk_0810C89C_struct gUnk_0810C89C[]; -extern SpriteLoadData gUnk_0810C8D4; -extern void (*gUnk_0810C8E0[])(Entity*); -extern u8 gUnk_0810C8F0[]; +void sub_080632E0(Entity* this); +void sub_08063314(Entity* this); +void sub_0806336C(Entity* this); +void sub_08063390(Entity* this); + +static const u8 gUnk_0810C88C[] = { + 0, 0x2d, 0x2c, 0x29, 0x2a, 0x2b, 0x2e, 0, +}; +static const Hitbox gUnk_0810C894 = { 0, 0, { 0, 0, 0, 0 }, 16, 6 }; +static const gUnk_0810C89C_struct gUnk_0810C89C[] = { + { 0, 0, 6, 6, 0, 0, 0, 0 }, { -24, 0, 6, 6, 0, 0, 0, 0 }, { -24, 16, 6, 6, 0, 0, 0, 0 }, + { -24, 32, 6, 6, 0, 0, 0, 0 }, { 24, 0, 6, 6, 0, 0, 0, 0 }, { 24, 16, 6, 6, 0, 0, 0, 0 }, + { 24, 32, 6, 6, 0, 0, 0, 0 }, +}; +static const SpriteLoadData gUnk_0810C8D4[] = { + { 0x3e, 0x31, 0x4 }, + { 0x203e, 0x31, 0x4 }, + { 0, 0, 0 }, +}; void sub_080632C8(Entity* this); void sub_08063410(Entity* this); @@ -33,11 +52,17 @@ void Beedle(Entity* this) { } void sub_080632C8(Entity* this) { + static void (*const gUnk_0810C8E0[])(Entity*) = { + sub_080632E0, + sub_08063314, + sub_0806336C, + sub_08063390, + }; gUnk_0810C8E0[this->action](this); } void sub_080632E0(Entity* this) { - if (LoadExtraSpriteData(this, &gUnk_0810C8D4) != 0) { + if (LoadExtraSpriteData(this, gUnk_0810C8D4) != 0) { InitializeAnimation(this, 0); sub_08078778(this); this->spriteSettings.draw = 1; @@ -94,12 +119,12 @@ void Beedle_Head(Entity* this) { void sub_08063410(Entity* this) { if (this->action == 0) { - if (LoadExtraSpriteData(this, &gUnk_0810C8D4) == 0) { + if (LoadExtraSpriteData(this, gUnk_0810C8D4) == 0) { return; } this->action++; if (this->type != 0) { - this->hitbox = &gUnk_0810C894; + this->hitbox = (Hitbox*)&gUnk_0810C894; this->type2 = 0; } sub_0807DD64(this); @@ -114,6 +139,48 @@ void sub_08063410(Entity* this) { } void sub_0806346C(Entity* this) { + static const u8 gUnk_0810C8F0[][6][4] = { + { + { 1, 1, 1, 1 }, + { 1, 1, 1, 1 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 4, 4, 4, 4 }, + { 4, 4, 4, 4 }, + }, + { + { 1, 1, 1, 1 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, + { 4, 4, 4, 4 }, + }, + { + { 2, 2, 2, 2 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 2 }, + { 0, 5, 0, 0 }, + { 0, 0, 0, 0 }, + { 5, 5, 5, 5 }, + }, + { + { 3, 3, 3, 3 }, + { 0, 0, 0, 0 }, + { 0, 0, 0, 3 }, + { 0, 6, 0, 0 }, + { 0, 0, 0, 0 }, + { 6, 6, 6, 6 }, + }, + { + { 3, 3, 3, 3 }, + { 3, 3, 3, 3 }, + { 3, 3, 3, 3 }, + { 6, 6, 6, 6 }, + { 6, 6, 6, 6 }, + { 6, 6, 6, 6 }, + }, + }; u8 bVar1; s32 iVar2; s32 iVar3; @@ -139,9 +206,9 @@ void sub_0806346C(Entity* this) { iVar3 >>= 4; iVar2 >>= 4; - bVar1 = gUnk_0810C8F0[(gPlayerEntity.animationState >> 1) + iVar3 * 4 + iVar2 * 0x18]; + bVar1 = gUnk_0810C8F0[iVar2][iVar3][gPlayerEntity.animationState >> 1]; if (bVar1 != this->type2) { - gUnk_0810C89C_struct* temp = &gUnk_0810C89C[bVar1]; + const gUnk_0810C89C_struct* temp = &gUnk_0810C89C[bVar1]; sub_08078850(this, 1, temp->unk_04, temp); this->type2 = bVar1; } diff --git a/src/npc/brocco.c b/src/npc/brocco.c index 680688f2..78e05325 100644 --- a/src/npc/brocco.c +++ b/src/npc/brocco.c @@ -9,8 +9,6 @@ void sub_0806355C(Entity*); void sub_08063584(Entity*); void sub_08063608(Entity*); -extern Dialog gUnk_0810CAAC[]; - void Brocco(Entity* this) { if ((this->flags & ENT_SCRIPTED) != 0) { sub_0806362C(this); @@ -100,6 +98,13 @@ void sub_0806362C(Entity* this) { } void sub_080636D8(Entity* this) { + static const Dialog gUnk_0810CAAC[] = { + { 0, 0, 1, 1, { 0, 0x2510 } }, { 0, 0, 1, 1, { 0, 0x2510 } }, { 5, 0, 3, 1, { 0x3424, 0x3423 } }, + { 5, 0, 3, 1, { 0x3424, 0x3423 } }, { 5, 0, 3, 1, { 0x351f, 0x351e } }, { 5, 0, 3, 1, { 0x361e, 0x361d } }, + { 5, 0, 3, 1, { 0x371f, 0x371e } }, { 5, 0, 3, 1, { 0x381f, 0x381e } }, { 5, 0, 3, 1, { 0x3919, 0x3918 } }, + { 5, 0, 3, 1, { 0x3919, 0x3918 } }, + }; + ShowNPCDialogue(this, &gUnk_0810CAAC[gSave.global_progress]); } diff --git a/src/npc/castleMaid.c b/src/npc/castleMaid.c index 2f17c380..701dfc2c 100644 --- a/src/npc/castleMaid.c +++ b/src/npc/castleMaid.c @@ -1,3 +1,4 @@ +#define NENT_DEPRECATED #include "entity.h" #include "script.h" #include "save.h" @@ -7,18 +8,18 @@ #include "manager.h" #include "functions.h" -extern Dialog gUnk_0810F894[]; +typedef struct { + Entity base; + void (*dialogFunc)(); + u16 field_0x6c; + u16 field_0x6e; +} CastleMaidEntity; -void sub_08064570(Entity* this); - -extern u16 gUnk_0810F88C[]; - -extern SpriteLoadData gUnk_0810F874[]; -extern u32 _call_via_r0(u32*); +void sub_08064570(CastleMaidEntity* this); void Maid(Entity* this) { if ((this->flags & ENT_SCRIPTED) != 0) { - sub_08064570(this); + sub_08064570((CastleMaidEntity*)this); } else { DeleteThisEntity(); } @@ -46,15 +47,18 @@ void Maid_Head(Entity* this) { sub_0807000C(this); } -void sub_08064570(Entity* this) { +void sub_08064570(CastleMaidEntity* this) { + static const SpriteLoadData gUnk_0810F874[] = { + { 0x46, 0x2f, 0x4 }, { 0x2046, 0x2f, 0x4 }, { 0, 0, 0 }, { 0, 0x2f, 0x4 }, { 0x4000, 0x2f, 0x4 }, { 0, 0, 0 }, + }; u32 tmp; u32 tmp2; u32 tmp3; - SpriteLoadData* data; + const SpriteLoadData* data; - switch (this->action) { + switch (super->action) { case 0: - tmp = this->id; + tmp = super->id; tmp ^= 0x16; if (tmp) { tmp3 = 1; @@ -62,29 +66,29 @@ void sub_08064570(Entity* this) { tmp3 = 0; } data = &gUnk_0810F874[tmp3 * 3]; - if (LoadExtraSpriteData(this, data) == 0) { + if (LoadExtraSpriteData(super, data) == 0) { return; } - this->action += 1; - this->timer = 0; - tmp2 = sub_0805ACC0(this); + super->action += 1; + super->timer = 0; + tmp2 = sub_0805ACC0(super); if (tmp2 == 0) { - this->field_0x6c.HWORD = this->x.HALF.HI; - this->field_0x6e.HWORD = this->y.HALF.HI; + this->field_0x6c = super->x.HALF.HI; + this->field_0x6e = super->y.HALF.HI; } else { - this->field_0x6c.HWORD = tmp2 >> 0x10; - this->field_0x6e.HWORD = tmp2; + this->field_0x6c = tmp2 >> 0x10; + this->field_0x6e = tmp2; } - *(u32*)&this->field_0x68 = 0; - sub_0807DD50(this); + this->dialogFunc = NULL; + sub_0807DD50(super); case 1: - sub_0807DD94(this, NULL); - if (this->interactType != 0) { - this->action += 1; - this->interactType = 0; - InitializeAnimation(this, sub_0806F5A4(GetFacingDirection(this, &gPlayerEntity))); - if (*(void**)&this->field_0x68 != NULL) { - _call_via_r0(*(void**)&this->field_0x68); + sub_0807DD94(super, NULL); + if (super->interactType != 0) { + super->action += 1; + super->interactType = 0; + InitializeAnimation(super, sub_0806F5A4(GetFacingDirection(super, &gPlayerEntity))); + if (this->dialogFunc != NULL) { + this->dialogFunc(); } } break; @@ -92,16 +96,22 @@ void sub_08064570(Entity* this) { if ((gMessage.doTextBox & 0x7f) != 0) { return; } - this->action = 1; + super->action = 1; break; } } -void sub_08064644(Entity* this, ScriptExecutionContext* context) { - *(u32*)&this->field_0x68 = context->intVariable; +void CastleMaid_SetDialogFunc(CastleMaidEntity* this, ScriptExecutionContext* context) { + this->dialogFunc = (void*)context->intVariable; } void sub_0806464C(Entity* this) { + static const u16 messageIndices[] = { + 0x105f, + 0x1060, + 0x1061, + 0, + }; s32 tmp; if (CheckGlobalFlag(TABIDACHI) != 0) { tmp = 2; @@ -111,14 +121,20 @@ void sub_0806464C(Entity* this) { } else { tmp = 1; } - MessageNoOverlap(gUnk_0810F88C[tmp], this); + MessageNoOverlap(messageIndices[tmp], this); } void sub_08064688(Entity* this) { + static const Dialog gUnk_0810F894[] = { + { 7, 0, 3, 1, { 0x3426, 0x3425 } }, { 7, 0, 3, 1, { 0x3426, 0x3425 } }, { 7, 0, 3, 1, { 0x3426, 0x3425 } }, + { 7, 0, 3, 1, { 0x3426, 0x3425 } }, { 7, 0, 3, 1, { 0x3521, 0x3520 } }, { 0, 0, 1, 1, { 0, 0x361f } }, + { 0, 0, 1, 1, { 0, 0x3720 } }, { 0, 0, 1, 1, { 0, 0x3820 } }, { 0, 0, 1, 1, { 0, 0x3820 } }, + { 0, 0, 1, 1, { 0, 0x3820 } }, + }; ShowNPCDialogue(this, &gUnk_0810F894[gSave.global_progress]); } -void sub_080646A4(Entity* this, ScriptExecutionContext* context) { +void sub_080646A4(CastleMaidEntity* this, ScriptExecutionContext* context) { u8 dir; s32 x, y; s32 diff; @@ -127,7 +143,7 @@ void sub_080646A4(Entity* this, ScriptExecutionContext* context) { context->unk_12 = (Random() & 0x3f) + 0x20; dir = Random() & 0x18; - switch (this->direction) { + switch (super->direction) { case 0: if (dir == 0x10) { dir = 0x8; @@ -149,34 +165,34 @@ void sub_080646A4(Entity* this, ScriptExecutionContext* context) { } break; } - this->direction = dir; - this->animationState = sub_0806F5B0(dir); - this->speed = 0x80; + super->direction = dir; + super->animationState = sub_0806F5B0(dir); + super->speed = 0x80; } context->postScriptActions |= 0x2; - ProcessMovement0(this); - x = this->x.HALF.HI; - diff = x - (s16)this->field_0x6c.HWORD; + ProcessMovement0(super); + x = super->x.HALF.HI; + diff = x - (s16)this->field_0x6c; if (diff > 0x10) { - this->x.HALF.HI = this->field_0x6c.HWORD + 0x10; + super->x.HALF.HI = this->field_0x6c + 0x10; context->unk_12 = 1; } if (diff < -0x10) { - this->x.HALF.HI = this->field_0x6c.HWORD - 0x10; + super->x.HALF.HI = this->field_0x6c - 0x10; context->unk_12 = 1; } - y = this->y.HALF.HI; - diff = y - (s16)this->field_0x6e.HWORD; + y = super->y.HALF.HI; + diff = y - (s16)this->field_0x6e; if (diff > 0x10) { - this->y.HALF.HI = this->field_0x6e.HWORD + 0x10; + super->y.HALF.HI = this->field_0x6e + 0x10; context->unk_12 = 1; } if (diff < -0x10) { - this->y.HALF.HI = this->field_0x6e.HWORD - 0x10; + super->y.HALF.HI = this->field_0x6e - 0x10; context->unk_12 = 1; } diff --git a/src/npc/epona.c b/src/npc/epona.c index b4840bbe..7673b726 100644 --- a/src/npc/epona.c +++ b/src/npc/epona.c @@ -7,12 +7,17 @@ void sub_08065A64(Entity* this); void sub_08065AA4(Entity*); - -extern void (*gUnk_0811006C[])(Entity*); -extern Dialog gUnk_08110080[]; +void sub_080659B8(Entity*); +void sub_080659F0(Entity*); +void sub_08065A00(Entity*); +void sub_08065A10(Entity*); +void sub_08065A34(Entity*); void Epona(Entity* this) { - gUnk_0811006C[this->action](this); + static void (*const actionFuncs[])(Entity*) = { + sub_080659B8, sub_080659F0, sub_08065A00, sub_08065A10, sub_08065A34, + }; + actionFuncs[this->action](this); sub_08065A64(this); sub_0806ED78(this); } @@ -51,7 +56,10 @@ void sub_08065A34(Entity* this) { } void sub_08065A50(Entity* this) { - ShowNPCDialogue(this, &gUnk_08110080[this->type]); + static const Dialog typeDialogs[] = { + { 0, 0, 6, 1, { 0x2017, 0x3f3c } }, + }; + ShowNPCDialogue(this, &typeDialogs[this->type]); } void sub_08065A64(Entity* this) { diff --git a/src/npc/ghostBrothers.c b/src/npc/ghostBrothers.c index 38846f47..fc641bba 100644 --- a/src/npc/ghostBrothers.c +++ b/src/npc/ghostBrothers.c @@ -5,30 +5,30 @@ #include "message.h" #include "npc.h" -extern void (*const gUnk_0811017C[])(Entity*); - -extern void (*const gUnk_08110274[])(Entity*); - -extern Dialog gUnk_08110280[]; - extern u32 gSpriteAnimations_GhostBrothers[]; -extern u32 gUnk_08110188; -extern s8 gUnk_0811015C[8]; - -extern u8 gUnk_0811022E[]; - void sub_08065C0C(Entity* this); -static EntityAction* const gUnk_08110164[]; +void sub_08065BF4(Entity* this); +void sub_08065EBC(Entity* this); +void sub_08065D18(Entity* this); +void sub_08065D74(Entity* this); +void sub_08065DB8(Entity* this); +void sub_08065D18(Entity* this); +void sub_08065EDC(Entity* this); +void sub_08065F20(Entity* this); void GhostBrothers(Entity* this) { + static const s8 gUnk_0811015C[8] = { -14, -16, -18, -20, -22, -20, -18, -16 }; + static EntityAction* const actionFuncs[] = { + sub_08065BF4, sub_08065BF4, sub_08065BF4, sub_08065BF4, sub_08065EBC, sub_08065EBC, + }; if (this->flags & ENT_SCRIPTED) { sub_08065C0C(this); } else { - gUnk_08110164[this->type](this); + actionFuncs[this->type](this); if (this->type < 3) { - s8* ptr = gUnk_0811015C; + const s8* ptr = gUnk_0811015C; u32 subtimer = this->subtimer++; this->z.HALF_U.HI = *(ptr + (((subtimer << 0x18) >> 0x1b) & 0x7)); } @@ -36,9 +36,25 @@ void GhostBrothers(Entity* this) { } void sub_08065BF4(Entity* this) { - gUnk_0811017C[this->action](this); + static void (*const actionFuncs[])(Entity*) = { + sub_08065D18, + sub_08065D74, + sub_08065DB8, + }; + actionFuncs[this->action](this); } +static const u16 gUnk_08110188[] = { 0x1000, 0x4, 0xf01, 0x4, 0xe02, 0x4, 0xd03, 0x4, 0xc04, 0x8, 0xd03, 0x4, + 0xe02, 0x4, 0xf01, 0x4, 0x1000, 0x14, 0xf01, 0x4, 0xe02, 0x4, 0xd03, 0x4, + 0xc04, 0x4, 0xb05, 0x4, 0xa06, 0x4, 0x907, 0x4, 0x808, 0x8, 0x907, 0x4, + 0xa06, 0x4, 0xb05, 0x4, 0xc04, 0x4, 0xd03, 0x4, 0xe02, 0x4, 0xf01, 0x4, + 0x1000, 0x14, 0xf01, 0x4, 0xe02, 0x4, 0xd03, 0x4, 0xc04, 0x4, 0xb05, 0x4, + 0xa06, 0x4, 0x907, 0x4, 0x808, 0x4, 0x709, 0x4, 0x60a, 0x4, 0x50b, 0x4, + 0x40c, 0x4, 0x30d, 0x4, 0x20e, 0x4, 0x10f, 0x4, 0x10, 0x1e, 0xffff }; +static const u16 gUnk_0811022E[] = { 0x10, 0x2, 0x10f, 0x2, 0x20e, 0x2, 0x30d, 0x2, 0x40c, 0x2, 0x50b, 0x2, + 0x60a, 0x2, 0x709, 0x2, 0x808, 0x2, 0x907, 0x2, 0xa06, 0x2, 0xb05, 0x2, + 0xc04, 0x2, 0xd03, 0x2, 0xe02, 0x2, 0xf01, 0x2, 0x1000, 0x2, 0xffff }; + void sub_08065C0C(Entity* this) { u16* puVar3; @@ -89,7 +105,7 @@ void sub_08065CCC(Entity* this) { this->action = 3; this->timer = 0x1e; this->spriteRendering.alphaBlend = 1; - *(u32**)&this->field_0x6c = (u32*)gUnk_0811022E; + *(const u16**)&this->field_0x6c = gUnk_0811022E; gScreen.controls.layerFXControl = 0x3f40; gScreen.controls.alphaBlend = 0x10; } @@ -105,7 +121,7 @@ void sub_08065D18(Entity* this) { this->subtimer = 0; this->spriteSettings.draw = 1; this->spriteRendering.alphaBlend = 1; - *(u32**)&this->field_0x6c = &gUnk_08110188; + *(const u16**)&this->field_0x6c = gUnk_08110188; SetDefaultPriority(this, PRIO_MESSAGE); InitAnimationForceUpdate(this, 2); gScreen.controls.layerFXControl = 0x3f40; @@ -161,7 +177,7 @@ void sub_08065DB8(Entity* this) { if ((gMessage.doTextBox & 0x7f) == 0) { this->subAction++; this->timer = 0x1e; - *(u8**)&this->field_0x6c = gUnk_0811022E; + *(const u16**)&this->field_0x6c = gUnk_0811022E; } break; } @@ -185,7 +201,12 @@ void sub_08065DB8(Entity* this) { } void sub_08065EBC(Entity* this) { - gUnk_08110274[this->action](this); + static void (*const actionFuncs[])(Entity*) = { + sub_08065D18, + sub_08065EDC, + sub_08065F20, + }; + actionFuncs[this->action](this); sub_0806ED78(this); } @@ -217,11 +238,29 @@ void sub_08065F20(Entity* this) { } void sub_08065F64(Entity* this) { + static const Dialog dialogs[][8] = { + { { 0, 0, 1, 1, { 0, 0x3f31 } }, + { 0, 0, 1, 1, { 0, 0x3f31 } }, + { 0, 0, 1, 1, { 0, 0x3f31 } }, + { 0, 0, 1, 1, { 0, 0x3f31 } }, + { 0, 0, 1, 1, { 0, 0x3f31 } }, + { 0, 0, 1, 1, { 0, 0x3f31 } }, + { 0, 0, 1, 1, { 0, 0x3f31 } }, + { 0, 0, 1, 1, { 0, 0x3f31 } } }, + { { 4, 0, 3, 1, { 0x3417, 0x3416 } }, + { 4, 0, 3, 1, { 0x3417, 0x3416 } }, + { 4, 0, 3, 1, { 0x3513, 0x3512 } }, + { 4, 0, 3, 1, { 0x3613, 0x3612 } }, + { 4, 0, 3, 1, { 0x3713, 0x3712 } }, + { 4, 0, 3, 1, { 0x3813, 0x3812 } }, + { 4, 0, 3, 1, { 0x3912, 0x3911 } }, + { 0, 0, 1, 1, { 0, 0x3A03 } } }, + }; s32 tmp = gSave.global_progress - 2; if (tmp < 0) { tmp = 0; } - ShowNPCDialogue(this, gUnk_08110280 + this->type * 8 + tmp); + ShowNPCDialogue(this, &dialogs[this->type][tmp]); } void GhostBrothers_Fusion(Entity* this) { diff --git a/src/npc/mailbox.c b/src/npc/mailbox.c index 1f7c7835..5c92eefc 100644 --- a/src/npc/mailbox.c +++ b/src/npc/mailbox.c @@ -4,11 +4,19 @@ #include "effects.h" #include "npc.h" -extern void sub_08063280(Entity*, u32); - -extern void (*gMailboxBehaviors[4])(Entity*); +void sub_08063280(Entity*); +void sub_08063210(Entity*); +void sub_08063220(Entity*); +void sub_08063254(Entity*); +void sub_08063278(Entity*); void Mailbox(Entity* this) { + static void (*const gMailboxBehaviors[4])(Entity*) = { + sub_08063210, + sub_08063220, + sub_08063254, + sub_08063278, + }; gMailboxBehaviors[this->action](this); if (this->action != 0) { @@ -34,30 +42,28 @@ void sub_08063220(Entity* this) { if (this->animIndex != bVar1) { InitAnimationForceUpdate(this, bVar1); } else { - sub_08063280(this, bVar1); + sub_08063280(this); } } -void sub_08063254(Entity* this, u32 unused) { - sub_08063280(this, unused); +void sub_08063254(Entity* this) { + sub_08063280(this); if ((this->frame & ANIM_DONE) != 0) { this->action = 3; MessageFromTarget(0); } } -void sub_08063278(Entity* this, u32 unused) { - sub_08063280(this, unused); +void sub_08063278(Entity* this) { + sub_08063280(this); } -void sub_08063280(Entity* this, u32 unused) { - Entity* e; // r4@1 - u8 var; // r2@1 +void sub_08063280(Entity* this) { + u8 var; // r2@1 - e = this; - UpdateAnimationSingleFrame(e); - var = e->frame & 0x7F; - e->frame ^= var; + UpdateAnimationSingleFrame(this); + var = this->frame & ~ANIM_DONE; + this->frame ^= var; if (var == 2) - CreateFx(e, FX_MAILBOX_UNUSED, 0); + CreateFx(this, FX_MAILBOX_UNUSED, 0); } diff --git a/src/npc/malon.c b/src/npc/malon.c index 2a3b2fa1..d38be5aa 100644 --- a/src/npc/malon.c +++ b/src/npc/malon.c @@ -3,14 +3,26 @@ #include "script.h" #include "npc.h" -extern void (*gUnk_0810FF5C[])(Entity* this); -extern void (*gUnk_0810FF64[])(Entity* this); +void sub_08065864(Entity* this); +void sub_08065880(Entity* this); +void sub_08065888(Entity* this); +void sub_080658BC(Entity* this); +void sub_08065900(Entity* this); void Malon(Entity* this) { + static void (*const actionFuncs[])(Entity * this) = { + sub_08065864, + sub_08065880, + }; + static void (*const scriptedActionFuncs[])(Entity * this) = { + sub_08065888, + sub_080658BC, + sub_08065900, + }; if (this->flags & ENT_SCRIPTED) { - gUnk_0810FF64[this->action](this); + scriptedActionFuncs[this->action](this); } else { - gUnk_0810FF5C[this->action](this); + actionFuncs[this->action](this); if (this->action != 0) { sub_0806ED78(this); } diff --git a/src/npc/milkCart.c b/src/npc/milkCart.c index 1493d385..5736b5b6 100644 --- a/src/npc/milkCart.c +++ b/src/npc/milkCart.c @@ -1,9 +1,14 @@ #include "entity.h" #include "npc.h" -extern void (*gMilkCartBehaviors[2])(Entity*); +void sub_08065B6C(Entity*); +void sub_08065B9C(Entity*); void MilkCart(Entity* ent) { + static void (*const gMilkCartBehaviors[2])(Entity*) = { + sub_08065B6C, + sub_08065B9C, + }; gMilkCartBehaviors[ent->action](ent); sub_0806ED78(ent); } diff --git a/src/npc/npc23.c b/src/npc/npc23.c index c684da71..68f785e6 100644 --- a/src/npc/npc23.c +++ b/src/npc/npc23.c @@ -5,16 +5,23 @@ #include "message.h" #include "npc.h" -extern void (*const gUnk_081104C8[])(Entity*); - bool32 sub_0806650C(Entity*); void sub_08066490(Entity*, Entity*); void sub_08066570(Entity* this); +void sub_080662F8(Entity* this); +void sub_08066358(Entity* this); +void nullsub_110(Entity* this); +void sub_080663D4(Entity* this); +void sub_0806643C(Entity* this); +void sub_08066474(Entity* this); void NPC23(Entity* this) { - gUnk_081104C8[this->action](this); + static void (*const actionFuncs[])(Entity*) = { + sub_080662F8, sub_08066358, nullsub_110, sub_080663D4, sub_0806643C, sub_08066474, + }; + actionFuncs[this->action](this); sub_0806ED78(this); } @@ -58,7 +65,7 @@ void sub_08066358(Entity* this) { sub_08066570(this); } -void nullsub_110(void) { +void nullsub_110(Entity* this) { } void sub_080663D4(Entity* this) { @@ -93,7 +100,7 @@ void sub_0806643C(Entity* this) { GetNextFrame(this); } -void sub_08066474(void) { +void sub_08066474(Entity* this) { if (gPlayerEntity.action != PLAYER_ROOM_EXIT) { gPauseMenuOptions.disabled = 0; } @@ -101,10 +108,10 @@ void sub_08066474(void) { ASM_FUNC("asm/non_matching/npc23/sub_08066490.inc", void sub_08066490(Entity* this, Entity* entity)) -// px needs to be used in both r5 and r7 -NONMATCH("asm/non_matching/npc23/sub_0806650C.inc", bool32 sub_0806650C(Entity* this)) { +bool32 sub_0806650C(Entity* this) { u32 dir = 0; s32 px = gPlayerEntity.x.HALF_U.HI; + s32 px2 = px; s32 py = gPlayerEntity.y.HALF_U.HI; if (py < this->field_0x80.HWORD + 16) { @@ -113,7 +120,7 @@ NONMATCH("asm/non_matching/npc23/sub_0806650C.inc", bool32 sub_0806650C(Entity* if (px < this->field_0x7c.HALF_U.HI + 2) { dir = 2; } - if (px > this->field_0x7c.HALF_U.HI + 6) { + if (px2 > this->field_0x7c.HALF_U.HI + 6) { dir = 6; } if (dir == 0) { @@ -131,21 +138,37 @@ NONMATCH("asm/non_matching/npc23/sub_0806650C.inc", bool32 sub_0806650C(Entity* } return 1; } -END_NONMATCH NONMATCH("asm/non_matching/npc23/sub_08066570.inc", void sub_08066570(Entity* this)) { - if (this->frame & ANIM_DONE) { + u32 direction; + u32 dir1, dir2; + bool32 cond; + if ((this->frame & ANIM_DONE) == 0) { return; } - if (this->action == 3 && sub_0806FC80(this, &gPlayerEntity, 0x50)) { - u32 direction = GetFacingDirection(this, &gPlayerEntity); - bool32 cond = (this->direction & 0x18) == (direction & 0x18) && ((this->direction + 5) & 7) < 3 && - ((direction + 5) & 7) < 3; - if (!cond) { - this->direction = direction; - InitializeAnimation(this, ((u32)(this->direction + 4) & 0x18) >> 3); + if (this->action == 3 || !sub_0806FC80(this, &gPlayerEntity, 0x50)) { + return; + } + + direction = GetFacingDirection(this, &gPlayerEntity); + cond = TRUE; + + dir2 = (direction & 0x18); + dir1 = (this->direction & 0x18); + if (dir1 == dir2) { + dir1 = (direction + 5) & 7; + dir2 = (this->direction + 5) & 7; + if (dir2 < 3 && dir1 < 3) { + cond = FALSE; } } + if (cond) { + this->direction = direction; + direction += 4; + direction &= 0x18; + direction >>= 3; + InitializeAnimation(this, direction); + } } END_NONMATCH diff --git a/src/npc/pina.c b/src/npc/pina.c index 17473005..a6ff993e 100644 --- a/src/npc/pina.c +++ b/src/npc/pina.c @@ -11,8 +11,6 @@ void sub_08063A98(Entity* this); void sub_08063AC0(Entity* this); void sub_08063B44(Entity* this); -extern Dialog gUnk_0810CE04[]; - void Pina(Entity* this) { if ((this->flags & ENT_SCRIPTED) != 0) { sub_08063B68(this); @@ -137,6 +135,12 @@ void sub_08063C74(void) { } void sub_08063C90(Entity* this) { + static const Dialog gUnk_0810CE04[] = { + { 6, 0, 3, 1, { 0x3422, 0x3421 } }, { 6, 0, 3, 1, { 0x3422, 0x3421 } }, { 6, 0, 3, 1, { 0x3422, 0x3421 } }, + { 6, 0, 3, 1, { 0x3422, 0x3421 } }, { 6, 0, 3, 1, { 0x351d, 0x351c } }, { 6, 0, 3, 1, { 0x361c, 0x361b } }, + { 6, 0, 3, 1, { 0x371d, 0x371c } }, { 6, 0, 3, 1, { 0x381d, 0x381c } }, { 6, 0, 3, 1, { 0x3917, 0x3916 } }, + { 6, 0, 3, 1, { 0x3917, 0x3916 } }, + }; ShowNPCDialogue(this, &gUnk_0810CE04[gSave.global_progress]); } diff --git a/src/npc/stockwell.c b/src/npc/stockwell.c index be0ce8e2..eec88d55 100644 --- a/src/npc/stockwell.c +++ b/src/npc/stockwell.c @@ -8,18 +8,35 @@ #include "item.h" #include "game.h" -extern void (*const gUnk_0810FDC8[])(Entity*); -extern void (*const gUnk_0810FDA4[])(Entity*); +#ifndef EU +static const u8 gUnk_0810FDA0[] = { 0, 8, 10, 16 }; +#endif + extern u16 script_StockwellBuy[]; extern u16 script_StockwellDogFood[]; -extern u8 gUnk_0810FDB8[]; extern void InitScriptExecutionContext(ScriptExecutionContext* context, u16* script); -extern u32 gUnk_0810FDA0; extern u16 script_Stockwell; +void sub_08065080(Entity*); +void sub_080650CC(Entity*); +void sub_080651AC(Entity*); +void sub_080651D8(Entity*); +void sub_08065368(Entity*); +void sub_080651F8(Entity*); +void sub_0806522C(Entity*); +void sub_08065250(Entity*); +void sub_0806528C(Entity*); +void sub_080652B0(Entity*); +void sub_080652E4(Entity*); +void sub_08065314(Entity*); +void sub_08065338(Entity*); + void Stockwell(Entity* this) { - gUnk_0810FDA4[this->action](this); + static void (*const actionFuncs[])(Entity*) = { + sub_08065080, sub_080650CC, sub_080651AC, sub_080651D8, sub_08065368, + }; + actionFuncs[this->action](this); ExecuteScript(this, *(ScriptExecutionContext**)&this->cutsceneBeh); sub_0806ED78(this); } @@ -40,6 +57,7 @@ void sub_08065080(Entity* this) { } void sub_080650CC(Entity* this) { + static const u8 gUnk_0810FDB8[] = { 4, 6, 6, 5, 6, 6, 6, 5, 6, 6, 6, 5, 6, 6, 6, 5 }; u32 bVar2; u32 confirmMsgId; u32 itemPrice; @@ -52,7 +70,7 @@ void sub_080650CC(Entity* this) { bVar2 = this->frame & 0x20; if ((bVar2 == 0) && (this->interactType != 0)) { this->interactType = bVar2; - this->action = this->action + 1; + this->action++; InitializeAnimation(this, 7); if (gRoomVars.shopItemType == 0) { confirmMsgId = 0x2c01; @@ -85,8 +103,11 @@ void sub_080651AC(Entity* this) { } void sub_080651D8(Entity* this) { + static void (*const subActionFuncs[])(Entity*) = { + sub_080651F8, sub_0806522C, sub_08065250, sub_0806528C, sub_080652B0, sub_080652E4, sub_08065314, sub_08065338, + }; GetNextFrame(this); - gUnk_0810FDC8[this->subAction](this); + subActionFuncs[this->subAction](this); } void sub_080651F8(Entity* this) { diff --git a/src/npc/talon.c b/src/npc/talon.c index c9f09dad..67845700 100644 --- a/src/npc/talon.c +++ b/src/npc/talon.c @@ -2,24 +2,40 @@ #include "functions.h" #include "item.h" -extern void (*gUnk_0810FEC4[])(Entity* this); -extern void (*gUnk_0810FEBC[])(Entity* this); -extern SpriteLoadData gUnk_0810FEB0; +static const SpriteLoadData gUnk_0810FEB0[] = { + { 0x4b, 0x8b, 0 }, + { 0x4b, 0x8b, 0 }, + { 0, 0, 0 }, +}; + extern u8 script_TalonGotKey; -extern u8 gUnk_0810FED8[]; void sub_0806574C(Entity* this); +void sub_08065570(Entity* this); +void sub_0806559C(Entity* this); +void sub_08065608(Entity* this); +void sub_08065648(Entity* this); +void sub_080656D4(Entity* this); +void sub_080656A4(Entity* this); +void sub_08065680(Entity* this); void Talon(Entity* this) { + static void (*const actionFuncs[])(Entity * this) = { + sub_08065570, + sub_0806559C, + }; + static void (*const scriptedActionFuncs[])(Entity * this) = { + sub_08065608, sub_08065648, sub_080656D4, sub_080656A4, sub_08065680, + }; if (this->flags & ENT_SCRIPTED) { - gUnk_0810FEC4[this->action](this); + scriptedActionFuncs[this->action](this); } else { - gUnk_0810FEBC[this->action](this); + actionFuncs[this->action](this); } } void sub_08065570(Entity* this) { - if (LoadExtraSpriteData(this, &gUnk_0810FEB0) != 0) { + if (LoadExtraSpriteData(this, gUnk_0810FEB0) != 0) { InitializeAnimation(this, 0); sub_08078778(this); this->action = 1; @@ -59,7 +75,7 @@ void sub_0806559C(Entity* this) { } void sub_08065608(Entity* this) { - if (LoadExtraSpriteData(this, &gUnk_0810FEB0) != 0) { + if (LoadExtraSpriteData(this, gUnk_0810FEB0) != 0) { this->action = 1; this->spriteSettings.draw = 1; this->field_0x68.HALF.LO = sub_0801E99C(this); @@ -129,6 +145,9 @@ void sub_0806574C(Entity* this) { } void sub_08065780(Entity* this, ScriptExecutionContext* context) { + static const u8 gUnk_0810FED8[] = { + 10, 20, 30, 18, 28, 38, 12, 24, + }; u32 rand; rand = Random(); @@ -145,7 +164,7 @@ void Talon_Head(Entity* this) { void Talon_Fusion(Entity* this) { if (this->action == 0) { - if (LoadExtraSpriteData(this, &gUnk_0810FEB0) != 0) { + if (LoadExtraSpriteData(this, gUnk_0810FEB0) != 0) { this->action++; this->spriteSettings.draw = 1; InitializeAnimation(this, 6); diff --git a/src/playerUtils.c b/src/playerUtils.c index 2e5da41e..d5062e2a 100644 --- a/src/playerUtils.c +++ b/src/playerUtils.c @@ -875,7 +875,7 @@ s32 sub_08078828(Entity* ent) { return iVar1; } -void sub_08078850(Entity* arg0, u32 arg1, u32 arg2, void* arg3) { +void sub_08078850(Entity* arg0, u32 arg1, u32 arg2, const void* arg3) { s32 iVar1; iVar1 = sub_08078904(arg0);