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 > Try to copy data to the subscreen

#145489 - kiwicode - Fri Nov 16, 2007 4:29 pm

Hi all,

I've got a very strange problem and I can't figure out what it might be the cause.

I want to change the value of subscreen's memory ( for example to draw a simple rect ). This is pretty easy and I don't have any problems with it.


Code:

   for( int iy = 50; iy < 100; iy ++ )
   {
      for( int ix = 50; ix < 150; ix++ )
      {
            
            video_buffer[ iy * 256 + ix >> 1 ] = 15 | ( 15 << 8 );
      }
   }


The problem occurs when I want to copy the data on every single byte of the subscreen instead of copying it on 2 bytes per time.

Code:


( ( uint8 * )video_buffer )[ iy * 256 + ix  ] = 15 | ( 15 << 8 );



After this simple cast I don't see anything blitted on my subscreen!
How can this happen?

I've initialized everything that way:
Code:

   videoSetMode( MODE_0_2D | DISPLAY_BG0_ACTIVE | DISPLAY_SPR_ACTIVE | DISPLAY_SPR_1D_LAYOUT | DISPLAY_SPR_EXT_PALETTE );
   videoSetModeSub( MODE_5_2D | DISPLAY_BG3_ACTIVE );

   vramSetBankA(VRAM_A_MAIN_BG);
   vramSetBankB(VRAM_B_MAIN_SPRITE_0x06400000);
   vramSetBankC(VRAM_C_SUB_BG);

   u16* video_buffer =  (u16*)BG_BMP_RAM_SUB(2);

   SUB_BG3_CR = BG_BMP8_256x256 | BG_BMP_BASE(2) | BG_PRIORITY(1);
   SUB_BG3_XDY = 0;
   SUB_BG3_XDX = 1 << 8;
   SUB_BG3_YDX = 0;
   SUB_BG3_YDY = 1 << 8;


any ideas?

Thanks in advance.

#145498 - DragonMinded - Fri Nov 16, 2007 7:08 pm

Quote:
The problem occurs when I want to copy the data on every single byte of the subscreen instead of copying it on 2 bytes per time.


This is the problem. You can't access VRAM bytewise.
_________________
Enter the mind of the dragon.

http://dragonminded.blogspot.com

Seriously guys, how hard is it to simply TRY something yourself?

#145509 - Lick - Fri Nov 16, 2007 10:50 pm

Funny that there are 3 of these (BMP8) topics at the same time!
_________________
http://licklick.wordpress.com