gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Beginners > error

#13883 - DDRfreak121 - Wed Dec 24, 2003 4:22 pm

Ok........I wanted to try my own at displaying an image so I got dovoto's image converter and made a C header file out of it

I also included gba.h and disprnct.h in the folder

I made the source
Code:
#include <gba.h>
#include <dispcnt.h>
#include <cool.h>

void Plotpixel(int x,int y, unsigned short int c)
{
VideoBuffer[(y) * 120 + (x)]= (c);
}

int main()
{
int loop;
int x,y;
SetMode(MODE_4 | BG2_ ENABLE);

for(loop = 0; loop < 256;loop++);
BGPalletteMem[loop] = coolPallette[loop];

while(1)
{
for(y=0;y<160;y++)
{
for(x=0;x<120;x++)
{
PlotPixel(x,y, coolData[y*120+x];
}
}
}
}
 
  system("PAUSE");   
  return 0;
}


and made a batch file
Code:
path=C:\devkitadv-r5-beta-3/bin

gcc -o yo.elf yo.c  -lm

objcopy -O binary yo.elf yo.bin
pause


I ended up getting this error saying that gba.h was undeclared and all the other things were undeclared
Why is this happening

#13884 - poslundc - Wed Dec 24, 2003 4:38 pm

It could be that your compiler is not configured to look in the user directory for system include-files.

