aboutsummaryrefslogtreecommitdiff
path: root/src/libdraw/cursor.c
blob: 58f447b131d668c3ba6e912902653b17780697ed (plain)
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
#include <u.h>
#include <libc.h>
#include <draw.h>
#include <cursor.h>

static uint8 expand[16] = {
	0x00, 0x03, 0x0c, 0x0f,
	0x30, 0x33, 0x3c, 0x3f,
	0xc0, 0xc3, 0xcc, 0xcf,
	0xf0, 0xf3, 0xfc, 0xff,
};

void
scalecursor(Cursor2 *c2, Cursor *c)
{
	int y;

	c2->offset.x = 2*c->offset.x;
	c2->offset.y = 2*c->offset.y;
	memset(c2->clr, 0, sizeof c2->clr);
	memset(c2->set, 0, sizeof c2->set);
	for(y = 0; y < 16; y++) {
		c2->clr[8*y] = c2->clr[8*y+4] = expand[c->clr[2*y]>>4];
		c2->set[8*y] = c2->set[8*y+4] = expand[c->set[2*y]>>4];
		c2->clr[8*y+1] = c2->clr[8*y+5] = expand[c->clr[2*y]&15];
		c2->set[8*y+1] = c2->set[8*y+5] = expand[c->set[2*y]&15];
		c2->clr[8*y+2] = c2->clr[8*y+6] = expand[c->clr[2*y+1]>>4];
		c2->set[8*y+2] = c2->set[8*y+6] = expand[c->set[2*y+1]>>4];
		c2->clr[8*y+3] = c2->clr[8*y+7] = expand[c->clr[2*y+1]&15];
		c2->set[8*y+3] = c2->set[8*y+7] = expand[c->set[2*y+1]&15];
	}
}