From 8df0774574f898314afa3373bf9c254e2427d09b Mon Sep 17 00:00:00 2001 From: AJR Date: Sat, 15 Apr 2023 19:46:17 -0400 Subject: 88games.cpp, asterix.cpp, bishi.cpp, chqflag.cpp, crimfght.cpp, dbz.cpp, djmain.cpp, gijoe.cpp, gradius3.cpp, lethal.cpp, moo.cpp, qdrmfgp.cpp, rungun.cpp, simpsons.cpp, spy.cpp, xexex.cpp: Consolidate drivers in one file each; remove a few ancient progress notes --- src/mame/konami/88games.cpp | 149 +++++++++++++++++++- src/mame/konami/88games.h | 80 ----------- src/mame/konami/88games_v.cpp | 83 ----------- src/mame/konami/asterix.cpp | 167 +++++++++++++++++++++- src/mame/konami/asterix.h | 71 ---------- src/mame/konami/asterix_v.cpp | 108 -------------- src/mame/konami/bishi.cpp | 122 +++++++++++++++- src/mame/konami/bishi.h | 71 ---------- src/mame/konami/bishi_v.cpp | 72 ---------- src/mame/konami/chqflag.cpp | 127 ++++++++++++++++- src/mame/konami/chqflag.h | 81 ----------- src/mame/konami/chqflag_v.cpp | 67 --------- src/mame/konami/crimfght.cpp | 130 ++++++++++++++++- src/mame/konami/crimfght.h | 73 ---------- src/mame/konami/crimfght_v.cpp | 70 ---------- src/mame/konami/dbz.cpp | 231 +++++++++++++++++++++++++++++- src/mame/konami/dbz.h | 98 ------------- src/mame/konami/dbz_v.cpp | 155 -------------------- src/mame/konami/djmain.cpp | 278 +++++++++++++++++++++++++++++++++++- src/mame/konami/djmain.h | 107 -------------- src/mame/konami/djmain_v.cpp | 185 ------------------------ src/mame/konami/gijoe.cpp | 262 +++++++++++++++++++++++++++++++--- src/mame/konami/gijoe.h | 83 ----------- src/mame/konami/gijoe_v.cpp | 168 ---------------------- src/mame/konami/gradius3.cpp | 188 ++++++++++++++++++++++++- src/mame/konami/gradius3.h | 78 ----------- src/mame/konami/gradius3_v.cpp | 124 ---------------- src/mame/konami/lethal.cpp | 172 ++++++++++++++++++++++- src/mame/konami/lethal.h | 76 ---------- src/mame/konami/lethal_v.cpp | 114 --------------- src/mame/konami/moo.cpp | 219 ++++++++++++++++++++++++++++- src/mame/konami/moo.h | 107 -------------- src/mame/konami/moo_v.cpp | 135 ------------------ src/mame/konami/qdrmfgp.cpp | 142 ++++++++++++++++++- src/mame/konami/qdrmfgp.h | 92 ------------ src/mame/konami/qdrmfgp_v.cpp | 64 --------- src/mame/konami/rungun.cpp | 291 ++++++++++++++++++++++++++++++++++++-- src/mame/konami/rungun.h | 125 ----------------- src/mame/konami/rungun_v.cpp | 175 ----------------------- src/mame/konami/simpsons.cpp | 311 ++++++++++++++++++++++++++++++++++++++++- src/mame/konami/simpsons.h | 85 ----------- src/mame/konami/simpsons_m.cpp | 110 --------------- src/mame/konami/simpsons_v.cpp | 124 ---------------- src/mame/konami/spy.cpp | 130 ++++++++++++++++- src/mame/konami/spy.h | 77 ---------- src/mame/konami/spy_v.cpp | 68 --------- src/mame/konami/xexex.cpp | 223 ++++++++++++++++++++++++++++- src/mame/konami/xexex.h | 119 ---------------- src/mame/konami/xexex_v.cpp | 118 ---------------- 49 files changed, 3085 insertions(+), 3420 deletions(-) delete mode 100644 src/mame/konami/88games.h delete mode 100644 src/mame/konami/88games_v.cpp delete mode 100644 src/mame/konami/asterix.h delete mode 100644 src/mame/konami/asterix_v.cpp delete mode 100644 src/mame/konami/bishi.h delete mode 100644 src/mame/konami/bishi_v.cpp delete mode 100644 src/mame/konami/chqflag.h delete mode 100644 src/mame/konami/chqflag_v.cpp delete mode 100644 src/mame/konami/crimfght.h delete mode 100644 src/mame/konami/crimfght_v.cpp delete mode 100644 src/mame/konami/dbz.h delete mode 100644 src/mame/konami/dbz_v.cpp delete mode 100644 src/mame/konami/djmain.h delete mode 100644 src/mame/konami/djmain_v.cpp delete mode 100644 src/mame/konami/gijoe.h delete mode 100644 src/mame/konami/gijoe_v.cpp delete mode 100644 src/mame/konami/gradius3.h delete mode 100644 src/mame/konami/gradius3_v.cpp delete mode 100644 src/mame/konami/lethal.h delete mode 100644 src/mame/konami/lethal_v.cpp delete mode 100644 src/mame/konami/moo.h delete mode 100644 src/mame/konami/moo_v.cpp delete mode 100644 src/mame/konami/qdrmfgp.h delete mode 100644 src/mame/konami/qdrmfgp_v.cpp delete mode 100644 src/mame/konami/rungun.h delete mode 100644 src/mame/konami/rungun_v.cpp delete mode 100644 src/mame/konami/simpsons.h delete mode 100644 src/mame/konami/simpsons_m.cpp delete mode 100644 src/mame/konami/simpsons_v.cpp delete mode 100644 src/mame/konami/spy.h delete mode 100644 src/mame/konami/spy_v.cpp delete mode 100644 src/mame/konami/xexex.h delete mode 100644 src/mame/konami/xexex_v.cpp diff --git a/src/mame/konami/88games.cpp b/src/mame/konami/88games.cpp index 59c3c67dd96..62b8970efdb 100644 --- a/src/mame/konami/88games.cpp +++ b/src/mame/konami/88games.cpp @@ -7,18 +7,163 @@ ***************************************************************************/ #include "emu.h" -#include "88games.h" +#include "k051960.h" +#include "k052109.h" +#include "konami_helper.h" + +#include "cpu/m6809/konami.h" #include "cpu/z80/z80.h" #include "machine/gen_latch.h" #include "machine/nvram.h" #include "machine/watchdog.h" +#include "sound/upd7759.h" #include "sound/ymopm.h" +#include "video/k051316.h" #include "emupal.h" #include "screen.h" #include "speaker.h" +namespace { + +class _88games_state : public driver_device +{ +public: + _88games_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_k052109(*this, "k052109"), + m_k051960(*this, "k051960"), + m_k051316(*this, "k051316"), + m_upd7759(*this, "upd%d", 1), + m_bank0000(*this, "bank0000"), + m_bank1000(*this, "bank1000"), + m_ram(*this, "ram") + { } + + void _88games(machine_config &config); + +private: + /* video-related */ + int m_k88games_priority = 0; + int m_videobank = 0; + int m_zoomreadroms = 0; + int m_speech_chip = 0; + + /* devices */ + required_device m_maincpu; + required_device m_audiocpu; + required_device m_k052109; + required_device m_k051960; + required_device m_k051316; + required_device_array m_upd7759; + + /* memory banks */ + required_memory_bank m_bank0000; + required_memory_bank m_bank1000; + + /* memory pointers */ + required_shared_ptr m_ram; + + uint8_t bankedram_r(offs_t offset); + void bankedram_w(offs_t offset, uint8_t data); + void k88games_5f84_w(uint8_t data); + void k88games_sh_irqtrigger_w(uint8_t data); + void speech_control_w(uint8_t data); + void speech_msg_w(uint8_t data); + uint8_t k052109_051960_r(offs_t offset); + void k052109_051960_w(offs_t offset, uint8_t data); + virtual void machine_start() override; + virtual void machine_reset() override; + uint32_t screen_update_88games(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); + K051316_CB_MEMBER(zoom_callback); + K052109_CB_MEMBER(tile_callback); + K051960_CB_MEMBER(sprite_callback); + void banking_callback(uint8_t data); + + void main_map(address_map &map); + void sound_map(address_map &map); +}; + + +/*************************************************************************** + + Callbacks for the K052109 + +***************************************************************************/ + +K052109_CB_MEMBER(_88games_state::tile_callback) +{ + static const int layer_colorbase[] = { 1024 / 16, 0 / 16, 256 / 16 }; + + *code |= ((*color & 0x0f) << 8) | (bank << 12); + *color = layer_colorbase[layer] + ((*color & 0xf0) >> 4); +} + + +/*************************************************************************** + + Callbacks for the K051960 + +***************************************************************************/ + +K051960_CB_MEMBER(_88games_state::sprite_callback) +{ + enum { sprite_colorbase = 512 / 16 }; + + *priority = (*color & 0x20) >> 5; /* ??? */ + *color = sprite_colorbase + (*color & 0x0f); +} + + +/*************************************************************************** + + Callbacks for the K051316 + +***************************************************************************/ + +K051316_CB_MEMBER(_88games_state::zoom_callback) +{ + enum { zoom_colorbase = 768 / 16 }; + + *code |= ((*color & 0x07) << 8); + *color = zoom_colorbase + ((*color & 0x38) >> 3) + ((*color & 0x80) >> 4); +} + +/*************************************************************************** + + Display refresh + +***************************************************************************/ + +uint32_t _88games_state::screen_update_88games(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) +{ + m_k052109->tilemap_update(); + + if (m_k88games_priority) + { + m_k052109->tilemap_draw(screen, bitmap, cliprect, 0, TILEMAP_DRAW_OPAQUE, 0); // tile 0 + m_k051960->k051960_sprites_draw(bitmap, cliprect, screen.priority(), 1, 1); + m_k052109->tilemap_draw(screen, bitmap, cliprect, 2, 0, 0); // tile 2 + m_k052109->tilemap_draw(screen, bitmap, cliprect, 1, 0, 0); // tile 1 + m_k051960->k051960_sprites_draw(bitmap, cliprect, screen.priority(), 0, 0); + m_k051316->zoom_draw(screen, bitmap, cliprect, 0, 0); + } + else + { + m_k052109->tilemap_draw(screen, bitmap, cliprect, 2, TILEMAP_DRAW_OPAQUE, 0); // tile 2 + m_k051316->zoom_draw(screen, bitmap, cliprect, 0, 0); + m_k051960->k051960_sprites_draw(bitmap, cliprect, screen.priority(), 0, 0); + m_k052109->tilemap_draw(screen, bitmap, cliprect, 1, 0, 0); // tile 1 + m_k051960->k051960_sprites_draw(bitmap, cliprect, screen.priority(), 1, 1); + m_k052109->tilemap_draw(screen, bitmap, cliprect, 0, 0, 0); // tile 0 + } + + return 0; +} + /************************************* * @@ -517,6 +662,8 @@ ROM_START( hypsptsp ) ROM_LOAD( "861a07.d", 0x010000, 0x10000, CRC(86731451) SHA1(c1410f6c7a23aa0c213878a6531d3e7eb966b0a4) ) ROM_END +} // anonymous namespace + /************************************* * diff --git a/src/mame/konami/88games.h b/src/mame/konami/88games.h deleted file mode 100644 index 94fd5f582f9..00000000000 --- a/src/mame/konami/88games.h +++ /dev/null @@ -1,80 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Nicola Salmoria -/************************************************************************* - - 88 Games - -*************************************************************************/ -#ifndef MAME_KONAMI_88GAMES_H -#define MAME_KONAMI_88GAMES_H - -#pragma once - -#include "cpu/m6809/konami.h" -#include "sound/upd7759.h" -#include "video/k051316.h" -#include "k051960.h" -#include "k052109.h" -#include "konami_helper.h" - -class _88games_state : public driver_device -{ -public: - _88games_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_k052109(*this, "k052109"), - m_k051960(*this, "k051960"), - m_k051316(*this, "k051316"), - m_upd7759(*this, "upd%d", 1), - m_bank0000(*this, "bank0000"), - m_bank1000(*this, "bank1000"), - m_ram(*this, "ram") - { } - - void _88games(machine_config &config); - -private: - /* video-related */ - int m_k88games_priority = 0; - int m_videobank = 0; - int m_zoomreadroms = 0; - int m_speech_chip = 0; - - /* devices */ - required_device m_maincpu; - required_device m_audiocpu; - required_device m_k052109; - required_device m_k051960; - required_device m_k051316; - required_device_array m_upd7759; - - /* memory banks */ - required_memory_bank m_bank0000; - required_memory_bank m_bank1000; - - /* memory pointers */ - required_shared_ptr m_ram; - - uint8_t bankedram_r(offs_t offset); - void bankedram_w(offs_t offset, uint8_t data); - void k88games_5f84_w(uint8_t data); - void k88games_sh_irqtrigger_w(uint8_t data); - void speech_control_w(uint8_t data); - void speech_msg_w(uint8_t data); - uint8_t k052109_051960_r(offs_t offset); - void k052109_051960_w(offs_t offset, uint8_t data); - virtual void machine_start() override; - virtual void machine_reset() override; - uint32_t screen_update_88games(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - K051316_CB_MEMBER(zoom_callback); - K052109_CB_MEMBER(tile_callback); - K051960_CB_MEMBER(sprite_callback); - void banking_callback(uint8_t data); - - void main_map(address_map &map); - void sound_map(address_map &map); -}; - -#endif // MAME_KONAMI_88GAMES_H diff --git a/src/mame/konami/88games_v.cpp b/src/mame/konami/88games_v.cpp deleted file mode 100644 index 2f47bc7fe53..00000000000 --- a/src/mame/konami/88games_v.cpp +++ /dev/null @@ -1,83 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Nicola Salmoria - -#include "emu.h" -#include "88games.h" -#include "screen.h" - - -/*************************************************************************** - - Callbacks for the K052109 - -***************************************************************************/ - -K052109_CB_MEMBER(_88games_state::tile_callback) -{ - static const int layer_colorbase[] = { 1024 / 16, 0 / 16, 256 / 16 }; - - *code |= ((*color & 0x0f) << 8) | (bank << 12); - *color = layer_colorbase[layer] + ((*color & 0xf0) >> 4); -} - - -/*************************************************************************** - - Callbacks for the K051960 - -***************************************************************************/ - -K051960_CB_MEMBER(_88games_state::sprite_callback) -{ - enum { sprite_colorbase = 512 / 16 }; - - *priority = (*color & 0x20) >> 5; /* ??? */ - *color = sprite_colorbase + (*color & 0x0f); -} - - -/*************************************************************************** - - Callbacks for the K051316 - -***************************************************************************/ - -K051316_CB_MEMBER(_88games_state::zoom_callback) -{ - enum { zoom_colorbase = 768 / 16 }; - - *code |= ((*color & 0x07) << 8); - *color = zoom_colorbase + ((*color & 0x38) >> 3) + ((*color & 0x80) >> 4); -} - -/*************************************************************************** - - Display refresh - -***************************************************************************/ - -uint32_t _88games_state::screen_update_88games(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - m_k052109->tilemap_update(); - - if (m_k88games_priority) - { - m_k052109->tilemap_draw(screen, bitmap, cliprect, 0, TILEMAP_DRAW_OPAQUE, 0); // tile 0 - m_k051960->k051960_sprites_draw(bitmap, cliprect, screen.priority(), 1, 1); - m_k052109->tilemap_draw(screen, bitmap, cliprect, 2, 0, 0); // tile 2 - m_k052109->tilemap_draw(screen, bitmap, cliprect, 1, 0, 0); // tile 1 - m_k051960->k051960_sprites_draw(bitmap, cliprect, screen.priority(), 0, 0); - m_k051316->zoom_draw(screen, bitmap, cliprect, 0, 0); - } - else - { - m_k052109->tilemap_draw(screen, bitmap, cliprect, 2, TILEMAP_DRAW_OPAQUE, 0); // tile 2 - m_k051316->zoom_draw(screen, bitmap, cliprect, 0, 0); - m_k051960->k051960_sprites_draw(bitmap, cliprect, screen.priority(), 0, 0); - m_k052109->tilemap_draw(screen, bitmap, cliprect, 1, 0, 0); // tile 1 - m_k051960->k051960_sprites_draw(bitmap, cliprect, screen.priority(), 1, 1); - m_k052109->tilemap_draw(screen, bitmap, cliprect, 0, 0, 0); // tile 0 - } - - return 0; -} diff --git a/src/mame/konami/asterix.cpp b/src/mame/konami/asterix.cpp index ad9c6f198a0..d115d0c7f68 100644 --- a/src/mame/konami/asterix.cpp +++ b/src/mame/konami/asterix.cpp @@ -13,8 +13,12 @@ TODO: ***************************************************************************/ #include "emu.h" -#include "asterix.h" + +#include "k053251.h" +#include "k054156_k054157_k056832.h" +#include "k053244_k053245.h" #include "konamipt.h" +#include "konami_helper.h" #include "cpu/m68000/m68000.h" #include "cpu/z80/z80.h" @@ -26,6 +30,165 @@ TODO: #include "speaker.h" +namespace { + +class asterix_state : public driver_device +{ +public: + asterix_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_k056832(*this, "k056832"), + m_k053244(*this, "k053244"), + m_k053251(*this, "k053251") + { } + + void asterix(machine_config &config); + +private: + virtual void machine_start() override; + virtual void machine_reset() override; + + void main_map(address_map &map); + void sound_map(address_map &map); + + void control2_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); + void sound_arm_nmi_w(uint8_t data); + void z80_nmi_w(int state); + void sound_irq_w(uint16_t data); + void protection_w(address_space &space, offs_t offset, uint16_t data, uint16_t mem_mask = ~0); + void asterix_spritebank_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); + uint32_t screen_update_asterix(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); + INTERRUPT_GEN_MEMBER(asterix_interrupt); + K05324X_CB_MEMBER(sprite_callback); + K056832_CB_MEMBER(tile_callback); + void reset_spritebank(); + + /* video-related */ + int m_sprite_colorbase = 0; + int m_layer_colorbase[4]{}; + int m_layerpri[3]{}; + uint16_t m_spritebank = 0U; + int m_tilebanks[4]{}; + int m_spritebanks[4]{}; + + /* misc */ + uint16_t m_prot[2]{}; + emu_timer *m_nmi_blocked = nullptr; + + /* devices */ + required_device m_maincpu; + required_device m_audiocpu; + required_device m_k056832; + required_device m_k053244; + required_device m_k053251; +}; + + +void asterix_state::reset_spritebank() +{ + m_k053244->bankselect(m_spritebank & 7); + m_spritebanks[0] = (m_spritebank << 12) & 0x7000; + m_spritebanks[1] = (m_spritebank << 9) & 0x7000; + m_spritebanks[2] = (m_spritebank << 6) & 0x7000; + m_spritebanks[3] = (m_spritebank << 3) & 0x7000; +} + +void asterix_state::asterix_spritebank_w(offs_t offset, uint16_t data, uint16_t mem_mask) +{ + COMBINE_DATA(&m_spritebank); + reset_spritebank(); +} + +K05324X_CB_MEMBER(asterix_state::sprite_callback) +{ + int pri = (*color & 0x00e0) >> 2; + if (pri <= m_layerpri[2]) + *priority = 0; + else if (pri > m_layerpri[2] && pri <= m_layerpri[1]) + *priority = 0xf0; + else if (pri > m_layerpri[1] && pri <= m_layerpri[0]) + *priority = 0xf0 | 0xcc; + else + *priority = 0xf0 | 0xcc | 0xaa; + *color = m_sprite_colorbase | (*color & 0x001f); + *code = (*code & 0xfff) | m_spritebanks[(*code >> 12) & 3]; +} + + +K056832_CB_MEMBER(asterix_state::tile_callback) +{ + *flags = *code & 0x1000 ? TILE_FLIPX : 0; + *color = (m_layer_colorbase[layer] + ((*code & 0xe000) >> 13)) & 0x7f; + *code = (*code & 0x03ff) | m_tilebanks[(*code >> 10) & 3]; +} + +uint32_t asterix_state::screen_update_asterix(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) +{ + static const int K053251_CI[4] = { k053251_device::CI0, k053251_device::CI2, k053251_device::CI3, k053251_device::CI4 }; + int layer[3], plane, new_colorbase; + + /* Layer offsets are different if horizontally flipped */ + if (m_k056832->read_register(0x0) & 0x10) + { + m_k056832->set_layer_offs(0, 89 - 176, 0); + m_k056832->set_layer_offs(1, 91 - 176, 0); + m_k056832->set_layer_offs(2, 89 - 176, 0); + m_k056832->set_layer_offs(3, 95 - 176, 0); + } + else + { + m_k056832->set_layer_offs(0, 89, 0); + m_k056832->set_layer_offs(1, 91, 0); + m_k056832->set_layer_offs(2, 89, 0); + m_k056832->set_layer_offs(3, 95, 0); + } + + + m_tilebanks[0] = (m_k056832->get_lookup(0) << 10); + m_tilebanks[1] = (m_k056832->get_lookup(1) << 10); + m_tilebanks[2] = (m_k056832->get_lookup(2) << 10); + m_tilebanks[3] = (m_k056832->get_lookup(3) << 10); + + // update color info and refresh tilemaps + m_sprite_colorbase = m_k053251->get_palette_index(k053251_device::CI1); + + for (plane = 0; plane < 4; plane++) + { + new_colorbase = m_k053251->get_palette_index(K053251_CI[plane]); + if (m_layer_colorbase[plane] != new_colorbase) + { + m_layer_colorbase[plane] = new_colorbase; + m_k056832->mark_plane_dirty(plane); + } + } + + layer[0] = 0; + m_layerpri[0] = m_k053251->get_priority(k053251_device::CI0); + layer[1] = 1; + m_layerpri[1] = m_k053251->get_priority(k053251_device::CI2); + layer[2] = 3; + m_layerpri[2] = m_k053251->get_priority(k053251_device::CI4); + + konami_sortlayers3(layer, m_layerpri); + + screen.priority().fill(0, cliprect); + bitmap.fill(0, cliprect); + + m_k056832->tilemap_draw(screen, bitmap, cliprect, layer[0], K056832_DRAW_FLAG_MIRROR, 1); + m_k056832->tilemap_draw(screen, bitmap, cliprect, layer[1], K056832_DRAW_FLAG_MIRROR, 2); + m_k056832->tilemap_draw(screen, bitmap, cliprect, layer[2], K056832_DRAW_FLAG_MIRROR, 4); + +/* this isn't supported anymore and it is unsure if still needed; keeping here for reference + pdrawgfx_shadow_lowpri = 1; fix shadows in front of feet */ + m_k053244->sprites_draw(bitmap, cliprect, screen.priority()); + + m_k056832->tilemap_draw(screen, bitmap, cliprect, 2, K056832_DRAW_FLAG_MIRROR, 0); + return 0; +} + + void asterix_state::control2_w(offs_t offset, uint16_t data, uint16_t mem_mask) { if (ACCESSING_BITS_0_7) @@ -384,6 +547,8 @@ ROM_START( asterixj ) ROM_LOAD( "asterixj.nv", 0x0000, 0x0080, CRC(84229f2c) SHA1(34c7491c731fbf741dfd53bfc559d91201ccfb03) ) ROM_END +} // anonymous namespace + GAME( 1992, asterix, 0, asterix, asterix, asterix_state, empty_init, ROT0, "Konami", "Asterix (ver EAD)", MACHINE_IMPERFECT_GRAPHICS | MACHINE_SUPPORTS_SAVE ) GAME( 1992, asterixeac, asterix, asterix, asterix, asterix_state, empty_init, ROT0, "Konami", "Asterix (ver EAC)", MACHINE_IMPERFECT_GRAPHICS | MACHINE_SUPPORTS_SAVE ) diff --git a/src/mame/konami/asterix.h b/src/mame/konami/asterix.h deleted file mode 100644 index afab9140c56..00000000000 --- a/src/mame/konami/asterix.h +++ /dev/null @@ -1,71 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Olivier Galibert -/************************************************************************* - - Asterix - -*************************************************************************/ -#ifndef MAME_KONAMI_ASTERIX_H -#define MAME_KONAMI_ASTERIX_H - -#pragma once - -#include "k053251.h" -#include "k054156_k054157_k056832.h" -#include "k053244_k053245.h" -#include "konami_helper.h" - -class asterix_state : public driver_device -{ -public: - asterix_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_k056832(*this, "k056832"), - m_k053244(*this, "k053244"), - m_k053251(*this, "k053251") - { } - - void asterix(machine_config &config); - -private: - virtual void machine_start() override; - virtual void machine_reset() override; - - void main_map(address_map &map); - void sound_map(address_map &map); - - void control2_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); - void sound_arm_nmi_w(uint8_t data); - void z80_nmi_w(int state); - void sound_irq_w(uint16_t data); - void protection_w(address_space &space, offs_t offset, uint16_t data, uint16_t mem_mask = ~0); - void asterix_spritebank_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); - uint32_t screen_update_asterix(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - INTERRUPT_GEN_MEMBER(asterix_interrupt); - K05324X_CB_MEMBER(sprite_callback); - K056832_CB_MEMBER(tile_callback); - void reset_spritebank(); - - /* video-related */ - int m_sprite_colorbase = 0; - int m_layer_colorbase[4]{}; - int m_layerpri[3]{}; - uint16_t m_spritebank = 0U; - int m_tilebanks[4]{}; - int m_spritebanks[4]{}; - - /* misc */ - uint16_t m_prot[2]{}; - emu_timer *m_nmi_blocked = nullptr; - - /* devices */ - required_device m_maincpu; - required_device m_audiocpu; - required_device m_k056832; - required_device m_k053244; - required_device m_k053251; -}; - -#endif // MAME_KONAMI_ASTERIX_H diff --git a/src/mame/konami/asterix_v.cpp b/src/mame/konami/asterix_v.cpp deleted file mode 100644 index 815c97473ae..00000000000 --- a/src/mame/konami/asterix_v.cpp +++ /dev/null @@ -1,108 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Olivier Galibert -#include "emu.h" -#include "asterix.h" -#include "screen.h" - - -void asterix_state::reset_spritebank() -{ - m_k053244->bankselect(m_spritebank & 7); - m_spritebanks[0] = (m_spritebank << 12) & 0x7000; - m_spritebanks[1] = (m_spritebank << 9) & 0x7000; - m_spritebanks[2] = (m_spritebank << 6) & 0x7000; - m_spritebanks[3] = (m_spritebank << 3) & 0x7000; -} - -void asterix_state::asterix_spritebank_w(offs_t offset, uint16_t data, uint16_t mem_mask) -{ - COMBINE_DATA(&m_spritebank); - reset_spritebank(); -} - -K05324X_CB_MEMBER(asterix_state::sprite_callback) -{ - int pri = (*color & 0x00e0) >> 2; - if (pri <= m_layerpri[2]) - *priority = 0; - else if (pri > m_layerpri[2] && pri <= m_layerpri[1]) - *priority = 0xf0; - else if (pri > m_layerpri[1] && pri <= m_layerpri[0]) - *priority = 0xf0 | 0xcc; - else - *priority = 0xf0 | 0xcc | 0xaa; - *color = m_sprite_colorbase | (*color & 0x001f); - *code = (*code & 0xfff) | m_spritebanks[(*code >> 12) & 3]; -} - - -K056832_CB_MEMBER(asterix_state::tile_callback) -{ - *flags = *code & 0x1000 ? TILE_FLIPX : 0; - *color = (m_layer_colorbase[layer] + ((*code & 0xe000) >> 13)) & 0x7f; - *code = (*code & 0x03ff) | m_tilebanks[(*code >> 10) & 3]; -} - -uint32_t asterix_state::screen_update_asterix(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - static const int K053251_CI[4] = { k053251_device::CI0, k053251_device::CI2, k053251_device::CI3, k053251_device::CI4 }; - int layer[3], plane, new_colorbase; - - /* Layer offsets are different if horizontally flipped */ - if (m_k056832->read_register(0x0) & 0x10) - { - m_k056832->set_layer_offs(0, 89 - 176, 0); - m_k056832->set_layer_offs(1, 91 - 176, 0); - m_k056832->set_layer_offs(2, 89 - 176, 0); - m_k056832->set_layer_offs(3, 95 - 176, 0); - } - else - { - m_k056832->set_layer_offs(0, 89, 0); - m_k056832->set_layer_offs(1, 91, 0); - m_k056832->set_layer_offs(2, 89, 0); - m_k056832->set_layer_offs(3, 95, 0); - } - - - m_tilebanks[0] = (m_k056832->get_lookup(0) << 10); - m_tilebanks[1] = (m_k056832->get_lookup(1) << 10); - m_tilebanks[2] = (m_k056832->get_lookup(2) << 10); - m_tilebanks[3] = (m_k056832->get_lookup(3) << 10); - - // update color info and refresh tilemaps - m_sprite_colorbase = m_k053251->get_palette_index(k053251_device::CI1); - - for (plane = 0; plane < 4; plane++) - { - new_colorbase = m_k053251->get_palette_index(K053251_CI[plane]); - if (m_layer_colorbase[plane] != new_colorbase) - { - m_layer_colorbase[plane] = new_colorbase; - m_k056832->mark_plane_dirty(plane); - } - } - - layer[0] = 0; - m_layerpri[0] = m_k053251->get_priority(k053251_device::CI0); - layer[1] = 1; - m_layerpri[1] = m_k053251->get_priority(k053251_device::CI2); - layer[2] = 3; - m_layerpri[2] = m_k053251->get_priority(k053251_device::CI4); - - konami_sortlayers3(layer, m_layerpri); - - screen.priority().fill(0, cliprect); - bitmap.fill(0, cliprect); - - m_k056832->tilemap_draw(screen, bitmap, cliprect, layer[0], K056832_DRAW_FLAG_MIRROR, 1); - m_k056832->tilemap_draw(screen, bitmap, cliprect, layer[1], K056832_DRAW_FLAG_MIRROR, 2); - m_k056832->tilemap_draw(screen, bitmap, cliprect, layer[2], K056832_DRAW_FLAG_MIRROR, 4); - -/* this isn't supported anymore and it is unsure if still needed; keeping here for reference - pdrawgfx_shadow_lowpri = 1; fix shadows in front of feet */ - m_k053244->sprites_draw(bitmap, cliprect, screen.priority()); - - m_k056832->tilemap_draw(screen, bitmap, cliprect, 2, K056832_DRAW_FLAG_MIRROR, 0); - return 0; -} diff --git a/src/mame/konami/bishi.cpp b/src/mame/konami/bishi.cpp index e2cc16a07e8..37dea66da19 100644 --- a/src/mame/konami/bishi.cpp +++ b/src/mame/konami/bishi.cpp @@ -86,12 +86,127 @@ Notes: ***************************************************************************/ #include "emu.h" -#include "bishi.h" + +#include "k054156_k054157_k056832.h" +#include "k054338.h" +#include "k055555.h" +#include "konami_helper.h" #include "cpu/m68000/m68000.h" +#include "machine/timer.h" #include "sound/ymz280b.h" +#include "emupal.h" +#include "screen.h" #include "speaker.h" +namespace { + +class bishi_state : public driver_device +{ +public: + bishi_state(const machine_config &mconfig, device_type type, const char *tag) : + driver_device(mconfig, type, tag), + m_maincpu(*this, "maincpu"), + m_k056832(*this, "k056832"), + m_k054338(*this, "k054338"), + m_k055555(*this, "k055555"), + m_palette(*this, "palette"), + m_screen(*this, "screen") + { } + + void bishi(machine_config &config); + +private: + uint16_t control_r(); + void control_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); + void control2_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); + uint16_t bishi_mirror_r(offs_t offset); + uint16_t bishi_K056832_rom_r(offs_t offset); + uint32_t screen_update_bishi(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); + TIMER_DEVICE_CALLBACK_MEMBER(bishi_scanline); + K056832_CB_MEMBER(tile_callback); + + void main_map(address_map &map); +protected: + virtual void machine_start() override; + virtual void machine_reset() override; + virtual void video_start() override; +private: + /* misc */ + uint16_t m_cur_control = 0U; + uint16_t m_cur_control2 = 0U; + + /* video-related */ + int m_layer_colorbase[4]{}; + + /* devices */ + required_device m_maincpu; + required_device m_k056832; + required_device m_k054338; + required_device m_k055555; + required_device m_palette; + required_device m_screen; +}; + + +K056832_CB_MEMBER(bishi_state::tile_callback) +{ +// *code -= '0'; +// *color = m_layer_colorbase[layer] | (*color>>2 & 0x0f); +// K055555GX_decode_vmixcolor(layer, color); +// if (*color) osd_printf_debug("plane %x col %x [55 %x %x]\n", layer, *color, layer_colorbase[layer], K055555_get_palette_index(layer)); + + *color = m_layer_colorbase[layer] + ((*color & 0xf0)); +} + +void bishi_state::video_start() +{ + assert(m_screen->format() == BITMAP_FORMAT_RGB32); + + m_k056832->set_layer_association(0); + + m_k056832->set_layer_offs(0, -2, 0); + m_k056832->set_layer_offs(1, 2, 0); + m_k056832->set_layer_offs(2, 4, 0); + m_k056832->set_layer_offs(3, 6, 0); + + // the 55555 is set to "0x10, 0x11, 0x12, 0x13", but these values are almost correct... + m_layer_colorbase[0] = 0x00; + m_layer_colorbase[1] = 0x40; // this one is wrong + m_layer_colorbase[2] = 0x80; + m_layer_colorbase[3] = 0xc0; +} + +uint32_t bishi_state::screen_update_bishi(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) +{ + int layers[4], layerpri[4], i;/*, old;*/ +/* int bg_colorbase, new_colorbase, plane, dirty; */ + static const int pris[4] = { K55_PRIINP_0, K55_PRIINP_3, K55_PRIINP_6, K55_PRIINP_7 }; + static const int enables[4] = { K55_INP_VRAM_A, K55_INP_VRAM_B, K55_INP_VRAM_C, K55_INP_VRAM_D }; + + m_k054338->update_all_shadows(0, *m_palette); + m_k054338->fill_solid_bg(bitmap, cliprect); + + for (i = 0; i < 4; i++) + { + layers[i] = i; + layerpri[i] = m_k055555->K055555_read_register(pris[i]); + } + + konami_sortlayers4(layers, layerpri); + + screen.priority().fill(0, cliprect); + + for (i = 0; i < 4; i++) + { + if (m_k055555->K055555_read_register(K55_INPUT_ENABLES) & enables[layers[i]]) + { + m_k056832->tilemap_draw(screen, bitmap, cliprect, layers[i], 0, 1 << i); + } + } + return 0; +} + uint16_t bishi_state::control_r() { @@ -376,6 +491,9 @@ void bishi_state::machine_reset() void bishi_state::bishi(machine_config &config) { + constexpr XTAL CPU_CLOCK = 24_MHz_XTAL / 2; + constexpr XTAL SOUND_CLOCK = 16.9344_MHz_XTAL; + /* basic machine hardware */ M68000(config, m_maincpu, CPU_CLOCK); /* 12MHz (24MHz OSC / 2 ) */ m_maincpu->set_addrmap(AS_PROGRAM, &bishi_state::main_map); @@ -502,6 +620,8 @@ ROM_START( sbishika ) ROM_LOAD( "675kaa04.8f", 0x180000, 0x080000, CRC(ebcbd813) SHA1(d67540d0ea303f09866f4a766e2d5162f05cd4ac) ) ROM_END +} // anonymous namespace + GAME( 1996, bishi, 0, bishi, bishi, bishi_state, empty_init, ROT0, "Konami", "Bishi Bashi Champ Mini Game Senshuken (ver JAA, 3 Players)", MACHINE_IMPERFECT_GRAPHICS | MACHINE_SUPPORTS_SAVE ) GAME( 1998, sbishi, 0, bishi, bishi2p, bishi_state, empty_init, ROT0, "Konami", "Super Bishi Bashi Champ (ver JAA, 2 Players)", MACHINE_IMPERFECT_GRAPHICS | MACHINE_SUPPORTS_SAVE ) GAME( 1998, sbishik, sbishi, bishi, bishi, bishi_state, empty_init, ROT0, "Konami", "Super Bishi Bashi Champ (ver KAB, 3 Players)", MACHINE_IMPERFECT_GRAPHICS | MACHINE_SUPPORTS_SAVE ) diff --git a/src/mame/konami/bishi.h b/src/mame/konami/bishi.h deleted file mode 100644 index a85007827a6..00000000000 --- a/src/mame/konami/bishi.h +++ /dev/null @@ -1,71 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:R. Belmont -/************************************************************************* - - Bishi Bashi Champ Mini Game Senshuken - -*************************************************************************/ -#ifndef MAME_KONAMI_BISHI_H -#define MAME_KONAMI_BISHI_H - -#pragma once - -#include "machine/timer.h" -#include "k054156_k054157_k056832.h" -#include "k055555.h" -#include "k054338.h" -#include "konami_helper.h" -#include "emupal.h" -#include "screen.h" - -#define CPU_CLOCK (XTAL(24'000'000) / 2) /* 68000 clock */ -#define SOUND_CLOCK XTAL(16'934'400) /* YMZ280 clock */ - -class bishi_state : public driver_device -{ -public: - bishi_state(const machine_config &mconfig, device_type type, const char *tag) : - driver_device(mconfig, type, tag), - m_maincpu(*this, "maincpu"), - m_k056832(*this, "k056832"), - m_k054338(*this, "k054338"), - m_k055555(*this, "k055555"), - m_palette(*this, "palette"), - m_screen(*this, "screen") - { } - - void bishi(machine_config &config); - -private: - uint16_t control_r(); - void control_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); - void control2_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); - uint16_t bishi_mirror_r(offs_t offset); - uint16_t bishi_K056832_rom_r(offs_t offset); - uint32_t screen_update_bishi(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); - TIMER_DEVICE_CALLBACK_MEMBER(bishi_scanline); - K056832_CB_MEMBER(tile_callback); - - void main_map(address_map &map); -protected: - virtual void machine_start() override; - virtual void machine_reset() override; - virtual void video_start() override; -private: - /* misc */ - uint16_t m_cur_control = 0U; - uint16_t m_cur_control2 = 0U; - - /* video-related */ - int m_layer_colorbase[4]{}; - - /* devices */ - required_device m_maincpu; - required_device m_k056832; - required_device m_k054338; - required_device m_k055555; - required_device m_palette; - required_device m_screen; -}; - -#endif // MAME_KONAMI_BISHI_H diff --git a/src/mame/konami/bishi_v.cpp b/src/mame/konami/bishi_v.cpp deleted file mode 100644 index 54bd0fb4a23..00000000000 --- a/src/mame/konami/bishi_v.cpp +++ /dev/null @@ -1,72 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:R. Belmont -/*************************************************************************** - - Bishi Bashi Champ Mini Game Senshuken - (c) 1996 Konami - - Video hardware emulation. - -***************************************************************************/ - -#include "emu.h" -#include "bishi.h" - - -K056832_CB_MEMBER(bishi_state::tile_callback) -{ -// *code -= '0'; -// *color = m_layer_colorbase[layer] | (*color>>2 & 0x0f); -// K055555GX_decode_vmixcolor(layer, color); -// if (*color) osd_printf_debug("plane %x col %x [55 %x %x]\n", layer, *color, layer_colorbase[layer], K055555_get_palette_index(layer)); - - *color = m_layer_colorbase[layer] + ((*color & 0xf0)); -} - -void bishi_state::video_start() -{ - assert(m_screen->format() == BITMAP_FORMAT_RGB32); - - m_k056832->set_layer_association(0); - - m_k056832->set_layer_offs(0, -2, 0); - m_k056832->set_layer_offs(1, 2, 0); - m_k056832->set_layer_offs(2, 4, 0); - m_k056832->set_layer_offs(3, 6, 0); - - // the 55555 is set to "0x10, 0x11, 0x12, 0x13", but these values are almost correct... - m_layer_colorbase[0] = 0x00; - m_layer_colorbase[1] = 0x40; // this one is wrong - m_layer_colorbase[2] = 0x80; - m_layer_colorbase[3] = 0xc0; -} - -uint32_t bishi_state::screen_update_bishi(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) -{ - int layers[4], layerpri[4], i;/*, old;*/ -/* int bg_colorbase, new_colorbase, plane, dirty; */ - static const int pris[4] = { K55_PRIINP_0, K55_PRIINP_3, K55_PRIINP_6, K55_PRIINP_7 }; - static const int enables[4] = { K55_INP_VRAM_A, K55_INP_VRAM_B, K55_INP_VRAM_C, K55_INP_VRAM_D }; - - m_k054338->update_all_shadows(0, *m_palette); - m_k054338->fill_solid_bg(bitmap, cliprect); - - for (i = 0; i < 4; i++) - { - layers[i] = i; - layerpri[i] = m_k055555->K055555_read_register(pris[i]); - } - - konami_sortlayers4(layers, layerpri); - - screen.priority().fill(0, cliprect); - - for (i = 0; i < 4; i++) - { - if (m_k055555->K055555_read_register(K55_INPUT_ENABLES) & enables[layers[i]]) - { - m_k056832->tilemap_draw(screen, bitmap, cliprect, layers[i], 0, 1 << i); - } - } - return 0; -} diff --git a/src/mame/konami/chqflag.cpp b/src/mame/konami/chqflag.cpp index f9e85941c5a..bdac7255fe3 100644 --- a/src/mame/konami/chqflag.cpp +++ b/src/mame/konami/chqflag.cpp @@ -20,18 +20,141 @@ ***************************************************************************/ #include "emu.h" -#include "chqflag.h" + +#include "k051733.h" +#include "k051960.h" #include "konamipt.h" +#include "konami_helper.h" #include "cpu/z80/z80.h" #include "cpu/m6809/konami.h" +#include "machine/bankdev.h" #include "machine/gen_latch.h" #include "machine/watchdog.h" +#include "sound/k007232.h" #include "sound/ymopm.h" +#include "video/k051316.h" +#include "emupal.h" #include "speaker.h" #include "chqflag.lh" +namespace { + +class chqflag_state : public driver_device +{ +public: + chqflag_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_bank1000(*this, "bank1000") + , m_k007232(*this, "k007232_%u", 1) + , m_k051960(*this, "k051960") + , m_k051316(*this, "k051316_%u", 1) + , m_palette(*this, "palette") + , m_rombank(*this, "rombank") + { + } + + void chqflag(machine_config &config); + +private: + template uint8_t k051316_ramrom_r(offs_t offset); + void chqflag_bankswitch_w(uint8_t data); + void chqflag_vreg_w(uint8_t data); + void select_analog_ctrl_w(uint8_t data); + uint8_t analog_read_r(); + void k007232_bankswitch_w(uint8_t data); + void k007232_extvolume_w(uint8_t data); + void volume_callback0(uint8_t data); + void volume_callback1(uint8_t data); + K051316_CB_MEMBER(zoom_callback_1); + K051316_CB_MEMBER(zoom_callback_2); + K051960_CB_MEMBER(sprite_callback); + uint32_t screen_update_chqflag(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); + void bank1000_map(address_map &map); + void chqflag_map(address_map &map); + void chqflag_sound_map(address_map &map); +protected: + virtual void machine_start() override; + virtual void machine_reset() override; +private: + /* misc */ + int m_k051316_readroms = 0; + int m_last_vreg = 0; + int m_analog_ctrl = 0; + int m_accel = 0; + int m_wheel = 0; + + /* devices */ + required_device m_maincpu; + required_device m_audiocpu; + required_device m_bank1000; + required_device_array m_k007232; + required_device m_k051960; + required_device_array m_k051316; + required_device m_palette; + + /* memory pointers */ + required_memory_bank m_rombank; + void update_background_shadows(uint8_t data); +}; + + +/*************************************************************************** + + Callbacks for the K051960 + +***************************************************************************/ + +K051960_CB_MEMBER(chqflag_state::sprite_callback) +{ + enum { sprite_colorbase = 0 }; + + *priority = (*color & 0x10) ? 0 : GFX_PMASK_1; + *color = sprite_colorbase + (*color & 0x0f); +} + +/*************************************************************************** + + Callbacks for the K051316 + +***************************************************************************/ + +K051316_CB_MEMBER(chqflag_state::zoom_callback_1) +{ + enum { zoom_colorbase_1 = 256 / 16 }; + + *code |= ((*color & 0x03) << 8); + *color = zoom_colorbase_1 + ((*color & 0x3c) >> 2); +} + +K051316_CB_MEMBER(chqflag_state::zoom_callback_2) +{ + enum { zoom_colorbase_2 = 512 / 256 }; + + *code |= ((*color & 0x0f) << 8); + *color = zoom_colorbase_2 + ((*color & 0x10) >> 4); +} + +/*************************************************************************** + + Display Refresh + +***************************************************************************/ + +uint32_t chqflag_state::screen_update_chqflag(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) +{ + screen.priority().fill(0, cliprect); + + m_k051316[1]->zoom_draw(screen, bitmap, cliprect, TILEMAP_DRAW_LAYER1, 0); + m_k051316[1]->zoom_draw(screen, bitmap, cliprect, TILEMAP_DRAW_LAYER0, 1); + m_k051960->k051960_sprites_draw(bitmap, cliprect, screen.priority(), -1, -1); + m_k051316[0]->zoom_draw(screen, bitmap, cliprect, 0, 0); + return 0; +} + /* these trampolines are less confusing than nested address_map_bank_devices */ template @@ -440,6 +563,8 @@ ROM_START( chqflagj ) ROM_LOAD( "717e09", 0x000000, 0x080000, CRC(d74e857d) SHA1(00c851c857650d67fc4caccea4461d99be4acb3c) ) ROM_END +} // anonymous namespace + // YEAR NAME PARENT MACHINE INPUT CLASS INIT MONITOR COMPANY FULLNAME FLAGS LAYOUT GAMEL( 1988, chqflag, 0, chqflag, chqflag, chqflag_state, empty_init, ROT90, "Konami", "Chequered Flag", MACHINE_UNEMULATED_PROTECTION | MACHINE_IMPERFECT_COLORS | MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE, layout_chqflag ) diff --git a/src/mame/konami/chqflag.h b/src/mame/konami/chqflag.h deleted file mode 100644 index a3b72fd94e3..00000000000 --- a/src/mame/konami/chqflag.h +++ /dev/null @@ -1,81 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Nicola Salmoria, Manuel Abadia -/************************************************************************* - - Chequered Flag - -*************************************************************************/ -#ifndef MAME_KONAMI_CHQFLAG_H -#define MAME_KONAMI_CHQFLAG_H - -#pragma once - -#include "machine/bankdev.h" -#include "sound/k007232.h" -#include "k051960.h" -#include "video/k051316.h" -#include "k051733.h" -#include "konami_helper.h" -#include "emupal.h" - -class chqflag_state : public driver_device -{ -public: - chqflag_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_bank1000(*this, "bank1000") - , m_k007232(*this, "k007232_%u", 1) - , m_k051960(*this, "k051960") - , m_k051316(*this, "k051316_%u", 1) - , m_palette(*this, "palette") - , m_rombank(*this, "rombank") - { - } - - void chqflag(machine_config &config); - -private: - template uint8_t k051316_ramrom_r(offs_t offset); - void chqflag_bankswitch_w(uint8_t data); - void chqflag_vreg_w(uint8_t data); - void select_analog_ctrl_w(uint8_t data); - uint8_t analog_read_r(); - void k007232_bankswitch_w(uint8_t data); - void k007232_extvolume_w(uint8_t data); - void volume_callback0(uint8_t data); - void volume_callback1(uint8_t data); - K051316_CB_MEMBER(zoom_callback_1); - K051316_CB_MEMBER(zoom_callback_2); - K051960_CB_MEMBER(sprite_callback); - uint32_t screen_update_chqflag(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - void bank1000_map(address_map &map); - void chqflag_map(address_map &map); - void chqflag_sound_map(address_map &map); -protected: - virtual void machine_start() override; - virtual void machine_reset() override; -private: - /* misc */ - int m_k051316_readroms = 0; - int m_last_vreg = 0; - int m_analog_ctrl = 0; - int m_accel = 0; - int m_wheel = 0; - - /* devices */ - required_device m_maincpu; - required_device m_audiocpu; - required_device m_bank1000; - required_device_array m_k007232; - required_device m_k051960; - required_device_array m_k051316; - required_device m_palette; - - /* memory pointers */ - required_memory_bank m_rombank; - void update_background_shadows(uint8_t data); -}; - -#endif // MAME_KONAMI_CHQFLAG_H diff --git a/src/mame/konami/chqflag_v.cpp b/src/mame/konami/chqflag_v.cpp deleted file mode 100644 index a4e6c0e561b..00000000000 --- a/src/mame/konami/chqflag_v.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Nicola Salmoria, Manuel Abadia -/*************************************************************************** - - video.c - - Functions to emulate the video hardware of the machine. - -***************************************************************************/ - -#include "emu.h" -#include "chqflag.h" -#include "screen.h" - - -/*************************************************************************** - - Callbacks for the K051960 - -***************************************************************************/ - -K051960_CB_MEMBER(chqflag_state::sprite_callback) -{ - enum { sprite_colorbase = 0 }; - - *priority = (*color & 0x10) ? 0 : GFX_PMASK_1; - *color = sprite_colorbase + (*color & 0x0f); -} - -/*************************************************************************** - - Callbacks for the K051316 - -***************************************************************************/ - -K051316_CB_MEMBER(chqflag_state::zoom_callback_1) -{ - enum { zoom_colorbase_1 = 256 / 16 }; - - *code |= ((*color & 0x03) << 8); - *color = zoom_colorbase_1 + ((*color & 0x3c) >> 2); -} - -K051316_CB_MEMBER(chqflag_state::zoom_callback_2) -{ - enum { zoom_colorbase_2 = 512 / 256 }; - - *code |= ((*color & 0x0f) << 8); - *color = zoom_colorbase_2 + ((*color & 0x10) >> 4); -} - -/*************************************************************************** - - Display Refresh - -***************************************************************************/ - -uint32_t chqflag_state::screen_update_chqflag(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - screen.priority().fill(0, cliprect); - - m_k051316[1]->zoom_draw(screen, bitmap, cliprect, TILEMAP_DRAW_LAYER1, 0); - m_k051316[1]->zoom_draw(screen, bitmap, cliprect, TILEMAP_DRAW_LAYER0, 1); - m_k051960->k051960_sprites_draw(bitmap, cliprect, screen.priority(), -1, -1); - m_k051316[0]->zoom_draw(screen, bitmap, cliprect, 0, 0); - return 0; -} diff --git a/src/mame/konami/crimfght.cpp b/src/mame/konami/crimfght.cpp index 863977092eb..27f7c620d0c 100644 --- a/src/mame/konami/crimfght.cpp +++ b/src/mame/konami/crimfght.cpp @@ -14,14 +14,140 @@ ***************************************************************************/ #include "emu.h" + +#include "k051960.h" +#include "k052109.h" #include "konamipt.h" -#include "crimfght.h" +#include "cpu/m6809/konami.h" #include "cpu/z80/z80.h" +#include "machine/bankdev.h" +#include "machine/gen_latch.h" #include "machine/watchdog.h" +#include "sound/k007232.h" #include "sound/ymopm.h" +#include "emupal.h" #include "speaker.h" +namespace { + +class crimfght_state : public driver_device +{ +public: + crimfght_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_bank0000(*this, "bank0000"), + m_k007232(*this, "k007232"), + m_k052109(*this, "k052109"), + m_k051960(*this, "k051960"), + m_palette(*this, "palette"), + m_soundlatch(*this, "soundlatch"), + m_rombank(*this, "rombank") + { } + + DECLARE_CUSTOM_INPUT_MEMBER(system_r); + void crimfght(machine_config &config); + +private: + /* devices */ + required_device m_maincpu; + required_device m_audiocpu; + required_device m_bank0000; + required_device m_k007232; + required_device m_k052109; + required_device m_k051960; + required_device m_palette; + required_device m_soundlatch; + required_memory_bank m_rombank; + + void crimfght_coin_w(uint8_t data); + void sound_w(uint8_t data); + uint8_t k052109_051960_r(offs_t offset); + void k052109_051960_w(offs_t offset, uint8_t data); + IRQ_CALLBACK_MEMBER(audiocpu_irq_ack); + void ym2151_ct_w(uint8_t data); + virtual void machine_start() override; + uint32_t screen_update_crimfght(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); + void volume_callback(uint8_t data); + K052109_CB_MEMBER(tile_callback); + K051960_CB_MEMBER(sprite_callback); + void banking_callback(uint8_t data); + + void bank0000_map(address_map &map); + void crimfght_map(address_map &map); + void crimfght_sound_map(address_map &map); + int m_woco = 0; + int m_rmrd = 0; + int m_init = 0; +}; + + +/*************************************************************************** + + Callbacks for the K052109 + +***************************************************************************/ + +K052109_CB_MEMBER(crimfght_state::tile_callback) +{ + *flags = (*color & 0x20) ? TILE_FLIPX : 0; + *code |= ((*color & 0x1f) << 8) | (bank << 13); + *color = layer * 4 + ((*color & 0xc0) >> 6); +} + +/*************************************************************************** + + Callbacks for the K051960 + +***************************************************************************/ + +K051960_CB_MEMBER(crimfght_state::sprite_callback) +{ + enum { sprite_colorbase = 256 / 16 }; + + /* The PROM allows for mixed priorities, where sprites would have */ + /* priority over text but not on one or both of the other two planes. */ + switch (*color & 0x70) + { + case 0x10: *priority = 0x00; break; /* over ABF */ + case 0x00: *priority = GFX_PMASK_4 ; break; /* over AB, not F */ + case 0x40: *priority = GFX_PMASK_4|GFX_PMASK_2 ; break; /* over A, not BF */ + case 0x20: + case 0x60: *priority = GFX_PMASK_4|GFX_PMASK_2|GFX_PMASK_1; break; /* over -, not ABF */ + case 0x50: *priority = GFX_PMASK_2 ; break; /* over AF, not B */ + case 0x30: + case 0x70: *priority = GFX_PMASK_2|GFX_PMASK_1; break; /* over F, not AB */ + } + /* bit 7 is on in the "Game Over" sprites, meaning unknown */ + /* in Aliens it is the top bit of the code, but that's not needed here */ + *color = sprite_colorbase + (*color & 0x0f); +} + + +/*************************************************************************** + + Display refresh + +***************************************************************************/ + +uint32_t crimfght_state::screen_update_crimfght(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) +{ + m_k052109->tilemap_update(); + + screen.priority().fill(0, cliprect); + /* The background color is always from layer 1 */ + m_k052109->tilemap_draw(screen, bitmap, cliprect, 1, TILEMAP_DRAW_OPAQUE, 0); + + m_k052109->tilemap_draw(screen, bitmap, cliprect, 1, 0, 1); + m_k052109->tilemap_draw(screen, bitmap, cliprect, 2, 0, 2); + m_k052109->tilemap_draw(screen, bitmap, cliprect, 0, 0, 4); + + m_k051960->k051960_sprites_draw(bitmap, cliprect, screen.priority(), -1, -1); + return 0; +} + void crimfght_state::crimfght_coin_w(uint8_t data) { @@ -428,6 +554,8 @@ ROM_START( crimfghtu ) ROM_LOAD( "821k03.e5", 0x00000, 0x40000, CRC(fef8505a) SHA1(5c5121609f69001838963e961cb227d6b64e4f5f) ) ROM_END +} // anonymous namespace + /*************************************************************************** Game driver(s) diff --git a/src/mame/konami/crimfght.h b/src/mame/konami/crimfght.h deleted file mode 100644 index 084afbb4a67..00000000000 --- a/src/mame/konami/crimfght.h +++ /dev/null @@ -1,73 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Manuel Abadia -/************************************************************************* - - Crime Fighters - -*************************************************************************/ -#ifndef MAME_KONAMI_CRIMFGHT_H -#define MAME_KONAMI_CRIMFGHT_H - -#pragma once - -#include "cpu/m6809/konami.h" -#include "machine/bankdev.h" -#include "machine/gen_latch.h" -#include "sound/k007232.h" -#include "k052109.h" -#include "k051960.h" -#include "emupal.h" - -class crimfght_state : public driver_device -{ -public: - crimfght_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_bank0000(*this, "bank0000"), - m_k007232(*this, "k007232"), - m_k052109(*this, "k052109"), - m_k051960(*this, "k051960"), - m_palette(*this, "palette"), - m_soundlatch(*this, "soundlatch"), - m_rombank(*this, "rombank") - { } - - DECLARE_CUSTOM_INPUT_MEMBER(system_r); - void crimfght(machine_config &config); - -private: - /* devices */ - required_device m_maincpu; - required_device m_audiocpu; - required_device m_bank0000; - required_device m_k007232; - required_device m_k052109; - required_device m_k051960; - required_device m_palette; - required_device m_soundlatch; - required_memory_bank m_rombank; - - void crimfght_coin_w(uint8_t data); - void sound_w(uint8_t data); - uint8_t k052109_051960_r(offs_t offset); - void k052109_051960_w(offs_t offset, uint8_t data); - IRQ_CALLBACK_MEMBER(audiocpu_irq_ack); - void ym2151_ct_w(uint8_t data); - virtual void machine_start() override; - uint32_t screen_update_crimfght(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - void volume_callback(uint8_t data); - K052109_CB_MEMBER(tile_callback); - K051960_CB_MEMBER(sprite_callback); - void banking_callback(uint8_t data); - - void bank0000_map(address_map &map); - void crimfght_map(address_map &map); - void crimfght_sound_map(address_map &map); - int m_woco = 0; - int m_rmrd = 0; - int m_init = 0; -}; - -#endif // MAME_KONAMI_CRIMFGHT_H diff --git a/src/mame/konami/crimfght_v.cpp b/src/mame/konami/crimfght_v.cpp deleted file mode 100644 index 7bcb3adb4b8..00000000000 --- a/src/mame/konami/crimfght_v.cpp +++ /dev/null @@ -1,70 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Manuel Abadia - -#include "emu.h" -#include "crimfght.h" -#include "screen.h" - -/*************************************************************************** - - Callbacks for the K052109 - -***************************************************************************/ - -K052109_CB_MEMBER(crimfght_state::tile_callback) -{ - *flags = (*color & 0x20) ? TILE_FLIPX : 0; - *code |= ((*color & 0x1f) << 8) | (bank << 13); - *color = layer * 4 + ((*color & 0xc0) >> 6); -} - -/*************************************************************************** - - Callbacks for the K051960 - -***************************************************************************/ - -K051960_CB_MEMBER(crimfght_state::sprite_callback) -{ - enum { sprite_colorbase = 256 / 16 }; - - /* The PROM allows for mixed priorities, where sprites would have */ - /* priority over text but not on one or both of the other two planes. */ - switch (*color & 0x70) - { - case 0x10: *priority = 0x00; break; /* over ABF */ - case 0x00: *priority = GFX_PMASK_4 ; break; /* over AB, not F */ - case 0x40: *priority = GFX_PMASK_4|GFX_PMASK_2 ; break; /* over A, not BF */ - case 0x20: - case 0x60: *priority = GFX_PMASK_4|GFX_PMASK_2|GFX_PMASK_1; break; /* over -, not ABF */ - case 0x50: *priority = GFX_PMASK_2 ; break; /* over AF, not B */ - case 0x30: - case 0x70: *priority = GFX_PMASK_2|GFX_PMASK_1; break; /* over F, not AB */ - } - /* bit 7 is on in the "Game Over" sprites, meaning unknown */ - /* in Aliens it is the top bit of the code, but that's not needed here */ - *color = sprite_colorbase + (*color & 0x0f); -} - - -/*************************************************************************** - - Display refresh - -***************************************************************************/ - -uint32_t crimfght_state::screen_update_crimfght(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - m_k052109->tilemap_update(); - - screen.priority().fill(0, cliprect); - /* The background color is always from layer 1 */ - m_k052109->tilemap_draw(screen, bitmap, cliprect, 1, TILEMAP_DRAW_OPAQUE, 0); - - m_k052109->tilemap_draw(screen, bitmap, cliprect, 1, 0, 1); - m_k052109->tilemap_draw(screen, bitmap, cliprect, 2, 0, 2); - m_k052109->tilemap_draw(screen, bitmap, cliprect, 0, 0, 4); - - m_k051960->k051960_sprites_draw(bitmap, cliprect, screen.priority(), -1, -1); - return 0; -} diff --git a/src/mame/konami/dbz.cpp b/src/mame/konami/dbz.cpp index 2f64e7d5883..78ba009ab83 100644 --- a/src/mame/konami/dbz.cpp +++ b/src/mame/konami/dbz.cpp @@ -53,14 +53,241 @@ Notes: */ #include "emu.h" -#include "dbz.h" + +#include "k053246_k053247_k055673.h" +#include "k053251.h" +#include "k054156_k054157_k056832.h" +#include "konami_helper.h" #include "cpu/m68000/m68000.h" #include "cpu/z80/z80.h" #include "machine/gen_latch.h" +#include "machine/k053252.h" +#include "machine/timer.h" #include "sound/okim6295.h" #include "sound/ymopm.h" +#include "video/k053936.h" #include "speaker.h" +#include "tilemap.h" + +namespace { + +class dbz_state : public driver_device +{ +public: + dbz_state(const machine_config &mconfig, device_type type, const char *tag) : + driver_device(mconfig, type, tag), + m_bg1_videoram(*this, "bg1_videoram"), + m_bg2_videoram(*this, "bg2_videoram"), + m_maincpu(*this, "maincpu"), + m_audiocpu(*this, "audiocpu"), + m_k053246(*this, "k053246"), + m_k053251(*this, "k053251"), + m_k053252(*this, "k053252"), + m_k056832(*this, "k056832"), + m_k053936_1(*this, "k053936_1"), + m_k053936_2(*this, "k053936_2"), + m_gfxdecode(*this, "gfxdecode"), + m_dsw2(*this, "DSW2") + { } + + void dbz(machine_config &config); + void dbz2bl(machine_config &config); + + void init_dbza(); + void init_dbz(); + void init_dbz2(); + +protected: + virtual void machine_start() override; + virtual void machine_reset() override; + virtual void video_start() override; + +private: + /* memory pointers */ + required_shared_ptr m_bg1_videoram; + required_shared_ptr m_bg2_videoram; + + /* video-related */ + tilemap_t *m_bg1_tilemap = nullptr; + tilemap_t *m_bg2_tilemap = nullptr; + int m_layer_colorbase[6]{}; + int m_layerpri[5]{}; + int m_sprite_colorbase = 0; + + /* misc */ + int m_control = 0; + + /* devices */ + required_device m_maincpu; + required_device m_audiocpu; + required_device m_k053246; + required_device m_k053251; + required_device m_k053252; + required_device m_k056832; + required_device m_k053936_1; + required_device m_k053936_2; + required_device m_gfxdecode; + + required_ioport m_dsw2; + + void dbzcontrol_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); + void dbz_sound_cause_nmi(uint16_t data); + void dbz_bg2_videoram_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); + void dbz_bg1_videoram_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); + DECLARE_WRITE_LINE_MEMBER(dbz_irq2_ack_w); + TILE_GET_INFO_MEMBER(get_dbz_bg2_tile_info); + TILE_GET_INFO_MEMBER(get_dbz_bg1_tile_info); + uint32_t screen_update_dbz(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); + TIMER_DEVICE_CALLBACK_MEMBER(dbz_scanline); + K056832_CB_MEMBER(tile_callback); + K053246_CB_MEMBER(sprite_callback); + void dbz_map(address_map &map); + void dbz2bl_map(address_map &map); + void dbz_sound_io_map(address_map &map); + void dbz_sound_map(address_map &map); +}; + + +K056832_CB_MEMBER(dbz_state::tile_callback) +{ + *color = (m_layer_colorbase[layer] << 1) + ((*color & 0x3c) >> 2); +} + +K053246_CB_MEMBER(dbz_state::sprite_callback) +{ + int pri = (*color & 0x3c0) >> 5; + + if (pri <= m_layerpri[3]) + *priority_mask = 0xff00; + else if (pri > m_layerpri[3] && pri <= m_layerpri[2]) + *priority_mask = 0xfff0; + else if (pri > m_layerpri[2] && pri <= m_layerpri[1]) + *priority_mask = 0xfffc; + else + *priority_mask = 0xfffe; + + *color = (m_sprite_colorbase << 1) + (*color & 0x1f); +} + +/* Background Tilemaps */ + +void dbz_state::dbz_bg2_videoram_w(offs_t offset, uint16_t data, uint16_t mem_mask) +{ + COMBINE_DATA(&m_bg2_videoram[offset]); + m_bg2_tilemap->mark_tile_dirty(offset / 2); +} + +TILE_GET_INFO_MEMBER(dbz_state::get_dbz_bg2_tile_info) +{ + int tileno, colour, flag; + + tileno = m_bg2_videoram[tile_index * 2 + 1] & 0x7fff; + colour = (m_bg2_videoram[tile_index * 2] & 0x000f); + flag = (m_bg2_videoram[tile_index * 2] & 0x0080) ? TILE_FLIPX : 0; + + tileinfo.set(0, tileno, colour + (m_layer_colorbase[5] << 1), flag); +} + +void dbz_state::dbz_bg1_videoram_w(offs_t offset, uint16_t data, uint16_t mem_mask) +{ + COMBINE_DATA(&m_bg1_videoram[offset]); + m_bg1_tilemap->mark_tile_dirty(offset / 2); +} + +TILE_GET_INFO_MEMBER(dbz_state::get_dbz_bg1_tile_info) +{ + int tileno, colour, flag; + + tileno = m_bg1_videoram[tile_index * 2 + 1] & 0x7fff; + colour = (m_bg1_videoram[tile_index * 2] & 0x000f); + flag = (m_bg1_videoram[tile_index * 2] & 0x0080) ? TILE_FLIPX : 0; + + tileinfo.set(1, tileno, colour + (m_layer_colorbase[4] << 1), flag); +} + +void dbz_state::video_start() +{ + m_bg1_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(dbz_state::get_dbz_bg1_tile_info)), TILEMAP_SCAN_ROWS, 16, 16, 64, 32); + m_bg2_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(dbz_state::get_dbz_bg2_tile_info)), TILEMAP_SCAN_ROWS, 16, 16, 64, 32); + + m_bg1_tilemap->set_transparent_pen(0); + m_bg2_tilemap->set_transparent_pen(0); + + if (!strcmp(machine().system().name, "dbz")) + m_k056832->set_layer_offs(0, -34, -16); + else + m_k056832->set_layer_offs(0, -35, -16); + + m_k056832->set_layer_offs(1, -31, -16); + m_k056832->set_layer_offs(3, -31, -16); //? +} + +uint32_t dbz_state::screen_update_dbz(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) +{ + static const int K053251_CI[6] = { k053251_device::CI3, k053251_device::CI4, k053251_device::CI4, k053251_device::CI4, k053251_device::CI2, k053251_device::CI1 }; + int layer[5], plane, new_colorbase; + + m_sprite_colorbase = m_k053251->get_palette_index(k053251_device::CI0); + + for (plane = 0; plane < 6; plane++) + { + new_colorbase = m_k053251->get_palette_index(K053251_CI[plane]); + if (m_layer_colorbase[plane] != new_colorbase) + { + m_layer_colorbase[plane] = new_colorbase; + if (plane <= 3) + m_k056832->mark_plane_dirty( plane); + else if (plane == 4) + m_bg1_tilemap->mark_all_dirty(); + else if (plane == 5) + m_bg2_tilemap->mark_all_dirty(); + } + } + + //layers priority + + layer[0] = 0; + m_layerpri[0] = m_k053251->get_priority(k053251_device::CI3); + layer[1] = 1; + m_layerpri[1] = m_k053251->get_priority(k053251_device::CI4); + layer[2] = 3; + m_layerpri[2] = m_k053251->get_priority(k053251_device::CI0); + layer[3] = 4; + m_layerpri[3] = m_k053251->get_priority(k053251_device::CI2); + layer[4] = 5; + m_layerpri[4] = m_k053251->get_priority(k053251_device::CI1); + + konami_sortlayers5(layer, m_layerpri); + + screen.priority().fill(0, cliprect); + + for (plane = 0; plane < 5; plane++) + { + int flag, pri; + + if (plane == 0) + { + flag = TILEMAP_DRAW_OPAQUE; + pri = 0; + } + else + { + flag = 0; + pri = 1 << (plane - 1); + } + + if(layer[plane] == 4) + m_k053936_2->zoom_draw(screen, bitmap, cliprect, m_bg1_tilemap, flag, pri, 1); + else if(layer[plane] == 5) + m_k053936_1->zoom_draw(screen, bitmap, cliprect, m_bg2_tilemap, flag, pri, 1); + else + m_k056832->tilemap_draw(screen, bitmap, cliprect, layer[plane], flag, pri); + } + + m_k053246->k053247_sprites_draw( bitmap, cliprect); + return 0; +} TIMER_DEVICE_CALLBACK_MEMBER(dbz_state::dbz_scanline) @@ -626,6 +853,8 @@ void dbz_state::init_dbz2() ROM[0xae8/2] = 0x4e71; /* 0x005e */ } +} // anonymous namespace + GAME( 1993, dbz, 0, dbz, dbz, dbz_state, init_dbz, ROT0, "Banpresto", "Dragon Ball Z (rev B)", MACHINE_IMPERFECT_GRAPHICS | MACHINE_SUPPORTS_SAVE ) // crashes MAME in tile/PSAC2 ROM test GAME( 1993, dbza, dbz, dbz, dbza, dbz_state, init_dbza, ROT0, "Banpresto", "Dragon Ball Z (rev A)", MACHINE_IMPERFECT_GRAPHICS | MACHINE_SUPPORTS_SAVE ) GAME( 1994, dbz2, 0, dbz, dbz2, dbz_state, init_dbz2, ROT0, "Banpresto", "Dragon Ball Z 2 - Super Battle", MACHINE_IMPERFECT_GRAPHICS | MACHINE_SUPPORTS_SAVE ) // crashes MAME in tile/PSAC2 ROM test diff --git a/src/mame/konami/dbz.h b/src/mame/konami/dbz.h deleted file mode 100644 index c099f69c4c6..00000000000 --- a/src/mame/konami/dbz.h +++ /dev/null @@ -1,98 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:David Haywood, R. Belmont, Pierpaolo Prazzoli -/************************************************************************* - - Dragon Ball Z - -*************************************************************************/ -#ifndef MAME_KONAMI_DBZ_H -#define MAME_KONAMI_DBZ_H - -#pragma once - -#include "machine/k053252.h" -#include "machine/timer.h" -#include "k054156_k054157_k056832.h" -#include "k053246_k053247_k055673.h" -#include "video/k053936.h" -#include "k053251.h" -#include "konami_helper.h" -#include "tilemap.h" - -class dbz_state : public driver_device -{ -public: - dbz_state(const machine_config &mconfig, device_type type, const char *tag) : - driver_device(mconfig, type, tag), - m_bg1_videoram(*this, "bg1_videoram"), - m_bg2_videoram(*this, "bg2_videoram"), - m_maincpu(*this, "maincpu"), - m_audiocpu(*this, "audiocpu"), - m_k053246(*this, "k053246"), - m_k053251(*this, "k053251"), - m_k053252(*this, "k053252"), - m_k056832(*this, "k056832"), - m_k053936_1(*this, "k053936_1"), - m_k053936_2(*this, "k053936_2"), - m_gfxdecode(*this, "gfxdecode"), - m_dsw2(*this, "DSW2") - { } - - void dbz(machine_config &config); - void dbz2bl(machine_config &config); - - void init_dbza(); - void init_dbz(); - void init_dbz2(); - -protected: - virtual void machine_start() override; - virtual void machine_reset() override; - virtual void video_start() override; - -private: - /* memory pointers */ - required_shared_ptr m_bg1_videoram; - required_shared_ptr m_bg2_videoram; - - /* video-related */ - tilemap_t *m_bg1_tilemap = nullptr; - tilemap_t *m_bg2_tilemap = nullptr; - int m_layer_colorbase[6]{}; - int m_layerpri[5]{}; - int m_sprite_colorbase = 0; - - /* misc */ - int m_control = 0; - - /* devices */ - required_device m_maincpu; - required_device m_audiocpu; - required_device m_k053246; - required_device m_k053251; - required_device m_k053252; - required_device m_k056832; - required_device m_k053936_1; - required_device m_k053936_2; - required_device m_gfxdecode; - - required_ioport m_dsw2; - - void dbzcontrol_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); - void dbz_sound_cause_nmi(uint16_t data); - void dbz_bg2_videoram_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); - void dbz_bg1_videoram_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); - DECLARE_WRITE_LINE_MEMBER(dbz_irq2_ack_w); - TILE_GET_INFO_MEMBER(get_dbz_bg2_tile_info); - TILE_GET_INFO_MEMBER(get_dbz_bg1_tile_info); - uint32_t screen_update_dbz(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - TIMER_DEVICE_CALLBACK_MEMBER(dbz_scanline); - K056832_CB_MEMBER(tile_callback); - K053246_CB_MEMBER(sprite_callback); - void dbz_map(address_map &map); - void dbz2bl_map(address_map &map); - void dbz_sound_io_map(address_map &map); - void dbz_sound_map(address_map &map); -}; - -#endif // MAME_KONAMI_DBZ_H diff --git a/src/mame/konami/dbz_v.cpp b/src/mame/konami/dbz_v.cpp deleted file mode 100644 index 43f5910a61c..00000000000 --- a/src/mame/konami/dbz_v.cpp +++ /dev/null @@ -1,155 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:David Haywood, R. Belmont, Pierpaolo Prazzoli -/* - Dragon Ball Z - (c) 1993 Banpresto - Dragon Ball Z 2 Super Battle - (c) 1994 Banpresto - - Video hardware emulation. -*/ - - -#include "emu.h" -#include "dbz.h" - - -K056832_CB_MEMBER(dbz_state::tile_callback) -{ - *color = (m_layer_colorbase[layer] << 1) + ((*color & 0x3c) >> 2); -} - -K053246_CB_MEMBER(dbz_state::sprite_callback) -{ - int pri = (*color & 0x3c0) >> 5; - - if (pri <= m_layerpri[3]) - *priority_mask = 0xff00; - else if (pri > m_layerpri[3] && pri <= m_layerpri[2]) - *priority_mask = 0xfff0; - else if (pri > m_layerpri[2] && pri <= m_layerpri[1]) - *priority_mask = 0xfffc; - else - *priority_mask = 0xfffe; - - *color = (m_sprite_colorbase << 1) + (*color & 0x1f); -} - -/* Background Tilemaps */ - -void dbz_state::dbz_bg2_videoram_w(offs_t offset, uint16_t data, uint16_t mem_mask) -{ - COMBINE_DATA(&m_bg2_videoram[offset]); - m_bg2_tilemap->mark_tile_dirty(offset / 2); -} - -TILE_GET_INFO_MEMBER(dbz_state::get_dbz_bg2_tile_info) -{ - int tileno, colour, flag; - - tileno = m_bg2_videoram[tile_index * 2 + 1] & 0x7fff; - colour = (m_bg2_videoram[tile_index * 2] & 0x000f); - flag = (m_bg2_videoram[tile_index * 2] & 0x0080) ? TILE_FLIPX : 0; - - tileinfo.set(0, tileno, colour + (m_layer_colorbase[5] << 1), flag); -} - -void dbz_state::dbz_bg1_videoram_w(offs_t offset, uint16_t data, uint16_t mem_mask) -{ - COMBINE_DATA(&m_bg1_videoram[offset]); - m_bg1_tilemap->mark_tile_dirty(offset / 2); -} - -TILE_GET_INFO_MEMBER(dbz_state::get_dbz_bg1_tile_info) -{ - int tileno, colour, flag; - - tileno = m_bg1_videoram[tile_index * 2 + 1] & 0x7fff; - colour = (m_bg1_videoram[tile_index * 2] & 0x000f); - flag = (m_bg1_videoram[tile_index * 2] & 0x0080) ? TILE_FLIPX : 0; - - tileinfo.set(1, tileno, colour + (m_layer_colorbase[4] << 1), flag); -} - -void dbz_state::video_start() -{ - m_bg1_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(dbz_state::get_dbz_bg1_tile_info)), TILEMAP_SCAN_ROWS, 16, 16, 64, 32); - m_bg2_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(dbz_state::get_dbz_bg2_tile_info)), TILEMAP_SCAN_ROWS, 16, 16, 64, 32); - - m_bg1_tilemap->set_transparent_pen(0); - m_bg2_tilemap->set_transparent_pen(0); - - if (!strcmp(machine().system().name, "dbz")) - m_k056832->set_layer_offs(0, -34, -16); - else - m_k056832->set_layer_offs(0, -35, -16); - - m_k056832->set_layer_offs(1, -31, -16); - m_k056832->set_layer_offs(3, -31, -16); //? -} - -uint32_t dbz_state::screen_update_dbz(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - static const int K053251_CI[6] = { k053251_device::CI3, k053251_device::CI4, k053251_device::CI4, k053251_device::CI4, k053251_device::CI2, k053251_device::CI1 }; - int layer[5], plane, new_colorbase; - - m_sprite_colorbase = m_k053251->get_palette_index(k053251_device::CI0); - - for (plane = 0; plane < 6; plane++) - { - new_colorbase = m_k053251->get_palette_index(K053251_CI[plane]); - if (m_layer_colorbase[plane] != new_colorbase) - { - m_layer_colorbase[plane] = new_colorbase; - if (plane <= 3) - m_k056832->mark_plane_dirty( plane); - else if (plane == 4) - m_bg1_tilemap->mark_all_dirty(); - else if (plane == 5) - m_bg2_tilemap->mark_all_dirty(); - } - } - - //layers priority - - layer[0] = 0; - m_layerpri[0] = m_k053251->get_priority(k053251_device::CI3); - layer[1] = 1; - m_layerpri[1] = m_k053251->get_priority(k053251_device::CI4); - layer[2] = 3; - m_layerpri[2] = m_k053251->get_priority(k053251_device::CI0); - layer[3] = 4; - m_layerpri[3] = m_k053251->get_priority(k053251_device::CI2); - layer[4] = 5; - m_layerpri[4] = m_k053251->get_priority(k053251_device::CI1); - - konami_sortlayers5(layer, m_layerpri); - - screen.priority().fill(0, cliprect); - - for (plane = 0; plane < 5; plane++) - { - int flag, pri; - - if (plane == 0) - { - flag = TILEMAP_DRAW_OPAQUE; - pri = 0; - } - else - { - flag = 0; - pri = 1 << (plane - 1); - } - - if(layer[plane] == 4) - m_k053936_2->zoom_draw(screen, bitmap, cliprect, m_bg1_tilemap, flag, pri, 1); - else if(layer[plane] == 5) - m_k053936_1->zoom_draw(screen, bitmap, cliprect, m_bg2_tilemap, flag, pri, 1); - else - m_k056832->tilemap_draw(screen, bitmap, cliprect, layer[plane], flag, pri); - } - - m_k053246->k053247_sprites_draw( bitmap, cliprect); - return 0; -} diff --git a/src/mame/konami/djmain.cpp b/src/mame/konami/djmain.cpp index a691aeabd19..b625f84369e 100644 --- a/src/mame/konami/djmain.cpp +++ b/src/mame/konami/djmain.cpp @@ -66,20 +66,291 @@ hard drive 3.5 adapter long 3.5 IDE cable 3.5 adapter PCB */ #include "emu.h" -#include "djmain.h" + +#include "k054156_k054157_k056832.h" +#include "k055555.h" +#include "konami_helper.h" #include "bus/ata/ataintf.h" #include "bus/ata/idehd.h" #include "cpu/m68000/m68020.h" #include "sound/k054539.h" +#include "emupal.h" #include "screen.h" #include "speaker.h" +namespace { #define DISABLE_VB_INT (!(m_v_ctrl & 0x8000)) +#define NUM_SPRITES (0x800 / 16) +#define NUM_LAYERS 2 + +class djmain_state : public driver_device +{ +public: + djmain_state(const machine_config &mconfig, device_type type, const char *tag) + : driver_device(mconfig, type, tag) + , m_obj_ram(*this, "obj_ram") + , m_maincpu(*this, "maincpu") + , m_k056832(*this, "k056832") + , m_k055555(*this, "k055555") + , m_ata(*this, "ata") + , m_gfxdecode(*this, "gfxdecode") + , m_palette(*this, "palette") + , m_turntable(*this, "TT%u", 1U) + , m_sndram(*this, "sndram") + , m_leds(*this, "led%u", 0U) + { + } + + void djmainj(machine_config &config); + void djmainu(machine_config &config); + void djmaina(machine_config &config); + + void init_bm7thmix(); + void init_bm6thmix(); + void init_hmcompmx(); + void init_bmfinal(); + void init_hmcompm2(); + void init_bm5thmix(); + void init_bm4thmix(); + void init_bs4thmix(); + void init_beatmania(); + void init_bmdct(); + void init_bmcompm2(); + void init_bmcorerm(); + void init_bmclubmx(); + +protected: + virtual void machine_start() override; + virtual void machine_reset() override; + virtual void video_start() override; + +private: + void sndram_bank_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0); + uint32_t sndram_r(offs_t offset, uint32_t mem_mask = ~0); + void sndram_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0); + uint32_t obj_ctrl_r(offs_t offset); + void obj_ctrl_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0); + uint32_t obj_rom_r(offs_t offset, uint32_t mem_mask = ~0); + void v_ctrl_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0); + uint32_t v_rom_r(offs_t offset, uint32_t mem_mask = ~0); + uint8_t inp1_r(offs_t offset); + uint8_t inp2_r(offs_t offset); + uint32_t turntable_r(offs_t offset, uint32_t mem_mask = ~0); + void turntable_select_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0); + void light_ctrl_1_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0); + void light_ctrl_2_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0); + void unknown590000_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0); + void unknown802000_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0); + void unknownc02000_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0); + + uint32_t screen_update_djmain(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); + INTERRUPT_GEN_MEMBER(vb_interrupt); + DECLARE_WRITE_LINE_MEMBER(ide_interrupt); + void draw_sprites( bitmap_rgb32 &bitmap, const rectangle &cliprect); + K056832_CB_MEMBER(tile_callback); + void k054539_map(address_map &map); + void maincpu_djmain(address_map &map); + void maincpu_djmaina(address_map &map); + void maincpu_djmainj(address_map &map); + void maincpu_djmainu(address_map &map); + + required_shared_ptr m_obj_ram; + required_device m_maincpu; + required_device m_k056832; + required_device m_k055555; + required_device m_ata; + required_device m_gfxdecode; + required_device m_palette; + optional_ioport_array<2> m_turntable; + required_shared_ptr m_sndram; + output_finder<3> m_leds; + + int m_sndram_bank = 0; + int m_turntable_select = 0; + uint8_t m_turntable_last_pos[2]{}; + uint16_t m_turntable_pos[2]{}; + uint8_t m_pending_vb_int = 0U; + uint16_t m_v_ctrl = 0U; + uint32_t m_obj_regs[0xa0/4]{}; + const uint8_t *m_ata_user_password = nullptr; + const uint8_t *m_ata_master_password = nullptr; +}; + + +void djmain_state::draw_sprites( bitmap_rgb32 &bitmap, const rectangle &cliprect) +{ + int offs, pri_code; + int sortedlist[NUM_SPRITES]; + + m_gfxdecode->gfx(0)->set_colorbase(m_k055555->K055555_read_register(K55_PALBASE_SUB2) * 0x400); + + for (offs = 0; offs < NUM_SPRITES; offs++) + sortedlist[offs] = -1; + + /* prebuild a sorted table */ + for (offs = 0; offs < NUM_SPRITES * 4; offs += 4) + { + if (m_obj_ram[offs] & 0x00008000) + { + if (m_obj_ram[offs] & 0x80000000) + continue; + + pri_code = m_obj_ram[offs] & (NUM_SPRITES - 1); + sortedlist[pri_code] = offs; + } + } + + for (pri_code = NUM_SPRITES - 1; pri_code >= 0; pri_code--) + { + static const int xoffset[8] = { 0, 1, 4, 5, 16, 17, 20, 21 }; + static const int yoffset[8] = { 0, 2, 8, 10, 32, 34, 40, 42 }; + static const int sizetab[4] = { 1, 2, 4, 8 }; + int x, y; + int ox, oy; + int flipx, flipy; + int xscale, yscale; + int code; + int color; + int size; + + offs = sortedlist[pri_code]; + if (offs == -1) continue; + + code = m_obj_ram[offs] >> 16; + flipx = (m_obj_ram[offs] >> 10) & 1; + flipy = (m_obj_ram[offs] >> 11) & 1; + size = sizetab[(m_obj_ram[offs] >> 8) & 3]; + + ox = (int16_t)(m_obj_ram[offs + 1] & 0xffff); + oy = (int16_t)(m_obj_ram[offs + 1] >> 16); + + xscale = m_obj_ram[offs + 2] >> 16; + yscale = m_obj_ram[offs + 2] & 0xffff; + + if (!xscale || !yscale) + continue; + + xscale = (0x40 << 16) / xscale; + yscale = (0x40 << 16) / yscale; + ox -= (size * xscale) >> 13; + oy -= (size * yscale) >> 13; + + color = (m_obj_ram[offs + 3] >> 16) & 15; + + for (x = 0; x < size; x++) + for (y = 0; y < size; y++) + { + int c = code; + + if (flipx) + c += xoffset[size - x - 1]; + else + c += xoffset[x]; + + if (flipy) + c += yoffset[size - y - 1]; + else + c += yoffset[y]; + + if (xscale != 0x10000 || yscale != 0x10000) + { + int sx = ox + ((x * xscale + (1 << 11)) >> 12); + int sy = oy + ((y * yscale + (1 << 11)) >> 12); + int zw = ox + (((x + 1) * xscale + (1 << 11)) >> 12) - sx; + int zh = oy + (((y + 1) * yscale + (1 << 11)) >> 12) - sy; + + + m_gfxdecode->gfx(0)->zoom_transpen(bitmap, + cliprect, + c, + color, + flipx, + flipy, + sx, + sy, + (zw << 16) / 16, + (zh << 16) / 16, + 0); + } + else + { + int sx = ox + (x << 4); + int sy = oy + (y << 4); + + + m_gfxdecode->gfx(0)->transpen(bitmap, + cliprect, + c, + color, + flipx, + flipy, + sx, + sy, + 0); + } + } + } +} + + +K056832_CB_MEMBER(djmain_state::tile_callback) +{ +} + +void djmain_state::video_start() +{ + m_k056832->set_layer_offs(0, -92, -27); + // m_k056832->set_layer_offs(1, -87, -27); + m_k056832->set_layer_offs(1, -88, -27); +} + +uint32_t djmain_state::screen_update_djmain(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) +{ + int enables = m_k055555->K055555_read_register(K55_INPUT_ENABLES); + int pri[NUM_LAYERS + 1]; + int order[NUM_LAYERS + 1]; + int i, j; + + for (i = 0; i < NUM_LAYERS; i++) + pri[i] = m_k055555->K055555_read_register(K55_PRIINP_0 + i * 3); + pri[i] = m_k055555->K055555_read_register(K55_PRIINP_10); + + for (i = 0; i < NUM_LAYERS + 1; i++) + order[i] = i; + + for (i = 0; i < NUM_LAYERS; i++) + for (j = i + 1; j < NUM_LAYERS + 1; j++) + if (pri[order[i]] > pri[order[j]]) + { + int temp = order[i]; + + order[i] = order[j]; + order[j] = temp; + } + + bitmap.fill(m_palette->pen(0), cliprect); + for (i = 0; i < NUM_LAYERS + 1; i++) + { + int layer = order[i]; + + if (layer == NUM_LAYERS) + { + if (enables & K55_INP_SUB2) + draw_sprites(bitmap, cliprect); + } + else + { + if (enables & (K55_INP_VRAM_A << layer)) + m_k056832->tilemap_draw_dj(screen, bitmap, cliprect, layer, 0, 1 << i); + } + } + return 0; +} /************************************* @@ -2272,6 +2543,8 @@ void djmain_state::init_bmfinal() m_ata_user_password = bmfinal_user_password; } +} // anonymous namespace + /************************************* * @@ -2313,6 +2586,3 @@ GAME( 1999, popnstex, 0, djmainj, popnstex, djmain_state, init_beatmania // for reference, these sets have not been verified //GAME( 1998, bm3rdmxb, bm3rdmix, djmainj, bm3rdmix, djmain_state, init_beatmania, ROT0, "Konami", "beatmania 3rd MIX (ver JA-B)", 0 ) - - - diff --git a/src/mame/konami/djmain.h b/src/mame/konami/djmain.h deleted file mode 100644 index 27bdf256067..00000000000 --- a/src/mame/konami/djmain.h +++ /dev/null @@ -1,107 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:smf -#ifndef MAME_KONAMI_DJMAIN_H -#define MAME_KONAMI_DJMAIN_H - -#pragma once - -#include "bus/ata/ataintf.h" -#include "konami_helper.h" -#include "k054156_k054157_k056832.h" -#include "k055555.h" -#include "emupal.h" - -class djmain_state : public driver_device -{ -public: - djmain_state(const machine_config &mconfig, device_type type, const char *tag) - : driver_device(mconfig, type, tag) - , m_obj_ram(*this, "obj_ram") - , m_maincpu(*this, "maincpu") - , m_k056832(*this, "k056832") - , m_k055555(*this, "k055555") - , m_ata(*this, "ata") - , m_gfxdecode(*this, "gfxdecode") - , m_palette(*this, "palette") - , m_turntable(*this, "TT%u", 1U) - , m_sndram(*this, "sndram") - , m_leds(*this, "led%u", 0U) - { - } - - void djmainj(machine_config &config); - void djmainu(machine_config &config); - void djmaina(machine_config &config); - - void init_bm7thmix(); - void init_bm6thmix(); - void init_hmcompmx(); - void init_bmfinal(); - void init_hmcompm2(); - void init_bm5thmix(); - void init_bm4thmix(); - void init_bs4thmix(); - void init_beatmania(); - void init_bmdct(); - void init_bmcompm2(); - void init_bmcorerm(); - void init_bmclubmx(); - -protected: - virtual void machine_start() override; - virtual void machine_reset() override; - virtual void video_start() override; - -private: - void sndram_bank_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0); - uint32_t sndram_r(offs_t offset, uint32_t mem_mask = ~0); - void sndram_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0); - uint32_t obj_ctrl_r(offs_t offset); - void obj_ctrl_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0); - uint32_t obj_rom_r(offs_t offset, uint32_t mem_mask = ~0); - void v_ctrl_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0); - uint32_t v_rom_r(offs_t offset, uint32_t mem_mask = ~0); - uint8_t inp1_r(offs_t offset); - uint8_t inp2_r(offs_t offset); - uint32_t turntable_r(offs_t offset, uint32_t mem_mask = ~0); - void turntable_select_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0); - void light_ctrl_1_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0); - void light_ctrl_2_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0); - void unknown590000_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0); - void unknown802000_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0); - void unknownc02000_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0); - - uint32_t screen_update_djmain(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); - INTERRUPT_GEN_MEMBER(vb_interrupt); - DECLARE_WRITE_LINE_MEMBER(ide_interrupt); - void draw_sprites( bitmap_rgb32 &bitmap, const rectangle &cliprect); - K056832_CB_MEMBER(tile_callback); - void k054539_map(address_map &map); - void maincpu_djmain(address_map &map); - void maincpu_djmaina(address_map &map); - void maincpu_djmainj(address_map &map); - void maincpu_djmainu(address_map &map); - - required_shared_ptr m_obj_ram; - required_device m_maincpu; - required_device m_k056832; - required_device m_k055555; - required_device m_ata; - required_device m_gfxdecode; - required_device m_palette; - optional_ioport_array<2> m_turntable; - required_shared_ptr m_sndram; - output_finder<3> m_leds; - - int m_sndram_bank = 0; - int m_turntable_select = 0; - uint8_t m_turntable_last_pos[2]{}; - uint16_t m_turntable_pos[2]{}; - uint8_t m_pending_vb_int = 0U; - uint16_t m_v_ctrl = 0U; - uint32_t m_obj_regs[0xa0/4]{}; - const uint8_t *m_ata_user_password = nullptr; - const uint8_t *m_ata_master_password = nullptr; -}; - -#endif // MAME_KONAMI_DJMAIN_H diff --git a/src/mame/konami/djmain_v.cpp b/src/mame/konami/djmain_v.cpp deleted file mode 100644 index 62430ef0d78..00000000000 --- a/src/mame/konami/djmain_v.cpp +++ /dev/null @@ -1,185 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:smf -/* - * Beatmania DJ Main Board (GX753) - * emulate video hardware - */ - -#include "emu.h" -#include "djmain.h" - -#define NUM_SPRITES (0x800 / 16) -#define NUM_LAYERS 2 - - - -void djmain_state::draw_sprites( bitmap_rgb32 &bitmap, const rectangle &cliprect) -{ - int offs, pri_code; - int sortedlist[NUM_SPRITES]; - - m_gfxdecode->gfx(0)->set_colorbase(m_k055555->K055555_read_register(K55_PALBASE_SUB2) * 0x400); - - for (offs = 0; offs < NUM_SPRITES; offs++) - sortedlist[offs] = -1; - - /* prebuild a sorted table */ - for (offs = 0; offs < NUM_SPRITES * 4; offs += 4) - { - if (m_obj_ram[offs] & 0x00008000) - { - if (m_obj_ram[offs] & 0x80000000) - continue; - - pri_code = m_obj_ram[offs] & (NUM_SPRITES - 1); - sortedlist[pri_code] = offs; - } - } - - for (pri_code = NUM_SPRITES - 1; pri_code >= 0; pri_code--) - { - static const int xoffset[8] = { 0, 1, 4, 5, 16, 17, 20, 21 }; - static const int yoffset[8] = { 0, 2, 8, 10, 32, 34, 40, 42 }; - static const int sizetab[4] = { 1, 2, 4, 8 }; - int x, y; - int ox, oy; - int flipx, flipy; - int xscale, yscale; - int code; - int color; - int size; - - offs = sortedlist[pri_code]; - if (offs == -1) continue; - - code = m_obj_ram[offs] >> 16; - flipx = (m_obj_ram[offs] >> 10) & 1; - flipy = (m_obj_ram[offs] >> 11) & 1; - size = sizetab[(m_obj_ram[offs] >> 8) & 3]; - - ox = (int16_t)(m_obj_ram[offs + 1] & 0xffff); - oy = (int16_t)(m_obj_ram[offs + 1] >> 16); - - xscale = m_obj_ram[offs + 2] >> 16; - yscale = m_obj_ram[offs + 2] & 0xffff; - - if (!xscale || !yscale) - continue; - - xscale = (0x40 << 16) / xscale; - yscale = (0x40 << 16) / yscale; - ox -= (size * xscale) >> 13; - oy -= (size * yscale) >> 13; - - color = (m_obj_ram[offs + 3] >> 16) & 15; - - for (x = 0; x < size; x++) - for (y = 0; y < size; y++) - { - int c = code; - - if (flipx) - c += xoffset[size - x - 1]; - else - c += xoffset[x]; - - if (flipy) - c += yoffset[size - y - 1]; - else - c += yoffset[y]; - - if (xscale != 0x10000 || yscale != 0x10000) - { - int sx = ox + ((x * xscale + (1 << 11)) >> 12); - int sy = oy + ((y * yscale + (1 << 11)) >> 12); - int zw = ox + (((x + 1) * xscale + (1 << 11)) >> 12) - sx; - int zh = oy + (((y + 1) * yscale + (1 << 11)) >> 12) - sy; - - - m_gfxdecode->gfx(0)->zoom_transpen(bitmap, - cliprect, - c, - color, - flipx, - flipy, - sx, - sy, - (zw << 16) / 16, - (zh << 16) / 16, - 0); - } - else - { - int sx = ox + (x << 4); - int sy = oy + (y << 4); - - - m_gfxdecode->gfx(0)->transpen(bitmap, - cliprect, - c, - color, - flipx, - flipy, - sx, - sy, - 0); - } - } - } -} - - -K056832_CB_MEMBER(djmain_state::tile_callback) -{ -} - -void djmain_state::video_start() -{ - m_k056832->set_layer_offs(0, -92, -27); - // m_k056832->set_layer_offs(1, -87, -27); - m_k056832->set_layer_offs(1, -88, -27); -} - -uint32_t djmain_state::screen_update_djmain(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) -{ - int enables = m_k055555->K055555_read_register(K55_INPUT_ENABLES); - int pri[NUM_LAYERS + 1]; - int order[NUM_LAYERS + 1]; - int i, j; - - for (i = 0; i < NUM_LAYERS; i++) - pri[i] = m_k055555->K055555_read_register(K55_PRIINP_0 + i * 3); - pri[i] = m_k055555->K055555_read_register(K55_PRIINP_10); - - for (i = 0; i < NUM_LAYERS + 1; i++) - order[i] = i; - - for (i = 0; i < NUM_LAYERS; i++) - for (j = i + 1; j < NUM_LAYERS + 1; j++) - if (pri[order[i]] > pri[order[j]]) - { - int temp = order[i]; - - order[i] = order[j]; - order[j] = temp; - } - - bitmap.fill(m_palette->pen(0), cliprect); - - for (i = 0; i < NUM_LAYERS + 1; i++) - { - int layer = order[i]; - - if (layer == NUM_LAYERS) - { - if (enables & K55_INP_SUB2) - draw_sprites(bitmap, cliprect); - } - else - { - if (enables & (K55_INP_VRAM_A << layer)) - m_k056832->tilemap_draw_dj(screen, bitmap, cliprect, layer, 0, 1 << i); - } - } - return 0; -} diff --git a/src/mame/konami/gijoe.cpp b/src/mame/konami/gijoe.cpp index df886dd541d..ae14b8c7c84 100644 --- a/src/mame/konami/gijoe.cpp +++ b/src/mame/konami/gijoe.cpp @@ -74,28 +74,6 @@ Notes: **************************************************************************** -Change Log ----------- - -AT070403: - -tilemap.h,tilemap.cpp -- added tilemap_get_transparency_data() for transparency cache manipulation - -video\konamiic.cpp -- added preliminary K056832 tilemap<->linemap switching and tileline code - -drivers\gijoe.cpp -- updated video settings, memory map and irq handler -- added object blitter - -video\gijoe.cpp -- completed K054157 to K056832 migration -- added ground scroll emulation -- fixed sprite and BG priority -- improved shadows and layer alignment - - Known Issues ------------ @@ -105,20 +83,256 @@ Known Issues ***************************************************************************/ #include "emu.h" -#include "gijoe.h" + +#include "k053251.h" +#include "k054156_k054157_k056832.h" +#include "k053246_k053247_k055673.h" #include "konamipt.h" +#include "konami_helper.h" #include "cpu/m68000/m68000.h" #include "cpu/z80/z80.h" #include "machine/eepromser.h" +#include "machine/k054321.h" #include "sound/k054539.h" +#include "emupal.h" #include "speaker.h" +namespace { + #define JOE_DEBUG 0 #define JOE_DMADELAY (attotime::from_nsec(42700 + 341300)) +class gijoe_state : public driver_device +{ +public: + gijoe_state(const machine_config &mconfig, device_type type, const char *tag) : + driver_device(mconfig, type, tag), + m_spriteram(*this, "spriteram"), + m_workram(*this, "workram"), + m_maincpu(*this, "maincpu"), + m_audiocpu(*this, "audiocpu"), + m_k054539(*this, "k054539"), + m_k056832(*this, "k056832"), + m_k053246(*this, "k053246"), + m_k053251(*this, "k053251"), + m_palette(*this, "palette"), + m_k054321(*this, "k054321") + { } + + void gijoe(machine_config &config); + +private: + /* memory pointers */ + required_shared_ptr m_spriteram; + required_shared_ptr m_workram; + + /* video-related */ + int m_avac_bits[4]{}; + int m_avac_occupancy[4]{}; + int m_layer_colorbase[4]{}; + int m_layer_pri[4]{}; + int m_avac_vrc = 0; + int m_sprite_colorbase = 0; + + /* misc */ + uint16_t m_cur_control2 = 0U; + emu_timer *m_dmadelay_timer = nullptr; + + /* devices */ + required_device m_maincpu; + required_device m_audiocpu; + required_device m_k054539; + required_device m_k056832; + required_device m_k053246; + required_device m_k053251; + required_device m_palette; + required_device m_k054321; + + uint16_t control2_r(); + void control2_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); + void sound_irq_w(uint16_t data); + virtual void machine_start() override; + virtual void machine_reset() override; + virtual void video_start() override; + uint32_t screen_update_gijoe(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); + INTERRUPT_GEN_MEMBER(gijoe_interrupt); + TIMER_CALLBACK_MEMBER(dmaend_callback); + void gijoe_objdma(); + K056832_CB_MEMBER(tile_callback); + K053246_CB_MEMBER(sprite_callback); + void gijoe_map(address_map &map); + void sound_map(address_map &map); +}; + + +K053246_CB_MEMBER(gijoe_state::sprite_callback) +{ + int pri = (*color & 0x03e0) >> 4; + + if (pri <= m_layer_pri[3]) + *priority_mask = 0; + else if (pri > m_layer_pri[3] && pri <= m_layer_pri[2]) + *priority_mask = 0xff00; + else if (pri > m_layer_pri[2] && pri <= m_layer_pri[1]) + *priority_mask = 0xff00 | 0xf0f0; + else if (pri > m_layer_pri[1] && pri <= m_layer_pri[0]) + *priority_mask = 0xff00 | 0xf0f0 | 0xcccc; + else + *priority_mask = 0xff00 | 0xf0f0 | 0xcccc | 0xaaaa; + + *color = m_sprite_colorbase | (*color & 0x001f); +} + +K056832_CB_MEMBER(gijoe_state::tile_callback) +{ + int tile = *code; + + if (tile >= 0xf000 && tile <= 0xf4ff) + { + tile &= 0x0fff; + if (tile < 0x0310) + { + m_avac_occupancy[layer] |= 0x0f00; + tile |= m_avac_bits[0]; + } + else if (tile < 0x0470) + { + m_avac_occupancy[layer] |= 0xf000; + tile |= m_avac_bits[1]; + } + else + { + m_avac_occupancy[layer] |= 0x00f0; + tile |= m_avac_bits[2]; + } + *code = tile; + } + + *color = (*color >> 2 & 0x0f) | m_layer_colorbase[layer]; +} + +void gijoe_state::video_start() +{ + int i; + + m_k056832->linemap_enable(1); + + for (i = 0; i < 4; i++) + { + m_avac_occupancy[i] = 0; + m_avac_bits[i] = 0; + m_layer_colorbase[i] = 0; + m_layer_pri[i] = 0; + } + + m_avac_vrc = 0xffff; + + save_item(NAME(m_avac_vrc)); + save_item(NAME(m_sprite_colorbase)); + save_item(NAME(m_avac_occupancy)); + save_item(NAME(m_avac_bits)); // these could possibly be re-created at postload k056832 elements + save_item(NAME(m_layer_colorbase)); + save_item(NAME(m_layer_pri)); +} + +uint32_t gijoe_state::screen_update_gijoe(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) +{ + static const int K053251_CI[4] = { k053251_device::CI1, k053251_device::CI2, k053251_device::CI3, k053251_device::CI4 }; + int layer[4]; + int vrc_mode, vrc_new, colorbase_new, /*primode,*/ dirty, i; + int mask = 0; + + // update tile offsets + m_k056832->read_avac(&vrc_mode, &vrc_new); + + if (vrc_mode) + { + for (dirty = 0xf000; dirty; dirty >>= 4) + if ((m_avac_vrc & dirty) != (vrc_new & dirty)) + mask |= dirty; + + m_avac_vrc = vrc_new; + m_avac_bits[0] = vrc_new << 4 & 0xf000; + m_avac_bits[1] = vrc_new & 0xf000; + m_avac_bits[2] = vrc_new << 8 & 0xf000; + m_avac_bits[3] = vrc_new << 12 & 0xf000; + } + else + m_avac_bits[3] = m_avac_bits[2] = m_avac_bits[1] = m_avac_bits[0] = 0xf000; + + // update color info and refresh tilemaps + m_sprite_colorbase = m_k053251->get_palette_index(k053251_device::CI0); + + for (i = 0; i < 4; i++) + { + dirty = 0; + colorbase_new = m_k053251->get_palette_index(K053251_CI[i]); + if (m_layer_colorbase[i] != colorbase_new) + { + m_layer_colorbase[i] = colorbase_new; + dirty = 1; + } + if (m_avac_occupancy[i] & mask) + dirty = 1; + + if (dirty) + { + m_avac_occupancy[i] = 0; + m_k056832->mark_plane_dirty( i); + } + } + + /* + Layer A is supposed to be a non-scrolling status display with static X-offset. + The weird thing is tilemap alignment only follows the 832 standard when 2 is + written to the layer's X-scroll register otherwise the chip expects totally + different alignment values. + */ + if (m_k056832->read_register(0x14) == 2) + { + m_k056832->set_layer_offs(0, 2, 0); + m_k056832->set_layer_offs(1, 4, 0); + m_k056832->set_layer_offs(2, 6, 0); // 7? + m_k056832->set_layer_offs(3, 8, 0); + } + else + { + m_k056832->set_layer_offs(0, 0, 0); + m_k056832->set_layer_offs(1, 8, 0); + m_k056832->set_layer_offs(2, 14, 0); + m_k056832->set_layer_offs(3, 16, 0); // smaller? + } + + // seems to switch the K053251 between different priority modes, detail unknown + // primode = m_k053251->get_priority(k053251_device::CI1); + + layer[0] = 0; + m_layer_pri[0] = 0; // not sure + layer[1] = 1; + m_layer_pri[1] = m_k053251->get_priority(k053251_device::CI2); + layer[2] = 2; + m_layer_pri[2] = m_k053251->get_priority(k053251_device::CI3); + layer[3] = 3; + m_layer_pri[3] = m_k053251->get_priority(k053251_device::CI4); + + konami_sortlayers4(layer, m_layer_pri); + + bitmap.fill(m_palette->black_pen(), cliprect); + screen.priority().fill(0, cliprect); + + m_k056832->tilemap_draw(screen, bitmap, cliprect, layer[0], 0, 1); + m_k056832->tilemap_draw(screen, bitmap, cliprect, layer[1], 0, 2); + m_k056832->tilemap_draw(screen, bitmap, cliprect, layer[2], 0, 4); + m_k056832->tilemap_draw(screen, bitmap, cliprect, layer[3], 0, 8); + + m_k053246->k053247_sprites_draw( bitmap, cliprect); + return 0; +} + + uint16_t gijoe_state::control2_r() { return m_cur_control2; @@ -545,6 +759,8 @@ ROM_START( gijoea ) ROM_LOAD( "er5911.7d", 0x0000, 0x080, CRC(6363513c) SHA1(181cbf2bd4960740d437c714dc70bb7e64c95348) ) // sldh ROM_END +} // anonymous namespace + GAME( 1992, gijoe, 0, gijoe, gijoe, gijoe_state, empty_init, ROT0, "Konami", "G.I. Joe (World, EAB, set 1)", MACHINE_SUPPORTS_SAVE ) GAME( 1992, gijoeea, gijoe, gijoe, gijoe, gijoe_state, empty_init, ROT0, "Konami", "G.I. Joe (World, EB8, prototype?)", MACHINE_SUPPORTS_SAVE ) diff --git a/src/mame/konami/gijoe.h b/src/mame/konami/gijoe.h deleted file mode 100644 index a0238e3f45c..00000000000 --- a/src/mame/konami/gijoe.h +++ /dev/null @@ -1,83 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Olivier Galibert -/************************************************************************* - - GI Joe - -*************************************************************************/ -#ifndef MAME_KONAMI_GIJOE_H -#define MAME_KONAMI_GIJOE_H - -#pragma once - -#include "sound/k054539.h" -#include "k053251.h" -#include "k054156_k054157_k056832.h" -#include "k053246_k053247_k055673.h" -#include "konami_helper.h" -#include "machine/k054321.h" -#include "emupal.h" - -class gijoe_state : public driver_device -{ -public: - gijoe_state(const machine_config &mconfig, device_type type, const char *tag) : - driver_device(mconfig, type, tag), - m_spriteram(*this, "spriteram"), - m_workram(*this, "workram"), - m_maincpu(*this, "maincpu"), - m_audiocpu(*this, "audiocpu"), - m_k054539(*this, "k054539"), - m_k056832(*this, "k056832"), - m_k053246(*this, "k053246"), - m_k053251(*this, "k053251"), - m_palette(*this, "palette"), - m_k054321(*this, "k054321") - { } - - void gijoe(machine_config &config); - -private: - /* memory pointers */ - required_shared_ptr m_spriteram; - required_shared_ptr m_workram; - - /* video-related */ - int m_avac_bits[4]{}; - int m_avac_occupancy[4]{}; - int m_layer_colorbase[4]{}; - int m_layer_pri[4]{}; - int m_avac_vrc = 0; - int m_sprite_colorbase = 0; - - /* misc */ - uint16_t m_cur_control2 = 0U; - emu_timer *m_dmadelay_timer = nullptr; - - /* devices */ - required_device m_maincpu; - required_device m_audiocpu; - required_device m_k054539; - required_device m_k056832; - required_device m_k053246; - required_device m_k053251; - required_device m_palette; - required_device m_k054321; - - uint16_t control2_r(); - void control2_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); - void sound_irq_w(uint16_t data); - virtual void machine_start() override; - virtual void machine_reset() override; - virtual void video_start() override; - uint32_t screen_update_gijoe(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - INTERRUPT_GEN_MEMBER(gijoe_interrupt); - TIMER_CALLBACK_MEMBER(dmaend_callback); - void gijoe_objdma(); - K056832_CB_MEMBER(tile_callback); - K053246_CB_MEMBER(sprite_callback); - void gijoe_map(address_map &map); - void sound_map(address_map &map); -}; - -#endif // MAME_KONAMI_GIJOE_H diff --git a/src/mame/konami/gijoe_v.cpp b/src/mame/konami/gijoe_v.cpp deleted file mode 100644 index 72ddf914228..00000000000 --- a/src/mame/konami/gijoe_v.cpp +++ /dev/null @@ -1,168 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Olivier Galibert -#include "emu.h" -#include "gijoe.h" - -K053246_CB_MEMBER(gijoe_state::sprite_callback) -{ - int pri = (*color & 0x03e0) >> 4; - - if (pri <= m_layer_pri[3]) - *priority_mask = 0; - else if (pri > m_layer_pri[3] && pri <= m_layer_pri[2]) - *priority_mask = 0xff00; - else if (pri > m_layer_pri[2] && pri <= m_layer_pri[1]) - *priority_mask = 0xff00 | 0xf0f0; - else if (pri > m_layer_pri[1] && pri <= m_layer_pri[0]) - *priority_mask = 0xff00 | 0xf0f0 | 0xcccc; - else - *priority_mask = 0xff00 | 0xf0f0 | 0xcccc | 0xaaaa; - - *color = m_sprite_colorbase | (*color & 0x001f); -} - -K056832_CB_MEMBER(gijoe_state::tile_callback) -{ - int tile = *code; - - if (tile >= 0xf000 && tile <= 0xf4ff) - { - tile &= 0x0fff; - if (tile < 0x0310) - { - m_avac_occupancy[layer] |= 0x0f00; - tile |= m_avac_bits[0]; - } - else if (tile < 0x0470) - { - m_avac_occupancy[layer] |= 0xf000; - tile |= m_avac_bits[1]; - } - else - { - m_avac_occupancy[layer] |= 0x00f0; - tile |= m_avac_bits[2]; - } - *code = tile; - } - - *color = (*color >> 2 & 0x0f) | m_layer_colorbase[layer]; -} - -void gijoe_state::video_start() -{ - int i; - - m_k056832->linemap_enable(1); - - for (i = 0; i < 4; i++) - { - m_avac_occupancy[i] = 0; - m_avac_bits[i] = 0; - m_layer_colorbase[i] = 0; - m_layer_pri[i] = 0; - } - - m_avac_vrc = 0xffff; - - save_item(NAME(m_avac_vrc)); - save_item(NAME(m_sprite_colorbase)); - save_item(NAME(m_avac_occupancy)); - save_item(NAME(m_avac_bits)); // these could possibly be re-created at postload k056832 elements - save_item(NAME(m_layer_colorbase)); - save_item(NAME(m_layer_pri)); -} - -uint32_t gijoe_state::screen_update_gijoe(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - static const int K053251_CI[4] = { k053251_device::CI1, k053251_device::CI2, k053251_device::CI3, k053251_device::CI4 }; - int layer[4]; - int vrc_mode, vrc_new, colorbase_new, /*primode,*/ dirty, i; - int mask = 0; - - // update tile offsets - m_k056832->read_avac(&vrc_mode, &vrc_new); - - if (vrc_mode) - { - for (dirty = 0xf000; dirty; dirty >>= 4) - if ((m_avac_vrc & dirty) != (vrc_new & dirty)) - mask |= dirty; - - m_avac_vrc = vrc_new; - m_avac_bits[0] = vrc_new << 4 & 0xf000; - m_avac_bits[1] = vrc_new & 0xf000; - m_avac_bits[2] = vrc_new << 8 & 0xf000; - m_avac_bits[3] = vrc_new << 12 & 0xf000; - } - else - m_avac_bits[3] = m_avac_bits[2] = m_avac_bits[1] = m_avac_bits[0] = 0xf000; - - // update color info and refresh tilemaps - m_sprite_colorbase = m_k053251->get_palette_index(k053251_device::CI0); - - for (i = 0; i < 4; i++) - { - dirty = 0; - colorbase_new = m_k053251->get_palette_index(K053251_CI[i]); - if (m_layer_colorbase[i] != colorbase_new) - { - m_layer_colorbase[i] = colorbase_new; - dirty = 1; - } - if (m_avac_occupancy[i] & mask) - dirty = 1; - - if (dirty) - { - m_avac_occupancy[i] = 0; - m_k056832->mark_plane_dirty( i); - } - } - - /* - Layer A is supposed to be a non-scrolling status display with static X-offset. - The weird thing is tilemap alignment only follows the 832 standard when 2 is - written to the layer's X-scroll register otherwise the chip expects totally - different alignment values. - */ - if (m_k056832->read_register(0x14) == 2) - { - m_k056832->set_layer_offs(0, 2, 0); - m_k056832->set_layer_offs(1, 4, 0); - m_k056832->set_layer_offs(2, 6, 0); // 7? - m_k056832->set_layer_offs(3, 8, 0); - } - else - { - m_k056832->set_layer_offs(0, 0, 0); - m_k056832->set_layer_offs(1, 8, 0); - m_k056832->set_layer_offs(2, 14, 0); - m_k056832->set_layer_offs(3, 16, 0); // smaller? - } - - // seems to switch the K053251 between different priority modes, detail unknown - // primode = m_k053251->get_priority(k053251_device::CI1); - - layer[0] = 0; - m_layer_pri[0] = 0; // not sure - layer[1] = 1; - m_layer_pri[1] = m_k053251->get_priority(k053251_device::CI2); - layer[2] = 2; - m_layer_pri[2] = m_k053251->get_priority(k053251_device::CI3); - layer[3] = 3; - m_layer_pri[3] = m_k053251->get_priority(k053251_device::CI4); - - konami_sortlayers4(layer, m_layer_pri); - - bitmap.fill(m_palette->black_pen(), cliprect); - screen.priority().fill(0, cliprect); - - m_k056832->tilemap_draw(screen, bitmap, cliprect, layer[0], 0, 1); - m_k056832->tilemap_draw(screen, bitmap, cliprect, layer[1], 0, 2); - m_k056832->tilemap_draw(screen, bitmap, cliprect, layer[2], 0, 4); - m_k056832->tilemap_draw(screen, bitmap, cliprect, layer[3], 0, 8); - - m_k053246->k053247_sprites_draw( bitmap, cliprect); - return 0; -} diff --git a/src/mame/konami/gradius3.cpp b/src/mame/konami/gradius3.cpp index c31d15937b3..13646e31274 100644 --- a/src/mame/konami/gradius3.cpp +++ b/src/mame/konami/gradius3.cpp @@ -23,19 +23,204 @@ ***************************************************************************/ #include "emu.h" -#include "gradius3.h" + +#include "k052109.h" +#include "k051960.h" #include "konamipt.h" +#include "konami_helper.h" #include "cpu/m68000/m68000.h" #include "cpu/z80/z80.h" #include "machine/gen_latch.h" +#include "machine/timer.h" #include "machine/watchdog.h" +#include "sound/k007232.h" #include "sound/ymopm.h" #include "emupal.h" #include "speaker.h" +namespace { + +class gradius3_state : public driver_device +{ +public: + gradius3_state(const machine_config &mconfig, device_type type, const char *tag) : + driver_device(mconfig, type, tag), + m_gfxram(*this, "k052109"), + m_gfxrom(*this, "k051960"), + m_maincpu(*this, "maincpu"), + m_audiocpu(*this, "audiocpu"), + m_subcpu(*this, "sub"), + m_k007232(*this, "k007232"), + m_k052109(*this, "k052109"), + m_k051960(*this, "k051960") + { } + + void gradius3(machine_config &config); + +private: + /* memory pointers */ + required_shared_ptr m_gfxram; + required_region_ptr m_gfxrom; + + /* misc */ + int m_priority = 0; + int m_irqAen = 0; + int m_irqBmask = 0; + + /* devices */ + required_device m_maincpu; + required_device m_audiocpu; + required_device m_subcpu; + required_device m_k007232; + required_device m_k052109; + required_device m_k051960; + + uint16_t k052109_halfword_r(offs_t offset); + void k052109_halfword_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); + void cpuA_ctrl_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); + void cpuB_irqenable_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); + void cpuB_irqtrigger_w(uint16_t data); + void sound_irq_w(uint16_t data); + uint16_t gradius3_gfxrom_r(offs_t offset); + void gradius3_gfxram_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); + void sound_bank_w(uint8_t data); + virtual void machine_start() override; + virtual void machine_reset() override; + virtual void video_start() override; + uint32_t screen_update_gradius3(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); + INTERRUPT_GEN_MEMBER(cpuA_interrupt); + TIMER_DEVICE_CALLBACK_MEMBER(gradius3_sub_scanline); + void gradius3_postload(); + void volume_callback(uint8_t data); + K052109_CB_MEMBER(tile_callback); + K051960_CB_MEMBER(sprite_callback); + void gradius3_map(address_map &map); + void gradius3_map2(address_map &map); + void gradius3_s_map(address_map &map); +}; + + +/*************************************************************************** + + Callbacks for the K052109 + +***************************************************************************/ + +K052109_CB_MEMBER(gradius3_state::tile_callback) +{ + static const int layer_colorbase[] = { 0 / 16, 512 / 16, 768 / 16 }; + + /* (color & 0x02) is flip y handled internally by the 052109 */ + *code |= ((*color & 0x01) << 8) | ((*color & 0x1c) << 7); + *color = layer_colorbase[layer] + ((*color & 0xe0) >> 5); +} + +/*************************************************************************** + + Callbacks for the K051960 + +***************************************************************************/ + +K051960_CB_MEMBER(gradius3_state::sprite_callback) +{ + enum { sprite_colorbase = 256 / 16 }; + + #define L0 GFX_PMASK_1 + #define L1 GFX_PMASK_2 + #define L2 GFX_PMASK_4 + static const int primask[2][4] = + { + { L0|L2, L0, L0|L2, L0|L1|L2 }, + { L1|L2, L2, 0, L0|L1|L2 } + }; + #undef L0 + #undef L1 + #undef L2 + + int pri = ((*color & 0x60) >> 5); + + if (m_priority == 0) + *priority = primask[0][pri]; + else + *priority = primask[1][pri]; + + *code |= (*color & 0x01) << 13; + *color = sprite_colorbase + ((*color & 0x1e) >> 1); +} + +/*************************************************************************** + + Start the video hardware emulation. + +***************************************************************************/ + +void gradius3_state::gradius3_postload() +{ + m_k052109->gfx(0)->mark_all_dirty(); +} + +void gradius3_state::video_start() +{ + machine().save().register_postload(save_prepost_delegate(FUNC(gradius3_state::gradius3_postload), this)); +} + +/*************************************************************************** + + Memory handlers + +***************************************************************************/ + +uint16_t gradius3_state::gradius3_gfxrom_r(offs_t offset) +{ + return (m_gfxrom[2 * offset + 1] << 8) | m_gfxrom[2 * offset]; +} + +void gradius3_state::gradius3_gfxram_w(offs_t offset, uint16_t data, uint16_t mem_mask) +{ + int oldword = m_gfxram[offset]; + + COMBINE_DATA(&m_gfxram[offset]); + + if (oldword != m_gfxram[offset]) + m_k052109->gfx(0)->mark_dirty(offset / 16); +} + +/*************************************************************************** + + Display refresh + +***************************************************************************/ + +uint32_t gradius3_state::screen_update_gradius3(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) +{ + /* TODO: this kludge enforces the char banks. For some reason, they don't work otherwise. */ + m_k052109->write(0x1d80, 0x10); + m_k052109->write(0x1f00, 0x32); + + m_k052109->tilemap_update(); + + screen.priority().fill(0, cliprect); + if (m_priority == 0) + { + m_k052109->tilemap_draw(screen, bitmap, cliprect, 1, TILEMAP_DRAW_OPAQUE, 2); + m_k052109->tilemap_draw(screen, bitmap, cliprect, 2, 0, 4); + m_k052109->tilemap_draw(screen, bitmap, cliprect, 0, 0, 1); + } + else + { + m_k052109->tilemap_draw(screen, bitmap, cliprect, 0, TILEMAP_DRAW_OPAQUE, 1); + m_k052109->tilemap_draw(screen, bitmap, cliprect, 1, 0, 2); + m_k052109->tilemap_draw(screen, bitmap, cliprect, 2, 0, 4); + } + + m_k051960->k051960_sprites_draw(bitmap, cliprect, screen.priority(), -1, -1); + return 0; +} + + uint16_t gradius3_state::k052109_halfword_r(offs_t offset) { return m_k052109->read(offset); @@ -486,6 +671,7 @@ ROM_START( gradius3a ) ROM_LOAD( "945_l11b.c20", 0x60000, 0x20000, CRC(89ea3baf) SHA1(8edcbaa7969185cfac48c02559826d1b8b081f3f) ) ROM_END +} // anonymous namespace GAME( 1989, gradius3, 0, gradius3, gradius3, gradius3_state, empty_init, ROT0, "Konami", "Gradius III (World, program code R)", MACHINE_SUPPORTS_SAVE ) diff --git a/src/mame/konami/gradius3.h b/src/mame/konami/gradius3.h deleted file mode 100644 index cc58657de49..00000000000 --- a/src/mame/konami/gradius3.h +++ /dev/null @@ -1,78 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Nicola Salmoria -/************************************************************************* - - Gradius 3 - -*************************************************************************/ -#ifndef MAME_KONAMI_GRADIUS3_H -#define MAME_KONAMI_GRADIUS3_H - -#pragma once - -#include "machine/timer.h" -#include "sound/k007232.h" -#include "k052109.h" -#include "k051960.h" -#include "konami_helper.h" - -class gradius3_state : public driver_device -{ -public: - gradius3_state(const machine_config &mconfig, device_type type, const char *tag) : - driver_device(mconfig, type, tag), - m_gfxram(*this, "k052109"), - m_gfxrom(*this, "k051960"), - m_maincpu(*this, "maincpu"), - m_audiocpu(*this, "audiocpu"), - m_subcpu(*this, "sub"), - m_k007232(*this, "k007232"), - m_k052109(*this, "k052109"), - m_k051960(*this, "k051960") - { } - - void gradius3(machine_config &config); - -private: - /* memory pointers */ - required_shared_ptr m_gfxram; - required_region_ptr m_gfxrom; - - /* misc */ - int m_priority = 0; - int m_irqAen = 0; - int m_irqBmask = 0; - - /* devices */ - required_device m_maincpu; - required_device m_audiocpu; - required_device m_subcpu; - required_device m_k007232; - required_device m_k052109; - required_device m_k051960; - - uint16_t k052109_halfword_r(offs_t offset); - void k052109_halfword_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); - void cpuA_ctrl_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); - void cpuB_irqenable_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); - void cpuB_irqtrigger_w(uint16_t data); - void sound_irq_w(uint16_t data); - uint16_t gradius3_gfxrom_r(offs_t offset); - void gradius3_gfxram_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); - void sound_bank_w(uint8_t data); - virtual void machine_start() override; - virtual void machine_reset() override; - virtual void video_start() override; - uint32_t screen_update_gradius3(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - INTERRUPT_GEN_MEMBER(cpuA_interrupt); - TIMER_DEVICE_CALLBACK_MEMBER(gradius3_sub_scanline); - void gradius3_postload(); - void volume_callback(uint8_t data); - K052109_CB_MEMBER(tile_callback); - K051960_CB_MEMBER(sprite_callback); - void gradius3_map(address_map &map); - void gradius3_map2(address_map &map); - void gradius3_s_map(address_map &map); -}; - -#endif // MAME_KONAMI_GRADIUS3_H diff --git a/src/mame/konami/gradius3_v.cpp b/src/mame/konami/gradius3_v.cpp deleted file mode 100644 index bd9e1d40784..00000000000 --- a/src/mame/konami/gradius3_v.cpp +++ /dev/null @@ -1,124 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Nicola Salmoria - -#include "emu.h" -#include "gradius3.h" -#include "screen.h" - - -/*************************************************************************** - - Callbacks for the K052109 - -***************************************************************************/ - -K052109_CB_MEMBER(gradius3_state::tile_callback) -{ - static const int layer_colorbase[] = { 0 / 16, 512 / 16, 768 / 16 }; - - /* (color & 0x02) is flip y handled internally by the 052109 */ - *code |= ((*color & 0x01) << 8) | ((*color & 0x1c) << 7); - *color = layer_colorbase[layer] + ((*color & 0xe0) >> 5); -} - -/*************************************************************************** - - Callbacks for the K051960 - -***************************************************************************/ - -K051960_CB_MEMBER(gradius3_state::sprite_callback) -{ - enum { sprite_colorbase = 256 / 16 }; - - #define L0 GFX_PMASK_1 - #define L1 GFX_PMASK_2 - #define L2 GFX_PMASK_4 - static const int primask[2][4] = - { - { L0|L2, L0, L0|L2, L0|L1|L2 }, - { L1|L2, L2, 0, L0|L1|L2 } - }; - #undef L0 - #undef L1 - #undef L2 - - int pri = ((*color & 0x60) >> 5); - - if (m_priority == 0) - *priority = primask[0][pri]; - else - *priority = primask[1][pri]; - - *code |= (*color & 0x01) << 13; - *color = sprite_colorbase + ((*color & 0x1e) >> 1); -} - -/*************************************************************************** - - Start the video hardware emulation. - -***************************************************************************/ - -void gradius3_state::gradius3_postload() -{ - m_k052109->gfx(0)->mark_all_dirty(); -} - -void gradius3_state::video_start() -{ - machine().save().register_postload(save_prepost_delegate(FUNC(gradius3_state::gradius3_postload), this)); -} - -/*************************************************************************** - - Memory handlers - -***************************************************************************/ - -uint16_t gradius3_state::gradius3_gfxrom_r(offs_t offset) -{ - return (m_gfxrom[2 * offset + 1] << 8) | m_gfxrom[2 * offset]; -} - -void gradius3_state::gradius3_gfxram_w(offs_t offset, uint16_t data, uint16_t mem_mask) -{ - int oldword = m_gfxram[offset]; - - COMBINE_DATA(&m_gfxram[offset]); - - if (oldword != m_gfxram[offset]) - m_k052109->gfx(0)->mark_dirty(offset / 16); -} - -/*************************************************************************** - - Display refresh - -***************************************************************************/ - -uint32_t gradius3_state::screen_update_gradius3(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - /* TODO: this kludge enforces the char banks. For some reason, they don't work otherwise. */ - m_k052109->write(0x1d80, 0x10); - m_k052109->write(0x1f00, 0x32); - - m_k052109->tilemap_update(); - - screen.priority().fill(0, cliprect); - if (m_priority == 0) - { - m_k052109->tilemap_draw(screen, bitmap, cliprect, 1, TILEMAP_DRAW_OPAQUE, 2); - m_k052109->tilemap_draw(screen, bitmap, cliprect, 2, 0, 4); - m_k052109->tilemap_draw(screen, bitmap, cliprect, 0, 0, 1); - } - else - { - m_k052109->tilemap_draw(screen, bitmap, cliprect, 0, TILEMAP_DRAW_OPAQUE, 1); - m_k052109->tilemap_draw(screen, bitmap, cliprect, 1, 0, 2); - m_k052109->tilemap_draw(screen, bitmap, cliprect, 2, 0, 4); - } - - m_k051960->k051960_sprites_draw(bitmap, cliprect, screen.priority(), -1, -1); - return 0; -} diff --git a/src/mame/konami/lethal.cpp b/src/mame/konami/lethal.cpp index 145bc34ac98..bd29990bdc4 100644 --- a/src/mame/konami/lethal.cpp +++ b/src/mame/konami/lethal.cpp @@ -247,19 +247,178 @@ maybe some sprite placement issues ***************************************************************************/ #include "emu.h" -#include "lethal.h" + +#include "k053244_k053245.h" +#include "k054156_k054157_k056832.h" +#include "k054000.h" +#include "konami_helper.h" #include "cpu/m6809/m6809.h" #include "cpu/m6809/hd6309.h" #include "cpu/z80/z80.h" #include "machine/eepromser.h" +#include "machine/bankdev.h" +#include "machine/k054321.h" #include "sound/k054539.h" +#include "emupal.h" #include "screen.h" #include "speaker.h" +namespace { + +class lethal_state : public driver_device +{ +public: + lethal_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_bank4000(*this, "bank4000"), + m_k056832(*this, "k056832"), + m_k053244(*this, "k053244"), + m_k054321(*this, "k054321"), + m_palette(*this, "palette") + { } + + void lethalej(machine_config &config); + void lethalen(machine_config &config); + +private: + /* video-related */ + int m_layer_colorbase[4]{}; + int m_sprite_colorbase = 0; + int m_back_colorbase = 0; + + /* misc */ + uint8_t m_cur_control2 = 0U; + + /* devices */ + required_device m_maincpu; + required_device m_soundcpu; + required_device m_bank4000; + required_device m_k056832; + required_device m_k053244; + required_device m_k054321; + required_device m_palette; + + void control2_w(uint8_t data); + uint8_t sound_irq_r(); + void sound_irq_w(uint8_t data); + void le_bankswitch_w(uint8_t data); + uint8_t guns_r(offs_t offset); + uint8_t gunsaux_r(); + void lethalen_palette_control(offs_t offset, uint8_t data); + virtual void machine_start() override; + virtual void machine_reset() override; + virtual void video_start() override; + uint32_t screen_update_lethalen(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); + INTERRUPT_GEN_MEMBER(lethalen_interrupt); + K05324X_CB_MEMBER(sprite_callback); + K056832_CB_MEMBER(tile_callback); + void bank4000_map(address_map &map); + void le_main(address_map &map); + void le_sound(address_map &map); +}; + + +K05324X_CB_MEMBER(lethal_state::sprite_callback) +{ + int pri = (*color & 0xfff0); + *color = *color & 0x000f; + *color += m_sprite_colorbase; + + /* this isn't ideal.. shouldn't need to hardcode it? not 100% sure about it anyway*/ + if (pri == 0x10) + *priority = 0xf0; // guys on first level + else if (pri == 0x90) + *priority = 0xf0; // car doors + else if (pri == 0x20) + *priority = 0xf0 | 0xcc; // people behind glass on 1st level + else if (pri == 0xa0) + *priority = 0xf0 | 0xcc; // glass on 1st/2nd level + else if (pri == 0x40) + *priority = 0; // blood splats? + else if (pri == 0x00) + *priority = 0; // gunshots etc + else if (pri == 0x30) + *priority = 0xf0 | 0xcc | 0xaa; // mask sprites (always in a bad colour, used to do special effects i think + else + { + popmessage("unknown pri %04x\n", pri); + *priority = 0; + } + + *code = (*code & 0x3fff); // | spritebanks[(*code >> 12) & 3]; +} + +K056832_CB_MEMBER(lethal_state::tile_callback) +{ + *color = m_layer_colorbase[layer] + ((*color & 0x3c) << 2); +} + +void lethal_state::video_start() +{ + // this game uses external linescroll RAM + m_k056832->SetExtLinescroll(); + + // the US and Japanese cabinets apparently use different mirror setups + if (!strcmp(machine().system().name, "lethalenj")) + { + m_k056832->set_layer_offs(0, 29, 0); + m_k056832->set_layer_offs(1, 31, 0); + m_k056832->set_layer_offs(2, 33, 0); + m_k056832->set_layer_offs(3, 35, 0); + } + else + { + m_k056832->set_layer_offs(0, 188, 0); + m_k056832->set_layer_offs(1, 190, 0); + m_k056832->set_layer_offs(2, 192, 0); + m_k056832->set_layer_offs(3, 194, 0); + } +} + +void lethal_state::lethalen_palette_control(offs_t offset, uint8_t data) +{ + switch (offset) + { + case 0: // 40c8 - PCU1 from schematics + m_layer_colorbase[0] = (data & 0x7) * 1024 / 16; + m_layer_colorbase[1] = ((data >> 4) & 0x7) * 1024 / 16; + m_k056832->mark_plane_dirty( 0); + m_k056832->mark_plane_dirty( 1); + break; + + case 4: // 40cc - PCU2 from schematics + m_layer_colorbase[2] = (data & 0x7) * 1024 / 16; + m_layer_colorbase[3] = ((data >> 4) & 0x7) * 1024 / 16; + m_k056832->mark_plane_dirty( 2); + m_k056832->mark_plane_dirty( 3); + break; + + case 8: // 40d0 - PCU3 from schematics + m_sprite_colorbase = (data & 0x7) * 1024 / 64; + m_back_colorbase = ((data >> 4) & 0x7) * 1024 + 1023; + break; + } +} -#define MAIN_CLOCK XTAL(24'000'000) -#define SOUND_CLOCK XTAL(18'432'000) +uint32_t lethal_state::screen_update_lethalen(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) +{ + bitmap.fill(m_back_colorbase, cliprect); + screen.priority().fill(0, cliprect); + + m_k056832->tilemap_draw(screen, bitmap, cliprect, 3, K056832_DRAW_FLAG_MIRROR, 1); + m_k056832->tilemap_draw(screen, bitmap, cliprect, 2, K056832_DRAW_FLAG_MIRROR, 2); + m_k056832->tilemap_draw(screen, bitmap, cliprect, 1, K056832_DRAW_FLAG_MIRROR, 4); + + m_k053244->sprites_draw(bitmap, cliprect, screen.priority()); + + // force "A" layer over top of everything + m_k056832->tilemap_draw(screen, bitmap, cliprect, 0, K056832_DRAW_FLAG_MIRROR, 0); + + return 0; +} static const char *const gunnames[] = { "LIGHT0_X", "LIGHT0_Y", "LIGHT1_X", "LIGHT1_Y" }; @@ -491,6 +650,9 @@ void lethal_state::machine_reset() void lethal_state::lethalen(machine_config &config) { + constexpr XTAL MAIN_CLOCK = 24_MHz_XTAL; + constexpr XTAL SOUND_CLOCK = 18.432_MHz_XTAL; + /* basic machine hardware */ HD6309(config, m_maincpu, MAIN_CLOCK/2); /* verified on pcb */ m_maincpu->set_addrmap(AS_PROGRAM, &lethal_state::le_main); @@ -534,7 +696,7 @@ void lethal_state::lethalen(machine_config &config) K054321(config, m_k054321, "lspeaker", "rspeaker"); - k054539_device &k054539(K054539(config, "k054539", XTAL(18'432'000))); + k054539_device &k054539(K054539(config, "k054539", SOUND_CLOCK)); k054539.timer_handler().set_inputline("soundcpu", INPUT_LINE_NMI); k054539.add_route(0, "rspeaker", 1.0); k054539.add_route(1, "lspeaker", 1.0); @@ -776,6 +938,8 @@ ROM_END // date strings are at 0x3fd00 in the main program rom +} // anonymous namespace + GAME( 1992, lethalen, 0, lethalen, lethalen, lethal_state, empty_init, ORIENTATION_FLIP_Y, "Konami", "Lethal Enforcers (ver UAE, 11/19/92 15:04)", MACHINE_IMPERFECT_GRAPHICS | MACHINE_SUPPORTS_SAVE ) // writes UE to eeprom GAME( 1992, lethalenub, lethalen, lethalen, lethalen, lethal_state, empty_init, ORIENTATION_FLIP_Y, "Konami", "Lethal Enforcers (ver UAB, 09/01/92 11:12)", MACHINE_IMPERFECT_GRAPHICS | MACHINE_SUPPORTS_SAVE ) // writes UB to eeprom GAME( 1992, lethalenua, lethalen, lethalen, lethalen, lethal_state, empty_init, ORIENTATION_FLIP_Y, "Konami", "Lethal Enforcers (ver UAA, 08/17/92 21:38)", MACHINE_IMPERFECT_GRAPHICS | MACHINE_SUPPORTS_SAVE ) // writes UA to eeprom diff --git a/src/mame/konami/lethal.h b/src/mame/konami/lethal.h deleted file mode 100644 index ac2786074f3..00000000000 --- a/src/mame/konami/lethal.h +++ /dev/null @@ -1,76 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:R. Belmont, Nicola Salmoria -/************************************************************************* - - Lethal Enforcers - -*************************************************************************/ -#ifndef MAME_KONAMI_LETHAL_H -#define MAME_KONAMI_LETHAL_H - -#pragma once - -#include "machine/bankdev.h" -#include "sound/k054539.h" -#include "konami_helper.h" -#include "k054156_k054157_k056832.h" -#include "k053244_k053245.h" -#include "k054000.h" -#include "machine/k054321.h" -#include "emupal.h" - -class lethal_state : public driver_device -{ -public: - lethal_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_bank4000(*this, "bank4000"), - m_k056832(*this, "k056832"), - m_k053244(*this, "k053244"), - m_k054321(*this, "k054321"), - m_palette(*this, "palette") - { } - - void lethalej(machine_config &config); - void lethalen(machine_config &config); - -private: - /* video-related */ - int m_layer_colorbase[4]{}; - int m_sprite_colorbase = 0; - int m_back_colorbase = 0; - - /* misc */ - uint8_t m_cur_control2 = 0U; - - /* devices */ - required_device m_maincpu; - required_device m_soundcpu; - required_device m_bank4000; - required_device m_k056832; - required_device m_k053244; - required_device m_k054321; - required_device m_palette; - - void control2_w(uint8_t data); - uint8_t sound_irq_r(); - void sound_irq_w(uint8_t data); - void le_bankswitch_w(uint8_t data); - uint8_t guns_r(offs_t offset); - uint8_t gunsaux_r(); - void lethalen_palette_control(offs_t offset, uint8_t data); - virtual void machine_start() override; - virtual void machine_reset() override; - virtual void video_start() override; - uint32_t screen_update_lethalen(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - INTERRUPT_GEN_MEMBER(lethalen_interrupt); - K05324X_CB_MEMBER(sprite_callback); - K056832_CB_MEMBER(tile_callback); - void bank4000_map(address_map &map); - void le_main(address_map &map); - void le_sound(address_map &map); -}; - -#endif // MAME_KONAMI_LETHAL_H diff --git a/src/mame/konami/lethal_v.cpp b/src/mame/konami/lethal_v.cpp deleted file mode 100644 index 4337ad43171..00000000000 --- a/src/mame/konami/lethal_v.cpp +++ /dev/null @@ -1,114 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:R. Belmont, Nicola Salmoria -/*************************************************************************** - - Lethal Enforcers - (c) 1992 Konami - - Video hardware emulation. - -***************************************************************************/ - -#include "emu.h" -#include "lethal.h" -#include "screen.h" - - -K05324X_CB_MEMBER(lethal_state::sprite_callback) -{ - int pri = (*color & 0xfff0); - *color = *color & 0x000f; - *color += m_sprite_colorbase; - - /* this isn't ideal.. shouldn't need to hardcode it? not 100% sure about it anyway*/ - if (pri == 0x10) - *priority = 0xf0; // guys on first level - else if (pri == 0x90) - *priority = 0xf0; // car doors - else if (pri == 0x20) - *priority = 0xf0 | 0xcc; // people behind glass on 1st level - else if (pri == 0xa0) - *priority = 0xf0 | 0xcc; // glass on 1st/2nd level - else if (pri == 0x40) - *priority = 0; // blood splats? - else if (pri == 0x00) - *priority = 0; // gunshots etc - else if (pri == 0x30) - *priority = 0xf0 | 0xcc | 0xaa; // mask sprites (always in a bad colour, used to do special effects i think - else - { - popmessage("unknown pri %04x\n", pri); - *priority = 0; - } - - *code = (*code & 0x3fff); // | spritebanks[(*code >> 12) & 3]; -} - -K056832_CB_MEMBER(lethal_state::tile_callback) -{ - *color = m_layer_colorbase[layer] + ((*color & 0x3c) << 2); -} - -void lethal_state::video_start() -{ - // this game uses external linescroll RAM - m_k056832->SetExtLinescroll(); - - // the US and Japanese cabinets apparently use different mirror setups - if (!strcmp(machine().system().name, "lethalenj")) - { - m_k056832->set_layer_offs(0, 29, 0); - m_k056832->set_layer_offs(1, 31, 0); - m_k056832->set_layer_offs(2, 33, 0); - m_k056832->set_layer_offs(3, 35, 0); - } - else - { - m_k056832->set_layer_offs(0, 188, 0); - m_k056832->set_layer_offs(1, 190, 0); - m_k056832->set_layer_offs(2, 192, 0); - m_k056832->set_layer_offs(3, 194, 0); - } -} - -void lethal_state::lethalen_palette_control(offs_t offset, uint8_t data) -{ - switch (offset) - { - case 0: // 40c8 - PCU1 from schematics - m_layer_colorbase[0] = (data & 0x7) * 1024 / 16; - m_layer_colorbase[1] = ((data >> 4) & 0x7) * 1024 / 16; - m_k056832->mark_plane_dirty( 0); - m_k056832->mark_plane_dirty( 1); - break; - - case 4: // 40cc - PCU2 from schematics - m_layer_colorbase[2] = (data & 0x7) * 1024 / 16; - m_layer_colorbase[3] = ((data >> 4) & 0x7) * 1024 / 16; - m_k056832->mark_plane_dirty( 2); - m_k056832->mark_plane_dirty( 3); - break; - - case 8: // 40d0 - PCU3 from schematics - m_sprite_colorbase = (data & 0x7) * 1024 / 64; - m_back_colorbase = ((data >> 4) & 0x7) * 1024 + 1023; - break; - } -} - -uint32_t lethal_state::screen_update_lethalen(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - bitmap.fill(m_back_colorbase, cliprect); - screen.priority().fill(0, cliprect); - - m_k056832->tilemap_draw(screen, bitmap, cliprect, 3, K056832_DRAW_FLAG_MIRROR, 1); - m_k056832->tilemap_draw(screen, bitmap, cliprect, 2, K056832_DRAW_FLAG_MIRROR, 2); - m_k056832->tilemap_draw(screen, bitmap, cliprect, 1, K056832_DRAW_FLAG_MIRROR, 4); - - m_k053244->sprites_draw(bitmap, cliprect, screen.priority()); - - // force "A" layer over top of everything - m_k056832->tilemap_draw(screen, bitmap, cliprect, 0, K056832_DRAW_FLAG_MIRROR, 0); - - return 0; -} diff --git a/src/mame/konami/moo.cpp b/src/mame/konami/moo.cpp index 98726f8d300..fc36490c79d 100644 --- a/src/mame/konami/moo.cpp +++ b/src/mame/konami/moo.cpp @@ -115,20 +115,235 @@ Bucky: ***************************************************************************/ #include "emu.h" -#include "moo.h" + +#include "k053246_k053247_k055673.h" +#include "k053251.h" +#include "k054156_k054157_k056832.h" +#include "k054000.h" +#include "k054338.h" #include "konamipt.h" +#include "konami_helper.h" #include "cpu/m68000/m68000.h" #include "cpu/z80/z80.h" #include "machine/eepromser.h" +#include "machine/k053252.h" +#include "machine/k054321.h" #include "sound/k054539.h" #include "sound/okim6295.h" #include "sound/ymopm.h" +#include "emupal.h" +#include "screen.h" #include "speaker.h" +namespace { + #define MOO_DEBUG 0 #define MOO_DMADELAY (100) +class moo_state : public driver_device +{ +public: + moo_state(const machine_config &mconfig, device_type type, const char *tag) : + driver_device(mconfig, type, tag), + m_workram(*this, "workram"), + m_spriteram(*this, "spriteram"), + m_maincpu(*this, "maincpu"), + m_soundcpu(*this, "soundcpu"), + m_oki(*this, "oki"), + m_k054539(*this, "k054539"), + m_k053246(*this, "k053246"), + m_k053251(*this, "k053251"), + m_k053252(*this, "k053252"), + m_k056832(*this, "k056832"), + m_k054338(*this, "k054338"), + m_palette(*this, "palette"), + m_screen(*this, "screen"), + m_k054321(*this, "k054321") + { } + + void bucky(machine_config &config) ATTR_COLD; + void moo(machine_config &config) ATTR_COLD; + void moobl(machine_config &config) ATTR_COLD; + +protected: + virtual void machine_start() override ATTR_COLD; + virtual void machine_reset() override ATTR_COLD; + +private: + /* memory pointers */ + optional_shared_ptr m_workram; + required_shared_ptr m_spriteram; + + /* video-related */ + int m_sprite_colorbase = 0; + int m_layer_colorbase[4]; + int m_layerpri[3]; + int m_alpha_enabled = 0; + uint16_t m_zmask = 0; + + /* misc */ + uint16_t m_protram[16]; + uint16_t m_cur_control2 = 0; + + /* devices */ + required_device m_maincpu; + optional_device m_soundcpu; + optional_device m_oki; + optional_device m_k054539; + required_device m_k053246; + required_device m_k053251; + optional_device m_k053252; + required_device m_k056832; + required_device m_k054338; + required_device m_palette; + required_device m_screen; + optional_device m_k054321; + + emu_timer *m_dmaend_timer = nullptr; + uint16_t control2_r(); + void control2_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); + void sound_irq_w(uint16_t data); + void sound_bankswitch_w(uint8_t data); + void moo_prot_w(address_space &space, offs_t offset, uint16_t data, uint16_t mem_mask = ~0); + void moobl_oki_bank_w(uint16_t data); + DECLARE_VIDEO_START(moo); + DECLARE_VIDEO_START(bucky); + uint32_t screen_update_moo(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); + INTERRUPT_GEN_MEMBER(moo_interrupt); + INTERRUPT_GEN_MEMBER(moobl_interrupt); + TIMER_CALLBACK_MEMBER(dmaend_callback); + void moo_objdma(); + K056832_CB_MEMBER(tile_callback); + K053246_CB_MEMBER(sprite_callback); + void bucky_map(address_map &map); + void moo_map(address_map &map); + void moobl_map(address_map &map); + void sound_map(address_map &map); +}; + + +K053246_CB_MEMBER(moo_state::sprite_callback) +{ + int pri = (*color & 0x03e0) >> 4; + + if (pri <= m_layerpri[2]) + *priority_mask = 0; + else if (pri <= m_layerpri[1]) + *priority_mask = 0xf0; + else if (pri <= m_layerpri[0]) + *priority_mask = 0xf0|0xcc; + else + *priority_mask = 0xf0|0xcc|0xaa; + + *color = m_sprite_colorbase | (*color & 0x001f); +} + +K056832_CB_MEMBER(moo_state::tile_callback) +{ + *color = m_layer_colorbase[layer] | (*color >> 2 & 0x0f); +} + +VIDEO_START_MEMBER(moo_state,moo) +{ + assert(m_screen->format() == BITMAP_FORMAT_RGB32); + + m_alpha_enabled = 0; + m_zmask = 0xffff; + + // other than the intro showing one blank line alignment is good through the game + m_k056832->set_layer_offs(0, -2 + 1, 0); + m_k056832->set_layer_offs(1, 2 + 1, 0); + m_k056832->set_layer_offs(2, 4 + 1, 0); + m_k056832->set_layer_offs(3, 6 + 1, 0); +} + +VIDEO_START_MEMBER(moo_state,bucky) +{ + assert(m_screen->format() == BITMAP_FORMAT_RGB32); + + m_alpha_enabled = 0; + m_zmask = 0x00ff; + + // Bucky doesn't chain tilemaps + m_k056832->set_layer_association(0); + + m_k056832->set_layer_offs(0, -2, 0); + m_k056832->set_layer_offs(1, 2, 0); + m_k056832->set_layer_offs(2, 4, 0); + m_k056832->set_layer_offs(3, 6, 0); +} + +uint32_t moo_state::screen_update_moo(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) +{ + static const int K053251_CI[4] = { k053251_device::CI1, k053251_device::CI2, k053251_device::CI3, k053251_device::CI4 }; + int layers[3]; + int new_colorbase, plane, dirty, alpha; + + m_sprite_colorbase = m_k053251->get_palette_index(k053251_device::CI0); + m_layer_colorbase[0] = 0x70; + + if (m_k056832->get_layer_association()) + { + for (plane = 1; plane < 4; plane++) + { + new_colorbase = m_k053251->get_palette_index(K053251_CI[plane]); + if (m_layer_colorbase[plane] != new_colorbase) + { + m_layer_colorbase[plane] = new_colorbase; + m_k056832->mark_plane_dirty( plane); + } + } + } + else + { + for (dirty = 0, plane = 1; plane < 4; plane++) + { + new_colorbase = m_k053251->get_palette_index(K053251_CI[plane]); + if (m_layer_colorbase[plane] != new_colorbase) + { + m_layer_colorbase[plane] = new_colorbase; + dirty = 1; + } + } + if (dirty) + m_k056832->mark_all_tilemaps_dirty(); + } + + layers[0] = 1; + m_layerpri[0] = m_k053251->get_priority(k053251_device::CI2); + layers[1] = 2; + m_layerpri[1] = m_k053251->get_priority(k053251_device::CI3); + layers[2] = 3; + m_layerpri[2] = m_k053251->get_priority(k053251_device::CI4); + + konami_sortlayers3(layers, m_layerpri); + + m_k054338->update_all_shadows(0, *m_palette); + m_k054338->fill_solid_bg(bitmap, cliprect); + + screen.priority().fill(0, cliprect); + + if (m_layerpri[0] < m_k053251->get_priority(k053251_device::CI1)) /* bucky hides back layer behind background */ + m_k056832->tilemap_draw(screen, bitmap, cliprect, layers[0], 0, 1); + + m_k056832->tilemap_draw(screen, bitmap, cliprect, layers[1], 0, 2); + + // Enabling alpha improves fog and fading in Moo but causes other things to disappear. + // There is probably a control bit somewhere to turn off alpha blending. + m_alpha_enabled = m_k054338->register_r(K338_REG_CONTROL) & K338_CTL_MIXPRI; // DUMMY + + alpha = (m_alpha_enabled) ? m_k054338->set_alpha_level(1) : 255; + + if (alpha > 0) + m_k056832->tilemap_draw(screen, bitmap, cliprect, layers[2], TILEMAP_DRAW_ALPHA(alpha), 4); + + m_k053246->k053247_sprites_draw( bitmap, cliprect); + + m_k056832->tilemap_draw(screen, bitmap, cliprect, 0, 0, 0); + return 0; +} + uint16_t moo_state::control2_r() { @@ -1026,6 +1241,8 @@ ROM_START( moomesabl ) ROM_LOAD( "moo.nv", 0x0000, 0x080, CRC(7bd904a8) SHA1(8747c5c62d1832e290be8ace73c61b1f228c0bec) ) ROM_END +} // anonymous namespace + GAME( 1992, moomesa, 0, moo, moo, moo_state, empty_init, ROT0, "Konami", "Wild West C.O.W.-Boys of Moo Mesa (ver EAB)", MACHINE_IMPERFECT_GRAPHICS | MACHINE_SUPPORTS_SAVE ) GAME( 1992, moomesauac, moomesa, moo, moo, moo_state, empty_init, ROT0, "Konami", "Wild West C.O.W.-Boys of Moo Mesa (ver UAC)", MACHINE_IMPERFECT_GRAPHICS | MACHINE_SUPPORTS_SAVE ) diff --git a/src/mame/konami/moo.h b/src/mame/konami/moo.h deleted file mode 100644 index cef3b9becf1..00000000000 --- a/src/mame/konami/moo.h +++ /dev/null @@ -1,107 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:R. Belmont, Acho A. Tang -/************************************************************************* - - Wild West C.O.W.boys of Moo Mesa / Bucky O'Hare - -*************************************************************************/ -#ifndef MAME_KONAMI_MOO_H -#define MAME_KONAMI_MOO_H - -#pragma once - -#include "sound/okim6295.h" -#include "sound/k054539.h" -#include "machine/k053252.h" -#include "k053251.h" -#include "k054156_k054157_k056832.h" -#include "k053246_k053247_k055673.h" -#include "k054000.h" -#include "k054338.h" -#include "machine/k054321.h" -#include "konami_helper.h" -#include "emupal.h" -#include "screen.h" - -class moo_state : public driver_device -{ -public: - moo_state(const machine_config &mconfig, device_type type, const char *tag) : - driver_device(mconfig, type, tag), - m_workram(*this, "workram"), - m_spriteram(*this, "spriteram"), - m_maincpu(*this, "maincpu"), - m_soundcpu(*this, "soundcpu"), - m_oki(*this, "oki"), - m_k054539(*this, "k054539"), - m_k053246(*this, "k053246"), - m_k053251(*this, "k053251"), - m_k053252(*this, "k053252"), - m_k056832(*this, "k056832"), - m_k054338(*this, "k054338"), - m_palette(*this, "palette"), - m_screen(*this, "screen"), - m_k054321(*this, "k054321") - { } - - void bucky(machine_config &config) ATTR_COLD; - void moo(machine_config &config) ATTR_COLD; - void moobl(machine_config &config) ATTR_COLD; - -protected: - virtual void machine_start() override ATTR_COLD; - virtual void machine_reset() override ATTR_COLD; - -private: - /* memory pointers */ - optional_shared_ptr m_workram; - required_shared_ptr m_spriteram; - - /* video-related */ - int m_sprite_colorbase = 0; - int m_layer_colorbase[4]; - int m_layerpri[3]; - int m_alpha_enabled = 0; - uint16_t m_zmask = 0; - - /* misc */ - uint16_t m_protram[16]; - uint16_t m_cur_control2 = 0; - - /* devices */ - required_device m_maincpu; - optional_device m_soundcpu; - optional_device m_oki; - optional_device m_k054539; - required_device m_k053246; - required_device m_k053251; - optional_device m_k053252; - required_device m_k056832; - required_device m_k054338; - required_device m_palette; - required_device m_screen; - optional_device m_k054321; - - emu_timer *m_dmaend_timer = nullptr; - uint16_t control2_r(); - void control2_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); - void sound_irq_w(uint16_t data); - void sound_bankswitch_w(uint8_t data); - void moo_prot_w(address_space &space, offs_t offset, uint16_t data, uint16_t mem_mask = ~0); - void moobl_oki_bank_w(uint16_t data); - DECLARE_VIDEO_START(moo); - DECLARE_VIDEO_START(bucky); - uint32_t screen_update_moo(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); - INTERRUPT_GEN_MEMBER(moo_interrupt); - INTERRUPT_GEN_MEMBER(moobl_interrupt); - TIMER_CALLBACK_MEMBER(dmaend_callback); - void moo_objdma(); - K056832_CB_MEMBER(tile_callback); - K053246_CB_MEMBER(sprite_callback); - void bucky_map(address_map &map); - void moo_map(address_map &map); - void moobl_map(address_map &map); - void sound_map(address_map &map); -}; - -#endif // MAME_KONAMI_MOO_H diff --git a/src/mame/konami/moo_v.cpp b/src/mame/konami/moo_v.cpp deleted file mode 100644 index fa9fa9da734..00000000000 --- a/src/mame/konami/moo_v.cpp +++ /dev/null @@ -1,135 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:R. Belmont, Acho A. Tang -/*************************************************************************** - - Wild West C.O.W.boys of Moo Mesa - Bucky O'Hare - (c) 1992 Konami - - Video hardware emulation. - -***************************************************************************/ - -#include "emu.h" -#include "moo.h" - -K053246_CB_MEMBER(moo_state::sprite_callback) -{ - int pri = (*color & 0x03e0) >> 4; - - if (pri <= m_layerpri[2]) - *priority_mask = 0; - else if (pri <= m_layerpri[1]) - *priority_mask = 0xf0; - else if (pri <= m_layerpri[0]) - *priority_mask = 0xf0|0xcc; - else - *priority_mask = 0xf0|0xcc|0xaa; - - *color = m_sprite_colorbase | (*color & 0x001f); -} - -K056832_CB_MEMBER(moo_state::tile_callback) -{ - *color = m_layer_colorbase[layer] | (*color >> 2 & 0x0f); -} - -VIDEO_START_MEMBER(moo_state,moo) -{ - assert(m_screen->format() == BITMAP_FORMAT_RGB32); - - m_alpha_enabled = 0; - m_zmask = 0xffff; - - // other than the intro showing one blank line alignment is good through the game - m_k056832->set_layer_offs(0, -2 + 1, 0); - m_k056832->set_layer_offs(1, 2 + 1, 0); - m_k056832->set_layer_offs(2, 4 + 1, 0); - m_k056832->set_layer_offs(3, 6 + 1, 0); -} - -VIDEO_START_MEMBER(moo_state,bucky) -{ - assert(m_screen->format() == BITMAP_FORMAT_RGB32); - - m_alpha_enabled = 0; - m_zmask = 0x00ff; - - // Bucky doesn't chain tilemaps - m_k056832->set_layer_association(0); - - m_k056832->set_layer_offs(0, -2, 0); - m_k056832->set_layer_offs(1, 2, 0); - m_k056832->set_layer_offs(2, 4, 0); - m_k056832->set_layer_offs(3, 6, 0); -} - -uint32_t moo_state::screen_update_moo(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) -{ - static const int K053251_CI[4] = { k053251_device::CI1, k053251_device::CI2, k053251_device::CI3, k053251_device::CI4 }; - int layers[3]; - int new_colorbase, plane, dirty, alpha; - - m_sprite_colorbase = m_k053251->get_palette_index(k053251_device::CI0); - m_layer_colorbase[0] = 0x70; - - if (m_k056832->get_layer_association()) - { - for (plane = 1; plane < 4; plane++) - { - new_colorbase = m_k053251->get_palette_index(K053251_CI[plane]); - if (m_layer_colorbase[plane] != new_colorbase) - { - m_layer_colorbase[plane] = new_colorbase; - m_k056832->mark_plane_dirty( plane); - } - } - } - else - { - for (dirty = 0, plane = 1; plane < 4; plane++) - { - new_colorbase = m_k053251->get_palette_index(K053251_CI[plane]); - if (m_layer_colorbase[plane] != new_colorbase) - { - m_layer_colorbase[plane] = new_colorbase; - dirty = 1; - } - } - if (dirty) - m_k056832->mark_all_tilemaps_dirty(); - } - - layers[0] = 1; - m_layerpri[0] = m_k053251->get_priority(k053251_device::CI2); - layers[1] = 2; - m_layerpri[1] = m_k053251->get_priority(k053251_device::CI3); - layers[2] = 3; - m_layerpri[2] = m_k053251->get_priority(k053251_device::CI4); - - konami_sortlayers3(layers, m_layerpri); - - m_k054338->update_all_shadows(0, *m_palette); - m_k054338->fill_solid_bg(bitmap, cliprect); - - screen.priority().fill(0, cliprect); - - if (m_layerpri[0] < m_k053251->get_priority(k053251_device::CI1)) /* bucky hides back layer behind background */ - m_k056832->tilemap_draw(screen, bitmap, cliprect, layers[0], 0, 1); - - m_k056832->tilemap_draw(screen, bitmap, cliprect, layers[1], 0, 2); - - // Enabling alpha improves fog and fading in Moo but causes other things to disappear. - // There is probably a control bit somewhere to turn off alpha blending. - m_alpha_enabled = m_k054338->register_r(K338_REG_CONTROL) & K338_CTL_MIXPRI; // DUMMY - - alpha = (m_alpha_enabled) ? m_k054338->set_alpha_level(1) : 255; - - if (alpha > 0) - m_k056832->tilemap_draw(screen, bitmap, cliprect, layers[2], TILEMAP_DRAW_ALPHA(alpha), 4); - - m_k053246->k053247_sprites_draw( bitmap, cliprect); - - m_k056832->tilemap_draw(screen, bitmap, cliprect, 0, 0, 0); - return 0; -} diff --git a/src/mame/konami/qdrmfgp.cpp b/src/mame/konami/qdrmfgp.cpp index 69e14159979..014c543a7e3 100644 --- a/src/mame/konami/qdrmfgp.cpp +++ b/src/mame/konami/qdrmfgp.cpp @@ -21,13 +21,151 @@ GP1 HDD data contents: ***************************************************************************/ #include "emu.h" -#include "qdrmfgp.h" +#include "k054156_k054157_k056832.h" +#include "konami_helper.h" + +#include "bus/ata/ataintf.h" #include "cpu/m68000/m68000.h" +#include "machine/k053252.h" #include "machine/nvram.h" +#include "machine/timer.h" #include "sound/k054539.h" +#include "emupal.h" #include "speaker.h" +namespace { + +class qdrmfgp_state : public driver_device +{ +public: + qdrmfgp_state(const machine_config &mconfig, device_type type, const char *tag) : + driver_device(mconfig, type, tag), + m_maincpu(*this, "maincpu"), + m_nvram(*this, "nvram"), + m_workram(*this, "workram"), + m_k056832(*this, "k056832"), + m_k054539(*this, "k054539"), + m_k053252(*this, "k053252"), + m_ata(*this, "ata"), + m_inputs_port(*this, "INPUTS"), + m_dsw_port(*this, "DSW"), + m_palette(*this, "palette"), + m_sndram(*this, "sndram") + { + } + + void qdrmfgp(machine_config &config); + void qdrmfgp2(machine_config &config); + + DECLARE_CUSTOM_INPUT_MEMBER(battery_sensor_r); + +protected: + virtual void machine_reset() override; + +private: + required_device m_maincpu; + required_shared_ptr m_nvram; + required_shared_ptr m_workram; + required_device m_k056832; + required_device m_k054539; + required_device m_k053252; + required_device m_ata; + required_ioport m_inputs_port; + required_ioport m_dsw_port; + required_device m_palette; + required_shared_ptr m_sndram; + + uint16_t m_control = 0; + int32_t m_gp2_irq_control = 0; + int32_t m_pal = 0; + emu_timer *m_gp2_timer = nullptr; + + void gp_control_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); + void gp2_control_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); + uint16_t v_rom_r(offs_t offset); + uint16_t gp2_vram_r(offs_t offset); + uint16_t gp2_vram_mirror_r(offs_t offset); + void gp2_vram_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); + void gp2_vram_mirror_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); + uint16_t sndram_r(offs_t offset, uint16_t mem_mask = ~0); + void sndram_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); + uint16_t inputs_r(); + + DECLARE_MACHINE_START(qdrmfgp); + DECLARE_VIDEO_START(qdrmfgp); + DECLARE_MACHINE_START(qdrmfgp2); + DECLARE_VIDEO_START(qdrmfgp2); + + uint32_t screen_update_qdrmfgp(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); + INTERRUPT_GEN_MEMBER(qdrmfgp2_interrupt); + TIMER_CALLBACK_MEMBER(gp2_timer_callback); + TIMER_DEVICE_CALLBACK_MEMBER(qdrmfgp_interrupt); + DECLARE_WRITE_LINE_MEMBER(ide_interrupt); + DECLARE_WRITE_LINE_MEMBER(gp2_ide_interrupt); + DECLARE_WRITE_LINE_MEMBER(k054539_irq1_gen); + K056832_CB_MEMBER(qdrmfgp_tile_callback); + K056832_CB_MEMBER(qdrmfgp2_tile_callback); + + void qdrmfgp2_map(address_map &map); + void qdrmfgp_k054539_map(address_map &map); + void qdrmfgp_map(address_map &map); +}; + + +K056832_CB_MEMBER(qdrmfgp_state::qdrmfgp_tile_callback) +{ + *color = ((*color>>2) & 0x0f) | m_pal; +} + +K056832_CB_MEMBER(qdrmfgp_state::qdrmfgp2_tile_callback) +{ + *color = (*color>>1) & 0x7f; +} + +/*************************************************************************** + + Start the video hardware emulation. + +***************************************************************************/ + +VIDEO_START_MEMBER(qdrmfgp_state,qdrmfgp) +{ + m_k056832->set_layer_association(0); + + m_k056832->set_layer_offs(0, 2, 0); + m_k056832->set_layer_offs(1, 4, 0); + m_k056832->set_layer_offs(2, 6, 0); + m_k056832->set_layer_offs(3, 8, 0); +} + +VIDEO_START_MEMBER(qdrmfgp_state,qdrmfgp2) +{ + m_k056832->set_layer_association(0); + + m_k056832->set_layer_offs(0, 3, 1); + m_k056832->set_layer_offs(1, 5, 1); + m_k056832->set_layer_offs(2, 7, 1); + m_k056832->set_layer_offs(3, 9, 1); +} + +/*************************************************************************** + + Display refresh + +***************************************************************************/ + +uint32_t qdrmfgp_state::screen_update_qdrmfgp(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) +{ + bitmap.fill(m_palette->black_pen(), cliprect); + + m_k056832->tilemap_draw(screen, bitmap, cliprect, 3, 0, 1); + m_k056832->tilemap_draw(screen, bitmap, cliprect, 2, 0, 2); + m_k056832->tilemap_draw(screen, bitmap, cliprect, 1, 0, 4); + m_k056832->tilemap_draw(screen, bitmap, cliprect, 0, 0, 8); + return 0; +} + /************************************* * @@ -654,6 +792,8 @@ ROM_START( qdrmfgp2 ) DISK_IMAGE( "ge557a09", 0, SHA1(1ef8093b542fe0bf8240a5fd64e5af3839b6a04c) ) ROM_END +} // anonymous namespace + /************************************* * diff --git a/src/mame/konami/qdrmfgp.h b/src/mame/konami/qdrmfgp.h deleted file mode 100644 index a403f9df498..00000000000 --- a/src/mame/konami/qdrmfgp.h +++ /dev/null @@ -1,92 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Hau -#ifndef MAME_KONAMI_QDRMFGP_H -#define MAME_KONAMI_QDRMFGP_H - -#pragma once - -#include "bus/ata/ataintf.h" -#include "machine/timer.h" -#include "sound/k054539.h" -#include "machine/k053252.h" -#include "konami_helper.h" -#include "k054156_k054157_k056832.h" -#include "emupal.h" - -class qdrmfgp_state : public driver_device -{ -public: - qdrmfgp_state(const machine_config &mconfig, device_type type, const char *tag) : - driver_device(mconfig, type, tag), - m_maincpu(*this, "maincpu"), - m_nvram(*this, "nvram"), - m_workram(*this, "workram"), - m_k056832(*this, "k056832"), - m_k054539(*this, "k054539"), - m_k053252(*this, "k053252"), - m_ata(*this, "ata"), - m_inputs_port(*this, "INPUTS"), - m_dsw_port(*this, "DSW"), - m_palette(*this, "palette"), - m_sndram(*this, "sndram") - { - } - - void qdrmfgp(machine_config &config); - void qdrmfgp2(machine_config &config); - - DECLARE_CUSTOM_INPUT_MEMBER(battery_sensor_r); - -protected: - virtual void machine_reset() override; - -private: - required_device m_maincpu; - required_shared_ptr m_nvram; - required_shared_ptr m_workram; - required_device m_k056832; - required_device m_k054539; - required_device m_k053252; - required_device m_ata; - required_ioport m_inputs_port; - required_ioport m_dsw_port; - required_device m_palette; - required_shared_ptr m_sndram; - - uint16_t m_control = 0; - int32_t m_gp2_irq_control = 0; - int32_t m_pal = 0; - emu_timer *m_gp2_timer = nullptr; - - void gp_control_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); - void gp2_control_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); - uint16_t v_rom_r(offs_t offset); - uint16_t gp2_vram_r(offs_t offset); - uint16_t gp2_vram_mirror_r(offs_t offset); - void gp2_vram_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); - void gp2_vram_mirror_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); - uint16_t sndram_r(offs_t offset, uint16_t mem_mask = ~0); - void sndram_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); - uint16_t inputs_r(); - - DECLARE_MACHINE_START(qdrmfgp); - DECLARE_VIDEO_START(qdrmfgp); - DECLARE_MACHINE_START(qdrmfgp2); - DECLARE_VIDEO_START(qdrmfgp2); - - uint32_t screen_update_qdrmfgp(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - INTERRUPT_GEN_MEMBER(qdrmfgp2_interrupt); - TIMER_CALLBACK_MEMBER(gp2_timer_callback); - TIMER_DEVICE_CALLBACK_MEMBER(qdrmfgp_interrupt); - DECLARE_WRITE_LINE_MEMBER(ide_interrupt); - DECLARE_WRITE_LINE_MEMBER(gp2_ide_interrupt); - DECLARE_WRITE_LINE_MEMBER(k054539_irq1_gen); - K056832_CB_MEMBER(qdrmfgp_tile_callback); - K056832_CB_MEMBER(qdrmfgp2_tile_callback); - - void qdrmfgp2_map(address_map &map); - void qdrmfgp_k054539_map(address_map &map); - void qdrmfgp_map(address_map &map); -}; - -#endif // MAME_KONAMI_QDRMFGP_H diff --git a/src/mame/konami/qdrmfgp_v.cpp b/src/mame/konami/qdrmfgp_v.cpp deleted file mode 100644 index 2d0db616d71..00000000000 --- a/src/mame/konami/qdrmfgp_v.cpp +++ /dev/null @@ -1,64 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Hau -/*************************************************************************** - - video.c - -***************************************************************************/ - -#include "emu.h" -#include "qdrmfgp.h" - - -K056832_CB_MEMBER(qdrmfgp_state::qdrmfgp_tile_callback) -{ - *color = ((*color>>2) & 0x0f) | m_pal; -} - -K056832_CB_MEMBER(qdrmfgp_state::qdrmfgp2_tile_callback) -{ - *color = (*color>>1) & 0x7f; -} - -/*************************************************************************** - - Start the video hardware emulation. - -***************************************************************************/ - -VIDEO_START_MEMBER(qdrmfgp_state,qdrmfgp) -{ - m_k056832->set_layer_association(0); - - m_k056832->set_layer_offs(0, 2, 0); - m_k056832->set_layer_offs(1, 4, 0); - m_k056832->set_layer_offs(2, 6, 0); - m_k056832->set_layer_offs(3, 8, 0); -} - -VIDEO_START_MEMBER(qdrmfgp_state,qdrmfgp2) -{ - m_k056832->set_layer_association(0); - - m_k056832->set_layer_offs(0, 3, 1); - m_k056832->set_layer_offs(1, 5, 1); - m_k056832->set_layer_offs(2, 7, 1); - m_k056832->set_layer_offs(3, 9, 1); -} - -/*************************************************************************** - - Display refresh - -***************************************************************************/ - -uint32_t qdrmfgp_state::screen_update_qdrmfgp(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - bitmap.fill(m_palette->black_pen(), cliprect); - - m_k056832->tilemap_draw(screen, bitmap, cliprect, 3, 0, 1); - m_k056832->tilemap_draw(screen, bitmap, cliprect, 2, 0, 2); - m_k056832->tilemap_draw(screen, bitmap, cliprect, 1, 0, 4); - m_k056832->tilemap_draw(screen, bitmap, cliprect, 0, 0, 8); - return 0; -} diff --git a/src/mame/konami/rungun.cpp b/src/mame/konami/rungun.cpp index 9e9134e43b2..0e2771b1a9f 100644 --- a/src/mame/konami/rungun.cpp +++ b/src/mame/konami/rungun.cpp @@ -21,34 +21,133 @@ - sound volume mixing, handtune with set_gain() with m_k054539 devices. Also notice that "volume" in sound options is for k054539_1 (SFX) - Change Log: - - (AT070703) - drivers\rungun.cpp (this file) - - mem maps, device settings, component communications, I/O's, sound...etc. - - video\rungun.cpp - - general clean-up, clipping, alignment - - video\konamiic.cpp - - missing sprites and priority - - *************************************************************************/ #include "emu.h" -#include "rungun.h" + +#include "k053246_k053247_k055673.h" #include "konamipt.h" +#include "konami_helper.h" #include "cpu/m68000/m68000.h" #include "cpu/z80/z80.h" #include "machine/eepromser.h" +#include "machine/k053252.h" +#include "machine/k054321.h" #include "sound/k054539.h" +#include "video/k053936.h" +#include "emupal.h" +#include "screen.h" #include "speaker.h" +#include "tilemap.h" #include "rungun_dual.lh" +namespace { + +class rungun_state : public driver_device +{ +public: + rungun_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_k054539_1(*this, "k054539_1"), + m_k054539_2(*this, "k054539_2"), + m_k053936(*this, "k053936"), + m_k055673(*this, "k055673"), + m_k053252(*this, "k053252"), + m_gfxdecode(*this, "gfxdecode"), + m_palette(*this, "palette"), + m_palette2(*this, "palette2"), + m_screen(*this, "screen"), + m_k054321(*this, "k054321"), + m_sysreg(*this, "sysreg") + { } + + void rng(machine_config &config); + void rng_dual(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_soundcpu; + required_device m_k054539_1; + required_device m_k054539_2; + required_device m_k053936; + required_device m_k055673; + required_device m_k053252; + required_device m_gfxdecode; + required_device m_palette; + optional_device m_palette2; + required_device m_screen; + required_device m_k054321; + + /* memory pointers */ + required_shared_ptr m_sysreg; + + /* video-related */ + tilemap_t *m_ttl_tilemap[2]{}; + tilemap_t *m_936_tilemap[2]{}; + std::unique_ptr m_psac2_vram; + std::unique_ptr m_ttl_vram; + std::unique_ptr m_pal_ram; + uint8_t m_current_display_bank = 0; + int m_ttl_gfx_index = 0; + int m_sprite_colorbase = 0; + + uint8_t *m_roz_rom = nullptr; + uint8_t m_roz_rombase = 0; + + /* sound */ + uint8_t m_sound_ctrl = 0; + uint8_t m_sound_status = 0; + uint8_t m_sound_nmi_clk = 0; + + bool m_video_priority_mode = false; + std::unique_ptr m_banked_ram; + bool m_single_screen_mode = false; + uint8_t m_video_mux_bank = 0; + + uint16_t sysregs_r(offs_t offset, uint16_t mem_mask = ~0); + void sysregs_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); + void sound_irq_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); + void sound_status_w(uint8_t data); + void sound_ctrl_w(uint8_t data); + uint16_t ttl_ram_r(offs_t offset); + void ttl_ram_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); + uint16_t psac2_videoram_r(offs_t offset); + void psac2_videoram_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); + uint8_t k53936_rom_r(offs_t offset); + TILE_GET_INFO_MEMBER(ttl_get_tile_info); + TILE_GET_INFO_MEMBER(get_rng_936_tile_info); + DECLARE_WRITE_LINE_MEMBER(k054539_nmi_gen); + uint16_t palette_read(offs_t offset); + void palette_write(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); + + + K055673_CB_MEMBER(sprite_callback); + + uint32_t screen_update_rng(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); + + uint32_t screen_update_rng_dual_left(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); + uint32_t screen_update_rng_dual_right(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); + bitmap_ind16 m_rng_dual_demultiplex_left_temp; + bitmap_ind16 m_rng_dual_demultiplex_right_temp; + void sprite_dma_trigger(void); + + INTERRUPT_GEN_MEMBER(rng_interrupt); + + void rungun_map(address_map &map); + void rungun_sound_map(address_map &map); +}; + uint16_t rungun_state::sysregs_r(offs_t offset, uint16_t mem_mask) { @@ -202,6 +301,168 @@ void rungun_state::rungun_map(address_map &map) } +/**********************************************************************************/ + +/* TTL text plane stuff */ +TILE_GET_INFO_MEMBER(rungun_state::ttl_get_tile_info) +{ + uint32_t const base_addr = uintptr_t(tilemap.user_data()); + auto const lvram = util::little_endian_cast(m_ttl_vram.get()) + base_addr; + + int const attr = (lvram[tile_index << 2] & 0xf0) >> 4; + int const code = ((lvram[tile_index << 2] & 0x0f) << 8) | lvram[(tile_index << 2) + 2]; + + tileinfo.set(m_ttl_gfx_index, code, attr, 0); +} + +K055673_CB_MEMBER(rungun_state::sprite_callback) +{ + *color = m_sprite_colorbase | (*color & 0x001f); +} + +uint16_t rungun_state::ttl_ram_r(offs_t offset) +{ + return m_ttl_vram[offset+(m_video_mux_bank*0x1000)]; +} + +void rungun_state::ttl_ram_w(offs_t offset, uint16_t data, uint16_t mem_mask) +{ + COMBINE_DATA(&m_ttl_vram[offset+(m_video_mux_bank*0x1000)]); + m_ttl_tilemap[m_video_mux_bank]->mark_tile_dirty(offset / 2); +} + +/* 53936 (PSAC2) rotation/zoom plane */ +uint16_t rungun_state::psac2_videoram_r(offs_t offset) +{ + return m_psac2_vram[offset+(m_video_mux_bank*0x80000)]; +} + +void rungun_state::psac2_videoram_w(offs_t offset, uint16_t data, uint16_t mem_mask) +{ + COMBINE_DATA(&m_psac2_vram[offset+(m_video_mux_bank*0x80000)]); + m_936_tilemap[m_video_mux_bank]->mark_tile_dirty(offset / 2); +} + +TILE_GET_INFO_MEMBER(rungun_state::get_rng_936_tile_info) +{ + uint32_t base_addr = (uintptr_t)tilemap.user_data(); + int tileno, colour, flipx; + + tileno = m_psac2_vram[tile_index * 2 + 1 + base_addr] & 0x3fff; + flipx = (m_psac2_vram[tile_index * 2 + 1 + base_addr] & 0xc000) >> 14; + colour = 0x10 + (m_psac2_vram[tile_index * 2 + base_addr] & 0x000f); + + tileinfo.set(0, tileno, colour, TILE_FLIPYX(flipx)); +} + + +void rungun_state::video_start() +{ + static const gfx_layout charlayout = + { + 8, 8, // 8x8 + 4096, // # of tiles + 4, // 4bpp + { 0, 1, 2, 3 }, // plane offsets + { 0*4, 1*4, 2*4, 3*4, 4*4, 5*4, 6*4, 7*4 }, // X offsets + { 0*8*4, 1*8*4, 2*8*4, 3*8*4, 4*8*4, 5*8*4, 6*8*4, 7*8*4 }, // Y offsets + 8*8*4 + }; + + int gfx_index; + + m_ttl_vram = std::make_unique(0x1000*2); + m_psac2_vram = std::make_unique(0x80000*2); + + /* find first empty slot to decode gfx */ + for (gfx_index = 0; gfx_index < MAX_GFX_ELEMENTS; gfx_index++) + if (m_gfxdecode->gfx(gfx_index) == nullptr) + break; + + assert(gfx_index != MAX_GFX_ELEMENTS); + + // decode the ttl layer's gfx + m_gfxdecode->set_gfx(gfx_index, std::make_unique(m_palette, charlayout, memregion("gfx3")->base(), 0, m_palette->entries() / 16, 0)); + m_ttl_gfx_index = gfx_index; + + // create the tilemaps + for(uint32_t screen_num = 0;screen_num < 2;screen_num++) + { + m_ttl_tilemap[screen_num] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(rungun_state::ttl_get_tile_info)), TILEMAP_SCAN_ROWS, 8, 8, 64, 32); + m_ttl_tilemap[screen_num]->set_user_data((void *)(uintptr_t)(screen_num * 0x2000)); + m_ttl_tilemap[screen_num]->set_transparent_pen(0); + + m_936_tilemap[screen_num] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(rungun_state::get_rng_936_tile_info)), TILEMAP_SCAN_ROWS, 16, 16, 128, 128); + m_936_tilemap[screen_num]->set_user_data((void *)(uintptr_t)(screen_num * 0x80000)); + m_936_tilemap[screen_num]->set_transparent_pen(0); + + } + m_sprite_colorbase = 0x20; + + m_screen->register_screen_bitmap(m_rng_dual_demultiplex_left_temp); + m_screen->register_screen_bitmap(m_rng_dual_demultiplex_right_temp); +} + +uint32_t rungun_state::screen_update_rng(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) +{ + bitmap.fill(m_palette->black_pen(), cliprect); + screen.priority().fill(0, cliprect); + m_current_display_bank = m_screen->frame_number() & 1; + if(m_single_screen_mode == true) + m_current_display_bank = 0; + + if(m_video_priority_mode == false) + { + m_k053936->zoom_draw(screen, bitmap, cliprect, m_936_tilemap[m_current_display_bank], 0, 0, 1); + m_k055673->k053247_sprites_draw(bitmap, cliprect); + } + else + { + m_k055673->k053247_sprites_draw(bitmap, cliprect); + m_k053936->zoom_draw(screen, bitmap, cliprect, m_936_tilemap[m_current_display_bank], 0, 0, 1); + } + + m_ttl_tilemap[m_current_display_bank]->draw(screen, bitmap, cliprect, 0, 0); + return 0; +} + + +// the 60hz signal gets split between 2 screens +uint32_t rungun_state::screen_update_rng_dual_left(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) +{ + int m_current_display_bank = m_screen->frame_number() & 1; + + if (!m_current_display_bank) + screen_update_rng(screen, m_rng_dual_demultiplex_left_temp, cliprect); + else + screen_update_rng(screen, m_rng_dual_demultiplex_right_temp, cliprect); + + copybitmap( bitmap, m_rng_dual_demultiplex_left_temp, 0, 0, 0, 0, cliprect); + return 0; +} + +// this depends upon the first screen being updated, and the bitmap being copied to the temp bitmap +uint32_t rungun_state::screen_update_rng_dual_right(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) +{ + copybitmap( bitmap, m_rng_dual_demultiplex_right_temp, 0, 0, 0, 0, cliprect); + return 0; +} + +void rungun_state::sprite_dma_trigger(void) +{ + uint32_t src_address; + + if(m_single_screen_mode == true) + src_address = 1*0x2000; + else + src_address = m_current_display_bank*0x2000; + + // TODO: size could be programmable somehow. + for(int i=0;i<0x1000;i+=2) + m_k055673->k053247_word_w(i/2, m_banked_ram[(i + src_address) /2]); +} + + /**********************************************************************************/ void rungun_state::sound_status_w(uint8_t data) @@ -934,6 +1195,8 @@ ROM_START( rungunud ) // dual cabinet setup ONLY ROM_LOAD( "rungunu.nv", 0x0000, 0x080, CRC(d501f579) SHA1(9e01d9a6a8cdc782dd2a92fbf2295e8df732f892) ) ROM_END +} // anonymous namespace + // these sets operate as single screen / dual screen depending on if you have the video de-multiplexer plugged in, and the dipswitch set to 1 or 2 monitors diff --git a/src/mame/konami/rungun.h b/src/mame/konami/rungun.h deleted file mode 100644 index 4e27f2df3c9..00000000000 --- a/src/mame/konami/rungun.h +++ /dev/null @@ -1,125 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:R. Belmont -/************************************************************************* - - Run and Gun / Slam Dunk - -*************************************************************************/ -#ifndef MAME_KONAMI_RUNGUN_H -#define MAME_KONAMI_RUNGUN_H - -#pragma once - -#include "sound/k054539.h" -#include "machine/k053252.h" -#include "k053246_k053247_k055673.h" -#include "video/k053936.h" -#include "machine/k054321.h" -#include "konami_helper.h" -#include "emupal.h" -#include "screen.h" -#include "tilemap.h" - -class rungun_state : public driver_device -{ -public: - rungun_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_k054539_1(*this, "k054539_1"), - m_k054539_2(*this, "k054539_2"), - m_k053936(*this, "k053936"), - m_k055673(*this, "k055673"), - m_k053252(*this, "k053252"), - m_gfxdecode(*this, "gfxdecode"), - m_palette(*this, "palette"), - m_palette2(*this, "palette2"), - m_screen(*this, "screen"), - m_k054321(*this, "k054321"), - m_sysreg(*this, "sysreg") - { } - - void rng(machine_config &config); - void rng_dual(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_soundcpu; - required_device m_k054539_1; - required_device m_k054539_2; - required_device m_k053936; - required_device m_k055673; - required_device m_k053252; - required_device m_gfxdecode; - required_device m_palette; - optional_device m_palette2; - required_device m_screen; - required_device m_k054321; - - /* memory pointers */ - required_shared_ptr m_sysreg; - - /* video-related */ - tilemap_t *m_ttl_tilemap[2]{}; - tilemap_t *m_936_tilemap[2]{}; - std::unique_ptr m_psac2_vram; - std::unique_ptr m_ttl_vram; - std::unique_ptr m_pal_ram; - uint8_t m_current_display_bank = 0; - int m_ttl_gfx_index = 0; - int m_sprite_colorbase = 0; - - uint8_t *m_roz_rom = nullptr; - uint8_t m_roz_rombase = 0; - - /* sound */ - uint8_t m_sound_ctrl = 0; - uint8_t m_sound_status = 0; - uint8_t m_sound_nmi_clk = 0; - - bool m_video_priority_mode = false; - std::unique_ptr m_banked_ram; - bool m_single_screen_mode = false; - uint8_t m_video_mux_bank = 0; - - uint16_t sysregs_r(offs_t offset, uint16_t mem_mask = ~0); - void sysregs_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); - void sound_irq_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); - void sound_status_w(uint8_t data); - void sound_ctrl_w(uint8_t data); - uint16_t ttl_ram_r(offs_t offset); - void ttl_ram_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); - uint16_t psac2_videoram_r(offs_t offset); - void psac2_videoram_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); - uint8_t k53936_rom_r(offs_t offset); - TILE_GET_INFO_MEMBER(ttl_get_tile_info); - TILE_GET_INFO_MEMBER(get_rng_936_tile_info); - DECLARE_WRITE_LINE_MEMBER(k054539_nmi_gen); - uint16_t palette_read(offs_t offset); - void palette_write(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); - - - K055673_CB_MEMBER(sprite_callback); - - uint32_t screen_update_rng(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - - uint32_t screen_update_rng_dual_left(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - uint32_t screen_update_rng_dual_right(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - bitmap_ind16 m_rng_dual_demultiplex_left_temp; - bitmap_ind16 m_rng_dual_demultiplex_right_temp; - void sprite_dma_trigger(void); - - INTERRUPT_GEN_MEMBER(rng_interrupt); - - void rungun_map(address_map &map); - void rungun_sound_map(address_map &map); -}; - -#endif // MAME_KONAMI_RUNGUN_H diff --git a/src/mame/konami/rungun_v.cpp b/src/mame/konami/rungun_v.cpp deleted file mode 100644 index 70f3439e7f8..00000000000 --- a/src/mame/konami/rungun_v.cpp +++ /dev/null @@ -1,175 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:R. Belmont -/************************************************************************* - - Run and Gun - (c) 1993 Konami - - Video hardware emulation. - - Driver by R. Belmont - -*************************************************************************/ - -#include "emu.h" -#include "rungun.h" - - -/* TTL text plane stuff */ -TILE_GET_INFO_MEMBER(rungun_state::ttl_get_tile_info) -{ - uint32_t const base_addr = uintptr_t(tilemap.user_data()); - auto const lvram = util::little_endian_cast(m_ttl_vram.get()) + base_addr; - - int const attr = (lvram[tile_index << 2] & 0xf0) >> 4; - int const code = ((lvram[tile_index << 2] & 0x0f) << 8) | lvram[(tile_index << 2) + 2]; - - tileinfo.set(m_ttl_gfx_index, code, attr, 0); -} - -K055673_CB_MEMBER(rungun_state::sprite_callback) -{ - *color = m_sprite_colorbase | (*color & 0x001f); -} - -uint16_t rungun_state::ttl_ram_r(offs_t offset) -{ - return m_ttl_vram[offset+(m_video_mux_bank*0x1000)]; -} - -void rungun_state::ttl_ram_w(offs_t offset, uint16_t data, uint16_t mem_mask) -{ - COMBINE_DATA(&m_ttl_vram[offset+(m_video_mux_bank*0x1000)]); - m_ttl_tilemap[m_video_mux_bank]->mark_tile_dirty(offset / 2); -} - -/* 53936 (PSAC2) rotation/zoom plane */ -uint16_t rungun_state::psac2_videoram_r(offs_t offset) -{ - return m_psac2_vram[offset+(m_video_mux_bank*0x80000)]; -} - -void rungun_state::psac2_videoram_w(offs_t offset, uint16_t data, uint16_t mem_mask) -{ - COMBINE_DATA(&m_psac2_vram[offset+(m_video_mux_bank*0x80000)]); - m_936_tilemap[m_video_mux_bank]->mark_tile_dirty(offset / 2); -} - -TILE_GET_INFO_MEMBER(rungun_state::get_rng_936_tile_info) -{ - uint32_t base_addr = (uintptr_t)tilemap.user_data(); - int tileno, colour, flipx; - - tileno = m_psac2_vram[tile_index * 2 + 1 + base_addr] & 0x3fff; - flipx = (m_psac2_vram[tile_index * 2 + 1 + base_addr] & 0xc000) >> 14; - colour = 0x10 + (m_psac2_vram[tile_index * 2 + base_addr] & 0x000f); - - tileinfo.set(0, tileno, colour, TILE_FLIPYX(flipx)); -} - - -void rungun_state::video_start() -{ - static const gfx_layout charlayout = - { - 8, 8, // 8x8 - 4096, // # of tiles - 4, // 4bpp - { 0, 1, 2, 3 }, // plane offsets - { 0*4, 1*4, 2*4, 3*4, 4*4, 5*4, 6*4, 7*4 }, // X offsets - { 0*8*4, 1*8*4, 2*8*4, 3*8*4, 4*8*4, 5*8*4, 6*8*4, 7*8*4 }, // Y offsets - 8*8*4 - }; - - int gfx_index; - - m_ttl_vram = std::make_unique(0x1000*2); - m_psac2_vram = std::make_unique(0x80000*2); - - /* find first empty slot to decode gfx */ - for (gfx_index = 0; gfx_index < MAX_GFX_ELEMENTS; gfx_index++) - if (m_gfxdecode->gfx(gfx_index) == nullptr) - break; - - assert(gfx_index != MAX_GFX_ELEMENTS); - - // decode the ttl layer's gfx - m_gfxdecode->set_gfx(gfx_index, std::make_unique(m_palette, charlayout, memregion("gfx3")->base(), 0, m_palette->entries() / 16, 0)); - m_ttl_gfx_index = gfx_index; - - // create the tilemaps - for(uint32_t screen_num = 0;screen_num < 2;screen_num++) - { - m_ttl_tilemap[screen_num] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(rungun_state::ttl_get_tile_info)), TILEMAP_SCAN_ROWS, 8, 8, 64, 32); - m_ttl_tilemap[screen_num]->set_user_data((void *)(uintptr_t)(screen_num * 0x2000)); - m_ttl_tilemap[screen_num]->set_transparent_pen(0); - - m_936_tilemap[screen_num] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(rungun_state::get_rng_936_tile_info)), TILEMAP_SCAN_ROWS, 16, 16, 128, 128); - m_936_tilemap[screen_num]->set_user_data((void *)(uintptr_t)(screen_num * 0x80000)); - m_936_tilemap[screen_num]->set_transparent_pen(0); - - } - m_sprite_colorbase = 0x20; - - m_screen->register_screen_bitmap(m_rng_dual_demultiplex_left_temp); - m_screen->register_screen_bitmap(m_rng_dual_demultiplex_right_temp); -} - -uint32_t rungun_state::screen_update_rng(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - bitmap.fill(m_palette->black_pen(), cliprect); - screen.priority().fill(0, cliprect); - m_current_display_bank = m_screen->frame_number() & 1; - if(m_single_screen_mode == true) - m_current_display_bank = 0; - - if(m_video_priority_mode == false) - { - m_k053936->zoom_draw(screen, bitmap, cliprect, m_936_tilemap[m_current_display_bank], 0, 0, 1); - m_k055673->k053247_sprites_draw(bitmap, cliprect); - } - else - { - m_k055673->k053247_sprites_draw(bitmap, cliprect); - m_k053936->zoom_draw(screen, bitmap, cliprect, m_936_tilemap[m_current_display_bank], 0, 0, 1); - } - - m_ttl_tilemap[m_current_display_bank]->draw(screen, bitmap, cliprect, 0, 0); - return 0; -} - - -// the 60hz signal gets split between 2 screens -uint32_t rungun_state::screen_update_rng_dual_left(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - int m_current_display_bank = m_screen->frame_number() & 1; - - if (!m_current_display_bank) - screen_update_rng(screen, m_rng_dual_demultiplex_left_temp, cliprect); - else - screen_update_rng(screen, m_rng_dual_demultiplex_right_temp, cliprect); - - copybitmap( bitmap, m_rng_dual_demultiplex_left_temp, 0, 0, 0, 0, cliprect); - return 0; -} - -// this depends upon the first screen being updated, and the bitmap being copied to the temp bitmap -uint32_t rungun_state::screen_update_rng_dual_right(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - copybitmap( bitmap, m_rng_dual_demultiplex_right_temp, 0, 0, 0, 0, cliprect); - return 0; -} - -void rungun_state::sprite_dma_trigger(void) -{ - uint32_t src_address; - - if(m_single_screen_mode == true) - src_address = 1*0x2000; - else - src_address = m_current_display_bank*0x2000; - - // TODO: size could be programmable somehow. - for(int i=0;i<0x1000;i+=2) - m_k055673->k053247_word_w(i/2, m_banked_ram[(i + src_address) /2]); -} diff --git a/src/mame/konami/simpsons.cpp b/src/mame/konami/simpsons.cpp index 6d2892df747..8462a87f51d 100644 --- a/src/mame/konami/simpsons.cpp +++ b/src/mame/konami/simpsons.cpp @@ -97,9 +97,14 @@ Notes: ***************************************************************************/ #include "emu.h" -#include "simpsons.h" + +#include "k052109.h" +#include "k053251.h" +#include "k053246_k053247_k055673.h" #include "konamipt.h" +#include "konami_helper.h" +#include "cpu/m6809/konami.h" #include "cpu/z80/z80.h" #include "machine/eepromser.h" #include "machine/watchdog.h" @@ -109,6 +114,308 @@ Notes: #include "speaker.h" +namespace { + +class simpsons_state : public driver_device +{ +public: + simpsons_state(const machine_config &mconfig, device_type type, const char *tag) : + driver_device(mconfig, type, tag), + m_palette_view(*this, "palette_view"), + m_video_view(*this, "video_view"), + m_maincpu(*this, "maincpu"), + m_audiocpu(*this, "audiocpu"), + m_k052109(*this, "k052109"), + m_k053246(*this, "k053246"), + m_k053251(*this, "k053251") + { } + + void simpsons(machine_config &config); + +private: + virtual void machine_start() override; + virtual void machine_reset() override; + + void bank0000_map(address_map &map); + void bank2000_map(address_map &map); + void main_map(address_map &map); + void z80_map(address_map &map); + + TIMER_CALLBACK_MEMBER(dma_start); + TIMER_CALLBACK_MEMBER(dma_end); + + /* memory pointers */ + std::unique_ptr m_spriteram; + + /* video-related */ + int m_sprite_colorbase = 0; + int m_layer_colorbase[3]{}; + int m_layerpri[3]{}; + emu_timer *m_dma_start_timer; + emu_timer *m_dma_end_timer; + + /* misc */ + int m_firq_enabled = 0; + emu_timer *m_nmi_blocked; + + /* views */ + memory_view m_palette_view; + memory_view m_video_view; + + /* devices */ + required_device m_maincpu; + required_device m_audiocpu; + required_device m_k052109; + required_device m_k053246; + required_device m_k053251; + void z80_bankswitch_w(uint8_t data); + void z80_arm_nmi_w(uint8_t data); + void eeprom_w(uint8_t data); + void coin_counter_w(uint8_t data); + uint8_t sound_interrupt_r(); + uint8_t k052109_r(offs_t offset); + void k052109_w(offs_t offset, uint8_t data); + uint8_t k053247_r(offs_t offset); + void k053247_w(offs_t offset, uint8_t data); + uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); + INTERRUPT_GEN_MEMBER(periodic_irq); + void video_bank_select(int bank); + void object_dma(); + void z80_nmi_w(int state); + K052109_CB_MEMBER(tile_callback); + void banking_callback(u8 data); + K053246_CB_MEMBER(sprite_callback); +}; + + + +/*************************************************************************** + + Callbacks for the K052109 + +***************************************************************************/ + +K052109_CB_MEMBER(simpsons_state::tile_callback) +{ + *code |= ((*color & 0x3f) << 8) | (bank << 14); + *color = m_layer_colorbase[layer] + ((*color & 0xc0) >> 6); +} + + +/*************************************************************************** + + Callbacks for the K053247 + +***************************************************************************/ + +K053246_CB_MEMBER(simpsons_state::sprite_callback) +{ + int pri = (*color & 0x0f80) >> 6; /* ??????? */ + + if (pri <= m_layerpri[2]) + *priority_mask = 0; + else if (pri > m_layerpri[2] && pri <= m_layerpri[1]) + *priority_mask = 0xf0; + else if (pri > m_layerpri[1] && pri <= m_layerpri[0]) + *priority_mask = 0xf0 | 0xcc; + else + *priority_mask = 0xf0 | 0xcc | 0xaa; + + *color = m_sprite_colorbase + (*color & 0x001f); +} + + +/*************************************************************************** + + Extra video banking + +***************************************************************************/ + +uint8_t simpsons_state::k052109_r(offs_t offset) +{ + return m_k052109->read(offset + 0x2000); +} + +void simpsons_state::k052109_w(offs_t offset, uint8_t data) +{ + m_k052109->write(offset + 0x2000, data); +} + +uint8_t simpsons_state::k053247_r(offs_t offset) +{ + int offs = offset >> 1; + + if (offset & 1) + return(m_spriteram[offs] & 0xff); + else + return(m_spriteram[offs] >> 8); +} + +void simpsons_state::k053247_w(offs_t offset, uint8_t data) +{ + int offs = offset >> 1; + + if (offset & 1) + m_spriteram[offs] = (m_spriteram[offs] & 0xff00) | data; + else + m_spriteram[offs] = (m_spriteram[offs] & 0x00ff) | (data << 8); +} + +void simpsons_state::video_bank_select( int bank ) +{ + if(bank & 1) + m_palette_view.select(0); + else + m_palette_view.disable(); + m_video_view.select((bank >> 1) & 1); +} + + + +/*************************************************************************** + + Display refresh + +***************************************************************************/ + +uint32_t simpsons_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) +{ + int layer[3], bg_colorbase; + + bg_colorbase = m_k053251->get_palette_index(k053251_device::CI0); + m_sprite_colorbase = m_k053251->get_palette_index(k053251_device::CI1); + m_layer_colorbase[0] = m_k053251->get_palette_index(k053251_device::CI2); + m_layer_colorbase[1] = m_k053251->get_palette_index(k053251_device::CI3); + m_layer_colorbase[2] = m_k053251->get_palette_index(k053251_device::CI4); + + m_k052109->tilemap_update(); + + layer[0] = 0; + m_layerpri[0] = m_k053251->get_priority(k053251_device::CI2); + layer[1] = 1; + m_layerpri[1] = m_k053251->get_priority(k053251_device::CI3); + layer[2] = 2; + m_layerpri[2] = m_k053251->get_priority(k053251_device::CI4); + + konami_sortlayers3(layer, m_layerpri); + + screen.priority().fill(0, cliprect); + bitmap.fill(16 * bg_colorbase, cliprect); + m_k052109->tilemap_draw(screen, bitmap, cliprect, layer[0], 0, 1); + m_k052109->tilemap_draw(screen, bitmap, cliprect, layer[1], 0, 2); + m_k052109->tilemap_draw(screen, bitmap, cliprect, layer[2], 0, 4); + + m_k053246->k053247_sprites_draw(bitmap, cliprect); + return 0; +} + + + +/*************************************************************************** + + EEPROM + +***************************************************************************/ + +void simpsons_state::eeprom_w(uint8_t data) +{ + if (data == 0xff) + return; + + ioport("EEPROMOUT")->write(data, 0xff); + + video_bank_select(data & 0x03); + + m_firq_enabled = data & 0x04; + if (!m_firq_enabled) + m_maincpu->set_input_line(KONAMI_FIRQ_LINE, CLEAR_LINE); +} + +/*************************************************************************** + + Coin Counters, Sound Interface + +***************************************************************************/ + +void simpsons_state::coin_counter_w(uint8_t data) +{ + /* bit 0,1 coin counters */ + machine().bookkeeping().coin_counter_w(0, data & 0x01); + machine().bookkeeping().coin_counter_w(1, data & 0x02); + /* bit 2 selects mono or stereo sound */ + /* bit 3 = enable char ROM reading through the video RAM */ + m_k052109->set_rmrd_line((data & 0x08) ? ASSERT_LINE : CLEAR_LINE); + /* bit 4 = INIT (unknown) */ + /* bit 5 = enable sprite ROM reading */ + m_k053246->k053246_set_objcha_line((~data & 0x20) ? ASSERT_LINE : CLEAR_LINE); +} + +uint8_t simpsons_state::sound_interrupt_r() +{ + if (!machine().side_effects_disabled()) + m_audiocpu->set_input_line_and_vector(0, HOLD_LINE, 0xff); // Z80 + + return 0x00; +} + + +/*************************************************************************** + + Banking, initialization + +***************************************************************************/ + +void simpsons_state::banking_callback(u8 data) +{ + membank("bank1")->set_entry(data & 0x3f); +} + +void simpsons_state::machine_start() +{ + m_spriteram = make_unique_clear(0x1000 / 2); + + membank("bank1")->configure_entries(0, 64, memregion("maincpu")->base(), 0x2000); + + membank("bank2")->configure_entries(0, 2, memregion("audiocpu")->base() + 0x10000, 0); + membank("bank2")->configure_entries(2, 6, memregion("audiocpu")->base() + 0x10000, 0x4000); + + save_item(NAME(m_firq_enabled)); + save_item(NAME(m_sprite_colorbase)); + save_item(NAME(m_layer_colorbase)); + save_item(NAME(m_layerpri)); + save_pointer(NAME(m_spriteram), 0x1000 / 2); + + m_dma_start_timer = timer_alloc(FUNC(simpsons_state::dma_start), this); + m_dma_end_timer = timer_alloc(FUNC(simpsons_state::dma_end), this); + m_nmi_blocked = timer_alloc(timer_expired_delegate()); +} + +void simpsons_state::machine_reset() +{ + for (int i = 0; i < 3; i++) + { + m_layerpri[i] = 0; + m_layer_colorbase[i] = 0; + } + + m_sprite_colorbase = 0; + m_firq_enabled = 0; + + /* init the default banks */ + membank("bank1")->set_entry(0); + membank("bank2")->set_entry(0); + video_bank_select(0); + + m_dma_start_timer->adjust(attotime::never); + m_dma_end_timer->adjust(attotime::never); + + // Z80 _NMI goes low at same time as reset + m_audiocpu->set_input_line(INPUT_LINE_NMI, ASSERT_LINE); + m_audiocpu->pulse_input_line(INPUT_LINE_RESET, attotime::zero); +} + + + /*************************************************************************** Memory Maps @@ -638,6 +945,8 @@ ROM_START( simpsons2pj ) /* Japan 2 Player */ ROM_LOAD( "simpsons2pj.12c.nv", 0x0000, 0x080, CRC(3550a54e) SHA1(370cd40a12c471b3b6690ecbdde9c7979bc2a652) ) ROM_END +} // anonymous namespace + /*************************************************************************** diff --git a/src/mame/konami/simpsons.h b/src/mame/konami/simpsons.h deleted file mode 100644 index 2d7d4930d5b..00000000000 --- a/src/mame/konami/simpsons.h +++ /dev/null @@ -1,85 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Ernesto Corvi -#ifndef MAME_KONAMI_SIMPSONS_H -#define MAME_KONAMI_SIMPSONS_H - -#pragma once - -#include "cpu/m6809/konami.h" -#include "k052109.h" -#include "k053251.h" -#include "k053246_k053247_k055673.h" -#include "konami_helper.h" - -class simpsons_state : public driver_device -{ -public: - simpsons_state(const machine_config &mconfig, device_type type, const char *tag) : - driver_device(mconfig, type, tag), - m_palette_view(*this, "palette_view"), - m_video_view(*this, "video_view"), - m_maincpu(*this, "maincpu"), - m_audiocpu(*this, "audiocpu"), - m_k052109(*this, "k052109"), - m_k053246(*this, "k053246"), - m_k053251(*this, "k053251") - { } - - void simpsons(machine_config &config); - -private: - virtual void machine_start() override; - virtual void machine_reset() override; - - void bank0000_map(address_map &map); - void bank2000_map(address_map &map); - void main_map(address_map &map); - void z80_map(address_map &map); - - TIMER_CALLBACK_MEMBER(dma_start); - TIMER_CALLBACK_MEMBER(dma_end); - - /* memory pointers */ - std::unique_ptr m_spriteram; - - /* video-related */ - int m_sprite_colorbase = 0; - int m_layer_colorbase[3]{}; - int m_layerpri[3]{}; - emu_timer *m_dma_start_timer; - emu_timer *m_dma_end_timer; - - /* misc */ - int m_firq_enabled = 0; - emu_timer *m_nmi_blocked; - - /* views */ - memory_view m_palette_view; - memory_view m_video_view; - - /* devices */ - required_device m_maincpu; - required_device m_audiocpu; - required_device m_k052109; - required_device m_k053246; - required_device m_k053251; - void z80_bankswitch_w(uint8_t data); - void z80_arm_nmi_w(uint8_t data); - void eeprom_w(uint8_t data); - void coin_counter_w(uint8_t data); - uint8_t sound_interrupt_r(); - uint8_t k052109_r(offs_t offset); - void k052109_w(offs_t offset, uint8_t data); - uint8_t k053247_r(offs_t offset); - void k053247_w(offs_t offset, uint8_t data); - uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - INTERRUPT_GEN_MEMBER(periodic_irq); - void video_bank_select(int bank); - void object_dma(); - void z80_nmi_w(int state); - K052109_CB_MEMBER(tile_callback); - void banking_callback(u8 data); - K053246_CB_MEMBER(sprite_callback); -}; - -#endif // MAME_KONAMI_SIMPSONS_H diff --git a/src/mame/konami/simpsons_m.cpp b/src/mame/konami/simpsons_m.cpp deleted file mode 100644 index ef54120e02f..00000000000 --- a/src/mame/konami/simpsons_m.cpp +++ /dev/null @@ -1,110 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Ernesto Corvi -#include "emu.h" - -#include "cpu/m6809/konami.h" -#include "machine/eepromser.h" -#include "simpsons.h" - -/*************************************************************************** - - EEPROM - -***************************************************************************/ - -void simpsons_state::eeprom_w(uint8_t data) -{ - if (data == 0xff) - return; - - ioport("EEPROMOUT")->write(data, 0xff); - - video_bank_select(data & 0x03); - - m_firq_enabled = data & 0x04; - if (!m_firq_enabled) - m_maincpu->set_input_line(KONAMI_FIRQ_LINE, CLEAR_LINE); -} - -/*************************************************************************** - - Coin Counters, Sound Interface - -***************************************************************************/ - -void simpsons_state::coin_counter_w(uint8_t data) -{ - /* bit 0,1 coin counters */ - machine().bookkeeping().coin_counter_w(0, data & 0x01); - machine().bookkeeping().coin_counter_w(1, data & 0x02); - /* bit 2 selects mono or stereo sound */ - /* bit 3 = enable char ROM reading through the video RAM */ - m_k052109->set_rmrd_line((data & 0x08) ? ASSERT_LINE : CLEAR_LINE); - /* bit 4 = INIT (unknown) */ - /* bit 5 = enable sprite ROM reading */ - m_k053246->k053246_set_objcha_line((~data & 0x20) ? ASSERT_LINE : CLEAR_LINE); -} - -uint8_t simpsons_state::sound_interrupt_r() -{ - if (!machine().side_effects_disabled()) - m_audiocpu->set_input_line_and_vector(0, HOLD_LINE, 0xff); // Z80 - - return 0x00; -} - - -/*************************************************************************** - - Banking, initialization - -***************************************************************************/ - -void simpsons_state::banking_callback(u8 data) -{ - membank("bank1")->set_entry(data & 0x3f); -} - -void simpsons_state::machine_start() -{ - m_spriteram = make_unique_clear(0x1000 / 2); - - membank("bank1")->configure_entries(0, 64, memregion("maincpu")->base(), 0x2000); - - membank("bank2")->configure_entries(0, 2, memregion("audiocpu")->base() + 0x10000, 0); - membank("bank2")->configure_entries(2, 6, memregion("audiocpu")->base() + 0x10000, 0x4000); - - save_item(NAME(m_firq_enabled)); - save_item(NAME(m_sprite_colorbase)); - save_item(NAME(m_layer_colorbase)); - save_item(NAME(m_layerpri)); - save_pointer(NAME(m_spriteram), 0x1000 / 2); - - m_dma_start_timer = timer_alloc(FUNC(simpsons_state::dma_start), this); - m_dma_end_timer = timer_alloc(FUNC(simpsons_state::dma_end), this); - m_nmi_blocked = timer_alloc(timer_expired_delegate()); -} - -void simpsons_state::machine_reset() -{ - for (int i = 0; i < 3; i++) - { - m_layerpri[i] = 0; - m_layer_colorbase[i] = 0; - } - - m_sprite_colorbase = 0; - m_firq_enabled = 0; - - /* init the default banks */ - membank("bank1")->set_entry(0); - membank("bank2")->set_entry(0); - video_bank_select(0); - - m_dma_start_timer->adjust(attotime::never); - m_dma_end_timer->adjust(attotime::never); - - // Z80 _NMI goes low at same time as reset - m_audiocpu->set_input_line(INPUT_LINE_NMI, ASSERT_LINE); - m_audiocpu->pulse_input_line(INPUT_LINE_RESET, attotime::zero); -} diff --git a/src/mame/konami/simpsons_v.cpp b/src/mame/konami/simpsons_v.cpp deleted file mode 100644 index 4e8bb92b308..00000000000 --- a/src/mame/konami/simpsons_v.cpp +++ /dev/null @@ -1,124 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Ernesto Corvi -#include "emu.h" -#include "simpsons.h" - -/*************************************************************************** - - Callbacks for the K052109 - -***************************************************************************/ - -K052109_CB_MEMBER(simpsons_state::tile_callback) -{ - *code |= ((*color & 0x3f) << 8) | (bank << 14); - *color = m_layer_colorbase[layer] + ((*color & 0xc0) >> 6); -} - - -/*************************************************************************** - - Callbacks for the K053247 - -***************************************************************************/ - -K053246_CB_MEMBER(simpsons_state::sprite_callback) -{ - int pri = (*color & 0x0f80) >> 6; /* ??????? */ - - if (pri <= m_layerpri[2]) - *priority_mask = 0; - else if (pri > m_layerpri[2] && pri <= m_layerpri[1]) - *priority_mask = 0xf0; - else if (pri > m_layerpri[1] && pri <= m_layerpri[0]) - *priority_mask = 0xf0 | 0xcc; - else - *priority_mask = 0xf0 | 0xcc | 0xaa; - - *color = m_sprite_colorbase + (*color & 0x001f); -} - - -/*************************************************************************** - - Extra video banking - -***************************************************************************/ - -uint8_t simpsons_state::k052109_r(offs_t offset) -{ - return m_k052109->read(offset + 0x2000); -} - -void simpsons_state::k052109_w(offs_t offset, uint8_t data) -{ - m_k052109->write(offset + 0x2000, data); -} - -uint8_t simpsons_state::k053247_r(offs_t offset) -{ - int offs = offset >> 1; - - if (offset & 1) - return(m_spriteram[offs] & 0xff); - else - return(m_spriteram[offs] >> 8); -} - -void simpsons_state::k053247_w(offs_t offset, uint8_t data) -{ - int offs = offset >> 1; - - if (offset & 1) - m_spriteram[offs] = (m_spriteram[offs] & 0xff00) | data; - else - m_spriteram[offs] = (m_spriteram[offs] & 0x00ff) | (data << 8); -} - -void simpsons_state::video_bank_select( int bank ) -{ - if(bank & 1) - m_palette_view.select(0); - else - m_palette_view.disable(); - m_video_view.select((bank >> 1) & 1); -} - - - -/*************************************************************************** - - Display refresh - -***************************************************************************/ - -uint32_t simpsons_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - int layer[3], bg_colorbase; - - bg_colorbase = m_k053251->get_palette_index(k053251_device::CI0); - m_sprite_colorbase = m_k053251->get_palette_index(k053251_device::CI1); - m_layer_colorbase[0] = m_k053251->get_palette_index(k053251_device::CI2); - m_layer_colorbase[1] = m_k053251->get_palette_index(k053251_device::CI3); - m_layer_colorbase[2] = m_k053251->get_palette_index(k053251_device::CI4); - - m_k052109->tilemap_update(); - - layer[0] = 0; - m_layerpri[0] = m_k053251->get_priority(k053251_device::CI2); - layer[1] = 1; - m_layerpri[1] = m_k053251->get_priority(k053251_device::CI3); - layer[2] = 2; - m_layerpri[2] = m_k053251->get_priority(k053251_device::CI4); - - konami_sortlayers3(layer, m_layerpri); - - screen.priority().fill(0, cliprect); - bitmap.fill(16 * bg_colorbase, cliprect); - m_k052109->tilemap_draw(screen, bitmap, cliprect, layer[0], 0, 1); - m_k052109->tilemap_draw(screen, bitmap, cliprect, layer[1], 0, 2); - m_k052109->tilemap_draw(screen, bitmap, cliprect, layer[2], 0, 4); - - m_k053246->k053247_sprites_draw(bitmap, cliprect); - return 0; -} diff --git a/src/mame/konami/spy.cpp b/src/mame/konami/spy.cpp index f5d119bd510..691a0a70c36 100644 --- a/src/mame/konami/spy.cpp +++ b/src/mame/konami/spy.cpp @@ -20,16 +20,142 @@ ***************************************************************************/ #include "emu.h" -#include "spy.h" + +#include "k051960.h" +#include "k052109.h" #include "konamipt.h" +#include "konami_helper.h" #include "cpu/m6809/m6809.h" #include "cpu/z80/z80.h" #include "machine/gen_latch.h" #include "machine/watchdog.h" +#include "sound/k007232.h" #include "sound/ymopl.h" +#include "emupal.h" #include "speaker.h" +namespace { + +class spy_state : public driver_device +{ +public: + spy_state(const machine_config &mconfig, device_type type, const char *tag) : + driver_device(mconfig, type, tag), + m_ram(*this, "ram"), + m_maincpu(*this, "maincpu"), + m_audiocpu(*this, "audiocpu"), + m_k007232_1(*this, "k007232_1"), + m_k007232_2(*this, "k007232_2"), + m_k052109(*this, "k052109"), + m_k051960(*this, "k051960"), + m_palette(*this, "palette") + { } + + void spy(machine_config &config); + +private: + /* memory pointers */ + required_shared_ptr m_ram; + uint8_t m_pmcram[0x800]{}; + std::vector m_paletteram{}; + + /* misc */ + int m_rambank = 0; + int m_pmcbank = 0; + int m_video_enable = 0; + int m_old_3f90 = 0; + + /* devices */ + required_device m_maincpu; + required_device m_audiocpu; + required_device m_k007232_1; + required_device m_k007232_2; + required_device m_k052109; + required_device m_k051960; + required_device m_palette; + uint8_t spy_bankedram1_r(offs_t offset); + void spy_bankedram1_w(offs_t offset, uint8_t data); + void bankswitch_w(uint8_t data); + void spy_3f90_w(uint8_t data); + void spy_sh_irqtrigger_w(uint8_t data); + void sound_bank_w(uint8_t data); + uint8_t k052109_051960_r(offs_t offset); + void k052109_051960_w(offs_t offset, uint8_t data); + virtual void machine_start() override; + virtual void machine_reset() override; + uint32_t screen_update_spy(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); + void spy_collision( ); + void volume_callback0(uint8_t data); + void volume_callback1(uint8_t data); + K052109_CB_MEMBER(tile_callback); + K051960_CB_MEMBER(sprite_callback); + + void spy_map(address_map &map); + void spy_sound_map(address_map &map); +}; + + +/*************************************************************************** + + Callbacks for the K052109 + +***************************************************************************/ + +K052109_CB_MEMBER(spy_state::tile_callback) +{ + static const int layer_colorbase[] = { 768 / 16, 0 / 16, 256 / 16 }; + + *flags = (*color & 0x20) ? TILE_FLIPX : 0; + *code |= ((*color & 0x03) << 8) | ((*color & 0x10) << 6) | ((*color & 0x0c) << 9) | (bank << 13); + *color = layer_colorbase[layer] + ((*color & 0xc0) >> 6); +} + + +/*************************************************************************** + + Callbacks for the K051960 + +***************************************************************************/ + +K051960_CB_MEMBER(spy_state::sprite_callback) +{ + enum { sprite_colorbase = 512 / 16 }; + + /* bit 4 = priority over layer A (0 = have priority) */ + /* bit 5 = priority over layer B (1 = have priority) */ + *priority = 0x00; + if ( *color & 0x10) *priority |= GFX_PMASK_1; + if (~*color & 0x20) *priority |= GFX_PMASK_2; + + *color = sprite_colorbase + (*color & 0x0f); +} + + +/*************************************************************************** + + Display refresh + +***************************************************************************/ + +uint32_t spy_state::screen_update_spy(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) +{ + m_k052109->tilemap_update(); + + screen.priority().fill(0, cliprect); + + if (!m_video_enable) + bitmap.fill(768, cliprect); // ? + else + { + m_k052109->tilemap_draw(screen, bitmap, cliprect, 1, TILEMAP_DRAW_OPAQUE, 1); + m_k052109->tilemap_draw(screen, bitmap, cliprect, 2, 0, 2); + m_k051960->k051960_sprites_draw(bitmap, cliprect, screen.priority(), -1, -1); + m_k052109->tilemap_draw(screen, bitmap, cliprect, 0, 0, 0); + } + + return 0; +} uint8_t spy_state::spy_bankedram1_r(offs_t offset) { @@ -603,6 +729,8 @@ ROM_START( spyu ) ROM_LOAD( "857b04.bin", 0x00000, 0x40000, CRC(20b83c13) SHA1(63062f1c0a9adbbced3d3d73682a2cd1217bee7d) ) ROM_END +} // anonymous namespace + GAME( 1989, spy, 0, spy, spy, spy_state, empty_init, ROT0, "Konami", "S.P.Y. - Special Project Y (World ver. N)", MACHINE_SUPPORTS_SAVE ) GAME( 1989, spyu, spy, spy, spy, spy_state, empty_init, ROT0, "Konami", "S.P.Y. - Special Project Y (US ver. M)", MACHINE_SUPPORTS_SAVE ) diff --git a/src/mame/konami/spy.h b/src/mame/konami/spy.h deleted file mode 100644 index bf48adcfa75..00000000000 --- a/src/mame/konami/spy.h +++ /dev/null @@ -1,77 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Nicola Salmoria -/************************************************************************* - - S.P.Y. - -*************************************************************************/ -#ifndef MAME_KONAMI_SPY_H -#define MAME_KONAMI_SPY_H - -#pragma once - -#include "sound/k007232.h" -#include "k052109.h" -#include "k051960.h" -#include "konami_helper.h" -#include "emupal.h" - -class spy_state : public driver_device -{ -public: - spy_state(const machine_config &mconfig, device_type type, const char *tag) : - driver_device(mconfig, type, tag), - m_ram(*this, "ram"), - m_maincpu(*this, "maincpu"), - m_audiocpu(*this, "audiocpu"), - m_k007232_1(*this, "k007232_1"), - m_k007232_2(*this, "k007232_2"), - m_k052109(*this, "k052109"), - m_k051960(*this, "k051960"), - m_palette(*this, "palette") - { } - - void spy(machine_config &config); - -private: - /* memory pointers */ - required_shared_ptr m_ram; - uint8_t m_pmcram[0x800]{}; - std::vector m_paletteram{}; - - /* misc */ - int m_rambank = 0; - int m_pmcbank = 0; - int m_video_enable = 0; - int m_old_3f90 = 0; - - /* devices */ - required_device m_maincpu; - required_device m_audiocpu; - required_device m_k007232_1; - required_device m_k007232_2; - required_device m_k052109; - required_device m_k051960; - required_device m_palette; - uint8_t spy_bankedram1_r(offs_t offset); - void spy_bankedram1_w(offs_t offset, uint8_t data); - void bankswitch_w(uint8_t data); - void spy_3f90_w(uint8_t data); - void spy_sh_irqtrigger_w(uint8_t data); - void sound_bank_w(uint8_t data); - uint8_t k052109_051960_r(offs_t offset); - void k052109_051960_w(offs_t offset, uint8_t data); - virtual void machine_start() override; - virtual void machine_reset() override; - uint32_t screen_update_spy(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - void spy_collision( ); - void volume_callback0(uint8_t data); - void volume_callback1(uint8_t data); - K052109_CB_MEMBER(tile_callback); - K051960_CB_MEMBER(sprite_callback); - - void spy_map(address_map &map); - void spy_sound_map(address_map &map); -}; - -#endif // MAME_KONAMI_SPY_H diff --git a/src/mame/konami/spy_v.cpp b/src/mame/konami/spy_v.cpp deleted file mode 100644 index 4dea9261ee8..00000000000 --- a/src/mame/konami/spy_v.cpp +++ /dev/null @@ -1,68 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Nicola Salmoria - -#include "emu.h" -#include "spy.h" -#include "screen.h" - - -/*************************************************************************** - - Callbacks for the K052109 - -***************************************************************************/ - -K052109_CB_MEMBER(spy_state::tile_callback) -{ - static const int layer_colorbase[] = { 768 / 16, 0 / 16, 256 / 16 }; - - *flags = (*color & 0x20) ? TILE_FLIPX : 0; - *code |= ((*color & 0x03) << 8) | ((*color & 0x10) << 6) | ((*color & 0x0c) << 9) | (bank << 13); - *color = layer_colorbase[layer] + ((*color & 0xc0) >> 6); -} - - -/*************************************************************************** - - Callbacks for the K051960 - -***************************************************************************/ - -K051960_CB_MEMBER(spy_state::sprite_callback) -{ - enum { sprite_colorbase = 512 / 16 }; - - /* bit 4 = priority over layer A (0 = have priority) */ - /* bit 5 = priority over layer B (1 = have priority) */ - *priority = 0x00; - if ( *color & 0x10) *priority |= GFX_PMASK_1; - if (~*color & 0x20) *priority |= GFX_PMASK_2; - - *color = sprite_colorbase + (*color & 0x0f); -} - - -/*************************************************************************** - - Display refresh - -***************************************************************************/ - -uint32_t spy_state::screen_update_spy(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - m_k052109->tilemap_update(); - - screen.priority().fill(0, cliprect); - - if (!m_video_enable) - bitmap.fill(768, cliprect); // ? - else - { - m_k052109->tilemap_draw(screen, bitmap, cliprect, 1, TILEMAP_DRAW_OPAQUE, 1); - m_k052109->tilemap_draw(screen, bitmap, cliprect, 2, 0, 2); - m_k051960->k051960_sprites_draw(bitmap, cliprect, screen.priority(), -1, -1); - m_k052109->tilemap_draw(screen, bitmap, cliprect, 0, 0, 0); - } - - return 0; -} diff --git a/src/mame/konami/xexex.cpp b/src/mame/konami/xexex.cpp index 120e5bd75c4..b1748f204d1 100644 --- a/src/mame/konami/xexex.cpp +++ b/src/mame/konami/xexex.cpp @@ -136,23 +136,242 @@ reference(xexexj) : https://www.youtube.com/watch?v=TegjBEvvGxI ***************************************************************************/ #include "emu.h" -#include "xexex.h" + +#include "k053246_k053247_k055673.h" +#include "k053250.h" +#include "k053251.h" +#include "k054156_k054157_k056832.h" +#include "k054338.h" #include "konamipt.h" +#include "konami_helper.h" #include "cpu/m68000/m68000.h" #include "cpu/z80/z80.h" #include "machine/eepromser.h" #include "machine/k053252.h" +#include "machine/k054321.h" +#include "machine/timer.h" #include "sound/flt_vol.h" #include "sound/k054539.h" #include "sound/ymopm.h" +#include "emupal.h" +#include "screen.h" #include "speaker.h" +namespace { + #define XE_DEBUG 0 #define XE_SKIPIDLE 1 #define XE_DMADELAY attotime::from_usec(256) +class xexex_state : public driver_device +{ +public: + xexex_state(const machine_config &mconfig, device_type type, const char *tag) + : driver_device(mconfig, type, tag) + , m_workram(*this, "workram") + , m_spriteram(*this, "spriteram") + , m_z80bank(*this, "z80bank") + , m_maincpu(*this, "maincpu") + , m_audiocpu(*this, "audiocpu") + , m_k054539(*this, "k054539") + , m_filter_l(*this, "filter%u_l", 1) + , m_filter_r(*this, "filter%u_r", 1) + , m_k056832(*this, "k056832") + , m_k053246(*this, "k053246") + , m_k053250(*this, "k053250") + , m_k053251(*this, "k053251") + , m_k053252(*this, "k053252") + , m_k054338(*this, "k054338") + , m_palette(*this, "palette") + , m_screen(*this, "screen") + , m_k054321(*this, "k054321") + { + } + + void xexex(machine_config &config); + + void init_xexex(); + +private: + /* memory pointers */ + required_shared_ptr m_workram; + required_shared_ptr m_spriteram; + + /* memory regions */ + required_memory_bank m_z80bank; + + /* video-related */ + int m_layer_colorbase[4]{}; + int m_sprite_colorbase = 0; + int m_layerpri[4]{}; + int m_cur_alpha = 0; + + /* misc */ + uint16_t m_cur_control2 = 0; + int32_t m_strip_0x1a = 0; + int m_suspension_active = 0; + int m_resume_trigger = 0; + emu_timer *m_dmadelay_timer = nullptr; + int m_frame = 0; + + /* devices */ + required_device m_maincpu; + required_device m_audiocpu; + required_device m_k054539; + required_device_array m_filter_l; + required_device_array m_filter_r; + required_device m_k056832; + required_device m_k053246; + required_device m_k053250; + required_device m_k053251; + required_device m_k053252; + required_device m_k054338; + required_device m_palette; + required_device m_screen; + required_device m_k054321; + + uint16_t spriteram_mirror_r(offs_t offset); + void spriteram_mirror_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); + uint16_t xexex_waitskip_r(); + uint16_t control2_r(); + void control2_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); + void sound_irq_w(uint16_t data); + void sound_bankswitch_w(uint8_t data); + + virtual void machine_start() override; + virtual void machine_reset() override; + virtual void video_start() override; + uint32_t screen_update_xexex(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); + TIMER_CALLBACK_MEMBER(dmaend_callback); + TIMER_DEVICE_CALLBACK_MEMBER(xexex_interrupt); + void xexex_postload(); + void xexex_objdma(int limiter); + void parse_control2(); + K056832_CB_MEMBER(tile_callback); + K053246_CB_MEMBER(sprite_callback); + K054539_CB_MEMBER(ym_set_mixing); + + void main_map(address_map &map); + void sound_map(address_map &map); +}; + + +K053246_CB_MEMBER(xexex_state::sprite_callback) +{ + // Xexex doesn't seem to use bit8 and 9 as effect selectors so this should be safe. + // (pdrawgfx() still needs change to fix Elaine's end-game graphics) + int pri = (*color & 0x3e0) >> 4; + + if (pri <= m_layerpri[3]) + *priority_mask = 0; + else if (pri > m_layerpri[3] && pri <= m_layerpri[2]) + *priority_mask = 0xff00; + else if (pri > m_layerpri[2] && pri <= m_layerpri[1]) + *priority_mask = 0xff00 | 0xf0f0; + else if (pri > m_layerpri[1] && pri <= m_layerpri[0]) + *priority_mask = 0xff00 | 0xf0f0 | 0xcccc; + else + *priority_mask = 0xff00 | 0xf0f0 | 0xcccc | 0xaaaa; + + *color = m_sprite_colorbase | (*color & 0x001f); +} + +K056832_CB_MEMBER(xexex_state::tile_callback) +{ + /* + Color format + xxxx ---- Color + ---- -x-- Alpha blend enable + ---- --x- Used, Unknown + Everything else : unknown + */ + *priority = *color & 1; // alpha flag + *color = m_layer_colorbase[layer] | (*color >> 2 & 0x0f); +} + +void xexex_state::video_start() +{ + assert(m_screen->format() == BITMAP_FORMAT_RGB32); + + m_cur_alpha = 0; + + // Xexex has relative plane offsets of -2,2,4,6 vs. -2,0,2,3 in MW and GX. + m_k056832->set_layer_offs(0, -2, 16); + m_k056832->set_layer_offs(1, 2, 16); + m_k056832->set_layer_offs(2, 4, 16); + m_k056832->set_layer_offs(3, 6, 16); +} + +uint32_t xexex_state::screen_update_xexex(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) +{ + static const int K053251_CI[4] = { k053251_device::CI1, k053251_device::CI2, k053251_device::CI3, k053251_device::CI4 }; + int layer[4]; + int bg_colorbase, new_colorbase, plane, alpha; + + m_sprite_colorbase = m_k053251->get_palette_index(k053251_device::CI0); + bg_colorbase = m_k053251->get_palette_index(k053251_device::CI1); + m_layer_colorbase[0] = 0x70; + + for (plane = 1; plane < 4; plane++) + { + new_colorbase = m_k053251->get_palette_index(K053251_CI[plane]); + if (m_layer_colorbase[plane] != new_colorbase) + { + m_layer_colorbase[plane] = new_colorbase; + m_k056832->mark_plane_dirty( plane); + } + } + + layer[0] = 1; + m_layerpri[0] = m_k053251->get_priority(k053251_device::CI2); + layer[1] = 2; + m_layerpri[1] = m_k053251->get_priority(k053251_device::CI3); + layer[2] = 3; + m_layerpri[2] = m_k053251->get_priority(k053251_device::CI4); + layer[3] = -1; + m_layerpri[3] = m_k053251->get_priority(k053251_device::CI1); + + konami_sortlayers4(layer, m_layerpri); + + m_k054338->update_all_shadows(0, *m_palette); + m_k054338->fill_solid_bg(bitmap, cliprect); + + screen.priority().fill(0, cliprect); + + for (plane = 0; plane < 4; plane++) + { + if (layer[plane] < 0) + { + m_k053250->draw(bitmap, cliprect, bg_colorbase, 0, screen.priority(), 1 << plane); + } + else if (!m_cur_alpha || layer[plane] != 1) + { + m_k056832->tilemap_draw(screen, bitmap, cliprect, layer[plane], TILEMAP_DRAW_ALL_CATEGORIES, 1 << plane); + } + else + { + m_k056832->tilemap_draw(screen, bitmap, cliprect, layer[plane], TILEMAP_DRAW_CATEGORY(0), 1 << plane); + } + } + + m_k053246->k053247_sprites_draw( bitmap, cliprect); + + if (m_cur_alpha) + { + alpha = m_k054338->set_alpha_level(1); + + if (alpha > 0) + { + m_k056832->tilemap_draw(screen, bitmap, cliprect, 1, TILEMAP_DRAW_ALPHA(alpha) | TILEMAP_DRAW_CATEGORY(1), 0); + } + } + + m_k056832->tilemap_draw(screen, bitmap, cliprect, 0, TILEMAP_DRAW_ALL_CATEGORIES, 0); + return 0; +} + #if 0 // (for reference; do not remove) /* the interface with the 053247 is weird. The chip can address only 0x1000 bytes */ @@ -681,6 +900,8 @@ void xexex_state::init_xexex() } } +} // anonymous namespace + GAME( 1991, xexex, 0, xexex, xexex, xexex_state, init_xexex, ROT0, "Konami", "Xexex (ver EAA)", MACHINE_IMPERFECT_GRAPHICS | MACHINE_NO_COCKTAIL | MACHINE_SUPPORTS_SAVE ) GAME( 1991, orius, xexex, xexex, xexex, xexex_state, init_xexex, ROT0, "Konami", "Orius (ver UAA)", MACHINE_IMPERFECT_GRAPHICS | MACHINE_NO_COCKTAIL | MACHINE_SUPPORTS_SAVE ) GAME( 1991, xexexa, xexex, xexex, xexex, xexex_state, init_xexex, ROT0, "Konami", "Xexex (ver AAA)", MACHINE_IMPERFECT_GRAPHICS | MACHINE_NO_COCKTAIL | MACHINE_SUPPORTS_SAVE ) diff --git a/src/mame/konami/xexex.h b/src/mame/konami/xexex.h deleted file mode 100644 index b66c9a49416..00000000000 --- a/src/mame/konami/xexex.h +++ /dev/null @@ -1,119 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Olivier Galibert -/************************************************************************* - - Xexex - -*************************************************************************/ -#ifndef MAME_KONAMI_XEXEX_H -#define MAME_KONAMI_XEXEX_H - -#pragma once - -#include "k053250.h" -#include "sound/flt_vol.h" -#include "sound/k054539.h" -#include "machine/k053252.h" -#include "k054156_k054157_k056832.h" -#include "k053246_k053247_k055673.h" -#include "k054338.h" -#include "k053251.h" -#include "konami_helper.h" -#include "machine/k054321.h" -#include "machine/timer.h" -#include "emupal.h" -#include "screen.h" - -class xexex_state : public driver_device -{ -public: - xexex_state(const machine_config &mconfig, device_type type, const char *tag) - : driver_device(mconfig, type, tag) - , m_workram(*this, "workram") - , m_spriteram(*this, "spriteram") - , m_z80bank(*this, "z80bank") - , m_maincpu(*this, "maincpu") - , m_audiocpu(*this, "audiocpu") - , m_k054539(*this, "k054539") - , m_filter_l(*this, "filter%u_l", 1) - , m_filter_r(*this, "filter%u_r", 1) - , m_k056832(*this, "k056832") - , m_k053246(*this, "k053246") - , m_k053250(*this, "k053250") - , m_k053251(*this, "k053251") - , m_k053252(*this, "k053252") - , m_k054338(*this, "k054338") - , m_palette(*this, "palette") - , m_screen(*this, "screen") - , m_k054321(*this, "k054321") - { - } - - void xexex(machine_config &config); - - void init_xexex(); - -private: - /* memory pointers */ - required_shared_ptr m_workram; - required_shared_ptr m_spriteram; - - /* memory regions */ - required_memory_bank m_z80bank; - - /* video-related */ - int m_layer_colorbase[4]{}; - int m_sprite_colorbase = 0; - int m_layerpri[4]{}; - int m_cur_alpha = 0; - - /* misc */ - uint16_t m_cur_control2 = 0; - int32_t m_strip_0x1a = 0; - int m_suspension_active = 0; - int m_resume_trigger = 0; - emu_timer *m_dmadelay_timer = nullptr; - int m_frame = 0; - - /* devices */ - required_device m_maincpu; - required_device m_audiocpu; - required_device m_k054539; - required_device_array m_filter_l; - required_device_array m_filter_r; - required_device m_k056832; - required_device m_k053246; - required_device m_k053250; - required_device m_k053251; - required_device m_k053252; - required_device m_k054338; - required_device m_palette; - required_device m_screen; - required_device m_k054321; - - uint16_t spriteram_mirror_r(offs_t offset); - void spriteram_mirror_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); - uint16_t xexex_waitskip_r(); - uint16_t control2_r(); - void control2_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); - void sound_irq_w(uint16_t data); - void sound_bankswitch_w(uint8_t data); - - virtual void machine_start() override; - virtual void machine_reset() override; - virtual void video_start() override; - uint32_t screen_update_xexex(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); - TIMER_CALLBACK_MEMBER(dmaend_callback); - TIMER_DEVICE_CALLBACK_MEMBER(xexex_interrupt); - void xexex_postload(); - void xexex_objdma(int limiter); - void parse_control2(); - K056832_CB_MEMBER(tile_callback); - K053246_CB_MEMBER(sprite_callback); - K054539_CB_MEMBER(ym_set_mixing); - - void main_map(address_map &map); - void sound_map(address_map &map); -}; - -#endif // MAME_KONAMI_XEXEX_H diff --git a/src/mame/konami/xexex_v.cpp b/src/mame/konami/xexex_v.cpp deleted file mode 100644 index bca3d8be56b..00000000000 --- a/src/mame/konami/xexex_v.cpp +++ /dev/null @@ -1,118 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Olivier Galibert -#include "emu.h" -#include "xexex.h" - -K053246_CB_MEMBER(xexex_state::sprite_callback) -{ - // Xexex doesn't seem to use bit8 and 9 as effect selectors so this should be safe. - // (pdrawgfx() still needs change to fix Elaine's end-game graphics) - int pri = (*color & 0x3e0) >> 4; - - if (pri <= m_layerpri[3]) - *priority_mask = 0; - else if (pri > m_layerpri[3] && pri <= m_layerpri[2]) - *priority_mask = 0xff00; - else if (pri > m_layerpri[2] && pri <= m_layerpri[1]) - *priority_mask = 0xff00 | 0xf0f0; - else if (pri > m_layerpri[1] && pri <= m_layerpri[0]) - *priority_mask = 0xff00 | 0xf0f0 | 0xcccc; - else - *priority_mask = 0xff00 | 0xf0f0 | 0xcccc | 0xaaaa; - - *color = m_sprite_colorbase | (*color & 0x001f); -} - -K056832_CB_MEMBER(xexex_state::tile_callback) -{ - /* - Color format - xxxx ---- Color - ---- -x-- Alpha blend enable - ---- --x- Used, Unknown - Everything else : unknown - */ - *priority = *color & 1; // alpha flag - *color = m_layer_colorbase[layer] | (*color >> 2 & 0x0f); -} - -void xexex_state::video_start() -{ - assert(m_screen->format() == BITMAP_FORMAT_RGB32); - - m_cur_alpha = 0; - - // Xexex has relative plane offsets of -2,2,4,6 vs. -2,0,2,3 in MW and GX. - m_k056832->set_layer_offs(0, -2, 16); - m_k056832->set_layer_offs(1, 2, 16); - m_k056832->set_layer_offs(2, 4, 16); - m_k056832->set_layer_offs(3, 6, 16); -} - -uint32_t xexex_state::screen_update_xexex(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) -{ - static const int K053251_CI[4] = { k053251_device::CI1, k053251_device::CI2, k053251_device::CI3, k053251_device::CI4 }; - int layer[4]; - int bg_colorbase, new_colorbase, plane, alpha; - - m_sprite_colorbase = m_k053251->get_palette_index(k053251_device::CI0); - bg_colorbase = m_k053251->get_palette_index(k053251_device::CI1); - m_layer_colorbase[0] = 0x70; - - for (plane = 1; plane < 4; plane++) - { - new_colorbase = m_k053251->get_palette_index(K053251_CI[plane]); - if (m_layer_colorbase[plane] != new_colorbase) - { - m_layer_colorbase[plane] = new_colorbase; - m_k056832->mark_plane_dirty( plane); - } - } - - layer[0] = 1; - m_layerpri[0] = m_k053251->get_priority(k053251_device::CI2); - layer[1] = 2; - m_layerpri[1] = m_k053251->get_priority(k053251_device::CI3); - layer[2] = 3; - m_layerpri[2] = m_k053251->get_priority(k053251_device::CI4); - layer[3] = -1; - m_layerpri[3] = m_k053251->get_priority(k053251_device::CI1); - - konami_sortlayers4(layer, m_layerpri); - - m_k054338->update_all_shadows(0, *m_palette); - m_k054338->fill_solid_bg(bitmap, cliprect); - - screen.priority().fill(0, cliprect); - - for (plane = 0; plane < 4; plane++) - { - if (layer[plane] < 0) - { - m_k053250->draw(bitmap, cliprect, bg_colorbase, 0, screen.priority(), 1 << plane); - } - else if (!m_cur_alpha || layer[plane] != 1) - { - m_k056832->tilemap_draw(screen, bitmap, cliprect, layer[plane], TILEMAP_DRAW_ALL_CATEGORIES, 1 << plane); - } - else - { - m_k056832->tilemap_draw(screen, bitmap, cliprect, layer[plane], TILEMAP_DRAW_CATEGORY(0), 1 << plane); - } - } - - m_k053246->k053247_sprites_draw( bitmap, cliprect); - - if (m_cur_alpha) - { - alpha = m_k054338->set_alpha_level(1); - - if (alpha > 0) - { - m_k056832->tilemap_draw(screen, bitmap, cliprect, 1, TILEMAP_DRAW_ALPHA(alpha) | TILEMAP_DRAW_CATEGORY(1), 0); - } - } - - m_k056832->tilemap_draw(screen, bitmap, cliprect, 0, TILEMAP_DRAW_ALL_CATEGORIES, 0); - return 0; -} -- cgit v1.2.3