Help with assembler thing

  • Thread starter Familie Smeding
  • Start date
F

Familie Smeding

Hello everyone,

I've just learned C++ a bit, and i think a good exercise would be to make a
small game(after having made the hello world examples etc.)
I've read quite a bit about setting screen modes and stuff using assembler,
and I understand it all, but I can't get it to work in Dev-Cpp. This is the
first bad part of the code I'm using:

//Header stoof

#include <cstdlib>
#include <iostream>
#include <DOS.H>
#include <MEM.H>
#include <STDLIB.H>
#include <STDIO.H>

using namespace std;

//Variable declarations
unsigned char Pall[256][3];
unsigned char *vaddr = NULL;

/*some working functions go here*/

//MCGA functions
void SetMCGA() {
_AX = 0x0013;
geninterrupt (0x10);
}

void SetText() {
_AX = 0x0003;
geninterrupt (0x10);
}

It goes wrong at SetMCGA, telling me that the variable _AX isn't defined.
How do I solve this?
I'm using Dev-Cpp for Windows.
 
M

Matthias Kaeppler

Familie said:
Hello everyone,

I've just learned C++ a bit, and i think a good exercise would be to make a
small game(after having made the hello world examples etc.)
I've read quite a bit about setting screen modes and stuff using assembler,
and I understand it all, but I can't get it to work in Dev-Cpp. This is the
first bad part of the code I'm using:

//Header stoof

#include <cstdlib>
#include <iostream>
#include <DOS.H>
#include <MEM.H>
#include <STDLIB.H>
#include <STDIO.H>

using namespace std;

//Variable declarations
unsigned char Pall[256][3];
unsigned char *vaddr = NULL;

/*some working functions go here*/

//MCGA functions
void SetMCGA() {
_AX = 0x0013;
geninterrupt (0x10);
}

void SetText() {
_AX = 0x0003;
geninterrupt (0x10);
}

It goes wrong at SetMCGA, telling me that the variable _AX isn't defined.
How do I solve this?
I'm using Dev-Cpp for Windows.

Yes, because it isn't defined. Solution: Define it.
I don't know what you're trying to achieve though. Do you want to use
inline assembly? This is off-topic here.
 
F

Familie Smeding

Why would this be off-topic? After all, it's still C++, and geninterrupt();
and stuff are normal functions.
The problem is, the variable isn't defined, while all the tutorials I've
read say it should be. I've included all the files the examples use, but it
still doesn't work.
And Matthias, if you don't know what I'm trying to do, why do you reply?
 
M

Matthias Kaeppler

Familie said:
Why would this be off-topic? After all, it's still C++, and geninterrupt();
and stuff are normal functions.
The problem is, the variable isn't defined, while all the tutorials I've
read say it should be. I've included all the files the examples use, but it
still doesn't work.
And Matthias, if you don't know what I'm trying to do, why do you reply?

My copy of the C++98 standard says nothing about a function called
geninterrupt(). It's probably a system-API function.
As to the variable:
There is no thing like predefined variables in C++. Either it's defined
as a constant in some header you have to include (which I doubt, since
you are trying to assign values to it), or you have to define it yourself.
By the way, which tutorials are you talking about? Maybe this one:
http://www.cprogramming.com/tutorial/tut1.html ?
From what I see, the "C++" code samples are only pseudo code and intend
that you use inline assembly features of your compiler. From any point,
this tutorial has nothing to do with C++ programming.

I suggest you read this instead, to get familiar with the language:
http://home.no.net/dubjai/win32cpptut/html/

If you want to get into game programming, use an API which abstracts
from your hardware/platform. Google for OpenGL or SDL, especially the
latter is pretty easy and straightforward to get into game programming
(it's a C API, but I guess there are C++ wrappers available).
 
G

Gary Labowitz

Familie Smeding said:
Why would this be off-topic? After all, it's still C++, and geninterrupt();
and stuff are normal functions.
The problem is, the variable isn't defined, while all the tutorials I've
read say it should be. I've included all the files the examples use, but it
still doesn't work.
And Matthias, if you don't know what I'm trying to do, why do you reply?

I smell a troll......
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,164
Messages
2,570,898
Members
47,439
Latest member
shasuze

Latest Threads

Top