*DEFINE (InitDiacriticalTables) (
	oStartDiaTable EQU OFFSET $
	SET(cEntries,0)
	DEFINE (String1) ()
	DEFINE (String2) ()
	)

*DEFINE (DiacriticalSet(bDiacriticalKey,bFollowingKey,bResultantKey)) (
	DEFINE (tmpString) (String1)
	DEFINE (String1) (tmpString
				DB	bDiacriticalKey,bFollowingKey)
	DEFINE (tmpString) (String2)
	DEFINE (String2) (tmpString
				DB	bResultantKey)
	SET(cEntries, cEntries+1)
	)

*DEFINE (EndDiacriticalTables) (
	cDiacriticalPairs	 DW	 cEntries
	rgwDiacriticalPairs	 LABEL	 WORD
				String1
	rgbTranslationValue	 LABEL	 BYTE
				String2

	oEndDiaTable EQU OFFSET $

	DB (640(oEndDiaTableoStartDiaTable)) DUP (0)
	pDiacriticTable				DD DGroup:cDiacriticalPairs
	)



*DEFINE (InitEscapeKeys) (
	SET(cKeys,0)
	LookupSeg SEGMENT BYTE 'const'
	cEscKeys DW 0
	LookupSeg ENDS
	ExpansionSeg SEGMENT BYTE 'const'
	ExpansionSeg ENDS
	)

*DEFINE (DefEscapeKey(bEsc,bAttr) (rgbIkeys)) LOCAL tmp0 tmp1 (
	ExpansionSeg SEGMENT
	tmp0 LABEL BYTE
	IF(NES(rgbIkeys,''))THEN(
		DB rgbIKeys
	)FI'
	tmp1 LABEL BYTE
	ExpansionSeg ENDS

	LookupSeg SEGMENT
		DB bEsc,bAttr
		DW tmp1tmp0
		DW OFFSET DGROUP:tmp0
	LookupSeg ENDS

	SET(cKeys, cKeys+1)
	)

*DEFINE (EndEscapeKeys) (
	LookupSeg SEGMENT BYTE 'const'
	pEscKeys	 DD DGroup:cEscKeys+2
	ORG OFFSET cEscKeys
		DW	 cKeys
	LookupSeg ENDS
	)

e
 ,iKey BYTE
 ,fIntercepted FLAG
 ,ch EncodedChType
 ,fEscKey FLAG
 ,iEscKey WORD
 ;

fWakeupPending = FALSE;

DO WHILE ibBufInPut <> ibBufInTake;
  * iKey, fWentDown are set from next byte