Index: proj/include/xpm_utils.h
===================================================================
--- proj/include/xpm_utils.h	(revision 278)
+++ proj/include/xpm_utils.h	(nonexistent)
@@ -1,8 +0,0 @@
-#ifndef XMP_UTILS_H_INCLUDED
-#define XMP_UTILS_H_INCLUDED
-
-void xpm_save_as_xpm2(const char **p, const char *s);
-
-char** xpm_load_xpm2(const char *s);
-
-#endif //XMP_UTILS_H_INCLUDED

Property changes on: proj/include/xpm_utils.h
___________________________________________________________________
Deleted: svn:executable
## -1 +0,0 ##
-*
\ No newline at end of property
Index: proj/include/fast_math.h
===================================================================
--- proj/include/fast_math.h	(revision 278)
+++ proj/include/fast_math.h	(nonexistent)
@@ -1,7 +0,0 @@
-#ifndef FAST_MATH_H_INCLUDED
-#define FAST_MATH_H_INCLUDED
-
-double fm_sin(double x);
-double fm_cos(double x);
-
-#endif //FAST_MATH_H_INCLUDED

Property changes on: proj/include/fast_math.h
___________________________________________________________________
Deleted: svn:executable
## -1 +0,0 ##
-*
\ No newline at end of property
Index: proj/include/utils.h
===================================================================
--- proj/include/utils.h	(revision 278)
+++ proj/include/utils.h	(nonexistent)
@@ -1,75 +0,0 @@
-#ifndef UTILS_H_INCLUDED
-#define UTILS_H_INCLUDED
-
-#define BCD_FIRST(n)     (n >> 4)       /** @brief Get first digit (leftmost digit) of 8-bit BCD */
-#define BCD_SECOND(n)    (n & 0x0F)     /** @brief Get second digit (rightmost digit) of 8-bit BCD */
-
-/**
- * @brief Gets the least significant byte of a 16-bit variable
- * @param val 16-bit variable
- * @param lsb Pointer to a 8-bit variable to store the value of the LSB
- * @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
- */
-int(util_get_LSB)(uint16_t val, uint8_t *lsb);
-
-/**
- * @brief Gets the most significant byte of a 16-bit variable
- * @param val 16-bit variable
- * @param lsb Pointer to a 8-bit variable to store the value of the MSB
- * @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
- */
-int(util_get_MSB)(uint16_t val, uint8_t *msb);
-
-/**
- * @brief sys_inb wrapper
- * @param port Port to read from
- * @param value Pointer to byte to store value read
- * @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
- */
-int (util_sys_inb)(int port, uint8_t *value);
-
-/**
- * @brief Unsubcribes Interrupts
- * @param interrupt_id Interrupt ID, value via arguments on subscription of the interrupt_id
- * @see subscribe_kbc_interrupt, subscribe_timer_interrupt
- * @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
- */
-int (unsubscribe_interrupt)(int *interrupt_id);
-
-/**
- * @brief Gets the minimum value out of two values.
- * @param a     First value
- * @param b     Second value
- * @return  The minimum of the two values
- */
-int32_t min(int32_t a, int32_t b);
-
-/**
- * @brief Gets the maximum value out of two values.
- * @param a     First value
- * @param b     Second value
- * @return  The maximum of the two values
- */
-int32_t max(int32_t a, int32_t b);
-
-/**
- * @brief Gets the minimum value out of two doubles.
- * @param a     First value
- * @param b     Second value
- * @return  The minimum of the two values
- */
-double min_d(double a, double b);
-
-/**
- * @brief Gets the maximum value out of two doubles.
- * @param a     First value
- * @param b     Second value
- * @return  The maximum of the two values
- */
-double max_d(double a, double b);
-
-
-double abs_d(double a);
-
-
-#endif //UTILS_H_INCLUDED

Property changes on: proj/include/utils.h
___________________________________________________________________
Deleted: svn:executable
Index: proj/include/graph.h
===================================================================
--- proj/include/graph.h	(revision 278)
+++ proj/include/graph.h	(nonexistent)
@@ -1,53 +0,0 @@
-#ifndef GRAPH_H_INCLUDED
-#define GRAPH_H_INCLUDED
-
-// Graphics modes
-#define INDEXED_1024_768        0x105
-#define DIRECT_640_480_888      0x110
-#define DIRECT_800_600_888      0x115
-#define DIRECT_1024_768_888     0x118
-#define DIRECT_1280_1024_565    0x11A
-#define DIRECT_1280_1024_888    0x11B
-#define LINEAR_FRAME_BUFFER_MD  BIT(14)
-
-// Colors in RBG (8 bit)
-#define GRAPH_BLACK               0x000000
-#define GRAPH_WHITE               0xFFFFFF
-
-// Alpha
-#define ALPHA_THRESHOLD     0x7F
-
-/// 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 GET_COLOR(n)        (0xFFFFFF & (n))
-#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))
-
-/// PUBLIC GET
-uint16_t   (graph_get_XRes)         (void);
-uint16_t   (graph_get_YRes)         (void);
-uint16_t   (graph_get_bytes_pixel)  (void);
-
-/// INIT
-int (graph_init)(uint16_t mode);
-
-/// CLEANUP
-int (graph_cleanup)(void);
-
-/// PIXEL DRAWING
-int (graph_set_pixel)             (uint16_t x, uint16_t y, uint32_t color);
-void (graph_set_pixel_pos)         (unsigned pos          , uint32_t color);
-
-/// SCREEN
-int (graph_clear_screen)(void);
-
-/// DRAW
-int (graph_draw)(void);
-
-#endif /* end of include guard: GRAPH_H_INCLUDED */

