SBSPSS/source/fileio/fileio.h

154 lines
3.3 KiB
C
Raw Normal View History

2000-08-29 21:52:28 +02:00
/***************************************/
/*** PSX PC/CD Big Lump FileIO Stuff ***/
/***************************************/
#ifndef _FILEIO_HEADER_
#define _FILEIO_HEADER_
2000-09-20 17:12:20 +02:00
#ifndef _GLOBAL_HEADER_
#include "system\global.h"
#endif
2000-08-29 22:16:17 +02:00
#ifndef __FILE_EQUATES_H__
2000-08-29 21:52:28 +02:00
#include "BigLump.h"
2000-08-29 22:16:17 +02:00
#endif
2000-08-29 21:52:28 +02:00
#include "fileio\filetab.h"
/*****************************************************************************/
#define FILEIO_MINCHUNKS (1) // 2k
#define FILEIO_MAXCHUNKS (1) // 2k 64k (only needed for small files, daft streams and end of files now)
#define FILEIO_CHUNKSIZE (2048)
#define FILEIO_MINCHUNKSIZE (FILEIO_CHUNKSIZE*FILEIO_MINCHUNKS)
#define FILEIO_MAXCHUNKSIZE (FILEIO_CHUNKSIZE*FILEIO_MAXCHUNKS)
enum
{
FILEIO_MODE_NONE=0,
FILEIO_MODE_CHUNK,
FILEIO_MODE_STREAM,
};
enum
{
BLStatusOffline=-1,
BLStatusReady,
BLStatusOpen,
BLStatusRead,
BLStatusFail
};
enum
{
DataLump=0,
OverlayLump,
MaxLumps
};
struct sFAT
{
s32 FilePos;
s32 FileSize;
};
struct sBigLump
{
s16 Status;
u32 Sector;
u8 *ChunkPtr,*DstPtr;
int ChunkLeft;
int Length,LengthLeft,ReadSoFar;
int LoadLeft;
int LoadMode;
u8 ChunkBuffer[FILEIO_MAXCHUNKSIZE];
};
/*****************************************************************************/
enum DataBankEquate
{
DATABANK_MAX
};
struct sDataBank
{
FileEquate Filename;
sFAT *Data;
};
2001-04-04 14:38:57 +02:00
/*****************************************************************************/
struct sASyncQueue
{
int Sector;
int Length;
u8 *Dst;
int Status;
};
2000-08-29 21:52:28 +02:00
/*****************************************************************************/
class CLOFileIO;
class CFileIO
{
public:
static void Init();
static void OpenFile(FileEquate file);
static long ReadFile(void *Buffer,s32 Length);
static void CloseFile();
static void AlignFile(int Length);
static void SkipFile(int Skip);
static int GetStatus() {return(BigLump.Status);}
static void LoadFileSizeAtAddr(FileEquate Filename,void *Buffer,u32 Length);
static u8 *loadFile( FileEquate file, char *allocName="CFileIO::loadFile" );
static int IsFromDataBank(void *Addr);
static u8 *loadFileAtAddr(FileEquate file, u8* buffer);
static void loadDataBank(DataBankEquate Bank);
static void dumpDataBank();
static u8 *isFileInDataBank(FileEquate File);
static s32 getFileSize( FileEquate file );
static s32 getFileSector( FileEquate file );
static s32 getFileOffset( FileEquate file );
static int GetFilePos(int File);
static void FindAllFilePos();
static void GetAllFilePos();
static int GetReadLeft();
2001-04-04 14:38:57 +02:00
// Fake ASync Que Stuff
static void EnableASync(bool f) {ASyncFlag=f;}
static void AddASyncFile(FileEquate file,u8 *Dst);
static void LoadASyncFiles();
2000-08-29 21:52:28 +02:00
private:
static void CheckChunk();
static sBigLump BigLump;
static CLOFileIO *FileIO;
static int FilePosList[FILEPOS_MAX];
static sDataBank DataBank[DATABANK_MAX];
static DataBankEquate CurrentDataBank;
static sFAT *MainFAT;
2001-04-04 14:38:57 +02:00
static sASyncQueue ASyncQueue;
static bool ASyncFlag;
2000-08-29 21:52:28 +02:00
};
/*****************************************************************************/
class CLOFileIO
{
public:
virtual void Open()=0;
virtual void Read(u32 Length,void *Buffer)=0;
2001-04-04 14:38:57 +02:00
virtual void ReadAsync(sASyncQueue &File){};
2000-08-29 21:52:28 +02:00
virtual void Close()=0;
};
/*****************************************************************************/
#endif