+ // Configurations
+ // DCBA | X Y
+ // 0001 3 0
+ // 0010
+
+ for( int y = 0; y < map.y; y ++ )
+ {
+ for( int x = 0; x < map.x; x ++ )
+ {
+ struct cell *cur = map.cells + y*map.x + x;
+ u8 *cellbytes = celldata + (y*map.x+x)*4;
+
+ if( cur->flags & CELL_FLAG_WALKABLE )
+ {
+ struct cell *a, *b, *c, *d;
+
+ a = map_tile_at_cond( (int[2]){ x,y+1 }, CELL_FLAG_WALKABLE );
+ b = map_tile_at_cond( (int[2]){ x+1,y }, CELL_FLAG_WALKABLE );
+ c = map_tile_at_cond( (int[2]){ x,y-1 }, CELL_FLAG_WALKABLE );
+ d = map_tile_at_cond( (int[2]){ x-1,y }, CELL_FLAG_WALKABLE );
+
+ u32 config = (a?0x1:0x0) | (b?0x2:0x0) | (c?0x4:0x0) | (d?0x8:0x0);
+
+ cellbytes[ 0 ] = config;
+ cellbytes[ 1 ] = 0;
+ }
+ else
+ {
+ // TODO: Random background tiles
+ cellbytes[ 0 ] = 1;
+ cellbytes[ 1 ] = 0;
+ }
+ }
+ }
+