home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / MBUG / MBUG099.ARC / HIRES2.I < prev    next >
Text File  |  1979-12-31  |  6KB  |  210 lines

  1. {Collection of routines for implementing HIRES2 Graphics in Turbo Pascal
  2.  by Simon Carter Copyright 3/7/1988
  3.  
  4.  HIRES2 procedures : Hires2      - Sets up screen ready for HIRES2
  5.                      Text        - Masks text onto graphics
  6.                      Dot         - Sets, inverts or resets dot
  7.                      Point       - Tests condition of point
  8.                      Plot        - Plots line with Dot
  9.                      Circle      - Draws circles
  10.                      Arc         - Draws arcs
  11.                      PlotBox     - Plots boxes
  12.                      Fill        - Fills shapes
  13.                      ScreenDump  - Hires2 screendump
  14.                      Normal      - Sets up 80x24, de-allocates screen}
  15.  
  16. {$I Inverse.I}
  17. {$U-,C-,I-,V-}
  18.  
  19.  
  20. type
  21.   Operation = (ResDot,SetDot,InvDot);
  22.   Script = String[255];
  23.   FileSpec = String[80];
  24.  
  25. var
  26.   PCGRAM : Byte absolute $F800;
  27.  
  28.  
  29. Procedure HIRES2;
  30. {This routine : 1. Sets up the screen in 64x16 mode
  31.                 2. Sets up bank allocation in the attribute RAM
  32.                 3. Clears the PCGs in all banks
  33.                 4. Fills the screen with PCGs ready to use}
  34.  
  35. var
  36.   Bank, Character : Byte;
  37.  
  38.  
  39. Procedure Set64_16;
  40.  
  41. Begin
  42.   Inline ($21/*+36/    {          LD      HL,DATA }
  43.           $C5/         {          PUSH    BC      }
  44.           $E5/         {          PUSH    HL      }
  45.           6/$10/       {          LD      B,16    }
  46.           $78/         { LOOP     LD      A,B     }
  47.           $3D/         {          DEC     A       }
  48.           $D3/$0C/     {          OUT     (0C),A  }
  49.           $7E/         {          LD      A,(HL)  }
  50.           $D3/$0D/     {          OUT     (0D),A  }
  51.           $2B/         {          DEC     HL      }
  52.           $10/$F6/     {          DJNZ    LOOP    }
  53.           6/$4B/       {          LD      B,75    }
  54.           $E1/         {          POP     HL      }
  55.           $C1/         {          POP     BC      }
  56.           $C9/         {          RET             }
  57.  
  58.           $6B/         {          DB      $6B     }
  59.           $40/         {          DB      $40     }
  60.           $51/         {          DB      $51     }
  61.           $37/         {          DB      $37     }
  62.           $12/         {          DB      $12     }
  63.           9/           {          DB      9       }
  64.           $10/         {          DB      16      }
  65.           $11/         {          DB      17      }
  66.           $48/         {          DB      $48     }
  67.           $0F/         {          DB      15      }
  68.           $2F/         {          DB      $2F     }
  69.           $0F/         {          DB      15      }
  70.           0/           {          DB      0       }
  71.           0/           {          DB      0       }
  72.           0/           {          DB      0       }
  73.           0);          { DATA     DB      0       }
  74. End;
  75.  
  76.  
  77.  
  78. Begin
  79.   ClrScr;
  80.   Set64_16;
  81.  
  82.   Port[28] := 144;
  83.   for Bank := 0 to 7 do
  84.     for Character := 0 to 127 do
  85.       Mem[$F000 + (Bank * 128) + Character] := Bank;
  86.  
  87.   for Bank := 7 downto 0 do
  88.     begin
  89.     Port[28] := 128 + Bank;
  90.     FillChar(PCGRAM,2048,0);
  91.     end;
  92.  
  93.   for Bank := 0 to 7 do
  94.     for Character := 0 to 127 do
  95.       Mem[$F000 + (Bank * 128) + Character] := Character + 128;
  96. End;
  97.  
  98.  
  99. {$I Dot.I}
  100. {$I Text.I}
  101. {$I Point.I}
  102. {$I GrDsk.I}
  103. {$I Plot.I}
  104. {$I Circle.I}
  105. {$I Arc.I}
  106. {$I Box.I}
  107. {$I Fill.I}
  108. {$I HiDump.I}
  109.  
  110.  
  111. Procedure Normal;
  112. {This procedure 1. Puts screen back in 80x24 mode
  113.                 2. Resets bank allocation in attribute RAM
  114.                 3. Inverts all bank's PCGs}
  115.  
  116. var
  117.   Count : Byte;
  118.   Screen : Integer;
  119.  
  120. Procedure Set80_24;
  121.  
  122. Begin
  123.   Inline ($21/*+36/    {          LD      HL,DATA }
  124.           $C5/         {          PUSH    BC      }
  125.           $E5/         {          PUSH    HL      }
  126.           6/$10/       {          LD      B,16    }
  127.           $78/         { LOOP     LD      A,B     }
  128.           $3D/         {          DEC     A       }
  129.           $D3/$0C/     {          OUT     (0C),A  }
  130.           $7E/         {          LD      A,(HL)  }
  131.           $D3/$0D/     {          OUT     (0D),A  }
  132.           $2B/         {          DEC     HL      }
  133.           $10/$F6/     {          DJNZ    LOOP    }
  134.           6/$4B/       {          LD      B,75    }
  135.           $E1/         {          POP     HL      }
  136.           $C1/         {          POP     BC      }
  137.           $C9/         {          RET             }
  138.  
  139.           $6B/         {          DB      $6B     }
  140.           $50/         {          DB      $50     }
  141.           $58/         {          DB      $58     }
  142.           $37/         {          DB      $37     }
  143.           $1B/         {          DB      $1B     }
  144.           5/           {          DB      5       }
  145.           $18/         {          DB      $18     }
  146.           $19/         {          DB      $19     }
  147.           $48/         {          DB      $48     }
  148.           10/          {          DB      10      }
  149.           $2A/         {          DB      $2A     }
  150.           10/          {          DB      10      }
  151.           $20/         {          DB      $20     }
  152.           0/           {          DB      0       }
  153.           0/           {          DB      0       }
  154.           0);          { DATA     DB      0       }
  155. End;
  156.  
  157.  
  158. Begin
  159.   ClrScr;
  160.   Set80_24;
  161.  
  162.   Port[28] := 144;
  163.     for Screen := 0 to 1920 do
  164.       Mem[$F000 + Screen] := 0;
  165.  
  166.   for Count := 135 downto 128 do
  167.     begin
  168.     Port[28] := Count;
  169.     Inverse;
  170.     end;
  171. End;
  172.  
  173.  
  174.  
  175.  
  176. {Main Program}
  177. Begin
  178.   Hires2;
  179.   PlotBox(0,0,511,255,SetDot);
  180.   Circle(255,128,200,160,SetDot);
  181.   Arc(383,128,40,64,90,270,SetDot);
  182.   Arc(128,128,40,64,270,90,SetDot);
  183.   Plot(383,192,128,192,SetDot);
  184.   Plot(128,64,383,64,SetDot);
  185.  
  186.   Circle(255,168,50,10,SetDot);
  187.   Arc(255,88,50,10,180,360,SetDot);
  188.   Plot(205,168,205,88,SetDot);
  189.   Plot(305,88,305,168,SetDot);
  190.  
  191.   Text(17,3,'Simon Carter wrote ALL of this!!',SetDot);
  192.  
  193.   Plot(250,123,260,123,SetDot);
  194.   Plot(260,123,255,133,SetDot);
  195.   Plot(255,133,250,123,SetDot);
  196.   Fill(255,128);
  197.  
  198.   repeat until KeyPressed;
  199.  
  200.   GRSave('M:TEST.GRA');
  201.   Delay(1000);
  202.   Hires2;
  203.   GRLoad('M:TEST.GRA');
  204.  
  205.   repeat until KeyPressed;
  206.  
  207.   ScreenDump;
  208.   Normal;
  209. End.
  210.