Decompile sinf.c

This commit is contained in:
rozlette 2018-11-17 02:16:20 -06:00
parent bd397414c3
commit 55bece5060
14 changed files with 760 additions and 31 deletions

View File

@ -7,8 +7,8 @@ LD := $(MIPS_BINUTILS)ld
#QEMU_IRIX := ~/irixemu/mips-linux-user/qemu-mips
QEMU_IRIX := ~/qemu-irix
IRIX_ROOT := ./ido/62/
CC := $(QEMU_IRIX) -L $(IRIX_ROOT) $(IRIX_ROOT)/usr/bin/cc
IRIX_62_ROOT := ./ido/62/
IRIX_53_ROOT := ./ido/
CFLAGS := -G 0 -non_shared -Xfullwarn -Xcpluscomm
ASFLAGS := -march=vr4300 -32
@ -19,10 +19,16 @@ OPTIMIZATION := -O2 -g3
build/src/libultra/os/%: OPTIMIZATION := -O1
build/src/libultra/io/%: OPTIMIZATION := -O2
build/src/libultra/libc/%: OPTIMIZATION := -O2
build/src/libultra/gu/%: OPTIMIZATION := -O2
build/src/libultra/%: CC := $(QEMU_IRIX) -L $(IRIX_53_ROOT) $(IRIX_53_ROOT)/usr/bin/cc
build/src/libultra/%: CFLAGS := $(CFLAGS) -Wab,-r4300_mul
build/src/boot_O1/%: OPTIMIZATION := -O1
build/src/boot_O2_g3/%: OPTIMIZATION := -O2 -g3
test.txt: OPTIMIZATION := -O2 -g3
test.txt: MIPS_VERSION := -mips2
test.txt: OPTIMIZATION := -O2
test.txt: CC := $(QEMU_IRIX) -L $(IRIX_53_ROOT) $(IRIX_53_ROOT)/usr/bin/cc
test.txt: CFLAGS := $(CFLAGS) -Wab,-r4300_mul
CC := $(QEMU_IRIX) -L $(IRIX_62_ROOT) $(IRIX_62_ROOT)/usr/bin/cc
test.txt: CC := python3 preprocess.py $(CC) -- $(AS) $(ASFLAGS) --
build/src/boot_O2_g3/%: CC := python3 preprocess.py $(CC) -- $(AS) $(ASFLAGS) --
@ -35,6 +41,7 @@ C_FILES := $(wildcard src/libultra/*) \
$(wildcard src/libultra/os/*) \
$(wildcard src/libultra/io/*) \
$(wildcard src/libultra/libc/*) \
$(wildcard src/libultra/gu/*) \
$(wildcard src/code/*) \
$(wildcard src/boot_O2_g3/*) \
$(wildcard src/boot_O1/*)
@ -53,6 +60,7 @@ $(shell mkdir -p build/src/libultra)
$(shell mkdir -p build/src/libultra/os)
$(shell mkdir -p build/src/libultra/io)
$(shell mkdir -p build/src/libultra/libc)
$(shell mkdir -p build/src/libultra/gu)
$(shell mkdir -p build/src/code)
$(shell mkdir -p build/src/boot_O2_g3)
$(shell mkdir -p build/src/boot_O1)

View File

@ -32,7 +32,7 @@ SECTIONS
build/asm/getintmask.o(.text)
build/asm/boot_0x80088110.o(.text)
build/asm/boot_0x800882A0.o(.text)
build/asm/sinf.o(.text)
build/src/libultra/gu/sinf.o(.text)
build/asm/sins.o(.text)
build/src/libultra/io/sptask.o(.text)
build/asm/ll.o(.text)

View File

@ -593,7 +593,7 @@ class Disassembler:
with open(path + "functions.h", 'w', newline='\n') as f:
f.write("#ifndef _FUNCTIONS_H_\n#define _FUNCTIONS_H_\n\n");
f.write('#include <PR/ultratypes.h>\n#include <osint.h>\n#include <viint.h>\n#include <unk.h>\n#include <structs.h>\n\n');
f.write('#include <PR/ultratypes.h>\n#include <osint.h>\n#include <viint.h>\n#include <guint.h>\n#include <unk.h>\n#include <structs.h>\n\n');
for addr in sorted(self.functions):
if addr in known_funcs:
@ -606,7 +606,7 @@ class Disassembler:
with open(path + "variables.h", 'w', newline='\n') as f:
f.write("#ifndef _VARIABLES_H_\n#define _VARIABLES_H_\n\n");
f.write('#include <PR/ultratypes.h>\n#include <osint.h>\n#include <viint.h>\n#include <unk.h>\n#include <structs.h>\n\n');
f.write('#include <PR/ultratypes.h>\n#include <osint.h>\n#include <viint.h>\n#include <guint.h>\n#include <unk.h>\n#include <structs.h>\n\n');
for addr in sorted(self.vars):
if addr in known_vars:

View File

@ -42,7 +42,7 @@ known_funcs = {
0x8008481C:("func_8008481C","UNK_RET","UNK_TYPE, UNK_TYPE, UNK_PTR, UNK_PTR"),
0x80084940:("func_80084940","void","void"),
0x80084968:("func_80084968","void","void"),
0x80085320:("func_80085320","void"," s80085320*, UNK_PTR, UNK_PTR, UNK_TYPE, UNK_TYPE, UNK_PTR"),
0x80085320:("func_80085320","void","s80085320*, UNK_PTR, UNK_PTR, UNK_TYPE, UNK_TYPE, UNK_PTR"),
0x800853F8:("func_800853F8","UNK_RET","s80085320*"),
0x80085468:("func_80085468","UNK_TYPE","s80085320*"),
0x800854E0:("func_800854E0","UNK_TYPE","UNK_ARGS"),
@ -206,8 +206,8 @@ known_funcs = {
0x80097eb0:("osViModeNtscHpn1","UNK_RET","UNK_ARGS"),
0x80097fc0:("osViModeNtscLan1","UNK_RET","UNK_ARGS"),
0x80098010:("osViModeMpalLan1","UNK_RET","UNK_ARGS"),
0x800991a0:("__osRcpImTable","UNK_RET","UNK_ARGS"),
0x80099450:("__libm_qnan_f","UNK_RET","UNK_ARGS"),
#0x800991a0:("__osRcpImTable","UNK_RET","UNK_ARGS"), TODO this is definitely actually a variable
#0x80099450:("__libm_qnan_f","UNK_RET","UNK_ARGS"), TODO this is definitely actually a variable
0x800A5AC0:("func_800A5AC0","UNK_RET","void*, UNK_TYPE"), # guessing this is void* bc it's a thread entry point
0x800A5B6C:("func_800A5B6C","UNK_RET","s800A5AC0*, z_GlobalContext*"),
0x800A5B98:("func_800A5B98","UNK_RET","s800A5AC0*, UNK_TYPE"),

189
include/PR/abi.h Normal file
View File

@ -0,0 +1,189 @@
#ifndef _ABI_H_
#define _ABI_H_
typedef struct {
/* 0x0 */ unsigned int cmd : 8;
/* 0x1 */ unsigned int flags : 8;
/* 0x2 */ unsigned int gain : 16;
/* 0x4 */ unsigned int addr;
} Aadpcm;
typedef struct {
/* 0x0 */ unsigned int cmd : 8;
/* 0x1 */ unsigned int flags : 8;
/* 0x2 */ unsigned int gain : 16;
/* 0x4 */ unsigned int addr;
} Apolef;
typedef struct {
/* 0x0 */ unsigned int cmd : 8;
/* 0x1 */ unsigned int flags : 8;
/* 0x2 */ unsigned int pad1 : 16;
/* 0x4 */ unsigned int addr;
} Aenvelope;
typedef struct {
/* 0x0 */ unsigned int cmd : 8;
/* 0x1 */ unsigned int pad1 : 8;
/* 0x2 */ unsigned int dmem : 16;
/* 0x4 */ unsigned int pad2 : 16;
/* 0x6 */ unsigned int count : 16;
} Aclearbuff;
typedef struct {
/* 0x0 */ unsigned int cmd : 8;
/* 0x1 */ unsigned int pad1 : 8;
/* 0x2 */ unsigned int pad2 : 16;
/* 0x4 */ unsigned int inL : 16;
/* 0x6 */ unsigned int inR : 16;
} Ainterleave;
typedef struct {
/* 0x0 */ unsigned int cmd : 8;
/* 0x1 */ unsigned int pad1 : 24;
/* 0x4 */ unsigned int addr;
} Aloadbuff;
typedef struct {
/* 0x0 */ unsigned int cmd : 8;
/* 0x1 */ unsigned int flags : 8;
/* 0x2 */ unsigned int pad1 : 16;
/* 0x4 */ unsigned int addr;
} Aenvmixer;
typedef struct {
/* 0x0 */ unsigned int cmd : 8;
/* 0x1 */ unsigned int flags : 8;
/* 0x2 */ unsigned int gain : 16;
/* 0x4 */ unsigned int dmemi : 16;
/* 0x6 */ unsigned int dmemo : 16;
} Amixer;
typedef struct {
/* 0x0 */ unsigned int cmd : 8;
/* 0x1 */ unsigned int flags : 8;
/* 0x2 */ unsigned int dmem2 : 16;
/* 0x4 */ unsigned int addr;
} Apan;
typedef struct {
/* 0x0 */ unsigned int cmd : 8;
/* 0x1 */ unsigned int flags : 8;
/* 0x2 */ unsigned int pitch : 16;
/* 0x4 */ unsigned int addr;
} Aresample;
typedef struct {
/* 0x0 */ unsigned int cmd : 8;
/* 0x1 */ unsigned int flags : 8;
/* 0x2 */ unsigned int pad1 : 16;
/* 0x4 */ unsigned int addr;
} Areverb;
typedef struct {
/* 0x0 */ unsigned int cmd : 8;
/* 0x1 */ unsigned int pad1 : 24;
/* 0x4 */ unsigned int addr;
} Asavebuff;
typedef struct {
/* 0x0 */ unsigned int cmd : 8;
/* 0x1 */ unsigned int pad1 : 24;
/* 0x4 */ unsigned int pad2 : 2;
/* 0x4 */ unsigned int number : 4;
/* 0x4 */ unsigned int base : 24;
} Asegment;
typedef struct {
/* 0x0 */ unsigned int cmd : 8;
/* 0x1 */ unsigned int flags : 8;
/* 0x2 */ unsigned int dmemin : 16;
/* 0x4 */ unsigned int dmemout : 16;
/* 0x6 */ unsigned int count : 16;
} Asetbuff;
typedef struct {
/* 0x0 */ unsigned int cmd : 8;
/* 0x1 */ unsigned int flags : 8;
/* 0x2 */ unsigned int vol : 16;
/* 0x4 */ unsigned int voltgt : 16;
/* 0x6 */ unsigned int volrate : 16;
} Asetvol;
typedef struct {
/* 0x0 */ unsigned int cmd : 8;
/* 0x1 */ unsigned int pad1 : 8;
/* 0x2 */ unsigned int dmemin : 16;
/* 0x4 */ unsigned int dmemout : 16;
/* 0x6 */ unsigned int count : 16;
} Admemmove;
typedef struct {
/* 0x0 */ unsigned int cmd : 8;
/* 0x1 */ unsigned int pad1 : 8;
/* 0x2 */ unsigned int count : 16;
/* 0x4 */ unsigned int addr;
} Aloadadpcm;
typedef struct {
/* 0x0 */ unsigned int cmd : 8;
/* 0x1 */ unsigned int pad1 : 8;
/* 0x2 */ unsigned int pad2 : 16;
/* 0x4 */ unsigned int addr;
} Asetloop;
typedef struct {
/* 0x0 */ unsigned int w0;
/* 0x4 */ unsigned int w1;
} Awords;
typedef union {
/* 0x0 */ Awords words;
/* 0x0 */ Aadpcm adpcm;
/* 0x0 */ Apolef polef;
/* 0x0 */ Aclearbuff clearbuff;
/* 0x0 */ Aenvelope envelope;
/* 0x0 */ Ainterleave interleave;
/* 0x0 */ Aloadbuff loadbuff;
/* 0x0 */ Aenvmixer envmixer;
/* 0x0 */ Aresample resample;
/* 0x0 */ Areverb reverb;
/* 0x0 */ Asavebuff savebuff;
/* 0x0 */ Asegment segment;
/* 0x0 */ Asetbuff setbuff;
/* 0x0 */ Asetvol setvol;
/* 0x0 */ Admemmove dmemmove;
/* 0x0 */ Aloadadpcm loadadpcm;
/* 0x0 */ Amixer mixer;
/* 0x0 */ Asetloop setloop;
/* 0x0 */ long long force_union_align;
} Acmd;
typedef short ADPCM_STATE[16];
typedef short POLEF_STATE[4];
typedef short RESAMPLE_STATE[16];
typedef short ENVMIX_STATE[40];
#endif