Property changes on: proj/include/graph.h
___________________________________________________________________
Deleted: svn:executable
## -1 +0,0 ##
-*
\ No newline at end of property
Index: proj/src/graph.c
===================================================================
--- proj/src/graph.c	(revision 278)
+++ proj/src/graph.c	(nonexistent)
@@ -1,432 +0,0 @@
-#include <lcom/lcf.h>
-
-#include "graph.h"
-
-#include "errors.h"
-#include <stdio.h>
-
-#define VC_BIOS_SERV  0x10 /** @brief Interrupt service of video card */
-#define VBE_CALL      0x4F /** @brief VBE call function specifier */
-
-#define MBYTE_BASE  0x0         /** @brief Base address (zero address) */
-#define MBYTE_SIZE  0xFFFFF     /** @brief Size of a mebibyte */
-
-// Graphics Functions
-#define VBE_CTRL_INFO       0x00    /** @brief Get VBE Controller Information */
-#define VBE_MD_INFO         0x01    /** @brief Get VBE Mode Information */
-#define SET_VBE_MD          0x02    /** @brief Set VBE Mode */
-
-// Error codes (AH)
-#define AH_SUCCESS          0x00    /** @brief Success code on BIOS call */
-#define AH_FUNC_CALL_FAIL   0x01    /** @brief Function call failed */
-#define AH_FUNC_NOT_SUPP    0x02    /** @brief Function call is not supported in current HW configuration */
-#define AH_FUNC_INVALID     0x03    /** @brief Invalid function in current video mode */
-
-/// 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;
-
-/// PRIVATE GET
-static uint16_t   (graph_get_bits_pixel)   (void){ return vbe_mem_info.BitsPerPixel; }
-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 ; }
-
-/// PUBLIC GET
-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_bytes_pixel)  (void){ return (graph_get_bits_pixel() + 7) >> 3; }
-
-///
-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;
-    return sys_privctl(SELF, SYS_PRIV_ADD_MEM, &mmr);
-}
-
-//static int (get_permissions_first_mbyte)(void) {
-//    return get_permission(MBYTE_BASE, MBYTE_SIZE);
-//}
-
-/// MEMORY
-static uint8_t *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);
-    }
-
-    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;
-}
-
-/// 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;
-    memset(&reg_86, 0, sizeof(struct reg86)); // reset struct
-
-    vbe_mode_info_t *virtual_addr = lm_alloc(sizeof(vbe_mode_info_t), &mem_map);
-
-    reg_86.intno = VC_BIOS_SERV;
-    reg_86.ah = VBE_CALL;
-    reg_86.al = VBE_MD_INFO;
-    reg_86.cx = mode;
-    reg_86.es = PB2BASE(mem_map.phys);
-    reg_86.di = PB2OFF(mem_map.phys);
-    // BIOS CALL
-    if (sys_int86(&reg_86) || reg_86.ah != AH_SUCCESS) {
-        printf("%s: sys_int86 failed\n", __func__);
-        if (graph_free_memory()) {
-            printf("%s: lm_free failed\n", __func__);
-        }
-        return BIOS_CALL_ERROR;
-    }
-
-    memcpy((void*)&vbe_mem_info, (void*)virtual_addr, mem_map.size);
-    return SUCCESS;
-}
-/*
-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;
-
-    struct reg86 reg_86;
-    memset(&reg_86, 0, sizeof(struct reg86)); // reset struct
-
-    VbeInfoBlock *virtual_addr = lm_alloc(sizeof(VbeInfoBlock), &controller_map);
-
-    uint32_t virtual_base = (uint32_t)(virtual_addr) - controller_map.phys;
-
-    virtual_addr->VbeSignature[0] = 'V';
-    virtual_addr->VbeSignature[1] = 'B';
-    virtual_addr->VbeSignature[2] = 'E';
-    virtual_addr->VbeSignature[3] = '2';
-
-
-    reg_86.intno = VC_BIOS_SERV;
-    reg_86.ah = VBE_CALL;
-    reg_86.al = VBE_CTRL_INFO;
-    reg_86.es = PB2BASE(controller_map.phys);
-    reg_86.di = PB2OFF(controller_map.phys);
-    // BIOS CALL
-    if (sys_int86(&reg_86) || reg_86.ah != AH_SUCCESS) {
-        printf("%s: sys_int86 failed\n", __func__);
-        if (!lm_free(&controller_map)) {
-            printf("%s: lm_free failed\n", __func__);
-        }
-        return BIOS_CALL_ERROR;
-    }
-
-    info_p->VBESignature[0] = virtual_addr->VbeSignature[0];
-    info_p->VBESignature[1] = virtual_addr->VbeSignature[1];
-    info_p->VBESignature[2] = virtual_addr->VbeSignature[2];
-    info_p->VBESignature[3] = virtual_addr->VbeSignature[3];
-
-    uint8_t lsb, msb;
-    util_get_LSB(virtual_addr->VbeVersion, &lsb);
-    util_get_MSB(virtual_addr->VbeVersion, &msb);
-    info_p->VBEVersion[0] = lsb;
-    info_p->VBEVersion[1] = msb;
-
-    info_p->TotalMemory = (virtual_addr->TotalMemory << 6);
-
-    // Convert Far Far Pointer to Virtual Address
-
-    uint32_t phys_ptr = FAR2PHYS(virtual_addr->OemStringPtr);
-    uint32_t virtual_ptr = phys_ptr + virtual_base;
-    info_p->OEMString = (char*)(virtual_ptr);
-
-    phys_ptr = FAR2PHYS(virtual_addr->VideoModePtr);
-    virtual_ptr = phys_ptr + virtual_base;
-    info_p->VideoModeList = (uint16_t*)(virtual_ptr);
-
-    phys_ptr = FAR2PHYS(virtual_addr->OemVendorNamePtr);
-    virtual_ptr = phys_ptr + virtual_base;
-    info_p->OEMVendorNamePtr = (char*)(virtual_ptr);
-
-    phys_ptr = FAR2PHYS(virtual_addr->OemProductNamePtr);
-    virtual_ptr = phys_ptr + virtual_base;
-    info_p->OEMProductNamePtr = (char*)(virtual_ptr);
-
-    phys_ptr = FAR2PHYS(virtual_addr->OemProductRevPtr);
-    virtual_ptr = phys_ptr + virtual_base;
-    info_p->OEMProductRevPtr = (char*)(virtual_ptr);
-
-    if (!lm_free(&controller_map)) {
-        printf("%s: lm_free failed\n", __func__);
-        return LCF_ERROR;
-    }
-
-    return SUCCESS;
-}
-*/
-
-/// 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
-
-    // Set Reg86
-    reg_86.intno = VC_BIOS_SERV;
-    reg_86.ah = VBE_CALL;
-    reg_86.al = SET_VBE_MD;
-    reg_86.bx = mode | LINEAR_FRAME_BUFFER_MD;
-
-    // BIOS CALL
-    if (sys_int86(&reg_86) || reg_86.ah != AH_SUCCESS) {
-        printf("%s: sys_int86 failed\n", __func__);
-        return BIOS_CALL_ERROR;
-    }
-
-    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) {
-    //pixels are certain to be inside can reduce lag
-    /*if (x < 0 || vbe_mem_info.XResolution <= x || y < 0 || vbe_mem_info.YResolution <= y) {
-        //printf("%s: invalid pixel.\n", __func__);
-        return OUT_OF_RANGE;
-    }*/
-    unsigned int pos = (x + y * vbe_mem_info.XResolution) * 3/*graph_get_bytes_pixel()*/;
-    memcpy(video_buf + pos, &color, 3/*graph_get_bytes_pixel()*/);
-    return SUCCESS;
-}
-void (graph_set_pixel_pos)(unsigned pos, uint32_t color){
-    memcpy(video_buf + pos, &color, graph_get_bytes_pixel());
-}
-int (graph_clear_screen)(void){ memset(video_buf, 0, graph_get_vram_size()); return SUCCESS; }
-int (graph_draw)(void){ memcpy(video_mem, video_buf, graph_get_vram_size()); return SUCCESS; }
-
-///SPRITE
-#include "sprite.h"
-
-#include "utils.h"
-#include "fast_math.h"
-#include <math.h>
-
-struct basic_sprite{
-    uint8_t *map;
-    uint16_t w, h;
-    int16_t u0, v0;
-};
-basic_sprite_t* (basic_sprite_ctor)(const char **xpm, int16_t u0, int16_t v0){
-    basic_sprite_t *ret = malloc(sizeof(basic_sprite_t));
-    if(ret == NULL) return NULL;
-    enum xpm_image_type type = XPM_8_8_8_8;
-    xpm_image_t img;
-    ret->map = xpm_load((xpm_map_t)xpm, type, &img);
-    if(ret->map == NULL){
-        basic_sprite_dtor(ret);
-        return NULL;
-    }
-    ret->w = img.width;
-    ret->h = img.height;
-    ret->u0 = u0;
-    ret->v0 = v0;
-    return ret;
-}
-void (basic_sprite_dtor)(basic_sprite_t *p){
-    if(p == NULL) return;
-    free(p->map);
-    free(p);
-}
-const uint8_t* (basic_sprite_get_map)(const basic_sprite_t *p){ return p->map; }
-uint16_t       (basic_sprite_get_w)  (const basic_sprite_t *p){ return p->w  ; }
-uint16_t       (basic_sprite_get_h)  (const basic_sprite_t *p){ return p->h  ; }
-int16_t        (basic_sprite_get_u0) (const basic_sprite_t *p){ return p->u0 ; }
-int16_t        (basic_sprite_get_v0) (const basic_sprite_t *p){ return p->v0 ; }
-
-/*
-struct basic_sprite_alpha{
-    uint8_t *map;
-    uint16_t w, h;
-    int16_t u0, v0;
-};
-basic_sprite_alpha_t* (basic_sprite_alpha_ctor)(const char **xpm, int16_t u0, int16_t v0){
-    basic_sprite_alpha_t *ret = malloc(sizeof(basic_sprite_t));
-    if(ret == NULL) return NULL;
-    enum xpm_image_type type = XPM_8_8_8_8;
-    xpm_image_t img;
-    ret->map = NULL;
-    uint8_t *m = xpm_load((xpm_map_t)xpm, type, &img);
-    if(m == NULL){
-        basic_sprite_alpha_dtor(ret);
-        return NULL;
-    }
-    ret->map = m;
-    if(ret->map == NULL){
-        basic_sprite_alpha_dtor(ret);
-        return NULL;
-    }
-    ret->w = img.width;
-    ret->h = img.height;
-    ret->u0 = u0;
-    ret->v0 = v0;
-    return ret;
-}
-void (basic_sprite_alpha_dtor)(basic_sprite_alpha_t *p){
-    if(p == NULL) return;
-    free(p->map);
-    free(p);
-}
-const uint8_t* (basic_sprite_alpha_get_map)(const basic_sprite_alpha_t *p){ return p->map; }
-uint16_t       (basic_sprite_alpha_get_w)  (const basic_sprite_alpha_t *p){ return p->w  ; }
-uint16_t       (basic_sprite_alpha_get_h)  (const basic_sprite_alpha_t *p){ return p->h  ; }
-int16_t        (basic_sprite_alpha_get_u0) (const basic_sprite_alpha_t *p){ return p->u0 ; }
-int16_t        (basic_sprite_alpha_get_v0) (const basic_sprite_alpha_t *p){ return p->v0 ; }
-*/
-
-struct sprite{
-    const basic_sprite_t *bsp;
-    int16_t x, y; //position in screen
-    double theta, s, c;
-    double scale;
-};
-sprite_t* (sprite_ctor)(const basic_sprite_t *bsp){
-    sprite_t *ret = malloc(sizeof(sprite_t));
-    if(ret == NULL) return NULL;
-    ret->bsp = bsp;
-    ret->x = 0;
-    ret->y = 0;
-    sprite_set_angle(ret, 0.0);
-    ret->scale = 1.0;
-    return ret;
-}
-void (sprite_dtor)(sprite_t *p){
-    if(p == NULL) return;
-    free(p);
-}
-void (sprite_set_pos)   (sprite_t *p, int16_t x , int16_t y ){ p->x = x; p->y = y; }
-void (sprite_set_angle) (sprite_t *p, double angle          ){ p->theta = angle; p->c = fm_cos(p->theta); p->s = fm_sin(p->theta); }
-void (sprite_set_scale) (sprite_t *p, double scale          ){ p->scale = scale; }
-int16_t  (sprite_get_x)(const sprite_t *p){ return p->x; }
-int16_t  (sprite_get_y)(const sprite_t *p){ return p->y; }
-double   (sprite_get_angle)(const sprite_t *p){ return p->theta; }
-uint16_t (sprite_get_w)(const sprite_t *p){ return basic_sprite_get_w(p->bsp); }
-uint16_t (sprite_get_h)(const sprite_t *p){ return basic_sprite_get_h(p->bsp); }
-void (sprite_src2pic)(const sprite_t *p, int16_t x, int16_t y, int16_t *u, int16_t *v){
-    double dx = (x - p->x)/p->scale;
-    double dy = (y - p->y)/p->scale;
-    int16_t du = dx*p->c - dy*p->s - 0.5;
-    int16_t dv = dx*p->s + dy*p->c - 0.5;
-    *u = du + basic_sprite_get_u0(p->bsp);
-    *v = dv + basic_sprite_get_v0(p->bsp);
-}
-void (sprite_pic2src)(const sprite_t *p, int16_t u, int16_t v, int16_t *x, int16_t *y){
-    int16_t du = u - basic_sprite_get_u0(p->bsp);
-    int16_t dv = v - basic_sprite_get_v0(p->bsp);
-    double dx =  du*p->c + dv*p->s;
-    double dy = -du*p->s + dv*p->c;
-    *x = dx*p->scale + 0.5 + p->x;
-    *y = dy*p->scale + 0.5 + p->y;
-}
-void (sprite_draw)(const sprite_t *p){
-    const uint16_t w = basic_sprite_get_w(p->bsp);
-    const uint16_t h = basic_sprite_get_h(p->bsp);
-    int16_t xmin, xmax, ymin, ymax; {
-        int16_t x, y;
-        sprite_pic2src(p, 0, 0, &x, &y);
-        xmin = x; xmax = x; ymin = y; ymax = y;
-        sprite_pic2src(p, w, 0, &x, &y);
-        xmin = min(x, xmin); xmax = max(x, xmax); ymin = min(y, ymin); ymax = max(y, ymax);
-        sprite_pic2src(p, 0, h, &x, &y);
-        xmin = min(x, xmin); xmax = max(x, xmax); ymin = min(y, ymin); ymax = max(y, ymax);
-        sprite_pic2src(p, w, h, &x, &y);
-        xmin = min(x, xmin); xmax = max(x, xmax); ymin = min(y, ymin); ymax = max(y, ymax);
-        xmin = max(xmin-(int16_t)p->scale-2, 0); xmax = min(xmax+(int16_t)p->scale+2, graph_get_XRes());
-        ymin = max(ymin-(int16_t)p->scale-2, 0); ymax = min(ymax+(int16_t)p->scale+2, graph_get_YRes());
-    }
-    const uint8_t *map = basic_sprite_get_map(p->bsp);
-    const uint16_t bytes_pixel = 3/*graph_get_bytes_pixel()*/;
-    for(int16_t u, v, y = ymin; y < ymax; ++y){
-        uint8_t *place = video_buf + (xmin + y*graph_get_XRes())*bytes_pixel;
-        for(int16_t x = xmin; x < xmax; ++x, place += bytes_pixel){
-            sprite_src2pic(p, x, y, &u, &v);
-            if(0 <= u && u < w && 0 <= v && v < h){
-                const uint8_t *c_p = map+(v*w+u)*4;
-                if(*(c_p+3) < ALPHA_THRESHOLD) //alpha
-                    memcpy(place, c_p, bytes_pixel);
-            }
-        }
-    }
-}

Property changes on: proj/src/graph.c
___________________________________________________________________
Deleted: svn:executable
## -1 +0,0 ##
-*
\ No newline at end of property
Index: proj/src/fast_math.c
===================================================================
--- proj/src/fast_math.c	(revision 278)
+++ proj/src/fast_math.c	(nonexistent)
@@ -1,30 +0,0 @@
-#include <lcom/lcf.h>
-
-#include "fast_math.h"
-#include "utils.h"
-
-#include <math.h>
-
-double fm_sin(double x){
-    if(x < 0.0)         return -fm_sin(-x);
-    if(x > 2.0*M_PI) return fm_sin(x-2.0*M_PI);
-    if(x > M_PI)      return -fm_sin(x-M_PI);
-    if(x > 0.5*M_PI) x = M_PI - x;
-    double x2 = x*x;
-    double x3 = x*x2;
-    double x5 = x3*x2;
-    //double x7 = x5*x2;
-    return x-x3*0.1666666666666666666666+x5*0.008333333333333333333333;//-x7*0.0001984126984127;
-}
-
-double fm_cos(double x){
-    if(x < 0.0)         x = -x;
-    if(x > 2.0*M_PI) return fm_cos(x-2.0*M_PI);
-    if(x > M_PI)      x = 2.0*M_PI-x;
-    if(x > 0.5*M_PI) return -fm_cos(M_PI-x);
-    double x2 = x*x;
-    double x4 = x2*x2;
-    double x6 = x4*x2;
-    //double x8 = x4*x4;
-    return 1.0-x2*0.5+x4*0.041666666666666666666666-x6*0.0013888888888888888888888;//+x8*0.000024801587;
-}

Property changes on: proj/src/fast_math.c
___________________________________________________________________
Deleted: svn:executable
## -1 +0,0 ##
-*
\ No newline at end of property
Index: proj/src/xpm_utils.c
===================================================================
--- proj/src/xpm_utils.c	(revision 278)
+++ proj/src/xpm_utils.c	(nonexistent)
@@ -1,52 +0,0 @@
-#ifdef LCOM_MACRO
-    #include <lcom/lcf.h>
-#endif
-
-#include "xpm_utils.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-void xpm_save_as_xpm2(const char **p, const char *s){
-    FILE *f = fopen(s, "w");
-    int w, h, num_colors, chars_per_pixel;
-    sscanf(p[0], "%d %d %d %d", &w, &h, &num_colors, &chars_per_pixel);
-    for(int i = 0; i < 1+num_colors+h; ++i){
-        fprintf(f, "%s\n", p[i]);
-    }
-    fclose(f); f = NULL;
-}
-
-char** xpm_load_xpm2(const char *fpath){
-    FILE *f = fopen(fpath, "r");
-    if(f == NULL) return NULL;
-    size_t len = 1024; char *line_buf = malloc(len*sizeof(char));
-    int sz;
-
-    char **ret = NULL;
-
-    int w, h, num_colors, chars_per_pixel;
-
-    sz = getline(&line_buf, &len, f);{
-        sscanf(line_buf, "%d %d %d %d", &w, &h, &num_colors, &chars_per_pixel);
-        ret = malloc((1+num_colors+h)*sizeof(char*));
-    }
-    ret[0] = malloc((sz+1)*sizeof(char)); if(ret[0] == NULL){ free(ret); return NULL; }
-    strcpy(ret[0], line_buf);
-
-    for(int i = 1; i < 1+num_colors+h; ++i){
-        sz = getline(&line_buf, &len, f);
-        ret[i] = malloc((sz+1)*sizeof(char));
-        if(ret[i] == NULL){
-            for(int j = 0; j < i; ++j)
-                free(ret[i]);
-            free(ret);
-            return NULL;
-        }
-        strcpy(ret[i], line_buf);
-        ret[i][sz-1] = '\0';
-    }
-    fclose(f); f = NULL;
-    return ret;
-}

Property changes on: proj/src/xpm_utils.c
___________________________________________________________________
Deleted: svn:executable
## -1 +0,0 ##
-*
\ No newline at end of property
Index: proj/src/utils.c
===================================================================
--- proj/src/utils.c	(revision 278)
+++ proj/src/utils.c	(nonexistent)
@@ -1,39 +0,0 @@
-#include <lcom/lcf.h>
-
-#include "utils.h"
-
-#include <stdint.h>
-#include "errors.h"
-
-int(util_get_LSB)(uint16_t val, uint8_t *lsb) {
-    if (lsb == NULL) return NULL_PTR;
-    *lsb = val;
-    return SUCCESS;
-}
-
-int(util_get_MSB)(uint16_t val, uint8_t *msb) {
-    if (msb == NULL) return NULL_PTR;
-    *msb = (val >> 8);
-    return SUCCESS;
-}
-
-int (util_sys_inb)(int port, uint8_t *value) {
-    if(value == NULL) return NULL_PTR;
-    uint32_t n = 0;
-    if(sys_inb(port, &n)) return READ_ERROR;
-    *value = n;
-    return SUCCESS;
-}
-
-int (unsubscribe_interrupt)(int *interrupt_id) {
-    if (interrupt_id == NULL) return NULL_PTR;
-    if(sys_irqrmpolicy(interrupt_id)) return UNSBCR_ERROR;
-    return SUCCESS;
-}
-
-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); }
-
-double min_d(double a, double b){ return (b < a ? b : a); }
-double max_d(double a, double b){ return (a < b ? b : a); }
-double abs_d(double a)          { return (a < 0 ? -a: a); }

