Page 1 of 1

Cursor

Posted: Sun Jul 04, 2004 6:43 pm
by Gregor
Ive written a getline-functions.. but the problem is, sometimes I can see the "cursor", a line under the cursor position..and sometimes I dont see it.. how do I controll this? (Like in DOS, there?s allways a blinking line when you type something)

Re:Cursor

Posted: Mon Jul 05, 2004 1:16 am
by DennisCGc
This [url=http://my.execpc.com/~geezer/osd/cons/index.htm] website says:

Code: Select all

Move hardware cursor by changing VGA registers; without using the BIOS: 
        #include <dos.h> /* outportb() */
        unsigned short crtc_adr = 0x3D4; /* 0x3B4 for monochrome */
        unsigned short offset;
        unsigned short x = 20, y = 3;

   offset = x + y * 80;            /* 80 characters per line */
   outportb(crtc_adr + 0, 14);     /* MSB of offset to CRTC reg 14 */
   outportb(crtc_adr + 1, offset >> 8);
   outportb(crtc_adr + 0, 15);     /* LSB of offset to CRTC reg 15 */
   outportb(crtc_adr + 1, offset);
This should work...

HTH..

Re:Cursor

Posted: Mon Jul 05, 2004 4:42 am
by Gregor
Thank you! But how do I hide the cursor? So I wont see no line

Re:Cursor

Posted: Mon Jul 05, 2004 6:17 am
by pkd
Heres the code I use to turn the text cursor on and off its in asm,
but should be easy to convert to c if thats what you need, just use
ie. outportb(0x3d4,0x0a)

Hope this helps
pkd


;------------------------------------------
;Turn Cursor on
;------------------------------------------
   mov   dx,0x3d4   
   mov   al,0x0a
   out   dx,al

   mov   dx,0x3d5   
   mov   al,0x0f
   out   dx,al

   mov   dx,0x3d4
   mov   al,0x0b
   out   dx,al

   mov   dx,0x3d5
   mov   al,0x0f
   out   dx,al
;----------------------------------------
;Turn Cursor off
;----------------------------------------   
   mov   dx,0x3d4
   mov   al,0x0a
   out   dx,al

   mov   dx,0x3d5
   mov   al,0x2f
   out   dx,al

   mov   dx,0x3d4
   mov   al,0x0b
   out   dx,al

   mov   dx,0x3d5
   mov   al,0x0f
   out   dx,al

Re:Cursor

Posted: Mon Jul 05, 2004 7:20 am
by Gregor
Thank you..
something is strange.. I got an input function..suppose I write:
hello
then I dont see the cursor..but if I use backspace and Then type, then I see the cursor (but only on the places where it was text before and I used backspace)...

Re:Cursor

Posted: Mon Jul 05, 2004 7:22 am
by Gregor
found the problem I guess.. it only shows the cursor when there?s a ' ' space.. so I need to fill the screen with spaces to see it :)

Re:Cursor

Posted: Mon Jul 05, 2004 8:41 am
by DennisCGc
Gregor wrote: found the problem I guess.. it only shows the cursor when there?s a ' ' space.. so I need to fill the screen with spaces to see it :)
Hmm, maybe you set the attribute byte to 0, so indeed you won't see the cursor :)