📄 file_sys.lst
字号:
C51 COMPILER V7.50 FILE_SYS 11/18/2005 21:31:24 PAGE 1
C51 COMPILER V7.50, COMPILATION OF MODULE FILE_SYS
OBJECT MODULE PLACED IN FILE_SYS.OBJ
COMPILER INVOKED BY: d:\Keil\C51\BIN\C51.EXE FILE_SYS.C LARGE BROWSE
line level source
1 /* Copyright (C) 1996-2005 Brilliant Ideal Electronics. All rights reserved.
2 MP3_Player+USB_Disk V3.0 Edit by JMBIE STUDIO 2005.03
3 */
4
5
6 #include <string.h>
7 #include "AT89C51SND1_REG.H"
8 #include "FILE_SYS.H"
9 #include "MP3_PLAYER.H"
10 #include "UDISK_DEF.H"
11 #include "MCU_UART.H"
12
13 unsigned char Page_Buf[512];
14 long int Current_Cluster, DataRead = 0, DataRemain = 0, Sector_Offset = 0x21d;
15 unsigned int TotalCluster, BootSector, RsdSector, SectorofFatSize, TotalCapacity, RootEntry, SecPerClus;
16 unsigned int TotalSector, BytesPerSec, FirstDataSec;
17 unsigned char FAT_TYPE;
18
19
20
21 void Init_FAT_Info(void)
22 {
23 1
24 1 ReadPage(Begin_Cluster, 0, Page_Buf);
25 1
26 1 if (!(Page_Buf[0] == 0xeb && Page_Buf[2] == 0x90))
27 1 {
28 2
29 2 BootSector = Page_Buf[454] + Page_Buf[455] * 256 + Page_Buf[456] * (256 * 256) + Page_Buf[457] * (256 *
-256 * 256);
30 2 }
31 1 else
32 1 {
33 2 BootSector = 0;
34 2 }
35 1
36 1
37 1 ReadPage(Begin_Cluster, BootSector, Page_Buf);
38 1 RsdSector = Page_Buf[14] + Page_Buf[15] * 256;
39 1 SecPerClus = Page_Buf[13];
40 1
41 1 BytesPerSec = Page_Buf[12] * 256 + Page_Buf[11];
42 1
43 1 TotalSector = (Page_Buf[20] * 256 + Page_Buf[19]);
44 1 TotalCapacity = TotalSector * BytesPerSec;
45 1 TotalCluster = TotalSector / SecPerClus;
46 1
47 1 SectorofFatSize = ((Page_Buf[22] + Page_Buf[23] * 256));
48 1 RootEntry = (Page_Buf[18] * 256 + Page_Buf[17]);
49 1
50 1 FirstDataSec = BootSector + RsdSector + (SectorofFatSize * 2) + ((RootEntry * 32 + (BytesPerSec-1)) / Byt
-esPerSec);
51 1
52 1 if (TotalCluster > 65525)
53 1 {
C51 COMPILER V7.50 FILE_SYS 11/18/2005 21:31:24 PAGE 2
54 2 FAT_TYPE = FAT32;
55 2
56 2 if (TotalSector == 0)
57 2 {
58 3 TotalSector = (Page_Buf[32] + Page_Buf[33] * 256 + Page_Buf[34] * 256 * 256 + Page_Buf[35] * 256 * 256
-* 256);
59 3 }
60 2 TotalCapacity = TotalSector * BytesPerSec;
61 2 TotalCluster = TotalSector / SecPerClus;
62 2
63 2 SectorofFatSize = (Page_Buf[36] + Page_Buf[37] * 256 + Page_Buf[38] * 256 * 256 + Page_Buf[39] * 256 * 2
-56 * 256);
64 2 if (SectorofFatSize > (TotalCluster * 16 / 512))
65 2 {
66 3 SectorofFatSize = ((Page_Buf[22] + Page_Buf[23] * 256));
67 3 }
68 2 RootEntry = (Page_Buf[44] * 256 + Page_Buf[43]);
69 2 FirstDataSec = BootSector+RsdSector + (SectorofFatSize * 2) + ((RootEntry * 32 + (BytesPerSec-1)) / Byte
-sPerSec);
70 2
71 2 }
72 1 else if ((TotalCluster > 0) && (TotalCluster < 4085))
73 1 {
74 2 FAT_TYPE = FAT12;
75 2 }
76 1 else
77 1 {
78 2 FAT_TYPE = FAT16;
79 2 }
80 1 }
81
82 unsigned char GetMP3List(void)
83 {
84 1 unsigned char i = 0, j = 0, l = 0;
85 1 int k = 0;
86 1 unsigned char MP3[3] = {'M', 'P', '3'};
87 1
88 1
89 1 k = BootSector + RsdSector + 2 * SectorofFatSize;
90 1
91 1 ReadPage(0 + k / 32, k % 32, Page_Buf);
92 1
93 1 while (Page_Buf[0] != 0)
94 1 {
95 2 for (j=0; j<16; j++)
96 2 {
97 3 if (!Page_Buf[j * 32]) break;
98 3 if (Page_Buf[j * 32] == 0xE5) continue;
99 3
100 3 if (!memcmp(MP3, &Page_Buf[j * 32 + 8], 3)) //file find
101 3 {
102 4 for (i=0; i<11; i++)
103 4 {
104 5 SONG[l * 11 + i] = Page_Buf[j * 32 + i];
105 5 }
106 4 l++;
107 4 }
108 3 }
109 2 k++;
110 2 ReadPage(0 + k / 32, k % 32, Page_Buf);
111 2 }
112 1 return (l);
C51 COMPILER V7.50 FILE_SYS 11/18/2005 21:31:24 PAGE 3
113 1 }
114
115 int ReadSector(unsigned char *Name, unsigned char *databuff)
116 {
117 1 int i, k, Page;
118 1 unsigned long CurrentSector;
119 1 if (DataRead == 0)
120 1 {
121 2 Page = BootSector + RsdSector + 2 * SectorofFatSize;
122 2 ReadPage(0 + Page / 32, Page % 32, databuff);
123 2 while (databuff[0] != 0)
124 2 {
125 3 for (i=0; i<16; i++)
126 3 {
127 4
128 4
129 4 if (!memcmp(Name, &databuff[i * 32], 11))
130 4 {
131 5 Current_Cluster = databuff[32 * i + 27] * 256 + databuff[32 * i + 26];
132 5 for (k=31; k>27; k--)
133 5 {
134 6 DataRemain = (DataRemain << 8) | databuff[i * 32 + k];
135 6 }
136 5
137 5 CurrentSector = (Current_Cluster - 2) * SecPerClus + FirstDataSec;
138 5 ReadPage(CurrentSector / 32, CurrentSector % 32, databuff);
139 5
140 5 DataRead += 512;
141 5 DataRemain -= 512;
142 5 if (DataRemain < 0)
143 5 {
144 6 DataRead = 0;
145 6 return (DataRemain + 512);
146 6 }
147 5 else
148 5 {
149 6 return (512);
150 6 }
151 5 }
152 4 }
153 3 Page++;
154 3 ReadPage(0 + Page / 32, Page % 32, databuff);
155 3 }
156 2 return (0);
157 2 }
158 1 else
159 1 {
160 2 Current_Cluster++;
161 2 CurrentSector = (Current_Cluster - 2) * SecPerClus + FirstDataSec;
162 2 ReadPage(CurrentSector / 32, CurrentSector % 32, databuff);
163 2
164 2 DataRead += 512;
165 2 DataRemain -= 512;
166 2 if (DataRemain < 0)
167 2 {
168 3 DataRead = 0;
169 3 return (DataRemain + 512);
170 3 }
171 2 else return (512);
172 2 }
173 1
174 1 }
C51 COMPILER V7.50 FILE_SYS 11/18/2005 21:31:24 PAGE 4
175
176 int ReadOneSector(unsigned char *Name, unsigned long SetCluster,unsigned char *databuff)
177 {
178 1 int i, Page;
179 1 unsigned long CurrentSector;
180 1
181 1 Page = BootSector + RsdSector + 2 * SectorofFatSize;
182 1 ReadPage(0 + Page / 32, Page % 32, databuff);
183 1 for (i=0; i<16; i++)
184 1 {
185 2 if (!memcmp(Name, &databuff[i * 32], 11))
186 2 {
187 3 Current_Cluster = databuff[32 * i + 27] * 256 + databuff[32 * i + 26];
188 3 CurrentSector =(Current_Cluster - 2) * SecPerClus + FirstDataSec;
189 3 CurrentSector=CurrentSector+SetCluster;
190 3 ReadPage(CurrentSector / 32, CurrentSector % 32, databuff);
191 3 return (512);
192 3
193 3 }
194 2 }
195 1
196 1 return (0);
197 1 }
198
199
200
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 2544 ----
CONSTANT SIZE = 3 ----
XDATA SIZE = 549 40
PDATA SIZE = ---- ----
DATA SIZE = ---- ----
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -