Project

General

Profile

Revision 304

simplified interrupts

View differences:

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);
25

  
24 26
#endif /* end of include guard: INTERRUPTS_FUNC_H_INCLUDED */
proj/src/interrupts_func.c
198 198
void (mouse_manager)() {
199 199

  
200 200
}
201

  
202
int get_interrupts_vector(uint32_t *p){
203
    int r;
204

  
205
    *p = 0;
206

  
207
    int ipc_status;
208
    message msg;
209
    if ((r = driver_receive(ANY, &msg, &ipc_status)) != 0) {
210
        printf("driver_receive failed with %d", r);
211
        return OTHER_ERROR;
212
    }
213
    if (is_ipc_notify(ipc_status)) { /* received notification */
214
        switch (_ENDPOINT_P(msg.m_source)) {
215
            case HARDWARE: /* hardware interrupt notification */
216
                *p = msg.m_notify.interrupts;
217
                return SUCCESS;
218
            default: break; /* no other notifications expected: do nothing */
219
        }
220
    }
221
    return SUCCESS;
222
}
proj/src/proj.c
214 214
    keys_t *keys = get_key_presses();
215 215

  
216 216
    /// loop stuff
217
    int ipc_status;
218
    message msg;
219

  
220 217
    int click = 0;
221

  
218
    uint32_t int_vector = 0;
222 219
    int good = true;
223

  
224 220
    while (good) {
225 221
        /* Get a request message. */
226
        if ((r = driver_receive(ANY, &msg, &ipc_status)) != 0) {
227
            printf("driver_receive failed with %d", r);
228
            continue;
229
        }
230
        if (is_ipc_notify(ipc_status)) { /* received notification */
231
            switch (_ENDPOINT_P(msg.m_source)) {
232
                case HARDWARE: /* hardware interrupt notification */
233
                    for (uint32_t i = 0, n = 1; i < 32; i++, n <<= 1) {
234
                        if (msg.m_notify.interrupts & n) {
235
                            interrupt_handler(i);
236
                            switch (i) {
237
                            case TIMER0_IRQ:
222
        if((r = get_interrupts_vector(&int_vector))) return r;
223
        for (uint32_t i = 0, n = 1; i < 32; i++, n <<= 1) {
224
            if (int_vector & n) {
225
                interrupt_handler(i);
226
                switch (i) {
227
                case TIMER0_IRQ:
238 228

  
239
                                graph_clear_screen();
240
                                switch(menu_update_state(main_menu, click)){
241
                                    case -1: break;
242
                                    case  0: campaign(); break;
243
                                    case  1: zombies(); break;
244
                                    case  2: good = false; break;
245
                                }
246
                                menu_draw(main_menu);
229
                    graph_clear_screen();
230
                    switch(menu_update_state(main_menu, click)){
231
                        case -1: break;
232
                        case  0: campaign(); break;
233
                        case  1: zombies(); break;
234
                        case  2: good = false; break;
235
                    }
236
                    menu_draw(main_menu);
247 237

  
248
                                click = 0;
238
                    click = 0;
249 239

  
250
                                sprite_set_pos(sp_crosshair, *get_mouse_X(), *get_mouse_Y());
251
                                sprite_draw(sp_crosshair);
252
                                graph_draw();
240
                    sprite_set_pos(sp_crosshair, *get_mouse_X(), *get_mouse_Y());
241
                    sprite_draw(sp_crosshair);
242
                    graph_draw();
253 243

  
254
                                break;
255
                            case KBC_IRQ:
256
                                if ((scancode[0]) == ESC_BREAK_CODE) good = false;
257
                            case MOUSE_IRQ:
258
                                if (counter_mouse_ih >= 3) {
259
                                    mouse_parse_packet(packet_mouse_ih, &pp);
260
                                    update_mouse(&pp);
261
                                    if (!click) click = last_lb ^ keys->lb_pressed && keys->lb_pressed;
262
                                    last_lb = keys->lb_pressed;
263
                                    counter_mouse_ih = 0;
264
                                }
265
                                break;
266
                            case COM1_IRQ: nctp_ih(); break;
267
                            }
268
                        }
244
                    break;
245
                case KBC_IRQ:
246
                    if ((scancode[0]) == ESC_BREAK_CODE) good = false;
247
                case MOUSE_IRQ:
248
                    if (counter_mouse_ih >= 3) {
249
                        mouse_parse_packet(packet_mouse_ih, &pp);
250
                        update_mouse(&pp);
251
                        if (!click) click = last_lb ^ keys->lb_pressed && keys->lb_pressed;
252
                        last_lb = keys->lb_pressed;
253
                        counter_mouse_ih = 0;
269 254
                    }
270

  
271 255
                    break;
272
                default:
273
                    break; /* no other notifications expected: do nothing */
256
                case COM1_IRQ: nctp_ih(); break;
257
                }
274 258
            }
275
        } else { /* received standart message, not a notification */
276
            /* no standart message expected: do nothing */
277 259
        }
278 260
    }
279 261

  
......
311 293
   keys_t *keys = get_key_presses();
312 294

  
313 295
    /// loop stuff
314
    int ipc_status;
315
    message msg;
296
    uint32_t int_vector = 0;
316 297
    int good = true;
317

  
318 298
    while (good) {
319
       /* Get a request message. */
320
       if ((r = driver_receive(ANY, &msg, &ipc_status)) != 0) {
321
           printf("driver_receive failed with %d", r);
322
           continue;
323
       }
324
       if (is_ipc_notify(ipc_status)) { /* received notification */
325
           switch (_ENDPOINT_P(msg.m_source)) {
326
               case HARDWARE: /* hardware interrupt notification */
327
                   for (uint32_t i = 0, n = 1; i < 32; i++, n <<= 1) {
328
                       if (msg.m_notify.interrupts & n) {
329
                           interrupt_handler(i);
330
                           switch (i) {
331
                           case TIMER0_IRQ:
299
        /* Get a request message. */
300
        if((r = get_interrupts_vector(&int_vector))) return r;
301
        for (uint32_t i = 0, n = 1; i < 32; i++, n <<= 1) {
302
           if (int_vector & n) {
303
               interrupt_handler(i);
304
               switch (i) {
305
               case TIMER0_IRQ:
332 306

  
333
                               if (no_interrupts % 60 == 0) timer_update(in_game_timer);
334
                               update_movement(map1, shooter1, keys, shooter_list);
307
                   if (no_interrupts % 60 == 0) timer_update(in_game_timer);
308
                   update_movement(map1, shooter1, keys, shooter_list);
335 309

  
336
                               update_game_state(map1, shooter_list, bullet_list);
310
                   update_game_state(map1, shooter_list, bullet_list);
337 311

  
338
                               //update_scale();
339
                               double angle = get_mouse_angle(shooter1);
340
                               gunner_set_angle(shooter1, angle - M_PI_2);
312
                   //update_scale();
313
                   double angle = get_mouse_angle(shooter1);
314
                   gunner_set_angle(shooter1, angle - M_PI_2);
341 315

  
342
                               ent_set_origin(gunner_get_x(shooter1)-ent_get_XLength()/2.0,
343
                                              gunner_get_y(shooter1)-ent_get_YLength()/2.0);
316
                   ent_set_origin(gunner_get_x(shooter1)-ent_get_XLength()/2.0,
317
                                  gunner_get_y(shooter1)-ent_get_YLength()/2.0);
344 318

  
345
                               graph_clear_screen();
346
                               map_draw   (map1);
347
                               bullet_draw_list(bullet_list);
348
                               gunner_draw_list(shooter_list);
319
                   graph_clear_screen();
320
                   map_draw   (map1);
321
                   bullet_draw_list(bullet_list);
322
                   gunner_draw_list(shooter_list);
349 323

  
350
                               text_draw(in_game_timer->text);
324
                   text_draw(in_game_timer->text);
351 325

  
352
                               sprite_set_pos(sp_crosshair, *get_mouse_X(), *get_mouse_Y());
353
                               sprite_draw(sp_crosshair);
354
                               graph_draw();
326
                   sprite_set_pos(sp_crosshair, *get_mouse_X(), *get_mouse_Y());
327
                   sprite_draw(sp_crosshair);
328
                   graph_draw();
355 329

  
356
                               break;
357
                           case KBC_IRQ:
358
                               if ((scancode[0]) == ESC_BREAK_CODE) {
359
                                   good = false;
360
                                   // reset game
361
                                   while(list_size(bullet_list) > 0){
362
                                       bullet_t *p = (bullet_t*)list_erase(bullet_list, list_begin(bullet_list));
363
                                       bullet_dtor(p);
364
                                   }
365
                                   list_node_t *it = list_begin(shooter_list);
366
                                   while (it != list_end(shooter_list)) {
367
                                       gunner_t *p = *(gunner_t**)list_node_val(it);
368
                                       get_random_spawn(map1, p);
369
                                       gunner_set_curr_health(p, gunner_get_health(p));
370
                                       it = list_node_next(it);
371
                                   }
372
                                   timer_reset(in_game_timer);
373
                               }
374
                               break;
375
                           case MOUSE_IRQ:
376
                               if (counter_mouse_ih >= 3) {
377
                                   mouse_parse_packet(packet_mouse_ih, &pp);
378
                                   update_mouse(&pp);
379
                                   if (last_lb ^ keys->lb_pressed && keys->lb_pressed)
380
                                       shoot_bullet(shooter1, bullet_list, bsp_bullet);
381
                                   last_lb = keys->lb_pressed;
382
                                   counter_mouse_ih = 0;
383

  
384
                               }
385
                               break;
386
                           case COM1_IRQ: nctp_ih(); break;
387
                           }
330
                   break;
331
               case KBC_IRQ:
332
                   if ((scancode[0]) == ESC_BREAK_CODE) {
333
                       good = false;
334
                       // reset game
335
                       while(list_size(bullet_list) > 0){
336
                           bullet_t *p = (bullet_t*)list_erase(bullet_list, list_begin(bullet_list));
337
                           bullet_dtor(p);
388 338
                       }
339
                       list_node_t *it = list_begin(shooter_list);
340
                       while (it != list_end(shooter_list)) {
341
                           gunner_t *p = *(gunner_t**)list_node_val(it);
342
                           get_random_spawn(map1, p);
343
                           gunner_set_curr_health(p, gunner_get_health(p));
344
                           it = list_node_next(it);
345
                       }
346
                       timer_reset(in_game_timer);
389 347
                   }
390 348
                   break;
391
               default:
392
                   break; /* no other notifications expected: do nothing */
349
               case MOUSE_IRQ:
350
                   if (counter_mouse_ih >= 3) {
351
                       mouse_parse_packet(packet_mouse_ih, &pp);
352
                       update_mouse(&pp);
353
                       if (last_lb ^ keys->lb_pressed && keys->lb_pressed)
354
                           shoot_bullet(shooter1, bullet_list, bsp_bullet);
355
                       last_lb = keys->lb_pressed;
356
                       counter_mouse_ih = 0;
357

  
358
                   }
359
                   break;
360
               case COM1_IRQ: nctp_ih(); break;
361
               }
393 362
           }
394
       } else { /* received standart message, not a notification */
395
           /* no standart message expected: do nothing */
396
       }
363
        }
397 364
    }
398 365

  
399 366
    while(list_size(shooter_list) > 0){
......
442 409
   keys_t *keys = get_key_presses();
443 410

  
444 411
    /// loop stuff
445
    int ipc_status;
446
    message msg;
412
    uint32_t int_vector = 0;
447 413
    int good = true;
448 414
    int dead = false;
449 415

  
450 416
    int health = 50;
451 417

  
452 418
    while (good && !dead) {
453
       /* Get a request message. */
454
       if ((r = driver_receive(ANY, &msg, &ipc_status)) != 0) {
455
           printf("driver_receive failed with %d", r);
456
           continue;
457
       }
458
       if (is_ipc_notify(ipc_status)) { /* received notification */
459
           switch (_ENDPOINT_P(msg.m_source)) {
460
               case HARDWARE: /* hardware interrupt notification */
461
                   for (uint32_t i = 0, n = 1; i < 32; i++, n <<= 1) {
462
                       if (msg.m_notify.interrupts & n) {
463
                           interrupt_handler(i);
464
                           switch (i) {
465
                           case TIMER0_IRQ: //printf("L463\n");
419
        /* Get a request message. */
420
        if((r = get_interrupts_vector(&int_vector))) return r;
421
        for (uint32_t i = 0, n = 1; i < 32; i++, n <<= 1) {
422
            if (int_vector & n) {
423
               interrupt_handler(i);
424
               switch (i) {
425
               case TIMER0_IRQ: //printf("L463\n");
466 426

  
467
                               if (no_interrupts % 60 == 0) timer_update(in_game_timer);//printf("L465\n");
468
                               update_movement(map1, shooter1, keys, shooter_list);//printf("L466\n");
427
                   if (no_interrupts % 60 == 0) timer_update(in_game_timer);//printf("L465\n");
428
                   update_movement(map1, shooter1, keys, shooter_list);//printf("L466\n");
469 429

  
470
                               update_game_state(map1, shooter_list, bullet_list);//printf("L468\n");
430
                   update_game_state(map1, shooter_list, bullet_list);//printf("L468\n");
471 431

  
472
                               if(list_find(shooter_list, shooter1) == list_end(shooter_list)){ printf("YOU DIED\n");
473
                                   good = false;
474
                                   dead = true;
475
                                   break;
476
                               } //printf("L489\n");
432
                   if(list_find(shooter_list, shooter1) == list_end(shooter_list)){
433
                       good = false;
434
                       dead = true;
435
                       break;
436
                   } //printf("L489\n");
477 437

  
478
                               //update_scale();
479
                               double angle = get_mouse_angle(shooter1);//printf("L471\n");
480
                               gunner_set_angle(shooter1, angle - M_PI_2); //printf("L472\n");
438
                   //update_scale();
439
                   double angle = get_mouse_angle(shooter1);//printf("L471\n");
440
                   gunner_set_angle(shooter1, angle - M_PI_2); //printf("L472\n");
481 441

  
482
                               ent_set_origin(gunner_get_x(shooter1)-ent_get_XLength()/2.0,
483
                                              gunner_get_y(shooter1)-ent_get_YLength()/2.0);
442
                   ent_set_origin(gunner_get_x(shooter1)-ent_get_XLength()/2.0,
443
                                  gunner_get_y(shooter1)-ent_get_YLength()/2.0);
484 444

  
485
                               while(list_size(shooter_list) < ZOMBIES_NUM){
486
                                   gunner_t *zombie = gunner_ctor(bsp_zombie, bsp_nothing, gunner_meelee, 3);
487
                                   gunner_set_health(zombie, health);
488
                                   gunner_set_curr_health(zombie, health);
489
                                   health *= ZOMBIE_HEALTH_FACTOR;
490
                                   get_random_spawn(map1, zombie);
491
                                   list_push_back(shooter_list, zombie);
492
                               } //printf("L484\n");
445
                   while(list_size(shooter_list) < ZOMBIES_NUM){
446
                       gunner_t *zombie = gunner_ctor(bsp_zombie, bsp_nothing, gunner_meelee, 3);
447
                       gunner_set_health(zombie, health);
448
                       gunner_set_curr_health(zombie, health);
449
                       health *= ZOMBIE_HEALTH_FACTOR;
450
                       get_random_spawn(map1, zombie);
451
                       list_push_back(shooter_list, zombie);
452
                   } //printf("L484\n");
493 453

  
494
                               graph_clear_screen();
495
                               map_draw   (map1);
496
                               bullet_draw_list(bullet_list);
497
                               gunner_draw_list(shooter_list);
454
                   graph_clear_screen();
455
                   map_draw   (map1);
456
                   bullet_draw_list(bullet_list);
457
                   gunner_draw_list(shooter_list);
498 458

  
499
                               text_draw(in_game_timer->text);
459
                   text_draw(in_game_timer->text);
500 460

  
501
                               sprite_set_pos(sp_crosshair, *get_mouse_X(), *get_mouse_Y());
502
                               sprite_draw(sp_crosshair);
503
                               graph_draw(); //printf("L508\n");
461
                   sprite_set_pos(sp_crosshair, *get_mouse_X(), *get_mouse_Y());
462
                   sprite_draw(sp_crosshair);
463
                   graph_draw(); //printf("L508\n");
504 464

  
505
                               break;
506
                           case KBC_IRQ:
507
                               if ((scancode[0]) == ESC_BREAK_CODE) {
508
                                   good = false;
509
                                   // reset game
510
                                   while(list_size(bullet_list) > 0){
511
                                       bullet_t *p = (bullet_t*)list_erase(bullet_list, list_begin(bullet_list));
512
                                       bullet_dtor(p);
513
                                   }
514
                                   list_node_t *it = list_begin(shooter_list);
515
                                   while (it != list_end(shooter_list)) {
516
                                       gunner_t *p = *(gunner_t**)list_node_val(it);
517
                                       get_random_spawn(map1, p);
518
                                       gunner_set_curr_health(p, gunner_get_health(p));
519
                                       it = list_node_next(it);
520
                                   }
521
                                   timer_reset(in_game_timer);
522
                               }
523
                               break;
524
                           case MOUSE_IRQ:
525
                               if (counter_mouse_ih >= 3) {
526
                                   mouse_parse_packet(packet_mouse_ih, &pp);
527
                                   update_mouse(&pp);
528
                                   if (last_lb ^ keys->lb_pressed && keys->lb_pressed)
529
                                       shoot_bullet(shooter1, bullet_list, bsp_bullet);
530
                                   last_lb = keys->lb_pressed;
531
                                   counter_mouse_ih = 0;
532

  
533
                               }
534
                               break;
535
                           case COM1_IRQ: nctp_ih(); break;
536
                           }
465
                   break;
466
               case KBC_IRQ:
467
                   if ((scancode[0]) == ESC_BREAK_CODE) {
468
                       good = false;
469
                       // reset game
470
                       while(list_size(bullet_list) > 0){
471
                           bullet_t *p = (bullet_t*)list_erase(bullet_list, list_begin(bullet_list));
472
                           bullet_dtor(p);
537 473
                       }
474
                       list_node_t *it = list_begin(shooter_list);
475
                       while (it != list_end(shooter_list)) {
476
                           gunner_t *p = *(gunner_t**)list_node_val(it);
477
                           get_random_spawn(map1, p);
478
                           gunner_set_curr_health(p, gunner_get_health(p));
479
                           it = list_node_next(it);
480
                       }
481
                       timer_reset(in_game_timer);
538 482
                   }
539 483
                   break;
540
               default:
541
                   break; /* no other notifications expected: do nothing */
484
               case MOUSE_IRQ:
485
                   if (counter_mouse_ih >= 3) {
486
                       mouse_parse_packet(packet_mouse_ih, &pp);
487
                       update_mouse(&pp);
488
                       if (last_lb ^ keys->lb_pressed && keys->lb_pressed)
489
                           shoot_bullet(shooter1, bullet_list, bsp_bullet);
490
                       last_lb = keys->lb_pressed;
491
                       counter_mouse_ih = 0;
492

  
493
                   }
494
                   break;
495
               case COM1_IRQ: nctp_ih(); break;
496
               }
542 497
           }
543
       } else { /* received standart message, not a notification */
544
           /* no standart message expected: do nothing */
545 498
       }
546 499
    }
547 500

  
......
654 607
    }
655 608

  
656 609
    /// loop stuff
657
    int ipc_status;
658
    message msg;
610
    uint32_t int_vector = 0;
659 611
    int good = true;
660 612
    while (good) {
661 613
        /* Get a request message. */
662
        if ((r = driver_receive(ANY, &msg, &ipc_status)) != 0) {
663
            printf("driver_receive failed with %d", r);
664
            continue;
665
        }
666
        if (is_ipc_notify(ipc_status)) { /* received notification */
667
            switch (_ENDPOINT_P(msg.m_source)) {
668
                case HARDWARE: /* hardware interrupt notification */
669
                    for (uint32_t i = 0, n = 1; i < 32; i++, n <<= 1) {
670
                        if (msg.m_notify.interrupts & n) {
671
                            interrupt_handler(i);
672
                            switch (i) {
673
                            case TIMER0_IRQ:
674
                                graph_clear_screen();
675
                                sprite_set_pos(sp_crosshair, *get_mouse_X(), *get_mouse_Y());
614
        if((r = get_interrupts_vector(&int_vector))) return r;
615
        for (uint32_t i = 0, n = 1; i < 32; i++, n <<= 1) {
616
            if (int_vector & n) {
617
                interrupt_handler(i);
618
                switch (i) {
619
                case TIMER0_IRQ:
620
                    graph_clear_screen();
621
                    sprite_set_pos(sp_crosshair, *get_mouse_X(), *get_mouse_Y());
676 622

  
677
                                rectangle_draw(r_buffer);
678
                                text_draw(t_buffer);
679
                                text_draw(t_size);
623
                    rectangle_draw(r_buffer);
624
                    text_draw(t_buffer);
625
                    text_draw(t_size);
680 626

  
681
                                rectangle_draw(r_text);
682
                                for(size_t i = 0; i < CHAT_MAX_NUM; ++i) text_draw(t_text[i]);
627
                    rectangle_draw(r_text);
628
                    for(size_t i = 0; i < CHAT_MAX_NUM; ++i) text_draw(t_text[i]);
683 629

  
684
                                sprite_draw(sp_crosshair);
685
                                graph_draw();
686
                                break;
687
                            case KBC_IRQ:
688
                                if      (scancode[0] == ESC_BREAK_CODE) good = false;
689
                                else if (scancode[0] == ENTER_MAKE_CODE) {
690
                                    hltp_send_string(buffer);
691
                                    char buffer2[CHAT_MAX_SIZE+3] = "> ";
692
                                    strncat(buffer2, buffer, strlen(buffer));
693
                                    for(size_t i = CHAT_MAX_NUM-1; i; --i)
694
                                        text_set_text(t_text[i], text_get_string(t_text[i-1]));
695
                                    text_set_text(t_text[0], buffer2);
696
                                    for(size_t i = 0; i < CHAT_MAX_NUM; ++i){
697
                                        if(text_get_string(t_text[i])[0] == '>'){
698
                                            text_set_pos(t_text[i], rectangle_get_x(r_text)+50, text_get_y(t_text[i]));
699
                                            text_set_halign(t_text[i], text_halign_left);
700
                                        }else{
701
                                            text_set_pos(t_text[i], rectangle_get_x(r_text)+rectangle_get_w(r_text)-50, text_get_y(t_text[i]));
702
                                            text_set_halign(t_text[i], text_halign_right);
703
                                        }
704
                                    }
705
                                    buffer[0] = '\0';
706
                                } else if(scancode[0] == BACKSPACE_MAKE_CODE){
707
                                    buffer[strlen(buffer)-1] = '\0';
708
                                } else {
709
                                    char c = map_makecode(scancode[0]);
710
                                    if (c == ERROR_CODE) break;
711
                                    if(strlen(buffer) < CHAT_MAX_SIZE) strncat(buffer, &c, 1);
712
                                    else                               printf("Char limit exceeded\n");
713
                                }
714
                                text_set_text(t_buffer, buffer);
715
                                char buffer2[20];
716
                                sprintf(buffer2, "%d/%d", strlen(buffer), CHAT_MAX_SIZE);
717
                                text_set_text(t_size, buffer2);
718
                            case MOUSE_IRQ:
719
                                if (counter_mouse_ih >= 3) {
720
                                    mouse_parse_packet(packet_mouse_ih, &pp);
721
                                    update_mouse(&pp);
722
                                    counter_mouse_ih = 0;
723
                                }
724
                                break;
725
                            case COM1_IRQ: nctp_ih(); break;
630
                    sprite_draw(sp_crosshair);
631
                    graph_draw();
632
                    break;
633
                case KBC_IRQ:
634
                    if      (scancode[0] == ESC_BREAK_CODE) good = false;
635
                    else if (scancode[0] == ENTER_MAKE_CODE) {
636
                        hltp_send_string(buffer);
637
                        char buffer2[CHAT_MAX_SIZE+3] = "> ";
638
                        strncat(buffer2, buffer, strlen(buffer));
639
                        for(size_t i = CHAT_MAX_NUM-1; i; --i)
640
                            text_set_text(t_text[i], text_get_string(t_text[i-1]));
641
                        text_set_text(t_text[0], buffer2);
642
                        for(size_t i = 0; i < CHAT_MAX_NUM; ++i){
643
                            if(text_get_string(t_text[i])[0] == '>'){
644
                                text_set_pos(t_text[i], rectangle_get_x(r_text)+50, text_get_y(t_text[i]));
645
                                text_set_halign(t_text[i], text_halign_left);
646
                            }else{
647
                                text_set_pos(t_text[i], rectangle_get_x(r_text)+rectangle_get_w(r_text)-50, text_get_y(t_text[i]));
648
                                text_set_halign(t_text[i], text_halign_right);
726 649
                            }
727 650
                        }
651
                        buffer[0] = '\0';
652
                    } else if(scancode[0] == BACKSPACE_MAKE_CODE){
653
                        buffer[strlen(buffer)-1] = '\0';
654
                    } else {
655
                        char c = map_makecode(scancode[0]);
656
                        if (c == ERROR_CODE) break;
657
                        if(strlen(buffer) < CHAT_MAX_SIZE) strncat(buffer, &c, 1);
658
                        else                               printf("Char limit exceeded\n");
728 659
                    }
660
                    text_set_text(t_buffer, buffer);
661
                    char buffer2[20];
662
                    sprintf(buffer2, "%d/%d", strlen(buffer), CHAT_MAX_SIZE);
663
                    text_set_text(t_size, buffer2);
664
                case MOUSE_IRQ:
665
                    if (counter_mouse_ih >= 3) {
666
                        mouse_parse_packet(packet_mouse_ih, &pp);
667
                        update_mouse(&pp);
668
                        counter_mouse_ih = 0;
669
                    }
729 670
                    break;
730
                default:
731
                    break; /* no other notifications expected: do nothing */
671
                case COM1_IRQ: nctp_ih(); break;
672
                }
732 673
            }
733
        } else { /* received standart message, not a notification */
734
            /* no standart message expected: do nothing */
735 674
        }
736 675
    }
737 676

  

Also available in: Unified diff