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 > Another Background Question

#35116 - Mitch GBA - Sun Jan 30, 2005 7:31 pm

how do you make them wrap around the screen?? I've seen a few demo's where 1 map wraps around, repeating itself, and I even saw the code. Still I cant figure out what code actually does the wrapping around.. Can someone help me out here? :) help appreciated

#35120 - Cearn - Sun Jan 30, 2005 8:23 pm

Text backgrounds will wrap automatically. For rotational backgrounds you need to set bit13 (0x2000) of REG_BGxCNT.

#35125 - Mitch GBA - Sun Jan 30, 2005 10:35 pm

how do you do this?

#35144 - yaustar - Mon Jan 31, 2005 5:51 am

Are you talking about this:
Quote:
For rotational backgrounds you need to set bit13 (0x2000) of REG_BGxCNT.

if I remember correctly
Code:
REG_BGxCNT |= 1 << 13;

If you dont understand then please say so rather then accept the fact that it works and that's it.
_________________
[Blog] [Portfolio]

#35147 - Mitch GBA - Mon Jan 31, 2005 7:46 am

Well, I think I understand. The x is the background nr. you refer too. and this just enables bit 13, which is wrapping the bg. I'll check it now, thanks :)

#35164 - Mitch GBA - Mon Jan 31, 2005 3:53 pm

yeh it works, thanks :) Now another problem. I cant load 2 backgrounds :( How do you load 2 background?

#35165 - Cearn - Mon Jan 31, 2005 4:11 pm

Pretty much the same way you load one background:
  • load image and map data
  • set REG_BGxCNT for size, screen & char block, etc (x=0,1,2,3, sorry about that earlier)
  • enable it in REG_DISPCNT
Make sure that the video mode actually supports the background you want to use, though. Mode 0 has all four; mode 1 can't use bg3, mode 2 can't use bg0 or bg1, and in mode 3-5 only bg2 is allowed.

#35166 - Mitch GBA - Mon Jan 31, 2005 4:42 pm

ok thanks. I'll check it again :)

#35167 - Mitch GBA - Mon Jan 31, 2005 4:49 pm

hmm, I dont know what I'm doing wrong.. Here's the map. Could someone take a look at the code??

http://www.klikacademy.com/cc/Mitch/Shooter.zip

help very much appreciated :)

#35195 - Mitch GBA - Tue Feb 01, 2005 7:49 am

please :)

#35209 - poslundc - Tue Feb 01, 2005 2:53 pm

Most people in the forum don't have either the time or inclination to debug other people's code for them. Try debugging it yourself, see how far you get, and when you run into a specific problem you can't solve try asking a specific question about a specific block of code, rather than just dumping the project on the community and expecting people to tell you why it doesn't do what you want it to.

Dan.

#35214 - Cearn - Tue Feb 01, 2005 4:31 pm

As much as I agree with Dan that you should try to find the problem yourself, sometimes it can be difficult if there are multiple bugs acting in tandem and you have no idea where to start.
The main problem is one that's not really mentioned in various tutorials, namely that you should always set a rotational background's matrix before use. (I'd fix this in mine, but I can't get to it right now). However, there are more problems than just this one. For example, there's no such thing as charblock 100, nor is there a screenblock 128, and the wrap-around flag not defined as 1.
Some of these problems are related to gbajunkie's tutorials. It is advisable to read some of the other tutorials as well. Every one of them has its issues, but by getting your information from multiple indendent sources, you will craft a better picture of what one is supposed to do. And read them carefully. Make sure you actually understand what's going on before you start writing down code. Yes this will take some time, but so will getting stumped at every corner.

(Btw, if you're wondering why it takes so long before you see anything in your demo, it's busy filling the sin/cos table. Floating point on the GBA is evil. Write a small PC program that spits out a sin/cos table which you can link to, rather than fill the thing inside a GBA program)

#35227 - Mitch GBA - Tue Feb 01, 2005 7:44 pm

thanks. I'll try and work on it a bit more, yeah. I think I took the easy road too fast :) thanks for the help