2
* OpenTyrian: A modern cross-platform port of Tyrian
3
* Copyright (C) 2007-2009 The OpenTyrian Development Team
5
* This program is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU General Public License
7
* as published by the Free Software Foundation; either version 2
8
* of the License, or (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
31
#include "vga_palette.h"
36
bool trigger_quit = false, // true when user wants to quit
39
bool hide_text = false;
41
bool fade_looped_songs = true, fading_song = false;
47
int palette_fade_steps = 15;
50
init_step_fade_palette(diff, vga_palette, 0, 255);
54
int fade_volume = tyrMusicVolume;
58
if (!stopped && !audio_disabled)
60
if (songlooped && fade_looped_songs)
71
fade_volume = tyrMusicVolume;
76
set_volume(fade_volume, fxVolume);
79
if (!playing || (songlooped && fade_looped_songs && !fading_song))
80
play_song(mt_rand() % MUSIC_NUM);
85
SDL_FillRect(VGAScreenSeg, NULL, 0);
87
// starlib input needs to be rewritten
90
push_joysticks_as_keyboard();
91
service_SDL_events(true);
98
snprintf(buffer, sizeof(buffer), "%d %s", fx_num + 1, soundTitle[fx_num]);
100
snprintf(buffer, sizeof(buffer), "%d %s", song_playing + 1, musicTitle[song_playing]);
102
const int x = VGAScreen->w / 2;
104
draw_font_hv(VGAScreen, x, 170, "Press ESC to quit the jukebox.", small_font, centered, 1, 0);
105
draw_font_hv(VGAScreen, x, 180, "Arrow keys change the song being played.", small_font, centered, 1, 0);
106
draw_font_hv(VGAScreen, x, 190, buffer, small_font, centered, 1, 4);
109
if (palette_fade_steps > 0)
110
step_fade_palette(diff, palette_fade_steps--, 0, 255);
116
// quit on mouse click
118
if (JE_mousePosition(&x, &y) > 0)
125
case SDLK_ESCAPE: // quit jukebox
131
hide_text = !hide_text;
135
fading_song = !fading_song;
138
fade_looped_songs = !fade_looped_songs;
141
case SDLK_SLASH: // switch to sfx mode
145
if (fx && --fx_num < 0)
146
fx_num = SAMPLE_COUNT - 1;
149
if (fx && ++fx_num >= SAMPLE_COUNT)
154
JE_playSampleNum(fx_num + 1);
159
play_song((song_playing > 0 ? song_playing : MUSIC_NUM) - 1);
165
play_song((song_playing + 1) % MUSIC_NUM);
168
case SDLK_s: // stop song
172
case SDLK_r: // restart song
182
// user wants to quit, start fade-out
183
if (trigger_quit && !quitting)
185
palette_fade_steps = 15;
187
SDL_Color black = { 0, 0, 0 };
188
init_step_fade_solid(diff, black, 0, 255);
193
// if fade-out finished, we can finally quit
194
if (quitting && palette_fade_steps == 0)
198
set_volume(tyrMusicVolume, fxVolume);