Plan 9 from Bell Labs’s /usr/web/sources/extra/9hist/carrera/screen.c

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


## diffname carrera/screen.c 1993/0906
## diff -e /dev/null /n/fornaxdump/1993/0906/sys/src/brazil/carrera/screen.c
0a
#include	"u.h"
#include	"../port/lib.h"
#include	"mem.h"
#include	"dat.h"
#include	"fns.h"
#include	"io.h"
#include	"ureg.h"
#include	"../port/error.h"

#include	<libg.h>
#include	<gnot.h>

#define	MINX	8

enum
{
	EMISCR=		0x3CC,		/* control sync polarity */
	EMISCW=		0x3C2,
	EFCW=		0x3DA,		/* feature control */
	EFCR=		0x3CA,
	GRX=		0x3CE,		/* index to graphics registers */
	GR=		0x3CF,		/* graphics registers */
	 Grms=		 0x04,		/*  read map select register */
	SRX=		0x3C4,		/* index to sequence registers */
	SR=		0x3C5,		/* sequence registers */
	 Smmask=	 0x02,		/*  map mask */
	CRX=		0x3D4,		/* index to crt registers */
	CR=		0x3D5,		/* crt registers */
	 Cvre=		 0x11,		/*  vertical retrace end */
	ARW=		0x3C0,		/* attribute registers (writing) */
	ARR=		0x3C1,		/* attribute registers (reading) */
	CMRX=		0x3C7,		/* color map read index */
	CMWX=		0x3C8,		/* color map write index */
	CM=		0x3C9,		/* color map data reg */
};

typedef struct VGAmode	VGAmode;
struct VGAmode
{
	uchar	general[2];
	uchar	sequencer[5];
	uchar	crt[0x19];
	uchar	graphics[9];
	uchar	attribute[0x15];
	uchar	special[12];
};

void	setmode(VGAmode*);

extern	struct GBitmap	gscreen;

VGAmode dfltmode = 
{
	/* general */
	0xef, 0x00, 
	/* sequence */
	0x03, 0x01, 0x0f, 0x00, 0x0e, 
	/* crt */
	0xa1, 0x7f, 0x7f, 0x85, 0x85, 0x96, 0x24, 0xf5, 
	0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
	0x02, 0x88, 0xff, 0x80, 0x60, 0xff, 0x25, 0xab, 
	0xff, 
	/* graphics */
	0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0f, 
	0xff, 
	/* attribute */
	0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 
	0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 
	0x01, 0x00, 0x0f, 0x00, 0x00,
	/* special */
	0x00, 0x00, 0xbc, 0x00, 0x00, 0x00, 0x28, 0x00, 
	0x0a, 0x00, 0x43, 0x1f, 
};

extern	GSubfont	defont0;
GSubfont		*defont;

static ulong rep(ulong, int);

struct{
	Point	pos;
	int	bwid;
}out;

Lock	screenlock;

GBitmap	gscreen =
{
	EISAUNCACHED(0xA0000),
	0,
	(1024*(1<<3))/32,
	3,
	{ 0, 0, 1024, 768 },
	{ 0, 0, 1024, 768 },
	0
};

static GBitmap hwcursor=
{
	0,		/* base filled in by malloc when needed */
	0,
	4,
	1,
	{0, 0, 64, 64},
	{0, 0, 64, 64}
};

uchar bdata[] =
{
	0xC0,
};

GBitmap bgrnd =
{
	(ulong*)bdata,
	0,
	4,
	3,
	{ 0, 0, 1, 1 },
	{ 0, 0, 1, 1 },
	0
};

/*
 *  a fatter than usual cursor for the safari
 */
Cursor fatarrow = {
	{ -1, -1 },
	{
		0xff, 0xff, 0x80, 0x01, 0x80, 0x02, 0x80, 0x0c, 
		0x80, 0x10, 0x80, 0x10, 0x80, 0x08, 0x80, 0x04, 
		0x80, 0x02, 0x80, 0x01, 0x80, 0x02, 0x8c, 0x04, 
		0x92, 0x08, 0x91, 0x10, 0xa0, 0xa0, 0xc0, 0x40, 
	},
	{
		0x00, 0x00, 0x7f, 0xfe, 0x7f, 0xfc, 0x7f, 0xf0, 
		0x7f, 0xe0, 0x7f, 0xe0, 0x7f, 0xf0, 0x7f, 0xf8, 
		0x7f, 0xfc, 0x7f, 0xfe, 0x7f, 0xfc, 0x73, 0xf8, 
		0x61, 0xf0, 0x60, 0xe0, 0x40, 0x40, 0x00, 0x00, 
	},
};

static Rectangle window;
static Point cursor;
static int h, w;
extern Cursor arrow;

void
gborder(GBitmap *l, Rectangle r, int i, Fcode c)
{
	if(i < 0){
		r = inset(r, i);
		i = -i;
	}
	gbitblt(l, r.min, l, Rect(r.min.x, r.min.y, r.max.x, r.min.y+i), c);
	gbitblt(l, Pt(r.min.x, r.max.y-i),
		l, Rect(r.min.x, r.max.y-i, r.max.x, r.max.y), c);
	gbitblt(l, Pt(r.min.x, r.min.y+i),
		l, Rect(r.min.x, r.min.y+i, r.min.x+i, r.max.y-i), c);
	gbitblt(l, Pt(r.max.x-i, r.min.y+i),
		l, Rect(r.max.x-i, r.min.y+i, r.max.x, r.max.y-i), c);
}

void
screenwin(void)
{
	gtexture(&gscreen, gscreen.r, &bgrnd, S);
	w = defont0.info[' '].width;
	h = defont0.height;

	window.min = Pt(100, 100);
	window.max = add(window.min, Pt(10+w*120, 10+h*60));

	gbitblt(&gscreen, window.min, &gscreen, window, Zero);
	window = inset(window, 5);
	cursor = window.min;
	window.max.y = window.min.y+((window.max.y-window.min.y)/h)*h;

	hwcurs = 0;
}

void
screeninit(void)
{
	setmode(&dfltmode);

	memmove(&arrow, &fatarrow, sizeof(fatarrow));

	/* save space; let bitblt do the conversion work */
	defont = &defont0;	
	gbitblt(&gscreen, Pt(0, 0), &gscreen, gscreen.r, 0);
	out.pos.x = MINX;
	out.pos.y = 0;
	out.bwid = defont0.info[' '].width;

	screenwin();
}

static void
scroll(void)
{
	int o;
	Rectangle r;

	o = 5*h;
	r = Rpt(Pt(window.min.x, window.min.y+o), window.max);
	gbitblt(&gscreen, window.min, &gscreen, r, S);
	r = Rpt(Pt(window.min.x, window.max.y-o), window.max);
	gbitblt(&gscreen, r.min, &gscreen, r, Zero);
	cursor.y -= o;
}

static void
screenputc(char *buf)
{
	int pos;

	switch(buf[0]) {
	case '\n':
		if(cursor.y+h >= window.max.y)
			scroll();
		cursor.y += h;
		screenputc("\r");
		break;
	case '\r':
		cursor.x = window.min.x;
		break;
	case '\t':
		pos = (cursor.x-window.min.x)/w;
		pos = 8-(pos%8);
		cursor.x += pos*w;
		break;
	case '\b':
		if(cursor.x-w >= 0)
			cursor.x -= w;
		break;
	default:
		if(cursor.x >= window.max.x-w)
			screenputc("\n");
		cursor = gsubfstring(&gscreen, cursor, &defont0, buf, S);
	}
}

#ifdef USEME
void
screenputs(char *s, int n)
{
	int i;
	Rune r;
	char buf[4];

	if((getstatus() & IEC) == 0) {
		/* don't deadlock trying to print in interrupt */
		if(!canlock(&screenlock))
			return;	
	}
	else
		lock(&screenlock);

	while(n > 0){
		i = chartorune(&r, s);
		if(i == 0){
			s++;
			--n;
			continue;
		}
		memmove(buf, s, i);
		buf[i] = 0;
		n -= i;
		s += i;
		screenputc(buf);
	}
	unlock(&screenlock);
}
#endif

/* replicate (from top) value in v (n bits) until it fills a ulong */
static ulong
rep(ulong v, int n)
{
	int o;
	ulong rv;

	rv = 0;
	for(o = 32 - n; o >= 0; o -= n)
		rv |= (v << o);
	return rv;
}

void
getcolor(ulong p, ulong *pr, ulong *pg, ulong *pb)
{
	ulong ans;

	/*
	 * The gnot says 0 is white (max intensity)
	 */
	if(gscreen.ldepth == 0){
		if(p == 0)
				ans = ~0;
		else
				ans = 0;
	}else{
		switch(p){
		case 0:		ans = ~0;		break;
		case 1:		ans = 0xAAAAAAAA;	break;
		case 2:		ans = 0x55555555;	break;
		default:	ans = 0;		break;
		}
	}
	*pr = *pg = *pb = ans;
}

int
setcolor(ulong p, ulong r, ulong g, ulong b)
{
	USED(p, r, g, b);
	return 0;	/* can't change mono screen colormap */
}

void
hwcursset(ulong *s, ulong *c, int ox, int oy)
{
	USED(s, c, ox, oy);
}

void
hwcursmove(int x, int y)
{
	USED(x, y);
}

/* only 1 flavor mouse */
void
mousectl(char *x)
{
	USED(x);
}

/* bits per pixel */
int
screenbits(void)
{
	return 1<<gscreen.ldepth;
}

void
mbbrect(Rectangle r)
{
	USED(r);
}

void
mbbpt(Point p)
{
	USED(p);
}

