summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/video/sbrkout.c
blob: 66bfc01dc3e42eb9d8c7824636fe47c4c34e5e04 (plain) (blame)
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
/*************************************************************************

    Atari Super Breakout hardware

*************************************************************************/

#include "driver.h"
#include "includes/sbrkout.h"

UINT8 *sbrkout_horiz_ram;
UINT8 *sbrkout_vert_ram;

static tilemap *bg_tilemap;

WRITE8_HANDLER( sbrkout_videoram_w )
{
	videoram[offset] = data;
	tilemap_mark_tile_dirty(bg_tilemap, offset);
}

static TILE_GET_INFO( get_bg_tile_info )
{
	int code = (videoram[tile_index] & 0x80) ? videoram[tile_index] : 0;

	SET_TILE_INFO(0, code, 0, 0);
}

VIDEO_START( sbrkout )
{
	bg_tilemap = tilemap_create(get_bg_tile_info, tilemap_scan_rows,
		TILEMAP_TYPE_PEN, 8, 8, 32, 32);
}

static void draw_balls(running_machine *machine, mame_bitmap *bitmap, const rectangle *cliprect)
{
	int ball;

	for (ball=2; ball>=0; ball--)
	{
		int code = ((sbrkout_vert_ram[ball * 2 + 1] & 0x80) >> 7);
		int sx = 31 * 8 - sbrkout_horiz_ram[ball * 2];
		int sy = 30 * 8 - sbrkout_vert_ram[ball * 2];

		drawgfx(bitmap, machine->gfx[1],
			code, 0,
			0, 0,
			sx, sy,
			cliprect,
			TRANSPARENCY_PEN, 0);
	}
}

VIDEO_UPDATE( sbrkout )
{
	tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
	draw_balls(machine, bitmap, cliprect);
	return 0;
}