home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / demos / 26 / pascal / spr2.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1986-06-19  |  3.1 KB  |  99 lines

  1. {$M+}
  2. {$E+}
  3. { link this with sprite.o }
  4.  
  5. program addr_stuff;
  6.         { this is a module to go with sprite.pas - necessary in order to
  7.           convert addresses to integers }
  8.  
  9. type
  10.         { these are echos of types in sprite.pas }
  11.  
  12.    scrn_memory = array[1..16000] of integer;
  13.    mfdb_fields = (addr1,addr2,wid_pix,ht_pix,wid_wds,flag,num_planes,r1,r2,r3);
  14.    mfdb = array[mfdb_fields] of integer;
  15.  
  16. PROCEDURE init_form(var form : MFDB; addr : long_integer);
  17.         { initializes a form to point to a chunk of memory off screen }
  18.         { note that the caller passes a 32K chunk of memory as what it
  19.           thinks is a var parameter, thus passing its address }
  20. var
  21.    hi_byte,lo_byte : integer;
  22.  
  23. begin
  24.         { convert the address to integers }
  25.    lo_byte := int(addr & $0000ffff);
  26.    hi_byte := int( ShR(addr,16) & $0000ffff);
  27.         { and initialize all fields of the MFDB }
  28.    form[addr1] := hi_byte;
  29.    form[addr2] := lo_byte;
  30.         { some assumptions here }
  31.    form[wid_pix] := 640;        { medium or high rez }
  32.    form[ht_pix] := 200;         { medium rez }
  33.    form[wid_wds] := 40;
  34.    form[flag] := 0;             { device dependent }
  35.    form[num_planes] := 2;       { again, med rez }
  36. end;
  37.  
  38.  
  39. PROCEDURE copy_rect(src,dst : long_integer;
  40.                     from_x,from_y,to_x,to_y,width,height : integer);
  41.         { heres where we actually copy a rectangle from one loc. to another }
  42.         { using gem raster copy function }
  43.  
  44.     TYPE
  45.       Ctrl_Parms      = ARRAY [ 0..11 ] OF integer ;
  46.       Int_In_Parms    = ARRAY [ 0..15 ] OF integer ;
  47.       Int_Out_Parms   = ARRAY [ 0..45 ] OF integer ;
  48.       Pts_In_Parms    = ARRAY [ 0..11 ] OF integer ;
  49.       Pts_Out_Parms   = ARRAY [ 0..11 ] OF integer ;
  50.  
  51.     VAR
  52.       control : Ctrl_Parms ;
  53.       int_in  : Int_In_Parms ;
  54.       int_out : Int_Out_Parms ;
  55.       pts_in  : Pts_In_Parms ;
  56.       pts_out : Pts_Out_Parms ;
  57.  
  58.       hi_byte,lo_byte : integer;
  59.  
  60.  
  61.     PROCEDURE VDI_Call( cmd, sub_cmd : integer ; nints, npts : integer ;
  62.                 VAR ctrl : Ctrl_Parms ;
  63.                 VAR int_in : Int_In_Parms ; VAR int_out : Int_Out_Parms ;
  64.                 VAR pts_in : Pts_In_Parms ; VAR pts_out : Pts_Out_Parms ;
  65.                 translate : boolean ) ;
  66.       EXTERNAL ;
  67.  
  68.  
  69. begin
  70.         { put source MFDB address in control array }
  71.    lo_byte := int(src & $0000ffff);
  72.    hi_byte := int( ShR(src,16) & $0000ffff);
  73.    control[7] := hi_byte; control[8] := lo_byte;
  74.  
  75.        { and same for destination MFDB }
  76.    lo_byte := int(dst & $0000ffff);
  77.    hi_byte := int( ShR(dst,16) & $0000ffff);
  78.    control[9] := hi_byte; control[10] := lo_byte;
  79.  
  80.    int_in[0] := 3;      { replace mode }
  81.  
  82.         { set the points for src and dest }
  83.    pts_in[0] := from_x; pts_in[1] := from_y;
  84.    pts_in[2] := from_x + width - 1;
  85.    pts_in[3] := from_y + height - 1;
  86.  
  87.    pts_in[4] := to_x; pts_in[5] := to_y;
  88.    pts_in[6] := to_x + width - 1;
  89.    pts_in[7] := to_y + height - 1;
  90.  
  91.         { do the copy }
  92.    VDI_Call(109,0,1,8,control,int_in,int_out,pts_in,pts_out,false);
  93.  
  94. end;
  95.  
  96.         { just a module, no main program }
  97. begin
  98. end.
  99. əəəəəəəəəəəəəəəəəəəəəəəəəəəəəəə