⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.i

📁 mp3量不要让站长把时间都花费在为您修正说明上。压缩包解压时不能有密码。系统会自动删除debug和release目录
💻 I
📖 第 1 页 / 共 5 页
字号:
								if(temp == '.'){i=2;mscnt = 0;continue;}

								 
								if(i==0)min = min*10 + (temp-0x30);
								else if(i==1)sec = sec*10 + (temp-0x30);
								else 
								{
									if(mscnt == 0)
										ms += (temp-0x30)*100;
									else if(mscnt == 1)
										ms += (temp - 0x30)*10;
									else ms += temp-0x30;
									mscnt ++;
								}							 
							}
							
							if(temp == ']')	 
							{
							
#line 682 "main.c"
													  
								if(LrcStruct_p == 0)
								{
									printf(("WARNING: Sorry! no more space for the rest tag, som lryic can't display!\r\n"));
									goto end;
								}

								 
								LrcStruct_p->time = (unsigned int)(min*60 + sec)*1000 + ms;
													  





								 
								if(LrcStructHead.sign)
								{
									if(LrcStruct_p->time<LrcStructHead.offset)LrcStruct_p->time = 0;
									else LrcStruct_p->time -= LrcStructHead.offset;
								}
								else LrcStruct_p->time += LrcStructHead.offset;
													  




								 
								LrcStruct_p->eeaddr = lrcaddr;
								temp = buffer[j];
								LrcStruct_p = LrcStruct_p->next;
                                                      
                                                      
								if(temp == '[');	 
								else			 
								{
									while(1)
									{
										temp = buffer[j++];
                                                                    




										 
										if(sector == totalsect && j == leftbytes + 1) goto end;	 
                                                                    
										if(j == 512)	 
										{
											if(part == (SectorsPerClust - 1))	 
											{
												
												p=FAT_NextCluster(p);
												if(p == 0x0fffffff || p == 0x0ffffff8 || (FAT32_Enable == 0 && p == 0xffff))
												{



													goto end;
												}
												part = 0;	 
												if(FAT_LoadPartCluster(p,part,buffer))
												{



													free(buffer);
													return 1;
												}
											}
											else 	 
											{
												part ++;	 
												if(FAT_LoadPartCluster(p,part,buffer))
												{



													free(buffer);
													return 1;
												}
											}
											sector ++;	 
											j = 0;		 
										}
										 
										 
										if(temp == 0x0d || temp == 0x0a)	 
										{
											
											
												lrcdatbuf[lrcaddr++] ='\0';
											
											
											
											break;
										}
										else 				 
										{
											
											
											
												
												
													lrcdatbuf[lrcaddr++] = temp;
												
												
												
											
										}
										if(lrcaddr == 4096)	 
										{
												
												
												printf(("\r\n\r\nWow! The lyric is so long, Buffer is run out, sorry!\r\n"));
												goto end;
										}
									}
								} 
							}
						}
					}
					else j++;	 
				}
				sector ++;	 
			}
			p=FAT_NextCluster(p);
			
			if(p == 0x0fffffff || p == 0x0ffffff8 || (FAT32_Enable == 0 && p == 0xffff))
			{



				break;
			}
		}
	
end:
		 
	
	
			lrcdatbuf[lrcaddr++] = '\0';
	
	
	

		 
		LrcStruct_p = LrcStruct_p - 1;
		LrcStruct_p->next = 0;

		 
		free(buffer);

		 
		 
