-- BitBlt.mesa  (last edited by: Karlton, July 17, 1980  4:02 PM)

DIRECTORY
  Environment: FROM "Environment" USING [BitAddress],
  Mopcodes: FROM "Mopcodes" USING [zBITBLT];

BitBlt: DEFINITIONS =
  BEGIN

  -- Types used to make up a BitBltTable

  BitAddress: TYPE = Environment.BitAddress;

  BitBltFlags: TYPE = MACHINE DEPENDENT RECORD [
    -- determines the BitBlt function
    direction: Direction ← forward,
    disjoint: BOOLEAN ← FALSE,
    disjointItems: BOOLEAN ← FALSE,
    gray: BOOLEAN ← FALSE,
    srcFunc: SrcFunc ← null,
    dstFunc: DstFunc ← null,
    reserved: [0..511] ← 0];

  Direction: TYPE = {forward, backward};

  DstFunc: TYPE = {null, and, or, xor};

  GrayParm: TYPE = MACHINE DEPENDENT RECORD [
    -- used with Src to describe gray brick
    reserved: [0..15] ← 0,
    yOffset: [0..15],
    widthMinusOne: [0..15],
    -- restricted to 0 for initial microcode implementations
    heightMinusOne: [0..15]];

  SrcDesc: TYPE = MACHINE DEPENDENT RECORD [
    SELECT OVERLAID * FROM
      gray => [gray: GrayParm],
      srcBpl => [srcBpl: INTEGER],
      ENDCASE];

  SrcFunc: TYPE = {null, complement};

  -- BitBlt and BBTable

  BBptr, BitBltTablePtr: TYPE = POINTER TO BBTable;

  BBTable, BitBltTable: TYPE = MACHINE DEPENDENT RECORD [
    dst: BitAddress,
    dstBpl: INTEGER,
    src: BitAddress,
    srcDesc: SrcDesc,
    width: CARDINAL,
    height: CARDINAL,
    flags: BitBltFlags,
    reserved: UNSPECIFIED ← 0];

  BITBLT: PROCEDURE [ptr: BBptr] = MACHINE CODE BEGIN Mopcodes.zBITBLT END;

  -- alignment issues

  BBTableAlignment: CARDINAL = 16;

  BBTableSpace: TYPE = ARRAY [1..SIZE[BBTable] + BBTableAlignment) OF UNSPECIFIED;

  AlignedBBTable: PROCEDURE [ip: POINTER TO BBTableSpace] RETURNS [b: BBptr] =
    INLINE
    BEGIN
    align: TYPE = MACHINE DEPENDENT RECORD [
      s: [0..LAST[WORD]/BBTableAlignment), z: [0..BBTableAlignment)];
    b ← LOOPHOLE[ip + BBTableAlignment - 1];
    LOOPHOLE[b, align].z ← 0;
    END;

  END.
LOG
Time: April 11, 1980  11:09 AM	By: Forrest	Action: Trimmed log to Amargosa; converted to PrincOps BitBlt.
Time: April 16, 1980  1:26 PM	By: Forrest	Action: formatting/spelling corections.  Changed BBTableSpace to [1.. from [0..
Time: April 17, 1980  12:07 AM	By: Forrest	Action: Move BitAddress to Environment
Time: July 17, 1980  4:03 PM	By: Karlton	Action: Add defaults to Flags record
Time: timeStamp	By: yourName	Action: shortDescription