1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2024-11-25 09:45:02 +00:00

code_80106550 / llcvt.c and code_80104450 / ortho.c OK (#163)

* llcvt.c OK, added script from mm decomp to set mips3

* ortho.c OK

* added entries to functions.h

* named guNormalize.s
This commit is contained in:
Lucas Shaw 2020-05-27 00:48:07 -07:00 committed by GitHub
parent c68d752813
commit 02fc5287cc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 118 additions and 326 deletions

View file

@ -35,9 +35,10 @@ ZAP2 := tools/ZAP2/ZAP2.out
OPTFLAGS := -O2
ASFLAGS := -march=vr4300 -32 -Iinclude
MIPS_VERSION := -mips2
# we support Microsoft extensions such as anonymous structs, which the compiler does support but warns for their usage. Surpress the warnings with -woff.
CFLAGS := -mips2 -G 0 -non_shared -Xfullwarn -Xcpluscomm -Iinclude -Isrc -Wab,-r4300_mul -woff 649,838
CFLAGS := -G 0 -non_shared -Xfullwarn -Xcpluscomm -Iinclude -Isrc -Wab,-r4300_mul -woff 649,838
ifeq ($(shell getconf LONG_BIT), 32)
# Work around memory allocation bug in QEMU
@ -102,6 +103,8 @@ build/src/code/fault_drawer.o: OPTFLAGS := -O2 -g3
build/src/code/code_801068B0.o: OPTFLAGS := -g
build/src/code/code_80106860.o: OPTFLAGS := -g
build/src/code/code_801067F0.o: OPTFLAGS := -g
build/src/libultra_code/llcvt.o: OPTFLAGS := -O1
build/src/libultra_code/llcvt.o: MIPS_VERSION := -mips3 -32
# Todo: split libultra_code into libultra_code_O1, etc..
build/src/libultra_code/sqrt.o: OPTFLAGS := -O2 -g3
@ -170,25 +173,32 @@ build/data/%.o: data/%.s
# cp $(<:.c=.xml) $@
build/scenes/%.o: scenes/%.c
$(CC) -c $(CFLAGS) $(OPTFLAGS) -o $@ $^
$(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $^
$(OBJCOPY) -O binary $@ $@.bin
build/assets/%.o: assets/%.c
$(CC) -c $(CFLAGS) $(OPTFLAGS) -o $@ $^
$(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $^
$(OBJCOPY) -O binary $@ $@.bin
build/src/overlays/%.o: src/overlays/%.c
$(CC) -c $(CFLAGS) $(OPTFLAGS) -o $@ $^
$(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $^
$(CC_CHECK) $^
$(ZAP2) bovl -i $@ -cfg $^ -o $(@:.o=_reloc.s)
-test -f $(@:.o=_reloc.s) && $(AS) $(ASFLAGS) $(@:.o=_reloc.s) -o $(@:.o=_reloc.o)
@$(OBJDUMP) -d $@ > $(@:.o=.s)
build/src/%.o: src/%.c
$(CC) -c $(CFLAGS) $(OPTFLAGS) -o $@ $^
$(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $^
$(CC_CHECK) $^
@$(OBJDUMP) -d $@ > $(@:.o=.s)
build/src/libultra_code/llcvt.o: src/libultra_code/llcvt.c
$(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $^
$(CC_CHECK) $^
python3 tools/set_o32abi_bit.py $@
@$(OBJDUMP) -d $@ > $(@:.o=.s)
#build/assets/textures/%.o: assets/textures/%.zdata
# $(OBJCOPY) -I binary -O elf32-big $< $@

View file

@ -1,126 +0,0 @@
.include "macro.inc"
# assembler directives
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
.set gp=64 # allow use of 64-bit general purpose registers
.section .text
.balign 16
glabel func_80104450
/* B7B5F0 80104450 27BDFFE8 */ addiu $sp, $sp, -0x18
/* B7B5F4 80104454 AFBF0014 */ sw $ra, 0x14($sp)
/* B7B5F8 80104458 AFA5001C */ sw $a1, 0x1c($sp)
/* B7B5FC 8010445C AFA60020 */ sw $a2, 0x20($sp)
/* B7B600 80104460 AFA70024 */ sw $a3, 0x24($sp)
/* B7B604 80104464 0C0406D0 */ jal guMtxIdentF
/* B7B608 80104468 AFA40018 */ sw $a0, 0x18($sp)
/* B7B60C 8010446C C7A40020 */ lwc1 $f4, 0x20($sp)
/* B7B610 80104470 C7A6001C */ lwc1 $f6, 0x1c($sp)
/* B7B614 80104474 3C014000 */ li $at, 0x40000000 # 0.000000
/* B7B618 80104478 44814000 */ mtc1 $at, $f8
/* B7B61C 8010447C 46062001 */ sub.s $f0, $f4, $f6
/* B7B620 80104480 8FA20018 */ lw $v0, 0x18($sp)
/* B7B624 80104484 C7AE0028 */ lwc1 $f14, 0x28($sp)
/* B7B628 80104488 C7B00030 */ lwc1 $f16, 0x30($sp)
/* B7B62C 8010448C 46004283 */ div.s $f10, $f8, $f0
/* B7B630 80104490 C7B2002C */ lwc1 $f18, 0x2c($sp)
/* B7B634 80104494 44813000 */ mtc1 $at, $f6
/* B7B638 80104498 3C01C000 */ li $at, 0xC0000000 # 0.000000
/* B7B63C 8010449C 46128301 */ sub.s $f12, $f16, $f18
/* B7B640 801044A0 00001825 */ move $v1, $zero
/* B7B644 801044A4 24040004 */ li $a0, 4
/* B7B648 801044A8 E44A0000 */ swc1 $f10, ($v0)
/* B7B64C 801044AC C7A40024 */ lwc1 $f4, 0x24($sp)
/* B7B650 801044B0 44815000 */ mtc1 $at, $f10
/* B7B654 801044B4 3C013F80 */ li $at, 0x3F800000 # 0.000000
/* B7B658 801044B8 46047081 */ sub.s $f2, $f14, $f4
/* B7B65C 801044BC 460C5103 */ div.s $f4, $f10, $f12
/* B7B660 801044C0 46023203 */ div.s $f8, $f6, $f2
/* B7B664 801044C4 E4440028 */ swc1 $f4, 0x28($v0)
/* B7B668 801044C8 E4480014 */ swc1 $f8, 0x14($v0)
/* B7B66C 801044CC C7A8001C */ lwc1 $f8, 0x1c($sp)
/* B7B670 801044D0 C7A60020 */ lwc1 $f6, 0x20($sp)
/* B7B674 801044D4 46083280 */ add.s $f10, $f6, $f8
/* B7B678 801044D8 46005107 */ neg.s $f4, $f10
/* B7B67C 801044DC 46002183 */ div.s $f6, $f4, $f0
/* B7B680 801044E0 E4460030 */ swc1 $f6, 0x30($v0)
/* B7B684 801044E4 C7A80024 */ lwc1 $f8, 0x24($sp)
/* B7B688 801044E8 46087280 */ add.s $f10, $f14, $f8
/* B7B68C 801044EC 46128200 */ add.s $f8, $f16, $f18
/* B7B690 801044F0 46005107 */ neg.s $f4, $f10
/* B7B694 801044F4 46004287 */ neg.s $f10, $f8
/* B7B698 801044F8 46022183 */ div.s $f6, $f4, $f2
/* B7B69C 801044FC 460C5103 */ div.s $f4, $f10, $f12
/* B7B6A0 80104500 E4460034 */ swc1 $f6, 0x34($v0)
/* B7B6A4 80104504 44813000 */ mtc1 $at, $f6
/* B7B6A8 80104508 00000000 */ nop
/* B7B6AC 8010450C E446003C */ swc1 $f6, 0x3c($v0)
/* B7B6B0 80104510 E4440038 */ swc1 $f4, 0x38($v0)
/* B7B6B4 80104514 C7A00034 */ lwc1 $f0, 0x34($sp)
/* B7B6B8 80104518 C4480000 */ lwc1 $f8, ($v0)
/* B7B6BC 8010451C 24630001 */ addiu $v1, $v1, 1
/* B7B6C0 80104520 C4520004 */ lwc1 $f18, 4($v0)
/* B7B6C4 80104524 46004302 */ mul.s $f12, $f8, $f0
/* B7B6C8 80104528 C44E0008 */ lwc1 $f14, 8($v0)
/* B7B6CC 8010452C 10640010 */ beq $v1, $a0, .L80104570
/* B7B6D0 80104530 C450000C */ lwc1 $f16, 0xc($v0)
.L80104534:
/* B7B6D4 80104534 46009282 */ mul.s $f10, $f18, $f0
/* B7B6D8 80104538 C4480010 */ lwc1 $f8, 0x10($v0)
/* B7B6DC 8010453C C4520014 */ lwc1 $f18, 0x14($v0)
/* B7B6E0 80104540 46007182 */ mul.s $f6, $f14, $f0
/* B7B6E4 80104544 C44E0018 */ lwc1 $f14, 0x18($v0)
/* B7B6E8 80104548 24630001 */ addiu $v1, $v1, 1
/* B7B6EC 8010454C 46008102 */ mul.s $f4, $f16, $f0
/* B7B6F0 80104550 C450001C */ lwc1 $f16, 0x1c($v0)
/* B7B6F4 80104554 E44C0000 */ swc1 $f12, ($v0)
/* B7B6F8 80104558 46004302 */ mul.s $f12, $f8, $f0
/* B7B6FC 8010455C E44A0004 */ swc1 $f10, 4($v0)
/* B7B700 80104560 E4460008 */ swc1 $f6, 8($v0)
/* B7B704 80104564 24420010 */ addiu $v0, $v0, 0x10
/* B7B708 80104568 1464FFF2 */ bne $v1, $a0, .L80104534
/* B7B70C 8010456C E444FFFC */ swc1 $f4, -4($v0)
.L80104570:
/* B7B710 80104570 46009282 */ mul.s $f10, $f18, $f0
/* B7B714 80104574 24420010 */ addiu $v0, $v0, 0x10
/* B7B718 80104578 E44CFFF0 */ swc1 $f12, -0x10($v0)
/* B7B71C 8010457C 46007182 */ mul.s $f6, $f14, $f0
/* B7B720 80104580 00000000 */ nop
/* B7B724 80104584 46008102 */ mul.s $f4, $f16, $f0
/* B7B728 80104588 E44AFFF4 */ swc1 $f10, -0xc($v0)
/* B7B72C 8010458C E446FFF8 */ swc1 $f6, -8($v0)
/* B7B730 80104590 E444FFFC */ swc1 $f4, -4($v0)
/* B7B734 80104594 8FBF0014 */ lw $ra, 0x14($sp)
/* B7B738 80104598 27BD0018 */ addiu $sp, $sp, 0x18
/* B7B73C 8010459C 03E00008 */ jr $ra
/* B7B740 801045A0 00000000 */ nop
glabel func_801045A4
/* B7B744 801045A4 27BDFF98 */ addiu $sp, $sp, -0x68
/* B7B748 801045A8 44856000 */ mtc1 $a1, $f12
/* B7B74C 801045AC 44867000 */ mtc1 $a2, $f14
/* B7B750 801045B0 C7A40078 */ lwc1 $f4, 0x78($sp)
/* B7B754 801045B4 C7A6007C */ lwc1 $f6, 0x7c($sp)
/* B7B758 801045B8 C7A80080 */ lwc1 $f8, 0x80($sp)
/* B7B75C 801045BC C7AA0084 */ lwc1 $f10, 0x84($sp)
/* B7B760 801045C0 AFBF0024 */ sw $ra, 0x24($sp)
/* B7B764 801045C4 AFA40068 */ sw $a0, 0x68($sp)
/* B7B768 801045C8 44056000 */ mfc1 $a1, $f12
/* B7B76C 801045CC 44067000 */ mfc1 $a2, $f14
/* B7B770 801045D0 AFA70074 */ sw $a3, 0x74($sp)
/* B7B774 801045D4 27A40028 */ addiu $a0, $sp, 0x28
/* B7B778 801045D8 E7A40010 */ swc1 $f4, 0x10($sp)
/* B7B77C 801045DC E7A60014 */ swc1 $f6, 0x14($sp)
/* B7B780 801045E0 E7A80018 */ swc1 $f8, 0x18($sp)
/* B7B784 801045E4 0C041114 */ jal func_80104450
/* B7B788 801045E8 E7AA001C */ swc1 $f10, 0x1c($sp)
/* B7B78C 801045EC 27A40028 */ addiu $a0, $sp, 0x28
/* B7B790 801045F0 0C041938 */ jal guMtxF2L
/* B7B794 801045F4 8FA50068 */ lw $a1, 0x68($sp)
/* B7B798 801045F8 8FBF0024 */ lw $ra, 0x24($sp)
/* B7B79C 801045FC 27BD0068 */ addiu $sp, $sp, 0x68
/* B7B7A0 80104600 03E00008 */ jr $ra
/* B7B7A4 80104604 00000000 */ nop

View file

@ -1,164 +0,0 @@
.include "macro.inc"
# assembler directives
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
.set gp=64 # allow use of 64-bit general purpose registers
.section .text
.balign 16
glabel __d_to_ll
/* B7D6F0 80106550 46206109 */ trunc.l.d $f4, $f12
/* B7D6F4 80106554 44222000 */ dmfc1 $v0, $f4
/* B7D6F8 80106558 00000000 */ nop
/* B7D6FC 8010655C 0002183C */ dsll32 $v1, $v0, 0
/* B7D700 80106560 0003183F */ dsra32 $v1, $v1, 0
/* B7D704 80106564 03E00008 */ jr $ra
/* B7D708 80106568 0002103F */ dsra32 $v0, $v0, 0
glabel __f_to_ll
/* B7D70C 8010656C 46006109 */ trunc.l.s $f4, $f12
/* B7D710 80106570 44222000 */ dmfc1 $v0, $f4
/* B7D714 80106574 00000000 */ nop
/* B7D718 80106578 0002183C */ dsll32 $v1, $v0, 0
/* B7D71C 8010657C 0003183F */ dsra32 $v1, $v1, 0
/* B7D720 80106580 03E00008 */ jr $ra
/* B7D724 80106584 0002103F */ dsra32 $v0, $v0, 0
glabel __d_to_ull
/* B7D728 80106588 444EF800 */ cfc1 $t6, $31
/* B7D72C 8010658C 24020001 */ li $v0, 1
/* B7D730 80106590 44C2F800 */ ctc1 $v0, $31
/* B7D734 80106594 00000000 */ nop
/* B7D738 80106598 46206125 */ cvt.l.d $f4, $f12
/* B7D73C 8010659C 4442F800 */ cfc1 $v0, $31
/* B7D740 801065A0 00000000 */ nop
/* B7D744 801065A4 30410004 */ andi $at, $v0, 4
/* B7D748 801065A8 30420078 */ andi $v0, $v0, 0x78
/* B7D74C 801065AC 10400015 */ beqz $v0, .L80106604
/* B7D750 801065B0 3C0143E0 */ li $at, 0x43E00000 # 0.000000
/* B7D754 801065B4 44812800 */ mtc1 $at, $f5
/* B7D758 801065B8 44802000 */ mtc1 $zero, $f4
/* B7D75C 801065BC 24020001 */ li $v0, 1
/* B7D760 801065C0 46246101 */ sub.d $f4, $f12, $f4
/* B7D764 801065C4 44C2F800 */ ctc1 $v0, $31
/* B7D768 801065C8 00000000 */ nop
/* B7D76C 801065CC 46202125 */ cvt.l.d $f4, $f4
/* B7D770 801065D0 4442F800 */ cfc1 $v0, $31
/* B7D774 801065D4 00000000 */ nop
/* B7D778 801065D8 30410004 */ andi $at, $v0, 4
/* B7D77C 801065DC 30420078 */ andi $v0, $v0, 0x78
/* B7D780 801065E0 14400006 */ bnez $v0, .L801065FC
/* B7D784 801065E4 00000000 */ nop
/* B7D788 801065E8 3C0F8015 */ lui $t7, %hi(D_8014B2E0) # $t7, 0x8015
/* B7D78C 801065EC DDEFB2E0 */ ld $t7, %lo(D_8014B2E0)($t7)
/* B7D790 801065F0 44222000 */ dmfc1 $v0, $f4
/* B7D794 801065F4 10000007 */ b .L80106614
/* B7D798 801065F8 004F1025 */ or $v0, $v0, $t7
.L801065FC:
/* B7D79C 801065FC 10000005 */ b .L80106614
/* B7D7A0 80106600 2402FFFF */ li $v0, -1
.L80106604:
/* B7D7A4 80106604 44222000 */ dmfc1 $v0, $f4
/* B7D7A8 80106608 00000000 */ nop
/* B7D7AC 8010660C 0440FFFB */ bltz $v0, .L801065FC
/* B7D7B0 80106610 00000000 */ nop
.L80106614:
/* B7D7B4 80106614 44CEF800 */ ctc1 $t6, $31
/* B7D7B8 80106618 0002183C */ dsll32 $v1, $v0, 0
/* B7D7BC 8010661C 0003183F */ dsra32 $v1, $v1, 0
/* B7D7C0 80106620 03E00008 */ jr $ra
/* B7D7C4 80106624 0002103F */ dsra32 $v0, $v0, 0
glabel __f_to_ull
/* B7D7C8 80106628 444EF800 */ cfc1 $t6, $31
/* B7D7CC 8010662C 24020001 */ li $v0, 1
/* B7D7D0 80106630 44C2F800 */ ctc1 $v0, $31
/* B7D7D4 80106634 00000000 */ nop
/* B7D7D8 80106638 46006125 */ cvt.l.s $f4, $f12
/* B7D7DC 8010663C 4442F800 */ cfc1 $v0, $31
/* B7D7E0 80106640 00000000 */ nop
/* B7D7E4 80106644 30410004 */ andi $at, $v0, 4
/* B7D7E8 80106648 30420078 */ andi $v0, $v0, 0x78
/* B7D7EC 8010664C 10400014 */ beqz $v0, .L801066A0
/* B7D7F0 80106650 3C015F00 */ li $at, 0x5F000000 # 0.000000
/* B7D7F4 80106654 44812000 */ mtc1 $at, $f4
/* B7D7F8 80106658 24020001 */ li $v0, 1
/* B7D7FC 8010665C 46046101 */ sub.s $f4, $f12, $f4
/* B7D800 80106660 44C2F800 */ ctc1 $v0, $31
/* B7D804 80106664 00000000 */ nop
/* B7D808 80106668 46002125 */ cvt.l.s $f4, $f4
/* B7D80C 8010666C 4442F800 */ cfc1 $v0, $31
/* B7D810 80106670 00000000 */ nop
/* B7D814 80106674 30410004 */ andi $at, $v0, 4
/* B7D818 80106678 30420078 */ andi $v0, $v0, 0x78
/* B7D81C 8010667C 14400006 */ bnez $v0, .L80106698
/* B7D820 80106680 00000000 */ nop
/* B7D824 80106684 3C0F8015 */ lui $t7, %hi(D_8014B2E8) # $t7, 0x8015
/* B7D828 80106688 DDEFB2E8 */ ld $t7, %lo(D_8014B2E8)($t7)
/* B7D82C 8010668C 44222000 */ dmfc1 $v0, $f4
/* B7D830 80106690 10000007 */ b .L801066B0
/* B7D834 80106694 004F1025 */ or $v0, $v0, $t7
.L80106698:
/* B7D838 80106698 10000005 */ b .L801066B0
/* B7D83C 8010669C 2402FFFF */ li $v0, -1
.L801066A0:
/* B7D840 801066A0 44222000 */ dmfc1 $v0, $f4
/* B7D844 801066A4 00000000 */ nop
/* B7D848 801066A8 0440FFFB */ bltz $v0, .L80106698
/* B7D84C 801066AC 00000000 */ nop
.L801066B0:
/* B7D850 801066B0 44CEF800 */ ctc1 $t6, $31
/* B7D854 801066B4 0002183C */ dsll32 $v1, $v0, 0
/* B7D858 801066B8 0003183F */ dsra32 $v1, $v1, 0
/* B7D85C 801066BC 03E00008 */ jr $ra
/* B7D860 801066C0 0002103F */ dsra32 $v0, $v0, 0
glabel __ll_to_d
/* B7D864 801066C4 AFA40000 */ sw $a0, ($sp)
/* B7D868 801066C8 AFA50004 */ sw $a1, 4($sp)
/* B7D86C 801066CC DFAE0000 */ ld $t6, ($sp)
/* B7D870 801066D0 44AE2000 */ dmtc1 $t6, $f4
/* B7D874 801066D4 03E00008 */ jr $ra
/* B7D878 801066D8 46A02021 */ cvt.d.l $f0, $f4
glabel __ll_to_f
/* B7D87C 801066DC AFA40000 */ sw $a0, ($sp)
/* B7D880 801066E0 AFA50004 */ sw $a1, 4($sp)
/* B7D884 801066E4 DFAE0000 */ ld $t6, ($sp)
/* B7D888 801066E8 44AE2000 */ dmtc1 $t6, $f4
/* B7D88C 801066EC 03E00008 */ jr $ra
/* B7D890 801066F0 46A02020 */ cvt.s.l $f0, $f4
glabel __ull_to_d
/* B7D894 801066F4 AFA40000 */ sw $a0, ($sp)
/* B7D898 801066F8 AFA50004 */ sw $a1, 4($sp)
/* B7D89C 801066FC DFAE0000 */ ld $t6, ($sp)
/* B7D8A0 80106700 44AE2000 */ dmtc1 $t6, $f4
/* B7D8A4 80106704 05C10006 */ bgez $t6, .L80106720
/* B7D8A8 80106708 46A02021 */ cvt.d.l $f0, $f4
/* B7D8AC 8010670C 3C0141F0 */ li $at, 0x41F00000 # 0.000000
/* B7D8B0 80106710 44813800 */ mtc1 $at, $f7
/* B7D8B4 80106714 44803000 */ mtc1 $zero, $f6
/* B7D8B8 80106718 00000000 */ nop
/* B7D8BC 8010671C 46260000 */ add.d $f0, $f0, $f6
.L80106720:
/* B7D8C0 80106720 03E00008 */ jr $ra
/* B7D8C4 80106724 00000000 */ nop
glabel __ull_to_f
/* B7D8C8 80106728 AFA40000 */ sw $a0, ($sp)
/* B7D8CC 8010672C AFA50004 */ sw $a1, 4($sp)
/* B7D8D0 80106730 DFAE0000 */ ld $t6, ($sp)
/* B7D8D4 80106734 44AE2000 */ dmtc1 $t6, $f4
/* B7D8D8 80106738 05C10005 */ bgez $t6, .L80106750
/* B7D8DC 8010673C 46A02020 */ cvt.s.l $f0, $f4
/* B7D8E0 80106740 3C014F80 */ li $at, 0x4F800000 # 0.000000
/* B7D8E4 80106744 44813000 */ mtc1 $at, $f6
/* B7D8E8 80106748 00000000 */ nop
/* B7D8EC 8010674C 46060000 */ add.s $f0, $f0, $f6
.L80106750:
/* B7D8F0 80106750 03E00008 */ jr $ra
/* B7D8F4 80106754 00000000 */ nop

View file

@ -47,7 +47,7 @@ glabel TransitionUnk_InitGraphics
/* B28ABC 800B191C E7A40014 */ swc1 $f4, 0x14($sp)
/* B28AC0 800B1920 E7A00010 */ swc1 $f0, 0x10($sp)
/* B28AC4 800B1924 E7A60018 */ swc1 $f6, 0x18($sp)
/* B28AC8 800B1928 0C041169 */ jal func_801045A4
/* B28AC8 800B1928 0C041169 */ jal guOrtho
/* B28ACC 800B192C E7A8001C */ swc1 $f8, 0x1c($sp)
/* B28AD0 800B1930 0000F825 */ move $ra, $zero
/* B28AD4 800B1934 00009825 */ move $s3, $zero

View file

@ -171,7 +171,7 @@ glabel func_800AB9EC
/* B22DA4 800ABC04 C6060020 */ lwc1 $f6, 0x20($s0)
/* B22DA8 800ABC08 E7A60018 */ swc1 $f6, 0x18($sp)
/* B22DAC 800ABC0C C6080024 */ lwc1 $f8, 0x24($s0)
/* B22DB0 800ABC10 0C041169 */ jal func_801045A4
/* B22DB0 800ABC10 0C041169 */ jal guOrtho
/* B22DB4 800ABC14 E7A8001C */ swc1 $f8, 0x1c($sp)
/* B22DB8 800ABC18 02405825 */ move $t3, $s2
/* B22DBC 800ABC1C 02007025 */ move $t6, $s0

View file

@ -1,16 +0,0 @@
.include "macro.inc"
# assembler directives
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
.set gp=64 # allow use of 64-bit general purpose registers
.section .rodata
.balign 16
glabel D_8014B2E0
.double -0
glabel D_8014B2E8
.double -0

View file

@ -2464,8 +2464,8 @@ u32 osDpGetStatus(void);
void osDpSetStatus(u32 status);
// ? func_801041E0(?);
// ? func_801043B8(?);
// ? func_80104450(?);
void func_801045A4(Mtx*, f32, f32, f32, f32, f32, f32, f32);
void guOrthoF(f32[4][4], f32, f32, f32, f32, f32, f32, f32);
void guOrtho(Mtx*, f32, f32, f32, f32, f32, f32, f32);
f32 cosf(f32);
s16 coss(u16);
void osViSetEvent(OSMesgQueue* mq, OSMesg m, u32 retraceCount);

5
spec
View file

@ -516,7 +516,7 @@ beginseg
include "build/src/libultra_code/osDpGetStatus.o"
include "build/src/libultra_code/osDpSetStatus.o"
include "build/asm/code_801041E0.o"
include "build/asm/code_80104450.o"
include "build/src/libultra_code/ortho.o"
include "build/src/libultra_code/cosf.o"
include "build/src/libultra_code/coss.o"
include "build/src/libultra_code/osViSetEvent.o"
@ -539,8 +539,7 @@ beginseg
include "build/asm/osWritebackDCacheAll.o"
include "build/src/libultra_code/__osGetCurrFaultedThread.o"
include "build/asm/guMtxF2L.o"
include "build/asm/code_80106550.o"
include "build/data/code_80106550.rodata.o"
include "build/src/libultra_code/llcvt.o"
include "build/src/libultra_code/osViGetCurrentFramebuffer.o"
include "build/src/libultra_code/__osSpSetPc.o"
include "build/src/libultra_code/sqrt.o"

View file

@ -32,7 +32,7 @@ void TransitionTriforce_Start(TransitionTriforce* this) {
TransitionTriforce* TransitionTriforce_Init(TransitionTriforce* this) {
bzero(this, sizeof(*this));
func_801045A4(&this->projection, -160.0f, 160.0f, -120.0f, 120.0f, -1000.0f, 1000.0f, 1.0f);
guOrtho(&this->projection, -160.0f, 160.0f, -120.0f, 120.0f, -1000.0f, 1000.0f, 1.0f);
this->transPos = 1.0f;
this->state = 2;
this->step = 0.015f;

View file

@ -400,8 +400,8 @@ s32 func_800AB0A8(View* view) {
LogUtils_CheckNullPointer("projection", projection, "../z_view.c", 744);
view->projectionPtr = projection;
func_801045A4(projection, -(f32)gScreenWidth * 0.5f, (f32)gScreenWidth * 0.5f, -(f32)gScreenHeight * 0.5f,
(f32)gScreenHeight * 0.5f, view->zNear, view->zFar, view->scale);
guOrtho(projection, -(f32)gScreenWidth * 0.5f, (f32)gScreenWidth * 0.5f, -(f32)gScreenHeight * 0.5f,
(f32)gScreenHeight * 0.5f, view->zNear, view->zFar, view->scale);
view->projection = *projection;
@ -438,8 +438,8 @@ s32 func_800AB2C4(View* view) {
LogUtils_CheckNullPointer("projection", projection, "../z_view.c", 791);
view->projectionPtr = projection;
func_801045A4(projection, -(f32)gScreenWidth * 0.5f, (f32)gScreenWidth * 0.5f, -(f32)gScreenHeight * 0.5f,
(f32)gScreenHeight * 0.5f, view->zNear, view->zFar, view->scale);
guOrtho(projection, -(f32)gScreenWidth * 0.5f, (f32)gScreenWidth * 0.5f, -(f32)gScreenHeight * 0.5f,
(f32)gScreenHeight * 0.5f, view->zNear, view->zFar, view->scale);
view->projection = *projection;
@ -551,8 +551,8 @@ s32 func_800AB9EC(View* view, s32 arg1, Gfx** gfxp) {
LogUtils_CheckNullPointer("projection", projection, "../z_view.c", 921);
view->projectionPtr = projection;
func_801045A4(projection, -(f32)gScreenWidth * 0.5f, (f32)gScreenWidth * 0.5f, -(f32)gScreenHeight * 0.5f,
(f32)gScreenHeight * 0.5f, view->zNear, view->zFar, view->scale);
guOrtho(projection, -(f32)gScreenWidth * 0.5f, (f32)gScreenWidth * 0.5f, -(f32)gScreenHeight * 0.5f,
(f32)gScreenHeight * 0.5f, view->zNear, view->zFar, view->scale);
view->projection = *projection;

33
src/libultra_code/llcvt.c Normal file
View file

@ -0,0 +1,33 @@
#include <global.h>
s64 __d_to_ll(f64 d) {
return d;
}
s64 __f_to_ll(f32 f) {
return f;
}
u64 __d_to_ull(f64 d) {
return d;
}
u64 __f_to_ull(f32 f) {
return f;
}
f64 __ll_to_d(s64 l) {
return l;
}
f32 __ll_to_f(s64 l) {
return l;
}
f64 __ull_to_d(u64 l) {
return l;
}
f32 __ull_to_f(u64 l) {
return l;
}

30
src/libultra_code/ortho.c Normal file
View file

@ -0,0 +1,30 @@
#include <ultra64.h>
#include <global.h>
void guOrthoF(f32 mf[4][4], f32 left, f32 right, f32 bottom, f32 top, f32 near, f32 far, f32 scale) {
s32 i, j;
guMtxIdentF(mf);
mf[0][0] = 2 / (right - left);
mf[1][1] = 2 / (top - bottom);
mf[2][2] = -2 / (far - near);
mf[3][0] = -(right + left) / (right - left);
mf[3][1] = -(top + bottom) / (top - bottom);
mf[3][2] = -(far + near) / (far - near);
mf[3][3] = 1;
for (i = 0; i < 4; i++) {
for (j = 0; j < 4; j++) {
mf[i][j] *= scale;
}
}
}
void guOrtho(Mtx* mtx, f32 left, f32 right, f32 bottom, f32 top, f32 near, f32 far, f32 scale) {
MtxF_t mf;
guOrthoF(mf, left, right, bottom, top, near, far, scale);
guMtxF2L(mf, mtx);
}

26
tools/set_o32abi_bit.py Normal file
View file

@ -0,0 +1,26 @@
#!/usr/bin/env python3
import argparse, struct, sys
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('file', help='input file')
args = parser.parse_args()
with open(args.file, 'r+b') as f:
magic = struct.unpack('>I', f.read(4))[0]
if magic != 0x7F454C46:
print('Error: Not an ELF file')
sys.exit(1)
f.seek(36)
flags = struct.unpack('>I', f.read(4))[0]
if flags & 0xF0000000 != 0x20000000: # test for mips3
print('Error: Architecture not mips3')
sys.exit(1)
flags |= 0x00001000 # set EF_MIPS_ABI_O32
f.seek(36)
f.write(struct.pack('>I', flags))