Property changes on: proj/src/utils.c
___________________________________________________________________
Deleted: svn:executable
Index: proj/libs/peripherals/include/graph.h
===================================================================
--- proj/libs/peripherals/include/graph.h	(nonexistent)
+++ proj/libs/peripherals/include/graph.h	(revision 279)
@@ -0,0 +1,53 @@
+#ifndef GRAPH_H_INCLUDED
+#define GRAPH_H_INCLUDED
+
+// Graphics modes
+#define INDEXED_1024_768        0x105
+#define DIRECT_640_480_888      0x110
+#define DIRECT_800_600_888      0x115
+#define DIRECT_1024_768_888     0x118
+#define DIRECT_1280_1024_565    0x11A
+#define DIRECT_1280_1024_888    0x11B
+#define LINEAR_FRAME_BUFFER_MD  BIT(14)
+
+// Colors in RBG (8 bit)
+#define GRAPH_BLACK               0x000000
+#define GRAPH_WHITE               0xFFFFFF
+
+// Alpha
+#define ALPHA_THRESHOLD     0x7F
+
+/// 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 GET_COLOR(n)        (0xFFFFFF & (n))
+#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))
+
+/// PUBLIC GET
+uint16_t   (graph_get_XRes)         (void);
+uint16_t   (graph_get_YRes)         (void);
+uint16_t   (graph_get_bytes_pixel)  (void);
+
+/// INIT
+int (graph_init)(uint16_t mode);
+
+/// CLEANUP
+int (graph_cleanup)(void);
+
+/// PIXEL DRAWING
+int (graph_set_pixel)             (uint16_t x, uint16_t y, uint32_t color);
+void (graph_set_pixel_pos)         (unsigned pos          , uint32_t color);
+
+/// SCREEN
+int (graph_clear_screen)(void);
+
+/// DRAW
+int (graph_draw)(void);
+
+#endif /* end of include guard: GRAPH_H_INCLUDED */

