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 > vram settings for BG_BMP8_1024x512 ?

#55874 - GPFerror - Mon Oct 03, 2005 5:41 pm

what should my vramSetMainBanks be set to for BG_BMP8_1024x512 on main screen and consoleprinting on sub screen?

should this work ? vramSetMainBanks(VRAM_A_MAIN_BG_0x6000000, VRAM_B_MAIN_BG_0x6020000, VRAM_C_SUB_BG , VRAM_D_LCD);

thanks,
Troy(GPF)

#55883 - GPFerror - Mon Oct 03, 2005 7:32 pm

ok found out on irc that 1024X512 requires 4 banks so i guess i use something like this

vramSetMainBanks(VRAM_A_MAIN_BG,VRAM_B_MAIN_BG,VRAM_C_MAIN_BG,VRAM_D_MAIN_BG);

but then I get no sub background for consoleprinting.

so if I do this
vramSetBankE(VRAM_H_SUB_BG);
vramSetBankF(VRAM_I_LCD);

how do I change my

SUB_BG0_CR = BG_MAP_BASE(31);
consoleInitDefault((u16*)SCREEN_BASE_BLOCK_SUB(31), (u16*)CHAR_BASE_BLOCK_SUB(0), 16);

so that it uses a different bank?

thanks

#55989 - GPFerror - Wed Oct 05, 2005 6:32 am

GPFerror wrote:
ok found out on irc that 1024X512 requires 4 banks so i guess i use something like this

vramSetMainBanks(VRAM_A_MAIN_BG,VRAM_B_MAIN_BG,VRAM_C_MAIN_BG,VRAM_D_MAIN_BG);

but then I get no sub background for consoleprinting.

so if I do this
vramSetBankE(VRAM_H_SUB_BG);
vramSetBankF(VRAM_I_LCD);

how do I change my

SUB_BG0_CR = BG_MAP_BASE(31);
consoleInitDefault((u16*)SCREEN_BASE_BLOCK_SUB(31), (u16*)CHAR_BASE_BLOCK_SUB(0), 16);

so that it uses a different bank?

thanks


ok I even tried this and its still not working for 1024X512

vramSetMainBanks(VRAM_A_MAIN_BG, VRAM_B_MAIN_BG, VRAM_C_MAIN_BG, VRAM_D_MAIN_BG);
vramSetBankH(VRAM_H_SUB_BG);
vramSetBankI(VRAM_I_LCD);

SUB_BG0_CR = BG_MAP_BASE(8);
consoleInitDefault((u16*)SCREEN_BASE_BLOCK_SUB(8), (u16*)CHAR_BASE_BLOCK_SUB(0), 16);

BG3_CR = BG_BMP8_1024x512;
BG3_XDX = ((width / 256) << 8) | (width % 256) ;
BG3_XDY = 0;
BG3_YDX = 0;
BG3_YDY = ((height / 192) << 8) | ((height % 192) + (height % 192) / 3) ;

and console printing is working again , but im just getting a black background on other screen.

Anyone here every use BG_BMP8_1024x512 successfully? can you post your setup code.

Thanks,
Troy(GPF)

#56001 - pepsiman - Wed Oct 05, 2005 11:18 am

GPFerror wrote:

ok I even tried this and its still not working for 1024X512
Code:
BG3_CR = BG_BMP8_1024x512;

im just getting a black background on other screen.

1024X512 needs mode 6.
Code:
videoSetMode(6);

Mode 6 uses BG2, not BG3.
Code:
BG2_CR = BG_BMP8_1024x512;

See http://dualis.1emulation.com/dsti.html for details.

#56057 - GPFerror - Wed Oct 05, 2005 8:34 pm

ok thanks, pepsiman that fixed the black screen problem , but Im now running into an issue of where the screen is not being scaled correctly, the screen on the right half is black, and the left is overlapped by what should be on the right side.

Here is my sample code that im using, with a 1024X512 bmp file of a nintendo ds converted to bin.

Code:
#include <nds.h>
#include <nds/arm9/console.h>
#include <stdio.h>
#include "nintendo_ds_img_bin.h"
#include "nintendo_ds_pal_bin.h"
int main(void)
{
   powerON(POWER_ALL);
   videoSetMode(MODE_6_2D | DISPLAY_BG2_ACTIVE );

   videoSetModeSub(MODE_0_2D | DISPLAY_BG0_ACTIVE);

    vramSetMainBanks(VRAM_A_MAIN_BG,VRAM_B_MAIN_BG,VRAM_C_MAIN_BG,VRAM_D_MAIN_BG);
   vramSetBankH(VRAM_H_SUB_BG);
   vramSetBankI(VRAM_I_LCD);

    SUB_BG0_CR = BG_MAP_BASE(8);

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

   consoleInitDefault((u16*)SCREEN_BASE_BLOCK_SUB(8), (u16*)CHAR_BASE_BLOCK_SUB(0), 16);

   iprintf("\x1b[5;2H1024X512 8 bit color demo");

   BG2_CR = BG_BMP8_1024x512;

   int width=1024;
   int  height=512;

        BG2_XDX = ((width / 256) << 8) | (width % 256) ;
        BG2_XDY = 0;
        BG2_YDX = 0;
        BG2_YDY = ((height / 192) << 8) | ((height % 192) + (height % 192) / 3) ;
        BG2_CX = 0;
        BG2_CY = 0;

   lcdSwap();

   dmaCopy(nintendo_ds_img_bin, BG_GFX, 1024*512);
   dmaCopy(nintendo_ds_pal_bin, BG_PALETTE, 256*2);

 while(1)swiWaitForVBlank();
   return 0;
}


[Images not permitted - Click here to view it]

Same thing is happening on hardware too. Is the scaling code different for mode6?

if I use a diffent bmp thats 512X512 then it renders correctly but the right half of the screen is black also.

also if I switch it to use a bmp thats 512X1024 and switch the above code to this

Code:
   BG2_CR = BG_BMP8_512x1024;
   int height=1024;
   int  width=512;


it renders correctly horizontally, but the bottom half of the screen is black.

thanks,
Troy

#56065 - GPFerror - Wed Oct 05, 2005 9:04 pm

according to http://dualis.1emulation.com/dsti.html

libnds video.h has the defines backwards

#define BG_BMP8_1024x512 0
#define BG_BMP8_512x1024 BIT(14)

should be

#define BG_BMP8_1024x512 BIT(14)
#define BG_BMP8_512x1024 0

and that has fixed the above problem , so I can now render a 1024X512 8bit bmp.

thanks again.
Troy