📄 readraw.c
字号:
//###########################################################
// File: readraw.c
//
// Using fopen() and fread() is very slow because a lot
// of calculations have to be done.
// Using ReadFileRaw() is up to 7 times faster.
//
//
//#########################################################################
// Last change: 22.03.2004
//#########################################################################
// holger.klabunde@t-online.de
// http://home.t-online.de/home/holger.klabunde/homepage.htm
//#########################################################################
// Compiler: avr-gcc 3.2
//#########################################################################
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "dos.h"
#ifdef DOS_READ_RAW
//###########################################################
// reads all clusters/sectors of the file.
// you have to check FileSize from direntry to see how
// many bytes of last cluster are valid for the file.
// much faster than fread()
unsigned char ReadFileRaw(char *name)
//###########################################################
{
unsigned long tmpsector;
#ifdef USE_FAT32
unsigned long tmp;
#else
unsigned int tmp;
#endif
unsigned char *p;
unsigned char by;
unsigned char secloop;
unsigned int i;
if(FileFlag>0) return F_ERROR; // there is an open file !
if(FindName(name)==FULL_MATCH)
{
tmp=FileFirstCluster;
FilePosition=0; //actual read position
while(tmp < endofclusterchain) // read all clusters of file
{
tmpsector=GetFirstSectorOfCluster(tmp);
// read all sectors of this cluster
for(secloop=0; secloop<secPerCluster; secloop++)
{
ReadSector(tmpsector,iob);
p=iob; //pointer to io buffer
// read data from iob now
for(i=0; i<BYTE_PER_SEC; i++) // read all bytes of a sector
{
by = *p++; // get a byte from iob
// 'by' holds your data now. use it as you want
// put your function to use 'by' below
//****************************
// load your MP3-Chip here ;)
//****************************
// end of your function
FilePosition++; // count bytes read
if(FilePosition>=FileSize) return F_OK; // end of file reached ?
}
tmpsector++; // next sector of cluster
}// for(secloop=0; secloop<secPerCluster; secloop++)
tmp=GetNextClusterNumber(tmp);
}// while(tmp < endofclusterchain)
}//if(FindName(name)==FULL_MATCH)
else return F_ERROR; // something went wrong
return F_OK;
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -