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
Moving the cursor
Re: Moving the cursor
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.
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.
Re: Moving the cursor
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
I ment an other snippet which I don't understand. Didn't know that df also has made one.
Thanks anyway!
mfG
DossKl
Re: Moving the cursor
But: the cursor doesn't move with the above code. When I use BIOS function 0x02 int 0x10 it moves.
DossKl
DossKl