How to hide the cursor

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
AlfaOmega08
Member
Member
Posts: 226
Joined: Wed Nov 07, 2007 12:15 pm
Location: Italy

How to hide the cursor

Post by AlfaOmega08 »

How can I hide the cursor in text mode like grub does?
Osbios
Member
Member
Posts: 116
Joined: Fri Jun 10, 2005 11:00 pm

Post by Osbios »

Just move the VGA text courser outside the view:

Code: Select all

mov  cx, 0x2000
mov  ah, 1
int  0x10
This is a BIOS int, so you have to do it at boot if you use the Protected mode!
User avatar
AlfaOmega08
Member
Member
Posts: 226
Joined: Wed Nov 07, 2007 12:15 pm
Location: Italy

Post by AlfaOmega08 »

I don't want to hide cursor since the boot.

When I need to hide it, I'll hide.

Also in PMode I can put the cursor out the screen using the bran's tutorial method to update the cursor?
Osbios
Member
Member
Posts: 116
Joined: Fri Jun 10, 2005 11:00 pm

Post by Osbios »

I don't know how to change the cursor directly on the VGA card. I just hide the VGA cursor and use a blinking char to make my own cursor. I think that's more easy and faster.
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Post by jal »

Osbios wrote:I don't know how to change the cursor directly on the VGA card. I just hide the VGA cursor and use a blinking char to make my own cursor. I think that's more easy and faster.
Ignorance is no excuse. Of course it is not easier nor faster to not use the hardware cursor.


JAL
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Post by jal »

AlfaOmega08 wrote:I don't want to hide cursor since the boot.
When I need to hide it, I'll hide.
You may want to check the VGA register specifications. Readily available on the internet everywhere (Google is your friend), and on the Wiki no doubt.


JAL
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Post by Dex »

Try

Code: Select all

;-------------------------------------------------------;
;                  Pmode  cursor demo                   ;
;             Coded by Dex(Craig Bamford)               ;
;-------------------------------------------------------;
        mov   bx,0x1c1b                     ; set cursor invisable
        call  ChangeCursor

; **PUT MORE CODE HERE ***

        mov   bx,0x0b0c                     ;Set cursor visable
        call  ChangeCursor

; **PUT MORE CODE HERE ***

;====================================================;
; GetCursor.                out: bx = cursor attribs ;
;====================================================;
GetCursor:
          push  ax
          push  dx
          mov   dx,0x3D4
          mov   al,0x0E
          out   dx,al
          inc   dx
          in    al,dx
          mov   bh,al
          mov   al,0x0F
          dec   dx
          out   dx,al
          inc   dx
          in    al,dx
          mov   bl,al
          pop   dx
          pop   ax
          ret

;====================================================;
; ChangeCursor.              in: bx = cursor attribs ;
;====================================================;
ChangeCursor:
          pushad
          mov   dx,0x3D4
          mov   al,0x0A
          mov   ah,bh
          out   dx,ax
          inc   ax
          mov   ah,bl
          out   dx,ax
          popad
          ret

;====================================================;
; CursorSetXY        in: al = cursorX   ah = cursorY ;
;====================================================;
CursorSetXY:
        mov   byte[PosX],al
        mov   byte[PosY],ah
        call  GoToXY
        ret

;====================================================;
; GoToXY.                           See  CursorSetXY ;
;====================================================;
GoToXY:
        pushad
        mov   dl,byte[PosX]
        mov   dh,byte[PosY]
        mov   al,80
        mul   dh
        xor   dh,dh
        add   ax,dx
        mov   cx,ax
        mov   dx,0x03d4
        mov   al,0x0e
        out   dx,al
        inc   dx
        mov   al,ch
        out   dx,al
        mov   dx,0x3d4
        mov   al,0x0f
        out   dx,al
        inc   dx
        mov   al,cl
        out   dx,al
        popad
        ret



Cursor dw 0
PosX   db 0
PosY   db 0

Last edited by Dex on Mon Feb 25, 2008 9:36 am, edited 1 time in total.
Osbios
Member
Member
Posts: 116
Joined: Fri Jun 10, 2005 11:00 pm

Post by Osbios »

jal wrote:
Osbios wrote:I don't know how to change the cursor directly on the VGA card. I just hide the VGA cursor and use a blinking char to make my own cursor. I think that's more easy and faster.
Ignorance is no excuse. Of course it is not easier nor faster to not use the hardware cursor.


JAL
What dos this have to do with ignorance??? o_O

I just told him how I do it and that I think is more easy. What is the reason we are using a forum? To share our ideas and not just to tell every one to look at the spec!
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Post by jal »

Osbios wrote:What dos this have to do with ignorance??? o_O
I just told him how I do it and that I think is more easy.
He asks a question about a subject that you don't know about. Then you give him lousy advise based on that.
What is the reason we are using a forum? To share our ideas and not just to tell every one to look at the spec!
Sharing bad ideas is bad. One should only reply to a topic if one has a clue (e.g. Dex).


JAL
Osbios
Member
Member
Posts: 116
Joined: Fri Jun 10, 2005 11:00 pm

Post by Osbios »

jal wrote:
Osbios wrote:What dos this have to do with ignorance??? o_O
I just told him how I do it and that I think is more easy.
He asks a question about a subject that you don't know about. Then you give him lousy advise based on that.
You just told him to look at some specifications and google. Seems like you know less about the subject then me. :P
jal wrote:
What is the reason we are using a forum? To share our ideas and not just to tell every one to look at the spec!
Sharing bad ideas is bad. One should only reply to a topic if one has a clue (e.g. Dex).
Or e.g. jal??? Come one...
And the quality of my ideas can AlfaOmega08 judge by him self!
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post by Combuster »

Osbios wrote:I don't know how to change the cursor directly on the VGA card. I just hide the VGA cursor and use a blinking char to make my own cursor. I think that's more easy and faster.
The problem with this is that you didn't bother to answer the OP's question, instead you come with an ugly hack that has only remotely to do with the problem, and even less interesting.
jal wrote:Ignorance is no excuse. Of course it is not easier nor faster to not use the hardware cursor.
The problem here is just as serious and uninformed. Apart from the many negatives, using the blink bit _is_ faster because you are accessing video memory rather than I/O ports. Ease is in this case too subjective to judge.

For both of you, If you can't make a decent attempt to help, its better to not post at all.

@AlfaOmega: http://www.osdever.net/FreeVGA/vga/textcur.htm
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Osbios
Member
Member
Posts: 116
Joined: Fri Jun 10, 2005 11:00 pm

Post by Osbios »

A bit conservatively?
Combuster wrote:The problem with this is that you didn't bother to answer the OP's question, instead you come with an ugly hack that has only remotely to do with the problem, and even less interesting.

...

For both of you, If you can't make a decent attempt to help, its better to not post at all.
Well, ... the problem was to move a the courser around and hide it, wasn't it?
That's exactly what I solved by hiding the hardware courser and only use the blink-bit and a char.

I don't care if YOU dislike this way so much. I wont ask you every time before I post if you like my Ideas or not.

And hell, my OS is using the UGLY blink-but char courser. ]:D
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Post by jal »

Combuster wrote:sing the blink bit _is_ faster because you are accessing video memory rather than I/O ports.
You are right. Point taken.


JAL
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Post by jal »

Osbios wrote:Well, ... the problem was to move a the courser around and hide it, wasn't it? That's exactly what I solved by hiding the hardware courser and only use the blink-bit and a char.
That won't help you with in-line editing, if you want a blinking cursor underneath an already typed character.


JAL
Post Reply