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 > Subscreen with BG3/BG1 problem

#154808 - a128 - Mon Apr 21, 2008 9:20 pm

This works on Emu BUT not on hardware..the console layer is distorted.

I tried various char_base/screen_base values no one worked

Code:
 
vramSetBankC(VRAM_C_SUB_BG); // 128Kbyte
vramSetBankH(VRAM_H_SUB_BG);


 vramSetBankD(VRAM_D_SUB_SPRITE);
 vramSetBankI(VRAM_I_SUB_SPRITE);

 videoSetModeSub(MODE_5_2D |
                                        DISPLAY_SPR_ACTIVE |   
                                        DISPLAY_SPR_1D_BMP  |   
                                        DISPLAY_BG3_ACTIVE |      DISPLAY_BG1_ACTIVE
               );

 int  char_base = 0;
 int screen_base = 15;
 // text
 SUB_BG1_CR = BG_256_COLOR | BG_TILE_BASE(char_base) | BG_MAP_BASE(screen_base)  |BG_PRIORITY(0);

    u16* sub_tile = u16*)CHAR_BASE_BLOCK_SUB(char_base);
     u16* sub_map = (u16*)SCREEN_BASE_BLOCK_SUB(screen_base);


  consoleInitDefault( sub_map,   sub_tile, 8);

BG_PALETTE_SUB[255] = RGB15(31, 31, 31);

BG_PALETTE_SUB[0] =0;

                        video_buffer =  (u16*)BG_BMP_RAM_SUB(2);

                        // create background image
                        SUB_BG3_CR = BG_BMP16_256x256 | BG_BMP_BASE(2)  |  BG_PRIORITY(1);

                        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;



I use video_bufer for CPU access..which works.

#154813 - Cydrak - Mon Apr 21, 2008 9:56 pm

Code:

vramSetBankC(VRAM_C_SUB_BG);         // 128K @ 0x6200000
vramSetBankH(VRAM_H_SUB_BG);         //  32K @ 0x6200000
vramSetBankD(VRAM_D_SUB_SPRITE);     // 128K @ 0x6600000
vramSetBankI(VRAM_I_SUB_SPRITE);     //  16K @ 0x6600000

This is a problem (and yup, not well emulated, if at all). Probably what you see is C/H and D/I sitting right on top of each other. Worse yet, H/I "repeat" to fill the whole 128K, clobbering their larger siblings.

Unfortunately, the sub mappings use hardwired locations; if you put C or D on the subscreen you can't then use H or I for the same thing. H/I can be mapped as ext-palettes, though... or just used as fast RAM.

#154816 - Lazy1 - Mon Apr 21, 2008 10:11 pm

Quote:

consoleInitDefault( sub_map, sub_tile, 8);


Should have 16 as the last parameter.

#154818 - Cydrak - Mon Apr 21, 2008 10:30 pm

Good point, didn't see that actually. But then one also needs BG_16_COLOR, not 256.

Side note: If you check the source, consoleInit() looks specifically for 16; other values give 256 color tiles (confusingly enough, for an arg called bitDepth). So that line ought to match the BG setup after all..

#154881 - a128 - Tue Apr 22, 2008 8:38 am

Cydrak wrote:
Code:

vramSetBankC(VRAM_C_SUB_BG);         // 128K @ 0x6200000
vramSetBankH(VRAM_H_SUB_BG);         //  32K @ 0x6200000
vramSetBankD(VRAM_D_SUB_SPRITE);     // 128K @ 0x6600000
vramSetBankI(VRAM_I_SUB_SPRITE);     //  16K @ 0x6600000



Thanks I really ignored the memory locations.