Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.idea/
.temp/
.vs/
build/
venv/
Expand Down
5 changes: 5 additions & 0 deletions genhooks
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ genhook "$sym_flush_backups_hook_1" "nop;" # Remove calls to update backup save
genhook "$sym_flush_backups_hook_2" "nop;"
genhook "$sym_update_camera_zone_interp_hook" "jal $sym_fpUpdateCameraZoneInterpHook;"
genhook "$sym_get_npc_unsafe_hook" "jal $sym_fpGetNpcUnsafe;"
genhook "$sym_no_walls_hook_1" "jal $sym_fpIgnoreWalls;"
genhook "$sym_no_walls_hook_2" "jal $sym_fpIgnoreWalls;"
genhook "$sym_no_walls_hook_3" "jal $sym_fpIgnoreWalls;"
genhook "$sym_no_walls_hook_4" "jal $sym_fpIgnoreWalls;"
genhook "$sym_no_walls_hook_5" "jal $sym_fpIgnoreWalls;"
genhook "$sym_update_player_input_rom_hook" "jal $sym_fpUpdateInput;"
genhook "$sym_peekaboo_hook" "jal $sym_fpIsAbilityActive;"
genhook "$sym_fire_flower_hook" "nop;" # Fix wii vc fire flower crash
6 changes: 6 additions & 0 deletions lib/libpm-jp.a
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ __osGetActiveQueue = 0x80066260;
osViSwapBuffer = 0x80066FF0;
osViBlack = 0x80067350;
osViRepeatLine = 0x800673B0;
pm_player_raycast_general = 0x800DEE3C;
pm_disable_player_input = 0x800E0158;
pm_update_player_input = 0x800E1F70;
pm_is_ability_active = 0x800E9CE8;
Expand All @@ -108,6 +109,11 @@ flush_backups_hook_1 = 0x8002B064;
flush_backups_hook_2 = 0x8002B074;
update_camera_zone_interp_hook = 0x8002D188;
get_npc_unsafe_hook = 0x8004165C;
no_walls_hook_1 = 0x8009CDD8;
no_walls_hook_2 = 0x8009D31C;
no_walls_hook_3 = 0x8009D3B0;
no_walls_hook_4 = 0x8009D62C;
no_walls_hook_5 = 0x8009D6E4;
update_player_input_rom_hook = 0x8009D914;
peekaboo_hook = 0x801AF3A0;
fire_flower_hook = 0x803AD0A0;
6 changes: 6 additions & 0 deletions lib/libpm-us.a
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ __osGetActiveQueue = 0x80066290;
osViSwapBuffer = 0x80067020;
osViBlack = 0x80067380;
osViRepeatLine = 0x800673E0;
pm_player_raycast_general = 0x800DEE5C;
pm_disable_player_input = 0x800E0178;
pm_update_player_input = 0x800E1F90;
pm_is_ability_active = 0x800E9D48;
Expand All @@ -108,6 +109,11 @@ flush_backups_hook_1 = 0x8002B0A4;
flush_backups_hook_2 = 0x8002B0B4;
update_camera_zone_interp_hook = 0x8002D4F8;
get_npc_unsafe_hook = 0x8004199C;
no_walls_hook_1 = 0x8009CDF8;
no_walls_hook_2 = 0x8009D33C;
no_walls_hook_3 = 0x8009D3D0;
no_walls_hook_4 = 0x8009D64C;
no_walls_hook_5 = 0x8009D704;
update_player_input_rom_hook = 0x8009D934;
peekaboo_hook = 0x801A7110;
fire_flower_hook = 0x803A4DA0;
26 changes: 25 additions & 1 deletion src/commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ struct Command fpCommands[COMMAND_MAX] = {
{"toggle in. disp.", COMMAND_PRESS_ONCE, 0, commandToggleInpDispProc },
{"clippy", COMMAND_PRESS_ONCE, 0, commandClippyProc },
{"store ability", COMMAND_PRESS_ONCE, 0, commandStoreAbility },
{"ignore walls", COMMAND_PRESS_ONCE, 0, commandIgnoreWalls },
{"floor clip", COMMAND_PRESS_ONCE, 0, commandFloorClip },
};

