From 9350b48825818b0e147abf64edf57562f226485e Mon Sep 17 00:00:00 2001 From: Ivan Vangelista Date: Fri, 26 Aug 2022 18:08:27 +0200 Subject: taito\ashnojoe.cpp, taito/bigevglf.cpp, taito/chaknpop.cpp: consolidated drivers in single files, minor cleanups --- src/mame/misc/photon2.cpp | 2 +- src/mame/sega/sega16sp.cpp | 6 +- src/mame/taito/ashnojoe.cpp | 304 ++++++++++++++++++++++++++++---- src/mame/taito/ashnojoe.h | 85 --------- src/mame/taito/ashnojoe_v.cpp | 167 ------------------ src/mame/taito/bigevglf.cpp | 369 +++++++++++++++++++++++++++----------- src/mame/taito/bigevglf.h | 95 ---------- src/mame/taito/bigevglf_v.cpp | 89 ---------- src/mame/taito/chaknpop.cpp | 402 ++++++++++++++++++++++++++++++++++++++---- src/mame/taito/chaknpop.h | 77 -------- src/mame/taito/chaknpop_v.cpp | 239 ------------------------- 11 files changed, 905 insertions(+), 930 deletions(-) delete mode 100644 src/mame/taito/ashnojoe.h delete mode 100644 src/mame/taito/ashnojoe_v.cpp delete mode 100644 src/mame/taito/bigevglf.h delete mode 100644 src/mame/taito/bigevglf_v.cpp delete mode 100644 src/mame/taito/chaknpop.h delete mode 100644 src/mame/taito/chaknpop_v.cpp diff --git a/src/mame/misc/photon2.cpp b/src/mame/misc/photon2.cpp index fef016fde4f..22124872757 100644 --- a/src/mame/misc/photon2.cpp +++ b/src/mame/misc/photon2.cpp @@ -99,7 +99,7 @@ private: #define SPEC_LEFT_BORDER_CYCLES 24 /* Cycles to display left hand border */ #define SPEC_DISPLAY_XSIZE_CYCLES 128 /* Horizontal screen resolution */ #define SPEC_RIGHT_BORDER_CYCLES 24 /* Cycles to display right hand border */ -#define SPEC_RETRACE_CYCLES 48 /* Cycles taken for horizonal retrace */ +#define SPEC_RETRACE_CYCLES 48 /* Cycles taken for horizontal retrace */ #define SPEC_CYCLES_PER_LINE 224 /* Number of cycles to display a single line */ static constexpr rgb_t spectrum_palette[16] = { diff --git a/src/mame/sega/sega16sp.cpp b/src/mame/sega/sega16sp.cpp index bcc324317fa..d942df151ba 100644 --- a/src/mame/sega/sega16sp.cpp +++ b/src/mame/sega/sega16sp.cpp @@ -132,7 +132,7 @@ void sega_hangon_sprite_device::draw(bitmap_ind16 &bitmap, const rectangle &clip // // Special notes: // - // There is an interaction between the horizonal flip bit and the offset. + // There is an interaction between the horizontal flip bit and the offset. // The offset is maintained as a 16-bit value, even though only the lower // 15 bits are used for the address. The top bit is used to control flipping. // This means that if the low 15 bits overflow during rendering, the sprite @@ -312,7 +312,7 @@ void sega_sharrier_sprite_device::draw(bitmap_ind16 &bitmap, const rectangle &cl // // Special notes: // - // There is an interaction between the horizonal flip bit and the offset. + // There is an interaction between the horizontal flip bit and the offset. // The offset is maintained as a 16-bit value, even though only the lower // 15 bits are used for the address. The top bit is used to control flipping. // This means that if the low 15 bits overflow during rendering, the sprite @@ -496,7 +496,7 @@ void sega_sys16a_sprite_device::draw(bitmap_ind16 &bitmap, const rectangle &clip // // Special notes: // - // There is an interaction between the horizonal flip bit and the offset. + // There is an interaction between the horizontal flip bit and the offset. // The offset is maintained as a 16-bit value, even though only the lower // 15 bits are used for the address. The top bit is used to control flipping. // This means that if the low 15 bits overflow during rendering, the sprite diff --git a/src/mame/taito/ashnojoe.cpp b/src/mame/taito/ashnojoe.cpp index b725e5d7dd2..fb836af00cb 100644 --- a/src/mame/taito/ashnojoe.cpp +++ b/src/mame/taito/ashnojoe.cpp @@ -1,5 +1,6 @@ // license:BSD-3-Clause -// copyright-holders:David Haywood +// copyright-holders: David Haywood + /*************************************************************************** Success Joe / Ashita no Joe [Wave] @@ -75,15 +76,246 @@ Coin B is not used *************************************************************************/ #include "emu.h" -#include "ashnojoe.h" #include "cpu/z80/z80.h" #include "cpu/m68000/m68000.h" +#include "machine/gen_latch.h" +#include "sound/msm5205.h" #include "sound/ymopn.h" + #include "emupal.h" #include "screen.h" #include "speaker.h" +#include "tilemap.h" + + +namespace { + +class ashnojoe_state : public driver_device +{ +public: + ashnojoe_state(const machine_config &mconfig, device_type type, const char *tag) : + driver_device(mconfig, type, tag), + m_tileram(*this, "tileram_%u", 1U), + m_tilemap_reg(*this, "tilemap_reg"), + m_audiobank(*this, "audiobank"), + m_maincpu(*this, "maincpu"), + m_audiocpu(*this, "audiocpu"), + m_msm(*this, "msm"), + m_gfxdecode(*this, "gfxdecode"), + m_soundlatch(*this, "soundlatch") + { } + + void ashnojoe(machine_config &config); + +protected: + virtual void machine_start() override; + virtual void machine_reset() override; + virtual void video_start() override; + +private: + // memory pointers + required_shared_ptr_array m_tileram; + required_shared_ptr m_tilemap_reg; + required_memory_bank m_audiobank; + + // video-related + tilemap_t *m_tilemap[7]{}; + + // sound-related + u8 m_adpcm_byte = 0; + u8 m_msm5205_vclk_toggle = 0; + + // devices + required_device m_maincpu; + required_device m_audiocpu; + required_device m_msm; + required_device m_gfxdecode; + required_device m_soundlatch; + + u16 fake_4a00a_r(); + void adpcm_w(u8 data); + u8 sound_latch_status_r(); + template void tileram_8x8_w(offs_t offset, u16 data); + template void tileram_16x16_w(offs_t offset, u16 data); + void tilemaps_xscroll_w(offs_t offset, u16 data); + void tilemaps_yscroll_w(offs_t offset, u16 data); + void tilemap_regs_w(offs_t offset, u16 data, u16 mem_mask); + void ym2203_write_a(u8 data); + void ym2203_write_b(u8 data); + TILE_GET_INFO_MEMBER(get_tile_info_highest); + TILE_GET_INFO_MEMBER(get_tile_info_midlow); + TILE_GET_INFO_MEMBER(get_tile_info_high); + TILE_GET_INFO_MEMBER(get_tile_info_low); + TILE_GET_INFO_MEMBER(get_tile_info_midhigh); + TILE_GET_INFO_MEMBER(get_tile_info_lowest); + u32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); + DECLARE_WRITE_LINE_MEMBER(vclk_cb); + void main_map(address_map &map); + void sound_map(address_map &map); + void sound_portmap(address_map &map); +}; + + +// video + +TILE_GET_INFO_MEMBER(ashnojoe_state::get_tile_info_highest) +{ + const int code = m_tileram[0][tile_index]; + + tileinfo.set(2, + code & 0xfff, + ((code >> 12) & 0x0f), + 0); +} + +TILE_GET_INFO_MEMBER(ashnojoe_state::get_tile_info_midlow) +{ + const int code = m_tileram[1][tile_index * 2]; + const int attr = m_tileram[1][tile_index * 2 + 1]; + + tileinfo.set(4, + (code & 0x7fff), + ((attr >> 8) & 0x1f) + 0x40, + 0); +} + +TILE_GET_INFO_MEMBER(ashnojoe_state::get_tile_info_high) +{ + const int code = m_tileram[2][tile_index]; + + tileinfo.set(0, + code & 0xfff, + ((code >> 12) & 0x0f) + 0x10, + 0); +} +TILE_GET_INFO_MEMBER(ashnojoe_state::get_tile_info_low) +{ + const int code = m_tileram[3][tile_index]; + + tileinfo.set(1, + code & 0xfff, + ((code >> 12) & 0x0f) + 0x60, + 0); +} + +TILE_GET_INFO_MEMBER(ashnojoe_state::get_tile_info_midhigh) +{ + const int code = m_tileram[4][tile_index * 2]; + const int attr = m_tileram[4][tile_index * 2 + 1]; + + tileinfo.set(4, + (code & 0x7fff), + ((attr >> 8) & 0x1f) + 0x20, + 0); +} + +TILE_GET_INFO_MEMBER(ashnojoe_state::get_tile_info_lowest) +{ + const int buffer = (m_tilemap_reg[0] & 0x02) >> 1; + int const code = m_tileram[5 + buffer][tile_index * 2]; + int const attr = m_tileram[5 + buffer][tile_index * 2 + 1]; + + tileinfo.set(3, + (code & 0x1fff), + ((attr >> 8) & 0x1f) + 0x70, + 0); +} + + +void ashnojoe_state::tilemaps_xscroll_w(offs_t offset, u16 data) +{ + switch (offset) + { + case 0: + m_tilemap[2]->set_scrollx(0, data); + break; + case 1: + m_tilemap[4]->set_scrollx(0, data); + break; + case 2: + m_tilemap[1]->set_scrollx(0, data); + break; + case 3: + m_tilemap[3]->set_scrollx(0, data); + break; + case 4: + m_tilemap[5]->set_scrollx(0, data); + break; + } +} + +void ashnojoe_state::tilemaps_yscroll_w(offs_t offset, u16 data) +{ + switch (offset) + { + case 0: + m_tilemap[2]->set_scrolly(0, data); + break; + case 1: + m_tilemap[4]->set_scrolly(0, data); + break; + case 2: + m_tilemap[1]->set_scrolly(0, data); + break; + case 3: + m_tilemap[3]->set_scrolly(0, data); + break; + case 4: + m_tilemap[5]->set_scrolly(0, data); + break; + } +} + +void ashnojoe_state::tilemap_regs_w(offs_t offset, u16 data, u16 mem_mask) +{ + const u16 old = m_tilemap_reg[offset]; + data = COMBINE_DATA(&m_tilemap_reg[offset]); + if (old != data) + { + if (offset == 0) + { + if ((old ^ data) & 0x02) + m_tilemap[5]->mark_all_dirty(); + } + } +} + +void ashnojoe_state::video_start() +{ + m_tilemap[0] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(ashnojoe_state::get_tile_info_highest)), TILEMAP_SCAN_ROWS, 8, 8, 64, 32); + m_tilemap[1] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(ashnojoe_state::get_tile_info_midlow)), TILEMAP_SCAN_ROWS, 16, 16, 32, 32); + m_tilemap[2] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(ashnojoe_state::get_tile_info_high)), TILEMAP_SCAN_ROWS, 8, 8, 64, 64); + m_tilemap[3] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(ashnojoe_state::get_tile_info_low)), TILEMAP_SCAN_ROWS, 8, 8, 64, 64); + m_tilemap[4] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(ashnojoe_state::get_tile_info_midhigh)), TILEMAP_SCAN_ROWS, 16, 16, 32, 32); + m_tilemap[5] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(ashnojoe_state::get_tile_info_lowest)), TILEMAP_SCAN_ROWS, 16, 16, 32, 32); + + m_tilemap[0]->set_transparent_pen(15); + m_tilemap[1]->set_transparent_pen(15); + m_tilemap[2]->set_transparent_pen(15); + m_tilemap[3]->set_transparent_pen(15); + m_tilemap[4]->set_transparent_pen(15); +} + +u32 ashnojoe_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) +{ + //m_tilemap_reg[0] & 0x10 // ?? on coin insertion + + flip_screen_set(m_tilemap_reg[0] & 1); + + m_tilemap[5]->draw(screen, bitmap, cliprect, 0, 0); + m_tilemap[3]->draw(screen, bitmap, cliprect, 0, 0); + m_tilemap[1]->draw(screen, bitmap, cliprect, 0, 0); + m_tilemap[4]->draw(screen, bitmap, cliprect, 0, 0); + m_tilemap[2]->draw(screen, bitmap, cliprect, 0, 0); + m_tilemap[0]->draw(screen, bitmap, cliprect, 0, 0); + + return 0; +} + + +// machine u16 ashnojoe_state::fake_4a00a_r() { @@ -108,21 +340,21 @@ void ashnojoe_state::tileram_16x16_w(offs_t offset, u16 data) m_tilemap[(Which < 5) ? Which : 5]->mark_tile_dirty(offset / 2); } -void ashnojoe_state::ashnojoe_map(address_map &map) +void ashnojoe_state::main_map(address_map &map) { map(0x000000, 0x01ffff).rom(); - map(0x040000, 0x041fff).ram().w(FUNC(ashnojoe_state::tileram_8x8_w<2>)).share("tileram_3"); - map(0x042000, 0x043fff).ram().w(FUNC(ashnojoe_state::tileram_8x8_w<3>)).share("tileram_4"); - map(0x044000, 0x044fff).ram().w(FUNC(ashnojoe_state::tileram_16x16_w<4>)).share("tileram_5"); - map(0x045000, 0x045fff).ram().w(FUNC(ashnojoe_state::tileram_16x16_w<1>)).share("tileram_2"); - map(0x046000, 0x046fff).ram().w(FUNC(ashnojoe_state::tileram_16x16_w<5>)).share("tileram_6"); - map(0x047000, 0x047fff).ram().w(FUNC(ashnojoe_state::tileram_16x16_w<6>)).share("tileram_7"); - map(0x048000, 0x048fff).ram().w(FUNC(ashnojoe_state::tileram_8x8_w<0>)).share("tileram_1"); + map(0x040000, 0x041fff).ram().w(FUNC(ashnojoe_state::tileram_8x8_w<2>)).share(m_tileram[2]); + map(0x042000, 0x043fff).ram().w(FUNC(ashnojoe_state::tileram_8x8_w<3>)).share(m_tileram[3]); + map(0x044000, 0x044fff).ram().w(FUNC(ashnojoe_state::tileram_16x16_w<4>)).share(m_tileram[4]); + map(0x045000, 0x045fff).ram().w(FUNC(ashnojoe_state::tileram_16x16_w<1>)).share(m_tileram[1]); + map(0x046000, 0x046fff).ram().w(FUNC(ashnojoe_state::tileram_16x16_w<5>)).share(m_tileram[5]); + map(0x047000, 0x047fff).ram().w(FUNC(ashnojoe_state::tileram_16x16_w<6>)).share(m_tileram[6]); + map(0x048000, 0x048fff).ram().w(FUNC(ashnojoe_state::tileram_8x8_w<0>)).share(m_tileram[0]); map(0x049000, 0x049fff).ram().w("palette", FUNC(palette_device::write16)).share("palette"); map(0x04a000, 0x04a001).portr("P1"); map(0x04a002, 0x04a003).portr("P2"); map(0x04a004, 0x04a005).portr("DSW"); - map(0x04a006, 0x04a007).w(FUNC(ashnojoe_state::tilemap_regs_w)).share("tilemap_reg"); + map(0x04a006, 0x04a007).w(FUNC(ashnojoe_state::tilemap_regs_w)).share(m_tilemap_reg); map(0x04a009, 0x04a009).w(m_soundlatch, FUNC(generic_latch_8_device::write)); map(0x04a00a, 0x04a00b).r(FUNC(ashnojoe_state::fake_4a00a_r)); // ?? map(0x04a010, 0x04a019).w(FUNC(ashnojoe_state::tilemaps_xscroll_w)); @@ -146,7 +378,7 @@ void ashnojoe_state::sound_map(address_map &map) { map(0x0000, 0x5fff).rom(); map(0x6000, 0x7fff).ram(); - map(0x8000, 0xffff).bankr("audiobank"); + map(0x8000, 0xffff).bankr(m_audiobank); } void ashnojoe_state::sound_portmap(address_map &map) @@ -257,7 +489,7 @@ GFXDECODE_END void ashnojoe_state::ym2203_write_a(u8 data) { - /* This gets called at 8910 startup with 0xff before the 5205 exists, causing a crash */ + // This gets called at 8910 startup with 0xff before the 5205 exists, causing a crash if (data == 0xff) return; @@ -269,7 +501,7 @@ void ashnojoe_state::ym2203_write_b(u8 data) m_audiobank->set_entry(data & 0x0f); } -WRITE_LINE_MEMBER(ashnojoe_state::ashnojoe_vclk_cb) +WRITE_LINE_MEMBER(ashnojoe_state::vclk_cb) { if (m_msm5205_vclk_toggle == 0) { @@ -286,6 +518,10 @@ WRITE_LINE_MEMBER(ashnojoe_state::ashnojoe_vclk_cb) void ashnojoe_state::machine_start() { + u8 *ROM = memregion("audiocpu")->base(); + m_audiobank->configure_entries(0, 16, &ROM[0x10000], 0x8000); + m_audiobank->set_entry(0); + save_item(NAME(m_adpcm_byte)); save_item(NAME(m_msm5205_vclk_toggle)); } @@ -299,16 +535,16 @@ void ashnojoe_state::machine_reset() void ashnojoe_state::ashnojoe(machine_config &config) { - /* basic machine hardware */ - M68000(config, m_maincpu, 8000000); - m_maincpu->set_addrmap(AS_PROGRAM, &ashnojoe_state::ashnojoe_map); + // basic machine hardware + M68000(config, m_maincpu, 8_MHz_XTAL); + m_maincpu->set_addrmap(AS_PROGRAM, &ashnojoe_state::main_map); m_maincpu->set_vblank_int("screen", FUNC(ashnojoe_state::irq1_line_hold)); - Z80(config, m_audiocpu, 4000000); + Z80(config, m_audiocpu, 8_MHz_XTAL / 2); m_audiocpu->set_addrmap(AS_PROGRAM, &ashnojoe_state::sound_map); m_audiocpu->set_addrmap(AS_IO, &ashnojoe_state::sound_portmap); - /* 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)); @@ -318,32 +554,32 @@ void ashnojoe_state::ashnojoe(machine_config &config) screen.set_palette("palette"); GFXDECODE(config, m_gfxdecode, "palette", gfx_ashnojoe); - PALETTE(config, "palette").set_format(palette_device::xRGB_555, 0x1000/2); + PALETTE(config, "palette").set_format(palette_device::xRGB_555, 0x1000 / 2); - /* sound hardware */ + // sound hardware SPEAKER(config, "mono").front_center(); GENERIC_LATCH_8(config, m_soundlatch); - ym2203_device &ymsnd(YM2203(config, "ymsnd", 4000000)); + ym2203_device &ymsnd(YM2203(config, "ymsnd", 8_MHz_XTAL / 2)); ymsnd.irq_handler().set_inputline(m_audiocpu, 0); ymsnd.port_a_write_callback().set(FUNC(ashnojoe_state::ym2203_write_a)); ymsnd.port_b_write_callback().set(FUNC(ashnojoe_state::ym2203_write_b)); ymsnd.add_route(ALL_OUTPUTS, "mono", 0.1); - MSM5205(config, m_msm, 384000); - m_msm->vck_legacy_callback().set(FUNC(ashnojoe_state::ashnojoe_vclk_cb)); + MSM5205(config, m_msm, 384'000); + m_msm->vck_legacy_callback().set(FUNC(ashnojoe_state::vclk_cb)); m_msm->set_prescaler_selector(msm5205_device::S48_4B); m_msm->add_route(ALL_OUTPUTS, "mono", 1.0); } ROM_START( scessjoe ) - ROM_REGION( 0xc0000, "maincpu", 0 ) /* 68000 code */ + ROM_REGION( 0xc0000, "maincpu", 0 ) // 68000 ROM_LOAD16_BYTE( "5.4q", 0x00000, 0x10000, CRC(c805f9e7) SHA1(e1e85701bde496b1fd64211b94bfb0def597ae51) ) ROM_LOAD16_BYTE( "6.4s", 0x00001, 0x10000, CRC(eda7a537) SHA1(3bb19fbdfb6c8af4e2078958fa445ac1f4434d0d) ) ROM_LOAD16_WORD_SWAP( "sj201-nw.6m", 0x80000, 0x40000, CRC(5a64ca42) SHA1(660b8bca21ef3c2230adce7cb7e7d1f018714f23) ) - ROM_REGION( 0x90000, "audiocpu", 0 ) /* 32k for Z80 code */ + ROM_REGION( 0x90000, "audiocpu", 0 ) // Z80 ROM_LOAD( "9.8q", 0x00000, 0x08000, CRC(8767e212) SHA1(13bf927febedff9d7d164fbf0da7fb3a588c2a94) ) ROM_LOAD( "sj401-nw.10r", 0x10000, 0x80000, CRC(25dfab59) SHA1(7d50159204ba05323a2442778f35192e66117dda) ) @@ -373,12 +609,12 @@ ROM_START( scessjoe ) ROM_END ROM_START( ashnojoe ) - ROM_REGION( 0xc0000, "maincpu", 0 ) /* 68000 code */ + ROM_REGION( 0xc0000, "maincpu", 0 ) // 68000 ROM_LOAD16_BYTE( "5.bin", 0x00000, 0x10000, CRC(c61e1569) SHA1(422c18f5810539b5a9e3a9bd4e3b4d70bde8d1d5) ) ROM_LOAD16_BYTE( "6.bin", 0x00001, 0x10000, CRC(c0a16338) SHA1(fb127b9d38f2c9807b6e23ff71935fc8a22a2e8f) ) ROM_LOAD16_WORD_SWAP( "sj201-nw.6m", 0x80000, 0x40000, CRC(5a64ca42) SHA1(660b8bca21ef3c2230adce7cb7e7d1f018714f23) ) - ROM_REGION( 0x90000, "audiocpu", 0 ) /* 32k for Z80 code */ + ROM_REGION( 0x90000, "audiocpu", 0 ) // Z80 ROM_LOAD( "9.8q", 0x00000, 0x08000, CRC(8767e212) SHA1(13bf927febedff9d7d164fbf0da7fb3a588c2a94) ) ROM_LOAD( "sj401-nw.10r", 0x10000, 0x80000, CRC(25dfab59) SHA1(7d50159204ba05323a2442778f35192e66117dda) ) @@ -407,12 +643,8 @@ ROM_START( ashnojoe ) ROM_LOAD16_WORD_SWAP( "sj409-nw.7j", 0x280000, 0x80000, CRC(d8764213) SHA1(89eadefb956863216c8e3d0380394aba35e8c856) ) ROM_END -void ashnojoe_state::init_ashnojoe() -{ - u8 *ROM = memregion("audiocpu")->base(); - m_audiobank->configure_entries(0, 16, &ROM[0x10000], 0x8000); - m_audiobank->set_entry(0); -} +} // anonymous namespace + -GAME( 1990, scessjoe, 0, ashnojoe, ashnojoe, ashnojoe_state, init_ashnojoe, ROT0, "Taito Corporation / Wave", "Success Joe (World)", MACHINE_SUPPORTS_SAVE ) -GAME( 1990, ashnojoe, scessjoe, ashnojoe, ashnojoe, ashnojoe_state, init_ashnojoe, ROT0, "Taito Corporation / Wave", "Ashita no Joe (Japan)", MACHINE_SUPPORTS_SAVE ) +GAME( 1990, scessjoe, 0, ashnojoe, ashnojoe, ashnojoe_state, empty_init, ROT0, "Taito Corporation / Wave", "Success Joe (World)", MACHINE_SUPPORTS_SAVE ) +GAME( 1990, ashnojoe, scessjoe, ashnojoe, ashnojoe, ashnojoe_state, empty_init, ROT0, "Taito Corporation / Wave", "Ashita no Joe (Japan)", MACHINE_SUPPORTS_SAVE ) diff --git a/src/mame/taito/ashnojoe.h b/src/mame/taito/ashnojoe.h deleted file mode 100644 index a01be8bbf09..00000000000 --- a/src/mame/taito/ashnojoe.h +++ /dev/null @@ -1,85 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:David Haywood - -/************************************************************************* - - Success Joe / Ashita no Joe - -*************************************************************************/ -#ifndef MAME_INCLUDES_ASHNOJOE_H -#define MAME_INCLUDES_ASHNOJOE_H - -#pragma once - -#include "machine/gen_latch.h" -#include "sound/msm5205.h" -#include "tilemap.h" - -class ashnojoe_state : public driver_device -{ -public: - ashnojoe_state(const machine_config &mconfig, device_type type, const char *tag) : - driver_device(mconfig, type, tag), - m_tileram(*this, "tileram_%u", 1U), - m_tilemap_reg(*this, "tilemap_reg"), - m_audiobank(*this, "audiobank"), - m_maincpu(*this, "maincpu"), - m_audiocpu(*this, "audiocpu"), - m_msm(*this, "msm"), - m_gfxdecode(*this, "gfxdecode"), - m_soundlatch(*this, "soundlatch") - { } - - void init_ashnojoe(); - - void ashnojoe(machine_config &config); - -protected: - virtual void machine_start() override; - virtual void machine_reset() override; - virtual void video_start() override; - -private: - /* memory pointers */ - required_shared_ptr_array m_tileram; - required_shared_ptr m_tilemap_reg; - required_memory_bank m_audiobank; - - /* video-related */ - tilemap_t *m_tilemap[7]{}; - - /* sound-related */ - u8 m_adpcm_byte = 0; - int m_msm5205_vclk_toggle = 0; - - /* devices */ - required_device m_maincpu; - required_device m_audiocpu; - required_device m_msm; - required_device m_gfxdecode; - required_device m_soundlatch; - - u16 fake_4a00a_r(); - void adpcm_w(u8 data); - u8 sound_latch_status_r(); - template void tileram_8x8_w(offs_t offset, u16 data); - template void tileram_16x16_w(offs_t offset, u16 data); - void tilemaps_xscroll_w(offs_t offset, u16 data); - void tilemaps_yscroll_w(offs_t offset, u16 data); - void tilemap_regs_w(offs_t offset, u16 data, u16 mem_mask); - void ym2203_write_a(u8 data); - void ym2203_write_b(u8 data); - TILE_GET_INFO_MEMBER(get_tile_info_highest); - TILE_GET_INFO_MEMBER(get_tile_info_midlow); - TILE_GET_INFO_MEMBER(get_tile_info_high); - TILE_GET_INFO_MEMBER(get_tile_info_low); - TILE_GET_INFO_MEMBER(get_tile_info_midhigh); - TILE_GET_INFO_MEMBER(get_tile_info_lowest); - u32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - DECLARE_WRITE_LINE_MEMBER(ashnojoe_vclk_cb); - void ashnojoe_map(address_map &map); - void sound_map(address_map &map); - void sound_portmap(address_map &map); -}; - -#endif // MAME_INCLUDES_ASHNOJOE_H diff --git a/src/mame/taito/ashnojoe_v.cpp b/src/mame/taito/ashnojoe_v.cpp deleted file mode 100644 index f59359e7919..00000000000 --- a/src/mame/taito/ashnojoe_v.cpp +++ /dev/null @@ -1,167 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:David Haywood -/******************************************************************** - - Ashita no Joe (Success Joe) [Wave] - video hardware emulation - -*********************************************************************/ - -#include "emu.h" -#include "ashnojoe.h" - - -TILE_GET_INFO_MEMBER(ashnojoe_state::get_tile_info_highest) -{ - int code = m_tileram[0][tile_index]; - - tileinfo.set(2, - code & 0xfff, - ((code >> 12) & 0x0f), - 0); -} - -TILE_GET_INFO_MEMBER(ashnojoe_state::get_tile_info_midlow) -{ - int code = m_tileram[1][tile_index * 2]; - int attr = m_tileram[1][tile_index * 2 + 1]; - - tileinfo.set(4, - (code & 0x7fff), - ((attr >> 8) & 0x1f) + 0x40, - 0); -} - -TILE_GET_INFO_MEMBER(ashnojoe_state::get_tile_info_high) -{ - int code = m_tileram[2][tile_index]; - - tileinfo.set(0, - code & 0xfff, - ((code >> 12) & 0x0f) + 0x10, - 0); -} - -TILE_GET_INFO_MEMBER(ashnojoe_state::get_tile_info_low) -{ - int code = m_tileram[3][tile_index]; - - tileinfo.set(1, - code & 0xfff, - ((code >> 12) & 0x0f) + 0x60, - 0); -} - -TILE_GET_INFO_MEMBER(ashnojoe_state::get_tile_info_midhigh) -{ - int code = m_tileram[4][tile_index * 2]; - int attr = m_tileram[4][tile_index * 2 + 1]; - - tileinfo.set(4, - (code & 0x7fff), - ((attr >> 8) & 0x1f) + 0x20, - 0); -} - -TILE_GET_INFO_MEMBER(ashnojoe_state::get_tile_info_lowest) -{ - const int buffer = (m_tilemap_reg[0] & 0x02) >> 1; - int code = m_tileram[5 + buffer][tile_index * 2]; - int attr = m_tileram[5 + buffer][tile_index * 2 + 1]; - - tileinfo.set(3, - (code & 0x1fff), - ((attr >> 8) & 0x1f) + 0x70, - 0); -} - - -void ashnojoe_state::tilemaps_xscroll_w(offs_t offset, u16 data) -{ - switch (offset) - { - case 0: - m_tilemap[2]->set_scrollx(0, data); - break; - case 1: - m_tilemap[4]->set_scrollx(0, data); - break; - case 2: - m_tilemap[1]->set_scrollx(0, data); - break; - case 3: - m_tilemap[3]->set_scrollx(0, data); - break; - case 4: - m_tilemap[5]->set_scrollx(0, data); - break; - } -} - -void ashnojoe_state::tilemaps_yscroll_w(offs_t offset, u16 data) -{ - switch (offset) - { - case 0: - m_tilemap[2]->set_scrolly(0, data); - break; - case 1: - m_tilemap[4]->set_scrolly(0, data); - break; - case 2: - m_tilemap[1]->set_scrolly(0, data); - break; - case 3: - m_tilemap[3]->set_scrolly(0, data); - break; - case 4: - m_tilemap[5]->set_scrolly(0, data); - break; - } -} - -void ashnojoe_state::tilemap_regs_w(offs_t offset, u16 data, u16 mem_mask) -{ - const u16 old = m_tilemap_reg[offset]; - data = COMBINE_DATA(&m_tilemap_reg[offset]); - if (old != data) - { - if (offset == 0) - { - if ((old ^ data) & 0x02) - m_tilemap[5]->mark_all_dirty(); - } - } -} - -void ashnojoe_state::video_start() -{ - m_tilemap[0] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(ashnojoe_state::get_tile_info_highest)), TILEMAP_SCAN_ROWS, 8, 8, 64, 32); - m_tilemap[1] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(ashnojoe_state::get_tile_info_midlow)), TILEMAP_SCAN_ROWS, 16, 16, 32, 32); - m_tilemap[2] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(ashnojoe_state::get_tile_info_high)), TILEMAP_SCAN_ROWS, 8, 8, 64, 64); - m_tilemap[3] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(ashnojoe_state::get_tile_info_low)), TILEMAP_SCAN_ROWS, 8, 8, 64, 64); - m_tilemap[4] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(ashnojoe_state::get_tile_info_midhigh)), TILEMAP_SCAN_ROWS, 16, 16, 32, 32); - m_tilemap[5] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(ashnojoe_state::get_tile_info_lowest)), TILEMAP_SCAN_ROWS, 16, 16, 32, 32); - - m_tilemap[0]->set_transparent_pen(15); - m_tilemap[1]->set_transparent_pen(15); - m_tilemap[2]->set_transparent_pen(15); - m_tilemap[3]->set_transparent_pen(15); - m_tilemap[4]->set_transparent_pen(15); -} - -u32 ashnojoe_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - //m_tilemap_reg[0] & 0x10 // ?? on coin insertion - - flip_screen_set(m_tilemap_reg[0] & 1); - - m_tilemap[5]->draw(screen, bitmap, cliprect, 0, 0); - m_tilemap[3]->draw(screen, bitmap, cliprect, 0, 0); - m_tilemap[1]->draw(screen, bitmap, cliprect, 0, 0); - m_tilemap[4]->draw(screen, bitmap, cliprect, 0, 0); - m_tilemap[2]->draw(screen, bitmap, cliprect, 0, 0); - m_tilemap[0]->draw(screen, bitmap, cliprect, 0, 0); - - return 0; -} diff --git a/src/mame/taito/bigevglf.cpp b/src/mame/taito/bigevglf.cpp index 4f76d679fcf..5995e25a24d 100644 --- a/src/mame/taito/bigevglf.cpp +++ b/src/mame/taito/bigevglf.cpp @@ -1,5 +1,6 @@ // license:GPL-2.0+ -// copyright-holders:Jarek Burczynski, Tomasz Slanina +// copyright-holders: Jarek Burczynski, Tomasz Slanina + /*************************************************************************** Big Event Golf (c) Taito 1986 @@ -58,24 +59,198 @@ J1100072A ***************************************************************************/ #include "emu.h" -#include "bigevglf.h" + +#include "taito68705.h" #include "cpu/m6805/m6805.h" #include "cpu/z80/z80.h" +#include "machine/gen_latch.h" #include "machine/input_merger.h" #include "sound/ay8910.h" #include "sound/dac.h" +#include "sound/msm5232.h" + +#include "emupal.h" #include "speaker.h" +#include "screen.h" -void bigevglf_state::beg_banking_w(uint8_t data) +namespace { + +class bigevglf_state : public driver_device { - m_beg_bank = data; +public: + bigevglf_state(const machine_config &mconfig, device_type type, const char *tag) : + driver_device(mconfig, type, tag), + m_paletteram(*this, "paletteram"), + m_spriteram(*this, "spriteram%u", 1U), + m_vidram(*this, "vidram", 0x100 * 0x100 * 4, ENDIANNESS_LITTLE), + m_mainbank(*this, "mainbank"), + m_maincpu(*this, "maincpu"), + m_msm(*this, "msm"), + m_soundlatch(*this, "soundlatch%u", 1), + m_gfxdecode(*this, "gfxdecode"), + m_screen(*this, "screen"), + m_palette(*this, "palette"), + m_audiocpu(*this, "audiocpu"), + m_bmcu(*this, "bmcu"), + m_trackx(*this, { "P1X", "P2X" }), + m_tracky(*this, { "P1Y", "P2Y" }), + m_port04(*this, "PORT04") { } + + void bigevglf(machine_config &config); + +protected: + virtual void machine_start() override; + virtual void machine_reset() override; + virtual void video_start() override; + +private: + // memory pointers + required_shared_ptr m_paletteram; + required_shared_ptr_array m_spriteram; + memory_share_creator m_vidram; + required_memory_bank m_mainbank; + + // devices + required_device m_maincpu; + required_device m_msm; + required_device_array m_soundlatch; + required_device m_gfxdecode; + required_device m_screen; + required_device m_palette; + required_device m_audiocpu; + required_device m_bmcu; + + // I/O + required_ioport_array<2> m_trackx; + required_ioport_array<2> m_tracky; + required_ioport m_port04; + + // video-related + bitmap_ind16 m_tmp_bitmap[4]{}; + uint16_t m_vidram_bank = 0U; + uint8_t m_plane_selected = 0U; + uint8_t m_plane_visible = 0U; + + // MCU related + uint8_t m_mcu_coin_bit5 = 0; + + // misc + uint8_t m_bank = 0U; + uint8_t m_13_ls74[2]{}; + uint8_t m_port_select = 0U; // for muxed controls + + void banking_w(uint8_t data); + uint8_t soundstate_r(); + void _13_a_clr_w(uint8_t data); + void _13_b_clr_w(uint8_t data); + void _13_a_set_w(uint8_t data); + void _13_b_set_w(uint8_t data); + uint8_t status_r(); + uint8_t trackball_x_r(); + uint8_t trackball_y_r(); + void port08_w(uint8_t data); + uint8_t sub_cpu_mcu_coin_port_r(); + void palette_w(offs_t offset, uint8_t data); + void gfxcontrol_w(uint8_t data); + void vidram_addr_w(uint8_t data); + void vidram_w(offs_t offset, uint8_t data); + uint8_t vidram_r(offs_t offset); + uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); + TIMER_CALLBACK_MEMBER(deferred_ls74_w); + void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect); + + void main_portmap(address_map &map); + void sub_portmap(address_map &map); + void main_map(address_map &map); + void sound_map(address_map &map); + void sub_map(address_map &map); +}; + +// video + +void bigevglf_state::palette_w(offs_t offset, uint8_t data) +{ + m_paletteram[offset] = data; + int const color = m_paletteram[offset & 0x3ff] | (m_paletteram[0x400 + (offset & 0x3ff)] << 8); + m_palette->set_pen_color(offset & 0x3ff, pal4bit(color >> 4), pal4bit(color >> 0), pal4bit(color >> 8)); +} + +void bigevglf_state::gfxcontrol_w(uint8_t data) +{ +/* bits used: 0,1,2,3 + 0 and 2 select plane, + 1 and 3 select visible plane, +*/ + m_plane_selected = ((data & 4) >> 1) | (data & 1); + m_plane_visible = ((data & 8) >> 2) | ((data & 2) >> 1); +} + +void bigevglf_state::vidram_addr_w(uint8_t data) +{ + m_vidram_bank = (data & 0xff) * 0x100; +} + +void bigevglf_state::vidram_w(offs_t offset, uint8_t data) +{ + uint32_t const o = m_vidram_bank + offset; + m_vidram[o + 0x10000 * m_plane_selected] = data; + uint32_t y = o >> 8; + uint32_t x = (o & 255); + m_tmp_bitmap[m_plane_selected].pix(y, x) = data; +} + +uint8_t bigevglf_state::vidram_r(offs_t offset) +{ + return m_vidram[0x10000 * m_plane_selected + m_vidram_bank + offset]; +} + +void bigevglf_state::video_start() +{ + m_screen->register_screen_bitmap(m_tmp_bitmap[0]); + m_screen->register_screen_bitmap(m_tmp_bitmap[1]); + m_screen->register_screen_bitmap(m_tmp_bitmap[2]); + m_screen->register_screen_bitmap(m_tmp_bitmap[3]); + save_item(NAME(m_tmp_bitmap[0])); + save_item(NAME(m_tmp_bitmap[1])); + save_item(NAME(m_tmp_bitmap[2])); + save_item(NAME(m_tmp_bitmap[3])); +} + +void bigevglf_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect) +{ + for (int i = 0xc0 - 4; i >= 0; i -= 4) + { + int const code = m_spriteram[1][i + 1]; + int const sx = m_spriteram[1][i + 3]; + int const sy = 200 - m_spriteram[1][i]; + for (int j = 0; j < 16; j++) + m_gfxdecode->gfx(0)->transpen(bitmap, cliprect, + m_spriteram[0][(code << 4) + j] + ((m_spriteram[0][0x400 + (code << 4) + j] & 0xf) << 8), + m_spriteram[1][i + 2] & 0xf, + 0,0, + sx + ((j & 1) << 3), sy + ((j >> 1) << 3), 0); + } +} + +uint32_t bigevglf_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) +{ + copybitmap(bitmap, m_tmp_bitmap[m_plane_visible], 0, 0, 0, 0, cliprect); + draw_sprites(bitmap, cliprect); + return 0; +} + + +// machine + +void bigevglf_state::banking_w(uint8_t data) +{ /* d0-d3 connect to A11-A14 of the ROMs (via ls273 latch) d4-d7 select one of ROMs (via ls273(above) and then ls154) */ - membank("bank1")->set_entry(m_beg_bank & 0xff); /* empty sockets for IC37-IC44 ROMS */ + m_mainbank->set_entry(data); // empty sockets for IC37-IC44 ROMS } uint8_t bigevglf_state::soundstate_r() @@ -87,33 +262,33 @@ uint8_t bigevglf_state::soundstate_r() TIMER_CALLBACK_MEMBER(bigevglf_state::deferred_ls74_w) { - int offs = (param >> 8) & 255; - int data = param & 255; - m_beg13_ls74[offs] = data; + int const offs = (param >> 8) & 255; + int const data = param & 255; + m_13_ls74[offs] = data; } -/* do this on a timer to let the CPUs synchronize */ -void bigevglf_state::beg13_a_clr_w(uint8_t data) +// do this on a timer to let the CPUs synchronize +void bigevglf_state::_13_a_clr_w(uint8_t data) { machine().scheduler().synchronize(timer_expired_delegate(FUNC(bigevglf_state::deferred_ls74_w),this), (0 << 8) | 0); } -void bigevglf_state::beg13_b_clr_w(uint8_t data) +void bigevglf_state::_13_b_clr_w(uint8_t data) { machine().scheduler().synchronize(timer_expired_delegate(FUNC(bigevglf_state::deferred_ls74_w),this), (1 << 8) | 0); } -void bigevglf_state::beg13_a_set_w(uint8_t data) +void bigevglf_state::_13_a_set_w(uint8_t data) { machine().scheduler().synchronize(timer_expired_delegate(FUNC(bigevglf_state::deferred_ls74_w),this), (0 << 8) | 1); } -void bigevglf_state::beg13_b_set_w(uint8_t data) +void bigevglf_state::_13_b_set_w(uint8_t data) { machine().scheduler().synchronize(timer_expired_delegate(FUNC(bigevglf_state::deferred_ls74_w),this), (1 << 8) | 1); } -uint8_t bigevglf_state::beg_status_r() +uint8_t bigevglf_state::status_r() { /* d0 = Q of 74ls74 IC13(partA) d1 = Q of 74ls74 IC13(partB) @@ -124,34 +299,30 @@ uint8_t bigevglf_state::beg_status_r() d6 = d7 = 10MHz/2 */ - /* set a timer to force synchronization after the read */ + // set a timer to force synchronization after the read machine().scheduler().synchronize(); - return (m_beg13_ls74[0] << 0) | (m_beg13_ls74[1] << 1); + return (m_13_ls74[0] << 0) | (m_13_ls74[1] << 1); } -uint8_t bigevglf_state::beg_trackball_x_r() +uint8_t bigevglf_state::trackball_x_r() { - static const char *const portx_name[2] = { "P1X", "P2X" }; - - return ioport(portx_name[m_port_select])->read(); + return m_trackx[m_port_select]->read(); } -uint8_t bigevglf_state::beg_trackball_y_r() +uint8_t bigevglf_state::trackball_y_r() { - static const char *const porty_name[2] = { "P1Y", "P2Y" }; - - return ioport(porty_name[m_port_select])->read(); + return m_tracky[m_port_select]->read(); } -void bigevglf_state::beg_port08_w(uint8_t data) +void bigevglf_state::port08_w(uint8_t data) { m_port_select = (data & 0x04) >> 2; } static INPUT_PORTS_START( bigevglf ) - PORT_START("PORT00") /* port 00 on sub cpu */ + PORT_START("PORT00") // on sub CPU PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_COCKTAIL @@ -161,11 +332,11 @@ static INPUT_PORTS_START( bigevglf ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_TILT ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SERVICE1 ) - PORT_START("PORT04") /* port 04 on sub cpu - bit 0 and bit 1 are coin inputs */ + PORT_START("PORT04") // on sub CPU - bit 0 and bit 1 are coin inputs PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_COIN1 ) PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_COIN2 ) - PORT_START("DSW1") /* port 05 on sub cpu */ + PORT_START("DSW1") // port 05 on sub CPU PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) ) PORT_DIPLOCATION("SW1:1") PORT_DIPSETTING( 0x00, DEF_STR( Upright ) ) PORT_DIPSETTING( 0x01, DEF_STR( Cocktail ) ) @@ -182,7 +353,7 @@ static INPUT_PORTS_START( bigevglf ) PORT_DIPSETTING( 0x00, DEF_STR( 2C_3C ) ) PORT_DIPSETTING( 0xa0, DEF_STR( 1C_2C ) ) - PORT_START("DSW2") /* port 06 on sub cpu */ + PORT_START("DSW2") // port 06 on sub CPU PORT_DIPNAME( 0x03, 0x03, DEF_STR( Difficulty ) ) PORT_DIPLOCATION("SW2:1,2") PORT_DIPSETTING( 0x01, DEF_STR( Easy ) ) PORT_DIPSETTING( 0x03, DEF_STR( Normal ) ) @@ -193,9 +364,9 @@ static INPUT_PORTS_START( bigevglf ) PORT_DIPSETTING( 0x08, "2" ) PORT_DIPSETTING( 0x0c, "3" ) PORT_DIPSETTING( 0x00, "4" ) - PORT_DIPNAME( 0x10, 0x00, DEF_STR( Language ) ) PORT_DIPLOCATION("SW2:5") /* Also changes the copyright on the title screen */ - PORT_DIPSETTING( 0x00, DEF_STR( English ) ) /* (c) 1986 Taito America Corp. */ - PORT_DIPSETTING( 0x10, DEF_STR( Japanese ) ) /* (c) Taito Corporation 1986 */ + PORT_DIPNAME( 0x10, 0x00, DEF_STR( Language ) ) PORT_DIPLOCATION("SW2:5") // Also changes the copyright on the title screen + PORT_DIPSETTING( 0x00, DEF_STR( English ) ) // (c) 1986 Taito America Corp. + PORT_DIPSETTING( 0x10, DEF_STR( Japanese ) ) // (c) Taito Corporation 1986 PORT_DIPNAME( 0xe0, 0xa0, "Full game price (credits)" ) PORT_DIPLOCATION("SW2:6,7,8") PORT_DIPSETTING( 0xe0, "3" ) PORT_DIPSETTING( 0xc0, "4" ) @@ -206,16 +377,16 @@ static INPUT_PORTS_START( bigevglf ) PORT_DIPSETTING( 0x20, "9" ) PORT_DIPSETTING( 0x00, "10" ) - PORT_START("P1X") /* port 02 on sub cpu - muxed port 0 */ + PORT_START("P1X") // port 02 on sub CPU - muxed port 0 PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_X ) PORT_SENSITIVITY(30) PORT_KEYDELTA(10) - PORT_START("P1Y") /* port 03 on sub cpu - muxed port 0 */ + PORT_START("P1Y") // port 03 on sub CPU - muxed port 0 PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_Y ) PORT_SENSITIVITY(30) PORT_KEYDELTA(10) PORT_REVERSE - PORT_START("P2X") /* port 02 on sub cpu - muxed port 1 */ + PORT_START("P2X") // port 02 on sub CPU - muxed port 1 PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_X ) PORT_SENSITIVITY(30) PORT_KEYDELTA(10) PORT_COCKTAIL - PORT_START("P2Y") /* port 03 on sub cpu - muxed port 1 */ + PORT_START("P2Y") // port 03 on sub CPU - muxed port 1 PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_Y ) PORT_SENSITIVITY(30) PORT_KEYDELTA(10) PORT_REVERSE PORT_COCKTAIL INPUT_PORTS_END @@ -223,48 +394,48 @@ static INPUT_PORTS_START( bigevglfj ) PORT_INCLUDE(bigevglf) PORT_MODIFY("DSW2") - PORT_DIPNAME( 0x10, 0x10, DEF_STR( Language ) ) PORT_DIPLOCATION("SW2:5") /* Doesn't change the title screen copyright like the US set */ + PORT_DIPNAME( 0x10, 0x10, DEF_STR( Language ) ) PORT_DIPLOCATION("SW2:5") // Doesn't change the title screen copyright like the US set PORT_DIPSETTING( 0x00, DEF_STR( English ) ) PORT_DIPSETTING( 0x10, DEF_STR( Japanese ) ) INPUT_PORTS_END /*****************************************************************************/ -/* Main CPU */ +// Main CPU void bigevglf_state::main_map(address_map &map) { map(0x0000, 0xbfff).rom(); map(0xc000, 0xcfff).ram(); - map(0xd000, 0xd7ff).bankr("bank1"); - map(0xd800, 0xdbff).ram().share("share1"); /* only half of the RAM is accessible, line a10 of IC73 (6116) is GNDed */ - map(0xe000, 0xe7ff).w(FUNC(bigevglf_state::bigevglf_palette_w)).share("paletteram"); - map(0xe800, 0xefff).writeonly().share("spriteram1"); /* sprite 'templates' */ - map(0xf000, 0xf0ff).rw(FUNC(bigevglf_state::bigevglf_vidram_r), FUNC(bigevglf_state::bigevglf_vidram_w)); /* 41464 (64kB * 8 chips), addressed using ports 1 and 5 */ - map(0xf840, 0xf8ff).ram().share("spriteram2"); /* spriteram (x,y,offset in spriteram1,palette) */ + map(0xd000, 0xd7ff).bankr(m_mainbank); + map(0xd800, 0xdbff).ram().share("main_sub"); // only half of the RAM is accessible, line a10 of IC73 (6116) is GNDed + map(0xe000, 0xe7ff).w(FUNC(bigevglf_state::palette_w)).share(m_paletteram); + map(0xe800, 0xefff).writeonly().share(m_spriteram[0]); // sprite 'templates' + map(0xf000, 0xf0ff).rw(FUNC(bigevglf_state::vidram_r), FUNC(bigevglf_state::vidram_w)); // 41464 (64kB * 8 chips), addressed using ports 1 and 5 + map(0xf840, 0xf8ff).ram().share(m_spriteram[1]); // x, y, offset in m_spriteram[0], palette } -void bigevglf_state::bigevglf_portmap(address_map &map) +void bigevglf_state::main_portmap(address_map &map) { map.global_mask(0xff); - map(0x00, 0x00).nopw(); /* video ram enable ???*/ - map(0x01, 0x01).w(FUNC(bigevglf_state::bigevglf_gfxcontrol_w)); /* plane select */ - map(0x02, 0x02).w(FUNC(bigevglf_state::beg_banking_w)); - map(0x03, 0x03).w(FUNC(bigevglf_state::beg13_a_set_w)); - map(0x04, 0x04).w(FUNC(bigevglf_state::beg13_b_clr_w)); - map(0x05, 0x05).w(FUNC(bigevglf_state::bigevglf_vidram_addr_w)); /* video banking (256 banks) for f000-f0ff area */ - map(0x06, 0x06).r(FUNC(bigevglf_state::beg_status_r)); + map(0x00, 0x00).nopw(); // video RAM enable ??? + map(0x01, 0x01).w(FUNC(bigevglf_state::gfxcontrol_w)); // plane select + map(0x02, 0x02).w(FUNC(bigevglf_state::banking_w)); + map(0x03, 0x03).w(FUNC(bigevglf_state::_13_a_set_w)); + map(0x04, 0x04).w(FUNC(bigevglf_state::_13_b_clr_w)); + map(0x05, 0x05).w(FUNC(bigevglf_state::vidram_addr_w)); // video banking (256 banks) for f000-f0ff area + map(0x06, 0x06).r(FUNC(bigevglf_state::status_r)); } /*********************************************************************************/ -/* Sub CPU */ +// Sub CPU void bigevglf_state::sub_map(address_map &map) { map(0x0000, 0x3fff).rom(); map(0x4000, 0x47ff).ram(); - map(0x8000, 0x83ff).ram().share("share1"); /* shared with main CPU */ + map(0x8000, 0x83ff).ram().share("main_sub"); } @@ -278,29 +449,29 @@ uint8_t bigevglf_state::sub_cpu_mcu_coin_port_r() */ m_mcu_coin_bit5 ^= 0x20; return - (ioport("PORT04")->read() & 0x03) | + (m_port04->read() & 0x03) | ((CLEAR_LINE == m_bmcu->host_semaphore_r()) ? 0x08 : 0x00) | ((CLEAR_LINE != m_bmcu->mcu_semaphore_r()) ? 0x10 : 0x00) | - m_mcu_coin_bit5; /* bit 0 and bit 1 - coin inputs */ + m_mcu_coin_bit5; // bit 0 and bit 1 - coin inputs } -void bigevglf_state::bigevglf_sub_portmap(address_map &map) +void bigevglf_state::sub_portmap(address_map &map) { map.global_mask(0xff); map(0x00, 0x00).portr("PORT00"); map(0x01, 0x01).nopr(); - map(0x02, 0x02).r(FUNC(bigevglf_state::beg_trackball_x_r)); - map(0x03, 0x03).r(FUNC(bigevglf_state::beg_trackball_y_r)); + map(0x02, 0x02).r(FUNC(bigevglf_state::trackball_x_r)); + map(0x03, 0x03).r(FUNC(bigevglf_state::trackball_y_r)); map(0x04, 0x04).r(FUNC(bigevglf_state::sub_cpu_mcu_coin_port_r)); map(0x05, 0x05).portr("DSW1"); map(0x06, 0x06).portr("DSW2"); map(0x07, 0x07).nopr(); - map(0x08, 0x08).w(FUNC(bigevglf_state::beg_port08_w)); /* muxed port select + other unknown stuff */ + map(0x08, 0x08).w(FUNC(bigevglf_state::port08_w)); // muxed port select + other unknown stuff map(0x0b, 0x0b).r(m_bmcu, FUNC(taito68705_mcu_device::data_r)); map(0x0c, 0x0c).w(m_bmcu, FUNC(taito68705_mcu_device::data_w)); - map(0x0e, 0x0e).nopw(); /* 0-enable MCU, 1-keep reset line ASSERTED; D0 goes to the input of ls74 and the /Q of this ls74 goes to reset line on 68705 */ - map(0x10, 0x17).w(FUNC(bigevglf_state::beg13_a_clr_w)); - map(0x18, 0x1f).w(FUNC(bigevglf_state::beg13_b_set_w)); + map(0x0e, 0x0e).nopw(); // 0-enable MCU, 1-keep reset line ASSERTED; D0 goes to the input of ls74 and the /Q of this ls74 goes to reset line on 68705 + map(0x10, 0x17).w(FUNC(bigevglf_state::_13_a_clr_w)); + map(0x18, 0x1f).w(FUNC(bigevglf_state::_13_b_set_w)); map(0x20, 0x20).r(m_soundlatch[1], FUNC(generic_latch_8_device::read)); map(0x20, 0x20).w(m_soundlatch[0], FUNC(generic_latch_8_device::write)); map(0x21, 0x21).r(FUNC(bigevglf_state::soundstate_r)); @@ -310,7 +481,7 @@ void bigevglf_state::bigevglf_sub_portmap(address_map &map) /*********************************************************************************/ -/* Sound CPU */ +// Sound CPU void bigevglf_state::sound_map(address_map &map) { @@ -321,12 +492,12 @@ void bigevglf_state::sound_map(address_map &map) map(0xcc00, 0xcc00).nopw(); map(0xce00, 0xce00).nopw(); map(0xd800, 0xd800).r(m_soundlatch[0], FUNC(generic_latch_8_device::read)); - map(0xd800, 0xd800).w(m_soundlatch[1], FUNC(generic_latch_8_device::write)); /* write to D800 sets bit 1 in status */ + map(0xd800, 0xd800).w(m_soundlatch[1], FUNC(generic_latch_8_device::write)); // write to D800 sets bit 1 in status map(0xda00, 0xda00).r(FUNC(bigevglf_state::soundstate_r)); map(0xda00, 0xda00).w("soundnmi", FUNC(input_merger_device::in_set<1>)); // enable NMI map(0xdc00, 0xdc00).w("soundnmi", FUNC(input_merger_device::in_clear<1>)); // disable NMI - map(0xde00, 0xde00).nopr().w("dac", FUNC(dac_byte_interface::data_w)); /* signed 8-bit DAC & unknown read */ - map(0xe000, 0xefff).nopr(); /* space for diagnostics ROM */ + map(0xde00, 0xde00).nopr().w("dac", FUNC(dac_byte_interface::data_w)); // signed 8-bit DAC & unknown read + map(0xe000, 0xefff).nopr(); // space for diagnostics ROM } @@ -344,18 +515,20 @@ static const gfx_layout gfxlayout = }; static GFXDECODE_START( gfx_bigevglf ) - GFXDECODE_ENTRY( "gfx1", 0, gfxlayout, 0x20*16, 16 ) + GFXDECODE_ENTRY( "gfx", 0, gfxlayout, 0x20*16, 16 ) GFXDECODE_END void bigevglf_state::machine_start() { + uint8_t *rom = memregion("maincpu")->base(); + m_mainbank->configure_entries(0, 0x100, &rom[0x10000], 0x800); + save_item(NAME(m_vidram_bank)); save_item(NAME(m_plane_selected)); save_item(NAME(m_plane_visible)); - save_item(NAME(m_beg13_ls74)); - save_item(NAME(m_beg_bank)); + save_item(NAME(m_13_ls74)); save_item(NAME(m_port_select)); save_item(NAME(m_mcu_coin_bit5)); @@ -367,9 +540,8 @@ void bigevglf_state::machine_reset() m_plane_selected = 0; m_plane_visible = 0; - m_beg13_ls74[0] = 0; - m_beg13_ls74[1] = 0; - m_beg_bank = 0; + m_13_ls74[0] = 0; + m_13_ls74[1] = 0; m_port_select = 0; m_mcu_coin_bit5 = 0; @@ -377,23 +549,23 @@ void bigevglf_state::machine_reset() void bigevglf_state::bigevglf(machine_config &config) { - /* basic machine hardware */ - Z80(config, m_maincpu, 10000000/2); /* 5 MHz ? */ + // basic machine hardware + Z80(config, m_maincpu, 10_MHz_XTAL / 2); // 5 MHz ? divider not verified m_maincpu->set_addrmap(AS_PROGRAM, &bigevglf_state::main_map); - m_maincpu->set_addrmap(AS_IO, &bigevglf_state::bigevglf_portmap); - m_maincpu->set_vblank_int("screen", FUNC(bigevglf_state::irq0_line_hold)); /* vblank */ + m_maincpu->set_addrmap(AS_IO, &bigevglf_state::main_portmap); + m_maincpu->set_vblank_int("screen", FUNC(bigevglf_state::irq0_line_hold)); - z80_device &subcpu(Z80(config, "sub", 10000000/2)); /* 5 MHz ? */ + z80_device &subcpu(Z80(config, "sub", 10_MHz_XTAL / 2)); // 5 MHz ? divider not verified subcpu.set_addrmap(AS_PROGRAM, &bigevglf_state::sub_map); - subcpu.set_addrmap(AS_IO, &bigevglf_state::bigevglf_sub_portmap); - subcpu.set_vblank_int("screen", FUNC(bigevglf_state::irq0_line_hold)); /* vblank */ + subcpu.set_addrmap(AS_IO, &bigevglf_state::sub_portmap); + subcpu.set_vblank_int("screen", FUNC(bigevglf_state::irq0_line_hold)); - Z80(config, m_audiocpu, 8000000/2); /* 4 MHz ? */ + Z80(config, m_audiocpu, 8_MHz_XTAL / 2); // 4 MHz ? divider not verified m_audiocpu->set_addrmap(AS_PROGRAM, &bigevglf_state::sound_map); - m_audiocpu->set_periodic_int(FUNC(bigevglf_state::irq0_line_hold), attotime::from_hz(2*60)); /* IRQ generated by ???; + m_audiocpu->set_periodic_int(FUNC(bigevglf_state::irq0_line_hold), attotime::from_hz(2 * 60)); /* IRQ generated by ??? 2 irqs/frame give good music tempo but also SOUND ERROR in test mode, 4 irqs/frame give SOUND OK in test mode but music seems to be running too fast */ - /* Clearly, then, there should be some sort of IRQ acknowledge mechanism, duh. -R */ + // Clearly, then, there should be some sort of IRQ acknowledge mechanism, duh. -R GENERIC_LATCH_8(config, m_soundlatch[0]); m_soundlatch[0]->data_pending_callback().set("soundnmi", FUNC(input_merger_device::in_w<0>)); @@ -402,29 +574,29 @@ void bigevglf_state::bigevglf(machine_config &config) INPUT_MERGER_ALL_HIGH(config, "soundnmi").output_handler().set_inputline("audiocpu", INPUT_LINE_NMI); - TAITO68705_MCU(config, m_bmcu, 2000000); /* ??? */ + TAITO68705_MCU(config, m_bmcu, 10_MHz_XTAL / 5); // 2 MHz ? divider not verified - config.set_maximum_quantum(attotime::from_hz(600)); /* 10 CPU slices per frame - interleaving is forced on the fly */ + config.set_maximum_quantum(attotime::from_hz(600)); // 10 CPU slices per frame - interleaving is forced on the fly - /* video hardware */ + // video hardware SCREEN(config, m_screen, SCREEN_TYPE_RASTER); m_screen->set_refresh_hz(60); m_screen->set_vblank_time(ATTOSECONDS_IN_USEC(0)); m_screen->set_size(32*8, 32*8); m_screen->set_visarea(0*8, 32*8-1, 2*8, 30*8-1); - m_screen->set_screen_update(FUNC(bigevglf_state::screen_update_bigevglf)); + m_screen->set_screen_update(FUNC(bigevglf_state::screen_update)); m_screen->set_palette(m_palette); GFXDECODE(config, m_gfxdecode, m_palette, gfx_bigevglf); PALETTE(config, m_palette).set_entries(0x800); - /* sound hardware */ + // sound hardware SPEAKER(config, "mono").front_center(); - YM2149(config, "aysnd", 8000000/4).add_route(ALL_OUTPUTS, "mono", 0.15); + YM2149(config, "aysnd", 8_MHz_XTAL / 4).add_route(ALL_OUTPUTS, "mono", 0.15); // divider not verified - MSM5232(config, m_msm, 8000000/4); - m_msm->set_capacitors(0.65e-6, 0.65e-6, 0.65e-6, 0.65e-6, 0.65e-6, 0.65e-6, 0.65e-6, 0.65e-6); /* 0.65 (???) uF capacitors */ + MSM5232(config, m_msm, 8_MHz_XTAL / 4); // divider not verified + m_msm->set_capacitors(0.65e-6, 0.65e-6, 0.65e-6, 0.65e-6, 0.65e-6, 0.65e-6, 0.65e-6, 0.65e-6); // 0.65 (???) uF capacitors m_msm->add_route(0, "mono", 1.0); // pin 28 2'-1 m_msm->add_route(1, "mono", 1.0); // pin 29 4'-1 m_msm->add_route(2, "mono", 1.0); // pin 30 8'-1 @@ -470,7 +642,7 @@ ROM_START( bigevglf ) ROM_REGION( 0x0800, "bmcu:mcu", 0 ) ROM_LOAD( "a67_19-1", 0x0000, 0x0800, CRC(25691658) SHA1(aabf47abac43abe2ffed18ead1cb94e587149e6e)) - ROM_REGION( 0x20000, "gfx1", 0 ) + ROM_REGION( 0x20000, "gfx", 0 ) ROM_LOAD( "a67-12", 0x00000, 0x8000, CRC(980cc3c5) SHA1(c35c20cfff0b5cfd5b95742333ae20a2c93371b5)) ROM_LOAD( "a67-13", 0x08000, 0x8000, CRC(ad6e04af) SHA1(4680d789cf53c4808105ad4f3c70aedb6d8bcf36)) ROM_LOAD( "a67-14", 0x10000, 0x8000, CRC(d6708cce) SHA1(5b48f9dff2a3e28242dc2004469dc2ac2b5d0321)) @@ -501,18 +673,15 @@ ROM_START( bigevglfj ) ROM_REGION( 0x0800, "bmcu:mcu", 0 ) ROM_LOAD( "a67_19-1", 0x0000, 0x0800, CRC(25691658) SHA1(aabf47abac43abe2ffed18ead1cb94e587149e6e)) - ROM_REGION( 0x20000, "gfx1", 0 ) + ROM_REGION( 0x20000, "gfx", 0 ) ROM_LOAD( "a67-12", 0x00000, 0x8000, CRC(980cc3c5) SHA1(c35c20cfff0b5cfd5b95742333ae20a2c93371b5)) ROM_LOAD( "a67-13", 0x08000, 0x8000, CRC(ad6e04af) SHA1(4680d789cf53c4808105ad4f3c70aedb6d8bcf36)) ROM_LOAD( "a67-14", 0x10000, 0x8000, CRC(d6708cce) SHA1(5b48f9dff2a3e28242dc2004469dc2ac2b5d0321)) ROM_LOAD( "a67-15", 0x18000, 0x8000, CRC(1d261428) SHA1(0f3e6d83a8a462436fa414de4e1e4306db869d3e)) ROM_END -void bigevglf_state::init_bigevglf() -{ - uint8_t *ROM = memregion("maincpu")->base(); - membank("bank1")->configure_entries(0, 0xff, &ROM[0x10000], 0x800); -} +} // anonymous namespace + -GAME( 1986, bigevglf, 0, bigevglf, bigevglf, bigevglf_state, init_bigevglf, ROT270, "Taito America Corporation", "Big Event Golf (US)", MACHINE_NO_COCKTAIL | MACHINE_SUPPORTS_SAVE ) -GAME( 1986, bigevglfj, bigevglf, bigevglf, bigevglfj, bigevglf_state, init_bigevglf, ROT270, "Taito Corporation", "Big Event Golf (Japan)", MACHINE_NO_COCKTAIL | MACHINE_SUPPORTS_SAVE ) +GAME( 1986, bigevglf, 0, bigevglf, bigevglf, bigevglf_state, empty_init, ROT270, "Taito America Corporation", "Big Event Golf (US)", MACHINE_NO_COCKTAIL | MACHINE_SUPPORTS_SAVE ) +GAME( 1986, bigevglfj, bigevglf, bigevglf, bigevglfj, bigevglf_state, empty_init, ROT270, "Taito Corporation", "Big Event Golf (Japan)", MACHINE_NO_COCKTAIL | MACHINE_SUPPORTS_SAVE ) diff --git a/src/mame/taito/bigevglf.h b/src/mame/taito/bigevglf.h deleted file mode 100644 index be7ef903dd1..00000000000 --- a/src/mame/taito/bigevglf.h +++ /dev/null @@ -1,95 +0,0 @@ -// license:GPL-2.0+ -// copyright-holders:Jarek Burczynski, Tomasz Slanina -#ifndef MAME_TAITO_BIGEVGOLF_H -#define MAME_TAITO_BIGEVGOLF_H - -#pragma once - -#include "taito68705.h" - -#include "sound/msm5232.h" -#include "machine/gen_latch.h" - -#include "emupal.h" -#include "screen.h" - -class bigevglf_state : public driver_device -{ -public: - bigevglf_state(const machine_config &mconfig, device_type type, const char *tag) : - driver_device(mconfig, type, tag), - m_paletteram(*this, "paletteram"), - m_spriteram1(*this, "spriteram1"), - m_spriteram2(*this, "spriteram2"), - m_audiocpu(*this, "audiocpu"), - m_bmcu(*this, "bmcu"), - m_maincpu(*this, "maincpu"), - m_msm(*this, "msm"), - m_soundlatch(*this, "soundlatch%u", 1), - m_gfxdecode(*this, "gfxdecode"), - m_screen(*this, "screen"), - m_palette(*this, "palette") { } - - void init_bigevglf(); - void bigevglf(machine_config &config); - -private: - /* memory pointers */ - required_shared_ptr m_paletteram; - required_shared_ptr m_spriteram1; - required_shared_ptr m_spriteram2; - - /* video-related */ - bitmap_ind16 m_tmp_bitmap[4]{}; - std::unique_ptr m_vidram{}; - uint32_t m_vidram_bank = 0U; - uint32_t m_plane_selected = 0U; - uint32_t m_plane_visible = 0U; - - /* MCU related */ - int m_mcu_coin_bit5 = 0; - - /* misc */ - uint32_t m_beg_bank = 0U; - uint8_t m_beg13_ls74[2]{}; - uint8_t m_port_select = 0U; /* for muxed controls */ - - /* devices */ - required_device m_audiocpu; - optional_device m_bmcu; - void beg_banking_w(uint8_t data); - uint8_t soundstate_r(); - void beg13_a_clr_w(uint8_t data); - void beg13_b_clr_w(uint8_t data); - void beg13_a_set_w(uint8_t data); - void beg13_b_set_w(uint8_t data); - uint8_t beg_status_r(); - uint8_t beg_trackball_x_r(); - uint8_t beg_trackball_y_r(); - void beg_port08_w(uint8_t data); - uint8_t sub_cpu_mcu_coin_port_r(); - void bigevglf_palette_w(offs_t offset, uint8_t data); - void bigevglf_gfxcontrol_w(uint8_t data); - void bigevglf_vidram_addr_w(uint8_t data); - void bigevglf_vidram_w(offs_t offset, uint8_t data); - uint8_t bigevglf_vidram_r(offs_t offset); - virtual void machine_start() override; - virtual void machine_reset() override; - virtual void video_start() override; - uint32_t screen_update_bigevglf(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - TIMER_CALLBACK_MEMBER(deferred_ls74_w); - void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect ); - required_device m_maincpu; - required_device m_msm; - required_device_array m_soundlatch; - required_device m_gfxdecode; - required_device m_screen; - required_device m_palette; - void bigevglf_portmap(address_map &map); - void bigevglf_sub_portmap(address_map &map); - void main_map(address_map &map); - void sound_map(address_map &map); - void sub_map(address_map &map); -}; - -#endif // MAME_TAITO_BIGEVGOLF_H diff --git a/src/mame/taito/bigevglf_v.cpp b/src/mame/taito/bigevglf_v.cpp deleted file mode 100644 index 275bc939b18..00000000000 --- a/src/mame/taito/bigevglf_v.cpp +++ /dev/null @@ -1,89 +0,0 @@ -// license:GPL-2.0+ -// copyright-holders:Jarek Burczynski, Tomasz Slanina -/*************************************************************************** - - bigevglf.cpp - - Functions to emulate the video hardware of the machine. - -***************************************************************************/ -#include "emu.h" -#include "bigevglf.h" - - -void bigevglf_state::bigevglf_palette_w(offs_t offset, uint8_t data) -{ - m_paletteram[offset] = data; - int color = m_paletteram[offset & 0x3ff] | (m_paletteram[0x400 + (offset & 0x3ff)] << 8); - m_palette->set_pen_color(offset & 0x3ff, pal4bit(color >> 4), pal4bit(color >> 0), pal4bit(color >> 8)); -} - -void bigevglf_state::bigevglf_gfxcontrol_w(uint8_t data) -{ -/* bits used: 0,1,2,3 - 0 and 2 select plane, - 1 and 3 select visible plane, -*/ - m_plane_selected = ((data & 4) >> 1) | (data & 1); - m_plane_visible = ((data & 8) >> 2) | ((data & 2) >> 1); -} - -void bigevglf_state::bigevglf_vidram_addr_w(uint8_t data) -{ - m_vidram_bank = (data & 0xff) * 0x100; -} - -void bigevglf_state::bigevglf_vidram_w(offs_t offset, uint8_t data) -{ - uint32_t o = m_vidram_bank + offset; - m_vidram[o + 0x10000 * m_plane_selected] = data; - uint32_t y = o >>8; - uint32_t x = (o & 255); - m_tmp_bitmap[m_plane_selected].pix(y, x) = data; -} - -uint8_t bigevglf_state::bigevglf_vidram_r(offs_t offset) -{ - return m_vidram[0x10000 * m_plane_selected + m_vidram_bank + offset]; -} - -void bigevglf_state::video_start() -{ - m_screen->register_screen_bitmap(m_tmp_bitmap[0]); - m_screen->register_screen_bitmap(m_tmp_bitmap[1]); - m_screen->register_screen_bitmap(m_tmp_bitmap[2]); - m_screen->register_screen_bitmap(m_tmp_bitmap[3]); - save_item(NAME(m_tmp_bitmap[0])); - save_item(NAME(m_tmp_bitmap[1])); - save_item(NAME(m_tmp_bitmap[2])); - save_item(NAME(m_tmp_bitmap[3])); - - m_vidram = std::make_unique(0x100 * 0x100 * 4); - - save_pointer(NAME(m_vidram), 0x100 * 0x100 * 4); -} - -void bigevglf_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect ) -{ - int i, j; - for (i = 0xc0-4; i >= 0; i-= 4) - { - int code, sx, sy; - code = m_spriteram2[i + 1]; - sx = m_spriteram2[i + 3]; - sy = 200 - m_spriteram2[i]; - for (j = 0; j < 16; j++) - m_gfxdecode->gfx(0)->transpen(bitmap,cliprect, - m_spriteram1[(code << 4) + j] + ((m_spriteram1[0x400 + (code << 4) + j] & 0xf) << 8), - m_spriteram2[i + 2] & 0xf, - 0,0, - sx + ((j & 1) << 3), sy + ((j >> 1) << 3), 0); - } -} - -uint32_t bigevglf_state::screen_update_bigevglf(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - copybitmap(bitmap, m_tmp_bitmap[m_plane_visible], 0, 0, 0, 0, cliprect); - draw_sprites(bitmap, cliprect); - return 0; -} diff --git a/src/mame/taito/chaknpop.cpp b/src/mame/taito/chaknpop.cpp index b23a9aff955..eac17698208 100644 --- a/src/mame/taito/chaknpop.cpp +++ b/src/mame/taito/chaknpop.cpp @@ -1,5 +1,6 @@ // license:BSD-3-Clause -// copyright-holders:BUT +// copyright-holders: BUT + /* Chack'n Pop driver by BUT @@ -110,14 +111,337 @@ Notes: */ #include "emu.h" -#include "chaknpop.h" + +#include "taito68705.h" #include "cpu/z80/z80.h" #include "cpu/m6805/m6805.h" #include "sound/ay8910.h" + +#include "emupal.h" #include "screen.h" #include "speaker.h" +#include "tilemap.h" + + +// configurable logging +#define LOG_UNKWRITE (1U << 1) +#define LOG_COINLOCK (1U << 2) + +//#define VERBOSE (LOG_GENERAL | LOG_UNKWRITE | LOG_COINLOCK) +#include "logmacro.h" + +#define LOGUNKWRITE(...) LOGMASKED(LOG_UNKWRITE, __VA_ARGS__) +#define LOGCOINLOCK(...) LOGMASKED(LOG_COINLOCK, __VA_ARGS__) + + +namespace { + +class chaknpop_state : public driver_device +{ +public: + chaknpop_state(const machine_config &mconfig, device_type type, const char *tag) : + driver_device(mconfig, type, tag), + m_maincpu(*this, "maincpu"), + m_bmcu(*this, "bmcu"), + m_gfxdecode(*this, "gfxdecode"), + m_palette(*this, "palette"), + m_tx_ram(*this, "tx_ram"), + m_attr_ram(*this, "attr_ram"), + m_spr_ram(*this, "spr_ram"), + m_vram_bank(*this, "vram_bank"), + m_vram(*this, "vram", 0x8000, ENDIANNESS_LITTLE) + { } + + void chaknpop(machine_config &config); + +protected: + virtual void machine_start() override; + virtual void machine_reset() override; + virtual void video_start() override; + +private: + // devices + required_device m_maincpu; + required_device m_bmcu; + required_device m_gfxdecode; + required_device m_palette; + + // memory pointers + required_shared_ptr m_tx_ram; + required_shared_ptr m_attr_ram; + required_shared_ptr m_spr_ram; + required_memory_bank m_vram_bank; + memory_share_creator m_vram; + + // video-related + tilemap_t *m_tx_tilemap = nullptr; + uint8_t m_gfxmode = 0U; + uint8_t m_flip_x = 0U; + uint8_t m_flip_y = 0U; + + enum + { + GFX_FLIP_X = 0x01, + GFX_FLIP_Y = 0x02, + GFX_VRAM_BANK = 0x04, + GFX_UNKNOWN1 = 0x08, + GFX_TX_BANK1 = 0x20, + GFX_UNKNOWN2 = 0x40, + GFX_TX_BANK2 = 0x80 + }; + + enum + { + TX_COLOR1 = 0x0b, + TX_COLOR2 = 0x01 + }; + + void coinlock_w(uint8_t data); + uint8_t gfxmode_r(); + void gfxmode_w(uint8_t data); + void txram_w(offs_t offset, uint8_t data); + void attrram_w(offs_t offset, uint8_t data); + void unknown_ay_port_a_w(uint8_t data); + void unknown_ay_port_b_w(uint8_t data); + void unknown_8802_w(uint8_t data); + uint8_t mcu_status_r(); + TILE_GET_INFO_MEMBER(get_tx_tile_info); + + void palette(palette_device &palette) const; + + uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); + void tx_tilemap_mark_all_dirty(); + void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect); + void draw_bitmap(bitmap_ind16 &bitmap, const rectangle &cliprect); + + void prg_map(address_map &map); +}; + + +// video + +/*************************************************************************** + palette decode +***************************************************************************/ + +void chaknpop_state::palette(palette_device &palette) const +{ + uint8_t const *const color_prom = memregion("proms")->base(); + + for (int i = 0; i < 1024; i++) + { + int bit0, bit1, bit2; + + int const col = (color_prom[i] & 0x0f) | ((color_prom[i + 1024] & 0x0f) << 4); + + // red component + bit0 = BIT(col, 0); + bit1 = BIT(col, 1); + bit2 = BIT(col, 2); + int const r = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; + + // green component + bit0 = BIT(col, 3); + bit1 = BIT(col, 4); + bit2 = BIT(col, 5); + int const g = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; + + // blue component + bit0 = 0; + bit1 = BIT(col, 6); + bit2 = BIT(col, 7); + int const b = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; + + palette.set_pen_color(i, rgb_t(r, g, b)); + } +} + +/*************************************************************************** + Memory handlers +***************************************************************************/ + +void chaknpop_state::tx_tilemap_mark_all_dirty() +{ + m_tx_tilemap->mark_all_dirty(); + m_tx_tilemap->set_flip(m_flip_x | m_flip_y); +} + +uint8_t chaknpop_state::gfxmode_r() +{ + return m_gfxmode; +} + +void chaknpop_state::gfxmode_w(uint8_t data) +{ + if (m_gfxmode != data) + { + int all_dirty = 0; + + m_gfxmode = data; + m_vram_bank->set_entry((m_gfxmode & GFX_VRAM_BANK) ? 1 : 0); // Select 2 banks of 16k + + if (m_flip_x != (m_gfxmode & GFX_FLIP_X)) + { + m_flip_x = m_gfxmode & GFX_FLIP_X; + all_dirty = 1; + } + + if (m_flip_y != (m_gfxmode & GFX_FLIP_Y)) + { + m_flip_y = m_gfxmode & GFX_FLIP_Y; + all_dirty = 1; + } + + if (all_dirty) + tx_tilemap_mark_all_dirty(); + } +} + +void chaknpop_state::txram_w(offs_t offset, uint8_t data) +{ + m_tx_ram[offset] = data; + m_tx_tilemap->mark_tile_dirty(offset); +} + +void chaknpop_state::attrram_w(offs_t offset, uint8_t data) +{ + if (m_attr_ram[offset] != data) + { + m_attr_ram[offset] = data; + + if (offset == TX_COLOR1 || offset == TX_COLOR2) + tx_tilemap_mark_all_dirty(); + } +} + + +/*************************************************************************** + Callback for the tilemap code +***************************************************************************/ + +/* + * I'm not sure how to handle attributes about color + */ + +TILE_GET_INFO_MEMBER(chaknpop_state::get_tx_tile_info) +{ + int tile = m_tx_ram[tile_index]; + int const tile_h_bank = (m_gfxmode & GFX_TX_BANK2) << 2; // 0x00-0xff -> 0x200-0x2ff + int color = m_attr_ram[TX_COLOR2]; + + if (tile == 0x74) + color = m_attr_ram[TX_COLOR1]; + + if (m_gfxmode & GFX_TX_BANK1 && tile >= 0xc0) + tile += 0xc0; // 0xc0-0xff -> 0x180-0x1bf + + tile |= tile_h_bank; + + tileinfo.set(1, tile, color, 0); +} + + +/*************************************************************************** + Initialize video hardware emulation +***************************************************************************/ + +void chaknpop_state::video_start() +{ + m_tx_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(chaknpop_state::get_tx_tile_info)), TILEMAP_SCAN_ROWS, 8, 8, 32, 32); + + m_gfxmode = 0; + m_flip_x = 0; + m_flip_y = 0; + + m_vram_bank->set_entry(0); + tx_tilemap_mark_all_dirty(); + + machine().save().register_postload(save_prepost_delegate(FUNC(chaknpop_state::tx_tilemap_mark_all_dirty), this)); +} + + +/*************************************************************************** + Screen refresh +***************************************************************************/ + +void chaknpop_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect) +{ + // Draw the sprites + for (int offs = 0; offs < m_spr_ram.bytes(); offs += 4) + { + int sx = m_spr_ram[offs + 3]; + int sy = 256 - 15 - m_spr_ram[offs]; + int flipx = m_spr_ram[offs + 1] & 0x40; + int flipy = m_spr_ram[offs + 1] & 0x80; + int const color = (m_spr_ram[offs + 2] & 7); + int const tile = (m_spr_ram[offs + 1] & 0x3f) | ((m_spr_ram[offs + 2] & 0x38) << 3); + + if (m_flip_x) + { + sx = 240 - sx; + flipx = !flipx; + } + if (m_flip_y) + { + sy = 242 - sy; + flipy = !flipy; + } + + + m_gfxdecode->gfx(0)->transpen(bitmap, cliprect, + tile, + color, + flipx, flipy, + sx, sy, 0); + } +} + +void chaknpop_state::draw_bitmap(bitmap_ind16 &bitmap, const rectangle &cliprect) +{ + int const dx = m_flip_x ? -1 : 1; + + for (int offs = 0; offs < 0x2000; offs++) + { + int x = ((offs & 0x1f) << 3) + 7; + int y = offs >> 5; + + if (!m_flip_x) + x = 255 - x; + + if (!m_flip_y) + y = 255 - y; + + for (int i = 0x80; i > 0; i >>= 1, x += dx) + { + pen_t color = 0; + + if (m_vram[offs] & i) + color |= 0x200; // green lower cage + if (m_vram[0x2000 + offs] & i) + color |= 0x080; + if (m_vram[0x4000 + offs] & i) + color |= 0x100; // green upper cage + if (m_vram[0x6000 + offs] & i) + color |= 0x040; // tx mask + + if (color) + bitmap.pix(y, x) |= color; + } + } +} + +uint32_t chaknpop_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) +{ + m_tx_tilemap->draw(screen, bitmap, cliprect, 0, 0); + draw_sprites(bitmap, cliprect); + draw_bitmap(bitmap, cliprect); + return 0; +} + + +// machine /*************************************************************************** @@ -134,24 +458,24 @@ uint8_t chaknpop_state::mcu_status_r() ((CLEAR_LINE != m_bmcu->mcu_semaphore_r()) ? 0x02 : 0x00); } -void chaknpop_state::unknown_port_1_w(uint8_t data) +void chaknpop_state::unknown_ay_port_a_w(uint8_t data) { - //logerror("%s: write to unknown port 1: 0x%02x\n", machine().describe_context(), data); + LOGUNKWRITE("%s: write to AY port A: 0x%02x\n", machine().describe_context(), data); } -void chaknpop_state::unknown_port_2_w(uint8_t data) +void chaknpop_state::unknown_ay_port_b_w(uint8_t data) { - //logerror("%s: write to unknown port 2: 0x%02x\n", machine().describe_context(), data); + LOGUNKWRITE("%s: write to AY port B: 0x%02x\n", machine().describe_context(), data); } -void chaknpop_state::unknown_port_3_w(uint8_t data) +void chaknpop_state::unknown_8802_w(uint8_t data) { - //logerror("%s: write to unknown port 3: 0x%02x\n", machine().describe_context(), data); + LOGUNKWRITE("%s: write to main CPU 0x8802: 0x%02x\n", machine().describe_context(), data); } void chaknpop_state::coinlock_w(uint8_t data) { - logerror("%04x: coin lock %sable\n", m_maincpu->pc(), data ? "dis" : "en"); + LOGCOINLOCK("%04x: coin lock %sable\n", m_maincpu->pc(), data ? "dis" : "en"); } @@ -161,13 +485,13 @@ void chaknpop_state::coinlock_w(uint8_t data) ***************************************************************************/ -void chaknpop_state::chaknpop_map(address_map &map) +void chaknpop_state::prg_map(address_map &map) { map(0x0000, 0x7fff).rom(); map(0x8000, 0x87ff).ram(); map(0x8800, 0x8800).rw(m_bmcu, FUNC(taito68705_mcu_device::data_r), FUNC(taito68705_mcu_device::data_w)); map(0x8801, 0x8801).r(FUNC(chaknpop_state::mcu_status_r)); - map(0x8802, 0x8802).w(FUNC(chaknpop_state::unknown_port_3_w)); + map(0x8802, 0x8802).w(FUNC(chaknpop_state::unknown_8802_w)); map(0x8804, 0x8805).rw("ay1", FUNC(ay8910_device::data_r), FUNC(ay8910_device::address_data_w)); map(0x8806, 0x8807).rw("ay2", FUNC(ay8910_device::data_r), FUNC(ay8910_device::address_data_w)); map(0x8808, 0x8808).portr("DSWC"); @@ -175,10 +499,10 @@ void chaknpop_state::chaknpop_map(address_map &map) map(0x880a, 0x880a).portr("SYSTEM"); map(0x880b, 0x880b).portr("P2"); map(0x880c, 0x880c).rw(FUNC(chaknpop_state::gfxmode_r), FUNC(chaknpop_state::gfxmode_w)); - map(0x880d, 0x880d).w(FUNC(chaknpop_state::coinlock_w)); // coin lock out - map(0x9000, 0x93ff).ram().w(FUNC(chaknpop_state::txram_w)).share("tx_ram"); // TX tilemap - map(0x9800, 0x983f).ram().w(FUNC(chaknpop_state::attrram_w)).share("attr_ram"); // Color attribute - map(0x9840, 0x98ff).ram().share("spr_ram"); // sprite + map(0x880d, 0x880d).w(FUNC(chaknpop_state::coinlock_w)); + map(0x9000, 0x93ff).ram().w(FUNC(chaknpop_state::txram_w)).share(m_tx_ram); + map(0x9800, 0x983f).ram().w(FUNC(chaknpop_state::attrram_w)).share(m_attr_ram); // Color attribute + map(0x9840, 0x98ff).ram().share(m_spr_ram); map(0xa000, 0xbfff).rom(); map(0xc000, 0xffff).bankrw(m_vram_bank); // bitmap plane 1-4 } @@ -316,31 +640,31 @@ INPUT_PORTS_END static const gfx_layout spritelayout = { - 16,16, /* 16*16 characters */ - 256, /* 256 characters */ - 2, /* 2 bits per pixel */ - { 0, 0x2000*8 }, /* the two bitplanes are separated */ + 16,16, // 16*16 characters + 256, // 256 characters + 2, // 2 bits per pixel + { 0, 0x2000*8 }, // the two bitplanes are separated { 0, 1, 2, 3, 4, 5, 6, 7 , 8*8+0, 8*8+1, 8*8+2, 8*8+3, 8*8+4, 8*8+5, 8*8+6, 8*8+7 }, { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8, 16*8, 17*8, 18*8, 19*8, 20*8, 21*8, 22*8, 23*8 }, - 32*8 /* every sprite takes 32 consecutive bytes */ + 32*8 // every sprite takes 32 consecutive bytes }; static const gfx_layout charlayout = { - 8,8, /* 8*8 characters */ - 1024, /* 1024 characters */ - 2, /* 2 bits per pixel */ - { 0, 0x2000*8 }, /* the two bitplanes are separated */ + 8,8, // 8*8 characters + 1024, // 1024 characters + 2, // 2 bits per pixel + { 0, 0x2000*8 }, // the two bitplanes are separated { 0, 1, 2, 3, 4, 5, 6, 7 }, { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 }, - 8*8 /* every char takes 8 consecutive bytes */ + 8*8 // every char takes 8 consecutive bytes }; static GFXDECODE_START( gfx_chaknpop ) - GFXDECODE_ENTRY( "gfx1", 0, spritelayout, 0, 8 ) - GFXDECODE_ENTRY( "gfx2", 0, charlayout, 32, 8 ) + GFXDECODE_ENTRY( "sprites", 0, spritelayout, 0, 8 ) + GFXDECODE_ENTRY( "chars", 0, charlayout, 32, 8 ) GFXDECODE_END @@ -362,15 +686,15 @@ void chaknpop_state::machine_reset() void chaknpop_state::chaknpop(machine_config &config) { - /* basic machine hardware */ + // basic machine hardware Z80(config, m_maincpu, XTAL(18'000'000) / 6); // Verified on PCB - m_maincpu->set_addrmap(AS_PROGRAM, &chaknpop_state::chaknpop_map); + m_maincpu->set_addrmap(AS_PROGRAM, &chaknpop_state::prg_map); m_maincpu->set_vblank_int("screen", FUNC(chaknpop_state::irq0_line_hold)); TAITO68705_MCU(config, m_bmcu, XTAL(18'000'000) / 6); // Verified on PCB config.set_maximum_quantum(attotime::from_hz(6000)); // 100 CPU slices per frame - a high value to ensure proper synchronization of the CPUs - /* video hardware */ + // video hardware screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_RASTER)); screen.set_refresh_hz(59.1828); screen.set_vblank_time(ATTOSECONDS_IN_USEC(0)); @@ -380,9 +704,9 @@ void chaknpop_state::chaknpop(machine_config &config) screen.set_palette(m_palette); GFXDECODE(config, m_gfxdecode, m_palette, gfx_chaknpop); - PALETTE(config, m_palette, FUNC(chaknpop_state::chaknpop_palette), 1024); + PALETTE(config, m_palette, FUNC(chaknpop_state::palette), 1024); - /* sound hardware */ + // sound hardware SPEAKER(config, "mono").front_center(); ay8910_device &ay1(AY8910(config, "ay1", XTAL(18'000'000) / 12)); // Verified on PCB @@ -391,8 +715,8 @@ void chaknpop_state::chaknpop(machine_config &config) ay1.add_route(ALL_OUTPUTS, "mono", 0.15); ay8910_device &ay2(AY8910(config, "ay2", XTAL(18'000'000) / 12)); // Verified on PCB - ay2.port_a_write_callback().set(FUNC(chaknpop_state::unknown_port_1_w)); // ?? - ay2.port_b_write_callback().set(FUNC(chaknpop_state::unknown_port_2_w)); // ?? + ay2.port_a_write_callback().set(FUNC(chaknpop_state::unknown_ay_port_a_w)); // ?? + ay2.port_b_write_callback().set(FUNC(chaknpop_state::unknown_ay_port_b_w)); // ?? ay2.add_route(ALL_OUTPUTS, "mono", 0.10); } @@ -404,21 +728,21 @@ void chaknpop_state::chaknpop(machine_config &config) ***************************************************************************/ ROM_START( chaknpop ) - ROM_REGION( 0xc000, "maincpu", 0 ) // Main CPU + ROM_REGION( 0xc000, "maincpu", 0 ) ROM_LOAD( "ao4_01.ic28", 0x00000, 0x2000, CRC(386fe1c8) SHA1(cca24abfb8a7f439251e7936036475c694002561) ) ROM_LOAD( "ao4_02.ic27", 0x02000, 0x2000, CRC(5562a6a7) SHA1(0c5d81f9aaf858f88007a6bca7f83dc3ef59c5b5) ) ROM_LOAD( "ao4_03.ic26", 0x04000, 0x2000, CRC(3e2f0a9c) SHA1(f1cf87a4cb07f77104d4a4d369807dac522e052c) ) ROM_LOAD( "ao4_04.ic25", 0x06000, 0x2000, CRC(5209c7d4) SHA1(dcba785a697df55d84d65735de38365869a1da9d) ) ROM_LOAD( "ao4_05.ic3", 0x0a000, 0x2000, CRC(8720e024) SHA1(99e445c117d1501a245f9eb8d014abc4712b4963) ) - ROM_REGION( 0x0800, "bmcu:mcu", 0 ) // 2k for the Motorola MC68705P5 Micro-controller + ROM_REGION( 0x0800, "bmcu:mcu", 0 ) // Motorola MC68705P5 Micro-controller ROM_LOAD( "ao4_06.ic23", 0x0000, 0x0800, CRC(9c78c24c) SHA1(f74c7f3ee106e5c45c907e590ec09614a2bc6751) ) - ROM_REGION( 0x4000, "gfx1", 0 ) // Sprite + ROM_REGION( 0x4000, "sprites", 0 ) ROM_LOAD( "ao4_08.ic14", 0x0000, 0x2000, CRC(5575a021) SHA1(c2fad53fe6a12c19cec69d27c13fce6aea2502f2) ) ROM_LOAD( "ao4_07.ic15", 0x2000, 0x2000, CRC(ae687c18) SHA1(65b25263da88d30cbc0dad94511869596e5c975a) ) - ROM_REGION( 0x4000, "gfx2", 0 ) // Text + ROM_REGION( 0x4000, "chars", 0 ) ROM_LOAD( "ao4_09.ic98", 0x0000, 0x2000, CRC(757a723a) SHA1(62ab84d2aaa9bc1ea5aa9df8155aa3b5a1e93889) ) ROM_LOAD( "ao4_10.ic97", 0x2000, 0x2000, CRC(3e3fd608) SHA1(053a8fbdb35bf1c142349f78a63e8cd1adb41ef6) ) @@ -427,6 +751,8 @@ ROM_START( chaknpop ) ROM_LOAD( "ao4-12.ic95", 0x0400, 0x0400, CRC(954ce8fc) SHA1(e187f9e2cb754264d149c2896ca949dea3bcf2eb) ) ROM_END +} // anonymous namespace + // ( YEAR NAME PARENT MACHINE INPUT STATE INIT MONITOR COMPANY FULLNAME FLAGS ) GAME( 1983, chaknpop, 0, chaknpop, chaknpop, chaknpop_state, empty_init, ROT0, "Taito Corporation", "Chack'n Pop", MACHINE_SUPPORTS_SAVE ) diff --git a/src/mame/taito/chaknpop.h b/src/mame/taito/chaknpop.h deleted file mode 100644 index c62b9e44659..00000000000 --- a/src/mame/taito/chaknpop.h +++ /dev/null @@ -1,77 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:BUT -#ifndef MAME_TAITO_CHAKNPOP_H -#define MAME_TAITO_CHAKNPOP_H - -#pragma once - -#include "taito68705.h" - -#include "emupal.h" -#include "tilemap.h" - -class chaknpop_state : public driver_device -{ -public: - chaknpop_state(const machine_config &mconfig, device_type type, const char *tag) : - driver_device(mconfig, type, tag), - m_maincpu(*this, "maincpu"), - m_bmcu(*this, "bmcu"), - m_gfxdecode(*this, "gfxdecode"), - m_palette(*this, "palette"), - m_tx_ram(*this, "tx_ram"), - m_attr_ram(*this, "attr_ram"), - m_spr_ram(*this, "spr_ram"), - m_vram_bank(*this, "vram_bank"), - m_vram(*this, "vram", 0x8000, ENDIANNESS_LITTLE) - { } - - void chaknpop(machine_config &config); - -protected: - virtual void machine_start() override; - virtual void machine_reset() override; - virtual void video_start() override; - -private: - /* devices */ - required_device m_maincpu; - optional_device m_bmcu; - required_device m_gfxdecode; - required_device m_palette; - - /* memory pointers */ - required_shared_ptr m_tx_ram; - required_shared_ptr m_attr_ram; - required_shared_ptr m_spr_ram; - required_memory_bank m_vram_bank; - memory_share_creator m_vram; - - /* video-related */ - tilemap_t *m_tx_tilemap = nullptr; - uint8_t m_gfxmode = 0U; - uint8_t m_flip_x = 0U; - uint8_t m_flip_y = 0U; - - void coinlock_w(uint8_t data); - uint8_t gfxmode_r(); - void gfxmode_w(uint8_t data); - void txram_w(offs_t offset, uint8_t data); - void attrram_w(offs_t offset, uint8_t data); - void unknown_port_1_w(uint8_t data); - void unknown_port_2_w(uint8_t data); - void unknown_port_3_w(uint8_t data); - uint8_t mcu_status_r(); - TILE_GET_INFO_MEMBER(get_tx_tile_info); - - void chaknpop_palette(palette_device &palette) const; - - uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - void tx_tilemap_mark_all_dirty(); - void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect); - void draw_bitmap(bitmap_ind16 &bitmap, const rectangle &cliprect); - - void chaknpop_map(address_map &map); -}; - -#endif // MAME_TAITO_CHAKNPOP_H diff --git a/src/mame/taito/chaknpop_v.cpp b/src/mame/taito/chaknpop_v.cpp deleted file mode 100644 index 240a162c416..00000000000 --- a/src/mame/taito/chaknpop_v.cpp +++ /dev/null @@ -1,239 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:BUT -/* - * Chack'n Pop (C) 1983 TAITO Corp. - * emulate video hardware - */ - -#include "emu.h" -#include "chaknpop.h" - -#define GFX_FLIP_X 0x01 -#define GFX_FLIP_Y 0x02 -#define GFX_VRAM_BANK 0x04 -#define GFX_UNKNOWN1 0x08 -#define GFX_TX_BANK1 0x20 -#define GFX_UNKNOWN2 0x40 -#define GFX_TX_BANK2 0x80 - -#define TX_COLOR1 0x0b -#define TX_COLOR2 0x01 - - -/*************************************************************************** - palette decode -***************************************************************************/ - -void chaknpop_state::chaknpop_palette(palette_device &palette) const -{ - uint8_t const *const color_prom = memregion("proms")->base(); - - for (int i = 0; i < 1024; i++) - { - int bit0, bit1, bit2; - - int const col = (color_prom[i] & 0x0f) | ((color_prom[i + 1024] & 0x0f) << 4); - - // red component - bit0 = BIT(col, 0); - bit1 = BIT(col, 1); - bit2 = BIT(col, 2); - int const r = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; - - // green component - bit0 = BIT(col, 3); - bit1 = BIT(col, 4); - bit2 = BIT(col, 5); - int const g = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; - - // blue component - bit0 = 0; - bit1 = BIT(col, 6); - bit2 = BIT(col, 7); - int const b = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; - - palette.set_pen_color(i, rgb_t(r, g, b)); - } -} - -/*************************************************************************** - Memory handlers -***************************************************************************/ - -void chaknpop_state::tx_tilemap_mark_all_dirty() -{ - m_tx_tilemap->mark_all_dirty(); - m_tx_tilemap->set_flip(m_flip_x | m_flip_y); -} - -uint8_t chaknpop_state::gfxmode_r() -{ - return m_gfxmode; -} - -void chaknpop_state::gfxmode_w(uint8_t data) -{ - if (m_gfxmode != data) - { - int all_dirty = 0; - - m_gfxmode = data; - m_vram_bank->set_entry((m_gfxmode & GFX_VRAM_BANK) ? 1 : 0); /* Select 2 banks of 16k */ - - if (m_flip_x != (m_gfxmode & GFX_FLIP_X)) - { - m_flip_x = m_gfxmode & GFX_FLIP_X; - all_dirty = 1; - } - - if (m_flip_y != (m_gfxmode & GFX_FLIP_Y)) - { - m_flip_y = m_gfxmode & GFX_FLIP_Y; - all_dirty = 1; - } - - if (all_dirty) - tx_tilemap_mark_all_dirty(); - } -} - -void chaknpop_state::txram_w(offs_t offset, uint8_t data) -{ - m_tx_ram[offset] = data; - m_tx_tilemap->mark_tile_dirty(offset); -} - -void chaknpop_state::attrram_w(offs_t offset, uint8_t data) -{ - if (m_attr_ram[offset] != data) - { - m_attr_ram[offset] = data; - - if (offset == TX_COLOR1 || offset == TX_COLOR2) - tx_tilemap_mark_all_dirty(); - } -} - - -/*************************************************************************** - Callback for the tilemap code -***************************************************************************/ - -/* - * I'm not sure how to handle attributes about color - */ - -TILE_GET_INFO_MEMBER(chaknpop_state::get_tx_tile_info) -{ - int tile = m_tx_ram[tile_index]; - int tile_h_bank = (m_gfxmode & GFX_TX_BANK2) << 2; /* 0x00-0xff -> 0x200-0x2ff */ - int color = m_attr_ram[TX_COLOR2]; - - if (tile == 0x74) - color = m_attr_ram[TX_COLOR1]; - - if (m_gfxmode & GFX_TX_BANK1 && tile >= 0xc0) - tile += 0xc0; /* 0xc0-0xff -> 0x180-0x1bf */ - - tile |= tile_h_bank; - - tileinfo.set(1, tile, color, 0); -} - - -/*************************************************************************** - Initialize video hardware emulation -***************************************************************************/ - -void chaknpop_state::video_start() -{ - m_tx_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(chaknpop_state::get_tx_tile_info)), TILEMAP_SCAN_ROWS, 8, 8, 32, 32); - - m_gfxmode = 0; - m_flip_x = 0; - m_flip_y = 0; - - m_vram_bank->set_entry(0); - tx_tilemap_mark_all_dirty(); - - machine().save().register_postload(save_prepost_delegate(FUNC(chaknpop_state::tx_tilemap_mark_all_dirty), this)); -} - - -/*************************************************************************** - Screen refresh -***************************************************************************/ - -void chaknpop_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect ) -{ - /* Draw the sprites */ - for (int offs = 0; offs < m_spr_ram.bytes(); offs += 4) - { - int sx = m_spr_ram[offs + 3]; - int sy = 256 - 15 - m_spr_ram[offs]; - int flipx = m_spr_ram[offs+1] & 0x40; - int flipy = m_spr_ram[offs+1] & 0x80; - int color = (m_spr_ram[offs + 2] & 7); - int tile = (m_spr_ram[offs + 1] & 0x3f) | ((m_spr_ram[offs + 2] & 0x38) << 3); - - if (m_flip_x) - { - sx = 240 - sx; - flipx = !flipx; - } - if (m_flip_y) - { - sy = 242 - sy; - flipy = !flipy; - } - - - m_gfxdecode->gfx(0)->transpen(bitmap,cliprect, - tile, - color, - flipx, flipy, - sx, sy, 0); - } -} - -void chaknpop_state::draw_bitmap( bitmap_ind16 &bitmap, const rectangle &cliprect ) -{ - int dx = m_flip_x ? -1 : 1; - - for (int offs = 0; offs < 0x2000; offs++) - { - int x = ((offs & 0x1f) << 3) + 7; - int y = offs >> 5; - - if (!m_flip_x) - x = 255 - x; - - if (!m_flip_y) - y = 255 - y; - - for (int i = 0x80; i > 0; i >>= 1, x += dx) - { - pen_t color = 0; - - if (m_vram[offs] & i) - color |= 0x200; // green lower cage - if (m_vram[0x2000 + offs] & i) - color |= 0x080; - if (m_vram[0x4000 + offs] & i) - color |= 0x100; // green upper cage - if (m_vram[0x6000 + offs] & i) - color |= 0x040; // tx mask - - if (color) - bitmap.pix(y, x) |= color; - } - } -} - -uint32_t chaknpop_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - m_tx_tilemap->draw(screen, bitmap, cliprect, 0, 0); - draw_sprites(bitmap, cliprect); - draw_bitmap(bitmap, cliprect); - return 0; -} -- cgit v1.2.3