alt mode
This commit is contained in:
4
cfg.cpp
4
cfg.cpp
@@ -14,7 +14,7 @@ void MiSTer_ini_parse()
|
||||
memset(&cfg, 0, sizeof(cfg));
|
||||
cfg.bootscreen = 1;
|
||||
cfg.fb_terminal = 1;
|
||||
ini_parse(&ini_cfg);
|
||||
ini_parse(&ini_cfg, altcfg());
|
||||
}
|
||||
|
||||
// mist ini sections
|
||||
@@ -61,7 +61,7 @@ const ini_var_t ini_vars[] = {
|
||||
// mist ini config
|
||||
const ini_cfg_t ini_cfg = {
|
||||
"MiSTer.ini",
|
||||
CONFIG_DIR"/MiSTer.ini",
|
||||
"MiSTer_alt.ini",
|
||||
ini_sections,
|
||||
ini_vars,
|
||||
(int)(sizeof(ini_sections) / sizeof(ini_section_t)),
|
||||
|
||||
@@ -192,7 +192,7 @@ void* ini_get_var(const ini_cfg_t* cfg, int cur_section, char* buf)
|
||||
return (void*)0;
|
||||
}
|
||||
|
||||
void ini_parse(const ini_cfg_t* cfg)
|
||||
void ini_parse(const ini_cfg_t* cfg, int alt)
|
||||
{
|
||||
char line[INI_LINE_SIZE] = { 0 };
|
||||
int section = INI_SECTION_INVALID_ID;
|
||||
@@ -201,13 +201,9 @@ void ini_parse(const ini_cfg_t* cfg)
|
||||
ini_parser_debugf("Start INI parser for core \"%s\".", user_io_get_core_name_ex());
|
||||
|
||||
memset(&ini_file, 0, sizeof(ini_file));
|
||||
if (!FileOpen(&ini_file, cfg->filename))
|
||||
if (!FileOpen(&ini_file, alt ? cfg->filename_alt : cfg->filename))
|
||||
{
|
||||
if (!FileOpen(&ini_file, cfg->filename_alt))
|
||||
{
|
||||
return;
|
||||
}
|
||||
else ini_parser_debugf("Opened file %s with size %llu bytes.", cfg->filename_alt, ini_file.size);
|
||||
return;
|
||||
}
|
||||
else ini_parser_debugf("Opened file %s with size %llu bytes.", cfg->filename, ini_file.size);
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ typedef struct {
|
||||
|
||||
|
||||
//// functions ////
|
||||
void ini_parse(const ini_cfg_t* cfg);
|
||||
void ini_parse(const ini_cfg_t* cfg, int alt);
|
||||
|
||||
#endif // __INI_PARSER_H__
|
||||
|
||||
|
||||
52
user_io.cpp
52
user_io.cpp
@@ -609,6 +609,49 @@ uint16_t sdram_sz(int sz)
|
||||
return res;
|
||||
}
|
||||
|
||||
uint16_t altcfg(int alt)
|
||||
{
|
||||
int res = 0;
|
||||
|
||||
int fd;
|
||||
if ((fd = open("/dev/mem", O_RDWR | O_SYNC)) == -1) return 0;
|
||||
|
||||
void* buf = mmap(0, 0x1000, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0x1FFFF000);
|
||||
if (buf == (void *)-1)
|
||||
{
|
||||
printf("Unable to mmap(/dev/mem)\n");
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
volatile uint8_t* par = (volatile uint8_t*)buf;
|
||||
par += 0xF04;
|
||||
if (alt >= 0)
|
||||
{
|
||||
*par++ = 0x34;
|
||||
*par++ = 0x99;
|
||||
*par++ = 0xBA;
|
||||
*par++ = (uint8_t)alt;
|
||||
printf("** altcfg(%d)\n", alt);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((par[0] == 0x34) && (par[1] == 0x99) && (par[2] == 0xBA))
|
||||
{
|
||||
res = par[3];
|
||||
printf("** altcfg: got cfg %d\n", res);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("** altcfg: no cfg\n");
|
||||
}
|
||||
}
|
||||
|
||||
munmap(buf, 0x1000);
|
||||
close(fd);
|
||||
return res;
|
||||
}
|
||||
|
||||
int user_io_is_dualsdr()
|
||||
{
|
||||
return dual_sdr;
|
||||
@@ -1704,6 +1747,15 @@ void user_io_send_buttons(char force)
|
||||
|
||||
if ((map != key_map) || force)
|
||||
{
|
||||
if ((key_map & (BUTTON1 | BUTTON2)) == BUTTON2 && (map & (BUTTON1 | BUTTON2)) == (BUTTON1 | BUTTON2) && is_menu_core())
|
||||
{
|
||||
if (FileExists(ini_cfg.filename_alt))
|
||||
{
|
||||
altcfg(altcfg() ? 0 : 1);
|
||||
fpga_load_rbf("menu.rbf");
|
||||
}
|
||||
}
|
||||
|
||||
const char *name = get_rbf_path();
|
||||
if (name[0] && (get_key_mod() & (LGUI | LSHIFT)) == (LGUI | LSHIFT) && (key_map & BUTTON2) && !(map & BUTTON2))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user