//------------------------------------------------------------------------------ //! \brief Play a sample (called from the game) //! //! \param id = SND_xxx id //! \param pos = Sample Position to use 0 to 255 //! \param rate = The rate //------------------------------------------------------------------------------ void CAudioDrv::PlaySample(int id, int pos, int rate) { if (m_DisableSamplesFlag) return; const void *sound_ptr = NULL; u32 sound_length = 0; if (rate == 0) rate = VOICE_FREQ32KHZ; switch(id) { case SND_CAR: sound_ptr = &car_raw; sound_length = car_raw_size; break; case SND_TRAIN: sound_ptr = &train_raw; sound_length = train_raw_size; break; case SND_DUCK: sound_ptr = &duck_raw; sound_length = duck_raw_size; break; case SND_PICKUP1: sound_ptr = &pickup1_raw; sound_length = pickup1_raw_size; break; case SND_TRIBBLE: sound_ptr = &tribble_raw; sound_length = tribble_raw_size; break; case SND_HURRY: sound_ptr = &hurry_raw; sound_length = hurry_raw_size; break; case SND_DAY: sound_ptr = &day_raw; sound_length = day_raw_size; break; case SND_CRYING: sound_ptr = &crying_raw; sound_length = crying_raw_size; break; case SND_DIE2: sound_ptr = &die2_raw; sound_length = die2_raw_size; break; case SND_SPIT: sound_ptr = &spit_raw; sound_length = spit_raw_size; break; case SND_SPLAT: sound_ptr = &splat_raw; sound_length = splat_raw_size; break; case SND_BLOW: sound_ptr = &blow_raw; sound_length = blow_raw_size; break; case SND_TWINKLE: sound_ptr = &twinkle_raw; sound_length = twinkle_raw_size; break; case SND_FINLEV1: sound_ptr = &finlev1_raw; sound_length = finlev1_raw_size; break; case SND_PSTAR: sound_ptr = &pstar_raw; sound_length = pstar_raw_size; break; case SND_XYLO: sound_ptr = &xylo_raw; sound_length = xylo_raw_size; break; case SND_CARDSOUND: sound_ptr = &card_raw; sound_length = card_raw_size; break; case SND_BOWLINGSOUND: sound_ptr = &bowling_raw; sound_length = bowling_raw_size; break; case SND_CANDLESOUND: sound_ptr = &candle_raw; sound_length = candle_raw_size; break; case SND_MARBLESOUND: sound_ptr = &marble_raw; sound_length = marble_raw_size; break; case SND_TAPSOUND: sound_ptr = &tap_raw; sound_length = tap_raw_size; break; case SND_OILSOUND: sound_ptr = &oil_raw; sound_length = oil_raw_size; break; case SND_SPININGTOPSOUND: sound_ptr = &spiningtop_raw; sound_length = spiningtop_raw_size; break; case SND_WINGSSOUND: sound_ptr = &wings_raw; sound_length = wings_raw_size; break; case SND_MOONSOUND: sound_ptr = &moon_raw; sound_length = moon_raw_size; break; case SND_MASKSOUND: sound_ptr = &mask_raw; sound_length = mask_raw_size; break; case SND_REDSTARSOUND: sound_ptr = &redstar_raw; sound_length = redstar_raw_size; break; case SND_TURBOSOUND: sound_ptr = &turbo_raw; sound_length = turbo_raw_size; break; case SND_CHICKENSOUND: sound_ptr = &chicken_raw; sound_length = chicken_raw_size; break; case SND_FEATHERSOUND: sound_ptr = &feather_raw; sound_length = feather_raw_size; break; case SND_WPOTIONSOUND: sound_ptr = &wpotion_raw; sound_length = wpotion_raw_size; break; case SND_COOKIESOUND: sound_ptr = &cookie_raw; sound_length = cookie_raw_size; break; default: // Error: unknown sample return; } // Add a voice AESNDPB* this_voice = AESND_AllocateVoice(VoiceCallBack); // Check if voice was available if (this_voice) { AESND_PlayVoice(this_voice, VOICE_STEREO16, sound_ptr, sound_length, rate, 0, 0); // Do volume math (with fake panning) int vol_l = ((255 - pos) > 0) ? (255 - pos) : 0; vol_l = (vol_l > 255) ? 255 : vol_l; vol_l = (float) sound_volume * (float) vol_l / 10.0; int vol_r = (pos > 0) ? pos : 0; vol_r = (vol_r > 255) ? 255 : vol_r; vol_r = (float) sound_volume * (float) pos / 10.0; AESND_SetVoiceVolume(this_voice, vol_l, vol_r); } }
void Init_Voice() { for (int i=0; i<MAX_SOUND_SLOT; i++) { sound[i] = NULL; sound[i] = AESND_AllocateVoice(NULL); } }
int main(int argc, char **argv) { GRRLIB_Init(); // Initialise the attached controllers WPAD_Init(); WPAD_SetDataFormat(WPAD_CHAN_0, WPAD_FMT_BTNS_ACC_IR); // Initialise the audio subsystem AESND_Init(NULL); MODPlay_Init(&play); MODPlay_SetMOD(&play,bg_music); MODPlay_SetVolume(&play,63,63); MODPlay_Start(&play); cui_cursor cursor; cursor.tex[0]=GRRLIB_LoadTexture(player1_point_png); cursor.tex[1]=GRRLIB_LoadTexture(player1_grab_png); cursor.is_grabbing=false; cui_board board; ENGINE engine = FIRSTCHESS; if(engine == TSCP){ int i; for (i=0; i < CUI_TILE_NB; i++) { board.piece[i]=init_piece[i]; if(init_color[i] == 1){ board.color[i]=CUI_BLACK; }else if (init_color[i] == 6){ board.color[i]=CUI_EMPTY; }else if (init_color[i] == 0){ board.color[i]=CUI_WHITE; } } init_hash(); init_board(); open_book(); gen(); } cui_board_read_core(&board, engine); GRRLIB_SetBackgroundColour(0x030, 0x30, 0x42, 0xFF); board.tile_color1 = 0xAAAAAAFF; board.tile_color2 = 0x444444FF; board.piece_color1 = 0xAAAAAAFF; board.piece_color2 = 0x444444FF; cui_board_init(&board); cui_game game; game.board = &board; game.engine = engine; game.cursor = &cursor; game.is_mute = false; GRRLIB_texImg *tex_wallpaper = GRRLIB_LoadTexture(wall_jpg); game.tex_wallpaper = tex_wallpaper; voice = AESND_AllocateVoice(aesnd_callback); AESND_SetVoiceVolume(voice, 0xFF, 0xFF); AESND_SetVoiceStream(voice, true); cui_menu current_state = CUI_MENU_MAIN; while(current_state != CUI_MENU_EXIT) { switch(current_state){ case CUI_MENU_MAIN: current_state=menu_main(&game);break; case CUI_MENU_PLAY: current_state=menu_play(&game);break; case CUI_MENU_OPTION:current_state=menu_option(&game);break; case CUI_MENU_OPTION_GENERAL:current_state=menu_option_general(&game);break; case CUI_MENU_OPTION_GFX:current_state=menu_option_gfx(&game);break; case CUI_MENU_OPTION_SND:current_state=menu_option_snd(&game);break; case CUI_MENU_CREDITS:current_state=menu_credits(&game);break; case CUI_MENU_PAUSE:current_state=menu_pause(&game);break; case CUI_MENU_HOME:current_state=menu_home(&game);break; case CUI_MENU_EXIT:current_state=menu_exit(&game);break; default:break; } } GRRLIB_FreeTexture(tex_wallpaper); GRRLIB_FreeTexture(cursor.tex[0]); GRRLIB_FreeTexture(cursor.tex[1]); GRRLIB_Exit(); return 0; }