Setting Up The Cursor Position
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?
AhmedHan
Junior Poster in Training
71 posts since Apr 2005
Reputation Points: 13
Solved Threads: 1
>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 );
}
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
Thank you,
I am gonna try it.
AhmedHan
Junior Poster in Training
71 posts since Apr 2005
Reputation Points: 13
Solved Threads: 1
Yes, it works. Really thanks.
But what about graphics and using Assembly?
AhmedHan
Junior Poster in Training
71 posts since Apr 2005
Reputation Points: 13
Solved Threads: 1
>But what about graphics and using Assembly?
What about graphics and using assembly? RTFM first if you have an compiler specific question.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
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, ®s, ®s);
}
<< 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?
AhmedHan
Junior Poster in Training
71 posts since Apr 2005
Reputation Points: 13
Solved Threads: 1
If you're writing Turbo C code for DOS, use Turbo C for DOS.
Dave Sinkula
long time no c
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
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
#include
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?
AhmedHan
Junior Poster in Training
71 posts since Apr 2005
Reputation Points: 13
Solved Threads: 1
Dave Sinkula
long time no c
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314