Project

General

Profile

Revision 323

more stuff

View differences:

proj/include/ent.h
69 69
int    (map_collides_point)(const map_t *p, double x, double y);
70 70
int    (map_collides_gunner)(const map_t *p, const gunner_t *gunner);
71 71
int    (map_collides_bullet)(const map_t *p, const bullet_t *bullet);
72
int16_t (map_get_width)   (const map_t *p);
73
int16_t (map_get_height)  (const map_t *p);
72
uint16_t (map_get_width)   (const map_t *p);
73
uint16_t (map_get_height)  (const map_t *p);
74 74
int (map_make_dijkstra)(map_t *p, double x_, double y_);
75 75
int (map_where_to_follow)(const map_t *p, double x, double y, double *theta);
76 76
int (gunner_collides_bullet)(const gunner_t *shooter, const bullet_t *bull);
proj/include/interrupts_func.h
21 21
 */
22 22
void interrupt_handler(uint8_t handler);
23 23

  
24
int get_interrupts_vector(uint32_t *p);
24
int get_interrupts_vector(uint64_t *p);
25 25

  
26 26
#endif /* end of include guard: INTERRUPTS_FUNC_H_INCLUDED */
proj/libs/graph/include/font.h
95 95
 */
96 96
void (text_set_pos)   (text_t *p, int16_t x, int16_t y);
97 97
/**
98
 * @brief Set text size (letter size).
98
 * @brief Set text size (letter size, in pixels).
99 99
 * @param   p       Pointer to text
100 100
 * @param   size    Letter size of the text
101 101
 */
102
void (text_set_size)  (text_t *p, unsigned size);
102
void (text_set_size)  (text_t *p, uint16_t size);
103 103
/**
104 104
 * @brief Set text color.
105 105
 * @param   p       Pointer to text
proj/libs/graph/src/font.c
20 20
 * @param   xpm XPM describing the glyph
21 21
 * @return      Pointer to created glyph
22 22
 */
23
static glyph_t* (glyph_ctor)(const char **xpm){
23
static glyph_t* (glyph_ctor)(const char *const *xpm){
24 24
    if(xpm == NULL) return NULL;
25 25
    glyph_t *ret = malloc(sizeof(glyph_t));
26 26
    if(ret == NULL) return NULL;
......
71 71
        for(int16_t w = 0; w < p->w; ++w){
72 72
            uint8_t a = *(p->map + w + h*p->w);
73 73
            int16_t x_ = x+w, y_ = y-p->h+h;
74
            unsigned pos = x_ +y_*W;
75
            alp_buf[pos] = a;
74
            int32_t pos = x_ +y_*W;
75
            if(0 <= pos && pos < W*H) alp_buf[pos] = a;
76 76
        }
77 77
    }
78 78
    return SUCCESS;
......
98 98
    for(size_t i = 0; i < ret->nchars; ++i){
99 99
        sprintf(filepath, "%s/ascii%03d.xpm2", s, i);
100 100
        char **xpm = xpm_load_xpm2(filepath);
101
        ret->glyphs[i] = glyph_ctor((const char**)xpm);
101
        ret->glyphs[i] = glyph_ctor((const char *const *)xpm);
102 102
        if(ret->glyphs[i] != NULL) good = true;
103 103
    }
104 104
    if(good) return ret;
......
137 137
    const font_t *fnt;
138 138
    char *txt;
139 139
    int16_t x, y;
140
    int size;
141
    uint32_t color;
140
    uint16_t size;
142 141
    text_valign valign;
143 142
    text_halign halign;
143
    uint32_t color;
144 144
};
145 145
text_t* (text_ctor)(const font_t *fnt, const char *txt){
146 146
    if(fnt == NULL) return NULL;
......
170 170
}
171 171
const char* (text_get_string)(const text_t *p){return p->txt; }
172 172
void (text_set_pos)   (text_t *p, int16_t x, int16_t y){ p->x = x; p->y = y; }
173
void (text_set_size)  (text_t *p, unsigned size       ){ p->size = size    ; }
173
void (text_set_size)  (text_t *p, uint16_t size       ){ p->size = size    ; }
174 174
void (text_set_color) (text_t *p, uint32_t color      ){ p->color = color  ; }
175 175
void (text_set_valign)(text_t *p, text_valign valign  ){ p->valign = valign; }
176 176
void (text_set_halign)(text_t *p, text_halign halign  ){ p->halign = halign; }
......
186 186
        uint16_t W = 0, H = 0; {
187 187
            for(size_t i = 0; i < len; ++i){
188 188
                const glyph_t *g = p->fnt->glyphs[(size_t)p->txt[i]];
189
                if(g != NULL){ W += g->w; H = max(H, g->h); }
189
                if(g != NULL){ W += g->w; H = umax16(H, g->h); }
190 190
            }
191 191
        }
192 192
        uint8_t *alp_buf = malloc(W*H);
193 193
        if(alp_buf == NULL) return ALLOC_ERROR;{
194
            int16_t y = H;
194
            int16_t y = (int16_t)H;
195 195
            int16_t x = 0;
196 196
            for(size_t i = 0; i < len; ++i){
197 197
                const glyph_t *g = p->fnt->glyphs[(size_t)p->txt[i]];
......
204 204

  
205 205
        double factor = (double)p->size/(double)H;
206 206

  
207
        newH = H*factor;
208
        newW = W*factor;
207
        newH = (uint16_t)(H*factor);
208
        newW = (uint16_t)(W*factor);
209 209
        alp_new_buf = malloc(newW*newH);
210 210
        if(alp_new_buf == NULL) return ALLOC_ERROR;
211 211

  
212
        for(size_t newy = 0; newy < newH; ++newy){
213
            size_t y = newy/factor;
214
            for(size_t newx = 0; newx < newW; ++newx){
215
                size_t x = newx/factor;
212
        for(uint16_t newy = 0; newy < newH; ++newy){
213
            uint16_t y = (uint16_t)(newy/factor);
214
            for(uint16_t newx = 0; newx < newW; ++newx){
215
                uint16_t x = (uint16_t)(newx/factor);
216 216
                *(alp_new_buf+newx+newy*newW) = *(alp_buf+x+y*W);
217 217
            }
218 218
        }
......
224 224
            case text_halign_left  : initx = p->x         ; break;
225 225
            case text_halign_center: initx = p->x - newW/2; break;
226 226
            case text_halign_right : initx = p->x - newW  ; break;
227
            default: return LOGIC_ERROR;
227
            //default: return LOGIC_ERROR;
228 228
        }
229 229
    }
230 230
    // Get initial value of y
......
233 233
            case text_valign_top   : inity = p->y         ; break;
234 234
            case text_valign_center: inity = p->y - newH/2; break;
235 235
            case text_valign_bottom: inity = p->y - newH  ; break;
236
            default: return LOGIC_ERROR;
236
            //default: return LOGIC_ERROR;
237 237
        }
238 238
    }
239 239
    // Draw text
......
244 244
            if(!(0 <= x && x < graph_get_XRes() &&
245 245
                 0 <= y && y < graph_get_YRes())) continue;
246 246
            uint8_t a = *(alp_new_buf+newx+newy*newW);
247
            if(a < ALPHA_THRESHOLD) graph_set_pixel(x,y,p->color);
247
            if(a < ALPHA_THRESHOLD) graph_set_pixel((uint16_t)x,(uint16_t)y,p->color);
248 248
        }
249 249
    }
250 250
    free(alp_new_buf);
