diff --git a/asm/code_08128BEC.s b/asm/code_08128BEC.s index 0a333d7..ad82f20 100644 --- a/asm/code_08128BEC.s +++ b/asm/code_08128BEC.s @@ -5,1673 +5,6 @@ .text - thumb_func_start sub_08131C20 -sub_08131C20: @ 0x08131C20 - push {r4, r5, r6, lr} - adds r4, r0, #0 - adds r6, r4, #0 - adds r6, #0xa4 - ldrh r3, [r6] - movs r2, #1 - ands r2, r3 - cmp r2, #0 - bne _08131C7E - ldr r5, _08131C84 @ =gUnk_08372944 - adds r0, #0xb3 - ldrb r0, [r0] - adds r0, r0, r5 - adds r1, r4, #0 - adds r1, #0xb2 - ldrb r1, [r1] - adds r1, r1, r5 - ldrb r0, [r0] - ldrb r1, [r1] - cmp r0, r1 - bls _08131C7E - movs r0, #1 - orrs r0, r3 - movs r1, #0x10 - orrs r0, r1 - strh r0, [r6] - adds r0, r4, #0 - adds r0, #0xa2 - strh r2, [r0] - adds r0, r4, #0 - movs r1, #0 - movs r2, #0x20 - bl sub_081332D0 - lsls r0, r0, #0x18 - lsrs r0, r0, #0x18 - adds r0, r0, r5 - adds r1, r4, #0 - adds r1, #0xa8 - ldrh r1, [r1] - lsls r1, r1, #0x10 - asrs r1, r1, #0x18 - ldrb r0, [r0] - adds r1, r1, r0 - adds r0, r4, #0 - adds r0, #0xa0 - strb r1, [r0] -_08131C7E: - pop {r4, r5, r6} - pop {r0} - bx r0 - .align 2, 0 -_08131C84: .4byte gUnk_08372944 - - thumb_func_start sub_08131C88 -sub_08131C88: @ 0x08131C88 - push {r4, r5, lr} - mov ip, r0 - mov r5, ip - adds r5, #0xa4 - ldrh r4, [r5] - movs r0, #1 - ands r0, r4 - cmp r0, #0 - beq _08131D14 - mov r0, ip - adds r0, #0xa0 - movs r1, #0 - ldrsb r1, [r0, r1] - mov r2, ip - adds r2, #0xa2 - ldrh r0, [r2] - muls r1, r0, r1 - movs r3, #0 - ldrsh r0, [r2, r3] - adds r3, r0, #0 - muls r3, r0, r3 - mov r0, ip - adds r0, #0xa1 - ldrb r0, [r0] - lsls r0, r0, #0x18 - asrs r0, r0, #0x18 - muls r0, r3, r0 - asrs r0, r0, #1 - subs r1, r1, r0 - lsls r1, r1, #0x10 - asrs r1, r1, #0x10 - adds r3, r2, #0 - cmp r1, #0 - bge _08131CF0 - ldr r0, _08131CE8 @ =0x0000FFFE - ands r0, r4 - movs r2, #0 - ldr r1, _08131CEC @ =0x0000FFEF - ands r0, r1 - strh r0, [r5] - strh r2, [r3] - mov r1, ip - adds r1, #0xac - mov r0, ip - adds r0, #0xc4 - ldr r0, [r0] - str r0, [r1] - b _08131D4C - .align 2, 0 -_08131CE8: .4byte 0x0000FFFE -_08131CEC: .4byte 0x0000FFEF -_08131CF0: - cmp r1, #0x1f - ble _08131D04 - mov r1, ip - adds r1, #0xaa - ldr r0, _08131D00 @ =0x0000FFE0 - strh r0, [r1] - b _08131D0C - .align 2, 0 -_08131D00: .4byte 0x0000FFE0 -_08131D04: - rsbs r1, r1, #0 - mov r0, ip - adds r0, #0xaa - strh r1, [r0] -_08131D0C: - ldrh r0, [r3] - adds r0, #1 - strh r0, [r3] - b _08131D4C -_08131D14: - mov r2, ip - adds r2, #0xa2 - movs r1, #0 - ldrsh r0, [r2, r1] - adds r1, r0, #0 - muls r1, r0, r1 - mov r0, ip - adds r0, #0xa1 - ldrb r0, [r0] - lsls r0, r0, #0x18 - asrs r0, r0, #0x18 - muls r0, r1, r0 - lsls r0, r0, #0xf - lsrs r1, r0, #0x10 - asrs r0, r0, #0x10 - cmp r0, #0xf - ble _08131D40 - mov r1, ip - adds r1, #0xaa - movs r0, #0x10 - strh r0, [r1] - b _08131D4C -_08131D40: - mov r0, ip - adds r0, #0xaa - strh r1, [r0] - ldrh r0, [r2] - adds r0, #1 - strh r0, [r2] -_08131D4C: - pop {r4, r5} - pop {r0} - bx r0 - .align 2, 0 - - thumb_func_start sub_08131D54 -sub_08131D54: @ 0x08131D54 - push {r4, r5, r6, lr} - adds r4, r0, #0 - adds r5, r4, #0 - adds r5, #0xb0 - ldrh r0, [r5] - ldr r1, _08131EE8 @ =0x0000FFE0 - ands r1, r0 - strh r1, [r5] - adds r0, r4, #0 - movs r1, #0 - movs r2, #0 - bl sub_081332D0 - lsls r0, r0, #0x18 - cmp r0, #0 - beq _08131DAC - adds r0, r4, #0 - movs r1, #0 - movs r2, #0 - bl sub_081332D0 - lsls r0, r0, #0x18 - lsrs r0, r0, #0x18 - cmp r0, #0xe - beq _08131D98 - adds r0, r4, #0 - movs r1, #0 - movs r2, #0 - bl sub_081332D0 - lsls r0, r0, #0x18 - lsrs r0, r0, #0x18 - cmp r0, #0xf - bne _08131DA0 -_08131D98: - ldrh r0, [r5] - movs r1, #0x20 - orrs r0, r1 - strh r0, [r5] -_08131DA0: - adds r2, r4, #0 - adds r2, #0xb0 - ldrh r1, [r2] - movs r0, #1 - orrs r0, r1 - strh r0, [r2] -_08131DAC: - movs r5, #0x20 - rsbs r5, r5, #0 - adds r0, r4, #0 - adds r1, r5, #0 - movs r2, #0 - bl sub_081332D0 - lsls r0, r0, #0x18 - cmp r0, #0 - beq _08131DCC - adds r2, r4, #0 - adds r2, #0xb0 - ldrh r1, [r2] - movs r0, #2 - orrs r0, r1 - strh r0, [r2] -_08131DCC: - adds r0, r4, #0 - movs r1, #0 - adds r2, r5, #0 - bl sub_081332D0 - lsls r0, r0, #0x18 - cmp r0, #0 - beq _08131E1A - adds r0, r4, #0 - movs r1, #0 - movs r2, #0 - bl sub_081332D0 - lsls r0, r0, #0x18 - lsrs r0, r0, #0x18 - cmp r0, #0xe - beq _08131E04 - adds r0, r4, #0 - movs r1, #0 - movs r2, #0 - bl sub_081332D0 - lsls r0, r0, #0x18 - lsrs r0, r0, #0x18 - adds r2, r4, #0 - adds r2, #0xb0 - cmp r0, #0xf - bne _08131E12 -_08131E04: - adds r0, r4, #0 - adds r0, #0xb0 - ldrh r2, [r0] - movs r1, #0x20 - orrs r1, r2 - strh r1, [r0] - adds r2, r0, #0 -_08131E12: - ldrh r1, [r2] - movs r0, #4 - orrs r0, r1 - strh r0, [r2] -_08131E1A: - adds r0, r4, #0 - movs r1, #0x20 - movs r2, #0 - bl sub_081332D0 - lsls r0, r0, #0x18 - cmp r0, #0 - beq _08131E36 - adds r2, r4, #0 - adds r2, #0xb0 - ldrh r1, [r2] - movs r0, #8 - orrs r0, r1 - strh r0, [r2] -_08131E36: - adds r0, r4, #0 - movs r1, #0 - movs r2, #0x20 - bl sub_081332D0 - lsls r0, r0, #0x18 - cmp r0, #0 - bne _08131E48 - b _08131F4C -_08131E48: - adds r0, r4, #0 - movs r1, #0 - movs r2, #0 - bl sub_081332D0 - lsls r0, r0, #0x18 - lsrs r0, r0, #0x18 - cmp r0, #0xe - beq _08131E70 - adds r0, r4, #0 - movs r1, #0 - movs r2, #0 - bl sub_081332D0 - lsls r0, r0, #0x18 - lsrs r0, r0, #0x18 - adds r2, r4, #0 - adds r2, #0xb0 - cmp r0, #0xf - bne _08131E7E -_08131E70: - adds r0, r4, #0 - adds r0, #0xb0 - ldrh r2, [r0] - movs r1, #0x20 - orrs r1, r2 - strh r1, [r0] - adds r2, r0, #0 -_08131E7E: - ldrh r0, [r2] - movs r1, #0x10 - movs r6, #0 - orrs r1, r0 - strh r1, [r2] - adds r3, r4, #0 - adds r3, #0xac - ldr r0, [r3] - adds r5, r4, #0 - adds r5, #0x94 - cmp r0, #0 - beq _08131EF6 - adds r2, r4, #0 - adds r2, #0xa4 - ldrh r1, [r2] - movs r0, #0x40 - ands r0, r1 - lsls r0, r0, #0x10 - lsrs r0, r0, #0x10 - cmp r0, #0 - beq _08131EF4 - ldr r0, _08131EEC @ =0x0000FFBF - ands r0, r1 - strh r0, [r2] - adds r1, r4, #0 - adds r1, #0xc4 - ldr r0, [r3] - ldr r1, [r1] - subs r0, r0, r1 - str r0, [r3] - movs r1, #0x60 - rsbs r1, r1, #0 - cmp r0, r1 - bgt _08131EF6 - ldrh r0, [r2] - movs r1, #0x80 - orrs r0, r1 - strh r0, [r2] - movs r0, #0 - str r0, [r3] - adds r0, r4, #0 - adds r0, #0xe4 - strb r6, [r0] - ldrh r1, [r5] - movs r0, #2 - ands r0, r1 - cmp r0, #0 - beq _08131F70 - ldr r0, _08131EF0 @ =0x0000022E - bl m4aSongNumStart - b _08131EF6 - .align 2, 0 -_08131EE8: .4byte 0x0000FFE0 -_08131EEC: .4byte 0x0000FFBF -_08131EF0: .4byte 0x0000022E -_08131EF4: - str r0, [r3] -_08131EF6: - ldrh r1, [r5] - movs r0, #2 - ands r0, r1 - cmp r0, #0 - beq _08131F70 - adds r0, r4, #0 - movs r1, #0 - movs r2, #0x20 - bl sub_081332D0 - lsls r0, r0, #0x18 - lsrs r0, r0, #0x18 - cmp r0, #1 - bne _08131F3A - adds r0, r4, #0 - adds r0, #0xb3 - ldrb r0, [r0] - cmp r0, #1 - bne _08131F2E - adds r4, #0x90 - ldr r0, [r4] - bl sub_08134720 - ldr r0, [r4] - movs r1, #1 - bl sub_08133688 - b _08131F70 -_08131F2E: - adds r0, r4, #0 - adds r0, #0x90 - ldr r0, [r0] - bl sub_08134754 - b _08131F70 -_08131F3A: - adds r4, #0x90 - ldr r0, [r4] - bl sub_08134720 - ldr r0, [r4] - movs r1, #0 - bl sub_08133688 - b _08131F70 -_08131F4C: - adds r2, r4, #0 - adds r2, #0xa4 - ldrh r1, [r2] - movs r0, #0x40 - orrs r0, r1 - strh r0, [r2] - adds r0, r4, #0 - adds r0, #0x94 - ldrh r1, [r0] - movs r0, #2 - ands r0, r1 - cmp r0, #0 - beq _08131F70 - adds r0, r4, #0 - adds r0, #0x90 - ldr r0, [r0] - bl sub_08134754 -_08131F70: - pop {r4, r5, r6} - pop {r0} - bx r0 - .align 2, 0 - - thumb_func_start sub_08131F78 -sub_08131F78: @ 0x08131F78 - push {r4, r5, r6, r7, lr} - mov r7, sl - mov r6, sb - mov r5, r8 - push {r5, r6, r7} - sub sp, #4 - adds r6, r0, #0 - adds r2, r6, #0 - adds r2, #0xc4 - ldr r0, [r2] - lsls r0, r0, #0xb - lsrs r1, r0, #0x10 - adds r0, r6, #0 - adds r0, #0xb0 - ldrh r3, [r0] - movs r0, #1 - ands r0, r3 - cmp r0, #0 - bne _08131FA6 - movs r0, #0x10 - ands r0, r3 - cmp r0, #0 - beq _0813201C -_08131FA6: - mov sl, r2 - movs r0, #0xc0 - adds r0, r0, r6 - mov r8, r0 - adds r7, r6, #0 - adds r7, #0xd4 - adds r2, r6, #0 - adds r2, #0xd0 - str r2, [sp] - b _08131FC6 -_08131FBA: - subs r0, r4, #1 - lsls r0, r0, #0x10 - lsrs r1, r0, #0x10 - cmp r0, #0 - bge _08131FC6 - movs r1, #0 -_08131FC6: - ldr r0, _0813202C @ =gUnk_08372954 - mov sb, r0 - mov r2, r8 - ldr r0, [r2] - lsls r1, r1, #0x10 - asrs r4, r1, #0x10 - lsls r5, r4, #5 - ldr r2, [r7] - adds r1, r5, #0 - bl sub_081332FC - lsls r0, r0, #0x18 - lsrs r0, r0, #0x18 - add r0, sb - ldrb r0, [r0] - cmp r0, #0 - bne _08131FBA - mov r0, sl - str r5, [r0] - adds r0, r6, #0 - movs r1, #0 - movs r2, #0x20 - bl sub_081332D0 - lsls r0, r0, #0x18 - lsrs r0, r0, #0x18 - add r0, sb - ldrb r2, [r0] - ldr r3, _08132030 @ =gUnk_08372964 - mov r1, r8 - ldr r0, [r1] - asrs r0, r0, #2 - movs r1, #7 - ands r0, r1 - lsls r2, r2, #3 - adds r0, r0, r2 - adds r0, r0, r3 - ldrb r0, [r0] - lsls r0, r0, #0x18 - asrs r0, r0, #0x18 - lsls r0, r0, #2 - ldr r2, [sp] - strh r0, [r2] -_0813201C: - add sp, #4 - pop {r3, r4, r5} - mov r8, r3 - mov sb, r4 - mov sl, r5 - pop {r4, r5, r6, r7} - pop {r0} - bx r0 - .align 2, 0 -_0813202C: .4byte gUnk_08372954 -_08132030: .4byte gUnk_08372964 - - thumb_func_start sub_08132034 -sub_08132034: @ 0x08132034 - push {r4, r5, r6, r7, lr} - mov r7, sl - mov r6, sb - mov r5, r8 - push {r5, r6, r7} - sub sp, #0x10 - mov ip, r0 - str r1, [sp] - lsls r2, r2, #0x18 - lsrs r2, r2, #0x18 - str r2, [sp, #4] - movs r7, #0 - cmp r7, r2 - bhs _08132148 - adds r0, #0xc0 - ldr r0, [r0] - str r0, [sp, #8] - ldr r0, _08132158 @ =0xFFFFFF00 - mov sl, r0 - movs r1, #1 - mov sb, r1 -_0813205E: - lsls r0, r7, #2 - adds r0, r0, r7 - lsls r0, r0, #2 - mov r8, r0 - ldr r3, [sp] - add r3, r8 - ldrh r0, [r3, #0x12] - ldr r5, _0813215C @ =0x0000FF0E - ands r5, r0 - strh r5, [r3, #0x12] - movs r2, #0 - ldr r0, [sp, #8] - add r0, sl - ldr r1, [r3] - cmp r0, r1 - bgt _08132080 - movs r2, #1 -_08132080: - movs r4, #0 - movs r6, #0xb0 - lsls r6, r6, #2 - ldr r0, [sp, #8] - adds r0, r0, r6 - str r0, [sp, #0xc] - cmp r1, r0 - bgt _08132092 - movs r4, #1 -_08132092: - ands r2, r4 - cmp r2, #0 - beq _081320A4 - adds r0, r5, #0 - mov r1, sb - orrs r0, r1 - movs r1, #0x10 - orrs r0, r1 - strh r0, [r3, #0x12] -_081320A4: - movs r2, #0 - movs r0, #0xd6 - lsls r0, r0, #1 - add r0, ip - ldr r1, [r0] - mov r4, sl - adds r0, r1, r4 - ldr r5, [r3] - cmp r0, r5 - bgt _081320BA - movs r2, #1 -_081320BA: - movs r4, #0 - adds r0, r1, r6 - cmp r5, r0 - bgt _081320C4 - movs r4, #1 -_081320C4: - ands r2, r4 - cmp r2, #0 - beq _081320D6 - ldrh r0, [r3, #0x12] - mov r1, sb - orrs r0, r1 - movs r1, #0x20 - orrs r0, r1 - strh r0, [r3, #0x12] -_081320D6: - movs r2, #0 - movs r0, #0xa6 - lsls r0, r0, #2 - add r0, ip - ldr r1, [r0] - mov r4, sl - adds r0, r1, r4 - cmp r0, r5 - bgt _081320EA - movs r2, #1 -_081320EA: - movs r4, #0 - adds r0, r1, r6 - cmp r5, r0 - bgt _081320F4 - movs r4, #1 -_081320F4: - ands r2, r4 - cmp r2, #0 - beq _08132106 - ldrh r0, [r3, #0x12] - mov r1, sb - orrs r0, r1 - movs r1, #0x40 - orrs r0, r1 - strh r0, [r3, #0x12] -_08132106: - movs r4, #0 - movs r0, #0xe1 - lsls r0, r0, #2 - add r0, ip - ldr r1, [r0] - mov r2, sl - adds r0, r1, r2 - cmp r0, r5 - bgt _0813211A - movs r4, #1 -_0813211A: - movs r5, #0 - ldr r3, [sp] - add r3, r8 - adds r1, r1, r6 - ldr r0, [r3] - cmp r0, r1 - bgt _0813212A - movs r5, #1 -_0813212A: - ands r4, r5 - cmp r4, #0 - beq _0813213C - ldrh r0, [r3, #0x12] - mov r4, sb - orrs r0, r4 - movs r1, #0x80 - orrs r0, r1 - strh r0, [r3, #0x12] -_0813213C: - adds r0, r7, #1 - lsls r0, r0, #0x18 - lsrs r7, r0, #0x18 - ldr r0, [sp, #4] - cmp r7, r0 - blo _0813205E -_08132148: - add sp, #0x10 - pop {r3, r4, r5} - mov r8, r3 - mov sb, r4 - mov sl, r5 - pop {r4, r5, r6, r7} - pop {r0} - bx r0 - .align 2, 0 -_08132158: .4byte 0xFFFFFF00 -_0813215C: .4byte 0x0000FF0E - - thumb_func_start sub_08132160 -sub_08132160: @ 0x08132160 - push {r4, r5, r6, r7, lr} - mov r7, sl - mov r6, sb - mov r5, r8 - push {r5, r6, r7} - sub sp, #0x10 - mov ip, r0 - str r1, [sp] - lsls r2, r2, #0x18 - lsrs r2, r2, #0x18 - str r2, [sp, #4] - movs r7, #0 - cmp r7, r2 - bhs _08132268 - adds r0, #0xc0 - ldr r0, [r0] - str r0, [sp, #8] - ldr r0, _08132278 @ =0xFFFFFF00 - mov sl, r0 - movs r1, #0xf1 - mov sb, r1 -_0813218A: - lsls r0, r7, #2 - adds r0, r0, r7 - lsls r0, r0, #2 - mov r8, r0 - ldr r2, [sp] - add r2, r8 - ldrh r0, [r2, #0x12] - ldr r3, _0813227C @ =0x0000FF0E - ands r3, r0 - strh r3, [r2, #0x12] - movs r4, #0 - ldr r0, [sp, #8] - add r0, sl - ldr r1, [r2] - cmp r0, r1 - bgt _081321AC - movs r4, #1 -_081321AC: - movs r5, #0 - str r5, [sp, #0xc] - movs r6, #0xb0 - lsls r6, r6, #2 - ldr r5, [sp, #8] - adds r0, r5, r6 - cmp r1, r0 - bgt _081321C0 - movs r0, #1 - str r0, [sp, #0xc] -_081321C0: - ldr r1, [sp, #0xc] - ands r4, r1 - cmp r4, #0 - beq _081321D0 - adds r0, r3, #0 - mov r5, sb - orrs r0, r5 - strh r0, [r2, #0x12] -_081321D0: - movs r4, #0 - movs r0, #0xd6 - lsls r0, r0, #1 - add r0, ip - ldr r3, [r0] - mov r1, sl - adds r0, r3, r1 - ldr r5, [r2] - cmp r0, r5 - bgt _081321E6 - movs r4, #1 -_081321E6: - movs r1, #0 - adds r0, r3, r6 - cmp r5, r0 - bgt _081321F0 - movs r1, #1 -_081321F0: - ands r4, r1 - cmp r4, #0 - beq _081321FE - ldrh r0, [r2, #0x12] - mov r1, sb - orrs r0, r1 - strh r0, [r2, #0x12] -_081321FE: - movs r4, #0 - movs r0, #0xa6 - lsls r0, r0, #2 - add r0, ip - ldr r3, [r0] - mov r1, sl - adds r0, r3, r1 - cmp r0, r5 - bgt _08132212 - movs r4, #1 -_08132212: - movs r1, #0 - adds r0, r3, r6 - cmp r5, r0 - bgt _0813221C - movs r1, #1 -_0813221C: - ands r4, r1 - cmp r4, #0 - beq _0813222A - ldrh r0, [r2, #0x12] - mov r1, sb - orrs r0, r1 - strh r0, [r2, #0x12] -_0813222A: - movs r4, #0 - movs r0, #0xe1 - lsls r0, r0, #2 - add r0, ip - ldr r1, [r0] - mov r2, sl - adds r0, r1, r2 - cmp r0, r5 - bgt _0813223E - movs r4, #1 -_0813223E: - movs r5, #0 - ldr r3, [sp] - add r3, r8 - adds r1, r1, r6 - ldr r0, [r3] - cmp r0, r1 - bgt _0813224E - movs r5, #1 -_0813224E: - ands r4, r5 - cmp r4, #0 - beq _0813225C - ldrh r0, [r3, #0x12] - mov r5, sb - orrs r0, r5 - strh r0, [r3, #0x12] -_0813225C: - adds r0, r7, #1 - lsls r0, r0, #0x18 - lsrs r7, r0, #0x18 - ldr r0, [sp, #4] - cmp r7, r0 - blo _0813218A -_08132268: - add sp, #0x10 - pop {r3, r4, r5} - mov r8, r3 - mov sb, r4 - mov sl, r5 - pop {r4, r5, r6, r7} - pop {r0} - bx r0 - .align 2, 0 -_08132278: .4byte 0xFFFFFF00 -_0813227C: .4byte 0x0000FF0E - - thumb_func_start sub_08132280 -sub_08132280: @ 0x08132280 - push {r4, r5, r6, r7, lr} - mov r7, sb - mov r6, r8 - push {r6, r7} - adds r6, r0, #0 - mov sb, r1 - lsls r2, r2, #0x18 - lsrs r2, r2, #0x18 - mov r8, r2 - movs r7, #0 - cmp r7, r8 - bhs _0813233E -_08132298: - lsls r0, r7, #2 - adds r0, r0, r7 - lsls r0, r0, #2 - mov r1, sb - adds r4, r0, r1 - ldrh r1, [r4, #0x12] - movs r0, #1 - ands r0, r1 - cmp r0, #0 - beq _08132334 - movs r5, #0 - ldr r0, [r4] - asrs r3, r0, #2 - adds r1, r3, #0 - subs r1, #0xe - adds r0, r6, #0 - adds r0, #0xc0 - ldr r0, [r0] - asrs r2, r0, #2 - cmp r1, r2 - bgt _081322C4 - movs r5, #1 -_081322C4: - movs r1, #0 - adds r0, r3, #0 - adds r0, #0xe - cmp r2, r0 - bgt _081322D0 - movs r1, #1 -_081322D0: - adds r3, r5, #0 - ands r3, r1 - movs r5, #0 - ldr r0, [r4, #4] - asrs r4, r0, #2 - adds r1, r4, #0 - subs r1, #0xe - adds r0, r6, #0 - adds r0, #0xc4 - ldr r0, [r0] - asrs r2, r0, #2 - cmp r1, r2 - bgt _081322EC - movs r5, #1 -_081322EC: - movs r1, #0 - adds r0, r4, #0 - adds r0, #0xe - cmp r2, r0 - bgt _081322F8 - movs r1, #1 -_081322F8: - ands r5, r1 - ands r3, r5 - cmp r3, #0 - beq _08132334 - adds r4, r6, #0 - adds r4, #0xa4 - ldrh r1, [r4] - movs r5, #0x80 - lsls r5, r5, #3 - adds r0, r5, #0 - ands r0, r1 - cmp r0, #0 - bne _08132334 - adds r0, r6, #0 - adds r0, #0x94 - ldrh r1, [r0] - movs r0, #2 - ands r0, r1 - cmp r0, #0 - beq _08132326 - ldr r0, _0813234C @ =0x00000235 - bl m4aSongNumStart -_08132326: - ldrh r1, [r4] - movs r2, #0x80 - lsls r2, r2, #1 - adds r0, r2, #0 - orrs r0, r1 - orrs r0, r5 - strh r0, [r4] -_08132334: - adds r0, r7, #1 - lsls r0, r0, #0x18 - lsrs r7, r0, #0x18 - cmp r7, r8 - blo _08132298 -_0813233E: - pop {r3, r4} - mov r8, r3 - mov sb, r4 - pop {r4, r5, r6, r7} - pop {r0} - bx r0 - .align 2, 0 -_0813234C: .4byte 0x00000235 - - thumb_func_start sub_08132350 -sub_08132350: @ 0x08132350 - push {r4, r5, lr} - adds r5, r0, #0 - adds r0, #0xa4 - ldrh r1, [r0] - movs r0, #0x10 - ands r0, r1 - cmp r0, #0 - bne _081323DC - adds r0, r5, #0 - adds r0, #0xb2 - ldrb r2, [r0] - adds r4, r0, #0 - cmp r2, #0 - beq _081323C2 - movs r0, #0x80 - ands r0, r1 - cmp r0, #0 - beq _081323A0 - adds r0, r5, #0 - adds r0, #0x94 - ldrh r1, [r0] - movs r0, #2 - ands r0, r1 - cmp r0, #0 - beq _0813238C - cmp r2, #1 - bne _0813238C - adds r0, r5, #0 - bl sub_08133804 -_0813238C: - adds r2, r5, #0 - adds r2, #0xa4 - ldrh r1, [r2] - ldr r0, _08132440 @ =0x0000FF7F - ands r0, r1 - strh r0, [r2] - adds r1, r5, #0 - adds r1, #0xbf - movs r0, #5 - strb r0, [r1] -_081323A0: - adds r2, r5, #0 - adds r2, #0xbf - ldrb r0, [r2] - movs r1, #0 - ldrsb r1, [r2, r1] - cmp r1, #0 - beq _081323C2 - cmp r1, #4 - beq _081323B6 - adds r0, #1 - strb r0, [r2] -_081323B6: - movs r0, #0 - ldrsb r0, [r2, r0] - cmp r0, #0xa - ble _081323C2 - movs r0, #0 - strb r0, [r2] -_081323C2: - adds r0, r5, #0 - adds r0, #0xa4 - ldrh r1, [r0] - movs r0, #0x10 - ands r0, r1 - cmp r0, #0 - bne _081323DC - ldrb r1, [r4] - cmp r1, #0 - beq _081323DC - adds r0, r5, #0 - adds r0, #0xbc - strb r1, [r0] -_081323DC: - movs r0, #0xbd - adds r0, r0, r5 - mov ip, r0 - ldrb r0, [r0] - adds r4, r5, #0 - adds r4, #0xbe - strb r0, [r4] - ldr r3, _08132444 @ =gUnk_083727B8 - adds r0, r5, #0 - adds r0, #0xbf - movs r1, #0 - ldrsb r1, [r0, r1] - ldr r2, _08132448 @ =gUnk_083727A8 - subs r0, #3 - ldrb r0, [r0] - adds r0, r0, r2 - movs r2, #0 - ldrsb r2, [r0, r2] - movs r0, #0xb - muls r0, r2, r0 - adds r1, r1, r0 - adds r1, r1, r3 - ldrb r2, [r1] - mov r1, ip - strb r2, [r1] - adds r3, r5, #0 - adds r3, #0xa4 - ldrh r1, [r3] - movs r0, #0x80 - lsls r0, r0, #3 - ands r0, r1 - cmp r0, #0 - beq _08132450 - adds r2, r5, #0 - adds r2, #0xb4 - ldrh r0, [r2] - adds r1, r0, #1 - strh r1, [r2] - lsls r0, r0, #0x10 - asrs r0, r0, #0x10 - cmp r0, #0x3c - ble _0813248A - ldrh r1, [r3] - ldr r0, _0813244C @ =0x0000FBFF - ands r0, r1 - strh r0, [r3] - movs r0, #0 - strh r0, [r2] - b _08132456 - .align 2, 0 -_08132440: .4byte 0x0000FF7F -_08132444: .4byte gUnk_083727B8 -_08132448: .4byte gUnk_083727A8 -_0813244C: .4byte 0x0000FBFF -_08132450: - ldrb r0, [r4] - cmp r0, r2 - beq _0813248A -_08132456: - ldr r4, _08132490 @ =gUnk_083726B8 - mov r0, ip - ldrb r1, [r0] - lsls r1, r1, #2 - ldr r3, _08132494 @ =gLanguage - ldrh r2, [r3] - lsls r0, r2, #2 - adds r0, r0, r2 - lsls r0, r0, #3 - adds r1, r1, r0 - adds r1, r1, r4 - ldrh r0, [r1] - strh r0, [r5, #0xc] - mov r0, ip - ldrb r1, [r0] - lsls r1, r1, #2 - ldrh r2, [r3] - lsls r0, r2, #2 - adds r0, r0, r2 - lsls r0, r0, #3 - adds r1, r1, r0 - adds r1, r1, r4 - ldrb r0, [r1, #2] - strb r0, [r5, #0x1a] - movs r0, #0xff - strb r0, [r5, #0x1b] -_0813248A: - pop {r4, r5} - pop {r0} - bx r0 - .align 2, 0 -_08132490: .4byte gUnk_083726B8 -_08132494: .4byte gLanguage - - thumb_func_start sub_08132498 -sub_08132498: @ 0x08132498 - push {r4, r5, lr} - adds r5, r0, #0 - adds r2, r5, #0 - adds r2, #0xa4 - ldrh r1, [r2] - movs r0, #0x80 - lsls r0, r0, #1 - ands r0, r1 - cmp r0, #0 - beq _0813253A - ldr r0, _081324C4 @ =0x0000FEFF - ands r0, r1 - strh r0, [r2] - ldr r0, _081324C8 @ =gLanguage - ldrh r0, [r0] - cmp r0, #5 - bhi _081324F4 - lsls r0, r0, #2 - ldr r1, _081324CC @ =_081324D0 - adds r0, r0, r1 - ldr r0, [r0] - mov pc, r0 - .align 2, 0 -_081324C4: .4byte 0x0000FEFF -_081324C8: .4byte gLanguage -_081324CC: .4byte _081324D0 -_081324D0: @ jump table - .4byte _081324E8 @ case 0 - .4byte _081324E8 @ case 1 - .4byte _081324E8 @ case 2 - .4byte _081324E8 @ case 3 - .4byte _081324E8 @ case 4 - .4byte _081324E8 @ case 5 -_081324E8: - ldr r0, _0813250C @ =0x00000347 - strh r0, [r5, #0xc] - movs r0, #0xb - strb r0, [r5, #0x1a] - movs r0, #0xff - strb r0, [r5, #0x1b] -_081324F4: - adds r0, r5, #0 - adds r0, #0x94 - ldrh r1, [r0] - movs r0, #2 - ands r0, r1 - cmp r0, #0 - beq _08132510 - adds r0, r5, #0 - bl sub_081340AC - b _08132514 - .align 2, 0 -_0813250C: .4byte 0x00000347 -_08132510: - bl sub_08134178 -_08132514: - adds r1, r5, #0 - adds r1, #0xa4 - ldrh r2, [r1] - movs r0, #1 - movs r4, #0 - movs r3, #0 - orrs r0, r2 - strh r0, [r1] - adds r0, r5, #0 - adds r0, #0xa2 - strh r3, [r0] - subs r1, #4 - movs r0, #4 - strb r0, [r1] - adds r0, r5, #0 - adds r0, #0xe4 - strb r4, [r0] - subs r0, #0x3c - strh r3, [r0] -_0813253A: - pop {r4, r5} - pop {r0} - bx r0 - - thumb_func_start sub_08132540 -sub_08132540: @ 0x08132540 - push {r4, r5, r6, lr} - mov ip, r0 - mov r5, ip - adds r5, #0xc0 - ldr r0, [r5] - ldr r6, _0813259C @ =0xFFFFFF00 - adds r0, r0, r6 - asrs r0, r0, #0xa - lsls r0, r0, #0x18 - lsrs r1, r0, #0x18 - cmp r0, #0 - bge _0813255A - movs r1, #0 -_0813255A: - mov r3, ip - adds r3, #0xd8 - ldr r4, _081325A0 @ =gUnk_0837EA54 - lsls r1, r1, #0x18 - asrs r1, r1, #0x18 - mov r2, ip - adds r2, #0xd4 - ldr r0, [r2] - adds r0, r0, r1 - ldrb r0, [r0] - lsls r0, r0, #2 - adds r0, r0, r4 - ldr r0, [r0] - str r0, [r3] - adds r3, #4 - ldr r0, [r2] - adds r1, r1, r0 - ldrb r0, [r1, #1] - lsls r0, r0, #2 - adds r0, r0, r4 - ldr r0, [r0] - str r0, [r3] - ldr r0, [r5] - adds r0, r0, r6 - asrs r1, r0, #2 - movs r0, #0xff - ands r1, r0 - mov r0, ip - adds r0, #0xe0 - strb r1, [r0] - pop {r4, r5, r6} - pop {r0} - bx r0 - .align 2, 0 -_0813259C: .4byte 0xFFFFFF00 -_081325A0: .4byte gUnk_0837EA54 - - thumb_func_start sub_081325A4 -sub_081325A4: @ 0x081325A4 - push {r4, r5, r6, r7, lr} - mov r7, r8 - push {r7} - adds r4, r0, #0 - ldr r0, _08132638 @ =0x0000044C - adds r2, r4, r0 - ldrh r1, [r2] - ldr r0, _0813263C @ =0x0000FEFF - ands r0, r1 - strh r0, [r2] - movs r5, #0 - ldr r1, _08132640 @ =0x00000524 - adds r0, r4, r1 - ldrb r0, [r0] - cmp r5, r0 - bhs _0813262E - movs r2, #0x88 - lsls r2, r2, #3 - adds r2, r2, r4 - mov r8, r2 - ldr r0, _08132638 @ =0x0000044C - adds r6, r4, r0 - subs r1, #0xe0 - adds r7, r4, r1 -_081325D4: - lsls r0, r5, #2 - adds r0, r0, r5 - lsls r3, r0, #2 - adds r0, r4, r3 - ldr r2, _08132644 @ =0x0000046E - adds r0, r0, r2 - ldrh r1, [r0] - ldr r0, _08132648 @ =0x00000579 - adds r2, r4, r0 - movs r0, #0x10 - ldrb r2, [r2] - lsls r0, r2 - ands r1, r0 - cmp r1, #0 - beq _0813261E - ldr r1, _0813264C @ =0x0000045C - adds r0, r4, r1 - adds r0, r0, r3 - ldr r0, [r0] - mov r2, r8 - str r0, [r2] - adds r1, #4 - adds r0, r4, r1 - adds r0, r0, r3 - ldr r0, [r0] - str r0, [r7] - movs r2, #0x83 - lsls r2, r2, #3 - adds r0, r4, r2 - bl sub_081288DC - ldrh r1, [r6] - movs r2, #0x80 - lsls r2, r2, #1 - adds r0, r2, #0 - orrs r0, r1 - strh r0, [r6] -_0813261E: - adds r0, r5, #1 - lsls r0, r0, #0x18 - lsrs r5, r0, #0x18 - ldr r1, _08132640 @ =0x00000524 - adds r0, r4, r1 - ldrb r0, [r0] - cmp r5, r0 - blo _081325D4 -_0813262E: - pop {r3} - mov r8, r3 - pop {r4, r5, r6, r7} - pop {r0} - bx r0 - .align 2, 0 -_08132638: .4byte 0x0000044C -_0813263C: .4byte 0x0000FEFF -_08132640: .4byte 0x00000524 -_08132644: .4byte 0x0000046E -_08132648: .4byte 0x00000579 -_0813264C: .4byte 0x0000045C - - thumb_func_start sub_08132650 -sub_08132650: @ 0x08132650 - push {r4, r5, r6, r7, lr} - mov r7, sl - mov r6, sb - mov r5, r8 - push {r5, r6, r7} - sub sp, #0x10 - adds r6, r0, #0 - adds r1, r6, #0 - adds r1, #0xe0 - ldr r0, [r1] - str r0, [sp] - movs r2, #0xe6 - lsls r2, r2, #1 - adds r0, r6, r2 - ldr r0, [r0] - str r0, [sp, #4] - adds r2, #0xec - adds r0, r6, r2 - ldr r0, [r0] - str r0, [sp, #8] - adds r2, #0xec - adds r0, r6, r2 - ldr r0, [r0] - str r0, [sp, #0xc] - movs r7, #0 - mov sl, r1 -_08132684: - movs r5, #0 - ldr r3, [sp, #0xc] - ldr r0, [sp, #8] - cmp r3, r0 - bge _08132690 - adds r3, r0, #0 -_08132690: - ldr r0, [sp, #4] - cmp r3, r0 - bge _08132698 - adds r3, r0, #0 -_08132698: - ldr r0, [sp] - cmp r3, r0 - bge _081326A0 - adds r3, r0, #0 -_081326A0: - movs r1, #0 - movs r0, #0xec - mov sb, r0 - mov r4, sl - mov r8, r1 - ldr r2, _081326F4 @ =0x00000105 - mov ip, r2 -_081326AE: - mov r2, sb - muls r2, r1, r2 - adds r0, r4, r2 - ldr r0, [r0] - cmp r3, r0 - bne _081326CE - adds r0, r6, r2 - add r0, ip - strb r7, [r0] - lsls r0, r1, #2 - add r0, sp - mov r2, r8 - str r2, [r0] - adds r0, r5, #1 - lsls r0, r0, #0x18 - lsrs r5, r0, #0x18 -_081326CE: - adds r0, r1, #1 - lsls r0, r0, #0x18 - lsrs r1, r0, #0x18 - cmp r1, #3 - bls _081326AE - adds r0, r7, r5 - lsls r0, r0, #0x18 - lsrs r7, r0, #0x18 - cmp r7, #3 - bls _08132684 - add sp, #0x10 - pop {r3, r4, r5} - mov r8, r3 - mov sb, r4 - mov sl, r5 - pop {r4, r5, r6, r7} - pop {r0} - bx r0 - .align 2, 0 -_081326F4: .4byte 0x00000105 - - thumb_func_start sub_081326F8 -sub_081326F8: @ 0x081326F8 - push {r4, r5, r6, r7, lr} - mov r7, r8 - push {r7} - sub sp, #8 - adds r6, r0, #0 - mov r1, sp - movs r2, #0x83 - lsls r2, r2, #1 - adds r0, r6, r2 - ldrh r0, [r0] - strh r0, [r1] - movs r3, #0xf9 - lsls r3, r3, #1 - adds r0, r6, r3 - ldrh r0, [r0] - strh r0, [r1, #2] - ldr r4, _08132744 @ =0x000002DE - adds r0, r6, r4 - ldrh r0, [r0] - strh r0, [r1, #4] - ldr r5, _08132748 @ =0x000003CA - adds r0, r6, r5 - ldrh r0, [r0] - strh r0, [r1, #6] - movs r0, #0 - mov ip, r0 - mov r2, sp -_0813272E: - movs r7, #0 - ldrh r3, [r2] - ldrh r1, [r2, #2] - ldrh r0, [r2, #4] - ldrh r4, [r2, #6] - cmp r0, r4 - bhs _0813274C - ldrh r5, [r2, #4] - cmp r1, r5 - blt _08132752 - b _0813275A - .align 2, 0 -_08132744: .4byte 0x000002DE -_08132748: .4byte 0x000003CA -_0813274C: - ldrh r0, [r2, #6] - cmp r1, r0 - bge _0813275A -_08132752: - ldrh r0, [r2, #2] - cmp r3, r0 - blt _08132770 - b _08132774 -_0813275A: - ldrh r0, [r2, #4] - ldrh r1, [r2, #6] - cmp r0, r1 - bhs _0813276A - ldrh r4, [r2, #4] - cmp r3, r4 - blt _08132770 - b _08132774 -_0813276A: - ldrh r5, [r2, #6] - cmp r3, r5 - bge _08132774 -_08132770: - ldrh r0, [r2] - b _0813279A -_08132774: - ldrh r1, [r2, #2] - ldrh r0, [r2, #4] - ldrh r3, [r2, #6] - cmp r0, r3 - bhs _08132786 - ldrh r4, [r2, #4] - cmp r1, r4 - blt _0813278C - b _08132790 -_08132786: - ldrh r5, [r2, #6] - cmp r1, r5 - bge _08132790 -_0813278C: - ldrh r0, [r2, #2] - b _0813279A -_08132790: - ldrh r0, [r2, #6] - ldrh r1, [r2, #4] - cmp r0, r1 - bls _0813279A - adds r0, r1, #0 -_0813279A: - mov r8, r0 - movs r3, #0 - movs r0, #0xf4 - lsls r0, r0, #2 - adds r4, r6, r0 -_081327A4: - movs r0, #0xec - muls r0, r3, r0 - adds r1, r6, r0 - movs r5, #0x83 - lsls r5, r5, #1 - adds r0, r1, r5 - ldrh r0, [r0] - cmp r8, r0 - bne _081327D6 - subs r5, #1 - adds r0, r1, r5 - mov r1, ip - strb r1, [r0] - mov r5, ip - adds r0, r5, r7 - adds r0, r4, r0 - strb r3, [r0] - lsls r0, r3, #1 - mov r5, sp - adds r1, r5, r0 - ldr r0, _081327FC @ =0x0000FFFF - strh r0, [r1] - adds r0, r7, #1 - lsls r0, r0, #0x18 - lsrs r7, r0, #0x18 -_081327D6: - adds r0, r3, #1 - lsls r0, r0, #0x18 - lsrs r3, r0, #0x18 - cmp r3, #3 - bls _081327A4 - mov r1, ip - adds r0, r1, r7 - lsls r0, r0, #0x18 - lsrs r0, r0, #0x18 - mov ip, r0 - cmp r0, #3 - bls _0813272E - add sp, #8 - pop {r3} - mov r8, r3 - pop {r4, r5, r6, r7} - pop {r0} - bx r0 - .align 2, 0 -_081327FC: .4byte 0x0000FFFF - - thumb_func_start sub_08132800 -sub_08132800: @ 0x08132800 - push {r4, r5, lr} - sub sp, #4 - adds r4, r0, #0 - movs r5, #0 - str r5, [sp] - movs r0, #0xf5 - lsls r0, r0, #2 - adds r4, r4, r0 - ldr r2, _08132878 @ =0x05000011 - mov r0, sp - adds r1, r4, #0 - bl CpuSet - ldr r0, _0813287C @ =0x06010000 - str r0, [r4] - movs r0, #0x90 - lsls r0, r0, #3 - strh r0, [r4, #0x14] - ldr r3, _08132880 @ =gUnk_0837283C - ldr r2, _08132884 @ =gLanguage - ldrh r0, [r2] - movs r1, #0x2c - muls r0, r1, r0 - adds r0, r0, r3 - ldrh r0, [r0] - strh r0, [r4, #0xc] - ldrh r0, [r2] - muls r0, r1, r0 - adds r0, r0, r3 - ldrb r0, [r0, #2] - strb r0, [r4, #0x1a] - strh r5, [r4, #0x16] - movs r0, #0xff - strb r0, [r4, #0x1b] - movs r1, #0x10 - strb r1, [r4, #0x1c] - movs r0, #4 - strb r0, [r4, #0x1f] - strh r5, [r4, #0x10] - movs r0, #0x40 - strh r0, [r4, #0x12] - movs r0, #0xc0 - lsls r0, r0, #0xc - str r0, [r4, #8] - str r5, [r4, #0x28] - movs r0, #0x80 - lsls r0, r0, #1 - str r0, [r4, #0x2c] - strh r5, [r4, #0x30] - strh r5, [r4, #0x32] - strh r1, [r4, #0x34] - strh r5, [r4, #0x36] - str r5, [r4, #0x38] - str r5, [r4, #0x3c] - str r5, [r4, #0x40] - add sp, #4 - pop {r4, r5} - pop {r0} - bx r0 - .align 2, 0 -_08132878: .4byte 0x05000011 -_0813287C: .4byte 0x06010000 -_08132880: .4byte gUnk_0837283C -_08132884: .4byte gLanguage - thumb_func_start sub_08132888 sub_08132888: @ 0x08132888 push {r4, r5, r6, r7, lr} diff --git a/data/data_8.s b/data/data_8.s index afcc04d..0d61c30 100644 --- a/data/data_8.s +++ b/data/data_8.s @@ -3,36 +3,6 @@ .section .rodata -gUnk_08372628:: @ 08372628 - .incbin "baserom.gba", 0x372628, 0x0000090 - -gUnk_083726B8:: @ 083726B8 - .incbin "baserom.gba", 0x3726B8, 0x00000F0 - -gUnk_083727A8:: @ 083727A8 - .incbin "baserom.gba", 0x3727A8, 0x0000010 - -gUnk_083727B8:: @ 083727B8 - .incbin "baserom.gba", 0x3727B8, 0x0000024 - -gUnk_083727DC:: @ 083727DC - .incbin "baserom.gba", 0x3727DC, 0x0000060 - -gUnk_0837283C:: @ 0837283C - .incbin "baserom.gba", 0x37283C, 0x0000108 - -gUnk_08372944:: @ 08372944 - .incbin "baserom.gba", 0x372944, 0x0000010 - -gUnk_08372954:: @ 08372954 - .incbin "baserom.gba", 0x372954, 0x0000010 - -gUnk_08372964:: @ 08372964 - .incbin "baserom.gba", 0x372964, 0x0000040 - -gUnk_083729A4:: @ 083729A4 - .incbin "baserom.gba", 0x3729A4, 0x0000030 - gUnk_083729D4:: @ 083729D4 .incbin "baserom.gba", 0x3729D4, 0x000000C diff --git a/include/code_08128D48.h b/include/code_08128D48.h index 4a815ba..47f236a 100644 --- a/include/code_08128D48.h +++ b/include/code_08128D48.h @@ -184,25 +184,25 @@ struct Unk_0812F91C_20 { u16 unk9A; u16 unk9C; u16 unk9E; - u8 unkA0; - u8 unkA1; - u16 unkA2; + s8 unkA0; + s8 unkA1; + s16 unkA2; u16 unkA4; u8 unkA6; - u16 unkA8; - u16 unkAA; - u32 unkAC; // ??? + s16 unkA8; + s16 unkAA; + s32 unkAC; u16 unkB0; u8 unkB2; u8 unkB3; - u16 unkB4; + s16 unkB4; u16 unkB6; s8 unkB8; u8 fillerB9[3]; u8 unkBC; u8 unkBD; u8 unkBE; - u8 unkBF; + s8 unkBF; s32 unkC0; s32 unkC4; u32 unkC8; // ??? @@ -237,7 +237,7 @@ struct Unk_0812F91C { struct Task *unk14[3]; struct Unk_0812F91C_20 unk20[4]; u8 unk3D0[4]; - struct Unk_08128F44_4 unk3D4; // ??? + struct Unk_08128F44_4 unk3D4; struct Unk_08128F44_4 unk418; struct Unk_0812F91C_45C unk45C[4]; u8 filler4AC[0xC]; diff --git a/src/code_08128D48.c b/src/code_08128D48.c index 4b9c9c1..69b87d4 100644 --- a/src/code_08128D48.c +++ b/src/code_08128D48.c @@ -5432,20 +5432,305 @@ void sub_081331F0(struct Unk_0812F91C_20 *, s32 *); void sub_08133248(struct Unk_0812F91C_20 *); void sub_08133280(struct Unk_0812F91C_20 *); u8 sub_081332D0(struct Unk_0812F91C_20 *, s16, s16); +u8 sub_081332FC(s32, u32, u8 *); void sub_08133344(struct Unk_0812F91C_20 *); struct Task *sub_081334DC(struct Unk_0812F91C_20 *); +void sub_08133688(struct Task *, bool8); +void sub_08133804(struct Unk_0812F91C_20 *); struct Task *sub_08133D44(struct Unk_0812F91C_20 *); void sub_08133EEC(struct Unk_0812F91C_20 *, u8); +void sub_081340AC(struct Unk_0812F91C_20 *); +void sub_08134178(void); void sub_081343EC(void); struct Task *sub_0813457C(void); +void sub_08134720(struct Task *); +void sub_08134754(struct Task *); struct Task *sub_08134788(struct Unk_0812F91C_20 *); void sub_081347D8(struct Unk_0812F91C_20 *, u8, u32); -extern const struct Unk_02021590 gUnk_08372628[][6]; -extern const struct Unk_02021590 gUnk_083726B8[][10]; -extern const struct Unk_02021590 gUnk_083727DC[][4]; -extern const struct Unk_02021590 gUnk_0837283C[][11]; -extern const u8 gUnk_083729A4[][16]; +const struct Unk_02021590 gUnk_08372628[][6] = { + [LANGUAGE_JAPANESE] = { + { 0x34B, 0x5, 0x0 }, + { 0x34B, 0x4, 0x0 }, + { 0x34B, 0x3, 0x0 }, + { 0x34B, 0x0, 0x0 }, + { 0x34B, 0x1, 0x0 }, + { 0x34B, 0x2, 0x0 }, + }, + [LANGUAGE_ENGLISH] = { + { 0x34B, 0x5, 0x0 }, + { 0x34B, 0x4, 0x0 }, + { 0x34B, 0x3, 0x0 }, + { 0x34B, 0x0, 0x0 }, + { 0x34B, 0x1, 0x0 }, + { 0x34B, 0x2, 0x0 }, + }, + [LANGUAGE_GERMAN] = { + { 0x34B, 0x5, 0x0 }, + { 0x34B, 0x4, 0x0 }, + { 0x34B, 0x3, 0x0 }, + { 0x34B, 0x0, 0x0 }, + { 0x34B, 0x1, 0x0 }, + { 0x34B, 0x2, 0x0 }, + }, + [LANGUAGE_FRENCH] = { + { 0x34B, 0x5, 0x0 }, + { 0x34B, 0x4, 0x0 }, + { 0x34B, 0x3, 0x0 }, + { 0x34B, 0x0, 0x0 }, + { 0x34B, 0x1, 0x0 }, + { 0x34B, 0x2, 0x0 }, + }, + [LANGUAGE_SPANISH] = { + { 0x34B, 0x5, 0x0 }, + { 0x34B, 0x4, 0x0 }, + { 0x34B, 0x3, 0x0 }, + { 0x34B, 0x0, 0x0 }, + { 0x34B, 0x1, 0x0 }, + { 0x34B, 0x2, 0x0 }, + }, + [LANGUAGE_ITALIAN] = { + { 0x34B, 0x5, 0x0 }, + { 0x34B, 0x4, 0x0 }, + { 0x34B, 0x3, 0x0 }, + { 0x34B, 0x0, 0x0 }, + { 0x34B, 0x1, 0x0 }, + { 0x34B, 0x2, 0x0 }, + }, +}; + +const struct Unk_02021590 gUnk_083726B8[][10] = { + [LANGUAGE_JAPANESE] = { + { 0x347, 0x0, 0x0 }, + { 0x347, 0x1, 0x0 }, + { 0x347, 0x2, 0x0 }, + { 0x347, 0x3, 0x0 }, + { 0x347, 0x4, 0x0 }, + { 0x347, 0x5, 0x0 }, + { 0x347, 0x6, 0x0 }, + { 0x347, 0x7, 0x0 }, + { 0x347, 0x8, 0x0 }, + { 0x347, 0x9, 0x0 }, + }, + [LANGUAGE_ENGLISH] = { + { 0x347, 0x0, 0x0 }, + { 0x347, 0x1, 0x0 }, + { 0x347, 0x2, 0x0 }, + { 0x347, 0x3, 0x0 }, + { 0x347, 0x4, 0x0 }, + { 0x347, 0x5, 0x0 }, + { 0x347, 0x6, 0x0 }, + { 0x347, 0x7, 0x0 }, + { 0x347, 0x8, 0x0 }, + { 0x347, 0x9, 0x0 }, + }, + [LANGUAGE_GERMAN] = { + { 0x347, 0x0, 0x0 }, + { 0x347, 0x1, 0x0 }, + { 0x347, 0x2, 0x0 }, + { 0x347, 0x3, 0x0 }, + { 0x347, 0x4, 0x0 }, + { 0x347, 0x5, 0x0 }, + { 0x347, 0x6, 0x0 }, + { 0x347, 0x7, 0x0 }, + { 0x347, 0x8, 0x0 }, + { 0x347, 0x9, 0x0 }, + }, + [LANGUAGE_FRENCH] = { + { 0x347, 0x0, 0x0 }, + { 0x347, 0x1, 0x0 }, + { 0x347, 0x2, 0x0 }, + { 0x347, 0x3, 0x0 }, + { 0x347, 0x4, 0x0 }, + { 0x347, 0x5, 0x0 }, + { 0x347, 0x6, 0x0 }, + { 0x347, 0x7, 0x0 }, + { 0x347, 0x8, 0x0 }, + { 0x347, 0x9, 0x0 }, + }, + [LANGUAGE_SPANISH] = { + { 0x347, 0x0, 0x0 }, + { 0x347, 0x1, 0x0 }, + { 0x347, 0x2, 0x0 }, + { 0x347, 0x3, 0x0 }, + { 0x347, 0x4, 0x0 }, + { 0x347, 0x5, 0x0 }, + { 0x347, 0x6, 0x0 }, + { 0x347, 0x7, 0x0 }, + { 0x347, 0x8, 0x0 }, + { 0x347, 0x9, 0x0 }, + }, + [LANGUAGE_ITALIAN] = { + { 0x347, 0x0, 0x0 }, + { 0x347, 0x1, 0x0 }, + { 0x347, 0x2, 0x0 }, + { 0x347, 0x3, 0x0 }, + { 0x347, 0x4, 0x0 }, + { 0x347, 0x5, 0x0 }, + { 0x347, 0x6, 0x0 }, + { 0x347, 0x7, 0x0 }, + { 0x347, 0x8, 0x0 }, + { 0x347, 0x9, 0x0 }, + }, +}; + +const s8 gUnk_083727A8[] = { + 0, 0, 1, 2, 2, 0, 0, 0, 1, 1, 1, 2, 2, 2, 0, 0 // TODO: padding? +}; + +const s8 gUnk_083727B8[][11] = { + { 0x0, 0x0, 0x1, 0x2, 0x2, 0x2, 0x9, 0x9, 0x9, 0x2, 0x1 }, + { 0x6, 0x6, 0x7, 0x8, 0x8, 0x8, 0x9, 0x9, 0x9, 0x8, 0x7 }, + { 0x3, 0x3, 0x4, 0x5, 0x5, 0x5, 0x9, 0x9, 0x9, 0x5, 0x4 }, +}; + +const struct Unk_02021590 gUnk_083727DC[][4] = { + [LANGUAGE_JAPANESE] = { + { 0x349, 0x2, 0x0 }, + { 0x349, 0x3, 0x0 }, + { 0x349, 0x4, 0x0 }, + { 0x349, 0x5, 0x0 }, + }, + [LANGUAGE_ENGLISH] = { + { 0x349, 0x2, 0x0 }, + { 0x349, 0x3, 0x0 }, + { 0x349, 0x4, 0x0 }, + { 0x349, 0x5, 0x0 }, + }, + [LANGUAGE_GERMAN] = { + { 0x349, 0x2, 0x0 }, + { 0x349, 0x3, 0x0 }, + { 0x349, 0x4, 0x0 }, + { 0x349, 0x5, 0x0 }, + }, + [LANGUAGE_FRENCH] = { + { 0x349, 0x2, 0x0 }, + { 0x349, 0x3, 0x0 }, + { 0x349, 0x4, 0x0 }, + { 0x349, 0x5, 0x0 }, + }, + [LANGUAGE_SPANISH] = { + { 0x349, 0x2, 0x0 }, + { 0x349, 0x3, 0x0 }, + { 0x349, 0x4, 0x0 }, + { 0x349, 0x5, 0x0 }, + }, + [LANGUAGE_ITALIAN] = { + { 0x349, 0x2, 0x0 }, + { 0x349, 0x3, 0x0 }, + { 0x349, 0x4, 0x0 }, + { 0x349, 0x5, 0x0 }, + }, +}; + +const struct Unk_02021590 gUnk_0837283C[][11] = { + [LANGUAGE_JAPANESE] = { + { 0x349, 0x6, 0x0 }, + { 0x349, 0x7, 0x0 }, + { 0x349, 0x8, 0x0 }, + { 0x349, 0x9, 0x0 }, + { 0x349, 0xA, 0x0 }, + { 0x349, 0xB, 0x0 }, + { 0x349, 0xC, 0x0 }, + { 0x349, 0xD, 0x0 }, + { 0x349, 0xE, 0x0 }, + { 0x349, 0xF, 0x0 }, + { 0x349, 0x10, 0x0 }, + }, + [LANGUAGE_ENGLISH] = { + { 0x349, 0x6, 0x0 }, + { 0x349, 0x7, 0x0 }, + { 0x349, 0x8, 0x0 }, + { 0x349, 0x9, 0x0 }, + { 0x349, 0xA, 0x0 }, + { 0x349, 0xB, 0x0 }, + { 0x349, 0xC, 0x0 }, + { 0x349, 0xD, 0x0 }, + { 0x349, 0xE, 0x0 }, + { 0x349, 0xF, 0x0 }, + { 0x349, 0x10, 0x0 }, + }, + [LANGUAGE_GERMAN] = { + { 0x349, 0x6, 0x0 }, + { 0x349, 0x7, 0x0 }, + { 0x349, 0x8, 0x0 }, + { 0x349, 0x9, 0x0 }, + { 0x349, 0xA, 0x0 }, + { 0x349, 0xB, 0x0 }, + { 0x349, 0xC, 0x0 }, + { 0x349, 0xD, 0x0 }, + { 0x349, 0xE, 0x0 }, + { 0x349, 0xF, 0x0 }, + { 0x349, 0x10, 0x0 }, + }, + [LANGUAGE_FRENCH] = { + { 0x349, 0x6, 0x0 }, + { 0x349, 0x7, 0x0 }, + { 0x349, 0x8, 0x0 }, + { 0x349, 0x9, 0x0 }, + { 0x349, 0xA, 0x0 }, + { 0x349, 0xB, 0x0 }, + { 0x349, 0xC, 0x0 }, + { 0x349, 0xD, 0x0 }, + { 0x349, 0xE, 0x0 }, + { 0x349, 0xF, 0x0 }, + { 0x349, 0x10, 0x0 }, + }, + [LANGUAGE_SPANISH] = { + { 0x349, 0x6, 0x0 }, + { 0x349, 0x7, 0x0 }, + { 0x349, 0x8, 0x0 }, + { 0x349, 0x9, 0x0 }, + { 0x349, 0xA, 0x0 }, + { 0x349, 0xB, 0x0 }, + { 0x349, 0xC, 0x0 }, + { 0x349, 0xD, 0x0 }, + { 0x349, 0xE, 0x0 }, + { 0x349, 0xF, 0x0 }, + { 0x349, 0x10, 0x0 }, + }, + [LANGUAGE_ITALIAN] = { + { 0x349, 0x6, 0x0 }, + { 0x349, 0x7, 0x0 }, + { 0x349, 0x8, 0x0 }, + { 0x349, 0x9, 0x0 }, + { 0x349, 0xA, 0x0 }, + { 0x349, 0xB, 0x0 }, + { 0x349, 0xC, 0x0 }, + { 0x349, 0xD, 0x0 }, + { 0x349, 0xE, 0x0 }, + { 0x349, 0xF, 0x0 }, + { 0x349, 0x10, 0x0 }, + }, +}; + +const u8 gUnk_08372944[] = { + 0x0, 0x1, 0x3, 0x2, 0x2, 0x1, 0x1, 0x1, + 0x3, 0x3, 0x3, 0x2, 0x2, 0x2, 0x0, 0x1, +}; + +const u8 gUnk_08372954[] = { + 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, + 0x2, 0x2, 0x2, 0x4, 0x3, 0x4, 0x0, 0x1, +}; + +const s8 gUnk_08372964[][8] = { + { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, + { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, + { 0x7, 0x6, 0x5, 0x4, 0x3, 0x2, 0x1, 0x0 }, + { 0x7, 0x7, 0x6, 0x6, 0x5, 0x5, 0x4, 0x4 }, + { 0x3, 0x3, 0x2, 0x2, 0x1, 0x1, 0x0, 0x0 }, + { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7 }, + { 0x0, 0x0, 0x1, 0x1, 0x2, 0x2, 0x3, 0x3 }, + { 0x4, 0x4, 0x5, 0x5, 0x6, 0x6, 0x7, 0x7 }, +}; + +const u8 gUnk_083729A4[][16] = { + { 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x8, 0x8, 0xA, 0x6, 0x8, 0xA, 0x0, 0x0 }, + { 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x6, 0xA, 0xC, 0x8, 0xA, 0xC, 0x0, 0x0 }, + { 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x4, 0x8, 0xE, 0xA, 0xC, 0xE, 0x0, 0x0 }, +}; + extern const u16 gUnk_083729E0[0x100]; extern const u32 gUnk_08372BE0[]; extern const u32 gUnk_083744AC[]; @@ -6623,3 +6908,376 @@ void sub_08131A6C(struct Unk_0812F91C_20 *a1) { } } } + +void sub_08131C20(struct Unk_0812F91C_20 *a1) { + if (!(a1->unkA4 & 1) + && gUnk_08372944[a1->unkB3] > gUnk_08372944[a1->unkB2]) { + a1->unkA4 |= 1; + a1->unkA4 |= 0x10; + a1->unkA2 = 0; + a1->unkA0 = gUnk_08372944[sub_081332D0(a1, 0, 0x20)] + (a1->unkA8 >> 8); + } +} + +void sub_08131C88(struct Unk_0812F91C_20 *a1) { + if (a1->unkA4 & 1) { + s16 var = a1->unkA0 * a1->unkA2 - (a1->unkA2 * a1->unkA2 * a1->unkA1 >> 1); + + if (var < 0) { + a1->unkA4 &= ~1; + a1->unkA4 &= ~0x10; + a1->unkA2 = 0; + a1->unkAC = a1->unkC4; + } + else { + if (var >= 0x20) + a1->unkAA = -0x20; + else + a1->unkAA = -var; + ++a1->unkA2; + } + } + else { + s16 var = a1->unkA2 * a1->unkA2 * a1->unkA1 >> 1; + + if (var >= 0x10) + a1->unkAA = 0x10; + else { + a1->unkAA = var; + ++a1->unkA2; + } + } +} + +void sub_08131D54(struct Unk_0812F91C_20 *a1) { + a1->unkB0 &= ~0x1F; + if (sub_081332D0(a1, 0, 0)) { + if (sub_081332D0(a1, 0, 0) == 0xE || sub_081332D0(a1, 0, 0) == 0xF) + a1->unkB0 |= 0x20; + a1->unkB0 |= 1; + } + if (sub_081332D0(a1, -0x20, 0)) + a1->unkB0 |= 2; + if (sub_081332D0(a1, 0, -0x20)) { + if (sub_081332D0(a1, 0, 0) == 0xE || sub_081332D0(a1, 0, 0) == 0xF) + a1->unkB0 |= 0x20; + a1->unkB0 |= 4; + } + if (sub_081332D0(a1, 0x20, 0)) + a1->unkB0 |= 8; + if (sub_081332D0(a1, 0, 0x20)) { + if (sub_081332D0(a1, 0, 0) == 0xE || sub_081332D0(a1, 0, 0) == 0xF) + a1->unkB0 |= 0x20; + a1->unkB0 |= 0x10; + if (a1->unkAC) { + if (a1->unkA4 & 0x40) { + a1->unkA4 &= ~0x40; + a1->unkAC -= a1->unkC4; + if (a1->unkAC <= -0x60) { + a1->unkA4 |= 0x80; + a1->unkAC = 0; + a1->unkE4 = 0; + if (!(a1->unk94 & 2)) return; + m4aSongNumStart(558); + } + } + else { + a1->unkAC = 0; + } + } + if (a1->unk94 & 2) { + if (sub_081332D0(a1, 0, 0x20) == 1) { + if (a1->unkB3 == 1) { + sub_08134720(a1->unk90); + sub_08133688(a1->unk90, 1); + } + else { + sub_08134754(a1->unk90); + } + } + else { + sub_08134720(a1->unk90); + sub_08133688(a1->unk90, 0); + } + } + } + else { + a1->unkA4 |= 0x40; + if (a1->unk94 & 2) + sub_08134754(a1->unk90); + } +} + +void sub_08131F78(struct Unk_0812F91C_20 *a1) { + s16 r1 = a1->unkC4 / 0x20u; + u32 idx; + + if (a1->unkB0 & 1 || a1->unkB0 & 0x10) { + while (gUnk_08372954[sub_081332FC(a1->unkC0, 0x20 * r1, a1->unkD4)]) + if (--r1 < 0) r1 = 0; + a1->unkC4 = 0x20 * r1; + idx = gUnk_08372954[sub_081332D0(a1, 0, 0x20)]; + a1->unkD0 = 4 * gUnk_08372964[idx][(a1->unkC0 >> 2) & 7]; + } +} + +#define Macro_08132034(a1, a2, idx, i) ({ \ + bool32 _a = (a1)[idx].unkC0 - 0x100 <= (a2)[i].unk0; \ + bool32 _b = (a2)[i].unk0 <= (a1)[idx].unkC0 + 0x2C0; \ + \ + if (_a & _b) { \ + (a2)[i].unk12 |= 1; \ + (a2)[i].unk12 |= 0x10 << (idx); \ + } \ +}) + +void sub_08132034(struct Unk_0812F91C_20 *a1, struct Unk_0812F91C_45C *a2, u8 a3) { + u8 i; + + for (i = 0; i < a3; ++i) { + a2[i].unk12 &= ~0xF1; + Macro_08132034(a1, a2, 0, i); + Macro_08132034(a1, a2, 1, i); + Macro_08132034(a1, a2, 2, i); + Macro_08132034(a1, a2, 3, i); + } +} + +#define Macro_08132160(a1, a2, idx, i) ({ \ + bool32 _a = (a1)[idx].unkC0 - 0x100 <= (a2)[i].unk0; \ + bool32 _b = (a2)[i].unk0 <= (a1)[idx].unkC0 + 0x2C0; \ + \ + if (_a & _b) { \ + (a2)[i].unk12 |= 0xF1; \ + } \ +}) + +void sub_08132160(struct Unk_0812F91C_20 *a1, struct Unk_0812F91C_45C *a2, u8 a3) { + u8 i; + + for (i = 0; i < a3; ++i) { + a2[i].unk12 &= ~0xF1; + Macro_08132160(a1, a2, 0, i); + Macro_08132160(a1, a2, 1, i); + Macro_08132160(a1, a2, 2, i); + Macro_08132160(a1, a2, 3, i); + } +} + +void sub_08132280(struct Unk_0812F91C_20 *a1, struct Unk_0812F91C_45C *a2, u8 a3) { + u8 i; + + for (i = 0; i < a3; ++i) { + if (a2[i].unk12 & 1) { + bool32 a = (a2[i].unk0 >> 2) - 0xE <= a1[0].unkC0 >> 2; + bool32 b = a1[0].unkC0 >> 2 <= (a2[i].unk0 >> 2) + 0xE; + bool32 c = a & b; + bool32 d = (a2[i].unk4 >> 2) - 0xE <= a1[0].unkC4 >> 2; + bool32 e = a1[0].unkC4 >> 2 <= (a2[i].unk4 >> 2) + 0xE; + bool32 f = d & e; + + if (c & f && !(a1[0].unkA4 & 0x400)) { + if (a1[0].unk94 & 2) + m4aSongNumStart(565); + a1[0].unkA4 |= 0x100; + a1[0].unkA4 |= 0x400; + } + } + } +} + +void sub_08132350(struct Unk_0812F91C_20 *a1) { + if (!(a1->unkA4 & 0x10)) { + if (a1->unkB2) { + if (a1->unkA4 & 0x80) { + if (a1->unk94 & 2 && a1->unkB2 == 1) + sub_08133804(a1); + a1->unkA4 &= ~0x80; + a1->unkBF = 5; + } + if (a1->unkBF) { + if (a1->unkBF != 4) + ++a1->unkBF; + if (a1->unkBF > 0xA) + a1->unkBF = 0; + } + } + if (!(a1->unkA4 & 0x10) && a1->unkB2) + a1->unkBC = a1->unkB2; + } + a1->unkBE = a1->unkBD; + a1->unkBD = gUnk_083727B8[gUnk_083727A8[a1->unkBC]][a1->unkBF]; + if (a1->unkA4 & 0x400) { + if (a1->unkB4++ > 0x3C) { + a1->unkA4 &= ~0x400; + a1->unkB4 = 0; + a1->unk0.unk0.animId = gUnk_083726B8[gLanguage][a1->unkBD].animId; + a1->unk0.unk0.variant = gUnk_083726B8[gLanguage][a1->unkBD].variant; + a1->unk0.unk0.unk1B = 0xFF; + } + } + else if (a1->unkBE != a1->unkBD) { + a1->unk0.unk0.animId = gUnk_083726B8[gLanguage][a1->unkBD].animId; + a1->unk0.unk0.variant = gUnk_083726B8[gLanguage][a1->unkBD].variant; + a1->unk0.unk0.unk1B = 0xFF; + } +} + +void sub_08132498(struct Unk_0812F91C_20 *a1) { + if (a1->unkA4 & 0x100) { + a1->unkA4 &= ~0x100; + switch (gLanguage) { // same for every language + case LANGUAGE_JAPANESE: + a1->unk0.unk0.animId = 0x347; + a1->unk0.unk0.variant = 0xB; + a1->unk0.unk0.unk1B = 0xFF; + break; + case LANGUAGE_ENGLISH: + a1->unk0.unk0.animId = 0x347; + a1->unk0.unk0.variant = 0xB; + a1->unk0.unk0.unk1B = 0xFF; + break; + case LANGUAGE_GERMAN: + a1->unk0.unk0.animId = 0x347; + a1->unk0.unk0.variant = 0xB; + a1->unk0.unk0.unk1B = 0xFF; + break; + case LANGUAGE_FRENCH: + a1->unk0.unk0.animId = 0x347; + a1->unk0.unk0.variant = 0xB; + a1->unk0.unk0.unk1B = 0xFF; + break; + case LANGUAGE_SPANISH: + a1->unk0.unk0.animId = 0x347; + a1->unk0.unk0.variant = 0xB; + a1->unk0.unk0.unk1B = 0xFF; + break; + case LANGUAGE_ITALIAN: + a1->unk0.unk0.animId = 0x347; + a1->unk0.unk0.variant = 0xB; + a1->unk0.unk0.unk1B = 0xFF; + break; + } + if (a1->unk94 & 2) + sub_081340AC(a1); + else + sub_08134178(); + a1->unkA4 |= 1; + a1->unkA2 = 0; + a1->unkA0 = 4; + a1->unkE4 = 0; + a1->unkA8 = 0; + } +} + +#ifndef NONMATCHING +void sub_08132540(struct Unk_0812F91C_20 *a1) { + s8 var = (a1->unkC0 - 0x100) >> 10; + register s32 r0 asm("r0"), r1 asm("r1"); + u32 mask = 0xFF; + + if (var < 0) { + a1->unkD4 += 0; + var = 0; + } + a1->unkD8 = gUnk_0837EA54[a1->unkD4[var]]; + a1->unkDC = gUnk_0837EA54[a1->unkD4[var + 1]]; + r0 = a1->unkC0 - 0x100; + r1 = r0 >> 2; + a1->unkE0 = r1 &= mask; +} +#else +void sub_08132540(struct Unk_0812F91C_20 *a1) { + s8 var = (a1->unkC0 - 0x100) >> 10; + + if (var < 0) var = 0; + a1->unkD8 = gUnk_0837EA54[a1->unkD4[var]]; + a1->unkDC = gUnk_0837EA54[a1->unkD4[var + 1]]; + a1->unkE0 = ((a1->unkC0 - 0x100) >> 2) & 0xFF; +} +#endif + +void sub_081325A4(struct Unk_0812F91C *a1) { + u8 i; + + a1->unk418.unk34 &= ~0x100; + for (i = 0; i < a1->unk524; ++i) { + if (a1->unk45C[i].unk12 & (0x10 << a1->unk579)) { + a1->unk418.unk28 = a1->unk45C[i].unk0; + a1->unk418.unk2C = a1->unk45C[i].unk4; + sub_081288DC(&a1->unk418); + a1->unk418.unk34 |= 0x100; + } + } +} + +void sub_08132650(struct Unk_0812F91C *a1) { + s32 array[4]; + u8 i, j, k; + s32 max; + + array[0] = a1->unk20[0].unkC0; + array[1] = a1->unk20[1].unkC0; + array[2] = a1->unk20[2].unkC0; + array[3] = a1->unk20[3].unkC0; + for (i = 0; i < 4; i += k) { + k = 0; + max = max(max(max(array[3], array[2]), array[1]), array[0]); + for (j = 0; j < 4; ++j) { + if (max == a1->unk20[j].unkC0) { + a1->unk20[j].unkE5 = i; + array[j] = 0; + ++k; + } + } + } +} + +void sub_081326F8(struct Unk_0812F91C *a1) { + u16 array[4]; + u8 i, j, k; + u16 min; + + array[0] = a1->unk20[0].unkE6; + array[1] = a1->unk20[1].unkE6; + array[2] = a1->unk20[2].unkE6; + array[3] = a1->unk20[3].unkE6; + for (i = 0; i < 4; i += k) { + k = 0; + min = min(array[0], min(array[1], min(array[2], array[3]))); + for (j = 0; j < 4; ++j) { + if (min == a1->unk20[j].unkE6) { + a1->unk20[j].unkE5 = i; + a1->unk3D0[i + k] = j; + array[j] = 0xFFFF; + ++k; + } + } + } +} + +void sub_08132800(struct Unk_0812F91C *a1) { + struct Unk_08128F44_4 *var; + + CpuFill32(0, var = &a1->unk3D4, sizeof(struct Unk_08128F44_4)); + var->unk0.tilesVram = 0x6010000; + var->unk0.unk14 = 0x480; + var->unk0.animId = gUnk_0837283C[gLanguage][0].animId; + var->unk0.variant = gUnk_0837283C[gLanguage][0].variant; + var->unk0.unk16 = 0; + var->unk0.unk1B = 0xFF; + var->unk0.unk1C = 0x10; + var->unk0.palId = 4; + var->unk0.x = 0; + var->unk0.y = 0x40; + var->unk0.unk8 = 0xC0000; + var->unk28 = 0; + var->unk2C = 0x100; + var->unk30 = 0; + var->unk32 = 0; + var->unk34 = 0x10; + var->unk36 = 0; + var->unk38 = NULL; + var->unk3C = NULL; + var->unk40 = NULL; +}