diff --git a/asm/non_matchings/camera/func_80065EA0.s b/asm/non_matchings/camera/func_80065EA0.s index a27e86f8..1d0f7afa 100644 --- a/asm/non_matchings/camera/func_80065EA0.s +++ b/asm/non_matchings/camera/func_80065EA0.s @@ -96,10 +96,10 @@ glabel func_80065EA0 /* 066BF4 80065FF4 C426709C */ lwc1 $f6, %lo(D_800E709C)($at) /* 066BF8 80065FF8 3C013F80 */ li $at, 0x3F800000 # 1.000000 /* 066BFC 80065FFC 44814000 */ mtc1 $at, $f8 -/* 066C00 80066000 3C058012 */ lui $a1, %hi(D_80120D58+20) # $a1, 0x8012 +/* 066C00 80066000 3C058012 */ lui $a1, %hi(perspNorm+20) # $a1, 0x8012 /* 066C04 80066004 3C073FAA */ lui $a3, (0x3FAAAAAB >> 16) # lui $a3, 0x3faa /* 066C08 80066008 34E7AAAB */ ori $a3, (0x3FAAAAAB & 0xFFFF) # ori $a3, $a3, 0xaaab -/* 066C0C 8006600C 24A50D6C */ addiu $a1, %lo(D_80120D58+20) # addiu $a1, $a1, 0xd6c +/* 066C0C 8006600C 24A50D6C */ addiu $a1, %lo(perspNorm+20) # addiu $a1, $a1, 0xd6c /* 066C10 80066010 02002025 */ move $a0, $s0 /* 066C14 80066014 3C064270 */ lui $a2, 0x4270 /* 066C18 80066018 E7A40010 */ swc1 $f4, 0x10($sp) diff --git a/asm/non_matchings/camera/func_80067D3C.s b/asm/non_matchings/camera/func_80067D3C.s index 8166b733..a019e182 100644 --- a/asm/non_matchings/camera/func_80067D3C.s +++ b/asm/non_matchings/camera/func_80067D3C.s @@ -6,9 +6,9 @@ glabel func_80067D3C /* 06894C 80067D4C 3C0FB400 */ lui $t7, 0xb400 /* 068950 80067D50 246E0008 */ addiu $t6, $v1, 8 /* 068954 80067D54 AC8E0000 */ sw $t6, ($a0) -/* 068958 80067D58 3C188012 */ lui $t8, %hi(D_80120D58+20) # $t8, 0x8012 +/* 068958 80067D58 3C188012 */ lui $t8, %hi(perspNorm+20) # $t8, 0x8012 /* 06895C 80067D5C AC6F0000 */ sw $t7, ($v1) -/* 068960 80067D60 97180D6C */ lhu $t8, %lo(D_80120D58+20)($t8) +/* 068960 80067D60 97180D6C */ lhu $t8, %lo(perspNorm+20)($t8) /* 068964 80067D64 3C068012 */ lui $a2, %hi(D_80120CE4) # $a2, 0x8012 /* 068968 80067D68 AC780004 */ sw $t8, 4($v1) /* 06896C 80067D6C 24C60CE4 */ addiu $a2, %lo(D_80120CE4) # addiu $a2, $a2, 0xce4 diff --git a/asm/non_matchings/camera/func_80068514.s b/asm/non_matchings/camera/func_80068514.s index 8f9f28b8..3078ef43 100644 --- a/asm/non_matchings/camera/func_80068514.s +++ b/asm/non_matchings/camera/func_80068514.s @@ -27,12 +27,12 @@ glabel func_80068514 /* 069178 80068578 E7A8005C */ swc1 $f8, 0x5c($sp) /* 06917C 8006857C C4F20010 */ lwc1 $f18, 0x10($a3) /* 069180 80068580 C42A0D40 */ lwc1 $f10, %lo(D_80120D40)($at) -/* 069184 80068584 3C018012 */ lui $at, %hi(D_80120D58) # $at, 0x8012 +/* 069184 80068584 3C018012 */ lui $at, %hi(perspNorm) # $at, 0x8012 /* 069188 80068588 46125101 */ sub.s $f4, $f10, $f18 /* 06918C 8006858C 00390821 */ addu $at, $at, $t9 /* 069190 80068590 E7A40058 */ swc1 $f4, 0x58($sp) /* 069194 80068594 C4E80014 */ lwc1 $f8, 0x14($a3) -/* 069198 80068598 C4260D58 */ lwc1 $f6, %lo(D_80120D58)($at) +/* 069198 80068598 C4260D58 */ lwc1 $f6, %lo(perspNorm)($at) /* 06919C 8006859C 84E40000 */ lh $a0, ($a3) /* 0691A0 800685A0 0C01C1F1 */ jal func_800707C4 /* 0691A4 800685A4 46083501 */ sub.s $f20, $f6, $f8 @@ -119,12 +119,12 @@ glabel func_80068514 /* 0692DC 800686DC C42A0D40 */ lwc1 $f10, %lo(D_80120D40)($at) /* 0692E0 800686E0 C6120010 */ lwc1 $f18, 0x10($s0) /* 0692E4 800686E4 46083001 */ sub.s $f0, $f6, $f8 -/* 0692E8 800686E8 3C018012 */ lui $at, %hi(D_80120D58) # $at, 0x8012 +/* 0692E8 800686E8 3C018012 */ lui $at, %hi(perspNorm) # $at, 0x8012 /* 0692EC 800686EC 46125101 */ sub.s $f4, $f10, $f18 /* 0692F0 800686F0 002C0821 */ addu $at, $at, $t4 /* 0692F4 800686F4 E7A40058 */ swc1 $f4, 0x58($sp) /* 0692F8 800686F8 C6080014 */ lwc1 $f8, 0x14($s0) -/* 0692FC 800686FC C4260D58 */ lwc1 $f6, %lo(D_80120D58)($at) +/* 0692FC 800686FC C4260D58 */ lwc1 $f6, %lo(perspNorm)($at) /* 069300 80068700 46000282 */ mul.s $f10, $f0, $f0 /* 069304 80068704 46083501 */ sub.s $f20, $f6, $f8 /* 069308 80068708 00125840 */ sll $t3, $s2, 1 diff --git a/asm/non_matchings/camera/func_80069484.s b/asm/non_matchings/camera/func_80069484.s index 126b9ed1..efb96809 100644 --- a/asm/non_matchings/camera/func_80069484.s +++ b/asm/non_matchings/camera/func_80069484.s @@ -192,9 +192,9 @@ glabel func_80069484 /* 06A370 80069770 E7A40044 */ swc1 $f4, 0x44($sp) /* 06A374 80069774 E4280D40 */ swc1 $f8, %lo(D_80120D40)($at) /* 06A378 80069778 C7AA0044 */ lwc1 $f10, 0x44($sp) -/* 06A37C 8006977C 3C018012 */ lui $at, %hi(D_80120D58) # $at, 0x8012 +/* 06A37C 8006977C 3C018012 */ lui $at, %hi(perspNorm) # $at, 0x8012 /* 06A380 80069780 00220821 */ addu $at, $at, $v0 /* 06A384 80069784 27BD0050 */ addiu $sp, $sp, 0x50 /* 06A388 80069788 03E00008 */ jr $ra -/* 06A38C 8006978C E42A0D58 */ swc1 $f10, %lo(D_80120D58)($at) +/* 06A38C 8006978C E42A0D58 */ swc1 $f10, %lo(perspNorm)($at) diff --git a/asm/non_matchings/camera/func_80069790.s b/asm/non_matchings/camera/func_80069790.s index 31d9a00f..07f3f809 100644 --- a/asm/non_matchings/camera/func_80069790.s +++ b/asm/non_matchings/camera/func_80069790.s @@ -163,13 +163,13 @@ glabel func_80069790 /* 06A610 80069A10 0018C880 */ sll $t9, $t8, 2 /* 06A614 80069A14 00390821 */ addu $at, $at, $t9 /* 06A618 80069A18 C4260D40 */ lwc1 $f6, %lo(D_80120D40)($at) -/* 06A61C 80069A1C 3C018012 */ lui $at, %hi(D_80120D58) # $at, 0x8012 +/* 06A61C 80069A1C 3C018012 */ lui $at, %hi(perspNorm) # $at, 0x8012 /* 06A620 80069A20 E4A60000 */ swc1 $f6, ($a1) /* 06A624 80069A24 8C480000 */ lw $t0, ($v0) /* 06A628 80069A28 00000000 */ nop /* 06A62C 80069A2C 00084880 */ sll $t1, $t0, 2 /* 06A630 80069A30 00290821 */ addu $at, $at, $t1 -/* 06A634 80069A34 C4280D58 */ lwc1 $f8, %lo(D_80120D58)($at) +/* 06A634 80069A34 C4280D58 */ lwc1 $f8, %lo(perspNorm)($at) /* 06A638 80069A38 03E00008 */ jr $ra /* 06A63C 80069A3C E4C80000 */ swc1 $f8, ($a2) diff --git a/asm/non_matchings/controller_pak/func_80073E1C.s b/asm/non_matchings/controller_pak/func_80073E1C.s index 0c3ab296..6c798f7d 100644 --- a/asm/non_matchings/controller_pak/func_80073E1C.s +++ b/asm/non_matchings/controller_pak/func_80073E1C.s @@ -41,7 +41,7 @@ glabel func_80073E1C /* 074AB0 80073EB0 8FA70020 */ lw $a3, 0x20($sp) /* 074AB4 80073EB4 AFA2002C */ sw $v0, 0x2c($sp) /* 074AB8 80073EB8 02002025 */ move $a0, $s0 -/* 074ABC 80073EBC 0C01D984 */ jal func_80076610 +/* 074ABC 80073EBC 0C01D984 */ jal read_data_from_controller_pak /* 074AC0 80073EC0 00403025 */ move $a2, $v0 /* 074AC4 80073EC4 14400013 */ bnez $v0, .L80073F14 /* 074AC8 80073EC8 00401825 */ move $v1, $v0 diff --git a/asm/non_matchings/controller_pak/func_80074018.s b/asm/non_matchings/controller_pak/func_80074018.s index 62fef754..5dc74c34 100644 --- a/asm/non_matchings/controller_pak/func_80074018.s +++ b/asm/non_matchings/controller_pak/func_80074018.s @@ -41,7 +41,7 @@ glabel func_80074018 /* 074CAC 800740AC 8FA70020 */ lw $a3, 0x20($sp) /* 074CB0 800740B0 AFA2002C */ sw $v0, 0x2c($sp) /* 074CB4 800740B4 02002025 */ move $a0, $s0 -/* 074CB8 800740B8 0C01D984 */ jal func_80076610 +/* 074CB8 800740B8 0C01D984 */ jal read_data_from_controller_pak /* 074CBC 800740BC 00403025 */ move $a2, $v0 /* 074CC0 800740C0 1440000F */ bnez $v0, .L80074100 /* 074CC4 800740C4 00401825 */ move $v1, $v0 diff --git a/asm/non_matchings/controller_pak/func_80074B34.s b/asm/non_matchings/controller_pak/func_80074B34.s index 2a21a5f0..c6bc48e8 100644 --- a/asm/non_matchings/controller_pak/func_80074B34.s +++ b/asm/non_matchings/controller_pak/func_80074B34.s @@ -58,7 +58,7 @@ glabel func_80074B34 /* 075808 80074C08 8FA40058 */ lw $a0, 0x58($sp) /* 07580C 80074C0C 8FA50048 */ lw $a1, 0x48($sp) /* 075810 80074C10 8FA60050 */ lw $a2, 0x50($sp) -/* 075814 80074C14 0C01D984 */ jal func_80076610 +/* 075814 80074C14 0C01D984 */ jal read_data_from_controller_pak /* 075818 80074C18 24070100 */ li $a3, 256 /* 07581C 80074C1C 87A8005E */ lh $t0, 0x5e($sp) /* 075820 80074C20 87A90062 */ lh $t1, 0x62($sp) diff --git a/asm/non_matchings/controller_pak/func_80075000.s b/asm/non_matchings/controller_pak/func_80075000.s index 17cb6037..6862d71a 100644 --- a/asm/non_matchings/controller_pak/func_80075000.s +++ b/asm/non_matchings/controller_pak/func_80075000.s @@ -84,7 +84,7 @@ glabel func_80075000 /* 075D0C 8007510C 8FA5004C */ lw $a1, 0x4c($sp) /* 075D10 80075110 8FA70054 */ lw $a3, 0x54($sp) /* 075D14 80075114 00409025 */ move $s2, $v0 -/* 075D18 80075118 0C01D984 */ jal func_80076610 +/* 075D18 80075118 0C01D984 */ jal read_data_from_controller_pak /* 075D1C 8007511C 00403025 */ move $a2, $v0 /* 075D20 80075120 8FA40078 */ lw $a0, 0x78($sp) /* 075D24 80075124 0C01D6BB */ jal func_80075AEC diff --git a/asm/non_matchings/controller_pak/func_800753D8.s b/asm/non_matchings/controller_pak/func_800753D8.s index 25762857..40737298 100644 --- a/asm/non_matchings/controller_pak/func_800753D8.s +++ b/asm/non_matchings/controller_pak/func_800753D8.s @@ -52,7 +52,7 @@ glabel func_800753D8 /* 07606C 8007546C 8FA50034 */ lw $a1, 0x34($sp) /* 076070 80075470 8FA70030 */ lw $a3, 0x30($sp) /* 076074 80075474 AFA20048 */ sw $v0, 0x48($sp) -/* 076078 80075478 0C01D984 */ jal func_80076610 +/* 076078 80075478 0C01D984 */ jal read_data_from_controller_pak /* 07607C 8007547C 00403025 */ move $a2, $v0 /* 076080 80075480 8FA40050 */ lw $a0, 0x50($sp) /* 076084 80075484 0C01D6BB */ jal func_80075AEC diff --git a/asm/non_matchings/controller_pak/func_800756D4.s b/asm/non_matchings/controller_pak/func_800756D4.s index 31195ea5..cf2090e6 100644 --- a/asm/non_matchings/controller_pak/func_800756D4.s +++ b/asm/non_matchings/controller_pak/func_800756D4.s @@ -74,7 +74,7 @@ glabel func_800756D4 /* 0763D0 800757D0 8FA5005C */ lw $a1, 0x5c($sp) /* 0763D4 800757D4 8FA70058 */ lw $a3, 0x58($sp) /* 0763D8 800757D8 00409025 */ move $s2, $v0 -/* 0763DC 800757DC 0C01D984 */ jal func_80076610 +/* 0763DC 800757DC 0C01D984 */ jal read_data_from_controller_pak /* 0763E0 800757E0 00403025 */ move $a2, $v0 /* 0763E4 800757E4 1440002A */ bnez $v0, .L80075890 /* 0763E8 800757E8 AFA20064 */ sw $v0, 0x64($sp) diff --git a/asm/non_matchings/controller_pak/func_80076388.s b/asm/non_matchings/controller_pak/func_80076388.s index 08702309..e83d3fa0 100644 --- a/asm/non_matchings/controller_pak/func_80076388.s +++ b/asm/non_matchings/controller_pak/func_80076388.s @@ -42,7 +42,7 @@ glabel func_80076388 /* 077020 80076420 8FA70034 */ lw $a3, 0x34($sp) /* 077024 80076424 AFA2002C */ sw $v0, 0x2c($sp) /* 077028 80076428 02002025 */ move $a0, $s0 -/* 07702C 8007642C 0C01D984 */ jal func_80076610 +/* 07702C 8007642C 0C01D984 */ jal read_data_from_controller_pak /* 077030 80076430 00403025 */ move $a2, $v0 /* 077034 80076434 02002025 */ move $a0, $s0 /* 077038 80076438 0C01D6BB */ jal func_80075AEC diff --git a/include/PR/gu.h b/include/PR/gu.h index 6527777d..6c291e1f 100644 --- a/include/PR/gu.h +++ b/include/PR/gu.h @@ -21,6 +21,8 @@ void guMtxIdent(Mtx *m); void guMtxIdentF(float mf[4][4]); void guMtxL2F(float mf[4][4], Mtx *m); void guNormalize(float *, float *, float *); +void guMtxXFMF(float mf[4][4], float x, float y, float z, + float *ox, float *oy, float *oz); /* Used only in Fast3DEX2 */ void guLookAtReflect (Mtx *m, LookAt *l, float xEye, float yEye, float zEye, diff --git a/include/PR/os_cont.h b/include/PR/os_cont.h index 2754f250..4108b582 100644 --- a/include/PR/os_cont.h +++ b/include/PR/os_cont.h @@ -190,7 +190,7 @@ typedef struct { extern s32 osContInit(OSMesgQueue *, u8 *, OSContStatus *); extern s32 osContReset(OSMesgQueue *, OSContStatus *); extern s32 osContStartQuery(OSMesgQueue *); -extern s32 osContStartReadData(OSMesgQueue *); +extern s32 osContStartReadData(OSMesgQueue *mq); #ifndef _HW_VERSION_1 extern s32 osContSetCh(u8); #endif diff --git a/include/PR/os_eeprom.h b/include/PR/os_eeprom.h index b3bca814..18cd04e6 100644 --- a/include/PR/os_eeprom.h +++ b/include/PR/os_eeprom.h @@ -91,11 +91,11 @@ extern "C" { /* EEPROM interface */ -extern s32 osEepromProbe(OSMesgQueue *); -extern s32 osEepromRead(OSMesgQueue *, u8, u8 *); -extern s32 osEepromWrite(OSMesgQueue *, u8, u8 *); -extern s32 osEepromLongRead(OSMesgQueue *, u8, u8 *, int); -extern s32 osEepromLongWrite(OSMesgQueue *, u8, u8 *, int); +extern s32 osEepromProbe(OSMesgQueue *mq); +extern s32 osEepromRead(OSMesgQueue *mq, u8 address, u8 *buffer); +extern s32 osEepromWrite(OSMesgQueue *mq, u8 address, u8 *buffer); +extern s32 osEepromLongRead(OSMesgQueue *mq, u8 address, u8 *buffer, int nbytes); +extern s32 osEepromLongWrite(OSMesgQueue *mq, u8 address, u8 *buffer, int nbytes); #endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ diff --git a/include/PR/pfs.h b/include/PR/pfs.h index d3d2928a..0e9dc7a2 100644 --- a/include/PR/pfs.h +++ b/include/PR/pfs.h @@ -134,4 +134,22 @@ typedef struct { u8 map[PFS_INODE_DIST_MAP]; } __OSInodeCache; +/* file system interface */ + +extern s32 osPfsInitPak(OSMesgQueue *, OSPfs *, int); +extern s32 osPfsRepairId(OSPfs *); +extern s32 osPfsInit(OSMesgQueue *, OSPfs *, int); +extern s32 osPfsReFormat(OSPfs *, OSMesgQueue *, int); +extern s32 osPfsChecker(OSPfs *); +extern s32 osPfsAllocateFile(OSPfs *, u16, u32, u8 *, u8 *, int, s32 *); +extern s32 osPfsFindFile(OSPfs *, u16, u32, u8 *, u8 *, s32 *); +extern s32 osPfsDeleteFile(OSPfs *, u16, u32, u8 *, u8 *); +extern s32 osPfsReadWriteFile(OSPfs *pfs, s32 file_no, u8 flag, int offset, int nbytes, u8 * data_buffer); +extern s32 osPfsFileState(OSPfs *, s32, OSPfsState *); +extern s32 osPfsGetLabel(OSPfs *, u8 *, int *); +extern s32 osPfsSetLabel(OSPfs *, u8 *); +extern s32 osPfsIsPlug(OSMesgQueue *, u8 *); +extern s32 osPfsFreeBlocks(OSPfs *, s32 *); +extern s32 osPfsNumFiles(OSPfs *, s32 *, s32 *); + #endif diff --git a/src/asset_loading.c b/src/asset_loading.c index 6a194238..83240201 100644 --- a/src/asset_loading.c +++ b/src/asset_loading.c @@ -5,7 +5,6 @@ #include "memory.h" //#include "assets.h" -#include "types.h" #include "macros.h" #include "ultra64.h" @@ -23,16 +22,12 @@ s32 *gAssetsLookupTable; // These are both defined in the generated dkr.ld file. extern u8 __ASSETS_LUT_START, __ASSETS_LUT_END; // __ASSETS_LUT_START = 0xECB60, _END = 0xECC30 - -void *allocate_from_main_pool_safe(s32, s32); -s32 func_80071478(s32*); -void dmacopy(u32 romOffset, u8 *ramAddress, s32 numBytes); void func_80076BA0(void) { u32 assetTableSize; osCreateMesgQueue(&D_80124278, &D_80124238, 16); osCreateMesgQueue(&D_80124220, &D_80124218, 1); - osCreatePiManager(150, &D_80124278, &D_80124238, 16); + osCreatePiManager((OSPri) 150, &D_80124278, &D_80124238, 16); assetTableSize = &__ASSETS_LUT_END - &__ASSETS_LUT_START; gAssetsLookupTable = (s32*)allocate_from_main_pool_safe(assetTableSize, COLOR_TAG_GRAY); func_80071478(gAssetsLookupTable); @@ -180,8 +175,8 @@ s32 get_size_of_asset_section(u32 assetIndex) { /** * Copies data from the game cartridge to a ram address. */ -void dmacopy(u32 romOffset, u8 *ramAddress, s32 numBytes) { - s32 sp4C; +void dmacopy(u32 romOffset, u32 ramAddress, s32 numBytes) { + OSMesg *sp4C; s32 numBytesToDMA; osInvalDCache(ramAddress, numBytes); diff --git a/src/asset_loading.h b/src/asset_loading.h index 142c49f5..140bb0bc 100644 --- a/src/asset_loading.h +++ b/src/asset_loading.h @@ -1,4 +1,14 @@ #ifndef _UNKNOWN_0777A0_H_ #define _UNKNOWN_0777A0_H_ +#include "types.h" + +void func_80076BA0(void); +s32 *load_asset_section_from_rom(u32 assetIndex); +s32 load_asset_section_from_rom_to_address(u32 assetIndex, s32 *address); +s32 load_asset_to_address(u32 assetIndex, s32 *address, s32 assetOffset, s32 size); +u8 *get_rom_offset_of_asset(u32 assetIndex, s32 assetOffset); +s32 get_size_of_asset_section(u32 assetIndex); +void dmacopy(u32 romOffset, u32 ramAddress, s32 numBytes); + #endif diff --git a/src/audio.c b/src/audio.c index bc50c3af..0c63e8f9 100644 --- a/src/audio.c +++ b/src/audio.c @@ -124,7 +124,6 @@ typedef struct audioMgrConfig_s{ void func_80000968(s32 arg0); ALCSPlayer *func_80002224(s32, s32); void func_8000B010(ALCSPlayer*, u8); -void *allocate_from_main_pool_safe(u32, u32); void *load_asset_section_from_rom(u32); void *alHeapDBAlloc(u8 *file, s32 line, ALHeap *hp, s32 num, s32 size); diff --git a/src/camera.c b/src/camera.c index 8501db1f..60166422 100644 --- a/src/camera.c +++ b/src/camera.c @@ -1,7 +1,6 @@ /* The comment below is needed for this file to be picked up by generate_ld */ /* RAM_POS: 0x80065EA0 */ -#include "libultra_internal.h" #include "camera.h" extern u32 osTvType; @@ -95,30 +94,6 @@ s16 gButtonMask = 0xFFFF; /************ .bss ************/ -/* Size: 0x44 bytes, might just be Object? */ -typedef struct unk80120AC0 { - s16 unk0; - s16 unk2; - s16 unk4; - u8 pad6[6]; - f32 x_position; - f32 y_position; - f32 z_position; - f32 pad18; - f32 unk1C; - f32 pad20; - f32 unk24; - f32 unk28; - f32 unk2C; - f32 unk30; - s16 unk34; - s16 pad36; - s16 unk38; - s8 pad3A; - s8 unk3B; - u8 pad3C[8]; -} unk80120AC0; - unk80120AC0 D_80120AC0[8]; s32 gNumberOfViewports; s32 D_80120CE4; @@ -135,31 +110,22 @@ s32 D_80120D1C; s32 D_80120D20[2]; s32 D_80120D28[6]; s32 D_80120D40[6]; -u16 *D_80120D58[6]; +u16 *perspNorm[6]; Mtx *D_80120D70[6]; s32 D_80120D88[6]; Mtx D_80120DA0[5]; Matrix D_80120EE0; Matrix D_80120F20; Matrix D_80120F60; -s32 D_80120FA0[16]; -s32 D_80120FE0[16]; -s32 D_80121020[16]; +Matrix D_80120FA0; +Matrix D_80120FE0; +Matrix D_80121020; Matrix D_80121060; -s32 D_801210A0[16]; +Matrix D_801210A0; OSMesgQueue *D_801210E0[6]; s32 D_801210F8; s32 D_801210FC; u8 D_80121100[16]; - -/* Size: 6 bytes */ -typedef struct unk80121110 { - u16 unk0; - s8 unk2; - s8 unk3; - s8 unk4; - s8 unk6; -} unk80121110; unk80121110 D_80121110[8]; u16 D_80121140[4]; u16 D_80121148[4]; @@ -167,28 +133,6 @@ u8 D_80121150[16]; /******************************/ -extern s32 D_A4000000; -extern s32 SP_IMEM; - -unk80120AC0 *func_80069D20(void); -void func_800014BC(f32 arg0); -s8 *get_misc_asset(s32 arg0); -s32 func_8006A624(s8 arg0); -void guMtxXFMF(Matrix, f32, f32, f32, f32*, f32*, f32*); -void func_8006F870(Matrix, s32[16]); -s16 get_level_segment_index_from_position(f32, f32, f32); -void func_8006A50C(void); -void func_800665E8(s32 arg0); -void load_level_2(s32 arg0, s32 arg1, s32 arg2, s32 arg3); -void func_8006C164(void); -void func_8000E194(void); -f32 sqrtf(f32); -void osSetTime(u64); -void func_8001D5E0(f32 arg0, f32 arg1, f32 arg2); -void func_800705F8(s32, f32, f32, f32); -void func_8006ECFC(s32 arg0); -void func_80068158(Gfx **dlist, s32 arg1, s32 arg2, s32 arg3, s32 arg4); - #ifdef NON_MATCHING void func_800663DC(s32 x_pos, s32 y_pos, s32 z_pos, s32 arg3, s32 arg4, s32 arg5); extern s32 D_A4600010; @@ -217,7 +161,7 @@ void func_80065EA0(void) { if ((D_B0000578 & 0xFFFF) != 0x8965) { D_800DD060 = 1; } - guPerspectiveF(&D_80120EE0, &D_80120D58[5], CAMERA_DEFAULT_FOV, CAMERA_ASPECT, CAMERA_NEAR, CAMERA_FAR, CAMERA_SCALE); + guPerspectiveF(&D_80120EE0, &perspNorm[5], CAMERA_DEFAULT_FOV, CAMERA_ASPECT, CAMERA_NEAR, CAMERA_FAR, CAMERA_SCALE); func_8006F870(&D_80120EE0, &D_80120FE0); gCurCamFOV = CAMERA_DEFAULT_FOV; } @@ -252,21 +196,21 @@ f32 get_current_camera_fov(void) { void update_camera_fov(f32 camFieldOfView) { if (CAMERA_MIN_FOV < camFieldOfView && camFieldOfView < CAMERA_MAX_FOV && camFieldOfView != gCurCamFOV) { gCurCamFOV = camFieldOfView; - guPerspectiveF(D_80120EE0, &D_80120D58[5], camFieldOfView, + guPerspectiveF(D_80120EE0, &perspNorm[5], camFieldOfView, CAMERA_ASPECT, CAMERA_NEAR, CAMERA_FAR, CAMERA_SCALE); func_8006F870(D_80120EE0, D_80120FE0); } } void func_80066194(void) { - guPerspectiveF(D_80120EE0, &D_80120D58[5], CAMERA_DEFAULT_FOV, + guPerspectiveF(D_80120EE0, &perspNorm[5], CAMERA_DEFAULT_FOV, CAMERA_ASPECT, CAMERA_NEAR, CAMERA_FAR, CAMERA_SCALE); func_8006F870(D_80120EE0, D_80120FE0); } /* Unused? */ -s32 *func_80066204(void) { - return D_801210A0; +Matrix *func_80066204(void) { + return &D_801210A0; } s32 get_viewport_count(void) { @@ -277,8 +221,6 @@ s32 func_80066220(void) { return D_80120CE4; } -void func_80066CDC(Gfx **dlist, s32 arg1); - void func_80066230(Gfx **dlist, s32 arg1) { unk80120AC0 *someStruct; s16 sp2A; @@ -333,11 +275,11 @@ f32 func_80066348(f32 arg0, f32 arg1, f32 arg2) { return sqrtf((temp_f0 * temp_f0) + ((temp_f2 * temp_f2) + (temp_f14 * temp_f14))); } -void func_800663DC(s32 x_pos, s32 y_pos, s32 z_pos, s32 arg3, s32 arg4, s32 arg5) { +void func_800663DC(s32 xPos, s32 yPos, s32 zPos, s32 arg3, s32 arg4, s32 arg5) { D_80120AC0[D_80120CE4].unk4 = (s16) (arg3 * 0xB6); - D_80120AC0[D_80120CE4].x_position = (f32) x_pos; - D_80120AC0[D_80120CE4].y_position = (f32) y_pos; - D_80120AC0[D_80120CE4].z_position = (f32) z_pos; + D_80120AC0[D_80120CE4].x_position = (f32) xPos; + D_80120AC0[D_80120CE4].y_position = (f32) yPos; + D_80120AC0[D_80120CE4].z_position = (f32) zPos; D_80120AC0[D_80120CE4].unk2 = (s16) (arg4 * 0xB6); D_80120AC0[D_80120CE4].unk38 = (u16)0; D_80120AC0[D_80120CE4].unk24 = 0.0f; @@ -349,16 +291,16 @@ void func_800663DC(s32 x_pos, s32 y_pos, s32 z_pos, s32 arg3, s32 arg4, s32 arg5 D_80120AC0[D_80120CE4].unk3B = D_800DD2F8[D_80120CE4]; } -void func_80066488(s32 arg0, f32 arg1, f32 arg2, f32 arg3, s16 arg4, s16 arg5, s16 arg6) { +void func_80066488(s32 arg0, f32 xPos, f32 yPos, f32 zPos, s16 arg4, s16 arg5, s16 arg6) { arg0 += 4; D_80120AC0[arg0].unk38 = 0; - D_80120AC0[arg0].x_position = arg1; - D_80120AC0[arg0].y_position = arg2; - D_80120AC0[arg0].z_position = arg3; + D_80120AC0[arg0].x_position = xPos; + D_80120AC0[arg0].y_position = yPos; + D_80120AC0[arg0].z_position = zPos; D_80120AC0[arg0].unk0 = arg4; D_80120AC0[arg0].unk2 = arg5; D_80120AC0[arg0].unk4 = arg6; - D_80120AC0[arg0].unk34 = get_level_segment_index_from_position(arg1, arg2, arg3); + D_80120AC0[arg0].unk34 = get_level_segment_index_from_position(xPos, yPos, zPos); D_80120D14 = 1; } @@ -470,32 +412,32 @@ void func_80066610(void) { GLOBAL_ASM("asm/non_matchings/camera/func_80066610.s") #endif -void func_80066818(s32 arg0, s32 arg1) { +void func_80066818(s32 viewPortIndex, s32 arg1) { if (arg1 != 0) { - gScreenViewports[arg0].flags |= 1; + gScreenViewports[viewPortIndex].flags |= 1; } else { - gScreenViewports[arg0].flags |= 2; + gScreenViewports[viewPortIndex].flags |= 2; } - gScreenViewports[arg0].flags &= ~4; + gScreenViewports[viewPortIndex].flags &= ~4; } -void func_80066894(s32 arg0, s32 arg1) { +void func_80066894(s32 viewPortIndex, s32 arg1) { if (arg1 != 0) { - gScreenViewports[arg0].flags &= ~1; + gScreenViewports[viewPortIndex].flags &= ~1; } else { - gScreenViewports[arg0].flags |= 4; + gScreenViewports[viewPortIndex].flags |= 4; } - gScreenViewports[arg0].flags &= ~2; + gScreenViewports[viewPortIndex].flags &= ~2; } -s32 func_80066910(s32 arg0) { - return gScreenViewports[arg0].flags & 0x1; +s32 func_80066910(s32 viewPortIndex) { + return gScreenViewports[viewPortIndex].flags & 0x1; } #ifdef NON_MATCHING // Should be functionally equivalent. -void func_80066940(s32 arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4) { +void func_80066940(s32 viewPortIndex, s32 arg1, s32 arg2, s32 arg3, s32 arg4) { s32 widthAndHeight, width, height; s32 phi_a1; s32 phi_a2; @@ -517,84 +459,84 @@ void func_80066940(s32 arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4) { phi_a2 = arg2; } if ((phi_a1 >= width) || (phi_a3 < 0) || (arg2 >= height) || (phi_a2 < 0)) { - gScreenViewports[arg0].unk20 = 0; - gScreenViewports[arg0].unk24 = 0; - gScreenViewports[arg0].unk28 = 0; - gScreenViewports[arg0].unk2C = 0; + gScreenViewports[viewPortIndex].unk20 = 0; + gScreenViewports[viewPortIndex].unk24 = 0; + gScreenViewports[viewPortIndex].unk28 = 0; + gScreenViewports[viewPortIndex].unk2C = 0; } else { if (phi_a1 < 0) { - gScreenViewports[arg0].unk20 = 0; + gScreenViewports[viewPortIndex].unk20 = 0; } else { - gScreenViewports[arg0].unk20 = phi_a1; + gScreenViewports[viewPortIndex].unk20 = phi_a1; } if (arg2 < 0) { - gScreenViewports[arg0].unk24 = 0; + gScreenViewports[viewPortIndex].unk24 = 0; } else { - gScreenViewports[arg0].unk24 = arg2; + gScreenViewports[viewPortIndex].unk24 = arg2; } if (phi_a3 >= width) { - gScreenViewports[arg0].unk28 = width - 1; + gScreenViewports[viewPortIndex].unk28 = width - 1; } else { - gScreenViewports[arg0].unk28 = phi_a3; + gScreenViewports[viewPortIndex].unk28 = phi_a3; } if (phi_a2 >= height) { - gScreenViewports[arg0].unk2C = height - 1; + gScreenViewports[viewPortIndex].unk2C = height - 1; } else { - gScreenViewports[arg0].unk2C = phi_a2; + gScreenViewports[viewPortIndex].unk2C = phi_a2; } } - gScreenViewports[arg0].unk4 = arg2; - gScreenViewports[arg0].unk0 = phi_a1; - gScreenViewports[arg0].unk8 = phi_a3; - gScreenViewports[arg0].unkC = phi_a2; + gScreenViewports[viewPortIndex].unk4 = arg2; + gScreenViewports[viewPortIndex].unk0 = phi_a1; + gScreenViewports[viewPortIndex].unk8 = phi_a3; + gScreenViewports[viewPortIndex].unkC = phi_a2; } #else GLOBAL_ASM("asm/non_matchings/camera/func_80066940.s") #endif -void func_80066AA8(s32 arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4) { +void func_80066AA8(s32 viewPortIndex, s32 arg1, s32 arg2, s32 arg3, s32 arg4) { if (arg1 != 0x8000) { - gScreenViewports[arg0].unk10 = arg1; - gScreenViewports[arg0].flags |= 8; + gScreenViewports[viewPortIndex].unk10 = arg1; + gScreenViewports[viewPortIndex].flags |= 8; } else { - gScreenViewports[arg0].flags &= ~8; + gScreenViewports[viewPortIndex].flags &= ~8; } if (arg2 != 0x8000) { - gScreenViewports[arg0].unk10 = arg2; - gScreenViewports[arg0].flags |= 0x10; + gScreenViewports[viewPortIndex].unk10 = arg2; + gScreenViewports[viewPortIndex].flags |= 0x10; } else { - gScreenViewports[arg0].flags &= ~0x10; + gScreenViewports[viewPortIndex].flags &= ~0x10; } if (arg3 != 0x8000) { - gScreenViewports[arg0].unk18 = arg3; - gScreenViewports[arg0].flags |= 0x20; + gScreenViewports[viewPortIndex].unk18 = arg3; + gScreenViewports[viewPortIndex].flags |= 0x20; } else { - gScreenViewports[arg0].flags &= ~0x20; + gScreenViewports[viewPortIndex].flags &= ~0x20; } if (arg4 != 0x8000) { - gScreenViewports[arg0].unk1C = arg4; - gScreenViewports[arg0].flags |= 0x40; + gScreenViewports[viewPortIndex].unk1C = arg4; + gScreenViewports[viewPortIndex].flags |= 0x40; return; } - gScreenViewports[arg0].flags &= ~0x40; + gScreenViewports[viewPortIndex].flags &= ~0x40; } -s32 func_80066BA8(s32 arg0, s32 *arg1, s32 *arg2, s32 *arg3, s32 *arg4) { - *arg1 = gScreenViewports[arg0].unk20; - *arg3 = gScreenViewports[arg0].unk28; - *arg2 = gScreenViewports[arg0].unk24; - *arg4 = gScreenViewports[arg0].unk2C; +s32 func_80066BA8(s32 viewPortIndex, s32 *arg1, s32 *arg2, s32 *arg3, s32 *arg4) { + *arg1 = gScreenViewports[viewPortIndex].unk20; + *arg3 = gScreenViewports[viewPortIndex].unk28; + *arg2 = gScreenViewports[viewPortIndex].unk24; + *arg4 = gScreenViewports[viewPortIndex].unk2C; if ((*arg1 | *arg3 | *arg2 | *arg4) == 0) { return 0; } return 1; } -void func_80066C2C(s32 arg0, s32 *arg1, s32 *arg2, s32 *arg3, s32 *arg4) { - *arg1 = gScreenViewports[arg0].unk0; - *arg2 = gScreenViewports[arg0].unk4; - *arg3 = gScreenViewports[arg0].unk8; - *arg4 = gScreenViewports[arg0].unkC; +void func_80066C2C(s32 viewPortIndex, s32 *arg1, s32 *arg2, s32 *arg3, s32 *arg4) { + *arg1 = gScreenViewports[viewPortIndex].unk0; + *arg2 = gScreenViewports[viewPortIndex].unk4; + *arg3 = gScreenViewports[viewPortIndex].unk8; + *arg4 = gScreenViewports[viewPortIndex].unkC; } // Unused? @@ -655,14 +597,14 @@ void func_80066CDC(Gfx **dlist, s32 arg1) { temp_a2 = temp_t1 >> 1; sp54 = temp_a2; sp58 = temp_a3; - if (osTvType == 0) { + if (osTvType == TV_TYPE_PAL) { sp58 = 0x91; } switch(gNumberOfViewports) { case VIEWPORTS_COUNT_1_PLAYER: phi_t3 = sp58; - if (osTvType == 0) { + if (osTvType == TV_TYPE_PAL) { phi_t3 = sp58 - 0x12; } gDPSetScissor((*dlist)++, SCISSOR_INTERLACE, 0, 0, temp_t1, temp_t0) @@ -672,7 +614,7 @@ void func_80066CDC(Gfx **dlist, s32 arg1) { if (D_80120CE4 == 0) { temp_v0_6 = temp_t0 >> 2; phi_t3 = temp_v0_6; - if (osTvType == 0) { + if (osTvType == TV_TYPE_PAL) { phi_t3 = temp_v0_6 - 0xC; } gDPSetScissor((*dlist)++, SCISSOR_INTERLACE, 0, 0, temp_t1, (temp_a3 - (temp_t0 >> 7))) @@ -727,7 +669,7 @@ void func_80066CDC(Gfx **dlist, s32 arg1) { } phi_t3 = phi_t5 + sp58; sp4C = phi_t4 + sp54; - if (osTvType == 0) { + if (osTvType == TV_TYPE_PAL) { phi_t3 -= 6; if (D_80120CE4 < 2) { phi_t3 -= 0x14; @@ -740,7 +682,7 @@ void func_80066CDC(Gfx **dlist, s32 arg1) { break; } - if (osTvType == 0) { + if (osTvType == TV_TYPE_PAL) { sp4C -= 4; } func_80068158(dlist, sp54, sp58, sp4C, phi_t3); @@ -876,24 +818,24 @@ unk80120AC0 *func_80069D7C(void) { return &D_80120AC0[0]; } -s32 *func_80069DA4(void) { - return D_80120FA0; +Matrix *func_80069DA4(void) { + return &D_80120FA0; } -s32 *func_80069DB0(void) { - return D_80120FE0; +Matrix *func_80069DB0(void) { + return &D_80120FE0; } -s32 *func_80069DBC(void) { - return D_80120F60; +Matrix *func_80069DBC(void) { + return &D_80120F60; } -f32 func_80069DC8(f32 arg0, f32 arg1, f32 arg2) { - f32 sp34; - f32 sp30; - f32 returnVal; - guMtxXFMF(D_80120F60, arg0, arg1, arg2, &sp34, &sp30, &returnVal); - return returnVal; +f32 func_80069DC8(f32 x, f32 y, f32 z) { + f32 ox, oy, oz; + + guMtxXFMF(D_80120F60, x, y, z, &ox, &oy, &oz); + + return oz; } void func_80069E14(f32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4) { @@ -958,8 +900,6 @@ OSMesgQueue *func_8006A100(void) { return &D_801210E0; } -void func_8006A434(void); - #ifdef NON_MATCHING // Has regalloc & stack issues. s32 func_8006A10C(void) { diff --git a/src/camera.h b/src/camera.h index 49ddb688..ad631dd6 100644 --- a/src/camera.h +++ b/src/camera.h @@ -6,6 +6,7 @@ #include "structs.h" #include "f3ddkr.h" #include "menu.h" +#include "libultra_internal.h" #define SCREEN_WIDTH 320 #define SCREEN_HEIGHT 240 @@ -49,6 +50,39 @@ typedef struct ScreenViewport { s32 flags; } ScreenViewport; +/* Size: 6 bytes */ +typedef struct unk80121110 { + u16 unk0; + s8 unk2; + s8 unk3; + s8 unk4; + s8 unk6; +} unk80121110; + +/* Size: 0x44 bytes, might just be Object? */ +typedef struct unk80120AC0 { + s16 unk0; + s16 unk2; + s16 unk4; + u8 pad6[6]; + f32 x_position; + f32 y_position; + f32 z_position; + f32 pad18; + f32 unk1C; + f32 pad20; + f32 unk24; + f32 unk28; + f32 unk2C; + f32 unk30; + s16 unk34; + s16 pad36; + s16 unk38; + s8 pad3A; + s8 unk3B; + u8 pad3C[8]; +} unk80120AC0; + extern ScreenViewport gScreenViewports[4]; // Not sure about the typing here @@ -69,4 +103,80 @@ extern s32 D_800DD300; extern s16 gButtonMask; +extern s32 D_A4000000; + +extern s32 SP_IMEM; + +//TODO: Remove from here once header files for below are created with these signatures. + void func_800014BC(f32 arg0); //audio.c + s8* get_misc_asset(s32 arg0); //unknown_00BC20 + void func_8006F870(Matrix, Matrix); //unknown_070110 + s16 get_level_segment_index_from_position(f32 xPos, f32 yPos, f32 zPos); //unknown_0255E0 + void load_level_2(s32 arg0, s32 arg1, s32 arg2, s32 arg3); //unknown_06B2B0 + void func_8006C164(void); //unknown_00BC20 + void func_8000E194(void); //unknown_00BC20 + void func_8001D5E0(f32 arg0, f32 arg1, f32 arg2); //unknown_00BC20 + void func_800705F8(s32, f32, f32, f32); //From unknown_070110 + void func_8006ECFC(s32 arg0); //From unknown_06B2B0 + +f32 sqrtf(f32); //IDO? + +void func_80066060(s32 arg0, s32 arg1); +void func_80066098(s8 arg0); +void func_800660C0(void); +void func_800660D0(void); +f32 get_current_camera_fov(void); +void update_camera_fov(f32 camFieldOfView); +void func_80066194(void); +Matrix *func_80066204(void); +s32 get_viewport_count(void); +s32 func_80066220(void); +void func_80066CDC(Gfx **dlist, s32 arg1); +void func_80066230(Gfx **dlist, s32 arg1); +f32 func_80066348(f32 arg0, f32 arg1, f32 arg2); +void func_800663DC(s32 xPos, s32 yPos, s32 zPos, s32 arg3, s32 arg4, s32 arg5); +void func_80066488(s32 arg0, f32 xPos, f32 yPos, f32 zPos, s16 arg4, s16 arg5, s16 arg6); +void func_80066520(void); +s8 func_80066510(void); +s32 func_8006652C(s32 arg0); +void func_800665E8(s32 arg0); +void func_80066818(s32 viewPortIndex, s32 arg1); +void func_80066894(s32 viewPortIndex, s32 arg1); +s32 func_80066910(s32 viewPortIndex); +void func_80066940(s32 viewPortIndex, s32 arg1, s32 arg2, s32 arg3, s32 arg4); +void func_80066AA8(s32 viewPortIndex, s32 arg1, s32 arg2, s32 arg3, s32 arg4); +s32 func_80066BA8(s32 viewPortIndex, s32 *arg1, s32 *arg2, s32 *arg3, s32 *arg4); +void func_80066C2C(s32 viewPortIndex, s32 *arg1, s32 *arg2, s32 *arg3, s32 *arg4); +void func_80066C80(s32 *arg0, s32 *arg1, s32 *arg2, s32 *arg3); +void func_80066CDC(Gfx **dlist, s32 arg1); +void func_80067F20(f32 arg0); +void func_80067F2C(Gfx **dlist, s32 *arg1); +void func_8006807C(Gfx **dlist, s32 *arg1); +void func_80068158(Gfx **dlist, s32 arg1, s32 arg2, s32 arg3, s32 arg4); +void func_800682AC(Gfx **dlist); +void func_80068408(Gfx **dlist, s32 *arg1); +void func_80068508(s32 arg0); +unk80120AC0 *func_80069CFC(void); +unk80120AC0 *func_80069D20(void); +unk80120AC0 *func_80069D7C(void); +Matrix *func_80069DA4(void); +Matrix *func_80069DB0(void); +Matrix *func_80069DBC(void); +f32 func_80069DC8(f32 x, f32 y, f32 z); +void func_80069E14(f32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4); +void func_80069F28(f32 arg0); +void func_8006A03C(f32 *mtx); +OSMesgQueue *func_8006A100(void); +void func_8006A434(void); +void func_8006A458(s8 *activePlayers); +u8 func_8006A4F8(s32 arg0); +void func_8006A50C(void); +u16 get_buttons_held_from_player(s32 arg0); +u16 get_buttons_pressed_from_player(s32 arg0); +u16 func_8006A578(s32 arg0); +s32 func_8006A59C(s32 arg0); +s32 func_8006A5E0(s32 arg0); +s32 func_8006A624(s8 arg0); +void disable_button_mask(void); + #endif diff --git a/src/controller_pak.c b/src/controller_pak.c index 893ef906..b3e44712 100644 --- a/src/controller_pak.c +++ b/src/controller_pak.c @@ -61,7 +61,7 @@ const char D_800E7750[] = "warning: corrupt ghost\n"; /************ .bss ************/ -s32 D_80124010; +OSMesgQueue *D_80124010; s32 D_80124014; OSPfs pfs[MAXCONTROLLERS]; @@ -365,14 +365,15 @@ s32 func_80076194(s32 controllerIndex, s32 *arg1, s32 *arg2) { #ifdef NON_MATCHING // regalloc & stack issues -s32 func_800762C8(s32 controllerIndex, s32 arg1) { +// Rename delete_file_from_controller_pak? +s32 func_800762C8(s32 controllerIndex, s32 fileNum) { s16 sp3E; s16 sp3A; s32 sp30; s32 sp34; u16 sp38; s32 temp_v0; - void *temp_a0; + OSPfs *temp_a0; temp_v0 = func_800758DC(); if (temp_v0 != 0) { @@ -382,7 +383,7 @@ s32 func_800762C8(s32 controllerIndex, s32 arg1) { temp_v0 = controllerIndex << 0x1E; temp_a0 = &pfs[controllerIndex]; temp_v0 |= 9; - if (osPfsFileState(temp_a0, arg1, &sp30) == 0) { + if (osPfsFileState(temp_a0, fileNum, &sp30) == 0) { if (osPfsDeleteFile(temp_a0, sp38, sp34, &sp3E, &sp3A) == 0) { temp_v0 = 0; } @@ -398,21 +399,22 @@ GLOBAL_ASM("asm/non_matchings/controller_pak/func_800762C8.s") GLOBAL_ASM("asm/non_matchings/controller_pak/func_80076388.s") GLOBAL_ASM("asm/non_matchings/controller_pak/func_800764E8.s") -s32 func_80076610(s32 controllerIndex, s32 arg1, u8 *data, s32 dataLength) { - s32 temp_v0 = osPfsReadWriteFile(&pfs[controllerIndex], arg1, 0, 0, dataLength, data); - if (temp_v0 == 0) { +s32 read_data_from_controller_pak(s32 controllerIndex, s32 fileNum, u8 *data, s32 dataLength) { + s32 readResult = osPfsReadWriteFile(&pfs[controllerIndex], fileNum, PFS_READ, 0, dataLength, data); + //Successful read + if (readResult == 0) { return 0; } - if ((temp_v0 == 1) || (temp_v0 == 0xB)) { + if ((readResult == PFS_ERR_NOPACK) || (readResult == PFS_ERR_DEVICE)) { return 1; } - if (temp_v0 == 3) { + if (readResult == PFS_ERR_INCONSISTENT) { return 2; } - if (temp_v0 == 0xA) { + if (readResult == PFS_ERR_ID_FATAL) { return 3; } - if (temp_v0 == 5) { + if (readResult == PFS_ERR_INVALID) { return 5; } return 9; @@ -440,15 +442,15 @@ GLOBAL_ASM("asm/non_matchings/controller_pak/func_80076924.s") GLOBAL_ASM("asm/non_matchings/controller_pak/func_8007698C.s") GLOBAL_ASM("asm/non_matchings/controller_pak/func_80076A38.s") -s32 func_80076AF4(s32 controllerIndex, s32 arg1) { - s32 *temp; +s32 func_80076AF4(s32 controllerIndex, s32 fileNum) { + s32 *data; s32 pad; s32 ret; ret = 6; - temp = allocate_from_main_pool_safe(0x100, COLOR_TAG_BLACK); - if (func_80076610(controllerIndex, arg1, temp, 0x100) == 0) { - switch(*temp) { + data = allocate_from_main_pool_safe(0x100, COLOR_TAG_BLACK); + if (read_data_from_controller_pak(controllerIndex, fileNum, (u8 *)data, 0x100) == 0) { + switch(*data) { case 0x47414D44: // GAMD, Game Data? ret = 3; break; @@ -463,6 +465,6 @@ s32 func_80076AF4(s32 controllerIndex, s32 arg1) { break; } } - free_from_memory_pool(temp); + free_from_memory_pool(data); return ret; } diff --git a/src/controller_pak.h b/src/controller_pak.h index 0a342587..b3530ed1 100644 --- a/src/controller_pak.h +++ b/src/controller_pak.h @@ -7,5 +7,6 @@ extern s32 D_800DE440; extern u8 gN64FontCodes[68]; extern s32 D_800DE488; extern s32 D_800DE48C; +s32 read_data_from_controller_pak(s32 controllerIndex, s32 fileNum, u8 *data, s32 dataLength); #endif diff --git a/src/fade_transition.c b/src/fade_transition.c index d0920bb5..bc0b0d75 100644 --- a/src/fade_transition.c +++ b/src/fade_transition.c @@ -8,6 +8,7 @@ #include "f3ddkr.h" #include "asset_sections.h" #include "memory.h" +#include "PR/libultra.h" /************ .data ************/ @@ -353,7 +354,7 @@ s32 func_800C0494(s32 arg0) { void render_fade_transition(s32 dlist, s32 arg1, s32 arg2) { if (D_800E31AC != 0) { - if (osTvType == 0) { + if (osTvType == TV_TYPE_PAL) { func_80067F20(1.4f); } else { func_80067F20(1.2f); diff --git a/src/game_text.c b/src/game_text.c index f0b60410..60675404 100644 --- a/src/game_text.c +++ b/src/game_text.c @@ -6,6 +6,7 @@ #include "f3ddkr.h" #include "asset_sections.h" #include "memory.h" +#include "PR/libultra.h" /************ .data ************/ @@ -81,7 +82,7 @@ void func_800C29F0(void) { D_8012A7BA = 0; D_8012A7AE = 0x20; D_8012A7B2 = 0x120; - if (osTvType == 0) { + if (osTvType == TV_TYPE_PAL) { D_8012A7B0 = 0xE0; D_8012A7B4 = 0xF8; } else { @@ -168,7 +169,7 @@ void func_800C314C(void) { } void func_800C3158(s32 arg0, f32 arg1) { - if (osTvType == 0) { + if (osTvType == TV_TYPE_PAL) { D_800E3678 = arg1 * 50.0; } else { D_800E3678 = arg1 * 60.0; diff --git a/src/memory.h b/src/memory.h index ed5cb8d2..76cb6fbf 100644 --- a/src/memory.h +++ b/src/memory.h @@ -1,6 +1,8 @@ #ifndef _MEMORY_H_ #define _MEMORY_H_ +#include "types.h" + // Animation related? #define COLOR_TAG_RED 0xFF0000FF // Object related? @@ -22,4 +24,7 @@ // ??? #define COLOR_TAG_BLACK 0x000000FF +void *allocate_from_main_pool_safe(s32 size, u32 colorTag); +s32 func_80071478(u8 *address); + #endif diff --git a/src/menu.c b/src/menu.c index f5aaa585..d40d73b3 100644 --- a/src/menu.c +++ b/src/menu.c @@ -2271,7 +2271,7 @@ void func_800829F8(s32 arg0, s32 arg1) { set_text_color(255, 255, 255, 0, 0xFF); set_text_background_color(0, 0, 0, 0); temp = 0xD0; - if (osTvType == 0) { + if (osTvType == TV_TYPE_PAL) { temp = 0xEA; } draw_text(arg0, -0x8000, temp, gMenuText[151], 0xC); @@ -2282,7 +2282,7 @@ void menu_logos_screen_init(void) { gMenuDelay = 0; D_80126450 = 16.0f; // 16 seconds func_80077B5C(0, 0, 0); - if (osTvType == 0) { + if (osTvType == TV_TYPE_PAL) { func_80066940(0, 0, 0x26, 0x140, 0xE0); func_80066AA8(0, 0x8000, 0x8000, 0x140, 0x11C); } else { @@ -3123,7 +3123,7 @@ void func_800887E8(void) { D_801263D8 = 0; func_8009C6D4(0x3F); func_8008E4B0(); - if (osTvType == 0) { + if (osTvType == TV_TYPE_PAL) { D_80126BB4 = 8; } else { D_80126BB4 = 7; @@ -3642,7 +3642,7 @@ void draw_character_select_text(s32 arg0) { draw_text(&D_801263A0, 0xA0, 0x20, gMenuText[135], 0xC); if (gNumberOfReadyPlayers == gNumberOfActivePlayers && gNumberOfActivePlayers > 0) { yPos = 0xD0; - if (osTvType == 0) { + if (osTvType == TV_TYPE_PAL) { yPos = 0xEA; } draw_text(&D_801263A0, 0xA0, yPos, D_800E8230 /* "OK?" */, 0xC); @@ -3938,7 +3938,7 @@ void func_8008C698(s32 arg0) { (&((unk80126460*)D_80126460)[temp] + 1)->elem[1].filterAlpha = filterAlpha; } - if (osTvType == 0) { + if (osTvType == TV_TYPE_PAL) { D_800DF79C = 0xC; D_800DF7A0 = 0; } else { @@ -5354,7 +5354,7 @@ void func_800983C0(s32 arg0) { s8 *sp20; sp20 = get_misc_asset(0x1A); - if (osTvType == 0) { + if (osTvType == TV_TYPE_PAL) { sp2C = 0x12; } else { sp2C = 0; @@ -5675,7 +5675,7 @@ void menu_credits_init(void) { D_80126BD8 = 0; D_80126BE0 = 0; func_80077B5C(0, 0, 0); - if (osTvType == 0) { + if (osTvType == TV_TYPE_PAL) { func_80066940(0, 0, 0x26, 0x140, 0xE0); func_80066AA8(0, 0x8000, 0x8000, 0x140, 0x11C); } else { diff --git a/src/thread0_epc.c b/src/thread0_epc.c index a97dffb2..038e9776 100644 --- a/src/thread0_epc.c +++ b/src/thread0_epc.c @@ -5,6 +5,7 @@ #include "macros.h" #include "libultra_internal.h" #include "menu.h" +#include "controller_pak.h" /************ .rodata ************/ @@ -286,27 +287,27 @@ void func_800B76B8(s32 arg0, s32 arg1) { } s32 func_800B76DC(void) { - s32 sp824; + s32 fileNum; u8 sp820[4]; // Unused? s16 sp420[0x200]; u8 sp220[0x200]; u8 sp1D0[0x50]; // Unused? - epcInfo sp20; + epcInfo dataFromControllerPak; if (D_800E3020 != -1) { return D_800E3020; } else { D_800E3020 = 0; - if ((func_800758DC(0) == 0) && (func_800764E8(0, &D_800E8EF4, &D_800E8EFC, &sp824) == 0) - && (func_80076610(0, sp824, &sp20, 0x800) == 0)) { - bcopy(&sp20, &gEpcInfo, 0x1B0); + if ((func_800758DC(0) == 0) && (func_800764E8(0, &D_800E8EF4, &D_800E8EFC, &fileNum) == 0) + && (read_data_from_controller_pak(0, fileNum, &dataFromControllerPak, 0x800) == 0)) { + bcopy(&dataFromControllerPak, &gEpcInfo, 0x1B0); bcopy(&sp220, &D_801299B0, 0x200); bcopy(&sp420, &D_80129BB0, 0x400); D_800E3020 = 1; } func_80075AEC(0); if (D_800E3020 != 0) { - func_800762C8(0, sp824); + func_800762C8(0, fileNum); } return D_800E3020; } diff --git a/src/unknown_0255E0.c b/src/unknown_0255E0.c index 5e9f3947..274b3aa8 100644 --- a/src/unknown_0255E0.c +++ b/src/unknown_0255E0.c @@ -7,6 +7,7 @@ #include "macros.h" #include "structs.h" #include "f3ddkr.h" +#include "PR/gu.h" /* Size: 0x44 bytes */ typedef struct unk80120AC0 { @@ -225,11 +226,11 @@ typedef struct unk8011D388 { } unk8011D388; unk8011D388 D_8011D388[4]; -typedef struct{ - s32 unk00; - s32 unk04; - s32 unk08; -}unk8011D468; +typedef struct { + /* 0x00 */ s32 x; + /* 0x04 */ s32 y; + /* 0x08 */ s32 z; +} unk8011D468; unk8011D468 D_8011D468; s32 D_8011D474; @@ -255,7 +256,6 @@ s32 D_8011D4BC; /******************************/ -extern void guMtxXFMF(Matrix, f32, f32, f32, f32*, f32*, f32*); f32 func_800BB2F4(s32, f32, f32, f32*); void func_8007B3D0(Gfx**); Object *get_object(s32); @@ -1177,8 +1177,8 @@ GLOBAL_ASM("asm/non_matchings/unknown_0255E0/func_80030A74.s") GLOBAL_ASM("asm/non_matchings/unknown_0255E0/func_80030DE0.s") -void func_80031018(void){ - Matrix sp_50; +void func_80031018(void) { + Matrix mf; struct { s16 unk00; //sp_38 @@ -1191,9 +1191,9 @@ void func_80031018(void){ f32 unk14; //sp4C; } sp_38; - f32 sp_34 = 0.0f; - f32 sp_30 = 0.0f; - f32 sp_2C = -65536.0f; + f32 x = 0.0f; + f32 y = 0.0f; + f32 z = -65536.0f; sp_38.unk04 = D_8011B0B0->z_rotation; sp_38.unk02 = D_8011B0B0->x_rotation; @@ -1203,9 +1203,11 @@ void func_80031018(void){ sp_38.unk14 = 0.0f; sp_38.unk08 = 1.0f; - func_8006FC30(&sp_50, &sp_38); - guMtxXFMF(&sp_50, sp_34, sp_30, sp_2C, &sp_34, &sp_30, &sp_2C); - D_8011D468.unk00 = sp_34; - D_8011D468.unk04 = sp_30; - D_8011D468.unk08 = sp_2C; + func_8006FC30(&mf, &sp_38); + guMtxXFMF(&mf, x, y, z, &x, &y, &z); + + //Store x/y/z as integers + D_8011D468.x = (s32) x; + D_8011D468.y = (s32) y; + D_8011D468.z = (s32) z; } \ No newline at end of file diff --git a/src/unknown_043920.c b/src/unknown_043920.c index 4e288f84..392a3485 100644 --- a/src/unknown_043920.c +++ b/src/unknown_043920.c @@ -641,20 +641,18 @@ typedef struct unk800535C4 { /* Unknown Size */ typedef struct unk800535C4_2 { - u8 unk0[0x9C]; - s32 unk9C; - s32 unkA0; - s32 unkA4; - u8 unkA8[0xF8]; - s16 unk1A0; - s16 unk1A2; - s16 unk1A4; + /* 0x00 */ u8 unk0[0x9C]; + /* 0x9C */ f32 oz; + /* 0xA0 */ f32 ox; + /* 0xA4 */ f32 oy; + /* 0xA8 */ u8 unkA8[0xF8]; + /* 0x1A0 */ s16 unk1A0; + /* 0x1A2 */ s16 unk1A2; + /* 0x1A4 */ s16 unk1A4; } unk800535C4_2; -void guMtxXFMF(Matrix*, f32, f32, f32, s32*, s32*, s32*); - void func_800535C4(unk800535C4 *arg0, unk800535C4_2 *arg1) { - Matrix sp30; + Matrix mf; D_8011D510.unk0 = -arg1->unk1A0; D_8011D510.unk2 = -arg0->unk2; @@ -663,9 +661,9 @@ void func_800535C4(unk800535C4 *arg0, unk800535C4_2 *arg1) { D_8011D510.unk10 = 0; D_8011D510.unk14 = 0; D_8011D510.unk8 = 1; - func_8006FE74(&sp30, &D_8011D510); + func_8006FE74(&mf, &D_8011D510); - guMtxXFMF(&sp30, 0, -1, 0, &arg1->unkA0, &arg1->unkA4, &arg1->unk9C); + guMtxXFMF(&mf, 0.0f, -1.0f, 0.0f, &arg1->ox, &arg1->oy, &arg1->oz); } void func_80053664(Object_64 *arg0) { @@ -805,20 +803,20 @@ GLOBAL_ASM("asm/non_matchings/unknown_043920/func_80057220.s") /* Unknown size */ typedef struct Object_64_800575EC { - u8 pad0[0x38]; - f32 unk38; - f32 unk3C; - f32 unk40; - f32 unk44; - f32 unk48; - f32 unk4C; - f32 unk50; - f32 unk54; - f32 unk58; + /* 0x00 */ u8 pad0[0x38]; + /* 0x38 */ f32 ox1; + /* 0x3C */ f32 oy1; + /* 0x40 */ f32 oz1; + /* 0x44 */ f32 ox2; + /* 0x48 */ f32 oy2; + /* 0x4C */ f32 oz2; + /* 0x50 */ f32 ox3; + /* 0x54 */ f32 oy3; + /* 0x58 */ f32 oz3; } Object_64_800575EC; void func_800575EC(Object *obj, Object_64_800575EC *obj64) { - Matrix sp38; + Matrix mf; D_8011D510.unk0 = obj->y_rotation; D_8011D510.unk2 = obj->x_rotation; @@ -827,10 +825,10 @@ void func_800575EC(Object *obj, Object_64_800575EC *obj64) { D_8011D510.unk10 = 0.0f; D_8011D510.unk14 = 0.0f; D_8011D510.unk8 = 1.0f; - func_8006FC30(&sp38, &D_8011D510); - guMtxXFMF(&sp38, 0.0f, 0.0f, 1.0f, &obj64->unk38, &obj64->unk3C, &obj64->unk40); - guMtxXFMF(&sp38, 0.0f, 1.0f, 0.0f, &obj64->unk44, &obj64->unk48, &obj64->unk4C); - guMtxXFMF(&sp38, 1.0f, 0.0f, 0.0f, &obj64->unk50, &obj64->unk54, &obj64->unk58); + func_8006FC30(&mf, &D_8011D510); + guMtxXFMF(&mf, 0.0f, 0.0f, 1.0f, &obj64->ox1, &obj64->oy1, &obj64->oz1); + guMtxXFMF(&mf, 0.0f, 1.0f, 0.0f, &obj64->ox2, &obj64->oy2, &obj64->oz2); + guMtxXFMF(&mf, 1.0f, 0.0f, 0.0f, &obj64->ox3, &obj64->oy3, &obj64->oz3); } GLOBAL_ASM("asm/non_matchings/unknown_043920/func_800576E0.s") diff --git a/src/unknown_06B2B0.c b/src/unknown_06B2B0.c index da1a8665..1b12387e 100644 --- a/src/unknown_06B2B0.c +++ b/src/unknown_06B2B0.c @@ -142,7 +142,8 @@ s32 *gHudTriangles[2]; s32 gCurrHudTris; s32 D_80121230[8]; s8 D_80121250[16]; -OSSched *D_80121260[2210]; //TODO: This almost definitely isn't an array this large. +OSSched *D_80121260; +s32 D_80121268[2208]; //Padding s32 D_801234E8; s32 D_801234EC; s32 D_801234F0; @@ -167,8 +168,8 @@ s32 gCurrNumF3dCmdsPerPlayer; s32 gCurrNumHudMatPerPlayer; s32 gCurrNumHudTrisPerPlayer; s32 gCurrNumHudVertsPerPlayer; -s32 D_80123538[3]; -s32 D_80123544; +OSScClient *D_80123538[3]; +OSMesg *D_80123544; OSMesgQueue *D_80123548; s32 D_8012354C; s32 D_80123550[4]; @@ -208,7 +209,6 @@ s32 is_in_tracks_mode(void); s32 *load_asset_section_from_rom(s32); void load_asset_to_address(u32, s32*, s32, s32); void free_from_memory_pool(s32*); -void *allocate_from_main_pool_safe(s32, s32); void func_8006C1AC(s32 arg0, s32 arg1, s32 arg2, s32 arg3); void func_8006C2E4(void); s16 func_8006C2F0(void); @@ -853,7 +853,7 @@ void thread3_main(s32 arg0) { } void func_8006C3E0(void) { - s32 sp24; + s32 mode; init_main_memory_pool(); func_800C6170(); @@ -865,14 +865,14 @@ void func_8006C3E0(void) { D_80123518 = 0; if (osTvType == TV_TYPE_PAL) { - sp24 = 14; + mode = 14; } else if (osTvType == TV_TYPE_NTSC) { - sp24 = 0; + mode = 0; } else if (osTvType == TV_TYPE_MPAL) { - sp24 = 28; + mode = 28; } - osCreateScheduler(&D_80121260, &D_801234E8, 0xD, sp24, 1); + osCreateScheduler(&D_80121260, &D_801234E8, /*priority*/ 13, (u8) mode, 1); D_800DD3A0 = 0; if (func_8006EFB8() == 0) { D_800DD3A0 = 1; diff --git a/src/unknown_0ABDF0.c b/src/unknown_0ABDF0.c index 3f067980..2737b15e 100644 --- a/src/unknown_0ABDF0.c +++ b/src/unknown_0ABDF0.c @@ -5,6 +5,7 @@ #include "macros.h" #include "structs.h" #include "f3ddkr.h" +#include "PR/libultra.h" typedef struct { s16 unk0; @@ -282,7 +283,7 @@ void func_800AD220(void) { } void func_800AD2C4(s32 arg0, s32 arg1, f32 arg2) { - D_800E2C78 = osTvType == 0 ? 50.0 * arg2 : 60.0 * arg2; + D_800E2C78 = osTvType == TV_TYPE_PAL ? 50.0 * arg2 : 60.0 * arg2; D_800E2C68 = arg0; D_800E2C64 = (D_800E2C68 - D_800E2C60) / D_800E2C78; D_800E2C74 = arg1; diff --git a/src/video.c b/src/video.c index 69520cf4..16d0cced 100644 --- a/src/video.c +++ b/src/video.c @@ -48,7 +48,7 @@ s32 D_801262E8[8]; u8 D_80126308; u8 D_80126309; s32 D_8012630C; -s32 D_80126310; +OSScClient *D_80126310; /******************************/ @@ -60,7 +60,7 @@ void init_framebuffer(s32); void func_8007A974(void); void swap_framebuffers(void); -void init_video(s32 arg0, OSSched *sc) { +void init_video(s32 videoModeIndex, OSSched *sc) { if (osTvType == TV_TYPE_PAL) { gVideoRefreshRate = REFRESH_50HZ; gVideoAspectRatio = ASPECT_RATIO_PAL; @@ -83,7 +83,7 @@ void init_video(s32 arg0, OSSched *sc) { } func_8007A974(); - set_video_mode_index(arg0); + set_video_mode_index(videoModeIndex); gVideoFramebuffers[0] = 0; gVideoFramebuffers[1] = 0; init_framebuffer(0);