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 + EMapper2 Advance

#4653 - Burre - Sun Apr 06, 2003 12:06 pm

Hi there...

I recently bought EMapper2 Advance to solve my mapping issues, but I can't seem to get them to work properly with each other. The E2A (Emapper2 Advance) is a licenced version and HAM isn't.

I've successfully built an map, based on an imported BMP tileset and manage to export both to C-code. I have then included the header files in my project and also included the C-files (containing map and tiles) into the compiler chain. So far so good. But when I run my code (using VBA), the tileset looks scrambled. I think that the map loads up fine, but the tilset looks scrambled (both by looking at the game and looking in the tile-viewer included in VBA). The pallette is fine, but is seems that HAM loads the tileset with wrong offset or something. I've noticed that gfx2gba exports to an array of 'const unsigned char' while E2A exports to 'const unsigned short', would that make any difference? Exporting the tilset with gfx2gba doesn't work either.

The code I use for loading maps and tiles are as follows:
Code:

ham_LoadBGPal((void*)bgmaster_Palette,256); // Background palette
ham_bg[0].ti = ham_InitTileSet((void*)&tiles0,SIZEOF_16BIT(&tiles0),1,1); // Load tileset
ham_bg[0].mi = ham_InitMapEmptySet(3,0); // Make room for the map
bg_game_ptr = ham_InitMapFragment((void*)&map0,40,30,0,0,32,22,0); // Load the map fragment
ham_InsertMapFragment(bg_game_ptr,0,0,0); // Put fragment on BG
ham_InitBg(0,1,0,0);   // Display the background


I think that is about all code I use for loading and displaying my map (if I haven't forgotten any). I use C++ (wich would explain all explicit typeconversions).

Any ideas why it won't work? I bet it's a simple nut to crack but I'm out of ideas and one can get quite blind reading it's own code over and over...

Any and all help appreciated! :)
_________________
"The best optimizer is between your ears..."

#4655 - Saj - Sun Apr 06, 2003 1:39 pm

Hi Burre,

Have you tried saving the file as a BMP in Emapper and then converting it using gfx2gba? the purpose of this would be to see if you get the same output. Then you'd know for sure that this is a HAM issue.

Also Check out : http://www.aaronrogers.com/ham/Day6/day6.php

Also I sent you a pm regarding something else. pm me when you've checked it.
_________________
---------------------------------------------------
Click here to give free food to starving animals.
--------------------------------------------------

#4656 - niltsair - Sun Apr 06, 2003 1:42 pm

I never used Ham, making it hard for me to tell, but one thing you should check is:
-Are you loading your tiles in Bank 0 while also loading your maps in Screen Data 0?
If you do, this means that 32x(NumberofMap Loaded) worth of tiles are overwritten with junk data, since they both share the same memory.

A common use is to load your tiles at Bank 0, Tile 0 and up and load your maps from Screen Map 31 and down. So for each Map put in memory, you lose 32 tiles toward the end of memory.

#4707 - tutifruti - Mon Apr 07, 2003 1:03 pm

Hi!

Try with something like this:

Code:

    ham_Init();
    ham_SetBgMode(0);

    ham_LoadBGPal((void *)tilesPal,256);
    ham_bg[0].ti=ham_InitTileEmptySet(480,1,1);
    ham_bg[0].mi=ham_InitMapEmptySet(0,0);
   
      TOOL_DMA3_SET(tiles0,MEM_BG_PTR,tilesCount0*32,DMA_TRANSFER_16BIT,DMA_STARTAT_NOW)

    map_fragment=ham_InitMapFragment((void*)map0,mapWidth0,mapHeight0,0,0,32,22,0);
    ham_InsertMapFragment(map_fragment,0,0,0);
    ham_InitBg(0,1,0,0);

#4709 - Burre - Mon Apr 07, 2003 4:41 pm

tutifruti wrote:
Hi!

Try with something like this:

Code:

    ham_Init();
    ham_SetBgMode(0);

    ham_LoadBGPal((void *)tilesPal,256);
    ham_bg[0].ti=ham_InitTileEmptySet(480,1,1);
    ham_bg[0].mi=ham_InitMapEmptySet(0,0);
   
      TOOL_DMA3_SET(tiles0,MEM_BG_PTR,tilesCount0*32,DMA_TRANSFER_16BIT,DMA_STARTAT_NOW)

    map_fragment=ham_InitMapFragment((void*)map0,mapWidth0,mapHeight0,0,0,32,22,0);
    ham_InsertMapFragment(map_fragment,0,0,0);
    ham_InitBg(0,1,0,0);


WOW! That finally did it! Thanks a bundle!

Now for the runner up question, what went wrong in the first place? I can't recall that I ever needed to manually DMA my tiledata before.
_________________
"The best optimizer is between your ears..."

#4848 - tutifruti - Sat Apr 12, 2003 9:59 am

Well, VRAM is 16 bits, Video Bus is 16 bits, and DMA is faster than CPU to transfer data, so I don't know why HAM uses 8 bits tile sets to transfer it with CPU...