mirror of
https://github.com/Polprzewodnikowy/N64FlashcartMenu.git
synced 2024-11-29 14:04:14 +01:00
Minor improvements
This commit is contained in:
parent
c57a5bef0b
commit
d21328b491
@ -7,7 +7,19 @@
|
||||
#define CPAK_BLOCKS 128
|
||||
#define CPAK_BLOCK_SIZE MEMPAK_BLOCK_SIZE
|
||||
|
||||
int clone_pak_content_to_file(char *path, uint8_t port) {
|
||||
cpak_err_t cpak_info_load(uint8_t port, cpak_info_t *cpak_info)
|
||||
{
|
||||
int res = validate_mempak(port);
|
||||
if (res != CONTROLLER_PAK_OK) {
|
||||
return CONTROLLER_PAK_ERR_INVALID;
|
||||
}
|
||||
|
||||
// TODO: implementation.
|
||||
|
||||
return CONTROLLER_PAK_OK;
|
||||
}
|
||||
|
||||
int cpak_clone_contents_to_file(char *path, uint8_t port) {
|
||||
uint8_t cpak_data[CPAK_BLOCKS * CPAK_BLOCK_SIZE];
|
||||
int err;
|
||||
for (int i = 0; i < CPAK_BLOCKS; i++) {
|
||||
@ -20,25 +32,27 @@ int clone_pak_content_to_file(char *path, uint8_t port) {
|
||||
FIL fil;
|
||||
UINT bytes_written;
|
||||
if (f_open(&fil, strip_sd_prefix(path), FA_WRITE | FA_CREATE_ALWAYS) != FR_OK) {
|
||||
return 1;
|
||||
return CONTROLLER_PAK_ERR_IO;
|
||||
}
|
||||
|
||||
FRESULT fw_err = f_write(&fil, &cpak_data, sizeof(cpak_data), &bytes_written);
|
||||
FRESULT fwrite_err = f_write(&fil, &cpak_data, sizeof(cpak_data), &bytes_written);
|
||||
|
||||
f_close(&fil);
|
||||
|
||||
if (fw_err) {
|
||||
return fw_err;
|
||||
if (fwrite_err) {
|
||||
return fwrite_err;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
return CONTROLLER_PAK_OK;
|
||||
}
|
||||
}
|
||||
|
||||
// void overwite_pak_content_from_file(char *path, uint8_t port) {
|
||||
cpak_err_t cpak_overwrite_contents_from_file(char *path, uint8_t port) {
|
||||
// TODO: implementation.
|
||||
return CONTROLLER_PAK_ERR_IO;
|
||||
}
|
||||
|
||||
// }
|
||||
|
||||
// void try_repair_pak() {
|
||||
|
||||
// }
|
||||
cpak_err_t cpak_attempt_repair() {
|
||||
// TODO: implementation.
|
||||
return CONTROLLER_PAK_ERR_IO;
|
||||
}
|
||||
|
@ -10,6 +10,23 @@
|
||||
#ifndef CPAK_HANDLER_H__
|
||||
#define CPAK_HANDLER_H__
|
||||
|
||||
int clone_pak_content_to_file(char *path, uint8_t port);
|
||||
/** @brief Controller Pak state enumeration. */
|
||||
typedef enum {
|
||||
CONTROLLER_PAK_OK,
|
||||
CONTROLLER_PAK_ERR_IO,
|
||||
CONTROLLER_PAK_ERR_NO_FILE,
|
||||
CONTROLLER_PAK_ERR_INVALID,
|
||||
} cpak_err_t;
|
||||
|
||||
/** @brief Controller Pak Information Structure. */
|
||||
typedef struct {
|
||||
// header
|
||||
// pages
|
||||
} cpak_info_t;
|
||||
|
||||
cpak_err_t cpak_info_load(uint8_t port, cpak_info_t *cpak_info);
|
||||
int cpak_clone_contents_to_file(char *path, uint8_t port);
|
||||
cpak_err_t cpak_overwrite_contents_from_file(char *path, uint8_t port);
|
||||
cpak_err_t cpak_attempt_repair();
|
||||
|
||||
#endif
|
||||
|
@ -14,7 +14,7 @@ static void process (menu_t *menu) {
|
||||
// TODO: handle all ports
|
||||
if (accessory_is_cpak[0]) {
|
||||
// TODO: preferably with the time added to the filename so it does not overwrite the existing one!
|
||||
clone_pak_content_to_file("sd://cpak/cpak_backup.mpk", 0);
|
||||
cpak_clone_contents_to_file("sd://cpak/cpak_backup.mpk", 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user