Skip to content

Commit

Permalink
add clang-format and format.py and cleanup util.c
Browse files Browse the repository at this point in the history
  • Loading branch information
RevoSucks committed Sep 2, 2023
1 parent 98ef3ef commit 8897a0f
Show file tree
Hide file tree
Showing 63 changed files with 1,144 additions and 1,194 deletions.
4 changes: 3 additions & 1 deletion format.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,9 @@ def main():
files = args.files
extra_files = []
else:
files = glob.glob("src/**/*.c", recursive=True)
# Ignore libultra files. They cause too many formatter issues so we just wont format libultra for now and only
# format the game specific files. We can format libleo however.
files = [file for file in glob.glob("src/**/*.c", recursive=True) if not file.startswith('src/libultra/')]
extra_files = glob.glob("assets/**/*.xml", recursive=True)

format_files(files, extra_files, nb_jobs)
Expand Down
2 changes: 1 addition & 1 deletion include/PR/gu.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ extern float sinf(float angle);
extern float cosf(float angle);
extern signed short sins (unsigned short angle);
extern signed short coss (unsigned short angle);
extern float sqrtf(float value);
extern float sqrtf(float f);

/*
* Dump routines for low-level display lists
Expand Down
4 changes: 2 additions & 2 deletions include/PR/leo.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,8 @@ extern u32 LeoDriveExist(void);

/* Synchronous functions */
extern s32 LeoClearQueue(void);
extern s32 LeoByteToLBA(s32 startLBA, u32 nbytes, s32 *lbas);
extern s32 LeoLBAToByte(s32 startLBA, u32 nLBAs, s32 *bytes);
extern s32 LeoByteToLBA(s32 startlba, u32 nbytes, s32* lba);
extern s32 LeoLBAToByte(s32 startlba, u32 nlbas, s32* bytes);
extern s32 LeoReadCapacity(LEOCapacity *cap, s32 dir);
extern s32 LeoInquiry(LEOVersion *ver);
extern s32 LeoTestUnitReady(LEOStatus *status);
Expand Down
4 changes: 2 additions & 2 deletions include/PR/leoappli.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
/*-----------------------------------*/
/* LEO FUNCTION DEFINITIONS */
/*-----------------------------------*/
extern void leoInitialize(OSPri PRI_WRK, OSPri PRI_INT, OSMesg *command_que_buf, u32 cmd_buff_size);
extern void leoCommand(void *CDB);
extern void leoInitialize(OSPri compri, OSPri intpri, OSMesg* command_que_buf, u32 cmd_buff_size);
extern void leoCommand(void* cmd_blk_addr);
extern void LeoReset(void);
extern s32 LeoResetClear(void);

Expand Down
2 changes: 1 addition & 1 deletion include/PR/sptask.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ typedef u32 OSYieldResult;
/*
* break this up into two steps for debugging.
*/
extern void osSpTaskLoad(OSTask *tp);
extern void osSpTaskLoad(OSTask* intp);
extern void osSpTaskStartGo(OSTask *tp);

extern void osSpTaskYield(void);
Expand Down
2 changes: 1 addition & 1 deletion include/PR/xstdio.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef _XSTDIO_H
#define _XSTDIO_H
#include <ultratypes.h>
#include "ultratypes.h"
#include <stdlib.h>
#include <stdarg.h>

Expand Down
6 changes: 0 additions & 6 deletions include/functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@ extern s32 func_8005A990(OSPiHandle *);
// bcopy.s
extern void _bcopy(void *, void *, u32);

// 3A80.c
extern uintptr_t convert_addr_to_virt_addr(uintptr_t addr);
extern void func_80002F58(void);
extern void *func_80002FDC(s32);
extern void func_80003004(void *);

// 3FB0.s
extern void func_80003B30(void *, s32, s32, s32); // types unknown

Expand Down
4 changes: 2 additions & 2 deletions include/ultra64/controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@ typedef struct

extern s32 __osEepStatus(OSMesgQueue *, OSContStatus *);
u16 __osSumcalc(u8 *ptr, int length);
s32 __osIdCheckSum(u16 *ptr, u16 *csum, u16 *icsum);
s32 __osIdCheckSum(u16* ptr, u16* checkSum, u16* idSum);
s32 __osRepairPackId(OSPfs *pfs, __OSPackId *badid, __OSPackId *newid);
s32 __osCheckPackId(OSPfs *pfs, __OSPackId *temp);
s32 __osCheckPackId(OSPfs* pfs, __OSPackId* check);
s32 __osGetId(OSPfs *pfs);
s32 __osCheckId(OSPfs *pfs);
s32 __osPfsRWInode(OSPfs *pfs, __OSInode *inode, u8 flag, u8 bank);
Expand Down
6 changes: 6 additions & 0 deletions include/variables.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@

