mirror of
https://github.com/holub/mame
synced 2025-04-23 00:39:36 +03:00
ks0164: Connect the mpu (nw)
This commit is contained in:
parent
e9bcc59748
commit
0626189f0f
@ -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));
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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 )
|
||||
|
Loading…
Reference in New Issue
Block a user