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 > problems with maps

#10931 - mandarin - Sat Sep 20, 2003 9:29 pm

Hi everyone,

I'm really having trouble with maps, I just can't get any maps to work properly I have tried 3 seperate sets of code to draw a map on screen from downtou.cjb.net 's tutorials and gbajunkie's tutorials but for some reason it doesn't work i have a really good hunch it is the map editor or tile converter or some other prob, beacause when I use the converted .h files from gbajunkies tutorial in all the code I have used above for my mapand it worked fine, but it might be the tiles to I was just wondering I have been testing it out with gif2sprites,gfx2gba,pcx2sprites,pcx2gba,bmp2sprites and so far no luck with any of their .h files.
My map editors I have tried is tume,time,map editor beta v4.

I just want to highlight if this is some use...my tiles are 16x16 pixels and the full tileset is 256x96 pixels.

Anyone know whats wrong plz help.

Yours truly,

Mandarin

#10932 - yaustar - Sat Sep 20, 2003 9:52 pm

have you just tried using gbajunkie's code and just change the tilesets and map headers to see it works?

He uses mapedit beta by warder1 and pcx->sprite/pcx->gba

also are you in the right mode? and using the right background

If Possible, post some code up
_________________
[Blog] [Portfolio]

#10933 - mandarin - Sat Sep 20, 2003 9:56 pm

i used my headers in the exact same code of his that comes out of the tutorials except I changed the dimensions in the loops to suite the tiles needs and the maps needs and yeah I use the same map editor as he does.

any idea what the prob could be?

#10934 - yaustar - Sat Sep 20, 2003 9:59 pm

what is the output screen?
I remeber I had a similar problem as well because I was working out the difference the backgrounds.

btw it's pcx->sprite
_________________
[Blog] [Portfolio]

#10935 - mandarin - Sat Sep 20, 2003 10:03 pm

i have many different results, first with downtou's code i get half of the map kind jumbled up in gbajunkie's code i get a mixture of tiles which i didn't even have in the original map and I tried changing his code but all i got was a screen filled with one particualar color.so i'm kinda confused by the whole thing.

#10936 - yaustar - Sat Sep 20, 2003 10:05 pm

again code would be nice pref the

int main (){}

I think it could be due to the modes that you are using.
_________________
[Blog] [Portfolio]

#10937 - mandarin - Sat Sep 20, 2003 10:10 pm

Code:

int main()
{
   int index = 0;  //generic loop variables
   u16 loop;
   u16* temp;      //temporary storage pointer

   //compute my Look up tables (Rotation stuff again)
   for(loop = 0; loop < 360; loop++)
   {
      SIN[loop] = (FIXED)(sin(RADIAN(loop)) * 256);  //sin and cos are computed and cast to fixed                     //fixed
      COS[loop] = (FIXED)(cos(RADIAN(loop)) * 256);
   }

   //set mode 2 and enable sprites and 1d mapping
   SetMode(MODE_1 | OBJ_ENABLE | OBJ_MAP_1D);

   //Let us set up the backgroud two structure and enable the background

   bg2.number = 2;            //background number 0-3
   bg2.charBaseBlock = 0;                  //tile data position (right at the start of the available memory on 16Kb boundary)
   bg2.screenBaseBlock = 28;      //map data position on 2Kb boundary
   bg2.colorMode = BG_COLOR_256;           //256-colour background
   bg2.size = ROTBG_SIZE_128x128;          //size of map
   bg2.mosaic = 0;                         //not enabled
   bg2.x_scroll = 120;         //scrolling variables
   bg2.y_scroll = 80;

   //Point to correct tile and map data, update the Background and Display registers accordingly
        EnableBackground(&bg2);



   for(loop = 0; loop < 256; loop++)
      BGPaletteMem[loop] = TILESPalette[loop];     //load the background palette into memory

   for(loop = 0; loop < exptiles_WIDTH * exptiles_HEIGHT /2; loop++)  //load tile image data
      bg2.tileData[loop] = TILESData[loop];

   //load the map image data
   temp = (u16*)map;
   for(loop = 0; loop < 16*16/2; loop++) //16x16 tiles /2 because 16 bit copy
      bg2.mapData[loop] = temp[loop];

   //Main Game loop
   while(1)
   {
      GetInput();    //check for input
      RotateBackground(&bg2,angle,119,79,zoom);    //rotates background if required (don't worry about this)
      WaitForVsync();               //waits for the screen to stop drawing
      UpdateBackground(&bg2); //make sure registers are updated if anything changes e.g. scrolling
   }
   return(0);
}




thats gbajunie's


Code:
void MakeBKG()
{
u16 loop,x,y;
for(loop = 0; loop < 256; loop++)
BGPaletteMem[loop] = TILESPalette[loop];
for(loop = 0; loop < TILES_WIDTH*TILES_HEIGHT/2; loop++)
BGTileMem[loop] = TILESData[loop];
for(loop = 0; loop < 64*64; loop++)
VideoBuffer[loop] = map[loop];
}



int main()
{
REG_BG0CNT = CHAR_BASE(1) | BG_MOSAIC_ENABLE | BG_COLOR_256;
SetMode(MODE_1 | OBJ_ENABLE | BG0_ENABLE | OBJ_MAP_1D);


MakeBKG();
while (1)
{GetInput();
REG_BG0HOFS = x;
REG_BG0VOFS = y;
WaitForVsync();

}
}


thats what i got from downtou

any ideas?

#10938 - yaustar - Sat Sep 20, 2003 10:15 pm

what is the size of the map?
_________________
[Blog] [Portfolio]

#10939 - mandarin - Sat Sep 20, 2003 10:19 pm

i have tried many different dimensions for the map i have tried the following

128x128
256x256
512x512

#10940 - yaustar - Sat Sep 20, 2003 10:19 pm

second thought, e-mail the entire gbajunkie's based code to me yaustar_8p@NOSPAMyahoo.co.uk (remove NOSPAM)
_________________
[Blog] [Portfolio]

#10941 - mandarin - Sat Sep 20, 2003 10:21 pm

yeah sure,but do u think you have an idea of what could be wrong?

#10942 - yaustar - Sat Sep 20, 2003 10:23 pm

I have a minor idea, but this I dont have to keep asking questions about the code and just give a solution.
_________________
[Blog] [Portfolio]

#10943 - mandarin - Sat Sep 20, 2003 10:39 pm

listen i'm gonna upload it to my site then u can download it from there coz my email server is down at the moment is that ok?

#10944 - yaustar - Sat Sep 20, 2003 10:41 pm

sure, no problem..
_________________
[Blog] [Portfolio]

#10945 - mandarin - Sat Sep 20, 2003 10:48 pm

http://galileo.spaceports.com/~mandarin/project.zip


thats the url....plz respond in this topic once you found out whats wrong

#10947 - yaustar - Sat Sep 20, 2003 11:06 pm

At the moment I acnt get the thing compling, it doesnt radian..
_________________
[Blog] [Portfolio]

#10948 - yaustar - Sat Sep 20, 2003 11:34 pm

found the problem map.c should be

Code:
const u8 map[ 16 * 16 ] = {
0x06,0x07,0x08,0x09,0x0A,0x0B,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x12,0x13,0x14,0x15,0x16,0x17,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x1E,0x1F,0x20,0x21,0x22,0x23,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x2A,0x2B,0x2C,0x2D,0x2E,0x2F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x07,0x08,0x09,0x0A,0x0B,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x12,0x13,0x14,0x15,0x16,0x17,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0x1F,0x20,0x21,0x22,0x23,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x04,0x05,0x04,0x05,0x04,0x05,0x04,0x05,0x04,0x05,0x04,0x05,0x04,0x05,0x04,0x05,
0x10,0x11,0x10,0x11,0x10,0x11,0x10,0x11,0x10,0x11,0x10,0x11,0x10,0x11,0x10,0x11,
0x04,0x05,0x04,0x05,0x04,0x05,0x04,0x05,0x04,0x05,0x04,0x05,0x04,0x05,0x04,0x05,
0x10,0x11,0x10,0x11,0x10,0x11,0x10,0x11,0x10,0x11,0x10,0x11,0x10,0x11,0x10,0x11,
0x04,0x05,0x04,0x05,0x04,0x05,0x04,0x05,0x04,0x05,0x04,0x05,0x04,0x05,0x04,0x05,
0x10,0x11,0x10,0x11,0x10,0x11,0x10,0x11,0x10,0x11,0x10,0x11,0x10,0x11,0x10,0x11,

};


Using MapEditBetav4, you need to export TWICE to get the full array. (falut in progam) It was mention in gbajunkies tutorial
_________________
[Blog] [Portfolio]

#10968 - goro - Mon Sep 22, 2003 7:37 am

That program is buggy.

You should use MapEd096 by Nessie.

#10971 - yaustar - Mon Sep 22, 2003 11:39 am

maped took some time getting use to, but yes, it's better then mapeditbeta IMO.
_________________
[Blog] [Portfolio]