From 5f9d5494c5d2cf585483ccc10d1018c1dab25d63 Mon Sep 17 00:00:00 2001 From: cam900 Date: Mon, 11 Feb 2019 09:07:27 +0900 Subject: nova2001.cpp : Cleanups (#4529) * nova2001.cpp : Cleanups Reduce duplicates, Unnecessary lines, MCFGs, Fix some namings, Spacings, Use shorter type values * nova2001.cpp : Minor constant-ization * nova2001.cpp : Minor correction, nw --- src/mame/drivers/nova2001.cpp | 192 ++++++++++++++++++++---------------------- src/mame/includes/nova2001.h | 30 ++++--- src/mame/video/nova2001.cpp | 132 ++++++++++++++--------------- 3 files changed, 171 insertions(+), 183 deletions(-) diff --git a/src/mame/drivers/nova2001.cpp b/src/mame/drivers/nova2001.cpp index fe0b254431f..e19726fc8c1 100644 --- a/src/mame/drivers/nova2001.cpp +++ b/src/mame/drivers/nova2001.cpp @@ -124,7 +124,6 @@ e000 - e7ff R/W Work RAM #include "emu.h" #include "includes/nova2001.h" -#include "cpu/z80/z80.h" #include "machine/watchdog.h" #include "sound/ay8910.h" #include "screen.h" @@ -183,7 +182,7 @@ MACHINE_START_MEMBER(nova2001_state,ninjakun) void nova2001_state::nova2001_map(address_map &map) { map(0x0000, 0x7fff).rom(); - map(0xa000, 0xa7ff).ram().w(FUNC(nova2001_state::nova2001_fg_videoram_w)).share("fg_videoram"); + map(0xa000, 0xa7ff).ram().w(FUNC(nova2001_state::fg_videoram_w)).share("fg_videoram"); map(0xa800, 0xafff).ram().w(FUNC(nova2001_state::nova2001_bg_videoram_w)).share("bg_videoram"); map(0xb000, 0xb7ff).ram().share("spriteram"); map(0xb800, 0xbfff).w(FUNC(nova2001_state::nova2001_flipscreen_w)); @@ -199,42 +198,38 @@ void nova2001_state::nova2001_map(address_map &map) } -void nova2001_state::ninjakun_cpu1_map(address_map &map) +void nova2001_state::ninjakun_shared_map(address_map &map) { - map(0x0000, 0x1fff).rom(); - map(0x2000, 0x7fff).rom(); + map(0x2000, 0x7fff).rom().region("maincpu", 0x2000); map(0x8000, 0x8001).w("ay1", FUNC(ay8910_device::address_data_w)); map(0x8001, 0x8001).r("ay1", FUNC(ay8910_device::data_r)); map(0x8002, 0x8003).w("ay2", FUNC(ay8910_device::address_data_w)); map(0x8003, 0x8003).r("ay2", FUNC(ay8910_device::data_r)); map(0xa000, 0xa000).portr("IN0"); map(0xa001, 0xa001).portr("IN1"); - map(0xa002, 0xa002).portr("IN2").w(FUNC(nova2001_state::ninjakun_cpu1_io_A002_w)); - map(0xa003, 0xa003).w(FUNC(nova2001_state::pkunwar_flipscreen_w)); - map(0xc000, 0xc7ff).ram().w(FUNC(nova2001_state::nova2001_fg_videoram_w)).share("fg_videoram"); + map(0xa002, 0xa002).portr("IN2"); + map(0xc000, 0xc7ff).ram().w(FUNC(nova2001_state::fg_videoram_w)).share("fg_videoram"); map(0xc800, 0xcfff).rw(FUNC(nova2001_state::ninjakun_bg_videoram_r), FUNC(nova2001_state::ninjakun_bg_videoram_w)).share("bg_videoram"); map(0xd000, 0xd7ff).ram().share("spriteram"); - map(0xd800, 0xd9ff).ram().w(FUNC(nova2001_state::ninjakun_paletteram_w)).share("palette"); + map(0xd800, 0xd9ff).ram().w(FUNC(nova2001_state::paletteram_w)).share("palette"); +} + +void nova2001_state::ninjakun_cpu1_map(address_map &map) +{ + ninjakun_shared_map(map); + map(0x0000, 0x1fff).rom().region("maincpu", 0); + map(0xa002, 0xa002).w(FUNC(nova2001_state::ninjakun_cpu1_io_A002_w)); + map(0xa003, 0xa003).w(FUNC(nova2001_state::pkunwar_flipscreen_w)); map(0xe000, 0xe3ff).ram().share("share1"); map(0xe400, 0xe7ff).ram().share("share2"); } void nova2001_state::ninjakun_cpu2_map(address_map &map) { - map(0x0000, 0x1fff).rom(); - map(0x2000, 0x7fff).rom().region("maincpu", 0x2000); - map(0x8000, 0x8001).w("ay1", FUNC(ay8910_device::address_data_w)); - map(0x8001, 0x8001).r("ay1", FUNC(ay8910_device::data_r)); - map(0x8002, 0x8003).w("ay2", FUNC(ay8910_device::address_data_w)); - map(0x8003, 0x8003).r("ay2", FUNC(ay8910_device::data_r)); - map(0xa000, 0xa000).portr("IN0"); - map(0xa001, 0xa001).portr("IN1"); - map(0xa002, 0xa002).portr("IN2").w(FUNC(nova2001_state::ninjakun_cpu2_io_A002_w)); + ninjakun_shared_map(map); + map(0x0000, 0x1fff).rom().region("sub", 0); + map(0xa002, 0xa002).w(FUNC(nova2001_state::ninjakun_cpu2_io_A002_w)); map(0xa003, 0xa003).w(FUNC(nova2001_state::nova2001_flipscreen_w)); - map(0xc000, 0xc7ff).ram().w(FUNC(nova2001_state::nova2001_fg_videoram_w)).share("fg_videoram"); - map(0xc800, 0xcfff).rw(FUNC(nova2001_state::ninjakun_bg_videoram_r), FUNC(nova2001_state::ninjakun_bg_videoram_w)).share("bg_videoram"); - map(0xd000, 0xd7ff).ram().share("spriteram"); - map(0xd800, 0xd9ff).ram().w(FUNC(nova2001_state::ninjakun_paletteram_w)).share("palette"); map(0xe000, 0xe3ff).ram().share("share2"); /* swapped wrt CPU1 */ map(0xe400, 0xe7ff).ram().share("share1"); /* swapped wrt CPU1 */ } @@ -264,16 +259,16 @@ void nova2001_state::raiders5_cpu1_map(address_map &map) { map(0x0000, 0x7fff).rom(); map(0x8000, 0x87ff).ram().share("spriteram"); - map(0x8800, 0x8fff).ram().w(FUNC(nova2001_state::nova2001_fg_videoram_w)).share("fg_videoram"); + map(0x8800, 0x8fff).ram().w(FUNC(nova2001_state::fg_videoram_w)).share("fg_videoram"); map(0x9000, 0x97ff).rw(FUNC(nova2001_state::ninjakun_bg_videoram_r), FUNC(nova2001_state::ninjakun_bg_videoram_w)).share("bg_videoram"); - map(0xa000, 0xa000).w(FUNC(nova2001_state::nova2001_scroll_x_w)); - map(0xa001, 0xa001).w(FUNC(nova2001_state::nova2001_scroll_y_w)); + map(0xa000, 0xa000).w(FUNC(nova2001_state::scroll_x_w)); + map(0xa001, 0xa001).w(FUNC(nova2001_state::scroll_y_w)); map(0xa002, 0xa002).w(FUNC(nova2001_state::pkunwar_flipscreen_w)); map(0xc000, 0xc001).w("ay1", FUNC(ay8910_device::address_data_w)); map(0xc001, 0xc001).r("ay1", FUNC(ay8910_device::data_r)); map(0xc002, 0xc003).w("ay2", FUNC(ay8910_device::address_data_w)); map(0xc003, 0xc003).r("ay2", FUNC(ay8910_device::data_r)); - map(0xd000, 0xd1ff).ram().w(FUNC(nova2001_state::ninjakun_paletteram_w)).share("palette"); + map(0xd000, 0xd1ff).ram().w(FUNC(nova2001_state::paletteram_w)).share("palette"); map(0xe000, 0xe7ff).ram().share("share1"); } @@ -289,8 +284,8 @@ void nova2001_state::raiders5_cpu2_map(address_map &map) map(0xc000, 0xc000).nopr(); /* unknown */ map(0xc800, 0xc800).nopr(); /* unknown */ map(0xd000, 0xd000).nopr(); /* unknown */ - map(0xe000, 0xe000).w(FUNC(nova2001_state::nova2001_scroll_x_w)); - map(0xe001, 0xe001).w(FUNC(nova2001_state::nova2001_scroll_y_w)); + map(0xe000, 0xe000).w(FUNC(nova2001_state::scroll_x_w)); + map(0xe001, 0xe001).w(FUNC(nova2001_state::scroll_y_w)); map(0xe002, 0xe002).w(FUNC(nova2001_state::pkunwar_flipscreen_w)); } @@ -646,22 +641,22 @@ GFXDECODE_END * *************************************/ -MACHINE_CONFIG_START(nova2001_state::nova2001) - +void nova2001_state::nova2001(machine_config &config) +{ /* basic machine hardware */ - MCFG_DEVICE_ADD("maincpu", Z80, MAIN_CLOCK/4) // 3 MHz verified on schematics - MCFG_DEVICE_PROGRAM_MAP(nova2001_map) - MCFG_DEVICE_VBLANK_INT_DRIVER("screen", nova2001_state, irq0_line_hold) + Z80(config, m_maincpu, MAIN_CLOCK/4); // 3 MHz verified on schematics + m_maincpu->set_addrmap(AS_PROGRAM, &nova2001_state::nova2001_map); + m_maincpu->set_vblank_int("screen", FUNC(nova2001_state::irq0_line_hold)); WATCHDOG_TIMER(config, "watchdog"); /* video hardware */ - MCFG_SCREEN_ADD("screen", RASTER) - MCFG_SCREEN_REFRESH_RATE(60) - MCFG_SCREEN_SIZE(32*8, 32*8) - MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 4*8, 28*8-1) - MCFG_SCREEN_UPDATE_DRIVER(nova2001_state, screen_update_nova2001) - MCFG_SCREEN_PALETTE(m_palette) + screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_RASTER)); + screen.set_refresh_hz(60); + screen.set_size(32*8, 32*8); + screen.set_visarea(0*8, 32*8-1, 4*8, 28*8-1); + screen.set_screen_update(FUNC(nova2001_state::screen_update_nova2001)); + screen.set_palette(m_palette); GFXDECODE(config, m_gfxdecode, m_palette, gfx_nova2001); PALETTE(config, m_palette, FUNC(nova2001_state::nova2001_palette)).set_format(1, &nova2001_state::BBGGRRII, 512); @@ -672,39 +667,38 @@ MACHINE_CONFIG_START(nova2001_state::nova2001) SPEAKER(config, "mono").front_center(); ay8910_device &ay1(AY8910(config, "ay1", MAIN_CLOCK/6)); // 2 MHz verified on schematics - ay1.port_a_write_callback().set(FUNC(nova2001_state::nova2001_scroll_x_w)); - ay1.port_b_write_callback().set(FUNC(nova2001_state::nova2001_scroll_y_w)); + ay1.port_a_write_callback().set(FUNC(nova2001_state::scroll_x_w)); + ay1.port_b_write_callback().set(FUNC(nova2001_state::scroll_y_w)); ay1.add_route(ALL_OUTPUTS, "mono", 0.25); ay8910_device &ay2(AY8910(config, "ay2", MAIN_CLOCK/6)); ay2.port_a_read_callback().set_ioport("DSW1"); ay2.port_b_read_callback().set_ioport("DSW2"); ay2.add_route(ALL_OUTPUTS, "mono", 0.25); -MACHINE_CONFIG_END - -MACHINE_CONFIG_START(nova2001_state::ninjakun) +} +void nova2001_state::ninjakun(machine_config &config) +{ /* basic machine hardware */ - MCFG_DEVICE_ADD("maincpu", Z80, MAIN_CLOCK/4) // 3 MHz - MCFG_DEVICE_PROGRAM_MAP(ninjakun_cpu1_map) - MCFG_DEVICE_VBLANK_INT_DRIVER("screen", nova2001_state, irq0_line_hold) + Z80(config, m_maincpu, MAIN_CLOCK/4); // 3 MHz + m_maincpu->set_addrmap(AS_PROGRAM, &nova2001_state::ninjakun_cpu1_map); + m_maincpu->set_vblank_int("screen", FUNC(nova2001_state::irq0_line_hold)); - MCFG_DEVICE_ADD("sub", Z80, MAIN_CLOCK/4) // 3 MHz - MCFG_DEVICE_PROGRAM_MAP(ninjakun_cpu2_map) - MCFG_DEVICE_PERIODIC_INT_DRIVER(nova2001_state, irq0_line_hold, 4*60) /* ? */ + z80_device &subcpu(Z80(config, "sub", MAIN_CLOCK/4)); // 3 MHz + subcpu.set_addrmap(AS_PROGRAM, &nova2001_state::ninjakun_cpu2_map); + subcpu.set_periodic_int(FUNC(nova2001_state::irq0_line_hold), attotime::from_hz(4*60)); /* ? */ config.m_minimum_quantum = attotime::from_hz(6000); /* 100 CPU slices per frame */ MCFG_MACHINE_START_OVERRIDE(nova2001_state,ninjakun) /* video hardware */ - - MCFG_SCREEN_ADD("screen", RASTER) - MCFG_SCREEN_REFRESH_RATE(60) - MCFG_SCREEN_SIZE(32*8, 32*8) - MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 4*8, 28*8-1 ) - MCFG_SCREEN_UPDATE_DRIVER(nova2001_state, screen_update_ninjakun) - MCFG_SCREEN_PALETTE(m_palette) + screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_RASTER)); + screen.set_refresh_hz(60); + screen.set_size(32*8, 32*8); + screen.set_visarea(0*8, 32*8-1, 4*8, 28*8-1); + screen.set_screen_update(FUNC(nova2001_state::screen_update_ninjakun)); + screen.set_palette(m_palette); GFXDECODE(config, m_gfxdecode, m_palette, gfx_ninjakun); PALETTE(config, m_palette).set_format(1, &nova2001_state::BBGGRRII, 768); @@ -720,26 +714,26 @@ MACHINE_CONFIG_START(nova2001_state::ninjakun) ay1.add_route(ALL_OUTPUTS, "mono", 0.20); ay8910_device &ay2(AY8910(config, "ay2", MAIN_CLOCK/4)); // 3 MHz - ay2.port_a_write_callback().set(FUNC(nova2001_state::nova2001_scroll_x_w)); - ay2.port_b_write_callback().set(FUNC(nova2001_state::nova2001_scroll_y_w)); + ay2.port_a_write_callback().set(FUNC(nova2001_state::scroll_x_w)); + ay2.port_b_write_callback().set(FUNC(nova2001_state::scroll_y_w)); ay2.add_route(ALL_OUTPUTS, "mono", 0.20); -MACHINE_CONFIG_END - -MACHINE_CONFIG_START(nova2001_state::pkunwar) +} +void nova2001_state::pkunwar(machine_config &config) +{ /* basic machine hardware */ - MCFG_DEVICE_ADD("maincpu", Z80, MAIN_CLOCK/4) // 3 MHz - MCFG_DEVICE_PROGRAM_MAP(pkunwar_map) - MCFG_DEVICE_IO_MAP(pkunwar_io) - MCFG_DEVICE_VBLANK_INT_DRIVER("screen", nova2001_state, irq0_line_hold) + Z80(config, m_maincpu, MAIN_CLOCK/4); // 3 MHz + m_maincpu->set_addrmap(AS_PROGRAM, &nova2001_state::pkunwar_map); + m_maincpu->set_addrmap(AS_IO, &nova2001_state::pkunwar_io); + m_maincpu->set_vblank_int("screen", FUNC(nova2001_state::irq0_line_hold)); /* video hardware */ - MCFG_SCREEN_ADD("screen", RASTER) - MCFG_SCREEN_REFRESH_RATE(60) - MCFG_SCREEN_SIZE(32*8, 32*8) - MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 4*8, 28*8-1) - MCFG_SCREEN_UPDATE_DRIVER(nova2001_state, screen_update_pkunwar) - MCFG_SCREEN_PALETTE(m_palette) + screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_RASTER)); + screen.set_refresh_hz(60); + screen.set_size(32*8, 32*8); + screen.set_visarea(0*8, 32*8-1, 4*8, 28*8-1); + screen.set_screen_update(FUNC(nova2001_state::screen_update_pkunwar)); + screen.set_palette(m_palette); GFXDECODE(config, m_gfxdecode, m_palette, gfx_pkunwar); PALETTE(config, m_palette, FUNC(nova2001_state::nova2001_palette)).set_format(1, &nova2001_state::BBGGRRII, 512); @@ -758,29 +752,29 @@ MACHINE_CONFIG_START(nova2001_state::pkunwar) ay2.port_a_read_callback().set_ioport("IN2"); ay2.port_b_read_callback().set_ioport("DSW1"); ay2.add_route(ALL_OUTPUTS, "mono", 0.25); -MACHINE_CONFIG_END - -MACHINE_CONFIG_START(nova2001_state::raiders5) +} +void nova2001_state::raiders5(machine_config &config) +{ /* basic machine hardware */ - MCFG_DEVICE_ADD("maincpu", Z80, MAIN_CLOCK/4) // 3 MHz - MCFG_DEVICE_PROGRAM_MAP(raiders5_cpu1_map) - MCFG_DEVICE_IO_MAP(raiders5_io) - MCFG_DEVICE_VBLANK_INT_DRIVER("screen", nova2001_state, irq0_line_hold) + Z80(config, m_maincpu, MAIN_CLOCK/4); // 3 MHz + m_maincpu->set_addrmap(AS_PROGRAM, &nova2001_state::raiders5_cpu1_map); + m_maincpu->set_addrmap(AS_IO, &nova2001_state::raiders5_io); + m_maincpu->set_vblank_int("screen", FUNC(nova2001_state::irq0_line_hold)); - MCFG_DEVICE_ADD("sub", Z80, MAIN_CLOCK/4) // 3 MHz - MCFG_DEVICE_PROGRAM_MAP(raiders5_cpu2_map) - MCFG_DEVICE_PERIODIC_INT_DRIVER(nova2001_state, irq0_line_hold, 4*60) /* ? */ + z80_device &subcpu(Z80(config, "sub", MAIN_CLOCK/4)); // 3 MHz + subcpu.set_addrmap(AS_PROGRAM, &nova2001_state::raiders5_cpu2_map); + subcpu.set_periodic_int(FUNC(nova2001_state::irq0_line_hold), attotime::from_hz(4*60)); /* ? */ config.m_minimum_quantum = attotime::from_hz(24000); /* video hardware */ - MCFG_SCREEN_ADD("screen", RASTER) - MCFG_SCREEN_REFRESH_RATE(60) - MCFG_SCREEN_SIZE(32*8, 32*8) - MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 4*8, 28*8-1) - MCFG_SCREEN_UPDATE_DRIVER(nova2001_state, screen_update_raiders5) - MCFG_SCREEN_PALETTE(m_palette) + screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_RASTER)); + screen.set_refresh_hz(60); + screen.set_size(32*8, 32*8); + screen.set_visarea(0*8, 32*8-1, 4*8, 28*8-1); + screen.set_screen_update(FUNC(nova2001_state::screen_update_raiders5)); + screen.set_palette(m_palette); GFXDECODE(config, m_gfxdecode, m_palette, gfx_raiders5); PALETTE(config, m_palette).set_format(1, &nova2001_state::BBGGRRII, 768); @@ -799,7 +793,7 @@ MACHINE_CONFIG_START(nova2001_state::raiders5) ay2.port_a_read_callback().set_ioport("IN2"); ay2.port_b_read_callback().set_ioport("DSW1"); ay2.add_route(ALL_OUTPUTS, "mono", 0.25); -MACHINE_CONFIG_END +} @@ -866,13 +860,13 @@ ROM_START( nova2001u ) ROM_END ROM_START( ninjakun ) /* Original Board? */ - ROM_REGION( 0x10000, "maincpu", 0 ) + ROM_REGION( 0x8000, "maincpu", 0 ) ROM_LOAD( "ninja-1.7a", 0x0000, 0x02000, CRC(1c1dc141) SHA1(423d3ed35e73a8d5bfce075a889b0322b207bd0d) ) ROM_LOAD( "ninja-2.7b", 0x2000, 0x02000, CRC(39cc7d37) SHA1(7f0d0e1e92cb6a57f15eb7fc51a67112f1c5fc8e) ) ROM_LOAD( "ninja-3.7d", 0x4000, 0x02000, CRC(d542bfe3) SHA1(3814d8f5b1acda21438fff4f71670fa653dc7b30) ) ROM_LOAD( "ninja-4.7e", 0x6000, 0x02000, CRC(a57385c6) SHA1(77925a281e64889bfe967c3d42a388529aaf7eb6) ) - ROM_REGION( 0x10000, "sub", 0 ) + ROM_REGION( 0x2000, "sub", 0 ) ROM_LOAD( "ninja-5.7h", 0x0000, 0x02000, CRC(164a42c4) SHA1(16b434b33b76b878514f67c23315d4c6da7bfc9e) ) ROM_REGION( 0x08000, "gfx1", 0 ) @@ -921,11 +915,11 @@ ROM_START( pkunwarj ) ROM_END ROM_START( raiders5 ) - ROM_REGION( 0x10000, "maincpu", 0 ) + ROM_REGION( 0x8000, "maincpu", 0 ) ROM_LOAD( "raiders5.1", 0x0000, 0x4000, CRC(47cea11f) SHA1(0499e6627ad9c16775fdc59f2ff56dfdfc23490a) ) ROM_LOAD( "raiders5.2", 0x4000, 0x4000, CRC(eb2ff410) SHA1(5c995b66b6301cd3cd58efd173481deaa036f842) ) - ROM_REGION( 0x10000, "sub", 0 ) + ROM_REGION( 0x4000, "sub", 0 ) ROM_LOAD( "raiders5.2", 0x0000, 0x4000, CRC(eb2ff410) SHA1(5c995b66b6301cd3cd58efd173481deaa036f842) ) ROM_REGION( 0x8000, "gfx1", 0 ) // (need lineswapping) @@ -937,11 +931,11 @@ ROM_START( raiders5 ) ROM_END ROM_START( raiders5t ) - ROM_REGION( 0x10000, "maincpu", 0 ) + ROM_REGION( 0x8000, "maincpu", 0 ) ROM_LOAD( "raiders1.4c", 0x0000, 0x4000, CRC(4e2d5679) SHA1(a1c1603ba98814a83b92ad024ca4422aea872111) ) ROM_LOAD( "raiders2.4d", 0x4000, 0x4000, CRC(c8604be1) SHA1(6d23f26174bb9b2f7db3a5fa6b39674fe237135b) ) - ROM_REGION( 0x10000, "sub", 0 ) + ROM_REGION( 0x4000, "sub", 0 ) ROM_LOAD( "raiders2.4d", 0x0000, 0x4000, CRC(c8604be1) SHA1(6d23f26174bb9b2f7db3a5fa6b39674fe237135b) ) ROM_REGION( 0x8000, "gfx1", 0 ) // (need lineswapping) @@ -973,7 +967,7 @@ To make it possible to decode graphics without resorting to ROM_CONTINUE trickery, this function makes an address line rotation, bringing bit "bit" to bit 0 and shifting left by one place all the intervening bits. -This code is overly generic because it is used for several games in ninjakd2.c +This code is overly generic because it is used for several games in ninjakd2.cpp ******************************************************************************/ @@ -981,9 +975,9 @@ void nova2001_state::lineswap_gfx_roms(const char *region, const int bit) { const int length = memregion(region)->bytes(); - uint8_t* const src = memregion(region)->base(); + u8* const src = memregion(region)->base(); - std::vector temp(length); + std::vector temp(length); const int mask = (1 << (bit + 1)) - 1; @@ -1028,7 +1022,7 @@ void nova2001_state::init_raiders5() // many of these don't explicitly state Japan, eg. Nova 2001 could easily be used anywhere. -// YEAR, NAME, PARENT, MACHINE, INPUT, STATE, INIT, MONITOR,COMPANY,FULLNAME,FLAGS +// YEAR, NAME, PARENT, MACHINE, INPUT, STATE, INIT, MONITOR,COMPANY,FULLNAME,FLAGS GAME( 1983, nova2001, 0, nova2001, nova2001, nova2001_state, empty_init, ROT0, "UPL", "Nova 2001 (Japan)", MACHINE_SUPPORTS_SAVE ) GAME( 1983, nova2001h, nova2001, nova2001, nova2001, nova2001_state, empty_init, ROT0, "UPL", "Nova 2001 (Japan, hack?)", MACHINE_SUPPORTS_SAVE ) GAME( 1983, nova2001u, nova2001, nova2001, nova2001, nova2001_state, empty_init, ROT0, "UPL (Universal license)", "Nova 2001 (US)", MACHINE_SUPPORTS_SAVE ) diff --git a/src/mame/includes/nova2001.h b/src/mame/includes/nova2001.h index c1d105e78d1..e63b8116496 100644 --- a/src/mame/includes/nova2001.h +++ b/src/mame/includes/nova2001.h @@ -5,6 +5,7 @@ #pragma once +#include "cpu/z80/z80.h" #include "emupal.h" class nova2001_state : public driver_device @@ -31,33 +32,33 @@ public: DECLARE_CUSTOM_INPUT_MEMBER(ninjakun_io_A002_ctrl_r); private: - required_device m_maincpu; + required_device m_maincpu; required_device m_gfxdecode; required_device m_palette; - optional_shared_ptr m_fg_videoram; - required_shared_ptr m_bg_videoram; - optional_shared_ptr m_spriteram; + optional_shared_ptr m_fg_videoram; + required_shared_ptr m_bg_videoram; + optional_shared_ptr m_spriteram; - uint8_t m_ninjakun_io_a002_ctrl; + u8 m_ninjakun_io_a002_ctrl; tilemap_t *m_bg_tilemap; tilemap_t *m_fg_tilemap; DECLARE_WRITE8_MEMBER(ninjakun_cpu1_io_A002_w); DECLARE_WRITE8_MEMBER(ninjakun_cpu2_io_A002_w); - DECLARE_WRITE8_MEMBER(ninjakun_paletteram_w); - DECLARE_WRITE8_MEMBER(nova2001_fg_videoram_w); + DECLARE_WRITE8_MEMBER(paletteram_w); + DECLARE_WRITE8_MEMBER(fg_videoram_w); DECLARE_WRITE8_MEMBER(nova2001_bg_videoram_w); DECLARE_WRITE8_MEMBER(ninjakun_bg_videoram_w); DECLARE_READ8_MEMBER(ninjakun_bg_videoram_r); - DECLARE_WRITE8_MEMBER(nova2001_scroll_x_w); - DECLARE_WRITE8_MEMBER(nova2001_scroll_y_w); + DECLARE_WRITE8_MEMBER(scroll_x_w); + DECLARE_WRITE8_MEMBER(scroll_y_w); DECLARE_WRITE8_MEMBER(nova2001_flipscreen_w); DECLARE_WRITE8_MEMBER(pkunwar_flipscreen_w); DECLARE_VIDEO_START(nova2001); void nova2001_palette(palette_device &palette) const; - static rgb_t BBGGRRII(uint32_t raw); + static rgb_t BBGGRRII(u32 raw); DECLARE_MACHINE_START(ninjakun); DECLARE_VIDEO_START(ninjakun); DECLARE_VIDEO_START(pkunwar); @@ -71,15 +72,16 @@ private: TILE_GET_INFO_MEMBER(raiders5_get_bg_tile_info); TILE_GET_INFO_MEMBER(raiders5_get_fg_tile_info); - uint32_t screen_update_nova2001(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - uint32_t screen_update_ninjakun(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - uint32_t screen_update_pkunwar(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - uint32_t screen_update_raiders5(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); + u32 screen_update_nova2001(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); + u32 screen_update_ninjakun(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); + u32 screen_update_pkunwar(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); + u32 screen_update_raiders5(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); void nova2001_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect ); void pkunwar_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect ); void lineswap_gfx_roms(const char *region, const int bit); void ninjakun_cpu1_map(address_map &map); void ninjakun_cpu2_map(address_map &map); + void ninjakun_shared_map(address_map &map); void nova2001_map(address_map &map); void pkunwar_io(address_map &map); void pkunwar_map(address_map &map); diff --git a/src/mame/video/nova2001.cpp b/src/mame/video/nova2001.cpp index 8061ab4b477..748dff44a36 100644 --- a/src/mame/video/nova2001.cpp +++ b/src/mame/video/nova2001.cpp @@ -12,7 +12,7 @@ void nova2001_state::nova2001_palette(palette_device &palette) const { - uint8_t const *const color_prom = memregion("proms")->base(); + u8 const *const color_prom = memregion("proms")->base(); /* Color #1 is used for palette animation. @@ -35,17 +35,17 @@ void nova2001_state::nova2001_palette(palette_device &palette) const } } -rgb_t nova2001_state::BBGGRRII(uint32_t raw) +rgb_t nova2001_state::BBGGRRII(u32 raw) { - uint8_t const i = raw & 3; - uint8_t const r = ((raw >> 0) & 0x0c) | i; - uint8_t const g = ((raw >> 2) & 0x0c) | i; - uint8_t const b = ((raw >> 4) & 0x0c) | i; + u8 const i = raw & 3; + u8 const r = ((raw >> 0) & 0x0c) | i; + u8 const g = ((raw >> 2) & 0x0c) | i; + u8 const b = ((raw >> 4) & 0x0c) | i; return rgb_t(r | (r << 4), g | (g << 4), b | (b << 4)); } -WRITE8_MEMBER(nova2001_state::ninjakun_paletteram_w) +WRITE8_MEMBER(nova2001_state::paletteram_w) { m_palette->write8(space, offset, data); @@ -74,17 +74,17 @@ WRITE8_MEMBER(nova2001_state::ninjakun_paletteram_w) TILE_GET_INFO_MEMBER(nova2001_state::nova2001_get_bg_tile_info) { - int code = m_bg_videoram[tile_index]; - int color = m_bg_videoram[tile_index + 0x400] & 0x0f; + int const code = m_bg_videoram[tile_index]; + int const color = m_bg_videoram[tile_index + 0x400] & 0x0f; SET_TILE_INFO_MEMBER(2, code, color, 0); } TILE_GET_INFO_MEMBER(nova2001_state::nova2001_get_fg_tile_info) { - int attr = m_fg_videoram[tile_index + 0x400]; - int code = m_fg_videoram[tile_index]; - int color = attr & 0x0f; + int const attr = m_fg_videoram[tile_index + 0x400]; + int const code = m_fg_videoram[tile_index]; + int const color = attr & 0x0f; SET_TILE_INFO_MEMBER(1, code, color, 0); @@ -93,18 +93,18 @@ TILE_GET_INFO_MEMBER(nova2001_state::nova2001_get_fg_tile_info) TILE_GET_INFO_MEMBER(nova2001_state::ninjakun_get_bg_tile_info) { - int attr = m_bg_videoram[tile_index+0x400]; - int code = m_bg_videoram[tile_index] + ((attr & 0xc0) << 2); - int color = attr & 0x0f; + int const attr = m_bg_videoram[tile_index + 0x400]; + int const code = m_bg_videoram[tile_index] + ((attr & 0xc0) << 2); + int const color = attr & 0x0f; SET_TILE_INFO_MEMBER(2, code, color, 0); } TILE_GET_INFO_MEMBER(nova2001_state::ninjakun_get_fg_tile_info) { - int attr = m_fg_videoram[tile_index+0x400]; - int code = m_fg_videoram[tile_index] + ((attr & 0x20) << 3); - int color = attr & 0x0f; + int const attr = m_fg_videoram[tile_index + 0x400]; + int const code = m_fg_videoram[tile_index] + ((attr & 0x20) << 3); + int const color = attr & 0x0f; SET_TILE_INFO_MEMBER(1, code, color, 0); @@ -113,9 +113,9 @@ TILE_GET_INFO_MEMBER(nova2001_state::ninjakun_get_fg_tile_info) TILE_GET_INFO_MEMBER(nova2001_state::pkunwar_get_bg_tile_info) { - int attr = m_bg_videoram[tile_index + 0x400]; - int code = m_bg_videoram[tile_index] + ((attr & 0x07) << 8); - int color = (attr & 0xf0) >> 4; + int const attr = m_bg_videoram[tile_index + 0x400]; + int const code = m_bg_videoram[tile_index] + ((attr & 0x07) << 8); + int const color = (attr & 0xf0) >> 4; SET_TILE_INFO_MEMBER(1, code, color, 0); @@ -124,17 +124,17 @@ TILE_GET_INFO_MEMBER(nova2001_state::pkunwar_get_bg_tile_info) TILE_GET_INFO_MEMBER(nova2001_state::raiders5_get_bg_tile_info) { - int attr = m_bg_videoram[tile_index+0x400]; - int code = m_bg_videoram[tile_index] + ((attr & 0x01) << 8); - int color = (attr & 0xf0) >> 4; + int const attr = m_bg_videoram[tile_index + 0x400]; + int const code = m_bg_videoram[tile_index] + ((attr & 0x01) << 8); + int const color = (attr & 0xf0) >> 4; SET_TILE_INFO_MEMBER(2, code, color, 0); } TILE_GET_INFO_MEMBER(nova2001_state::raiders5_get_fg_tile_info) { - int code = m_fg_videoram[tile_index]; - int color = (m_fg_videoram[tile_index + 0x400] & 0xf0) >> 4; + int const code = m_fg_videoram[tile_index]; + int const color = (m_fg_videoram[tile_index + 0x400] & 0xf0) >> 4; SET_TILE_INFO_MEMBER(1, code, color, 0); } @@ -185,7 +185,7 @@ VIDEO_START_MEMBER(nova2001_state,raiders5) * *************************************/ -WRITE8_MEMBER(nova2001_state::nova2001_fg_videoram_w) +WRITE8_MEMBER(nova2001_state::fg_videoram_w) { m_fg_videoram[offset] = data; m_fg_tilemap->mark_tile_dirty(offset & 0x3ff); @@ -199,8 +199,8 @@ WRITE8_MEMBER(nova2001_state::nova2001_bg_videoram_w) WRITE8_MEMBER(nova2001_state::ninjakun_bg_videoram_w) { - int x = m_bg_tilemap->scrollx(0) >> 3; - int y = m_bg_tilemap->scrolly(0) >> 3; + int const x = m_bg_tilemap->scrollx(0) >> 3; + int const y = m_bg_tilemap->scrolly(0) >> 3; // add scroll registers to address offset = ((offset + x + (y << 5)) & 0x3ff) + (offset & 0x400); @@ -211,8 +211,8 @@ WRITE8_MEMBER(nova2001_state::ninjakun_bg_videoram_w) READ8_MEMBER(nova2001_state::ninjakun_bg_videoram_r) { - int x = m_bg_tilemap->scrollx(0) >> 3; - int y = m_bg_tilemap->scrolly(0) >> 3; + int const x = m_bg_tilemap->scrollx(0) >> 3; + int const y = m_bg_tilemap->scrolly(0) >> 3; // add scroll registers to address offset = ((offset + x + (y << 5)) & 0x3ff) + (offset & 0x400); @@ -220,12 +220,12 @@ READ8_MEMBER(nova2001_state::ninjakun_bg_videoram_r) return m_bg_videoram[offset]; } -WRITE8_MEMBER(nova2001_state::nova2001_scroll_x_w) +WRITE8_MEMBER(nova2001_state::scroll_x_w) { m_bg_tilemap->set_scrollx(0, data); } -WRITE8_MEMBER(nova2001_state::nova2001_scroll_y_w) +WRITE8_MEMBER(nova2001_state::scroll_y_w) { m_bg_tilemap->set_scrolly(0, data); } @@ -251,19 +251,15 @@ WRITE8_MEMBER(nova2001_state::pkunwar_flipscreen_w) void nova2001_state::nova2001_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect ) { - uint8_t *spriteram = m_spriteram; - gfx_element *gfx = m_gfxdecode->gfx(0); - int offs; - - for (offs = 0; offs < 0x800; offs += 32) + for (int offs = 0; offs < 0x800; offs += 32) { - int attr = spriteram[offs+3]; + int const attr = m_spriteram[offs+3]; int flipx = attr & 0x10; int flipy = attr & 0x20; - int sx = spriteram[offs+1] - ((attr & 0x40) << 2); // high bit shown in schematics, not used by game - int sy = spriteram[offs+2]; - int tile = spriteram[offs+0]; - int color = attr & 0x0f; + int sx = m_spriteram[offs+1] - ((attr & 0x40) << 2); // high bit shown in schematics, not used by game + int sy = m_spriteram[offs+2]; + int const tile = m_spriteram[offs+0]; + int const color = attr & 0x0f; if (attr & 0x80) // disable bit shown in schematics, not used by game { @@ -278,7 +274,7 @@ void nova2001_state::nova2001_draw_sprites(bitmap_ind16 &bitmap, const rectangle flipy = !flipy; } - gfx->transpen(bitmap,cliprect, + m_gfxdecode->gfx(0)->transpen(bitmap,cliprect, tile, color, flipx, flipy, @@ -288,19 +284,15 @@ void nova2001_state::nova2001_draw_sprites(bitmap_ind16 &bitmap, const rectangle void nova2001_state::pkunwar_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect ) { - uint8_t *spriteram = m_spriteram; - gfx_element *gfx = m_gfxdecode->gfx(0); - int offs; - - for (offs = 0; offs < 0x800; offs += 32) + for (int offs = 0; offs < 0x800; offs += 32) { - int attr = spriteram[offs+3]; - int flipx = spriteram[offs+0] & 0x01; - int flipy = spriteram[offs+0] & 0x02; - int sx = spriteram[offs+1]; - int sy = spriteram[offs+2]; - int tile = ((spriteram[offs+0] & 0xfc) >> 2) + ((attr & 0x07) << 6); - int color = (attr & 0xf0) >> 4; + int const attr = m_spriteram[offs+3]; + int flipx = m_spriteram[offs+0] & 0x01; + int flipy = m_spriteram[offs+0] & 0x02; + int sx = m_spriteram[offs+1]; + int sy = m_spriteram[offs+2]; + int const tile = ((m_spriteram[offs+0] & 0xfc) >> 2) + ((attr & 0x07) << 6); + int const color = (attr & 0xf0) >> 4; if (attr & 0x08) // deducted by comparison, not used by game { @@ -315,24 +307,24 @@ void nova2001_state::pkunwar_draw_sprites(bitmap_ind16 &bitmap, const rectangle flipy = !flipy; } - gfx->transpen(bitmap,cliprect, - tile, - color, - flipx, flipy, - sx, sy, 0); + m_gfxdecode->gfx(0)->transpen(bitmap,cliprect, + tile, + color, + flipx, flipy, + sx, sy, 0); // there's no X MSB, so draw with wraparound (fixes title screen) - gfx->transpen(bitmap,cliprect, - tile, - color, - flipx, flipy, - sx - 256, sy, 0); + m_gfxdecode->gfx(0)->transpen(bitmap,cliprect, + tile, + color, + flipx, flipy, + sx - 256, sy, 0); } } -uint32_t nova2001_state::screen_update_nova2001(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) +u32 nova2001_state::screen_update_nova2001(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) { m_bg_tilemap->draw(screen, bitmap, cliprect, 0, 0); @@ -346,7 +338,7 @@ uint32_t nova2001_state::screen_update_nova2001(screen_device &screen, bitmap_in return 0; } -uint32_t nova2001_state::screen_update_pkunwar(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) +u32 nova2001_state::screen_update_pkunwar(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) { m_bg_tilemap->draw(screen, bitmap, cliprect, TILEMAP_DRAW_OPAQUE | TILEMAP_DRAW_ALL_CATEGORIES, 0); @@ -357,7 +349,7 @@ uint32_t nova2001_state::screen_update_pkunwar(screen_device &screen, bitmap_ind return 0; } -uint32_t nova2001_state::screen_update_ninjakun(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) +u32 nova2001_state::screen_update_ninjakun(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) { m_bg_tilemap->draw(screen, bitmap, cliprect, 0, 0); @@ -370,7 +362,7 @@ uint32_t nova2001_state::screen_update_ninjakun(screen_device &screen, bitmap_in return 0; } -uint32_t nova2001_state::screen_update_raiders5(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) +u32 nova2001_state::screen_update_raiders5(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) { m_bg_tilemap->draw(screen, bitmap, cliprect, 0, 0); -- cgit v1.2.3