Exemple #1
0
int audio_play_sound_panned(int soundId, int pan, sint16 x, sint16 y, sint16 z)
{
    if (pan == AUDIO_PLAY_AT_LOCATION)
        return audio_play_sound_at_location(soundId, x, y, z);

    return audio_play_sound(soundId, 0, pan);
}
static int dialog_title_sound_vol(gg_widget_t *widget, gg_widget_t *emitter, void *data, void *extra_data) {
	option_t *option = config_get_option("sound_volume");
	option_select_value_by_index(option, gg_option_get_selected(GG_OPTION(widget)));

	audio_set_sound_volume(option->selected->index);
	audio_play_sound(AUDIO_MOVE);

	return 1;
}
Exemple #3
0
static void news_item_tick_current()
{
    sint32 ticks;
    ticks = ++news_item_get(0)->Ticks;
    // Only play news item sound when in normal playing mode
    if (ticks == 1 && (gScreenFlags == SCREEN_FLAGS_PLAYING)) {
        // Play sound
        audio_play_sound(SOUND_NEWS_ITEM, 0, context_get_width() / 2);
    }
}
Exemple #4
0
/**************************************************************************
  Call this at end of program only.
**************************************************************************/
void audio_shutdown()
{
  /* avoid infinite loop at end of game */
  audio_stop();

  audio_play_sound("e_game_quit", NULL);
  plugins[selected_plugin].wait();
  plugins[selected_plugin].shutdown();

  if (tagfile) {
    section_file_free(tagfile);
    tagfile = NULL;
  }
}
Exemple #5
0
int audio_play_sound_at_location(int soundId, sint16 x, sint16 y, sint16 z)
{
    if (gGameSoundsOff)
        return 0;

    rct_xyz16 location;
    location.x = x;
    location.y = y;
    location.z = z;

    rct_audio_params params = audio_get_params_from_location(soundId, &location);
    if (!params.in_range)
        return soundId;

    return audio_play_sound(soundId, params.volume, params.pan);
}
Exemple #6
0
/**
 *
 *  rct2: 0x0066EA5C
 */
static void window_news_scrollmousedown(rct_window *w, sint32 scrollIndex, sint32 x, sint32 y)
{
    sint32 itemHeight = window_news_get_item_height();
    sint32 i, buttonIndex;

    buttonIndex = 0;
    for (i = 11; i < 61; i++)
    {
        if (news_item_is_empty(i))
            break;

        if (y < itemHeight)
        {
            NewsItem * const newsItem = news_item_get(i);
            if (newsItem->Flags & NEWS_FLAG_HAS_BUTTON ||
                y < 14 || y >= 38 ||
                x < 328)
            {
                buttonIndex = 0;
                break;
            }
            else if (x < 351 && news_type_properties[newsItem->Type] & NEWS_TYPE_HAS_SUBJECT)
            {
                buttonIndex = 1;
                break;
            }
            else if (x < 376 && news_type_properties[newsItem->Type] & NEWS_TYPE_HAS_LOCATION)
            {
                buttonIndex = 2;
                break;
            }
        }
        y -= itemHeight;
    }

    if (buttonIndex != 0)
    {
        w->news.var_480 = i - 11;
        w->news.var_482 = buttonIndex;
        w->news.var_484 = 4;
        window_invalidate(w);
        audio_play_sound(SOUND_CLICK_1, 0, w->x + (w->width / 2));
    }
}
Exemple #7
0
/**
 *
 *  rct2: 0x0066EAB8
 */
static void window_news_update(rct_window *w)
{
    sint32 i, j, x, y, z;

    if (w->news.var_480 == -1 ||
        --w->news.var_484 != 0)
    {
        return;
    }

    window_invalidate(w);
    audio_play_sound(SOUND_CLICK_2, 0, w->x + (w->width / 2));

    j = w->news.var_480;
    w->news.var_480 = -1;
    for (i = 11; i < 61; i++)
    {
        if (news_item_is_empty(i))
            return;

        if (j == 0)
        {
            NewsItem * const newsItem = news_item_get(i);
            if (newsItem->Flags & NEWS_FLAG_HAS_BUTTON)
                return;
            if (w->news.var_482 == 1)
            {
                news_item_open_subject(newsItem->Type, newsItem->Assoc);
                return;
            }
            else if (w->news.var_482 > 1)
            {
                news_item_get_subject_location(newsItem->Type, newsItem->Assoc, &x, &y, &z);
                if (x != LOCATION_NULL && (w = window_get_main()) != nullptr)
                {
                    window_scroll_to_location(w, x, y, z);
                }
                return;
            }
        }
        j--;
    }
}
Exemple #8
0
/**
 *
 *  rct2: 0x006CFB82
 */
