summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/video/ygv608.h
blob: 66f5ff80d0eb0e447d1bc6335be2e04eeeeee913 (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
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
#ifndef __YGV608_H__
#define __YGV608_H__

/*
 *    Yamaha YGV608 - PVDC2 Pattern mode Video Display Controller 2
 *    - Mark McDougall
 */

// Fundamental constants
#define YGV608_SPRITE_ATTR_TABLE_SIZE 256

enum {
	p5_rwai		= 0x80,		// increment register select on reads
	p5_rrai		= 0x40,		// increment register select on writes
	p5_rn		= 0x3f,		// register select

//  p6_res6     = 0xe0,
	p6_fp		= 0x10,		// position detection flag
	p6_fv		= 0x08,		// vertical border interval flag
	p6_fc		= 0x04,
	p6_hb		= 0x02,		// horizontal blanking flag?
	p6_vb		= 0x01,		// vertical blanking flag?

//  p7_res7     = 0xc0,
	p7_tr		= 0x20,
	p7_tc		= 0x10,
	p7_tl		= 0x08,
	p7_ts		= 0x04,
	p7_tn		= 0x02,
	p7_sr		= 0x01,

	r0_pnya		= 0x80,		// if set, increment name table address after reads
	r0_b_a		= 0x40,		// if set, we're reading from the second plane of tile data
	r0_pny		= 0x3f,		// y-coordinate of current name table address

	r1_pnxa		= 0x80,		// if set, increment name table address after read
	r1_res1		= 0x40,
	r1_pnx		= 0x3f,		// x-coordinate of current name table address

	r2_cpaw		= 0x80,		// if set, increment color palette address after writes
	r2_cpar		= 0x40,		// if set, increment color palette address after reads
//  r2_res2     = 0x20,
	r2_b_a		= 0x10,
	r2_scaw		= 0x08,		// if set, increment scroll address after writes
	r2_scar		= 0x04,		// if set, increment scroll address after reads
	r2_saaw		= 0x02,		// if set, increment sprite address after writes
	r2_saar		= 0x01,		// if set, increment sprite address after reads

	r7_dckm 	= 0x80,
	r7_flip		= 0x40,
//  r7_res7     = 0x30,
	r7_zron		= 0x08,		// if set, roz plane is active
	r7_md		= 0x06,		// determines 1 of 4 possible video modes
	r7_dspe		= 0x01,		// if set, display is enabled

	r8_hds		= 0xc0,
	r8_vds		= 0x30,
	r8_rlrt		= 0x08,
	r8_rlsc		= 0x04,
//  r8_res8     = 0x02,
	r8_pgs		= 0x01,

	r9_pts		= 0xc0,
	r9_slh		= 0x38,
	r9_slv		= 0x07,

	r10_spa		= 0xc0,		// misc global sprite attributes (x/y flip or sprite size)
	r10_spas	= 0x20,		// if set, spa controls sprite flip, if clear, controls sprite size
	r10_sprd	= 0x10,		// if set, sprites are disabled
	r10_mcb		= 0x0c,
	r10_mca		= 0x03,

	r11_scm		= 0xc0,
	r11_yse		= 0x20,
	r11_cbdr	= 0x10,
	r11_prm		= 0x0c,		// determines one of 4 priority settings
	r11_ctpb	= 0x02,
	r11_ctpa	= 0x01,

	r12_spf		= 0xc0,
	r12_bpf		= 0x38,
	r12_apf		= 0x07,

//  r14_res14   = 0xfc,
	r14_iep		= 0x02,		// if set, generate IRQ on position detection (?)
	r14_iev		= 0x01,		// if set, generate IRQ on vertical border interval draw

	// these 4 are currently unimplemented by us
	r16_fpm		= 0x80,
	r16_il8		= 0x40,
	r16_res16	= 0x20,
	r16_ih		= 0x1f,

	r17_ba1		= 0x70,
	r17_ba0		= 0x07,
	r18_ba3		= 0x70,
	r18_ba2		= 0x07,
	r19_ba5		= 0x70,
	r19_ba4		= 0x07,
	r20_ba7		= 0x70,
	r20_ba6		= 0x07,
	r21_bb1		= 0x70,
	r21_bb0		= 0x07,
	r22_bb3		= 0x70,
	r22_bb2		= 0x07,
	r23_bb5		= 0x70,
	r23_bb4		= 0x07,
	r24_bb7		= 0x70,
	r24_bb6		= 0x07,

	r39_hsw		= 0xe0,
	r39_hbw		= 0x1f,

	r40_htl89	= 0xc0,
	r40_hdw		= 0x3f,

	r43_vsw		= 0xe0,
	r43_vbw		= 0x1f,

	r44_vsls	= 0x40,
	r44_vdw		= 0x1f,

	r45_vtl8	= 0x80,
	r45_tres	= 0x40,
	r45_vdp		= 0x1f
};


typedef struct _ygv_ports {
	UINT8 na;			// P#0 - pattern name table data port (read/write)
	UINT8 p1;			// P#1 - sprite data port (read/write)
	UINT8 p2;			// P#2 - scroll data port (read/write)
	UINT8 p3;			// P#3 - colour palette data port (read/write)
	UINT8 p4;			// P#4 - register data port (read/write)
	UINT8 p5;			// P#5 - register select port (write only)
	UINT8 p6;			// P#6 - status port (read/write)
	UINT8 p7;			// P#7 - system control port (read/write)
} YGV_PORTS, *pYGV_PORTS;

typedef struct _ygv_regs {
	UINT8 r0;			// R#0 - pattern name table access ptr (r/w)
	UINT8 r1;			// R#1 - pattern name table access ptr (r/w)
	UINT8 r2;			// R#2 - built in ram access control
	UINT8 saa;			// R#3 - sprite attribute table access ptr (r/w)
	UINT8 sca;			// R#4 - scroll table access ptr (r/w)
	UINT8 cc;			// R#5 - color palette access ptr (r/w)
	UINT8 sba;			// R#6 - sprite generator base address (r/w)

	// R#7 - R#11 - screen control (r/w)
	UINT8 r7;			// misc screen control (r/w)
	UINT8 r8;			// misc screen control (r/w)
	UINT8 r9;			// misc screen control (r/w)
	UINT8 r10;			// misc screen control (r/w)
	UINT8 r11;			// misc screen control (r/w)

	UINT8 r12;			// R#12 - color palette selection (r/w)
	UINT8 bdc;			// R#13 - border colour (wo)

	// R#14 - R#16 - interrupt control
	UINT8 r14;
	UINT8 il;
	UINT8 r16;

	// R#17 - R#24 - base address (wo)
	UINT8 r17;
	UINT8 r18;
	UINT8 r19;
	UINT8 r20;
	UINT8 r21;
	UINT8 r22;
	UINT8 r23;
	UINT8 r24;

	// R#25 - R#38 - enlargement, contraction and rotation parameters (wo)
	UINT8 ax0;
	UINT8 ax8;
	UINT8 ax16;

	UINT8 dx0;
	UINT8 dx8;
	UINT8 dxy0;
	UINT8 dxy8;

	UINT8 ay0;
	UINT8 ay8;
	UINT8 ay16;

	UINT8 dy0;
	UINT8 dy8;
	UINT8 dyx0;
	UINT8 dyx8;

	// R#39 - R#46 - display scan control (wo)
	UINT8 r39;
	UINT8 r40;
	UINT8 hdsp;
	UINT8 htl;
	UINT8 r43;
	UINT8 r44;
	UINT8 r45;
	UINT8 vtl;

	// R#47 - R#49 - rom transfer control (wo)
	UINT8 tb5;
	UINT8 tb13;
	UINT8 tn4;

} YGV_REGS, *pYGV_REGS;

#define YGV608_MAX_SPRITES (YGV608_SPRITE_ATTR_TABLE_SIZE>>2)

// R#7(md)
#define MD_2PLANE_8BIT      0x00
#define MD_2PLANE_16BIT     0x02
#define MD_1PLANE_16COLOUR  0x04
#define MD_1PLANE_256COLOUR 0x06
#define MD_1PLANE           (MD_1PLANE_16COLOUR & MD_1PLANE_256COLOUR)
#define MD_SHIFT            0
#define MD_MASK             0x06

// R#8
#define PGS_64X32         0x0
#define PGS_32X64         0x1
#define PGS_SHIFT         0
#define PGS_MASK          0x01

// R#9
#define SLV_SCREEN        0x00
#define SLV_8             0x04
#define SLV_16            0x05
#define SLV_32            0x06
#define SLV_64            0x07
#define SLH_SCREEN        0x00
#define SLH_8             0x04
#define SLH_16            0x05
#define SLH_32            0x06
#define SLH_64            0x07
#define PTS_8X8           0x00
#define PTS_16X16         0x40
#define PTS_32X32         0x80
#define PTS_64X64         0xc0
#define PTS_SHIFT         0
#define PTS_MASK          0xc0

// R#10
#define SPAS_SPRITESIZE    0
#define SPAS_SPRITEREVERSE 1

// R#10(spas)=1
#define SZ_8X8            0x00
#define SZ_16X16          0x01
#define SZ_32X32          0x02
#define SZ_64X64          0x03

// R#10(spas)=0
#define SZ_NOREVERSE      0x00
#define SZ_VERTREVERSE    0x01
#define SZ_HORIZREVERSE   0x02
#define SZ_BOTHREVERSE    0x03

// R#11(prm)
#define PRM_SABDEX        0x00
#define PRM_ASBDEX        0x04
#define PRM_SEABDX        0x08
#define PRM_ASEBDX        0x0c

// R#40
#define HDW_SHIFT         0
#define HDW_MASK          0x3f

// R#44
#define VDW_SHIFT         0
#define VDW_MASK          0x3f

typedef struct {
	UINT8 sy;		// y dot position 7:0
	UINT8 sx;		// x dot position 7:0
	UINT8 attr;		// 0xf0 = color, 0x0c = size, reverse, 0x02 = x hi bit, 0x01 = y hi bit
	UINT8 sn;    // pattern name (0-255)
} SPRITE_ATTR, *PSPRITE_ATTR;


typedef struct _ygv608 {

  union {
    UINT8		b[8];
    YGV_PORTS	s;
  } ports;

  union {
    UINT8		b[50];
    YGV_REGS	s;
  } regs;

  /*
   *  Built in ram
   */

  UINT8 pattern_name_table[4096];

  union {
    UINT8			b[YGV608_SPRITE_ATTR_TABLE_SIZE];
    SPRITE_ATTR		s[YGV608_MAX_SPRITES];
  } sprite_attribute_table;

  UINT8 scroll_data_table[2][256];
  UINT8 colour_palette[256][3];

  /*
   *  Shortcut variables
   */

  UINT32 bits16;          // bits per pattern (8/16)
  UINT32 page_x, page_y;  // pattern page size
  UINT32 pny_shift;       // y coord multiplier
  UINT8 na8_mask;       // mask on/off na11/9:8
  int col_shift;                // shift in scroll table column index

  // rotation, zoom shortcuts
  UINT32 ax, dx, dxy, ay, dy, dyx;

  // base address shortcuts
  UINT32 base_addr[2][8];
  UINT32 base_y_shift;    // for extracting pattern y coord 'base'

  UINT8 screen_resize;  // screen requires resize
  UINT8 tilemap_resize; // tilemap requires resize

} YGV608, *pYGV608;


INTERRUPT_GEN( ygv608_timed_interrupt );
VIDEO_START( ygv608 );
VIDEO_UPDATE( ygv608 );

READ16_HANDLER( ygv608_r );
WRITE16_HANDLER( ygv608_w );

// to be removed
extern READ16_HANDLER( ygv608_debug_trigger );

#endif