diff --git a/config.c b/config.c index 96245c2..1805957 100644 --- a/config.c +++ b/config.c @@ -15,7 +15,7 @@ #include "config.h" #include "user_io.h" -configTYPE config; +configTYPE config = { 0 }; char configfilename[32]; char DebugMode = 0; unsigned char romkey[3072]; @@ -480,6 +480,7 @@ void ApplyConfiguration(char reloadkickstart) } ConfigVideo(config.filter.hires, config.filter.lores, config.scanlines); + ConfigAutofire(config.autofire, 0xC); } //// SaveConfiguration() //// diff --git a/menu.c b/menu.c index cf6b328..c451054 100644 --- a/menu.c +++ b/menu.c @@ -573,19 +573,20 @@ void HandleUI(void) case KEY_LALT | KEY_UPSTROKE: lalt = false; break; + /* case KEY_KP0: - if (ctrl && lalt) + if (StateKeyboardModifiers() == 5) //lAlt+lctrl { if (menustate == MENU_NONE2 || menustate == MENU_INFO) { config_autofire++; config_autofire &= 3; - ConfigAutofire(config_autofire); - if (menustate == MENU_NONE2 || menustate == MENU_INFO) - InfoMessage(config_autofire_msg[config_autofire]); + ConfigAutofire(config_autofire, 3); + InfoMessage(config_autofire_msg[config_autofire]); } } break; + */ case KEY_MENU: menu = true; @@ -1120,12 +1121,12 @@ void HandleUI(void) if (is_minimig()) { joy_bcount = 7; - strcpy(joy_bnames[0], "Red"); + strcpy(joy_bnames[0], "Red/Fire"); strcpy(joy_bnames[1], "Blue"); strcpy(joy_bnames[2], "Yellow"); strcpy(joy_bnames[3], "Green"); - strcpy(joy_bnames[4], "Right Front"); - strcpy(joy_bnames[5], "Left Front"); + strcpy(joy_bnames[4], "Right Trigger"); + strcpy(joy_bnames[5], "Left Trigger"); strcpy(joy_bnames[6], "Pause"); } start_map_setting(joy_bcount ? joy_bcount+5 : 9); @@ -2530,25 +2531,29 @@ void HandleUI(void) strcpy(s, " Turbo : "); strcat(s, config_turbo_msg[(config.cpu >> 2) & 0x03]); OsdWrite(2, s, menusub == 1, 0); + OsdWrite(3, "", 0, 0); strcpy(s, " Video : "); strcat(s, config.chipset & CONFIG_NTSC ? "NTSC" : "PAL"); - OsdWrite(3, s, menusub == 2, 0); + OsdWrite(4, s, menusub == 2, 0); strcpy(s, " Chipset : "); strcat(s, config_chipset_msg[(config.chipset >> 2) & 7]); - OsdWrite(4, s, menusub == 3, 0); + OsdWrite(5, s, menusub == 3, 0); + OsdWrite(6, "", 0, 0); strcpy(s, " CD32Pad : "); strcat(s, config_cd32pad_msg[(config.autofire >> 2) & 1]); - OsdWrite(5, s, menusub == 4, 0); - OsdWrite(6, "", 0, 0); - for (int i = 7; i < OsdGetSize() - 1; i++) OsdWrite(i, "", 0, 0); - OsdWrite(OsdGetSize() - 1, STD_EXIT, menusub == 5, 0); + OsdWrite(7, s, menusub == 4, 0); + strcpy(s, " Joy Swap : "); + strcat(s, (config.autofire & 0x8)? "ON" : "OFF"); + OsdWrite(8, s, menusub == 5, 0); + for (int i = 9; i < OsdGetSize() - 1; i++) OsdWrite(i, "", 0, 0); + OsdWrite(OsdGetSize() - 1, STD_EXIT, menusub == 6, 0); menustate = MENU_SETTINGS_CHIPSET2; break; case MENU_SETTINGS_CHIPSET2: - if (down && menusub < 5) + if (down && menusub < 6) { menusub++; menustate = MENU_SETTINGS_CHIPSET1; @@ -2607,12 +2612,17 @@ void HandleUI(void) } else if (menusub == 4) { - //config.autofire = ((((config.autofire >> 2) + 1) & 1) << 2) || (config.autofire & 3); - config.autofire = (config.autofire + 4) & 0x7; + config.autofire ^= 0x4; menustate = MENU_SETTINGS_CHIPSET1; - ConfigAutofire(config.autofire); + ConfigAutofire(config.autofire, 0x4); } else if (menusub == 5) + { + config.autofire ^= 0x8; + menustate = MENU_SETTINGS_CHIPSET1; + ConfigAutofire(config.autofire, 0x8); + } + else if (menusub == 6) { menustate = MENU_MAIN1; menusub = 6; diff --git a/osd.c b/osd.c index 228231e..2541edb 100644 --- a/osd.c +++ b/osd.c @@ -554,9 +554,11 @@ void ConfigIDE(unsigned char gayle, unsigned char master, unsigned char slave) spi_osd_cmd8(OSD_CMD_HDD, (slave ? 4 : 0) | (master ? 2 : 0) | (gayle ? 1 : 0)); } -void ConfigAutofire(unsigned char autofire) +void ConfigAutofire(unsigned char autofire, unsigned char mask) { - spi_osd_cmd8(OSD_CMD_JOY, autofire & 0x07); + uint16_t param = mask; + param = (param << 8) | autofire; + spi_osd_cmd16(OSD_CMD_JOY, param); } static unsigned char disable_menu = 0; diff --git a/osd.h b/osd.h index 3f3ece9..0e2f4df 100644 --- a/osd.h +++ b/osd.h @@ -119,7 +119,7 @@ void ConfigCPU(unsigned char cpu); void ConfigChipset(unsigned char chipset); void ConfigFloppy(unsigned char drives, unsigned char speed); void ConfigIDE(unsigned char gayle, unsigned char master, unsigned char slave); -void ConfigAutofire(unsigned char autofire); +void ConfigAutofire(unsigned char autofire, unsigned char mask); unsigned char OsdGetCtrl(void); void OsdDisableMenuButton(unsigned char disable); unsigned char GetASCIIKey(unsigned char c); diff --git a/user_io.c b/user_io.c index 23e7ce0..c33cc75 100644 --- a/user_io.c +++ b/user_io.c @@ -118,28 +118,28 @@ char *user_io_get_core_name() return core_name; } -char *user_io_get_core_name_ex() -{ - switch (user_io_core_type()) - { - case CORE_TYPE_MINIMIG2: - return "MINIMIG"; - - case CORE_TYPE_PACE: - return "PACE"; - - case CORE_TYPE_MIST: - return "ST"; - - case CORE_TYPE_ARCHIE: - return "ARCHIE"; - - case CORE_TYPE_8BIT: - return core_name; - } - - return ""; -} +char *user_io_get_core_name_ex() +{ + switch (user_io_core_type()) + { + case CORE_TYPE_MINIMIG2: + return "MINIMIG"; + + case CORE_TYPE_PACE: + return "PACE"; + + case CORE_TYPE_MIST: + return "ST"; + + case CORE_TYPE_ARCHIE: + return "ARCHIE"; + + case CORE_TYPE_8BIT: + return core_name; + } + + return ""; +} char is_menu_core() { @@ -352,47 +352,14 @@ void user_io_analog_joystick(unsigned char joystick, char valueX, char valueY) void user_io_digital_joystick(unsigned char joystick, uint16_t map) { - uint8_t state = map; - // "only" 6 joysticks are supported if (joystick >= 6) return; - // the physical joysticks (db9 ports at the right device side) - // as well as the joystick emulation are renumbered if usb joysticks - // are present in the system. The USB joystick(s) replace joystick 1 - // and 0 and the physical joysticks are "shifted up". - // Since the primary joystick is in port 1 the first usb joystick - // becomes joystick 1 and only the second one becomes joystick 0 - // (mouse port) - - StateJoySet(state, joystick == 0 ? 1 : 0); - if (joystick == 1) + if (is_minimig()) { - //StateJoyUpdateTurboStructure(0); - //map = (unsigned char) StateJoyStructureState(0) & 0xFF; - } - else if (joystick == 0) - {// WARNING: 0 is the second joystick, either USB or DB9 - //StateJoyUpdateTurboStructure(1); - //map = (unsigned char) StateJoyStructureState(1) & 0xFF; - } - - // if osd is open control it via joystick - if (osd_is_visible) - { - static const uint8_t joy2kbd[] = { - OSDCTRLMENU, OSDCTRLMENU, OSDCTRLMENU, OSDCTRLSELECT, - OSDCTRLUP, OSDCTRLDOWN, OSDCTRLLEFT, OSDCTRLRIGHT }; - - // iprintf("joy to osd\n"); - - // OsdKeySet(0x80 | usb2ami[pressed[i]]); - + if (joystick < 2) spi_uio_cmd16(UIO_JOYSTICK0 + joystick, map); return; } - // iprintf("j%d: %x\n", joystick, map); - - // atari ST handles joystick 0 and 1 through the ikbd emulated by the io controller // but only for joystick 1 and 2 if ((core_type == CORE_TYPE_MIST) && (joystick < 2)) @@ -401,16 +368,7 @@ void user_io_digital_joystick(unsigned char joystick, uint16_t map) return; } - // every other core else uses this - // (even MIST, joystick 3 and 4 were introduced later) - spi_uio_cmd16((joystick < 2) ? (UIO_JOYSTICK0 + joystick) : ((UIO_JOYSTICK2 + joystick - 2)), map); -} - -static char dig2ana(char min, char max) -{ - if (min && !max) return -128; - if (max && !min) return 127; - return 0; + spi_uio_cmd16((joystick < 2) ? (UIO_JOYSTICK0 + joystick) : (UIO_JOYSTICK2 + joystick - 2), map); } // transmit serial/rs232 data into core @@ -553,38 +511,6 @@ void user_io_eth_send_rx_frame(uint8_t *s, uint16_t len) DisableIO(); } -// the physical joysticks (db9 ports at the right device side) -// as well as the joystick emulation are renumbered if usb joysticks -// are present in the system. The USB joystick(s) replace joystick 1 -// and 0 and the physical joysticks are "shifted up". -// -// Since the primary joystick is in port 1 the first usb joystick -// becomes joystick 1 and only the second one becomes joystick 0 -// (mouse port) - -static uint8_t joystick_renumber(uint8_t j) -{ - uint8_t usb_sticks = 0; //hid_get_joysticks(); - - // no usb sticks present: no changes are being made - if (!usb_sticks) return j; - - if (j == 0) { - // if usb joysticks are present, then physical joystick 0 (mouse port) - // becomes becomes 2,3,... - j = usb_sticks + 1; - } - else { - // if one usb joystick is present, then physical joystick 1 (joystick port) - // becomes physical joystick 0 (mouse) port. If more than 1 usb joystick - // is present it becomes 2,3,... - if (usb_sticks == 1) j = 0; - else j = usb_sticks; - } - - return j; -} - // 16 byte fifo for amiga key codes to limit max key rate sent into the core #define KBD_FIFO_SIZE 16 // must be power of 2 static unsigned short kbd_fifo[KBD_FIFO_SIZE]; @@ -938,7 +864,7 @@ void user_io_poll() mouse_pos[Y] = 0; } - spi8(mouse_flags & 0x03); + spi8(mouse_flags & 0x07); DisableIO(); // reset flags @@ -1391,7 +1317,7 @@ void user_io_mouse(unsigned char b, int16_t x, int16_t y) { mouse_pos[X] += x; mouse_pos[Y] += y; - mouse_flags |= 0x80 | (b & 3); + mouse_flags |= 0x80 | (b & 7); } // 8 bit core expects ps2 like data @@ -1399,7 +1325,7 @@ void user_io_mouse(unsigned char b, int16_t x, int16_t y) { mouse_pos[X] += x; mouse_pos[Y] -= y; // ps2 y axis is reversed over usb - mouse_flags |= 0x08 | (b & 3); + mouse_flags |= 0x08 | (b & 7); } // send mouse data as mist expects it @@ -2006,7 +1932,7 @@ unsigned char user_io_ext_idx(char *name, char* ext) return 0; } -emu_mode_t user_io_get_kbdemu() -{ - return emu_mode; -} +emu_mode_t user_io_get_kbdemu() +{ + return emu_mode; +}