#26996 - saBADensetsu - Fri Oct 01, 2004 11:02 am
I have a few questions about "tiled-backgrounds", as described on gbajunkie.co.uk...
First of all - is the rom supposed to be ~8 seconds to load in VBA? How to reduce this time?
Then about larger maps... How is this done? I know it's something about reloading the map when moving, but not much more than this.
Thanks in advance.
_________________
"The Faith of Destruction, is also the Joy of Rebirth"
#27006 - yaustar - Fri Oct 01, 2004 2:56 pm
hmm. I think that is due to the program making a sin/cos lookup table as it starts up.. If you do use rotation then have a pre calculated sin/cos table and use that instead.
You may want to look at one of my 'tutorials' (using that term very loosely here) on my site:
http://yauster.com/main.php?body=dev/gba.html&head=dev/intro.html
_________________
[Blog] [Portfolio]
#27015 - DiscoStew - Fri Oct 01, 2004 4:15 pm
Is there a blank white screen for 8 seconds or is it black? If it is black, then VBA is loading the ROM. The time it takes depends on your computer, and how much resources are available to use. I know it takes a few seconds to load a ROM of only a few hundred KBytes on a Celeron 1.8GHz with 128MB of RAM. Good thing that is not my computer. he he.
If the screen is white, then you've got something loading that is taking a lot of time to do, such as what yaustar mentioned.
If I had more time right now, I'd talk about larger maps. Search the forums. I know there was a discussion about it, because I was involved in it.
_________________
DS - It's all about DiscoStew
#27017 - saBADensetsu - Fri Oct 01, 2004 4:46 pm
It was a white screen, and I can see that after i removed the rotating, it loads in < 2 secs...
Thanks alot!
Now, I've searched about larger maps, but I can't seem to find anything. Maybe I'm just a little bit blind...
_________________
"The Faith of Destruction, is also the Joy of Rebirth"
#27039 - tepples - Sat Oct 02, 2004 12:43 am
I haven't looked at the code, but perhaps it's building a sine table. This takes a long time on the GBA, which doesn't have an FPU. Unless you're entering a 4K competition, building a sine table at runtime is a bad idea. Instead, store an appropriately sized sine table in ROM.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
Last edited by tepples on Sat Oct 02, 2004 1:16 am; edited 1 time in total
#27043 - yaustar - Sat Oct 02, 2004 1:05 am
If you can look at a rom that does this and use vba to look at the backgrounds as you move around.. if you still have trouble then see if one of us can explain it properly...
_________________
[Blog] [Portfolio]
#27059 - DiscoStew - Sat Oct 02, 2004 8:50 am
Lets see if I can explain about large maps...
I imagine you know how text backgrounds work, as that is what I will use for explaining. They automatically wrap-around, which is what makes large maps possible by the method I will describe. As an example and not to over-fill this thread with a single post, imagine the text background is 32x32 pixels (4x4 tiles) big, and only 16x16 pixels (2x2 tiles) are visible, leaving the rest to be offscreen. We will also use a 6x6 tile map on this background, where tiles are filled with a simple algorithm Element = Col + (Row * 6). With Layer position at (8x8), the background would look like this, with the mid-section as the visible area...
Code: |
-------------
| 0 1 2 3|
| ----- |
| 6| 7 8| 9|
| | | |
|12|13 14|15|
| ----- |
|18 19 20 21|
-------------
|
If you were to scroll the layer 8 pixels to the right from point (8x8), you'd see the areas to the right in these 2 interpretations.
Code: |
GBA Interpretation Our Interpretation
------------- -------------
| 0 1 2 3| | 1 2 3 0|
| -----| | ----- |
| 6 7| 8 9| | 7| 8 9| 6|
| | | | | | |
|12 13|14 15| |13|14 15|12|
| -----| | ----- |
|18 19 20 21| |19 20 21 18|
------------- -------------
|
Now, after looking at the 2 interpretations, you can see if we were to scroll more than the 8 pixels, you'd begin to see what was on the left side appear on the right side, yet we'd want to see what was meant to be the next column of tiles. How do we fix this? Simple, just update the next column with the next column of map tiles. If that column is past the very edge of the background, you would switch over to the other side to update the tiles. Therefore, after the updating, the background in both interpretations would look like these...
Code: |
GBA Interpretation Our Interpretation
------------- -------------
| 4 1 2 3| | 1 2 3 4|
| -----| | ----- |
|10 7| 8 9| | 7| 8 9|10|
| | | | | | |
|16 13|14 15| |13|14 15|16|
| -----| | ----- |
|22 19 20 21| |19 20 21 21|
------------- -------------
|
After this update, you'd be able to scroll another 8 pixels to the right again. If you want to go more, just go through the steps again. This method can also be used for going left, up, and down also. If you want to scroll more than 8 pixels in a single instance, you'd have to update an additional number of sections depending on how much you scroll. Also once you begin to go past the edge of the actual map, you'd need to wrap-around to the opposite end of the map, and update from there. I'd recommend you store an h/v pixel offset which either increases or decreases by the amount you scroll per frame, depending on which direction you scroll, so that when you go to update, you can see how much to update, and on which sides. Once the update is complete, decrease or increase the h/v pixel offset opposite to how you increased or decreases it before. This will also help if you were to scroll, say 8 pixels one way (or one complete tile requiring an update), then scrolling back the other way.
I hope this explanation helps, though I may have missed some things. If you don't understand something, I'll try to explain that area if I can.
_________________
DS - It's all about DiscoStew