#
# +-------------------------------------------------------------------------+
# |     This file is generated by The Interactive Disassembler (IDA)        |
# |     Copyright (c) 2007 by DataRescue sa/nv, <ida@datarescue.com>        |
# +-------------------------------------------------------------------------+
#
RAM:81362000
RAM:81362000 # =============== S U B R O U T I N E =======================================
RAM:81362000
RAM:81362000
RAM:81362000 ipl::utility::ESMisc::DeleteSavedata((unsigned long long, EGG::Heap *)):
RAM:81362000                                         # CODE XREF: ipl::utility::ESMisc::VerifySavedataZD((ulong long,EGG::Heap *))+1E0p
RAM:81362000
RAM:81362000 .set arg_0,  0
RAM:81362000 .set arg_20,  0x20
RAM:81362000 .set arg_40,  0x40
RAM:81362000 .set arg_A0,  0xA0
RAM:81362000
RAM:81362000                 clrlwi  %r11, %sp, 27
RAM:81362004                 mr      %r12, %sp
RAM:81362008                 subfic  %r11, %r11, -0x120
RAM:8136200C                 stwux   %sp, %sp, %r11
RAM:81362010                 mflr    %r0
RAM:81362014                 mr      %r11, %r12
RAM:81362018                 stw     %r0, 4(%r12)
RAM:8136201C                 bl      savegpr26
RAM:81362020                 lis     %r31, a_ESMiscGetTmdViewTMDorContentdoesnotexist@h # "ESMisc::GetTmdView: TMD or Content does"...
RAM:81362024                 li      %r30, 0
RAM:81362028                 mr      %r6, %r3
RAM:8136202C                 mr      %r7, %r4
RAM:81362030                 addi    %r31, %r31, a_ESMiscGetTmdViewTMDorContentdoesnotexist@l # "ESMisc::GetTmdView: TMD or Content does"...
RAM:81362034                 li      %r0, -1
RAM:81362038                 mr      %r26, %r5
RAM:8136203C                 stw     %r30, arg_20(%sp)
RAM:81362040                 and     %r5, %r6, %r0
RAM:81362044                 addi    %r3, %sp, arg_A0
RAM:81362048                 addi    %r4, %r31, a_title08x08xdata_4 # "/title/%08x/%08x/data/"
RAM:8136204C                 and     %r6, %r7, %r0
RAM:81362050                 crclr   4*cr1+eq
RAM:81362054                 bl      sprintf
RAM:81362058                 addi    %r3, %sp, arg_A0
RAM:8136205C                 addi    %r5, %sp, arg_20
RAM:81362060                 li      %r4, 0
RAM:81362064                 bl      NANDReadDir
RAM:81362068                 cmpwi   %r3, 0
RAM:8136206C                 mr      %r27, %r3
RAM:81362070                 bne     loc_81362080
RAM:81362074                 lwz     %r0, arg_20(%sp)
RAM:81362078                 cmpwi   %r0, 0
RAM:8136207C                 bne     loc_813620A0
RAM:81362080
RAM:81362080 loc_81362080:                           # CODE XREF: ipl::utility::ESMisc::DeleteSavedata((ulong long,EGG::Heap *))+70j
RAM:81362080                 mr      %r7, %r27
RAM:81362084                 addi    %r3, %r31, a_ssCouldnotread1sd # "%s::%s: Could not read1 %s: %d\n"
RAM:81362088                 addi    %r4, %r31, a_iplESMisc_cpp # "iplESMisc.cpp"
RAM:8136208C                 addi    %r5, %r31, a_DeleteSavedata # "DeleteSavedata"
RAM:81362090                 addi    %r6, %sp, arg_A0
RAM:81362094                 crclr   4*cr1+eq
RAM:81362098                 bl      OSReport
RAM:8136209C                 b       loc_813621A0
RAM:813620A0 # ---------------------------------------------------------------------------
RAM:813620A0
RAM:813620A0 loc_813620A0:                           # CODE XREF: ipl::utility::ESMisc::DeleteSavedata((ulong long,EGG::Heap *))+7Cj
RAM:813620A0                 mulli   %r4, %r0, 0x41
RAM:813620A4                 lwz     %r12, 0(%r26)
RAM:813620A8                 mr      %r3, %r26
RAM:813620AC                 lwz     %r12, 0x14(%r12)
RAM:813620B0                 li      %r5, -0x20
RAM:813620B4                 addi    %r0, %r4, 0x1F
RAM:813620B8                 clrrwi  %r4, %r0, 5
RAM:813620BC                 mtctr   %r12
RAM:813620C0                 bctrl
RAM:813620C4                 cmpwi   %r3, 0
RAM:813620C8                 mr      %r30, %r3
RAM:813620CC                 bne     loc_813620F0
RAM:813620D0                 addi    %r3, %r31, a_ssCouldnotallocd # "%s::%s: Could not alloc: %d\n"
RAM:813620D4                 addi    %r4, %r31, a_iplESMisc_cpp # "iplESMisc.cpp"
RAM:813620D8                 addi    %r5, %r31, a_DeleteSavedata # "DeleteSavedata"
RAM:813620DC                 li      %r27, -2
RAM:813620E0                 li      %r6, -2
RAM:813620E4                 crclr   4*cr1+eq
RAM:813620E8                 bl      OSReport
RAM:813620EC                 b       loc_813621A0
RAM:813620F0 # ---------------------------------------------------------------------------
RAM:813620F0
RAM:813620F0 loc_813620F0:                           # CODE XREF: ipl::utility::ESMisc::DeleteSavedata((ulong long,EGG::Heap *))+CCj
RAM:813620F0                 mr      %r4, %r30
RAM:813620F4                 addi    %r3, %sp, arg_A0
RAM:813620F8                 addi    %r5, %sp, arg_20
RAM:813620FC                 bl      NANDReadDir
RAM:81362100                 cmpwi   %r3, 0
RAM:81362104                 mr      %r27, %r3
RAM:81362108                 beq     loc_8136212C
RAM:8136210C                 mr      %r7, %r27
RAM:81362110                 addi    %r3, %r31, a_ssCouldnotread2sd # "%s::%s: Could not read2 %s: %d\n"
RAM:81362114                 addi    %r4, %r31, a_iplESMisc_cpp # "iplESMisc.cpp"
RAM:81362118                 addi    %r5, %r31, a_DeleteSavedata # "DeleteSavedata"
RAM:8136211C                 addi    %r6, %sp, arg_A0
RAM:81362120                 crclr   4*cr1+eq
RAM:81362124                 bl      OSReport
RAM:81362128                 b       loc_813621A0
RAM:8136212C # ---------------------------------------------------------------------------
RAM:8136212C
RAM:8136212C loc_8136212C:                           # CODE XREF: ipl::utility::ESMisc::DeleteSavedata((ulong long,EGG::Heap *))+108j
RAM:8136212C                 mr      %r29, %r30
RAM:81362130                 li      %r28, 0
RAM:81362134                 b       loc_81362194
RAM:81362138 # ---------------------------------------------------------------------------
RAM:81362138
RAM:81362138 loc_81362138:                           # CODE XREF: ipl::utility::ESMisc::DeleteSavedata((ulong long,EGG::Heap *))+19Cj
RAM:81362138                 addi    %r3, %sp, arg_40
RAM:8136213C                 addi    %r4, %sp, arg_A0
RAM:81362140                 bl      strcpy
RAM:81362144                 mr      %r4, %r29
RAM:81362148                 addi    %r3, %sp, arg_40
RAM:8136214C                 bl      strcat
RAM:81362150                 addi    %r3, %sp, arg_40
RAM:81362154                 bl      NANDPrivateDelete
RAM:81362158                 cmpwi   %r3, 0
RAM:8136215C                 mr      %r27, %r3
RAM:81362160                 beq     loc_81362180
RAM:81362164                 mr      %r7, %r27
RAM:81362168                 addi    %r3, %r31, a_ssFailedtodeletesd # "%s::%s: Failed to delete %s: %d\n"
RAM:8136216C                 addi    %r4, %r31, a_iplESMisc_cpp # "iplESMisc.cpp"
RAM:81362170                 addi    %r5, %r31, a_DeleteSavedata # "DeleteSavedata"
RAM:81362174                 addi    %r6, %sp, arg_40
RAM:81362178                 crclr   4*cr1+eq
RAM:8136217C                 bl      OSReport
RAM:81362180
RAM:81362180 loc_81362180:                           # CODE XREF: ipl::utility::ESMisc::DeleteSavedata((ulong long,EGG::Heap *))+160j
RAM:81362180                 mr      %r3, %r29
RAM:81362184                 addi    %r28, %r28, 1
RAM:81362188                 bl      strlen
RAM:8136218C                 add     %r3, %r3, %r29
RAM:81362190                 addi    %r29, %r3, 1
RAM:81362194
RAM:81362194 loc_81362194:                           # CODE XREF: ipl::utility::ESMisc::DeleteSavedata((ulong long,EGG::Heap *))+134j
RAM:81362194                 lwz     %r0, arg_20(%sp)
RAM:81362198                 cmplw   %r28, %r0
RAM:8136219C                 blt     loc_81362138
RAM:813621A0
RAM:813621A0 loc_813621A0:                           # CODE XREF: ipl::utility::ESMisc::DeleteSavedata((ulong long,EGG::Heap *))+9Cj
RAM:813621A0                                         # ipl::utility::ESMisc::DeleteSavedata((ulong long,EGG::Heap *))+ECj
RAM:813621A0                                         # ipl::utility::ESMisc::DeleteSavedata((ulong long,EGG::Heap *))+128j
RAM:813621A0                 cmpwi   %r30, 0
RAM:813621A4                 beq     loc_813621C0
RAM:813621A8                 lwz     %r12, 0(%r26)
RAM:813621AC                 mr      %r3, %r26
RAM:813621B0                 mr      %r4, %r30
RAM:813621B4                 lwz     %r12, 0x18(%r12)
RAM:813621B8                 mtctr   %r12
RAM:813621BC                 bctrl
RAM:813621C0
RAM:813621C0 loc_813621C0:                           # CODE XREF: ipl::utility::ESMisc::DeleteSavedata((ulong long,EGG::Heap *))+1A4j
RAM:813621C0                 mr      %r3, %r27
RAM:813621C4                 lwz     %r10, arg_0(%sp)
RAM:813621C8                 mr      %r11, %r10
RAM:813621CC                 bl      restgpr26
RAM:813621D0                 lwz     %r0, 4(%r10)
RAM:813621D4                 mtlr    %r0
RAM:813621D8                 mr      %sp, %r10
RAM:813621DC                 blr
RAM:813621DC # End of function ipl::utility::ESMisc::DeleteSavedata((ulong long,EGG::Heap *))
RAM:813621DC
RAM:813621E0
RAM:813621E0 # =============== S U B R O U T I N E =======================================
RAM:813621E0
RAM:813621E0
RAM:813621E0 ipl::utility::ESMisc::VerifySavedataZD((unsigned long long, EGG::Heap *)):
RAM:813621E0                                         # CODE XREF: sub_81354104+188p
RAM:813621E0
RAM:813621E0 .set file_length, -0xF8
RAM:813621E0 .set var_F4, -0xF4
RAM:813621E0 .set var_B0, -0xB0
RAM:813621E0 .set arg_0,  0
RAM:813621E0 .set arg_4,  4
RAM:813621E0
RAM:813621E0                 stwu    %sp, -0x100(%sp)
RAM:813621E4                 mflr    %r0
RAM:813621E8                 stw     %r0, 0x100+arg_4(%sp)
RAM:813621EC                 addi    %r11, %sp, 0x100+arg_0
RAM:813621F0                 bl      savegpr25
RAM:813621F4                 lis     %r31, a_ESMiscGetTmdViewTMDorContentdoesnotexist@h # "ESMisc::GetTmdView: TMD or Content does"...
RAM:813621F8                 mr      %r26, %r3
RAM:813621FC                 addi    %r31, %r31, a_ESMiscGetTmdViewTMDorContentdoesnotexist@l # "ESMisc::GetTmdView: TMD or Content does"...
RAM:81362200                 mr      %r25, %r4
RAM:81362204                 li      %r0, -1
RAM:81362208                 mr      %r27, %r5
RAM:8136220C                 addi    %r3, %sp, 0x100+var_F4
RAM:81362210                 addi    %r4, %r31, a_title08x08xdatas_0 # "/title/%08x/%08x/data/%s"
RAM:81362214                 and     %r5, %r26, %r0
RAM:81362218                 and     %r6, %r25, %r0
RAM:8136221C                 addi    %r7, %r31, a_zeldaTp_dat_0 # "zeldaTp.dat"
RAM:81362220                 li      %r30, 0
RAM:81362224                 li      %r29, 0
RAM:81362228                 li      %r28, 0
RAM:8136222C                 crclr   4*cr1+eq
RAM:81362230                 bl      sprintf
RAM:81362234                 mr      %r4, %r25
RAM:81362238                 mr      %r3, %r26
RAM:8136223C                 bl      ipl::utility::ESMisc::ChangeUid((ulong long))
RAM:81362240                 cmpwi   %r3, 0
RAM:81362244                 beq     loc_813623C8
RAM:81362248                 addi    %r3, %sp, 0x100+var_F4
RAM:8136224C                 addi    %r4, %sp, 0x100+var_B0
RAM:81362250                 li      %r5, 3
RAM:81362254                 bl      nandPrivateOpen
RAM:81362258                 cmpwi   %r3, -0xC
RAM:8136225C                 mr      %r28, %r3
RAM:81362260                 bne     loc_81362284
RAM:81362264                 mr      %r7, %r28
RAM:81362268                 addi    %r3, %r31, a_ssDoesnotexistsd # "%s::%s: Does not exist %s: %d\n"
RAM:8136226C                 addi    %r4, %r31, a_iplESMisc_cpp # "iplESMisc.cpp"
RAM:81362270                 addi    %r5, %r31, a_VerifySavedataZD # "VerifySavedataZD"
RAM:81362274                 addi    %r6, %sp, 0x100+var_F4
RAM:81362278                 crclr   4*cr1+eq
RAM:8136227C                 bl      OSReport
RAM:81362280                 b       loc_813623C8
RAM:81362284 # ---------------------------------------------------------------------------
RAM:81362284
RAM:81362284 loc_81362284:                           # CODE XREF: ipl::utility::ESMisc::VerifySavedataZD((ulong long,EGG::Heap *))+80j
RAM:81362284                 cmpwi   %r3, 0
RAM:81362288                 beq     loc_813622A8
RAM:8136228C                 mr      %r6, %r28
RAM:81362290                 addi    %r3, %r31, a_ssOpensavedatafilefailedd # "%s::%s: Open save data file failed: %d\n"...
RAM:81362294                 addi    %r4, %r31, a_iplESMisc_cpp # "iplESMisc.cpp"
RAM:81362298                 addi    %r5, %r31, a_VerifySavedataZD # "VerifySavedataZD"
RAM:8136229C                 crclr   4*cr1+eq
RAM:813622A0                 bl      OSReport
RAM:813622A4                 b       loc_813623C8
RAM:813622A8 # ---------------------------------------------------------------------------
RAM:813622A8
RAM:813622A8 loc_813622A8:                           # CODE XREF: ipl::utility::ESMisc::VerifySavedataZD((ulong long,EGG::Heap *))+A8j
RAM:813622A8                 addi    %r3, %sp, 0x100+var_B0
RAM:813622AC                 addi    %r4, %sp, 0x100+file_length
RAM:813622B0                 li      %r29, 1
RAM:813622B4                 bl      NANDGetLength
RAM:813622B8                 cmpwi   %r3, 0
RAM:813622BC                 mr      %r28, %r3
RAM:813622C0                 beq     loc_813622E0
RAM:813622C4                 mr      %r6, %r28
RAM:813622C8                 addi    %r3, %r31, a_ssGetfilelengthfailedd # "%s::%s: Get file length failed: %d\n"
RAM:813622CC                 addi    %r4, %r31, a_iplESMisc_cpp # "iplESMisc.cpp"
RAM:813622D0                 addi    %r5, %r31, a_VerifySavedataZD # "VerifySavedataZD"
RAM:813622D4                 crclr   4*cr1+eq
RAM:813622D8                 bl      OSReport
RAM:813622DC                 b       loc_813623C8
RAM:813622E0 # ---------------------------------------------------------------------------
RAM:813622E0
RAM:813622E0 loc_813622E0:                           # CODE XREF: ipl::utility::ESMisc::VerifySavedataZD((ulong long,EGG::Heap *))+E0j
RAM:813622E0                 lwz     %r12, 0(%r27)
RAM:813622E4                 mr      %r3, %r27
RAM:813622E8                 lwz     %r4, 0x100+file_length(%sp)
RAM:813622EC                 li      %r5, -0x20
RAM:813622F0                 lwz     %r12, 0x14(%r12)
RAM:813622F4                 addi    %r0, %r4, 0x1F
RAM:813622F8                 clrrwi  %r4, %r0, 5
RAM:813622FC                 mtctr   %r12
RAM:81362300                 bctrl
RAM:81362304                 cmpwi   %r3, 0
RAM:81362308                 mr      %r30, %r3
RAM:8136230C                 bne     loc_81362330
RAM:81362310                 addi    %r3, %r31, a_ssAllocfailedd # "%s::%s: Alloc failed: %d\n"
RAM:81362314                 addi    %r4, %r31, a_iplESMisc_cpp # "iplESMisc.cpp"
RAM:81362318                 addi    %r5, %r31, a_VerifySavedataZD # "VerifySavedataZD"
RAM:8136231C                 li      %r28, -2
RAM:81362320                 li      %r6, -2
RAM:81362324                 crclr   4*cr1+eq
RAM:81362328                 bl      OSReport
RAM:8136232C                 b       loc_813623C8
RAM:81362330 # ---------------------------------------------------------------------------
RAM:81362330
RAM:81362330 loc_81362330:                           # CODE XREF: ipl::utility::ESMisc::VerifySavedataZD((ulong long,EGG::Heap *))+12Cj
RAM:81362330                 lwz     %r5, 0x100+file_length(%sp)
RAM:81362334                 mr      %r4, %r30
RAM:81362338                 addi    %r3, %sp, 0x100+var_B0
RAM:8136233C                 addi    %r0, %r5, 0x1F
RAM:81362340                 clrrwi  %r5, %r0, 5
RAM:81362344                 bl      NANDRead
RAM:81362348                 lwz     %r4, 0x100+file_length(%sp)
RAM:8136234C                 mr      %r28, %r3
RAM:81362350                 addi    %r0, %r4, 0x1F
RAM:81362354                 clrrwi  %r0, %r0, 5
RAM:81362358                 cmplw   %r3, %r0
RAM:8136235C                 beq     loc_8136237C
RAM:81362360                 mr      %r6, %r28
RAM:81362364                 addi    %r3, %r31, a_ssReadfilefailedd # "%s::%s: Read file failed: %d\n"
RAM:81362368                 addi    %r4, %r31, a_iplESMisc_cpp # "iplESMisc.cpp"
RAM:8136236C                 addi    %r5, %r31, a_VerifySavedataZD # "VerifySavedataZD"
RAM:81362370                 crclr   4*cr1+eq
RAM:81362374                 bl      OSReport
RAM:81362378                 b       loc_813623C8
RAM:8136237C # ---------------------------------------------------------------------------
RAM:8136237C
RAM:8136237C loc_8136237C:                           # CODE XREF: ipl::utility::ESMisc::VerifySavedataZD((ulong long,EGG::Heap *))+17Cj
RAM:8136237C                 mr      %r3, %r30
RAM:81362380                 bl      WADCheckSavedataZD # returns 0 if TP hack
RAM:81362384                 cmpwi   %r3, 0
RAM:81362388                 bne     savedata_ok
RAM:8136238C                 mr      %r8, %r25
RAM:81362390                 mr      %r7, %r26
RAM:81362394                 addi    %r3, %r31, a_ssVerifyfailedfor016llx # "%s::%s: Verify failed for %016llx\n"
RAM:81362398                 addi    %r4, %r31, a_iplESMisc_cpp # "iplESMisc.cpp"
RAM:8136239C                 addi    %r5, %r31, a_VerifySavedataZD # "VerifySavedataZD"
RAM:813623A0                 crclr   4*cr1+eq
RAM:813623A4                 bl      OSReport
RAM:813623A8                 addi    %r3, %sp, 0x100+var_B0
RAM:813623AC                 bl      NANDClose
RAM:813623B0                 mr      %r4, %r25       # int
RAM:813623B4                 mr      %r3, %r26       # int
RAM:813623B8                 mr      %r5, %r27       # int
RAM:813623BC                 li      %r29, 0
RAM:813623C0                 bl      ipl::utility::ESMisc::DeleteSavedata((ulong long,EGG::Heap *))
RAM:813623C4
RAM:813623C4 savedata_ok:                            # CODE XREF: ipl::utility::ESMisc::VerifySavedataZD((ulong long,EGG::Heap *))+1A8j
RAM:813623C4                 li      %r28, 0
RAM:813623C8
RAM:813623C8 loc_813623C8:                           # CODE XREF: ipl::utility::ESMisc::VerifySavedataZD((ulong long,EGG::Heap *))+64j
RAM:813623C8                                         # ipl::utility::ESMisc::VerifySavedataZD((ulong long,EGG::Heap *))+A0j
RAM:813623C8                                         # ipl::utility::ESMisc::VerifySavedataZD((ulong long,EGG::Heap *))+C4j ...
RAM:813623C8                 cmpwi   %r30, 0
RAM:813623CC                 beq     loc_813623E8
RAM:813623D0                 lwz     %r12, 0(%r27)
RAM:813623D4                 mr      %r3, %r27
RAM:813623D8                 mr      %r4, %r30
RAM:813623DC                 lwz     %r12, 0x18(%r12)
RAM:813623E0                 mtctr   %r12
RAM:813623E4                 bctrl
RAM:813623E8
RAM:813623E8 loc_813623E8:                           # CODE XREF: ipl::utility::ESMisc::VerifySavedataZD((ulong long,EGG::Heap *))+1ECj
RAM:813623E8                 cmpwi   %r29, 0
RAM:813623EC                 beq     loc_813623F8
RAM:813623F0                 addi    %r3, %sp, 0x100+var_B0
RAM:813623F4                 bl      NANDClose
RAM:813623F8
RAM:813623F8 loc_813623F8:                           # CODE XREF: ipl::utility::ESMisc::VerifySavedataZD((ulong long,EGG::Heap *))+20Cj
RAM:813623F8                 li      %r4, 2
RAM:813623FC                 li      %r3, 1
RAM:81362400                 bl      ipl::utility::ESMisc::ChangeUid((ulong long))
RAM:81362404                 addi    %r11, %sp, 0x100+arg_0
RAM:81362408                 mr      %r3, %r28
RAM:8136240C                 bl      restgpr25
RAM:81362410                 lwz     %r0, 0x100+arg_4(%sp)
RAM:81362414                 mtlr    %r0
RAM:81362418                 addi    %sp, %sp, 0x100
RAM:8136241C                 blr
RAM:8136241C # End of function ipl::utility::ESMisc::VerifySavedataZD((ulong long,EGG::Heap *))
RAM:8136241C
RAM:8159A3F8 # =============== S U B R O U T I N E =======================================
RAM:8159A3F8
RAM:8159A3F8
RAM:8159A3F8 WADVerify:                              # CODE XREF: cc_wadcheckzelda+6Cp
RAM:8159A3F8
RAM:8159A3F8 .set arg_0,  0
RAM:8159A3F8 .set arg_40,  0x40
RAM:8159A3F8 .set arg_80,  0x80
RAM:8159A3F8 .set arg_C0,  0xC0
RAM:8159A3F8
RAM:8159A3F8                 clrlwi  %r11, %sp, 26
RAM:8159A3FC                 mr      %r12, %sp
RAM:8159A400                 subfic  %r11, %r11, -0x180
RAM:8159A404                 stwux   %sp, %sp, %r11
RAM:8159A408                 mflr    %r0
RAM:8159A40C                 mr      %r11, %r12
RAM:8159A410                 stw     %r0, 4(%r12)
RAM:8159A414                 bl      sub_815CD944
RAM:8159A418                 addi    %r0, %r6, 0x1F
RAM:8159A41C                 li      %r7, 0
RAM:8159A420                 clrrwi  %r0, %r0, 5
RAM:8159A424                 stw     %r7, arg_40(%sp)
RAM:8159A428                 cmplw   %r6, %r0
RAM:8159A42C                 mr      %r24, %r3
RAM:8159A430                 mr      %r25, %r4
RAM:8159A434                 mr      %r26, %r5
RAM:8159A438                 mr      %r27, %r6
RAM:8159A43C                 li      %r30, 0
RAM:8159A440                 li      %r28, 0
RAM:8159A444                 beq     loc_8159A450
RAM:8159A448                 li      %r31, -0xBB8
RAM:8159A44C                 b       loc_8159A5BC
RAM:8159A450 # ---------------------------------------------------------------------------
RAM:8159A450
RAM:8159A450 loc_8159A450:                           # CODE XREF: WADVerify+4Cj
RAM:8159A450                 cmplwi  %r6, 0x340
RAM:8159A454                 bgt     loc_8159A460
RAM:8159A458                 li      %r31, -0xBB8
RAM:8159A45C                 b       loc_8159A5BC
RAM:8159A460 # ---------------------------------------------------------------------------
RAM:8159A460
RAM:8159A460 loc_8159A460:                           # CODE XREF: WADVerify+5Cj
RAM:8159A460                 lis     %r31, 1 # 0x8000
RAM:8159A464                 mr      %r3, %r25
RAM:8159A468                 addi    %r4, %r31, -0x8000 # 0x8000
RAM:8159A46C                 bl      mutex_sth
RAM:8159A470                 cmpwi   %r3, 0
RAM:8159A474                 mr      %r30, %r3
RAM:8159A478                 bne     loc_8159A484
RAM:8159A47C                 li      %r31, -0xBBB
RAM:8159A480                 b       loc_8159A5BC
RAM:8159A484 # ---------------------------------------------------------------------------
RAM:8159A484
RAM:8159A484 loc_8159A484:                           # CODE XREF: WADVerify+80j
RAM:8159A484                 clrlwi. %r0, %r3, 26
RAM:8159A488                 beq     loc_8159A494
RAM:8159A48C                 li      %r31, -0xBBF
RAM:8159A490                 b       loc_8159A5BC
RAM:8159A494 # ---------------------------------------------------------------------------
RAM:8159A494
RAM:8159A494 loc_8159A494:                           # CODE XREF: WADVerify+90j
RAM:8159A494                 addi    %r27, %r27, -0x340
RAM:8159A498                 addi    %r3, %sp, arg_C0
RAM:8159A49C                 add     %r29, %r26, %r27
RAM:8159A4A0                 bl      sub_813CDA80
RAM:8159A4A4                 mr      %r3, %r24
RAM:8159A4A8                 mr      %r4, %r26
RAM:8159A4AC                 mr      %r5, %r27
RAM:8159A4B0                 mr      %r7, %r30
RAM:8159A4B4                 addi    %r6, %sp, arg_C0
RAM:8159A4B8                 addi    %r8, %r31, -0x8000
RAM:8159A4BC                 bl      sub_8159A2E8
RAM:8159A4C0                 cmpwi   %r3, 0
RAM:8159A4C4                 mr      %r31, %r3
RAM:8159A4C8                 bne     loc_8159A5BC
RAM:8159A4CC                 addi    %r3, %sp, arg_C0
RAM:8159A4D0                 addi    %r4, %sp, arg_80
RAM:8159A4D4                 bl      sub_813CDAEC
RAM:8159A4D8                 cmpwi   %r3, 0
RAM:8159A4DC                 mr      %r31, %r3
RAM:8159A4E0                 bne     loc_8159A5BC
RAM:8159A4E4                 stw     %r30, arg_40(%sp)
RAM:8159A4E8                 mr      %r3, %r24
RAM:8159A4EC                 mr      %r6, %r29
RAM:8159A4F0                 addi    %r4, %sp, arg_40
RAM:8159A4F4                 li      %r5, 0x340
RAM:8159A4F8                 bl      WADReadStream
RAM:8159A4FC                 cmpwi   %r3, 0x340
RAM:8159A500                 beq     loc_8159A50C
RAM:8159A504                 li      %r31, -0xBBD
RAM:8159A508                 b       loc_8159A5BC
RAM:8159A50C # ---------------------------------------------------------------------------
RAM:8159A50C
RAM:8159A50C loc_8159A50C:                           # CODE XREF: WADVerify+108j
RAM:8159A50C                 mr      %r3, %r25
RAM:8159A510                 li      %r4, 0xF80
RAM:8159A514                 bl      mutex_sth
RAM:8159A518                 cmpwi   %r3, 0
RAM:8159A51C                 mr      %r28, %r3
RAM:8159A520                 bne     loc_8159A52C
RAM:8159A524                 li      %r31, -0xBBB
RAM:8159A528                 b       loc_8159A5BC
RAM:8159A52C # ---------------------------------------------------------------------------
RAM:8159A52C
RAM:8159A52C loc_8159A52C:                           # CODE XREF: WADVerify+128j
RAM:8159A52C                 lis     %r4, ((unk_8165D650+0x10000)@h)
RAM:8159A530                 li      %r5, 0x400
RAM:8159A534                 addi    %r4, %r4, -0x29B0 # unk_8165D650
RAM:8159A538                 bl      sub_81330230
RAM:8159A53C                 lis     %r4, ((unk_8165DC90+0x10000)@h)
RAM:8159A540                 addi    %r3, %r28, 0x400
RAM:8159A544                 addi    %r4, %r4, -0x2370 # unk_8165DC90
RAM:8159A548                 li      %r5, 0x240
RAM:8159A54C                 bl      sub_81330230
RAM:8159A550                 lis     %r4, ((unk_8165D250+0x10000)@h)
RAM:8159A554                 addi    %r3, %r28, 0x640
RAM:8159A558                 addi    %r4, %r4, -0x2DB0 # unk_8165D250
RAM:8159A55C                 li      %r5, 0x400
RAM:8159A560                 bl      sub_81330230
RAM:8159A564                 lis     %r4, ((unk_8165DA50+0x10000)@h)
RAM:8159A568                 addi    %r3, %r28, 0xA40
RAM:8159A56C                 addi    %r4, %r4, -0x25B0 # unk_8165DA50
RAM:8159A570                 li      %r5, 0x240
RAM:8159A574                 bl      sub_81330230
RAM:8159A578                 lwz     %r4, arg_40(%sp)
RAM:8159A57C                 addi    %r3, %r28, 0xC80
RAM:8159A580                 li      %r5, 0x180
RAM:8159A584                 addi    %r4, %r4, 0x40
RAM:8159A588                 bl      sub_81330230
RAM:8159A58C                 lwz     %r4, arg_40(%sp)
RAM:8159A590                 addi    %r3, %r28, 0xE00
RAM:8159A594                 li      %r5, 0x180
RAM:8159A598                 addi    %r4, %r4, 0x1C0
RAM:8159A59C                 bl      sub_81330230
RAM:8159A5A0                 lwz     %r5, arg_40(%sp) # int
RAM:8159A5A4                 mr      %r6, %r28       # int
RAM:8159A5A8                 addi    %r3, %sp, arg_80 # int
RAM:8159A5AC                 li      %r4, 0x14       # int
RAM:8159A5B0                 li      %r7, 0xF80      # int
RAM:8159A5B4                 bl      sub_81595CC4
RAM:8159A5B8                 mr      %r31, %r3
RAM:8159A5BC
RAM:8159A5BC loc_8159A5BC:                           # CODE XREF: WADVerify+54j
RAM:8159A5BC                                         # WADVerify+64j WADVerify+88j ...
RAM:8159A5BC                 cmpwi   %r30, 0
RAM:8159A5C0                 beq     loc_8159A5D0
RAM:8159A5C4                 mr      %r3, %r25
RAM:8159A5C8                 mr      %r4, %r30
RAM:8159A5CC                 bl      WADCallFree
RAM:8159A5D0
RAM:8159A5D0 loc_8159A5D0:                           # CODE XREF: WADVerify+1C8j
RAM:8159A5D0                 cmpwi   %r28, 0
RAM:8159A5D4                 beq     loc_8159A5E4
RAM:8159A5D8                 mr      %r3, %r25
RAM:8159A5DC                 mr      %r4, %r28
RAM:8159A5E0                 bl      WADCallFree
RAM:8159A5E4
RAM:8159A5E4 loc_8159A5E4:                           # CODE XREF: WADVerify+1DCj
RAM:8159A5E4                 mr      %r3, %r31
RAM:8159A5E8                 lwz     %r10, arg_0(%sp)
RAM:8159A5EC                 mr      %r11, %r10
RAM:8159A5F0                 bl      sub_815CD990
RAM:8159A5F4                 lwz     %r0, 4(%r10)
RAM:8159A5F8                 mtlr    %r0
RAM:8159A5FC                 mr      %sp, %r10
RAM:8159A600                 blr
RAM:8159A600 # End of function WADVerify
RAM:8159A600
RAM:8159A604
RAM:8159A604 # =============== S U B R O U T I N E =======================================
RAM:8159A604
RAM:8159A604
RAM:8159A604 # int __stdcall check_strlen(void *ptr, int num)
RAM:8159A604 check_strlen:                           # CODE XREF: WADCheckSavedataZD+34p
RAM:8159A604                                         # WADCheckSavedataZD+48p
RAM:8159A604                                         # WADCheckSavedataZD+5Cp ...
RAM:8159A604                 mtctr   %r4
RAM:8159A608                 cmplwi  %r4, 0
RAM:8159A60C                 ble     loc_8159A62C
RAM:8159A610
RAM:8159A610 loc_8159A610:                           # CODE XREF: check_strlen+24j
RAM:8159A610                 lbz     %r0, 0(%r3)
RAM:8159A614                 extsb.  %r0, %r0
RAM:8159A618                 bne     loc_8159A624
RAM:8159A61C                 li      %r3, 1
RAM:8159A620                 blr
RAM:8159A624 # ---------------------------------------------------------------------------
RAM:8159A624
RAM:8159A624 loc_8159A624:                           # CODE XREF: check_strlen+14j
RAM:8159A624                 addi    %r3, %r3, 1
RAM:8159A628                 bdnz    loc_8159A610
RAM:8159A62C
RAM:8159A62C loc_8159A62C:                           # CODE XREF: check_strlen+8j
RAM:8159A62C                 li      %r3, 0
RAM:8159A630                 blr
RAM:8159A630 # End of function check_strlen
RAM:8159A630
RAM:8159A634
RAM:8159A634 # =============== S U B R O U T I N E =======================================
RAM:8159A634
RAM:8159A634
RAM:8159A634 WADCheckSavedataZD:                     # CODE XREF: ipl::utility::ESMisc::VerifySavedataZD((ulong long,EGG::Heap *))+1A0p
RAM:8159A634                                         # call_wadCheckSavedataZD+154p
RAM:8159A634
RAM:8159A634 .set var_10, -0x10
RAM:8159A634 .set var_C, -0xC
RAM:8159A634 .set var_8, -8
RAM:8159A634 .set var_4, -4
RAM:8159A634 .set arg_4,  4
RAM:8159A634
RAM:8159A634                 stwu    %sp, -0x20(%sp)
RAM:8159A638                 mflr    %r0
RAM:8159A63C                 stw     %r0, 0x20+arg_4(%sp)
RAM:8159A640                 stw     %r31, 0x20+var_4(%sp)
RAM:8159A644                 addi    %r31, %r3, 8
RAM:8159A648                 stw     %r30, 0x20+var_8(%sp)
RAM:8159A64C                 li      %r30, 0
RAM:8159A650                 stw     %r29, 0x20+var_C(%sp)
RAM:8159A654                 li      %r29, 0
RAM:8159A658                 stw     %r28, 0x20+var_10(%sp)
RAM:8159A65C                 mr      %r28, %r3
RAM:8159A660
RAM:8159A660 check_main_saveslots:                   # CODE XREF: WADCheckSavedataZD+B0j
RAM:8159A660                 addi    %r3, %r31, 0x4E # ptr
RAM:8159A664                 li      %r4, 8          # num
RAM:8159A668                 bl      check_strlen
RAM:8159A66C                 cmpwi   %r3, 0
RAM:8159A670                 beq     you_fail_it
RAM:8159A674                 addi    %r3, %r31, 0x58 # ptr
RAM:8159A678                 li      %r4, 8          # num
RAM:8159A67C                 bl      check_strlen
RAM:8159A680                 cmpwi   %r3, 0
RAM:8159A684                 beq     you_fail_it
RAM:8159A688                 addi    %r3, %r31, 0x72 # ptr
RAM:8159A68C                 li      %r4, 8          # num
RAM:8159A690                 bl      check_strlen
RAM:8159A694                 cmpwi   %r3, 0
RAM:8159A698                 beq     you_fail_it
RAM:8159A69C                 addi    %r3, %r31, 0x8E # ptr
RAM:8159A6A0                 li      %r4, 8          # num
RAM:8159A6A4                 bl      check_strlen
RAM:8159A6A8                 cmpwi   %r3, 0
RAM:8159A6AC                 beq     you_fail_it
RAM:8159A6B0                 addi    %r3, %r31, 0x1B4 # ptr
RAM:8159A6B4                 li      %r4, 0x11       # num
RAM:8159A6B8                 bl      check_strlen    # player name < 11?
RAM:8159A6BC                 cmpwi   %r3, 0
RAM:8159A6C0                 beq     you_fail_it
RAM:8159A6C4                 addi    %r3, %r31, 0x1C5 # ptr
RAM:8159A6C8                 li      %r4, 0x11       # num
RAM:8159A6CC                 bl      check_strlen    # horse name < 11?
RAM:8159A6D0                 cmpwi   %r3, 0
RAM:8159A6D4                 beq     you_fail_it
RAM:8159A6D8                 addi    %r30, %r30, 1
RAM:8159A6DC                 addi    %r31, %r31, 0xA94
RAM:8159A6E0                 cmplwi  %r30, 3
RAM:8159A6E4                 blt     check_main_saveslots
RAM:8159A6E8                 addi    %r31, %r28, 0x2008
RAM:8159A6EC                 li      %r30, 0
RAM:8159A6F0
RAM:8159A6F0 check_backup_saveslots:                 # CODE XREF: WADCheckSavedataZD+140j
RAM:8159A6F0                 addi    %r3, %r31, 0x4E # ptr
RAM:8159A6F4                 li      %r4, 8          # num
RAM:8159A6F8                 bl      check_strlen
RAM:8159A6FC                 cmpwi   %r3, 0
RAM:8159A700                 beq     you_fail_it
RAM:8159A704                 addi    %r3, %r31, 0x58 # ptr
RAM:8159A708                 li      %r4, 8          # num
RAM:8159A70C                 bl      check_strlen
RAM:8159A710                 cmpwi   %r3, 0
RAM:8159A714                 beq     you_fail_it
RAM:8159A718                 addi    %r3, %r31, 0x72 # ptr
RAM:8159A71C                 li      %r4, 8          # num
RAM:8159A720                 bl      check_strlen
RAM:8159A724                 cmpwi   %r3, 0
RAM:8159A728                 beq     you_fail_it
RAM:8159A72C                 addi    %r3, %r31, 0x8E # ptr
RAM:8159A730                 li      %r4, 8          # num
RAM:8159A734                 bl      check_strlen
RAM:8159A738                 cmpwi   %r3, 0
RAM:8159A73C                 beq     you_fail_it
RAM:8159A740                 addi    %r3, %r31, 0x1B4 # ptr
RAM:8159A744                 li      %r4, 0x11       # num
RAM:8159A748                 bl      check_strlen
RAM:8159A74C                 cmpwi   %r3, 0
RAM:8159A750                 beq     you_fail_it
RAM:8159A754                 addi    %r3, %r31, 0x1C5 # ptr
RAM:8159A758                 li      %r4, 0x11       # num
RAM:8159A75C                 bl      check_strlen
RAM:8159A760                 cmpwi   %r3, 0
RAM:8159A764                 beq     you_fail_it
RAM:8159A768                 addi    %r30, %r30, 1
RAM:8159A76C                 addi    %r31, %r31, 0xA94
RAM:8159A770                 cmplwi  %r30, 3
RAM:8159A774                 blt     check_backup_saveslots
RAM:8159A778                 li      %r29, 1
RAM:8159A77C
RAM:8159A77C you_fail_it:                            # CODE XREF: WADCheckSavedataZD+3Cj
RAM:8159A77C                                         # WADCheckSavedataZD+50j
RAM:8159A77C                                         # WADCheckSavedataZD+64j ...
RAM:8159A77C                 lwz     %r31, 0x20+var_4(%sp)
RAM:8159A780                 mr      %r3, %r29
RAM:8159A784                 lwz     %r30, 0x20+var_8(%sp)
RAM:8159A788                 lwz     %r29, 0x20+var_C(%sp)
RAM:8159A78C                 lwz     %r28, 0x20+var_10(%sp)
RAM:8159A790                 lwz     %r0, 0x20+arg_4(%sp)
RAM:8159A794                 mtlr    %r0
RAM:8159A798                 addi    %sp, %sp, 0x20
RAM:8159A79C                 blr
RAM:8159A79C # End of function WADCheckSavedataZD
RAM:8159A79C
RAM:8159A7A0
RAM:8159A7A0 # =============== S U B R O U T I N E =======================================
RAM:8159A7A0
RAM:8159A7A0
RAM:8159A7A0 call_wadCheckSavedataZD:                # CODE XREF: cc_wadcheckzelda+20Cp
RAM:8159A7A0
RAM:8159A7A0 .set arg_0,  0
RAM:8159A7A0 .set arg_20,  0x20
RAM:8159A7A0 .set arg_24,  0x24
RAM:8159A7A0 .set arg_40,  0x40
RAM:8159A7A0
RAM:8159A7A0                 clrlwi  %r11, %sp, 27
RAM:8159A7A4                 mr      %r12, %sp
RAM:8159A7A8                 subfic  %r11, %r11, -0x100
RAM:8159A7AC                 stwux   %sp, %sp, %r11
RAM:8159A7B0                 mflr    %r0
RAM:8159A7B4                 mr      %r11, %r12
RAM:8159A7B8                 stw     %r0, 4(%r12)
RAM:8159A7BC                 bl      savegpr23
RAM:8159A7C0                 addi    %r0, %sp, arg_40
RAM:8159A7C4                 li      %r26, 0
RAM:8159A7C8                 stw     %r0, arg_24(%sp)
RAM:8159A7CC                 mr      %r23, %r3
RAM:8159A7D0                 mr      %r28, %r4
RAM:8159A7D4                 mr      %r29, %r5
RAM:8159A7D8                 stw     %r26, arg_20(%sp)
RAM:8159A7DC                 mr      %r30, %r6
RAM:8159A7E0                 li      %r24, 0
RAM:8159A7E4                 li      %r31, 0
RAM:8159A7E8                 li      %r25, 0
RAM:8159A7EC                 lis     %r27, ((a_zeldaTp_dat+0x10000)@h) # "zeldaTp.dat"
RAM:8159A7F0                 b       loc_8159A920
RAM:8159A7F4 # ---------------------------------------------------------------------------
RAM:8159A7F4
RAM:8159A7F4 loc_8159A7F4:                           # CODE XREF: call_wadCheckSavedataZD+188j
RAM:8159A7F4                 mr      %r3, %r28
RAM:8159A7F8                 addi    %r4, %sp, arg_24
RAM:8159A7FC                 add     %r6, %r30, %r24
RAM:8159A800                 li      %r5, 0x80
RAM:8159A804                 bl      WADReadStream
RAM:8159A808                 cmplwi  %r3, 0x80
RAM:8159A80C                 beq     loc_8159A818
RAM:8159A810                 li      %r26, -0xBBD
RAM:8159A814                 b       loc_8159A92C
RAM:8159A818 # ---------------------------------------------------------------------------
RAM:8159A818
RAM:8159A818 loc_8159A818:                           # CODE XREF: call_wadCheckSavedataZD+6Cj
RAM:8159A818                 lwz     %r3, arg_24(%sp)
RAM:8159A81C                 addi    %r0, %r24, 0xBF
RAM:8159A820                 clrrwi  %r24, %r0, 6
RAM:8159A824                 li      %r26, 0
RAM:8159A828                 addi    %r3, %r3, 0xB
RAM:8159A82C                 li      %r4, '/'
RAM:8159A830                 bl      strrchr
RAM:8159A834                 cmpwi   %r3, 0
RAM:8159A838                 bne     loc_8159A844
RAM:8159A83C                 lwz     %r3, arg_24(%sp)
RAM:8159A840                 addi    %r3, %r3, 0xB
RAM:8159A844
RAM:8159A844 loc_8159A844:                           # CODE XREF: call_wadCheckSavedataZD+98j
RAM:8159A844                 addi    %r4, %r27, -0x2DC0 # a_zeldaTp_dat
RAM:8159A848                 bl      strcmp
RAM:8159A84C                 cmpwi   %r3, 0
RAM:8159A850                 bne     loc_8159A908
RAM:8159A854                 lwz     %r4, arg_24(%sp)
RAM:8159A858                 mr      %r3, %r29
RAM:8159A85C                 lwz     %r4, 4(%r4)
RAM:8159A860                 addi    %r0, %r4, 0x1F
RAM:8159A864                 clrrwi  %r25, %r0, 5
RAM:8159A868                 mr      %r4, %r25
RAM:8159A86C                 bl      mutex_sth
RAM:8159A870                 cmpwi   %r3, 0
RAM:8159A874                 stw     %r3, arg_20(%sp)
RAM:8159A878                 bne     loc_8159A884
RAM:8159A87C                 li      %r26, -0xBBB
RAM:8159A880                 b       loc_8159A92C
RAM:8159A884 # ---------------------------------------------------------------------------
RAM:8159A884
RAM:8159A884 loc_8159A884:                           # CODE XREF: call_wadCheckSavedataZD+D8j
RAM:8159A884                 mr      %r3, %r29
RAM:8159A888                 mr      %r4, %r25
RAM:8159A88C                 bl      mutex_sth
RAM:8159A890                 cmpwi   %r3, 0
RAM:8159A894                 mr      %r31, %r3
RAM:8159A898                 bne     loc_8159A8A4
RAM:8159A89C                 li      %r26, -0xBBB
RAM:8159A8A0                 b       loc_8159A92C
RAM:8159A8A4 # ---------------------------------------------------------------------------
RAM:8159A8A4
RAM:8159A8A4 loc_8159A8A4:                           # CODE XREF: call_wadCheckSavedataZD+F8j
RAM:8159A8A4                 mr      %r3, %r28
RAM:8159A8A8                 mr      %r5, %r25
RAM:8159A8AC                 addi    %r4, %sp, arg_20
RAM:8159A8B0                 add     %r6, %r30, %r24
RAM:8159A8B4                 bl      WADReadStream
RAM:8159A8B8                 cmplw   %r3, %r25
RAM:8159A8BC                 beq     loc_8159A8C8
RAM:8159A8C0                 li      %r26, -0xBBD
RAM:8159A8C4                 b       loc_8159A92C
RAM:8159A8C8 # ---------------------------------------------------------------------------
RAM:8159A8C8
RAM:8159A8C8 loc_8159A8C8:                           # CODE XREF: call_wadCheckSavedataZD+11Cj
RAM:8159A8C8                 lwz     %r3, arg_24(%sp)
RAM:8159A8CC                 mr      %r6, %r25       # int
RAM:8159A8D0                 lwz     %r5, arg_20(%sp) # int
RAM:8159A8D4                 mr      %r7, %r31       # int
RAM:8159A8D8                 addi    %r4, %r3, 0x50  # int
RAM:8159A8DC                 li      %r3, 6          # int
RAM:8159A8E0                 bl      sub_81595AE8
RAM:8159A8E4                 cmpwi   %r3, 0
RAM:8159A8E8                 mr      %r26, %r3
RAM:8159A8EC                 bne     loc_8159A92C
RAM:8159A8F0                 mr      %r3, %r31
RAM:8159A8F4                 bl      WADCheckSavedataZD
RAM:8159A8F8                 cmpwi   %r3, 0
RAM:8159A8FC                 bne     loc_8159A92C
RAM:8159A900                 li      %r26, -0xBC1
RAM:8159A904                 b       loc_8159A92C
RAM:8159A908 # ---------------------------------------------------------------------------
RAM:8159A908
RAM:8159A908 loc_8159A908:                           # CODE XREF: call_wadCheckSavedataZD+B0j
RAM:8159A908                 lwz     %r3, arg_24(%sp)
RAM:8159A90C                 addi    %r25, %r25, 1
RAM:8159A910                 lwz     %r0, 4(%r3)
RAM:8159A914                 add     %r24, %r24, %r0
RAM:8159A918                 addi    %r0, %r24, 0x3F
RAM:8159A91C                 clrrwi  %r24, %r0, 6
RAM:8159A920
RAM:8159A920 loc_8159A920:                           # CODE XREF: call_wadCheckSavedataZD+50j
RAM:8159A920                 lwz     %r0, 0xC(%r23)
RAM:8159A924                 cmplw   %r25, %r0
RAM:8159A928                 blt     loc_8159A7F4
RAM:8159A92C
RAM:8159A92C loc_8159A92C:                           # CODE XREF: call_wadCheckSavedataZD+74j
RAM:8159A92C                                         # call_wadCheckSavedataZD+E0j
RAM:8159A92C                                         # call_wadCheckSavedataZD+100j ...
RAM:8159A92C                 lwz     %r4, arg_20(%sp)
RAM:8159A930                 cmpwi   %r4, 0
RAM:8159A934                 beq     loc_8159A948
RAM:8159A938                 mr      %r3, %r29
RAM:8159A93C                 bl      WADCallFree
RAM:8159A940                 li      %r0, 0
RAM:8159A944                 stw     %r0, arg_20(%sp)
RAM:8159A948
RAM:8159A948 loc_8159A948:                           # CODE XREF: call_wadCheckSavedataZD+194j
RAM:8159A948                 cmpwi   %r31, 0
RAM:8159A94C                 beq     loc_8159A95C
RAM:8159A950                 mr      %r3, %r29
RAM:8159A954                 mr      %r4, %r31
RAM:8159A958                 bl      WADCallFree
RAM:8159A95C
RAM:8159A95C loc_8159A95C:                           # CODE XREF: call_wadCheckSavedataZD+1ACj
RAM:8159A95C                 mr      %r3, %r26
RAM:8159A960                 lwz     %r10, arg_0(%sp)
RAM:8159A964                 mr      %r11, %r10
RAM:8159A968                 bl      restgpr23
RAM:8159A96C                 lwz     %r0, 4(%r10)
RAM:8159A970                 mtlr    %r0
RAM:8159A974                 mr      %sp, %r10
RAM:8159A978                 blr
RAM:8159A978 # End of function call_wadCheckSavedataZD
RAM:81598330
RAM:81598330 # =============== S U B R O U T I N E =======================================
RAM:81598330
RAM:81598330
RAM:81598330 mutex_sth:                              # CODE XREF: WADImportGetBlocks+2B0p
RAM:81598330                                         # sub_815965D0+220p
RAM:81598330                                         # sub_815965D0+368p ...
RAM:81598330
RAM:81598330 .set var_4, -4
RAM:81598330 .set arg_4,  4
RAM:81598330
RAM:81598330                 stwu    %sp, -0x10(%sp)
RAM:81598334                 mflr    %r0
RAM:81598338                 cmpwi   %r3, 0
RAM:8159833C                 stw     %r0, 0x10+arg_4(%sp)
RAM:81598340                 li      %r0, 0
RAM:81598344                 stw     %r31, 0x10+var_4(%sp)
RAM:81598348                 mr      %r31, %r3
RAM:8159834C                 beq     loc_81598418
RAM:81598350                 lwz     %r3, 4(%r3)
RAM:81598354                 cmpwi   %r3, 0
RAM:81598358                 beq     loc_81598418
RAM:8159835C                 lis     %r5, 'FR'
RAM:81598360                 lwz     %r6, 0(%r3)
RAM:81598364                 addi    %r0, %r5, 'MH'
RAM:81598368                 cmpw    %r6, %r0
RAM:8159836C                 beq     loc_815983A4
RAM:81598370                 bge     loc_81598388
RAM:81598374                 lis     %r5, 'EX'
RAM:81598378                 addi    %r0, %r5, 'PH'
RAM:8159837C                 cmpw    %r6, %r0
RAM:81598380                 beq     loc_8159839C
RAM:81598384                 b       loc_815983B4
RAM:81598388 # ---------------------------------------------------------------------------
RAM:81598388
RAM:81598388 loc_81598388:                           # CODE XREF: mutex_sth+40j
RAM:81598388                 lis     %r5, 'UN'
RAM:8159838C                 addi    %r0, %r5, 'TH'
RAM:81598390                 cmpw    %r6, %r0
RAM:81598394                 beq     loc_815983AC
RAM:81598398                 b       loc_815983B4
RAM:8159839C # ---------------------------------------------------------------------------
RAM:8159839C
RAM:8159839C loc_8159839C:                           # CODE XREF: mutex_sth+50j
RAM:8159839C                 li      %r0, 0
RAM:815983A0                 b       loc_815983B8
RAM:815983A4 # ---------------------------------------------------------------------------
RAM:815983A4
RAM:815983A4 loc_815983A4:                           # CODE XREF: mutex_sth+3Cj
RAM:815983A4                 li      %r0, 1
RAM:815983A8                 b       loc_815983B8
RAM:815983AC # ---------------------------------------------------------------------------
RAM:815983AC
RAM:815983AC loc_815983AC:                           # CODE XREF: mutex_sth+64j
RAM:815983AC                 li      %r0, 2
RAM:815983B0                 b       loc_815983B8
RAM:815983B4 # ---------------------------------------------------------------------------
RAM:815983B4
RAM:815983B4 loc_815983B4:                           # CODE XREF: mutex_sth+54j
RAM:815983B4                                         # mutex_sth+68j
RAM:815983B4                 li      %r0, 3
RAM:815983B8
RAM:815983B8 loc_815983B8:                           # CODE XREF: mutex_sth+70j
RAM:815983B8                                         # mutex_sth+78j mutex_sth+80j
RAM:815983B8                 cmpwi   %r0, 1
RAM:815983BC                 beq     loc_815983E4
RAM:815983C0                 bge     loc_815983F4
RAM:815983C4                 cmpwi   %r0, 0
RAM:815983C8                 bge     loc_815983D4
RAM:815983CC                 b       loc_815983F4
RAM:815983D0 # ---------------------------------------------------------------------------
RAM:815983D0                 b       loc_815983F4
RAM:815983D4 # ---------------------------------------------------------------------------
RAM:815983D4
RAM:815983D4 loc_815983D4:                           # CODE XREF: mutex_sth+98j
RAM:815983D4                 li      %r5, 0x40
RAM:815983D8                 bl      sub_8153292C
RAM:815983DC                 mr      %r0, %r3
RAM:815983E0                 b       loc_81598418
RAM:815983E4 # ---------------------------------------------------------------------------
RAM:815983E4
RAM:815983E4 loc_815983E4:                           # CODE XREF: mutex_sth+8Cj
RAM:815983E4                 li      %r5, 0x40
RAM:815983E8                 bl      sub_81533024
RAM:815983EC                 mr      %r0, %r3
RAM:815983F0                 b       loc_81598418
RAM:815983F4 # ---------------------------------------------------------------------------
RAM:815983F4
RAM:815983F4 loc_815983F4:                           # CODE XREF: mutex_sth+90j
RAM:815983F4                                         # mutex_sth+9Cj mutex_sth+A0j
RAM:815983F4                 mr      %r3, %r31
RAM:815983F8                 bl      sub_81533840
RAM:815983FC # ---------------------------------------------------------------------------
RAM:815983FC                 clrlwi. %r0, %r3, 26
RAM:81598400                 mr      %r0, %r3
RAM:81598404                 beq     loc_81598418
RAM:81598408                 mr      %r3, %r31
RAM:8159840C                 mr      %r4, %r0
RAM:81598410                 bl      sub_81533850
RAM:81598414 # ---------------------------------------------------------------------------
RAM:81598414                 li      %r0, 0
RAM:81598418
RAM:81598418 loc_81598418:                           # CODE XREF: mutex_sth+1Cj
RAM:81598418                                         # mutex_sth+28j mutex_sth+B0j ...
RAM:81598418                 mr      %r3, %r0
RAM:8159841C                 lwz     %r31, 0x10+var_4(%sp)
RAM:81598420                 lwz     %r0, 0x10+arg_4(%sp)
RAM:81598424                 mtlr    %r0
RAM:81598428                 addi    %sp, %sp, 0x10
RAM:8159842C                 blr
RAM:8159842C # End of function mutex_sth