-
VGA help
I'm having some trouble following the VGA tutorials on this site. I get all sorts of compiler errors whenever I try the following program:
#include <iostream> // Included lots of includes just to
#include <stdlib.h> // make sure that I wasn't missing the one
#include <dos.h> // that I needed
#include <mem.h>
#include <stdio.h>
#include <conio.h>
using namespace std;
int main(void) {
_AX = 0x0013; // first compiler error on this line: undefined function
geninterrupt (0x10); // another similar compile error here
cin.get();
return 1;
}
Can someone help me?
-
could you please provide a bit more info , like your compiler and the exact error messages
-
also please edit your post and put the code tags in.
thanks
-
Not sure what you mean by 'tags', but as for the other stuff:
using the latest version of DevC++. The compilation errors are:
11 D:\Dev-Cpp\pixelprog.cpp `_AX' undeclared (first use this function)
12 D:\Dev-Cpp\pixelprog.cpp `geninterrupt' undeclared (first use this function)
BTW: the file name is D:\Dev-Cpp\pixelprog.cpp
-
Problem is that _AX is undefined in the compiler as well as geninterrupt(). Those are valid in DOS Turbo C/C++ but maybe not DEV-C. I would recommend getting your hands on DJGPP and dump the dev stuff. DJGPP is 50 bazillion times easier and better and you will have a lot less heartache.
Get it here:
www.delorie.com
Also works under Windows XP - but then so does Turbo C and Turbo C++. I've yet to find any major issues with programs running in the DOS shell for XP - save for certain int21h functions that either are not supported or not implemented.
-
I would recomend you to first learn how to program and understand well C, or C++. Then you can go to hardcore stuff like VGA modes...
-
Click here for information on CODE TAGS.
Standard & Non-standard C++...
The C++ language standard is designed to be portable. Pure standard code will run on any machine (after being compiled for a particular platform). It will run on a simple computer with a text display, a keyboard, and disk storage. So, there are no graphics or VGA in standard C++. Every C++ compiler will have all of the standard headers and the associated standard library functions. (Well, they are not all 100% standard-compliant... but that's another discussion.)
Most beginning C++ textbooks stick-to standard C++, so that the examples will work on any compiler/platform.
This also means that most real-world programs contain some non-standard code. Most compilers will have additional headers & libraries. Every compiler has a different set of additional non-standard headers.
Code:
#include <iostream> // Standard
#include <stdlib.h> // Standard, but should use <cstdlib>
#include <dos.h> // Non-standard
#include <mem.h> // Non-standard
#include <stdio.h> // Standard, but should use <cstdio>
#include <conio.h> // Non-standard, but very common
You can check your compiler's documentation for stuff like _AX and geninterrupt. If you don't get any 'hits', then your compiler doesn't have them.
-
Here is the exact problem my friend. You can't compile this code with your compiler. Look for one called Turbo C++ from Borland. Its a DOS compiler.
By the way, code tags are just a way of formatting code on the forums.
-
Thanks for the help. I'm searching for Turbo C++. Found a copy at borland's website, installed it, and it didn't have an executable file. I guess I'll keep searching.
That's really annoying: having different compilers with different commands like that.
-
The one at Borland's site works just fine. You did not unzip it correctly. You may have to use the SUBST DOS function to fake an A: drive for the install program. I'm not sure that XP can do this, but I'm sure there is a workaround.
And I would hardly call VGA programming hard-core stuff. I think it's an excellent place to begin learning. You can see the results of your code and you learn about pointers in the process. The drive to create bigger and better graphics, sounds, etc., will most certainly cause you to dive deeper and deeper into C/C++ and who knows what from there.
Get DJGPP. It is ten thousand times better than Turbo C++ and it compiles just fine under XP. As well it is in protected mode so there are no memory constraints (theoretically).
Try this in Turbo C++.
unsigned char *Test=new unsigned char[999999999];
Now try it in DJGPP. Given that you have enough RAM, it should work just fine.
I really wouldn't even mess with real mode programming (All Borland Turbo C++ DOS compilers operate in real mode) unless you like self-inflicted pain.
-
-
I know VGA is pretty useless and has no future, but I'm interested in it because of the dodgy look it gives. Reminds me of my good old days of mario and commander keen. I've considered learning openGL graphics programming, but it does't have the same dodgy feel as the platformer games I grew up on (good old 320X200 16 colour games: I really miss them).
Also, after learning QB for eight years, VGA graphics aren't entirely new to me. It seems a lot easier to put a dot on the screen in VGA than other modes, and the tutorials seem to show it as extremely simple stuff (like I can keep calling the same 2-3 line functions to do most of the work for me). Just writing to the memory a lot.
I got DJGCC and it's IDE. It looks good. I'm having (more) problems getting it completely installed though. I had to create new 'environment variables' to djgcc\djgcc.env, but that file doesn't seem to exist, and DJGCC gives me error messages saying the .env file is corrupt (despite the fact that it doesn't exist). I'm getting more and more confused by the day.
-
The env file should have come with the installation package. I'm sure its there. Make sure you read the readme file prior to doing anything with DJGPP. It works like a charm on my system.