mirror of
https://github.com/Polprzewodnikowy/N64FlashcartMenu.git
synced 2024-11-29 22:14:15 +01:00
Further improvements
This commit is contained in:
parent
0cd545584c
commit
8ed610f25d
@ -2,7 +2,7 @@
|
|||||||
#include "../cpak_handler.h"
|
#include "../cpak_handler.h"
|
||||||
#include "utils/fs.h"
|
#include "utils/fs.h"
|
||||||
|
|
||||||
#define CPAK_BACKUP_DIRECTORY "/cpak"
|
#define CPAK_BACKUP_DIRECTORY "/cpak_backups"
|
||||||
#define CPAK_BACKUP_FILE_PREFIX "cpak_backup"
|
#define CPAK_BACKUP_FILE_PREFIX "cpak_backup"
|
||||||
#define CPAK_BACKUP_FILE_EXT "pak"
|
#define CPAK_BACKUP_FILE_EXT "pak"
|
||||||
|
|
||||||
@ -12,9 +12,17 @@ static cpak_info_t cpak_info;
|
|||||||
static bool backup_in_progress = false;
|
static bool backup_in_progress = false;
|
||||||
|
|
||||||
|
|
||||||
static void exec_cpak_backup(menu_t *menu) {
|
const static char *format_cpak_entries(entry_structure_t *entries) {
|
||||||
|
// TODO: either show the note descriptions, or show the notes used.
|
||||||
|
// for (int i = 0; i< 16; i++) {
|
||||||
|
|
||||||
|
// }
|
||||||
|
return "?/16";
|
||||||
|
}
|
||||||
|
|
||||||
|
static void exec_cpak_backup(menu_t *menu, uint8_t port) {
|
||||||
backup_in_progress = true;
|
backup_in_progress = true;
|
||||||
char file_name[128];
|
char file_name[64];
|
||||||
|
|
||||||
path_t *path = path_init(menu->storage_prefix, CPAK_BACKUP_DIRECTORY);
|
path_t *path = path_init(menu->storage_prefix, CPAK_BACKUP_DIRECTORY);
|
||||||
directory_create(path_get(path));
|
directory_create(path_get(path));
|
||||||
@ -26,7 +34,7 @@ static void exec_cpak_backup(menu_t *menu) {
|
|||||||
path_push(path, file_name);
|
path_push(path, file_name);
|
||||||
|
|
||||||
//int res =
|
//int res =
|
||||||
cpak_clone_contents_to_file(path_get(path), JOYPAD_PORT_1);
|
cpak_clone_contents_to_file(path_get(path), port);
|
||||||
|
|
||||||
// TODO: draw progress bar or error!
|
// TODO: draw progress bar or error!
|
||||||
// if (res == CONTROLLER_PAK_OK) {
|
// if (res == CONTROLLER_PAK_OK) {
|
||||||
@ -46,7 +54,7 @@ static void process (menu_t *menu) {
|
|||||||
if (menu->actions.enter) {
|
if (menu->actions.enter) {
|
||||||
// TODO: handle all ports
|
// TODO: handle all ports
|
||||||
if (accessory_is_cpak[JOYPAD_PORT_1]) {
|
if (accessory_is_cpak[JOYPAD_PORT_1]) {
|
||||||
exec_cpak_backup(menu);
|
exec_cpak_backup(menu, JOYPAD_PORT_1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,24 +70,29 @@ static void draw (menu_t *menu, surface_t *d) {
|
|||||||
|
|
||||||
component_layout_draw();
|
component_layout_draw();
|
||||||
|
|
||||||
|
// TODO: Backup from other ports, restore from SD, and/or Repair functions.
|
||||||
component_main_text_draw(
|
component_main_text_draw(
|
||||||
ALIGN_CENTER, VALIGN_TOP,
|
ALIGN_CENTER, VALIGN_TOP,
|
||||||
"CONTROLLER PAK MENU\n"
|
"CONTROLLER PAK MENU\n"
|
||||||
"\n"
|
"\n"
|
||||||
"\n"
|
"This menu only supports cloning the\n"
|
||||||
|
"Controller Pak connected to JoyPad 1.\n"
|
||||||
);
|
);
|
||||||
|
|
||||||
// TODO: Backup from other ports, restore from SD, and/or Repair functions.
|
|
||||||
// Bonus would be to handle individual per game entries!
|
// Bonus would be to handle individual per game entries!
|
||||||
if (accessory_is_cpak[0]) {
|
if (accessory_is_cpak[0]) {
|
||||||
component_main_text_draw(
|
component_main_text_draw(
|
||||||
ALIGN_LEFT, VALIGN_TOP,
|
ALIGN_LEFT, VALIGN_TOP,
|
||||||
"\n"
|
"\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
"\n"
|
||||||
|
"\n"
|
||||||
|
"\n"
|
||||||
"Controller Pak (1).\n"
|
"Controller Pak (1).\n"
|
||||||
"Pages: %d/123. \n"
|
" Pages: %d/123. \n"
|
||||||
"Notes: ?/16. \n", // "Notes: %d/16. \n",
|
" Notes: %s.",
|
||||||
cpak_info.free_pages
|
cpak_info.free_pages,
|
||||||
|
format_cpak_entries(cpak_info.entries)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -87,6 +100,9 @@ static void draw (menu_t *menu, surface_t *d) {
|
|||||||
ALIGN_LEFT, VALIGN_TOP,
|
ALIGN_LEFT, VALIGN_TOP,
|
||||||
"\n"
|
"\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
"\n"
|
||||||
|
"\n"
|
||||||
|
"\n"
|
||||||
"Controller Pak (1).\n"
|
"Controller Pak (1).\n"
|
||||||
" Not inserted.\n"
|
" Not inserted.\n"
|
||||||
);
|
);
|
||||||
@ -95,7 +111,7 @@ static void draw (menu_t *menu, surface_t *d) {
|
|||||||
if (accessory_is_cpak[0]) {
|
if (accessory_is_cpak[0]) {
|
||||||
component_actions_bar_text_draw(
|
component_actions_bar_text_draw(
|
||||||
ALIGN_LEFT, VALIGN_TOP,
|
ALIGN_LEFT, VALIGN_TOP,
|
||||||
"A: Clone\n"
|
"A: Clone to SD Card\n"
|
||||||
"B: Back"
|
"B: Back"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -116,12 +132,16 @@ static void draw (menu_t *menu, surface_t *d) {
|
|||||||
|
|
||||||
void view_joypad_controller_pak_init (menu_t *menu){
|
void view_joypad_controller_pak_init (menu_t *menu){
|
||||||
|
|
||||||
|
//TODO: handle all paks.
|
||||||
// check which paks are available
|
// check which paks are available
|
||||||
JOYPAD_PORT_FOREACH (port) {
|
// JOYPAD_PORT_FOREACH (port) {
|
||||||
accessory_is_cpak[port] = joypad_get_accessory_type(port) == JOYPAD_ACCESSORY_TYPE_CONTROLLER_PAK;
|
// accessory_is_cpak[port] = joypad_get_accessory_type(port) == JOYPAD_ACCESSORY_TYPE_CONTROLLER_PAK;
|
||||||
}
|
// }
|
||||||
|
|
||||||
cpak_info_load(JOYPAD_PORT_1, &cpak_info);
|
if (joypad_get_accessory_type(JOYPAD_PORT_1) == JOYPAD_ACCESSORY_TYPE_CONTROLLER_PAK) {
|
||||||
|
accessory_is_cpak[JOYPAD_PORT_1] = JOYPAD_ACCESSORY_TYPE_CONTROLLER_PAK;
|
||||||
|
cpak_info_load(JOYPAD_PORT_1, &cpak_info);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void view_joypad_controller_pak_display (menu_t *menu, surface_t *display) {
|
void view_joypad_controller_pak_display (menu_t *menu, surface_t *display) {
|
||||||
|
Loading…
Reference in New Issue
Block a user