-- File RasterLogFontImpl.mesa
-- last edited by Strickberger 19-Jul-85  1:22:31

-- Copyright (C) Xerox Corporation 1982, 1983, 1984, 1985.  All rights reserved.

DIRECTORY
  BandBLT USING [BlItem, charCmd, Font],
  BandBLTImage USING [BandlistSequence, FontloadSequence, Handle, Transfer],
  Environment USING [PageCount],
  File USING [nullFile],
  Heap USING [systemZone],
  RasterLogFont USING [],
  Space USING [Class, Interval, Life, Map, PageCount, wordsPerPage],
  StringSequence USING [Handle];

RasterLogFontImpl: PROGRAM IMPORTS Heap, Space
 EXPORTS RasterLogFont =
  BEGIN
  -- Constants:

  bandlistSequenceLength: CARDINAL = 1;
  bandlistSpaceCount: Space.PageCount = 32;
  fontloadInkwellSpaceCount: Space.PageCount = 1;
  fontloadLeftoverSpaceCount: Space.PageCount = 1;
  fontloadRasterSpaceCount: Space.PageCount = 5;
  fontloadSequenceLength: CARDINAL = 1;
  fontloadVectorSpaceCount: Space.PageCount = 2;

  -- Variables:

  transferInternal: BandBLTImage.Handle;

  -- PUBLIC PROCEDUREs:

  TransferStringSequence: PUBLIC PROCEDURE [sequence: StringSequence.Handle]
    RETURNS [transfer: BandBLTImage.Handle] = BEGIN
    bandList: LONG POINTER;
    BandlistFull: PROCEDURE RETURNS [full: BOOLEAN] = BEGIN
      RETURN[
        full: (bandList - transferInternal.bandlists[0].bandlist.pointer) >
        (bandlistSpaceCount*Space.wordsPerPage - SIZE[BandBLT.BlItem])];
      END;
    bandCountPerLine: CARDINAL = 2;
    emptyLeadingBandCount: CARDINAL = 10;
    xLocation: CARDINAL [0B..17B] = 0B;
    yDisplacement: CARDINAL [0B..7777B] = 22B;
    yLocation: CARDINAL [0B..7777B];
    yOffset: CARDINAL [0B..7777B] = 220B;

    bandList ← transferInternal.bandlists[0].bandlist.pointer;
    THROUGH [FIRST[CARDINAL]..emptyLeadingBandCount) UNTIL BandlistFull[] DO
      LOOPHOLE[bandList, LONG POINTER TO endOfBand BandBLT.BlItem]↑ ←
        BandBLT.BlItem[endOfBand[]];
      bandList ← bandList + SIZE[endOfBand BandBLT.BlItem];
      ENDLOOP;
    FOR i: CARDINAL IN [FIRST[CARDINAL]..sequence.length) UNTIL BandlistFull[] DO
      yLocation ← yOffset;
      FOR column: CARDINAL IN [FIRST[CARDINAL]..sequence[i].length) UNTIL
        BandlistFull[] DO
        LOOPHOLE[bandList, LONG POINTER TO char BandBLT.BlItem]↑ ← BandBLT.BlItem[
          char[
          type: BandBLT.charCmd, font: 0, cc: LOOPHOLE[sequence[i][column]],
          xloc: xLocation, yloc: yLocation]];
        bandList ← bandList + SIZE[char BandBLT.BlItem];
        yLocation ← yLocation + yDisplacement;
        ENDLOOP;
      THROUGH [FIRST[CARDINAL]..bandCountPerLine) UNTIL BandlistFull[] DO
        LOOPHOLE[bandList, LONG POINTER TO endOfBand BandBLT.BlItem]↑ ←
          BandBLT.BlItem[endOfBand[]];
        bandList ← bandList + SIZE[endOfBand BandBLT.BlItem];
        ENDLOOP;
      ENDLOOP;
    LOOPHOLE[bandList, LONG POINTER TO endOfPage BandBLT.BlItem]↑ ←
      BandBLT.BlItem[endOfPage[]];
    RETURN[transfer: transferInternal];
    END;

  -- PRIVATE PROCEDUREs:

  Initialize: PROCEDURE = BEGIN

    InitializeRasters: PROCEDURE = BEGIN
      fontBitMapMemory: LONG POINTER TO FontBitMapMemory =
        transferInternal.fontloads[0].rasters.pointer;
      fontBitMapMemory↑ ← [
        [
        16, 16, [
        00000B, 00000B, 00000B, 00000B, 00000B, 00000B, 00000B, 00000B, 00000B,
        00000B, 00000B, 00000B, 00000B, 00000B, 00000B, 00000B]],  --" "
        [
        16, 16, [
        00700B, 00700B, 00700B, 00700B, 00700B, 00700B, 00700B, 00700B, 00700B,
        00000B, 00000B, 00000B, 00700B, 00700B, 00700B, 00000B]],  --"!"
        [
        16, 16, [
        07070B, 07070B, 07070B, 07070B, 07070B, 07070B, 00000B, 00000B, 00000B,
        00000B, 00000B, 00000B, 00000B, 00000B, 00000B, 00000B]],  --"""
        [
        16, 16, [
        07070B, 07070B, 07070B, 77777B, 77777B, 77777B, 07070B, 07070B, 07070B,
        77777B, 77777B, 77777B, 07070B, 07070B, 07070B, 00000B]],  --"#"
        [
        16, 16, [
        77777B, 77777B, 77777B, 77700B, 77700B, 77700B, 00700B, 00700B, 00700B,
        00777B, 00777B, 00777B, 77777B, 77777B, 77777B, 00000B]],  --"$"
        [
        16, 16, [
        70007B, 70007B, 70007B, 00070B, 00070B, 00070B, 00700B, 00700B, 00700B,
        07000B, 07000B, 07000B, 70007B, 70007B, 70007B, 00000B]],  --"%"
        [
        16, 16, [
        77700B, 77700B, 77700B, 70700B, 70700B, 70700B, 70707B, 70707B, 70707B,
        70777B, 70777B, 70777B, 77707B, 77707B, 77707B, 00000B]],  --"&"
        [
        16, 16, [
        00700B, 00700B, 00700B, 00700B, 00700B, 00700B, 00000B, 00000B, 00000B,
        00000B, 00000B, 00000B, 00000B, 00000B, 00000B, 00000B]],  --"'"
        [
        16, 16, [
        00700B, 00700B, 00700B, 07000B, 07000B, 07000B, 07000B, 07000B, 07000B,
        07000B, 07000B, 07000B, 00700B, 00700B, 00700B, 00000B]],  --"("
        [
        16, 16, [
        00700B, 00700B, 00700B, 00070B, 00070B, 00070B, 00070B, 00070B, 00070B,
        00070B, 00070B, 00070B, 00700B, 00700B, 00700B, 00000B]],  --")"
        [
        16, 16, [
        00700B, 00700B, 00700B, 07770B, 07770B, 07770B, 77777B, 77777B, 77777B,
        07770B, 07770B, 07770B, 00700B, 00700B, 00700B, 00000B]],  --"*"
        [
        16, 16, [
        00000B, 00000B, 00000B, 00700B, 00700B, 00700B, 07770B, 07770B, 07770B,
        00700B, 00700B, 00700B, 00000B, 00000B, 00000B, 00000B]],  --"+"
        [
        16, 16, [
        00000B, 00000B, 00000B, 00000B, 00000B, 00000B, 00000B, 00000B, 00000B,
        00700B, 00700B, 00700B, 07000B, 07000B, 07000B, 00000B]],  --","
        [
        16, 16, [
        00000B, 00000B, 00000B, 00000B, 00000B, 00000B, 07770B, 07770B, 07770B,
        00000B, 00000B, 00000B, 00000B, 00000B, 00000B, 00000B]],  --"-"
        [
        16, 16, [
        00000B, 00000B, 00000B, 00000B, 00000B, 00000B, 00000B, 00000B, 00000B,
        00000B, 00000B, 00000B, 00700B, 00700B, 00700B, 00000B]],  --"."
        [
        16, 16, [
        00007B, 00007B, 00007B, 00070B, 00070B, 00070B, 00700B, 00700B, 00700B,
        07000B, 07000B, 07000B, 70000B, 70000B, 70000B, 00000B]],  --"/"
        [
        16, 16, [
        77777B, 77777B, 77777B, 70077B, 70077B, 70077B, 70707B, 70707B, 70707B,
        77007B, 77007B, 77007B, 77777B, 77777B, 77777B, 00000B]],  --"0"
        [
        16, 16, [
        00700B, 00700B, 00700B, 07700B, 07700B, 07700B, 00700B, 00700B, 00700B,
        00700B, 00700B, 00700B, 77777B, 77777B, 77777B, 00000B]],  --"1"
        [
        16, 16, [
        77777B, 77777B, 77777B, 00007B, 00007B, 00007B, 77777B, 77777B, 77777B,
        70000B, 70000B, 70000B, 77777B, 77777B, 77777B, 00000B]],  --"2"
        [
        16, 16, [
        77777B, 77777B, 77777B, 00007B, 00007B, 00007B, 77777B, 77777B, 77777B,
        00007B, 00007B, 00007B, 77777B, 77777B, 77777B, 00000B]],  --"3"
        [
        16, 16, [
        70070B, 70070B, 70070B, 70070B, 70070B, 70070B, 77777B, 77777B, 77777B,
        00070B, 00070B, 00070B, 00070B, 00070B, 00070B, 00000B]],  --"4"
        [
        16, 16, [
        77777B, 77777B, 77777B, 70000B, 70000B, 70000B, 77777B, 77777B, 77777B,
        00007B, 00007B, 00007B, 77777B, 77777B, 77777B, 00000B]],  --"5"
        [
        16, 16, [
        77777B, 77777B, 77777B, 70000B, 70000B, 70000B, 77777B, 77777B, 77777B,
        70007B, 70007B, 70007B, 77777B, 77777B, 77777B, 00000B]],  --"6"
        [
        16, 16, [
        77777B, 77777B, 77777B, 00007B, 00007B, 00007B, 00007B, 00007B, 00007B,
        00007B, 00007B, 00007B, 00007B, 00007B, 00007B, 00000B]],  --"7"
        [
        16, 16, [
        77777B, 77777B, 77777B, 70007B, 70007B, 70007B, 77777B, 77777B, 77777B,
        70007B, 70007B, 70007B, 77777B, 77777B, 77777B, 00000B]],  --"8"
        [
        16, 16, [
        77777B, 77777B, 77777B, 70007B, 70007B, 70007B, 77777B, 77777B, 77777B,
        00007B, 00007B, 00007B, 77777B, 77777B, 77777B, 00000B]],  --"9"
        [
        16, 16, [
        00000B, 00000B, 00000B, 00700B, 00700B, 00700B, 00000B, 00000B, 00000B,
        00700B, 00700B, 00700B, 00000B, 00000B, 00000B, 00000B]],  --":"
        [
        16, 16, [
        00000B, 00000B, 00000B, 00700B, 00700B, 00700B, 00000B, 00000B, 00000B,
        00700B, 00700B, 00700B, 07000B, 07000B, 07000B, 00000B]],  --";"
        [
        16, 16, [
        00070B, 00070B, 00070B, 00700B, 00700B, 00700B, 07000B, 07000B, 07000B,
        00700B, 00700B, 00700B, 00070B, 00070B, 00070B, 00000B]],  --"<"
        [
        16, 16, [
        00000B, 00000B, 00000B, 07770B, 07770B, 07770B, 00000B, 00000B, 00000B,
        07770B, 07770B, 07770B, 00000B, 00000B, 00000B, 00000B]],  --"="
        [
        16, 16, [
        07000B, 07000B, 07000B, 00700B, 00700B, 00700B, 00070B, 00070B, 00070B,
        00700B, 00700B, 00700B, 07000B, 07000B, 07000B, 00000B]],  --">"
        [
        16, 16, [
        07770B, 07770B, 07770B, 07070B, 07070B, 07070B, 00070B, 00070B, 00070B,
        00700B, 00700B, 00700B, 00700B, 00700B, 00700B, 00000B]],  --"?"
        [
        16, 16, [
        07777B, 07777B, 07777B, 00007B, 00007B, 00007B, 77707B, 77707B, 77707B,
        70707B, 70707B, 70707B, 77777B, 77777B, 77777B, 00000B]],  --"@"
        [
        16, 16, [
        77777B, 77777B, 77777B, 70007B, 70007B, 70007B, 77777B, 77777B, 77777B,
        70007B, 70007B, 70007B, 70007B, 70007B, 70007B, 00000B]],  --"A"
        [
        16, 16, [
        77770B, 77770B, 77770B, 70070B, 70070B, 70070B, 77777B, 77777B, 77777B,
        70007B, 70007B, 70007B, 77777B, 77777B, 77777B, 00000B]],  --"B"
        [
        16, 16, [
        77777B, 77777B, 77777B, 70000B, 70000B, 70000B, 70000B, 70000B, 70000B,
        70000B, 70000B, 70000B, 77777B, 77777B, 77777B, 00000B]],  --"C"
        [
        16, 16, [
        77000B, 77000B, 77000B, 70700B, 70700B, 70700B, 70070B, 70070B, 70070B,
        70007B, 70007B, 70007B, 77777B, 77777B, 77777B, 00000B]],  --"D"
        [
        16, 16, [
        77777B, 77777B, 77777B, 70000B, 70000B, 70000B, 77777B, 77777B, 77777B,
        70000B, 70000B, 70000B, 77777B, 77777B, 77777B, 00000B]],  --"E"
        [
        16, 16, [
        77777B, 77777B, 77777B, 70000B, 70000B, 70000B, 77777B, 77777B, 77777B,
        70000B, 70000B, 70000B, 70000B, 70000B, 70000B, 00000B]],  --"F"
        [
        16, 16, [
        77777B, 77777B, 77777B, 70000B, 70000B, 70000B, 70077B, 70077B, 70077B,
        70007B, 70007B, 70007B, 77777B, 77777B, 77777B, 00000B]],  --"G"
        [
        16, 16, [
        70007B, 70007B, 70007B, 70007B, 70007B, 70007B, 77777B, 77777B, 77777B,
        70007B, 70007B, 70007B, 70007B, 70007B, 70007B, 00000B]],  --"H"
        [
        16, 16, [
        77777B, 77777B, 77777B, 00700B, 00700B, 00700B, 00700B, 00700B, 00700B,
        00700B, 00700B, 00700B, 77777B, 77777B, 77777B, 00000B]],  --"I"
        [
        16, 16, [
        00007B, 00007B, 00007B, 00007B, 00007B, 00007B, 00007B, 00007B, 00007B,
        70007B, 70007B, 70007B, 77777B, 77777B, 77777B, 00000B]],  --"J"
        [
        16, 16, [
        70007B, 70007B, 70007B, 70070B, 70070B, 70070B, 77700B, 77700B, 77700B,
        70070B, 70070B, 70070B, 70007B, 70007B, 70007B, 00000B]],  --"K"
        [
        16, 16, [
        70000B, 70000B, 70000B, 70000B, 70000B, 70000B, 70000B, 70000B, 70000B,
        70000B, 70000B, 70000B, 77777B, 77777B, 77777B, 00000B]],  --"L"
        [
        16, 16, [
        77777B, 77777B, 77777B, 70707B, 70707B, 70707B, 70707B, 70707B, 70707B,
        70707B, 70707B, 70707B, 70707B, 70707B, 70707B, 00000B]],  --"M"
        [
        16, 16, [
        70007B, 70007B, 70007B, 77007B, 77007B, 77007B, 70707B, 70707B, 70707B,
        70077B, 70077B, 70077B, 70007B, 70007B, 70007B, 00000B]],  --"N"
        [
        16, 16, [
        77777B, 77777B, 77777B, 70007B, 70007B, 70007B, 70007B, 70007B, 70007B,
        70007B, 70007B, 70007B, 77777B, 77777B, 77777B, 00000B]],  --"O"
        [
        16, 16, [
        77777B, 77777B, 77777B, 70007B, 70007B, 70007B, 77777B, 77777B, 77777B,
        70000B, 70000B, 70000B, 70000B, 70000B, 70000B, 00000B]],  --"P"
        [
        16, 16, [
        77777B, 77777B, 77777B, 70007B, 70007B, 70007B, 70707B, 70707B, 70707B,
        70707B, 70707B, 70707B, 77777B, 77777B, 77777B, 00000B]],  --"Q"
        [
        16, 16, [
        77777B, 77777B, 77777B, 70007B, 70007B, 70007B, 77777B, 77777B, 77777B,
        70070B, 70070B, 70070B, 70007B, 70007B, 70007B, 00000B]],  --"R"
        [
        16, 16, [
        77777B, 77777B, 77777B, 77000B, 77000B, 77000B, 00700B, 00700B, 00700B,
        00077B, 00077B, 00077B, 77777B, 77777B, 77777B, 00000B]],  --"S"
        [
        16, 16, [
        77777B, 77777B, 77777B, 00700B, 00700B, 00700B, 00700B, 00700B, 00700B,
        00700B, 00700B, 00700B, 00700B, 00700B, 00700B, 00000B]],  --"T"
        [
        16, 16, [
        70007B, 70007B, 70007B, 70007B, 70007B, 70007B, 70007B, 70007B, 70007B,
        70007B, 70007B, 70007B, 77777B, 77777B, 77777B, 00000B]],  --"U"
        [
        16, 16, [
        70007B, 70007B, 70007B, 70007B, 70007B, 70007B, 70007B, 70007B, 70007B,
        07070B, 07070B, 07070B, 00700B, 00700B, 00700B, 00000B]],  --"V"
        [
        16, 16, [
        70707B, 70707B, 70707B, 70707B, 70707B, 70707B, 70707B, 70707B, 70707B,
        70707B, 70707B, 70707B, 77777B, 77777B, 77777B, 00000B]],  --"W"
        [
        16, 16, [
        70007B, 70007B, 70007B, 07070B, 07070B, 07070B, 00700B, 00700B, 00700B,
        07070B, 07070B, 07070B, 70007B, 70007B, 70007B, 00000B]],  --"X"
        [
        16, 16, [
        70007B, 70007B, 70007B, 07070B, 07070B, 07070B, 00700B, 00700B, 00700B,
        00700B, 00700B, 00700B, 00700B, 00700B, 00700B, 00000B]],  --"Y"
        [
        16, 16, [
        77777B, 77777B, 77777B, 00077B, 00077B, 00077B, 00700B, 00700B, 00700B,
        77000B, 77000B, 77000B, 77777B, 77777B, 77777B, 00000B]],  --"Z"
        [
        16, 16, [
        07770B, 07770B, 07770B, 07000B, 07000B, 07000B, 07000B, 07000B, 07000B,
        07000B, 07000B, 07000B, 07770B, 07770B, 07770B, 00000B]],  --"["
        [
        16, 16, [
        07770B, 07770B, 07770B, 00070B, 00070B, 00070B, 00070B, 00070B, 00070B,
        00070B, 00070B, 00070B, 07770B, 07770B, 07770B, 00000B]],  --"]"
        [
        16, 16, [
        00700B, 00700B, 00700B, 00700B, 00700B, 00700B, 00700B, 00700B, 00700B,
        00700B, 00700B, 00700B, 00700B, 00700B, 00700B, 00000B]],  --"|"
        [
        16, 16, [
        00000B, 00000B, 00000B, 77707B, 77707B, 77707B, 00700B, 00700B, 00700B,
        70777B, 70777B, 70777B, 00000B, 00000B, 00000B, 00000B]],  --"~"
        [
        16, 16, [
        77777B, 77777B, 77777B, 77777B, 77777B, 77777B, 77777B, 77777B, 77777B,
        77777B, 77777B, 77777B, 77777B, 77777B, 77777B, 00000B]]  -- Jocker
        ];
      END; -- InitializeRasters

    InitializeVectors: PROCEDURE = BEGIN
      fontPointerTable: LONG POINTER TO FontPointerTable =
        transferInternal.fontloads[0].vectors.pointer;
      fontVectorTable: LONG POINTER TO FontVectorTable;
      halfSizeFontBitMap: CARDINAL = SIZE[FontBitMap]/2;
      mappingA: STRING =
        " !""#$%&'()*+,-./0123456789:;<=>?@abcdefghijklmnopqrstuvwxyz[]|~"L;
      mappingB: STRING =
        " !""#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]|~"L;
      lastDisplacement: CARDINAL = halfSizeFontBitMap*LAST[Character];

      fontPointerTable[FIRST[BandBLT.Font]] ← fontVectorTable ←
        LOOPHOLE[fontPointerTable + Space.wordsPerPage];
      FOR character: CHARACTER IN CHARACTER DO
        fontVectorTable[character] ← lastDisplacement;  -- Fall back for unimplemented CHARACTERs.
        ENDLOOP;
      FOR i: CARDINAL IN [FIRST[CARDINAL]..mappingA.length) DO
        fontVectorTable[mappingA[i]] ← halfSizeFontBitMap*i; ENDLOOP;
      FOR i: CARDINAL IN [FIRST[CARDINAL]..mappingB.length) DO
        fontVectorTable[mappingB[i]] ← halfSizeFontBitMap*i; ENDLOOP;
      END; -- InitializeVectors

    MapScratch: PROCEDURE [count: Environment.PageCount]
     RETURNS [interval: Space.Interval] = INLINE BEGIN
      RETURN[
      Space.Map[
        window: [file: File.nullFile, base: NULL, count: count],
        class: data, life: dead]]
      END; -- MapScratch

    Character: TYPE = [FIRST[CARDINAL]..CARDINAL[64]);
    FontBitMap: TYPE = MACHINE DEPENDENT RECORD [
      height, width: CARDINAL, bitMap: ARRAY [0..16) OF WORD];
    FontBitMapMemory: TYPE = ARRAY Character OF FontBitMap;
    FontPointerTable: TYPE = ARRAY BandBLT.Font OF LONG POINTER TO
      FontVectorTable;
    FontVectorTable: TYPE = ARRAY CHARACTER OF CARDINAL;
    transferInternal ← Heap.systemZone.NEW[
      BandBLTImage.Transfer ← [
      fontloads: Heap.systemZone.NEW[
      BandBLTImage.FontloadSequence[fontloadSequenceLength]],
      bandlists: Heap.systemZone.NEW[
      BandBLTImage.BandlistSequence[bandlistSequenceLength]]]];
    transferInternal.fontloads[0] ← [
      leftovers: [MapScratch[count: fontloadLeftoverSpaceCount],
		  MapScratch[count: fontloadLeftoverSpaceCount]],
      vectors: MapScratch[count: fontloadVectorSpaceCount],
      inkwells: MapScratch[count: fontloadInkwellSpaceCount],
      rasters: MapScratch[count: fontloadRasterSpaceCount]];
    transferInternal.bandlists[0] ← [
      font: 0,
      bandlist: MapScratch[count: bandlistSpaceCount],
      maxBandEntries: 1];  -- basically meaningless
    transferInternal.fontloads.length ← transferInternal.bandlists.length ← 1;
    InitializeVectors;
    InitializeRasters;
    END; -- Initialize

  -- MAINLINE CODE:

  Initialize;
  END.

LOG
When/Who/What.
30-Mar-82/Claude Pany/Created.
15-Sep-83 17:06:52/Strickberger/name DecomposeExtrasImpl ← RavenLogFontImpl.  Update for Klamath.
20-Nov-84 23:01:05/Strickberger/Change name to RasterLogFontImpl.  Add copyright.
19-Jul-85  1:22:31/Strickberger/BandBltImage ← BandBLTImage for Euclid.  FixArrows.