OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Apr 18, 2024 9:55 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Moving the cursor
PostPosted: Sun Oct 21, 2001 1:56 am 
Hi!
Anyone has some infos about moving the cursor by direct video access? A sourcecode in C would also be very helpfully for me, if possible with comments.
Just for info: The one on OSD I don't understand

Thanks
DossKl


Top
  
 
 Post subject: Re: Moving the cursor
PostPosted: Sun Oct 21, 2001 4:10 am 
What's wrong with df's code snippet in his FAQ?
http://www.mega-tokyo.com/os/os-faq-console.html

I hope df does not mind if I'll try to explain what he does and why it works... ;)

A quick explanation:

There is a chip on your VGA card called CRTC (Cathod Ray Tube Controller), responsible for the video signal generation. It has a set of registers you can modify. To communicate with the CRTC you use 2 ports, the so called Index Port ( port no. 3D4H in color and 3B4H in monochrome display mode) and Data Port (3D5H in color and 3B5H in monochrome display mode).

To read/write the value of a single CRTC register you must first output its identifier (number) to the Index Port (outb in C) and then read/write the register value using the Data Port (inb/outb in C).

There are 2 registers controlling the cursor position in text modes, they are called Cursor Address High (register no. 0EH) and Cursor Address Low (register no. 0FH). Together they hold the LINEAR OFFSET ADDRESS of the cursor relative to the start of the the video memory (it means they do not hold the row/column values as you may have thought first ;)). The offset is a 16-bit value you calculate after the following formula:

? ?_offset_ = (current_row * total_columns) + current_column

Then you write the higher byte of ?_offset_ to the CRTC register no. 0EH and the lower byte to 0FH and voila. That's what df's code is doing for the 80x25 color text mode.


Top
  
 
 Post subject: Re: Moving the cursor
PostPosted: Sun Oct 21, 2001 7:54 am 
Ah, tanks!
I ment an other snippet which I don't understand. Didn't know that df also has made one.
Thanks anyway!

mfG
DossKl


Top
  
 
 Post subject: Re: Moving the cursor
PostPosted: Sun Oct 21, 2001 8:03 am 
But: the cursor doesn't move with the above code. When I use BIOS function 0x02 int 0x10 it moves.

DossKl


Top
  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Markelov69 and 117 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group