Index: proj/graph.c
===================================================================
--- proj/graph.c	(revision 173)
+++ proj/graph.c	(revision 174)
@@ -6,12 +6,44 @@
 
 #include <stdio.h>
 
-static void *video_mem = NULL; /** @brief Frame-buffer VM address. */
-static uint8_t *video_buf = NULL; /** @brief Primary buffer for drawing before copying to video_mem. */
+/// MACROS
+#define FAR2PHYS(n)         ((((n)>>12) & 0xFFFFFFF0) + ((n) & 0x0000FFFF))
+
+/// STRUCT
+typedef struct __attribute__((packed)) {
+
+    char        VbeSignature[4]     ;
+    uint16_t    VbeVersion          ;
+    uint32_t    OemStringPtr        ;
+    uint8_t     Capabilities[4]     ;
+    uint32_t    VideoModePtr        ;
+    uint16_t    TotalMemory         ;
+
+    uint16_t    OemSoftwareRev      ;
+    uint32_t    OemVendorNamePtr    ;
+    uint32_t    OemProductNamePtr   ;
+    uint32_t    OemProductRevPtr    ;
+    char        Reserved[222]       ;
+
+    char        OemData[256]        ;
+} VbeInfoBlock;
+
 static vbe_mode_info_t vbe_mem_info;
-static mmap_t mem_map;
 
