/*************************************************** エントリ ***************************************************/ int main (void) { // ゲームパックウェイト&キャッシュ *((vu16 *) 0x04000204) = 0x4317; // BG初期化 init_bg (); // スプライト初期化 init_sprite (); // キー初期化 init_key (); // サウンド初期化 DirectSoundInitialize (); // キャラクタ初期化 init_sprite_chr (); // ハイスコア初期化 init_hiscore (); // ゲーム初期化 init_game (); // タイトル init_title (); // 割り込み初期化 irqInit (); // サウンド用ハンドラ MUSIC / SE irqSet (IRQ_TIMER0, IRQ_Music); irqSet (IRQ_TIMER1, IRQ_Sound); irqEnable (IRQ_VBLANK | IRQ_TIMER0 | IRQ_TIMER1); // タイトル PlayMusic (MUSIC_TITLE, PLAY_LOOP_ON); // メインループ while (1) { // キー入力 scanKeys (); // ゲーム本体 game (); // 割り込み待ち VBlankIntrWait (); } }
/* the main program body */ int main(int argc, char *argv[]) { ALLEGRO_PATH *font_path; int w = 0, h = 0; int www = FALSE; int i, n; int display_flags = ALLEGRO_GENERATE_EXPOSE_EVENTS; srand(time(NULL)); al_set_org_name("liballeg.org"); al_set_app_name("SPEED"); if (!al_init()) { fprintf(stderr, "Could not initialise Allegro.\n"); return 1; } al_init_primitives_addon(); /* parse the commandline */ for (i=1; i<argc; i++) { if (strcmp(argv[i], "-cheat") == 0) { cheat = TRUE; } else if (strcmp(argv[i], "-simple") == 0) { low_detail = TRUE; } else if (strcmp(argv[i], "-nogrid") == 0) { no_grid = TRUE; } else if (strcmp(argv[i], "-nomusic") == 0) { no_music = TRUE; } else if (strcmp(argv[i], "-www") == 0) { www = TRUE; } else if (strcmp(argv[i], "-fullscreen") == 0) { /* if no width is specified, assume fullscreen_window */ display_flags |= w ? ALLEGRO_FULLSCREEN : ALLEGRO_FULLSCREEN_WINDOW; } else { n = atoi(argv[i]); if (!n) { usage(); return 1; } if (!w) { w = n; if (display_flags & ALLEGRO_FULLSCREEN_WINDOW) { /* toggle from fullscreen_window to fullscreen */ display_flags &= ~ALLEGRO_FULLSCREEN_WINDOW; display_flags |= ALLEGRO_FULLSCREEN; } } else if (!h) { h = n; } else { usage(); return 1; } } } /* it's a real shame that I had to take this out! */ if (www) { printf( "\n" "Unfortunately the built-in web browser feature had to be removed.\n" "\n" "I did get it more or less working as of Saturday evening (forms and\n" "Java were unsupported, but tables and images were mostly rendering ok),\n" "but the US Department of Justice felt that this was an unacceptable\n" "monopolistic attempt to tie in web browsing functionality to an\n" "unrelated product, so they threatened me with being sniped at from\n" "the top of tall buildings by guys with high powered rifles unless I\n" "agreed to disable this code.\n" "\n" "We apologise for any inconvenience that this may cause you.\n" ); return 1; } if (!w || !h) { if (argc == 1 || (display_flags & ALLEGRO_FULLSCREEN_WINDOW)) { w = 640; h = 480; } else { usage(); return 1; } } /* set the screen mode */ al_set_new_display_option(ALLEGRO_SAMPLE_BUFFERS, 1, ALLEGRO_SUGGEST); al_set_new_display_option(ALLEGRO_SAMPLES, 4, ALLEGRO_SUGGEST); al_set_new_display_flags(display_flags); screen = al_create_display(w, h); if (!screen) { fprintf(stderr, "Error setting %dx%d display mode\n", w, h); return 1; } al_init_image_addon(); /* The Allegro 5 port introduced an external data dependency, sorry. * To avoid performance problems on graphics drivers that don't support * drawing to textures, we build up transition screens on memory bitmaps. * We need a font loaded into a memory bitmap for those, then a font * loaded into a video bitmap for the game view. Blech! */ font_path = get_resources_path(); al_set_path_filename(font_path, "a4_font.tga"); al_init_font_addon(); al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP); font = al_load_bitmap_font(al_path_cstr(font_path, '/')); if (!font) { fprintf(stderr, "Error loading %s\n", al_path_cstr(font_path, '/')); return 1; } al_set_new_bitmap_flags(ALLEGRO_VIDEO_BITMAP); font_video = al_load_bitmap_font(al_path_cstr(font_path, '/')); if (!font_video) { fprintf(stderr, "Error loading %s\n", al_path_cstr(font_path, '/')); return 1; } al_destroy_path(font_path); /* set up everything else */ al_install_keyboard(); al_install_joystick(); if (al_install_audio()) { if (!al_reserve_samples(8)) al_uninstall_audio(); } init_input(); init_sound(); init_hiscore(); /* the main program body */ while (title_screen()) { if (play_game()) { show_results(); score_table(); } } /* time to go away now */ shutdown_hiscore(); shutdown_sound(); goodbye(); shutdown_input(); al_destroy_font(font); al_destroy_font(font_video); return 0; }