From 3cc0e8207b3b7775924a6f0e7053f9a6a2f906db Mon Sep 17 00:00:00 2001 From: Ivan Vangelista Date: Mon, 21 Nov 2022 19:19:40 +0100 Subject: sigma/sub.cpp, thepit/timelimt.cpp: consolidated drivers in single files --- src/mame/sigma/sub.cpp | 276 ++++++++++++++++++++++++++++------ src/mame/sigma/sub.h | 86 ----------- src/mame/sigma/sub_v.cpp | 127 ---------------- src/mame/thepit/timelimt.cpp | 332 ++++++++++++++++++++++++++++++++++------- src/mame/thepit/timelimt.h | 72 --------- src/mame/thepit/timelimt_v.cpp | 162 -------------------- 6 files changed, 511 insertions(+), 544 deletions(-) delete mode 100644 src/mame/sigma/sub.h delete mode 100644 src/mame/sigma/sub_v.cpp delete mode 100644 src/mame/thepit/timelimt.h delete mode 100644 src/mame/thepit/timelimt_v.cpp diff --git a/src/mame/sigma/sub.cpp b/src/mame/sigma/sub.cpp index 1254e7e56fb..45fdda167ba 100644 --- a/src/mame/sigma/sub.cpp +++ b/src/mame/sigma/sub.cpp @@ -1,5 +1,6 @@ // license:BSD-3-Clause -// copyright-holders:Angelo Salese, David Haywood +// copyright-holders: Angelo Salese, David Haywood + /************************************************************************************* Submarine (c) 1985 Sigma @@ -58,7 +59,7 @@ TODO: Text = sigma enterprises, inc. JAPAN F-021BCRT - (rotated 90 degress left) + (rotated 90 degrees left) Res = a bunch of resistors (colour weighting?) @@ -109,7 +110,190 @@ PCB2 (Top board, CPU board) *************************************************************************************/ #include "emu.h" -#include "sub.h" + +#include "cpu/z80/z80.h" +#include "machine/74259.h" +#include "machine/gen_latch.h" +#include "machine/watchdog.h" +#include "sound/ay8910.h" + +#include "emupal.h" +#include "screen.h" +#include "speaker.h" +#include "tilemap.h" + + +namespace { + +class sub_state : public driver_device +{ +public: + sub_state(const machine_config &mconfig, device_type type, const char *tag) : + driver_device(mconfig, type, tag), + m_maincpu(*this, "maincpu"), + m_soundcpu(*this, "soundcpu"), + m_gfxdecode(*this, "gfxdecode"), + m_palette(*this, "palette"), + m_vram(*this, "vram"), + m_attr(*this, "attr"), + m_spriteram(*this, "spriteram%u", 1U), + m_scrolly(*this, "scrolly") + { } + + void sub(machine_config &config); + +protected: + virtual void machine_start() override; + virtual void video_start() override; + +private: + required_device m_maincpu; + required_device m_soundcpu; + required_device m_gfxdecode; + required_device m_palette; + + required_shared_ptr m_vram; + required_shared_ptr m_attr; + required_shared_ptr_array m_spriteram; + required_shared_ptr m_scrolly; + + bool m_int_en = false; + bool m_nmi_en = false; + + tilemap_t *m_tilemap = nullptr; + + DECLARE_WRITE_LINE_MEMBER(int_mask_w); + void nmi_mask_w(uint8_t data); + + void sub_palette(palette_device &palette) const; + TILE_GET_INFO_MEMBER(get_tile_info); + void attr_w(offs_t offset, uint8_t data); + void vram_w(offs_t offset, uint8_t data); + void scrolly_w(offs_t offset, uint8_t data); + + void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect); + uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); + DECLARE_WRITE_LINE_MEMBER(main_irq); + INTERRUPT_GEN_MEMBER(sound_irq); + + void main_io_map(address_map &map); + void main_program_map(address_map &map); + void sound_io_map(address_map &map); + void sound_program_map(address_map &map); +}; + + +// video + +void sub_state::sub_palette(palette_device &palette) const +{ + uint8_t const *const color_prom = memregion("proms")->base(); + for (int i = 0; i < 0x100; i++) + { + int const r = color_prom[i | 0x000]; + int const g = color_prom[i | 0x100]; + int const b = color_prom[i | 0x200]; + + palette.set_indirect_color(i, rgb_t(pal4bit(r), pal4bit(g), pal4bit(b))); + } + + uint8_t const *const lookup = memregion("proms2")->base(); + for (int i = 0; i < 0x400; i++) + { + uint8_t const ctabentry = lookup[i | 0x400] | (lookup[i | 0x000] << 4); + palette.set_pen_indirect(i, ctabentry); + } +} + +TILE_GET_INFO_MEMBER(sub_state::get_tile_info) +{ + int const code = m_vram[tile_index] | ((m_attr[tile_index] & 0xe0) << 3); + int const color = (m_attr[tile_index] & 0x1f) + 0x40; + + tileinfo.set(0, code, color, 0); +} + +void sub_state::vram_w(offs_t offset, uint8_t data) +{ + m_vram[offset] = data; + m_tilemap->mark_tile_dirty(offset & 0x3ff); +} + +void sub_state::attr_w(offs_t offset, uint8_t data) +{ + m_attr[offset] = data; + m_tilemap->mark_tile_dirty(offset & 0x3ff); +} + +void sub_state::scrolly_w(offs_t offset, uint8_t data) +{ + m_scrolly[offset] = data; + m_tilemap->set_scrolly(offset, m_scrolly[offset]); +} + +void sub_state::video_start() +{ + m_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(sub_state::get_tile_info)), TILEMAP_SCAN_ROWS, 8, 8, 32, 32); + + m_tilemap->set_scroll_cols(32); +} + +/* +sprite bank 1 +0 xxxx xxxx X offset +1 tttt tttt tile offset +sprite bank 2 +0 yyyy yyyy Y offset +1 f--- ---- flips the X offset +1 -f-- ---- flip y, inverted +1 --cc cccc color +*/ +void sub_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect) +{ + for (uint8_t i = 0; i < 0x40; i += 2) + { + uint8_t const spr_offs = m_spriteram[0][i + 1]; + uint8_t x = m_spriteram[0][i + 0]; + uint8_t const y = 0xe0 - m_spriteram[1][i + 1]; + uint8_t const col = (m_spriteram[1][i + 0]) & 0x3f; + uint8_t const dx = (m_spriteram[1][i + 0] & 0x80) ? 0 : 1; + uint8_t const fy = (m_spriteram[1][i + 0] & 0x40) ? 0 : 1; + uint8_t fx = 0; + if (flip_screen()) + { + x = 0xe0 - x; + fx = 1; + //fx ^= 1; + //fy ^= 1; + } + + if (dx) + x = 0xe0 - x; + + m_gfxdecode->gfx(1)->transpen(bitmap, cliprect, spr_offs, col, fx, fy, x, y, 0); + } +} + + +uint32_t sub_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) +{ + m_tilemap->draw(screen, bitmap, cliprect, 0, 0); + draw_sprites(bitmap, cliprect); + + // re-draw score display above the sprites (window effect) + rectangle opaque_rect; + opaque_rect.min_y = cliprect.min_y; + opaque_rect.max_y = cliprect.max_y; + opaque_rect.min_x = flip_screen() ? cliprect.min_x : (cliprect.max_x - 32); + opaque_rect.max_x = flip_screen() ? (cliprect.min_x + 32) : cliprect.max_x; + + m_tilemap->draw(screen, bitmap, opaque_rect, 0, 0); + + return 0; +} + + +// machine void sub_state::machine_start() { @@ -125,15 +309,15 @@ WRITE_LINE_MEMBER(sub_state::int_mask_w) m_maincpu->set_input_line(0, CLEAR_LINE); } -void sub_state::subm_map(address_map &map) +void sub_state::main_program_map(address_map &map) { map(0x0000, 0xafff).rom(); map(0xb000, 0xbfff).ram(); - map(0xc000, 0xc3ff).ram().w(FUNC(sub_state::attr_w)).share("attr"); - map(0xc400, 0xc7ff).ram().w(FUNC(sub_state::vram_w)).share("vram"); - map(0xd000, 0xd03f).ram().share("spriteram"); - map(0xd800, 0xd83f).ram().share("spriteram2"); - map(0xd840, 0xd85f).ram().w(FUNC(sub_state::scrolly_w)).share("scrolly"); + map(0xc000, 0xc3ff).ram().w(FUNC(sub_state::attr_w)).share(m_attr); + map(0xc400, 0xc7ff).ram().w(FUNC(sub_state::vram_w)).share(m_vram); + map(0xd000, 0xd03f).ram().share(m_spriteram[0]); + map(0xd800, 0xd83f).ram().share(m_spriteram[1]); + map(0xd840, 0xd85f).ram().w(FUNC(sub_state::scrolly_w)).share(m_scrolly); map(0xe000, 0xe000).w("watchdog", FUNC(watchdog_timer_device::reset_w)); map(0xe800, 0xe807).w("mainlatch", FUNC(ls259_device::write_d0)); @@ -151,23 +335,23 @@ void sub_state::nmi_mask_w(uint8_t data) m_soundcpu->set_input_line(INPUT_LINE_NMI, CLEAR_LINE); } -void sub_state::subm_io(address_map &map) +void sub_state::main_io_map(address_map &map) { map.global_mask(0xff); - map(0x00, 0x00).r("soundlatch2", FUNC(generic_latch_8_device::read)).w(m_soundlatch, FUNC(generic_latch_8_device::write)); // to/from sound CPU + map(0x00, 0x00).r("soundlatch2", FUNC(generic_latch_8_device::read)).w("soundlatch", FUNC(generic_latch_8_device::write)); // to/from sound CPU } -void sub_state::subm_sound_map(address_map &map) +void sub_state::sound_program_map(address_map &map) { map(0x0000, 0x3fff).rom(); map(0x4000, 0x47ff).ram(); map(0x6000, 0x6000).w(FUNC(sub_state::nmi_mask_w)); } -void sub_state::subm_sound_io(address_map &map) +void sub_state::sound_io_map(address_map &map) { map.global_mask(0xff); - map(0x00, 0x00).r(m_soundlatch, FUNC(generic_latch_8_device::read)).w("soundlatch2", FUNC(generic_latch_8_device::write)); // to/from main CPU + map(0x00, 0x00).r("soundlatch", FUNC(generic_latch_8_device::read)).w("soundlatch2", FUNC(generic_latch_8_device::write)); // to/from main CPU map(0x40, 0x41).rw("ay1", FUNC(ay8910_device::data_r), FUNC(ay8910_device::address_data_w)); map(0x80, 0x81).rw("ay2", FUNC(ay8910_device::data_r), FUNC(ay8910_device::address_data_w)); } @@ -211,20 +395,19 @@ static INPUT_PORTS_START( sub ) PORT_DIPSETTING( 0x40, DEF_STR( 3C_1C ) ) PORT_DIPSETTING( 0x20, DEF_STR( 2C_1C ) ) PORT_DIPSETTING( 0x10, DEF_STR( 1C_1C ) ) + PORT_DIPSETTING( 0xd0, DEF_STR( 1C_1C ) ) // Duplicate PORT_DIPSETTING( 0x60, DEF_STR( 4C_5C ) ) PORT_DIPSETTING( 0x50, DEF_STR( 2C_3C ) ) PORT_DIPSETTING( 0x30, DEF_STR( 1C_2C ) ) + PORT_DIPSETTING( 0xe0, DEF_STR( 1C_2C ) ) // Duplicate PORT_DIPSETTING( 0x70, DEF_STR( 1C_3C ) ) + PORT_DIPSETTING( 0xa0, DEF_STR( 1C_3C ) ) // Duplicate PORT_DIPSETTING( 0xf0, DEF_STR( 1C_4C ) ) PORT_DIPSETTING( 0x80, DEF_STR( 1C_5C ) ) + PORT_DIPSETTING( 0xb0, DEF_STR( 1C_5C ) ) // Duplicate PORT_DIPSETTING( 0x90, DEF_STR( 1C_6C ) ) + PORT_DIPSETTING( 0xc0, DEF_STR( 1C_6C ) ) // Duplicate PORT_DIPSETTING( 0x00, DEF_STR( Free_Play ) ) -// Duplicates -// PORT_DIPSETTING( 0xa0, DEF_STR( 1C_3C ) ) -// PORT_DIPSETTING( 0xb0, DEF_STR( 1C_5C ) ) -// PORT_DIPSETTING( 0xc0, DEF_STR( 1C_6C ) ) -// PORT_DIPSETTING( 0xd0, DEF_STR( 1C_1C ) ) -// PORT_DIPSETTING( 0xe0, DEF_STR( 1C_2C ) ) PORT_START("DSW1") PORT_DIPNAME( 0x03, 0x00, DEF_STR( Lives ) ) @@ -242,8 +425,8 @@ static INPUT_PORTS_START( sub ) PORT_DIPSETTING( 0x10, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_DIPNAME( 0x20, 0x20, DEF_STR( Cabinet ) ) - PORT_DIPSETTING( 0x20, DEF_STR( Upright ) ) /* separate controls for each player */ - PORT_DIPSETTING( 0x00, DEF_STR( Cocktail ) ) /* Controls via player 1 for both, but need to get x/y screen flip working to fully test */ + PORT_DIPSETTING( 0x20, DEF_STR( Upright ) ) // separate controls for each player + PORT_DIPSETTING( 0x00, DEF_STR( Cocktail ) ) // Controls via player 1 for both, but need to get x/y screen flip working to fully test PORT_DIPNAME( 0x40, 0x40, DEF_STR( Demo_Sounds ) ) PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x40, DEF_STR( On ) ) @@ -281,8 +464,8 @@ static const gfx_layout tiles16x32_layout = }; static GFXDECODE_START( gfx_sub ) - GFXDECODE_ENTRY( "gfx1", 0, tiles8x8_layout, 0, 0x80 ) - GFXDECODE_ENTRY( "gfx2", 0, tiles16x32_layout, 0, 0x80 ) + GFXDECODE_ENTRY( "tiles", 0, tiles8x8_layout, 0, 0x80 ) + GFXDECODE_ENTRY( "sprites", 0, tiles16x32_layout, 0, 0x80 ) GFXDECODE_END WRITE_LINE_MEMBER(sub_state::main_irq) @@ -291,11 +474,6 @@ WRITE_LINE_MEMBER(sub_state::main_irq) m_maincpu->set_input_line(0, ASSERT_LINE); } -WRITE_LINE_MEMBER(sub_state::flipscreen_w) -{ - flip_screen_set(!(state & 1)); -} - INTERRUPT_GEN_MEMBER(sub_state::sound_irq) { if (m_nmi_en) @@ -306,25 +484,27 @@ INTERRUPT_GEN_MEMBER(sub_state::sound_irq) void sub_state::sub(machine_config &config) { - /* basic machine hardware */ - Z80(config, m_maincpu, MASTER_CLOCK/6); /* ? MHz */ - m_maincpu->set_addrmap(AS_PROGRAM, &sub_state::subm_map); - m_maincpu->set_addrmap(AS_IO, &sub_state::subm_io); + static constexpr XTAL MASTER_CLOCK = XTAL(18'432'000); - Z80(config, m_soundcpu, MASTER_CLOCK/6); /* ? MHz */ - m_soundcpu->set_addrmap(AS_PROGRAM, &sub_state::subm_sound_map); - m_soundcpu->set_addrmap(AS_IO, &sub_state::subm_sound_io); - m_soundcpu->set_periodic_int(FUNC(sub_state::sound_irq), attotime::from_hz(120)); //??? + // basic machine hardware + Z80(config, m_maincpu, MASTER_CLOCK / 6); // ? MHz + m_maincpu->set_addrmap(AS_PROGRAM, &sub_state::main_program_map); + m_maincpu->set_addrmap(AS_IO, &sub_state::main_io_map); + + Z80(config, m_soundcpu, MASTER_CLOCK / 6); // ? MHz + m_soundcpu->set_addrmap(AS_PROGRAM, &sub_state::sound_program_map); + m_soundcpu->set_addrmap(AS_IO, &sub_state::sound_io_map); + m_soundcpu->set_periodic_int(FUNC(sub_state::sound_irq), attotime::from_hz(120)); // ??? ls259_device &mainlatch(LS259(config, "mainlatch")); mainlatch.q_out_cb<0>().set(FUNC(sub_state::int_mask_w)); - mainlatch.q_out_cb<1>().set(FUNC(sub_state::flipscreen_w)); + mainlatch.q_out_cb<1>().set(FUNC(sub_state::flip_screen_set)).invert(); mainlatch.q_out_cb<3>().set_nop(); // same as Q0? mainlatch.q_out_cb<5>().set_nop(); WATCHDOG_TIMER(config, "watchdog"); - /* video hardware */ + // video hardware screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_RASTER)); screen.set_refresh_hz(60); screen.set_vblank_time(ATTOSECONDS_IN_USEC(0)); @@ -337,17 +517,16 @@ void sub_state::sub(machine_config &config) GFXDECODE(config, m_gfxdecode, m_palette, gfx_sub); PALETTE(config, m_palette, FUNC(sub_state::sub_palette), 0x400, 0x100); - /* sound hardware */ + // sound hardware SPEAKER(config, "mono").front_center(); - GENERIC_LATCH_8(config, m_soundlatch); - m_soundlatch->data_pending_callback().set_inputline(m_soundcpu, 0); + GENERIC_LATCH_8(config, "soundlatch").data_pending_callback().set_inputline(m_soundcpu, 0); GENERIC_LATCH_8(config, "soundlatch2"); - AY8910(config, "ay1", MASTER_CLOCK/6/2).add_route(ALL_OUTPUTS, "mono", 0.23); /* ? Mhz */ + AY8910(config, "ay1", MASTER_CLOCK / 6 / 2).add_route(ALL_OUTPUTS, "mono", 0.23); // ? MHz - AY8910(config, "ay2", MASTER_CLOCK/6/2).add_route(ALL_OUTPUTS, "mono", 0.23); /* ? Mhz */ + AY8910(config, "ay2", MASTER_CLOCK / 6 / 2).add_route(ALL_OUTPUTS, "mono", 0.23); // ? MHz } @@ -361,17 +540,17 @@ ROM_START( sub ) ROM_LOAD( "m sound pos f14 2764.bin", 0x0000, 0x2000, CRC(61536a97) SHA1(84effc2251bf7c91e0bb670a651117503de8940d) ) ROM_RELOAD( 0x2000, 0x2000 ) - ROM_REGION( 0xc000, "gfx1", 0) + ROM_REGION( 0xc000, "tiles", 0) ROM_LOAD( "vram 1 pos f12 27128 version3.bin", 0x0000, 0x4000, CRC(8d176ba0) SHA1(b0bf4af97e991545d6b38e8159eb909376e6df35) ) ROM_LOAD( "vram 2 pos f14 27128 version3.bin", 0x4000, 0x4000, CRC(0677cf3a) SHA1(072e9391f6a230b78124e820da0f0d27ffa45dc3) ) ROM_LOAD( "vram 3 pos f15 27128 version3.bin", 0x8000, 0x4000, CRC(9a4cd1a0) SHA1(a321b88386424d73d7d73a7f321317b0f21d2eb6) ) - ROM_REGION( 0xc000, "gfx2", 0 ) + ROM_REGION( 0xc000, "sprites", 0 ) ROM_LOAD( "obj 1 pos h1 27128 version3.bin", 0x0000, 0x4000, CRC(63173e65) SHA1(2be3776c0e08d2c876cfce842e02345389e1fba0) ) ROM_LOAD( "obj 2 pos h3 27128 version3.bin", 0x4000, 0x4000, CRC(3898d1a8) SHA1(acd3d7695a0fe9faa5e4315032c65e131d24a3ce) ) ROM_LOAD( "obj 3 pos h4 27128 version3.bin", 0x8000, 0x4000, CRC(304e2145) SHA1(d4eb49b5502872718d64e53f02acd2150f6bf713) ) - ROM_REGION( 0x300, "proms", 0 ) // color proms + ROM_REGION( 0x300, "proms", 0 ) // color PROMs ROM_LOAD( "prom pos a9 n82s129", 0x0200, 0x100, CRC(8df9cefe) SHA1(86320eb8135932d79c4478929b9fd90ffba55712) ) ROM_LOAD( "prom pos a10 n82s129", 0x0100, 0x100, CRC(3c834094) SHA1(4d681431376a8ed071566d74d4accc737bf965dd) ) ROM_LOAD( "prom pos a11 n82s129", 0x0000, 0x100, CRC(339afa95) SHA1(ff4ff712960f41c26419a681e8dcceaeef75d2e3) ) @@ -383,4 +562,7 @@ ROM_START( sub ) ROM_LOAD( "prom pos c8 n82s129", 0x0600, 0x100, CRC(351e1ef8) SHA1(530c9012ff5abda1c4ba9787ca999ca1ae1a893d) ) ROM_END +} // anonymous namespace + + GAME( 1985, sub, 0, sub, sub, sub_state, empty_init, ROT270, "Sigma Enterprises Inc.", "Submarine (Sigma)", MACHINE_SUPPORTS_SAVE ) diff --git a/src/mame/sigma/sub.h b/src/mame/sigma/sub.h deleted file mode 100644 index fe2639930c2..00000000000 --- a/src/mame/sigma/sub.h +++ /dev/null @@ -1,86 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Angelo Salese, David Haywood -/************************************************************************************* - -Submarine (c) 1985 Sigma - -*************************************************************************************/ -#ifndef MAME_INCLUDES_SUB_H -#define MAME_INCLUDES_SUB_H - -#pragma once - -#include "cpu/z80/z80.h" -#include "machine/74259.h" -#include "machine/gen_latch.h" -#include "machine/watchdog.h" -#include "sound/ay8910.h" -#include "emupal.h" -#include "screen.h" -#include "speaker.h" -#include "tilemap.h" - -#define MASTER_CLOCK XTAL(18'432'000) - -class sub_state : public driver_device -{ -public: - sub_state(const machine_config &mconfig, device_type type, const char *tag) : - driver_device(mconfig, type, tag), - m_maincpu(*this, "maincpu"), - m_soundcpu(*this, "soundcpu"), - m_gfxdecode(*this, "gfxdecode"), - m_palette(*this, "palette"), - m_soundlatch(*this, "soundlatch"), - m_vram(*this, "vram"), - m_attr(*this, "attr"), - m_spriteram(*this, "spriteram"), - m_spriteram2(*this, "spriteram2"), - m_scrolly(*this, "scrolly") - { } - - void sub(machine_config &config); - -private: - bool m_int_en = false; - bool m_nmi_en = false; - - DECLARE_WRITE_LINE_MEMBER(int_mask_w); - DECLARE_WRITE_LINE_MEMBER(flipscreen_w); - void nmi_mask_w(uint8_t data); - - void sub_palette(palette_device &palette) const; - TILE_GET_INFO_MEMBER(get_tile_info); - void attr_w(offs_t offset, uint8_t data); - void vram_w(offs_t offset, uint8_t data); - void scrolly_w(offs_t offset, uint8_t data); - - uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - DECLARE_WRITE_LINE_MEMBER(main_irq); - INTERRUPT_GEN_MEMBER(sound_irq); - void subm_io(address_map &map); - void subm_map(address_map &map); - void subm_sound_io(address_map &map); - void subm_sound_map(address_map &map); - - virtual void machine_start() override; - virtual void video_start() override; - - tilemap_t *m_tilemap = nullptr; - - required_device m_maincpu; - required_device m_soundcpu; - required_device m_gfxdecode; - required_device m_palette; - required_device m_soundlatch; - - required_shared_ptr m_vram; - required_shared_ptr m_attr; - required_shared_ptr m_spriteram; - required_shared_ptr m_spriteram2; - required_shared_ptr m_scrolly; - - void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect); -}; - -#endif // MAME_INCLUDES_SUB_H diff --git a/src/mame/sigma/sub_v.cpp b/src/mame/sigma/sub_v.cpp deleted file mode 100644 index 9230f3bd198..00000000000 --- a/src/mame/sigma/sub_v.cpp +++ /dev/null @@ -1,127 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Angelo Salese, David Haywood -/************************************************************************************* - -Submarine (c) 1985 Sigma - -Video functions - -*************************************************************************************/ - -#include "emu.h" -#include "sub.h" - -void sub_state::sub_palette(palette_device &palette) const -{ - uint8_t const *const color_prom = memregion("proms")->base(); - for (int i = 0; i < 0x100; i++) - { - int const r = color_prom[i | 0x000]; - int const g = color_prom[i | 0x100]; - int const b = color_prom[i | 0x200]; - - palette.set_indirect_color(i, rgb_t(pal4bit(r), pal4bit(g), pal4bit(b))); - } - - uint8_t const *const lookup = memregion("proms2")->base(); - for (int i = 0; i < 0x400; i++) - { - uint8_t const ctabentry = lookup[i | 0x400] | (lookup[i | 0x000] << 4); - palette.set_pen_indirect(i, ctabentry); - } -} - -TILE_GET_INFO_MEMBER(sub_state::get_tile_info) -{ - int code = m_vram[tile_index] | ((m_attr[tile_index]&0xe0)<<3); - int color = (m_attr[tile_index]&0x1f)+0x40; - - tileinfo.set(0, code, color, 0); -} - -void sub_state::vram_w(offs_t offset, uint8_t data) -{ - m_vram[offset] = data; - m_tilemap->mark_tile_dirty(offset & 0x3ff); -} - -void sub_state::attr_w(offs_t offset, uint8_t data) -{ - m_attr[offset] = data; - m_tilemap->mark_tile_dirty(offset & 0x3ff); -} - -void sub_state::scrolly_w(offs_t offset, uint8_t data) -{ - m_scrolly[offset] = data; - m_tilemap->set_scrolly(offset,m_scrolly[offset]); -} - -void sub_state::video_start() -{ - m_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(sub_state::get_tile_info)), TILEMAP_SCAN_ROWS, 8, 8, 32, 32); - - m_tilemap->set_scroll_cols(32); -} - -/* -sprite bank 1 -0 xxxx xxxx X offset -1 tttt tttt tile offset -sprite bank 2 -0 yyyy yyyy Y offset -1 f--- ---- flips the X offset -1 -f-- ---- flip y, inverted -1 --cc cccc color -*/ -void sub_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - gfx_element *gfx = m_gfxdecode->gfx(1); - - uint8_t *spriteram = m_spriteram; - uint8_t *spriteram_2 = m_spriteram2; - uint8_t x,y,spr_offs,i,col,dx,fx,fy; - - for(i=0;i<0x40;i+=2) - { - spr_offs = spriteram[i+1]; - x = spriteram[i+0]; - y = 0xe0 - spriteram_2[i+1]; - col = (spriteram_2[i+0])&0x3f; - dx = (spriteram_2[i+0] & 0x80) ? 0 : 1; - fy = (spriteram_2[i+0] & 0x40) ? 0 : 1; - fx = 0; - if (flip_screen()) - { - x = 0xe0 - x; - fx = 1; - //fx ^= 1; - //fy ^= 1; - } - - if(dx) - x = 0xe0 - x; - - - gfx->transpen(bitmap,cliprect,spr_offs,col,fx,fy,x,y,0); - } -} - - -uint32_t sub_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - m_tilemap->draw(screen, bitmap, cliprect, 0, 0); - draw_sprites(bitmap,cliprect); - - /* re-draw score display above the sprites (window effect) */ - rectangle opaque_rect; - opaque_rect.min_y = cliprect.min_y; - opaque_rect.max_y = cliprect.max_y; - opaque_rect.min_x = flip_screen() ? cliprect.min_x : (cliprect.max_x - 32); - opaque_rect.max_x = flip_screen() ? (cliprect.min_x + 32) : cliprect.max_x; - - m_tilemap->draw(screen, bitmap, opaque_rect, 0, 0); - - return 0; -} - diff --git a/src/mame/thepit/timelimt.cpp b/src/mame/thepit/timelimt.cpp index 27396ff178a..0eb285b9b7c 100644 --- a/src/mame/thepit/timelimt.cpp +++ b/src/mame/thepit/timelimt.cpp @@ -1,5 +1,6 @@ // license:BSD-3-Clause -// copyright-holders:Ernesto Corvi +// copyright-holders: Ernesto Corvi + /*************************************************************************** Time Limit (c) 1983 Chuo @@ -9,23 +10,251 @@ driver by Ernesto Corvi Notes: - Sprite colors are wrong (missing colortable?) -- driver should probably be merged with suprridr.cpp and thepit.cpp +- driver should probably be merged with venture/suprridr.cpp and + thepit/thepit.cpp - unused color bank for tilemaps? (colors 0x10-0x1f & 0x30-0x3f) ***************************************************************************/ #include "emu.h" -#include "timelimt.h" #include "cpu/z80/z80.h" #include "machine/74259.h" #include "machine/gen_latch.h" #include "machine/watchdog.h" #include "sound/ay8910.h" +#include "video/resnet.h" +#include "emupal.h" #include "screen.h" #include "speaker.h" +#include "tilemap.h" + + +namespace { + +class timelimt_state : public driver_device +{ +public: + timelimt_state(const machine_config &mconfig, device_type type, const char *tag) : + driver_device(mconfig, type, tag), + m_maincpu(*this, "maincpu"), + m_audiocpu(*this, "audiocpu"), + m_gfxdecode(*this, "gfxdecode"), + m_palette(*this, "palette"), + m_videoram(*this, "videoram"), + m_bg_videoram(*this, "bg_videoram"), + m_spriteram(*this, "spriteram") + { } + + void timelimt(machine_config &config); + +protected: + virtual void machine_start() override; + virtual void video_start() override; + +private: + required_device m_maincpu; + required_device m_audiocpu; + required_device m_gfxdecode; + required_device m_palette; + + required_shared_ptr m_videoram; + required_shared_ptr m_bg_videoram; + required_shared_ptr m_spriteram; + + bool m_nmi_enabled = false; + bool m_nmi_state = false; + uint16_t m_scrollx = 0; + uint8_t m_scrolly = 0; + tilemap_t *m_bg_tilemap = nullptr; + tilemap_t *m_fg_tilemap = nullptr; + + DECLARE_WRITE_LINE_MEMBER(nmi_enable_w); + DECLARE_WRITE_LINE_MEMBER(coin_lockout_w); + + void videoram_w(offs_t offset, uint8_t data); + void bg_videoram_w(offs_t offset, uint8_t data); + void scroll_x_lsb_w(uint8_t data); + void scroll_x_msb_w(uint8_t data); + void scroll_y_w(uint8_t data); + + TILE_GET_INFO_MEMBER(get_bg_tile_info); + TILE_GET_INFO_MEMBER(get_fg_tile_info); + + void palette(palette_device &palette) const; + + uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); + void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect); + + INTERRUPT_GEN_MEMBER(main_nmi); + + void main_io_map(address_map &map); + void main_map(address_map &map); + void sound_io_map(address_map &map); + void sound_map(address_map &map); +}; + + +// video + + +/*************************************************************************** + + Convert the color PROMs into a more useable format. + + Time Limit has three 32 bytes palette PROM, connected to the RGB output this + way: + + bit 7 -- 220 ohm resistor -- BLUE + -- 470 ohm resistor -- BLUE + -- 220 ohm resistor -- GREEN + -- 470 ohm resistor -- GREEN + -- 1 kohm resistor -- GREEN + -- 220 ohm resistor -- RED + -- 470 ohm resistor -- RED + bit 0 -- 1 kohm resistor -- RED + +***************************************************************************/ + +void timelimt_state::palette(palette_device &palette) const +{ + static constexpr int resistances_rg[3] = { 1000, 470, 220 }; + static constexpr int resistances_b [2] = { 470, 220 }; + + uint8_t const *const color_prom = memregion("proms")->base(); + + double weights_r[3], weights_g[3], weights_b[2]; + compute_resistor_weights(0, 255, -1.0, + 3, resistances_rg, weights_r, 0, 0, + 3, resistances_rg, weights_g, 0, 0, + 2, resistances_b, weights_b, 0, 0); + + for (int i = 0; i < palette.entries(); i++) + { + int bit0, bit1, bit2; + + // red component + bit0 = BIT(color_prom[i], 0); + bit1 = BIT(color_prom[i], 1); + bit2 = BIT(color_prom[i], 2); + int const r = combine_weights(weights_r, bit0, bit1, bit2); + + // green component + bit0 = BIT(color_prom[i], 3); + bit1 = BIT(color_prom[i], 4); + bit2 = BIT(color_prom[i], 5); + int const g = combine_weights(weights_g, bit0, bit1, bit2); + + // blue component + bit0 = BIT(color_prom[i], 6); + bit1 = BIT(color_prom[i], 7); + int const b = combine_weights(weights_b, bit0, bit1); + + palette.set_pen_color(i, rgb_t(r, g, b)); + } +} + +/*************************************************************************** + + Start the video hardware emulation. + +***************************************************************************/ + +TILE_GET_INFO_MEMBER(timelimt_state::get_bg_tile_info) +{ + tileinfo.set(1, m_bg_videoram[tile_index], 0, 0); +} + +TILE_GET_INFO_MEMBER(timelimt_state::get_fg_tile_info) +{ + tileinfo.set(0, m_videoram[tile_index], 0, 0); +} + +void timelimt_state::video_start() +{ + m_bg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(timelimt_state::get_bg_tile_info)), TILEMAP_SCAN_ROWS, 8, 8, 64, 32); + + m_fg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(timelimt_state::get_fg_tile_info)), TILEMAP_SCAN_ROWS, 8, 8, 32, 32); + + m_fg_tilemap->set_transparent_pen(0); + m_scrollx = 0; + m_scrolly = 0; + + save_item(NAME(m_scrollx)); + save_item(NAME(m_scrolly)); +} + +/***************************************************************************/ + +void timelimt_state::videoram_w(offs_t offset, uint8_t data) +{ + m_videoram[offset] = data; + m_fg_tilemap->mark_tile_dirty(offset); +} + +void timelimt_state::bg_videoram_w(offs_t offset, uint8_t data) +{ + m_bg_videoram[offset] = data; + m_bg_tilemap->mark_tile_dirty(offset); +} + +void timelimt_state::scroll_x_lsb_w(uint8_t data) +{ + m_scrollx &= 0x100; + m_scrollx |= data; +} + +void timelimt_state::scroll_x_msb_w(uint8_t data) +{ + m_scrollx &= 0xff; + m_scrollx |= (data & 1) << 8; +} + +void timelimt_state::scroll_y_w(uint8_t data) +{ + m_scrolly = data; +} + + +void timelimt_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect) +{ + for (int offs = m_spriteram.bytes() - 4; offs >= 0; offs -= 4) + { + int const sy = 240 - m_spriteram[offs]; + int const sx = m_spriteram[offs + 3]; + int code = m_spriteram[offs + 1] & 0x3f; + int const attr = m_spriteram[offs + 2]; + int const flipy = m_spriteram[offs + 1] & 0x80; + int const flipx = m_spriteram[offs + 1] & 0x40; + + code += (attr & 0x80) ? 0x40 : 0x00; + code += (attr & 0x40) ? 0x80 : 0x00; + + m_gfxdecode->gfx(2)->transpen(bitmap, cliprect, + code, + attr & 3, // was & 7, wrong for 3bpp and 32 colors + flipx, flipy, + sx, sy, 0); + } +} + + +uint32_t timelimt_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) +{ + m_bg_tilemap->set_scrollx(0, m_scrollx); + m_bg_tilemap->set_scrolly(0, m_scrolly); + m_bg_tilemap->draw(screen, bitmap, cliprect, 0, 0); + + draw_sprites(bitmap, cliprect); + + m_fg_tilemap->draw(screen, bitmap, cliprect, 0, 0); + return 0; +} + + +// machine /***************************************************************************/ @@ -52,22 +281,22 @@ WRITE_LINE_MEMBER(timelimt_state::coin_lockout_w) void timelimt_state::main_map(address_map &map) { - map(0x0000, 0x7fff).rom(); /* rom */ - map(0x8000, 0x87ff).ram(); /* ram */ - map(0x8800, 0x8bff).ram().w(FUNC(timelimt_state::videoram_w)).share("videoram"); /* video ram */ - map(0x9000, 0x97ff).ram().w(FUNC(timelimt_state::bg_videoram_w)).share("bg_videoram");/* background ram */ - map(0x9800, 0x98ff).ram().share("spriteram"); /* sprite ram */ + map(0x0000, 0x7fff).rom(); + map(0x8000, 0x87ff).ram(); + map(0x8800, 0x8bff).ram().w(FUNC(timelimt_state::videoram_w)).share(m_videoram); + map(0x9000, 0x97ff).ram().w(FUNC(timelimt_state::bg_videoram_w)).share(m_bg_videoram); + map(0x9800, 0x98ff).ram().share(m_spriteram); map(0xa000, 0xa000).portr("INPUTS"); map(0xa800, 0xa800).portr("SYSTEM"); map(0xb000, 0xb000).portr("DSW"); map(0xb000, 0xb007).w("mainlatch", FUNC(ls259_device::write_d0)); - map(0xb800, 0xb800).w("soundlatch", FUNC(generic_latch_8_device::write)); /* sound write */ - map(0xb800, 0xb800).nopr(); /* NMI ack? */ + map(0xb800, 0xb800).w("soundlatch", FUNC(generic_latch_8_device::write)); + map(0xb800, 0xb800).nopr(); // NMI ack? map(0xc800, 0xc800).w(FUNC(timelimt_state::scroll_x_lsb_w)); map(0xc801, 0xc801).w(FUNC(timelimt_state::scroll_x_msb_w)); map(0xc802, 0xc802).w(FUNC(timelimt_state::scroll_y_w)); - map(0xc803, 0xc803).nopw(); /* ???? bit 0 used only */ - map(0xc804, 0xc804).nopw(); /* ???? not used */ + map(0xc803, 0xc803).nopw(); // ???? bit 0 used only + map(0xc804, 0xc804).nopw(); // ???? not used } void timelimt_state::main_io_map(address_map &map) @@ -99,19 +328,19 @@ static INPUT_PORTS_START( timelimt ) PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_4WAY PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_4WAY PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 ) - PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNKNOWN ) /* probably unused */ - PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN ) /* probably unused */ - PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN ) /* probably unused */ + PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNKNOWN ) // probably unused + PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN ) // probably unused + PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN ) // probably unused PORT_START("SYSTEM") PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_SERVICE1 ) PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_START1 ) PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_START2 ) - PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNKNOWN ) /* probably unused */ - PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNKNOWN ) /* probably unused */ - PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN ) /* probably unused */ - PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN ) /* probably unused */ + PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNKNOWN ) // probably unused + PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNKNOWN ) // probably unused + PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN ) // probably unused + PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN ) // probably unused PORT_START("DSW") PORT_DIPNAME( 0x07, 0x01, DEF_STR( Coinage ) ) @@ -126,10 +355,10 @@ static INPUT_PORTS_START( timelimt ) PORT_DIPNAME( 0x10, 0x00, DEF_STR( Lives ) ) PORT_DIPSETTING( 0x00, "3" ) PORT_DIPSETTING( 0x10, "5" ) - PORT_DIPNAME( 0x20, 0x00, DEF_STR( Unknown ) ) /* probably bonus */ + PORT_DIPNAME( 0x20, 0x00, DEF_STR( Unknown ) ) // probably bonus PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x20, DEF_STR( On ) ) - PORT_DIPNAME( 0x40, 0x00, DEF_STR( Unknown ) ) /* probably screen-flip */ + PORT_DIPNAME( 0x40, 0x00, DEF_STR( Unknown ) ) // probably screen-flip PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x40, DEF_STR( On ) ) PORT_DIPNAME( 0x80, 0x00, "Invincibility (Cheat)") @@ -145,7 +374,7 @@ static INPUT_PORTS_START( progress ) PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON2 ) - PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN ) /* probably unused */ + PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN ) // probably unused PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_START("SYSTEM") @@ -153,10 +382,10 @@ static INPUT_PORTS_START( progress ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_SERVICE1 ) PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_START1 ) PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_START2 ) - PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNKNOWN ) /* probably unused */ - PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNKNOWN ) /* probably unused */ - PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN ) /* probably unused */ - PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN ) /* probably unused */ + PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNKNOWN ) // probably unused + PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNKNOWN ) // probably unused + PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN ) // probably unused + PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN ) // probably unused PORT_START("DSW") PORT_DIPNAME( 0x07, 0x01, DEF_STR( Coinage ) ) @@ -174,7 +403,7 @@ static INPUT_PORTS_START( progress ) PORT_DIPNAME( 0x20, 0x00, DEF_STR( Bonus_Life ) ) PORT_DIPSETTING( 0x00, "20,000 & 100,000" ) PORT_DIPSETTING( 0x20, "50,000 & 200,000" ) - PORT_DIPNAME( 0x40, 0x00, DEF_STR( Unknown ) ) /* Manual shows "SCREEN" Table=On / Upright=Off */ + PORT_DIPNAME( 0x40, 0x00, DEF_STR( Unknown ) ) // Manual shows "SCREEN" Table=On / Upright=Off PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x40, DEF_STR( On ) ) PORT_DIPNAME( 0x80, 0x00, "Invincibility (Cheat)") @@ -209,9 +438,9 @@ static const gfx_layout spritelayout = }; static GFXDECODE_START( gfx_timelimt ) - GFXDECODE_ENTRY( "tiles_1", 0, charlayout, 32, 1 ) /* seems correct */ - GFXDECODE_ENTRY( "tiles_2", 0, charlayout, 0, 1 ) /* seems correct */ - GFXDECODE_ENTRY( "sprites", 0, spritelayout, 64, 4 ) /* seems correct */ + GFXDECODE_ENTRY( "tiles_1", 0, charlayout, 32, 1 ) // seems correct + GFXDECODE_ENTRY( "tiles_2", 0, charlayout, 0, 1 ) // seems correct + GFXDECODE_ENTRY( "sprites", 0, spritelayout, 64, 4 ) // seems correct GFXDECODE_END /***************************************************************************/ @@ -230,16 +459,16 @@ INTERRUPT_GEN_MEMBER(timelimt_state::main_nmi) void timelimt_state::timelimt(machine_config &config) { - /* basic machine hardware */ - Z80(config, m_maincpu, 5000000); /* 5.000 MHz */ + // basic machine hardware + Z80(config, m_maincpu, 5'000'000); // 5.000 MHz m_maincpu->set_addrmap(AS_PROGRAM, &timelimt_state::main_map); m_maincpu->set_addrmap(AS_IO, &timelimt_state::main_io_map); m_maincpu->set_vblank_int("screen", FUNC(timelimt_state::main_nmi)); - Z80(config, m_audiocpu, 18432000/6); /* 3.072 MHz */ + Z80(config, m_audiocpu, 18'432'000 / 6); // 3.072 MHz m_audiocpu->set_addrmap(AS_PROGRAM, &timelimt_state::sound_map); m_audiocpu->set_addrmap(AS_IO, &timelimt_state::sound_io_map); - m_audiocpu->set_vblank_int("screen", FUNC(timelimt_state::irq0_line_hold)); /* ? */ + m_audiocpu->set_vblank_int("screen", FUNC(timelimt_state::irq0_line_hold)); // ? config.set_maximum_quantum(attotime::from_hz(3000)); @@ -252,7 +481,7 @@ void timelimt_state::timelimt(machine_config &config) WATCHDOG_TIMER(config, "watchdog"); - /* video hardware */ + // video hardware screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_RASTER)); screen.set_refresh_hz(60); screen.set_vblank_time(ATTOSECONDS_IN_USEC(0)); @@ -262,16 +491,16 @@ void timelimt_state::timelimt(machine_config &config) screen.set_palette(m_palette); GFXDECODE(config, m_gfxdecode, m_palette, gfx_timelimt); - PALETTE(config, m_palette, FUNC(timelimt_state::timelimt_palette), 64+32); + PALETTE(config, m_palette, FUNC(timelimt_state::palette), 64+32); - /* sound hardware */ + // sound hardware SPEAKER(config, "mono").front_center(); GENERIC_LATCH_8(config, "soundlatch"); - AY8910(config, "ay1", 18432000/12).add_route(ALL_OUTPUTS, "mono", 0.25); + AY8910(config, "ay1", 18'432'000 / 12).add_route(ALL_OUTPUTS, "mono", 0.25); - ay8910_device &ay2(AY8910(config, "ay2", 18432000/12)); + ay8910_device &ay2(AY8910(config, "ay2", 18'432'000 / 12)); ay2.port_a_read_callback().set("soundlatch", FUNC(generic_latch_8_device::read)); ay2.add_route(ALL_OUTPUTS, "mono", 0.25); } @@ -283,54 +512,54 @@ void timelimt_state::timelimt(machine_config &config) ***************************************************************************/ ROM_START( timelimt ) - ROM_REGION( 0x10000, "maincpu", 0 ) /* ROMs */ + ROM_REGION( 0x10000, "maincpu", 0 ) ROM_LOAD( "t8", 0x0000, 0x2000, CRC(006767ca) SHA1(a5d528c58cd73c0101ffa9ab783ec870668256db) ) ROM_LOAD( "t7", 0x2000, 0x2000, CRC(cbe7cd86) SHA1(502a78c14c9717a466ea24cdc63da4c0f3bec1f9) ) ROM_LOAD( "t6", 0x4000, 0x2000, CRC(f5f17e39) SHA1(7d78f551ce73276725c349703a790f2a63bb5503) ) ROM_LOAD( "t9", 0x6000, 0x2000, CRC(2d72ab45) SHA1(01d4afacc01b9e7c49355123efd5f5ad4d79a9cd) ) - ROM_REGION( 0x10000, "audiocpu", 0 ) /* ROMs */ + ROM_REGION( 0x10000, "audiocpu", 0 ) ROM_LOAD( "tl5", 0x0000, 0x1000, CRC(5b782e4a) SHA1(2f4fe2beb8efa5a636fefc1ee172d0200d1c9497) ) ROM_LOAD( "tl4", 0x1000, 0x1000, CRC(a32883a9) SHA1(26e1725b67be87db28855672facb1504b8ac84d6) ) - ROM_REGION( 0x2000, "tiles_1", 0 ) /* tiles */ + ROM_REGION( 0x2000, "tiles_1", 0 ) ROM_LOAD( "tl11", 0x0000, 0x1000, CRC(46676307) SHA1(38fe80722972b6b3ba32705469a0dcb868fb76a9) ) ROM_LOAD( "tl10", 0x1000, 0x1000, CRC(2336908a) SHA1(345fc209ce891cc6f8f111c6d3a9e0f65ee6d818) ) - ROM_REGION( 0x2000, "tiles_2", 0 ) /* tiles */ + ROM_REGION( 0x2000, "tiles_2", 0 ) ROM_LOAD( "tl13", 0x0000, 0x1000, CRC(072e4053) SHA1(209edf7b371078e38d1c2812fa6a3d1a78193b3f) ) ROM_LOAD( "tl12", 0x1000, 0x1000, CRC(ce960389) SHA1(57ee52cfa1b5a3832b362b38c8b7aa411dfc782b) ) - ROM_REGION( 0x6000, "sprites", 0 ) /* sprites */ + ROM_REGION( 0x6000, "sprites", 0 ) ROM_LOAD( "tl3", 0x4000, 0x2000, CRC(01a9fd95) SHA1(cd1078700c97a3539c9d9447c55efbd27540a1b3) ) ROM_LOAD( "tl2", 0x2000, 0x2000, CRC(4693b849) SHA1(fbebedde53599fb1eaedc648bd704b321ab096b5) ) ROM_LOAD( "tl1", 0x0000, 0x2000, CRC(c4007caf) SHA1(ae05af3319545d5ca98a046bfc100138a5a3ed96) ) ROM_REGION( 0x0060, "proms", 0 ) // N82S123N color PROMs ROM_LOAD( "clr.35", 0x0000, 0x0020, CRC(9c9e6073) SHA1(98496175bf19a8cdb0018705bc1a2193b8a782e1) ) - ROM_LOAD( "clr.48", 0x0020, 0x0020, CRC(a0bcac59) SHA1(e5832831b21981363509b79d89766757bd9273b0) ) /* FIXED BITS (xxxxxx1x) */ + ROM_LOAD( "clr.48", 0x0020, 0x0020, CRC(a0bcac59) SHA1(e5832831b21981363509b79d89766757bd9273b0) ) // FIXED BITS (xxxxxx1x) ROM_LOAD( "clr.57", 0x0040, 0x0020, CRC(3a9f5394) SHA1(0b501f81ce1df722cf7ef982c03e0be337bfe9ee) ) ROM_END ROM_START( progress ) - ROM_REGION( 0x10000, "maincpu", 0 ) /* ROMs */ + ROM_REGION( 0x10000, "maincpu", 0 ) ROM_LOAD( "pg8.bin", 0x0000, 0x2000, CRC(e8779658) SHA1(3eca574d7328d54e544e663f58be789dbf151e77) ) ROM_LOAD( "pg7.bin", 0x2000, 0x2000, CRC(5dcf6b6f) SHA1(550f02ff5ed2935f4c3c9055c5742fea46f42351) ) ROM_LOAD( "pg6.bin", 0x4000, 0x2000, CRC(f21d2a08) SHA1(b2542e895d6d011895abec641b056ad8d7dc0d15) ) ROM_LOAD( "pg9.bin", 0x6000, 0x2000, CRC(052ab4ac) SHA1(a2bfb575f2dfde862f9b1e8a4378f9b6b6200831) ) - ROM_REGION( 0x10000, "audiocpu", 0 ) /* ROMs */ + ROM_REGION( 0x10000, "audiocpu", 0 ) ROM_LOAD( "pg4.bin", 0x0000, 0x1000, CRC(b1cc2fe8) SHA1(c9045e7b65311b052c337ad3bedadf108d1c24c3) ) - ROM_REGION( 0x2000, "tiles_1", 0 ) /* tiles */ + ROM_REGION( 0x2000, "tiles_1", 0 ) ROM_LOAD( "pg11.bin", 0x0000, 0x1000, CRC(bd8462e4) SHA1(91b1bd2d69aa1b1a84ee8e642b2c1131a7697dd9) ) ROM_LOAD( "pg10.bin", 0x1000, 0x1000, CRC(c4bbf0b8) SHA1(d149eda9637474febdafd565a60eb2940702f162) ) - ROM_REGION( 0x2000, "tiles_2", 0 ) /* tiles */ + ROM_REGION( 0x2000, "tiles_2", 0 ) ROM_LOAD( "pg13.bin", 0x0000, 0x1000, CRC(25ec45be) SHA1(1271b7a5632934a82ccae35de8c2968247a233bb) ) ROM_LOAD( "pg12.bin", 0x1000, 0x1000, CRC(c837c5f5) SHA1(dbfc0d8afe0a8e9dd213cb4095b23b7aa8e2b6f4) ) - ROM_REGION( 0x6000, "sprites", 0 ) /* sprites */ + ROM_REGION( 0x6000, "sprites", 0 ) ROM_LOAD( "pg1.bin", 0x0000, 0x2000, CRC(155c8f7f) SHA1(0d32ebceb9b2a0b3faf1f91b7a6800999889b331) ) ROM_LOAD( "pg2.bin", 0x2000, 0x2000, CRC(a6ca4dfc) SHA1(4243c9ea98e365bf342cf928ff97cafb35cdc7b6) ) ROM_LOAD( "pg3.bin", 0x4000, 0x2000, CRC(2b21c2fb) SHA1(8c95889a19057d32790c9ccddc0977980eddbd0e) ) @@ -341,5 +570,8 @@ ROM_START( progress ) ROM_LOAD( "57.bin", 0x0040, 0x0020, CRC(18455a79) SHA1(e4d64368560e3116a922588129f5f91a4c520f7d) ) ROM_END +} // anonymous namespace + + GAME( 1983, timelimt, 0, timelimt, timelimt, timelimt_state, empty_init, ROT90, "Chuo Co. Ltd", "Time Limit", MACHINE_SUPPORTS_SAVE ) GAME( 1984, progress, 0, timelimt, progress, timelimt_state, empty_init, ROT90, "Chuo Co. Ltd", "Progress", MACHINE_SUPPORTS_SAVE ) diff --git a/src/mame/thepit/timelimt.h b/src/mame/thepit/timelimt.h deleted file mode 100644 index f8125bbfa3f..00000000000 --- a/src/mame/thepit/timelimt.h +++ /dev/null @@ -1,72 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Ernesto Corvi -#ifndef MAME_INCLUDES_TIMELIMT_H -#define MAME_INCLUDES_TIMELIMT_H - -#pragma once - -#include "emupal.h" -#include "tilemap.h" - -class timelimt_state : public driver_device -{ -public: - timelimt_state(const machine_config &mconfig, device_type type, const char *tag) : - driver_device(mconfig, type, tag), - m_maincpu(*this, "maincpu"), - m_audiocpu(*this, "audiocpu"), - m_gfxdecode(*this, "gfxdecode"), - m_palette(*this, "palette"), - m_videoram(*this, "videoram"), - m_bg_videoram(*this, "bg_videoram"), - m_spriteram(*this, "spriteram") - { } - - void timelimt(machine_config &config); - -protected: - virtual void machine_start() override; - virtual void video_start() override; - - required_device m_maincpu; - required_device m_audiocpu; - required_device m_gfxdecode; - required_device m_palette; - - required_shared_ptr m_videoram; - required_shared_ptr m_bg_videoram; - required_shared_ptr m_spriteram; - - bool m_nmi_enabled = false; - bool m_nmi_state = false; - int m_scrollx = 0; - int m_scrolly = 0; - tilemap_t *m_bg_tilemap = nullptr; - tilemap_t *m_fg_tilemap = nullptr; - - DECLARE_WRITE_LINE_MEMBER(nmi_enable_w); - DECLARE_WRITE_LINE_MEMBER(coin_lockout_w); - - void videoram_w(offs_t offset, uint8_t data); - void bg_videoram_w(offs_t offset, uint8_t data); - void scroll_x_lsb_w(uint8_t data); - void scroll_x_msb_w(uint8_t data); - void scroll_y_w(uint8_t data); - - TILE_GET_INFO_MEMBER(get_bg_tile_info); - TILE_GET_INFO_MEMBER(get_fg_tile_info); - - void timelimt_palette(palette_device &palette) const; - - uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect); - - INTERRUPT_GEN_MEMBER(main_nmi); - - void main_io_map(address_map &map); - void main_map(address_map &map); - void sound_io_map(address_map &map); - void sound_map(address_map &map); -}; - -#endif // MAME_INCLUDES_TIMELIMT_H diff --git a/src/mame/thepit/timelimt_v.cpp b/src/mame/thepit/timelimt_v.cpp deleted file mode 100644 index c8be27c2345..00000000000 --- a/src/mame/thepit/timelimt_v.cpp +++ /dev/null @@ -1,162 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Ernesto Corvi -#include "emu.h" -#include "timelimt.h" -#include "video/resnet.h" - - -/*************************************************************************** - - Convert the color PROMs into a more useable format. - - Time Limit has three 32 bytes palette PROM, connected to the RGB output this - way: - - bit 7 -- 220 ohm resistor -- BLUE - -- 470 ohm resistor -- BLUE - -- 220 ohm resistor -- GREEN - -- 470 ohm resistor -- GREEN - -- 1 kohm resistor -- GREEN - -- 220 ohm resistor -- RED - -- 470 ohm resistor -- RED - bit 0 -- 1 kohm resistor -- RED - -***************************************************************************/ - -void timelimt_state::timelimt_palette(palette_device &palette) const -{ - static constexpr int resistances_rg[3] = { 1000, 470, 220 }; - static constexpr int resistances_b [2] = { 470, 220 }; - - uint8_t const *const color_prom = memregion("proms")->base(); - - double weights_r[3], weights_g[3], weights_b[2]; - compute_resistor_weights(0, 255, -1.0, - 3, resistances_rg, weights_r, 0, 0, - 3, resistances_rg, weights_g, 0, 0, - 2, resistances_b, weights_b, 0, 0); - - for (int i = 0; i < palette.entries(); i++) - { - int bit0, bit1, bit2; - - // red component - bit0 = BIT(color_prom[i], 0); - bit1 = BIT(color_prom[i], 1); - bit2 = BIT(color_prom[i], 2); - int const r = combine_weights(weights_r, bit0, bit1, bit2); - - // green component - bit0 = BIT(color_prom[i], 3); - bit1 = BIT(color_prom[i], 4); - bit2 = BIT(color_prom[i], 5); - int const g = combine_weights(weights_g, bit0, bit1, bit2); - - // blue component - bit0 = BIT(color_prom[i], 6); - bit1 = BIT(color_prom[i], 7); - int const b = combine_weights(weights_b, bit0, bit1); - - palette.set_pen_color(i, rgb_t(r, g, b)); - } -} - -/*************************************************************************** - - Start the video hardware emulation. - -***************************************************************************/ - -TILE_GET_INFO_MEMBER(timelimt_state::get_bg_tile_info) -{ - tileinfo.set(1, m_bg_videoram[tile_index], 0, 0); -} - -TILE_GET_INFO_MEMBER(timelimt_state::get_fg_tile_info) -{ - tileinfo.set(0, m_videoram[tile_index], 0, 0); -} - -void timelimt_state::video_start() -{ - m_bg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(timelimt_state::get_bg_tile_info)), TILEMAP_SCAN_ROWS, - 8, 8, 64, 32); - - m_fg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(timelimt_state::get_fg_tile_info)), TILEMAP_SCAN_ROWS, - 8, 8, 32, 32); - - m_fg_tilemap->set_transparent_pen(0); - - m_scrollx = 0; - m_scrolly = 0; - - save_item(NAME(m_scrollx)); - save_item(NAME(m_scrolly)); -} - -/***************************************************************************/ - -void timelimt_state::videoram_w(offs_t offset, uint8_t data) -{ - m_videoram[offset] = data; - m_fg_tilemap->mark_tile_dirty(offset); -} - -void timelimt_state::bg_videoram_w(offs_t offset, uint8_t data) -{ - m_bg_videoram[offset] = data; - m_bg_tilemap->mark_tile_dirty(offset); -} - -void timelimt_state::scroll_x_lsb_w(uint8_t data) -{ - m_scrollx &= 0x100; - m_scrollx |= data & 0xff; -} - -void timelimt_state::scroll_x_msb_w(uint8_t data) -{ - m_scrollx &= 0xff; - m_scrollx |= ( data & 1 ) << 8; -} - -void timelimt_state::scroll_y_w(uint8_t data) -{ - m_scrolly = data; -} - - -void timelimt_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - for( int offs = m_spriteram.bytes() - 4; offs >= 0; offs -= 4 ) - { - int sy = 240 - m_spriteram[offs]; - int sx = m_spriteram[offs+3]; - int code = m_spriteram[offs+1] & 0x3f; - int attr = m_spriteram[offs+2]; - int flipy = m_spriteram[offs+1] & 0x80; - int flipx = m_spriteram[offs+1] & 0x40; - - code += ( attr & 0x80 ) ? 0x40 : 0x00; - code += ( attr & 0x40 ) ? 0x80 : 0x00; - - m_gfxdecode->gfx(2)->transpen(bitmap,cliprect, - code, - attr & 3, // was & 7, wrong for 3bpp and 32 colors - flipx,flipy, - sx,sy,0); - } -} - - -uint32_t timelimt_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - m_bg_tilemap->set_scrollx(0, m_scrollx); - m_bg_tilemap->set_scrolly(0, m_scrolly); - m_bg_tilemap->draw(screen, bitmap, cliprect, 0, 0); - - draw_sprites(bitmap, cliprect); - - m_fg_tilemap->draw(screen, bitmap, cliprect, 0, 0); - return 0; -} -- cgit v1.2.3