2 #include "../port/lib.h"
7 #include "../port/error.h"
16 * TVP3026 Viewpoint Video Interface Pallette.
17 * Assumes hooked up to an S3 Vision968.
20 Index = 0x00, /* Index */
21 Data = 0x0A, /* Data */
23 CaddrW = 0x04, /* Colour Write Address */
24 Cdata = 0x05, /* Colour Data */
26 Cctl = 0x09, /* Direct Cursor Control */
27 Cram = 0x0B, /* Cursor Ram Data */
28 Cxlsb = 0x0C, /* Cursor X LSB */
29 Cxmsb = 0x0D, /* Cursor X MSB */
30 Cylsb = 0x0E, /* Cursor Y LSB */
31 Cymsb = 0x0F, /* Cursor Y MSB */
33 Icctl = 0x06, /* Indirect Cursor Control */
37 * Lower 2-bits of indirect DAC register
40 static ushort dacxreg[4] = {
41 PaddrW, Pdata, Pixmask, PaddrR
45 tvp3026io(uchar reg, uchar data)
49 crt55 = vgaxi(Crtx, 0x55) & 0xFC;
50 vgaxo(Crtx, 0x55, crt55|((reg>>2) & 0x03));
51 vgao(dacxreg[reg & 0x03], data);
57 tvp3026o(uchar reg, uchar data)
61 crt55 = tvp3026io(reg, data);
62 vgaxo(Crtx, 0x55, crt55);
66 tvp3026xo(uchar index, uchar data)
70 crt55 = tvp3026io(Index, index);
71 vgaxo(Crtx, 0x55, crt55|((Data>>2) & 0x03));
72 vgao(dacxreg[Data & 0x03], data);
73 vgaxo(Crtx, 0x55, crt55);
77 tvp3026disable(VGAscr*)
79 tvp3026xo(Icctl, 0x90);
84 tvp3026enable(VGAscr*)
87 * Make sure cursor is off and direct control enabled.
89 tvp3026xo(Icctl, 0x90);
94 * cursor colour 1 (white),
95 * cursor colour 2, 3 (black).
97 tvp3026o(CaddrW, 0x00);
98 tvp3026o(Cdata, Pwhite); tvp3026o(Cdata, Pwhite); tvp3026o(Cdata, Pwhite);
99 tvp3026o(Cdata, Pwhite); tvp3026o(Cdata, Pwhite); tvp3026o(Cdata, Pwhite);
100 tvp3026o(Cdata, Pblack); tvp3026o(Cdata, Pblack); tvp3026o(Cdata, Pblack);
101 tvp3026o(Cdata, Pblack); tvp3026o(Cdata, Pblack); tvp3026o(Cdata, Pblack);
104 * Enable the cursor in 3-colour mode.
106 tvp3026o(Cctl, 0x01);
110 tvp3026load(VGAscr* scr, Cursor* curs)
115 * Make sure cursor is off by initialising the cursor
116 * control to defaults.
117 * Write to the indirect control register to make sure
118 * direct register is enabled and upper 2 bits of cursor
120 * The LSBs of the cursor RAM address are in PaddrW.
122 tvp3026xo(Icctl, 0x90);
123 tvp3026o(Cctl, 0x00);
127 * Initialise the 64x64 cursor RAM array. There are 2 planes,
128 * p0 and p1. Data is written 8 pixels per byte, with p0 in the
129 * first 512 bytes of the array and p1 in the second.
130 * The cursor is set in 3-colour mode which gives the following
134 * 0 1 cursor colour 0
135 * 1 0 cursor colour 1
136 * 1 1 cursor colour 2
137 * Put the cursor into the top-left of the 64x64 array.
138 * The 0,0 cursor point is bottom-right, so positioning will
139 * have to take that into account.
141 for(y = 0; y < 64; y++){
142 for(x = 0; x < 64/8; x++){
143 if(x < 16/8 && y < 16)
144 tvp3026o(Cram, curs->clr[x+y*2]);
146 tvp3026o(Cram, 0x00);
149 for(y = 0; y < 64; y++){
150 for(x = 0; x < 64/8; x++){
151 if(x < 16/8 && y < 16)
152 tvp3026o(Cram, curs->set[x+y*2]);
154 tvp3026o(Cram, 0x00);
159 * Initialise the cursor hotpoint
160 * and enable the cursor in 3-colour mode.
162 scr->offset.x = 64+curs->offset.x;
163 scr->offset.y = 64+curs->offset.y;
164 tvp3026o(Cctl, 0x01);
168 tvp3026move(VGAscr* scr, Point p)
172 x = p.x+scr->offset.x;
173 y = p.y+scr->offset.y;
175 tvp3026o(Cxlsb, x & 0xFF);
176 tvp3026o(Cxmsb, (x>>8) & 0x0F);
177 tvp3026o(Cylsb, y & 0xFF);
178 tvp3026o(Cymsb, (y>>8) & 0x0F);
183 VGAcur vgatvp3026cur = {