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 > Help: Subscreen bgs using extended mode

#166701 - Emmanuel - Sun Feb 15, 2009 11:33 am

The palette is loading correctly but, The sub screen bg is using the sub screen palette instead of the extended one... I am using

Code:
REG_BG1CNT_SUB ^= BG_PALETTE_SLOT1;


For editing the registers and telling it to use the palette accordingly... to no avail...

Googling, tutorials only explain for main screen... I know the process should be similar... but I can't find what I'm missing...

#166719 - Dwedit - Sun Feb 15, 2009 9:40 pm

XOR Operator?
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."

#166744 - Emmanuel - Mon Feb 16, 2009 12:54 pm

Yeah, that was the one being used in some examples I found... I tested with OR and it gives the same results though... however, I don't know in the long run which is the correct one, I guess I'll stick with XOR...

and still, the subscreen uses default sub screen palette, instead of the extended sub palette 1... I tried disabling the console, and leaving just that background... all I got was a black screen because the palette was not loaded...

All the palettes in the main screen work correctly, and still I can't find what I'm missing...

My initVideo()
Code:
vramSetMainBanks(VRAM_A_MAIN_BG_0x06000000,
                     VRAM_B_MAIN_BG_0x06020000,
                     VRAM_C_SUB_BG_0x06200000,
                     VRAM_D_LCD);

    /*  Set the video mode on the main screen. */
    videoSetMode(MODE_0_2D |
            DISPLAY_BG0_ACTIVE |
                DISPLAY_BG1_ACTIVE |
            DISPLAY_BG2_ACTIVE |
            DISPLAY_BG3_ACTIVE); //Enable BG3 for display

    /*  Set the video mode on the sub screen. */
    videoSetModeSub(MODE_0_2D|
                DISPLAY_BG0_ACTIVE |
                DISPLAY_BG1_ACTIVE |
            DISPLAY_BG2_ACTIVE |
            DISPLAY_BG3_ACTIVE); //Enable BG3 for display
   vramSetBankE(VRAM_E_LCD);
   vramSetBankH(VRAM_H_LCD);
   REG_DISPCNT|= DISPLAY_BG_EXT_PALETTE;


My load Palette

Code:
if(main){
         vramSetBankE(VRAM_E_LCD);
         memcpy(VRAM_E_EXT_PALETTE[number], /* screen palette*/
                     buffer, size);
         VRAM_E_CR = VRAM_ENABLE | VRAM_E_BG_EXT_PALETTE;
         switch(number){
            case 3:
               REG_BG3CNT ^= BG_PALETTE_SLOT3;
               break;
            case 2:
               REG_BG2CNT ^= BG_PALETTE_SLOT2;
               break;
            case 1:
               REG_BG1CNT ^= BG_PALETTE_SLOT1;
               break;
            case 0:
               REG_BG0CNT ^= BG_PALETTE_SLOT0;
               break;
         }
      }else{
         vramSetBankH(VRAM_H_LCD);
         memcpy(VRAM_H_EXT_PALETTE[number], /* screen palette*/
                     buffer, size);;
         VRAM_H_CR = VRAM_ENABLE | VRAM_H_SUB_BG_EXT_PALETTE;
         REG_BG1CNT_SUB ^= BG_PALETTE_SLOT1;
         switch(number){
            case 3:
               REG_BG3CNT_SUB ^= BG_PALETTE_SLOT3;
               break;
            case 2:
               REG_BG2CNT_SUB ^= BG_PALETTE_SLOT2;
               break;
            case 1:
               REG_BG1CNT_SUB ^= BG_PALETTE_SLOT1;
               break;
            case 0:
               REG_BG0CNT_SUB ^= BG_PALETTE_SLOT0;
               break;
         }


Fixed
Code:
videoSetModeSub(MODE_0_2D|
                DISPLAY_BG0_ACTIVE |
                DISPLAY_BG1_ACTIVE |
            DISPLAY_BG2_ACTIVE |
            DISPLAY_BG3_ACTIVE |
            DISPLAY_BG_EXT_PALETTE);

I set
Code:
REG_DISPCNT|= DISPLAY_BG_EXT_PALETTE;

and thought it was for both screens... but now it's fixed with the videoSetModeSub