📄 zfat.h
字号:
struct partSecRec {
// From a 512 byte sector, 446 bytes must be skipped before entering
// data to this record. This data is boot executable code for PC
// but we do not need it. This will also keep memory requirement at
// low. We are not using any external memroy, therefore only RAM we
// have is 512 byte of AVR internal SRAM. The skipping is done init function.
//byte skip[446] /* Skip 446 bytes.
struct partRec partRecs[4]; /* four partition records (64 bytes) */
byte bootSectSig0; /* two signature bytes (2 bytes) */
byte bootSectSig1;
// #define BOOTSIG0 0x55
// #define BOOTSIG1 0xaa
};
//==========================================================
/*
* Format of a boot sector. This is the first sector on a DOS floppy disk
* or the fist sector of a partition on a hard disk. But, it is not the
* first sector of a partitioned hard disk.
*/
//==============================================================================
// BIOS Parameter Block (BPB) for different DOS versions
//==============================================================================
typedef struct bootSecExt {
char driveNumber; /* drive number (0x80) */
char reserved1; /* reserved */
char bootSignature; /* ext. boot signature (0x29) */
//#define EXBOOTSIG 0x29
dword volumeID; /* volume ID number */
char volumeLabel[11]; /* volume label */
char fileSysType[8]; /* fs type (FAT12 or FAT16) */
} bootSecExtType;
//=======================================================================================
//BPB for Win9x (DOS 7.10)
typedef struct bpb710 {
word bytesPerSec; /* bytes per sector */
byte secPerClust; /* sectors per cluster */
word resSectors; /* number of reserved sectors */
byte FATs; /* number of FATs */
word rootDirEnts; /* number of root directory entries */
word totSec16; /* total number of sectors */
byte media; /* media descriptor */
word FATSz16; /* number of sectors per FAT */
word secPerTrack; /* sectors per track */
word heads; /* number of heads */
dword hiddenSecs; /* # of hidden sectors */
/* DOS 3.3 compatibility ends here */
dword totSec32; /* # of sectors if parition is FAT32 */
/* DOS 5.0 compatibility ends here */
dword FATSz32; /* like bpbFATsecs for FAT32 */
word extFlags; /* extended flags: */
//#define FATNUM 0xf /* mask for numbering active FAT */
//#define FATMIRROR 0x80 /* FAT is mirrored (like it always was) */
word FSVers; /* filesystem version */
//#define FSVERS 0 /* currently only 0 is understood */
dword rootClust; /* start cluster for root directory */
word FSInfo; /* filesystem info structure sector */
word backup; /* backup boot sector */
byte skip[12]; /* This is 12 byte filler, we skip it */
} bpb710Type;
//Windows 9x (DOS 7.10)boot sector
struct bootSec710 {
byte jump[3]; /* jump inst E9xxxx or EBxx90 3 byte*/
char oemName[8]; /* OEM name and version 8 byte */
bpb710Type BPB; /* BIOS parameter block 53 */
bootSecExtType ext; /* Bootsector Extension 6 byte*/
//Must skip 418 bytes, reason is given in struct partSecRec
//byte skip[418]; /* skip bytes */
byte bootSectSig2; /* 2 & 3 are only defined for FAT32? */
byte bootSectSig3;
byte bootSectSig0;
byte bootSectSig1;
};
/*
* FAT32 FSInfo block.
*/
struct FAT32fsInfo {
//skip 484 bytes
//byte sig1[4]; //double word, signatrue is: 0x52 52 61 41
//BYTE skip[480];
dword sig2; //dword, signature is: 0x61 41 72 72
dword freeCluster; //# of free clusters
dword nxtfree; //Cluster # of cluster that was most recentrly allocated
//Following parameters are not used in ZipAmp thus not put into record.
// byte reserved[12]; //reserved 12 bytes
// byte notNeeded[2];
// byte sig3[4]; //Boot record signature, 0xAA 55 00 00
};
//File name in directory entry, 32 byte
struct direntry {
byte name[8]; /* filename, blank filled */
byte extension[3]; /* extension, blank filled */
byte attributes; /* file attributes */
byte lowerCase; /* NT VFAT lower case flags */
byte CHundredth; /* hundredth of seconds in CTime */
byte CTime[2]; /* create time */
byte CDate[2]; /* create date */
byte ADate[2]; /* access date */
word highClust; /* high bytes of cluster number */
byte MTime[2]; /* last update time */
byte MDate[2]; /* last update date */
word startCluster; /* starting cluster of file */
dword fileSize; /* size of file in bytes */
};
//Long file name structure
struct winentry {
byte Cnt; //Start offset of text in name
word Part1[5]; //First 5 bytes of name, size is word because of UNICODE
byte Attr; //Attributes;
byte Reserved1;
byte Chksum;
word Part2[6]; //Next 6 bytes of name
word Reserved2;
word Part3[2]; //Last 2 bytes, total 13 bytes
};
struct configuration { //This structure is saved by ZipAmp in ZIPAMP.CFG file to store player state.
byte Sign1; //If data valid Sign1 = 0xA5
byte SoundMode; //SoundMode
byte PlayMode; //0=Continue, 1=Random, 2=Dir, 3=Repeat
dword DriveSize; //Size of hard drive during last play, used for identifying drive
word TotalFiles; //Total files during last play
word LastFile; //Number of last file played
byte Sign2; //If data valid Sign2=0x5A
//Total 12 bytes
//These records aren't used yet.
// dword PlayListCount; //Total number of play list files upto 4
// dword PlayListClust[4];//Start cluster address of play list file
// byte PlayListNum; //Last play list used
// word PlayListFileNum; //Last played back file number from last play list used
};
void InitFAT(); //gets FAT table, sets FirstDataSector, sets FirstFATSector
//sets FirstDirSector, sets Sectors_Per_Cluster
//sets Bytes_Per_Sector
byte getDirEntry(byte onlyMP3); //gets the next file from the direcotry entry list.
//sets fileName, sets nextCluster to startCluster of the file
//sets fileSize.
dword findNextCluster(); //looks at the current nextCluster value, then looks in the
//FAT table and then sets currentCluster to the value of next cluster
//in file chain.
unsigned long clust2LBA(unsigned long clust); //Translates cluster address into LBA address
void GoToSectorOffset(dword LBASector, word offset); //Goes to a byte offset in a sector
void saveConfig(); //Saves the configuration record in ZIPAMP.CFG file
byte loadConfig(); //Loads configuration record from ZIPAMP.CFG file
void pushDir(); //Pushes directory return address into dir stack file ZIPAMP.SYS
void popDir(); //Pops directory address from dir stack ZIPAMP.SYS
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -