diff options
author | Olivier Galibert <galibert@pobox.com> | 2020-03-15 16:54:50 +0100 |
---|---|---|
committer | Olivier Galibert <galibert@pobox.com> | 2020-03-15 16:55:21 +0100 |
commit | 0626189f0f23968de034870f8d79e9db95e3cf14 (patch) | |
tree | 1367be650ab4cd507de520e91c4126e1544e22e4 | |
parent | e9bcc59748ee517cca0472b45e06d009b05253ca (diff) |
ks0164: Connect the mpu (nw)
-rw-r--r-- | src/devices/sound/ks0164.cpp | 102 | ||||
-rw-r--r-- | src/devices/sound/ks0164.h | 18 | ||||
-rw-r--r-- | src/mame/drivers/dgpix.cpp | 34 |
3 files changed, 150 insertions, 4 deletions
diff --git a/src/devices/sound/ks0164.cpp b/src/devices/sound/ks0164.cpp index 53269c0e0c1..774081c6acc 100644 --- a/src/devices/sound/ks0164.cpp +++ b/src/devices/sound/ks0164.cpp @@ -53,6 +53,20 @@ void ks0164_device::device_start() m_stream = stream_alloc(0, 2, 44100); m_mem_cache = space().cache<1, 0, ENDIANNESS_BIG>(); m_timer = timer_alloc(0); + + save_item(NAME(m_bank1_base)); + save_item(NAME(m_bank1_select)); + save_item(NAME(m_bank2_base)); + save_item(NAME(m_bank2_select)); + save_item(NAME(m_sregs)); + save_item(NAME(m_mpu_in)); + save_item(NAME(m_mpu_out)); + save_item(NAME(m_mpu_status)); + save_item(NAME(m_unk60)); + save_item(NAME(m_voice_select)); + save_item(NAME(m_irqen_76)); + save_item(NAME(m_irqen_77)); + save_item(NAME(m_timer_interrupt)); } void ks0164_device::device_reset() @@ -68,6 +82,10 @@ void ks0164_device::device_reset() m_irqen_77 = 0; m_timer_interrupt = false; + m_mpu_in = 0x00; + m_mpu_out = 0x00; + m_mpu_status = 0x00; + m_timer->adjust(attotime::from_msec(1), 0, attotime::from_msec(1)); } @@ -78,6 +96,84 @@ void ks0164_device::device_timer(emu_timer &timer, device_timer_id id, int param m_cpu->set_input_line(14, ASSERT_LINE); } +void ks0164_device::mpuin_set(bool control, u8 data) +{ + // logerror("mpu push %s %02x\n", control ? "ctrl" : "data", data); + m_mpu_in = data; + if(control) + m_mpu_status |= MPUS_RX_CTRL; + else + m_mpu_status &= ~MPUS_RX_CTRL; + m_mpu_status |= MPUS_RX_FULL; + + if(m_mpu_status & MPUS_RX_INT) + m_cpu->set_input_line(11, ASSERT_LINE); +} + +void ks0164_device::mpu401_data_w(u8 data) +{ + mpuin_set(false, data); +} + +void ks0164_device::mpu401_ctrl_w(u8 data) +{ + mpuin_set(true, data); +} + +u8 ks0164_device::mpu401_data_r() +{ + // logerror("mpu pop %02x\n", m_mpu_out); + return m_mpu_out; +} + +u8 ks0164_device::mpu401_status_r() +{ + u8 res = 0x3f; + if(!(m_mpu_status & MPUS_TX_FULL)) + res |= 0x80; + if(m_mpu_status & MPUS_RX_FULL) + res |= 0x40; + + static std::string pc; + static u8 pr; + + std::string cc = machine().describe_context(); + if(pc != cc || pr != res) { + // logerror("status read %02x (%s)\n", res, cc); + pc = cc; + pr = res; + } + return res; +} + +u8 ks0164_device::mpu401_istatus_r() +{ + // logerror("mpu istatus read %02x (%04x)\n", m_mpu_status, m_cpu->pc()); + return m_mpu_status; +} + +void ks0164_device::mpu401_istatus_w(u8 data) +{ + m_mpu_status = (m_mpu_status & ~(MPUS_RX_INT|MPUS_TX_INT)) | (data & (MPUS_RX_INT|MPUS_TX_INT)); + m_cpu->set_input_line(11, (m_mpu_status & (MPUS_RX_INT|MPUS_RX_FULL)) == (MPUS_RX_INT|MPUS_RX_FULL) ? ASSERT_LINE : CLEAR_LINE); + // logerror("mpu status write %02x (%04x)\n", m_mpu_status, m_cpu->pc()); +} + +u8 ks0164_device::mpu401_r() +{ + m_mpu_status &= ~MPUS_RX_FULL; + m_cpu->set_input_line(11, CLEAR_LINE); + // logerror("mpu_r %02x (%04x)\n", m_mpu_in, m_cpu->pc()); + return m_mpu_in; +} + +void ks0164_device::mpu401_w(u8 data) +{ + m_mpu_out = data; + m_mpu_status |= MPUS_TX_FULL; + // logerror("mpu_w %02x (%04x)\n", m_mpu_out, m_cpu->pc()); +} + u16 ks0164_device::vec_r(offs_t offset, u16 mem_mask) { return m_mem_cache->read_word(offset << 1, mem_mask); @@ -138,7 +234,8 @@ u16 ks0164_device::voice_r(offs_t offset) void ks0164_device::voice_w(offs_t offset, u16 data, u16 mem_mask) { COMBINE_DATA(&m_sregs[m_voice_select & 0x1f][offset]); - logerror("voice %02x.%02x = %04x (%04x)\n", m_voice_select & 0x1f, offset, m_sregs[m_voice_select & 0x1f][offset], m_cpu->pc()); + if(m_cpu->pc() < 0x5f94 || m_cpu->pc() > 0x5fc0) + logerror("voice %02x.%02x = %04x (%04x)\n", m_voice_select & 0x1f, offset, m_sregs[m_voice_select & 0x1f][offset], m_cpu->pc()); } u8 ks0164_device::irqen_76_r() @@ -203,6 +300,9 @@ void ks0164_device::cpu_map(address_map &map) map(0x0062, 0x0063).rw(FUNC(ks0164_device::bank1_select_r), FUNC(ks0164_device::bank1_select_w)); map(0x0064, 0x0065).rw(FUNC(ks0164_device::bank2_select_r), FUNC(ks0164_device::bank2_select_w)); + map(0x0068, 0x0068).rw(FUNC(ks0164_device::mpu401_r), FUNC(ks0164_device::mpu401_w)); + map(0x0069, 0x0069).rw(FUNC(ks0164_device::mpu401_istatus_r), FUNC(ks0164_device::mpu401_istatus_w)); + map(0x0076, 0x0076).rw(FUNC(ks0164_device::irqen_76_r), FUNC(ks0164_device::irqen_76_w)); map(0x0077, 0x0077).rw(FUNC(ks0164_device::irqen_77_r), FUNC(ks0164_device::irqen_77_w)); diff --git a/src/devices/sound/ks0164.h b/src/devices/sound/ks0164.h index f93bc45e1a6..2edb82d590f 100644 --- a/src/devices/sound/ks0164.h +++ b/src/devices/sound/ks0164.h @@ -29,6 +29,14 @@ protected: virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; private: + enum { + MPUS_RX_FULL = 0x01, + MPUS_TX_FULL = 0x02, + MPUS_RX_CTRL = 0x04, + MPUS_TX_INT = 0x40, + MPUS_RX_INT = 0x80 + }; + optional_memory_region m_mem_region; required_device<ks0164_cpu_device> m_cpu; address_space_config m_mem_config; @@ -41,6 +49,10 @@ private: u16 m_sregs[0x20][0x20]; + u8 m_mpu_in; + u8 m_mpu_out; + u8 m_mpu_status; + u8 m_unk60; u8 m_voice_select; u8 m_irqen_76, m_irqen_77; @@ -69,6 +81,12 @@ private: void voice_select_w(u8 data); u16 voice_r(offs_t offset); void voice_w(offs_t offset, u16 data, u16 mem_mask); + void mpuin_set(bool control, u8 data); + + u8 mpu401_r(); + void mpu401_w(u8 data); + u8 mpu401_istatus_r(); + void mpu401_istatus_w(u8 data); }; DECLARE_DEVICE_TYPE(KS0164, ks0164_device) diff --git a/src/mame/drivers/dgpix.cpp b/src/mame/drivers/dgpix.cpp index 3ac9f13aa37..29484abd2d0 100644 --- a/src/mame/drivers/dgpix.cpp +++ b/src/mame/drivers/dgpix.cpp @@ -210,8 +210,37 @@ private: u32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); void mem_map(address_map &map); void io_map(address_map &map); + + void mpu401_data_w(offs_t, u32 data, u32 mem_mask); + void mpu401_ctrl_w(offs_t, u32 data, u32 mem_mask); + u32 mpu401_data_r(offs_t, u32 mem_mask); + u32 mpu401_status_r(); }; +void dgpix_state::mpu401_data_w(offs_t, u32 data, u32 mem_mask) +{ + if(ACCESSING_BITS_0_7) + m_sound->mpu401_data_w(data); +} + +void dgpix_state::mpu401_ctrl_w(offs_t, u32 data, u32 mem_mask) +{ + if(ACCESSING_BITS_0_7) + m_sound->mpu401_ctrl_w(data); +} + +u32 dgpix_state::mpu401_data_r(offs_t, u32 mem_mask) +{ + if(ACCESSING_BITS_0_7) + return m_sound->mpu401_data_r(); + return 0; +} + +u32 dgpix_state::mpu401_status_r() +{ + return m_sound->mpu401_status_r(); +} + u32 dgpix_state::flash_r(offs_t offset) { u32 *ROM = (u32 *)m_flash->base(); @@ -340,9 +369,8 @@ void dgpix_state::io_map(address_map &map) map(0x0a10, 0x0a13).portr("INPUTS"); map(0x0200, 0x0203).w(FUNC(dgpix_state::coin_w)); map(0x0c00, 0x0c03).nopw(); // writes only: 1, 0, 1 at startup - map(0x0c80, 0x0c83).nopw(); // sound commands / latches - map(0x0c80, 0x0c83).nopr(); //read at startup -> cmp 0xFE - map(0x0c84, 0x0c87).nopr(); // sound status, checks bit 0x40 and 0x80 + map(0x0c80, 0x0c83).rw(FUNC(dgpix_state::mpu401_data_r), FUNC(dgpix_state::mpu401_data_w)); + map(0x0c84, 0x0c87).rw(FUNC(dgpix_state::mpu401_status_r), FUNC(dgpix_state::mpu401_ctrl_w)); } static INPUT_PORTS_START( dgpix ) |