Example #1
0
void debug( int level, const wchar_t *msg, ... )
{
	va_list va;

	string_buffer_t sb;
	string_buffer_t sb2;

	int errno_old = errno;

	if( level > debug_level )
		return;

	CHECK( msg, );

	sb_init( &sb );
	sb_init( &sb2 );

	sb_printf( &sb, L"%ls: ", program_name );

	va_start( va, msg );
	sb_vprintf( &sb, msg, va );
	va_end( va );

	write_screen( (wchar_t *)sb.buff, &sb2 );
	fwprintf( stderr, L"%ls", sb2.buff );

	sb_destroy( &sb );
	sb_destroy( &sb2 );

	errno = errno_old;
}
Example #2
0
int player_turn( int player )
{

  unsigned int x,
               y;
  
  if(player == 0)
  {
    write_screen("Computer will start playing");
    AI();
    moves++;
    player = 1;
  }
  
  if(player == 1)
  {
    write_screen("You will start to play");
    
    puts("Insert the cordinates like this: x y");
    scanf("%d %d", &x, &y);
    
    if(table[y][x] == 'O' || table[y][x] == 'X') 
    {
      
      do {
        
        write_screen("*This position is already checked, please choose another.");
        scanf("%d %d", &x, &y);
        
        if(table[y][x] != 'O' && table[y][x] != 'X')
        {
          table[y][x] = 'O';
          return false;
        }
        
      } while(true);
      
    } else { table[y][x] = 'O'; }
    
    moves++;
    
    player = 0;
  }
  
  return player;
  
}
Example #3
0
void timer_isr(void)
{

	/* 
	 * Timer hardware configuration must be added here 
	 */

	timer_count++;

	timer_msg[11] = flow[timer_count%4];

	write_screen(timer_msg, 22, 12);

}
Example #4
0
File: csnow.c Project: Saruta/ToyOS
int main(int argc, char * argv) {

	screen_t * main_screen = init_screen();
	flake_t *  flakes      = make_some_flakes(main_screen, INITIAL_SNOW);

	for (;;) {
		write_screen(main_screen, flakes);
		flip_screen(main_screen);
		update_flakes(main_screen, flakes);
		flakes = add_flakes(main_screen, flakes, INCREMENTAL_SNOW);
		usleep(90000);
	}


	return 0;
}
Example #5
0
int demo0(DPFHANDLE h)
{
	static unsigned char image[2 * 128 * 128];
	int x, y;
	int i;
	for (i = 0; i < 127; i++) {
		unsigned char *b = image;
		for (y = 0; y < 128; y++) {
			for (x = 0; x < 128; x++) {
				*b++ = RGB565_0(x * 2 + i, y * 2 + i, i);
				*b++ = RGB565_1(x * 2 + i, y * 2 + i, i);
			}
		}
		write_screen(h, image, sizeof(image));
	}
	return 0;
}
Example #6
0
File: vesa.c Project: Haifisch/axle
void vesa_screen_refresh(Screen* screen) {
	//check if there are any keys pending
	while (haskey()) {
		char ch = getchar();
		if (ch == 'q') {
			//quit xserv
			gfx_teardown(screen);
			switch_to_text();
			return;
		}
	}

	if (!screen->finished_drawing) return;

	//if no changes occured this refresh, don't bother writing the screen
	if (xserv_draw(screen)) {
		write_screen(screen);
	}
}
Example #7
0
void game_init(char **tela) { //Função para iniciar o jogo.
    int i;
    int game_over;
    int score_global;

    score_global = 0;
    game_over = 0;
    create_per(tela);             //Inicialização de variaveis.

    while(!game_over) {
        write_col(tela);
        for(i = 0; i < SPACE_COL; i++) {
            move_col(tela);
            score_global = score_check(tela);
            controls(tela, score_global);       //Loop principal do jogo.
            gravity(tela, score_global);
            move_col(tela);
            write_screen(tela, score_global);
            collision(tela, score_global);
        }
    }
}
Example #8
0
void gameover(char **tela, int score_global) {        ///Finaliza o jogo mostrando o score.
    int op, i, count;
    FILE *score_file;
    char line[30];
    score_t score;

    write_screen(tela, score_global);
    clear();
    show_score(score_global);
    count = 0;
    init_pair(1, COLOR_RED, COLOR_YELLOW);
    bkgd(COLOR_PAIR(1));
    score_file = fopen("score.sprite", "r");
    while(!feof(score_file)) {
		fgets(line, COLUNAS, score_file);
		mvprintw(count, 0, "%s", line);
		count++;
	}
	fclose(score_file);
    score_file = fopen("score.txt", "r");

  for(i = 0; i < 5; i++)
  {
		fgets(line, 30, score_file);
    sscanf(line, "%s %d %d %d %d", score.nome, &score.dia, &score.mes, &score.ano, &score.score);
		mvprintw(i + (count + 2), 0, "%d. %s        %d/%d/%d     %d ", (i + 1), score.nome, score.dia, score.mes, score.ano, score.score);
	}
	fclose(score_file);
	refresh();

    while (1) {
        op = getch();
        if(op == KEY_UP) {
            score_global = 0;
            tela = init_screen(COLUNAS, LINHAS);
            game_init(tela);
        }
    }
}
Example #9
0
void debug( int level, const wchar_t *msg, ... )
{
	va_list va;

	wcstring sb;

	int errno_old = errno;
	
	if( level > debug_level )
		return;

	CHECK( msg, );
		
	sb = format_string(L"%ls: ", program_name);
	va_start(va, msg);
	sb.append(vformat_string(msg, va));
	va_end(va);

	wcstring sb2;
	write_screen( sb, sb2 );
	fwprintf( stderr, L"%ls", sb2.c_str() );	

	errno = errno_old;
}
Example #10
0
File: vga.c Project: Haifisch/axle
void vga_screen_refresh(Screen* screen) {
	write_screen(screen);
}
Example #11
0
void dpf_update (void) {
	write_screen(h, image, sizeof(image));
}