Property changes on: proj/libs/peripherals/include/graph.h
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: proj/libs/peripherals/src/graph.c
===================================================================
--- proj/libs/peripherals/src/graph.c	(nonexistent)
+++ proj/libs/peripherals/src/graph.c	(revision 279)
@@ -0,0 +1,432 @@
+#include <lcom/lcf.h>
+
+#include "graph.h"
+
+#include "errors.h"
+#include <stdio.h>
+
+#define VC_BIOS_SERV  0x10 /** @brief Interrupt service of video card */
+#define VBE_CALL      0x4F /** @brief VBE call function specifier */
+
+#define MBYTE_BASE  0x0         /** @brief Base address (zero address) */
+#define MBYTE_SIZE  0xFFFFF     /** @brief Size of a mebibyte */
+
+// Graphics Functions
+#define VBE_CTRL_INFO       0x00    /** @brief Get VBE Controller Information */
+#define VBE_MD_INFO         0x01    /** @brief Get VBE Mode Information */
+#define SET_VBE_MD          0x02    /** @brief Set VBE Mode */
+
+// Error codes (AH)
+#define AH_SUCCESS          0x00    /** @brief Success code on BIOS call */
+#define AH_FUNC_CALL_FAIL   0x01    /** @brief Function call failed */
+#define AH_FUNC_NOT_SUPP    0x02    /** @brief Function call is not supported in current HW configuration */
+#define AH_FUNC_INVALID     0x03    /** @brief Invalid function in current video mode */
+
+/// 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;
+
+/// PRIVATE GET
+static uint16_t   (graph_get_bits_pixel)   (void){ return vbe_mem_info.BitsPerPixel; }
+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 ; }
+
+/// PUBLIC GET
+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_bytes_pixel)  (void){ return (graph_get_bits_pixel() + 7) >> 3; }
+
+///
+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;
+    return sys_privctl(SELF, SYS_PRIV_ADD_MEM, &mmr);
+}
+
+//static int (get_permissions_first_mbyte)(void) {
+//    return get_permission(MBYTE_BASE, MBYTE_SIZE);
+//}
+
+/// MEMORY
+static uint8_t *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);
+    }
+
+    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;
+}
+
+/// 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;
+    memset(&reg_86, 0, sizeof(struct reg86)); // reset struct
+
+    vbe_mode_info_t *virtual_addr = lm_alloc(sizeof(vbe_mode_info_t), &mem_map);
+
+    reg_86.intno = VC_BIOS_SERV;
+    reg_86.ah = VBE_CALL;
+    reg_86.al = VBE_MD_INFO;
+    reg_86.cx = mode;
+    reg_86.es = PB2BASE(mem_map.phys);
+    reg_86.di = PB2OFF(mem_map.phys);
+    // BIOS CALL
+    if (sys_int86(&reg_86) || reg_86.ah != AH_SUCCESS) {
+        printf("%s: sys_int86 failed\n", __func__);
+        if (graph_free_memory()) {
+            printf("%s: lm_free failed\n", __func__);
+        }
+        return BIOS_CALL_ERROR;
+    }
+
+    memcpy((void*)&vbe_mem_info, (void*)virtual_addr, mem_map.size);
+    return SUCCESS;
+}
+/*
+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;
+
+    struct reg86 reg_86;
+    memset(&reg_86, 0, sizeof(struct reg86)); // reset struct
+
+    VbeInfoBlock *virtual_addr = lm_alloc(sizeof(VbeInfoBlock), &controller_map);
+
+    uint32_t virtual_base = (uint32_t)(virtual_addr) - controller_map.phys;
+
+    virtual_addr->VbeSignature[0] = 'V';
+    virtual_addr->VbeSignature[1] = 'B';
+    virtual_addr->VbeSignature[2] = 'E';
+    virtual_addr->VbeSignature[3] = '2';
+
+
+    reg_86.intno = VC_BIOS_SERV;
+    reg_86.ah = VBE_CALL;
+    reg_86.al = VBE_CTRL_INFO;
+    reg_86.es = PB2BASE(controller_map.phys);
+    reg_86.di = PB2OFF(controller_map.phys);
+    // BIOS CALL
+    if (sys_int86(&reg_86) || reg_86.ah != AH_SUCCESS) {
+        printf("%s: sys_int86 failed\n", __func__);
+        if (!lm_free(&controller_map)) {
+            printf("%s: lm_free failed\n", __func__);
+        }
+        return BIOS_CALL_ERROR;
+    }
+
+    info_p->VBESignature[0] = virtual_addr->VbeSignature[0];
+    info_p->VBESignature[1] = virtual_addr->VbeSignature[1];
+    info_p->VBESignature[2] = virtual_addr->VbeSignature[2];
+    info_p->VBESignature[3] = virtual_addr->VbeSignature[3];
+
+    uint8_t lsb, msb;
+    util_get_LSB(virtual_addr->VbeVersion, &lsb);
+    util_get_MSB(virtual_addr->VbeVersion, &msb);
+    info_p->VBEVersion[0] = lsb;
+    info_p->VBEVersion[1] = msb;
+
+    info_p->TotalMemory = (virtual_addr->TotalMemory << 6);
+
+    // Convert Far Far Pointer to Virtual Address
+
+    uint32_t phys_ptr = FAR2PHYS(virtual_addr->OemStringPtr);
+    uint32_t virtual_ptr = phys_ptr + virtual_base;
+    info_p->OEMString = (char*)(virtual_ptr);
+
+    phys_ptr = FAR2PHYS(virtual_addr->VideoModePtr);
+    virtual_ptr = phys_ptr + virtual_base;
+    info_p->VideoModeList = (uint16_t*)(virtual_ptr);
+
+    phys_ptr = FAR2PHYS(virtual_addr->OemVendorNamePtr);
+    virtual_ptr = phys_ptr + virtual_base;
+    info_p->OEMVendorNamePtr = (char*)(virtual_ptr);
+
+    phys_ptr = FAR2PHYS(virtual_addr->OemProductNamePtr);
+    virtual_ptr = phys_ptr + virtual_base;
+    info_p->OEMProductNamePtr = (char*)(virtual_ptr);
+
+    phys_ptr = FAR2PHYS(virtual_addr->OemProductRevPtr);
+    virtual_ptr = phys_ptr + virtual_base;
+    info_p->OEMProductRevPtr = (char*)(virtual_ptr);
+
+    if (!lm_free(&controller_map)) {
+        printf("%s: lm_free failed\n", __func__);
+        return LCF_ERROR;
+    }
+
+    return SUCCESS;
+}
+*/
+
+/// 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
+
+    // Set Reg86
+    reg_86.intno = VC_BIOS_SERV;
+    reg_86.ah = VBE_CALL;
+    reg_86.al = SET_VBE_MD;
+    reg_86.bx = mode | LINEAR_FRAME_BUFFER_MD;
+
+    // BIOS CALL
+    if (sys_int86(&reg_86) || reg_86.ah != AH_SUCCESS) {
+        printf("%s: sys_int86 failed\n", __func__);
+        return BIOS_CALL_ERROR;
+    }
+
+    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) {
+    //pixels are certain to be inside can reduce lag
+    /*if (x < 0 || vbe_mem_info.XResolution <= x || y < 0 || vbe_mem_info.YResolution <= y) {
+        //printf("%s: invalid pixel.\n", __func__);
+        return OUT_OF_RANGE;
+    }*/
+    unsigned int pos = (x + y * vbe_mem_info.XResolution) * 3/*graph_get_bytes_pixel()*/;
+    memcpy(video_buf + pos, &color, 3/*graph_get_bytes_pixel()*/);
+    return SUCCESS;
+}
+void (graph_set_pixel_pos)(unsigned pos, uint32_t color){
+    memcpy(video_buf + pos, &color, graph_get_bytes_pixel());
+}
+int (graph_clear_screen)(void){ memset(video_buf, 0, graph_get_vram_size()); return SUCCESS; }
+int (graph_draw)(void){ memcpy(video_mem, video_buf, graph_get_vram_size()); return SUCCESS; }
+
+///SPRITE
+#include "sprite.h"
+
+#include "utils.h"
+#include "fast_math.h"
+#include <math.h>
+
+struct basic_sprite{
+    uint8_t *map;
+    uint16_t w, h;
+    int16_t u0, v0;
+};
+basic_sprite_t* (basic_sprite_ctor)(const char **xpm, int16_t u0, int16_t v0){
+    basic_sprite_t *ret = malloc(sizeof(basic_sprite_t));
+    if(ret == NULL) return NULL;
+    enum xpm_image_type type = XPM_8_8_8_8;
+    xpm_image_t img;
+    ret->map = xpm_load((xpm_map_t)xpm, type, &img);
+    if(ret->map == NULL){
+        basic_sprite_dtor(ret);
+        return NULL;
+    }
+    ret->w = img.width;
+    ret->h = img.height;
+    ret->u0 = u0;
+    ret->v0 = v0;
+    return ret;
+}
+void (basic_sprite_dtor)(basic_sprite_t *p){
+    if(p == NULL) return;
+    free(p->map);
+    free(p);
+}
+const uint8_t* (basic_sprite_get_map)(const basic_sprite_t *p){ return p->map; }
+uint16_t       (basic_sprite_get_w)  (const basic_sprite_t *p){ return p->w  ; }
+uint16_t       (basic_sprite_get_h)  (const basic_sprite_t *p){ return p->h  ; }
+int16_t        (basic_sprite_get_u0) (const basic_sprite_t *p){ return p->u0 ; }
+int16_t        (basic_sprite_get_v0) (const basic_sprite_t *p){ return p->v0 ; }
+
+/*
+struct basic_sprite_alpha{
+    uint8_t *map;
+    uint16_t w, h;
+    int16_t u0, v0;
+};
+basic_sprite_alpha_t* (basic_sprite_alpha_ctor)(const char **xpm, int16_t u0, int16_t v0){
+    basic_sprite_alpha_t *ret = malloc(sizeof(basic_sprite_t));
+    if(ret == NULL) return NULL;
+    enum xpm_image_type type = XPM_8_8_8_8;
+    xpm_image_t img;
+    ret->map = NULL;
+    uint8_t *m = xpm_load((xpm_map_t)xpm, type, &img);
+    if(m == NULL){
+        basic_sprite_alpha_dtor(ret);
+        return NULL;
+    }
+    ret->map = m;
+    if(ret->map == NULL){
+        basic_sprite_alpha_dtor(ret);
+        return NULL;
+    }
+    ret->w = img.width;
+    ret->h = img.height;
+    ret->u0 = u0;
+    ret->v0 = v0;
+    return ret;
+}
+void (basic_sprite_alpha_dtor)(basic_sprite_alpha_t *p){
+    if(p == NULL) return;
+    free(p->map);
+    free(p);
+}
+const uint8_t* (basic_sprite_alpha_get_map)(const basic_sprite_alpha_t *p){ return p->map; }
+uint16_t       (basic_sprite_alpha_get_w)  (const basic_sprite_alpha_t *p){ return p->w  ; }
+uint16_t       (basic_sprite_alpha_get_h)  (const basic_sprite_alpha_t *p){ return p->h  ; }
+int16_t        (basic_sprite_alpha_get_u0) (const basic_sprite_alpha_t *p){ return p->u0 ; }
+int16_t        (basic_sprite_alpha_get_v0) (const basic_sprite_alpha_t *p){ return p->v0 ; }
+*/
+
+struct sprite{
+    const basic_sprite_t *bsp;
+    int16_t x, y; //position in screen
+    double theta, s, c;
+    double scale;
+};
+sprite_t* (sprite_ctor)(const basic_sprite_t *bsp){
+    sprite_t *ret = malloc(sizeof(sprite_t));
+    if(ret == NULL) return NULL;
+    ret->bsp = bsp;
+    ret->x = 0;
+    ret->y = 0;
+    sprite_set_angle(ret, 0.0);
+    ret->scale = 1.0;
+    return ret;
+}
+void (sprite_dtor)(sprite_t *p){
+    if(p == NULL) return;
+    free(p);
+}
+void (sprite_set_pos)   (sprite_t *p, int16_t x , int16_t y ){ p->x = x; p->y = y; }
+void (sprite_set_angle) (sprite_t *p, double angle          ){ p->theta = angle; p->c = fm_cos(p->theta); p->s = fm_sin(p->theta); }
+void (sprite_set_scale) (sprite_t *p, double scale          ){ p->scale = scale; }
+int16_t  (sprite_get_x)(const sprite_t *p){ return p->x; }
+int16_t  (sprite_get_y)(const sprite_t *p){ return p->y; }
+double   (sprite_get_angle)(const sprite_t *p){ return p->theta; }
+uint16_t (sprite_get_w)(const sprite_t *p){ return basic_sprite_get_w(p->bsp); }
+uint16_t (sprite_get_h)(const sprite_t *p){ return basic_sprite_get_h(p->bsp); }
+void (sprite_src2pic)(const sprite_t *p, int16_t x, int16_t y, int16_t *u, int16_t *v){
+    double dx = (x - p->x)/p->scale;
+    double dy = (y - p->y)/p->scale;
+    int16_t du = dx*p->c - dy*p->s - 0.5;
+    int16_t dv = dx*p->s + dy*p->c - 0.5;
+    *u = du + basic_sprite_get_u0(p->bsp);
+    *v = dv + basic_sprite_get_v0(p->bsp);
+}
+void (sprite_pic2src)(const sprite_t *p, int16_t u, int16_t v, int16_t *x, int16_t *y){
+    int16_t du = u - basic_sprite_get_u0(p->bsp);
+    int16_t dv = v - basic_sprite_get_v0(p->bsp);
+    double dx =  du*p->c + dv*p->s;
+    double dy = -du*p->s + dv*p->c;
+    *x = dx*p->scale + 0.5 + p->x;
+    *y = dy*p->scale + 0.5 + p->y;
+}
+void (sprite_draw)(const sprite_t *p){
+    const uint16_t w = basic_sprite_get_w(p->bsp);
+    const uint16_t h = basic_sprite_get_h(p->bsp);
+    int16_t xmin, xmax, ymin, ymax; {
+        int16_t x, y;
+        sprite_pic2src(p, 0, 0, &x, &y);
+        xmin = x; xmax = x; ymin = y; ymax = y;
+        sprite_pic2src(p, w, 0, &x, &y);
+        xmin = min(x, xmin); xmax = max(x, xmax); ymin = min(y, ymin); ymax = max(y, ymax);
+        sprite_pic2src(p, 0, h, &x, &y);
+        xmin = min(x, xmin); xmax = max(x, xmax); ymin = min(y, ymin); ymax = max(y, ymax);
+        sprite_pic2src(p, w, h, &x, &y);
+        xmin = min(x, xmin); xmax = max(x, xmax); ymin = min(y, ymin); ymax = max(y, ymax);
+        xmin = max(xmin-(int16_t)p->scale-2, 0); xmax = min(xmax+(int16_t)p->scale+2, graph_get_XRes());
+        ymin = max(ymin-(int16_t)p->scale-2, 0); ymax = min(ymax+(int16_t)p->scale+2, graph_get_YRes());
+    }
+    const uint8_t *map = basic_sprite_get_map(p->bsp);
+    const uint16_t bytes_pixel = 3/*graph_get_bytes_pixel()*/;
+    for(int16_t u, v, y = ymin; y < ymax; ++y){
+        uint8_t *place = video_buf + (xmin + y*graph_get_XRes())*bytes_pixel;
+        for(int16_t x = xmin; x < xmax; ++x, place += bytes_pixel){
+            sprite_src2pic(p, x, y, &u, &v);
+            if(0 <= u && u < w && 0 <= v && v < h){
+                const uint8_t *c_p = map+(v*w+u)*4;
+                if(*(c_p+3) < ALPHA_THRESHOLD) //alpha
+                    memcpy(place, c_p, bytes_pixel);
+            }
+        }
+    }
+}

