From 8f2cf0789ed080211b9f26e57eff0e2044779c86 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Sun, 1 May 2016 15:22:26 +0200 Subject: [PATCH] ladybug and redclash split (nw) --- scripts/target/mame/arcade.lua | 1 + src/mame/drivers/ladybug.cpp | 327 ------------------------- src/mame/drivers/redclash.cpp | 425 ++++++++++++++++++++++++++++++--- src/mame/includes/ladybug.h | 49 +--- src/mame/includes/redclash.h | 64 +++++ src/mame/mame.lst | 2 +- src/mame/video/ladybug.cpp | 142 +---------- src/mame/video/redclash.cpp | 183 ++++++++++++-- 8 files changed, 625 insertions(+), 568 deletions(-) create mode 100644 src/mame/includes/redclash.h diff --git a/scripts/target/mame/arcade.lua b/scripts/target/mame/arcade.lua index 2d39af60ee9..869c800a378 100644 --- a/scripts/target/mame/arcade.lua +++ b/scripts/target/mame/arcade.lua @@ -3954,6 +3954,7 @@ files { MAME_DIR .. "src/mame/includes/mrdo.h", MAME_DIR .. "src/mame/video/mrdo.cpp", MAME_DIR .. "src/mame/drivers/redclash.cpp", + MAME_DIR .. "src/mame/includes/redclash.h", MAME_DIR .. "src/mame/video/redclash.cpp", MAME_DIR .. "src/mame/drivers/superdq.cpp", } diff --git a/src/mame/drivers/ladybug.cpp b/src/mame/drivers/ladybug.cpp index a6ebabbf911..d5f22026828 100644 --- a/src/mame/drivers/ladybug.cpp +++ b/src/mame/drivers/ladybug.cpp @@ -66,65 +66,6 @@ TODO: #include "includes/ladybug.h" -/* Sound comm between CPU's */ -READ8_MEMBER(ladybug_state::sraider_sound_low_r) -{ - return m_sound_low; -} - -READ8_MEMBER(ladybug_state::sraider_sound_high_r) -{ - return m_sound_high; -} - -WRITE8_MEMBER(ladybug_state::sraider_sound_low_w) -{ - m_sound_low = data; -} - -WRITE8_MEMBER(ladybug_state::sraider_sound_high_w) -{ - m_sound_high = data; -} - -/* Protection? */ -READ8_MEMBER(ladybug_state::sraider_8005_r) -{ - /* This must return X011111X or cpu #1 will hang */ - /* see code at rst $10 */ - return 0x3e; -} - -/* Unknown IO */ -WRITE8_MEMBER(ladybug_state::sraider_misc_w) -{ - switch(offset) - { - /* These 8 bits are stored in the latch at A7 */ - case 0x00: - case 0x01: - case 0x02: - case 0x03: - case 0x04: - case 0x05: - case 0x06: - case 0x07: - m_weird_value[offset & 7] = data & 1; - break; - /* These 6 bits are stored in the latch at N7 */ - case 0x08: - m_sraider_0x30 = data&0x3f; - break; - /* These 6 bits are stored in the latch at N8 */ - case 0x10: - m_sraider_0x38 = data&0x3f; - break; - default: - osd_printf_debug("(%04X) write to %02X\n", space.device().safe_pc(), offset); - break; - } -} - static ADDRESS_MAP_START( ladybug_map, AS_PROGRAM, 8, ladybug_state ) AM_RANGE(0x0000, 0x5fff) AM_ROM AM_RANGE(0x6000, 0x6fff) AM_RAM @@ -146,47 +87,6 @@ static ADDRESS_MAP_START( decrypted_opcodes_map, AS_DECRYPTED_OPCODES, 8, ladybu AM_RANGE(0x0000, 0x5fff) AM_ROM AM_SHARE("decrypted_opcodes") ADDRESS_MAP_END - -static ADDRESS_MAP_START( sraider_cpu1_map, AS_PROGRAM, 8, ladybug_state ) - AM_RANGE(0x0000, 0x5fff) AM_ROM - AM_RANGE(0x6000, 0x6fff) AM_RAM - AM_RANGE(0x7000, 0x73ff) AM_WRITEONLY AM_SHARE("spriteram") - AM_RANGE(0x8005, 0x8005) AM_READ(sraider_8005_r) // protection check? - AM_RANGE(0x8006, 0x8006) AM_WRITE(sraider_sound_low_w) - AM_RANGE(0x8007, 0x8007) AM_WRITE(sraider_sound_high_w) - AM_RANGE(0x9000, 0x9000) AM_READ_PORT("IN0") - AM_RANGE(0x9001, 0x9001) AM_READ_PORT("IN1") - AM_RANGE(0x9002, 0x9002) AM_READ_PORT("DSW0") - AM_RANGE(0x9003, 0x9003) AM_READ_PORT("DSW1") - AM_RANGE(0xd000, 0xd3ff) AM_WRITE(ladybug_videoram_w) AM_SHARE("videoram") - AM_RANGE(0xd400, 0xd7ff) AM_WRITE(ladybug_colorram_w) AM_SHARE("colorram") - AM_RANGE(0xe000, 0xe000) AM_WRITENOP //unknown 0x10 when in attract, 0x20 when coined/playing -ADDRESS_MAP_END - - -static ADDRESS_MAP_START( sraider_cpu2_map, AS_PROGRAM, 8, ladybug_state ) - AM_RANGE(0x0000, 0x5fff) AM_ROM - AM_RANGE(0x6000, 0x63ff) AM_RAM - AM_RANGE(0x8000, 0x8000) AM_READ(sraider_sound_low_r) - AM_RANGE(0xa000, 0xa000) AM_READ(sraider_sound_high_r) - AM_RANGE(0xc000, 0xc000) AM_READNOP //some kind of sync - AM_RANGE(0xe000, 0xe0ff) AM_WRITEONLY AM_SHARE("grid_data") - AM_RANGE(0xe800, 0xe800) AM_WRITE(sraider_io_w) -ADDRESS_MAP_END - - -static ADDRESS_MAP_START( sraider_cpu2_io_map, AS_IO, 8, ladybug_state ) - ADDRESS_MAP_GLOBAL_MASK(0xff) - AM_RANGE(0x00, 0x00) AM_DEVWRITE("sn1", sn76489_device, write) - AM_RANGE(0x08, 0x08) AM_DEVWRITE("sn2", sn76489_device, write) - AM_RANGE(0x10, 0x10) AM_DEVWRITE("sn3", sn76489_device, write) - AM_RANGE(0x18, 0x18) AM_DEVWRITE("sn4", sn76489_device, write) - AM_RANGE(0x20, 0x20) AM_DEVWRITE("sn5", sn76489_device, write) - AM_RANGE(0x28, 0x3f) AM_WRITE(sraider_misc_w) // lots unknown -ADDRESS_MAP_END - - - INPUT_CHANGED_MEMBER(ladybug_state::coin1_inserted) { /* left coin insertion causes an NMI */ @@ -567,81 +467,6 @@ static INPUT_PORTS_START( dorodon ) PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_COIN2 ) PORT_CHANGED_MEMBER(DEVICE_SELF, ladybug_state,coin2_inserted, 0) INPUT_PORTS_END -static INPUT_PORTS_START( sraider ) - PORT_START("IN0") /* IN0 */ - PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_4WAY - PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_4WAY - PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_4WAY - PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_4WAY - PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) - PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_START1 ) - PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_START2 ) - PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) - - PORT_START("IN1") /* IN1 */ - PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_4WAY PORT_COCKTAIL - PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_4WAY PORT_COCKTAIL - PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_4WAY PORT_COCKTAIL - PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_4WAY PORT_COCKTAIL - PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_COCKTAIL - PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN1 ) - PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN2 ) - - PORT_START("DSW0") /* DSW0 */ - PORT_DIPNAME( 0x03, 0x03, DEF_STR( Difficulty ) ) - PORT_DIPSETTING( 0x03, DEF_STR( Easy ) ) - PORT_DIPSETTING( 0x02, DEF_STR( Medium ) ) - PORT_DIPSETTING( 0x01, DEF_STR( Hard ) ) - PORT_DIPSETTING( 0x00, DEF_STR( Hardest ) ) - PORT_DIPNAME( 0x04, 0x04, "High Score Names" ) - PORT_DIPSETTING( 0x00, "3 Letters" ) - PORT_DIPSETTING( 0x04, "10 Letters" ) - PORT_DIPNAME( 0x08, 0x08, DEF_STR( Allow_Continue ) ) - PORT_DIPSETTING( 0x08, DEF_STR( No ) ) - PORT_DIPSETTING( 0x00, DEF_STR( Yes ) ) - PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) ) - PORT_DIPSETTING( 0x10, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x00, DEF_STR( On ) ) - PORT_DIPNAME( 0x20, 0x00, DEF_STR( Cabinet ) ) - PORT_DIPSETTING( 0x00, DEF_STR( Upright ) ) - PORT_DIPSETTING( 0x20, DEF_STR( Cocktail ) ) - PORT_DIPNAME( 0xc0, 0xc0, DEF_STR( Lives ) ) - PORT_DIPSETTING( 0x00, "2" ) - PORT_DIPSETTING( 0xc0, "3" ) - PORT_DIPSETTING( 0x80, "4" ) - PORT_DIPSETTING( 0x40, "5" ) - - /* Free Play setting works when it's set for both */ - PORT_START("DSW1") /* DSW1 */ - PORT_DIPNAME( 0x0f, 0x0f, DEF_STR( Coin_A ) ) - /* settings 0x00 through 0x05 all give 1 Coin/1 Credit */ - PORT_DIPSETTING( 0x06, DEF_STR( 4C_1C ) ) - PORT_DIPSETTING( 0x08, DEF_STR( 3C_1C ) ) - PORT_DIPSETTING( 0x0a, DEF_STR( 2C_1C ) ) - PORT_DIPSETTING( 0x07, DEF_STR( 3C_2C ) ) - PORT_DIPSETTING( 0x09, DEF_STR( 2C_2C ) ) - PORT_DIPSETTING( 0x0f, DEF_STR( 1C_1C ) ) - PORT_DIPSETTING( 0x0e, DEF_STR( 1C_2C ) ) - PORT_DIPSETTING( 0x0d, DEF_STR( 1C_3C ) ) - PORT_DIPSETTING( 0x0c, DEF_STR( 1C_4C ) ) - PORT_DIPSETTING( 0x0b, DEF_STR( 1C_5C ) ) - PORT_DIPSETTING( 0x00, DEF_STR( Free_Play ) ) - PORT_DIPNAME( 0xf0, 0xf0, DEF_STR( Coin_B ) ) - /* settings 0x00 through 0x50 all give 1 Coin/1 Credit */ - PORT_DIPSETTING( 0x60, DEF_STR( 4C_1C ) ) - PORT_DIPSETTING( 0x80, DEF_STR( 3C_1C ) ) - PORT_DIPSETTING( 0xa0, DEF_STR( 2C_1C ) ) - PORT_DIPSETTING( 0x70, DEF_STR( 3C_2C ) ) - PORT_DIPSETTING( 0x90, DEF_STR( 2C_2C ) ) - PORT_DIPSETTING( 0xf0, DEF_STR( 1C_1C ) ) - PORT_DIPSETTING( 0xe0, DEF_STR( 1C_2C ) ) - PORT_DIPSETTING( 0xd0, DEF_STR( 1C_3C ) ) - PORT_DIPSETTING( 0xc0, DEF_STR( 1C_4C ) ) - PORT_DIPSETTING( 0xb0, DEF_STR( 1C_5C ) ) - PORT_DIPSETTING( 0x00, DEF_STR( Free_Play ) ) -INPUT_PORTS_END - static const gfx_layout charlayout = { 8,8, /* 8*8 characters */ @@ -675,87 +500,16 @@ static const gfx_layout spritelayout2 = 16*8 /* every sprite takes 16 consecutive bytes */ }; -static const gfx_layout gridlayout = -{ - 8,8, /* 8*8 characters */ - 512, /* 512 characters */ - 1, /* 1 bit per pixel */ - { 0 }, - { 7, 6, 5, 4, 3, 2, 1, 0 }, - { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8}, - 8*8 /* every char takes 8 consecutive bytes */ -}; - -static const gfx_layout gridlayout2 = -{ - 8,8, /* 8*8 characters */ - 512, /* 512 characters */ - 1, /* 1 bit per pixel */ - { 0 }, - { 7, 6, 5, 4, 3, 2, 1, 0 }, - { 7*8, 6*8, 5*8, 4*8, 3*8, 2*8, 1*8, 0*8 }, - 8*8 /* every char takes 8 consecutive bytes */ -}; - static GFXDECODE_START( ladybug ) GFXDECODE_ENTRY( "gfx1", 0, charlayout, 0, 8 ) GFXDECODE_ENTRY( "gfx2", 0, spritelayout, 4*8, 16 ) GFXDECODE_ENTRY( "gfx2", 0, spritelayout2, 4*8, 16 ) GFXDECODE_END -static GFXDECODE_START( sraider ) - GFXDECODE_ENTRY( "gfx1", 0, charlayout, 0, 8 ) - GFXDECODE_ENTRY( "gfx2", 0, spritelayout, 4*8, 16 ) - GFXDECODE_ENTRY( "gfx2", 0, spritelayout2, 4*8, 16 ) - GFXDECODE_ENTRY( "gfx3", 0, gridlayout, 4*8+4*16+32, 1 ) - GFXDECODE_ENTRY( "gfx3", 0, gridlayout2, 4*8+4*16+32, 1 ) -GFXDECODE_END - - MACHINE_START_MEMBER(ladybug_state,ladybug) { } -MACHINE_START_MEMBER(ladybug_state,sraider) -{ - save_item(NAME(m_grid_color)); - save_item(NAME(m_sound_low)); - save_item(NAME(m_sound_high)); - save_item(NAME(m_sraider_0x30)); - save_item(NAME(m_sraider_0x38)); - save_item(NAME(m_weird_value)); - - /* for stars */ - save_item(NAME(m_star_speed)); - save_item(NAME(m_stars_enable)); - save_item(NAME(m_stars_speed)); - save_item(NAME(m_stars_state)); - save_item(NAME(m_stars_offset)); - save_item(NAME(m_stars_count)); -} - -MACHINE_RESET_MEMBER(ladybug_state,sraider) -{ - int i; - - m_grid_color = 0; - m_sound_low = 0; - m_sound_high = 0; - m_sraider_0x30 = 0; - m_sraider_0x38 = 0; - - /* for stars */ - m_star_speed = 0; - m_stars_enable = 0; - m_stars_speed = 0; - m_stars_state = 0; - m_stars_offset = 0; - m_stars_count = 0; - - for (i = 0; i < 8; i++) - m_weird_value[i] = 0; -} - static MACHINE_CONFIG_START( ladybug, ladybug_state ) /* basic machine hardware */ @@ -795,57 +549,6 @@ static MACHINE_CONFIG_DERIVED( dorodon, ladybug ) MCFG_CPU_DECRYPTED_OPCODES_MAP(decrypted_opcodes_map) MACHINE_CONFIG_END -static MACHINE_CONFIG_START( sraider, ladybug_state ) - - /* basic machine hardware */ - MCFG_CPU_ADD("maincpu", Z80, 4000000) /* 4 MHz */ - MCFG_CPU_PROGRAM_MAP(sraider_cpu1_map) - MCFG_CPU_VBLANK_INT_DRIVER("screen", ladybug_state, irq0_line_hold) - - MCFG_CPU_ADD("sub", Z80, 4000000) /* 4 MHz */ - MCFG_CPU_PROGRAM_MAP(sraider_cpu2_map) - MCFG_CPU_IO_MAP(sraider_cpu2_io_map) - MCFG_CPU_VBLANK_INT_DRIVER("screen", ladybug_state, irq0_line_hold) - - MCFG_MACHINE_START_OVERRIDE(ladybug_state,sraider) - MCFG_MACHINE_RESET_OVERRIDE(ladybug_state,sraider) - - /* video hardware */ - MCFG_SCREEN_ADD("screen", RASTER) - MCFG_SCREEN_REFRESH_RATE(60) - MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500) /* not accurate */) - MCFG_SCREEN_SIZE(32*8, 32*8) - MCFG_SCREEN_VISIBLE_AREA(1*8, 31*8-1, 4*8, 28*8-1) - MCFG_SCREEN_UPDATE_DRIVER(ladybug_state, screen_update_sraider) - MCFG_SCREEN_VBLANK_DRIVER(ladybug_state, screen_eof_sraider) - MCFG_SCREEN_PALETTE("palette") - - MCFG_GFXDECODE_ADD("gfxdecode", "palette", sraider) - MCFG_PALETTE_ADD("palette", 4*8+4*16+32+2) - MCFG_PALETTE_INDIRECT_ENTRIES(32+32+1) - MCFG_PALETTE_INIT_OWNER(ladybug_state,sraider) - - MCFG_VIDEO_START_OVERRIDE(ladybug_state,sraider) - - /* sound hardware */ - MCFG_SPEAKER_STANDARD_MONO("mono") - - MCFG_SOUND_ADD("sn1", SN76489, 4000000) - MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) - - MCFG_SOUND_ADD("sn2", SN76489, 4000000) - MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) - - MCFG_SOUND_ADD("sn3", SN76489, 4000000) - MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) - - MCFG_SOUND_ADD("sn4", SN76489, 4000000) - MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) - - MCFG_SOUND_ADD("sn5", SN76489, 4000000) - MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) -MACHINE_CONFIG_END - /*************************************************************************** @@ -1017,35 +720,6 @@ ROM_START( dorodon2 ) ROM_LOAD( "dorodon.bp2", 0x0040, 0x0020, CRC(27fa3a50) SHA1(7cf59b7a37c156640d6ea91554d1c4276c1780e0) ) /* timing?? */ ROM_END -ROM_START( sraider ) - ROM_REGION( 0x10000, "maincpu", 0 ) - ROM_LOAD( "sraid3.r4", 0x0000, 0x2000, CRC(0f389774) SHA1(c67596e6bf00175ff0a241506cd2f88114d05933) ) - ROM_LOAD( "sraid2.n4", 0x2000, 0x2000, CRC(38a48db0) SHA1(6f4f384d702fb8ee4bb2ef579638239d57e32ddd) ) - ROM_LOAD( "sraid1.m4", 0x4000, 0x2000, CRC(2f302a4e) SHA1(3a902ce6858f38df88b60830bef4b1d45b09b2df) ) - - ROM_REGION( 0x10000, "sub", 0 ) - ROM_LOAD( "sraid-s4.h6", 0x0000, 0x2000, CRC(57173a12) SHA1(6cb8fd4826e499f9a4e63621d58bc4b596cc261e) ) - ROM_LOAD( "sraid-s5.j6", 0x2000, 0x2000, CRC(5a459179) SHA1(a261c8f3c7c4cd4587c003bbbe815d2c4e01ffbc) ) - ROM_LOAD( "sraid-s6.l6", 0x4000, 0x2000, CRC(ea3aa25d) SHA1(353c0d075d5e0a3bc25a65e2748f5eb5212a844d) ) - - ROM_REGION( 0x2000, "gfx1", 0 ) - ROM_LOAD( "sraid-s0.k6", 0x0000, 0x1000, CRC(a0373909) SHA1(00e3bd5dd90769d670fc3c51edd1cd4b69e6132d) ) - ROM_LOAD( "sraids11.l6", 0x1000, 0x1000, CRC(ba22d949) SHA1(83762ced1df92ff594887e44d5b783826bbfb0c9) ) - - ROM_REGION( 0x2000, "gfx2", 0 ) - ROM_LOAD( "sraid-s7.m2", 0x0000, 0x1000, CRC(299f8e07) SHA1(1de71f251286088487da7285d6f8070147002af5) ) - ROM_LOAD( "sraid-s8.n2", 0x1000, 0x1000, CRC(57ba8888) SHA1(2aa1a5f682d146a55a96e471bb78e5c60da02bf9) ) - - ROM_REGION( 0x1000, "gfx3", 0 ) /* fixed portion of the grid */ - ROM_LOAD( "sraid-s9.f6", 0x0000, 0x1000, CRC(2380b90f) SHA1(0310554e3f2ec973c2bb6e816d04e5c0c1e0a0b9) ) - - ROM_REGION( 0x0060, "proms", 0 ) - ROM_LOAD( "srpr10-1.a2", 0x0000, 0x0020, CRC(121fdb99) SHA1(3bc092da40beb129a4df3db2f55d22bbbcf7bad8) ) - ROM_LOAD( "srpr10-2.l3", 0x0020, 0x0020, CRC(88b67e70) SHA1(e21ee2939e96dffee101bd92c62ed975b6b64001) ) - ROM_LOAD( "srpr10-3.c1", 0x0040, 0x0020, CRC(27fa3a50) SHA1(7cf59b7a37c156640d6ea91554d1c4276c1780e0) ) /* ?? */ -ROM_END - - DRIVER_INIT_MEMBER(ladybug_state,dorodon) { /* decode the opcodes */ @@ -1066,4 +740,3 @@ GAME( 1981, ladybgb2, ladybug, ladybug, ladybug, driver_device, 0, ROT270 GAME( 1982, dorodon, 0, dorodon, dorodon, ladybug_state, dorodon, ROT270, "UPL (Falcon license?)", "Dorodon (set 1)", MACHINE_SUPPORTS_SAVE ) // license or bootleg? GAME( 1982, dorodon2, dorodon, dorodon, dorodon, ladybug_state, dorodon, ROT270, "UPL (Falcon license?)", "Dorodon (set 2)", MACHINE_SUPPORTS_SAVE ) // " GAME( 1982, snapjack, 0, ladybug, snapjack, driver_device, 0, ROT0, "Universal", "Snap Jack", MACHINE_SUPPORTS_SAVE ) -GAME( 1982, sraider, 0, sraider, sraider, driver_device, 0, ROT270, "Universal", "Space Raider", MACHINE_SUPPORTS_SAVE ) diff --git a/src/mame/drivers/redclash.cpp b/src/mame/drivers/redclash.cpp index f2d64bccf56..ee8eebe9197 100644 --- a/src/mame/drivers/redclash.cpp +++ b/src/mame/drivers/redclash.cpp @@ -24,15 +24,114 @@ TODO: #include "emu.h" #include "cpu/z80/z80.h" -#include "includes/ladybug.h" +#include "sound/sn76496.h" +#include "includes/redclash.h" -WRITE8_MEMBER( ladybug_state::irqack_w ) +/* Sound comm between CPU's */ +READ8_MEMBER(redclash_state::sraider_sound_low_r) +{ + return m_sound_low; +} + +READ8_MEMBER(redclash_state::sraider_sound_high_r) +{ + return m_sound_high; +} + +WRITE8_MEMBER(redclash_state::sraider_sound_low_w) +{ + m_sound_low = data; +} + +WRITE8_MEMBER(redclash_state::sraider_sound_high_w) +{ + m_sound_high = data; +} + +/* Protection? */ +READ8_MEMBER(redclash_state::sraider_8005_r) +{ + /* This must return X011111X or cpu #1 will hang */ + /* see code at rst $10 */ + return 0x3e; +} + +/* Unknown IO */ +WRITE8_MEMBER(redclash_state::sraider_misc_w) +{ + switch(offset) + { + /* These 8 bits are stored in the latch at A7 */ + case 0x00: + case 0x01: + case 0x02: + case 0x03: + case 0x04: + case 0x05: + case 0x06: + case 0x07: + m_weird_value[offset & 7] = data & 1; + break; + /* These 6 bits are stored in the latch at N7 */ + case 0x08: + m_sraider_0x30 = data&0x3f; + break; + /* These 6 bits are stored in the latch at N8 */ + case 0x10: + m_sraider_0x38 = data&0x3f; + break; + default: + osd_printf_debug("(%04X) write to %02X\n", space.device().safe_pc(), offset); + break; + } +} + +static ADDRESS_MAP_START( sraider_cpu1_map, AS_PROGRAM, 8, redclash_state ) + AM_RANGE(0x0000, 0x5fff) AM_ROM + AM_RANGE(0x6000, 0x6fff) AM_RAM + AM_RANGE(0x7000, 0x73ff) AM_WRITEONLY AM_SHARE("spriteram") + AM_RANGE(0x8005, 0x8005) AM_READ(sraider_8005_r) // protection check? + AM_RANGE(0x8006, 0x8006) AM_WRITE(sraider_sound_low_w) + AM_RANGE(0x8007, 0x8007) AM_WRITE(sraider_sound_high_w) + AM_RANGE(0x9000, 0x9000) AM_READ_PORT("IN0") + AM_RANGE(0x9001, 0x9001) AM_READ_PORT("IN1") + AM_RANGE(0x9002, 0x9002) AM_READ_PORT("DSW0") + AM_RANGE(0x9003, 0x9003) AM_READ_PORT("DSW1") + AM_RANGE(0xd000, 0xd3ff) AM_WRITE(ladybug_videoram_w) AM_SHARE("videoram") + AM_RANGE(0xd400, 0xd7ff) AM_WRITE(ladybug_colorram_w) AM_SHARE("colorram") + AM_RANGE(0xe000, 0xe000) AM_WRITENOP //unknown 0x10 when in attract, 0x20 when coined/playing +ADDRESS_MAP_END + + +static ADDRESS_MAP_START( sraider_cpu2_map, AS_PROGRAM, 8, redclash_state ) + AM_RANGE(0x0000, 0x5fff) AM_ROM + AM_RANGE(0x6000, 0x63ff) AM_RAM + AM_RANGE(0x8000, 0x8000) AM_READ(sraider_sound_low_r) + AM_RANGE(0xa000, 0xa000) AM_READ(sraider_sound_high_r) + AM_RANGE(0xc000, 0xc000) AM_READNOP //some kind of sync + AM_RANGE(0xe000, 0xe0ff) AM_WRITEONLY AM_SHARE("grid_data") + AM_RANGE(0xe800, 0xe800) AM_WRITE(sraider_io_w) +ADDRESS_MAP_END + + +static ADDRESS_MAP_START( sraider_cpu2_io_map, AS_IO, 8, redclash_state ) + ADDRESS_MAP_GLOBAL_MASK(0xff) + AM_RANGE(0x00, 0x00) AM_DEVWRITE("sn1", sn76489_device, write) + AM_RANGE(0x08, 0x08) AM_DEVWRITE("sn2", sn76489_device, write) + AM_RANGE(0x10, 0x10) AM_DEVWRITE("sn3", sn76489_device, write) + AM_RANGE(0x18, 0x18) AM_DEVWRITE("sn4", sn76489_device, write) + AM_RANGE(0x20, 0x20) AM_DEVWRITE("sn5", sn76489_device, write) + AM_RANGE(0x28, 0x3f) AM_WRITE(sraider_misc_w) // lots unknown +ADDRESS_MAP_END + + +WRITE8_MEMBER( redclash_state::irqack_w ) { m_maincpu->set_input_line(0, CLEAR_LINE); } -static ADDRESS_MAP_START( zerohour_map, AS_PROGRAM, 8, ladybug_state ) +static ADDRESS_MAP_START( zerohour_map, AS_PROGRAM, 8, redclash_state ) AM_RANGE(0x0000, 0x2fff) AM_ROM AM_RANGE(0x3000, 0x37ff) AM_RAM AM_RANGE(0x3800, 0x3bff) AM_RAM AM_SHARE("spriteram") @@ -51,7 +150,7 @@ static ADDRESS_MAP_START( zerohour_map, AS_PROGRAM, 8, ladybug_state ) AM_RANGE(0x7800, 0x7800) AM_WRITE(irqack_w) ADDRESS_MAP_END -static ADDRESS_MAP_START( redclash_map, AS_PROGRAM, 8, ladybug_state ) +static ADDRESS_MAP_START( redclash_map, AS_PROGRAM, 8, redclash_state ) AM_RANGE(0x0000, 0x2fff) AM_ROM // AM_RANGE(0x3000, 0x3000) AM_WRITENOP // AM_RANGE(0x3800, 0x3800) AM_WRITENOP @@ -77,13 +176,13 @@ ADDRESS_MAP_END Interrupts are still used, but they are related to coin slots. Left slot generates an IRQ, Right slot a NMI. */ -INPUT_CHANGED_MEMBER( ladybug_state::left_coin_inserted ) +INPUT_CHANGED_MEMBER( redclash_state::left_coin_inserted ) { if(newval) m_maincpu->set_input_line(0, ASSERT_LINE); } -INPUT_CHANGED_MEMBER( ladybug_state::right_coin_inserted ) +INPUT_CHANGED_MEMBER( redclash_state::right_coin_inserted ) { if(newval) m_maincpu->set_input_line(INPUT_LINE_NMI, PULSE_LINE); @@ -179,8 +278,8 @@ static INPUT_PORTS_START( redclash ) /* handler to be notified of coin insertions. We use IMPULSE to */ /* trigger exactly one interrupt, without having to check when the */ /* user releases the key. */ - PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_COIN1 ) PORT_IMPULSE(1) PORT_CHANGED_MEMBER(DEVICE_SELF, ladybug_state, left_coin_inserted, 0) - PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_COIN2 ) PORT_IMPULSE(1) PORT_CHANGED_MEMBER(DEVICE_SELF, ladybug_state, right_coin_inserted, 0) + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_COIN1 ) PORT_IMPULSE(1) PORT_CHANGED_MEMBER(DEVICE_SELF, redclash_state, left_coin_inserted, 0) + PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_COIN2 ) PORT_IMPULSE(1) PORT_CHANGED_MEMBER(DEVICE_SELF, redclash_state, right_coin_inserted, 0) INPUT_PORTS_END static INPUT_PORTS_START( zerohour ) @@ -255,8 +354,83 @@ static INPUT_PORTS_START( zerohour ) /* handler to be notified of coin insertions. We use IMPULSE to */ /* trigger exactly one interrupt, without having to check when the */ /* user releases the key. */ - PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_COIN1 ) PORT_IMPULSE(1) PORT_CHANGED_MEMBER(DEVICE_SELF, ladybug_state, left_coin_inserted, 0) - PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_COIN2 ) PORT_IMPULSE(1) PORT_CHANGED_MEMBER(DEVICE_SELF, ladybug_state, right_coin_inserted, 0) + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_COIN1 ) PORT_IMPULSE(1) PORT_CHANGED_MEMBER(DEVICE_SELF, redclash_state, left_coin_inserted, 0) + PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_COIN2 ) PORT_IMPULSE(1) PORT_CHANGED_MEMBER(DEVICE_SELF, redclash_state, right_coin_inserted, 0) +INPUT_PORTS_END + +static INPUT_PORTS_START( sraider ) + PORT_START("IN0") /* IN0 */ + PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_4WAY + PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_4WAY + PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_4WAY + PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_4WAY + PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) + PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_START1 ) + PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_START2 ) + PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) + + PORT_START("IN1") /* IN1 */ + PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_4WAY PORT_COCKTAIL + PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_4WAY PORT_COCKTAIL + PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_4WAY PORT_COCKTAIL + PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_4WAY PORT_COCKTAIL + PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_COCKTAIL + PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN ) + PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN1 ) + PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN2 ) + + PORT_START("DSW0") /* DSW0 */ + PORT_DIPNAME( 0x03, 0x03, DEF_STR( Difficulty ) ) + PORT_DIPSETTING( 0x03, DEF_STR( Easy ) ) + PORT_DIPSETTING( 0x02, DEF_STR( Medium ) ) + PORT_DIPSETTING( 0x01, DEF_STR( Hard ) ) + PORT_DIPSETTING( 0x00, DEF_STR( Hardest ) ) + PORT_DIPNAME( 0x04, 0x04, "High Score Names" ) + PORT_DIPSETTING( 0x00, "3 Letters" ) + PORT_DIPSETTING( 0x04, "10 Letters" ) + PORT_DIPNAME( 0x08, 0x08, DEF_STR( Allow_Continue ) ) + PORT_DIPSETTING( 0x08, DEF_STR( No ) ) + PORT_DIPSETTING( 0x00, DEF_STR( Yes ) ) + PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) ) + PORT_DIPSETTING( 0x10, DEF_STR( Off ) ) + PORT_DIPSETTING( 0x00, DEF_STR( On ) ) + PORT_DIPNAME( 0x20, 0x00, DEF_STR( Cabinet ) ) + PORT_DIPSETTING( 0x00, DEF_STR( Upright ) ) + PORT_DIPSETTING( 0x20, DEF_STR( Cocktail ) ) + PORT_DIPNAME( 0xc0, 0xc0, DEF_STR( Lives ) ) + PORT_DIPSETTING( 0x00, "2" ) + PORT_DIPSETTING( 0xc0, "3" ) + PORT_DIPSETTING( 0x80, "4" ) + PORT_DIPSETTING( 0x40, "5" ) + + /* Free Play setting works when it's set for both */ + PORT_START("DSW1") /* DSW1 */ + PORT_DIPNAME( 0x0f, 0x0f, DEF_STR( Coin_A ) ) + /* settings 0x00 through 0x05 all give 1 Coin/1 Credit */ + PORT_DIPSETTING( 0x06, DEF_STR( 4C_1C ) ) + PORT_DIPSETTING( 0x08, DEF_STR( 3C_1C ) ) + PORT_DIPSETTING( 0x0a, DEF_STR( 2C_1C ) ) + PORT_DIPSETTING( 0x07, DEF_STR( 3C_2C ) ) + PORT_DIPSETTING( 0x09, DEF_STR( 2C_2C ) ) + PORT_DIPSETTING( 0x0f, DEF_STR( 1C_1C ) ) + PORT_DIPSETTING( 0x0e, DEF_STR( 1C_2C ) ) + PORT_DIPSETTING( 0x0d, DEF_STR( 1C_3C ) ) + PORT_DIPSETTING( 0x0c, DEF_STR( 1C_4C ) ) + PORT_DIPSETTING( 0x0b, DEF_STR( 1C_5C ) ) + PORT_DIPSETTING( 0x00, DEF_STR( Free_Play ) ) + PORT_DIPNAME( 0xf0, 0xf0, DEF_STR( Coin_B ) ) + /* settings 0x00 through 0x50 all give 1 Coin/1 Credit */ + PORT_DIPSETTING( 0x60, DEF_STR( 4C_1C ) ) + PORT_DIPSETTING( 0x80, DEF_STR( 3C_1C ) ) + PORT_DIPSETTING( 0xa0, DEF_STR( 2C_1C ) ) + PORT_DIPSETTING( 0x70, DEF_STR( 3C_2C ) ) + PORT_DIPSETTING( 0x90, DEF_STR( 2C_2C ) ) + PORT_DIPSETTING( 0xf0, DEF_STR( 1C_1C ) ) + PORT_DIPSETTING( 0xe0, DEF_STR( 1C_2C ) ) + PORT_DIPSETTING( 0xd0, DEF_STR( 1C_3C ) ) + PORT_DIPSETTING( 0xc0, DEF_STR( 1C_4C ) ) + PORT_DIPSETTING( 0xb0, DEF_STR( 1C_5C ) ) + PORT_DIPSETTING( 0x00, DEF_STR( Free_Play ) ) INPUT_PORTS_END static const gfx_layout charlayout = @@ -323,9 +497,111 @@ static GFXDECODE_START( redclash ) GFXDECODE_ENTRY( "gfx2", 0x0004, spritelayout16x16bis, 4*8, 16 ) GFXDECODE_END +static const gfx_layout charlayout2 = +{ + 8,8, /* 8*8 characters */ + 512, /* 512 characters */ + 2, /* 2 bits per pixel */ + { 0, 512*8*8 }, /* the two bitplanes are separated */ + { 7, 6, 5, 4, 3, 2, 1, 0 }, + { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 }, + 8*8 /* every char takes 8 consecutive bytes */ +}; +static const gfx_layout spritelayout = +{ + 16,16, /* 16*16 sprites */ + 128, /* 128 sprites */ + 2, /* 2 bits per pixel */ + { 1, 0 }, /* the two bitplanes are packed in two consecutive bits */ + { 0, 2, 4, 6, 8, 10, 12, 14, + 8*16+0, 8*16+2, 8*16+4, 8*16+6, 8*16+8, 8*16+10, 8*16+12, 8*16+14 }, + { 23*16, 22*16, 21*16, 20*16, 19*16, 18*16, 17*16, 16*16, + 7*16, 6*16, 5*16, 4*16, 3*16, 2*16, 1*16, 0*16 }, + 64*8 /* every sprite takes 64 consecutive bytes */ +}; +static const gfx_layout spritelayout2 = +{ + 8,8, /* 8*8 sprites */ + 512, /* 512 sprites */ + 2, /* 2 bits per pixel */ + { 1, 0 }, /* the two bitplanes are packed in two consecutive bits */ + { 0, 2, 4, 6, 8, 10, 12, 14 }, + { 7*16, 6*16, 5*16, 4*16, 3*16, 2*16, 1*16, 0*16 }, + 16*8 /* every sprite takes 16 consecutive bytes */ +}; + +static const gfx_layout gridlayout = +{ + 8,8, /* 8*8 characters */ + 512, /* 512 characters */ + 1, /* 1 bit per pixel */ + { 0 }, + { 7, 6, 5, 4, 3, 2, 1, 0 }, + { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8}, + 8*8 /* every char takes 8 consecutive bytes */ +}; + +static const gfx_layout gridlayout2 = +{ + 8,8, /* 8*8 characters */ + 512, /* 512 characters */ + 1, /* 1 bit per pixel */ + { 0 }, + { 7, 6, 5, 4, 3, 2, 1, 0 }, + { 7*8, 6*8, 5*8, 4*8, 3*8, 2*8, 1*8, 0*8 }, + 8*8 /* every char takes 8 consecutive bytes */ +}; + +static GFXDECODE_START( sraider ) + GFXDECODE_ENTRY( "gfx1", 0, charlayout2, 0, 8 ) + GFXDECODE_ENTRY( "gfx2", 0, spritelayout, 4*8, 16 ) + GFXDECODE_ENTRY( "gfx2", 0, spritelayout2, 4*8, 16 ) + GFXDECODE_ENTRY( "gfx3", 0, gridlayout, 4*8+4*16+32, 1 ) + GFXDECODE_ENTRY( "gfx3", 0, gridlayout2, 4*8+4*16+32, 1 ) +GFXDECODE_END + +MACHINE_START_MEMBER(redclash_state,sraider) +{ + save_item(NAME(m_grid_color)); + save_item(NAME(m_sound_low)); + save_item(NAME(m_sound_high)); + save_item(NAME(m_sraider_0x30)); + save_item(NAME(m_sraider_0x38)); + save_item(NAME(m_weird_value)); + + /* for stars */ + save_item(NAME(m_star_speed)); + save_item(NAME(m_stars_enable)); + save_item(NAME(m_stars_speed)); + save_item(NAME(m_stars_state)); + save_item(NAME(m_stars_offset)); + save_item(NAME(m_stars_count)); +} + +MACHINE_RESET_MEMBER(redclash_state,sraider) +{ + int i; + + m_grid_color = 0; + m_sound_low = 0; + m_sound_high = 0; + m_sraider_0x30 = 0; + m_sraider_0x38 = 0; + + /* for stars */ + m_star_speed = 0; + m_stars_enable = 0; + m_stars_speed = 0; + m_stars_state = 0; + m_stars_offset = 0; + m_stars_count = 0; + + for (i = 0; i < 8; i++) + m_weird_value[i] = 0; +} -MACHINE_START_MEMBER(ladybug_state,redclash) +MACHINE_START_MEMBER(redclash_state,redclash) { save_item(NAME(m_star_speed)); save_item(NAME(m_gfxbank)); @@ -336,7 +612,7 @@ MACHINE_START_MEMBER(ladybug_state,redclash) save_item(NAME(m_stars_count)); } -MACHINE_RESET_MEMBER(ladybug_state,redclash) +MACHINE_RESET_MEMBER(redclash_state,redclash) { m_star_speed = 0; m_gfxbank = 0; @@ -347,14 +623,14 @@ MACHINE_RESET_MEMBER(ladybug_state,redclash) m_stars_count = 0; } -static MACHINE_CONFIG_START( zerohour, ladybug_state ) +static MACHINE_CONFIG_START( zerohour, redclash_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", Z80, 4000000) /* 4 MHz */ MCFG_CPU_PROGRAM_MAP(zerohour_map) - MCFG_MACHINE_START_OVERRIDE(ladybug_state,redclash) - MCFG_MACHINE_RESET_OVERRIDE(ladybug_state,redclash) + MCFG_MACHINE_START_OVERRIDE(redclash_state,redclash) + MCFG_MACHINE_RESET_OVERRIDE(redclash_state,redclash) /* video hardware */ MCFG_SCREEN_ADD("screen", RASTER) @@ -362,28 +638,28 @@ static MACHINE_CONFIG_START( zerohour, ladybug_state ) MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500) /* not accurate */) MCFG_SCREEN_SIZE(32*8, 32*8) MCFG_SCREEN_VISIBLE_AREA(1*8, 31*8-1, 4*8, 28*8-1) - MCFG_SCREEN_UPDATE_DRIVER(ladybug_state, screen_update_redclash) - MCFG_SCREEN_VBLANK_DRIVER(ladybug_state, screen_eof_redclash) + MCFG_SCREEN_UPDATE_DRIVER(redclash_state, screen_update_redclash) + MCFG_SCREEN_VBLANK_DRIVER(redclash_state, screen_eof_redclash) MCFG_SCREEN_PALETTE("palette") MCFG_GFXDECODE_ADD("gfxdecode", "palette", redclash) MCFG_PALETTE_ADD("palette", 4*8+4*16+32) MCFG_PALETTE_INDIRECT_ENTRIES(32+32) - MCFG_PALETTE_INIT_OWNER(ladybug_state,redclash) - MCFG_VIDEO_START_OVERRIDE(ladybug_state,redclash) + MCFG_PALETTE_INIT_OWNER(redclash_state,redclash) + MCFG_VIDEO_START_OVERRIDE(redclash_state,redclash) /* sound hardware */ MACHINE_CONFIG_END -static MACHINE_CONFIG_START( redclash, ladybug_state ) +static MACHINE_CONFIG_START( redclash, redclash_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", Z80, 4000000) /* 4 MHz */ MCFG_CPU_PROGRAM_MAP(redclash_map) - MCFG_MACHINE_START_OVERRIDE(ladybug_state,redclash) - MCFG_MACHINE_RESET_OVERRIDE(ladybug_state,redclash) + MCFG_MACHINE_START_OVERRIDE(redclash_state,redclash) + MCFG_MACHINE_RESET_OVERRIDE(redclash_state,redclash) /* video hardware */ MCFG_SCREEN_ADD("screen", RASTER) @@ -391,19 +667,72 @@ static MACHINE_CONFIG_START( redclash, ladybug_state ) MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500) /* not accurate */) MCFG_SCREEN_SIZE(32*8, 32*8) MCFG_SCREEN_VISIBLE_AREA(1*8, 31*8-1, 4*8, 28*8-1) - MCFG_SCREEN_UPDATE_DRIVER(ladybug_state, screen_update_redclash) - MCFG_SCREEN_VBLANK_DRIVER(ladybug_state, screen_eof_redclash) + MCFG_SCREEN_UPDATE_DRIVER(redclash_state, screen_update_redclash) + MCFG_SCREEN_VBLANK_DRIVER(redclash_state, screen_eof_redclash) MCFG_SCREEN_PALETTE("palette") MCFG_GFXDECODE_ADD("gfxdecode", "palette", redclash) MCFG_PALETTE_ADD("palette", 4*8+4*16+32) MCFG_PALETTE_INDIRECT_ENTRIES(32+32) - MCFG_PALETTE_INIT_OWNER(ladybug_state,redclash) - MCFG_VIDEO_START_OVERRIDE(ladybug_state,redclash) + MCFG_PALETTE_INIT_OWNER(redclash_state,redclash) + MCFG_VIDEO_START_OVERRIDE(redclash_state,redclash) /* sound hardware */ MACHINE_CONFIG_END +static MACHINE_CONFIG_START( sraider, redclash_state ) + + /* basic machine hardware */ + MCFG_CPU_ADD("maincpu", Z80, 4000000) /* 4 MHz */ + MCFG_CPU_PROGRAM_MAP(sraider_cpu1_map) + MCFG_CPU_VBLANK_INT_DRIVER("screen", redclash_state, irq0_line_hold) + + MCFG_CPU_ADD("sub", Z80, 4000000) /* 4 MHz */ + MCFG_CPU_PROGRAM_MAP(sraider_cpu2_map) + MCFG_CPU_IO_MAP(sraider_cpu2_io_map) + MCFG_CPU_VBLANK_INT_DRIVER("screen", redclash_state, irq0_line_hold) + + MCFG_MACHINE_START_OVERRIDE(redclash_state,sraider) + MCFG_MACHINE_RESET_OVERRIDE(redclash_state,sraider) + + /* video hardware */ + MCFG_SCREEN_ADD("screen", RASTER) + MCFG_SCREEN_REFRESH_RATE(60) + MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500) /* not accurate */) + MCFG_SCREEN_SIZE(32*8, 32*8) + MCFG_SCREEN_VISIBLE_AREA(1*8, 31*8-1, 4*8, 28*8-1) + MCFG_SCREEN_UPDATE_DRIVER(redclash_state, screen_update_sraider) + MCFG_SCREEN_VBLANK_DRIVER(redclash_state, screen_eof_sraider) + MCFG_SCREEN_PALETTE("palette") + + MCFG_GFXDECODE_ADD("gfxdecode", "palette", sraider) + MCFG_PALETTE_ADD("palette", 4*8+4*16+32+2) + MCFG_PALETTE_INDIRECT_ENTRIES(32+32+1) + MCFG_PALETTE_INIT_OWNER(redclash_state,sraider) + + MCFG_VIDEO_START_OVERRIDE(redclash_state,sraider) + + /* sound hardware */ + MCFG_SPEAKER_STANDARD_MONO("mono") + + MCFG_SOUND_ADD("sn1", SN76489, 4000000) + MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) + + MCFG_SOUND_ADD("sn2", SN76489, 4000000) + MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) + + MCFG_SOUND_ADD("sn3", SN76489, 4000000) + MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) + + MCFG_SOUND_ADD("sn4", SN76489, 4000000) + MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) + + MCFG_SOUND_ADD("sn5", SN76489, 4000000) + MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) +MACHINE_CONFIG_END + + + /*************************************************************************** Game driver(s) @@ -568,7 +897,36 @@ ROM_START( redclashk ) ROM_LOAD( "3.11e", 0x0040, 0x0020, CRC(27fa3a50) SHA1(7cf59b7a37c156640d6ea91554d1c4276c1780e0) ) /* 6331.6w */ ROM_END -DRIVER_INIT_MEMBER(ladybug_state,redclash) +ROM_START( sraider ) + ROM_REGION( 0x10000, "maincpu", 0 ) + ROM_LOAD( "sraid3.r4", 0x0000, 0x2000, CRC(0f389774) SHA1(c67596e6bf00175ff0a241506cd2f88114d05933) ) + ROM_LOAD( "sraid2.n4", 0x2000, 0x2000, CRC(38a48db0) SHA1(6f4f384d702fb8ee4bb2ef579638239d57e32ddd) ) + ROM_LOAD( "sraid1.m4", 0x4000, 0x2000, CRC(2f302a4e) SHA1(3a902ce6858f38df88b60830bef4b1d45b09b2df) ) + + ROM_REGION( 0x10000, "sub", 0 ) + ROM_LOAD( "sraid-s4.h6", 0x0000, 0x2000, CRC(57173a12) SHA1(6cb8fd4826e499f9a4e63621d58bc4b596cc261e) ) + ROM_LOAD( "sraid-s5.j6", 0x2000, 0x2000, CRC(5a459179) SHA1(a261c8f3c7c4cd4587c003bbbe815d2c4e01ffbc) ) + ROM_LOAD( "sraid-s6.l6", 0x4000, 0x2000, CRC(ea3aa25d) SHA1(353c0d075d5e0a3bc25a65e2748f5eb5212a844d) ) + + ROM_REGION( 0x2000, "gfx1", 0 ) + ROM_LOAD( "sraid-s0.k6", 0x0000, 0x1000, CRC(a0373909) SHA1(00e3bd5dd90769d670fc3c51edd1cd4b69e6132d) ) + ROM_LOAD( "sraids11.l6", 0x1000, 0x1000, CRC(ba22d949) SHA1(83762ced1df92ff594887e44d5b783826bbfb0c9) ) + + ROM_REGION( 0x2000, "gfx2", 0 ) + ROM_LOAD( "sraid-s7.m2", 0x0000, 0x1000, CRC(299f8e07) SHA1(1de71f251286088487da7285d6f8070147002af5) ) + ROM_LOAD( "sraid-s8.n2", 0x1000, 0x1000, CRC(57ba8888) SHA1(2aa1a5f682d146a55a96e471bb78e5c60da02bf9) ) + + ROM_REGION( 0x1000, "gfx3", 0 ) /* fixed portion of the grid */ + ROM_LOAD( "sraid-s9.f6", 0x0000, 0x1000, CRC(2380b90f) SHA1(0310554e3f2ec973c2bb6e816d04e5c0c1e0a0b9) ) + + ROM_REGION( 0x0060, "proms", 0 ) + ROM_LOAD( "srpr10-1.a2", 0x0000, 0x0020, CRC(121fdb99) SHA1(3bc092da40beb129a4df3db2f55d22bbbcf7bad8) ) + ROM_LOAD( "srpr10-2.l3", 0x0020, 0x0020, CRC(88b67e70) SHA1(e21ee2939e96dffee101bd92c62ed975b6b64001) ) + ROM_LOAD( "srpr10-3.c1", 0x0040, 0x0020, CRC(27fa3a50) SHA1(7cf59b7a37c156640d6ea91554d1c4276c1780e0) ) /* ?? */ +ROM_END + + +DRIVER_INIT_MEMBER(redclash_state,redclash) { int i,j; const UINT8 *src = memregion("gfx2")->base(); @@ -584,9 +942,10 @@ DRIVER_INIT_MEMBER(ladybug_state,redclash) } -GAME( 1980, zerohour, 0, zerohour, zerohour, ladybug_state, redclash, ROT270, "Universal", "Zero Hour (set 1)", MACHINE_NO_SOUND | MACHINE_WRONG_COLORS | MACHINE_IMPERFECT_GRAPHICS | MACHINE_SUPPORTS_SAVE ) -GAME( 1980, zerohoura, zerohour, zerohour, zerohour, ladybug_state, redclash, ROT270, "Universal", "Zero Hour (set 2)", MACHINE_NO_SOUND | MACHINE_WRONG_COLORS | MACHINE_IMPERFECT_GRAPHICS | MACHINE_SUPPORTS_SAVE ) -GAME( 1980, zerohouri, zerohour, zerohour, zerohour, ladybug_state, redclash, ROT270, "bootleg (Inder SA)", "Zero Hour (Inder)", MACHINE_NO_SOUND | MACHINE_WRONG_COLORS | MACHINE_IMPERFECT_GRAPHICS | MACHINE_SUPPORTS_SAVE ) -GAME( 1981, redclash, 0, redclash, redclash, ladybug_state, redclash, ROT270, "Tehkan", "Red Clash (set 1)", MACHINE_NO_SOUND | MACHINE_WRONG_COLORS | MACHINE_IMPERFECT_GRAPHICS | MACHINE_SUPPORTS_SAVE ) -GAME( 1981, redclasha, redclash, redclash, redclash, ladybug_state, redclash, ROT270, "Tehkan", "Red Clash (set 2)", MACHINE_NO_SOUND | MACHINE_WRONG_COLORS | MACHINE_IMPERFECT_GRAPHICS | MACHINE_SUPPORTS_SAVE ) -GAME( 1981, redclashk, redclash, redclash, redclash, ladybug_state, redclash, ROT270, "Tehkan (Kaneko license)", "Red Clash (Kaneko)", MACHINE_NO_SOUND | MACHINE_WRONG_COLORS | MACHINE_IMPERFECT_GRAPHICS | MACHINE_SUPPORTS_SAVE ) +GAME( 1980, zerohour, 0, zerohour, zerohour, redclash_state, redclash, ROT270, "Universal", "Zero Hour (set 1)", MACHINE_NO_SOUND | MACHINE_WRONG_COLORS | MACHINE_IMPERFECT_GRAPHICS | MACHINE_SUPPORTS_SAVE ) +GAME( 1980, zerohoura, zerohour, zerohour, zerohour, redclash_state, redclash, ROT270, "Universal", "Zero Hour (set 2)", MACHINE_NO_SOUND | MACHINE_WRONG_COLORS | MACHINE_IMPERFECT_GRAPHICS | MACHINE_SUPPORTS_SAVE ) +GAME( 1980, zerohouri, zerohour, zerohour, zerohour, redclash_state, redclash, ROT270, "bootleg (Inder SA)", "Zero Hour (Inder)", MACHINE_NO_SOUND | MACHINE_WRONG_COLORS | MACHINE_IMPERFECT_GRAPHICS | MACHINE_SUPPORTS_SAVE ) +GAME( 1981, redclash, 0, redclash, redclash, redclash_state, redclash, ROT270, "Tehkan", "Red Clash (set 1)", MACHINE_NO_SOUND | MACHINE_WRONG_COLORS | MACHINE_IMPERFECT_GRAPHICS | MACHINE_SUPPORTS_SAVE ) +GAME( 1981, redclasha, redclash, redclash, redclash, redclash_state, redclash, ROT270, "Tehkan", "Red Clash (set 2)", MACHINE_NO_SOUND | MACHINE_WRONG_COLORS | MACHINE_IMPERFECT_GRAPHICS | MACHINE_SUPPORTS_SAVE ) +GAME( 1981, redclashk, redclash, redclash, redclash, redclash_state, redclash, ROT270, "Tehkan (Kaneko license)", "Red Clash (Kaneko)", MACHINE_NO_SOUND | MACHINE_WRONG_COLORS | MACHINE_IMPERFECT_GRAPHICS | MACHINE_SUPPORTS_SAVE ) +GAME( 1982, sraider, 0, sraider, sraider, driver_device, 0, ROT270, "Universal", "Space Raider", MACHINE_SUPPORTS_SAVE ) diff --git a/src/mame/includes/ladybug.h b/src/mame/includes/ladybug.h index 8b7308edf5c..e6f5572f607 100644 --- a/src/mame/includes/ladybug.h +++ b/src/mame/includes/ladybug.h @@ -3,9 +3,7 @@ /************************************************************************* Universal 8106-A2 + 8106-B PCB set - - and Zero Hour / Red Clash - + *************************************************************************/ class ladybug_state : public driver_device @@ -34,10 +32,8 @@ public: /* video-related */ tilemap_t *m_bg_tilemap; tilemap_t *m_grid_tilemap; // ladybug - tilemap_t *m_fg_tilemap; // redclash UINT8 m_grid_color; int m_star_speed; - int m_gfxbank; // redclash only UINT8 m_stars_enable; UINT8 m_stars_speed; UINT32 m_stars_state; @@ -48,8 +44,6 @@ public: UINT8 m_sound_low; UINT8 m_sound_high; UINT8 m_weird_value[8]; - UINT8 m_sraider_0x30; - UINT8 m_sraider_0x38; /* devices */ required_device m_maincpu; @@ -60,59 +54,22 @@ public: optional_ioport m_p2_control; optional_shared_ptr m_decrypted_opcodes; - DECLARE_READ8_MEMBER(sraider_sound_low_r); - DECLARE_READ8_MEMBER(sraider_sound_high_r); - DECLARE_WRITE8_MEMBER(sraider_sound_low_w); - DECLARE_WRITE8_MEMBER(sraider_sound_high_w); - DECLARE_READ8_MEMBER(sraider_8005_r); - DECLARE_WRITE8_MEMBER(sraider_misc_w); DECLARE_WRITE8_MEMBER(ladybug_videoram_w); DECLARE_WRITE8_MEMBER(ladybug_colorram_w); DECLARE_WRITE8_MEMBER(ladybug_flipscreen_w); - DECLARE_WRITE8_MEMBER(sraider_io_w); DECLARE_CUSTOM_INPUT_MEMBER(ladybug_p1_control_r); DECLARE_CUSTOM_INPUT_MEMBER(ladybug_p2_control_r); DECLARE_INPUT_CHANGED_MEMBER(coin1_inserted); DECLARE_INPUT_CHANGED_MEMBER(coin2_inserted); - DECLARE_INPUT_CHANGED_MEMBER(left_coin_inserted); - DECLARE_INPUT_CHANGED_MEMBER(right_coin_inserted); DECLARE_DRIVER_INIT(dorodon); - DECLARE_DRIVER_INIT(redclash); TILE_GET_INFO_MEMBER(get_bg_tile_info); TILE_GET_INFO_MEMBER(get_grid_tile_info); - TILE_GET_INFO_MEMBER(get_fg_tile_info); DECLARE_MACHINE_START(ladybug); DECLARE_VIDEO_START(ladybug); DECLARE_PALETTE_INIT(ladybug); - DECLARE_MACHINE_START(sraider); - DECLARE_MACHINE_RESET(sraider); - DECLARE_VIDEO_START(sraider); - DECLARE_PALETTE_INIT(sraider); - DECLARE_MACHINE_START(redclash); - DECLARE_MACHINE_RESET(redclash); - DECLARE_VIDEO_START(redclash); - DECLARE_PALETTE_INIT(redclash); UINT32 screen_update_ladybug(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - UINT32 screen_update_sraider(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - UINT32 screen_update_redclash(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - void screen_eof_sraider(screen_device &screen, bool state); - void screen_eof_redclash(screen_device &screen, bool state); void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect ); - DECLARE_WRITE8_MEMBER( redclash_videoram_w ); - DECLARE_WRITE8_MEMBER( redclash_gfxbank_w ); - DECLARE_WRITE8_MEMBER( redclash_flipscreen_w ); + void palette_init_common( palette_device &palette, const UINT8 *color_prom, + int r_bit0, int r_bit1, int g_bit0, int g_bit1, int b_bit0, int b_bit1 ); - DECLARE_WRITE8_MEMBER( redclash_star0_w ); - DECLARE_WRITE8_MEMBER( redclash_star1_w ); - DECLARE_WRITE8_MEMBER( redclash_star2_w ); - DECLARE_WRITE8_MEMBER( redclash_star_reset_w ); - DECLARE_WRITE8_MEMBER( irqack_w ); - - /* sraider uses the zerohour star generator board */ - void redclash_set_stars_enable(UINT8 on); - void redclash_update_stars_state(); - void redclash_set_stars_speed(UINT8 speed); - void redclash_draw_stars(bitmap_ind16 &bitmap, const rectangle &cliprect, UINT8 palette_offset, UINT8 sraider, UINT8 firstx, UINT8 lastx); - void redclash_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect ); - void redclash_draw_bullets( bitmap_ind16 &bitmap, const rectangle &cliprect ); }; diff --git a/src/mame/includes/redclash.h b/src/mame/includes/redclash.h new file mode 100644 index 00000000000..7ebbc12e5e2 --- /dev/null +++ b/src/mame/includes/redclash.h @@ -0,0 +1,64 @@ +// license:BSD-3-Clause +// copyright-holders:Nicola Salmoria +/************************************************************************* + + Zero Hour / Red Clash + +*************************************************************************/ + +#include "includes/ladybug.h" + +class redclash_state : public ladybug_state +{ +public: + redclash_state(const machine_config &mconfig, device_type type, const char *tag) + : ladybug_state(mconfig, type, tag) { } + + tilemap_t *m_fg_tilemap; // redclash + int m_gfxbank; // redclash only + + /* misc */ + UINT8 m_sraider_0x30; + UINT8 m_sraider_0x38; + + DECLARE_READ8_MEMBER(sraider_sound_low_r); + DECLARE_READ8_MEMBER(sraider_sound_high_r); + DECLARE_WRITE8_MEMBER(sraider_sound_low_w); + DECLARE_WRITE8_MEMBER(sraider_sound_high_w); + DECLARE_READ8_MEMBER(sraider_8005_r); + DECLARE_WRITE8_MEMBER(sraider_misc_w); + DECLARE_WRITE8_MEMBER(sraider_io_w); + DECLARE_INPUT_CHANGED_MEMBER(left_coin_inserted); + DECLARE_INPUT_CHANGED_MEMBER(right_coin_inserted); + DECLARE_DRIVER_INIT(redclash); + DECLARE_MACHINE_START(sraider); + DECLARE_MACHINE_RESET(sraider); + DECLARE_VIDEO_START(sraider); + DECLARE_PALETTE_INIT(sraider); + DECLARE_MACHINE_START(redclash); + DECLARE_MACHINE_RESET(redclash); + DECLARE_VIDEO_START(redclash); + DECLARE_PALETTE_INIT(redclash); + UINT32 screen_update_sraider(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); + UINT32 screen_update_redclash(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); + void screen_eof_sraider(screen_device &screen, bool state); + void screen_eof_redclash(screen_device &screen, bool state); + DECLARE_WRITE8_MEMBER( redclash_videoram_w ); + DECLARE_WRITE8_MEMBER( redclash_gfxbank_w ); + DECLARE_WRITE8_MEMBER( redclash_flipscreen_w ); + TILE_GET_INFO_MEMBER(get_fg_tile_info); + + DECLARE_WRITE8_MEMBER( redclash_star0_w ); + DECLARE_WRITE8_MEMBER( redclash_star1_w ); + DECLARE_WRITE8_MEMBER( redclash_star2_w ); + DECLARE_WRITE8_MEMBER( redclash_star_reset_w ); + DECLARE_WRITE8_MEMBER( irqack_w ); + + /* sraider uses the zerohour star generator board */ + void redclash_set_stars_enable(UINT8 on); + void redclash_update_stars_state(); + void redclash_set_stars_speed(UINT8 speed); + void redclash_draw_stars(bitmap_ind16 &bitmap, const rectangle &cliprect, UINT8 palette_offset, UINT8 sraider, UINT8 firstx, UINT8 lastx); + void redclash_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect ); + void redclash_draw_bullets( bitmap_ind16 &bitmap, const rectangle &cliprect ); +}; diff --git a/src/mame/mame.lst b/src/mame/mame.lst index bf7bfa223a7..472b2863035 100644 --- a/src/mame/mame.lst +++ b/src/mame/mame.lst @@ -16704,7 +16704,6 @@ ladybgb2 // bootleg ladybug // 8110 (c) 1981 ladybugb // bootleg snapjack // ???? (c) -sraider // ???? (c) 1982 Universal @source:ladyfrog.cpp ladyfrog // (c) 1990 Mondial Games @@ -31167,6 +31166,7 @@ redclashk // (c) Kaneko (bootleg?) zerohour // 8011 (c) Universal zerohoura // 8011 (c) Universal zerohouri // +sraider // ???? (c) 1982 Universal @source:relief.cpp relief // 136093 (c) 1992 diff --git a/src/mame/video/ladybug.cpp b/src/mame/video/ladybug.cpp index 4fe3c200853..773344349c5 100644 --- a/src/mame/video/ladybug.cpp +++ b/src/mame/video/ladybug.cpp @@ -31,7 +31,7 @@ ***************************************************************************/ -static void palette_init_common( palette_device &palette, const UINT8 *color_prom, +void ladybug_state::palette_init_common( palette_device &palette, const UINT8 *color_prom, int r_bit0, int r_bit1, int g_bit0, int g_bit1, int b_bit0, int b_bit1 ) { static const int resistances[2] = { 470, 220 }; @@ -98,44 +98,6 @@ PALETTE_INIT_MEMBER(ladybug_state,ladybug) palette_init_common(palette, color_prom, 0, 5, 2, 6, 4, 7); } -PALETTE_INIT_MEMBER(ladybug_state,sraider) -{ - const UINT8 *color_prom = memregion("proms")->base(); - int i; - - /* the resistor net may be probably different than Lady Bug */ - palette_init_common(palette, color_prom, 3, 0, 5, 4, 7, 6); - - /* star colors */ - for (i = 0x20; i < 0x40; i++) - { - int bit0, bit1; - int r, g, b; - - /* red component */ - bit0 = ((i - 0x20) >> 3) & 0x01; - bit1 = ((i - 0x20) >> 4) & 0x01; - b = 0x47 * bit0 + 0x97 * bit1; - - /* green component */ - bit0 = ((i - 0x20) >> 1) & 0x01; - bit1 = ((i - 0x20) >> 2) & 0x01; - g = 0x47 * bit0 + 0x97 * bit1; - - /* blue component */ - bit0 = ((i - 0x20) >> 0) & 0x01; - r = 0x47 * bit0; - - palette.set_indirect_color(i, rgb_t(r, g, b)); - } - - for (i = 0x60; i < 0x80; i++) - palette.set_pen_indirect(i, (i - 0x60) + 0x20); - - /* stationary part of grid */ - palette.set_pen_indirect(0x81, 0x40); -} - WRITE8_MEMBER(ladybug_state::ladybug_videoram_w) { m_videoram[offset] = data; @@ -157,34 +119,6 @@ WRITE8_MEMBER(ladybug_state::ladybug_flipscreen_w) } } -WRITE8_MEMBER(ladybug_state::sraider_io_w) -{ - // bit7 = flip - // bit6 = grid red - // bit5 = grid green - // bit4 = grid blue - // bit3 = enable stars - // bit210 = stars speed/dir - - if (flip_screen() != (data & 0x80)) - { - flip_screen_set(data & 0x80); - machine().tilemap().mark_all_dirty(); - } - - m_grid_color = data & 0x70; - - redclash_set_stars_enable((data & 0x08) >> 3); - - /* - * There must be a subtle clocking difference between - * Space Raider and the other games using this star generator, - * hence the -1 here - */ - - redclash_set_stars_speed((data & 0x07) - 1); -} - TILE_GET_INFO_MEMBER(ladybug_state::get_bg_tile_info) { int code = m_videoram[tile_index] + 32 * (m_colorram[tile_index] & 0x08); @@ -212,17 +146,6 @@ VIDEO_START_MEMBER(ladybug_state,ladybug) m_bg_tilemap->set_transparent_pen(0); } -VIDEO_START_MEMBER(ladybug_state,sraider) -{ - m_grid_tilemap = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(ladybug_state::get_grid_tile_info),this), TILEMAP_SCAN_ROWS, 8, 8, 32, 32); - m_grid_tilemap->set_scroll_rows(32); - m_grid_tilemap->set_transparent_pen(0); - - m_bg_tilemap = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(ladybug_state::get_bg_tile_info),this), TILEMAP_SCAN_ROWS, 8, 8, 32, 32); - m_bg_tilemap->set_scroll_rows(32); - m_bg_tilemap->set_transparent_pen(0); -} - void ladybug_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect ) { UINT8 *spriteram = m_spriteram; @@ -296,66 +219,3 @@ UINT32 ladybug_state::screen_update_ladybug(screen_device &screen, bitmap_ind16 return 0; } -void ladybug_state::screen_eof_sraider(screen_device &screen, bool state)/* update starfield position */ -{ - // falling edge - if (!state) - redclash_update_stars_state(); -} - -UINT32 ladybug_state::screen_update_sraider(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - // this part is boilerplate from ladybug, not sure if hardware does this, - // since it's not used - - int offs; - int i; - - for (offs = 0; offs < 32; offs++) - { - int sx = offs % 4; - int sy = offs / 4; - - if (flip_screen()) - m_bg_tilemap->set_scrollx(offs, -m_videoram[32 * sx + sy]); - else - m_bg_tilemap->set_scrollx(offs, m_videoram[32 * sx + sy]); - } - - // clear the bg bitmap - bitmap.fill(0, cliprect); - - // draw the stars - if (flip_screen()) - redclash_draw_stars(bitmap, cliprect, 0x60, 1, 0x27, 0xff); - else - redclash_draw_stars(bitmap, cliprect, 0x60, 1, 0x00, 0xd8); - - // draw the gridlines - m_palette->set_indirect_color(0x40, rgb_t(m_grid_color & 0x40 ? 0xff : 0, - m_grid_color & 0x20 ? 0xff : 0, - m_grid_color & 0x10 ? 0xff : 0)); - m_grid_tilemap->draw(screen, bitmap, cliprect, 0, flip_screen()); - - for (i = 0; i < 0x100; i++) - { - if (m_grid_data[i] != 0) - { - UINT8 x = i; - int height = cliprect.max_y - cliprect.min_y + 1; - - if (flip_screen()) - x = ~x; - - bitmap.plot_box(x, cliprect.min_y, 1, height, 0x81); - } - } - - // now the chars - m_bg_tilemap->draw(screen, bitmap, cliprect, 0, flip_screen()); - - // now the sprites - draw_sprites(bitmap, cliprect); - - return 0; -} diff --git a/src/mame/video/redclash.cpp b/src/mame/video/redclash.cpp index 68b6664237c..4b8b93bebac 100644 --- a/src/mame/video/redclash.cpp +++ b/src/mame/video/redclash.cpp @@ -9,7 +9,8 @@ ***************************************************************************/ #include "emu.h" -#include "includes/ladybug.h" +#include "includes/redclash.h" +#include "video/resnet.h" /*************************************************************************** @@ -20,7 +21,7 @@ ***************************************************************************/ -PALETTE_INIT_MEMBER(ladybug_state,redclash) +PALETTE_INIT_MEMBER(redclash_state,redclash) { const UINT8 *color_prom = memregion("proms")->base(); int i; @@ -99,13 +100,52 @@ PALETTE_INIT_MEMBER(ladybug_state,redclash) palette.set_pen_indirect(i, (i - 0x60) + 0x20); } -WRITE8_MEMBER( ladybug_state::redclash_videoram_w ) +PALETTE_INIT_MEMBER(redclash_state,sraider) +{ + const UINT8 *color_prom = memregion("proms")->base(); + int i; + + /* the resistor net may be probably different than Lady Bug */ + palette_init_common(palette, color_prom, 3, 0, 5, 4, 7, 6); + + /* star colors */ + for (i = 0x20; i < 0x40; i++) + { + int bit0, bit1; + int r, g, b; + + /* red component */ + bit0 = ((i - 0x20) >> 3) & 0x01; + bit1 = ((i - 0x20) >> 4) & 0x01; + b = 0x47 * bit0 + 0x97 * bit1; + + /* green component */ + bit0 = ((i - 0x20) >> 1) & 0x01; + bit1 = ((i - 0x20) >> 2) & 0x01; + g = 0x47 * bit0 + 0x97 * bit1; + + /* blue component */ + bit0 = ((i - 0x20) >> 0) & 0x01; + r = 0x47 * bit0; + + palette.set_indirect_color(i, rgb_t(r, g, b)); + } + + for (i = 0x60; i < 0x80; i++) + palette.set_pen_indirect(i, (i - 0x60) + 0x20); + + /* stationary part of grid */ + palette.set_pen_indirect(0x81, 0x40); +} + + +WRITE8_MEMBER( redclash_state::redclash_videoram_w ) { m_videoram[offset] = data; m_fg_tilemap->mark_tile_dirty(offset); } -WRITE8_MEMBER( ladybug_state::redclash_gfxbank_w ) +WRITE8_MEMBER( redclash_state::redclash_gfxbank_w ) { if (m_gfxbank != (data & 0x01)) { @@ -114,7 +154,7 @@ WRITE8_MEMBER( ladybug_state::redclash_gfxbank_w ) } } -WRITE8_MEMBER( ladybug_state::redclash_flipscreen_w ) +WRITE8_MEMBER( redclash_state::redclash_flipscreen_w ) { flip_screen_set(data & 0x01); } @@ -130,30 +170,30 @@ star_speed: 6 = backwards medium 7 = backwards fast */ -WRITE8_MEMBER( ladybug_state::redclash_star0_w ) +WRITE8_MEMBER( redclash_state::redclash_star0_w ) { m_star_speed = (m_star_speed & ~1) | ((data & 1) << 0); redclash_set_stars_speed(m_star_speed); } -WRITE8_MEMBER( ladybug_state::redclash_star1_w ) +WRITE8_MEMBER( redclash_state::redclash_star1_w ) { m_star_speed = (m_star_speed & ~2) | ((data & 1) << 1); redclash_set_stars_speed(m_star_speed); } -WRITE8_MEMBER( ladybug_state::redclash_star2_w ) +WRITE8_MEMBER( redclash_state::redclash_star2_w ) { m_star_speed = (m_star_speed & ~4) | ((data & 1) << 2); redclash_set_stars_speed( m_star_speed); } -WRITE8_MEMBER( ladybug_state::redclash_star_reset_w ) +WRITE8_MEMBER( redclash_state::redclash_star_reset_w ) { redclash_set_stars_enable(1); } -TILE_GET_INFO_MEMBER(ladybug_state::get_fg_tile_info) +TILE_GET_INFO_MEMBER(redclash_state::get_fg_tile_info) { int code = m_videoram[tile_index]; int color = (m_videoram[tile_index] & 0x70) >> 4; // ?? @@ -161,13 +201,13 @@ TILE_GET_INFO_MEMBER(ladybug_state::get_fg_tile_info) SET_TILE_INFO_MEMBER(0, code, color, 0); } -VIDEO_START_MEMBER(ladybug_state,redclash) +VIDEO_START_MEMBER(redclash_state,redclash) { - m_fg_tilemap = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(ladybug_state::get_fg_tile_info),this), TILEMAP_SCAN_ROWS, 8, 8, 32, 32); + m_fg_tilemap = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(redclash_state::get_fg_tile_info),this), TILEMAP_SCAN_ROWS, 8, 8, 32, 32); m_fg_tilemap->set_transparent_pen(0); } -void ladybug_state::redclash_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect ) +void redclash_state::redclash_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect ) { UINT8 *spriteram = m_spriteram; int i, offs; @@ -250,7 +290,7 @@ void ladybug_state::redclash_draw_sprites( bitmap_ind16 &bitmap, const rectangle } } -void ladybug_state::redclash_draw_bullets( bitmap_ind16 &bitmap, const rectangle &cliprect ) +void redclash_state::redclash_draw_bullets( bitmap_ind16 &bitmap, const rectangle &cliprect ) { int offs; @@ -284,7 +324,7 @@ void ladybug_state::redclash_draw_bullets( bitmap_ind16 &bitmap, const rectangle */ /* This line can reset the LFSR to zero and disables the star generator */ -void ladybug_state::redclash_set_stars_enable(UINT8 on) +void redclash_state::redclash_set_stars_enable(UINT8 on) { if ((m_stars_enable == 0) && (on == 1)) { @@ -297,7 +337,7 @@ void ladybug_state::redclash_set_stars_enable(UINT8 on) /* This sets up which starfield to draw and the offset, */ /* To be called from screen_eof_*() */ -void ladybug_state::redclash_update_stars_state() +void redclash_state::redclash_update_stars_state() { if (m_stars_enable == 0) return; @@ -328,7 +368,7 @@ void ladybug_state::redclash_update_stars_state() * 7 right/up fast (+5/2 pix per frame) */ -void ladybug_state::redclash_set_stars_speed(UINT8 speed ) +void redclash_state::redclash_set_stars_speed(UINT8 speed ) { m_stars_speed = speed; } @@ -338,7 +378,7 @@ void ladybug_state::redclash_set_stars_speed(UINT8 speed ) /* Space Raider doesn't use the Va bit, and it is also set up to */ /* window the stars to a certain x range */ -void ladybug_state::redclash_draw_stars(bitmap_ind16 &bitmap, const rectangle &cliprect, UINT8 palette_offset, UINT8 sraider, UINT8 firstx, UINT8 lastx ) +void redclash_state::redclash_draw_stars(bitmap_ind16 &bitmap, const rectangle &cliprect, UINT8 palette_offset, UINT8 sraider, UINT8 firstx, UINT8 lastx ) { int i; UINT8 tempbit, feedback, star_color, xloc, yloc; @@ -395,14 +435,14 @@ void ladybug_state::redclash_draw_stars(bitmap_ind16 &bitmap, const rectangle &c } } -void ladybug_state::screen_eof_redclash(screen_device &screen, bool state) +void redclash_state::screen_eof_redclash(screen_device &screen, bool state) { // falling edge if (!state) redclash_update_stars_state(); } -UINT32 ladybug_state::screen_update_redclash(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) +UINT32 redclash_state::screen_update_redclash(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) { bitmap.fill(m_palette->black_pen(), cliprect); redclash_draw_stars(bitmap, cliprect, 0x60, 0, 0x00, 0xff); @@ -411,3 +451,106 @@ UINT32 ladybug_state::screen_update_redclash(screen_device &screen, bitmap_ind16 m_fg_tilemap->draw(screen, bitmap, cliprect, 0, 0); return 0; } + +WRITE8_MEMBER(redclash_state::sraider_io_w) +{ + // bit7 = flip + // bit6 = grid red + // bit5 = grid green + // bit4 = grid blue + // bit3 = enable stars + // bit210 = stars speed/dir + + if (flip_screen() != (data & 0x80)) + { + flip_screen_set(data & 0x80); + machine().tilemap().mark_all_dirty(); + } + + m_grid_color = data & 0x70; + + redclash_set_stars_enable((data & 0x08) >> 3); + + /* + * There must be a subtle clocking difference between + * Space Raider and the other games using this star generator, + * hence the -1 here + */ + + redclash_set_stars_speed((data & 0x07) - 1); +} + +VIDEO_START_MEMBER(redclash_state,sraider) +{ + m_grid_tilemap = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(redclash_state::get_grid_tile_info),this), TILEMAP_SCAN_ROWS, 8, 8, 32, 32); + m_grid_tilemap->set_scroll_rows(32); + m_grid_tilemap->set_transparent_pen(0); + + m_bg_tilemap = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(redclash_state::get_bg_tile_info),this), TILEMAP_SCAN_ROWS, 8, 8, 32, 32); + m_bg_tilemap->set_scroll_rows(32); + m_bg_tilemap->set_transparent_pen(0); +} + +void redclash_state::screen_eof_sraider(screen_device &screen, bool state)/* update starfield position */ +{ + // falling edge + if (!state) + redclash_update_stars_state(); +} + +UINT32 redclash_state::screen_update_sraider(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) +{ + // this part is boilerplate from ladybug, not sure if hardware does this, + // since it's not used + + int offs; + int i; + + for (offs = 0; offs < 32; offs++) + { + int sx = offs % 4; + int sy = offs / 4; + + if (flip_screen()) + m_bg_tilemap->set_scrollx(offs, -m_videoram[32 * sx + sy]); + else + m_bg_tilemap->set_scrollx(offs, m_videoram[32 * sx + sy]); + } + + // clear the bg bitmap + bitmap.fill(0, cliprect); + + // draw the stars + if (flip_screen()) + redclash_draw_stars(bitmap, cliprect, 0x60, 1, 0x27, 0xff); + else + redclash_draw_stars(bitmap, cliprect, 0x60, 1, 0x00, 0xd8); + + // draw the gridlines + m_palette->set_indirect_color(0x40, rgb_t(m_grid_color & 0x40 ? 0xff : 0, + m_grid_color & 0x20 ? 0xff : 0, + m_grid_color & 0x10 ? 0xff : 0)); + m_grid_tilemap->draw(screen, bitmap, cliprect, 0, flip_screen()); + + for (i = 0; i < 0x100; i++) + { + if (m_grid_data[i] != 0) + { + UINT8 x = i; + int height = cliprect.max_y - cliprect.min_y + 1; + + if (flip_screen()) + x = ~x; + + bitmap.plot_box(x, cliprect.min_y, 1, height, 0x81); + } + } + + // now the chars + m_bg_tilemap->draw(screen, bitmap, cliprect, 0, flip_screen()); + + // now the sprites + draw_sprites(bitmap, cliprect); + + return 0; +}