Пример #1
0
/*
** affiche des informations complémentaires.
** pour activer cette option = -v
*/
void	debug(t_vm *vm, t_proc **lproc, int address)
{
  if (vm->option[0].debug != 1)
    return ;
  my_putstr(INTENSITE);
  my_putstr("[wait : ");
  my_put_nbr(vm->cycle_champion[(*lproc)->nb_proc % 4]);
  my_putstr("] ");
  my_putstr("[cycle : ");
  my_put_nbr(vm->cycle);
  my_putstr("] ");
  my_putstr(BLEU);
  my_putstr("[N°proc : ");
  my_put_nbr((*lproc)->num_proc + 1);
  my_putstr("] ");
  my_putstr(CYAN);
  my_putstr("[Champion ");
  my_put_nbr((*lproc)->nb_proc + 1);
  my_putstr("] ");
  my_putstr(REZ);
  my_putstr(op_tab[((*lproc)->code - 1) % REG_NUMBER].mnemonique);
  actualize_memory(vm, lproc, address);
  actualize_data(vm, lproc);
  if (SDL_Flip(vm->sdl->screen) == -1)
    return ;
}
Пример #2
0
void		display_tab(t_all *st)
{
  st->y = -1;
  while (++st->y < st->size_allum * 2 + 1)
    printstr(1, "*", BLUEST);
  write(1, "\n", 1);
  st->y = -1;
  while (++st->y < st->size_allum)
    {
      printstr(1, "*", BLUEST);
      display_space(st->size_allum - st->y - 1);
      display_allum(st->tab[st->y]);
      display_space((st->size_allum * 2) -
		    st->tab[st->y] - (st->size_allum - st->y));
      printstr(1, "* (", BLUEST);
      my_put_nbr(st->y + 1);
      printstr(1, ")", BLUEST);
      printstr(1, " (", REDST);
      my_put_nbr(st->tab[st->y]);
      printstr(1, ")\n", REDST);
    }
  st->y = -1;
  while (++st->y < st->size_allum * 2 + 1)
    printstr(1, "*", BLUEST);
  write(1, "\n", 1);
  if (st->finish == 0)
    write(1, "\n", 1);
}
Пример #3
0
void	print_keys(t_config *config)
{
  my_putstr("*** DEBUG MODE ***\nKey Left : ");
  my_debugstr(config->left);
  my_putstr("Key Right : ");
  my_debugstr(config->right);
  my_putstr("Key Turn : ");
  my_debugstr(config->turn);
  my_putstr("Key Drop : ");
  my_debugstr(config->drop);
  my_putstr("Key Quit : ");
  my_debugstr(config->quit);
  my_putstr("Key Pause : ");
  my_debugstr(config->pause);
  my_putstr("Next : ");
  if (config->hide)
    my_putstr("No\n");
  else
    my_putstr("Yes\n");
  my_putstr("Level : ");
  my_put_nbr(config->level);
  my_putstr("\nSize : ");
  my_put_nbr(config->height);
  my_putchar('*');
  my_put_nbr(config->width);
  my_putchar('\n');
}
Пример #4
0
static int	remind_options_to_user(t_rtc *rtc)
{
  if (rtc->height == 1080)
    my_putstr("Default height selected : 1080\n");
  else
    {
      my_putstr("Your selected height : ");
      my_put_nbr(rtc->height);
      my_putstr("\n");
    }
  if (rtc->width == 1920)
    my_putstr("Default width selected : 1920\n");
  else
    {
      my_putstr("Your selected width : ");
      my_put_nbr(rtc->width);
      my_putstr("\n");
    }
  (rtc->fullscreen == 1) ? (my_putstr("Fullscreen : YES\n")) :
    (my_putstr("Fullscreen : NO\n"));
  if (rtc->scene_file == NULL)
    return (my_puterr("Error : No scene file given. Aborting.\n"));
  else
    return (parse_obj_file(rtc));
}
Пример #5
0
void		tcheck_getnbr(t_all *all, int j, int i, int errare)
{
  while (i < j)
    {
      if (all->simple_buff[i] < 48 || all->simple_buff[i] > 57)
	{
	  my_puterr("at the case ");
	  my_put_nbr(i);
	  my_puterr(" there is a wrong char (");
	  my_putchar_err(all->simple_buff[i]);
	  my_puterr("), please remove-it\n");
	  errare += 1;
	}
      i += 1;
    }
  if (errare > 0)
    {
      my_puterr("Total of ");
      my_put_nbr(errare);
      my_puterr(" error(s) on the first line\n");
      free(all->simple_buff);
      free(all);
      exit(EXIT_FAILURE);
    }
}
Пример #6
0
int   main(int ac, char **av)
{
  int nb;
  int n;

  if (ac == 2)
  {
    nb = atoi(av[1]);
    if (nb == 1)
      my_put_nbr(1);
    while (42)
    {
      n = 1;
      while (++n <= nb)
      {
        if (nb % n == 0)
        {
          my_put_nbr(n);
          nb = nb / n;
          break;
        }
      }
      if (nb == 1)
        break;
      else
        my_putchar('*');
    }
  }
  my_putchar('\n');
  return (0);
}
Пример #7
0
int	stat(s_hero hero)
{
	my_putstr("Hero : ");
	my_putstr(hero.name);
	my_putchar('\n');

	my_putstr("\033[32;40m|--PV : ");
	my_put_nbr(hero.pv);

	my_putchar('\n');

	my_putstr("\033[34;40m|--PM : ");
	my_put_nbr(hero.pm);
	my_putchar('\n');

	my_putstr("\033[36;40m|--Ether : ");
	my_put_nbr(hero.ether);
	my_putchar('\n');
	my_putstr("\033[31;40m|--Potion : ");
	my_put_nbr(hero.potion);
	my_putchar('\n');
	my_putchar('\n');
	my_putstr("\033[0m");
	return (1);
}
Пример #8
0
void	ia_say(int l, int n)
{
  my_putstr("AI removed ");
  my_put_nbr(n);
  my_putstr(" match(es) from line ");
  my_put_nbr(l);
  my_putstr("\n");
}
Пример #9
0
void	player_say(int l, int n)
{
  my_putstr("Player removed ");
  my_put_nbr(n);
  my_putstr(" match(es) from line ");
  my_put_nbr(l);
  my_putstr("\n");
}
Пример #10
0
void	aff_ia(int num_lines_ia, int num_matches_ia)
{
  my_putstr("AI removed ");
  my_put_nbr(num_matches_ia);
  my_putstr(" match(es) from line ");
  my_put_nbr(num_lines_ia);
  my_putchar('\n');
}
Пример #11
0
void	display_colle(char nb, t_lines *lines, char separator)
{
  my_putstr("[colle1-");
  my_putchar('0' + nb);
  my_putstr("] ");
  my_put_nbr(my_strlen(get_line(0, lines)->buffer));
  my_putchar(' ');
  my_put_nbr(count_lines(lines));
}
Пример #12
0
int		main(void)
{
  int	color;
  color = get_color(10, 10, 10);
  my_put_nbr(color);
  color = swap_endian_color(color);
  my_putchar('\n');
  my_put_nbr(color);
}
Пример #13
0
void		display_next_IA(t_all *st)
{
  write(1, "AI's turn...", 12);
  write(1, "\nAI removed ", 12);
  my_put_nbr(st->allum);
  write(1, " match(es) from line ", 21);
  my_put_nbr(st->line);
  write(1, "\n", 1);
}
Пример #14
0
void	libra(t_hero *hero, t_monster *monster)
{
  hero->pm--;
  my_putstr(monster->name);
  my_putstr("\n|--PV : ");
  my_put_nbr(monster->pv);
  my_putstr("\n|--PM : ");
  my_put_nbr(monster->pm);
  my_putstr("\n\n");
}
Пример #15
0
void  my_put_nbr(int nb)
{
  if (nb <= 9)
    my_putchar(nb + 48);
  else
  {
    my_put_nbr(nb / 10);
    my_put_nbr(nb % 10);
  }
}
Пример #16
0
int	colle1_2(int x, int y)
{
  my_putchar('[');
  my_putstr("colle1-2");
  my_putchar(' ');
  my_put_nbr(x);
  my_putchar(' ');
  my_put_nbr(y);
  my_putchar(']');
  my_putchar('\n');
}
Пример #17
0
RETSIGTYPE      sigwinch()
{
  struct winsize        w;

  if (ioctl(0, TIOCGWINSZ, &w) < 0)
    my_putstr("ioctl");
  my_putstr("ws_row=");
  my_put_nbr(w.ws_row);
  my_putstr("ws_col=");
  my_put_nbr(w.ws_col);
  my_putstr("\n");
}
Пример #18
0
void	my_aff_struct_info(t_struct *objs)
{
  my_putstr("operateur: ");
  my_put_nbr(objs->operateur);
  my_putchar('\n');
  my_putstr("instruction: ");
  my_putstr(objs->instruction);
  my_putchar('\n');
  my_putstr("background: ");
  my_put_nbr(objs->background);
  my_putchar('\n');
  my_putchar('\n');
}
Пример #19
0
int	manage_os3(struct stat *statut, struct group *getgr,
		   struct passwd *user)
{
  my_put_nbr(statut->st_nlink);
  my_putchar('\t');
  my_put_nbr(statut->st_uid);
  my_putchar('\t');
  my_put_nbr(statut->st_gid);
  my_putchar('\t');
  my_put_nbr(statut->st_size);
  my_putchar('\t');
  return (1);
}
Пример #20
0
int	check_tetrimino(t_cdlist *list)
{
  my_putstr("Tetriminos : Name ");
  my_putstr(list->data->name);
  my_putstr(" : Size ");
  my_put_nbr(list->data->width);
  write(1, "*", 1);
  my_put_nbr(list->data->height);
  my_putstr(" : Color ");
  my_put_nbr(list->data->color);
  write(1, " :\n", 3);
  return (0);
}
Пример #21
0
void	do_lab(t_option *opt)
{
  char	**map;

  map = map_alloc(opt);
  map_ext(opt, map);
  way_ext(opt, map);
  my_putstr("AUTEUR : folie_a\n");
  my_put_nbr(opt->w);
  my_putchar(opt->dd);
  my_put_nbr(opt->h);
  my_putchar('\n');
  my_showtab(map);
}
Пример #22
0
void		display_next(t_all *st)
{
  write(1, "Player ", 7);
  if (st->player != 0)
    {
      my_put_nbr(st->player);
      write(1, " removed ", 9);
    }
  else
    write(1, "removed ", 8);
  my_put_nbr(st->allum);
  write(1, " match(es) from line ", 21);
  my_put_nbr(st->line);
  write(1, "\n", 1);
}
Пример #23
0
void	my_put_nbr(int n)
{
    if (n < 0)
    {
        n = -n;
        my_putchar('-');
    }
    if (n >= 10)
    {
        my_put_nbr(n / 10);
        my_put_nbr(n % 10);
    }
    else
        my_putchar(n + 48);
}
Пример #24
0
void    my_put_nbr(int nb)
{
  int   neg;

  neg = 0;
  if (nb < 0)
    {
      my_putchar('-');
      if (nb == -2147483648)
        {
          neg = 1;
          nb++;
        }
      nb = nb * -1;
    }
  if (nb >= 10)
    my_put_nbr(nb / 10);
  if (neg == 1)
    {
      neg = 0;
      my_putchar(nb % 10 + '1');
    }
  else
    my_putchar(nb % 10 + '0');
}
Пример #25
0
void		show_tab(int *tab, int tab_size)
{
  t_vars	v;
  int		nline;

  nline = 1;
  v.space = tab_size + 2;
  init_vars(&v);
  while (v.i < tab_size)
    {
      v.j = 0;
      my_put_nbr(nline++);
      my_putchar('.');
      v.k = (nline > 10) ? 1 : 0;
      while (v.k++ < v.space)
	my_putchar(' ');
      while (v.j < tab[v.i])
	{
	  my_putchar('|');
	  v.j++;
	}
      my_putchar('\n');
      v.i++;
      v.space--;
    }
}
Пример #26
0
int	server(int args)
{
  if (args < 0)
    return (0);
  my_put_nbr((int)getpid());
  if (write(1, "\n", 1) < 0)
    return (1);
  set_infos();
  while (1)
    {
      if (g_infos.id == 0)
	{
	  if (get_c_pid())
	    return (1);
	  if (g_infos.pid != 0)
	    {
	      if (signal(SIGUSR1, &sig_1) == SIG_ERR ||
		  signal(SIGUSR2, &sig_2) == SIG_ERR)
		return (1);
	    }
	}
      if (usleep(100000) == 0)
	set_infos();
    }
  return (0);
}
Пример #27
0
int		my_put_nbr(int nb)
{
  int   min;

  min = 0;
  if (nb < 0)
    {
      my_putchar('-');
      if (nb == -2147483648)
        {
          min = 1;
          nb = nb + 1;
        }
      nb = nb * -1;
    }
  if (nb >= 10)
    my_put_nbr(nb / 10);
  if (min == 1)
    {
      min = 0;
      my_putchar(nb % 10 + '1');
    }
  else
    my_putchar(nb % 10 + '0');
  return (0);
}
Пример #28
0
int		my_put_nbr(int nb)
{
  int		check_neg;

  check_neg = 0;
  if (nb < 0)
    {
      if (nb == -2147483648)
	{
	  my_putchar_overflow();
	  return (0);
	}
      my_putchar('-');
      check_neg = check_neg + 1;
      nb = nb * -1;
    }
  if (nb >= 10)
    my_put_nbr(nb / 10);
  if (check_neg == 1)
    {
      check_neg = 0;
      my_putchar(nb % 10 + '0');
    }
  else
    my_putchar(nb % 10 + '0');
  return (0);
}
Пример #29
0
int	main(int argc, char **argv)
{
  int	(*(*tab))(int, int);

  if (argc > 4 || (my_getnbr(argv[3]) == 0 && (argv[2][0] == '/' || argv[2][0] == '%')))
    {
      if (argv[2][0] == '/')
	my_putstr("Stop : division by Zero");
      if (argv[2][0] == '%')
	my_putstr("Stop : modulo by Zero");
      my_putstr("\n");
      return(0);
    }
  if (argv[2][0] != '*' && argv[2][0] != '/' && argv[2][0] != '+')
    if (argv[2][0] != '%' && argv[2][0] != '-')
    {
      my_putstr("0\n");
      return (0);
    }
  tab = malloc(6 * sizeof(tab));
  tab[0] = &mul;
  tab[1] = &add;
  tab[2] = &mod;
  tab[3] = &sub;
  tab[5] = &divis;
  my_put_nbr(tab[(argv[2][0] % 7)](my_getnbr(argv[1]), my_getnbr(argv[3])));
  my_putstr("\n");
}
Пример #30
0
int	init_listen(int s_fd, char **argv, int ac)
{
  int	maxclient;
  int	flag;
  int	option;

  if (ac < 3 || (option = verify_int_option("-maxclient", argv)) == -1)
    maxclient = 16;
  else
    {
      maxclient = my_getnbr(argv[option], &flag);
      if (maxclient < 0 || maxclient > 128 || flag == 1)
	{
	  xclose(s_fd);
	  write_usage();
	}
    }
  my_putstr("- Maximum connection limitation set at \033[31m");
  my_put_nbr(maxclient);
  my_putstr("\033[36m client\033[00m\n");
  if (maxclient == 0)
    {
      my_putstr("# Warning : maxclient set to 0. ");
      my_putstr("No user will be able to connect !\n");
    }
  set_listen(s_fd, maxclient);
  return (maxclient);
}