ImagerFrameBufferImpl.mesa
Michael Plass, September 30, 1983 12:26 pm
Provides descriptions of displays as PixelMaps
DIRECTORY ImagerPixelMaps, ColorDisplay, Environment, BitBlt, UserTerminal, ImagerFrameBuffer;
ImagerFrameBufferImpl: PROGRAM
IMPORTS ColorDisplay, UserTerminal
EXPORTS ImagerFrameBuffer
~ BEGIN
lfDisplay: ImagerPixelMaps.PixelMap;
LFDisplay: PUBLIC PROC RETURNS [ImagerPixelMaps.PixelMap] ~ {
IF lfDisplay.refRep = NIL THEN {
bb: BitBlt.BBTable;
[] ← UserTerminal.SetState[on];
bb ← UserTerminal.GetBitBltTable[];
lfDisplay ← [sOrigin: 0, fOrigin: 0, sMin: 0, fMin: 0,
sSize: bb.height,
fSize: bb.width,
refRep: NEW [ImagerPixelMaps.PixelMapRep ← [
pointer: bb.dst.word,
words: LONG[bb.width/Environment.bitsPerWord]*bb.height,
lgBitsPerPixel: 0,
rast: bb.width/Environment.bitsPerWord,
lines: bb.height
]]
];
};
RETURN [lfDisplay];
};
ColorDisplayError: PUBLIC ERROR [reason: ATOM] ~ CODE;
ColorDisplay8: PUBLIC PROC RETURNS [colorDisplay: ImagerPixelMaps.PixelMap] ~ {
IF ColorDisplay.GetMode[] = ColorDisplay.disconnected THEN {
IF ColorDisplay.SetMode[ [FALSE, 8, 0] ] THEN ColorDisplay.TurnOn[]
ELSE ERROR ColorDisplayError[$NoColorDisplay];
}
ELSE IF ColorDisplay.GetMode[] # [FALSE, 8, 0] THEN ERROR ColorDisplayError[$IncompatibleDisplayMode];
colorDisplay ← [sOrigin: 0, fOrigin: 0, sMin: 0, fMin: 0,
sSize: ColorDisplay.height,
fSize: ColorDisplay.width,
refRep: NEW [ImagerPixelMaps.PixelMapRep ← [
pointer: ColorDisplay.baseA,
words: LONG[ColorDisplay.wplA]*ColorDisplay.height,
lgBitsPerPixel: 3,
rast: ColorDisplay.wplA,
lines: ColorDisplay.height
]]
];
FOR i: LONG CARDINAL IN [0..40) DO ColorDisplay.SetColor[ i + 216, 0, i*6, i*6, i*6] ENDLOOP; -- greyscale
FOR i: LONG CARDINAL IN [0..216) DO          -- 6 x 6 x 6 color cube
ColorDisplay.SetColor[ i, 0, 36 * (i MOD 6 + 1), 36 * ((i/6) MOD 6 + 1), 36 * (i/36 + 1)];
ENDLOOP;
};
END.