Esempio n. 1
0
 /**
 * This function shows and allows to pick the
 * player who is going to play first
 *
 * @v info_s
 * @return	none
 * @date	2014-04-22
 * @author	PL Team
 **/
void show_who_first()

{
    int control;
    int who_first_start_game;

    do
    {
        clearscr();
        printf("Triplets - %s vs %s\n\n", G_players[0].name, G_players[1].name);
        printf("Select who goes first:\n1. %s\n2. %s\n3. Random\n(Choose an option and press enter): ",G_players[0].name,G_players[1].name);
        control=scanf("%d",&who_first_start_game);
        if (who_first_start_game==3)
        {
            who_first_start_game=rand()%2 + 1;
        }
        clean_buffer_keyboard();
    }
    while (who_first_start_game<1 || who_first_start_game>2 || control==0);
    switch(who_first_start_game)
    {
    case 1:
        G_current_game.player_first= 1;
        G_players[0].number=1;
        G_players[1].number=2;
        break;
    case 2:
        G_current_game.player_first= 0;
        G_players[0].number=2;
        G_players[1].number=1;
        break;
    }
    clearscr();
}
Esempio n. 2
0
void main()
{
	//enum data_source ABC;
	//ABC=PRBS7;
	tChar temp;
	lcd_init();
	display("Initializing...");
	enable_spi(0);
	dac_set(0);
	chip_init_CCFFE();
	pll_init();
	clearscr();
    enable_serial();
    display("Set Jumpers and ping");
    temp = receive_serial();
    clearscr();

	display("Offset trim DUT1");
	sel_source(OFFSET_CAL);
	msDelay(1);
	LF_SELECT = 0;
	CHIP_RESET = 0;
//	LF_SELECT=1;
	while(1);
//	{
//		LF_SELECT=1;
//		msDelay(10000);
//		LF_SELECT=0;
//		msDelay(10000);
//	}
}
Esempio n. 3
0
 /**
 * This function shows the possible difficulties of
 * the CPU and allows the user to pick one
 *
 * @v info_s
 * @return	none
 * @date	2014-05-13
 * @author	Gabriel Rodrigues
 **/
void show_difficulty()
{

    int menu_choose;
    int control; // to verify if it is not a char!

    do
    {
        clearscr();
        printf("Triplets Game\n\n");
        printf("Choose the CPU difficulty:\n");
        printf("1. Player vs Computer: (EASY)\n");
        printf("2. Player vs Computer: (HARD)\n\n");
        printf("(Choose an option and press enter): ");

        control=scanf("%d",&menu_choose);
        clean_buffer_keyboard();
    }
    while(menu_choose<1 || menu_choose>2 || control == 0);

    switch(menu_choose)
    {

    case 1:
        G_current_game.cpu_mode = easy;
        break;
    case 2:
        G_current_game.cpu_mode = hard;
        break;
    }
}
Esempio n. 4
0
 /**
 * This function shows the possible game modes of
 * the PvP mode and allows the user to pick one
 *
 * @v info_s
 * @return	none
 * @date	2014-05-20
 * @author	Gabriel Rodrigues
 **/
void show_pvp_mode()
{

    int menu_choose;
    int control; // to verify if it is not a char!

    do
    {
        clearscr();
        printf("Triplets Game\n\n");
        printf("Choose the PvP Mode:\n");
        printf("1. Normal Mode. \n");
        printf("2. Column Mode (it's a challenge!). \n\n");
        printf("(Choose an option and press enter): ");

        control=scanf("%d",&menu_choose);
        clean_buffer_keyboard();
    }
    while(menu_choose<1 || menu_choose>2 || control == 0);

    switch(menu_choose)
    {

    case 1:
        G_current_game.pvp_mode = normal;
        break;
    case 2:
        G_current_game.pvp_mode = column;
        break;
    }
}
Esempio n. 5
0
void retro_reset(void)
{
   init_cpu();
   init_roms();
   init_vpp();
   clearscr();
}
Esempio n. 6
0
void    menu_7 (void)
{
    int loop = TRUE;
    int c;
    
    clearscr(pm->term_length);
    while ( loop ) {
        printf (" Menu 7 A Bit of fun \n");
        printf ("\n");
        printf (" (1) Test your knowledge of the genetic code \n");
        printf (" (X) Exit this menu\n");
        printf (" Select a menu choice, (Q)uit or (H)elp -> ");
        gets(pm->junk);
        clearscr(pm->term_length);

        if (isalpha( (int) pm->junk[0]) || pm->junk[0]=='\0') {
            c =  toupper( (int) pm->junk[0]);
            switch ( c ) {
            case 'Q':
                my_exit(2,"menu 7");
                break;
            case 'X': case '\0':
                return;

            case 'H':
                chelp("menu_7");
                continue;
                break;

            default:
                fprintf( stderr, "The answer %s is not a valid\n", pm->junk);
                pause;
                break;
            }
        } else {
            c = atoi(pm->junk);
            if ( c == 1 )
                tester();        /****** call tester () ********************/
            else {
                fprintf( stderr, "The answer %s is not a valid\n", pm->junk);
                continue;
            }
        }
    }
    return;
}
Esempio n. 7
0
void init_display()
{
	os_hide_cursor();
	textio_init();
	viewpage(2);
	outpage(2);
	clearscr();
}
Esempio n. 8
0
void    menu_6 (void)
{
    int loop = TRUE;
    int c;
    
    clearscr(pm->term_length);
    while ( loop ) {
        printf (" Menu 6-Basic Stats\n");
        printf ("\n");
        printf ("\t ( ) Sorry currently unimplemented \n");
        printf ("\t (X) Exit this menu\n");
        printf (" Select a menu choice, (Q)uit or (H)elp -> ");
        gets(pm->junk);
        clearscr(pm->term_length);

        if (isalpha( (int) pm->junk[0])|| pm->junk[0] == '\0') {
            c =  toupper( (int) pm->junk[0]);
            switch ( c ) {
            case 'Q':
                my_exit(2,"menu 6");
                break;
            case 'X': 
            case '\0':
                return;
            case 'H':
                 chelp("menu_6");
                 break;
            default:
                fprintf( stderr, "The answer %s is not a valid\n", pm->junk);
                pause;
                break;
            }
        } else {
            c =  atoi(pm->junk);
            if ( c > 0 && c <= 9 )
                main_menu((int) c);
            else {
                fprintf( stderr, "The answer %s is not a valid\n", pm->junk);
                continue;
            }
        }
    }
    return;
}
Esempio n. 9
0
void show_credits()
{
    clearscr();
    printf("Triplets game developers:\n\n Poland Team:\n -Paliga Krzysztof\n -Gradzi%cski Tomasz\n -Daniel W%cgrzyn\n\n",228,169);
    printf(" Portugal Team:\n -Jo%co Ramos\n -Eduardo Andrade\n -Gabriel Rodrigues\n\n",199);
    printf(" Spain Team:\n -Nuria Manchado Bustelos\n -Andres Martin de la Iglesia\n\n");
    printf(" Promoters:\n -Patricio Domingues (from Portugal)\n\n");
    printf("Press any key to go back to main menu...");
    readchar();
}
Esempio n. 10
0
void show_game_rules()
{
    clearscr();
    printf("This game is called Triplets Game. \n");
    printf("\nThe rules are:\n");
    printf("1. The goal is to connect 3 pieces in a line\n\t-This can be vertically, horizontally or across\n\t-First to do this, is the winner\n");
    printf("2. You can win with your own pieces or your opponent's pieces - be careful!\n");
    printf("3. There's 3 board sizes: small (3x3) medium (6x6) and large (12x12).\n");
    printf("4. Matches can be played as Player vs Player or Player vs Computer.\n");
    printf("\nPress any key to go back to main menu...");
    readchar();
}
Esempio n. 11
0
void display_board(board *b)
{
	int x, y;

	if (alt_video_page) {
		outpage(2);
	} else {
		outpage(4);
	}

	textcolour(7);
	clearscr();

	movecur(30, 7);
	os_long_int_to_string(&score, 10, conv_buffer);
	strout("Score: ");
	strout(conv_buffer);

	for (y = 0; y < brd_h; y++) {
		movecur(30, y * 2 + 8);
		strout(seperator);
		movecur(30, y * 2 + 9);

		for (x = 0; x < brd_w; x++) {
			charout('|');

			if ((*b)[y][x] < 10000) charout(' ');
			if ((*b)[y][x] < 1000) charout(' ');
			if ((*b)[y][x] < 100) charout(' ');
			if ((*b)[y][x] < 10) charout(' ');

			if ((*b)[y][x] == 0) {
				charout(' ');
			} else {
				strout(os_int_to_string((*b)[y][x]));
			}
		}

		charout('|');
	}
	
	movecur(30, 16);
	strout(seperator);

	if (alt_video_page) {
		viewpage(2);
		alt_video_page = 0;
	} else {
		viewpage(4);
		alt_video_page = 1;
	}
}
Esempio n. 12
0
void    menu_2 (void)
{
    int loop = TRUE;
    int  c;
    
    clearscr(pm->term_length);
    while ( loop ) {
        printf (" Menu 2 \n");
        printf (" Purifying sequences menu\n");
        printf ("\t ( ) Sorry currently unimplemented \n");
        printf ("\t (X) Exit this menu\n");
        printf (" Select a menu choice, (Q)uit or (H)elp -> ");
        gets(pm->junk);
        clearscr(pm->term_length);

        if (isalpha((int)pm->junk[0]) || pm->junk[0]=='\0' ) {
            c = toupper( (int) pm->junk[0]);
            switch ( c ) {
            case 'Q':
                my_exit(2,"menu 2");
                break;
            case 'X':
            case '\0':
                return;
            case 'H':
                chelp("menu_2");
                break;
            default:
                fprintf( stderr, "The answer %s is not a valid\n", pm->junk);
                pause;
                break;
            }
        } 
    }
    return;
}
Esempio n. 13
0
 /**
 * This function shows the menu to pick the size of the board
 *
 * @v info_s
 * @return	none
 * @date	2014-04-18
 * @author	PL Team
 **/
