-- JasmineCalibrate.mesaedit by McGregorDecember 1, 1980 4:56 PM
DIRECTORY
JasmineDefs: FROM "JasmineDefs";
JasmineCalibrate: PROGRAM IMPORTS JasmineDefs EXPORTS JasmineDefs =
BEGIN OPEN JasmineDefs;
RamRec: TYPE = MACHINE DEPENDENT RECORD [pad: [0..15],offset:[0..63],gain:[0..63]];
sh: POINTER TO ScanHead;
rv: ARRAY [0..1024) OF RamRec;
sp: POINTER TO PACKED ARRAY OF [0..377B];
JZeroRam: PROCEDURE = BEGIN
c: CARDINAL;
FOR c IN [0..1024) DO
rv[c] ← RamRec[0,63,0];
ENDLOOP;
JasmineLoadRam[LOOPHOLE[@rv]];
END;
JKRam: PROCEDURE [k: CARDINAL] = BEGIN
c: CARDINAL;
FOR c IN [0..1024 ) DO
rv[c]←RamRec[,63,k];
ENDLOOP;
JasmineLoadRam[LOOPHOLE[@rv]];
END;
JasmineCalibrate: PUBLIC PROCEDURE = BEGIN
p420: POINTER TO UNSPECIFIED = LOOPHOLE[420B];
saved420: POINTER TO POINTER ← p420↑;
under: BOOLEAN;
i: CARDINAL;
max,maxi,tmax,maxval,maxupper,maxlower,tmp,temp,temp1: INTEGER;
line: ARRAY [0..1024) OF INTEGER ← ALL[0];
linea: ARRAY [0..1024) OF INTEGER ← ALL[0];
c: CARDINAL = 100;-- number of lines
g: CARDINAL = 63;-- gain
-- turn off display
p420↑ ← saved420↑;
JasmineSetWindow[0, 1024, 100, 300];
sh←JasmineScanInit[];
JZeroRam[];
--read lines with zero gain and collect sum for c lines
THROUGH [0..c) DO
sp←JasmineReadLine[sh];
FOR i IN [0..1024) DO
line[i]←sp[i]+line[i];
ENDLOOP;
ENDLOOP;
--divide by c to get average
FOR i IN [0..1024) DO
line[i]←line[i]/c;
ENDLOOP;
--read lines with given gain g in order to get max percentage increase.
JKRam[g]; --load given gain
JasmineStep[c,FALSE]; --back up paper
--collect sum for c lines
THROUGH [0..c) DO
sp←JasmineReadLine[sh];
FOR i IN [0..1024) DO
linea[i]←sp[i]+linea[i];
ENDLOOP;
ENDLOOP;
--divide by c to get average
FOR i IN [0..1024) DO
linea[i]←linea[i]/c;
ENDLOOP;
max←0;
maxi←0;
maxval←0;
FOR i IN [0..1024) DO
maxval←MAX[line[i],maxval];
IF (tmp ← linea[i] - line[i]) > max THEN BEGIN max ← tmp; maxi ← i; END;
ENDLOOP;
JZeroRam[];
under ←TRUE;
maxupper←max+(max/8); --set upcoming treshold to max + 16%
maxlower←max+(max/4); --set downgoing treshold to max + 25%
tmax←maxupper;
temp1←g*line[maxi];
FOR i IN [0..1024) DO
temp←maxval-line[i];
IF temp > tmax THEN BEGIN tmax←maxupper; LOOP; END;
tmax←maxlower;
rv[i].gain←ABS[MIN[((temp1/line[i])*temp)/max,g]]; --don’t reorder expression!!
ENDLOOP;
JasmineLoadRam[LOOPHOLE[@rv]];
JasmineScanClose[sh];
p420↑ ← saved420;-- restore display
END;
END.