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
Gregor

Cursor

Post 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)
DennisCGc

Re:Cursor

Post 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..
Gregor

Re:Cursor

Post by Gregor »

Thank you! But how do I hide the cursor? So I wont see no line
pkd

Re:Cursor

Post 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
Gregor

Re:Cursor

Post 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)...
Gregor

Re:Cursor

Post 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 :)
DennisCGc

Re:Cursor

Post 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 :)
Post Reply