home *** CD-ROM | disk | FTP | other *** search
/ Share Gallery 1 / share_gal_1.zip / share_gal_1 / GR / GR034.ZIP / MB.TP < prev    next >
Text File  |  1988-09-17  |  2KB  |  77 lines

  1. (*
  2.         Routines for Interfacing Turbo Pascal* programs with Magic Brush.
  3.         Copyright 1988 by Nassib Nassar, All rights reserved
  4.         * Turbo Pascal is a registered trademark of Borland International, Inc.
  5.  
  6.         These routines may be used in Turbo Pascal, version 3 or 4.
  7.  
  8.         Example of Usage:
  9.  
  10.                 To read a Magic Brush file from disk:
  11.                 ------------------------------------------------------------
  12.                   {$I MB.TP }
  13.                   begin { YOUR PROGRAM }
  14.                     { Switch to medium-resolution graphics mode here }
  15.                     if read_mb_pic('FILENAME.MB') <> 0 then
  16.                             writeln('Error reading file');
  17.                   end.
  18.                 ------------------------------------------------------------
  19.  
  20.                 To write a Magic Brush file to disk:
  21.                 ------------------------------------------------------------
  22.                   {$I MB.TP }
  23.                   begin { YOUR PROGRAM }
  24.                     { Switch to medium-resolution graphics mode here }
  25.                     { Draw picture here }
  26.                     if write_mb_pic('FILENAME.MB') <> 0 then
  27.                             writeln('Error writing file');
  28.                   end.
  29.                 ------------------------------------------------------------
  30. *)
  31.  
  32. { ROUTINES FOR READING AND WRITING PICTURE FILES IN MAGIC BRUSH FORMAT }
  33.  
  34. type  mb_fn = string[40];
  35.  
  36. function read_mb_pic(fn: mb_fn): integer;
  37. var
  38.   mb_file: file;
  39.   io: integer;
  40.   display: array[0..16383] of byte absolute $0B800:$00;
  41. begin
  42.   if (pos('.',fn) = 0) then fn := fn + '.MB';
  43.   assign(mb_file,fn);
  44.   {$I-} reset(mb_file); {$I+}
  45.   io := ioresult;
  46.   if (io = 0) then begin
  47.     {$I-} blockread(mb_file,display,128); {$I+}
  48.     io := ioresult;
  49.     if (io = 0) then begin
  50.       {$I-} close(mb_file); {$I+}
  51.       io := ioresult;
  52.     end;
  53.   end;
  54.   read_mb_pic := io;
  55. end;
  56.  
  57. function write_mb_pic(fn: mb_fn): integer;
  58. var
  59.   mb_file: file;
  60.   io: integer;
  61.   display: array[0..16383] of byte absolute $0B800:$00;
  62. begin
  63.   if (pos('.',fn) = 0) then fn := fn + '.MB';
  64.   assign(mb_file,fn);
  65.   {$I-} rewrite(mb_file); {$I+}
  66.   io := ioresult;
  67.   if (io = 0) then begin
  68.     {$I-} blockwrite(mb_file,display,128); {$I+}
  69.     io := ioresult;
  70.     if (io = 0) then begin
  71.       {$I-} close(mb_file); {$I+}
  72.       io := ioresult;
  73.     end;
  74.   end;
  75.   write_mb_pic := io;
  76. end;
  77.