Few edit + BUG on bit convertion for tetri starting at top left corner

This commit is contained in:
Manzovince
2019-04-23 21:44:11 +02:00
parent 2c9340c645
commit 39a59058ba
6 changed files with 30 additions and 31 deletions

2
.gitignore vendored
View File

@@ -11,3 +11,5 @@ a\.out
*.swp *.swp
fillit fillit
test_fillit\.c

View File

@@ -6,7 +6,7 @@
/* By: hulamy <hulamy@student.42.fr> +#+ +:+ +#+ */ /* By: hulamy <hulamy@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2019/04/14 15:20:53 by hulamy #+# #+# */ /* Created: 2019/04/14 15:20:53 by hulamy #+# #+# */
/* Updated: 2019/04/23 21:04:43 by vmanzoni ### ########.fr */ /* Updated: 2019/04/23 21:36:37 by vmanzoni ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@@ -30,13 +30,13 @@ void print_bits(short line)
} }
/* /*
** this function transforme a tetrminos char* into a short of 16 bites ** Function that transforme a tetrminos char* into a short of 16 bites
** then it fills it and its reverse into the list ** then it fills it and its reverse into the list
*/ */
int fill_list(char line[], t_fillist *list) int fill_list(char line[], t_fillist *list)
{ {
short tmp; // short tmp;
int i; int i;
i = 0; i = 0;
@@ -48,14 +48,15 @@ int fill_list(char line[], t_fillist *list)
if (line[i++] == '#') if (line[i++] == '#')
list->tetribit |= 1; list->tetribit |= 1;
} }
tmp = list->tetribit; // tmp = list->tetribit;
while (tmp) // while (tmp)
{ // {
if (tmp & 1) // if (tmp & 1)
list->tibirtet |= 1; // list->tibirtet |= 1;
list->tibirtet <<= 1; // list->tibirtet <<= 1;
tmp >>= 1; // tmp >>= 1;
} // }
print_bits(list->tetribit);
return (0); return (0);
} }
@@ -98,7 +99,7 @@ void print_test(int octet)
/* /*
** DELETE BEFORE EVAL - TEST FUNCTION ** DELETE BEFORE EVAL - TEST FUNCTION
** Test ** Test for big map
*/ */
void test(unsigned int map[]) void test(unsigned int map[])

View File

@@ -6,7 +6,7 @@
/* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */ /* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2019/04/12 22:29:45 by vmanzoni #+# #+# */ /* Created: 2019/04/12 22:29:45 by vmanzoni #+# #+# */
/* Updated: 2019/04/23 21:03:10 by vmanzoni ### ########.fr */ /* Updated: 2019/04/23 21:42:35 by vmanzoni ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@@ -19,11 +19,9 @@
unsigned int *initialize_map(int size) unsigned int *initialize_map(int size)
{ {
unsigned int *map[0]; unsigned int *map[0];
int i;
i = size;
while (size--) while (size--)
map[i] = malloc(sizeof(unsigned int) * i); map[size] = 0;
return (map); return (map);
} }

2
main.c
View File

@@ -6,7 +6,7 @@
/* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */ /* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2019/02/12 13:20:48 by vmanzoni #+# #+# */ /* Created: 2019/02/12 13:20:48 by vmanzoni #+# #+# */
/* Updated: 2019/04/23 16:19:17 by vmanzoni ### ########.fr */ /* Updated: 2019/04/23 21:39:42 by vmanzoni ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View File

@@ -6,7 +6,7 @@
/* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */ /* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2019/04/15 14:48:14 by vmanzoni #+# #+# */ /* Created: 2019/04/15 14:48:14 by vmanzoni #+# #+# */
/* Updated: 2019/04/23 21:09:40 by vmanzoni ### ########.fr */ /* Updated: 2019/04/23 21:23:47 by vmanzoni ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@@ -38,15 +38,13 @@ void parse_input(char *input)
while (input[i] && input[i] != '.' && input[i] != '#') while (input[i] && input[i] != '.' && input[i] != '#')
i++; i++;
} }
/*DEBUG PART - Print each tetribit*/ /*DEBUG PART - Print each tetribit*/
/* // while (list != NULL)
while (list != NULL) // {
{ // printf("%i\n", list->tetribit);
printf("%i\n", list->tetribit); // printf("\n");
printf("\n"); // list = list->next;
list = list->next; // }
}
*/
} }
/* /*

View File

@@ -1,4 +1,4 @@
...# #...
...# #...
...# #...
...# #...