386
include/PR/gbi.h Normal file
View File

@ -0,0 +1,386 @@
#ifndef _GBI_H_
#define _GBI_H_
typedef struct {
/* 0x0 */ short ob[3];
/* 0x6 */ unsigned short flag;
/* 0x8 */ short tc[2];
/* 0xC */ unsigned char cn[4];
} Vtx_t;
typedef struct {
/* 0x0 */ short ob[3];
/* 0x6 */ unsigned short flag;
/* 0x8 */ short tc[2];
/* 0xC */ signed char n[3];
/* 0xF */ unsigned char a;
} Vtx_tn;
typedef union {
/* 0x0 */ Vtx_t v;
/* 0x0 */ Vtx_tn n;
/* 0x0 */ long long force_structure_alignment;
} Vtx;
typedef struct {
/* 0x0 */ unsigned char flag;
/* 0x1 */ unsigned char v[3];
} Tri;
typedef long Mtx_t[4][4];
typedef union {
/* 0x0 */ Mtx_t m;
/* 0x0 */ long long force_structure_alignment;
} Mtx;
typedef struct {
/* 0x0 */ short vscale[4];
/* 0x8 */ short vtrans[4];
} Vp_t;
typedef union {
/* 0x0 */ Vp_t vp;
/* 0x0 */ long long force_structure_alignment;
} Vp;
typedef struct {
/* 0x0 */ unsigned char col[3];
/* 0x3 */ unsigned char pad1;
/* 0x4 */ unsigned char colc[3];
/* 0x7 */ unsigned char pad2;
/* 0x8 */ signed char dir[3];
/* 0xB */ unsigned char pad3;
} Light_t;
typedef struct {
/* 0x0 */ unsigned char col[3];
/* 0x3 */ unsigned char pad1;
/* 0x4 */ unsigned char colc[3];
/* 0x7 */ unsigned char pad2;
} Ambient_t;
typedef struct {
/* 0x0 */ int x1;
/* 0x4 */ int y1;
/* 0x8 */ int x2;
/* 0xC */ int y2;
} Hilite_t;
typedef union {
/* 0x0 */ Light_t l;
/* 0x0 */ long long force_structure_alignment[2];
} Light;
typedef union {
/* 0x0 */ Ambient_t l;
/* 0x0 */ long long force_structure_alignment[1];
} Ambient;
typedef struct {
/* 0x0 */ Ambient a;
/* 0x8 */ Light l[7];
} Lightsn;
typedef struct {
/* 0x0 */ Ambient a;
/* 0x8 */ Light l[1];
} Lights0;
typedef struct {
/* 0x0 */ Ambient a;
/* 0x8 */ Light l[1];
} Lights1;
typedef struct {
/* 0x0 */ Ambient a;
/* 0x8 */ Light l[2];
} Lights2;
typedef struct {
/* 0x0 */ Ambient a;
/* 0x8 */ Light l[3];
} Lights3;
typedef struct {
/* 0x0 */ Ambient a;
/* 0x8 */ Light l[4];
} Lights4;
typedef struct {
/* 0x0 */ Ambient a;
/* 0x8 */ Light l[5];
} Lights5;
typedef struct {
/* 0x0 */ Ambient a;
/* 0x8 */ Light l[6];
} Lights6;
typedef struct {
/* 0x0 */ Ambient a;
/* 0x8 */ Light l[7];
} Lights7;
typedef struct {
/* 0x0 */ Light l[2];
} LookAt;
typedef union {
/* 0x0 */ Hilite_t h;
/* 0x0 */ long force_structure_alignment[4];
} Hilite;
typedef struct {
/* 0x0 */ int cmd : 8;
/* 0x1 */ unsigned int par : 8;
/* 0x2 */ unsigned int len : 16;
/* 0x4 */ unsigned int addr;
} Gdma;
typedef struct {
/* 0x0 */ int cmd : 8;
/* 0x1 */ int pad : 24;
/* 0x4 */ Tri tri;
} Gtri;
typedef struct {
/* 0x0 */ int cmd : 8;
/* 0x1 */ int pad1 : 24;
/* 0x4 */ int pad2 : 24;
/* 0x7 */ unsigned char param : 8;
} Gpopmtx;
typedef struct {
/* 0x0 */ int cmd : 8;
/* 0x1 */ int pad0 : 8;
/* 0x2 */ int mw_index : 8;
/* 0x3 */ int number : 8;
/* 0x4 */ int pad1 : 8;
/* 0x5 */ int base : 24;
} Gsegment;
typedef struct {
/* 0x0 */ int cmd : 8;
/* 0x1 */ int pad0 : 8;
/* 0x2 */ int sft : 8;
/* 0x3 */ int len : 8;
/* 0x4 */ unsigned int data : 32;
} GsetothermodeL;
typedef struct {
/* 0x0 */ int cmd : 8;
/* 0x1 */ int pad0 : 8;
/* 0x2 */ int sft : 8;
/* 0x3 */ int len : 8;
/* 0x4 */ unsigned int data : 32;
} GsetothermodeH;
typedef struct {
/* 0x0 */ unsigned char cmd;
/* 0x1 */ unsigned char lodscale;
/* 0x2 */ unsigned char tile;
/* 0x3 */ unsigned char on;
/* 0x4 */ unsigned short s;
/* 0x6 */ unsigned short t;
} Gtexture;
typedef struct {
/* 0x0 */ int cmd : 8;
/* 0x1 */ int pad : 24;
/* 0x4 */ Tri line;
} Gline3D;
typedef struct {
/* 0x0 */ int cmd : 8;
/* 0x1 */ int pad1 : 24;
/* 0x4 */ short pad2;
/* 0x6 */ short scale;
} Gperspnorm;
typedef struct {
/* 0x0 */ int cmd : 8;
/* 0x1 */ unsigned int fmt : 3;
/* 0x1 */ unsigned int siz : 2;
/* 0x1 */ unsigned int pad : 7;
/* 0x2 */ unsigned int wd : 12;
/* 0x4 */ unsigned int dram;
} Gsetimg;
typedef struct {
/* 0x0 */ int cmd : 8;
/* 0x1 */ unsigned int muxs0 : 24;
/* 0x4 */ unsigned int muxs1 : 32;
} Gsetcombine;
typedef struct {
/* 0x0 */ int cmd : 8;
/* 0x1 */ unsigned char pad;
/* 0x2 */ unsigned char prim_min_level;
/* 0x3 */ unsigned char prim_level;
/* 0x4 */ unsigned long color;
} Gsetcolor;
typedef struct {
/* 0x0 */ int cmd : 8;
/* 0x1 */ int x0 : 10;
/* 0x2 */ int x0frac : 2;
/* 0x2 */ int y0 : 10;
/* 0x3 */ int y0frac : 2;
/* 0x4 */ unsigned int pad : 8;
/* 0x5 */ int x1 : 10;
/* 0x6 */ int x1frac : 2;
/* 0x6 */ int y1 : 10;
/* 0x7 */ int y1frac : 2;
} Gfillrect;
typedef struct {
/* 0x0 */ int cmd : 8;
/* 0x1 */ unsigned int fmt : 3;
/* 0x1 */ unsigned int siz : 2;
/* 0x1 */ unsigned int pad0 : 1;
/* 0x1 */ unsigned int line : 9;
/* 0x2 */ unsigned int tmem : 9;
/* 0x4 */ unsigned int pad1 : 5;
/* 0x4 */ unsigned int tile : 3;
/* 0x5 */ unsigned int palette : 4;
/* 0x5 */ unsigned int ct : 1;
/* 0x5 */ unsigned int mt : 1;
/* 0x5 */ unsigned int maskt : 4;
/* 0x6 */ unsigned int shiftt : 4;
/* 0x6 */ unsigned int cs : 1;
/* 0x6 */ unsigned int ms : 1;
/* 0x7 */ unsigned int masks : 4;
/* 0x7 */ unsigned int shifts : 4;
} Gsettile;
typedef struct {
/* 0x0 */ int cmd : 8;
/* 0x1 */ unsigned int sl : 12;
/* 0x2 */ unsigned int tl : 12;
/* 0x4 */ int pad : 5;
/* 0x4 */ unsigned int tile : 3;
/* 0x5 */ unsigned int sh : 12;
/* 0x6 */ unsigned int th : 12;
} Gloadtile;
typedef struct {
/* 0x0 */ int cmd : 8;
/* 0x1 */ unsigned int sl : 12;
/* 0x2 */ unsigned int tl : 12;
/* 0x4 */ int pad : 5;
/* 0x4 */ unsigned int tile : 3;
/* 0x5 */ unsigned int sh : 12;
/* 0x6 */ unsigned int th : 12;
} Gloadblock;
typedef struct {
/* 0x0 */ int cmd : 8;
/* 0x1 */ unsigned int sl : 12;
/* 0x2 */ unsigned int tl : 12;
/* 0x4 */ int pad : 5;
/* 0x4 */ unsigned int tile : 3;
/* 0x5 */ unsigned int sh : 12;
/* 0x6 */ unsigned int th : 12;
} Gsettilesize;
typedef struct {
/* 0x0 */ int cmd : 8;
/* 0x1 */ unsigned int sl : 12;
/* 0x2 */ unsigned int tl : 12;
/* 0x4 */ int pad : 5;
/* 0x4 */ unsigned int tile : 3;
/* 0x5 */ unsigned int sh : 12;
/* 0x6 */ unsigned int th : 12;
} Gloadtlut;
typedef struct {
/* 0x0 */ unsigned int cmd : 8;
/* 0x1 */ unsigned int xl : 12;
/* 0x2 */ unsigned int yl : 12;
/* 0x4 */ unsigned int pad1 : 5;
/* 0x4 */ unsigned int tile : 3;
/* 0x5 */ unsigned int xh : 12;
/* 0x6 */ unsigned int yh : 12;
/* 0x8 */ unsigned int s : 16;
/* 0xA */ unsigned int t : 16;
/* 0xC */ unsigned int dsdx : 16;
/* 0xE */ unsigned int dtdy : 16;
} Gtexrect;
typedef struct {
/* 0x0 */ unsigned long w0;
/* 0x4 */ unsigned long w1;
/* 0x8 */ unsigned long w2;
/* 0xC */ unsigned long w3;
} TexRect;
typedef struct {
/* 0x0 */ unsigned int w0;
/* 0x4 */ unsigned int w1;
} Gwords;
typedef union {
/* 0x0 */ Gwords words;
/* 0x0 */ Gdma dma;
/* 0x0 */ Gtri tri;
/* 0x0 */ Gline3D line;
/* 0x0 */ Gpopmtx popmtx;
/* 0x0 */ Gsegment segment;
/* 0x0 */ GsetothermodeH setothermodeH;
/* 0x0 */ GsetothermodeL setothermodeL;
/* 0x0 */ Gtexture texture;
/* 0x0 */ Gperspnorm perspnorm;
/* 0x0 */ Gsetimg setimg;
/* 0x0 */ Gsetcombine setcombine;
/* 0x0 */ Gsetcolor setcolor;
/* 0x0 */ Gfillrect fillrect;
/* 0x0 */ Gsettile settile;
/* 0x0 */ Gloadtile loadtile;
/* 0x0 */ Gloadtile settilesize;
/* 0x0 */ Gloadtile loadtlut;
/* 0x0 */ long long force_structure_alignment;
} Gfx;
#endif

