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.

Beginners > bg problems switching from mode 0 to mode 4

#22567 - immortalninjak - Thu Jun 24, 2004 11:13 am

hey ho,
I'm having trouble switching from mode 0-4
to start I have 3 bgs in mode 0:

Code:
SetMode(MODE_0 | OBJ_ENABLE | OBJ_MAP_1D);
     bg0clear.number = 0;
     bg0clear.charBaseBlock = 0;                 
     bg0clear.screenBaseBlock = 24;      
     bg0clear.colorMode = BG_COLOR_256;     
     bg0clear.size = TEXTBG_SIZE_256x256;         
     bg0clear.mosaic = 0;                       
     bg0clear.x_scroll = 0;         
     bg0clear.y_scroll = 0;
     bg0clear.priority = BG_P2;
      
     bg1title.number = 1;
     bg1title.charBaseBlock = 0;                 
     bg1title.screenBaseBlock = 16;      
     bg1title.colorMode = BG_COLOR_256;     
     bg1title.size = TEXTBG_SIZE_256x256;         
     bg1title.mosaic = 0;                       
     bg1title.x_scroll = 200;         
     bg1title.y_scroll = 247;
     bg1title.priority = BG_P1;
      
     bg2scroll.number = 2;      
     bg2scroll.charBaseBlock = 0;                 
     bg2scroll.screenBaseBlock = 8;      
     bg2scroll.colorMode = BG_COLOR_256;     
     bg2scroll.size = TEXTBG_SIZE_256x256;         
     bg2scroll.mosaic = 0;
     bg2scroll.x_scroll = 0;
     bg2scroll.y_scroll = 0;
     bg1title.priority = BG_P3;

     EnableBackground(&bg0clear);
     EnableBackground(&bg1title);
     EnableBackground(&bg2scroll);




I then mess around with the sprites and scroll the bgs so I reset the scrolling regiters:

Code:
   REG_BG2HOFS =0;
   REG_BG2VOFS =0;
   REG_BG0HOFS =0;
   REG_BG0VOFS =0;
   REG_BG1HOFS =0;
   REG_BG1VOFS =0;


before chaging to mode4:

Code:
SetMode(MODE_4 | BG2_ENABLE | OBJ_ENABLE | OBJ_MAP_1D);
   
   for (int i = 0; i < 256; i++){
      BGPaletteMem[i] = into1Palette[i];
   }
   REG_DMA3SAD = (u32) &(into1Data[0]);
   REG_DMA3DAD = 0x6000000;
   REG_DMA3CNT = 9600 | DMA_32NOW;
   


However this does not seem to work. The screen appears blue repeating the first pixel over and over.
Using the map viewer in VBA it shows that everything is ok, with the corretly loaded bg and mode set.
If the code above is used seperatly everything is ok.
Only when I switch from mode 0 to 4 do I get this problem.
Any ideas?
thank you

#22572 - tepples - Thu Jun 24, 2004 2:44 pm

When you switch to a linear bitmap mode, especially after having used mode 1 or 2, you have to reset background 2's affine matrix to pa = 256, pb = 0, pc = 0, pd = 256, x = 0, y = 0.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#22577 - immortalninjak - Thu Jun 24, 2004 3:34 pm

thank you so very much.
that was exactly the problem
me happy now.
cheers