From 8a17d6649681277fda01c6ce08b2d28d0d9f6f73 Mon Sep 17 00:00:00 2001 From: sorgelig Date: Mon, 17 Jul 2017 01:27:15 +0800 Subject: [PATCH] Some tweaks in Minimig boot code. --- MiSTer.vcxproj | 1 - MiSTer.vcxproj.filters | 3 --- boot.c | 7 +---- config.c | 61 ++++++++++++++++++------------------------ errors.h | 9 ------- fdd.c | 4 ++- hdd.c | 1 - input.c | 31 ++++++++++++++++++++- input.h | 2 +- main.c | 22 --------------- menu.c | 12 ++++----- menu.h | 2 +- user_io.c | 1 - 13 files changed, 68 insertions(+), 88 deletions(-) delete mode 100644 errors.h diff --git a/MiSTer.vcxproj b/MiSTer.vcxproj index f1e32f2..45743f9 100644 --- a/MiSTer.vcxproj +++ b/MiSTer.vcxproj @@ -65,7 +65,6 @@ - diff --git a/MiSTer.vcxproj.filters b/MiSTer.vcxproj.filters index 37ff07f..8109dc2 100644 --- a/MiSTer.vcxproj.filters +++ b/MiSTer.vcxproj.filters @@ -85,9 +85,6 @@ Header Files - - Header Files - Header Files diff --git a/boot.c b/boot.c index dfdce23..8afedeb 100644 --- a/boot.c +++ b/boot.c @@ -447,16 +447,12 @@ void BootInit() WaitTimer(500); char rtl_ver[45]; - siprintf(rtl_ver, "**** MINIMIG-AGA%s v%d.%d.%d for MiST ****", ver_beta ? " BETA" : "", ver_major, ver_minor, ver_minion); + siprintf(rtl_ver, "MINIMIG-AGA%s v%d.%d.%d by Rok Krajnc. MiSTer port by Sorgelig.", ver_beta ? " BETA" : "", ver_major, ver_minor, ver_minion); BootPrintEx(rtl_ver); BootPrintEx(" "); - BootPrintEx("MINIMIG-AGA for MiST by Rok Krajnc (rok.krajnc@gmail.com)"); BootPrintEx("Original Minimig by Dennis van Weeren"); BootPrintEx("Updates by Jakub Bednarski, Tobias Gubener, Sascha Boing, A.M. Robinson & others"); - BootPrintEx("MiST by Till Harbaum (till@harbaum.org)"); - BootPrintEx("For updates & code see https://github.com/rkrajnc/minimig-mist"); BootPrintEx(" "); - WaitTimer(1000); //eject all disk df[0].status = 0; @@ -473,7 +469,6 @@ void BootInit() //// BootPrint() //// void BootPrintEx(char * str) { - char buf[2]; unsigned char i, j; unsigned char len; diff --git a/config.c b/config.c index 1805957..62e3a9d 100644 --- a/config.c +++ b/config.c @@ -4,7 +4,6 @@ #include #include -#include "errors.h" #include "hardware.h" #include "boot.h" #include "file_io.h" @@ -14,6 +13,7 @@ #include "menu.h" #include "config.h" #include "user_io.h" +#include "input.h" configTYPE config = { 0 }; char configfilename[32]; @@ -296,8 +296,8 @@ unsigned char LoadConfiguration(char *filename) // set default configuration memset((void*)&config, 0, sizeof(config)); // Finally found default config bug - params were reversed! strncpy(config.id, config_id, sizeof(config.id)); - strcpy(config.kickstart, "KICK.ROM"); - config.memory = 0x15; + strcpy(config.kickstart, "Amiga/KICK.ROM"); + config.memory = 0x11; config.cpu = 0; config.chipset = 0; config.floppy.speed = CONFIG_FLOPPY2X; @@ -310,47 +310,32 @@ unsigned char LoadConfiguration(char *filename) config.hardfile[1].long_name[0] = 0; config.hardfile[1].enabled = 1; // Default is access to entire SD card updatekickstart = true; - BootPrint("Defaults set\n"); + BootPrintEx(">>> No config found. Using defaults. <<<"); } // print config to boot screen - char cfg_str[41]; - siprintf(cfg_str, "CPU: %s", config_cpu_msg[config.cpu & 0x03]); BootPrintEx(cfg_str); - siprintf(cfg_str, "Chipset: %s", config_chipset_msg[(config.chipset >> 2) & 7]); BootPrintEx(cfg_str); - siprintf(cfg_str, "Memory: CHIP: %s FAST: %s SLOW: %s", config_memory_chip_msg[(config.memory >> 0) & 0x03], config_memory_fast_msg[(config.memory >> 4) & 0x03], config_memory_slow_msg[(config.memory >> 2) & 0x03]); BootPrintEx(cfg_str); + char cfg_str[256]; + siprintf(cfg_str, "CPU: %s, Chipset: %s, ChipRAM: %s, FastRAM: %s, SlowRAM: %s", + config_cpu_msg[config.cpu & 0x03], config_chipset_msg[(config.chipset >> 2) & 7], + config_memory_chip_msg[(config.memory >> 0) & 0x03], config_memory_fast_msg[(config.memory >> 4) & 0x03], config_memory_slow_msg[(config.memory >> 2) & 0x03] + ); + BootPrintEx(cfg_str); - // wait up to 3 seconds for keyboard to appear. If it appears wait another - // two seconds for the user to press a key - /* - int8_t keyboard_present = 0; - for(i=0;i<3;i++) { - unsigned long to = GetTimer(1000); - //while(!CheckTimer(to)) usb_poll(); - - // check if keyboard just appeared - if(!keyboard_present && hid_keyboard_present()) { - // BootPrintEx("Press F1 for NTSC, F2 for PAL"); - keyboard_present = 1; - i = 0; - } - } - */ - - key = OsdGetCtrl(); - if (key == KEY_F1) { - // BootPrintEx("Forcing NTSC video ..."); - // force NTSC mode if F1 pressed + input_poll(0); + if (is_key_pressed(59)) + { + BootPrintEx("Forcing NTSC video ..."); + //force NTSC mode if F1 pressed config.chipset |= CONFIG_NTSC; } - - if (key == KEY_F2) { - // BootPrintEx("Forcing PAL video ..."); + else if (is_key_pressed(60)) + { + BootPrintEx("Forcing PAL video ..."); // force PAL mode if F2 pressed config.chipset &= ~CONFIG_NTSC; } ApplyConfiguration(updatekickstart); - return(result); } @@ -447,10 +432,16 @@ void ApplyConfiguration(char reloadkickstart) DisableOsd(); if (!UploadKickstart(config.kickstart)) { - strcpy(config.kickstart, "KICK.ROM"); + strcpy(config.kickstart, "Amiga/KICK.ROM"); if (!UploadKickstart(config.kickstart)) { - FatalError(6); + strcpy(config.kickstart, "KICK.ROM"); + if (!UploadKickstart(config.kickstart)) + { + BootPrintEx("No Kickstart loaded. Press F12 for settings."); + BootPrintEx("** Halted! **"); + return; + } } } EnableOsd(); diff --git a/errors.h b/errors.h deleted file mode 100644 index 947473f..0000000 --- a/errors.h +++ /dev/null @@ -1,9 +0,0 @@ -#define ERROR_NONE 0 -#define ERROR_FILE_NOT_FOUND 1 -#define ERROR_INVALID_DATA 2 -#define ERROR_UPDATE_FAILED 3 - -extern unsigned char Error; - -void ErrorMessage(const char *message, unsigned char code); -void FatalError(unsigned long error); diff --git a/fdd.c b/fdd.c index 173847e..dd03be4 100644 --- a/fdd.c +++ b/fdd.c @@ -24,13 +24,13 @@ along with this program. If not, see . // 2010-01-09 - support for variable number of tracks #include -#include "errors.h" #include "hardware.h" #include "file_io.h" #include "fdd.h" #include "config.h" #include "debug.h" #include "fpga_io.h" +#include "menu.h" unsigned char drives = 0; // number of active drives reported by FPGA (may change only during reset) adfTYPE *pdfx; // drive select pointer @@ -38,6 +38,8 @@ adfTYPE df[4]; // drive 0 information structure static uint8_t sector_buffer[512]; +unsigned char Error; + #define TRACK_SIZE 12668 #define HEADER_SIZE 0x40 #define DATA_SIZE 0x400 diff --git a/hdd.c b/hdd.c index d5cdf81..5531efb 100644 --- a/hdd.c +++ b/hdd.c @@ -22,7 +22,6 @@ along with this program. If not, see . #include #include -#include "errors.h" #include "hardware.h" #include "file_io.h" #include "hdd.h" diff --git a/input.c b/input.c index 4939c58..5a9e9d9 100644 --- a/input.c +++ b/input.c @@ -1048,9 +1048,10 @@ static void getVidPid(int num, uint16_t* vid, uint16_t* pid) *pid = read_hex(name); } +static struct pollfd pool[NUMDEV + 1]; + int input_test(int getchar) { - static struct pollfd pool[NUMDEV + 1]; static char cur_leds = 0; static int state = 0; @@ -1353,3 +1354,31 @@ int input_poll(int getchar) } } } + +int is_key_pressed(int key) +{ + unsigned char bits[(KEY_MAX + 7) / 8]; + for (int i = 0; i < NUMDEV; i++) + { + if (pool[i].fd > 0) + { + unsigned long evbit = 0; + if (ioctl(pool[i].fd, EVIOCGBIT(0, sizeof(evbit)), &evbit) >= 0) + { + if (evbit & (1 << EV_KEY)) + { + memset(bits, 0, sizeof(bits)); + if (ioctl(pool[i].fd, EVIOCGKEY(sizeof(bits)), &bits) >= 0) + { + if (bits[key / 8] & (1 << (key % 8))) + { + return 1; + } + } + } + } + } + } + + return 0; +} diff --git a/input.h b/input.h index fab993a..88b7369 100644 --- a/input.h +++ b/input.h @@ -12,7 +12,7 @@ int get_kbdled(int mask); int toggle_kbdled(int mask); int input_poll(int getchar); - +int is_key_pressed(int key); void start_map_setting(int cnt); int get_map_button(); diff --git a/main.c b/main.c index 25ba0f9..756edfe 100644 --- a/main.c +++ b/main.c @@ -23,7 +23,6 @@ along with this program. If not, see . #include #include #include "string.h" -#include "errors.h" #include "hardware.h" #include "file_io.h" #include "osd.h" @@ -40,27 +39,6 @@ along with this program. If not, see . const char version[] = { "$VER:HPS" VDATE }; -unsigned char Error; - -void FatalError(unsigned long error) -{ - unsigned long i; - - iprintf("Fatal error: %lu\n", error); - - while (1) - { - for (i = 0; i < error; i++) - { - DISKLED_ON; - WaitTimer(250); - DISKLED_OFF; - WaitTimer(250); - } - WaitTimer(1000); - } -} - void HandleDisk(void) { unsigned char c1, c2; diff --git a/menu.c b/menu.c index bf7dcb9..0cd5f71 100644 --- a/menu.c +++ b/menu.c @@ -30,7 +30,6 @@ along with this program. If not, see . #include #include "stdio.h" #include "string.h" -#include "errors.h" #include "file_io.h" #include "osd.h" #include "state.h" @@ -139,15 +138,16 @@ const char *config_tos_mem[] = { "512 kB", "1 MB", "2 MB", "4 MB", "8 MB", "14 M const char *config_tos_wrprot[] = { "none", "A:", "B:", "A: and B:" }; const char *config_tos_usb[] = { "none", "control", "debug", "serial", "parallel", "midi" }; +const char *config_memory_chip_msg[] = { "512kb", "1mb", "1.5mb", "2mb" }; +const char *config_memory_slow_msg[] = { "none", "512kb", "1mb", "1.5mb" }; +const char *config_memory_fast_msg[] = { "none", "2mb", "4mb","24mb","24mb" }; + const char *config_filter_msg[] = { "none", "HORIZONTAL", "VERTICAL", "H+V" }; -const char *config_memory_chip_msg[] = { "0.5 MB", "1.0 MB", "1.5 MB", "2.0 MB" }; -const char *config_memory_slow_msg[] = { "none ", "0.5 MB", "1.0 MB", "1.5 MB" }; const char *config_scanlines_msg[] = { "off", "dim", "black" }; const char *config_ar_msg[] = { "4:3", "16:9" }; const char *config_blank_msg[] = { "Blank", "Blank+" }; const char *config_dither_msg[] = { "off", "SPT", "RND", "S+R" }; -const char *config_memory_fast_msg[] = { "none ", "2.0 MB", "4.0 MB","24.0 MB","24.0 MB" }; -const char *config_cpu_msg[] = { "68000 ", "68010", "-----","68020" }; +const char *config_cpu_msg[] = { "68000", "68010", "-----","68020" }; const char *config_hdf_msg[] = { "Disabled", "Hardfile (disk img)", "MMC/SD card", "MMC/SD partition 1", "MMC/SD partition 2", "MMC/SD partition 3", "MMC/SD partition 4" }; const char *config_chipset_msg[] = { "OCS-A500", "OCS-A1000", "ECS", "---", "---", "---", "AGA", "---" }; const char *config_turbo_msg[] = { "none", "CHIPRAM", "KICK", "BOTH" }; @@ -1266,7 +1266,7 @@ void HandleUI(void) OsdDrawLogo(3, 3, 1); OsdDrawLogo(4, 4, 1); OsdDrawLogo(5, 5, 1); - ScrollText(OsdIsBig ? 13 : 6, " MiST by Till Harbaum, based on Minimig by Dennis van Weeren and other projects. MiST hardware and software is distributed under the terms of the GNU General Public License version 3. MiST FPGA cores are the work of their respective authors under individual licensing.", 0, 0, 0, 0); + ScrollText(OsdIsBig ? 13 : 6, " MiSTer by Sorgelig, based on MiST by Till Harbaum and 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); if (menu | select | left) { diff --git a/menu.h b/menu.h index 3e0008a..06c6a28 100644 --- a/menu.h +++ b/menu.h @@ -118,10 +118,10 @@ void InsertFloppy(adfTYPE *drive, char* path); void HandleUI(void); void PrintDirectory(void); void ScrollLongName(void); +void ErrorMessage(const char *message, unsigned char code); void InfoMessage(char *message); void ShowSplash(); void HideSplash(); void EjectAllFloppies(); #endif - diff --git a/user_io.c b/user_io.c index 35cb770..9c29cdc 100644 --- a/user_io.c +++ b/user_io.c @@ -17,7 +17,6 @@ #include "spi.h" #include "mist_cfg.h" #include "tos.h" -#include "errors.h" #include "input.h" #include "fpga_io.h" #include "file_io.h"