Beispiel #1
0
// something has gone wrong :(
void network_tyrian_halt( unsigned int err, bool attempt_sync )
{
#ifdef __BLACKBERRY__
	quit = true;
#else
	const char *err_msg[] = {
		"Quitting...",
		"Other player quit the game.",
		"Network connection was lost.",
		"Network connection failed.",
		"Network version mismatch.",
		"Network delay mismatch.",
		"Network player number conflict.",
	};

	quit = true;

	if (err >= COUNTOF(err_msg))
		err = 0;

	fade_black(10);

	VGAScreen = VGAScreenSeg;

	JE_loadPic(VGAScreen, 2, false);
	JE_dString(VGAScreen, JE_fontCenter(err_msg[err], SMALL_FONT_SHAPES), 140, err_msg[err], SMALL_FONT_SHAPES);

	JE_showVGA();
	fade_palette(colors, 10, 0, 255);

	if (attempt_sync)
	{
		while (!network_is_sync() && network_is_alive())
		{
			service_SDL_events(false);

			network_check();
			SDL_Delay(16);
		}
	}

	if (err)
	{
		while (!JE_anyButton())
			SDL_Delay(16);
	}

	fade_black(10);

	SDLNet_Quit();

	JE_tyrianHalt(5);
#endif
}
Beispiel #2
0
bool select_gameplay( void )
{
	JE_loadPic(2, false);
	JE_dString(JE_fontCenter(gameplay_name[0], FONT_SHAPES), 20, gameplay_name[0], FONT_SHAPES);
	
	int gameplay = 1,
	    gameplay_max = 4;
	
	bool fade_in = true;
	for (; ; )
	{
		for (int i = 1; i <= gameplay_max; i++)
		{
			JE_outTextAdjust(JE_fontCenter(gameplay_name[i], SMALL_FONT_SHAPES), i * 24 + 30, gameplay_name[i], 15, - 4 + (i == gameplay ? 2 : 0) - (i == 4 ? 4 : 0), SMALL_FONT_SHAPES, true);
		}
		JE_showVGA();
		
		if (fade_in)
		{
			JE_fadeColor(10);
			fade_in = false;
		}
		
		JE_word temp = 0;
		JE_textMenuWait(&temp, false);
		
		if (newkey)
		{
			switch (lastkey_sym)
			{
			case SDLK_UP:
				gameplay--;
				if (gameplay < 1)
				{
					gameplay = gameplay_max;
				}
				JE_playSampleNum(CURSOR_MOVE);
				break;
			case SDLK_DOWN:
				gameplay++;
				if (gameplay > gameplay_max)
				{
					gameplay = 1;
				}
				JE_playSampleNum(CURSOR_MOVE);
				break;
				
			case SDLK_RETURN:
				if (gameplay == 4)
				{
					JE_playSampleNum(ESC);
					/* TODO: NETWORK */
					printf("error: networking via menu not implemented\n");
					break;
				}
				JE_playSampleNum(SELECT);
				JE_fadeBlack(10);
				
				onePlayerAction = (gameplay == 2);
				twoPlayerMode = (gameplay == 3);
				return true;
				
			case SDLK_ESCAPE:
				JE_playSampleNum(ESC);
				/* fading handled elsewhere
				JE_fadeBlack(10); */
				
				return false;
				
			default:
				break;
			}
		}
	}
	
	return false;
}
Beispiel #3
0
bool select_difficulty( void )
{
	JE_loadPic(2, false);
	JE_dString(JE_fontCenter(difficulty_name[0], FONT_SHAPES), 20, difficulty_name[0], FONT_SHAPES);
	
	difficultyLevel = 2;
	int difficulty_max = 3;
	
	bool fade_in = true;
	for (; ; )
	{
		for (int i = 1; i <= difficulty_max; i++)
		{
			JE_outTextAdjust(JE_fontCenter(difficulty_name[i], SMALL_FONT_SHAPES), i * 24 + 30, difficulty_name[i], 15, -4 + (i == difficultyLevel ? 2 : 0), SMALL_FONT_SHAPES, true);
		}
		JE_showVGA();
		
		if (fade_in)
		{
			JE_fadeColor(10);
			fade_in = false;
		}
		
		JE_word temp = 0;
		JE_textMenuWait(&temp, false);
		
		if (SDL_GetModState() & KMOD_SHIFT)
		{
			if ((difficulty_max < 4 && keysactive[SDLK_g]) ||
			    (difficulty_max == 4 && keysactive[SDLK_RIGHTBRACKET]))
			{
				difficulty_max++;
			}
		} else if (difficulty_max == 5 && keysactive[SDLK_l] && keysactive[SDLK_o] && keysactive[SDLK_r] && keysactive[SDLK_d]) {
			difficulty_max++;
		}
		
		if (newkey)
		{
			switch (lastkey_sym)
			{
			case SDLK_UP:
				difficultyLevel--;
				if (difficultyLevel < 1)
				{
					difficultyLevel = difficulty_max;
				}
				JE_playSampleNum(CURSOR_MOVE);
				break;
			case SDLK_DOWN:
				difficultyLevel++;
				if (difficultyLevel > difficulty_max)
				{
					difficultyLevel = 1;
				}
				JE_playSampleNum(CURSOR_MOVE);
				break;
				
			case SDLK_RETURN:
				JE_playSampleNum(SELECT);
				/* fading handled elsewhere
				JE_fadeBlack(10); */
				
				if (difficultyLevel == 6)
				{
					difficultyLevel = 8;
				} else if (difficultyLevel == 5) {
					difficultyLevel = 6;
				}
				return true;
				
			case SDLK_ESCAPE:
				JE_playSampleNum(ESC);
				/* fading handled elsewhere
				JE_fadeBlack(10); */
				
				return false;
				
			default:
				break;
			}
		}
	}
	
	return false;
}
Beispiel #4
0
bool select_episode( void )
{
	JE_loadPic(2, false);
	JE_dString(JE_fontCenter(episode_name[0], FONT_SHAPES), 20, episode_name[0], FONT_SHAPES);
	
	int episode = 1,
	    episode_max = EPISODE_MAX - 1;
	
	bool fade_in = true;
	for (; ; )
	{
		for (int i = 1; i <= episode_max; i++)
		{
			JE_outTextAdjust(20, i * 30 + 20, episode_name[i], 15, -4 + (i == episode ? 2 : 0) - (!episodeAvail[i - 1] ? 4 : 0), SMALL_FONT_SHAPES, true);
		}
		JE_showVGA();
		
		if (fade_in)
		{
			JE_fadeColor(10);
			fade_in = false;
		}
		
		JE_word temp = 0;
		JE_textMenuWait(&temp, false);
		
		if (newkey)
		{
			switch (lastkey_sym)
			{
			case SDLK_UP:
				episode--;
				if (episode < 1)
				{
					episode = episode_max;
				}
				JE_playSampleNum(CURSOR_MOVE);
				break;
			case SDLK_DOWN:
				episode++;
				if (episode > episode_max)
				{
					episode = 1;
				}
				JE_playSampleNum(CURSOR_MOVE);
				break;
				
			case SDLK_RETURN:
				if (!episodeAvail[episode - 1])
				{
					JE_playSampleNum(ESC);
					break;
				}
				JE_playSampleNum(SELECT);
				JE_fadeBlack(10);
				
				JE_initEpisode(episode);
				pItems[9-1] = episodeNum;
				return true;
				
			case SDLK_ESCAPE:
				JE_playSampleNum(ESC);
				/* fading handled elsewhere
				JE_fadeBlack(10); */
				
				return false;
				
			default:
				break;
			}
		}
	}
	
	return false;
}
Beispiel #5
0
void opentyrian_menu( void )
{
	static const char *menu_items[] =
	{
		"About OpenTyrian",
		"Toggle Fullscreen",
		"Scaler: None",
		// "Play Destruct",
		"Jukebox",
		"Return to Main Menu",
	};
	bool menu_items_disabled[] =
	{
		false,
		!can_init_any_scaler(false) || !can_init_any_scaler(true),
		false,
		// false,
		false,
		false,
	};
	
	fade_black(10);
	JE_loadPic(VGAScreen, 13, false);

	draw_font_hv(VGAScreen, VGAScreen->w / 2, 5, opentyrian_str, large_font, centered, 15, -3);

	memcpy(VGAScreen2->pixels, VGAScreen->pixels, VGAScreen2->pitch * VGAScreen2->h);

	JE_showVGA();

	play_song(36); // A Field for Mag

	int sel = 0;
	const int maxSel = COUNTOF(menu_items) - 1;

	uint32_t temp_scaler = scaler;

	bool fade_in = true, quit = false;
	do
	{
		memcpy(VGAScreen->pixels, VGAScreen2->pixels, VGAScreen->pitch * VGAScreen->h);

		for (int i = 0; i <= maxSel; i++)
		{
			const char *text = menu_items[i];
			char buffer[100];

			if (i == 2) /* Scaler */
			{
				snprintf(buffer, sizeof(buffer), "Scaler: %s", scalers[temp_scaler].name);
				text = buffer;
			}

			int y = i != maxSel ? i * 16 + 32 : 118;
			draw_font_hv(VGAScreen, VGAScreen->w / 2, y, text, normal_font, centered, 15, menu_items_disabled[i] ? -8 : i != sel ? -4 : -2);
		}

		JE_showVGA();

		if (fade_in)
		{
			fade_in = false;
			fade_palette(colors, 20, 0, 255);
			wait_noinput(true, false, false);
		}

		tempW = 0;
		JE_textMenuWait(&tempW, false);

		if (newkey)
		{
			switch (lastkey_sym)
			{
			case SDLK_UP:
				do
				{
					if (--sel < 0)
						sel = maxSel;
				}
				while (menu_items_disabled[sel]);
				
				JE_playSampleNum(S_CURSOR);
				break;
			case SDLK_DOWN:
				do
				{
					if (++sel > maxSel)
						sel = 0;
				}
				while (menu_items_disabled[sel]);
				
				JE_playSampleNum(S_CURSOR);
				break;
				
			case SDLK_LEFT:
				if (sel == 2)
				{
					do
					{
						if (temp_scaler == 0)
							temp_scaler = scalers_count;
						temp_scaler--;
					}
					while (!can_init_scaler(temp_scaler, fullscreen_enabled));
					
					JE_playSampleNum(S_CURSOR);
				}
				break;
			case SDLK_RIGHT:
				if (sel == 2)
				{
					do
					{
						temp_scaler++;
						if (temp_scaler == scalers_count)
							temp_scaler = 0;
					}
					while (!can_init_scaler(temp_scaler, fullscreen_enabled));
					
					JE_playSampleNum(S_CURSOR);
				}
				break;
				
			case SDLK_RETURN:
				switch (sel)
				{
				case 0: /* About */
					JE_playSampleNum(S_SELECT);

					scroller_sine(about_text);

					memcpy(VGAScreen->pixels, VGAScreen2->pixels, VGAScreen->pitch * VGAScreen->h);
					JE_showVGA();
					fade_in = true;
					break;
					
				case 1: /* Fullscreen */
					JE_playSampleNum(S_SELECT);

					if (!init_scaler(scaler, !fullscreen_enabled) && // try new fullscreen state
						!init_any_scaler(!fullscreen_enabled) &&     // try any scaler in new fullscreen state
						!init_scaler(scaler, fullscreen_enabled))    // revert on fail
					{
						exit(EXIT_FAILURE);
					}
					set_palette(colors, 0, 255); // for switching between 8 bpp scalers
					break;
					
				case 2: /* Scaler */
					JE_playSampleNum(S_SELECT);

					if (scaler != temp_scaler)
					{
						if (!init_scaler(temp_scaler, fullscreen_enabled) &&   // try new scaler
							!init_scaler(temp_scaler, !fullscreen_enabled) &&  // try other fullscreen state
							!init_scaler(scaler, fullscreen_enabled))          // revert on fail
						{
							exit(EXIT_FAILURE);
						}
						set_palette(colors, 0, 255); // for switching between 8 bpp scalers
					}
					break;
					
				case 3: /* Jukebox */
					JE_playSampleNum(S_SELECT);

					fade_black(10);
					jukebox();

					memcpy(VGAScreen->pixels, VGAScreen2->pixels, VGAScreen->pitch * VGAScreen->h);
					JE_showVGA();
					fade_in = true;
					break;
					
				case 4: /* Return to main menu */
					quit = true;
					JE_playSampleNum(S_SPRING);
					break;
				}
				break;
				
			case SDLK_ESCAPE:
				quit = true;
				JE_playSampleNum(S_SPRING);
				break;
				
			default:
				break;
			}
		}
	} while (!quit);
}
Beispiel #6
0
void opentyrian_menu( void )
{
	typedef enum
	{
		MENU_ABOUT = 0,
		MENU_FULLSCREEN,
		MENU_SCALER,
		// MENU_DESTRUCT,
		MENU_JUKEBOX,
		MENU_RETURN,
		MenuOptions_MAX
	} MenuOptions;

	static const char *menu_items[] =
	{
		"About OpenTyrian",
		"Toggle Fullscreen",
		"Scaler: None",
		// "Play Destruct",
		"Jukebox",
		"Return to Main Menu",
	};
	bool menu_items_disabled[] =
	{
		false,
		!can_init_any_scaler(false) || !can_init_any_scaler(true),
		false,
		// false,
		false,
		false,
	};
	
	assert(COUNTOF(menu_items) == MenuOptions_MAX);
	assert(COUNTOF(menu_items_disabled) == MenuOptions_MAX);

	fade_black(10);
	JE_loadPic(VGAScreen, 13, false);

	draw_font_hv(VGAScreen, VGAScreen->surf->w / 2, 5, opentyrian_str, large_font, centered, 15, -3);

	memcpy(VGAScreen2->surf->pixels, VGAScreen->surf->pixels, VGAScreen2->surf->pitch * VGAScreen2->surf->h);

	JE_showVGA();

	play_song(36); // A Field for Mag

	MenuOptions sel = 0;

	uint temp_scaler = scaler;

	bool fade_in = true, quit = false;
	do
	{
		memcpy(VGAScreen->surf->pixels, VGAScreen2->surf->pixels, VGAScreen->surf->pitch * VGAScreen->surf->h);

		for (MenuOptions i = 0; i < MenuOptions_MAX; i++)
		{
			const char *text = menu_items[i];
			char buffer[100];

			if (i == MENU_SCALER)
			{
				snprintf(buffer, sizeof(buffer), "Scaler: %s", scalers[temp_scaler].name);
				text = buffer;
			}

			int y = i != MENU_RETURN ? i * 16 + 32 : 118;
			draw_font_hv(VGAScreen, VGAScreen->surf->w / 2, y, text, normal_font, centered, 15, menu_items_disabled[i] ? -8 : i != sel ? -4 : -2);
		}

		JE_showVGA();

		if (fade_in)
		{
			fade_in = false;
			fade_palette(colors, 20, 0, 255);
			wait_noinput(true, false, false);
		}

		tempW = 0;
		JE_textMenuWait(&tempW, false);

		if (newkey)
		{
			switch (lastkey_sym)
			{
			case SDLK_UP:
				do
				{
					if (sel-- == 0)
						sel = MenuOptions_MAX - 1;
				}
				while (menu_items_disabled[sel]);
				
				JE_playSampleNum(S_CURSOR);
				break;
			case SDLK_DOWN:
				do
				{
					if (++sel >= MenuOptions_MAX)
						sel = 0;
				}
				while (menu_items_disabled[sel]);
				
				JE_playSampleNum(S_CURSOR);
				break;
				
			case SDLK_LEFT:
				if (sel == MENU_SCALER)
				{
					do
					{
						if (temp_scaler == 0)
							temp_scaler = scalers_count;
						temp_scaler--;
					}
					while (!can_init_scaler(temp_scaler, fullscreen_enabled));
					
					JE_playSampleNum(S_CURSOR);
				}
				break;
			case SDLK_RIGHT:
				if (sel == MENU_SCALER)
				{
					do
					{
						temp_scaler++;
						if (temp_scaler == scalers_count)
							temp_scaler = 0;
					}
					while (!can_init_scaler(temp_scaler, fullscreen_enabled));
					
					JE_playSampleNum(S_CURSOR);
				}
				break;
				
			case SDLK_RETURN:
				switch (sel)
				{
				case MENU_ABOUT:
					JE_playSampleNum(S_SELECT);

					scroller_sine(about_text);

					memcpy(VGAScreen->surf->pixels, VGAScreen2->surf->pixels, VGAScreen->surf->pitch * VGAScreen->surf->h);
					JE_showVGA();
					fade_in = true;
					break;
					
				case MENU_FULLSCREEN:
					JE_playSampleNum(S_SELECT);

					if (!init_scaler(scaler, !fullscreen_enabled) && // try new fullscreen state
						!init_any_scaler(!fullscreen_enabled) &&     // try any scaler in new fullscreen state
						!init_scaler(scaler, fullscreen_enabled))    // revert on fail
					{
						exit(EXIT_FAILURE);
					}
					break;
					
				case MENU_SCALER:
					JE_playSampleNum(S_SELECT);

					if (scaler != temp_scaler)
					{
						if (!init_scaler(temp_scaler, fullscreen_enabled) &&   // try new scaler
							!init_scaler(temp_scaler, !fullscreen_enabled) &&  // try other fullscreen state
							!init_scaler(scaler, fullscreen_enabled))          // revert on fail
						{
							exit(EXIT_FAILURE);
						}
					}
					break;
					
				case MENU_JUKEBOX:
					JE_playSampleNum(S_SELECT);

					fade_black(10);
					jukebox();

					memcpy(VGAScreen->surf->pixels, VGAScreen2->surf->pixels, VGAScreen->surf->pitch * VGAScreen->surf->h);
					JE_showVGA();
					fade_in = true;
					break;
					
				case MENU_RETURN:
					quit = true;
					JE_playSampleNum(S_SPRING);
					break;
					
				case MenuOptions_MAX:
					assert(false);
					break;
				}
				break;
				
			case SDLK_ESCAPE:
				quit = true;
				JE_playSampleNum(S_SPRING);
				break;
				
			default:
				break;
			}
		}
	} while (!quit);
}
Beispiel #7
0
bool select_gameplay( void )
{
	JE_loadPic(VGAScreen, 2, false);
	JE_dString(VGAScreen, JE_fontCenter(gameplay_name[0], FONT_SHAPES), 20, gameplay_name[0], FONT_SHAPES);

	int gameplay = 1,
	    gameplay_max = GAMEPLAY_NAME_COUNT - 1;

	bool fade_in = true;
	for (; ; )
	{
		for (int i = 1; i <= gameplay_max; i++)
		{
			JE_outTextAdjust(VGAScreen, JE_fontCenter(gameplay_name[i], SMALL_FONT_SHAPES), i * 24 + 30, gameplay_name[i], 15, -4 + (i == gameplay ? 2 : 0) - (i == (GAMEPLAY_NAME_COUNT - 1) ? 4 : 0), SMALL_FONT_SHAPES, true);
		}
		JE_showVGA();

		if (fade_in)
		{
			fade_palette(colors, 10, 0, 255);
			fade_in = false;
		}

		JE_word temp = 0;
		JE_textMenuWait(&temp, false);

		if (newkey)
		{
			switch (lastkey_sym)
			{
			case SDLK_UP:
				if (--gameplay < 1)
					gameplay = gameplay_max;
				JE_playSampleNum(S_CURSOR);
				break;
			case SDLK_DOWN:
				if (++gameplay > gameplay_max)
					gameplay = 1;
				JE_playSampleNum(S_CURSOR);
				break;

			case SDLK_RETURN:
				if (gameplay == GAMEPLAY_NAME_COUNT - 1)
				{
					JE_playSampleNum(S_SPRING);
					/* TODO: NETWORK */
					fprintf(stderr, "error: networking via menu not implemented\n");
					break;
				}
				JE_playSampleNum(S_SELECT);
				fade_black(10);

				onePlayerAction = (gameplay == 2);
				twoPlayerMode = (gameplay == GAMEPLAY_NAME_COUNT - 2);
				return true;

			case SDLK_ESCAPE:
				JE_playSampleNum(S_SPRING);
				/* fading handled elsewhere
				fade_black(10); */

				return false;

			default:
				break;
			}
		}
	}
}
Beispiel #8
0
bool select_episode( void )
{
	JE_loadPic(VGAScreen, 2, false);
	JE_dString(VGAScreen, JE_fontCenter(episode_name[0], FONT_SHAPES), 20, episode_name[0], FONT_SHAPES);

	int episode = 1, episode_max = EPISODE_AVAILABLE;

	bool fade_in = true;
	for (; ; )
	{
		for (int i = 1; i <= episode_max; i++)
		{
			JE_outTextAdjust(VGAScreen, 20, i * 30 + 20, episode_name[i], 15, -4 + (i == episode ? 2 : 0) - (!episodeAvail[i - 1] ? 4 : 0), SMALL_FONT_SHAPES, true);
		}
		JE_showVGA();

		if (fade_in)
		{
			fade_palette(colors, 10, 0, 255);
			fade_in = false;
		}

		JE_word temp = 0;
		JE_textMenuWait(&temp, false);

		if (newkey)
		{
			switch (lastkey_sym)
			{
			case SDLK_UP:
				episode--;
				if (episode < 1)
				{
					episode = episode_max;
				}
				JE_playSampleNum(S_CURSOR);
				break;
			case SDLK_DOWN:
				episode++;
				if (episode > episode_max)
				{
					episode = 1;
				}
				JE_playSampleNum(S_CURSOR);
				break;

			case SDLK_RETURN:
				if (!episodeAvail[episode - 1])
				{
					JE_playSampleNum(S_SPRING);
					break;
				}
				JE_playSampleNum(S_SELECT);
				fade_black(10);

				JE_initEpisode(episode);
				initial_episode_num = episodeNum;
				return true;

			case SDLK_ESCAPE:
				JE_playSampleNum(S_SPRING);
				/* fading handled elsewhere
				fade_black(10); */

				return false;

			default:
				break;
			}
		}
	}
}
Beispiel #9
0
bool select_difficulty( void )
{
	newkey = false;
	JE_loadPic(VGAScreen, 2, false);
	JE_dString(VGAScreen, JE_fontCenter(difficulty_name[0], FONT_SHAPES), 20, difficulty_name[0], FONT_SHAPES);

	difficultyLevel = 2;
	int difficulty_max = 3;

	bool fade_in = true;
	for (; ; )
	{
		for (int i = 1; i <= difficulty_max; i++)
		{
			JE_outTextAdjust(VGAScreen, JE_fontCenter(difficulty_name[i], SMALL_FONT_SHAPES), i * 24 + 30, difficulty_name[i], 15, -4 + (i == difficultyLevel ? 2 : 0), SMALL_FONT_SHAPES, true);
		}
		JE_showVGA();

		if (fade_in)
		{
			fade_palette(colors, 10, 0, 255);
			fade_in = false;
		}

		JE_word temp = 0;
		JE_textMenuWait(&temp, false);

		if (SDL_GetModState() & KMOD_SHIFT)
		{
			if ((difficulty_max < 4 && keysactive[SDL_SCANCODE_G]) ||
			    (difficulty_max == 4 && keysactive[SDL_SCANCODE_RIGHTBRACKET]))
			{
				difficulty_max++;
			}
		} else if (difficulty_max == 5 && keysactive[SDL_SCANCODE_L] && keysactive[SDL_SCANCODE_O] && keysactive[SDL_SCANCODE_R] && keysactive[SDL_SCANCODE_D]) {
			difficulty_max++;
		}

		if (newkey)
		{
			switch (lastkey_scan)
			{
			case SDL_SCANCODE_UP:
				difficultyLevel--;
				if (difficultyLevel < 1)
				{
					difficultyLevel = difficulty_max;
				}
				JE_playSampleNum(S_CURSOR);
				break;
			case SDL_SCANCODE_DOWN:
				difficultyLevel++;
				if (difficultyLevel > difficulty_max)
				{
					difficultyLevel = 1;
				}
				JE_playSampleNum(S_CURSOR);
				break;

			case SDL_SCANCODE_RETURN:
				JE_playSampleNum(S_SELECT);
				/* fading handled elsewhere
				fade_black(10); */

				if (difficultyLevel == 6)
				{
					difficultyLevel = 8;
				} else if (difficultyLevel == 5) {
					difficultyLevel = 6;
				}
				return true;

			case SDL_SCANCODE_AC_BACK:
			case SDL_SCANCODE_ESCAPE:
				JE_playSampleNum(S_SPRING);
				/* fading handled elsewhere
				fade_black(10); */

				return false;

			default:
				break;
			}
		}
	}
}