mirror of
https://github.com/Polprzewodnikowy/N64FlashcartMenu.git
synced 2024-11-25 03:56:54 +01:00
Settings cleanup + SC64 config default state + libdragon update
This commit is contained in:
parent
f8fb8b617e
commit
edf8e13da1
2
Makefile
2
Makefile
@ -44,7 +44,7 @@ SRCS = \
|
||||
ASSETS = \
|
||||
FiraMono-Bold.ttf
|
||||
|
||||
$(BUILD_DIR)/FiraMono-Bold.o: MKFONT_FLAGS+=--size 16 -r 20-7F -r 2000-206F -r 2190-21FF
|
||||
$(BUILD_DIR)/FiraMono-Bold.o: MKFONT_FLAGS+=-c 0 --size 16 -r 20-7F -r 2000-206F -r 2190-21FF
|
||||
|
||||
$(BUILD_DIR)/%.o: $(ASSETS_DIR)/%.ttf
|
||||
@echo " [FONT] $@"
|
||||
|
24
README.md
24
README.md
@ -15,28 +15,6 @@
|
||||
Download the `sc64menu.n64` ROM from the latest action run assets.
|
||||
Add it to the root folder on your SD card.
|
||||
|
||||
(Optional):
|
||||
Create a file called `config.sc64.toml.txt`
|
||||
Add the following content, replacing the comments.
|
||||
```
|
||||
[last_rom]
|
||||
rom_path = "<!-- path to your ROM from the root of your SD card, note the quotes -->"
|
||||
save_path = "<!-- path to a save file from the root of your SD card, note the quotes -->"
|
||||
save_type = <!-- a number representing the save type (see save types) -->
|
||||
auto_load = <!-- a boolean value of `true` or `false` -->
|
||||
save_writeback = false
|
||||
|
||||
[last_state]
|
||||
auto_load_last_rom = false
|
||||
current_directory = "sd://"
|
||||
|
||||
[boot_params]
|
||||
device_type = 0;
|
||||
reset_type = 1;
|
||||
detect_tv_type = true;
|
||||
detect_cic_seed = true;
|
||||
```
|
||||
Save it to the root folder on your SD card.
|
||||
|
||||
#### Save types
|
||||
`0` = NONE
|
||||
@ -50,7 +28,7 @@ Save it to the root folder on your SD card.
|
||||
|
||||
|
||||
### ED64
|
||||
Not currently not supported, but there is an aim to do so.
|
||||
Currently not supported, but there is an aim to do so.
|
||||
The aim is to replace [Altra64](https://github.com/networkfusion/altra64) and [ED64-UnofficialOS](https://github.com/n64-tools/ED64-UnofficialOS-binaries).
|
||||
|
||||
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit afa6c25f9e8186432d9480b5fe1aff4f29ab05a1
|
||||
Subproject commit 520419b7a952eb519c89539fb2cb2f097bf3c2cf
|
@ -89,12 +89,41 @@ static flashcart_error_t sc64_init (void) {
|
||||
}
|
||||
} while (writeback_pending);
|
||||
|
||||
const struct {
|
||||
sc64_cfg_t id;
|
||||
uint32_t value;
|
||||
} default_config[] = {
|
||||
{ CFG_BOOTLOADER_SWITCH, false },
|
||||
{ CFG_ROM_WRITE_ENABLE, false },
|
||||
{ CFG_ROM_SHADOW_ENABLE, false },
|
||||
{ CFG_DD_MODE, DD_MODE_DISABLED },
|
||||
{ CFG_ISV_ADDRESS, 0x00000000 },
|
||||
{ CFG_BOOT_MODE, BOOT_MODE_MENU },
|
||||
{ CFG_SAVE_TYPE, SAVE_TYPE_NONE },
|
||||
{ CFG_CIC_SEED, CIC_SEED_AUTO },
|
||||
{ CFG_TV_TYPE, TV_TYPE_PASSTHROUGH },
|
||||
{ CFG_DD_SD_ENABLE, false },
|
||||
{ CFG_DD_DRIVE_TYPE, DRIVE_TYPE_RETAIL },
|
||||
{ CFG_DD_DISK_STATE, DISK_STATE_EJECTED },
|
||||
{ CFG_BUTTON_MODE, BUTTON_MODE_NONE },
|
||||
{ CFG_ROM_EXTENDED_ENABLE, false },
|
||||
};
|
||||
|
||||
for (int i = 0; i < sizeof(default_config) / sizeof(default_config[0]); i++) {
|
||||
if (sc64_set_config(default_config[i].id, default_config[i].value) != SC64_OK) {
|
||||
return FLASHCART_ERROR_INT;
|
||||
}
|
||||
}
|
||||
|
||||
return FLASHCART_OK;
|
||||
}
|
||||
|
||||
static flashcart_error_t sc64_deinit (void) {
|
||||
// NOTE: Necessary because libcart enables ROM write by default
|
||||
sc64_set_config(CFG_ROM_WRITE_ENABLE, false);
|
||||
|
||||
sc64_lock();
|
||||
|
||||
return FLASHCART_OK;
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ typedef enum {
|
||||
CFG_ROM_WRITE_ENABLE,
|
||||
CFG_ROM_SHADOW_ENABLE,
|
||||
CFG_DD_MODE,
|
||||
CFG_ISV_ENABLE,
|
||||
CFG_ISV_ADDRESS,
|
||||
CFG_BOOT_MODE,
|
||||
CFG_SAVE_TYPE,
|
||||
CFG_CIC_SEED,
|
||||
@ -55,6 +55,21 @@ typedef enum {
|
||||
CFG_ROM_EXTENDED_ENABLE,
|
||||
} sc64_cfg_t;
|
||||
|
||||
typedef enum {
|
||||
DD_MODE_DISABLED = 0,
|
||||
DD_MODE_REGS = 1,
|
||||
DD_MODE_IPL = 2,
|
||||
DD_MODE_FULL = 3
|
||||
} sc64_dd_mode_t;
|
||||
|
||||
typedef enum {
|
||||
BOOT_MODE_MENU = 0,
|
||||
BOOT_MODE_ROM = 1,
|
||||
BOOT_MODE_DDIPL = 2,
|
||||
BOOT_MODE_DIRECT_ROM = 3,
|
||||
BOOT_MODE_DIRECT_DDIPL = 4,
|
||||
} sc64_boot_mode_t;
|
||||
|
||||
typedef enum {
|
||||
SAVE_TYPE_NONE,
|
||||
SAVE_TYPE_EEPROM_4K,
|
||||
@ -65,6 +80,35 @@ typedef enum {
|
||||
SAVE_TYPE_SRAM_128K,
|
||||
} sc64_save_type_t;
|
||||
|
||||
typedef enum {
|
||||
CIC_SEED_AUTO = 0xFFFF
|
||||
} sc64_cic_seed_t;
|
||||
|
||||
typedef enum {
|
||||
TV_TYPE_PAL = 0,
|
||||
TV_TYPE_NTSC = 1,
|
||||
TV_TYPE_MPAL = 2,
|
||||
TV_TYPE_PASSTHROUGH = 3
|
||||
} sc64_tv_type_t;
|
||||
|
||||
typedef enum {
|
||||
DRIVE_TYPE_RETAIL,
|
||||
DRIVE_TYPE_DEVELOPMENT,
|
||||
} sc64_drive_type_t;
|
||||
|
||||
typedef enum {
|
||||
DISK_STATE_EJECTED,
|
||||
DISK_STATE_INSERTED,
|
||||
DISK_STATE_CHANGED,
|
||||
} sc64_disk_state_t;
|
||||
|
||||
typedef enum {
|
||||
BUTTON_MODE_NONE,
|
||||
BUTTON_MODE_N64_IRQ,
|
||||
BUTTON_MODE_USB_PACKET,
|
||||
BUTTON_MODE_DD_DISK_SWAP,
|
||||
} sc64_button_mode_t;
|
||||
|
||||
|
||||
void sc64_unlock (void);
|
||||
void sc64_lock (void);
|
||||
|
@ -14,8 +14,7 @@
|
||||
#include "views/views.h"
|
||||
|
||||
|
||||
#define SETTINGS_FILE_PATH "config.txt"
|
||||
#define TV_TYPE_RAM *((uint32_t *) (0x80000300))
|
||||
#define TV_TYPE_RAM *((uint32_t *) (0x80000300))
|
||||
|
||||
|
||||
static menu_t *menu;
|
||||
@ -43,15 +42,13 @@ static void menu_init (boot_params_t *boot_params) {
|
||||
menu->mode = MENU_MODE_NONE;
|
||||
menu->next_mode = MENU_MODE_STARTUP;
|
||||
|
||||
settings_set_default_state(&menu->settings);
|
||||
|
||||
menu->flashcart_error = flashcart_init();
|
||||
if (menu->flashcart_error != FLASHCART_OK) {
|
||||
menu->next_mode = MENU_MODE_FAULT;
|
||||
} else {
|
||||
settings_load_from_file(SETTINGS_FILE_PATH, &menu->settings);
|
||||
}
|
||||
|
||||
settings_load(&menu->settings);
|
||||
|
||||
menu->boot_params = boot_params;
|
||||
|
||||
bool default_directory_exists = directory_exists(menu->settings.default_directory);
|
||||
|
@ -1,22 +1,36 @@
|
||||
#include <libdragon.h>
|
||||
|
||||
#include "libs/mini.c/src/mini.h"
|
||||
#include "path.h"
|
||||
#include "settings.h"
|
||||
#include "utils/fs.h"
|
||||
|
||||
|
||||
void settings_set_default_state (settings_t *settings) {
|
||||
settings->pal60 = false;
|
||||
settings->show_hidden_files = false;
|
||||
settings->default_directory = "/";
|
||||
#define SETTINGS_FILE_PATH "/config.ini"
|
||||
|
||||
|
||||
static settings_t init = {
|
||||
.pal60 = false,
|
||||
.show_hidden_files = false,
|
||||
.default_directory = "/",
|
||||
};
|
||||
|
||||
|
||||
void settings_load (settings_t *settings) {
|
||||
if (!file_exists(SETTINGS_FILE_PATH)) {
|
||||
settings_save(&init);
|
||||
}
|
||||
|
||||
mini_t *ini = mini_try_load("sd:/"SETTINGS_FILE_PATH);
|
||||
|
||||
settings->pal60 = mini_get_bool(ini, "menu", "pal60", init.pal60);
|
||||
settings->show_hidden_files = mini_get_bool(ini, "menu", "show_hidden_files", init.show_hidden_files);
|
||||
settings->default_directory = strdup(mini_get_string(ini, "menu", "default_directory", init.default_directory));
|
||||
|
||||
mini_free(ini);
|
||||
}
|
||||
|
||||
void settings_save_to_file (char *path, settings_t *settings) {
|
||||
path_t *config_file_path = path_init("sd:/");
|
||||
path_append(config_file_path, path);
|
||||
|
||||
mini_t *ini = mini_create(path_get(config_file_path));
|
||||
void settings_save (settings_t *settings) {
|
||||
mini_t *ini = mini_create("sd:/"SETTINGS_FILE_PATH);
|
||||
|
||||
mini_set_bool(ini, "menu", "pal60", settings->pal60);
|
||||
mini_set_bool(ini, "menu", "show_hidden_files", settings->show_hidden_files);
|
||||
@ -25,25 +39,4 @@ void settings_save_to_file (char *path, settings_t *settings) {
|
||||
mini_save(ini);
|
||||
|
||||
mini_free(ini);
|
||||
|
||||
path_free(config_file_path);
|
||||
}
|
||||
|
||||
void settings_load_from_file (char *path, settings_t *settings) {
|
||||
if (!file_exists(path)) {
|
||||
settings_save_to_file(path, settings);
|
||||
}
|
||||
|
||||
path_t *config_file_path = path_init("sd:/");
|
||||
path_append(config_file_path, path);
|
||||
|
||||
mini_t *ini = mini_try_load(path_get(config_file_path));
|
||||
|
||||
settings->pal60 = mini_get_bool(ini, "menu", "pal60", false);
|
||||
settings->show_hidden_files = mini_get_bool(ini, "menu", "show_hidden_files", false);
|
||||
settings->default_directory = strdup(mini_get_string(ini, "menu", "default_directory", "/"));
|
||||
|
||||
mini_free(ini);
|
||||
|
||||
path_free(config_file_path);
|
||||
}
|
||||
|
@ -10,15 +10,19 @@
|
||||
|
||||
/** @brief Settings Structure */
|
||||
typedef struct {
|
||||
/** @brief Select 60 Hz refresh rate if running on PAL console */
|
||||
bool pal60;
|
||||
|
||||
/** @brief Show files marked as hidden in the browser */
|
||||
bool show_hidden_files;
|
||||
|
||||
/** @brief Default directory to navigate to when menu loads */
|
||||
char *default_directory;
|
||||
} settings_t;
|
||||
|
||||
|
||||
void settings_set_default_state (settings_t *settings);
|
||||
void settings_save_to_file (char *path, settings_t *settings);
|
||||
void settings_load_from_file (char *path, settings_t *settings);
|
||||
void settings_load (settings_t *settings);
|
||||
void settings_save (settings_t *settings);
|
||||
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user