diff --git a/file_io.cpp b/file_io.cpp index f4a72b6..c5e2786 100644 --- a/file_io.cpp +++ b/file_io.cpp @@ -518,9 +518,9 @@ int FileWriteSec(fileTYPE *file, void *pBuffer) return FileWriteAdv(file, pBuffer, 512); } -int FileSave(const char *name, void *pBuffer, int size, int sys) +int FileSave(const char *name, void *pBuffer, int size) { - if(!sys) sprintf(full_path, "%s/%s", getRootDir(), name); + if(name[0] != '/') sprintf(full_path, "%s/%s", getRootDir(), name); else strcpy(full_path, name); int fd = open(full_path, O_WRONLY | O_CREAT | O_TRUNC | O_SYNC, S_IRWXU | S_IRWXG | S_IRWXO); @@ -549,9 +549,9 @@ int FileSaveConfig(const char *name, void *pBuffer, int size) return FileSave(path, pBuffer, size); } -int FileLoad(const char *name, void *pBuffer, int size, int sys) +int FileLoad(const char *name, void *pBuffer, int size) { - if (!sys) sprintf(full_path, "%s/%s", getRootDir(), name); + if (name[0] != '/') sprintf(full_path, "%s/%s", getRootDir(), name); else strcpy(full_path, name); int fd = open(full_path, O_RDONLY); diff --git a/file_io.h b/file_io.h index ef129d2..9411e7f 100644 --- a/file_io.h +++ b/file_io.h @@ -71,8 +71,8 @@ void FileGenerateSavePath(const char *name, char* out_name); #define SCREENSHOT_DEFAULT "screen" void FileGenerateScreenshotName(const char *name, char *out_name, int buflen); -int FileSave(const char *name, void *pBuffer, int size, int sys = 0); -int FileLoad(const char *name, void *pBuffer, int size, int sys = 0); // supply pBuffer = 0 to get the file size without loading +int FileSave(const char *name, void *pBuffer, int size); +int FileLoad(const char *name, void *pBuffer, int size); // supply pBuffer = 0 to get the file size without loading //save/load from config dir #define CONFIG_DIR "config" diff --git a/menu.cpp b/menu.cpp index e5f52c2..c1d9d00 100644 --- a/menu.cpp +++ b/menu.cpp @@ -741,6 +741,35 @@ const char* get_rbf_name_bootcore(char *str) return p + 1; } +static void vga_nag() +{ + if (video_fb_state()) + { + EnableOsd_on(OSD_VGA); + OsdSetSize(16); + OsdSetTitle("Information"); + int n = 0; + OsdWrite(n++); + OsdWrite(n++); + OsdWrite(n++); + OsdWrite(n++); + OsdWrite(n++, " If you see this, then you"); + OsdWrite(n++, " need to modify MiSTer.ini"); + OsdWrite(n++); + OsdWrite(n++, " Either disable framebuffer:"); + OsdWrite(n++, " fb_terminal=0"); + OsdWrite(n++); + OsdWrite(n++, " or enable scaler on VGA:"); + OsdWrite(n++, " vga_scaler=1"); + for (; n < OsdGetSize(); n++) OsdWrite(n); + OsdEnable(0); + EnableOsd_on(OSD_HDMI); + } + + OsdDisable(); + EnableOsd_on(OSD_ALL); +} + static int joymap_first = 0; static int wm_x = 0; @@ -1015,36 +1044,7 @@ void HandleUI(void) menumask = 0; menustate = MENU_NONE2; firstmenu = 0; - - if (video_fb_state()) - { - EnableOsd_on(OSD_VGA); - OsdSetSize(16); - OsdSetTitle("Information"); - int n = 0; - OsdWrite(n++); - OsdWrite(n++); - OsdWrite(n++); - OsdWrite(n++); - OsdWrite(n++, " If you see this, then you"); - OsdWrite(n++, " need to modify MiSTer.ini"); - OsdWrite(n++); - OsdWrite(n++, " Either disable framebuffer:"); - OsdWrite(n++, " fb_terminal=0"); - OsdWrite(n++); - OsdWrite(n++, " or enable scaler on VGA:"); - OsdWrite(n++, " vga_scaler=1"); - for (; n < OsdGetSize(); n++) OsdWrite(n); - OsdEnable(0); - EnableOsd_on(OSD_HDMI); - OsdDisable(); - EnableOsd_on(OSD_ALL); - } - else - { - OsdDisable(); - } - + vga_nag(); OsdSetSize(8); break; @@ -4027,14 +4027,15 @@ void HandleUI(void) case MENU_SCRIPTS_FB: if (cfg.fb_terminal) { + static char cmd[1024 * 2]; + const char *path = getFullPath(SelectedPath); menustate = MENU_SCRIPTS_FB2; - OsdDisable(); video_chvt(2); video_fb_enable(1); - static char cmd[1024 * 2]; - sprintf(cmd, "#!/bin/bash\nexport LC_ALL=en_US.UTF-8\ncd $(dirname %s)\n%s\necho \"Press any key to continue\"\n", getFullPath(SelectedPath), getFullPath(SelectedPath)); + vga_nag(); + sprintf(cmd, "#!/bin/bash\nexport LC_ALL=en_US.UTF-8\ncd $(dirname %s)\n%s\necho \"Press any key to continue\"\n", path, path); unlink("/tmp/script"); - FileSave("/tmp/script", cmd, strlen(cmd), 1); + FileSave("/tmp/script", cmd, strlen(cmd)); ttypid = fork(); if (!ttypid) { diff --git a/video.cpp b/video.cpp index acbef15..51f9481 100644 --- a/video.cpp +++ b/video.cpp @@ -871,7 +871,7 @@ void video_menu_bg(int n, int idle) if (!logo) { unlink("/tmp/logo.png"); - if (FileSave("/tmp/logo.png", _binary_logo_png_start, _binary_logo_png_end - _binary_logo_png_start, 1)) + if (FileSave("/tmp/logo.png", _binary_logo_png_start, _binary_logo_png_end - _binary_logo_png_start)) { while(1) {