home *** CD-ROM | disk | FTP | other *** search
/ PC Underground / UNDERGROUND.ISO / graphic / starx.pas < prev    next >
Pascal/Delphi Source File  |  1995-07-28  |  2KB  |  55 lines

  1. {$G+}
  2. Uses ModeXLib,Crt;
  3. Var Stars:Array[0..500] of Record
  4.                               x,y,Plane:Integer;
  5.                             End;
  6.   st_no:Word;
  7.   vscreen:Pointer;
  8.   vpage:Word;
  9.   palette:Array[0..768] of Byte;
  10.  
  11. Procedure PutPixel(x,y,col:word);assembler;
  12. {sets pixel (x/y) to color col (Mode X)}
  13. asm
  14.   mov ax,0a000h                 {load segment}
  15.   mov es,ax
  16.  
  17.   mov cx,x                      {define Write Plane}
  18.   and cx,3                      {as x mov 4}
  19.   mov ax,1
  20.   shl ax,cl                     {set appropriate bit}
  21.   mov ah,al
  22.   mov dx,03c4h                  {Timing Sequencer}
  23.   mov al,2                      {Register 2 - Write Plane Mask}
  24.   out dx,ax
  25.  
  26.   mov ax,80                     {Offset = Y*80 + X div 4}
  27.   mul y
  28.   mov di,ax
  29.   mov ax,x
  30.   shr ax,2
  31.   add di,ax                     {load offset}
  32.   mov al,byte ptr col           {load color}
  33.   mov es:[di],al                {and set pixel}
  34. End;
  35.  
  36. Begin
  37.   Randomize;                    {initialize random numbers}
  38.   Init_ModeX;
  39.   Repeat                        {executed once per display}
  40.     For St_no:=0 to 500 do Begin{calculate new position for each start}
  41.       With Stars[st_no] do Begin
  42.         PutPixel(x,y,0);        {clear old pixel}
  43.         Dec(x,Plane shr 5 + 1); {continue moving}
  44.         if x <= 0 Then Begin    {left ?}
  45.           x:=319;               {then reinitialize}
  46.           y:=Random(200);
  47.           Plane:=Random(256);
  48.         End;
  49.         PutPixel(x,y,Plane shr 4 + 16);  {set new pixel}
  50.       End;
  51.     End;
  52.   Until KeyPressed;             {run until key pressed}
  53.   TextMode(3);
  54. End.
  55.