From 96c119d7fa627dde9368ec567a73920b398cd330 Mon Sep 17 00:00:00 2001 From: hap Date: Wed, 14 Dec 2022 01:19:43 +0100 Subject: tehkanwc: merge driver files --- src/mame/tecmo/tehkanwc.cpp | 245 +++++++++++++++++++++++++++++++++++++++--- src/mame/tecmo/tehkanwc.h | 102 ------------------ src/mame/tecmo/tehkanwc_v.cpp | 132 ----------------------- 3 files changed, 228 insertions(+), 251 deletions(-) delete mode 100644 src/mame/tecmo/tehkanwc.h delete mode 100644 src/mame/tecmo/tehkanwc_v.cpp diff --git a/src/mame/tecmo/tehkanwc.cpp b/src/mame/tecmo/tehkanwc.cpp index f79efd88c3d..d6854c3d1a2 100644 --- a/src/mame/tecmo/tehkanwc.cpp +++ b/src/mame/tecmo/tehkanwc.cpp @@ -12,6 +12,12 @@ robbiex@rocketmail.com TODO: - dip switches and input ports for Gridiron and Tee'd Off +- Check MEMORY_* definitions (too many M?A_NOP areas) +- Check sound in all games (too many messages like this in the .log file : + 'Warning: sound latch 2 written before being read') +- Figure out the controls in 'tehkanwc' (they are told to be better in MAME 0.34) +- Figure out the controls in 'teedoff' +- Confirm "Difficulty" Dip Switch in 'teedoff' Additional notes (Steph 2002.01.14) @@ -67,31 +73,117 @@ But here again, 0x1d06 is in ROM and it's ALWAYS 00 ! So the "jp z" instruction at 0x0238 of the main CPU will ALWAYS jump in shared memory when NO code seems to be written ! -TO DO : - - - Check MEMORY_* definitions (too many M?A_NOP areas) - - Check sound in all games (too many messages like this in the .log file : - 'Warning: sound latch 2 written before being read') - - Figure out the controls in 'tehkanwc' (they are told to be better in MAME 0.34) - - Figure out the controls in 'teedoff' - - Confirm "Difficulty" Dip Switch in 'teedoff' - ***************************************************************************/ #include "emu.h" -#include "tehkanwc.h" #include "cpu/z80/z80.h" +#include "machine/gen_latch.h" #include "machine/watchdog.h" #include "sound/ay8910.h" +#include "sound/msm5205.h" + +#include "emupal.h" #include "screen.h" #include "speaker.h" +#include "tilemap.h" #include "gridiron.lh" +namespace { + +class tehkanwc_state : public driver_device +{ +public: + tehkanwc_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_subcpu(*this, "sub"), + m_msm(*this, "msm"), + m_gfxdecode(*this, "gfxdecode"), + m_palette(*this, "palette"), + m_soundlatch(*this, "soundlatch"), + m_soundlatch2(*this, "soundlatch2"), + m_videoram(*this, "videoram"), + m_colorram(*this, "colorram"), + m_videoram2(*this, "videoram2"), + m_spriteram(*this, "spriteram"), + m_digits(*this, "digit%u", 0U) + { } + + void tehkanwcb(machine_config &config); + void tehkanwc(machine_config &config); + +protected: + virtual void machine_start() override; + virtual void video_start() override; + +private: + required_device m_maincpu; + required_device m_audiocpu; + required_device m_subcpu; + required_device m_msm; + required_device m_gfxdecode; + required_device m_palette; + required_device m_soundlatch; + required_device m_soundlatch2; + + required_shared_ptr m_videoram; + required_shared_ptr m_colorram; + required_shared_ptr m_videoram2; + required_shared_ptr m_spriteram; + + output_finder<2> m_digits; + + int m_track0[2]{}; + int m_track1[2]{}; + int m_msm_data_offs = 0; + int m_toggle = 0; + uint8_t m_scroll_x[2]{}; + tilemap_t *m_bg_tilemap = nullptr; + tilemap_t *m_fg_tilemap = nullptr; + + void sub_cpu_reset_w(uint8_t data); + void sound_cpu_reset_w(uint8_t data); + uint8_t track_0_r(offs_t offset); + uint8_t track_1_r(offs_t offset); + void track_0_reset_w(offs_t offset, uint8_t data); + void track_1_reset_w(offs_t offset, uint8_t data); + void sound_command_w(uint8_t data); + void videoram_w(offs_t offset, uint8_t data); + void colorram_w(offs_t offset, uint8_t data); + void videoram2_w(offs_t offset, uint8_t data); + void scroll_x_w(offs_t offset, uint8_t data); + void scroll_y_w(uint8_t data); + void flipscreen_x_w(uint8_t data); + void flipscreen_y_w(uint8_t data); + void gridiron_led0_w(uint8_t data); + void gridiron_led1_w(uint8_t data); + uint8_t teedoff_unk_r(); + uint8_t portA_r(); + uint8_t portB_r(); + void portA_w(uint8_t data); + void portB_w(uint8_t data); + void msm_reset_w(uint8_t data); + DECLARE_WRITE_LINE_MEMBER(adpcm_int); + + TILE_GET_INFO_MEMBER(get_bg_tile_info); + TILE_GET_INFO_MEMBER(get_fg_tile_info); + + uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); + void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect); + + void shared_mem(address_map &map); + void main_mem(address_map &map); + void sound_mem(address_map &map); + void sound_port(address_map &map); + void sub_mem(address_map &map); +}; void tehkanwc_state::machine_start() { + // register for savestates save_item(NAME(m_track0)); save_item(NAME(m_track1)); save_item(NAME(m_msm_data_offs)); @@ -141,6 +233,130 @@ void tehkanwc_state::track_1_reset_w(offs_t offset, uint8_t data) } +uint8_t tehkanwc_state::teedoff_unk_r() +{ + logerror("%s: teedoff_unk_r\n", machine().describe_context()); + return 0x80; +} + + +/* Video emulation */ + +void tehkanwc_state::videoram_w(offs_t offset, uint8_t data) +{ + m_videoram[offset] = data; + m_fg_tilemap->mark_tile_dirty(offset); +} + +void tehkanwc_state::colorram_w(offs_t offset, uint8_t data) +{ + m_colorram[offset] = data; + m_fg_tilemap->mark_tile_dirty(offset); +} + +void tehkanwc_state::videoram2_w(offs_t offset, uint8_t data) +{ + m_videoram2[offset] = data; + m_bg_tilemap->mark_tile_dirty(offset / 2); +} + +void tehkanwc_state::scroll_x_w(offs_t offset, uint8_t data) +{ + m_scroll_x[offset] = data; +} + +void tehkanwc_state::scroll_y_w(uint8_t data) +{ + m_bg_tilemap->set_scrolly(0, data); +} + +void tehkanwc_state::flipscreen_x_w(uint8_t data) +{ + flip_screen_x_set(data & 0x40); +} + +void tehkanwc_state::flipscreen_y_w(uint8_t data) +{ + flip_screen_y_set(data & 0x40); +} + + +TILE_GET_INFO_MEMBER(tehkanwc_state::get_bg_tile_info) +{ + int offs = tile_index * 2; + int attr = m_videoram2[offs + 1]; + int code = m_videoram2[offs] + ((attr & 0x30) << 4); + int color = attr & 0x0f; + int flags = ((attr & 0x40) ? TILE_FLIPX : 0) | ((attr & 0x80) ? TILE_FLIPY : 0); + + tileinfo.set(2, code, color, flags); +} + +TILE_GET_INFO_MEMBER(tehkanwc_state::get_fg_tile_info) +{ + int attr = m_colorram[tile_index]; + int code = m_videoram[tile_index] + ((attr & 0x10) << 4); + int color = attr & 0x0f; + int flags = ((attr & 0x40) ? TILE_FLIPX : 0) | ((attr & 0x80) ? TILE_FLIPY : 0); + + tileinfo.category = (attr & 0x20) ? 0 : 1; + + tileinfo.set(0, code, color, flags); +} + +void tehkanwc_state::video_start() +{ + m_bg_tilemap = &machine().tilemap().create( + *m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(tehkanwc_state::get_bg_tile_info)), + TILEMAP_SCAN_ROWS, 16, 8, 32, 32); + + m_fg_tilemap = &machine().tilemap().create( + *m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(tehkanwc_state::get_fg_tile_info)), + TILEMAP_SCAN_ROWS, 8, 8, 32, 32); + + m_fg_tilemap->set_transparent_pen(0); +} + +void tehkanwc_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect) +{ + for (int offs = 0;offs < m_spriteram.bytes();offs += 4) + { + int attr = m_spriteram[offs + 1]; + int code = m_spriteram[offs] + ((attr & 0x08) << 5); + int color = attr & 0x07; + int flipx = attr & 0x40; + int flipy = attr & 0x80; + int sx = m_spriteram[offs + 2] + ((attr & 0x20) << 3) - 128; + int sy = m_spriteram[offs + 3]; + + if (flip_screen_x()) + { + sx = 240 - sx; + flipx = !flipx; + } + + if (flip_screen_y()) + { + sy = 240 - sy; + flipy = !flipy; + } + + m_gfxdecode->gfx(1)->transpen(bitmap, cliprect, code, color, flipx, flipy, sx, sy, 0); + } +} + +uint32_t tehkanwc_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) +{ + m_bg_tilemap->set_scrollx(0, m_scroll_x[0] + 256 * m_scroll_x[1]); + m_bg_tilemap->draw(screen, bitmap, cliprect, 0, 0); + m_fg_tilemap->draw(screen, bitmap, cliprect, 0, 0); + draw_sprites(bitmap, cliprect); + m_fg_tilemap->draw(screen, bitmap, cliprect, 1, 0); + + return 0; +} + + /* Gridiron Fight has a LED display on the control panel, to let each player choose the formation without letting the other know. @@ -157,13 +373,6 @@ void tehkanwc_state::gridiron_led1_w(uint8_t data) } -uint8_t tehkanwc_state::teedoff_unk_r() -{ - logerror("%s: teedoff_unk_r\n", machine().describe_context()); - return 0x80; -} - - /* Emulate MSM sound samples with counters */ uint8_t tehkanwc_state::portA_r() @@ -960,6 +1169,8 @@ ROM_START( teedoffj ) ROM_LOAD( "to-5.4r", 0x0000, 0x8000, CRC(e5e4246b) SHA1(b2fe2e68fa86163ebe1ef00ecce73fb62cef6b19) ) ROM_END +} // anonymous namespace + GAME( 1985, tehkanwc, 0, tehkanwc, tehkanwc, tehkanwc_state, empty_init, ROT0, "Tehkan", "Tehkan World Cup (set 1)", MACHINE_SUPPORTS_SAVE ) GAME( 1985, tehkanwcb, tehkanwc, tehkanwcb,tehkanwc, tehkanwc_state, empty_init, ROT0, "Tehkan", "Tehkan World Cup (set 2, bootleg?)", MACHINE_SUPPORTS_SAVE ) diff --git a/src/mame/tecmo/tehkanwc.h b/src/mame/tecmo/tehkanwc.h deleted file mode 100644 index ea683659968..00000000000 --- a/src/mame/tecmo/tehkanwc.h +++ /dev/null @@ -1,102 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Ernesto Corvi, Roberto Fresca -#ifndef MAME_INCLUDES_TEHKANWC_H -#define MAME_INCLUDES_TEHKANWC_H - -#pragma once - -#include "machine/gen_latch.h" -#include "sound/msm5205.h" -#include "emupal.h" -#include "tilemap.h" - -class tehkanwc_state : public driver_device -{ -public: - tehkanwc_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_subcpu(*this, "sub"), - m_msm(*this, "msm"), - m_gfxdecode(*this, "gfxdecode"), - m_palette(*this, "palette"), - m_soundlatch(*this, "soundlatch"), - m_soundlatch2(*this, "soundlatch2"), - m_videoram(*this, "videoram"), - m_colorram(*this, "colorram"), - m_videoram2(*this, "videoram2"), - m_spriteram(*this, "spriteram"), - m_digits(*this, "digit%u", 0U) - { } - - void tehkanwcb(machine_config &config); - void tehkanwc(machine_config &config); - -protected: - virtual void machine_start() override; - virtual void video_start() override; - -private: - required_device m_maincpu; - required_device m_audiocpu; - required_device m_subcpu; - required_device m_msm; - required_device m_gfxdecode; - required_device m_palette; - required_device m_soundlatch; - required_device m_soundlatch2; - - required_shared_ptr m_videoram; - required_shared_ptr m_colorram; - required_shared_ptr m_videoram2; - required_shared_ptr m_spriteram; - - output_finder<2> m_digits; - - int m_track0[2]{}; - int m_track1[2]{}; - int m_msm_data_offs = 0; - int m_toggle = 0; - uint8_t m_scroll_x[2]{}; - tilemap_t *m_bg_tilemap = nullptr; - tilemap_t *m_fg_tilemap = nullptr; - - void sub_cpu_reset_w(uint8_t data); - void sound_cpu_reset_w(uint8_t data); - uint8_t track_0_r(offs_t offset); - uint8_t track_1_r(offs_t offset); - void track_0_reset_w(offs_t offset, uint8_t data); - void track_1_reset_w(offs_t offset, uint8_t data); - void sound_command_w(uint8_t data); - void videoram_w(offs_t offset, uint8_t data); - void colorram_w(offs_t offset, uint8_t data); - void videoram2_w(offs_t offset, uint8_t data); - void scroll_x_w(offs_t offset, uint8_t data); - void scroll_y_w(uint8_t data); - void flipscreen_x_w(uint8_t data); - void flipscreen_y_w(uint8_t data); - void gridiron_led0_w(uint8_t data); - void gridiron_led1_w(uint8_t data); - uint8_t teedoff_unk_r(); - uint8_t portA_r(); - uint8_t portB_r(); - void portA_w(uint8_t data); - void portB_w(uint8_t data); - void msm_reset_w(uint8_t data); - DECLARE_WRITE_LINE_MEMBER(adpcm_int); - - TILE_GET_INFO_MEMBER(get_bg_tile_info); - TILE_GET_INFO_MEMBER(get_fg_tile_info); - - uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect); - - void shared_mem(address_map &map); - void main_mem(address_map &map); - void sound_mem(address_map &map); - void sound_port(address_map &map); - void sub_mem(address_map &map); -}; - -#endif // MAME_INCLUDES_TEHKANWC_H diff --git a/src/mame/tecmo/tehkanwc_v.cpp b/src/mame/tecmo/tehkanwc_v.cpp deleted file mode 100644 index 5b7b24bca8b..00000000000 --- a/src/mame/tecmo/tehkanwc_v.cpp +++ /dev/null @@ -1,132 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Ernesto Corvi, Roberto Fresca -/*************************************************************************** - -Tehkan World Cup - (c) Tehkan 1985 - - -Ernesto Corvi -ernesto@imagina.com - -Roberto Juan Fresca -robbiex@rocketmail.com - -***************************************************************************/ - -#include "emu.h" -#include "tehkanwc.h" - - -void tehkanwc_state::videoram_w(offs_t offset, uint8_t data) -{ - m_videoram[offset] = data; - m_fg_tilemap->mark_tile_dirty(offset); -} - -void tehkanwc_state::colorram_w(offs_t offset, uint8_t data) -{ - m_colorram[offset] = data; - m_fg_tilemap->mark_tile_dirty(offset); -} - -void tehkanwc_state::videoram2_w(offs_t offset, uint8_t data) -{ - m_videoram2[offset] = data; - m_bg_tilemap->mark_tile_dirty(offset / 2); -} - -void tehkanwc_state::scroll_x_w(offs_t offset, uint8_t data) -{ - m_scroll_x[offset] = data; -} - -void tehkanwc_state::scroll_y_w(uint8_t data) -{ - m_bg_tilemap->set_scrolly(0, data); -} - -void tehkanwc_state::flipscreen_x_w(uint8_t data) -{ - flip_screen_x_set(data & 0x40); -} - -void tehkanwc_state::flipscreen_y_w(uint8_t data) -{ - flip_screen_y_set(data & 0x40); -} - - -TILE_GET_INFO_MEMBER(tehkanwc_state::get_bg_tile_info) -{ - int offs = tile_index * 2; - int attr = m_videoram2[offs + 1]; - int code = m_videoram2[offs] + ((attr & 0x30) << 4); - int color = attr & 0x0f; - int flags = ((attr & 0x40) ? TILE_FLIPX : 0) | ((attr & 0x80) ? TILE_FLIPY : 0); - - tileinfo.set(2, code, color, flags); -} - -TILE_GET_INFO_MEMBER(tehkanwc_state::get_fg_tile_info) -{ - int attr = m_colorram[tile_index]; - int code = m_videoram[tile_index] + ((attr & 0x10) << 4); - int color = attr & 0x0f; - int flags = ((attr & 0x40) ? TILE_FLIPX : 0) | ((attr & 0x80) ? TILE_FLIPY : 0); - - tileinfo.category = (attr & 0x20) ? 0 : 1; - - tileinfo.set(0, code, color, flags); -} - -void tehkanwc_state::video_start() -{ - m_bg_tilemap = &machine().tilemap().create( - *m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(tehkanwc_state::get_bg_tile_info)), - TILEMAP_SCAN_ROWS, 16, 8, 32, 32); - - m_fg_tilemap = &machine().tilemap().create( - *m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(tehkanwc_state::get_fg_tile_info)), - TILEMAP_SCAN_ROWS, 8, 8, 32, 32); - - m_fg_tilemap->set_transparent_pen(0); -} - -void tehkanwc_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - for (int offs = 0;offs < m_spriteram.bytes();offs += 4) - { - int attr = m_spriteram[offs + 1]; - int code = m_spriteram[offs] + ((attr & 0x08) << 5); - int color = attr & 0x07; - int flipx = attr & 0x40; - int flipy = attr & 0x80; - int sx = m_spriteram[offs + 2] + ((attr & 0x20) << 3) - 128; - int sy = m_spriteram[offs + 3]; - - if (flip_screen_x()) - { - sx = 240 - sx; - flipx = !flipx; - } - - if (flip_screen_y()) - { - sy = 240 - sy; - flipy = !flipy; - } - - m_gfxdecode->gfx(1)->transpen(bitmap, cliprect, code, color, flipx, flipy, sx, sy, 0); - } -} - -uint32_t tehkanwc_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - m_bg_tilemap->set_scrollx(0, m_scroll_x[0] + 256 * m_scroll_x[1]); - m_bg_tilemap->draw(screen, bitmap, cliprect, 0, 0); - m_fg_tilemap->draw(screen, bitmap, cliprect, 0, 0); - draw_sprites(bitmap, cliprect); - m_fg_tilemap->draw(screen, bitmap, cliprect, 1, 0); - - return 0; -} -- cgit v1.2.3