void choose_board()
{
    int control; // to verify if it is not a char!
    int size_board;
    do
    {
        //clearscr();
        printf("\nChoose board size:\n");
        printf("1. Small board (%dx%d)\n", BOARD_SMALL, BOARD_SMALL);
        printf("2. Medium board (%dx%d)\n", BOARD_MEDIUM, BOARD_MEDIUM);
        printf("3. Big board (%dx%d)\n", BOARD_BIG, BOARD_BIG);
        printf("4. Large board (%dx%d)\n\n", BOARD_LARGE, BOARD_LARGE);
        printf("(Choose an option and press enter): ");

        control=scanf("%d",&size_board);
        clean_buffer_keyboard();

    }
    while (size_board<1 || size_board>4 || control ==0);

    switch(size_board)
    {
    case 1:
        board_set_size(BOARD_SMALL);
        G_current_game.board_columns=BOARD_SMALL;
        G_current_game.board_rows=BOARD_SMALL;
        break;
    case 2:
        board_set_size(BOARD_MEDIUM);
        G_current_game.board_columns=BOARD_MEDIUM;
        G_current_game.board_rows=BOARD_MEDIUM;
        break;
    case 3:
        board_set_size(BOARD_BIG);
        G_current_game.board_columns=BOARD_BIG;
        G_current_game.board_rows=BOARD_BIG;
        break;
    case 4:
        board_set_size(BOARD_LARGE);
        G_current_game.board_columns=BOARD_LARGE;
        G_current_game.board_rows=BOARD_LARGE;
        break;
    default:
        clearscr();
        choose_board();
        break;
    }
}
Esempio n. 14
0
void showhelp()
{
    int y = 4;

	clearscr();
	frame(1, 80, 1, 24, "Arkanoid!!!", 'l', 2, 0);
	gotoxy(35, y);
	printf("Helpscreen:");

	y++;
	gotoxy(MENUOFFSET, ++y);
	printf("Menu:");
	gotoxy(MENUOFFSET, ++y);
	printf("Navigate the menus with a(up) and s(down)");
	gotoxy(MENUOFFSET, ++y);
	printf("Press d to select the marked menu item");

	y++;
	gotoxy(MENUOFFSET, ++y);
	printf("In Game:");
	gotoxy(MENUOFFSET, ++y);
	printf("Move the striker with a(left) and s(right)");
	gotoxy(MENUOFFSET, ++y);
	printf("To exit the game press q");

	y++;
	gotoxy(MENUOFFSET, ++y);
	printf("\"Start a new game\" starts a new game on level one");
	gotoxy(MENUOFFSET, ++y);
	printf("\"Hall of fame\" lists the highscores of previous games");
	gotoxy(MENUOFFSET, ++y);
	printf("\"Introduction\" displays this message");
	gotoxy(MENUOFFSET, ++y);
	printf("\"Quit\" quits the game");

	gotoxy(30, 20);
	printf("Press d to continue");

while(getchar()!='d'){}

}
Esempio n. 15
0
void    main_menu ( int menu )
{
    switch ( menu ) {                                 /* go to menu X    */
    case 0:
        menu_initial();
        break;
    case 1:
        menu_1();
        break;
    case 2:
        menu_2();
        break;
    case 3:
        menu_3();
        break;
    case 4:
        menu_4();
        break;
    case 5:
        menu_5();
        break;
    case 6:
        menu_6();
        break;
    case 7:
        menu_7();
        break;
    case 8:
        menu_8();
        break;
    case 9:
        printinfo();
        welcome();
        pause;
        clearscr(pm->term_length);
        break;                     
    default:
        fprintf ( stderr,"ERROR: Unrecognised menu in main_menu\n");
        break;
    }
}
Esempio n. 16
0
void SWSerLCDpa::clearscr(const char *s)
{
    clearscr();
    print(s);
}
Esempio n. 17
0
void show_menu()
{
    int who_first_start_game;
    int menu_choose;
    int control; // to verify if it is not a char!

    do
    {
        clearscr();
        printf("Triplets Game\n\n");
        printf("1. Play : Player vs Computer (PvC)\n");
        printf("2. Play : Player vs Player (PvP)\n");
        printf("3. Game rules\n");
        printf("4. High scores\n");
        printf("5. Credits\n\n");
        printf("6. Exit Game.\n\n");
        printf("(Choose an option and press enter): ");



        control=scanf("%d",&menu_choose);
        clean_buffer_keyboard();


    }
    while (menu_choose<1 || menu_choose>6 || control == 0);


    switch(menu_choose)
    {

    case 1:
        G_current_game.game_mode=pvc;
        clearscr();
        printf("Triplets - Player vs Computer\n\n");
        printf("Enter your name: ");
        scanf("%s",G_players[0].name);
        strcpy(G_players[1].name, "CPU");// G_players[1] is cpu player
        choose_board();


        do
        {
            clearscr();
            printf("Triplets - %s vs %s\n\n", G_players[0].name, G_players[1].name);
            printf("Select who goes first:\n1. %s\n2. %s\n\n(Choose an option and press enter): ",G_players[0].name,G_players[1].name);
            control=scanf("%d",&who_first_start_game);
            clean_buffer_keyboard();

        }
        while (who_first_start_game<1 || who_first_start_game>2 || control==0);

        switch(who_first_start_game)
        {
        case 1:
            G_current_game.player_first= 1;
            break;
        case 2:
            G_current_game.player_first= 0;
            break;
        }

        clearscr();
        break;
    case 2:
        G_current_game.game_mode=pvp;
        clearscr();
        printf("Triplets - Player vs Player\n");
        printf("Enter the name of player 1: ");
        scanf("%s",G_players[0].name);
        printf("\nEnter the name of player 2: ");
        scanf("%s",G_players[1].name);
        choose_board();

        do
        {
            clearscr();
            printf("Triplets - %s vs %s\n\n", G_players[0].name, G_players[1].name);
            printf("Select who goes first:\n1. %s\n2. %s\n\n(Choose an option and press enter): ",G_players[0].name,G_players[1].name);
            control=scanf("%d",&who_first_start_game);
            clean_buffer_keyboard();
        }
        while (who_first_start_game<1 || who_first_start_game>2 || control==0);
        switch(who_first_start_game)
        {
        case 1:
            G_current_game.player_first= 1;
            break;
        case 2:
            G_current_game.player_first= 0;
            break;
        }
        clearscr();
        break;

    case 3:
        show_game_rules();
        show_menu();
        break;
    case 4:
        //show High scores//
        show_highscores();
        show_menu();
        break;
    case 5:
        show_credits();
        show_menu();
        break;
    case 6:
        exit(0);
        break;
    default:
        clearscr();
        show_menu();
        break;
    }
}
Esempio n. 18
0
/*=====================================
* main
*===================================*/
int main(void){
reset_data_structs();
clearscr();
welcome_screen();
show_menu();

int check=0;
if(G_current_game.game_mode==pvp){ //pvp mode

    if(G_current_game.player_first==1){  // who first start game,  first move
        cmp.current_player_move=G_players[0];
        cmp.previous_player_move=G_players[1];
    }
    else{
       cmp.current_player_move=G_players[1];
       cmp.previous_player_move=G_players[0];
    }

//    while(1){   // in while add finish_game...
    while( !finish_game_wrapper(pos) ){
            //system("cls");
            clearscr();
            board_print_raw();
                do{
                        //
                    printf("%s your move! (all your moves: %d)\n",cmp.current_player_move.name,cmp.current_player_move.moves);
                    read_move(&pos);
                    check = function_validate_move(pos);
                    }while(check != 0);

            cmp.current_player_move.moves+=1;
            cmp.tmp=cmp.current_player_move;                   //swap current player
            cmp.current_player_move=cmp.previous_player_move;  //
            cmp.previous_player_move=cmp.tmp;                  //
    }//end while(1)
    cmp.tmp=cmp.current_player_move;                   //swap current player
    cmp.current_player_move=cmp.previous_player_move;  //
    cmp.previous_player_move=cmp.tmp;
    board_print_raw();
    printf("%s wins! (In %d moves!)\n",cmp.current_player_move.name,cmp.current_player_move.moves);
}// end pvp mode

if(G_current_game.game_mode==pvc){ //pvc mode

    if(G_current_game.player_first==1){  // who first start game,  first move
        cmp.current_player_move=G_players[0];
        cmp.previous_player_move=G_players[1];// G_players[1] is cpu player
    }
    else{
       cmp.current_player_move=G_players[1];
       cmp.previous_player_move=G_players[0];
    }
    while(1){
            //system("cls");
            clearscr();
            board_print_raw();
            do{
                printf("%s your move! (all your moves: %d)\n",cmp.current_player_move.name,cmp.current_player_move.moves);
                read_move(&pos);
                check = function_validate_move(pos);
                }while(check != 0);

            cmp.current_player_move.moves+=1;
            cmp.tmp=cmp.current_player_move;                   //swap current player
            cmp.current_player_move=cmp.previous_player_move;  //
            cmp.previous_player_move=cmp.tmp;                  //
    }//end while(1)
}// end pvc
return 0;
}
Esempio n. 19
0
 /**
 * This function shows the main menu
 *
 * @v info_s
 * @return	none
 * @date	2014-04-14
 * @author	PL Team
 **/
