mirror of
https://github.com/Polprzewodnikowy/N64FlashcartMenu.git
synced 2024-12-01 23:14:14 +01:00
add info structure
could be worse!
This commit is contained in:
parent
d21328b491
commit
ecd131b7a4
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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]) {
|
||||
|
Loading…
Reference in New Issue
Block a user