Property changes on: proj/libs/peripherals/src/graph.c
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: proj/libs/utils/include/fast_math.h
===================================================================
--- proj/libs/utils/include/fast_math.h	(nonexistent)
+++ proj/libs/utils/include/fast_math.h	(revision 279)
@@ -0,0 +1,7 @@
+#ifndef FAST_MATH_H_INCLUDED
+#define FAST_MATH_H_INCLUDED
+
+double fm_sin(double x);
+double fm_cos(double x);
+
+#endif //FAST_MATH_H_INCLUDED

Property changes on: proj/libs/utils/include/fast_math.h
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: proj/libs/utils/include/utils.h
===================================================================
--- proj/libs/utils/include/utils.h	(nonexistent)
+++ proj/libs/utils/include/utils.h	(revision 279)
@@ -0,0 +1,75 @@
+#ifndef UTILS_H_INCLUDED
+#define UTILS_H_INCLUDED
+
+#define BCD_FIRST(n)     (n >> 4)       /** @brief Get first digit (leftmost digit) of 8-bit BCD */
+#define BCD_SECOND(n)    (n & 0x0F)     /** @brief Get second digit (rightmost digit) of 8-bit BCD */
+
+/**
+ * @brief Gets the least significant byte of a 16-bit variable
+ * @param val 16-bit variable
+ * @param lsb Pointer to a 8-bit variable to store the value of the LSB
+ * @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
+ */
+int(util_get_LSB)(uint16_t val, uint8_t *lsb);
+
+/**
+ * @brief Gets the most significant byte of a 16-bit variable
+ * @param val 16-bit variable
+ * @param lsb Pointer to a 8-bit variable to store the value of the MSB
+ * @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
+ */
+int(util_get_MSB)(uint16_t val, uint8_t *msb);
+
+/**
+ * @brief sys_inb wrapper
+ * @param port Port to read from
+ * @param value Pointer to byte to store value read
+ * @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
+ */
+int (util_sys_inb)(int port, uint8_t *value);
+
+/**
+ * @brief Unsubcribes Interrupts
+ * @param interrupt_id Interrupt ID, value via arguments on subscription of the interrupt_id
+ * @see subscribe_kbc_interrupt, subscribe_timer_interrupt
+ * @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
+ */
+int (unsubscribe_interrupt)(int *interrupt_id);
+
+/**
+ * @brief Gets the minimum value out of two values.
+ * @param a     First value
+ * @param b     Second value
+ * @return  The minimum of the two values
+ */
+int32_t min(int32_t a, int32_t b);
+
+/**
+ * @brief Gets the maximum value out of two values.
+ * @param a     First value
+ * @param b     Second value
+ * @return  The maximum of the two values
+ */
+int32_t max(int32_t a, int32_t b);
+
+/**
+ * @brief Gets the minimum value out of two doubles.
+ * @param a     First value
+ * @param b     Second value
+ * @return  The minimum of the two values
+ */
+double min_d(double a, double b);
+
+/**
+ * @brief Gets the maximum value out of two doubles.
+ * @param a     First value
+ * @param b     Second value
+ * @return  The maximum of the two values
+ */
+double max_d(double a, double b);
+
+
+double abs_d(double a);
+
+
+#endif //UTILS_H_INCLUDED