26
include/PR/gu.h Normal file
View File

@ -0,0 +1,26 @@
#ifndef _GU_H_
#define _GU_H_
typedef struct {
/* 0x0 */ unsigned char* base;
/* 0x4 */ int fmt;
/* 0x8 */ int siz;
/* 0xC */ int xsize;
/* 0x10 */ int ysize;
/* 0x14 */ int lsize;
/* 0x18 */ int addr;
/* 0x1C */ int w;
/* 0x20 */ int h;
/* 0x24 */ int s;
/* 0x28 */ int t;
} Image;
typedef struct {
/* 0x0 */ float col[3];
/* 0xC */ float pos[3];
/* 0x18 */ float a1;
/* 0x1C */ float a2;
} PositionalLight;
#endif

View File

@ -4,6 +4,7 @@
#include <PR/ultratypes.h>
#include <osint.h>
#include <viint.h>
#include <guint.h>
#include <unk.h>
#include <structs.h>
@ -44,7 +45,6 @@ void func_80080E00(void); // func_80080E00
// UNK_RET func_80081550(UNK_ARGS);
// UNK_RET func_800815A8(UNK_ARGS);
// UNK_RET func_800815CC(UNK_ARGS);
// UNK_RET func_800815CC(UNK_ARGS);
// UNK_RET func_80081684(UNK_ARGS);
// UNK_RET func_800816E8(UNK_ARGS);
// UNK_RET func_800816F8(UNK_ARGS);
@ -290,7 +290,7 @@ void osSpTaskYield(void); // func_8008AF50
// UNK_RET func_8008B554(UNK_ARGS);
// UNK_RET func_8008B600(UNK_ARGS);
UNK_RET func_8008B650(UNK_PTR); // func_8008B650
u32 __osGetConfig(void ); // func_8008B6B0
u32 __osGetConfig(void); // func_8008B6B0
void __osSetConfig(u32 value); // func_8008B6C0
// UNK_RET func_8008B6D0(UNK_ARGS);
// UNK_RET func_8008B974(UNK_ARGS);
@ -457,8 +457,6 @@ UNK_RET osViModeNtscHpf1(UNK_ARGS); // func_80097540
UNK_RET osViModeNtscHpn1(UNK_ARGS); // func_80097EB0
UNK_RET osViModeNtscLan1(UNK_ARGS); // func_80097FC0
UNK_RET osViModeMpalLan1(UNK_ARGS); // func_80098010
UNK_RET __osRcpImTable(UNK_ARGS); // func_800991A0
UNK_RET __libm_qnan_f(UNK_ARGS); // func_80099450
UNK_RET func_800A5AC0(void*, UNK_TYPE); // func_800A5AC0
UNK_RET func_800A5B6C(s800A5AC0*, z_GlobalContext*); // func_800A5B6C
UNK_RET func_800A5B98(s800A5AC0*, UNK_TYPE); // func_800A5B98

