Skip to content
Open
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
6 changes: 3 additions & 3 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
32 changes: 31 additions & 1 deletion src/gz/gz_trainer.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include "gfx.h"
#include "gz.h"
#include "menu.h"
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}
48 changes: 48 additions & 0 deletions src/gz/trainer.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

struct roll roll;
struct sidehop sidehop;
struct hover hover;
struct hess hess;
struct equip_swap equip_swap;

Expand All @@ -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))
Expand Down Expand Up @@ -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();
Expand Down
16 changes: 16 additions & 0 deletions src/gz/trainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ enum animation
ANIM_LANDING_L = 0x04002960,
ANIM_SIDEHOP_R = 0x04002988,
ANIM_LANDING_R = 0x04002998,
ANIM_BACKFLIP = 0x040029D0,

};

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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