donut-decomp/asm/libMobiclip/ImaAdpcm.s

241 lines
9 KiB
ArmAsm

.include "macros.inc"
.section .text, "ax" # 0x80006A00 - 0x80406260 ; 0x003FF860
.global ImaAdpcmInit
ImaAdpcmInit:
/* 8014EB00 0014A940 38 C0 00 01 */ li r6, 0x1
/* 8014EB04 0014A944 90 C3 00 00 */ stw r6, 0x0(r3)
/* 8014EB08 0014A948 38 00 00 00 */ li r0, 0x0
/* 8014EB0C 0014A94C 38 60 00 00 */ li r3, 0x0
/* 8014EB10 0014A950 90 04 00 00 */ stw r0, 0x0(r4)
/* 8014EB14 0014A954 90 C5 00 00 */ stw r6, 0x0(r5)
/* 8014EB18 0014A958 4E 80 00 20 */ blr
/* 8014EB1C 0014A95C 00 00 00 00 */ .4byte 0x00000000
.global ImaAdpcmSetContext
ImaAdpcmSetContext:
/* 8014EB20 0014A960 88 A4 00 03 */ lbz r5, 0x3(r4)
/* 8014EB24 0014A964 88 04 00 02 */ lbz r0, 0x2(r4)
/* 8014EB28 0014A968 50 A0 44 2E */ rlwimi r0, r5, 8, 16, 23
/* 8014EB2C 0014A96C 88 84 00 00 */ lbz r4, 0x0(r4)
/* 8014EB30 0014A970 7C 00 07 34 */ extsh r0, r0
/* 8014EB34 0014A974 90 83 00 04 */ stw r4, 0x4(r3)
/* 8014EB38 0014A978 90 03 00 00 */ stw r0, 0x0(r3)
/* 8014EB3C 0014A97C 4E 80 00 20 */ blr
.global ImaAdpcmDecode
ImaAdpcmDecode:
/* 8014EB40 0014A980 94 21 FF E0 */ stwu r1, -0x20(r1)
/* 8014EB44 0014A984 3D 00 80 41 */ lis r8, g_Ima_Adpcm_StepTable@ha
/* 8014EB48 0014A988 3C E0 80 41 */ lis r7, g_Ima_Adpcm_IndexTable@ha
/* 8014EB4C 0014A98C 39 20 00 00 */ li r9, 0x0
/* 8014EB50 0014A990 93 E1 00 1C */ stw r31, 0x1c(r1)
/* 8014EB54 0014A994 39 68 E4 50 */ addi r11, r8, g_Ima_Adpcm_StepTable@l
/* 8014EB58 0014A998 39 47 E5 08 */ addi r10, r7, g_Ima_Adpcm_IndexTable@l
/* 8014EB5C 0014A99C 39 00 00 58 */ li r8, 0x58
/* 8014EB60 0014A9A0 93 C1 00 18 */ stw r30, 0x18(r1)
/* 8014EB64 0014A9A4 38 E0 80 00 */ li r7, -0x8000
/* 8014EB68 0014A9A8 38 00 7F FF */ li r0, 0x7fff
/* 8014EB6C 0014A9AC 93 A1 00 14 */ stw r29, 0x14(r1)
/* 8014EB70 0014A9B0 7C A9 03 A6 */ mtctr r5
/* 8014EB74 0014A9B4 2C 05 00 00 */ cmpwi r5, 0x0
/* 8014EB78 0014A9B8 40 81 01 80 */ ble lbl_8014ECF8
.global lbl_8014EB7C
lbl_8014EB7C:
/* 8014EB7C 0014A9BC 89 84 00 00 */ lbz r12, 0x0(r4)
/* 8014EB80 0014A9C0 83 C3 00 04 */ lwz r30, 0x4(r3)
/* 8014EB84 0014A9C4 55 85 07 7E */ clrlwi r5, r12, 29
/* 8014EB88 0014A9C8 7C AA 28 AE */ lbzx r5, r10, r5
/* 8014EB8C 0014A9CC 57 DD 08 3C */ slwi r29, r30, 1
/* 8014EB90 0014A9D0 7F EB EA AE */ lhax r31, r11, r29
/* 8014EB94 0014A9D4 7C A5 07 74 */ extsb r5, r5
/* 8014EB98 0014A9D8 7C BE 2A 15 */ add. r5, r30, r5
/* 8014EB9C 0014A9DC 90 A3 00 04 */ stw r5, 0x4(r3)
/* 8014EBA0 0014A9E0 40 80 00 08 */ bge lbl_8014EBA8
/* 8014EBA4 0014A9E4 91 23 00 04 */ stw r9, 0x4(r3)
.global lbl_8014EBA8
lbl_8014EBA8:
/* 8014EBA8 0014A9E8 80 A3 00 04 */ lwz r5, 0x4(r3)
/* 8014EBAC 0014A9EC 2C 05 00 58 */ cmpwi r5, 0x58
/* 8014EBB0 0014A9F0 40 81 00 08 */ ble lbl_8014EBB8
/* 8014EBB4 0014A9F4 91 03 00 04 */ stw r8, 0x4(r3)
.global lbl_8014EBB8
lbl_8014EBB8:
/* 8014EBB8 0014A9F8 55 85 07 7B */ rlwinm. r5, r12, 0, 29, 29
/* 8014EBBC 0014A9FC 7F FD 1E 70 */ srawi r29, r31, 3
/* 8014EBC0 0014AA00 41 82 00 08 */ beq lbl_8014EBC8
/* 8014EBC4 0014AA04 7F BD FA 14 */ add r29, r29, r31
.global lbl_8014EBC8
lbl_8014EBC8:
/* 8014EBC8 0014AA08 55 85 07 BD */ rlwinm. r5, r12, 0, 30, 30
/* 8014EBCC 0014AA0C 41 82 00 0C */ beq lbl_8014EBD8
/* 8014EBD0 0014AA10 7F E5 0E 70 */ srawi r5, r31, 1
/* 8014EBD4 0014AA14 7F BD 2A 14 */ add r29, r29, r5
.global lbl_8014EBD8
lbl_8014EBD8:
/* 8014EBD8 0014AA18 55 85 07 FF */ clrlwi. r5, r12, 31
/* 8014EBDC 0014AA1C 41 82 00 0C */ beq lbl_8014EBE8
/* 8014EBE0 0014AA20 7F E5 16 70 */ srawi r5, r31, 2
/* 8014EBE4 0014AA24 7F BD 2A 14 */ add r29, r29, r5
.global lbl_8014EBE8
lbl_8014EBE8:
/* 8014EBE8 0014AA28 55 85 07 39 */ rlwinm. r5, r12, 0, 28, 28
/* 8014EBEC 0014AA2C 41 82 00 14 */ beq lbl_8014EC00
/* 8014EBF0 0014AA30 80 A3 00 00 */ lwz r5, 0x0(r3)
/* 8014EBF4 0014AA34 7C BD 28 50 */ subf r5, r29, r5
/* 8014EBF8 0014AA38 90 A3 00 00 */ stw r5, 0x0(r3)
/* 8014EBFC 0014AA3C 48 00 00 10 */ b lbl_8014EC0C
.global lbl_8014EC00
lbl_8014EC00:
/* 8014EC00 0014AA40 80 A3 00 00 */ lwz r5, 0x0(r3)
/* 8014EC04 0014AA44 7C A5 EA 14 */ add r5, r5, r29
/* 8014EC08 0014AA48 90 A3 00 00 */ stw r5, 0x0(r3)
.global lbl_8014EC0C
lbl_8014EC0C:
/* 8014EC0C 0014AA4C 80 A3 00 00 */ lwz r5, 0x0(r3)
/* 8014EC10 0014AA50 2C 05 80 00 */ cmpwi r5, -0x8000
/* 8014EC14 0014AA54 40 80 00 08 */ bge lbl_8014EC1C
/* 8014EC18 0014AA58 90 E3 00 00 */ stw r7, 0x0(r3)
.global lbl_8014EC1C
lbl_8014EC1C:
/* 8014EC1C 0014AA5C 80 A3 00 00 */ lwz r5, 0x0(r3)
/* 8014EC20 0014AA60 2C 05 7F FF */ cmpwi r5, 0x7fff
/* 8014EC24 0014AA64 40 81 00 08 */ ble lbl_8014EC2C
/* 8014EC28 0014AA68 90 03 00 00 */ stw r0, 0x0(r3)
.global lbl_8014EC2C
lbl_8014EC2C:
/* 8014EC2C 0014AA6C 7D 8C 26 70 */ srawi r12, r12, 4
/* 8014EC30 0014AA70 83 A3 00 04 */ lwz r29, 0x4(r3)
/* 8014EC34 0014AA74 55 9F 07 7E */ clrlwi r31, r12, 29
/* 8014EC38 0014AA78 80 A3 00 00 */ lwz r5, 0x0(r3)
/* 8014EC3C 0014AA7C 7F EA F8 AE */ lbzx r31, r10, r31
/* 8014EC40 0014AA80 57 BE 08 3C */ slwi r30, r29, 1
/* 8014EC44 0014AA84 7F CB F2 AE */ lhax r30, r11, r30
/* 8014EC48 0014AA88 7F FF 07 74 */ extsb r31, r31
/* 8014EC4C 0014AA8C 7F FD FA 15 */ add. r31, r29, r31
/* 8014EC50 0014AA90 93 E3 00 04 */ stw r31, 0x4(r3)
/* 8014EC54 0014AA94 40 80 00 08 */ bge lbl_8014EC5C
/* 8014EC58 0014AA98 91 23 00 04 */ stw r9, 0x4(r3)
.global lbl_8014EC5C
lbl_8014EC5C:
/* 8014EC5C 0014AA9C 83 E3 00 04 */ lwz r31, 0x4(r3)
/* 8014EC60 0014AAA0 2C 1F 00 58 */ cmpwi r31, 0x58
/* 8014EC64 0014AAA4 40 81 00 08 */ ble lbl_8014EC6C
/* 8014EC68 0014AAA8 91 03 00 04 */ stw r8, 0x4(r3)
.global lbl_8014EC6C
lbl_8014EC6C:
/* 8014EC6C 0014AAAC 55 9F 07 7B */ rlwinm. r31, r12, 0, 29, 29
/* 8014EC70 0014AAB0 7F DD 1E 70 */ srawi r29, r30, 3
/* 8014EC74 0014AAB4 41 82 00 08 */ beq lbl_8014EC7C
/* 8014EC78 0014AAB8 7F BD F2 14 */ add r29, r29, r30
.global lbl_8014EC7C
lbl_8014EC7C:
/* 8014EC7C 0014AABC 55 9F 07 BD */ rlwinm. r31, r12, 0, 30, 30
/* 8014EC80 0014AAC0 41 82 00 0C */ beq lbl_8014EC8C
/* 8014EC84 0014AAC4 7F DF 0E 70 */ srawi r31, r30, 1
/* 8014EC88 0014AAC8 7F BD FA 14 */ add r29, r29, r31
.global lbl_8014EC8C
lbl_8014EC8C:
/* 8014EC8C 0014AACC 55 9F 07 FF */ clrlwi. r31, r12, 31
/* 8014EC90 0014AAD0 41 82 00 0C */ beq lbl_8014EC9C
/* 8014EC94 0014AAD4 7F DF 16 70 */ srawi r31, r30, 2
/* 8014EC98 0014AAD8 7F BD FA 14 */ add r29, r29, r31
.global lbl_8014EC9C
lbl_8014EC9C:
/* 8014EC9C 0014AADC 55 8C 07 39 */ rlwinm. r12, r12, 0, 28, 28
/* 8014ECA0 0014AAE0 41 82 00 14 */ beq lbl_8014ECB4
/* 8014ECA4 0014AAE4 81 83 00 00 */ lwz r12, 0x0(r3)
/* 8014ECA8 0014AAE8 7D 9D 60 50 */ subf r12, r29, r12
/* 8014ECAC 0014AAEC 91 83 00 00 */ stw r12, 0x0(r3)
/* 8014ECB0 0014AAF0 48 00 00 10 */ b lbl_8014ECC0
.global lbl_8014ECB4
lbl_8014ECB4:
/* 8014ECB4 0014AAF4 81 83 00 00 */ lwz r12, 0x0(r3)
/* 8014ECB8 0014AAF8 7D 8C EA 14 */ add r12, r12, r29
/* 8014ECBC 0014AAFC 91 83 00 00 */ stw r12, 0x0(r3)
.global lbl_8014ECC0
lbl_8014ECC0:
/* 8014ECC0 0014AB00 81 83 00 00 */ lwz r12, 0x0(r3)
/* 8014ECC4 0014AB04 2C 0C 80 00 */ cmpwi r12, -0x8000
/* 8014ECC8 0014AB08 40 80 00 08 */ bge lbl_8014ECD0
/* 8014ECCC 0014AB0C 90 E3 00 00 */ stw r7, 0x0(r3)
.global lbl_8014ECD0
lbl_8014ECD0:
/* 8014ECD0 0014AB10 81 83 00 00 */ lwz r12, 0x0(r3)
/* 8014ECD4 0014AB14 2C 0C 7F FF */ cmpwi r12, 0x7fff
/* 8014ECD8 0014AB18 40 81 00 08 */ ble lbl_8014ECE0
/* 8014ECDC 0014AB1C 90 03 00 00 */ stw r0, 0x0(r3)
.global lbl_8014ECE0
lbl_8014ECE0:
/* 8014ECE0 0014AB20 81 83 00 00 */ lwz r12, 0x0(r3)
/* 8014ECE4 0014AB24 38 84 00 01 */ addi r4, r4, 0x1
/* 8014ECE8 0014AB28 B0 A6 00 00 */ sth r5, 0x0(r6)
/* 8014ECEC 0014AB2C B1 86 00 02 */ sth r12, 0x2(r6)
/* 8014ECF0 0014AB30 38 C6 00 04 */ addi r6, r6, 0x4
/* 8014ECF4 0014AB34 42 00 FE 88 */ bdnz lbl_8014EB7C
.global lbl_8014ECF8
lbl_8014ECF8:
/* 8014ECF8 0014AB38 83 E1 00 1C */ lwz r31, 0x1c(r1)
/* 8014ECFC 0014AB3C 83 C1 00 18 */ lwz r30, 0x18(r1)
/* 8014ED00 0014AB40 83 A1 00 14 */ lwz r29, 0x14(r1)
/* 8014ED04 0014AB44 38 21 00 20 */ addi r1, r1, 0x20
/* 8014ED08 0014AB48 4E 80 00 20 */ blr
/* 8014ED0C 0014AB4C 00 00 00 00 */ .4byte 0x00000000
.include "macros.inc"
.section .rodata, "wa" # 0x80406560 - 0x80421040 ; 0x0001AAE0
.global g_Ima_Adpcm_StepTable
g_Ima_Adpcm_StepTable:
.4byte 0x00070008
.4byte 0x0009000A
.4byte 0x000B000C
.4byte 0x000D000E
.4byte 0x00100011
.4byte 0x00130015
.4byte 0x00170019
.4byte 0x001C001F
.4byte 0x00220025
.4byte 0x0029002D
.4byte 0x00320037
.4byte 0x003C0042
.4byte 0x00490050
.4byte 0x00580061
.4byte 0x006B0076
.4byte 0x0082008F
.4byte 0x009D00AD
.4byte 0x00BE00D1
.4byte 0x00E600FD
.4byte 0x01170133
.4byte 0x01510173
.4byte 0x019801C1
.4byte 0x01EE0220
.4byte 0x02560292
.4byte 0x02D4031C
.4byte 0x036C03C3
.4byte 0x0424048E
.4byte 0x05020583
.4byte 0x061006AB
.4byte 0x07560812
.4byte 0x08E009C3
.4byte 0x0ABD0BD0
.4byte 0x0CFF0E4C
.4byte 0x0FBA114C
.4byte 0x130714EE
.4byte 0x17061954
.4byte 0x1BDC1EA5
.4byte 0x21B62515
.4byte 0x28CA2CDF
.4byte 0x315B364B
.4byte 0x3BB941B2
.4byte 0x48444F7E
.4byte 0x5771602F
.4byte 0x69CE7462
.4byte 0x7FFF0000
.4byte 0
.global g_Ima_Adpcm_IndexTable
g_Ima_Adpcm_IndexTable:
.4byte 0xFFFFFFFF
.4byte 0x02040608
.4byte 0xFFFFFFFF
.4byte 0x02040608