Try it with quotes instead of angle-brackets (ie. #include "gba.h") instead.

Dan.

#13885 - DDRfreak121 - Wed Dec 24, 2003 5:18 pm

not that

Heres the error I get

C:\Documents and Settings\Zack1\Desktop\New Folder (2)>path=C:\devkitadv-r5-beta
-3/bin

C:\Documents and Settings\Zack1\Desktop\New Folder (2)>gcc -o yo.elf yo.c -lm
yo.c:1:17: gba.h: No such file or directory
yo.c:2:20: ispcnt.h: No such file or directory
yo.c:3:18: cool.h: No such file or directory
yo.c: In function `Plotpixel':
yo.c:7: `VideoBuffer' undeclared (first use in this function)
yo.c:7: (Each undeclared identifier is reported only once
yo.c:7: for each function it appears in.)
yo.c: In function `main':
yo.c:14: `MODE_4' undeclared (first use in this function)
yo.c:14: `BG2_' undeclared (first use in this function)
yo.c:14: syntax error before "ENABLE"
yo.c:17: `BGPalletteMem' undeclared (first use in this function)
yo.c:17: `coolPallette' undeclared (first use in this function)
yo.c:25: `coolData' undeclared (first use in this function)
yo.c:25: syntax error before ';' token
yo.c: At top level:
yo.c:31: syntax error before string constant
yo.c:31: warning: data definition has no type or storage class

C:\Documents and Settings\Zack1\Desktop\New Folder (2)>objcopy -O binary yo.elf
yo.bin
objcopy: yo.elf: No such file or directory

C:\Documents and Settings\Zack1\Desktop\New Folder (2)>pause
Press any key to continue . . .

#13886 - dagamer34 - Wed Dec 24, 2003 5:21 pm

The compiler does not like spaces in its file path. Its better just to create a new folder at the base of the drive ex. (C:\GBA) and put the compiler there. Then it should work.

Also, there are a couple of misspellings.

You put this as the function declaration:
Quote:

Plotpixel (blah..., blah...)


But then use it like this
Quote:

PlotPixel (blah..., blah...)

And BGPaletteMem has only one l.


One last thing to help you is to compile your ROMS with the .gba extenstion, that way you can associate it with VBA and double-click from My Computer.
_________________
Little kids and Playstation 2's don't mix. :(

#13887 - DDRfreak121 - Wed Dec 24, 2003 5:32 pm

how would I change the root folder of the compiler

I tryed reinstalliung it to there but it made no difference

#13890 - sajiimori - Wed Dec 24, 2003 5:58 pm

Are you asking how to move folders? Read your OS manual.

Change #include <gba.h> to #include "gba.h" and make sure the file is in the directory and it should work.

Anyway, you called system("pause") which doesn't make any sense on gba, since it comes with no operating system, and thus has no "pause" command. Then you return to the nonexistant OS, which makes the gba reset. You need an infinite loop instead.

dagamer34, .elf represents a compiled ELF binary complete with symbols and linkage info, while .gba represents a stripped, flat binary, which is quite different.


Last edited by sajiimori on Wed Dec 24, 2003 6:04 pm; edited 1 time in total

#13891 - DDRfreak121 - Wed Dec 24, 2003 5:59 pm

No.....I dont understand what he is asking me to do with the moving thing

#13892 - poslundc - Wed Dec 24, 2003 6:02 pm

dagamer34 wrote:
The compiler does not like spaces in its file path.


It doesn't look like there were any spaces in his file path. The path statement was: path=C:\devkitadv-r5-beta-3/bin

It could be a problem that you're mixing forward- and back-slashes; I don't know enough about Windows to say.

If you do want to change the root folder of the compiler, it's pretty simple. Hilight the current folder in your C drive (devkitadv-whatever), select the text, and type a new name. I'm not a Windows user and I could figure that one out.

Did you try switching it to quotes? I can tell you right now that you should be using quotes instead of angle brackets, and even if that's not what's causing the problem now it very well might still cause a new problem when you fix the current one.

Dan.

#13894 - sajiimori - Wed Dec 24, 2003 6:05 pm

GCC doesn't mind having mixed backslashes and forward slashes on Win32.

Edit: excuse me, you meant when assigning the path, which has nothing to do with GCC. Well, at least on WinXP, it still doesn't mind having forward slashes.


Last edited by sajiimori on Wed Dec 24, 2003 6:09 pm; edited 1 time in total

#13895 - DDRfreak121 - Wed Dec 24, 2003 6:05 pm

Damn....

I did everything you all said

changed it to quotes
fixed the Pixel thing
Changed the slash
and whatever else

Should I be using a different compiler than dev c++?

#13897 - sajiimori - Wed Dec 24, 2003 6:07 pm

DevC++ is not a compiler, it's an IDE.

#13903 - Miked0801 - Wed Dec 24, 2003 6:59 pm

Take the semi-colon off the back of your for statement. This is why I always {} brace statements even if they're one lineers.

for(i-0;i<10;i++);
foo();

executes foo once as the for loop is only a stupid way to assign 10 to i. If you place a -Wall in your command line, it might catch that.

Once running, the game will never get to the system message as your while loop runs (ruins) for ever. For god's sake, please tab your braces in either K&R or Pascal style so you (and we) can figure out your program's flow control.

I'd place either a -I<path> on your gcc so it can find the .h files - or place the /include and /lib directories in your path as well. The bin directory only includes gcc and make0 - not the include files. That's why it can't find those files.

Mike

#13904 - dagamer34 - Wed Dec 24, 2003 7:21 pm

I was actually talking about where his files are located. There are spaces in THAT path.

C:\Documents*SPACE*and*SPACE*Settings\

See what i mean? Its because it can't find those files where all that stuff is included.
_________________
Little kids and Playstation 2's don't mix. :(

#13906 - DDRfreak121 - Wed Dec 24, 2003 7:48 pm

Yeah I guess

the thing that pisses me off is that I dled the gbajunkie chapter 3 thing and it had an example image that ran fine

I did the exact same thing but changed the image and name from palette to cool and it didnt work

#13911 - sajiimori - Wed Dec 24, 2003 9:38 pm

dagamer34, GCC doesn't care about spaces in the path to either its own files or the project files, even on Win32.

For instance, this works fine:
Code:

C:\Documents and Settings\temp>dir/b
test.h
test.c

C:\Documents and Settings\temp>type test.c
#include "test.h"
main() {}

C:\Documents and Settings\temp>gcc -o test.exe test.c

C:\Documents and Settings\temp>dir/b
test.h
test.c
test.exe

#14028 - DDRfreak121 - Sat Dec 27, 2003 10:59 pm

OK heres what I did

this might be wrong becuase it displayed in my error message

I dled the tutorial to GBAJUNKIE chapter 3

I then changed the image and converted something else

I named it cool so I changed the content of the imagedisp.cpp thing it came with from

junkiePalette
to
coolPalette

It then says in the batch error message that coolPallette is unrecognized

I think that might be the problem but Im not sure how to fix it

#14032 - poslundc - Sat Dec 27, 2003 11:59 pm

A good first step would be to check and see if you can get it working WITHOUT making any changes to it...

Dan.

#14033 - DDRfreak121 - Sun Dec 28, 2003 12:00 am

I can........

the image displays fine

I dont know what is wrong

#14035 - poslundc - Sun Dec 28, 2003 12:09 am

My guess, then, is that you didn't find and change all occurrences of junkiePalette in your code to coolPalette.

But that's the best I (or just about anyone else) can do without seeing the actual source and error messages.

Dan.

#14042 - yaustar - Sun Dec 28, 2003 2:39 am

If you want, email it to me at yaustar_8p@NOSPAMyahoo.co.uk, remove NOSPAM. And I see what I can do.
_________________
[Blog] [Portfolio]

#14052 - DDRfreak121 - Sun Dec 28, 2003 4:08 pm

Do you have to change the screenn mode or anything else when you change the picture?

Its a color image does that change anything

Im desperate

I even named the new picure junkie.h and kept everything the same and it failed to work

damn

#14053 - poslundc - Sun Dec 28, 2003 4:35 pm

OK, are you saying that the only thing you changed was the name of the header file from "image.h" (or whatever it was) to "junkie.h"? And it worked before you changed the name of the file?

Then the only thing I can say is make sure you've changed the #include statements everywhere to reflect this change.

Other than that, we're still not getting enough info on what the problem is. Post your code and the error message. (Or take yaustar up on his e-mail offer.)

Dan.

#14055 - DDRfreak121 - Sun Dec 28, 2003 5:27 pm

Ok..........
[Images not permitted - Click here to view it]
the image (Just used that off the homepage because it was GBA screen size)

I used gfxfront to convert it to a C file....then made it a header file

I placed it in a folder along with gba.h and discrept.h that came with the tutorial

I then opened up the imagedisp c++ document

Code:
#include "gba.h"        //GBA register definitions
#include "dispcnt.h"    //REG_DISPCNT register definitions
#include "junkie.h"   //holds the image information in an array

void PlotPixel(int x,int y, unsigned short int c)
{
   VideoBuffer[(y) * 120 + (x)] = (c);
}

int main()
{
   int loop;
   int x, y;

        SetMode(MODE_4 | BG2_ENABLE); //set mode 4 and enable background 2

   for(loop = 0; loop < 256; loop++)                 //256 entries allowed
      BGPaletteMem[loop] = junkiePalette[loop]; //load the palette into palette memory

   while(1)
   {
      for(y = 0; y < 160; y++)                  //screen height
      {
         for(x = 0; x < 120; x++)          //screen width
         {
            PlotPixel(x,y, junkieData[y*120+x]);   //load image data into
         }                  //memory pixel by pixel
      }
   }
}




I didn't change anything at all
I then name the image C file junkie.h

I created a batch
Code:
path=C:\devkitadv-r5-beta-3\bin

gcc -o imagedisp.elf imagedisp.cpp

objcopy -O binary imagedisp.elf imagedisp.bin

pause


and then tryed to run it

this is the error I got

not really a code but...
Code:
C:\Documents and Settings\Zack1\Desktop\New Folder (3)>path=C:\devkitadv-r5-beta
-3\bin

C:\Documents and Settings\Zack1\Desktop\New Folder (3)>gcc -o imagedisp.elf imag
edisp.cpp
In file included from imagedisp.cpp:9:
junkie.h:13: syntax error before `~' token
imagedisp.cpp: In function `int main()':
imagedisp.cpp:24: `junkiePalette' undeclared (first use this function)
imagedisp.cpp:24: (Each undeclared identifier is reported only once for each
   function it appears in.)
imagedisp.cpp:32: `junkieData' undeclared (first use this function)

C:\Documents and Settings\Zack1\Desktop\New Folder (3)>objcopy -O binary imagedi
sp.elf imagedisp.bin
objcopy: imagedisp.elf: No such file or directory

C:\Documents and Settings\Zack1\Desktop\New Folder (3)>pause
Press any key to continue . . .


thats all the info I have....thanks alot

#14059 - poslundc - Sun Dec 28, 2003 6:00 pm

This line here indicates your problem:

Code:
junkie.h:13: syntax error before `~' token


This means you changed something in the junkie.h file and typed it incorrectly, and it will appear either on line 12 or line 13 or the file.

The problem may be the tilde (~) character itself. There is no conceivable reason you should be using a tilde in a header or data file, as it is the C bitflip operator and has no place in a file where there is no executable code (unless it is part of a macro definition, or a comment that wasn't properly commented).

If you can't figure out the problem from there, post your header file (or the first 15 lines of it if it is too large to post).

Dan.

#14060 - DDRfreak121 - Sun Dec 28, 2003 6:15 pm

Code:
// junkie.h
//   Converted by gfx2gba (v1.03, Nov 28 2001) - www.gbacode.net
//
// Original file   :  junkie.bmp, BMP (Windows or OS/2 Bitmap)
// Original size   :  240 x 160 pixels
// Output format   :  15 bit
// Converted on    :  Sun Dec 28 12:04:06 2003
//
// FreeImage image library (v2.4.2)
// FreeImage is an open source image library supporting all common
// bitmap formats. See http://www.6ixsoft.com for more details.

const u16 junkie[] =
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,


Where can i get dovotos image converter

#14063 - jenswa - Sun Dec 28, 2003 7:34 pm

Looks like the image you made is namend junkie and not junkieData as these lines are referring to:

Code:

imagedisp.cpp:32: `junkieData' undeclared

and
Code:

const u16 junkie[] = {image data}


so either you change junkie to junkieData or junkieData to junkie in your source code. The same goes for junkiePalette.

And that still leaves the tilde (~) character open ...
_________________
It seems this wasn't lost after all.

#14064 - DDRfreak121 - Sun Dec 28, 2003 7:46 pm

Thanks jenswa that was the problem

It spit out the elf file and I tryed to run it in VBA when

the screen went black


I think I do need the junkiePalette and junkieData

thats how it was dont in the tutorial and it worked fine...

Next to junkiePalette it says sest palette colros and there are no colors So I figured that was the problem