summaryrefslogtreecommitdiffstatshomepage
path: root/src/mess/video/cgc7900.c
blob: 9b4418fef9ef1736f819c7e653a6a5d19b866e21 (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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
// license:BSD-3-Clause
// copyright-holders:Curt Coder
#include "emu.h"
#include "includes/cgc7900.h"

/***************************************************************************
    PARAMETERS
***************************************************************************/

#define OVERLAY_CUR                 BIT(cell, 31)   /* places a cursor in the cell if SET */
#define OVERLAY_BLK                 BIT(cell, 30)   /* blinks the foreground character in the cell if SET */
#define OVERLAY_VF                  BIT(cell, 28)   /* makes the foreground visible if SET (else transparent) */
#define OVERLAY_VB                  BIT(cell, 27)   /* makes the background visible if SET (else transparent) */
#define OVERLAY_PL                  BIT(cell, 24)   /* uses bits 0-7 as PLOT DOT descriptor if SET (else ASCII) */
#define OVERLAY_BR                  BIT(cell, 18)   /* turns on Red in background if SET */
#define OVERLAY_BG                  BIT(cell, 17)   /* turns on Green in background if SET */
#define OVERLAY_BB                  BIT(cell, 16)   /* turns on Blue in background if SET */
#define OVERLAY_FR                  BIT(cell, 10)   /* turns on Red in foreground if SET */
#define OVERLAY_FG                  BIT(cell, 9)    /* turns on Green in foreground if SET */
#define OVERLAY_FB                  BIT(cell, 8)    /* turns on Blue in background if SET */
#define OVERLAY_DATA                (cell & 0xff)   /* ASCII or Plot Dot character */

#define IMAGE_SELECT                BIT(m_roll_overlay[0], 13)
#define OVERLAY_CURSOR_BLINK        BIT(m_roll_overlay[0], 12)
#define OVERLAY_CHARACTER_BLINK     BIT(m_roll_overlay[0], 11)

static const rgb_t PALETTE[] =
{
	rgb_t::black,
	rgb_t(0x00, 0x00, 0xff),
	rgb_t(0x00, 0xff, 0x00),
	rgb_t(0x00, 0xff, 0xff),
	rgb_t(0xff, 0x00, 0x00),
	rgb_t(0xff, 0x00, 0xff),
	rgb_t(0xff, 0xff, 0x00),
	rgb_t::white
};

/***************************************************************************
    READ/WRITE HANDLERS
***************************************************************************/

/*-------------------------------------------------
    cgc7900_z_mode_r - Z mode read
-------------------------------------------------*/

READ16_MEMBER( cgc7900_state::z_mode_r )
{
	return 0;
}

/*-------------------------------------------------
    cgc7900_z_mode_w - Z mode write
-------------------------------------------------*/

WRITE16_MEMBER( cgc7900_state::z_mode_w )
{
}

/*-------------------------------------------------
    cgc7900_color_status_w - color status write
-------------------------------------------------*/

WRITE16_MEMBER( cgc7900_state::color_status_w )
{
}

/*-------------------------------------------------
    cgc7900_sync_r - sync information read
-------------------------------------------------*/

READ16_MEMBER( cgc7900_state::sync_r )
{
	/*

	    bit     signal      description

	     0      _VERT       vertical retrace (0=vblank)
	     1                  interlace (1=first field, 0=second field)
	     2      _HG         horizontal retrace (0=hblank)
	     3      1
	     4      1
	     5      1
	     6      1
	     7      1
	     8      1
	     9      1
	    10      1
	    11      1
	    12      1
	    13      1
	    14      1
	    15      1

	*/

	return 0xffff;
}

/***************************************************************************
    VIDEO
***************************************************************************/

/*-------------------------------------------------
    update_clut - update color lookup table
-------------------------------------------------*/

void cgc7900_state::update_clut()
{
	for (int i = 0; i < 256; i++)
	{
		UINT16 addr = i * 2;
		UINT32 data = (m_clut_ram[addr + 1] << 16) | m_clut_ram[addr];
		UINT8 b = data & 0xff;
		UINT8 g = (data >> 8) & 0xff;
		UINT8 r = (data >> 16) & 0xff;

		m_clut[i] = rgb_t(r, g, b);
	}
}

/*-------------------------------------------------
    draw_bitmap - draw bitmap image
-------------------------------------------------*/

void cgc7900_state::draw_bitmap(screen_device *screen, bitmap_rgb32 &bitmap)
{
}

/*-------------------------------------------------
    draw_overlay - draw text overlay
-------------------------------------------------*/

void cgc7900_state::draw_overlay(screen_device *screen, bitmap_rgb32 &bitmap)
{
	for (int y = 0; y < 768; y++)
	{
		int sy = y / 8;
		int line = y % 8;

		for (int sx = 0; sx < 85; sx++)
		{
			UINT16 addr = (sy * 170) + (sx * 2);
			UINT32 cell = (m_overlay_ram[addr] << 16) | m_overlay_ram[addr + 1];
			UINT8 data = m_char_rom->base()[(OVERLAY_DATA << 3) | line];
			int fg = (cell >> 8) & 0x07;
			int bg = (cell >> 16) & 0x07;

			for (int x = 0; x < 8; x++)
			{
				if (OVERLAY_CUR)
				{
					if (!OVERLAY_CURSOR_BLINK || m_blink)
					{
						bitmap.pix32(y, (sx * 8) + x) = PALETTE[7];
					}
				}
				else
				{
					if (BIT(data, x) && (!OVERLAY_CHARACTER_BLINK || m_blink))
					{
						if (OVERLAY_VF) bitmap.pix32(y, (sx * 8) + x) = PALETTE[fg];
					}
					else
					{
						if (OVERLAY_VB) bitmap.pix32(y, (sx * 8) + x) = PALETTE[bg];
					}
				}
			}
		}
	}
}

/*-------------------------------------------------
    TIMER_DEVICE_CALLBACK_MEMBER( blink_tick )
-------------------------------------------------*/

TIMER_DEVICE_CALLBACK_MEMBER(cgc7900_state::blink_tick)
{
	m_blink = !m_blink;
}

UINT32 cgc7900_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
{
	update_clut();
	draw_bitmap(&screen, bitmap);
	draw_overlay(&screen, bitmap);

	return 0;
}

/*-------------------------------------------------
    gfx_layout cgc7900_charlayout
-------------------------------------------------*/

static const gfx_layout cgc7900_charlayout =
{
	8,8,
	RGN_FRAC(1,1),
	1,
	{ RGN_FRAC(0,1) },
	{ STEP8(7,-1) },
	{ STEP8(0,8) },
	8*8
};

/*-------------------------------------------------
    GFXDECODE( cgc7900 )
-------------------------------------------------*/

static GFXDECODE_START( cgc7900 )
	GFXDECODE_ENTRY( "gfx1", 0x0000, cgc7900_charlayout, 0, 1 )
GFXDECODE_END

/***************************************************************************
    MACHINE DRIVERS
***************************************************************************/

/*-------------------------------------------------
    MACHINE_DRIVER( cgc7900_video )
-------------------------------------------------*/

MACHINE_CONFIG_FRAGMENT( cgc7900_video )
	MCFG_SCREEN_ADD(SCREEN_TAG, RASTER)
	MCFG_SCREEN_REFRESH_RATE(60)
	MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */
	MCFG_SCREEN_UPDATE_DRIVER(cgc7900_state, screen_update)
	MCFG_SCREEN_SIZE(1024, 768)
	MCFG_SCREEN_VISIBLE_AREA(0, 1024-1, 0, 768-1)

	MCFG_GFXDECODE_ADD("gfxdecode", cgc7900)

	MCFG_TIMER_DRIVER_ADD_PERIODIC("blink", cgc7900_state, blink_tick, attotime::from_hz(XTAL_28_48MHz/7500000))
MACHINE_CONFIG_END