Matched most remaining libultra files (#221)

* osPfsIsPlug.c and osContSetCh.c OK

* update

* __osPfsGetStatus.c OK

* removed unused asm

* Updated all libultra controller files to use new structs instead of the temporary structs. Added os_pfs.h

* controller updates

* fixed header guard

* Made suggested changes

* guLookAt.c OK

* commit

* __osPfsSelectBank.c OK

* osPfsDeleteFile.c OK

* pfsreadwritefile.c OK

* osPfsFreeBlocks.c OK

* cleaned up ospfsfreeblocks

* started pfsinitpak.c

* pfsallocatefile.c OK

* contpfs.c decompiled with 1 non matching

* osPfsFindFile.c OK

* pfsinitpak.c decompiled. one non-matching

* Actually fixed merge conflict

* sins.c OK

* cosf.c sinf.c and sins.c OK

* moved osAfterPreNMI to its own file. Renamed code_801031F0 to contquery.c

* pfschecker.c OK

* final update and rename

* Removed makefile testing thing that i accidentally added

* Made suggested changes
This commit is contained in:
Lucas Shaw
2020-07-06 17:15:01 -07:00
committed by GitHub
parent e6ca2dfd70
commit 7e195a3562
59 changed files with 1769 additions and 3641 deletions
+24 -24
View File
@@ -2402,7 +2402,7 @@ s32 JpegDecoder_Decode(JpegDecoder* decoder, u16* mcuBuff, s32 count, u8 isFollo
s32 JpegDecoder_ProcessMcu(JpegHuffmanTable* hTable0, JpegHuffmanTable* hTable1, s16* mcu, s16* unk);
s32 JpegDecoder_ParseNextSymbol(JpegHuffmanTable* hTable, s16* outCoeff, u8* outZeroCount);
u16 JpegDecoder_ReadBits(u8 len);
s32 osPfsFreeBlocks(OSPfs* pfs, s32 *bytes_not_used);
s32 osPfsFreeBlocks(OSPfs* pfs, s32* leftoverBytes);
void guScale(Mtx* m, f32 x, f32 y, f32 z);
f32 sinf(f32);
s16 sins(u16);
@@ -2426,26 +2426,26 @@ void __osPackReadData();
// ? __osSpRawStartDma(?);
s32 __osSiRawStartDma(s32 dir, void *addr);
// ? osSpTaskYield(?);
// ? func_801014C0(?);
s32 osPfsReadWriteFile(OSPfs* pfs, s32 file_no, u8 flag, s32 offset, s32 nbytes, u8* data_buffer);
s32 __osPfsGetNextPage(OSPfs* pfs, u8* bank, __OSInode* inode, __OSInodeUnit* page);
s32 osPfsReadWriteFile(OSPfs* pfs, s32 fileNo, u8 flag, s32 offset, s32 size, u8* data);
s32 __osPfsGetStatus(OSMesgQueue* queue, s32 channel);
void __osPfsRequestOneChannel(s32 channel, u8 poll);
void __osPfsGetOneChannelData(s32 channel, OSContStatus* contData);
// ? guMtxIdentF(?);
void guLookAtF(MtxF* mf, f32 xEye, f32 yEye, f32 zEye, f32 xAt, f32 yAt, f32 zAt, f32 xUp, f32 yUp, f32 zUp);
void guLookAtF(float mf[4][4], f32 xEye, f32 yEye, f32 zEye, f32 xAt, f32 yAt, f32 zAt, f32 xUp, f32 yUp, f32 zUp);
void guLookAt(Mtx*, f32 xEye, f32 yEye, f32 zEye, f32 xAt, f32 yAt, f32 zAt, f32 xUp, f32 yUp, f32 zUp);
s32 osPfsAllocateFile(OSPfs* pfs, u16 company_code, u32 game_code, u8* game_name, u8* ext_name, s32 length, s32* file_no);
// ? func_801021E4(?);
s32 __osPfsDeclearPage(OSPfs* pfs, __OSInode* inode, s32 fileSizeInPages, s32* startPage, u8 bank, s32* decleared, s32* finalPage);
// ? osStopTimer(?);
// ? func_80102420(?);
// ? func_80102494(?);
// ? func_80102590(?);
// ? func_801028E0(?);
// ? func_80102A44(?);
// ? func_80102BF0(?);
// ? func_80102CC4(?);
u16 __osSumcalc(u8* ptr, s32 length);
s32 __osIdCheckSum(u16 *ptr, u16 *csum, u16 *icsum);
s32 __osRepairPackId(OSPfs* pfs, __OSPackId* badid, __OSPackId* newid);
s32 __osCheckPackId(OSPfs* pfs, __OSPackId* temp);
s32 __osGetId(OSPfs* pfs);
s32 __osCheckId(OSPfs* pfs);
s32 __osPfsRWInode(OSPfs* pfs, __OSInode* inode, u8 flag, u8 bank);
// ? func_80102FA0(?);
s32 osPfsFindFile(OSPfs* pfs, u16 company_code, u32 game_code, u8* game_name, u8* ext_name, s32* file_no);
s32 osPfsFindFile(OSPfs *pfs, u16 companyCode, u32 gameCode, u8 *gameName, u8 *extName, s32 *fileNo);
// ? osAfterPreNMI(?);
// ? osContStartQuery(?);
void osContGetQuery(OSContStatus* data);
@@ -2466,7 +2466,7 @@ void guRotate(Mtx*, f32 angle, f32 x, f32 y, f32 z);
u32 osDpGetStatus(void);
void osDpSetStatus(u32 status);
s32 osPfsDeleteFile(OSPfs* pfs, u16 company_code, u32 game_code, u8* game_name, u8* ext_name);
// ? func_801043B8(?);
s32 __osPfsReleasePages(OSPfs* pfs, __OSInode* inode, u8 initialPage, u8 bank, __OSInodeUnit* finalPage);
void guOrthoF(f32[4][4], f32, f32, f32, f32, f32, f32, f32);
void guOrtho(Mtx*, f32, f32, f32, f32, f32, f32, f32);
f32 cosf(f32);
@@ -2476,20 +2476,20 @@ s32 osPfsIsPlug(OSMesgQueue* mq, u8* pattern);
void __osPfsRequestData(u8 poll);
void __osPfsGetInitData(u8 *pattern, OSContStatus* contData);
void guS2DInitBg(uObjBg *bg);
// ? func_80104C80(?);
s32 __osPfsSelectBank(OSPfs *pfs, u8 bank);
s32 osContSetCh(u8 ch);
s32 osPfsFileState(OSPfs* pfs, s32 file_no, OSPfsState* state);
s32 osPfsInitPak(OSMesgQueue* mq, OSPfs* pfs, s32 controller_no);
// ? func_80105148(?);
// ? func_80105250(?);
// ? func_80105788(?);
// ? func_80105A60(?);
s32 osPfsInitPak(OSMesgQueue* mq, OSPfs* pfs, s32 channel);
s32 __osPfsCheckRamArea(OSPfs* pfs);
s32 osPfsChecker(OSPfs* pfs);
s32 func_80105788(OSPfs* pfs, __OSInodeCache* cache);
s32 func_80105A60(OSPfs* pfs, __OSInodeUnit fpage, __OSInodeCache* cache);
// ? osAiGetLength(?);
void guTranslate(Mtx* m, f32 x, f32 y, f32 z);
// ? func_80105CF0(?);
s32 osReadMempak(OSMesgQueue* ctrlrqueue, s32 channel, u16 addr, u8* data);
u8 osMempakAddrCRC(u16 addr);
u8 osMempakDataCRC(u8* data);
s32 __osContRamWrite(OSMesgQueue* mq, s32 channel, u16 address, u8* buffer, s32 force);
s32 __osContRamRead(OSMesgQueue* ctrlrqueue, s32 channel, u16 addr, u8* data);
u8 __osContAddressCrc(u16 addr);
u8 __osContDataCrc(u8* data);
u32 __osSpGetStatus();
void __osSpSetStatus(u32 status);
void osWritebackDCacheAll(void);
+1
View File
@@ -12,6 +12,7 @@
#define SQ(x) ((x)*(x))
#define ABS(x) ((x) >= 0 ? (x) : -(x))
#define ULTRA_ABS(x) ((x) > 0) ? (x) : -(x)
#define DECR(x) ((x) == 0 ? 0 : ((x) -= 1))
#define CLAMP(x, min, max) ((x) < (min) ? (min) : (x) > (max) ? (max) : (x))
#define CLAMP_MAX(x, max) ((x) > (max) ? (max) : (x))
+16
View File
@@ -14,4 +14,20 @@ float cosf(float);
double cos(double);
float sqrtf(float f);
typedef union {
struct {
unsigned int hi;
unsigned int lo;
} word;
double d;
} du;
typedef union {
unsigned int i;
float f;
} fu;
extern float __libm_qnan_f;
#endif
+3
View File
@@ -8,6 +8,9 @@
#define SIAccessQueueSize 2
#define BLOCKSIZE 32
#define MAXCONTROLLERS 4
#define PFS_ONE_PAGE 8
#define PFS_PAGE_SIZE (BLOCKSIZE*PFS_ONE_PAGE)
#define CONT_CMD_REQUEST_STATUS 0
#define CONT_CMD_READ_BUTTON 1
+2
View File
@@ -4,6 +4,8 @@
#define GU_PI 3.1415926
/* Functions */
#define ROUND(x) (s32)(((x) >= 0.0) ? ((x) + 0.5) : ((x) - 0.5))
void guPerspectiveF(float mf[4][4], u16 *perspNorm, float fovy, float aspect,
float near, float far, float scale);
void guPerspective(Mtx *m, u16 *perspNorm, float fovy, float aspect, float near,
+91 -24
View File
@@ -3,35 +3,12 @@
#include <ultra64.h>
typedef struct {
int status;
OSMesgQueue* queue;
int channel;
u8 id[32];
u8 label[32];
int version;
int dir_size;
int inode_table; /* block location */
int minode_table; /* mirrioring inode_table */
int dir_table; /* block location */
int inode_start_page; /* page # */
u8 banks;
u8 activebank;
} OSPfs;
typedef struct {
u32 file_size; /* bytes */
u32 game_code;
u16 company_code;
char ext_name[4];
char game_name[16];
} OSPfsState;
/* File System size */
#define OS_PFS_VERSION 0x0200
#define OS_PFS_VERSION_HI (OS_PFS_VERSION >> 8)
#define OS_PFS_VERSION_LO (OS_PFS_VERSION & 255)
#define PFS_INODE_SIZE_PER_PAGE 128
#define PFS_FILE_NAME_LEN 16
#define PFS_FILE_EXT_LEN 4
#define BLOCKSIZE 32
@@ -51,6 +28,11 @@ typedef struct {
#define PFS_MOTOR_INITIALIZED 0x8
#define PFS_GBPAK_INITIALIZED 0x10
/* Definition for page usage */
#define PFS_EOF 1
#define PFS_PAGE_NOT_EXIST 2
#define PFS_PAGE_NOT_USED 3
/* File System error number */
#define PFS_ERR_NOPACK 1 /* no memory card is plugged or */
@@ -67,4 +49,89 @@ typedef struct {
#define PFS_ERR_NO_GBCART 12 /* no gb cartridge (64GB-PAK) */
#define PFS_ERR_NEW_GBCART 13 /* gb cartridge may be changed */
/* Definition for bank */
#define PFS_ID_BANK_256K 0
#define PFS_ID_BANK_1M 4
#define PFS_BANKS_256K 1
#define PFS_WRITTEN 2
#define DEF_DIR_PAGES 2
#define PFS_ID_0AREA 1
#define PFS_ID_1AREA 3
#define PFS_ID_2AREA 4
#define PFS_ID_3AREA 6
#define PFS_LABEL_AREA 7
#define PFS_ID_PAGE PFS_ONE_PAGE * 0
#define PFS_BANK_LAPPED_BY 8 /* => u8 */
#define PFS_SECTOR_PER_BANK 32
#define PFS_INODE_DIST_MAP (PFS_BANK_LAPPED_BY * PFS_SECTOR_PER_BANK)
#define PFS_SECTOR_SIZE (PFS_INODE_SIZE_PER_PAGE/PFS_SECTOR_PER_BANK)
typedef struct {
int status;
OSMesgQueue* queue;
int channel;
u8 id[32];
u8 label[32];
int version;
int dir_size;
int inode_table; /* block location */
int minode_table; /* mirrioring inode_table */
int dir_table; /* block location */
int inodeStartPage; /* page # */
u8 banks;
u8 activebank;
} OSPfs;
typedef struct {
u32 file_size; /* bytes */
u32 game_code;
u16 company_code;
char ext_name[4];
char game_name[16];
} OSPfsState;
typedef union {
struct {
u8 bank;
u8 page;
} inode_t;
u16 ipage;
} __OSInodeUnit;
typedef struct {
__OSInodeUnit inodePage[128];
} __OSInode;
typedef struct {
u32 game_code;
u16 company_code;
__OSInodeUnit start_page;
u8 status;
s8 reserved;
u16 data_sum;
u8 ext_name[PFS_FILE_EXT_LEN];
u8 game_name[PFS_FILE_NAME_LEN];
} __OSDir;
typedef struct {
u32 repaired;
u32 random;
u64 serialMid;
u64 serialLow;
u16 deviceid;
u8 banks;
u8 version;
u16 checksum;
u16 invertedChecksum;
} __OSPackId;
typedef struct {
__OSInode inode;
u8 bank;
u8 map[PFS_INODE_DIST_MAP];
} __OSInodeCache;
#endif
+2 -2
View File
@@ -822,7 +822,7 @@ extern s32 gSystemArenaLogSeverity;
//extern ? D_801344C0;
extern u32 gOSSiAccessQueueCreated; // = 0;
extern u32 gOSContInitialized; // = 0
//extern ? D_80134CF0;
extern s32 __osPfsInodeCacheChannel;
extern u8 __osPfsInodeCacheBank;
extern s32 __osPfsLastChannel;
//extern ? D_80135130;
@@ -3740,7 +3740,7 @@ extern u8 __osContLastPoll;
extern u8 __osMaxControllers;
extern OSMesgQueue __osContMesgQueue;
extern OSMesg __osContMesgBuff[4];
//extern ? D_80175860;
extern __OSInode __osPfsInodeCache;
extern OSPifRam pifMempakBuf;
//extern ? D_801759A0;
//extern ? D_801759A4;