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 > Ham problem.... But why?

#25371 - Fatnickc - Sat Aug 21, 2004 5:41 pm

Whenever I compile This part of code in Vham, something happens:
Code:
DrawPixel3(x, y, mode3_Bitmap[y * 240 + x]);

When compiling (The whole file, not the line on its own)
It outputs this:
Code:
/gcc-arm/bin/arm-thumb-elf-as.exe -mthumb-interwork  /system/crt0.s -ocrt0.o
/gcc-arm/bin/arm-thumb-elf-gcc.exe  -I /gcc-arm/include -I /gcc-arm/arm-thumb-elf/include -I /include -I /system  -c -DHAM_HAM  -DHAM_MULTIBOOT  -DHAM_ENABLE_MBV2LIB -O2 -DHAM_WITH_LIBHAM  -mthumb-interwork -mlong-calls -Wall -save-temps -fverbose-asm -nostartfiles main.c -o main.o
main.c: In function `main':
main.c:27: error: `mode3_Bitmap' undeclared (first use in this function)
main.c:27: error: (Each undeclared identifier is reported only once
main.c:27: error: for each function it appears in.)
make: *** [main.o] Error 1

Any ideas what the problem causng it is?
The whole file (From J Harbour's eBook) is:
Code:
#define MULTIBOOT int __gba_multiboot;
MULTIBOOT
//include files
#include <stdlib.h>
#include "C:\vham\gfx\bg.raw.c"
//declare the function prototype
void DrawPixel3(int, int, unsigned short);
//declare some defines for the video mode
#define REG_DISPCNT *(unsigned long*)0x4000000
#define MODE_3 0x3
#define BG2_ENABLE 0x400
//changes the video mode
#define SetMode(mode) REG_DISPCNT = (mode)
//create a pointer to the video buffer
unsigned short* videoBuffer = (unsigned short*)0x6000000;
/////////////////////////////////////////////////////////////
// Function: main()
// Entry point for the program
/////////////////////////////////////////////////////////////
int main(void)
{
int x, y;
SetMode(MODE_3 | BG2_ENABLE);
//display the bitmap
for(y = 0; y < 160; y++)
for(x = 0; x < 240; x++)
DrawPixel3(x, y, mode3_Bitmap[y * 240 + x]);
//endless loop
while(1)
{
}
return 0;
}
void DrawPixel3(int x, int y, unsigned short c)
{
videoBuffer[y * 240 + x] = c;
}

Thanks in advance,
Fatnickc.

#25375 - tepples - Sat Aug 21, 2004 5:54 pm

Fatnickc wrote:

Code:
main.c: In function `main':
main.c:27: error: `mode3_Bitmap' undeclared (first use in this function)
main.c:27: error: (Each undeclared identifier is reported only once
main.c:27: error: for each function it appears in.)
make: *** [main.o] Error 1

Any ideas what the problem causng it is?
The whole file (From J Harbour's eBook) is:
Code:
#define MULTIBOOT int __gba_multiboot;
MULTIBOOT
//include files
#include <stdlib.h>
#include "C:\vham\gfx\bg.raw.c"
// SNIP
int main(void)
{
int x, y;
SetMode(MODE_3 | BG2_ENABLE);
//display the bitmap
for(y = 0; y < 160; y++)
for(x = 0; x < 240; x++)
DrawPixel3(x, y, mode3_Bitmap[y * 240 + x]);
//endless loop
while(1)
{
}
return 0;
}
void DrawPixel3(int x, int y, unsigned short c)
{
videoBuffer[y * 240 + x] = c;
}

Where in your code do you define mode3_Bitmap[]?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#25378 - Fatnickc - Sat Aug 21, 2004 7:01 pm

How exactly would you reccomend I did declare it? Obviously
Code:
#define mode3_Bitmap[]
alone wouldn't do it.

#25379 - CATS - Sat Aug 21, 2004 7:04 pm

buy a book on C/C++, seriously

#25380 - Fatnickc - Sat Aug 21, 2004 7:06 pm

Jeez... But, i just can't remember how to do this one bit, I mean i can code (nearly..) complete games.
Just what to do for the #define.......

#25385 - jenswa - Sat Aug 21, 2004 10:06 pm

mode3_Bitmap[]

I think it's an arry of data from the bitmap you want to display.
And in your case it's missing (or not properly linked).
_________________
It seems this wasn't lost after all.

#25401 - tepples - Sun Aug 22, 2004 1:09 am

What are the first few lines of C:\vham\gfx\bg.raw.c ?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#25435 - Fatnickc - Sun Aug 22, 2004 9:35 pm

I'll just give the whole file, it isn't that long (weird?)
Code:
const unsigned short bg_Palette[256]={
0x0000, 0x0200, 0x63b9, 0x7b34, 0x7fff, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000
};

#25440 - dagamer34 - Mon Aug 23, 2004 12:20 am

Why are you using absolute paths to include data? It will become a real headache if you ever have to move your project/resources.

And you gave us the wrong file. That is bg.pal.c. We need to see bg.raw.c. And I'm also going out on a limb and guessing that you have never opened bg.raw.c, in any case, there really isn't any "mode3_bitmap" because you called it something else. Just open that file and you'll see what I'm talking about.

Maybe you copy and pasted code from a tutorial and forgot to change the name of the data?
_________________
Little kids and Playstation 2's don't mix. :(