-- File: EstimateBits.mesa: Calculate the number of alto pages a press.bits takes.
-- Last Edited: March 1, 1982 5:04 PM By: GWilliams
--Added lookup of DiskDescriptor.
DIRECTORY
AltoFileDefs USING [KD],
IODefs USING[CR, ReadChar, ReadDecimal, WriteChar, WriteDecimal, WriteLine, WriteString],
StreamDefs USING [DefaultAccess, NewWordStream, DiskHandle, ReadBlock];
PressBitsEstimate: PROGRAM
IMPORTS IODefs, StreamDefs
=
BEGIN OPEN AltoFileDefs, IODefs, StreamDefs;
Main: PROC[]=
BEGIN
nBands, firstBand, lastBand, scanLen, wordsPerBand, kPerBand, tridentPages: CARDINAL;
bandWidth: CARDINAL = 16;
descriptorH: DiskHandle;
kD: KD;
kDPtr: POINTER TO KD ← @kD;
wordsRead: CARDINAL;
WriteLine["Enter all numbers in decimal."L];
WriteString["First Band: "L];
firstBand ← ReadDecimal[]; WriteChar[CR];
WriteString["Last Band: "L];
lastBand ← ReadDecimal[]; WriteChar[CR];
WriteString["Scan line length: "L];
scanLen ← ReadDecimal[]; WriteChar[CR];
nBands ← (lastBand-firstBand) + 1;
wordsPerBand ← scanLen*bandWidth;
kPerBand ← (wordsPerBand/1024)+1;
tridentPages ← kPerBand*nBands + 1;--the +1 for leader page
descriptorH ← NewWordStream["DiskDescriptor", DefaultAccess];
[wordsRead] ← ReadBlock[descriptorH, kDPtr, SIZE[KD]];
WriteString["This bits file will use "L];
WriteDecimal[tridentPages*4];
WriteLine[" Alto pages."L];
WriteString["Grab pages from server until disk pages = "L];
WriteDecimal[kDPtr.freePages - (tridentPages*4)];
WriteChar[CR];
WriteLine["Type any key to exit."L];
[] ← ReadChar[];
descriptorH.destroy[descriptorH];
END;
Main[];
END.
-- Last Edited: February 24, 1982 4:04 PM By: GWilliams
--Created.