📄 song_task.lst
字号:
463 5 case KEY_SOUND:
464 5 song_snd_select(); /* select next sound control */
465 5 print_sound(); /* display selected sound icon */
466 5 print_sound_level(); /* display new level */
467 5 break;
468 5
469 5 case KEY_REPEAT:
470 5 song_loop = ~song_loop; /* display repeat or not */
471 5 print_repeat(song_loop);
472 5 break;
473 5
474 5 case KEY_STOP:
475 5 song_stop(); /* stop playing song */
476 5 Fclose();
477 5 song_state = SONG_STOP;
478 5 break;
479 5
480 5 default:
481 5 break;
482 5 }
483 4 gl_key_press = FALSE; /* ack key usage */
484 4 }
485 3 break;
486 3 }
487 2
488 2
C51 COMPILER V7.06 SONG_TASK 05/05/2005 12:12:04 PAGE 9
489 2 case SONG_NEW:
490 2 {
491 3 #if PLAYER_PLAY_MODE == PLAY_DISK
492 3 if (File_type() == FILE_DIR)
493 3 {
494 4 if (file_entry_dir(FILE_MP3 | FILE_DIR) == OK)
495 4 { /* mp3 or dir in sub-dir */
496 5 song_state = SONG_NEW; /* stay in same state */
497 5 }
498 4 else
499 4 { /* no mp3 or dir in sub-dir */
500 5 song_state = SONG_NEXT; /* select next */
501 5 }
502 4 }
503 3 else
504 3 { /* file is MP3 */
505 4 song_state = SONG_INIT; /* new song */
506 4 print_repeat(song_loop);
507 4 print_file_name(); /* display file name */
508 4 }
509 3 break;
510 3 #else /* PLAYER_MODE == PLAY_DIR */
song_state = SONG_INIT; /* new song */
print_repeat(song_loop);
print_file_name(); /* display file name */
break;
#endif
516 3 }
517 2
518 2 case SONG_NEXT:
519 2 {
520 3 disp_name_stop(); /* stop scrolling */
521 3 #if PLAYER_PLAY_MODE == PLAY_DISK
522 3 if (file_seek_next(FILE_MP3 | FILE_DIR, FALSE))/* next song or dir */
523 3 { /* mp3 or dir selected */
524 4 song_state = SONG_NEW;
525 4 }
526 3 else
527 3 { /* at end of dir */
528 4 if (File_goto_parent(FILE_MP3 | FILE_DIR) == OK)
529 4 { /* parent exists, point on dir */
530 5 song_state = SONG_NEXT; /* next will select next file */
531 5 }
532 4 else
533 4 { /* no parent: end of root dir */
534 5 if (loop)
535 5 {
536 6 song_state = SONG_NEW;
537 6 }
538 5 else
539 5 {
540 6 song_stop();
541 6 song_state = SONG_STOP;
542 6 }
543 5 }
544 4 }
545 3 break;
546 3 #else /* PLAYER_MODE == PLAY_DIR */
if (file_seek_next(FILE_MP3, loop)) /* select next song */
{ /* still some file to play */
song_state = SONG_NEW;
}
C51 COMPILER V7.06 SONG_TASK 05/05/2005 12:12:04 PAGE 10
else
{ /* end of dir: stop */
song_stop();
song_state = SONG_STOP;
}
break;
#endif
558 3 }
559 2
560 2 case SONG_PREV:
561 2 {
562 3 disp_name_stop(); /* stop scrolling */
563 3 #if PLAYER_PLAY_MODE == PLAY_DISK
564 3 while( song_state == SONG_PREV )
565 3 { /* prev song or dir */
566 4 if( !file_seek_prev(FILE_MP3 | FILE_DIR, FALSE))
567 4 { /* No mp3 or dir selected, at beginning of dir */
568 5 if (File_goto_parent(FILE_MP3 | FILE_DIR) != OK)
569 5 { /* no parent: beginning of root dir */
570 6 if (loop)
571 6 {
572 7 if(File_goto_last() != OK) /* goto to the end of dir */
573 7 { /* error system */
574 8 song_stop();
575 8 song_state = SONG_STOP;
576 8 }
577 7 }
578 6 else
579 6 { /* end of dir: stop */
580 7 song_stop();
581 7 song_state = SONG_STOP;
582 7 }
583 6 }
584 5 else
585 5 {
586 6 continue; /* goto to previous file in dir parent */
587 6 }
588 5 }
589 4
590 4 while (File_type() == FILE_DIR)
591 4 { /* file found is directory -> enter directory and goto last file */
592 5 if (file_entry_dir(FILE_MP3 | FILE_DIR) == OK)
593 5 { /* mp3 or dir in sub-dir */
594 6 if(File_goto_last() != OK) /* goto to the end of dir */
595 6 { /* error system */
596 7 song_stop();
597 7 song_state = SONG_STOP;
598 7 }
599 6 }
600 5 else
601 5 {
602 6 break; /* directory empty goto search previous file */
603 6 }
604 5 }
605 4
606 4 if (File_type() == FILE_MP3)
607 4 { /* mp3 file -> stop research previous file */
608 5 song_state = SONG_NEW;
609 5 }
610 4 /* HERE song_state == SONG_PREV, if select file is empty directory or not mp3 file */
611 4 }
612 3 break;
C51 COMPILER V7.06 SONG_TASK 05/05/2005 12:12:04 PAGE 11
613 3 #else /* PLAYER_MODE == PLAY_DIR */
if (file_seek_prev(FILE_MP3, loop)) /* select prev song */
{ /* still some file to play */
song_state = SONG_NEW;
}
else
{ /* beginning of dir: stop */
song_stop();
song_state = SONG_STOP;
}
break;
#endif
625 3 }
626 2
627 2
628 2 case SONG_STOP:
629 2 {
630 3 disp_end_of_play(); /* end of music... */
631 3 disp_clock_reset(); /* reset clock timer */
632 3 print_file_name(); /* display file name */
633 3 song_state = SONG_IDLE;
634 3 break;
635 3 }
636 2
637 2
638 2 case SONG_NO_SONG:
639 2 {
640 3 if (gl_key_press) /* a key is pressed? */
641 3 {
642 4 switch (gl_key)
643 4 {
644 5 case KEY_MEM:
645 5 mem_select_next(); /* select next memory */
646 5 song_state = SONG_START;
647 5 break;
648 5
649 5 case KEY_MODE:
650 5 mode_set_init(); /* exit from song task */
651 5 song_state = SONG_START;
652 5 break;
653 5 }
654 4 gl_key_press = FALSE; /* ack key usage */
655 4 }
656 3 else
657 3 { /* check card presence */
658 4 if (mem_check_card() == KO)
659 4 {
660 5 mem_select_next();
661 5 song_state = SONG_START; /* card has been unplugged */
662 5 }
663 4 }
664 3 break;
665 3 }
666 2
667 2
668 2 case SONG_ERROR:
669 2 {
670 3 song_stop(); /* stop playing song */
671 3 Fclose(); /* close opened file */
672 3 disp_clock_reset(); /* reset clock timer */
673 3 print_state_error(); /* display error icon */
674 3 disp_name_stop();
C51 COMPILER V7.06 SONG_TASK 05/05/2005 12:12:04 PAGE 12
675 3 song_state = SONG_IDLE;
676 3 break;
677 3 }
678 2 }
679 1 }
680
681
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 994 ----
CONSTANT SIZE = 34 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 1 1
IDATA SIZE = ---- ----
BIT SIZE = 1 1
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -