Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion config/us/sym/symbol_addrs_libultra.txt
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,6 @@ __osSetCompare = 0x80245480;
__osSiDeviceBusy = 0x80245490;
__osGetCause = 0x802454C0;
__osAtomicDec = 0x802454D0;
__additional_scanline = 0x80248DD8;
alGlobals = 0x8024B780;
aisetnextbuf_data_0000 = 0x8024B790;
sprite_data_0004 = 0x8024B7A4;
Expand Down
2 changes: 1 addition & 1 deletion include/uv_dobj.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ typedef struct {
u16 unk0;
u16 unk2[1]; // unknown size, might take up everything till unk34
u8 pad4[0x34-0x4];
s8 unk34;
u8 unk34;
f32 unk38;
s32 unk3C;
} Unk80263780;
Expand Down
70 changes: 61 additions & 9 deletions include/uv_graphics.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,31 @@ typedef struct {
void* unk54;
} UnkStruct_uvGfxInit; // size: 0x58

typedef struct UnkTileStruct40 {
u8 pad0[0x10];
struct UnkSobjDraw* unk10;
} UnkTileStruct40;

typedef struct uvUnkTileStruct {
u8 pad0[0x40];
UnkTileStruct40* unk40;
u8 pad44[0x4];
} uvUnkTileStruct;

typedef struct uvGfxUnkStructTerra {
f32 unk0;
f32 unk4;
u8 pad8[0x4];
f32 unkC;
f32 unk10;
u8 pad14[0x4];
u8 unk18;
f32 unk1C;
f32 unk20;
u8 pad24[0x4];
uvUnkTileStruct* unk28;
} uvGfxUnkStructTerra;

typedef struct {
void* unk0;
Gfx *unk4;
Expand All @@ -61,13 +86,38 @@ typedef struct {
struct unk_UVTX_1C* unk1C;
u8 pad20[0x2];
u8 unk22;
} uvGfxUnkStruct2;
} uvGfxUnkStructTexture;

typedef struct uvGfxUnkStruct10 {
uvGfxState_t* unk0;
u8 unk4;
u8 pad5[0x1];
u8 unk6;
u8 pad7[0x6];
u8 unkD;
u8 padE[0x2];
} uvGfxUnkStruct10;

typedef struct uvGfxUnkStruct8 {
uvGfxUnkStruct10* unk0;
u8 unk4;
u8 unk5;
u8 pad6[0x2];
} uvGfxUnkStruct8;

typedef struct {
u8 pad0[0x1C];
u8 pad0[0x8];
uvGfxUnkStruct8* unk8;
f32* unkC;
u8 unk10;
u8 unk11;
u8 pad12[0x2];
void* unk14;
u8 unk18;
u8 pad19[0x3];
f32 unk1C;
f32 unk20;
} uvGfxUnkStructC8;
} uvGfxUnkStructModel;

typedef struct {
u8 pad0[0x2];
Expand All @@ -80,23 +130,25 @@ typedef struct {
s16 nbitmaps;
u8 pad10[0x4];
Bitmap* bitmap;
} uvGfxUnkStruct1410;
} uvGfxUnkStructBlit;

typedef struct {
u8 pad0[0x4];
void *unk4[1];
uvGfxUnkStructTerra *unk4[1];
u8 pad8[0x28];
void *unk30[1];
u8 pad34[0x10];
void *unk44[1];
u8 pad48[0x80];
uvGfxUnkStructC8 *unkC8[1];
uvGfxUnkStructModel *unkC8[1];
u8 padCC[0x844];
uvGfxUnkStruct2 *unk910[1];
uvGfxUnkStructTexture *unk910[1];
u8 pad914[0x7D0];
void *unk10E4[1];
u8 pad10E8[0x328];
uvGfxUnkStruct1410* unk1410[1];
uvGfxUnkStructBlit* unk1410[1];
u8 pad1414[0x1F4];
f32 unk1608;
} uvGfxUnkStruct;

