diff --git a/src/menu/cpak_handler.c b/src/menu/cpak_handler.c index 3eadbd4e..9165f898 100644 --- a/src/menu/cpak_handler.c +++ b/src/menu/cpak_handler.c @@ -14,7 +14,16 @@ cpak_err_t cpak_info_load(uint8_t port, cpak_info_t *cpak_info) return CONTROLLER_PAK_ERR_INVALID; } - // TODO: implementation. + for (int j = 0; j < 16; j++) + { + entry_structure_t entry; + + get_mempak_entry(port, j, &entry); + + cpak_info->entries[j] = entry; + } + + cpak_info->free_space = get_mempak_free_space(port); return CONTROLLER_PAK_OK; } diff --git a/src/menu/cpak_handler.h b/src/menu/cpak_handler.h index f154e884..a30aef28 100644 --- a/src/menu/cpak_handler.h +++ b/src/menu/cpak_handler.h @@ -20,8 +20,9 @@ typedef enum { /** @brief Controller Pak Information Structure. */ typedef struct { - // header - // pages + entry_structure_t entries[16]; + int free_space; + } cpak_info_t; cpak_err_t cpak_info_load(uint8_t port, cpak_info_t *cpak_info); diff --git a/src/menu/views/joypad_controller_pak.c b/src/menu/views/joypad_controller_pak.c index 34c146d4..0be89fb7 100644 --- a/src/menu/views/joypad_controller_pak.c +++ b/src/menu/views/joypad_controller_pak.c @@ -2,6 +2,22 @@ #include "../cpak_handler.h" static int accessory_is_cpak[4]; +static cpak_info_t cpak_info; + +static char *format_entries_info(entry_structure_t *entries) { + // for (int j = 0; j < 16; j++) + // { + // if (entries[j].valid) + // { + // sprintf(buffer + strlen(buffer), "%s - %d blocks\n", entries[j].name, entries[j].blocks); + // } + // else + // { + // sprintf(buffer + strlen(buffer), "(EMPTY)\n"); + // } + // } + return " unknown."; +} static void process (menu_t *menu) { @@ -10,6 +26,8 @@ static void process (menu_t *menu) { accessory_is_cpak[port] = joypad_get_accessory_type(port) == JOYPAD_ACCESSORY_TYPE_CONTROLLER_PAK; } + cpak_info_load(0, &cpak_info); + if (menu->actions.enter) { // TODO: handle all ports if (accessory_is_cpak[0]) { @@ -43,8 +61,11 @@ static void draw (menu_t *menu, surface_t *d) { ALIGN_LEFT, VALIGN_TOP, "\n" "\n" - "Clone Controller Pak (1) to SD Card.\n" - "If it is available.\n" + "Controller Pak (1).\n" + "Free space: %d blocks" + "Entries: \n%s", + cpak_info.free_space, + format_entries_info(cpak_info.entries) ); if (accessory_is_cpak[0]) {