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 > Tiles dissapear after going below 0?

#110912 - lostgame - Sat Dec 02, 2006 8:23 pm

I created a simple scrolling platformer, and I find the tiles dissapear after going below 0.

What's wrong here?

#110914 - QuantumDoja - Sat Dec 02, 2006 8:33 pm

How do you mean go below 0??

What/how are you loading data into memory?
_________________
Chris Davis

#110915 - lostgame - Sat Dec 02, 2006 8:47 pm

They're going below 0 on the x or y axis, and they just suddenly dissapear.

And I'm loading data into the memory with the regular data types. The x and y for the sprites are held this way:

Code:
   /* block sprites */
   for (n=1; n<=numblocks; n++)
   {
      sprites[n].attribute0 = COLOR_256 | SQUARE | blocky[n-1];
      sprites[n].attribute1 = SIZE_8 | blockx[n-1];
      sprites[n].attribute2 = 512+16;
   } //end for


blockx and blocky are u32 data types.

#110918 - QuantumDoja - Sat Dec 02, 2006 8:59 pm

what is numblocks?

also what is blocky[] <- is this an array containing int's??

maybe also change the code to this....(i always get in a mess when starting from 1)
Code:

/* block sprites */
   for (n=0; n<numblocks; n++)
   {
      sprites[n].attribute0 = COLOR_256 | SQUARE | blocky[n];
      sprites[n].attribute1 = SIZE_8 | blockx[n];
      sprites[n].attribute2 = 512+16;
   } //end for

_________________
Chris Davis

#110920 - Ant6n - Sat Dec 02, 2006 9:18 pm

how about anding y with 0xffff and x with 0x1ffff, because when x,y for example are -1, all bits are set and then they screw up the rest of the attr bits.
http://nocash.emubase.de/gbatek.htm#lcdobjoamattributes

anton

#110957 - tepples - Sun Dec 03, 2006 7:17 am

See the FAQ:

Q: Why do my sprites become corrupt when I move them off the top or the left side of the screen?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.