mirror of
https://github.com/zeldaret/oot.git
synced 2025-07-13 11:24:40 +00:00
Format all src C files
This commit is contained in:
parent
251aea64ab
commit
8cfe7cce9f
652 changed files with 12488 additions and 19093 deletions
|
@ -7,13 +7,13 @@ OSMesg osSiMesgBuff[SIAccessQueueSize];
|
|||
OSMesgQueue gOsSiMessageQueue;
|
||||
u32 gOsSiAccessQueueCreated = 0;
|
||||
|
||||
void __osSiCreateAccessQueue() { //func_80100B50
|
||||
void __osSiCreateAccessQueue() {
|
||||
gOsSiAccessQueueCreated = 1;
|
||||
osCreateMesgQueue(&gOsSiMessageQueue, &osSiMesgBuff[0], SIAccessQueueSize - 1);
|
||||
osSendMesg(&gOsSiMessageQueue, NULL, OS_MESG_NOBLOCK);
|
||||
}
|
||||
|
||||
void __osSiGetAccess() { //func_80100BA0
|
||||
void __osSiGetAccess() {
|
||||
OSMesg sp1c;
|
||||
if (!gOsSiAccessQueueCreated) {
|
||||
__osSiCreateAccessQueue();
|
||||
|
@ -21,6 +21,6 @@ void __osSiGetAccess() { //func_80100BA0
|
|||
osRecvMesg(&gOsSiMessageQueue, &sp1c, OS_MESG_BLOCK);
|
||||
}
|
||||
|
||||
void __osSiRelAccess() { //func_80100BE4
|
||||
void __osSiRelAccess() {
|
||||
osSendMesg(&gOsSiMessageQueue, NULL, OS_MESG_NOBLOCK);
|
||||
}
|
||||
|
|
|
@ -1,21 +1,20 @@
|
|||
#include "libultra_internal.h"
|
||||
#include <ultra64/hardware.h>
|
||||
|
||||
s32 __osSiRawStartDma(s32 dir, void *addr) //func_801013F0
|
||||
{
|
||||
if (HW_REG(SI_STATUS_REG, u32) & (SI_STATUS_DMA_BUSY | SI_STATUS_IO_READ_BUSY)){
|
||||
s32 __osSiRawStartDma(s32 dir, void* addr) {
|
||||
if (HW_REG(SI_STATUS_REG, u32) & (SI_STATUS_DMA_BUSY | SI_STATUS_IO_READ_BUSY)) {
|
||||
return -1;
|
||||
}
|
||||
if (dir == OS_WRITE){
|
||||
if (dir == OS_WRITE) {
|
||||
osWritebackDCache(addr, 0x40);
|
||||
}
|
||||
HW_REG(SI_DRAM_ADDR_REG, void*) = (void*)osVirtualToPhysical(addr);
|
||||
if (dir == OS_READ){
|
||||
if (dir == OS_READ) {
|
||||
HW_REG(SI_PIF_ADDR_RD64B_REG, void*) = (void*)PIF_RAM_START;
|
||||
}else{
|
||||
} else {
|
||||
HW_REG(SI_PIF_ADDR_WR64B_REG, void*) = (void*)PIF_RAM_START;
|
||||
}
|
||||
if (dir == OS_READ){
|
||||
if (dir == OS_READ) {
|
||||
osInvalDCache(addr, 0x40);
|
||||
}
|
||||
return 0;
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
#include <global.h>
|
||||
#include <ultra64/hardware.h>
|
||||
|
||||
u32 __osSpGetStatus()
|
||||
{
|
||||
u32 __osSpGetStatus() {
|
||||
return HW_REG(SP_STATUS_REG, u32);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
#include <global.h>
|
||||
#include <ultra64/hardware.h>
|
||||
|
||||
void __osSpSetStatus(u32 a0)
|
||||
{
|
||||
void __osSpSetStatus(u32 a0) {
|
||||
HW_REG(SP_STATUS_REG, u32) = a0;
|
||||
}
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
#include <ultra64.h>
|
||||
#include <global.h>
|
||||
|
||||
void func_80101B40(u32* a0)
|
||||
{
|
||||
void func_80101B40(u32* a0) {
|
||||
a0[0] = 0x3F800000; // Float?
|
||||
a0[1] = 0;
|
||||
a0[2] = 0;
|
||||
|
|
|
@ -2,14 +2,14 @@
|
|||
#include <global.h>
|
||||
#include <ultra64/hardware.h>
|
||||
|
||||
u32 func_80103B30()
|
||||
{
|
||||
u32 func_80103B30() {
|
||||
register u32 status;
|
||||
|
||||
status = HW_REG(SP_STATUS_REG, u32);
|
||||
|
||||
if (status & 0x1C)
|
||||
if (status & 0x1C) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#include <global.h>
|
||||
|
||||
OSThread* func_80104140()
|
||||
{
|
||||
OSThread* func_80104140() {
|
||||
return __osActiveQueue;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#include <ultra64.h>
|
||||
#include <global.h>
|
||||
|
||||
OSThread* __osGetCurrFaultedThread()
|
||||
{
|
||||
OSThread* __osGetCurrFaultedThread() {
|
||||
return __osFaultedThread;
|
||||
}
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
#include <ultra64.h>
|
||||
#include <global.h>
|
||||
|
||||
u32* func_80106760()
|
||||
{
|
||||
u32* func_80106760() {
|
||||
register u32 sMask = __osDisableInt();
|
||||
u32* var1;
|
||||
|
||||
|
|
|
@ -2,14 +2,14 @@
|
|||
#include <global.h>
|
||||
#include <ultra64/hardware.h>
|
||||
|
||||
s32 func_801067A0(u32 a0)
|
||||
{
|
||||
s32 func_801067A0(u32 a0) {
|
||||
register u32 spStatus;
|
||||
|
||||
spStatus = HW_REG(SP_STATUS_REG, u32);
|
||||
|
||||
if (!(spStatus & SP_STATUS_HALT))
|
||||
if (!(spStatus & SP_STATUS_HALT)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
HW_REG(SP_PC_REG, u32) = a0;
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#include "libultra_internal.h"
|
||||
|
||||
void guPerspectiveF(float mf[4][4], u16 *perspNorm, float fovy, float aspect, float near, float far,
|
||||
float scale) {
|
||||
void guPerspectiveF(float mf[4][4], u16* perspNorm, float fovy, float aspect, float near, float far, float scale) {
|
||||
float yscale;
|
||||
int row;
|
||||
int col;
|
||||
|
@ -23,14 +22,14 @@ void guPerspectiveF(float mf[4][4], u16 *perspNorm, float fovy, float aspect, fl
|
|||
if (near + far <= 2.0) {
|
||||
*perspNorm = 65535;
|
||||
} else {
|
||||
*perspNorm = (double) (1 << 17) / (near + far);
|
||||
if (*perspNorm <= 0)
|
||||
*perspNorm = (double)(1 << 17) / (near + far);
|
||||
if (*perspNorm <= 0) {
|
||||
*perspNorm = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
void guPerspective(Mtx *m, u16 *perspNorm, float fovy, float aspect, float near, float far,
|
||||
float scale) {
|
||||
void guPerspective(Mtx* m, u16* perspNorm, float fovy, float aspect, float near, float far, float scale) {
|
||||
float mat[4][4];
|
||||
guPerspectiveF(mat, perspNorm, fovy, aspect, near, far, scale);
|
||||
guMtxF2L(mat, m);
|
||||
|
|
|
@ -5,19 +5,19 @@
|
|||
|
||||
pif_data_buffer_t _osPifInternalBuff;
|
||||
u8 _osCont_lastPollType;
|
||||
u8 _osCont_numControllers; //always 4
|
||||
u8 _osCont_numControllers; // always 4
|
||||
|
||||
//Not sure if the following is a struct together with the last two variables
|
||||
// Not sure if the following is a struct together with the last two variables
|
||||
u16 unk_80175812;
|
||||
u32 unk_80175814;
|
||||
u8 unk_80175818[0x20];
|
||||
u8 unk_80175818[0x20];
|
||||
|
||||
u32 gOsContInitialized = 0;
|
||||
OSMesgQueue _osContMesgQueue;
|
||||
OSMesg _osContMesgBuff[4];
|
||||
|
||||
#define HALF_SECOND OS_USEC_TO_CYCLES(500000)
|
||||
s32 osContInit(OSMesgQueue *mq, u8 *ctl_present_bitfield, OSContStatus *status) { //func_80100C10
|
||||
s32 osContInit(OSMesgQueue* mq, u8* ctl_present_bitfield, OSContStatus* status) {
|
||||
OSMesg mesg;
|
||||
s32 ret = 0;
|
||||
OSTime currentTime;
|
||||
|
@ -47,8 +47,8 @@ s32 osContInit(OSMesgQueue *mq, u8 *ctl_present_bitfield, OSContStatus *status)
|
|||
return ret;
|
||||
}
|
||||
|
||||
void __osContGetInitData(u8 *ctl_present_bitfield, OSContStatus *status) { //func_80100D6C
|
||||
PIF_IO_slot_t *slot_ptr;
|
||||
void __osContGetInitData(u8* ctl_present_bitfield, OSContStatus* status) {
|
||||
PIF_IO_slot_t* slot_ptr;
|
||||
PIF_IO_slot_t slot;
|
||||
s32 i;
|
||||
u8 bitfield_temp;
|
||||
|
@ -66,11 +66,11 @@ void __osContGetInitData(u8 *ctl_present_bitfield, OSContStatus *status) { //fun
|
|||
*ctl_present_bitfield = bitfield_temp;
|
||||
}
|
||||
|
||||
void __osPackRequestData(u8 command) { //func_80100E18
|
||||
PIF_IO_slot_t *slot_ptr;
|
||||
void __osPackRequestData(u8 command) {
|
||||
PIF_IO_slot_t* slot_ptr;
|
||||
PIF_IO_slot_t slot;
|
||||
s32 i;
|
||||
for(i = 0; i < 0xF; i++) {
|
||||
for (i = 0; i < 0xF; i++) {
|
||||
_osPifInternalBuff.words[i] = 0;
|
||||
}
|
||||
_osPifInternalBuff.status_control = 1;
|
||||
|
|
|
@ -3,12 +3,10 @@
|
|||
|
||||
#include <ultra64/controller.h>
|
||||
|
||||
s32 osContStartReadData(OSMesgQueue *mq) //func_80100EF0
|
||||
{
|
||||
s32 osContStartReadData(OSMesgQueue* mq) {
|
||||
s32 ret;
|
||||
__osSiGetAccess(); //__osSiGetAccess
|
||||
if (_osCont_lastPollType != 1)
|
||||
{
|
||||
__osSiGetAccess(); // __osSiGetAccess
|
||||
if (_osCont_lastPollType != 1) {
|
||||
__osPackReadData();
|
||||
__osSiRawStartDma(OS_WRITE, &_osPifInternalBuff);
|
||||
osRecvMesg(mq, NULL, OS_MESG_BLOCK);
|
||||
|
@ -19,8 +17,8 @@ s32 osContStartReadData(OSMesgQueue *mq) //func_80100EF0
|
|||
return ret;
|
||||
}
|
||||
|
||||
void osContGetReadData(OSContPad *pad) { //func_80100F74
|
||||
PIF_IO_slot_t *slot_ptr;
|
||||
void osContGetReadData(OSContPad* pad) {
|
||||
PIF_IO_slot_t* slot_ptr;
|
||||
PIF_IO_slot_t slot;
|
||||
s32 i;
|
||||
slot_ptr = _osPifInternalBuff.slots;
|
||||
|
@ -35,12 +33,12 @@ void osContGetReadData(OSContPad *pad) { //func_80100F74
|
|||
};
|
||||
}
|
||||
|
||||
void __osPackReadData() { //func_80101000
|
||||
PIF_IO_slot_t *slot_ptr;
|
||||
void __osPackReadData() {
|
||||
PIF_IO_slot_t* slot_ptr;
|
||||
PIF_IO_slot_t slot;
|
||||
s32 i;
|
||||
slot_ptr = _osPifInternalBuff.slots;
|
||||
for(i = 0; i < 0xF; i++) {
|
||||
for (i = 0; i < 0xF; i++) {
|
||||
_osPifInternalBuff.words[i] = 0;
|
||||
}
|
||||
_osPifInternalBuff.status_control = 1;
|
||||
|
@ -51,7 +49,7 @@ void __osPackReadData() { //func_80101000
|
|||
slot.button = 0xFFFF;
|
||||
slot.rawStickX = 0xFF;
|
||||
slot.rawStickY = 0xFF;
|
||||
for(i = 0; i < _osCont_numControllers; i++) {
|
||||
for (i = 0; i < _osCont_numControllers; i++) {
|
||||
*slot_ptr++ = slot;
|
||||
}
|
||||
slot_ptr->hdr.slot_type = 0xFE;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#include <global.h>
|
||||
|
||||
u32 osDpGetStatus(void)
|
||||
{
|
||||
u32 osDpGetStatus(void) {
|
||||
return DPC_STATUS_REG;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#include <global.h>
|
||||
|
||||
void osDpSetStatus(u32 status)
|
||||
{
|
||||
void osDpSetStatus(u32 status) {
|
||||
DPC_STATUS_REG = status;
|
||||
}
|
||||
|
|
|
@ -5,25 +5,24 @@
|
|||
|
||||
pif_data_buffer_t osPifBuffers[4];
|
||||
|
||||
//func_800CF990 in 1.0
|
||||
s32 osSetVibration(unk_controller_t *arg0, u32 vibrate) //func_80100780
|
||||
{
|
||||
// func_800CF990 in 1.0
|
||||
s32 osSetVibration(unk_controller_t* arg0, u32 vibrate) {
|
||||
s32 i;
|
||||
s32 ret;
|
||||
u8 *buf;
|
||||
|
||||
u8* buf;
|
||||
|
||||
buf = (u8*)&osPifBuffers[arg0->ctrlridx];
|
||||
if (!(arg0->unk0 & 8)){
|
||||
if (!(arg0->unk0 & 8)) {
|
||||
return 5;
|
||||
}
|
||||
__osSiGetAccess();
|
||||
osPifBuffers[arg0->ctrlridx].status_control = 1;
|
||||
buf += arg0->ctrlridx;
|
||||
for(i=0; i<0x20; i++){
|
||||
((PIF_mempak_wr_t*)buf)->data[i+2] = vibrate;
|
||||
for (i = 0; i < 0x20; i++) {
|
||||
((PIF_mempak_wr_t*)buf)->data[i + 2] = vibrate;
|
||||
}
|
||||
|
||||
_osCont_lastPollType = (u8)0xfe; //last controller poll type?
|
||||
|
||||
_osCont_lastPollType = (u8)0xfe; // last controller poll type?
|
||||
__osSiRawStartDma(OS_WRITE, &osPifBuffers[arg0->ctrlridx]);
|
||||
osRecvMesg(arg0->ctrlrqueue, NULL, OS_MESG_BLOCK);
|
||||
__osSiRawStartDma(OS_READ, &osPifBuffers[arg0->ctrlridx]);
|
||||
|
@ -31,11 +30,11 @@ s32 osSetVibration(unk_controller_t *arg0, u32 vibrate) //func_80100780
|
|||
ret = ((PIF_mempak_wr_t*)buf)->hdr.status_hi_bytes_rec_lo & 0xc0;
|
||||
if (!ret) {
|
||||
if (!vibrate) {
|
||||
if (((PIF_mempak_wr_t*)buf)->data[0x22] != 0){
|
||||
if (((PIF_mempak_wr_t*)buf)->data[0x22] != 0) {
|
||||
ret = 4;
|
||||
}
|
||||
}else{
|
||||
if (((PIF_mempak_wr_t*)buf)->data[0x22] != 0xeb){
|
||||
} else {
|
||||
if (((PIF_mempak_wr_t*)buf)->data[0x22] != 0xeb) {
|
||||
ret = 4;
|
||||
}
|
||||
}
|
||||
|
@ -44,19 +43,18 @@ s32 osSetVibration(unk_controller_t *arg0, u32 vibrate) //func_80100780
|
|||
return ret;
|
||||
}
|
||||
|
||||
void osSetUpMempakWrite(s32 ctrlridx, pif_data_buffer_t* buf) //func_801009F4
|
||||
{
|
||||
void osSetUpMempakWrite(s32 ctrlridx, pif_data_buffer_t* buf) {
|
||||
u8* buf_ptr = (u8*)buf;
|
||||
PIF_mempak_wr_t mempakwr;
|
||||
s32 i;
|
||||
mempakwr.hdr.slot_type = 0xFF;
|
||||
mempakwr.hdr.bytes_send = 0x23;
|
||||
mempakwr.hdr.status_hi_bytes_rec_lo = 1;
|
||||
mempakwr.hdr.command = 3; //write mempak
|
||||
mempakwr.hdr.command = 3; // write mempak
|
||||
mempakwr.data[0] = 0xC0;
|
||||
mempakwr.data[1] = (u8)(func_80106170(0x600) | 0xC000); //yes, this is correct
|
||||
if(ctrlridx != 0){
|
||||
for(i=0; i<ctrlridx; ++i){
|
||||
mempakwr.data[1] = (u8)(func_80106170(0x600) | 0xC000); // yes, this is correct
|
||||
if (ctrlridx != 0) {
|
||||
for (i = 0; i < ctrlridx; ++i) {
|
||||
*buf_ptr++ = 0;
|
||||
}
|
||||
}
|
||||
|
@ -69,55 +67,53 @@ typedef struct {
|
|||
u8 unk[0x20];
|
||||
} unk_sp24_t;
|
||||
|
||||
s32 osProbeVibrationPack(OSMesgQueue* ctrlrqueue, unk_controller_t *unk_controller, u32 ctrlridx) //func_80100B50
|
||||
{
|
||||
s32 osProbeVibrationPack(OSMesgQueue* ctrlrqueue, unk_controller_t* unk_controller, u32 ctrlridx) {
|
||||
s32 ret;
|
||||
unk_sp24_t sp24;
|
||||
|
||||
|
||||
unk_controller->ctrlrqueue = ctrlrqueue;
|
||||
unk_controller->ctrlridx = ctrlridx;
|
||||
unk_controller->bytes[0x65] = (u8)0xff;
|
||||
unk_controller->unk0 = 0;
|
||||
|
||||
|
||||
ret = func_80104C80(unk_controller, 0xfe);
|
||||
if (ret == 2){
|
||||
if (ret == 2) {
|
||||
ret = func_80104C80(unk_controller, 0x80);
|
||||
}
|
||||
if (ret != 0){
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
ret = func_80105F40(ctrlrqueue, ctrlridx, 0x400, &sp24);
|
||||
ret = ret;
|
||||
if (ret == 2){
|
||||
if (ret == 2) {
|
||||
ret = 4; //"Controller pack communication error"
|
||||
}
|
||||
if (ret != 0){
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
if (sp24.unk[0x1F] == 0xfe){
|
||||
return 0xb; //possibly controller pack? (Some other valid return value other than vibration pack)
|
||||
if (sp24.unk[0x1F] == 0xfe) {
|
||||
return 0xb; // possibly controller pack? (Some other valid return value other than vibration pack)
|
||||
}
|
||||
ret = func_80104C80(unk_controller, 0x80);
|
||||
if (ret == 2){
|
||||
if (ret == 2) {
|
||||
ret = 4; //"Controller pack communication error"
|
||||
}
|
||||
if (ret != 0){
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
ret = func_80105F40(ctrlrqueue, ctrlridx, 0x400, &sp24);
|
||||
if (ret == 2){
|
||||
if (ret == 2) {
|
||||
ret = 4; //"Controller pack communication error"
|
||||
}
|
||||
if (ret != 0){
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
if (sp24.unk[0x1F] != 0x80){
|
||||
return 0xb; //possibly controller pack? (Some other valid return value other than vibration pack)
|
||||
if (sp24.unk[0x1F] != 0x80) {
|
||||
return 0xb; // possibly controller pack? (Some other valid return value other than vibration pack)
|
||||
}
|
||||
if ((unk_controller->unk0 & 8) == 0){
|
||||
if ((unk_controller->unk0 & 8) == 0) {
|
||||
osSetUpMempakWrite(ctrlridx, &osPifBuffers[ctrlridx]);
|
||||
}
|
||||
unk_controller->unk0 = 8;
|
||||
return 0; //"Recognized vibration pack"
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue