A: The usually
advocated trick for turning the cursor off is to
equate the lower and the upper scan line of the cursor as
explained
e.g. in Stephen O'Brien (1988), Turbo Pascal, Advanced
Programmer's
Guide.
uses Dos;
var regs : registers;
begin
regs.ax := $0100; (* Service $01 *)
regs.cl := $20; (* Top scan line *)
regs.ch := $20; (* Bottom scan line *)
Intr ($10, regs); (* ROM BIOS video driver interrupt *)
end;
To turn the cursor back on this (and many other) sources suggest
setting regs.ch and regs.cl as 12 and 13 for mono screen, and 6
and
7 for others.
This is not a good solution since it is equipment dependent, and
may thus produce unexpected results. Better to store the current
scan line settings, and turn off the cursor bit. Below is the code
from ftp://garbo.uwasa.fi/pc/ts/tspa3470.zip (or whatever version
number is the latest) available by anonymous FTP from
garbo.uwasa.fi
archives. The general idea is that regs.ch bit 5 toggles the cursor
on / off state. Thus to set the cursor off, apply
regs.ch := regs.ch or $20; (* $20 = 00100000 *)
and to set it on, apply
regs.ch := regs.ch and $DF; (* $DF = 11011111 *)
(* From TSUNTE unit, which also has a CURSON procedure *)
procedure CURSOFF;
var regs : registers;
begin
FillChar (regs, SizeOf(regs), 0); (* Initialize, a precaution *)
{... find out the current cursor size (regs.ch, regs.cl) ...}
regs.ah := $03;
regs.bh := $00; (* page 1, superfluous because of FillChar *)
Intr ($10, regs); (* ROM BIOS video driver interrupt *)
{... turn off the cursor without changing its size ...}
regs.ah := $01; (* Below are bits 76543210 *)
regs.ch := regs.ch or $20; (* Turn on bit 5; $20 = 00100000 *)
Intr ($10, regs);
end; (* cursoff *)
A2: A comment from
Leonard Erickson leonard@qiclab.scn.rain.com.
Reprinted with permission. There's a *reason* those sources don't
suggest storing the current scan line settings. On IBM
Monochrome
Display Adapters (MDA), Hercules Graphics Cards, and the
various
clones of both, the "read cursor start and end scan
lines" function
*always* returns the same values. And those values are almost
never
the actual settings. Most cards return 6 & 7. Some return 12
& 13.
But they return these values even if the cursor has been set to
something else.
So you are *still* stuck with checking the hardware type if the
screen is in mode 7.
See the Interrupt list for details on this mess.
A3: Another solution
that has been suggested is putting the cursor
outside the screen. But you can't do this with the Crt's GotoXY
procedure, since it ignores off screen positions, as observed by
Luiz Marques luiz.marques%mandic@ibase.org.br. You'll need to
use
video interrupt, that is $10, function $02. Fair enough, but
somewhat complicated. Besides, how do you write on the screen if
the
cursor position is off it?
A4: This snippet of
disabling the cursor at hardware level was
posted to the late comp.lang.pascal by JAB@ib.rl.ac.uk.
procedure turn_off_cursor;
var num : word;
begin
port[$03D4]:=$0A; num:=port[$03D5];
port[$03D4]:=$0A; port[$03D5]:=num or 32;
end;
{}
procedure turn_on_cursor;
var num : word;
begin
port[$03D4]:=$0A; num:=port[$03D5];
port[$03D4]:=$0A; port[$03D5]:=num xor 32;
end;
A5: (Not to be taken
seriously). Simple, turn off your computer and
the cursor stops showing :-).