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.
Yeah i know. Its really sloppy code, but none the less it should still print the character pressed. Shouldn't it?
It does nothing though. I dont see why it doesnt print the characters pressed to the screen.
It does work however, It overwrites the last character placed on the screen.
How could I leave the last character as well? I suppose that is because it is using the same byte loaded each time the function is called? Yes I know C, but I don't know C with out my regular include files.
You didnt write right. this code will keep writing a character at 0xb8000, and thats not right, right? You gotta write it to keep track of the cursor position, thats the right way to do it.
Another issue is that your code would display the same keypress *many* times. You don't notice this now because it puts it at the same place on the screen, but after you've got your code working properly it'll probably end up llllllloooooooooookkkkkiiiiinggggggg llllllliiiiiikkkkkkkeeeee tttttttthhhhhiiiiisssssss!!!!!!!!!!!
The problem is that "scancode = inb(0x60);" will get the last byte sent from the keyboard to the keyboard controller. You need to wait until the next byte is sent from the keyboard to the keyboard controller and then get that byte (and display it) once.
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
The problem with your WriteChar function is that it always writes to 0xb8000 exactly. Remember, video memory only starts at 0xb8000; it's a big chunk of space from 0xb8000 to (0xb8000 + (80 * 25 * 2)). You've got to keep track of where you're writing to, and write to 0xb8000 + the offset to your target cell.
Keep track of your row and column (use static or global variables). In WriteChar, increment your row, and if it's end-of-line zero it and increment your column. If you want, then you can implement a scroll_screen and call that when you hit the bottom row; it's up to you. Anyway, when you find your write address, you use 0xb8000 + ((column * 80) + row) * 2. (* 2 is there because a character is 2 bytes.)
And you haven't tested it, obviously, which you should have done.
Again, you failed to ask smart questions, and worse, do you even have the necessary (programming) skills to be taking on OS development since you fail at even the most basic programming tasks.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]