[Prev][Next][Index][Thread]

Re: I big question




oskit/kern/x86/pc/direct_cons_putchar.c has:

  static void set_cursor(unsigned int pos);

which looks to do the same as Ramon's code (s/videoMemOffs/pos/).  We
don't seem to have a get_cursor call (or maybe I just didn't look very
hard).

Aargh, just noticed that this function is static so it's not much use
to you.  Mutter, mutter, C's lame excuse for a module system, mutter
mutter.

--
Alastair Reid        reid@cs.utah.edu        http://www2.cs.utah.edu/~reid/


> For this specific case, moving the hardware cursor is pretty
> easy. (but I can't imagine that the OSKit doesn't have a text
> driver :).  Still, if you want to do it manually, that's
> possible.) Here's some code:
> 
> [base for gotoxy]
>     videoMemOffs >>= 1;                 /* Set the new cursor position 
> */
>     outportb(0x3d4, 0x0f);
>     outportb(0x3d5, videoMemOffs & 0x0ff);
>     outportw(0x3d4, 0x0e);
>     outportb(0x3d5, videoMemOffs >> 8);
> 
> [base for getxy]
>     outportb(0x3d4, 0x0e);              /* Get cursor Y position       
> */
>     videoMemOffs = inportb(0x3d5);
>     videoMemOffs <<= 8;
>     outportb(0x3d4, 0x0f);              /* And add cursor X position   
> */
>     videoMemOffs += inportb(0x3d5);
>     videoMemOffs <<= 1;
> 
> videoMemOffs is the byte offset into the video memory.
> Actually, this is part of a printf() routine, that's
> why it looks so weird :)

References: