Project

General

Profile

Revision 140

idk why it works but well

View differences:

lab5.c
452 452
    message msg;
453 453
    /// cycle
454 454
    uint16_t x = xi, y = yi;
455
    int i = Nt-1; //Nt-1
455
    sprite_set_pos(sp,x,y);
456
    clear_screen();
457
    sprite_draw(sp); printf("\nnew frame %d %d", x, y);
456 458
    int good = 1;
457 459
    while (good) {
458 460
        /* Get a request message. */
......
464 466
            switch (_ENDPOINT_P(msg.m_source)) {
465 467
                case HARDWARE: /* hardware interrupt notification */
466 468
                    if (msg.m_notify.interrupts & timer_irq) { /* subscribed interrupt */
467
                        if(no_interrupts == 0){
468
                            i = (i+1)%Nt;
469
                            if(i == 0){
470
                                //if(vx) draw_rectangle(min(x-v,x),y         , abs(v)         , sprite_get_h(sp), 0);
471
                                //if(vy) draw_rectangle(x         ,min(y-v,y),sprite_get_w(sp), abs(v)          , 0);
472
                                clear_screen();
473
                                sprite_set_pos(sp,x,y);
474
                                sprite_draw(sp); printf("\nnew frame");
475
                                vx = (vx > 0 ? min(vx, xf-x) : max(vx, xf-x) );
476
                                vy = (vy > 0 ? min(vy, yf-y) : max(vy, yf-y) );
477
                                x += vx;
478
                                y += vy;
479
                            }
469
                        timer_int_handler();
470
                        if(no_interrupts == Nt*ticks_per_frame){
471

  
472
                            //if(vx) draw_rectangle(min(x-v,x),y         , abs(v)         , sprite_get_h(sp), 0);
473
                            //if(vy) draw_rectangle(x         ,min(y-v,y),sprite_get_w(sp), abs(v)          , 0);
474

  
475
                            vx = (vx > 0 ? min(vx, xf-x) : max(vx, xf-x) );
476
                            vy = (vy > 0 ? min(vy, yf-y) : max(vy, yf-y) );
477
                            x += vx;
478
                            y += vy;
479
                            sprite_set_pos(sp,x,y);
480
                            clear_screen();
481
                            sprite_draw(sp); printf("\nnew frame %d %d", x, y);
482

  
483

  
484
                            no_interrupts = 0;
480 485
                        }
481
                        timer_int_handler();
482
                        no_interrupts %= ticks_per_frame;
483 486
                    }
484 487
                    if (msg.m_notify.interrupts & kbc_irq) { /* subscribed interrupt */
485 488
                        kbc_ih();

Also available in: Unified diff