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

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


## diffname ss/screen.c 1990/1223
## diff -e /dev/null /n/bootesdump/1990/1223/sys/src/9/sparc/screen.c
0a
#include	"u.h"
#include	"lib.h"
#include	"mem.h"
#include	"dat.h"
#include	"fns.h"
#include	"io.h"
#include	"ureg.h"
#include	"errno.h"

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

#define	MINX	8

extern	GFont	defont0;
GFont		*defont;

struct{
	Point	pos;
	int	bwid;
}out;

void	duartinit(void);
int	duartacr;
int	duartimr;

void	(*kprofp)(ulong);

GBitmap	gscreen =
{
	(ulong*)((4*1024*1024-256*1024)|KZERO),	/* BUG */
	0,
	64,
	0,
	0, 0, 1024, 1024,
	0
};

void
screeninit(void)
{
	duartinit();
	/*
	 * Read HEX switch to set ldepth
	 */
	if(*(uchar*)MOUSE & (1<<4))
		gscreen.ldepth = 1;
	defont = &defont0;	/* save space; let bitblt do the conversion work */
	gbitblt(&gscreen, Pt(0, 0), &gscreen, gscreen.r, 0);
	out.pos.x = MINX;
	out.pos.y = 0;
	out.bwid = defont0.info[' '].width;
}

void
screenputc(int c)
{
	char buf[2];
	int nx;

	if(c == '\n'){
		out.pos.x = MINX;
		out.pos.y += defont0.height;
		if(out.pos.y > gscreen.r.max.y-defont0.height)
			out.pos.y = gscreen.r.min.y;
		gbitblt(&gscreen, Pt(0, out.pos.y), &gscreen,
		    Rect(0, out.pos.y, gscreen.r.max.x, out.pos.y+2*defont0.height), 0);
	}else if(c == '\t'){
		out.pos.x += (8-((out.pos.x-MINX)/out.bwid&7))*out.bwid;
		if(out.pos.x >= gscreen.r.max.x)
			screenputc('\n');
	}else if(c == '\b'){
		if(out.pos.x >= out.bwid+MINX){
			out.pos.x -= out.bwid;
			screenputc(' ');
			out.pos.x -= out.bwid;
		}
	}else{
		if(out.pos.x >= gscreen.r.max.x-out.bwid)
			screenputc('\n');
		buf[0] = c&0x7F;
		buf[1] = 0;
		out.pos = gbitbltstring(&gscreen, out.pos, defont, buf, S);
	}
}

/*
 * Register set for half the duart.  There are really two sets.
 */
struct Duart{
	uchar	mr1_2;		/* Mode Register Channels 1 & 2 */
	uchar	sr_csr;		/* Status Register/Clock Select Register */
	uchar	cmnd;		/* Command Register */
	uchar	data;		/* RX Holding / TX Holding Register */
	uchar	ipc_acr;	/* Input Port Change/Aux. Control Register */
#define	ivr	ivr		/* Interrupt Vector Register */
	uchar	is_imr;		/* Interrupt Status/Interrupt Mask Register */
#define	ip_opcr	is_imr		/* Input Port/Output Port Configuration Register */
	uchar	ctur;		/* Counter/Timer Upper Register */
#define	scc_sopbc ctur		/* Start Counter Command/Set Output Port Bits Command */
	uchar	ctlr;		/* Counter/Timer Lower Register */
#define	scc_ropbc ctlr		/* Stop Counter Command/Reset Output Port Bits Command */
};

enum{
	CHAR_ERR	=0x00,	/* MR1x - Mode Register 1 */
	PAR_ENB		=0x00,
	EVEN_PAR	=0x00,
	ODD_PAR		=0x04,
	NO_PAR		=0x10,
	CBITS8		=0x03,
	CBITS7		=0x02,
	CBITS6		=0x01,
	CBITS5		=0x00,
	NORM_OP		=0x00,	/* MR2x - Mode Register 2 */
	TWOSTOPB	=0x0F,
	ONESTOPB	=0x07,
	ENB_RX		=0x01,	/* CRx - Command Register */
	DIS_RX		=0x02,
	ENB_TX		=0x04,
	DIS_TX		=0x08,
	RESET_MR 	=0x10,
	RESET_RCV  	=0x20,
	RESET_TRANS  	=0x30,
	RESET_ERR  	=0x40,
	RESET_BCH	=0x50,
	STRT_BRK	=0x60,
	STOP_BRK	=0x70,
	RCV_RDY		=0x01,	/* SRx - Channel Status Register */
	FIFOFULL	=0x02,
	XMT_RDY		=0x04,
	XMT_EMT		=0x08,
	OVR_ERR		=0x10,
	PAR_ERR		=0x20,
	FRM_ERR		=0x40,
	RCVD_BRK	=0x80,
	BD38400		=0xCC|0x0000,
	BD19200		=0xCC|0x0100,
	BD9600		=0xBB|0x0000,
	BD4800		=0x99|0x0000,
	BD2400		=0x88|0x0000,
	BD1200		=0x66|0x0000,
	BD300		=0x44|0x0000,
	IM_IPC		=0x80,	/* IMRx/ISRx - Interrupt Mask/Interrupt Status */
	IM_DBB		=0x40,
	IM_RRDYB	=0x20,
	IM_XRDYB	=0x10,
	IM_CRDY		=0x08,
	IM_DBA		=0x04,
	IM_RRDYA	=0x02,
	IM_XRDYA	=0x01,
};

uchar keymap[]={
/*80*/	0x58,	0x58,	0x58,	0x58,	0x58,	0x58,	0x58,	0x58,
	0x58,	0x58,	0x58,	0x58,	0x58,	0x58,	0x8e,	0x58,
/*90*/	0x90,	0x91,	0x92,	0x93,	0x94,	0x95,	0x96,	0x97,
	0x98,	0x99,	0x9a,	0x9b,	0x58,	0x58,	0x58,	0x58,
/*A0*/	0x58,	0xa1,	0xa2,	0xa3,	0xa4,	0xa5,	0xa6,	0xa7,
	0x58,	0x58,	0x58,	0x58,	0x58,	0x58,	0xae,	0xaf,
/*B0*/	0xb0,	0xb1,	0xb2,	0xb3,	0xb4,	0xb5,	0x80,	0xb7,
	0xb8,	0xb9,	0x00,	0xbb,	0x1e,	0xbd,	0x60,	0x1f,
/*C0*/	0xc0,	0xc1,	0xc2,	0xc3,	0xc4,	0x58,	0xc6,	0x0a,
	0xc8,	0xc9,	0xca,	0xcb,	0xcc,	0xcd,	0xce,	0xcf,
/*D0*/	0x09,	0x08,	0xd2,	0xd3,	0xd4,	0xd5,	0xd6,	0xd7,
	0x58,	0x58,	0x58,	0x58,	0x58,	0x58,	0x7f,	0x58,
/*E0*/	0x58,	0x58,	0xe2,	0x1b,	0x0d,	0xe5,	0x58,	0x0a,
	0xe8,	0xe9,	0xea,	0xeb,	0xec,	0xed,	0xee,	0xef,
/*F0*/	0x09,	0x08,	0xb2,	0x1b,	0x0d,	0xf5,	0x81,	0x58,
	0x58,	0x58,	0x58,	0x58,	0x58,	0x58,	0x7f,	0xb2,
};

void
duartinit(void)
{
	Duart *duart;

	duart  =  DUARTREG;

	/*
	 * Keyboard
	 */
	duart[0].cmnd = RESET_RCV|DIS_TX|DIS_RX;
	duart[0].cmnd = RESET_TRANS;
	duart[0].cmnd = RESET_ERR;
	duart[0].cmnd = RESET_MR;
	duart[0].mr1_2 = CHAR_ERR|PAR_ENB|EVEN_PAR|CBITS8;
	duart[0].mr1_2 = NORM_OP|ONESTOPB;
	duart[0].sr_csr = BD4800;

	/*
	 * RS232
	 */
	duart[1].cmnd = RESET_RCV|DIS_TX|DIS_RX;
	duart[1].cmnd = RESET_TRANS;
	duart[1].cmnd = RESET_ERR;
	duart[1].cmnd = RESET_MR;
	duart[1].mr1_2 = CHAR_ERR|NO_PAR|CBITS8;
	duart[1].mr1_2 = NORM_OP|ONESTOPB;
	duart[1].sr_csr = BD9600;

	/*
	 * Output port
	 */
	duart[0].ipc_acr = duartacr = 0xB7;	/* allow change	of state interrupt */
	duart[1].ip_opcr = 0x00;
	duart[1].scc_ropbc = 0xFF;	/* make sure the port is reset first */
	duart[1].scc_sopbc = 0x04;	/* dtr = 1, pp = 01 */
	duart[0].is_imr = duartimr = IM_IPC|IM_RRDYB|IM_XRDYB|IM_RRDYA|IM_XRDYA;
	duart[0].cmnd = ENB_TX|ENB_RX;	/* enable TX and RX last */
	duart[1].cmnd = ENB_TX|ENB_RX;

	/*
	 * Initialize keyboard
	 */
	while (!(duart[0].sr_csr & (XMT_EMT|XMT_RDY)))
		;
	duart[0].data = 0x02;
}

