I want to change cursor position in my C++ program. As you know, C++ does not have any command to do this. By I think, one of the h files can be used for this purpose.

My Bloodshed compiler has lots of "*.h" files. But I don't know how to use any of them. Even you tell me an header file name, it doesn't have any worth since I don't know how to use it.

Is there any URL that explains most commonly used header files?
-----------------------------------
OR...

I can set cursor position or create any graphics within Assembly language. But, Bloodshed supports AT&T Assembly language standard. That is good, but I don't know how to call interrupts within AT&T Assembly.

Can you please help me on calling interrupts in that standard?

>Can you please help me on calling interrupts in that standard?
Didn't you already ask that question, or was it someone else?

>By I think, one of the h files can be used for this purpose.
windows.h, and you have to implement the functionality yourself:

#include <windows.h> 

void gotoxy ( short x, short y )
{
  COORD coord = {x, y};
  SetConsoleCursorPosition ( GetStdHandle ( STD_OUTPUT_HANDLE ), coord );
}

Thank you,
I am gonna try it.

Yes, it works. Really thanks.
But what about graphics and using Assembly?

>But what about graphics and using Assembly?
What about graphics and using assembly? RTFM first if you have an compiler specific question.

In the tutorials of this web site, I found a topic related in using Mod 13h graphics in C++. Have a look at this URL :http://www.daniweb.com/tutorials/tutorial8439.html. I tried it on my computer, but the following function made the compiler give some error messages :

void set_mode(byte mode)
{
	union REGS regs;
	
	regs.h.ah = SET_MODE;
	regs.h.al = mode;
	int86(VIDEO_INT, &regs, &regs);
}

<< moderator edit: added [code][/code] tags >>

The compiler (I am using Dev-C++) gave the error on the "union REGS regs;" line. I think it is about the dos.h header file. I couldn't solve the problem because of having lackness in information on using dos.h and calling interrupts.

And another problem... Also the program need a byte type variable in order to load values to al and ah registers. But C++ does not support 'byte' type, or does it? Can I use char for this purpose? Is there any chr() or asc() (as in BASIC or PASCAL) function in C++ for conversion between char and integer?

May someone please help me?

If you're writing Turbo C code for DOS, use Turbo C for DOS.

Yes Dave, you're right.
At the weekend, I studied on it and I realized than dos.h for Bloodshed has no union type for REGS. But Turbo C has...

I quit using Bloodshed, now I am using Microsoft Visual C++, And I wrote the following code in MS VC++ :

#include <cstdlib>
#include <iostream>

using namespace std;

void VGAInitialize(short ScreenMode) {
    //char ModeChar;
    //ModeChar=BINTOC(ScreenMode);
    __asm
    {
        mov ax, ScreenMode //0x0013    03h for text secreen
        int  0x10        //The program gives error here
    }
}

void Pixel(short Apsis, short Ordinate, char Colour)
{
    __asm
    {
        mov ah, 0x0C        //Interrupt sub-function
        mov bh, 0x00        //Video page number
        mov al, Colour
        mov cx, Apsis
        mov dx, Ordinate
        int 0x10
    }
}

int main(int argc, char *argv[])
{
    VGAInitialize(0x0013);

    char Colour=7;
    for(int y=0; y<200; y++) for(int x=0; x<320; x++)
    {
        Colour=y;
        Pixel(x, y, Colour);
    }

    VGAInitialize(0x0003);
    system("PAUSE");
    return EXIT_SUCCESS;
}

It compiles successfuly but again gives an error message on the line which I marked up above. OSs, I tested on , are WinXP and Win2000

So what do you think, the reson can be for this error?
Can any of you try this code on Win98 or DOS?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.