From e52ae6ba82f53e261a5c8c18ed3fe189e2f52cbe Mon Sep 17 00:00:00 2001 From: sorgelig Date: Wed, 26 Jun 2019 02:16:21 +0800 Subject: [PATCH] Rework disk LED activity. --- fpga_io.h | 3 --- input.cpp | 35 ++++----------------------------- menu.cpp | 9 ++++----- support/minimig/minimig_fdd.cpp | 2 +- support/minimig/minimig_hdd.cpp | 2 +- user_io.cpp | 16 +++++++-------- user_io.h | 4 ++++ 7 files changed, 22 insertions(+), 49 deletions(-) diff --git a/fpga_io.h b/fpga_io.h index 36127c2..44cfb36 100644 --- a/fpga_io.h +++ b/fpga_io.h @@ -4,9 +4,6 @@ #ifndef FPGAIO_H #define FPGAIO_H -#define DISKLED_ON fpga_set_led(1) -#define DISKLED_OFF fpga_set_led(0) - #define BUTTON_OSD 1 #define BUTTON_USR 2 diff --git a/input.cpp b/input.cpp index 48007e7..e4434a4 100644 --- a/input.cpp +++ b/input.cpp @@ -2655,18 +2655,12 @@ int input_test(int getchar) state++; } - static unsigned long led_to = 0; - if (state == 2) { - int timeout = 0, extrapoll = 2; - if (is_menu_core() && video_fb_state()) - { - timeout = 25; - if (pool[NUMDEV + 2].fd > 0) extrapoll = 3; - } + int timeout = 0; + if (is_menu_core() && video_fb_state()) timeout = 25; - int return_value = poll(pool, NUMDEV + extrapoll, timeout); + int return_value = poll(pool, NUMDEV + 3, timeout); if (return_value < 0) { printf("ERR: poll\n"); @@ -3040,23 +3034,9 @@ int input_test(int getchar) if ((pool[NUMDEV + 2].fd >= 0) && (pool[NUMDEV + 2].revents & POLLPRI)) { - //printf("revents = %x\n", pool[NUMDEV + 2].revents); - pool[NUMDEV + 2].revents = 0; - static char status[16]; - int len = read(pool[NUMDEV + 2].fd, status, sizeof(status) - 1); + if (read(pool[NUMDEV + 2].fd, status, sizeof(status) - 1) && status[0] != '0') DISKLED_ON; lseek(pool[NUMDEV + 2].fd, 0, SEEK_SET); - if (len) - { - status[len] = 0; - //printf("led: %s", status); - if (status[0] != '0' && is_menu_core() && video_fb_state()) - { - //printf("led: on\n"); - if (!led_to) user_io_8bit_set_status(0x80, 0x80); - led_to = GetTimer(40); - } - } } } @@ -3085,13 +3065,6 @@ int input_test(int getchar) } } - if (led_to && CheckTimer(led_to)) - { - //printf("led: off\n"); - led_to = 0; - user_io_8bit_set_status(0, 0x80); - } - return 0; } diff --git a/menu.cpp b/menu.cpp index c1d9d00..204404a 100644 --- a/menu.cpp +++ b/menu.cpp @@ -2247,8 +2247,9 @@ void HandleUI(void) OsdDrawLogo(3); OsdDrawLogo(4); + OsdWrite(10, " www.MiSTerFPGA.org"); sprintf(s, " MiSTer v%s", version + 5); - OsdWrite(10, s, 0, 0, 1); + OsdWrite(12, s, 0, 0, 1); s[0] = 0; if (user_io_core_type() != CORE_TYPE_MINIMIG2) @@ -2262,11 +2263,9 @@ void HandleUI(void) for (int i = 0; i < len; i++) *s2++ = *s3++; *s2++ = 0; } - OsdWrite(11, s, 0, 0, 1); - OsdWrite(12, "", 0, 0, 1); - ScrollText(13, " MiSTer by Sorgelig, based on MiST by Till Harbaum, Minimig by Dennis van Weeren and other projects. MiSTer hardware and software is distributed under the terms of the GNU General Public License version 3. MiSTer FPGA cores are the work of their respective authors under individual licensing.", 0, 0, 0, 0); + OsdWrite(13, s, 0, 0, 1); OsdWrite(14, "", 0, 0, 1); - OsdWrite(15, "", 0, 0, 1); + ScrollText(15, " MiSTer by Sorgelig, based on MiST by Till Harbaum, Minimig by Dennis van Weeren and other projects. MiSTer hardware and software is distributed under the terms of the GNU General Public License version 3. MiSTer FPGA cores are the work of their respective authors under individual licensing. Go to www.MiSTerFPGA.org for more details.", 0, 0, 0, 0); if (menu | select | left) { diff --git a/support/minimig/minimig_fdd.cpp b/support/minimig/minimig_fdd.cpp index 41e09d6..0b1fb8f 100644 --- a/support/minimig/minimig_fdd.cpp +++ b/support/minimig/minimig_fdd.cpp @@ -30,7 +30,7 @@ along with this program. If not, see . #include "minimig_fdd.h" #include "minimig_config.h" #include "../../debug.h" -#include "../../fpga_io.h" +#include "../../user_io.h" #include "../../menu.h" unsigned char drives = 0; // number of active drives reported by FPGA (may change only during reset) diff --git a/support/minimig/minimig_hdd.cpp b/support/minimig/minimig_hdd.cpp index 149a6db..93e80ae 100644 --- a/support/minimig/minimig_hdd.cpp +++ b/support/minimig/minimig_hdd.cpp @@ -31,7 +31,7 @@ along with this program. If not, see . #include "../../menu.h" #include "minimig_config.h" #include "../../debug.h" -#include "../../fpga_io.h" +#include "../../user_io.h" #define CMD_IDECMD 0x04 #define CMD_IDEDAT 0x08 diff --git a/user_io.cpp b/user_io.cpp index 238580c..f0acf60 100644 --- a/user_io.cpp +++ b/user_io.cpp @@ -1574,9 +1574,9 @@ void user_io_send_buttons(char force) static uint32_t diskled_timer = 0; static uint32_t diskled_is_on = 0; -void __inline diskled_on() +void diskled_on() { - DISKLED_ON; + fpga_set_led(1); diskled_timer = GetTimer(50); diskled_is_on = 1; } @@ -1910,12 +1910,6 @@ void user_io_poll() } } } - - if(diskled_is_on && CheckTimer(diskled_timer)) - { - DISKLED_OFF; - diskled_is_on = 0; - } } if (core_type == CORE_TYPE_8BIT && !is_menu_core()) @@ -2195,6 +2189,12 @@ void user_io_poll() vol_set_timeout = 0; FileSaveConfig("Volume.dat", &vol_att, 1); } + + if (diskled_is_on && CheckTimer(diskled_timer)) + { + fpga_set_led(0); + diskled_is_on = 0; + } } static void send_keycode(unsigned short key, int press) diff --git a/user_io.h b/user_io.h index 3c863c4..ab251cf 100644 --- a/user_io.h +++ b/user_io.h @@ -248,4 +248,8 @@ int get_volume(); void user_io_store_filename(char *filename); int user_io_use_cheats(); +void diskled_on(); +#define DISKLED_ON diskled_on() +#define DISKLED_OFF void() + #endif // USER_IO_H