nrioTool/bootloader/source/my_fat.h
ApacheThunder 0df94f509a The big release overhaul...
* Option to write a default fat image to card is now possible through
new covery menu! An image for 16g capacity cards is included. Note that
other capacities are not currently supported until fat image jumps of
them become available.
* Recovery menu has option to dump/write sector 0 of FAT section of
nand. This allows restoring bricked cards if access to a DS/DS Lite and
the reguired slot2 device is not available.
* Ability to boot into bootstrap program to launch files on cart added
to recovery menu. Allows booting udisk updator as a result so can
recover a bricked cart!
* Changes to UI. New top screen graphic. Graphics for bottom screen now
added for better console! :D
2023-11-06 13:22:37 -06:00

88 lines
2.5 KiB
C

/*-----------------------------------------------------------------
fat.h
NDS MP
GBAMP NDS Firmware Hack Version 2.12
An NDS aware firmware patch for the GBA Movie Player.
By Michael Chisholm (Chishm)
Filesystem code based on GBAMP_CF.c by Chishm (me).
License:
Copyright (C) 2005 Michael "Chishm" Chisholm
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
If you use this code, please give due credit and email me about your
project at chishm@hotmail.com
------------------------------------------------------------------*/
#ifndef FAT_H
#define FAT_H
#include <nds/ndstypes.h>
#define CLUSTER_FREE 0x00000000
#define CLUSTER_EOF 0x0FFFFFFF
#define CLUSTER_FIRST 0x00000002
typedef struct aFile
{
u32 firstCluster;
u32 currentCluster;
u32 currentOffset;
bool fatTableCached;
bool fatTableCompressed;
u32* fatTableCache;
u32 fatTableCacheSize;
} aFile;
typedef struct
{
aFile * file;
char* buffer;
u32 startOffset;
u32 length;
int dataPos;
int curSect;
int curByte;
int clusterIndex;
int chunks;
int cmd;
} readContext;
bool FAT_InitFiles(bool initCard);
void getBootFileCluster(aFile* file, const char* bootName);
void getFileFromCluster(aFile* file, u32 cluster);
void resetPrevSect();
#ifndef B4DS
u32 fileRead(char* buffer, aFile* file, u32 startOffset, u32 length);
bool fileReadNonBLocking(char* buffer, aFile* file, u32 startOffset, u32 length);
bool resumeFileRead();
u32 fileWrite(const char* buffer, aFile* file, u32 startOffset, u32 length);
u32 FAT_ClustToSect(u32 cluster);
#else
u32 fileRead(char* buffer, aFile* file, u32 startOffset, u32 length);
u32 fileWrite(const char* buffer, aFile* file, u32 startOffset, u32 length);
u32 FAT_ClustToSect(u32 cluster);
#endif
void buildFatTableCache (aFile* file);
void buildFatTableCacheCompressed (aFile* file);
/* ROM Header Region Information Structure */
#endif // FAT_H