void show_menu()
{
    int menu_choose;
    int control; // to verify if it is not a char!
    char player1nameAux[MAX_PLAYERNAME_LENGTH]="";
    char player2nameAux[MAX_PLAYERNAME_LENGTH]="";

    do
    {
        clearscr();
        printf("Triplets Game\n\n");
        printf("1. Play : Player vs Computer (PvC)\n");
        printf("2. Play : Player vs Player (PvP)\n");
        printf("3. Game rules\n");
        printf("4. High scores\n");
        printf("5. Replay game\n");
        printf("6. Credits\n\n");
        printf("7. Exit Game.\n\n");
        printf("(Choose an option and press enter): ");



        control=scanf("%d",&menu_choose);
        clean_buffer_keyboard();


    }
    while (menu_choose<1 || menu_choose>7 || control == 0);


    switch(menu_choose)
    {

    case 1:
        G_current_game.game_mode=pvc;
        G_current_game.pvp_mode = notpvp;
        show_difficulty();
        choose_interface();
        clearscr();
        printf("Triplets - Player vs Computer \n\n");
        do
        {
            printf("Enter your name: ");
            fgets(G_players[0].name, MAX_PLAYERNAME_LENGTH, stdin);
            terminate_string_at_first_slash_n(G_players[0].name);
            strcpy(player1nameAux,G_players[0].name);
            string_to_lower(player1nameAux);

            if (!strcmp(player1nameAux,"cpu"))
            {
                printf("Invalid name.\n");
            }
        }
        while (!strcmp(player1nameAux,"cpu"));
        strcpy(G_players[1].name, "CPU");// G_players[1] is cpu player
        choose_board();


        show_who_first();

        break;

    case 2:
        G_current_game.game_mode=pvp;
        G_current_game.cpu_mode = none;
        clearscr();
        printf("Triplets - Player vs Player\n");
        do
        {
            printf("Enter the name of player 1: ");
            fgets(G_players[0].name, MAX_PLAYERNAME_LENGTH, stdin);
            terminate_string_at_first_slash_n(G_players[0].name);
            strcpy(player1nameAux,G_players[0].name);
            string_to_lower(player1nameAux);

            if (!(strcmp(player1nameAux,"cpu")))
            {
                printf("Invalid name.\n");
            }
        }
        while (!(strcmp(player1nameAux,"cpu")));
        do
        {
            printf("\nEnter the name of player 2: ");
            fgets(G_players[1].name, MAX_PLAYERNAME_LENGTH, stdin);
            terminate_string_at_first_slash_n(G_players[1].name);
            strcpy(player2nameAux,G_players[1].name);
            string_to_lower(player2nameAux);

            if (!(strcmp(player2nameAux,"cpu")) || !(strcmp(player2nameAux,player1nameAux)))
            {
                printf("Invalid name.\n");
            }
        }
        while (!(strcmp(player2nameAux,"cpu")) || !(strcmp(player2nameAux,player1nameAux)));

        show_pvp_mode();
        if (G_current_game.pvp_mode == normal)
        {
            choose_interface();
        }
        else
        {
            G_current_game.interface_mode = console;
        }
        choose_board();
        show_who_first();

        break;

    case 3:
        show_game_rules();
        show_menu();
        break;
    case 4:
        //show High scores//
        show_highscores();
        show_menu();
        break;
    case 5:
        replay_menu(); // this is in PT_save_read_moves.c
        show_menu();
        break;
    case 6:
        show_credits();
        show_menu();
        break;
    case 7:
        exit(0);
        break;
    default:
        clearscr();
        show_menu();
        break;
    }
}
Esempio n. 20
0
int main(void)
{

	struct person player =
	{
		// Name
		"\0",
		// Position
		{0, 0},
		// Map
		{
			{"+=======+==========+"},
			{"|SHP    |G         |"},
			{"|G      |          |"},
			{"|=======+==========|"},
			{"|       |PP        |"},
			{"|       |PP        |"},
			{"|       +==========|"},
			{"|       |HHHH      |"},
			{"|       |HH        |"},
			{"|       +====+     |"},
			{"|=======+    |     |"},
			{"|     GG|    |SS   |"},
			{"|       |    +=====|"},
			{"|       |          |"},
			{"|=======+          |"},
			{"|       HHH        |"},
			{"|        Ho====+===|"},
			{"|   PPP        |   |"},
			{"|   PPP        |   |"},
			{"+==============+===+"}
		},
		// Health (actual, full)
		{50, 100},
		// Money
		10000.00,

		// Skill_points;
		10,
		// Intelligence;
		1,
		// Stealth;
		1,
		// Charisma;
		1,

		// Equipped Weapon
		0,
		// Equipped Ammo
		{0,0},
		// Weapons
		{
			{0,0},
			{0,0},
			{0,0},
			{0,0},
			{0,0},
			{0,0},
			{0,0},
			{0,0},
			{0,0},
			{0,0},
		},
		// Items
		{
			{0, 0},
			{0, 0},
			{0, 0},
			{0, 0},
			{0, 0},
			{0, 0},
			{0, 0},
			{0, 0},
			{0, 0},
			{0, 0}
		}
	};

	// Command list
	char commandlist[MAX_COMMAND_LENGTH][NUM_OF_COMMANDS]=
	{
		{"enter"},
		{"exit"},
		{"help"},
		{"inv"},
		{"map"},
		{"tile"},
		{"walk"}
	};

	// Command
	char command[100];
	char cmdprompt[10];

	// Word (Sectioned Command)
	char *word[100];

	/////////////////////////
	// Database

	//item objects = NULL;
	//int num_obj = 0;

	/////////////////////////
	// Main Menu
	do
	{
		clearscr();
		printf("Urban Sprawl\n");
		printl();
		printf("By: Sami Volk	2012\n");
		pause();
		//clearscr();
		do
		{
			printf("Please type in one of the commands: \n");
			printf("NEW - starts a new game \t\t");
			printf("QUIT - quits game\n");

			get_command(">> ",command);
			//clearscr();

			// check for "exit" command.
			if ((strcmp("exit", command) == 0) || (strcmp("quit", command) == 0))
			{
				printf("Good bye!");
				pause();
				exit(0);
			}
			else if (strcmp("new", command) == 0)
			{
				printf("What is your name?\n");
				fgets(player.name, 100, stdin);
				fflush(stdin);
				//clearscr();
				break;
			}
			else
			{
				printf("Command not recognized.\n");
				pause();
			}

		}while (1);

		break;

	}while (1);

	/////////////////////////
	// Main game loop
	do
	{

		//printf("name: %s\n", player.name);
		//printf("Position: %d, %d \n", player.position[0], player.position[1]);
		//printf("Health: %d / %d\n", player.health[0], player.health[1]);
		//printf("Money: $%.2f\n", player.money);
		//printl();

		//tile_info(player.map, player.position);
		//printl();

		sprintf(cmdprompt, "\033[22;31m%d/%d \033[22;37m>> ", player.health[0], player.health[1]);
		//printf("%s\n", cmdprompt);

		get_command(cmdprompt,command);
		split_command(command, word);
		check_command(word, &player);
		printl();

	} while (1);

	return 0;

}
void loadLogs(int gameCounter)
{

    FILE *playLog;

    int playNumber;
    char dateExtended[32];
    char playerName[30];
    int dimension;
    int i;
    int moveX;
    char moveY;
    int lineCounter=0;
    int headLinesNumber=6;
    char logName[255];

    sprintf(logName, "data/logs/TripletsLog-%d.txt", gameCounter);

    lineCounter=get_file_lines(logName);

    lineCounter-=headLinesNumber;

    lineCounter++; // to add the last line which doesn't have /n !!


    playLog = fopen(logName, "rt");
    if(playLog == NULL)
    {
        printf("\n\tERR: Unable to read Log!");
    }
    else
    {
        gameCounter=0;
        dimension=0;
        fscanf(playLog, "--Triplets Log--\n");
        fscanf(playLog, "Game #%d\n", &gameCounter);
        fscanf(playLog, "Matrix Dimension: %dx%d\n", &dimension, &dimension);
        fscanf(playLog, "Started on: %s\n", dateExtended);

        board_set_size(dimension);
        board_set_empty();
        clearscr();
        board_print_raw();
        init_players();

        for (i=0; i<lineCounter; i++)
        {
            printf("\nPress any key to print next move...");
            readchar();
            clearscr();
            fscanf(playLog, "Player %s ; Play %d ; Move [%d][%c]\n", playerName, &playNumber, &moveX, &moveY);


            board_set_content_row_col(moveX, moveY);
            if (i==lineCounter-1)
            {
                finish_gamePL(get_current_game_ptr()->board);
            }
            board_print_raw();
            printf("\nPlayer Name: %s - Play Number: %d - Move: [%d][%c]\n",playerName, playNumber, moveX, moveY); // was just to test if it's reading right

            cmp.tmp=cmp.current_player_move;                   //swap current player
            cmp.current_player_move=cmp.previous_player_move;  //
            cmp.previous_player_move=cmp.tmp;

        }
        printf("\nWINNER: %s\a\n", playerName);
        printf("\nPress any key to go back to menu...");
        readchar();



    }

    fclose(playLog);

}
Esempio n. 22
0
void    menu_3 (void)
{
    int loop = TRUE;
    int i;
    int c;
    
    clearscr(pm->term_length);
    while (loop) {
        printf (" Changing defaults\n");
        printf (" Options\n");
        printf (" %-40.40s", "(1) Change the ASCII delimiter in output");
        printf ("{%s}\n", 
            (pm->seperator == ' ' ) ? "space" : 
            (pm->seperator == '\t') ? "tab" : 
            (pm->seperator == ',' ) ? "," : 
            "ERROR" );

        printf (" %-40.40s", "(2) Run silently, No Warnings");
        printf ("{%s}\n", (pm->verbose) ? "FALSE" : "TRUE");
        printf (" %-40.40s", "(3) Log warnings/information to a file");
        printf ("{%s}\n", (strlen(pm->curr_logfilename) > 1) ? "TRUE" : 
                "FALSE");
        printf (" %-40.40s", "(4) Number of lines on screen");
        printf ("{%d}\n", pm->term_length);
        printf (" %-40.40s", "(5) Change the genetic code");
        printf ("{%s}\n", cu[pm->code].des);
        printf (" %-40.40s", "(6) Change the Fop/CBI values");
        printf ("{%s}\n", fop[pm->f_type].des);
        printf (" %-40.40s", "(7) Change the CAI values");
        printf ("{%s}\n", cai[pm->c_type].des);
        printf (" %-40.40s", "(8) Output Human or Computer readable");
        printf ("{%s readable}\n", (pm->seq_format == 'M') ? "Computer" : 
                "Human"); 
        printf (" %-40.40s", "(9) Concatenate or individual genes");
        printf ("{%s genes}\n", (pm->totals == TRUE ? "concatenate":
                "individual"));      
        printf (" %s", "(10) Correspondence analysis defaults\n");
    
        printf (" (X) Return to previous menu\n");
        printf ("Choices enclosed with curly brackets are the current "
                "defaults\n");
        printf (" Select a menu choice, (Q)uit or (H)elp -> ");
        gets(pm->junk);
        clearscr(pm->term_length);

        if (isalpha((int) pm->junk[0])|| pm->junk[0]=='\0') {
            switch (c = toupper((int) pm->junk[0])){
              case 'Q': 
                my_exit(2,"menu 3");           /* decided to quit program  */
                break;
              case 'H':
                chelp("menu_3");
                break;
              case 'X':
              case '\0':
                return; /*     way out of loop is X or blank line          */
                break;
              default:
                fprintf(stderr,"The answer %s is not a valid\n", pm->junk);
                pause;
                continue;
                break;
                }
        }

        c=0;
        if (isdigit((int)pm->junk[0]))
            c = atoi(pm->junk);
        if ( c <= 0 && c > 10 ) {
            fprintf( stderr, "The answer %s is not valid\n", pm->junk);
            continue;
        }

        switch ((int) c) {
        case 1:
            clearscr(pm->term_length);
            printf (" The current separator is  \"%s\"\n",  
                (pm->seperator == ' ' ) ? "space" : 
                (pm->seperator == '\t') ? "tab" : 
                (pm->seperator == ',' ) ? "," : 
                "ERROR" );
            printf (" Please select a new separator \t:");
            gets(pm->junk);
            c = pm->junk[0];             /* take first character of string */

            if ( strchr ("\t, ", (int)c) == NULL || c == '\0' ) {
                                     /* remember the \0 is in every string */
                printf( "WARNING: The chosen separator %s is unsuitable\n", 
                        pm->junk);
                printf( "\tSeparator is unchanged try comma,tab "
                        "or space\n\n");
            } else
                pm->seperator = (char) c;  /* specify the column separator */

            break;
        case 2:                            /* warn about overwriting files?*/
            clearscr(pm->term_length);
            pm->verbose = (char) ((pm->verbose) ? FALSE : TRUE);
            pm->warn         = (char) ((pm->warn        ) ? FALSE : TRUE);
            break;
        case 3:                            /* redirect errors to a file    */
            if ( strlen(pm->curr_logfilename) > 1 ) {
                strcpy(pm->curr_logfilename , "" );   /* blank logfilename */
                pm->my_err = stderr;                  /* redirects errors  */
                                                      /* to stderr         */
                fclose(pm->logfile);                  /* close logfile     */ 
            } else {
                                       /* open logfile and redirect stderr */
                if (!(pm->logfile = open_file("log filename        \t",
                    "warning.log", "w", (int) pm->verbose)))
                    my_exit(1," open log file menu 3");
                pm->my_err = pm->logfile;
                strncpy(pm->curr_logfilename, pm->junk, MAX_FILENAME_LEN-1);
            }                                                 /* end of if */
            break;

        case 4:                                       /* No of line on term*/
            printf("Please give the new height of the screen [%i] ", 
                    pm->term_length);
            gets(pm->junk);
            if ( isdigit( (int) pm->junk[0]))
                pm->term_length = atoi(pm->junk) ;
            break;

        case 5:                                      /*Change genetic code */
            clearscr(pm->term_length);
            printf(" Genetic codes currently supported are\n");
           /* NumGeneticCodes is given in codonW.h                         */
           for ( i = 0 ; i < NumGeneticCodes ; i++) {
                (pm->code == i) ? printf ( " (%i) {%-45.45s %-17.17s}", i, 
                    cu[i].des, cu[i].typ) : 
                    printf ( " (%i)  %-45.45s %-17.17s ", i, cu[i].des, 
                        cu[i].typ) ;
                printf("\n");
            }
            printf("Choice enclosed with curly brackets is "
                   "the current code\n");
            printf("Please select a new code [no change]\n");
            gets(pm->junk);
            if ( isdigit( (int) pm->junk[0]) ) {
                c = (char)atoi(pm->junk);
                if ( c > 0 && c < NumGeneticCodes && pm->code!= (char) c ){ 
                    pm->code = (char) c;
                    initilize_point(pm->code,pm->f_type, pm->c_type);  
                    }
            }
            break;

        case 6:                                     /*Change optimal codons*/
            clearscr(pm->term_length);
            printf(" Fop values pre-loaded are\n");
            /* NumFopSpecies  defined with the Fop_struct in codonW.h      */
            for ( i = 0 ; i < NumFopSpecies ; i++) {
                (pm->f_type == i) ? printf (" (%i) {%-25.25s %-40.40s}", 
                    i, fop[i].des, fop[i].ref) : 
                    printf (" (%i)  %-25.25s %-40.40s ", i, fop[i].des, 
                        fop[i].ref) ;
                printf("\n");
            }
            printf ("Choice enclosed with curly brackets is the current "
                "selection\n");
            printf ("Please select a type [no change]\n");
            gets(pm->junk);
            if ( isdigit( (int) pm->junk[0]) ) {
                c = (char)atoi(pm->junk);
                if ( c > 0 && c < NumFopSpecies && pm->f_type!=(char) c) {
                        pm->f_type = (char) c;  
                        initilize_point(pm->code,pm->f_type, pm->c_type);
                }
            }
            break;

        case 7:                                      /*Change CAI w values */
            clearscr(pm->term_length);
            printf(" CAI types currently supported are\n");

            /*  NumCaiSpecies currently defined in codonW.h                */
            for ( i = 0 ; i < NumCaiSpecies ; i++) {
                (pm->c_type == i) ? printf (" (%i) {%-25.25s %-40.40s}", 
                    i, cai[i].des, cai[i].ref) : 
                    printf (" (%i)  %-25.25s %-40.40s ", i, cai[i].des, 
                        cai[i].ref) ;
                printf("\n");
            }
            printf ("Choice enclosed with curly brackets is the current "
                "selection\n");
            printf ("Please chose a new CAI [no change]\n");
            gets(pm->junk);
            if ( isdigit( (int) pm->junk[0]) ) {
                c = (char)atoi( pm->junk);

                /* if valid value and different from the current choice    */
                if (  c > 0 && c < NumCaiSpecies && pm->c_type!=(char) c){
                    pm->c_type = (char) c;
                    initilize_point(pm->code,pm->f_type, pm->c_type);
                    }
            }
            break;
       case 8:                       /* machine or human readable format  */
             clearscr(pm->term_length);
             pm->seq_format = 
                (char) (  pm->seq_format == 'M' ? 'H' : 'M'); /*toggle    */
             break;
      case 9:                        /* concatenate genes?                */
            clearscr(pm->term_length);
            pm->totals    = (char) (pm->totals == TRUE ? FALSE : TRUE); 
            break;
     case 10:                       /* change COA default then go to menu5*/
           clearscr(pm->term_length);
           if( !pm->coa ) 
                menu_5();
           else 
                menu_coa();           
           break;
     default:
            fprintf( stderr, "The answer %s is not a valid\n", pm->junk);
            break;
     }
    }
  return;
}
Esempio n. 23
0
void    menu_4 (void)
{
    char    loop = TRUE;
    char    *choices[] = {
        " ",
        "Codon Adaptation Index       (CAI)",
        "Frequency of OPtimal codons  (Fop)", 
        "Codon bias index             (CBI)",
        "Effective Number of Codons   (ENc)",
        "GC content of gene           (G+C)",
        "GC of silent 3rd codon posit.(GC3s)",
        "Silent base composition",    
        "Number of synonymous codons  (L_sym)",
        "Total number of amino acids  (L_aa )",
        "Hydrophobicity of protein    (Hydro)",
        "Aromaticity of protein       (Aromo)",
        "Select all"
    }; 
    int i,NumChoices;
    int c;
    
    
    NumChoices = (char) 12;                      /* size of choices array */

    clearscr(pm->term_length);
    while (loop) {
        printf (" Codon usage indices\n");
        printf (" Options\n");

        for (i = 1; i <= NumChoices; i++) {
            printf(" (%2i) ", i);
            switch ((int) i) {
            case 1:
                (pm->cai) ? printf ("{%-45.45s}", choices[i]) : 
                printf (" %s ", choices[i]);
                break;
            case 2:
                (pm->fop) ? printf ("{%-45.45s}", choices[i]) : 
                printf (" %s ", choices[i]);
                break;
            case 3:
                (pm->cbi) ? printf ("{%-45.45s}", choices[i]) : 
                printf (" %s ", choices[i]);
                break;         
            case 4:
                (pm->enc) ? printf ("{%-45.45s}", choices[i]) : 
                printf (" %s ", choices[i]);
                break;
            case 5:
                (pm->gc)  ? printf ("{%-45.45s}", choices[i]) : 
                printf (" %s ", choices[i]);
                break;
            case 6:
                (pm->gc3s)? printf ("{%-45.45s}", choices[i]) : 
                printf (" %s ", choices[i]);
                break;
            case 7:
                (pm->sil_base) ?  printf ("{%-45.45s}", choices[i]) : 
                printf (" %s ", choices[i]);
                break;
            case 8:
                (pm->L_sym) ?  printf ("{%-45.45s}", choices[i]) : 
                printf (" %s ", choices[i]);
                break;
            case 9:
                (pm->L_aa)?  printf ("{%-45.45s}", choices[i]) : 
                printf (" %s ", choices[i]);
                break;
            case 10:
                (pm->hyd ) ? printf ("{%-45.45s}", choices[i]) : 
                printf (" %s ", choices[i]);
                break;
            case 11:    
                (pm->aro ) ? printf ("{%-45.45s}", choices[i]): 
                printf (" %s ", choices[i]);
                break;
            case 12:
                printf (" %s ", choices[i]);
                break;                      
            default:
                fprintf(stderr, "programming error \n");
                my_exit(99, "menu 4");
                break;
            }
            printf("\n");
        }
        printf (" (X)  Return to previous menu\n");
        printf ("Choices enclosed with curly brackets are the current"
                " selections\n");
        printf (" Select a menu choice, (Q)uit or (H)elp -> ");


        gets(pm->junk);

        if (isalpha( (int) pm->junk[0]) || pm->junk[0]=='\0') {
            switch (c = toupper( (int) pm->junk[0])){
                case 'Q': 
                 my_exit(2,"menu 4");     /* User decides to quit programme*/
                 break;
                case 'X':
                case '\0':
                    return;               /* <-back to previous menu->     */
                    break;
                case 'H':
                    chelp("menu_4");
                    continue;
                    break;
                default:
                    fprintf( stderr, "The answer %s is not a valid choice\n",
                    pm->junk);
                    continue;
                    break;
                }
        } else if (isdigit ( (int) pm->junk[0] ) ) {
            c =  atoi(pm->junk);
            switch ((int) c) {
            /* User wants to calculate CAI then we explain that it is     */
            /* dependent on the choice of CAI adaptiveness values         */
            case 1: 
                pm->cai = (char) ((pm->cai)   ? FALSE : TRUE);    
                if( pm->cai){
                clearscr(pm->term_length);
                printf("\nTo calculate CAI a reference set of highly ");
                printf("expressed genes \nmust be selected\n\n");
                printf("The reference set currently selected is that of "
                    "%s\n\n",cai[pm->c_type].des);  
                printf("See the menu 'Change defaults' to change this "
                       "selection\n\n");  
                printf("If you wish to use a personal choice of CAI "
                       "vaules\n");
                printf("\tplease continue and you will be prompted for"
                       " input\n\n");  
                pause;
                }
                break ;
            case 2: 
            /* User wants to calculate Fop then we explain that it is     */
            /* dependent on the choice of optimal codons                  */
                pm->fop = (char) ((pm->fop)   ? FALSE : TRUE); 
                if(pm->fop){   
                clearscr(pm->term_length);              
                printf("\n\nYou have chosen to calculate Fop\n\n");
                printf("To calculate Fop a set of optimal "
                       "codons must be selected\n");
                printf("The optimal codons of %s are the current selection"
                       "\n\n",fop[pm->f_type].des);  
                printf("See the menu 'Change defaults' to change Fop "
                       "selection\n\n");
                printf("If you wish to use a personal choice of Fop "
                       "vaules\n");
                printf("\tplease continue and you will be prompted for "
                       "input\n\n");            
                pause;
                }
                break ; 
           case 3: 
            /* User wants to calculate CBI then we remind then that it is */
            /* dependent on the choice of optimal codons                  */
                pm->cbi = (char) ((pm->cbi)   ? FALSE : TRUE); 
                if(pm->cbi){   
                clearscr(pm->term_length);              
                printf("\n\nYou have chosen to calculate CBI\n\n");
                printf("To calculate CBI a set of optimal "
                       "codons must be selected\n");
                printf("The optimal codons of %s are the current selection"
                       "\n\n",fop[pm->f_type].des);  
                printf("See the menu 'Change defaults' to change CBI "
                       "selection\n\n");
                printf("If you wish to use a personal choice of CBI "
                       "vaules\n");
                printf("\tplease continue and you will be prompted for "
                       "input\n\n");               
                pause;
                }
                break ;                
            case 4:                                      /* calc Nc       */
                pm->enc = (char) ( (pm->enc)   ? FALSE : TRUE);    
                break ;
            case 5:                                      /* calc GC       */
                pm->gc =  (char) ((pm->gc )   ? FALSE : TRUE);    
                break ;
            case 6:                                      /* calc GC3s     */   
                pm->gc3s =(char) ( (pm->gc3s) ? FALSE : TRUE);    
                break ;
            case 7:                                      /* calc sil base */   
                pm->sil_base = (char) ((pm->sil_base) ? FALSE : TRUE); 
                break ; 
            case 8:                                      /* No. synonyms  */
                pm->L_sym = (char) ((pm->L_sym) ? FALSE : TRUE); 
                break ; 
            case 9:                                      /* No. AminoAcids*/   
                pm->L_aa  = (char) ((pm->L_aa)  ? FALSE : TRUE); 
                break ; 
            case 10:                                     /* hydropathicity*/
                pm->hyd   =(char) ( (pm->hyd )  ? FALSE : TRUE);
                break;
            case 11:                                     /* aromatic      */
                pm->aro   = (char) ((pm->aro )  ? FALSE : TRUE);                                         
                break;
            case 12:                                     /* all the above */
                pm->cai   = (char)  TRUE;    
                pm->fop   = (char)  TRUE;
                pm->cbi   = (char)  TRUE;    
                pm->enc   = (char)  TRUE;    
                pm->gc    = (char)  TRUE;    
                pm->gc3s  = (char)  TRUE;    
                pm->sil_base 
                          = (char)  TRUE; 
                pm->L_sym = (char)  TRUE; 
                pm->L_aa  = (char)  TRUE;
                pm->hyd   = (char)  TRUE;
                pm->aro   = (char)  TRUE;          
                break ;             
            default:
                fprintf( stderr, "The answer %s is not a valid\n", pm->junk);
                break;
            }
        } else
            fprintf( stderr, "The answer %s is not a valid choice\n", 
            pm->junk);
    }
    return;
}
Esempio n. 24
0
void    menu_8 (void)
{
  struct multi {                    /* struct of menu items                */
    char    *string;                /* description string                  */
    char    prog;                   /* programme name                      */
  };
  char  loop = TRUE;
  int  c;
  int  ans1,NumChoices;

  struct multi aii[] = {
    " ", ' ',              /* Initialise a single value of choices in menu */
    "Fasta format output of DNA sequence", 'T',
    "Reader format output of DNA sequence",'R',
    "Translate input file to AA sequence", 'N',
    "Codon Usage"                        , 'C',
    "Amino acid usage"                   , 'A',
    "RSCU values"                        , 'S',
    "Relative Amino Acid usage"          , 'L',
    "Dinucleotide frequencies"           , 'D',
    "Exhaustive base compostion analysis", 'B',
    "No output written to file"          , 'X' };
  
  NumChoices = 10;                            /* Number of choices in Menu */
  
            /* if there is already an output file available the user may   */
            /* select to change it                                         */

  clearscr(pm->term_length);

  /* because only one type of bulk option is permitted each time 
     codonw runs, it may be necessary to rerun with the same data
     file but changing the blk output options, if so the user
     is prompted with the choice of changing the blk filename             */

  if ( pm->analysis_run  ) {
    printf (" The current bulk output file is %s do you "
            "wish to change this (y/n) [n] ", pm->curr_tidyoutname);
    gets(pm->junk);
   
    if ( toupper( (int) pm->junk[0]) == 'Y') {
      fileclose(&pm->tidyoutfile);
    
      if (!(pm->tidyoutfile = open_file("codon usage output file",
               pm->curr_tidyoutname, "w",(int)pm->verbose)))
               my_exit(1, "menu 8");
      strncpy(pm->curr_tidyoutname, pm->junk, MAX_FILENAME_LEN - 1);
    }        /* matches  if ( !strlen (pm->junk) || toupper= ............. */
  
  } else {   /* matches  if( strlen( pm->curr_cufilename)  )               */    
    printf("Note: No output file has been selected !\n");
  }
  

  while ( loop ) {
    printf (" Menu 8\n");
    printf (" This output will be saved to %s\n\n", pm->curr_tidyoutname);
    
    for ( ans1 = 1; ans1 <= NumChoices; ans1++) {
      if (aii[ans1].prog != (char) pm->bulk)
         printf("\n\t (%2d) %s", ans1, aii[ans1].string);
      else
         printf("\n\t{(%2d) %-45.45s\t\t}", ans1, aii[ans1].string);
    }

    printf ("\n\t ( X) To return to previous menu\n");
    
    printf ("Values enclosed with curly{} brackets are the current "
            "selection\n");
    printf (" Select a menu choice, (Q)uit or (H)elp -> ");
    gets(pm->junk);
    clearscr(pm->term_length);
    
    if (isalpha( (int) pm->junk[0]) || pm->junk[0]=='\0') {
      switch (c =  toupper( (int) pm->junk[0])){
        case 'Q':  
            my_exit(2,"menu 8");         /* User decides to quit          */
            break;
        case 'X':
        case '\0':
            return;                      /* <-back to previous menu->     */      
        case 'H':
            chelp("menu_8_blk");
            continue;
            break;
        default:
          fprintf( stderr, "The answer %s is not a valid\n", pm->junk);
          pause;
          break;
      }
    } else {
      c = atoi(pm->junk);
      if ( c > 0 && c <= NumChoices )
         pm->bulk = aii[c].prog;
      else
         fprintf( stderr, "The answer %s is not a valid\n", pm->junk);
    }
  }                                      /* match while                  */
  return;
}
Esempio n. 25
0
void    menu_5 (void)
{ 
    char    *choices[] = {
        "",
        "COA on codon usage",
        "COA on RSCU",
        "COA on Amino Acid usage",
        "Do not perform a COA"
    };
    int loop = TRUE;
    int i,c,NumChoices;

    NumChoices = 4;

    clearscr(pm->term_length);

    while ( loop ) {
        printf (" Menu 5  Correspondence analysis\n");
        printf ("  Correspondence analysis (COA) \n");

        for (i = 1; i <= NumChoices; i++) {
            printf(" (%i) ", i);
            switch ((int) i) {
            case 1:
                (pm->coa=='c') ? printf ("{%-45.45s}", choices[1]):
                printf (" %s ", choices[1]);
                break;
            case 2:
                (pm->coa=='r') ? printf ("{%-45.45s}", choices[2]):
                printf (" %s ", choices[2]);
                break;
            case 3:
                (pm->coa=='a') ? printf ("{%-45.45s}", choices[3]):

                printf (" %s ", choices[3]);
                break;
            case 4:
                (pm->coa== 0 ) ? printf ("{%-45.45s}", choices[4]):
                printf (" %s ", choices[4]);
                break;                  
            default:
                fprintf(stderr, "programming error \n");
                my_exit(99,"menu 5");
                break;
            }
            printf("\n");
        }
        printf (" (X) Exit this menu\n");
        printf (" Select a menu choice, (Q)uit or (H)elp -> ");
        gets(pm->junk);                                              
        clearscr(pm->term_length);

        if (isalpha( (int) pm->junk[0]) ||   pm->junk[0]=='\0') {
            c =  toupper( (int) pm->junk[0]);
            switch ( c ) {
            case 'Q':
                my_exit(2,"menu 5");
                break;
            case 'X':
            case '\0':
                return;
                break;
            case 'H':
                chelp("menu_5_coa");
                continue;
                break;
            default:
                fprintf( stderr, "The answer %s is not a valid\n", pm->junk);
                break;
            }
        } else {
            c =  atoi(pm->junk);
            if ( c > 0 && c <= 4 ) {
            switch ((int) c){
            case 1: 
                pm->coa = 'c';                              /* COA of CU  */
                break ;
            case 2: 
                pm->coa = 'r';                              /* COA of RSCU*/
                break ;
            case 3: 
                pm->coa = 'a';                              /* COA of AA  */
                break ;
            case 4: 
                pm->coa = FALSE;        
                break;
#ifdef DEBUG
            default:
                fprintf(pm->my_err,"Error in switch in coa_raw_out\n");
#endif          
              }
            } else {
                fprintf(stderr,"The answer %s is not a valid\n", pm->junk);
                break;
            }
        }
 
     if ( pm->coa ) {  
         printf( " Do you wish to see the advanced COA menu (Y/N) [N] ");
         gets( pm->junk );

        /* Select the default codon/AAs to analyse, based on genetic code */
         initilize_coa  (pm->code);
         
         if ( (char) toupper( (int) pm->junk[0]) == 'Y' ) menu_coa(); 
         }
        
    } /* while loop */ 
    return;
}
Esempio n. 26
0
void menu_initial (void)
{
    int loop = TRUE;
    int c;
    
    while (loop) {                                             /* loop    */
        printf (" Initial Menu \n");
        printf (" Option\n\t (1) Load sequence file\n"); 
        
/*      printf ("\t (2) Check sequence file for redundancy\n");           */
        printf ("\t ( )\n");
        printf ("\t (3) Change defaults\n");
        printf ("\t (4) Codon usage indices\n");
        printf ("\t (5) Correspondence analysis\n");

/*      printf ("\t (6) Basic statistics\n");                             */
        printf ("\t ( ) \n");

        printf ("\t (7) Teach yourself codon usage\n");
        printf ("\t (8) Change the output written to file\n");
        printf ("\t (9) About C-codons\n");
        printf ("\t (R) Run C-codons \n");
        printf ("\t (Q) Quit \n");
        printf (" Select a menu choice, (Q)uit or (H)elp -> ");

        gets(pm->junk);
        
        if (isalpha((int)pm->junk[0])) {
            c = toupper( (int) pm->junk[0]);

            switch  (c) {
            case 'Q':       
                my_exit(2,"main menu");
                break;                
            case 'R':    
                /* test that all the required files are opened             */
                if ( pm->inputfile && pm->outputfile && pm->tidyoutfile)
                    loop = FALSE;
                else {                  
                    printf("Not all required files are open\n");
		            printf("About to open input and output files\n");
		            pause;
		            main_menu(1);   
		            loop = FALSE;
                 } 
		    break;
            case 'H':                                              /* help */     
                 chelp ( "main_menu" );       
                 break;   
            default:
                fprintf( stderr, "The answer %s is not valid\n", pm->junk);
                pause;
                break;
           }                                            /* end of switch c */     
        } else if (isdigit((int) pm->junk[0])) {
            c =    atoi( pm->junk);
            if (c > 0 && c <= 9 )  
                main_menu( (int) c );
            else 
                fprintf( stderr, "The answer %s is not valid\n", pm->junk);
        }
        clearscr(pm->term_length);
    }
    return;
}
void main()
{
	int i=10,j,k,N=24;
	tInt bias,scale;
	tLong frequency;
	tChar temp;
//	__bit test_resultA;

	FLG_CPL=0;
	lcd_init();
	display("Initializing...");
	enable_spi(0);
	dac_set(0);
	chip_init_CCFFE();
	pll_init();
	clearscr();
	enable_serial();
	display("Set Jumpers and ping");
	temp = receive_serial();
	clearscr();
	display("     CCFFE");
	line2();
	display("Throughput test");
	
	msDelay(1000);
	enable_serial();
	load_test_data();
	clearscr();
	display("Setting up test");
	line2();
	display("With 7 bit PRBS");
	scale = 2650/N;
	
	for(i=N;i>0;i--)
	{
		for(j=0;j<20;j++)
		{
			chip_init_CCFFE();
			sel_source(RING);
			bias=scale*i;
			dac_set(bias);
			msDelay(1000);			
			for(k=j;k>=0;k--)
			{
				tick_RX_RC_CKIN();
				msDelay(1);
			}
        	frequency = fmeasure();
        	clearscr();
        	display("f(");
			display_int(i);
			display(",");
        	display_int(j);
        	display(")=");
        	display_freq(frequency);
			write_test_data_CCFFE();
			LF_SELECT = 0;
			msDelay(1);
			LF_SELECT = 1;
			read_results_CCFFE();
			test_result = cross_correlation();//source_data);
			if(test_result)
			{
				FLG_CPL=1;
                send_byte(fm_byte[0]);
                send_byte(fm_byte[1]);
                send_byte(fm_byte[2]);
                send_int(i);
                send_byte(',');
                send_int(j);
			}
		}
	}
	

	
	clearscr();
	display("Throughput test");
	line2();
	if(FLG_CPL)
	display("SUCCESS");
	else
	display("Failed");
	while(1);
}
Esempio n. 28
0
void SWSerLCDpa::clearscr(int n)
{
    clearscr();
    print(n);
}
Esempio n. 29
0
void handle_key(void){
	if (NeedsPoll) poll_keyboard();


	if (key[syskeys[0]] || key[KEY_ESC]) {
		do {
			rest(5);
			if (NeedsPoll) poll_keyboard();
		} while (key[syskeys[0]] || key[KEY_ESC]);
		key_done=1;
	}

if (key[syskeys[1]]) {
		do {
			rest(5);
			if (NeedsPoll) poll_keyboard();
		} while (key[syskeys[1]]);

		mute_audio();
		mute_voice();
		abaut();

		do {
			rest(5);
			if (NeedsPoll) poll_keyboard();

			if (key[KEY_ALT] && key[KEY_ENTER]) {
				app_data.fullscreen = app_data.fullscreen ? 0 : 1;
				grmode();
				abaut();
				do {
					rest(5);
					if (NeedsPoll) poll_keyboard();
				} while (key[KEY_ENTER]);
			}		

		} while ((!key[syskeys[1]]) && (!key[KEY_ESC]) && (!key[syskeys[0]]));
		do {
			rest(5);
			if (NeedsPoll) poll_keyboard();
		} while (key[syskeys[1]]);
		
		init_sound_stream();
	}		

if (key[syskeys[5]])
	{
		if (savestate(app_data.statefile)==0)
		{
			display_msg("Savefile saved.",5);
		}
		do {
			rest(5);
			if (NeedsPoll) poll_keyboard();
		} while (key[syskeys[5]]);

	}

	/* LOAD STATE */
	if (key[syskeys[6]])
	{
		int stateError;
		if ((stateError=loadstate(app_data.statefile))==0)
		{
			display_msg("Savefile loaded.",5);
		}
		else if (stateError>=199)
		{
			if (stateError==199) display_msg("Wrong ROM-File for Savefile.",5);
			else if (stateError==200+ROM_O2) display_msg("Wrong BIOS for Savefile: O2ROM needed.",5);
			else if (stateError==200+ROM_G7400) display_msg("Wrong BIOS for Savefile: G7400 ROM needed.",5);
			else if (stateError==200+ROM_C52) display_msg("Wrong BIOS for Savefile: C52 ROM needed.",5);
			else if (stateError==200+ROM_JOPAC) display_msg("Wrong BIOS for Savefile: JOPAC ROM needed.",5);
			else display_msg("Wrong BIOS for Savefile: UNKNOWN ROM needed.",5);
		}
		do {
			rest(5);
			if (NeedsPoll) poll_keyboard();
		} while (key[syskeys[6]]);
	}

	if (key[syskeys[2]]) key_debug=1;

	if (key[syskeys[3]]) {
		init_cpu();
		init_roms();
		init_vpp();
		clearscr();
		do {
			rest(5);
			if (NeedsPoll) poll_keyboard();
		} while (key[syskeys[3]]);
	}

    /* SET HIGHSCORE */
	if (key[syskeys[7]])
	{
		set_score(app_data.scoretype, app_data.scoreaddress, app_data.default_highscore);
	}


	if (key[syskeys[4]]) {
		BITMAP *bmp;
		PALETTE pal;
		char *p;
		static char name[1024];
		static int scshot_counter = 0;

		if (strlen(app_data.scshot)>0){
			if ((p=strchr(app_data.scshot,'@'))) {
				*p = 0;
				sprintf(name, "%s%02d%s", app_data.scshot, scshot_counter++, p+1);
				*p = '@';
			} else {
				strcpy(name, app_data.scshot);
			}
			get_palette(pal);
			bmp = create_sub_bitmap(screen, 0, 0, SCREEN_W, SCREEN_H);
			save_bitmap(name, bmp, pal);
			destroy_bitmap(bmp);
			do {
				rest(5);
				if (NeedsPoll) poll_keyboard();
			} while (key[syskeys[4]]);
		}
	}

	// switch joystick
	if (key[syskeys[8]]) {
		joyswitch = joyswitch ? 0 : 1;

		set_defjoykeys(0,joyswitch);
		set_defjoykeys(1,joyswitch ? 0 : 1);
		int tmp = app_data.stick[0];
		app_data.stick[0] = app_data.stick[1];
		app_data.stick[1] = tmp;

		do {
			rest(5);
			if (NeedsPoll) poll_keyboard();
		} while (key[syskeys[8]]);

	}

	if (key[KEY_ALT] && key[KEY_ENTER]) {
		app_data.fullscreen = app_data.fullscreen ? 0 : 1;
		grmode();
		do {
			rest(5);
			if (NeedsPoll) poll_keyboard();
		} while (key[KEY_ENTER]);
	}		

}
Esempio n. 30
0
void SWSerLCDpa::clearscr(long n, int base)
{
    clearscr();
    print(n, base);
}