#line 866 "main.c"




                     
#line 882 "main.c"
		 

		 		   
		LrcStruct_p_header = LrcStruct_p = LrcStructHead.header;
		while(1)
		{
			LrcStruct_p_header = LrcStruct_p;
			LrcStruct_p = LrcStruct_p->next;
			if(LrcStruct_p == 0)break;
			if(LrcStruct_p_header->time > LrcStruct_p->time)
			{
				LrcStruct_p_temp = LrcStructHead.header;
				j = 0;
				while(1)
				{   
					j++;
					if(LrcStruct_p_temp->time < LrcStruct_p->time)	 
					{
						LrcStruct_p_up = LrcStruct_p_temp;
						LrcStruct_p_temp = LrcStruct_p_temp->next;
						LrcStruct_p_down = LrcStruct_p_temp->next;
					}
					else										 
					{
                                                   
#line 913 "main.c"
                                                    
						if(j == 1)	 
						{
							LrcStructHead.header = LrcStruct_p;
							LrcStruct_p_header->next = LrcStruct_p ->next;
							LrcStruct_p ->next = LrcStruct_p_header;
							LrcStruct_p = LrcStruct_p_header;
						}
						else		 
						{
							LrcStruct_p_header->next = LrcStruct_p->next;
							LrcStruct_p_up->next = LrcStruct_p;
							LrcStruct_p->next = LrcStruct_p_temp;
							LrcStruct_p = LrcStruct_p_header;
                                                             



						}
						break;
					}
				}
			}
		}
		printf(("\r\n\r\nAnalyze complete!\r\n\r\nCode written by Bozai - 章其波"));
		printf(("\r\n*****************************************************\r\n"));

		 
#line 962 "main.c"

	}
	else lrc = 0;

	return 0;
}

#line 989 "main.c"

