//FONT EDITOR FOR ALTO FONTS
//OTHER FILES: FED.DEFS FEDA.SR FEDB.SR FEDC.SR
//LOAD WITH BLDR/U FED FEDA FEDB FEDC FORMAT INITALTOIO
//C. THACKER 4/28/75
GET "FED.DEFS"


STATIC
[
FONTVEC
CURRENTFONT
CURSOR
FONT
S420
NEWY
MASKTAB
DISPLAYAREA
DCB
]


LET MAIN() BE
[
	INITALTOIO()
LET FOOX  = TABLE
	[
	0;100000B;140000B;160000B;170000B;174000B;176000B;177000B;
	177400B;177600B;177700B;177740B;177760B;177770B;177774B;
	177776B;177777B;
	]

	MASKTAB = FOOX
	LET CURTAB = TABLE
	[ 0;154000B;154000B;0;154000B;154000B;0;0;0;0;0;0;0;0;0;0;0 ] 
	FOR I= 1 TO 16 DO RV(430B+I) = CURTAB!I //CURSOR SETUP
	CURSOR = CURTAB

	RV MOUSELINK = FALSE


	LET V = VEC 4
	FONTVEC = V
	CURRENTFONT = 0
	FOR I = 0 TO 2 DO FONTVEC!I = RV 1011B
	FONT = RV 1011B
	FONTVEC!3 = INITALTOIO+2
//BUILD A FAKE FONT 3
	FOR I = 0 TO 377B DO (FONTVEC!3)!I = 400B-I
	(FONTVEC!3)!400B = 1
	(FONTVEC!3)!401B = 0



	LET V = VEC NWRDS*LINES
	IF (V & 1) NE 0 THEN V= V+1
	DISPLAYAREA = V
	LET V = VEC 5
	IF (V & 1) NE 0 THEN V = V+1
	DCB = V
	DCB!0 = 0; DCB!1 = NWRDS; DCB!2 = DISPLAYAREA; DCB!3 = LINES/2

	S420 = RV 420B
	RV 420B = DCB

	BSTORE(DISPLAYAREA,0,LINES*NWRDS)

	FEDIT()
]








AND CLEARBLOCK(ITEMPTR) BE
[
	LET HEIGHT = (ITEMPTR>>ITEM.YMAX)-(ITEMPTR>>ITEM.YMIN) 

	LET WIDTH = (ITEMPTR>>ITEM.XMAX) -(ITEMPTR>>ITEM.XMIN) 

	LET STARTBIT = (ITEMPTR>>ITEM.XMIN) REM 16

	LET STARTWORD = DISPLAYAREA + ((ITEMPTR>>ITEM.YMIN)*NWRDS) + ((ITEMPTR>>ITEM.XMIN)/16)

	LET L = WIDTH GR 16? 16,WIDTH

	LET MASK = NOT((MASKTAB! L) RSHIFT STARTBIT)

	FOR P = STARTWORD BY NWRDS TO STARTWORD+(NWRDS*HEIGHT)-1 DO RV P = RV P & MASK

	IF STARTBIT + WIDTH LE 16 THEN RETURN

	STARTWORD = STARTWORD+1

	WIDTH=WIDTH-(16-STARTBIT)
	UNTIL WIDTH LS 16 DO
	[
		FOR P = STARTWORD BY NWRDS TO STARTWORD + (NWRDS*HEIGHT)-1 DO RV P = 0
		WIDTH = WIDTH - 16
		STARTWORD = STARTWORD + 1
	]

	IF WIDTH EQ 0 THEN RETURN

	MASK = NOT(MASKTAB ! WIDTH)

	FOR P = STARTWORD BY NWRDS TO STARTWORD + (NWRDS*HEIGHT)-1 DO RV P = RV P & MASK

]




AND SETBLOCK(ITEMPTR,XREF,YREF) BE
[
	LET HEIGHT = (ITEMPTR>>ITEM.YMAX)-(ITEMPTR>>ITEM.YMIN) 

	LET WIDTH = (ITEMPTR>>ITEM.XMAX) -(ITEMPTR>>ITEM.XMIN) 

	LET STARTBIT = (XREF + ITEMPTR>>ITEM.XMIN) REM 16

	LET STARTWORD = DISPLAYAREA + ((YREF + ITEMPTR>>ITEM.YMIN)*NWRDS) + ((XREF + ITEMPTR>>ITEM.XMIN)/16)

	LET L = WIDTH GR 16? 16,WIDTH

	LET MASK = (MASKTAB ! L) RSHIFT STARTBIT

	FOR P = STARTWORD BY NWRDS TO STARTWORD+(NWRDS*HEIGHT)-1 DO RV P = RV P % MASK

	IF STARTBIT + WIDTH LE 16 THEN RETURN

	STARTWORD = STARTWORD+1

	WIDTH = WIDTH-(16-STARTBIT)
	UNTIL WIDTH LS 16 DO
	[
		FOR P = STARTWORD BY NWRDS TO STARTWORD + (NWRDS*HEIGHT)-1 DO RV P = 177777B
		WIDTH = WIDTH - 16
		STARTWORD = STARTWORD + 1
	]

	IF WIDTH EQ 0 THEN RETURN

	MASK = MASKTAB ! WIDTH

	FOR P = STARTWORD BY NWRDS TO STARTWORD + (NWRDS*HEIGHT)-1 DO RV P = RV P % MASK


]