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 > Backgrounds

#76101 - gs2phateon - Sat Mar 18, 2006 4:42 am

I've had this problem that's driving me absolutely crazy. I have this formula that I'm using to scroll a background map:
Code:
    for (b = vscroll; b < vscroll + 31; b++){
        for (a = hscroll; a < hscroll + 32; a++){
            *bg0map2 = testlevel2b_Map[(b * 600) + a];
            bg0map2++;
        }
    }

Where vscroll and hscroll are the number of tiles scrolled down and right (respectively), and bg0map2 is the location of the ScreenBaseBlock of the map (25 in this case). The 600 you see is the width of the map, in tiles. This formula has worked pretty well (it's glitchy because it doesn't use DMA, but I'll save that for later...) at scrolling a large 600x40 tile map.

My problem started when I tried applying all of the EXACT same elements to another program. For some reason, the tiles on the screen are in the wrong order, and it looks like a random mosaic than the original picture. I think something is wrong with the tiles, as well. Both programs used screen mode 0 and are on background 0.

The only major difference between the good and bad programs is that the bad one uses sprites. Does this have any effect on how the map and tiles are stored? If not, do you have any suggestions about what I might be doing wrong? I even tried replacing the source code of the second program (the one with the sprites) using the code from the working program (the one without the sprites), and the problem still happened.

There is one exception I have found to this: the original background I used to test the sprite program DOES still work, and was compatible with the scrolling. It is a small, 32x32 tile map (same as the background size), and doesn't use a lot of tiles. However, the larger maps I made have had this map/tile problem.

I'm sorry this might be difficult to describe, but any help you might have to offer would be very appreciated.

#76135 - tepples - Sat Mar 18, 2006 3:52 pm

How is your other map's data aligned?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#76155 - gs2phateon - Sat Mar 18, 2006 7:47 pm

Both map's data (the 600x40 and 32x32) are aligned the same way, as in they are written straight out. I think that's 1D, right?

#76156 - tepples - Sat Mar 18, 2006 7:49 pm

I mean byte vs. word vs. long alignment. What program are you using to export the map data, and how are you loading it in your GBA file?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#76164 - gs2phateon - Sat Mar 18, 2006 8:56 pm

Ok, I'm using GFX2GBA, which turns it into a "const unsigned short" array of hexidecimal numbers (0x0000..., so 16 bit right?) within a source file. And to load it I just #include it.