コード例 #1
0
void player_drop_bomb( void* _pVoidGame )
{
    player* p_player = ((in_game_state*)((game*)_pVoidGame)->p_current_state)->p_player;

    if ( !p_player->p_bomb->active )
    {
        p_player->p_bomb->left   = p_player->j * GC_block_size;

        p_player->p_bomb->top    = p_player->i * GC_block_size + GC_y_offset;

        p_player->p_bomb->right  = p_player->p_bomb->left + GC_block_size;

        p_player->p_bomb->bottom = p_player->p_bomb->top  + GC_block_size;

        p_player->p_bomb->i = p_player->i;

        p_player->p_bomb->j = p_player->j;

        p_player->p_bomb->active = 1;

        explode( _pVoidGame );

        pause_audio();

        play_sound( GC_bomb_sound );

        reset_timer( p_player->p_bomb->bomb_timer );
    }
}
コード例 #2
0
DirectorConference::~DirectorConference()
{
	// 释放所有 sources, sinks, ...
	do {
		ost::MutexLock al(cs_graphics_);
		GRAPHICS::iterator it;
		for (it = graphics_.begin(); it != graphics_.end(); ++it) {
			delete *it;
		}
		graphics_.clear();
	} while (0);

	do {
		ost::MutexLock al(cs_sinks_);
		SINKS::iterator it;
		for (it = sinks_.begin(); it != sinks_.end(); ++it) {
			del_sink(*it);
			delete *it;
		}
		sinks_.clear();
	} while (0);

	do {
		ost::MutexLock al(cs_streams_);
		STREAMS::iterator it;
		for (it = streams_.begin(); it != streams_.end(); ++it) {
			del_stream(*it);
			delete *it;
		}
		streams_.clear();
	} while (0);

	do {
		ost::MutexLock al(cs_sources_);
		SOURCES::iterator it;
		for (it = sources_.begin(); it != sources_.end(); ++it) {
			del_source(*it);
			delete *it;
		}
		sources_.clear();
	} while (0);

	pause_audio();
	pause_video();

	ms_ticker_destroy(audio_ticker_);
	ms_ticker_destroy(video_ticker_);

	ms_filter_destroy(audio_resample_);
	ms_filter_destroy(audio_encoder_);
	ms_filter_destroy(audio_mixer_);
	ms_filter_destroy(video_mixer_);
	ms_filter_destroy(audio_publisher_);
	ms_filter_destroy(video_publisher_);
	ms_filter_destroy(video_tee_);

	if (filter_tee_) ms_filter_destroy(filter_tee_);
	if (filter_sink_) ms_filter_destroy(filter_sink_);
}
コード例 #3
0
ファイル: emu.c プロジェクト: EdCornejo/emu-ex-plus-alpha
void init_sound(void) {

	if (conf.sound) init_sdl_audio();

#ifdef ENABLE_940T
		printf("Init all neo");
		shared_data->sample_rate = conf.sample_rate;
		shared_data->z80_cycle = (z80_overclk == 0 ? 73333 : 73333
				+ (z80_overclk * 73333 / 100.0));
		//gp2x_add_job940(JOB940_INITALL);
		gp2x_add_job940(JOB940_INITALL);
		wait_busy_940(JOB940_INITALL);
		printf("The YM2610 have been initialized\n");
#else
		cpu_z80_init();
		//streams_sh_start();
		YM2610_sh_start();
#endif
	if (conf.sound)	pause_audio(0);
		conf.snd_st_reg_create = 1;


}
コード例 #4
0
int DirectorConference::add_audio_stream(Stream *s, KVS &params)
{
	if (audio_stream_cnt_ >= MAX_STREAMS) {
		log("[Conference] %s: Oh, toooo many audio streams!\n",
				__FUNCTION__);
		return -2;
	}

	pause_audio();
	int cid = find_audio_free_pin();
	s->channel_id(cid);	// save for removing

	// connect audio decoder to mixer
	ms_filter_link(s->get_source_filter(), s->get_source_pin(), audio_mixer_, cid);

	if (s->payload_type() == -100) {
		fprintf(stderr, "ERR: ??? stream payload = -100 ????\n");
		__asm int 3;
		ms_filter_link(audio_mixer_, cid, filter_tee_, 0);
		if (s->support_sink())
			ms_filter_link(filter_tee_, 0, s->get_sink_filter(), 0);
		ms_filter_link(filter_tee_, 1, filter_sink_, 0);
	}
コード例 #5
0
void init_in_game_state( game* _pGame )
{
    // allocate the necessary memory for the in_game_state struct
    _pGame->p_current_state = malloc( sizeof( in_game_state ) );

    // game is not paused
    ((in_game_state*)_pGame->p_current_state)->bool_paused = 0;

    // load esc menu image
    ((in_game_state*)_pGame->p_current_state)->p_esc_menu_img = load_image( GC_ig_esc_menu_img, GC_ig_esc_menu_width, GC_ig_esc_menu_height );

    // init current game state flag variable
    ((in_game_state*)_pGame->p_current_state)->game_state = PLAYING;

    // esc menu is not active
    ((in_game_state*)_pGame->p_current_state)->bool_menu_is_active = 0;

    // create the top bar
    ((in_game_state*)_pGame->p_current_state)->p_top_bar = construct_top_bar();

    // load esc menu buttons
    ((in_game_state*)_pGame->p_current_state)->p_continue = load_button( GC_ig_continue_x,
                                                                        GC_ig_continue_y,
                                                                        GC_button_width,
                                                                        GC_button_height,
                                                                        GC_ig_continue_nr_img,
                                                                        GC_ig_continue_se_img );

     ((in_game_state*)_pGame->p_current_state)->p_main_menu = load_button( GC_ig_mm_x,
                                                                          GC_ig_mm_y,
                                                                          GC_button_width,
                                                                          GC_button_height,
                                                                          GC_ig_mm_nr_img,
                                                                          GC_ig_mm_se_img );

    ((in_game_state*)_pGame->p_current_state)->p_exit = load_button( GC_ig_exit_x,
                                                                    GC_ig_exit_y,
                                                                    GC_button_width,
                                                                    GC_button_height,
                                                                    GC_mm_exit_nr_img,
                                                                    GC_mm_exit_se_img );

    // pause main menu backgorund music
    pause_audio();

    _pGame->main_menu_music_is_on = 0;

    // selected button in esc menu is "continue"
    ((in_game_state*)_pGame->p_current_state)->selected_button = CONTINUE_BUTTON;
    ((in_game_state*)_pGame->p_current_state)->p_continue->bool_is_selected = 1;

    // seed the random number generator
    srand( time( NULL ) );

    // construct the map struct, load a random map file from "maps\" directoty
    ((in_game_state*)_pGame->p_current_state)->p_map = construct_map( rand() % GC_number_of_maps );

    // construct the NPCs( pacmen ) based on how many 'N' characters there are in the map( max being GC_max_NPC_count )
    matrix_point* p_NPCs_coords = (matrix_point*)malloc( GC_max_NPC_count * sizeof( matrix_point ) );

    ((in_game_state*)_pGame->p_current_state)->NPC_count = find_NPCs_in_map( ((in_game_state*)_pGame->p_current_state)->p_map, p_NPCs_coords );

    ((in_game_state*)_pGame->p_current_state)->pp_NPCs = (NPC**)malloc( ((in_game_state*)_pGame->p_current_state)->NPC_count * sizeof( NPC ) );

    for ( int i = 0; i < ((in_game_state*)_pGame->p_current_state)->NPC_count; i++ )
        ((in_game_state*)_pGame->p_current_state)->pp_NPCs[i] = construct_NPC( p_NPCs_coords[i].i, p_NPCs_coords[i].j );

    free( p_NPCs_coords );

    // construct the player
    ((in_game_state*)_pGame->p_current_state)->p_player = construct_player();

    ((in_game_state*)_pGame->p_current_state)->game_ended_timer = create_timer( GC_game_ended_duration );

    ((in_game_state*)_pGame->p_current_state)->timer_set = 0;

    // Configure the text that will be outputed(WinBGIm); this is only for the "PAUSED GAME" that appears when game's paused
    settextjustify( CENTER_TEXT, CENTER_TEXT );
    settextstyle( SMALL_FONT, HORIZ_DIR, 9 );
}
コード例 #6
0
void text_input(const char *message,int x,int y,char *string,int size)
{
    int sx;
    int a;
    int s=0;
    int i;
    int pos=0;
    static SDL_Surface *save=NULL;
    SDL_Rect clear_rect={16,227,320,16};
    if (!save)
	save=SDL_CreateRGBSurface(SDL_SWSURFACE,320,16,16, 0xF800, 0x7E0,0x1F, 0);

    if (conf.sound) pause_audio(1);

    memset(string,0,size+1);

    SDL_FillRect(buffer,&clear_rect,0);
//    SDL_BlitSurface(buffer,&clear_rect,save,NULL);
    SDL_textout(buffer,x,y,message);
    sx=x+strlen(message)* font_w;
    SDL_EnableUNICODE(1);
    while((a=SDL_getchar())!=-1) {
	if (a==LEFT && pos>0) pos--;
	if (a==RIGHT && pos<s) pos++;
	if (a==BACKSPACE && pos>0) {
	    for(i=pos-1;i<s;i++)
		string[i]=string[i+1];
	    s--;
	    pos--;
	}
	if (a==DEL && pos<s) {
	    for(i=pos;i<s;i++)
		string[i]=string[i+1];
	    s--;
	}
	if (a>32  && s<size ) {
	    for(i=s;i>pos;i--)
		string[i]=string[i-1];
	    string[pos]=(char)a;

	    s++;
	    pos++;
	}
	SDL_FillRect(buffer,&clear_rect,0);
	//SDL_BlitSurface(save,NULL,buffer,&clear_rect);
	SDL_textout(buffer,x,y,message);
	SDL_textout(buffer,sx,y,string);
	/* cursor */
	((Uint16*)buffer->pixels)[352*(16+222)+sx+pos* font_w-1]=0;
	for(i=sx+pos* font_w;i<sx+pos* font_w+ font_w;i++) {
	    ((Uint16*)buffer->pixels)[352*(16+222)+i]=0xFFFF;
	    ((Uint16*)buffer->pixels)[352*(16+221)+i]=0;
	    ((Uint16*)buffer->pixels)[352*(16+223)+i]=0;
	}
	((Uint16*)buffer->pixels)[352*(16+222)+sx+pos* font_w+font_w]=0;	
	screen_update();
    }
    SDL_EnableUNICODE(0);
    if (conf.sound) pause_audio(0);
    reset_frame_skip();
}
コード例 #7
0
ファイル: audio.cpp プロジェクト: djyt/cannonball
void Audio::load_wav(const char* filename)
{
    if (sound_enabled)
    {
        clear_wav();

        // Load Wav File
        SDL_AudioSpec wave;
    
        uint8_t *data;
        uint32_t length;

        pause_audio();

        if( SDL_LoadWAV(filename, &wave, &data, &length) == NULL)
        {
            wavfile.loaded = 0;
            resume_audio();
            std::cout << "Could not load wav: " << filename << std::endl;
            return;
        }
        
        SDL_LockAudio();

        // Halve Volume Of Wav File
        uint8_t* data_vol = new uint8_t[length];
	SDL_MixAudioFormat(data_vol, data, wave.format, length, SDL_MIX_MAXVOLUME / 2);

        // WAV File Needs Conversion To Target Format
        if (wave.format != AUDIO_S16 || wave.channels != 2 || wave.freq != FREQ)
        {
            SDL_AudioCVT cvt;
            SDL_BuildAudioCVT(&cvt, wave.format, wave.channels, wave.freq,
                                    AUDIO_S16,   CHANNELS,      FREQ);

            cvt.buf = (uint8_t*) malloc(length*cvt.len_mult);
            memcpy(cvt.buf, data_vol, length);
            cvt.len = length;
            SDL_ConvertAudio(&cvt);
            SDL_FreeWAV(data);
            delete[] data_vol;

            wavfile.data = (int16_t*) cvt.buf;
            wavfile.length = cvt.len_cvt / 2;
            wavfile.pos = 0;
            wavfile.loaded = 1;
        }
        // No Conversion Needed
        else
        {
            SDL_FreeWAV(data);
            wavfile.data = (int16_t*) data_vol;
            wavfile.length = length / 2;
            wavfile.pos = 0;
            wavfile.loaded = 2;
        }

        resume_audio();
        SDL_UnlockAudio();
    }
}