Aiuto - Cerca - Utenti - Calendario
Versione completa: più di una palette nds
.: GBArl.it :. News sulle Console Nintendo - Emulazione - Flash Cards - Trainer > Discussioni Console Nintendo > Discussioni Nintendo DS > Hardware e Utilità DS
nick98t
frantic4yc.gif aiuto!! 26.gif
mi aiutate a far funzionare questo codice??

CODICE
#include <nds.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

//---------------------------------------------------------------------------------
int main(void) {
    //---------------------------------------------------------------------------------
    int i = 0;

    videoSetMode(MODE_0_2D);
    videoSetModeSub(MODE_0_2D);

    vramSetBankA(VRAM_A_MAIN_SPRITE);
    vramSetBankD(VRAM_D_SUB_SPRITE);

    oamInit(&oamMain, SpriteMapping_1D_32, false);
    oamInit(&oamSub, SpriteMapping_1D_32, false);

    u16* gfx = oamAllocateGfx(&oamMain, SpriteSize_16x16, SpriteColorFormat_256Color);
    u16* gfxSub = oamAllocateGfx(&oamSub, SpriteSize_16x16, SpriteColorFormat_256Color);

    for(i = 0; i < 16 * 16 / 2; i++)
    {
        gfx[i] = 1 | (1 << 8);
        gfxSub[i] = 1 | (1 << 8);
    }

    SPRITE_PALETTE[0] = RGB15(0,31,0);
    SPRITE_PALETTE[1] = RGB15(31,0,0);
    oamSet(&oamMain, //main graphics engine context
    0,           //oam index (0 to 127)  
    0, 0,   //x and y pixle location of the sprite
    0,                    //priority, lower renders last (on top)
    0,                      //this is the palette index if multiple palettes or the alpha value if bmp sprite    
    SpriteSize_16x16,    
    SpriteColorFormat_256Color,
    gfx,                  //pointer to the loaded graphics
    -1,                  //sprite rotation data  
    false,               //double the size when rotating?
    false,            //hide the sprite?
    false, false, //vflip, hflip
    false    //apply mosaic
    );
    oamUpdate(&oamMain);
    oamSet(&oamMain, //main graphics engine context
    1,           //oam index (0 to 127)  
    16, 16,   //x and y pixle location of the sprite
    0,                    //priority, lower renders last (on top)
    1,                      //this is the palette index if multiple palettes or the alpha value if bmp sprite    
    SpriteSize_16x16,    
    SpriteColorFormat_256Color,
    gfx,                  //pointer to the loaded graphics
    -1,                  //sprite rotation data  
    false,               //double the size when rotating?
    false,            //hide the sprite?
    false, false, //vflip, hflip
    false    //apply mosaic
    );
    oamUpdate(&oamMain);
    while(1) {
        swiWaitForVBlank();
    }

    return 0;
}


l'obbiettivo sarebbe di creare 2 quadrati di colori diversi...
Aurelio
Prova così

CODICE
#include <nds.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

//---------------------------------------------------------------------------------
int main(void) {
    //---------------------------------------------------------------------------------
    int i = 0;

    videoSetMode(MODE_0_2D);
    videoSetModeSub(MODE_0_2D);

    vramSetBankA(VRAM_A_MAIN_SPRITE);
    vramSetBankD(VRAM_D_SUB_SPRITE);

    oamInit(&oamMain, SpriteMapping_1D_32, false);
    oamInit(&oamSub, SpriteMapping_1D_32, false);

    u16* gfx = oamAllocateGfx(&oamMain, SpriteSize_16x16, SpriteColorFormat_256Color);
    u16* gfxSub = oamAllocateGfx(&oamSub, SpriteSize_16x16, SpriteColorFormat_256Color);

    for(i = 0; i < 16 * 16 / 2; i++)
    {
        gfx[i] = 1 | (1 << 8);
        gfxSub[i] = 2 | (2 << 8);
    }

    SPRITE_PALETTE[1] = RGB15(0,31,0);  //L'indice 0 è bene lasciarlo per eventuali trasparenze
    SPRITE_PALETTE[2] = RGB15(31,0,0);
    oamSet(&oamMain, //main graphics engine context
    0,           //oam index (0 to 127)  
    0, 0,   //x and y pixle location of the sprite
    0,                    //priority, lower renders last (on top)
    0,                      //this is the palette index if multiple palettes or the alpha value if bmp sprite    
    SpriteSize_16x16,    
    SpriteColorFormat_256Color,
    gfx,                  //pointer to the loaded graphics
    -1,                  //sprite rotation data  
    false,               //double the size when rotating?
    false,            //hide the sprite?
    false, false, //vflip, hflip
    false    //apply mosaic
    );
    oamUpdate(&oamMain);
    oamSet(&oamMain, //main graphics engine context
    1,           //oam index (0 to 127)  
    16, 16,   //x and y pixle location of the sprite
    0,                    //priority, lower renders last (on top)
    0,                      //this is the palette index if multiple palettes or the alpha value if bmp sprite    
    SpriteSize_16x16,    
    SpriteColorFormat_256Color,
    gfx,                  //pointer to the loaded graphics
    -1,                  //sprite rotation data  
    false,               //double the size when rotating?
    false,            //hide the sprite?
    false, false, //vflip, hflip
    false    //apply mosaic
    );
    oamUpdate(&oamMain);
    while(1) {
        swiWaitForVBlank();
    }

    return 0;
}