void
srout(int reg, int val)
{
	EISAOUTB(SRX, reg);
	EISAOUTB(SR, val);
}

void
grout(int reg, int val)
{
	EISAOUTB(GRX, reg);
	EISAOUTB(GR, val);
}

void
genout(int reg, int val)
{
	if(reg == 0)
		EISAOUTB(EMISCW, val);
	else if (reg == 1)
		EISAOUTB(EFCW, val);
}

void
arout(int reg, int val)
{
	uchar junk;

	junk = EISAINB(0x3DA);
	USED(junk);

	if (reg <= 0xf) {
		EISAOUTB(ARW, reg | 0x0);
		EISAOUTB(ARW, val);
		junk = EISAINB(0x3DA);
		USED(junk);
		EISAOUTB(ARW, reg | 0x20);
	} else {
		EISAOUTB(ARW, reg | 0x20);
		EISAOUTB(ARW, val);
	}
}

void
crout(int reg, int val)
{
	EISAOUTB(CRX, reg);
	EISAOUTB(CR, val);
}

void
setmode(VGAmode *v)
{
	int i;

	/* turn screen off (to avoid damage) */
	srout(1, 0x21);

	for(i = 0; i < sizeof(v->general); i++)
		genout(i, v->general[i]);

	for(i = 0; i < sizeof(v->sequencer); i++)
		if(i == 1)
			srout(i, v->sequencer[i]|0x20);
		else
			srout(i, v->sequencer[i]);

	crout(Cvre, 0);	/* allow writes to CRT registers 0-7 */
	for(i = 0; i < sizeof(v->crt); i++)
		crout(i, v->crt[i]);

	for(i = 0; i < sizeof(v->graphics); i++)
		grout(i, v->graphics[i]);

	for(i = 0; i < sizeof(v->attribute); i++)
		arout(i, v->attribute[i]);

	/* turn screen on */
	srout(1, v->sequencer[1]);
}
.
## diffname carrera/screen.c 1993/0907
## diff -e /n/fornaxdump/1993/0906/sys/src/brazil/carrera/screen.c /n/fornaxdump/1993/0907/sys/src/brazil/carrera/screen.c
434a

	EISAOUTB(0x3C6, 0xFF);	/* pel mask */
	EISAOUTB(0x3C8, 0x00);	/* pel write address */
	EISAOUTB(0x3bf, 0x03);	/* hercules compatibility reg */
	EISAOUTB(0x3d8, 0xa0);	/* display mode control register */

	srout(0x06, v->tseng.sr6);
	srout(0x07, v->tseng.sr7);
	i = EISAINB(0x3da); /* reset flip-flop. inp stat 1*/
	USED(i);
	arout(0x16, v->tseng.ar16);	/* misc */
	arout(0x17, v->tseng.ar17);	/* misc 1*/
	crout(0x31, v->tseng.crt31);	/* extended start. */
	crout(0x32, v->tseng.crt32);	/* extended start. */
	crout(0x33, v->tseng.crt33);	/* extended start. */
	crout(0x34, v->tseng.crt34);	/* stub: 46ee + other bits */
	crout(0x35, v->tseng.crt35);	/* overflow bits */
	crout(0x36, v->tseng.crt36);	/* overflow bits */
	crout(0x37, v->tseng.crt37);	/* overflow bits */
	EISAOUTB(0x3c3, v->tseng.viden);/* video enable */
.
426c
	/* allow writes to CRT registers 0-7 */
	crout(Cvre, 0);
.
416a
	EISAOUTB(0x3bf, 0x03);		/* hercules compatibility reg */
	EISAOUTB(0x3d8, 0xa0);		/* display mode control register */
	EISAOUTB(0x3cd, 0x00);		/* segment select */

	srout(0x00, srin(0x00) & 0xFD);	/* synchronous reset*/

.
396c
	}
	else {
.
378c
	else
	if (reg == 1)
.
365a
uchar
srin(ushort i) {
        EISAOUTB(SRX, i);
        return EISAINB(SR);
}

.
191a
iprint("done\n");
.
190c
	defont = &defont0;
iprint("gbitblt\n");	
.
188a
	scr = (uchar*)EISA(0xA0000);
iprint("%lux\n", scr);
*scr = 0xaa;
i = *scr;
iprint("%2.2ux\n", i);
*scr = 0x55;
i = *scr;
iprint("%2.2ux\n", i);

	for(j = 0; j < 768; j++)
		for(i = 0; i < 1024; i++)
			*(scr+i+(j*1024)) = i;

.
184a
	int i, j;
	uchar *scr;

.
124,126d
98,107d
89c
	EISA(0xA0000),
.
45a
	struct {
		uchar viden;
		uchar sr6;
		uchar sr7;
		uchar ar16;
		uchar ar17;
		uchar crt31;
		uchar crt32;
		uchar crt33;
		uchar crt34;
		uchar crt35;
		uchar crt36;
		uchar crt37;
	} tseng;
.
## diffname carrera/screen.c 1993/0908
## diff -e /n/fornaxdump/1993/0907/sys/src/brazil/carrera/screen.c /n/fornaxdump/1993/0908/sys/src/brazil/carrera/screen.c
491a
}

uchar
grin(ushort i)
{
	EISAOUTB(GRX, i);
	return EISAINB(GR);
}

uchar
arin(ushort i)
{
	uchar junk;
	junk = EISAINB(0x3DA);
	USED(junk);
	EISAOUTB(ARW, i | 0x20);
	return EISAINB(ARR);
}

uchar
crin(ushort i) {
	EISAOUTB(CRX, i);
	return EISAINB(CR);
}

void
getvmode(VGAmode *v)
{
	int i;

	v->general[0] = EISAINB(EMISCR);	/* misc output */
	v->general[1] = EISAINB(EFCR);	/* feature control */
	for(i = 0; i < sizeof(v->sequencer); i++)
		v->sequencer[i] = srin(i);
	for(i = 0; i < sizeof(v->crt); i++) 
		v->crt[i] = crin(i);
	for(i = 0; i < sizeof(v->graphics); i++) 
		v->graphics[i] = grin(i);
	for(i = 0; i < sizeof(v->attribute); i++)
		v->attribute[i] = arin(i);

	v->tseng.viden = EISAINB(0x3c3);
	v->tseng.sr6  = srin(6);
	v->tseng.sr7  = srin(7);
	v->tseng.ar16 = arin(0x16);
	v->tseng.ar17 = arin(0x17);
	v->tseng.crt31= crin(0x31);
	v->tseng.crt32= crin(0x32);
	v->tseng.crt33= crin(0x33);
	v->tseng.crt34= crin(0x34);
	v->tseng.crt35= crin(0x35);
	v->tseng.crt36= crin(0x36);
	v->tseng.crt37= crin(0x37);
}

