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 > Garbled mess...

#46479 - GarrettVD - Sat Jun 25, 2005 8:28 pm

I just started to learn how to develop for the GBA the other day, and I am having a spot of trouble on getting my map to show up. I am experimenting with the code from Ch. 6a of the GBAJunkie tutorials, about setting up a background. I tried to input my own BG that I made in Map Ed v0.98.5, but I am having some trouble getting it to display. What I get is a garbled mess of random tiles. Most of which I am sure aren't even on the tilemap itself. I've included code, and at the moment I am pretty much stumped. Any help would be great. Thanks.

Files: http://emw.onewinged.org/garbledmess.zip

#46555 - Cearn - Mon Jun 27, 2005 9:30 am

The main reason it looks garbled is that the exported map uses 16colors, while the background is set up for 256. Changing that will show recognizable tiles, but even then there seems to be something funny with the palettes.

If you're wondering why it takes a while before anything shows up, it's busy filling the SIN/COS tables. Do not use floating point unless you absolutely have to, and even then its often possible to fake them using fixed point. Something similar goes for variables and array-types/casts: the GBA is a 32bit machine, int/u32 can work twice as fast as u16.

#46560 - tepples - Mon Jun 27, 2005 1:02 pm

In general, the sin/cos tables are best done at compile time. Use a PC based program to create fixed-point sin/cos tables and write them to a .c file, then compile that .c file into your GBA project.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#46598 - GarrettVD - Mon Jun 27, 2005 9:52 pm

Cearn wrote:
The main reason it looks garbled is that the exported map uses 16colors, while the background is set up for 256. Changing that will show recognizable tiles, but even then there seems to be something funny with the palettes.

If you're wondering why it takes a while before anything shows up, it's busy filling the SIN/COS tables. Do not use floating point unless you absolutely have to, and even then its often possible to fake them using fixed point. Something similar goes for variables and array-types/casts: the GBA is a 32bit machine, int/u32 can work twice as fast as u16.


I took out the whole SIN/COS thing. I really don't need rotating backgrounds etc. at this point in time. I just made a new map in MapEd, exported it, and got the three files (palette, tiles, and map). I changed the colour from 256 to 16, and you are right, I do see some recognizable tiles, but the palette or tile files must be screwed up somehow. Why is this? And is there another way to generate a tile or palette file? (Depending on whichever is screwed up). Thanks for your help this far guys.

#46830 - GarrettVD - Fri Jul 01, 2005 4:46 am

...Anyone???

#46848 - poslundc - Fri Jul 01, 2005 6:29 am

Use the various debugging tools in GBA (tile viewer, etc.) to see if the contents of VRAM match what you expect them to be. Other than that, I've not used MapEd so I can't comment on what it outputs.

Dan.

#46884 - GarrettVD - Fri Jul 01, 2005 7:18 pm

There are debugging tools in the GBA itself? Oh boy I feel stupid, I never knew :p How do you access them?

EDIT: Now that I come to think of it, I want to know what tools everyone else uses to make maps, and convert tiles into .cpp/.h files etc. Any recommendations? MapEd isn't working out for me as I thought it would.

#46891 - poslundc - Fri Jul 01, 2005 8:46 pm

Sorry, I meant VBA, not GBA.

Dan.

#46968 - GarrettVD - Sat Jul 02, 2005 8:00 pm

Yeah, I've narrowed it down to just my tiles being screwed... I don't know why. I converted the BMP to palette/raw data in GFX2GBA, so it should technically work fine...

#46984 - LOst? - Sun Jul 03, 2005 3:15 am

GarrettVD, the problem with MapEd and other tools are that they forget to add const in front of the arrays.

Always add const in front of the palette, map, and tile data, as well as the pre-calced sine tables.

Example:
Code:

const u16 array_in_rom [size] = {0, 0, 0};


const will store the data in ROM space and not in RAM. GBA has very limited RAM size. Adding const will also fix the garbled mess.