void Music::start(Music::Starting starting) { if (starting == Music::Starting::LOOP) mmStart(this->music, MM_PLAY_LOOP); else if (starting == Music::Starting::ONCE) mmStart(this->music, MM_PLAY_ONCE); }
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 soundtest() { tte_write("#{es}"); tte_write("#{P:0,0}GBA Sound Test\n"); tte_write("A song should now be playing.\n"); tte_write("Pressing B will exit.\n"); vid_vsync(); key_poll(); mmStart( MOD_SMACHOOSEAPLAYER, MM_PLAY_LOOP ); while(key_is_up(KEY_B)){ vid_vsync(); mmFrame(); key_poll(); } mmStop(); }
Sound::Sound() { mmInitDefaultMem((mm_addr)soundbank_bin); mmLoad(MOD_CASTLE_MUSIC); mmStart(MOD_CASTLE_MUSIC, MM_PLAY_LOOP); initEffects(); }
/* Exécute la demo ************************************************************ * --------------- ******************************************************************************/ void DemoPlay(void) { mmStart(0, MM_PLAY_LOOP); //CurrentPart = -1; //DemoAdvancePart(); CurrentPart = 0; DemoParts[0].init(); mmSetEventHandler(DemoParts[CurrentPart].sync); DemoParts[0].start_time = TimerMillis; while(1) { if(CurrentPart < NbParts) { DemoParts[CurrentPart].exec(TimerMillis - DemoParts[CurrentPart].start_time); if(DemoParts[CurrentPart].duration != 0) { if((TimerMillis - DemoParts[CurrentPart].start_time) >= DemoParts[CurrentPart].duration) { //DemoAdvancePart(); DemoParts[CurrentPart].deinit(); mmSetEventHandler(NULL); CurrentPart++; if(CurrentPart == NbParts) { ledBlink(PM_LED_BLINK); return; } DemoParts[CurrentPart].init(); mmSetEventHandler(DemoParts[CurrentPart].sync); DemoParts[CurrentPart].start_time = TimerMillis; } } } else { ledBlink(PM_LED_BLINK); return; } } }
DSGM_SoundInstance *DSGM_PlaySoundFull(DSGM_Sound *sound) { 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; } soundInstance->effectNumber = mmEffect(sound->ID - DSGM_soundStreamCount); mmEffectRelease(soundInstance->effectNumber); } soundInstance->volume = 255; soundInstance->panning = 128; return soundInstance; }
void game_manager::reinit_the_game() { curr_game_mode = gm_initializing_the_game; bios_wait_for_vblank(); gfx_manager::fade_out_to_white(15); gfx_manager::init_hud_vram_as_tiles_start_offset(); // Use video Mode 0, use 1D object mapping, enable forced blank, // display BG 0, BG 1, and objects. reg_dispcnt = dcnt_mode0 | dcnt_obj_1d | dcnt_blank_on | dcnt_bg0_on | dcnt_bg1_on | dcnt_obj_on; //// Use video Mode 0, use 1D object mapping, enable forced blank, //// and display BG 0, BG 1, BG 2, BG 3, and objects //reg_dispcnt = dcnt_mode0 | dcnt_obj_1d | dcnt_blank_on | dcnt_bg0_on // | dcnt_bg1_on | dcnt_bg2_on | dcnt_bg3_on | dcnt_obj_on; // Use screen base block 28 for BG0's Map. reg_bg0cnt = bgcnt_sbb(bg0_sbb) | bgcnt_prio(1); // Give BG1 a higher display priority than BG0. reg_bg1cnt = bgcnt_sbb(bg1_sbb) | bgcnt_prio(0); reg_bg2cnt = bgcnt_sbb(bg2_sbb) | bgcnt_prio(1); reg_bg3cnt = bgcnt_sbb(bg3_sbb) | bgcnt_prio(1); //u32 the_metatile_id = gfx_manager::get_metatile_number_of_block_type // (bt_eyes); //u32 the_palette_id = gfx_manager::get_palette_number_of_block_type // (bt_eyes); //u32 num_tiles_per_metatile = gfx_manager::num_tiles_in_ss_16x16; // //for ( u32 i=0; i<screenblock_size; ++i ) //{ // se_ram[bg1_sbb][i] // = se_id( the_metatile_id * num_tiles_per_metatile ) // | se_palbank(the_palette_id); //} //bios_wait_for_vblank(); //for ( u32 i=0; i<screenblock_size; ++i ) //{ // se_ram[bg1_sbb][i] = bt_wood * 4; //} // Copy the sprite palettes to OBJ Palette RAM. gfx_manager::upload_sprite_palettes_to_target(obj_pal_ram); //// Copy the sprite graphics to OBJ Video RAM. //gfx_manager::upload_default_sprite_graphics(); // Also, copy the_block_gfxPalLen to BG Palette RAM gfx_manager::upload_bg_palettes_to_target(bg_pal_ram); //bios_wait_for_vblank(); // Finally, copy the_block_gfxTiles to BG VRAM, screenblock 0 gfx_manager::upload_bg_tiles_to_vram(); //bios_wait_for_vblank(); sprite_manager::next_oam_index = 0; active_level_manager::load_level(&test_level); // Also, start playing music when the game is started. mmStart( MOD_PRACTICE_17, MM_PLAY_LOOP ); // An extra bios_wait_for_vblank() so that bios_wait_for_vblank(); gfx_manager::fade_out_to_white(1); // Disable forced blank clear_bits( reg_dispcnt, dcnt_blank_mask ); gfx_manager::fade_in(15); bios_wait_for_vblank(); //curr_game_mode = gm_in_sublevel; }
// Program entrypoint int main() { if (!mmIsARM7Loaded()) { printf("Couldn't load Maxmod!\n"); return 1; } // Init Maxmod with default settings (loading from FAR) mmInitDefaultFAR(hFar, "/soundbank.bin"); FeOS_DirectMode(); videoSetMode(MODE_0_2D); videoSetModeSub(0); vramSetBankA(VRAM_A_MAIN_SPRITE); // Initialize the sprite engine with 1D mapping 128 byte boundary // aand no external palette support oamInit(&oamMain, SpriteMapping_1D_32, false); int i; for (i = 0; i < 5; i ++) { // Allocate some space for the sprite graphics sprites[i].gfx = oamAllocateGfx(&oamMain, sprites[i].size, sprites[i].format); // Fill each sprite with a different index (2 pixels at a time) dmaFillHalfWords(((i+1) << 8) | (i+1), sprites[i].gfx, 32*32); } // Set indexes to different colours SPRITE_PALETTE[1] = RGB15(31,0,0); SPRITE_PALETTE[2] = RGB15(0,31,0); SPRITE_PALETTE[3] = RGB15(0,0,31); SPRITE_PALETTE[4] = RGB15(31,0,31); SPRITE_PALETTE[5] = RGB15(0,31,31); mmSetEventHandler(myEventHandler); mmLoad(MOD_EXAMPLE2); mmStart(MOD_EXAMPLE2, MM_PLAY_LOOP); for(;;) { swiWaitForVBlank(); if (keysDown() & KEY_START) break; for (i = 0; i < 5; i ++) { // Constantly increase the sprite's y velocity sprites[i].dy += 1; // Update the sprite's y position with its y velocity sprites[i].y += sprites[i].dy; // Clamp the sprite's y position if (sprites[i].y<72) sprites[i].y = 72; if (sprites[i].y>96) sprites[i].y = 96; oamSet(&oamMain, // Main graphics engine context i, // OAM index (0 to 127) sprites[i].x, // X and Y pixel location of the sprite sprites[i].y, 0, // Priority, lower renders last (on top) sprites[i].paletteAlpha, // Palette index sprites[i].size, sprites[i].format, sprites[i].gfx, // Pointer to the loaded graphics sprites[i].rotationIndex, // Sprite rotation data false, // Double the size when rotating? false, // Hide the sprite? false, false, // VFlip, HFlip false); // Apply mosaic } } mmStop(); mmUnload(MOD_EXAMPLE2); mmUnloadSoundbank(); FeOS_ConsoleMode(); return 0; }
//--------------------------------------------------------------------------------- int main(void) { //--------------------------------------------------------------------------------- int i = 0; videoSetMode(MODE_0_2D); videoSetModeSub(0); // not using subscreen lcdMainOnBottom(); //initialize the sprite engine with 1D mapping 128 byte boundary //and no external palette support oamInit(&oamMain, SpriteMapping_1D_32, false); vramSetBankA(VRAM_A_MAIN_SPRITE); for (i = 0; i < 5; i++) { //allocate some space for the sprite graphics sprites[i].gfx = oamAllocateGfx(&oamMain, sprites[i].size, sprites[i].format); //fill each sprite with a different index (2 pixels at a time) dmaFillHalfWords( ((i+1)<<8)|(i+1), sprites[i].gfx, 32*32); } //set indexes to different colours SPRITE_PALETTE[1] = RGB15(31,0,0); SPRITE_PALETTE[2] = RGB15(0,31,0); SPRITE_PALETTE[3] = RGB15(0,0,31); SPRITE_PALETTE[4] = RGB15(31,0,31); SPRITE_PALETTE[5] = RGB15(0,31,31); // initialise maxmod using default settings, and enable interface for soundbank that is loaded into memory mmInitDefaultMem( (mm_addr)mmsolution_bin ); // setup maxmod to use the song event handler mmSetEventHandler( myEventHandler ); // load song // values for this function are in the solution header mmLoad( MOD_EXAMPLE2 ); // start song playing mmStart( MOD_EXAMPLE2, MM_PLAY_LOOP ); while(1) { for (i=0; i < 5; i++) { // constantly increase the sprite's y velocity sprites[i].dy += 1; // update the sprite's y position with its y velocity sprites[i].y += sprites[i].dy; // clamp the sprite's y position if ( sprites[i].y<72 ) sprites[i].y = 72; if ( sprites[i].y>96 ) sprites[i].y = 96; oamSet( &oamMain, //main graphics engine context i, //oam index (0 to 127) sprites[i].x, //x and y pixel location of the sprite sprites[i].y, 0, //priority, lower renders last (on top) sprites[i].paletteAlpha, //palette index sprites[i].size, sprites[i].format, sprites[i].gfx, //pointer to the loaded graphics sprites[i].rotationIndex, //sprite rotation data false, //double the size when rotating? false, //hide the sprite? false, false, //vflip, hflip false //apply mosaic ); } swiWaitForVBlank(); //send the updates to the hardware oamUpdate(&oamMain); } return 0; }