summaryrefslogtreecommitdiffstatshomepage
path: root/src/mess/video/advision.c
blob: 4d3fa95d9dc7f240e6b0ab6fe3db0c4b814ad5d3 (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/***************************************************************************

  video/advision.c

  Routines to control the Adventurevision video hardware

  Video hardware is composed of a vertical array of 40 LEDs which is
  reflected off a spinning mirror, to give a resolution of 150 x 40 at 15 FPS.

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

#include "emu.h"
#include "includes/advision.h"

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

  Start the video hardware emulation.

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

void advision_state::video_start()
{
	m_video_hpos = 0;
	m_display = auto_alloc_array(machine(), UINT8, 8 * 8 * 256);
	memset(m_display, 0, 8 * 8 * 256);
}

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

  Initialise the palette.

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

PALETTE_INIT_MEMBER(advision_state, advision)
{
	int i;

	for( i = 0; i < 8; i++ )
	{
		/* 8 shades of RED */
		m_palette->set_pen_color(i, i * 0x22, 0x00, 0x00);
	}
}

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

  Update the display data.

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

void advision_state::vh_write(int data)
{
	if (m_video_bank >= 1 && m_video_bank <=5)
	{
		m_led_latch[m_video_bank] = data;
	}
}

void advision_state::vh_update(int x)
{
	UINT8 *dst = &m_display[x];
	int y;

	for( y = 0; y < 8; y++ )
	{
		UINT8 data = m_led_latch[7-y];

		if( (data & 0x80) == 0 ) dst[0 * 256] = 8;
		if( (data & 0x40) == 0 ) dst[1 * 256] = 8;
		if( (data & 0x20) == 0 ) dst[2 * 256] = 8;
		if( (data & 0x10) == 0 ) dst[3 * 256] = 8;
		if( (data & 0x08) == 0 ) dst[4 * 256] = 8;
		if( (data & 0x04) == 0 ) dst[5 * 256] = 8;
		if( (data & 0x02) == 0 ) dst[6 * 256] = 8;
		if( (data & 0x01) == 0 ) dst[7 * 256] = 8;

		m_led_latch[7-y] = 0xff;

		dst += 8 * 256;
	}
}


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

  Refresh the video screen

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

UINT32 advision_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
	int x, y;

	if( (m_frame_count++ % 4) == 0 )
	{
		m_frame_start = 1;
		m_video_hpos = 0;
	}

	for (x = 0; x < 150; x++)
	{
		UINT8 *led = &m_display[x];

		for( y = 0; y < 128; y+=2 )
		{
			if( *led > 0 )
				bitmap.pix16(30 + y, 85 + x) = --(*led);
			else
				bitmap.pix16(30 + y, 85 + x) = 0;

			led += 256;
		}
	}
	return 0;
}