unsigned char PlayMusicwithKey()
{

	unsigned short keylen;			
	unsigned short count;			
	unsigned char i;				
	unsigned short j;				
	unsigned int p;				
	unsigned int totalsect;		
	unsigned short leftbytes;		
	unsigned char *buffer;			
	unsigned int sector;			
	unsigned char flag;				
	unsigned short vol= 0x2828;
	unsigned char vol_temp;
	unsigned short songs=1;			
	unsigned short songs_cnt = 0;					
	unsigned char mode=0;			
	unsigned int rand_val;
	
	unsigned char total[6];	 
	unsigned char current[12];	 
	unsigned short temp = totalsongs;

	unsigned char time[6];
	unsigned short decodetime;

	unsigned char volume[3];
	unsigned char min,sec;

        
	struct LrcStruct_s * LrcStruct_pp;
	unsigned short lrcaddr;

	 

	unsigned char lrcdata[52];
	unsigned char lrcDisFlag = 0;	 
	unsigned char lrcCnt = 0;		 

	ClearTrackInfo();

      
	printf(("\r\nCurrent mode : "));
	switch(mode)
	{
		case 0: printf(("repet all"));break;
		case 1:printf(("repet one"));break;
		case 2:printf(("shuffle"));break;
	}

	if(totalsongs==0)
	{
		lcdClrDisBuf();
		LCD_print12_P(0,20,("File not found!"));
		lcdUpdateDisplay();
		return 1; 
	}
	
 
	for(i=0;i<5;i++)
	{
		total[4-i] = temp%10;
		temp /= 10;
	}
	for(i=0;i<5;i++)
	{
		if(total[i])break;
	}
	for(j=0;j<5-i;j++)
	{
		total[j] = total[j+i] + 0x30;
	}
	total[j] = 0;
 
	vol_temp = 100-((0x2828 & 0x00ff)*100/255);
	volume[0] = vol_temp/10 + 0x30;
	volume[1] = vol_temp%10 +0x30;    
	volume[2] = '\0'; 
 

	
next:

	if(mode==2)
	{
		songs_cnt++;
		if(songs_cnt == totalsongs && totalsongs<1025)
		{
			ClearTrackInfo();
			songs_cnt = 0;
		}
		rand_val = (*((volatile unsigned long *) 0xE0004008));

		srand(rand_val);
		if(totalsongs>1024)
		{
			songs = (unsigned short)(((unsigned long)rand()/2147483 * (unsigned long)totalsongs)/1000)+1;
		}
		while(totalsongs<1025)
		{
			songs = (unsigned short)(((unsigned long)rand()/2147483 * (unsigned long)totalsongs)/1000)+1;
			
			if(SetTrack(songs) == 0)break;
		}	
	}
	count=0;
	flag=1;
	if(type != 3)VS1003B_Fill2048Zero();

	lrcDisFlag = 0;	 
	lrcCnt = 0;		 
	
	
	VS1003B_SoftReset();




	Search(&lrcaddr,&MusicInfo,&songs,&type);		


	 

	for(j=0;j<80/2;j++)			 
	{
		if(((unsigned short *)LongNameBuffer)[j] == 0)
		{
			((unsigned short *)LongNameBuffer)[j-4] = 0;
			break;
		}
	}
 
	time[0] = '0';
	time[1] = '0';
	time[2] = ':';
	time[3] = '0';
	time[4] = '0';
	time[5] = '\0';
	decodetime = -1;	 
 
	temp = songs;
	for(i=0;i<5;i++)
	{
		current[4-i] = temp%10;
		temp /= 10;
	}
	for(i=0;i<5;i++)
	{
		if(current[i])break;
	}
	for(j=0;j<5-i;j++)
	{
		current[j] = current[j+i] + 0x30;
	}
	current[j++] = '/';
	for(i=0;i<6;i++)
	{
		current[j+i] = total[i];
	}
 	
	lcdClrDisBuf();
	switch(type)
	{
		case 1:LCD_print12_P(0,0,("mp3"));break;
		case 2:LCD_print12_P(0,0,("wma"));break;
		case 3:LCD_print12_P(0,0,("mid"));break;
		case 4:LCD_print12_P(0,0,("wav"));break;
		default:break;
	}
	Print_ICON_12(18,0,Playing);
	LCD_print12(30,0,current);
	switch(mode)
	{
		case 0:Print_ICON_12(72,0,RepetAll);break;
		case 1:Print_ICON_12(72,0,RepetOne);break;
		case 2   :Print_ICON_12(72,0,Shuffle);break;
		default:break;
	}
 
	
	
	
	
 
	if(LongNameFlag)
	{
		if(HanziEnable)	 
		{
			buffer = malloc(80);
			if(buffer == 0)return 1;
			i = 0;
			j=0;
			while(1)
			{
				temp = ((unsigned short *)LongNameBuffer)[i++];
				 
				if(temp == 0 )
				{
					buffer[j++] = '.';
					while(1)	 
					{
						temp = ((unsigned short *)LongNameBuffer)[i++];
						if(temp == 0)break;	 
						buffer[j++] = (unsigned char)temp;
						
					}
					break;
				}
				else if (temp<0x80)
				{
					buffer[j++]=(unsigned char)temp;
				}
				else if(temp<0x4e00)
				{
					put16_little(&buffer[j],'?');
					j+=2;
				}
				else if(temp<0x9fa6)
				{
					if(Unicode_to_GBK((unsigned char *)&temp))return 1;
					put16_little(&buffer[j],temp);
					j+=2; 
				}
				else
				{
					put16_little(&buffer[j],'?');
					j+=2;
				}
			}
			buffer[j] = 0;
			LCD_print12(12,12,buffer);
			
		}
		else
		{
			LCD_print12_P(0,12,("-- --By bozai\nFirmware lost!"));
		}
	}
	else 	 
	{
		for(j=0;j<8;j++)
		{
			if(MusicInfo.deName[j]==0x20)break;
			LongNameBuffer[j]=MusicInfo.deName[j];
		}
		
		LongNameBuffer[j++]='.';
		count = j+3;
		for(count=0;count<3;count++)LongNameBuffer[j+count]=MusicInfo.deExtension[count];
		LongNameBuffer[j+count]='\0';
		if(HanziEnable)LCD_print12(12,12,LongNameBuffer);
		else
		{
			LCD_print12_P(0,12,("    -By bozai\nFirmware lost!"));
		}
	} 
 
	LCD_print12(30,36,time);
	LCD_print12(72,36,volume);
	Print_ICON_12(60,36,Speaker);
	Print_ICON_12(0,12,Music);	
	lcdUpdateDisplay();
 

	printf(("\r\nNow playing "));
	printf(("%s :"),current);
	if(LongNameFlag && HanziEnable)
	{
		printf(("%s"),buffer);
		free(buffer);
	}
	else
	{
		for(j=0;j<8;j++)
		{
			if(MusicInfo.deName[j]==0x20)break;
			uart0_putc(MusicInfo.deName[j]);
		}
        
		uart0_putc('.');
		for(j=0;j<3;j++)
		{
			
			uart0_putc(MusicInfo.deExtension[j]);
		}
	}
	printf("\r\n");
 



	LrcProc(LongNameBuffer,lrcaddr);			 
											 
											 

	LrcStruct_pp = LrcStructHead.header;

 

	p     = get16_little(MusicInfo.deStartCluster)+(((unsigned int)get16_little(MusicInfo.deHighClust))<<16);
		
	totalsect = get32_little(MusicInfo.deFileSize)/512; 
	leftbytes = get32_little(MusicInfo.deFileSize)%512; 
	i=0;
	sector=0;

	if(lrc && HanziEnable)		 
	{
		if(LrcStruct_pp->time/1000 == 0 && LrcStruct_pp != 0) 
		{
			
			decodetime = -1;	 
		}
		else
		{
			decodetime = 0;		 
		}
		LCD_print12_P(36,36,("    "));
		lcdClrDisBuf(); 
	}
    
	while(1)
	{
		keylen=0;
		for(;i<SectorsPerClust;i++)		
		{
			buffer=malloc(512);
			FAT_LoadPartCluster(p,i,buffer);
			count=0;
			while(count<512)
			{
				if(flag==0){if(keylen){Delay(100);keylen--;}}
				else if(type == 3){if(keylen){Delay(100);keylen--;}}

				if(VS1003B_NeedData() && flag)	
				{
					VS1003B_Write32B(&buffer[count]);
					count += 32;
					if(keylen)keylen--;			
					if(sector == totalsect && count >= leftbytes)		
					{
						if(type == 3)
							VS1003B_Fill2048Zero();
						i=SectorsPerClust;
						break;
					}
					if(count == 511){break;}
				}
				else if(VS1003B_ReadDecodeTime() != decodetime)
				{
					decodetime = VS1003B_ReadDecodeTime();
					min = decodetime/60;
					sec = decodetime%60;
					if(lrc)
					{ 
						if(min>99);
						else if(HanziEnable)
						{
							time[0] = min/10 + 0x30;
							time[1] = min%10 + 0x30;
							time[3] = sec/10 + 0x30;
							time[4] = sec%10 + 0x30;
							LCD_print12_fast(54,36,time);
						} 
						else
						{
							time[0] = min/10 + 0x30;
							time[1] = min%10 + 0x30;
							time[3] = sec/10 + 0x30;
							time[4] = sec%10 + 0x30;
							LCD_print12_fast(30,36,time);
						}
						while(1)
						{
							if(LrcStruct_pp->time/1000 <= decodetime && LrcStruct_pp != 0)
							{
								lrcaddr = LrcStruct_pp->eeaddr;
								while(1)
								{
									
									
									temp = lrcdatbuf[lrcaddr++];
									if(temp == 0)
									{
										break;
									}
									if(lrcCnt<52-1)lrcdata[lrcCnt++] = temp;
								}
								lrcdata[lrcCnt] = '\n';
								LrcStruct_pp = LrcStruct_pp->next;
							}
							else
							{
								if(lrcCnt && HanziEnable)
								{
									lcdClrDisBuf(); 
									lrcdata[lrcCnt] = '\0';
									printf(("[%s] %s\r\n"),time,lrcdata);
									

									lrcDisFlag = 1;	 
													 
													 
									
									
									
								}
								else if(lrcCnt)
								{
									lrcdata[lrcCnt] = '\0';
									printf(("[%s] %s\r\n"),time,lrcdata);
									LCD_print12_fast(30,36,time);
								}
								break;
							}
						}
						lcdUpdateDisplay();
					}
					else
					{
						if(min>99);
						else
						{
							time[0] = min/10 + 0x30;
							time[1] = min%10 + 0x30;
							time[3] = sec/10 + 0x30;
							time[4] = sec%10 + 0x30;
							LCD_print12(30,36,time);
							lcdUpdateDisplay();
						} 
					}
				}
				else if(lrcDisFlag)	 
				{					 
					lrcDisFlag = 0;
					lrcCnt = 0;
					LCD_print12_fast(0,0,lrcdata);
					LCD_print12_fast(54,36,time);
					lcdUpdateDisplay();
				} 


				if(((*((volatile unsigned long *) 0xE0028000)) & (0x01 << 25)) == 0  )
				{
					Delay(100);
					if(((*((volatile unsigned long *) 0xE0028000)) & (0x01 << 25)) == 0)
					{
						while(((*((volatile unsigned long *) 0xE0028000)) & (0x01 << 25)) == 0);
						if(flag)
						{
							flag=0;
							printf(("Pause\r\n"));
							if(lrc == 0 || HanziEnable == 0)
							{
								Print_ICON_12(18,0,Pause);
								lcdUpdateDisplay();
							}
							else
							{
								Print_ICON_12(42,36,Pause);
								lcdUpdateDisplay();
							}						}
						else
						{
							flag=1;
							printf(("Playing\r\n"));
							if(lrc == 0 || HanziEnable == 0)
							{
								Print_ICON_12(18,0,Playing);
								lcdUpdateDisplay();
							}
							else
							{
								Print_ICON_12(42,36,Playing);
								lcdUpdateDisplay();
							}
						}
						Delay(1000);
					}
				}
				else if((((*((volatile unsigned long *) 0xE0028000)) & (0x01 << 28)) == 0) && keylen==0)  
				{
					Delay(100);
	   			 	if(((*((volatile unsigned long *) 0xE0028000)) & (0x01 << 28)) == 0)  
					{
						keylen=200;
						if(vol_temp == 0);
						else 
						{
							vol_temp--;
							vol = (unsigned char)(255-(((unsigned short)vol_temp)*255)/100);
							vol = (vol<<8) +vol;
							VS1003B_SetVolume(vol);
							volume[0] = vol_temp/10 + 0x30;
							volume[1] = vol_temp%10 +0x30; 
							printf(("Turn volume down to: %s\r\n"),volume);
							if(lrc == 0 || HanziEnable == 0)
							{
								LCD_print12(72,36,volume);
								lcdUpdateDisplay();
							}
							else
							{
								Print_ICON_12(30,36,Speaker);
								LCD_print12(42,36,volume);
								lcdUpdateDisplay();
							}
						} 
					}
				}
				else if((((*((volatile unsigned long *) 0xE0028000)) & (0x01 << 29)) == 0) && keylen==0) 
				{
					Delay(100);
					if(((*((volatile unsigned long *) 0xE0028000)) & (0x01 << 29)) == 0) 
					{
						keylen=200;
						if(vol_temp == 99);
						else  
						{
							vol_temp++;
							vol = (unsigned char)(255-(((unsigned short)vol_temp)*255)/100);
							vol =(vol<<8) + vol;
							VS1003B_SetVolume(vol);
							volume[0] = vol_temp/10 + 0x30;
							volume[1] = vol_temp%10 +0x30;
							printf(("Turn volume up   to: %s\r\n"),volume);
							if(lrc == 0 || HanziEnable == 0)
							{
								LCD_print12(72,36,volume);
								lcdUpdateDisplay();
							}
							else
							{
								Print_ICON_12(30,36,Speaker);
								LCD_print12(42,36,volume);
								lcdUpdateDisplay();
							}
						} 
					}
				}
				else if(((*((volatile unsigned long *) 0xE0028000)) & (0x01 << 27)) == 0) 



				{
					Delay(50000);		
					if(((*((volatile unsigned long *) 0xE0028000)) & (0x01 << 27)) == 0)
					{
						while(((*((volatile unsigned long *) 0xE0028000)) & (0x01 << 27)) == 0);
						songs++;
						if(songs > totalsongs)songs=1;
						{
							free(buffer);
							goto next;
						}
					}
				}
				else if(((*((volatile unsigned long *) 0xE0028000)) & (0x01 << 26)) == 0) 
	 			 {
					Delay(5000);		
					if(((*((volatile unsigned long *) 0xE0028000)) & (0x01 << 26)) == 0)
					{
						while(((*((volatile unsigned long *) 0xE0028000)) & (0x01 << 26)) == 0);
						if(songs == 1)songs=totalsongs;
						else songs--;
						{
							free(buffer);
							goto next;
						}
					}
	  			 }
				else if((((*((volatile unsigned long *) 0xE0028000)) & (0x01 << 30)) == 0) && keylen==0) 
	 			{
					Delay(100);		
					if(((*((volatile unsigned long *) 0xE0028000)) & (0x01 << 30)) == 0)
					{
						keylen=0xffff;
						if(mode==0)
						{
							mode=1;
						
						
						}
						else if(mode==1)
						{
							mode=2;
						
						
							srand((*((volatile unsigned long *) 0xE0004008)));
						}
						else 
						{
							mode=0;
						
						
						}
						if(lrc == 0 || HanziEnable == 0)
						{
							switch(mode)
							{
								case 0:Print_ICON_12(72,0,RepetAll);printf(("Set mode -> repet all\r\n"));break;
								case 1:Print_ICON_12(72,0,RepetOne);printf(("Set mode -> repet one\r\n"));break;
								case 2   :Print_ICON_12(72,0,Shuffle);printf(("Set mode -> shuffle\r\n"));break;
								default:break;
							}
							lcdUpdateDisplay();
						}
						else
						{
							switch(mode)
							{
								case 0:Print_ICON_12(18,36,RepetAll);printf(("Set mode -> repet all\r\n"));break;
								case 1:Print_ICON_12(18,36,RepetOne);printf(("Set mode -> repet one\r\n"));break;
								case 2   :Print_ICON_12(18,36,Shuffle);printf(("Set mode -> shuffle\r\n"));break;
								default:break;
							}
							lcdUpdateDisplay();
						}  
					}
				}
			}
			sector++;
			free(buffer);
		}
		i=0;
              p=FAT_NextCluster(p);
		
		if(p == 0x0fffffff || p == 0x0ffffff8 || (FAT32_Enable == 0 && p == 0xffff))
		{
			if(mode==0)songs++;
			if(songs>totalsongs)songs=1;
			goto next;
		}
	}

	return 0;
}



 






