[comp.sys.ibm.pc] How to turn off cursor?

tad@killer.UUCP (Tad Marko) (11/12/87)

I need a little help...how in the world, using BIOS interrupts, do I turn
off the cursor?

Thanks,
Tad

..!ihnp4!killer!tad

creps@silver.bacs.indiana.edu (11/16/87)

   People have been writing about changing the cursor, and I wrote
a program a few weeks ago (as a test) to do just that. I'll post
it below, since it's very small.

-	-	-	-	-	-	-	-	-
Steve Creps on the VAX 8650 running Ultrix 2.0-1 at Indiana University.
	creps@silver.bacs.indiana.edu
"F-14 Tomcat! There IS no substitute."


(this is the Pascal calling program. the actual routine is below in assembly.
 input data are the top and bottom pixel rows of the cursor.)

program curs(input, output);
var
	l, h: byte;
 
procedure scurs_size(h, l: byte); extern;
 
begin
	write(output, 'l, h ? ');
	readln(input, l, h);
	scurs_size(h, l);
	writeln(output, 'done.')
end.



(and here is the assembly code)
 cursor		segment	'CODE'
		assume	cs:cursor
 
;	set cursor size: scurs_size(bottom, top: byte)
;	bottom = bottom line (0-7)
;	top = top line (0-7)
		public	scurs_size
scurs_size	proc	far
		push	bp
		mov	bp,sp
		mov	ch,[bp+6]
		mov	cl,[bp+8]
		mov	ah,1
		int	16
		pop	bp
		ret	0
scurs_size	endp
 
cursor		ends
		end

kevino@hpccc.HP.COM (Kevin Owen) (11/18/87)

/ hpccc:comp.sys.ibm.pc / tad@killer.UUCP (Tad Marko) /  8:24 pm  Nov 11, 1987 /
I need a little help...how in the world, using BIOS interrupts, do I turn
off the cursor?

Thanks,
Tad

..!ihnp4!killer!tad
----------
In text mode there is no way of turning the cursor off but you can place the
cursor off screen (which effectively turns it off).  A code fragment that I 
have used in the past follows :

	mov	ah,2		; function 2 = position cursor
	mov	bh,0		; select page 0
	mov	dl,0		; X position
	mov	dh,25		; Y position - which is off screen
	int	10h		; invoke software interupt

Enjoy,
Kevin

..!hpccc!kevino

marty@uw-june.UUCP (Marty Sirkin) (11/18/87)

In article <5060014@hpccc.HP.COM>, kevino@hpccc.HP.COM (Kevin Owen) writes:
>> I need a little help...how in the world, using BIOS interrupts, do I turn
>> off the cursor?

> In text mode there is no way of turning the cursor off.

Actually you can.  Check out pg. 92 (and the related pages) in Norton.  You
can do it in both Monochrome and color text.

						Marty Sirkin

crs@cpsc6b.cpsc6a.att.com (Chris (The Home of the Killer Smiley) Seaman) (11/19/87)

In article <3639@uw-june.UUCP>, marty@uw-june.UUCP (Marty Sirkin) writes:
< In article <5060014@hpccc.HP.COM>, kevino@hpccc.HP.COM (Kevin Owen) writes:
< >> I need a little help...how in the world, using BIOS interrupts, do I turn
< >> off the cursor?
< 
< Actually you can.  Check out pg. 92 (and the related pages) in Norton.  You
< can do it in both Monochrome and color text.
< 
< 						Marty Sirkin

I don't know what Norton says, but it seems to me that there is an easy
way:

    1) Set register ah to 1 (The 'set cursor attributes' function)

    2) Set register cl to some value (The 'cursor end line' value)
       Note: it is assumed that you will set it to a logical value.

    3) Set register ch to a LARGER value than cl
       (The 'cursor start line' value)

    4) Call int 10h (The video interrupt).

This should effectively 'turn off' the cursor.  It might be advisable
to use the 'get cursor attributes' function (ah = 3) of int 10h before
using the above steps.  That way you can remember the previous start
and end lines of the cursor (they will be returned in ch and cl,
respectively).

Hope this is of some help.

-- 
Chris Seaman            |    o\  /o
crs@cpsc6a.att.com <or> |      ||         See "Attack of the Killer Smiley"!
..!ihnp4!cpsc6a!crs     |   \vvvvvv/     Coming Soon to a newsgroup near you!
                        |    \____/ 

marty@uw-june.UUCP (11/20/87)

In article <428@cpsc6b.cpsc6a.att.com>, crs@cpsc6b.cpsc6a.att.com (Chris (The Home of the Killer Smiley) Seaman) writes:

