I've been working on a small "engine" in C++ for developing purely text-based games (for the NDS using libnds, of course).
This is how the engine currently looks like in an emulator: http://i111.photobucket.com/albums/n147/IDKAA/e.png
The ">" sign can be moved around (and changes into a "<", "^" or "v" according to the direction it's "facing"), and the "/" symbols are "animated" (they rotate "/", "-", "\", "|", etc).
And it works pretty well.
On a real DS however, it looks like this: http://i111.photobucket.com/albums/n147/IDKAA/r.jpg
Well, the image isn't what I'd call "high quality", so...
Basically it works perfectly. except that a bunch of blinking smileys and strange symbols appear at the bottom center of the screen.
And... I can't figure out why this happens.
Well, I AM using consoleDemoInit and using cout to print stuff to the screen, and that's probably a bad idea. But I'm not sure that's the problem, and I'm new to libnds so I know no alternatives.
What can I do? Can someone point me in the rigth direction?
Thanks!
Game behaves strangely in the DS
-
- Site Admin
- Posts: 1845
- Joined: Tue Aug 09, 2005 3:21 am
- Location: UK
- Contact:
Re: Game behaves strangely in the DS
There's not really a lot we can do to help without at least seeing the nds file and preferably the actual code.
If you have the time and the inclination then IRC might be the best way to get help. See the link in my sig
If you have the time and the inclination then IRC might be the best way to get help. See the link in my sig
Re: Game behaves strangely in the DS
Here: http://www.host-a.net/u/Ideka/test.tar.gz
It's the source.
It's the source.
Re: Game behaves strangely in the DS
Well, I could finally get it fixed. It seems both Nocash and DeSmuMe initialize to 0 (i.e. NULL) the memory they reserve for the rom being played. Or maybe they don't, what the hell I have no idea what I'm talking about.
What I do know is that the problem was in image.cpp, here:
More specifically, in the condition of the second for.
Anyway, I'd explain what I think the cause was but I'm tired and I don't think much people care .
I'll just say that to fix it I switched from const char*[] to vector<string>:
(Of course I had to change other stuff accordingly.)
Thanks to the people who took a look at the code.
What I do know is that the problem was in image.cpp, here:
Code: Select all
void Image::initialize(const char* repr[]) {
transparent_char = '\0';
vector<char> line;
for (unsigned int i = 0; i < strlen(repr[0]); i++) {
line.clear();
for (unsigned int j = 0; repr[j][i] != NULL; j++) {
line.push_back(repr[j][i]);
}
data.push_back(line);
}
}
Anyway, I'd explain what I think the cause was but I'm tired and I don't think much people care .
I'll just say that to fix it I switched from const char*[] to vector<string>:
Code: Select all
void Image::init(vector<string> repr) {
transparent_char = '\0';
vector<char> line;
for (unsigned int i = 0; i < repr[0].size(); i++) {
line.clear();
for (unsigned int j = 0; j < repr.size(); j++) {
line.push_back(repr[j][i]);
}
data.push_back(line);
}
}
Thanks to the people who took a look at the code.
Re: Game behaves strangely in the DS
This sounds like a classic case of "I forgot to initialize my data." If anything, it's the first for loop's condition that doesn't make sense; you don't usually check strlen on an array of char pointers. First, strlen was specifically made for char arrays. Second, it checks byte-by-byte until it reaches a byte that has the value '0'. Each index in the array of char pointers is the size of an int, so really you should have been checking int-by-int, not byte-by-byte, since it could stop early if one of the bytes in an address happened to be '0'. But that's still not a good way to find the size of an array, unless you specifically allocated an extra space for a NULL pointer at the end.
Actually, now that I'm looking at it, your two samples of code are opposite of each other. The inner/outer loops are swapped between them. This may be the original source of your problem (or it could just be compounding it).
Actually, now that I'm looking at it, your two samples of code are opposite of each other. The inner/outer loops are swapped between them. This may be the original source of your problem (or it could just be compounding it).
Re: Game behaves strangely in the DS
whoops, my bad. Ignore what I said about the strlen stuff; you were doing it right. This code is very confusing. It would probably make sense to me with more context.
Re: Game behaves strangely in the DS
What do you mean? =omtheall wrote:This code is very confusing. It would probably make sense to me with more context.
Re: Game behaves strangely in the DS
What I mean is that I haven't looked at the rest of the code you posted, and without that context, I'm unsure what you're trying to accomplish with the snippet in your previous post. It looks like you're trying to store the data for an image in an vector of strings, which, honestly, seems like a very inflated way of doing it.
Re: Game behaves strangely in the DS
Well, as I said, the program is purely text-based, so "images" are actually made of characters.
Who is online
Users browsing this forum: No registered users and 12 guests