/* * SPEED - by Shawn Hargreaves, 1999 * * Title screen and results display. */ #include #include #include #include "speed.h" /* draws text with a dropshadow */ static void textout_shadow(BITMAP *bmp, char *msg, int x, int y, int c) { textout_centre(bmp, font, msg, x+1, y+1, makecol(0, 0, 0)); textout_centre(bmp, font, msg, x, y, c); } /* display the title screen */ int title_screen() { BITMAP *bmp, *b; int c, i, j, y; bmp = create_bitmap(SCREEN_W, SCREEN_H); if (bitmap_color_depth(bmp) > 8) { for (i=0; i 8) { for (i=0; iid == DIGI_NONE) { set_gfx_mode(GFX_TEXT, 0, 0, 0, 0); allegro_message("Couldn't install a digital sound driver, so no closing tune is available.\n"); return; } s1 = create_sample(8, FALSE, 44100, 256); s2 = create_sample(8, FALSE, 44100, 256); for (i=0; i<256; i++) { ((char *)s1->data)[i] = i; ((char *)s2->data)[i] = (i < 128) ? 255 : 0; } rectfill(screen, 0, 0, SCREEN_W/2, SCREEN_H/2, makecol(255, 255, 0)); rectfill(screen, SCREEN_W/2, 0, SCREEN_W, SCREEN_H/2, makecol(0, 255, 0)); rectfill(screen, 0, SCREEN_H/2, SCREEN_W/2, SCREEN_H, makecol(0, 0, 255)); rectfill(screen, SCREEN_W/2, SCREEN_H/2, SCREEN_W, SCREEN_H, makecol(255, 0, 0)); b = create_bitmap(168, 8); clear_to_color(b, bitmap_mask_color(b)); textout(b, font, "Happy birthday Arron!", 0, 0, makecol(0, 0, 0)); stretch_sprite(screen, b, SCREEN_W/8+4, SCREEN_H*3/8+4, SCREEN_W*3/4, SCREEN_H/4); textout(b, font, "Happy birthday Arron!", 0, 0, makecol(255, 255, 255)); stretch_sprite(screen, b, SCREEN_W/8, SCREEN_H*3/8, SCREEN_W*3/4, SCREEN_H/4); destroy_bitmap(b); while ((key[KEY_SPACE]) || (key[KEY_ENTER]) | (key[KEY_ESC])) poll_keyboard(); clear_keybuf(); for (i=0; i < (int)(sizeof(data1)/sizeof(int)); i += 2) { play_sample(s1, 64, 128, (int)(1000 * pow(2.0, (float)data1[i]/12.0)), TRUE); rest(100*data1[i+1]); stop_sample(s1); rest(50*data1[i+1]); if (keypressed()) return; } rest(500); clear(screen); set_gfx_mode(GFX_TEXT, 0, 0, 0, 0); allegro_message("\nAnd thanks for organising this most excellent competition...\n"); for (i=0; i < (int)(sizeof(data2)/sizeof(int)); i += 2) { play_sample(s2, 64, 128, (int)(1000 * pow(2.0, (float)data2[i]/12.0)), TRUE); rest(75*data2[i+1]); stop_sample(s2); rest(25*data2[i+1]); if (keypressed()) return; } rest(300); putchar('\007'); fflush(stdout); rest(300); putchar('\007'); fflush(stdout); destroy_sample(s1); destroy_sample(s2); }