1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
/***************************************************************************
Atari Tetris hardware
***************************************************************************/
#include "emu.h"
#include "includes/atetris.h"
/*************************************
*
* Tilemap callback
*
*************************************/
static TILE_GET_INFO( get_tile_info )
{
atetris_state *state = machine.driver_data<atetris_state>();
UINT8 *videoram = state->m_videoram;
int code = videoram[tile_index * 2] | ((videoram[tile_index * 2 + 1] & 7) << 8);
int color = (videoram[tile_index * 2 + 1] & 0xf0) >> 4;
SET_TILE_INFO(0, code, color, 0);
}
/*************************************
*
* Video RAM write
*
*************************************/
WRITE8_HANDLER( atetris_videoram_w )
{
atetris_state *state = space->machine().driver_data<atetris_state>();
UINT8 *videoram = state->m_videoram;
videoram[offset] = data;
tilemap_mark_tile_dirty(state->m_bg_tilemap, offset / 2);
}
/*************************************
*
* Video system start
*
*************************************/
VIDEO_START( atetris )
{
atetris_state *state = machine.driver_data<atetris_state>();
state->m_bg_tilemap = tilemap_create(machine, get_tile_info, tilemap_scan_rows, 8,8, 64,32);
}
/*************************************
*
* Main refresh
*
*************************************/
SCREEN_UPDATE( atetris )
{
atetris_state *state = screen->machine().driver_data<atetris_state>();
tilemap_draw(bitmap, cliprect, state->m_bg_tilemap, 0,0);
return 0;
}
|