diff --git a/lib/libnbke.a b/lib/libnbke.a index 0a74b00..2ca62a1 100755 --- a/lib/libnbke.a +++ b/lib/libnbke.a @@ -9,9 +9,21 @@ gfx_finish_hook = 0x802E3B7C; kb_vi_counter = 0x80274578; /* need nbke */ bk_controller_raw = 0x802812B8; + bk_take_me_there = 0x802E4078; bk_transformation_set = 0x8029a95c; +/* BK_Moves.c */ +bk_moves_has_used_set_bit = 0x802957bc; +bk_moves_has_used_get_bit = 0x802957a0; +bk_moves_unlocked_get_bit = 0x802957d8; +bk_moves_unlocked_get = 0x802957f0; +bk_moves_clear = 0x80295804; +bk_moves_unlocked_set_bit = 0x80295818; +bk_moves_unlocked_set = 0x80295864; +bk_moves_has_used_set = 0x80295870; +bk_moves_bitfield_stats = 0x8029587c; + bk_item_array = 0x80385f30; bk_item_get_count = 0x80345fa0; @@ -27,4 +39,4 @@ bk_mumbo_token_flag_set = 0x803215d0; bk_empty_honeycomb_flag_get = 0x803212e4; bk_empty_honeycomb_flag_set = 0x80321364; -bk_high_note_scores = 0x80385ff0; \ No newline at end of file +bk_high_note_scores = 0x80385ff0; diff --git a/lib/libnbke11.a b/lib/libnbke11.a index a52d510..dffdfd5 100644 --- a/lib/libnbke11.a +++ b/lib/libnbke11.a @@ -10,4 +10,15 @@ kb_vi_counter = 0x80274578; /* need nbke-1.1 */ bk_controller_raw = 0x80284754; bk_take_me_there = 0x802e30b8; -bk_transformation_set = 0x802997d8; \ No newline at end of file +bk_transformation_set = 0x802997d8; + +/* BK_Moves.c */ +bk_moves_has_used_get_bit = 0x80294610; +bk_moves_has_used_set_bit = 0x80294628; +bk_moves_unlocked_get_bit = 0x80294648; +bk_moves_unlocked_get = 0x80294660; +bk_moves_clear = 0x80294674; +bk_moves_unlocked_set_bit = 0x80294688; +bk_moves_unlocked_set = 0x802946d4; +bk_moves_has_used_set = 0x802946e0; +bk_moves_bitfield_stats = 0x802946ec; \ No newline at end of file diff --git a/lib/libnbkj.a b/lib/libnbkj.a index f1f7e1a..f170278 100755 --- a/lib/libnbkj.a +++ b/lib/libnbkj.a @@ -10,4 +10,15 @@ kb_vi_counter = 0x80274578; bk_controller_raw = 0x80284754; bk_take_me_there = 0x802e31d8; -bk_transformation_set = 0x802997fC; \ No newline at end of file +bk_transformation_set = 0x802997fC; + +/* BK_Moves.c */ +bk_moves_has_used_get_bit = 0x80294640; +bk_moves_has_used_set_bit = 0x80294658; +bk_moves_unlocked_get_bit = 0x80294678; +bk_moves_unlocked_get = 0x80294690; +bk_moves_clear = 0x802946a4; +bk_moves_unlocked_set_bit = 0x802946b8; +bk_moves_unlocked_set = 0x80294704; +bk_moves_has_used_set = 0x80294710; +bk_moves_bitfield_stats = 0x8029471C; \ No newline at end of file diff --git a/lib/libnbkp.a b/lib/libnbkp.a index 013f60a..80c0c0e 100755 --- a/lib/libnbkp.a +++ b/lib/libnbkp.a @@ -10,4 +10,15 @@ kb_vi_counter = 0x80274578; /* need nbkp */ bk_controller_raw = 0x802810d8; bk_take_me_there = 0x802E4268; -bk_transformation_set = 0x8029a95c; \ No newline at end of file +bk_transformation_set = 0x8029a95c; + +/* BK_Moves.c */ +bk_moves_has_used_get_bit = 0x802955e0; +bk_moves_has_used_set_bit = 0x802945f8; +bk_moves_unlocked_get_bit = 0x80295618; +bk_moves_unlocked_get = 0x80295630; +bk_moves_clear = 0x80295644; +bk_moves_unlocked_set_bit = 0x80295658; +bk_moves_unlocked_set = 0x802956a4; +bk_moves_has_used_set = 0x802956b0; +bk_moves_bitfield_stats = 0x802956bc; \ No newline at end of file diff --git a/src/kb/bk.h b/src/kb/bk.h index 6200d0a..04b969b 100644 --- a/src/kb/bk.h +++ b/src/kb/bk.h @@ -29,6 +29,29 @@ typedef struct{ int8_t y; } bk_controller_t; +typedef enum moves{ + bk_moves_beakBarge = 0, + bk_moves_beakBomb = 1, + bk_moves_beakBuster = 2, + bk_moves_cameraControls = 3, + bk_moves_bearPunch = 4, + bk_moves_climbTrees = 5, + bk_moves_eggs = 6, + bk_moves_featheryFlap = 7, + bk_moves_flapFlip = 8, + bk_moves_flying = 9, + bk_moves_holdAToJumpHigher = 10, + bk_moves_ratATatRap = 11, + bk_moves_roll = 12, + bk_moves_shockSpringJump = 13, + bk_moves_wadingBoots = 14, + bk_moves_dive = 15, + bk_moves_talonTrot = 16, + bk_moves_turboTalonTrainers = 17, + bk_moves_wonderwing = 18, + bk_moves_firstNoteDoorMolehill = 19, +} bk_moves_t; + typedef enum bK_item{ BK_ITEM_SKULL_HOURGLASS = 0x1, BK_ITEM_PROPELLOR_TIMER = 0x3, @@ -87,6 +110,16 @@ bk_extern void load_code_stage1 (void); bk_extern void bk_gfx_finish (Gfx **p_gfx_p); bk_extern void bk_take_me_there (uint32_t map, uint32_t exit, uint32_t warp_type); +bk_extern bool bk_moves_has_used_get_bit (uint32_t move_index); +bk_extern void bk_moves_has_used_set_bit (uint32_t move_index); //code clear method +bk_extern bool bk_moves_unlocked_get_bit (uint32_t move_index); +bk_extern uint32_t bk_moves_unlocked_get(void); +bk_extern void bk_moves_clear(void); +bk_extern void bk_moves_unlocked_set_bit (uint32_t move_index, uint32_t boolean); +bk_extern void bk_moves_unlocked_set(uint32_t value); +bk_extern void bk_moves_has_used_set(uint32_t value); +bk_extern void bk_moves_bitfield_stats(uint32_t* size, void* addr); + bk_extern uint32_t bk_item_get_count (uint32_t item_index); bk_extern uint32_t bk_item_array; diff --git a/src/kb/kb.c b/src/kb/kb.c index 14f6eef..a8f84de 100644 --- a/src/kb/kb.c +++ b/src/kb/kb.c @@ -89,8 +89,10 @@ void init(void){ menu_init(main_menu, 20, 30); main_menu->selected_item = menu_button_add(main_menu, 0, 0, "return", main_menu_on_activate, NULL); + menu_submenu_add(main_menu, 0, 1, "warps", create_warps_menu()); menu_submenu_add(main_menu, 0, 2, "watches", create_watches_menu()); + menu_submenu_add(main_menu, 0, 4, "moves", create_moves_menu()); menu_submenu_add(main_menu, 0, 5, "items", create_items_menu()); kb.menu_active = 0; diff --git a/src/kb/kb.h b/src/kb/kb.h index 4cdb925..96a99b9 100644 --- a/src/kb/kb.h +++ b/src/kb/kb.h @@ -16,5 +16,5 @@ extern kb_ctxt_t kb; menu_t *create_warps_menu(void); menu_t *create_watches_menu (void); - +menu_t *create_moves_menu(void); #endif diff --git a/src/kb/kb_moves_menu.c b/src/kb/kb_moves_menu.c new file mode 100644 index 0000000..7073068 --- /dev/null +++ b/src/kb/kb_moves_menu.c @@ -0,0 +1,73 @@ +#include +#include +#include "kb.h" +#include "bk.h" + +struct moves_data { + uint32_t moves_indx; + char *tooltip; +}; + +static struct moves_data moves_table[]={ + { bk_moves_beakBarge, "beak barge"}, + { bk_moves_beakBomb, "beak bomb"}, + { bk_moves_beakBuster, "beak buster"}, + { bk_moves_cameraControls, "camera controls"}, + { bk_moves_bearPunch, "bear punch"}, + { bk_moves_climbTrees, "climb trees"}, + { bk_moves_eggs, "eggs"}, + { bk_moves_featheryFlap,"feathery flap"}, + { bk_moves_flapFlip, "flap flip"}, + { bk_moves_flying, "flying"}, + { bk_moves_holdAToJumpHigher, "variable jump height"}, + { bk_moves_ratATatRap, "rat-a-tat rap"}, + { bk_moves_roll, "roll"}, + { bk_moves_shockSpringJump, "shock spring jump"}, + { bk_moves_wadingBoots, "wading boots"}, + { bk_moves_dive, "dive" }, + { bk_moves_talonTrot, "talon trot"}, + { bk_moves_turboTalonTrainers, "turbo talon trainers"}, + { bk_moves_wonderwing, "wonderwing"}, + { bk_moves_firstNoteDoorMolehill, "1st note door molehill"}, //move to other flags? +}; + + +static int has_move_callback(event_handler_t *handler, menu_event_t callback, void *data){ + uint32_t moves_index = (uint32_t)handler->callback_data & 0xFF; + if(callback == MENU_EVENT_ACTIVATE){ + bool is_unlocked = bk_moves_unlocked_get_bit(moves_index); + if(is_unlocked){ + bk_moves_unlocked_set_bit(moves_index, 0); + } else { + bk_moves_unlocked_set_bit(moves_index, 1); + } + bk_moves_has_used_set(bk_moves_unlocked_get()); + return 1; + } else if(callback == MENU_EVENT_UPDATE) { + menu_checkbox_set(handler->subscriber,bk_moves_unlocked_get_bit(moves_index)); + return 1; + } + return 0; +} + +menu_t *create_moves_menu(){ + static menu_t moves_menu; + uint32_t data; + menu_init(&moves_menu, 0, 0); + moves_menu.selected_item = menu_button_add(&moves_menu, 0, 0, "return", menu_return, NULL); + + for (int i = 0; i < sizeof(moves_table)/sizeof(struct moves_data); i++) + { //add visual elements + menu_item_t* unlock_move_item = menu_checkbox_add(&moves_menu,0,i+1); + menu_label_add(&moves_menu, 1,i+1,moves_table[i].tooltip); + + //set callback process + menu_item_register_event(unlock_move_item,MENU_EVENT_ACTIVATE | MENU_EVENT_UPDATE, has_move_callback, (void*)moves_table[i].moves_indx); + } + + + + + + return &moves_menu; +} \ No newline at end of file