ex2.pp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. program example2;
  2. uses video,keyboard;
  3. {$ifndef cpu86}
  4. {$error This example only works on intel 80x86 machines}
  5. {$endif}
  6. Var
  7. P,PP,D : Integer;
  8. K: TKeyEvent;
  9. Procedure PutSquare (P : INteger; C : Char);
  10. begin
  11. VideoBuf^[P]:=Ord(C)+($07 shl 8);
  12. VideoBuf^[P+ScreenWidth]:=Ord(c)+($07 shl 8);
  13. VideoBuf^[P+1]:=Ord(c)+($07 shl 8);
  14. VideoBuf^[P+ScreenWidth+1]:=Ord(c)+($07 shl 8);
  15. end;
  16. begin
  17. InitVideo;
  18. InitKeyBoard;
  19. P:=0;
  20. PP:=-1;
  21. Repeat
  22. If PP<>-1 then
  23. PutSquare(PP,' ');
  24. PutSquare(P,'#');
  25. SetCursorPos(P Mod ScreenWidth,P div ScreenWidth);
  26. UpdateScreen(False);
  27. PP:=P;
  28. Repeat
  29. D:=0;
  30. K:=TranslateKeyEvent(GetKeyEvent);
  31. Case GetKeyEventCode(K) of
  32. kbdLeft : If (P Mod ScreenWidth)<>0 then
  33. D:=-1;
  34. kbdUp : If P>=ScreenWidth then
  35. D:=-ScreenWidth;
  36. kbdRight : If ((P+2) Mod ScreenWidth)<>0 then
  37. D:=1;
  38. kbdDown : if (P<(VideoBufSize div 2)-(ScreenWidth*2)) then
  39. D:=ScreenWidth;
  40. end;
  41. Until (D<>0) or (GetKeyEventChar(K)='q');
  42. P:=P+D;
  43. until GetKeyEventChar(K)='q';
  44. DoneKeyBoard;
  45. DoneVideo;
  46. end.