📄 enhanced.c
字号:
#include "fat_include.h"
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Prototypes
//-----------------------------------------------------------------------------
void fopen_cluster(UI32 StartCluster);
UI8 fgetc(void);
UI8 feof(void);
void fscanf(char *args, char *string);
void ReadMP3_3(UI32 StartCluster);
void ReadPLS(void);
//-----------------------------------------------------------------------------
// Structures
//-----------------------------------------------------------------------------
struct {
UI16 i;
UI32 clustortemp;
UI32 currentsectornumber;
UI16 bytenum;
UI8 UsedBefore;
UI8 eof;
} MP3System;
//-----------------------------------------------------------------------------
// Functions
//-----------------------------------------------------------------------------
UI8 fgetc(void)
{
// Databyte declaration
UI8 datareturn;
// If first byte required then load the sector that contains it
if (MP3System.bytenum==0)
{
if (SectorReaderV2(MP3System.clustortemp, MP3System.currentsectornumber)) MP3System.eof = 1;
}
// Copy data from sector buffer
datareturn = currentsector[MP3System.bytenum];
// Increase pointer in current sector for next load
MP3System.bytenum++;
// If pointer reaches end of sector, reset and increase sector number
if (MP3System.bytenum==512)
{
MP3System.bytenum=0;
MP3System.currentsectornumber++;
}
// Return Data
return datareturn;
}
void fopen_cluster(UI32 StartCluster)
{
// Reset MPEG Stream Counters
MP3System.currentsectornumber = 0;
MP3System.bytenum = 0;
MP3System.clustortemp = StartCluster;
MP3System.eof = 0;
// Reset FAT Buffer
FATBufferV2.firstuse = 1;
FATBufferV2.firstsector = 1;
}
//-----------------------------------------------------------------------
// feof: Returns 1 when end of file
//-----------------------------------------------------------------------
UI8 feof(void)
{
return (MP3System.eof);
}
// ----------------------------------------------------------------
// fscanf: Read a line from a file
// ----------------------------------------------------------------
void fscanf(char *args, char *string)
{
UI8 datalast = 0;
UI8 datacurrent= 0;
int stringpntr=0;
// -------------------------------------------------
// Find a string
// -------------------------------------------------
if (args=="%s")
{
while (datacurrent!=0xFF)
{
datacurrent = fgetc();
if ((datalast==0x0D) && (datacurrent==0x0A))
{
stringpntr--;
//stringpntr--;
break;
}
string[stringpntr++] = datacurrent;
datalast = datacurrent;
}
string[stringpntr] = '\0';
}
// -------------------------------------------------
// other find types go here
// -------------------------------------------------
}
//-----------------------------------------------------------------------------
// ReadSector: Version 2
//-----------------------------------------------------------------------------
void ReadMP3_3(UI32 StartCluster)
{
UI8 data;
UI8 exist=0;
fopen_cluster(StartCluster);
do
{
if (DREQStatus)
{
data = fgetc();
exist = 1;
}
while ((DREQStatus)) ControlCheck();
if (exist==0) data = fgetc();
MP3SendByte( data );
exist=0;
}
while ( !feof() );
}
void ReadPLS(void)
{
char string[100];
char dirpath[100];
char filename[50];
UI32 startcluster;
s3c44b0x_Printf("PlaylistCluster opened 0x%x",fopen("C:\\NEWPLS.TXT"));
s3c44b0x_Printf("\r\n");
do
{
fscanf("%s", string);
// Split full path into filename and directory path
split_path(string, dirpath, filename);
// Find last subdirs start cluster
startcluster = recursive_dirfind(dirpath);
// Using dir cluster address search for filename
startcluster = MatchName(startcluster, filename);
s3c44b0x_Printf("%s",filename);
s3c44b0x_Printf(" |0x%lx|\r\n",startcluster);
}
while (string!=0);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -