Skip to content

Commit

Permalink
Match Libultra (#120)
Browse files Browse the repository at this point in the history
* Matched perspective, contquery, contreaddata, recvmesg and sendmesg

* Fixed libultra compilation flags

* Matched viblack

* Matched virepeatline, visetmode, visetspecial and viswapbuf

* Matched cartrominit, dpsetstat, sptask, sptaskyield, visetevent, createthread, gettime, setthreadpri, settime, settimer and starthread

* Fixed bss bs

* Matched even more libultra stuff

* Matched even more

* __osRdbSend

* Decompiled most of the functions of libultra <3

* Matched last functions

* Added a separation to libultra macros

* Removed ARRLEN from controller.h

* Fix libultra warnings

---------

Co-authored-by: Alejandro Javier Asenjo Nitti <[email protected]>
  • Loading branch information
KiritoDv and sonicdcer authored Feb 14, 2024
1 parent ff2627c commit 902dc0b
Show file tree
Hide file tree
Showing 138 changed files with 10,087 additions and 1,430 deletions.
101 changes: 95 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,9 @@ WARNINGS := -fullwarn -verbose -woff 624,649,838,712,516,513,596,564,594,
ASFLAGS := -march=vr4300 -32 -G0
COMMON_DEFINES := -D_MIPS_SZLONG=32
GBI_DEFINES := -DF3DEX_GBI
RELEASE_DEFINES := -DNDEBUG -D_FINALROM
RELEASE_DEFINES := -DNDEBUG
AS_DEFINES := -DMIPSEB -D_LANGUAGE_ASSEMBLY -D_ULTRA64
C_DEFINES := -DLANGUAGE_C -D_LANGUAGE_C -DBUILD_VERSION=VERSION_H
C_DEFINES := -DLANGUAGE_C -D_LANGUAGE_C -DBUILD_VERSION=VERSION_H ${RELEASE_DEFINES}
ENDIAN := -EB

OPTFLAGS := -O2 -g3
Expand Down Expand Up @@ -254,41 +254,130 @@ build/src/main/sys_audio_1EB50.o: OPTFLAGS := -O1 -g0
build/src/main/sys_sprintf.o: OPTFLAGS := -O2 -g0
build/src/main/sys_math64.o: OPTFLAGS := -O2 -g0

build/src/libultra/debug/kdebugserver.o: OPTFLAGS := -O1 -g0

build/src/libultra/gu/sqrtf.o: OPTFLAGS := -O3 -g0
build/src/libultra/gu/ortho.o: OPTFLAGS := -O3 -g0
build/src/libultra/gu/lookat.o: OPTFLAGS := -O3 -g0

build/src/libultra/io/pidma.o: OPTFLAGS := -O1 -g0
build/src/libultra/gu/perspective.o: OPTFLAGS := -O3 -g0
build/src/libultra/gu/sinf.o: OPTFLAGS := -O3 -g0
build/src/libultra/gu/cosf.o: OPTFLAGS := -O3 -g0
build/src/libultra/gu/mtxutil.o: OPTFLAGS := -O3 -g0

build/src/libultra/host/readhost.o: OPTFLAGS := -O1 -g0

build/src/libultra/io/crc.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/contramwrite.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/cartrominit.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/contquery.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/contramread.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/devmgr.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/epidma.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/epirawdma.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/epirawwrite.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/epirawread.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/leodiskinit.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/leointerrupt.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/pigetcmdq.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/conteepread.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/conteepwrite.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/conteepprobe.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/contreaddata.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/dpsetstat.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/aisetnextbuf.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/pimgr.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/pidma.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/pirawdma.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/pfsisplug.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/spsetpc.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/motor.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/controller.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/ai.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/vi.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/aigetlen.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/aisetfreq.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/pfsgetstatus.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/si.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/siacs.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/sp.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/sirawdma.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/sirawread.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/sirawwrite.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/sprawwrite.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/sprawread.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/sprawdma.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/spgetstat.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/sptaskyielded.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/sptaskyield.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/sptask.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/spsetstat.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/pirawread.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/piacs.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/viblack.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/vimgr.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/vigetcurrcontext.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/virepeatline.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/visetmode.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/visetspecial.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/visetevent.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/viswapbuf.o: OPTFLAGS := -O1 -g0
build/src/libultra/io/viswapcontext.o: OPTFLAGS := -O1 -g0

build/src/libultra/libc/ldiv.o: OPTFLAGS := -O2 -g0
build/src/libultra/libc/string.o: OPTFLAGS := -O2 -g0
build/src/libultra/libc/xlitob.o: OPTFLAGS := -O2 -g0
build/src/libultra/libc/xldtob.o: OPTFLAGS := -O3 -g0
build/src/libultra/libc/xprintf.o: OPTFLAGS := -O3 -g0
build/src/libultra/libc/ll.o: OPTFLAGS := -O1 -g0
build/src/libultra/libc/ll.o: MIPS_VERSION := -mips3 -32

build/src/libultra/os/createmesgqueue.o: OPTFLAGS := -O1 -g0
build/src/libultra/os/createthread.o: OPTFLAGS := -O1 -g0
build/src/libultra/os/setglobalintmask.o: OPTFLAGS := -O1 -g0
build/src/libultra/os/gettime.o: OPTFLAGS := -O1 -g0
build/src/libultra/os/initialize.o: OPTFLAGS := -O1 -g0
build/src/libultra/os/jammesg.o: OPTFLAGS := -O1 -g0
build/src/libultra/os/destroythread.o: OPTFLAGS := -O1 -g0
build/src/libultra/os/getactivequeue.o: OPTFLAGS := -O1 -g0
build/src/libultra/os/recvmesg.o: OPTFLAGS := -O1 -g0
build/src/libultra/os/rdbsend.o: OPTFLAGS := -O1 -g0
build/src/libultra/os/resetglobalintmask.o: OPTFLAGS := -O1 -g0
build/src/libultra/os/sendmesg.o: OPTFLAGS := -O1 -g0
build/src/libultra/os/startthread.o: OPTFLAGS := -O1 -g0
build/src/libultra/os/stopthread.o: OPTFLAGS := -O1 -g0

build/src/libultra/os/setthreadpri.o: OPTFLAGS := -O1 -g0
build/src/libultra/os/settimer.o: OPTFLAGS := -O1 -g0
build/src/libultra/os/settime.o: OPTFLAGS := -O1 -g0
build/src/libultra/os/seteventmesg.o: OPTFLAGS := -O1 -g0
build/src/libultra/os/initrdb.o: OPTFLAGS := -O1 -g0
build/src/libultra/os/thread.o: OPTFLAGS := -O1 -g0
build/src/libultra/os/timerintr.o: OPTFLAGS := -O1 -g0
build/src/libultra/os/timerintr.o: OPTFLAGS := -O1 -g0
build/src/libultra/os/getthreadpri.o: OPTFLAGS := -O1 -g0
build/src/libultra/os/virtualtophysical.o: OPTFLAGS := -O1 -g0
build/src/libultra/os/yieldthread.o: OPTFLAGS := -O1 -g0

build/src/libultra/rmon/rmoncmds.o: OPTFLAGS := -O1 -g0
build/src/libultra/rmon/rmonmain.o: OPTFLAGS := -O1 -g0
build/src/libultra/rmon/rmonmem.o: OPTFLAGS := -O1 -g0
build/src/libultra/rmon/rmonbrk.o: OPTFLAGS := -O1 -g0
build/src/libultra/rmon/rmontask.o: OPTFLAGS := -O1 -g0
build/src/libultra/rmon/rmonregs.o: OPTFLAGS := -O1 -g0
build/src/libultra/rmon/rmonmisc.o: OPTFLAGS := -O1 -g0
build/src/libultra/rmon/rmonmisc.o: OPTFLAGS := -O1 -G0
build/src/libultra/rmon/rmonsio.o: OPTFLAGS := -O1 -g0

# cc & asm-processor
CC := $(ASM_PROC) $(ASM_PROC_FLAGS) $(IDO) -- $(AS) $(ASFLAGS) --
build/src/libultra/gu/sqrtf.o: CC := $(IDO)
build/src/libultra/gu/sinf.o: CC := $(IDO)
build/src/libultra/gu/lookat.o: CC := $(IDO)
build/src/libultra/gu/ortho.o: CC := $(IDO)
build/src/libultra/libc/ll.o: CC := $(IDO)
build/src/libultra/gu/perspective.o: CC := $(IDO)
build/src/libultra/gu/mtxutil.o: CC := $(IDO)
build/src/libultra/gu/cosf.o: CC := $(IDO)
build/src/libultra/libc/xprintf.o: CC := $(IDO)
build/src/libultra/libc/xldtob.o: CC := $(IDO)

#build/src/%.o: CC := $(ASM_PROC) $(ASM_PROC_FLAGS) $(IDO) -- $(AS) $(ASFLAGS) --

Expand Down
12 changes: 12 additions & 0 deletions include/PR/assert.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#ifndef __ASSERT_H__
#define __ASSERT_H__

#ifdef NDEBUG
#undef assert
#define assert(EX) ((void)0)
#else
extern void __assert(const char *, const char *, int);
#define assert(EX) ((EX)?((void)0):__assert("EX", __FILE__, __LINE__))
#endif /* NDEBUG */

#endif /* !__ASSERT_H__ */
4 changes: 2 additions & 2 deletions include/PR/controller.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#ifndef _CONTROLLER_H
#define _CONTROLLER_H

#include "macros.h"
#include "PR/ultratypes.h"
#include "PR/os_internal.h"
#include "PR/os_version.h"
#include "PR/rcp.h"

//should go somewhere else but
#define ARRLEN(x) ((s32)(sizeof(x) / sizeof(x[0])))
#define CHNL_ERR(format) (((format).rxsize & CHNL_ERR_MASK) >> 4)

typedef struct
Expand Down
42 changes: 42 additions & 0 deletions include/PR/guint.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/**************************************************************************
* *
* Copyright (C) 1994, Silicon Graphics, Inc. *
* *
* These coded instructions, statements, and computer programs contain *
* unpublished proprietary information of Silicon Graphics, Inc., and *
* are protected by Federal copyright law. They may not be disclosed *
* to third parties or copied or duplicated in any form, in whole or *
* in part, without the prior written consent of Silicon Graphics, Inc. *
* *
**************************************************************************/

#include "PR/mbi.h"
#include "PR/gu.h"

typedef union
{
struct
{
unsigned int hi;
unsigned int lo;
} word;

double d;
} du;

typedef union
{
unsigned int i;
float f;
} fu;

#ifndef __GL_GL_H__

typedef float Matrix[4][4];

#endif

#define ROUND(d) (int)(((d) >= 0.0) ? ((d) + 0.5) : ((d) - 0.5))
#define ABS(d) ((d) > 0) ? (d) : -(d)

extern float __libm_qnan_f;
Loading

0 comments on commit 902dc0b

Please sign in to comment.