int main(void)
{  


	char temp;
	
















    (*((volatile unsigned long *) 0xE002C000)) = ((*((volatile unsigned long *) 0xE002C000)) & 0xFFFF0000) | 0x05 | 0x50;

     
     
    (*((volatile unsigned char *) 0xE01FC080)) = 1;

    (*((volatile unsigned char *) 0xE01FC100)) = 0;
#line 1674 "main.c"





    (*((volatile unsigned char *) 0xE01FC084)) = (((11059200 * 4) / 11059200) - 1) | (1 << 5);
#line 1687 "main.c"
    (*((volatile unsigned char *) 0xE01FC08C)) = 0xaa;
    (*((volatile unsigned char *) 0xE01FC08C)) = 0x55;
    while(((*((volatile unsigned short*) 0xE01FC088)) & (1 << 10)) == 0);
    (*((volatile unsigned char *) 0xE01FC080)) = 3;
    (*((volatile unsigned char *) 0xE01FC08C)) = 0xaa;
    (*((volatile unsigned char *) 0xE01FC08C)) = 0x55;

		  

 
 
    (*((volatile unsigned char *) 0xE01FC000)) = 0;
#line 1705 "main.c"
    (*((volatile unsigned char *) 0xE01FC004)) = 3;


      (*((volatile unsigned char *) 0xE01FC000)) = 2;

	(*((volatile unsigned long *) 0xE002C000)) &= ~(0x03 <<20);				
	(*((volatile unsigned long *) 0xE0028008)) |= (0x01 << 10);	
	(*((volatile unsigned long *) 0xE002800C)) |= (0x01 << 10);

	(*((volatile unsigned long *) 0xE002C014)) &= ~(0x02 <<2);					
	(*((volatile unsigned long *) 0xE0028018)) |= (0x01 << 21);	
	(*((volatile unsigned long *) 0xE002801C)) |= (0x01 << 21);

	 (*((volatile unsigned long *) 0xE002C004)) &= ~(0x03 <<18);
	 (*((volatile unsigned long *) 0xE0028008)) &=~(0x01 << 25);	
	 (*((volatile unsigned long *) 0xE002C004)) &= ~(0x03 <<20);	
	 (*((volatile unsigned long *) 0xE0028008)) &=~(0x01 << 26);
	(*((volatile unsigned long *) 0xE002C004)) &= ~(0x03 <<22);
	 (*((volatile unsigned long *) 0xE0028008)) &=~(0x01 << 27);
	 (*((volatile unsigned long *) 0xE002C004)) &= ~(0x03 <<24);
	 (*((volatile unsigned long *) 0xE0028008)) &=~(0x01 << 28);
	 (*((v

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -