Index: proj/TB.mk
===================================================================
--- proj/TB.mk	(revision 166)
+++ proj/TB.mk	(revision 167)
@@ -2,7 +2,7 @@
 
 SRCS= proj.c graph.c sprite.c kbc.c keyboard.c mouse.c utils.c timer.c interrupts_func.c proj_func.c
 
-CPPFLAGS += -pedantic -I./bmp -I./xpm -D __LCOM_OPTIMIZED_ -D TELMO
+CPPFLAGS += -pedantic -I./bmp -I./xpm -D TELMO #-D __LCOM_OPTIMIZED_
 
 DPADD += ${LIBLCF}
 LDADD += -llcf
Index: proj/keyboard.c
===================================================================
--- proj/keyboard.c	(revision 166)
+++ proj/keyboard.c	(revision 167)
@@ -6,6 +6,7 @@
 #include "kbc_macros.h"
 #include "utils.h"
 #include "errors.h"
+#include "proj_func.h"
 
 int (subscribe_kbc_interrupt)(uint8_t interrupt_bit, int *interrupt_id) {
     if (interrupt_id == NULL) return NULL_PTR;
@@ -19,7 +20,7 @@
 int got_error_keyboard = SUCCESS;
 
 void (kbc_ih)(void) {
-    if(done) sz = 1;
+    if(done) { update_movement(); sz = 1; }
     else     sz++;
     uint8_t status = 0;
     got_error_keyboard = SUCCESS;
@@ -37,6 +38,8 @@
 
     scancode[sz-1] = byte;
     done = !(TWO_BYTE_CODE == byte);
+
+
 }
 
 int (keyboard_poll)(uint8_t bytes[], uint8_t *size){
Index: proj/proj.c
===================================================================
--- proj/proj.c	(revision 166)
+++ proj/proj.c	(revision 167)
@@ -87,9 +87,10 @@
                     for (uint32_t i = 0, n = 1; i < 32; i++, n <<= 1) {
                         if (msg.m_notify.interrupts & n) {
                             interrupt_handler(i);
+                            if ((scancode[0]) == ESC_BREAK_CODE) good = 0;
                         }
                     }
-                    if (scancode[0] == ESC_BREAK_CODE) good = 0;
+
                     break;
                 default:
                     break; /* no other notifications expected: do nothing */
@@ -97,6 +98,23 @@
         } else { /* received standart message, not a notification */
             /* no standart message expected: do nothing */
         }
+
+        switch (get_hor_movement()) {
+            case LEFT:
+                printf("GOING LEFT.\n");
+                break;
+            case RIGHT:
+                printf("GOING RIGHT.\n");
+                break;
+        }
+        switch (get_ver_movement()) {
+            case UP:
+                printf("GOING UP.\n");
+                break;
+            case DOWN:
+                printf("GOING DOWN.\n");
+                break;
+        }
     }
 
     // Unsubscribe interrupts
Index: proj/proj_func.c
===================================================================
--- proj/proj_func.c	(revision 166)
+++ proj/proj_func.c	(revision 167)
@@ -1,10 +1,18 @@
+#include <lcom/lcf.h>
+
 #include "proj_func.h"
+
 #include "interrupts_func.h"
 #include "graph.h"
+#include "keyboard.h"
 #include "errors.h"
+#include "proj_macros.h"
+#include "utils.h"
 
-#include <lcom/lcf.h>
+#include "kbc_macros.h"
 
+#include <math.h>
+
 int cleanup(void) {
     int r = SUCCESS;
     if ((r = unsubscribe_all()))
@@ -14,3 +22,32 @@
 
     return r;
 }
+
+static int hor_mov = REST, ver_mov = REST;
+
+void update_movement(void) {
+    static int w_pressed = 0, a_pressed = 0, s_pressed = 0, d_pressed = 0;
+    if (sz == 1) {
+        kbd_print_scancode(!(scancode[0] & BREAK_CODE_BIT), 1, scancode);
+        switch(scancode[0]) {
+        case W_MAKE_CODE  : w_pressed = 1;      break;
+        case W_BREAK_CODE : w_pressed = 0;      break;
+        case A_MAKE_CODE  : a_pressed = 1;      break;
+        case A_BREAK_CODE : a_pressed = 0;      break;
+        case S_MAKE_CODE  : s_pressed = 1;      break;
+        case S_BREAK_CODE : s_pressed = 0;      break;
+        case D_MAKE_CODE  : d_pressed = 1;      break;
+        case D_BREAK_CODE : d_pressed = 0;      break;
+        }
+    }
+    ver_mov = s_pressed - w_pressed;
+    hor_mov = d_pressed - a_pressed;
+}
+
+double get_mouse_angle(sprite_t *p, int32_t mouse_x, int32_t mouse_y) {
+    return atan2(sprite_get_y(p) - mouse_y, mouse_x - sprite_get_x(p));
+}
+
+int get_hor_movement(void) { return hor_mov; }
+
+int get_ver_movement(void) { return ver_mov; }
Index: proj/proj_func.h
===================================================================
--- proj/proj_func.h	(revision 166)
+++ proj/proj_func.h	(revision 167)
@@ -1,6 +1,8 @@
 #ifndef PROJ_FUNC_H_INCLUDED
 #define PROJ_FUNC_H_INCLUDED
 
+#include "sprite.h"
+
 /**
  * @brief Cleans up all memory, unsubscribes interrupts.
  * @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
@@ -8,4 +10,30 @@
  */
 int cleanup(void);
 
+/**
+ * @brief Updates movement variables.
+ */
+void update_movement(void);
+
+/**
+ * @brief
+ * @param
+ * @param
+ * @param
+ * @return Angle
+ */
+double get_mouse_angle(sprite_t *p, int32_t mouse_x, int32_t mouse_y);
+
+/**
+ * @brief Get horizontal movement direction.
+ * @return Horizontal movement direction (-1 -> heading LEFT; 0 -> not moving horizontally; 1 -> heading RIGHT)
+ */
+int get_hor_movement(void);
+
+/**
+ * @brief Get vertical movement direction.
+ * @return Vertical movement direction (-1 -> heading UP; 0 -> not moving vertically; 1 -> heading DOWN)
+ */
+int get_ver_movement(void);
+
 #endif /* end of include guard: PROJ_FUNC_H_INCLUDED */
Index: proj/proj_macros.h
===================================================================
--- proj/proj_macros.h	(revision 166)
+++ proj/proj_macros.h	(revision 167)
@@ -3,14 +3,21 @@
 
 // WASD Movement Keys
 #define W_MAKE_CODE     0x11    /** @brief W Make Code */
-#define W_BREAK_CODE    0x91    /** @brief W Make Code */
+#define W_BREAK_CODE    0x91    /** @brief W Break Code */
 #define A_MAKE_CODE     0x1E    /** @brief A Make Code */
-#define A_BREAK_CODE    0x9E    /** @brief A Make Code */
+#define A_BREAK_CODE    0x9E    /** @brief A Break Code */
 #define S_MAKE_CODE     0x1F    /** @brief S Make Code */
-#define S_BREAK_CODE    0x9F    /** @brief S Make Code */
+#define S_BREAK_CODE    0x9F    /** @brief S Break Code */
 #define D_MAKE_CODE     0x20    /** @brief D Make Code */
-#define D_BREAK_CODE    0xA0    /** @brief D Make Code */
+#define D_BREAK_CODE    0xA0    /** @brief D Break Code */
 
+// Movement Directions
+#define UP      -1  /** @brief Moving to the top side of screen */
+#define DOWN    1   /** @brief Moving to the bottom side of screen */
+#define LEFT    -1  /** @brief Moving to the left side of screen */
+#define RIGHT   1   /** @brief Moving to the right side of screen */
+#define REST    0   /** @brief Not moving */
+
 // Extra Keys
 #define ESC_MAKE_CODE   0x01    /** @brief ESC Make Code */
 #define ESC_BREAK_CODE  0x81    /** @brief ESC Break Code */
Index: proj/sprite.c
===================================================================
--- proj/sprite.c	(revision 166)
+++ proj/sprite.c	(revision 167)
@@ -45,8 +45,10 @@
 void (sprite_set_angle) (sprite_t *p, double angle){ p->theta = angle; }
 void (sprite_set_center)(sprite_t *p, int16_t u0, int16_t v0){ p->u0 = u0; p->v0 = v0; }
 
-uint16_t (sprite_get_w)(const sprite_t *p){ return p->w; }
-uint16_t (sprite_get_h)(const sprite_t *p){ return p->h; }
+int sprite_get_x(const sprite_t *p){ return p->x; }
+int sprite_get_y(const sprite_t *p){ return p->y; }
+int sprite_get_w(const sprite_t *p){ return p->w; }
+int sprite_get_h(const sprite_t *p){ return p->h; }
 
 void (sprite_src2pic)(const sprite_t *p, int16_t x, int16_t y, int16_t *u, int16_t *v){
     int16_t dx = x - p->x;
Index: proj/sprite.h
===================================================================
--- proj/sprite.h	(revision 166)
+++ proj/sprite.h	(revision 167)
@@ -13,8 +13,10 @@
 void (sprite_set_angle) (sprite_t *p, double angle);
 void (sprite_set_center)(sprite_t *p, int16_t u0, int16_t v0);
 
-uint16_t (sprite_get_w)(const sprite_t *p);
-uint16_t (sprite_get_h)(const sprite_t *p);
+int sprite_get_x(const sprite_t *p);
+int sprite_get_y(const sprite_t *p);
+int sprite_get_w(const sprite_t *p);
+int sprite_get_h(const sprite_t *p);
 
 void (sprite_draw)(const sprite_t *p);
 
Index: proj/utils.c
===================================================================
--- proj/utils.c	(revision 166)
+++ proj/utils.c	(revision 167)
@@ -31,5 +31,5 @@
     return SUCCESS;
 }
 
-int16_t min(int16_t a, int16_t b){ return (b < a ? b : a); }
-int16_t max(int16_t a, int16_t b){ return (a < b ? b : a); }
+int32_t min(int32_t a, int32_t b){ return (b < a ? b : a); }
+int32_t max(int32_t a, int32_t b){ return (a < b ? b : a); }
Index: proj/utils.h
===================================================================
--- proj/utils.h	(revision 166)
+++ proj/utils.h	(revision 167)
@@ -39,7 +39,7 @@
  * @param b     Second value
  * @return  The minimum of the two values
  */
-int16_t min(int16_t a, int16_t b);
+int32_t min(int32_t a, int32_t b);
 
 /**
  * @brief Gets the maximum value out of two values.
@@ -47,7 +47,7 @@
  * @param b     Second value
  * @return  The maximum of the two values
  */
-int16_t max(int16_t a, int16_t b);
+int32_t max(int32_t a, int32_t b);
 
 
 #endif //UTILS_H_INCLUDED
