Page 1 of 1

WITHOUT BIOS: GET X AND Y (TEXT MODE)

Posted: Mon Jul 30, 2007 2:23 pm
by matias_beretta
How can I get X and Y without BIOS?

Posted: Mon Jul 30, 2007 6:09 pm
by frank
Do you mean width and height? If you do then I believe that standard text mode is 80 by 25. All the computers I have ever seen boot up in that mode.

Posted: Tue Jul 31, 2007 3:10 am
by urxae
If you want to get the line and column of the text-mode cursor, this is what I use:

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;
("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.

Posted: Tue Jul 31, 2007 4:44 am
by XCHG
Why are you repeating this question while you have already asked it here?

Posted: Tue Jul 31, 2007 8:30 am
by SpooK
XCHG wrote:Why are you repeating this question while you have already asked it here?
Because he is impatient and wants to be spoon-fed source code :?: