// getmsg.sr


get "BRAVO1.DF"
get "MSG.DF"
get "NEWMSG.DF"


// Outgoing Procedures

external	[
	FFillInUfop
	]


// Outgoing Statics

// external


// Incoming Procedures

external	[
	errhlta
	mapcp
	]


// Incoming Statics

external	[
	mpIffFfs
	mpIffFfp
	vmapstatus
	parsacred
	ttblsacred
	vlook1
	vlook2
	]


// Local Statics

// static


// Local Structures

// structure


// F   F I L L   I N    U F O P

let FFillInUfop(pfop, doc, cp) = valof
[
vmapstatus = statusblind
mapcp(doc, cp, parneeded)

let iff = pfop>>UFOP.iff
if iff ge iffMax then errhlta(208)
let ffp = mpIffFfp ! iff
let itb = nil
let ffv = nil
test ffp<<FFP.fProcval ifso
	switchon iff into
		[
case iffProcYpos:
		pfop ! 1 = parsacred>>PAR.ypos
		endcase

case iffProcDxtb:
		unless parsacred>>PAR.fOldtab do
			resultis false
		pfop ! 1 = parsacred>>PAR.dxtb
		endcase

case iffProcXtb:
		if parsacred>>PAR.fOldtab then
			resultis false
		itb = pfop>>UFOP.ffv
		if itb ge itbMax then errhlta(209)
		pfop ! 1 = itb ge ttblsacred>>TTBL.cw-1 ? xtbNil,
			(lv ttblsacred>>TTBL.ampitbxtb) ! itb
		endcase

case iffProcSub:
		ffv = vlook2<<LOOK2.ofset
		if ffv<<LOOK2.ofsetsgn then
			ffv = ffv + ofsetsgnext
		if ffv gr 0 then
			resultis false
		pfop ! 1 = -ffv
		endcase

case iffProcLeftmarg:
		pfop ! 1 = parsacred>>PAR.xleftmarg
		pfop ! 2 = parsacred>>PAR.xleftmargf
		endcase

// case iffProcTable:
//		pfop ! 1 = parsacred>>PAR.tab
//		endcase

default:
		errhlta(210)
		]
ifnot	[
	let ffs = mpIffFfs ! iff
	let iw = ffs<<FFS.iw
	ffv = selecton iw into
			[
	case iwLook1:	vlook1
	case iwLook2:	vlook2
	default:		parsacred ! (iw - iwMinpar)
			]
	let offbitRt = ffs<<FFS.offbitRt
	let cbit = ffs<<FFS.cbit
	if cbit + offbitRt gr 16 then errhlta(211)
	if cbit ne 16 then
		ffv = (ffv rshift offbitRt) & (1 lshift cbit - 1)
	if iff eq iffSuper then
		[
		if ffv<<LOOK2.ofsetsgn then
			ffv = ffv + ofsetsgnext
		if ffv ls 0 then
			resultis false
		]
	test ffp<<FFP.carg eq 0 ifso
		pfop>>UFOP.ffv = ffv
	ifnot	pfop ! 1 = ffv
	]
resultis true
] // end FFillInUfop