From 7cd8162937f2ba4aad6206df52ed77e396259650 Mon Sep 17 00:00:00 2001 From: David Haywood Date: Mon, 18 Mar 2019 23:50:20 +0000 Subject: machines promoted to WORKING (Popira 2) (#4773) * some more dirt rebel inputs (nw) * shuffle some code around (nw) * shuffle some code around (nw) * fix controls in Popira 2 * put stuff in better place (nw) * machines promoted to WORKING --- Popira 2 (Japan) [David Haywood, Peter Wilhelmsen, Sean Riddle, ShouTime] * remove old comment (nw) --- scripts/target/mame/mess.lua | 2 + src/mame/drivers/vii.cpp | 2 +- src/mame/drivers/xavix.cpp | 263 ++++++++++------------------------------- src/mame/includes/xavix.h | 26 ++-- src/mame/machine/xavix.cpp | 55 --------- src/mame/machine/xavix_adc.cpp | 100 ++++++++++++++++ src/mame/machine/xavix_adc.h | 50 ++++++++ 7 files changed, 231 insertions(+), 267 deletions(-) create mode 100644 src/mame/machine/xavix_adc.cpp create mode 100644 src/mame/machine/xavix_adc.h diff --git a/scripts/target/mame/mess.lua b/scripts/target/mame/mess.lua index 9f4d4e86493..d9f407008d6 100644 --- a/scripts/target/mame/mess.lua +++ b/scripts/target/mame/mess.lua @@ -3544,6 +3544,8 @@ files { MAME_DIR .. "src/mame/machine/xavix_madfb_ball.h", MAME_DIR .. "src/mame/machine/xavix_io.cpp", MAME_DIR .. "src/mame/machine/xavix_io.h", + MAME_DIR .. "src/mame/machine/xavix_adc.cpp", + MAME_DIR .. "src/mame/machine/xavix_adc.h", MAME_DIR .. "src/mame/machine/xavix2002_io.cpp", MAME_DIR .. "src/mame/machine/xavix2002_io.h", MAME_DIR .. "src/mame/drivers/xavix2.cpp", diff --git a/src/mame/drivers/vii.cpp b/src/mame/drivers/vii.cpp index 98567f1c082..c4e4457b661 100644 --- a/src/mame/drivers/vii.cpp +++ b/src/mame/drivers/vii.cpp @@ -1220,7 +1220,7 @@ static INPUT_PORTS_START( icanpian ) PORT_BIT( 0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_ASTERISK) PORT_NAME("Tempo Default") PORT_BIT( 0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_MINUS_PAD) PORT_NAME("Tempo Down") PORT_BIT( 0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_7_PAD) PORT_NAME("Pause") - PORT_BIT( 0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_8_PAD) PORT_NAME("Metronome") // is one of these the metronome button? + PORT_BIT( 0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_8_PAD) PORT_NAME("Metronome") PORT_BIT( 0x0020, IP_ACTIVE_HIGH, IPT_UNUSED ) // will skip intro scenes etc. like other buttons but no more physical buttons on KB to map here PORT_BIT( 0xffc0, IP_ACTIVE_HIGH, IPT_UNKNOWN ) diff --git a/src/mame/drivers/xavix.cpp b/src/mame/drivers/xavix.cpp index e5f3630d937..4da43b3a2ad 100644 --- a/src/mame/drivers/xavix.cpp +++ b/src/mame/drivers/xavix.cpp @@ -381,8 +381,8 @@ void xavix_state::xavix_lowbus_map(address_map &map) //map(0x7b18, 0x7b1b) // ADC registers - map(0x7b80, 0x7b80).rw(FUNC(xavix_state::adc_7b80_r), FUNC(xavix_state::adc_7b80_w)); // rad_snow (not often) - map(0x7b81, 0x7b81).rw(FUNC(xavix_state::adc_7b81_r), FUNC(xavix_state::adc_7b81_w)); // written (often, m_trck, analog related?) + map(0x7b80, 0x7b80).rw("adc", FUNC(xavix_adc_device::adc_7b80_r), FUNC(xavix_adc_device::adc_7b80_w)); // rad_snow (not often) + map(0x7b81, 0x7b81).rw("adc", FUNC(xavix_adc_device::adc_7b81_r), FUNC(xavix_adc_device::adc_7b81_w)); // written (often, m_trck, analog related?) // Sleep control //map(0x7b82, 0x7b83) @@ -889,202 +889,12 @@ static INPUT_PORTS_START( popira2 ) // player 2 buttons have heavy latency, prob PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_POWER_OFF ) PORT_NAME("Power Switch") // pressing this will turn the game off. PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNUSED ) - PORT_MODIFY("AN0") // 00 - PORT_DIPNAME( 0x0001, 0x0001, "AN0" ) - PORT_DIPSETTING( 0x0001, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPNAME( 0x0002, 0x0002, DEF_STR( Unknown ) ) - PORT_DIPSETTING( 0x0002, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPNAME( 0x0004, 0x0004, DEF_STR( Unknown ) ) - PORT_DIPSETTING( 0x0004, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPNAME( 0x0008, 0x0008, DEF_STR( Unknown ) ) - PORT_DIPSETTING( 0x0008, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNKNOWN ) // buttons respond in a strange way if these are high - PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNKNOWN ) - PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("P2 Pad 1") PORT_PLAYER(2) - PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("P2 Pad 2") PORT_PLAYER(2) - - PORT_MODIFY("AN1") // 01 - PORT_DIPNAME( 0x0001, 0x0001, "AN1" ) - PORT_DIPSETTING( 0x0001, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPNAME( 0x0002, 0x0002, DEF_STR( Unknown ) ) - PORT_DIPSETTING( 0x0002, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPNAME( 0x0004, 0x0004, DEF_STR( Unknown ) ) - PORT_DIPSETTING( 0x0004, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPNAME( 0x0008, 0x0008, DEF_STR( Unknown ) ) - PORT_DIPSETTING( 0x0008, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNKNOWN ) // buttons respond in a strange way if these are high - PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNKNOWN ) - PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_NAME("P2 Pad 3") PORT_PLAYER(2) - PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_NAME("P2 Pad 4") PORT_PLAYER(2) - - PORT_MODIFY("AN2") // 02 - PORT_DIPNAME( 0x0001, 0x0001, "AN2" ) - PORT_DIPSETTING( 0x0001, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPNAME( 0x0002, 0x0002, DEF_STR( Unknown ) ) - PORT_DIPSETTING( 0x0002, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPNAME( 0x0004, 0x0004, DEF_STR( Unknown ) ) - PORT_DIPSETTING( 0x0004, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPNAME( 0x0008, 0x0008, DEF_STR( Unknown ) ) - PORT_DIPSETTING( 0x0008, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPNAME( 0x0010, 0x0010, DEF_STR( Unknown ) ) - PORT_DIPSETTING( 0x0010, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPNAME( 0x0020, 0x0020, DEF_STR( Unknown ) ) - PORT_DIPSETTING( 0x0020, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPNAME( 0x0040, 0x0040, DEF_STR( Unknown ) ) - PORT_DIPSETTING( 0x0040, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Unknown ) ) - PORT_DIPSETTING( 0x0080, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - - - PORT_MODIFY("AN3") // 03 - PORT_DIPNAME( 0x0001, 0x0001, "AN3" ) - PORT_DIPSETTING( 0x0001, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPNAME( 0x0002, 0x0002, DEF_STR( Unknown ) ) - PORT_DIPSETTING( 0x0002, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPNAME( 0x0004, 0x0004, DEF_STR( Unknown ) ) - PORT_DIPSETTING( 0x0004, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPNAME( 0x0008, 0x0008, DEF_STR( Unknown ) ) - PORT_DIPSETTING( 0x0008, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPNAME( 0x0010, 0x0010, DEF_STR( Unknown ) ) - PORT_DIPSETTING( 0x0010, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPNAME( 0x0020, 0x0020, DEF_STR( Unknown ) ) - PORT_DIPSETTING( 0x0020, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPNAME( 0x0040, 0x0040, DEF_STR( Unknown ) ) - PORT_DIPSETTING( 0x0040, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Unknown ) ) - PORT_DIPSETTING( 0x0080, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - - - - PORT_MODIFY("AN4") // 10 - PORT_DIPNAME( 0x0001, 0x0001, "AN4" ) - PORT_DIPSETTING( 0x0001, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPNAME( 0x0002, 0x0002, DEF_STR( Unknown ) ) - PORT_DIPSETTING( 0x0002, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPNAME( 0x0004, 0x0004, DEF_STR( Unknown ) ) - PORT_DIPSETTING( 0x0004, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPNAME( 0x0008, 0x0008, DEF_STR( Unknown ) ) - PORT_DIPSETTING( 0x0008, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPNAME( 0x0010, 0x0010, DEF_STR( Unknown ) ) - PORT_DIPSETTING( 0x0010, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPNAME( 0x0020, 0x0020, DEF_STR( Unknown ) ) - PORT_DIPSETTING( 0x0020, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPNAME( 0x0040, 0x0040, DEF_STR( Unknown ) ) - PORT_DIPSETTING( 0x0040, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Unknown ) ) - PORT_DIPSETTING( 0x0080, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - - - PORT_MODIFY("AN5") // 11 - PORT_DIPNAME( 0x0001, 0x0001, "AN5" ) - PORT_DIPSETTING( 0x0001, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPNAME( 0x0002, 0x0002, DEF_STR( Unknown ) ) - PORT_DIPSETTING( 0x0002, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPNAME( 0x0004, 0x0004, DEF_STR( Unknown ) ) - PORT_DIPSETTING( 0x0004, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPNAME( 0x0008, 0x0008, DEF_STR( Unknown ) ) - PORT_DIPSETTING( 0x0008, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPNAME( 0x0010, 0x0010, DEF_STR( Unknown ) ) - PORT_DIPSETTING( 0x0010, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPNAME( 0x0020, 0x0020, DEF_STR( Unknown ) ) - PORT_DIPSETTING( 0x0020, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPNAME( 0x0040, 0x0040, DEF_STR( Unknown ) ) - PORT_DIPSETTING( 0x0040, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Unknown ) ) - PORT_DIPSETTING( 0x0080, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - - PORT_MODIFY("AN6") // 12 - PORT_DIPNAME( 0x0001, 0x0001, "AN6" ) - PORT_DIPSETTING( 0x0001, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPNAME( 0x0002, 0x0002, DEF_STR( Unknown ) ) - PORT_DIPSETTING( 0x0002, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPNAME( 0x0004, 0x0004, DEF_STR( Unknown ) ) - PORT_DIPSETTING( 0x0004, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPNAME( 0x0008, 0x0008, DEF_STR( Unknown ) ) - PORT_DIPSETTING( 0x0008, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPNAME( 0x0010, 0x0010, DEF_STR( Unknown ) ) - PORT_DIPSETTING( 0x0010, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPNAME( 0x0020, 0x0020, DEF_STR( Unknown ) ) - PORT_DIPSETTING( 0x0020, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPNAME( 0x0040, 0x0040, DEF_STR( Unknown ) ) - PORT_DIPSETTING( 0x0040, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Unknown ) ) - PORT_DIPSETTING( 0x0080, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - - - PORT_MODIFY("AN7") // 13 - PORT_DIPNAME( 0x0001, 0x0001, "AN7" ) - PORT_DIPSETTING( 0x0001, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPNAME( 0x0002, 0x0002, DEF_STR( Unknown ) ) - PORT_DIPSETTING( 0x0002, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPNAME( 0x0004, 0x0004, DEF_STR( Unknown ) ) - PORT_DIPSETTING( 0x0004, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPNAME( 0x0008, 0x0008, DEF_STR( Unknown ) ) - PORT_DIPSETTING( 0x0008, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPNAME( 0x0010, 0x0010, DEF_STR( Unknown ) ) - PORT_DIPSETTING( 0x0010, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPNAME( 0x0020, 0x0020, DEF_STR( Unknown ) ) - PORT_DIPSETTING( 0x0020, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPNAME( 0x0040, 0x0040, DEF_STR( Unknown ) ) - PORT_DIPSETTING( 0x0040, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) - PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Unknown ) ) - PORT_DIPSETTING( 0x0080, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) + // main input processing code is at 028059, which ends with setting a timer (028079) to read analog ports and get these buttons that way. main timer handler is at 00eb77, which reads ports via the ADC. $c3 where ports are stored is also checked at 00e6f4 + PORT_START("P2") + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("P2 Pad 1") PORT_PLAYER(2) + PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("P2 Pad 2") PORT_PLAYER(2) + PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_NAME("P2 Pad 3") PORT_PLAYER(2) + PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_NAME("P2 Pad 4") PORT_PLAYER(2) INPUT_PORTS_END @@ -1235,8 +1045,12 @@ static INPUT_PORTS_START( ttv_mx ) PORT_MODIFY("IN0") PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1 ) // Accel PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON2 ) // Brake - PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) - PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) + PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_NAME("Pause") + PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_UNUSED ) + PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_NAME("Motion Up") // you tilt the device, but actual inputs are digital + PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_NAME("Motion Down") + PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_NAME("Motion Left") + PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_NAME("Motion Right") INPUT_PORTS_END @@ -1387,6 +1201,16 @@ void xavix_state::xavix(machine_config &config) ADDRESS_MAP_BANK(config, "lowbus").set_map(&xavix_state::xavix_lowbus_map).set_options(ENDIANNESS_LITTLE, 8, 24, 0x8000); + XAVIX_ADC(config, m_adc, 0); + m_adc->read_0_callback().set(FUNC(xavix_state::adc0_r)); + m_adc->read_1_callback().set(FUNC(xavix_state::adc1_r)); + m_adc->read_2_callback().set(FUNC(xavix_state::adc2_r)); + m_adc->read_3_callback().set(FUNC(xavix_state::adc3_r)); + m_adc->read_4_callback().set(FUNC(xavix_state::adc4_r)); + m_adc->read_5_callback().set(FUNC(xavix_state::adc5_r)); + m_adc->read_6_callback().set(FUNC(xavix_state::adc6_r)); + m_adc->read_7_callback().set(FUNC(xavix_state::adc7_r)); + /* video hardware */ SCREEN(config, m_screen, SCREEN_TYPE_RASTER); m_screen->set_refresh_hz(60); @@ -1624,6 +1448,43 @@ void xavix_cart_state::xavix_cart_popira(machine_config &config) SOFTWARE_LIST(config, "cart_list_japan_sp").set_original("ekara_japan_sp"); } +// see code at 028060, using table from 00eb6d for conversion +READ8_MEMBER(xavix_popira2_cart_state::popira2_adc0_r) +{ + uint8_t p2 = ioport("P2")->read() & 0x03; + switch (p2) + { + case 0x00: return 0xa0; + case 0x01: return 0x60; + case 0x02: return 0x10; + case 0x03: return 0x00; + } + + return 0x00; +} + +READ8_MEMBER(xavix_popira2_cart_state::popira2_adc1_r) +{ + uint8_t p2 = (ioport("P2")->read() >> 2) & 0x03; + switch (p2) + { + case 0x00: return 0xa0; + case 0x01: return 0x60; + case 0x02: return 0x10; + case 0x03: return 0x00; + } + + return 0x00; +} + +void xavix_popira2_cart_state::xavix_cart_popira2(machine_config &config) +{ + xavix_cart_popira(config); + + m_adc->read_0_callback().set(FUNC(xavix_popira2_cart_state::popira2_adc0_r)); + m_adc->read_1_callback().set(FUNC(xavix_popira2_cart_state::popira2_adc1_r)); +} + void xavix_cart_state::xavix_cart_ddrfammt(machine_config &config) { xavix_cart(config); @@ -2037,7 +1898,7 @@ CONS( 2001, ddrfammt, 0, 0, xavix_cart_ddrfammt,ddrfammt, xavix_cart_ CONS( 2000, popira, 0, 0, xavix_cart_popira,popira, xavix_cart_state, init_xavix, "Takara / SSD Company LTD", "Popira (Japan)", MACHINE_IMPERFECT_SOUND/*|MACHINE_IS_BIOS_ROOT*/ ) // The original Popira is a single yellow unit -CONS( 2002, popira2, 0, 0, xavix_cart_popira,popira2, xavix_popira2_cart_state, init_xavix, "Takara / SSD Company LTD", "Popira 2 (Japan)", MACHINE_NOT_WORKING | MACHINE_IMPERFECT_SOUND/*|MACHINE_IS_BIOS_ROOT*/ ) // Popira 2 is a set of 2 blue & green linked units (2nd unit is just a controller, no CPU or TV out) +CONS( 2002, popira2, 0, 0, xavix_cart_popira2,popira2, xavix_popira2_cart_state, init_xavix, "Takara / SSD Company LTD", "Popira 2 (Japan)", MACHINE_IMPERFECT_SOUND/*|MACHINE_IS_BIOS_ROOT*/ ) // Popira 2 is a set of 2 blue & green linked units (2nd unit is just a controller, no CPU or TV out) CONS( 2003, taikodp, 0, 0, xavix_i2c_taiko, taikodp, xavix_i2c_cart_state, init_xavix, "Takara / SSD Company LTD", "Taiko De Popira (Japan)", MACHINE_NOT_WORKING | MACHINE_IMPERFECT_SOUND /*|MACHINE_IS_BIOS_ROOT*/ ) // inputs? are the drums analog? diff --git a/src/mame/includes/xavix.h b/src/mame/includes/xavix.h index 9bcd83ac4cc..176f534d5d6 100644 --- a/src/mame/includes/xavix.h +++ b/src/mame/includes/xavix.h @@ -20,6 +20,7 @@ #include "machine/xavix_madfb_ball.h" #include "machine/xavix2002_io.h" #include "machine/xavix_io.h" +#include "machine/xavix_adc.h" class xavix_sound_device : public device_t, public device_sound_interface { @@ -101,6 +102,7 @@ public: m_region(*this, "REGION"), m_gfxdecode(*this, "gfxdecode"), m_sound(*this, "xavix_sound"), + m_adc(*this, "adc"), m_xavix2002io(*this, "xavix2002io") { } @@ -285,14 +287,6 @@ private: DECLARE_WRITE8_MEMBER(mouse_7b10_w); DECLARE_WRITE8_MEMBER(mouse_7b11_w); - DECLARE_READ8_MEMBER(adc_7b80_r); - DECLARE_WRITE8_MEMBER(adc_7b80_w); - DECLARE_READ8_MEMBER(adc_7b81_r); - DECLARE_WRITE8_MEMBER(adc_7b81_w); - TIMER_CALLBACK_MEMBER(adc_timer_done); - emu_timer *m_adc_timer; - uint8_t m_adc_control; - DECLARE_WRITE8_MEMBER(slotreg_7810_w); DECLARE_WRITE8_MEMBER(rom_dmatrg_w); @@ -323,8 +317,6 @@ private: uint8_t m_io0_direction; uint8_t m_io1_direction; - uint8_t m_adc_inlatch; - DECLARE_READ8_MEMBER(nmi_vector_lo_r); DECLARE_READ8_MEMBER(nmi_vector_hi_r); DECLARE_READ8_MEMBER(irq_vector_lo_r); @@ -476,6 +468,14 @@ private: DECLARE_READ8_MEMBER(barrel_r); DECLARE_WRITE8_MEMBER(barrel_w); + DECLARE_READ8_MEMBER(adc0_r) { return m_an_in[0]->read(); }; + DECLARE_READ8_MEMBER(adc1_r) { return m_an_in[1]->read(); }; + DECLARE_READ8_MEMBER(adc2_r) { return m_an_in[2]->read(); }; + DECLARE_READ8_MEMBER(adc3_r) { return m_an_in[3]->read(); }; + DECLARE_READ8_MEMBER(adc4_r) { return m_an_in[4]->read(); }; + DECLARE_READ8_MEMBER(adc5_r) { return m_an_in[5]->read(); }; + DECLARE_READ8_MEMBER(adc6_r) { return m_an_in[6]->read(); }; + DECLARE_READ8_MEMBER(adc7_r) { return m_an_in[7]->read(); }; void update_irqs(); uint8_t m_irqsource; @@ -575,6 +575,7 @@ private: DECLARE_READ8_MEMBER(sound_regram_read_cb); protected: + required_device m_adc; optional_device m_xavix2002io; uint8_t m_extbusctrl[3]; @@ -920,11 +921,16 @@ public: : xavix_cart_state(mconfig,type,tag) { } + void xavix_cart_popira2(machine_config &config); + DECLARE_CUSTOM_INPUT_MEMBER(i2c_r); protected: virtual void write_io1(uint8_t data, uint8_t direction) override; +private: + DECLARE_READ8_MEMBER(popira2_adc0_r); + DECLARE_READ8_MEMBER(popira2_adc1_r); }; diff --git a/src/mame/machine/xavix.cpp b/src/mame/machine/xavix.cpp index 2745b98b078..4eef98c39c5 100644 --- a/src/mame/machine/xavix.cpp +++ b/src/mame/machine/xavix.cpp @@ -310,52 +310,6 @@ WRITE8_MEMBER(xavix_state::mouse_7b11_w) -READ8_MEMBER(xavix_state::adc_7b80_r) -{ - LOG("%s: adc_7b80_r\n", machine().describe_context()); - return m_adc_inlatch; -} - -WRITE8_MEMBER(xavix_state::adc_7b80_w) -{ - // is the latch writeable? - LOG("%s: adc_7b80_w %02x\n", machine().describe_context(), data); -} - -WRITE8_MEMBER(xavix_state::adc_7b81_w) -{ -// m_irqsource &= ~0x04; -// update_irqs(); - - LOG("%s: adc_7b81_w %02x\n", machine().describe_context(), data); - m_adc_control = data; - - // bit 0x40 = run? or IRQ? (doesn't seem to be any obvious way to clear IRQs tho, ADC handling is usually done in timer IRQ?) - // should probably set latch after a timer has expired not instantly? - // bits 0x0c are not port select? - // bit 0x80 is some kind of ack? / done flag? - switch (m_adc_control & 0x13) - { - case 0x00: m_adc_inlatch = m_an_in[0]->read(); break; - case 0x01: m_adc_inlatch = m_an_in[1]->read(); break; - case 0x02: m_adc_inlatch = m_an_in[2]->read(); break; - case 0x03: m_adc_inlatch = m_an_in[3]->read(); break; - case 0x10: m_adc_inlatch = m_an_in[4]->read(); break; - case 0x11: m_adc_inlatch = m_an_in[5]->read(); break; - case 0x12: m_adc_inlatch = m_an_in[6]->read(); break; - case 0x13: m_adc_inlatch = m_an_in[7]->read(); break; - } - -// m_adc_timer->adjust(attotime::from_usec(200)); -} - -READ8_MEMBER(xavix_state::adc_7b81_r) -{ -// has_wamg polls this if interrupt is enabled - return machine().rand(); -} - - WRITE8_MEMBER(xavix_state::slotreg_7810_w) { @@ -915,12 +869,6 @@ TIMER_CALLBACK_MEMBER(xavix_state::freq_timer_done) //m_freq_timer->adjust(attotime::from_usec(50000)); } -TIMER_CALLBACK_MEMBER(xavix_state::adc_timer_done) -{ - //m_irqsource |= 0x04; - //update_irqs(); -} - // epo_guru uses this for ground movement in 3d stages (and other places) READ8_MEMBER(xavix_state::barrel_r) { @@ -1073,7 +1021,6 @@ void xavix_state::machine_start() m_interrupt_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(xavix_state::interrupt_gen), this)); m_freq_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(xavix_state::freq_timer_done), this)); - m_adc_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(xavix_state::adc_timer_done), this)); for (int i = 0; i < 4; i++) { @@ -1091,7 +1038,6 @@ void xavix_state::machine_start() save_item(NAME(m_io1_data)); save_item(NAME(m_io0_direction)); save_item(NAME(m_io1_direction)); - save_item(NAME(m_adc_control)); save_item(NAME(m_sound_irqstatus)); save_item(NAME(m_soundreg16_0)); save_item(NAME(m_soundreg16_1)); @@ -1191,7 +1137,6 @@ void xavix_state::machine_reset() m_sound_regbase = 0x02; // rad_bb doesn't initialize this and expects it here. It is possible the default is 0x00, but since 0x00 and 0x01 are special (zero page and stack) those values would also use bank 0x02 - m_adc_control = 0x00; m_sprite_xhigh_ignore_hack = true; diff --git a/src/mame/machine/xavix_adc.cpp b/src/mame/machine/xavix_adc.cpp new file mode 100644 index 00000000000..6d171c8018d --- /dev/null +++ b/src/mame/machine/xavix_adc.cpp @@ -0,0 +1,100 @@ +// license:BSD-3-Clause +// copyright-holders:David Haywood + +#include "emu.h" +#include "xavix_adc.h" + +#define VERBOSE 0 +#include "logmacro.h" + +DEFINE_DEVICE_TYPE(XAVIX_ADC, xavix_adc_device, "xavix_adc", "XaviX ADC") + +xavix_adc_device::xavix_adc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : device_t(mconfig, XAVIX_ADC, tag, owner, clock) + , m_in0_cb(*this) + , m_in1_cb(*this) + , m_in2_cb(*this) + , m_in3_cb(*this) + , m_in4_cb(*this) + , m_in5_cb(*this) + , m_in6_cb(*this) + , m_in7_cb(*this) +{ +} + +void xavix_adc_device::device_start() +{ + m_in0_cb.resolve_safe(0xff); + m_in1_cb.resolve_safe(0xff); + m_in2_cb.resolve_safe(0xff); + m_in3_cb.resolve_safe(0xff); + m_in4_cb.resolve_safe(0xff); + m_in5_cb.resolve_safe(0xff); + m_in6_cb.resolve_safe(0xff); + m_in7_cb.resolve_safe(0xff); + + m_adc_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(xavix_adc_device::adc_timer_done), this)); + + save_item(NAME(m_adc_control)); + save_item(NAME(m_adc_inlatch)); +} + +TIMER_CALLBACK_MEMBER(xavix_adc_device::adc_timer_done) +{ + //m_irqsource |= 0x04; + //update_irqs(); +} + +void xavix_adc_device::device_reset() +{ + m_adc_control = 0x00; + m_adc_inlatch = 0xff; +} + + +READ8_MEMBER(xavix_adc_device::adc_7b80_r) +{ + LOG("%s: adc_7b80_r\n", machine().describe_context()); + return m_adc_inlatch; +} + +WRITE8_MEMBER(xavix_adc_device::adc_7b80_w) +{ + // is the latch writeable? + LOG("%s: adc_7b80_w %02x\n", machine().describe_context(), data); +} + +WRITE8_MEMBER(xavix_adc_device::adc_7b81_w) +{ +// m_irqsource &= ~0x04; +// update_irqs(); + + LOG("%s: adc_7b81_w %02x\n", machine().describe_context(), data); + m_adc_control = data; + + // bit 0x40 = run? or IRQ? (doesn't seem to be any obvious way to clear IRQs tho, ADC handling is usually done in timer IRQ?) + // should probably set latch after a timer has expired not instantly? + // bits 0x0c are not port select? + // bit 0x80 is some kind of ack? / done flag? + switch (m_adc_control & 0x13) + { + case 0x00: m_adc_inlatch = m_in0_cb(); break; + case 0x01: m_adc_inlatch = m_in1_cb(); break; + case 0x02: m_adc_inlatch = m_in2_cb(); break; + case 0x03: m_adc_inlatch = m_in3_cb(); break; + case 0x10: m_adc_inlatch = m_in4_cb(); break; + case 0x11: m_adc_inlatch = m_in5_cb(); break; + case 0x12: m_adc_inlatch = m_in6_cb(); break; + case 0x13: m_adc_inlatch = m_in7_cb(); break; + } + +// m_adc_timer->adjust(attotime::from_usec(200)); +} + +READ8_MEMBER(xavix_adc_device::adc_7b81_r) +{ +// has_wamg polls this if interrupt is enabled + return machine().rand(); +} + + diff --git a/src/mame/machine/xavix_adc.h b/src/mame/machine/xavix_adc.h new file mode 100644 index 00000000000..5bf524eb9d8 --- /dev/null +++ b/src/mame/machine/xavix_adc.h @@ -0,0 +1,50 @@ +// license:BSD-3-Clause +// copyright-holders:David Haywood + +#ifndef MAME_MACHINE_XAVIX_ADC_H +#define MAME_MACHINE_XAVIX_ADC_H + +class xavix_adc_device : public device_t +{ +public: + xavix_adc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + + auto read_0_callback() { return m_in0_cb.bind(); } + auto read_1_callback() { return m_in1_cb.bind(); } + auto read_2_callback() { return m_in2_cb.bind(); } + auto read_3_callback() { return m_in3_cb.bind(); } + auto read_4_callback() { return m_in4_cb.bind(); } + auto read_5_callback() { return m_in5_cb.bind(); } + auto read_6_callback() { return m_in6_cb.bind(); } + auto read_7_callback() { return m_in7_cb.bind(); } + + DECLARE_READ8_MEMBER(adc_7b80_r); + DECLARE_WRITE8_MEMBER(adc_7b80_w); + DECLARE_READ8_MEMBER(adc_7b81_r); + DECLARE_WRITE8_MEMBER(adc_7b81_w); + +protected: + // device-level overrides + virtual void device_start() override; + virtual void device_reset() override; + +private: + devcb_read8 m_in0_cb; + devcb_read8 m_in1_cb; + devcb_read8 m_in2_cb; + devcb_read8 m_in3_cb; + devcb_read8 m_in4_cb; + devcb_read8 m_in5_cb; + devcb_read8 m_in6_cb; + devcb_read8 m_in7_cb; + + uint8_t m_adc_inlatch; + uint8_t m_adc_control; + emu_timer *m_adc_timer; + + TIMER_CALLBACK_MEMBER(adc_timer_done); +}; + +DECLARE_DEVICE_TYPE(XAVIX_ADC, xavix_adc_device) + +#endif // MAME_MACHINE_XAVIX_ADC_H -- cgit v1.2.3