From c6dca189a364833bb9021da94af7fc5fe0b17888 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Banaan=20Ananas?= Date: Sat, 27 Sep 2014 04:09:15 +0000 Subject: [PATCH] machine/maniach.c filename different from driver name was confusing. decided to move code to the driver file instead of renaming the file, only 120 lines anyway --- .gitattributes | 1 - src/mame/drivers/matmania.c | 144 +++++++++++++++++++++++++++++++---- src/mame/includes/matmania.h | 69 +++++++++-------- src/mame/machine/maniach.c | 135 -------------------------------- src/mame/mame.mak | 2 +- src/mame/video/matmania.c | 15 ++-- 6 files changed, 172 insertions(+), 194 deletions(-) delete mode 100644 src/mame/machine/maniach.c diff --git a/.gitattributes b/.gitattributes index 71e01f7be7c..a3f21308911 100644 --- a/.gitattributes +++ b/.gitattributes @@ -6934,7 +6934,6 @@ src/mame/machine/konppc.h svneol=native#text/plain src/mame/machine/leland.c svneol=native#text/plain src/mame/machine/lkage.c svneol=native#text/plain src/mame/machine/lsasquad.c svneol=native#text/plain -src/mame/machine/maniach.c svneol=native#text/plain src/mame/machine/maple-dc.c svneol=native#text/plain src/mame/machine/maple-dc.h svneol=native#text/plain src/mame/machine/mapledev.c svneol=native#text/plain diff --git a/src/mame/drivers/matmania.c b/src/mame/drivers/matmania.c index b9abce3112a..36cca045f86 100644 --- a/src/mame/drivers/matmania.c +++ b/src/mame/drivers/matmania.c @@ -38,9 +38,133 @@ The driver has been updated accordingly. #include "sound/3526intf.h" #include "includes/matmania.h" + /************************************* * - * Memory handlers + * 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; +} + + +/************************************* + * + * Misc Memory handlers * *************************************/ @@ -296,10 +420,6 @@ GFXDECODE_END * *************************************/ -MACHINE_START_MEMBER(matmania_state,matmania) -{ -} - static MACHINE_CONFIG_START( matmania, matmania_state ) /* basic machine hardware */ @@ -310,10 +430,8 @@ static MACHINE_CONFIG_START( matmania, matmania_state ) MCFG_CPU_ADD("audiocpu", M6502, 1200000) /* 1.2 MHz ???? */ MCFG_CPU_PROGRAM_MAP(matmania_sound_map) MCFG_CPU_PERIODIC_INT_DRIVER(matmania_state, nmi_line_pulse, 15*60) /* ???? */ - /* IRQs are caused by the main CPU */ - MCFG_QUANTUM_TIME(attotime::from_hz(600)) - MCFG_MACHINE_START_OVERRIDE(matmania_state,matmania) + MCFG_QUANTUM_TIME(attotime::from_hz(6000)) /* video hardware */ MCFG_SCREEN_ADD("screen", RASTER) @@ -344,8 +462,6 @@ MACHINE_CONFIG_END MACHINE_START_MEMBER(matmania_state,maniach) { - MACHINE_START_CALL_MEMBER(matmania); - save_item(NAME(m_port_a_in)); save_item(NAME(m_port_a_out)); save_item(NAME(m_ddr_a)); @@ -387,7 +503,6 @@ static MACHINE_CONFIG_START( maniach, matmania_state ) MCFG_CPU_ADD("audiocpu", M6809, 1500000) /* 1.5 MHz ???? */ MCFG_CPU_PROGRAM_MAP(maniach_sound_map) - /* IRQs are caused by the main CPU */ 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) @@ -421,6 +536,7 @@ static MACHINE_CONFIG_START( maniach, matmania_state ) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.40) MACHINE_CONFIG_END + /************************************* * * ROM definition(s) @@ -656,6 +772,6 @@ ROM_END *************************************/ GAME( 1985, matmania, 0, matmania, matmania, driver_device, 0, ROT270, "Technos Japan (Taito America license)", "Mat Mania", GAME_SUPPORTS_SAVE ) -GAME( 1985, excthour, matmania, matmania, maniach, driver_device, 0, ROT270, "Technos Japan (Taito license)", "Exciting Hour", GAME_SUPPORTS_SAVE ) -GAME( 1986, maniach, 0, maniach, maniach, driver_device, 0, ROT270, "Technos Japan (Taito America license)", "Mania Challenge (set 1)", GAME_SUPPORTS_SAVE ) -GAME( 1986, maniach2, maniach, maniach, maniach, driver_device, 0, ROT270, "Technos Japan (Taito America license)", "Mania Challenge (set 2)", GAME_SUPPORTS_SAVE ) /* earlier version? */ +GAME( 1985, excthour, matmania, matmania, maniach, driver_device, 0, ROT270, "Technos Japan (Taito license)", "Exciting Hour", GAME_SUPPORTS_SAVE ) +GAME( 1986, maniach, 0, maniach, maniach, driver_device, 0, ROT270, "Technos Japan (Taito America license)", "Mania Challenge (set 1)", GAME_SUPPORTS_SAVE ) +GAME( 1986, maniach2, maniach, maniach, maniach, driver_device, 0, ROT270, "Technos Japan (Taito America license)", "Mania Challenge (set 2)", GAME_SUPPORTS_SAVE ) /* earlier version? */ diff --git a/src/mame/includes/matmania.h b/src/mame/includes/matmania.h index b454076132b..08929c579ff 100644 --- a/src/mame/includes/matmania.h +++ b/src/mame/includes/matmania.h @@ -19,7 +19,8 @@ public: m_mcu(*this, "mcu"), m_gfxdecode(*this, "gfxdecode"), m_screen(*this, "screen"), - m_palette(*this, "palette") { } + m_palette(*this, "palette") + { } /* memory pointers */ required_shared_ptr m_videoram; @@ -33,26 +34,6 @@ public: required_shared_ptr m_spriteram; required_shared_ptr m_paletteram; - /* video-related */ - bitmap_ind16 *m_tmpbitmap; - bitmap_ind16 *m_tmpbitmap2; - - /* mcu */ - /* maniach 68705 protection */ - UINT8 m_port_a_in; - UINT8 m_port_a_out; - UINT8 m_ddr_a; - UINT8 m_port_b_in; - UINT8 m_port_b_out; - UINT8 m_ddr_b; - UINT8 m_port_c_in; - UINT8 m_port_c_out; - UINT8 m_ddr_c; - UINT8 m_from_main; - UINT8 m_from_mcu; - int m_mcu_sent; - int m_main_sent; - /* devices */ required_device m_maincpu; required_device m_audiocpu; @@ -61,27 +42,45 @@ public: required_device m_screen; required_device m_palette; + /* video-related */ + bitmap_ind16 *m_tmpbitmap; + bitmap_ind16 *m_tmpbitmap2; + + /* maniach 68705 protection */ + UINT8 m_port_a_in; + UINT8 m_port_a_out; + UINT8 m_ddr_a; + UINT8 m_port_b_in; + UINT8 m_port_b_out; + UINT8 m_ddr_b; + UINT8 m_port_c_in; + UINT8 m_port_c_out; + UINT8 m_ddr_c; + UINT8 m_from_main; + UINT8 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(); DECLARE_PALETTE_INIT(matmania); - DECLARE_MACHINE_START(matmania); DECLARE_MACHINE_START(maniach); DECLARE_MACHINE_RESET(maniach); UINT32 screen_update_matmania(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); UINT32 screen_update_maniach(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - /*----------- defined in machine/maniach.c -----------*/ - 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 ); }; diff --git a/src/mame/machine/maniach.c b/src/mame/machine/maniach.c deleted file mode 100644 index ebd425a9acd..00000000000 --- a/src/mame/machine/maniach.c +++ /dev/null @@ -1,135 +0,0 @@ -/*************************************************************************** - - machine.c - - Functions to emulate general aspects of the machine (RAM, ROM, interrupts, - I/O ports) - -***************************************************************************/ - -#include "emu.h" -#include "includes/matmania.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; -} diff --git a/src/mame/mame.mak b/src/mame/mame.mak index f5934b43081..cef57327577 100644 --- a/src/mame/mame.mak +++ b/src/mame/mame.mak @@ -1976,7 +1976,7 @@ $(MAMEOBJ)/technos.a: \ $(DRIVERS)/ddragon.o $(VIDEO)/ddragon.o \ $(DRIVERS)/ddragon3.o $(VIDEO)/ddragon3.o \ $(DRIVERS)/dogfgt.o $(VIDEO)/dogfgt.o \ - $(DRIVERS)/matmania.o $(MACHINE)/maniach.o $(VIDEO)/matmania.o \ + $(DRIVERS)/matmania.o $(VIDEO)/matmania.o \ $(DRIVERS)/mystston.o $(VIDEO)/mystston.o \ $(DRIVERS)/renegade.o $(VIDEO)/renegade.o \ $(DRIVERS)/scregg.o \ diff --git a/src/mame/video/matmania.c b/src/mame/video/matmania.c index 6e71b0332c8..24b0b42a231 100644 --- a/src/mame/video/matmania.c +++ b/src/mame/video/matmania.c @@ -41,12 +41,12 @@ bit 0 -- 2.2kohm resistor -- BLUE ***************************************************************************/ + PALETTE_INIT_MEMBER(matmania_state, matmania) { const UINT8 *color_prom = memregion("proms")->base(); - int i; - for (i = 0; i < 64; i++) + for (int i = 0; i < 64; i++) { int bit0, bit1, bit2, bit3, r, g, b; @@ -77,33 +77,32 @@ WRITE8_MEMBER(matmania_state::matmania_paletteram_w) { int bit0, bit1, bit2, bit3, val; int r, g, b; - int offs2; m_paletteram[offset] = data; - offs2 = offset & 0x0f; + offset &= 0x0f; - val = m_paletteram[offs2]; + val = m_paletteram[offset]; bit0 = BIT(val, 0); bit1 = BIT(val, 1); bit2 = BIT(val, 2); bit3 = BIT(val, 3); r = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3; - val = m_paletteram[offs2 | 0x10]; + val = m_paletteram[offset | 0x10]; bit0 = BIT(val, 0); bit1 = BIT(val, 1); bit2 = BIT(val, 2); bit3 = BIT(val, 3); g = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3; - val = m_paletteram[offs2 | 0x20]; + val = m_paletteram[offset | 0x20]; bit0 = BIT(val, 0); bit1 = BIT(val, 1); bit2 = BIT(val, 2); bit3 = BIT(val, 3); b = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3; - m_palette->set_pen_color(offs2 + 64,rgb_t(r,g,b)); + m_palette->set_pen_color(offset + 64, rgb_t(r,g,b)); }