1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-07-18 13:54:46 +00:00

Decompile a bunch of small files (#160)

* Decompile a bunch of small files

* Rename dacrate to dacRate

* Run format.sh

* Minor fixes in PR #160
This commit is contained in:
Random 2020-05-25 23:18:14 +02:00 committed by GitHub
parent 13b1dc03bb
commit 3d050f2861
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
54 changed files with 412 additions and 1029 deletions

5
src/libultra_code/absf.c Normal file
View file

@ -0,0 +1,5 @@
#include <global.h>
f32 absf(f32 a) {
return fabsf(a);
}

View file

@ -0,0 +1,28 @@
#include <global.h>
void guS2DInitBg(uObjBg* bg) {
u16 shift;
u32 size;
s32 tmem;
tmem = (bg->b.imageFmt == G_IM_FMT_CI) ? 0x100 : 0x200;
shift = (6 - bg->b.imageSiz);
if (bg->b.imageLoad == G_BGLT_LOADBLOCK) {
bg->b.tmemW = bg->b.imageW >> shift;
bg->b.tmemH = (tmem / bg->b.tmemW) * 4;
bg->b.tmemSizeW = bg->b.tmemW * 2;
bg->b.tmemSize = bg->b.tmemH * bg->b.tmemSizeW;
bg->b.tmemLoadSH = (bg->b.tmemSize >> 1) - 1;
bg->b.tmemLoadTH = (0x7FF / bg->b.tmemW) + 1;
} else { // G_BGLT_LOADTILE
bg->b.tmemW = (bg->b.frameW >> shift) + 3;
bg->b.tmemH = (tmem / bg->b.tmemW) * 4;
bg->b.tmemSizeW = (bg->b.imageW >> shift) * 2;
size = bg->b.tmemH * bg->b.tmemSizeW;
bg->b.tmemSize = (size >> 16);
bg->b.tmemLoadSH = (size >> 0) & 0xFFFF;
bg->b.tmemLoadTH = bg->b.tmemH - 1;
}
}

View file

@ -4,8 +4,6 @@
// TODO: rename these
// SM64 OOT
#define guMtxF2L func_801064E0 // believed to be correct name, needs confirmation.
s32 __osDisableInt();
void __osRestoreInt(s32);
void __osEnqueueAndYield(OSThread**);

View file

@ -0,0 +1,24 @@
#include <global.h>
#include <ultra64/hardware.h>
s32 osAiSetFrequency(u32 frequency) {
u32 dacRate;
u8 bitrate;
f32 dacRateF;
dacRateF = ((f32)osViClock / frequency) + 0.5f;
dacRate = dacRateF;
if (dacRate < 132) {
return -1;
}
bitrate = (dacRate / 66);
if (bitrate > 16) {
bitrate = 16;
}
HW_REG(AI_DACRATE_REG, u32) = dacRate - 1;
HW_REG(AI_BITRATE_REG, u32) = bitrate - 1;
return osViClock / (s32)dacRate;
}

View file

@ -0,0 +1,42 @@
#include <global.h>
s32 osSetTimer(OSTimer* timer, OSTime countdown, OSTime interval, OSMesgQueue* mq, OSMesg msg) {
OSTime time;
OSTimer* next;
u32 count;
u32 value;
s32 prevInt;
timer->next = NULL;
timer->prev = NULL;
timer->interval = interval;
if (countdown != 0) {
timer->value = countdown;
} else {
timer->value = interval;
}
timer->mq = mq;
timer->msg = msg;
prevInt = __osDisableInt();
if (__osTimerList->next != __osTimerList) {
if (1) {}
next = __osTimerList->next;
count = osGetCount();
value = count - __osTimerCounter;
if (value < next->value) {
next->value -= value;
} else {
next->value = 1;
}
}
time = __osInsertTimer(timer);
__osSetTimerIntr(__osTimerList->next->value);
__osRestoreInt(prevInt);
return 0;
}

View file

@ -0,0 +1,5 @@
#include <global.h>
void osSpTaskYield() {
__osSpSetStatus(SP_STATUS_SIG3);
}

View file

@ -0,0 +1,21 @@
#include <global.h>
u32 osSpTaskYielded(OSTask* task) {
u32 ret;
u32 status;
status = __osSpGetStatus();
if (status & SP_STATUS_YIELDED) {
ret = OS_TASK_YIELDED;
} else {
ret = 0;
}
if (status & SP_STATUS_YIELD) {
task->t.flags |= ret;
task->t.flags &= ~OS_TASK_DP_WAIT;
}
return ret;
}

View file

@ -0,0 +1,28 @@
#include <global.h>
s32 osStopTimer(OSTimer* timer) {
register s32 prevInt;
OSTimer* next;
if (!timer->next) {
return -1;
}
prevInt = __osDisableInt();
next = timer->next;
if (next != __osTimerList) {
next->value += timer->value;
}
timer->prev->next = timer->next;
timer->next->prev = timer->prev;
timer->next = NULL;
timer->prev = NULL;
if (__osTimerList->next == __osTimerList) {
__osSetCompare(0);
}
__osRestoreInt(prevInt);
return 0;
}

View file

@ -0,0 +1,50 @@
#include <global.h>
void guRotateF(f32 m[4][4], f32 a, f32 x, f32 y, f32 z) {
static f32 D_80134D10 = M_PI / 180.0f;
f32 sine;
f32 cosine;
f32 ab;
f32 bc;
f32 ca;
f32 t;
f32 xs;
f32 ys;
f32 zs;
guNormalize(&x, &y, &z);
a = a * D_80134D10;
sine = sinf(a);
cosine = cosf(a);
ab = x * y * (1 - cosine);
bc = y * z * (1 - cosine);
ca = z * x * (1 - cosine);
guMtxIdentF(m);
xs = x * sine;
ys = y * sine;
zs = z * sine;
t = x * x;
m[0][0] = (1 - t) * cosine + t;
m[2][1] = bc - xs;
m[1][2] = bc + xs;
t = y * y;
m[1][1] = (1 - t) * cosine + t;
m[2][0] = ca + ys;
m[0][2] = ca - ys;
t = z * z;
m[2][2] = (1 - t) * cosine + t;
m[1][0] = ab - zs;
m[0][1] = ab + zs;
}
void guRotate(Mtx* m, f32 a, f32 x, f32 y, f32 z) {
f32 mf[4][4];
guRotateF(mf, a, x, y, z);
guMtxF2L(mf, m);
}

10
src/libultra_code/sqrt.c Normal file
View file

@ -0,0 +1,10 @@
#include <global.h>
#ifndef __GNUC__
#pragma intrinsic(sqrt)
#define __builtin_sqrt sqrt
#endif
f64 sqrt(f64 f) {
return __builtin_sqrt(f);
}

View file

@ -1,12 +1,10 @@
#include <math.h>
float sqrtf(float f);
#include <global.h>
#ifndef __GNUC__
#pragma intrinsic(sqrtf)
#define __builtin_sqrtf sqrtf
#endif
float sqrtf(float f) {
f32 sqrtf(f32 f) {
return __builtin_sqrtf(f);
}