merge avec nouveau file search_map qui est la recursive et reorganisation du makefile

This commit is contained in:
Hugo LAMY
2019-04-30 14:21:41 +02:00
7 changed files with 311 additions and 114 deletions

View File

@@ -6,59 +6,14 @@
/* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/04/15 14:48:14 by vmanzoni #+# #+# */
/* Updated: 2019/04/27 15:15:53 by vmanzoni ### ########.fr */
/* Updated: 2019/04/30 14:19:32 by hulamy ### ########.fr */
/* */
/* ************************************************************************** */
#include "fillit.h"
/*
** DELETE BEFORE EVAL - TEST FUNCTION
** Prints a ligne of size bits
*/
void print_bits(unsigned int bits, int size)
{
unsigned int mask;
mask = 1 << (size - 1);
while (mask)
{
(bits & mask) ? write(1, "#", 1) : write(1, ".", 1);
write(1, " ", 1);
mask >>= 1;
}
write(1, "\n", 1);
}
/*
** DELETE BEFORE EVAL - TEST FUNCTION
** Print a map of height and width
*/
void print_map(unsigned int *tab, int width, int height)
{
int i;
unsigned int mask;
i = 0;
mask = 0;
while (i++ < width)
mask = (mask >> 1) | ((mask | 1) << 31);
i = 0;
while (i < width * height)
{
if (i && !(i % width))
ft_putchar('\n');
tab[i / 32] & (1 << (31 - i % 32)) ? ft_putchar('#') : ft_putchar('.');
ft_putchar(' ');
i++;
}
write(1, "\n", 1);
}
/*
** Function that transform a tab of . and # into a binary tab of int
** function that transform a tab of . and # into a binary tab of int
*/
unsigned short tab_to_bin(char line[])
@@ -107,7 +62,7 @@ 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;
@@ -136,11 +91,11 @@ 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');
// tmp = list->tetribit;
// tmp <<= 16;
// print_map(&tmp, list->width, list->height);
// tmp >>= 16;
}
/*
@@ -151,15 +106,21 @@ void fill_list(char line[], t_fillist *list)
int add_to_list(char *line, t_fillist **list)
{
t_fillist *tmp;
t_fillist *test;
if (!(tmp = (t_fillist*)malloc(sizeof(*tmp))))
return (0);
if (!(*list))
tmp->next = NULL;
tmp->next = NULL;
test = *list;
if (!test)
*list = tmp;
else
tmp->next = *list;
*list = tmp;
fill_list(line, *list);
{
while(test->next)
test = test->next;
test->next = tmp;
}
fill_list(line, tmp);
return (1);
}
@@ -187,4 +148,5 @@ void parse_input(char *input)
while (input[i] && input[i] != '.' && input[i] != '#')
i++;
}
search_map(list);
}