WITHOUT BIOS: GET X AND Y (TEXT MODE)

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.
Locked
User avatar
matias_beretta
Member
Member
Posts: 101
Joined: Mon Feb 26, 2007 3:39 pm

WITHOUT BIOS: GET X AND Y (TEXT MODE)

Post by matias_beretta »

How can I get X and Y without BIOS?
frank
Member
Member
Posts: 729
Joined: Sat Dec 30, 2006 2:31 pm
Location: East Coast, USA

Post 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.
urxae
Member
Member
Posts: 149
Joined: Sun Jul 30, 2006 8:16 am
Location: The Netherlands

Post 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.
User avatar
XCHG
Member
Member
Posts: 416
Joined: Sat Nov 25, 2006 3:55 am
Location: Wisconsin
Contact:

Post by XCHG »

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.
SpooK
Member
Member
Posts: 260
Joined: Sun Jun 18, 2006 7:21 pm

Post 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 :?:
Locked