From b238b4644f4020c5145ee52762aed3c85cfd1757 Mon Sep 17 00:00:00 2001 From: sorgelig Date: Fri, 15 Jan 2021 17:51:40 +0800 Subject: [PATCH] OSD: display saving message upon autosave. --- menu.cpp | 26 ++++++++++++++++++++++++-- menu.h | 1 + user_io.cpp | 5 +++++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/menu.cpp b/menu.cpp index 20dfe88..025bcc8 100644 --- a/menu.cpp +++ b/menu.cpp @@ -131,6 +131,7 @@ enum MENU MENU_GENERIC_MAIN2, MENU_GENERIC_FILE_SELECTED, MENU_GENERIC_IMAGE_SELECTED, + MENU_GENERIC_SAVE_WAIT, // Arcade MENU_ARCADE_DIP1, @@ -186,6 +187,7 @@ static uint32_t menusub = 0; static uint32_t menusub_last = 0; //for when we allocate it dynamically and need to know last row static uint64_t menumask = 0; // Used to determine which rows are selectable... static uint32_t menu_timer = 0; +static uint32_t menu_save_timer = 0; extern const char *version; @@ -1838,11 +1840,26 @@ void HandleUI(void) } break; + case MENU_GENERIC_SAVE_WAIT: + menumask = 0; + parentstate = menustate; + if (menu_save_timer && CheckTimer(menu_save_timer)) + { + menu_save_timer = 0; + menustate = MENU_GENERIC_MAIN1; + } + break; + case MENU_GENERIC_MAIN2: saved_menustate = MENU_GENERIC_MAIN1; - // menu key closes menu - if (menu) + if (menu_save_timer && !CheckTimer(menu_save_timer)) + { + for (int i = 0; i < 16; i++) OsdWrite(m++); + OsdWrite(8, " Saving..."); + menustate = MENU_GENERIC_SAVE_WAIT; + } + else if (menu) { menustate = MENU_NONE1; } @@ -6347,3 +6364,8 @@ int menu_allow_cfg_switch() return 0; } + +void menu_process_save() +{ + menu_save_timer = GetTimer(1000); +} diff --git a/menu.h b/menu.h index 39dd008..877c337 100644 --- a/menu.h +++ b/menu.h @@ -5,6 +5,7 @@ void HandleUI(void); void menu_key_set(unsigned int c); +void menu_process_save(); void PrintDirectory(int expand = 0); void ScrollLongName(void); diff --git a/user_io.cpp b/user_io.cpp index e4f7f34..9fb75d0 100644 --- a/user_io.cpp +++ b/user_io.cpp @@ -42,6 +42,8 @@ static char rbf_path[1024] = {}; static fileTYPE sd_image[4] = {}; static uint64_t buffer_lba[4] = { ULLONG_MAX,ULLONG_MAX,ULLONG_MAX,ULLONG_MAX }; +static int use_save = 0; + // mouse and keyboard emulation state static int emu_mode = EMU_NONE; @@ -1466,6 +1468,7 @@ int user_io_file_mount(const char *name, unsigned char index, char pre) } buffer_lba[index] = -1; + if (!index) use_save = pre; if (!ret) { @@ -2617,6 +2620,8 @@ void user_io_poll() { //printf("SD WR %d on %d\n", lba, disk); + if (use_save) menu_process_save(); + buffer_lba[disk] = -1; // Fetch sector data from FPGA ...