home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / MADTRB13.ZIP / CURSOR.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1985-05-19  |  3.4 KB  |  102 lines

  1.  
  2. PROGRAM CURSORS;
  3.  
  4. {   This program is a sample on how to control the cursor using TURBO PASCAL
  5.     on an IBM or IBM compatable machine.  It calls the BIOS VIDEO_IO module
  6.     through the standard interupt $10.  This will not work with any machine
  7.     not supporting the standard interupts into the BIOS roms               }
  8.  
  9. VAR
  10.     X         :   STRING[79];
  11.     StartScan :   INTEGER;
  12.     EndScan   :   INTEGER;
  13.  
  14. {--------------------------------------------------------------------------}
  15. PROCEDURE SetCursor (StartLine,EndLine : Integer);
  16.       { This procedure does the actual cursor setting thru the TURBO
  17.         INTR procedure.                                              }
  18.  TYPE
  19.       Register = record
  20.                  ax,bx,cx,dx,bp,si,ds,es,flags : integer;
  21.                  end;
  22.  VAR
  23.       IntrRegs    :  Register;
  24.       CXRegArray  :  Array [1..2] of Byte;
  25.       CXReg       :  integer absolute CXRegArray;
  26.  BEGIN
  27.       CXRegArray[2] := LO(StartLine);
  28.       CXRegArray[1] := LO(EndLine);
  29.       With IntrRegs do
  30.            BEGIN
  31.            ax := $0100;             {ah = 1 means set cursor type}
  32.            bx := $0;                {bx = page number, zero for us}
  33.            cx := CXReg;             {ch bits 4 to 0 = start line for cursor}
  34.                                     {cl bits 4 to 0 = end line for cursor}
  35.            intr($10,IntrRegs);      {set cursor}
  36.       END;
  37. END;
  38.  
  39. {--------------------------------------------------------------------------}
  40. PROCEDURE NoCursor;
  41.       { This procedure calls SetCursor to turn the cursor off }
  42. BEGIN
  43.       SetCursor(32,0);              {Setting bit 5 turns off cursor}
  44. END;
  45.  
  46. {--------------------------------------------------------------------------}
  47. PROCEDURE BoxCursor;
  48.       { This procedure calls SetCursor to show a block (box) cursor }
  49. BEGIN
  50.       SetCursor(0,13);              {0-7 for mono, 0-13 for color}
  51.                                     {but 0-13 works ok for mono too}
  52. END;
  53.  
  54. {--------------------------------------------------------------------------}
  55. PROCEDURE NormCursor;
  56.       { This procedure calls SetCursor to show the 'normal' cursor }
  57. BEGIN
  58.       SetCursor(7,7);
  59. END;
  60.  
  61. {--------------------------------------------------------------------------}
  62. BEGIN     {Main Program}
  63.  
  64.      ClrScr;            {Clear Screen}
  65.  
  66.      GoToXY(1,5);       {Row 5, Column 1}
  67.      WriteLn('Notice that there is now NO cursor! (Press Enter to continue)');
  68.      NoCursor;
  69.      ReadLn(X);
  70.  
  71.      GoToXY(1,7);
  72.      WriteLn('Now notice the BOX cursor! (Press Enter to continue)');
  73.      BoxCursor;
  74.      ReadLn(X);
  75.  
  76.      GoToXY(1,9);
  77.      WriteLn('Now back to the normal cursor! (Press Enter to continue)');
  78.      NormCursor;
  79.      ReadLn(X);
  80.  
  81.      StartScan := 1;   EndScan := 1;
  82.      While (StartScan > 0) or (EndScan > 0) do
  83.         BEGIN
  84.         GoToXY(1,12);
  85.         WriteLn('Now it is time to design your own (enter zero for both to end)');
  86.         Write('Enter the topmost scan line for the cursor (0-13):');
  87.         ReadLn(StartScan);
  88.         Write('Enter the bottom scan line for the cursor (0-13):');
  89.         ReadLn(EndScan);
  90.         If (StartScan > 0) or (EndScan > 0) then
  91.            BEGIN
  92.            SetCursor(StartScan,EndScan);
  93.            GoToXY(1,15);
  94.            WriteLn('Well, here is your cursor:');
  95.            ReadLn(X);
  96.            END;
  97.         END;
  98.         NormCursor;
  99.     End.
  100.  
  101.  
  102.