void
writeregisters(VGAmode *v)
{
	int i;

	print("\t/* general */\n\t");
	for (i=0; i<sizeof(v->general); i++)
		print("0x%.2x, ", v->general[i]);
	print("\n\t/* sequence */\n\t");
	for (i=0; i<sizeof(v->sequencer); i++) {
		if (i>0 && i%8 == 0)
			print("\n\t");
		print("0x%.2x, ", v->sequencer[i]);
	}
	print("\n\t/* crt */\n\t");
	for (i=0; i<sizeof(v->crt); i++) {
		if (i>0 && i%8 == 0)
			print("\n\t");
		print("0x%.2x, ", v->crt[i]);
	}
	print("\n\t/* graphics */\n\t");
	for (i=0; i<sizeof(v->graphics); i++) {
		if (i>0 && i%8 == 0)
			print("\n\t");
		print("0x%.2x, ", v->graphics[i]);
	}
	print("\n\t/* attribute */\n\t");
	for (i=0; i<sizeof(v->attribute); i++) {
		if (i>0 && i%8 == 0)
			print("\n\t");
		print("0x%.2x, ", v->attribute[i]);
	}
	print("\n");
	print("\t/* special */\n");

	for (i=0; i<12; i++) {
		if (i%8 == 0)
			print("\n\t");
		print("0x%.2x, ", ((uchar*)(&v->tseng))[i]);
	}
	print("\n");
.
450,452d
440a
	for(i = 0; i < sizeof(v->general); i++)
		genout(i, v->general[i]);

.
386c
srin(ushort i)
{
.
193c
	scr = (uchar*)EISA(0xC0000);
.
190c
	getvmode(&x);
	writeregisters(&x);
return;
.
182a
void	getvmode(VGAmode *v);
void	writeregisters(VGAmode *v);
VGAmode x;

.
## diffname carrera/screen.c 1993/0909
## diff -e /n/fornaxdump/1993/0908/sys/src/brazil/carrera/screen.c /n/fornaxdump/1993/0909/sys/src/brazil/carrera/screen.c
458a

	for(i = 0; i < sizeof(v->general); i++)
		genout(i, v->general[i]);
.
448,450d
192a
	EISAOUTB(0x3c3, 1);
	delay(1);
	EISAOUTB(0x46e8, 0x8);

.
## diffname carrera/screen.c 1993/0910
## diff -e /n/fornaxdump/1993/0909/sys/src/brazil/carrera/screen.c /n/fornaxdump/1993/0910/sys/src/brazil/carrera/screen.c
196a
	setmode(&dfltmode);
.
193,195c
EISAOUTB(0x3C3, 1);
EISAOUTB(0x46e8, 8);
EISAOUTB(0x3bf, 1);
i = EISAINB(0x3b8);
print("=%2.2ux\n", i);
EISAOUTB(0x3bf, 3);
i = EISAINB(0x3b8);
print("=%2.2ux\n", i);
EISAOUTB(0x3bf, 1);
i = EISAINB(0x3d8);
print("=%2.2ux\n", i);
EISAOUTB(0x3bf, 3);
i = EISAINB(0x3d8);
print("=%2.2ux\n", i);
EISAOUTB(0x3d8, 0xa0);
.
## diffname carrera/screen.c 1993/0916
## diff -e /n/fornaxdump/1993/0910/sys/src/brazil/carrera/screen.c /n/fornaxdump/1993/0916/sys/src/brazil/carrera/screen.c
193,209d
148a
#define IOPORT	((uchar*)0xE0010000)

static uchar
inb(int port)
{
	return IOPORT[port^7];
}

static void
outb(int port, int val)
{
	IOPORT[port^7] = val;
}

.
## diffname carrera/screen.c 1993/0918
## diff -e /n/fornaxdump/1993/0916/sys/src/brazil/carrera/screen.c /n/fornaxdump/1993/0918/sys/src/brazil/carrera/screen.c
608d
603,606c
	inc = gscreen.width*4;
	off = r.min.y * inc + r.min.x;
	sp = ((uchar*)gscreen.base) + off;

	page = off>>16;
	off &= (1<<16)-1;
	hp = edisp = 0;
	for(y = r.min.y; y < r.max.y; y++){
		if(hp >= edisp){
			hp = ((uchar*)vgascreen.base) + off;
			edisp = ((uchar*)vgascreen.base) + 64*1024;
			EISAOUTB(0x3cd, (page<<4) | page);
			off = r.min.x;
			page++;
		}
		for(i = 0; i < len; i += 8)
			twizzle(sp+i, hp+i);
		hp += inc;
		sp += inc;
.
573,601c
	r.min.x &= ~7;
	len = r.max.x - r.min.x;
	len = (len+7)&~7;
	if(len <= 0)
		return;
.
568,571c
	if(r.min.x < 0)
		r.min.x = 0;
	if(r.min.y < 0)
		r.min.y = 0;
	if(r.max.x > gscreen.r.max.x)
		r.max.x = gscreen.r.max.x;
	if(r.max.y > gscreen.r.max.y)
		r.max.y = gscreen.r.max.y;
.
554,566c
	if(Dy(r) < 0)
		return;
.
543,552c
	r = mbb;
	mbb = NULLMBB;
.
541c
	uchar *sp, *hp, *edisp;
	int i, y, len, off, page, inc;
	Rectangle r;
.
539c
screenupdate(void)
.
532,535c
	in1 = *(ulong*)f;
	in2 = *(ulong*)(f+4);
	*(ulong*)t = swiz(in2);
	*(ulong*)(t+4) = swiz(in1);
.
525,530c
	ulong in1, in2;
.
522,523c
void
twizzle(uchar *f, uchar *t)
.
515,520c
#define swiz(s)	(s<<24)|((s>>8)&0xff00)|((s<<8)&0xff0000)|(s>>24)
.
492a

.
387,398d
356,357c
	p &= (1<<(1<<gscreen.ldepth))-1;
	colormap[p][0] = r;
	colormap[p][1] = g;
	colormap[p][2] = b;
	EISAOUTB(CMWX, 255-p);
	EISAOUTB(CM, r>>(32-6));
	EISAOUTB(CM, g>>(32-6));
	EISAOUTB(CM, b>>(32-6));
	return ~0;
.
332,350c
	p &= (1<<(1<<gscreen.ldepth))-1;
	*pr = colormap[p][0];
	*pg = colormap[p][1];
	*pb = colormap[p][2];
.
316,328d
314d
311a
	if(isscroll) {
		mbb = window;
		isscroll = 0;
	}
	else
		mbbpt(Pt(cursor.x, cursor.y+h));

	screenupdate();
.
299c
	mbbpt(cursor);
	while(n > 0) {
.
291c
	if((getstatus() & IE) == 0) {
.
283d
278a

.
251a
void
mbbrect(Rectangle r)
{
	if (r.min.x < mbb.min.x)
		mbb.min.x = r.min.x;
	if (r.min.y < mbb.min.y)
		mbb.min.y = r.min.y;
	if (r.max.x > mbb.max.x)
		mbb.max.x = r.max.x;
	if (r.max.y > mbb.max.y)
		mbb.max.y = r.max.y;
}

void
mbbpt(Point p)
{
	if (p.x < mbb.min.x)
		mbb.min.x = p.x;
	if (p.y < mbb.min.y)
		mbb.min.y = p.y;
	if (p.x >= mbb.max.x)
		mbb.max.x = p.x+1;
	if (p.y >= mbb.max.y)
		mbb.max.y = p.y+1;
}

.
249a
	isscroll = 1;
.
234a
	memmove(&arrow, &fatarrow, sizeof(fatarrow));

.
230,233d
222,228d
213,220c
	/* allocate a new soft bitmap area */
	gscreen.base = xalloc(1024*1024);
.
208,211c
	for(i = 0; i < 256; i++)
		setcolor(i, x3to32(i>>5), x3to32(i>>2), x3to32(i<<1));
.
204,205c
	int i;
.
200a
	x = x&7;
	x= (x<<3)|x;
	y = (x<<(32-6))|(x<<(32-12))|(x<<(32-18))|(x<<(32-24))|(x<<(32-30));
	return y;
}

.
197,199c
/*
 *  expand 3 and 6 bits of color to 32
 */
static ulong
x3to32(uchar x)
{
	ulong y;
.
194a

	mbb = gscreen.r;
	screenupdate();
.
193d
186,187c
	window.min = Pt(50, 50);
	window.max = add(window.min, Pt(10+w*100, 10+h*40));
.
184a
	defont = &defont0;	
.
164,179d
149,162d
147a
static ulong colormap[256][3];
static Rectangle mbb;
static Rectangle NULLMBB = {10000, 10000, -10000, -10000};
static int isscroll;
.
102a
	0,
	0,
	(1024*(1<<3))/32,
	3,
	{ 0, 0, 1024, 768 },
	{ 0, 0, 1024, 768 },
	0
};

GBitmap	vgascreen =
{
.
92,98d
45d
## diffname carrera/screen.c 1993/0930
## diff -e /n/fornaxdump/1993/0918/sys/src/brazil/carrera/screen.c /n/fornaxdump/1993/0930/sys/src/brazil/carrera/screen.c
550a
}

/*
 * graphics
 */
void
screenload(Rectangle r, uchar *data, long n)
{
	int y, ws, l, t, lpart, rpart, mx, m, mr;
	uchar *q;

	if(!rectclip(&r, gscreen.r))
		return;
	lock(&screenlock);
	ws = 8>>gscreen.ldepth;	/* pixels per byte */
	/* set l to number of bytes of data per scan line */
	if(r.min.x >= 0)
		l = (r.max.x+ws-1)/ws - r.min.x/ws;
	else{		/* make positive before divide */
		t = (-r.min.x)+ws-1;
		t = (t/ws)*ws;
		l = (t+r.max.x+ws-1)/ws;
	}
	if(n != l*Dy(r)){
		unlock(&screenlock);
		error("bad tile size");
	}
	q = gbaddr(&gscreen, r.min);
	mx = 7>>gscreen.ldepth;
	lpart = (r.min.x & mx) << gscreen.ldepth;
	rpart = (r.max.x & mx) << gscreen.ldepth;
	m = 0xFF >> lpart;
	mr = 0xFF ^ (0xFF >> rpart);
	/* may need to do bit insertion on edges */
	if(l == 1){	/* all in one byte */
		if(rpart)
			m ^= 0xFF >> rpart;
		for(y=r.min.y; y<r.max.y; y++){
			*q ^= (*data^*q) & m;
			q += gscreen.width*sizeof(ulong);
			data++;
		}
	}else if(lpart==0 && rpart==0){	/* easy case */
		for(y=r.min.y; y<r.max.y; y++){
			memmove(q, data, l);
			q += gscreen.width*sizeof(ulong);
			data += l;
		}
	}else if(rpart==0){
		for(y=r.min.y; y<r.max.y; y++){
			*q ^= (*data^*q) & m;
			if(l > 1)
				memmove(q+1, data+1, l-1);
			q += gscreen.width*sizeof(ulong);
			data += l;
		}
	}else if(lpart == 0){
		for(y=r.min.y; y<r.max.y; y++){
			if(l > 1)
				memmove(q, data, l-1);
			q[l-1] ^= (data[l-1]^q[l-1]) & mr;
			q += gscreen.width*sizeof(ulong);
			data += l;
		}
	}else for(y=r.min.y; y<r.max.y; y++){
			*q ^= (*data^*q) & m;
			if(l > 2)
				memmove(q+1, data+1, l-2);
			q[l-1] ^= (data[l-1]^q[l-1]) & mr;
			q += gscreen.width*sizeof(ulong);
			data += l;
		}
	mbbrect(r);
	screenupdate();
	unlock(&screenlock);
.
316,317d
298d
280a
	mbbpt(Pt(cursor.x, cursor.y+h));
.
255a
	mbbpt(cursor);
.
## diffname carrera/screen.c 1993/1001
## diff -e /n/fornaxdump/1993/0930/sys/src/brazil/carrera/screen.c /n/fornaxdump/1993/1001/sys/src/brazil/carrera/screen.c
273c
		if(cursor.x-w >= window.min.x)
.
## diffname carrera/screen.c 1993/1003
## diff -e /n/fornaxdump/1993/1001/sys/src/brazil/carrera/screen.c /n/fornaxdump/1993/1003/sys/src/brazil/carrera/screen.c
549a
}

void
mousescreenupdate(void)
{
	if(canlock(&screenlock) == 0)
		return;

	screenupdate();
	unlock(&screenlock);
.
545,546c
		for(i = 0; i < len; i += 8) {
			s = (ulong*)(sp+i);
			h = (ulong*)(hp+i);
			in1 = s[0];
			in2 = s[1];
			h[0] = swiz(in2);
			h[1] = swiz(in1);
		}
.
536c
	hp = 0;
	edisp = 0;
.
531a

.
507d
504a
	Rectangle r;
	ulong *s, *h, in1, in2;
.
205,206d
131,146d
## diffname carrera/screen.c 1993/1006
## diff -e /n/fornaxdump/1993/1003/sys/src/brazil/carrera/screen.c /n/fornaxdump/1993/1006/sys/src/brazil/carrera/screen.c
143c
	memset(gscreen.base, 0xC0, gscreen.width*sizeof(ulong)*Dy(gscreen.r));
.
115,130d
## diffname carrera/screen.c 1993/1008
## diff -e /n/fornaxdump/1993/1006/sys/src/brazil/carrera/screen.c /n/fornaxdump/1993/1008/sys/src/brazil/carrera/screen.c
607a
	cursoron(1);
.
561a
	cursoroff(1);
.
## diffname carrera/screen.c 1993/1026
## diff -e /n/fornaxdump/1993/1008/sys/src/brazil/carrera/screen.c /n/fornaxdump/1993/1026/sys/src/brazil/carrera/screen.c
609c
	screenupdate();
	cursorunlock();
.
603,604c
				memmove(q+1, data+1, tl-2);
			q[tl-1] ^= (data[tl-1]^q[l-1]) & mr;
.
594,596c
			if(tl > 1)
				memmove(q, data, tl-1);
			q[tl-1] ^= (data[tl-1]^q[tl-1]) & mr;
.
587,588c
			if(tl > 1)
				memmove(q+1, data+1, tl-1);
.
580c
			memmove(q, data, tl);
.
576c
			data += l;
.
549,562c
	cursorlock(r);
	screenupdate();
.
546c
	if(!rectclip(&r, gscreen.r) || tl<=0)
.
543c
	int y, lpart, rpart, mx, m, mr;
.
541c
screenload(Rectangle r, uchar *data, int tl, int l)
.
538c
 * paste tile into screen.
 * tile is at location r, first pixel in *data.  tl is length of scan line to insert,
 * l is amount to advance data after each scan line.
.
536a
extern	cursorlock(Rectangle);
extern	cursorunlock(void);
.
## diffname carrera/screen.c 1993/1221
## diff -e /n/fornaxdump/1993/1026/sys/src/brazil/carrera/screen.c /n/fornaxdump/1993/1221/sys/src/brazil/carrera/screen.c
594c
			if(tl > 2)
.
564c
			m &= mr;
.
458,468d
127d
108,111c
	(1280*(1<<0))/32,
	0,
	{ 0, 0, 1280, 1024 },
	{ 0, 0, 1280, 1024 },
.
97,100c
	(1280*(1<<0))/32,
	0,
	{ 0, 0, 1280, 1024 },
	{ 0, 0, 1280, 1024 },
.
85c
	0x0a, 0x9b, 0x43, 0x1f, 
.
80,82c
	0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, 
	0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 
	0x01, 0x00, 0x0f, 0x00, 0x00, 
.
77c
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 
.
72,74c
	0xcb, 0x9f, 0xa0, 0x8e, 0xa9, 0x04, 0x4f, 0x52, 
	0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
	0x11, 0x89, 0xff, 0x50, 0x00, 0x09, 0x46, 0xc3, 
.
70c
	0x03, 0x01, 0x0f, 0x00, 0x06, 
.
68c
	0x23, 0x00, 
.
13,14d
## diffname carrera/screen.c 1993/1222
## diff -e /n/fornaxdump/1993/1221/sys/src/brazil/carrera/screen.c /n/fornaxdump/1993/1222/sys/src/brazil/carrera/screen.c
582c
			q[tl-1] ^= (data[tl-1]^q[tl-1]) & mr;
.
492,493c
	for(y = r.min.y; y < r.max.y; y++) {
		if(hp >= edisp) {
.
482a
	pixshft = 3-gscreen.ldepth;
	len = (len>>pixshft)+8;
	r.min.x = (r.min.x>>pixshft) & ~7;
	
.
460c
	int i, y, len, off, page, inc, pixshft;
.
301c
	EISAOUTB(CMWX, p);
.
164a
	gscreen.ldepth = 3;
	for(i = 0; i < 16; i++){
		x = x6to32((i*63)/15);
		setcolor(i, x, x, x);
	}
	gscreen.ldepth = 0;

.
162,163d
159c
	int i, x;
.
155a
	x = x&0x3f;
	y = (x<<(32-6))|(x<<(32-12))|(x<<(32-18))|(x<<(32-24))|(x<<(32-30));
	return y;
}

.
154a
static ulong
x6to32(uchar x)
{
	ulong y;
.
124a
	int i;

	for(i = 0; i < 768; i += 2) {
		memset(gscreen.base+(i*gscreen.width), 0xCC, 160);
		memset(gscreen.base+((i+1)*gscreen.width), 0xCC^0xff, 160);
	}
.
108,109c
	{ 0, 0, 1024, 768 },
	{ 0, 0, 1024, 768 },
.
106c
	(1024*(1<<0))/32,
.
97,98c
	{ 0, 0, 1024, 768 },
	{ 0, 0, 1024, 768 },
.
95c
	(1024*(1<<0))/32,
.
83c
	0x0a, 0x00, 0x43, 0x1f, 
.
70,72c
	0xa1, 0x7f, 0x7f, 0x85, 0x85, 0x96, 0x24, 0xf5, 
	0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
	0x02, 0x88, 0xff, 0x40, 0x00, 0xff, 0x25, 0xc3, 
.
65,66c
	0xef, 0x00, 
.
## diffname carrera/screen.c 1993/1224
## diff -e /n/fornaxdump/1993/1222/sys/src/brazil/carrera/screen.c /n/fornaxdump/1993/1224/sys/src/brazil/carrera/screen.c
526,527c
			in1 = ~s[0];
			in2 = ~s[1];
.
446c
	EISAOUTB(0x3C6, 0x0F);	/* pel mask */
.
77,78c
	0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 
	0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 
.
## diffname carrera/screen.c 1993/1228
## diff -e /n/fornaxdump/1993/1224/sys/src/brazil/carrera/screen.c /n/fornaxdump/1993/1228/sys/src/brazil/carrera/screen.c
550c
 * tile is at location r, first pixel in *data. 
 * tl is length of scan line to insert,
.
186d
159a

.
88,89d
86d
84a
	Lock		screenlock;
	GSubfont*	defont;
.
## diffname carrera/screen.c 1993/1230
## diff -e /n/fornaxdump/1993/1228/sys/src/brazil/carrera/screen.c /n/fornaxdump/1993/1230/sys/src/brazil/carrera/screen.c
525,526c
			in1 = s[0];
			in2 = s[1];
.
445c
	switch(gscreen.ldepth){
	case 3:
		EISAOUTB(0x3C6, 0xFF);	/* pel mask */
		break;
	default:
		EISAOUTB(0x3C6, 0x0F);	/* pel mask */
		break;
	}
.
315c
	ulong x;

	switch(gscreen.ldepth){
	default:
		x = 0xf;
		break;
	case 3:
		x = 0xff;
		break;
	}
	p &= x;
	p ^= x;
.
306c
	ulong x;

	switch(gscreen.ldepth){
	default:
		x = 0xf;
		break;
	case 3:
		x = 0xff;
		break;
	}
	p &= x;
	p ^= x;
.
182d
177d
174a
	gscreen.ldepth = 0;

.
## diffname carrera/screen.c 1994/0210
## diff -e /n/fornaxdump/1993/1230/sys/src/brazil/carrera/screen.c /n/fornaxdump/1994/0210/sys/src/brazil/carrera/screen.c
638,641d
591,592c

.
589a

.
586a
	int y, lpart, rpart, mx, m, mr;
.
585d
575a

.
433,573d
429,430c
	return 1<<gscreen.ldepth;
.
426,427c
int
screenbits(void)
.
410,423c
	x += 379;		/* adjusted by experiment */
	y += 11;		/* adjusted by experiment */
	d->cr1 = 03;
	d->cr0 = 01;
	d->cr2 = x&0xFF;
	d->cr2 = (x>>8)&0xF;
	d->cr2 = y&0xFF;
	d->cr2 = (y>>8)&0xF;
.
405,408c
	d = DAC;
.
398,403c
	Dac *d;
.
396c
hwcursmove(int x, int y)
.
388,392c
	d = DAC;
	/* have to set y offscreen before writing cursor bits */
	d->cr1 = 0x03;
	d->cr0 = 0x03;
	ylow = d->cr2;
	yhigh = d->cr2;
	d->cr1 = 0x03;
	d->cr0 = 0x03;
	d->cr2 = 0xFF;
	d->cr2 = 0xFF;
	/* now set the bits */
	d->cr1 = 0x04;
	d->cr0 = 0x00;
	for(x = 0; x < 1024; x++)
		d->cr2 = ((uchar *)hwcursor.base)[x];
	/* set y back */
	d->cr1 = 0x03;
	d->cr0 = 0x03;
	d->cr2 = ylow;
	d->cr2 = yhigh;
	free(hwcursor.base);
.
381,386c
	hwcursor.base = (ulong *)malloc(1024);
	if(hwcursor.base == 0)
		error(Enomem);
	/* hw cursor is 64x64 with hot point at (32,32) */
	org = add(Pt(32,32), Pt(offx,offy)); 
	for(x = 0; x < 16; x++)
		for(y = 0; y < 16; y++) {
			spix = (s[y]>>(31-(x&0x1F)))&1;
			cpix = (c[y]>>(31-(x&0x1F)))&1;
			dpix = (spix<<1) | cpix;
			gpoint(&hwcursor, add(Pt(x,y), org), dpix, S);
		}
.
377,379c
	Dac *d;
	int x, y;
	Point org;
	uchar ylow, yhigh;
	ulong spix, cpix, dpix;
.
375c
hwcursset(ulong *s, ulong *c, int offx, int offy)
.
367,373d
360,364c
	rv = 0;
	for(o = 32 - n; o >= 0; o -= n)
		rv |= (v << o);
	return rv;
.
357,358c
	int o;
	ulong rv;
.
354,355c
/* replicate (from top) value in v (n bits) until it fills a ulong */
static ulong
rep(ulong v, int n)
.
348,351c
	d->cr0 = revtab0[p & 0xFF];
	d->cr1 = 0;
	d->cr3 = r >> 24;
	d->cr3 = g >> 24;
	d->cr3 = b >> 24;
	return 1;
.
328,346c
	d = DAC;
.
326c
	Dac *d;
	extern uchar revtab0[];
.
308,320c
	d = DAC;

	d->cr0 = revtab0[p & 0xFF];
	d->cr1 = 0;
	r = d->cr3;
	g = d->cr3;
	b = d->cr3;
	*pr = (r<<24) | (r<<16) | (r<<8) | r;
	*pg = (g<<24) | (g<<16) | (g<<8) | g;
	*pb = (b<<24) | (b<<16) | (b<<8) | b;
.
306c
	Dac *d;
	uchar r, g, b;
	extern uchar revtab0[];
.
302a
uchar revtab0[] = {
 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8,
 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4,
 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4,
 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec,
 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc,
 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2,
 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2,
 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea,
 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa,
 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6,
 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6,
 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee,
 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe,
 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1,
 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1,
 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9,
 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9,
 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5,
 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5,
 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed,
 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd,
 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3,
 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3,
 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb,
 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb,
 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7,
 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7,
 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef,
 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff,
};

.
294,299d
281c
	while(n > 0){
.
263d
260d
254c
		if(cursor.x-w >= 0)
.
237d
206,231d
203d
187a
	for(i = 0; i<256; i++) {
		r = ~rep((i>>5) & 7, 3);
		g = ~rep((i>>2) & 7, 3);
		b = ~rep(i & 3, 2);
		setcolor(i, r, g, b);
	}
	setcolor(85, 0xAAAAAAAA, 0xAAAAAAAA, 0xAAAAAAAA);
	setcolor(170, 0x55555555, 0x55555555, 0x55555555);

.
186a
	out.pos.x = MINX;
	out.pos.y = 0;
	out.bwid = defont0.info[' '].width;
.
179,185c
	defont = &defont0;	
.
177c
	memmove(&arrow, &fatarrow, sizeof(fatarrow));
.
175c
	dacinit();
.
173c
	int i;
	ulong r, g, b;
.
165,167c
	/* Cursor programming */
	d->cr0 = 0x00;
	d->cr1 = 0x03;
	d->cr2 = 0xC0;
	for(i = 0; i < 12; i++)
		d->cr2 = 0;

	/* Load Cursor Ram */
	d->cr0 = 0x00;
	d->cr1 = 0x04;
	for(i = 0; i < 0x400; i++)
		d->cr2 = 0xff;

	for(i = 0; i<256; i++) {
		r = ~rep((i>>5) & 7, 3);
		g = ~rep((i>>2) & 7, 3);
		b = ~rep(i & 3, 2);
		setcolor(i, r, g, b);
	}
	setcolor(85, 0xAAAAAAAA, 0xAAAAAAAA, 0xAAAAAAAA);
	setcolor(170, 0x55555555, 0x55555555, 0x55555555);

	/* Overlay Palette Ram */
	d->cr0 = 0x00;
	d->cr1 = 0x01;
	for(i = 0; i < 0x10; i++) {
		d->cr2 = 0xff;
		d->cr2 = 0xff;
		d->cr2 = 0xff;
	}

	/* Overlay Palette Ram */
	d->cr0 = 0x81;
	d->cr1 = 0x01;
	for(i = 0; i < 3; i++) {
		d->cr2 = 0xff;
		d->cr2 = 0xff;
		d->cr2 = 0xff;
	}
.
160,163c
	/* Control registers */
	d->cr0 = 0x01;
	d->cr1 = 0x02;
	for(i = 0; i < sizeof s1; i++)
		d->cr2 = s1[i];
.
154,158c
	d = DAC;
.
152c
	Dac *d;
	int i;
	ulong r, g, b;
.
146,150c
void
dacinit(void)
.
142,143c
	hwcurs = 1;
	d = DAC;
	/* cursor color 1: white */
	d->cr1 = 0x01;
	d->cr0 = 0x81;
	d->cr2 = 0xFF;
	d->cr2 = 0xFF;
	d->cr2 = 0xFF;
	/* cursor color 2: noir */
	d->cr1 = 0x01;
	d->cr0 = 0x82;
	d->cr2 = 0;
	d->cr2 = 0;
	d->cr2 = 0;
	/* cursor color 3: schwarz */
	d->cr1 = 0x01;
	d->cr0 = 0x83;
	d->cr2 = 0;
	d->cr2 = 0;
	d->cr2 = 0;
	/* initialize with all-transparent cursor */
	memset(zbuf, 0, sizeof zbuf);
	hwcursset(zbuf, zbuf, 0, 0);
	/* enable both planes of cursor */
	d->cr1 = 0x03;
	d->cr0 = 0x00;
	d->cr2 = 0xc0;
.
140d
133,134c
	window.min = Pt(100, 100);
	window.max = add(window.min, Pt(10+w*120, 10+h*60));
.
131d
125,128c
	gtexture(&gscreen, gscreen.r, &bgrnd, S);
.
123c
	Dac *d;
	ulong zbuf[16];
.
120a
gborder(GBitmap *l, Rectangle r, int i, Fcode c)
{
	if(i < 0){
		r = inset(r, i);
		i = -i;
	}
	gbitblt(l, r.min, l, Rect(r.min.x, r.min.y, r.max.x, r.min.y+i), c);
	gbitblt(l, Pt(r.min.x, r.max.y-i),
		l, Rect(r.min.x, r.max.y-i, r.max.x, r.max.y), c);
	gbitblt(l, Pt(r.min.x, r.min.y+i),
		l, Rect(r.min.x, r.min.y+i, r.min.x+i, r.max.y-i), c);
	gbitblt(l, Pt(r.max.x-i, r.min.y+i),
		l, Rect(r.max.x-i, r.min.y+i, r.max.x, r.max.y-i), c);
}

void
.
115,118d
110a
Cursor fatarrow = {
	{ -1, -1 },
	{
		0xff, 0xff, 0x80, 0x01, 0x80, 0x02, 0x80, 0x0c, 
		0x80, 0x10, 0x80, 0x10, 0x80, 0x08, 0x80, 0x04, 
		0x80, 0x02, 0x80, 0x01, 0x80, 0x02, 0x8c, 0x04, 
		0x92, 0x08, 0x91, 0x10, 0xa0, 0xa0, 0xc0, 0x40, 
	},
	{
		0x00, 0x00, 0x7f, 0xfe, 0x7f, 0xfc, 0x7f, 0xf0, 
		0x7f, 0xe0, 0x7f, 0xe0, 0x7f, 0xf0, 0x7f, 0xf8, 
		0x7f, 0xfc, 0x7f, 0xfe, 0x7f, 0xfc, 0x73, 0xf8, 
		0x61, 0xf0, 0x60, 0xe0, 0x40, 0x40, 0x00, 0x00, 
	},
};

.
106,107c
	4,
	3,
	{ 0, 0, 1, 1 },
	{ 0, 0, 1, 1 },
.
104c
	4,
	1,
	{0, 0, 64, 64},
	{0, 0, 64, 64}
};

uchar bdata[] =
{
	0xC0,
};

GBitmap bgrnd =
{
	(ulong*)bdata,
.
102c
	0,		/* base filled in by malloc when needed */
.
100c
static GBitmap hwcursor=
.
92,96c
	512,
	3,
	{ 0, 0, 1599, 1239 },
	{ 0, 0, 1599, 1239 },
.
90a
	Screenvirt+0x00017924,
.
88a
struct{
	Point	pos;
	int	bwid;
}out;

Lock	screenlock;

.
87a
static	ulong		rep(ulong, int);
.
61,85d
59c
char s1[] = { 0x40, 0x00, 0xC0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
.
38,56c
	uchar	pad0[7];
	uchar	cr0;
	uchar	pad1[7];
	uchar	cr1;
	uchar	pad2[7];
	uchar	cr2;
	uchar	pad3[7];
	uchar	cr3;
.
35,36c
#define DAC	((Dac*)BTDac)
typedef struct Dac Dac;
struct Dac
.
13,33c
#define	MINX	8
.
11a
#include	"screen.h"
.
## diffname carrera/screen.c 1994/0211
## diff -e /n/fornaxdump/1994/0210/sys/src/brazil/carrera/screen.c /n/fornaxdump/1994/0211/sys/src/brazil/carrera/screen.c
30c
char s1[] = { 0x00, 0x00, 0xC0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
.
## diffname carrera/screen.c 1994/0213
## diff -e /n/fornaxdump/1994/0211/sys/src/brazil/carrera/screen.c /n/fornaxdump/1994/0213/sys/src/brazil/carrera/screen.c
459c
	x += 371;		/* adjusted by experiment */
.
45c
	Screenvirt+0x00017918,
.
## diffname carrera/screen.c 1994/0215
## diff -e /n/fornaxdump/1994/0213/sys/src/brazil/carrera/screen.c /n/fornaxdump/1994/0215/sys/src/brazil/carrera/screen.c
122a
	memset(Screenvirt, 0, 3*1024*1024);

.
## diffname carrera/screen.c 1994/0216
## diff -e /n/fornaxdump/1994/0215/sys/src/brazil/carrera/screen.c /n/fornaxdump/1994/0216/sys/src/brazil/carrera/screen.c
133a
	for(i = 0; i < h+6; i += 2) {
		y = window.min.y+i;
		gsegment(&gscreen, Pt(window.min.x, y), Pt(window.max.x, y), ~0, F);
	}
	p = add(window.min, Pt(10, 2));
	gsubfstring(&gscreen, p, &defont0, "Brazil Console ", S);
	window.min.y += h+6;
.
132a
	gborder(&gscreen, window, 4, F);
.
131a
	gbitblt(&gscreen, add(window.min, Pt(5, 5)), &gscreen, window, F);
.
130c
	window.max = add(window.min, Pt(10+w*80, 10+h*40));
.
123c
	memset((void*)Screenvirt, 0xff, 3*1024*1024);
.
120a
	Point p;
	int i, y;
.
## diffname carrera/screen.c 1994/0227
## diff -e /n/fornaxdump/1994/0216/sys/src/brazil/carrera/screen.c /n/fornaxdump/1994/0227/sys/src/brazil/carrera/screen.c
132c
	window.max = add(window.min, Pt(10+w*120, 10+h*60));
.
## diffname carrera/screen.c 1994/0228
## diff -e /n/fornaxdump/1994/0227/sys/src/brazil/carrera/screen.c /n/fornaxdump/1994/0228/sys/src/brazil/carrera/screen.c
472c
	x += 295;		/* adjusted by experiment */
.
49,50c
	{ 0, 0, 1599, 1240 },
	{ 0, 0, 1599, 1240 },
.
45c
	Screenvirt+0x000178cc,
.
## diffname carrera/screen.c 1994/0306
## diff -e /n/fornaxdump/1994/0228/sys/src/brazil/carrera/screen.c /n/fornaxdump/1994/0306/sys/src/brazil/carrera/screen.c
472c
	x += 380;		/* adjusted by experiment */
.
49,50c
	{ 0, 0, 1599, 1239 },
	{ 0, 0, 1599, 1239 },
.
45c
	Screenvirt+0x00017924,
.
## diffname carrera/screen.c 1994/0401
## diff -e /n/fornaxdump/1994/0306/sys/src/brazil/carrera/screen.c /n/fornaxdump/1994/0401/sys/src/brazil/carrera/screen.c
297a
		}
.
296c
		if(cursor.x-w >= 0){
			r.min.x = cursor.x-w;
			r.max.x = cursor.x;
			r.min.y = cursor.y;
			r.max.y = cursor.y+defont0.height;
			gbitblt(&gscreen, r.min, &gscreen, r, Zero);
.
278a
	Rectangle r;
.
49,50c
	{ 0, 0, 1600, 1240 },
	{ 0, 0, 1600, 1240 },
.
## diffname carrera/screen.c 1994/0407
## diff -e /n/fornaxdump/1994/0401/sys/src/brazil/carrera/screen.c /n/fornaxdump/1994/0407/sys/src/brazil/carrera/screen.c
516,559c
	for(y=r.min.y; y<r.max.y; y++){
		memmove(q, data, tl);
		q += gscreen.width*sizeof(ulong);
		data += l;
	}
.
514d
508c
	int y;
.
502a
 * gscreen.ldepth is known to be >= 3
.
## diffname carrera/screen.c 1994/0412
## diff -e /n/fornaxdump/1994/0407/sys/src/brazil/carrera/screen.c /n/fornaxdump/1994/0412/sys/src/brazil/carrera/screen.c
517a
		q += gscreen.width*sizeof(ulong);
		data += l;
	}
	unlock(&screenlock);
}

/*
 * get a tile from screen memory.
 * tile is at location r, first pixel in *data. 
 * tl is length of scan line to insert,
 * l is amount to advance data after each scan line.
 * gscreen.ldepth is known to be >= 3
 */
void
screenunload(Rectangle r, uchar *data, int tl, int l, int dolock)
{
	uchar *q;
	int y;

	USED(dolock);

	if(!rectclip(&r, gscreen.r) || tl<=0)
		return;

	lock(&screenlock);
	q = gbaddr(&gscreen, r.min);
	for(y=r.min.y; y<r.max.y; y++){
		memmove(data, q, tl);
.
510a
	USED(dolock);

.
506c
screenload(Rectangle r, uchar *data, int tl, int l, int dolock)
.
## diffname carrera/screen.c 1994/0413
## diff -e /n/fornaxdump/1994/0412/sys/src/brazil/carrera/screen.c /n/fornaxdump/1994/0413/sys/src/brazil/carrera/screen.c
545c
	q = byteaddr(&gscreen, r.min);
.
541,543d
531c
 * gscreen.ldepth is known to be >= 3.
 * screenunload() doesn't clip, so must be
 * called correctly.
.
517c
	q = byteaddr(&gscreen, r.min);
.
446c
			point(&hwcursor, add(Pt(x,y), org), dpix, S);
.
309c
		cursor = subfstring(&gscreen, cursor, &defont0, buf, S);
.
302c
			bitblt(&gscreen, r.min, &gscreen, r, Zero);
.
271c
	bitblt(&gscreen, r.min, &gscreen, r, Zero);
.
269c
	bitblt(&gscreen, window.min, &gscreen, r, S);
.
243,244c
	bitblt(&gscreen, Pt(0, 0), &gscreen, gscreen.r, 0);
.
143c
	subfstring(&gscreen, p, &defont0, "Brazil Console ", S);
.
140c
		bitblt(&gscreen, Pt(window.min.x, y),
			&gscreen, Rect(window.min.x, y, window.max.x, y+1), F);
.
134,136c
	bitblt(&gscreen, add(window.min, Pt(5, 5)), &gscreen, window, F);
	bitblt(&gscreen, window.min, &gscreen, window, Zero);
	border(&gscreen, window, 4, F);
.
127c
	texture(&gscreen, gscreen.r, &bgrnd, S);
.
102,117d
74,76d
70a
	{ 0, 0, 1, 1 },
	{ 0, 0, 1, 1 },
	3,
.
69c
Bitmap bgrnd =
.
59,61c
	0,
.
55a
	{0, 0, 64, 64},
	{0, 0, 64, 64},
	1,
.
54c
static Bitmap hwcursor=
.
48,50d
44a
	{ 0, 0, 1600, 1240 },
	{ 0, 0, 1600, 1240 },
	3,
.
43c
Bitmap	gscreen =
.
32,33c
extern	Subfont	defont0;
.
11d
## diffname carrera/screen.c 1994/0414
## diff -e /n/fornaxdump/1994/0413/sys/src/brazil/carrera/screen.c /n/fornaxdump/1994/0414/sys/src/brazil/carrera/screen.c
466,469c
	d->cr2 = p.x&0xFF;
	d->cr2 = (p.x>>8)&0xF;
	d->cr2 = p.y&0xFF;
	d->cr2 = (p.y>>8)&0xF;

	if(dolock)
		unlock(&cursor);
.
462,463c
	if(dolock)
		lock(&cursor);

	p.x += 380;		/* adjusted by experiment */
	p.y += 11;		/* adjusted by experiment */
.
459a
	p = mousexy();

.
458a
	Point p;
.
456c
cursoron(int dolock)
.
411c
setcursor(ulong *s, ulong *c, int offx, int offy)
.
292c
		curpos = subfstring(&gscreen, curpos, &defont0, buf, S);
.
290c
		if(curpos.x >= window.max.x-w)
.
286c
			curpos.x -= w;
.
280,284c
		if(curpos.x-w >= 0){
			r.min.x = curpos.x-w;
			r.max.x = curpos.x;
			r.min.y = curpos.y;
			r.max.y = curpos.y+defont0.height;
.
277c
		curpos.x += pos*w;
.
275c
		pos = (curpos.x-window.min.x)/w;
.
272c
		curpos.x = window.min.x;
.
268c
		curpos.y += h;
.
266c
		if(curpos.y+h >= window.max.y)
.
255c
	curpos.y -= o;
.
154c
	setcursor(zbuf, zbuf, 0, 0);
.
132d
129c
	curpos = window.min;
.
96c
static Point curpos;
.
## diffname carrera/screen.c 1994/0520
## diff -e /n/fornaxdump/1994/0414/sys/src/brazil/carrera/screen.c /n/fornaxdump/1994/0520/sys/src/brazil/carrera/screen.c
422c
	org = add(Pt(32,32), curs->offset); 
.
417a
	for(i=0; i<16; i++){
		p = (uchar*)&s[i];
		*p = curs->set[2*i];
		*(p+1) = curs->set[2*i+1];
		p = (uchar*)&c[i];
		*p = curs->clr[2*i];
		*(p+1) = curs->clr[2*i+1];
	}
.
416a
	ulong s[16], c[16];
.
415c
	uchar ylow, yhigh, *p;
.
413c
	int x, y, i;
.
410c
setcursor(Cursor *curs)
.
152,153c
	memset(&zero, 0, sizeof zero);
	setcursor(&zero);
.
106c
	Cursor zero;
.
## diffname carrera/screen.c 1994/0521
## diff -e /n/fornaxdump/1994/0520/sys/src/brazil/carrera/screen.c /n/fornaxdump/1994/0521/sys/src/brazil/carrera/screen.c
223,224d
98d
79,94d
## diffname carrera/screen.c 1994/0525
## diff -e /n/fornaxdump/1994/0521/sys/src/brazil/carrera/screen.c /n/fornaxdump/1994/0525/sys/src/brazil/carrera/screen.c
457c
	p.x += 296;		/* adjusted by experiment */
.
46c
	Screenvirt+0x000178D0,
.
43,44c
	{ 0, 0, 1597, 1234 },
	{ 0, 0, 1597, 1234 },
.
## diffname carrera/screen.c 1994/0624
## diff -e /n/fornaxdump/1994/0525/sys/src/brazil/carrera/screen.c /n/fornaxdump/1994/0624/sys/src/brazil/carrera/screen.c
467a
	return 0;
.
444c
int
.
## diffname carrera/screen.c 1994/0909
## diff -e /n/fornaxdump/1994/0624/sys/src/brazil/carrera/screen.c /n/fornaxdump/1994/0909/sys/src/brazil/carrera/screen.c
369c
	d->cr0 = revtab0[255 - (p & 0xFF)];
.
351c
	d->cr0 = revtab0[255 - (p & 0xFF)];
.
212,220d
202,204d
177,178c
	setcolor(170, 0xAAAAAAAA, 0xAAAAAAAA, 0xAAAAAAAA);
	setcolor(85, 0x55555555, 0x55555555, 0x55555555);
.
172,174c
		r = rep((i>>5) & 7, 3);
		g = rep((i>>2) & 7, 3);
		b = rep(i & 3, 2);
.
## diffname carrera/screen.c 1995/0531
## diff -e /n/fornaxdump/1994/0909/sys/src/brazil/carrera/screen.c /n/fornaxdump/1995/0531/sys/src/brazil/carrera/screen.c
428a
	
.
409a

.
361a

	unlock(&cursor);

.
356a
	/* to protect DAC from mouse movement */
	lock(&cursor);

.
346a

	unlock(&cursor);
.
338a
	/* to protect DAC from mouse movement */
	lock(&cursor);

.
## diffname carrera/screen.c 1996/0216
## diff -e /n/fornaxdump/1995/0531/sys/src/brazil/carrera/screen.c /n/fornaxdump/1996/0216/sys/src/brazil/carrera/screen.c
171,178c
	graphicscmap(0);
.
148d
## diffname carrera/screen.c 1996/0219
## diff -e /n/fornaxdump/1996/0216/sys/src/brazil/carrera/screen.c /n/fornaxdump/1996/0219/sys/src/brazil/carrera/screen.c
65c
	0xa0,
.
## diffname carrera/screen.c 1997/0129
## diff -e /n/fornaxdump/1996/0219/sys/src/brazil/carrera/screen.c /n/fornaxdump/1997/0129/sys/src/brazil/carrera/screen.c
93d
91a
	for(y=gscreen.r.min.y; y<gscreen.r.max.y; y++)
		memset(byteaddr(&gscreen, Pt(gscreen.r.min.x, y)), 0xa0, Dx(gscreen.r));
.
63,78d
## diffname carrera/screen.c 1997/0327
## diff -e /n/fornaxdump/1997/0129/sys/src/brazil/carrera/screen.c /n/emeliedump/1997/0327/sys/src/brazil/carrera/screen.c
248c
	if(!islo()) {
.
## diffname carrera/screen.c 1997/1101
## diff -e /n/emeliedump/1997/0327/sys/src/brazil/carrera/screen.c /n/emeliedump/1997/1101/sys/src/brazil/carrera/screen.c
419c
	free(hwcursor.data->data);
.
412c
		d->cr2 = ((uchar *)hwcursor.data->data)[x];
.
394c
			/* point(&hwcursor, addpt(Pt(x,y), org), dpix, S), by hand */
			*byteaddr(&hwcursor, Pt(x+org.x, y+org.y)) |= dpix<<(6-(2*((x+org.x)&3)));
.
388,390c
	org = addpt(Pt(32,32), curs->offset); 
	for(y = 0; y < 16; y++)
		for(x = 0; x < 16; x++) {
.
384,385c
	hwcursor.data->data = (ulong *)malloc(1024);
	if(hwcursor.data->data == 0)
.
237c

		*xp++ = curpos.x;
		r = Rect(curpos.x, curpos.y, curpos.x+w, curpos.y + h);
		memimagedraw(&gscreen, r, back, back->r.min, memones, back->r.min);
		memimagestring(&gscreen, curpos, &conscol, memdefont, buf);
		curpos.x += w;
.
234a
		p = memsubfontwidth(memdefont, buf);
		w = p.x;

.
225,232c
		if(xp <= xbuf)
			break;
		xp--;
		r = Rect(*xp, curpos.y, curpos.x, curpos.y + h);
		memimagedraw(&gscreen, r, back, back->r.min, memones, back->r.min);
		curpos.x = *xp;
.
221a
		r = Rect(curpos.x, curpos.y, curpos.x+pos*w, curpos.y + h);
		memimagedraw(&gscreen, r, back, back->r.min, memones, back->r.min);
.
219a
		p = memsubfontwidth(memdefont, " ");
		w = p.x;
		*xp++ = curpos.x;
.
216a
		xp = xbuf;
.
208a
	if(xp < xbuf || xp >= &xbuf[sizeof(xbuf)])
		xp = xbuf;

.
207a
	static int *xp;
	static int xbuf[256];
.
206c
	Point p;
	int w, pos;
.
202a
/* 
 * export screen to devdraw
 */
ulong*
attachscreen(Rectangle *r, int *ld, int *width)
{
	*r = gscreen.r;
	*ld = gscreen.ldepth;
	*width = gscreen.width;

	return gscreendata.data;
}

/*
 * update screen (no-op: frame buffer is direct-mapped)
 */
void
flushmemscreen(Rectangle)
{
}

.
199c
	memimagedraw(&gscreen, r, back, ZP, memones, ZP);

.
195,197c
	o = 8*h;
	r = Rpt(window.min, Pt(window.max.x, window.max.y-o));
	p = Pt(window.min.x, window.min.y+o);
	memimagedraw(&gscreen, r, &gscreen, p, memones, p);
.
192a
	Point p;
.
184c
	out.bwid = memdefont->info[' '].width;
.
181c
	memdefont = getmemdefont();

.
155c
	drawcmap(0);
.
85,95c
	memimagedraw(&gscreen, window, memones, ZP, memones, ZP);
	window = insetrect(window, 4);
	memimagedraw(&gscreen, window, back, ZP, memones, ZP);
	/* hack to get a grey color */
	memzeros->data->data[0] = 0x33333333;
	memimagedraw(&gscreen, Rect(window.min.x, window.min.y,
			window.max.x, window.min.y+h+5+6), memzeros, ZP, memones, ZP);
	memzeros->data->data[0] = 0;
	window = insetrect(window, 5);

	greet = " Brazil Console: Draw version ";
	p = addpt(window.min, Pt(10, 0));
	q = memsubfontwidth(memdefont, greet);
	memimagestring(&gscreen, p, &conscol, memdefont, greet);
.
83c
	window.max = addpt(window.min, Pt(10+w*120, 10+h*60));
.
79,80c
	w = memdefont->info[' '].width;
	h = memdefont->height;
.
77c
		memset(byteaddr(&gscreen, Pt(gscreen.r.min.x, y)), 0xba, Dx(gscreen.r));
.
73a
	char *greet;
.
71,72c
	Point p, q;
	int y;
.
62a
ulong	consbits = ~0;
Memdata	consdata = {
	nil,
	&consbits
};
Memimage conscol =
{
	{ 0, 0, 1, 1 },
	{ -100000, -100000, 100000, 100000 },
	3,
	1,
	&consdata,
	0,
	1
};

ulong	onesbits = ~0;
Memdata	onesdata = {
	nil,
	&onesbits,
};
Memimage	xones =
{
	{ 0, 0, 1, 1 },
	{ -100000, -100000, 100000, 100000 },
	3,
	1,
	&onesdata,
	0,
	1
};
Memimage *memones = &xones;

ulong	zerosbits = 0;
Memdata	zerosdata = {
	nil,
	&zerosbits,
};
Memimage	xzeros =
{
	{ 0, 0, 1, 1 },
	{ -100000, -100000, 100000, 100000 },
	3,
	1,
	&zerosdata,
	0,
	1
};
Memimage *memzeros = &xzeros;

ulong	backbits = (Backgnd<<24)|(Backgnd<<16)|(Backgnd<<8)|Backgnd;
Memdata	backdata = {
	nil,
	&backbits
};
Memimage	xback =
{
	{ 0, 0, 1, 1 },
	{ -100000, -100000, 100000, 100000 },
	3,
	1,
	&backdata,
	0,
	1
};
Memimage *back = &xback;

.
58a
	&hwcursordata,		/* base filled in by malloc when needed */
	0,
.
57d
53a
	{ 0, 0, 1597, 1234 },	/* r */
	{ 0, 0, 1597, 1234 },	/* clipr */
	3,	/* ldepth */
	0,	/* repl */
	&gscreendata,	/* data */
	0,	/* zero */
	512,	/* width */
	0,	/* layer */
};

static Memimage hwcursor=
{
.
52c
Memimage gscreen =
.
43,49c
	nil,
	(ulong*)(Screenvirt+0x000178D0),
	1,
.
41c
Point	ZP = {0, 0};

static Memdata	hwcursordata;

static Memdata gscreendata =
.
31c
		Memsubfont	*memdefont;
.
29a
#define	Backgnd		0x00
.
10c
#define	Image	IMAGE
#include	<draw.h>
#include	<memdraw.h>
.
## diffname carrera/screen.c 1998/0109
## diff -e /n/emeliedump/1997/1101/sys/src/brazil/carrera/screen.c /n/emeliedump/1998/0109/sys/src/brazil/carrera/screen.c
312a
	USED(r);
/*
	DEBUG version flashes the screen to indicate what's being painted
	Memimage *x;
	int i;

	if(Dx(r)<=0 || Dy(r)<=0)
		return;
	x = allocmemimage(r, 3);
	memimagedraw(x, r, &gscreen, r.min, memones, r.min);
	memimagedraw(&gscreen, r, memones, r.min, memones, r.min);
	for(i=1000000; --i>0; );
	memimagedraw(&gscreen, r, x, r.min, memones, r.min);
	freememimage(x);
*/
.
311c
flushmemscreen(Rectangle r)
.
302a
	*softscreen = 0;
.
298c
attachscreen(Rectangle *r, int *ld, int *width, int *softscreen)
.
## diffname carrera/screen.c 1998/0209
## diff -e /n/emeliedump/1998/0109/sys/src/brazil/carrera/screen.c /n/emeliedump/1998/0209/sys/src/brazil/carrera/screen.c
145a
Cursor	arrow = {
	{ -1, -1 },
	{ 0xFF, 0xFF, 0x80, 0x01, 0x80, 0x02, 0x80, 0x0C, 
	  0x80, 0x10, 0x80, 0x10, 0x80, 0x08, 0x80, 0x04, 
	  0x80, 0x02, 0x80, 0x01, 0x80, 0x02, 0x8C, 0x04, 
	  0x92, 0x08, 0x91, 0x10, 0xA0, 0xA0, 0xC0, 0x40, 
	},
	{ 0x00, 0x00, 0x7F, 0xFE, 0x7F, 0xFC, 0x7F, 0xF0, 
	  0x7F, 0xE0, 0x7F, 0xE0, 0x7F, 0xF0, 0x7F, 0xF8, 
	  0x7F, 0xFC, 0x7F, 0xFE, 0x7F, 0xFC, 0x73, 0xF8, 
	  0x61, 0xF0, 0x60, 0xE0, 0x40, 0x40, 0x00, 0x00, 
	},
};

.
## diffname carrera/screen.c 1998/0630
## diff -e /n/emeliedump/1998/0209/sys/src/brazil/carrera/screen.c /n/emeliedump/1998/0630/sys/src/brazil/carrera/screen.c
597c
	p.y += 9;		/* adjusted by experiment */
.
551,552c
			spix = (s[y]>>(15-x))&1;
			cpix = (c[y]>>(15-x))&1;
.
534c
	ushort s[16], c[16];
.
## diffname carrera/screen.c 1999/0119
## diff -e /n/emeliedump/1998/0630/sys/src/brazil/carrera/screen.c /n/emeliedump/1999/0119/sys/src/brazil/carrera/screen.c
12a
#include	<cursor.h>
.
## diffname carrera/screen.c 1999/0326
## diff -e /n/emeliedump/1999/0119/sys/src/brazil/carrera/screen.c /n/emeliedump/1999/0326/sys/src/brazil/carrera/screen.c
605a
	splx(s);
.
595a
	s = splhi();
.
588a
	int s;
.
## diffname carrera/screen.c 1999/0327
## diff -e /n/emeliedump/1999/0326/sys/src/brazil/carrera/screen.c /n/emeliedump/1999/0327/sys/src/brazil/carrera/screen.c
608d
597d
589d
## diffname carrera/screen.c 1999/1005
## diff -e /n/emeliedump/1999/0327/sys/src/brazil/carrera/screen.c /n/emeliedump/1999/1005/sys/src/brazil/carrera/screen.c
669c
		q += gscreen->width*sizeof(ulong);
.
666c
	q = byteaddr(gscreen, r.min);
.
642c
		q += gscreen->width*sizeof(ulong);
.
639c
	q = byteaddr(gscreen, r.min);
.
635c
	if(!rectclip(&r, gscreen->r) || tl<=0)
.
614c
	return gscreen->depth;
.
580,581d
574c
		d->cr2 = hwcursor->data->bdata[x];
.
556c
			*byteaddr(hwcursor, Pt(x+org.x, y+org.y)) |= (dpix<<(6-(2*((x+org.x)&3))));
.
545,547c
	memset(hwcursor->data->bdata, 0, sizeof(long)*hwcursor->width*Dy(hwcursor->r));
.
396,397c
		memimagedraw(gscreen, r, back, back->r.min, nil, back->r.min);
		memimagestring(gscreen, curpos, conscol, memdefont, buf);
.
384c
		memimagedraw(gscreen, r, back, back->r.min, nil, back->r.min);
.
376c
		memimagedraw(gscreen, r, back, back->r.min, nil, back->r.min);
.
341c
	memimagedraw(&gscreen, r, x, r.min, memopaque, r.min);
.
338,339c
	memimagedraw(x, r, &gscreen, r.min, memopaque, r.min);
	memimagedraw(&gscreen, r, memblack, r.min, memopaque, r.min);
.
320c
	return gscreendata.bdata;
.
315,317c
	*r = gscreen->r;
	*d = gscreen->depth;
	*chan = gscreen->chan;
	*width = gscreen->width;
.
312,313c
uchar*
attachscreen(Rectangle *r, ulong *chan, int* d, int *width, int *softscreen)
.
304c
	memimagedraw(gscreen, r, back, ZP, nil, ZP);
.
302c
	memimagedraw(gscreen, r, gscreen, p, nil, p);
.
282a
	memimageinit();
.
257c
	drawcmap(1);
.
197c
	memimagestring(gscreen, p, conscol, memdefont, greet);
.
194c
	greet = " Brazil Console: New Draw version ";
.
186,191c
	memimagedraw(gscreen, window, memwhite, ZP, memopaque, ZP);

	/* a lot of work to get a grey color */
	grey = allocmemimage(Rect(0,0,1,1), CMAP8);
	grey->flags |= Frepl;
	grey->clipr = gscreen->r;
	grey->data->bdata[0] = 0xAA;
	memimagedraw(gscreen, Rect(window.min.x, window.min.y,
			window.max.x, window.min.y+h+5+6), grey, ZP, nil, ZP);
	freememimage(grey);
.
184c
	memimagedraw(gscreen, window, memblack, ZP, memopaque, ZP);
.
177a
	memset((void*)Screenvirt, 0, 3*1024*1024);
	memfillcolor(gscreen, 0x444488FF);

.
174,176c
	gscreen = &xgscreen;
	memsetchan(gscreen, CMAP8);
	hwcursor = allocmemimage(Rect(0,0,64,64), GREY2);
	memsetchan(hwcursor, GREY2);
	
	back = memwhite;
	conscol = memblack;
.
172a
	Memimage *grey;
.
170d
163a
int drawdebug;
.
80,146d
68,78c
Memimage *gscreen;
Memimage *conscol;
Memimage *back;
Memimage *hwcursor;
.
65a
	Frepl,	/* flags */
.
60,61c
	8,	/* depth */
	1,	/* nchan */
	CMAP8,	/* chan */
	nil,	/* cmap */
.
56c
static Memimage xgscreen =
.
47,48d
33c
#define	Backgnd		0xFF	/* white */
.
## diffname carrera/screen.c 1999/1013
## diff -e /n/emeliedump/1999/1005/sys/src/brazil/carrera/screen.c /n/emeliedump/1999/1013/sys/src/brazil/carrera/screen.c
444c
	d->cr0 = revtab0[p & 0xFF];
.
421c
	d->cr0 = revtab0[p & 0xFF];
.
196c
	drawcmap();
.
## diffname carrera/screen.c 1999/1031
## diff -e /n/emeliedump/1999/1013/sys/src/brazil/carrera/screen.c /n/emeliedump/1999/1031/sys/src/9/carrera/screen.c
133c
	greet = " Plan 9 Console ";
.
## diffname carrera/screen.c 2000/0104
## diff -e /n/emeliedump/1999/1031/sys/src/9/carrera/screen.c /n/emeliedump/2000/0104/sys/src/9/carrera/screen.c
338c
		memimagestring(gscreen, curpos, conscol, ZP, memdefont, buf);
.
136c
	memimagestring(gscreen, p, conscol, ZP, memdefont, greet);
.
## diffname carrera/screen.c 2000/0504
## diff -e /n/emeliedump/2000/0104/sys/src/9/carrera/screen.c /n/emeliedump/2000/0504/sys/src/9/carrera/screen.c
610a

void
blankscreen(int)
{
}
.
## diffname carrera/screen.c 2000/1021
## diff -e /n/emeliedump/2000/0504/sys/src/9/carrera/screen.c /n/emeliedump/2000/1021/sys/src/9/carrera/screen.c
66c
	0,	/* flags */
.
11c
#include	<draw.h>
.
## diffname carrera/screen.c 2000/1102
## diff -e /n/emeliedump/2000/1021/sys/src/9/carrera/screen.c /n/emeliedump/2000/1102/sys/src/9/carrera/screen.c
326a
		break;
	case '\0':
.
315a
		*xp++ = curpos.x;
.
313c
		if(curpos.x >= window.max.x-8*w)
			screenputc("\n");

.
11c
#include	<draw.h>
.
## diffname carrera/screen.c 2001/0527 # deleted
## diff -e /n/emeliedump/2000/1102/sys/src/9/carrera/screen.c /n/emeliedump/2001/0527/sys/src/9/carrera/screen.c
1,620d

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.