plan 9 kernel history: overview | file list | diff list

1990/05313/port/devbit.c (diff list | history)

1990/05151/sys/src/9/port/devbit.c:9,151990/05313/sys/src/9/port/devbit.c:9,15 (short | long | prev | next)
1990/0324    
 
#include	"gnot.h" 
 
1990/0329    
extern Font	defont0;	/* BUG */ 
1990/05313    
extern Font	*defont; 
1990/0329    
 
1990/0327    
/* 
1990/0329    
 * Device (#b/bitblt) is exclusive use on open, so no locks are necessary 
1990/05151/sys/src/9/port/devbit.c:24,301990/05313/sys/src/9/port/devbit.c:24,31
1990/0327    
 * followed by N blocks.  The bitmap pointer is zero if block is free.  
 */ 
1990/0324    
 
struct{ 
1990/05313    
struct 
{ 
1990/0324    
	Ref; 
1990/0327    
	Bitmap	*map;		/* arena */ 
	Bitmap	*free;		/* free list */ 
1990/05151/sys/src/9/port/devbit.c:53,771990/05313/sys/src/9/port/devbit.c:54,80
1990/0504    
	Rendez	r; 
}mouse; 
 
1990/05313    
Cursor	arrow = 
{ 
	{0, 0}, 
	{0xFF, 0xE0, 0xFF, 0xE0, 0xFF, 0xC0, 0xFF, 0x00, 
	 0xFF, 0x00, 0xFF, 0x80, 0xFF, 0xC0, 0xFF, 0xE0, 
	 0xE7, 0xF0, 0xE3, 0xF8, 0xC1, 0xFC, 0x00, 0xFE, 
	 0x00, 0x7F, 0x00, 0x3E, 0x00, 0x1C, 0x00, 0x08, 
	}, 
	{0x00, 0x00, 0x7F, 0xC0, 0x7F, 0x00, 0x7C, 0x00, 
	 0x7E, 0x00, 0x7F, 0x00, 0x6F, 0x80, 0x67, 0xC0, 
	 0x43, 0xE0, 0x41, 0xF0, 0x00, 0xF8, 0x00, 0x7C, 
	 0x00, 0x3E, 0x00, 0x1C, 0x00, 0x08, 0x00, 0x00, 
	} 
}; 
 
1990/0504    
struct{ 
	Cursor; 
	Lock; 
	int	visible;	/* on screen */ 
	Rectangle r;		/* location */ 
}cursor = 
{ 
	{{0, 0}, 
	{0xFFE0, 0xFFE0, 0xFFC0, 0xFF00, 
	 0xFF00, 0xFF80, 0xFFC0, 0xFFE0, 
	 0xE7F0, 0xE3F8, 0xC1FC, 0x00FE, 
	 0x007F, 0x003E, 0x001C, 0x0008, 
	}, 
	{0x0000, 0x7FC0, 0x7F00, 0x7C00, 
	 0x7E00, 0x7F00, 0x6F80, 0x67C0, 
	 0x43E0, 0x41F0, 0x00F8, 0x007C, 
	 0x003E, 0x001C, 0x0008, 0x0000, 
	}}, 
}; 
1990/05313    
}cursor; 
1990/0504    
 
ulong setbits[16]; 
Bitmap	set = 
1990/05151/sys/src/9/port/devbit.c:103,1091990/05313/sys/src/9/port/devbit.c:106,112
1990/0504    
	{0, 0, 16, 16} 
}; 
 
void	cursortobitmap(void); 
1990/05313    
void	Cursortocursor(Cursor*); 
1990/0504    
void	cursoron(int); 
void	cursoroff(int); 
1990/0505    
int	mousechanged(void*); 
1990/05151/sys/src/9/port/devbit.c:140,1461990/05313/sys/src/9/port/devbit.c:143,149
1990/0327    
	bit.words = ialloc(conf.nbitbyte, 0); 
	bit.nwords = conf.nbitbyte/sizeof(ulong); 
	bit.wfree = bit.words; 
1990/0504    
	cursortobitmap(); 
1990/05313    
	Cursortocursor(&arrow); 
1990/0324    
} 
 
void 
1990/05151/sys/src/9/port/devbit.c:148,1531990/05313/sys/src/9/port/devbit.c:151,159
1990/0324    
{ 
	lock(&bit); 
	unlock(&bit); 
1990/05313    
	if(screen.ldepth > 1) 
		panic("bitinit ldepth>1"); 
	cursorback.ldepth = screen.ldepth; 
1990/0504    
	cursoron(1); 
1990/0324    
} 
 
1990/05151/sys/src/9/port/devbit.c:192,1971990/05313/sys/src/9/port/devbit.c:198,204
1990/0327    
		bit.lastid = -1; 
1990/0329    
		bit.init = 1; 
1990/05151    
		bit.ref = 1; 
1990/05313    
		Cursortocursor(&arrow); 
1990/0324    
		unlock(&bit); 
1990/05151    
	}else 
1990/0324    
		incref(&bit); 
1990/05151/sys/src/9/port/devbit.c:341,3461990/05313/sys/src/9/port/devbit.c:348,354
1990/0504    
	int off; 
1990/0324    
	Point pt; 
	Rectangle rect; 
1990/05313    
	Cursor curs; 
1990/0327    
	Bitmap *bp, *src, *dst; 
