From 5dd491ed529433b9b12fb6319442a889317e8d0d Mon Sep 17 00:00:00 2001 From: Manzovince Date: Tue, 30 Apr 2019 15:32:47 +0200 Subject: [PATCH] few little edits + show wrong tetri feature --- fillit.h | 6 +++--- parse_input.c | 30 ++++++++++++++++++++---------- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/fillit.h b/fillit.h index 5f65c3f..b43a3ee 100644 --- a/fillit.h +++ b/fillit.h @@ -6,7 +6,7 @@ /* By: vmanzoni +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/03/01 13:34:46 by vmanzoni #+# #+# */ -/* Updated: 2019/04/30 14:19:39 by hulamy ### ########.fr */ +/* Updated: 2019/04/30 14:43:42 by vmanzoni ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,8 +18,8 @@ #include // for system call open #include // for printf (DELETE BEFORE EVAL) -#include "../42-libft/includes/libft.h" -//# define BUFF_SIZE 1024 +#include "libft/includes/libft.h" +# define BUFF_SIZE 1024 /* ** STRUCTURE diff --git a/parse_input.c b/parse_input.c index 7a0c77c..5b3f33d 100644 --- a/parse_input.c +++ b/parse_input.c @@ -6,7 +6,7 @@ /* By: vmanzoni +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/04/15 14:48:14 by vmanzoni #+# #+# */ -/* Updated: 2019/04/30 14:19:32 by hulamy ### ########.fr */ +/* Updated: 2019/04/30 15:30:53 by vmanzoni ### ########.fr */ /* */ /* ************************************************************************** */ @@ -62,13 +62,15 @@ unsigned short reduce_tetri(unsigned short tetri, int width) void fill_list(char line[], t_fillist *list) { -// unsigned int tmp; + unsigned int tmp; unsigned int mask; int i; // transforme la ligne de . et # en un short de 0 et 1 list->tetribit = tab_to_bin(line); - // cree un mask avec des 1 sur la colonne de droite + ft_putstr("BEFORE: "); + print_bits(list->tetribit, 16); + // cree un mask avec des 1 sur la colonne de droite (#...#...#...#...) mask = (1 << 15) | (1 << 11) | (1 << 7) | (1 << 3); // utilise le mask pour trouver la largeur que prend le tetriminos i = 0; @@ -78,7 +80,8 @@ void fill_list(char line[], t_fillist *list) while (mask & list->tetribit && ++i < 4) mask >>= 1; list->width = i - list->width; - // deplace le tetriminos tout en haut a gauche (i - list->width = le nombre de colonne vide a gauche) + // deplace le tetriminos tout en haut a gauche + //(i - list->width = le nombre de colonne vide a gauche) list->tetribit <<= (i - list->width); while (!(list->tetribit & (~0u << 12))) list->tetribit <<= 4; @@ -91,11 +94,15 @@ void fill_list(char line[], t_fillist *list) list->tetribit = reduce_tetri(list->tetribit, list->width); // imression pour tests -// ft_putchar('\n'); -// tmp = list->tetribit; -// tmp <<= 16; -// print_map(&tmp, list->width, list->height); -// tmp >>= 16; + ft_putchar('\n'); + ft_putstr("AFTER: "); + print_bits(list->tetribit, 16); + ft_putstr("\n"); + tmp = list->tetribit; + tmp <<= 16; + ft_putstr("\n"); + print_map(&tmp, list->width, list->height); + tmp >>= 16; } /* @@ -143,7 +150,10 @@ void parse_input(char *input) tetri[j++] = input[i++]; tetri[19] = '\0'; if (check_tetri_errors(tetri)) - print_error("Error: Tetrimino not valid."); + { + ft_putstr(tetri); + print_error("\n\nerror: This tetrimino is not valid.\n"); + } add_to_list(tetri, &list); while (input[i] && input[i] != '.' && input[i] != '#') i++;