From 02c3f2635cd10f7f0ea4923027075db3eef03569 Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Mon, 2 Dec 2024 07:09:17 +1100 Subject: dynax/ddenlovr.cpp, dynax/dynax.cpp: More I/O improvements: * Fixed 2P side inputs for tenkai, ougonhai and mjmyster. * Use hanafuda input types for hginga. * Use proper bookkeeping and memory reset inputs for hginga and hanakanz. * Started using I/O port finders for mahjong keyboards. * More side effects checks. * Reduced some duplication. --- scripts/target/mame/tiny.lua | 4 +- src/devices/machine/nscsi_bus.cpp | 2 +- src/mame/dynax/ddenlovr.cpp | 205 ++++++++++++------------------- src/mame/dynax/dynax.cpp | 247 ++++++++++++++++---------------------- src/mame/dynax/dynax.h | 16 +-- 5 files changed, 192 insertions(+), 282 deletions(-) diff --git a/scripts/target/mame/tiny.lua b/scripts/target/mame/tiny.lua index 402027691c1..246282a344a 100644 --- a/scripts/target/mame/tiny.lua +++ b/scripts/target/mame/tiny.lua @@ -154,12 +154,12 @@ files{ MAME_DIR .. "src/mame/shared/s11c_bg.h", MAME_DIR .. "src/mame/shared/williamssound.cpp", MAME_DIR .. "src/mame/shared/williamssound.h", - MAME_DIR .. "src/mame/midway/williamsblitter.cpp", - MAME_DIR .. "src/mame/midway/williamsblitter.h", MAME_DIR .. "src/mame/midway/williams.cpp", MAME_DIR .. "src/mame/midway/williams.h", MAME_DIR .. "src/mame/midway/williams_m.cpp", MAME_DIR .. "src/mame/midway/williams_v.cpp", + MAME_DIR .. "src/mame/midway/williamsblitter.cpp", + MAME_DIR .. "src/mame/midway/williamsblitter.h", MAME_DIR .. "src/mame/gaelco/gaelco.cpp", MAME_DIR .. "src/mame/gaelco/gaelco.h", MAME_DIR .. "src/mame/gaelco/gaelco_v.cpp", diff --git a/src/devices/machine/nscsi_bus.cpp b/src/devices/machine/nscsi_bus.cpp index f9b73ec5540..9b68dec2101 100644 --- a/src/devices/machine/nscsi_bus.cpp +++ b/src/devices/machine/nscsi_bus.cpp @@ -15,7 +15,7 @@ #define LOG_DATA_SENT (1U << 5) #define VERBOSE (LOG_UNSUPPORTED) -#define LOG_OUTPUT_FUNC osd_printf_info +//#define LOG_OUTPUT_FUNC osd_printf_info #include "logmacro.h" diff --git a/src/mame/dynax/ddenlovr.cpp b/src/mame/dynax/ddenlovr.cpp index b02e02ee5ef..c0c6d600552 100644 --- a/src/mame/dynax/ddenlovr.cpp +++ b/src/mame/dynax/ddenlovr.cpp @@ -288,7 +288,6 @@ private: uint8_t rongrong_input_r(); void rongrong_select_w(uint8_t data); protected: - void hanakanz_keyb_w(uint8_t data); uint8_t hanakanz_rand_r(); private: void mjschuka_protection_w(uint8_t data); @@ -600,7 +599,6 @@ private: void hanakanz_blitter_data_w(uint8_t data); void hanakanz_rombank_w(uint8_t data); - //void hanakanz_keyb_w(uint8_t data); void hanakanz_dsw_w(uint8_t data); uint8_t hanakanz_keyb_r(offs_t offset); uint8_t hanakanz_dsw_r(); @@ -2774,11 +2772,6 @@ void hanakanz_state::hanakanz_map(address_map &map) } -void ddenlovr_state::hanakanz_keyb_w(uint8_t data) -{ - m_keyb = data; -} - void hanakanz_state::hanakanz_dsw_w(uint8_t data) { m_dsw_sel = data; @@ -2786,13 +2779,7 @@ void hanakanz_state::hanakanz_dsw_w(uint8_t data) uint8_t hanakanz_state::hanakanz_keyb_r(offs_t offset) { - uint8_t val = 0xff; - - if (!BIT(m_keyb, 0)) val = ioport(offset ? "KEY5" : "KEY0")->read(); - else if (!BIT(m_keyb, 1)) val = ioport(offset ? "KEY6" : "KEY1")->read(); - else if (!BIT(m_keyb, 2)) val = ioport(offset ? "KEY7" : "KEY2")->read(); - else if (!BIT(m_keyb, 3)) val = ioport(offset ? "KEY8" : "KEY3")->read(); - else if (!BIT(m_keyb, 4)) val = ioport(offset ? "KEY9" : "KEY4")->read(); + uint8_t val = offset ? hanamai_keyboard_r<1>() : hanamai_keyboard_r<0>(); val |= ioport(offset ? "HOPPER" : "BET")->read(); return val; @@ -2896,7 +2883,7 @@ void hanakanz_state::hanakanz_portmap(address_map &map) map(0x90, 0x90).portr("SYSTEM"); map(0x91, 0x92).r(FUNC(hanakanz_state::hanakanz_keyb_r)); map(0x93, 0x93).w(FUNC(hanakanz_state::hanakanz_coincounter_w)); - map(0x94, 0x94).w(FUNC(hanakanz_state::hanakanz_keyb_w)); + map(0x94, 0x94).w(FUNC(hanakanz_state::hanamai_keyboard_w)); map(0x96, 0x96).r(FUNC(hanakanz_state::hanakanz_rand_r)); map(0xa0, 0xa1).w("ym2413", FUNC(ym2413_device::write)); map(0xc0, 0xc0).rw(m_oki, FUNC(okim6295_device::read), FUNC(okim6295_device::write)); @@ -2914,7 +2901,7 @@ void hanakanz_state::hkagerou_portmap(address_map &map) map(0xb0, 0xb0).portr("SYSTEM"); map(0xb1, 0xb2).r(FUNC(hanakanz_state::hanakanz_keyb_r)); map(0xb3, 0xb3).w(FUNC(hanakanz_state::hanakanz_coincounter_w)); - map(0xb4, 0xb4).w(FUNC(hanakanz_state::hanakanz_keyb_w)); + map(0xb4, 0xb4).w(FUNC(hanakanz_state::hanamai_keyboard_w)); map(0xb6, 0xb6).r(FUNC(hanakanz_state::hanakanz_rand_r)); map(0xc0, 0xc0).rw(m_oki, FUNC(okim6295_device::read), FUNC(okim6295_device::write)); map(0xe0, 0xef).rw("rtc", FUNC(msm6242_device::read), FUNC(msm6242_device::write)); @@ -2934,7 +2921,7 @@ void hanakanz_state::kotbinyo_portmap(address_map &map) map(0xb1, 0xb1).portr("KEYB0"); map(0xb2, 0xb2).portr("KEYB1"); map(0xb3, 0xb3).w(FUNC(hanakanz_state::hanakanz_coincounter_w)); -// map(0xb4, 0xb4).w(FUNC(hanakanz_state::hanakanz_keyb_w)); +// map(0xb4, 0xb4).w(FUNC(hanakanz_state::hanamai_keyboard_w)); map(0xb6, 0xb6).r(FUNC(hanakanz_state::hanakanz_rand_r)); map(0xc0, 0xc0).rw(m_oki, FUNC(okim6295_device::read), FUNC(okim6295_device::write)); // map(0xe0, 0xef).rw("rtc", FUNC(msm6242_device::read), FUNC(msm6242_device::write)); @@ -2954,7 +2941,7 @@ void hanakanz_state::kotbinsp_portmap(address_map &map) map(0x91, 0x91).portr("KEYB0"); map(0x92, 0x92).portr("KEYB1"); map(0x93, 0x93).w(FUNC(hanakanz_state::hanakanz_coincounter_w)); -// map(0x94, 0x94).w(FUNC(hanakanz_state::hanakanz_keyb_w)); +// map(0x94, 0x94).w(FUNC(hanakanz_state::hanamai_keyboard_w)); map(0x96, 0x96).r(FUNC(hanakanz_state::hanakanz_rand_r)); map(0xc0, 0xc0).rw(m_oki, FUNC(okim6295_device::read), FUNC(okim6295_device::write)); // map(0xe0, 0xef).rw("rtc", FUNC(msm6242_device::read), FUNC(msm6242_device::write)); @@ -2977,7 +2964,7 @@ void hanakanz_state::mjreach1_portmap(address_map &map) map(0x80, 0x80).w(FUNC(hanakanz_state::hanakanz_blitter_data_w)); map(0x81, 0x81).w(FUNC(hanakanz_state::hanakanz_palette_w)); map(0x83, 0x84).r(FUNC(hanakanz_state::hanakanz_gfxrom_r)); - map(0x90, 0x90).w(FUNC(hanakanz_state::hanakanz_keyb_w)); + map(0x90, 0x90).w(FUNC(hanakanz_state::hanamai_keyboard_w)); map(0x92, 0x92).r(FUNC(hanakanz_state::hanakanz_rand_r)); map(0x93, 0x93).rw(FUNC(hanakanz_state::mjreach1_protection_r), FUNC(hanakanz_state::mjreach1_protection_w)); map(0x94, 0x94).portr("SYSTEM"); @@ -2995,13 +2982,7 @@ void hanakanz_state::mjreach1_portmap(address_map &map) uint8_t hanakanz_state::mjchuuka_keyb_r(offs_t offset) { - uint8_t val = 0xff; - - if (!BIT(m_keyb, 0)) val = ioport(offset ? "KEY5" : "KEY0")->read(); - else if (!BIT(m_keyb, 1)) val = ioport(offset ? "KEY6" : "KEY1")->read(); - else if (!BIT(m_keyb, 2)) val = ioport(offset ? "KEY7" : "KEY2")->read(); - else if (!BIT(m_keyb, 3)) val = ioport(offset ? "KEY8" : "KEY3")->read(); - else if (!BIT(m_keyb, 4)) val = ioport(offset ? "KEY9" : "KEY4")->read(); + uint8_t val = hanakanz_keyb_r(offset); val |= ioport(offset ? "HOPPER" : "BET")->read(); @@ -3099,7 +3080,7 @@ void hanakanz_state::mjchuuka_portmap(address_map &map) map(0x21, 0x21).select(0xff00).w(FUNC(hanakanz_state::mjchuuka_palette_w)); map(0x23, 0x23).mirror(0xff00).r(FUNC(hanakanz_state::mjchuuka_gfxrom_0_r)); map(0x40, 0x40).mirror(0xff00).w(FUNC(hanakanz_state::mjchuuka_coincounter_w)); - map(0x41, 0x41).mirror(0xff00).w(FUNC(hanakanz_state::hanakanz_keyb_w)); + map(0x41, 0x41).mirror(0xff00).w(FUNC(hanakanz_state::hanamai_keyboard_w)); map(0x42, 0x42).mirror(0xff00).portr("SYSTEM"); map(0x43, 0x44).mirror(0xff00).r(FUNC(hanakanz_state::mjchuuka_keyb_r)); map(0x45, 0x45).mirror(0xff00).r(FUNC(hanakanz_state::mjchuuka_gfxrom_1_r)); @@ -3160,7 +3141,7 @@ void ddenlovr_state::mjschuka_portmap(address_map &map) map(0x5c, 0x5c).r(FUNC(ddenlovr_state::hanakanz_rand_r)); map(0x60, 0x60).w(FUNC(ddenlovr_state::sryudens_coincounter_w)); - map(0x61, 0x61).w(FUNC(ddenlovr_state::hanakanz_keyb_w)); + map(0x61, 0x61).w(FUNC(ddenlovr_state::hanamai_keyboard_w)); map(0x62, 0x62).portr("SYSTEM"); map(0x63, 0x64).r(FUNC(ddenlovr_state::sryudens_keyb_r)); @@ -3191,7 +3172,7 @@ void ddenlovr_state::mjmyorntr_portmap(address_map &map) map(0x40, 0x41).w(FUNC(ddenlovr_state::ddenlovr_blitter_w)); map(0x43, 0x43).r(FUNC(ddenlovr_state::ddenlovr_gfxrom_r)); map(0x50, 0x50).w(FUNC(ddenlovr_state::sryudens_coincounter_w)); - map(0x51, 0x51).w(FUNC(ddenlovr_state::hanakanz_keyb_w)); + map(0x51, 0x51).w(FUNC(ddenlovr_state::hanamai_keyboard_w)); map(0x52, 0x52).portr("SYSTEM"); map(0x53, 0x54).r(FUNC(ddenlovr_state::sryudens_keyb_r)); map(0x58, 0x58).portr("DSW1"); @@ -3236,7 +3217,7 @@ void ddenlovr_state::mjmyster_select2_w(uint8_t data) m_input_sel = data; if (data & 0x80) - m_keyb = 1; + m_keyb = 0; } uint8_t ddenlovr_state::mjmyster_coins_r() @@ -3258,14 +3239,17 @@ uint8_t ddenlovr_state::mjmyster_keyb_r() { uint8_t ret = 0xff; - if (BIT(m_keyb, 0)) ret = ioport("KEY0")->read(); - else if (BIT(m_keyb, 1)) ret = ioport("KEY1")->read(); - else if (BIT(m_keyb, 2)) ret = ioport("KEY2")->read(); - else if (BIT(m_keyb, 3)) ret = ioport("KEY3")->read(); - else if (BIT(m_keyb, 4)) ret = ioport("KEY4")->read(); - else logerror("%06x: warning, unknown bits read, keyb = %02x\n", m_maincpu->pc(), m_keyb); - - m_keyb <<= 1; + if (m_keyb < 5) + { + ret = m_io_key[BIT(m_input_sel, 0)][m_keyb]->read(); + if (!machine().side_effects_disabled()) + ++m_keyb; + } + else + { + if (!machine().side_effects_disabled()) + logerror("%06x: warning, unknown bits read, keyb = %02x\n", m_maincpu->pc(), m_keyb); + } return ret; } @@ -3420,24 +3404,28 @@ void ddenlovr_state::hginga_coins_w(uint8_t data) uint8_t ddenlovr_state::hginga_input_r() { - static const char *const keynames0[] = { "KEY0", "KEY1", "KEY2", "KEY3", "KEY4" }; - static const char *const keynames1[] = { "KEY5", "KEY6", "KEY7", "KEY8", "KEY9" }; - + uint8_t result = 0xff; switch (m_input_sel) { - case 0x2d: - return 0xff; + case 0x2d: + result = 0xff; + break; - // player 1 - case 0xa1: - return ioport(keynames0[m_keyb++])->read(); + case 0xa1: // player 1 + case 0xa2: // player 2 + if (m_keyb < 5) + { + result = m_io_key[BIT(m_input_sel, 1)][m_keyb]->read(); + if (!machine().side_effects_disabled()) + ++m_keyb; + } + break; - // player 2 - case 0xa2: - return ioport(keynames1[m_keyb++])->read(); + default: + if (!machine().side_effects_disabled()) + logerror("%04x: input_r with select = %02x\n", m_maincpu->pc(), m_input_sel); } - logerror("%04x: input_r with select = %02x\n", m_maincpu->pc(), m_input_sel); - return 0xff; + return result; } void ddenlovr_state::hginga_blitter_w(offs_t offset, uint8_t data) @@ -3500,7 +3488,7 @@ void ddenlovr_state::hginga_portmap(address_map &map) Hanafuda Hana Gokou ***************************************************************************/ -uint8_t ddenlovr_state::hgokou_player_r(int player ) +uint8_t ddenlovr_state::hgokou_player_r(int player) { uint8_t hopper_bit = ((m_hopper && !(m_screen->frame_number() % 10)) ? 0 : (1 << 6)); @@ -3540,8 +3528,8 @@ void ddenlovr_state::hgokou_input_w(uint8_t data) // bit 1 = out counter // bit 2 = hopper // bit 7 = ? - machine().bookkeeping().coin_counter_w(0, data & 1); - machine().bookkeeping().coin_counter_w(1, data & 2); + machine().bookkeeping().coin_counter_w(0, BIT(data, 0)); + machine().bookkeeping().coin_counter_w(1, BIT(data, 1)); m_hopper = data & 0x04; #ifdef MAME_DEBUG // popmessage("COINS %02x",data); @@ -4094,13 +4082,7 @@ void ddenlovr_state::sryudens_map(address_map &map) uint8_t ddenlovr_state::sryudens_keyb_r(offs_t offset) { - uint8_t val = 0x3f; - - if (!BIT(m_keyb, 0)) val = ioport(offset ? "KEY5" : "KEY0")->read(); - else if (!BIT(m_keyb, 1)) val = ioport(offset ? "KEY6" : "KEY1")->read(); - else if (!BIT(m_keyb, 2)) val = ioport(offset ? "KEY7" : "KEY2")->read(); - else if (!BIT(m_keyb, 3)) val = ioport(offset ? "KEY8" : "KEY3")->read(); - else if (!BIT(m_keyb, 4)) val = ioport(offset ? "KEY9" : "KEY4")->read(); + uint8_t val = offset ? hanamai_keyboard_r<1>() : hanamai_keyboard_r<0>(); val |= ioport(offset ? "HOPPER" : "BET")->read(); if (offset) @@ -4116,8 +4098,8 @@ void ddenlovr_state::sryudens_coincounter_w(uint8_t data) // bit 4 = ? on except during boot or test mode // bit 7 = ? mostly on - machine().bookkeeping().coin_counter_w(0, data & 1); - machine().bookkeeping().coin_counter_w(1, data & 2); + machine().bookkeeping().coin_counter_w(0, BIT(data, 0)); + machine().bookkeeping().coin_counter_w(1, BIT(data, 1)); m_hopper = data & 0x04; if (data & 0x68) @@ -4159,7 +4141,7 @@ void ddenlovr_state::sryudens_portmap(address_map &map) map(0x93, 0x93).portr("DSW3"); map(0x94, 0x94).portr("DSWTOP"); map(0x98, 0x98).w(FUNC(ddenlovr_state::sryudens_coincounter_w)); - map(0x99, 0x99).w(FUNC(ddenlovr_state::hanakanz_keyb_w)); + map(0x99, 0x99).w(FUNC(ddenlovr_state::hanamai_keyboard_w)); map(0x9a, 0x9a).portr("SYSTEM"); map(0x9b, 0x9c).r(FUNC(ddenlovr_state::sryudens_keyb_r)); } @@ -4205,7 +4187,7 @@ void ddenlovr_state::janshinp_portmap(address_map &map) map(0x03, 0x03).portr("DSW3"); map(0x04, 0x04).portr("DSWTOP"); map(0x08, 0x08).w(FUNC(ddenlovr_state::janshinp_coincounter_w)); - map(0x09, 0x09).w(FUNC(ddenlovr_state::hanakanz_keyb_w)); + map(0x09, 0x09).w(FUNC(ddenlovr_state::hanamai_keyboard_w)); map(0x0a, 0x0a).portr("SYSTEM"); map(0x0b, 0x0c).r(FUNC(ddenlovr_state::sryudens_keyb_r)); map(0x20, 0x23).w(FUNC(ddenlovr_state::ddenlovr_palette_base_w)); @@ -4373,7 +4355,8 @@ void htengoku_state::htengoku_coin_w(uint8_t data) // bit 0 = coin counter // bit 1 = out counter // bit 2 = hopper - machine().bookkeeping().coin_counter_w(0, data & 1); + machine().bookkeeping().coin_counter_w(0, BIT(data, 0)); + machine().bookkeeping().coin_counter_w(1, BIT(data, 1)); m_hopper = data & 0x04; #ifdef MAME_DEBUG // popmessage("COINS %02x",data); @@ -5027,7 +5010,7 @@ static INPUT_PORTS_START( htengoku ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_INCLUDE( HANAFUDA_KEYS_BET ) + PORT_INCLUDE( dynax_hanafuda_keys_bet ) PORT_START("DSW0") // IN11 - DSW1 PORT_DIPNAME( 0x01, 0x01, "Show Girls" ) @@ -5621,9 +5604,9 @@ static INPUT_PORTS_START( hanakanz ) PORT_START("SYSTEM") PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_GAMBLE_PAYOUT ) PORT_CODE(KEYCODE_4) // pay PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN) - PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME(DEF_STR( Test )) PORT_CODE(KEYCODE_F1) // Test - PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_SERVICE1 ) // analyzer - PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_SERVICE2 ) // data clear + PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME(DEF_STR( Test )) // Test + PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_GAMBLE_BOOK ) // analyzer + PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_MEMORY_RESET ) // data clear PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN2 ) // note PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN1) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN) @@ -7381,45 +7364,7 @@ static INPUT_PORTS_START( mjmyster ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN1) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN) - PORT_START("KEY0") - PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_A ) // A - PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_MAHJONG_E ) // E - PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_MAHJONG_I ) // I - PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_MAHJONG_M ) // M - PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_MAHJONG_KAN ) // Kan - PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_START1 ) // Start 1 - - PORT_START("KEY1") - PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_B ) // B - PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_MAHJONG_F ) // F - PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_MAHJONG_J ) // J - PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_MAHJONG_N ) // N - PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_MAHJONG_REACH ) // Reach - PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_MAHJONG_BET ) // BET - - PORT_START("KEY2") - PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_C ) // C - PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_MAHJONG_G ) // G - PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_MAHJONG_K ) // K - PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_MAHJONG_CHI ) // Chi - PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_MAHJONG_RON ) // Ron - PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN ) // nothing - - PORT_START("KEY3") - PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_D ) // D - PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_MAHJONG_H ) // H - PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_MAHJONG_L ) // L - PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_MAHJONG_PON ) // Pon - PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN ) // nothing - PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN ) // nothing - - PORT_START("KEY4") - PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_LAST_CHANCE ) // "l" - PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_MAHJONG_SCORE ) // "t" - PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_MAHJONG_DOUBLE_UP ) // "w" - PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_MAHJONG_FLIP_FLOP ) // Flip Flop - PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_MAHJONG_BIG ) // "b" - PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_MAHJONG_SMALL ) // "s" + PORT_INCLUDE( dynax_mahjong_keys_bet ) PORT_START("DSW1") PORT_DIPNAME( 0x0f, 0x07, "Pay Out Rate (%)" ) @@ -7554,31 +7499,31 @@ static INPUT_PORTS_START( hginga ) PORT_START("SYSTEM") PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_GAMBLE_PAYOUT ) PORT_CODE(KEYCODE_4) // pay // PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME(DEF_STR( Test )) PORT_CODE(KEYCODE_F1) // Test - PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_SERVICE1 ) // analyzer - PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_SERVICE2 ) // data clear + PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME(DEF_STR( Test )) // Test + PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_GAMBLE_BOOK ) // analyzer + PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_MEMORY_RESET ) // data clear PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN2 ) // note PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN1) // PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_START("KEY0") - PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_A ) PORT_PLAYER(2) // A - PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_MAHJONG_E ) PORT_PLAYER(2) // E + PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_HANAFUDA_A ) PORT_PLAYER(2) // A + PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_HANAFUDA_E ) PORT_PLAYER(2) // E PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN ) // I - PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_MAHJONG_M ) PORT_PLAYER(2) // M + PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_HANAFUDA_YES ) PORT_PLAYER(2) // M PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN ) // Kan PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_START2 ) PORT_START("KEY1") - PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_B ) PORT_PLAYER(2) // B - PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_MAHJONG_F ) PORT_PLAYER(2) // F + PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_HANAFUDA_B ) PORT_PLAYER(2) // B + PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_HANAFUDA_F ) PORT_PLAYER(2) // F PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN ) // J - PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_MAHJONG_N ) PORT_PLAYER(2) // N + PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_HANAFUDA_NO ) PORT_PLAYER(2) // N PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN ) // Reach PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_MAHJONG_BET ) PORT_PLAYER(2) // BET PORT_START("KEY2") - PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_C ) PORT_PLAYER(2) // C + PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_HANAFUDA_C ) PORT_PLAYER(2) // C PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN ) // G PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN ) // K PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN ) // Chi @@ -7586,7 +7531,7 @@ static INPUT_PORTS_START( hginga ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_START("KEY3") - PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_D ) PORT_PLAYER(2) // D + PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_HANAFUDA_D ) PORT_PLAYER(2) // D PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN ) // H PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN ) // L PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN ) // PON @@ -7602,23 +7547,23 @@ static INPUT_PORTS_START( hginga ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_MAHJONG_SMALL ) PORT_PLAYER(2) // "s" PORT_START("KEY5") - PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_A ) // A - PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_MAHJONG_E ) // E + PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_HANAFUDA_A ) // A + PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_HANAFUDA_E ) // E PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN ) // I - PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_MAHJONG_M ) // M + PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_HANAFUDA_YES ) // M PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN ) // Kan PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_START1 ) PORT_START("KEY6") - PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_B ) // B - PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_MAHJONG_F ) // F + PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_HANAFUDA_B ) // B + PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_HANAFUDA_F ) // F PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN ) // J - PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_MAHJONG_N ) // N + PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_HANAFUDA_NO ) // N PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN ) // Reach PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_MAHJONG_BET ) // BET PORT_START("KEY7") - PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_C ) // C + PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_HANAFUDA_C ) // C PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN ) // G PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN ) // K PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN ) // Chi @@ -7626,7 +7571,7 @@ static INPUT_PORTS_START( hginga ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_START("KEY8") - PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_D ) // D + PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_HANAFUDA_D ) // D PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN ) // H PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN ) // L PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN ) // PON @@ -10625,7 +10570,7 @@ void ddenlovr_state::mjflove(machine_config &config) maincpu.set_addrmap(AS_PROGRAM, &ddenlovr_state::rongrong_map); maincpu.set_addrmap(AS_IO, &ddenlovr_state::mjflove_portmap); maincpu.in_pa_callback().set_ioport("DSW2"); - maincpu.out_pb_callback().set(FUNC(ddenlovr_state::hanakanz_keyb_w)); + maincpu.out_pb_callback().set(FUNC(ddenlovr_state::hanamai_keyboard_w)); MCFG_MACHINE_START_OVERRIDE(ddenlovr_state,mjflove) @@ -10846,7 +10791,7 @@ void ddenlovr_state::seljan2(machine_config &config) tmpz84c015_device &maincpu(TMPZ84C015(config, m_maincpu, XTAL(16'000'000) / 2)); maincpu.set_addrmap(AS_PROGRAM, &ddenlovr_state::seljan2_map); maincpu.set_addrmap(AS_IO, &ddenlovr_state::seljan2_portmap); - maincpu.out_pa_callback().set(FUNC(ddenlovr_state::hanakanz_keyb_w)); + maincpu.out_pa_callback().set(FUNC(ddenlovr_state::hanamai_keyboard_w)); maincpu.out_pb_callback().set(FUNC(ddenlovr_state::sryudens_coincounter_w)); MCFG_MACHINE_START_OVERRIDE(ddenlovr_state,seljan2) diff --git a/src/mame/dynax/dynax.cpp b/src/mame/dynax/dynax.cpp index b674ed4228d..359cc80a76a 100644 --- a/src/mame/dynax/dynax.cpp +++ b/src/mame/dynax/dynax.cpp @@ -218,30 +218,16 @@ uint8_t dynax_state::ret_ff() } -uint8_t dynax_state::hanamai_keyboard_0_r() +template +uint8_t dynax_state::hanamai_keyboard_r() { - int res = 0x3f; - /* the game reads all rows at once (keyb = 0) to check if a key is pressed */ - if (!BIT(m_keyb, 0)) res &= ioport("KEY0")->read(); - if (!BIT(m_keyb, 1)) res &= ioport("KEY1")->read(); - if (!BIT(m_keyb, 2)) res &= ioport("KEY2")->read(); - if (!BIT(m_keyb, 3)) res &= ioport("KEY3")->read(); - if (!BIT(m_keyb, 4)) res &= ioport("KEY4")->read(); - - return res; -} - -uint8_t dynax_state::hanamai_keyboard_1_r() -{ int res = 0x3f; - - /* the game reads all rows at once (keyb = 0) to check if a key is pressed */ - if (!BIT(m_keyb, 0)) res &= ioport("KEY5")->read(); - if (!BIT(m_keyb, 1)) res &= ioport("KEY6")->read(); - if (!BIT(m_keyb, 2)) res &= ioport("KEY7")->read(); - if (!BIT(m_keyb, 3)) res &= ioport("KEY8")->read(); - if (!BIT(m_keyb, 4)) res &= ioport("KEY9")->read(); + for (unsigned i = 0; 5 > i; ++i) + { + if (!BIT(m_keyb, i)) + res &= m_io_key[N][i]->read(); + } return res; } @@ -483,8 +469,8 @@ void dynax_adpcm_state::hanamai_io_map(address_map &map) map(0x20, 0x20).w(FUNC(dynax_adpcm_state::dynax_extra_scrolly_w)); // screen scroll Y map(0x41, 0x47).w(m_blitter, FUNC(dynax_blitter_rev2_device::regs_w)); // Blitter map(0x50, 0x50).w(FUNC(dynax_adpcm_state::dynax_rombank_w)); // BANK ROM Select hnkochou only - map(0x60, 0x60).r(FUNC(dynax_adpcm_state::hanamai_keyboard_0_r)); // P1 - map(0x61, 0x61).r(FUNC(dynax_adpcm_state::hanamai_keyboard_1_r)); // P2 + map(0x60, 0x60).r(FUNC(dynax_adpcm_state::hanamai_keyboard_r<0>)); // P1 + map(0x61, 0x61).r(FUNC(dynax_adpcm_state::hanamai_keyboard_r<1>)); // P2 map(0x62, 0x62).portr("COINS"); // Coins map(0x63, 0x63).r(FUNC(dynax_adpcm_state::ret_ff)); // ? map(0x64, 0x64).w(FUNC(dynax_adpcm_state::hanamai_keyboard_w)); // keyboard row select @@ -515,8 +501,8 @@ void dynax_adpcm_state::hnoridur_io_map(address_map &map) // map(0x11, 0x11).nopw(); // CRT Controller map(0x20, 0x20).w(FUNC(dynax_adpcm_state::hanamai_keyboard_w)); // keyboard row select map(0x21, 0x21).portr("COINS"); // Coins - map(0x22, 0x22).r(FUNC(dynax_adpcm_state::hanamai_keyboard_1_r)); // P2 - map(0x23, 0x23).r(FUNC(dynax_adpcm_state::hanamai_keyboard_0_r)); // P1 + map(0x22, 0x22).r(FUNC(dynax_adpcm_state::hanamai_keyboard_r<1>)); // P2 + map(0x23, 0x23).r(FUNC(dynax_adpcm_state::hanamai_keyboard_r<0>)); // P1 map(0x24, 0x24).portr("DSW1"); // DSW2 map(0x25, 0x25).portr("DSW3"); // DSW4 map(0x26, 0x26).portr("DSW2"); // DSW3 @@ -555,12 +541,12 @@ void dynax_adpcm_state::hjingi_lockout_w(int state) uint8_t dynax_adpcm_state::hjingi_keyboard_0_r() { - return hanamai_keyboard_0_r() | (m_hopper->line_r() ? 0 : (1 << 6)); + return hanamai_keyboard_r<0>() | (m_hopper->line_r() ? 0 : (1 << 6)); } uint8_t dynax_adpcm_state::hjingi_keyboard_1_r() { - return hanamai_keyboard_1_r() | ioport("BET")->read(); + return hanamai_keyboard_r<1>() | ioport("BET")->read(); } void dynax_adpcm_state::hjingi_mem_map(address_map &map) @@ -635,57 +621,61 @@ void dynax_adpcm_state::yarunara_input_w(offs_t offset, uint8_t data) { switch (offset) { - case 0: m_input_sel = data; - m_keyb = 0; - break; + case 0: + m_input_sel = data; + m_keyb = 0; + break; - case 1: break; + case 1: + break; } } uint8_t dynax_adpcm_state::yarunara_input_r(offs_t offset) { - static const char *const keynames0[] = { "KEY0", "KEY1", "KEY2", "KEY3", "KEY4" }; - static const char *const keynames1[] = { "KEY5", "KEY6", "KEY7", "KEY8", "KEY9" }; - + uint8_t result = 0xff; switch (offset) { - case 0: + case 0: + switch (m_input_sel) { - switch (m_input_sel) - { - case 0x00: - return ioport("COINS")->read(); // coins + case 0x00: + result = ioport("COINS")->read(); // coins + break; - case 0x02: - return 0xff; // bit 7 must be 1. Bit 2? + case 0x02: + result = 0xff; // bit 7 must be 1. Bit 2? + break; - default: - return 0xff; - } + default: + result = 0xff; } + break; - case 1: + case 1: + switch (m_input_sel) { - switch (m_input_sel) + // player 2 + case 0x01: //quiztvqq + case 0x81: + // player 1 + case 0x02: //quiztvqq + case 0x82: + if (m_keyb < 5) { - // player 2 - case 0x01: //quiztvqq - case 0x81: - return ioport(keynames1[m_keyb++])->read(); - - // player 1 - case 0x02: //quiztvqq - case 0x82: - return ioport(keynames0[m_keyb++])->read(); - - default: - return 0xff; + result = m_io_key[BIT(m_input_sel, 0)][m_keyb]->read(); + if (!machine().side_effects_disabled()) + ++m_keyb; } + break; + + default: + result = 0xff; } + break; } - return 0xff; + return result; } void dynax_adpcm_state::yarunara_rombank_w(uint8_t data) @@ -743,8 +733,8 @@ void dynax_adpcm_state::mcnpshnt_io_map(address_map &map) // map(0x11, 0x11).nopw(); // CRT Controller map(0x20, 0x20).w(FUNC(dynax_adpcm_state::hanamai_keyboard_w)); // keyboard row select map(0x21, 0x21).portr("COINS"); // Coins - map(0x22, 0x22).r(FUNC(dynax_adpcm_state::hanamai_keyboard_1_r)); // P2 - map(0x23, 0x23).r(FUNC(dynax_adpcm_state::hanamai_keyboard_0_r)); // P1 + map(0x22, 0x22).r(FUNC(dynax_adpcm_state::hanamai_keyboard_r<1>)); // P2 + map(0x23, 0x23).r(FUNC(dynax_adpcm_state::hanamai_keyboard_r<0>)); // P1 map(0x24, 0x24).portr("DSW0"); // DSW2 map(0x26, 0x26).portr("DSW1"); // DSW3 map(0x30, 0x30).w(FUNC(dynax_adpcm_state::adpcm_reset_w)); // MSM5205 reset @@ -797,22 +787,22 @@ void dynax_state::sprtmtch_io_map(address_map &map) void dynax_state::mjfriday_io_map(address_map &map) { map.global_mask(0xff); - map(0x00, 0x00).w(m_blitter, FUNC(dynax_blitter_rev2_device::pen_w)); // Destination Pen - map(0x01, 0x01).w(FUNC(dynax_state::dynax_blit_palette01_w)); // Layers Palettes (Low Bits) - map(0x02, 0x02).w(FUNC(dynax_state::dynax_rombank_w)); // BANK ROM Select - map(0x03, 0x03).w(FUNC(dynax_state::dynax_blit_backpen_w)); // Background Color + map(0x00, 0x00).w(m_blitter, FUNC(dynax_blitter_rev2_device::pen_w)); // Destination Pen + map(0x01, 0x01).w(FUNC(dynax_state::dynax_blit_palette01_w)); // Layers Palettes (Low Bits) + map(0x02, 0x02).w(FUNC(dynax_state::dynax_rombank_w)); // BANK ROM Select + map(0x03, 0x03).w(FUNC(dynax_state::dynax_blit_backpen_w)); // Background Color map(0x10, 0x17).w(m_mainlatch, FUNC(ls259_device::write_d0)); - map(0x41, 0x47).w(m_blitter, FUNC(dynax_blitter_rev2_device::regs_w)); // Blitter -// map(0x50, 0x50).nopw(); // CRT Controller -// map(0x51, 0x51).nopw(); // CRT Controller - map(0x60, 0x60).w(FUNC(dynax_state::hanamai_keyboard_w)); // keyboard row select - map(0x61, 0x61).portr("COINS"); // Coins - map(0x62, 0x62).r(FUNC(dynax_state::hanamai_keyboard_1_r)); // P2 - map(0x63, 0x63).r(FUNC(dynax_state::hanamai_keyboard_0_r)); // P1 - map(0x64, 0x64).portr("DSW0"); // DSW - map(0x67, 0x67).portr("DSW1"); // DSW - map(0x70, 0x71).w("ym2413", FUNC(ym2413_device::write)); // -// map(0x80, 0x80).nopw(); // IRQ ack? + map(0x41, 0x47).w(m_blitter, FUNC(dynax_blitter_rev2_device::regs_w)); // Blitter +// map(0x50, 0x50).nopw(); // CRT Controller +// map(0x51, 0x51).nopw(); // CRT Controller + map(0x60, 0x60).w(FUNC(dynax_state::hanamai_keyboard_w)); // keyboard row select + map(0x61, 0x61).portr("COINS"); // Coins + map(0x62, 0x62).r(FUNC(dynax_state::hanamai_keyboard_r<1>)); // P2 + map(0x63, 0x63).r(FUNC(dynax_state::hanamai_keyboard_r<0>)); // P1 + map(0x64, 0x64).portr("DSW0"); // DSW + map(0x67, 0x67).portr("DSW1"); // DSW + map(0x70, 0x71).w("ym2413", FUNC(ym2413_device::write)); // +// map(0x80, 0x80).nopw(); // IRQ ack? } @@ -826,8 +816,8 @@ void dynax_adpcm_state::nanajign_io_map(address_map &map) map(0x0a, 0x0a).w("aysnd", FUNC(ay8912_device::address_w)); // map(0x10, 0x10).w(FUNC(dynax_adpcm_state::hanamai_keyboard_w)); // keyboard row select map(0x11, 0x11).portr("COINS"); // Coins - map(0x12, 0x12).r(FUNC(dynax_adpcm_state::hanamai_keyboard_1_r)); // P2 - map(0x13, 0x13).r(FUNC(dynax_adpcm_state::hanamai_keyboard_0_r)); // P1 + map(0x12, 0x12).r(FUNC(dynax_adpcm_state::hanamai_keyboard_r<1>)); // P2 + map(0x13, 0x13).r(FUNC(dynax_adpcm_state::hanamai_keyboard_r<0>)); // P1 map(0x14, 0x14).portr("DSW0"); // DSW1 map(0x15, 0x15).portr("DSW1"); // DSW2 map(0x16, 0x16).portr("DSW2"); // DSW3 @@ -884,7 +874,7 @@ void jantouki_state::jantouki_io_map(address_map &map) map(0x4f, 0x4f).w(FUNC(jantouki_state::dynax_blit2_romregion_w)); // Blitter 2 ROM bank map(0x50, 0x50).w(FUNC(jantouki_state::jantouki_vblank_ack_w)); // VBlank IRQ Ack map(0x51, 0x51).w(FUNC(jantouki_state::hanamai_keyboard_w)); // keyboard row select - map(0x52, 0x52).r(FUNC(jantouki_state::hanamai_keyboard_0_r)); // P1 + map(0x52, 0x52).r(FUNC(jantouki_state::hanamai_keyboard_r<0>)); // P1 map(0x54, 0x54).portr("COINS"); // Coins map(0x55, 0x55).portr("DSW0"); // DSW1 map(0x56, 0x56).portr("DSW1"); // DSW2 @@ -934,7 +924,7 @@ void jantouki_state::jantouki_sound_io_map(address_map &map) uint8_t dynax_adpcm_state::mjelctrn_keyboard_1_r() { - return (hanamai_keyboard_1_r() & 0x3f) | (ioport("FAKE")->read() ? 0x40 : 0); + return (hanamai_keyboard_r<1>() & 0x3f) | (ioport("FAKE")->read() ? 0x40 : 0); } uint8_t dynax_adpcm_state::mjelctrn_dsw_r() @@ -1047,9 +1037,6 @@ void dynax_state::tenkai_ip_w(uint8_t data) uint8_t dynax_state::tenkai_ip_r(offs_t offset) { - static const char *const keynames0[] = { "KEY0", "KEY1", "KEY2", "KEY3", "KEY4" }; - //static const char *const keynames1[] = { "KEY5", "KEY6", "KEY7", "KEY8", "KEY9" }; - uint8_t result = 0xff; switch (offset) { @@ -1079,15 +1066,8 @@ uint8_t dynax_state::tenkai_ip_r(offs_t offset) result = 0xff; break; - // player 2 - case 0x81: - if (m_keyb >= 5) - logerror("%s: unmapped keyb=%02x read\n", machine().describe_context(), m_keyb); - result = 0xff;//ioport(keynames1[m_keyb++])->read(); - break; - - // player 1 - case 0x82: + case 0x81: // player 2 + case 0x82: // player 1 if (m_input_mode != 0xff) { result = 0x00; @@ -1097,9 +1077,12 @@ uint8_t dynax_state::tenkai_ip_r(offs_t offset) logerror("%s: unmapped keyb=%02x read\n", machine().describe_context(), m_keyb); result = 0x00; } - result = ioport(keynames0[m_keyb])->read(); - if (!machine().side_effects_disabled()) - ++m_keyb; + else + { + result = m_io_key[BIT(m_input_sel, 0)][m_keyb]->read(); + if (!machine().side_effects_disabled()) + ++m_keyb; + } break; default: @@ -1302,27 +1285,9 @@ void dynax_state::ougonhai_banked_map(address_map &map) Mahjong Gekisha ***************************************************************************/ -uint8_t dynax_state::gekisha_keyboard_0_r() -{ - int res = 0x3f; - - if (!BIT(m_keyb, 0)) res &= ioport("KEY0")->read(); - if (!BIT(m_keyb, 1)) res &= ioport("KEY1")->read(); - if (!BIT(m_keyb, 2)) res &= ioport("KEY2")->read(); - if (!BIT(m_keyb, 3)) res &= ioport("KEY3")->read(); - if (!BIT(m_keyb, 4)) res &= ioport("KEY4")->read(); - - return res; -} uint8_t dynax_state::gekisha_keyboard_1_r() { - int res = 0x3f; - - if (!BIT(m_keyb, 0)) res &= ioport("KEY5")->read(); - if (!BIT(m_keyb, 1)) res &= ioport("KEY6")->read(); - if (!BIT(m_keyb, 2)) res &= ioport("KEY7")->read(); - if (!BIT(m_keyb, 3)) res &= ioport("KEY8")->read(); - if (!BIT(m_keyb, 4)) res &= ioport("KEY9")->read(); + uint8_t res = hanamai_keyboard_r<1>(); // bit 6 res |= ioport("BET")->read(); @@ -1366,7 +1331,7 @@ void dynax_state::gekisha_banked_map(address_map &map) map(0x10060, 0x10060).w(FUNC(dynax_state::hanamai_keyboard_w)); // keyboard row select map(0x10061, 0x10061).portr("COINS"); // Coins map(0x10062, 0x10062).r(FUNC(dynax_state::gekisha_keyboard_1_r)); // P2 - map(0x10063, 0x10063).r(FUNC(dynax_state::gekisha_keyboard_0_r)); // P1 + map(0x10063, 0x10063).r(FUNC(dynax_state::hanamai_keyboard_r<0>)); // P1 map(0x10064, 0x10064).portr("DSW1"); // DSW map(0x10065, 0x10065).portr("DSW3"); // DSW map(0x10066, 0x10066).portr("DSW4"); // DSW @@ -1433,7 +1398,7 @@ void cdracula_state::cdracula_io_map(address_map &map) ***************************************************************************/ -static INPUT_PORTS_START( MAHJONG_KEYS ) +INPUT_PORTS_START( dynax_mahjong_keys ) PORT_START("KEY0") PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_A ) PORT_PLAYER(1) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_MAHJONG_E ) PORT_PLAYER(1) @@ -1515,8 +1480,8 @@ static INPUT_PORTS_START( MAHJONG_KEYS ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN ) INPUT_PORTS_END -static INPUT_PORTS_START( MAHJONG_KEYS_BET ) - PORT_INCLUDE( MAHJONG_KEYS ) +INPUT_PORTS_START( dynax_mahjong_keys_bet ) + PORT_INCLUDE( dynax_mahjong_keys ) PORT_MODIFY("KEY1") PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_MAHJONG_BET ) PORT_PLAYER(1) @@ -1537,7 +1502,7 @@ static INPUT_PORTS_START( MAHJONG_KEYS_BET ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_MAHJONG_SMALL ) PORT_PLAYER(2) // "s" INPUT_PORTS_END -static INPUT_PORTS_START( HANAFUDA_KEYS ) +static INPUT_PORTS_START( dynax_hanafuda_keys ) PORT_START("KEY0") PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_HANAFUDA_A ) PORT_PLAYER(1) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_HANAFUDA_E ) PORT_PLAYER(1) @@ -1619,8 +1584,8 @@ static INPUT_PORTS_START( HANAFUDA_KEYS ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN ) INPUT_PORTS_END -INPUT_PORTS_START( HANAFUDA_KEYS_BET ) - PORT_INCLUDE( HANAFUDA_KEYS ) +INPUT_PORTS_START( dynax_hanafuda_keys_bet ) + PORT_INCLUDE( dynax_hanafuda_keys ) PORT_MODIFY("KEY1") PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_MAHJONG_BET ) PORT_PLAYER(1) @@ -1643,7 +1608,7 @@ INPUT_PORTS_END #if 0 [[maybe_unused]] static INPUT_PORTS_START( HANAFUDA_KEYS_BET_ALT ) - PORT_INCLUDE( HANAFUDA_KEYS ) + PORT_INCLUDE( dynax_hanafuda_keys ) PORT_MODIFY("KEY0") PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_MAHJONG_SCORE ) // "t" @@ -1885,7 +1850,7 @@ static INPUT_PORTS_START( hanamai ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SERVICE1 ) - PORT_INCLUDE( HANAFUDA_KEYS ) + PORT_INCLUDE( dynax_hanafuda_keys ) INPUT_PORTS_END static INPUT_PORTS_START( hnkochou ) @@ -1950,7 +1915,7 @@ static INPUT_PORTS_START( hnkochou ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_IMPULSE(2) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_INCLUDE( HANAFUDA_KEYS_BET ) + PORT_INCLUDE( dynax_hanafuda_keys_bet ) INPUT_PORTS_END @@ -2015,7 +1980,7 @@ static INPUT_PORTS_START( hnoridur ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SERVICE1 ) - PORT_INCLUDE( HANAFUDA_KEYS ) + PORT_INCLUDE( dynax_hanafuda_keys ) PORT_START("DSW2") PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) ) PORT_DIPLOCATION( "DIP3:1" ) @@ -2182,7 +2147,7 @@ static INPUT_PORTS_START( hjingi ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SERVICE1 ) // 18A - PORT_INCLUDE( HANAFUDA_KEYS_BET ) + PORT_INCLUDE( dynax_hanafuda_keys_bet ) // PORT_INCLUDE( HANAFUDA_KEYS_BET_ALT ) PORT_START("BET") @@ -2342,7 +2307,7 @@ static INPUT_PORTS_START( mjfriday ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) // "18A" - PORT_INCLUDE( MAHJONG_KEYS ) + PORT_INCLUDE( dynax_mahjong_keys ) INPUT_PORTS_END @@ -2408,7 +2373,7 @@ static INPUT_PORTS_START( mjdialq2 ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) // "18A" - PORT_INCLUDE( MAHJONG_KEYS ) + PORT_INCLUDE( dynax_mahjong_keys ) INPUT_PORTS_END @@ -2473,7 +2438,7 @@ static INPUT_PORTS_START( yarunara ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SERVICE1 ) - PORT_INCLUDE( MAHJONG_KEYS ) + PORT_INCLUDE( dynax_mahjong_keys ) INPUT_PORTS_END static INPUT_PORTS_START( warahana ) @@ -2519,7 +2484,7 @@ static INPUT_PORTS_START( warahana ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SERVICE1 ) - PORT_INCLUDE( MAHJONG_KEYS ) + PORT_INCLUDE( dynax_mahjong_keys ) INPUT_PORTS_END static INPUT_PORTS_START( hanayara ) @@ -2583,7 +2548,7 @@ static INPUT_PORTS_START( hanayara ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SERVICE1 ) - PORT_INCLUDE( HANAFUDA_KEYS ) + PORT_INCLUDE( dynax_hanafuda_keys ) INPUT_PORTS_END static INPUT_PORTS_START( quiztvqq ) @@ -2746,7 +2711,7 @@ static INPUT_PORTS_START( mcnpshnt ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SERVICE1 ) - PORT_INCLUDE( MAHJONG_KEYS ) + PORT_INCLUDE( dynax_mahjong_keys ) INPUT_PORTS_END @@ -2812,7 +2777,7 @@ static INPUT_PORTS_START( nanajign ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SERVICE1 ) - PORT_INCLUDE( MAHJONG_KEYS ) + PORT_INCLUDE( dynax_mahjong_keys ) PORT_START("DSW2") PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) ) @@ -3139,7 +3104,7 @@ static INPUT_PORTS_START( mjembase ) MAHJONG_COIN_TEST("DSW1", 0x40) - PORT_INCLUDE( MAHJONG_KEYS_BET ) + PORT_INCLUDE( dynax_mahjong_keys_bet ) INPUT_PORTS_END @@ -3147,7 +3112,7 @@ INPUT_PORTS_END static INPUT_PORTS_START( mjelct3 ) MAHJONG_COIN_TEST("DSW1", 0x40) - PORT_INCLUDE( MAHJONG_KEYS_BET ) + PORT_INCLUDE( dynax_mahjong_keys_bet ) PORT_START("SW1") // port 85 PORT_DIPUNKNOWN_DIPLOC(0x01, 0x01, "SW1:1") @@ -3246,7 +3211,7 @@ static INPUT_PORTS_START( mjelctrn ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN1 ) // Coin PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SERVICE1 ) // Service - PORT_INCLUDE( MAHJONG_KEYS_BET ) + PORT_INCLUDE( dynax_mahjong_keys_bet ) PORT_START("SW1") // port 85 PORT_DIPUNKNOWN_DIPLOC(0x01, 0x01, "SW1:1") @@ -3426,7 +3391,7 @@ static INPUT_PORTS_START( majxtal7 ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN1 ) // Coin PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SERVICE1 ) // Service - PORT_INCLUDE( MAHJONG_KEYS_BET ) + PORT_INCLUDE( dynax_mahjong_keys_bet ) PORT_START("DSW2") /* select = 80 */ PORT_DIPNAME( 0x07, 0x07, "YAKUMAN Bonus" ) @@ -3551,7 +3516,7 @@ static INPUT_PORTS_START( neruton ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN1 ) // Coin PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) // 18A - PORT_INCLUDE( MAHJONG_KEYS ) + PORT_INCLUDE( dynax_mahjong_keys ) /* 2008-06 FP: the following are needed to make happy the read handlers shared with mjelctrn */ PORT_START("SW1") @@ -3688,7 +3653,7 @@ static INPUT_PORTS_START( tenkai ) MAHJONG_COIN_TEST("DSW2", 0x01) - PORT_INCLUDE( MAHJONG_KEYS_BET ) + PORT_INCLUDE( dynax_mahjong_keys_bet ) INPUT_PORTS_END @@ -3892,7 +3857,7 @@ static INPUT_PORTS_START( mjreach ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN1 ) // Coin PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SERVICE1 ) // Service - PORT_INCLUDE( MAHJONG_KEYS_BET ) + PORT_INCLUDE( dynax_mahjong_keys_bet ) INPUT_PORTS_END static INPUT_PORTS_START( gekisha ) @@ -4016,7 +3981,7 @@ static INPUT_PORTS_START( gekisha ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN1 ) // Coin PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_INCLUDE( MAHJONG_KEYS_BET ) + PORT_INCLUDE( dynax_mahjong_keys_bet ) INPUT_PORTS_END diff --git a/src/mame/dynax/dynax.h b/src/mame/dynax/dynax.h index 17b32bb7e6b..2bd18221997 100644 --- a/src/mame/dynax/dynax.h +++ b/src/mame/dynax/dynax.h @@ -37,6 +37,7 @@ public: , m_hopper(*this, "hopper") , m_bankdev(*this, "bankdev") , m_mainirq(*this, "mainirq") + , m_io_key{ { *this, "KEY%u", 0U }, { *this, "KEY%u", 5U } } { } @@ -69,6 +70,9 @@ protected: optional_device m_mainlatch; optional_device m_blitter; optional_device m_hopper; + optional_device m_bankdev; + optional_device m_mainirq; + optional_ioport_array<5> m_io_key[2]; /* input / output */ uint8_t m_input_sel = 0U; @@ -94,8 +98,7 @@ protected: void coincounter_0_w(int state); void coincounter_1_w(int state); uint8_t ret_ff(); - uint8_t hanamai_keyboard_0_r(); - uint8_t hanamai_keyboard_1_r(); + template uint8_t hanamai_keyboard_r(); void hanamai_keyboard_w(uint8_t data); void dynax_rombank_w(uint8_t data); void dynax_blit_palette23_w(uint8_t data); @@ -118,10 +121,6 @@ protected: void sprtmtch_mem_map(address_map &map) ATTR_COLD; - // devices - optional_device m_bankdev; - optional_device m_mainirq; - // up to 8 layers, 2 images per layer (interleaved on screen) std::unique_ptr m_pixmap[8][2]{}; @@ -171,7 +170,6 @@ private: void tenkai_6c_w(int state); void tenkai_70_w(int state); void tenkai_blit_romregion_w(uint8_t data); - uint8_t gekisha_keyboard_0_r(); uint8_t gekisha_keyboard_1_r(); void gekisha_hopper_w(offs_t offset, uint8_t data); void gekisha_p4_w(uint8_t data); @@ -461,6 +459,8 @@ private: }; -INPUT_PORTS_EXTERN(HANAFUDA_KEYS_BET); +INPUT_PORTS_EXTERN(dynax_mahjong_keys); +INPUT_PORTS_EXTERN(dynax_mahjong_keys_bet); +INPUT_PORTS_EXTERN(dynax_hanafuda_keys_bet); #endif // MAME_DYNAX_DYNAX_H -- cgit v1.2.3