int
duartinputport(void)
{
	Duart *duart = DUARTREG;
	return duart[1].ip_opcr;
}
void
duartbaud(int b)
{
	int x;
	Duart *duart = DUARTREG;

	x = 0;		/* set */
	switch(b){
	case 38400:
		x = BD38400;
		break;
	case 19200:
		x = BD19200;
		break;
	case 9600:
		x = BD9600;
		break;
	case 4800:
		x = BD4800;
		break;
	case 2400:
		x = BD2400;
		break;
	case 1200:
		x = BD1200;
		break;
	case 300:
		x = BD300;
		break;
	default:
		error(Ebadarg);
	}
	if(x & 0x0100)
		duart[0].ipc_acr = duartacr |= 0x80;
	else
		duart[0].ipc_acr = duartacr &= ~0x80;
	duart[1].sr_csr = x;
}

void
duartdtr(int val)
{
	Duart *duart = DUARTREG;
	if (val)
		duart[1].scc_ropbc=0x01;
	else
		duart[1].scc_sopbc=0x01;
}

void
duartbreak(int ms)
{
	static QLock brk;
	Duart *duart = DUARTREG;
	if (ms<=0 || ms >20000)
		error(Ebadarg);
	qlock(&brk);
	duart[0].is_imr = duartimr &= ~IM_XRDYB;
	duart[1].cmnd = STRT_BRK|ENB_TX;
	tsleep(&u->p->sleep, return0, 0, ms);
	duart[1].cmnd = STOP_BRK|ENB_TX;
	duart[0].is_imr = duartimr |= IM_XRDYB;
	qunlock(&brk);
}

enum{
	Kptime=200
};
void
duartstarttimer(void)
{
	Duart *duart;
	char x;

	duart = DUARTREG;
	duart[0].ctur = (Kptime)>>8;
	duart[0].ctlr = (Kptime)&255;
	duart[0].is_imr = duartimr |= IM_CRDY;
	x = duart[1].scc_sopbc;
}

void
duartstoptimer(void)
{
	Duart *duart;
	char x;

	duart = DUARTREG;
	x = duart[1].scc_ropbc;
	duart[0].is_imr = duartimr &= ~IM_CRDY;
}

void
duartrs232intr(void)
{
	int c;
	Duart *duart;

	duart = DUARTREG;
	c = getrs232o();
	if(c == -1)
		duart[1].cmnd = DIS_TX;
	else
		duart[1].data = c;
}

void
duartstartrs232o(void)
{
	DUARTREG[1].cmnd = ENB_TX;
	duartrs232intr();
}

void
duartintr(Ureg *ur)
{
	int cause, status, c;
	Duart *duart;

	duart = DUARTREG;
	cause = duart->is_imr;
	/*
	 * I can guess your interrupt.
	 */
	/*
	 * Is it 0?
	 */
	if(cause & IM_CRDY){
		if(kprofp)
			(*kprofp)(ur->pc);
		c = duart[1].scc_ropbc;
		duart[0].ctur = (Kptime)>>8;
		duart[0].ctlr = (Kptime)&255;
		c = duart[1].scc_sopbc;
		return;
	}
	/*
	 * Is it 1?
	 */
	if(cause & IM_RRDYA){		/* keyboard input */
		status = duart->sr_csr;
		c = duart->data;
		if(status & (FRM_ERR|OVR_ERR|PAR_ERR))
			duart->cmnd = RESET_ERR;
		if(status & PAR_ERR) /* control word: caps lock (0x4) or repeat (0x10) */
			kbdrepeat((c&0x10) == 0);
		else{
			if(c == 0x7F)
				c = 0xFF;	/* VIEW key (bizarre) */
			if(c & 0x80)
				c = keymap[c&0x7F];
			kbdchar(c);
		}
	}
	/*
	 * Is it 2?
	 */
	if(cause & IM_RRDYB){		/* rs232 input */
		status = duart[1].sr_csr;
		c = duart[1].data;
		if(status & (FRM_ERR|OVR_ERR|PAR_ERR))
			duart[1].cmnd = RESET_ERR;
		else
			rs232ichar(c);
	}
	/*
	 * Is it 3?
	 */
	if(cause & IM_XRDYB)		/* rs232 output */
		duartrs232intr();
	/*
	 * Is it 4?
	 */
	if(cause & IM_XRDYA)
		duart[0].cmnd = DIS_TX;
	/*
	 * Is it 5?
	 */
	if(cause & IM_IPC)
		mousebuttons((~duart[0].ipc_acr) & 7);
}
.
## diffname ss/screen.c 1990/1226
## diff -e /n/bootesdump/1990/1223/sys/src/9/sparc/screen.c /n/bootesdump/1990/1226/sys/src/9/sparc/screen.c
83c
		out.pos = gstring(&gscreen, out.pos, defont, buf, S);
.
42,48c
/*	duartinit(); /**/
	defont = &defont0;
.
35c
	{0, 0, 1160, 900},
.
33c
	1160/32,
.
31c
	(ulong*)SCREENSEGM,
.
## diffname ss/screen.c 1990/1231
## diff -e /n/bootesdump/1990/1226/sys/src/9/sparc/screen.c /n/bootesdump/1990/1231/sys/src/9/sparc/screen.c
387,401c
	if(tc==0xF1){	/* shift */
		shift |= 1;
		repeatc = -1;
		return;
	}
	if(tc==0xF2){	/* caps */
		caps ^= 1;
		repeatc =- 1;
		return;
	}
	if(caps && 'a'<=tc && tc<='z')
		tc |= ' ';
	repeatc = tc;
/*
	startclick = clicks;
*/
	if(tc == 0x10)		/* ctrl-p */
		reset();
	kbdchar(tc);
