void advMultipleLayers(void) { videoSetMode(MODE_5_2D); vramSetBankA(VRAM_A_MAIN_BG); //initialize the backgrounds int bg1 = bgInit(0, BgType_Text8bpp, BgSize_ER_256x256, 0,1); int bg2 = bgInit(1, BgType_Text8bpp, BgSize_ER_256x256, 1,1); int bg3 = bgInit(2, BgType_ExRotation, BgSize_ER_256x256, 2,1); //make sure the floor is on the bottom (by default hardware layer 0 will be rendered last) bgSetPriority(bg1, 3); bgSetPriority(bg2, 2); bgSetPriority(bg3, 1); //they all share tiles and a palette dmaCopy(MultilayerTiles, bgGetGfxPtr(bg1), sizeof(MultilayerTiles)); dmaCopy(MultilayerPal, BG_PALETTE, sizeof(MultilayerPal)); //all we need to do is copy in the maps dmaCopy(Layer_1Map, bgGetMapPtr(bg1), Layer_1MapLen); dmaCopy(Layer_2Map, bgGetMapPtr(bg2), Layer_2MapLen); dmaCopy(Layer_3Map, bgGetMapPtr(bg3), Layer_3MapLen); int keys = 0; bool bg1_hidden = false; bool bg2_hidden = false; bool bg3_hidden = false; while(!(keys & KEY_B)) { scanKeys(); keys = keysDown(); if(keys & KEY_UP) bg1_hidden = !bg1_hidden; if(keys & KEY_DOWN) bg2_hidden = !bg2_hidden; if(keys & KEY_LEFT) bg3_hidden = !bg3_hidden; swiWaitForVBlank(); bg1_hidden ? bgHide(bg1) : bgShow(bg1); bg2_hidden ? bgHide(bg2) : bgShow(bg2); bg3_hidden ? bgHide(bg3) : bgShow(bg3); consoleClear(); iprintf("Press UP DOWN LEFT to toggle the layers\n\n"); iprintf("Floor (UP): %s\n", bg1_hidden ? "hidden" : "displayed"); iprintf("Walls (DOWN): %s\n", bg2_hidden ? "hidden" : "displayed"); iprintf("Decorations (LEFT): %s\n", bg3_hidden ? "hidden" : "displayed"); } }
void Display::modeSelektor(){ //Displaying bg3, and mode sprites bgSetPriority(this->subbg3, 1); DC_FlushAll(); dmaCopy(greyedBgSubTiles, bgGetGfxPtr(this->subbg3), greyedBgSubTilesLen); dmaCopy(greyedBgSubMap, bgGetMapPtr(this->subbg3), greyedBgSubMapLen); bgShow(subbg3); s8 i; for (i = 0; i < 4; ++i){ modesSprite->display(64 + i, 32 + 128 * (i % 2), 16 + 96 * (i / 2), OBJPRIORITY_0, i); } oamUpdate(&oamSub); input->paused = true; while(!(Cfg::modeSelector && input->pad->select() == DOWN) && input->modeSelektor() != 1){ swiWaitForVBlank(); } Cfg::modeSelector = false; oamClear(&oamSub, 64, 4); if (Cfg::mode == SLIDERS){ dmaCopy(slidersBg3SubTiles, bgGetGfxPtr(this->subbg3), slidersBg3SubTilesLen); dmaCopy(this->slidersBg3Map, bgGetMapPtr(this->subbg3), 1536); } else { bgSetPriority(this->subbg3, 2); bgHide(this->subbg3); } }
void updateCenter(AppState & state) { Point bottomLeft = state.convertBufferToScreen(Point(0,0)); Point topRight = state.convertBufferToScreen(Point(MY_BG_W,MY_BG_H)); Point newCenter = state.convertScreenToImage(Point(SCREEN_WIDTH/2, SCREEN_HEIGHT/2)); // printf("--------------\n"); // printf("%d %d\n", bottomLeft.x, bottomLeft.y); // printf("%d %d\n", topRight.x, topRight.y); // printf("%d %d\n", newCenter.x, newCenter.y); if (bottomLeft.x > 0 || bottomLeft.y > 0 || topRight.x < SCREEN_WIDTH || topRight.y < SCREEN_HEIGHT) { //Point newCenter = state.convertScreenToImage(Point(SCREEN_WIDTH/2, SCREEN_HEIGHT/2)); state.scroll_x = MY_BG_W/2-SCREEN_WIDTH/2; state.scroll_y = MY_BG_H/2-SCREEN_HEIGHT/2; state.center_x = newCenter.x; state.center_y = newCenter.y; // printf("%d %d\n", state.center_x, state.center_y); bgHide(3); fillDisplay(RGB15(0,0,0) | BIT(15), state.lastPage, state); drawPage(state.currentPage, RGB15(31,0,0) | BIT(15), state); } bgSetScroll(3, state.scroll_x, state.scroll_y); bgUpdate(); bgShow(3); }
void CargarPausa() { // Pone una transparencia cargarFondoNegro(Fondo2); REG_BLDCNT = BLEND_ALPHA | BLEND_SRC_BG2 | BLEND_DST_BG3 | BLEND_DST_SPRITE; REG_BLDALPHA = 3 << 1 | 1 << 10; bgShow(Fondo2); // Muestra los botones dibujar_botonContinuar(60, 20); dibujar_botonSalir(60, 110); // Inicializa las variables DesplazamientoAnimacion_Pausa = 0; BotonPulsado_Pausa = 0; }
void Display::editKaossParams(){ CCParam* ccParam = NULL; bgSetPriority(this->subbg3, 1); DC_FlushAll(); dmaCopy(greyedBgSubTiles, bgGetGfxPtr(this->subbg3), greyedBgSubTilesLen); dmaCopy(greyedBgSubMap, bgGetMapPtr(this->subbg3), greyedBgSubMapLen); bgShow(this->subbg3); while(!(Cfg::editParams && input->pad->start() == DOWN)){ for (u8 i = 0; i<3; ++i){ if (i == 0){ echo(0, RED, 5, 7 + 8*(i%8), "X"); ccParam = &Cfg::kaoss.x[Cfg::kaoss.bank]; } if (i == 1){ echo(0, RED, 5, 7 + 8*(i%8), "Y"); ccParam = &Cfg::kaoss.y[Cfg::kaoss.bank]; } if (i == 2){ echo(0, RED, 5, 7 + 8*(i%8), "Z"); ccParam = &Cfg::kaoss.z[Cfg::kaoss.bank]; } echo(0, WHITE, 8, 7 + 8*(i%8), "CC"); paramsEditSprite->display(16+i, 56 + 64*(i%8), 72, OBJPRIORITY_0, 0); iprintf("\x1b[%d;%dH%3d", 10, 6 + 8*(i%8), (*ccParam).cc); paramsEditSprite->display(32+i, 56 + 64*(i%8), 88, OBJPRIORITY_0, 1); echo(0, WHITE, 13, 7 + 8*(i%8), "CH"); paramsEditSprite->display(48+i, 56 + 64*(i%8), 112, OBJPRIORITY_0, 0); iprintf("\x1b[%d;%dH%3d", 15, 6 + 8*(i%8), 1 + (*ccParam).channel); paramsEditSprite->display(64+i, 56 + 64*(i%8), 128, OBJPRIORITY_0, 1); } oamUpdate(&oamSub); input->editKaossParams(); Cfg::editParams = true; swiWaitForVBlank(); } Cfg::editParams = false; save->write(); oamClear(&oamSub, 16, 80); consoleClear(); if (Cfg::mode == SLIDERS){ dmaCopy(slidersBg3SubTiles, bgGetGfxPtr(this->subbg3), slidersBg3SubTilesLen); dmaCopy(slidersBg3Map, bgGetMapPtr(this->subbg3), 1536); } else { bgSetPriority(this->subbg3, 2); bgHide(this->subbg3); } }
// PADS Functions //------------------------------------------------------------------------- void Display::pads(){ u8 noteStatus; char* noteName; clearGfx(); for (u8 i = 0; i < 12; ++i){ noteName = midi->getNoteName(i + Cfg::pads.baseNote); noteStatus = Cfg::notesStatus[Cfg::pads.channel][i + Cfg::pads.baseNote]; echo(0, 40, 22 - (i/4)*8, (i%4)*8 + 3, noteName); setPadSpriteFrame(i,noteStatus); } bgShow(mainbg3); echo(1, LIGHT_GREY, 1, 2, "CHANNEL:"); save->writeCcs(); }
void Display::editMixerParams(){ CCParam ccParam; bgSetPriority(this->subbg3, 1); DC_FlushAll(); dmaCopy(greyedBgSubTiles, bgGetGfxPtr(this->subbg3), greyedBgSubTilesLen); dmaCopy(greyedBgSubMap, bgGetMapPtr(this->subbg3), greyedBgSubMapLen); bgShow(this->subbg3); echo(0, RED, 0, 13, "MIXER"); echo(0, RED, 12, 13, "MUTES"); while(!(Cfg::editParams && input->pad->start() == DOWN)){ for (u8 i = 0; i<8; ++i){ ccParam = Cfg::mixer.ccs[i]; echo(0, WHITE, 2, 1 + 4*(i%8), "CC"); paramsEditSprite->display(16+i, 8 + 32*(i%8), 24, OBJPRIORITY_0, 0); iprintf("\x1b[%d;%dH%3d", 4, 4*(i%8), ccParam.cc); paramsEditSprite->display(32+i, 8 + 32*(i%8), 40, OBJPRIORITY_0, 1); echo(0, WHITE, 6, 1 + 4*(i%8), "CH"); paramsEditSprite->display(48+i, 8 + 32*(i%8), 56, OBJPRIORITY_0, 0); iprintf("\x1b[%d;%dH%3d", 8, 4*(i%8), 1 + ccParam.channel); paramsEditSprite->display(64+i, 8 + 32*(i%8), 72, OBJPRIORITY_0, 1); ccParam = Cfg::mixer.mutes[i]; echo(0, WHITE, 14, 1 + 4*(i%8), "CC"); paramsEditSprite->display(24+i, 8 + 32*(i%8), 120, OBJPRIORITY_0, 0); iprintf("\x1b[%d;%dH%3d", 16, 4*(i%8), ccParam.cc); paramsEditSprite->display(40+i, 8 + 32*(i%8), 136, OBJPRIORITY_0, 1); echo(0, WHITE, 18, 1 + 4*(i%8), "CH"); paramsEditSprite->display(56+i, 8 + 32*(i%8), 152, OBJPRIORITY_0, 0); iprintf("\x1b[%d;%dH%3d", 20, 4*(i%8), 1 + ccParam.channel); paramsEditSprite->display(72+i, 8 + 32*(i%8), 168, OBJPRIORITY_0, 1); } oamUpdate(&oamSub); input->editMixerParams(); Cfg::editParams = true; swiWaitForVBlank(); } save->write(); Cfg::editParams = false; oamClear(&oamSub, 16, 80); consoleClear(); }
void Display::editSliderParams(){ CCParam ccParam; u8 color; bgSetPriority(this->subbg3, 1); DC_FlushAll(); dmaCopy(greyedBgSubTiles, bgGetGfxPtr(this->subbg3), greyedBgSubTilesLen); dmaCopy(greyedBgSubMap, bgGetMapPtr(this->subbg3), greyedBgSubMapLen); bgShow(this->subbg3); while(!(Cfg::editParams && input->pad->start() == DOWN)){ for (u8 i = 0; i<16; ++i){ ccParam = Cfg::sliders.ccs[Cfg::sliders.bank][i]; color = Cfg::sliders.colors[Cfg::sliders.bank][i]; echo(0, WHITE, 12*(i/8) , 1 + 4*(i%8), "CC"); paramsEditSprite->display(16+i, 8 + 32*(i%8), 8 + 96*(i/8), OBJPRIORITY_0, 0); iprintf("\x1b[%d;%dH%3d", 2 + 12*(i/8) , 4*(i%8), ccParam.cc); paramsEditSprite->display(32+i, 8 + 32*(i%8), 24 + 96*(i/8), OBJPRIORITY_0, 1); echo(0, WHITE, 4+12*(i/8) , 1 + 4*(i%8), "CH"); paramsEditSprite->display(48+i, 8 + 32*(i%8), 40 + 96*(i/8), OBJPRIORITY_0, 0); iprintf("\x1b[%d;%dH%3d", 6 + 12*(i/8) , 4*(i%8), 1 + ccParam.channel); paramsEditSprite->display(64+i, 8 + 32*(i%8), 56 + 96*(i/8), OBJPRIORITY_0, 1); paramsEditSprite->display(80+i, 8 + 32*(i%8), 72 + 96*(i/8), OBJPRIORITY_0, color + 2); } oamUpdate(&oamSub); input->editSliderParams(); Cfg::editParams = true; swiWaitForVBlank(); } save->write(); Cfg::editParams = false; oamClear(&oamSub, 16, 80); consoleClear(); sliders(); }
void Display::connected(){ clearGfx(); bgShow(mainbg2); greyTempoLeds(); }
void showConsole(void) { bgShow(consoleId); }
void mode__intro__main___init(void) { // ooh, ahh, earcandy mmEffectEx(&sounds[SFX_STARTUP]); // initialize main screen // edunote: had tried MODE_5_3D here, but after 3D was actually used, // it would interfere with the bitmap showing. I think I'm // effectively bghiding all layers in intermode init, but // maybe I'm not, or maybe there is another way to hide the 3D // layer. Probably I should figure out how to render 3D on // top of a bitmap successfully. Then the rest might follow. videoSetMode(MODE_5_2D); // map main screen background fourth (128k) region to vram bank A vramSetBankA(VRAM_A_MAIN_BG_0x06060000); // NOTE: current half educated assumption is that or-ing together // bg enabled layers here is nothing but effectively an // advanced call to bgShow, which is also a part of bgInit // NOTE2: after some time, I'm convinced of the above, and about // to write a function bg_init_hidden() videoSetModeSub(MODE_5_2D); // map sub screen background (only? 1/4?) to vram bank C vramSetBankC(VRAM_C_SUB_BG); mcp_console_init(&bottom_screen, MCP_SUB_SCREEN, 0, 1, 1, BgType_Text4bpp, BgSize_T_256x256, 31, 0); // set printf sink consoleSelect(&bottom_screen); // set console background layer to top priority bgSetPriority(bottom_screen.bgId, 0); // note: this must be done _after_ consoleInit (as that resets it) // and _after_ loading our 8bit indexed bitmap reloads it // set to black to allow renderer to really control BG_PALETTE_SUB[255] = RGB15(0, 0, 0); // show the console layer mcp_bg_show(MCP_SUB_SCREEN, 0); // default to fully faded (to black) mcp_set_blend(MCP_MAIN_SCREEN, MCP_MAX_BLEND_LEVEL); mcp_set_blend(MCP_SUB_SCREEN, MCP_MAX_BLEND_LEVEL); // fade the mainscreen background to/from black, layer 3 REG_BLDCNT = BLEND_FADE_BLACK | BLEND_SRC_BG3; // fade the lava background to/from black, layer 3 REG_BLDCNT_SUB = BLEND_FADE_BLACK | BLEND_SRC_BG2; // init subscreen layer/background 3 // the mapbase offset of 24 here means 24*16k which means utilizing // the 4th of the possible main background memory regions that vram // bank A can be mapped to. I.e. above we mapped to the 4th. Had // we mapped to the 1st, we would have used offset 0. // note: vram bank A is 128k, i.e. 8 * 16k. // note: *16k is because of bitmap type, else would be *2k // bg3 = bgInit(3, BgType_Bmp16, BgSize_B16_256x256, 24, 0); bg3 = mcp_bg_init(MCP_MAIN_SCREEN, 3, MCP_BG_HIDE, BgType_Bmp16, BgSize_B16_256x256, 24, 0); // its initial priority, lowest (to emphasize lack of other enabled layers) // note: priorities 0..3, 0 highest priority bgSetPriority(bg3, 3); // mcp_bg_init covers this // maybe this prevents flicker during decompress // bgHide(bg3); // load main splash screen into screen/background memory (bgs3) decompress(guitar_zyx_splash_mainBitmap, (u16*)bgGetGfxPtr(bg3), LZ77Vram); // maybe this prevents flicker during decompress mcp_bg_show(MCP_MAIN_SCREEN, 3); // note: using offset=4, because 4 will be 64k offset, where 31 above is 62k // (thus above using only 2k? seems plausible with tiles for console text chars // bgs2 = bgInitSub(2, BgType_Bmp8, BgSize_B8_256x256, 4, 0); bgs2 = mcp_bg_init(MCP_SUB_SCREEN, 2, MCP_BG_HIDE, BgType_Bmp8, BgSize_B8_256x256, 4, 0); // its initial priority, lowest (to emphasize lack of other enabled layers) // priorities 0..3, 0 highest priority bgSetPriority(bgs2, 2); // mcp_bg_init covers this // bgHide(bgs2); // note: as per libnds doc on dma, do the flush first DC_FlushRange(dlavaBitmap, 256*256); dmaCopy(dlavaBitmap, bgGetGfxPtr(bgs2), 256*256); DC_FlushRange(dlavaPal, 256*2); dmaCopy(dlavaPal, BG_PALETTE_SUB, 256*2); bgShow(bgs2); // reinitialize the text color BG_PALETTE_SUB[255] = RGB15(0, 0, 0); /* bad experiment, but probably will use later anyway) consoleInit(&bottom_screen_x, 3, BgType_ExRotation, BgSize_ER_256x256, 31, 1, false, false); // custom 8bpp font mcpfont.asciiOffset = 32; mcpfont.bpp = 8; mcpfont.convertSingleColor = false; mcpfont.gfx = (u16*)mcpfontTiles; mcpfont.numChars = 95; mcpfont.numColors = mcpfontPalLen / 2; mcpfont.pal = (u16*)mcpfontPal; consoleSetFont(&bottom_screen, &mcpfont); // set console background layer to top priority bgSetPriority(bottom_screen_x.bgId, 0); bgShow(bottom_screen_x.bgId); */ }
void mode__intro__credits___init(void) { // initialize main screen videoSetMode(MODE_5_2D); // map main screen background fourth (128k) region to vram bank A vramSetBankA(VRAM_A_MAIN_BG_0x06060000); // set the secondary/sub screen for text and a background videoSetModeSub(MODE_5_2D); // map sub screen background (only? 1/4?) to vram bank C vramSetBankC(VRAM_C_SUB_BG); // FRAK, may need to reimplement this with mcp_bg_init... // XXX: time will tell if this flickers consoleInit(&bottom_screen, 0, BgType_Text4bpp, BgSize_T_256x256, 31, 0, false, true); // set printf sink consoleSelect(&bottom_screen); // set console background layer to top priority bgSetPriority(bottom_screen.bgId, 0); // note: this must be done _after_ consoleInit (as that resets it) // and _after_ loading our 8bit indexed bitmap reloads it // set to black to allow renderer to really control BG_PALETTE_SUB[255] = RGB15(0, 0, 0); // unfaded mcp_set_blend(MCP_MAIN_SCREEN, MCP_MAX_BLEND_LEVEL); mcp_set_blend(MCP_SUB_SCREEN, MCP_MAX_BLEND_LEVEL); // fade the mainscreen background to/from black, layer 3 REG_BLDCNT = BLEND_FADE_BLACK | BLEND_SRC_BG3; // fade the lava background to/from black, layer 3 REG_BLDCNT_SUB = BLEND_FADE_BLACK | BLEND_SRC_BG3; // init subscreen layer/background 3 // the mapbase offset of 24 here means 24*16k which means utilizing // the 4th of the possible main background memory regions that vram // bank A can be mapped to. I.e. above we mapped to the 4th. Had // we mapped to the 1st, we would have used offset 0. // note: vram bank A is 128k, i.e. 8 * 16k. // note: *16k is because of bitmap type, else would be *2k // bg3 = bgInit(3, BgType_Bmp16, BgSize_B16_256x256, 24, 0); bg3 = mcp_bg_init(MCP_MAIN_SCREEN, 3, MCP_BG_HIDE, BgType_Bmp16, BgSize_B16_256x256, 24, 0); // its initial priority, lowest (to emphasize lack of other enabled layers) // priorities 0..3, 0 highest priority bgSetPriority(bg3, 3); // bgHide(bg3); // load main splash screen into screen/background memory (bgs3) // note: if I wanted to do this quickly/perfectly/doublebufferred somehow // I'm not sure if I'd need to tweak the bgInitSub offset or pointer // here or some such. As it is, the fade to black ensures no tear // as this new image gets loaded into display memory. decompress(guitar_zyx_splash_creditsBitmap, (u16*)bgGetGfxPtr(bg3), LZ77Vram); bgShow(bg3); // note: using offset=4, because 4 will be 64k offset, where 31 above is 62k // (thus above using only 2k? seems plausible with tiles for console text chars // NOTE: if this flickers, could try 2 instead of 3 bgs3 = mcp_bg_init(MCP_SUB_SCREEN, 3, MCP_BG_HIDE, BgType_Bmp8, BgSize_B8_256x256, 4, 0); // its initial priority, lowest (to emphasize lack of other enabled layers) // priorities 0..3, 0 highest priority bgSetPriority(bgs3, 2); // bgHide(bgs3); // as per libnds doc on dma DC_FlushRange(dlavaBitmap, 256*256); dmaCopy(dlavaBitmap, bgGetGfxPtr(bgs3), 256*256); DC_FlushRange(dlavaPal, 256*2); dmaCopy(dlavaPal, BG_PALETTE_SUB, 256*2); bgShow(bgs3); BG_PALETTE_SUB[255] = RGB15(0, 0, 0); }