Thread: read console x y position

  1. #1
    Registered User red_baron's Avatar
    Join Date
    May 2002
    Posts
    274

    Question read console x y position

    i'm searching everywhere to learn how to find the console coord (x, y position) not give it new coord, just find out what the coordinates are for the cursor.

    thanx in advance
    ¿Red Baron?

    "Imagination is more important than knowledge"
    -Albert Einstein (1879-1955)

    Check out my games!

    [code] /* dont forget code tags! */ [/code]

  2. #2
    Registered User VBprogrammer's Avatar
    Join Date
    Mar 2002
    Posts
    175
    Ive dont this in ASM before, ive posted the code below incase it helps.

    Code:
    mov dx, 0x03D4  ;Get Cursor Position MSB
       mov al, 0x0E
       out dx, al
       mov dx, 0x03D5
       in al, dx
       shl ax, 8       ;Store MSB in ah
       mov dx, 0x03D4  ;Get Cursor Position LSB
       mov al, 0x0F
       out dx, al
       mov dx, 0x03D5
       in al, dx       ;Store LSB in al
    
       mov bh, 80      ;Divide to get XY coordinates (X in ah and Y in al)
       div bh
    	
       xchg ah, al     ;The Y coordinate must be first and the X coordinate last
    The other way of doing it in dos is to use interupt 10, 3 (though i havent used this method before). Heres a discription of how to use it:

    Code:
    Int 10
    
    AH = 0x03
    BH = Video page - probably 0
    
    On return:
    DH = Y co-ord
    DL = X co-ord
    VC++ 6

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    You can use ansi escape codes to save the cursor position.

    Quzah.
    Hope is the first step on the road to disappointment.

  4. #4
    Registered User VBprogrammer's Avatar
    Join Date
    Mar 2002
    Posts
    175
    Well not really, because the method i used (the first one) actually reads the graphic controllers curser position so will work in any OS (actually i did it in the absence of an OS).
    VC++ 6

  5. #5
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Originally posted by VBprogrammer
    Well not really, because the method i used (the first one) actually reads the graphic controllers curser position so will work in any OS (actually i did it in the absence of an OS).
    Oh really? On a SUN system? On an Alpha? On a ...

    Quzah.
    Hope is the first step on the road to disappointment.

  6. #6
    Registered User red_baron's Avatar
    Join Date
    May 2002
    Posts
    274
    i'll try some of the stuff you guys suggested, all i need it for is windows, thanx for the help so far
    ¿Red Baron?

    "Imagination is more important than knowledge"
    -Albert Einstein (1879-1955)

    Check out my games!

    [code] /* dont forget code tags! */ [/code]

  7. #7
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Originally posted by VBprogrammer
    Well not really, because the method i used (the first one) actually reads the graphic controllers curser position so will work in any OS (actually i did it in the absence of an OS).
    Did I miss something..? When did assembler become portable?
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  8. #8
    Registered User red_baron's Avatar
    Join Date
    May 2002
    Posts
    274
    i've ready the ansi escape codes and i'm pretty sure this is what i need
    ESC[s
    Save Cursor Position: Saves the current cursor position. You can move
    the cursor to the saved cursor position by using the Restore Cursor
    Position sequence.
    but i'm not sure how to use this, any help?

    ps thanx VBprogrammer for the code but i have no idea how to use asm or the code you posted.
    ¿Red Baron?

    "Imagination is more important than knowledge"
    -Albert Einstein (1879-1955)

    Check out my games!

    [code] /* dont forget code tags! */ [/code]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. fscanf function won't read my float value...?
    By qpsnhalfs in forum C Programming
    Replies: 8
    Last Post: 07-07-2009, 11:01 PM
  2. bytes lost with partial read in UDP
    By mynickmynick in forum Networking/Device Communication
    Replies: 3
    Last Post: 03-31-2009, 02:06 AM
  3. Pipe the console from a DLL
    By loobian in forum Windows Programming
    Replies: 12
    Last Post: 11-30-2003, 08:55 PM
  4. Replies: 0
    Last Post: 02-05-2002, 07:44 PM
  5. Help! Can't read decimal number
    By Unregistered in forum C Programming
    Replies: 2
    Last Post: 09-07-2001, 02:09 AM