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.

C/C++ > Very stupid trouble

#8365 - XeroxBoy - Wed Jul 09, 2003 4:44 am

Previously, I've been including my external data through included .h files, and its worked fairly well. However, this generally isn't the best way to do things - recompilling takes forever. So, I've decided to switch over to GBFS, but I'm, unfortunately, having some difficulty getting it to work. I've packed my files together properly, as far as I can tell, and have appended them to my ROM. However, it doesn't seem to be working, and I'm fairly confident that it's because I'm making one or more stupid, stupid mistakes in my code. So, I'd really appreciate it if someone looked over my code and pointed out all of the flaws in it.

Code:

#define REG_DM3SAD     *(u32*)0x40000D4
#define REG_DM3DAD     *(u32*)0x40000D8
#define REG_DM3CNT_L   *(u16*)0x40000DC
#define REG_DM3CNT_H   *(u16*)0x40000DE

#define CharMem ((u16*)0x6010000)

const GBFS_FILE *dat = find_first_gbfs_file(find_first_gbfs_file);
const u8 *tileset = gbfs_get_obj(dat, "tileset.dat", NULL);


REG_DM3SAD = tileset;
REG_DM3DAD = tiles0;
REG_DM3CNT_L = 8192;
REG_DM3CNT_H |= 0x80000000;


Many thanks in advance!

#8366 - niltsair - Wed Jul 09, 2003 6:23 am

You're declaring a constant pointer to receive the value of what seems to be a function, not possible. And in your REG_DM3SAD [/b ] should receive a 32bits value that represent the address

Try this :
u32 tileset = gbfs_get_obj(dat, "tileset.dat", NULL);

Or if [b]gbfs_get_obj
is a define and not a function, then :
const u32 tileset = gbfs_get_obj(dat, "tileset.dat", NULL);

#8377 - tepples - Wed Jul 09, 2003 12:01 pm

niltsair wrote:
You're declaring a constant pointer to receive the value of what seems to be a function, not possible.

The gbfs_get_obj() does return a pointer to constant data, and the DMA source address register does take such a pointer.

What I'd like to know is whether find_first_gbfs_file() is returning a NULL pointer. If find_first_gbfs_file() returns a NULL pointer, then the appending probably went wrong somehow. Perhaps you didn't pad your program to a 256-byte boundary like the GBFS docs say.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#8412 - XeroxBoy - Wed Jul 09, 2003 9:00 pm

Yes! Thank you! That was the problem (along with a few goofy little bugs in the DMA code).