Question

Je suis totalement nouveau dans les libdns.J'essaye de changer l'exemple de Graphics \ Backgrounds \ 256_color_bmp pour afficher l'arrière-plan sur le sous-écran.

Voici mon code.Avez-vous une idée de ce qui manque pour afficher hey_typBitmap sur le sous-écran?J'ai déjà réussi à afficher la nouvelle image sur l'écran supérieur.

#include <nds.h>
#include <stdio.h>
#include "drunkenlogo.h"
#include "hey_typ.h"

int main(void)
{
    videoSetMode(MODE_5_2D);
    vramSetBankA(VRAM_A_MAIN_BG_0x06000000);

    videoSetModeSub(MODE_5_2D);
    vramSetBankC(VRAM_C_SUB_BG_0x06200000);

    int bg3 = bgInit(3, BgType_Bmp8, BgSize_B8_256x256, 0,0);
    dmaCopy(hey_typBitmap, bgGetGfxPtr(bg3), 256*256);
    dmaCopy(hey_typPal, BG_PALETTE, 256*2);

    int bg2 = bgInit(2, BgType_Bmp8, BgSize_B8_256x256, 0,0);
    dmaCopy(drunkenlogoBitmap, bgGetGfxPtr(bg2), 256*256);
    dmaCopy(drunkenlogoPal, BG_PALETTE, 256*2);

    while(1)swiWaitForVBlank();

    return 0;
}
Était-ce utile?

La solution

En mode 5 , la DS a 3 couches d'arrière-plan disponibles, et en appelant bgInit avec 2renvoie une référence à un calque différent sur le même écran.Si vous souhaitez utiliser un calque sur le sous-écran, utilisez bgInitSub.

Il y a aussi 2 palettes;un sur l'écran principal et un autre sur le sous-écran.La palette du sous-écran est au BG_PALETTE_SUB.

Espérons que ce code affichera l'image sur le deuxième écran (changements marqués avec /* ! */):

int main(void)
{
    videoSetMode(MODE_5_2D);
    vramSetBankA(VRAM_A_MAIN_BG_0x06000000);

    videoSetModeSub(MODE_5_2D);
    vramSetBankC(VRAM_C_SUB_BG_0x06200000);

    int bg3 = bgInit(3, BgType_Bmp8, BgSize_B8_256x256, 0,0);
    dmaCopy(hey_typBitmap, bgGetGfxPtr(bg3), 256*256);
    dmaCopy(hey_typPal, BG_PALETTE, 256*2);

    int bg3sub = bgInitSub(3, BgType_Bmp8, BgSize_B8_256x256, 0,0);  /* ! */
    dmaCopy(drunkenlogoBitmap, bgGetGfxPtr(bg3sub), 256*256);  /* ! */
    dmaCopy(drunkenlogoPal, BG_PALETTE_SUB, 256*2);  /* ! */

    while(1)swiWaitForVBlank();

    return 0;
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top