donut-decomp/asm/MSL_C.PPCEABI.bare.H/MSL_Common/Src/direct_io.s

245 lines
11 KiB
ArmAsm

.include "macros.inc"
.section .text, "ax" # 0x80006A00 - 0x80406260 ; 0x003FF860
.global __fwrite
__fwrite:
/* 8000A3EC 0000622C 94 21 FF D0 */ stwu r1, -0x30(r1)
/* 8000A3F0 00006230 7C 08 02 A6 */ mflr r0
/* 8000A3F4 00006234 90 01 00 34 */ stw r0, 0x34(r1)
/* 8000A3F8 00006238 BF 21 00 14 */ stmw r25, 0x14(r1)
/* 8000A3FC 0000623C 7C 9B 23 78 */ mr r27, r4
/* 8000A400 00006240 7C DC 33 78 */ mr r28, r6
/* 8000A404 00006244 7C 7A 1B 78 */ mr r26, r3
/* 8000A408 00006248 7C B9 2B 78 */ mr r25, r5
/* 8000A40C 0000624C 38 80 00 00 */ li r4, 0x0
/* 8000A410 00006250 7F 83 E3 78 */ mr r3, r28
/* 8000A414 00006254 48 00 5F C9 */ bl fwide
/* 8000A418 00006258 2C 03 00 00 */ cmpwi r3, 0x0
/* 8000A41C 0000625C 40 82 00 10 */ bne lbl_8000A42C
/* 8000A420 00006260 7F 83 E3 78 */ mr r3, r28
/* 8000A424 00006264 38 80 FF FF */ li r4, -0x1
/* 8000A428 00006268 48 00 5F B5 */ bl fwide
.global lbl_8000A42C
lbl_8000A42C:
/* 8000A42C 0000626C 7F DB C9 D7 */ mullw. r30, r27, r25
/* 8000A430 00006270 41 82 00 1C */ beq lbl_8000A44C
/* 8000A434 00006274 88 1C 00 0A */ lbz r0, 0xa(r28)
/* 8000A438 00006278 2C 00 00 00 */ cmpwi r0, 0x0
/* 8000A43C 0000627C 40 82 00 10 */ bne lbl_8000A44C
/* 8000A440 00006280 80 1C 00 04 */ lwz r0, 0x4(r28)
/* 8000A444 00006284 54 00 57 7F */ extrwi. r0, r0, 3, 7
/* 8000A448 00006288 40 82 00 0C */ bne lbl_8000A454
.global lbl_8000A44C
lbl_8000A44C:
/* 8000A44C 0000628C 38 60 00 00 */ li r3, 0x0
/* 8000A450 00006290 48 00 02 90 */ b lbl_8000A6E0
.global lbl_8000A454
lbl_8000A454:
/* 8000A454 00006294 28 00 00 02 */ cmplwi r0, 0x2
/* 8000A458 00006298 40 82 00 08 */ bne lbl_8000A460
/* 8000A45C 0000629C 48 00 0E 25 */ bl __stdio_atexit
.global lbl_8000A460
lbl_8000A460:
/* 8000A460 000062A0 80 7C 00 04 */ lwz r3, 0x4(r28)
/* 8000A464 000062A4 3B E0 00 01 */ li r31, 0x1
/* 8000A468 000062A8 38 80 00 00 */ li r4, 0x0
/* 8000A46C 000062AC 54 60 6F FF */ extrwi. r0, r3, 1, 12
/* 8000A470 000062B0 41 82 00 10 */ beq lbl_8000A480
/* 8000A474 000062B4 54 60 3F BE */ extrwi r0, r3, 2, 5
/* 8000A478 000062B8 28 00 00 02 */ cmplwi r0, 0x2
/* 8000A47C 000062BC 40 82 00 08 */ bne lbl_8000A484
.global lbl_8000A480
lbl_8000A480:
/* 8000A480 000062C0 38 80 00 01 */ li r4, 0x1
.global lbl_8000A484
lbl_8000A484:
/* 8000A484 000062C4 2C 04 00 00 */ cmpwi r4, 0x0
/* 8000A488 000062C8 40 82 00 18 */ bne lbl_8000A4A0
/* 8000A48C 000062CC 80 1C 00 04 */ lwz r0, 0x4(r28)
/* 8000A490 000062D0 54 00 3F BE */ extrwi r0, r0, 2, 5
/* 8000A494 000062D4 28 00 00 01 */ cmplwi r0, 0x1
/* 8000A498 000062D8 41 82 00 08 */ beq lbl_8000A4A0
/* 8000A49C 000062DC 3B E0 00 00 */ li r31, 0x0
.global lbl_8000A4A0
lbl_8000A4A0:
/* 8000A4A0 000062E0 80 1C 00 08 */ lwz r0, 0x8(r28)
/* 8000A4A4 000062E4 54 00 1F 7F */ srwi. r0, r0, 29
/* 8000A4A8 000062E8 40 82 00 54 */ bne lbl_8000A4FC
/* 8000A4AC 000062EC 80 7C 00 04 */ lwz r3, 0x4(r28)
/* 8000A4B0 000062F0 54 60 2F BD */ rlwinm. r0, r3, 5, 30, 30
/* 8000A4B4 000062F4 54 60 2F 7E */ extrwi r0, r3, 3, 2
/* 8000A4B8 000062F8 41 82 00 44 */ beq lbl_8000A4FC
/* 8000A4BC 000062FC 54 00 07 7B */ rlwinm. r0, r0, 0, 29, 29
/* 8000A4C0 00006300 41 82 00 24 */ beq lbl_8000A4E4
/* 8000A4C4 00006304 7F 83 E3 78 */ mr r3, r28
/* 8000A4C8 00006308 38 80 00 00 */ li r4, 0x0
/* 8000A4CC 0000630C 38 A0 00 02 */ li r5, 0x2
/* 8000A4D0 00006310 48 00 04 C1 */ bl _fseek
/* 8000A4D4 00006314 2C 03 00 00 */ cmpwi r3, 0x0
/* 8000A4D8 00006318 41 82 00 0C */ beq lbl_8000A4E4
/* 8000A4DC 0000631C 38 60 00 00 */ li r3, 0x0
/* 8000A4E0 00006320 48 00 02 00 */ b lbl_8000A6E0
.global lbl_8000A4E4
lbl_8000A4E4:
/* 8000A4E4 00006324 80 1C 00 08 */ lwz r0, 0x8(r28)
/* 8000A4E8 00006328 38 60 00 01 */ li r3, 0x1
/* 8000A4EC 0000632C 50 60 E8 04 */ rlwimi r0, r3, 29, 0, 2
/* 8000A4F0 00006330 90 1C 00 08 */ stw r0, 0x8(r28)
/* 8000A4F4 00006334 7F 83 E3 78 */ mr r3, r28
/* 8000A4F8 00006338 4B FF FD E5 */ bl __prep_buffer
.global lbl_8000A4FC
lbl_8000A4FC:
/* 8000A4FC 0000633C 80 1C 00 08 */ lwz r0, 0x8(r28)
/* 8000A500 00006340 54 00 1F 7E */ srwi r0, r0, 29
/* 8000A504 00006344 28 00 00 01 */ cmplwi r0, 0x1
/* 8000A508 00006348 41 82 00 1C */ beq lbl_8000A524
/* 8000A50C 0000634C 38 60 00 01 */ li r3, 0x1
/* 8000A510 00006350 38 00 00 00 */ li r0, 0x0
/* 8000A514 00006354 98 7C 00 0A */ stb r3, 0xa(r28)
/* 8000A518 00006358 38 60 00 00 */ li r3, 0x0
/* 8000A51C 0000635C 90 1C 00 28 */ stw r0, 0x28(r28)
/* 8000A520 00006360 48 00 01 C0 */ b lbl_8000A6E0
.global lbl_8000A524
lbl_8000A524:
/* 8000A524 00006364 2C 1E 00 00 */ cmpwi r30, 0x0
/* 8000A528 00006368 3B A0 00 00 */ li r29, 0x0
/* 8000A52C 0000636C 41 82 01 28 */ beq lbl_8000A654
/* 8000A530 00006370 80 7C 00 1C */ lwz r3, 0x1c(r28)
/* 8000A534 00006374 80 9C 00 24 */ lwz r4, 0x24(r28)
/* 8000A538 00006378 7C 04 18 40 */ cmplw r4, r3
/* 8000A53C 0000637C 40 82 00 0C */ bne lbl_8000A548
/* 8000A540 00006380 2C 1F 00 00 */ cmpwi r31, 0x0
/* 8000A544 00006384 41 82 01 10 */ beq lbl_8000A654
.global lbl_8000A548
lbl_8000A548:
/* 8000A548 00006388 80 1C 00 20 */ lwz r0, 0x20(r28)
/* 8000A54C 0000638C 7C 63 20 50 */ subf r3, r3, r4
/* 8000A550 00006390 7C 03 00 50 */ subf r0, r3, r0
/* 8000A554 00006394 90 1C 00 28 */ stw r0, 0x28(r28)
.global lbl_8000A558
lbl_8000A558:
/* 8000A558 00006398 80 BC 00 28 */ lwz r5, 0x28(r28)
/* 8000A55C 0000639C 3B 20 00 00 */ li r25, 0x0
/* 8000A560 000063A0 90 A1 00 08 */ stw r5, 0x8(r1)
/* 8000A564 000063A4 7C 05 F0 40 */ cmplw r5, r30
/* 8000A568 000063A8 40 81 00 0C */ ble lbl_8000A574
/* 8000A56C 000063AC 7F C5 F3 78 */ mr r5, r30
/* 8000A570 000063B0 93 C1 00 08 */ stw r30, 0x8(r1)
.global lbl_8000A574
lbl_8000A574:
/* 8000A574 000063B4 80 1C 00 04 */ lwz r0, 0x4(r28)
/* 8000A578 000063B8 54 00 3F BE */ extrwi r0, r0, 2, 5
/* 8000A57C 000063BC 28 00 00 01 */ cmplwi r0, 0x1
/* 8000A580 000063C0 40 82 00 30 */ bne lbl_8000A5B0
/* 8000A584 000063C4 2C 05 00 00 */ cmpwi r5, 0x0
/* 8000A588 000063C8 41 82 00 28 */ beq lbl_8000A5B0
/* 8000A58C 000063CC 7F 43 D3 78 */ mr r3, r26
/* 8000A590 000063D0 38 80 00 0A */ li r4, 0xa
/* 8000A594 000063D4 48 00 08 B1 */ bl __memrchr
/* 8000A598 000063D8 2C 03 00 00 */ cmpwi r3, 0x0
/* 8000A59C 000063DC 7C 79 1B 78 */ mr r25, r3
/* 8000A5A0 000063E0 41 82 00 10 */ beq lbl_8000A5B0
/* 8000A5A4 000063E4 38 03 00 01 */ addi r0, r3, 0x1
/* 8000A5A8 000063E8 7C BA 00 50 */ subf r5, r26, r0
/* 8000A5AC 000063EC 90 A1 00 08 */ stw r5, 0x8(r1)
.global lbl_8000A5B0
lbl_8000A5B0:
/* 8000A5B0 000063F0 80 A1 00 08 */ lwz r5, 0x8(r1)
/* 8000A5B4 000063F4 2C 05 00 00 */ cmpwi r5, 0x0
/* 8000A5B8 000063F8 41 82 00 38 */ beq lbl_8000A5F0
/* 8000A5BC 000063FC 80 7C 00 24 */ lwz r3, 0x24(r28)
/* 8000A5C0 00006400 7F 44 D3 78 */ mr r4, r26
/* 8000A5C4 00006404 4B FF 9A 3D */ bl memcpy
/* 8000A5C8 00006408 80 81 00 08 */ lwz r4, 0x8(r1)
/* 8000A5CC 0000640C 80 7C 00 24 */ lwz r3, 0x24(r28)
/* 8000A5D0 00006410 80 1C 00 28 */ lwz r0, 0x28(r28)
/* 8000A5D4 00006414 7F 5A 22 14 */ add r26, r26, r4
/* 8000A5D8 00006418 7C 63 22 14 */ add r3, r3, r4
/* 8000A5DC 0000641C 90 7C 00 24 */ stw r3, 0x24(r28)
/* 8000A5E0 00006420 7F C4 F0 50 */ subf r30, r4, r30
/* 8000A5E4 00006424 80 61 00 08 */ lwz r3, 0x8(r1)
/* 8000A5E8 00006428 7C 03 00 50 */ subf r0, r3, r0
/* 8000A5EC 0000642C 90 1C 00 28 */ stw r0, 0x28(r28)
.global lbl_8000A5F0
lbl_8000A5F0:
/* 8000A5F0 00006430 80 1C 00 28 */ lwz r0, 0x28(r28)
/* 8000A5F4 00006434 2C 00 00 00 */ cmpwi r0, 0x0
/* 8000A5F8 00006438 41 82 00 18 */ beq lbl_8000A610
/* 8000A5FC 0000643C 2C 19 00 00 */ cmpwi r25, 0x0
/* 8000A600 00006440 40 82 00 10 */ bne lbl_8000A610
/* 8000A604 00006444 80 1C 00 04 */ lwz r0, 0x4(r28)
/* 8000A608 00006448 54 00 3F BF */ extrwi. r0, r0, 2, 5
/* 8000A60C 0000644C 40 82 00 30 */ bne lbl_8000A63C
.global lbl_8000A610
lbl_8000A610:
/* 8000A610 00006450 7F 83 E3 78 */ mr r3, r28
/* 8000A614 00006454 38 80 00 00 */ li r4, 0x0
/* 8000A618 00006458 4B FF FC ED */ bl __flush_buffer
/* 8000A61C 0000645C 2C 03 00 00 */ cmpwi r3, 0x0
/* 8000A620 00006460 41 82 00 1C */ beq lbl_8000A63C
/* 8000A624 00006464 38 60 00 01 */ li r3, 0x1
/* 8000A628 00006468 38 00 00 00 */ li r0, 0x0
/* 8000A62C 0000646C 98 7C 00 0A */ stb r3, 0xa(r28)
/* 8000A630 00006470 3B C0 00 00 */ li r30, 0x0
/* 8000A634 00006474 90 1C 00 28 */ stw r0, 0x28(r28)
/* 8000A638 00006478 48 00 00 1C */ b lbl_8000A654
.global lbl_8000A63C
lbl_8000A63C:
/* 8000A63C 0000647C 80 01 00 08 */ lwz r0, 0x8(r1)
/* 8000A640 00006480 2C 1E 00 00 */ cmpwi r30, 0x0
/* 8000A644 00006484 7F BD 02 14 */ add r29, r29, r0
/* 8000A648 00006488 41 82 00 0C */ beq lbl_8000A654
/* 8000A64C 0000648C 2C 1F 00 00 */ cmpwi r31, 0x0
/* 8000A650 00006490 40 82 FF 08 */ bne lbl_8000A558
.global lbl_8000A654
lbl_8000A654:
/* 8000A654 00006494 2C 1E 00 00 */ cmpwi r30, 0x0
/* 8000A658 00006498 41 82 00 6C */ beq lbl_8000A6C4
/* 8000A65C 0000649C 2C 1F 00 00 */ cmpwi r31, 0x0
/* 8000A660 000064A0 40 82 00 64 */ bne lbl_8000A6C4
/* 8000A664 000064A4 83 3C 00 1C */ lwz r25, 0x1c(r28)
/* 8000A668 000064A8 7C 1A F2 14 */ add r0, r26, r30
/* 8000A66C 000064AC 83 FC 00 20 */ lwz r31, 0x20(r28)
/* 8000A670 000064B0 7F 83 E3 78 */ mr r3, r28
/* 8000A674 000064B4 93 5C 00 1C */ stw r26, 0x1c(r28)
/* 8000A678 000064B8 38 81 00 08 */ addi r4, r1, 0x8
/* 8000A67C 000064BC 93 DC 00 20 */ stw r30, 0x20(r28)
/* 8000A680 000064C0 90 1C 00 24 */ stw r0, 0x24(r28)
/* 8000A684 000064C4 4B FF FC 81 */ bl __flush_buffer
/* 8000A688 000064C8 2C 03 00 00 */ cmpwi r3, 0x0
/* 8000A68C 000064CC 41 82 00 18 */ beq lbl_8000A6A4
/* 8000A690 000064D0 38 60 00 01 */ li r3, 0x1
/* 8000A694 000064D4 38 00 00 00 */ li r0, 0x0
/* 8000A698 000064D8 98 7C 00 0A */ stb r3, 0xa(r28)
/* 8000A69C 000064DC 90 1C 00 28 */ stw r0, 0x28(r28)
/* 8000A6A0 000064E0 48 00 00 0C */ b lbl_8000A6AC
.global lbl_8000A6A4
lbl_8000A6A4:
/* 8000A6A4 000064E4 80 01 00 08 */ lwz r0, 0x8(r1)
/* 8000A6A8 000064E8 7F BD 02 14 */ add r29, r29, r0
.global lbl_8000A6AC
lbl_8000A6AC:
/* 8000A6AC 000064EC 93 3C 00 1C */ stw r25, 0x1c(r28)
/* 8000A6B0 000064F0 7F 83 E3 78 */ mr r3, r28
/* 8000A6B4 000064F4 93 FC 00 20 */ stw r31, 0x20(r28)
/* 8000A6B8 000064F8 4B FF FC 25 */ bl __prep_buffer
/* 8000A6BC 000064FC 38 00 00 00 */ li r0, 0x0
/* 8000A6C0 00006500 90 1C 00 28 */ stw r0, 0x28(r28)
.global lbl_8000A6C4
lbl_8000A6C4:
/* 8000A6C4 00006504 80 1C 00 04 */ lwz r0, 0x4(r28)
/* 8000A6C8 00006508 54 00 3F BE */ extrwi r0, r0, 2, 5
/* 8000A6CC 0000650C 28 00 00 02 */ cmplwi r0, 0x2
/* 8000A6D0 00006510 41 82 00 0C */ beq lbl_8000A6DC
/* 8000A6D4 00006514 38 00 00 00 */ li r0, 0x0
/* 8000A6D8 00006518 90 1C 00 28 */ stw r0, 0x28(r28)
.global lbl_8000A6DC
lbl_8000A6DC:
/* 8000A6DC 0000651C 7C 7D DB 96 */ divwu r3, r29, r27
.global lbl_8000A6E0
lbl_8000A6E0:
/* 8000A6E0 00006520 BB 21 00 14 */ lmw r25, 0x14(r1)
/* 8000A6E4 00006524 80 01 00 34 */ lwz r0, 0x34(r1)
/* 8000A6E8 00006528 7C 08 03 A6 */ mtlr r0
/* 8000A6EC 0000652C 38 21 00 30 */ addi r1, r1, 0x30
/* 8000A6F0 00006530 4E 80 00 20 */ blr