28
include/guint.h Normal file
View File

@ -0,0 +1,28 @@
#ifndef _GUINT_H_
#define _GUINT_H_
// TODO should be in libultra/gu
#include <PR/gbi.h>
#include <PR/abi.h>
#include <PR/ultratypes.h>
#include <sptask.h> // TODO the load path for this is actually PR/sptask.h, why?
#include <PR/gu.h>
typedef union {
/* 0x0 */ struct {
/* 0x0 */ unsigned int hi;
/* 0x4 */ unsigned int lo;
} word;
/* 0x0 */ double d;
} du;
typedef union {
/* 0x0 */ unsigned int i;
/* 0x0 */ float f;
} fu;
typedef float Matrix[4][4];
#endif

View File

@ -170,13 +170,6 @@ typedef struct {
// TODO everything past here should be placed in an appropiate libultra header
typedef long Mtx_t[4][4];
typedef union {
/* 0x0 */ Mtx_t m;
/* 0x0 */ long long force_structure_alignment;
} Mtx;
typedef struct {
/* 0x0 */ int quot;

View File

@ -4,6 +4,7 @@
#include <PR/ultratypes.h>
#include <osint.h>
#include <viint.h>
#include <guint.h>
#include <unk.h>
#include <structs.h>
@ -2071,10 +2072,11 @@ extern UNK_TYPE D_800982A4; // D_800982A4
//extern UNK_TYPE D_80099108;
//extern UNK_TYPE D_8009910C;
//extern UNK_TYPE D_800991A0;
//extern UNK_TYPE D_80099220;
//extern UNK_TYPE D_80099248;
//extern UNK_TYPE D_80099250;
//extern UNK_TYPE D_80099258;
extern du P[]; // D_80099220
extern du rpi; // D_80099248
extern du pihi; // D_80099250
extern du pilo; // D_80099258
extern fu zero; // D_80099260
extern UNK_TYPE __osHwIntTable; // D_80099270
extern UNK_TYPE leoDiskStack; // D_80099290
//extern UNK_TYPE D_800992C0;
@ -2085,7 +2087,7 @@ extern UNK_TYPE leoDiskStack; // D_80099290
//extern UNK_TYPE D_80099428;
//extern UNK_TYPE D_80099430;
//extern UNK_TYPE D_80099438;
//extern UNK_TYPE D_80099450;
extern float __libm_qnan_f; // D_80099450
//extern UNK_TYPE D_80099460;
//extern UNK_TYPE D_800994A8;
//extern UNK_TYPE D_800994B0;

89
src/libultra/gu/sinf.c Normal file
View File

@ -0,0 +1,89 @@
#include <guint.h>
// TODO find these values wherever they are in .rodata
// TODO these can't be defined in here yet because we strip out the .rodata for each object
//static const du P[5];
//static const du rpi;
//static const du pihi;
//static const du pilo;
//static const fu zero;
extern du P[5];
extern du rpi;
extern du pihi;
extern du pilo;
extern fu zero;
extern float __libm_qnan_f;
float __sinf(float x) {
double dx; // double x
double xsq; // x squared
double poly;
double dn;
int n;
double result;
int ix; // int x
int xpt;
ix = *(int*)&x;
xpt = (ix >> 22) & 0x1FF;
if (xpt < 255) {
dx = x;
if (xpt >= 230) {
xsq = dx * dx;
poly = (((((P[4].d * xsq) + P[3].d) * xsq) + P[2].d) * xsq) + P[1].d;
result = ((dx * xsq) * poly) + dx;
return result;
} else {
return x;
}
}
if (xpt < 310) {
dx = x;
dn = dx * rpi.d;
if (dn >= 0) {
n = dn + 0.5;
} else {
n = dn - 0.5;
}
dn = n;
dx -= dn * pihi.d;
dx -= dn * pilo.d;
xsq = dx * dx;
poly = (((((P[4].d * xsq) + P[3].d) * xsq) + P[2].d) * xsq) + P[1].d;
result = ((dx * xsq) * poly) + dx;
if ((n & 0x1) == 0) {
return result;
} else {
return -(float)result;
}
}
if (x != x) {
return __libm_qnan_f;
}
return zero.f;
}

View File

@ -2062,10 +2062,11 @@ D_80099104 = 0x80099104;
D_80099108 = 0x80099108;
D_8009910C = 0x8009910C;
D_800991A0 = 0x800991A0;
D_80099220 = 0x80099220;
D_80099248 = 0x80099248;
D_80099250 = 0x80099250;
D_80099258 = 0x80099258;
P = 0x80099220;
rpi = 0x80099248;
pihi = 0x80099250;
pilo = 0x80099258;
zero = 0x80099260;
__osHwIntTable = 0x80099270;
leoDiskStack = 0x80099290;
D_800992C0 = 0x800992C0;
@ -2076,7 +2077,7 @@ D_80099400 = 0x80099400;
D_80099428 = 0x80099428;
D_80099430 = 0x80099430;
D_80099438 = 0x80099438;
D_80099450 = 0x80099450;
__libm_qnan_f = 0x80099450;
D_80099460 = 0x80099460;
D_800994A8 = 0x800994A8;
D_800994B0 = 0x800994B0;

View File

@ -5,6 +5,9 @@ known_vars = {
0x00ACC000:("","UNK_TYPE",False), # this seems low
0x00B3C000:("","UNK_TYPE",False), # this seems low
0x00C7A4E0:("","UNK_TYPE",False), # this seems low
0x00C7A4E0:("","UNK_TYPE",False), # this seems low
0x06001100:("","UNK_TYPE",False), # this seems low
0x06001228:("","UNK_TYPE",False), # this seems low
0x80000300:("osTvType","UNK_TYPE",False),
0x80000304:("osRomType","UNK_TYPE",False),
0x80000308:("osRomBase","UNK_TYPE",False),
@ -67,8 +70,14 @@ known_vars = {
0x80098280:("","UNK_TYPE",False),
0x80098290:("","UNK_TYPE",False),
0x800982A4:("","UNK_TYPE",False),
0x80099220:("P","du",True),
0x80099248:("rpi","du",False),
0x80099250:("pihi","du",False),
0x80099258:("pilo","du",False),
0x80099260:("zero","fu",False),
0x80099270:("__osHwIntTable","UNK_TYPE",False),
0x80099290:("leoDiskStack","UNK_TYPE",False),
0x80099450:("__libm_qnan_f", "float",False),
0x800994D0:("","UNK_TYPE",False),
0x800994DC:("","UNK_TYPE",False),
0x80099500:("","s80085320",False),