Ejemplo n.º 1
0
struct graph *graph_create(int nvertices)
{
    struct graph *g;
    g = malloc(sizeof(*g));
    g->nvertices = nvertices;
    g->visited = malloc(sizeof(int) * (nvertices + 1));
    g->m = (int **) malloc(nvertices * sizeof(int *));
    if (g->m != NULL) {
        for (int i = 0; i < nvertices; i++) {
            g->m[i] = (int *) malloc(nvertices * sizeof(int));
        }
    }
    else {
        printf("Can't create buffer!\n");
    }
    graph_clear(g); // Опционально, O(n^2)
    return g;
}
Ejemplo n.º 2
0
Archivo: op_06.c Proyecto: nmlgc/ReC98
void pascal musicroom(void)
{
	static unsigned char track_playing = 0;
	music_page = 1;

	palette_black();

	graph_showpage(0);
	graph_accesspage(0);
	graph_clear();
	graph_accesspage(1);

	pi_load_put_free(0, "op3.pi");
	music_sel = track_playing;
	draw_tracks(music_sel);
	graph_copy_page(0);

	graph_accesspage(1);
	graph_showpage(0);
	screen_back_B_snap();
	cmt_back_snap();

	graph_accesspage(1);	draw_cmt(track_playing);
	graph_accesspage(0);	draw_cmt(track_playing);

	palette_100();

	do {
		input_sense();
		if(input) {
			music_flip();
			continue;
		}
controls:
		input_sense();
		if(input & INPUT_UP) {
			draw_track(music_sel, 3);
			if(music_sel > 0) {
				music_sel--;
			} else {
				music_sel = SEL_QUIT;
			}
			if(music_sel == TRACK_COUNT) {
				music_sel--;
			}
			draw_track(music_sel, 15);
		}
		if(input & INPUT_DOWN) {
			draw_track(music_sel, 3);
			if(music_sel < SEL_QUIT) {
				music_sel++;
			} else {
				music_sel = 0;
			}
			if(music_sel == TRACK_COUNT) {
				music_sel++;
			}
			draw_track(music_sel, 15);
		}
		if(input & INPUT_SHOT || input & INPUT_OK) {
			if(music_sel != SEL_QUIT) {
				char midi_active = snd_midi_active;

				snd_midi_active = snd_midi_possible;
				snd_load(MUSIC_FILES[music_sel], SND_LOAD_SONG);
				snd_midi_active = 0;
				snd_load(MUSIC_FILES[music_sel], SND_LOAD_SONG);
				snd_midi_active = midi_active;
				snd_kaja_func(KAJA_SONG_PLAY, 0);
				track_playing = music_sel;

				draw_cmt(music_sel);
				music_flip();
				draw_cmt(music_sel);
			} else {
				break;
			}
		}
		if(input & INPUT_CANCEL) {
			break;
		}
		if(!input) {
			music_flip();
			goto controls;
		}
	} while(1);
	while(1) {
		input_sense();
		if(input) {
			music_flip();
		} else {
			break;
		}
	};
	screen_back_B_free();
	cmt_back_free();
	graph_showpage(0);
	graph_accesspage(0);
	graph_clear();
	graph_accesspage(1);
	pi_load_put_free(0, "op2.pi");
	palette_entry_rgb_show("op.rgb");
	graph_copy_page(0);
	graph_accesspage(0);
}
Ejemplo n.º 3
0
Archivo: op_01.c Proyecto: nmlgc/ReC98
int main(void)
{
    unsigned char ret;
    if(snd_pmd_resident()) {
        snd_mmd_resident();
        if(game_init_op()) {
            zun_error(ERROR_OUT_OF_MEMORY);
            return 1;
        }
        extra_unlocked = score_cleared_load();
        if(cfg_load() == 1) {
            return 1;
        }
    } else {
        return 1;
    }
    gaiji_backup();
    gaiji_entry_bfnt("MIKOFT.bft");
    if(mikoconfig->demo_num == 0) {
        demo_num = 1;
        snd_kaja_func(KAJA_SONG_STOP, 0);
    } else {
        demo_num = mikoconfig->demo_num + 1;
        if(demo_num > 3) {
            demo_num = 1;
        }
        score_duration = 350;
        score_menu();
        graph_showpage(0);
        graph_accesspage(0);
    }
    input = 0;

    snd_active = snd_bgm_mode;
    if(!mikoconfig->demo_num && snd_midi_possible) {
        char midi_active = snd_midi_active;

        snd_midi_active = 1;
        snd_load("gminit.m", SND_LOAD_SONG);
        snd_kaja_func(KAJA_SONG_PLAY, 0);
        snd_midi_active = midi_active;
    }

    op_animate();
    pi_slot_load(2, "ts3.pi");
    pi_slot_load(1, "ts2.pi");
    input = 0;
    idle_frames = 0;

    while(!quit) {
        input_sense();
        if(in_option == 0) {
            main_update_and_render();
        } else if(in_option == 1) {
            option_update_and_render();
        }
        mikoconfig->frame++;
        idle_frames++;
        frame_delay(1);
    }

    ret = mikoconfig->op_main_retval;
    mikoconfig_sgm = 0;
    cfg_save();
    text_clear();
    graph_clear();
    game_exit_to_dos();
    gaiji_restore();
    return ret;
}