mirror of
https://github.com/zeldaret/oot.git
synced 2024-11-13 04:39:36 +00:00
Decompile the last of libultra_code_O2 (#464)
* Decompile osPfsFileState, move guMtxL2F to asm/ * Remove asm * Add some prototypes to functions.h
This commit is contained in:
parent
af326f5b78
commit
92bb1fb210
8 changed files with 84 additions and 156 deletions
|
@ -1,4 +1,15 @@
|
|||
glabel func_80102FA0
|
||||
.include "macro.inc"
|
||||
|
||||
# assembler directives
|
||||
.set noat # allow manual use of $at
|
||||
.set noreorder # don't insert nops after branches
|
||||
.set gp=64 # allow use of 64-bit general purpose registers
|
||||
|
||||
.section .text
|
||||
|
||||
.balign 16
|
||||
|
||||
glabel guMtxL2F
|
||||
/* B7A140 80102FA0 3C013780 */ li $at, 0x37800000 # 0.000000
|
||||
/* B7A144 80102FA4 44810000 */ mtc1 $at, $f0
|
||||
/* B7A148 80102FA8 3C19FFFF */ li $t9, 0xFFFF0000 # 0.000000
|
||||
|
@ -25,4 +36,4 @@ glabel func_80102FA0
|
|||
/* B7A198 80102FF8 14B8FFED */ bne $a1, $t8, .L80102FB0
|
||||
/* B7A19C 80102FFC E492FFFC */ swc1 $f18, -4($a0)
|
||||
/* B7A1A0 80103000 03E00008 */ jr $ra
|
||||
/* B7A1A4 80103004 00000000 */ nop
|
||||
/* B7A1A4 80103004 00000000 */ nop
|
|
@ -1,135 +0,0 @@
|
|||
glabel osPfsFileState
|
||||
/* B7BF00 80104D60 27BDFEA0 */ addiu $sp, $sp, -0x160
|
||||
/* B7BF04 80104D64 AFBF002C */ sw $ra, 0x2c($sp)
|
||||
/* B7BF08 80104D68 AFB40028 */ sw $s4, 0x28($sp)
|
||||
/* B7BF0C 80104D6C AFB30024 */ sw $s3, 0x24($sp)
|
||||
/* B7BF10 80104D70 AFB20020 */ sw $s2, 0x20($sp)
|
||||
/* B7BF14 80104D74 AFB1001C */ sw $s1, 0x1c($sp)
|
||||
/* B7BF18 80104D78 AFB00018 */ sw $s0, 0x18($sp)
|
||||
/* B7BF1C 80104D7C AFA60168 */ sw $a2, 0x168($sp)
|
||||
/* B7BF20 80104D80 8C8E0050 */ lw $t6, 0x50($a0)
|
||||
/* B7BF24 80104D84 00A08025 */ move $s0, $a1
|
||||
/* B7BF28 80104D88 00809825 */ move $s3, $a0
|
||||
/* B7BF2C 80104D8C 00AE082A */ slt $at, $a1, $t6
|
||||
/* B7BF30 80104D90 10200003 */ beqz $at, .L80104DA0
|
||||
/* B7BF34 80104D94 00000000 */ nop
|
||||
/* B7BF38 80104D98 04A30004 */ bgezl $a1, .L80104DAC
|
||||
/* B7BF3C 80104D9C 8E6F0000 */ lw $t7, ($s3)
|
||||
.L80104DA0:
|
||||
/* B7BF40 80104DA0 1000005E */ b .L80104F1C
|
||||
/* B7BF44 80104DA4 24020005 */ li $v0, 5
|
||||
/* B7BF48 80104DA8 8E6F0000 */ lw $t7, ($s3)
|
||||
.L80104DAC:
|
||||
/* B7BF4C 80104DAC 31F80001 */ andi $t8, $t7, 1
|
||||
/* B7BF50 80104DB0 17000003 */ bnez $t8, .L80104DC0
|
||||
/* B7BF54 80104DB4 00000000 */ nop
|
||||
/* B7BF58 80104DB8 10000058 */ b .L80104F1C
|
||||
/* B7BF5C 80104DBC 24020005 */ li $v0, 5
|
||||
.L80104DC0:
|
||||
/* B7BF60 80104DC0 0C040AFC */ jal __osCheckId
|
||||
/* B7BF64 80104DC4 02602025 */ move $a0, $s3
|
||||
/* B7BF68 80104DC8 50400004 */ beql $v0, $zero, .L80104DDC
|
||||
/* B7BF6C 80104DCC 92790065 */ lbu $t9, 0x65($s3)
|
||||
/* B7BF70 80104DD0 10000053 */ b .L80104F20
|
||||
/* B7BF74 80104DD4 8FBF002C */ lw $ra, 0x2c($sp)
|
||||
/* B7BF78 80104DD8 92790065 */ lbu $t9, 0x65($s3)
|
||||
.L80104DDC:
|
||||
/* B7BF7C 80104DDC 02602025 */ move $a0, $s3
|
||||
/* B7BF80 80104DE0 53200008 */ beql $t9, $zero, .L80104E04
|
||||
/* B7BF84 80104DE4 8E68005C */ lw $t0, 0x5c($s3)
|
||||
/* B7BF88 80104DE8 0C041320 */ jal __osPfsSelectBank
|
||||
/* B7BF8C 80104DEC 00002825 */ move $a1, $zero
|
||||
/* B7BF90 80104DF0 50400004 */ beql $v0, $zero, .L80104E04
|
||||
/* B7BF94 80104DF4 8E68005C */ lw $t0, 0x5c($s3)
|
||||
/* B7BF98 80104DF8 10000049 */ b .L80104F20
|
||||
/* B7BF9C 80104DFC 8FBF002C */ lw $ra, 0x2c($sp)
|
||||
/* B7BFA0 80104E00 8E68005C */ lw $t0, 0x5c($s3)
|
||||
.L80104E04:
|
||||
/* B7BFA4 80104E04 8E640004 */ lw $a0, 4($s3)
|
||||
/* B7BFA8 80104E08 8E650008 */ lw $a1, 8($s3)
|
||||
/* B7BFAC 80104E0C 01103021 */ addu $a2, $t0, $s0
|
||||
/* B7BFB0 80104E10 30C9FFFF */ andi $t1, $a2, 0xffff
|
||||
/* B7BFB4 80104E14 01203025 */ move $a2, $t1
|
||||
/* B7BFB8 80104E18 0C0417D0 */ jal __osContRamRead
|
||||
/* B7BFBC 80104E1C 27A70038 */ addiu $a3, $sp, 0x38
|
||||
/* B7BFC0 80104E20 10400003 */ beqz $v0, .L80104E30
|
||||
/* B7BFC4 80104E24 97AA003C */ lhu $t2, 0x3c($sp)
|
||||
/* B7BFC8 80104E28 1000003D */ b .L80104F20
|
||||
/* B7BFCC 80104E2C 8FBF002C */ lw $ra, 0x2c($sp)
|
||||
.L80104E30:
|
||||
/* B7BFD0 80104E30 11400003 */ beqz $t2, .L80104E40
|
||||
/* B7BFD4 80104E34 8FAB0038 */ lw $t3, 0x38($sp)
|
||||
/* B7BFD8 80104E38 15600003 */ bnez $t3, .L80104E48
|
||||
/* B7BFDC 80104E3C 27B40034 */ addiu $s4, $sp, 0x34
|
||||
.L80104E40:
|
||||
/* B7BFE0 80104E40 10000036 */ b .L80104F1C
|
||||
/* B7BFE4 80104E44 24020005 */ li $v0, 5
|
||||
.L80104E48:
|
||||
/* B7BFE8 80104E48 27AC003E */ addiu $t4, $sp, 0x3e
|
||||
/* B7BFEC 80104E4C 95810000 */ lhu $at, ($t4)
|
||||
/* B7BFF0 80104E50 00009025 */ move $s2, $zero
|
||||
/* B7BFF4 80104E54 241000FF */ li $s0, 255
|
||||
/* B7BFF8 80104E58 27B10058 */ addiu $s1, $sp, 0x58
|
||||
/* B7BFFC 80104E5C A6810000 */ sh $at, ($s4)
|
||||
.L80104E60:
|
||||
/* B7C000 80104E60 97AF0034 */ lhu $t7, 0x34($sp)
|
||||
/* B7C004 80104E64 8E780060 */ lw $t8, 0x60($s3)
|
||||
/* B7C008 80104E68 93B90034 */ lbu $t9, 0x34($sp)
|
||||
/* B7C00C 80104E6C 02602025 */ move $a0, $s3
|
||||
/* B7C010 80104E70 01F8082A */ slt $at, $t7, $t8
|
||||
/* B7C014 80104E74 14200011 */ bnez $at, .L80104EBC
|
||||
/* B7C018 80104E78 02202825 */ move $a1, $s1
|
||||
/* B7C01C 80104E7C 12190008 */ beq $s0, $t9, .L80104EA0
|
||||
/* B7C020 80104E80 00003025 */ move $a2, $zero
|
||||
/* B7C024 80104E84 03208025 */ move $s0, $t9
|
||||
/* B7C028 80104E88 0C040B31 */ jal __osPfsRWInode
|
||||
/* B7C02C 80104E8C 332700FF */ andi $a3, $t9, 0xff
|
||||
/* B7C030 80104E90 50400004 */ beql $v0, $zero, .L80104EA4
|
||||
/* B7C034 80104E94 93A80035 */ lbu $t0, 0x35($sp)
|
||||
/* B7C038 80104E98 10000021 */ b .L80104F20
|
||||
/* B7C03C 80104E9C 8FBF002C */ lw $ra, 0x2c($sp)
|
||||
.L80104EA0:
|
||||
/* B7C040 80104EA0 93A80035 */ lbu $t0, 0x35($sp)
|
||||
.L80104EA4:
|
||||
/* B7C044 80104EA4 26520001 */ addiu $s2, $s2, 1
|
||||
/* B7C048 80104EA8 00084840 */ sll $t1, $t0, 1
|
||||
/* B7C04C 80104EAC 02295021 */ addu $t2, $s1, $t1
|
||||
/* B7C050 80104EB0 95410000 */ lhu $at, ($t2)
|
||||
/* B7C054 80104EB4 1000FFEA */ b .L80104E60
|
||||
/* B7C058 80104EB8 A6810000 */ sh $at, ($s4)
|
||||
.L80104EBC:
|
||||
/* B7C05C 80104EBC 97AC0034 */ lhu $t4, 0x34($sp)
|
||||
/* B7C060 80104EC0 24010001 */ li $at, 1
|
||||
/* B7C064 80104EC4 8FA20168 */ lw $v0, 0x168($sp)
|
||||
/* B7C068 80104EC8 11810003 */ beq $t4, $at, .L80104ED8
|
||||
/* B7C06C 80104ECC 00127200 */ sll $t6, $s2, 8
|
||||
/* B7C070 80104ED0 10000012 */ b .L80104F1C
|
||||
/* B7C074 80104ED4 24020003 */ li $v0, 3
|
||||
.L80104ED8:
|
||||
/* B7C078 80104ED8 AC4E0000 */ sw $t6, ($v0)
|
||||
/* B7C07C 80104EDC 97AF003C */ lhu $t7, 0x3c($sp)
|
||||
/* B7C080 80104EE0 27A40048 */ addiu $a0, $sp, 0x48
|
||||
/* B7C084 80104EE4 2445000E */ addiu $a1, $v0, 0xe
|
||||
/* B7C088 80104EE8 A44F0008 */ sh $t7, 8($v0)
|
||||
/* B7C08C 80104EEC 8FB80038 */ lw $t8, 0x38($sp)
|
||||
/* B7C090 80104EF0 24060010 */ li $a2, 16
|
||||
/* B7C094 80104EF4 0C001BC4 */ jal bcopy
|
||||
/* B7C098 80104EF8 AC580004 */ sw $t8, 4($v0)
|
||||
/* B7C09C 80104EFC 8FA50168 */ lw $a1, 0x168($sp)
|
||||
/* B7C0A0 80104F00 27A40044 */ addiu $a0, $sp, 0x44
|
||||
/* B7C0A4 80104F04 24060004 */ li $a2, 4
|
||||
/* B7C0A8 80104F08 0C001BC4 */ jal bcopy
|
||||
/* B7C0AC 80104F0C 24A5000A */ addiu $a1, $a1, 0xa
|
||||
/* B7C0B0 80104F10 8E640004 */ lw $a0, 4($s3)
|
||||
/* B7C0B4 80104F14 0C040644 */ jal __osPfsGetStatus
|
||||
/* B7C0B8 80104F18 8E650008 */ lw $a1, 8($s3)
|
||||
.L80104F1C:
|
||||
/* B7C0BC 80104F1C 8FBF002C */ lw $ra, 0x2c($sp)
|
||||
.L80104F20:
|
||||
/* B7C0C0 80104F20 8FB00018 */ lw $s0, 0x18($sp)
|
||||
/* B7C0C4 80104F24 8FB1001C */ lw $s1, 0x1c($sp)
|
||||
/* B7C0C8 80104F28 8FB20020 */ lw $s2, 0x20($sp)
|
||||
/* B7C0CC 80104F2C 8FB30024 */ lw $s3, 0x24($sp)
|
||||
/* B7C0D0 80104F30 8FB40028 */ lw $s4, 0x28($sp)
|
||||
/* B7C0D4 80104F34 03E00008 */ jr $ra
|
||||
/* B7C0D8 80104F38 27BD0160 */ addiu $sp, $sp, 0x160
|
|
@ -2493,7 +2493,7 @@ s32 osPfsFreeBlocks(OSPfs* pfs, s32* leftoverBytes);
|
|||
void guScale(Mtx* m, f32 x, f32 y, f32 z);
|
||||
f32 sinf(f32);
|
||||
s16 sins(u16);
|
||||
// ? func_801004C0(?);
|
||||
OSTask* _VirtualToPhysicalTask(OSTask* intp);
|
||||
void osSpTaskLoad(OSTask* task);
|
||||
void osSpTaskStartGo(OSTask* task);
|
||||
s32 osSetRumble(OSPfs* pfs, u32 vibrate);
|
||||
|
@ -2518,7 +2518,7 @@ s32 osPfsReadWriteFile(OSPfs* pfs, s32 fileNo, u8 flag, s32 offset, s32 size, u8
|
|||
s32 __osPfsGetStatus(OSMesgQueue* queue, s32 channel);
|
||||
void __osPfsRequestOneChannel(s32 channel, u8 poll);
|
||||
void __osPfsGetOneChannelData(s32 channel, OSContStatus* contData);
|
||||
// ? guMtxIdentF(?);
|
||||
void guMtxIdentF(f32 mf[4][4]);
|
||||
void guLookAtF(f32 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 companyCode, u32 gameCode, u8* gameName, u8* extName, s32 length, s32* fileNo);
|
||||
|
@ -2531,25 +2531,28 @@ 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(?);
|
||||
void guMtxL2F(MtxF* m1, Mtx* m2);
|
||||
s32 osPfsFindFile(OSPfs* pfs, u16 companyCode, u32 gameCode, u8* gameName, u8* extName, s32* fileNo);
|
||||
s32 osAfterPreNMI(void);
|
||||
s32 osContStartQuery(OSMesgQueue* mq);
|
||||
void osContGetQuery(OSContStatus* data);
|
||||
// ? guLookAtHiliteF(?);
|
||||
void guLookAtHiliteF(f32 mf[4][4], LookAt* l, Hilite* h, f32 xEye, f32 yEye, f32 zEye, f32 xAt, f32 yAt, f32 zAt,
|
||||
f32 xUp, f32 yUp, f32 zUp, f32 xl1, f32 yl1, f32 zl1,
|
||||
f32 xl2, f32 yl2, f32 zl2,
|
||||
s32 hiliteWidth, s32 hiliteHeight);
|
||||
void guLookAtHilite(Mtx* m, LookAt* l, Hilite* h, f32 xEye, f32 yEye, f32 zEye, f32 xAt, f32 yAt, f32 zAt, f32 xUp,
|
||||
f32 yUp, f32 zUp, f32 xl1, f32 yl1, f32 zl1, f32 xl2, f32 yl2, f32 zl2, s32 hiliteWidth,
|
||||
s32 hiliteHeight);
|
||||
u32 __osSpDeviceBusy();
|
||||
// ? guMtxIdent(?);
|
||||
void guMtxIdent(f32 m[4][4]);
|
||||
void guPositionF(f32 mf[4][4], f32 rot, f32 pitch, f32 yaw, f32 scale, f32 x, f32 y, f32 z);
|
||||
void guPosition(Mtx*, f32, f32, f32, f32, f32, f32, f32);
|
||||
OSYieldResult osSpTaskYielded(OSTask* task);
|
||||
// ? guRotateF(?);
|
||||
void guRotateF(f32 m[4][4], f32 a, f32 x, f32 y, f32 z);
|
||||
void guRotate(Mtx*, f32 angle, f32 x, f32 y, f32 z);
|
||||
s32 osAiSetFrequency(u32 frequency);
|
||||
OSThread* __osGetActiveQueue();
|
||||
// ? guNormalize(?);
|
||||
void guNormalize(f32* x, f32* y, f32* z);
|
||||
u32 osDpGetStatus(void);
|
||||
void osDpSetStatus(u32 status);
|
||||
s32 osPfsDeleteFile(OSPfs* pfs, u16 companyCode, u32 gameCode, u8* gameName, u8* extName);
|
||||
|
@ -2582,7 +2585,7 @@ u32 __osSpGetStatus();
|
|||
void __osSpSetStatus(u32 status);
|
||||
void osWritebackDCacheAll(void);
|
||||
OSThread* __osGetCurrFaultedThread();
|
||||
// ? guMtxF2L(?);
|
||||
void guMtxF2L(MtxF* m1, Mtx* m2);
|
||||
// ? __d_to_ll(?);
|
||||
// ? __f_to_ll(?);
|
||||
// ? __d_to_ull(?);
|
||||
|
|
4
spec
4
spec
|
@ -460,7 +460,7 @@ beginseg
|
|||
include "build/src/libultra_code_O2/pfsallocatefile.o"
|
||||
include "build/src/libultra_code_O1/osStopTimer.o"
|
||||
include "build/src/libultra_code_O2/contpfs.o"
|
||||
include "build/src/libultra_code_O2/code_80102FA0.o"
|
||||
include "build/asm/guMtxL2F.o"
|
||||
include "build/src/libultra_code_O2/osPfsFindFile.o"
|
||||
include "build/src/libultra_code_O2/sqrtf.o"
|
||||
include "build/src/libultra_code_O2/osAfterPreNMI.o"
|
||||
|
@ -486,7 +486,7 @@ beginseg
|
|||
include "build/src/libultra_code_O2/guS2DInitBg.o"
|
||||
include "build/src/libultra_code_O2/__osPfsSelectBank.o"
|
||||
include "build/src/libultra_code_O2/osContSetCh.o"
|
||||
include "build/src/libultra_code_O2/code_80104D60.o"
|
||||
include "build/src/libultra_code_O2/osPfsFileState.o"
|
||||
include "build/src/libultra_code_O2/pfsinitpak.o"
|
||||
include "build/src/libultra_code_O2/pfschecker.o"
|
||||
include "build/src/libultra_code_O2/osAiGetLength.o"
|
||||
|
|
|
@ -19,5 +19,5 @@ void MtxConv_F2L(MatrixInternal* m1, MtxF* m2) {
|
|||
void MtxConv_L2F(MtxF* m1, MatrixInternal* m2) {
|
||||
LogUtils_CheckNullPointer("m1", m1, "../mtxuty-cvt.c", 55);
|
||||
LogUtils_CheckNullPointer("m2", m2, "../mtxuty-cvt.c", 56);
|
||||
func_80102FA0(m1, m2); // guMtxL2F ?
|
||||
guMtxL2F(m1, (Mtx*)m2);
|
||||
}
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
#include "ultra64.h"
|
||||
#include "global.h"
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80102FA0/func_80102FA0.s")
|
|
@ -1,4 +0,0 @@
|
|||
#include "ultra64.h"
|
||||
#include "global.h"
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80104D60/osPfsFileState.s")
|
57
src/libultra_code_O2/osPfsFileState.c
Normal file
57
src/libultra_code_O2/osPfsFileState.c
Normal file
|
@ -0,0 +1,57 @@
|
|||
#include "ultra64.h"
|
||||
#include "global.h"
|
||||
|
||||
s32 osPfsFileState(OSPfs* pfs, s32 fileNo, OSPfsState* state) {
|
||||
s32 ret;
|
||||
s32 pages;
|
||||
__OSInode inode;
|
||||
__OSDir dir;
|
||||
__OSInodeUnit page;
|
||||
u8 bank;
|
||||
|
||||
if (fileNo >= pfs->dir_size || fileNo < 0) {
|
||||
return PFS_ERR_INVALID;
|
||||
}
|
||||
if (!(pfs->status & PFS_INITIALIZED)) {
|
||||
return PFS_ERR_INVALID;
|
||||
}
|
||||
if ((ret = __osCheckId(pfs)) != 0) {
|
||||
return ret;
|
||||
}
|
||||
if (pfs->activebank != 0 && (ret = __osPfsSelectBank(pfs, 0)) != 0) {
|
||||
return ret;
|
||||
}
|
||||
if ((ret = __osContRamRead(pfs->queue, pfs->channel, pfs->dir_table + fileNo, &dir)) != 0) {
|
||||
return ret;
|
||||
}
|
||||
if (dir.company_code == 0 || dir.game_code == 0) {
|
||||
return PFS_ERR_INVALID;
|
||||
}
|
||||
|
||||
page = dir.start_page;
|
||||
pages = 0;
|
||||
bank = 0xFF;
|
||||
while (true) {
|
||||
if (page.ipage < pfs->inodeStartPage) {
|
||||
break;
|
||||
}
|
||||
if (page.inode_t.bank != bank) {
|
||||
bank = page.inode_t.bank;
|
||||
if ((ret = __osPfsRWInode(pfs, &inode, PFS_READ, bank)) != 0) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
pages++;
|
||||
page = inode.inodePage[page.inode_t.page];
|
||||
}
|
||||
if (page.ipage != PFS_EOF) {
|
||||
return PFS_ERR_INCONSISTENT;
|
||||
}
|
||||
|
||||
state->file_size = pages * PFS_ONE_PAGE * BLOCKSIZE;
|
||||
state->company_code = dir.company_code;
|
||||
state->game_code = dir.game_code;
|
||||
bcopy(&dir.game_name, state->game_name, PFS_FILE_NAME_LEN);
|
||||
bcopy(&dir.ext_name, state->ext_name, PFS_FILE_EXT_LEN);
|
||||
return __osPfsGetStatus(pfs->queue, pfs->channel);
|
||||
}
|
Loading…
Reference in a new issue