void showMenu(void) {
Expand Down Expand Up @@ -173,11 +175,12 @@ void commandLoadPosProc(void) {
pm_gPlayerStatus.targetYaw = fp.savedMovementAngle;

if (pm_gPlayerStatus.actionState & ACTION_STATE_RIDE) {
pm_Npc *partner = pm_get_npc_safe(-4);
pm_Npc *partner = pm_get_npc_safe(-4); // NPC_PARTNER
if (partner) {
partner->pos.x = fp.savedPos.x;
partner->pos.y = fp.savedPos.y;
partner->pos.z = fp.savedPos.z;
partner->moveToPos.y = fp.savedPos.y;
partner->yaw = fp.savedMovementAngle;
}
}
Expand Down Expand Up @@ -300,3 +303,24 @@ void commandStoreAbility(void) {
fpLog("partner ability stored");
}
}

void commandIgnoreWalls(void) {
if (fp.ignoreWalls) {
fp.ignoreWalls = FALSE;
fpLog("walls enabled");
} else {
fp.ignoreWalls = TRUE;
fpLog("walls disabled");
}
}

void commandFloorClip(void) {
pm_gPlayerStatus.position.y -= 20;
if (pm_gPlayerStatus.actionState & ACTION_STATE_RIDE) {
pm_Npc *partner = pm_get_npc_safe(-4); // NPC_PARTNER
if (partner) {
partner->pos.y -= 20;
partner->moveToPos.y -= 20;
}
}
}
4 changes: 4 additions & 0 deletions src/commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ enum Commands {
COMMAND_TOGGLE_INPUT_DISPLAY,
COMMAND_CLIPPY,
COMMAND_STORE_ABILITY,
COMMAND_IGNORE_WALLS,
COMMAND_FLOOR_CLIP,
COMMAND_MAX
};

Expand Down Expand Up @@ -59,6 +61,8 @@ void commandBreakFreeProc(void);
void commandToggleInpDispProc(void);
void commandClippyProc(void);
void commandStoreAbility(void);
void commandIgnoreWalls(void);
void commandFloorClip(void);

extern struct Command fpCommands[COMMAND_MAX];

Expand Down
38 changes: 28 additions & 10 deletions src/fp.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "fp.h"
#include "commands.h"
#include "common.h"
#include "fp/debug/flags.h"
#include "fp/practice/timer.h"
#include "fp/practice/trainer.h"
#include "fp/warps/bosses.h"
Expand Down Expand Up @@ -508,6 +509,10 @@ void fpUpdate(void) {
}
fpCamUpdate();

if (settings->flagLogging) {
updateFlagRecords();
}

while (fp.menuActive && menuThink(fp.mainMenu)) {
// wait
}
Expand All @@ -529,15 +534,6 @@ void fpDraw(void) {
s32 cellWidth = menuGetCellWidth(fp.mainMenu, TRUE);
s32 cellHeight = menuGetCellHeight(fp.mainMenu, TRUE);

if (settings->inputDisplay) {
fpDrawInputDisplay(font, cellWidth, cellHeight, menuAlpha);
}

if (fp.timerMoving || (timerState == TIMER_STOPPED && !fp.menuActive) ||
(settings->timerShow && !fp.menuActive && timerState != TIMER_INACTIVE)) {
fpDrawTimer(font, cellWidth, cellHeight, menuAlpha);
}

if (fp.menuActive) {
if (settings->menuBackground) {
gfxModeSet(GFX_MODE_COLOR, GPACK_RGB24A8(0x000000, settings->menuBackgroundAlpha));
Expand All @@ -550,6 +546,19 @@ void fpDraw(void) {
menuDraw(fp.mainMenu);
}

if (settings->inputDisplay) {
fpDrawInputDisplay(font, cellWidth, cellHeight, menuAlpha);
}

if (fp.timerMoving || (timerState == TIMER_STOPPED && !fp.menuActive) ||
(settings->timerShow && !fp.menuActive && timerState != TIMER_INACTIVE)) {
fpDrawTimer(font, cellWidth, cellHeight, menuAlpha);
}

if (fp.trainerMoving || (settings->trainerDisplayPinned && !fp.menuActive)) {
trainerDrawPinned(settings->trainerX, settings->trainerY, font, cellWidth, cellHeight, 0xC0C0C0, menuAlpha);
}

if (!fp.versionShown) {
fpDrawVersion(font, cellWidth, cellHeight, menuAlpha);
}
Expand Down Expand Up @@ -608,14 +617,23 @@ HOOK s32 fpIsAbilityActive(s32 ability) {
return pm_is_ability_active(ability);
}

HOOK pm_Npc *fpGetNpcUnsafe(s16 npcId) {
HOOK pm_Npc *fpGetNpcUnsafe(s16 npcId) { // NOLINT
if (npcId == BOSSES_DUMMY_ID) {
bossesDummyNpc.pos = pm_gPlayerStatus.position;
return &bossesDummyNpc;
}
return pm_get_npc_unsafe(npcId);
}

HOOK s32 fpIgnoreWalls(s32 mode, f32 startX, f32 startY, f32 startZ, f32 dirX, f32 dirY, f32 dirZ, f32 *hitX, f32 *hitY,
f32 *hitZ, f32 *hitDepth, f32 *hitNx, f32 *hitNy, f32 *hitNz) {
if (fp.ignoreWalls) {
return -1;
}
return pm_player_raycast_general(mode, startX, startY, startZ, dirX, dirY, dirZ, hitX, hitY, hitZ, hitDepth, hitNx,
hitNy, hitNz);
}

#include <grc.c>
#include <list/list.c>
#include <set/set.c>
Expand Down
2 changes: 2 additions & 0 deletions src/fp.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ typedef struct {
s64 cpuCounter;
s32 cpuCounterFreq;
bool timerMoving;
bool trainerMoving;
bool menuActive;
struct LogEntry log[SETTINGS_LOG_MAX];
Vec3f savedPos;
Expand Down Expand Up @@ -69,6 +70,7 @@ typedef struct {
pm_Camera savedCam;
u16 freeCamMoveSpeed;
u16 freeCamPanSpeed;
bool ignoreWalls;
} FpCtxt;

extern FpCtxt fp;
Expand Down
36 changes: 21 additions & 15 deletions src/fp/debug/flags.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "flags.h"
#include "common.h"
#include "fp.h"
#include "menu/menu.h"
#include "sys/gfx.h"
#include "sys/resource.h"
Expand Down Expand Up @@ -62,6 +63,9 @@ static void addEvent(s32 recordIndex, s32 flagIndex, bool value) {
e->value = value;
snprintf(e->description, sizeof(e->description), "%s[0x%0*lx] := %i", r->name, r->indexLength % 10, flagIndex,
value);
if (settings->flagLogging) {
fpLog(e->description);
}
}

static u32 getFlagWord(void *data, size_t wordSize, s32 index) {
Expand Down Expand Up @@ -103,22 +107,9 @@ static void modifyFlag(void *data, size_t wordSize, s32 flagIndex, bool value) {
}

static s32 logThinkProc(struct MenuItem *item) {
for (s32 i = 0; i < records.size; ++i) {
struct FlagRecord *r = vector_at(&records, i);
for (s32 j = 0; j < r->length; ++j) {
u32 wd = getFlagWord(r->data, r->wordSize, j);
u32 wc = getFlagWord(r->comp, r->wordSize, j);
u32 d = wd ^ wc;
if (d != 0) {
for (s32 k = 0; k < r->wordSize * 8; ++k) {
if ((d >> k) & 1) {
addEvent(i, r->wordSize * 8 * j + k, (wd >> k) & 1);
}
}
}
}
if (!settings->flagLogging) {
updateFlagRecords();
}
updateFlagRecords();
return 0;
}

Expand Down Expand Up @@ -271,6 +262,21 @@ void flagMenuCreate(struct Menu *menu) {
}

void updateFlagRecords(void) {
for (s32 i = 0; i < records.size; ++i) {
struct FlagRecord *r = vector_at(&records, i);
for (s32 j = 0; j < r->length; ++j) {
u32 wd = getFlagWord(r->data, r->wordSize, j);
u32 wc = getFlagWord(r->comp, r->wordSize, j);
u32 d = wd ^ wc;
if (d != 0) {
for (s32 k = 0; k < r->wordSize * 8; ++k) {
if ((d >> k) & 1) {
addEvent(i, r->wordSize * 8 * j + k, (wd >> k) & 1);
}
}
}
}
}
for (s32 i = 0; i < records.size; ++i) {
struct FlagRecord *r = vector_at(&records, i);
memcpy(r->comp, r->data, r->wordSize * r->length);
Expand Down
12 changes: 6 additions & 6 deletions src/fp/file/fp_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ static s32 storyProgressDrawProc(struct MenuItem *item, struct MenuDrawParams *d

char buffer[24];
if (chapter == 0) {
snprintf(buffer, sizeof(buffer), "pro. (%d/%d) -", chapterProgress, chapterMax);
snprintf(buffer, sizeof(buffer), "pro. (%d/%d)", chapterProgress, chapterMax);
} else if (chapter > 8) {
snprintf(buffer, sizeof(buffer), "invalid -");
snprintf(buffer, sizeof(buffer), "invalid");
} else {
snprintf(buffer, sizeof(buffer), "ch%d (%d/%d) -", chapter, chapterProgress, chapterMax);
snprintf(buffer, sizeof(buffer), "ch%d (%d/%d)", chapter, chapterProgress, chapterMax);
}
gfxPrintf(font, x, y, buffer);
return 1;
Expand Down Expand Up @@ -228,9 +228,9 @@ struct Menu *createFileMenu(void) {
menuItemAddChainLink(importButton, minusButton, MENU_NAVIGATE_DOWN);
y++;

menuAddStatic(&menu, 0, y++, "story progress", 0xC0C0C0);
menuAddStaticCustom(&menu, 0, y, storyProgressDrawProc, NULL, 0xC0C0C0);
struct MenuItem *progressInput = menuAddIntinput(&menu, 14, y++, 16, 2, menuByteModProc, &STORY_PROGRESS);
menuAddStatic(&menu, 0, y, "story progress", 0xC0C0C0);
struct MenuItem *progressInput = menuAddIntinput(&menu, 15, y++, 16, 2, menuByteModProc, &STORY_PROGRESS);
menuAddStaticCustom(&menu, 0, y++, storyProgressDrawProc, NULL, 0xC0C0C0);
menuItemAddChainLink(minusButton, progressInput, MENU_NAVIGATE_DOWN);
menuItemAddChainLink(plusButton, progressInput, MENU_NAVIGATE_DOWN);
y++;
Expand Down
13 changes: 13 additions & 0 deletions src/fp/fp_settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ static s32 controlStickRangeProc(struct MenuItem *item, enum MenuCallbackReason
return 0;
}

static s32 trainerPositionProc(struct MenuItem *item, enum MenuCallbackReason reason, void *data) {
if (reason == MENU_CALLBACK_ACTIVATE) {
fp.trainerMoving = TRUE;
} else if (reason == MENU_CALLBACK_DEACTIVATE) {
fp.trainerMoving = FALSE;
}
return menuGenericPositionProc(item, reason, &settings->trainerX);
}

static void profileDecProc(struct MenuItem *item, void *data) {
fp.profile += SETTINGS_PROFILE_MAX - 1;
fp.profile %= SETTINGS_PROFILE_MAX;
Expand Down Expand Up @@ -184,6 +193,10 @@ struct Menu *createSettingsMenu(void) {
menuAddStatic(&menuDisplay, 0, y, "logging", 0xC0C0C0);
menuAddCheckbox(&menuDisplay, menuX, y, menuByteCheckboxProc, &settings->log);
menuAddPositioning(&menuDisplay, menuX + 2, y++, logPositionProc, NULL);
menuAddStatic(&menuDisplay, 0, y, "flag logging", 0xC0C0C0);
menuAddCheckbox(&menuDisplay, menuX, y++, menuByteCheckboxProc, &settings->flagLogging);
menuAddStatic(&menuDisplay, 0, y, "pinned trainer", 0xC0C0C0);
menuAddPositioning(&menuDisplay, menuX, y++, trainerPositionProc, &settings->trainerX);
y++;
menuAddStatic(&menuDisplay, 0, y, "input display", 0xC0C0C0);
menuAddCheckbox(&menuDisplay, menuX, y, menuByteCheckboxProc, &settings->inputDisplay);
Expand Down
Loading