nick98t
funziona ma comunque i due quadrati me li da dello stesso colore...
il mio obbiettivo erano 2 colori diversi...

CITAZIONE (Aurelio @ Monday 14 May 2012 - 19:01) *
Prova così

CODICE
#include <nds.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

//---------------------------------------------------------------------------------
int main(void) {
    //---------------------------------------------------------------------------------
    int i = 0;

    videoSetMode(MODE_0_2D);
    videoSetModeSub(MODE_0_2D);

    vramSetBankA(VRAM_A_MAIN_SPRITE);
    vramSetBankD(VRAM_D_SUB_SPRITE);

    oamInit(&oamMain, SpriteMapping_1D_32, false);
    oamInit(&oamSub, SpriteMapping_1D_32, false);

    u16* gfx = oamAllocateGfx(&oamMain, SpriteSize_16x16, SpriteColorFormat_256Color);
    u16* gfxSub = oamAllocateGfx(&oamSub, SpriteSize_16x16, SpriteColorFormat_256Color);

    for(i = 0; i < 16 * 16 / 2; i++)
    {
        gfx[i] = 1 | (1 << 8);
        gfxSub[i] = 2 | (2 << 8);
    }

    SPRITE_PALETTE[1] = RGB15(0,31,0);  //L'indice 0 è bene lasciarlo per eventuali trasparenze
    SPRITE_PALETTE[2] = RGB15(31,0,0);
    oamSet(&oamMain, //main graphics engine context
    0,           //oam index (0 to 127)  
    0, 0,   //x and y pixle location of the sprite
    0,                    //priority, lower renders last (on top)
    0,                      //this is the palette index if multiple palettes or the alpha value if bmp sprite    
    SpriteSize_16x16,    
    SpriteColorFormat_256Color,
    gfx,                  //pointer to the loaded graphics
    -1,                  //sprite rotation data  
    false,               //double the size when rotating?
    false,            //hide the sprite?
    false, false, //vflip, hflip
    false    //apply mosaic
    );
    oamUpdate(&oamMain);
    oamSet(&oamMain, //main graphics engine context
    1,           //oam index (0 to 127)  
    16, 16,   //x and y pixle location of the sprite
    0,                    //priority, lower renders last (on top)
    0,                      //this is the palette index if multiple palettes or the alpha value if bmp sprite    
    SpriteSize_16x16,    
    SpriteColorFormat_256Color,
    gfx,                  //pointer to the loaded graphics
    -1,                  //sprite rotation data  
    false,               //double the size when rotating?
    false,            //hide the sprite?
    false, false, //vflip, hflip
    false    //apply mosaic
    );
    oamUpdate(&oamMain);
    while(1) {
        swiWaitForVBlank();
    }

    return 0;
}

Aurelio
Ho ricontrollato bene il codice. L'errore che hai commesso sta nell'aver creato uno sprite nello schermo inferiore e poi nell'averlo gestito come se fosse nello schermo superiore. Prova a ricontrollare bene il codice, se poi non arrivi ad una soluzione, ti scrivo il codice corretto smile.gif
Nel caso contattami via PM così sicuramente vedo che hai bisogno di aiuto smile.gif
Questa è la versione 'lo-fi' del forum. Per visualizzare la versione completa con molte più informazioni, formattazione ed immagini, per favore clicca qui.
Invision Power Board © 2001-2024 Invision Power Services, Inc.