home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / pctchnqs / 1990 / number2 / vidpoint.pas < prev    next >
Pascal/Delphi Source File  |  1989-08-25  |  2KB  |  93 lines

  1. Unit VidPoint;
  2.  
  3.  
  4. INTERFACE
  5.  
  6. USES DOS;
  7.  
  8.  
  9. { Returns a pointer to the current hardware cursor position: }
  10.  
  11. FUNCTION CursorPointer : Pointer;
  12.  
  13.  
  14. { Returns a pointer to screen buffer address corresponding to X,Y: }
  15.  
  16. FUNCTION XYPointer(X,Y : Integer) : Pointer;
  17.  
  18.  
  19. { Writes count attribute bytes at hardware cursor position:}
  20.  
  21. PROCEDURE WriteAttribute(Attribute : Byte; Count : Integer);
  22.  
  23.  
  24.  
  25. IMPLEMENTATION
  26.  
  27.  
  28. { Returns a pointer to the current hardware cursor position: }
  29.  
  30.  
  31. FUNCTION CursorPointer : Pointer;
  32.  
  33. VAR
  34.   Regs   : Registers;
  35.   Origin : Word;
  36.  
  37. BEGIN
  38.   WITH Regs DO
  39.     BEGIN
  40.       Intr($11,Regs);  { Call Equipment Configuration Information }
  41.       IF AX AND $0030 = $0030 THEN Origin := $B000 ELSE
  42.         Origin := $B800;
  43.       { Obtain the current cursor position from BIOS: }
  44.       AH := $03; BH := 0;
  45.       Intr($10,Regs);
  46.       { Cursor row is now in DH; Column in DL; calculate offset of }
  47.       {   cursor into video refresh buffer & make a pointer: }
  48.       CursorPointer := Ptr(Origin,(DH * 160) + (DL * 2));
  49.     END;
  50. END;
  51.  
  52.  
  53. { Returns a pointer to screen buffer address corresponding to X,Y: }
  54.  
  55. FUNCTION XYPointer(X,Y : Integer) : Pointer;
  56.  
  57. VAR
  58.   Regs   : Registers;
  59.   Origin : Word;
  60.  
  61. BEGIN
  62.   WITH Regs DO
  63.     BEGIN
  64.       Intr($11,Regs);  { Call Equipment Configuration Information }
  65.       IF AX AND $0030 = $0030 THEN Origin := $B000 ELSE
  66.         Origin := $B800;
  67.       Dec(X); Dec(Y);  { Adjust X & Y to 0-origin }
  68.       XYPointer := Ptr(Origin,(Y * 160) + (X * 2));
  69.     END;
  70. END;
  71.  
  72.  
  73. { Writes count attribute bytes at hardware cursor position:}
  74.  
  75. PROCEDURE WriteAttribute(Attribute : Byte; Count : Integer);
  76.  
  77. TYPE
  78.   VidArray = ARRAY[0..4096] OF Byte;
  79.   VidArrayPtr = ^VidArray;
  80.  
  81. VAR
  82.   I : Integer;
  83.  
  84. BEGIN
  85.   FOR I := 1 TO Count*2 DO
  86.     IF Odd(I) THEN VidArrayPtr(CursorPointer)^[I] := Attribute;
  87. END;
  88.  
  89.  
  90. { No initialization section }
  91.  
  92. END.
  93.