-- JaMSnapImpl.mesa
-- Last changed by Doug Wyatt, January 16, 1981 12:13 PM

DIRECTORY
AltoDevice USING [Bitmap, ScreenBitmap],
Blt USING [Handle, New, Source, SetBox, Rect],
JaMFnsDefs USING [Register, PopString],
JaMGraphicsDefs USING [GetDC],
JaMSnapDefs USING [],
PressDefs USING [PressFileDescriptor, InitPressFileDescriptor,
PutComputedDots, ClosePressFile];

JaMSnapImpl: PROGRAM
IMPORTS AltoDevice, Blt, JaMFnsDefs, JaMGraphicsDefs, PressDefs
EXPORTS JaMSnapDefs = {

pfd: PressDefs.PressFileDescriptor;

linew: CARDINAL = 40;
line: ARRAY[0..linew) OF WORD;
bb: Blt.Handle ← Blt.New[@line,linew];

JSnap: PROCEDURE = {
bm: AltoDevice.Bitmap ← AltoDevice.ScreenBitmap[];
w: CARDINAL ← 16*bm.raster;
h: CARDINAL ← bm.height;
y: CARDINAL←0;
NextScanLine: PROCEDURE RETURNS[POINTER] = {
Blt.Rect[bb];
bb.sdy←bb.sdy-1;
RETURN[@line];
};
filename: STRING ← [100];
JaMFnsDefs.PopString[filename];
Blt.Source[bb,bm.base,bm.raster];
bb.bbt.sourcetype ← block;
Blt.SetBox[bb,0,0,w,1];
PressDefs.InitPressFileDescriptor[@pfd,filename];
PressDefs.PutComputedDots[p: @pfd, x: 1270, y: 26670-32*h,
nPixels: w, nScanLines: h, bitsPerPixel: 0,
width: 32*w, height: 32*h, nextScanLine: NextScanLine];
PressDefs.ClosePressFile[@pfd];
};

[]←JaMGraphicsDefs.GetDC[]; -- to make sure it’s started
JaMFnsDefs.Register[".snap",JSnap];

}.