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

#102657 - Caladus - Fri Sep 15, 2006 11:20 pm

I have been messing around with this and I just can't seem to get it to display. I am using the same palette as my exrot, so I figure I don't have to mess with the palette. I am trying to get it into VRam D, here is my code

Code:
void setUpText() {
   int mapbase = 7575;
   int tilebase = 1515 + 1;
   BG2_CR = BG_COLOR_16 |
          BG_32x32 |
          BG_MAP_BASE(mapbase) |
          BG_TILE_BASE(tilebase) |
          BG_PRIORITY(2);
   dmaCopy(MyFont_Bitmap, (uint16*)CHAR_BASE_BLOCK(tilebase), sizeof(MyFont_Bitmap));
   for(int x = 0; x < 32; x++){
      for(int y = 0; y < 24; y++){
         ((uint16*)SCREEN_BASE_BLOCK(mapbase))[32*y+x] = 32;
      }
   }
}

#102660 - Caladus - Fri Sep 15, 2006 11:25 pm

I am very sorry. In my haste I seem to have created another thread instead of replying in my current one. I can't seem to find a way to remove this thread. If a moderator sees this, please merge the two.

#102673 - tepples - Fri Sep 15, 2006 11:55 pm

This forum is a pretty much stock phpBB. In phpBB, unlike in some other forum software, moderators cannot merge topics. Sorry :(
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#102675 - Caladus - Fri Sep 15, 2006 11:58 pm

Oh well, I sappose I deserve to look like an idiot for not paying more attention. Also, the values for the bases in my code should be 75 and 16. Typo

#102686 - knight0fdragon - Sat Sep 16, 2006 3:28 am

WHOA WHOA WHOA some of your stuff is crazy

Code:


void setUpText() {
   uint16* mapbase = SCREEN_BASE_BLOCK(0);
   uint16* tilebase = CHAR_BASE_BLOCK(1);
   BG2_CR = BG_COLOR_16 |
          BG_32x32 |
          BG_MAP_BASE(0) |
          BG_TILE_BASE(1) |
          BG_PRIORITY(2);
   dmaCopy(MyFont_Bitmap, tilebase, sizeof(MyFont_Bitmap));
   for(int x = 0; x < 32; x++){
      for(int y = 0; y < 24; y++){
         mapbase[32*y+x] = 32;
      }
   }
}


_________________
http://www.myspace.com/knight0fdragonds

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

#102741 - Caladus - Sat Sep 16, 2006 4:10 pm

Thanks, that works wonderfully except that it writes data over the top of my exrot that is already taking up VRam A and B. I am attempting to store the data in VRamD now. I have been trying map = 75, tile = 15 for the base values, because 0x60000/0x4000 and 0x800 is 15 and 75. Maybe my concept of this math is wrong, perhaps the values are hex. I would be very greatful for the correct values to store this data in VRamD. Once I see the values, I know it will all make sense. Thanks

#102743 - Caladus - Sat Sep 16, 2006 4:49 pm

Actually, its not working. I have no idea what I am doing wrong
I made a 8x760 bitmap, I put one character in each 8x8 pixel block. I used the following line to convert it into a raw.c
gfx2gba -fsrc -m -pDemoFont.pal -t8 DemoFont.bmp

I then used the section of code listed above. The first character is blank, and when I put 0 in for the map values, the bg is transparent, which is good, but for every other value 1-95, I get things that I didn't draw. Also, my 512x512 exrot which takes up VRam A and B has a section that is flawed, which I am assuming is the tile data being written over the 512 because the map and screen bases are not high enough. This is so very frustrating, but I am determined to figure it out. Any guidance would be very appreciated.

BTW, the prompt responces and time you have put into answering my questions is greatly appreciated knight0fdragon. I know it must be hard helping newbies like me get on the right path, but every time I recieve a responce to a very frustrating question is like Christmas all over agian. Thanks

#102747 - knight0fdragon - Sat Sep 16, 2006 5:54 pm

You want this on the sub screen I am assuming

Code:

   uint16* mapbase = SCREEN_BASE_BLOCK_SUB(0);
   uint16* tilebase = CHAR_BASE_BLOCK_SUB(1);
   BG2_CR_SUB = BG_COLOR_16 |
          BG_32x32 |
          BG_MAP_BASE(0) |
          BG_TILE_BASE(1) |
          BG_PRIORITY(2);
   dmaCopy(MyFont_Bitmap, tilebase, sizeof(MyFont_Bitmap));
   for(int x = 0; x < 32; x++){
      for(int y = 0; y < 24; y++){
         mapbase[32*y+x] = 32;
      }
   }




_________________
http://www.myspace.com/knight0fdragonds

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

#102751 - Caladus - Sat Sep 16, 2006 6:14 pm

I was hoping to have it on the main screen to show how sprites, exrots and tiled bgs can all go on the same screen. Let me give you some more of my code to explain things better.

int main() {

powerON(POWER_ALL_2D);

irqInit();
irqSet(IRQ_VBLANK, vBlank);

vramSetBankA(VRAM_A_MAIN_BG_0x6000000);
vramSetBankB(VRAM_B_MAIN_BG_0x6020000);
vramSetBankC(VRAM_C_SUB_BG_0x6200000);
vramSetBankD(VRAM_D_MAIN_BG_0x6060000);
vramSetBankE(VRAM_E_MAIN_SPRITE);
vramSetBankF(VRAM_F_MAIN_SPRITE);
vramSetBankG(VRAM_G_MAIN_SPRITE);
vramSetBankI(VRAM_I_LCD);

videoSetMode(MODE_3_2D |
DISPLAY_SPR_ACTIVE |
DISPLAY_BG3_ACTIVE |
DISPLAY_BG2_ACTIVE |
DISPLAY_SPR_1D);

videoSetModeSub(MODE_3_2D | DISPLAY_BG3_ACTIVE);

BG3_CR = BG_BMP8_512x512 | BG_BMP_BASE(0) | BG_PRIORITY(3);
BG3_XDX = 1 << 8; //scale x
BG3_XDY = 0; //rotation x
BG3_YDX = 0; //rotation y
BG3_YDY = 1 << 8; //scale y
BG3_CX = 0; //translation x
BG3_CY = 0; //translation y

SUB_BG3_CR = BG_BMP16_256x256 | BG_BMP_BASE(0) | BG_PRIORITY(3);
SUB_BG3_XDX = 1 << 8; //scale x
SUB_BG3_XDY = 0; //rotation x
SUB_BG3_YDX = 0; //scale y
SUB_BG3_YDY = 1 << 8; //scale y
SUB_BG3_CX = 0; //translation x
SUB_BG3_CY = 0; //translation y

dmaCopy(Background1_bin, BG_GFX, 512 * 512);
dmaCopy(background1Pal_bin, BG_PALETTE, 256*2);
dmaCopy(SubExrot_bin, BG_GFX_SUB, SubExrot_bin_size);

uint16* mapbase = (uint16*) SCREEN_BASE_BLOCK(0);
uint16* tilebase = (uint16*) CHAR_BASE_BLOCK(1);
BG2_CR = BG_COLOR_16 |
BG_32x32 |
BG_MAP_BASE(0) |
BG_TILE_BASE(1) |
BG_PRIORITY(2);
dmaCopy(DemoFont_Tiles, tilebase, sizeof(DemoFont_Tiles));
for(int x = 0; x < 32; x++){
for(int y = 0; y < 24; y++){
mapbase[32*y+x] = charval;
}
}


The last part is the issue. This is not all of my program, but I think it shows what I am trying to do. To sum it up, its this

Main Screen - Sprites - VRam E-G
Text Backgroud - VRamD (this is the problem)
Exrot - VRam A and B

Sub Screen - Exrot - VRam C

#102805 - knight0fdragon - Sun Sep 17, 2006 3:01 am

if you want tiles and BMP on the same screen then just look at this example

http://hyperclubbingfriends.yourfreewebspace.com/Knight0fDragon/tile_and_bmp.rar


all you would have to do is add sprite
_________________
http://www.myspace.com/knight0fdragonds

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