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.

DS development > Tiled Background

#102551 - Caladus - Fri Sep 15, 2006 4:33 am

I am currently working on a simple rpg-ish demo program that uses all the tools the ds provides that I can get into it. I have hopes of documenting it and posting it to help other newbies like me.

I currently have 2 exrot's (main and sub) one is 512x512x8 and the other is 256x256x16. I also have sprites, movement and simple animations. My next goal is to draw a tiled background ontop of the 512x512. I have VRam A and B set to MainBG for the 512 and C and D are for the 256 and sprites. I have now assigned VRam E to MainBG for use with this new tiled backgroud. I am having trouble understanding the screenbase and mapbase concept. I seem to be writing data over my other bgs and I am not sure which values to use to get it to write into VRamE, or even if this setup is feasable. If anyone can give a quick rundown of how to write the tile data and tile map and all other necessary bits (the tiles use the same palette as the 512) to help me display it, I will be very greatful and I believe it will help others than just me. Thanks

#102552 - Caladus - Fri Sep 15, 2006 4:54 am

I'd figured I'd mention that the tiles I am using are basicly a font with each character taking up 8x8 pixels for a total of 95 tiles. I was hoping to use this for displaying text and showing how tiled backgrounds work at the same time (not using the console). They ar 8 bit (color) aswell.

#102558 - knight0fdragon - Fri Sep 15, 2006 7:47 am

whoa whoa whoa, what are you using for your MainBG, A, B or E
the way VRAM works with the screen is that you have to map them to certain addresses starting at 0x6000000
tiles are limited to 1024 per background, so you can only have 64k worth of tile saved.

This is great for VRAM E since it is 64k
(note you can not use all 1024 tiles in E though, unless you find a clever way to compine map and tile data)

I would recommend just sticking with A for now, A gives you 128k in space.

screen base = offset *0x800, so offset 1 would be 0x6000800
char base = offset * 0x4000, so offset 1 would be at 0x6004000
_________________
http://www.myspace.com/knight0fdragonds

MK DS FC: Dragon 330772 075464
AC WW FC: Anthony SamsClub 1933-3433-9458
MPFH: Dragon 0215 4231 1206

#102586 - Caladus - Fri Sep 15, 2006 2:08 pm

The offset number really helped. To answer your question. VRam A and B are mapped to MainBG because the 512 bitmap took up 256k so I had to map 2 consecutive VRams to hold it. The reason I chose VRam E for the tiled background is because all of the previous VRams are being used. I am hoping my tiles take up little room, but I will try to squeeze them into whatever VRams I have left. Can you go over how to construct a map? I was just fillin the array with 1's hoping it would print out the second tile accross the screen.

#102620 - knight0fdragon - Fri Sep 15, 2006 6:33 pm

map corresponds to the tile you want to be placed in the screen

so 0 would be your first tile,(having this transparent is usually the best idea) 1 would be your second tile and so on and so forth, for your 256x256 BG, you would have a map size of 2048, that is 32x32 tiles x 2bytes per map (max map # is 1023, and 2 bytes are needed for it)
_________________
http://www.myspace.com/knight0fdragonds

MK DS FC: Dragon 330772 075464
AC WW FC: Anthony SamsClub 1933-3433-9458
MPFH: Dragon 0215 4231 1206