Hiding the cursor 
Author Message
 Hiding the cursor

Hello!

  I was wondering if anyone could post or e-mail me the 80x86 asembler
code to hide and show the cursor. I'd like to insert this code into a
Turbo Pascal 7 (I think 7) program to create procedures to hide and show
the cursor.

  If anyone knows an easier way to do this in Turbo Pascal (without
using TViews (I think it's TViews))... Please let me know.

  Thank you so much --

--
_/_/_/_/_/  _/_/_/_/  _/_/_/       _/_/_/    
   _/      _/        _/   _/      _/    _/   Ted Pavlic

 _/      _/        _/   _/      _/          
http://www.*-*-*.com/ ~tpavlic/
_/      _/_/_/_/  _/_/_/       _/     _/



Wed, 08 Nov 2000 03:00:00 GMT  
 Hiding the cursor



:  I was wondering if anyone could post or e-mail me the 80x86 asembler
:code to hide and show the cursor. I'd like to insert this code into a
:Turbo Pascal 7 (I think 7) program to create procedures to hide and show
:the cursor.

You don't need asm

 21) How do I turn the cursor off?

 138630 May 10 1998 ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip
 tsfaqp.zip Common Turbo Pascal Questions and Timo's answers


Followups pruned.

   All the best, Timo

....................................................................

Moderating at ftp:// & http://garbo.uwasa.fi/ archives 193.166.120.5
Department of Accounting and Business Finance  ; University of Vaasa

Spam foiling in effect.  My email filter autoresponder will return a
required email password to users not yet in the privileges database.



Thu, 09 Nov 2000 03:00:00 GMT  
 Hiding the cursor

Quote:

>Hello!

>  I was wondering if anyone could post or e-mail me the 80x86 asembler
>code to hide and show the cursor. I'd like to insert this code into a
>Turbo Pascal 7 (I think 7) program to create procedures to hide and show
>the cursor.

Use Int 10h, Function 3 to get the current start and end lines for the cursor.
This will be in CH and CL respectively. Use Int 10h, Function 1, with CH set
to 20h to turn off the cursor.  Use Int 10h, Function 1 with CH and CL set to
the values obtained using Function 3 to restore the cursor.

HTH

Paul Bosselaers



Thu, 09 Nov 2000 03:00:00 GMT  
 Hiding the cursor

Ted Pavlic schrieb:

Quote:
> Hello!

>   I was wondering if anyone could post or e-mail me the 80x86 asembler
> code to hide and show the cursor. I'd like to insert this code into a
> Turbo Pascal 7 (I think 7) program to create procedures to hide and show
> the cursor.

>   If anyone knows an easier way to do this in Turbo Pascal (without
> using TViews (I think it's TViews))... Please let me know.

       3d4h index  Ah (r/W): CRTC: Cursor Start Register
       bit 0-4  First scanline of cursor within character.
      5  (VGA) Turns Cursor off if set

MOV DX,03D4h
MOV AL,0Ah
OUT DX,AL
INC DX
IN AL,DX
OR AL,20h
OUT DX,AL

turns the cursor off

and

MOV DX,03D4h
MOV AL,0Ah
OUT DX,AL
INC DX
IN AL,DX
AND AL,0DFh
OUT DX,AL

turns the cursor on

Yours,
Michael



Thu, 09 Nov 2000 03:00:00 GMT  
 Hiding the cursor



Quote:
>  I was wondering if anyone could post or e-mail me the 80x86 asembler
>code to hide and show the cursor. I'd like to insert this code into a
>Turbo Pascal 7 (I think 7) program to create procedures to hide and show
>the cursor.

http://www.merlyn.demon.co.uk/pascal.htm#Cursor  refers.

NGs trimmed to something more reasonable.

--

  Web <URL: http://www.merlyn.demon.co.uk/> - TP/BP/&c. FAQqish topics & links.
  Timo's TurboPascal <A HREF="ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip">FAQ</A>.
  <A HREF="http://www.merlyn.demon.co.uk/clpb-faq.txt">Mini-FAQ</A> of c.l.p.b.



Thu, 09 Nov 2000 03:00:00 GMT  
 Hiding the cursor

Ted Pavlic heeft geschreven in bericht

Quote:
>Hello!

>  I was wondering if anyone could post or e-mail me the 80x86 asembler
>code to hide and show the cursor. I'd like to insert this code into a
>Turbo Pascal 7 (I think 7) program to create procedures to hide and show
>the cursor.

USES CRT;
BEGIN
 WriteLn('Normal');
 ReadKey;
 ASM
  MOV  DX,$03D4
  MOV  AL,$0A
  OUT  DX,AL
  INC  DX
  IN   AL,DX
  OR   AL,$20
  OUT  DX,AL
 END;
 WriteLn('No Cursor');
 ReadKey;
 ASM
  MOV  DX,$03D4
  MOV  AL,$0A
  OUT  DX,AL
  INC  DX
  IN   AL,DX
  AND  AL,NOT $20
  OUT  DX,AL
 END;
 WriteLn('Normal');
 ReadKey;
END.


Thu, 09 Nov 2000 03:00:00 GMT  
 Hiding the cursor



Quote:

>Ted Pavlic heeft geschreven in bericht

>>Hello!

>>  I was wondering if anyone could post or e-mail me the 80x86 asembler
>>code to hide and show the cursor. I'd like to insert this code into a
>>Turbo Pascal 7 (I think 7) program to create procedures to hide and show
>>the cursor.

>USES CRT;
>BEGIN
> WriteLn('Normal');
> ReadKey;
> ASM
>  MOV  DX,$03D4
>  MOV  AL,$0A
>  OUT  DX,AL
>  INC  DX
>  IN   AL,DX
>  OR   AL,$20
>  OUT  DX,AL
> END;

This is the third solution I have seen that messes with the ports
directly. What is wrong with the BIOS?

Procedure CursorOff; Assembler;
  Asm
  Mov ah,3
  mov bx,0
  int 10h
  or ch,20h
  mov ah,1
  mov bx,0
  int 10h
  end;

Procedure CursorOn;  Assembler;
  Asm
  Mov ah,3
  mov bx,0
  int 10h
  and ch,255-20h
  mov ah,1
  mov bx,0
  int 10h
  end;

Osmo



Thu, 09 Nov 2000 03:00:00 GMT  
 Hiding the cursor

Osmo Ronkanen heeft geschreven in bericht

Quote:


>>Ted Pavlic heeft geschreven in bericht

>>>Hello!

>>>  I was wondering if anyone could post or e-mail me the 80x86 asembler
>>>code to hide and show the cursor. I'd like to insert this code into a
>>>Turbo Pascal 7 (I think 7) program to create procedures to hide and show
>>>the cursor.

>>USES CRT;
>>BEGIN
>> WriteLn('Normal');
>> ReadKey;
>> ASM
>>  MOV  DX,$03D4
>>  MOV  AL,$0A
>>  OUT  DX,AL
>>  INC  DX
>>  IN   AL,DX
>>  OR   AL,$20
>>  OUT  DX,AL
>> END;

>This is the third solution I have seen that messes with the ports
>directly. What is wrong with the BIOS?

Nothing, but why always use the BIOS?
I remember some text that said it is no official way to set bit 21.

- Show quoted text -

Quote:

>Procedure CursorOff; Assembler;
>  Asm
>  Mov ah,3
>  mov bx,0
>  int 10h
>  or ch,20h
>  mov ah,1
>  mov bx,0
>  int 10h
>  end;

>Procedure CursorOn;  Assembler;
>  Asm
>  Mov ah,3
>  mov bx,0
>  int 10h
>  and ch,255-20h
>  mov ah,1
>  mov bx,0
>  int 10h
>  end;

>Osmo



Fri, 10 Nov 2000 03:00:00 GMT  
 Hiding the cursor



Quote:

>Osmo Ronkanen heeft geschreven in bericht

>>This is the third solution I have seen that messes with the ports
>>directly. What is wrong with the BIOS?

>Nothing, but why always use the BIOS?

Because BIOS updates the variables that store the cursor shape. Not
keeping them in sync can cause {*filter*} problems for example with TSRs.

Osmo



Fri, 10 Nov 2000 03:00:00 GMT  
 Hiding the cursor

Quote:

>>Nothing, but why always use the BIOS?

>Because BIOS updates the variables that store the cursor shape. Not
>keeping them in sync can cause {*filter*} problems for example with TSRs.

>Osmo

Actually, I'd just like to ask a question which has been bugging me for ages:
there are quite a lot of these hiding/showing cursor routines out there, nearly
all with different lengths or statements; is there any one _definitive_ way to
turn the cursor off? All these different approaches have the effect of confusing
the user (or me, in any case!)

Myles Fisher



Sun, 12 Nov 2000 03:00:00 GMT  
 Hiding the cursor

place this in the procedure section of your program..TP7
to use it, cursor_off for off, and, cursor_on for on

there are other ways of achieving this, both of i know are in assembler,
this one just turns it off and on, using defaults...the other one
remembers cursor size, etc...there is a pas register method, but that is
technicly pascal as well...so, here it is......

procedure cursor_off; Assembler; (* procedure that turns the cursor off
*)
 asm
   Mov AX,0100h
   Mov CX,2000h
   Int 10h
 End;

 procedure cursor_on; Assembler; (* turns the cursor on *)
 asm
   Mov AX,0100h
   Mov CX,0607h
   Int 10h
 end;

Quote:


> >>Nothing, but why always use the BIOS?

> >Because BIOS updates the variables that store the cursor shape. Not
> >keeping them in sync can cause {*filter*} problems for example with TSRs.

> >Osmo

> Actually, I'd just like to ask a question which has been bugging me for ages:
> there are quite a lot of these hiding/showing cursor routines out there, nearly
> all with different lengths or statements; is there any one _definitive_ way to
> turn the cursor off? All these different approaches have the effect of confusing
> the user (or me, in any case!)

> Myles Fisher



Mon, 13 Nov 2000 03:00:00 GMT  
 Hiding the cursor

Quote:

> place this in the procedure section of your program..TP7
> to use it, cursor_off for off, and, cursor_on for on

> there are other ways of achieving this, both of i know are in assembler,
> this one just turns it off and on, using defaults...the other one
> remembers cursor size, etc...there is a pas register method, but that is
> technicly pascal as well...so, here it is......

The problem here is that this works, but is by no means as requested a
"definitive" way to hide or show the cursor.  This cursor_off() procedure
clobbers the cursor settings.  You could save the settings but that requires
more code and more variables.  And the cursor_on() procedure assumes the
cursor is supposed to be at a particular place.  That could end up making the
program look a little obtuse.  The robust method is to toggle bit 6 of the
cursor starting scanline on, and toggle it back off to show the cursor again.
This preserves the settings.

What I use:

procedure HideCursor; assembler;

asm
  mov   es,[Seg0040]
  mov   di,0060h
  mov   cx,word ptr es:[di]
  mov   ax,0100h
  or    ch,20h
  int   10h
end;

procedure ShowCursor; assembler;

asm
  mov   es,[Seg0040]
  mov   di,0060h
  mov   cx,word ptr es:[di]
  mov   ax,0100h
  and   ch,0dfh
  int   10h
end;

Note:  Written for TP7.  for TP6, replace "mov es,[Seg0040] with "mov
ax,$0040; mov es,ax".

--
Scott Earnest            | SPAM protection in effect. Remove  |





Mon, 13 Nov 2000 03:00:00 GMT  
 Hiding the cursor

Quote:

>Actually, I'd just like to ask a question which has been bugging me
for ages:
>there are quite a lot of these hiding/showing cursor routines out
there, nearly
>all with different lengths or statements; is there any one
_definitive_ way to
>turn the cursor off? All these different approaches have the effect
of confusing
>the user (or me, in any case!)

>Myles Fisher

Unfortunately, there doesn't seem to be, in DOS at any rate. One
reason for the different routines is that different people will go to
different lengths to write well-behaved programs when faced with a
lack of OS cooperation.

As a general rule, when there are no OS services to do something that
you really have to do, you go to the next level - which is usually
either the BIOS or a device driver. You only go direct to the hardware
when there is no higher-level service that will give you what you want
without degrading performance unacceptably. The theory is that the
hardware may change but if the device driver or BIOS service remains
compatible your program will still work. For example, if you write a
program for a serial mouse but use INT 33h instead of going direct to
the hardware, your program will still work on a machine with a PS/2
style mouse.

For video services the routines are in the BIOS but the theory begins
to look a little irrelevant here. In practise, so many programmers
went direct to the hardware over so many years that the hardware has
become quite standardised. Anyway, in the BIOS on a PC, there is
_also_ NO function to turn off the cursor. There is a service to
change the cursor shape, and one to change the cursor position. The
latter has occasionally been suggested as a way of hiding the cursor,
by moving it off the screen, but most schemes use the former: INT 10h,
fn 1.

The parameters for this which will make the cursor look "normal", and
which will make it disappear, depend on what sort of text mode you are
running. You can use int 10h fn 3 -- preceded by int 10h fn 0Fh to get
the current display page -- to get the cursor size at the start of the
program, and use that to set the cursor shape for turning the cursor
on. I'd do that, but maybe it's just paranoia. Or you can guess: the
value will usually be $0607. ISTR that on the original Monochrome
adaptor (mode 7) it would be $0C0D, but you don't meet these often.
The VGA emulates mode 7 but seems to double up the parameters: 0607
works fine there (I just tried it). Either way, to hide the cursor you
set it to an "illegal" value, so you can't read that value anywhere -
2000h seems to work.

Whichever way you choose, you then have to code it in some language.
Borland Pascal provides at least 2 ways of doing this (I'm not sure
whether I should count Inline). You can use the Registers record type,
with the Intr procedure, or you can use the inline assembler. The
former has some overhead but protects you from doing things like
corrupting the DS register (not that this is relevant to int 10h fn 1
but it is for some other interrupts). The latter will save a few bytes
in the .EXE but is only available from v6 of the compiler.

I hope this at least partly explains the multitude of different
routines.

FP



Tue, 14 Nov 2000 03:00:00 GMT  
 
 [ 14 post ] 

 Relevant Pages 

1. Hide the cursor

2. how to hide mouse cursor for labview linux

3. Hiding the cursor

4. Q: 80x50 text-mode and hiding the cursor

5. Microfocus Cobol : hiding the cursor

6. How can I hide the cursor in the canvas-widget?

7. Hiding cursor in console (HLA)

8. Hiding and moving text cursor!

9. Hiding cursor in NextenetPlayer or Cortona?

10. Hide cursor in curses module

11. Hiding the mouse cursor in TK

 

 
Powered by phpBB® Forum Software