Extract player macros

This commit is contained in:
octorock 2023-06-17 11:08:13 +02:00
parent c317fe3f18
commit f9da634427
12 changed files with 98 additions and 130 deletions

View File

@ -975,61 +975,6 @@
"start": 15940,
"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,

View File

@ -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"

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -232,7 +232,7 @@ typedef struct {
typedef struct {
u16 flags;
u16 keys;
} PlayerMacroEntry;
} PlayerMacroEntry ALIGNED(2);
typedef enum {
PLAYER_INPUT_1 = 0x1, // A

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -1,15 +1,14 @@
#include "global.h"
#include "entity.h"
#include "flags.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"
#include "message.h"
#include "npc.h"
#include "player.h"
#include "room.h"
#include "save.h"
#include "script.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[] = {

View File

@ -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;
}
}