home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / library / dos / grafik / dc / dc.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1992-10-21  |  4.9 KB  |  163 lines

  1. {
  2.   Copyright 1992 by Digital Crime.
  3.  
  4.   All rights reserved.
  5.  
  6.   Permission to use, copy, modify, and distribute this software and its
  7.   documentation for any purpose and without fee is hereby granted,
  8.   provided that the above copyright notice appear in all copies and that
  9.   both that copyright notice and this permission notice appear in
  10.   supporting documentation, and that the name of the Digital Crime
  11.   not be used in advertising or publicity pertaining to distribution
  12.   of the software without specific, written  prior permission.
  13.  
  14.   DIGITAL CRIME DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
  15.   SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  16.   AND FITNESS, IN NO EVENT SHALL DIGITAL CRIME BE LIABLE FOR ANY SPECIAL,
  17.   INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
  18.   FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
  19.   NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
  20.   WITH THE USE OR PERFORMANCE OF THIS  SOFTWARE.
  21.  
  22.   s924683@minyos.xx.rmit.OZ.AU   Chandi.
  23.   s924698@minyos.xx.rmit.OZ.AU   Ed.
  24.  
  25. }
  26. {$R-}
  27.  
  28. program Digital_Crime;
  29.  
  30. { Simple demo of using bitmaps made using SVGAMAP }
  31. { and some pallette scrolling                     }
  32.  
  33. uses SVGA, Crt;
  34.  
  35. const MaxWidth = 120;
  36.       MaxHeight = 120;
  37.  
  38. type ImageType = array[ 0..MaxWidth, 0..MaxHeight ] of byte;
  39.  
  40. var D, C, T : ImageType;
  41.     i, j, Col, Top, Top2  : integer;
  42.     Hue : RGB;
  43.     TempCol : PaletteRegister;
  44.  
  45. procedure LoadImage( ImageName: string; var Image: ImageType );
  46.  
  47.   var fil : File of ImageType;
  48.  
  49.   begin
  50.     assign( fil, ImageName );
  51.     reset( fil );
  52.     read( fil, Image );
  53.     close( fil );
  54.   end;
  55.  
  56. procedure PutImage( Image : ImageType; x, y : integer );
  57.  
  58.   var i, y1, y2, x1, x2 : integer;
  59.       Segment, Color : byte;
  60.  
  61.   procedure PutPix( Color : byte; xx, yy : integer );
  62.  
  63.     begin
  64.         asm
  65.           mov ax, Bytes_per_Line
  66.           mov bx, yy
  67.           mul bx
  68.           add ax, xx
  69.           mov di, ax
  70.           mov ax, 0a000h
  71.           mov es, ax
  72.           mov al, Color
  73.           mov es:[di], al
  74.         end;
  75.     end;
  76.  
  77.   begin
  78.     x1 := x; x2 := x + 119;
  79.     y1 := y; y2 := y + 119;
  80.     repeat
  81.       if (y1 = 102) OR (y1 = 204) OR (y1 = 307) OR (y1 = 409) then
  82.         begin
  83.           repeat
  84.             if (y1 = 102) AND (x1 < 256) then Segment := 0
  85.              else if ((y1 = 102) AND (x1 > 255)) OR
  86.                      ((y1 = 204) AND (x1 < 512)) then Segment := 1
  87.              else if ((y1 = 204) AND (x1 > 511)) OR
  88.                      ((y1 = 307) AND (x1 < 128)) then  Segment := 2
  89.              else if ((y1 = 307) AND (x1 > 127)) OR
  90.                      ((y1 = 409) AND (x1 < 384)) then Segment := 3
  91.                else Segment := 4;
  92.             LoadWriteBank( Segment );
  93.             if Image[y1-y,x1-x] <> 0 then
  94.               PutPix( Image[ y1-y, x1-x ], x1, y1 );
  95.             x1 := x1 + 1;
  96.           until  x1 > x2
  97.         end
  98.       else
  99.         begin
  100.           if y1 < 102 then Segment := 0
  101.             else if y1 < 204 then Segment := 1
  102.               else if y1 < 307 then Segment := 2
  103.                 else if y1 < 409 then Segment := 3
  104.                   else Segment := 4;
  105.           LoadWriteBank( Segment );
  106.           repeat
  107.             if Image[y1-y,x1-x] <> 0 then
  108.               PutPix( Image[ y1-y, x1-x ], x1, y1 );
  109.             x1 := x1 + 1;
  110.           until x1 > x2;
  111.         end;
  112.       x1 := x;
  113.       y1 := y1 + 1;
  114.     until y1 > y2;
  115.   end;
  116.  
  117. begin
  118.   SetMode( SVGAMED );
  119.   LoadPalette( 'DC.PAL' );
  120.   LoadImage( 'D.Img', D );
  121.   LoadImage( 'C.Img', C );
  122.   for j := 0 to 639 do
  123.     begin
  124.       Col := round( j * 0.19844 );
  125.       Line( 320, 240, j, 0, Col );
  126.       Line( 320, 240, j, 479, Col );
  127.     end;
  128.   for j := 0 to 479 do
  129.     begin
  130.       Col := round( j * 0.2645833 );
  131.       Line( 320, 240, 0, j, Col );
  132.       Line( 320, 240, 639, j, Col );
  133.     end;
  134.   TempCol := Color;                    { Color is a public pallette array }
  135.   for i := 0 to 63 do                  { that keeps track of the colors   }
  136.     begin                              { stored in each pallette          }
  137.       for j := 0 to 255 do
  138.         begin
  139.           if 0 < Color[j].Red then Color[j].Red := Color[j].Red - 1;
  140.           if 0 < Color[j].Grn then Color[j].Grn := Color[j].Grn - 1;
  141.           if 0 < Color[j].Blu then Color[j].Blu := Color[j].Blu - 1;
  142.         end;
  143.      SetPalette( Color );
  144.     end;
  145.   PutImage( D, 180, 180 );
  146.   PutImage( C, 340, 180 );
  147.   for i := 0 to 63 do
  148.     begin
  149.       for j := 0 to 255 do
  150.         begin
  151.           if TempCol[j].Red > Color[j].Red then
  152.             Color[j].Red := Color[j].Red + 1;
  153.           if TempCol[j].Grn > Color[j].Grn then
  154.             Color[j].Grn := Color[j].Grn + 1;
  155.           if TempCol[j].Blu > Color[j].Blu then
  156.             Color[j].Blu := Color[j].Blu + 1;
  157.         end;
  158.      SetPalette( Color );
  159.     end;
  160.   repeat  until keypressed;
  161.   ExitGraphics;
  162. end.
  163.