Property changes on: proj/libs/utils/include/utils.h
___________________________________________________________________
Added: svn:executable
Index: proj/libs/utils/include/xpm_utils.h
===================================================================
--- proj/libs/utils/include/xpm_utils.h	(nonexistent)
+++ proj/libs/utils/include/xpm_utils.h	(revision 279)
@@ -0,0 +1,8 @@
+#ifndef XMP_UTILS_H_INCLUDED
+#define XMP_UTILS_H_INCLUDED
+
+void xpm_save_as_xpm2(const char **p, const char *s);
+
+char** xpm_load_xpm2(const char *s);
+
+#endif //XMP_UTILS_H_INCLUDED

Property changes on: proj/libs/utils/include/xpm_utils.h
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: proj/libs/utils/src/fast_math.c
===================================================================
--- proj/libs/utils/src/fast_math.c	(nonexistent)
+++ proj/libs/utils/src/fast_math.c	(revision 279)
@@ -0,0 +1,30 @@
+#include <lcom/lcf.h>
+
+#include "fast_math.h"
+#include "utils.h"
+
+#include <math.h>
+
+double fm_sin(double x){
+    if(x < 0.0)         return -fm_sin(-x);
+    if(x > 2.0*M_PI) return fm_sin(x-2.0*M_PI);
+    if(x > M_PI)      return -fm_sin(x-M_PI);
+    if(x > 0.5*M_PI) x = M_PI - x;
+    double x2 = x*x;
+    double x3 = x*x2;
+    double x5 = x3*x2;
+    //double x7 = x5*x2;
+    return x-x3*0.1666666666666666666666+x5*0.008333333333333333333333;//-x7*0.0001984126984127;
+}
+
+double fm_cos(double x){
+    if(x < 0.0)         x = -x;
+    if(x > 2.0*M_PI) return fm_cos(x-2.0*M_PI);
+    if(x > M_PI)      x = 2.0*M_PI-x;
+    if(x > 0.5*M_PI) return -fm_cos(M_PI-x);
+    double x2 = x*x;
+    double x4 = x2*x2;
+    double x6 = x4*x2;
+    //double x8 = x4*x4;
+    return 1.0-x2*0.5+x4*0.041666666666666666666666-x6*0.0013888888888888888888888;//+x8*0.000024801587;
+}

Property changes on: proj/libs/utils/src/fast_math.c
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: proj/libs/utils/src/utils.c
===================================================================
--- proj/libs/utils/src/utils.c	(nonexistent)
+++ proj/libs/utils/src/utils.c	(revision 279)
@@ -0,0 +1,39 @@
+#include <lcom/lcf.h>
+
+#include "utils.h"
+
+#include <stdint.h>
+#include "errors.h"
+
+int(util_get_LSB)(uint16_t val, uint8_t *lsb) {
+    if (lsb == NULL) return NULL_PTR;
+    *lsb = val;
+    return SUCCESS;
+}
+
+int(util_get_MSB)(uint16_t val, uint8_t *msb) {
+    if (msb == NULL) return NULL_PTR;
+    *msb = (val >> 8);
+    return SUCCESS;
+}
+
+int (util_sys_inb)(int port, uint8_t *value) {
+    if(value == NULL) return NULL_PTR;
+    uint32_t n = 0;
+    if(sys_inb(port, &n)) return READ_ERROR;
+    *value = n;
+    return SUCCESS;
+}
+
+int (unsubscribe_interrupt)(int *interrupt_id) {
+    if (interrupt_id == NULL) return NULL_PTR;
+    if(sys_irqrmpolicy(interrupt_id)) return UNSBCR_ERROR;
+    return SUCCESS;
+}
+
+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); }
+
+double min_d(double a, double b){ return (b < a ? b : a); }
+double max_d(double a, double b){ return (a < b ? b : a); }
+double abs_d(double a)          { return (a < 0 ? -a: a); }

Property changes on: proj/libs/utils/src/utils.c
___________________________________________________________________
Added: svn:executable
Index: proj/libs/utils/src/xpm_utils.c
===================================================================
--- proj/libs/utils/src/xpm_utils.c	(nonexistent)
+++ proj/libs/utils/src/xpm_utils.c	(revision 279)
@@ -0,0 +1,52 @@
+#ifdef LCOM_MACRO
+    #include <lcom/lcf.h>
+#endif
+
+#include "xpm_utils.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+void xpm_save_as_xpm2(const char **p, const char *s){
+    FILE *f = fopen(s, "w");
+    int w, h, num_colors, chars_per_pixel;
+    sscanf(p[0], "%d %d %d %d", &w, &h, &num_colors, &chars_per_pixel);
+    for(int i = 0; i < 1+num_colors+h; ++i){
+        fprintf(f, "%s\n", p[i]);
+    }
+    fclose(f); f = NULL;
+}
+
+char** xpm_load_xpm2(const char *fpath){
+    FILE *f = fopen(fpath, "r");
+    if(f == NULL) return NULL;
+    size_t len = 1024; char *line_buf = malloc(len*sizeof(char));
+    int sz;
+
+    char **ret = NULL;
+
+    int w, h, num_colors, chars_per_pixel;
+
+    sz = getline(&line_buf, &len, f);{
+        sscanf(line_buf, "%d %d %d %d", &w, &h, &num_colors, &chars_per_pixel);
+        ret = malloc((1+num_colors+h)*sizeof(char*));
+    }
+    ret[0] = malloc((sz+1)*sizeof(char)); if(ret[0] == NULL){ free(ret); return NULL; }
+    strcpy(ret[0], line_buf);
+
+    for(int i = 1; i < 1+num_colors+h; ++i){
+        sz = getline(&line_buf, &len, f);
+        ret[i] = malloc((sz+1)*sizeof(char));
+        if(ret[i] == NULL){
+            for(int j = 0; j < i; ++j)
+                free(ret[i]);
+            free(ret);
+            return NULL;
+        }
+        strcpy(ret[i], line_buf);
+        ret[i][sz-1] = '\0';
+    }
+    fclose(f); f = NULL;
+    return ret;
+}

Property changes on: proj/libs/utils/src/xpm_utils.c
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: proj/DR.mk
===================================================================
--- proj/DR.mk	(revision 278)
+++ proj/DR.mk	(revision 279)
@@ -3,9 +3,10 @@
 .PATH: ${.CURDIR}/src
 .PATH: ${.CURDIR}/libs/peripherals/src
 .PATH: ${.CURDIR}/libs/classes/src
+.PATH: ${.CURDIR}/libs/utils/src
 
 SRCS= proj.c list.c queue.c graph.c kbc.c keyboard.c mouse.c utils.c timer.c interrupts_func.c proj_func.c fast_math.c rectangle.c font.c xpm_utils.c ent.c rtc.c uart.c hltp.c makecode_map.c
-IPATHS=-I./include -I./libs/peripherals/include -I./libs/classes/include -I./maps -I./media/xpm
+IPATHS=-I./include -I./libs/peripherals/include -I./libs/classes/include -I./libs/utils/include -I./maps -I./media/xpm
 
 CPPFLAGS += -pedantic ${IPATHS} -D LCOM_MACRO -D DIOGO #-D __LCOM_OPTIMIZED_
 
