diff --git a/src/mame/drivers/m68705prg.cpp b/src/mame/drivers/m68705prg.cpp index c404818f3c6..80a532b3efc 100644 --- a/src/mame/drivers/m68705prg.cpp +++ b/src/mame/drivers/m68705prg.cpp @@ -273,7 +273,7 @@ ROM_END } // anonymous namespace -// YEAR NAME PARENT COMPAT MACHINE INPUT STATE INIT COMPANY FULLNAME FLAGS -COMP( 1984, 705p3prg, 0, 0, m68705p3prg, m68705prg, m68705prg_state_base, m68705prg, "Motorola", "MC68705P3 Programmer", MACHINE_SUPPORTS_SAVE | MACHINE_NO_SOUND_HW ) -COMP( 1984, 705p5prg, 0, 0, m68705p5prg, m68705prg, m68705prg_state_base, m68705prg, "Motorola", "MC68705P5 Programmer", MACHINE_SUPPORTS_SAVE | MACHINE_NO_SOUND_HW ) -COMP( 1984, 705u3prg, 0, 0, m68705u3prg, m68705prg, m68705prg_state_base, m68705prg, "Motorola", "MC68705U3 Programmer", MACHINE_SUPPORTS_SAVE | MACHINE_NO_SOUND_HW ) +// YEAR NAME PARENT COMPAT MACHINE INPUT STATE INIT COMPANY FULLNAME FLAGS +COMP( 1984, 705p5prg, 0, 0, m68705p5prg, m68705prg, m68705prg_state_base, m68705prg, "Motorola", "MC68705P5 Programmer", MACHINE_SUPPORTS_SAVE | MACHINE_NO_SOUND_HW ) +COMP( 1984, 705p3prg, 705p5prg, 0, m68705p3prg, m68705prg, m68705prg_state_base, m68705prg, "Motorola", "MC68705P3 Programmer", MACHINE_SUPPORTS_SAVE | MACHINE_NO_SOUND_HW ) +COMP( 1984, 705u3prg, 705p5prg, 0, m68705u3prg, m68705prg, m68705prg_state_base, m68705prg, "Motorola", "MC68705U3 Programmer", MACHINE_SUPPORTS_SAVE | MACHINE_NO_SOUND_HW ) diff --git a/src/mame/drivers/matmania.cpp b/src/mame/drivers/matmania.cpp index 09a52909506..eae4cc915b8 100644 --- a/src/mame/drivers/matmania.cpp +++ b/src/mame/drivers/matmania.cpp @@ -33,136 +33,14 @@ The driver has been updated accordingly. #include "emu.h" #include "includes/matmania.h" + #include "cpu/m6502/m6502.h" #include "cpu/m6809/m6809.h" -#include "cpu/m6805/m68705.h" #include "sound/3526intf.h" #include "sound/ay8910.h" #include "sound/dac.h" #include "sound/volt_reg.h" -/************************************* - * - * Mania Challenge 68705 protection interface - * - * The following is ENTIRELY GUESSWORK!!! - * - *************************************/ - -READ8_MEMBER(matmania_state::maniach_68705_port_a_r) -{ - //logerror("%04x: 68705 port A read %02x\n", space.device().safe_pc(), m_port_a_in); - return (m_port_a_out & m_ddr_a) | (m_port_a_in & ~m_ddr_a); -} - -WRITE8_MEMBER(matmania_state::maniach_68705_port_a_w) -{ - //logerror("%04x: 68705 port A write %02x\n", space.device().safe_pc(), data); - m_port_a_out = data; -} - -WRITE8_MEMBER(matmania_state::maniach_68705_ddr_a_w) -{ - m_ddr_a = data; -} - - -/* - * Port B connections: - * - * all bits are logical 1 when read (+5V pullup) - * - * 1 W when 1->0, enables latch which brings the command from main CPU (read from port A) - * 2 W when 0->1, copies port A to the latch for the main CPU - */ - -READ8_MEMBER(matmania_state::maniach_68705_port_b_r) -{ - return (m_port_b_out & m_ddr_b) | (m_port_b_in & ~m_ddr_b); -} - -WRITE8_MEMBER(matmania_state::maniach_68705_port_b_w) -{ - //logerror("%04x: 68705 port B write %02x\n", space.device().safe_pc(), data); - - if (BIT(m_ddr_b, 1) && BIT(~data, 1) && BIT(m_port_b_out, 1)) - { - m_port_a_in = m_from_main; - m_main_sent = 0; - //logerror("read command %02x from main cpu\n", m_port_a_in); - } - if (BIT(m_ddr_b, 2) && BIT(data, 2) && BIT(~m_port_b_out, 2)) - { - //logerror("send command %02x to main cpu\n", m_port_a_out); - m_from_mcu = m_port_a_out; - m_mcu_sent = 1; - } - - m_port_b_out = data; -} - -WRITE8_MEMBER(matmania_state::maniach_68705_ddr_b_w) -{ - m_ddr_b = data; -} - - -READ8_MEMBER(matmania_state::maniach_68705_port_c_r) -{ - m_port_c_in = 0; - - if (m_main_sent) - m_port_c_in |= 0x01; - - if (!m_mcu_sent) - m_port_c_in |= 0x02; - - //logerror("%04x: 68705 port C read %02x\n",m_space->device().safe_pc(), m_port_c_in); - - return (m_port_c_out & m_ddr_c) | (m_port_c_in & ~m_ddr_c); -} - -WRITE8_MEMBER(matmania_state::maniach_68705_port_c_w) -{ - //logerror("%04x: 68705 port C write %02x\n", space.device().safe_pc(), data); - m_port_c_out = data; -} - -WRITE8_MEMBER(matmania_state::maniach_68705_ddr_c_w) -{ - m_ddr_c = data; -} - - -WRITE8_MEMBER(matmania_state::maniach_mcu_w) -{ - //logerror("%04x: 3040_w %02x\n", space.device().safe_pc(), data); - m_from_main = data; - m_main_sent = 1; -} - -READ8_MEMBER(matmania_state::maniach_mcu_r) -{ - //logerror("%04x: 3040_r %02x\n", space.device().safe_pc(), m_from_mcu); - m_mcu_sent = 0; - return m_from_mcu; -} - -READ8_MEMBER(matmania_state::maniach_mcu_status_r) -{ - int res = 0; - - /* bit 0 = when 0, mcu has sent data to the main cpu */ - /* bit 1 = when 1, mcu is ready to receive data from main cpu */ - //logerror("%04x: 3041_r\n", space.device().safe_pc()); - if (!m_mcu_sent) - res |= 0x01; - if (!m_main_sent) - res |= 0x02; - - return res; -} - /************************************* * @@ -170,6 +48,12 @@ READ8_MEMBER(matmania_state::maniach_mcu_status_r) * *************************************/ +READ8_MEMBER(matmania_state::maniach_mcu_status_r) +{ + // semaphore bits swapped compared to other games + return (m_mcu->get_main_sent() ? 0x00 : 0x02) | (m_mcu->get_mcu_sent() ? 0x00 : 0x01); +} + WRITE8_MEMBER(matmania_state::matmania_sh_command_w) { m_soundlatch->write(space, offset, data); @@ -219,7 +103,7 @@ static ADDRESS_MAP_START( maniach_map, AS_PROGRAM, 8, matmania_state ) AM_RANGE(0x3010, 0x3010) AM_READ_PORT("IN1") AM_WRITE(maniach_sh_command_w) AM_RANGE(0x3020, 0x3020) AM_READ_PORT("DSW2") AM_WRITEONLY AM_SHARE("scroll") AM_RANGE(0x3030, 0x3030) AM_READ_PORT("DSW1") AM_WRITENOP /* ?? */ - AM_RANGE(0x3040, 0x3040) AM_READWRITE(maniach_mcu_r,maniach_mcu_w) + AM_RANGE(0x3040, 0x3040) AM_DEVREADWRITE("mcu", taito68705_mcu_device, data_r, data_w) AM_RANGE(0x3041, 0x3041) AM_READ(maniach_mcu_status_r) AM_RANGE(0x3050, 0x307f) AM_WRITE(matmania_paletteram_w) AM_SHARE("paletteram") AM_RANGE(0x4000, 0xffff) AM_ROM @@ -244,19 +128,6 @@ static ADDRESS_MAP_START( maniach_sound_map, AS_PROGRAM, 8, matmania_state ) ADDRESS_MAP_END -static ADDRESS_MAP_START( maniach_mcu_map, AS_PROGRAM, 8, matmania_state ) - ADDRESS_MAP_GLOBAL_MASK(0x7ff) - AM_RANGE(0x0000, 0x0000) AM_READWRITE(maniach_68705_port_a_r,maniach_68705_port_a_w) - AM_RANGE(0x0001, 0x0001) AM_READWRITE(maniach_68705_port_b_r,maniach_68705_port_b_w) - AM_RANGE(0x0002, 0x0002) AM_READWRITE(maniach_68705_port_c_r,maniach_68705_port_c_w) - AM_RANGE(0x0004, 0x0004) AM_WRITE(maniach_68705_ddr_a_w) - AM_RANGE(0x0005, 0x0005) AM_WRITE(maniach_68705_ddr_b_w) - AM_RANGE(0x0006, 0x0006) AM_WRITE(maniach_68705_ddr_c_w) - AM_RANGE(0x0010, 0x007f) AM_RAM - AM_RANGE(0x0080, 0x07ff) AM_ROM -ADDRESS_MAP_END - - /************************************* * * Input ports @@ -465,40 +336,6 @@ static MACHINE_CONFIG_START( matmania, matmania_state ) MACHINE_CONFIG_END -MACHINE_START_MEMBER(matmania_state,maniach) -{ - save_item(NAME(m_port_a_in)); - save_item(NAME(m_port_a_out)); - save_item(NAME(m_ddr_a)); - save_item(NAME(m_port_b_in)); - save_item(NAME(m_port_b_out)); - save_item(NAME(m_ddr_b)); - save_item(NAME(m_port_c_in)); - save_item(NAME(m_port_c_out)); - save_item(NAME(m_ddr_c)); - save_item(NAME(m_mcu_sent)); - save_item(NAME(m_main_sent)); - save_item(NAME(m_from_main)); - save_item(NAME(m_from_mcu)); -} - -MACHINE_RESET_MEMBER(matmania_state,maniach) -{ - m_port_a_in = 0; - m_port_a_out = 0; - m_ddr_a = 0; - m_port_b_in = 0; - m_port_b_out = 0; - m_ddr_b = 0; - m_port_c_in = 0; - m_port_c_out = 0; - m_ddr_c = 0; - m_mcu_sent = 0; - m_main_sent = 0; - m_from_main = 0; - m_from_mcu = 0; -} - static MACHINE_CONFIG_START( maniach, matmania_state ) /* basic machine hardware */ @@ -509,13 +346,9 @@ static MACHINE_CONFIG_START( maniach, matmania_state ) MCFG_CPU_ADD("audiocpu", M6809, 1500000) /* 1.5 MHz ???? */ MCFG_CPU_PROGRAM_MAP(maniach_sound_map) - MCFG_CPU_ADD("mcu", M68705, 1500000*2) /* (don't know really how fast, but it doesn't need to even be this fast) */ - MCFG_CPU_PROGRAM_MAP(maniach_mcu_map) + MCFG_CPU_ADD("mcu", TAITO68705_MCU, 1500000) /* (don't know really how fast, but it doesn't need to even be this fast) */ - MCFG_QUANTUM_TIME(attotime::from_hz(6000)) /* 100 CPU slice per frame - high interleaving to sync main and mcu */ - - MCFG_MACHINE_START_OVERRIDE(matmania_state,maniach) - MCFG_MACHINE_RESET_OVERRIDE(matmania_state,maniach) + MCFG_QUANTUM_PERFECT_CPU("mcu:mcu") /* high interleaving to sync main and mcu */ /* video hardware */ MCFG_SCREEN_ADD("screen", RASTER) @@ -662,7 +495,7 @@ ROM_START( maniach ) ROM_LOAD( "mc-m40.bin", 0x8000, 0x4000, CRC(2a217ed0) SHA1(b06f7c9a2c96ffe78a7065e5edadfdbf985305a5) ) ROM_LOAD( "mc-m30.bin", 0xc000, 0x4000, CRC(95af1723) SHA1(691ca3f7400d10897e805ff691c904fb2d5bb53a) ) - ROM_REGION( 0x0800, "mcu", 0 ) /* 8k for the microcontroller */ + ROM_REGION( 0x0800, "mcu:mcu", 0 ) /* 2k for the microcontroller */ ROM_LOAD( "01", 0x0000, 0x0800, CRC(00c7f80c) SHA1(d2216f660eb8310b1530fa5dc844d26ba90c5e9c) ) ROM_REGION( 0x06000, "gfx1", 0 ) @@ -722,7 +555,7 @@ ROM_START( maniach2 ) ROM_LOAD( "mc-m40.bin", 0x8000, 0x4000, CRC(2a217ed0) SHA1(b06f7c9a2c96ffe78a7065e5edadfdbf985305a5) ) ROM_LOAD( "mc-m30.bin", 0xc000, 0x4000, CRC(95af1723) SHA1(691ca3f7400d10897e805ff691c904fb2d5bb53a) ) - ROM_REGION( 0x0800, "mcu", 0 ) /* 8k for the microcontroller */ + ROM_REGION( 0x0800, "mcu:mcu", 0 ) /* 2k for the microcontroller */ ROM_LOAD( "01", 0x0000, 0x0800, CRC(00c7f80c) SHA1(d2216f660eb8310b1530fa5dc844d26ba90c5e9c) ) ROM_REGION( 0x06000, "gfx1", 0 ) diff --git a/src/mame/includes/matmania.h b/src/mame/includes/matmania.h index 9ddecb93e1d..fe2da57d832 100644 --- a/src/mame/includes/matmania.h +++ b/src/mame/includes/matmania.h @@ -1,6 +1,8 @@ // license:BSD-3-Clause // copyright-holders:Brad Oliver +#include "machine/taito68705interface.h" + #include "machine/gen_latch.h" class matmania_state : public driver_device @@ -42,7 +44,7 @@ public: /* devices */ required_device m_maincpu; required_device m_audiocpu; - optional_device m_mcu; + optional_device m_mcu; required_device m_gfxdecode; required_device m_screen; required_device m_palette; @@ -52,41 +54,12 @@ public: std::unique_ptr m_tmpbitmap; std::unique_ptr m_tmpbitmap2; - /* maniach 68705 protection */ - uint8_t m_port_a_in; - uint8_t m_port_a_out; - uint8_t m_ddr_a; - uint8_t m_port_b_in; - uint8_t m_port_b_out; - uint8_t m_ddr_b; - uint8_t m_port_c_in; - uint8_t m_port_c_out; - uint8_t m_ddr_c; - uint8_t m_from_main; - uint8_t m_from_mcu; - int m_mcu_sent; - int m_main_sent; - - DECLARE_READ8_MEMBER(maniach_68705_port_a_r); - DECLARE_WRITE8_MEMBER(maniach_68705_port_a_w); - DECLARE_READ8_MEMBER(maniach_68705_port_b_r); - DECLARE_WRITE8_MEMBER(maniach_68705_port_b_w); - DECLARE_READ8_MEMBER(maniach_68705_port_c_r); - DECLARE_WRITE8_MEMBER(maniach_68705_port_c_w); - DECLARE_WRITE8_MEMBER(maniach_68705_ddr_a_w); - DECLARE_WRITE8_MEMBER(maniach_68705_ddr_b_w); - DECLARE_WRITE8_MEMBER(maniach_68705_ddr_c_w); - DECLARE_WRITE8_MEMBER(maniach_mcu_w); - DECLARE_READ8_MEMBER(maniach_mcu_r); DECLARE_READ8_MEMBER(maniach_mcu_status_r); - DECLARE_WRITE8_MEMBER(matmania_sh_command_w); DECLARE_WRITE8_MEMBER(maniach_sh_command_w); DECLARE_WRITE8_MEMBER(matmania_paletteram_w); virtual void video_start() override; DECLARE_PALETTE_INIT(matmania); - DECLARE_MACHINE_START(maniach); - DECLARE_MACHINE_RESET(maniach); uint32_t screen_update_matmania(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); uint32_t screen_update_maniach(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); }; diff --git a/src/mame/machine/taito68705interface.cpp b/src/mame/machine/taito68705interface.cpp index 7cb3bda1c3e..0007610e317 100644 --- a/src/mame/machine/taito68705interface.cpp +++ b/src/mame/machine/taito68705interface.cpp @@ -21,10 +21,13 @@ lkage.cpp - lkage bigevglf.cpp - bigevglf xain.cpp - xsleena + matmania.cpp - maniach and the following with slight changes: - slapfght.cpp - tigerh (inverted status bits read on portC) + slapfght.cpp - tigerh (inverted status bits read on port C) - slapfght (extended outputs for scrolling) + arkanoid.cpp - arkanoid (latch control on port C, inputs on port B) + taito_l.cpp - puzznic (latch control on port C) not hooked up here, but possible (needs investigating) @@ -32,7 +35,6 @@ taitosj.cpp - ^^ changela.cpp - ^^ renegade.cpp - ^^ - matmania.cpp - ^^ 68705 sets in Taito drivers that are NOT suitable for hookup here? bublbobl.cpp - bub68705 - this is a bootleg, not an official Taito hookup @@ -193,6 +195,9 @@ u8 taito68705_mcu_device_base::pa_value() const void taito68705_mcu_device_base::latch_control(u8 data, u8 &value, unsigned host_bit, unsigned mcu_bit) { + // save this here to simulate latch propagation delays + u8 const old_pa_value(pa_value()); + // rising edge clears the host semaphore flag if (BIT(data, host_bit)) { @@ -218,7 +223,7 @@ void taito68705_mcu_device_base::latch_control(u8 data, u8 &value, unsigned host // data is latched on falling edge if (BIT(value, mcu_bit)) - m_mcu_latch = pa_value(); + m_mcu_latch = old_pa_value; } value = data;