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.

Graphics > MapEd094 Examples, Anyone?

#10379 - goro - Wed Sep 03, 2003 5:13 pm

Hi,

Are there any code examples/tutorials that demonstrate exactly how the output files from MapEd094 are used?

It seems to output 5 files :-
Code:

mapheaders.h
palout.cpp
tilesout.cpp
mapout.cpp
collisionout.cpp



Please help me obi wan kenobi - you're my only hope

#10385 - jenswa - Wed Sep 03, 2003 7:40 pm

I don't know if there are any samples out, but did you take a look in those files?

They same to have logical names, mapheaders.h, this file must have some headers, like size and type of map.
And so on for the rest.
_________________
It seems this wasn't lost after all.

#10415 - goro - Thu Sep 04, 2003 11:46 am

It contains
Code:

//  File generated by: Map Ed v0.94 Lite

extern const u16 backgroundPalette[256];
extern const u16 bgTiles[816]; // num tiles: 51
extern const u16 BG_Layer0_map[1024]; // 32 x 32


I'm a newbie but I think these are external constant unsigned integer arrays. I think these will store the map, palette and tile data that will be transferred to vram and stuff.

But why are they in a seperate header file?
is it not enough to just have them in their respective output files ie:-

mapout.cpp contains
Code:
const u16 BG_Layer0_map[1024]ALIGN4 = {
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000 etc ect


Can anyone clarify?

#10426 - Nessie - Thu Sep 04, 2003 3:48 pm

MapEd currently spits out the different files for the way I personally like to have things organized.

An alternate solution, which may or may not be what you want, is that you could copy the arrays all to a single file (nothing wrong with that if that's how you'd like to do it ).

If you do this and keep the data arrays in a .c file, the part of the code that needs to access this data is going to need to know what the array names are, so that's where the header file comes in. Simply include the header file wherever your code needs to access one of these arrays and you are done.

Another solution is, copy the arrays to a single file and make that file a .h instead of a .c. In that case, you can discard the generated header file and just include the data array .h file you made in your code where you need to access the actual array data. I'd be careful with this though, because if you include the .h file you made from several .c files, you'll probably get duplicate data definition compile/link errors.

As you can see, many ways to shuffle it around for what you need. Furture versions of mapEd might be allow a bit more flexibility in generated files, but for now it isn't.

#10429 - goro - Thu Sep 04, 2003 5:04 pm

I think I'll adopt your way of doing things, MapEd is a great tool. Thanks for your reply and many thanks for creating MapEd.