fonction pour verifier si l'emplacement est libre en cours de construction

This commit is contained in:
Hugo LAMY
2019-04-25 07:06:37 +02:00
parent dabdd7dbef
commit 2364b6322a

View File

@@ -45,7 +45,7 @@ void print_map(unsigned int *tab, int s)
/*
** second version :
** n'utilise pas le mask m
** n'utilise pas le mask m et le tmp
*/
if (!(i % s))
ft_putchar('\n');
@@ -56,6 +56,43 @@ void print_map(unsigned int *tab, int s)
write(1, "\n", 1);
}
void find_place(unsigned int *tab, char *line, int s)
{
unsigned short tetri;
int i;
unsigned int m;
unsigned int tmp;
ft_putendl("# . . # # # # T T # . # . # # # # # . . # # . # T # . # # # # . . # . # . . # # T . . # # # . # # . # # # . . . # # # # . . # . . # . # # . . # . . . # . . . . # . . . # # . # . . . # . # # .");
// create tetri
i = 0;
while (line[i])
{
tetri <<= 1;
if (line[i] == '\n')
i++;
if (line[i++] == '#')
tetri |= 1;
}
while (!(tetri & (1 << 15)))
tetri <<= 1;
print_bits(tetri, 16);
write(1, "\n", 1);
m = 15 << (32 - 4);
i = 0;
while (i < 20)
{
while (i < 4 * s)
{
tmp = (m & (tab[i / 32] << i)) | (m & (tab[(i + s) / 32] >> (32 - i)));
print_bits(tmp, 32);
i += s;
}
i++;
}
}
int main(int ac, char **av)
{
unsigned int tab[8];
@@ -84,6 +121,9 @@ int main(int ac, char **av)
if (av[0][0] == 'b' && ac > 2)
ft_putendl(ft_convertbase(av[1], "01", "0123456789"));
print_map(tab, 16);
write(1, "\n", 1);
if (av[0][0] == 't' && ac > 2)
find_place(tab, av[1], 16);
}
return (0);
}