From d15fc6c284533f1e60f06de01c47f7c25e7c75b6 Mon Sep 17 00:00:00 2001 From: hap Date: Thu, 2 Sep 2021 23:19:15 +0200 Subject: [PATCH] n8080: merge some input ports, remove tag lookups --- src/mame/audio/n8080.cpp | 6 +-- src/mame/drivers/n8080.cpp | 91 +++++++++++--------------------------- src/mame/includes/n8080.h | 7 ++- src/mame/video/n8080.cpp | 47 +++++++++----------- 4 files changed, 54 insertions(+), 97 deletions(-) diff --git a/src/mame/audio/n8080.cpp b/src/mame/audio/n8080.cpp index 16f78afbedd..8296a4d6735 100644 --- a/src/mame/audio/n8080.cpp +++ b/src/mame/audio/n8080.cpp @@ -460,7 +460,7 @@ void helifire_state::sound_io_map(address_map &map) void spacefev_state::spacefev_sound(machine_config &config) { /* basic machine hardware */ - I8035(config, m_audiocpu, 6000000); + I8035(config, m_audiocpu, 6_MHz_XTAL); m_audiocpu->set_addrmap(AS_PROGRAM, &spacefev_state::n8080_sound_cpu_map); m_audiocpu->t0_in_cb().set(FUNC(spacefev_state::n8080_8035_t0_r)); m_audiocpu->t1_in_cb().set(FUNC(spacefev_state::n8080_8035_t1_r)); @@ -494,7 +494,7 @@ void spacefev_state::spacefev_sound(machine_config &config) void sheriff_state::sheriff_sound(machine_config &config) { /* basic machine hardware */ - I8035(config, m_audiocpu, 6000000); + I8035(config, m_audiocpu, 6_MHz_XTAL); m_audiocpu->set_addrmap(AS_PROGRAM, &sheriff_state::n8080_sound_cpu_map); m_audiocpu->t0_in_cb().set(FUNC(sheriff_state::n8080_8035_t0_r)); m_audiocpu->t1_in_cb().set(FUNC(sheriff_state::n8080_8035_t1_r)); @@ -526,7 +526,7 @@ void sheriff_state::sheriff_sound(machine_config &config) void helifire_state::helifire_sound(machine_config &config) { /* basic machine hardware */ - I8035(config, m_audiocpu, 6000000); + I8035(config, m_audiocpu, 6_MHz_XTAL); m_audiocpu->set_addrmap(AS_PROGRAM, &helifire_state::n8080_sound_cpu_map); m_audiocpu->set_addrmap(AS_IO, &helifire_state::sound_io_map); m_audiocpu->t0_in_cb().set(FUNC(helifire_state::helifire_8035_t0_r)); diff --git a/src/mame/drivers/n8080.cpp b/src/mame/drivers/n8080.cpp index 46987b17dd6..6c868116de4 100644 --- a/src/mame/drivers/n8080.cpp +++ b/src/mame/drivers/n8080.cpp @@ -199,11 +199,11 @@ static INPUT_PORTS_START( spacefev ) PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(2) PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_2WAY PORT_PLAYER(2) PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_2WAY PORT_PLAYER(2) - PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME("Game A") PORT_CODE(KEYCODE_Q) - PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME("Game B") PORT_CODE(KEYCODE_W) - PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME("Game C") PORT_CODE(KEYCODE_E) + PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("Game A") + PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_NAME("Game B") + PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_NAME("Game C") PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNUSED ) - PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNUSED ) /* enables diagnostic ROM at $1c00 */ + PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNUSED ) // enables diagnostic ROM at $1c00 ($2000 for highsplt/spacelnc) PORT_START("IN2") PORT_DIPNAME( 0x03, 0x00, DEF_STR( Lives )) @@ -231,32 +231,14 @@ static INPUT_PORTS_START( spacefev ) PORT_DIPSETTING( 0x00, DEF_STR( On )) PORT_START("IN3") - + PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED ) INPUT_PORTS_END static INPUT_PORTS_START( highsplt ) - PORT_START("IN0") - PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1 ) - PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_2WAY - PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_2WAY - PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_START1 ) - PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_START2 ) - PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNUSED ) - PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNUSED ) - PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_COIN1 ) + PORT_INCLUDE( spacefev ) - PORT_START("IN1") - PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(2) - PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_2WAY PORT_PLAYER(2) - PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_2WAY PORT_PLAYER(2) - PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME("Game A") PORT_CODE(KEYCODE_Q) - PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME("Game B") PORT_CODE(KEYCODE_W) - PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME("Game C") PORT_CODE(KEYCODE_E) - PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNUSED ) - PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNUSED ) /* enables diagnostic ROM at $2000 */ - - PORT_START("IN2") + PORT_MODIFY("IN2") PORT_DIPNAME( 0x03, 0x00, DEF_STR( Lives )) PORT_DIPSETTING( 0x00, "3" ) PORT_DIPSETTING( 0x01, "4" ) @@ -279,34 +261,13 @@ static INPUT_PORTS_START( highsplt ) PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unused )) PORT_DIPSETTING( 0x80, DEF_STR( Off )) PORT_DIPSETTING( 0x00, DEF_STR( On )) - - PORT_START("IN3") - INPUT_PORTS_END static INPUT_PORTS_START( spacelnc ) - PORT_START("IN0") - PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1 ) - PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_2WAY - PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_2WAY - PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_START1 ) - PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_START2 ) - PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNUSED ) - PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNUSED ) - PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_COIN1 ) + PORT_INCLUDE( highsplt ) - PORT_START("IN1") - PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(2) - PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_2WAY PORT_PLAYER(2) - PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_2WAY PORT_PLAYER(2) - PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME("Game A") PORT_CODE(KEYCODE_Q) - PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME("Game B") PORT_CODE(KEYCODE_W) - PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME("Game C") PORT_CODE(KEYCODE_E) - PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNUSED ) - PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNUSED ) /* enables diagnostic ROM at $2000 */ - - PORT_START("IN2") + PORT_MODIFY("IN2") PORT_DIPNAME( 0x03, 0x00, DEF_STR( Lives )) PORT_DIPSETTING( 0x00, "3" ) PORT_DIPSETTING( 0x01, "4" ) @@ -329,9 +290,6 @@ static INPUT_PORTS_START( spacelnc ) PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unused )) PORT_DIPSETTING( 0x80, DEF_STR( Off )) PORT_DIPSETTING( 0x00, DEF_STR( On )) - - PORT_START("IN3") - INPUT_PORTS_END @@ -361,9 +319,9 @@ static INPUT_PORTS_START( sheriff ) PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_COCKTAIL PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_START1 ) PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_START2 ) - PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNUSED ) /* EXP1 */ - PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNUSED ) /* EXP2 */ - PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNUSED ) /* EXP3 enables diagnostic ROM at $2400 */ + PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNUSED ) // EXP1 + PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNUSED ) // EXP2 + PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNUSED ) // EXP3 enables diagnostic ROM at $2400 PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_COIN1 ) PORT_START("IN3") @@ -395,15 +353,16 @@ static INPUT_PORTS_START( bandido ) PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_JOYSTICKRIGHT_DOWN ) PORT_START("IN1") + PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_START("IN2") PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_COIN2 ) PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_START1 ) PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_START2 ) - PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNUSED ) /* EXP1 */ - PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNUSED ) /* EXP2 */ - PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNUSED ) /* EXP3 enables diagnostic ROM at $2400 */ + PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNUSED ) // EXP1 + PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNUSED ) // EXP2 + PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNUSED ) // EXP3 enables diagnostic ROM at $2400 PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_COIN1 ) PORT_START("IN3") @@ -427,7 +386,7 @@ static INPUT_PORTS_START( bandido ) PORT_DIPNAME( 0x40, 0x00, DEF_STR( Unused )) PORT_DIPSETTING( 0x40, DEF_STR( Off )) PORT_DIPSETTING( 0x00, DEF_STR( On )) - PORT_DIPNAME( 0x80, 0x00, DEF_STR( Unknown )) /* don't know if this is used */ + PORT_DIPNAME( 0x80, 0x00, DEF_STR( Unknown )) // don't know if this is used PORT_DIPSETTING( 0x80, DEF_STR( Off )) PORT_DIPSETTING( 0x00, DEF_STR( On )) INPUT_PORTS_END @@ -465,11 +424,11 @@ static INPUT_PORTS_START( westgun2 ) PORT_DIPNAME( 0x20, 0x20, DEF_STR( Cabinet )) PORT_DIPSETTING( 0x20, DEF_STR( Upright )) PORT_DIPSETTING( 0x00, DEF_STR( Cocktail )) - PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNUSED ) /* enables diagnostic ROM at $2400 */ + PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNUSED ) // enables diagnostic ROM at $2400 PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_COIN1 ) PORT_START("IN3") - + PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED ) INPUT_PORTS_END @@ -499,9 +458,9 @@ static INPUT_PORTS_START( helifire ) PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_START1 ) PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_START2 ) - PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNUSED ) /* EXP1 */ - PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNUSED ) /* EXP2 */ - PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNUSED ) /* EXP3 */ + PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNUSED ) // EXP1 + PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNUSED ) // EXP2 + PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNUSED ) // EXP3 PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_COIN1 ) PORT_START("IN3") @@ -731,7 +690,7 @@ ROM_START( spacefev ) ROM_REGION( 0x0400, "audiocpu", 0 ) ROM_LOAD( "ss3.ic2", 0x0000, 0x0400, CRC(95c2c1ee) SHA1(42a3a382fc7d2782052372d71f6d0e8a153e74d0) ) - ROM_REGION( 0x0020, "proms", 0 ) + ROM_REGION( 0x0020, "proms", 0 ) // for color video hw ROM_LOAD( "f5-i-.bin", 0x0000, 0x0020, CRC(c5914ec1) SHA1(198875fcab36d09c8726bb21e2fdff9882f6721a) ) // "F5?C" ROM_END @@ -748,7 +707,7 @@ ROM_START( spacefevo ) ROM_REGION( 0x0400, "audiocpu", 0 ) ROM_LOAD( "ss3.ic2", 0x0000, 0x0400, CRC(95c2c1ee) SHA1(42a3a382fc7d2782052372d71f6d0e8a153e74d0) ) - ROM_REGION( 0x0020, "proms", 0 ) + ROM_REGION( 0x0020, "proms", 0 ) // for color video hw ROM_LOAD( "f5-i-.bin", 0x0000, 0x0020, CRC(c5914ec1) SHA1(198875fcab36d09c8726bb21e2fdff9882f6721a) ) // "F5?C" ROM_END @@ -765,7 +724,7 @@ ROM_START( spacefevo2 ) ROM_REGION( 0x0400, "audiocpu", 0 ) ROM_LOAD( "ss3.ic2", 0x0000, 0x0400, CRC(95c2c1ee) SHA1(42a3a382fc7d2782052372d71f6d0e8a153e74d0) ) - ROM_REGION( 0x0020, "proms", 0 ) + ROM_REGION( 0x0020, "proms", 0 ) // for color video hw ROM_LOAD( "f5-i-.bin", 0x0000, 0x0020, CRC(c5914ec1) SHA1(198875fcab36d09c8726bb21e2fdff9882f6721a) ) // "F5?C" ROM_END diff --git a/src/mame/includes/n8080.h b/src/mame/includes/n8080.h index 0a944bdfa38..f0bffde9905 100644 --- a/src/mame/includes/n8080.h +++ b/src/mame/includes/n8080.h @@ -19,6 +19,7 @@ public: n8080_state(const machine_config &mconfig, device_type type, const char *tag) : driver_device(mconfig, type, tag), m_videoram(*this, "videoram"), + m_prom(*this, "proms"), m_maincpu(*this, "maincpu"), m_audiocpu(*this, "audiocpu"), m_n8080_dac(*this, "n8080_dac"), @@ -36,9 +37,9 @@ protected: virtual void delayed_sound_1(int data); virtual void delayed_sound_2(int data); -//private: /* memory pointers */ required_shared_ptr m_videoram; + optional_memory_region m_prom; /* video-related */ int m_sheriff_color_mode; @@ -155,7 +156,8 @@ public: helifire_state(const machine_config &mconfig, device_type type, const char *tag) : n8080_state(mconfig, type, tag), m_dac(*this, "helifire_dac"), - m_colorram(*this, "colorram") + m_colorram(*this, "colorram"), + m_pot(*this, "POT%u", 0) { } void helifire(machine_config &config); @@ -188,6 +190,7 @@ private: required_device m_dac; required_shared_ptr m_colorram; + required_ioport_array<2> m_pot; int m_dac_phase; double m_dac_volume; diff --git a/src/mame/video/n8080.cpp b/src/mame/video/n8080.cpp index 7d7a7147d02..c80fb805e07 100644 --- a/src/mame/video/n8080.cpp +++ b/src/mame/video/n8080.cpp @@ -33,11 +33,11 @@ void helifire_state::helifire_palette(palette_device &palette) const { int const level = 0xff * exp(-3 * i / 255.); // capacitor discharge - palette.set_pen_color(0x000 + 8 + i, rgb_t(0x00, 0x00, level)); // shades of blue - palette.set_pen_color(0x100 + 8 + i, rgb_t(0x00, 0xc0, level)); // shades of blue w/ green star + palette.set_pen_color(0x000 + 8 + i, rgb_t(0x00, 0x00, level)); // shades of blue + palette.set_pen_color(0x100 + 8 + i, rgb_t(0x00, 0xc0, level)); // shades of blue w/ green star - palette.set_pen_color(0x200 + 8 + i, rgb_t(level, 0x00, 0x00)); // shades of red - palette.set_pen_color(0x300 + 8 + i, rgb_t(level, 0xc0, 0x00)); // shades of red w/ green star + palette.set_pen_color(0x200 + 8 + i, rgb_t(level, 0x00, 0x00)); // shades of red + palette.set_pen_color(0x300 + 8 + i, rgb_t(level, 0xc0, 0x00)); // shades of red w/ green star } } @@ -129,7 +129,7 @@ uint32_t spacefev_state::screen_update(screen_device &screen, bitmap_ind16 &bitm uint8_t mask = flip_screen() ? 0xff : 0x00; uint8_t const *pRAM = m_videoram; - uint8_t const *const pPROM = memregion("proms")->base(); + uint8_t const *const pPROM = m_prom->base(); for (int y = 0; y < 256; y++) { @@ -154,12 +154,12 @@ uint32_t spacefev_state::screen_update(screen_device &screen, bitmap_ind16 &bitm { static const uint8_t ufo_color[] = { - 1, /* red */ - 2, /* green */ - 7, /* white */ - 3, /* yellow */ - 5, /* magenta */ - 6, /* cyan */ + 1, // red + 2, // green + 7, // white + 3, // yellow + 5, // magenta + 6, // cyan }; int cycle = screen.frame_number() / 32; @@ -193,7 +193,7 @@ uint32_t sheriff_state::screen_update(screen_device &screen, bitmap_ind16 &bitma uint8_t mask = flip_screen() ? 0xff : 0x00; uint8_t const *pRAM = m_videoram; - uint8_t const *const pPROM = memregion("proms")->base(); + uint8_t const *const pPROM = m_prom->base(); for (int y = 0; y < 256; y++) { @@ -226,8 +226,8 @@ uint32_t sheriff_state::screen_update(screen_device &screen, bitmap_ind16 &bitma uint32_t helifire_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) { - int SUN_BRIGHTNESS = ioport("POT0")->read(); - int SEA_BRIGHTNESS = ioport("POT1")->read(); + const int SUN_BRIGHTNESS = m_pot[0]->read(); + const int SEA_BRIGHTNESS = m_pot[1]->read(); static const int wave[8] = { 0, 1, 2, 2, 2, 1, 0, 0 }; @@ -240,16 +240,14 @@ uint32_t helifire_state::screen_update(screen_device &screen, bitmap_ind16 &bitm int level = 120 + wave[m_mv & 7]; - /* draw sky */ - + // draw sky for (int x = level; x < 256; x++) { pLine[x] = 0x200 + 8 + SUN_BRIGHTNESS + x - level; } - /* draw stars */ - - if (m_mv % 8 == 4) /* upper half */ + // draw stars + if (m_mv % 8 == 4) // upper half { int step = (320 * (m_mv - 0)) % sizeof m_LSFR; @@ -262,7 +260,7 @@ uint32_t helifire_state::screen_update(screen_device &screen, bitmap_ind16 &bitm pLine[0x80 + data] |= 0x100; } - if (m_mv % 8 == 5) /* lower half */ + if (m_mv % 8 == 5) // lower half { int step = (320 * (m_mv - 1)) % sizeof m_LSFR; @@ -275,15 +273,13 @@ uint32_t helifire_state::screen_update(screen_device &screen, bitmap_ind16 &bitm pLine[0x00 + data] |= 0x100; } - /* draw sea */ - + // draw sea for (int x = 0; x < level; x++) { pLine[x] = 8 + SEA_BRIGHTNESS + x; } - /* draw foreground */ - + // draw foreground for (int x = 0; x < 256; x += 8) { int offset = 32 * y + (x >> 3); @@ -307,8 +303,7 @@ uint32_t helifire_state::screen_update(screen_device &screen, bitmap_ind16 &bitm } } - /* next line */ - + // next line next_line(); }