int sndMatrix_add_sound_from_file (const char filename[255]) { FILE * sound_file; int sound_file_size; sound_file = fopen (filename, "rb"); fseek(sound_file, 0, SEEK_END); sound_file_size = ftell(sound_file); rewind(sound_file); // Add a new entry in the matrix and make some space for it ++soundMatrix_sounds; soundMatrix = (sndCore_sound **)realloc(soundMatrix, sizeof(sndCore_sound*) * soundMatrix_sounds); // Allocate some space for the sound buffer soundMatrix[0][soundMatrix_sounds]->sound_buffer = (u8 *)malloc(sizeof(u8) * sound_file_size); // Fill the sndCore_sound structure soundMatrix[0][soundMatrix_sounds]->id = 666; soundMatrix[0][soundMatrix_sounds]->sound_type = SOUND_MP3; if (soundMatrix[0][soundMatrix_sounds]->sound_type == SOUND_SFX) soundMatrix[0][soundMatrix_sounds]->sound_voice = ASND_GetFirstUnusedVoice(); soundMatrix[0][soundMatrix_sounds]->sound_volume = 100; soundMatrix[0][soundMatrix_sounds]->sound_time = 0; fread(soundMatrix[0][soundMatrix_sounds]->sound_buffer, 1, sound_file_size, sound_file); fclose(sound_file); return soundMatrix[0][soundMatrix_sounds]->id; }
void GuiSound::Play() { switch (type) { case SOUND_PCM: xenon_sound_submit((void*)sound,length); break; } #ifndef NO_SOUND int vol; switch (type) { case SOUND_PCM: vol = 255 * (volume / 100.0); voice = ASND_GetFirstUnusedVoice(); if (voice >= 0) ASND_SetVoice(voice, VOICE_STEREO_16BIT, 48000, 0, (u8 *) sound, length, vol, vol, NULL); break; case SOUND_OGG: voice = 0; if (loop) PlayOgg((char *) sound, length, 0, OGG_INFINITE_TIME); else PlayOgg((char *) sound, length, 0, OGG_ONE_TIME); SetVolumeOgg(255 * (volume / 100.0)); break; } #endif }
void config_default(void) { /* version TAG */ strncpy(config.version,CONFIG_VERSION,16); /* sound options */ config.psg_preamp = 150; config.fm_preamp = 100; config.hq_fm = 1; config.psgBoostNoise = 1; config.filter = 1; config.lp_range = 0x9999; /* 0.6 in 16.16 fixed point */ config.low_freq = 880; config.high_freq = 5000; config.lg = 1.0; config.mg = 1.0; config.hg = 1.0; config.dac_bits = 14; config.ym2413 = 2; /* AUTO */ config.mono = 0; /* system options */ config.system = 0; /* AUTO */ config.region_detect = 0; /* AUTO */ config.vdp_mode = 0; /* AUTO */ config.master_clock = 0; /* AUTO */ config.force_dtack = 0; config.addr_error = 1; config.bios = 0; config.lock_on = 0; config.hot_swap = 0; /* video options */ config.xshift = 0; config.yshift = 0; config.xscale = 0; config.yscale = 0; config.aspect = 1; config.overscan = 3; /* FULL */ config.gg_extra = 0; config.lcd = 0; config.ntsc = 0; config.vsync = 1; /* AUTO */ config.bilinear = 0; config.vfilter = 1; if (VIDEO_HaveComponentCable()) { config.render = 2; } else { config.render = 0; } switch (vmode->viTVMode >> 2) { case VI_PAL: config.tv_mode = 1; /* 50hz only */ break; case VI_EURGB60: config.tv_mode = 2; /* 50/60hz */ break; default: config.tv_mode = 0; /* 60hz only */ break; } #ifdef HW_RVL config.trap = 0; config.gamma = VI_GM_1_0 / 10.0; #else config.v_prog = 1; #endif /* NTSC filter options */ config.ntsc_sharpness = 0.0; config.ntsc_resolution = 0.0; config.ntsc_artifacts = 0.0; config.ntsc_fringing = 0.0; config.ntsc_bleed = 0.0; /* controllers options */ config.gun_cursor[0] = 1; config.gun_cursor[1] = 1; config.invert_mouse = 0; /* on-screen options */ config.cd_leds = 0; config.fps = 0; /* menu options */ config.autoload = 0; config.autocheat = 0; config.s_auto = 1; config.s_default = 1; config.s_device = 0; config.bg_overlay = 0; config.screen_w = 658; config.bgm_volume = 100.0; config.sfx_volume = 100.0; #ifdef HW_RVL config.autosleep = 1; config.calx = 0; config.caly = 0; #endif /* default ROM directories */ #ifdef HW_RVL DIR *dir = opendir("sd:/"); if (dir) { config.l_device = TYPE_SD; closedir(dir); } else { config.l_device = TYPE_USB; } sprintf (config.lastdir[0][TYPE_SD], "sd:%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[1][TYPE_SD], "sd:%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[2][TYPE_SD], "sd:%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[3][TYPE_SD], "sd:%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[4][TYPE_SD], "sd:%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[0][TYPE_USB], "usb:%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[1][TYPE_USB], "usb:%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[2][TYPE_USB], "usb:%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[3][TYPE_USB], "usb:%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[4][TYPE_USB], "usb:%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[0][TYPE_DVD], "dvd:%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[1][TYPE_DVD], "dvd:%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[2][TYPE_DVD], "dvd:%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[3][TYPE_DVD], "dvd:%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[4][TYPE_DVD], "dvd:%s/roms/", DEFAULT_PATH); #else config.l_device = TYPE_SD; sprintf (config.lastdir[0][TYPE_SD], "%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[1][TYPE_SD], "%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[2][TYPE_SD], "%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[3][TYPE_SD], "%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[4][TYPE_SD], "%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[0][TYPE_DVD], "dvd:%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[1][TYPE_DVD], "dvd:%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[2][TYPE_DVD], "dvd:%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[3][TYPE_DVD], "dvd:%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[4][TYPE_DVD], "dvd:%s/roms/", DEFAULT_PATH); #endif /* system ROM paths */ sprintf (config.sys_rom[0], "%s/bios/bios_CD_U.bin", DEFAULT_PATH); sprintf (config.sys_rom[1], "%s/bios/bios_CD_E.bin", DEFAULT_PATH); sprintf (config.sys_rom[2], "%s/bios/bios_CD_J.bin", DEFAULT_PATH); sprintf (config.sys_rom[3], "%s/bios/bios_MD.bin", DEFAULT_PATH); sprintf (config.sys_rom[4], "%s/bios/bios_U.sms", DEFAULT_PATH); sprintf (config.sys_rom[5], "%s/bios/bios_E.sms", DEFAULT_PATH); sprintf (config.sys_rom[6], "%s/bios/bios_J.sms", DEFAULT_PATH); sprintf (config.sys_rom[7], "%s/bios/bios.gg", DEFAULT_PATH); sprintf (config.sys_rom[8], "%s/lock-on/ggenie.bin", DEFAULT_PATH); sprintf (config.sys_rom[9], "%s/lock-on/areplay.bin", DEFAULT_PATH); sprintf (config.sys_rom[10], "%s/lock-on/sk.bin", DEFAULT_PATH); sprintf (config.sys_rom[11], "%s/lock-on/sk2chip.bin", DEFAULT_PATH); /* try to restore user config */ int loaded = config_load(); #ifdef HW_RVL /* initialize WPAD timeout */ WPAD_SetIdleTimeout(config.autosleep ? 300 : 1800); #else /* check if component cable was detected */ if (VIDEO_HaveComponentCable()) { /* when component cable is detected, libogc automatically enables progressive mode */ /* as preferred video mode but it could still be used on TV not supporting 480p/576p */ PAD_ScanPads(); /* detect progressive mode switch requests */ if (PAD_ButtonsHeld(0) & PAD_BUTTON_B) { /* swap progressive mode enable flag */ config.v_prog ^= 1; /* play some sound to inform user */ 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); } /* check if progressive mode should be disabled */ if (!config.v_prog) { /* switch menu video mode to interlaced */ vmode->viTVMode = (vmode->viTVMode & ~3) | VI_INTERLACE; VIDEO_Configure(vmode); VIDEO_Flush(); VIDEO_WaitVSync(); VIDEO_WaitVSync(); } } #endif /* inform user if default config is used */ if (!loaded) { GUI_WaitPrompt("Warning","Default Settings restored"); gx_input_SetDefault(); } /* default emulated inputs */ input.system[0] = SYSTEM_GAMEPAD; input.system[1] = (config.input[1].device != -1) ? SYSTEM_GAMEPAD : NO_SYSTEM; input_init(); }
void config_default(void) { /* version TAG */ strncpy(config.version,CONFIG_VERSION,16); /* sound options */ config.psg_preamp = 150; config.fm_preamp = 100; config.hq_fm = 1; config.psgBoostNoise = 1; config.filter = 1; config.lp_range = 0x9999; /* 0.6 in 16.16 fixed point */ config.low_freq = 880; config.high_freq = 5000; config.lg = 1.0; config.mg = 1.0; config.hg = 1.0; config.dac_bits = 14; config.ym2413 = 2; /* AUTO */ config.mono = 0; /* system options */ config.system = 0; /* AUTO */ config.region_detect = 0; /* AUTO */ config.vdp_mode = 0; /* AUTO */ config.master_clock = 0; /* AUTO */ config.force_dtack = 0; config.addr_error = 1; config.bios = 0; config.lock_on = 0; config.hot_swap = 0; /* video options */ config.xshift = 0; config.yshift = 0; config.xscale = 0; config.yscale = 0; config.aspect = 1; config.overscan = 3; /* FULL */ config.gg_extra = 0; config.ntsc = 0; config.vsync = 1; /* AUTO */ config.bilinear = 1; config.vfilter = 1; if (VIDEO_HaveComponentCable()) { config.render = 2; } else { config.render = 0; } switch (vmode->viTVMode >> 2) { case VI_PAL: config.tv_mode = 1; /* 50hz only */ break; case VI_EURGB60: config.tv_mode = 2; /* 50/60hz */ break; default: config.tv_mode = 0; /* 60hz only */ break; } #ifdef HW_RVL config.trap = 0; config.gamma = VI_GM_1_0 / 10.0; #endif /* controllers options */ config.gun_cursor[0] = 1; config.gun_cursor[1] = 1; config.invert_mouse = 0; /* on-screen options */ config.cd_leds = 0; /* menu options */ config.autoload = 0; config.autocheat = 0; #ifdef HW_RVL config.s_auto = 1; #else config.s_auto = 0; config.v_prog = 1; #endif config.s_default = 1; config.s_device = 0; config.l_device = 0; config.bg_overlay = 0; config.screen_w = 658; config.bgm_volume = 100.0; config.sfx_volume = 100.0; /* default ROM directories */ #ifdef HW_RVL sprintf (config.lastdir[0][TYPE_SD], "sd:%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[1][TYPE_SD], "sd:%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[2][TYPE_SD], "sd:%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[3][TYPE_SD], "sd:%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[4][TYPE_SD], "sd:%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[0][TYPE_USB], "usb:%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[1][TYPE_USB], "usb:%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[2][TYPE_USB], "usb:%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[3][TYPE_USB], "usb:%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[4][TYPE_USB], "usb:%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[0][TYPE_DVD], "dvd:%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[1][TYPE_DVD], "dvd:%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[2][TYPE_DVD], "dvd:%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[3][TYPE_DVD], "dvd:%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[4][TYPE_DVD], "dvd:%s/roms/", DEFAULT_PATH); #else sprintf (config.lastdir[0][TYPE_SD], "%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[1][TYPE_SD], "%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[2][TYPE_SD], "%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[3][TYPE_SD], "%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[4][TYPE_SD], "%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[0][TYPE_DVD], "dvd:%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[1][TYPE_DVD], "dvd:%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[2][TYPE_DVD], "dvd:%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[3][TYPE_DVD], "dvd:%s/roms/", DEFAULT_PATH); sprintf (config.lastdir[4][TYPE_DVD], "dvd:%s/roms/", DEFAULT_PATH); #endif /* try to restore user config */ int loaded = config_load(); #ifndef HW_RVL /* detect progressive mode enable/disable requests */ PAD_ScanPads(); if (PAD_ButtonsHeld(0) & PAD_BUTTON_B) { /* swap progressive mode enable flag and play some sound to inform user */ config.v_prog ^= 1; 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); } /* switch into 480p if component cable has been detected and progressive mode is enabled */ if (VIDEO_HaveComponentCable() && config.v_prog) { vmode = &TVNtsc480Prog; VIDEO_Configure (vmode); VIDEO_Flush(); VIDEO_WaitVSync(); VIDEO_WaitVSync(); } #endif /* inform user if default config is used */ if (!loaded) { GUI_WaitPrompt("Warning","Default Settings restored"); gx_input_SetDefault(); } /* default emulated inputs */ input.system[0] = SYSTEM_MD_GAMEPAD; input.system[1] = (config.input[1].device != -1) ? SYSTEM_MD_GAMEPAD : NO_SYSTEM; input_init(); }
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); }