extern Gfx* gGfxDisplayListHead;
Expand Down Expand Up @@ -187,7 +239,7 @@ typedef struct {
/* 1FC */ f32 unk1FC;
/* 200 */ f32 unk200;
/* 204 */ f32 unk204;
/* 208 */ u8 pad208[0x2E0 - 0x208];
/* 208 */ u8 pad208[0xD8];
/* 2E0 */ u8 unk2E0[0x90];
/* 370 */ s32 unk370;
/* 374 */ s32 unk374;
Expand Down
14 changes: 14 additions & 0 deletions include/uv_matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,20 @@ typedef union {
};
} Mtx4F;

typedef struct Mtx_u {
u16 i[4][4];
u16 f[4][4];
} Mtx_u;

typedef union {
Mtx_t m;
Mtx_u u;
long long int force_structure_alignment;
} uvMtx;

#define MTX_TO_PART(mtx) (*(Mtx_u*)&(mtx))
#define L2F(mtx, i1, i2) ((((s16)MTX_TO_PART(mtx).i[(i1)][(i2)] << 0x10) | ((s16)MTX_TO_PART(mtx).f[(i1)][(i2)] & 0xFFFF)) / 65536.0f)

void _uvDbMstackReset(void);
Mtx4F* _uvDbMstackTop(void);
void _uvDbMstackPush(Mtx4F* src);
Expand Down
2 changes: 1 addition & 1 deletion include/uv_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <uv_matrix.h>

s32 uvModelGet(s32, s32);
void uvModelGetProps(u16, s32, void*, s32);
void uvModelGetProps(s32, s32, void*, s32);
void uvModelGetPosm(s32 model, s32 part, Mtx4F*);

#endif // UV_MODEL_H
11 changes: 10 additions & 1 deletion include/uv_sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,20 @@

#include <ultra64.h>
#include <PR/sched.h>
#include <uv_matrix.h>
#include <uv_util.h>

#define UV_MESG_DMA 0
#define UV_MESG_SCHED 2
#define UV_MESG_GFX 4

typedef struct Unk8022B0A0 {
f32 unk0;
f32 unk4;
f32 unk8;
f32 unkC;
} Unk8022B0A0; // size: 0x10

void uvWaitForMesg(char msg_type);

void _uvScDoneGfx(void);
Expand All @@ -26,8 +34,9 @@ void _uvScHandleRDP(void);
void _uvScHandleNMI(void);
void _uvScLogCpuEvent(s32 ring);
void _uvScLogIntoRing(void);
void func_8022C34C(void);
void func_8022B0A0(Unk8022B0A0* arg0, Mtx4F* arg1);
void func_8022BEB8(s32 arg0);
void func_8022C34C(void);
void func_8022C3C0(u8 arg0, s32 arg1);

#endif // PILOTWINGS64_UV_SCHED
20 changes: 20 additions & 0 deletions include/uv_sobj.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#ifndef UV_SOBJ_H
#define UV_SOBJ_H

#include <PR/ultratypes.h>
#include <uv_matrix.h>

typedef struct UnkSobjDraw {
u16 unk0;
Mtx* unk4;
f32 unk8;
f32 unkC;
f32 unk10;
u16 unk14;
} UnkSobjDraw;

u8 func_8022C7B8(uvGfxUnkStructModel* arg0, f32 arg1);
void func_8022C8D0(UnkSobjDraw* arg0, uvGfxUnkStructModel* arg1, u8 arg2, Mtx4F* arg3);
void func_8022CC28(UnkSobjDraw* arg0, uvGfxUnkStructModel* arg1, u8 arg2, f32 arg3, f32 arg4);

