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
_/ _/_/_/ _/ _/ _/_/_/ <mailto:tpa...@usa.net>
_/ _/ _/ _/ _/
http://www.netwalk.com/~tpavlic/
_/ _/_/_/_/ _/_/_/ _/ _/
Ted Pavlic schrieb:
> 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
Ted:
I created BASM - the (Free) BASIC to 80286 Assembly Language Compiler. I
invite you to visit my page and download the powerful freebies I have made
available to the programming public -- the professional and hobbiest alike.
Visit it at http://www.flatland.com/~zardoz/index.html
Using my program, you could do something like this in BASIC :
locate 10,5,0 'position the cursor at Y,X 10,5, & turn the cursor off
print "Goodbye Cursor" 'display this message --- look ma, no cursor!
junk = GetKey 'wait for a keypress
locate 20,10,1 'position the cursor at Y,X 20,10, & reveal the cursor
print "Hello Cursor" 'display another message -- the cursor is blinking
junk = Getkey ' wait for a keypress
My program,BASM, generates the assembly language SOURCE CODE equivalent.
The following code is a part of the standard library that BASM outputs. You
will need to save the cursor location and then call this code with either
AX=0 to hide the cursor or AX=1 to turn the cursor back on. An example
follows. Hope this is of some use to you ...
Mov AX,0 ; hide the cursor
Call ShowHideCursor
Mov AX,1 ; reveal the cursor
Call ShowHideCursor
ShowHideCursor Proc Near
Cmp AX,0
Je Sh1
Mov CL,13
Mov CH,12
Mov AH,01
Int 10h
Jmp Sh2
Sh1:
Xor CL,CL
Mov CH,1
Mov AH,1
Int 10h
Sh2:
Ret
ShowHideCursor Endp
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
In article <6k7j8s$9tk$1...@winter.news.erols.com>,
Ted Pavlic <tpa...@usa.net> wrote:
>
> 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
> _/ _/_/_/ _/ _/ _/_/_/ <mailto:tpa...@usa.net>
> _/ _/ _/ _/ _/
> http://www.netwalk.com/~tpavlic/
> _/ _/_/_/_/ _/_/_/ _/ _/
>
>
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
Ted Pavlic heeft geschreven in bericht
<6k7j8s$9tk$1...@winter.news.erols.com>...
>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.
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
Osmo Ronkanen heeft geschreven in bericht
<6ka3ra$pqe$2...@winter.news.erols.com>...
>In article <6k9p1h$3f5$3...@winter.news.erols.com>,
>Olaf van der Spek <Sp...@EuroNet.NL> wrote:
>>
>>Ted Pavlic heeft geschreven in bericht
>><6k7j8s$9tk$1...@winter.news.erols.com>...
>>>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.
Because BIOS updates the variables that store the cursor shape. Not
keeping them in sync can cause nasty problems for example with TSRs.
Osmo
Osmo Ronkanen wrote in message <6kcs48$s00$2...@winter.news.erols.com>...
>>Nothing, but why always use the BIOS?
>
>Because BIOS updates the variables that store the cursor shape. Not
>keeping them in sync can cause nasty 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
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;
> 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 |
setech@_ix.netcom.com | "_" as needed for true addresses. |
earnests@_homenet.lm.com | UIN:1136443 EFnet:pale_blue |
sinykal@_cyberspace.org | URL: http://www.netcom.com/~setech |
Myles F. wrote in message <6kh8ta$1o1$1...@winter.news.erols.com>...
>
>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