1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-07-17 13:24:45 +00:00

Finished code_801031F0.c, guPosition.c, guLookAtHilite.c (#84)

* started microcode decomp

* Modified spec to fix error

* osContGetQuery OK

* Decompiled guLookAtHilite.c

* guPosition.c OK

* Fixed formatting

* osViSetEvent.c OK

* Deleted unnecessary files

* Made suggested changes, merged playblack.c

* Removed line breaks from comments

* Removed argument listing
This commit is contained in:
Lucas Shaw 2020-04-22 10:20:49 -07:00 committed by GitHub
parent 06b731c494
commit 3c440ef7f1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
31 changed files with 313 additions and 973 deletions

View file

@ -1,8 +1,15 @@
#include "libultra_internal.h"
#include <global.h>
#pragma GLOBAL_ASM("asm/non_matchings/code/code_801031F0/func_801031F0.s")
s32 osAfterPreNMI(void) {
return __osSpSetPc(0);
}
/**
* osContStartQuery:
* Starts to read the values for SI device status and type which are connected to the controller port and joyport
* connector.
**/
s32 osContStartQuery(OSMesgQueue* mq) {
s32 ret;
ret = 0;
@ -19,8 +26,11 @@ s32 osContStartQuery(OSMesgQueue* mq) {
return ret;
}
#pragma GLOBAL_ASM("asm/non_matchings/code/code_801031F0/func_8010328C.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/code_801031F0/func_801032B0.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/code_801031F0/func_80103A70.s")
/**
* osContGetQuery:
* Returns the values from osContStartQuery to status. Both functions must be paired for use.
**/
void osContGetQuery(OSContStatus* data) {
u8 pattern;
__osContGetInitData(&pattern, data);
}

View file

@ -0,0 +1,153 @@
#include "libultra_internal.h"
#include <global.h>
#define FTOFRAC8(x) ((s32)MIN(((x) * (128.0f)), 127.0f) & 0xff)
/**
* guLookAtHiliteF
* This function creates the viewing matrix (floating point) and sets the LookAt/Hilite structures
**/
void guLookAtHiliteF(f32 mf[4][4], LookAt* l, Hilite* h, f32 xEye, f32 yEye, f32 zEye, f32 xAt, f32 yAt, f32 zAt,
f32 xUp, f32 yUp, f32 zUp, f32 xl1, f32 yl1, f32 zl1, /* light 1 direction */
f32 xl2, f32 yl2, f32 zl2, /* light 2 direction */
s32 hiliteWidth, s32 hiliteHeight) /* size of hilite texture */
{
f32 length, xLook, yLook, zLook, xRight, yRight, zRight, xHilite, yHilite, zHilite;
guMtxIdentF(mf);
xLook = xAt - xEye;
yLook = yAt - yEye;
zLook = zAt - zEye;
length = -1.0 / sqrtf(xLook * xLook + yLook * yLook + zLook * zLook);
xLook *= length;
yLook *= length;
zLook *= length;
xRight = yUp * zLook - zUp * yLook;
yRight = zUp * xLook - xUp * zLook;
zRight = xUp * yLook - yUp * xLook;
length = 1.0 / sqrtf(xRight * xRight + yRight * yRight + zRight * zRight);
xRight *= length;
yRight *= length;
zRight *= length;
xUp = yLook * zRight - zLook * yRight;
yUp = zLook * xRight - xLook * zRight;
zUp = xLook * yRight - yLook * xRight;
length = 1.0 / sqrtf(xUp * xUp + yUp * yUp + zUp * zUp);
xUp *= length;
yUp *= length;
zUp *= length;
/* hilite vectors */
length = 1.0 / sqrtf(xl1 * xl1 + yl1 * yl1 + zl1 * zl1);
xl1 *= length;
yl1 *= length;
zl1 *= length;
xHilite = xl1 + xLook;
yHilite = yl1 + yLook;
zHilite = zl1 + zLook;
length = sqrtf(xHilite * xHilite + yHilite * yHilite + zHilite * zHilite);
if (length > 0.1) {
length = 1.0 / length;
xHilite *= length;
yHilite *= length;
zHilite *= length;
h->h.x1 = hiliteWidth * 4 + (xHilite * xRight + yHilite * yRight + zHilite * zRight) * hiliteWidth * 2;
h->h.y1 = hiliteHeight * 4 + (xHilite * xUp + yHilite * yUp + zHilite * zUp) * hiliteHeight * 2;
} else {
h->h.x1 = hiliteWidth * 2;
h->h.y1 = hiliteHeight * 2;
}
length = 1.0 / sqrtf(xl2 * xl2 + yl2 * yl2 + zl2 * zl2);
xl2 *= length;
yl2 *= length;
zl2 *= length;
xHilite = xl2 + xLook;
yHilite = yl2 + yLook;
zHilite = zl2 + zLook;
length = sqrtf(xHilite * xHilite + yHilite * yHilite + zHilite * zHilite);
if (length > 0.1) {
length = 1.0 / length;
xHilite *= length;
yHilite *= length;
zHilite *= length;
h->h.x2 = hiliteWidth * 4 + (xHilite * xRight + yHilite * yRight + zHilite * zRight) * hiliteWidth * 2;
h->h.y2 = hiliteHeight * 4 + (xHilite * xUp + yHilite * yUp + zHilite * zUp) * hiliteHeight * 2;
} else {
h->h.x2 = hiliteWidth * 2;
h->h.y2 = hiliteHeight * 2;
}
/* reflectance vectors = Up and Right */
l->l[0].l.dir[0] = FTOFRAC8(xRight);
l->l[0].l.dir[1] = FTOFRAC8(yRight);
l->l[0].l.dir[2] = FTOFRAC8(zRight);
l->l[1].l.dir[0] = FTOFRAC8(xUp);
l->l[1].l.dir[1] = FTOFRAC8(yUp);
l->l[1].l.dir[2] = FTOFRAC8(zUp);
l->l[0].l.col[0] = 0x00;
l->l[0].l.col[1] = 0x00;
l->l[0].l.col[2] = 0x00;
l->l[0].l.pad1 = 0x00;
l->l[0].l.colc[0] = 0x00;
l->l[0].l.colc[1] = 0x00;
l->l[0].l.colc[2] = 0x00;
l->l[0].l.pad2 = 0x00;
l->l[1].l.col[0] = 0x00;
l->l[1].l.col[1] = 0x80;
l->l[1].l.col[2] = 0x00;
l->l[1].l.pad1 = 0x00;
l->l[1].l.colc[0] = 0x00;
l->l[1].l.colc[1] = 0x80;
l->l[1].l.colc[2] = 0x00;
l->l[1].l.pad2 = 0x00;
mf[0][0] = xRight;
mf[1][0] = yRight;
mf[2][0] = zRight;
mf[3][0] = -(xEye * xRight + yEye * yRight + zEye * zRight);
mf[0][1] = xUp;
mf[1][1] = yUp;
mf[2][1] = zUp;
mf[3][1] = -(xEye * xUp + yEye * yUp + zEye * zUp);
mf[0][2] = xLook;
mf[1][2] = yLook;
mf[2][2] = zLook;
mf[3][2] = -(xEye * xLook + yEye * yLook + zEye * zLook);
mf[0][3] = 0;
mf[1][3] = 0;
mf[2][3] = 0;
mf[3][3] = 1;
}
/**
* guLookAtHilite
* This function creates the viewing matrix (fixed point) and sets the LookAt/Hilite structures
* Same args as previous function
**/
void guLookAtHilite(Mtx* m, LookAt* l, Hilite* h, f32 xEye, f32 yEye, f32 zEye, f32 xAt, f32 yAt, f32 zAt, f32 xUp,
f32 yUp, f32 zUp, f32 xl1, f32 yl1, f32 zl1, f32 xl2, f32 yl2, f32 zl2, s32 hiliteWidth,
s32 hiliteHeight) {
f32 mf[4][4];
guLookAtHiliteF(mf, l, h, xEye, yEye, zEye, xAt, yAt, zAt, xUp, yUp, zUp, xl1, yl1, zl1, xl2, yl2, zl2, hiliteWidth,
hiliteHeight);
guMtxF2L(mf, m);
}

View file

@ -0,0 +1,6 @@
#include <ultra64.h>
#include <global.h>
#pragma GLOBAL_ASM("asm/non_matchings/code/guLookAtRef/guLookAtReflectF.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/guLookAtRef/guLookAtReflect.s")

View file

@ -0,0 +1,55 @@
#include "libultra_internal.h"
/**
* guPositionF
* Creates a rotation/parallel translation modeling matrix (floating point)
**/
void guPositionF(f32 mf[4][4], f32 rot, f32 pitch, f32 yaw, f32 scale, f32 x, f32 y, f32 z) {
static f32 D_80134D00 = M_PI / 180.0;
f32 sinr, sinp, sinh;
f32 cosr, cosp, cosh;
rot *= D_80134D00;
pitch *= D_80134D00;
yaw *= D_80134D00;
sinr = sinf(rot);
cosr = cosf(rot);
sinp = sinf(pitch);
cosp = cosf(pitch);
sinh = sinf(yaw);
cosh = cosf(yaw);
mf[0][0] = (cosp * cosh) * scale;
mf[0][1] = (cosp * sinh) * scale;
mf[0][2] = (-sinp) * scale;
mf[0][3] = 0.0f;
mf[1][0] = ((sinr * sinp * cosh) - (cosr * sinh)) * scale;
mf[1][1] = ((sinr * sinp * sinh) + (cosr * cosh)) * scale;
mf[1][2] = (sinr * cosp) * scale;
mf[1][3] = 0.0f;
mf[2][0] = ((cosr * sinp * cosh) + (sinr * sinh)) * scale;
mf[2][1] = ((cosr * sinp * sinh) - (sinr * cosh)) * scale;
mf[2][2] = (cosr * cosp) * scale;
mf[2][3] = 0.0f;
mf[3][0] = x;
mf[3][1] = y;
mf[3][2] = z;
mf[3][3] = 1.0f;
}
/**
* guPosition
* Creates a rotational/paralell translation moeling matrix (fixed point)
*/
void guPosition(Mtx* m, f32 rot, f32 pitch, f32 yaw, f32 scale, f32 x, f32 y, f32 z) {
f32 mf[4][4];
guPositionF(mf, rot, pitch, yaw, scale, x, y, z);
guMtxF2L(mf, m);
}

View file

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

View file

@ -0,0 +1,12 @@
#include "libultra_internal.h"
extern OSViContext* __osViNext;
void osViSetEvent(OSMesgQueue* mq, OSMesg msg, u32 retraceCount) {
register u32 saveMask;
saveMask = __osDisableInt();
__osViNext->mq = mq;
__osViNext->msg = msg;
__osViNext->retraceCount = retraceCount;
__osRestoreInt(saveMask);
}