TextBltImpl.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Levin, April 11, 1983 9:48 am
Russ Atkinson (RRA) January 29, 1985 1:21:48 am PST
DIRECTORY
PrincOps USING [BBptr, BBTableSpace, CharEntry, TextBltArg, TextBltFontHandle, TextBltResult],
PrincOpsUtils USING [AlignedBBTable, BITBLT],
SoftwareTextBlt USING [];
TextBltImpl: PROGRAM
IMPORTS PrincOpsUtils
EXPORTS SoftwareTextBlt = BEGIN
TextBlt: PUBLIC PROC [index: CARDINAL, bitPos: CARDINAL, micaPos: CARDINAL, count: INTEGER, ptr: POINTER TO PrincOps.TextBltArg] RETURNS [ newIndex: CARDINAL, newBitPos: CARDINAL, newMicaPos: CARDINAL, newCount: INTEGER, result: PrincOps.TextBltResult] = {
bbtablespace: PrincOps.BBTableSpace;
bb: PrincOps.BBptr = PrincOpsUtils.AlignedBBTable[@bbtablespace];
font: PrincOps.TextBltFontHandle = ptr.font;
UNTIL index > ptr.last DO
FetchChar: PROC RETURNS [CHAR] = INLINE {RETURN[ptr.text[index]]};
BitWidth: PROC RETURNS [CARDINAL] = INLINE {RETURN[font.font.widths[char]]};
Height: PROC RETURNS [CARDINAL] = INLINE {RETURN[font.height]};
MicaWidth: PROC RETURNS [CARDINAL] = INLINE {RETURN[font.font.char[char].mica]};
Pad: PROC RETURNS [BOOL] = INLINE {RETURN[font.rgflags[char].pad]};
Stop: PROC RETURNS [BOOL] = INLINE {RETURN[font.rgflags[char].stop]};
char: CHAR = FetchChar[];
IF ptr.function = resolve THEN ptr.coord[index] ← bitPos;
IF Stop[] THEN GOTO Quit;
IF micaPos + MicaWidth[] > ptr.margin THEN GOTO Margin;
IF ptr.function = display THEN DisplayChar[ptr, bitPos, char, bb];
bitPos ← bitPos + BitWidth[];
micaPos ← micaPos + MicaWidth[];
IF Pad[] THEN {
count ← count + 1;
IF ptr.function # format THEN {
bitPos ← bitPos + ptr.space;
IF count <= 0 THEN bitPos ← bitPos + 1;
};
};
index ← index + 1;
REPEAT
Quit => result ← stop;
Margin => result ← margin;
FINISHED => result ← normal;
ENDLOOP;
RETURN[index, bitPos, micaPos, count, result]
};
DisplayChar: PROC [ptr: POINTER TO PrincOps.TextBltArg, bitPos: CARDINAL, char: CHAR, bb: PrincOps.BBptr] = {
font: PrincOps.TextBltFontHandle = ptr.font;
ce: LONG POINTER TO PrincOps.CharEntry = @font.font.char[char];
KernLeftWidth: PROC RETURNS [CARDINAL] = INLINE {RETURN[LOOPHOLE[ce.leftKern]]};
KernRightWidth: PROC RETURNS [CARDINAL] = INLINE {RETURN[LOOPHOLE[ce.rightKern]]};
bitPos ← bitPos - KernLeftWidth[];
bb.dst ← [word: ptr.dst + bitPos/16, reserved: 0, bit: bitPos MOD 16];
bb.dstBpl ← INTEGER[ptr.dstBpl];
bb.src ← [word: @font.font.bits[ce.offset], reserved: 0, bit: 0];
bb.srcDesc.srcBpl ← bb.width ← font.font.widths[char] + KernLeftWidth[] + KernRightWidth[];
bb.height ← font.height;
bb.flags ← [
direction: forward, disjoint: TRUE, disjointItems: TRUE,
gray: FALSE, srcFunc: null, dstFunc: or, reserved: 0
];
bb.reserved ← 0;
PrincOpsUtils.BITBLT[bb];
};
END.