summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoroctorock <79596758+octorock@users.noreply.github.com>2023-06-17 11:08:13 +0200
committeroctorock <79596758+octorock@users.noreply.github.com>2023-06-17 11:08:13 +0200
commitf9da6344273ac86d6fd9219fac2710c968eeab37 (patch)
treebd83d094d1d1fbc7f16b7f2c025cb77ca796bac2
parentc317fe3f18325fec54c0d76df450f132945449f7 (diff)
Extract player macros
-rw-r--r--assets/assets.json55
-rw-r--r--data/data_080046A4.s41
-rw-r--r--data/scripts/cutscene/introCeremony/script_Npc4EMonsters.inc4
-rw-r--r--data/scripts/cutscene/introCeremony/script_Npc4EVaatiAttacking.inc4
-rw-r--r--data/scripts/cutscene/introTown/script_Npc4EIntroTown.inc4
-rw-r--r--data/scripts/sanctuary/script_Npc4EThirdSanctuary.inc4
-rw-r--r--include/player.h2
-rw-r--r--linker.ld1
-rw-r--r--src/code_0805EC04.c6
-rw-r--r--src/data/data_080046A4.c65
-rw-r--r--src/npc/bladeBrothers.c32
-rw-r--r--src/playerUtils.c8
12 files changed, 97 insertions, 129 deletions
diff --git a/assets/assets.json b/assets/assets.json
index a9a152e7..56e7228f 100644
--- a/assets/assets.json
+++ b/assets/assets.json
@@ -976,61 +976,6 @@
"size": 384
},
{
- "path": "code_080043E8/gUnk_080049D6.bin",
- "start": 18902,
- "size": 32
- },
- {
- "path": "code_080043E8/gUnk_080049F6.bin",
- "start": 18934,
- "size": 8
- },
- {
- "path": "code_080043E8/gUnk_080049FE.bin",
- "start": 18942,
- "size": 14
- },
- {
- "path": "code_080043E8/gUnk_08004A0C.bin",
- "start": 18956,
- "size": 10
- },
- {
- "path": "code_080043E8/gUnk_08004A16.bin",
- "start": 18966,
- "size": 14
- },
- {
- "path": "code_080043E8/gUnk_08004A24.bin",
- "start": 18980,
- "size": 14
- },
- {
- "path": "code_080043E8/gUnk_08004A32.bin",
- "start": 18994,
- "size": 22
- },
- {
- "path": "code_080043E8/gUnk_08004A48.bin",
- "start": 19016,
- "size": 42
- },
- {
- "path": "code_080043E8/gUnk_08004A72.bin",
- "start": 19058,
- "size": 26
- },
- {
- "path": "code_080043E8/gUnk_08004A8C.bin",
- "start": 19084,
- "size": 26
- },
- {
- "path": "code_080043E8/gUnk_08004AA6.bin",
- "start": 19110,
- "size": 70
- },
- {
"path": "animations/gSpriteAnimations_1_0.bin",
"start": 19180,
"size": 5,
diff --git a/data/data_080046A4.s b/data/data_080046A4.s
deleted file mode 100644
index bca2f8f1..00000000
--- a/data/data_080046A4.s
+++ /dev/null
@@ -1,41 +0,0 @@
- .include "asm/macros.inc"
- .include "constants/constants.inc"
-
- .section .rodata
-@ .align 2
-
-
-@ TODO PlayerMacros
-
-gUnk_080049D6:: @ 080049D6
- .incbin "code_080043E8/gUnk_080049D6.bin"
-
-gUnk_080049F6:: @ 080049F6
- .incbin "code_080043E8/gUnk_080049F6.bin"
-
-gUnk_080049FE:: @ gUnk_080049FE
- .incbin "code_080043E8/gUnk_080049FE.bin"
-
-gUnk_08004A0C:: @ 08004A0C
- .incbin "code_080043E8/gUnk_08004A0C.bin"
-
-gUnk_08004A16:: @ 08004A16
- .incbin "code_080043E8/gUnk_08004A16.bin"
-
-gUnk_08004A24:: @ 08004A24
- .incbin "code_080043E8/gUnk_08004A24.bin"
-
-gUnk_08004A32:: @ 08004A32
- .incbin "code_080043E8/gUnk_08004A32.bin"
-
-gUnk_08004A48:: @ 08004A48
- .incbin "code_080043E8/gUnk_08004A48.bin"
-
-gUnk_08004A72:: @ 08004A72
- .incbin "code_080043E8/gUnk_08004A72.bin"
-
-gUnk_08004A8C:: @ 08004A8C
- .incbin "code_080043E8/gUnk_08004A8C.bin"
-
-gUnk_08004AA6:: @ 08004AA6
- .incbin "code_080043E8/gUnk_08004AA6.bin"
diff --git a/data/scripts/cutscene/introCeremony/script_Npc4EMonsters.inc b/data/scripts/cutscene/introCeremony/script_Npc4EMonsters.inc
index eb566324..e378d0f2 100644
--- a/data/scripts/cutscene/introCeremony/script_Npc4EMonsters.inc
+++ b/data/scripts/cutscene/introCeremony/script_Npc4EMonsters.inc
@@ -30,7 +30,7 @@ SCRIPT_START script_Npc4EMonsters
Call NPC4E_SaveEquippedItems
Call SetPlayerActionNormal
CallWithArg EquipItem, ITEM_SHIELD
- CallWithArg SetPlayerMacro, gUnk_080049F6
+ CallWithArg SetPlayerMacro, gPlayerMacroProtectWithShield
SetScrollSpeed 1
SetEntityPositionRelative 0x01f8, 0x0068
SetSyncFlag 0x00000004
@@ -41,7 +41,7 @@ SCRIPT_START script_Npc4EMonsters
PlaySound SFX_1C3
SetSyncFlag 0x20000000
Wait 0x0078
- CallWithArg SetPlayerMacro, 0x00000000
+ CallWithArg SetPlayerMacro, 0
Call NPC4E_RestoreEquippedItems
SetSyncFlag 0x40000000
SetSyncFlag 0x00000010
diff --git a/data/scripts/cutscene/introCeremony/script_Npc4EVaatiAttacking.inc b/data/scripts/cutscene/introCeremony/script_Npc4EVaatiAttacking.inc
index d9a9df96..0ce97624 100644
--- a/data/scripts/cutscene/introCeremony/script_Npc4EVaatiAttacking.inc
+++ b/data/scripts/cutscene/introCeremony/script_Npc4EVaatiAttacking.inc
@@ -10,11 +10,11 @@ SCRIPT_START script_Npc4EVaatiAttacking
Call NPC4E_SaveEquippedItems
Call SetPlayerActionNormal
CallWithArg EquipItem, ITEM_SHIELD
- CallWithArg SetPlayerMacro, gUnk_080049F6
+ CallWithArg SetPlayerMacro, gPlayerMacroProtectWithShield
Wait 0x001e
SetSyncFlag 0x00000100
WaitForSyncFlagAndClear 0x00000200
- CallWithArg SetPlayerMacro, 0x00000000
+ CallWithArg SetPlayerMacro, 0
Call NPC4E_RestoreEquippedItems
Wait 0x003c
SetSyncFlag 0x08000000
diff --git a/data/scripts/cutscene/introTown/script_Npc4EIntroTown.inc b/data/scripts/cutscene/introTown/script_Npc4EIntroTown.inc
index 14a92e0c..0b1e0424 100644
--- a/data/scripts/cutscene/introTown/script_Npc4EIntroTown.inc
+++ b/data/scripts/cutscene/introTown/script_Npc4EIntroTown.inc
@@ -152,14 +152,14 @@ SCRIPT_START script_Npc4EIntroTown
CallWithArg EquipItem, ITEM_SHIELD
SetIntVariable 0x000000ff
Call sub_0807F5B0
- CallWithArg SetPlayerMacro, gUnk_080049D6
+ CallWithArg SetPlayerMacro, gPlayerMacroTryOutShield
Wait 0x00b7
SetIntVariable 0x00000000
Call sub_0807F5B0
MessageFromTargetPos TEXT_PROLOGUE, 0x2c, 0x0000
WaitUntilTextboxCloses
@ Give control back to the player
- CallWithArg SetPlayerMacro, 0x00000000
+ CallWithArg SetPlayerMacro, 0
Call NPC4E_RestoreEquippedItems
SetScrollSpeed 4
CameraTargetPlayer
diff --git a/data/scripts/sanctuary/script_Npc4EThirdSanctuary.inc b/data/scripts/sanctuary/script_Npc4EThirdSanctuary.inc
index ffb033f9..3e99529d 100644
--- a/data/scripts/sanctuary/script_Npc4EThirdSanctuary.inc
+++ b/data/scripts/sanctuary/script_Npc4EThirdSanctuary.inc
@@ -85,9 +85,9 @@ script_080138D0:
.endif
Call NPC4E_SaveEquippedItems
CallWithArg EquipItem, 0x00010001
- CallWithArg SetPlayerMacro, gUnk_080049FE
+ CallWithArg SetPlayerMacro, gPlayerMacroSanctuary
Wait 0x00c8
- CallWithArg SetPlayerMacro, 0x00000000
+ CallWithArg SetPlayerMacro, 0
Call NPC4E_RestoreEquippedItems
script_08013A8E:
.ifndef EU
diff --git a/include/player.h b/include/player.h
index 1f338872..736e62a9 100644
--- a/include/player.h
+++ b/include/player.h
@@ -232,7 +232,7 @@ typedef struct {
typedef struct {
u16 flags;
u16 keys;
-} PlayerMacroEntry;
+} PlayerMacroEntry ALIGNED(2);
typedef enum {
PLAYER_INPUT_1 = 0x1, // A
diff --git a/linker.ld b/linker.ld
index 2c6938b1..5228c36b 100644
--- a/linker.ld
+++ b/linker.ld
@@ -243,7 +243,6 @@ SECTIONS {
asm/src/code_08003FC4.o(.text);
asm/src/code_080043E8.o(.text);
src/data/data_080046A4.o(.rodata);
- data/data_080046A4.o(.rodata);
data/gfx/link_animations.o(.rodata);
src/data/mapVvvToSurfaceType.o(.rodata);
asm/src/code_08007CAC.o(.text);
diff --git a/src/code_0805EC04.c b/src/code_0805EC04.c
index c3a7bdbd..82c2769f 100644
--- a/src/code_0805EC04.c
+++ b/src/code_0805EC04.c
@@ -79,7 +79,7 @@ void UpdatePlayerInput(void) {
PlayerMacroEntry* playerMacro;
u32 zero;
- if (gPlayerState.playerInput.playerMacro != NULL) {
+ if (gPlayerState.playerInput.playerMacro != NULL) {
// Player is controlled by macro.
playerInput = &gPlayerState.playerInput;
playerMacro = playerInput->playerMacro;
@@ -87,7 +87,7 @@ void UpdatePlayerInput(void) {
zero = 0;
goto code_2;
code_0:
- if (flags != 2) {
+ if (flags != 2) { // !PLAYER_MACRO_IGNORE
playerInput->playerMacroWaiting = playerMacro->flags;
playerInput->playerMacroHeldKeys = playerMacro->keys;
}
@@ -100,10 +100,12 @@ void UpdatePlayerInput(void) {
if (flags != 1) {
break;
}
+ // PLAYER_MACRO_JUMPTO
(u8*)playerMacro += ((s16)playerMacro->keys);
} while (TRUE);
if (flags == 3) {
+ // PLAYER_MACRO_END
playerInput->playerMacroWaiting = zero;
playerInput->playerMacroHeldKeys = zero;
playerMacro = NULL;
diff --git a/src/data/data_080046A4.c b/src/data/data_080046A4.c
index 0f0d8a65..25521082 100644
--- a/src/data/data_080046A4.c
+++ b/src/data/data_080046A4.c
@@ -1,4 +1,5 @@
#include "asm.h"
+#include "player.h"
const KeyValuePair gUnk_080046A4[] = {
{ 63, 1 }, { 80, 2 }, { 69, 8 }, { 70, 9 }, { 71, 10 }, { 72, 11 }, { 73, 12 }, { 74, 13 },
@@ -32,3 +33,67 @@ const u16 gUnk_080047F6[] = {
32776, 1039, 65280, 52, 32779, 21263, 65280, 19, 32779, 21263, 65280, 789, 0, 30, 2, 18,
64, 8, 0, 1, 128, 10, 0, 1, 128, 8, 384, 10, 128, 30, 1, 49152
};
+
+#define PLAYER_MACRO_JUMPTO 0x4000 // Jump
+#define PLAYER_MACRO_IGNORE 0x8000 // Do not set playerMacroWaiting and playerMacroHeldKeys?
+#define PLAYER_MACRO_END 0xC000 // End // 49152
+
+// Link tries out the shield.
+const PlayerMacroEntry gPlayerMacroTryOutShield[] = {
+ { 4, DPAD_LEFT }, { 1, DPAD_DOWN }, { 60, A_BUTTON }, { 1, DPAD_LEFT },
+ { 60, A_BUTTON }, { 1, DPAD_RIGHT }, { 60, A_BUTTON }, { PLAYER_MACRO_JUMPTO, -4 },
+};
+
+// Link holding his shield when the monsters escape or vaati attacks zelda.
+const PlayerMacroEntry gPlayerMacroProtectWithShield[] = {
+ { 0, A_BUTTON },
+ { PLAYER_MACRO_JUMPTO, -4 },
+};
+
+const PlayerMacroEntry gPlayerMacroSanctuary[] = {
+ { 1, DPAD_UP },
+ { 120, B_BUTTON },
+ { 60, 0 },
+};
+const u16 gPlayerMacroSanctuaryEnd = PLAYER_MACRO_END;
+
+const PlayerMacroEntry gPlayerMacroBladeBrothers0[] = {
+ { 120, B_BUTTON },
+ { 60, 0 },
+};
+const u16 gPlayerMacroBladeBrothers0End = PLAYER_MACRO_END;
+const PlayerMacroEntry gPlayerMacroBladeBrothers1[] = {
+ { 60, DPAD_RIGHT },
+ { 4, B_BUTTON },
+ { 60, 0 },
+};
+const u16 gPlayerMacroBladeBrothers1End = PLAYER_MACRO_END;
+const PlayerMacroEntry gPlayerMacroBladeBrothers2[] = {
+ { 4, DPAD_LEFT },
+ { 120, A_BUTTON },
+ { 60, 0 },
+};
+const u16 gPlayerMacroBladeBrothers2End = PLAYER_MACRO_END;
+const PlayerMacroEntry gPlayerMacroBladeBrothers3[] = {
+ { 1, DPAD_DOWN }, { 4, A_BUTTON }, { 10, 0 }, { 10, B_BUTTON }, { 60, 0 },
+};
+const u16 gPlayerMacroBladeBrothers3End = PLAYER_MACRO_END;
+const PlayerMacroEntry gPlayerMacroBladeBrothers4[] = {
+ { 4, DPAD_RIGHT }, { 8, R_BUTTON + DPAD_RIGHT }, { 30, 0 }, { 1, DPAD_LEFT }, { 30, 0 },
+ { 4, DPAD_LEFT }, { 4, R_BUTTON + DPAD_LEFT }, { 20, 0 }, { 6, B_BUTTON }, { 60, 0 },
+};
+const u16 gPlayerMacroBladeBrothers4End = PLAYER_MACRO_END;
+const PlayerMacroEntry gPlayerMacroBladeBrothers5[] = {
+ { 1, DPAD_LEFT }, { 30, 0 }, { 4, B_BUTTON }, { 60, 0 }, { 4, B_BUTTON }, { 60, 0 },
+};
+const u16 gPlayerMacroBladeBrothers5End = PLAYER_MACRO_END;
+const PlayerMacroEntry gPlayerMacroBladeBrothers6[] = {
+ { 1, DPAD_LEFT }, { 30, 0 }, { 4, B_BUTTON }, { 60, 0 }, { 4, B_BUTTON }, { 60, 0 },
+};
+const u16 gPlayerMacroBladeBrothers6End = PLAYER_MACRO_END;
+const PlayerMacroEntry gPlayerMacroBladeBrothers7[] = {
+ { 1, DPAD_LEFT }, { 120, B_BUTTON }, { 10, 0 }, { 4, B_BUTTON }, { 4, 0 }, { 4, B_BUTTON },
+ { 4, 0 }, { 4, B_BUTTON }, { 4, 0 }, { 4, B_BUTTON }, { 4, 0 }, { 4, B_BUTTON },
+ { 4, 0 }, { 4, B_BUTTON }, { 4, 0 }, { 4, B_BUTTON }, { 30, 0 },
+};
+const u16 gPlayerMacroBladeBrothers7End = PLAYER_MACRO_END; \ No newline at end of file
diff --git a/src/npc/bladeBrothers.c b/src/npc/bladeBrothers.c
index 4532cfaf..698834c8 100644
--- a/src/npc/bladeBrothers.c
+++ b/src/npc/bladeBrothers.c
@@ -1,15 +1,14 @@
-#include "global.h"
#include "entity.h"
#include "flags.h"
+#include "functions.h"
+#include "game.h"
+#include "item.h"
+#include "message.h"
+#include "npc.h"
#include "player.h"
#include "room.h"
-#include "message.h"
#include "save.h"
#include "script.h"
-#include "npc.h"
-#include "functions.h"
-#include "game.h"
-#include "item.h"
void sub_08068A1C(Entity*);
void sub_08068A4C(Entity*);
@@ -32,18 +31,17 @@ void (*const gUnk_081115D0[])(Entity*) = {
const u16 gUnk_081115DC[] = { 183, 184, 185, 186, 187, 188, 189, 190 };
-// TODO extract macros
-extern const PlayerMacroEntry gUnk_08004A0C;
-extern const PlayerMacroEntry gUnk_08004A16;
-extern const PlayerMacroEntry gUnk_08004A24;
-extern const PlayerMacroEntry gUnk_08004A32;
-extern const PlayerMacroEntry gUnk_08004A48;
-extern const PlayerMacroEntry gUnk_08004A72;
-extern const PlayerMacroEntry gUnk_08004A8C;
-extern const PlayerMacroEntry gUnk_08004AA6;
+extern const PlayerMacroEntry gPlayerMacroBladeBrothers0;
+extern const PlayerMacroEntry gPlayerMacroBladeBrothers1;
+extern const PlayerMacroEntry gPlayerMacroBladeBrothers2;
+extern const PlayerMacroEntry gPlayerMacroBladeBrothers3;
+extern const PlayerMacroEntry gPlayerMacroBladeBrothers4;
+extern const PlayerMacroEntry gPlayerMacroBladeBrothers5;
+extern const PlayerMacroEntry gPlayerMacroBladeBrothers6;
+extern const PlayerMacroEntry gPlayerMacroBladeBrothers7;
const PlayerMacroEntry* const BladeBrothers_PlayerMacros[] = {
- &gUnk_08004A0C, &gUnk_08004A16, &gUnk_08004A24, &gUnk_08004A32, &gUnk_08004A48, &gUnk_08004A72,
- &gUnk_08004A8C, &gUnk_08004AA6, NULL, NULL, NULL,
+ &gPlayerMacroBladeBrothers0, &gPlayerMacroBladeBrothers1, &gPlayerMacroBladeBrothers2, &gPlayerMacroBladeBrothers3, &gPlayerMacroBladeBrothers4, &gPlayerMacroBladeBrothers5,
+ &gPlayerMacroBladeBrothers6, &gPlayerMacroBladeBrothers7, NULL, NULL, NULL,
};
const u8 BladeBrothers_EquippedItem[] = {
diff --git a/src/playerUtils.c b/src/playerUtils.c
index 0d3a1422..303cdf1f 100644
--- a/src/playerUtils.c
+++ b/src/playerUtils.c
@@ -2113,7 +2113,7 @@ void sub_08079BD8(Entity* this) {
this->spritePriority.b0 = gPlayerEntity.spritePriority.b0;
}
-bool32 sub_08079C30(Entity* param_1) {
+bool32 sub_08079C30(Entity* player) {
if (gPlayerState.field_0x14 == 0 && (gPlayerState.flags & PL_FLAGS2) == 0) {
if ((gPlayerState.flags & PL_MINISH) != 0) {
return TRUE;
@@ -2129,13 +2129,13 @@ bool32 sub_08079C30(Entity* param_1) {
return TRUE;
}
- if (gPlayerState.floor_type != FindValueForKey(GetVvvRelativeToEntity(param_1, 0, -1), gMapVvvToSurfaceType))
+ if (gPlayerState.floor_type != FindValueForKey(GetVvvRelativeToEntity(player, 0, -1), gMapVvvToSurfaceType))
return FALSE;
- if (gPlayerState.floor_type != FindValueForKey(GetVvvRelativeToEntity(param_1, 2, 0), gMapVvvToSurfaceType))
+ if (gPlayerState.floor_type != FindValueForKey(GetVvvRelativeToEntity(player, 2, 0), gMapVvvToSurfaceType))
return FALSE;
- if (gPlayerState.floor_type == FindValueForKey(GetVvvRelativeToEntity(param_1, -2, 0), gMapVvvToSurfaceType)) {
+ if (gPlayerState.floor_type == FindValueForKey(GetVvvRelativeToEntity(player, -2, 0), gMapVvvToSurfaceType)) {
return TRUE;
}
}