/*
* Make sure cursor is off by initialising the cursor
* control to defaults.
*/
rgb524xo(CursorCtl, 0x00);
/*
* Set auto-increment mode for index-register addressing
* and initialise the cursor array index.
*/
vgao(dacxreg[IndexCtl], 0x01);
vgao(dacxreg[IndexLo], CursorArray & 0xFF);
vgao(dacxreg[IndexHi], (CursorArray>>8) & 0xFF);
/*
* Initialise the 32x32 cursor RAM array. There are 2 planes,
* p0 and p1. Data is written 4 pixels per byte, with p1 the
* MS bit of each pixel.
* The cursor is set in X-Windows mode which gives the following
* truth table:
* p1 p0 colour
* 0 0 underlying pixel colour
* 0 1 underlying pixel colour
* 1 0 cursor colour 1
* 1 1 cursor colour 2
* Put the cursor into the top-left of the 32x32 array.
*/
for(y = 0; y < 32; y++){
for(x = 0; x < 32/8; x++){
if(x < 16/8 && y < 16){
p0 = curs->clr[x+y*2];
p1 = curs->set[x+y*2];
p = 0x00;
if(p1 & 0x80)
p |= 0xC0;
else if(p0 & 0x80)
p |= 0x80;
if(p1 & 0x40)
p |= 0x30;
else if(p0 & 0x40)
p |= 0x20;
if(p1 & 0x20)
p |= 0x0C;
else if(p0 & 0x20)
p |= 0x08;
if(p1 & 0x10)
p |= 0x03;
else if(p0 & 0x10)
p |= 0x02;
vgao(dacxreg[Data], p);
p = 0x00;
if(p1 & 0x08)
p |= 0xC0;
else if(p0 & 0x08)
p |= 0x80;
if(p1 & 0x04)
p |= 0x30;
else if(p0 & 0x04)
p |= 0x20;
if(p1 & 0x02)
p |= 0x0C;
else if(p0 & 0x02)
p |= 0x08;
if(p1 & 0x01)
p |= 0x03;
else if(p0 & 0x01)
p |= 0x02;
vgao(dacxreg[Data], p);
}
else{
vgao(dacxreg[Data], 0x00);
vgao(dacxreg[Data], 0x00);
}
}
}
/*
* Initialise the cursor hotpoint,
* enable the cursor and restore state.
*/
rgb524xo(CursorHotX, -curs->offset.x);
rgb524xo(CursorHotY, -curs->offset.y);
rgb524xo(CursorCtl, 0x23);
vgaxo(Crtx, 0x55, rs2);
}
static int
rgb524move(VGAscr*, Point p)
{
uchar rs2;