diff options
Diffstat (limited to 'src/mess/drivers/coleco.c')
-rw-r--r-- | src/mess/drivers/coleco.c | 97 |
1 files changed, 94 insertions, 3 deletions
diff --git a/src/mess/drivers/coleco.c b/src/mess/drivers/coleco.c index 7f8d4be28d8..5f6c020e33c 100644 --- a/src/mess/drivers/coleco.c +++ b/src/mess/drivers/coleco.c @@ -70,12 +70,12 @@ READ8_MEMBER( coleco_state::paddle_1_r ) { - return m_joy_d7_state[0] | coleco_paddle_read(machine(), 0, m_joy_mode, m_joy_analog_state[0]); + return m_joy_d7_state[0] | coleco_paddle_read(0, m_joy_mode, m_joy_analog_state[0]); } READ8_MEMBER( coleco_state::paddle_2_r ) { - return m_joy_d7_state[1] | coleco_paddle_read(machine(), 1, m_joy_mode, m_joy_analog_state[1]); + return m_joy_d7_state[1] | coleco_paddle_read(1, m_joy_mode, m_joy_analog_state[1]); } WRITE8_MEMBER( coleco_state::paddle_off_w ) @@ -206,7 +206,7 @@ TIMER_CALLBACK_MEMBER(coleco_state::paddle_pulse_callback) TIMER_DEVICE_CALLBACK_MEMBER(coleco_state::paddle_update_callback) { // arbitrary timer for reading analog controls - coleco_scan_paddles(machine(), &m_joy_analog_reload[0], &m_joy_analog_reload[1]); + coleco_scan_paddles(&m_joy_analog_reload[0], &m_joy_analog_reload[1]); for (int port = 0; port < 2; port++) { @@ -229,6 +229,97 @@ READ8_MEMBER( coleco_state::cart_r ) return m_cart->bd_r(space, offset & 0x7fff, 0, 0, 0, 0, 0); } +UINT8 coleco_state::coleco_scan_paddles(UINT8 *joy_status0, UINT8 *joy_status1) +{ + UINT8 ctrl_sel = (m_ctrlsel != NULL) ? m_ctrlsel->read() : 0; + + /* which controller shall we read? */ + if ((ctrl_sel & 0x07) == 0x02) // Super Action Controller P1 + *joy_status0 = (m_sac_slide1 != NULL) ? m_sac_slide1->read() : 0; + else if ((ctrl_sel & 0x07) == 0x03) // Driving Controller P1 + *joy_status0 = (m_driv_wheel1 != NULL) ? m_driv_wheel1->read() : 0; + + if ((ctrl_sel & 0x70) == 0x20) // Super Action Controller P2 + *joy_status1 = (m_sac_slide2 != NULL) ? m_sac_slide2->read() : 0; + else if ((ctrl_sel & 0x70) == 0x30) // Driving Controller P2 + *joy_status1 = (m_driv_wheel2 != NULL) ? m_driv_wheel2->read() : 0; + + /* In principle, even if not supported by any game, I guess we could have two Super + Action Controllers plugged into the Roller controller ports. Since I found no info + about the behavior of sliders in such a configuration, we overwrite SAC sliders with + the Roller trackball inputs and actually use the latter ones, when both are selected. */ + if (ctrl_sel & 0x80) // Roller controller + { + *joy_status0 = (m_roller_x != NULL) ? m_roller_x->read() : 0; + *joy_status1 = (m_roller_y != NULL) ? m_roller_y->read() : 0; + } + + return *joy_status0 | *joy_status1; +} + + +UINT8 coleco_state::coleco_paddle_read(int port, int joy_mode, UINT8 joy_status) +{ + UINT8 ctrl_sel = (m_ctrlsel != NULL ) ? m_ctrlsel->read() : 0; + UINT8 ctrl_extra = ctrl_sel & 0x80; + ctrl_sel = ctrl_sel >> (port*4) & 7; + + /* Keypad and fire 1 (SAC Yellow Button) */ + if (joy_mode == 0) + { + /* No key pressed by default */ + UINT8 data = 0x0f; + UINT16 ipt = 0xffff; + + if (ctrl_sel == 0) // ColecoVision Controller + ipt = port ? m_std_keypad2->read() : m_std_keypad1->read(); + else if (ctrl_sel == 2) // Super Action Controller + ipt = port ? m_sac_keypad2->read() : m_sac_keypad1->read(); + + /* Numeric pad buttons are not independent on a real ColecoVision, if you push more + than one, a real ColecoVision think that it is a third button, so we are going to emulate + the right behaviour */ + /* Super Action Controller additional buttons are read in the same way */ + if (!(ipt & 0x0001)) data &= 0x0a; /* 0 */ + if (!(ipt & 0x0002)) data &= 0x0d; /* 1 */ + if (!(ipt & 0x0004)) data &= 0x07; /* 2 */ + if (!(ipt & 0x0008)) data &= 0x0c; /* 3 */ + if (!(ipt & 0x0010)) data &= 0x02; /* 4 */ + if (!(ipt & 0x0020)) data &= 0x03; /* 5 */ + if (!(ipt & 0x0040)) data &= 0x0e; /* 6 */ + if (!(ipt & 0x0080)) data &= 0x05; /* 7 */ + if (!(ipt & 0x0100)) data &= 0x01; /* 8 */ + if (!(ipt & 0x0200)) data &= 0x0b; /* 9 */ + if (!(ipt & 0x0400)) data &= 0x06; /* # */ + if (!(ipt & 0x0800)) data &= 0x09; /* * */ + if (!(ipt & 0x1000)) data &= 0x04; /* Blue Action Button */ + if (!(ipt & 0x2000)) data &= 0x08; /* Purple Action Button */ + + return ((ipt & 0x4000) >> 8) | 0x30 | data; + } + /* Joystick and fire 2 (SAC Red Button) */ + else + { + UINT8 data = 0x7f; + + if (ctrl_sel == 0) // ColecoVision Controller + data = port ? m_std_joy2->read() : m_std_joy1->read(); + else if (ctrl_sel == 2) // Super Action Controller + data = port ? m_sac_joy2->read() : m_sac_joy1->read(); + else if (ctrl_sel == 3) // Driving Controller + data = port ? m_driv_pedal2->read() : m_driv_pedal1->read(); + + /* If any extra analog contoller enabled */ + if (ctrl_extra || ctrl_sel == 2 || ctrl_sel == 3) + { + if (joy_status & 0x80) data ^= 0x30; + else if (joy_status) data ^= 0x10; + } + + return data & 0x7f; + } +} + void coleco_state::machine_start() { memset(m_ram, 0xff, m_ram.bytes()); // initialize RAM |