trunk/src/emu/bus/rs232/rs232.h
| r242806 | r242807 | |
| 41 | 41 | |
| 42 | 42 | #define MCFG_RS232_BAUD(_tag, _default_baud, _description, _class, _write_line) \ |
| 43 | 43 | PORT_START(_tag) \ |
| 44 | | PORT_CONFNAME(0xff, _default_baud, _description) PORT_DEVICE PORT_WRITE_LINE_DEVICE_MEMBER(DEVICE_SELF, _class, _write_line) \ |
| 44 | PORT_CONFNAME(0xff, _default_baud, _description) PORT_WRITE_LINE_DEVICE_MEMBER(DEVICE_SELF, _class, _write_line) \ |
| 45 | 45 | PORT_CONFSETTING( RS232_BAUD_110, "110") \ |
| 46 | 46 | PORT_CONFSETTING( RS232_BAUD_150, "150") \ |
| 47 | 47 | PORT_CONFSETTING( RS232_BAUD_300, "300") \ |
| r242806 | r242807 | |
| 62 | 62 | |
| 63 | 63 | #define MCFG_RS232_STARTBITS(_tag, _default_startbits, _description, _class, _write_line) \ |
| 64 | 64 | PORT_START(_tag) \ |
| 65 | | PORT_CONFNAME(0xff, _default_startbits, _description) PORT_DEVICE PORT_WRITE_LINE_DEVICE_MEMBER(DEVICE_SELF, _class, _write_line) \ |
| 65 | PORT_CONFNAME(0xff, _default_startbits, _description) PORT_WRITE_LINE_DEVICE_MEMBER(DEVICE_SELF, _class, _write_line) \ |
| 66 | 66 | PORT_CONFSETTING( RS232_STARTBITS_0, "0") \ |
| 67 | 67 | PORT_CONFSETTING( RS232_STARTBITS_1, "1") |
| 68 | 68 | |
| r242806 | r242807 | |
| 73 | 73 | |
| 74 | 74 | #define MCFG_RS232_DATABITS(_tag, _default_databits, _description, _class, _write_line) \ |
| 75 | 75 | PORT_START(_tag) \ |
| 76 | | PORT_CONFNAME(0xff, _default_databits, _description) PORT_DEVICE PORT_WRITE_LINE_DEVICE_MEMBER(DEVICE_SELF, _class, _write_line) \ |
| 76 | PORT_CONFNAME(0xff, _default_databits, _description) PORT_WRITE_LINE_DEVICE_MEMBER(DEVICE_SELF, _class, _write_line) \ |
| 77 | 77 | PORT_CONFSETTING( RS232_DATABITS_5, "5") \ |
| 78 | 78 | PORT_CONFSETTING( RS232_DATABITS_6, "6") \ |
| 79 | 79 | PORT_CONFSETTING( RS232_DATABITS_7, "7") \ |
| r242806 | r242807 | |
| 87 | 87 | |
| 88 | 88 | #define MCFG_RS232_PARITY(_tag, _default_parity, _description, _class, _write_line) \ |
| 89 | 89 | PORT_START(_tag) \ |
| 90 | | PORT_CONFNAME(0xff, _default_parity, "Parity") PORT_DEVICE PORT_WRITE_LINE_DEVICE_MEMBER(DEVICE_SELF, _class, _write_line) \ |
| 90 | PORT_CONFNAME(0xff, _default_parity, "Parity") PORT_WRITE_LINE_DEVICE_MEMBER(DEVICE_SELF, _class, _write_line) \ |
| 91 | 91 | PORT_CONFSETTING( RS232_PARITY_NONE, "None") \ |
| 92 | 92 | PORT_CONFSETTING( RS232_PARITY_ODD, "Odd") \ |
| 93 | 93 | PORT_CONFSETTING( RS232_PARITY_EVEN, "Even") \ |
| r242806 | r242807 | |
| 101 | 101 | |
| 102 | 102 | #define MCFG_RS232_STOPBITS(_tag, _default_stopbits, _description, _class, _write_line) \ |
| 103 | 103 | PORT_START(_tag) \ |
| 104 | | PORT_CONFNAME(0xff, 0x01, _description) PORT_DEVICE PORT_WRITE_LINE_DEVICE_MEMBER(DEVICE_SELF, _class, _write_line) \ |
| 104 | PORT_CONFNAME(0xff, 0x01, _description) PORT_WRITE_LINE_DEVICE_MEMBER(DEVICE_SELF, _class, _write_line) \ |
| 105 | 105 | PORT_CONFSETTING( RS232_STOPBITS_0, "0") \ |
| 106 | 106 | PORT_CONFSETTING( RS232_STOPBITS_1, "1") \ |
| 107 | 107 | PORT_CONFSETTING( RS232_STOPBITS_1_5, "1.5") \ |
trunk/src/emu/bus/sms_ctrl/joypad.c
| r242806 | r242807 | |
| 20 | 20 | |
| 21 | 21 | static INPUT_PORTS_START( sms_joypad ) |
| 22 | 22 | PORT_START("JOYPAD") |
| 23 | | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_DEVICE |
| 24 | | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_DEVICE |
| 25 | | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_DEVICE |
| 26 | | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_DEVICE |
| 27 | | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNUSED ) // Vcc |
| 28 | | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_DEVICE // TL |
| 29 | | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNUSED ) // TH |
| 30 | | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_DEVICE // TR |
| 23 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY |
| 24 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY |
| 25 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY |
| 26 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY |
| 27 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNUSED ) // Vcc |
| 28 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 ) // TL |
| 29 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNUSED ) // TH |
| 30 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON2 ) // TR |
| 31 | 31 | INPUT_PORTS_END |
| 32 | 32 | |
| 33 | 33 | |
trunk/src/emu/bus/sms_ctrl/lphaser.c
| r242806 | r242807 | |
| 38 | 38 | |
| 39 | 39 | static INPUT_PORTS_START( sms_light_phaser ) |
| 40 | 40 | PORT_START("CTRL_PORT") |
| 41 | | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_DEVICE // TL (trigger) |
| 42 | | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SPECIAL ) PORT_DEVICE PORT_CUSTOM_MEMBER(DEVICE_SELF, sms_light_phaser_device, th_pin_r, NULL) |
| 41 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 ) // TL (trigger) |
| 42 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, sms_light_phaser_device, th_pin_r, NULL) |
| 43 | 43 | PORT_BIT( 0x9f, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 44 | 44 | |
| 45 | 45 | PORT_START("LPHASER_X") |
| 46 | | PORT_BIT( 0xff, 0x00, IPT_LIGHTGUN_X) PORT_DEVICE PORT_CROSSHAIR(X, 1.0, 0.0, 0) PORT_SENSITIVITY(50) PORT_KEYDELTA(15) PORT_CHANGED_MEMBER(DEVICE_SELF, sms_light_phaser_device, position_changed, 0) |
| 46 | PORT_BIT( 0xff, 0x00, IPT_LIGHTGUN_X) PORT_CROSSHAIR(X, 1.0, 0.0, 0) PORT_SENSITIVITY(50) PORT_KEYDELTA(15) PORT_CHANGED_MEMBER(DEVICE_SELF, sms_light_phaser_device, position_changed, 0) |
| 47 | 47 | |
| 48 | 48 | PORT_START("LPHASER_Y") |
| 49 | | PORT_BIT( 0xff, 0x00, IPT_LIGHTGUN_Y) PORT_DEVICE PORT_CROSSHAIR(Y, 1.0, 0.0, 0) PORT_SENSITIVITY(50) PORT_KEYDELTA(15) PORT_CHANGED_MEMBER(DEVICE_SELF, sms_light_phaser_device, position_changed, 0) |
| 49 | PORT_BIT( 0xff, 0x00, IPT_LIGHTGUN_Y) PORT_CROSSHAIR(Y, 1.0, 0.0, 0) PORT_SENSITIVITY(50) PORT_KEYDELTA(15) PORT_CHANGED_MEMBER(DEVICE_SELF, sms_light_phaser_device, position_changed, 0) |
| 50 | 50 | INPUT_PORTS_END |
| 51 | 51 | |
| 52 | 52 | |
trunk/src/emu/bus/sms_ctrl/sports.c
| r242806 | r242807 | |
| 71 | 71 | |
| 72 | 72 | static INPUT_PORTS_START( sms_sports_pad ) |
| 73 | 73 | PORT_START("SPORTS_IN") |
| 74 | | PORT_BIT( 0x0f, IP_ACTIVE_LOW, IPT_SPECIAL ) PORT_DEVICE PORT_CUSTOM_MEMBER(DEVICE_SELF, sms_sports_pad_device, dir_pins_r, NULL) // Directional pins |
| 74 | PORT_BIT( 0x0f, IP_ACTIVE_LOW, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, sms_sports_pad_device, dir_pins_r, NULL) // Directional pins |
| 75 | 75 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNUSED ) // Vcc |
| 76 | | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_DEVICE // TL (Button 1) |
| 77 | | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SPECIAL ) PORT_DEVICE PORT_CUSTOM_MEMBER(DEVICE_SELF, sms_sports_pad_device, th_pin_r, NULL) |
| 78 | | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_DEVICE // TR (Button 2) |
| 76 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 ) // TL (Button 1) |
| 77 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, sms_sports_pad_device, th_pin_r, NULL) |
| 78 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON2 ) // TR (Button 2) |
| 79 | 79 | |
| 80 | 80 | PORT_START("SPORTS_OUT") |
| 81 | 81 | PORT_BIT( 0x0f, IP_ACTIVE_LOW, IPT_UNUSED ) // Directional pins |
| 82 | 82 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNUSED ) // Vcc |
| 83 | 83 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNUSED ) // TL (Button 1) |
| 84 | | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_OUTPUT ) PORT_DEVICE PORT_CHANGED_MEMBER(DEVICE_SELF, sms_sports_pad_device, th_pin_w, NULL) |
| 84 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_OUTPUT ) PORT_CHANGED_MEMBER(DEVICE_SELF, sms_sports_pad_device, th_pin_w, NULL) |
| 85 | 85 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED ) // TR (Button 2) |
| 86 | 86 | |
| 87 | 87 | PORT_START("SPORTS_X") /* Sports Pad X axis */ |
| 88 | | PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_X ) PORT_DEVICE PORT_SENSITIVITY(50) PORT_KEYDELTA(40) PORT_RESET PORT_REVERSE |
| 88 | PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_X ) PORT_SENSITIVITY(50) PORT_KEYDELTA(40) PORT_RESET PORT_REVERSE |
| 89 | 89 | |
| 90 | 90 | PORT_START("SPORTS_Y") /* Sports Pad Y axis */ |
| 91 | | PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_Y ) PORT_DEVICE PORT_SENSITIVITY(50) PORT_KEYDELTA(40) PORT_RESET PORT_REVERSE |
| 91 | PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_Y ) PORT_SENSITIVITY(50) PORT_KEYDELTA(40) PORT_RESET PORT_REVERSE |
| 92 | 92 | INPUT_PORTS_END |
| 93 | 93 | |
| 94 | 94 | |
trunk/src/emu/bus/sms_ctrl/sportsjp.c
| r242806 | r242807 | |
| 53 | 53 | |
| 54 | 54 | static INPUT_PORTS_START( sms_sports_pad_jp ) |
| 55 | 55 | PORT_START("SPORTS_JP_IN") |
| 56 | | PORT_BIT( 0x0f, IP_ACTIVE_LOW, IPT_SPECIAL ) PORT_DEVICE PORT_CUSTOM_MEMBER(DEVICE_SELF, sms_sports_pad_jp_device, dir_pins_r, NULL) // Directional pins |
| 56 | PORT_BIT( 0x0f, IP_ACTIVE_LOW, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, sms_sports_pad_jp_device, dir_pins_r, NULL) // Directional pins |
| 57 | 57 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNUSED ) // Vcc |
| 58 | | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_DEVICE // TL (Button 1) |
| 58 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 ) // TL (Button 1) |
| 59 | 59 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNUSED ) // TH |
| 60 | | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_DEVICE // TR (Button 2) |
| 60 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON2 ) // TR (Button 2) |
| 61 | 61 | |
| 62 | 62 | PORT_START("SPORTS_JP_X") /* Sports Pad X axis */ |
| 63 | | PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_X ) PORT_DEVICE PORT_SENSITIVITY(50) PORT_KEYDELTA(40) |
| 63 | PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_X ) PORT_SENSITIVITY(50) PORT_KEYDELTA(40) |
| 64 | 64 | |
| 65 | 65 | PORT_START("SPORTS_JP_Y") /* Sports Pad Y axis */ |
| 66 | | PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_Y ) PORT_DEVICE PORT_SENSITIVITY(50) PORT_KEYDELTA(40) |
| 66 | PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_Y ) PORT_SENSITIVITY(50) PORT_KEYDELTA(40) |
| 67 | 67 | INPUT_PORTS_END |
| 68 | 68 | |
| 69 | 69 | |
trunk/src/emu/ioport.h
| r242806 | r242807 | |
| 992 | 992 | friend class dynamic_field; |
| 993 | 993 | |
| 994 | 994 | // flags for ioport_fields |
| 995 | | static const int FIELD_FLAG_UNUSED = 0x0001; // set if this field is unused but relevant to other games on the same hw |
| 996 | | static const int FIELD_FLAG_COCKTAIL = 0x0002; // set if this field is relevant only for cocktail cabinets |
| 997 | | static const int FIELD_FLAG_TOGGLE = 0x0004; // set if this field should behave as a toggle |
| 998 | | static const int FIELD_FLAG_ROTATED = 0x0008; // set if this field represents a rotated control |
| 999 | | static const int FIELD_FLAG_DEVICE = 0x0010; // set if this field is used only in a device |
| 1000 | | static const int ANALOG_FLAG_REVERSE = 0x0020; // analog only: reverse the sense of the axis |
| 1001 | | static const int ANALOG_FLAG_RESET = 0x0040; // analog only: always preload in->default for relative axes, returning only deltas |
| 1002 | | static const int ANALOG_FLAG_WRAPS = 0x0080; // analog only: positional count wraps around |
| 1003 | | static const int ANALOG_FLAG_INVERT = 0x0100; // analog only: bitwise invert bits |
| 995 | static const int FIELD_FLAG_UNUSED = 0x01; // set if this field is unused but relevant to other games on the same hw |
| 996 | static const int FIELD_FLAG_COCKTAIL = 0x02; // set if this field is relevant only for cocktail cabinets |
| 997 | static const int FIELD_FLAG_TOGGLE = 0x04; // set if this field should behave as a toggle |
| 998 | static const int FIELD_FLAG_ROTATED = 0x08; // set if this field represents a rotated control |
| 999 | static const int ANALOG_FLAG_REVERSE = 0x10; // analog only: reverse the sense of the axis |
| 1000 | static const int ANALOG_FLAG_RESET = 0x20; // analog only: always preload in->default for relative axes, returning only deltas |
| 1001 | static const int ANALOG_FLAG_WRAPS = 0x40; // analog only: positional count wraps around |
| 1002 | static const int ANALOG_FLAG_INVERT = 0x80; // analog only: bitwise invert bits |
| 1004 | 1003 | |
| 1005 | 1004 | public: |
| 1006 | 1005 | // construction/destruction |
| r242806 | r242807 | |
| 1028 | 1027 | bool cocktail() const { return ((m_flags & FIELD_FLAG_COCKTAIL) != 0); } |
| 1029 | 1028 | bool toggle() const { return ((m_flags & FIELD_FLAG_TOGGLE) != 0); } |
| 1030 | 1029 | bool rotated() const { return ((m_flags & FIELD_FLAG_ROTATED) != 0); } |
| 1031 | | bool used_in_device() const { return ((m_flags & FIELD_FLAG_DEVICE) != 0); } |
| 1032 | 1030 | bool analog_reverse() const { return ((m_flags & ANALOG_FLAG_REVERSE) != 0); } |
| 1033 | 1031 | bool analog_reset() const { return ((m_flags & ANALOG_FLAG_RESET) != 0); } |
| 1034 | 1032 | bool analog_wraps() const { return ((m_flags & ANALOG_FLAG_WRAPS) != 0); } |
| r242806 | r242807 | |
| 1491 | 1489 | void field_set_way(int way) const { m_curfield->m_way = way; } |
| 1492 | 1490 | void field_set_rotated() const { m_curfield->m_flags |= ioport_field::FIELD_FLAG_ROTATED; } |
| 1493 | 1491 | void field_set_name(const char *name) const { m_curfield->m_name = string_from_token(name); } |
| 1494 | | void field_set_device() const { m_curfield->m_flags |= ioport_field::FIELD_FLAG_DEVICE; } |
| 1495 | 1492 | void field_set_player(int player) const { m_curfield->m_player = player - 1; } |
| 1496 | 1493 | void field_set_cocktail() const { m_curfield->m_flags |= ioport_field::FIELD_FLAG_COCKTAIL; field_set_player(2); } |
| 1497 | 1494 | void field_set_toggle() const { m_curfield->m_flags |= ioport_field::FIELD_FLAG_TOGGLE; } |
| r242806 | r242807 | |
| 1627 | 1624 | #define PORT_NAME(_name) \ |
| 1628 | 1625 | configurer.field_set_name(_name); |
| 1629 | 1626 | |
| 1630 | | #define PORT_DEVICE \ |
| 1631 | | configurer.field_set_device(); |
| 1632 | | |
| 1633 | 1627 | #define PORT_PLAYER(_player) \ |
| 1634 | 1628 | configurer.field_set_player(_player); |
| 1635 | 1629 | |
trunk/src/emu/ui/miscmenu.c
| r242806 | r242807 | |
| 510 | 510 | item->sortorder = sortorder * 4 + suborder[seqtype]; |
| 511 | 511 | item->type = ioport_manager::type_is_analog(entry->type()) ? (INPUT_TYPE_ANALOG + seqtype) : INPUT_TYPE_DIGITAL; |
| 512 | 512 | item->name = entry->name(); |
| 513 | | item->owner_name = NULL; |
| 514 | 513 | item->next = itemlist; |
| 515 | 514 | itemlist = item; |
| 516 | 515 | |
| r242806 | r242807 | |
| 584 | 583 | item->sortorder = sortorder + suborder[seqtype]; |
| 585 | 584 | item->type = field->is_analog() ? (INPUT_TYPE_ANALOG + seqtype) : INPUT_TYPE_DIGITAL; |
| 586 | 585 | item->name = name; |
| 587 | | item->owner_name = field->used_in_device() ? (field->device().tag() + 1) : NULL; |
| 588 | 586 | item->next = itemlist; |
| 589 | 587 | itemlist = item; |
| 590 | 588 | |
| r242806 | r242807 | |
| 791 | 789 | /* generate the name of the item itself, based off the base name and the type */ |
| 792 | 790 | item = itemarray[curitem]; |
| 793 | 791 | assert(nameformat[item->type] != NULL); |
| 794 | | if (item->owner_name) |
| 795 | | { |
| 796 | | text.printf("[%s] ", item->owner_name); |
| 797 | | text.catprintf(nameformat[item->type], item->name); |
| 798 | | } |
| 799 | | else |
| 800 | | text.printf(nameformat[item->type], item->name); |
| 792 | text.printf(nameformat[item->type], item->name); |
| 801 | 793 | |
| 802 | 794 | /* if we're polling this item, use some spaces with left/right arrows */ |
| 803 | 795 | if (pollingref == item->ref) |
| r242806 | r242807 | |
| 929 | 921 | if (field->type() == type && field->enabled()) |
| 930 | 922 | { |
| 931 | 923 | UINT32 flags = 0; |
| 932 | | astring name; |
| 933 | 924 | |
| 934 | 925 | /* set the left/right flags appropriately */ |
| 935 | 926 | if (field->has_previous_setting()) |
| r242806 | r242807 | |
| 938 | 929 | flags |= MENU_FLAG_RIGHT_ARROW; |
| 939 | 930 | |
| 940 | 931 | /* add the menu item */ |
| 941 | | if (field->used_in_device()) |
| 942 | | name.cpy("[").cat(field->device().tag() + 1).cat("] ").cat(field->name()); |
| 943 | | else |
| 944 | | name.cpy(field->name()); |
| 932 | item_append(field->name(), field->setting_name(), flags, (void *)field); |
| 945 | 933 | |
| 946 | | item_append(name.cstr(), field->setting_name(), flags, (void *)field); |
| 947 | | |
| 948 | 934 | /* for DIP switches, build up the model */ |
| 949 | 935 | if (type == IPT_DIPSWITCH && field->first_diplocation() != NULL) |
| 950 | 936 | { |
| r242806 | r242807 | |
| 1231 | 1217 | { |
| 1232 | 1218 | analog_item_data *data; |
| 1233 | 1219 | UINT32 flags = 0; |
| 1234 | | astring name; |
| 1235 | | if (field->used_in_device()) |
| 1236 | | name.cpy("[").cat(field->device().tag() + 1).cat("] ").cat(field->name()); |
| 1237 | | else |
| 1238 | | name.cpy(field->name()); |
| 1239 | | |
| 1220 | |
| 1240 | 1221 | /* allocate a data item for tracking what this menu item refers to */ |
| 1241 | 1222 | data = (analog_item_data *)m_pool_alloc(sizeof(*data)); |
| 1242 | 1223 | data->field = field; |
| r242806 | r242807 | |
| 1247 | 1228 | { |
| 1248 | 1229 | default: |
| 1249 | 1230 | case ANALOG_ITEM_KEYSPEED: |
| 1250 | | text.printf("%s Digital Speed", name.cstr()); |
| 1231 | text.printf("%s Digital Speed", field->name()); |
| 1251 | 1232 | subtext.printf("%d", settings.delta); |
| 1252 | 1233 | data->min = 0; |
| 1253 | 1234 | data->max = 255; |
| r242806 | r242807 | |
| 1256 | 1237 | break; |
| 1257 | 1238 | |
| 1258 | 1239 | case ANALOG_ITEM_CENTERSPEED: |
| 1259 | | text.printf("%s Autocenter Speed", name.cstr()); |
| 1240 | text.printf("%s Autocenter Speed", field->name()); |
| 1260 | 1241 | subtext.printf("%d", settings.centerdelta); |
| 1261 | 1242 | data->min = 0; |
| 1262 | 1243 | data->max = 255; |
| r242806 | r242807 | |
| 1265 | 1246 | break; |
| 1266 | 1247 | |
| 1267 | 1248 | case ANALOG_ITEM_REVERSE: |
| 1268 | | text.printf("%s Reverse", name.cstr()); |
| 1249 | text.printf("%s Reverse", field->name()); |
| 1269 | 1250 | subtext.cpy(settings.reverse ? "On" : "Off"); |
| 1270 | 1251 | data->min = 0; |
| 1271 | 1252 | data->max = 1; |
| r242806 | r242807 | |
| 1274 | 1255 | break; |
| 1275 | 1256 | |
| 1276 | 1257 | case ANALOG_ITEM_SENSITIVITY: |
| 1277 | | text.printf("%s Sensitivity", name.cstr()); |
| 1258 | text.printf("%s Sensitivity", field->name()); |
| 1278 | 1259 | subtext.printf("%d", settings.sensitivity); |
| 1279 | 1260 | data->min = 1; |
| 1280 | 1261 | data->max = 255; |
trunk/src/osd/osdcore.c
| r242806 | r242807 | |
| 1 | 1 | #include "emucore.h" |
| 2 | 2 | #include "osdcore.h" |
| 3 | | #include "portmidi/portmidi.h" |
| 4 | 3 | |
| 5 | 4 | bool g_print_verbose = false; |
| 6 | 5 | |
| r242806 | r242807 | |
| 166 | 165 | } |
| 167 | 166 | #endif |
| 168 | 167 | |
| 169 | | static const int RX_EVENT_BUF_SIZE = 512; |
| 170 | | |
| 171 | | #define MIDI_SYSEX 0xf0 |
| 172 | | #define MIDI_EOX 0xf7 |
| 173 | | |
| 174 | | struct osd_midi_device |
| 175 | | { |
| 176 | | #ifndef DISABLE_MIDI |
| 177 | | PortMidiStream *pmStream; |
| 178 | | PmEvent rx_evBuf[RX_EVENT_BUF_SIZE]; |
| 179 | | #endif |
| 180 | | UINT8 xmit_in[4]; // Pm_Messages mean we can at most have 3 residue bytes |
| 181 | | int xmit_cnt; |
| 182 | | UINT8 last_status; |
| 183 | | bool rx_sysex; |
| 184 | | }; |
| 185 | | |
| 186 | | void osd_list_midi_devices(void) |
| 187 | | { |
| 188 | | #ifndef DISABLE_MIDI |
| 189 | | int num_devs = Pm_CountDevices(); |
| 190 | | const PmDeviceInfo *pmInfo; |
| 191 | | |
| 192 | | printf("\n"); |
| 193 | | |
| 194 | | if (num_devs == 0) |
| 195 | | { |
| 196 | | printf("No MIDI ports were found\n"); |
| 197 | | return; |
| 198 | | } |
| 199 | | |
| 200 | | printf("MIDI input ports:\n"); |
| 201 | | for (int i = 0; i < num_devs; i++) |
| 202 | | { |
| 203 | | pmInfo = Pm_GetDeviceInfo(i); |
| 204 | | |
| 205 | | if (pmInfo->input) |
| 206 | | { |
| 207 | | printf("%s %s\n", pmInfo->name, (i == Pm_GetDefaultInputDeviceID()) ? "(default)" : ""); |
| 208 | | } |
| 209 | | } |
| 210 | | |
| 211 | | printf("\nMIDI output ports:\n"); |
| 212 | | for (int i = 0; i < num_devs; i++) |
| 213 | | { |
| 214 | | pmInfo = Pm_GetDeviceInfo(i); |
| 215 | | |
| 216 | | if (pmInfo->output) |
| 217 | | { |
| 218 | | printf("%s %s\n", pmInfo->name, (i == Pm_GetDefaultOutputDeviceID()) ? "(default)" : ""); |
| 219 | | } |
| 220 | | } |
| 221 | | #else |
| 222 | | printf("\nMIDI is not supported in this build\n"); |
| 223 | | #endif |
| 224 | | } |
| 225 | | |
| 226 | | osd_midi_device *osd_open_midi_input(const char *devname) |
| 227 | | { |
| 228 | | #ifndef DISABLE_MIDI |
| 229 | | int num_devs = Pm_CountDevices(); |
| 230 | | int found_dev = -1; |
| 231 | | const PmDeviceInfo *pmInfo; |
| 232 | | PortMidiStream *stm; |
| 233 | | osd_midi_device *ret; |
| 234 | | |
| 235 | | if (!strcmp("default", devname)) |
| 236 | | { |
| 237 | | found_dev = Pm_GetDefaultInputDeviceID(); |
| 238 | | } |
| 239 | | else |
| 240 | | { |
| 241 | | for (int i = 0; i < num_devs; i++) |
| 242 | | { |
| 243 | | pmInfo = Pm_GetDeviceInfo(i); |
| 244 | | |
| 245 | | if (pmInfo->input) |
| 246 | | { |
| 247 | | if (!strcmp(devname, pmInfo->name)) |
| 248 | | { |
| 249 | | found_dev = i; |
| 250 | | break; |
| 251 | | } |
| 252 | | } |
| 253 | | } |
| 254 | | } |
| 255 | | |
| 256 | | if (found_dev >= 0) |
| 257 | | { |
| 258 | | if (Pm_OpenInput(&stm, found_dev, NULL, RX_EVENT_BUF_SIZE, NULL, NULL) == pmNoError) |
| 259 | | { |
| 260 | | ret = (osd_midi_device *)osd_malloc(sizeof(osd_midi_device)); |
| 261 | | memset(ret, 0, sizeof(osd_midi_device)); |
| 262 | | ret->pmStream = stm; |
| 263 | | return ret; |
| 264 | | } |
| 265 | | else |
| 266 | | { |
| 267 | | printf("Couldn't open PM device\n"); |
| 268 | | return NULL; |
| 269 | | } |
| 270 | | } |
| 271 | | else |
| 272 | | { |
| 273 | | return NULL; |
| 274 | | } |
| 275 | | #else |
| 276 | | return NULL; |
| 277 | | #endif |
| 278 | | } |
| 279 | | |
| 280 | | osd_midi_device *osd_open_midi_output(const char *devname) |
| 281 | | { |
| 282 | | #ifndef DISABLE_MIDI |
| 283 | | int num_devs = Pm_CountDevices(); |
| 284 | | int found_dev = -1; |
| 285 | | const PmDeviceInfo *pmInfo; |
| 286 | | PortMidiStream *stm; |
| 287 | | osd_midi_device *ret; |
| 288 | | |
| 289 | | if (!strcmp("default", devname)) |
| 290 | | { |
| 291 | | found_dev = Pm_GetDefaultOutputDeviceID(); |
| 292 | | } |
| 293 | | else |
| 294 | | { |
| 295 | | for (int i = 0; i < num_devs; i++) |
| 296 | | { |
| 297 | | pmInfo = Pm_GetDeviceInfo(i); |
| 298 | | |
| 299 | | if (pmInfo->output) |
| 300 | | { |
| 301 | | if (!strcmp(devname, pmInfo->name)) |
| 302 | | { |
| 303 | | found_dev = i; |
| 304 | | break; |
| 305 | | } |
| 306 | | } |
| 307 | | } |
| 308 | | } |
| 309 | | |
| 310 | | if (found_dev >= 0) |
| 311 | | { |
| 312 | | if (Pm_OpenOutput(&stm, found_dev, NULL, 100, NULL, NULL, 0) == pmNoError) |
| 313 | | { |
| 314 | | ret = (osd_midi_device *)osd_malloc(sizeof(osd_midi_device)); |
| 315 | | memset(ret, 0, sizeof(osd_midi_device)); |
| 316 | | ret->pmStream = stm; |
| 317 | | return ret; |
| 318 | | } |
| 319 | | else |
| 320 | | { |
| 321 | | printf("Couldn't open PM device\n"); |
| 322 | | return NULL; |
| 323 | | } |
| 324 | | } |
| 325 | | else |
| 326 | | { |
| 327 | | return NULL; |
| 328 | | } |
| 329 | | #endif |
| 330 | | return NULL; |
| 331 | | } |
| 332 | | |
| 333 | | void osd_close_midi_channel(osd_midi_device *dev) |
| 334 | | { |
| 335 | | #ifndef DISABLE_MIDI |
| 336 | | Pm_Close(dev->pmStream); |
| 337 | | osd_free(dev); |
| 338 | | #endif |
| 339 | | } |
| 340 | | |
| 341 | | bool osd_poll_midi_channel(osd_midi_device *dev) |
| 342 | | { |
| 343 | | #ifndef DISABLE_MIDI |
| 344 | | PmError chk = Pm_Poll(dev->pmStream); |
| 345 | | |
| 346 | | return (chk == pmGotData) ? true : false; |
| 347 | | #else |
| 348 | | return false; |
| 349 | | #endif |
| 350 | | } |
| 351 | | |
| 352 | | int osd_read_midi_channel(osd_midi_device *dev, UINT8 *pOut) |
| 353 | | { |
| 354 | | #ifndef DISABLE_MIDI |
| 355 | | int msgsRead = Pm_Read(dev->pmStream, dev->rx_evBuf, RX_EVENT_BUF_SIZE); |
| 356 | | int bytesOut = 0; |
| 357 | | |
| 358 | | if (msgsRead <= 0) |
| 359 | | { |
| 360 | | return 0; |
| 361 | | } |
| 362 | | |
| 363 | | for (int msg = 0; msg < msgsRead; msg++) |
| 364 | | { |
| 365 | | UINT8 status = Pm_MessageStatus(dev->rx_evBuf[msg].message); |
| 366 | | |
| 367 | | if (dev->rx_sysex) |
| 368 | | { |
| 369 | | if (status & 0x80) // sys real-time imposing on us? |
| 370 | | { |
| 371 | | if ((status == 0xf2) || (status == 0xf3)) |
| 372 | | { |
| 373 | | *pOut++ = status; |
| 374 | | *pOut++ = Pm_MessageData1(dev->rx_evBuf[msg].message); |
| 375 | | *pOut++ = Pm_MessageData2(dev->rx_evBuf[msg].message); |
| 376 | | bytesOut += 3; |
| 377 | | } |
| 378 | | else |
| 379 | | { |
| 380 | | *pOut++ = status; |
| 381 | | bytesOut++; |
| 382 | | if (status == MIDI_EOX) |
| 383 | | { |
| 384 | | dev->rx_sysex = false; |
| 385 | | } |
| 386 | | } |
| 387 | | } |
| 388 | | else // shift out the sysex bytes |
| 389 | | { |
| 390 | | for (int i = 0; i < 4; i++) |
| 391 | | { |
| 392 | | UINT8 byte = dev->rx_evBuf[msg].message & 0xff; |
| 393 | | *pOut++ = byte; |
| 394 | | bytesOut++; |
| 395 | | if (byte == MIDI_EOX) |
| 396 | | { |
| 397 | | dev->rx_sysex = false; |
| 398 | | break; |
| 399 | | } |
| 400 | | dev->rx_evBuf[msg].message >>= 8; |
| 401 | | } |
| 402 | | } |
| 403 | | } |
| 404 | | else |
| 405 | | { |
| 406 | | switch ((status>>4) & 0xf) |
| 407 | | { |
| 408 | | case 0xc: // 2-byte messages |
| 409 | | case 0xd: |
| 410 | | *pOut++ = status; |
| 411 | | *pOut++ = Pm_MessageData1(dev->rx_evBuf[msg].message); |
| 412 | | bytesOut += 2; |
| 413 | | break; |
| 414 | | |
| 415 | | case 0xf: // system common |
| 416 | | switch (status & 0xf) |
| 417 | | { |
| 418 | | case 0: // System Exclusive |
| 419 | | { |
| 420 | | *pOut++ = status; // this should be OK: the shortest legal sysex is F0 tt dd F7, I believe |
| 421 | | *pOut++ = (dev->rx_evBuf[msg].message>>8) & 0xff; |
| 422 | | *pOut++ = (dev->rx_evBuf[msg].message>>16) & 0xff; |
| 423 | | UINT8 last = *pOut++ = (dev->rx_evBuf[msg].message>>24) & 0xff; |
| 424 | | bytesOut += 4; |
| 425 | | dev->rx_sysex = (last != MIDI_EOX); |
| 426 | | break; |
| 427 | | } |
| 428 | | |
| 429 | | case 7: // End of System Exclusive |
| 430 | | *pOut++ = status; |
| 431 | | bytesOut += 1; |
| 432 | | dev->rx_sysex = false; |
| 433 | | break; |
| 434 | | |
| 435 | | case 2: // song pos |
| 436 | | case 3: // song select |
| 437 | | *pOut++ = status; |
| 438 | | *pOut++ = Pm_MessageData1(dev->rx_evBuf[msg].message); |
| 439 | | *pOut++ = Pm_MessageData2(dev->rx_evBuf[msg].message); |
| 440 | | bytesOut += 3; |
| 441 | | break; |
| 442 | | |
| 443 | | default: // all other defined Fx messages are 1 byte |
| 444 | | break; |
| 445 | | } |
| 446 | | break; |
| 447 | | |
| 448 | | default: |
| 449 | | *pOut++ = status; |
| 450 | | *pOut++ = Pm_MessageData1(dev->rx_evBuf[msg].message); |
| 451 | | *pOut++ = Pm_MessageData2(dev->rx_evBuf[msg].message); |
| 452 | | bytesOut += 3; |
| 453 | | break; |
| 454 | | } |
| 455 | | } |
| 456 | | } |
| 457 | | |
| 458 | | return bytesOut; |
| 459 | | #else |
| 460 | | return 0; |
| 461 | | #endif |
| 462 | | } |
| 463 | | |
| 464 | | void osd_write_midi_channel(osd_midi_device *dev, UINT8 data) |
| 465 | | { |
| 466 | | #ifndef DISABLE_MIDI |
| 467 | | int bytes_needed = 0; |
| 468 | | PmEvent ev; |
| 469 | | ev.timestamp = 0; // use the current time |
| 470 | | |
| 471 | | // printf("write: %02x (%d)\n", data, dev->xmit_cnt); |
| 472 | | |
| 473 | | // reject data bytes when no valid status exists |
| 474 | | if ((dev->last_status == 0) && !(data & 0x80)) |
| 475 | | { |
| 476 | | dev->xmit_cnt = 0; |
| 477 | | return; |
| 478 | | } |
| 479 | | |
| 480 | | if (dev->xmit_cnt >= 4) |
| 481 | | { |
| 482 | | printf("MIDI out: packet assembly overflow, contact MAMEdev!\n"); |
| 483 | | return; |
| 484 | | } |
| 485 | | |
| 486 | | // handle sysex |
| 487 | | if (dev->last_status == MIDI_SYSEX) |
| 488 | | { |
| 489 | | // printf("sysex: %02x (%d)\n", data, dev->xmit_cnt); |
| 490 | | |
| 491 | | // if we get a status that isn't sysex, assume it's system common |
| 492 | | if ((data & 0x80) && (data != MIDI_EOX)) |
| 493 | | { |
| 494 | | // printf("common during sysex!\n"); |
| 495 | | ev.message = Pm_Message(data, 0, 0); |
| 496 | | Pm_Write(dev->pmStream, &ev, 1); |
| 497 | | return; |
| 498 | | } |
| 499 | | |
| 500 | | dev->xmit_in[dev->xmit_cnt++] = data; |
| 501 | | |
| 502 | | // if EOX or 4 bytes filled, transmit 4 bytes |
| 503 | | if ((dev->xmit_cnt == 4) || (data == MIDI_EOX)) |
| 504 | | { |
| 505 | | ev.message = dev->xmit_in[0] | (dev->xmit_in[1]<<8) | (dev->xmit_in[2]<<16) | (dev->xmit_in[3]<<24); |
| 506 | | Pm_Write(dev->pmStream, &ev, 1); |
| 507 | | dev->xmit_in[0] = dev->xmit_in[1] = dev->xmit_in[2] = dev->xmit_in[3] = 0; |
| 508 | | dev->xmit_cnt = 0; |
| 509 | | |
| 510 | | // printf("SysEx packet: %08x\n", ev.message); |
| 511 | | |
| 512 | | // if this is EOX, kill the running status |
| 513 | | if (data == MIDI_EOX) |
| 514 | | { |
| 515 | | dev->last_status = 0; |
| 516 | | } |
| 517 | | } |
| 518 | | |
| 519 | | return; |
| 520 | | } |
| 521 | | |
| 522 | | // handle running status. don't allow system real-time messages to be considered as running status. |
| 523 | | if ((dev->xmit_cnt == 0) && (data & 0x80) && (data < 0xf8)) |
| 524 | | { |
| 525 | | dev->last_status = data; |
| 526 | | } |
| 527 | | |
| 528 | | if ((dev->xmit_cnt == 0) && !(data & 0x80)) |
| 529 | | { |
| 530 | | dev->xmit_in[dev->xmit_cnt++] = dev->last_status; |
| 531 | | dev->xmit_in[dev->xmit_cnt++] = data; |
| 532 | | // printf("\trunning status: [%d] = %02x, [%d] = %02x, last_status = %02x\n", dev->xmit_cnt-2, dev->last_status, dev->xmit_cnt-1, data, dev->last_status); |
| 533 | | } |
| 534 | | else |
| 535 | | { |
| 536 | | dev->xmit_in[dev->xmit_cnt++] = data; |
| 537 | | // printf("\tNRS: [%d] = %02x\n", dev->xmit_cnt-1, data); |
| 538 | | } |
| 539 | | |
| 540 | | if ((dev->xmit_cnt == 1) && (dev->xmit_in[0] == MIDI_SYSEX)) |
| 541 | | { |
| 542 | | // printf("Start SysEx!\n"); |
| 543 | | dev->last_status = MIDI_SYSEX; |
| 544 | | return; |
| 545 | | } |
| 546 | | |
| 547 | | // are we there yet? |
| 548 | | // printf("status check: %02x\n", dev->xmit_in[0]); |
| 549 | | switch ((dev->xmit_in[0]>>4) & 0xf) |
| 550 | | { |
| 551 | | case 0xc: // 2-byte messages |
| 552 | | case 0xd: |
| 553 | | bytes_needed = 2; |
| 554 | | break; |
| 555 | | |
| 556 | | case 0xf: // system common |
| 557 | | switch (dev->xmit_in[0] & 0xf) |
| 558 | | { |
| 559 | | case 0: // System Exclusive is handled above |
| 560 | | break; |
| 561 | | |
| 562 | | case 7: // End of System Exclusive |
| 563 | | bytes_needed = 1; |
| 564 | | break; |
| 565 | | |
| 566 | | case 2: // song pos |
| 567 | | case 3: // song select |
| 568 | | bytes_needed = 3; |
| 569 | | break; |
| 570 | | |
| 571 | | default: // all other defined Fx messages are 1 byte |
| 572 | | bytes_needed = 1; |
| 573 | | break; |
| 574 | | } |
| 575 | | break; |
| 576 | | |
| 577 | | default: |
| 578 | | bytes_needed = 3; |
| 579 | | break; |
| 580 | | } |
| 581 | | |
| 582 | | if (dev->xmit_cnt == bytes_needed) |
| 583 | | { |
| 584 | | ev.message = Pm_Message(dev->xmit_in[0], dev->xmit_in[1], dev->xmit_in[2]); |
| 585 | | Pm_Write(dev->pmStream, &ev, 1); |
| 586 | | dev->xmit_cnt = 0; |
| 587 | | } |
| 588 | | |
| 589 | | #endif |
| 590 | | } |