void initialize_sound_system () { ASND_Init(); MP3Player_Init(); soundMatrix_sounds = 0; soundMatrix = (sndCore_sound *)malloc(sizeof(sndCore_sound) * soundMatrix_sounds); }
int sound_init_asnd() { ASND_Init(); ASND_Pause(0); ordenador.sign=0; ordenador.format=2; //16 bit BE ordenador.channels=2; //stereo ordenador.freq=48000; ordenador.buffer_len=4096; started_sound_asnd = 0; return 0; }
//--------------------------------------------------------------------------------- // main! //--------------------------------------------------------------------------------- int main(int argc, char **argv) { #ifdef PLATFORM_IS_WII try { // Setup the remote debugger if possible... DEBUG_Init(GDBSTUB_DEVICE_USB, 1); // Initialize filesystem to load from SD Card - This should change to NAND for official releases ... fatInitDefault(); for(int i = 0; i < 100; i++) { usleep(100); } //setupTrace("//Map.csv"); srand ( time(NULL) ); AUDIO_Init(NULL); ASND_Init(); ASND_Pause(0); //setupUnitTesting(); RunGameMain(); ASND_Pause(1); ASND_End(); //MemTrack::TrackListMemoryUsage(); //shutDownTrace(); } catch(int ex) { printf("\x1b[2;0H");printf("Exception Triggered, Executing Breakpoint!\n"); ASSERT(false); _break(); } #endif #ifdef PLATFORM_IS_WIN runUnitTests(); #endif return 0; }
void WiiInit() { extern const devoptab_t dotab_stdnull; devoptab_list[STD_OUT] = &dotab_stdnull; devoptab_list[STD_ERR] = &dotab_stdnull; //USBGeckoOutput(); // uncomment to enable USB gecko output __exception_setreload(8); fatInitDefault(); ASND_Init(); SetupPads(); InitFreeType((u8*)font_ttf, font_ttf_size); LWP_CreateThread (&keythread, PressKeys, NULL, NULL, 0, 65); appPath[0] = 0; }
/**************************************************************************** * SwitchAudioMode * * Switches between menu sound and emulator sound ***************************************************************************/ static void SwitchAudioMode(int mode) { if(mode == 0) // emulator { ASND_Pause(1); AUDIO_StopDMA(); WII_AudioStart(); } else // menu { WII_AudioStop(); ASND_Init(); ASND_Pause(0); } }
/*** gx_audio_Stop This function stops current Audio DMA process This is called when going back to Main Menu ***/ void gx_audio_Stop(void) { /* restart menu audio processing */ DSP_Unhalt(); ASND_Init(); ASND_Pause(0); /* play background music */ if (Bg_music_ogg && !Shutdown) { PauseOgg(0); PlayOgg((char *)Bg_music_ogg, Bg_music_ogg_size, 0, OGG_INFINITE_TIME); SetVolumeOgg(((int)config.bgm_volume * 255) / 100); } }
/* Plays a MP3 file */ void mp3_player(file_handle* allFiles, int numFiles, file_handle* curFile) { // Initialise the audio subsystem ASND_Init(); MP3Player_Init(); // Find all the .mp3 files in the set of allFiles, and also where our file is. int curMP3 = 0, i = 0; for(i = 0; i < numFiles; i++) { if(!strcmp(allFiles[i].name,curFile->name)) { curMP3 = i; break; } } int first = 1; for(i = curMP3; i < numFiles; i++) { int ret = PLAYER_NEXT; if(!first && useShuffle) { i = (rand() % numFiles); } // if it's .mp3 if((strlen(allFiles[i].name)>4) && endsWith(allFiles[i].name,".mp3")) { ret = play_mp3(&allFiles[i], numFiles, i); } if(ret == PLAYER_STOP) { break; } if(ret == PLAYER_PREV) { i-=2; } first = 0; } MP3Player_Stop(); }
/* AUDIO engine initialization */ void gx_audio_Init(void) { /* Initialize AUDIO processing library (ASNDLIB) */ /* AUDIO & DSP hardware are initialized */ /* Default samplerate is set to 48kHz */ ASND_Init(); /* Load background music from FAT device */ char fname[MAXPATHLEN]; sprintf(fname,"%s/Bg_music.ogg",DEFAULT_PATH); FILE *f = fopen(fname,"rb"); if (f) { struct stat filestat; stat(fname, &filestat); Bg_music_ogg_size = filestat.st_size; Bg_music_ogg = memalign(32,Bg_music_ogg_size); if (Bg_music_ogg) { fread(Bg_music_ogg,1,Bg_music_ogg_size,f); } fclose(f); } }
/**************************************************************************** * InitAudio * * Initializes the Wii's audio subsystem ***************************************************************************/ void InitAudio() { AUDIO_Init(NULL); ASND_Init(); ASND_Pause(0); }
void _Music_Start() { int ret; // always init SND, so banner sounds play if music disabled ASND_Init(); ASND_Pause(0); if (CFG.music == 0) { dbg_printf(gt("Music: Disabled")); dbg_printf("\n"); return; } else { dbg_printf(gt("Music: Enabled")); dbg_printf("\n"); } was_playing = false; //get a music file ret = get_music_file(); if (ret==0) return; if (music_format == FORMAT_MP3) { MP3Player_Init(); MP3Player_Volume(0x80); // of 255 //ret = MP3Player_PlayBuffer(music_buf, music_size, NULL); ret = MP3Player_PlayFile(music_f, mp3_reader, NULL); dbg_printf("mp3 play: %s (%d)\n", ret? gt("ERROR"):gt("OK"), ret); if (ret) goto err_play; usleep(10000); // wait 10ms and verify if playing if (!MP3Player_IsPlaying()) { err_play: printf(gt("Error playing %s"), music_fname); printf("\n"); Music_Stop(); sleep(1); } } else { music_buf = malloc(music_size); if (!music_buf) { printf(gt("music file too big (%d) %s"), music_size, music_fname); printf("\n"); sleep(1); music_format = 0; return; } //printf("Loading...\n"); ret = fread(music_buf, music_size, 1, music_f); //printf("size: %d %d\n", music_size, ret); sleep(2); fclose(music_f); music_f = NULL; if (ret != 1) { printf(gt("error reading: %s (%d)"), music_fname, music_size); printf("\n"); sleep(2); free(music_buf); music_buf = NULL; music_size = 0; music_format = 0; return; } MODPlay_Init(&mod); ret = MODPlay_SetMOD(&mod, music_buf); dbg_printf("mod play: %s (%d)\n", ret?gt("ERROR"):gt("OK"), ret); if (ret < 0 ) { Music_Stop(); } else { MODPlay_SetVolume(&mod, 32,32); // fix the volume to 32 (max 64) MODPlay_Start(&mod); // Play the MOD } } }
//--------------------------------------------------------------------------------- int main(int argc, char **argv) { //--------------------------------------------------------------------------------- // Initialise the video system VIDEO_Init(); // Initialise the attached controllers PAD_Init(); // Initialise the audio subsystem ASND_Init(); MP3Player_Init(); // Obtain the preferred video mode from the system // This will correspond to the settings in the Wii menu rmode = VIDEO_GetPreferredMode(NULL); // Allocate memory for the display in the uncached region xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode)); // Initialise the console, required for printf console_init(xfb,20,20,rmode->fbWidth,rmode->xfbHeight,rmode->fbWidth*VI_DISPLAY_PIX_SZ); // Set up the video registers with the chosen mode VIDEO_Configure(rmode); // Tell the video hardware where our display memory is VIDEO_SetNextFramebuffer(xfb); // Make the display visible VIDEO_SetBlack(FALSE); // Flush the video register changes to the hardware VIDEO_Flush(); // Wait for Video setup to complete VIDEO_WaitVSync(); if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync(); // The console understands VT terminal escape codes // This positions the cursor on row 2, column 0 // we can use variables for this with format codes too // e.g. printf ("\x1b[%d;%dH", row, column ); printf("\x1b[2;0H"); printf("Playing sample MP3 file...Press HOME to exit.\n"); MP3Player_PlayBuffer(sample_mp3, sample_mp3_size, NULL); while(1) { // Call PAD_ScanPads each loop, this reads the latest controller states PAD_ScanPads(); // PAD_ButtonsDown tells us which buttons were pressed in this loop // this is a "one shot" state which will not fire again until the button has been released u32 pressed = PAD_ButtonsDown(0); // We return to the launcher application via exit if ( pressed & PAD_BUTTON_START ) exit(0); // Wait for the next frame VIDEO_WaitVSync(); } return 0; }
void legal () { int count = 2000; int vis = 0; #ifdef HW_RVL gx_texture *button = gxTextureOpenPNG(Key_A_wii_png,0); #else gx_texture *button = gxTextureOpenPNG(Key_A_gcn_png,0); #endif gx_texture *logo_left= gxTextureOpenPNG(Bg_intro_c5_png,0); gx_texture *logo_right = gxTextureOpenPNG(Bg_intro_c4_png,0); gxClearScreen((GXColor)BLACK); show_disclaimer(56); gxDrawTexture(logo_left, (640-logo_left->width-logo_right->width -32)/2, 480-logo_left->height-24, logo_left->width, logo_left->height,255); gxDrawTexture(logo_right, (640-logo_left->width-logo_right->width -32)/2+logo_left->width+32, 480-logo_right->height-24, logo_right->width, logo_right->height,255); gxSetScreen(); sleep(1); while (!(m_input.keys & PAD_BUTTON_A) && (count > 0)) { gxClearScreen((GXColor)BLACK); show_disclaimer(56); if (count%25 == 0) vis^=1; if (vis) { FONT_writeCenter("Press button to continue.",24,0,640,366,(GXColor)SKY_BLUE); gxDrawTexture(button, 220, 366-24+(24-button->height)/2, button->width, button->height,255); } gxDrawTexture(logo_left, (640-logo_left->width-logo_right->width -32)/2, 480-logo_left->height-24, logo_left->width, logo_left->height,255); gxDrawTexture(logo_right, (640-logo_left->width-logo_right->width -32)/2+logo_left->width+32, 480-logo_right->height-24, logo_right->width, logo_right->height,255); gxSetScreen(); count--; } gxTextureClose(&button); gxTextureClose(&logo_left); gxTextureClose(&logo_right); if (count > 0) { ASND_Init(); ASND_Pause(0); int voice = ASND_GetFirstUnusedVoice(); ASND_SetVoice(voice,VOICE_MONO_16BIT,44100,0,(u8 *)button_select_pcm,button_select_pcm_size,200,200,NULL); GUI_FadeOut(); ASND_Pause(1); ASND_End(); return; } gxClearScreen((GXColor)BLACK); gx_texture *texture = gxTextureOpenPNG(Bg_intro_c1_png,0); if (texture) { gxDrawTexture(texture, (640-texture->width)/2, (480-texture->height)/2, texture->width, texture->height,255); if (texture->data) free(texture->data); free(texture); } gxSetScreen(); sleep (1); gxClearScreen((GXColor)WHITE); texture = gxTextureOpenPNG(Bg_intro_c2_png,0); if (texture) { gxDrawTexture(texture, (640-texture->width)/2, (480-texture->height)/2, texture->width, texture->height,255); if (texture->data) free(texture->data); free(texture); } gxSetScreen(); sleep (1); gxClearScreen((GXColor)BLACK); texture = gxTextureOpenPNG(Bg_intro_c3_png,0); if (texture) { gxDrawTexture(texture, (640-texture->width)/2, (480-texture->height)/2, texture->width, texture->height,255); if (texture->data) free(texture->data); free(texture); } gxSetScreen(); ASND_Pause(0); int voice = ASND_GetFirstUnusedVoice(); ASND_SetVoice(voice,VOICE_MONO_16BIT,44100,0,(u8 *)intro_pcm,intro_pcm_size,200,200,NULL); sleep (2); ASND_Pause(1); }
// nyanise the system void nyan() { // subsystem VIDEO_Init(); WPAD_Init(); ASND_Init(); MP3Player_Init(); // video setup wichFb = 0; rmode = VIDEO_GetPreferredMode(NULL); xfb[0] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode)); xfb[1] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode)); VIDEO_Configure(rmode); VIDEO_SetNextFramebuffer(xfb[wichFb]); VIDEO_Flush(); VIDEO_WaitVSync(); if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync(); wichFb ^= 1; // setup the fifo and then init gx gp_fifo = memalign(32, DEFAULT_FIFO_SIZE); memset(gp_fifo, 0, DEFAULT_FIFO_SIZE); GX_Init(gp_fifo, DEFAULT_FIFO_SIZE); // other gx setup GX_SetViewport(0, 0, rmode->fbWidth, rmode->efbHeight, 0, 1); yscale = GX_GetYScaleFactor(rmode->efbHeight, rmode->xfbHeight); xfbHeight = GX_SetDispCopyYScale(yscale); GX_SetScissor(0, 0, rmode->fbWidth, rmode->efbHeight); GX_SetDispCopySrc(0, 0, rmode->fbWidth, rmode->efbHeight); GX_SetDispCopyDst(rmode->fbWidth, xfbHeight); GX_SetCopyFilter(rmode->aa, rmode->sample_pattern, GX_TRUE, rmode->vfilter); GX_SetFieldMode(rmode->field_rendering, ((rmode->viHeight==2*rmode->xfbHeight) ? GX_ENABLE : GX_DISABLE)); if (rmode->aa) GX_SetPixelFmt(GX_PF_RGB565_Z16, GX_ZC_LINEAR); else GX_SetPixelFmt(GX_PF_RGB8_Z24, GX_ZC_LINEAR); GX_SetCullMode(GX_CULL_NONE); GX_CopyDisp(xfb[wichFb], GX_TRUE); GX_SetDispCopyGamma(GX_GM_1_0); GX_SetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE); GX_SetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_CLEAR); GX_SetAlphaUpdate(GX_TRUE); GX_SetColorUpdate(GX_TRUE); GX_SetCopyClear(background, 0x00ffffff); // empty the vertex descriptor GX_InvVtxCache(); GX_InvalidateTexAll(); GX_ClearVtxDesc(); GX_SetVtxDesc(GX_VA_POS, GX_DIRECT); GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT); GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XY, GX_F32, 0); GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0); // tev is like shadow for me (i don't really understand these Chans, and TevOps-nyan-thing things) GX_SetNumChans(1); GX_SetNumTexGens(1); GX_SetTevOp(GX_TEVSTAGE0, GX_REPLACE); GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0); GX_SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY); GX_InvalidateTexAll(); // Load the spriteSheet TPLFile spriteTPL; TPL_OpenTPLFromMemory(&spriteTPL, (void *)textures_tpl, textures_tpl_size); TPL_GetTexture(&spriteTPL, spritesheet, &spriteSheetTexture); // no filtering plz GX_InitTexObjLOD(&spriteSheetTexture, GX_NEAR, GX_NEAR, 0.0f, 0.0f, 0.0f, GX_FALSE, GX_FALSE, GX_ANISO_1); GX_LoadTexObj(&spriteSheetTexture, GX_TEXMAP0); // Load texture in slot 0 into gx // Setup the view GX_SetViewport(0, 0, rmode->fbWidth, rmode->efbHeight, 0, 1); guOrtho(perspective, 0, 479, 0, 639, 0, 300); GX_LoadProjectionMtx(perspective, GX_ORTHOGRAPHIC); startTime = ticks_to_millisecs(gettime()); bkgTimeCounter = startTime; nyanTimeCounter = startTime; currentBkgStep = 0; currentNyanStep = 0; }