! EDREVIEW - The EDWIN PDF reviewing routine

!%include "edwin:types.inc"

!%include "EDWIN.DD"
!%include "edwin:specs.inc"
!%include "edwin:shapes.inc"

!%const %integer TRUE = 1, FALSE = 0

%external %routine REVIEW %alias "EDWIN_REVIEW"
   %integer WORD, CODE, R, X, Y, Z, P, XL, YB, XR, YT, ACTION, WX, WY
   %switch C (0:15)

   Action = False
   %cycle
      READ (WORD)
      CODE = WORD&15
      %if CODE<=5 %start;  !Draw, Move, Point
          READ(X)
          %if WORD&16=0 %start; !Long form
              READ(Y)
          %finish%else %start
              Y=X&255; X=X>>8&255
              X=X!!(\255) %if X&128#0
              Y=Y!!(\255) %if Y&128#0
          %finish
    %finish
    ->C(CODE)

C(0): LINE ABS (X, Y)
      %continue

C(1): MOVE ABS (X, Y)
      %continue

C(2): MARKER ABS (WORD>>12&15, X, Y)
      Action = True
      %continue

C(3): LINE REL (X, Y)
      Action = True
      %continue

C(4): MOVE REL (X, Y)
      %continue

C(5): MARKER REL (WORD>>12&15, X, Y)
      Action = True
      %continue

C(6): ! Polygons
      READ (X)
      %begin
         %record (POINTFM) %array P (1:X)
         %integer I
         %for I = 1, 1, X %cycle
              READ (P(I)_X);   READ (P(I)_Y)
         %repeat
         Polygon (X, P)
      %end
      %continue

C(8): ! SET new WINDOW
      READ(XL);  READ(XR);  READ(CODE);  READ (YB);  READ (YT)
      WINDOW (XL, XR, YB, YT)
      %continue

C(9): ! Character
      Character (Word >> 4)
      Action = true
      %continue

C(11): ! Newframe
       %return %if Action = true
       %continue

C(12): ! Terminate
       %return

C(13): ! Rectangle
       READ (WX);   READ (WY);   READ (WORD);  READ (X);   READ (Y)
       RECTANGLE (WX, WY, X, Y)
       %continue

C(14): !Circle
       READ (X)
       Circle (X)
       %continue

C(15): ! New attribute setting.
C(10): %if CODE=10 %then X=WORD>>4&255 %else READ(X)
       Y = WORD >> 12 & 15
       %if Y=15 %start
           ASPECT RATIOING (X)
       %else
           SET ATTRIBUTE (Y, X)
       %finish
  %repeat

C(*): %signal 14, 5
%end

%end %of %file
