1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2024-12-01 15:26:01 +00:00
oot/asm/code_801014A0.s
silv3rwing07 5aef81071e
padmgr and related (#71)
* In process of moving changes over from old repo

* Merged in changes

* Finished import of padmgr changes from old repo

* Adjusted some volatile

* Improving padmgr volatile situation

* Almost matched osReadMempak

* Working on osMempakDataCRC

* Explanations and equivalents but no matches for osMempakAddrCRC and osMempakDataCRC

* OK after merge

* Matched osMempakAddrCRC and osMempakDataCRC

* Matched osReadMempak

* Updated PadMgr function names to be less like original code

* Changed variable names to make them further from original code

* Changed names and it stopped matching

* Undid clang-format steamrollering whitespace memes

* Cleaned up Input names

* More formatting changes

* Moved padmgr to z64.h, deleted padmgr.h
2020-04-14 13:17:25 -04:00

340 lines
15 KiB
ArmAsm

.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 purposee registers
.section .text
.align 4
glabel osSpTaskYield
/* B78640 801014A0 27BDFFE8 */ addiu $sp, $sp, -0x18
/* B78644 801014A4 AFBF0014 */ sw $ra, 0x14($sp)
/* B78648 801014A8 0C041920 */ jal __osSpSetStatus
/* B7864C 801014AC 24040400 */ li $a0, 1024
/* B78650 801014B0 8FBF0014 */ lw $ra, 0x14($sp)
/* B78654 801014B4 27BD0018 */ addiu $sp, $sp, 0x18
/* B78658 801014B8 03E00008 */ jr $ra
/* B7865C 801014BC 00000000 */ nop
glabel func_801014C0
/* B78660 801014C0 27BDFFE0 */ addiu $sp, $sp, -0x20
/* B78664 801014C4 AFBF001C */ sw $ra, 0x1c($sp)
/* B78668 801014C8 AFB00018 */ sw $s0, 0x18($sp)
/* B7866C 801014CC AFA50024 */ sw $a1, 0x24($sp)
/* B78670 801014D0 AFA60028 */ sw $a2, 0x28($sp)
/* B78674 801014D4 90AF0000 */ lbu $t7, ($a1)
/* B78678 801014D8 90E20000 */ lbu $v0, ($a3)
/* B7867C 801014DC 00E08025 */ move $s0, $a3
/* B78680 801014E0 00A07025 */ move $t6, $a1
/* B78684 801014E4 104F000A */ beq $v0, $t7, .L80101510
/* B78688 801014E8 00003025 */ move $a2, $zero
/* B7868C 801014EC A0A20000 */ sb $v0, ($a1)
/* B78690 801014F0 91C70000 */ lbu $a3, ($t6)
/* B78694 801014F4 AFA40020 */ sw $a0, 0x20($sp)
/* B78698 801014F8 0C040B31 */ jal func_80102CC4
/* B7869C 801014FC 8FA50028 */ lw $a1, 0x28($sp)
/* B786A0 80101500 10400003 */ beqz $v0, .L80101510
/* B786A4 80101504 8FA40020 */ lw $a0, 0x20($sp)
/* B786A8 80101508 1000001E */ b .L80101584
/* B786AC 8010150C 8FBF001C */ lw $ra, 0x1c($sp)
.L80101510:
/* B786B0 80101510 92190001 */ lbu $t9, 1($s0)
/* B786B4 80101514 8FB80028 */ lw $t8, 0x28($sp)
/* B786B8 80101518 00194040 */ sll $t0, $t9, 1
/* B786BC 8010151C 03084821 */ addu $t1, $t8, $t0
/* B786C0 80101520 95210000 */ lhu $at, ($t1)
/* B786C4 80101524 A6010000 */ sh $at, ($s0)
/* B786C8 80101528 8C8C0060 */ lw $t4, 0x60($a0)
/* B786CC 8010152C 3023FFFF */ andi $v1, $at, 0xffff
/* B786D0 80101530 006C082A */ slt $at, $v1, $t4
/* B786D4 80101534 5420000C */ bnezl $at, .L80101568
/* B786D8 80101538 24010001 */ li $at, 1
/* B786DC 8010153C 920D0000 */ lbu $t5, ($s0)
/* B786E0 80101540 908F0064 */ lbu $t7, 0x64($a0)
/* B786E4 80101544 01AF082A */ slt $at, $t5, $t7
/* B786E8 80101548 50200007 */ beql $at, $zero, .L80101568
/* B786EC 8010154C 24010001 */ li $at, 1
/* B786F0 80101550 92020001 */ lbu $v0, 1($s0)
/* B786F4 80101554 18400003 */ blez $v0, .L80101564
/* B786F8 80101558 28410080 */ slti $at, $v0, 0x80
/* B786FC 8010155C 14200008 */ bnez $at, .L80101580
/* B78700 80101560 00001025 */ move $v0, $zero
.L80101564:
/* B78704 80101564 24010001 */ li $at, 1
.L80101568:
/* B78708 80101568 14610003 */ bne $v1, $at, .L80101578
/* B7870C 8010156C 00000000 */ nop
/* B78710 80101570 10000003 */ b .L80101580
/* B78714 80101574 24020005 */ li $v0, 5
.L80101578:
/* B78718 80101578 10000001 */ b .L80101580
/* B7871C 8010157C 24020003 */ li $v0, 3
.L80101580:
/* B78720 80101580 8FBF001C */ lw $ra, 0x1c($sp)
.L80101584:
/* B78724 80101584 8FB00018 */ lw $s0, 0x18($sp)
/* B78728 80101588 27BD0020 */ addiu $sp, $sp, 0x20
/* B7872C 8010158C 03E00008 */ jr $ra
/* B78730 80101590 00000000 */ nop
glabel func_80101594
/* B78734 80101594 27BDFE90 */ addiu $sp, $sp, -0x170
/* B78738 80101598 AFBF002C */ sw $ra, 0x2c($sp)
/* B7873C 8010159C AFB30028 */ sw $s3, 0x28($sp)
/* B78740 801015A0 AFB20024 */ sw $s2, 0x24($sp)
/* B78744 801015A4 AFB10020 */ sw $s1, 0x20($sp)
/* B78748 801015A8 AFB0001C */ sw $s0, 0x1c($sp)
/* B7874C 801015AC AFA60178 */ sw $a2, 0x178($sp)
/* B78750 801015B0 8C8E0050 */ lw $t6, 0x50($a0)
/* B78754 801015B4 30D000FF */ andi $s0, $a2, 0xff
/* B78758 801015B8 00E08825 */ move $s1, $a3
/* B7875C 801015BC 00AE082A */ slt $at, $a1, $t6
/* B78760 801015C0 10200003 */ beqz $at, .L801015D0
/* B78764 801015C4 00809025 */ move $s2, $a0
/* B78768 801015C8 04A10003 */ bgez $a1, .L801015D8
/* B7876C 801015CC 8FA20180 */ lw $v0, 0x180($sp)
.L801015D0:
/* B78770 801015D0 100000C7 */ b .L801018F0
/* B78774 801015D4 24020005 */ li $v0, 5
.L801015D8:
/* B78778 801015D8 18400003 */ blez $v0, .L801015E8
/* B7877C 801015DC 304F001F */ andi $t7, $v0, 0x1f
/* B78780 801015E0 11E00003 */ beqz $t7, .L801015F0
/* B78784 801015E4 00000000 */ nop
.L801015E8:
/* B78788 801015E8 100000C1 */ b .L801018F0
/* B7878C 801015EC 24020005 */ li $v0, 5
.L801015F0:
/* B78790 801015F0 06200003 */ bltz $s1, .L80101600
/* B78794 801015F4 3238001F */ andi $t8, $s1, 0x1f
/* B78798 801015F8 53000004 */ beql $t8, $zero, .L8010160C
/* B7879C 801015FC 8E590000 */ lw $t9, ($s2)
.L80101600:
/* B787A0 80101600 100000BB */ b .L801018F0
/* B787A4 80101604 24020005 */ li $v0, 5
/* B787A8 80101608 8E590000 */ lw $t9, ($s2)
.L8010160C:
/* B787AC 8010160C 02402025 */ move $a0, $s2
/* B787B0 80101610 33280001 */ andi $t0, $t9, 1
/* B787B4 80101614 15000003 */ bnez $t0, .L80101624
/* B787B8 80101618 00000000 */ nop
/* B787BC 8010161C 100000B4 */ b .L801018F0
/* B787C0 80101620 24020005 */ li $v0, 5
.L80101624:
/* B787C4 80101624 0C040AFC */ jal func_80102BF0
/* B787C8 80101628 AFA50174 */ sw $a1, 0x174($sp)
/* B787CC 8010162C 24010002 */ li $at, 2
/* B787D0 80101630 54410004 */ bnel $v0, $at, .L80101644
/* B787D4 80101634 92490065 */ lbu $t1, 0x65($s2)
/* B787D8 80101638 100000AD */ b .L801018F0
/* B787DC 8010163C 24020002 */ li $v0, 2
/* B787E0 80101640 92490065 */ lbu $t1, 0x65($s2)
.L80101644:
/* B787E4 80101644 02402025 */ move $a0, $s2
/* B787E8 80101648 51200008 */ beql $t1, $zero, .L8010166C
/* B787EC 8010164C 8E4A005C */ lw $t2, 0x5c($s2)
/* B787F0 80101650 0C041320 */ jal func_80104C80
/* B787F4 80101654 00002825 */ move $a1, $zero
/* B787F8 80101658 50400004 */ beql $v0, $zero, .L8010166C
/* B787FC 8010165C 8E4A005C */ lw $t2, 0x5c($s2)
/* B78800 80101660 100000A4 */ b .L801018F4
/* B78804 80101664 8FBF002C */ lw $ra, 0x2c($sp)
/* B78808 80101668 8E4A005C */ lw $t2, 0x5c($s2)
.L8010166C:
/* B7880C 8010166C 8FAB0174 */ lw $t3, 0x174($sp)
/* B78810 80101670 8E440004 */ lw $a0, 4($s2)
/* B78814 80101674 8E450008 */ lw $a1, 8($s2)
/* B78818 80101678 014B3021 */ addu $a2, $t2, $t3
/* B7881C 8010167C 30CCFFFF */ andi $t4, $a2, 0xffff
/* B78820 80101680 01803025 */ move $a2, $t4
/* B78824 80101684 0C0417D0 */ jal osReadMempak
/* B78828 80101688 27A7014C */ addiu $a3, $sp, 0x14c
/* B7882C 8010168C 10400003 */ beqz $v0, .L8010169C
/* B78830 80101690 97AD0150 */ lhu $t5, 0x150($sp)
/* B78834 80101694 10000097 */ b .L801018F4
/* B78838 80101698 8FBF002C */ lw $ra, 0x2c($sp)
.L8010169C:
/* B7883C 8010169C 11A00003 */ beqz $t5, .L801016AC
/* B78840 801016A0 8FAE014C */ lw $t6, 0x14c($sp)
/* B78844 801016A4 15C00003 */ bnez $t6, .L801016B4
/* B78848 801016A8 97AF0152 */ lhu $t7, 0x152($sp)
.L801016AC:
/* B7884C 801016AC 10000090 */ b .L801018F0
/* B78850 801016B0 24020005 */ li $v0, 5
.L801016B4:
/* B78854 801016B4 8E580060 */ lw $t8, 0x60($s2)
/* B78858 801016B8 93B90152 */ lbu $t9, 0x152($sp)
/* B7885C 801016BC 97AA0152 */ lhu $t2, 0x152($sp)
/* B78860 801016C0 01F8082A */ slt $at, $t7, $t8
/* B78864 801016C4 5420000A */ bnezl $at, .L801016F0
/* B78868 801016C8 24010001 */ li $at, 1
/* B7886C 801016CC 92480064 */ lbu $t0, 0x64($s2)
/* B78870 801016D0 93A90153 */ lbu $t1, 0x153($sp)
/* B78874 801016D4 0328082A */ slt $at, $t9, $t0
/* B78878 801016D8 50200005 */ beql $at, $zero, .L801016F0
/* B7887C 801016DC 24010001 */ li $at, 1
/* B78880 801016E0 19200002 */ blez $t1, .L801016EC
/* B78884 801016E4 29210080 */ slti $at, $t1, 0x80
/* B78888 801016E8 14200007 */ bnez $at, .L80101708
.L801016EC:
/* B7888C 801016EC 24010001 */ li $at, 1
.L801016F0:
/* B78890 801016F0 15410003 */ bne $t2, $at, .L80101700
/* B78894 801016F4 00000000 */ nop
/* B78898 801016F8 1000007D */ b .L801018F0
/* B7889C 801016FC 24020005 */ li $v0, 5
.L80101700:
/* B788A0 80101700 1000007B */ b .L801018F0
/* B788A4 80101704 24020003 */ li $v0, 3
.L80101708:
/* B788A8 80101708 16000007 */ bnez $s0, .L80101728
/* B788AC 8010170C AFB00034 */ sw $s0, 0x34($sp)
/* B788B0 80101710 93AC0154 */ lbu $t4, 0x154($sp)
/* B788B4 80101714 318D0002 */ andi $t5, $t4, 2
/* B788B8 80101718 55A00004 */ bnezl $t5, .L8010172C
/* B788BC 8010171C 97AF0152 */ lhu $t7, 0x152($sp)
/* B788C0 80101720 10000073 */ b .L801018F0
/* B788C4 80101724 24020006 */ li $v0, 6
.L80101728:
/* B788C8 80101728 97AF0152 */ lhu $t7, 0x152($sp)
.L8010172C:
/* B788CC 8010172C 240E00FF */ li $t6, 255
/* B788D0 80101730 A3AE003B */ sb $t6, 0x3b($sp)
/* B788D4 80101734 06210003 */ bgez $s1, .L80101744
/* B788D8 80101738 00111143 */ sra $v0, $s1, 5
/* B788DC 8010173C 2621001F */ addiu $at, $s1, 0x1f
/* B788E0 80101740 00011143 */ sra $v0, $at, 5
.L80101744:
/* B788E4 80101744 28410008 */ slti $at, $v0, 8
/* B788E8 80101748 00408025 */ move $s0, $v0
/* B788EC 8010174C 1420000D */ bnez $at, .L80101784
/* B788F0 80101750 A7AF0048 */ sh $t7, 0x48($sp)
/* B788F4 80101754 02402025 */ move $a0, $s2
.L80101758:
/* B788F8 80101758 27A5003B */ addiu $a1, $sp, 0x3b
/* B788FC 8010175C 27A6004C */ addiu $a2, $sp, 0x4c
/* B78900 80101760 0C040530 */ jal func_801014C0
/* B78904 80101764 27A70048 */ addiu $a3, $sp, 0x48
/* B78908 80101768 10400003 */ beqz $v0, .L80101778
/* B7890C 8010176C 2610FFF8 */ addiu $s0, $s0, -8
/* B78910 80101770 10000060 */ b .L801018F4
/* B78914 80101774 8FBF002C */ lw $ra, 0x2c($sp)
.L80101778:
/* B78918 80101778 2A010008 */ slti $at, $s0, 8
/* B7891C 8010177C 5020FFF6 */ beql $at, $zero, .L80101758
/* B78920 80101780 02402025 */ move $a0, $s2
.L80101784:
/* B78924 80101784 8FA20180 */ lw $v0, 0x180($sp)
/* B78928 80101788 8FB10184 */ lw $s1, 0x184($sp)
/* B7892C 8010178C 04410003 */ bgez $v0, .L8010179C
/* B78930 80101790 0002C143 */ sra $t8, $v0, 5
/* B78934 80101794 2441001F */ addiu $at, $v0, 0x1f
/* B78938 80101798 0001C143 */ sra $t8, $at, 5
.L8010179C:
/* B7893C 8010179C 1B000031 */ blez $t8, .L80101864
/* B78940 801017A0 03009825 */ move $s3, $t8
.L801017A4:
/* B78944 801017A4 24010008 */ li $at, 8
/* B78948 801017A8 16010009 */ bne $s0, $at, .L801017D0
/* B7894C 801017AC 02402025 */ move $a0, $s2
/* B78950 801017B0 27A5003B */ addiu $a1, $sp, 0x3b
/* B78954 801017B4 27A6004C */ addiu $a2, $sp, 0x4c
/* B78958 801017B8 0C040530 */ jal func_801014C0
/* B7895C 801017BC 27A70048 */ addiu $a3, $sp, 0x48
/* B78960 801017C0 10400003 */ beqz $v0, .L801017D0
/* B78964 801017C4 00008025 */ move $s0, $zero
/* B78968 801017C8 1000004A */ b .L801018F4
/* B7896C 801017CC 8FBF002C */ lw $ra, 0x2c($sp)
.L801017D0:
/* B78970 801017D0 93B90048 */ lbu $t9, 0x48($sp)
/* B78974 801017D4 92480065 */ lbu $t0, 0x65($s2)
/* B78978 801017D8 02402025 */ move $a0, $s2
/* B7897C 801017DC 53280008 */ beql $t9, $t0, .L80101800
/* B78980 801017E0 93A90049 */ lbu $t1, 0x49($sp)
/* B78984 801017E4 0C041320 */ jal func_80104C80
/* B78988 801017E8 03202825 */ move $a1, $t9
/* B7898C 801017EC 50400004 */ beql $v0, $zero, .L80101800
/* B78990 801017F0 93A90049 */ lbu $t1, 0x49($sp)
/* B78994 801017F4 1000003F */ b .L801018F4
/* B78998 801017F8 8FBF002C */ lw $ra, 0x2c($sp)
/* B7899C 801017FC 93A90049 */ lbu $t1, 0x49($sp)
.L80101800:
/* B789A0 80101800 8FAC0034 */ lw $t4, 0x34($sp)
/* B789A4 80101804 02203825 */ move $a3, $s1
/* B789A8 80101808 000950C0 */ sll $t2, $t1, 3
/* B789AC 8010180C 01503021 */ addu $a2, $t2, $s0
/* B789B0 80101810 30CBFFFF */ andi $t3, $a2, 0xffff
/* B789B4 80101814 15800007 */ bnez $t4, .L80101834
/* B789B8 80101818 01603025 */ move $a2, $t3
/* B789BC 8010181C 8E440004 */ lw $a0, 4($s2)
/* B789C0 80101820 8E450008 */ lw $a1, 8($s2)
/* B789C4 80101824 0C0417D0 */ jal osReadMempak
/* B789C8 80101828 02203825 */ move $a3, $s1
/* B789CC 8010182C 10000006 */ b .L80101848
/* B789D0 80101830 00401825 */ move $v1, $v0
.L80101834:
/* B789D4 80101834 8E440004 */ lw $a0, 4($s2)
/* B789D8 80101838 8E450008 */ lw $a1, 8($s2)
/* B789DC 8010183C 0C04173C */ jal func_80105CF0
/* B789E0 80101840 AFA00010 */ sw $zero, 0x10($sp)
/* B789E4 80101844 00401825 */ move $v1, $v0
.L80101848:
/* B789E8 80101848 10400003 */ beqz $v0, .L80101858
/* B789EC 8010184C 26310020 */ addiu $s1, $s1, 0x20
/* B789F0 80101850 10000027 */ b .L801018F0
/* B789F4 80101854 00601025 */ move $v0, $v1
.L80101858:
/* B789F8 80101858 2673FFFF */ addiu $s3, $s3, -1
/* B789FC 8010185C 1660FFD1 */ bnez $s3, .L801017A4
/* B78A00 80101860 26100001 */ addiu $s0, $s0, 1
.L80101864:
/* B78A04 80101864 8FAD0034 */ lw $t5, 0x34($sp)
/* B78A08 80101868 93A20154 */ lbu $v0, 0x154($sp)
/* B78A0C 8010186C 24010001 */ li $at, 1
/* B78A10 80101870 15A1001C */ bne $t5, $at, .L801018E4
/* B78A14 80101874 304E0002 */ andi $t6, $v0, 2
/* B78A18 80101878 15C0001A */ bnez $t6, .L801018E4
/* B78A1C 8010187C 344F0002 */ ori $t7, $v0, 2
/* B78A20 80101880 A3AF0154 */ sb $t7, 0x154($sp)
/* B78A24 80101884 92580065 */ lbu $t8, 0x65($s2)
/* B78A28 80101888 02402025 */ move $a0, $s2
/* B78A2C 8010188C 53000008 */ beql $t8, $zero, .L801018B0
/* B78A30 80101890 8E48005C */ lw $t0, 0x5c($s2)
/* B78A34 80101894 0C041320 */ jal func_80104C80
/* B78A38 80101898 00002825 */ move $a1, $zero
/* B78A3C 8010189C 50400004 */ beql $v0, $zero, .L801018B0
/* B78A40 801018A0 8E48005C */ lw $t0, 0x5c($s2)
/* B78A44 801018A4 10000013 */ b .L801018F4
/* B78A48 801018A8 8FBF002C */ lw $ra, 0x2c($sp)
/* B78A4C 801018AC 8E48005C */ lw $t0, 0x5c($s2)
.L801018B0:
/* B78A50 801018B0 8FB90174 */ lw $t9, 0x174($sp)
/* B78A54 801018B4 8E440004 */ lw $a0, 4($s2)
/* B78A58 801018B8 8E450008 */ lw $a1, 8($s2)
/* B78A5C 801018BC 01193021 */ addu $a2, $t0, $t9
/* B78A60 801018C0 30C9FFFF */ andi $t1, $a2, 0xffff
/* B78A64 801018C4 01203025 */ move $a2, $t1
/* B78A68 801018C8 AFA00010 */ sw $zero, 0x10($sp)
/* B78A6C 801018CC 0C04173C */ jal func_80105CF0
/* B78A70 801018D0 27A7014C */ addiu $a3, $sp, 0x14c
/* B78A74 801018D4 50400004 */ beql $v0, $zero, .L801018E8
/* B78A78 801018D8 8E440004 */ lw $a0, 4($s2)
/* B78A7C 801018DC 10000005 */ b .L801018F4
/* B78A80 801018E0 8FBF002C */ lw $ra, 0x2c($sp)
.L801018E4:
/* B78A84 801018E4 8E440004 */ lw $a0, 4($s2)
.L801018E8:
/* B78A88 801018E8 0C040644 */ jal func_80101910
/* B78A8C 801018EC 8E450008 */ lw $a1, 8($s2)
.L801018F0:
/* B78A90 801018F0 8FBF002C */ lw $ra, 0x2c($sp)
.L801018F4:
/* B78A94 801018F4 8FB0001C */ lw $s0, 0x1c($sp)
/* B78A98 801018F8 8FB10020 */ lw $s1, 0x20($sp)
/* B78A9C 801018FC 8FB20024 */ lw $s2, 0x24($sp)
/* B78AA0 80101900 8FB30028 */ lw $s3, 0x28($sp)
/* B78AA4 80101904 03E00008 */ jr $ra
/* B78AA8 80101908 27BD0170 */ addiu $sp, $sp, 0x170