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.
When I run the function the cursor is blinking in the middle of the screen. Why does the cursor stand on that place? and how can I hide the cursor or set it to point 0.0.
I am going to use this code for my setcursorpos() function, but which one is the x coordinate and which is y? I think the first is the y coordinate because of something my old programming teacher said (havent done much vga programming as of yet and my kernel isnt far enough advanced that I can test the function out myself to see)
I've got a question about the cursor. When I execute this piece of code, the cursor is set in the middle of the screen. But if you write to 0xB8000, the cursor is not moved, sn't it?
zyp wrote:
You have to move the cursor yourself, it's not done automatically when writing to the screen buffer.
Yeah I know, I have that in my print function already, but I wasnt sure how to move it unless I wrote to the screen, so I wanted a standalone solution.
If you're using GRUB, the cursor is probably at the position where GRUB finished outputting text before booting your kernel. That's what happens to me, anyway...
Top three reasons why my OS project died:
Too much overtime at work
Got married
My brain got stuck in an infinite loop while trying to design the memory manager
btw, I'd only move the cursor upon user input at each keystroke, else I'd move it straight to the end of the recently output line (after all the output is done)
void setcursor(byte i, byte j)
{
unsigned short position = (j * width + i);
// cursor LOW port to vga INDEX register
outportb(0x3D4, 0x0F);
outportb(0x3D5, (unsigned char)(position & 0xFF));
// cursor HIGH port to vga INDEX register
outportb(0x3D4, 0x0E);
outportb(0x3D5, (unsigned char)((position >> 8) & 0xFF));
}
This will move your hardware cursor at desired X,Y position.
One thing that I just figured out, I'm sure it's obvious to some (most?), but the cursor will be displayed in whatever color the framebuffer has for that particular character...
I was clearing my screen with memset( buf, 0, 80*25*2 ) and wondering why my cursor had disappeared...