diff options
Diffstat (limited to 'src/mame/video/tc0100scn.cpp')
-rw-r--r-- | src/mame/video/tc0100scn.cpp | 166 |
1 files changed, 128 insertions, 38 deletions
diff --git a/src/mame/video/tc0100scn.cpp b/src/mame/video/tc0100scn.cpp index d40cef83a33..0238be3d35e 100644 --- a/src/mame/video/tc0100scn.cpp +++ b/src/mame/video/tc0100scn.cpp @@ -150,10 +150,12 @@ the wide tilemap mode) #define TC0100SCN_TOTAL_CHARS 256 DEFINE_DEVICE_TYPE(TC0100SCN, tc0100scn_device, "tc0100scn", "Taito TC0100SCN") +DEFINE_DEVICE_TYPE(TC0620SCC, tc0620scc_device, "tc0620scc", "Taito TC0620SCC") -tc0100scn_device::tc0100scn_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) - : device_t(mconfig, TC0100SCN, tag, owner, clock) +tc0100scn_base_device::tc0100scn_base_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock) + : device_t(mconfig, type, tag, owner, clock) , device_gfx_interface(mconfig, *this) + , m_gfxlayout(TC0100SCN_LAYOUT_DEFAULT) , m_ram(nullptr) , m_bgscroll_ram(nullptr) , m_fgscroll_ram(nullptr) @@ -165,7 +167,6 @@ tc0100scn_device::tc0100scn_device(const machine_config &mconfig, const char *ta , m_tx_colbank(0) , m_dblwidth(0) , m_dirty(false) - , m_gfxnum(0) , m_x_offset(0) , m_y_offset(0) , m_flip_xoffs(0) @@ -174,16 +175,56 @@ tc0100scn_device::tc0100scn_device(const machine_config &mconfig, const char *ta , m_flip_text_yoffs(0) , m_multiscrn_xoffs(0) , m_multiscrn_hack(0) - , m_gfxdecode(*this, finder_base::DUMMY_TAG) + , m_col_base(0) { std::fill(std::begin(m_bg_colbank), std::end(m_bg_colbank), 0); } +tc0100scn_device::tc0100scn_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) + : tc0100scn_base_device(mconfig, TC0100SCN, tag, owner, clock) +{ +} + +tc0620scc_device::tc0620scc_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) + : tc0100scn_base_device(mconfig, TC0620SCC, tag, owner, clock) +{ +} + +/************************************* + * + * Graphics definitions + * + *************************************/ + +GFXDECODE_MEMBER(tc0100scn_device::gfxinfo_default) + GFXDECODE_DEVICE(DEVICE_SELF, 0, gfx_8x8x4_packed_msb, 0, 256) +GFXDECODE_END + +GFXDECODE_MEMBER(tc0100scn_device::gfxinfo_1bpp) + GFXDECODE_DEVICE(DEVICE_SELF, 0, gfx_8x8x1, 0, 256) +GFXDECODE_END + +static const gfx_layout layout_scc_6bpp_hi = +{ + 8,8, + RGN_FRAC(1,1), + 6, + { STEP2(0,1)/**/,0,0,0,0/**/ }, + { STEP8(0,2) }, + { STEP8(0,8*2) }, + 8*8*2 +}; + +GFXDECODE_MEMBER(tc0620scc_device::gfxinfo_6bpp) + GFXDECODE_DEVICE(DEVICE_SELF, 0, gfx_8x8x4_packed_msb, 0, 256) // low 4bpp of 6bpp tiles + GFXDECODE_DEVICE("hi_gfx", 0, layout_scc_6bpp_hi, 0, 256) // hi 2bpp of 6bpp tiles +GFXDECODE_END + //------------------------------------------------- // device_start - device-specific startup //------------------------------------------------- -void tc0100scn_device::device_start() +void tc0100scn_base_device::device_start() { // bind callbacks m_tc0100scn_cb.bind_relative_to(*owner()); @@ -199,9 +240,6 @@ void tc0100scn_device::device_start() 16*8 /* every sprite takes 16 consecutive bytes */ }; - if(!m_gfxdecode->started()) - throw device_missing_dependencies(); - int xd, yd; /* Set up clipping for multi-TC0100SCN games. We assume @@ -210,14 +248,14 @@ void tc0100scn_device::device_start() we're safe as it uses single width tilemaps. */ /* Single width versions */ - m_tilemap[0][0] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(&tc0100scn_device::get_bg_tile_info<0x00000, 0>, "bg0_std", this), TILEMAP_SCAN_ROWS, 8, 8, 64, 64); - m_tilemap[1][0] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(&tc0100scn_device::get_bg_tile_info<0x04000, 1>, "bg1_std", this), TILEMAP_SCAN_ROWS, 8, 8, 64, 64); - m_tilemap[2][0] = &machine().tilemap().create(*this, tilemap_get_info_delegate(&tc0100scn_device::get_tx_tile_info<0x02000, 0>, "txt_std", this), TILEMAP_SCAN_ROWS, 8, 8, 64, 64); + m_tilemap[0][0] = &machine().tilemap().create(*this, tilemap_get_info_delegate(&tc0100scn_base_device::get_bg_tile_info<0x00000, 0>, "bg0_std", this), TILEMAP_SCAN_ROWS, 8, 8, 64, 64); + m_tilemap[1][0] = &machine().tilemap().create(*this, tilemap_get_info_delegate(&tc0100scn_base_device::get_bg_tile_info<0x04000, 1>, "bg1_std", this), TILEMAP_SCAN_ROWS, 8, 8, 64, 64); + m_tilemap[2][0] = &machine().tilemap().create(*this, tilemap_get_info_delegate(&tc0100scn_base_device::get_tx_tile_info<0x02000, 1>, "txt_std", this), TILEMAP_SCAN_ROWS, 8, 8, 64, 64); /* Double width versions */ - m_tilemap[0][1] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(&tc0100scn_device::get_bg_tile_info<0x00000, 0>, "bg0_wide", this), TILEMAP_SCAN_ROWS, 8, 8, 128, 64); - m_tilemap[1][1] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(&tc0100scn_device::get_bg_tile_info<0x04000, 1>, "bg1_wide", this), TILEMAP_SCAN_ROWS, 8, 8, 128, 64); - m_tilemap[2][1] = &machine().tilemap().create(*this, tilemap_get_info_delegate(&tc0100scn_device::get_tx_tile_info<0x09000, 1>, "txt_wide", this), TILEMAP_SCAN_ROWS, 8, 8, 128, 32); + m_tilemap[0][1] = &machine().tilemap().create(*this, tilemap_get_info_delegate(&tc0100scn_base_device::get_bg_tile_info<0x00000, 0>, "bg0_wide", this), TILEMAP_SCAN_ROWS, 8, 8, 128, 64); + m_tilemap[1][1] = &machine().tilemap().create(*this, tilemap_get_info_delegate(&tc0100scn_base_device::get_bg_tile_info<0x04000, 1>, "bg1_wide", this), TILEMAP_SCAN_ROWS, 8, 8, 128, 64); + m_tilemap[2][1] = &machine().tilemap().create(*this, tilemap_get_info_delegate(&tc0100scn_base_device::get_tx_tile_info<0x09000, 2>, "txt_wide", this), TILEMAP_SCAN_ROWS, 8, 8, 128, 32); m_tilemap[0][0]->set_transparent_pen(0); m_tilemap[1][0]->set_transparent_pen(0); @@ -266,12 +304,13 @@ void tc0100scn_device::device_start() set_layer_ptrs(); /* create the char set (gfx will then be updated dynamically from RAM) */ - set_gfx(0, std::make_unique<gfx_element>(&palette(), charlayout, (u8 *)&m_ram[0x6000 / 2], NATIVE_ENDIAN_VALUE_LE_BE(8,0), 256, 0)); - set_gfx(1, std::make_unique<gfx_element>(&palette(), charlayout, (u8 *)&m_ram[0x11000 / 2], NATIVE_ENDIAN_VALUE_LE_BE(8,0), 256, 0)); + gfx(0)->set_colorbase(m_col_base); + set_gfx(1, std::make_unique<gfx_element>(&palette(), charlayout, (u8 *)&m_ram[0x6000 / 2], NATIVE_ENDIAN_VALUE_LE_BE(8,0), 64, m_col_base)); + set_gfx(2, std::make_unique<gfx_element>(&palette(), charlayout, (u8 *)&m_ram[0x11000 / 2], NATIVE_ENDIAN_VALUE_LE_BE(8,0), 64, m_col_base)); - gfx_element *bg_gfx = m_gfxdecode->gfx(m_gfxnum); - gfx_element *txt0 = gfx(0); - gfx_element *txt1 = gfx(1); + gfx_element *bg_gfx = gfx(0); + gfx_element *txt0 = gfx(1); + gfx_element *txt1 = gfx(2); if (bg_gfx->granularity() == 2) /* Yuyugogo, Yesnoj */ bg_gfx->set_granularity(16); @@ -287,11 +326,62 @@ void tc0100scn_device::device_start() save_item(NAME(m_dblwidth)); } +void tc0100scn_device::device_start() +{ + switch (m_gfxlayout) + { + case TC0100SCN_LAYOUT_DEFAULT: + default: + decode_gfx(gfxinfo_default); + break; + case TC0100SCN_LAYOUT_1BPP: + decode_gfx(gfxinfo_1bpp); + break; + } + tc0100scn_base_device::device_start(); +} + +void tc0620scc_device::device_start() +{ + decode_gfx(gfxinfo_6bpp); + /* make SCC tile GFX format suitable for gfxdecode */ + gfx_element *gx0 = gfx(0); + gfx_element *gx1 = gfx(1); + + // allocate memory for the assembled data + u8 *srcdata = auto_alloc_array(machine(), u8, gx0->elements() * gx0->width() * gx0->height()); + + // loop over elements + u8 *dest = srcdata; + for (int c = 0; c < gx0->elements(); c++) + { + const u8 *c0base = gx0->get_data(c); + const u8 *c1base = gx1->get_data(c); + + // loop over height + for (int y = 0; y < gx0->height(); y++) + { + const u8 *c0 = c0base; + const u8 *c1 = c1base; + + for (int x = 0; x < gx0->width(); x++) + *dest++ = (*c0++ & 0xf) | (*c1++ & 0x30); + + c0base += gx0->rowbytes(); + c1base += gx1->rowbytes(); + } + } + + gx0->set_raw_layout(srcdata, gx0->width(), gx0->height(), gx0->elements(), 8 * gx0->width(), 8 * gx0->width() * gx0->height()); + gx0->set_granularity(64); + tc0100scn_base_device::device_start(); +} + //------------------------------------------------- // device_reset - device-specific reset //------------------------------------------------- -void tc0100scn_device::device_reset() +void tc0100scn_base_device::device_reset() { m_dblwidth = 0; @@ -305,7 +395,7 @@ void tc0100scn_device::device_reset() *****************************************************************************/ template<unsigned Offset, unsigned Colbank> -TILE_GET_INFO_MEMBER(tc0100scn_device::get_bg_tile_info) +TILE_GET_INFO_MEMBER(tc0100scn_base_device::get_bg_tile_info) { u32 code = m_ram[(2 * tile_index) + 1 + Offset]; const u16 attr = m_ram[(2 * tile_index) + Offset]; @@ -315,14 +405,14 @@ TILE_GET_INFO_MEMBER(tc0100scn_device::get_bg_tile_info) if (!m_tc0100scn_cb.isnull()) m_tc0100scn_cb(&code, &color); - SET_TILE_INFO_MEMBER(m_gfxnum, + SET_TILE_INFO_MEMBER(0, code, ((color + m_bg_colbank[Colbank]) & 0xff), TILE_FLIPYX((attr & 0xc000) >> 14)); } template<unsigned Offset, unsigned Gfx> -TILE_GET_INFO_MEMBER(tc0100scn_device::get_tx_tile_info) +TILE_GET_INFO_MEMBER(tc0100scn_base_device::get_tx_tile_info) { int attr = m_ram[Offset + tile_index]; @@ -332,20 +422,20 @@ TILE_GET_INFO_MEMBER(tc0100scn_device::get_tx_tile_info) TILE_FLIPYX((attr & 0xc000) >> 14)); } -void tc0100scn_device::set_colbanks( int bg0, int bg1, int tx ) +void tc0100scn_base_device::set_colbanks( int bg0, int bg1, int tx ) { m_bg_colbank[0] = bg0; m_bg_colbank[1] = bg1; m_tx_colbank = tx; } -void tc0100scn_device::tilemap_set_dirty() +void tc0100scn_base_device::tilemap_set_dirty() { if (!m_dirty) m_dirty = true; } -void tc0100scn_device::set_layer_ptrs() +void tc0100scn_base_device::set_layer_ptrs() { if (!m_dblwidth) { @@ -361,7 +451,7 @@ void tc0100scn_device::set_layer_ptrs() } } -void tc0100scn_device::restore_scroll() +void tc0100scn_base_device::restore_scroll() { int flip; @@ -388,7 +478,7 @@ void tc0100scn_device::restore_scroll() // device_post_load - device-specific postload //------------------------------------------------- -void tc0100scn_device::device_post_load() +void tc0100scn_base_device::device_post_load() { set_layer_ptrs(); restore_scroll(); @@ -401,12 +491,12 @@ void tc0100scn_device::device_post_load() m_tilemap[2][1]->mark_all_dirty(); } -u16 tc0100scn_device::ram_r(offs_t offset) +u16 tc0100scn_base_device::ram_r(offs_t offset) { return m_ram[offset]; } -void tc0100scn_device::ram_w(offs_t offset, u16 data, u16 mem_mask) +void tc0100scn_base_device::ram_w(offs_t offset, u16 data, u16 mem_mask) { COMBINE_DATA(&m_ram[offset]); /* Double-width tilemaps have a different memory map */ @@ -422,7 +512,7 @@ void tc0100scn_device::ram_w(offs_t offset, u16 data, u16 mem_mask) } else if (offset < 0x3800) { - gfx(0)->mark_dirty((offset - 0x3000) / 8); + gfx(1)->mark_dirty((offset - 0x3000) / 8); m_tilemap[0][1]->mark_tile_dirty(offset / 2); } else if (offset < 0x4000) @@ -435,18 +525,18 @@ void tc0100scn_device::ram_w(offs_t offset, u16 data, u16 mem_mask) else if (offset < 0x8000) m_tilemap[1][1]->mark_tile_dirty((offset & 0x3fff) / 2); else if (offset >= 0x8800 && offset < 0x9000) - gfx(1)->mark_dirty((offset - 0x8800) / 8); + gfx(2)->mark_dirty((offset - 0x8800) / 8); else if (offset >= 0x9000) m_tilemap[2][1]->mark_tile_dirty((offset & 0x0fff)); } -u16 tc0100scn_device::ctrl_r(offs_t offset) +u16 tc0100scn_base_device::ctrl_r(offs_t offset) { return m_ctrl[offset]; } -void tc0100scn_device::ctrl_w(offs_t offset, u16 data, u16 mem_mask) +void tc0100scn_base_device::ctrl_w(offs_t offset, u16 data, u16 mem_mask) { COMBINE_DATA(&m_ctrl[offset]); @@ -511,7 +601,7 @@ void tc0100scn_device::ctrl_w(offs_t offset, u16 data, u16 mem_mask) } -void tc0100scn_device::tilemap_update() +void tc0100scn_base_device::tilemap_update() { if (m_dirty) { @@ -536,7 +626,7 @@ void tc0100scn_device::tilemap_update() m_tilemap[1][m_dblwidth]->set_scrollx((j + m_fgscrolly) & 0x1ff, m_fgscrollx - m_fgscroll_ram[j]); } -void tc0100scn_device::tilemap_draw_fg( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, tilemap_t* tmap, int flags, u8 priority, u8 pmask ) +void tc0100scn_base_device::tilemap_draw_fg( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, tilemap_t* tmap, int flags, u8 priority, u8 pmask ) { const bitmap_ind16 &src_bitmap = tmap->pixmap(); int width_mask, height_mask, x, y, p; @@ -582,7 +672,7 @@ void tc0100scn_device::tilemap_draw_fg( screen_device &screen, bitmap_ind16 &bit } } -int tc0100scn_device::tilemap_draw( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int layer, int flags, u8 priority, u8 pmask ) +int tc0100scn_base_device::tilemap_draw( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int layer, int flags, u8 priority, u8 pmask ) { int disable = m_ctrl[6] & 0xf7; rectangle clip = cliprect; @@ -614,7 +704,7 @@ if (disable != 0 && disable != 3 && disable != 7) return 0; } -int tc0100scn_device::bottomlayer() +int tc0100scn_base_device::bottomlayer() { return (m_ctrl[6] & 0x8) >> 3; } |