[comp.sys.ibm.pc] Turn on/off cursor?

spolsky-joel@CS.Yale.EDU (Joel Spolsky) (12/01/88)

How do you turn off the cursor and turn it on again? I need a method
that works well for all video types and I would like to be able to
restore the cursor to its original shape when the program exits.

Assembler, C, whatever...

Thanks very much,

+----------------+----------------------------------------------------------+
|  Joel Spolsky  | bitnet: spolsky@yalecs.bitnet     uucp: ...!yale!spolsky |
|                | internet: spolsky@cs.yale.edu     voicenet: 203-436-1483 |
+----------------+----------------------------------------------------------+
                                                     #include <disclaimer.h>

schanck@schooner.cis.ohio-state.edu (Christopher Schanck) (12/02/88)

In article <44479@yale-celray.yale.UUCP> spolsky-joel@CS.Yale.EDU (Joel Spolsky) writes:
>How do you turn off the cursor and turn it on again? I need a method
>that works well for all video types and I would like to be able to
>restore the cursor to its original shape when the program exits.

At a job I worked this summer, we had this same problem. Bios routine for 
setting cursor height won't work across CGA/EGA etc. We ended up simply
calling the cursor position BIOS routine and putting the cursor off the
screen. Of course, this only works if you screen output is in bursts,
since you must do it for every screen write. BUt if you use direct memory
writes ... :-)!!!




-=-
"My brain is NOT a deadlock-free environment!!!!"
--- Christopher Schanck, mammal at large.
schanck@flounder.cis.ohio-state.edu

poage@sunny.UUCP (Tom Poage) (12/02/88)

In article <44479@yale-celray.yale.UUCP> spolsky-joel@CS.Yale.EDU (Joel Spolsky) writes:
>How do you turn off the cursor and turn it on again?

Try INT 10H with
	AH = 01H ;set the number of scan lines to zero with CX for off.
	AH = 03H ;read cursor size in scan lines (CX) and location.
Tom.
-- 
Tom Poage, UCDMC Clinical Engineering, Sacto., CA
ucdavis.ucdavis.edu!sunny!{poage,root,postmaster,news}
ucbvax!ucdavis!sunny!{poage,root,postmaster,news}

wbnsnsr@nmtsun.nmt.edu (William Norris) (12/02/88)

In article <44479@yale-celray.yale.UUCP> spolsky-joel@CS.Yale.EDU (Joel Spolsky) writes:
>How do you turn off the cursor and turn it on again? I need a method
>that works well for all video types and I would like to be able to
>restore the cursor to its original shape when the program exits.

In (Microsoft) C, try:

	_displaycursor( _GCURSOROFF | _GCURSORON )


-- 
wbnsnsr@nmtsun.nmt.edu                             |    /// Seulement
William B. Norris IV                               |\\ ///  l'Amiga peut 
POB #2185 C/S                                      | \\//   vous l'offrir.
Socorro, NM  87801                                 |=-=-=-=-=-=-=-=-=-=-=-=-=

earl@trsvax.UUCP (12/02/88)

/* ---------- "Turn on/off cursor?" ---------- */
How do you turn off the cursor and turn it on again? I need a method
that works well for all video types and I would like to be able to
restore the cursor to its original shape when the program exits.

Assembler, C, whatever...

Thanks very much,

+----------------+----------------------------------------------------------+
|  Joel Spolsky  | bitnet: spolsky@yalecs.bitnet     uucp: ...!yale!spolsky |
|                | internet: spolsky@cs.yale.edu     voicenet: 203-436-1483 |
+----------------+----------------------------------------------------------+

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

     According to my handy BIOS reference manual you might try the Video
Display BIOS Function call 10 hex (16 dec).

Set the cursor type and attribute

	AH = 1
	CH = "bit values"
		bits 5-6:
		bit 6:	bit 5:
		  0	  0   =  non-blink   ====>  Likely what you
		  0       1   =  invisible   ====>   want here.
		  1       0   =  blink (slow)
		  1       1   =  blink (fast)
                bits 4-0 = the start line for the cursor within a character
				cell
	CL = "bit values"
		bits 4-0 = the end line for the cursor within a character
				cell

***********************************************************************


<This information is provided by an individual and is not nor should be
 construed  as  being  provided  by  Radio  Shack or Tandy Corp.  Radio
 Shack/Tandy Corp has no obligation to support the information provided
 in  any way. > 
						
						Earl W. Bollinger
						@ <trsvax!earl>


"You were in the Clone Wars!", said Luke excitedly.
"Yes", replied Obi Wan, "I was a DOS programmer. But that was before the dark
 times, before OS2."

schanck@schooner.cis.ohio-state.edu (Christopher Schanck) (12/03/88)

In article <350@sunny.UUCP> poage@sunny.UUCP (Tom Poage) writes:
>In article <44479@yale-celray.yale.UUCP> spolsky-joel@CS.Yale.EDU (Joel Spolsky) writes:
>>How do you turn off the cursor and turn it on again?
>
>Try INT 10H with
>	AH = 01H ;set the number of scan lines to zero with CX for off.
>	AH = 03H ;read cursor size in scan lines (CX) and location.
There is a problem with this method; EGA and CGA cards handle cursor height
start and end scan lines differently. You would have to write a seperate
version for CGA and EGA, and probably one for VGA and monochrome, though
I am not sure. Writing seperate versions means you need to know which the
system is running, which is a pain. A couple years ago PC magazine did an
article on this (it was around when EGA carss first came out). 
>Tom.
Chris



-=-
"My brain is NOT a deadlock-free environment!!!!"
--- Christopher Schanck, mammal at large.
schanck@flounder.cis.ohio-state.edu

dlm1377@uxf.cso.uiuc.edu (12/05/88)

In my experience, Using the afore-mentioned method of setting the 
cursor scan lines works, but with the following twist: use the current
settings and "or" the fifth bit of the top's setting.  This has the effect
of hiding the cursor on all machines I've tested (CGA, EGA, & VGA)  To 
bring the cursor back, you then clear this bit.

Hope it works for you.


D.L. Meyer               Graduate Student in Ag Economics
                         University of Ilinois, Urbana-Champaign

leonard@bucket.UUCP (Leonard Erickson) (12/06/88)

In article <28843@tut.cis.ohio-state.edu> (Christopher Schanck) writes:
<In article <44479@yale-celray.yale.UUCP> (Joel Spolsky) writes:
<>How do you turn off the cursor and turn it on again? I need a method
<>that works well for all video types and I would like to be able to
<>restore the cursor to its original shape when the program exits.
<
<At a job I worked this summer, we had this same problem. Bios routine for 
<setting cursor height won't work across CGA/EGA etc. We ended up simply
<calling the cursor position BIOS routine and putting the cursor off the
<screen. Of course, this only works if you screen output is in bursts,
<since you must do it for every screen write. BUt if you use direct memory
<writes ... :-)!!!

No, no, NO!
Any blind user running into such a package will curse you! Their screen
readers use cursor position as the prime indication of where on the screen
they should be reading from.

Just set the bit that tells indicates the system is in graphics mode. This
works well on everything except MDA and Hercules cards. From them you need
to make a minor change.
 
For most cards:
AH := 3;
BH := 1;
interrupt $10
CH := CH or $20
AH := 1;
interrupt $10
 
To restore the cursor replace the CH := CH or $20 with CH := CH and $DF.
 
For MDA and Hercules cards, the initial call frequently returns erroneous
values for CH and CL. So I just *assume* that they have their normal
values of CH := 12 and CL := 13 if the system is running MDA or HGC...
(it's not that hard to test!)
 
I've got a quite functional routine in Turbo Pascal if you want to 
"steal" it and convert it to your language of choice...

-- 
Leonard Erickson		...!tektronix!reed!percival!bucket!leonard
CIS: [70465,203]
"I used to be a hacker. Now I'm a 'microcomputer specialist'.
You know... I'd rather be a hacker."