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 / BEEHIVE / UTILITYS / PUDD.ARC / PUDD-03.PAS < prev    next >
Pascal/Delphi Source File  |  1991-08-11  |  6KB  |  221 lines

  1. {Pudd-03 contains the procedures used to write directly to the
  2.  screen                                                       }
  3.  
  4.  
  5. procedure DrawRow(y,PtrList:integer); {...........Draw row y from datalist }
  6. var  BitList     :string[8];          { PtrList is addr of top of datalist }
  7.      PixByte     :byte;
  8.      i,j,k       :integer;
  9.      Xpoz        :integer;
  10.      Ptr         :integer;
  11.      Xleft       :integer;
  12.      color       :char;
  13.      PrevColor   :char;
  14.      value       :HexString;
  15.  
  16. begin
  17.     PrevColor := '0';
  18.     writemode(1);
  19.     linecolor(1);
  20.     setline(1);
  21.     Ptr := PtrList;
  22.     PixByte := mem[Ptr];
  23.     ReadByte(PixByte,BitList);
  24.     FlipList(BitList);
  25.     if copy(BitList,1,1) = '1' then  {....find beginning color }
  26.       begin
  27.        Xleft := 0;
  28.        color := '1';
  29.       end
  30.     else
  31.       color := '0';
  32.     Xpoz := 0;
  33.     for i := 1 to 80 do  {.....80 bytes of 8 bits yields 640 pixels }
  34.      begin
  35.        if ((color = '0') and (PixByte = $00)) or
  36.         ((color = '1') and (PixByte = $FF)) then
  37.            begin
  38.              Xpoz := Xpoz + 8;
  39.           end
  40.        else
  41.          begin
  42.            ReadByte(PixByte,BitList);
  43.            FlipList(BitList);
  44.            for j := 1 to 8 do
  45.             begin
  46.              if copy(BitList,j,1) <> color then
  47.               begin
  48.                  if color = '1' then  {....an end of a line }
  49.                   begin
  50.                    MoveTo(Xleft,y);
  51.                    DrawTo(Xpoz-1,y);
  52.                    color := '0';
  53.                   end
  54.                  else               {....beginning new line }
  55.                   begin
  56.                    Xleft := Xpoz;
  57.                    Color := '1'
  58.                   end
  59.               end;
  60.              Xpoz := Xpoz + 1;
  61.             end;  {..........................out of bit searching loop}
  62.          end;
  63.        Ptr := Ptr + 1;
  64.        PixByte := mem[Ptr];
  65.        if (i = 80) and (color = '1') then {...at far left and done }
  66.         begin
  67.          MoveTo(Xleft,y);
  68.          DrawTo(639,y);
  69.         end;
  70.      end;
  71. end;
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79. {***************************************************************************}
  80. {*   Save will save the screen to a disk file.  The default file type      *}
  81. {*   is .SCR.  These are 20k files, make sure there's room                 *}
  82. {***************************************************************************}
  83. procedure Save;
  84. var  LineNum  :integer;
  85.      i,j      :integer;
  86.      block    :integer;
  87.      trans    :integer;
  88.      bytelist :scanline;
  89. begin
  90.  gotoXY(1,1);
  91.  ClrSomeScr(1,10);
  92.  NewFileName(drive,name,ftype,2,9);
  93.  if name = '' then   {....no name selected }
  94.   write(^G)
  95.  else
  96.    begin
  97.     initgraph;
  98.     LineNum := 0;
  99.     assign(DiskFile,drive + ':' + name + '.' + ftype);
  100.     rewrite(DiskFile);
  101.     for block := 1 to 30 do        {...........30 disk writes of 640 bytes }
  102.      begin
  103.       j := 0;
  104.       for trans := 1 to 8 do       {..................8 rows in each block }
  105.        begin
  106.         GetLine(LineNum,ByteList);
  107.         LineNum := LineNum + 1;
  108.         for i := 1 to 80 do        {..................80 bytes in each row }
  109.          begin
  110.           TransBuff[i+j] := ByteList[i];
  111.          end;
  112.         j := j + 80;
  113.        end;
  114.       BlockWrite(DiskFile,TransBuff,5);
  115.      end;
  116.     Alphamode;
  117.     close(DiskFile);
  118.    end;
  119. end;
  120.  
  121.  
  122. {***************************************************************************}
  123. {*   Load will load the screen with a disk file saved earlier.  The        *}
  124. {*   default file type is .SCR.                                            *}
  125. {***************************************************************************}
  126. procedure Load;
  127. var  LineNum  :integer;
  128.      i,j      :integer;
  129.      block    :integer;
  130.      trans    :integer;
  131.      Next80Byte :integer;
  132. begin
  133.  gotoXY(1,1);
  134.  ClrSomeScr(1,10);
  135.  OldFileName(drive,name,ftype,2,9);
  136.  if name = '' then   {....no name selected }
  137.   write(^G)
  138.  else
  139.    begin
  140.     gotoXY(10,20);
  141.     initgraph;
  142.     LineNum := 0;
  143.     assign(DiskFile,drive + ':' + name + '.' + ftype);
  144.     reset(DiskFile);
  145.     for block := 1 to 30 do        {...........30 disk writes of 640 bytes }
  146.      begin
  147.       Next80Byte := addr(transBuff);
  148.       BlockRead(DiskFile,Transbuff,5);
  149.       j := 0;
  150.       for trans := 1 to 8 do       {..................8 rows in each block }
  151.        begin
  152.         for i := 1 to 80 do        {..................80 bytes in each row }
  153.          begin
  154.           ByteList[i] := TransBuff[i+j];
  155.          end;
  156.        DrawRow(LineNum,Next80Byte);
  157.         Next80Byte := Next80Byte + 80;
  158.         LineNum := LineNum + 1;
  159.         j := j + 80;
  160.        end;
  161.      end;
  162.      alphamode;
  163.      close(DiskFile);
  164.    end;
  165. end;
  166.  
  167.  
  168. procedure ChangeDrive(x,y:integer);
  169. var   ThisDrive  :char;
  170.       NextDrive  :char;
  171. begin
  172.  gotoXY(x,y);
  173.  clreol;
  174.  write('Current drive is ');
  175.  ThisDrive := CurrDrive;
  176.  write(ThisDrive);
  177.  write('  Change drive to ');
  178.  read(kbd,NextDrive);
  179.  write(NextDrive);
  180.  gotoXY(x,y);
  181.  clreol;
  182.  NewDrive(NextDrive);
  183.  gotoXY(x,y);
  184.  clreol;
  185. end;
  186.  
  187. {***************************************************************************}
  188. {*   Files is the main procedure for the file subsection.  It is from      *}
  189. {*   here that all file procedures are selected.                           *}
  190. {***************************************************************************}
  191. procedure Files;
  192. var response  :char;
  193. begin
  194.  ClrScr;
  195.  repeat
  196.   gotoXY(10,5);
  197.   writeln('FILE SUB-MENU.......');
  198.   writeln('             1) Load screen from a disk file -new screen');
  199.   writeln('             2) Load screen from a disk file -overlay on current screen');
  200.   writeln('             3) Save current screen to a disk file');
  201.   writeln('             4) Show directory of *.scr files');
  202.   writeln('             5) Change logged drive');
  203.   read(kbd,response);
  204.   case response of
  205.    '1':begin
  206.         initgraph;
  207.         ClearGraph;
  208.         alphamode;
  209.         Load;
  210.        end;
  211.    '2':Load;
  212.    '3':Save;
  213.    '5':ChangeDrive(10,22);
  214.  
  215.   end;  {....case }
  216.  until not(response in ['1','2','3','4','5']);
  217.  HeadLine;
  218. end;
  219.  
  220.  
  221.