DSGM_SoundInstance *DSGM_PlaySoundAdvancedFull(DSGM_Sound *sound, u8 volume, u8 panning) { DSGM_SoundInstance *soundInstance = DSGM_AddSoundInstance(sound); if(sound->type == DSGM_SOUND_STREAM) { if(!sound->loaded) { mmLoad(sound->ID); sound->loaded = true; } mmStart(sound->ID, MM_PLAY_LOOP); } else { if(!sound->loaded) { mmLoadEffect(sound->ID - DSGM_soundStreamCount); sound->loaded = true; } mm_sound_effect effect = { { sound->ID - DSGM_soundStreamCount } , (int)(1.0f * (1<<10)), // rate 0, // handle soundInstance->volume = volume, // volume (255 = max) soundInstance->panning = panning, // panning (128 = center) }; soundInstance->effectNumber = mmEffectEx(&effect); mmEffectRelease(soundInstance->effectNumber); } return soundInstance; }
void play_metrognome(void) { if (astrobe_enabled) { // play metrognome mmEffectEx(&sounds[SFX_METROGNOME]); } }
void Sound::play(int s) { mmEffectEx(&effects[s]); }
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); */ }
int main() { touchPosition touch; PrintConsole mainScreen; mySprite sprites[128]; lcdMainOnBottom(); initVideo(); initBackgrounds(); initConsole(&mainScreen); initSprites(sprites); //leftButtonOff oamSet(&oamMain, sprites[0].id, sprites[0].x, sprites[0].y, 0, 0, SpriteSize_64x64, SpriteColorFormat_16Color, sprites[0].gfx, -1, false, false, false, false, false); //rightButtonOff oamSet(&oamMain, sprites[2].id, sprites[2].x, sprites[2].y, 0, 0, SpriteSize_64x64, SpriteColorFormat_16Color, sprites[2].gfx, -1, false, false, false, false, false); int keys = keysDown(); int currentSprite = 4; int moveLeft = 0; int moveRight = 0; int MOVE_SPEED = 21; while (true) { //consoleClear(); scanKeys(); touchRead(&touch); keys = keysHeld(); if (keys) { if (keys & KEY_TOUCH) { touchRead(&touch); if (within(&touch, sprites[0])) { // leftButton clicked // leftButtonOn oamClearSprite(&oamMain, 0); oamSet(&oamMain, sprites[1].id, sprites[1].x, sprites[1].y, 0, 1, SpriteSize_64x64, SpriteColorFormat_16Color, sprites[1].gfx, -1, false, false, false, false, false); swiWaitForVBlank(); oamUpdate(&oamMain); moveLeft = 1; } else if (within(&touch, sprites[2])) { // rightButton clicked // rightButtonOn oamClearSprite(&oamMain, 2); oamSet(&oamMain, sprites[3].id, sprites[3].x, sprites[3].y, 0, 1, SpriteSize_64x64, SpriteColorFormat_16Color, sprites[3].gfx, -1, false, false, false, false, false); swiWaitForVBlank(); oamUpdate(&oamMain); moveRight = 1; } else if(within(&touch, sprites[currentSprite])) { mmEffectEx(&sprites[currentSprite].sfx); } } } else { //leftButtonOff oamClearSprite(&oamMain, 1); oamSet(&oamMain, sprites[0].id, sprites[0].x, sprites[0].y, 0, 0, SpriteSize_64x64, SpriteColorFormat_16Color, sprites[0].gfx, -1, false, false, false, false, false); //rightButtonOff oamClearSprite(&oamMain, 3); oamSet(&oamMain, sprites[2].id, sprites[2].x, sprites[2].y, 0, 0, SpriteSize_64x64, SpriteColorFormat_16Color, sprites[2].gfx, -1, false, false, false, false, false); if (moveLeft) { if ((currentSprite - 1) >= 4) { // move current sprite to the right and new one in from left int x1 = sprites[currentSprite].x; int x2 = -64; while (x1 < 280 || x2 < 96) { oamSet(&oamMain, sprites[currentSprite].id, x1, sprites[currentSprite].y, 0, sprites[currentSprite].paletteAlpha, SpriteSize_64x64, SpriteColorFormat_16Color, sprites[currentSprite].gfx, -1, false, false, false, false, false); oamSet(&oamMain, sprites[currentSprite-1].id, x2, sprites[currentSprite-1].y, 0, sprites[currentSprite-1].paletteAlpha, SpriteSize_64x64, SpriteColorFormat_16Color, sprites[currentSprite-1].gfx, -1, false, false, false, false, false); swiWaitForVBlank(); oamUpdate(&oamMain); x1 += MOVE_SPEED; x2 += MOVE_SPEED; } currentSprite--; } moveLeft = 0; } else if (moveRight) { if ((currentSprite + 1) - SPRITECOUNT < 0) { // move current sprite to the left and new one from right int x1 = sprites[currentSprite].x; int x2 = 256; while (x1 > -80 || x2 > 96) { oamSet(&oamMain, sprites[currentSprite].id, x1, sprites[currentSprite].y, 0, sprites[currentSprite].paletteAlpha, SpriteSize_64x64, SpriteColorFormat_16Color, sprites[currentSprite].gfx, -1, false, false, false, false, false); oamSet(&oamMain, sprites[currentSprite+1].id, x2, sprites[currentSprite+1].y, 0, sprites[currentSprite+1].paletteAlpha, SpriteSize_64x64, SpriteColorFormat_16Color, sprites[currentSprite+1].gfx, -1, false, false, false, false, false); swiWaitForVBlank(); oamUpdate(&oamMain); x1 -= MOVE_SPEED; x2 -= MOVE_SPEED; } currentSprite++; } moveRight = 0; } } //oamSet(oam, id, x, y, priority, palette_alpha, size, colorformat, gfxOffset, affineIndex, //sizedouble, hide, hflip, vflip, mosaic); // //gong consoleClear(); printf("\x1b[3;3H%s", sprites[currentSprite].desc); oamSet(&oamMain, sprites[currentSprite].id, sprites[currentSprite].x, sprites[currentSprite].y, 0, sprites[currentSprite].paletteAlpha, SpriteSize_64x64, SpriteColorFormat_16Color, sprites[currentSprite].gfx, -1, false, false, false, false, false); swiWaitForVBlank(); oamUpdate(&oamMain); } }