-- MesaBandStreamImpl.mesa -- Last changed by Ken Pier, March 14, 1982 6:48 PM DIRECTORY MesaBandStream, PressBandsDefs USING [GetTfsBandsBuffer, ReadTfsPage], Inline USING [COPY]; MesaBandStreamImpl: PROGRAM IMPORTS Inline, PressBandsDefs EXPORTS MesaBandStream = { OPEN PB: PressBandsDefs, MesaBandStream; wordsPerPage: CARDINAL = 256; wordsPerTFSPage: CARDINAL = 1024; InitBandFileBuffer: PUBLIC PROC[] = { wordsLeft _ 0; bRef _ bStart _ PB.GetTfsBandsBuffer[]; bEnd _ bStart+bufferWords; }; GetBand: PUBLIC PROC[to: POINTER, words: CARDINAL] RETURNS [CARDINAL] = { wordsRead, nWords: CARDINAL _ 0; DO nWords _ MIN[wordsLeft, words]; Inline.COPY[from: bRef, nwords: nWords, to: to]; wordsRead _ wordsRead+nWords; IF nWords=words THEN {--buffer had all the words wordsLeft _ wordsLeft-words; bRef _ bRef+words; EXIT; }; --buffer empty and more to COPY. bRef _ bStart; words _ words-wordsLeft; to _ to+wordsLeft; PB.ReadTfsPage; wordsLeft _ wordsPerTFSPage; ENDLOOP; RETURN[wordsRead]; };--GetBand SkipBand: PUBLIC PROC [words: CARDINAL] RETURNS [CARDINAL] = { wordsRead, nWords: CARDINAL _ 0; DO nWords _ MIN[wordsLeft, words]; wordsRead _ wordsRead+nWords; IF nWords=words THEN {--buffer had all the words wordsLeft _ wordsLeft-words; bRef _ bRef+words; EXIT; }; --buffer empty and more to COPY. bRef _ bStart; words _ words-wordsLeft; PB.ReadTfsPage; wordsLeft _ wordsPerTFSPage; ENDLOOP; RETURN[wordsRead]; };--SkipBand --global storage wordsLeft: CARDINAL _ 0;--remaining valid words in Get buffer bufferPages: CARDINAL _ 1; bufferWords: CARDINAL _ bufferPages*wordsPerTFSPage; bStart, bRef, bEnd: POINTER _ NIL; }. LOG March 11, 1982, changed to SHORT POINTERS