home *** CD-ROM | disk | FTP | other *** search
- PROGRAM Cursors;
-
- { This program is a sample on how to control the cursor using TURBO PASCAL
- on an IBM or IBM compatable machine. It calls the BIOS VIDEO_IO module
- through the standard interupt $10. This will not work with any machine
- not supporting the standard interupts into the BIOS roms }
-
- VAR
- X : STRING[79];
- StartScan : INTEGER;
- EndScan : INTEGER;
-
- {--------------------------------------------------------------------------}
- PROCEDURE SetCursor (StartLine,EndLine : INTEGER);
- { This procedure does the actual cursor setting thru the TURBO
- INTR procedure. }
- TYPE
- Register = RECORD
- AX,BX,CX,DX,BP,SI,DS,ES,Flags : INTEGER;
- END;
- VAR
- IntrRegs : Register;
- CXRegArray : ARRAY [1..2] OF BYTE;
- CXReg : INTEGER ABSOLUTE CXRegArray;
- BEGIN
- CXRegArray[2] := LO(StartLine);
- CXRegArray[1] := LO(EndLine);
- WITH IntrRegs DO
- BEGIN
- AX := $0100; {ah = 1 means set cursor type}
- BX := $0; {BX = page number, zero for us}
- CX := CXReg; {ch bits 4 to 0 = start line for cursor}
- {cl bits 4 to 0 = end line for cursor}
- INTR($10,IntrRegs); {set cursor}
- END;
-
- END;
-
- {--------------------------------------------------------------------------}
- PROCEDURE NoCursor;
- { This procedure calls SetCursor to turn the cursor off }
- BEGIN
- SetCursor(32,0); {Setting bit 5 turns off cursor}
- END;
-
- {--------------------------------------------------------------------------}
- PROCEDURE BoxCursor;
- { This procedure calls SetCursor to show a block (box) cursor }
- BEGIN
- SetCursor(0,13); {0-7 for mono, 0-13 for color}
- {but 0-13 works ok for mono too}
- END;
- {--------------------------------------------------------------------------}
- FUNCTION CrtMode : INTEGER;
- { This procedure call BIOS to determine current CRT mode }
- TYPE
- Register = RECORD
- AX,BX,CX,DX,BP,SI,DS,ES,Flags : INTEGER;
- END;
- VAR
- IntrRegs : Register;
- BEGIN
- WITH IntrRegs DO
- BEGIN
- AX := $0f00; {VIDEO_IO function 15}
- INTR($10,IntrRegs);
- CrtMode := LO(AX);
- END;
- END;
-
- {--------------------------------------------------------------------------}
- PROCEDURE NormCursor;
- { This procedure calls SetCursor to show the 'normal' cursor }
- BEGIN
- IF CrtMode = 7 THEN
- SetCursor(11,12) {mono}
- ELSE
- SetCursor(6,7); {color}
- END;
-
- {--------------------------------------------------------------------------}
- BEGIN {Main Program}
-
- CLRSCR; {Clear Screen}
-
- GOTOXY(1,5); {Row 5, Column 1}
- WRITELN('Notice that there is now NO cursor! (Press Enter to continue)');
- NoCursor;
- READLN(X);
-
- GOTOXY(1,7);
- WRITELN('Now notice the BOX cursor! (Press Enter to continue)');
- BoxCursor;
- READLN(X);
-
- GOTOXY(1,9);
- WRITELN('Now back to the normal cursor! (Press Enter to continue)');
- NormCursor;
- READLN(X);
-
- StartScan := 1; EndScan := 1;
- WHILE (StartScan > 0) OR (EndScan > 0) DO
- BEGIN
- GOTOXY(1,12);
- WRITELN('Now it is time to design your own (enter zero for both to end)');
- WRITE('Enter the topmost scan line for the cursor (0-13):');
- READLN(StartScan);
- WRITE('Enter the bottom scan line for the cursor (0-13):');
- READLN(EndScan);
- IF (StartScan > 0) OR (EndScan > 0) THEN
- BEGIN
- SetCursor(StartScan,EndScan);
- GOTOXY(1,15);
- WRITELN('Well, here is your cursor:');
- READLN(X);
- END;
- END;
- NormCursor;
- END.