summaryrefslogtreecommitdiff
path: root/src/libultra_code
diff options
context:
space:
mode:
authorRoman971 <romanlasnier@hotmail.com>2020-03-22 22:19:43 +0100
committerRoman971 <romanlasnier@hotmail.com>2020-03-22 22:20:03 +0100
commit8cfe7cce9f8d8abea794e67510879e751d373a87 (patch)
treec6c46f34d3575f6dc02b98b2b5f5ad88d2b2c64e /src/libultra_code
parent251aea64ab3e6e8cd6f1d9ed34f514e656724777 (diff)
Format all src C files
Diffstat (limited to 'src/libultra_code')
-rw-r--r--src/libultra_code/__osSiCreateAccessQueue.c6
-rw-r--r--src/libultra_code/__osSiRawStartDma.c13
-rw-r--r--src/libultra_code/__osSpGetStatus.c3
-rw-r--r--src/libultra_code/__osSpSetStatus.c3
-rw-r--r--src/libultra_code/code_80101B40.c.ignore3
-rw-r--r--src/libultra_code/code_80103B30.c6
-rw-r--r--src/libultra_code/code_80104140.c3
-rw-r--r--src/libultra_code/code_801064C0.c3
-rw-r--r--src/libultra_code/code_80106760.c3
-rw-r--r--src/libultra_code/code_801067A0.c6
-rw-r--r--src/libultra_code/guPerspectiveF.c11
-rw-r--r--src/libultra_code/osContInit.c18
-rw-r--r--src/libultra_code/osContStartReadData.c20
-rw-r--r--src/libultra_code/osDpGetStatus.c3
-rw-r--r--src/libultra_code/osDpSetStatus.c3
-rw-r--r--src/libultra_code/osVibrationPack.c70
16 files changed, 79 insertions, 95 deletions
diff --git a/src/libultra_code/__osSiCreateAccessQueue.c b/src/libultra_code/__osSiCreateAccessQueue.c
index e2d0c8e33..b1ed321af 100644
--- a/src/libultra_code/__osSiCreateAccessQueue.c
+++ b/src/libultra_code/__osSiCreateAccessQueue.c
@@ -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);
}
diff --git a/src/libultra_code/__osSiRawStartDma.c b/src/libultra_code/__osSiRawStartDma.c
index 537a0fba2..d44036657 100644
--- a/src/libultra_code/__osSiRawStartDma.c
+++ b/src/libultra_code/__osSiRawStartDma.c
@@ -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;
diff --git a/src/libultra_code/__osSpGetStatus.c b/src/libultra_code/__osSpGetStatus.c
index 61b5053b2..cd68e408c 100644
--- a/src/libultra_code/__osSpGetStatus.c
+++ b/src/libultra_code/__osSpGetStatus.c
@@ -2,7 +2,6 @@
#include <global.h>
#include <ultra64/hardware.h>
-u32 __osSpGetStatus()
-{
+u32 __osSpGetStatus() {
return HW_REG(SP_STATUS_REG, u32);
}
diff --git a/src/libultra_code/__osSpSetStatus.c b/src/libultra_code/__osSpSetStatus.c
index 3bd9c84d3..01cf1adc1 100644
--- a/src/libultra_code/__osSpSetStatus.c
+++ b/src/libultra_code/__osSpSetStatus.c
@@ -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;
}
diff --git a/src/libultra_code/code_80101B40.c.ignore b/src/libultra_code/code_80101B40.c.ignore
index f0780cb74..908f84f9e 100644
--- a/src/libultra_code/code_80101B40.c.ignore
+++ b/src/libultra_code/code_80101B40.c.ignore
@@ -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;
diff --git a/src/libultra_code/code_80103B30.c b/src/libultra_code/code_80103B30.c
index 2e17bf58d..5137e4e26 100644
--- a/src/libultra_code/code_80103B30.c
+++ b/src/libultra_code/code_80103B30.c
@@ -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;
}
diff --git a/src/libultra_code/code_80104140.c b/src/libultra_code/code_80104140.c
index c2ccd0c8d..aa9fed857 100644
--- a/src/libultra_code/code_80104140.c
+++ b/src/libultra_code/code_80104140.c
@@ -1,6 +1,5 @@
#include <global.h>
-OSThread* func_80104140()
-{
+OSThread* func_80104140() {
return __osActiveQueue;
}
diff --git a/src/libultra_code/code_801064C0.c b/src/libultra_code/code_801064C0.c
index 04eafa5d8..23b73d853 100644
--- a/src/libultra_code/code_801064C0.c
+++ b/src/libultra_code/code_801064C0.c
@@ -1,7 +1,6 @@
#include <ultra64.h>
#include <global.h>
-OSThread* __osGetCurrFaultedThread()
-{
+OSThread* __osGetCurrFaultedThread() {
return __osFaultedThread;
}
diff --git a/src/libultra_code/code_80106760.c b/src/libultra_code/code_80106760.c
index e6626dfb3..e9f44fd63 100644
--- a/src/libultra_code/code_80106760.c
+++ b/src/libultra_code/code_80106760.c
@@ -1,8 +1,7 @@
#include <ultra64.h>
#include <global.h>
-u32* func_80106760()
-{
+u32* func_80106760() {
register u32 sMask = __osDisableInt();
u32* var1;
diff --git a/src/libultra_code/code_801067A0.c b/src/libultra_code/code_801067A0.c
index 2257881ab..0ea5f968c 100644
--- a/src/libultra_code/code_801067A0.c
+++ b/src/libultra_code/code_801067A0.c
@@ -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;
diff --git a/src/libultra_code/guPerspectiveF.c b/src/libultra_code/guPerspectiveF.c
index caef68560..503bcc25a 100644
--- a/src/libultra_code/guPerspectiveF.c
+++ b/src/libultra_code/guPerspectiveF.c
@@ -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);
diff --git a/src/libultra_code/osContInit.c b/src/libultra_code/osContInit.c
index dcccfb765..33cc136b8 100644
--- a/src/libultra_code/osContInit.c
+++ b/src/libultra_code/osContInit.c
@@ -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;
diff --git a/src/libultra_code/osContStartReadData.c b/src/libultra_code/osContStartReadData.c
index a96bc6f28..9bd0bfbd2 100644
--- a/src/libultra_code/osContStartReadData.c
+++ b/src/libultra_code/osContStartReadData.c
@@ -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;
diff --git a/src/libultra_code/osDpGetStatus.c b/src/libultra_code/osDpGetStatus.c
index 636bdd2f9..f9c87f1fb 100644
--- a/src/libultra_code/osDpGetStatus.c
+++ b/src/libultra_code/osDpGetStatus.c
@@ -1,6 +1,5 @@
#include <global.h>
-u32 osDpGetStatus(void)
-{
+u32 osDpGetStatus(void) {
return DPC_STATUS_REG;
}
diff --git a/src/libultra_code/osDpSetStatus.c b/src/libultra_code/osDpSetStatus.c
index 9a5f189a5..d57ca509e 100644
--- a/src/libultra_code/osDpSetStatus.c
+++ b/src/libultra_code/osDpSetStatus.c
@@ -1,6 +1,5 @@
#include <global.h>
-void osDpSetStatus(u32 status)
-{
+void osDpSetStatus(u32 status) {
DPC_STATUS_REG = status;
}
diff --git a/src/libultra_code/osVibrationPack.c b/src/libultra_code/osVibrationPack.c
index b00f25de8..033f04500 100644
--- a/src/libultra_code/osVibrationPack.c
+++ b/src/libultra_code/osVibrationPack.c
@@ -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"
}
-