From bc231904587c032c45d5a8fd203f6dbf35d4ca8d Mon Sep 17 00:00:00 2001 From: angelosa Date: Tue, 9 Jul 2024 17:54:58 +0200 Subject: [PATCH] machine/k056230: refactor regs_r/_w to regs_map --- src/devices/machine/k056230.cpp | 68 ++++++++++++--------------------- src/devices/machine/k056230.h | 3 +- src/mame/konami/gticlub.cpp | 12 ++++-- src/mame/konami/plygonet.cpp | 2 +- src/mame/konami/zr107.cpp | 12 ++++-- 5 files changed, 43 insertions(+), 54 deletions(-) diff --git a/src/devices/machine/k056230.cpp b/src/devices/machine/k056230.cpp index 68f1a718197..da56c309831 100644 --- a/src/devices/machine/k056230.cpp +++ b/src/devices/machine/k056230.cpp @@ -47,42 +47,28 @@ void k056230_device::device_start() save_item(NAME(m_irq_state)); } -u8 k056230_device::regs_r(offs_t offset) +void k056230_device::regs_map(address_map &map) { - u8 data = 0; - - switch (offset) - { - case 0: // Status register - data = 0x08; - LOGMASKED(LOG_REG_READS, "%s: regs_r: Status Register: %02x\n", machine().describe_context(), data); - break; - - case 1: // CRC Error register - data = 0x00; - LOGMASKED(LOG_REG_READS, "%s: regs_r: CRC Error Register: %02x\n", machine().describe_context(), data); - break; - - default: - LOGMASKED(LOG_REG_READS, "%s: regs_r: Unknown Register [%02x]: %02x\n", machine().describe_context(), offset, data); - break; - } - - return data; -} - -void k056230_device::regs_w(offs_t offset, u8 data) -{ - switch (offset) - { - case 0: // Mode register + map(0x00, 0x00).lrw8( + NAME([this] (offs_t offset) { + const u8 res = 0x08; + LOGMASKED(LOG_REG_READS, "%s: regs_r: Status Register: %02x\n", machine().describe_context(), res); + return res; + }), + NAME([this] (offs_t offset, u8 data) { LOGMASKED(LOG_REG_WRITES, "%s: regs_w: Mode Register = %02x\n", machine().describe_context(), data); - break; - - case 1: // Control register - { + }) + ), + map(0x01, 0x01).lrw8( + NAME([this] (offs_t offset) { + const u8 res = 0x00; + LOGMASKED(LOG_REG_READS, "%s: regs_r: CRC Error Register: %02x\n", machine().describe_context(), res); + return res; + }), + NAME([this] (offs_t offset, u8 data) { LOGMASKED(LOG_REG_WRITES, "%s: regs_w: Control Register = %02x\n", machine().describe_context(), data); - // TODO: This is a literal translation of the previous device behaviour, and seems pretty likely to be incorrect. + // TODO: This is a literal translation of the previous device behaviour, and is incorrect. + // Namely it can't possibly ping irq state on the fly, needs some transaction from the receiver. const int old_state = m_irq_state; if (BIT(data, 5)) { @@ -98,17 +84,13 @@ void k056230_device::regs_w(offs_t offset, u8 data) { m_irq_cb(m_irq_state); } - break; - } - - case 2: // Sub ID register + }) + ); + map(0x02, 0x02).lw8( + NAME([this] (offs_t offset, u8 data) { LOGMASKED(LOG_REG_WRITES, "%s: regs_w: Sub ID Register = %02x\n", machine().describe_context(), data); - break; - - default: - LOGMASKED(LOG_REG_WRITES | LOG_UNKNOWNS, "%s: regs_w: Unknown Register [%02x] = %02x\n", machine().describe_context(), offset, data); - break; - } + }) + ); } u32 k056230_device::ram_r(offs_t offset, u32 mem_mask) diff --git a/src/devices/machine/k056230.h b/src/devices/machine/k056230.h index 7df76c26e53..0c450e3f18c 100644 --- a/src/devices/machine/k056230.h +++ b/src/devices/machine/k056230.h @@ -22,8 +22,7 @@ public: u32 ram_r(offs_t offset, u32 mem_mask = ~0); void ram_w(offs_t offset, u32 data, u32 mem_mask = ~0); - u8 regs_r(offs_t offset); - void regs_w(offs_t offset, u8 data); + void regs_map(address_map &map); protected: // device-level overrides diff --git a/src/mame/konami/gticlub.cpp b/src/mame/konami/gticlub.cpp index e3db26b9ee7..107527dfc24 100644 --- a/src/mame/konami/gticlub.cpp +++ b/src/mame/konami/gticlub.cpp @@ -518,7 +518,7 @@ void gticlub_state::gticlub_map(address_map &map) map(0x78080000, 0x7808000f).rw(m_k001006[1], FUNC(k001006_device::read), FUNC(k001006_device::write)); map(0x780c0000, 0x780c0003).rw(m_konppc, FUNC(konppc_device::cgboard_dsp_comm_r_ppc), FUNC(konppc_device::cgboard_dsp_comm_w_ppc)); map(0x7e000000, 0x7e003fff).rw(FUNC(gticlub_state::sysreg_r), FUNC(gticlub_state::sysreg_w)); - map(0x7e008000, 0x7e009fff).rw(m_k056230, FUNC(k056230_device::regs_r), FUNC(k056230_device::regs_w)); + map(0x7e008000, 0x7e009fff).m(m_k056230, FUNC(k056230_device::regs_map)); map(0x7e00a000, 0x7e00bfff).rw(m_k056230, FUNC(k056230_device::ram_r), FUNC(k056230_device::ram_w)); map(0x7e00c000, 0x7e00c00f).rw(m_k056800, FUNC(k056800_device::host_r), FUNC(k056800_device::host_w)); map(0x7f000000, 0x7f3fffff).rom().region("datarom", 0); @@ -541,7 +541,7 @@ void hangplt_state::hangplt_map(address_map &map) map(0x78000000, 0x7800ffff).rw(m_konppc, FUNC(konppc_device::cgboard_dsp_shared_r_ppc), FUNC(konppc_device::cgboard_dsp_shared_w_ppc)); map(0x780c0000, 0x780c0003).rw(m_konppc, FUNC(konppc_device::cgboard_dsp_comm_r_ppc), FUNC(konppc_device::cgboard_dsp_comm_w_ppc)); map(0x7e000000, 0x7e003fff).rw(FUNC(hangplt_state::sysreg_r), FUNC(hangplt_state::sysreg_w)); - map(0x7e008000, 0x7e009fff).rw(m_k056230, FUNC(k056230_device::regs_r), FUNC(k056230_device::regs_w)); + map(0x7e008000, 0x7e009fff).m(m_k056230, FUNC(k056230_device::regs_map)); map(0x7e00a000, 0x7e00bfff).rw(m_k056230, FUNC(k056230_device::ram_r), FUNC(k056230_device::ram_w)); map(0x7e00c000, 0x7e00c00f).rw(m_k056800, FUNC(k056800_device::host_r), FUNC(k056800_device::host_w)); map(0x7f000000, 0x7f3fffff).rom().region("datarom", 0); @@ -763,7 +763,9 @@ static INPUT_PORTS_START( hangplt ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_NAME("Push limit switch") PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("Pull limit switch") - PORT_MODIFY("IN3") //Todo: The test mode for this game shows eight dip switches. + // TODO: The test mode for this game shows 8 dip switches + // verify if they are read anywhere (or physically mapped for that matter). + PORT_MODIFY("IN3") PORT_DIPNAME( 0x01, 0x01, "Disable Machine Init" ) PORT_DIPLOCATION("SW:1") // NOTE: Disabling Machine Init also disables analog controls PORT_DIPSETTING( 0x01, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) @@ -946,12 +948,14 @@ void gticlub_state::gticlub(machine_config &config) m_konppc->set_cbboard_type(konppc_device::CGBOARD_TYPE_GTICLUB); } -void thunderh_state::thunderh(machine_config &config) // Todo: K056230 from the I/O board +void thunderh_state::thunderh(machine_config &config) { gticlub(config); m_adc1038->set_gti_club_hack(false); + // TODO: replace K056230 from main gticlub config with a LANC tied to gn680 I/O board + M68000(config, m_gn680, XTAL(32'000'000) / 2); // 16MHz m_gn680->set_addrmap(AS_PROGRAM, &thunderh_state::gn680_memmap); } diff --git a/src/mame/konami/plygonet.cpp b/src/mame/konami/plygonet.cpp index c91408f8426..3c206dde837 100644 --- a/src/mame/konami/plygonet.cpp +++ b/src/mame/konami/plygonet.cpp @@ -941,7 +941,7 @@ void polygonet_state::main_map(address_map &map) map(0x540000, 0x540fff).ram().share(m_ttl_vram).w(FUNC(polygonet_state::ttl_vram_w)); map(0x541000, 0x54101f).ram().share(m_fix_regs).rw(FUNC(polygonet_state::fix_regs_r), FUNC(polygonet_state::fix_regs_w)); map(0x580000, 0x5807ff).rw(m_k056230, FUNC(k056230_device::ram_r), FUNC(k056230_device::ram_w)); - map(0x580800, 0x580803).rw(m_k056230, FUNC(k056230_device::regs_r), FUNC(k056230_device::regs_w)); + map(0x580800, 0x580803).m(m_k056230, FUNC(k056230_device::regs_map)); map(0x600000, 0x60000f).m(m_k054321, FUNC(k054321_device::main_map)); map(0x640000, 0x640003).w(FUNC(polygonet_state::sound_irq_w)); map(0x680000, 0x680003).w(m_watchdog, FUNC(watchdog_timer_device::reset32_w)); diff --git a/src/mame/konami/zr107.cpp b/src/mame/konami/zr107.cpp index a0301dc0043..a858f8aa2cd 100644 --- a/src/mame/konami/zr107.cpp +++ b/src/mame/konami/zr107.cpp @@ -6,6 +6,9 @@ Driver by Ville Linde + TODO: + - segfaults on soft reset; + - jetwave: fix debug mode; Hardware overview: @@ -494,7 +497,7 @@ void midnrun_state::main_memmap(address_map &map) map(0x78040000, 0x7804000f).rw(m_k001006_1, FUNC(k001006_device::read), FUNC(k001006_device::write)); map(0x780c0000, 0x780c0007).rw(m_konppc, FUNC(konppc_device::cgboard_dsp_comm_r_ppc), FUNC(konppc_device::cgboard_dsp_comm_w_ppc)); map(0x7e000000, 0x7e003fff).rw(FUNC(midnrun_state::sysreg_r), FUNC(midnrun_state::sysreg_w)); - map(0x7e008000, 0x7e009fff).rw(m_k056230, FUNC(k056230_device::regs_r), FUNC(k056230_device::regs_w)); // LANC registers + map(0x7e008000, 0x7e009fff).m(m_k056230, FUNC(k056230_device::regs_map)); // LANC registers map(0x7e00a000, 0x7e00bfff).rw(m_k056230, FUNC(k056230_device::ram_r), FUNC(k056230_device::ram_w)); // LANC Buffer RAM (27E) map(0x7e00c000, 0x7e00c00f).rw(m_k056800, FUNC(k056800_device::host_r), FUNC(k056800_device::host_w)); map(0x7f800000, 0x7f9fffff).rom().region("prgrom", 0); @@ -515,7 +518,7 @@ void jetwave_state::main_memmap(address_map &map) map(0x78080000, 0x7808000f).rw(m_k001006_2, FUNC(k001006_device::read), FUNC(k001006_device::write)); map(0x780c0000, 0x780c0007).rw(m_konppc, FUNC(konppc_device::cgboard_dsp_comm_r_ppc), FUNC(konppc_device::cgboard_dsp_comm_w_ppc)); map(0x7e000000, 0x7e003fff).rw(FUNC(jetwave_state::sysreg_r), FUNC(jetwave_state::sysreg_w)); - map(0x7e008000, 0x7e009fff).rw(m_k056230, FUNC(k056230_device::regs_r), FUNC(k056230_device::regs_w)); // LANC registers + map(0x7e008000, 0x7e009fff).m(m_k056230, FUNC(k056230_device::regs_map)); // LANC registers map(0x7e00a000, 0x7e00bfff).rw(m_k056230, FUNC(k056230_device::ram_r), FUNC(k056230_device::ram_w)); // LANC Buffer RAM (27E) map(0x7e00c000, 0x7e00c00f).rw(m_k056800, FUNC(k056800_device::host_r), FUNC(k056800_device::host_w)); map(0x7f000000, 0x7f3fffff).rom().region("datarom", 0); @@ -644,9 +647,10 @@ static INPUT_PORTS_START( jetwave ) PORT_DIPSETTING( 0x08, "2" ) PORT_DIPSETTING( 0x04, "3" ) PORT_DIPSETTING( 0x00, "4" ) + // TODO: make these two less confusing PORT_DIPNAME( 0x02, 0x00, "Drive System" ) PORT_DIPLOCATION("SW:2") //Sensors for force feedback. Todo: "Disable" the sensors so this switch can be set to off without errors. - PORT_DIPSETTING( 0x02, "On" ) // Enables the sensors/normal use. - PORT_DIPSETTING( 0x00, "Off" ) //Disables and bypasses all sensor checks. This disables the force feedback on actual hardware. + PORT_DIPSETTING( 0x02, DEF_STR( On ) ) // Enables the sensors/normal use. + PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) //Disables and bypasses all sensor checks. This disables the force feedback on actual hardware. PORT_DIPNAME( 0x01, 0x01, "Running Mode" ) PORT_DIPLOCATION("SW:1") PORT_DIPSETTING( 0x01, "Product" ) //Enables the analog inputs; normal usage PORT_DIPSETTING( 0x00, "Check" ) //Disables them for use with a JAMMA interface; intended for development purposes.