proj/libs/graph/src/graph.c
8 8
#define VC_BIOS_SERV  0x10 /** @brief Interrupt service of video card */
9 9
#define VBE_CALL      0x4F /** @brief VBE call function specifier */
10 10

  
11
#define MBYTE_BASE  0x0         /** @brief Base address (zero address) */
12
#define MBYTE_SIZE  0xFFFFF     /** @brief Size of a mebibyte */
11
//#define MBYTE_BASE  0x0         /** @brief Base address (zero address) */
12
//#define MBYTE_SIZE  0xFFFFF     /** @brief Size of a mebibyte */
13 13

  
14 14
// Graphics Functions
15
#define VBE_CTRL_INFO       0x00    /** @brief Get VBE Controller Information */
15
//#define VBE_CTRL_INFO       0x00    /** @brief Get VBE Controller Information */
16 16
#define VBE_MD_INFO         0x01    /** @brief Get VBE Mode Information */
17 17
#define SET_VBE_MD          0x02    /** @brief Set VBE Mode */
18 18

  
19 19
// Error codes (AH)
20 20
#define AH_SUCCESS          0x00    /** @brief Success code on BIOS call */
21
#define AH_FUNC_CALL_FAIL   0x01    /** @brief Function call failed */
22
#define AH_FUNC_NOT_SUPP    0x02    /** @brief Function call is not supported in current HW configuration */
23
#define AH_FUNC_INVALID     0x03    /** @brief Invalid function in current video mode */
21
//#define AH_FUNC_CALL_FAIL   0x01    /** @brief Function call failed */
22
//#define AH_FUNC_NOT_SUPP    0x02    /** @brief Function call is not supported in current HW configuration */
23
//#define AH_FUNC_INVALID     0x03    /** @brief Invalid function in current video mode */
24 24

  
25 25
/// MACROS
26
#define FAR2PHYS(n)         ((((n)>>12) & 0xFFFFFFF0) + ((n) & 0x0000FFFF))
26
//#define FAR2PHYS(n)         ((((n)>>12) & 0xFFFFFFF0) + ((n) & 0x0000FFFF))
27 27

  
28 28
/// STRUCT
29 29
typedef struct __attribute__((packed)) {
......
211 211
*/
212 212

  
213 213
/// INIT
214
/**
215
 * @brief
216
 * @param mode
217
 * @return
218
 */
219 214
static int (graph_set_mode)(uint16_t mode) {
220 215
    struct reg86 reg_86;
221 216

  
......
314 309
int16_t        (basic_sprite_get_u0) (const basic_sprite_t *p){ return p->u0 ; }
315 310
int16_t        (basic_sprite_get_v0) (const basic_sprite_t *p){ return p->v0 ; }
316 311

  
317
/*
318
struct basic_sprite_alpha{
319
    uint8_t *map;
320
    uint16_t w, h;
321
    int16_t u0, v0;
322
};
323
basic_sprite_alpha_t* (basic_sprite_alpha_ctor)(const char **xpm, int16_t u0, int16_t v0){
324
    basic_sprite_alpha_t *ret = malloc(sizeof(basic_sprite_t));
325
    if(ret == NULL) return NULL;
326
    enum xpm_image_type type = XPM_8_8_8_8;
327
    xpm_image_t img;
328
    ret->map = NULL;
329
    uint8_t *m = xpm_load((xpm_map_t)xpm, type, &img);
330
    if(m == NULL){
331
        basic_sprite_alpha_dtor(ret);
332
        return NULL;
333
    }
334
    ret->map = m;
335
    if(ret->map == NULL){
336
        basic_sprite_alpha_dtor(ret);
337
        return NULL;
338
    }
339
    ret->w = img.width;
340
    ret->h = img.height;
341
    ret->u0 = u0;
342
    ret->v0 = v0;
343
    return ret;
344
}
345
void (basic_sprite_alpha_dtor)(basic_sprite_alpha_t *p){
346
    if(p == NULL) return;
347
    free(p->map);
348
    free(p);
349
}
350
const uint8_t* (basic_sprite_alpha_get_map)(const basic_sprite_alpha_t *p){ return p->map; }
351
uint16_t       (basic_sprite_alpha_get_w)  (const basic_sprite_alpha_t *p){ return p->w  ; }
352
uint16_t       (basic_sprite_alpha_get_h)  (const basic_sprite_alpha_t *p){ return p->h  ; }
353
int16_t        (basic_sprite_alpha_get_u0) (const basic_sprite_alpha_t *p){ return p->u0 ; }
354
int16_t        (basic_sprite_alpha_get_v0) (const basic_sprite_alpha_t *p){ return p->v0 ; }
355
*/
356

  
357 312
struct sprite{
358 313
    const basic_sprite_t *bsp;
359 314
    int16_t x, y; //position in screen
......
381 336
void (sprite_set_pos)   (sprite_t *p, int16_t x , int16_t y ){ p->x = x; p->y = y; }
382 337
void (sprite_set_angle) (sprite_t *p, double angle          ){ p->theta = angle; p->c = fm_cos(p->theta); p->s = fm_sin(p->theta); }
383 338
void (sprite_set_scale) (sprite_t *p, double scale          ){
384
    if(p->scale == scale) return;
339
    if(deq(p->scale, scale)) return;
385 340
    p->scale = scale;
386 341

  
387
    p->su0 = p->bsp->u0*p->scale;
388
    p->sv0 = p->bsp->u0*p->scale;
342
    p->su0 = (int16_t)(p->bsp->u0*p->scale);
343
    p->sv0 = (int16_t)(p->bsp->u0*p->scale);
389 344

  
390 345
    const uint16_t W = basic_sprite_get_w(p->bsp),
391 346
                   H = basic_sprite_get_h(p->bsp);
392
    uint16_t sW = W*scale, sH = H*scale;
347
    uint16_t sW = (uint16_t)(W*scale), sH = (uint16_t)(H*scale);
393 348
    p->sbuf = realloc(p->sbuf, sW*sH*4);
394 349
    const uint8_t *map = basic_sprite_get_map(p->bsp);
395 350
    for(uint16_t sx = 0; sx < sW; ++sx){
396 351
        for(uint16_t sy = 0; sy < sH; ++sy){
397
            uint16_t x = sx/scale, y = sy/scale;
352
            uint16_t x = (uint16_t)(sx/scale), y = (uint16_t)(sy/scale);
398 353
            if(x > W || y > H) continue;
399 354
            memcpy(p->sbuf+4*(sx+sy*sW), map+4*(x+y*W), 4);
400 355
        }
......
405 360
double   (sprite_get_angle)(const sprite_t *p){ return p->theta; }
406 361
uint16_t (sprite_get_w)(const sprite_t *p){ return basic_sprite_get_w(p->bsp); }
407 362
uint16_t (sprite_get_h)(const sprite_t *p){ return basic_sprite_get_h(p->bsp); }
408
void (sprite_src2sbuf)(const sprite_t *p, int16_t x, int16_t y, int16_t *u, int16_t *v){
363
static void (sprite_src2sbuf)(const sprite_t *p, int16_t x, int16_t y, int16_t *u, int16_t *v){
409 364
    if(p->theta == 0.0){
410 365
        *u = x - p->x + p->su0;
411 366
        *v = y - p->y + p->sv0;
412 367
    }else{
413 368
        double dx = x - p->x;
414 369
        double dy = y - p->y;
415
        int16_t du = dx*p->c - dy*p->s - 0.5f;
416
        int16_t dv = dx*p->s + dy*p->c - 0.5f;
370
        int16_t du = (int16_t)(dx*p->c - dy*p->s - 0.5f);
371
        int16_t dv = (int16_t)(dx*p->s + dy*p->c - 0.5f);
417 372
        *u = du + p->su0;
418 373
        *v = dv + p->sv0;
419 374
    }
420 375
}
421
void (sprite_sbuf2src)(const sprite_t *p, int16_t u, int16_t v, int16_t *x, int16_t *y){
376
static void (sprite_sbuf2src)(const sprite_t *p, int16_t u, int16_t v, int16_t *x, int16_t *y){
422 377
    int16_t du = u - p->su0;
423 378
    int16_t dv = v - p->sv0;
424 379
    double dx =  du*p->c + dv*p->s;
425 380
    double dy = -du*p->s + dv*p->c;
426
    *x = dx + 0.5 + p->x;
427
    *y = dy + 0.5 + p->y;
381
    *x = (int16_t)(dx + 0.5 + p->x);
382
    *y = (int16_t)(dy + 0.5 + p->y);
428 383
}
429 384

  
430 385
void (sprite_draw)(const sprite_t *p){
431
    const uint16_t sw = p->scale*basic_sprite_get_w(p->bsp);
432
    const uint16_t sh = p->scale*basic_sprite_get_h(p->bsp);
386
    const uint16_t sw = (uint16_t)(p->scale*basic_sprite_get_w(p->bsp));
387
    const uint16_t sh = (uint16_t)(p->scale*basic_sprite_get_h(p->bsp));
433 388
    int16_t xmin, xmax, ymin, ymax; {
434 389
        int16_t x, y;
435
        sprite_sbuf2src(p, 0 , 0 , &x, &y);
390
        sprite_sbuf2src(p, 0          , 0          , &x, &y);
436 391
        xmin = x; xmax = x; ymin = y; ymax = y;
437
        sprite_sbuf2src(p, sw, 0 , &x, &y);
438
        xmin = min(x, xmin); xmax = max(x, xmax); ymin = min(y, ymin); ymax = max(y, ymax);
439
        sprite_sbuf2src(p, 0 , sh, &x, &y);
440
        xmin = min(x, xmin); xmax = max(x, xmax); ymin = min(y, ymin); ymax = max(y, ymax);
441
        sprite_sbuf2src(p, sw, sh, &x, &y);
442
        xmin = min(x, xmin); xmax = max(x, xmax); ymin = min(y, ymin); ymax = max(y, ymax);
443
        xmin = max(xmin-2, 0); xmax = min(xmax+2, graph_get_XRes());
444
        ymin = max(ymin-2, 0); ymax = min(ymax+2, graph_get_YRes());
392
        sprite_sbuf2src(p, (int16_t)sw, 0          , &x, &y);
393
        xmin = min16(x, xmin); xmax = max16(x, xmax); ymin = min16(y, ymin); ymax = max16(y, ymax);
394
        sprite_sbuf2src(p, 0          , (int16_t)sh, &x, &y);
395
        xmin = min16(x, xmin); xmax = max16(x, xmax); ymin = min16(y, ymin); ymax = max16(y, ymax);
396
        sprite_sbuf2src(p, (int16_t)sw, (int16_t)sh, &x, &y);
397
        xmin = min16(x, xmin); xmax = max16(x, xmax); ymin = min16(y, ymin); ymax = max16(y, ymax);
398
        xmin = max16(xmin-2, 0); xmax = min16(xmax+2, (int16_t)graph_get_XRes());
399
        ymin = max16(ymin-2, 0); ymax = min16(ymax+2, (int16_t)graph_get_YRes());
445 400
    }
446 401
    const uint16_t bytes_pixel = 3/*graph_get_bytes_pixel()*/;
447 402
    for(int16_t u, v, y = ymin; y < ymax; ++y){
proj/libs/graph/src/rectangle.c
8 8
struct rectangle{
9 9
    int16_t  x, y;
10 10
    uint16_t w, h;
11
    uint32_t outline_color;
11 12
    uint32_t fill_color;
13
    int16_t  outline_width;
12 14
    uint8_t  fill_alpha;
13
    uint32_t outline_color;
14
    int16_t  outline_width;
15 15
};
16 16

  
17 17
rectangle_t* (rectangle_ctor)(int16_t x, int16_t y, uint16_t w, uint16_t h){
......
51 51

  
52 52
static void (rectangle_draw_hline)(int16_t x, int16_t y, int16_t l, uint32_t color){
53 53
    if(l < 0){ rectangle_draw_hline(x+l, y, -l, color); return; }
54
    for(int16_t x_ = max(0,x); x_ < min(x+l,graph_get_XRes()); ++x_){
55
        graph_set_pixel(x_, y, color);
54
    for(int16_t x_ = max16(0,x); x_ < min16(x+l,(int16_t)graph_get_XRes()); ++x_){
55
        graph_set_pixel((uint16_t)x_, (uint16_t)y, color);
56 56
    }
57 57
}
58 58
static void (rectangle_draw_vline)(int16_t x, int16_t y, int16_t l, uint32_t color){
59 59
    if(l < 0){ rectangle_draw_vline(x, y+l, -l, color); return; }
60
    for(int16_t y_ = max(0,y); y_ < min(y+l,graph_get_YRes()); ++y_){
61
        graph_set_pixel(x, y_, color);
60
    for(int16_t y_ = max16(0,y); y_ < min16(y+l,(int16_t)graph_get_YRes()); ++y_){
61
        graph_set_pixel((uint16_t)x, (uint16_t)y_, color);
62 62
    }
63 63
}
64 64

  
65 65
void (rectangle_draw)(const rectangle_t *p){
66 66
    /// fill
67 67
    if(p->fill_alpha > ALPHA_THRESHOLD)
68
        for(int16_t y = max(p->y,0); y < min(p->y+p->h, graph_get_YRes()); ++y)
69
            rectangle_draw_hline(p->x, y, p->w, p->fill_color);
68
        for(int16_t y = max16(p->y,0); y < min16(p->y+p->h, (int16_t)graph_get_YRes()); ++y)
69
            rectangle_draw_hline(p->x, y, (int16_t)p->w, p->fill_color);
70 70
    /// border
71 71
    int16_t step = (p->outline_width > 0 ? 1 : -1);
72 72
    int16_t l = p->x, r = p->x+p->w, t = p->y, b = p->y+p->h;
proj/libs/kbc/include/mouse.h
14 14
int (mouse_get_got_error_mouse_ih)(void);
15 15
const uint8_t* (mouse_get_packet_mouse_ih)(void);
16 16
int (mouse_get_counter_mouse_ih)(void);
17
void (mouse_set_counter_mouse_ih)(int n);
17 18

  
18
int got_error_mouse_ih;
19
uint8_t packet_mouse_ih[3];
20
int counter_mouse_ih;
21

  
22 19
/**
23 20
 * @brief   Parse 3 bytes and returns it as a parsed, struct packet.
24 21
 * @param   packet_bytes    array of bytes to parse
......
61 58
 * @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
62 59
 * @see {_ERRORS_H_::errors}
63 60
 */
64
int (mouse_issue_cmd)(uint32_t cmd);
61
int (mouse_issue_cmd)(uint8_t cmd);
65 62

  
66 63
/**
67 64
 * @brief Reads byte from mouse
proj/libs/kbc/src/kbc.c
18 18
    if((ret = kbc_issue_arg(cmd))) return ret;
19 19
    return SUCCESS;
20 20
}
21

  
22
int (kbc_restore_kbd)(){
21
/*
22
static int (kbc_restore_kbd)(){
23 23
    int ret = 0;
24 24
    uint8_t cmd = 0;
25 25
    if((ret = kbc_read_cmd(&cmd))) return ret;
......
27 27
    if((ret = kbc_change_cmd(cmd))) return ret;
28 28
    return SUCCESS;
29 29
}
30

  
30
*/
31 31
int (kbc_issue_cmd)(uint8_t cmd){
32 32
    int ret = 0;
33 33
    uint8_t stat;
proj/libs/kbc/src/mouse.c
19 19
// Byte 2 - Y delta
20 20

  
21 21
/* Mouse Commands */
22
#define RESET           0xFF /* @brief Reset mouse */
23
#define RESEND          0xFE /* @brief Resend command */
24
#define DEFAULT         0xF6 /* @brief Set default values */
22
//#define RESET           0xFF /* @brief Reset mouse */
23
//#define RESEND          0xFE /* @brief Resend command */
24
//#define DEFAULT         0xF6 /* @brief Set default values */
25 25
#define DIS_DATA_REP    0xF5 /* @brief Disable Data Reporting */
26 26
#define ENABLE_DATA_REP 0xF4 /* @brief Enable Data Reporting */
27
#define SET_SAMPLE_RT   0xF3 /* @brief Sets state sampling rate */
28
#define SET_REMOTE_MD   0xF0 /* @brief Sets Mouse on Remote Mode, data on request */
27
//#define SET_SAMPLE_RT   0xF3 /* @brief Sets state sampling rate */
28
//#define SET_REMOTE_MD   0xF0 /* @brief Sets Mouse on Remote Mode, data on request */
29 29
#define READ_DATA       0xEB /* @brief Sends data packet request */
30
#define SET_STREAM_MD   0xEA /* @brief Sets mouse on Stream Mode, data on events */
31
#define STATUS_REQUEST  0xE9 /* @brief Get mouse configuration */
32
#define SET_RESOLUTION  0xE8 /* @brief Sets resolution for mouse movement */
33
#define SCALING_ACC_MD  0xE7 /* @brief Sets scaling on acceleration mode */
34
#define SCALING_LIN_MD  0xE6 /* @brief Sets scaling on linear mode */
30
//#define SET_STREAM_MD   0xEA /* @brief Sets mouse on Stream Mode, data on events */
31
//#define STATUS_REQUEST  0xE9 /* @brief Get mouse configuration */
32
//#define SET_RESOLUTION  0xE8 /* @brief Sets resolution for mouse movement */
33
//#define SCALING_ACC_MD  0xE7 /* @brief Sets scaling on acceleration mode */
34
//#define SCALING_LIN_MD  0xE6 /* @brief Sets scaling on linear mode */
35 35

  
36 36
/* Mouse Controller Responses */
37 37
#define ACK_OK      0xFA /* @brief Operation sucessful */
38
#define ACK_INVALID 0xFE /* @brief Invalid Byte, first occurence */
38
//#define ACK_INVALID 0xFE /* @brief Invalid Byte, first occurence */
39 39
#define ACK_ERROR   0xFC /* @brief Invalid Byte on resend */
40 40

  
41 41
int (subscribe_mouse_interrupt)(uint8_t interrupt_bit, int *interrupt_id) {
......
45 45
    return SUCCESS;
46 46
}
47 47

  
48
int got_error_mouse_ih = 0;
49
uint8_t packet_mouse_ih[3];
50
int counter_mouse_ih = 0;
48
static int got_error_mouse_ih = 0;
49
static uint8_t packet_mouse_ih[3];
50
static int counter_mouse_ih = 0;
51 51
int (mouse_get_got_error_mouse_ih)(void){return got_error_mouse_ih; }
52 52
const uint8_t* (mouse_get_packet_mouse_ih)(void){return packet_mouse_ih; }
53 53
int (mouse_get_counter_mouse_ih)(void){return counter_mouse_ih; }
54
void (mouse_set_counter_mouse_ih)(int n){ counter_mouse_ih = n; }
54 55

  
55 56
void (mouse_ih)(void) {
56 57
    uint8_t status = 0;
......
117 118
    return SUCCESS;
118 119
}
119 120

  
120
int (mouse_issue_cmd)(uint32_t cmd) {
121
int (mouse_issue_cmd)(uint8_t cmd) {
121 122
    int ret;
122 123
    uint8_t ack = 0;
123 124
    for (unsigned int i = 0; i < KBC_NUM_TRIES; i++) {
proj/libs/timer/include/timer.h
9 9

  
10 10
int (subscribe_timer_interrupt)(uint8_t interrupt_bit, int *interrupt_id);
11 11

  
12
void (timer_int_handler)(void);
13

  
12 14
uint32_t (timer_get_no_interrupts)(void);
13 15

  
14 16
#endif //TIMER_H_INCLUDED
proj/libs/timer/src/timer.c
2 2

  
3 3
#include "timer.h"
4 4

  
5
#define TIMER_FREQ     1193182                                                          /**< @brief clock frequency for timer in PC and AT */
6
#define TIMER_MIN_FREQ (TIMER_FREQ/UINT16_MAX) + ((TIMER_FREQ % UINT16_MAX) ? 1 : 0)    /**< @brief mininum frequency for timer */
5
//#define TIMER_FREQ     1193182                                                          /**< @brief clock frequency for timer in PC and AT */
6
//#define TIMER_MIN_FREQ (TIMER_FREQ/UINT16_MAX) + ((TIMER_FREQ % UINT16_MAX) ? 1 : 0)    /**< @brief mininum frequency for timer */
7 7

  
8 8
/* I/O port addresses */
9 9

  
10
#define TIMER_0    0x40         /**< @brief Timer 0 count register */
11
#define TIMER_1    0x41         /**< @brief Timer 1 count register */
12
#define TIMER_2    0x42         /**< @brief Timer 2 count register */
13
#define TIMER_CTRL 0x43         /**< @brief Control register */
10
//#define TIMER_0    0x40         /**< @brief Timer 0 count register */
11
//#define TIMER_1    0x41         /**< @brief Timer 1 count register */
12
//#define TIMER_2    0x42         /**< @brief Timer 2 count register */
13
//#define TIMER_CTRL 0x43         /**< @brief Control register */
14 14

  
15
#define SPEAKER_CTRL 0x61       /**< @brief Register for speaker control  */
15
//#define SPEAKER_CTRL 0x61       /**< @brief Register for speaker control  */
16 16

  
17 17
/* Timer control */
18 18

  
19 19
/* Timer selection: bits 7 and 6 */
20 20

  
21
#define TIMER_SEL0   0x00              /**< @brief Control Word for Timer 0 */
22
#define TIMER_SEL1   BIT(6)            /**< @brief Control Word for Timer 1 */
23
#define TIMER_SEL2   BIT(7)            /**< @brief Control Word for Timer 2 */
24
#define TIMER_RB_CMD (BIT(7) | BIT(6)) /**< @brief Read Back Command */
21
//#define TIMER_SEL0   0x00              /**< @brief Control Word for Timer 0 */
22
//#define TIMER_SEL1   BIT(6)            /**< @brief Control Word for Timer 1 */
23
//#define TIMER_SEL2   BIT(7)            /**< @brief Control Word for Timer 2 */
24
//#define TIMER_RB_CMD (BIT(7) | BIT(6)) /**< @brief Read Back Command */
25 25

  
26 26
/* Register selection: bits 5 and 4 */
27 27

  
28
#define TIMER_LSB     BIT(4)                    /**< @brief Initialize Counter LSB only */
29
#define TIMER_MSB     BIT(5)                    /**< @brief Initialize Counter MSB only */
30
#define TIMER_LSB_MSB (TIMER_LSB | TIMER_MSB)   /**< @brief Initialize LSB first and MSB afterwards */
31
#define TIMER_INMODE_MASK 0x30                  /**< @brief Mask for Timer Counter Mode */
32
#define TIMER_INMODE_POS  4                     /**< @brief Bit position of Timer Counter Mode */
28
//#define TIMER_LSB     BIT(4)                    /**< @brief Initialize Counter LSB only */
29
//#define TIMER_MSB     BIT(5)                    /**< @brief Initialize Counter MSB only */
30
//#define TIMER_LSB_MSB (TIMER_LSB | TIMER_MSB)   /**< @brief Initialize LSB first and MSB afterwards */
31
//#define TIMER_INMODE_MASK 0x30                  /**< @brief Mask for Timer Counter Mode */
32
//#define TIMER_INMODE_POS  4                     /**< @brief Bit position of Timer Counter Mode */
33 33

  
34 34
/* Operating mode: bits 3, 2 and 1 */
35 35

  
36
#define TIMER_SQR_WAVE (BIT(2) | BIT(1)) /**< @brief Mode 3: square wave generator */
37
#define TIMER_RATE_GEN BIT(2)            /**< @brief Mode 2: rate generator */
38
#define TIMER_MODE_MASK 0x0E             /**< @brief Mask for mode */
39
#define TIMER_MODE_POS  1                /**< @brief Position of smallest bit from mode */
40
#define TIMER_MODE_2ALT 0x6              /**< @brief Alternative notation for mode 2 */
41
#define TIMER_MODE_3ALT 0x7              /**< @brief Alternative notation for mode 3 */
42
#define TIMER_MODE_RED2 0x03             /**< @brief Reduce 3-bit mode to 2-bit mode */
36
//#define TIMER_SQR_WAVE (BIT(2) | BIT(1)) /**< @brief Mode 3: square wave generator */
37
//#define TIMER_RATE_GEN BIT(2)            /**< @brief Mode 2: rate generator */
38
//#define TIMER_MODE_MASK 0x0E             /**< @brief Mask for mode */
39
//#define TIMER_MODE_POS  1                /**< @brief Position of smallest bit from mode */
40
//#define TIMER_MODE_2ALT 0x6              /**< @brief Alternative notation for mode 2 */
41
//#define TIMER_MODE_3ALT 0x7              /**< @brief Alternative notation for mode 3 */
42
//#define TIMER_MODE_RED2 0x03             /**< @brief Reduce 3-bit mode to 2-bit mode */
43 43

  
44 44
/* Counting mode: bit 0 */
45 45

  
46
#define TIMER_BCD 0x01 /**< @brief Count in BCD */
47
#define TIMER_BIN 0x00 /**< @brief Count in binary */
46
//#define TIMER_BCD 0x01 /**< @brief Count in BCD */
47
//#define TIMER_BIN 0x00 /**< @brief Count in binary */
48 48

  
49 49
/* READ-BACK COMMAND FORMAT */
50 50

  
51
#define TIMER_RB_COUNT_  BIT(5)         /**< @brief Read counter value on read-back (0 to activate) */
52
#define TIMER_RB_STATUS_ BIT(4)         /**< @brief Read status value on read-back (0 to activate) */
53
#define TIMER_RB_SEL(n)  BIT((n) + 1)   /**< @brief Select timer to read information from */
51
//#define TIMER_RB_COUNT_  BIT(5)         /**< @brief Read counter value on read-back (0 to activate) */
52
//#define TIMER_RB_STATUS_ BIT(4)         /**< @brief Read status value on read-back (0 to activate) */
53
//#define TIMER_RB_SEL(n)  BIT((n) + 1)   /**< @brief Select timer to read information from */
54 54

  
55 55
int (subscribe_timer_interrupt)(uint8_t interrupt_bit, int *interrupt_id) {
56 56
    if (interrupt_id == NULL) return 1;
......
59 59
}
60 60

  
61 61
static uint32_t no_interrupts = 0;
62
void (timer_int_handler)() {
62

  
63
void (timer_int_handler)(void) {
63 64
    no_interrupts++;
64 65
}
65 66

  
67

  
66 68
uint32_t (timer_get_no_interrupts)(void){ return no_interrupts; }
proj/libs/uart/include/uart.h
57 57

  
58 58
int nctp_send(size_t num, uint8_t* ptr[], size_t sz[]);
59 59

  
60
int nctp_ih_err;
60
int (nctp_get_ih_error)(void);
61 61
void nctp_ih(void);
62 62

  
63 63
#endif //UART_H_INCLUDED
proj/libs/uart/src/uart.c
365 365
    return SUCCESS;
366 366
}
367 367

  
368
int nctp_ih_err = SUCCESS;
368
static int nctp_ih_err = SUCCESS;
369
int (nctp_get_ih_error)(void){ return nctp_ih_err; }
369 370
void nctp_ih(void){
370 371
    uint8_t iir;
371 372
    if((nctp_ih_err = uart_get_iir(COM1_ADDR, &iir))) return;
proj/libs/utils/include/utils.h
15 15
/**
16 16
 * @brief Gets the most significant byte of a 16-bit variable
17 17
 * @param val 16-bit variable
18
 * @param lsb Pointer to a 8-bit variable to store the value of the MSB
18
 * @param msb Pointer to a 8-bit variable to store the value of the MSB
19 19
 * @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
20 20
 */
21 21
int(util_get_MSB)(uint16_t val, uint8_t *msb);
......
42 42
 * @param b     Second value
43 43
 * @return  The minimum of the two values
44 44
 */
45
int32_t min(int32_t a, int32_t b);
45
int16_t min16(int16_t a, int16_t b);
46
uint16_t umin16(uint16_t a, uint16_t b);
47
int32_t min32(int32_t a, int32_t b);
48
double  dmin (double  a, double  b);
46 49

  
47 50
/**
48 51
 * @brief Gets the maximum value out of two values.
......
50 53
 * @param b     Second value
51 54
 * @return  The maximum of the two values
52 55
 */
53
int32_t max(int32_t a, int32_t b);
56
int16_t max16(int16_t a, int16_t b);
57
uint16_t umax16(uint16_t a, uint16_t b);
58
int32_t max32(int32_t a, int32_t b);
59
double  dmax (double  a, double  b);
54 60

  
55
/**
56
 * @brief Gets the minimum value out of two doubles.
57
 * @param a     First value
58
 * @param b     Second value
59
 * @return  The minimum of the two values
60
 */
61
double min_d(double a, double b);
61
double dabs(double a);
62 62

  
63
/**
64
 * @brief Gets the maximum value out of two doubles.
65
 * @param a     First value
66
 * @param b     Second value
67
 * @return  The maximum of the two values
68
 */
69
double max_d(double a, double b);
63
int deq(double a, double b);
70 64

  
71

  
72
double abs_d(double a);
73

  
74

  
75 65
#endif //UTILS_H_INCLUDED
proj/libs/utils/include/xpm_utils.h
1 1
#ifndef XMP_UTILS_H_INCLUDED
2 2
#define XMP_UTILS_H_INCLUDED
3 3

  
4
void xpm_save_as_xpm2(const char **p, const char *s);
4
void xpm_save_as_xpm2(const char* const* p, const char *s);
5 5

  
6 6
char** xpm_load_xpm2(const char *s);
7 7

  
proj/libs/utils/src/utils.c
7 7

  
8 8
int(util_get_LSB)(uint16_t val, uint8_t *lsb) {
9 9
    if (lsb == NULL) return NULL_PTR;
10
    *lsb = val;
10
    *lsb = (uint8_t)val;
11 11
    return SUCCESS;
12 12
}
13 13

  
......
21 21
    if(value == NULL) return NULL_PTR;
22 22
    uint32_t n = 0;
23 23
    if(sys_inb(port, &n)) return READ_ERROR;
24
    *value = n;
24
    *value = (uint8_t)n;
25 25
    return SUCCESS;
26 26
}
27 27

  
......
31 31
    return SUCCESS;
32 32
}
33 33

  
34
int32_t min(int32_t a, int32_t b){ return (b < a ? b : a); }
35
int32_t max(int32_t a, int32_t b){ return (a < b ? b : a); }
34
int16_t min16(int16_t a, int16_t b){ return (b < a ? b : a); }
35
uint16_t umin16(uint16_t a, uint16_t b){ return (b < a ? b : a); }
36
int32_t min32(int32_t a, int32_t b){ return (b < a ? b : a); }
37
double  dmin (double  a, double  b){ return (b < a ? b : a); }
36 38

  
37
double min_d(double a, double b){ return (b < a ? b : a); }
38
double max_d(double a, double b){ return (a < b ? b : a); }
39
double abs_d(double a)          { return (a < 0 ? -a: a); }
39
int16_t max16(int16_t a, int16_t b){ return (a < b ? b : a); }
40
uint16_t umax16(uint16_t a, uint16_t b){ return (a < b ? b : a); }
41
int32_t max32(int32_t a, int32_t b){ return (a < b ? b : a); }
42
double  dmax (double  a, double  b){ return (a < b ? b : a); }
43

  
44
double dabs(double a)          { return (a < 0 ? -a: a); }
45

  
46
int deq(double a, double b){ return (dabs(a-b) < 1e-10 ? true : false); }
proj/libs/utils/src/xpm_utils.c
8 8
#include <stdlib.h>
9 9
#include <string.h>
10 10

  
11
void xpm_save_as_xpm2(const char **p, const char *s){
11
void xpm_save_as_xpm2(const char* const* p, const char *s){
12 12
    FILE *f = fopen(s, "w");
13 13
    int w, h, num_colors, chars_per_pixel;
14 14
    sscanf(p[0], "%d %d %d %d", &w, &h, &num_colors, &chars_per_pixel);
......
22 22
    FILE *f = fopen(fpath, "r");
23 23
    if(f == NULL) return NULL;
24 24
    size_t len = 1024; char *line_buf = malloc(len*sizeof(char));
25
    int sz;
25
    ssize_t sz;
26 26

  
27 27
    char **ret = NULL;
28 28

  
29
    int w, h, num_colors, chars_per_pixel;
29
    unsigned w, h, num_colors, chars_per_pixel;
30 30

  
31 31
    sz = getline(&line_buf, &len, f);{
32 32
        sscanf(line_buf, "%d %d %d %d", &w, &h, &num_colors, &chars_per_pixel);
33 33
        ret = malloc((1+num_colors+h)*sizeof(char*));
34 34
    }
35
    ret[0] = malloc((sz+1)*sizeof(char)); if(ret[0] == NULL){ free(ret); return NULL; }
35
    ret[0] = malloc(((unsigned)sz+1)*sizeof(char)); if(ret[0] == NULL){ free(ret); return NULL; }
36 36
    strcpy(ret[0], line_buf);
37 37

  
38
    for(int i = 1; i < 1+num_colors+h; ++i){
38
    for(size_t i = 1; i < 1+num_colors+h; ++i){
39 39
        sz = getline(&line_buf, &len, f);
40
        ret[i] = malloc((sz+1)*sizeof(char));
40
        ret[i] = malloc(((unsigned)sz+1)*sizeof(char));
41 41
        if(ret[i] == NULL){
42
            for(int j = 0; j < i; ++j)
42
            for(size_t j = 0; j < i; ++j)
43 43
                free(ret[i]);
44 44
            free(ret);
45 45
            return NULL;
......
48 48
        ret[i][sz-1] = '\0';
49 49
    }
50 50
    fclose(f); f = NULL;
51
    free(line_buf); line_buf = NULL;
51 52
    return ret;
52 53
}
proj/src/ent.c
13 13
#define GREEN_HEALTH_COLOR      0x009900
14 14

  
15 15
static double scale = 1.0;
16
static int16_t x_origin = 0;
17
static int16_t y_origin = 0;
16
static double x_origin = 0;
17
static double y_origin = 0;
18 18

  
19 19
void (ent_set_scale) (double n){ scale = n; }
20 20
void (ent_set_origin)(double x, double y){ x_origin = x; y_origin = y; }
......
91 91
double  (gunner_get_angle)          (const gunner_t *p){ return sprite_get_angle(p->dude); }
92 92
double  (gunner_get_health)         (const gunner_t *p){ return p->health; }
93 93
double  (gunner_get_curr_health)    (const gunner_t *p){ return p->current_health; }
94
int16_t (gunner_get_x_screen)       (const gunner_t *p){ return (p->x-x_origin)*scale; }
95
int16_t (gunner_get_y_screen)       (const gunner_t *p){ return (p->y-y_origin)*scale; }
94
int16_t (gunner_get_x_screen)       (const gunner_t *p){ return (int16_t)((p->x-x_origin)*scale); }
95
int16_t (gunner_get_y_screen)       (const gunner_t *p){ return (int16_t)((p->y-y_origin)*scale); }
96 96
uint16_t (gunner_get_type)          (const gunner_t *p){ return p->type; }
97 97
int     (gunner_get_team)           (const gunner_t *p){ return p->team; }
98 98
void (gunner_draw)(gunner_t *p){
......
107 107
    gunner_draw_health(p);
108 108
}
109 109
void (gunner_draw_health)(const gunner_t *p) {
110
    int16_t w = sprite_get_w(p->dude);
111
    int16_t h = sprite_get_h(p->dude);
112
    double x = gunner_get_x_screen(p) - w/2;
113
    double y = gunner_get_y_screen(p) - h/2 - 10;
110
    const uint16_t w = sprite_get_w(p->dude);
111
    const uint16_t h = sprite_get_h(p->dude);
112
    int16_t x = gunner_get_x_screen(p) - w/2;
113
    int16_t y = gunner_get_y_screen(p) - h/2 - 10;
114 114
    double curr_health = gunner_get_curr_health(p);
115 115
    double health = gunner_get_health(p);
116 116
    double perc = curr_health/health;
117
    rectangle_set_pos(p->green_bar, x, y); rectangle_set_size(p->green_bar, (int16_t)(w*perc), 10);
118
    rectangle_set_pos(p->red_bar, x+(int16_t)(w*perc), y); rectangle_set_size(p->red_bar, (int16_t)(w*(1-perc)), 10);
117
    rectangle_set_pos(p->green_bar, x, y); rectangle_set_size(p->green_bar, (uint16_t)(w*perc), 10);
118
    rectangle_set_pos(p->red_bar, x+(int16_t)(w*perc), y); rectangle_set_size(p->red_bar, (uint16_t)(w*(1.0-perc)), 10);
119 119
    char buf[20]; sprintf(buf, "%d/%d", (int)p->current_health, (int)p->health);
120 120
    text_set_string(p->txt, buf);
121 121
    text_set_pos(p->txt, x+w/2, y+10/2);
......
165 165
double  (bullet_get_y)       (const bullet_t *p){ return p->y; }
166 166
double  (bullet_get_vx)      (const bullet_t *p){ return p->vx; }
167 167
double  (bullet_get_vy)      (const bullet_t *p){ return p->vy; }
168
int16_t (bullet_get_x_screen)(const bullet_t *p){ return (p->x-x_origin)*scale; }
169
int16_t (bullet_get_y_screen)(const bullet_t *p){ return (p->y-y_origin)*scale; }
168
int16_t (bullet_get_x_screen)(const bullet_t *p){ return (int16_t)((p->x-x_origin)*scale); }
169
int16_t (bullet_get_y_screen)(const bullet_t *p){ return (int16_t)((p->y-y_origin)*scale); }
170 170
double  (bullet_get_damage)  (const bullet_t *p){ return p->damage; }
171 171
void    (bullet_set_damage)  (bullet_t *p, double damage) {
172 172
    if (damage < 0) damage = 0;
......
262 262
    ret->collide_gunner = malloc(W*H*sizeof(uint8_t));
263 263
    if(ret->collide_gunner == NULL){ map_dtor(ret); return NULL; }
264 264
    for(size_t i = 0; i < W*H; ++i){
265
        int16_t x = i%W, y = i/W;
265
        uint16_t x = i%W, y = (uint16_t)(i/W);
266 266
        ret->collide_gunner[i] = (map_collides_gunner_pos(ret, x, y, 36) ? 1 : 0);
267 267
    }
268 268

  
......
284 284
    free(p->visited);
285 285
    free(p);
286 286
}
287
int16_t (map_get_x_screen)(const map_t *p){ return (-x_origin)*scale; }
288
int16_t (map_get_y_screen)(const map_t *p){ return (-y_origin)*scale; }
289
int16_t (map_get_width)   (const map_t *p){ return sprite_get_w(p->background); }
290
int16_t (map_get_height)  (const map_t *p){ return sprite_get_h(p->background); }
287
static int16_t (map_get_x_screen)(const map_t *p){ return (int16_t)((-x_origin)*scale); }
288
static int16_t (map_get_y_screen)(const map_t *p){ return (int16_t)((-y_origin)*scale); }
289
uint16_t (map_get_width)   (const map_t *p){ return sprite_get_w(p->background); }
290
uint16_t (map_get_height)  (const map_t *p){ return sprite_get_h(p->background); }
291 291
int (map_collides_point)(const map_t *p, double x, double y){
292 292
    const uint16_t w = sprite_get_w(p->background), h = sprite_get_h(p->background);
293
    int16_t x_ = x, y_ = y;
293
    int16_t x_ = (int16_t)x, y_ = (int16_t)y;
294 294
    if(x_ < 0 || w <= x_ || y_ < 0 || h <= y_) return 0;
295
    uint32_t pos = x_ + y_*w;
296
    return p->collide[pos];
295
    int32_t pos = x_ + y_*w;
296
    if(0 <= pos && pos < w*h) return p->collide[pos];
297
    else return false;
297 298
}
298 299
int (map_collides_gunner)(const map_t *p, const gunner_t *shooter) {
299
    double radius = max(sprite_get_w(shooter->dude), sprite_get_h(shooter->dude))/2.0;
300
    double radius = dmax(sprite_get_w(shooter->dude), sprite_get_h(shooter->dude))/2.0;
300 301
    return map_collides_gunner_pos(p, gunner_get_x(shooter), gunner_get_y(shooter), radius);
301 302
}
302 303
int (map_make_dijkstra)(map_t *p, double x_, double y_){
......
347 348
}
348 349

  
349 350
int (map_collides_bullet)(const map_t *p, const bullet_t *bull){
350
    double radius = max(sprite_get_w(bull->b), sprite_get_h(bull->b))/2.0;
351
    double radius = dmax(sprite_get_w(bull->b), sprite_get_h(bull->b))/2.0;
351 352
    double bullet_x = bullet_get_x(bull);
352 353
    double bullet_y = bullet_get_y(bull);
353 354
    for (double x = -radius; x < radius; x += 1){
......
361 362
int (gunner_collides_bullet)(const gunner_t *shooter, const bullet_t *bull){
362 363
    if(bull->shooter == shooter) return false;
363 364

  
364
    double shooter_radius = max(sprite_get_w(shooter->dude), sprite_get_h(shooter->dude))/2.0;
365
    double shooter_radius = dmax(sprite_get_w(shooter->dude), sprite_get_h(shooter->dude))/2.0;
365 366
    double shooter_x = gunner_get_x(shooter);
366 367
    double shooter_y = gunner_get_y(shooter);
367 368

  
368
    double bullet_radius = max(sprite_get_w(bull->b), sprite_get_h(bull->b))/2.0;
369
    double bullet_radius = dmax(sprite_get_w(bull->b), sprite_get_h(bull->b))/2.0;
369 370
    double bullet_x = bullet_get_x(bull);
370 371
    double bullet_y = bullet_get_y(bull);
371 372

  
......
389 390

  
390 391
int (gunner_collides_gunner)(const gunner_t *shooter1, const gunner_t *shooter2) {
391 392
    if (shooter1 == shooter2) return false;
392
    double shooter1_radius = max(sprite_get_w(shooter1->dude), sprite_get_h(shooter1->dude))/2.0;
393
    double shooter2_radius = max(sprite_get_w(shooter2->dude), sprite_get_h(shooter2->dude))/2.0;
393
    double shooter1_radius = dmax(sprite_get_w(shooter1->dude), sprite_get_h(shooter1->dude))/2.0;
394
    double shooter2_radius = dmax(sprite_get_w(shooter2->dude), sprite_get_h(shooter2->dude))/2.0;
394 395
    double distance = distance_gunners(shooter1, shooter2);
395 396
    return distance <= shooter1_radius+shooter2_radius;
396 397
}
proj/src/interrupts_func.c
191 191
    (*ih[handler])();
192 192
}
193 193

  
194
void (timer_manager)() {
195

  
196
}
197

  
198
void (mouse_manager)() {
199

  
200
}
201

  
202
int get_interrupts_vector(uint32_t *p){
194
int get_interrupts_vector(uint64_t *p){
203 195
    int r;
204 196

  
205 197
    *p = 0;
proj/src/proj.c
38 38

  
39 39
    lcf_set_language("EN-US");
40 40

  
41
    //lcf_trace_calls("/home/lcom/labs/proj/trace.txt");
41
    lcf_trace_calls("/home/lcom/labs/proj/trace.txt");
42 42

  
43
    //lcf_log_output("/home/lcom/labs/proj/output.txt");
43
    lcf_log_output("/home/lcom/labs/proj/output.txt");
44 44

  
45 45
    if (lcf_start(argc, argv)) return 1;
46 46

  
......
113 113

  
114 114
    /// loop stuff
115 115
    int click = 0;
116
    uint32_t int_vector = 0;
116
    uint64_t int_vector = 0;
117 117
    int good = true;
118 118
    while (good) {
119 119
        /* Get a request message. */
......
145 145
                    case KBC_IRQ:
146 146
                    if (keyboard_get_scancode()[0] == ESC_BREAK_CODE) good = false;
147 147
                    case MOUSE_IRQ:
148
                    if (counter_mouse_ih >= 3) {
149
                        mouse_parse_packet(packet_mouse_ih, &pp);
148
                    if (mouse_get_counter_mouse_ih() >= 3) {
149
                        mouse_parse_packet(mouse_get_packet_mouse_ih(), &pp);
150 150
                        update_mouse(&pp);
151 151
                        if (!click) click = last_lb ^ keys->lb_pressed && keys->lb_pressed;
152 152
                        last_lb = keys->lb_pressed;
153
                        counter_mouse_ih = 0;
153
                        mouse_set_counter_mouse_ih(0);
154 154
                    }
155 155
                    break;
156 156
                    case COM1_IRQ: nctp_ih(); break;
......
224 224

  
225 225
    /// loop stuff
226 226
    int click = 0;
227
    uint32_t int_vector = 0;
227
    uint64_t int_vector = 0;
228 228
    int good = true;
229 229
    while (good) {
230 230
        /* Get a request message. */
......
255 255
                    case KBC_IRQ:
256 256
                    if (keyboard_get_scancode()[0] == ESC_BREAK_CODE) good = false;
257 257
                    case MOUSE_IRQ:
258
                    if (counter_mouse_ih >= 3) {
259
                        mouse_parse_packet(packet_mouse_ih, &pp);
258
                    if (mouse_get_counter_mouse_ih() >= 3) {
259
                        mouse_parse_packet(mouse_get_packet_mouse_ih(), &pp);
260 260
                        update_mouse(&pp);
261 261
                        if (!click) click = last_lb ^ keys->lb_pressed && keys->lb_pressed;
262 262
                        last_lb = keys->lb_pressed;
263
                        counter_mouse_ih = 0;
263
                        mouse_set_counter_mouse_ih(0);
264 264
                    }
265 265
                    break;
266 266
                    case COM1_IRQ: nctp_ih(); break;
......
310 310
    struct packet pp;
311 311
    keys_t *keys = get_key_presses();
312 312
    /// loop stuff
313
    uint32_t int_vector = 0;
313
    uint64_t int_vector = 0;
314 314
    int good = true;
315 315
    int state = 0; // -1 for remote win, 0 for draw, 1 for host win
316 316
    list_node_t *p1, *p2; // player states
......
369 369
                    }
370 370
                    break;
371 371
                    case MOUSE_IRQ:
372
                    if (counter_mouse_ih >= 3) {
373
                        mouse_parse_packet(packet_mouse_ih, &pp);
372
                    if (mouse_get_counter_mouse_ih() >= 3) {
373
                        mouse_parse_packet(mouse_get_packet_mouse_ih(), &pp);
374 374
                        update_mouse(&pp);
375 375
                        if (last_lb ^ keys->lb_pressed && keys->lb_pressed)
376 376
                        shoot_bullet(shooter1, bullet_list, bsp_bullet);
377 377
                        last_lb = keys->lb_pressed;
378
                        counter_mouse_ih = 0;
378
                        mouse_set_counter_mouse_ih(0);
379 379
                    }
380 380
                    break;
381 381

  
......
446 446
    keys_t *keys = get_key_presses();
447 447

  
448 448
    /// loop stuff
449
    uint32_t int_vector = 0;
449
    uint64_t int_vector = 0;
450 450
    int good = true;
451 451
    while (good) {
452 452
        if ((r = get_interrupts_vector(&int_vector))) return r;
......
510 510
                    }
511 511
                    break;
512 512
                    case MOUSE_IRQ:
513
                    if (counter_mouse_ih >= 3) {
514
                        mouse_parse_packet(packet_mouse_ih, &pp);
513
                    if (mouse_get_counter_mouse_ih() >= 3) {
514
                        mouse_parse_packet(mouse_get_packet_mouse_ih(), &pp);
515 515
                        update_mouse(&pp);
516 516
                        if (last_lb ^ keys->lb_pressed && keys->lb_pressed) {
517 517
                            bullet_info->new_bullet = true;
518 518
                            hltp_send_bullet_info(bullet_info);
519 519
                        }
520 520
                        last_lb = keys->lb_pressed;
521
                        counter_mouse_ih = 0;
521
                        mouse_set_counter_mouse_ih(0);
522 522
                    }
523 523
                    break;
524 524

  
......
567 567

  
568 568
    /// loop stuff
569 569
    int click = 0;
570
    uint32_t int_vector = 0;
570
    uint64_t int_vector = 0;
571 571
    int good = true;
572 572
    while (good) {
573 573
        /* Get a request message. */
......
598 598
                    case KBC_IRQ:
599 599
                    if (keyboard_get_scancode()[0] == ESC_BREAK_CODE) good = false;
600 600
                    case MOUSE_IRQ:
601
                    if (counter_mouse_ih >= 3) {
602
                        mouse_parse_packet(packet_mouse_ih, &pp);
601
                    if (mouse_get_counter_mouse_ih() >= 3) {
602
                        mouse_parse_packet(mouse_get_packet_mouse_ih(), &pp);
603 603
                        update_mouse(&pp);
604 604
                        if (!click) click = last_lb ^ keys->lb_pressed && keys->lb_pressed;
605 605
                        last_lb = keys->lb_pressed;
606
                        counter_mouse_ih = 0;
606
                        mouse_set_counter_mouse_ih(0);
607 607
                    }
608 608
                    break;
609 609
                    case COM1_IRQ: nctp_ih(); break;
......
646 646
    keys_t *keys = get_key_presses();
647 647

  
648 648
    /// loop stuff
649
    uint32_t int_vector = 0;
649
    uint64_t int_vector = 0;
650 650
    int good = true;
651 651
    while (good) {
652 652
        /* Get a request message. */
......
689 689
                    }
690 690
                    break;
691 691
                    case MOUSE_IRQ:
692
                    if (counter_mouse_ih >= 3) {
693
                        mouse_parse_packet(packet_mouse_ih, &pp);
692
                    if (mouse_get_counter_mouse_ih() >= 3) {
693
                        mouse_parse_packet(mouse_get_packet_mouse_ih(), &pp);
694 694
                        update_mouse(&pp);
695 695
                        if (last_lb ^ keys->lb_pressed && keys->lb_pressed)
696 696
                        shoot_bullet(shooter1, bullet_list, bsp_bullet);
697 697
                        last_lb = keys->lb_pressed;
698
                        counter_mouse_ih = 0;
698
                        mouse_set_counter_mouse_ih(0);
699 699

  
700 700
                    }
701 701
                    break;
......
750 750
    keys_t *keys = get_key_presses();
751 751

  
752 752
    /// loop stuff
753
    uint32_t int_vector = 0;
753
    uint64_t int_vector = 0;
754 754
    int good = true;
755 755
    int dead = false;
756 756

  
......
816 816
                    }
817 817
                    break;
818 818
                    case MOUSE_IRQ:
819
                    if (counter_mouse_ih >= 3) {
820
                        mouse_parse_packet(packet_mouse_ih, &pp);
819
                    if (mouse_get_counter_mouse_ih() >= 3) {
820
                        mouse_parse_packet(mouse_get_packet_mouse_ih(), &pp);
821 821
                        update_mouse(&pp);
822 822
                        if (last_lb ^ keys->lb_pressed && keys->lb_pressed)
823 823
                        shoot_bullet(shooter1, bullet_list, bsp_bullet);
824 824
                        last_lb = keys->lb_pressed;
825
                        counter_mouse_ih = 0;
825
                        mouse_set_counter_mouse_ih(0);
826 826

  
827 827
                    }
828 828
                    break;
......
944 944
}
945 945

  
946 946
/// loop stuff
947
uint32_t int_vector = 0;
947
uint64_t int_vector = 0;
948 948
int good = true;
949 949
while (good) {
950 950
    /* Get a request message. */
......
999 999
                sprintf(buffer2, "%d/%d", strlen(buffer), CHAT_MAX_SIZE);
1000 1000
                text_set_string(t_size, buffer2);
1001 1001
                case MOUSE_IRQ:
1002
                if (counter_mouse_ih >= 3) {
1003
                    mouse_parse_packet(packet_mouse_ih, &pp);
1002
                if (mouse_get_counter_mouse_ih() >= 3) {
1003
                    mouse_parse_packet(mouse_get_packet_mouse_ih(), &pp);
1004 1004
                    update_mouse(&pp);
1005
                    counter_mouse_ih = 0;
1005
                    mouse_set_counter_mouse_ih(0);
1006 1006
                }
1007 1007
                break;
1008 1008
                case COM1_IRQ: nctp_ih(); break;
proj/src/proj_func.c
297 297
static int16_t mouse_x = 0, mouse_y = 0;
298 298

  
299 299
void (update_mouse)(struct packet *p) {
300
    mouse_x = max(0, mouse_x + p->delta_x);
301
    mouse_x = min(mouse_x, graph_get_XRes() - 1);
300
    mouse_x = max16(0, mouse_x + p->delta_x);
301
    mouse_x = min16(mouse_x, graph_get_XRes() - 1);
302 302

  
303
    mouse_y = max(0, mouse_y - p->delta_y);
304
    mouse_y = min(mouse_y, graph_get_YRes() - 1);
303
    mouse_y = max16(0, mouse_y - p->delta_y);
304
    mouse_y = min16(mouse_y, graph_get_YRes() - 1);
305 305

  
306 306
    key_presses.lb_pressed = p->lb;
307 307
}
proj/Makefile
9 9
.PATH: ${.CURDIR}/libs/classes/src
10 10
.PATH: ${.CURDIR}/libs/utils/src
11 11

  
12
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 menu.c
12
SRCS= list.c queue.c graph.c kbc.c keyboard.c mouse.c utils.c timer.c interrupts_func.c fast_math.c xpm_utils.c ent.c rtc.c uart.c hltp.c makecode_map.c menu.c proj.c proj_func.c rectangle.c font.c
13 13
IPATHS=-I./include -I./libs/graph/include -I./libs/kbc/include -I./libs/rtc/include -I./libs/timer/include -I./libs/uart/include -I./libs/classes/include -I./libs/utils/include -I./maps -I./media/xpm
14 14

  
15
CPPFLAGS += -pedantic -Weverything ${IPATHS} -D LCOM_MACRO -D __LCOM_OPTIMIZED__
15
CPPFLAGS += -pedantic ${IPATHS} -D LCOM_MACRO -D __LCOM_OPTIMIZED__ #-Weverything
16 16

  
17 17

  
18 18
DPADD += ${LIBLCF}

Also available in: Unified diff