diff --git a/MiSTer.vcxproj b/MiSTer.vcxproj index 78c6a0b..b84e58f 100644 --- a/MiSTer.vcxproj +++ b/MiSTer.vcxproj @@ -40,36 +40,34 @@ - - + - - - - + + + + - + + - + - - @@ -77,17 +75,19 @@ - - - - + + + + + - + + diff --git a/MiSTer.vcxproj.filters b/MiSTer.vcxproj.filters index cec2238..dc88408 100644 --- a/MiSTer.vcxproj.filters +++ b/MiSTer.vcxproj.filters @@ -14,27 +14,12 @@ Source Files - - Source Files - - - Source Files - - - Source Files - Source Files Source Files - - Source Files - - - Source Files - Source Files @@ -47,18 +32,12 @@ Source Files - - Source Files - Source Files Source Files - - Source Files - Source Files @@ -74,26 +53,38 @@ Source Files + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + Header Files - - Header Files - Header Files - - Header Files - Header Files - - Header Files - Header Files @@ -115,15 +106,6 @@ Header Files - - Header Files - - - Header Files - - - Header Files - Header Files @@ -136,18 +118,12 @@ Header Files - - Header Files - Header Files Header Files - - Header Files - Header Files @@ -163,6 +139,30 @@ Header Files + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + diff --git a/cfg.c b/cfg.c new file mode 100644 index 0000000..409fc62 --- /dev/null +++ b/cfg.c @@ -0,0 +1,47 @@ +// cfg.c +// 2015, rok.krajnc@gmail.com +// 2017+, Sorgelig + +#include +#include "ini_parser.h" +#include "cfg.h" +#include "user_io.h" + +cfg_t cfg; + +void MiSTer_ini_parse() +{ + memset(&cfg, 0, sizeof(cfg)); + ini_parse(&ini_cfg); +} + +// mist ini sections +const ini_section_t ini_sections[] = +{ + { 1, "MiSTer" } +}; + +// mist ini vars +const ini_var_t ini_vars[] = { + { "YPBPR", (void*)(&(cfg.ypbpr)), UINT8, 0, 1, 1 }, + { "COMPOSITE_SYNC", (void*)(&(cfg.csync)), UINT8, 0, 1, 1 }, + { "FORCED_SCANDOUBLER", (void*)(&(cfg.forced_scandoubler)), UINT8, 0, 1, 1 }, + { "VGA_SCALER", (void*)(&(cfg.vga_scaler)), UINT8, 0, 1, 1 }, + { "KEYRAH_MODE", (void*)(&(cfg.keyrah_mode)), UINT32, 0, 0xFFFFFFFF, 1 }, + { "RESET_COMBO", (void*)(&(cfg.reset_combo)), UINT8, 0, 3, 1 }, + { "KEY_MENU_AS_RGUI", (void*)(&(cfg.key_menu_as_rgui)), UINT8, 0, 1, 1 }, + { "VIDEO_MODE", (void*)(cfg.video_conf), STRING, 0, sizeof(cfg.video_conf)-1, 1 }, + { "HDMI_AUDIO_96K", (void*)(&(cfg.hdmi_audio_96k)), UINT8, 0, 1, 1 }, + { "DVI_MODE", (void*)(&(cfg.dvi)), UINT8, 0, 1, 1 }, + { "KBD_NOMOUSE", (void*)(&(cfg.kbd_nomouse)), UINT8, 0, 1, 1 }, + { "MOUSE_THROTTLE", (void*)(&(cfg.mouse_throttle)), UINT8, 1, 100, 1 }, +}; + +// mist ini config +const ini_cfg_t ini_cfg = { + CONFIG_DIR"/MiSTer.ini", + ini_sections, + ini_vars, + (int)(sizeof(ini_sections) / sizeof(ini_section_t)), + (int)(sizeof(ini_vars) / sizeof(ini_var_t)) +}; diff --git a/mist_cfg.h b/cfg.h similarity index 71% rename from mist_cfg.h rename to cfg.h index 2db7aba..b34424c 100644 --- a/mist_cfg.h +++ b/cfg.h @@ -1,9 +1,9 @@ -// mist_cfg.h +// cfg.h // 2015, rok.krajnc@gmail.com +// 2017+, Sorgelig - -#ifndef __MIST_CFG_H__ -#define __MIST_CFG_H__ +#ifndef __CFG_H__ +#define __CFG_H__ //// includes //// @@ -26,15 +26,14 @@ typedef struct { uint8_t kbd_nomouse; uint8_t mouse_throttle; char video_conf[1024]; -} mist_cfg_t; +} cfg_t; //// functions //// -void mist_ini_parse(); +void MiSTer_ini_parse(); //// global variables //// -extern const ini_cfg_t mist_ini_cfg; -extern mist_cfg_t mist_cfg; +extern const ini_cfg_t ini_cfg; +extern cfg_t cfg; -#endif // __MIST_CFG_H__ - +#endif // __CFG_H__ diff --git a/input.c b/input.c index c449acf..213c782 100644 --- a/input.c +++ b/input.c @@ -11,7 +11,7 @@ #include "user_io.h" #include "menu.h" #include "hardware.h" -#include "mist_cfg.h" +#include "cfg.h" #include "fpga_io.h" #include "osd.h" @@ -1578,22 +1578,22 @@ static void input_cb(struct input_event *ev, int dev) case EV_REL: { int msval; - if (!mist_cfg.mouse_throttle) mist_cfg.mouse_throttle = 1; + if (!cfg.mouse_throttle) cfg.mouse_throttle = 1; switch (ev->code) { case 0: input[dev].accx += ev->value; - msval = input[dev].accx / mist_cfg.mouse_throttle; - input[dev].accx -= msval * mist_cfg.mouse_throttle; + msval = input[dev].accx / cfg.mouse_throttle; + input[dev].accx -= msval * cfg.mouse_throttle; //printf("Mouse PosX: %d\n", msval); user_io_mouse(mouse_btn, msval, 0); return; case 1: input[dev].accy += ev->value; - msval = input[dev].accy / mist_cfg.mouse_throttle; - input[dev].accy -= msval * mist_cfg.mouse_throttle; + msval = input[dev].accy / cfg.mouse_throttle; + input[dev].accy -= msval * cfg.mouse_throttle; //printf("Mouse PosY: %d\n", msval); user_io_mouse(mouse_btn, 0, msval); @@ -1811,10 +1811,10 @@ static void input_cb(struct input_event *ev, int dev) // replace MENU key by RGUI to allow using Right Amiga on reduced keyboards // (it also disables the use of Menu for OSD) - if (mist_cfg.key_menu_as_rgui && code == 139) code = 126; + if (cfg.key_menu_as_rgui && code == 139) code = 126; //Keyrah v2: USB\VID_18D8&PID_0002\A600/A1200_MULTIMEDIA_EXTENSION_VERSION - int keyrah = (mist_cfg.keyrah_mode && (((((uint32_t)input[dev].vid) << 16) | input[dev].pid) == mist_cfg.keyrah_mode)); + int keyrah = (cfg.keyrah_mode && (((((uint32_t)input[dev].vid) << 16) | input[dev].pid) == cfg.keyrah_mode)); if (keyrah) code = keyrah_trans(code, ev->value); uint32_t ps2code = get_ps2_code(code); @@ -1823,7 +1823,7 @@ static void input_cb(struct input_event *ev, int dev) uint16_t reset_m = (modifier & MODMASK) >> 8; if (code == 111) reset_m |= 0x100; - user_io_check_reset(reset_m, (keyrah && !mist_cfg.reset_combo) ? 1 : mist_cfg.reset_combo); + user_io_check_reset(reset_m, (keyrah && !cfg.reset_combo) ? 1 : cfg.reset_combo); if(!user_io_osd_is_visible() && ((user_io_get_kbdemu() == EMU_JOY0) || (user_io_get_kbdemu() == EMU_JOY1))) { diff --git a/menu.c b/menu.c index 0bedcd1..c16cc74 100644 --- a/menu.c +++ b/menu.c @@ -37,19 +37,19 @@ along with this program. If not, see . #include "string.h" #include "file_io.h" #include "osd.h" -#include "fdd.h" -#include "hdd.h" +#include "minimig_fdd.h" +#include "minimig_hdd.h" #include "hardware.h" -#include "config.h" +#include "minimig_config.h" #include "menu.h" #include "user_io.h" -#include "tos.h" +#include "st_tos.h" #include "debug.h" -#include "boot.h" +#include "minimig_boot.h" #include "archie.h" #include "fpga_io.h" #include -#include "mist_cfg.h" +#include "cfg.h" #include "input.h" #include "x86.h" @@ -623,11 +623,11 @@ void HandleUI(void) break; /* case 0x01: // 1: 1280x720 mode - if (user_io_osd_is_visible) mist_cfg.video_mode = 0; + if (user_io_osd_is_visible) cfg.video_mode = 0; break; case 0x02: // 2: 1280x1024 mode - if (user_io_osd_is_visible) mist_cfg.video_mode = 1; + if (user_io_osd_is_visible) cfg.video_mode = 1; break; */ } diff --git a/menu.h b/menu.h index e23f2a7..211c4bc 100644 --- a/menu.h +++ b/menu.h @@ -1,7 +1,7 @@ #ifndef MENU_H #define MENU_H -#include "fdd.h" // for adfTYPE definition +#include "minimig_fdd.h" // for adfTYPE definition // UI strings, used by boot messages extern const char *config_filter_msg[]; diff --git a/boot.c b/minimig_boot.c similarity index 99% rename from boot.c rename to minimig_boot.c index f0b45f4..ef94b6a 100644 --- a/boot.c +++ b/minimig_boot.c @@ -5,13 +5,13 @@ #include "string.h" #include "stdio.h" -#include "boot.h" +#include "minimig_boot.h" #include "hardware.h" #include "osd.h" #include "spi.h" #include "file_io.h" -#include "config.h" -#include "fdd.h" +#include "minimig_config.h" +#include "minimig_fdd.h" static uint8_t buffer[1024]; diff --git a/boot.h b/minimig_boot.h similarity index 94% rename from boot.h rename to minimig_boot.h index a574909..15bfdf5 100644 --- a/boot.h +++ b/minimig_boot.h @@ -3,8 +3,8 @@ // 2014, rok.krajnc@gmail.com -#ifndef __BOOT_H__ -#define __BOOT_H__ +#ifndef __MINIMIG_BOOT_H__ +#define __MINIMIG_BOOT_H__ //// defines //// diff --git a/config.c b/minimig_config.c similarity index 99% rename from config.c rename to minimig_config.c index bd6f228..b9ec122 100644 --- a/config.c +++ b/minimig_config.c @@ -5,13 +5,13 @@ #include #include "hardware.h" -#include "boot.h" +#include "minimig_boot.h" #include "file_io.h" #include "osd.h" -#include "fdd.h" -#include "hdd.h" +#include "minimig_fdd.h" +#include "minimig_hdd.h" #include "menu.h" -#include "config.h" +#include "minimig_config.h" #include "user_io.h" #include "input.h" diff --git a/config.h b/minimig_config.h similarity index 94% rename from config.h rename to minimig_config.h index 46e523f..710ea34 100644 --- a/config.h +++ b/minimig_config.h @@ -1,3 +1,7 @@ + +#ifndef __MINIMIG_CONFIG_H__ +#define __MINIMIG_CONFIG_H__ + #include "file_io.h" typedef struct @@ -47,3 +51,5 @@ unsigned char SaveConfiguration(int num); // Can supply NULL to use filename pre unsigned char ConfigurationExists(int num); void ApplyConfiguration(char reloadkickstart); void MinimigReset(); + +#endif diff --git a/fdd.c b/minimig_fdd.c similarity index 99% rename from fdd.c rename to minimig_fdd.c index dd03be4..1afa90a 100644 --- a/fdd.c +++ b/minimig_fdd.c @@ -26,8 +26,8 @@ along with this program. If not, see . #include #include "hardware.h" #include "file_io.h" -#include "fdd.h" -#include "config.h" +#include "minimig_fdd.h" +#include "minimig_config.h" #include "debug.h" #include "fpga_io.h" #include "menu.h" diff --git a/fdd.h b/minimig_fdd.h similarity index 92% rename from fdd.h rename to minimig_fdd.h index c651028..be0c006 100644 --- a/fdd.h +++ b/minimig_fdd.h @@ -1,5 +1,5 @@ -#ifndef FDD_H -#define FDD_H +#ifndef __MINIMIG_FDD_H__ +#define __MINIMIG_FDD_H__ #include "file_io.h" diff --git a/hdd.c b/minimig_hdd.c similarity index 99% rename from hdd.c rename to minimig_hdd.c index 2196197..4e55116 100644 --- a/hdd.c +++ b/minimig_hdd.c @@ -24,10 +24,10 @@ along with this program. If not, see . #include #include "hardware.h" #include "file_io.h" -#include "hdd.h" -#include "hdd_internal.h" +#include "minimig_hdd.h" +#include "minimig_hdd_internal.h" #include "menu.h" -#include "config.h" +#include "minimig_config.h" #include "debug.h" #include "fpga_io.h" diff --git a/hdd.h b/minimig_hdd.h similarity index 97% rename from hdd.h rename to minimig_hdd.h index 41b4b99..f0423c7 100644 --- a/hdd.h +++ b/minimig_hdd.h @@ -1,8 +1,8 @@ // hdd.h -#ifndef __HDD_H__ -#define __HDD_H__ +#ifndef __MINIMIG_HDD_H__ +#define __MINIMIG_HDD_H__ // defines diff --git a/hdd_internal.h b/minimig_hdd_internal.h similarity index 97% rename from hdd_internal.h rename to minimig_hdd_internal.h index ecc824a..4d740c0 100644 --- a/hdd_internal.h +++ b/minimig_hdd_internal.h @@ -1,5 +1,5 @@ -#ifndef HDD_INTERNAL_H -#define HDD_INTERNAL_H +#ifndef __MINIMIG_HDD_INTERNAL_H__ +#define __MINIMIG_HDD_INTERNAL_H__ // Structure definitions for RDB emulation. // For hardfiles that have no RDB information, we'll just create a single-partition RDB and Part block diff --git a/mist_cfg.c b/mist_cfg.c deleted file mode 100644 index 7b0b5be..0000000 --- a/mist_cfg.c +++ /dev/null @@ -1,47 +0,0 @@ -// mist_cfg.c -// 2015, rok.krajnc@gmail.com - - -#include -#include "ini_parser.h" -#include "mist_cfg.h" -#include "user_io.h" - -mist_cfg_t mist_cfg; - -void mist_ini_parse() -{ - memset(&mist_cfg, 0, sizeof(mist_cfg)); - ini_parse(&mist_ini_cfg); -} - -// mist ini sections -const ini_section_t mist_ini_sections[] = -{ - { 1, "MiSTer" } -}; - -// mist ini vars -const ini_var_t mist_ini_vars[] = { - { "YPBPR", (void*)(&(mist_cfg.ypbpr)), UINT8, 0, 1, 1 }, - { "COMPOSITE_SYNC", (void*)(&(mist_cfg.csync)), UINT8, 0, 1, 1 }, - { "FORCED_SCANDOUBLER", (void*)(&(mist_cfg.forced_scandoubler)), UINT8, 0, 1, 1 }, - { "VGA_SCALER", (void*)(&(mist_cfg.vga_scaler)), UINT8, 0, 1, 1 }, - { "KEYRAH_MODE", (void*)(&(mist_cfg.keyrah_mode)), UINT32, 0, 0xFFFFFFFF, 1 }, - { "RESET_COMBO", (void*)(&(mist_cfg.reset_combo)), UINT8, 0, 3, 1 }, - { "KEY_MENU_AS_RGUI", (void*)(&(mist_cfg.key_menu_as_rgui)), UINT8, 0, 1, 1 }, - { "VIDEO_MODE", (void*)(mist_cfg.video_conf), STRING, 0, sizeof(mist_cfg.video_conf)-1, 1 }, - { "HDMI_AUDIO_96K", (void*)(&(mist_cfg.hdmi_audio_96k)), UINT8, 0, 1, 1 }, - { "DVI_MODE", (void*)(&(mist_cfg.dvi)), UINT8, 0, 1, 1 }, - { "KBD_NOMOUSE", (void*)(&(mist_cfg.kbd_nomouse)), UINT8, 0, 1, 1 }, - { "MOUSE_THROTTLE", (void*)(&(mist_cfg.mouse_throttle)), UINT8, 1, 100, 1 }, -}; - -// mist ini config -const ini_cfg_t mist_ini_cfg = { - CONFIG_DIR"/MiSTer.ini", - mist_ini_sections, - mist_ini_vars, - (int)(sizeof(mist_ini_sections) / sizeof(ini_section_t)), - (int)(sizeof(mist_ini_vars) / sizeof(ini_var_t)) -}; diff --git a/osd.c b/osd.c index 7fbbab9..79419e7 100644 --- a/osd.c +++ b/osd.c @@ -45,7 +45,7 @@ as rotated copies of the first 128 entries. -- AMR #include "logo.h" #include "user_io.h" #include "hardware.h" -#include "config.h" +#include "minimig_config.h" static int osd_size = 8; diff --git a/ikbd.c b/st_ikbd.c similarity index 99% rename from ikbd.c rename to st_ikbd.c index 1d0683a..727be1e 100644 --- a/ikbd.c +++ b/st_ikbd.c @@ -29,7 +29,7 @@ M1 tank platoon/A_385 fixed #include "user_io.h" #include "spi.h" -#include "ikbd.h" +#include "st_ikbd.h" #include "debug.h" #define IKBD_AUTO_MS 20 diff --git a/ikbd.h b/st_ikbd.h similarity index 84% rename from ikbd.h rename to st_ikbd.h index ca0eb24..dcd0cdf 100644 --- a/ikbd.h +++ b/st_ikbd.h @@ -1,5 +1,5 @@ -#ifndef IKBD_H -#define IKBD_H +#ifndef __ST_IKBD_H__ +#define __ST_IKBD_H__ void ikbd_init(void); void ikbd_poll(void); diff --git a/tos.c b/st_tos.c similarity index 95% rename from tos.c rename to st_tos.c index 9fd6b77..73ee637 100644 --- a/tos.c +++ b/st_tos.c @@ -4,11 +4,11 @@ #include "hardware.h" #include "menu.h" -#include "tos.h" +#include "st_tos.h" #include "file_io.h" #include "debug.h" #include "user_io.h" -#include "ikbd.h" +#include "st_ikbd.h" #include "fpga_io.h" #define CONFIG_FILENAME "MIST.CFG" diff --git a/tos.h b/st_tos.h similarity index 98% rename from tos.h rename to st_tos.h index fc26ca5..af3673b 100644 --- a/tos.h +++ b/st_tos.h @@ -1,5 +1,5 @@ -#ifndef TOS_H -#define TOS_H +#ifndef __ST_TOS_H__ +#define __ST_TOS_H__ #include "file_io.h" diff --git a/user_io.c b/user_io.c index fe6cc67..e21628d 100644 --- a/user_io.c +++ b/user_io.c @@ -11,21 +11,21 @@ #include "user_io.h" #include "archie.h" #include "debug.h" -#include "ikbd.h" +#include "st_ikbd.h" #include "spi.h" -#include "mist_cfg.h" -#include "tos.h" +#include "cfg.h" +#include "st_tos.h" #include "input.h" #include "fpga_io.h" #include "file_io.h" -#include "config.h" +#include "minimig_config.h" #include "menu.h" #include "x86.h" #include "tzx2wav.h" #include "DiskImage.h" -#include "boot.h" -#include "fdd.h" -#include "hdd.h" +#include "minimig_boot.h" +#include "minimig_fdd.h" +#include "minimig_hdd.h" #define BREAK 0x8000 @@ -363,7 +363,7 @@ void user_io_init() user_io_8bit_set_status(UIO_STATUS_RESET, UIO_STATUS_RESET); } - mist_ini_parse(); + MiSTer_ini_parse(); parse_video_mode(); user_io_send_buttons(1); @@ -895,7 +895,7 @@ void user_io_send_buttons(char force) static unsigned short key_map = 0; unsigned short map = 0; - map = mist_cfg.video_mode; + map = cfg.video_mode; map = (map << CONF_RES_SHIFT) & CONF_RES_MASK; int btn = fpga_get_buttons(); @@ -904,12 +904,12 @@ void user_io_send_buttons(char force) else if(btn & BUTTON_USR) map |= BUTTON2; if (kbd_reset) map |= BUTTON2; - if (mist_cfg.vga_scaler) map |= CONF_VGA_SCALER; - if (mist_cfg.csync) map |= CONF_CSYNC; - if (mist_cfg.ypbpr) map |= CONF_YPBPR; - if (mist_cfg.forced_scandoubler) map |= CONF_FORCED_SCANDOUBLER; - if (mist_cfg.hdmi_audio_96k) map |= CONF_AUDIO_96K; - if (mist_cfg.dvi) map |= CONF_DVI; + if (cfg.vga_scaler) map |= CONF_VGA_SCALER; + if (cfg.csync) map |= CONF_CSYNC; + if (cfg.ypbpr) map |= CONF_YPBPR; + if (cfg.forced_scandoubler) map |= CONF_FORCED_SCANDOUBLER; + if (cfg.hdmi_audio_96k) map |= CONF_AUDIO_96K; + if (cfg.dvi) map |= CONF_DVI; if ((map != key_map) || force) { @@ -1825,7 +1825,7 @@ void user_io_kbd(uint16_t key, int press) else { emu_mode = (emu_mode + 1) & 3; - if(mist_cfg.kbd_nomouse && emu_mode == EMU_MOUSE) emu_mode = (emu_mode + 1) & 3; + if(cfg.kbd_nomouse && emu_mode == EMU_MOUSE) emu_mode = (emu_mode + 1) & 3; } break; } @@ -1948,18 +1948,18 @@ uint32_t vitems[32]; static int parse_custom_video_mode() { - char *cfg = mist_cfg.video_conf; + char *vcfg = cfg.video_conf; int cnt = 0; - while (*cfg) + while (*vcfg) { char *next; if (cnt == 9 && vitems[0] == 1) { - double Fout = strtod(cfg, &next); - if (cfg == next || (Fout < 20.f || Fout > 200.f)) + double Fout = strtod(vcfg, &next); + if (vcfg == next || (Fout < 20.f || Fout > 200.f)) { - printf("Error parsing video_mode parameter: ""%s""\n", mist_cfg.video_conf); + printf("Error parsing video_mode parameter: ""%s""\n", cfg.video_conf); return 0; } @@ -1981,16 +1981,16 @@ static int parse_custom_video_mode() break; } - uint32_t val = strtoul(cfg, &next, 0); - if (cfg == next || (*next != ',' && *next)) + uint32_t val = strtoul(vcfg, &next, 0); + if (vcfg == next || (*next != ',' && *next)) { - printf("Error parsing video_mode parameter: ""%s""\n", mist_cfg.video_conf); + printf("Error parsing video_mode parameter: ""%s""\n", cfg.video_conf); return 0; } if (cnt < 32) vitems[cnt] = val; if (*next == ',') next++; - cfg = next; + vcfg = next; cnt++; } @@ -2018,7 +2018,7 @@ static int parse_custom_video_mode() void parse_video_mode() { // always 0. Use custom parameters. - mist_cfg.video_mode = 0; + cfg.video_mode = 0; int mode = parse_custom_video_mode(); if (mode >= 0)