Skip to content

Commit

Permalink
Add compatibility with startup
Browse files Browse the repository at this point in the history
(untested).
  • Loading branch information
networkfusion committed Dec 4, 2024
1 parent 9da4d08 commit 1192881
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/menu/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ static settings_t init = {
.use_saves_folder = true,
.sound_enabled = true,
.rom_autoload_enabled = false,
.disk_autoload_enabled = false,
.rom_autoload_path = "",
.disk_autoload_path = "",
.rom_autoload_filename = "",
.disk_autoload_filename = "",
.autoload_disk_uses_rom = false,

/* Beta feature flags (should always init to off) */
.bgm_enabled = false,
Expand Down Expand Up @@ -48,11 +48,11 @@ void settings_load (settings_t *settings) {
settings->sound_enabled = mini_get_bool(ini, "menu", "sound_enabled", init.sound_enabled);

settings->rom_autoload_enabled = mini_get_bool(ini, "menu", "autoload_rom_enabled", init.rom_autoload_enabled);
settings->disk_autoload_enabled = mini_get_bool(ini, "menu", "autoload_rom_enabled", init.rom_autoload_enabled);
settings->rom_autoload_path = strdup(mini_get_string(ini, "autoload", "rom_path", init.rom_autoload_path));
settings->disk_autoload_path = strdup(mini_get_string(ini, "autoload", "disk_path", init.disk_autoload_path));
settings->rom_autoload_filename = strdup(mini_get_string(ini, "autoload", "rom_filename", init.rom_autoload_filename));
settings->disk_autoload_filename = strdup(mini_get_string(ini, "autoload", "disk_filename", init.disk_autoload_filename));
settings->autoload_disk_uses_rom = mini_get_bool(ini, "autoload", "disk_uses_rom", init.autoload_disk_uses_rom);

/* Beta feature flags, they might not be in the file */
settings->bgm_enabled = mini_get_bool(ini, "menu_beta_flag", "bgm_enabled", init.bgm_enabled);
Expand All @@ -70,11 +70,11 @@ void settings_save (settings_t *settings) {
mini_set_bool(ini, "menu", "use_saves_folder", settings->use_saves_folder);
mini_set_bool(ini, "menu", "sound_enabled", settings->sound_enabled);
mini_set_bool(ini, "menu", "autoload_rom_enabled", settings->rom_autoload_enabled);
mini_set_bool(ini, "menu", "autoload_disk_enabled", settings->disk_autoload_enabled);
mini_set_string(ini, "autoload", "rom_path", settings->rom_autoload_path);
mini_set_string(ini, "autoload", "disk_path", settings->disk_autoload_path);
mini_set_string(ini, "autoload", "rom_filename", settings->rom_autoload_filename);
mini_set_string(ini, "autoload", "disk_filename", settings->disk_autoload_filename);
mini_set_bool(ini, "autoload", "disk_uses_rom", settings->autoload_disk_uses_rom);

/* Beta feature flags, they should not save until production ready! */
// mini_set_bool(ini, "menu_beta_flag", "bgm_enabled", settings->bgm_enabled);
Expand Down
6 changes: 3 additions & 3 deletions src/menu/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ typedef struct {
/** @brief Enable the ability to bypass the menu and instantly load a ROM */
bool rom_autoload_enabled;

/** @brief Enable the ability to bypass the menu and instantly load a Disk (with ROM if also enabled) */
bool disk_autoload_enabled;

/** @brief A path to the autoloaded ROM */
char *rom_autoload_path;

Expand All @@ -46,9 +49,6 @@ typedef struct {
/** @brief A filename of the autoloaded DD image */
char *disk_autoload_filename;

/** @brief Load a DD image with a ROM compatible with expansion */
bool autoload_disk_uses_rom;

} settings_t;


Expand Down
2 changes: 1 addition & 1 deletion src/menu/views/load_disk.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ static void set_autoload_type (menu_t *menu, void *arg) {
free(menu->settings.disk_autoload_filename);
menu->settings.disk_autoload_filename = strdup(menu->browser.entry->name);
// FIXME: add a confirmation box here! (press start on reboot)
menu->settings.rom_autoload_enabled = true;
menu->settings.disk_autoload_enabled = true;
settings_save(&menu->settings);
menu->browser.reload = true;
}
Expand Down
13 changes: 12 additions & 1 deletion src/menu/views/startup.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@ void view_startup_init (menu_t *menu) {
joypad_poll();
joypad_buttons_t b_held = joypad_get_buttons_held(port);

if (menu->settings.rom_autoload_enabled && b_held.start) {
if ((menu->settings.rom_autoload_enabled || menu->settings.disk_autoload_enabled) && b_held.start) {
menu->settings.rom_autoload_enabled = false;
menu->settings.disk_autoload_enabled = false;
menu->settings.rom_autoload_path = "";
menu->settings.disk_autoload_path = "";
menu->settings.rom_autoload_filename = "";
menu->settings.disk_autoload_filename = "";
settings_save(&menu->settings);
}
}
Expand All @@ -29,6 +32,14 @@ void view_startup_init (menu_t *menu) {

return;
}
else if (menu->settings.disk_autoload_enabled) {
menu->browser.directory = path_init(menu->storage_prefix, menu->settings.disk_autoload_path);
menu->load.disk_path = path_clone_push(menu->browser.directory, menu->settings.disk_autoload_filename);
menu->boot_pending.disk_file = true;
menu->next_mode = MENU_MODE_LOAD_DISK;

return;
}

menu->next_mode = MENU_MODE_BROWSER;
}
Expand Down

0 comments on commit 1192881

Please sign in to comment.