[ntsc-1.2] Match N64 libultra (#2081)

* Match N64 libultra

* INITIALIZE_FUNC -> OSINITIALIZE_FUNC

* Document osGetIntMask

* Refer readers of osGetIntMask to osSetIntMask comment

* Whitelist new static functions in disasm unksyms check
This commit is contained in:
cadmic
2024-08-28 18:30:36 -07:00
committed by GitHub
parent 6e8b820184
commit 7079005c83
31 changed files with 344 additions and 42 deletions

View File

@@ -451,6 +451,9 @@ ifeq ($(PLATFORM),N64)
$(BUILD_DIR)/src/code/z_rumble.o: CFLAGS += -DNO_SQRTF_INTRINSIC
endif
$(BUILD_DIR)/src/code/jpegutils.o: CC := $(CC_OLD)
$(BUILD_DIR)/src/code/jpegdecoder.o: CC := $(CC_OLD)
ifeq ($(DEBUG),1)
$(BUILD_DIR)/src/libc/%.o: OPTFLAGS := -g
else
@@ -470,28 +473,57 @@ endif
$(BUILD_DIR)/src/audio/sfx.o: CFLAGS += -use_readwrite_const
$(BUILD_DIR)/src/audio/sequence.o: CFLAGS += -use_readwrite_const
$(BUILD_DIR)/src/libultra/%.o: CC := $(CC_OLD)
$(BUILD_DIR)/src/libultra/libc/ll.o: OPTFLAGS := -O1
$(BUILD_DIR)/src/libultra/libc/ll.o: MIPS_VERSION := -mips3 -32
$(BUILD_DIR)/src/libultra/libc/llcvt.o: OPTFLAGS := -O1
$(BUILD_DIR)/src/libultra/libc/llcvt.o: MIPS_VERSION := -mips3 -32
ifeq ($(PLATFORM),N64)
$(BUILD_DIR)/src/libultra/gu/%.o: OPTFLAGS := -O3
$(BUILD_DIR)/src/libultra/io/%.o: OPTFLAGS := -O1
$(BUILD_DIR)/src/libultra/libc/%.o: OPTFLAGS := -O3
$(BUILD_DIR)/src/libultra/os/%.o: OPTFLAGS := -O1
$(BUILD_DIR)/src/libultra/io/aisetfreq.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/libultra/io/cartrominit.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/libultra/io/contpfs.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/libultra/io/contramread.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/libultra/io/contramwrite.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/libultra/io/contreaddata.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/libultra/io/crc.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/libultra/io/devmgr.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/libultra/io/epiread.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/libultra/io/epiwrite.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/libultra/io/epirawdma.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/libultra/io/epirawread.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/libultra/io/epirawwrite.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/libultra/io/motor.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/libultra/io/pfsgetstatus.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/libultra/io/pfsselectbank.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/libultra/io/pimgr.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/libultra/io/pirawdma.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/libultra/io/sirawdma.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/libultra/io/sirawread.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/libultra/io/sirawwrite.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/libultra/io/sprawdma.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/libultra/io/vimgr.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/libultra/io/visetspecial.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/libultra/io/viswapcontext.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/libultra/gu/lookat.o: CFLAGS += -DNO_SQRTF_INTRINSIC
$(BUILD_DIR)/src/libultra/gu/lookathil.o: CFLAGS += -DNO_SQRTF_INTRINSIC
$(BUILD_DIR)/src/libultra/gu/normalize.o: CFLAGS += -DNO_SQRTF_INTRINSIC
else
$(BUILD_DIR)/src/libultra/gu/%.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/libultra/io/%.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/libultra/libc/%.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/libultra/rmon/%.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/libultra/gu/%.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/libultra/os/%.o: OPTFLAGS := -O1
endif
$(BUILD_DIR)/assets/misc/z_select_static/%.o: GBI_DEFINES := -DF3DEX_GBI
$(BUILD_DIR)/src/libultra/gu/%.o: CC := $(CC_OLD)
$(BUILD_DIR)/src/libultra/io/%.o: CC := $(CC_OLD)
$(BUILD_DIR)/src/libultra/libc/%.o: CC := $(CC_OLD)
$(BUILD_DIR)/src/libultra/os/%.o: CC := $(CC_OLD)
$(BUILD_DIR)/src/libultra/rmon/%.o: CC := $(CC_OLD)
$(BUILD_DIR)/src/code/jpegutils.o: CC := $(CC_OLD)
$(BUILD_DIR)/src/code/jpegdecoder.o: CC := $(CC_OLD)
# For using asm_processor on some files:
#$(BUILD_DIR)/.../%.o: CC := $(PYTHON) tools/asm_processor/build.py $(CC) -- $(AS) $(ASFLAGS) --

View File

@@ -1677,7 +1677,7 @@ s32 __osCheckPackId(OSPfs* pfs, __OSPackId* check);
s32 __osGetId(OSPfs* pfs);
s32 __osCheckId(OSPfs* pfs);
s32 __osPfsRWInode(OSPfs* pfs, __OSInode* inode, u8 flag, u8 bank);
void guMtxL2F(MtxF* m1, Mtx* m2);
void guMtxL2F(f32 mf[4][4], Mtx* m);
s32 osPfsFindFile(OSPfs* pfs, u16 companyCode, u32 gameCode, u8* gameName, u8* extName, s32* fileNo);
s32 osAfterPreNMI(void);
s32 osContStartQuery(OSMesgQueue* mq);
@@ -1728,7 +1728,7 @@ u32 __osSpGetStatus(void);
void __osSpSetStatus(u32 status);
void osWritebackDCacheAll(void);
OSThread* __osGetCurrFaultedThread(void);
void guMtxF2L(MtxF* m1, Mtx* m2);
void guMtxF2L(f32 mf[4][4], Mtx* m);
// ? __d_to_ll(?);
// ? __f_to_ll(?);
// ? __d_to_ull(?);

View File

@@ -5,6 +5,9 @@
#define GU_PI 3.1415926
#define FTOFIX32(x) (s32)((x) * (f32)0x00010000)
#define FIX32TOF(x) ((f32)(x) * (1.0f / (f32)0x00010000))
#define ROUND(x) (s32)(((x) >= 0.0) ? ((x) + 0.5) : ((x) - 0.5))
typedef union du {

29
spec
View File

@@ -589,7 +589,14 @@ beginseg
#if OOT_DEBUG
include "$(BUILD_DIR)/src/libultra/io/pfsfreeblocks.o"
#endif
#if PLATFORM_N64
include "$(BUILD_DIR)/src/libultra/os/getintmask.o"
#endif
#if PLATFORM_N64
include "$(BUILD_DIR)/src/libultra/gu/scale.o"
#else
include "$(BUILD_DIR)/src/libultra/mgu/scale.o"
#endif
include "$(BUILD_DIR)/src/libultra/gu/sinf.o"
include "$(BUILD_DIR)/src/libultra/gu/sins.o"
include "$(BUILD_DIR)/src/libultra/io/sptask.o"
@@ -605,7 +612,12 @@ beginseg
include "$(BUILD_DIR)/src/libultra/io/pfsreadwritefile.o"
include "$(BUILD_DIR)/src/libultra/io/pfsgetstatus.o"
#endif
#if PLATFORM_N64
include "$(BUILD_DIR)/src/libultra/gu/mtxutil.o"
#endif
#if !PLATFORM_N64
include "$(BUILD_DIR)/src/libultra/mgu/mtxidentf.o"
#endif
include "$(BUILD_DIR)/src/libultra/gu/lookat.o"
#if OOT_DEBUG
include "$(BUILD_DIR)/src/libultra/io/pfsallocatefile.o"
@@ -613,7 +625,9 @@ beginseg
include "$(BUILD_DIR)/src/libultra/os/stoptimer.o"
#if OOT_DEBUG
include "$(BUILD_DIR)/src/libultra/io/contpfs.o"
#if !PLATFORM_N64
include "$(BUILD_DIR)/src/libultra/mgu/mtxl2f.o"
#endif
include "$(BUILD_DIR)/src/libultra/io/pfsfindfile.o"
#endif
include "$(BUILD_DIR)/src/libultra/gu/sqrtf.o"
@@ -627,13 +641,19 @@ beginseg
include "$(BUILD_DIR)/src/libultra/libc/string.o"
#endif
include "$(BUILD_DIR)/src/libultra/io/sp.o"
#if !PLATFORM_N64
include "$(BUILD_DIR)/src/libultra/mgu/mtxident.o"
#endif
include "$(BUILD_DIR)/src/libultra/gu/position.o"
include "$(BUILD_DIR)/src/libultra/io/sptaskyielded.o"
include "$(BUILD_DIR)/src/libultra/gu/rotate.o"
include "$(BUILD_DIR)/src/libultra/io/aisetfreq.o"
include "$(BUILD_DIR)/src/libultra/os/getactivequeue.o"
#if PLATFORM_N64
include "$(BUILD_DIR)/src/libultra/gu/normalize.o"
#else
include "$(BUILD_DIR)/src/libultra/mgu/normalize.o"
#endif
include "$(BUILD_DIR)/src/libultra/io/dpgetstat.o"
include "$(BUILD_DIR)/src/libultra/io/dpsetstat.o"
#if OOT_DEBUG
@@ -643,6 +663,9 @@ beginseg
include "$(BUILD_DIR)/src/libultra/gu/cosf.o"
include "$(BUILD_DIR)/src/libultra/gu/libm_vals.o"
include "$(BUILD_DIR)/src/libultra/gu/coss.o"
#if PLATFORM_N64
include "$(BUILD_DIR)/src/libultra/os/settime.o"
#endif
include "$(BUILD_DIR)/src/libultra/io/visetevent.o"
#if OOT_DEBUG
include "$(BUILD_DIR)/src/libultra/io/pfsisplug.o"
@@ -656,7 +679,11 @@ beginseg
include "$(BUILD_DIR)/src/libultra/io/pfschecker.o"
#endif
include "$(BUILD_DIR)/src/libultra/io/aigetlen.o"
#if PLATFORM_N64
include "$(BUILD_DIR)/src/libultra/gu/translate.o"
#else
include "$(BUILD_DIR)/src/libultra/mgu/translate.o"
#endif
include "$(BUILD_DIR)/src/libultra/io/contramwrite.o"
#if !OOT_DEBUG
include "$(BUILD_DIR)/src/libultra/io/vimodefpallan1.o"
@@ -678,7 +705,9 @@ beginseg
include "$(BUILD_DIR)/src/libultra/io/spsetstat.o"
include "$(BUILD_DIR)/src/libultra/os/writebackdcacheall.o"
include "$(BUILD_DIR)/src/libultra/os/getcurrfaultedthread.o"
#if !PLATFORM_N64
include "$(BUILD_DIR)/src/libultra/mgu/mtxf2l.o"
#endif
include "$(BUILD_DIR)/src/libultra/libc/llcvt.o"
include "$(BUILD_DIR)/src/libultra/io/vigetcurrframebuf.o"
include "$(BUILD_DIR)/src/libultra/io/spsetpc.o"

View File

@@ -20,5 +20,5 @@ void MtxConv_F2L(Mtx* m1, MtxF* m2) {
void MtxConv_L2F(MtxF* m1, Mtx* m2) {
LOG_UTILS_CHECK_NULL_POINTER("m1", m1, "../mtxuty-cvt.c", 55);
LOG_UTILS_CHECK_NULL_POINTER("m2", m2, "../mtxuty-cvt.c", 56);
guMtxL2F(m1, m2);
guMtxL2F(m1->mf, m2);
}

View File

@@ -1020,7 +1020,7 @@ void Matrix_SetTranslateUniformScaleMtx(Mtx* mtx, f32 scale, f32 translateX, f32
MtxF mf;
Matrix_SetTranslateUniformScaleMtxF(&mf, scale, translateX, translateY, translateZ);
guMtxF2L(&mf, mtx);
guMtxF2L(mf.mf, mtx);
}
void Matrix_SetTranslateUniformScaleMtx2(Mtx* mtx, f32 scale, f32 translateX, f32 translateY, f32 translateZ) {

View File

@@ -61,5 +61,5 @@ void guLookAt(Mtx* m, f32 xEye, f32 yEye, f32 zEye, f32 xAt, f32 yAt, f32 zAt, f
guLookAtF(mf, xEye, yEye, zEye, xAt, yAt, zAt, xUp, yUp, zUp);
guMtxF2L((MtxF*)mf, m);
guMtxF2L(mf, m);
}

View File

@@ -157,5 +157,5 @@ void guLookAtHilite(Mtx* m, LookAt* l, Hilite* h, f32 xEye, f32 yEye, f32 zEye,
guLookAtHiliteF(mf, l, h, xEye, yEye, zEye, xAt, yAt, zAt, xUp, yUp, zUp, xl1, yl1, zl1, xl2, yl2, zl2, hiliteWidth,
hiliteHeight);
guMtxF2L((MtxF*)mf, m);
guMtxF2L(mf, m);
}

View File

@@ -1 +1,63 @@
#include "global.h"
void guMtxF2L(f32 mf[4][4], Mtx* m) {
s32 i, j;
s32 e1, e2;
s32 *ai, *af;
ai = (s32*)&m->m[0][0];
af = (s32*)&m->m[2][0];
for (i = 0; i < 4; i++) {
for (j = 0; j < 2; j++) {
e1 = FTOFIX32(mf[i][j * 2]);
e2 = FTOFIX32(mf[i][j * 2 + 1]);
*(ai++) = (e1 & 0xFFFF0000) | ((e2 >> 16) & 0xFFFF);
*(af++) = ((e1 << 16) & 0xFFFF0000) | (e2 & 0xFFFF);
}
}
}
void guMtxL2F(f32 mf[4][4], Mtx* m) {
s32 i, j;
u32 e1, e2;
u32 *ai, *af;
s32 q1, q2;
ai = (u32*)&m->m[0][0];
af = (u32*)&m->m[2][0];
for (i = 0; i < 4; i++) {
for (j = 0; j < 2; j++) {
e1 = (*ai & 0xFFFF0000) | ((*af >> 16) & 0xFFFF);
e2 = ((*(ai++) << 16) & 0xFFFF0000) | (*(af++) & 0xFFFF);
q1 = *((s32*)&e1);
q2 = *((s32*)&e2);
mf[i][j * 2] = FIX32TOF(q1);
mf[i][j * 2 + 1] = FIX32TOF(q2);
}
}
}
void guMtxIdentF(f32 mf[4][4]) {
s32 i, j;
for (i = 0; i < 4; i++) {
for (j = 0; j < 4; j++) {
if (i == j) {
mf[i][j] = 1.0;
} else {
mf[i][j] = 0.0;
}
}
}
}
void guMtxIdent(Mtx* m) {
f32 mf[4][4];
guMtxIdentF(mf);
guMtxF2L(mf, m);
}

View File

@@ -0,0 +1,9 @@
#include "global.h"
void guNormalize(f32* x, f32* y, f32* z) {
f32 m = 1 / sqrtf(SQ(*x) + SQ(*y) + SQ(*z));
*x *= m;
*y *= m;
*z *= m;
}

View File

@@ -25,5 +25,5 @@ void guOrtho(Mtx* mtx, f32 left, f32 right, f32 bottom, f32 top, f32 near, f32 f
guOrthoF(mf, left, right, bottom, top, near, far, scale);
guMtxF2L((MtxF*)mf, mtx);
guMtxF2L(mf, mtx);
}

View File

@@ -38,5 +38,6 @@ void guPerspective(Mtx* m, u16* perspNorm, f32 fovy, f32 aspect, f32 near, f32 f
f32 mf[4][4];
guPerspectiveF(mf, perspNorm, fovy, aspect, near, far, scale);
guMtxF2L((MtxF*)mf, m);
guMtxF2L(mf, m);
}

View File

@@ -50,5 +50,5 @@ void guPosition(Mtx* m, f32 rot, f32 pitch, f32 yaw, f32 scale, f32 x, f32 y, f3
guPositionF(mf, rot, pitch, yaw, scale, x, y, z);
guMtxF2L((MtxF*)mf, m);
guMtxF2L(mf, m);
}

View File

@@ -8,9 +8,11 @@ void guRotateF(f32 m[4][4], f32 a, f32 x, f32 y, f32 z) {
f32 bc;
f32 ca;
f32 t;
#if !PLATFORM_N64
f32 xs;
f32 ys;
f32 zs;
#endif
guNormalize(&x, &y, &z);
@@ -25,9 +27,15 @@ void guRotateF(f32 m[4][4], f32 a, f32 x, f32 y, f32 z) {
guMtxIdentF(m);
#if PLATFORM_N64
#define xs (x * sine)
#define ys (y * sine)
#define zs (z * sine)
#else
xs = x * sine;
ys = y * sine;
zs = z * sine;
#endif
t = x * x;
m[0][0] = (1 - t) * cosine + t;
@@ -47,5 +55,6 @@ void guRotate(Mtx* m, f32 a, f32 x, f32 y, f32 z) {
f32 mf[4][4];
guRotateF(mf, a, x, y, z);
guMtxF2L((MtxF*)mf, m);
guMtxF2L(mf, m);
}

18
src/libultra/gu/scale.c Normal file
View File

@@ -0,0 +1,18 @@
#include "global.h"
void guScaleF(f32 m[4][4], f32 x, f32 y, f32 z) {
guMtxIdentF(m);
m[0][0] = x;
m[1][1] = y;
m[2][2] = z;
m[3][3] = 1;
}
void guScale(Mtx* m, f32 x, f32 y, f32 z) {
f32 mf[4][4];
guScaleF(mf, x, y, z);
guMtxF2L(mf, m);
}

View File

@@ -0,0 +1,17 @@
#include "global.h"
void guTranslateF(f32 m[4][4], f32 x, f32 y, f32 z) {
guMtxIdentF(m);
m[3][0] = x;
m[3][1] = y;
m[3][2] = z;
}
void guTranslate(Mtx* m, f32 x, f32 y, f32 z) {
f32 mf[4][4];
guTranslateF(mf, x, y, z);
guMtxF2L(mf, m);
}

View File

@@ -7,6 +7,8 @@
* direct SI devices.
*/
s32 osContSetCh(u8 ch) {
s32 ret = 0;
__osSiGetAccess();
if (ch > MAXCONTROLLERS) {
@@ -17,5 +19,5 @@ s32 osContSetCh(u8 ch) {
__osContLastCmd = CONT_CMD_END;
__osSiRelAccess();
return 0;
return ret;
}

View File

@@ -2,7 +2,7 @@
#include "ultra64/internal.h"
s32 osEPiStartDma(OSPiHandle* handle, OSIoMesg* mb, s32 direction) {
s32 ret;
register s32 ret;
if (!__osPiDevMgr.active) {
return -1;

View File

@@ -1,8 +1,8 @@
#include "global.h"
u32 osSpTaskYielded(OSTask* task) {
u32 ret;
u32 status = __osSpGetStatus();
u32 ret;
if (status & SP_STATUS_YIELDED) {
ret = OS_TASK_YIELDED;

View File

@@ -4,8 +4,8 @@
#define BUFF_LEN 0x20
short _Ldunscale(short*, _Pft*);
void _Genld(_Pft*, char, char*, short, short);
static short _Ldunscale(short*, _Pft*);
static void _Genld(_Pft*, char, char*, short, short);
static const double pows[] = { 10e0L, 10e1L, 10e3L, 10e7L, 10e15L, 10e31L, 10e63L, 10e127L, 10e255L };
@@ -156,7 +156,7 @@ void _Ldtob(_Pft* args, char code) {
_Genld((_Pft*)args, code, ptr, nsig, exp);
}
short _Ldunscale(short* pex, _Pft* px) {
static short _Ldunscale(short* pex, _Pft* px) {
unsigned short* ps = (unsigned short*)px;
short xchar = (ps[_D0] & _DMASK) >> _DOFF;
@@ -176,7 +176,7 @@ short _Ldunscale(short* pex, _Pft* px) {
}
}
void _Genld(_Pft* px, char code, char* p, short nsig, short xexp) {
static void _Genld(_Pft* px, char code, char* p, short nsig, short xexp) {
const char point = '.';
if (nsig <= 0) {

Some files were not shown because too many files have changed in this diff Show More