WITHOUT BIOS: GET X AND Y (TEXT MODE)
- matias_beretta
- Member
- Posts: 101
- Joined: Mon Feb 26, 2007 3:39 pm
WITHOUT BIOS: GET X AND Y (TEXT MODE)
How can I get X and Y without BIOS?
If you want to get the line and column of the text-mode cursor, this is what I use: ("width" is a constant with value 80 and inp and outp perform IN and OUT assembly instructions, respectively)
I thought I originally got this from Bran's tutorial, but looking back at that I can only find code to set the cursor position. This is basically the reverse of that code though, reading the I/O registers that store the location instead of writing them and reversing the "csr_y * 80 + csr_x" computation.
Code: Select all
// Read cursor high byte
outp(0x3D4, 14);
int temp = inp(0x3D5) << 8;
// Read cursor low byte
outp(0x3D4, 15);
temp |= inp(0x3D5);
// Decode
csr_y = temp / width;
csr_x = temp % width;
I thought I originally got this from Bran's tutorial, but looking back at that I can only find code to set the cursor position. This is basically the reverse of that code though, reading the I/O registers that store the location instead of writing them and reversing the "csr_y * 80 + csr_x" computation.
Why are you repeating this question while you have already asked it here?
On the field with sword and shield amidst the din of dying of men's wails. War is waged and the battle will rage until only the righteous prevails.
Because he is impatient and wants to be spoon-fed source codeXCHG wrote:Why are you repeating this question while you have already asked it here?
![Question :?:](./images/smilies/icon_question.gif)