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;
-
- {--------------------------------------------------------------------------}
- PROCEDURE NormCursor;
- { This procedure calls SetCursor to show the 'normal' cursor }
- BEGIN
- SetCursor(7,7);
- 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.
-
-