diff options
Diffstat (limited to 'src/mame/video/tecmosys.cpp')
-rw-r--r-- | src/mame/video/tecmosys.cpp | 249 |
1 files changed, 110 insertions, 139 deletions
diff --git a/src/mame/video/tecmosys.cpp b/src/mame/video/tecmosys.cpp index a3af6f5cd95..f84f5c7b742 100644 --- a/src/mame/video/tecmosys.cpp +++ b/src/mame/video/tecmosys.cpp @@ -10,61 +10,13 @@ #include "includes/tecmosys.h" -TILE_GET_INFO_MEMBER(tecmosys_state::get_bg0tile_info) +template<int Layer> +TILE_GET_INFO_MEMBER(tecmosys_state::get_tile_info) { - SET_TILE_INFO_MEMBER(1, - m_bg0tilemap_ram[2*tile_index+1], - (m_bg0tilemap_ram[2*tile_index]&0x3f), - TILE_FLIPYX((m_bg0tilemap_ram[2*tile_index]&0xc0)>>6)); -} - -TILE_GET_INFO_MEMBER(tecmosys_state::get_bg1tile_info) -{ - SET_TILE_INFO_MEMBER(2, - m_bg1tilemap_ram[2*tile_index+1], - (m_bg1tilemap_ram[2*tile_index]&0x3f), - TILE_FLIPYX((m_bg1tilemap_ram[2*tile_index]&0xc0)>>6)); -} - -TILE_GET_INFO_MEMBER(tecmosys_state::get_bg2tile_info) -{ - SET_TILE_INFO_MEMBER(3, - m_bg2tilemap_ram[2*tile_index+1], - (m_bg2tilemap_ram[2*tile_index]&0x3f), - TILE_FLIPYX((m_bg2tilemap_ram[2*tile_index]&0xc0)>>6)); -} - -TILE_GET_INFO_MEMBER(tecmosys_state::get_fg_tile_info) -{ - SET_TILE_INFO_MEMBER(0, - m_fgtilemap_ram[2*tile_index+1], - (m_fgtilemap_ram[2*tile_index]&0x3f), - TILE_FLIPYX((m_fgtilemap_ram[2*tile_index]&0xc0)>>6)); -} - - -WRITE16_MEMBER(tecmosys_state::bg0_tilemap_w) -{ - COMBINE_DATA(&m_bg0tilemap_ram[offset]); - m_bg0tilemap->mark_tile_dirty(offset/2); -} - -WRITE16_MEMBER(tecmosys_state::bg1_tilemap_w) -{ - COMBINE_DATA(&m_bg1tilemap_ram[offset]); - m_bg1tilemap->mark_tile_dirty(offset/2); -} - -WRITE16_MEMBER(tecmosys_state::bg2_tilemap_w) -{ - COMBINE_DATA(&m_bg2tilemap_ram[offset]); - m_bg2tilemap->mark_tile_dirty(offset/2); -} - -WRITE16_MEMBER(tecmosys_state::fg_tilemap_w) -{ - COMBINE_DATA(&m_fgtilemap_ram[offset]); - m_txt_tilemap->mark_tile_dirty(offset/2); + SET_TILE_INFO_MEMBER(Layer, + m_vram[Layer][2*tile_index+1], + (m_vram[Layer][2*tile_index]&0x3f), + TILE_FLIPYX((m_vram[Layer][2*tile_index]&0xc0)>>6)); } @@ -79,29 +31,8 @@ WRITE16_MEMBER(tecmosys_state::tilemap_paletteram16_xGGGGGRRRRRBBBBB_word_w) set_color_555(offset+0x4000, 5, 10, 0, m_tilemap_paletteram16[offset]); } -WRITE16_MEMBER(tecmosys_state::bg0_tilemap_lineram_w) -{ - COMBINE_DATA(&m_bg0tilemap_lineram[offset]); - if (data!=0x0000) popmessage("non 0 write to bg0 lineram %04x %04x",offset,data); -} - -WRITE16_MEMBER(tecmosys_state::bg1_tilemap_lineram_w) -{ - COMBINE_DATA(&m_bg1tilemap_lineram[offset]); - if (data!=0x0000) popmessage("non 0 write to bg1 lineram %04x %04x",offset,data); -} - -WRITE16_MEMBER(tecmosys_state::bg2_tilemap_lineram_w) -{ - COMBINE_DATA(&m_bg2tilemap_lineram[offset]); - if (data!=0x0000) popmessage("non 0 write to bg2 lineram %04x %04x",offset,data); -} - - - void tecmosys_state::render_sprites_to_bitmap(bitmap_rgb32 &bitmap, uint16_t extrax, uint16_t extray ) { - uint8_t *gfxsrc = memregion ( "gfx1" )->base(); int i; /* render sprites (with priority information) to temp bitmap */ @@ -178,7 +109,7 @@ void tecmosys_state::render_sprites_to_bitmap(bitmap_rgb32 &bitmap, uint16_t ext dstptr = &m_sprite_bitmap.pix16(drawy, drawx); - data = (gfxsrc[address]); + data = (m_sprite_region[address]); if(data) dstptr[0] = (data + (colour*0x100)) | (priority << 14); @@ -190,16 +121,16 @@ void tecmosys_state::render_sprites_to_bitmap(bitmap_rgb32 &bitmap, uint16_t ext } } -void tecmosys_state::tilemap_copy_to_compose(uint16_t pri) +void tecmosys_state::tilemap_copy_to_compose(uint16_t pri, const rectangle &cliprect) { int y,x; uint16_t *srcptr; uint16_t *dstptr; - for (y=0;y<240;y++) + for (y=cliprect.min_y;y<=cliprect.max_y;y++) { srcptr = &m_tmp_tilemap_renderbitmap.pix16(y); dstptr = &m_tmp_tilemap_composebitmap.pix16(y); - for (x=0;x<320;x++) + for (x=cliprect.min_x;x<=cliprect.max_x;x++) { if ((srcptr[x]&0xf)!=0x0) dstptr[x] = (srcptr[x]&0x7ff) | pri; @@ -207,7 +138,34 @@ void tecmosys_state::tilemap_copy_to_compose(uint16_t pri) } } -void tecmosys_state::do_final_mix(bitmap_rgb32 &bitmap) +#define DRAW_BLENDED \ + int r,g,b; \ + int r2,g2,b2; \ + b = (colour & 0x000000ff) >> 0; \ + g = (colour & 0x0000ff00) >> 8; \ + r = (colour & 0x00ff0000) >> 16; \ + \ + b2 = (colour2 & 0x000000ff) >> 0; \ + g2 = (colour2 & 0x0000ff00) >> 8; \ + r2 = (colour2 & 0x00ff0000) >> 16; \ + \ + r = (r + r2) >> 1; \ + g = (g + g2) >> 1; \ + b = (b + b2) >> 1; \ + \ + dstptr[x] = b | (g<<8) | (r<<16); + +#define DRAW_BG \ + if (srcptr[x]&0xf) \ + { \ + dstptr[x] = colour; \ + } \ + else \ + { \ + dstptr[x] = m_palette->pen(0x3f00); \ + } + +void tecmosys_state::do_final_mix(bitmap_rgb32 &bitmap, const rectangle &cliprect) { const pen_t *paldata = m_palette->pens(); int y,x; @@ -215,19 +173,21 @@ void tecmosys_state::do_final_mix(bitmap_rgb32 &bitmap) uint16_t *srcptr2; uint32_t *dstptr; - for (y=0;y<240;y++) + for (y=cliprect.min_y;y<=cliprect.max_y;y++) { srcptr = &m_tmp_tilemap_composebitmap.pix16(y); srcptr2 = &m_sprite_bitmap.pix16(y); dstptr = &bitmap.pix32(y); - for (x=0;x<320;x++) + for (x=cliprect.min_x;x<=cliprect.max_x;x++) { uint16_t pri, pri2; uint16_t penvalue; uint16_t penvalue2; uint32_t colour; uint32_t colour2; + uint8_t mask = 0; + bool is_transparent = false; pri = srcptr[x] & 0xc000; pri2 = srcptr2[x] & 0xc000; @@ -235,42 +195,49 @@ void tecmosys_state::do_final_mix(bitmap_rgb32 &bitmap) penvalue = m_tilemap_paletteram16[srcptr[x]&0x7ff]; colour = paldata[(srcptr[x]&0x7ff) | 0x4000]; - if (srcptr2[x]&0x3fff) + if (srcptr2[x]&0xff) { penvalue2 = m_palette->basemem().read(srcptr2[x] & 0x3fff); colour2 = paldata[srcptr2[x]&0x3fff]; + mask = srcptr2[x]&0xff; } - else + else if (srcptr[x]&0xf) { penvalue2 = m_tilemap_paletteram16[srcptr[x]&0x7ff]; colour2 = paldata[(srcptr[x]&0x7ff) | 0x4000]; + mask = srcptr[x]&0xf; } - - if ((penvalue & 0x8000) && (penvalue2 & 0x8000)) // blend + else { - int r,g,b; - int r2,g2,b2; - b = (colour & 0x000000ff) >> 0; - g = (colour & 0x0000ff00) >> 8; - r = (colour & 0x00ff0000) >> 16; - - b2 = (colour2 & 0x000000ff) >> 0; - g2 = (colour2 & 0x0000ff00) >> 8; - r2 = (colour2 & 0x00ff0000) >> 16; - - r = (r + r2) >> 1; - g = (g + g2) >> 1; - b = (b + b2) >> 1; - - dstptr[x] = b | (g<<8) | (r<<16); + penvalue2 = m_palette->basemem().read(0x3f00); + colour2 = paldata[0x3f00]; + is_transparent = true; } - else if (pri2 >= pri) + if (is_transparent) { - dstptr[x] = colour2; + if (((penvalue & 0x8000) && (srcptr[x]&0xf)) && (penvalue2 & 0x8000)) // blend + { + DRAW_BLENDED; + } + else + { + DRAW_BG; + } } else { - dstptr[x] = colour; + if (((penvalue & 0x8000) && (srcptr[x]&0xf)) && ((penvalue2 & 0x8000) && (mask))) // blend + { + DRAW_BLENDED; + } + else if ((pri2 >= pri) && (mask)) + { + dstptr[x] = colour2; + } + else + { + DRAW_BG; + } } } } @@ -279,38 +246,44 @@ void tecmosys_state::do_final_mix(bitmap_rgb32 &bitmap) uint32_t tecmosys_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) { - bitmap.fill(m_palette->pen(0x4000), cliprect); - - - m_bg0tilemap->set_scrolly(0, m_c80000regs[1]+16); - m_bg0tilemap->set_scrollx(0, m_c80000regs[0]+104); - - m_bg1tilemap->set_scrolly(0, m_a80000regs[1]+17); - m_bg1tilemap->set_scrollx(0, m_a80000regs[0]+106); - - m_bg2tilemap->set_scrolly(0, m_b00000regs[1]+17); - m_bg2tilemap->set_scrollx(0, m_b00000regs[0]+106); + bitmap.fill(0, cliprect); + + // TODO : Verify 0xc00000-0xc00003 scroll both flip screen and normal screen case, Bit 4 of 0xc00004 is unknown + // TODO : is tilemap flip bits is correct? + m_tilemap[0]->set_flip(((m_scroll[0][2] & 1) ? TILEMAP_FLIPX : 0) | ((m_scroll[0][2] & 2) ? TILEMAP_FLIPY : 0) ); + + // TODO : Scroll is wrong/unverified when flip screen case + m_tilemap[1]->set_flip(((m_scroll[1][2] & 1) ? TILEMAP_FLIPX : 0) | ((m_scroll[1][2] & 2) ? TILEMAP_FLIPY : 0) ); + m_tilemap[1]->set_scrolly(0, m_scroll[1][1]+16); + m_tilemap[1]->set_scrollx(0, m_scroll[1][0]+104); + + m_tilemap[2]->set_flip(((m_scroll[2][2] & 1) ? TILEMAP_FLIPX : 0) | ((m_scroll[2][2] & 2) ? TILEMAP_FLIPY : 0) ); + m_tilemap[2]->set_scrolly(0, m_scroll[2][1]+17); + m_tilemap[2]->set_scrollx(0, m_scroll[2][0]+106); + + m_tilemap[3]->set_flip(((m_scroll[3][2] & 1) ? TILEMAP_FLIPX : 0) | ((m_scroll[3][2] & 2) ? TILEMAP_FLIPY : 0) ); + m_tilemap[3]->set_scrolly(0, m_scroll[3][1]+17); + m_tilemap[3]->set_scrollx(0, m_scroll[3][0]+106); m_tmp_tilemap_composebitmap.fill(0, cliprect); m_tmp_tilemap_renderbitmap.fill(0, cliprect); - m_bg0tilemap->draw(screen, m_tmp_tilemap_renderbitmap, cliprect, 0,0); - tilemap_copy_to_compose(0x0000); + m_tilemap[1]->draw(screen, m_tmp_tilemap_renderbitmap, cliprect, 0,0); + tilemap_copy_to_compose(0x0000, cliprect); m_tmp_tilemap_renderbitmap.fill(0, cliprect); - m_bg1tilemap->draw(screen, m_tmp_tilemap_renderbitmap, cliprect, 0,0); - tilemap_copy_to_compose(0x4000); + m_tilemap[2]->draw(screen, m_tmp_tilemap_renderbitmap, cliprect, 0,0); + tilemap_copy_to_compose(0x4000, cliprect); m_tmp_tilemap_renderbitmap.fill(0, cliprect); - m_bg2tilemap->draw(screen, m_tmp_tilemap_renderbitmap, cliprect, 0,0); - tilemap_copy_to_compose(0x8000); + m_tilemap[3]->draw(screen, m_tmp_tilemap_renderbitmap, cliprect, 0,0); + tilemap_copy_to_compose(0x8000, cliprect); m_tmp_tilemap_renderbitmap.fill(0, cliprect); - m_txt_tilemap->draw(screen, m_tmp_tilemap_renderbitmap, cliprect, 0,0); - tilemap_copy_to_compose(0xc000); - + m_tilemap[0]->draw(screen, m_tmp_tilemap_renderbitmap, cliprect, 0,0); + tilemap_copy_to_compose(0xc000, cliprect); - do_final_mix(bitmap); + do_final_mix(bitmap, cliprect); // prepare sprites for NEXT frame - causes 1 frame palette errors, but prevents sprite lag in tkdensho, which is correct? render_sprites_to_bitmap(bitmap, m_880000regs[0x0], m_880000regs[0x1]); @@ -320,27 +293,25 @@ uint32_t tecmosys_state::screen_update(screen_device &screen, bitmap_rgb32 &bitm void tecmosys_state::video_start() { - m_sprite_bitmap.allocate(320,240); + m_screen->register_screen_bitmap(m_sprite_bitmap); m_sprite_bitmap.fill(0x4000); - - m_tmp_tilemap_composebitmap.allocate(320,240); - m_tmp_tilemap_renderbitmap.allocate(320,240); - + + m_screen->register_screen_bitmap(m_tmp_tilemap_composebitmap); + m_screen->register_screen_bitmap(m_tmp_tilemap_renderbitmap); m_tmp_tilemap_composebitmap.fill(0x0000); m_tmp_tilemap_renderbitmap.fill(0x0000); + m_tilemap[0] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(tecmosys_state::get_tile_info<0>),this),TILEMAP_SCAN_ROWS,8,8,32*2,32*2); + m_tilemap[0]->set_transparent_pen(0); - m_txt_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(tecmosys_state::get_fg_tile_info),this),TILEMAP_SCAN_ROWS,8,8,32*2,32*2); - m_txt_tilemap->set_transparent_pen(0); - - m_bg0tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(tecmosys_state::get_bg0tile_info),this),TILEMAP_SCAN_ROWS,16,16,32,32); - m_bg0tilemap->set_transparent_pen(0); + m_tilemap[1] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(tecmosys_state::get_tile_info<1>),this),TILEMAP_SCAN_ROWS,16,16,32,32); + m_tilemap[1]->set_transparent_pen(0); - m_bg1tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(tecmosys_state::get_bg1tile_info),this),TILEMAP_SCAN_ROWS,16,16,32,32); - m_bg1tilemap->set_transparent_pen(0); + m_tilemap[2] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(tecmosys_state::get_tile_info<2>),this),TILEMAP_SCAN_ROWS,16,16,32,32); + m_tilemap[2]->set_transparent_pen(0); - m_bg2tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(tecmosys_state::get_bg2tile_info),this),TILEMAP_SCAN_ROWS,16,16,32,32); - m_bg2tilemap->set_transparent_pen(0); + m_tilemap[3] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(tecmosys_state::get_tile_info<3>),this),TILEMAP_SCAN_ROWS,16,16,32,32); + m_tilemap[3]->set_transparent_pen(0); save_item(NAME(m_spritelist)); } |