#include "ultra64.h"

// thread pris
#define THREAD_PRI_IDLE_INIT 100

// thread IDs
#define THREAD_ID_IDLE 1

#define POOL_END_4MB 0x80400000
#define POOL_END_6MB 0x80600000

Expand Down
6 changes: 3 additions & 3 deletions splat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ segments:
- [0x28E0, c, memmap]
- [0x2EC0, c, memory_main] # handles the main global pool
- [0x3640, c, memory] # memory_pool
- [0x3A80, c]
- [0x3A80, c, util]
- [0x3FB0, asm] # PRES-JPEG decoder
- [0x5580, asm] # there's a split here according to PAL
- [0x60A0, asm] #
Expand Down Expand Up @@ -325,7 +325,7 @@ segments:
- [0x68020, bin] # rest of rom part 1

# .data is somewhere in here
- [0x69790, .data, 3A80]
- [0x69790, .data, util]
- [0x697A0, bin, rom_data_697A0]
- [0x6A1B0, .data, crash_screen]
- [0x6A3B0, .data, profiler]
Expand Down Expand Up @@ -354,7 +354,7 @@ segments:
# Start of .rodata
- [0x7BAC0, .rodata, rsp]
- [0x7BB10, rodata, rom_rodata_7BB10]
- [0x7BB20, .rodata, 3A80]
- [0x7BB20, .rodata, util]
- [0x7BB50, rodata, rom_rodata_7BB50]
- [0x7BBE0, .rodata, crash_screen]
- [0x7BFA0, .rodata, profiler]
Expand Down
2 changes: 1 addition & 1 deletion src/43520.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ extern s32 D_80078580;

extern void* D_80078584;

