Main Page | Alphabetical List | Class List | File List | Class Members | File Members

engine/main.c

Go to the documentation of this file.
00001 #define SAVE_SCREEN
00002 #include "engine.h"
00003 
00004 //INT_HANDLER save_int_1;
00005 
00006 static void CALLBACK cleanup(void);
00007 //{{{
00008 void _main(void)
00009 {
00010     int loaded_set;
00011     show_title_screen();
00012     initialize();
00013     loaded_set = pick_set();
00014     while(loaded_set) {
00015         level_advance(0);
00016         game_loop();
00017         loaded_set = pick_set();
00018     }
00019 }
00020 //}}}
00021 short saved_between_delay, saved_init_delay;
00022 //{{{
00023 void initialize(void)
00024 {
00025     saved_init_delay = OSInitKeyInitDelay( 90 );
00026     saved_between_delay = OSInitBetweenKeyDelay( 30 );
00027     clrscr();
00028     GrayOn();
00029     atexit(cleanup);
00030 }
00031 //}}}
00032 //{{{
00033 static void CALLBACK cleanup(void)
00034 {
00035     GrayOff();
00036     if(current_map.t) {
00037         free(current_map.t);
00038         current_map.t = NULL;
00039     }
00040     OSInitKeyInitDelay(saved_init_delay);
00041     OSInitBetweenKeyDelay(saved_between_delay);
00042 }
00043 //}}}
00044 
00045 //{{{
00046 void show_title_screen(void)
00047 {
00048     clrscr();
00049     draw_string("SKye", 55, 20, F_8x10);
00050     draw_string(VERSION_STRING, 60, 31, F_4x6);
00051     draw_string("By Jim Babcock", 30, 40, F_4x6);
00052     draw_string("Based on Kye by Dillon Collins", 30, 47, F_4x6);
00053     draw_string("and on Kye by Colin Garbutt", 30, 54, F_4x6);
00054     read_char();
00055 }
00056 //}}}
00057 //{{{
00058 int show_splash(void)
00059 {
00060     char buf[64];
00061     int font;
00062     clear_screen();
00063     sprintf(buf, "Level %i:", current_level_num+1);
00064     draw_string(buf, SCREEN_CENTER-DrawStrWidth(buf, F_4x6)/2, 20, F_4x6);
00065     if(strlen(current_map.name) <= 19) // Name short enough for 8x10 font
00066         font = F_8x10;
00067     else if(strlen(current_map.name) <= 26) // Name short enough for 6x8 font
00068         font = F_6x8;
00069     else                               // Very long name! Use 4x6.
00070         font = F_4x6;
00071     
00072     draw_string(current_map.name,
00073         SCREEN_CENTER - DrawStrWidth(current_map.name,font)/2, 28, font);
00074     
00075     if(strlen(current_map.author) > 0) {
00076         sprintf(buf, "By %s", current_map.author);
00077         draw_string(buf, SCREEN_CENTER-DrawStrWidth(buf, F_4x6)/2, 44, F_4x6);
00078     }
00079     
00080     draw_string("+",                      3, 80, F_4x6);
00081     draw_string("Next level",             8, 80, F_4x6);
00082     draw_string("-",                      3, 86, F_4x6);
00083     draw_string("Previous level",         8, 86, F_4x6);
00084     draw_string("Press any other key to begin", 3, 92, F_4x6);
00085     return read_char();
00086 }
00087 //}}}
00088 
00089 //{{{
00090 void message(const char *message)
00091 {
00092     int in;
00093     int width = DrawStrWidth(message, F_4x6);
00094     int left = SCREEN_CENTER - width/2 - 5;
00095     
00096     draw_rect(left, 35, width+10, 10);
00097     draw_string(message, left+5, 37, F_4x6);
00098     
00099     do {
00100         in = read_char() & ~0x800;
00101         if(in == KEY_LEFT || in == KEY_RIGHT ||
00102            in == KEY_UP || in == KEY_DOWN)
00103             continue;
00104         else
00105             break;
00106     } while(1);
00107 }
00108 //}}}
00109 

Generated on Thu Apr 22 14:06:33 2004 for SKye by doxygen 1.3.6