1 // license:BSD-3-Clause
2 // copyright-holders:Zsolt Vasvari, Aaron Giles
3 /***************************************************************************
4 
5     Atari Tetris hardware
6 
7 ***************************************************************************/
8 
9 #include "emu.h"
10 #include "includes/atetris.h"
11 
12 
13 /*************************************
14  *
15  *  Tilemap callback
16  *
17  *************************************/
18 
TILE_GET_INFO_MEMBER(atetris_state::get_tile_info)19 TILE_GET_INFO_MEMBER(atetris_state::get_tile_info)
20 {
21 	int code = m_videoram[tile_index * 2] | ((m_videoram[tile_index * 2 + 1] & 7) << 8);
22 	int color = (m_videoram[tile_index * 2 + 1] & 0xf0) >> 4;
23 
24 	tileinfo.set(0, code, color, 0);
25 }
26 
27 
28 
29 /*************************************
30  *
31  *  Video RAM write
32  *
33  *************************************/
34 
videoram_w(offs_t offset,uint8_t data)35 void atetris_state::videoram_w(offs_t offset, uint8_t data)
36 {
37 	m_videoram[offset] = data;
38 	m_bg_tilemap->mark_tile_dirty(offset / 2);
39 }
40 
41 
42 
43 /*************************************
44  *
45  *  Video system start
46  *
47  *************************************/
48 
video_start()49 void atetris_state::video_start()
50 {
51 	m_bg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(atetris_state::get_tile_info)), TILEMAP_SCAN_ROWS,  8,8, 64,32);
52 }
53 
54 
55 
56 /*************************************
57  *
58  *  Main refresh
59  *
60  *************************************/
61 
screen_update(screen_device & screen,bitmap_ind16 & bitmap,const rectangle & cliprect)62 uint32_t atetris_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
63 {
64 	m_bg_tilemap->draw(screen, bitmap, cliprect, 0,0);
65 	return 0;
66 }
67