diff --git a/makefile b/makefile index 88de818d..8bf6b40a 100644 --- a/makefile +++ b/makefile @@ -184,8 +184,8 @@ endif $(OBJ-N64) : CFLAGS ?= -O2 -g -flto -ffat-lto-objects $(OBJ-N64) : CXXFLAGS ?= -O2 -g -flto -ffat-lto-objects $(ELF-N64) : LDFLAGS ?= -O2 -g -flto -$(OBJ-VC) : CFLAGS ?= -Os -g -flto -ffat-lto-objects -$(OBJ-VC) : CXXFLAGS ?= -Os -g -flto -ffat-lto-objects -$(ELF-VC) : LDFLAGS ?= -Os -g -flto +$(OBJ-VC) : CFLAGS ?= -O1 -g +$(OBJ-VC) : CXXFLAGS ?= -O1 -g +$(ELF-VC) : LDFLAGS ?= -O1 -g $(eval $(call bin_template,ldr,ldr,$(SRCDIR)/ldr,$(RESDIR)/ldr,$(OBJDIR)/ldr,$(BINDIR)/ldr,$(HOOKDIR)/ldr,$(LDR_ADDRESS))) diff --git a/src/gz/gz_trainer.c b/src/gz/gz_trainer.c index 4460cad8..79cab3d9 100644 --- a/src/gz/gz_trainer.c +++ b/src/gz/gz_trainer.c @@ -1,5 +1,6 @@ #include #include +#include #include "gfx.h" #include "gz.h" #include "menu.h" @@ -8,7 +9,7 @@ #include "z64.h" #include "trainer.h" -#define TRAINER_MENU_ITEM_COUNT 3 +#define TRAINER_MENU_ITEM_COUNT 4 #define SIDEHOP_LOG_LENGTH 6 // length of "perfect! (frame perfect)" #define SIDEHOP_LOG_STRING_LENGTH 25 @@ -212,6 +213,28 @@ static int equip_swap_draw_proc(struct menu_item *item, return 1; } +static int hover_draw_proc(struct menu_item *item, + struct menu_draw_params *draw_params) +{ + if (gz.menu_active) + return 1; + + gfx_mode_set(GFX_MODE_COLOR, GPACK_RGB24A8(draw_params->color, + draw_params->alpha)); + struct gfx_font *font = draw_params->font; + int ch = menu_get_cell_height(item->owner, 1); + int x = draw_params->x; + int y = draw_params->y; + + update_hover(); + + set_rgb_white(); + gfx_printf(font, x, y + ch * 0, "height gained: %.1f", hover.link_final_y - hover.link_initial_y); + gfx_printf(font, x, y + ch * 1, "linear distance: %.3lf", sqrt(hover.link_x_traveled+hover.link_z_traveled)); + + return 1; +} + static int trainer_radio_button_toggle_proc(struct menu_item *item, enum menu_callback_reason reason, void *data) @@ -268,5 +291,12 @@ struct menu *gz_trainer_menu(void) menu_add_static(&menu, 2, index + 1, "equip swap trainer", 0xC0C0C0); index += 1; + /*add hover training option*/ + trainer_menu_data[index] = menu_add_static_custom(gz.menu_global, global_x, global_y, hover_draw_proc, NULL, 0xFFFFFF); + trainer_menu_data[index]->enabled = 0; + menu_add_checkbox(&menu, 0, index + 1, trainer_radio_button_toggle_proc, (void*)index); + menu_add_static(&menu, 2, index + 1, "hover trainer", 0xC0C0C0); + index += 1; + return &menu; } diff --git a/src/gz/trainer.c b/src/gz/trainer.c index 839cb01e..241f4491 100644 --- a/src/gz/trainer.c +++ b/src/gz/trainer.c @@ -12,6 +12,7 @@ struct roll roll; struct sidehop sidehop; +struct hover hover; struct hess hess; struct equip_swap equip_swap; @@ -31,6 +32,14 @@ _Bool is_sidehopping() return 0; } +_Bool is_backflipping() +{ + if((z64_link.current_animation == ANIM_BACKFLIP)) + return 1; + else + return 0; +} + _Bool is_landing() { if((z64_link.current_animation == ANIM_LANDING_L) || (z64_link.current_animation == ANIM_LANDING_R)) @@ -217,6 +226,45 @@ _Bool update_sidehop() return ret; } +_Bool update_hover() +{ + if (is_backflipping()) + { + if (hover.backflipping) + { + return 1; + } + else + { + hover.backflipping = 1; + hover.link_initial_x = z64_link.common.pos_2.x; + hover.link_initial_y = z64_link.common.pos_2.y; + hover.link_initial_z = z64_link.common.pos_2.z; + return 1; + } + } + else + { + if(hover.backflipping) + { + hover.link_final_x = z64_link.common.pos_2.x; + hover.link_final_y = z64_link.common.pos_2.y; + hover.link_final_z = z64_link.common.pos_2.z; + + //algebra to calculate first part of linear distance + hover.link_x_traveled = pow(fabs(hover.link_final_x-hover.link_initial_x),2); + hover.link_z_traveled = pow(fabs(hover.link_final_z-hover.link_initial_z),2); + + hover.backflipping = 0; + return 1; + } + else + { + return 1; + } + } +} + void update_equip_swap() { int8_t x = input_x(); diff --git a/src/gz/trainer.h b/src/gz/trainer.h index 2877a100..d922e7c1 100644 --- a/src/gz/trainer.h +++ b/src/gz/trainer.h @@ -17,6 +17,7 @@ enum animation ANIM_LANDING_L = 0x04002960, ANIM_SIDEHOP_R = 0x04002988, ANIM_LANDING_R = 0x04002998, + ANIM_BACKFLIP = 0x040029D0, }; @@ -58,6 +59,20 @@ struct sidehop uint8_t streak; }; +struct hover +{ + _Bool backflipping; + float link_initial_x; + float link_final_x; + float link_initial_y; + float link_final_y; + float link_initial_z; + float link_final_z; + float link_x_traveled; + float link_z_traveled; + +}; + struct equip_swap { _Bool changing_screen; @@ -91,5 +106,6 @@ extern struct roll roll; extern struct sidehop sidehop; extern struct hess hess; extern struct equip_swap equip_swap; +extern struct hover hover; #endif