c++ help needed

Status
Not open for further replies.

masterovpuppetz

Right off the assembly line
I wanted know if there's a way in c++ to know what character exists at a particular x,y coordinate.
for eg: suppose i used gotoxy(2,5) and my cursor is now at (2,5) and i want to know what character exists next to my cursor at (3,5). How can i know that?
 

dheeraj_kumar

Legen-wait for it-dary!
The screen is an output device, its for echoing the data in the memory. You cant read from the output device. What exactly are you trying to do? We can suggest alternatives for that.
 

lucifer_is_back

Journeyman
I wanted know if there's a way in c++ to know what character exists at a particular x,y coordinate.
for eg: suppose i used gotoxy(2,5) and my cursor is now at (2,5) and i want to know what character exists next to my cursor at (3,5). How can i know that?
well you can do it if you are in Win98 by directly accessing the video ram buffer located at 0xB8000, in physical memory. The buffer is of the datatype 'short', Each 16-bit element in the text memory buffer is broken into an 'upper' 8-bits and a 'lower' 8-bits. The lower 8 bits of each element tells the display controller what character to draw on the screen. We just have to extract this lower byte

use the following code

Code:
index = (y_value_cur * width_of_screen) + x_value_cur;
unsigned short *where = (unsigned short *)0xB8000 + index;
this code will give you direct access to the location where your cursor is

now to move to next or previous position just increment or decrement the where pointer .
 
OP
M

masterovpuppetz

Right off the assembly line
as u guys said tht it was not possible to get input from buffer screen using standard c++,i modified my code (infact had to reprogram about two thirds of it).

So now instead of getting the x,y coordinates during runtime, I have made a array of x,y coordinates( which holds the desired character) and check wether the cursor coordinates is next to ne of these predefined coordinates.

Not the best way to do the job i guess, but at least the program is working !!
 
Status
Not open for further replies.
Top Bottom