static void window_track_list_select(rct_window *w, sint32 index)
{
    w->track_list.var_480 = index;

    // Displays a message if the ride can't load, fix #4080
    if (_loadedTrackDesign == NULL) {
        window_error_open(STR_CANT_BUILD_PARK_ENTRANCE_HERE, STR_TRACK_LOAD_FAILED_ERROR);
        return;
    }

    audio_play_sound(SOUND_CLICK_1, 0, w->x + (w->width / 2));
    if (!(gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER)) {
        if (index == 0) {
            window_close(w);
            ride_construct_new(_window_track_list_item);
            return;
        }
        index--;
    }

    rct_track_td6 *td6 = _loadedTrackDesign;
    if (td6 != NULL && (td6->track_flags & TRACK_DESIGN_FLAG_SCENERY_UNAVAILABLE)) {
        gTrackDesignSceneryToggle = true;
    }

    track_design_file_ref *tdRef = &_trackDesigns[index];
    if (gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER) {
        window_track_manage_open(tdRef);
    } else {
        if (_loadedTrackDesignIndex != TRACK_DESIGN_INDEX_UNLOADED && (_loadedTrackDesign->track_flags & TRACK_DESIGN_FLAG_VEHICLE_UNAVAILABLE)) {
            window_error_open(STR_THIS_DESIGN_WILL_BE_BUILT_WITH_AN_ALTERNATIVE_VEHICLE_TYPE, STR_NONE);
        }

        window_track_place_open(tdRef);
    }
}
Exemple #9
0
int main_deathmatch()
{
	SDL_Event e;

	SDL_ShowCursor(SDL_DISABLE);

	entity_initialize_list(1024);
	tank_initialize_list(15);

	g_current_level = level_load("leveloneconfig");
	render_set_background(g_current_level->background->image);

	g_music = audio_load_music("sounds/music/backgroundmusic.wav");
	g_sound = audio_load_sound("sounds/digital/digital.wav");
	if(g_music->file.music != NULL)
	{
		slog("Playing Music");
		//audio_play_music(g_music->file.music);
	}
	else
		slog("Could not load music file");

	player = player_spawn("Player", PLAYER);
	v2d_set(player->tank->tracks->body->position, SCREEN_WIDTH/2, SCREEN_HEIGHT/2);
	v2d_set(player->tank->turret->body->position, SCREEN_WIDTH/2, SCREEN_HEIGHT/2);

	g_now = SDL_GetTicks();

	ui_initialize_deathmatch(rtn_renderer());

	do
	{
		//calculate deltatime
		g_last = g_now;
		g_now = SDL_GetTicks();
		g_deltatime = g_now - g_last;

		render_update(1);
		render_clear();
		entity_all_think();
		entity_all_update();
		player_move(player);
		while(SDL_PollEvent(&e))
		{
			if(e.type == SDL_KEYDOWN)
			{
				if(e.type == SDL_QUIT)
					SDL_Quit();
				if(e.key.keysym.sym == SDLK_w)
					player->keysHeld.W = 1;
				if(e.key.keysym.sym == SDLK_s)
					player->keysHeld.S = 1;
				if(e.key.keysym.sym == SDLK_a)
					player->keysHeld.A = 1;
				if(e.key.keysym.sym == SDLK_d)
					player->keysHeld.D = 1;
				if(e.key.keysym.sym == SDLK_e)
				{
					tank_weapon_change(player->tank);
					slog("Current weapon: %s", player->tank->currentweapon->name);
				}
				if(e.key.keysym.sym == SDLK_p)
				{
					audio_play_sound(g_sound->file.sound);
				}
				if(e.key.keysym.sym == SDLK_f)
				{
					Entity *sonar;
					sonar = sonar_new(sonar = entity_new(SONAR, NULL), 3.0, player->tank);
				}
				if(e.key.keysym.sym == SDLK_g)
				{
					tank_weapon_fire(player->tank);
				}
				if(e.key.keysym.sym == SDLK_h)
					player->tank->health -= 5;
				if(e.key.keysym.sym == SDLK_j)
					player->tank->armour -= 5;
				if(e.key.keysym.sym == SDLK_SPACE)
				{
					if(player->tank->is_hidden)
						player->tank->is_hidden = 0;
					else
						player->tank->is_hidden = 1;

					tank_sprite_change(player->tank);
				}
				if(e.key.keysym.sym == SDLK_ESCAPE)
				{
					playclicked = 0;
					entity_close_list();
					tank_close_list();
					player_close_list();
					currentstate = MAINMENU;
				}
			}
			if(e.type == SDL_KEYUP)
			{
				if(e.key.keysym.sym == SDLK_w)
					player->keysHeld.W = 0;
				if(e.key.keysym.sym == SDLK_s)
					player->keysHeld.S = 0;
				if(e.key.keysym.sym == SDLK_a)
					player->keysHeld.A = 0;
				if(e.key.keysym.sym == SDLK_d)
					player->keysHeld.D = 0;
			}
		}
		if(g_deltatime < 32)
			SDL_Delay(32-g_deltatime);
	} while(currentstate == DEATHMATCH);

	return 0;
}
Exemple #10
0
/**
 * Init_Genesis(): Initialize the Genesis with the specified ROM image.
 * @param MD_ROM ROM image struct.
 * @return 1 if successful.
 */
