diff --git a/game_of_life_v2/game_of_life_v2.srcs/sources_1/new/game_of_life.vhd b/game_of_life_v2/game_of_life_v2.srcs/sources_1/new/game_of_life.vhd
index e3243536646db2d2192e97b83c0b3c6e549a0164..cfe92575a40a107a2796a6d4ca58d773319e5ab0 100644
--- a/game_of_life_v2/game_of_life_v2.srcs/sources_1/new/game_of_life.vhd
+++ b/game_of_life_v2/game_of_life_v2.srcs/sources_1/new/game_of_life.vhd
@@ -35,8 +35,11 @@ entity game_of_life is
     generic (cell_number : positive := 32);
     Port ( clk : in STD_LOGIC;
            switch_mode : in STD_LOGIC;                     -- 0: editor, 1: simulation
-           --cursor_position_x : in UNSIGNED(9 downto 0);    -- cursor's position in the horizontal axis
-           --cursor_position_y : in UNSIGNED(9 downto 0);    -- cursor's position in the vertical axis
+           move_left : in STD_LOGIC;                       -- cursor's move left button
+           move_right : in STD_LOGIC;                      -- cursor's move right button
+           move_up : in STD_LOGIC;                         -- cursor's move up button
+           move_down : in STD_LOGIC;                       -- cursor's move down button
+           set_cell : in STD_LOGIC;                        -- invert cell's value
            
            Hsync : out STD_LOGIC;                          -- horizontal synchronization controll sign
            Vsync : out STD_LOGIC;                          -- vertical synchronization controll sign
@@ -58,8 +61,8 @@ port
 end component;
 
 signal clk_25MHz, locked : std_logic;
-signal cells : std_logic_vector(0 to cell_number*cell_number-1) := (511 => '1', 512 => '1', 513 => '1',others => '0');
-signal cells_to_draw : std_logic_vector(0 to cell_number*cell_number-1) := (others => '0');
+signal cells : std_logic_vector(0 to cell_number*cell_number-1) := (501 => '1', 502 => '1', 503 => '1',others => '0');
+signal cells_to_draw : std_logic_vector(0 to cell_number*cell_number-1) := (501 => '1', 502 => '1', 503 => '1',others => '0');
 
 -- drawing period's constants
 constant HORIZONTAL_SYNC_PULSE : integer := 800;
@@ -81,7 +84,19 @@ signal frame_sig : std_logic_vector(11 downto 0);
 -- simulation processers
 signal shift_register_top : std_logic_vector(0 to cell_number-1);
 signal shift_register_middle : std_logic_vector(0 to cell_number-1);
+signal actual_register : std_logic_vector(0 to 0);
 signal neighbours : std_logic_vector(0 to 8);
+signal neighbours_count : unsigned(3 downto 0);
+signal frame_counter : unsigned(6 downto 0);
+
+-- cursor handling
+signal cursor_pos_x, cursor_pos_y : unsigned(9 downto 0);
+
+signal prev_move_left : std_logic;
+signal prev_move_right : std_logic;
+signal prev_move_up : std_logic;
+signal prev_move_down : std_logic;
+signal prev_set_cell : std_logic;
 
 begin
 
@@ -96,7 +111,7 @@ clk_gen_25MHz : clk_wiz_0
  );
 
 options : process(clk_25MHz,locked)
-variable neighbour_cnt : unsigned(3 downto 0) := (others=>'0');
+--variable neighbour_cnt : unsigned(3 downto 0) := (others=>'0');
 begin
     if locked = '0' then
         horizontal_counter <= (others => '0');
@@ -106,22 +121,33 @@ begin
         
         shift_register_top <= (others => '0');
         shift_register_middle <= (others => '0');
+        actual_register <= (others => '0');
         neighbours <= (others => '0');
+        neighbours_count <= (others => '0');
+        frame_counter <= (others => '0');
+        
+        cursor_pos_x <= (others => '0');
+        cursor_pos_y <= (others => '0');
+        prev_move_left <= move_left;
+        prev_move_right <= move_right;
+        prev_move_up <= move_up;
+        prev_move_down <= move_down;
+        prev_set_cell <= set_cell;
     else
         if clk_25MHz'event and clk_25MHz = '1' then
             -- output change
             if horizontal_counter(9 downto 3) < cell_number and vertical_counter(9 downto 3) < cell_number then
                 -- editor mode
                 if switch_mode = '0' then
-                    --if cursor_position_x <= horizontal_counter and cursor_position_x+8 > horizontal_counter and cursor_position_y <= vertical_counter and cursor_position_y+8 > vertical_counter then
-                    --    if cells_to_draw(to_integer(vertical_counter(9 downto 3) * to_unsigned(cell_number,8) + horizontal_counter(9 downto 3))) = '0' then
-                    --        frame_sig <= "000011110000";
-                    --    else
-                    --        frame_sig <= "111100000000";
-                    --    end if;
-                    --else
+                    if cursor_pos_x <= horizontal_counter and cursor_pos_x+8 > horizontal_counter and cursor_pos_y <= vertical_counter and cursor_pos_y+8 > vertical_counter then
+                        if cells_to_draw(to_integer(vertical_counter(9 downto 3) * to_unsigned(cell_number,8) + horizontal_counter(9 downto 3))) = '0' then
+                            frame_sig <= "000011110000";
+                        else
+                            frame_sig <= "111100000000";
+                        end if;
+                    else
                         frame_sig <= (others => cells_to_draw(to_integer(vertical_counter(9 downto 3) * to_unsigned(cell_number,8) + horizontal_counter(9 downto 3))));
-                    --end if;
+                    end if;
 
                 -- simulation mode
                 else
@@ -132,40 +158,46 @@ begin
             end if;
 
             -- handle shift registers
-            if horizontal_counter(9 downto 3) < cell_number+2 and vertical_counter(9 downto 3) < cell_number+2 then
+            --if switch_mode = '1' and frame_counter = 0 and horizontal_counter(9 downto 3) < cell_number+2 and vertical_counter(9 downto 3) < cell_number+2 then
+            if switch_mode = '1' and frame_counter = 0 and horizontal_counter(2 downto 0) = 0 and horizontal_counter(9 downto 3) < cell_number and vertical_counter(2 downto 0) = 0 and vertical_counter(9 downto 3) < cell_number then
                 shift_register_top <= shift_register_top(1 to cell_number-1) & shift_register_middle(0);
                 
-                if horizontal_counter(9 downto 3) /= 0 and horizontal_counter(9 downto 3) < cell_number+1 and vertical_counter(9 downto 3) /= 0 and vertical_counter(9 downto 3) < cell_number+1 then
-                    shift_register_middle <= shift_register_middle(1 to cell_number-1) & cells(to_integer((vertical_counter(9 downto 3)-1) * to_unsigned(cell_number,8) + horizontal_counter(9 downto 3)-1));
-                    neighbours <= neighbours(3 to 8) & shift_register_top(0) & shift_register_middle(0) & cells(to_integer((vertical_counter(9 downto 3) -1)* to_unsigned(cell_number,8) + horizontal_counter(9 downto 3)-1));
+                --if horizontal_counter(9 downto 3) /= 0 and horizontal_counter(9 downto 3) < cell_number+1 and vertical_counter(9 downto 3) /= 0 and vertical_counter(9 downto 3) < cell_number+1 then
+                if horizontal_counter(9 downto 3) < cell_number and vertical_counter(9 downto 3) < cell_number then
+                    shift_register_middle <= shift_register_middle(1 to cell_number-1) & actual_register;
+                    neighbours <= neighbours(3 to 8) & shift_register_top(0) & shift_register_middle(0) & actual_register;
+                    neighbours_count <= neighbours_count - unsigned(neighbours(0 to 0)) - unsigned(neighbours(1 to 1)) - unsigned(neighbours(2 to 2)) + unsigned(shift_register_top(0 to 0)) + unsigned(shift_register_middle(0 to 0)) + unsigned(actual_register);
+                    actual_register(0) <= cells(to_integer((vertical_counter(9 downto 3))* to_unsigned(cell_number,8) + horizontal_counter(9 downto 3)));
                 else
-                    shift_register_middle <= shift_register_middle(1 to cell_number-1) & '0';
-                    neighbours <= neighbours(3 to 8) & shift_register_top(0) & shift_register_middle(0) & '0';
+                    shift_register_middle <= shift_register_middle(1 to cell_number-1) & actual_register;
+                    neighbours <= neighbours(3 to 8) & shift_register_top(0) & shift_register_middle(0) & actual_register;
+                    neighbours_count <= neighbours_count - unsigned(neighbours(0 to 0)) - unsigned(neighbours(1 to 1)) - unsigned(neighbours(2 to 2)) + unsigned(shift_register_top(0 to 0)) + unsigned(shift_register_middle(0 to 0)) + unsigned(actual_register);
+                    actual_register <= (others => '0');
                 end if;
                 
                 if vertical_counter(9 downto 3) >= 2 and horizontal_counter(9 downto 3) >= 2 then
-                    neighbour_cnt := (others=>'0');
-                    for i in 0 to 8 loop
-                        if (neighbours(i)) = '1' then
-                            neighbour_cnt := neighbour_cnt+1;
-                        end if;
-                    end loop;
+                    --neighbour_cnt := (others=>'0');
+                    --for i in 0 to 8 loop
+                    --    if (neighbours(i)) = '1' then
+                            --neighbour_cnt := neighbour_cnt+1;
+                    --    end if;
+                    --end loop;
                     
                     if neighbours(4)='1' then
-                        if neighbour_cnt = 3 or neighbour_cnt = 4 then
-                            cells(to_integer((vertical_counter(9 downto 3)-1) * to_unsigned(cell_number,8) + horizontal_counter(9 downto 3)-1)) <= '1';
-                            cells_to_draw(to_integer((vertical_counter(9 downto 3)-1) * to_unsigned(cell_number,8) + horizontal_counter(9 downto 3)-1)) <= '1';
+                        if neighbours_count = 3 or neighbours_count = 4 then
+                            cells(to_integer((vertical_counter(9 downto 3)-1) * to_unsigned(cell_number,8) + horizontal_counter(9 downto 3)-2)) <= '1';
+                            cells_to_draw(to_integer((vertical_counter(9 downto 3)-1) * to_unsigned(cell_number,8) + horizontal_counter(9 downto 3)-2)) <= '1';
                         else
