2018-07-01 17:45:25 +00:00
|
|
|
/*
|
2020-03-14 07:24:24 +00:00
|
|
|
* Copyright (c) 2018-2020 CTCaer
|
2018-08-05 11:40:32 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms and conditions of the GNU General Public License,
|
|
|
|
* version 2, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2018-07-01 17:45:25 +00:00
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "ini.h"
|
2019-02-23 22:35:24 +00:00
|
|
|
#include "../gfx/gfx.h"
|
2018-08-13 08:58:24 +00:00
|
|
|
#include "../gfx/tui.h"
|
2019-02-23 22:35:24 +00:00
|
|
|
#include "../libs/fatfs/ff.h"
|
|
|
|
#include "../soc/t210.h"
|
2020-04-29 20:20:18 +00:00
|
|
|
#include "../storage/nx_sd.h"
|
2019-09-12 20:08:38 +00:00
|
|
|
#include "../storage/sdmmc.h"
|
2019-02-23 22:35:24 +00:00
|
|
|
#include "../utils/btn.h"
|
|
|
|
#include "../utils/list.h"
|
2018-08-13 08:58:24 +00:00
|
|
|
#include "../utils/util.h"
|
2018-07-01 17:45:25 +00:00
|
|
|
|
|
|
|
extern hekate_config h_cfg;
|
|
|
|
|
|
|
|
void set_default_configuration()
|
|
|
|
{
|
|
|
|
h_cfg.autoboot = 0;
|
2018-08-21 01:37:40 +00:00
|
|
|
h_cfg.autoboot_list = 0;
|
2018-07-01 17:45:25 +00:00
|
|
|
h_cfg.bootwait = 3;
|
2018-07-09 13:02:47 +00:00
|
|
|
h_cfg.se_keygen_done = 0;
|
2018-07-09 13:06:17 +00:00
|
|
|
h_cfg.sbar_time_keeping = 0;
|
2018-09-18 21:01:42 +00:00
|
|
|
h_cfg.backlight = 100;
|
2018-12-16 14:59:25 +00:00
|
|
|
h_cfg.autohosoff = 0;
|
2019-02-23 23:06:24 +00:00
|
|
|
h_cfg.autonogc = 1;
|
2019-12-11 22:13:32 +00:00
|
|
|
h_cfg.updater2p = 0;
|
2019-06-30 00:55:19 +00:00
|
|
|
h_cfg.brand = NULL;
|
|
|
|
h_cfg.tagline = NULL;
|
2019-06-30 00:15:46 +00:00
|
|
|
h_cfg.errors = 0;
|
2020-04-30 00:43:29 +00:00
|
|
|
h_cfg.eks = NULL;
|
2019-02-23 23:06:24 +00:00
|
|
|
h_cfg.sept_run = EMC(EMC_SCRATCH0) & EMC_SEPT_RUN;
|
2020-06-13 15:16:29 +00:00
|
|
|
h_cfg.rcm_patched = fuse_check_patched_rcm();
|
2019-06-30 00:40:37 +00:00
|
|
|
h_cfg.emummc_force_disable = false;
|
2019-09-12 20:08:38 +00:00
|
|
|
|
2020-01-17 07:19:58 +00:00
|
|
|
sd_power_cycle_time_start = 0;
|
2018-07-01 17:45:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int create_config_entry()
|
|
|
|
{
|
|
|
|
if (!sd_mount())
|
|
|
|
return 1;
|
|
|
|
|
2019-08-27 22:08:57 +00:00
|
|
|
char lbuf[32];
|
2018-07-01 17:45:25 +00:00
|
|
|
FIL fp;
|
2018-09-18 20:47:37 +00:00
|
|
|
bool mainIniFound = false;
|
2018-07-01 17:45:25 +00:00
|
|
|
|
|
|
|
LIST_INIT(ini_sections);
|
|
|
|
|
2018-08-21 01:37:40 +00:00
|
|
|
if (ini_parse(&ini_sections, "bootloader/hekate_ipl.ini", false))
|
2018-09-18 20:47:37 +00:00
|
|
|
mainIniFound = true;
|
|
|
|
else
|
2018-07-01 17:45:25 +00:00
|
|
|
{
|
2018-09-18 20:47:37 +00:00
|
|
|
u8 res = f_open(&fp, "bootloader/hekate_ipl.ini", FA_READ);
|
|
|
|
if (res == FR_NO_FILE || res == FR_NO_PATH)
|
|
|
|
{
|
|
|
|
f_mkdir("bootloader");
|
|
|
|
f_mkdir("bootloader/ini");
|
|
|
|
f_mkdir("bootloader/payloads");
|
|
|
|
f_mkdir("bootloader/sys");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!res)
|
|
|
|
f_close(&fp);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
2018-07-01 17:45:25 +00:00
|
|
|
|
2018-09-18 20:47:37 +00:00
|
|
|
if (f_open(&fp, "bootloader/hekate_ipl.ini", FA_WRITE | FA_CREATE_ALWAYS) != FR_OK)
|
|
|
|
return 1;
|
|
|
|
// Add config entry.
|
|
|
|
f_puts("[config]\nautoboot=", &fp);
|
|
|
|
itoa(h_cfg.autoboot, lbuf, 10);
|
|
|
|
f_puts(lbuf, &fp);
|
|
|
|
f_puts("\nautoboot_list=", &fp);
|
|
|
|
itoa(h_cfg.autoboot_list, lbuf, 10);
|
|
|
|
f_puts(lbuf, &fp);
|
|
|
|
f_puts("\nbootwait=", &fp);
|
|
|
|
itoa(h_cfg.bootwait, lbuf, 10);
|
|
|
|
f_puts(lbuf, &fp);
|
2018-09-18 21:01:42 +00:00
|
|
|
f_puts("\nbacklight=", &fp);
|
|
|
|
itoa(h_cfg.backlight, lbuf, 10);
|
|
|
|
f_puts(lbuf, &fp);
|
2018-09-24 20:45:06 +00:00
|
|
|
f_puts("\nautohosoff=", &fp);
|
|
|
|
itoa(h_cfg.autohosoff, lbuf, 10);
|
|
|
|
f_puts(lbuf, &fp);
|
2019-02-23 23:06:24 +00:00
|
|
|
f_puts("\nautonogc=", &fp);
|
|
|
|
itoa(h_cfg.autonogc, lbuf, 10);
|
|
|
|
f_puts(lbuf, &fp);
|
2019-12-11 22:13:32 +00:00
|
|
|
f_puts("\nupdater2p=", &fp);
|
|
|
|
itoa(h_cfg.updater2p, lbuf, 10);
|
|
|
|
f_puts(lbuf, &fp);
|
2019-06-30 00:55:19 +00:00
|
|
|
if (h_cfg.brand)
|
|
|
|
{
|
|
|
|
f_puts("\nbrand=", &fp);
|
|
|
|
f_puts(h_cfg.brand, &fp);
|
|
|
|
}
|
|
|
|
if (h_cfg.tagline)
|
|
|
|
{
|
|
|
|
f_puts("\ntagline=", &fp);
|
|
|
|
f_puts(h_cfg.tagline, &fp);
|
|
|
|
}
|
2018-09-18 20:47:37 +00:00
|
|
|
f_puts("\n", &fp);
|
|
|
|
|
|
|
|
if (mainIniFound)
|
|
|
|
{
|
2018-07-01 17:45:25 +00:00
|
|
|
// Re-construct existing entries.
|
|
|
|
LIST_FOREACH_ENTRY(ini_sec_t, ini_sec, &ini_sections, link)
|
|
|
|
{
|
|
|
|
if (!strcmp(ini_sec->name, "config"))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
switch (ini_sec->type)
|
|
|
|
{
|
|
|
|
case INI_CHOICE: // Re-construct Boot entry [ ].
|
|
|
|
f_puts("[", &fp);
|
|
|
|
f_puts(ini_sec->name, &fp);
|
|
|
|
f_puts("]\n", &fp);
|
|
|
|
// Re-construct boot entry's config.
|
|
|
|
LIST_FOREACH_ENTRY(ini_kv_t, kv, &ini_sec->kvs, link)
|
|
|
|
{
|
|
|
|
f_puts(kv->key, &fp);
|
|
|
|
f_puts("=", &fp);
|
|
|
|
f_puts(kv->val, &fp);
|
|
|
|
f_puts("\n", &fp);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case INI_CAPTION: // Re-construct caption entry { }.
|
|
|
|
f_puts("{", &fp);
|
|
|
|
f_puts(ini_sec->name, &fp);
|
|
|
|
f_puts("}\n", &fp);
|
|
|
|
break;
|
|
|
|
case INI_NEWLINE: // Re-construct cosmetic newline \n.
|
|
|
|
f_puts("\n", &fp);
|
|
|
|
break;
|
|
|
|
case INI_COMMENT: // Re-construct comment entry #.
|
|
|
|
f_puts("#", &fp);
|
|
|
|
f_puts(ini_sec->name, &fp);
|
|
|
|
f_puts("\n", &fp);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-18 20:47:37 +00:00
|
|
|
f_close(&fp);
|
2020-06-13 15:32:40 +00:00
|
|
|
sd_end();
|
2018-09-18 20:47:37 +00:00
|
|
|
|
2018-07-01 17:45:25 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-06-30 00:15:46 +00:00
|
|
|
#pragma GCC push_options
|
|
|
|
#pragma GCC optimize ("Os")
|
|
|
|
|
2019-02-23 22:35:24 +00:00
|
|
|
static void _save_config()
|
|
|
|
{
|
2019-04-13 23:30:14 +00:00
|
|
|
gfx_clear_grey(0x1B);
|
|
|
|
gfx_con_setpos(0, 0);
|
2019-02-23 22:35:24 +00:00
|
|
|
|
|
|
|
if (!create_config_entry())
|
2019-04-13 23:30:14 +00:00
|
|
|
gfx_puts("\nConfiguration was saved!\n");
|
2019-02-23 22:35:24 +00:00
|
|
|
else
|
|
|
|
EPRINTF("\nConfiguration saving failed!");
|
2019-04-13 23:30:14 +00:00
|
|
|
gfx_puts("\nPress any key...");
|
2019-02-23 22:35:24 +00:00
|
|
|
}
|
|
|
|
|
2018-12-16 18:21:59 +00:00
|
|
|
static void _config_autoboot_list(void *ent)
|
2018-07-01 17:45:25 +00:00
|
|
|
{
|
2019-04-13 23:30:14 +00:00
|
|
|
gfx_clear_grey(0x1B);
|
|
|
|
gfx_con_setpos(0, 0);
|
2018-07-01 17:45:25 +00:00
|
|
|
|
|
|
|
u32 *temp_autoboot = NULL;
|
|
|
|
|
|
|
|
LIST_INIT(ini_sections);
|
|
|
|
|
2018-08-21 01:26:14 +00:00
|
|
|
u8 max_entries = 30;
|
2018-07-01 17:45:25 +00:00
|
|
|
|
|
|
|
ment_t *ments = (ment_t *)malloc(sizeof(ment_t) * (max_entries + 3));
|
|
|
|
u32 *boot_values = (u32 *)malloc(sizeof(u32) * max_entries);
|
|
|
|
char *boot_text = (char *)malloc(512 * max_entries);
|
|
|
|
|
|
|
|
for (u32 j = 0; j < max_entries; j++)
|
|
|
|
boot_values[j] = j;
|
|
|
|
|
|
|
|
if (sd_mount())
|
|
|
|
{
|
2018-08-21 01:37:40 +00:00
|
|
|
if (ini_parse(&ini_sections, "bootloader/ini", true))
|
|
|
|
{
|
|
|
|
// Build configuration menu.
|
|
|
|
ments[0].type = MENT_BACK;
|
|
|
|
ments[0].caption = "Back";
|
|
|
|
|
|
|
|
ments[1].type = MENT_CHGLINE;
|
|
|
|
|
|
|
|
u32 i = 2;
|
|
|
|
LIST_FOREACH_ENTRY(ini_sec_t, ini_sec, &ini_sections, link)
|
|
|
|
{
|
|
|
|
// Skip other ini entries for autoboot.
|
|
|
|
if (ini_sec->type == INI_CHOICE)
|
|
|
|
{
|
|
|
|
if (!strcmp(ini_sec->name, "config"))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (strlen(ini_sec->name) > 510)
|
|
|
|
ments[i].caption = ini_sec->name;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (h_cfg.autoboot != (i - 1) || !h_cfg.autoboot_list)
|
|
|
|
boot_text[(i - 1) * 512] = ' ';
|
|
|
|
|
|
|
|
else
|
|
|
|
boot_text[(i - 1) * 512] = '*';
|
2019-12-04 13:56:53 +00:00
|
|
|
strcpy(boot_text + (i - 1) * 512 + 1, ini_sec->name);
|
2018-08-21 01:37:40 +00:00
|
|
|
ments[i].caption = &boot_text[(i - 1) * 512];
|
|
|
|
}
|
|
|
|
ments[i].type = ini_sec->type;
|
|
|
|
ments[i].data = &boot_values[i - 1];
|
|
|
|
i++;
|
|
|
|
|
|
|
|
if ((i - 1) > max_entries)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(&ments[i], 0, sizeof(ment_t));
|
2019-02-23 22:35:24 +00:00
|
|
|
menu_t menu = {ments, "Select an entry to auto boot", 0, 0};
|
2019-04-13 23:30:14 +00:00
|
|
|
temp_autoboot = (u32 *)tui_do_menu(&menu);
|
2018-08-21 01:37:40 +00:00
|
|
|
if (temp_autoboot != NULL)
|
|
|
|
{
|
|
|
|
h_cfg.autoboot = *(u32 *)temp_autoboot;
|
|
|
|
h_cfg.autoboot_list = 1;
|
2019-02-23 22:35:24 +00:00
|
|
|
_save_config();
|
2018-12-16 18:21:59 +00:00
|
|
|
|
|
|
|
ment_t *tmp = (ment_t *)ent;
|
|
|
|
tmp->data = NULL;
|
2018-08-21 01:37:40 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
goto out2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-02-23 22:35:24 +00:00
|
|
|
EPRINTF("Could not open 'bootloader/hekate_ipl.ini'.\nMake sure it exists!.");
|
2018-08-21 01:37:40 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
out:;
|
|
|
|
btn_wait();
|
|
|
|
out2:;
|
|
|
|
free(ments);
|
|
|
|
free(boot_values);
|
|
|
|
free(boot_text);
|
|
|
|
|
2020-06-13 15:32:40 +00:00
|
|
|
sd_end();
|
2018-08-21 01:37:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void config_autoboot()
|
|
|
|
{
|
2019-04-13 23:30:14 +00:00
|
|
|
gfx_clear_grey(0x1B);
|
|
|
|
gfx_con_setpos(0, 0);
|
2018-08-21 01:37:40 +00:00
|
|
|
|
|
|
|
u32 *temp_autoboot = NULL;
|
|
|
|
|
|
|
|
LIST_INIT(ini_sections);
|
|
|
|
|
|
|
|
u8 max_entries = 30;
|
2020-01-17 07:22:28 +00:00
|
|
|
u32 boot_text_size = 512;
|
2018-08-21 01:37:40 +00:00
|
|
|
|
|
|
|
ment_t *ments = (ment_t *)malloc(sizeof(ment_t) * (max_entries + 5));
|
|
|
|
u32 *boot_values = (u32 *)malloc(sizeof(u32) * max_entries);
|
2020-01-17 07:22:28 +00:00
|
|
|
char *boot_text = (char *)malloc(boot_text_size * max_entries);
|
2018-08-21 01:37:40 +00:00
|
|
|
|
|
|
|
for (u32 j = 0; j < max_entries; j++)
|
|
|
|
boot_values[j] = j;
|
|
|
|
|
|
|
|
if (sd_mount())
|
|
|
|
{
|
|
|
|
if (ini_parse(&ini_sections, "bootloader/hekate_ipl.ini", false))
|
2018-07-01 17:45:25 +00:00
|
|
|
{
|
|
|
|
// Build configuration menu.
|
|
|
|
ments[0].type = MENT_BACK;
|
|
|
|
ments[0].caption = "Back";
|
|
|
|
|
|
|
|
ments[1].type = MENT_CHGLINE;
|
|
|
|
|
2018-09-24 20:22:19 +00:00
|
|
|
ments[2].type = MENT_DATA;
|
2018-07-01 17:45:25 +00:00
|
|
|
if (!h_cfg.autoboot)
|
|
|
|
ments[2].caption = "*Disable";
|
|
|
|
else
|
|
|
|
ments[2].caption = " Disable";
|
|
|
|
ments[2].data = &boot_values[0];
|
|
|
|
|
2018-12-16 18:21:59 +00:00
|
|
|
ments[3].type = MENT_HDLR_RE;
|
2018-08-21 01:37:40 +00:00
|
|
|
if (h_cfg.autoboot_list)
|
|
|
|
ments[3].caption = "*More configs...";
|
|
|
|
else
|
|
|
|
ments[3].caption = " More configs...";
|
|
|
|
ments[3].handler = _config_autoboot_list;
|
2018-12-16 18:21:59 +00:00
|
|
|
ments[3].data = (void *)0xCAFE;
|
2018-08-21 01:37:40 +00:00
|
|
|
|
|
|
|
ments[4].type = MENT_CHGLINE;
|
|
|
|
|
|
|
|
u32 i = 5;
|
2018-07-01 17:45:25 +00:00
|
|
|
LIST_FOREACH_ENTRY(ini_sec_t, ini_sec, &ini_sections, link)
|
|
|
|
{
|
|
|
|
// Skip other ini entries for autoboot.
|
|
|
|
if (ini_sec->type == INI_CHOICE)
|
|
|
|
{
|
|
|
|
if (!strcmp(ini_sec->name, "config"))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (strlen(ini_sec->name) > 510)
|
|
|
|
ments[i].caption = ini_sec->name;
|
|
|
|
else
|
|
|
|
{
|
2018-08-21 01:37:40 +00:00
|
|
|
if (h_cfg.autoboot != (i - 4) || h_cfg.autoboot_list)
|
2020-01-17 07:22:28 +00:00
|
|
|
boot_text[(i - 4) * boot_text_size] = ' ';
|
2018-07-01 17:45:25 +00:00
|
|
|
|
|
|
|
else
|
2020-01-17 07:22:28 +00:00
|
|
|
boot_text[(i - 4) * boot_text_size] = '*';
|
|
|
|
strcpy(boot_text + (i - 4) * boot_text_size + 1, ini_sec->name);
|
|
|
|
ments[i].caption = &boot_text[(i - 4) * boot_text_size];
|
2018-07-01 17:45:25 +00:00
|
|
|
}
|
|
|
|
ments[i].type = ini_sec->type;
|
2018-08-21 01:37:40 +00:00
|
|
|
ments[i].data = &boot_values[i - 4];
|
2018-07-01 17:45:25 +00:00
|
|
|
i++;
|
|
|
|
|
2018-08-21 01:37:40 +00:00
|
|
|
if ((i - 4) > max_entries)
|
2018-07-01 17:45:25 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2018-08-21 01:37:40 +00:00
|
|
|
if (i < 6 && !h_cfg.autoboot_list)
|
2018-07-01 17:45:25 +00:00
|
|
|
{
|
2018-09-18 20:47:37 +00:00
|
|
|
ments[i].type = MENT_CAPTION;
|
|
|
|
ments[i].caption = "No main configurations found...";
|
|
|
|
ments[i].color = 0xFFFFDD00;
|
|
|
|
i++;
|
2018-07-01 17:45:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
memset(&ments[i], 0, sizeof(ment_t));
|
2018-08-05 11:40:32 +00:00
|
|
|
menu_t menu = {ments, "Disable or select entry to auto boot", 0, 0};
|
2019-04-13 23:30:14 +00:00
|
|
|
temp_autoboot = (u32 *)tui_do_menu(&menu);
|
2018-07-01 17:45:25 +00:00
|
|
|
if (temp_autoboot != NULL)
|
|
|
|
{
|
|
|
|
h_cfg.autoboot = *(u32 *)temp_autoboot;
|
2018-08-21 01:37:40 +00:00
|
|
|
h_cfg.autoboot_list = 0;
|
2019-02-23 22:35:24 +00:00
|
|
|
_save_config();
|
2018-07-01 17:45:25 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
goto out2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-02-23 22:35:24 +00:00
|
|
|
EPRINTF("Could not open 'bootloader/hekate_ipl.ini'.\nMake sure it exists!.");
|
2018-07-01 17:45:25 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
out:;
|
|
|
|
btn_wait();
|
|
|
|
out2:;
|
|
|
|
free(ments);
|
|
|
|
free(boot_values);
|
|
|
|
free(boot_text);
|
|
|
|
|
2020-06-13 15:32:40 +00:00
|
|
|
sd_end();
|
2018-07-01 17:45:25 +00:00
|
|
|
|
|
|
|
if (temp_autoboot == NULL)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void config_bootdelay()
|
|
|
|
{
|
2019-04-13 23:30:14 +00:00
|
|
|
gfx_clear_grey(0x1B);
|
|
|
|
gfx_con_setpos(0, 0);
|
2018-07-01 17:45:25 +00:00
|
|
|
|
|
|
|
u32 delay_entries = 6;
|
2020-01-17 07:22:28 +00:00
|
|
|
u32 delay_text_size = 32;
|
2018-07-01 17:45:25 +00:00
|
|
|
|
|
|
|
ment_t *ments = (ment_t *)malloc(sizeof(ment_t) * (delay_entries + 3));
|
|
|
|
u32 *delay_values = (u32 *)malloc(sizeof(u32) * delay_entries);
|
2020-01-17 07:22:28 +00:00
|
|
|
char *delay_text = (char *)malloc(delay_text_size * delay_entries);
|
2018-07-01 17:45:25 +00:00
|
|
|
|
|
|
|
for (u32 j = 0; j < delay_entries; j++)
|
|
|
|
delay_values[j] = j;
|
|
|
|
|
|
|
|
ments[0].type = MENT_BACK;
|
|
|
|
ments[0].caption = "Back";
|
|
|
|
|
|
|
|
ments[1].type = MENT_CHGLINE;
|
|
|
|
|
2018-09-24 20:22:19 +00:00
|
|
|
ments[2].type = MENT_DATA;
|
2018-07-01 17:45:25 +00:00
|
|
|
if (h_cfg.bootwait)
|
|
|
|
ments[2].caption = " 0 seconds (Bootlogo disabled)";
|
|
|
|
else
|
|
|
|
ments[2].caption = "*0 seconds (Bootlogo disabled)";
|
|
|
|
ments[2].data = &delay_values[0];
|
|
|
|
|
|
|
|
u32 i = 0;
|
|
|
|
for (i = 1; i < delay_entries; i++)
|
|
|
|
{
|
|
|
|
if (h_cfg.bootwait != i)
|
2020-01-17 07:22:28 +00:00
|
|
|
delay_text[i * delay_text_size] = ' ';
|
2018-07-01 17:45:25 +00:00
|
|
|
else
|
2020-01-17 07:22:28 +00:00
|
|
|
delay_text[i * delay_text_size] = '*';
|
|
|
|
delay_text[i * delay_text_size + 1] = i + '0';
|
|
|
|
strcpy(delay_text + i * delay_text_size + 2, " seconds");
|
2018-08-05 11:40:32 +00:00
|
|
|
|
2018-09-24 20:22:19 +00:00
|
|
|
ments[i + 2].type = MENT_DATA;
|
2020-01-17 07:22:28 +00:00
|
|
|
ments[i + 2].caption = delay_text + (i * delay_text_size);
|
2018-07-01 17:45:25 +00:00
|
|
|
ments[i + 2].data = &delay_values[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(&ments[i + 2], 0, sizeof(ment_t));
|
2018-08-05 11:40:32 +00:00
|
|
|
menu_t menu = {ments, "Time delay for entering bootloader menu", 0, 0};
|
2018-07-01 17:45:25 +00:00
|
|
|
|
2019-04-13 23:30:14 +00:00
|
|
|
u32 *temp_bootwait = (u32 *)tui_do_menu(&menu);
|
2018-07-01 17:45:25 +00:00
|
|
|
if (temp_bootwait != NULL)
|
|
|
|
{
|
|
|
|
h_cfg.bootwait = *(u32 *)temp_bootwait;
|
2019-02-23 22:35:24 +00:00
|
|
|
_save_config();
|
2018-07-01 17:45:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
free(ments);
|
|
|
|
free(delay_values);
|
|
|
|
free(delay_text);
|
|
|
|
|
|
|
|
if (temp_bootwait == NULL)
|
|
|
|
return;
|
|
|
|
btn_wait();
|
|
|
|
}
|
|
|
|
|
2018-09-18 21:01:42 +00:00
|
|
|
void config_backlight()
|
|
|
|
{
|
2019-04-13 23:30:14 +00:00
|
|
|
gfx_clear_grey(0x1B);
|
|
|
|
gfx_con_setpos(0, 0);
|
2018-09-18 21:01:42 +00:00
|
|
|
|
2020-01-17 07:22:28 +00:00
|
|
|
u32 bri_text_size = 8;
|
2018-09-18 21:01:42 +00:00
|
|
|
u32 bri_entries = 11;
|
|
|
|
|
|
|
|
ment_t *ments = (ment_t *)malloc(sizeof(ment_t) * (bri_entries + 3));
|
|
|
|
u32 *bri_values = (u32 *)malloc(sizeof(u32) * bri_entries);
|
2020-01-17 07:22:28 +00:00
|
|
|
char *bri_text = (char *)malloc(bri_text_size * bri_entries);
|
2018-09-18 21:01:42 +00:00
|
|
|
|
|
|
|
for (u32 j = 1; j < bri_entries; j++)
|
|
|
|
bri_values[j] = j * 10;
|
|
|
|
|
|
|
|
ments[0].type = MENT_BACK;
|
|
|
|
ments[0].caption = "Back";
|
|
|
|
|
|
|
|
ments[1].type = MENT_CHGLINE;
|
|
|
|
|
|
|
|
u32 i = 0;
|
|
|
|
for (i = 1; i < bri_entries; i++)
|
|
|
|
{
|
|
|
|
if ((h_cfg.backlight / 20) != i)
|
2020-01-17 07:22:28 +00:00
|
|
|
bri_text[i * bri_text_size] = ' ';
|
2018-09-18 21:01:42 +00:00
|
|
|
else
|
2020-01-17 07:22:28 +00:00
|
|
|
bri_text[i * bri_text_size] = '*';
|
2019-10-18 15:02:06 +00:00
|
|
|
|
2018-09-18 21:01:42 +00:00
|
|
|
if (i < 10)
|
|
|
|
{
|
2020-01-17 07:22:28 +00:00
|
|
|
bri_text[i * bri_text_size + 1] = i + '0';
|
|
|
|
strcpy(bri_text + i * bri_text_size + 2, "0%");
|
2018-09-18 21:01:42 +00:00
|
|
|
}
|
|
|
|
else
|
2020-01-17 07:22:28 +00:00
|
|
|
strcpy(bri_text + i * bri_text_size + 1, "100%");
|
2018-09-18 21:01:42 +00:00
|
|
|
|
2018-09-24 20:22:19 +00:00
|
|
|
ments[i + 1].type = MENT_DATA;
|
2020-01-17 07:22:28 +00:00
|
|
|
ments[i + 1].caption = bri_text + (i * bri_text_size);
|
2018-09-18 21:01:42 +00:00
|
|
|
ments[i + 1].data = &bri_values[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(&ments[i + 1], 0, sizeof(ment_t));
|
|
|
|
menu_t menu = {ments, "Backlight brightness", 0, 0};
|
|
|
|
|
2019-04-13 23:30:14 +00:00
|
|
|
u32 *temp_backlight = (u32 *)tui_do_menu(&menu);
|
2018-09-18 21:01:42 +00:00
|
|
|
if (temp_backlight != NULL)
|
|
|
|
{
|
|
|
|
h_cfg.backlight = (*(u32 *)temp_backlight) * 2;
|
2019-02-23 22:35:24 +00:00
|
|
|
_save_config();
|
2018-09-18 21:01:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
free(ments);
|
|
|
|
free(bri_values);
|
|
|
|
free(bri_text);
|
|
|
|
|
|
|
|
if (temp_backlight == NULL)
|
|
|
|
return;
|
|
|
|
btn_wait();
|
|
|
|
}
|
2018-09-24 20:45:06 +00:00
|
|
|
|
|
|
|
void config_auto_hos_poweroff()
|
|
|
|
{
|
2019-04-13 23:30:14 +00:00
|
|
|
gfx_clear_grey(0x1B);
|
|
|
|
gfx_con_setpos(0, 0);
|
2018-09-24 20:45:06 +00:00
|
|
|
|
2018-09-29 23:09:18 +00:00
|
|
|
ment_t *ments = (ment_t *)malloc(sizeof(ment_t) * 6);
|
|
|
|
u32 *hp_values = (u32 *)malloc(sizeof(u32) * 3);
|
2018-09-24 20:45:06 +00:00
|
|
|
|
2018-09-29 23:09:18 +00:00
|
|
|
for (u32 j = 0; j < 3; j++)
|
2018-09-24 20:45:06 +00:00
|
|
|
{
|
|
|
|
hp_values[j] = j;
|
|
|
|
ments[j + 2].type = MENT_DATA;
|
|
|
|
ments[j + 2].data = &hp_values[j];
|
|
|
|
}
|
|
|
|
|
|
|
|
ments[0].type = MENT_BACK;
|
|
|
|
ments[0].caption = "Back";
|
|
|
|
|
|
|
|
ments[1].type = MENT_CHGLINE;
|
|
|
|
|
2018-09-29 23:09:18 +00:00
|
|
|
if (h_cfg.autohosoff == 1)
|
2018-09-24 20:45:06 +00:00
|
|
|
{
|
|
|
|
ments[2].caption = " Disable";
|
|
|
|
ments[3].caption = "*Enable";
|
2018-09-29 23:09:18 +00:00
|
|
|
ments[4].caption = " Enable (No logo)";
|
|
|
|
}
|
|
|
|
else if (h_cfg.autohosoff >= 2)
|
|
|
|
{
|
|
|
|
ments[2].caption = " Disable";
|
|
|
|
ments[3].caption = " Enable";
|
|
|
|
ments[4].caption = "*Enable (No logo)";
|
2018-09-24 20:45:06 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ments[2].caption = "*Disable";
|
|
|
|
ments[3].caption = " Enable";
|
2018-09-29 23:09:18 +00:00
|
|
|
ments[4].caption = " Enable (No logo)";
|
2018-09-24 20:45:06 +00:00
|
|
|
}
|
|
|
|
|
2018-09-29 23:09:18 +00:00
|
|
|
memset(&ments[5], 0, sizeof(ment_t));
|
2018-09-24 20:45:06 +00:00
|
|
|
menu_t menu = {ments, "Power off if woke up from HOS", 0, 0};
|
|
|
|
|
2019-04-13 23:30:14 +00:00
|
|
|
u32 *temp_autohosoff = (u32 *)tui_do_menu(&menu);
|
2018-09-24 20:45:06 +00:00
|
|
|
if (temp_autohosoff != NULL)
|
|
|
|
{
|
|
|
|
h_cfg.autohosoff = *(u32 *)temp_autohosoff;
|
2019-02-23 22:35:24 +00:00
|
|
|
_save_config();
|
2018-09-24 20:45:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
free(ments);
|
|
|
|
free(hp_values);
|
|
|
|
|
|
|
|
if (temp_autohosoff == NULL)
|
|
|
|
return;
|
|
|
|
btn_wait();
|
|
|
|
}
|
2019-02-23 23:06:24 +00:00
|
|
|
|
|
|
|
void config_nogc()
|
|
|
|
{
|
2019-04-13 23:30:14 +00:00
|
|
|
gfx_clear_grey(0x1B);
|
|
|
|
gfx_con_setpos(0, 0);
|
2019-02-23 23:06:24 +00:00
|
|
|
|
|
|
|
ment_t *ments = (ment_t *)malloc(sizeof(ment_t) * 5);
|
|
|
|
u32 *cb_values = (u32 *)malloc(sizeof(u32) * 2);
|
|
|
|
|
|
|
|
for (u32 j = 0; j < 2; j++)
|
|
|
|
{
|
|
|
|
cb_values[j] = j;
|
|
|
|
ments[j + 2].type = MENT_DATA;
|
|
|
|
ments[j + 2].data = &cb_values[j];
|
|
|
|
}
|
|
|
|
|
|
|
|
ments[0].type = MENT_BACK;
|
|
|
|
ments[0].caption = "Back";
|
|
|
|
|
|
|
|
ments[1].type = MENT_CHGLINE;
|
|
|
|
|
|
|
|
if (h_cfg.autonogc)
|
|
|
|
{
|
|
|
|
ments[2].caption = " Disable";
|
|
|
|
ments[3].caption = "*Auto";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ments[2].caption = "*Disable";
|
|
|
|
ments[3].caption = " Auto";
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(&ments[4], 0, sizeof(ment_t));
|
|
|
|
menu_t menu = {ments, "No Gamecard", 0, 0};
|
|
|
|
|
2019-04-13 23:30:14 +00:00
|
|
|
u32 *temp_nogc = (u32 *)tui_do_menu(&menu);
|
2019-02-23 23:06:24 +00:00
|
|
|
if (temp_nogc != NULL)
|
|
|
|
{
|
|
|
|
h_cfg.autonogc = *(u32 *)temp_nogc;
|
|
|
|
_save_config();
|
|
|
|
}
|
|
|
|
|
|
|
|
free(ments);
|
|
|
|
free(cb_values);
|
|
|
|
|
|
|
|
if (temp_nogc == NULL)
|
|
|
|
return;
|
|
|
|
btn_wait();
|
|
|
|
}
|
2019-06-30 00:15:46 +00:00
|
|
|
|
|
|
|
#pragma GCC pop_options
|