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 > Framebuffer + 256 bmp on sub

#47602 - tonysavon - Mon Jul 11, 2005 8:43 am

Hello,
I'm trying to port my Gba Jpeg Viewer on the DS. I would like to use the top screen as a framebuffer to display the picture and the second screen as a 256 colors paletted bmp for the gui. I can succesfully write to the top framebuffer screen in 16 bit, but I cannot draw to to the second one, which is always black:-(
Here is my code:
Code:

int main(void)
{   
  powerON(POWER_ALL);
  videoSetMode(MODE_FB0);
  vramSetBankA(VRAM_A_LCD); //
 
  videoSetModeSub(MODE_5_2D | DISPLAY_BG3_ACTIVE);
  vramSetBankC(VRAM_C_SUB_BG);
  SUB_BG3_CR = BG_BMP8_256x256;
  SUB_BG3_XDX = 1 << 8;
  SUB_BG3_XDY = 0;
  SUB_BG3_YDX = 0;
  SUB_BG3_YDY = 1 << 8;
  SUB_BG3_CX = 0;
  SUB_BG3_CY = 0;

  int z;
  u16* palette=(u16*)BG_PALETTE_SUB;
  u16*  screen=(u16*)BG_GFX_SUB;
 
  //grey palette, just for try
  for (z=0;z<256;z++) palette[z]=RGB(z>>3,z>>3,z>>3)|BIT(15);
  // try to write something
  for (z=0;z<256*128;z++) screen[z]=(u16)z;
   // but nothing happens.
   //following is code to write in VRAM_A for top screen, which works.

What am I doing wrong? Thanks!

#47630 - cory1492 - Mon Jul 11, 2005 4:20 pm

Have a look at subpixelfont, it is able to put stuff on either screen in frame mode. Wish I could be of more help, as it is Im trying to figure out how to simply change one pixel at a time inside vram....

Last edited by cory1492 on Mon Jul 11, 2005 4:31 pm; edited 1 time in total

#47633 - MrAdults - Mon Jul 11, 2005 4:28 pm

Code:
u16*  screen=(u16*)BG_GFX_SUB;


Don't know if it's your only problem, but 256 color bitmap mode means 8-bit palette lookup values, so that should be a u8.

-Rich

#47635 - tonysavon - Mon Jul 11, 2005 5:00 pm

MrAdults wrote:
Code:
u16*  screen=(u16*)BG_GFX_SUB;


Don't know if it's your only problem, but 256 color bitmap mode means 8-bit palette lookup values, so that should be a u8.

-Rich


I was writing data in 16 bits the old GBA style (where you only had 16bit access to vram if I remember correctly); anyway changing to u8* does not improve things. I always get black screen :-(
Any other ideas? Thanks

#47636 - MrAdults - Mon Jul 11, 2005 5:11 pm

It's also more appropriate to be writing to BG_BMP_RAM_SUB(0), but since BG_GFX_SUB and that will both result in a destination of 0x06200000, it isn't an issue.

Your problem may also be the way you're writing into the buffer. Try creating a scratch buffer (global or malloc) and writing into that, and using a dmaCopy to move your data from that buffer into vram, and see if that helps your black screen problem.

-Rich

#47638 - tonysavon - Mon Jul 11, 2005 5:30 pm

MrAdults wrote:

Your problem may also be the way you're writing into the buffer. Try creating a scratch buffer (global or malloc) and writing into that, and using a dmaCopy to move your data from that buffer into vram, and see if that helps your black screen problem.
-Rich

I've tryied this one too, with no luck. Thanks for your efforts though, I'm afraid I'll give up :-(

#47640 - tonysavon - Mon Jul 11, 2005 6:09 pm

It looks like I've solved :-)
Instead of writing to BG_GFX_SUB, i write directly to 0x6040000.
I wish I could understand why it is working now! I guess I've to study better.
Thanks to anyone who helped
Tony