-int (get_permission)(unsigned int base_addr, unsigned int size) {
+/// PUBLIC GET
+uint16_t   (graph_get_XRes)         (void){ return vbe_mem_info.XResolution; }
+uint16_t   (graph_get_YRes)         (void){ return vbe_mem_info.YResolution; }
+
+/// PRIVATE GET
+static uint16_t   (graph_get_bits_pixel)   (void){ return vbe_mem_info.BitsPerPixel; }
+static uint16_t   (graph_get_bytes_pixel)  (void){ return (graph_get_bits_pixel() + 7) >> 3; }
+static phys_bytes (graph_get_phys_addr)    (void){ return vbe_mem_info.PhysBasePtr; }
+static unsigned   (graph_get_vram_size)    (void){ return vbe_mem_info.XResolution * vbe_mem_info.YResolution * graph_get_bytes_pixel(); }
+//static uint16_t   (graph_get_RedMaskSize)  (void){ return vbe_mem_info.RedMaskSize  ; }
+//static uint16_t   (graph_get_GreenMaskSize)(void){ return vbe_mem_info.GreenMaskSize; }
+//static uint16_t   (graph_get_BlueMaskSize) (void){ return vbe_mem_info.BlueMaskSize ; }
+
+static int (get_permission)(unsigned int base_addr, unsigned int size) {
     struct minix_mem_range mmr;
     mmr.mr_base = base_addr;
     mmr.mr_limit = base_addr + size;
@@ -18,35 +50,47 @@
     return sys_privctl(SELF, SYS_PRIV_ADD_MEM, &mmr);
 }
 
-//int (get_permissions_first_mbyte)(void) {
+//static int (get_permissions_first_mbyte)(void) {
 //    return get_permission(MBYTE_BASE, MBYTE_SIZE);
 //}
 
-int (graph_init)(uint16_t mode){
-    if (vbe_get_mode_information(mode)) {
-        printf("%s: failed to get information for mode %x.\n", __func__, mode);
-        return 1;
+/// MEMORY
+static void    *video_mem = NULL; /** @brief Frame-buffer VM address. */
+static uint8_t *video_buf = NULL; /** @brief Primary buffer for drawing before copying to video_mem. */
+static mmap_t mem_map;
+static int (graph_free_memory)(void) {
+    int r = SUCCESS;
+    free(video_buf); video_buf = NULL;
+    r = !lm_free(&mem_map);
+    return r;
+}
+static int (graph_map_vram)(void) {
+    int r;
+    const unsigned vram_base = graph_get_phys_addr();
+    const unsigned vram_size = graph_get_vram_size();
+    if ((r = get_permission(vram_base, vram_size))) {
+        if (graph_free_memory()) {
+            printf("%s: lm_free failed\n", __func__);
+        }
+        panic("%s: sys_privctl (ADD MEM) failed: %d\n", __func__, r);
     }
 
-    graph_map_vram(); // if function fails it aborts program
+    video_mem = vm_map_phys(SELF, (void *)vram_base, vram_size);
 
-    if (graph_set_mode(mode)) {
-        printf("%s: failed to set graphic mode %x.\n", __func__, mode);
-        return 1;
-    };
+    if (video_mem == MAP_FAILED) {
+        if (graph_free_memory()) {
+            printf("%s: lm_free failed\n", __func__);
+        }
+        panic("%s: couldn't map video memory.", __func__);
+    }
+
+    video_buf = malloc(vram_size);
+
     return SUCCESS;
 }
 
-int (graph_cleanup)(void){
-    int r = SUCCESS;
-    if ((r = vg_exit()))
-        printf("%s: vg_exit failed to exit to text mode.\n", __func__);
-    if ((r = graph_free_memory()))
-        printf("%s: lm_free failed\n", __func__);
-    return r;
-}
-
-int (vbe_get_mode_information)(uint16_t mode) {
+/// INFO GET
+static int (vbe_get_mode_information)(uint16_t mode) {
     memset(&vbe_mem_info, 0, sizeof(vbe_mode_info_t)); // reset values
 
     struct reg86 reg_86;
@@ -72,8 +116,8 @@
     memcpy((void*)&vbe_mem_info, (void*)virtual_addr, mem_map.size);
     return SUCCESS;
 }
-
-int (vbe_get_controller_information)(vg_vbe_contr_info_t *info_p) {
+/*
+static int (vbe_get_controller_information)(vg_vbe_contr_info_t *info_p) {
     memset(info_p, 0, sizeof(vg_vbe_contr_info_t)); // reset values
 
     mmap_t controller_map;
@@ -147,50 +191,15 @@
 
     return SUCCESS;
 }
+*/
 
-phys_bytes (graph_get_phys_addr)    (void){ return vbe_mem_info.PhysBasePtr; }
-unsigned   (graph_get_vram_size)    (void){ return vbe_mem_info.XResolution * vbe_mem_info.YResolution * graph_get_bytes_pixel(); }
-uint16_t   (graph_get_XRes)         (void){ return vbe_mem_info.XResolution; }
-uint16_t   (graph_get_YRes)         (void){ return vbe_mem_info.YResolution; }
-uint16_t   (graph_get_bits_pixel)   (void){ return vbe_mem_info.BitsPerPixel; }
-uint16_t   (graph_get_bytes_pixel)  (void){ return (vbe_mem_info.BitsPerPixel + 7) >> 3; }
-uint16_t   (graph_get_RedMaskSize)  (void){ return vbe_mem_info.RedMaskSize  ; }
-uint16_t   (graph_get_GreenMaskSize)(void){ return vbe_mem_info.GreenMaskSize; }
-uint16_t   (graph_get_BlueMaskSize) (void){ return vbe_mem_info.BlueMaskSize ; }
-
-int (graph_map_vram)(void) {
-    int r;
-    const unsigned vram_base = graph_get_phys_addr();
-    const unsigned vram_size = graph_get_vram_size();
-    if ((r = get_permission(vram_base, vram_size))) {
-        if (graph_free_memory()) {
-            printf("%s: lm_free failed\n", __func__);
-        }
-        panic("%s: sys_privctl (ADD MEM) failed: %d\n", __func__, r);
-    }
-
-    video_mem = vm_map_phys(SELF, (void *)vram_base, vram_size);
-
-    if (video_mem == MAP_FAILED) {
-        if (graph_free_memory()) {
-            printf("%s: lm_free failed\n", __func__);
-        }
-        panic("%s: couldn't map video memory.", __func__);
-    }
-
-    video_buf = malloc(vram_size);
-
-    return SUCCESS;
-}
-
-int (graph_free_memory)(void) {
-    int r = SUCCESS;
-    free(video_buf); video_buf = NULL;
-    r = !lm_free(&mem_map);
-    return r;
-}
-
-int (graph_set_mode)(uint16_t mode) {
+/// INIT
+/**
+ * @brief
+ * @param mode
+ * @return
+ */
+static int (graph_set_mode)(uint16_t mode) {
     struct reg86 reg_86;
 
     memset(&reg_86, 0, sizeof(struct reg86)); // reset struct
@@ -209,7 +218,32 @@
 
     return SUCCESS;
 }
+int (graph_init)(uint16_t mode){
+    if (vbe_get_mode_information(mode)) {
+        printf("%s: failed to get information for mode %x.\n", __func__, mode);
+        return 1;
+    }
 
+    graph_map_vram(); // if function fails it aborts program
+
+    if (graph_set_mode(mode)) {
+        printf("%s: failed to set graphic mode %x.\n", __func__, mode);
+        return 1;
+    };
+    return SUCCESS;
+}
+
+/// CLEANUP
+int (graph_cleanup)(void){
+    int r = SUCCESS;
+    if ((r = vg_exit()))
+        printf("%s: vg_exit failed to exit to text mode.\n", __func__);
+    if ((r = graph_free_memory()))
+        printf("%s: lm_free failed\n", __func__);
+    return r;
+}
+
+/// PIXEL DRAWING
 int (graph_set_pixel)(uint16_t x, uint16_t y, uint32_t color) {
     if (x >= vbe_mem_info.XResolution || y >= vbe_mem_info.YResolution) {
         //printf("%s: invalid pixel.\n", __func__);
@@ -235,6 +269,18 @@
     //return set_pixel(x,y,color);
 }
 
+int (graph_clear_screen)(void){
+    //return graph_paint_screen(BLACK);
+    memset(video_buf, 0, graph_get_vram_size());
+    return SUCCESS;
+}
+
+int (graph_draw)(void){
+    memcpy((uint8_t*)video_mem, video_buf, graph_get_vram_size());
+    return 0;
+}
+
+/// RECTANGLE
 int (graph_draw_hline)(uint16_t x, uint16_t y, uint16_t len, uint32_t color){
     int r;
     for (uint16_t i = 0; i < len; i++)
@@ -241,9 +287,6 @@
         if ((r = graph_set_pixel(x + i, y, color))) return r;
     return SUCCESS;
 }
-int (vg_draw_hline)(uint16_t x, uint16_t y, uint16_t len, uint32_t color){
-    return graph_draw_hline(x,y,len,color);
-}
 
 int (graph_draw_rectangle)(uint16_t x, uint16_t y,uint16_t width, uint16_t height, uint32_t color)	{
     int r;
@@ -251,21 +294,3 @@
         if ((r = graph_draw_hline(x, y + i, width, color))) return r;
     return SUCCESS;
 }
-int (vg_draw_rectangle)(uint16_t x, uint16_t y,uint16_t width, uint16_t height, uint32_t color){
-    return graph_draw_rectangle(x,y,width,height, color);
-}
-
-int (graph_paint_screen)(uint32_t color){
-    return graph_draw_rectangle(0,0,graph_get_XRes(),graph_get_YRes(),color);
-}
-
-int (graph_clear_screen)(void){
-    //return graph_paint_screen(BLACK);
-    memset(video_buf, 0, graph_get_vram_size());
-    return SUCCESS;
-}
-
-int (graph_draw)(void){
-    memcpy((uint8_t*)video_mem, video_buf, graph_get_vram_size());
-    return 0;
-}
Index: proj/graph.h
===================================================================
--- proj/graph.h	(revision 173)
+++ proj/graph.h	(revision 174)
@@ -4,79 +4,43 @@
 #include <lcom/lcf.h>
 #include <stdint.h>
 
-#define GET_ALP(n)          (0xFF & ((n) >> 24))
+/// MACROS
+//#define GET_ALP(n)          (0xFF & ((n) >> 24))
 #define GET_RED(n)          (0xFF & ((n) >> 16))
 #define GET_GRE(n)          (0xFF & ((n) >>  8))
 #define GET_BLU(n)          (0xFF & (n      ))
-#define SET_ALP(n)          (((n)&0xFF) << 24)
+//#define SET_ALP(n)          (((n)&0xFF) << 24)
 #define SET_RED(n)          (((n)&0xFF) << 16)
 #define SET_GRE(n)          (((n)&0xFF) <<  8)
 #define SET_BLU(n)          (((n)&0xFF)      )
-#define SET_RGB(r,g,b)      (             SET_RED(r) | SET_GRE(g) | SET_BLU(b))
-#define SET_ARGB(a,r,g,b)   (SET_ALP(a) | SET_RED(r) | SET_GRE(g) | SET_BLU(b))
-#define FAR2PHYS(n)         ((((n)>>12) & 0xFFFFFFF0) + ((n) & 0x0000FFFF))
+#define SET_RGB(r,g,b)      (SET_RED(r) | SET_GRE(g) | SET_BLU(b))
 
-typedef struct __attribute__((packed)) {
+/// PUBLIC GET
+uint16_t   (graph_get_XRes)         (void);
+uint16_t   (graph_get_YRes)         (void);
 
-    char        VbeSignature[4]     ;
-    uint16_t    VbeVersion          ;
-    uint32_t    OemStringPtr        ;
-    uint8_t     Capabilities[4]     ;
-    uint32_t    VideoModePtr        ;
-    uint16_t    TotalMemory         ;
+/// INIT
+int (graph_init)(uint16_t mode);
 
-    uint16_t    OemSoftwareRev      ;
-    uint32_t    OemVendorNamePtr    ;
-    uint32_t    OemProductNamePtr   ;
-    uint32_t    OemProductRevPtr    ;
-    char        Reserved[222]       ;
-
-    char        OemData[256]        ;
-} VbeInfoBlock;
-
-int (get_permission)(unsigned int base_addr, unsigned int size);
-
-//int (get_permissions_first_mbyte)(void);
-
-int (graph_init)(uint16_t mode);
+/// CLEANUP
 int (graph_cleanup)(void);
 
-int (vbe_get_mode_information)(uint16_t mode);
+/// PIXEL DRAWING
+int (graph_set_pixel)      (uint16_t x, uint16_t y, uint32_t color);
+int (graph_set_pixel_alpha)(uint16_t x, uint16_t y, uint32_t color, uint8_t alpha);
 
-int (vbe_get_controller_information)(vg_vbe_contr_info_t *info_p);
+/// SCREEN
+int (graph_clear_screen)(void);
 
-phys_bytes (graph_get_phys_addr)    (void);
-unsigned   (graph_get_vram_size)    (void);
-uint16_t   (graph_get_XRes)         (void);
-uint16_t   (graph_get_YRes)         (void);
-uint16_t   (graph_get_bits_pixel)   (void);
-uint16_t   (graph_get_bytes_pixel)  (void);
-uint16_t   (graph_get_RedMaskSize)  (void);
-uint16_t   (graph_get_GreenMaskSize)(void);
-uint16_t   (graph_get_BlueMaskSize) (void);
+/// DRAW
+int (graph_draw)(void);
 
-int (graph_map_vram)(void);
 
-int (graph_free_memory)(void);
 
-int (graph_set_pixel)      (uint16_t x, uint16_t y, uint32_t color);
-int (graph_set_pixel_alpha)(uint16_t x, uint16_t y, uint32_t color, uint8_t alpha);
+/// RECTANGLE
 
-/**
- * @brief
- * @param mode
- * @return
- */
-int (graph_set_mode)(uint16_t mode);
 
 int (graph_draw_hline)(uint16_t x, uint16_t y, uint16_t len, uint32_t color);
-
 int (graph_draw_rectangle)(uint16_t x, uint16_t y,uint16_t width, uint16_t height, uint32_t color);
 
-int (graph_paint_screen)(uint32_t color);
-
-int (graph_clear_screen)(void);
-
-int (graph_draw)(void);
-
 #endif /* end of include guard: GRAPH_H_INCLUDED */
Index: proj/proj.c
===================================================================
--- proj/proj.c	(revision 173)
+++ proj/proj.c	(revision 174)
@@ -63,29 +63,28 @@
     }
 
     #ifdef DIOGO
-        printf("%d\n", 1000000-(int)(1000000*fm_sin(0.5*M_PI)));
-        printf("%d\n", (int)(1000000*fm_cos(0.5*M_PI)));
-
+        //printf("%d\n", 1000000-(int)(1000000*fm_sin(0.5*M_PI)));
+        //printf("%d\n", (int)(1000000*fm_cos(0.5*M_PI)));
+        /*
         clock_t t = clock();
         sprite_t *shooter1 = get_shooter(); sprite_set_pos(shooter1, 100, 100);
         for(double angle = 0; angle <= 6.283185; angle += 0.006283185){
              sprite_set_angle(shooter1, angle);
-             //graph_paint_screen(0x777777);
              graph_clear_screen();
              sprite_draw(shooter1);
              graph_draw();
         }
-        t = clock() - t; //printf("%d\n", CLOCKS_PER_SEC);
-        //double dt = ((double)t)/(double)CLOCKS_PER_SEC;
+        t = clock() - t;
         printf("Time taken: %d/%d \n", t, CLOCKS_PER_SEC);
         sprite_dtor(shooter1);
+        */
     #endif
 
     #ifdef TELMO
-    sprite_t *crosshair = get_crosshair();
-    graph_clear_screen();
-    sprite_draw(crosshair);
-    graph_draw();
+        sprite_t *crosshair = get_crosshair();
+        graph_clear_screen();
+        sprite_draw(crosshair);
+        graph_draw();
     #endif
 
     /// loop stuff
@@ -132,23 +131,24 @@
         } 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;
-        }
+        #ifdef TELMO
+            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;
+            }
+        #endif
     }
 
     // Unsubscribe interrupts
