donut-decomp/asm/bte/hidd_pm.s
2022-10-17 09:41:13 +01:00

270 lines
12 KiB
ArmAsm

.include "macros.inc"
.section .text, "ax" # 0x80006A00 - 0x80406260 ; 0x003FF860
.global hidd_pm_set_now
hidd_pm_set_now:
/* 8008D0A4 00088EE4 94 21 FF E0 */ stwu r1, -0x20(r1)
/* 8008D0A8 00088EE8 7C 08 02 A6 */ mflr r0
/* 8008D0AC 00088EEC 3C 80 80 50 */ lis r4, hd_cb@ha
/* 8008D0B0 00088EF0 38 A0 00 00 */ li r5, 0x0
/* 8008D0B4 00088EF4 90 01 00 24 */ stw r0, 0x24(r1)
/* 8008D0B8 00088EF8 38 84 8A D0 */ addi r4, r4, hd_cb@l
/* 8008D0BC 00088EFC 93 E1 00 1C */ stw r31, 0x1c(r1)
/* 8008D0C0 00088F00 88 04 00 6E */ lbz r0, 0x6e(r4)
/* 8008D0C4 00088F04 90 A1 00 0C */ stw r5, 0xc(r1)
/* 8008D0C8 00088F08 2C 00 00 00 */ cmpwi r0, 0x0
/* 8008D0CC 00088F0C 90 A1 00 10 */ stw r5, 0x10(r1)
/* 8008D0D0 00088F10 B0 A1 00 14 */ sth r5, 0x14(r1)
/* 8008D0D4 00088F14 98 A1 00 08 */ stb r5, 0x8(r1)
/* 8008D0D8 00088F18 40 82 00 38 */ bne lbl_8008D110
/* 8008D0DC 00088F1C 88 C4 00 6A */ lbz r6, 0x6a(r4)
/* 8008D0E0 00088F20 88 A3 00 08 */ lbz r5, 0x8(r3)
/* 8008D0E4 00088F24 7C 05 30 40 */ cmplw r5, r6
/* 8008D0E8 00088F28 40 82 00 40 */ bne lbl_8008D128
/* 8008D0EC 00088F2C 2C 05 00 00 */ cmpwi r5, 0x0
/* 8008D0F0 00088F30 41 82 00 20 */ beq lbl_8008D110
/* 8008D0F4 00088F34 A0 84 00 6C */ lhz r4, 0x6c(r4)
/* 8008D0F8 00088F38 A0 03 00 02 */ lhz r0, 0x2(r3)
/* 8008D0FC 00088F3C 7C 04 00 40 */ cmplw r4, r0
/* 8008D100 00088F40 41 80 00 28 */ blt lbl_8008D128
/* 8008D104 00088F44 A0 03 00 00 */ lhz r0, 0x0(r3)
/* 8008D108 00088F48 7C 04 00 40 */ cmplw r4, r0
/* 8008D10C 00088F4C 41 81 00 1C */ bgt lbl_8008D128
.global lbl_8008D110
lbl_8008D110:
/* 8008D110 00088F50 3C 80 80 50 */ lis r4, hd_cb@ha
/* 8008D114 00088F54 38 00 00 FF */ li r0, 0xff
/* 8008D118 00088F58 38 84 8A D0 */ addi r4, r4, hd_cb@l
/* 8008D11C 00088F5C 38 60 00 01 */ li r3, 0x1
/* 8008D120 00088F60 98 04 00 78 */ stb r0, 0x78(r4)
/* 8008D124 00088F64 48 00 01 44 */ b lbl_8008D268
.global lbl_8008D128
lbl_8008D128:
/* 8008D128 00088F68 2C 05 00 02 */ cmpwi r5, 0x2
/* 8008D12C 00088F6C 41 82 00 80 */ beq lbl_8008D1AC
/* 8008D130 00088F70 40 80 00 10 */ bge lbl_8008D140
/* 8008D134 00088F74 2C 05 00 00 */ cmpwi r5, 0x0
/* 8008D138 00088F78 41 82 00 14 */ beq lbl_8008D14C
/* 8008D13C 00088F7C 48 00 00 E4 */ b lbl_8008D220
.global lbl_8008D140
lbl_8008D140:
/* 8008D140 00088F80 2C 05 00 04 */ cmpwi r5, 0x4
/* 8008D144 00088F84 40 80 00 DC */ bge lbl_8008D220
/* 8008D148 00088F88 48 00 00 A0 */ b lbl_8008D1E8
.global lbl_8008D14C
lbl_8008D14C:
/* 8008D14C 00088F8C 28 06 00 02 */ cmplwi r6, 0x2
/* 8008D150 00088F90 40 82 00 2C */ bne lbl_8008D17C
/* 8008D154 00088F94 3F E0 80 50 */ lis r31, hd_cb@ha
/* 8008D158 00088F98 38 A1 00 0C */ addi r5, r1, 0xc
/* 8008D15C 00088F9C 38 9F 8A D0 */ addi r4, r31, hd_cb@l
/* 8008D160 00088FA0 38 60 00 80 */ li r3, 0x80
/* 8008D164 00088FA4 4B FF 66 F5 */ bl BTM_SetPowerMode
/* 8008D168 00088FA8 38 9F 8A D0 */ addi r4, r31, -0x7530
/* 8008D16C 00088FAC 38 00 00 01 */ li r0, 0x1
/* 8008D170 00088FB0 98 61 00 08 */ stb r3, 0x8(r1)
/* 8008D174 00088FB4 98 04 00 6E */ stb r0, 0x6e(r4)
/* 8008D178 00088FB8 48 00 00 A8 */ b lbl_8008D220
.global lbl_8008D17C
lbl_8008D17C:
/* 8008D17C 00088FBC 28 06 00 03 */ cmplwi r6, 0x3
/* 8008D180 00088FC0 40 82 00 A0 */ bne lbl_8008D220
/* 8008D184 00088FC4 3F E0 80 50 */ lis r31, hd_cb@ha
/* 8008D188 00088FC8 38 A1 00 0C */ addi r5, r1, 0xc
/* 8008D18C 00088FCC 38 9F 8A D0 */ addi r4, r31, hd_cb@l
/* 8008D190 00088FD0 38 60 00 80 */ li r3, 0x80
/* 8008D194 00088FD4 4B FF 66 C5 */ bl BTM_SetPowerMode
/* 8008D198 00088FD8 38 9F 8A D0 */ addi r4, r31, -0x7530
/* 8008D19C 00088FDC 38 00 00 01 */ li r0, 0x1
/* 8008D1A0 00088FE0 98 61 00 08 */ stb r3, 0x8(r1)
/* 8008D1A4 00088FE4 98 04 00 6E */ stb r0, 0x6e(r4)
/* 8008D1A8 00088FE8 48 00 00 78 */ b lbl_8008D220
.global lbl_8008D1AC
lbl_8008D1AC:
/* 8008D1AC 00088FEC 2C 06 00 00 */ cmpwi r6, 0x0
/* 8008D1B0 00088FF0 41 82 00 10 */ beq lbl_8008D1C0
/* 8008D1B4 00088FF4 38 61 00 0C */ addi r3, r1, 0xc
/* 8008D1B8 00088FF8 4B FF FE ED */ bl hidd_pm_set_now
/* 8008D1BC 00088FFC 48 00 00 64 */ b lbl_8008D220
.global lbl_8008D1C0
lbl_8008D1C0:
/* 8008D1C0 00089000 3F E0 80 50 */ lis r31, hd_cb@ha
/* 8008D1C4 00089004 7C 65 1B 78 */ mr r5, r3
/* 8008D1C8 00089008 38 9F 8A D0 */ addi r4, r31, hd_cb@l
/* 8008D1CC 0008900C 38 60 00 80 */ li r3, 0x80
/* 8008D1D0 00089010 4B FF 66 89 */ bl BTM_SetPowerMode
/* 8008D1D4 00089014 38 9F 8A D0 */ addi r4, r31, -0x7530
/* 8008D1D8 00089018 38 00 00 01 */ li r0, 0x1
/* 8008D1DC 0008901C 98 61 00 08 */ stb r3, 0x8(r1)
/* 8008D1E0 00089020 98 04 00 6E */ stb r0, 0x6e(r4)
/* 8008D1E4 00089024 48 00 00 3C */ b lbl_8008D220
.global lbl_8008D1E8
lbl_8008D1E8:
/* 8008D1E8 00089028 2C 06 00 00 */ cmpwi r6, 0x0
/* 8008D1EC 0008902C 41 82 00 10 */ beq lbl_8008D1FC
/* 8008D1F0 00089030 38 61 00 0C */ addi r3, r1, 0xc
/* 8008D1F4 00089034 4B FF FE B1 */ bl hidd_pm_set_now
/* 8008D1F8 00089038 48 00 00 28 */ b lbl_8008D220
.global lbl_8008D1FC
lbl_8008D1FC:
/* 8008D1FC 0008903C 3F E0 80 50 */ lis r31, hd_cb@ha
/* 8008D200 00089040 7C 65 1B 78 */ mr r5, r3
/* 8008D204 00089044 38 9F 8A D0 */ addi r4, r31, hd_cb@l
/* 8008D208 00089048 38 60 00 80 */ li r3, 0x80
/* 8008D20C 0008904C 4B FF 66 4D */ bl BTM_SetPowerMode
/* 8008D210 00089050 38 9F 8A D0 */ addi r4, r31, -0x7530
/* 8008D214 00089054 38 00 00 01 */ li r0, 0x1
/* 8008D218 00089058 98 61 00 08 */ stb r3, 0x8(r1)
/* 8008D21C 0008905C 98 04 00 6E */ stb r0, 0x6e(r4)
.global lbl_8008D220
lbl_8008D220:
/* 8008D220 00089060 88 81 00 08 */ lbz r4, 0x8(r1)
/* 8008D224 00089064 28 04 00 01 */ cmplwi r4, 0x1
/* 8008D228 00089068 41 81 00 0C */ bgt lbl_8008D234
/* 8008D22C 0008906C 38 60 00 01 */ li r3, 0x1
/* 8008D230 00089070 48 00 00 38 */ b lbl_8008D268
.global lbl_8008D234
lbl_8008D234:
/* 8008D234 00089074 3C 60 80 50 */ lis r3, hd_cb@ha
/* 8008D238 00089078 38 04 00 37 */ addi r0, r4, 0x37
/* 8008D23C 0008907C 38 63 8A D0 */ addi r3, r3, hd_cb@l
/* 8008D240 00089080 98 01 00 08 */ stb r0, 0x8(r1)
/* 8008D244 00089084 81 83 00 C4 */ lwz r12, 0xc4(r3)
/* 8008D248 00089088 2C 0C 00 00 */ cmpwi r12, 0x0
/* 8008D24C 0008908C 41 82 00 18 */ beq lbl_8008D264
/* 8008D250 00089090 88 83 00 6F */ lbz r4, 0x6f(r3)
/* 8008D254 00089094 38 A1 00 08 */ addi r5, r1, 0x8
/* 8008D258 00089098 38 60 00 04 */ li r3, 0x4
/* 8008D25C 0008909C 7D 89 03 A6 */ mtctr r12
/* 8008D260 000890A0 4E 80 04 21 */ bctrl
.global lbl_8008D264
lbl_8008D264:
/* 8008D264 000890A4 38 60 00 00 */ li r3, 0x0
.global lbl_8008D268
lbl_8008D268:
/* 8008D268 000890A8 80 01 00 24 */ lwz r0, 0x24(r1)
/* 8008D26C 000890AC 83 E1 00 1C */ lwz r31, 0x1c(r1)
/* 8008D270 000890B0 7C 08 03 A6 */ mtlr r0
/* 8008D274 000890B4 38 21 00 20 */ addi r1, r1, 0x20
/* 8008D278 000890B8 4E 80 00 20 */ blr
.global hidd_pm_proc_mode_change
hidd_pm_proc_mode_change:
/* 8008D27C 000890BC 94 21 FF E0 */ stwu r1, -0x20(r1)
/* 8008D280 000890C0 7C 08 02 A6 */ mflr r0
/* 8008D284 000890C4 90 01 00 24 */ stw r0, 0x24(r1)
/* 8008D288 000890C8 93 E1 00 1C */ stw r31, 0x1c(r1)
/* 8008D28C 000890CC 93 C1 00 18 */ stw r30, 0x18(r1)
/* 8008D290 000890D0 3F C0 80 50 */ lis r30, hd_cb@ha
/* 8008D294 000890D4 3B DE 8A D0 */ addi r30, r30, hd_cb@l
/* 8008D298 000890D8 93 A1 00 14 */ stw r29, 0x14(r1)
/* 8008D29C 000890DC 7C 9D 23 78 */ mr r29, r4
/* 8008D2A0 000890E0 88 1E 01 40 */ lbz r0, 0x140(r30)
/* 8008D2A4 000890E4 98 61 00 08 */ stb r3, 0x8(r1)
/* 8008D2A8 000890E8 2C 00 00 00 */ cmpwi r0, 0x0
/* 8008D2AC 000890EC B0 A1 00 0A */ sth r5, 0xa(r1)
/* 8008D2B0 000890F0 41 82 01 08 */ beq lbl_8008D3B8
/* 8008D2B4 000890F4 3B E0 00 00 */ li r31, 0x0
/* 8008D2B8 000890F8 54 60 06 3F */ clrlwi. r0, r3, 24
/* 8008D2BC 000890FC 9B FE 00 6E */ stb r31, 0x6e(r30)
/* 8008D2C0 00089100 41 82 00 28 */ beq lbl_8008D2E8
/* 8008D2C4 00089104 81 9E 00 C4 */ lwz r12, 0xc4(r30)
/* 8008D2C8 00089108 2C 0C 00 00 */ cmpwi r12, 0x0
/* 8008D2CC 0008910C 41 82 00 EC */ beq lbl_8008D3B8
/* 8008D2D0 00089110 38 A1 00 08 */ addi r5, r1, 0x8
/* 8008D2D4 00089114 88 9E 00 6F */ lbz r4, 0x6f(r30)
/* 8008D2D8 00089118 38 60 00 04 */ li r3, 0x4
/* 8008D2DC 0008911C 7D 89 03 A6 */ mtctr r12
/* 8008D2E0 00089120 4E 80 04 21 */ bctrl
/* 8008D2E4 00089124 48 00 00 D4 */ b lbl_8008D3B8
.global lbl_8008D2E8
lbl_8008D2E8:
/* 8008D2E8 00089128 88 1E 00 78 */ lbz r0, 0x78(r30)
/* 8008D2EC 0008912C 54 A3 04 3E */ clrlwi r3, r5, 16
/* 8008D2F0 00089130 98 9E 00 6A */ stb r4, 0x6a(r30)
/* 8008D2F4 00089134 28 00 00 FF */ cmplwi r0, 0xff
/* 8008D2F8 00089138 B0 BE 00 6C */ sth r5, 0x6c(r30)
/* 8008D2FC 0008913C 41 82 00 54 */ beq lbl_8008D350
/* 8008D300 00089140 7C 00 20 40 */ cmplw r0, r4
/* 8008D304 00089144 40 82 00 24 */ bne lbl_8008D328
/* 8008D308 00089148 2C 00 00 00 */ cmpwi r0, 0x0
/* 8008D30C 0008914C 41 82 00 30 */ beq lbl_8008D33C
/* 8008D310 00089150 A0 1E 00 72 */ lhz r0, 0x72(r30)
/* 8008D314 00089154 7C 03 00 40 */ cmplw r3, r0
/* 8008D318 00089158 41 80 00 10 */ blt lbl_8008D328
/* 8008D31C 0008915C A0 1E 00 70 */ lhz r0, 0x70(r30)
/* 8008D320 00089160 7C 03 00 40 */ cmplw r3, r0
/* 8008D324 00089164 40 81 00 18 */ ble lbl_8008D33C
.global lbl_8008D328
lbl_8008D328:
/* 8008D328 00089168 3C 60 80 50 */ lis r3, hd_cb@ha
/* 8008D32C 0008916C 38 63 8A D0 */ addi r3, r3, hd_cb@l
/* 8008D330 00089170 38 63 00 70 */ addi r3, r3, 0x70
/* 8008D334 00089174 4B FF FD 71 */ bl hidd_pm_set_now
/* 8008D338 00089178 48 00 00 58 */ b lbl_8008D390
.global lbl_8008D33C
lbl_8008D33C:
/* 8008D33C 0008917C 3C 60 80 50 */ lis r3, hd_cb@ha
/* 8008D340 00089180 38 00 00 FF */ li r0, 0xff
/* 8008D344 00089184 38 63 8A D0 */ addi r3, r3, hd_cb@l
/* 8008D348 00089188 98 03 00 78 */ stb r0, 0x78(r3)
/* 8008D34C 0008918C 48 00 00 44 */ b lbl_8008D390
.global lbl_8008D350
lbl_8008D350:
/* 8008D350 00089190 2C 04 00 00 */ cmpwi r4, 0x0
/* 8008D354 00089194 40 82 00 3C */ bne lbl_8008D390
/* 8008D358 00089198 38 7E 00 70 */ addi r3, r30, 0x70
/* 8008D35C 0008919C 38 9E 00 4C */ addi r4, r30, 0x4c
/* 8008D360 000891A0 38 A0 00 0A */ li r5, 0xa
/* 8008D364 000891A4 4B F7 6C 9D */ bl memcpy
/* 8008D368 000891A8 38 7E 00 4C */ addi r3, r30, 0x4c
/* 8008D36C 000891AC 4B FF FD 39 */ bl hidd_pm_set_now
/* 8008D370 000891B0 3C 60 80 09 */ lis r3, hidd_pm_inact_timeout@ha
/* 8008D374 000891B4 9B FE 00 6F */ stb r31, 0x6f(r30)
/* 8008D378 000891B8 38 63 D3 D4 */ addi r3, r3, hidd_pm_inact_timeout@l
/* 8008D37C 000891BC 38 80 00 16 */ li r4, 0x16
/* 8008D380 000891C0 90 7E 00 44 */ stw r3, 0x44(r30)
/* 8008D384 000891C4 38 7E 00 34 */ addi r3, r30, 0x34
/* 8008D388 000891C8 38 A0 00 3C */ li r5, 0x3c
/* 8008D38C 000891CC 4B FE AB 25 */ bl btu_start_timer
.global lbl_8008D390
lbl_8008D390:
/* 8008D390 000891D0 3C 60 80 50 */ lis r3, hd_cb@ha
/* 8008D394 000891D4 38 63 8A D0 */ addi r3, r3, hd_cb@l
/* 8008D398 000891D8 81 83 00 C4 */ lwz r12, 0xc4(r3)
/* 8008D39C 000891DC 2C 0C 00 00 */ cmpwi r12, 0x0
/* 8008D3A0 000891E0 41 82 00 18 */ beq lbl_8008D3B8
/* 8008D3A4 000891E4 7F A4 EB 78 */ mr r4, r29
/* 8008D3A8 000891E8 38 A1 00 0A */ addi r5, r1, 0xa
/* 8008D3AC 000891EC 38 60 00 03 */ li r3, 0x3
/* 8008D3B0 000891F0 7D 89 03 A6 */ mtctr r12
/* 8008D3B4 000891F4 4E 80 04 21 */ bctrl
.global lbl_8008D3B8
lbl_8008D3B8:
/* 8008D3B8 000891F8 80 01 00 24 */ lwz r0, 0x24(r1)
/* 8008D3BC 000891FC 83 E1 00 1C */ lwz r31, 0x1c(r1)
/* 8008D3C0 00089200 83 C1 00 18 */ lwz r30, 0x18(r1)
/* 8008D3C4 00089204 83 A1 00 14 */ lwz r29, 0x14(r1)
/* 8008D3C8 00089208 7C 08 03 A6 */ mtlr r0
/* 8008D3CC 0008920C 38 21 00 20 */ addi r1, r1, 0x20
/* 8008D3D0 00089210 4E 80 00 20 */ blr
.global hidd_pm_inact_timeout
hidd_pm_inact_timeout:
/* 8008D3D4 00089214 94 21 FF F0 */ stwu r1, -0x10(r1)
/* 8008D3D8 00089218 7C 08 02 A6 */ mflr r0
/* 8008D3DC 0008921C 38 A0 00 0A */ li r5, 0xa
/* 8008D3E0 00089220 90 01 00 14 */ stw r0, 0x14(r1)
/* 8008D3E4 00089224 93 E1 00 0C */ stw r31, 0xc(r1)
/* 8008D3E8 00089228 3F E0 80 50 */ lis r31, hd_cb@ha
/* 8008D3EC 0008922C 3B FF 8A D0 */ addi r31, r31, hd_cb@l
/* 8008D3F0 00089230 38 7F 00 70 */ addi r3, r31, 0x70
/* 8008D3F4 00089234 38 9F 00 56 */ addi r4, r31, 0x56
/* 8008D3F8 00089238 4B F7 6C 09 */ bl memcpy
/* 8008D3FC 0008923C 38 7F 00 56 */ addi r3, r31, 0x56
/* 8008D400 00089240 4B FF FC A5 */ bl hidd_pm_set_now
/* 8008D404 00089244 38 00 00 01 */ li r0, 0x1
/* 8008D408 00089248 98 1F 00 6F */ stb r0, 0x6f(r31)
/* 8008D40C 0008924C 83 E1 00 0C */ lwz r31, 0xc(r1)
/* 8008D410 00089250 80 01 00 14 */ lwz r0, 0x14(r1)
/* 8008D414 00089254 7C 08 03 A6 */ mtlr r0
/* 8008D418 00089258 38 21 00 10 */ addi r1, r1, 0x10
/* 8008D41C 0008925C 4E 80 00 20 */ blr