Some refactoring and normalization.

This commit is contained in:
sorgelig
2020-04-12 17:19:49 +08:00
parent b2ae1e562a
commit 07d965102d
7 changed files with 136 additions and 119 deletions

View File

@@ -1233,7 +1233,7 @@ void start_map_setting(int cnt, int set)
mapping_clear = 0;
tmp_axis_n = 0;
if (mapping_type <= 1 && is_menu_core()) mapping_button = -6;
if (mapping_type <= 1 && is_menu()) mapping_button = -6;
memset(tmp_axis, 0, sizeof(tmp_axis));
//un-stick the enter key
@@ -1258,13 +1258,13 @@ int get_map_clear()
static uint32_t osd_timer = 0;
int get_map_cancel()
{
return (mapping && !is_menu_core() && osd_timer && CheckTimer(osd_timer));
return (mapping && !is_menu() && osd_timer && CheckTimer(osd_timer));
}
static char *get_map_name(int dev, int def)
{
static char name[128];
if (def || is_menu_core()) sprintf(name, "input_%s_v3.map", input[dev].idstr);
if (def || is_menu()) sprintf(name, "input_%s_v3.map", input[dev].idstr);
else sprintf(name, "%s_input_%s_v3.map", user_io_get_core_name_ex(), input[dev].idstr);
return name;
}
@@ -1297,7 +1297,7 @@ void finish_map_setting(int dismiss)
if (!dismiss) save_map(get_map_name(mapping_dev, 0), &input[mapping_dev].map, sizeof(input[mapping_dev].map));
if (dismiss == 2) delete_map(get_map_name(mapping_dev, 0));
if (is_menu_core()) input[mapping_dev].has_mmap = 0;
if (is_menu()) input[mapping_dev].has_mmap = 0;
}
}
@@ -1881,7 +1881,7 @@ static void input_cb(struct input_event *ev, struct input_absinfo *absinfo, int
else if (!load_map(get_map_name(dev, 0), &input[dev].map, sizeof(input[dev].map)))
{
memset(input[dev].map, 0, sizeof(input[dev].map));
if (!is_menu_core())
if (!is_menu())
{
if (input[dev].has_mmap == 1)
{
@@ -1923,12 +1923,12 @@ static void input_cb(struct input_event *ev, struct input_absinfo *absinfo, int
if (old_combo != 3 && input[dev].osd_combo == 3)
{
osd_event = 1;
if (mapping && !is_menu_core()) osd_timer = GetTimer(1000);
if (mapping && !is_menu()) osd_timer = GetTimer(1000);
}
else if (old_combo == 3 && input[dev].osd_combo != 3)
{
osd_event = 2;
if (mapping && !is_menu_core())
if (mapping && !is_menu())
{
if (CheckTimer(osd_timer))
{
@@ -1952,7 +1952,7 @@ static void input_cb(struct input_event *ev, struct input_absinfo *absinfo, int
{
int idx = 0;
if (is_menu_core())
if (is_menu())
{
spi_uio_cmd(UIO_KEYBOARD); //ping the Menu core to wakeup
osd_event = 0;
@@ -2014,7 +2014,7 @@ static void input_cb(struct input_event *ev, struct input_absinfo *absinfo, int
}
else
{
int clear = (ev->code == KEY_F12 || ev->code == KEY_MENU || ev->code == KEY_HOMEPAGE) && !is_menu_core();
int clear = (ev->code == KEY_F12 || ev->code == KEY_MENU || ev->code == KEY_HOMEPAGE) && !is_menu();
if (ev->value == 1 && mapping_dev < 0 && !clear)
{
mapping_dev = dev;
@@ -2023,11 +2023,11 @@ static void input_cb(struct input_event *ev, struct input_absinfo *absinfo, int
}
mapping_clear = 0;
if (mapping_dev >= 0 && !map_skip && (mapping_dev == dev || clear) && mapping_button < (is_menu_core() ? (mapping_type ? SYS_BTN_CNT_ESC + 1 : SYS_BTN_OSD_KTGL + 1) : mapping_count))
if (mapping_dev >= 0 && !map_skip && (mapping_dev == dev || clear) && mapping_button < (is_menu() ? (mapping_type ? SYS_BTN_CNT_ESC + 1 : SYS_BTN_OSD_KTGL + 1) : mapping_count))
{
if (ev->value == 1 && !key_mapped)
{
if (is_menu_core())
if (is_menu())
{
if (mapping_dev == dev && !(!mapping_button && last_axis && ((ev->code == last_axis) || (ev->code == last_axis + 1))))
{
@@ -2102,7 +2102,7 @@ static void input_cb(struct input_event *ev, struct input_absinfo *absinfo, int
}
}
//combo for osd button
if (ev->value == 1 && key_mapped && key_mapped != ev->code && is_menu_core() && mapping_button == SYS_BTN_OSD_KTGL && mapping_type)
if (ev->value == 1 && key_mapped && key_mapped != ev->code && is_menu() && mapping_button == SYS_BTN_OSD_KTGL && mapping_type)
{
input[dev].map[SYS_BTN_OSD_KTGL + 2] = ev->code;
printf("Set combo: %x + %x\n", input[dev].map[SYS_BTN_OSD_KTGL + 1], input[dev].map[SYS_BTN_OSD_KTGL + 2]);
@@ -2120,7 +2120,7 @@ static void input_cb(struct input_event *ev, struct input_absinfo *absinfo, int
}
}
}
else if (is_menu_core())
else if (is_menu())
{
//Define min-0-max analogs
switch (mapping_button)
@@ -2237,7 +2237,7 @@ static void input_cb(struct input_event *ev, struct input_absinfo *absinfo, int
if (idx) input[mapping_dev].map[idx] = 0;
else if (mapping_button > 0)
{
if (!is_menu_core()) input[mapping_dev].map[mapping_button] &= mapping_set ? 0x0000FFFF : 0xFFFF0000;
if (!is_menu()) input[mapping_dev].map[mapping_button] &= mapping_set ? 0x0000FFFF : 0xFFFF0000;
}
}
last_axis = 0;
@@ -2247,11 +2247,11 @@ static void input_cb(struct input_event *ev, struct input_absinfo *absinfo, int
}
map_skip = 0;
if (mapping_button >= 4 && !is_menu_core() && !strcmp(joy_bnames[mapping_button - 4], "-")) map_skip = 2;
if (mapping_button >= 4 && !is_menu() && !strcmp(joy_bnames[mapping_button - 4], "-")) map_skip = 2;
if (!map_skip) break;
}
if (is_menu_core() && mapping_type <= 1 && mapping_dev >= 0)
if (is_menu() && mapping_type <= 1 && mapping_dev >= 0)
{
memcpy(&input[mapping_dev].mmap[SYS_AXIS1_X], tmp_axis, sizeof(tmp_axis));
memcpy(&input[mapping_dev].map[SYS_AXIS1_X], tmp_axis, sizeof(tmp_axis));
@@ -2986,7 +2986,7 @@ int input_test(int getchar)
if (state == 2)
{
int timeout = 0;
if (is_menu_core() && video_fb_state()) timeout = 25;
if (is_menu() && video_fb_state()) timeout = 25;
while (1)
{
@@ -3194,7 +3194,7 @@ int input_test(int getchar)
if (ev.code == KEY_MENU) ev.code = BTN_MODE;
}
if (is_menu_core() && !video_fb_state())
if (is_menu() && !video_fb_state())
{
/*
if (mapping && mapping_type <= 1 && !(ev.type==EV_KEY && ev.value>1))
@@ -3398,7 +3398,7 @@ int input_test(int getchar)
xval = ((data[0] & 0x10) ? -256 : 0) | data[1];
yval = ((data[0] & 0x20) ? -256 : 0) | data[2];
if (is_menu_core() && !video_fb_state()) printf("%s: btn=0x%02X, dx=%d, dy=%d, scroll=%d\n", input[i].devname, data[0], xval, yval, (int8_t)data[3]);
if (is_menu() && !video_fb_state()) printf("%s: btn=0x%02X, dx=%d, dy=%d, scroll=%d\n", input[i].devname, data[0], xval, yval, (int8_t)data[3]);
if (cfg.mouse_throttle) throttle = cfg.mouse_throttle;
if (ds_mouse_emu) throttle *= 4;

View File

@@ -488,7 +488,7 @@ static uint32_t menu_key_get(void)
c2 = c1;
// inject a fake "MENU_KEY" if no menu is visible and the menu key is loaded
if (!user_io_osd_is_visible() && !video_fb_state() && is_menu_core()) c = KEY_F12;
if (!user_io_osd_is_visible() && !video_fb_state() && is_menu()) c = KEY_F12;
// generate repeat "key-pressed" events
if ((c1 & UPSTROKE) || (!c1))
@@ -539,7 +539,7 @@ static uint32_t menu_key_get(void)
if (but && CheckTimer(longpress) && !longpress_consumed)
{
longpress_consumed = 1;
if (is_menu_core())
if (is_menu())
{
if (menustate == MENU_SYSTEM2 || menustate == MENU_FILE_SELECT2) menustate = MENU_JOYSYSMAP;
}
@@ -678,7 +678,7 @@ static void printSysInfo()
sysinfo_timer = GetTimer(2000);
struct battery_data_t bat;
int hasbat = getBattery(0, &bat);
int n = is_menu_core() ? 10 : 5;
int n = is_menu() ? 10 : 5;
char str[40];
OsdWrite(n++, info_top, 0, 0);
@@ -893,7 +893,7 @@ void HandleUI(void)
if (c && c != KEY_F12 && cfg.bootcore[0] != '\0') cfg.bootcore[0] = '\0';
if (is_menu_core())
if (is_menu())
{
static int menu_visible = 1;
static unsigned long timeout = 0;
@@ -952,7 +952,7 @@ void HandleUI(void)
break;
case KEY_F1:
if (is_menu_core() && cfg.fb_terminal)
if (is_menu() && cfg.fb_terminal)
{
unsigned long status = (user_io_8bit_set_status(0, 0)+ 2) & 0xE;
user_io_8bit_set_status(status, 0xE);
@@ -980,7 +980,7 @@ void HandleUI(void)
break;
case KEY_F9:
if ((is_menu_core() || ((get_key_mod() & (LALT | RALT)) && (get_key_mod() & (LCTRL | RCTRL))) || has_fb_terminal) && cfg.fb_terminal)
if ((is_menu() || ((get_key_mod() & (LALT | RALT)) && (get_key_mod() & (LCTRL | RCTRL))) || has_fb_terminal) && cfg.fb_terminal)
{
video_chvt(1);
video_fb_enable(!video_fb_state());
@@ -1139,14 +1139,14 @@ void HandleUI(void)
if (menu)
{
OsdSetSize(16);
if(!is_menu_core() && (get_key_mod() & (LALT | RALT))) //Alt+Menu
if(!is_menu() && (get_key_mod() & (LALT | RALT))) //Alt+Menu
{
SelectFile(0, SCANO_CORES, MENU_CORE_FILE_SELECTED1, MENU_NONE1);
}
else if (user_io_core_type() == CORE_TYPE_MIST) menustate = MENU_MIST_MAIN1;
else if (is_archie_core()) menustate = MENU_ARCHIE_MAIN1;
else if (is_archie()) menustate = MENU_ARCHIE_MAIN1;
else {
if (is_menu_core())
if (is_menu())
{
OsdCoreNameSet("");
SelectFile(0, SCANO_CORES, MENU_CORE_FILE_SELECTED1, MENU_SYSTEM1);
@@ -1157,7 +1157,7 @@ void HandleUI(void)
}
else
{
if ((get_key_mod() & (LGUI | RGUI)) && !is_x86_core() && has_menu()) //Win+Menu
if ((get_key_mod() & (LGUI | RGUI)) && !is_x86() && has_menu()) //Win+Menu
{
menustate = MENU_8BIT_SYSTEM1;
}
@@ -1617,10 +1617,10 @@ void HandleUI(void)
if (p[idx] >= '0' && p[idx] <= '9') ioctl_index = p[idx] - '0';
substrcpy(ext, p, 1);
if (is_gba_core() && FileExists(user_io_make_filepath(HomeDir, "goomba.rom"))) strcat(ext, "GB GBC");
if (is_gba() && FileExists(user_io_make_filepath(HomeDir, "goomba.rom"))) strcat(ext, "GB GBC");
while (strlen(ext) % 3) strcat(ext, " ");
fs_Options = SCANO_DIR | (is_neogeo_core() ? SCANO_NEOGEO | SCANO_NOENTER : 0);
fs_Options = SCANO_DIR | (is_neogeo() ? SCANO_NEOGEO | SCANO_NOENTER : 0);
fs_MenuSelect = MENU_8BIT_MAIN_FILE_SELECTED;
fs_MenuCancel = MENU_8BIT_MAIN1;
strcpy(fs_pFileExt, ext);
@@ -1665,7 +1665,7 @@ void HandleUI(void)
uint32_t status = user_io_8bit_set_status(0, 0, ex); // 0,0 gets status
uint32_t x = getStatus(p, status) + 1;
if (byarm && is_x86_core())
if (byarm && is_x86())
{
if (p[1] == '2') x86_set_fdd_boot(!(x & 1));
}
@@ -1683,14 +1683,14 @@ void HandleUI(void)
// determine which status bit is affected
uint32_t mask = 1 << getIdx(p);
if (mask == 1 && is_x86_core())
if (mask == 1 && is_x86())
{
x86_init();
menustate = MENU_NONE1;
}
else
{
if (is_megacd_core())
if (is_megacd())
{
if (mask == 1) mcd_set_image(0, "");
if (mask == 2)
@@ -1745,11 +1745,11 @@ void HandleUI(void)
case MENU_8BIT_MAIN_IMAGE_SELECTED:
printf("Image selected: %s\n", SelectedPath);
if (is_x86_core())
if (is_x86())
{
x86_set_image(ioctl_index, SelectedPath);
}
else if (is_megacd_core())
else if (is_megacd())
{
uint32_t status = user_io_8bit_set_status(0, 0);
if (!(status & 4))
@@ -1791,7 +1791,7 @@ void HandleUI(void)
adjvisible = 0;
MenuWrite(n++, " Core \x16", menusub == 0, 0);
sprintf(s, " Define %s buttons ", is_menu_core() ? "System" : user_io_get_core_name_ex());
sprintf(s, " Define %s buttons ", is_menu() ? "System" : user_io_get_core_name_ex());
s[27] = '\x16';
s[28] = 0;
MenuWrite(n++, s, menusub == 1, 0);
@@ -1852,7 +1852,7 @@ void HandleUI(void)
else
{
MenuWrite(n++);
MenuWrite(n++, " Reset settings", menusub == 9, is_archie_core());
MenuWrite(n++, " Reset settings", menusub == 9, is_archie());
MenuWrite(n++, " Save settings", menusub == 10, 0);
}
@@ -1971,7 +1971,7 @@ void HandleUI(void)
}
break;
case 9:
if (!is_archie_core())
if (!is_archie())
{
menustate = MENU_RESET1;
menusub = 1;
@@ -1988,7 +1988,7 @@ void HandleUI(void)
menustate = MENU_8BIT_MAIN1;
menusub = 0;
if (is_archie_core())
if (is_archie())
{
archie_save_config();
menustate = MENU_ARCHIE_MAIN1;
@@ -2003,7 +2003,7 @@ void HandleUI(void)
uint32_t status[2] = { user_io_8bit_set_status(0, 0, 0), user_io_8bit_set_status(0, 0, 1) };
printf("Saving config to %s\n", filename);
FileSaveConfig(filename, status, 8);
if (is_x86_core()) x86_config_save();
if (is_x86()) x86_config_save();
}
break;
@@ -2048,7 +2048,7 @@ void HandleUI(void)
menusub = 0;
menustate = MENU_MAIN1;
}
else if (is_archie_core())
else if (is_archie())
{
menusub = 0;
menustate = MENU_ARCHIE_MAIN1;
@@ -2362,7 +2362,7 @@ void HandleUI(void)
menusub = 0;
menustate = MENU_MAIN1;
}
else if (is_archie_core())
else if (is_archie())
{
menusub = 0;
menustate = MENU_ARCHIE_MAIN1;
@@ -2406,7 +2406,7 @@ void HandleUI(void)
flash_timer = 0;
flash_state = 0;
for (int i = 0; i < OsdGetSize(); i++) OsdWrite(i);
if (is_menu_core())
if (is_menu())
{
OsdWrite(8, " Esc \x16 Cancel");
OsdWrite(9, " Enter \x16 Finish");
@@ -2438,7 +2438,7 @@ void HandleUI(void)
break;
}
if (is_menu_core() && !get_map_button()) OsdWrite(7);
if (is_menu() && !get_map_button()) OsdWrite(7);
const char* p = 0;
if (get_map_button() < 0)
@@ -2453,7 +2453,7 @@ void HandleUI(void)
else if (joy_bcount)
{
p = joy_bnames[get_map_button() - DPAD_NAMES];
if (is_menu_core())
if (is_menu())
{
if (!get_map_type()) joy_bcount = 17;
if (get_map_button() == SYS_BTN_OSD_KTGL)
@@ -2474,7 +2474,7 @@ void HandleUI(void)
if (get_map_button() >= 0)
{
if (is_menu_core() && get_map_button() > SYS_BTN_CNT_ESC)
if (is_menu() && get_map_button() > SYS_BTN_CNT_ESC)
{
strcpy(s, joy_button_map[(get_map_button() - SYS_BTN_CNT_ESC - 1) + DPAD_BUTTON_NAMES + 2]);
}
@@ -2496,7 +2496,7 @@ void HandleUI(void)
OsdWrite(3, s, 0, 0);
OsdWrite(4);
if(is_menu_core() && joy_bcount && get_map_button() >= SYS_BTN_RIGHT && get_map_button() <= SYS_BTN_START)
if(is_menu() && joy_bcount && get_map_button() >= SYS_BTN_RIGHT && get_map_button() <= SYS_BTN_START)
{
// draw an on-screen gamepad to help with central button mapping
if (!flash_timer || CheckTimer(flash_timer))
@@ -2551,7 +2551,7 @@ void HandleUI(void)
if (get_map_vid() || get_map_pid())
{
if (!is_menu_core() && get_map_type() && !has_default_map())
if (!is_menu() && get_map_type() && !has_default_map())
{
for (int i = 0; i < OsdGetSize(); i++) OsdWrite(i);
OsdWrite(6, " You need to define this");
@@ -2565,15 +2565,15 @@ void HandleUI(void)
sprintf(s, " %s ID: %04x:%04x", get_map_type() ? "Joystick" : "Keyboard", get_map_vid(), get_map_pid());
if (get_map_button() > 0 || !joymap_first)
{
OsdWrite(7, (get_map_type() && !is_menu_core()) ? " Space/Menu \x16 Undefine" : " Space \x16 Undefine");
OsdWrite(7, (get_map_type() && !is_menu()) ? " Space/Menu \x16 Undefine" : " Space \x16 Undefine");
if (!get_map_type()) OsdWrite(9);
}
OsdWrite(5, s);
if (!is_menu_core()) OsdWrite(10, " F12 \x16 Clear all");
if (!is_menu()) OsdWrite(10, " F12 \x16 Clear all");
}
}
if (!is_menu_core() && (get_map_button() >= (joy_bcount ? joy_bcount + 4 : 8) || (select & get_map_vid() & get_map_pid())) && joymap_first && get_map_type())
if (!is_menu() && (get_map_button() >= (joy_bcount ? joy_bcount + 4 : 8) || (select & get_map_vid() & get_map_pid())) && joymap_first && get_map_type())
{
finish_map_setting(0);
menustate = MENU_JOYDIGMAP3;
@@ -2582,7 +2582,7 @@ void HandleUI(void)
else if (select || menu || get_map_button() >= (joy_bcount ? joy_bcount + 4 : 8))
{
finish_map_setting(menu);
if (is_menu_core())
if (is_menu())
{
menustate = MENU_SYSTEM1;
menusub = 2;
@@ -3566,7 +3566,7 @@ void HandleUI(void)
char type = flist_SelectedItem()->de.d_type;
memcpy(name, flist_SelectedItem()->de.d_name, sizeof(name));
if ((fs_Options & SCANO_UMOUNT) && is_megacd_core() && type == DT_DIR && strcmp(flist_SelectedItem()->de.d_name, ".."))
if ((fs_Options & SCANO_UMOUNT) && is_megacd() && type == DT_DIR && strcmp(flist_SelectedItem()->de.d_name, ".."))
{
int len = strlen(SelectedPath);
strcat(SelectedPath, "/");
@@ -3696,7 +3696,7 @@ void HandleUI(void)
if (menu || recent)
{
menustate = fs_MenuCancel;
if (is_menu_core()) menustate = MENU_FILE_SELECT1;
if (is_menu()) menustate = MENU_FILE_SELECT1;
break;
}
@@ -3734,7 +3734,7 @@ void HandleUI(void)
sleep(1);
recent_clear((fs_Options & SCANO_CORES) ? -1 : (fs_Options & SCANO_UMOUNT) ? ioctl_index + 500 : ioctl_index);
menustate = fs_MenuCancel;
if (is_menu_core()) menustate = MENU_FILE_SELECT1;
if (is_menu()) menustate = MENU_FILE_SELECT1;
break;
}
@@ -4889,7 +4889,7 @@ void HandleUI(void)
break;
}
if (is_menu_core())
if (is_menu())
{
static unsigned long rtc_timer = 0;
static int init_wait = 0;

View File

@@ -695,7 +695,7 @@ char* OsdCoreName()
void OsdUpdate()
{
int n = is_menu_core() ? 19 : osd_size;
int n = is_menu() ? 19 : osd_size;
for (int i = 0; i < n; i++)
{
if (osdset & (1 << i))
@@ -703,7 +703,7 @@ void OsdUpdate()
spi_osd_cmd_cont(OSD_CMD_WRITE | i);
spi_write(osdbuf + i * 256, 256, 0);
DisableOsd();
if (is_megacd_core()) mcd_poll();
if (is_megacd()) mcd_poll();
}
}

View File

@@ -64,7 +64,7 @@ static void recent_load(int idx)
for (int i = 0; i < recent_available(); i++)
{
ena[i] = FileExists(recent_path(recents[i].dir, recents[i].name));
if (idx >= 0 && is_neogeo_core() && !ena[i]) ena[i] = PathIsDir(recent_path(recents[i].dir, recents[i].name));
if (idx >= 0 && is_neogeo() && !ena[i]) ena[i] = PathIsDir(recent_path(recents[i].dir, recents[i].name));
}
}

View File

@@ -187,42 +187,42 @@ const char *user_io_get_core_name_ex()
}
static int is_menu_type = 0;
char is_menu_core()
char is_menu()
{
if (!is_menu_type) is_menu_type = strcasecmp(core_name, "MENU") ? 2 : 1;
return (is_menu_type == 1);
}
static int is_x86_type = 0;
char is_x86_core()
char is_x86()
{
if (!is_x86_type) is_x86_type = strcasecmp(core_name, "AO486") ? 2 : 1;
return (is_x86_type == 1);
}
static int is_snes_type = 0;
char is_snes_core()
char is_snes()
{
if (!is_snes_type) is_snes_type = strcasecmp(core_name, "SNES") ? 2 : 1;
return (is_snes_type == 1);
}
static int is_cpc_type = 0;
char is_cpc_core()
char is_cpc()
{
if (!is_cpc_type) is_cpc_type = strcasecmp(core_name, "amstrad") ? 2 : 1;
return (is_cpc_type == 1);
}
static int is_zx81_type = 0;
char is_zx81_core()
char is_zx81()
{
if (!is_zx81_type) is_zx81_type = strcasecmp(core_name, "zx81") ? 2 : 1;
return (is_zx81_type == 1);
}
static int is_neogeo_type = 0;
char is_neogeo_core()
char is_neogeo()
{
if (!is_neogeo_type) is_neogeo_type = strcasecmp(core_name, "neogeo") ? 2 : 1;
return (is_neogeo_type == 1);
@@ -236,14 +236,14 @@ char is_minimig()
}
static int is_megacd_type = 0;
char is_megacd_core()
char is_megacd()
{
if (!is_megacd_type) is_megacd_type = strcasecmp(core_name, "MEGACD") ? 2 : 1;
return (is_megacd_type == 1);
}
static int is_archie_type = 0;
char is_archie_core()
char is_archie()
{
if (core_type == CORE_TYPE_ARCHIE) return 1;
if (!is_archie_type) is_archie_type = strcasecmp(core_name, "ARCHIE") ? 2 : 1;
@@ -251,19 +251,26 @@ char is_archie_core()
}
static int is_gba_type = 0;
char is_gba_core()
char is_gba()
{
if (!is_gba_type) is_gba_type = strcasecmp(core_name, "GBA") ? 2 : 1;
return (is_gba_type == 1);
}
static int is_c64_type = 0;
char is_c64_core()
char is_c64()
{
if (!is_c64_type) is_c64_type = strcasecmp(core_name, "C64") ? 2 : 1;
return (is_c64_type == 1);
}
static int is_st_type = 0;
char is_st()
{
if (!is_st_type) is_st_type = strcasecmp(core_name, "AtariST") ? 2 : 1;
return (is_st_type == 1);
}
char is_sharpmz()
{
return(core_type == CORE_TYPE_SHARPMZ);
@@ -292,6 +299,8 @@ static void user_io_read_core_name()
is_megacd_type = 0;
is_archie_type = 0;
is_gba_type = 0;
is_c64_type = 0;
is_st_type = 0;
core_name[0] = 0;
// get core name
@@ -426,7 +435,7 @@ static void parse_config()
unsigned long x = getStatus(p+1, status);
if (is_x86_core())
if (is_x86())
{
if (p[2] == '2') x86_set_fdd_boot(!(x&1));
}
@@ -600,7 +609,7 @@ uint16_t sdram_sz(int sz)
if(res & 0x4000) printf("*** Debug phase: %d\n", (res & 0x100) ? (res & 0xFF) : -(res & 0xFF));
else printf("*** Found SDRAM config: %d\n", res & 7);
}
else if(!is_menu_core())
else if(!is_menu())
{
printf("*** SDRAM config not found\n");
}
@@ -786,7 +795,7 @@ void user_io_init(const char *path, const char *xml)
}
parse_config();
if (is_menu_core())
if (is_menu())
{
user_io_8bit_set_status((cfg.menu_pal) ? 0x10 : 0, 0x10);
if (cfg.fb_terminal) video_menu_bg((status[0] >> 1) & 7);
@@ -803,12 +812,12 @@ void user_io_init(const char *path, const char *xml)
puts("Identified Minimig V2 core");
BootInit();
}
else if (is_x86_core())
else if (is_x86())
{
x86_config_load();
x86_init();
}
else if (is_archie_core())
else if (is_archie())
{
puts("Identified Archimedes core");
archie_init();
@@ -817,7 +826,7 @@ void user_io_init(const char *path, const char *xml)
{
if (!strlen(path) || !user_io_file_tx(path, 0, 0, 0, 1))
{
if (!is_cpc_core())
if (!is_cpc())
{
// check for multipart rom
for (char i = 0; i < 4; i++)
@@ -847,7 +856,7 @@ void user_io_init(const char *path, const char *xml)
if (user_io_use_cheats()) cheats_init("", user_io_get_file_crc());
}
if (is_cpc_core())
if (is_cpc())
{
for (int m = 0; m < 3; m++)
{
@@ -1226,7 +1235,7 @@ int user_io_file_mount(char *name, unsigned char index, char pre)
{
ret = x2trd(name, sd_image + index);
}
else if (is_c64_core() && len > 4 && !strcasecmp(name + len - 4, ".t64"))
else if (is_c64() && len > 4 && !strcasecmp(name + len - 4, ".t64"))
{
writable = 0;
ret = c64_openT64(name, sd_image + index);
@@ -1816,7 +1825,7 @@ int user_io_file_tx(const char* name, unsigned char index, char opensave, char m
// prepare transmission of new file
user_io_set_download(1);
if (is_snes_core() && bytes2send)
if (is_snes() && bytes2send)
{
printf("Load SNES ROM.\n");
uint8_t* buf = snes_get_header(&f);
@@ -1840,7 +1849,7 @@ int user_io_file_tx(const char* name, unsigned char index, char opensave, char m
if (use_progress) MenuHide();
int dosend = 1;
if (is_gba_core())
if (is_gba())
{
process_ss(name);
@@ -1912,7 +1921,7 @@ int user_io_file_tx(const char* name, unsigned char index, char opensave, char m
user_io_set_download(0);
printf("\n");
if (is_zx81_core() && index)
if (is_zx81() && index)
{
send_pcolchr(name, (index & 0x1F) | 0x20, 0);
send_pcolchr(name, (index & 0x1F) | 0x60, 1);
@@ -2052,16 +2061,16 @@ void user_io_send_buttons(char force)
//special reset for some cores
if (!user_io_osd_is_visible() && (key_map & BUTTON2) && !(map & BUTTON2))
{
if (is_archie_core()) fpga_load_rbf(name[0] ? name : "Archie.rbf");
if (is_archie()) fpga_load_rbf(name[0] ? name : "Archie.rbf");
if (is_minimig()) minimig_reset();
if (is_megacd_core()) mcd_reset();
if (is_megacd()) mcd_reset();
}
key_map = map;
if (user_io_osd_is_visible()) map &= ~BUTTON2;
spi_uio_cmd16(UIO_BUT_SW, map);
printf("sending keymap: %X\n", map);
if ((key_map & BUTTON2) && is_x86_core()) x86_init();
if ((key_map & BUTTON2) && is_x86()) x86_init();
}
}
@@ -2239,7 +2248,7 @@ void user_io_poll()
tos_poll();
}
if (core_type == CORE_TYPE_8BIT && !is_menu_core())
if (core_type == CORE_TYPE_8BIT && !is_menu())
{
/*
unsigned char c = 1, f, p = 0;
@@ -2271,11 +2280,11 @@ void user_io_poll()
}
// sd card emulation
if (is_x86_core())
if (is_x86())
{
x86_poll();
}
else if ((core_type == CORE_TYPE_8BIT || core_type == CORE_TYPE_ARCHIE) && !is_menu_core() && !is_minimig())
else if ((core_type == CORE_TYPE_8BIT || core_type == CORE_TYPE_ARCHIE) && !is_menu() && !is_minimig())
{
static uint8_t buffer[4][512];
uint32_t lba;
@@ -2389,7 +2398,7 @@ void user_io_poll()
{
if (sd_image[disk].type == 2)
{
if (is_megacd_core())
if (is_megacd())
{
mcd_fill_blanksave(buffer[disk], lba);
}
@@ -2440,7 +2449,7 @@ void user_io_poll()
}
}
if (core_type == CORE_TYPE_8BIT && !is_menu_core() && !is_minimig() && !is_archie_core())
if (core_type == CORE_TYPE_8BIT && !is_menu() && !is_minimig() && !is_archie())
{
// frequently check ps2 mouse for events
if (CheckTimer(mouse_timer))
@@ -2503,7 +2512,7 @@ void user_io_poll()
else if (ps2_wheel < -63) ps2_wheel = -63;
// collect movement info and send at predefined rate
if (is_menu_core() && !video_fb_state()) printf("PS2 MOUSE: %x %d %d %d\n", ps2_mouse[0], ps2_mouse[1], ps2_mouse[2], ps2_wheel);
if (is_menu() && !video_fb_state()) printf("PS2 MOUSE: %x %d %d %d\n", ps2_mouse[0], ps2_mouse[1], ps2_mouse[2], ps2_wheel);
if (!osd_is_visible)
{
@@ -2521,18 +2530,18 @@ void user_io_poll()
}
}
if (is_neogeo_core() && (!rtc_timer || CheckTimer(rtc_timer)))
if (is_neogeo() && (!rtc_timer || CheckTimer(rtc_timer)))
{
// Update once per minute should be enough
rtc_timer = GetTimer(60000);
send_rtc(1);
}
if (core_type == CORE_TYPE_ARCHIE || is_archie_core()) archie_poll();
if (core_type == CORE_TYPE_ARCHIE || is_archie()) archie_poll();
if (core_type == CORE_TYPE_SHARPMZ) sharpmz_poll();
static uint8_t leds = 0;
if(use_ps2ctl && !is_minimig() && !is_archie_core())
if(use_ps2ctl && !is_minimig() && !is_archie())
{
leds |= (KBD_LED_FLAG_STATUS | KBD_LED_CAPS_CONTROL);
@@ -2664,7 +2673,7 @@ void user_io_poll()
}
}
if (CheckTimer(led_timer) && !is_menu_core())
if (CheckTimer(led_timer) && !is_menu())
{
led_timer = GetTimer(LED_FREQ);
if (!use_ps2ctl)
@@ -2697,7 +2706,7 @@ void user_io_poll()
}
else if(CheckTimer(res_timer))
{
if (is_menu_core())
if (is_menu())
{
static int got_cfg = 0;
if (!got_cfg)
@@ -2765,7 +2774,7 @@ void user_io_poll()
diskled_is_on = 0;
}
if (is_megacd_core()) mcd_poll();
if (is_megacd()) mcd_poll();
process_ss(0);
}
@@ -2843,7 +2852,7 @@ static void send_keycode(unsigned short key, int press)
return;
}
if (core_type == CORE_TYPE_ARCHIE || is_archie_core())
if (core_type == CORE_TYPE_ARCHIE || is_archie())
{
if (press > 1) return;
@@ -2985,7 +2994,7 @@ void user_io_mouse(unsigned char b, int16_t x, int16_t y, int16_t w)
mouse_pos[Y] += y;
mouse_flags |= 0x80 | (b & 7);
}
else if (is_archie_core())
else if (is_archie())
{
archie_mouse(b, x, y);
}
@@ -3094,7 +3103,7 @@ void set_volume(int cmd)
void user_io_kbd(uint16_t key, int press)
{
if(is_menu_core()) spi_uio_cmd(UIO_KEYBOARD); //ping the Menu core to wakeup
if(is_menu()) spi_uio_cmd(UIO_KEYBOARD); //ping the Menu core to wakeup
// Win+PrnScr or Alt/Win+ScrLk - screen shot
if ((key == KEY_SYSRQ && (get_key_mod() & (RGUI | LGUI))) || (key == KEY_SCROLLLOCK && (get_key_mod() & (LALT | RALT | RGUI | LGUI))))
@@ -3167,7 +3176,7 @@ void user_io_kbd(uint16_t key, int press)
uint32_t code = get_ps2_code(key);
if (!press)
{
if (is_menu_core() && !video_fb_state()) printf("PS2 code(break)%s for core: %d(0x%X)\n", (code & EXT) ? "(ext)" : "", code & 255, code & 255);
if (is_menu() && !video_fb_state()) printf("PS2 code(break)%s for core: %d(0x%X)\n", (code & EXT) ? "(ext)" : "", code & 255, code & 255);
if (key == KEY_MENU) key = KEY_F12;
if (osd_is_visible) menu_key_set(UPSTROKE | key);
@@ -3177,16 +3186,16 @@ void user_io_kbd(uint16_t key, int press)
}
else
{
if (is_menu_core() && !video_fb_state()) printf("PS2 code(make)%s for core: %d(0x%X)\n", (code & EXT) ? "(ext)" : "", code & 255, code & 255);
if (!osd_is_visible && !is_menu_core() && key == KEY_MENU && press == 3) open_joystick_setup();
else if ((has_menu() || osd_is_visible || (get_key_mod() & (LALT | RALT | RGUI | LGUI))) && (((key == KEY_F12) && ((!is_x86_core() && !is_archie_core()) || (get_key_mod() & (RGUI | LGUI)))) || key == KEY_MENU)) menu_key_set(KEY_F12);
if (is_menu() && !video_fb_state()) printf("PS2 code(make)%s for core: %d(0x%X)\n", (code & EXT) ? "(ext)" : "", code & 255, code & 255);
if (!osd_is_visible && !is_menu() && key == KEY_MENU && press == 3) open_joystick_setup();
else if ((has_menu() || osd_is_visible || (get_key_mod() & (LALT | RALT | RGUI | LGUI))) && (((key == KEY_F12) && ((!is_x86() && !is_archie()) || (get_key_mod() & (RGUI | LGUI)))) || key == KEY_MENU)) menu_key_set(KEY_F12);
else if (osd_is_visible)
{
if (press == 1) menu_key_set(key);
}
else
{
if (((code & EMU_SWITCH_1) || ((code & EMU_SWITCH_2) && !use_ps2ctl && !is_archie_core())) && !is_menu_core())
if (((code & EMU_SWITCH_1) || ((code & EMU_SWITCH_2) && !use_ps2ctl && !is_archie())) && !is_menu())
{
if (press == 1)
{

View File

@@ -76,6 +76,12 @@
#define UIO_CD_SET 0x35
#define UIO_INFO_GET 0x36
#define UIO_SETWIDTH 0x37 // Set max scaled horizontal resolution
#define UIO_SETSYNC 0x38
#define ST_WRITE_MEMORY 0x3A
#define ST_READ_MEMORY 0x3B
#define ST_ACK_DMA 0x3C
#define ST_NAK_DMA 0x3D
#define ST_GET_DMASTATE 0x3E
// codes as used by 8bit for file loading from OSD
#define UIO_FILE_TX 0x53
@@ -285,15 +291,17 @@ void diskled_on();
char is_minimig();
char is_sharpmz();
char is_menu_core();
char is_x86_core();
char is_snes_core();
char is_neogeo_core();
char is_megacd_core();
char is_archie_core();
char is_gba_core();
char is_menu();
char is_x86();
char is_snes();
char is_neogeo();
char is_megacd();
char is_archie();
char is_gba();
char is_c64();
char is_st();
#define HomeDir (is_menu_core() ? "Scripts" : user_io_get_core_path())
#define CoreName (is_menu_core() ? "Scripts" : user_io_get_core_name())
#define HomeDir (is_menu() ? "Scripts" : user_io_get_core_path())
#define CoreName (is_menu() ? "Scripts" : user_io_get_core_name())
#endif // USER_IO_H

View File

@@ -450,7 +450,7 @@ static void set_video(vmode_custom_t *v, double Fpix)
for (int i = 9; i < 21; i++)
{
printf("0x%X, ", v_cur.item[i]);
if (i & 1) spi_w(v_cur.item[i] | ((i == 9 && Fpix && cfg.vsync_adjust == 2 && !is_menu_core()) ? 0x8000 : 0));
if (i & 1) spi_w(v_cur.item[i] | ((i == 9 && Fpix && cfg.vsync_adjust == 2 && !is_menu()) ? 0x8000 : 0));
else
{
spi_w(v_cur.item[i]);
@@ -604,7 +604,7 @@ void video_mode_load()
static int api1_5 = 0;
int hasAPI1_5()
{
return api1_5 || is_menu_core();
return api1_5 || is_menu();
}
static uint32_t show_video_info(int force)
@@ -706,7 +706,7 @@ static uint32_t show_video_info(int force)
void video_mode_adjust()
{
uint32_t vtime = show_video_info(0);
if (vtime && cfg.vsync_adjust && !is_menu_core())
if (vtime && cfg.vsync_adjust && !is_menu())
{
printf("\033[1;33madjust_video_mode(%u): vsync_adjust=%d", vtime, cfg.vsync_adjust);
@@ -785,7 +785,7 @@ void video_fb_enable(int enable, int n)
int res = spi_uio_cmd_cont(UIO_SET_FBUF);
if (res)
{
if (is_menu_core() && !enable && menu_bg)
if (is_menu() && !enable && menu_bg)
{
enable = 1;
n = menu_bgn;
@@ -842,13 +842,13 @@ void video_fb_enable(int enable, int n)
DisableIO();
if (cfg.direct_video) set_vga_fb(enable);
if (is_menu_core()) user_io_8bit_set_status((fb_enabled && !fb_num) ? 0x160 : 0, 0x1E0);
if (is_menu()) user_io_8bit_set_status((fb_enabled && !fb_num) ? 0x160 : 0, 0x1E0);
}
}
int video_fb_state()
{
if (is_menu_core())
if (is_menu())
{
return fb_enabled && !fb_num;
}