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
+4 -2
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;
+65
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;
+16 -18
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[] = {
+4 -4
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;
}
}