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.
35
const struct about_text_type about_text[] =
37
{0x30, "----- ~OpenTyrian~ -----"},
39
{0x0b, "...eliminating Microsol,"},
40
{0x0b, "one planet at a time..."},
43
{0x30, "----- ~Developers~ -----"},
45
{0x03, "Carl Reinke // Mindless"},
46
{0x07, "Yuri Schlesner // yuriks"},
47
{0x04, "Casey McCann // syntaxglitch"},
50
{0x30, "----- ~Thanks~ -----"},
52
{0x0e, "Thanks to everyone who has"},
53
{0x0e, "assisted the developers by testing"},
54
{0x0e, "the game and reporting bugs."},
57
{0x05, "Thanks to ~DOSBox~ for the"},
58
{0x05, "FM-Synthesis emulator and"},
59
{0x05, "~AdPlug~ for the Loudness player."},
62
{0x32, "And special thanks to ~Jason Emery~"},
63
{0x32, "for making all this possible"},
64
{0x32, "by giving Tyrian to its fans."},
67
/* {0x00, "This is line color test ~0~."},
68
{0x01, "This is line color test ~1~."},
69
{0x02, "This is line color test ~2~."},
70
{0x03, "This is line color test ~3~."},
71
{0x04, "This is line color test ~4~."},
72
{0x05, "This is line color test ~5~."},
73
{0x06, "This is line color test ~6~."},
74
{0x07, "This is line color test ~7~."},
75
{0x08, "This is line color test ~8~."},
76
{0x09, "This is line color test ~9~."},
77
{0x0a, "This is line color test ~A~."},
78
{0x0b, "This is line color test ~B~."},
79
{0x0c, "This is line color test ~C~."},
80
{0x0d, "This is line color test ~D~."},
81
{0x0e, "This is line color test ~E~."},
82
{0x0f, "This is line color test ~F~."},*/
89
{0x00, "Press a key to leave."},
93
#define LINE_HEIGHT 15
96
#define BEER_SHAPE 241
98
struct coin_def_type {
105
struct coin_def_type coin_defs[] =
107
{1, 6}, {7, 6}, {20, 6}, {26, 6}, // Coins
108
{14, 5, true}, {32, 5, true}, {51, 5, true} // Gems
111
/* Text is an array of strings terminated by a NULL */
112
void scroller_sine( const struct about_text_type text[] )
114
bool ale = mt_rand() % 2;
116
int visible_lines = vga_height / LINE_HEIGHT + 1;
117
int current_line = -visible_lines;
121
struct coin_type { int x, y, vel, type, cur_frame; bool backwards; } coins[MAX_COINS];
122
struct { int x, y, ay, vx, vy; } beer[MAX_BEER];
126
memset(beer, 0, sizeof(beer));
128
for (int i = 0; i < MAX_COINS; i++)
130
coins[i].x = mt_rand() % (vga_width - 12);
131
coins[i].y = mt_rand() % (vga_height - 20 - 14);
133
coins[i].vel = (mt_rand() % 4) + 1;
134
coins[i].type = mt_rand() % COUNTOF(coin_defs);
135
coins[i].cur_frame = mt_rand() % coin_defs[coins[i].type].frame_count;
136
coins[i].backwards = false;
142
wait_noinput(true, true, true);
144
play_song(40); // BEER
146
while (!JE_anyButton())
150
JE_clr256(VGAScreen);
154
for (int i = 0; i < MAX_COINS/2; i++)
156
struct coin_type *coin = &coins[i];
157
blit_sprite2(VGAScreen, coin->x, coin->y, eShapes[4], coin_defs[coin->type].shape_num + coin->cur_frame);
161
for (int i = 0; i < visible_lines; i++)
163
if (current_line + i >= 0)
165
if (text[current_line + i].text == NULL)
170
int line_x = VGAScreen->w / 2;
171
int line_y = i * LINE_HEIGHT - y;
173
// smooths edges on sine-wave text
174
if (text[i + current_line].effect & 0x20)
176
draw_font_hv(VGAScreen, line_x + 1, line_y, text[i + current_line].text, normal_font, centered, text[i + current_line].effect & 0x0f, -10);
177
draw_font_hv(VGAScreen, line_x - 1, line_y, text[i + current_line].text, normal_font, centered, text[i + current_line].effect & 0x0f, -10);
180
draw_font_hv(VGAScreen, line_x, line_y, text[i + current_line].text, normal_font, centered, text[i + current_line].effect & 0x0f, -4);
182
if (text[i + current_line].effect & 0x10)
184
for (int j = 0; j < LINE_HEIGHT; j++)
186
if (line_y + j >= 10 && line_y + j <= vga_height - 10)
188
int waver = sinf((((line_y + j) / 2) % 10) / 5.0f * M_PI) * 3;
189
memmove(&((Uint8 *)VGAScreen->pixels)[VGAScreen->pitch * (line_y + j) + waver],
190
&((Uint8 *)VGAScreen->pixels)[VGAScreen->pitch * (line_y + j)],
198
if (++y == LINE_HEIGHT)
202
if (current_line < 0 || text[current_line].text != NULL)
205
current_line = -visible_lines;
210
for (int i = MAX_COINS/2; i < MAX_COINS; i++)
212
struct coin_type *coin = &coins[i];
213
blit_sprite2(VGAScreen, coin->x, coin->y, eShapes[4], coin_defs[coin->type].shape_num + coin->cur_frame);
217
fill_rectangle_xy(VGAScreen, 0, 0, vga_width - 1, 14, 0);
218
fill_rectangle_xy(VGAScreen, 0, vga_height - 14, vga_width - 1, vga_height - 1, 0);
222
for (int i = 0; i < MAX_COINS; i++)
224
struct coin_type *coin = &coins[i];
232
if (coin->cur_frame == coin_defs[coin->type].frame_count)
234
if (coin_defs[coin->type].reverse_anim)
236
coin->backwards = true;
237
coin->cur_frame -= 2;
242
if (coin->cur_frame == -1)
245
coin->backwards = false;
248
coin->y += coin->vel;
249
if (coin->y > vga_height - 14)
251
coin->x = mt_rand() % (vga_width - 12);
254
coin->vel = (mt_rand() % 4) + 1;
255
coin->type = mt_rand() % COUNTOF(coin_defs);
256
coin->cur_frame = mt_rand() % coin_defs[coin->type].frame_count;
260
for (uint i = 0; i < COUNTOF(beer); i++)
262
while (beer[i].vx == 0)
264
beer[i].x = mt_rand() % (vga_width - 24);
265
beer[i].y = mt_rand() % (vga_height - 28 - 50);
267
beer[i].vx = (mt_rand() % 5) - 2;
272
if (beer[i].x + beer[i].vx > vga_width - 24 || beer[i].x + beer[i].vx < 0) // check if the beer hit the sides
274
beer[i].vx = -beer[i].vx;
276
beer[i].x += beer[i].vx;
278
if (beer[i].y + beer[i].vy > vga_height - 28) // check if the beer hit the bottom
280
if ((beer[i].vy) < 8) // make sure the beer bounces!
282
beer[i].vy += mt_rand() % 2;
283
} else if (beer[i].vy > 16) { // make sure the beer doesn't bounce too high
286
beer[i].vy = -beer[i].vy + (mt_rand() % 3 - 1);
288
beer[i].x += (beer[i].vx > 0 ? 1 : -1) * (i % 2 ? 1 : -1);
290
beer[i].y += beer[i].vy;
292
blit_sprite2x2(VGAScreen, beer[i].x, beer[i].y, eShapes[4], BEER_SHAPE);
301
fade_palette(colors, 10, 0, 255);
303
SDL_Color white = { 255, 255, 255 };
304
set_colors(white, 254, 254);