void func_80042920(void *arg0, s32 arg1) {
void func_80042920(void* arg0, s32 arg1) {
if (D_80078580 == 0) {
D_80078580 = arg0;
if (D_80078584 == NULL) {
Expand Down
4 changes: 2 additions & 2 deletions src/4F7F0.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ struct UnkArray4* func_800495F8();
extern struct UnkArray4* D_80078584; // who did this? fix later

void func_8004EBF0(struct UnkStruct8004EBF0* arg0, f32 arg1) {
struct UnkArray4 *temp_v0;
struct UnkArray4* temp_v0;

if (arg0->unk8 != NULL) {
temp_v0 = func_800495F8();
if (temp_v0 != NULL) {
temp_v0->unk4 = (s32) (D_80078584->unk1C + arg0->unk8->unk88);
temp_v0->unk4 = (s32)(D_80078584->unk1C + arg0->unk8->unk88);
temp_v0->unk8 = 7;
temp_v0->unkC = arg1;
temp_v0->unk0 = 0;
Expand Down
37 changes: 18 additions & 19 deletions src/C030.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ extern u8 D_800A82B0[32];

extern OSMesgQueue gSIEventMesgQueue;

s32 __osContRamWrite(OSMesgQueue *mq, int channel, u16 address, u8 *buffer, int force);
s32 __osContRamRead(OSMesgQueue *mq, int channel, u16 address, u8 *buffer);
s32 __osContRamWrite(OSMesgQueue* mq, int channel, u16 address, u8* buffer, int force);
s32 __osContRamRead(OSMesgQueue* mq, int channel, u16 address, u8* buffer);

extern s32 osPfsIsPlug(OSMesgQueue *, u8 *);
extern s32 osPfsIsPlug(OSMesgQueue*, u8*);

extern u8 D_800A82CF;

Expand All @@ -30,35 +30,34 @@ s32 func_8000B4C4(void) {
u8 sp2F; // sp2F

if (D_800697E0 == 0) {
u8 *buffer;
u8* buffer;
osPfsIsPlug(&gSIEventMesgQueue, &sp2F);
if(sp2F & 8) {
if (sp2F & 8) {
Cont_BlockEepromQueue();
for(buffer = D_800A82B0, i = 0; i < 32; i++) {
for (buffer = D_800A82B0, i = 0; i < 32; i++) {
buffer[i] = 0xFE;
}
if((__osContRamWrite(&gSIEventMesgQueue, 3, 0x400, buffer, 0) == 2)
&& (__osContRamWrite(&gSIEventMesgQueue, 3, 0x400, buffer, 0) != 0)) {
if ((__osContRamWrite(&gSIEventMesgQueue, 3, 0x400, buffer, 0) == 2) &&
(__osContRamWrite(&gSIEventMesgQueue, 3, 0x400, buffer, 0) != 0)) {
Cont_NoBlockEepromQueue();
return 0;
}
if((__osContRamRead(&gSIEventMesgQueue, 3, 0x400, buffer) == 0) && (D_800A82CF == 0xFE)) {
if ((__osContRamRead(&gSIEventMesgQueue, 3, 0x400, buffer) == 0) && (D_800A82CF == 0xFE)) {
Cont_NoBlockEepromQueue();
return 0;
}
for(buffer = D_800A82B0, i = 0; i < 32; i+=4) {
buffer[i+0] = 0x85;
buffer[i+1] = 0x85;
buffer[i+2] = 0x85;
buffer[i+3] = 0x85;
for (buffer = D_800A82B0, i = 0; i < 32; i += 4) {
buffer[i + 0] = 0x85;
buffer[i + 1] = 0x85;
buffer[i + 2] = 0x85;
buffer[i + 3] = 0x85;
}
if((__osContRamWrite(&gSIEventMesgQueue, 3, 0x400, buffer, 0) == 2)
&& (__osContRamWrite(&gSIEventMesgQueue, 3, 0x400, buffer, 0) != 0)) {
if ((__osContRamWrite(&gSIEventMesgQueue, 3, 0x400, buffer, 0) == 2) &&
(__osContRamWrite(&gSIEventMesgQueue, 3, 0x400, buffer, 0) != 0)) {
Cont_NoBlockEepromQueue();
return 0;
}
if((__osContRamRead(&gSIEventMesgQueue, 3, 0x400, buffer) == 0)
&& (D_800A82CF == 0x85)) {
if ((__osContRamRead(&gSIEventMesgQueue, 3, 0x400, buffer) == 0) && (D_800A82CF == 0x85)) {
Cont_NoBlockEepromQueue();
D_800697E0 = 1;
return 1;
Expand All @@ -78,7 +77,7 @@ u8 func_8000B6B4(void) {
}

void func_8000B6FC(u8 arg0) {
u8 *buffer = D_800A82B0;
u8* buffer = D_800A82B0;
Cont_BlockEepromQueue();
__osContRamRead(&gSIEventMesgQueue, 3, 0x600, buffer);
if (D_800A82CF == 8) {
Expand Down
16 changes: 6 additions & 10 deletions src/DDC0.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,23 @@ void func_800373D8(void);
void func_8004FD44(void);
void func_8004B1CC();
void func_8004B9C4();
void func_80037340(void *);
void func_80037340(void*);
void func_8004FCD8(s32);
void func_8003D4A0(s32);
void func_8004AF24(s32);
void func_8004FD64(s32);
void func_8004AE90(s32, s32);

void func_8000D1C0(void) {

}

void func_8000D1C8(void) {

}

void func_8000D1D0(void) {

}

void func_8000D1D8(void) {

}

void func_8000D1E0(void) {
Expand Down Expand Up @@ -82,7 +78,7 @@ void func_8000D278(void) {

s32 func_8000D2B4(s32 arg0) {
s32 retvar = 0;

if (arg0 != 0) {
func_8004FCD8(2);
}
Expand Down Expand Up @@ -111,7 +107,7 @@ void func_8000D380(void) {
D_800A83A0 = 1;
}

void func_8000D3A8(void *unused) {
void func_8000D3A8(void* unused) {
__osSetFpcCsr(0x01000C01);
func_80004CC0(&D_800A8480, 1, 1);
func_80005328(&D_800A8480);
Expand All @@ -120,14 +116,14 @@ void func_8000D3A8(void *unused) {
D_800A8478 = 0;
osCreateMesgQueue(&D_800A83A8[0].queue, &D_800A83A8[0].mesg, 1);
osCreateMesgQueue(&D_800A83A8[1].queue, &D_800A83A8[1].mesg, 1);
osSendMesg(&D_800A83A8[0].queue, (void* )0x444F4E45, 0);
osSendMesg(&D_800A83A8[1].queue, (void* )0x444F4E45, 0);
osSendMesg(&D_800A83A8[0].queue, (void*)0x444F4E45, 0);
osSendMesg(&D_800A83A8[1].queue, (void*)0x444F4E45, 0);
func_800373D8();
func_8004AF24(0);
func_8004AE90(3, 4);

// thread loop
while(1) {
while (1) {
func_80004CF4(&D_800A8480);
profiler_log_thread4_time();
if ((D_800A83A0 != 0) && (D_800A62E0.unkA38 < 0x15)) {
Expand Down
32 changes: 17 additions & 15 deletions src/E1C0.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "fragments.h"
#include "memory.h"
#include "dp_intro.h"
#include "util.h"

struct UnkInputStruct8000D738 {
s32 unk0;
Expand All @@ -25,8 +26,8 @@ struct UnkStruct800AA664 {
char padding1B0[0x2030];
};

extern struct UnkStruct800AA660 *D_800AA660;
extern struct UnkStruct800AA664 *D_800AA664;
extern struct UnkStruct800AA660* D_800AA660;
extern struct UnkStruct800AA664* D_800AA664;
extern char D_800AA668;

extern u8 D_81200000[];
Expand All @@ -40,20 +41,20 @@ void func_81206D9C(void);
void func_81206E64(void);
void func_81206F38(void);

void func_80005370(struct UnkStruct800AA660 *);
void func_80004454(u32, void *, void *);
void func_80005370(struct UnkStruct800AA660*);
void func_80004454(u32, void*, void*);
char func_8000B318(char);
s32 func_800044F4(void *, void *, s32, s32);
s32 func_800044F4(void*, void*, s32, s32);
s32 func_8000484C(s32, s32);

void func_8000D5C0(void* unused) {
void (*func)(void *) = convert_addr_to_virt_addr(&func_81206F38);
void (*func)(void*) = Util_ConvertAddrToVirtAddr(&func_81206F38);

__osSetFpcCsr(0x01000C01);
func_80004CC0(D_800AA664, 0, 1);
func_80005328(D_800AA664);

while(1) {
while (1) {
func_80004CF4(D_800AA664);
if (D_800A62E0.unkA38 >= 0x15) {
continue;
Expand All @@ -62,17 +63,17 @@ void func_8000D5C0(void* unused) {
}
}

void func_8000D678(void *unused) {
void (*func1)(void *func) = convert_addr_to_virt_addr(&func_81206D9C);
void (*func2)(void *func) = convert_addr_to_virt_addr(&func_81206E64);
void func_8000D678(void* unused) {
void (*func1)(void* func) = Util_ConvertAddrToVirtAddr(&func_81206D9C);
void (*func2)(void* func) = Util_ConvertAddrToVirtAddr(&func_81206E64);

__osSetFpcCsr(0x01000C01);
func_80004CC0(D_800AA660, 0, 1);
func_80005328(D_800AA660);
func1(D_800AA660);
osStartThread(D_800AA664);

while(1) {
while (1) {
func_80004CF4(D_800AA660);
if (D_800A62E0.unkA38 >= 0x15) {
continue;
Expand All @@ -87,14 +88,15 @@ void func_8000D738(struct UnkInputStruct8000D738* arg0) {
main_pool_push_state('GBEM');
D_800AA660 = (void*)main_pool_alloc_node_no_func(0x2210, 0);
D_800AA664 = (void*)main_pool_alloc_node_no_func(0x21E0, 0);
func_80004454(((u32) ((u32) &fragment1_TEXT_START & 0x0FF00000) >> 0x14) - 0x10, &fragment1_ROM_START, &fragment1_ROM_END);
func_80004454(((u32)((u32)&fragment1_TEXT_START & 0x0FF00000) >> 0x14) - 0x10, &fragment1_ROM_START,
&fragment1_ROM_END);
temp_v0 = func_800044F4(&D_3BA190, &D_3CB130, 1, 1);
D_800AA660->unk21FC = func_8000484C(temp_v0, 0);
D_800AA660->unk2200 = func_8000484C(temp_v0, 1);
D_800AA660->unk2204 = *arg0;
osCreateMesgQueue(&D_800AA660->queue, &D_800AA660->mesg, 1);
osCreateThread(&D_800AA664->thread, 10, func_8000D5C0, NULL, (u32)D_800AA664 + 0x21E0, 0x11);
osCreateThread(&D_800AA660->thread, 8, func_8000D678, NULL, (u32)D_800AA660 + 0x21E0, 0xF);
osCreateThread(&D_800AA664->thread, 10, func_8000D5C0, NULL, (u32)D_800AA664 + 0x21E0, 0x11);
osCreateThread(&D_800AA660->thread, 8, func_8000D678, NULL, (u32)D_800AA660 + 0x21E0, 0xF);
D_800AA668 = func_8000B318(0);
osStartThread(&D_800AA660->thread);
}
Expand Down
Loading

0 comments on commit 8897a0f

Please sign in to comment.