using bgs and sprites on the sub vram banks
using bgs and sprites on the sub vram banks
hello,
if i want to use vram banks F, G, H, I
for bg main, bg sub and sub sprite, what offsets do i use?
i'm using the main vram banks for textures and vram E for mai sprite.
or can i use the sub vrm banks for textures?
thanks for your help.
if i want to use vram banks F, G, H, I
for bg main, bg sub and sub sprite, what offsets do i use?
i'm using the main vram banks for textures and vram E for mai sprite.
or can i use the sub vrm banks for textures?
thanks for your help.
Re: using bgs and sprites on the sub vram banks
From what I can tell from http://nocash.emubase.de/gbatek.htm#dsmemorycontrolvram you'll have F and G for Main Bg, H for Sub Bg and I for Sub Bg.
If you have these lines:
That should be exactly what you want. The only bank with any offset is G. It does not look like Banks E-I can be used for Textures (except E and F for Texture palettes).
If you have these lines:
Code: Select all
vramSetBankF(VRAM_F_MAIN_BG);
vramSetBankG(VRAM_G_MAIN_BG_0x06004000);
vramSetBankH(VRAM_H_SUB_BG);
vramSetBankI(VRAM_I_SUB_SPRITE);
Re: using bgs and sprites on the sub vram banks
if i've already used bgs on vram banks A,b and C for my Bgs do i have to clear my variables or something?
i tried using:
but it only shows half of the bg....
thanks for your help though.
i tried using:
Code: Select all
videoSetMode( MODE_5_2D );
videoSetModeSub(MODE_5_2D);
vramSetMainBanks(VRAM_A_MAIN_BG_0x06000000,VRAM_B_MAIN_BG_0x06020000,VRAM_C_SUB_BG_0x06200000,VRAM_D_LCD);
int bg2 = bgInit(3, BgType_Bmp8, BgSize_B8_256x256, 0,0);
int bg3 = bgInitSub(3, BgType_Bmp8, BgSize_B8_256x256, 0,0);
dmaCopy(splash1Pal,BG_PALETTE,splash1PalLen);
dmaCopy(splash1Bitmap,bgGetGfxPtr(bg2),splash1BitmapLen);
dmaCopy(splash2Pal,BG_PALETTE_SUB,splash1PalLen);
dmaCopy(splash2Bitmap,bgGetGfxPtr(bg3),splash2BitmapLen);
int ninjanumber=1;
while (ninjanumber < 300)
{
ninjanumber+=1;
swiWaitForVBlank();
}
dmaCopy(splash2Pal,BG_PALETTE,splash1PalLen);
dmaCopy(splash2Bitmap,bgGetGfxPtr(bg2),splash2BitmapLen);
dmaCopy(menuPal,BG_PALETTE_SUB,splash1PalLen);
dmaCopy(menuBitmap,bgGetGfxPtr(bg3),menuBitmapLen);
touchPosition touch;
int mode=0;
while (mode==0){
scanKeys();
if(keysHeld() & KEY_TOUCH){
touchRead(&touch);
if(touch.px < 128)mode=1;
if(touch.px > 128)mode=2;
}
swiWaitForVBlank();
}
videoSetMode( MODE_0_3D );
videoSetModeSub(MODE_5_2D);
vramSetBankF(VRAM_F_MAIN_BG);
vramSetBankG(VRAM_G_MAIN_BG_0x06004000);
vramSetBankH(VRAM_H_SUB_BG);
//setup BG
bg3 = 0;
bg3 = bgInitSub(3, BgType_Bmp8, BgSize_B8_256x256, 0,0);
dmaCopy(btmPal,BG_PALETTE_SUB,btmPalLen);
dmaCopy(btmBitmap,bgGetGfxPtr(bg3),btmBitmapLen);
thanks for your help though.
Re: using bgs and sprites on the sub vram banks
I'll have to come back to it a bit later, but my initial suspicion is due to the size of the banks. VRAM Banks F,G,H, and I are much smaller than A,B, and C. Where with A,B,and C as you had them you had 256K for Main BG and 128K for Sub BG. Changing to F through I you've got only 32K main bg, 32K for sub bg, and 16K for sub sprites.
If after the splash screens go by you're still working with 8bit backgrounds... you'd never be able to display a full screens worth of information as it takes 48K to show a 256*192 8bit background.
If after the splash screens go by you're still working with 8bit backgrounds... you'd never be able to display a full screens worth of information as it takes 48K to show a 256*192 8bit background.
Re: using bgs and sprites on the sub vram banks
ok, thanks.... can i somehow link vram banks? (i think i've seen this asked before... i think the answer was no....)
or how else can i get it to work?
thanks
-opearn
or how else can i get it to work?
thanks
-opearn
Re: using bgs and sprites on the sub vram banks
There should be a chart of possibly vram configurations somewhere in dovoto's tutorial. VRAM banks can't be "linked" necessarily... but under certain configurations when successive banks are assigned to the same job and the offset is done properly they could be thought of as linked, I suppose (like you had A and B at the start of the code).
You can't "link" banks that are not successive and unable to be assigned to particular jobs.
So what exactly are you trying to ultimately accomplish?
You can't "link" banks that are not successive and unable to be assigned to particular jobs.
So what exactly are you trying to ultimately accomplish?
Re: using bgs and sprites on the sub vram banks
I'm trying to make a basic first person shooter engine.
[3d top screen.
2D HUD on bottom screen.]
although its really in the earliest stages possible.
[3d top screen.
2D HUD on bottom screen.]
although its really in the earliest stages possible.
Re: using bgs and sprites on the sub vram banks
Ahhh, okay. I consider myself to be getting pretty good at programming for the DS, but I have yet to tackle any 3D at all,
What I guess I'm not going to know, is how much memory you're really going to need for your 3D part. If you're really going to need all of banks A-E for 3D textures and palettes and be stuck with F-I for everything on the sub screen, you're going to have very limited space available to display anything on the bottom screen.
You'll absolutely have to give up on an 8bit bmp background on the bottom, there's just not enough room if A-D are used up for the main engine. If somehow you found that you could switch to maybe just A and B and could use C and D for the sub screen that would change things.
I'm betting what you're going to need to do is switch to a tiled bg on the bottom with heavily re-used tiles...
What I guess I'm not going to know, is how much memory you're really going to need for your 3D part. If you're really going to need all of banks A-E for 3D textures and palettes and be stuck with F-I for everything on the sub screen, you're going to have very limited space available to display anything on the bottom screen.
You'll absolutely have to give up on an 8bit bmp background on the bottom, there's just not enough room if A-D are used up for the main engine. If somehow you found that you could switch to maybe just A and B and could use C and D for the sub screen that would change things.
I'm betting what you're going to need to do is switch to a tiled bg on the bottom with heavily re-used tiles...
Re: using bgs and sprites on the sub vram banks
could i setup (any) VRAM banks
F>I to get a working result? i can stop using all the other vram banks there...
thanks
-opearn
F>I to get a working result? i can stop using all the other vram banks there...
thanks
-opearn
Re: using bgs and sprites on the sub vram banks
If you mean using F through I to get more ram? No... unfortunately there only a few specific purposes that each Bank can be assigned to. Here's a bit from libnds' video.h that shows acceptable values for the vramSetBank functions:
Code: Select all
/** \brief Allowed VRAM bank A modes */
typedef enum {
VRAM_A_LCD = 0,
VRAM_A_MAIN_BG = 1,
VRAM_A_MAIN_BG_0x06000000 = 1 | VRAM_OFFSET(0),
VRAM_A_MAIN_BG_0x06020000 = 1 | VRAM_OFFSET(1),
VRAM_A_MAIN_BG_0x06040000 = 1 | VRAM_OFFSET(2),
VRAM_A_MAIN_BG_0x06060000 = 1 | VRAM_OFFSET(3),
VRAM_A_MAIN_SPRITE = 2,
VRAM_A_MAIN_SPRITE_0x06400000 = 2,
VRAM_A_MAIN_SPRITE_0x06420000 = 2 | VRAM_OFFSET(1),
VRAM_A_TEXTURE = 3,
VRAM_A_TEXTURE_SLOT0 = 3 | VRAM_OFFSET(0),
VRAM_A_TEXTURE_SLOT1 = 3 | VRAM_OFFSET(1),
VRAM_A_TEXTURE_SLOT2 = 3 | VRAM_OFFSET(2),
VRAM_A_TEXTURE_SLOT3 = 3 | VRAM_OFFSET(3)
} VRAM_A_TYPE;
/** \brief Allowed VRAM bank B modes */
typedef enum {
VRAM_B_LCD = 0,
VRAM_B_MAIN_BG = 1 | VRAM_OFFSET(1),
VRAM_B_MAIN_BG_0x06000000 = 1 | VRAM_OFFSET(0),
VRAM_B_MAIN_BG_0x06020000 = 1 | VRAM_OFFSET(1),
VRAM_B_MAIN_BG_0x06040000 = 1 | VRAM_OFFSET(2),
VRAM_B_MAIN_BG_0x06060000 = 1 | VRAM_OFFSET(3),
VRAM_B_MAIN_SPRITE = 2 | VRAM_OFFSET(1),
VRAM_B_MAIN_SPRITE_0x06400000 = 2,
VRAM_B_MAIN_SPRITE_0x06420000 = 2 | VRAM_OFFSET(1),
VRAM_B_TEXTURE = 3 | VRAM_OFFSET(1),
VRAM_B_TEXTURE_SLOT0 = 3 | VRAM_OFFSET(0),
VRAM_B_TEXTURE_SLOT1 = 3 | VRAM_OFFSET(1),
VRAM_B_TEXTURE_SLOT2 = 3 | VRAM_OFFSET(2),
VRAM_B_TEXTURE_SLOT3 = 3 | VRAM_OFFSET(3)
} VRAM_B_TYPE;
/** \brief Allowed VRAM bank C modes */
typedef enum {
VRAM_C_LCD = 0,
VRAM_C_MAIN_BG = 1 | VRAM_OFFSET(2),
VRAM_C_MAIN_BG_0x06000000 = 1 | VRAM_OFFSET(0),
VRAM_C_MAIN_BG_0x06020000 = 1 | VRAM_OFFSET(1),
VRAM_C_MAIN_BG_0x06040000 = 1 | VRAM_OFFSET(2),
VRAM_C_MAIN_BG_0x06060000 = 1 | VRAM_OFFSET(3),
VRAM_C_ARM7 = 2,
VRAM_C_ARM7_0x06000000 = 2,
VRAM_C_ARM7_0x06020000 = 2 | VRAM_OFFSET(1),
VRAM_C_SUB_BG = 4,
VRAM_C_SUB_BG_0x06200000 = 4 | VRAM_OFFSET(0),
VRAM_C_TEXTURE = 3 | VRAM_OFFSET(2),
VRAM_C_TEXTURE_SLOT0 = 3 | VRAM_OFFSET(0),
VRAM_C_TEXTURE_SLOT1 = 3 | VRAM_OFFSET(1),
VRAM_C_TEXTURE_SLOT2 = 3 | VRAM_OFFSET(2),
VRAM_C_TEXTURE_SLOT3 = 3 | VRAM_OFFSET(3)
} VRAM_C_TYPE;
/** \brief Allowed VRAM bank D modes */
typedef enum {
VRAM_D_LCD = 0,
VRAM_D_MAIN_BG = 1 | VRAM_OFFSET(3),
VRAM_D_MAIN_BG_0x06000000 = 1 | VRAM_OFFSET(0),
VRAM_D_MAIN_BG_0x06020000 = 1 | VRAM_OFFSET(1),
VRAM_D_MAIN_BG_0x06040000 = 1 | VRAM_OFFSET(2),
VRAM_D_MAIN_BG_0x06060000 = 1 | VRAM_OFFSET(3),
VRAM_D_ARM7 = 2 | VRAM_OFFSET(1),
VRAM_D_ARM7_0x06000000 = 2,
VRAM_D_ARM7_0x06020000 = 2 | VRAM_OFFSET(1),
VRAM_D_SUB_SPRITE = 4,
VRAM_D_TEXTURE = 3 | VRAM_OFFSET(3),
VRAM_D_TEXTURE_SLOT0 = 3 | VRAM_OFFSET(0),
VRAM_D_TEXTURE_SLOT1 = 3 | VRAM_OFFSET(1),
VRAM_D_TEXTURE_SLOT2 = 3 | VRAM_OFFSET(2),
VRAM_D_TEXTURE_SLOT3 = 3 | VRAM_OFFSET(3)
} VRAM_D_TYPE;
/** \brief Allowed VRAM bank E modes */
typedef enum {
VRAM_E_LCD = 0,
VRAM_E_MAIN_BG = 1,
VRAM_E_MAIN_SPRITE = 2,
VRAM_E_TEX_PALETTE = 3,
VRAM_E_BG_EXT_PALETTE = 4,
} VRAM_E_TYPE;
/** \brief Allowed VRAM bank F modes */
typedef enum {
VRAM_F_LCD = 0,
VRAM_F_MAIN_BG = 1,
VRAM_F_MAIN_BG_0x06000000 = 1,
VRAM_F_MAIN_BG_0x06004000 = 1 | VRAM_OFFSET(1),
VRAM_F_MAIN_BG_0x06010000 = 1 | VRAM_OFFSET(2),
VRAM_F_MAIN_BG_0x06014000 = 1 | VRAM_OFFSET(3),
VRAM_F_MAIN_SPRITE = 2,
VRAM_F_MAIN_SPRITE_0x06400000 = 2,
VRAM_F_MAIN_SPRITE_0x06404000 = 2 | VRAM_OFFSET(1),
VRAM_F_MAIN_SPRITE_0x06410000 = 2 | VRAM_OFFSET(2),
VRAM_F_MAIN_SPRITE_0x06414000 = 2 | VRAM_OFFSET(3),
VRAM_F_TEX_PALETTE = 3,
VRAM_F_BG_EXT_PALETTE = 4,
VRAM_F_BG_EXT_PALETTE_SLOT01 = 4 | VRAM_OFFSET(0),
VRAM_F_BG_EXT_PALETTE_SLOT23 = 4 | VRAM_OFFSET(1),
VRAM_F_SPRITE_EXT_PALETTE = 5,
} VRAM_F_TYPE;
/** \brief Allowed VRAM bank G modes */
typedef enum {
VRAM_G_LCD = 0,
VRAM_G_MAIN_BG = 1,
VRAM_G_MAIN_BG_0x06000000 = 1,
VRAM_G_MAIN_BG_0x06004000 = 1 | VRAM_OFFSET(1),
VRAM_G_MAIN_BG_0x06010000 = 1 | VRAM_OFFSET(2),
VRAM_G_MAIN_BG_0x06014000 = 1 | VRAM_OFFSET(3),
VRAM_G_MAIN_SPRITE = 2,
VRAM_G_MAIN_SPRITE_0x06400000 = 2,
VRAM_G_MAIN_SPRITE_0x06404000 = 2 | VRAM_OFFSET(1),
VRAM_G_MAIN_SPRITE_0x06410000 = 2 | VRAM_OFFSET(2),
VRAM_G_MAIN_SPRITE_0x06414000 = 2 | VRAM_OFFSET(3),
VRAM_G_TEX_PALETTE = 3,
VRAM_G_BG_EXT_PALETTE = 4,
VRAM_G_BG_EXT_PALETTE_SLOT01 = 4 | VRAM_OFFSET(0),
VRAM_G_BG_EXT_PALETTE_SLOT23 = 4 | VRAM_OFFSET(1),
VRAM_G_SPRITE_EXT_PALETTE = 5,
} VRAM_G_TYPE;
/** \brief Allowed VRAM bank H modes */
typedef enum {
VRAM_H_LCD = 0,
VRAM_H_SUB_BG = 1,
VRAM_H_SUB_BG_EXT_PALETTE = 2,
} VRAM_H_TYPE;
/** \brief Allowed VRAM bank I modes */
typedef enum {
VRAM_I_LCD = 0,
VRAM_I_SUB_BG_0x06208000 = 1,
VRAM_I_SUB_SPRITE = 2,
VRAM_I_SUB_SPRITE_EXT_PALETTE = 3,
}VRAM_I_TYPE;
Who is online
Users browsing this forum: No registered users and 3 guests