diff --git a/menu.cpp b/menu.cpp
index d98f6a6..0036583 100644
--- a/menu.cpp
+++ b/menu.cpp
@@ -34,8 +34,9 @@ along with this program. If not, see .
#include
#include
#include
-#include "stdio.h"
-#include "string.h"
+#include
+#include
+#include
#include "file_io.h"
#include "osd.h"
#include "hardware.h"
@@ -43,7 +44,6 @@ along with this program. If not, see .
#include "user_io.h"
#include "debug.h"
#include "fpga_io.h"
-#include
#include "cfg.h"
#include "input.h"
#include "battery.h"
@@ -215,45 +215,6 @@ uint32_t fs_Options;
uint32_t fs_MenuSelect;
uint32_t fs_MenuCancel;
-int GetUARTMode()
-{
- struct stat filestat;
- if (!stat("/tmp/uartmode1", &filestat)) return 1;
- if (!stat("/tmp/uartmode2", &filestat)) return 2;
- if (!stat("/tmp/uartmode3", &filestat)) return 3;
- if (!stat("/tmp/uartmode4", &filestat)) return 4;
- return 0;
-}
-
-int GetMidiLinkMode()
-{
- struct stat filestat;
- if (!stat("/tmp/ML_FSYNTH", &filestat)) return 0;
- if (!stat("/tmp/ML_MUNT", &filestat)) return 1;
- if (!stat("/tmp/ML_TCP", &filestat)) return 2;
- if (!stat("/tmp/ML_UDP", &filestat)) return 3;
- return 0;
-}
-
-void SetMidiLinkMode(int mode)
-{
- remove("/tmp/ML_FSYNTH");
- remove("/tmp/ML_MUNT");
- remove("/tmp/ML_UDP");
- remove("/tmp/ML_TCP");
- switch (mode)
- {
- case 0: system("echo 1 > /tmp/ML_FSYNTH");
- break;
- case 1: system("echo 1 > /tmp/ML_MUNT");
- break;
- case 2: system("echo 1 > /tmp/ML_TCP");
- break;
- case 3: system("echo 1 > /tmp/ML_UDP");
- break;
- }
-}
-
char* GetExt(char *ext)
{
static char extlist[32];
@@ -1401,6 +1362,7 @@ void HandleUI(void)
SelectFile(0, SCANO_CORES, MENU_FIRMWARE_CORE_FILE_SELECTED1, MENU_8BIT_SYSTEM1);
menusub = 0;
break;
+
case 1:
if (is_minimig())
{
@@ -1417,42 +1379,49 @@ void HandleUI(void)
menustate = MENU_JOYDIGMAP;
menusub = 0;
break;
+
case 2:
start_map_setting(-1);
menustate = MENU_JOYKBDMAP;
menusub = 0;
break;
+
case 3:
{
- int mode = GetUARTMode();
- mode++;
- if (mode > 5) mode = 0;
+ uint mode = GetUARTMode() + 1;
+ if (mode > sizeof(config_uart_msg)/sizeof(config_uart_msg[0])) mode = 0;
+
sprintf(s, "uartmode %d", mode);
system(s);
menustate = MENU_8BIT_SYSTEM1;
+ mode |= GetMidiLinkMode() << 8;
sprintf(s, "uartmode.%s", user_io_get_core_name_ex());
FileSaveConfig(s, &mode, 4);
}
break;
+
case 4:
- {
- int mode = GetUARTMode();
- if(mode == 3 or mode == 4)
- {
- struct stat filestat;
- int midilink = GetMidiLinkMode();
+ {
+ int mode = GetUARTMode();
+ if (mode == 3 or mode == 4)
+ {
+ uint midilink = GetMidiLinkMode();
midilink++;
- if (midilink > 3) midilink = 0;
- SetMidiLinkMode(midilink);
- sprintf(s, "uartmode %d", 0);
- system(s);
- sprintf(s, "uartmode %d", mode);
- system(s);
- }
- menustate = MENU_8BIT_SYSTEM1;
- }
- break;
+ if (midilink > sizeof(config_softsynth_msg)/sizeof(config_softsynth_msg[0])) midilink = 0;
+ SetMidiLinkMode(midilink);
+ sprintf(s, "uartmode %d", 0);
+ system(s);
+ sprintf(s, "uartmode %d", mode);
+ system(s);
+
+ mode |= GetMidiLinkMode() << 8;
+ sprintf(s, "uartmode.%s", user_io_get_core_name_ex());
+ FileSaveConfig(s, &mode, 4);
+ }
+ menustate = MENU_8BIT_SYSTEM1;
+ }
+ break;
case 5:
user_io_set_scaler_flt(user_io_get_scaler_flt() ? 0 : 1);
@@ -1479,6 +1448,7 @@ void HandleUI(void)
menusub = 0;
}
break;
+
case 8:
// Save settings
menustate = MENU_8BIT_MAIN1;
@@ -1502,6 +1472,7 @@ void HandleUI(void)
if (is_x86_core()) x86_config_save();
}
break;
+
case 9:
{
reboot_req = 1;
@@ -1514,10 +1485,12 @@ void HandleUI(void)
OsdWrite(cr, p, menusub == 8, 0);
}
break;
+
case 10:
menustate = MENU_8BIT_ABOUT1;
menusub = 0;
break;
+
default:
menustate = MENU_NONE1;
break;
diff --git a/user_io.cpp b/user_io.cpp
index 5b4a840..d02865f 100644
--- a/user_io.cpp
+++ b/user_io.cpp
@@ -7,6 +7,8 @@
#include
#include
#include
+#include
+#include
#include "hardware.h"
#include "osd.h"
@@ -403,6 +405,41 @@ const char* get_rbf_name()
return p+1;
}
+int GetUARTMode()
+{
+ struct stat filestat;
+ if (!stat("/tmp/uartmode1", &filestat)) return 1;
+ if (!stat("/tmp/uartmode2", &filestat)) return 2;
+ if (!stat("/tmp/uartmode3", &filestat)) return 3;
+ if (!stat("/tmp/uartmode4", &filestat)) return 4;
+ return 0;
+}
+
+int GetMidiLinkMode()
+{
+ struct stat filestat;
+ if (!stat("/tmp/ML_FSYNTH", &filestat)) return 0;
+ if (!stat("/tmp/ML_MUNT", &filestat)) return 1;
+ if (!stat("/tmp/ML_TCP", &filestat)) return 2;
+ if (!stat("/tmp/ML_UDP", &filestat)) return 3;
+ return 0;
+}
+
+void SetMidiLinkMode(int mode)
+{
+ remove("/tmp/ML_FSYNTH");
+ remove("/tmp/ML_MUNT");
+ remove("/tmp/ML_UDP");
+ remove("/tmp/ML_TCP");
+ switch (mode)
+ {
+ case 0: system("echo 1 > /tmp/ML_FSYNTH"); break;
+ case 1: system("echo 1 > /tmp/ML_MUNT"); break;
+ case 2: system("echo 1 > /tmp/ML_TCP"); break;
+ case 3: system("echo 1 > /tmp/ML_UDP"); break;
+ }
+}
+
void user_io_init(const char *path)
{
char *name;
@@ -588,11 +625,13 @@ void user_io_init(const char *path)
{
sprintf(mainpath, "uartmode.%s", user_io_get_core_name_ex());
FileLoadConfig(mainpath, &mode, 4);
- if (mode > 5) mode = 0;
}
char cmd[32];
- sprintf(cmd, "uartmode %d", mode);
+ system("uartmode 0");
+
+ SetMidiLinkMode((mode >> 8) & 0xFF);
+ sprintf(cmd, "uartmode %d", mode & 0xFF);
system(cmd);
}
diff --git a/user_io.h b/user_io.h
index fc7f27a..a1e54eb 100644
--- a/user_io.h
+++ b/user_io.h
@@ -248,4 +248,9 @@ char user_io_minimig_get_adjust();
#define HomeDir (is_minimig() ? "Amiga" : is_archie() ? "Archie" : user_io_get_core_name())
+int GetUARTMode();
+int GetMidiLinkMode();
+void SetMidiLinkMode(int mode);
+
+
#endif // USER_IO_H