summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/video/avigo.cpp
blob: ca21f5867e29eb02e366d67acb4695548cbfc489 (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
// license:GPL-2.0+
// copyright-holders:Kevin Thacker,Sandro Ronco
/***************************************************************************

  avigo.c

  Functions to emulate the video hardware of the TI Avigo 10 PDA

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

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

/***************************************************************************
  Start the video hardware emulation.
***************************************************************************/

/* mem size = 0x017c0 */


/* current column to read/write */

#define AVIGO_VIDEO_DEBUG 0
#define LOG(x) do { if (AVIGO_VIDEO_DEBUG) logerror x; } while (0)


READ8_MEMBER(avigo_state::vid_memory_r)
{
	if (!offset)
		return m_screen_column;

	if ((offset<0x0100) || (offset>=0x01f0) || (m_screen_column >= (AVIGO_SCREEN_WIDTH>>3)))
	{
		LOG(("vid mem read: %04x\n", offset));
		return 0;
	}

	/* 0x0100-0x01f0 contains data for selected column */
	return m_video_memory[m_screen_column + ((offset&0xff)*(AVIGO_SCREEN_WIDTH>>3))];
}

WRITE8_MEMBER(avigo_state::vid_memory_w)
{
	if (!offset)
	{
		/* select column to read/write */
		m_screen_column = data;

		LOG(("vid mem column write: %02x\n",data));

		if (data>=(AVIGO_SCREEN_WIDTH>>3))
		{
			LOG(("error: vid mem column write: %02x\n",data));
		}
		return;
	}

	if ((offset<0x0100) || (offset>=0x01f0) || (m_screen_column >= (AVIGO_SCREEN_WIDTH>>3)))
	{
		LOG(("vid mem write: %04x %02x\n", offset, data));
		return;
	}

	/* 0x0100-0x01f0 contains data for selected column */
	m_video_memory[m_screen_column + ((offset&0xff)*(AVIGO_SCREEN_WIDTH>>3))] = data;
}

void avigo_state::video_start()
{
	/* current selected column to read/write */
	m_screen_column = 0;

	/* allocate video memory */
	m_video_memory = make_unique_clear<uint8_t[]>((AVIGO_SCREEN_WIDTH>>3) * AVIGO_SCREEN_HEIGHT + 1);

	save_pointer(NAME(m_video_memory), (AVIGO_SCREEN_WIDTH>>3) * AVIGO_SCREEN_HEIGHT + 1);
}

uint32_t avigo_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
	int y;
	int b;
	int x;

	/* draw avigo display */
	for (y=0; y<AVIGO_SCREEN_HEIGHT; y++)
	{
		int by;
		uint8_t *line_ptr = &m_video_memory[y*(AVIGO_SCREEN_WIDTH>>3)];

		x = 0;
		for (by=((AVIGO_SCREEN_WIDTH>>3)-1); by>=0; by--)
		{
			int px;
			uint8_t byte = line_ptr[0];

			px = x;
			for (b=7; b>=0; b--)
			{
				bitmap.pix16(y, px) = ((byte>>7) & 0x01);
				px++;
				byte = byte<<1;
			}

			x = px;
			line_ptr = line_ptr+1;
		}
	}
	return 0;
}