src/mess/machine/coleco.c
| r13550 | r13551 | |
| 8 | 8 | UINT8 ctrl_sel = input_port_read_safe(machine, "CTRLSEL", 0); |
| 9 | 9 | |
| 10 | 10 | /* which controller shall we read? */ |
| 11 | | if ((ctrl_sel & 0x07) == 0x03) // Driving controller |
| 12 | | analog1 = input_port_read_safe(machine, "DRIV", 0); |
| 11 | if ((ctrl_sel & 0x07) == 0x02) // Super Action Controller P1 |
| 12 | analog1 = input_port_read_safe(machine, "SAC_SLIDE1", 0); |
| 13 | 13 | |
| 14 | | else |
| 15 | | { |
| 16 | | if ((ctrl_sel & 0x07) == 0x02) // Super Action Controller P1 |
| 17 | | analog1 = input_port_read_safe(machine, "SAC_SLIDE1", 0); |
| 14 | if ((ctrl_sel & 0x70) == 0x20) // Super Action Controller P2 |
| 15 | analog2 = input_port_read_safe(machine, "SAC_SLIDE2", 0); |
| 18 | 16 | |
| 19 | | if ((ctrl_sel & 0x70) == 0x20) // Super Action Controller P2 |
| 20 | | analog2 = input_port_read_safe(machine, "SAC_SLIDE2", 0); |
| 21 | | |
| 22 | | /* In principle, even if not supported by any game, I guess we could have two Super |
| 23 | | Action Controllers plugged into the Roller controller ports. Since I found no info |
| 24 | | about the behavior of sliders in such a configuration, we overwrite SAC sliders with |
| 25 | | the Roller trackball inputs and actually use the latter ones, when both are selected. */ |
| 26 | | if (ctrl_sel & 0x80) // Roller controller |
| 27 | | { |
| 28 | | analog1 = input_port_read_safe(machine, "ROLLER_X", 0); |
| 29 | | analog2 = input_port_read_safe(machine, "ROLLER_Y", 0); |
| 30 | | } |
| 17 | /* In principle, even if not supported by any game, I guess we could have two Super |
| 18 | Action Controllers plugged into the Roller controller ports. Since I found no info |
| 19 | about the behavior of sliders in such a configuration, we overwrite SAC sliders with |
| 20 | the Roller trackball inputs and actually use the latter ones, when both are selected. */ |
| 21 | if (ctrl_sel & 0x80) // Roller controller |
| 22 | { |
| 23 | analog1 = input_port_read_safe(machine, "ROLLER_X", 0); |
| 24 | analog2 = input_port_read_safe(machine, "ROLLER_Y", 0); |
| 31 | 25 | } |
| 32 | 26 | |
| 33 | 27 | if (analog1 == 0) |
| 34 | 28 | *joy_status0 = 0; |
| 35 | | else if (analog1 & 0x08) |
| 36 | | *joy_status0 = -1; |
| 29 | else if (analog1 & 8) |
| 30 | *joy_status0 = 0x8f; |
| 37 | 31 | else |
| 38 | | *joy_status0 = 1; |
| 32 | *joy_status0 = 0x81; |
| 39 | 33 | |
| 40 | 34 | if (analog2 == 0) |
| 41 | 35 | *joy_status1 = 0; |
| 42 | | else if (analog2 & 0x08) |
| 43 | | *joy_status1 = -1; |
| 36 | else if (analog2 & 8) |
| 37 | *joy_status1 = 0x8f; |
| 44 | 38 | else |
| 45 | | *joy_status1 = 1; |
| 39 | *joy_status1 = 0x81; |
| 46 | 40 | } |
| 47 | 41 | |
| 48 | 42 | |
| 49 | | UINT8 coleco_paddle1_read(running_machine &machine, int joy_mode, int joy_status) |
| 43 | UINT8 coleco_paddle_read(running_machine &machine, int port, int joy_mode, int joy_status) |
| 50 | 44 | { |
| 51 | 45 | UINT8 ctrl_sel = input_port_read_safe(machine, "CTRLSEL", 0); |
| 46 | UINT8 ctrl_extra = ctrl_sel & 0x80; |
| 47 | ctrl_sel = ctrl_sel >> (port*4) & 7; |
| 52 | 48 | |
| 53 | | /* is there a controller connected to port1? */ |
| 54 | | if ((ctrl_sel & 0x07) != 0x01 ) |
| 49 | /* Keypad and fire 1 (SAC Yellow Button) */ |
| 50 | if (joy_mode == 0) |
| 55 | 51 | { |
| 56 | | /* Keypad and fire 1 (SAC Yellow Button) */ |
| 57 | | if (joy_mode == 0) |
| 58 | | { |
| 59 | | UINT8 data = 0x0f; /* No key pressed by default */ |
| 60 | | UINT16 ipt1 = 0x00; |
| 52 | /* No key pressed by default */ |
| 53 | UINT8 data = 0x0f; |
| 54 | UINT16 ipt = 0; |
| 61 | 55 | |
| 62 | | if ((ctrl_sel & 0x07) == 0x00) // colecovision controller |
| 63 | | ipt1 = input_port_read(machine, "KEYPAD1"); |
| 64 | | else if ((ctrl_sel & 0x07) == 0x02) // super action controller controller |
| 65 | | ipt1 = input_port_read(machine, "SAC_KPD1"); |
| 56 | if (ctrl_sel == 0) // colecovision controller |
| 57 | ipt = input_port_read(machine, port ? "KEYPAD2" : "KEYPAD1"); |
| 58 | else if (ctrl_sel == 2) // super action controller |
| 59 | ipt = input_port_read(machine, port ? "SAC_KPD2" : "SAC_KPD1"); |
| 60 | else // unconnected |
| 61 | ipt = 0xffff; |
| 66 | 62 | |
| 67 | | /* Numeric pad buttons are not independent on a real ColecoVision, if you push more |
| 68 | | than one, a real ColecoVision think that it is a third button, so we are going to emulate |
| 69 | | the right behaviour */ |
| 70 | | /* Super Action Controller additional buttons are read in the same way */ |
| 71 | | if ((ctrl_sel & 0x07) != 0x03) /* If Driving Controller enabled -> no keypad 1*/ |
| 72 | | { |
| 73 | | if (!(ipt1 & 0x0001)) data &= 0x0a; /* 0 */ |
| 74 | | if (!(ipt1 & 0x0002)) data &= 0x0d; /* 1 */ |
| 75 | | if (!(ipt1 & 0x0004)) data &= 0x07; /* 2 */ |
| 76 | | if (!(ipt1 & 0x0008)) data &= 0x0c; /* 3 */ |
| 77 | | if (!(ipt1 & 0x0010)) data &= 0x02; /* 4 */ |
| 78 | | if (!(ipt1 & 0x0020)) data &= 0x03; /* 5 */ |
| 79 | | if (!(ipt1 & 0x0040)) data &= 0x0e; /* 6 */ |
| 80 | | if (!(ipt1 & 0x0080)) data &= 0x05; /* 7 */ |
| 81 | | if (!(ipt1 & 0x0100)) data &= 0x01; /* 8 */ |
| 82 | | if (!(ipt1 & 0x0200)) data &= 0x0b; /* 9 */ |
| 83 | | if (!(ipt1 & 0x0400)) data &= 0x06; /* # */ |
| 84 | | if (!(ipt1 & 0x0800)) data &= 0x09; /* . */ |
| 85 | | if (!(ipt1 & 0x1000)) data &= 0x04; /* Blue Action Button */ |
| 86 | | if (!(ipt1 & 0x2000)) data &= 0x08; /* Purple Action Button */ |
| 87 | | } |
| 63 | /* Numeric pad buttons are not independent on a real ColecoVision, if you push more |
| 64 | than one, a real ColecoVision think that it is a third button, so we are going to emulate |
| 65 | the right behaviour */ |
| 66 | /* Super Action Controller additional buttons are read in the same way */ |
| 67 | if (!(ipt & 0x0001)) data &= 0x0a; /* 0 */ |
| 68 | if (!(ipt & 0x0002)) data &= 0x0d; /* 1 */ |
| 69 | if (!(ipt & 0x0004)) data &= 0x07; /* 2 */ |
| 70 | if (!(ipt & 0x0008)) data &= 0x0c; /* 3 */ |
| 71 | if (!(ipt & 0x0010)) data &= 0x02; /* 4 */ |
| 72 | if (!(ipt & 0x0020)) data &= 0x03; /* 5 */ |
| 73 | if (!(ipt & 0x0040)) data &= 0x0e; /* 6 */ |
| 74 | if (!(ipt & 0x0080)) data &= 0x05; /* 7 */ |
| 75 | if (!(ipt & 0x0100)) data &= 0x01; /* 8 */ |
| 76 | if (!(ipt & 0x0200)) data &= 0x0b; /* 9 */ |
| 77 | if (!(ipt & 0x0400)) data &= 0x06; /* # */ |
| 78 | if (!(ipt & 0x0800)) data &= 0x09; /* . */ |
| 79 | if (!(ipt & 0x1000)) data &= 0x04; /* Blue Action Button */ |
| 80 | if (!(ipt & 0x2000)) data &= 0x08; /* Purple Action Button */ |
| 88 | 81 | |
| 89 | | return ((ipt1 & 0x4000) >> 8) | 0x30 | (data); |
| 90 | | } |
| 91 | | /* Joystick and fire 2 (SAC Red Button) */ |
| 92 | | else |
| 93 | | { |
| 94 | | UINT8 data = 0x0f; |
| 95 | | |
| 96 | | if ((ctrl_sel & 0x07) == 0x00) // colecovision controller |
| 97 | | data = input_port_read(machine, "JOY1") & 0xcf; |
| 98 | | else if ((ctrl_sel & 0x07) == 0x02) // super action controller controller |
| 99 | | data = input_port_read(machine, "SAC_JOY1") & 0xcf; |
| 100 | | |
| 101 | | /* If any extra contoller enabled */ |
| 102 | | if ((ctrl_sel & 0x80) || ((ctrl_sel & 0x07) == 0x02) || ((ctrl_sel & 0x07) == 0x03)) |
| 103 | | { |
| 104 | | if (joy_status == 0) data |= 0x30; /* Spinner Move Left*/ |
| 105 | | else if (joy_status == 1) data |= 0x20; /* Spinner Move Right */ |
| 106 | | } |
| 107 | | |
| 108 | | return data | 0x80; |
| 109 | | } |
| 82 | return (joy_status & 0x80) | ((ipt & 0x4000) >> 8) | 0x30 | data; |
| 110 | 83 | } |
| 111 | | |
| 112 | | return 0x0f; |
| 113 | | } |
| 114 | | |
| 115 | | |
| 116 | | UINT8 coleco_paddle2_read(running_machine &machine, int joy_mode, int joy_status) |
| 117 | | { |
| 118 | | UINT8 ctrl_sel = input_port_read_safe(machine, "CTRLSEL", 0); |
| 119 | | |
| 120 | | /* is there a controller connected to port2? */ |
| 121 | | if ((ctrl_sel & 0x70) != 0x10 ) |
| 84 | /* Joystick and fire 2 (SAC Red Button) */ |
| 85 | else |
| 122 | 86 | { |
| 123 | | /* Keypad and fire 1 */ |
| 124 | | if (joy_mode == 0) |
| 125 | | { |
| 126 | | UINT8 data = 0x0f; /* No key pressed by default */ |
| 127 | | UINT16 ipt2 = 0x00; |
| 87 | UINT8 data = 0x7f; |
| 128 | 88 | |
| 129 | | if ((ctrl_sel & 0x70) == 0x00) // colecovision controller |
| 130 | | ipt2 = input_port_read(machine, "KEYPAD2"); |
| 131 | | else if ((ctrl_sel & 0x70) == 0x20) // super action controller controller |
| 132 | | ipt2 = input_port_read(machine, "SAC_KPD2"); |
| 89 | if (ctrl_sel == 0) // colecovision controller |
| 90 | data = input_port_read(machine, port ? "JOY2" : "JOY1"); |
| 91 | else if (ctrl_sel == 2) // super action controller |
| 92 | data = input_port_read(machine, port ? "SAC_JOY2" : "SAC_JOY1"); |
| 133 | 93 | |
| 134 | | /* Numeric pad buttons are not independent on a real ColecoVision, if you push more |
| 135 | | than one, a real ColecoVision think that it is a third button, so we are going to emulate |
| 136 | | the right behaviour */ |
| 137 | | /* Super Action Controller additional buttons are read in the same way */ |
| 138 | | if (!(ipt2 & 0x0001)) data &= 0x0a; /* 0 */ |
| 139 | | if (!(ipt2 & 0x0002)) data &= 0x0d; /* 1 */ |
| 140 | | if (!(ipt2 & 0x0004)) data &= 0x07; /* 2 */ |
| 141 | | if (!(ipt2 & 0x0008)) data &= 0x0c; /* 3 */ |
| 142 | | if (!(ipt2 & 0x0010)) data &= 0x02; /* 4 */ |
| 143 | | if (!(ipt2 & 0x0020)) data &= 0x03; /* 5 */ |
| 144 | | if (!(ipt2 & 0x0040)) data &= 0x0e; /* 6 */ |
| 145 | | if (!(ipt2 & 0x0080)) data &= 0x05; /* 7 */ |
| 146 | | if (!(ipt2 & 0x0100)) data &= 0x01; /* 8 */ |
| 147 | | if (!(ipt2 & 0x0200)) data &= 0x0b; /* 9 */ |
| 148 | | if (!(ipt2 & 0x0400)) data &= 0x06; /* # */ |
| 149 | | if (!(ipt2 & 0x0800)) data &= 0x09; /* . */ |
| 150 | | if (!(ipt2 & 0x1000)) data &= 0x04; /* Blue Action Button */ |
| 151 | | if (!(ipt2 & 0x2000)) data &= 0x08; /* Purple Action Button */ |
| 152 | | |
| 153 | | return ((ipt2 & 0x4000) >> 8) | 0x30 | (data); |
| 154 | | } |
| 155 | | /* Joystick and fire 2*/ |
| 156 | | else |
| 94 | /* If any extra contoller enabled */ |
| 95 | if (ctrl_extra || ctrl_sel == 2 || ctrl_sel == 3) |
| 157 | 96 | { |
| 158 | | UINT8 data = 0x0f; |
| 159 | | |
| 160 | | if ((ctrl_sel & 0x70) == 0x00) // colecovision controller |
| 161 | | data = input_port_read(machine, "JOY2") & 0xcf; |
| 162 | | else if ((ctrl_sel & 0x70) == 0x20) // super action controller controller |
| 163 | | data = input_port_read(machine, "SAC_JOY2") & 0xcf; |
| 164 | | |
| 165 | | /* If Roller Controller or P2 Super Action Controller enabled */ |
| 166 | | if ((ctrl_sel & 0x80) || ((ctrl_sel & 0x70) == 0x20)) |
| 167 | | { |
| 168 | | if (joy_status == 0) data |= 0x30; |
| 169 | | else if (joy_status == 1) data |= 0x20; |
| 170 | | } |
| 171 | | |
| 172 | | return data | 0x80; |
| 97 | data &= 0xcf; |
| 98 | if (joy_status == 0) data |= 0x30; /* Spinner Move Left */ |
| 99 | else if (joy_status == 0x81) data |= 0x20; /* Spinner Move Right */ |
| 173 | 100 | } |
| 174 | | } |
| 175 | 101 | |
| 176 | | return 0x0f; |
| 102 | return (joy_status & 0x80) | (data & 0x7f); |
| 103 | } |
| 177 | 104 | } |
| 178 | 105 | |
| 179 | 106 | |
| r13550 | r13551 | |
| 296 | 223 | INPUT_PORTS_END |
| 297 | 224 | |
| 298 | 225 | |
| 299 | | static INPUT_PORTS_START( driving ) |
| 300 | | PORT_START("DRIV") // Driving Controller |
| 301 | | PORT_BIT( 0x0f, 0x00, IPT_DIAL ) PORT_SENSITIVITY(20) PORT_KEYDELTA(10) PORT_CODE_DEC(KEYCODE_L) PORT_CODE_INC(KEYCODE_J) PORT_RESET PORT_CONDITION("CTRLSEL", 0x07, PORTCOND_EQUALS, 0x03) |
| 302 | | |
| 303 | | // PORT_START("IN8") // |
| 304 | | // PORT_BIT( 0x0f, 0x00, IPT_TRACKBALL_Y ) PORT_SENSITIVITY(20) PORT_KEYDELTA(10) PORT_CODE_DEC(KEYCODE_I) PORT_CODE_INC(KEYCODE_K) PORT_PLAYER(2) |
| 305 | | INPUT_PORTS_END |
| 306 | | |
| 307 | | |
| 308 | 226 | static INPUT_PORTS_START( roller ) |
| 309 | 227 | PORT_START("ROLLER_X") // Roller Controller X Axis |
| 310 | | PORT_BIT( 0x0f, 0x00, IPT_TRACKBALL_X ) PORT_SENSITIVITY(20) PORT_KEYDELTA(10) PORT_CODE_DEC(KEYCODE_L) PORT_CODE_INC(KEYCODE_J) PORT_RESET PORT_CONDITION("CTRLSEL", 0x80, PORTCOND_EQUALS, 0x80) |
| 228 | PORT_BIT( 0x0f, 0x00, IPT_TRACKBALL_X ) PORT_SENSITIVITY(20) PORT_KEYDELTA(10) PORT_CODE_DEC(KEYCODE_L) PORT_CODE_INC(KEYCODE_J) PORT_REVERSE PORT_RESET PORT_CONDITION("CTRLSEL", 0x80, PORTCOND_EQUALS, 0x80) |
| 311 | 229 | |
| 312 | 230 | PORT_START("ROLLER_Y") // Roller Controller Y Axis |
| 313 | 231 | PORT_BIT( 0x0f, 0x00, IPT_TRACKBALL_Y ) PORT_SENSITIVITY(20) PORT_KEYDELTA(10) PORT_CODE_DEC(KEYCODE_I) PORT_CODE_INC(KEYCODE_K) PORT_RESET PORT_CONDITION("CTRLSEL", 0x80, PORTCOND_EQUALS, 0x80) |
| r13550 | r13551 | |
| 319 | 237 | PORT_CONFNAME( 0x07, 0x00, "Port 1 Controller" ) |
| 320 | 238 | PORT_CONFSETTING( 0x01, DEF_STR( None ) ) |
| 321 | 239 | PORT_CONFSETTING( 0x00, "ColecoVision Controller" ) |
| 322 | | PORT_CONFSETTING( 0x02, "Super Action Controller" ) |
| 323 | | PORT_CONFSETTING( 0x03, "Driving Controller" ) |
| 240 | PORT_CONFSETTING( 0x02, "Super Action/Driving Controller" ) |
| 324 | 241 | PORT_CONFNAME( 0x70, 0x00, "Port 2 Controller" ) |
| 325 | 242 | PORT_CONFSETTING( 0x10, DEF_STR( None ) ) |
| 326 | 243 | PORT_CONFSETTING( 0x00, "ColecoVision Controller" ) |
| r13550 | r13551 | |
| 333 | 250 | PORT_INCLUDE( ctrl2 ) |
| 334 | 251 | PORT_INCLUDE( sac1 ) |
| 335 | 252 | PORT_INCLUDE( sac2 ) |
| 336 | | PORT_INCLUDE( driving ) |
| 337 | 253 | PORT_INCLUDE( roller ) |
| 338 | 254 | INPUT_PORTS_END |
src/mess/drivers/adam.c
| r13550 | r13551 | |
| 1155 | 1155 | //************************************************************************** |
| 1156 | 1156 | |
| 1157 | 1157 | //------------------------------------------------- |
| 1158 | // TIMER_CALLBACK( paddle_d7reset_callback ) |
| 1159 | //------------------------------------------------- |
| 1160 | |
| 1161 | static TIMER_CALLBACK( paddle_d7reset_callback ) |
| 1162 | { |
| 1163 | adam_state *state = machine.driver_data<adam_state>(); |
| 1164 | |
| 1165 | state->m_joy_status0 &= 0x7f; |
| 1166 | state->m_joy_status1 &= 0x7f; |
| 1167 | } |
| 1168 | |
| 1169 | //------------------------------------------------- |
| 1170 | // TIMER_CALLBACK( paddle_irqreset_callback ) |
| 1171 | //------------------------------------------------- |
| 1172 | |
| 1173 | static TIMER_CALLBACK( paddle_irqreset_callback ) |
| 1174 | { |
| 1175 | adam_state *state = machine.driver_data<adam_state>(); |
| 1176 | |
| 1177 | state->m_maincpu->set_input_line(INPUT_LINE_IRQ0, CLEAR_LINE); |
| 1178 | } |
| 1179 | |
| 1180 | |
| 1181 | //------------------------------------------------- |
| 1158 | 1182 | // TIMER_DEVICE_CALLBACK( paddle_tick ) |
| 1159 | 1183 | //------------------------------------------------- |
| 1160 | 1184 | |
| r13550 | r13551 | |
| 1164 | 1188 | |
| 1165 | 1189 | coleco_scan_paddles(timer.machine(), &state->m_joy_status0, &state->m_joy_status1); |
| 1166 | 1190 | |
| 1191 | // on change, controller port d7 is set for a short period and an irq is fired on d7 rising edge |
| 1167 | 1192 | if (state->m_joy_status0 || state->m_joy_status1) |
| 1168 | 1193 | { |
| 1169 | | device_set_input_line(state->m_maincpu, INPUT_LINE_IRQ0, HOLD_LINE); |
| 1194 | state->m_joy_d7_timer->adjust(attotime::from_usec(500)); // TODO: measure duration |
| 1195 | // irq on rising edge, PULSE_LINE is not supported in this case, so clear it manually |
| 1196 | |
| 1197 | state->m_maincpu->set_input_line(INPUT_LINE_IRQ0, ASSERT_LINE); |
| 1198 | state->m_joy_irq_timer->adjust(attotime::from_usec(11)); // TODO: measure duration |
| 1170 | 1199 | } |
| 1171 | 1200 | } |
| 1172 | 1201 | |
| r13550 | r13551 | |
| 1197 | 1226 | |
| 1198 | 1227 | READ8_MEMBER( adam_state::input1_r ) |
| 1199 | 1228 | { |
| 1200 | | return coleco_paddle1_read(machine(), m_joy_mode, m_joy_status0); |
| 1229 | return coleco_paddle_read(machine(), 0, m_joy_mode, m_joy_status0); |
| 1201 | 1230 | } |
| 1202 | 1231 | |
| 1203 | 1232 | |
| r13550 | r13551 | |
| 1207 | 1236 | |
| 1208 | 1237 | READ8_MEMBER( adam_state::input2_r ) |
| 1209 | 1238 | { |
| 1210 | | return coleco_paddle1_read(machine(), m_joy_mode, m_joy_status1); |
| 1239 | return coleco_paddle_read(machine(), 1, m_joy_mode, m_joy_status1); |
| 1211 | 1240 | } |
| 1212 | 1241 | |
| 1213 | 1242 | |
| r13550 | r13551 | |
| 1617 | 1646 | |
| 1618 | 1647 | void adam_state::machine_start() |
| 1619 | 1648 | { |
| 1649 | m_joy_d7_timer = machine().scheduler().timer_alloc(FUNC(paddle_d7reset_callback)); |
| 1650 | m_joy_irq_timer = machine().scheduler().timer_alloc(FUNC(paddle_irqreset_callback)); |
| 1651 | |
| 1620 | 1652 | // register for state saving |
| 1621 | 1653 | save_item(NAME(m_mioc)); |
| 1622 | 1654 | save_item(NAME(m_game)); |
| r13550 | r13551 | |
| 1663 | 1695 | |
| 1664 | 1696 | m_adamnet = 0; |
| 1665 | 1697 | |
| 1698 | m_joy_d7_timer->reset(); |
| 1699 | m_joy_status0 &= 0x7f; |
| 1700 | m_joy_status1 &= 0x7f; |
| 1701 | |
| 1702 | m_joy_irq_timer->reset(); |
| 1703 | m_maincpu->set_input_line(INPUT_LINE_IRQ0, CLEAR_LINE); |
| 1704 | |
| 1666 | 1705 | bankswitch(); |
| 1667 | 1706 | } |
| 1668 | 1707 | |
src/mess/drivers/coleco.c
| r13550 | r13551 | |
| 27 | 27 | E0-FF (R) = Read Controller data, A1=0 -> read controller 1, A1=1 -> read controller 2 |
| 28 | 28 | |
| 29 | 29 | - Modified paddle handler, now it is handled as on a real ColecoVision |
| 30 | | - Added support for a Driving Controller (Expansion Module #2), enabled via category |
| 31 | 30 | - Added support for a Roller Controller (Trackball), enabled via category |
| 32 | 31 | - Added support for two Super Action Controller, enabled via category |
| 33 | 32 | |
| r13550 | r13551 | |
| 68 | 67 | |
| 69 | 68 | READ8_MEMBER( coleco_state::paddle_1_r ) |
| 70 | 69 | { |
| 71 | | return coleco_paddle1_read(machine(), m_joy_mode, m_joy_status[0]); |
| 70 | return coleco_paddle_read(machine(), 0, m_joy_mode, m_joy_status[0]); |
| 72 | 71 | } |
| 73 | 72 | |
| 74 | 73 | READ8_MEMBER( coleco_state::paddle_2_r ) |
| 75 | 74 | { |
| 76 | | return coleco_paddle2_read(machine(), m_joy_mode, m_joy_status[1]); |
| 75 | return coleco_paddle_read(machine(), 1, m_joy_mode, m_joy_status[1]); |
| 77 | 76 | } |
| 78 | 77 | |
| 79 | 78 | WRITE8_MEMBER( coleco_state::paddle_off_w ) |
| r13550 | r13551 | |
| 191 | 190 | drvstate->m_last_state = state; |
| 192 | 191 | } |
| 193 | 192 | |
| 193 | static TIMER_CALLBACK( paddle_d7reset_callback ) |
| 194 | { |
| 195 | coleco_state *state = machine.driver_data<coleco_state>(); |
| 196 | |
| 197 | state->m_joy_status[0] &= 0x7f; |
| 198 | state->m_joy_status[1] &= 0x7f; |
| 199 | } |
| 200 | |
| 201 | static TIMER_CALLBACK( paddle_irqreset_callback ) |
| 202 | { |
| 203 | coleco_state *state = machine.driver_data<coleco_state>(); |
| 204 | |
| 205 | state->m_maincpu->set_input_line(INPUT_LINE_IRQ0, CLEAR_LINE); |
| 206 | } |
| 207 | |
| 194 | 208 | static TIMER_DEVICE_CALLBACK( paddle_callback ) |
| 195 | 209 | { |
| 196 | 210 | coleco_state *state = timer.machine().driver_data<coleco_state>(); |
| 197 | 211 | |
| 198 | 212 | coleco_scan_paddles(timer.machine(), &state->m_joy_status[0], &state->m_joy_status[1]); |
| 199 | 213 | |
| 214 | // on change, controller port d7 is set for a short period and an irq is fired on d7 rising edge |
| 200 | 215 | if (state->m_joy_status[0] || state->m_joy_status[1]) |
| 201 | | state->m_maincpu->set_input_line(INPUT_LINE_IRQ0, HOLD_LINE); |
| 216 | { |
| 217 | state->m_joy_d7_timer->adjust(attotime::from_usec(500)); // TODO: measure duration |
| 218 | |
| 219 | // irq on rising edge, PULSE_LINE is not supported in this case, so clear it manually |
| 220 | state->m_maincpu->set_input_line(INPUT_LINE_IRQ0, ASSERT_LINE); |
| 221 | state->m_joy_irq_timer->adjust(attotime::from_usec(11)); // TODO: measure duration |
| 222 | } |
| 202 | 223 | } |
| 203 | 224 | |
| 204 | 225 | /* Machine Initialization */ |
| r13550 | r13551 | |
| 212 | 233 | |
| 213 | 234 | void coleco_state::machine_start() |
| 214 | 235 | { |
| 236 | m_joy_d7_timer = machine().scheduler().timer_alloc(FUNC(paddle_d7reset_callback)); |
| 237 | m_joy_irq_timer = machine().scheduler().timer_alloc(FUNC(paddle_irqreset_callback)); |
| 215 | 238 | } |
| 216 | 239 | |
| 217 | 240 | void coleco_state::machine_reset() |
| 218 | 241 | { |
| 219 | 242 | m_last_state = 0; |
| 220 | 243 | |
| 244 | m_joy_d7_timer->reset(); |
| 245 | m_joy_status[0] &= 0x7f; |
| 246 | m_joy_status[1] &= 0x7f; |
| 247 | |
| 248 | m_joy_irq_timer->reset(); |
| 249 | m_maincpu->set_input_line(INPUT_LINE_IRQ0, CLEAR_LINE); |
| 221 | 250 | m_maincpu->set_input_line_vector(INPUT_LINE_IRQ0, 0xff); |
| 222 | 251 | |
| 223 | 252 | memset(&machine().region(Z80_TAG)->base()[0x6000], 0xff, 0x400); // initialize RAM |