1990/0324    
 
	if(c->qid == CHDIR) 
1990/05151/sys/src/9/port/devbit.c:368,3741990/05313/sys/src/9/port/devbit.c:376,382
1990/0327    
			if(m < 18) 
1990/0324    
				error(0, Ebadblt); 
1990/0327    
			v = *(p+1); 
			if(v != 0)	/* BUG */ 
1990/05313    
			if(v!=0 && v!=1)	/* BUG */ 
1990/0327    
				error(0, Ebadblt); 
			ws = 1<<(5-v);	/* pixels per word */ 
			if(bit.free == 0) 
1990/05151/sys/src/9/port/devbit.c:385,3931990/05313/sys/src/9/port/devbit.c:393,401
1990/0327    
				l = (t+rect.max.x+ws-1)/ws; 
1990/0324    
			} 
1990/0327    
			nw = l*Dy(rect); 
			if(bit.wfree+l+2 > bit.words+bit.nwords){ 
1990/05313    
			if(bit.wfree+2+nw > bit.words+bit.nwords){ 
1990/0327    
				bitcompact(); 
				if(bit.wfree+l+1 > bit.words+bit.nwords) 
1990/05313    
				if(bit.wfree+2+nw > bit.words+bit.nwords) 
1990/0327    
					error(0, Enobitstore); 
			} 
			bp = bit.free; 
1990/05151/sys/src/9/port/devbit.c:453,4581990/05313/sys/src/9/port/devbit.c:461,496
1990/0327    
			p += 31; 
			break; 
 
1990/05313    
		case 'c': 
			/* 
			 * cursorswitch 
			 *	'c'		1 
			 * nothing more: return to arrow; else 
			 * 	Point		8 
			 *	clr		32 
			 *	set		32 
			 */ 
			if(m == 1){ 
				cursoroff(1); 
				Cursortocursor(&arrow); 
				cursoron(1); 
				m -= 1; 
				p += 1; 
				break; 
			} 
			if(m < 73) 
				error(0, Ebadblt); 
			curs.offset.x = GLONG(p+1); 
			curs.offset.y = GLONG(p+5); 
			memcpy(curs.clr, p+9, 2*16); 
			memcpy(curs.set, p+41, 2*16); 
			cursoroff(1); 
			Cursortocursor(&curs); 
			cursoron(1); 
			m -= 73; 
			p += 73; 
			break; 
 
1990/0327    
		case 'f': 
			/* 
			 * free 
1990/05151/sys/src/9/port/devbit.c:502,5081990/05313/sys/src/9/port/devbit.c:540,546
1990/0329    
				error(0, Ebadblt); 
1990/0504    
			if(off) 
				cursoroff(1); 
1990/0329    
			string(dst, pt, &defont0/*BUG*/, (char*)p, v); 
1990/05313    
			string(dst, pt, defont/*BUG*/, (char*)p, v); 
1990/0504    
			if(off) 
				cursoron(1); 
1990/0329    
			q++; 
1990/05151/sys/src/9/port/devbit.c:622,6281990/05313/sys/src/9/port/devbit.c:660,666
1990/0327    
void 
bitfree(Bitmap *bp) 
{ 
	bp->base[1] = 0; 
1990/05313    
	bp->base[-1] = 0; 
1990/0327    
	bp->ldepth = -1; 
	bp->base = (ulong*)bit.free; 
	bit.free = bp; 
1990/05151/sys/src/9/port/devbit.c:633,6391990/05313/sys/src/9/port/devbit.c:671,676
1990/0327    
{ 
	ulong *p1, *p2; 
 
print("bitcompact\n"); 
	p1 = p2 = bit.words; 
	while(p2 < bit.wfree){ 
		if(p2[1] == 0){ 
1990/05151/sys/src/9/port/devbit.c:648,6651990/05313/sys/src/9/port/devbit.c:685,702
1990/0327    
		p1 += 2 + p1[0]; 
	} 
	bit.wfree = p1; 
print("bitcompact done\n"); 
1990/0329    
} 
 
void 
1990/0504    
cursortobitmap(void) 
1990/05313    
Cursortocursor(Cursor *c) 
1990/0329    
{ 
1990/0504    
	int i; 
 
	lock(&cursor); 
1990/05313    
	memcpy(&cursor, c, sizeof(Cursor)); 
1990/0504    
	for(i=0; i<16; i++){ 
		setbits[i] = cursor.set[i]<<16; 
		clrbits[i] = cursor.clr[i]<<16; 
1990/05313    
		setbits[i] = (c->set[2*i]<<24) + (c->set[2*i+1]<<16); 
		clrbits[i] = (c->clr[2*i]<<24) + (c->clr[2*i+1]<<16); 
1990/0504    
	} 
	unlock(&cursor); 
} 
1990/05151/sys/src/9/port/devbit.c:711,7171990/05313/sys/src/9/port/devbit.c:748,753
1990/0505    
mouseclock(void)	/* called spl6 */ 
1990/0504    
{ 
	int x, y; 
                 
	if(mouse.track && canlock(&cursor)){ 
		x = mouse.xy.x + mouse.dx; 
		if(x < screen.r.min.x) 


source code copyright © 1990-2005 Lucent Technologies; see license
Plan 9 distribution
comments to russ cox (rsc@swtch.com)