diff --git a/scripts/target/mame/arcade.lua b/scripts/target/mame/arcade.lua index 705c4c92aa9..2ff01e51362 100644 --- a/scripts/target/mame/arcade.lua +++ b/scripts/target/mame/arcade.lua @@ -1743,14 +1743,15 @@ files { MAME_DIR .. "src/mame/includes/fantland.h", MAME_DIR .. "src/mame/video/fantland.cpp", MAME_DIR .. "src/mame/drivers/mwarr.cpp", + MAME_DIR .. "src/mame/drivers/stlforce.cpp", + MAME_DIR .. "src/mame/includes/stlforce.h", + MAME_DIR .. "src/mame/video/edevices.cpp", + MAME_DIR .. "src/mame/video/edevices.h", MAME_DIR .. "src/mame/drivers/mugsmash.cpp", MAME_DIR .. "src/mame/includes/mugsmash.h", MAME_DIR .. "src/mame/video/mugsmash.cpp", MAME_DIR .. "src/mame/drivers/ppmast93.cpp", MAME_DIR .. "src/mame/drivers/pzletime.cpp", - MAME_DIR .. "src/mame/drivers/stlforce.cpp", - MAME_DIR .. "src/mame/includes/stlforce.h", - MAME_DIR .. "src/mame/video/stlforce.cpp", MAME_DIR .. "src/mame/drivers/twins.cpp", } diff --git a/src/mame/drivers/mwarr.cpp b/src/mame/drivers/mwarr.cpp index e86f4c97f15..7cacdddc10a 100644 --- a/src/mame/drivers/mwarr.cpp +++ b/src/mame/drivers/mwarr.cpp @@ -46,7 +46,7 @@ Notes: #include "emupal.h" #include "screen.h" #include "speaker.h" - +#include "video/edevices.h" #define MASTER_CLOCK XTAL(12'000'000) #define SOUND_CLOCK XTAL(45'000'000) @@ -55,160 +55,50 @@ Notes: class mwarr_state : public driver_device { public: - mwarr_state(const machine_config &mconfig, device_type type, const char *tag) - : driver_device(mconfig, type, tag), - m_bg_videoram(*this, "bg_videoram"), - m_mlow_videoram(*this, "mlow_videoram"), - m_mhigh_videoram(*this, "mhigh_videoram"), - m_tx_videoram(*this, "tx_videoram"), - m_bg_scrollram(*this, "bg_scrollram"), - m_mlow_scrollram(*this, "mlow_scrollram"), - m_mhigh_scrollram(*this, "mhigh_scrollram"), - m_vidattrram(*this, "vidattrram"), - m_spriteram(*this, "spriteram"), + mwarr_state(const machine_config &mconfig, device_type type, const char *tag) : + driver_device(mconfig, type, tag), m_mwarr_ram(*this, "mwarr_ram"), m_okibank(*this, "okibank"), m_maincpu(*this, "maincpu"), + m_video(*this, "edevices_vid"), m_gfxdecode(*this, "gfxdecode"), - m_palette(*this, "palette") { } + m_palette(*this, "palette") + { } void mwarr(machine_config &config); private: /* memory pointers */ - required_shared_ptr m_bg_videoram; - required_shared_ptr m_mlow_videoram; - required_shared_ptr m_mhigh_videoram; - required_shared_ptr m_tx_videoram; - required_shared_ptr m_bg_scrollram; - required_shared_ptr m_mlow_scrollram; - required_shared_ptr m_mhigh_scrollram; - required_shared_ptr m_vidattrram; - required_shared_ptr m_spriteram; required_shared_ptr m_mwarr_ram; required_memory_bank m_okibank; - /* video-related */ - tilemap_t *m_bg_tilemap; - tilemap_t *m_mlow_tilemap; - tilemap_t *m_mhigh_tilemap; - tilemap_t *m_tx_tilemap; - - /* misc */ - int m_which; - - uint16_t m_sprites_buffer[0x800]; - DECLARE_WRITE16_MEMBER(bg_videoram_w); - DECLARE_WRITE16_MEMBER(mlow_videoram_w); - DECLARE_WRITE16_MEMBER(mhigh_videoram_w); - DECLARE_WRITE16_MEMBER(tx_videoram_w); - DECLARE_WRITE16_MEMBER(sprites_commands_w); DECLARE_WRITE16_MEMBER(mwarr_brightness_w); + DECLARE_WRITE16_MEMBER(oki1_bank_w); - TILE_GET_INFO_MEMBER(get_bg_tile_info); - TILE_GET_INFO_MEMBER(get_mlow_tile_info); - TILE_GET_INFO_MEMBER(get_mhigh_tile_info); - TILE_GET_INFO_MEMBER(get_tx_tile_info); + virtual void machine_start() override; virtual void machine_reset() override; - virtual void video_start() override; uint32_t screen_update_mwarr(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - void draw_sprites( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect ); required_device m_maincpu; + required_device m_video; required_device m_gfxdecode; required_device m_palette; void mwarr_map(address_map &map); void oki2_map(address_map &map); }; - /************************************* * * Memory handlers * *************************************/ -WRITE16_MEMBER(mwarr_state::bg_videoram_w) -{ - COMBINE_DATA(&m_bg_videoram[offset]); - m_bg_tilemap->mark_tile_dirty(offset); -} - -WRITE16_MEMBER(mwarr_state::mlow_videoram_w) -{ - COMBINE_DATA(&m_mlow_videoram[offset]); - m_mlow_tilemap->mark_tile_dirty(offset); -} - -WRITE16_MEMBER(mwarr_state::mhigh_videoram_w) -{ - COMBINE_DATA(&m_mhigh_videoram[offset]); - m_mhigh_tilemap->mark_tile_dirty(offset); -} - -WRITE16_MEMBER(mwarr_state::tx_videoram_w) -{ - COMBINE_DATA(&m_tx_videoram[offset]); - m_tx_tilemap->mark_tile_dirty(offset); -} - WRITE16_MEMBER(mwarr_state::oki1_bank_w) { m_okibank->set_entry(data & 3); } -WRITE16_MEMBER(mwarr_state::sprites_commands_w) -{ - if (m_which) - { - int i; - - switch (data) - { - case 0: - /* clear sprites on screen */ - for (i = 0; i < 0x800; i++) - { - m_sprites_buffer[i] = 0; - } - m_which = 0; - break; - - default: - logerror("used unknown sprites command %02X\n",data); - case 0xf: - /* refresh sprites on screen */ - for (i = 0; i < 0x800; i++) - { - m_sprites_buffer[i] = m_spriteram[i]; - } - break; - - case 0xd: - /* keep sprites on screen */ - break; - } - } - - m_which ^= 1; -} - -WRITE16_MEMBER(mwarr_state::mwarr_brightness_w) -{ - int i; - double brightness; - - COMBINE_DATA(&m_mwarr_ram[0x14 / 2]); - - brightness = (double)(data & 0xff); - for (i = 0; i < 0x800; i++) - { - m_palette->set_pen_contrast(i, brightness/255); - } -} - - /************************************* * * Address maps @@ -218,23 +108,24 @@ WRITE16_MEMBER(mwarr_state::mwarr_brightness_w) void mwarr_state::mwarr_map(address_map &map) { map(0x000000, 0x0fffff).rom(); - map(0x100000, 0x1007ff).ram().w(FUNC(mwarr_state::bg_videoram_w)).share("bg_videoram"); - map(0x100800, 0x100fff).ram().w(FUNC(mwarr_state::mlow_videoram_w)).share("mlow_videoram"); - map(0x101000, 0x1017ff).ram().w(FUNC(mwarr_state::mhigh_videoram_w)).share("mhigh_videoram"); - map(0x101800, 0x1027ff).ram().w(FUNC(mwarr_state::tx_videoram_w)).share("tx_videoram"); + map(0x100000, 0x1007ff).ram().w(m_video, FUNC(edevices_device::bg_videoram_w)).share("bg_videoram"); + map(0x100800, 0x100fff).ram().w(m_video, FUNC(edevices_device::mlow_videoram_w)).share("mlow_videoram"); + map(0x101000, 0x1017ff).ram().w(m_video, FUNC(edevices_device::mhigh_videoram_w)).share("mhigh_videoram"); + map(0x101800, 0x1027ff).ram().w(m_video, FUNC(edevices_device::tx_videoram_w)).share("tx_videoram"); map(0x103000, 0x1033ff).ram().share("bg_scrollram"); map(0x103400, 0x1037ff).ram().share("mlow_scrollram"); map(0x103800, 0x103bff).ram().share("mhigh_scrollram"); map(0x103c00, 0x103fff).ram().share("vidattrram"); map(0x104000, 0x104fff).ram().w(m_palette, FUNC(palette_device::write16)).share("palette"); - map(0x108000, 0x108fff).ram().share("spriteram"); + map(0x108000, 0x1087ff).ram().share("spriteram"); + map(0x108800, 0x108fff).ram(); map(0x110000, 0x11ffff).ram().share("mwarr_ram"); map(0x110000, 0x110001).portr("P1_P2"); map(0x110002, 0x110003).portr("SYSTEM"); map(0x110004, 0x110005).portr("DSW"); map(0x110010, 0x110011).w(FUNC(mwarr_state::oki1_bank_w)); map(0x110014, 0x110015).w(FUNC(mwarr_state::mwarr_brightness_w)); - map(0x110016, 0x110017).w(FUNC(mwarr_state::sprites_commands_w)); + map(0x110016, 0x110017).w(m_video, FUNC(edevices_device::sprites_commands_w)); map(0x180001, 0x180001).rw("oki1", FUNC(okim6295_device::read), FUNC(okim6295_device::write)); map(0x190001, 0x190001).rw("oki2", FUNC(okim6295_device::read), FUNC(okim6295_device::write)); } @@ -247,7 +138,6 @@ void mwarr_state::oki2_map(address_map &map) map(0x20000, 0x3ffff).bankr("okibank"); } - /************************************* * * Input ports @@ -277,7 +167,7 @@ static INPUT_PORTS_START( mwarr ) PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_CUSTOM ) PORT_VBLANK("screen") - PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_CUSTOM ) // otherwise it doesn't boot + PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_CUSTOM ) // otherwise it doesn't boot (is service switch on stlforce) PORT_BIT( 0xfff0, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_START("DSW") @@ -381,175 +271,24 @@ GFXDECODE_END * Video emulation * *************************************/ - -TILE_GET_INFO_MEMBER(mwarr_state::get_bg_tile_info) -{ - int tileno = m_bg_videoram[tile_index] & 0x1fff; - int colour = (m_bg_videoram[tile_index] & 0xe000) >> 13; - - SET_TILE_INFO_MEMBER(4, tileno, colour, 0); -} - -TILE_GET_INFO_MEMBER(mwarr_state::get_mlow_tile_info) -{ - int tileno = m_mlow_videoram[tile_index] & 0x1fff; - int colour = (m_mlow_videoram[tile_index] & 0xe000) >> 13; - - SET_TILE_INFO_MEMBER(3, tileno, colour, 0); -} - -TILE_GET_INFO_MEMBER(mwarr_state::get_mhigh_tile_info) -{ - int tileno = m_mhigh_videoram[tile_index] & 0x1fff; - int colour = (m_mhigh_videoram[tile_index] & 0xe000) >> 13; - - SET_TILE_INFO_MEMBER(2, tileno, colour, 0); -} - -TILE_GET_INFO_MEMBER(mwarr_state::get_tx_tile_info) -{ - int tileno = m_tx_videoram[tile_index] & 0x1fff; - int colour = (m_tx_videoram[tile_index] & 0xe000) >> 13; - - SET_TILE_INFO_MEMBER(1, tileno, colour, 0); -} - -void mwarr_state::video_start() -{ - m_bg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(mwarr_state::get_bg_tile_info),this), TILEMAP_SCAN_COLS, 16, 16, 64, 16); - m_mlow_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(mwarr_state::get_mlow_tile_info),this), TILEMAP_SCAN_COLS, 16, 16, 64, 16); - m_mhigh_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(mwarr_state::get_mhigh_tile_info),this), TILEMAP_SCAN_COLS, 16, 16, 64, 16); - m_tx_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(mwarr_state::get_tx_tile_info),this), TILEMAP_SCAN_ROWS, 8, 8, 64, 32); - - m_mlow_tilemap->set_transparent_pen(0); - m_mhigh_tilemap->set_transparent_pen(0); - m_tx_tilemap->set_transparent_pen(0); - - m_bg_tilemap->set_scroll_rows(256); - m_mlow_tilemap->set_scroll_rows(256); - m_mhigh_tilemap->set_scroll_rows(256); - - save_item(NAME(m_sprites_buffer)); -} - -void mwarr_state::draw_sprites( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect ) -{ - const uint16_t *source = m_sprites_buffer + 0x800 - 4; - const uint16_t *finish = m_sprites_buffer; - gfx_element *gfx = m_gfxdecode->gfx(0); - int x, y, color, flipx, dy, pri, pri_mask, i; - - while (source >= finish) - { - /* draw sprite */ - if (source[0] & 0x0800) - { - y = 512 - (source[0] & 0x01ff); - x = (source[3] & 0x3ff) - 9; - - color = source[1] & 0x000f; - flipx = source[1] & 0x0200; - - dy = (source[0] & 0xf000) >> 12; - - pri = ((source[1] & 0x3c00) >> 10); // Priority (1 = Low) - pri_mask = ~((1 << (pri + 1)) - 1); // Above the first "pri" levels - - for (i = 0; i <= dy; i++) - { - gfx->prio_transpen(bitmap, - cliprect, - source[2]+i, - color, - flipx,0, - x,y+i*16, - screen.priority(),pri_mask,0 ); - - /* wrap around x */ - gfx->prio_transpen(bitmap, - cliprect, - source[2]+i, - color, - flipx,0, - x-1024,y+i*16, - screen.priority(),pri_mask,0 ); - - /* wrap around y */ - gfx->prio_transpen(bitmap, - cliprect, - source[2]+i, - color, - flipx,0, - x,y-512+i*16, - screen.priority(),pri_mask,0 ); - - /* wrap around x & y */ - gfx->prio_transpen(bitmap, - cliprect, - source[2]+i, - color, - flipx,0, - x-1024,y-512+i*16, - screen.priority(),pri_mask,0 ); - } - } - - source -= 0x4; - } -} - + uint32_t mwarr_state::screen_update_mwarr(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) +{ + return m_video->draw(screen, bitmap, cliprect); +} + +WRITE16_MEMBER(mwarr_state::mwarr_brightness_w) { int i; + double brightness; - screen.priority().fill(0, cliprect); + COMBINE_DATA(&m_mwarr_ram[0x14 / 2]); - if (BIT(m_vidattrram[6], 0)) + brightness = (double)(data & 0xff); + for (i = 0; i < 0x800; i++) { - for (i = 0; i < 256; i++) - m_bg_tilemap->set_scrollx(i, m_bg_scrollram[i] + 20); + m_palette->set_pen_contrast(i, brightness/255); } - else - { - for (i = 0; i < 256; i++) - m_bg_tilemap->set_scrollx(i, m_bg_scrollram[0] + 19); - } - - if (BIT(m_vidattrram[6], 2)) - { - for (i = 0; i < 256; i++) - m_mlow_tilemap->set_scrollx(i, m_mlow_scrollram[i] + 19); - } - else - { - for (i = 0; i < 256; i++) - m_mlow_tilemap->set_scrollx(i, m_mlow_scrollram[0] + 19); - } - - if (BIT(m_vidattrram[6], 4)) - { - for (i = 0; i < 256; i++) - m_mhigh_tilemap->set_scrollx(i, m_mhigh_scrollram[i] + 19); - } - else - { - for (i = 0; i < 256; i++) - m_mhigh_tilemap->set_scrollx(i, m_mhigh_scrollram[0] + 19); - } - - m_bg_tilemap->set_scrolly(0, m_vidattrram[1] + 1); - m_mlow_tilemap->set_scrolly(0, m_vidattrram[2] + 1); - m_mhigh_tilemap->set_scrolly(0, m_vidattrram[3] + 1); - - m_tx_tilemap->set_scrollx(0, m_vidattrram[0] + 16); - m_tx_tilemap->set_scrolly(0, m_vidattrram[4] + 1); - - m_bg_tilemap->draw(screen, bitmap, cliprect, 0, 0x01); - m_mlow_tilemap->draw(screen, bitmap, cliprect, 0, 0x02); - m_mhigh_tilemap->draw(screen, bitmap, cliprect, 0, 0x04); - m_tx_tilemap->draw(screen, bitmap, cliprect, 0, 0x10); - draw_sprites(screen, bitmap, cliprect); - return 0; } /************************************* @@ -561,23 +300,18 @@ uint32_t mwarr_state::screen_update_mwarr(screen_device &screen, bitmap_ind16 &b void mwarr_state::machine_start() { m_okibank->configure_entries(0, 4, memregion("oki2")->base(), 0x20000); - - save_item(NAME(m_which)); } void mwarr_state::machine_reset() { - m_which = 0; } MACHINE_CONFIG_START(mwarr_state::mwarr) - /* basic machine hardware */ MCFG_DEVICE_ADD("maincpu", M68000, MASTER_CLOCK) MCFG_DEVICE_PROGRAM_MAP(mwarr_map) MCFG_DEVICE_VBLANK_INT_DRIVER("screen", mwarr_state, irq4_line_hold) - /* video hardware */ MCFG_SCREEN_ADD("screen", RASTER) MCFG_SCREEN_REFRESH_RATE(54) @@ -591,6 +325,19 @@ MACHINE_CONFIG_START(mwarr_state::mwarr) MCFG_PALETTE_ADD("palette", 0x800) MCFG_PALETTE_FORMAT(xBBBBBGGGGGRRRRR) + EDEVICES_VID(config, m_video, 0); + m_video->set_bg_videoram_tag("bg_videoram"); + m_video->set_mlow_videoram_tag("mlow_videoram"); + m_video->set_mhigh_videoram_tag("mhigh_videoram"); + m_video->set_tx_videoram_tag("tx_videoram"); + m_video->set_bg_scrollram_tag("bg_scrollram"); + m_video->set_mlow_scrollram_tag("mlow_scrollram"); + m_video->set_mhigh_scrollram_tag("mhigh_scrollram"); + m_video->set_vidattrram_tag("vidattrram"); + m_video->set_spriteram_tag("spriteram"); + m_video->set_gfxdecode_tag("gfxdecode"); + m_video->set_palette_tag("palette"); + /* sound hardware */ SPEAKER(config, "mono").front_center(); @@ -609,52 +356,54 @@ MACHINE_CONFIG_END * *************************************/ +// all roms had a handwritten date, possible prototype? newest date is the program roms, 24th January ROM_START( mwarr ) ROM_REGION( 0x100000, "maincpu", 0 ) /* 68000 Code */ - ROM_LOAD16_BYTE( "prg_ev", 0x00000, 0x80000, CRC(d1d5e0a6) SHA1(f47955459d41c904b96de000b32cae156ee3bcba) ) - ROM_LOAD16_BYTE( "prg_od", 0x00001, 0x80000, CRC(e5217d91) SHA1(6a5d282e8e5b98628f98530e3c47b9b398e9334e) ) + ROM_LOAD16_BYTE( "prg_ev", 0x00000, 0x80000, CRC(d1d5e0a6) SHA1(f47955459d41c904b96de000b32cae156ee3bcba) ) // date 24/1 + ROM_LOAD16_BYTE( "prg_od", 0x00001, 0x80000, CRC(e5217d91) SHA1(6a5d282e8e5b98628f98530e3c47b9b398e9334e) ) // date 24/1 ROM_REGION( 0x900000, "gfx1", 0 ) - ROM_LOAD( "obm-0", 0x000000, 0x80000, CRC(b4707ba1) SHA1(35330a31e9837e5f848a21fa6f589412b35a04a0) ) - ROM_LOAD( "obm-6", 0x080000, 0x80000, CRC(f9675acc) SHA1(06e0c0c0928ace331ebd08cfeeaa2c8b5603457f) ) - ROM_LOAD( "obm-12", 0x100000, 0x80000, CRC(6239c4dd) SHA1(128040e9517151faf15c75dc1f2d79c5a66b9e1c) ) - ROM_LOAD( "obm-1", 0x180000, 0x80000, CRC(817dcead) SHA1(697b4b3e18e022e0635a3b02cbce1e4d2959a732) ) - ROM_LOAD( "obm-7", 0x200000, 0x80000, CRC(3a93c499) SHA1(9ecd72c5ef4f0edbdc19946bd33aa4e74690756d) ) - ROM_LOAD( "obm-13", 0x280000, 0x80000, CRC(bac42f06) SHA1(6998e605db732e6be9d8213e96bfb04a258eae8f) ) - ROM_LOAD( "obm-2", 0x300000, 0x80000, CRC(68cd29b0) SHA1(02f7bf463cd15eaf4713d33494f19c4fcd199e87) ) - ROM_LOAD( "obm-8", 0x380000, 0x80000, CRC(f9482638) SHA1(ea6256136362a12a40d6b168157c28a14236fcc1) ) - ROM_LOAD( "obm-14", 0x400000, 0x80000, CRC(79ed46b8) SHA1(93b503b58a316be312a74f2da7df3dbcd275884b) ) - ROM_LOAD( "obm-3", 0x480000, 0x80000, CRC(6e924cb8) SHA1(3c56dfcd042108b1cd16395bcdda0fd92a6ab0f7) ) - ROM_LOAD( "obm-9", 0x500000, 0x80000, CRC(be1fb64e) SHA1(4141b6b78fa9830cf5dc4f4f0b29e87e57f70ccb) ) - ROM_LOAD( "obm-15", 0x580000, 0x80000, CRC(5e0efb71) SHA1(d556ed9307a9a9f59f5235981b4b091a88399c98) ) - ROM_LOAD( "obm-4", 0x600000, 0x80000, CRC(f34b67bd) SHA1(91d6553144e45ea1b96bf59403b3e26224b79a7d) ) - ROM_LOAD( "obm-10", 0x680000, 0x80000, CRC(00c68a23) SHA1(a4984932ac3fae368700f77ad16b35b0138dbc21) ) - ROM_LOAD( "obm-16", 0x700000, 0x80000, CRC(e9516379) SHA1(8d9aaa2ee1331dd3eb8951a1008811703dd9f41d) ) - ROM_LOAD( "obm-5", 0x780000, 0x80000, CRC(b2b976f3) SHA1(77dee06ac1187c8a1c4188951bd7b0a62ec84350) ) - ROM_LOAD( "obm-11", 0x800000, 0x80000, CRC(7bf1e4da) SHA1(4aeef3b7c23303580a851dc793e9671a2a0f421f) ) - ROM_LOAD( "obm-17", 0x880000, 0x80000, CRC(47bd56e8) SHA1(e10569e89083165a7efe29f84167a1c15171ccaf) ) + ROM_LOAD( "obm-0", 0x000000, 0x80000, CRC(b4707ba1) SHA1(35330a31e9837e5f848a21fa6f589412b35a04a0) ) // 7/11 + ROM_LOAD( "obm-6", 0x080000, 0x80000, CRC(f9675acc) SHA1(06e0c0c0928ace331ebd08cfeeaa2c8b5603457f) ) // 7/11 + ROM_LOAD( "obm-12", 0x100000, 0x80000, CRC(6239c4dd) SHA1(128040e9517151faf15c75dc1f2d79c5a66b9e1c) ) // 22/11 + ROM_LOAD( "obm-1", 0x180000, 0x80000, CRC(817dcead) SHA1(697b4b3e18e022e0635a3b02cbce1e4d2959a732) ) // 7/11 + ROM_LOAD( "obm-7", 0x200000, 0x80000, CRC(3a93c499) SHA1(9ecd72c5ef4f0edbdc19946bd33aa4e74690756d) ) // 7/11 + ROM_LOAD( "obm-13", 0x280000, 0x80000, CRC(bac42f06) SHA1(6998e605db732e6be9d8213e96bfb04a258eae8f) ) // 22/11 + ROM_LOAD( "obm-2", 0x300000, 0x80000, CRC(68cd29b0) SHA1(02f7bf463cd15eaf4713d33494f19c4fcd199e87) ) // 7/11 + ROM_LOAD( "obm-8", 0x380000, 0x80000, CRC(f9482638) SHA1(ea6256136362a12a40d6b168157c28a14236fcc1) ) // 7/11 + ROM_LOAD( "obm-14", 0x400000, 0x80000, CRC(79ed46b8) SHA1(93b503b58a316be312a74f2da7df3dbcd275884b) ) // 22/11 + + ROM_LOAD( "obm-3", 0x480000, 0x80000, CRC(6e924cb8) SHA1(3c56dfcd042108b1cd16395bcdda0fd92a6ab0f7) ) // 7/11 + ROM_LOAD( "obm-9", 0x500000, 0x80000, CRC(be1fb64e) SHA1(4141b6b78fa9830cf5dc4f4f0b29e87e57f70ccb) ) // 7/11 + ROM_LOAD( "obm-15", 0x580000, 0x80000, CRC(5e0efb71) SHA1(d556ed9307a9a9f59f5235981b4b091a88399c98) ) // 22/11 + ROM_LOAD( "obm-4", 0x600000, 0x80000, CRC(f34b67bd) SHA1(91d6553144e45ea1b96bf59403b3e26224b79a7d) ) // 7/11 + ROM_LOAD( "obm-10", 0x680000, 0x80000, CRC(00c68a23) SHA1(a4984932ac3fae368700f77ad16b35b0138dbc21) ) // 7/11 + ROM_LOAD( "obm-16", 0x700000, 0x80000, CRC(e9516379) SHA1(8d9aaa2ee1331dd3eb8951a1008811703dd9f41d) ) // 22/11 + ROM_LOAD( "obm-5", 0x780000, 0x80000, CRC(b2b976f3) SHA1(77dee06ac1187c8a1c4188951bd7b0a62ec84350) ) // 7/11 + ROM_LOAD( "obm-11", 0x800000, 0x80000, CRC(7bf1e4da) SHA1(4aeef3b7c23303580a851dc793e9671a2a0f421f) ) // 7/11 + ROM_LOAD( "obm-17", 0x880000, 0x80000, CRC(47bd56e8) SHA1(e10569e89083165a7efe29f84167a1c15171ccaf) ) // 22/11 ROM_REGION( 0x100000, "gfx2", 0 ) - ROM_LOAD( "sf4-0", 0x000000, 0x80000, CRC(25938b2d) SHA1(6336e41eee58cab9a524b9bca08965786cc133d3) ) - ROM_LOAD( "sf4-1", 0x080000, 0x80000, CRC(2269ce5c) SHA1(4c6169acf17bba94dc5684f5db60d5bcf73ad068) ) + ROM_LOAD( "sf4-0", 0x000000, 0x80000, CRC(25938b2d) SHA1(6336e41eee58cab9a524b9bca08965786cc133d3) ) // 7/11 + ROM_LOAD( "sf4-1", 0x080000, 0x80000, CRC(2269ce5c) SHA1(4c6169acf17bba94dc5684f5db60d5bcf73ad068) ) // 7/11 ROM_REGION( 0x100000, "gfx3", 0 ) - ROM_LOAD( "sf3-0", 0x000000, 0x80000, CRC(86cd162c) SHA1(95d5f300e3671ebe29b2331325f4d80b96988619) ) - ROM_LOAD( "sf3-1", 0x080000, 0x80000, CRC(2e755e54) SHA1(74b1e099358a07848f7c22c71fbe2661e1ebb417) ) + ROM_LOAD( "sf3-0", 0x000000, 0x80000, CRC(86cd162c) SHA1(95d5f300e3671ebe29b2331325f4d80b96988619) ) // 7/11 + ROM_LOAD( "sf3-1", 0x080000, 0x80000, CRC(2e755e54) SHA1(74b1e099358a07848f7c22c71fbe2661e1ebb417) ) // 7/11 ROM_REGION( 0x100000, "gfx4", 0 ) - ROM_LOAD( "sf2-0", 0x000000, 0x80000, CRC(622a1816) SHA1(b7b88a90ff69e8f2e291e1f9299708ec97ef9b77) ) - ROM_LOAD( "sf2-1", 0x080000, 0x80000, CRC(545f89e9) SHA1(e7d52dc2da3770d7310698af47da9ff7ec32388c) ) + ROM_LOAD( "sf2-0", 0x000000, 0x80000, CRC(622a1816) SHA1(b7b88a90ff69e8f2e291e1f9299708ec97ef9b77) ) // 7/11 + ROM_LOAD( "sf2-1", 0x080000, 0x80000, CRC(545f89e9) SHA1(e7d52dc2da3770d7310698af47da9ff7ec32388c) ) // 7/11 ROM_REGION( 0x100000, "gfx5", 0 ) - ROM_LOAD( "dw-0", 0x000000, 0x80000, CRC(b9b18d00) SHA1(4f38502c75eae88916bc58bfd5d255bac59d0813) ) - ROM_LOAD( "dw-1", 0x080000, 0x80000, CRC(7aea0b12) SHA1(07cbcd6ddcd9ead068b0f5763829e8474b699085) ) + ROM_LOAD( "dw-0", 0x000000, 0x80000, CRC(b9b18d00) SHA1(4f38502c75eae88916bc58bfd5d255bac59d0813) ) // 22/11 + ROM_LOAD( "dw-1", 0x080000, 0x80000, CRC(7aea0b12) SHA1(07cbcd6ddcd9ead068b0f5763829e8474b699085) ) // 22/11 ROM_REGION( 0x40000, "oki1", 0 ) /* Samples */ - ROM_LOAD( "oki0", 0x000000, 0x40000, CRC(005811ce) SHA1(9149bc8e9cc16ce3db4e22f8cb7ea8a57a66980e) ) + ROM_LOAD( "oki0", 0x000000, 0x40000, CRC(005811ce) SHA1(9149bc8e9cc16ce3db4e22f8cb7ea8a57a66980e) ) // no date ROM_REGION( 0x80000, "oki2", 0 ) /* Samples */ - ROM_LOAD( "oki1", 0x000000, 0x80000, CRC(bcde2330) SHA1(452d871360fa907d2e4ebad93c3fba9a3fa32fa7) ) + ROM_LOAD( "oki1", 0x000000, 0x80000, CRC(bcde2330) SHA1(452d871360fa907d2e4ebad93c3fba9a3fa32fa7) ) // no date ROM_END /************************************* @@ -663,4 +412,4 @@ ROM_END * *************************************/ -GAME( 199?, mwarr, 0, mwarr, mwarr, mwarr_state, empty_init, ROT0, "Elettronica Video-Games S.R.L.", "Mighty Warriors", MACHINE_SUPPORTS_SAVE ) +GAME( 199?, mwarr, 0, mwarr, mwarr, mwarr_state, empty_init, ROT0, "Elettronica Video-Games S.R.L.", "Mighty Warriors (24/1)", MACHINE_SUPPORTS_SAVE ) diff --git a/src/mame/drivers/stlforce.cpp b/src/mame/drivers/stlforce.cpp index db02de52c1e..4f4fe0717ff 100644 --- a/src/mame/drivers/stlforce.cpp +++ b/src/mame/drivers/stlforce.cpp @@ -72,10 +72,6 @@ TO DO : #include "emu.h" #include "includes/stlforce.h" -#include "cpu/m68000/m68000.h" -#include "sound/okim6295.h" -#include "screen.h" -#include "speaker.h" WRITE8_MEMBER(stlforce_state::eeprom_w) { @@ -95,10 +91,10 @@ WRITE8_MEMBER(stlforce_state::oki_bank_w) void stlforce_state::stlforce_map(address_map &map) { map(0x000000, 0x03ffff).rom(); - map(0x100000, 0x1007ff).ram().w(FUNC(stlforce_state::bg_videoram_w)).share("bg_videoram"); - map(0x100800, 0x100fff).ram().w(FUNC(stlforce_state::mlow_videoram_w)).share("mlow_videoram"); - map(0x101000, 0x1017ff).ram().w(FUNC(stlforce_state::mhigh_videoram_w)).share("mhigh_videoram"); - map(0x101800, 0x1027ff).ram().w(FUNC(stlforce_state::tx_videoram_w)).share("tx_videoram"); + map(0x100000, 0x1007ff).ram().w(m_video, FUNC(edevices_device::bg_videoram_w)).share("bg_videoram"); + map(0x100800, 0x100fff).ram().w(m_video, FUNC(edevices_device::mlow_videoram_w)).share("mlow_videoram"); + map(0x101000, 0x1017ff).ram().w(m_video, FUNC(edevices_device::mhigh_videoram_w)).share("mhigh_videoram"); + map(0x101800, 0x1027ff).ram().w(m_video, FUNC(edevices_device::tx_videoram_w)).share("tx_videoram"); map(0x102800, 0x102fff).ram(); /* unknown / ram */ map(0x103000, 0x1033ff).ram().share("bg_scrollram"); map(0x103400, 0x1037ff).ram().share("mlow_scrollram"); @@ -106,13 +102,14 @@ void stlforce_state::stlforce_map(address_map &map) map(0x103c00, 0x103fff).ram().share("vidattrram"); map(0x104000, 0x104fff).ram().w(m_palette, FUNC(palette_device::write16)).share("palette"); map(0x105000, 0x107fff).ram(); /* unknown / ram */ - map(0x108000, 0x108fff).ram().share("spriteram"); + map(0x108000, 0x1087ff).ram().share("spriteram"); + map(0x108800, 0x108fff).ram(); map(0x109000, 0x11ffff).ram(); map(0x400000, 0x400001).portr("INPUT"); map(0x400002, 0x400003).portr("SYSTEM"); map(0x400011, 0x400011).w(FUNC(stlforce_state::eeprom_w)); map(0x400012, 0x400012).w(FUNC(stlforce_state::oki_bank_w)); - map(0x40001e, 0x40001f).nopw(); // sprites buffer commands + map(0x40001e, 0x40001f).w(m_video, FUNC(edevices_device::sprites_commands_w)); map(0x410001, 0x410001).rw("oki", FUNC(okim6295_device::read), FUNC(okim6295_device::write)); } @@ -156,7 +153,7 @@ INPUT_PORTS_END static const gfx_layout stlforce_bglayout = { 16,16, - RGN_FRAC(1,1), + RGN_FRAC(1,4), 4, {0,1,2,3}, {12,8,4,0,28,24,20,16,16*32+12,16*32+8,16*32+4,16*32+0,16*32+28,16*32+24,16*32+20,16*32+16}, @@ -167,7 +164,7 @@ static const gfx_layout stlforce_bglayout = static const gfx_layout stlforce_txlayout = { 8,8, - RGN_FRAC(1,1), + RGN_FRAC(1,4), 4, {0,1,2,3}, {12,8,4,0,28,24,20,16}, @@ -187,11 +184,17 @@ static const gfx_layout stlforce_splayout = }; static GFXDECODE_START( gfx_stlforce ) - GFXDECODE_ENTRY( "gfx1", 0, stlforce_bglayout, 0, 256 ) - GFXDECODE_ENTRY( "gfx1", 0, stlforce_txlayout, 0, 256 ) - GFXDECODE_ENTRY( "gfx2", 0, stlforce_splayout, 0, 256 ) + GFXDECODE_ENTRY( "gfx2", 0, stlforce_splayout, 1024, 16 ) + GFXDECODE_ENTRY( "gfx1", 0x180000, stlforce_txlayout, 384, 8 ) + GFXDECODE_ENTRY( "gfx1", 0x100000, stlforce_bglayout, 256, 8 ) + GFXDECODE_ENTRY( "gfx1", 0x080000, stlforce_bglayout, 128, 8 ) + GFXDECODE_ENTRY( "gfx1", 0x000000, stlforce_bglayout, 0, 8 ) GFXDECODE_END +uint32_t stlforce_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) +{ + return m_video->draw(screen, bitmap, cliprect); +} MACHINE_CONFIG_START(stlforce_state::stlforce) @@ -207,7 +210,7 @@ MACHINE_CONFIG_START(stlforce_state::stlforce) MCFG_SCREEN_REFRESH_RATE(58) MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500) /* not accurate */) MCFG_SCREEN_SIZE(64*8, 32*8) - MCFG_SCREEN_VISIBLE_AREA(1*8, 47*8-1, 0*8, 30*8-1) + MCFG_SCREEN_VISIBLE_AREA(8, 48*8-1-8-2, 0, 30*8-1) MCFG_SCREEN_UPDATE_DRIVER(stlforce_state, screen_update) MCFG_SCREEN_PALETTE("palette") @@ -215,6 +218,19 @@ MACHINE_CONFIG_START(stlforce_state::stlforce) MCFG_PALETTE_ADD("palette", 0x800) MCFG_PALETTE_FORMAT(xBBBBBGGGGGRRRRR) + EDEVICES_SFORCE_VID(config, m_video, 0); + m_video->set_bg_videoram_tag("bg_videoram"); + m_video->set_mlow_videoram_tag("mlow_videoram"); + m_video->set_mhigh_videoram_tag("mhigh_videoram"); + m_video->set_tx_videoram_tag("tx_videoram"); + m_video->set_bg_scrollram_tag("bg_scrollram"); + m_video->set_mlow_scrollram_tag("mlow_scrollram"); + m_video->set_mhigh_scrollram_tag("mhigh_scrollram"); + m_video->set_vidattrram_tag("vidattrram"); + m_video->set_spriteram_tag("spriteram"); + m_video->set_gfxdecode_tag("gfxdecode"); + m_video->set_palette_tag("palette"); + /* sound hardware */ SPEAKER(config, "mono").front_center(); @@ -230,7 +246,10 @@ MACHINE_CONFIG_START(stlforce_state::twinbrat) MCFG_DEVICE_CLOCK(XTAL(14'745'600)) MCFG_SCREEN_MODIFY("screen") - MCFG_SCREEN_VISIBLE_AREA(3*8, 45*8-1, 0*8, 30*8-1) + MCFG_SCREEN_VISIBLE_AREA(3*8, 44*8-1, 0*8, 30*8-1) + + /* modify m_video */ + m_video->set_spritexoffset(10); MCFG_DEVICE_MODIFY("oki") MCFG_DEVICE_CLOCK(XTAL(30'000'000) / 32) // verified on 2 PCBs @@ -374,21 +393,15 @@ ROM_START( twinbratb ) ROM_LOAD( "eeprom-twinbrat.bin", 0x0000, 0x0080, CRC(9366263d) SHA1(ff5155498ed0b349ecc1ce98a39566b642201cf2) ) ROM_END -void stlforce_state::init_stlforce() -{ - m_sprxoffs = 0; -} - void stlforce_state::init_twinbrat() { - m_sprxoffs = 9; - m_okibank->configure_entries(0, 4, memregion("oki")->base(), 0x20000); m_okibank->set_entry(0); } -GAME( 1994, stlforce, 0, stlforce, stlforce, stlforce_state, init_stlforce, ROT0, "Electronic Devices Italy / Ecogames S.L. Spain", "Steel Force", MACHINE_SUPPORTS_SAVE ) +GAME( 1994, stlforce, 0, stlforce, stlforce, stlforce_state, empty_init, ROT0, "Electronic Devices Italy / Ecogames S.L. Spain", "Steel Force", MACHINE_SUPPORTS_SAVE ) + GAME( 1995, twinbrat, 0, twinbrat, stlforce, stlforce_state, init_twinbrat, ROT0, "Elettronica Video-Games S.R.L.", "Twin Brats (set 1)", MACHINE_SUPPORTS_SAVE ) GAME( 1995, twinbrata, twinbrat, twinbrat, stlforce, stlforce_state, init_twinbrat, ROT0, "Elettronica Video-Games S.R.L.", "Twin Brats (set 2)", MACHINE_SUPPORTS_SAVE ) GAME( 1995, twinbratb, twinbrat, twinbrat, stlforce, stlforce_state, init_twinbrat, ROT0, "Elettronica Video-Games S.R.L.", "Twin Brats (set 3)", MACHINE_SUPPORTS_SAVE ) diff --git a/src/mame/includes/stlforce.h b/src/mame/includes/stlforce.h index 6061804005c..c117738a7da 100644 --- a/src/mame/includes/stlforce.h +++ b/src/mame/includes/stlforce.h @@ -1,75 +1,45 @@ // license:BSD-3-Clause // copyright-holders:David Haywood +#include "video/edevices.h" #include "machine/eepromser.h" #include "emupal.h" +#include "cpu/m68000/m68000.h" +#include "sound/okim6295.h" +#include "screen.h" +#include "speaker.h" class stlforce_state : public driver_device { public: - stlforce_state(const machine_config &mconfig, device_type type, const char *tag) - : driver_device(mconfig, type, tag), + stlforce_state(const machine_config &mconfig, device_type type, const char *tag) : + driver_device(mconfig, type, tag), m_maincpu(*this, "maincpu"), m_eeprom(*this, "eeprom"), + m_video(*this, "edevices_vid"), m_gfxdecode(*this, "gfxdecode"), m_palette(*this, "palette"), - m_bg_videoram(*this, "bg_videoram"), - m_mlow_videoram(*this, "mlow_videoram"), - m_mhigh_videoram(*this, "mhigh_videoram"), - m_tx_videoram(*this, "tx_videoram"), - m_bg_scrollram(*this, "bg_scrollram"), - m_mlow_scrollram(*this, "mlow_scrollram"), - m_mhigh_scrollram(*this, "mhigh_scrollram"), - m_vidattrram(*this, "vidattrram"), - m_spriteram(*this, "spriteram"), - m_okibank(*this, "okibank") { } + m_okibank(*this, "okibank") + { } void stlforce(machine_config &config); void twinbrat(machine_config &config); void init_twinbrat(); - void init_stlforce(); private: required_device m_maincpu; required_device m_eeprom; + required_device m_video; required_device m_gfxdecode; required_device m_palette; - required_shared_ptr m_bg_videoram; - required_shared_ptr m_mlow_videoram; - required_shared_ptr m_mhigh_videoram; - required_shared_ptr m_tx_videoram; - required_shared_ptr m_bg_scrollram; - required_shared_ptr m_mlow_scrollram; - required_shared_ptr m_mhigh_scrollram; - required_shared_ptr m_vidattrram; - required_shared_ptr m_spriteram; - optional_memory_bank m_okibank; - tilemap_t *m_bg_tilemap; - tilemap_t *m_mlow_tilemap; - tilemap_t *m_mhigh_tilemap; - tilemap_t *m_tx_tilemap; - - int m_sprxoffs; - - DECLARE_WRITE16_MEMBER(bg_videoram_w); - DECLARE_WRITE16_MEMBER(mlow_videoram_w); - DECLARE_WRITE16_MEMBER(mhigh_videoram_w); - DECLARE_WRITE16_MEMBER(tx_videoram_w); DECLARE_WRITE8_MEMBER(eeprom_w); DECLARE_WRITE8_MEMBER(oki_bank_w); - TILE_GET_INFO_MEMBER(get_bg_tile_info); - TILE_GET_INFO_MEMBER(get_mlow_tile_info); - TILE_GET_INFO_MEMBER(get_mhigh_tile_info); - TILE_GET_INFO_MEMBER(get_tx_tile_info); - - virtual void video_start() override; uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect ); void stlforce_map(address_map &map); void twinbrat_oki_map(address_map &map); diff --git a/src/mame/video/edevices.cpp b/src/mame/video/edevices.cpp new file mode 100644 index 00000000000..2c2c1a6e3fd --- /dev/null +++ b/src/mame/video/edevices.cpp @@ -0,0 +1,336 @@ +// license:BSD-3-Clause +// copyright-holders:Pierpaolo Prazzoli, David Haywood +/* + Electronic Devices video system + + used by + stlforce.cpp + mwarr.cpp + + TODO: + Check if the sprites are an obvious clone of anything else and split out if neccessary + Steel Force doesn't use the variable height sprites, does the hardware support them? + Verify offsets / visible areas / overscan etc. especially text layer as Steel Force ending does not quite fit on screen +*/ + + +#include "emu.h" +#include "edevices.h" + +DEFINE_DEVICE_TYPE(EDEVICES_VID, edevices_device, "edevices_vid", "Electronic Devices Video (Mighty Warriors)") +DEFINE_DEVICE_TYPE(EDEVICES_SFORCE_VID, edevices_sforce_device, "edevices_sforce_vid", "Electronic Devices Video (Steel Forces)") + + +edevices_device::edevices_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) : + device_t(mconfig, type, tag, owner, clock), + m_bg_videoram(*this, finder_base::DUMMY_TAG), + m_mlow_videoram(*this, finder_base::DUMMY_TAG), + m_mhigh_videoram(*this, finder_base::DUMMY_TAG), + m_tx_videoram(*this, finder_base::DUMMY_TAG), + m_bg_scrollram(*this, finder_base::DUMMY_TAG), + m_mlow_scrollram(*this, finder_base::DUMMY_TAG), + m_mhigh_scrollram(*this, finder_base::DUMMY_TAG), + m_vidattrram(*this, finder_base::DUMMY_TAG), + m_spriteram(*this, finder_base::DUMMY_TAG), + m_gfxdecode(*this, finder_base::DUMMY_TAG), + m_palette(*this, finder_base::DUMMY_TAG), + m_spritexoffs(0) // might come from the clock, twinbrat has different video timings and resolution +{ +} + + +edevices_device::edevices_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + edevices_device(mconfig, EDEVICES_VID, tag, owner, clock) +{ +} + +edevices_sforce_device::edevices_sforce_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + edevices_device(mconfig, EDEVICES_SFORCE_VID, tag, owner, clock) +{ +} + + +void edevices_device::device_start() +{ + m_bg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(edevices_device::get_bg_tile_info),this), TILEMAP_SCAN_COLS, 16, 16, 64, 16); + m_mlow_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(edevices_device::get_mlow_tile_info),this), TILEMAP_SCAN_COLS, 16, 16, 64, 16); + m_mhigh_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(edevices_device::get_mhigh_tile_info),this), TILEMAP_SCAN_COLS, 16, 16, 64, 16); + m_tx_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(edevices_device::get_tx_tile_info),this), TILEMAP_SCAN_ROWS, 8, 8, 64, 32); + + m_mlow_tilemap->set_transparent_pen(0); + m_mhigh_tilemap->set_transparent_pen(0); + m_tx_tilemap->set_transparent_pen(0); + + m_bg_tilemap->set_scroll_rows(256); + m_mlow_tilemap->set_scroll_rows(256); + m_mhigh_tilemap->set_scroll_rows(256); + + save_item(NAME(m_sprites_buffer)); + save_item(NAME(m_which)); +} + +void edevices_device::device_reset() +{ + m_which = 0; +} + +WRITE16_MEMBER(edevices_device::bg_videoram_w) +{ + COMBINE_DATA(&m_bg_videoram[offset]); + m_bg_tilemap->mark_tile_dirty(offset); +} + +WRITE16_MEMBER(edevices_device::mlow_videoram_w) +{ + COMBINE_DATA(&m_mlow_videoram[offset]); + m_mlow_tilemap->mark_tile_dirty(offset); +} + +WRITE16_MEMBER(edevices_device::mhigh_videoram_w) +{ + COMBINE_DATA(&m_mhigh_videoram[offset]); + m_mhigh_tilemap->mark_tile_dirty(offset); +} + +WRITE16_MEMBER(edevices_device::tx_videoram_w) +{ + COMBINE_DATA(&m_tx_videoram[offset]); + m_tx_tilemap->mark_tile_dirty(offset); +} + +WRITE16_MEMBER(edevices_device::sprites_commands_w) +{ + // TODO: I'm not convinced by this, from mwarr.cpp driver + if (m_which) + { + int i; + + switch (data & 0xf) + { + case 0: + /* clear sprites on screen */ + for (i = 0; i < 0x400; i++) + { + m_sprites_buffer[i] = 0; + } + m_which = 0; + break; + + default: + // allow everything else to fall through, other games are writing other values + case 0xf: // mwarr + /* refresh sprites on screen */ + for (i = 0; i < 0x400; i++) + { + m_sprites_buffer[i] = m_spriteram[i]; + } + break; + + case 0xd: + /* keep sprites on screen */ + break; + } + } + + m_which ^= 1; +} + +TILE_GET_INFO_MEMBER(edevices_device::get_bg_tile_info) +{ + int tileno = m_bg_videoram[tile_index] & 0x1fff; + int colour = (m_bg_videoram[tile_index] & 0xe000) >> 13; + + SET_TILE_INFO_MEMBER(4, tileno, colour, 0); +} + +TILE_GET_INFO_MEMBER(edevices_device::get_mlow_tile_info) +{ + int tileno = m_mlow_videoram[tile_index] & 0x1fff; + int colour = (m_mlow_videoram[tile_index] & 0xe000) >> 13; + + SET_TILE_INFO_MEMBER(3, tileno, colour, 0); +} + +TILE_GET_INFO_MEMBER(edevices_device::get_mhigh_tile_info) +{ + int tileno = m_mhigh_videoram[tile_index] & 0x1fff; + int colour = (m_mhigh_videoram[tile_index] & 0xe000) >> 13; + + SET_TILE_INFO_MEMBER(2, tileno, colour, 0); +} + +TILE_GET_INFO_MEMBER(edevices_device::get_tx_tile_info) +{ + int tileno = m_tx_videoram[tile_index] & 0x1fff; + int colour = (m_tx_videoram[tile_index] & 0xe000) >> 13; + + SET_TILE_INFO_MEMBER(1, tileno, colour, 0); +} + + +int edevices_device::get_priority(const uint16_t *source) +{ + return ((source[1] & 0x3c00) >> 10); // Priority (1 = Low) +} + +// the Steel Force type hardware uses an entirely different bit for priority and only appears to have 2 levels +int edevices_sforce_device::get_priority(const uint16_t *source) +{ + return (source[1] & 0x0020) ? 0xc : 0x2; +} + +void edevices_device::draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) +{ + const uint16_t *source = m_sprites_buffer + 0x400 - 4; + const uint16_t *finish = m_sprites_buffer; + gfx_element *gfx = m_gfxdecode->gfx(0); + int x, y, color, flipx, dy, pri, pri_mask, i; + + while (source >= finish) + { + /* draw sprite */ + if (source[0] & 0x0800) + { + y = 0x1ff - (source[0] & 0x01ff); + x = (source[3] & 0x3ff) - 9; + + color = source[1] & 0x000f; + flipx = source[1] & 0x0200; + + dy = (source[0] & 0xf000) >> 12; + + pri = get_priority(source); + pri_mask = ~((1 << (pri + 1)) - 1); // Above the first "pri" levels + + x += m_spritexoffs; + + for (i = 0; i <= dy; i++) + { + gfx->prio_transpen(bitmap, + cliprect, + source[2] + i, + color, + flipx, 0, + x, y + i * 16, + screen.priority(), pri_mask, 0); + + /* wrap around x */ + gfx->prio_transpen(bitmap, + cliprect, + source[2] + i, + color, + flipx, 0, + x - 1024, y + i * 16, + screen.priority(), pri_mask, 0); + + /* wrap around y */ + gfx->prio_transpen(bitmap, + cliprect, + source[2] + i, + color, + flipx, 0, + x, y - 512 + i * 16, + screen.priority(), pri_mask, 0); + + /* wrap around x & y */ + gfx->prio_transpen(bitmap, + cliprect, + source[2] + i, + color, + flipx, 0, + x - 1024, y - 512 + i * 16, + screen.priority(), pri_mask, 0); + } + } + + source -= 0x4; + } +} + +/* + m_vidattrram + 0 tx xscroll (or global x scroll?) + 1 back yscroll + 2 mlow yscroll + 3 mhigh yscroll + 4 tx yscroll + 5 ---- ---- ---s tMmB layer enables (s = sprites, t = tx, M = highmid, m = lowmid, B = back) + 6 ---- ---- ---M -m-B rowscroll enables (B = back, m = lowmid, M = highmid) + +*/ + +uint32_t edevices_device::draw(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) +{ + int i; + + bitmap.fill(0, cliprect); + screen.priority().fill(0, cliprect); + + /* xscrolls - Steel Force clearly shows that each layer needs -1 scroll compared to the previous, do enable flags change this? */ + if (BIT(m_vidattrram[6], 0)) + { + for (i = 0; i < 256; i++) + m_bg_tilemap->set_scrollx(i, m_bg_scrollram[i] + 18); + } + else + { + for (i = 0; i < 256; i++) + m_bg_tilemap->set_scrollx(i, m_bg_scrollram[0] + 18); + } + + if (BIT(m_vidattrram[6], 2)) + { + for (i = 0; i < 256; i++) + m_mlow_tilemap->set_scrollx(i, m_mlow_scrollram[i] + 17); + } + else + { + for (i = 0; i < 256; i++) + m_mlow_tilemap->set_scrollx(i, m_mlow_scrollram[0] + 17); + } + + if (BIT(m_vidattrram[6], 4)) + { + for (i = 0; i < 256; i++) + m_mhigh_tilemap->set_scrollx(i, m_mhigh_scrollram[i] + 16); + } + else + { + for (i = 0; i < 256; i++) + m_mhigh_tilemap->set_scrollx(i, m_mhigh_scrollram[0] + 16); + } + + m_tx_tilemap->set_scrollx(0, m_vidattrram[0] + 15); + + /* yscrolls */ + m_bg_tilemap->set_scrolly(0, m_vidattrram[1] + 1); + m_mlow_tilemap->set_scrolly(0, m_vidattrram[2] + 1); + m_mhigh_tilemap->set_scrolly(0, m_vidattrram[3] + 1); + m_tx_tilemap->set_scrolly(0, m_vidattrram[4] + 1); + + + if (BIT(m_vidattrram[5], 0)) + { + m_bg_tilemap->draw(screen, bitmap, cliprect, 0, 0x01); + } + + if (BIT(m_vidattrram[5], 1)) + { + m_mlow_tilemap->draw(screen, bitmap, cliprect, 0, 0x02); + } + + if (BIT(m_vidattrram[5], 2)) + { + m_mhigh_tilemap->draw(screen, bitmap, cliprect, 0, 0x04); + } + + if (BIT(m_vidattrram[5], 3)) + { + m_tx_tilemap->draw(screen, bitmap, cliprect, 0, 0x10); + } + + if (BIT(m_vidattrram[5], 4)) + draw_sprites(screen, bitmap, cliprect); + + return 0; +} diff --git a/src/mame/video/edevices.h b/src/mame/video/edevices.h new file mode 100644 index 00000000000..dcb91a67b45 --- /dev/null +++ b/src/mame/video/edevices.h @@ -0,0 +1,93 @@ +// license:BSD-3-Clause +// copyright-holders:David Haywood +#ifndef MAME_VIDEO_EDEVICES_H +#define MAME_VIDEO_EDEVICES_H + +#pragma once + +#include "screen.h" +#include "emupal.h" + +class edevices_device : public device_t +{ +public: + edevices_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock); + edevices_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + + template void set_bg_videoram_tag(T &&tag) { m_bg_videoram.set_tag(std::forward(tag)); } + template void set_mlow_videoram_tag(T &&tag) { m_mlow_videoram.set_tag(std::forward(tag)); } + template void set_mhigh_videoram_tag(T &&tag) { m_mhigh_videoram.set_tag(std::forward(tag)); } + template void set_tx_videoram_tag(T &&tag) { m_tx_videoram.set_tag(std::forward(tag)); } + template void set_bg_scrollram_tag(T &&tag) { m_bg_scrollram.set_tag(std::forward(tag)); } + template void set_mlow_scrollram_tag(T &&tag) { m_mlow_scrollram.set_tag(std::forward(tag)); } + template void set_mhigh_scrollram_tag(T &&tag) { m_mhigh_scrollram.set_tag(std::forward(tag)); } + template void set_vidattrram_tag(T &&tag) { m_vidattrram.set_tag(std::forward(tag)); } + template void set_spriteram_tag(T &&tag) { m_spriteram.set_tag(std::forward(tag)); } + template void set_gfxdecode_tag(T &&tag) { m_gfxdecode.set_tag(std::forward(tag)); } + template void set_palette_tag(T &&tag) { m_palette.set_tag(std::forward(tag)); } + + void set_spritexoffset(int offset) + { + m_spritexoffs = offset; + } + + DECLARE_WRITE16_MEMBER(bg_videoram_w); + DECLARE_WRITE16_MEMBER(mlow_videoram_w); + DECLARE_WRITE16_MEMBER(mhigh_videoram_w); + DECLARE_WRITE16_MEMBER(tx_videoram_w); + DECLARE_WRITE16_MEMBER(sprites_commands_w); + + uint32_t draw(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); + +protected: + virtual void device_start() override; + virtual void device_reset() override; + + virtual int get_priority(const uint16_t *source); +private: + + /* video-related */ + tilemap_t *m_bg_tilemap; + tilemap_t *m_mlow_tilemap; + tilemap_t *m_mhigh_tilemap; + tilemap_t *m_tx_tilemap; + + TILE_GET_INFO_MEMBER(get_bg_tile_info); + TILE_GET_INFO_MEMBER(get_mlow_tile_info); + TILE_GET_INFO_MEMBER(get_mhigh_tile_info); + TILE_GET_INFO_MEMBER(get_tx_tile_info); + + void draw_sprites( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect ); + + uint16_t m_sprites_buffer[0x400]; + + required_shared_ptr m_bg_videoram; + required_shared_ptr m_mlow_videoram; + required_shared_ptr m_mhigh_videoram; + required_shared_ptr m_tx_videoram; + required_shared_ptr m_bg_scrollram; + required_shared_ptr m_mlow_scrollram; + required_shared_ptr m_mhigh_scrollram; + required_shared_ptr m_vidattrram; + required_shared_ptr m_spriteram; + required_device m_gfxdecode; + required_device m_palette; + + /* misc */ + int m_which; + int m_spritexoffs; +}; + +class edevices_sforce_device : public edevices_device +{ +public: + edevices_sforce_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); +protected: + virtual int get_priority(const uint16_t *source) override; +}; + + +DECLARE_DEVICE_TYPE(EDEVICES_VID, edevices_device) +DECLARE_DEVICE_TYPE(EDEVICES_SFORCE_VID, edevices_sforce_device) + +#endif // MAME_VIDEO_EDEVICES_H diff --git a/src/mame/video/stlforce.cpp b/src/mame/video/stlforce.cpp deleted file mode 100644 index ad52fac5e6a..00000000000 --- a/src/mame/video/stlforce.cpp +++ /dev/null @@ -1,189 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:David Haywood -/* video/stlforce.cpp - see main driver for other notes */ - -#include "emu.h" -#include "includes/stlforce.h" - -/* background, appears to be the bottom layer */ - -TILE_GET_INFO_MEMBER(stlforce_state::get_bg_tile_info) -{ - int tileno,colour; - - tileno = m_bg_videoram[tile_index] & 0x0fff; - colour = m_bg_videoram[tile_index] & 0xe000; - colour = colour >> 13; - SET_TILE_INFO_MEMBER(0,tileno,colour,0); -} - -WRITE16_MEMBER(stlforce_state::bg_videoram_w) -{ - m_bg_videoram[offset] = data; - m_bg_tilemap->mark_tile_dirty(offset); -} - -/* middle layer, low */ - -TILE_GET_INFO_MEMBER(stlforce_state::get_mlow_tile_info) -{ - int tileno,colour; - - tileno = m_mlow_videoram[tile_index] & 0x0fff; - colour = m_mlow_videoram[tile_index] & 0xe000; - colour = colour >> 13; - colour += 8; - tileno += 0x1000; - - SET_TILE_INFO_MEMBER(0,tileno,colour,0); -} - -WRITE16_MEMBER(stlforce_state::mlow_videoram_w) -{ - m_mlow_videoram[offset] = data; - m_mlow_tilemap->mark_tile_dirty(offset); -} - -/* middle layer, high */ - -TILE_GET_INFO_MEMBER(stlforce_state::get_mhigh_tile_info) -{ - int tileno,colour; - - tileno = m_mhigh_videoram[tile_index] & 0x0fff; - colour = m_mhigh_videoram[tile_index] & 0xe000; - colour = colour >> 13; - colour += 16; - tileno += 0x2000; - - SET_TILE_INFO_MEMBER(0,tileno,colour,0); -} - -WRITE16_MEMBER(stlforce_state::mhigh_videoram_w) -{ - m_mhigh_videoram[offset] = data; - m_mhigh_tilemap->mark_tile_dirty(offset); -} - -/* text layer, appears to be the top layer */ - -TILE_GET_INFO_MEMBER(stlforce_state::get_tx_tile_info) -{ - int tileno,colour; - - tileno = m_tx_videoram[tile_index] & 0x0fff; - colour = m_tx_videoram[tile_index] & 0xe000; - colour = colour >> 13; - - tileno += 0xc000; - - colour += 24; - SET_TILE_INFO_MEMBER(1,tileno,colour,0); -} - -WRITE16_MEMBER(stlforce_state::tx_videoram_w) -{ - m_tx_videoram[offset] = data; - m_tx_tilemap->mark_tile_dirty(offset); -} - -/* sprites - quite a bit still needs doing .. */ - -void stlforce_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect ) -{ - const uint16_t *source = m_spriteram+0x0; - const uint16_t *finish = m_spriteram+0x800; - gfx_element *gfx = m_gfxdecode->gfx(2); - int ypos, xpos, attr, num; - - while (sourcetranspen(bitmap, - cliprect, - num, - 64+attr, - 0,0, - xpos+m_sprxoffs,ypos,0 ); - } - - source += 0x4; - } -} - -uint32_t stlforce_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - int i; - - if (m_vidattrram[6] & 1) - { - for(i=0;i<256;i++) - m_bg_tilemap->set_scrollx(i, m_bg_scrollram[i]+9); //+9 for twinbrat - } - else - { - for(i=0;i<256;i++) - m_bg_tilemap->set_scrollx(i, m_bg_scrollram[0]+9); //+9 for twinbrat - } - - if (m_vidattrram[6] & 4) - { - for(i=0;i<256;i++) - m_mlow_tilemap->set_scrollx(i, m_mlow_scrollram[i]+8); - } - else - { - for(i=0;i<256;i++) - m_mlow_tilemap->set_scrollx(i, m_mlow_scrollram[0]+8); - } - - if (m_vidattrram[6] & 0x10) - { - for(i=0;i<256;i++) - m_mhigh_tilemap->set_scrollx(i, m_mhigh_scrollram[i]+8); - } - else - { - for(i=0;i<256;i++) - m_mhigh_tilemap->set_scrollx(i, m_mhigh_scrollram[0]+8); - } - - m_bg_tilemap->set_scrolly(0, m_vidattrram[1]); - m_mlow_tilemap->set_scrolly(0, m_vidattrram[2]); - m_mhigh_tilemap->set_scrolly(0, m_vidattrram[3]); - - m_tx_tilemap->set_scrollx(0, m_vidattrram[0]+8); - m_tx_tilemap->set_scrolly(0,m_vidattrram[4]); - - m_bg_tilemap->draw(screen, bitmap, cliprect, 0,0); - m_mlow_tilemap->draw(screen, bitmap, cliprect, 0,0); - m_mhigh_tilemap->draw(screen, bitmap, cliprect, 0,0); - draw_sprites(bitmap, cliprect); - m_tx_tilemap->draw(screen, bitmap, cliprect, 0,0); - return 0; -} - -void stlforce_state::video_start() -{ - m_bg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(stlforce_state::get_bg_tile_info),this), TILEMAP_SCAN_COLS, 16,16,64,16); - m_mlow_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(stlforce_state::get_mlow_tile_info),this), TILEMAP_SCAN_COLS, 16,16,64,16); - m_mhigh_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(stlforce_state::get_mhigh_tile_info),this),TILEMAP_SCAN_COLS, 16,16,64,16); - m_tx_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(stlforce_state::get_tx_tile_info),this), TILEMAP_SCAN_ROWS, 8, 8,64,32); - - m_mlow_tilemap->set_transparent_pen(0); - m_mhigh_tilemap->set_transparent_pen(0); - m_tx_tilemap->set_transparent_pen(0); - - m_bg_tilemap->set_scroll_rows(256); - m_mlow_tilemap->set_scroll_rows(256); - m_mhigh_tilemap->set_scroll_rows(256); -}