Skip to content

Commit

Permalink
Decompile sinf.c
Browse files Browse the repository at this point in the history
Rozelette committed Nov 17, 2018
1 parent bd39741 commit 55bece5
Showing 14 changed files with 760 additions and 31 deletions.
16 changes: 12 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 1 addition & 1 deletion codescript.txt
Original file line number Diff line number Diff line change
@@ -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)
4 changes: 2 additions & 2 deletions disasm.py
Original file line number Diff line number Diff line change
@@ -593,7 +593,7 @@ def generate_headers(self, path):
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 @@ def generate_headers(self, path):
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:
6 changes: 3 additions & 3 deletions functions.py
Original file line number Diff line number Diff line change
@@ -42,7 +42,7 @@
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 @@
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 changes: 189 additions & 0 deletions include/PR/abi.h
Original file line number Diff line number Diff line change
@@ -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
Loading

0 comments on commit 55bece5

Please sign in to comment.