#endif // UV_SOBJ_H
4 changes: 2 additions & 2 deletions include/uv_sprite.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ typedef struct {
void uvSprt_80230130(void);
void uvSprt_802301A4(void);
void _uvTxtDraw(s32 arg0);
void uvSprtFromBitmap(uvSprite_t* arg0, uvGfxUnkStruct2* arg1);
void uvSprt_80230750(uvSprite_t* arg0, uvGfxUnkStruct2* arg1);
void uvSprtFromBitmap(uvSprite_t* arg0, uvGfxUnkStructTexture* arg1);
void uvSprt_80230750(uvSprite_t* arg0, uvGfxUnkStructTexture* arg1);
s32 uvSprt_80230898(void);
void uvSprtInit(void);
void uvSprtDisplayList(uvSprite_t* arg0);
Expand Down
84 changes: 83 additions & 1 deletion src/kernel/code_58E0.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
#include <uv_graphics.h>
#include <uv_math.h>
#include <libc/stdarg.h>

typedef struct UnkSortAdd {
s8 unk0;
s8 unk1;
s8 unk2;
f32 unk4;
f32 unk8;
f32 unkC;
void* unk10;
u16 unk14;
s32 unk18;
} UnkSortAdd;

extern UnkSortAdd D_80261ED8[];
extern UnkSortAdd D_802629C8[];
extern s32 D_80263058;
extern s32 D_8026305C;

// from kernel/code_7150
void func_802061A0(void*);
Expand Down Expand Up @@ -147,7 +165,71 @@ void func_802057F4(Mtx4F* arg0, Mtx4F* arg1) {
uvMat4UnkOp4(arg0, arg1);
}

#pragma GLOBAL_ASM("asm/nonmatchings/kernel/code_58E0/_uvSortAdd.s")
void _uvSortAdd(s32 arg0, f32 arg1, void* arg2, UnkStruct_80204D94* arg3, f32 arg4, f32 arg5, ...) {
UnkSortAdd* var_a1;
uvGfxUnkStructTerra* var_v0;
s32 var_v1;
s32 var_a0;
va_list args;

if (arg0 > 0) {
if (D_80263058 >= 100) {
_uvDebugPrintf("_uvSortAdd: sort list full %d\n", 100);
return;
}
var_a1 = &D_80261ED8[D_80263058];
D_80263058++;
} else {
if (D_8026305C >= 60) {
_uvDebugPrintf("_uvSortAdd: dobj list full for %d\n", 60);
return;
}

var_a1 = &D_802629C8[D_8026305C];
D_8026305C++;
arg0 = -arg0;
}
var_a1->unk0 = arg0;
var_a1->unk4 = arg1;
var_a1->unk10 = arg2;
if (arg3->unk0 & 2) {
var_v0 = gGfxUnkPtrs->unk4[arg3->unk4];
} else {
var_v0 = NULL;
}
if (var_v0 != NULL) {
if ((arg4 < var_v0->unk0) || (var_v0->unkC <= arg4) || (arg5 < var_v0->unk4) || (var_v0->unk10 <= arg5)) {
var_a1->unk14 = 0xFFFF;
} else {
var_v1 = (s32)(arg4 - var_v0->unk0) / (s32)var_v0->unk1C;
var_a0 = (s32)(arg5 - var_v0->unk4) / (s32)var_v0->unk20;
var_a1->unk14 = var_v1 + var_v0->unk18 * var_a0;
}
} else {
var_a1->unk14 = 0xFFFF;
}

va_start(args, arg5);
switch (arg0) {
case 1:
break;
case 2:
var_a1->unk1 = va_arg(args, s32);
break;
case 3:
var_a1->unk1 = va_arg(args, s32);
var_a1->unk8 = va_arg(args, f64);
var_a1->unkC = va_arg(args, f64);
break;
case 4:
var_a1->unk8 = va_arg(args, f64);
var_a1->unkC = va_arg(args, f64);
var_a1->unk18 = va_arg(args, s32);
var_a1->unk2 = va_arg(args, s32);
var_a1->unk1 = va_arg(args, s32);
break;
}
}

#pragma GLOBAL_ASM("asm/nonmatchings/kernel/code_58E0/func_80205BFC.s")

Expand Down
2 changes: 1 addition & 1 deletion src/kernel/code_8170.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

uvGfxUnkStruct* gGfxUnkPtrs = NULL;
s32 D_80248DD4 = 0xFFFFFFFF;
s32 __additional_scanline[] = { 0x00000000, 0x00000000 };
s32 D_80248DD8 = 0x00000000;

#pragma GLOBAL_ASM("asm/nonmatchings/kernel/code_8170/osViExtendVStart.s")

Expand Down
Loading