// qinitfcode.sr

get "BRAVO1.DF"
get "FORMAT.DF"
get "CHAR.DF"
get "MSG.DF"

// Incoming procedures

external	[
	movec
	]

// Outgoing procedures

external	[
	qinitfcode
	]

// Outgoing statics

external	[
	rgfcode
	]

// Local statics

static	[
	rgfcode
	]

// local manifests

manifest	[ 
	flook1 = 1;
	frmarg = (offset PAR.xrightmarg + 15)/16;
	flmarg = (offset PAR.xleftmarg + 15)/16;
	fdent = (offset PAR.xleftmargf + 15)/16;
	fypos = (offset PAR.ypos + 15)/16;
	fquad = (offset PAR.spec + 15)/16;
	fykeep = (offset PAR.ykeep + 15)/16;

	fcontrol = 2;
	fjust = 1;
	fcenter = 0;

	fuppercase = 10;
	flowercase = 9;
	fvisibuf = 7;
	fovstrike = 6;
	ful = 5;
	fvanish = 4;
	fbold = 3;
	fitalic = 2;
	fext = 1;
	fvisible = 0;
	]


let qinitfcode(alloc) be
[
rgfcode = alloc(128)
movec(rgfcode, rgfcode+127, -1)

qinitfcodebit($q, kquad, fquad, fcontrol)
qinitfcodebit($j, kquad, fquad, fjust)
qinitfcodebit($c, kquad, fquad, fcenter)

qinitfcodebit($a, klook1, flook1, fuppercase)
qinitfcodebit($h, klook1, flook1, flowercase)
qinitfcodebit($s, klook1, flook1, fovstrike)
qinitfcodebit($u, klook1, flook1, ful)
qinitfcodebit($n, klook1, flook1, fvanish)
qinitfcodebit($b, klook1, flook1, fbold)
qinitfcodebit($i, klook1, flook1, fitalic)
qinitfcodebit($g, klook1, flook1, fext)
qinitfcodebit($v, klook1, flook1, fvisible)

for i = $0 to $9 do
	[
	let p = 0
	p << FCODE.kind = kdigit
	p << FCODE.bitn = i-$0
	rgfcode !i = p
	]

(rgfcode+$f) >> FCODE.kind = kfun;
(rgfcode+$o) >> FCODE.kind = koffset;
(rgfcode+$x) >> FCODE.kind = kldln;
(rgfcode+$e) >> FCODE.kind = kldhdr;
(rgfcode+$") >> FCODE.kind = klabel;
(rgfcode + chcr) >> FCODE.kind = kcr
(rgfcode + $() >> FCODE.kind = kitb
(rgfcode + $,) >> FCODE.kind = kxtb
(rgfcode+$t) >> FCODE.kind = ktab

(rgfcode + $\) >>  FCODE.kind = kparastatterm
(rgfcode + $\) >>  FCODE.un = 0

qinitfcodeword($z, frmarg, 1)
qinitfcodeword($l, flmarg, 0)
qinitfcodeword($d, fdent, 0)
qinitfcodeword($y, fypos, 0)
qinitfcodeword($k, fykeep, 0)
qinitfcodeword($p, -1, -1)
]

and qinitfcodebit(ch, kind, wordn, bitn) be
[
let fcode = 0
fcode << FCODE.kind = kind
fcode << FCODE.wordn = wordn
fcode << FCODE.bitn = bitn
rgfcode ! ch = fcode
fcode << FCODE.un = 1
rgfcode ! (ch-#40) = fcode
]

and qinitfcodeword(ch, wordn, subtract) be
[
let fcode = 0
fcode << FCODE.kind = kmeasure
fcode << FCODE.wordn = wordn
fcode << FCODE.un = subtract
rgfcode ! ch = fcode
]