diff --git a/asm/code_0814A828.s b/asm/code_0814A828.s index 35ce603..50c3cf8 100644 --- a/asm/code_0814A828.s +++ b/asm/code_0814A828.s @@ -5,116 +5,6 @@ .text - thumb_func_start sub_0814A828 -sub_0814A828: @ 0x0814A828 - push {r4, r5, r6, r7, lr} - sub sp, #8 - ldr r0, _0814A840 @ =gUnk_0203AD10 - ldr r0, [r0] - movs r1, #0x10 - ands r0, r1 - cmp r0, #0 - beq _0814A844 - bl sub_08039670 - b _0814A902 - .align 2, 0 -_0814A840: .4byte gUnk_0203AD10 -_0814A844: - ldr r0, _0814A8C4 @ =gUnk_0203AD2C - ldrh r1, [r0] - ldr r0, _0814A8C8 @ =0x0000012B - cmp r1, r0 - bhi _0814A902 - ldr r1, _0814A8CC @ =0x00007FFF - add r0, sp, #4 - strh r1, [r0] - movs r1, #0 - movs r2, #1 - bl sub_0803D21C - ldr r1, _0814A8D0 @ =gDispCnt - movs r2, #0x82 - lsls r2, r2, #5 - adds r0, r2, #0 - strh r0, [r1] - bl m4aSoundVSyncOn - movs r2, #0 - ldr r3, _0814A8D4 @ =gUnk_0203AD30 - mov r7, sp - adds r7, #6 - ldrb r0, [r3] - cmp r2, r0 - bhs _0814A898 - movs r6, #0xd4 - lsls r6, r6, #1 - ldr r5, _0814A8D8 @ =gKirbys+8 - ldr r4, _0814A8DC @ =0xFEFFFFFF -_0814A880: - adds r0, r2, #0 - muls r0, r6, r0 - adds r0, r0, r5 - ldr r1, [r0] - ands r1, r4 - str r1, [r0] - adds r0, r2, #1 - lsls r0, r0, #0x10 - lsrs r2, r0, #0x10 - ldrb r0, [r3] - cmp r2, r0 - blo _0814A880 -_0814A898: - ldr r0, _0814A8E0 @ =sub_0814A914 - movs r2, #0x80 - lsls r2, r2, #5 - ldr r1, _0814A8E4 @ =nullsub_12 - str r1, [sp] - movs r1, #0xc8 - movs r3, #4 - bl TaskCreate - adds r2, r0, #0 - ldrh r1, [r2, #0x12] - movs r0, #0x10 - ands r0, r1 - cmp r0, #0 - beq _0814A8E8 - ldrh r0, [r2, #6] - lsls r0, r0, #2 - movs r1, #0x80 - lsls r1, r1, #0x12 - adds r4, r0, r1 - b _0814A8F0 - .align 2, 0 -_0814A8C4: .4byte gUnk_0203AD2C -_0814A8C8: .4byte 0x0000012B -_0814A8CC: .4byte 0x00007FFF -_0814A8D0: .4byte gDispCnt -_0814A8D4: .4byte gUnk_0203AD30 -_0814A8D8: .4byte gKirbys+8 -_0814A8DC: .4byte 0xFEFFFFFF -_0814A8E0: .4byte sub_0814A914 -_0814A8E4: .4byte nullsub_12 -_0814A8E8: - ldrh r1, [r2, #6] - movs r0, #0xc0 - lsls r0, r0, #0x12 - adds r4, r1, r0 -_0814A8F0: - movs r0, #0 - strh r0, [r7] - ldr r2, _0814A90C @ =0x01000064 - adds r0, r7, #0 - adds r1, r4, #0 - bl CpuSet - ldr r0, _0814A910 @ =sub_0814E0B4 - str r0, [r4, #8] -_0814A902: - add sp, #8 - pop {r4, r5, r6, r7} - pop {r0} - bx r0 - .align 2, 0 -_0814A90C: .4byte 0x01000064 -_0814A910: .4byte sub_0814E0B4 - thumb_func_start sub_0814A914 sub_0814A914: @ 0x0814A914 push {r4, r5, r6, lr} diff --git a/asm/collection_room.s b/asm/collection_room.s index 71e8ac4..780f35f 100644 --- a/asm/collection_room.s +++ b/asm/collection_room.s @@ -5,1371 +5,6 @@ .text - thumb_func_start sub_08143DA8 -sub_08143DA8: @ 0x08143DA8 - push {r4, r5, r6, r7, lr} - mov r7, r8 - push {r7} - sub sp, #4 - mov r8, r0 - ldr r1, _08143E38 @ =gVramHeapMaxTileSlots - movs r2, #0x80 - lsls r2, r2, #3 - adds r0, r2, #0 - strh r0, [r1] - ldr r1, _08143E3C @ =gVramHeapStartAddr - ldr r0, _08143E40 @ =0x06010000 - str r0, [r1] - mov r0, sp - ldr r1, _08143E44 @ =0x00007FFF - adds r3, r1, #0 - strh r3, [r0] - ldr r0, _08143E48 @ =0x040000D4 - mov r2, sp - str r2, [r0] - ldr r1, _08143E4C @ =gBgPalette - str r1, [r0, #4] - ldr r2, _08143E50 @ =0x81000100 - str r2, [r0, #8] - ldr r1, [r0, #8] - mov r1, sp - strh r3, [r1] - str r1, [r0] - ldr r1, _08143E54 @ =gObjPalette - str r1, [r0, #4] - str r2, [r0, #8] - ldr r0, [r0, #8] - ldr r2, _08143E58 @ =gMainFlags - ldr r0, [r2] - movs r1, #3 - orrs r0, r1 - str r0, [r2] - ldr r1, _08143E5C @ =gDispCnt - movs r2, #0x9a - lsls r2, r2, #5 - adds r0, r2, #0 - strh r0, [r1] - movs r4, #0 - ldr r0, _08143E60 @ =sub_0814565C - mov ip, r0 - ldr r7, _08143E64 @ =gBgCntRegs - ldr r6, _08143E68 @ =gUnk_0838665C - movs r5, #0x1f -_08143E08: - lsls r2, r4, #1 - adds r2, r2, r7 - lsls r3, r4, #2 - adds r0, r3, r6 - ldr r1, [r0] - subs r0, r5, r4 - lsls r0, r0, #8 - orrs r1, r0 - orrs r1, r3 - strh r1, [r2] - adds r0, r4, #1 - lsls r0, r0, #0x18 - lsrs r4, r0, #0x18 - cmp r4, #1 - bls _08143E08 - mov r1, ip - mov r2, r8 - str r1, [r2, #0x38] - add sp, #4 - pop {r3} - mov r8, r3 - pop {r4, r5, r6, r7} - pop {r0} - bx r0 - .align 2, 0 -_08143E38: .4byte gVramHeapMaxTileSlots -_08143E3C: .4byte gVramHeapStartAddr -_08143E40: .4byte 0x06010000 -_08143E44: .4byte 0x00007FFF -_08143E48: .4byte 0x040000D4 -_08143E4C: .4byte gBgPalette -_08143E50: .4byte 0x81000100 -_08143E54: .4byte gObjPalette -_08143E58: .4byte gMainFlags -_08143E5C: .4byte gDispCnt -_08143E60: .4byte sub_0814565C -_08143E64: .4byte gBgCntRegs -_08143E68: .4byte gUnk_0838665C - - thumb_func_start sub_08143E6C -sub_08143E6C: @ 0x08143E6C - push {r4, r5, r6, r7, lr} - adds r7, r0, #0 - ldr r2, _08143ED4 @ =gUnk_08386664 - ldr r0, _08143ED8 @ =gLanguage - ldrh r1, [r0] - movs r0, #0x4e - muls r0, r1, r0 - adds r0, r0, r2 - ldrh r0, [r0] - ldr r1, _08143EDC @ =gUnk_082D7850 - lsls r0, r0, #2 - adds r0, r0, r1 - ldr r1, [r0] - ldr r0, [r1, #8] - ldr r5, [r1, #0x18] - ldrh r4, [r1, #2] - movs r2, #0 - movs r3, #0xc0 - lsls r3, r3, #0x13 - adds r1, r2, r3 - ldr r3, _08143EE0 @ =0x0600F800 - adds r6, r2, r3 - ldr r3, _08143EE4 @ =gBgScrollRegs - strh r2, [r3] - strh r2, [r3, #2] - bl LZ77UnCompVram - movs r1, #0 - cmp r1, r4 - bhs _08143ECA - ldr r2, _08143EE8 @ =0x040000D4 - ldr r3, _08143EEC @ =0x80000020 -_08143EAC: - lsls r0, r1, #4 - subs r0, r0, r1 - lsls r0, r0, #2 - adds r0, r5, r0 - str r0, [r2] - lsls r0, r1, #6 - adds r0, r6, r0 - str r0, [r2, #4] - str r3, [r2, #8] - ldr r0, [r2, #8] - adds r0, r1, #1 - lsls r0, r0, #0x10 - lsrs r1, r0, #0x10 - cmp r1, r4 - blo _08143EAC -_08143ECA: - ldr r0, _08143EF0 @ =sub_08143EF4 - str r0, [r7, #0x38] - pop {r4, r5, r6, r7} - pop {r0} - bx r0 - .align 2, 0 -_08143ED4: .4byte gUnk_08386664 -_08143ED8: .4byte gLanguage -_08143EDC: .4byte gUnk_082D7850 -_08143EE0: .4byte 0x0600F800 -_08143EE4: .4byte gBgScrollRegs -_08143EE8: .4byte 0x040000D4 -_08143EEC: .4byte 0x80000020 -_08143EF0: .4byte sub_08143EF4 - - thumb_func_start sub_08143EF4 -sub_08143EF4: @ 0x08143EF4 - push {r4, r5, r6, r7, lr} - adds r7, r0, #0 - ldr r3, _08143F60 @ =gUnk_08386664 - ldr r0, _08143F64 @ =gUnk_08386A50 - ldrb r0, [r0, #3] - lsls r0, r0, #1 - ldr r1, _08143F68 @ =gLanguage - ldrh r2, [r1] - movs r1, #0x4e - muls r1, r2, r1 - adds r0, r0, r1 - adds r0, r0, r3 - ldrh r0, [r0] - ldr r1, _08143F6C @ =gUnk_082D7850 - lsls r0, r0, #2 - adds r0, r0, r1 - ldr r1, [r0] - ldr r0, [r1, #8] - ldr r5, [r1, #0x18] - ldrh r4, [r1, #2] - ldr r6, _08143F70 @ =0x0600F340 - ldr r2, _08143F74 @ =gBgScrollRegs - movs r1, #0 - strh r1, [r2, #4] - strh r1, [r2, #6] - ldr r1, _08143F78 @ =0x06004000 - bl LZ77UnCompVram - movs r1, #0 - cmp r1, r4 - bhs _08143F54 - ldr r2, _08143F7C @ =0x040000D4 - ldr r3, _08143F80 @ =0x80000020 -_08143F36: - lsls r0, r1, #4 - subs r0, r0, r1 - lsls r0, r0, #2 - adds r0, r5, r0 - str r0, [r2] - lsls r0, r1, #6 - adds r0, r6, r0 - str r0, [r2, #4] - str r3, [r2, #8] - ldr r0, [r2, #8] - adds r0, r1, #1 - lsls r0, r0, #0x10 - lsrs r1, r0, #0x10 - cmp r1, r4 - blo _08143F36 -_08143F54: - ldr r0, _08143F84 @ =sub_08145718 - str r0, [r7, #0x38] - pop {r4, r5, r6, r7} - pop {r0} - bx r0 - .align 2, 0 -_08143F60: .4byte gUnk_08386664 -_08143F64: .4byte gUnk_08386A50 -_08143F68: .4byte gLanguage -_08143F6C: .4byte gUnk_082D7850 -_08143F70: .4byte 0x0600F340 -_08143F74: .4byte gBgScrollRegs -_08143F78: .4byte 0x06004000 -_08143F7C: .4byte 0x040000D4 -_08143F80: .4byte 0x80000020 -_08143F84: .4byte sub_08145718 - - thumb_func_start sub_08143F88 -sub_08143F88: @ 0x08143F88 - push {r4, r5, r6, r7, lr} - mov r7, r8 - push {r7} - adds r5, r0, #0 - movs r1, #0 - ldr r0, _08144044 @ =gUnk_08386838 - mov ip, r0 - ldr r7, _08144048 @ =gLanguage - ldr r2, _0814404C @ =gUnk_08386A12 - mov r8, r2 - ldr r6, _08144050 @ =gKeysContinuedRepeatIntervals - movs r4, #5 - ldr r3, _08144054 @ =gKeysFirstRepeatIntervals - movs r2, #0xa -_08143FA4: - adds r0, r1, r6 - strb r4, [r0] - adds r0, r1, r3 - strb r2, [r0] - adds r0, r1, #1 - lsls r0, r0, #0x18 - lsrs r1, r0, #0x18 - cmp r1, #9 - bls _08143FA4 - adds r1, r5, #0 - adds r1, #0x2c - movs r0, #0 - strb r0, [r1] - adds r1, #1 - movs r0, #1 - strb r0, [r1] - movs r1, #0xd5 - lsls r1, r1, #3 - adds r0, r5, r1 - ldrh r2, [r7] - lsls r1, r2, #1 - adds r1, r1, r2 - lsls r1, r1, #3 - mov r2, ip - adds r2, #6 - adds r1, r1, r2 - ldrh r1, [r1] - strh r1, [r0, #0xc] - ldrh r2, [r7] - lsls r1, r2, #1 - adds r1, r1, r2 - lsls r1, r1, #3 - mov r2, ip - adds r2, #8 - adds r1, r1, r2 - ldrh r1, [r1] - strb r1, [r0, #0x1a] - mov r2, r8 - ldrb r1, [r2, #1] - strb r1, [r0, #0x1f] - bl sub_08155128 - adds r0, r5, #0 - bl sub_08144438 - ldr r0, _08144058 @ =sub_0814405C - str r0, [r5, #0x38] - movs r4, #0 - adds r6, r5, #2 - movs r0, #0xd0 - lsls r0, r0, #3 - adds r7, r5, r0 -_0814400C: - adds r0, r6, r4 - ldrb r0, [r0] - cmp r0, #0 - beq _08144022 - lsls r0, r4, #2 - adds r0, r0, r4 - lsls r0, r0, #3 - adds r0, #0x40 - adds r0, r5, r0 - bl sub_0815604C -_08144022: - adds r0, r4, #1 - lsls r0, r0, #0x18 - lsrs r4, r0, #0x18 - cmp r4, #0x27 - bls _0814400C - adds r0, r7, #0 - bl sub_0815604C - adds r0, r5, #0 - bl sub_08145974 - pop {r3} - mov r8, r3 - pop {r4, r5, r6, r7} - pop {r0} - bx r0 - .align 2, 0 -_08144044: .4byte gUnk_08386838 -_08144048: .4byte gLanguage -_0814404C: .4byte gUnk_08386A12 -_08144050: .4byte gKeysContinuedRepeatIntervals -_08144054: .4byte gKeysFirstRepeatIntervals -_08144058: .4byte sub_0814405C - - thumb_func_start sub_0814405C -sub_0814405C: @ 0x0814405C - push {r4, r5, r6, r7, lr} - adds r4, r0, #0 - adds r0, #0x2a - ldrb r0, [r0] - adds r1, r4, #0 - adds r1, #0x2b - strb r0, [r1] - adds r0, r4, #0 - bl sub_081447E0 - cmp r0, #0 - bne _081440B6 - ldr r0, _0814408C @ =gPressedKeys - ldrh r1, [r0] - movs r0, #2 - ands r0, r1 - cmp r0, #0 - beq _08144098 - ldr r0, _08144090 @ =0x0000021F - bl m4aSongNumStart - ldr r0, _08144094 @ =sub_08145848 - str r0, [r4, #0x38] - b _081440B6 - .align 2, 0 -_0814408C: .4byte gPressedKeys -_08144090: .4byte 0x0000021F -_08144094: .4byte sub_08145848 -_08144098: - adds r0, r4, #0 - bl sub_08144238 - adds r0, r4, #0 - bl sub_08143A38 - adds r0, r4, #0 - bl sub_081443D8 - adds r0, r4, #0 - bl sub_08144438 - adds r0, r4, #0 - bl sub_08144304 -_081440B6: - adds r0, r4, #0 - bl sub_081445BC - movs r5, #0 - adds r6, r4, #2 - movs r0, #0xd0 - lsls r0, r0, #3 - adds r7, r4, r0 -_081440C6: - adds r0, r6, r5 - ldrb r0, [r0] - cmp r0, #0 - beq _081440DC - lsls r0, r5, #2 - adds r0, r0, r5 - lsls r0, r0, #3 - adds r0, #0x40 - adds r0, r4, r0 - bl sub_0815604C -_081440DC: - adds r0, r5, #1 - lsls r0, r0, #0x18 - lsrs r5, r0, #0x18 - cmp r5, #0x27 - bls _081440C6 - adds r0, r7, #0 - bl sub_0815604C - adds r0, r4, #0 - bl sub_08145974 - pop {r4, r5, r6, r7} - pop {r0} - bx r0 - - thumb_func_start sub_081440F8 -sub_081440F8: @ 0x081440F8 - push {r4, r5, r6, lr} - adds r6, r0, #0 - adds r0, #0x2c - movs r5, #0 - strb r5, [r0] - adds r1, r6, #0 - adds r1, #0x2d - movs r0, #1 - strb r0, [r1] - movs r1, #0xd5 - lsls r1, r1, #3 - adds r0, r6, r1 - ldr r3, _08144194 @ =gUnk_08386838 - ldr r4, _08144198 @ =gLanguage - ldrh r2, [r4] - lsls r1, r2, #1 - adds r1, r1, r2 - lsls r1, r1, #3 - adds r2, r3, #6 - adds r1, r1, r2 - ldrh r1, [r1] - strh r1, [r0, #0xc] - ldrh r2, [r4] - lsls r1, r2, #1 - adds r1, r1, r2 - lsls r1, r1, #3 - adds r3, #8 - adds r1, r1, r3 - ldrh r1, [r1] - strb r1, [r0, #0x1a] - ldr r1, _0814419C @ =gUnk_08386A12 - ldrb r1, [r1, #1] - strb r1, [r0, #0x1f] - bl sub_08155128 - adds r0, r6, #0 - bl sub_08144510 - adds r0, r6, #0 - bl sub_081459EC - strh r5, [r6, #0x3c] - ldr r0, _081441A0 @ =sub_081441A8 - str r0, [r6, #0x38] - ldr r0, _081441A4 @ =0x0000073B - adds r1, r6, r0 - movs r0, #0xff - strb r0, [r1] - movs r4, #0 -_0814415A: - adds r0, r6, #2 - adds r0, r0, r4 - ldrb r0, [r0] - cmp r0, #0 - beq _08144172 - lsls r0, r4, #2 - adds r0, r0, r4 - lsls r0, r0, #3 - adds r0, #0x40 - adds r0, r6, r0 - bl sub_0815604C -_08144172: - adds r0, r4, #1 - lsls r0, r0, #0x18 - lsrs r4, r0, #0x18 - cmp r4, #0x27 - bls _0814415A - movs r1, #0xd0 - lsls r1, r1, #3 - adds r0, r6, r1 - bl sub_0815604C - adds r0, r6, #0 - bl sub_08145974 - pop {r4, r5, r6} - pop {r0} - bx r0 - .align 2, 0 -_08144194: .4byte gUnk_08386838 -_08144198: .4byte gLanguage -_0814419C: .4byte gUnk_08386A12 -_081441A0: .4byte sub_081441A8 -_081441A4: .4byte 0x0000073B - - thumb_func_start sub_081441A8 -sub_081441A8: @ 0x081441A8 - push {r4, r5, r6, r7, lr} - adds r5, r0, #0 - ldrh r0, [r5, #0x3c] - adds r0, #1 - strh r0, [r5, #0x3c] - lsls r0, r0, #0x10 - asrs r0, r0, #0x10 - cmp r0, #0x1d - ble _081441C6 - ldr r0, _0814422C @ =gUnk_0203ADE0 - movs r1, #1 - ldrsb r1, [r5, r1] - strh r1, [r0] - ldr r0, _08144230 @ =sub_08143F88 - str r0, [r5, #0x38] -_081441C6: - adds r0, r5, #0 - bl sub_08144718 - adds r0, r5, #0 - bl sub_081459FC - movs r0, #0xe4 - lsls r0, r0, #3 - adds r4, r5, r0 - adds r0, r4, #0 - bl sub_08155128 - cmp r0, #0 - bne _081441EA - ldr r0, _08144234 @ =0x0000073B - adds r1, r5, r0 - movs r0, #0xff - strb r0, [r1] -_081441EA: - adds r0, r4, #0 - bl sub_0815604C - movs r4, #0 - adds r6, r5, #2 - movs r0, #0xd0 - lsls r0, r0, #3 - adds r7, r5, r0 -_081441FA: - adds r0, r6, r4 - ldrb r0, [r0] - cmp r0, #0 - beq _08144210 - lsls r0, r4, #2 - adds r0, r0, r4 - lsls r0, r0, #3 - adds r0, #0x40 - adds r0, r5, r0 - bl sub_0815604C -_08144210: - adds r0, r4, #1 - lsls r0, r0, #0x18 - lsrs r4, r0, #0x18 - cmp r4, #0x27 - bls _081441FA - adds r0, r7, #0 - bl sub_0815604C - adds r0, r5, #0 - bl sub_08145974 - pop {r4, r5, r6, r7} - pop {r0} - bx r0 - .align 2, 0 -_0814422C: .4byte gUnk_0203ADE0 -_08144230: .4byte sub_08143F88 -_08144234: .4byte 0x0000073B - - thumb_func_start sub_08144238 -sub_08144238: @ 0x08144238 - push {r4, r5, r6, lr} - adds r6, r0, #0 - adds r0, #0x2a - movs r4, #0 - ldrsb r4, [r0, r4] - adds r0, r4, #0 - movs r1, #0xa - bl __modsi3 - lsls r0, r0, #0x18 - lsrs r5, r0, #0x18 - adds r0, r4, #0 - movs r1, #0xa - bl __divsi3 - lsls r0, r0, #0x18 - lsrs r3, r0, #0x18 - ldr r2, _081442F4 @ =gRepeatedKeys - ldrh r1, [r2] - movs r0, #0x40 - ands r0, r1 - cmp r0, #0 - beq _08144276 - lsls r0, r3, #0x18 - movs r1, #0xff - lsls r1, r1, #0x18 - adds r0, r0, r1 - lsrs r3, r0, #0x18 - cmp r0, #0 - bge _08144276 - movs r3, #3 -_08144276: - ldrh r1, [r2] - movs r0, #0x80 - ands r0, r1 - cmp r0, #0 - beq _08144292 - lsls r0, r3, #0x18 - movs r1, #0x80 - lsls r1, r1, #0x11 - adds r0, r0, r1 - lsrs r3, r0, #0x18 - asrs r0, r0, #0x18 - cmp r0, #3 - ble _08144292 - movs r3, #0 -_08144292: - ldrh r1, [r2] - movs r0, #0x20 - ands r0, r1 - cmp r0, #0 - beq _081442AC - lsls r0, r5, #0x18 - movs r1, #0xff - lsls r1, r1, #0x18 - adds r0, r0, r1 - lsrs r5, r0, #0x18 - cmp r0, #0 - bge _081442AC - movs r5, #9 -_081442AC: - ldrh r1, [r2] - movs r0, #0x10 - ands r0, r1 - cmp r0, #0 - beq _081442C8 - lsls r0, r5, #0x18 - movs r1, #0x80 - lsls r1, r1, #0x11 - adds r0, r0, r1 - lsrs r5, r0, #0x18 - asrs r0, r0, #0x18 - cmp r0, #9 - ble _081442C8 - movs r5, #0 -_081442C8: - lsls r0, r3, #0x18 - asrs r0, r0, #0x18 - lsls r1, r0, #2 - adds r1, r1, r0 - lsls r1, r1, #1 - lsls r0, r5, #0x18 - asrs r0, r0, #0x18 - adds r0, r0, r1 - lsls r0, r0, #0x18 - lsrs r2, r0, #0x18 - adds r1, r6, #0 - adds r1, #0x2a - movs r0, #0 - ldrsb r0, [r1, r0] - cmp r2, r0 - beq _081442FC - strb r2, [r1] - ldr r0, _081442F8 @ =0x0000021D - bl m4aSongNumStart - movs r0, #1 - b _081442FE - .align 2, 0 -_081442F4: .4byte gRepeatedKeys -_081442F8: .4byte 0x0000021D -_081442FC: - movs r0, #0 -_081442FE: - pop {r4, r5, r6} - pop {r1} - bx r1 - - thumb_func_start sub_08144304 -sub_08144304: @ 0x08144304 - push {r4, r5, r6, lr} - sub sp, #4 - adds r2, r0, #0 - adds r0, #0x2b - adds r3, r2, #0 - adds r3, #0x2a - movs r1, #0 - ldrsb r1, [r0, r1] - movs r0, #0 - ldrsb r0, [r3, r0] - cmp r1, r0 - beq _081443C2 - adds r4, r0, #0 - adds r0, r2, #2 - adds r0, r0, r4 - ldrb r1, [r0] - cmp r1, #0 - beq _081443B0 - ldr r3, _0814438C @ =gUnk_08386664 - ldr r1, _08144390 @ =gUnk_08386A50 - lsls r0, r4, #2 - adds r0, r0, r1 - ldrb r0, [r0, #3] - lsls r0, r0, #1 - ldr r1, _08144394 @ =gLanguage - ldrh r2, [r1] - movs r1, #0x4e - muls r1, r2, r1 - adds r0, r0, r1 - adds r0, r0, r3 - ldrh r0, [r0] - ldr r1, _08144398 @ =gUnk_082D7850 - lsls r0, r0, #2 - adds r0, r0, r1 - ldr r1, [r0] - ldr r0, [r1, #8] - ldr r5, [r1, #0x18] - ldrh r4, [r1, #2] - ldr r6, _0814439C @ =0x0600F340 - ldr r2, _081443A0 @ =gBgScrollRegs - movs r1, #0 - strh r1, [r2, #4] - strh r1, [r2, #6] - ldr r1, _081443A4 @ =0x06004000 - bl LZ77UnCompVram - movs r1, #0 - cmp r1, r4 - bhs _081443C2 - ldr r2, _081443A8 @ =0x040000D4 - ldr r3, _081443AC @ =0x80000020 -_0814436A: - lsls r0, r1, #4 - subs r0, r0, r1 - lsls r0, r0, #2 - adds r0, r5, r0 - str r0, [r2] - lsls r0, r1, #6 - adds r0, r6, r0 - str r0, [r2, #4] - str r3, [r2, #8] - ldr r0, [r2, #8] - adds r0, r1, #1 - lsls r0, r0, #0x10 - lsrs r1, r0, #0x10 - cmp r1, r4 - blo _0814436A - b _081443C2 - .align 2, 0 -_0814438C: .4byte gUnk_08386664 -_08144390: .4byte gUnk_08386A50 -_08144394: .4byte gLanguage -_08144398: .4byte gUnk_082D7850 -_0814439C: .4byte 0x0600F340 -_081443A0: .4byte gBgScrollRegs -_081443A4: .4byte 0x06004000 -_081443A8: .4byte 0x040000D4 -_081443AC: .4byte 0x80000020 -_081443B0: - mov r0, sp - strh r1, [r0] - ldr r1, _081443CC @ =0x040000D4 - str r0, [r1] - ldr r0, _081443D0 @ =0x06004000 - str r0, [r1, #4] - ldr r0, _081443D4 @ =0x81002000 - str r0, [r1, #8] - ldr r0, [r1, #8] -_081443C2: - add sp, #4 - pop {r4, r5, r6} - pop {r0} - bx r0 - .align 2, 0 -_081443CC: .4byte 0x040000D4 -_081443D0: .4byte 0x06004000 -_081443D4: .4byte 0x81002000 - - thumb_func_start sub_081443D8 -sub_081443D8: @ 0x081443D8 - push {lr} - adds r3, r0, #0 - ldr r1, _08144408 @ =gUnk_08386A50 - adds r0, #0x2a - ldrb r0, [r0] - lsls r0, r0, #0x18 - asrs r0, r0, #0x18 - lsls r0, r0, #2 - adds r0, r0, r1 - ldrh r2, [r0] - adds r0, r3, #0 - adds r0, #0x2b - ldrb r0, [r0] - lsls r0, r0, #0x18 - asrs r0, r0, #0x18 - lsls r0, r0, #2 - adds r0, r0, r1 - ldrh r0, [r0] - lsrs r2, r2, #8 - lsrs r0, r0, #8 - cmp r2, r0 - bne _0814440C - movs r0, #0 - b _08144434 - .align 2, 0 -_08144408: .4byte gUnk_08386A50 -_0814440C: - cmp r2, #1 - beq _08144416 - cmp r2, #0x10 - beq _08144424 - b _08144432 -_08144416: - movs r0, #0xd5 - lsls r0, r0, #3 - adds r1, r3, r0 - movs r0, #0x98 - strh r0, [r1, #0x10] - movs r0, #0x8a - b _08144430 -_08144424: - movs r0, #0xd5 - lsls r0, r0, #3 - adds r1, r3, r0 - movs r0, #0xb4 - strh r0, [r1, #0x10] - movs r0, #0x79 -_08144430: - strh r0, [r1, #0x12] -_08144432: - movs r0, #1 -_08144434: - pop {r1} - bx r1 - - thumb_func_start sub_08144438 -sub_08144438: @ 0x08144438 - push {r4, lr} - sub sp, #0x28 - adds r4, r0, #0 - mov r0, sp - movs r1, #0 - movs r2, #0x28 - bl memset - adds r0, r4, #0 - adds r0, #0x2a - ldrb r0, [r0] - adds r2, r0, #0 - ldr r1, _0814448C @ =gUnk_08386A50 - lsls r0, r2, #2 - adds r0, r0, r1 - ldrh r1, [r0] - subs r0, r1, #1 - lsls r0, r0, #0x18 - lsrs r3, r0, #0x18 - adds r0, r4, #2 - adds r0, r0, r2 - ldrb r0, [r0] - cmp r0, #0 - beq _08144486 - lsrs r0, r1, #8 - cmp r0, #1 - bne _08144486 - adds r0, r4, #0 - adds r0, #0x2b - ldrb r0, [r0] - lsls r0, r0, #0x18 - asrs r0, r0, #0x18 - cmp r2, r0 - beq _08144486 - lsls r0, r3, #0x18 - asrs r2, r0, #0x18 - adds r4, r0, #0 - cmp r2, #0 - bge _08144490 -_08144486: - movs r0, #0 - b _08144502 - .align 2, 0 -_0814448C: .4byte gUnk_08386A50 -_08144490: - movs r0, #0 - str r0, [sp] - mov r1, sp - movs r0, #0xf8 - lsls r0, r0, #3 - strh r0, [r1, #0x14] - mov r3, sp - movs r0, #1 - rsbs r0, r0, #0 - cmp r2, r0 - bne _081444B4 - ldr r0, _081444B0 @ =gUnk_08386AF0 - ldrh r2, [r0] - adds r1, r0, #0 - b _081444BC - .align 2, 0 -_081444B0: .4byte gUnk_08386AF0 -_081444B4: - ldr r1, _081444D0 @ =gUnk_08386AF0 - lsls r0, r2, #2 - adds r0, r0, r1 - ldrh r2, [r0] -_081444BC: - strh r2, [r3, #0xc] - mov r3, sp - asrs r2, r4, #0x18 - movs r0, #1 - rsbs r0, r0, #0 - cmp r2, r0 - bne _081444D4 - ldrb r0, [r1, #2] - b _081444DC - .align 2, 0 -_081444D0: .4byte gUnk_08386AF0 -_081444D4: - lsls r0, r2, #2 - adds r1, #2 - adds r0, r0, r1 - ldrb r0, [r0] -_081444DC: - movs r2, #0 - strb r0, [r3, #0x1a] - mov r0, sp - strh r2, [r0, #0x16] - mov r1, sp - movs r0, #0xff - strb r0, [r1, #0x1b] - movs r0, #0x10 - strb r0, [r1, #0x1c] - movs r0, #0xb - strb r0, [r1, #0x1f] - mov r0, sp - ldr r1, _0814450C @ =0x0000FFC0 - strh r1, [r0, #0x10] - strh r1, [r0, #0x12] - str r2, [sp, #8] - bl sub_08155128 - movs r0, #1 -_08144502: - add sp, #0x28 - pop {r4} - pop {r1} - bx r1 - .align 2, 0 -_0814450C: .4byte 0x0000FFC0 - - thumb_func_start sub_08144510 -sub_08144510: @ 0x08144510 - push {r4, r5, lr} - sub sp, #0x28 - adds r4, r0, #0 - mov r0, sp - movs r1, #0 - movs r2, #0x28 - bl memset - adds r0, r4, #0 - adds r0, #0x2a - ldrb r0, [r0] - ldr r1, _08144558 @ =gUnk_08386A50 - lsls r0, r0, #2 - adds r0, r0, r1 - ldrb r0, [r0] - subs r0, #1 - lsls r0, r0, #0x18 - lsrs r3, r0, #0x18 - movs r0, #0 - strb r3, [r4, #1] - str r0, [sp] - mov r1, sp - movs r0, #0xf8 - lsls r0, r0, #3 - strh r0, [r1, #0x14] - mov r4, sp - lsls r0, r3, #0x18 - asrs r2, r0, #0x18 - movs r0, #1 - rsbs r0, r0, #0 - cmp r2, r0 - bne _08144560 - ldr r0, _0814455C @ =gUnk_08386AF0 - ldrh r2, [r0] - adds r1, r0, #0 - b _08144568 - .align 2, 0 -_08144558: .4byte gUnk_08386A50 -_0814455C: .4byte gUnk_08386AF0 -_08144560: - ldr r1, _0814457C @ =gUnk_08386AF0 - lsls r0, r2, #2 - adds r0, r0, r1 - ldrh r2, [r0] -_08144568: - strh r2, [r4, #0xc] - mov r5, sp - lsls r0, r3, #0x18 - asrs r4, r0, #0x18 - movs r0, #1 - rsbs r0, r0, #0 - cmp r4, r0 - bne _08144580 - ldrb r0, [r1, #2] - b _08144588 - .align 2, 0 -_0814457C: .4byte gUnk_08386AF0 -_08144580: - lsls r0, r4, #2 - adds r1, #2 - adds r0, r0, r1 - ldrb r0, [r0] -_08144588: - movs r2, #0 - strb r0, [r5, #0x1a] - mov r0, sp - strh r2, [r0, #0x16] - mov r1, sp - movs r0, #0xff - strb r0, [r1, #0x1b] - movs r0, #0x10 - strb r0, [r1, #0x1c] - movs r0, #0xa - strb r0, [r1, #0x1f] - mov r0, sp - ldr r1, _081445B8 @ =0x0000FFC0 - strh r1, [r0, #0x10] - strh r1, [r0, #0x12] - str r2, [sp, #8] - bl sub_08155128 - movs r0, #1 - add sp, #0x28 - pop {r4, r5} - pop {r1} - bx r1 - .align 2, 0 -_081445B8: .4byte 0x0000FFC0 - - thumb_func_start sub_081445BC -sub_081445BC: @ 0x081445BC - push {r4, r5, lr} - adds r2, r0, #0 - ldr r0, _08144644 @ =gUnk_08386A50 - adds r1, r2, #0 - adds r1, #0x2a - ldrb r1, [r1] - lsls r1, r1, #0x18 - asrs r1, r1, #0x18 - lsls r1, r1, #2 - adds r1, r1, r0 - ldrh r1, [r1] - lsrs r1, r1, #8 - adds r3, r0, #0 - cmp r1, #1 - beq _081445DE - cmp r1, #0x10 - bne _08144666 -_081445DE: - adds r0, r2, #0 - adds r0, #0x2a - ldrb r0, [r0] - lsls r0, r0, #0x18 - asrs r0, r0, #0x18 - lsls r0, r0, #2 - adds r0, r0, r3 - ldrh r1, [r0] - adds r0, r2, #0 - adds r0, #0x2b - ldrb r0, [r0] - lsls r0, r0, #0x18 - asrs r0, r0, #0x18 - lsls r0, r0, #2 - adds r0, r0, r3 - ldrh r0, [r0] - lsrs r1, r1, #8 - lsrs r0, r0, #8 - cmp r1, r0 - beq _08144654 - adds r1, r2, #0 - adds r1, #0x2c - movs r0, #0 - strb r0, [r1] - adds r1, #1 - movs r0, #1 - strb r0, [r1] - movs r0, #0xd5 - lsls r0, r0, #3 - adds r5, r2, r0 - ldr r2, _08144648 @ =gUnk_08386838 - ldr r3, _0814464C @ =gLanguage - ldrh r1, [r3] - lsls r0, r1, #1 - adds r0, r0, r1 - lsls r0, r0, #3 - adds r1, r2, #6 - adds r0, r0, r1 - ldrh r0, [r0] - strh r0, [r5, #0xc] - ldrh r1, [r3] - lsls r0, r1, #1 - adds r0, r0, r1 - lsls r0, r0, #3 - adds r2, #8 - adds r0, r0, r2 - ldrh r0, [r0] - strb r0, [r5, #0x1a] - ldr r0, _08144650 @ =gUnk_08386A12 - ldrb r0, [r0, #1] - b _08144700 - .align 2, 0 -_08144644: .4byte gUnk_08386A50 -_08144648: .4byte gUnk_08386838 -_0814464C: .4byte gLanguage -_08144650: .4byte gUnk_08386A12 -_08144654: - adds r1, r2, #0 - adds r1, #0x2c - ldrb r0, [r1] - adds r0, #1 - strb r0, [r1] - lsls r0, r0, #0x18 - lsrs r0, r0, #0x18 - cmp r0, #0x1d - bhi _0814466A -_08144666: - movs r0, #0 - b _0814470A -_0814466A: - movs r0, #0 - strb r0, [r1] - movs r1, #0 - adds r3, r2, #0 - adds r3, #0x2d - ldrb r0, [r3] - cmp r0, #0 - bne _0814467C - movs r1, #1 -_0814467C: - strb r1, [r3] - adds r4, r1, #0 - movs r0, #0xd5 - lsls r0, r0, #3 - adds r5, r2, r0 - cmp r4, #3 - bhi _081446AC - ldr r3, _081446A4 @ =gUnk_08386838 - lsls r1, r4, #1 - adds r1, r1, r4 - lsls r1, r1, #1 - ldr r0, _081446A8 @ =gLanguage - ldrh r2, [r0] - lsls r0, r2, #1 - adds r0, r0, r2 - lsls r0, r0, #3 - adds r1, r1, r0 - adds r1, r1, r3 - ldrh r0, [r1] - b _081446BA - .align 2, 0 -_081446A4: .4byte gUnk_08386838 -_081446A8: .4byte gLanguage -_081446AC: - ldr r2, _081446DC @ =gUnk_083868C8 - subs r1, r4, #4 - lsls r0, r1, #1 - adds r0, r0, r1 - lsls r0, r0, #1 - adds r0, r0, r2 - ldrh r0, [r0] -_081446BA: - strh r0, [r5, #0xc] - cmp r4, #3 - bhi _081446E8 - ldr r3, _081446E0 @ =gUnk_08386838 - lsls r1, r4, #1 - adds r1, r1, r4 - lsls r1, r1, #1 - ldr r0, _081446E4 @ =gLanguage - ldrh r2, [r0] - lsls r0, r2, #1 - adds r0, r0, r2 - lsls r0, r0, #3 - adds r1, r1, r0 - adds r3, #2 - adds r1, r1, r3 - ldrb r0, [r1] - b _081446F8 - .align 2, 0 -_081446DC: .4byte gUnk_083868C8 -_081446E0: .4byte gUnk_08386838 -_081446E4: .4byte gLanguage -_081446E8: - ldr r2, _08144710 @ =gUnk_083868C8 - subs r1, r4, #4 - lsls r0, r1, #1 - adds r0, r0, r1 - lsls r0, r0, #1 - adds r2, #2 - adds r0, r0, r2 - ldrb r0, [r0] -_081446F8: - strb r0, [r5, #0x1a] - ldr r0, _08144714 @ =gUnk_08386A12 - adds r0, r4, r0 - ldrb r0, [r0] -_08144700: - strb r0, [r5, #0x1f] - adds r0, r5, #0 - bl sub_08155128 - movs r0, #1 -_0814470A: - pop {r4, r5} - pop {r1} - bx r1 - .align 2, 0 -_08144710: .4byte gUnk_083868C8 -_08144714: .4byte gUnk_08386A12 - - thumb_func_start sub_08144718 -sub_08144718: @ 0x08144718 - push {r4, r5, lr} - adds r3, r0, #0 - adds r1, r3, #0 - adds r1, #0x2c - ldrb r0, [r1] - adds r0, #1 - strb r0, [r1] - lsls r0, r0, #0x18 - lsrs r0, r0, #0x18 - cmp r0, #4 - bhi _08144732 - movs r0, #0 - b _081447D2 -_08144732: - movs r0, #0 - strb r0, [r1] - movs r1, #0 - adds r2, r3, #0 - adds r2, #0x2d - ldrb r0, [r2] - cmp r0, #0 - bne _08144744 - movs r1, #1 -_08144744: - strb r1, [r2] - adds r4, r1, #0 - movs r0, #0xd5 - lsls r0, r0, #3 - adds r5, r3, r0 - cmp r4, #3 - bhi _08144774 - ldr r3, _0814476C @ =gUnk_08386838 - lsls r1, r4, #1 - adds r1, r1, r4 - lsls r1, r1, #1 - ldr r0, _08144770 @ =gLanguage - ldrh r2, [r0] - lsls r0, r2, #1 - adds r0, r0, r2 - lsls r0, r0, #3 - adds r1, r1, r0 - adds r1, r1, r3 - ldrh r0, [r1] - b _08144782 - .align 2, 0 -_0814476C: .4byte gUnk_08386838 -_08144770: .4byte gLanguage -_08144774: - ldr r2, _081447A4 @ =gUnk_083868C8 - subs r1, r4, #4 - lsls r0, r1, #1 - adds r0, r0, r1 - lsls r0, r0, #1 - adds r0, r0, r2 - ldrh r0, [r0] -_08144782: - strh r0, [r5, #0xc] - cmp r4, #3 - bhi _081447B0 - ldr r3, _081447A8 @ =gUnk_08386838 - lsls r1, r4, #1 - adds r1, r1, r4 - lsls r1, r1, #1 - ldr r0, _081447AC @ =gLanguage - ldrh r2, [r0] - lsls r0, r2, #1 - adds r0, r0, r2 - lsls r0, r0, #3 - adds r1, r1, r0 - adds r3, #2 - adds r1, r1, r3 - ldrb r0, [r1] - b _081447C0 - .align 2, 0 -_081447A4: .4byte gUnk_083868C8 -_081447A8: .4byte gUnk_08386838 -_081447AC: .4byte gLanguage -_081447B0: - ldr r2, _081447D8 @ =gUnk_083868C8 - subs r1, r4, #4 - lsls r0, r1, #1 - adds r0, r0, r1 - lsls r0, r0, #1 - adds r2, #2 - adds r0, r0, r2 - ldrb r0, [r0] -_081447C0: - strb r0, [r5, #0x1a] - ldr r0, _081447DC @ =gUnk_08386A12 - adds r0, r4, r0 - ldrb r0, [r0] - strb r0, [r5, #0x1f] - adds r0, r5, #0 - bl sub_08155128 - movs r0, #1 -_081447D2: - pop {r4, r5} - pop {r1} - bx r1 - .align 2, 0 -_081447D8: .4byte gUnk_083868C8 -_081447DC: .4byte gUnk_08386A12 - - thumb_func_start sub_081447E0 -sub_081447E0: @ 0x081447E0 - push {lr} - adds r3, r0, #0 - ldr r0, _08144818 @ =gPressedKeys - ldrh r1, [r0] - movs r0, #1 - ands r0, r1 - cmp r0, #0 - beq _08144814 - adds r0, r3, #0 - adds r0, #0x2a - movs r2, #0 - ldrsb r2, [r0, r2] - adds r0, r3, #2 - adds r0, r0, r2 - ldrb r0, [r0] - cmp r0, #0 - beq _08144814 - ldr r1, _0814481C @ =gUnk_08386A50 - lsls r0, r2, #2 - adds r0, r0, r1 - ldrh r0, [r0] - lsrs r1, r0, #8 - cmp r1, #1 - beq _08144820 - cmp r1, #0x10 - beq _08144840 -_08144814: - movs r0, #0 - b _08144856 - .align 2, 0 -_08144818: .4byte gPressedKeys -_0814481C: .4byte gUnk_08386A50 -_08144820: - lsls r0, r0, #0x18 - asrs r0, r0, #0x18 - subs r0, #1 - movs r1, #1 - ldrsb r1, [r3, r1] - cmp r0, r1 - beq _08144814 - ldr r0, _08144838 @ =sub_081440F8 - str r0, [r3, #0x38] - ldr r0, _0814483C @ =0x00000223 - b _08144850 - .align 2, 0 -_08144838: .4byte sub_081440F8 -_0814483C: .4byte 0x00000223 -_08144840: - adds r0, r3, #0 - adds r0, #0x37 - ldrb r0, [r0] - cmp r0, #0 - beq _08144814 - ldr r0, _0814485C @ =sub_08144864 - str r0, [r3, #0x38] - ldr r0, _08144860 @ =0x0000021E -_08144850: - bl m4aSongNumStart - movs r0, #1 -_08144856: - pop {r1} - bx r1 - .align 2, 0 -_0814485C: .4byte sub_08144864 -_08144860: .4byte 0x0000021E - thumb_func_start sub_08144864 sub_08144864: @ 0x08144864 push {r4, r5, r6, r7, lr} diff --git a/include/code_0814A828.h b/include/code_0814A828.h new file mode 100644 index 0000000..2c8c23f --- /dev/null +++ b/include/code_0814A828.h @@ -0,0 +1,41 @@ +#ifndef GUARD_CODE_0814A828_H +#define GUARD_CODE_0814A828_H + +#include "global.h" +#include "bg.h" +#include "sprite.h" + +struct Unk_0814E394 { + u8 unk0; + void (*unk4)(struct Unk_0814E394 *); + u16 unk8; + struct Unk_0814A828 *unkC; + struct Sprite unk10[2]; + s32 unk60; + s32 unk64; + s32 unk68; + s32 unk6C; + s32 unk70; + s32 unk74; +}; /* size = 0x78 */ + +struct Unk_0814A828 { + u8 filler0[4]; + u32 unk4; + void (*unk8)(struct Unk_0814A828 *); + u16 unkC; + struct Sprite unk10; + struct Sprite unk38; + struct Background unk60; + void (*unkA0)(struct Unk_0814A828 *); + u16 unkA4; + u16 unkA6; + struct Task *unkA8; + struct Task *unkAC; + u8 fillerB0[8]; + struct Unk_0814E394 *unkB8; + struct Unk_0814E394 *unkBC; + u8 fillerC0[8]; +}; /* size = 0xC8 */ + +#endif diff --git a/include/collection_room.h b/include/collection_room.h index 380a1d1..7e98aa7 100644 --- a/include/collection_room.h +++ b/include/collection_room.h @@ -11,7 +11,7 @@ struct Unk_081434F8 { s8 unk2A; s8 unk2B; u8 unk2C; - u8 unk2D; + bool8 unk2D; s16 unk2E; u16 unk30; s16 unk32; @@ -19,7 +19,7 @@ struct Unk_081434F8 { u8 unk36; u8 unk37; void (*unk38)(struct Unk_081434F8 *); - u16 unk3C; + s16 unk3C; struct Sprite unk40[0x39]; }; /* size = 0x928 */ diff --git a/linker.ld b/linker.ld index e63d8d6..0d04201 100644 --- a/linker.ld +++ b/linker.ld @@ -363,6 +363,7 @@ SECTIONS { asm/collection_room.o(.text); asm/intro.o(.text); src/title_screen.o(.text); + src/code_0814A828.o(.text); asm/code_0814A828.o(.text); asm/m4a_asm.o(.text); src/m4a.o(.text); diff --git a/src/code_0814A828.c b/src/code_0814A828.c new file mode 100644 index 0000000..3a3ba63 --- /dev/null +++ b/src/code_0814A828.c @@ -0,0 +1,29 @@ +#include "data.h" +#include "code_0814A828.h" +#include "functions.h" +#include "kirby.h" + +void sub_0814A914(void); +void nullsub_12(struct Task *); +void sub_0814E0B4(struct Unk_0814A828 *); + +void sub_0814A828(void) { + u16 color, i; + struct Task *t; + struct Unk_0814A828 *var; + + if (gUnk_0203AD10 & 0x10) + sub_08039670(); + else if (gUnk_0203AD2C < 300) { + color = RGB_WHITE; + sub_0803D21C(&color, 0, 1); + gDispCnt = DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP; + m4aSoundVSyncOn(); + for (i = 0; i < gUnk_0203AD30; ++i) + gKirbys[i].base.base.base.flags &= ~0x1000000; + t = TaskCreate(sub_0814A914, sizeof(struct Unk_0814A828), 0x1000, TASK_USE_IWRAM | TASK_x0004, nullsub_12); + var = TaskGetStructPtr(t); + CpuFill16(0, var, sizeof(struct Unk_0814A828)); + var->unk8 = sub_0814E0B4; + } +} diff --git a/src/collection_room.c b/src/collection_room.c index c1ca68a..39d6b01 100644 --- a/src/collection_room.c +++ b/src/collection_room.c @@ -10,7 +10,25 @@ void sub_08143664(struct Task *); void sub_08143730(struct Unk_081434F8 *); u8 sub_08143A90(struct Unk_081434F8 *); void sub_08143DA8(struct Unk_081434F8 *); +void sub_08143EF4(struct Unk_081434F8 *); +void sub_0814405C(struct Unk_081434F8 *); +void sub_081441A8(struct Unk_081434F8 *); +bool32 sub_08144238(struct Unk_081434F8 *); +void sub_08144304(struct Unk_081434F8 *); +bool32 sub_081443D8(struct Unk_081434F8 *); +bool32 sub_08144438(struct Unk_081434F8 *); +bool32 sub_08144510(struct Unk_081434F8 *); +bool32 sub_081445BC(struct Unk_081434F8 *); +bool32 sub_08144718(struct Unk_081434F8 *); +bool32 sub_081447E0(struct Unk_081434F8 *); +void sub_08144864(struct Unk_081434F8 *); void sub_08145620(void); +void sub_0814565C(struct Unk_081434F8 *); +void sub_08145718(struct Unk_081434F8 *); +void sub_08145848(struct Unk_081434F8 *); +void sub_08145974(struct Unk_081434F8 *); +void sub_081459EC(struct Unk_081434F8 *); +void sub_081459FC(struct Unk_081434F8 *); const u32 gUnk_0838665C[] = { 2, 1 }; @@ -35,38 +53,38 @@ const u16 gUnk_08386664[NUM_LANGUAGES][0x27] = { 0x1FB, 0x1FC, 0x1FD, 0x1FE, 0x1FF, 0x200, 0x201, 0x202, 0x203, 0x204, 0x205, 0x206, 0x207 }, }; -const u16 gUnk_08386838[][4][3] = { - { +const u16 gUnk_08386838[NUM_LANGUAGES][4][3] = { + [LANGUAGE_JAPANESE] = { { 0x389, 0x0, 0x8 }, { 0x389, 0x1, 0x8 }, { 0x38F, 0x0, 0xE }, { 0x38F, 0x1, 0x10 }, }, - { + [LANGUAGE_ENGLISH] = { { 0x389, 0x0, 0x8 }, { 0x389, 0x1, 0x8 }, { 0x38B, 0x0, 0xE }, { 0x38B, 0x1, 0x10 }, }, - { + [LANGUAGE_GERMAN] = { { 0x389, 0x0, 0x8 }, { 0x389, 0x1, 0x8 }, { 0x38A, 0x0, 0xE }, { 0x38A, 0x1, 0xC }, }, - { + [LANGUAGE_FRENCH] = { { 0x389, 0x0, 0x8 }, { 0x389, 0x1, 0x8 }, { 0x38D, 0x0, 0xE }, { 0x38D, 0x1, 0xC }, }, - { + [LANGUAGE_SPANISH] = { { 0x389, 0x0, 0x8 }, { 0x389, 0x1, 0x8 }, { 0x38C, 0x0, 0xE }, { 0x38C, 0x1, 0xE }, }, - { + [LANGUAGE_ITALIAN] = { { 0x389, 0x0, 0x8 }, { 0x389, 0x1, 0x8 }, { 0x38E, 0x0, 0xE }, @@ -666,7 +684,7 @@ void sub_081434F8(void) { DmaFill16(3, 0, var, sizeof(struct Unk_081434F8)); var->unk38 = sub_08143DA8; - var->unk2D = 1; + var->unk2D = TRUE; var->unk30 = 0xFFFF; var->unk1 = gUnk_0203ADE0; sub_08143730(var); @@ -732,7 +750,7 @@ bool32 sub_081436D8(struct Unk_081434F8 *a1) { void sub_08143730(struct Unk_081434F8 *a1) { u8 *arr = a1->unk2; - u8 i, j, k; // r1, r4, r2 + u8 i, j, k; bool32 r4; u8 r5; @@ -843,11 +861,11 @@ u8 sub_08143A90(struct Unk_081434F8 *a1) { return ret; } -struct Unk_02021590_Clone { - u16 animId; - u8 variant; - s8 unk3; -}; +#define gUnk_08386AF0_aligned ({ \ + const struct Unk_02021590 *ptr = (const void *)gUnk_08386AF0; \ + \ + ptr; \ +}) void sub_08143AF8(struct Unk_081434F8 *a1) { struct Sprite sp00; @@ -898,19 +916,408 @@ void sub_08143AF8(struct Unk_081434F8 *a1) { a1->unk1 == -1 ? gUnk_08386AF0[0].variant : gUnk_08386AF0[a1->unk1].variant, 0, 0xFF, 0x10, 0xA, -0x40, -0x40, 0); #else - sp00.tilesVram = 0; - sp00.unk14 = 0x7C0; - sp00.animId = a1->unk1 == -1 - ? ((const struct Unk_02021590 *)gUnk_08386AF0)[0].animId - : (ptr = (const struct Unk_02021590 *)gUnk_08386AF0, ptr[a1->unk1].animId); - sp00.variant = (a1->unk1 == -1 ? gUnk_08386AF0[0].variant : gUnk_08386AF0[a1->unk1].variant) ^ 0; - sp00.unk16 = 0; - sp00.unk1B = 0xFF; - sp00.unk1C = 0x10; - sp00.palId = 0xA; - sp00.x = -0x40; - sp00.y = -0x40; - sp00.unk8 = 0; - sub_08155128(&sp00); + SpriteInitNoPointer2(&sp00, 0, 0x7C0, + a1->unk1 == -1 ? gUnk_08386AF0_aligned[0].animId : gUnk_08386AF0_aligned[a1->unk1].animId, + (a1->unk1 == -1 ? gUnk_08386AF0[0].variant : gUnk_08386AF0[a1->unk1].variant) ^ 0, + 0, 0xFF, 0x10, 0xA, -0x40, -0x40, 0); #endif } + +void sub_08143DA8(struct Unk_081434F8 *a1) { + u8 i; + + gVramHeapMaxTileSlots = 0x400; + gVramHeapStartAddr = 0x6010000; + DmaFill16(3, RGB_WHITE, gBgPalette, sizeof(gBgPalette)); + DmaFill16(3, RGB_WHITE, gObjPalette, sizeof(gObjPalette)); + gMainFlags |= MAIN_FLAG_BG_PALETTE_SYNC_ENABLE | MAIN_FLAG_OBJ_PALETTE_SYNC_ENABLE; + gDispCnt = DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | DISPCNT_BG1_ON; + for (i = 0; i < 2; ++i) + gBgCntRegs[i] = gUnk_0838665C[i] | ((0x1F - i) << 8) | (i << 2); + a1->unk38 = sub_0814565C; +} + +void sub_08143E6C(struct Unk_081434F8 *a1) { // see sub_0813FF6C + const struct TiledBg_082D7850 *ptr; + const u16 *tilemap; + u16 height; + u16 *vram, *dst; + const u32 *tileset; + u16 idx; + u16 i; + u32 j; + + idx = gUnk_08386664[gLanguage][0]; + ptr = gUnk_082D7850[idx]; + tileset = ptr->tileset; + do tilemap = ptr->tilemap; while (0); + height = ptr->height; +#ifndef NONMATCHING + asm("mov\t%0, #0":"=r"(j)::"cc"); +#else + j = 0; +#endif + dst = (void *)0x6000000 + j; + vram = (void *)0x600F800 + j; + gBgScrollRegs[0][0] = j; + gBgScrollRegs[0][1] = j; + LZ77UnCompVram(tileset, dst); + for (i = 0; i < height; ++i) + DmaCopy16(3, tilemap + i * 0x1E, vram + i * 0x20, 0x20 * sizeof(u16)); + a1->unk38 = sub_08143EF4; +} + +void sub_08143EF4(struct Unk_081434F8 *a1) { + const struct TiledBg_082D7850 *ptr; + const u16 *tilemap; + u16 height; + u16 *vram; + const u32 *tileset; + u16 idx; + u16 i; + + idx = gUnk_08386664[gLanguage][gUnk_08386A50[0].unk3]; + ptr = gUnk_082D7850[idx]; + tileset = ptr->tileset; + tilemap = ptr->tilemap; + height = ptr->height; + vram = (void *)0x600F340; + gBgScrollRegs[1][0] = 0; + gBgScrollRegs[1][1] = 0; + LZ77UnCompVram(tileset, (u16 *)0x6004000); + for (i = 0; i < height; ++i) + DmaCopy16(3, tilemap + i * 0x1E, vram + i * 0x20, 0x20 * sizeof(u16)); + a1->unk38 = sub_08145718; +} + +static inline struct Sprite *GetSpriteFromArray(struct Unk_081434F8 *a1, u8 idx) { + return &a1->unk40[idx]; +} + +void sub_08143F88(struct Unk_081434F8 *a1) { + u8 i, j; + struct Sprite *sprite; + + for (i = 0; i < 0xA; ++i) { + gKeysContinuedRepeatIntervals[i] = 5; + gKeysFirstRepeatIntervals[i] = 0xA; + } + a1->unk2C = 0; + a1->unk2D = TRUE; + sprite = &a1->unk40[0x29]; + sprite->animId = gUnk_08386838[gLanguage][1][0]; + sprite->variant = gUnk_08386838[gLanguage][1][1]; + sprite->palId = gUnk_08386A12[1]; + sub_08155128(sprite); + sub_08144438(a1); + a1->unk38 = sub_0814405C; + for (j = 0; j < 0x28; ++j) { + if (a1->unk2[j]) + sub_0815604C(&a1->unk40[j]); + } + sub_0815604C(GetSpriteFromArray(a1, 0x28)); + sub_08145974(a1); +} + +void sub_0814405C(struct Unk_081434F8 *a1) { + u8 i; + + a1->unk2B = a1->unk2A; + if (!sub_081447E0(a1)) { + if (gPressedKeys & B_BUTTON) { + m4aSongNumStart(543); + a1->unk38 = sub_08145848; + } + else + { + sub_08144238(a1); + sub_08143A38(a1); + sub_081443D8(a1); + sub_08144438(a1); + sub_08144304(a1); + } + } + sub_081445BC(a1); + for (i = 0; i < 0x28; ++i) { + if (a1->unk2[i]) + sub_0815604C(&a1->unk40[i]); + } + sub_0815604C(GetSpriteFromArray(a1, 0x28)); + sub_08145974(a1); +} + +void sub_081440F8(struct Unk_081434F8 *a1) { + u8 i; + struct Sprite *sprite; + + a1->unk2C = 0; + a1->unk2D = TRUE; + sprite = &a1->unk40[0x29]; + sprite->animId = gUnk_08386838[gLanguage][1][0]; + sprite->variant = gUnk_08386838[gLanguage][1][1]; + sprite->palId = gUnk_08386A12[1]; + sub_08155128(sprite); + sub_08144510(a1); + sub_081459EC(a1); + a1->unk3C = 0; + a1->unk38 = sub_081441A8; + a1->unk40[0x2C].unk1B = 0xFF; + for (i = 0; i < 0x28; ++i) { + if (a1->unk2[i]) + sub_0815604C(&a1->unk40[i]); + } + sub_0815604C(GetSpriteFromArray(a1, 0x28)); + sub_08145974(a1); +} + +void sub_081441A8(struct Unk_081434F8 *a1) { + u8 i; + struct Sprite *sprite; + + if (++a1->unk3C > 0x1D) { + gUnk_0203ADE0 = a1->unk1; + a1->unk38 = sub_08143F88; + } + sub_08144718(a1); + sub_081459FC(a1); + if (!sub_08155128(&a1->unk40[0x2C])) + a1->unk40[0x2C].unk1B = 0xFF; + sub_0815604C(&a1->unk40[0x2C]); + for (i = 0; i < 0x28; ++i) { + if (a1->unk2[i]) + sub_0815604C(&a1->unk40[i]); + } + sub_0815604C(GetSpriteFromArray(a1, 0x28)); + sub_08145974(a1); +} + +bool32 sub_08144238(struct Unk_081434F8 *a1) { + s8 ones = a1->unk2A % 10; + s8 tens = a1->unk2A / 10; + u8 var; + + if (gRepeatedKeys & DPAD_UP) { + if (--tens < 0) + tens = 3; + } + if (gRepeatedKeys & DPAD_DOWN) { + if (++tens > 3) + tens = 0; + } + if (gRepeatedKeys & DPAD_LEFT) { + if (--ones < 0) + ones = 9; + } + if (gRepeatedKeys & DPAD_RIGHT) { + if (++ones > 9) + ones = 0; + } + var = 10 * tens + ones; + if (var == a1->unk2A) { + return FALSE; + } else { + a1->unk2A = var; + m4aSongNumStart(541); + return TRUE; + } +} + +void sub_08144304(struct Unk_081434F8 *a1) { + if (a1->unk2B != a1->unk2A) { + if (a1->unk2[a1->unk2A]) { + const struct TiledBg_082D7850 *ptr; + const u16 *tilemap; + u16 height; + u16 *vram; + const u32 *tileset; + u16 idx; + u16 i; + + idx = gUnk_08386664[gLanguage][gUnk_08386A50[a1->unk2A].unk3]; + ptr = gUnk_082D7850[idx]; + tileset = ptr->tileset; + tilemap = ptr->tilemap; + height = ptr->height; + vram = (void *)0x600F340; + gBgScrollRegs[1][0] = 0; + gBgScrollRegs[1][1] = 0; + LZ77UnCompVram(tileset, (u16 *)0x6004000); + for (i = 0; i < height; ++i) + DmaCopy16(3, tilemap + i * 0x1E, vram + i * 0x20, 0x20 * sizeof(u16)); + } else { + DmaFill16(3, 0, (u16 *)0x6004000, 0x4000); + } + } +} + +bool32 sub_081443D8(struct Unk_081434F8 *a1) { + u32 r2 = gUnk_08386A50[a1->unk2A].unk0; + u32 r0 = gUnk_08386A50[a1->unk2B].unk0; + struct Sprite *sprite; + + r2 >>= 8; + r0 >>= 8; + if (r2 == r0) return FALSE; + switch (r2) { + case 1: + sprite = &a1->unk40[0x29]; + sprite->x = 0x98; + sprite->y = 0x8A; + break; + case 0x10: + sprite = &a1->unk40[0x29]; + sprite->x = 0xB4; + sprite->y = 0x79; + break; + } + return TRUE; +} + +#ifdef NONMATCHING +bool32 sub_08144438(struct Unk_081434F8 *a1) { + struct Sprite sprite; + u16 unk0; + s8 r3; + u8 unk2A; + + memset(&sprite, 0, sizeof(struct Sprite)); + unk2A = a1->unk2A; + unk0 = gUnk_08386A50[unk2A].unk0; + r3 = unk0 - 1; + if (a1->unk2[unk2A] == 0 + || (unk0 >> 8) != 1 + || unk2A == a1->unk2B + || r3 < 0) + return FALSE; + SpriteInitNoPointer2(&sprite, 0, 0x7C0, + r3 == -1 ? gUnk_08386AF0[0].animId : gUnk_08386AF0[r3].animId, + r3 == -1 ? gUnk_08386AF0[0].variant : gUnk_08386AF0[r3].variant, + 0, 0xFF, 0x10, 0xB, -0x40, -0x40, 0); + return TRUE; +} +#else +bool32 sub_08144438(struct Unk_081434F8 *a1) { + struct Sprite sprite; + u16 unk0; + s8 r3; + u8 unk2A; + register u8 r0 asm("r0"); + + memset(&sprite, 0, sizeof(struct Sprite)); + r0 = a1->unk2A; + asm(""::"r"(r0)); + unk2A = r0; + unk0 = gUnk_08386A50[unk2A].unk0; + r3 = unk0 - 1; + if (a1->unk2[unk2A] == 0 + || (unk0 >> 8) != 1 + || unk2A == a1->unk2B + || r3 < 0) + return FALSE; + SpriteInitNoPointer2(&sprite, 0, 0x7C0, + r3 == -1 ? gUnk_08386AF0_aligned[0].animId : gUnk_08386AF0_aligned[r3].animId, + r3 == -1 ? gUnk_08386AF0[0].variant : gUnk_08386AF0[r3].variant, + 0, 0xFF, 0x10, 0xB, -0x40, -0x40, 0); + return TRUE; +} +#endif + +bool32 sub_08144510(struct Unk_081434F8 *a1) { + struct Sprite sprite; + u8 unk0; + s8 r3; + u8 unk2A; + + memset(&sprite, 0, sizeof(struct Sprite)); + unk2A = a1->unk2A; + unk0 = gUnk_08386A50[unk2A].unk0; + r3 = unk0 - 1; + a1->unk1 = r3; +#ifdef NONMATCHING + SpriteInitNoPointer2(&sprite, 0, 0x7C0, + r3 == -1 ? gUnk_08386AF0[0].animId : gUnk_08386AF0[r3].animId, + r3 == -1 ? gUnk_08386AF0[0].variant : gUnk_08386AF0[r3].variant, + 0, 0xFF, 0x10, 0xA, -0x40, -0x40, 0); +#else + SpriteInitNoPointer2(&sprite, 0, 0x7C0, + r3 == -1 ? gUnk_08386AF0_aligned[0].animId : gUnk_08386AF0_aligned[r3].animId, + r3 == -1 ? gUnk_08386AF0[0].variant : gUnk_08386AF0[r3].variant, + 0, 0xFF, 0x10, 0xA, -0x40, -0x40, 0); +#endif + return TRUE; +} + +bool32 sub_081445BC(struct Unk_081434F8 *a1) { + u32 r1 = gUnk_08386A50[a1->unk2A].unk0 >> 8; + struct Sprite *sprite; + bool8 v3; + + if (r1 != 1 && r1 != 0x10) { + return FALSE; + } else { + if (gUnk_08386A50[a1->unk2A].unk0 >> 8 != gUnk_08386A50[a1->unk2B].unk0 >> 8) { + a1->unk2C = 0; + a1->unk2D = TRUE; + sprite = &a1->unk40[0x29]; + sprite->animId = gUnk_08386838[gLanguage][1][0]; + sprite->variant = gUnk_08386838[gLanguage][1][1]; + sprite->palId = gUnk_08386A12[1]; + sub_08155128(sprite); + return TRUE; + } else { + if (++a1->unk2C < 0x1E) + return FALSE; + a1->unk2C = 0; + v3 = a1->unk2D = !a1->unk2D; + sprite = &a1->unk40[0x29]; + sprite->animId = v3 < 4 ? gUnk_08386838[gLanguage][v3][0] : gUnk_083868C8[v3 - 4][0]; + sprite->variant = v3 < 4 ? gUnk_08386838[gLanguage][v3][1] : gUnk_083868C8[v3 - 4][1]; + sprite->palId = gUnk_08386A12[v3]; + sub_08155128(sprite); + return TRUE; + } + } +} + +bool32 sub_08144718(struct Unk_081434F8 *a1) { + struct Sprite *sprite; + bool8 v3; + + if (++a1->unk2C < 5) + return FALSE; + a1->unk2C = 0; + v3 = a1->unk2D = !a1->unk2D; + sprite = &a1->unk40[0x29]; + sprite->animId = v3 < 4 ? gUnk_08386838[gLanguage][v3][0] : gUnk_083868C8[v3 - 4][0]; + sprite->variant = v3 < 4 ? gUnk_08386838[gLanguage][v3][1] : gUnk_083868C8[v3 - 4][1]; + sprite->palId = gUnk_08386A12[v3]; + sub_08155128(sprite); + return TRUE; +} + +bool32 sub_081447E0(struct Unk_081434F8 *a1) { + u32 unk0; + + if (!(gPressedKeys & A_BUTTON) || !a1->unk2[a1->unk2A]) + return FALSE; + do unk0 = gUnk_08386A50[a1->unk2A].unk0; while (0); + switch (unk0 >> 8) { + case 1: + if ((s8)unk0 - 1 == a1->unk1) { + return FALSE; + } else { + a1->unk38 = sub_081440F8; + m4aSongNumStart(547); + return TRUE; + } + case 0x10: + if (!a1->unk37) { + return FALSE; + } else { + a1->unk38 = sub_08144864; + m4aSongNumStart(542); + return TRUE; + } + } + return FALSE; +}