trunk/src/mame/machine/snes.c
| r23750 | r23751 | |
| 128 | 128 | |
| 129 | 129 | TIMER_CALLBACK_MEMBER(snes_state::snes_update_io) |
| 130 | 130 | { |
| 131 | | m_io_read(m_maincpu->space(AS_PROGRAM),0,0,0); |
| 131 | io_read(m_maincpu->space(AS_PROGRAM),0,0,0); |
| 132 | 132 | SNES_CPU_REG(HVBJOY) &= 0xfe; /* Clear busy bit */ |
| 133 | 133 | |
| 134 | 134 | m_io_timer->adjust(attotime::never); |
| r23750 | r23751 | |
| 423 | 423 | value = space.read_byte(0x7e0000 + m_wram_address++); |
| 424 | 424 | m_wram_address &= 0x1ffff; |
| 425 | 425 | return value; |
| 426 | |
| 426 | 427 | case OLDJOY1: /* Data for old NES controllers (JOYSER1) */ |
| 427 | | if (m_oldjoy1_latch & 0x1) |
| 428 | | return 0 | (snes_open_bus_r(space, 0) & 0xfc); //correct? |
| 428 | return (oldjoy1_read(m_oldjoy1_latch & 0x1) & 0x03) | (snes_open_bus_r(space, 0) & 0xfc); |
| 429 | 429 | |
| 430 | | value = m_oldjoy1_read(space,0,0); |
| 431 | | |
| 432 | | return (value & 0x03) | (snes_open_bus_r(space, 0) & 0xfc); //correct? |
| 433 | 430 | case OLDJOY2: /* Data for old NES controllers (JOYSER2) */ |
| 434 | | if (m_oldjoy1_latch & 0x1) |
| 435 | | return 0 | 0x1c | (snes_open_bus_r(space, 0) & 0xe0); //correct? |
| 431 | return (oldjoy2_read(m_oldjoy1_latch & 0x1) & 0x03) | 0x1c | (snes_open_bus_r(space, 0) & 0xe0); |
| 436 | 432 | |
| 437 | | value = m_oldjoy2_read(space,0,0); |
| 438 | | |
| 439 | | return value | 0x1c | (snes_open_bus_r(space, 0) & 0xe0); //correct? |
| 440 | 433 | case RDNMI: /* NMI flag by v-blank and version number */ |
| 441 | 434 | value = (SNES_CPU_REG(RDNMI) & 0x80) | (snes_open_bus_r(space, 0) & 0x70); |
| 442 | 435 | SNES_CPU_REG(RDNMI) &= 0x70; /* NMI flag is reset on read */ |
| r23750 | r23751 | |
| 461 | 454 | case JOY3H: /* Joypad 3 status register (high) */ |
| 462 | 455 | case JOY4L: /* Joypad 4 status register (low) */ |
| 463 | 456 | case JOY4H: /* Joypad 4 status register (high) */ |
| 464 | | if(m_is_nss && m_input_disabled) |
| 457 | if (m_is_nss && m_input_disabled) |
| 465 | 458 | return 0; |
| 466 | 459 | return SNES_CPU_REG(offset); |
| 467 | 460 | |
| 468 | 461 | case 0x4100: /* NSS Dip-Switches */ |
| 469 | | { |
| 470 | | if (m_is_nss) |
| 471 | | return ioport("DSW")->read(); |
| 472 | | |
| 473 | | return snes_open_bus_r(space, 0); |
| 474 | | } |
| 462 | if (m_is_nss) |
| 463 | return ioport("DSW")->read(); |
| 464 | break; |
| 475 | 465 | // case 0x4101: //PC: a104 - a10e - a12a //only nss_actr (DSW actually reads in word units ...) |
| 476 | 466 | |
| 477 | 467 | default: |
| r23750 | r23751 | |
| 538 | 528 | m_wram_address &= 0x1ffff; |
| 539 | 529 | return; |
| 540 | 530 | case OLDJOY1: /* Old NES joystick support */ |
| 541 | | if (((!(data & 0x1)) && (m_oldjoy1_latch & 0x1))) |
| 542 | | { |
| 543 | | m_read_idx[0] = 0; |
| 544 | | m_read_idx[1] = 0; |
| 545 | | } |
| 531 | write_joy_latch(data); |
| 546 | 532 | if (m_is_nss) |
| 547 | | { |
| 548 | 533 | m_game_over_flag = (data & 4) >> 2; |
| 549 | | } |
| 550 | | m_oldjoy1_latch = data; |
| 551 | 534 | return; |
| 552 | 535 | case OLDJOY2: /* Old NES joystick support */ |
| 553 | 536 | return; |
| r23750 | r23751 | |
| 622 | 605 | |
| 623 | 606 | } |
| 624 | 607 | |
| 608 | void snes_state::write_joy_latch(UINT8 data) |
| 609 | { |
| 610 | if (m_oldjoy1_latch == (data & 0x01)) |
| 611 | return; |
| 612 | |
| 613 | m_oldjoy1_latch = data & 0x01; |
| 614 | m_read_idx[0] = 0; |
| 615 | m_read_idx[1] = 0; |
| 616 | m_read_idx[2] = 0; |
| 617 | m_read_idx[3] = 0; |
| 618 | } |
| 619 | |
| 620 | |
| 625 | 621 | WRITE_LINE_MEMBER(snes_state::snes_extern_irq_w) |
| 626 | 622 | { |
| 627 | 623 | m_maincpu->set_input_line(G65816_LINE_IRQ, state); |
| r23750 | r23751 | |
| 943 | 939 | |
| 944 | 940 | *************************************/ |
| 945 | 941 | |
| 946 | | WRITE8_MEMBER(snes_state::nss_io_read) |
| 942 | WRITE8_MEMBER(snes_state::io_read) |
| 947 | 943 | { |
| 948 | | static const char *const portnames[2][4] = |
| 949 | | { |
| 950 | | { "SERIAL1_DATA1_L", "SERIAL1_DATA1_H", "SERIAL1_DATA2_L", "SERIAL1_DATA2_H" }, |
| 951 | | { "SERIAL2_DATA1_L", "SERIAL2_DATA1_H", "SERIAL2_DATA2_L", "SERIAL2_DATA2_H" }, |
| 952 | | }; |
| 953 | | int port; |
| 944 | static const char *const portnames[2][2] = |
| 945 | { |
| 946 | { "SERIAL1_DATA1", "SERIAL1_DATA2" }, |
| 947 | { "SERIAL2_DATA1", "SERIAL2_DATA2" } |
| 948 | }; |
| 954 | 949 | |
| 955 | | for (port = 0; port < 2; port++) |
| 950 | for (int port = 0; port < 2; port++) |
| 956 | 951 | { |
| 957 | | m_data1[port] = ioport(portnames[port][0])->read() | (ioport(portnames[port][1])->read() << 8); |
| 958 | | m_data2[port] = ioport(portnames[port][2])->read() | (ioport(portnames[port][3])->read() << 8); |
| 952 | m_data1[port] = ioport(portnames[port][0])->read(); |
| 953 | m_data2[port] = ioport(portnames[port][1])->read(); |
| 959 | 954 | |
| 960 | 955 | // avoid sending signals that could crash games |
| 961 | 956 | // if left, no right |
| r23750 | r23751 | |
| 964 | 959 | // if up, no down |
| 965 | 960 | if (m_data1[port] & 0x800) |
| 966 | 961 | m_data1[port] &= ~0x400; |
| 967 | | |
| 968 | | m_joypad[port].buttons = m_data1[port]; |
| 962 | // if left, no right |
| 963 | if (m_data2[port] & 0x200) |
| 964 | m_data2[port] &= ~0x100; |
| 965 | // if up, no down |
| 966 | if (m_data2[port] & 0x800) |
| 967 | m_data2[port] &= ~0x400; |
| 969 | 968 | } |
| 970 | 969 | |
| 971 | 970 | // is automatic reading on? if so, copy port data1/data2 to joy1l->joy4h |
| r23750 | r23751 | |
| 991 | 990 | } |
| 992 | 991 | |
| 993 | 992 | |
| 994 | | |
| 995 | | READ8_MEMBER(snes_state::nss_oldjoy1_read) |
| 993 | UINT8 snes_state::oldjoy1_read(int latched) |
| 996 | 994 | { |
| 997 | | UINT8 res; |
| 995 | if (latched) |
| 996 | return 0; |
| 998 | 997 | |
| 999 | 998 | if (m_read_idx[0] >= 16) |
| 1000 | | res = 0x01; |
| 999 | return 1; |
| 1001 | 1000 | else |
| 1002 | | res = (m_joypad[0].buttons >> (15 - m_read_idx[0]++)) & 0x01; |
| 1003 | | |
| 1004 | | return res; |
| 1001 | return (m_data1[0] >> (15 - m_read_idx[0]++)) & 0x01; |
| 1005 | 1002 | } |
| 1006 | 1003 | |
| 1007 | | READ8_MEMBER(snes_state::nss_oldjoy2_read) |
| 1004 | UINT8 snes_state::oldjoy2_read(int latched) |
| 1008 | 1005 | { |
| 1009 | | UINT8 res; |
| 1006 | if (latched) |
| 1007 | return 0; |
| 1010 | 1008 | |
| 1011 | 1009 | if (m_read_idx[1] >= 16) |
| 1012 | | res = 0x01; |
| 1010 | return 1; |
| 1013 | 1011 | else |
| 1014 | | res = (m_joypad[1].buttons >> (15 - m_read_idx[1]++)) & 0x01; |
| 1015 | | |
| 1016 | | return res; |
| 1012 | return (m_data1[1] >> (15 - m_read_idx[1]++)) & 0x01; |
| 1017 | 1013 | } |
| 1018 | 1014 | |
| 1015 | |
| 1019 | 1016 | /************************************* |
| 1020 | 1017 | |
| 1021 | 1018 | Driver Init |
| r23750 | r23751 | |
| 1065 | 1062 | SNES_CPU_REG(JOY4L) = SNES_CPU_REG(JOY4H) = 0; |
| 1066 | 1063 | m_data1[0] = m_data2[0] = m_data1[1] = m_data2[1] = 0; |
| 1067 | 1064 | |
| 1068 | | m_io_read = write8_delegate(FUNC(snes_state::nss_io_read),this); |
| 1069 | | m_oldjoy1_read = read8_delegate(FUNC(snes_state::nss_oldjoy1_read),this); |
| 1070 | | m_oldjoy2_read = read8_delegate(FUNC(snes_state::nss_oldjoy2_read),this); |
| 1071 | | |
| 1072 | 1065 | // set up some known register power-up defaults |
| 1073 | 1066 | SNES_CPU_REG(WRIO) = 0xff; |
| 1074 | 1067 | |
| r23750 | r23751 | |
| 1091 | 1084 | |
| 1092 | 1085 | for (int i = 0; i < 6; i++) |
| 1093 | 1086 | { |
| 1094 | | state_save_register_item(machine(), "snes_dma", NULL, i, m_dma_channel[i].dmap); |
| 1095 | | state_save_register_item(machine(), "snes_dma", NULL, i, m_dma_channel[i].dest_addr); |
| 1096 | | state_save_register_item(machine(), "snes_dma", NULL, i, m_dma_channel[i].src_addr); |
| 1097 | | state_save_register_item(machine(), "snes_dma", NULL, i, m_dma_channel[i].bank); |
| 1098 | | state_save_register_item(machine(), "snes_dma", NULL, i, m_dma_channel[i].trans_size); |
| 1099 | | state_save_register_item(machine(), "snes_dma", NULL, i, m_dma_channel[i].ibank); |
| 1100 | | state_save_register_item(machine(), "snes_dma", NULL, i, m_dma_channel[i].hdma_addr); |
| 1101 | | state_save_register_item(machine(), "snes_dma", NULL, i, m_dma_channel[i].hdma_line_counter); |
| 1102 | | state_save_register_item(machine(), "snes_dma", NULL, i, m_dma_channel[i].unk); |
| 1103 | | state_save_register_item(machine(), "snes_dma", NULL, i, m_dma_channel[i].do_transfer); |
| 1104 | | state_save_register_item(machine(), "snes_dma", NULL, i, m_dma_channel[i].dma_disabled); |
| 1087 | save_item(NAME(m_dma_channel[i].dmap), i); |
| 1088 | save_item(NAME(m_dma_channel[i].dest_addr), i); |
| 1089 | save_item(NAME(m_dma_channel[i].src_addr), i); |
| 1090 | save_item(NAME(m_dma_channel[i].bank), i); |
| 1091 | save_item(NAME(m_dma_channel[i].trans_size), i); |
| 1092 | save_item(NAME(m_dma_channel[i].ibank), i); |
| 1093 | save_item(NAME(m_dma_channel[i].hdma_addr), i); |
| 1094 | save_item(NAME(m_dma_channel[i].hdma_line_counter), i); |
| 1095 | save_item(NAME(m_dma_channel[i].unk), i); |
| 1096 | save_item(NAME(m_dma_channel[i].do_transfer), i); |
| 1097 | save_item(NAME(m_dma_channel[i].dma_disabled), i); |
| 1105 | 1098 | } |
| 1106 | 1099 | |
| 1107 | 1100 | save_item(NAME(m_hblank_offset)); |
| r23750 | r23751 | |
| 1116 | 1109 | save_item(NAME(m_cpu_regs)); |
| 1117 | 1110 | save_item(NAME(m_oldjoy1_latch)); |
| 1118 | 1111 | |
| 1119 | | for (int i = 0; i < 2; i++) |
| 1120 | | { |
| 1121 | | state_save_register_item(machine(), "snes_dma", NULL, i, m_joypad[i].buttons); |
| 1122 | | state_save_register_item(machine(), "snes_dma", NULL, i, m_mouse[i].x); |
| 1123 | | state_save_register_item(machine(), "snes_dma", NULL, i, m_mouse[i].oldx); |
| 1124 | | state_save_register_item(machine(), "snes_dma", NULL, i, m_mouse[i].y); |
| 1125 | | state_save_register_item(machine(), "snes_dma", NULL, i, m_mouse[i].oldy); |
| 1126 | | state_save_register_item(machine(), "snes_dma", NULL, i, m_mouse[i].buttons); |
| 1127 | | state_save_register_item(machine(), "snes_dma", NULL, i, m_mouse[i].deltax); |
| 1128 | | state_save_register_item(machine(), "snes_dma", NULL, i, m_mouse[i].deltay); |
| 1129 | | state_save_register_item(machine(), "snes_dma", NULL, i, m_mouse[i].speed); |
| 1130 | | state_save_register_item(machine(), "snes_dma", NULL, i, m_scope[i].x); |
| 1131 | | state_save_register_item(machine(), "snes_dma", NULL, i, m_scope[i].y); |
| 1132 | | state_save_register_item(machine(), "snes_dma", NULL, i, m_scope[i].buttons); |
| 1133 | | state_save_register_item(machine(), "snes_dma", NULL, i, m_scope[i].turbo_lock); |
| 1134 | | state_save_register_item(machine(), "snes_dma", NULL, i, m_scope[i].pause_lock); |
| 1135 | | state_save_register_item(machine(), "snes_dma", NULL, i, m_scope[i].fire_lock); |
| 1136 | | state_save_register_item(machine(), "snes_dma", NULL, i, m_scope[i].offscreen); |
| 1137 | | } |
| 1138 | | |
| 1139 | 1112 | m_is_nss = 0; |
| 1140 | 1113 | m_is_sfcbox = 0; |
| 1141 | 1114 | } |
| 1142 | 1115 | |
| 1143 | 1116 | void snes_state::machine_reset() |
| 1144 | 1117 | { |
| 1145 | | int i; |
| 1146 | | |
| 1147 | 1118 | snes_init_ram(); |
| 1148 | 1119 | |
| 1149 | 1120 | /* init DMA regs to be 0xff */ |
| 1150 | | for(i = 0; i < 8; i++) |
| 1121 | for (int i = 0; i < 8; i++) |
| 1151 | 1122 | { |
| 1152 | 1123 | m_dma_channel[i].dmap = 0xff; |
| 1153 | 1124 | m_dma_channel[i].dest_addr = 0xff; |
trunk/src/mess/drivers/snes.c
| r23750 | r23751 | |
| 47 | 47 | #include "machine/sns_event.h" |
| 48 | 48 | |
| 49 | 49 | |
| 50 | struct snes_mouse |
| 51 | { |
| 52 | INT16 x, y, oldx, oldy; |
| 53 | UINT16 buttons; |
| 54 | UINT8 deltax, deltay; |
| 55 | int speed; |
| 56 | }; |
| 57 | |
| 58 | struct snes_superscope |
| 59 | { |
| 60 | INT16 x, y; |
| 61 | UINT8 buttons; |
| 62 | int turbo_lock, pause_lock, fire_lock; |
| 63 | int offscreen; |
| 64 | }; |
| 65 | |
| 66 | |
| 50 | 67 | class snes_console_state : public snes_state |
| 51 | 68 | { |
| 52 | 69 | public: |
| r23750 | r23751 | |
| 99 | 116 | |
| 100 | 117 | DECLARE_READ8_MEMBER( spc_ram_100_r ); |
| 101 | 118 | DECLARE_WRITE8_MEMBER( spc_ram_100_w ); |
| 102 | | CUSTOM_INPUT_MEMBER( snes_mouse_speed_input ); |
| 103 | | CUSTOM_INPUT_MEMBER( snes_superscope_offscreen_input ); |
| 104 | 119 | TIMER_CALLBACK_MEMBER( lightgun_tick ); |
| 105 | | void snes_gun_latch( INT16 x, INT16 y ); |
| 106 | | void snes_input_read_joy( int port ); |
| 107 | | void snes_input_read_mouse( int port ); |
| 108 | | void snes_input_read_superscope( int port ); |
| 109 | | DECLARE_WRITE8_MEMBER(snes_input_read); |
| 110 | | DECLARE_READ8_MEMBER(snes_oldjoy1_read); |
| 111 | | DECLARE_READ8_MEMBER(snes_oldjoy2_read); |
| 112 | 120 | |
| 121 | // input related |
| 122 | virtual DECLARE_WRITE8_MEMBER(io_read); |
| 123 | virtual UINT8 oldjoy1_read(int latched); |
| 124 | virtual UINT8 oldjoy2_read(int latched); |
| 125 | |
| 126 | // pad inputs |
| 127 | void input_read_joy(int port, bool multitap); |
| 128 | UINT8 input_serial_pad(int port, int latched, bool multitap); |
| 129 | |
| 130 | // mouse inputs |
| 131 | void input_read_mouse(int port); |
| 132 | UINT8 input_serial_mouse(int port, int latched); |
| 133 | |
| 134 | // superscope inputs |
| 135 | DECLARE_CUSTOM_INPUT_MEMBER( sscope_offscreen_input ); |
| 136 | void input_read_sscope(int port); |
| 137 | UINT8 input_serial_sscope(int port, int latched); |
| 138 | void gun_latch(INT16 x, INT16 y); |
| 139 | |
| 113 | 140 | virtual void machine_start(); |
| 114 | 141 | virtual void machine_reset(); |
| 115 | 142 | int m_type; |
| 116 | 143 | optional_device<sns_cart_slot_device> m_cartslot; |
| 117 | 144 | |
| 118 | 145 | protected: |
| 146 | |
| 147 | snes_mouse m_mouse[2]; |
| 148 | snes_superscope m_scope[2]; |
| 149 | |
| 119 | 150 | virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); |
| 120 | 151 | }; |
| 121 | 152 | |
| r23750 | r23751 | |
| 1038 | 1069 | * |
| 1039 | 1070 | *************************************/ |
| 1040 | 1071 | |
| 1041 | | CUSTOM_INPUT_MEMBER( snes_console_state::snes_mouse_speed_input ) |
| 1042 | | { |
| 1043 | | int port = (FPTR)param; |
| 1044 | | |
| 1045 | | if (m_oldjoy1_latch & 0x1) |
| 1046 | | { |
| 1047 | | m_mouse[port].speed++; |
| 1048 | | if ((m_mouse[port].speed & 0x03) == 0x03) |
| 1049 | | m_mouse[port].speed = 0; |
| 1050 | | } |
| 1051 | | |
| 1052 | | return m_mouse[port].speed; |
| 1053 | | } |
| 1054 | | |
| 1055 | | CUSTOM_INPUT_MEMBER( snes_console_state::snes_superscope_offscreen_input ) |
| 1056 | | { |
| 1057 | | int port = (FPTR)param; |
| 1058 | | static const char *const portnames[2][3] = |
| 1059 | | { |
| 1060 | | { "SUPERSCOPE1", "SUPERSCOPE1_X", "SUPERSCOPE1_Y" }, |
| 1061 | | { "SUPERSCOPE2", "SUPERSCOPE2_X", "SUPERSCOPE2_Y" }, |
| 1062 | | }; |
| 1063 | | |
| 1064 | | INT16 x = ioport(portnames[port][1])->read(); |
| 1065 | | INT16 y = ioport(portnames[port][2])->read(); |
| 1066 | | |
| 1067 | | /* these are the theoretical boundaries, but we currently are always onscreen... */ |
| 1068 | | if (x < 0 || x >= SNES_SCR_WIDTH || y < 0 || y >= m_ppu.m_beam.last_visible_line) |
| 1069 | | m_scope[port].offscreen = 1; |
| 1070 | | else |
| 1071 | | m_scope[port].offscreen = 0; |
| 1072 | | |
| 1073 | | return m_scope[port].offscreen; |
| 1074 | | } |
| 1075 | | |
| 1076 | 1072 | void snes_console_state::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) |
| 1077 | 1073 | { |
| 1078 | 1074 | switch (id) |
| r23750 | r23751 | |
| 1110 | 1106 | } |
| 1111 | 1107 | } |
| 1112 | 1108 | |
| 1113 | | |
| 1114 | 1109 | static INPUT_PORTS_START( snes_joypads ) |
| 1115 | | PORT_START("SERIAL1_DATA1_L") |
| 1116 | | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("P1 Button A") PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01) |
| 1117 | | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON5 ) PORT_NAME("P1 Button X") PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01) |
| 1118 | | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON6 ) PORT_NAME("P1 Button L") PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01) |
| 1119 | | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_NAME("P1 Button R") PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01) |
| 1120 | | PORT_START("SERIAL1_DATA1_H") |
| 1121 | | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("P1 Button B") PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01) |
| 1122 | | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_NAME("P1 Button Y") PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01) |
| 1123 | | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_SELECT ) PORT_NAME("P1 Select") PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01) |
| 1124 | | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_START1 ) PORT_NAME("P1 Start") PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01) |
| 1125 | | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01) |
| 1126 | | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01) |
| 1127 | | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01) |
| 1128 | | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01) |
| 1129 | 1110 | |
| 1130 | | PORT_START("SERIAL2_DATA1_L") |
| 1131 | | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("P2 Button A") PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10) |
| 1132 | | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON5 ) PORT_NAME("P2 Button X") PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10) |
| 1133 | | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON6 ) PORT_NAME("P2 Button L") PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10) |
| 1134 | | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_NAME("P2 Button R") PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10) |
| 1135 | | PORT_START("SERIAL2_DATA1_H") |
| 1136 | | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("P2 Button B") PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10) |
| 1137 | | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_NAME("P2 Button Y") PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10) |
| 1138 | | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_SELECT ) PORT_NAME("P2 Select") PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10) |
| 1139 | | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_START2 ) PORT_NAME("P2 Start") PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10) |
| 1140 | | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10) |
| 1141 | | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10) |
| 1142 | | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10) |
| 1143 | | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10) |
| 1111 | PORT_START("JOY1") |
| 1112 | PORT_BIT( 0x8000, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("P1 Button B") PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01) |
| 1113 | PORT_BIT( 0x4000, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_NAME("P1 Button Y") PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01) |
| 1114 | PORT_BIT( 0x2000, IP_ACTIVE_HIGH, IPT_SELECT ) PORT_NAME("P1 Select") PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01) |
| 1115 | PORT_BIT( 0x1000, IP_ACTIVE_HIGH, IPT_START1 ) PORT_NAME("P1 Start") PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01) |
| 1116 | PORT_BIT( 0x0800, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01) |
| 1117 | PORT_BIT( 0x0400, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01) |
| 1118 | PORT_BIT( 0x0200, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01) |
| 1119 | PORT_BIT( 0x0100, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01) |
| 1120 | PORT_BIT( 0x0080, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("P1 Button A") PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01) |
| 1121 | PORT_BIT( 0x0040, IP_ACTIVE_HIGH, IPT_BUTTON5 ) PORT_NAME("P1 Button X") PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01) |
| 1122 | PORT_BIT( 0x0020, IP_ACTIVE_HIGH, IPT_BUTTON6 ) PORT_NAME("P1 Button L") PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01) |
| 1123 | PORT_BIT( 0x0010, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_NAME("P1 Button R") PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01) |
| 1124 | PORT_BIT( 0x000f, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x01) |
| 1144 | 1125 | |
| 1145 | | PORT_START("SERIAL1_DATA2_L") |
| 1146 | | PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 1147 | | PORT_START("SERIAL1_DATA2_H") |
| 1148 | | PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 1126 | PORT_START("JOY2") |
| 1127 | PORT_BIT( 0x8000, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("P2 Button B") PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10) |
| 1128 | PORT_BIT( 0x4000, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_NAME("P2 Button Y") PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10) |
| 1129 | PORT_BIT( 0x2000, IP_ACTIVE_HIGH, IPT_SELECT ) PORT_NAME("P2 Select") PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10) |
| 1130 | PORT_BIT( 0x1000, IP_ACTIVE_HIGH, IPT_START2 ) PORT_NAME("P2 Start") PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10) |
| 1131 | PORT_BIT( 0x0800, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10) |
| 1132 | PORT_BIT( 0x0400, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10) |
| 1133 | PORT_BIT( 0x0200, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10) |
| 1134 | PORT_BIT( 0x0100, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10) |
| 1135 | PORT_BIT( 0x0080, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("P2 Button A") PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10) |
| 1136 | PORT_BIT( 0x0040, IP_ACTIVE_HIGH, IPT_BUTTON5 ) PORT_NAME("P2 Button X") PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10) |
| 1137 | PORT_BIT( 0x0020, IP_ACTIVE_HIGH, IPT_BUTTON6 ) PORT_NAME("P2 Button L") PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10) |
| 1138 | PORT_BIT( 0x0010, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_NAME("P2 Button R") PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10) |
| 1139 | PORT_BIT( 0x000f, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x10) |
| 1140 | // temp hack to share the same port both for P2 alone and P2 through MP5 adapter |
| 1141 | PORT_BIT( 0x8000, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("P2 Button B") PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50) |
| 1142 | PORT_BIT( 0x4000, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_NAME("P2 Button Y") PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50) |
| 1143 | PORT_BIT( 0x2000, IP_ACTIVE_HIGH, IPT_SELECT ) PORT_NAME("P2 Select") PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50) |
| 1144 | PORT_BIT( 0x1000, IP_ACTIVE_HIGH, IPT_START2 ) PORT_NAME("P2 Start") PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50) |
| 1145 | PORT_BIT( 0x0800, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50) |
| 1146 | PORT_BIT( 0x0400, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50) |
| 1147 | PORT_BIT( 0x0200, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50) |
| 1148 | PORT_BIT( 0x0100, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50) |
| 1149 | PORT_BIT( 0x0080, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("P2 Button A") PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50) |
| 1150 | PORT_BIT( 0x0040, IP_ACTIVE_HIGH, IPT_BUTTON5 ) PORT_NAME("P2 Button X") PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50) |
| 1151 | PORT_BIT( 0x0020, IP_ACTIVE_HIGH, IPT_BUTTON6 ) PORT_NAME("P2 Button L") PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50) |
| 1152 | PORT_BIT( 0x0010, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_NAME("P2 Button R") PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50) |
| 1153 | PORT_BIT( 0x000f, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50) |
| 1149 | 1154 | |
| 1150 | | PORT_START("SERIAL2_DATA2_L") |
| 1151 | | PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 1152 | | PORT_START("SERIAL2_DATA2_H") |
| 1153 | | PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 1155 | PORT_START("JOY3") |
| 1156 | PORT_BIT( 0x8000, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("P3 Button B") PORT_PLAYER(3) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50) |
| 1157 | PORT_BIT( 0x4000, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_NAME("P3 Button Y") PORT_PLAYER(3) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50) |
| 1158 | PORT_BIT( 0x2000, IP_ACTIVE_HIGH, IPT_SELECT ) PORT_NAME("P3 Select") PORT_PLAYER(3) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50) |
| 1159 | PORT_BIT( 0x1000, IP_ACTIVE_HIGH, IPT_START3 ) PORT_NAME("P3 Start") PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50) |
| 1160 | PORT_BIT( 0x0800, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_PLAYER(3) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50) |
| 1161 | PORT_BIT( 0x0400, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_PLAYER(3) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50) |
| 1162 | PORT_BIT( 0x0200, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_PLAYER(3) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50) |
| 1163 | PORT_BIT( 0x0100, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(3) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50) |
| 1164 | PORT_BIT( 0x0080, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("P3 Button A") PORT_PLAYER(3) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50) |
| 1165 | PORT_BIT( 0x0040, IP_ACTIVE_HIGH, IPT_BUTTON5 ) PORT_NAME("P3 Button X") PORT_PLAYER(3) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50) |
| 1166 | PORT_BIT( 0x0020, IP_ACTIVE_HIGH, IPT_BUTTON6 ) PORT_NAME("P3 Button L") PORT_PLAYER(3) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50) |
| 1167 | PORT_BIT( 0x0010, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_NAME("P3 Button R") PORT_PLAYER(3) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50) |
| 1168 | PORT_BIT( 0x000f, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50) |
| 1169 | |
| 1170 | PORT_START("JOY4") |
| 1171 | PORT_BIT( 0x8000, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("P4 Button B") PORT_PLAYER(4) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50) |
| 1172 | PORT_BIT( 0x4000, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_NAME("P4 Button Y") PORT_PLAYER(4) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50) |
| 1173 | PORT_BIT( 0x2000, IP_ACTIVE_HIGH, IPT_SELECT ) PORT_NAME("P4 Select") PORT_PLAYER(4) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50) |
| 1174 | PORT_BIT( 0x1000, IP_ACTIVE_HIGH, IPT_START4 ) PORT_NAME("P4 Start") PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50) |
| 1175 | PORT_BIT( 0x0800, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_PLAYER(4) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50) |
| 1176 | PORT_BIT( 0x0400, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_PLAYER(4) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50) |
| 1177 | PORT_BIT( 0x0200, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_PLAYER(4) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50) |
| 1178 | PORT_BIT( 0x0100, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(4) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50) |
| 1179 | PORT_BIT( 0x0080, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("P4 Button A") PORT_PLAYER(4) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50) |
| 1180 | PORT_BIT( 0x0040, IP_ACTIVE_HIGH, IPT_BUTTON5 ) PORT_NAME("P4 Button X") PORT_PLAYER(4) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50) |
| 1181 | PORT_BIT( 0x0020, IP_ACTIVE_HIGH, IPT_BUTTON6 ) PORT_NAME("P4 Button L") PORT_PLAYER(4) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50) |
| 1182 | PORT_BIT( 0x0010, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_NAME("P4 Button R") PORT_PLAYER(4) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50) |
| 1183 | PORT_BIT( 0x000f, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50) |
| 1184 | |
| 1185 | PORT_START("JOY5") |
| 1186 | PORT_BIT( 0x8000, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("P5 Button B") PORT_PLAYER(5) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50) |
| 1187 | PORT_BIT( 0x4000, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_NAME("P5 Button Y") PORT_PLAYER(5) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50) |
| 1188 | PORT_BIT( 0x2000, IP_ACTIVE_HIGH, IPT_SELECT ) PORT_NAME("P5 Select") PORT_PLAYER(5) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50) |
| 1189 | PORT_BIT( 0x1000, IP_ACTIVE_HIGH, IPT_START5 ) PORT_NAME("P5 Start") PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50) |
| 1190 | PORT_BIT( 0x0800, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_PLAYER(5) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50) |
| 1191 | PORT_BIT( 0x0400, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_PLAYER(5) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50) |
| 1192 | PORT_BIT( 0x0200, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_PLAYER(5) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50) |
| 1193 | PORT_BIT( 0x0100, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(5) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50) |
| 1194 | PORT_BIT( 0x0080, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("P5 Button A") PORT_PLAYER(5) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50) |
| 1195 | PORT_BIT( 0x0040, IP_ACTIVE_HIGH, IPT_BUTTON5 ) PORT_NAME("P5 Button X") PORT_PLAYER(5) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50) |
| 1196 | PORT_BIT( 0x0020, IP_ACTIVE_HIGH, IPT_BUTTON6 ) PORT_NAME("P5 Button L") PORT_PLAYER(5) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50) |
| 1197 | PORT_BIT( 0x0010, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_NAME("P5 Button R") PORT_PLAYER(5) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50) |
| 1198 | PORT_BIT( 0x000f, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x50) |
| 1199 | |
| 1154 | 1200 | INPUT_PORTS_END |
| 1155 | 1201 | |
| 1156 | 1202 | static INPUT_PORTS_START( snes_mouse ) |
| 1157 | 1203 | PORT_START("MOUSE1") |
| 1158 | 1204 | /* bits 0,3 = mouse signature (must be 1) */ |
| 1159 | | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 1160 | | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 1161 | | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 1162 | | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 1205 | PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 1206 | PORT_BIT( 0x0002, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 1207 | PORT_BIT( 0x0004, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 1208 | PORT_BIT( 0x0008, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 1163 | 1209 | /* bits 4,5 = mouse speed: 0 = slow, 1 = normal, 2 = fast, 3 = unused */ |
| 1164 | | PORT_BIT( 0x30, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, snes_console_state, snes_mouse_speed_input, (void *)0) |
| 1210 | PORT_BIT( 0x0030, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 1165 | 1211 | /* bits 6,7 = mouse buttons */ |
| 1166 | | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("P1 Mouse Button Left") PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x02) |
| 1167 | | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("P1 Mouse Button Right") PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x02) |
| 1212 | PORT_BIT( 0x0040, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("P1 Mouse Button Left") PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x02) |
| 1213 | PORT_BIT( 0x0080, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("P1 Mouse Button Right") PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x02) |
| 1214 | PORT_BIT( 0xff00, IP_ACTIVE_HIGH, IPT_SPECIAL ) // these must be 0! |
| 1168 | 1215 | |
| 1169 | 1216 | PORT_START("MOUSE1_X") |
| 1170 | | PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_X) PORT_SENSITIVITY(100) PORT_KEYDELTA(0) PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x02) |
| 1217 | PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_X) PORT_SENSITIVITY(100) PORT_KEYDELTA(15) PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x02) |
| 1171 | 1218 | |
| 1172 | 1219 | PORT_START("MOUSE1_Y") |
| 1173 | | PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_Y) PORT_SENSITIVITY(100) PORT_KEYDELTA(0) PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x02) |
| 1220 | PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_Y) PORT_SENSITIVITY(100) PORT_KEYDELTA(15) PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x02) |
| 1174 | 1221 | |
| 1175 | 1222 | PORT_START("MOUSE2") |
| 1176 | 1223 | /* bits 0,3 = mouse signature (must be 1) */ |
| r23750 | r23751 | |
| 1179 | 1226 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 1180 | 1227 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 1181 | 1228 | /* bits 4,5 = mouse speed: 0 = slow, 1 = normal, 2 = fast, 3 = unused */ |
| 1182 | | PORT_BIT( 0x30, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, snes_console_state, snes_mouse_speed_input, (void *)1) |
| 1229 | PORT_BIT( 0x30, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 1183 | 1230 | /* bits 6,7 = mouse buttons */ |
| 1184 | 1231 | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("P2 Mouse Button Left") PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x20) |
| 1185 | 1232 | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("P2 Mouse Button Right") PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x20) |
| 1186 | 1233 | |
| 1187 | 1234 | PORT_START("MOUSE2_X") |
| 1188 | | PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_X) PORT_SENSITIVITY(100) PORT_KEYDELTA(0) PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x20) |
| 1235 | PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_X) PORT_SENSITIVITY(100) PORT_KEYDELTA(15) PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x20) |
| 1189 | 1236 | |
| 1190 | 1237 | PORT_START("MOUSE2_Y") |
| 1191 | | PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_Y) PORT_SENSITIVITY(100) PORT_KEYDELTA(0) PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x20) |
| 1238 | PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_Y) PORT_SENSITIVITY(100) PORT_KEYDELTA(15) PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x20) |
| 1192 | 1239 | INPUT_PORTS_END |
| 1193 | 1240 | |
| 1194 | 1241 | static INPUT_PORTS_START( snes_superscope ) |
| 1195 | 1242 | PORT_START("SUPERSCOPE1") |
| 1196 | 1243 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNUSED ) // Noise |
| 1197 | | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, snes_console_state, snes_superscope_offscreen_input, (void *)0) |
| 1244 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, snes_console_state, sscope_offscreen_input, (void *)0) |
| 1198 | 1245 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 1199 | 1246 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 1200 | 1247 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_NAME("Port1 Superscope Pause") PORT_PLAYER(1) PORT_CONDITION("CTRLSEL", 0x0f, EQUALS, 0x03) |
| r23750 | r23751 | |
| 1210 | 1257 | |
| 1211 | 1258 | PORT_START("SUPERSCOPE2") |
| 1212 | 1259 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNUSED ) // Noise |
| 1213 | | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, snes_console_state, snes_superscope_offscreen_input, (void *)1) |
| 1260 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, snes_console_state, sscope_offscreen_input, (void *)1) |
| 1214 | 1261 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 1215 | 1262 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 1216 | 1263 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_NAME("Port2 Superscope Pause") PORT_PLAYER(2) PORT_CONDITION("CTRLSEL", 0xf0, EQUALS, 0x30) |
| r23750 | r23751 | |
| 1240 | 1287 | PORT_CONFSETTING( 0x20, "Mouse" ) |
| 1241 | 1288 | PORT_CONFSETTING( 0x30, "Superscope" ) |
| 1242 | 1289 | // PORT_CONFSETTING( 0x40, "Justfier" ) |
| 1243 | | // PORT_CONFSETTING( 0x50, "Multitap" ) |
| 1290 | PORT_CONFSETTING( 0x50, "Multitap" ) |
| 1244 | 1291 | |
| 1245 | 1292 | PORT_INCLUDE(snes_joypads) |
| 1246 | 1293 | PORT_INCLUDE(snes_mouse) |
| r23750 | r23751 | |
| 1311 | 1358 | * |
| 1312 | 1359 | *************************************/ |
| 1313 | 1360 | |
| 1314 | | void snes_console_state::snes_gun_latch( INT16 x, INT16 y ) |
| 1315 | | { |
| 1316 | | /* these are the theoretical boundaries */ |
| 1317 | | if (x < 0) |
| 1318 | | x = 0; |
| 1319 | | if (x > (SNES_SCR_WIDTH - 1)) |
| 1320 | | x = SNES_SCR_WIDTH - 1; |
| 1361 | // Mouse handling |
| 1321 | 1362 | |
| 1322 | | if (y < 0) |
| 1323 | | y = 0; |
| 1324 | | if (y > (m_ppu.m_beam.last_visible_line - 1)) |
| 1325 | | y = m_ppu.m_beam.last_visible_line - 1; |
| 1326 | | |
| 1327 | | m_ppu.m_beam.latch_horz = x; |
| 1328 | | m_ppu.m_beam.latch_vert = y; |
| 1329 | | m_ppu.m_stat78 |= 0x40; |
| 1330 | | } |
| 1331 | | |
| 1332 | | void snes_console_state::snes_input_read_joy( int port ) |
| 1363 | void snes_console_state::input_read_mouse(int port) |
| 1333 | 1364 | { |
| 1334 | | static const char *const portnames[2][4] = |
| 1335 | | { |
| 1336 | | { "SERIAL1_DATA1_L", "SERIAL1_DATA1_H", "SERIAL1_DATA2_L", "SERIAL1_DATA2_H" }, |
| 1337 | | { "SERIAL2_DATA1_L", "SERIAL2_DATA1_H", "SERIAL2_DATA2_L", "SERIAL2_DATA2_H" }, |
| 1338 | | }; |
| 1339 | | |
| 1340 | | m_data1[port] = ioport(portnames[port][0])->read() | (ioport(portnames[port][1])->read() << 8); |
| 1341 | | m_data2[port] = ioport(portnames[port][2])->read() | (ioport(portnames[port][3])->read() << 8); |
| 1342 | | |
| 1343 | | // avoid sending signals that could crash games |
| 1344 | | // if left, no right |
| 1345 | | if (m_data1[port] & 0x200) |
| 1346 | | m_data1[port] &= ~0x100; |
| 1347 | | // if up, no down |
| 1348 | | if (m_data1[port] & 0x800) |
| 1349 | | m_data1[port] &= ~0x400; |
| 1350 | | |
| 1351 | | m_joypad[port].buttons = m_data1[port]; |
| 1352 | | } |
| 1353 | | |
| 1354 | | void snes_console_state::snes_input_read_mouse( int port ) |
| 1355 | | { |
| 1356 | 1365 | INT16 var; |
| 1357 | 1366 | static const char *const portnames[2][3] = |
| 1358 | | { |
| 1359 | | { "MOUSE1", "MOUSE1_X", "MOUSE1_Y" }, |
| 1360 | | { "MOUSE2", "MOUSE2_X", "MOUSE2_Y" }, |
| 1361 | | }; |
| 1367 | { |
| 1368 | { "MOUSE1", "MOUSE1_X", "MOUSE1_Y" }, |
| 1369 | { "MOUSE2", "MOUSE2_X", "MOUSE2_Y" }, |
| 1370 | }; |
| 1362 | 1371 | |
| 1363 | 1372 | m_mouse[port].buttons = ioport(portnames[port][0])->read(); |
| 1364 | 1373 | m_mouse[port].x = ioport(portnames[port][1])->read(); |
| 1365 | 1374 | m_mouse[port].y = ioport(portnames[port][2])->read(); |
| 1375 | |
| 1366 | 1376 | var = m_mouse[port].x - m_mouse[port].oldx; |
| 1367 | 1377 | |
| 1368 | 1378 | if (var < -127) |
| r23750 | r23751 | |
| 1409 | 1419 | m_mouse[port].oldy = m_mouse[port].y; |
| 1410 | 1420 | } |
| 1411 | 1421 | |
| 1412 | | m_data1[port] = m_mouse[port].buttons | (0x00 << 8); |
| 1422 | m_data1[port] = m_mouse[port].buttons; |
| 1413 | 1423 | m_data2[port] = 0; |
| 1414 | 1424 | } |
| 1415 | 1425 | |
| 1416 | | void snes_console_state::snes_input_read_superscope( int port ) |
| 1426 | UINT8 snes_console_state::input_serial_mouse(int port, int latched) |
| 1417 | 1427 | { |
| 1428 | UINT8 res = 0; |
| 1429 | |
| 1430 | if (latched) |
| 1431 | { |
| 1432 | m_mouse[port].speed = (m_mouse[port].speed + 1) % 3; |
| 1433 | return res; |
| 1434 | } |
| 1435 | |
| 1436 | if (m_read_idx[port] >= 32) |
| 1437 | res |= 0x01; |
| 1438 | else if (m_read_idx[port] >= 24) |
| 1439 | res |= (m_mouse[port].deltax >> (31 - m_read_idx[port]++)) & 0x01; |
| 1440 | else if (m_read_idx[port] >= 16) |
| 1441 | res |= (m_mouse[port].deltay >> (23 - m_read_idx[port]++)) & 0x01; |
| 1442 | else if (m_read_idx[port] == 11) |
| 1443 | { |
| 1444 | res |= (m_mouse[port].speed >> 0) & 0x01; |
| 1445 | m_read_idx[port]++; |
| 1446 | } |
| 1447 | else if (m_read_idx[port] == 10) |
| 1448 | { |
| 1449 | res |= (m_mouse[port].speed >> 1) & 0x01; |
| 1450 | m_read_idx[port]++; |
| 1451 | } |
| 1452 | else |
| 1453 | res |= (m_mouse[port].buttons >> (15 - m_read_idx[port]++)) & 0x01; |
| 1454 | |
| 1455 | return res; |
| 1456 | } |
| 1457 | |
| 1458 | // Superscope handling |
| 1459 | |
| 1460 | CUSTOM_INPUT_MEMBER( snes_console_state::sscope_offscreen_input ) |
| 1461 | { |
| 1462 | int port = (FPTR)param; |
| 1418 | 1463 | static const char *const portnames[2][3] = |
| 1419 | | { |
| 1420 | | { "SUPERSCOPE1", "SUPERSCOPE1_X", "SUPERSCOPE1_Y" }, |
| 1421 | | { "SUPERSCOPE2", "SUPERSCOPE2_X", "SUPERSCOPE2_Y" }, |
| 1422 | | }; |
| 1464 | { |
| 1465 | { "SUPERSCOPE1", "SUPERSCOPE1_X", "SUPERSCOPE1_Y" }, |
| 1466 | { "SUPERSCOPE2", "SUPERSCOPE2_X", "SUPERSCOPE2_Y" }, |
| 1467 | }; |
| 1468 | |
| 1469 | INT16 x = ioport(portnames[port][1])->read(); |
| 1470 | INT16 y = ioport(portnames[port][2])->read(); |
| 1471 | |
| 1472 | /* these are the theoretical boundaries, but we currently are always onscreen... */ |
| 1473 | if (x < 0 || x >= SNES_SCR_WIDTH || y < 0 || y >= m_ppu.m_beam.last_visible_line) |
| 1474 | m_scope[port].offscreen = 1; |
| 1475 | else |
| 1476 | m_scope[port].offscreen = 0; |
| 1477 | |
| 1478 | return m_scope[port].offscreen; |
| 1479 | } |
| 1480 | |
| 1481 | |
| 1482 | void snes_console_state::gun_latch(INT16 x, INT16 y) |
| 1483 | { |
| 1484 | /* these are the theoretical boundaries */ |
| 1485 | if (x < 0) |
| 1486 | x = 0; |
| 1487 | if (x > (SNES_SCR_WIDTH - 1)) |
| 1488 | x = SNES_SCR_WIDTH - 1; |
| 1489 | |
| 1490 | if (y < 0) |
| 1491 | y = 0; |
| 1492 | if (y > (m_ppu.m_beam.last_visible_line - 1)) |
| 1493 | y = m_ppu.m_beam.last_visible_line - 1; |
| 1494 | |
| 1495 | m_ppu.m_beam.latch_horz = x; |
| 1496 | m_ppu.m_beam.latch_vert = y; |
| 1497 | m_ppu.m_stat78 |= 0x40; |
| 1498 | } |
| 1499 | |
| 1500 | void snes_console_state::input_read_sscope(int port) |
| 1501 | { |
| 1502 | static const char *const portnames[2][3] = |
| 1503 | { |
| 1504 | { "SUPERSCOPE1", "SUPERSCOPE1_X", "SUPERSCOPE1_Y" }, |
| 1505 | { "SUPERSCOPE2", "SUPERSCOPE2_X", "SUPERSCOPE2_Y" }, |
| 1506 | }; |
| 1423 | 1507 | UINT8 input; |
| 1424 | 1508 | |
| 1425 | 1509 | /* first read input bits */ |
| r23750 | r23751 | |
| 1464 | 1548 | m_scope[port].pause_lock = 0; |
| 1465 | 1549 | |
| 1466 | 1550 | /* If we have pressed fire or cursor and we are on-screen and SuperScope is in Port2, then latch video signal. |
| 1467 | | Notice that we only latch Port2 because its IOBit pin is connected to bit7 of the IO Port, while Port1 has |
| 1468 | | IOBit pin connected to bit6 of the IO Port, and the latter is not detected by the H/V Counters. In other |
| 1469 | | words, you can connect SuperScope to Port1, but there is no way SNES could detect its on-screen position */ |
| 1551 | Notice that we only latch Port2 because its IOBit pin is connected to bit7 of the IO Port, while Port1 has |
| 1552 | IOBit pin connected to bit6 of the IO Port, and the latter is not detected by the H/V Counters. In other |
| 1553 | words, you can connect SuperScope to Port1, but there is no way SNES could detect its on-screen position */ |
| 1470 | 1554 | if ((m_scope[port].buttons & 0xc0) && !(m_scope[port].buttons & 0x02) && port == 1) |
| 1471 | | snes_gun_latch(m_scope[port].x, m_scope[port].y); |
| 1555 | gun_latch(m_scope[port].x, m_scope[port].y); |
| 1472 | 1556 | |
| 1473 | 1557 | m_data1[port] = 0xff | (m_scope[port].buttons << 8); |
| 1474 | 1558 | m_data2[port] = 0; |
| 1475 | 1559 | } |
| 1476 | 1560 | |
| 1477 | | WRITE8_MEMBER(snes_console_state::snes_input_read) |
| 1561 | UINT8 snes_console_state::input_serial_sscope(int port, int latched) |
| 1478 | 1562 | { |
| 1563 | UINT8 res = 0; |
| 1564 | |
| 1565 | if (m_read_idx[port] >= 8) |
| 1566 | res |= 0x01; |
| 1567 | else |
| 1568 | res |= (m_scope[port].buttons >> (7 - m_read_idx[port]++)) & 0x01; |
| 1569 | |
| 1570 | return res; |
| 1571 | } |
| 1572 | |
| 1573 | // Joypad + Multitap handling |
| 1574 | // input_read_joy is used both for standard joys and for the MP5 multitap |
| 1575 | |
| 1576 | void snes_console_state::input_read_joy( int port, bool multitap ) |
| 1577 | { |
| 1578 | static const char *const portnames[4][2] = |
| 1579 | { |
| 1580 | { "JOY1", "JOY3" }, |
| 1581 | { "JOY2", "JOY3" }, |
| 1582 | { "JOY4", "JOY5" }, |
| 1583 | { "JOY4", "JOY5" } |
| 1584 | }; |
| 1585 | |
| 1586 | if (!multitap) |
| 1587 | { |
| 1588 | m_data1[port] = ioport(portnames[port][0])->read(); |
| 1589 | m_data2[port] = 0; |
| 1590 | // avoid sending signals that could crash games |
| 1591 | // if left, no right |
| 1592 | if (m_data1[port] & 0x200) |
| 1593 | m_data1[port] &= ~0x100; |
| 1594 | // if up, no down |
| 1595 | if (m_data1[port] & 0x800) |
| 1596 | m_data1[port] &= ~0x400; |
| 1597 | // if left, no right |
| 1598 | if (m_data2[port] & 0x200) |
| 1599 | m_data2[port] &= ~0x100; |
| 1600 | // if up, no down |
| 1601 | if (m_data2[port] & 0x800) |
| 1602 | m_data2[port] &= ~0x400; |
| 1603 | } |
| 1604 | else |
| 1605 | { |
| 1606 | m_data1[port] = ioport(portnames[port][0])->read(); |
| 1607 | m_data2[port] = ioport(portnames[port][1])->read(); |
| 1608 | m_data1[port + 2] = ioport(portnames[port + 2][0])->read(); |
| 1609 | m_data2[port + 2] = ioport(portnames[port + 2][1])->read(); |
| 1610 | // avoid sending signals that could crash games |
| 1611 | // if left, no right |
| 1612 | if (m_data1[port] & 0x200) |
| 1613 | m_data1[port] &= ~0x100; |
| 1614 | // if up, no down |
| 1615 | if (m_data1[port] & 0x800) |
| 1616 | m_data1[port] &= ~0x400; |
| 1617 | // if left, no right |
| 1618 | if (m_data2[port] & 0x200) |
| 1619 | m_data2[port] &= ~0x100; |
| 1620 | // if up, no down |
| 1621 | if (m_data2[port] & 0x800) |
| 1622 | m_data2[port] &= ~0x400; |
| 1623 | // if left, no right |
| 1624 | if (m_data1[port + 2] & 0x200) |
| 1625 | m_data1[port + 2] &= ~0x100; |
| 1626 | // if up, no down |
| 1627 | if (m_data1[port + 2] & 0x800) |
| 1628 | m_data1[port + 2] &= ~0x400; |
| 1629 | // if left, no right |
| 1630 | if (m_data2[port + 2] & 0x200) |
| 1631 | m_data2[port + 2] &= ~0x100; |
| 1632 | // if up, no down |
| 1633 | if (m_data2[port + 2] & 0x800) |
| 1634 | m_data2[port + 2] &= ~0x400; |
| 1635 | } |
| 1636 | } |
| 1637 | |
| 1638 | UINT8 snes_console_state::input_serial_pad(int port, int latched, bool multitap) |
| 1639 | { |
| 1640 | UINT8 res = 0; |
| 1641 | |
| 1642 | // multitap signature? Super Bomberman 3-5 do not like this at all... |
| 1643 | if (multitap) |
| 1644 | res |= 2; |
| 1645 | if (latched) |
| 1646 | return res; |
| 1647 | |
| 1648 | if (!multitap) |
| 1649 | { |
| 1650 | if (m_read_idx[port] >= 16) |
| 1651 | res |= 0x01; |
| 1652 | else |
| 1653 | { |
| 1654 | res |= (BIT(m_data1[port], (15 - m_read_idx[port]))); |
| 1655 | res |= (BIT(m_data2[port], (15 - m_read_idx[port])) << 1); |
| 1656 | m_read_idx[port]++; |
| 1657 | } |
| 1658 | } |
| 1659 | else |
| 1660 | { |
| 1661 | int shift = !(SNES_CPU_REG(WRIO) & 0x80) ? 2 : 0; |
| 1662 | if (m_read_idx[port + shift] >= 16) |
| 1663 | res |= 0x03; |
| 1664 | else |
| 1665 | { |
| 1666 | res |= (BIT(m_data1[port + shift], (15 - m_read_idx[port + shift]))); |
| 1667 | res |= (BIT(m_data2[port + shift], (15 - m_read_idx[port + shift])) << 1); |
| 1668 | m_read_idx[port + shift]++; |
| 1669 | } |
| 1670 | } |
| 1671 | return res; |
| 1672 | } |
| 1673 | |
| 1674 | |
| 1675 | // input handling from the system side |
| 1676 | |
| 1677 | WRITE8_MEMBER(snes_console_state::io_read) |
| 1678 | { |
| 1479 | 1679 | UINT8 ctrl1 = ioport("CTRLSEL")->read() & 0x0f; |
| 1480 | 1680 | UINT8 ctrl2 = (ioport("CTRLSEL")->read() & 0xf0) >> 4; |
| 1681 | bool multitap0 = FALSE; |
| 1682 | bool multitap1 = FALSE; |
| 1481 | 1683 | |
| 1482 | | /* Check if lightgun has been chosen as input: if so, enable crosshair */ |
| 1684 | // Check if lightgun has been chosen as input: if so, enable crosshair |
| 1483 | 1685 | timer_set(attotime::zero, TIMER_LIGHTGUN_TICK); |
| 1484 | 1686 | |
| 1485 | 1687 | switch (ctrl1) |
| 1486 | 1688 | { |
| 1487 | | case 1: /* SNES joypad */ |
| 1488 | | snes_input_read_joy(0); |
| 1489 | | break; |
| 1490 | | case 2: /* SNES Mouse */ |
| 1491 | | snes_input_read_mouse(0); |
| 1492 | | break; |
| 1493 | | case 3: /* SNES Superscope */ |
| 1494 | | snes_input_read_superscope(0); |
| 1495 | | break; |
| 1496 | | case 0: /* no controller in port1 */ |
| 1497 | | default: |
| 1498 | | m_data1[0] = 0; |
| 1499 | | m_data2[0] = 0; |
| 1500 | | break; |
| 1689 | case 1: // SNES joypad |
| 1690 | input_read_joy(0, FALSE); |
| 1691 | break; |
| 1692 | case 2: // SNES Mouse |
| 1693 | input_read_mouse(0); |
| 1694 | break; |
| 1695 | case 3: // SNES Superscope |
| 1696 | input_read_sscope(0); |
| 1697 | break; |
| 1698 | case 5: // SNES joypad(s) through MP5 multitap |
| 1699 | input_read_joy(0, TRUE); |
| 1700 | multitap0 = TRUE; |
| 1701 | break; |
| 1702 | case 0: // empty port1 |
| 1703 | default: |
| 1704 | m_data1[0] = 0; |
| 1705 | m_data2[0] = 0; |
| 1706 | break; |
| 1501 | 1707 | } |
| 1502 | 1708 | |
| 1503 | 1709 | switch (ctrl2) |
| 1504 | 1710 | { |
| 1505 | | case 1: /* SNES joypad */ |
| 1506 | | snes_input_read_joy(1); |
| 1507 | | break; |
| 1508 | | case 2: /* SNES Mouse */ |
| 1509 | | snes_input_read_mouse(1); |
| 1510 | | break; |
| 1511 | | case 3: /* SNES Superscope */ |
| 1512 | | snes_input_read_superscope(1); |
| 1513 | | break; |
| 1514 | | case 0: /* no controller in port2 */ |
| 1515 | | default: |
| 1516 | | m_data1[1] = 0; |
| 1517 | | m_data2[1] = 0; |
| 1518 | | break; |
| 1711 | case 1: // SNES joypad |
| 1712 | input_read_joy(1, FALSE); |
| 1713 | break; |
| 1714 | case 2: // SNES Mouse |
| 1715 | input_read_mouse(1); |
| 1716 | break; |
| 1717 | case 3: // SNES Superscope |
| 1718 | input_read_sscope(1); |
| 1719 | break; |
| 1720 | case 5: // SNES joypad(s) through MP5 multitap |
| 1721 | input_read_joy(1, TRUE); |
| 1722 | multitap1 = TRUE; |
| 1723 | break; |
| 1724 | case 0: // empty port2 |
| 1725 | default: |
| 1726 | m_data1[1] = 0; |
| 1727 | m_data2[1] = 0; |
| 1728 | break; |
| 1519 | 1729 | } |
| 1520 | 1730 | |
| 1521 | 1731 | // is automatic reading on? if so, copy port data1/data2 to joy1l->joy4h |
| 1522 | 1732 | // this actually works like reading the first 16bits from oldjoy1/2 in reverse order |
| 1523 | 1733 | if (SNES_CPU_REG(NMITIMEN) & 1) |
| 1524 | 1734 | { |
| 1525 | | SNES_CPU_REG(JOY1L) = (m_data1[0] & 0x00ff) >> 0; |
| 1526 | | SNES_CPU_REG(JOY1H) = (m_data1[0] & 0xff00) >> 8; |
| 1527 | | SNES_CPU_REG(JOY2L) = (m_data1[1] & 0x00ff) >> 0; |
| 1528 | | SNES_CPU_REG(JOY2H) = (m_data1[1] & 0xff00) >> 8; |
| 1529 | | SNES_CPU_REG(JOY3L) = (m_data2[0] & 0x00ff) >> 0; |
| 1530 | | SNES_CPU_REG(JOY3H) = (m_data2[0] & 0xff00) >> 8; |
| 1531 | | SNES_CPU_REG(JOY4L) = (m_data2[1] & 0x00ff) >> 0; |
| 1532 | | SNES_CPU_REG(JOY4H) = (m_data2[1] & 0xff00) >> 8; |
| 1735 | int shift0 = (multitap0 && !(SNES_CPU_REG(WRIO) & 0x80)) ? 2 : 0; |
| 1736 | int shift1 = (multitap1 && !(SNES_CPU_REG(WRIO) & 0x80)) ? 2 : 0; |
| 1533 | 1737 | |
| 1738 | SNES_CPU_REG(JOY1L) = (m_data1[0 + shift0] & 0x00ff) >> 0; |
| 1739 | SNES_CPU_REG(JOY1H) = (m_data1[0 + shift0] & 0xff00) >> 8; |
| 1740 | SNES_CPU_REG(JOY2L) = (m_data1[1 + shift1] & 0x00ff) >> 0; |
| 1741 | SNES_CPU_REG(JOY2H) = (m_data1[1 + shift1] & 0xff00) >> 8; |
| 1742 | SNES_CPU_REG(JOY3L) = (m_data2[0 + shift0] & 0x00ff) >> 0; |
| 1743 | SNES_CPU_REG(JOY3H) = (m_data2[0 + shift0] & 0xff00) >> 8; |
| 1744 | SNES_CPU_REG(JOY4L) = (m_data2[1 + shift1] & 0x00ff) >> 0; |
| 1745 | SNES_CPU_REG(JOY4H) = (m_data2[1 + shift1] & 0xff00) >> 8; |
| 1746 | |
| 1534 | 1747 | // make sure read_idx starts returning all 1s because the auto-read reads it :-) |
| 1535 | | m_read_idx[0] = 16; |
| 1536 | | m_read_idx[1] = 16; |
| 1748 | m_read_idx[0 + shift0] = 16; |
| 1749 | m_read_idx[1 + shift1] = 16; |
| 1537 | 1750 | } |
| 1538 | | |
| 1539 | 1751 | } |
| 1540 | 1752 | |
| 1541 | | READ8_MEMBER(snes_console_state::snes_oldjoy1_read) |
| 1753 | UINT8 snes_console_state::oldjoy1_read(int latched) |
| 1542 | 1754 | { |
| 1543 | 1755 | UINT8 ctrl1 = ioport("CTRLSEL")->read() & 0x0f; |
| 1544 | | UINT8 res = 0; |
| 1545 | 1756 | |
| 1546 | 1757 | switch (ctrl1) |
| 1547 | 1758 | { |
| 1548 | | case 1: /* SNES joypad */ |
| 1549 | | if (m_read_idx[0] >= 16) |
| 1550 | | res = 0x01; |
| 1551 | | else |
| 1552 | | res = (m_joypad[0].buttons >> (15 - m_read_idx[0]++)) & 0x01; |
| 1553 | | break; |
| 1554 | | case 2: /* SNES Mouse */ |
| 1555 | | if (m_read_idx[0] >= 32) |
| 1556 | | res = 0x01; |
| 1557 | | else if (m_read_idx[0] >= 24) |
| 1558 | | res = (m_mouse[0].deltax >> (31 - m_read_idx[0]++)) & 0x01; |
| 1559 | | else if (m_read_idx[0] >= 16) |
| 1560 | | res = (m_mouse[0].deltay >> (23 - m_read_idx[0]++)) & 0x01; |
| 1561 | | else if (m_read_idx[0] >= 8) |
| 1562 | | res = (m_mouse[0].buttons >> (15 - m_read_idx[0]++)) & 0x01; |
| 1563 | | else |
| 1564 | | res = 0; |
| 1565 | | break; |
| 1566 | | case 3: /* SNES Superscope */ |
| 1567 | | if (m_read_idx[0] >= 8) |
| 1568 | | res = 0x01; |
| 1569 | | else |
| 1570 | | res = (m_scope[0].buttons >> (7 - m_read_idx[0]++)) & 0x01; |
| 1571 | | break; |
| 1572 | | case 0: /* no controller in port2 */ |
| 1573 | | default: |
| 1574 | | break; |
| 1759 | case 1: // SNES joypad |
| 1760 | return input_serial_pad(0, latched, FALSE); |
| 1761 | |
| 1762 | case 2: // SNES Mouse |
| 1763 | return input_serial_mouse(0, latched); |
| 1764 | |
| 1765 | case 3: // SNES Superscope |
| 1766 | return input_serial_sscope(0, latched); |
| 1767 | |
| 1768 | case 5: // SNES multipad |
| 1769 | return input_serial_pad(0, latched, TRUE); |
| 1770 | |
| 1771 | case 0: // empty port1 |
| 1772 | default: |
| 1773 | return 0; |
| 1575 | 1774 | } |
| 1576 | | |
| 1577 | | return res; |
| 1578 | 1775 | } |
| 1579 | 1776 | |
| 1580 | | READ8_MEMBER(snes_console_state::snes_oldjoy2_read) |
| 1777 | UINT8 snes_console_state::oldjoy2_read(int latched) |
| 1581 | 1778 | { |
| 1582 | 1779 | UINT8 ctrl2 = (ioport("CTRLSEL")->read() & 0xf0) >> 4; |
| 1583 | | UINT8 res = 0; |
| 1584 | 1780 | |
| 1585 | 1781 | switch (ctrl2) |
| 1586 | 1782 | { |
| 1587 | | case 1: /* SNES joypad */ |
| 1588 | | if (m_read_idx[1] >= 16) |
| 1589 | | res = 0x01; |
| 1590 | | else |
| 1591 | | res = (m_joypad[1].buttons >> (15 - m_read_idx[1]++)) & 0x01; |
| 1592 | | break; |
| 1593 | | case 2: /* SNES Mouse */ |
| 1594 | | if (m_read_idx[1] >= 32) |
| 1595 | | res = 0x01; |
| 1596 | | else if (m_read_idx[1] >= 24) |
| 1597 | | res = (m_mouse[1].deltax >> (31 - m_read_idx[1]++)) & 0x01; |
| 1598 | | else if (m_read_idx[1] >= 16) |
| 1599 | | res = (m_mouse[1].deltay >> (23 - m_read_idx[1]++)) & 0x01; |
| 1600 | | else if (m_read_idx[1] >= 8) |
| 1601 | | res = (m_mouse[1].buttons >> (15 - m_read_idx[1]++)) & 0x01; |
| 1602 | | else |
| 1603 | | res = 0; |
| 1604 | | break; |
| 1605 | | case 3: /* SNES Superscope */ |
| 1606 | | if (m_read_idx[1] >= 8) |
| 1607 | | res = 0x01; |
| 1608 | | else |
| 1609 | | res = (m_scope[1].buttons >> (7 - m_read_idx[1]++)) & 0x01; |
| 1610 | | break; |
| 1611 | | case 0: /* no controller in port2 */ |
| 1612 | | default: |
| 1613 | | break; |
| 1783 | case 1: // SNES joypad |
| 1784 | return input_serial_pad(1, latched, FALSE); |
| 1785 | |
| 1786 | case 2: // SNES Mouse |
| 1787 | return input_serial_mouse(1, latched); |
| 1788 | |
| 1789 | case 3: // SNES Superscope |
| 1790 | return input_serial_sscope(1, latched); |
| 1791 | |
| 1792 | case 5: // SNES multipad |
| 1793 | return input_serial_pad(1, latched, TRUE); |
| 1794 | |
| 1795 | case 0: // empty port1 |
| 1796 | default: |
| 1797 | return 0; |
| 1614 | 1798 | } |
| 1615 | | |
| 1616 | | return res; |
| 1617 | 1799 | } |
| 1618 | 1800 | |
| 1619 | 1801 | /************************************* |
| r23750 | r23751 | |
| 1784 | 1966 | // set_5a22_map(m_maincpu); |
| 1785 | 1967 | break; |
| 1786 | 1968 | } |
| 1969 | |
| 1970 | for (int i = 0; i < 2; i++) |
| 1971 | { |
| 1972 | save_item(NAME(m_mouse[i].x), i); |
| 1973 | save_item(NAME(m_mouse[i].oldx), i); |
| 1974 | save_item(NAME(m_mouse[i].y), i); |
| 1975 | save_item(NAME(m_mouse[i].oldy), i); |
| 1976 | save_item(NAME(m_mouse[i].buttons), i); |
| 1977 | save_item(NAME(m_mouse[i].deltax), i); |
| 1978 | save_item(NAME(m_mouse[i].deltay), i); |
| 1979 | save_item(NAME(m_mouse[i].speed), i); |
| 1980 | save_item(NAME(m_scope[i].x), i); |
| 1981 | save_item(NAME(m_scope[i].y), i); |
| 1982 | save_item(NAME(m_scope[i].buttons), i); |
| 1983 | save_item(NAME(m_scope[i].turbo_lock), i); |
| 1984 | save_item(NAME(m_scope[i].pause_lock), i); |
| 1985 | save_item(NAME(m_scope[i].fire_lock), i); |
| 1986 | save_item(NAME(m_scope[i].offscreen), i); |
| 1987 | } |
| 1787 | 1988 | } |
| 1788 | 1989 | |
| 1789 | 1990 | void snes_console_state::machine_reset() |
| 1790 | 1991 | { |
| 1791 | 1992 | snes_state::machine_reset(); |
| 1792 | | |
| 1793 | | m_io_read = write8_delegate(FUNC(snes_console_state::snes_input_read),this); |
| 1794 | | m_oldjoy1_read = read8_delegate(FUNC(snes_console_state::snes_oldjoy1_read),this); |
| 1795 | | m_oldjoy2_read = read8_delegate(FUNC(snes_console_state::snes_oldjoy2_read),this); |
| 1796 | 1993 | } |
| 1797 | 1994 | |
| 1798 | 1995 | |