home *** CD-ROM | disk | FTP | other *** search
/ Hráč 1997 February / Hrac_09_1997-02_cd.bin / UTILS / PROGRAM / 1SVGA.ZIP / HARD.PAS < prev    next >
Pascal/Delphi Source File  |  1994-05-29  |  3KB  |  80 lines

  1. { Hardware Panning & Split Screen / VGA Text Mode 720x400 }
  2.  
  3. uses Txt;
  4.  
  5. { ─────────────── Split2Static ─────────────── }
  6. procedure Split2Static;
  7. var A:byte;
  8. begin
  9.   A:=Port[$3DA];                  { Attribute mode control }
  10.   Port[$3C0]:=$10 or $20;
  11.   Port[$3C0]:=Port[$3C1] or $20;
  12. end;
  13. { ─────────────── SplitScreen ─────────────── }
  14. procedure SplitScr(N:integer);         { 1023..0 }
  15. var A:byte;
  16. begin             { Screen-up is Start addr high/low, -down is $B800 }
  17.   Port[$3D4]:=$18; Port[$3D5]:=Lo(N);  { Bit 0-7, Line compare }
  18.   Port[$3D4]:=$07; A:=Port[$3D5];      { Bit 8, Overflow }
  19.   if N<$100 then A:=A and $EF else A:=A or $10;
  20.   Port[$3D5]:=A;
  21.   Port[$3D4]:=$09; A:=Port[$3D5];      { Bit 9, Maximum scan line }
  22.   if N<$200 then A:=A and $BF else A:=A or $40;
  23.   Port[$3D5]:=A;
  24. end;
  25. { ─────────────── SetSize ─────────────── }
  26. procedure SetSize(X,Y:integer);
  27. begin
  28.   Port[$3D4]:=$13; Port[$3D5]:=X shr 1;
  29.   MemW[0:$44A]:=X;
  30.   MemW[0:$484]:=Y-1;
  31.   MemW[0:$44C]:=X*Y;
  32. end;
  33. { ─────────────── SetTextDisplay ─────────────── }
  34. procedure SetTextDisp(X,Y:integer);
  35. var A:byte;
  36. begin
  37.   repeat until Port[$3DA] and 8<>8;
  38.   repeat until Port[$3DA] and 8=8;
  39.   Port[$3D4]:=$0C; Port[$3D5]:=Hi(Y shr 4*160+X div 9);  { Start XY addr }
  40.   Port[$3D4]:=$0D; Port[$3D5]:=Lo(Y shr 4*160+X div 9);
  41.   repeat until Port[$3DA] and 1<>1;
  42.   repeat until Port[$3DA] and 1=1;
  43.   Port[$3D4]:=$08; Port[$3D5]:=Port[$3D5] and $E0 or (Y and 15);
  44.   A:=Port[$3DA];                                         { Horizental PEL }
  45.   Port[$3C0]:=$13 or $20; Port[$3C0]:=(X+8) mod 9;
  46. end;
  47. { ─────────────── Scroll ─────────────── }
  48. procedure Scroll;
  49. var K,K2,X,Y,N:integer;
  50. begin
  51.   VideoMode(3); TextWidth:=320;
  52.   SetSize(160,50);
  53.   TextBar(1,1,160,50,$1F,' '); TextBox(1,1,160,50,$1F,2);
  54.   for K:=0 to 87 do PrintText(35*(K and 3)+10,2*(K shr 2)+4,$19+K mod 7,
  55.     'Hardware Panning...Smooth......');
  56.   PrintBig(47,10,8,16,$5F,'▒','Hardware',GetFontAddr(6)^);
  57.   PrintBig(47,25,8,16,$5F,'▒','Panning',GetFontAddr(6)^);
  58.   X:=0; Y:=0; K:=0; K2:=-1; N:=6;
  59.   SplitScr(299); Split2Static;
  60.   repeat
  61.     SetTextDisp(X,Y);
  62.     if KeyPressed=1 then begin K:=Key; if K=K2 then K:=Key; K2:=K; end;
  63.     case K of
  64.       $4B00:Dec(X,N);  $4D00:Inc(X,N);      { Left,Right }
  65.       $4800:Dec(Y,N);  $5000:Inc(Y,N);      { Up,Down }
  66.       $4700:begin Dec(X,N); Dec(Y,N); end;  { Home }
  67.       $4F00:begin Dec(X,N); Inc(Y,N); end;  { End }
  68.       $4900:begin Inc(X,N); Dec(Y,N); end;  { PgUp }
  69.       $5100:begin Inc(X,N); Inc(Y,N); end;  { PgDn }
  70.     end;
  71.     if X<0 then X:=0; if X>720 then X:=720;
  72.     if Y<0 then Y:=0; if Y>500 then Y:=500;
  73.   until (K=$011B) or (K=$1C0D);             { Esc,Enter }
  74.   SetTextDisp(0,0); VideoMode(3);
  75. end;
  76.  
  77. begin
  78.   Scroll;
  79. end.
  80.