.
376,385c
	if(tc == 0xF0){		/* control */
		shift |= 2;
		repeatc = -1;
		return;
.
374a
		if(tc == 0xF1){	/* shift */
			shift &= ~1;
			repeatc = -1;
			return;
		}
		if(tc == 0xF2){	/* caps */
			repeatc = -1;
			return;
		}
		if(tc == repeatc)
			repeatc = -1;
		return;
.
358,373c
*/
	if(c==0x7F){	/* all keys up */
		repeatc = -1;
		return;
	}
	if(tc == 0xFF)	/* shouldn't happen; ignore */
		return;
	if(c & 0x80){	/* key went up */
		if(tc == 0xF0){		/* control */
			shift &= ~2;
			repeatc =- 1;
			return;
.
349,355c
	dp = &duart[1];
	if(cause & ExtPendB)
		duartwrreg(dp, 0, ResExtPend);
	if(cause & RxPendB){
		ch = *dp->data;
		mousechar(ch);
	}
	if(cause & TxPendB)
		duartwrreg(dp, 0, ResTxPend);
}

/*
 * Map is indexed by keyboard char, output is ASCII
 */
uchar keymap[128] = {
/*	00    L1    02    L2    04    F1    F2    07	*/
	0xFF, 0x80, 0xFF, 0x81, 0xFF, 0x82, 0x83, 0xFF,
/*	F3    09    F4    0b    F5    0d    F6    0f  	*/
	0x84, 0xFF, 0x85, 0xFF, 0x86, 0xFF, 0x87, 0xFF,
/*	F7    F8    F9    Alt   14    R1    R2    R3	*/
	0x88, 0x89, 0x8a, 0x8b, 0xFF, 0x8c, 0x8d, 0x8e,
/*	18    L3    L4    1b    1c    Esc   1     2	*/
	0xFF, 0x8f, 0x90, 0xFF, 0xFF, 0x1b, '1',  '2',
/*	3     4     5     6     7     8     9     0	*/
	'3',  '4',  '5',  '6',  '7',  '8',  '9',  '0',
/*	-     =     `     bs    2c    R4    R5    R6	*/
	'-',  '=',  '`',  '\b', 0xFF, 0x91, 0x92, 0x93,
/*	30    L5    L6    33    34    tab   q     w  	*/
	0xFF, 0x94, 0x95, 0xFF, 0xFF, '\t', 'q',  'w',
/*	e     r     t     y     u     i     o     p    	*/
	'e',  'r',  't',  'y',  'u',  'i',  'o',  'p',
/*	[     ]     del   43    R7    R8    R9    47   	*/
	'[',  ']',  0x7F, 0xFF, 0x96, 0x97, 0x98, 0xFF,
/*	L7    L8    4a    4b    ctrl  a     s     d	*/
	0x99, 0x9a, 0xFF, 0xFF, 0xF0, 'a',  's',  'd',
/*	f     g     h     j     k     l     ;     '   	*/
	'f',  'g',  'h',  'j',  'k',  'l',  ';',  '\'',
/*	\     ret   5a    R10   R11   R12   5e    L9	*/
	'\\', '\n', 0xFF, 0x9b, 0x9c, 0x9d, 0xFF, 0x9e, 
/*	60    L10   62    shift z     x     c     v	*/
	0xFF, 0x9f, 0xFF, 0xF1, 'z',  'x',  'c', 'v',
/*	b     n     m     ,     .     /     shift lf	*/
	'b',  'n',  'm',  ',',  '.',  '/',  0xF1, '\r',
/*	R13   R14   R15   73    74    75    76    caps	*/
	0xA0, 0xA1, 0xA2, 0xFF, 0xFF, 0xFF, 0xFF, 0xF2,
/*	left  79    right 7b    7c    7d    7e    7f	*/
	0xA3, ' ',  0xA4, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
};

uchar keymapshift[128] = {
/*	00    L1    02    L2    04    F1    F2    07	*/
	0xFF, 0x80, 0xFF, 0x81, 0xFF, 0x82, 0x83, 0xFF,
/*	F3    09    F4    0b    F5    0d    F6    0f  	*/
	0x84, 0xFF, 0x85, 0xFF, 0x86, 0xFF, 0x87, 0xFF,
/*	F7    F8    F9    Alt   14    R1    R2    R3	*/
	0x88, 0x89, 0x8a, 0x8b, 0xFF, 0x8c, 0x8d, 0x8e,
/*	18    L3    L4    1b    1c    Esc   1     2	*/
	0xFF, 0x8f, 0x90, 0xFF, 0xFF, 0x1b, '!',  '@',
/*	3     4     5     6     7     8     9     0	*/
	'#',  '$',  '%',  '^',  '&',  '*',  '(',  ')',
/*	-     =     `     bs    2c    R4    R5    R6	*/
	'_',  '+',  '~',  '\b', 0xFF, 0x91, 0x92, 0x93,
/*	30    L5    L6    33    34    tab   q     w  	*/
	0xFF, 0x94, 0x95, 0xFF, 0xFF, '\t', 'Q',  'W',
/*	e     r     t     y     u     i     o     p    	*/
	'E',  'R',  'T',  'Y',  'U',  'I',  'O',  'P',
/*	[     ]     del   43    R7    R8    R9    47   	*/
	'{',  '}',  0x7F, 0xFF, 0x96, 0x97, 0x98, 0xFF,
/*	L7    L8    4a    4b    ctrl  a     s     d	*/
	0x99, 0x9a, 0xFF, 0xFF, 0xF0, 'A',  'S',  'D',
/*	f     g     h     j     k     l     ;     '   	*/
	'F',  'G',  'H',  'J',  'K',  'L',  ':',  '"',
/*	\     ret   5a    R10   R11   R12   5e    L9	*/
	'|', '\n',  0xFF, 0x9b, 0x9c, 0x9d, 0xFF, 0x9e, 
/*	60    L10   62    shift z     x     c     v	*/
	0xFF, 0x9f, 0xFF, 0xF1, 'Z',  'X',  'C', 'V',
/*	b     n     m     ,     .     /     shift lf	*/
	'B',  'N',  'M',  '<',  '>',  '?',  0xF1, '\r',
/*	R13   R14   R15   73    74    75    76    caps	*/
	0xA0, 0xA1, 0xA2, 0xFF, 0xFF, 0xFF, 0xFF, 0xF2,
/*	left  79    right 7b    7c    7d    7e    7f	*/
	0xA3, ' ',  0xA4, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
};

uchar keymapctrl[128] = {
/*	00    L1    02    L2    04    F1    F2    07	*/
	0xFF, 0x80, 0xFF, 0x81, 0xFF, 0x82, 0x83, 0xFF,
/*	F3    09    F4    0b    F5    0d    F6    0f  	*/
	0x84, 0xFF, 0x85, 0xFF, 0x86, 0xFF, 0x87, 0xFF,
/*	F7    F8    F9    Alt   14    R1    R2    R3	*/
	0x88, 0x89, 0x8a, 0x8b, 0xFF, 0x8c, 0x8d, 0x8e,
/*	18    L3    L4    1b    1c    Esc   1     2	*/
	0xFF, 0x8f, 0x90, 0xFF, 0xFF, 0x1b, '!',  '@',
/*	3     4     5     6     7     8     9     0	*/
	'#',  '$',  '%',  '^',  '&',  '*',  '(',  ')',
/*	-     =     `     bs    2c    R4    R5    R6	*/
	'_',  '+',  '~', '\b', 0xFF, 0x91, 0x92, 0x93,
/*	30    L5    L6    33    34    tab   q     w  	*/
	0xFF, 0x94, 0x95, 0xFF, 0xFF, '\t', 0x11, 0x17,
/*	e     r     t     y     u     i     o     p    	*/
	0x05, 0x12, 0x14, 0x19, 0x15, 0x09, 0x0F, 0x10,
/*	[     ]     del   43    R7    R8    R9    47   	*/
	0x1B, 0x1D, 0x7F, 0xFF, 0x96, 0x97, 0x98, 0xFF,
/*	L7    L8    4a    4b    ctrl  a     s     d	*/
	0x99, 0x9a, 0xFF, 0xFF, 0xF0, 0x01, 0x13, 0x04,
/*	f     g     h     j     k     l     ;     '   	*/
	0x06, 0x07, 0x08, 0x0A, 0x0B, 0x0C,':',  '"',
/*	\     ret   5a    R10   R11   R12   5e    L9	*/
	0x1C, '\n',  0xFF, 0x9b, 0x9c, 0x9d, 0xFF, 0x9e, 
/*	60    L10   62    shift z     x     c     v	*/
	0xFF, 0x9f, 0xFF, 0xF1, 0x1A, 0x18, 0x03, 0x16,
/*	b     n     m     ,     .     /     shift lf	*/
	0x02, 0x0E, 0x0D, '<',  '>',  '?',  0xF1, '\r',
/*	R13   R14   R15   73    74    75    76    caps	*/
	0xA0, 0xA1, 0xA2, 0xFF, 0xFF, 0xFF, 0xFF, 0xF2,
/*	left  79    right 7b    7c    7d    7e    7f	*/
	0xA3, ' ',  0xA4, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
};

uchar keymapshiftctrl[128] = {
/*	00    L1    02    L2    04    F1    F2    07	*/
	0xFF, 0x80, 0xFF, 0x81, 0xFF, 0x82, 0x83, 0xFF,
/*	F3    09    F4    0b    F5    0d    F6    0f  	*/
	0x84, 0xFF, 0x85, 0xFF, 0x86, 0xFF, 0x87, 0xFF,
/*	F7    F8    F9    Alt   14    R1    R2    R3	*/
	0x88, 0x89, 0x8a, 0x8b, 0xFF, 0x8c, 0x8d, 0x8e,
/*	18    L3    L4    1b    1c    Esc   1     2	*/
	0xFF, 0x8f, 0x90, 0xFF, 0xFF, 0x1b, '!',  0x00,
/*	3     4     5     6     7     8     9     0	*/
	'#',  '$',  '%',  0x1E, '&',  '*',  '(',  ')',
/*	-     =     `     bs    2c    R4    R5    R6	*/
	0x1F, '+',  '~', '\b', 0xFF, 0x91, 0x92, 0x93,
/*	30    L5    L6    33    34    tab   q     w  	*/
	0xFF, 0x94, 0x95, 0xFF, 0xFF, '\t', 0x11, 0x17,
/*	e     r     t     y     u     i     o     p    	*/
	0x05, 0x12, 0x14, 0x19, 0x15, 0x09, 0x0F, 0x10,
/*	[     ]     del   43    R7    R8    R9    47   	*/
	0x1B, 0x1D, 0x7F, 0xFF, 0x96, 0x97, 0x98, 0xFF,
/*	L7    L8    4a    4b    ctrl  a     s     d	*/
	0x99, 0x9a, 0xFF, 0xFF, 0xF0, 0x01, 0x13, 0x04,
/*	f     g     h     j     k     l     ;     '   	*/
	0x06, 0x07, 0x08, 0x0A, 0x0B, 0x0C,':',  '"',
/*	\     ret   5a    R10   R11   R12   5e    L9	*/
	0x1C, '\n',  0xFF, 0x9b, 0x9c, 0x9d, 0xFF, 0x9e, 
/*	60    L10   62    shift z     x     c     v	*/
	0xFF, 0x9f, 0xFF, 0xF1, 0x1A, 0x18, 0x03, 0x16,
/*	b     n     m     ,     .     /     shift lf	*/
	0x02, 0x0E, 0x0D, '<',  '>',  '?',  0xF1, '\r',
/*	R13   R14   R15   73    74    75    76    caps	*/
	0xA0, 0xA1, 0xA2, 0xFF, 0xFF, 0xFF, 0xFF, 0xF2,
/*	left  79    right 7b    7c    7d    7e    7f	*/
	0xA3, ' ',  0xA4, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
};

static uchar *kbdmap[4] = {
	keymap,
	keymapshift,
	keymapctrl,
	keymapshiftctrl
};

void
kbdstate(int c)
{
	static shift = 0x00;
	static caps = 0;
	static repeatc = -1;
	static long startclick;
	int tc;

	tc = kbdmap[shift][c&0x7F];

/*
	if(c==0xFFFF && repeatc!=-1 && clicks>startclick+40 && (clicks-startclick)%3==0){
		kbdc = repeatc;
.
347c
	 * Mouse
.
345a
	dp = &duart[0];
	if(cause & ExtPendA)
		duartwrreg(dp, 0, ResExtPend);
	if(cause & RxPendA){
		ch = *dp->data;
		kbdstate(ch);
	}
	if(cause & TxPendA)
		duartwrreg(dp, 0, ResTxPend);
.
344c
	 * Keyboard
.
341,342c
	cause = duartrdreg(&duart[0], 3);
.
338,339c
	char ch;
	int cause;
	Duart *dp;
.
336c
duartintr(void)
.
328,332c
		/*
		 *  enable I/O, 8 bits/character
		 */
		dp->sticky[3] = RxEna | Rx8bits;
		duartwrreg(dp, 3, 0);
		dp->sticky[5] = TxEna | Tx8bits;
		duartwrreg(dp, 5, 0);

		/*
	 	 *  turn on interrupts
		 */
		dp->sticky[1] |= TxIntEna | RxIntAllEna;
		duartwrreg(dp, 1, 0);
		dp->sticky[9] |= IntEna;
		duartwrreg(dp, 9, 0);
	}

	/*
	 *  turn on DTR and RTS
	 */
	dp = &duart[1];
	dp->sticky[5] |= TxRTS | TxDTR;
	duartwrreg(dp, 5, 0);
.
320,326c
	for(dp=duart; dp < &duart[2]; dp++){
		memset(dp->sticky, 0, sizeof(dp->sticky));
.
314,318c
	/*
	 *  get port addresses
	 */
	duart[0].ptr = &zp->ptra;
	duart[0].data = &zp->dataa;
	duart[1].ptr = &zp->ptrb;
	duart[1].data = &zp->datab;
.
309,312c
	k = kmappa(KMDUART, PTEIO|PTENOCACHE);
	zp = (Z8530*)k->va;
.
306,307c
	Duart *dp;
	Z8530 *zp;
	KMap *k;
.
304c
duartinit(void)
.
302a
/*
 * Initialize just keyboard and mouse for now
 */
.
296,300c
	brconst = 10000000/(16*2*rate) - 2;
	duartwrreg(dp, 12, brconst & 0xff);
	duartwrreg(dp, 13, (brconst>>8) & 0xff);
.
293,294c
	int brconst;
.
291c
duartsetbaud(Duart *dp, int rate)
.
287,289c
/*
 *  set the baud rate by calculating and setting the baudrate
 *  generator constant.  This will work with fairly non-standard
 *  baud rates.
 */
.
274,284c
	*dp->ptr = addr;
	return *dp->ptr;
.
271,272c
ushort
duartrdreg(Duart *dp, int addr)
.
264,268c
	*dp->ptr = addr;
	*dp->ptr = dp->sticky[addr] | value;
.
262c
duartwrreg(Duart *dp, int addr, int value)
.
260a
/*
 *  Access registers using the pointer in register 0.
 */
.
228,259c
#define PRINTING	0x4
#define MASK		0x1
.
225,226c
	QLock;
	ushort	sticky[16];	/* sticky write register values */
	uchar	*ptr;		/* command/pointer register in Z8530 */
	uchar	*data;		/* data register in Z8530 */
};
Duart	duart[2];
.
219,223c
	uchar	ptrb;
	uchar	dummy1;
	uchar	datab;
	uchar	dummy2;
	uchar	ptra;
	uchar	dummy3;
	uchar	dataa;
	uchar	dummy4;
};

#define NDELIM 5
typedef struct Duart	Duart;
struct Duart
.
216,217c
	/* rr 3 */
	ExtPendB=	1,	
	TxPendB=	1<<1,
	RxPendB=	1<<2,
	ExtPendA=	1<<3,	
	TxPendA=	1<<4,
	RxPendA=	1<<5,
};