int Init_Genesis(ROM_t* MD_ROM)
{
	// Clear the sound buffer.
	audio_clear_sound_buffer();
	
	Flag_Clr_Scr = 1;
	Settings.Paused = Frame_Number = 0;
	SRAM_Start = SRAM_End = SRAM_ON = SRAM_Write = 0;
	Controller_1_COM = Controller_2_COM = 0;
#ifdef GENS_DEBUGGER
	STOP_DEBUGGING();
#endif

	
#if 0	// TODO: Replace with MDP "exclusive mode" later.
	if (!Kaillera_Client_Running)
#endif
	Init_Genesis_SRAM(MD_ROM);
	
	// Check what country code should be used.
	// TODO: Get rid of magic numbers.
	switch (Country)
	{
		default:
		case -1: // Autodetection.
			Detect_Country_Genesis(MD_ROM);
			break;
		
		case 0: // Japan (NTSC)
			Game_Mode = 0;
			CPU_Mode = 0;
			break;
		
		case 1: // US (NTSC)
			Game_Mode = 1;
			CPU_Mode = 0;
			break;
		
		case 2: // Europe (PAL)
			Game_Mode = 1;
			CPU_Mode = 1;
			break;
		
		case 3: // Japan (PAL)
			Game_Mode = 0;
			CPU_Mode = 1;
			break;
	}
	
	VDP_Num_Vis_Lines = 224;
	Gen_Version = 0x20 + 0x0;	// Version de la megadrive (0x0 - 0xF)
	
	// Byteswap the ROM data.
	be16_to_cpu_array(Rom_Data, Rom_Size);
	ROM_ByteSwap_State |= ROM_BYTESWAPPED_MD_ROM;
	
	// Reset all CPUs and other components.
	M68K_Reset(0);
	Z80_Reset();
	VDP_Reset();
	
	// Initialize the controller state.
	Init_Controllers();
	
	// Set clock rates depending on the CPU mode (NTSC / PAL).
	Set_Clock_Freq(0);
	
	// If auto-fix checksum is enabled, fix the ROM checksum.
	if (Auto_Fix_CS)
		ROM::fixChecksum();
	
	// Initialize sound.
	if (audio_get_enabled())
	{
		audio_end();
		
		if (audio_init(AUDIO_BACKEND_DEFAULT))
			audio_set_enabled(false);
		else
		{
			if (audio_play_sound)
				audio_play_sound();
		}
	}
	
	Reset_Update_Timers();
	
	// Set the appropriate frame update function pointers.
	Update_Frame = Do_Genesis_Frame;
	Update_Frame_Fast = Do_Genesis_Frame_No_VDP;
	
	return 1;
}
Exemple #11
0
int main(int argc, char **argv) {
	cl_options_t cl_options = {0};

	dbg_init();
	DBG_LOG("Version %s", g_version);

	ui = &ui_sdlgl;

	printf("DreamChess %s\n", g_version);

	parse_options(argc, argv, &ui, &cl_options);
	config_init();
	set_cl_options(&cl_options);

	if (!ui) {
		DBG_ERROR("Failed to find a user interface driver");
		exit(1);
	}

	ui->init();

	init_resolution();

	while (1) {
		board_t board;
		int pgn_slot;
		option_t *option;

		if (!(config = ui->config(&pgn_slot)))
			break;

		ch_userdir();
		option = config_get_option("first_engine");

#ifdef __APPLE__
		char temp1[200];
		char temp2[200];

		if (!strcmp(option->string, "dreamer") || !strcmp(option->string, "Dreamer")) {
			CFBundleRef mainBundle = CFBundleGetMainBundle();

			CFURLRef bundledir = CFBundleCopyBundleURL(mainBundle);
			CFStringRef stringref = CFURLCopyFileSystemPath(bundledir, kCFURLPOSIXPathStyle);
			CFStringGetCString(stringref, temp1, 200, kCFStringEncodingMacRoman);

			snprintf(temp2, sizeof(temp2), "%s/contents/MacOS/dreamer", temp1);

			game_set_engine_error(comm_init(temp2));
		} else
			game_set_engine_error(comm_init(option->string));
#else
		game_set_engine_error(comm_init(option->string));
#endif

		comm_send("xboard\n");

		comm_send("new\n");
		comm_send("random\n");

		comm_send("sd %i\n", config->cpu_level);
		comm_send("depth %i\n", config->cpu_level);

		if (config->difficulty == 0)
			comm_send("noquiesce\n");

		if (config->player[WHITE] == PLAYER_UI && config->player[BLACK] == PLAYER_UI)
			comm_send("force\n");

		if (config->player[WHITE] == PLAYER_ENGINE)
			comm_send("go\n");

		in_game = 1;
		board_setup(&board);
		history = history_init(&board);
		move_list_init(&san_list);
		move_list_init(&fan_list);
		move_list_init(&fullalg_list);

		if (pgn_slot >= 0)
			if (game_load(pgn_slot)) {
				DBG_ERROR("Failed to load savegame in slot %i", pgn_slot);
				exit(1);
			}

		ui->update(history->view->board, NULL);
		while (in_game) {
			char *s;

			if ((s = comm_poll())) {
				DBG_LOG("Message from engine: '%s'", s);
				if (!history->result) {
					if ((!strncmp(s, "move ", 4) || strstr(s, "... ")) &&
						config->player[history->last->board->turn] == PLAYER_ENGINE) {
						char *move_str = strrchr(s, ' ') + 1;
						board_t new_board = *history->last->board;
						move_t *engine_move;

						DBG_LOG("Parsing move string '%s'", move_str);

						engine_move = san_to_move(&new_board, move_str);
						if (!engine_move)
							engine_move = fullalg_to_move(&new_board, move_str);
						if (engine_move) {
							audio_play_sound(AUDIO_MOVE);
							do_move(engine_move, 1);
							free(engine_move);
						} else
							DBG_ERROR("Failed to parse move string '%s'", move_str);
					} else if (strstr(s, "llegal move"))
						game_undo();
					/* Ignore result message if we've already determined a result ourselves. */
					else {
						char *start = strchr(s, '{');
						char *end = strchr(s, '}');

						if (start && end && end > start) {
							char *comment = malloc(end - start);
							history->result = malloc(sizeof(result_t));
							strncpy(comment, start + 1, end - start - 1);
							comment[end - start - 1] = '\0';
							history->result->reason = comment;
							if (strstr(s, "1-0")) {
								history->result->code = RESULT_WHITE_WINS;
								ui->show_result(history->result);
							} else if (strstr(s, "1/2-1/2")) {
								history->result->code = RESULT_DRAW;
								ui->show_result(history->result);
							} else if (strstr(s, "0-1")) {
								history->result->code = RESULT_BLACK_WINS;
								ui->show_result(history->result);
							} else {
								free(history->result->reason);
								free(history->result);
								history->result = NULL;
							}
						}
					}
				}

				free(s);
			}
			ui->poll();
		}
		comm_send("quit\n");
		comm_exit();
		history_exit(history);
		move_list_exit(&san_list);
		move_list_exit(&fan_list);
		move_list_exit(&fullalg_list);
	}
	ui->exit();
	dbg_exit();
	return 0;
}