#include "fillit.h" #include #include unsigned int ft_sqrt_ceil(unsigned int num) { int i; i = 1; while (i * i < num) i++; return (i); } void clear_map(t_map *map) { int i; i = 0; while (i < 16) map->line[i++] = 0; } t_tetraminos *convert_tetramino(char *s) { t_tetraminos *res; uint16_t temp; int i; int y; res = (t_tetraminos*)malloc(sizeof(t_tetraminos)); res->offset_y = 0; i = 0; y = 1; while (i < 16) { temp = 0; while (i < y * 4) { temp = temp << 1; if (s[i++] == '#') temp = temp | 0x01; } temp = temp << 12; res->line[y - 1] = temp; y++; } return (res); } t_map *map_initialization(char **tetramino_table) { t_map *map; unsigned int i; map = (t_map*)malloc(sizeof(t_map)); i = 0; while (*tetramino_table) map->figure[i++] = convert_tetramino(*tetramino_table++); map->figure_amount = i; map->size = ft_sqrt_ceil(i * 4); clear_map(map); return (map); } void insert_tetramino(t_map *map, int index) { int i; int k; t_tetraminos *temp; temp = map->figure[index]; i = temp->offset_y; k = i + 4; while (i < k) { map->line[i] |= temp->line[i]; i++; } } void erase_tetramino(t_map *map, int index) { int i; int k; t_tetraminos *temp; temp = map->figure[index]; i = temp->offset_y; k = 0; while (k < 4) { map->line[i + k] ^= temp->line[i + k]; k++; } } void algorithm(t_map *map) { }