#include #include #include #include #include #include #include #include #include #include #include #include #include "isp1362.h" #include "isa290.h" #include "reg.h" #include "cheeyu.h" #include #include unsigned int audio_addr=1; unsigned int MasterToggle=5; char filename[MAXPATH]="\\you.wav"; long file_mod(char mode, unsigned int *sptr) { static FILE *stream; static factor=6; unsigned int toggle=MasterToggle; static signed int sbuf[2048]; static signed int tbuf[2048]; signed int cnt; signed int t_cnt; int handle; unsigned long songlength; unsigned long len_in_kb; unsigned long accu_L=0; unsigned long accu_R=0; static unsigned int avg_L; static unsigned int avg_R; struct ffblk ffblk; int done; int dir_cnt=0; char cur_dir[MAXDIR]; if(mode=='N') //New OPEN { e_box(320,200,580,320); //Look for default file first... if( (stream = fopen(filename,"rb"))!=NULL ) //default file found! { gotoxy(12,5); printf("Default wav file found!"); fclose(stream); } else //File not found... get filename from user { gotoxy(12,5); getcwd(cur_dir,MAXPATH); printf("Default wav file not found!"); gotoxy(12,6); printf("Searching for wave files in %s ",cur_dir); done = findfirst("*.wav",&ffblk,0); while ((!done)&&(dir_cnt<10)) { gotoxy(12,7+dir_cnt); printf("File : %s\n", ffblk.ff_name); done = findnext(&ffblk); dir_cnt++; } gotoxy(12,16); printf("Full path of file name to play: "); scanf("%s",filename); if( (stream = fopen(filename,"rb"))!=NULL ) //user file found! { gotoxy(12,17); printf("User input file found!"); fclose(stream); } else { gotoxy(12,17); printf("User input file NOT found! Exiting..."); getch(); exit(0); } } //================ handle = open(filename, O_RDONLY); songlength=filelength(handle); close(handle); len_in_kb=songlength/1024; stream = fopen(filename,"rb"); do { sbuf[cnt]=getw(stream); cnt++; } while(cnt<20); } if(mode=='O') //OPEN { handle = open(filename, O_RDONLY); songlength=filelength(handle); close(handle); len_in_kb=songlength/1024; if( (stream = fopen(filename,"rb"))==NULL ) { printf("\nFile open failed!!\n"); exit(0); } else { printf("\nFile Found and Opened! File Length is %ld Bytes (%ld KBytes)",songlength,len_in_kb); printf("\n"); do { sbuf[cnt]=getw(stream); cnt++; } while(cnt<20); } } if(mode=='C') //CLOSE { fclose(stream); } if(mode=='V') //Left Vol { return(avg_L); } if(mode=='U') //Right Vol { return(avg_R); } if(mode=='F') //CLOSE { return(len_in_kb); } if(mode=='L') //CLOSE { if(factor>= 0) {factor--;} } if(mode=='S') //CLOSE { if(factor<=15) {factor++;} } if(mode=='R') //READ { cnt=0; do { sbuf[cnt]=getw(stream); accu_L=accu_L+(abs)(sbuf[cnt]); cnt++; } while(cnt<(88*toggle)); avg_L=accu_L/(88*toggle); accu_L=0; cnt=0; do { tbuf[cnt]=getw(stream); accu_R=accu_R+(abs)(tbuf[cnt]); cnt++; } while(cnt<(88*toggle)); avg_R=accu_R/(88*toggle); accu_R=0; } /* if(mode=='R') //READ { cnt=0; do { sbuf[cnt]=getw(stream); accu_L=accu_L+(abs)(sbuf[cnt]); cnt++; } while(cnt<(88*toggle)); avg_L=accu_L/(88*toggle); cnt=0; do { tbuf[cnt]=getw(stream); accu_R=accu_R+(abs)(tbuf[cnt]); cnt++; } while(cnt<(88*toggle)); avg_R=accu_R/(88*toggle); accu_R=0; accu_L=0; } */ if(mode=='G') //GET { t_cnt=0; do { cnt=0; do { *(sptr+(92*t_cnt)+cnt+4)=(sbuf[cnt+(88*t_cnt)])>>factor; cnt++; } while(cnt<88); t_cnt++; } while(t_cnt>factor; cnt++; } while(cnt<88); t_cnt++; } while(t_cnt400) {lin_L=400;} if(lin_R>400) {lin_R=400;} if(lin_L>max_L) {max_L=lin_L;} if(lin_R>max_R) {max_R=lin_R;} if(p_L400) {lin_L=400;} if(lin_R>400) {lin_R=400;} if(lin_L>max_L) {max_L=lin_L;} if(lin_R>max_R) {max_R=lin_R;} p_L=lin_L; p_R=lin_R; } void send_sound_gui(int mode) { unsigned long lbuf; unsigned long fm; unsigned long status1; unsigned int start=6; unsigned int init_wait=500; unsigned int user_in; unsigned int TR=MasterToggle; unsigned int t_size=176; unsigned int Up_Int,b_status; unsigned int c_fm; unsigned int d_cnt=0; struct time ti; struct time tf; unsigned long f_fm; unsigned int ma_ptl_size; unsigned int tcnt; unsigned long l_cnt; unsigned long ending; unsigned long end_cnt; signed int target_f,current_f; signed int volume=10; signed int LV,RV; clrscr(); cleardevice(); w16(HcBufStatus,0x0000); file_mod('N',0); file_mod('R',0); ending=file_mod('F',0); ma_ptl_size=r16(HcPTLLen); clrscr(); cleardevice(); e_box(320,160,620,300); advlogo(); gotoxy(23,3); printf("Philips USB WavPlayer For ISP1362"); gotoxy(23,4); printf("================================="); gotoxy(13,5); printf("Wave File Size=%ld KBytes, Play Time = %2.1f Minutes",ending,((float)ending*1024)/(44100*60*4) ); end_cnt=(ending*1024)/(176*TR)-100; delay(200); //ISO Buffer Setting w16(HcPTLLen ,ma_ptl_size); w16(HcPTLTogRate , TR); w16(HcUpInt , 0xFFFF); w32(HcIntEnable , 0x000000FF); set_operational(); enable_port(); status1=r32(HcRhP2); e_box(135,150,180,100); gotoxy(9,8); printf("L :increase volume"); gotoxy(9,9); printf("S :decrease volume"); gotoxy(9,10); printf("X :stop playing"); gotoxy(9,11); printf("Current Vol: %2d",volume); fm=r32(HcFmNo); start=start+init_wait+(unsigned int)(fm&0xFFFF); file_mod('R',0); prepare_sound(0,start,ma_ptl_size,TR,t_size); prepare_sound(1,start,ma_ptl_size,TR,t_size); e_box(415,150,360,100); gotoxy(33,8); printf("Initial frame number is %6lX",fm); gotoxy(33,9); printf("Waiting for frame number %6X",start); do { fm=r32(HcFmNo); gotoxy(33,10); printf("Current Frame Number : %8lX",fm); } while((unsigned int)(fm&0xFFFF)!=(start-1)); gotoxy(33,10); printf("Kick Start ISO Engine... "); gettime(&ti); w16(HcBufStatus,0x0003); tcnt=2; l_cnt=2; do { user_in=read_key(0); if(user_in=='L') {if(volume<15) {file_mod('L',0); volume++;} } if(user_in=='S') {if(volume>0 ) {file_mod('S',0); volume--;} } gotoxy(9,11); printf("Current Vol: %2d ",volume); gotoxy(9,12); printf("Progress : %2d%",(l_cnt*100)/end_cnt); if(user_in=='X') {l_cnt=1000000; } LV=file_mod('V',0); RV=file_mod('U',0); if((l_cnt%10)==0) {v_ind(LV,RV,240);} //wait for PTL0 to be done.... do { fm=r32(HcFmNo); current_f=(unsigned int)(fm&0xFFFF); target_f =(start+(tcnt*TR)-TR); gotoxy(33,11); printf("Preparing ISO group %08ld @<%08lX>",l_cnt,fm); if((current_f-target_f)>100) {break;} if((target_f-current_f)>100) {break;} } while(current_f",l_cnt,fm); if((current_f-target_f)>100) {break;} if((target_f-current_f)>100) {break;} } while(current_f>8; addr_info(1,'W','O',iManufacturer); addr_info(1,'W','P',iProduct); mycode=get_control(rbuf,1,'H',addr_info(1,'R','P',0),1); { mycode=set_config(1,1); printf("\nSetting config of device 1 to config 2... %04X",mycode); set_interface(1,0,1); set_sound(1,1,0x0121,0x0300,0x0200,0x0001,0x0000); set_sound(1,1,0x0121,0x0500,0x0200,0x0001,0x0000); set_sound(1,1,0x0121,0x0201,0x0200,0x0002,0xF400); set_sound(1,1,0x0121,0x0202,0x0200,0x0002,0xF400); set_interface(1,0,1); set_interface(1,4,1); set_sound(1,1,0x0121,0x0201,0x0200,0x0002,0xF416); set_sound(1,1,0x0121,0x0202,0x0200,0x0002,0xF416); audio_addr=1; } } } if( (status&0x0001)!=0) //port 2 active { //Check port 2 for mouse mycode=get_control(rbuf,2,'D',0,2); printf("\nGetting device descriptor for device at port 2... "); printf("%04X",mycode); if(mycode==0x0300) { iManufacturer = rbuf[7]&0xFF; iProduct = (rbuf[7]&0xFF00)>>8; addr_info(2,'W','O',iManufacturer); addr_info(2,'W','P',iProduct); mycode=get_control(rbuf,2,'H',addr_info(2,'R','P',0),2); { mycode=set_config(2,1); printf("\nSetting config of device 2 to config 2... %04X",mycode); set_interface(2,0,2); set_sound(2,2,0x0121,0x0300,0x0200,0x0001,0x0000); set_sound(2,2,0x0121,0x0500,0x0200,0x0001,0x0000); set_sound(2,2,0x0121,0x0201,0x0200,0x0002,0xF400); set_sound(2,2,0x0121,0x0202,0x0200,0x0002,0xF400); set_interface(2,0,2); set_interface(2,4,2); set_sound(2,2,0x0121,0x0201,0x0200,0x0002,0xF416); set_sound(2,2,0x0121,0x0202,0x0200,0x0002,0xF416); audio_addr=2; } } } getch(); gui(); send_sound_gui(mode); close_gui(); }