typedef struct Z8530	Z8530;
struct Z8530
.
208,214c
	/* rr 0 */
	RxReady=	1,
	TxReady=	1<<2,
	RxDCD=		1<<3,
	RxCTS=		1<<5,
	RxBreak=	1<<7,
.
197,206c
	/* wr 14 */
	BREna=		1,
	BRSource=	2,
.
186,195c
	/* wr 11 */
	TRxCOutBR=	2,
	TxClockBR=	2<<3,
	RxClockBR=	2<<5,
	TRxCOI=		1<<2,
.
175,184c
	/* wr 9 */
	IntEna=		1<<3,
	ResetB=		1<<6,
	ResetA=		2<<6,
	HardReset=	3<<6,
.
173c
	/* wr 5 */
	TxRTS=		1<<1,
	TxEna=		1<<3,
	TxBreak=	1<<4,
	TxDTR=		1<<7,
	Tx5bits=	0<<5,
	Tx7bits=	1<<5,
	Tx6bits=	2<<5,
	Tx8bits=	3<<5,
.
168,171c
	/* wr 4 */
	SyncMode=	0<<2,
	Rx1stop=	1<<2,
	Rx1hstop=	2<<2,
	Rx2stop=	3<<2,
	X16=		1<<6,
.
149,166c
	/* wr 3 */
	RxEna=		1,
	Rx5bits=	0<<6,
	Rx7bits=	1<<6,
	Rx6bits=	2<<6,
	Rx8bits=	3<<6,
.
100,147c
	/* wr 1 */
	TxIntEna=	1<<1,
	RxIntDis=	0<<3,
	RxIntFirstEna=	1<<3,
	RxIntAllEna=	2<<3,
.
85,98c
enum
{
	/* wr 0 */
	ResExtPend=	2<<3,
	ResTxPend=	5<<3,
	ResErr=		6<<3,
.
83c
 *  Driver for the Z8530.
.
42d
27a
void	kbdstate(int);
.
23d
## diffname ss/screen.c 1991/0110
## diff -e /n/bootesdump/1990/1231/sys/src/9/sparc/screen.c /n/bootesdump/1991/0110/sys/src/9/sparc/screen.c
292a
	cause = duartrdreg(&duart[0], 3);
.
268a

.
## diffname ss/screen.c 1991/0112
## diff -e /n/bootesdump/1991/0110/sys/src/9/sparc/screen.c /n/bootesdump/1991/0112/sys/src/9/sparc/screen.c
510,512c
	if(tc == 0xB6)	/* Compose */
		kbdstate = 1;
	else{
		switch(kbdstate){
		case 1:
			k1 = tc;
			kbdstate = 2;
			break;
		case 2:
			k2 = tc;
			tc = latin1(k1, k2);
			if(c == 0){
				kbdchar(k1);
				tc = k2;
			}
			/* fall through */
		default:
			kbdstate = 0;
			kbdchar(tc);
		}
	}
.
457d
453a
	static int kbdstate, k1, k2;
.
446a
struct latin
{
	uchar	l;
	char	c[2];
}latintab[] = {
	'€',	"!!",	/* spanish initial ! */
	'€',	"c|",	/* cent */
	'€',	"c$",	/* cent */
	'€',	"l$",	/* pound sterling */
	'€',	"g$",	/* general currency */
	'€',	"y$",	/* yen */
	'€',	"j$",	/* yen */
	'€',	"||",	/* broken vertical bar */
	'€',	"SS",	/* section symbol */
	'€',	"\"\"",	/* dieresis */
	'€',	"cr",	/* copyright */
	'€',	"cO",	/* copyright */
	'€',	"sa",	/* super a, feminine ordinal */
	'€',	"<<",	/* left angle quotation */
	'€',	"no",	/* not sign, hooked overbar */
	'€',	"--",	/* soft hyphen */
	'€',	"rg",	/* registered trademark */
	'€',	"__",	/* macron */
	'€',	"s0",	/* degree (sup o) */
	'€',	"+-",	/* plus-minus */
	'€',	"s2",	/* sup 2 */
	'€',	"s3",	/* sup 3 */
	'€',	"''",	/* grave accent */
	'€',	"mu",	/* mu */
	'€',	"pg",	/* paragraph (pilcrow) */
	'€',	"..",	/* centered . */
	'€',	",,",	/* cedilla */
	'€',	"s1",	/* sup 1 */
	'€',	"so",	/* sup o */
	'€',	">>",	/* right angle quotation */
	'€',	"14",	/* 1/4 */
	'€',	"12",	/* 1/2 */
	'€',	"34",	/* 3/4 */
	'€',	"??",	/* spanish initial ? */
	'€',	"A`",	/* A grave */
	'€',	"A'",	/* A acute */
	'€',	"A^",	/* A circumflex */
	'€',	"A~",	/* A tilde */
	'€',	"A\"",	/* A dieresis */
	'€',	"A:",	/* A dieresis */
	'€',	"Ao",	/* A circle */
	'€',	"AO",	/* A circle */
	'€',	"Ae",	/* AE ligature */
	'€',	"AE",	/* AE ligature */
	'€',	"C,",	/* C cedilla */
	'€',	"E`",	/* E grave */
	'€',	"E'",	/* E acute */
	'€',	"E^",	/* E circumflex */
	'€',	"E\"",	/* E dieresis */
	'€',	"E:",	/* E dieresis */
	'€',	"I`",	/* I grave */
	'€',	"I'",	/* I acute */
	'€',	"I^",	/* I circumflex */
	'€',	"I\"",	/* I dieresis */
	'€',	"I:",	/* I dieresis */
	'€',	"D-",	/* Eth */
	'€',	"N~",	/* N tilde */
	'€',	"O`",	/* O grave */
	'€',	"O'",	/* O acute */
	'€',	"O^",	/* O circumflex */
	'€',	"O~",	/* O tilde */
	'€',	"O\"",	/* O dieresis */
	'€',	"O:",	/* O dieresis */
	'€',	"OE",	/* O dieresis */
	'€',	"Oe",	/* O dieresis */
	'€',	"xx",	/* times sign */
	'€',	"O/",	/* O slash */
	'€',	"U`",	/* U grave */
	'€',	"U'",	/* U acute */
	'€',	"U^",	/* U circumflex */
	'€',	"U\"",	/* U dieresis */
	'€',	"U:",	/* U dieresis */
	'€',	"UE",	/* U dieresis */
	'€',	"Ue",	/* U dieresis */
	'€',	"Y'",	/* Y acute */
	'€',	"P|",	/* Thorn */
	'€',	"Th",	/* Thorn */
	'€',	"TH",	/* Thorn */
	'€',	"ss",	/* sharp s */
	'€',	"a`",	/* a grave */
	'€',	"a'",	/* a acute */
	'€',	"a^",	/* a circumflex */
	'€',	"a~",	/* a tilde */
	'€',	"a\"",	/* a dieresis */
	'€',	"a:",	/* a dieresis */
	'€',	"ao",	/* a circle */
	'€',	"ae",	/* ae ligature */
	'€',	"c,",	/* c cedilla */
	'€',	"e`",	/* e grave */
	'€',	"e'",	/* e acute */
	'€',	"e^",	/* e circumflex */
	'€',	"e\"",	/* e dieresis */
	'€',	"e:",	/* e dieresis */
	'€',	"i`",	/* i grave */
	'€',	"i'",	/* i acute */
	'€',	"i^",	/* i circumflex */
	'€',	"i\"",	/* i dieresis */
	'€',	"i:",	/* i dieresis */
	'€',	"d-",	/* eth */
	'€',	"n~",	/* n tilde */
	'€',	"o`",	/* o grave */
	'€',	"o'",	/* o acute */
	'€',	"o^",	/* o circumflex */
	'€',	"o~",	/* o tilde */
	'€',	"o\"",	/* o dieresis */
	'€',	"o:",	/* o dieresis */
	'€',	"oe",	/* o dieresis */
	'€',	"-:",	/* divide sign */
	'€',	"o/",	/* o slash */
	'€',	"u`",	/* u grave */
	'€',	"u'",	/* u acute */
	'€',	"u^",	/* u circumflex */
	'€',	"u\"",	/* u dieresis */
	'€',	"u:",	/* u dieresis */
	'€',	"ue",	/* u dieresis */
	'€',	"y'",	/* y acute */
	'€',	"th",	/* thorn */
	'€',	"p|",	/* thorn */
	'€',	"y\"",	/* y dieresis */
	'€',	"y:",	/* y dieresis */
	0,	0,
};

int
latin1(int k1, int k2)
{
	int i;
	struct latin *l;

	for(l=latintab; l->l; l++)
		if(k1==l->c[0] && k2==l->c[1])
			return l->l;
	return 0;
}

.
436c
/*	lloz  79    rloz  7b    7c    r +  7e    7f	*/
.
434c
/*	R13   R14   R15   73    74    75    help  caps	*/
.
428,431c
/*	\     ret   enter R10   R11   R12   ins   L9	*/
	0x1C, '\n', 0xFF, 0x9b, 0x9c, 0x9d, 0xFF, 0x9e, 
/*	60    L10   numlk shift z     x     c     v	*/
	0xFF, 0x9f, 0x7F, 0xF1, 0x1A, 0x18, 0x03, 0x16,
.
422,423c
/*	[     ]     dele  comp  R7    R8    R9    r -	*/
	0x1B, 0x1D, '\b', 0xB6, 0x96, 0x97, 0x98, 0xFF,
.
418,419c
/*	30    L5    del   L6     34    tab   q     w  	*/
	0xFF, 0x94, 0xFF, 0x95, 0xFF, '\t', 0x11, 0x17,
.
408,409c
/*	F3    09    F4    0b    F5    altgr F6    0f  	*/
	0x84, 0xFF, 0x85, 0xFF, 0x86, 0x80, 0x87, 0xFF,
.
401c
/*	lloz  79    rloz  7b    7c    r +  7e    7f	*/
.
399c
/*	R13   R14   R15   73    74    75    help  caps	*/
.
395,396c
/*	60    L10   numlk shift z     x     c     v	*/
	0xFF, 0x9f, 0x7F, 0xF1, 0x1A, 0x18, 0x03, 0x16,
.
393c
/*	\     ret   enter R10   R11   R12   ins   L9	*/
.
387,388c
/*	[     ]     dele  comp  R7    R8    R9    r -	*/
	0x1B, 0x1D, '\b', 0xB6, 0x96, 0x97, 0x98, 0xFF,
.
383,384c
/*	30    L5    del   L6    34    tab   q     w  	*/
	0xFF, 0x94, 0xFF, 0x95, 0xFF, '\t', 0x11, 0x17,
.
373,374c
/*	F3    09    F4    0b    F5    altgr F6    0f  	*/
	0x84, 0xFF, 0x85, 0xFF, 0x86, 0x80, 0x87, 0xFF,
.
366c
/*	lloz  79    rloz  7b    7c    r +  7e    7f	*/
.
364c
/*	R13   R14   R15   73    74    75    help  caps	*/
.
360,361c
/*	60    L10   numlk shift z     x     c     v	*/
	0xFF, 0x9f, 0x7F, 0xF1, 'Z',  'X',  'C', 'V',
.
358c
/*	\     ret   enter R10   R11   R12   ins   L9	*/
.
352,353c
/*	[     ]     dele  comp  R7    R8    R9    r -	*/
	'{',  '}',  '\b', 0xB6, 0x96, 0x97, 0x98, 0xFF,
.
348,349c
/*	30    L5    del   L6    34    tab   q     w  	*/
	0xFF, 0x94, 0xFF, 0x95, 0xFF, '\t', 'Q',  'W',
.
338,339c
/*	F3    09    F4    0b    F5    altgr F6    0f  	*/
	0x84, 0xFF, 0x85, 0xFF, 0x86, 0x80, 0x87, 0xFF,
.
331c
/*	lloz  79    rloz  7b    7c    r +   7e    7f	*/
.
329c
/*	R13   R14   R15   73    74    75    help  caps	*/
.
325,326c
/*	60    L10   numlk shift z     x     c     v	*/
	0xFF, 0x9f, 0x7F, 0xF1, 'z',  'x',  'c', 'v',
.
323c
/*	\     ret   enter R10   R11   R12   ins   L9	*/
.
317,318c
/*	[     ]     dele  comp  R7    R8    R9    r -	*/
	'[',  ']',  '\b', 0xB6, 0x96, 0x97, 0x98, 0xFF,
.
313,314c
/*	30    L5    del   L6   34    tab   q     w  	*/
	0xFF, 0x94, 0xFF, 0x95, 0xFF, '\t', 'q',  'w',
.
303,304c
/*	F3    09    F4    0b    F5    altgr F6    0f  	*/
	0x84, 0xFF, 0x85, 0xFF, 0x86, 0x80, 0x87, 0xFF,
.
298c
 * Map is indexed by keyboard char, output is ASCII.
 * Gnotisms: Return sends newline and Line Feed sends carriage return.
 * Delete and Backspace both send backspace.
 * Num Lock sends delete (rubout).
 * Alt Graph is VIEW (scroll).
 * Compose builds Latin-1 characters.
.
35c
	{0, 0, 1152, 900},
.
33c
	1152/32,
.
## diffname ss/screen.c 1991/0604
## diff -e /n/bootesdump/1991/0201/sys/src/9/sparc/screen.c /n/bootesdump/1991/0604/sys/src/9/slc/screen.c
675a
}

void
buzz(int freq, int dur)
{
}

void
lights(int mask)
{
.
673c
			kbdputc(&kbdq, tc);
.
667c
				kbdputc(&kbdq, k1);
.
592,593c
int
kbdstate(IOQ *q, int c)
.
198,297d
190,196d
186,187c
	while(n-- > 0)
		screenputc(*s++);
.
184c
screenputs(char *s, int n)
.
81,182d
27d
23,25d
## diffname ss/screen.c 1991/0707
## diff -e /n/bootesdump/1991/0604/sys/src/9/slc/screen.c /n/bootesdump/1991/0707/sys/src/9/slc/screen.c
472a
}

int
screenbits(void)
{
	return 1;	/* bits per pixel */
}

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

	/*
	 * The slc monochrome says 0 is white (max intensity)
	 */
	if(p == 0)
		ans = ~0;
	else
		ans = 0;
	*pr = *pg = *pb = ans;
}


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

int
hwcursset(uchar *s, uchar *c, int ox, int oy)
{
	return 0;
}

int
hwcursmove(int x, int y)
{
	return 0;
}

void
mouseclock(void)	/* called splhi */
{
	mouseupdate(1);
.
11a
#include	"mouse.h"
.
## diffname ss/screen.c 1991/0708
## diff -e /n/bootesdump/1991/0707/sys/src/9/slc/screen.c /n/bootesdump/1991/0708/sys/src/9/slc/screen.c
12c
#include	"screen.h"
.
## diffname ss/screen.c 1991/0713
## diff -e /n/bootesdump/1991/0708/sys/src/9/slc/screen.c /n/bootesdump/1991/0713/sys/src/9/slc/screen.c
440,442c
	kbdrepeat(1);
.
434,435c
		goto norepeat;
.
429,430c
		goto norepeat;
.
424,425c
		goto norepeat;
.
418,420c
		goto norepeat;
.
415,416c
			goto norepeat;
.
411,412c
			goto norepeat;
.
406,407c
			goto norepeat;
.
398c
    norepeat:
		kbdrepeat(0);
.
391,396d
386a
	static int repeatc;
.
385d
## diffname ss/screen.c 1991/1108
## diff -e /n/bootesdump/1991/0713/sys/src/9/slc/screen.c /n/bootesdump/1991/1108/sys/src/9/slc/screen.c
240,379d
## diffname ss/screen.c 1991/1211
## diff -e /n/bootesdump/1991/1108/sys/src/9/slc/screen.c /n/bootesdump/1991/1211/sys/src/9/slc/screen.c
305,306c
			kbdputc(&kbdq, ch);
			break;
.
297,303c
			kc[1] = ch;
			c = latin1(kc);
			nk = 2;
		putit:
			lstate = 0;
			if(c != -1)
				kbdputc(&kbdq, c);
			else for(i=0; i<nk; i++)
				kbdputc(&kbdq, kc[i]);
			break;
		case 3:
		case 4:
		case 5:
			kc[lstate-2] = ch;
			lstate++;
			break;
		case 6:
			kc[4] = ch;
			c = unicode(kc);
			nk = 5;
			goto putit;
.
293,294c
			kc[0] = ch;
			lstate = 2;
			if(ch == 'X')
				lstate = 3;
.
291c
		switch(lstate){
.
288,289c
	if(ch == 0xB6)	/* Compose */
		lstate = 1;
.
284,286c
	if(caps && 'a'<=ch && ch<='z')
		ch |= ' ';
	repeatc = ch;
.
280c
	if(ch==0xF2){	/* caps */
.
276c
	if(ch==0xF1){	/* shift */
.
272c
	if(ch == 0xF0){		/* control */
.
267c
		if(ch == 0xF2){	/* caps */
.
263c
		if(ch == 0xF1){	/* shift */
.
259c
		if(ch == 0xF0){		/* control */
.
256c
	if(ch == 0xFF)	/* shouldn't happen; ignore */
.
250c
	ch = kbdmap[shift][c&0x7F];
.
247,248c
	static int lstate;
	static uchar kc[4];
	uchar ch, code;
	int i, nk;
.
## diffname ss/screen.c 1991/1223
## diff -e /n/bootesdump/1991/1211/sys/src/9/slc/screen.c /n/bootesdump/1991/1223/sys/src/9/slc/screen.c
81,82c
	Rune r;
	int i;
	char buf[4];

	while(n > 0){
		i = chartorune(&r, s);
		if(i == 0){
			s++;
			--n;
			continue;
		}
		memmove(buf, s, i);
		buf[i] = 0;
		n -= i;
		s += i;
		if(r == '\n'){
			out.pos.x = MINX;
			out.pos.y += defont0.height;
			if(out.pos.y > gscreen.r.max.y-defont0.height)
				out.pos.y = gscreen.r.min.y;
			gbitblt(&gscreen, Pt(0, out.pos.y), &gscreen,
			    Rect(0, out.pos.y, gscreen.r.max.x, out.pos.y+2*defont0.height), 0);
		}else if(r == '\t'){
			out.pos.x += (8-((out.pos.x-MINX)/out.bwid&7))*out.bwid;
			if(out.pos.x >= gscreen.r.max.x)
				screenputs("\n", 1);
		}else if(r == '\b'){
			if(out.pos.x >= out.bwid+MINX){
				out.pos.x -= out.bwid;
				screenputs(" ", 1);
				out.pos.x -= out.bwid;
			}
		}else{
			if(out.pos.x >= gscreen.r.max.x-out.bwid)
				screenputs("\n", 1);
			out.pos = gstring(&gscreen, out.pos, defont, buf, S);
		}
	}
.
## diffname ss/screen.c 1991/1225
## diff -e /n/bootesdump/1991/1223/sys/src/9/slc/screen.c /n/bootesdump/1991/1225/sys/src/9/slc/screen.c
47,78d
## diffname ss/screen.c 1991/1228
## diff -e /n/bootesdump/1991/1225/sys/src/9/slc/screen.c /n/bootesdump/1991/1228/sys/src/9/slc/screen.c
86a
	unlock(&screenlock);
.
83c
				screenputnl();
.
78,79c
				gstring(&gscreen, out.pos, defont, " ", S);
.
74c
				screenputnl();
.
64,71c
		if(r == '\n')
			screenputnl();
		else if(r == '\t'){
.
52a
	lock(&screenlock);
.
46a
screenputnl(void)
{
	out.pos.x = MINX;
	out.pos.y += defont0.height;
	if(out.pos.y > gscreen.r.max.y-defont0.height)
		out.pos.y = gscreen.r.min.y;
	gbitblt(&gscreen, Pt(0, out.pos.y), &gscreen,
	    Rect(0, out.pos.y, gscreen.r.max.x, out.pos.y+2*defont0.height), 0);
}

void
.
35a
Lock screenlock;

.
## diffname ss/screen.c 1992/0111
## diff -e /n/bootesdump/1991/1228/sys/src/9/slc/screen.c /n/bootesdump/1992/0111/sys/src/9/slc/screen.c
8c
#include	"../port/error.h"
.
## diffname ss/screen.c 1992/0120
## diff -e /n/bootesdump/1992/0111/sys/src/9/slc/screen.c /n/bootesdump/1992/0120/sys/src/9/slc/screen.c
7d
## diffname ss/screen.c 1992/0208
## diff -e /n/bootesdump/1992/0120/sys/src/9/slc/screen.c /n/bootesdump/1992/0208/sys/src/9/slc/screen.c
91c
			out.pos = gsubfstring(&gscreen, out.pos, defont, buf, S);
.
86c
				gsubfstring(&gscreen, out.pos, defont, " ", S);
.
15,16c
extern	GSubfont	defont0;
GSubfont		*defont;
.
## diffname ss/screen.c 1992/0209
## diff -e /n/bootesdump/1992/0208/sys/src/9/slc/screen.c /n/bootesdump/1992/0209/sys/src/9/slc/screen.c
9c
#include	<libng.h>
.
## diffname ss/screen.c 1992/0211
## diff -e /n/bootesdump/1992/0209/sys/src/9/slc/screen.c /n/bootesdump/1992/0211/sys/src/9/slc/screen.c
9c
#include	<libg.h>
.
## diffname ss/screen.c 1992/0321
## diff -e /n/bootesdump/1992/0211/sys/src/9/slc/screen.c /n/bootesdump/1992/0321/sys/src/9/slc/screen.c
2c
#include	"../port/lib.h"
.
## diffname ss/screen.c 1992/0604
## diff -e /n/bootesdump/1992/0321/sys/src/9/slc/screen.c /n/bootesdump/1992/0604/sys/src/9/slc/screen.c
31a
	{0, 0, 1152, 900},
.
## diffname ss/screen.c 1992/0703
## diff -e /n/bootesdump/1992/0604/sys/src/9/slc/screen.c /n/bootesdump/1992/0703/sys/src/9/slc/screen.c
349a
	USED(mask);
.
344a
	USED(freq, dur);
.
## diffname ss/screen.c 1992/0711
## diff -e /n/bootesdump/1992/0703/sys/src/9/slc/screen.c /n/bootesdump/1992/0711/sys/src/9/slc/screen.c
390a
	USED(x, y);
.
384a
	USED(s, c, ox, oy);
.
378a
	USED(p, r, g, b);
.
339a
	return 0;
.
272c
		return 0;
.
269c
		return 0;
.
264a
	USED(q);
.
262c
	uchar ch;
.
## diffname ss/screen.c 1992/0807
## diff -e /n/bootesdump/1992/0807/sys/src/9/slc/screen.c /n/bootesdump/1992/0807/sys/src/9/ss/screen.c
65a
	if(!conf.monitor)
		return;
.
50a
	if(!conf.monitor)
		return;
.
40a
	if(!conf.monitor)
		return;
.
## diffname ss/screen.c 1992/0810
## diff -e /n/bootesdump/1992/0807/sys/src/9/ss/screen.c /n/bootesdump/1992/0810/sys/src/9/ss/screen.c
41,42c
	struct screens *s;

	for(s=screens; s->type; s++)
		if(s->type == conf.monitor)
			goto found;
	/* default is 0th element of table */
	if(conf.monitor){
		s = screens;
		goto found;
	]
	conf.monitor = 0;
	return;

    found:
	gscreen.base = (ulong*)SCREENSEGM;
	gscreen.zero = 0;
	gscreen.width = (s->x<<s->ld)/32;
	gscreen.ldepth = s->ld;
	gscreen.r = Rect(0, 0, s->x, s->y);
	gscreen.clipr = gscreen.r;
	gscreen.cache = 0;
.
27,32c
	ulong	type;
	int	x;
	int	y;
	int	ld;
}screens[] = {
	{ 0xFE010104, 1152, 900, 0 },
.
25c
GBitmap gscreen;

struct screens
.
## diffname ss/screen.c 1992/0811
## diff -e /n/bootesdump/1992/0810/sys/src/9/ss/screen.c /n/bootesdump/1992/0811/sys/src/9/ss/screen.c
52c
	}
.
## diffname ss/screen.c 1992/0812
## diff -e /n/bootesdump/1992/0811/sys/src/9/ss/screen.c /n/bootesdump/1992/0812/sys/src/9/ss/screen.c
59c
	gscreen.width = (s->x<<s->ld)/(8*sizeof(ulong));
	n = sizeof(ulong) * gscreen.width * s->y;
	gscreen.base = (ulong*)kmapregion(DISPLAYRAM, n, PTENOCACHE|PTEIO);
.
57d
46c
		if(strcmp(s->type, str) == 0)
.
43a
	ulong n;
.
41c
screeninit(char *str)
.
34c
	{ "bwtwo", 1152, 900, 0 },
	{ "cgsix", 1152, 900, 3 },
	{ "cgthree", 1152, 900, 3 },
.
29c
	char	*type;
.
## diffname ss/screen.c 1992/0813
## diff -e /n/bootesdump/1992/0812/sys/src/9/ss/screen.c /n/bootesdump/1992/0813/sys/src/9/ss/screen.c
433a
}

/* 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;
.
412,413c
	if(1 || gscreen.ldepth == 0)
		return 0;	/* can't change mono screen colormap */
	else {
		/* perhaps not reliable unless done while vertical blanking ? */
		*(uchar *)&dac->dacaddr = p & 0xFF;
/*
		*(uchar *)&dac->daccolor = r >> 24;
		*(uchar *)&dac->daccolor = g >> 24;
		*(uchar *)&dac->daccolor = b >> 24;
*/
		return 1;
	}
.
401,405c
	if(1 || gscreen.ldepth == 0) {
		if(p == 0)
			ans = ~0;
		else
			ans = 0;
		*pr = *pg = *pb = ans;
	} else {
		*(uchar *)&dac->dacaddr = p & 0xFF;
		r = *(uchar *)&dac->daccolor;
		g = *(uchar *)&dac->daccolor;
		b = *(uchar *)&dac->daccolor;
		*pr = (r<<24) | (r<<16) | (r<<8) | r;
		*pg = (g<<24) | (g<<16) | (g<<8) | g;
		*pb = (b<<24) | (b<<16) | (b<<8) | b;
	}
.
395a
	uchar r, g, b;
.
135c
 * Compose builds Unicode characters.
.
131c
 * Plan 9-isms:
 * Return sends newline and Line Feed sends carriage return.
.
75a
mapdump(void)
{
	int i;
	dac->dacaddr = 0;
	for(i=0; i<100; i++)
		print("%lux ", dac->daccolor);
}

void
.
72a
	dac = (DAC*)kmappa(FRAMEBUF+s->dacaddr, PTENOCACHE|PTEIO);
	if(gscreen.ldepth == 3){
		havecol = 0;	
		if(havecol) {
			/*
			 * For now, just use a fixed colormap, where pixel i is
			 * regarded as 3 bits of red, 3 bits of green, and 2 bits of blue.
			 * Intensities are inverted so that 0 means white, 255 means black.
			 * Exception: pixels 85 and 170 are set to intermediate grey values
			 * so that 2-bit grey scale images will look ok on this screen.
			 */
			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);
		} else {
dac->dacaddr = 4;
dac->daccntrl = 0xFF;
dac->dacaddr = 5;
dac->daccntrl = 0x00;
dac->dacaddr = 6;
dac->daccntrl = 0x40;
dac->dacaddr = 7;
dac->daccntrl = 0x00;

			dac->dacaddr = 0;
			for(i=0; i<252; i+=4) {
				dac->daccolor = ~rep(i,8);
				dac->daccolor = ~rep(i,8);
				dac->daccolor = ~rep(i,8);
			}

/*
			for(i = 0; i<256; i++)
				setcolor(i, ~rep(i,8), ~rep(i,8), ~rep(i,8));
*/
		}
	}
.
46c
	ulong n, r, g, b;
	int i;
	int havecol;
.
34,36c
	{ "bwtwo", 1152, 900, 0, 0x400000 },
	{ "cgsix", 1152, 900, 3, 0x400000 },
	{ "cgthree", 1152, 900, 3, 0x200000 },
.
32a
	ulong	dacaddr;
.
24a
/* Brooktree 458/451 */
typedef struct	DAC DAC;
struct DAC
{
	uchar	pad[16];
	ulong	dacaddr;	/* DAC address register */
	ulong	daccolor;	/* DAC color palette */
	ulong	daccntrl;	/* DAC control register */
	ulong	dacovrl;	/* DAC overlay palette */
}*dac;

.
23c
static ulong	rep(ulong, int);
void		(*kprofp)(ulong);
.
## diffname ss/screen.c 1992/0814
## diff -e /n/bootesdump/1992/0813/sys/src/9/ss/screen.c /n/bootesdump/1992/0814/sys/src/9/ss/screen.c
136,138c
	for(i=0; i<100; i++) {
		dac->dacaddr = i;
		dac->daccolor = i;
		dac->daccolor = i;
		dac->daccolor = i;
		dac->dacaddr = i;
		print("%ux.%ux.%ux ", dac->daccolor, dac->daccolor, dac->daccolor);
	}
.
123d
117,121c
			for(i=0; i<255; i++) {
				dac->dacaddr = i;
				dac->daccolor = i;
				dac->daccolor = i;
				dac->daccolor = i;
.
88c
	dac = (DAC*)kmappa(FRAMEBUF+s->dacaddr, PTENOCACHE|PTEMAINMEM);
.
48c
	{ "cgsix", 1152, 900, 3, 0x200000 },
.
30,34c
uchar pad[3];	uchar	dacaddr;	/* DAC address register */
uchar pad[3];	uchar	daccolor;	/* DAC color palette */
uchar pad[3];	uchar	daccntrl;	/* DAC control register */
uchar pad[3];	uchar	dacovrl;	/* DAC overlay palette */
.
## diffname ss/screen.c 1992/0815
## diff -e /n/bootesdump/1992/0814/sys/src/9/ss/screen.c /n/bootesdump/1992/0815/sys/src/9/ss/screen.c
495,502c
	else{
		dac->addr = p & 0xFF;
		dac->color = r >> 24;
		dac->color = g >> 24;
		dac->color = b >> 24;
.
493c
	if(gscreen.ldepth == 0)
.
479,482c
		*(uchar *)&dac->addr = p & 0xFF;
		r = dac->color;
		g = dac->color;
		b = dac->color;
.
472c
	if(gscreen.ldepth == 0) {
.
470c
	 * The slc monochrome says 0 is white (max intensity).
.
131,144d
125a

			dac->addr = 0;
			for(i=255; i>=0; i--){
				dac->color = i;
				dac->color = i;
				dac->color = i;
			}
.
123,124c
			dac->addr = 4;
			dac->cntrl = 0xFF;
			dac->addr = 5;
			dac->cntrl = 0x00;
			dac->addr = 6;
			dac->cntrl = 0x40;
			dac->addr = 7;
			dac->cntrl = 0x00;
.
107,121d
87c
	dac = (DAC*)(kmappa(FRAMEBUF+s->dacaddr, PTENOCACHE|PTEIO)->va);
.
30,33c
	uchar	addr;	/* DAC address register */
	uchar	pad0[3];
	uchar	color;	/* DAC color palette */
	uchar	pad1[3];
	uchar	cntrl;	/* DAC control register */
	uchar	pad2[3];
	uchar	ovrl;	/* DAC overlay palette */
	uchar	pad3[3];
.
## diffname ss/screen.c 1992/0816
## diff -e /n/bootesdump/1992/0815/sys/src/9/ss/screen.c /n/bootesdump/1992/0816/sys/src/9/ss/screen.c
52c
	{ "cgthree", 1152, 900, 3, 0x200000 },	/* PURE GUESS! */
.
## diffname ss/screen.c 1992/0817
## diff -e /n/bootesdump/1992/0816/sys/src/9/ss/screen.c /n/bootesdump/1992/0817/sys/src/9/ss/screen.c
129a
}

mapdump(void)
{
	dac->addr = 4;
	print("cntrl4 %.2ux\n", dac->cntrl);
	dac->addr = 5;
	print("cntrl5 %.2ux\n", dac->cntrl);
	dac->addr = 6;
	print("cntrl6 %.2ux\n", dac->cntrl);
	dac->addr = 7;
	print("cntrl7 %.2ux\n", dac->cntrl);
.
111,121d
92a
		dac->addr = 4;
		dac->cntrl = 0xFF;	/* enable all planes */
		dac->addr = 5;
		dac->cntrl = 0x00;	/* no blinking */
		dac->addr = 6;
		dac->cntrl = 0x43;	/* enable palette ram and display */
		dac->addr = 7;
		dac->cntrl = 0x00;	/* no tests */
.
36c
	uchar	ovrl;		/* overlay palette */
.
34c
	uchar	cntrl;		/* control register */
.
32c
	uchar	color;		/* color palette */
.
30c
	uchar	addr;		/* address register */
.
## diffname ss/screen.c 1992/0824
## diff -e /n/bootesdump/1992/0817/sys/src/9/ss/screen.c /n/bootesdump/1992/0824/sys/src/9/ss/screen.c
127,138d
103,109c
		/*
		 * For now, just use a fixed colormap, where pixel i is
		 * regarded as 3 bits of red, 3 bits of green, and 2 bits of blue.
		 * Intensities are inverted so that 0 means white, 255 means black.
		 * Exception: pixels 85 and 170 are set to intermediate grey values
		 * so that 2-bit grey scale images will look ok on this screen.
		 */
.
## diffname ss/screen.c 1992/0904
## diff -e /n/bootesdump/1992/0824/sys/src/9/ss/screen.c /n/bootesdump/1992/0904/sys/src/9/ss/screen.c
481,484c
		vid->addr = p & 0xFF;
		vid->color = r >> 24;
		vid->color = g >> 24;
		vid->color = b >> 24;
.
464,467c
		*(uchar *)&vid->addr = p & 0xFF;
		r = vid->color;
		g = vid->color;
		b = vid->color;
.
129a
mapcrap(void)
{
	uchar *v;
	int i;

	v = &vid->mcr;
	for(i=0; i<16; i++,v++)
		print("%lux %.2ux\n", v, *v);
}

void
.
121,123c
				vid->color = i;
				vid->color = i;
				vid->color = i;
.
119c
			vid->addr = 0;
.
93,100c
		vid->addr = 4;
		vid->cntrl = 0xFF;	/* enable all planes */
		vid->addr = 5;
		vid->cntrl = 0x00;	/* no blinking */
		vid->addr = 6;
		vid->cntrl = 0x43;	/* enable palette ram and display */
		vid->addr = 7;
		vid->cntrl = 0x00;	/* no tests */
.
91c
	vid = (Video*)(kmappa(FRAMEBUF(slot)+s->vidaddr, PTENOCACHE|PTEIO)->va);
.
81c
	gscreen.base = (ulong*)kmapregion(DISPLAYRAM(slot), n, PTENOCACHE|PTEIO);
.
59c
screeninit(char *str, int slot)
.
48c
	ulong	vidaddr;
.
38c
	/* Sun-4 video chip */
	uchar	mcr;		/* master control register */
	uchar	sr;		/* status register */
	uchar	csa;		/* cursor start address */
	uchar	cea;		/* cursor end address */
	uchar	hbs;		/* horizontal blank set */
	uchar	hbc;		/* horizontal blank clear */
	uchar	hss;		/* horizontal sync set */
	uchar	hsc;		/* horizontal sync clear */
	uchar	csc;		/* composite sync clear */
	uchar	vbsh;		/* vertical blank set high byte */
	uchar	vbsl;		/* vertical blank set low byte */
	uchar	vbc;		/* vertical blank clear */
	uchar	vss;		/* vertical sync set */
	uchar	vsc;		/* vertical sync clear */
	uchar	xcs;		/* transfer cycle hold off set */
	uchar	xcc;		/* transfer cycle hold off clear */
}*vid;
.
29a
	/* Brooktree 458/451 */
.
26,28c
typedef struct	Video Video;
struct Video
.
## diffname ss/screen.c 1992/0905
## diff -e /n/bootesdump/1992/0904/sys/src/9/ss/screen.c /n/bootesdump/1992/0905/sys/src/9/ss/screen.c
146,155d
55c
#endif
} *vid;
.
37a
#ifdef notright
.
## diffname ss/screen.c 1992/0914
## diff -e /n/bootesdump/1992/0905/sys/src/9/ss/screen.c /n/bootesdump/1992/0914/sys/src/9/ss/screen.c
171c

	if((getpsr()&SPL(15))){
		if(!canlock(&screenlock))
			return;	/* don't deadlock trying to print in interrupt */
	}else
		lock(&screenlock);
.
## diffname ss/screen.c 1992/1012
## diff -e /n/bootesdump/1992/0914/sys/src/9/ss/screen.c /n/bootesdump/1992/1012/sys/src/9/ss/screen.c
24a
void	screenupdate(void);
.
## diffname ss/screen.c 1992/1020
## diff -e /n/bootesdump/1992/1012/sys/src/9/ss/screen.c /n/bootesdump/1992/1020/sys/src/9/ss/screen.c
545a
}

/* only 1 flavor mouse */
void
mousectl(char *x)
{
	USED(x);
.
16a
int	islcd;
.
## diffname ss/screen.c 1992/1030
## diff -e /n/bootesdump/1992/1020/sys/src/9/ss/screen.c /n/bootesdump/1992/1030/sys/src/9/ss/screen.c
553c
	USED(arg);
}

void
screenupdate(Rectangle r)
{
	USED(r);
.
551c
mousectl(char *arg)
.
549c
/*
 *  set/change mouse configuration
 */
.
26d
## diffname ss/screen.c 1992/1104
## diff -e /n/bootesdump/1992/1030/sys/src/9/ss/screen.c /n/bootesdump/1992/1104/sys/src/9/ss/screen.c
556,561d
## diffname ss/screen.c 1993/0217
## diff -e /n/bootesdump/1992/1104/sys/src/9/ss/screen.c /n/bootesdump/1993/0217/sys/src/9/ss/screen.c
72c
	{ "cgthree", 1152, 900, 3, 0x400000 },	/* data from rwolff */
.
## diffname ss/screen.c 1993/0226
## diff -e /n/bootesdump/1993/0217/sys/src/9/ss/screen.c /n/bootesdump/1993/0226/sys/src/9/ss/screen.c
529,534d
## diffname ss/screen.c 1993/0501 # deleted
## diff -e /n/bootesdump/1993/0226/sys/src/9/ss/screen.c /n/fornaxdump/1993/0501/sys/src/brazil/ss/screen.c
1,549d

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].