Play-/Source/ee/Ee_LibMc2.h

137 lines
3.1 KiB
C
Raw Permalink Normal View History

2020-03-25 08:02:59 -04:00
#pragma once
#include "Types.h"
#include "MIPS.h"
#include "iop/IopBios.h"
2020-03-25 08:02:59 -04:00
class CPS2OS;
2021-11-08 14:25:17 -05:00
namespace Framework
{
class CZipArchiveReader;
class CZipArchiveWriter;
}
2020-03-25 08:02:59 -04:00
namespace Ee
{
class CLibMc2
{
public:
2020-03-30 08:49:06 -04:00
struct DIRPARAM
{
struct TIME
{
uint8 unknown;
uint8 second;
uint8 minute;
uint8 hour;
uint8 day;
uint8 month;
uint16 year;
};
TIME creationDate;
TIME modificationDate;
uint32 size;
uint16 attributes;
uint16 resv1;
char name[32];
};
static_assert(sizeof(DIRPARAM) == 0x38);
2020-03-25 08:02:59 -04:00
enum
{
SYSCALL_RANGE_START = 0x800,
SYSCALL_MC2_CHECKASYNC = 0x800,
SYSCALL_MC2_GETINFO_ASYNC = 0x802,
2020-03-31 08:40:17 -04:00
SYSCALL_MC2_READFILE_ASYNC = 0x805,
2020-03-27 20:38:13 -04:00
SYSCALL_MC2_WRITEFILE_ASYNC = 0x806,
2020-03-27 20:05:25 -04:00
SYSCALL_MC2_CREATEFILE_ASYNC = 0x807,
2021-03-07 18:03:32 -05:00
SYSCALL_MC2_DELETE_ASYNC = 0x808,
2020-03-27 08:32:07 -04:00
SYSCALL_MC2_GETDIR_ASYNC = 0x80A,
2020-03-27 20:05:25 -04:00
SYSCALL_MC2_MKDIR_ASYNC = 0x80B,
2020-04-01 08:02:47 -04:00
SYSCALL_MC2_CHDIR_ASYNC = 0x80C,
2021-03-07 18:02:44 -05:00
SYSCALL_MC2_CHMOD_ASYNC = 0x80D,
2020-03-25 08:02:59 -04:00
SYSCALL_MC2_SEARCHFILE_ASYNC = 0x80E,
2021-12-29 15:59:16 -05:00
SYSCALL_MC2_GETENTSPACE_ASYNC = 0x80F,
2020-03-31 08:40:17 -04:00
SYSCALL_MC2_READFILE2_ASYNC = 0x820,
2020-04-13 07:57:21 -04:00
SYSCALL_MC2_WRITEFILE2_ASYNC = 0x821,
SYSCALL_MC2_GETDBCSTATUS = 0x900,
2020-03-25 08:02:59 -04:00
SYSCALL_RANGE_END,
};
CLibMc2(uint8*, CPS2OS&, CIopBios&);
2021-11-08 14:25:17 -05:00
2021-11-16 16:40:44 -05:00
void Reset();
2021-11-08 14:25:17 -05:00
void SaveState(Framework::CZipArchiveWriter&);
void LoadState(Framework::CZipArchiveReader&);
2020-03-25 08:02:59 -04:00
void HandleSyscall(CMIPS&);
void NotifyVBlankStart();
2020-03-25 08:02:59 -04:00
void HookLibMc2Functions();
private:
enum
{
WAIT_THREAD_ID_EMPTY = 0,
2021-11-08 14:34:35 -05:00
WAIT_VBLANK_INIT_COUNT = 4,
};
struct MODULE_FUNCTIONS
{
uint32 getInfoAsyncPtr = 0;
2021-12-29 15:59:16 -05:00
uint32 readFileAsyncPtr = 0;
uint32 writeFileAsyncPtr = 0;
uint32 createFileAsyncPtr = 0;
uint32 deleteAsyncPtr = 0;
uint32 getDirAsyncPtr = 0;
uint32 mkDirAsyncPtr = 0;
uint32 chDirAsyncPtr = 0;
uint32 chModAsyncPtr = 0;
uint32 searchFileAsyncPtr = 0;
2021-12-29 15:59:16 -05:00
uint32 getEntSpaceAsyncPtr = 0;
uint32 readFile2AsyncPtr = 0;
uint32 writeFile2AsyncPtr = 0;
uint32 checkAsyncPtr = 0;
uint32 getDbcStatusPtr = 0;
};
2020-03-25 08:02:59 -04:00
struct CARDINFO
{
uint32 type;
uint32 formatted;
uint32 freeClusters;
};
static_assert(sizeof(CARDINFO) == 0x0C);
void OnIopModuleLoaded(const char*);
uint32 AnalyzeFunction(MODULE_FUNCTIONS&, uint32, int16);
2020-03-25 08:02:59 -04:00
void WriteSyscall(uint32, uint16);
void CheckAsync(CMIPS&);
2020-03-25 08:02:59 -04:00
int32 GetInfoAsync(uint32, uint32);
2020-03-27 20:05:25 -04:00
int32 CreateFileAsync(uint32, uint32);
2021-03-07 18:03:32 -05:00
int32 DeleteAsync(uint32, uint32);
2020-03-25 08:02:59 -04:00
int32 GetDirAsync(uint32, uint32, uint32, int32, uint32, uint32);
2020-03-27 20:05:25 -04:00
int32 MkDirAsync(uint32, uint32);
2020-04-01 08:02:47 -04:00
int32 ChDirAsync(uint32, uint32, uint32);
2021-03-07 18:02:44 -05:00
int32 ChModAsync(uint32, uint32, uint32);
2020-03-25 08:02:59 -04:00
int32 SearchFileAsync(uint32, uint32, uint32);
2021-12-29 15:59:16 -05:00
int32 GetEntSpaceAsync(uint32, uint32);
2020-03-25 08:02:59 -04:00
int32 ReadFileAsync(uint32, uint32, uint32, uint32, uint32);
2020-03-27 20:38:13 -04:00
int32 WriteFileAsync(uint32, uint32, uint32, uint32, uint32);
int32 GetDbcStatus(uint32, uint32);
2020-03-25 08:02:59 -04:00
static const char* GetSysCallDescription(uint16);
2020-03-25 08:02:59 -04:00
uint8* m_ram = nullptr;
CPS2OS& m_eeBios;
2020-03-25 08:02:59 -04:00
CIopBios& m_iopBios;
CIopBios::ModuleLoadedEvent::Connection m_moduleLoadedConnection;
2020-03-25 08:02:59 -04:00
uint32 m_lastCmd = 0;
uint32 m_lastResult = 0;
uint32 m_waitThreadId = WAIT_THREAD_ID_EMPTY;
uint32 m_waitVBlankCount = 0;
2020-03-25 08:02:59 -04:00
};
}