home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / TURBOPAS / CURSOR.ZIP / CURSOR.PAS
Encoding:
Pascal/Delphi Source File  |  1986-11-07  |  4.0 KB  |  120 lines

  1. PROGRAM Cursors;
  2.  
  3. {   This program is a sample on how to control the cursor using TURBO PASCAL
  4.     on an IBM or IBM compatable machine.  It calls the BIOS VIDEO_IO module
  5.     through the standard interupt $10.  This will not work with any machine
  6.     not supporting the standard interupts into the BIOS roms               }
  7.  
  8. VAR
  9.     X         :   STRING[79];
  10.     StartScan :   INTEGER;
  11.     EndScan   :   INTEGER;
  12.  
  13. {--------------------------------------------------------------------------}
  14. PROCEDURE SetCursor (StartLine,EndLine : INTEGER);
  15.       { This procedure does the actual cursor setting thru the TURBO
  16.         INTR procedure.                                              }
  17.  TYPE
  18.       Register = RECORD
  19.                  AX,BX,CX,DX,BP,SI,DS,ES,Flags : INTEGER;
  20.                  END;
  21.  VAR
  22.       IntrRegs    :  Register;
  23.       CXRegArray  :  ARRAY [1..2] OF BYTE;
  24.       CXReg       :  INTEGER ABSOLUTE CXRegArray;
  25.  BEGIN
  26.       CXRegArray[2] := LO(StartLine);
  27.       CXRegArray[1] := LO(EndLine);
  28.       WITH IntrRegs DO
  29.            BEGIN
  30.            AX := $0100;             {ah = 1 means set cursor type}
  31.            BX := $0;                {BX = page number, zero for us}
  32.            CX := CXReg;             {ch bits 4 to 0 = start line for cursor}
  33.                                     {cl bits 4 to 0 = end line for cursor}
  34.            INTR($10,IntrRegs);      {set cursor}
  35.       END;
  36.  
  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. FUNCTION CrtMode : INTEGER;
  55.        { This procedure call BIOS to determine current CRT mode }
  56. TYPE
  57.       Register = RECORD
  58.                  AX,BX,CX,DX,BP,SI,DS,ES,Flags : INTEGER;
  59.                  END;
  60. VAR
  61.       IntrRegs    :  Register;
  62. BEGIN
  63.      WITH IntrRegs DO
  64.        BEGIN
  65.        AX := $0f00;                   {VIDEO_IO function 15}
  66.        INTR($10,IntrRegs);
  67.        CrtMode := LO(AX);
  68.        END;
  69. END;
  70.  
  71. {--------------------------------------------------------------------------}
  72. PROCEDURE NormCursor;
  73.       { This procedure calls SetCursor to show the 'normal' cursor }
  74. BEGIN
  75.       IF CrtMode = 7 THEN
  76.          SetCursor(11,12)              {mono}
  77.       ELSE
  78.          SetCursor(6,7);               {color}
  79. END;
  80.  
  81. {--------------------------------------------------------------------------}
  82. BEGIN     {Main Program}
  83.  
  84.      CLRSCR;            {Clear Screen}
  85.  
  86.      GOTOXY(1,5);       {Row 5, Column 1}
  87.      WRITELN('Notice that there is now NO cursor! (Press Enter to continue)');
  88.      NoCursor;
  89.      READLN(X);
  90.  
  91.      GOTOXY(1,7);
  92.      WRITELN('Now notice the BOX cursor! (Press Enter to continue)');
  93.      BoxCursor;
  94.      READLN(X);
  95.  
  96.      GOTOXY(1,9);
  97.      WRITELN('Now back to the normal cursor! (Press Enter to continue)');
  98.      NormCursor;
  99.      READLN(X);
  100.  
  101.      StartScan := 1;   EndScan := 1;
  102.      WHILE (StartScan > 0) OR (EndScan > 0) DO
  103.         BEGIN
  104.         GOTOXY(1,12);
  105.         WRITELN('Now it is time to design your own (enter zero for both to end)');
  106.         WRITE('Enter the topmost scan line for the cursor (0-13):');
  107.         READLN(StartScan);
  108.         WRITE('Enter the bottom scan line for the cursor (0-13):');
  109.         READLN(EndScan);
  110.         IF (StartScan > 0) OR (EndScan > 0) THEN
  111.            BEGIN
  112.            SetCursor(StartScan,EndScan);
  113.            GOTOXY(1,15);
  114.            WRITELN('Well, here is your cursor:');
  115.            READLN(X);
  116.            END;
  117.         END;
  118.         NormCursor;
  119. END.
  120.