C51 COMPILER V7.06 SOUND 08/02/2005 13:30:04 PAGE 1 C51 COMPILER V7.06, COMPILATION OF MODULE SOUND OBJECT MODULE PLACED IN SOUND.OBJ COMPILER INVOKED BY: d:\Keil777\C51\BIN\C51.EXE SOUND.C BROWSE DEBUG OBJECTEXTEND stmt level source 1 #include 2 #include *** WARNING C318 IN LINE 2 OF SOUND.C: can't open file 'conio.h' 3 #include *** WARNING C318 IN LINE 3 OF SOUND.C: can't open file 'dos.h' 4 #include 5 #include *** WARNING C318 IN LINE 5 OF SOUND.C: can't open file 'bios.h' 6 #include *** WARNING C318 IN LINE 6 OF SOUND.C: can't open file 'mem.h' 7 #include *** WARNING C318 IN LINE 7 OF SOUND.C: can't open file 'graphics.h' 8 #include 9 #include *** WARNING C318 IN LINE 9 OF SOUND.C: can't open file 'io.h' 10 #include *** WARNING C318 IN LINE 10 OF SOUND.C: can't open file 'fcntl.h' 11 #include 12 #include *** WARNING C318 IN LINE 12 OF SOUND.C: can't open file 'dir.h' 13 14 #include "isp1362.h" 15 #include "isa290.h" 16 #include "reg.h" 17 #include "cheeyu.h" 18 #include *** WARNING C318 IN LINE 18 OF SOUND.C: can't open file 'fcntl.h' 19 #include *** WARNING C318 IN LINE 19 OF SOUND.C: can't open file 'io.h' 20 21 unsigned int audio_addr=1; 22 unsigned int MasterToggle=5; 23 24 char filename[MAXPATH]="\\you.wav"; *** ERROR C202 IN LINE 24 OF SOUND.C: 'MAXPATH': undefined identifier *** ERROR C136 IN LINE 24 OF SOUND.C: invalid dimension size: [0] 25 26 long file_mod(char mode, unsigned int *sptr) 27 { 28 1 static FILE *stream; *** ERROR C141 IN LINE 28 OF SOUND.C: syntax error near '*' 29 1 static factor=6; 30 1 unsigned int toggle=MasterToggle; 31 1 static signed int sbuf[2048]; 32 1 static signed int tbuf[2048]; 33 1 signed int cnt; 34 1 signed int t_cnt; 35 1 int handle; 36 1 unsigned long songlength; 37 1 unsigned long len_in_kb; 38 1 39 1 unsigned long accu_L=0; 40 1 unsigned long accu_R=0; 41 1 42 1 static unsigned int avg_L; C51 COMPILER V7.06 SOUND 08/02/2005 13:30:04 PAGE 2 43 1 static unsigned int avg_R; 44 1 45 1 struct ffblk ffblk; *** ERROR C230 IN LINE 45 OF SOUND.C: 'ffblk': unknown struct/union/enum tag 46 1 int done; 47 1 int dir_cnt=0; 48 1 49 1 char cur_dir[MAXDIR]; *** ERROR C202 IN LINE 49 OF SOUND.C: 'MAXDIR': undefined identifier *** ERROR C136 IN LINE 49 OF SOUND.C: invalid dimension size: [0] 50 1 51 1 if(mode=='N') //New OPEN 52 1 { 53 2 e_box(320,200,580,320); 54 2 55 2 //Look for default file first... 56 2 if( (stream = fopen(filename,"rb"))!=NULL ) //default file found! 57 2 { 58 3 gotoxy(12,5); 59 3 printf("Default wav file found!"); 60 3 fclose(stream); 61 3 } 62 2 63 2 else //File not found... get filename from user 64 2 { 65 3 gotoxy(12,5); 66 3 getcwd(cur_dir,MAXPATH); 67 3 printf("Default wav file not found!"); 68 3 gotoxy(12,6); 69 3 printf("Searching for wave files in %s ",cur_dir); 70 3 done = findfirst("*.wav",&ffblk,0); 71 3 while ((!done)&&(dir_cnt<10)) 72 3 { 73 4 gotoxy(12,7+dir_cnt); 74 4 printf("File : %s\n", ffblk.ff_name); 75 4 done = findnext(&ffblk); 76 4 dir_cnt++; 77 4 } 78 3 gotoxy(12,16); 79 3 printf("Full path of file name to play: "); 80 3 81 3 scanf("%s",filename); 82 3 if( (stream = fopen(filename,"rb"))!=NULL ) //user file found! 83 3 { 84 4 gotoxy(12,17); 85 4 printf("User input file found!"); 86 4 fclose(stream); 87 4 } 88 3 else 89 3 { 90 4 gotoxy(12,17); 91 4 printf("User input file NOT found! Exiting..."); 92 4 93 4 getch(); 94 4 exit(0); 95 4 } 96 3 } 97 2 //================ 98 2 99 2 handle = open(filename, O_RDONLY); 100 2 songlength=filelength(handle); 101 2 close(handle); C51 COMPILER V7.06 SOUND 08/02/2005 13:30:04 PAGE 3 102 2 len_in_kb=songlength/1024; 103 2 104 2 stream = fopen(filename,"rb"); 105 2 do 106 2 { 107 3 sbuf[cnt]=getw(stream); 108 3 cnt++; 109 3 } 110 2 while(cnt<20); 111 2 } 112 1 113 1 if(mode=='O') //OPEN 114 1 { 115 2 handle = open(filename, O_RDONLY); 116 2 songlength=filelength(handle); 117 2 close(handle); 118 2 len_in_kb=songlength/1024; 119 2 120 2 if( (stream = fopen(filename,"rb"))==NULL ) 121 2 { 122 3 printf("\nFile open failed!!\n"); 123 3 exit(0); 124 3 } 125 2 else 126 2 { 127 3 printf("\nFile Found and Opened! File Length is %ld Bytes (%ld KBytes)",songlength,len_in_kb); 128 3 printf("\n"); 129 3 do 130 3 { 131 4 sbuf[cnt]=getw(stream); 132 4 cnt++; 133 4 } 134 3 while(cnt<20); 135 3 136 3 } 137 2 } 138 1 139 1 if(mode=='C') //CLOSE 140 1 { 141 2 fclose(stream); 142 2 } 143 1 144 1 if(mode=='V') //Left Vol 145 1 { 146 2 return(avg_L); 147 2 } 148 1 149 1 if(mode=='U') //Right Vol 150 1 { 151 2 return(avg_R); 152 2 } 153 1 154 1 if(mode=='F') //CLOSE 155 1 { return(len_in_kb); } 156 1 157 1 if(mode=='L') //CLOSE 158 1 { if(factor>= 0) {factor--;} } 159 1 160 1 if(mode=='S') //CLOSE 161 1 { if(factor<=15) {factor++;} } 162 1 163 1 if(mode=='R') //READ C51 COMPILER V7.06 SOUND 08/02/2005 13:30:04 PAGE 4 164 1 { 165 2 cnt=0; 166 2 do 167 2 { 168 3 sbuf[cnt]=getw(stream); 169 3 accu_L=accu_L+(abs)(sbuf[cnt]); 170 3 cnt++; 171 3 } 172 2 while(cnt<(88*toggle)); 173 2 avg_L=accu_L/(88*toggle); 174 2 accu_L=0; 175 2 176 2 cnt=0; 177 2 do 178 2 { 179 3 tbuf[cnt]=getw(stream); 180 3 accu_R=accu_R+(abs)(tbuf[cnt]); 181 3 cnt++; 182 3 } 183 2 while(cnt<(88*toggle)); 184 2 185 2 avg_R=accu_R/(88*toggle); 186 2 accu_R=0; 187 2 } 188 1 189 1 /* 190 1 if(mode=='R') //READ 191 1 { 192 1 cnt=0; 193 1 do 194 1 { 195 1 sbuf[cnt]=getw(stream); 196 1 accu_L=accu_L+(abs)(sbuf[cnt]); 197 1 cnt++; 198 1 } 199 1 while(cnt<(88*toggle)); 200 1 201 1 avg_L=accu_L/(88*toggle); 202 1 203 1 cnt=0; 204 1 do 205 1 { 206 1 tbuf[cnt]=getw(stream); 207 1 accu_R=accu_R+(abs)(tbuf[cnt]); 208 1 cnt++; 209 1 } 210 1 while(cnt<(88*toggle)); 211 1 212 1 avg_R=accu_R/(88*toggle); 213 1 214 1 accu_R=0; 215 1 accu_L=0; 216 1 } 217 1 */ 218 1 if(mode=='G') //GET 219 1 { 220 2 t_cnt=0; 221 2 do 222 2 { 223 3 cnt=0; 224 3 do 225 3 { C51 COMPILER V7.06 SOUND 08/02/2005 13:30:04 PAGE 5 226 4 *(sptr+(92*t_cnt)+cnt+4)=(sbuf[cnt+(88*t_cnt)])>>factor; 227 4 cnt++; 228 4 } 229 3 while(cnt<88); 230 3 t_cnt++; 231 3 } 232 2 while(t_cnt>factor; 244 4 cnt++; 245 4 } 246 3 while(cnt<88); 247 3 t_cnt++; 248 3 } 249 2 while(t_cnt400) {lin_L=400;} 350 1 if(lin_R>400) {lin_R=400;} 351 1 if(lin_L>max_L) {max_L=lin_L;} 352 1 if(lin_R>max_R) {max_R=lin_R;} 353 1 354 1 if(p_L400) {lin_L=400;} 399 1 if(lin_R>400) {lin_R=400;} 400 1 if(lin_L>max_L) {max_L=lin_L;} 401 1 if(lin_R>max_R) {max_R=lin_R;} 402 1 403 1 p_L=lin_L; 404 1 p_R=lin_R; 405 1 } 406 407 void send_sound_gui(int mode) 408 { 409 1 unsigned long lbuf; C51 COMPILER V7.06 SOUND 08/02/2005 13:30:04 PAGE 8 410 1 unsigned long fm; 411 1 unsigned long status1; 412 1 unsigned int start=6; 413 1 unsigned int init_wait=500; 414 1 unsigned int user_in; 415 1 unsigned int TR=MasterToggle; 416 1 unsigned int t_size=176; 417 1 418 1 unsigned int Up_Int,b_status; 419 1 420 1 unsigned int c_fm; 421 1 unsigned int d_cnt=0; 422 1 423 1 struct time ti; 424 1 struct time tf; 425 1 unsigned long f_fm; 426 1 427 1 unsigned int ma_ptl_size; 428 1 429 1 unsigned int tcnt; 430 1 unsigned long l_cnt; 431 1 unsigned long ending; 432 1 unsigned long end_cnt; 433 1 434 1 signed int target_f,current_f; 435 1 signed int volume=10; 436 1 437 1 signed int LV,RV; 438 1 439 1 clrscr(); 440 1 cleardevice(); 441 1 w16(HcBufStatus,0x0000); 442 1 file_mod('N',0); 443 1 file_mod('R',0); 444 1 ending=file_mod('F',0); 445 1 ma_ptl_size=r16(HcPTLLen); 446 1 447 1 clrscr(); 448 1 cleardevice(); 449 1 e_box(320,160,620,300); 450 1 451 1 advlogo(); 452 1 453 1 gotoxy(23,3); 454 1 printf("Philips USB WavPlayer For ISP1362"); 455 1 gotoxy(23,4); 456 1 printf("================================="); 457 1 gotoxy(13,5); 458 1 printf("Wave File Size=%ld KBytes, Play Time = %2.1f Minutes",ending,((float)ending*1024)/(44100*60*4) ) -; 459 1 end_cnt=(ending*1024)/(176*TR)-100; 460 1 461 1 delay(200); 462 1 463 1 //ISO Buffer Setting 464 1 w16(HcPTLLen ,ma_ptl_size); 465 1 w16(HcPTLTogRate , TR); 466 1 w16(HcUpInt , 0xFFFF); 467 1 w32(HcIntEnable , 0x000000FF); 468 1 469 1 set_operational(); 470 1 C51 COMPILER V7.06 SOUND 08/02/2005 13:30:04 PAGE 9 471 1 enable_port(); 472 1 473 1 status1=r32(HcRhP2); 474 1 475 1 e_box(135,150,180,100); 476 1 gotoxy(9,8); 477 1 printf("L :increase volume"); 478 1 gotoxy(9,9); 479 1 printf("S :decrease volume"); 480 1 gotoxy(9,10); 481 1 printf("X :stop playing"); 482 1 gotoxy(9,11); 483 1 printf("Current Vol: %2d",volume); 484 1 485 1 fm=r32(HcFmNo); 486 1 start=start+init_wait+(unsigned int)(fm&0xFFFF); 487 1 file_mod('R',0); 488 1 prepare_sound(0,start,ma_ptl_size,TR,t_size); 489 1 prepare_sound(1,start,ma_ptl_size,TR,t_size); 490 1 491 1 e_box(415,150,360,100); 492 1 gotoxy(33,8); 493 1 printf("Initial frame number is %6lX",fm); 494 1 gotoxy(33,9); 495 1 printf("Waiting for frame number %6X",start); 496 1 497 1 do 498 1 { 499 2 fm=r32(HcFmNo); 500 2 gotoxy(33,10); 501 2 printf("Current Frame Number : %8lX",fm); 502 2 } 503 1 while((unsigned int)(fm&0xFFFF)!=(start-1)); 504 1 505 1 gotoxy(33,10); 506 1 printf("Kick Start ISO Engine... "); 507 1 508 1 gettime(&ti); 509 1 510 1 w16(HcBufStatus,0x0003); 511 1 512 1 tcnt=2; 513 1 l_cnt=2; 514 1 515 1 do 516 1 { 517 2 user_in=read_key(0); 518 2 519 2 if(user_in=='L') {if(volume<15) {file_mod('L',0); volume++;} } 520 2 if(user_in=='S') {if(volume>0 ) {file_mod('S',0); volume--;} } 521 2 gotoxy(9,11); 522 2 printf("Current Vol: %2d ",volume); 523 2 gotoxy(9,12); 524 2 printf("Progress : %2d%",(l_cnt*100)/end_cnt); 525 2 if(user_in=='X') {l_cnt=1000000; } 526 2 527 2 LV=file_mod('V',0); 528 2 RV=file_mod('U',0); 529 2 530 2 if((l_cnt%10)==0) {v_ind(LV,RV,240);} 531 2 532 2 //wait for PTL0 to be done.... C51 COMPILER V7.06 SOUND 08/02/2005 13:30:04 PAGE 10 533 2 do 534 2 { 535 3 fm=r32(HcFmNo); 536 3 current_f=(unsigned int)(fm&0xFFFF); 537 3 target_f =(start+(tcnt*TR)-TR); 538 3 gotoxy(33,11); 539 3 printf("Preparing ISO group %08ld @<%08lX>",l_cnt,fm); 540 3 541 3 if((current_f-target_f)>100) 542 3 {break;} 543 3 if((target_f-current_f)>100) 544 3 {break;} 545 3 } 546 2 while(current_f",l_cnt,fm); 570 3 571 3 if((current_f-target_f)>100) 572 3 {break;} 573 3 if((target_f-current_f)>100) 574 3 {break;} 575 3 } 576 2 while(current_f>8; 715 3 716 3 addr_info(1,'W','O',iManufacturer); 717 3 addr_info(1,'W','P',iProduct); 718 3 C51 COMPILER V7.06 SOUND 08/02/2005 13:30:04 PAGE 13 719 3 mycode=get_control(rbuf,1,'H',addr_info(1,'R','P',0),1); 720 3 721 3 { 722 4 mycode=set_config(1,1); 723 4 printf("\nSetting config of device 1 to config 2... %04X",mycode); 724 4 725 4 set_interface(1,0,1); 726 4 set_sound(1,1,0x0121,0x0300,0x0200,0x0001,0x0000); 727 4 set_sound(1,1,0x0121,0x0500,0x0200,0x0001,0x0000); 728 4 set_sound(1,1,0x0121,0x0201,0x0200,0x0002,0xF400); 729 4 set_sound(1,1,0x0121,0x0202,0x0200,0x0002,0xF400); 730 4 set_interface(1,0,1); 731 4 732 4 set_interface(1,4,1); 733 4 set_sound(1,1,0x0121,0x0201,0x0200,0x0002,0xF416); 734 4 set_sound(1,1,0x0121,0x0202,0x0200,0x0002,0xF416); 735 4 audio_addr=1; 736 4 } 737 3 } 738 2 } 739 1 740 1 if( (status&0x0001)!=0) //port 2 active 741 1 { 742 2 //Check port 2 for mouse 743 2 mycode=get_control(rbuf,2,'D',0,2); 744 2 printf("\nGetting device descriptor for device at port 2... "); 745 2 printf("%04X",mycode); 746 2 if(mycode==0x0300) 747 2 { 748 3 iManufacturer = rbuf[7]&0xFF; 749 3 iProduct = (rbuf[7]&0xFF00)>>8; 750 3 751 3 addr_info(2,'W','O',iManufacturer); 752 3 addr_info(2,'W','P',iProduct); 753 3 754 3 mycode=get_control(rbuf,2,'H',addr_info(2,'R','P',0),2); 755 3 756 3 { 757 4 mycode=set_config(2,1); 758 4 printf("\nSetting config of device 2 to config 2... %04X",mycode); 759 4 760 4 set_interface(2,0,2); 761 4 set_sound(2,2,0x0121,0x0300,0x0200,0x0001,0x0000); 762 4 set_sound(2,2,0x0121,0x0500,0x0200,0x0001,0x0000); 763 4 set_sound(2,2,0x0121,0x0201,0x0200,0x0002,0xF400); 764 4 set_sound(2,2,0x0121,0x0202,0x0200,0x0002,0xF400); 765 4 set_interface(2,0,2); 766 4 767 4 set_interface(2,4,2); 768 4 set_sound(2,2,0x0121,0x0201,0x0200,0x0002,0xF416); 769 4 set_sound(2,2,0x0121,0x0202,0x0200,0x0002,0xF416); 770 4 771 4 audio_addr=2; 772 4 } 773 3 774 3 } 775 2 } 776 1 777 1 getch(); 778 1 779 1 gui(); 780 1 send_sound_gui(mode); C51 COMPILER V7.06 SOUND 08/02/2005 13:30:04 PAGE 14 781 1 close_gui(); 782 1 } C51 COMPILATION COMPLETE. 10 WARNING(S), 6 ERROR(S)