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 > Having trouble with Visual HAM...(troubleshhoting)

#174694 - ericd3742 - Fri Jul 09, 2010 1:43 am

i am learning how to use HAM, and i have been trying to build the program on page 29 of [http://www.aaronrogers.com/ham/Books/PTGBA/GBA_05.pdf] and i cant find what i have done wrong! the HAM error thing at the bottom of the window says i have multiple errors. it says this:

/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:24: error: `REG_DISPCNT' undeclared (first use in this function)
main.c:24: error: (Each undeclared identifier is reported only once
main.c:24: error: for each function it appears in.)
main.c:28: error: `X' undeclared (first use in this function)
main.c:29: error: `mode3_Bitmap' undeclared (first use in this function)
make: *** [main.o] Error 1

my code looks like this:

#define MULTIBOOT int __gba_multiboot;
MULTIBOOT

//include files
#include <stdlib.h>
#include "mode3.raw.c"

void DrawPixel3(int, int, unsigned short);

#define RED_DISPCNT *(unsigned long*)0x4000000
#define MODE_3 0x3
#define BG2_ENABLE 0x400

#define SetMode(mode) REG_DISPCNT = (mode)

unsigned short* videoBuffer = (unsigned short*)0x6000000;

//function: main()

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]);

//loop
while(1)
{
}
return 0;
}


if anybody can tell me what ive done wrong it would be greatly appreciated.

#174695 - headspin - Fri Jul 09, 2010 2:29 am

Check the spelling of RED_DISPCNT (G not D) and remember that variables in C are case sensitive (you have an uppercase X < 240)
_________________
Warhawk DS | Manic Miner: The Lost Levels | The Detective Game

#174696 - ericd3742 - Fri Jul 09, 2010 3:02 am

headspin wrote:
Check the spelling of RED_DISPCNT (G not D) and remember that variables in C are case sensitive (you have an uppercase X < 240)


thanks, i guess my eyes dont notice spelling errors like yours do.

but, i still have errors:

/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:29: error: `mode3_Bitmap' undeclared (first use in this function)
main.c:29: error: (Each undeclared identifier is reported only once
main.c:29: error: for each function it appears in.)
make: *** [main.o] Error 1

my code now looks like this:

#define MULTIBOOT int __gba_multiboot;
MULTIBOOT

//include files
#include <stdlib.h>
#include "mode3.raw.c"

void DrawPixel3(int, int, unsigned short);

#define REG_DISPCNT *(unsigned long*)0x4000000
#define MODE_3 0x3
#define BG2_ENABLE 0x400

#define SetMode(mode) REG_DISPCNT = (mode)

unsigned short* videoBuffer = (unsigned short*)0x6000000;

//function: main()

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]);

//loop
while(1)
{
}
return 0;
}

#174720 - KayH - Sat Jul 10, 2010 10:34 am

In:
Code:

DrawPixel3(x, y, mode3_Bitmap[y * 240 + x]);

the mode3_Bitmap[] is an array representing your bitmap. This is (or have to) defined in the "mode3.raw.c" which you include some lines above.
Please have a look inside this generated file and check for the correct name of the array.

Please have also a look about good programming style, especially about including c-files.

hth
Kay