From c3b40f860701454678868be2c8d2caeff7739580 Mon Sep 17 00:00:00 2001 From: Angelo Salese Date: Wed, 17 Jul 2013 20:45:52 +0000 Subject: [PATCH] Tried to hook-up the MCU, without much luck ... --- src/mame/drivers/stfight.c | 13 ++--- src/mame/includes/stfight.h | 28 +++++++++- src/mame/machine/stfight.c | 101 +++++++++++++++++++++++++++++++++++- 3 files changed, 132 insertions(+), 10 deletions(-) diff --git a/src/mame/drivers/stfight.c b/src/mame/drivers/stfight.c index 12e627c501b..a72c4c8de63 100644 --- a/src/mame/drivers/stfight.c +++ b/src/mame/drivers/stfight.c @@ -264,6 +264,7 @@ static ADDRESS_MAP_START( cshooter_cpu1_map, AS_PROGRAM, 8, stfight_state ) AM_RANGE(0xc204, 0xc204) AM_READ_PORT("DSW0") AM_RANGE(0xd000, 0xd7ff) AM_RAM_WRITE(cshooter_text_w) AM_SHARE("tx_vram") AM_RANGE(0xd809, 0xd809) AM_WRITE(stfight_bank_w) + AM_RANGE(0xd818, 0xd818) AM_WRITE(cshooter_mcu_w) AM_IMPORT_FROM(cpu1_map) ADDRESS_MAP_END @@ -278,12 +279,12 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( cshooter_mcu_map, AS_PROGRAM, 8, stfight_state ) ADDRESS_MAP_GLOBAL_MASK(0x7ff) -// AM_RANGE(0x0000, 0x0000) AM_READWRITE(mexico86_68705_port_a_r,mexico86_68705_port_a_w) -// AM_RANGE(0x0001, 0x0001) AM_READWRITE(mexico86_68705_port_b_r,mexico86_68705_port_b_w) -// AM_RANGE(0x0002, 0x0002) AM_READ_PORT("IN0") /* COIN */ -// AM_RANGE(0x0004, 0x0004) AM_WRITE(mexico86_68705_ddr_a_w) -// AM_RANGE(0x0005, 0x0005) AM_WRITE(mexico86_68705_ddr_b_w) -// AM_RANGE(0x000a, 0x000a) AM_WRITENOP + AM_RANGE(0x0000, 0x0000) AM_READWRITE(cshooter_68705_port_a_r,cshooter_68705_port_a_w) + AM_RANGE(0x0001, 0x0001) AM_READWRITE(cshooter_68705_port_b_r,cshooter_68705_port_b_w) + AM_RANGE(0x0002, 0x0002) AM_READWRITE(cshooter_68705_port_c_r,cshooter_68705_port_c_w) + AM_RANGE(0x0004, 0x0004) AM_WRITE(cshooter_68705_ddr_a_w) + AM_RANGE(0x0005, 0x0005) AM_WRITE(cshooter_68705_ddr_b_w) + AM_RANGE(0x0006, 0x0006) AM_WRITE(cshooter_68705_ddr_c_w) AM_RANGE(0x0010, 0x007f) AM_RAM AM_RANGE(0x0080, 0x07ff) AM_ROM ADDRESS_MAP_END diff --git a/src/mame/includes/stfight.h b/src/mame/includes/stfight.h index 32a1bab5855..af9f07540e8 100644 --- a/src/mame/includes/stfight.h +++ b/src/mame/includes/stfight.h @@ -16,6 +16,7 @@ public: m_vh_latch_ram(*this, "vh_latch_ram"), m_sprite_ram(*this, "sprite_ram"), m_maincpu(*this, "maincpu"), + m_mcu(*this, "mcu"), m_msm(*this, "msm") { } optional_shared_ptr m_text_char_ram; @@ -23,6 +24,9 @@ public: optional_shared_ptr m_tx_vram; required_shared_ptr m_vh_latch_ram; required_shared_ptr m_sprite_ram; + required_device m_maincpu; + optional_device m_mcu; + required_device m_msm; UINT8 *m_decrypt; int m_adpcm_data_offs; int m_adpcm_data_end; @@ -67,8 +71,28 @@ public: void set_pens(); void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect); DECLARE_WRITE_LINE_MEMBER(stfight_adpcm_int); - required_device m_maincpu; - required_device m_msm; + + /* + Cross Shooter MCU specifics + */ + + DECLARE_READ8_MEMBER(cshooter_68705_port_a_r); + DECLARE_READ8_MEMBER(cshooter_68705_port_b_r); + DECLARE_READ8_MEMBER(cshooter_68705_port_c_r); + DECLARE_WRITE8_MEMBER(cshooter_68705_port_a_w); + DECLARE_WRITE8_MEMBER(cshooter_68705_port_b_w); + DECLARE_WRITE8_MEMBER(cshooter_68705_port_c_w); + + DECLARE_WRITE8_MEMBER(cshooter_68705_ddr_a_w); + DECLARE_WRITE8_MEMBER(cshooter_68705_ddr_b_w); + DECLARE_WRITE8_MEMBER(cshooter_68705_ddr_c_w); + DECLARE_WRITE8_MEMBER(cshooter_mcu_w); + + UINT8 m_portA_out, m_portA_in; + UINT8 m_portB_out, m_portB_in; + UINT8 m_portC_out, m_portC_in; + UINT8 m_ddrA, m_ddrB, m_ddrC; + UINT8 m_from_main, m_main_sent; protected: virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); diff --git a/src/mame/machine/stfight.c b/src/mame/machine/stfight.c index 983b88fb7e5..4b63003b3e3 100644 --- a/src/mame/machine/stfight.c +++ b/src/mame/machine/stfight.c @@ -123,7 +123,7 @@ void stfight_state::device_timer(emu_timer &timer, device_timer_id id, int param { case TIMER_STFIGHT_INTERRUPT_1: // Do a RST08 - m_maincpu->set_input_line_and_vector(0, HOLD_LINE, 0xcf); + m_maincpu->set_input_line_and_vector(0, HOLD_LINE, 0xd7); break; default: assert_always(FALSE, "Unknown id in stfight_state::device_timer"); @@ -133,7 +133,7 @@ void stfight_state::device_timer(emu_timer &timer, device_timer_id id, int param INTERRUPT_GEN_MEMBER(stfight_state::stfight_vb_interrupt) { // Do a RST10 - device.execute().set_input_line_and_vector(0, HOLD_LINE, 0xd7); + device.execute().set_input_line_and_vector(0, HOLD_LINE, 0xcf); timer_set(attotime::from_hz(120), TIMER_STFIGHT_INTERRUPT_1); } @@ -263,3 +263,100 @@ READ8_MEMBER(stfight_state::stfight_fm_r) return( data ); } + +/* + * Cross Shooter MCU communications + * + * TODO: everything, especially MCU to main comms + */ + +WRITE8_MEMBER(stfight_state::cshooter_68705_ddr_a_w) +{ + m_ddrA = data; +} + +WRITE8_MEMBER(stfight_state::cshooter_68705_ddr_b_w) +{ + m_ddrB = data; +} + +WRITE8_MEMBER(stfight_state::cshooter_68705_ddr_c_w) +{ + m_ddrC = data; +} + +WRITE8_MEMBER(stfight_state::cshooter_mcu_w) +{ + m_mcu->set_input_line(0, HOLD_LINE); + m_from_main = data; + m_main_sent = 1; + +} + +READ8_MEMBER(stfight_state::cshooter_68705_port_a_r) +{ + return (m_portA_out & m_ddrA) | (m_portA_in & ~m_ddrA); +} + +WRITE8_MEMBER(stfight_state::cshooter_68705_port_a_w) +{ + m_portA_out = data; +} + +READ8_MEMBER(stfight_state::cshooter_68705_port_b_r) +{ + return (m_portB_out & m_ddrB) | (m_portB_in & ~m_ddrB); +} + +WRITE8_MEMBER(stfight_state::cshooter_68705_port_b_w) +{ + if ((m_ddrB & 0x01) && (data & 0x01) && (~m_portB_out & 0x01)) + { + printf("bit 0\n"); + } + if ((m_ddrB & 0x02) && (data & 0x02) && (~m_portB_out & 0x02)) + { + printf("bit 1\n"); + } + if ((m_ddrB & 0x04) && (data & 0x04) && (~m_portB_out & 0x04)) + { + printf("bit 2\n"); + } + if ((m_ddrB & 0x08) && (data & 0x08) && (~m_portB_out & 0x08)) + { + printf("bit 3\n"); + } + if ((m_ddrB & 0x10) && (data & 0x10) && (~m_portB_out & 0x10)) + { + printf("bit 4\n"); + } + if ((m_ddrB & 0x20) && (data & 0x20) && (~m_portB_out & 0x20)) + { + m_portA_in = m_from_main; + + //if (m_main_sent) + // m_mcu->set_input_line(0, CLEAR_LINE); + + m_main_sent = 0; + } + if ((m_ddrB & 0x40) && (data & 0x40) && (~m_portB_out & 0x40)) + { + printf("bit 6\n"); + } + if ((m_ddrB & 0x80) && (data & 0x80) && (~m_portB_out & 0x80)) + { + printf("bit 7\n"); + } + + m_portB_out = data; +} + +READ8_MEMBER(stfight_state::cshooter_68705_port_c_r) +{ + return (m_portC_out & m_ddrC) | (m_portC_in & ~m_ddrC); +} + +WRITE8_MEMBER(stfight_state::cshooter_68705_port_c_w) +{ + m_portC_out = data; +}