mirror of
https://github.com/Polprzewodnikowy/N64FlashcartMenu.git
synced 2025-01-26 00:31:14 +01:00
Code improvements
This commit is contained in:
parent
9bb6e66e1a
commit
0cd545584c
@ -23,7 +23,7 @@ cpak_err_t cpak_info_load(uint8_t port, cpak_info_t *cpak_info)
|
||||
cpak_info->entries[j] = entry;
|
||||
}
|
||||
|
||||
cpak_info->free_space = get_mempak_free_space(port);
|
||||
cpak_info->free_pages = get_mempak_free_space(port);
|
||||
|
||||
return CONTROLLER_PAK_OK;
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ typedef enum {
|
||||
/** @brief Controller Pak Information Structure. */
|
||||
typedef struct {
|
||||
entry_structure_t entries[16];
|
||||
int free_space;
|
||||
int free_pages;
|
||||
|
||||
} cpak_info_t;
|
||||
|
||||
|
@ -4,28 +4,49 @@
|
||||
|
||||
#define CPAK_BACKUP_DIRECTORY "/cpak"
|
||||
#define CPAK_BACKUP_FILE_PREFIX "cpak_backup"
|
||||
#define CPAK_BACKUP_FILE_EXT ".pak"
|
||||
#define CPAK_BACKUP_FILE_EXT "pak"
|
||||
|
||||
|
||||
static int accessory_is_cpak[4];
|
||||
static cpak_info_t cpak_info;
|
||||
static bool backup_in_progress = false;
|
||||
|
||||
|
||||
static void exec_cpak_backup(menu_t *menu) {
|
||||
backup_in_progress = true;
|
||||
char file_name[128];
|
||||
|
||||
path_t *path = path_init(menu->storage_prefix, CPAK_BACKUP_DIRECTORY);
|
||||
directory_create(path_get(path));
|
||||
|
||||
// TODO: preferably with the time added to the filename so it does not overwrite the existing one!
|
||||
sprintf(file_name, "%s-%s.%s", CPAK_BACKUP_FILE_PREFIX, "1", CPAK_BACKUP_FILE_EXT);
|
||||
|
||||
|
||||
path_push(path, file_name);
|
||||
|
||||
//int res =
|
||||
cpak_clone_contents_to_file(path_get(path), JOYPAD_PORT_1);
|
||||
|
||||
// TODO: draw progress bar or error!
|
||||
// if (res == CONTROLLER_PAK_OK) {
|
||||
|
||||
// }
|
||||
// else {
|
||||
|
||||
// }
|
||||
|
||||
path_free(path);
|
||||
|
||||
backup_in_progress = false;
|
||||
}
|
||||
|
||||
static void process (menu_t *menu) {
|
||||
|
||||
|
||||
if (menu->actions.enter) {
|
||||
// TODO: handle all ports
|
||||
if (accessory_is_cpak[JOYPAD_PORT_1]) {
|
||||
// TODO: draw progress bar!
|
||||
// TODO: preferably with the time added to the filename so it does not overwrite the existing one!
|
||||
path_t *path = path_init(menu->storage_prefix, CPAK_BACKUP_DIRECTORY);
|
||||
directory_create(path_get(path));
|
||||
|
||||
path_push(path, CPAK_BACKUP_FILE_PREFIX CPAK_BACKUP_FILE_EXT);
|
||||
|
||||
cpak_clone_contents_to_file(path_get(path), JOYPAD_PORT_1);
|
||||
path_free(path);
|
||||
exec_cpak_backup(menu);
|
||||
}
|
||||
}
|
||||
|
||||
@ -56,8 +77,9 @@ static void draw (menu_t *menu, surface_t *d) {
|
||||
"\n"
|
||||
"\n"
|
||||
"Controller Pak (1).\n"
|
||||
"Free space: %d/123 pages. \n",
|
||||
cpak_info.free_space
|
||||
"Pages: %d/123. \n"
|
||||
"Notes: ?/16. \n", // "Notes: %d/16. \n",
|
||||
cpak_info.free_pages
|
||||
);
|
||||
}
|
||||
else {
|
||||
@ -85,6 +107,10 @@ static void draw (menu_t *menu, surface_t *d) {
|
||||
);
|
||||
}
|
||||
|
||||
if (backup_in_progress) {
|
||||
component_messagebox_draw("Saving...");
|
||||
}
|
||||
|
||||
rdpq_detach_show();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user