-                            cells(to_integer((vertical_counter(9 downto 3)-1) * to_unsigned(cell_number,8) + horizontal_counter(9 downto 3)-1)) <= '0';
-                            cells_to_draw(to_integer((vertical_counter(9 downto 3)-1) * to_unsigned(cell_number,8) + horizontal_counter(9 downto 3)-1)) <= '0';
+                            cells(to_integer((vertical_counter(9 downto 3)-1) * to_unsigned(cell_number,8) + horizontal_counter(9 downto 3)-2)) <= '0';
+                            cells_to_draw(to_integer((vertical_counter(9 downto 3)-1) * to_unsigned(cell_number,8) + horizontal_counter(9 downto 3)-2)) <= '0';
                         end if;
                     else
-                        if neighbour_cnt = 3 then
-                            cells(to_integer((vertical_counter(9 downto 3)-1) * to_unsigned(cell_number,8) + horizontal_counter(9 downto 3)-1)) <= '1';
-                            cells_to_draw(to_integer((vertical_counter(9 downto 3)-1) * to_unsigned(cell_number,8) + horizontal_counter(9 downto 3)-1)) <= '1';
+                        if neighbours_count = 3 then
+                            cells(to_integer((vertical_counter(9 downto 3)-1) * to_unsigned(cell_number,8) + horizontal_counter(9 downto 3)-2)) <= '1';
+                            cells_to_draw(to_integer((vertical_counter(9 downto 3)-1) * to_unsigned(cell_number,8) + horizontal_counter(9 downto 3)-2)) <= '1';
                         else
-                            cells(to_integer((vertical_counter(9 downto 3)-1) * to_unsigned(cell_number,8) + horizontal_counter(9 downto 3)-1)) <= '0';
-                            cells_to_draw(to_integer((vertical_counter(9 downto 3)-1) * to_unsigned(cell_number,8) + horizontal_counter(9 downto 3)-1)) <= '0';
+                            cells(to_integer((vertical_counter(9 downto 3)-1) * to_unsigned(cell_number,8) + horizontal_counter(9 downto 3)-2)) <= '0';
+                            cells_to_draw(to_integer((vertical_counter(9 downto 3)-1) * to_unsigned(cell_number,8) + horizontal_counter(9 downto 3)-2)) <= '0';
                         end if;
                     end if;
                     
@@ -173,6 +205,35 @@ begin
                 
             end if;
             
+            -- moving with cursor
+            if switch_mode = '0' then
+                if prev_move_left = '0' and move_left = '1' and cursor_pos_x /= 0 then
+                    cursor_pos_x <= cursor_pos_x - 8;
+                end if;
+                if prev_move_right = '0' and move_right = '1' and cursor_pos_x /= (cell_number-1)*8 then
+                    cursor_pos_x <= cursor_pos_x + 8;
+                end if;
+                if prev_move_up = '0' and move_up = '1' and cursor_pos_y /= 0 then
+                    cursor_pos_y <= cursor_pos_y - 8;
+                end if;
+                if prev_move_down = '0' and move_down = '1' and cursor_pos_y /= (cell_number-1)*8 then
+                    cursor_pos_y <= cursor_pos_y + 8;
+                end if;
+                
+                -- set cell's value
+                if prev_set_cell = '0' and set_cell = '1' then
+                    cells(to_integer(cursor_pos_y(9 downto 3)*cell_number + cursor_pos_x(9 downto 3))) <= not cells(to_integer(cursor_pos_y(9 downto 3)*cell_number + cursor_pos_x(9 downto 3)));
+                    cells_to_draw(to_integer(cursor_pos_y(9 downto 3)*cell_number + cursor_pos_x(9 downto 3))) <= not cells_to_draw(to_integer(cursor_pos_y(9 downto 3)*cell_number + cursor_pos_x(9 downto 3)));
+                end if;
+            end if;
+            
+            -- memorize previous state
+            prev_move_left <= move_left;
+            prev_move_right <= move_right;
+            prev_move_up <= move_up;
+            prev_move_down <= move_down;
+            prev_set_cell <= set_cell;
+            
             -- sign options
             if horizontal_counter = HORIZONTAL_DISPLAY_TIME + HORIZONTAL_FRONT_PORCH - 1 then
                 Hsync_sig <= '0';
@@ -190,6 +251,11 @@ begin
             -- position changing
             if vertical_counter = VERTICAL_SYNC_PULSE-1 then
                 vertical_counter <= (others => '0');
+                if frame_counter = 127 then
+                    frame_counter <= (others => '0');
+                else
+                    frame_counter <= frame_counter + 1;
+                end if;
             end if;
             if horizontal_counter = HORIZONTAL_SYNC_PULSE-1 then
                 horizontal_counter <= (others => '0');