From fffa96c74394fb6300eb309da58831e1c282d055 Mon Sep 17 00:00:00 2001 From: Ivan Vangelista Date: Thu, 3 Nov 2022 19:23:43 +0100 Subject: - cinematronics/leland.h: zero-filled variables - dataeast/stadhero.cpp, dataeast/tryout.cpp: consolidated drivers in a single file --- src/mame/cinematronics/leland.h | 64 +++---- src/mame/dataeast/stadhero.cpp | 184 +++++++++++++++++---- src/mame/dataeast/stadhero.h | 56 ------- src/mame/dataeast/stadhero_v.cpp | 65 -------- src/mame/dataeast/tryout.cpp | 348 +++++++++++++++++++++++++++++++++++++-- src/mame/dataeast/tryout.h | 77 --------- src/mame/dataeast/tryout_v.cpp | 252 ---------------------------- 7 files changed, 519 insertions(+), 527 deletions(-) delete mode 100644 src/mame/dataeast/stadhero.h delete mode 100644 src/mame/dataeast/stadhero_v.cpp delete mode 100644 src/mame/dataeast/tryout.h delete mode 100644 src/mame/dataeast/tryout_v.cpp diff --git a/src/mame/cinematronics/leland.h b/src/mame/cinematronics/leland.h index 96e67fa3fac..98d55ed27c1 100644 --- a/src/mame/cinematronics/leland.h +++ b/src/mame/cinematronics/leland.h @@ -21,12 +21,6 @@ #define ATAXX_EXTRA_TRAM_SIZE 0x800 -struct vram_state_data -{ - u16 m_addr; - u8 m_latch[2]; -}; - class leland_80186_sound_device; class leland_state : public driver_device @@ -102,18 +96,18 @@ protected: optional_ioport_array<4> m_io_in; optional_ioport_array<6> m_io_an; - emu_timer *m_master_int_timer; - u8 m_battery_ram_enable; + emu_timer *m_master_int_timer = nullptr; + u8 m_battery_ram_enable = 0U; void rotate_memory(const char *cpuname); int dial_compute_value(int new_val, int indx); - u8 m_dial_last_input[4]; - u8 m_dial_last_result[4]; - u8 m_analog_result; + u8 m_dial_last_input[4]{}; + u8 m_dial_last_result[4]{}; + u8 m_analog_result = 0U; - int m_dangerz_x; - int m_dangerz_y; + int m_dangerz_x = 0; + int m_dangerz_y = 0; void init_master_ports(u8 mvram_base, u8 io_base); void (leland_state::*m_update_master_bank)(); @@ -121,7 +115,7 @@ protected: int vram_port_r(offs_t offset, int num); void vram_port_w(offs_t offset, u8 data, int num); - u8 m_wcol_enable; + u8 m_wcol_enable = 0U; u8 master_analog_key_r(offs_t offset); void master_analog_key_w(offs_t offset, u8 data); @@ -131,10 +125,18 @@ protected: void scroll_w(offs_t offset, u8 data); void leland_master_alt_bankswitch_w(u8 data); - tilemap_t *m_tilemap; - u16 m_xscroll; - u16 m_yscroll; + tilemap_t *m_tilemap = nullptr; + u16 m_xscroll = 0U; + u16 m_yscroll = 0U; + std::unique_ptr m_video_ram; + + struct vram_state_data + { + u16 m_addr = 0U; + u8 m_latch[2]{}; + }; + struct vram_state_data m_vram_state[2]; void slave_map_program(address_map &map); @@ -150,20 +152,20 @@ private: required_region_ptr m_bg_gfxrom; optional_region_ptr m_bg_prom; - u8 m_dac_control; - u8 *m_alleymas_kludge_mem; - u8 m_gfx_control; - u8 m_keycard_shift; - u8 m_keycard_bit; - u8 m_keycard_state; - u8 m_keycard_clock; - u8 m_keycard_command[3]; - u8 m_top_board_bank; - u8 m_sound_port_bank; - u8 m_alternate_bank; - u8 m_gfxbank; - u16 m_last_scanline; - emu_timer *m_scanline_timer; + u8 m_dac_control = 0U; + u8 *m_alleymas_kludge_mem = nullptr; + u8 m_gfx_control = 0U; + u8 m_keycard_shift = 0U; + u8 m_keycard_bit = 0U; + u8 m_keycard_state = 0U; + u8 m_keycard_clock = 0U; + u8 m_keycard_command[3]{}; + u8 m_top_board_bank = 0U; + u8 m_sound_port_bank = 0U; + u8 m_alternate_bank = 0U; + u8 m_gfxbank = 0U; + u16 m_last_scanline = 0U; + emu_timer *m_scanline_timer = nullptr; u8 cerberus_dial_1_r(); u8 cerberus_dial_2_r(); diff --git a/src/mame/dataeast/stadhero.cpp b/src/mame/dataeast/stadhero.cpp index afe60bd5fe5..f2e25287a87 100644 --- a/src/mame/dataeast/stadhero.cpp +++ b/src/mame/dataeast/stadhero.cpp @@ -1,5 +1,6 @@ // license:BSD-3-Clause -// copyright-holders:Bryan McPhail +// copyright-holders: Bryan McPhail + /*************************************************************************** Stadium Hero (Japan) (c) 1988 Data East Corporation @@ -90,16 +91,124 @@ ***************************************************************************/ #include "emu.h" -#include "stadhero.h" -#include "cpu/m68000/m68000.h" +#include "decbac06.h" +#include "decmxc06.h" + #include "cpu/m6502/m6502.h" +#include "cpu/m68000/m68000.h" +#include "machine/gen_latch.h" #include "sound/okim6295.h" -#include "sound/ymopn.h" #include "sound/ymopl.h" +#include "sound/ymopn.h" + #include "emupal.h" +#include "screen.h" #include "speaker.h" +#include "tilemap.h" + +namespace { + +class stadhero_state : public driver_device +{ +public: + stadhero_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_tilegen(*this, "tilegen"), + m_spritegen(*this, "spritegen"), + m_gfxdecode(*this, "gfxdecode"), + m_soundlatch(*this, "soundlatch"), + m_screen(*this, "screen"), + m_spriteram(*this, "spriteram"), + m_pf1_data(*this, "pf1_data"), + m_coin(*this, "COIN") + { + } + + void stadhero(machine_config &config); + +protected: + virtual void video_start() override; + +private: + required_device m_maincpu; + required_device m_audiocpu; + required_device m_tilegen; + required_device m_spritegen; + required_device m_gfxdecode; + required_device m_soundlatch; + required_device m_screen; + + required_shared_ptr m_spriteram; + required_shared_ptr m_pf1_data; + + required_ioport m_coin; + + tilemap_t *m_pf1_tilemap = nullptr; + + void int_ack_w(uint16_t data); + void pf1_data_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); + uint8_t mystery_r(); + + TILE_GET_INFO_MEMBER(get_pf1_tile_info); + uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); + void audio_map(address_map &map); + void main_map(address_map &map); +}; + + +// video + +/******************************************************************************/ + +uint32_t stadhero_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) +{ + bool const flip = m_tilegen->get_flip_state(); + m_tilegen->set_flip_screen(flip); + m_spritegen->set_flip_screen(flip); + m_pf1_tilemap->set_flip(flip ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0); + + m_tilegen->deco_bac06_pf_draw(screen, bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 0); + m_spritegen->draw_sprites(screen, bitmap, cliprect, m_gfxdecode->gfx(2), m_spriteram, 0x800 / 2); + m_pf1_tilemap->draw(screen, bitmap, cliprect, 0, 0); + return 0; +} + +/******************************************************************************/ + +void stadhero_state::pf1_data_w(offs_t offset, uint16_t data, uint16_t mem_mask) +{ + COMBINE_DATA(&m_pf1_data[offset]); + m_pf1_tilemap->mark_tile_dirty(offset); +} + + +/******************************************************************************/ + +TILE_GET_INFO_MEMBER(stadhero_state::get_pf1_tile_info) +{ + int tile = m_pf1_data[tile_index]; + int const color = tile >> 12; + + tile = tile & 0xfff; + tileinfo.set(0, + tile, + color, + 0); +} + +void stadhero_state::video_start() +{ + m_pf1_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(stadhero_state::get_pf1_tile_info)), TILEMAP_SCAN_ROWS, 8, 8, 32, 32); + m_pf1_tilemap->set_transparent_pen(0); +} + +/******************************************************************************/ + +// machine /******************************************************************************/ @@ -121,8 +230,8 @@ uint8_t stadhero_state::mystery_r() void stadhero_state::main_map(address_map &map) { map(0x000000, 0x01ffff).rom(); - map(0x200000, 0x2007ff).ram().w(FUNC(stadhero_state::pf1_data_w)).share("pf1_data"); - map(0x240000, 0x240007).w(m_tilegen, FUNC(deco_bac06_device::pf_control_0_w)); /* text layer */ + map(0x200000, 0x2007ff).ram().w(FUNC(stadhero_state::pf1_data_w)).share(m_pf1_data); + map(0x240000, 0x240007).w(m_tilegen, FUNC(deco_bac06_device::pf_control_0_w)); // text layer map(0x240010, 0x240017).w(m_tilegen, FUNC(deco_bac06_device::pf_control_1_w)); map(0x260000, 0x261fff).rw(m_tilegen, FUNC(deco_bac06_device::pf_data_r), FUNC(deco_bac06_device::pf_data_w)); map(0x30c000, 0x30c001).portr("INPUTS"); @@ -131,8 +240,8 @@ void stadhero_state::main_map(address_map &map) map(0x30c004, 0x30c005).portr("DSW").w(FUNC(stadhero_state::int_ack_w)); map(0x30c007, 0x30c007).w(m_soundlatch, FUNC(generic_latch_8_device::write)); map(0x310000, 0x3107ff).ram().w("palette", FUNC(palette_device::write16)).share("palette"); - map(0xff8000, 0xffbfff).ram(); /* Main ram */ - map(0xffc000, 0xffc7ff).mirror(0x000800).ram().share("spriteram"); + map(0xff8000, 0xffbfff).ram(); // Main RAM + map(0xffc000, 0xffc7ff).mirror(0x000800).ram().share(m_spriteram); } /******************************************************************************/ @@ -150,7 +259,7 @@ void stadhero_state::audio_map(address_map &map) /******************************************************************************/ static INPUT_PORTS_START( stadhero ) - PORT_START("INPUTS") /* 0x30c000 - 0x30c001 */ + PORT_START("INPUTS") // 0x30c000 - 0x30c001 PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(1) PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(1) PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(1) @@ -168,7 +277,7 @@ static INPUT_PORTS_START( stadhero ) PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(2) PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_START2 ) - PORT_START("DSW") /* 0x30c004 - 0x30c005 */ + PORT_START("DSW") // 0x30c004 - 0x30c005 PORT_DIPNAME( 0x0003, 0x0003, DEF_STR( Coin_A ) ) PORT_DIPSETTING( 0x0000, DEF_STR( 3C_1C ) ) PORT_DIPSETTING( 0x0001, DEF_STR( 2C_1C ) ) @@ -187,17 +296,17 @@ static INPUT_PORTS_START( stadhero ) PORT_DIPSETTING( 0x0040, DEF_STR( Off ) ) PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) PORT_DIPUNUSED( 0x0080, IP_ACTIVE_LOW ) - PORT_DIPNAME( 0x0300, 0x0300, "Time (1P Vs CPU)" ) /* Table at 0x0014f6 */ + PORT_DIPNAME( 0x0300, 0x0300, "Time (1P Vs CPU)" ) // Table at 0x0014f6 PORT_DIPSETTING( 0x0200, "600" ) PORT_DIPSETTING( 0x0300, "500" ) PORT_DIPSETTING( 0x0100, "450" ) PORT_DIPSETTING( 0x0000, "400" ) - PORT_DIPNAME( 0x0c00, 0x0c00, "Time (1P Vs 2P)" ) /* Table at 0x0014fe */ + PORT_DIPNAME( 0x0c00, 0x0c00, "Time (1P Vs 2P)" ) // Table at 0x0014fe PORT_DIPSETTING( 0x0800, "270" ) PORT_DIPSETTING( 0x0c00, "210" ) PORT_DIPSETTING( 0x0400, "180" ) PORT_DIPSETTING( 0x0000, "120" ) - PORT_DIPNAME( 0x3000, 0x3000, "Final Set" ) /* Table at 0x00078c */ + PORT_DIPNAME( 0x3000, 0x3000, "Final Set" ) // Table at 0x00078c PORT_DIPSETTING( 0x2000, "3 Credits" ) PORT_DIPSETTING( 0x3000, "4 Credits" ) PORT_DIPSETTING( 0x1000, "5 Credits" ) @@ -205,7 +314,7 @@ static INPUT_PORTS_START( stadhero ) PORT_DIPUNUSED( 0x4000, IP_ACTIVE_LOW ) PORT_DIPUNUSED( 0x8000, IP_ACTIVE_LOW ) - PORT_START("COIN") /* 0x30c002 */ + PORT_START("COIN") // 0x30c002 PORT_BIT( 0x0f, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN2 ) @@ -217,13 +326,13 @@ INPUT_PORTS_END static const gfx_layout charlayout = { - 8,8, /* 8*8 chars */ + 8,8, // 8*8 chars RGN_FRAC(1,3), - 3, /* 4 bits per pixel */ + 3, // 4 bits per pixel { RGN_FRAC(0,3), RGN_FRAC(1,3), RGN_FRAC(2,3) }, { STEP8(0,1) }, { STEP8(0,8) }, - 8*8 /* every char takes 8 consecutive bytes */ + 8*8 // every char takes 8 consecutive bytes }; static const gfx_layout tile_3bpp = @@ -249,24 +358,24 @@ static const gfx_layout spritelayout = }; static GFXDECODE_START( gfx_stadhero ) - GFXDECODE_ENTRY( "gfx1", 0, charlayout, 0, 16 ) /* Characters 8x8 */ - GFXDECODE_ENTRY( "gfx2", 0, tile_3bpp, 512, 16 ) /* Tiles 16x16 */ - GFXDECODE_ENTRY( "gfx3", 0, spritelayout, 256, 16 ) /* Sprites 16x16 */ + GFXDECODE_ENTRY( "chars", 0, charlayout, 0, 16 ) // 8x8 + GFXDECODE_ENTRY( "tiles", 0, tile_3bpp, 512, 16 ) // 16x16 + GFXDECODE_ENTRY( "sprites", 0, spritelayout, 256, 16 ) // 16x16 GFXDECODE_END /******************************************************************************/ void stadhero_state::stadhero(machine_config &config) { - /* basic machine hardware */ - M68000(config, m_maincpu, 20_MHz_XTAL/2); + // basic machine hardware + M68000(config, m_maincpu, 20_MHz_XTAL / 2); m_maincpu->set_addrmap(AS_PROGRAM, &stadhero_state::main_map); m_maincpu->set_vblank_int("screen", FUNC(stadhero_state::irq5_line_assert)); - M6502(config, m_audiocpu, 24_MHz_XTAL/16); + M6502(config, m_audiocpu, 24_MHz_XTAL / 16); m_audiocpu->set_addrmap(AS_PROGRAM, &stadhero_state::audio_map); - /* video hardware */ + // video hardware screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_RASTER)); screen.set_refresh(HZ_TO_ATTOSECONDS(58)); screen.set_vblank_time(ATTOSECONDS_IN_USEC(529)); @@ -284,19 +393,19 @@ void stadhero_state::stadhero(machine_config &config) DECO_MXC06(config, m_spritegen, 0); - /* sound hardware */ + // sound hardware SPEAKER(config, "mono").front_center(); GENERIC_LATCH_8(config, m_soundlatch, 0); m_soundlatch->data_pending_callback().set_inputline(m_audiocpu, INPUT_LINE_NMI); - ym2203_device &ym1(YM2203(config, "ym1", 24_MHz_XTAL/16)); + ym2203_device &ym1(YM2203(config, "ym1", 24_MHz_XTAL / 16)); ym1.add_route(0, "mono", 0.95); ym1.add_route(1, "mono", 0.95); ym1.add_route(2, "mono", 0.95); ym1.add_route(3, "mono", 0.40); - ym3812_device &ym2(YM3812(config, "ym2", 24_MHz_XTAL/8)); + ym3812_device &ym2(YM3812(config, "ym2", 24_MHz_XTAL / 8)); ym2.irq_handler().set_inputline(m_audiocpu, M6502_IRQ_LINE); ym2.add_route(ALL_OUTPUTS, "mono", 0.80); @@ -307,24 +416,24 @@ void stadhero_state::stadhero(machine_config &config) /******************************************************************************/ ROM_START( stadhero ) - ROM_REGION( 0x20000, "maincpu", 0 ) /* 68000 code */ + ROM_REGION( 0x20000, "maincpu", 0 ) // 68000 ROM_LOAD16_BYTE( "ef15.9a", 0x00000, 0x10000, CRC(bbba364e) SHA1(552096102f402085596635f02096462c6b8e13a7) ) ROM_LOAD16_BYTE( "ef13.4e", 0x00001, 0x10000, CRC(97c6717a) SHA1(6c81260f49a59f70c71f520e51330a6833828684) ) - ROM_REGION( 0x10000, "audiocpu", 0 ) /* 6502 Sound */ + ROM_REGION( 0x10000, "audiocpu", 0 ) // 6502 ROM_LOAD( "ef18.7f", 0x08000, 0x08000, CRC(20fd9668) SHA1(058e34a0ebfc372aaa9230c2bc9164ee2e85e217) ) - ROM_REGION( 0x18000, "gfx1", 0 ) - ROM_LOAD( "ef08.2j", 0x00000, 0x10000, CRC(e84752fe) SHA1(9af2140ddbb44be793ab5b39787bac27f5b1c1f2) ) /* chars */ + ROM_REGION( 0x18000, "chars", 0 ) + ROM_LOAD( "ef08.2j", 0x00000, 0x10000, CRC(e84752fe) SHA1(9af2140ddbb44be793ab5b39787bac27f5b1c1f2) ) ROM_LOAD( "ef09.4j", 0x10000, 0x08000, CRC(2ade874d) SHA1(5c884535214438a4ea79fd262700a346bc12ad81) ) - ROM_REGION( 0x30000, "gfx2", 0 ) - ROM_LOAD( "ef11.13j", 0x00000, 0x10000, CRC(af563e96) SHA1(c88eaff4a1ea133d708f4511bb1dbc99ef066eed) ) /* tiles */ + ROM_REGION( 0x30000, "tiles", 0 ) + ROM_LOAD( "ef11.13j", 0x00000, 0x10000, CRC(af563e96) SHA1(c88eaff4a1ea133d708f4511bb1dbc99ef066eed) ) ROM_LOAD( "ef10.11j", 0x10000, 0x10000, CRC(dca3d599) SHA1(2b97a70065f3065e7fbb54fb53cb120d9e5013b3) ) ROM_LOAD( "ef12.14j", 0x20000, 0x10000, CRC(9a1bf51c) SHA1(e733c193b305496878551fc6eefc21587ba75c82) ) - ROM_REGION( 0x80000, "gfx3", 0 ) - ROM_LOAD( "ef00.2a", 0x00000, 0x10000, CRC(94ed257c) SHA1(caa4a4c8bf3b34d2288e117cfc704cca4c6f913b) ) /* sprites */ + ROM_REGION( 0x80000, "sprites", 0 ) + ROM_LOAD( "ef00.2a", 0x00000, 0x10000, CRC(94ed257c) SHA1(caa4a4c8bf3b34d2288e117cfc704cca4c6f913b) ) ROM_LOAD( "ef01.4a", 0x10000, 0x10000, CRC(6eb9a721) SHA1(0f9dce614e67e57612e3a4ce187f0f9c12b78281) ) ROM_LOAD( "ef02.5a", 0x20000, 0x10000, CRC(850cb771) SHA1(ccb54036191674d76965270a5831fba3e62f47c0) ) ROM_LOAD( "ef03.7a", 0x30000, 0x10000, CRC(24338b96) SHA1(7730486bd0b84ba0a69b5547e348ee0058d4e7f1) ) @@ -333,13 +442,16 @@ ROM_START( stadhero ) ROM_LOAD( "ef06.11a", 0x60000, 0x10000, CRC(9f47848f) SHA1(e23337684c8999483cbd11d3d953b06c34f13069) ) ROM_LOAD( "ef07.12a", 0x70000, 0x10000, CRC(8859f655) SHA1(b3d69c5808b3ba7347ddb7f9693499903e9bfe6b) ) - ROM_REGION( 0x40000, "oki", 0 ) /* ADPCM samples */ + ROM_REGION( 0x40000, "oki", 0 ) // ADPCM samples ROM_LOAD( "ef17.1e", 0x00000, 0x10000, CRC(07c78358) SHA1(ce82b429eec0193fd9665b717336756a514db144) ) ROM_REGION( 0x00200, "proms", 0 ) ROM_LOAD( "ef19.3d", 0x00000, 0x00200, CRC(852ff668) SHA1(d3053b68f86dcc81c3c3be280f75a4acd0b05be2) ) // ? ROM_END +} // anonymous namespace + + /******************************************************************************/ GAME( 1988, stadhero, 0, stadhero, stadhero, stadhero_state, empty_init, ROT0, "Data East Corporation", "Stadium Hero (Japan)", MACHINE_SUPPORTS_SAVE ) diff --git a/src/mame/dataeast/stadhero.h b/src/mame/dataeast/stadhero.h deleted file mode 100644 index efd91b46eba..00000000000 --- a/src/mame/dataeast/stadhero.h +++ /dev/null @@ -1,56 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Bryan McPhail - -#include "machine/gen_latch.h" -#include "decbac06.h" -#include "decmxc06.h" -#include "screen.h" -#include "tilemap.h" - -class stadhero_state : public driver_device -{ -public: - stadhero_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_tilegen(*this, "tilegen"), - m_spritegen(*this, "spritegen"), - m_gfxdecode(*this, "gfxdecode"), - m_soundlatch(*this, "soundlatch"), - m_screen(*this, "screen"), - m_spriteram(*this, "spriteram"), - m_pf1_data(*this, "pf1_data"), - m_coin(*this, "COIN") - { - } - - void stadhero(machine_config &config); - -private: - required_device m_maincpu; - required_device m_audiocpu; - required_device m_tilegen; - required_device m_spritegen; - required_device m_gfxdecode; - required_device m_soundlatch; - required_device m_screen; - - required_shared_ptr m_spriteram; - required_shared_ptr m_pf1_data; - - required_ioport m_coin; - - tilemap_t *m_pf1_tilemap = nullptr; - - void int_ack_w(uint16_t data); - void pf1_data_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); - uint8_t mystery_r(); - - virtual void video_start() override; - - TILE_GET_INFO_MEMBER(get_pf1_tile_info); - uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - void audio_map(address_map &map); - void main_map(address_map &map); -}; diff --git a/src/mame/dataeast/stadhero_v.cpp b/src/mame/dataeast/stadhero_v.cpp deleted file mode 100644 index 8d57bf0747a..00000000000 --- a/src/mame/dataeast/stadhero_v.cpp +++ /dev/null @@ -1,65 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Bryan McPhail -/*************************************************************************** - - stadhero video emulation - Bryan McPhail, mish@tendril.co.uk - -********************************************************************* - - MXC-06 chip to produce sprites, see decmxc06.cpp - BAC-06 chip for background - ??? for text layer - -***************************************************************************/ - -#include "emu.h" -#include "stadhero.h" - - -/******************************************************************************/ - -/******************************************************************************/ - -uint32_t stadhero_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - bool flip = m_tilegen->get_flip_state(); - m_tilegen->set_flip_screen(flip); - m_spritegen->set_flip_screen(flip); - m_pf1_tilemap->set_flip(flip ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0); - - m_tilegen->deco_bac06_pf_draw(screen,bitmap,cliprect,TILEMAP_DRAW_OPAQUE, 0); - m_spritegen->draw_sprites(screen, bitmap, cliprect, m_gfxdecode->gfx(2), m_spriteram, 0x800/2); - m_pf1_tilemap->draw(screen, bitmap, cliprect, 0,0); - return 0; -} - -/******************************************************************************/ - -void stadhero_state::pf1_data_w(offs_t offset, uint16_t data, uint16_t mem_mask) -{ - COMBINE_DATA(&m_pf1_data[offset]); - m_pf1_tilemap->mark_tile_dirty(offset); -} - - -/******************************************************************************/ - -TILE_GET_INFO_MEMBER(stadhero_state::get_pf1_tile_info) -{ - int tile=m_pf1_data[tile_index]; - int color=tile >> 12; - - tile=tile&0xfff; - tileinfo.set(0, - tile, - color, - 0); -} - -void stadhero_state::video_start() -{ - m_pf1_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(stadhero_state::get_pf1_tile_info)), TILEMAP_SCAN_ROWS, 8,8, 32,32); - m_pf1_tilemap->set_transparent_pen(0); -} - -/******************************************************************************/ diff --git a/src/mame/dataeast/tryout.cpp b/src/mame/dataeast/tryout.cpp index cdcf57e6811..49d5a45b257 100644 --- a/src/mame/dataeast/tryout.cpp +++ b/src/mame/dataeast/tryout.cpp @@ -1,5 +1,6 @@ // license:BSD-3-Clause -// copyright-holders:Pierpaolo Prazzoli, Bryan McPhail +// copyright-holders: Pierpaolo Prazzoli, Bryan McPhail + /*************************************************************** Pro Baseball Skill Tryout (JPN Ver.) @@ -20,14 +21,338 @@ $208 strikes count ****************************************************************/ #include "emu.h" -#include "tryout.h" #include "cpu/m6502/m6502.h" #include "machine/gen_latch.h" #include "sound/ymopn.h" + +#include "emupal.h" #include "screen.h" #include "speaker.h" +#include "tilemap.h" + + +// configurable logging +#define LOG_GFXCTRL (1U << 1) + +//#define VERBOSE (LOG_GENERAL | LOG_GFXCTRL) + +#include "logmacro.h" + +#define LOGGFXCTRL(...) LOGMASKED(LOG_GFXCTRL, __VA_ARGS__) + + +namespace { + +class tryout_state : public driver_device +{ +public: + tryout_state(const machine_config &mconfig, device_type type, const char *tag) : + driver_device(mconfig, type, tag), + m_maincpu(*this, "maincpu"), + m_audiocpu(*this, "audiocpu"), + m_gfxdecode(*this, "gfxdecode"), + m_palette(*this, "palette"), + m_videoram(*this, "videoram"), + m_spriteram(*this, "spriteram%u", 1U), + m_gfx_control(*this, "gfx_control"), + m_vram(*this, "vram", 8 * 0x800, ENDIANNESS_LITTLE), + m_vram_gfx(*this, "vram_gfx", 0x6000, ENDIANNESS_LITTLE), + m_rombank(*this, "rombank") + { } + + void tryout(machine_config &config); + + DECLARE_INPUT_CHANGED_MEMBER(coin_inserted); + +protected: + virtual void machine_start() override; + virtual void video_start() override; + +private: + required_device m_maincpu; + required_device m_audiocpu; + required_device m_gfxdecode; + required_device m_palette; + + required_shared_ptr m_videoram; + required_shared_ptr_array m_spriteram; + required_shared_ptr m_gfx_control; + memory_share_creator m_vram; + memory_share_creator m_vram_gfx; + + required_memory_bank m_rombank; + + tilemap_t *m_fg_tilemap = nullptr; + tilemap_t *m_bg_tilemap = nullptr; + uint8_t m_vram_bank = 0; + + void nmi_ack_w(uint8_t data); + void sound_irq_ack_w(uint8_t data); + void bankswitch_w(uint8_t data); + uint8_t vram_r(offs_t offset); + void videoram_w(offs_t offset, uint8_t data); + void vram_w(offs_t offset, uint8_t data); + void vram_bankswitch_w(uint8_t data); + void flipscreen_w(uint8_t data); + + TILE_GET_INFO_MEMBER(get_fg_tile_info); + TILE_GET_INFO_MEMBER(get_bg_tile_info); + TILEMAP_MAPPER_MEMBER(get_fg_memory_offset); + TILEMAP_MAPPER_MEMBER(get_bg_memory_offset); + + void palette(palette_device &palette) const; + + uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); + void draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect); + + void main_cpu(address_map &map); + void sound_cpu(address_map &map); +}; + + +// video + +void tryout_state::palette(palette_device &palette) const +{ + uint8_t const *const color_prom = memregion("proms")->base(); + + for (int i = 0; i < palette.entries(); i++) + { + int bit0, bit1, bit2; + + // red component + bit0 = BIT(color_prom[i], 0); + bit1 = BIT(color_prom[i], 1); + bit2 = BIT(color_prom[i], 2); + int const r = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; + // green component + bit0 = BIT(color_prom[i], 3); + bit1 = BIT(color_prom[i], 4); + bit2 = BIT(color_prom[i], 5); + int const g = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; + // blue component + bit0 = 0; + bit1 = BIT(color_prom[i], 6); + bit2 = BIT(color_prom[i], 7); + int const b = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; + + palette.set_pen_color(i, rgb_t(r, g, b)); + } +} + +TILE_GET_INFO_MEMBER(tryout_state::get_fg_tile_info) +{ + int code = m_videoram[tile_index]; + int const attr = m_videoram[tile_index + 0x400]; + code |= ((attr & 0x03) << 8); + int const color = ((attr & 0x4) >> 2) + 6; + tileinfo.set(0, code, color, 0); +} + +TILE_GET_INFO_MEMBER(tryout_state::get_bg_tile_info) +{ + tileinfo.set(2, m_vram[tile_index] & 0x7f, 2, 0); +} + +uint8_t tryout_state::vram_r(offs_t offset) +{ + return m_vram[offset]; // debug only +} + +void tryout_state::videoram_w(offs_t offset, uint8_t data) +{ + m_videoram[offset] = data; + m_fg_tilemap->mark_tile_dirty(offset & 0x3ff); +} + +void tryout_state::vram_w(offs_t offset, uint8_t data) +{ + /* There are eight banks of vram - in bank 0 the first 0x400 bytes + are reserved for the tilemap. In banks 2, 4 and 6 the game never + writes to the first 0x400 bytes - I suspect it's either + unused, or it actually mirrors the tilemap ram from the first bank. + + The rest of the vram is tile data which has the bitplanes arranged + in a very strange format. For MAME's sake we reformat this on + the fly for easier gfx decode. + + Bit 0 of the bank register seems special - it's kept low when uploading + gfx data and then set high from that point onwards. + + */ + const uint8_t bank = (m_vram_bank >> 1) & 0x7; + + + if ((bank == 0 || bank == 2 || bank == 4 || bank == 6) && (offset & 0x7ff) < 0x400) + { + int const newoff = offset & 0x3ff; + + m_vram[newoff] = data; + m_bg_tilemap->mark_tile_dirty(newoff); + return; + } + + /* + Bit planes for tiles are arranged as follows within vram (split into high/low nibbles): + 0x0400 (0) + 0x0400 (4) + 0x0800(0) - tiles 0x00 to 0x0f + 0x0800 (4) + 0x0c00 (0) + 0x0c00(4) - tiles 0x10 to 0x1f + 0x1400 (0) + 0x1400 (4) + 0x1800(0) - tiles 0x20 to 0x2f + 0x1800 (4) + 0x1c00 (0) + 0x1c00(4) - tiles 0x30 to 0x3f + etc. + */ + + offset = (offset & 0x7ff) | (bank << 11); + m_vram[offset] = data; + + switch (offset & 0x1c00) + { + case 0x0400: + m_vram_gfx[(offset & 0x3ff) + 0x0000 + ((offset & 0x2000) >> 1)] = (~data & 0xf); + m_vram_gfx[(offset & 0x3ff) + 0x2000 + ((offset & 0x2000) >> 1)] = (~data & 0xf0) >> 4; + break; + case 0x0800: + m_vram_gfx[(offset & 0x3ff) + 0x4000 + ((offset & 0x2000) >> 1)] = (~data & 0xf); + m_vram_gfx[(offset & 0x3ff) + 0x4400 + ((offset & 0x2000) >> 1)] = (~data & 0xf0) >> 4; + break; + case 0x0c00: + m_vram_gfx[(offset & 0x3ff) + 0x0400 + ((offset & 0x2000) >> 1)] = (~data & 0xf); + m_vram_gfx[(offset & 0x3ff) + 0x2400 + ((offset & 0x2000) >> 1)] = (~data & 0xf0) >> 4; + break; + case 0x1400: + m_vram_gfx[(offset & 0x3ff) + 0x0800 + ((offset & 0x2000) >> 1)] = (~data & 0xf); + m_vram_gfx[(offset & 0x3ff) + 0x2800 + ((offset & 0x2000) >> 1)] = (~data & 0xf0) >> 4; + break; + case 0x1800: + m_vram_gfx[(offset & 0x3ff) + 0x4800 + ((offset & 0x2000) >> 1)] = (~data & 0xf); + m_vram_gfx[(offset & 0x3ff) + 0x4c00 + ((offset & 0x2000) >> 1)] = (~data & 0xf0) >> 4; + break; + case 0x1c00: + m_vram_gfx[(offset & 0x3ff) + 0x0c00 + ((offset & 0x2000) >> 1)] = (~data & 0xf); + m_vram_gfx[(offset & 0x3ff) + 0x2c00 + ((offset & 0x2000) >> 1)] = (~data & 0xf0) >> 4; + break; + } + + m_gfxdecode->gfx(2)->mark_dirty((offset - 0x400 / 64) & 0x7f); +} + +void tryout_state::vram_bankswitch_w(uint8_t data) +{ + m_vram_bank = data; +} + +void tryout_state::flipscreen_w(uint8_t data) +{ + flip_screen_set(data & 1); +} + +TILEMAP_MAPPER_MEMBER(tryout_state::get_fg_memory_offset) +{ + return (row ^ 0x1f) + (col << 5); +} + +TILEMAP_MAPPER_MEMBER(tryout_state::get_bg_memory_offset) +{ + int a; +// if (col&0x20) +// a= (7 - (row & 7)) + ((0x8 - (row & 0x8)) << 4) + ((col & 0xf) << 3) + (( ( 0x10 - (col & 0x10) ) ) << 4) + ((( (col & 0x20))) << 4); +// else + a= (7 - (row & 7)) + ((0x8 - (row & 0x8)) << 4) + ((col & 0xf) << 3) + ((col & 0x10) << 4) + ((col & 0x20) << 4); + +// osd_printf_debug("%d %d -> %d\n", col, row, a); + return a; +} + +void tryout_state::video_start() +{ + m_fg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(tryout_state::get_fg_tile_info)), tilemap_mapper_delegate(*this, FUNC(tryout_state::get_fg_memory_offset)), 8, 8, 32,32); + m_bg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(tryout_state::get_bg_tile_info)), tilemap_mapper_delegate(*this, FUNC(tryout_state::get_bg_memory_offset)), 16,16, 64,16); + + m_fg_tilemap->set_transparent_pen(0); + + save_item(NAME(m_vram_bank)); +} + +void tryout_state::draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect) +{ + for (int offs = 0; offs < 0x7f; offs += 4) + { + if (!(m_spriteram[0][offs] & 1)) + continue; + + int const sprite = m_spriteram[0][offs + 1] + ((m_spriteram[1][offs] & 7) << 8); + int x = m_spriteram[0][offs + 3] - 3; + int y = m_spriteram[0][offs + 2]; + int const color = 0;//(m_spriteram[0][offs] & 8) >> 3; + int fx = (m_spriteram[0][offs] & 8) >> 3; + int fy = 0; + int inc = 16; + + if (flip_screen()) + { + x = 240 - x; + fx = !fx; + + y = 240 - y; + fy = !fy; + + inc = -inc; + } + + // Double Height + if (m_spriteram[0][offs] & 0x10) + { + m_gfxdecode->gfx(1)->transpen(bitmap, cliprect, + sprite, + color, fx, fy, x, y + inc, 0); + + m_gfxdecode->gfx(1)->transpen(bitmap, cliprect, + sprite + 1, + color, fx, fy, x, y, 0); + } + else + { + m_gfxdecode->gfx(1)->transpen(bitmap, cliprect, + sprite, + color, fx, fy, x, y, 0); + } + } +} + +uint32_t tryout_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) +{ + if (!flip_screen()) + m_fg_tilemap->set_scrollx(0, 16); // Assumed hard-wired + else + m_fg_tilemap->set_scrollx(0, -8); // Assumed hard-wired + + int scrollx = m_gfx_control[1] + ((m_gfx_control[0] & 1) << 8) + ((m_gfx_control[0] & 4) << 7) - ((m_gfx_control[0] & 2) ? 0 : 0x100); + + // wrap-around + if (m_gfx_control[1] == 0) { scrollx += 0x100; } + + m_bg_tilemap->set_scrollx(0, scrollx + 2); // why +2? hard-wired? + m_bg_tilemap->set_scrolly(0, -m_gfx_control[2]); + + if (!(m_gfx_control[0] & 0x8)) // screen disable + { + // TODO: Color might be different, needs a video from an original PCB. + bitmap.fill(m_palette->pen(0x10), cliprect); + } + else + { + m_bg_tilemap->draw(screen, bitmap, cliprect, 0, 0); + m_fg_tilemap->draw(screen, bitmap, cliprect, 0, 0); + draw_sprites(bitmap, cliprect); + } + + LOGGFXCTRL("%02x %02x %02x %02x", m_gfx_control[0], m_gfx_control[1], m_gfx_control[2], scrollx); + return 0; +} + + +// machine void tryout_state::nmi_ack_w(uint8_t data) { @@ -180,18 +505,18 @@ static const gfx_layout spritelayout = }; static GFXDECODE_START( gfx_tryout ) - GFXDECODE_ENTRY( "gfx1", 0, charlayout, 0, 8 ) - GFXDECODE_ENTRY( "gfx2", 0, spritelayout, 0, 4 ) - GFXDECODE_RAM( "vram_gfx", 0, vramlayout, 0, 4 ) + GFXDECODE_ENTRY( "chars", 0, charlayout, 0, 8 ) + GFXDECODE_ENTRY( "sprites", 0, spritelayout, 0, 4 ) + GFXDECODE_RAM( "vram_gfx", 0, vramlayout, 0, 4 ) GFXDECODE_END void tryout_state::tryout(machine_config &config) { // basic machine hardware - M6502(config, m_maincpu, 2000000); // ? + M6502(config, m_maincpu, 2'000'000); // ? m_maincpu->set_addrmap(AS_PROGRAM, &tryout_state::main_cpu); - M6502(config, m_audiocpu, 1500000); // ? + M6502(config, m_audiocpu, 1'500'000); // ? m_audiocpu->set_addrmap(AS_PROGRAM, &tryout_state::sound_cpu); m_audiocpu->set_periodic_int(FUNC(tryout_state::nmi_line_pulse), attotime::from_hz(1000)); // controls BGM tempo, 1000 is an hand-tuned value to match a side-by-side video @@ -213,7 +538,7 @@ void tryout_state::tryout(machine_config &config) generic_latch_8_device &soundlatch(GENERIC_LATCH_8(config, "soundlatch")); soundlatch.data_pending_callback().set_inputline(m_audiocpu, INPUT_LINE_IRQ0); - YM2203(config, "ymsnd", 1500000).add_route(ALL_OUTPUTS, "mono", 0.50); + YM2203(config, "ymsnd", 1'500'000).add_route(ALL_OUTPUTS, "mono", 0.50); } ROM_START( tryout ) @@ -225,10 +550,10 @@ ROM_START( tryout ) ROM_REGION( 0x10000, "audiocpu", 0 ) ROM_LOAD( "ch00-1.bin", 0x0c000, 0x4000, CRC(8b33d968) SHA1(cf44529e5577d09978b87dc2bbe1415babbf36a0) ) - ROM_REGION( 0x4000, "gfx1", 0 ) + ROM_REGION( 0x4000, "chars", 0 ) ROM_LOAD( "ch13.bin", 0x00000, 0x4000, CRC(a9619c58) SHA1(92528b1c4afc95394ac8cad5b37f23da0c6a5310) ) - ROM_REGION( 0x24000, "gfx2", 0 ) + ROM_REGION( 0x24000, "sprites", 0 ) ROM_LOAD( "ch09.bin", 0x00000, 0x4000, CRC(9c5e275b) SHA1(83b29996573d85c73bb4b63086c7a624fad19bde) ) ROM_LOAD( "ch08.bin", 0x04000, 0x4000, CRC(88396abb) SHA1(2865a265ddfb91c2ad2770da5e0d84a544f3c419) ) ROM_LOAD( "ch07.bin", 0x08000, 0x4000, CRC(901b5f5e) SHA1(f749b5ec0c51c66655798e8a37c887870370991e) ) @@ -243,4 +568,7 @@ ROM_START( tryout ) ROM_LOAD( "ch14.bpr", 0x00000, 0x0020, CRC(8ce19925) SHA1(12f8f6022f1148b6ba1d019a34247452637063a7) ) ROM_END +} // anonymous namespace + + GAME( 1985, tryout, 0, tryout, tryout, tryout_state, empty_init, ROT90, "Data East Corporation", "Pro Baseball Skill Tryout (Japan)", MACHINE_SUPPORTS_SAVE ) diff --git a/src/mame/dataeast/tryout.h b/src/mame/dataeast/tryout.h deleted file mode 100644 index 6e537ea26f4..00000000000 --- a/src/mame/dataeast/tryout.h +++ /dev/null @@ -1,77 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Pierpaolo Prazzoli, Bryan McPhail -#ifndef MAME_INCLUDES_TRYOUT_H -#define MAME_INCLUDES_TRYOUT_H - -#pragma once - -#include "emupal.h" -#include "tilemap.h" - -class tryout_state : public driver_device -{ -public: - tryout_state(const machine_config &mconfig, device_type type, const char *tag) : - driver_device(mconfig, type, tag), - m_maincpu(*this, "maincpu"), - m_audiocpu(*this, "audiocpu"), - m_gfxdecode(*this, "gfxdecode"), - m_palette(*this, "palette"), - m_videoram(*this, "videoram"), - m_spriteram(*this, "spriteram%u", 1U), - m_gfx_control(*this, "gfx_control"), - m_vram(*this, "vram", 8 * 0x800, ENDIANNESS_LITTLE), - m_vram_gfx(*this, "vram_gfx", 0x6000, ENDIANNESS_LITTLE), - m_rombank(*this, "rombank") - { } - - void tryout(machine_config &config); - - DECLARE_INPUT_CHANGED_MEMBER(coin_inserted); - -protected: - virtual void machine_start() override; - virtual void video_start() override; - -private: - required_device m_maincpu; - required_device m_audiocpu; - required_device m_gfxdecode; - required_device m_palette; - - required_shared_ptr m_videoram; - required_shared_ptr_array m_spriteram; - required_shared_ptr m_gfx_control; - memory_share_creator m_vram; - memory_share_creator m_vram_gfx; - - required_memory_bank m_rombank; - - tilemap_t *m_fg_tilemap = nullptr; - tilemap_t *m_bg_tilemap = nullptr; - uint8_t m_vram_bank = 0; - - void nmi_ack_w(uint8_t data); - void sound_irq_ack_w(uint8_t data); - void bankswitch_w(uint8_t data); - uint8_t vram_r(offs_t offset); - void videoram_w(offs_t offset, uint8_t data); - void vram_w(offs_t offset, uint8_t data); - void vram_bankswitch_w(uint8_t data); - void flipscreen_w(uint8_t data); - - TILE_GET_INFO_MEMBER(get_fg_tile_info); - TILE_GET_INFO_MEMBER(get_bg_tile_info); - TILEMAP_MAPPER_MEMBER(get_fg_memory_offset); - TILEMAP_MAPPER_MEMBER(get_bg_memory_offset); - - void palette(palette_device &palette) const; - - uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - void draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect); - - void main_cpu(address_map &map); - void sound_cpu(address_map &map); -}; - -#endif // MAME_INCLUDES_TRYOUT_H diff --git a/src/mame/dataeast/tryout_v.cpp b/src/mame/dataeast/tryout_v.cpp deleted file mode 100644 index 4c2a9ce8295..00000000000 --- a/src/mame/dataeast/tryout_v.cpp +++ /dev/null @@ -1,252 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Pierpaolo Prazzoli, Bryan McPhail -/*************************************************************** - - Pro Yakyuu Nyuudan Test Tryout (JPN Ver.) - video hardware emulation - -****************************************************************/ - -#include "emu.h" -#include "tryout.h" - - -void tryout_state::palette(palette_device &palette) const -{ - uint8_t const *const color_prom = memregion("proms")->base(); - - for (int i = 0; i < palette.entries(); i++) - { - int bit0, bit1, bit2; - - // red component - bit0 = BIT(color_prom[i], 0); - bit1 = BIT(color_prom[i], 1); - bit2 = BIT(color_prom[i], 2); - int const r = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; - // green component - bit0 = BIT(color_prom[i], 3); - bit1 = BIT(color_prom[i], 4); - bit2 = BIT(color_prom[i], 5); - int const g = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; - // blue component - bit0 = 0; - bit1 = BIT(color_prom[i], 6); - bit2 = BIT(color_prom[i], 7); - int const b = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; - - palette.set_pen_color(i, rgb_t(r, g, b)); - } -} - -TILE_GET_INFO_MEMBER(tryout_state::get_fg_tile_info) -{ - int code = m_videoram[tile_index]; - int attr = m_videoram[tile_index + 0x400]; - code |= ((attr & 0x03) << 8); - int color = ((attr & 0x4) >> 2) + 6; - - tileinfo.set(0, code, color, 0); -} - -TILE_GET_INFO_MEMBER(tryout_state::get_bg_tile_info) -{ - tileinfo.set(2, m_vram[tile_index] & 0x7f, 2, 0); -} - -uint8_t tryout_state::vram_r(offs_t offset) -{ - return m_vram[offset]; // debug only -} - -void tryout_state::videoram_w(offs_t offset, uint8_t data) -{ - m_videoram[offset] = data; - m_fg_tilemap->mark_tile_dirty(offset & 0x3ff); -} - -void tryout_state::vram_w(offs_t offset, uint8_t data) -{ - /* There are eight banks of vram - in bank 0 the first 0x400 bytes - are reserved for the tilemap. In banks 2, 4 and 6 the game never - writes to the first 0x400 bytes - I suspect it's either - unused, or it actually mirrors the tilemap ram from the first bank. - - The rest of the vram is tile data which has the bitplanes arranged - in a very strange format. For MAME's sake we reformat this on - the fly for easier gfx decode. - - Bit 0 of the bank register seems special - it's kept low when uploading - gfx data and then set high from that point onwards. - - */ - const uint8_t bank = (m_vram_bank >> 1) & 0x7; - - - if ((bank == 0 || bank == 2 || bank == 4 || bank == 6) && (offset & 0x7ff) < 0x400) - { - int newoff = offset & 0x3ff; - - m_vram[newoff] = data; - m_bg_tilemap->mark_tile_dirty(newoff); - return; - } - - /* - Bit planes for tiles are arranged as follows within vram (split into high/low nibbles): - 0x0400 (0) + 0x0400 (4) + 0x0800(0) - tiles 0x00 to 0x0f - 0x0800 (4) + 0x0c00 (0) + 0x0c00(4) - tiles 0x10 to 0x1f - 0x1400 (0) + 0x1400 (4) + 0x1800(0) - tiles 0x20 to 0x2f - 0x1800 (4) + 0x1c00 (0) + 0x1c00(4) - tiles 0x30 to 0x3f - etc. - */ - - offset = (offset & 0x7ff) | (bank << 11); - m_vram[offset] = data; - - switch (offset & 0x1c00) - { - case 0x0400: - m_vram_gfx[(offset & 0x3ff) + 0x0000 + ((offset & 0x2000) >> 1)] = (~data & 0xf); - m_vram_gfx[(offset & 0x3ff) + 0x2000 + ((offset & 0x2000) >> 1)] = (~data & 0xf0) >> 4; - break; - case 0x0800: - m_vram_gfx[(offset & 0x3ff) + 0x4000 + ((offset & 0x2000) >> 1)] = (~data & 0xf); - m_vram_gfx[(offset & 0x3ff) + 0x4400 + ((offset & 0x2000) >> 1)] = (~data & 0xf0) >> 4; - break; - case 0x0c00: - m_vram_gfx[(offset & 0x3ff) + 0x0400 + ((offset & 0x2000) >> 1)] = (~data & 0xf); - m_vram_gfx[(offset & 0x3ff) + 0x2400 + ((offset & 0x2000) >> 1)] = (~data & 0xf0) >> 4; - break; - case 0x1400: - m_vram_gfx[(offset & 0x3ff) + 0x0800 + ((offset & 0x2000) >> 1)] = (~data & 0xf); - m_vram_gfx[(offset & 0x3ff) + 0x2800 + ((offset & 0x2000) >> 1)] = (~data & 0xf0) >> 4; - break; - case 0x1800: - m_vram_gfx[(offset & 0x3ff) + 0x4800 + ((offset & 0x2000) >> 1)] = (~data & 0xf); - m_vram_gfx[(offset & 0x3ff) + 0x4c00 + ((offset & 0x2000) >> 1)] = (~data & 0xf0) >> 4; - break; - case 0x1c00: - m_vram_gfx[(offset & 0x3ff) + 0x0c00 + ((offset & 0x2000) >> 1)] = (~data & 0xf); - m_vram_gfx[(offset & 0x3ff) + 0x2c00 + ((offset & 0x2000) >> 1)] = (~data & 0xf0) >> 4; - break; - } - - m_gfxdecode->gfx(2)->mark_dirty((offset - 0x400 / 64) & 0x7f); -} - -void tryout_state::vram_bankswitch_w(uint8_t data) -{ - m_vram_bank = data; -} - -void tryout_state::flipscreen_w(uint8_t data) -{ - flip_screen_set(data & 1); -} - -TILEMAP_MAPPER_MEMBER(tryout_state::get_fg_memory_offset) -{ - return (row ^ 0x1f) + (col << 5); -} - -TILEMAP_MAPPER_MEMBER(tryout_state::get_bg_memory_offset) -{ - int a; -// if (col&0x20) -// a= (7 - (row & 7)) + ((0x8 - (row & 0x8)) << 4) + ((col & 0xf) << 3) + (( ( 0x10 - (col & 0x10) ) ) << 4) + ((( (col & 0x20))) << 4); -// else - a= (7 - (row & 7)) + ((0x8 - (row & 0x8)) << 4) + ((col & 0xf) << 3) + ((col & 0x10) << 4) + ((col & 0x20) << 4); - -// osd_printf_debug("%d %d -> %d\n", col, row, a); - return a; -} - -void tryout_state::video_start() -{ - m_fg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(tryout_state::get_fg_tile_info)), tilemap_mapper_delegate(*this, FUNC(tryout_state::get_fg_memory_offset)), 8, 8, 32,32); - m_bg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(tryout_state::get_bg_tile_info)), tilemap_mapper_delegate(*this, FUNC(tryout_state::get_bg_memory_offset)), 16,16, 64,16); - - m_fg_tilemap->set_transparent_pen(0); - - save_item(NAME(m_vram_bank)); -} - -void tryout_state::draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect) -{ - for (int offs = 0; offs < 0x7f; offs += 4) - { - if (!(m_spriteram[0][offs] & 1)) - continue; - - int sprite = m_spriteram[0][offs + 1] + ((m_spriteram[1][offs] & 7) << 8); - int x = m_spriteram[0][offs + 3] - 3; - int y = m_spriteram[0][offs + 2]; - int color = 0;//(m_spriteram[0][offs] & 8) >> 3; - int fx = (m_spriteram[0][offs] & 8) >> 3; - int fy = 0; - int inc = 16; - - if (flip_screen()) - { - x = 240 - x; - fx = !fx; - - y = 240 - y; - fy = !fy; - - inc = -inc; - } - - // Double Height - if(m_spriteram[0][offs] & 0x10) - { - m_gfxdecode->gfx(1)->transpen(bitmap, cliprect, - sprite, - color, fx, fy, x, y + inc, 0); - - m_gfxdecode->gfx(1)->transpen(bitmap, cliprect, - sprite + 1, - color, fx, fy, x, y, 0); - } - else - { - m_gfxdecode->gfx(1)->transpen(bitmap, cliprect, - sprite, - color, fx, fy, x, y, 0); - } - } -} - -uint32_t tryout_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - int scrollx = 0; - - if (!flip_screen()) - m_fg_tilemap->set_scrollx(0, 16); // Assumed hard-wired - else - m_fg_tilemap->set_scrollx(0, -8); // Assumed hard-wired - - scrollx = m_gfx_control[1] + ((m_gfx_control[0] & 1) << 8) + ((m_gfx_control[0] & 4) << 7) - ((m_gfx_control[0] & 2) ? 0 : 0x100); - - // wrap-around - if (m_gfx_control[1] == 0) { scrollx += 0x100; } - - m_bg_tilemap->set_scrollx(0, scrollx + 2); // why +2? hard-wired? - m_bg_tilemap->set_scrolly(0, -m_gfx_control[2]); - - if(!(m_gfx_control[0] & 0x8)) // screen disable - { - // TODO: Color might be different, needs a video from an original PCB. - bitmap.fill(m_palette->pen(0x10), cliprect); - } - else - { - m_bg_tilemap->draw(screen, bitmap, cliprect, 0, 0); - m_fg_tilemap->draw(screen, bitmap, cliprect, 0, 0); - draw_sprites(bitmap, cliprect); - } - -// popmessage("%02x %02x %02x %02x", m_gfx_control[0], m_gfx_control[1], m_gfx_control[2], scrollx); - return 0; -} -- cgit v1.2.3