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.

Coding > Error

#5222 - Link - Wed Apr 23, 2003 1:29 pm

i get the follow error when i compile the .bin file:

test3.c: In function `main':
test3.c:19: `gbatestPalette' undeclared (first use in this function)
test3.c:19: (Each undeclared identifier is reported only once
test3.c:19: for each function it appears in.)
test3.c:22: `gbatest' undeclared (first use in this function)


the code is:

Code:

#include "gba.h"
#include "screenmodes.h"
#include "gbatest.h" //header file ottenuto da pcx2gba

u16* theVideoBuffer = (u16*)VideoBuffer;
u16* theScreenPalette = (u16*)BGPaletteMem;

 
#define RGB(r,g,b) (r+(g<<5)+(b<<10))                   //Macro to build a color from its parts

int main()

{
    SetMode(SCREENMODE4|BG2ENABLE);

    //Copy the palette
    u16 i;
    for ( i = 0; i < 256; i++ )
           theScreenPalette[ i ] = gbatestPalette[ i ];

    //Cast a 16 bit pointer to our data so we can read/write 16 bits at a time easily
    u16* tempData = (u16*)gbatest;

    //Write the data
    //Note we?re using 120 instead of 240 because we?re writing 16  bits
    //(2 colors) at a time.
    u16 x, y;
    for ( x = 0; x < 120; x++ )
        for ( y = 0; y < 160; y++ )
                theVideoBuffer[ y * 120 + x ] = tempData[ y * 120 + x ];

    return 0;

}

#5223 - Link - Wed Apr 23, 2003 1:41 pm

i've changed the previous code with this one:

Code:

#include "gba.h"
#include "screenmodes.h"
#include "test.h" //header file ottenuto da pcx2gba

u16* theVideoBuffer = (u16*)VideoBuffer;
u16* theScreenPalette = (u16*)BGPaletteMem;
[b]u16* gbatestPalette;
u16* gbatest;[/b]

 
#define RGB(r,g,b) (r+(g<<5)+(b<<10))                   //Macro to build a color from its parts

int main()

{
    SetMode(SCREENMODE4|BG2ENABLE);

    //Copy the palette
    u16 i;
    for ( i = 0; i < 256; i++ )
           theScreenPalette[ i ] = gbatestPalette[ i ];

    //Cast a 16 bit pointer to our data so we can read/write 16 bits at a time easily
    u16* tempData = (u16*)gbatest;

    //Write the data
    //Note we?re using 120 instead of 240 because we?re writing 16  bits
    //(2 colors) at a time.
    u16 x, y;
    for ( x = 0; x < 120; x++ )
        for ( y = 0; y < 160; y++ )
                theVideoBuffer[ y * 120 + x ] = tempData[ y * 120 + x ];

    return 0;

}


now it work and i get .bin file, but i can see when i run with the emulator only a bitmap blue and blue light, blue and blue light... not my drawn .pcx image converted in .h file.
why can i see the image correctly?

#5224 - Link - Wed Apr 23, 2003 1:56 pm

i use this command in gfx2gba:

gfx2gba test.pcx test.h [-15]

or

gfx2gba test.png test.h [-15]

is it correct??

test.png is a 24 bit image, i use Firework how graphics program and the only possibility of export image is BMP at 8-24 bit PNG 8-24-32 Jpg and Gif at 2-8-16-256 colors

#5226 - niltsair - Wed Apr 23, 2003 2:32 pm

How can you want to develop a game when you've got so much to still learn?

You should focus on :
1- Honing your programming skills.
2- Do some demos/App/Games on the gba.

Then you might think about forming a team a create your own game. I doubt a 1 man team could produce a GoldenSun quality game elsewise.

-----------------------

For your problem, you picked mode4 which support256 paletted colors only (with front and back buffer).

You need to either need to use mode3 or export in 256 colors your data and the palette and then transfer your picture and palette in video memory.

#5227 - Quirky - Wed Apr 23, 2003 2:51 pm

Link, have you read the Beginners FAQ? It has a lot of this sort of thing covered.

#5254 - Link - Wed Apr 23, 2003 8:41 pm

yes but i think that at the plase of speak behind back, speak and speak you give some suggestion i shall think a lot of more!

for 256 colors image bitmap what of these i must choose?:

-15 15 bit, convert to 15 bit BGR format, default
-8 8 bit, convert to 8 bit format
-v verbose
-w n width, number of entries of data array per line, default = 8
-s n size, size in bytes of each entry, must be 1, 2 or 4, default = 1
-n name name, C variable name
-c C types, use standard C types instead of common GBA types
-t type type, type of data array, default depends on the following:
-s 1 => u8; with -c => unsigned char
-s 2 => u16; with -c => unsigned short int
-s 4 => u32; with -c => unsigned int
-r RGB cube, create standardized RGB cube 8 bit palette, default
-o optimal, create optimal 8 bit palette
-k no const, do not use the const modifier for type of data array
-z n sprite, output in GBA sprite/tile format
-z 256 => 256 colors x 1 palette, default
-q type quantizer, specify quantizer to create optimal 8 bit palette
-q wu => Wu's quantizer, default
-q nn => neural net quantizer
-b binary, write image data out to a binary file
-p file palette, write palette data out to a binary file
-m merge, merge palette data, use with -p option

#5259 - Link - Wed Apr 23, 2003 10:39 pm

i proved in 1000 others modes lso -8 with more images but i get always the same blue screen! Why??

#5282 - Link - Thu Apr 24, 2003 2:35 pm

what i wrong?? Please suggest me! ;)

#5283 - niltsair - Thu Apr 24, 2003 2:59 pm

There are more 'grapgical program' to convert data that could help you. Like Bmp2Gba i think. Check it under the tools section of www.gbadev.org.

As for your option, it would be -z. Check if this also yield you the palette array, else try adding -p.

#5286 - peebrain - Thu Apr 24, 2003 4:20 pm

Someone needs to ban Link... this kid is clueless.

~Sean
_________________
http://www.pbwhere.com

#5292 - Daikath - Thu Apr 24, 2003 5:44 pm

Link,

I am not saying other stuff but I do sugest that you learn how to program first.

I myself am not a perfect programmer but I dont ask everyone how to fix something. Yes it does take longer but I'm less of a bother in the proccess.

It comes accros to me as though you lack the persiverance to find things out for yourself. I do not know shit by far but I use www.gbadev.org and links from other poeple to find out instead of asking them how to do it exactly.
_________________
?There are no stupid questions but there are a LOT of inquisitive idiots.?

#5300 - jenswa - Thu Apr 24, 2003 8:14 pm

Some suggestions, they have a newbie forum, try some questions over there.
And the second, gather some info about the different screenmodes to start with.

I use pcx2gba (for 256 colour pcx files) and it works just fine.
So perhaps try that (oh yeah, use mode 4 for 256 colour bitmapped images).
_________________
It seems this wasn't lost after all.

#5305 - Link - Thu Apr 24, 2003 11:32 pm

i thanks niltsair and jenswa, i think they are some people really clever... i haven't words for the others!
Maybe only one:

If you think my questions very bothersome or stupid you are free do not answare, if you do it but telling no sense words i think you are really only a ignorant!
Even the BAN???

but what does happen to you? Do you not be able to shit the morning??

#5323 - Maddox - Fri Apr 25, 2003 7:38 am

Also, people, we can write our own tools, y'know. It is EASY to make a bitmap reader.

Programming. That's what we do.

MADDOX RULES!

-Maddox
_________________
You probably suck. I hope you're is not a game programmer.

#5325 - sgeos - Fri Apr 25, 2003 7:48 am

Maddox wrote:
Also, people, we can write our own tools, y'know. It is EASY to make a bitmap reader.

Programming. That's what we do.


That sounds like a good plan. What is the general format of a bmp file?

-Brendan

#5327 - funkeejeffou - Fri Apr 25, 2003 9:04 am

You should take a look at your "gbatest.h" file...
Open it with any editor and check if it looks like :
unsigned short int gbatestPalette[256] ={..................}
or
u16 gbatestPalette = {......................}

the only problem seems to be that your are not using the right name of the palette variable.
Hope this helps

#5329 - joet - Fri Apr 25, 2003 9:43 am

Have a look at:

http://www.wotsit.org/

loads of file formats here

(in reply to someone asking for the format for a BMP file)

#5335 - niltsair - Fri Apr 25, 2003 2:40 pm

I'm currently in the process of creating a Pc Editor for a Slide program that runs on the Gba.

For this i need to open any type of picture and export it in raw data.

I didn't want to learn every picture format. After a period of time messing around, a friend told me about the SDL librairie which does exactly what i wanted. It decode any kind of picture and i only need to convert the data to a 15bits picture afterward. (I had to pick a Add-On module to Sdl for picture loading).

So if some of you also end up wanting to convert picutre, give it a try.

#5378 - Link - Sat Apr 26, 2003 10:09 am

funkeejeffou wrote:
You should take a look at your "gbatest.h" file...
Open it with any editor and check if it looks like :
unsigned short int gbatestPalette[256] ={..................}
or
u16 gbatestPalette = {......................}

the only problem seems to be that your are not using the right name of the palette variable.
Hope this helps


this is my .c file:
Code:

#include "gba.h"
#include "screenmodes.h"
#include "hprova.h" //header file ottenuto da gfx2gba

u16* theVideoBuffer = (u16*)VideoBuffer;
u16* theScreenPalette = (u16*)BGPaletteMem;
u16* gbatestPalette[256];
u16* gbatest[256];

 
#define RGB(r,g,b) (r+(g<<5)+(b<<10))                   //Macro to build a color from its parts

int main()

{
    SetMode(SCREENMODE4|BG2ENABLE);

    //Copy the palette
    u16 i;
    for ( i = 0; i < 256; i++ )
           theScreenPalette[ i ] = gbatestPalette[ i ];

    //Cast a 16 bit pointer to our data so we can read/write 16 bits at a time easily
    u16* tempData = (u16*)gbatest;

    //Write the data
    //Note we?re using 120 instead of 240 because we?re writing 16  bits
    //(2 colors) at a time.
    u16 x, y;
    for ( x = 0; x < 120; x++ )
        for ( y = 0; y < 160; y++ )
                theVideoBuffer[ y * 120 + x ] = tempData[ y * 120 + x ];

    return 0;

}


Instead this is the .h (image) code:
Code:

// hprova.h
//   Converted by gfx2gba (v1.03, Nov 28 2001) - www.gbacode.net
//
// Original file   :  tst.bmp, BMP (Windows or OS/2 Bitmap)
// Original size   :  240 x 160 pixels
// Output format   :  256 color sprite
// Converted on    :  Sat Apr 26 01:07:41 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 u8 tst[] =
{ 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
  0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
  0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
  0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
  0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
  0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
  0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
  0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
  0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
  0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
  0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
  0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
  0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
  0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
  0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
  0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
  0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
  0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
  0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
  0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
  0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
  0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
  0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
  0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
  0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
  0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
  0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
  0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
  0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
  0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
  0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
  0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
  0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
  0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
  0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
  0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
  0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
  0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
  0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
  0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
  0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
  0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
  0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
  0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
  0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
  0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
  0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
  0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
  0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
  0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
  0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
  0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
  0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
  0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
  0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
  0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
  0xef, 0xef, 0xef, 0xef, 0x82, 0x82, 0x82, 0x82,
  0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0xbd,
  0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82,

.......

  0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
  0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
  0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
  0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07 };

const u16 tstPalette[] =
{ 0x0c45, 0x6b9b, 0x39ed, 0x254a,
  0x4e31, 0x084c, 0x2d8b, 0x7fff,
  0x20e8, 0x14ec, 0x4214, 0x5ad6,
  0x1909, 0x2d8f, 0x10ad, 0x18c6,

........
  0x1d09, 0x5294, 0x31ae, 0x5ad9,
  0x18d3, 0x0c6d, 0x73dc, 0x5276 };


furthermore can you explain me the meanng of (for example) 0x07 and 0x0c45 ??
Tnx very much!

#5381 - Link - Sat Apr 26, 2003 1:05 pm

must i declare gbatestPalette and gbatest??

#5382 - Link - Sat Apr 26, 2003 1:43 pm

Finally i've find the error!
:)

#5464 - regularkid - Mon Apr 28, 2003 9:58 pm

Quote:

yes but i think that at the plase of speak behind back, speak and speak you give some suggestion i shall think a lot of more!


Quote:

but what does happen to you? Do you not be able to shit the morning??


HAHAHAHAHA! Those are some of the funniest things I've ever read. What exactly do they mean.....the world may never know. :)

I've read some of Link's posts and can honestly say I only understand about 1/2 of what he says. No offense, Link, but you need to work on English as well as your programming skills.

Seriously, dude, just get a beginners programming book and quit wasting everyone's time here in the forum. Just my 2 cents.
_________________
- RegularKid

#5465 - Link - Mon Apr 28, 2003 10:58 pm

regularkid wrote:
Quote:

yes but i think that at the plase of speak behind back, speak and speak you give some suggestion i shall think a lot of more!


Quote:

but what does happen to you? Do you not be able to shit the morning??


HAHAHAHAHA! Those are some of the funniest things I've ever read. What exactly do they mean.....the world may never know. :)

I've read some of Link's posts and can honestly say I only understand about 1/2 of what he says. No offense, Link, but you need to work on English as well as your programming skills.

Seriously, dude, just get a beginners programming book and quit wasting everyone's time here in the forum. Just my 2 cents.



ok i know 1/2 of english, but you, what do u know? Do u know 1/2 of italian??
No!!!
Seriously dude go to buy a good book of good manners!

#5467 - regularkid - Mon Apr 28, 2003 11:07 pm

Why would I want to know 1/2 of italian? I live in America; we speak English here. :)
_________________
- RegularKid

#5472 - excessus - Tue Apr 29, 2003 7:32 am

(N)etiquettes, ie manners, things so many have forgotten today. I personally don't know which is more annoying the obwious newbie questions or the stupid answers to those. I'd like to point out that no matter how silly these questions are these will be some reference to someone who searches the news database so you could try to keep this formal. Besides if you don't want Link continues posting here you can simply stop answering his questions because as long as his posts are replied he will continue sending his questions. And the matter of english here: Link could spend extra 10 minutes checking the if the senteces actually make some sense in english to get sane response. As much as I would love to learn italian your english doesn't help that at all. Also consider that you would really try to learn what people here are saying to you and read those tutorials people have given you so many times.
_________________
Current binary for my pinball game demo:
www.lut.fi/~rusakko/gba/flibu.gba

#5475 - Link - Tue Apr 29, 2003 11:30 am

excessus wrote:
(N)etiquettes, ie manners, things so many have forgotten today. I personally don't know which is more annoying the obwious newbie questions or the stupid answers to those. I'd like to point out that no matter how silly these questions are these will be some reference to someone who searches the news database so you could try to keep this formal. Besides if you don't want Link continues posting here you can simply stop answering his questions because as long as his posts are replied he will continue sending his questions. And the matter of english here: Link could spend extra 10 minutes checking the if the senteces actually make some sense in english to get sane response. As much as I would love to learn italian your english doesn't help that at all. Also consider that you would really try to learn what people here are saying to you and read those tutorials people have given you so many times.


Tnx excessus!