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

📄 源程序.htm

📁 我的MP3 DIY 自带原代码希望各位提出宝贵意见和建议
💻 HTM
📖 第 1 页 / 共 5 页
字号:
                &nbsp;&nbsp;&nbsp;IDE_DIOR=1;<br>
                &nbsp;&nbsp;}<br>
                IDE_Address=IDE_Bus_Not_Use;<br>
                set_IDE_address();<br>
                IDE_DATA_L=0xFF;<br>
                }<br>
                ///////////////////////////////////////////////////////////////////////////////////////////////<br>
                <br>
                unsigned int play_count;&nbsp;&nbsp;//当前文件夹中播放曲号<br>
                <br>
                /////////////////////////////////////&nbsp;&nbsp;&nbsp;获取磁盘信息&nbsp;&nbsp;/////////////////////////////////////////<br>
                void get_IDE_information(void)<br>
                {<br>
                unsigned int i;<br>
                unsigned int j;<br>
                unsigned int k;<br>
                unsigned long int LBA=0;<br>
                mp3_file_exist=0;<br>
                LBA=0;<br>
                read_IDE_sector(LBA);<br>
                for(i=0;i&lt;4;i++)<br>
                {<br>
                &nbsp;&nbsp;dpt[i].file_system_type=buffer[0x1C2+i*16];&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//文件系统类型<br>
                &nbsp;&nbsp;((unsigned char 
                *)&amp;(dpt[i].start_sector))[3]=buffer[0x1C6+i*16];<br>
                &nbsp;&nbsp;((unsigned char 
                *)&amp;(dpt[i].start_sector))[2]=buffer[0x1C7+i*16];<br>
                &nbsp;&nbsp;((unsigned char 
                *)&amp;(dpt[i].start_sector))[1]=buffer[0x1C8+i*16];<br>
                &nbsp;&nbsp;((unsigned char 
                *)&amp;(dpt[i].start_sector))[0]=buffer[0x1C9+i*16];&nbsp;&nbsp;//分区开始扇区<br>
                &nbsp;&nbsp;((unsigned char 
                *)&amp;(dpt[i].total_sectors))[3]=buffer[0x1CA+i*16];<br>
                &nbsp;&nbsp;((unsigned char 
                *)&amp;(dpt[i].total_sectors))[2]=buffer[0x1CB+i*16];<br>
                &nbsp;&nbsp;((unsigned char 
                *)&amp;(dpt[i].total_sectors))[1]=buffer[0x1CC+i*16];<br>
                &nbsp;&nbsp;((unsigned char 
                *)&amp;(dpt[i].total_sectors))[0]=buffer[0x1CD+i*16];&nbsp;&nbsp;//分区总扇区<br>
                }<br>
                <br>
                if((buffer[510]!=0x55)||(buffer[511]!=0xAA))disk_error=1;<br>
                LBA=dpt[0].start_sector;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//C盘<br>
                read_IDE_sector(LBA);<br>
                DISK_CAPACITY[7]=buffer[0x0B];<br>
                DISK_CAPACITY[6]=buffer[0x0C];&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//分区容量<br>
                ((unsigned char 
                *)&amp;(dbr[0].bytes_per_sectors))[0]=buffer[0x0C];<br>
                ((unsigned char 
                *)&amp;(dbr[0].bytes_per_sectors))[1]=buffer[0x0B];&nbsp;&nbsp;//每扇区字节数<br>
                dbr[0].sectors_per_cluster=buffer[0x0D];&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//每簇扇区数<br>
                ((unsigned char 
                *)&amp;(dbr[0].reserve_sectors))[1]=buffer[0x0E];<br>
                ((unsigned char 
                *)&amp;(dbr[0].reserve_sectors))[0]=buffer[0x0F];&nbsp;&nbsp;&nbsp;//保留扇区数<br>
                dbr[0].num_of_FAT=buffer[0x10];&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//FAT副本数<br>
                ((unsigned char *)&amp;(dbr[0].FAT16_ROOT_num))[1]=buffer[0x11];<br>
                ((unsigned char *)&amp;(dbr[0].FAT16_ROOT_num))[0]=buffer[0x12];&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//FAT16文件系统的根目录数<br>
                ((unsigned char *)&amp;(dbr[0].small_sectors))[1]=buffer[0x13];<br>
                ((unsigned char *)&amp;(dbr[0].small_sectors))[0]=buffer[0x14];<br>
                ((unsigned char 
                *)&amp;(dbr[0].sectors_per_FAT16))[1]=buffer[0x16];<br>
                ((unsigned char 
                *)&amp;(dbr[0].sectors_per_FAT16))[0]=buffer[0x17];<br>
                ((unsigned char *)&amp;(dbr[0].hidden_sectors))[3]=buffer[0x1C];<br>
                ((unsigned char *)&amp;(dbr[0].hidden_sectors))[2]=buffer[0x1D];<br>
                ((unsigned char *)&amp;(dbr[0].hidden_sectors))[1]=buffer[0x1E];<br>
                ((unsigned char *)&amp;(dbr[0].hidden_sectors))[0]=buffer[0x1F];<br>
                ((unsigned char *)&amp;(dbr[0].large_sectors))[3]=buffer[0x20];<br>
                ((unsigned char *)&amp;(dbr[0].large_sectors))[2]=buffer[0x21];<br>
                ((unsigned char *)&amp;(dbr[0].large_sectors))[1]=buffer[0x22];<br>
                ((unsigned char *)&amp;(dbr[0].large_sectors))[0]=buffer[0x23];<br>
                ((unsigned char 
                *)&amp;(dbr[0].sectors_per_FAT32))[3]=buffer[0x24];<br>
                ((unsigned char 
                *)&amp;(dbr[0].sectors_per_FAT32))[2]=buffer[0x25];<br>
                ((unsigned char 
                *)&amp;(dbr[0].sectors_per_FAT32))[1]=buffer[0x26];<br>
                ((unsigned char 
                *)&amp;(dbr[0].sectors_per_FAT32))[0]=buffer[0x27];<br>
                ((unsigned char 
                *)&amp;(dbr[0].root_cluster_num))[3]=buffer[0x2C];<br>
                ((unsigned char 
                *)&amp;(dbr[0].root_cluster_num))[2]=buffer[0x2D];<br>
                ((unsigned char 
                *)&amp;(dbr[0].root_cluster_num))[1]=buffer[0x2E];<br>
                ((unsigned char 
                *)&amp;(dbr[0].root_cluster_num))[0]=buffer[0x2F];<br>
                if((buffer[510]!=0x55)||(buffer[511]!=0xAA))disk_error=2;<br>
                FAT_start_sector[0]=dpt[0].start_sector+dbr[0].reserve_sectors;<br>
                DATA_start_sector[0]=FAT_start_sector[0]+(dbr[0].num_of_FAT)*(dbr[0].sectors_per_FAT32);<br>
                LBA=DATA_start_sector[0];<br>
                driver_number=C_;<br>
                current_dir.first_cluster_number=dbr[0].root_cluster_num;<br>
                for(i=0;i&lt;dbr[0].sectors_per_cluster;i++)&nbsp;&nbsp;//扫描C盘根目录,是否有MP3文件<br>
                &nbsp;&nbsp;{<br>
                &nbsp;&nbsp;&nbsp;read_IDE_sector(LBA);<br>
                &nbsp;&nbsp;&nbsp;for(j=0;j&lt;512/32;j++)<br>
                &nbsp;&nbsp;&nbsp;&nbsp;{<br>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for(k=0;k&lt;11;k++)file.name[k]=buffer[j*32+k];<br>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;file.attribute=buffer[j*32+11];<br>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;((unsigned char 
                *)&amp;(file.first_cluster_number))[0]=buffer[j*32+0x15];<br>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;((unsigned char 
                *)&amp;(file.first_cluster_number))[1]=buffer[j*32+0x14];<br>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;((unsigned char 
                *)&amp;(file.first_cluster_number))[2]=buffer[j*32+0x1B];<br>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;((unsigned char 
                *)&amp;(file.first_cluster_number))[3]=buffer[j*32+0x1A];<br>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;((unsigned char 
                *)&amp;(file.length))[3]=buffer[j*32+0x1C];<br>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;((unsigned char 
                *)&amp;(file.length))[2]=buffer[j*32+0x1D];<br>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;((unsigned char 
                *)&amp;(file.length))[1]=buffer[j*32+0x1E];<br>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;((unsigned char 
                *)&amp;(file.length))[0]=buffer[j*32+0x1F];<br>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;file.next_cluster_number=file.first_cluster_number;<br>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(is_a_mp3_file())<br>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mp3_file_exist=1;<br>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;play_count++;<br>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(play_count==3)return;<br>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>
                &nbsp;&nbsp;&nbsp;&nbsp;}<br>
                &nbsp;&nbsp;&nbsp;LBA++;<br>
                &nbsp;&nbsp;}<br>
                }<br>
                ////////////////////////////////////////////////////////////////////////////////////////////////////////////<br>
                <br>
                /*void read_IDE_buffer(void)<br>
                {<br>
                write_IDE_command(IDE_Read_Buffer);<br>
                }*/<br>
                <br>
                /*void write_IDE_buffer(void)<br>
                {<br>
                write_IDE_command(IDE_Write_Buffer);<br>
                }*/<br>
                <br>
                <br>
                /*void write_IDE_sector(void)<br>
                {<br>
                write_IDE_command(IDE_Write_Sectors);<br>
                }*/<br>
                <br>
                /////////////////////////////////////////////&nbsp;&nbsp;&nbsp;&nbsp;IDE 
                初始化&nbsp;&nbsp;/////////////////////////////////////////<br>
                void IDE_initial(void)<br>
                {<br>
                reset_IDE();<br>
                do<br>
                &nbsp;&nbsp;{<br>
                &nbsp;&nbsp;&nbsp;write_IDE_8(IDE_Drive_Head,0xE0);<br>
                &nbsp;&nbsp;&nbsp;read_IDE_status();<br>
                &nbsp;&nbsp;}while(IDE_BSY);<br>
                wait_IDE_busy();<br>
                write_IDE_8(IDE_Device_Control,0xFA);//没有中断模式f<br>
                get_IDE_information();<br>
                }<br>
                ///////////////////////////////////////////////////////////////////////////////////////////////////////<br>
                <br>
                <br>
                /*file_system.c file<br>
                &nbsp;&nbsp;Created by Computer-lov Date: 2005.3.19<br>
                &nbsp;&nbsp;Copyright (c) 2005 Computer-lov<br>
                &nbsp;&nbsp;&nbsp;version 1.0<br>
                */<br>
                <br>
                #include &quot;file_system.h&quot;<br>
                #include &quot;IDE.H&quot;<br>
                #include &quot;hardware.h&quot;<br>
                //#include &quot;USB_mass_storage.h&quot;<br>
                <br>
                FILE xdata file;<br>
                <br>
                ////////////////////////////////////&nbsp;&nbsp;判断是否为一个 
                MP3 文件&nbsp;&nbsp;&nbsp;///////////////////////////////<br>
                unsigned char is_a_mp3_file(void)<br>
                {<br>
                if((file.name[0]==0x00)||(file.name[0]==0xE5)||(file.name[0]=='.'))return 
                0;<br>
                if(file.attribute==0x0F)return 0;&nbsp;&nbsp;//此项目为长文件名项目<br>
                if(file.attribute &amp; 0x04)return 0;&nbsp;&nbsp;//此文件为系统文件<br>
                if(file.attribute &amp; 0x08)return 0;&nbsp;&nbsp;//此项目为系统标卷<br>
                if(file.attribute &amp; 0x10)return 0;&nbsp;&nbsp;//此项目为子目录<br>
                if((file.name[8]=='M')&amp;&amp;(file.name[9]=='P')&amp;&amp;(file.name[10]=='3'))return 
                1;<br>
                else return 0;<br>
                }<br>
                ///////////////////////////////////////////////////////////////////////////////////////////////<br>
                <br>
                unsigned long int LAST_FAT_LBA;<br>
                //最后一次读取FAT时的逻辑块地址,用来判断本次读取是否需要重新从硬盘中读取,以加快速度<br>
                <br>
                ////////////////////////////////////////////////////////////////////////////////////////////////<br>
                unsigned long int get_next_sector(void)&nbsp;&nbsp;//根据当前簇号,获取下一个扇区地址<br>
                {<br>
                unsigned long int LBA;<br>
                unsigned&nbsp;&nbsp;int i;<br>
                LBA=(file.next_cluster_number)/((dbr[driver_number].bytes_per_sectors)/4);&nbsp;&nbsp;//计算扇区地址<br>
                i=(file.next_cluster_number)*4-LBA*dbr[driver_number].bytes_per_sectors; 
                //计算偏移地址<br>
                if(LAST_FAT_LBA!=LBA)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//如果数据不在FAT_buffer[]中,则需要重新读取<br>
                &nbsp;&nbsp;{<br>
                &nbsp;&nbsp;&nbsp;LAST_FAT_LBA=LBA;<br>
                &nbsp;&nbsp;&nbsp;LBA=LBA+FAT_start_sector[driver_number];<br>
                &nbsp;&nbsp;&nbsp;read_IDE_FAT_sector(LBA);<br>
                &nbsp;&nbsp;}<br>
                ((unsigned char 
                *)&amp;(file.next_cluster_number))[3]=FAT_buffer[i];<br>

⌨️ 快捷键说明

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