> ... but it seems to me that there is an easy way:
>     1) Set register ah to 1 (The 'set cursor attributes' function)
>     2) Set register cl to some value (The 'cursor end line' value)
>        Note: it is assumed that you will set it to a logical value.
>     3) Set register ch to a LARGER value than cl
>        (The 'cursor start line' value)
>     4) Call int 10h (The video interrupt).
> 
> This should effectively 'turn off' the cursor.  

   Well it doesn't (really you should have tried it before you posted it
as a "solution"!).  What this does is to give you a "split" cursor, with the
scan lines at the top and bottom lit, and the stuff between blank!!

					Marty Sirkin

mjs@ernie.Berkeley.EDU (Marc J. Sabatella) (11/20/87)

Having grappled with this problem before, I can tell you several things about
the bloody cursor:

First, setting the start line below the end line has the interesting effect of
creating a two-part cursor (top and bottom) not of turning it off.
Setting both the start and end line to a ridiculous value (only 5 bits are
used, if I remember correctly, so it has to be ridiculous mod 32) works on
some machines, but fails on others (all genuine IBM equipment).  Moving the
cursor off the screen is specifically warned against in several sources, but
seems to work in most cases (certain graphics clone cards used on some brand
name clones don't seem to like it).

An annoying bug in most BIOSes - presumably the cloners decided to clone
IBM's bugs as well - is that the BIOS record of current cursor start line and
end line is *NOT* accurate unless you happen to be in CGA text mode.  In one
application I was writing, I wished to provide a block cursor, and then restore
it to whatever it was before when the program was through, but the BIOS data
area always said the cursor was orignally on lines 6-7 when I went to save it;
even on a monchrome system in which the cursor was actually on lines 11-12
(or somewhere around there).  Looking at the BIOS startup routine listings,
the BIOS data area for the cursor is unconditionally initialized to 6,7.  Turbo
Editor Toolbox (and some TP version) users may already have noticed that the
cursor is an annoying overstrike on monochrome systems, and leaves the cursor
in that state upon exit.  Moral: if you change the cursor shape, be careful
to consider the curren video mode both when setting up the cursor, and when
restoring it (you DO restore it, don't you???).

Marc Sabatella
mjs@ernie.Berkeley.EDU

Zatar_Braxana@milehi (Zatar Braxana) (11/22/87)

        Useing BIOS interrupts to change the cursor, you set the starting 

and ending scan lines, so if tou want to turn it off just set the starting 
and ending points to 0. I hope this works for you, I've never tried 
it, but I read about it somewhere.
 
                Z.


---
 * Origin: * Excalibur * Boulder CO * 303-497-6051 (Opus 1:104/39)
SEEN-BY: 104/39 56
--  
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
via FidoNet 104/56 Mile Hi Tech  (303-973-9338)
       uucp:  ...!{hao|isis}!scicom!milehi!oscar

crs@cpsc6b.UUCP (11/23/87)

In article <3653@uw-june.UUCP>, marty@uw-june.UUCP (Marty Sirkin) writes:
< In article <428@cpsc6b.cpsc6a.att.com>, (Chris Seaman) writes:
< 
< > This should effectively 'turn off' the cursor.  
< 
<    Well it doesn't (really you should have tried it before you posted it
< as a "solution"!).  What this does is to give you a "split" cursor, with
< the scan lines at the top and bottom lit, and the stuff between blank!!
< 
< 					Marty Sirkin

Sorry this didn't work for you, but I *DID* try it, and it works on my 6300.
I have since been told that it doesn't work the same on all PC/CLONE/BIOS
combinations, but I was unaware of this.  As far as I know, it should work
on "real" IBM PC's.

-- 
Chris Seaman            |    o\  /o
crs@cpsc6a.att.com <or> |      ||         See "Attack of the Killer Smiley"!
..!ihnp4!cpsc6a!crs     |   \vvvvvv/     Coming Soon to a newsgroup near you!
                        |    \____/ 

marty@uw-june.UUCP (Marty Sirkin) (11/25/87)

In article <429@cpsc6b.cpsc6a.att.com>, crs@cpsc6b.cpsc6a.att.com (Chris (I'm Outta Here!) Seaman) writes:

> Sorry this didn't work for you, but I *DID* try it, and it works on my 6300.

I am sorry for flaming you on the previous posting, and it may well work on 
your 6300, but if you try it on any IBM PC/XT/AT/PS2 (or on Phoenix BIOS, or
other "standard" BIOS), or look it up in Norton (or one of several other
books) you will see that it *shouldn't* work.  The fact that it does on your
6300 is an exception, not the rule.

As I mentioned in my previous posting, there are several ways to do this
which should work on all 100% compatibles.

						Marty Sirkin

mjg@ecsvax.UUCP (Michael Gingell) (11/25/87)

In article <3678@uw-june.UUCP>, marty@uw-june.UUCP (Marty Sirkin) writes:
> In article <429@cpsc6b.cpsc6a.att.com>, crs@cpsc6b.cpsc6a.att.com (Chris (I'm Outta Here!) Seaman) writes:
> 
> > Sorry this didn't work for you, but I *DID* try it, and it works on my 6300.
> 
> I am sorry for flaming you on the previous posting, and it may well work on 
> your 6300, but if you try it on any IBM PC/XT/AT/PS2 (or on Phoenix BIOS, or
> other "standard" BIOS), or look it up in Norton (or one of several other
> books) you will see that it *shouldn't* work.  The fact that it does on your
> 6300 is an exception, not the rule.
> 
I agree, I wrote a routine to turn the cursor off which works on PCs, Ats
PS/2s, clones, MDA, CGA, EGA, EGA clones but apparently NOT the 6300.
Using the standard call to set the cursor size you simply define the line  line
within the character block at which the logic turns the cursor on and
the line where it it is turned off. If you define it to be turned off
at any line within the normal display box for one character then it
gets turned off every time the cursor cell is scanned. If you also define
it to be turned on at a line outside the range that is ever scanned
(e.g. 8 or higher for MDA, 12 or higher for CGA, more for EGA) then
the scan counters never reach a point where they detect coincidence
and thus the cursor is never started.

It seems to me this is primarily a function of hardware on the MDA and
CGA but certain BIOSs may mask the numbers you try and send to the
hardware. In the EGA, emulating the CGA, the hardware function is
partially emulated by the EGA BIOS and it works just fine.

Are ther any other 6300 experts out there that can shed light on why
the cursor on/off routine doesn't work. For the record, here is my
cursor routine:

; set cursor start in ch, end in cl

; to set cursor off
       mov   cx,0f0eh
       mov   ah,1
       int   10h

; to set cursor on
       mov    cx,0107h
       mov    ah,1
       int    10h

Im sorry, I dont have the exact numbers in front of me now
for the start/end for turning the cursor off. This is from memory.

Thats it,   .....  Mike Gingell       ..ecsvax!mjg

winters@jacobs.cs.orst.edu (stafford winters) (11/28/87)

I wish I could remember the exact numbers I used, but I do remember that I
read and later tested a series of initializations for the cursor.  Included
was a setting for turning it off.  The trick was in setting some combination
of bits 5 and 6 of register CH along with start scan line, and the end scan
line in register CL, and AH set to 1.  Follow this up with INT 10H and no
more cursor.  I'll try to get back with verification.
Tad WBrBrBWa

winters@jacobs.cs.orst.edu (stafford winters) (11/28/87)

I found this in a file called interrup.arc on one of the BBS's in PDX.  I
believe it was originally posted in one of the newsgroups some time back.
So, credit goes to someone else.

-----------------------------------------------------------
INT 10 - VIDEO - SET VIDEO MODE
        AH = 0
        AL =
                0 = 40x25 B&W
                1 = 40x25 COLOR
                2 = 80x25 BW
                3 = 80x25 COLOR
                4 = 320x200 GRAPHICS, 4 COLOR
                5 = 320x200 GRAPHICS, 4 GREY
                6 = 640x200 GRAPHICS, B&W
                7 = MONOCHROME
                8 = 160x200 GRAPHICS, 16 COLOR (PCjr/Tandy 1000)
                9 = 320x200 GRAPHICS, 16 COLOR (PCjr/Tandy 1000)
                A = 640x200 GRAPHICS, 4 COLOR (PCjr/Tandy 1000)
                D = 320x200 graphics, 16 color (EGA)
                E = 640x200 graphics, 16 color (EGA)
                F = 640x350 graphics, monochrome (EGA)
               10 = 640x350 graphics, 4 or 16 color (EGA)
-----------------------------------------------------------
INT 10 - VIDEO - SET CURSOR CHARACTERISTICS
        AH = 1
        CH =
                bits 5-6 = blink attribute
                        (00=normal, 01=invis., 10 = slow, 11=fast)
                bits 0-4 = start line for cursor in char. cell
        CL =
                bits 0-4 = end line for cursor in char. cell
-----------------------------------------------------------
INT 10 - VIDEO - SET CURSOR POSITION
        AH = 2
        DH,DL = ROW,COLUMN - 0,0 = UPPER LEFT
        BH = PAGE NO. - 0 = GRAPHICS
-----------------------------------------------------------
INT 10 - VIDEO - READ CURSOR POSITION
        AH = 3
        BH = PAGE NO. - 0 = GRAPHICS
        Return: DH,DL = ROW,COLUMN
                CH,CL = CURSOR MODE,CURRENT SET
-----------------------------------------------------------
INT 10 - VIDEO - READ LIGHT PEN POSITION
        AH = 4
        Return: AH = 0: light pen switch not activated
                AH = 1: light pen values in registers
                DH = row of current position
                DL = column of current position
                CH = raster line (0-199)
                BX = pixel column (0-319 or 0-639)
-----------------------------------------------------------