home *** CD-ROM | disk | FTP | other *** search
- PROGRAM sprites ;
- { this is an example of using two screens, one off screen to save stuff }
- { draws a box on a medium rez screen then copies it to an off screen buffer
- in a new location. Then it copies it back to the physical screen }
-
- { by Ron Rautenberg 72777,2277 May 1986
- 15 San Juan Dr
- Salinas, Ca 93901
- 408-757-6481 }
-
- CONST
- {$I GEMCONST.PAS}
- box_x = 100; box_y = 50; { dimensions of our box }
- box_wid = 64; box_ht = 20;
-
- new_x = 200; new_y = 100; { where we're going to move it to }
-
- TYPE
- {$I gemtype.pas}
-
- { this is for our off screen buffer }
- scrn_memory = array[1..16000] of integer;
-
- { MFDB for raster copies - must be an array, not a record }
- { apparantly records aren't allocated sequentially in Pers. P }
- mfdb_fields = (addr1,addr2,wid_pix,ht_pix,wid_wds,flag,num_planes,r1,r2,r3);
- mfdb = array[mfdb_fields] of integer;
-
- VAR
- screen,backup : MFDB; { one physical, one off-screen }
- screen_buffer : scrn_memory;
-
- msg : Message_Buffer; { stuff }
- i,key,event : integer;
-
- { these procedures must be in second module so that we can
- convert an address to integers }
- PROCEDURE init_form(var form : MFDB; var addr : scrn_memory); EXTERNAL;
- PROCEDURE copy_rect(var s,d : MFDB;
- from_x,from_y,to_x,to_y,wid,ht : integer); EXTERNAL;
-
- {$I gemsubs} { GEM subroutines }
-
- { *************************************************************************** }
- { main program }
-
- BEGIN
- IF Init_Gem >= 0 THEN
- BEGIN
- clear_screen;
- { put some background lines on screen }
- Draw_mode(replace_mode);
- Line_Color(Green);
- Line_Style(Solid);
- for i := 1 to 39 do begin
- Line(i*16,0,i*16,200);
- Line(0,i*5,640,i*5);
- end;
- { put a figure on top of background }
- Paint_Color(Red);
- Paint_Style(Solid);
- Paint_Rect(box_x,box_y,box_wid,box_ht);
-
- { initialize screen form }
- screen[addr1] := 0; { the physical screen }
- screen[addr2] := 0;
-
- { initialize backup form }
- init_form(backup,screen_buffer);
-
- { now wait for key press }
- event := Get_Event(E_Keyboard,0,0,0,0,false,0,0,0,0,
- false,0,0,0,0,msg,key,key,key,key,key,key);
-
- { and copy stuff to backup screen in new location }
- copy_rect(screen,backup,box_x,box_y,new_x,new_y,box_wid,box_ht);
-
- { and wait for another key press }
- event := Get_Event(E_Keyboard,0,0,0,0,false,0,0,0,0,
- false,0,0,0,0,msg,key,key,key,key,key,key);
-
- { and copy back to screen }
- copy_rect(backup,screen,new_x,new_y,new_x,new_y,box_wid,box_ht);
-
- { and wait for another key press }
- event := Get_Event(E_Keyboard,0,0,0,0,false,0,0,0,0,
- false,0,0,0,0,msg,key,key,key,key,key,key);
- Exit_Gem ;
- END ;
- END. { Thats all folks }
- əəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəə