diff --git a/asm/code_805D8C8.s b/asm/code_805D8C8.s index 05471bbec..b90239e08 100644 --- a/asm/code_805D8C8.s +++ b/asm/code_805D8C8.s @@ -443,7 +443,7 @@ _08061D8E: mov r8, r2 b _080621E6 .align 2, 0 -_08061D94: .4byte gUnknown_203B080 +_08061D94: .4byte gIwramTextFunc1 _08061D98: ldr r0, _08061DDC ldrh r1, [r0, 0x4] @@ -481,7 +481,7 @@ _08061DC2: .align 2, 0 _08061DDC: .4byte gRealInputs _08061DE0: .4byte gUnknown_202EE10 -_08061DE4: .4byte gUnknown_203B080 +_08061DE4: .4byte gIwramTextFunc1 _08061DE8: adds r0, r1, 0 movs r1, 0 @@ -514,7 +514,7 @@ _08061E0A: add r1, sp b _08061F90 .align 2, 0 -_08061E24: .4byte gUnknown_203B084 +_08061E24: .4byte gIwramTextFunc2 _08061E28: ldr r0, _08061E74 ldrh r1, [r0, 0x4] @@ -556,7 +556,7 @@ _08061E58: .align 2, 0 _08061E74: .4byte gRealInputs _08061E78: .4byte gUnknown_202EE10 -_08061E7C: .4byte gUnknown_203B084 +_08061E7C: .4byte gIwramTextFunc2 _08061E80: adds r0, r1, 0 movs r1, 0 @@ -589,7 +589,7 @@ _08061EA6: bge _08061EA6 b _08061EFC .align 2, 0 -_08061EBC: .4byte gUnknown_203B080 +_08061EBC: .4byte gIwramTextFunc1 _08061EC0: ldr r0, _08061F0C ldrh r1, [r0, 0x4] @@ -632,7 +632,7 @@ _08061F04: .align 2, 0 _08061F0C: .4byte gRealInputs _08061F10: .4byte gUnknown_202EE10 -_08061F14: .4byte gUnknown_203B080 +_08061F14: .4byte gIwramTextFunc1 _08061F18: adds r0, r1, 0 movs r1, 0 @@ -660,7 +660,7 @@ _08061F36: bge _08061F36 b _08061F8E .align 2, 0 -_08061F4C: .4byte gUnknown_203B084 +_08061F4C: .4byte gIwramTextFunc2 _08061F50: ldr r0, _08061F9C ldrh r1, [r0, 0x4] @@ -704,7 +704,7 @@ _08061F96: .align 2, 0 _08061F9C: .4byte gRealInputs _08061FA0: .4byte gUnknown_202EE10 -_08061FA4: .4byte gUnknown_203B084 +_08061FA4: .4byte gIwramTextFunc2 _08061FA8: adds r0, r1, 0 movs r1, 0 @@ -9131,7 +9131,7 @@ _0806633E: .align 2, 0 _08066348: .4byte gUnknown_8106D8C _0806634C: .4byte gFormatBuffer_Monsters -_08066350: .4byte gUnknown_203B084 +_08066350: .4byte gIwramTextFunc2 _08066354: .4byte gUnknown_202F2F8 thumb_func_end sub_8066288 @@ -9233,7 +9233,7 @@ _0806641A: .align 2, 0 _08066424: .4byte gUnknown_8106D8C _08066428: .4byte gFormatBuffer_Monsters -_0806642C: .4byte gUnknown_203B080 +_0806642C: .4byte gIwramTextFunc1 _08066430: .4byte gUnknown_202F2F8 thumb_func_end sub_8066358 diff --git a/asm/code_8066D04.s b/asm/code_8066D04.s index 4535c860c..2449ee99a 100644 --- a/asm/code_8066D04.s +++ b/asm/code_8066D04.s @@ -1678,7 +1678,7 @@ _08067B98: .4byte gUnknown_202F308 _08067B9C: .4byte gUnknown_202F30C _08067BA0: .4byte gUnknown_202EE10 _08067BA4: .4byte gUnknown_8106DA4 -_08067BA8: .4byte gUnknown_203B080 +_08067BA8: .4byte gIwramTextFunc1 _08067BAC: ldr r0, _08067BF8 ldrh r1, [r0, 0x4] @@ -1721,7 +1721,7 @@ _08067BF0: .align 2, 0 _08067BF8: .4byte gRealInputs _08067BFC: .4byte gUnknown_202EE10 -_08067C00: .4byte gUnknown_203B080 +_08067C00: .4byte gIwramTextFunc1 _08067C04: adds r0, r1, 0 movs r1, 0 @@ -1754,7 +1754,7 @@ _08067C38: mov r10, r1 b _08067CF6 .align 2, 0 -_08067C40: .4byte gUnknown_203B084 +_08067C40: .4byte gIwramTextFunc2 _08067C44: ldr r0, _08067C8C ldrh r1, [r0, 0x4] @@ -1794,7 +1794,7 @@ _08067C84: .align 2, 0 _08067C8C: .4byte gRealInputs _08067C90: .4byte gUnknown_202EE10 -_08067C94: .4byte gUnknown_203B084 +_08067C94: .4byte gIwramTextFunc2 _08067C98: adds r0, r1, 0 movs r1, 0 @@ -2493,7 +2493,7 @@ _08068224: strh r0, [r4] b _080682E8 .align 2, 0 -_08068244: .4byte gUnknown_203B080 +_08068244: .4byte gIwramTextFunc1 _08068248: ldr r0, _0806828C ldrh r1, [r0, 0x4] @@ -2529,7 +2529,7 @@ _0806826C: b _080682E8 .align 2, 0 _0806828C: .4byte gRealInputs -_08068290: .4byte gUnknown_203B084 +_08068290: .4byte gIwramTextFunc2 _08068294: bl sub_80048C8 lsls r0, 24 diff --git a/asm/code_8272724.s b/asm/code_8272724.s deleted file mode 100644 index bd4cc80e1..000000000 --- a/asm/code_8272724.s +++ /dev/null @@ -1,538 +0,0 @@ - #include "asm/constants/gba_constants.inc" - #include "asm/macros.inc" - - .syntax unified - - - .text - - thumb_func_start sub_8272774 -sub_8272774: - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x10 - lsls r2, r1, 3 - adds r2, r1 - lsls r2, 3 - adds r4, r0, r2 - movs r1, 0x8 - ldrsh r0, [r4, r1] - cmp r0, 0 - ble _08272860 - ldr r0, [r4, 0xC] - cmp r0, 0x6 - bne _082727B0 - movs r2, 0x4 - ldrsh r1, [r4, r2] - ldr r0, [r4, 0x24] - adds r0, 0x2 - lsls r0, 3 - muls r0, r1 - lsls r0, 2 - ldr r1, [r4, 0x18] - adds r1, r0 - movs r3, 0x8 - ldrsh r0, [r4, r3] - subs r2, r0, 0x2 - b _082727B6 -_082727B0: - ldr r1, [r4, 0x18] - movs r5, 0x8 - ldrsh r2, [r4, r5] -_082727B6: - ldr r0, [r4, 0x20] - adds r3, r0, 0 - adds r3, 0x8 - str r3, [sp] - adds r0, 0x9 - mov r10, r0 - movs r3, 0 - movs r5, 0x4 - ldrsh r0, [r4, r5] - ldr r5, [r4, 0x28] - str r5, [sp, 0x8] - ldr r5, [r4, 0x1C] - str r5, [sp, 0x4] - adds r5, r4, 0 - adds r5, 0x44 - str r5, [sp, 0xC] - cmp r3, r0 - bge _0827284E - subs r7, r2, 0x1 - mov r9, r3 -_082727DE: - adds r2, r1, 0 - movs r0, 0x20 - adds r0, r2 - mov r12, r0 - adds r3, 0x1 - mov r8, r3 - cmp r7, 0 - ble _08272824 - ldr r1, [sp] - lsls r6, r1, 2 - adds r3, r7, 0 - mov r0, r10 - lsls r5, r0, 2 -_082727F8: - ldr r0, [r2, 0x8] - str r0, [r2] - ldr r0, [r2, 0xC] - str r0, [r2, 0x4] - ldr r0, [r2, 0x10] - str r0, [r2, 0x8] - ldr r0, [r2, 0x14] - str r0, [r2, 0xC] - ldr r0, [r2, 0x18] - str r0, [r2, 0x10] - ldr r0, [r2, 0x1C] - str r0, [r2, 0x14] - adds r1, r6, r2 - ldr r0, [r1] - str r0, [r2, 0x18] - adds r0, r5, r2 - ldr r0, [r0] - str r0, [r2, 0x1C] - adds r2, r1, 0 - subs r3, 0x1 - cmp r3, 0 - bne _082727F8 -_08272824: - ldr r0, [r2, 0x8] - str r0, [r2] - ldr r0, [r2, 0xC] - str r0, [r2, 0x4] - ldr r0, [r2, 0x10] - str r0, [r2, 0x8] - ldr r0, [r2, 0x14] - str r0, [r2, 0xC] - ldr r0, [r2, 0x18] - str r0, [r2, 0x10] - ldr r0, [r2, 0x1C] - str r0, [r2, 0x14] - mov r1, r9 - str r1, [r2, 0x18] - str r1, [r2, 0x1C] - mov r1, r12 - mov r3, r8 - movs r2, 0x4 - ldrsh r0, [r4, r2] - cmp r3, r0 - blt _082727DE -_0827284E: - ldr r3, [sp, 0x8] - str r3, [r4, 0x30] - ldr r5, [sp, 0x4] - str r5, [r4, 0x34] - ldr r0, [r4, 0x2C] - str r0, [r4, 0x38] - movs r0, 0x1 - ldr r1, [sp, 0xC] - strb r0, [r1] -_08272860: - add sp, 0x10 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_8272774 - - - thumb_func_start sub_8272870 -sub_8272870: - push {lr} - adds r1, r0, 0 - ldr r0, _08272880 - bl sub_8272884 - pop {r0} - bx r0 - .align 2, 0 -_08272880: .4byte gUnknown_2027370 - thumb_func_end sub_8272870 - - thumb_func_start sub_8272884 -sub_8272884: - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0xC - lsls r2, r1, 3 - adds r2, r1 - lsls r2, 3 - adds r5, r0, r2 - movs r1, 0x8 - ldrsh r0, [r5, r1] - cmp r0, 0 - ble _08272994 - ldr r0, [r5, 0xC] - cmp r0, 0x6 - bne _082728B0 - movs r2, 0x8 - ldrsh r0, [r5, r2] - subs r0, 0x2 - mov r9, r0 - b _082728B6 -_082728B0: - movs r0, 0x8 - ldrsh r3, [r5, r0] - mov r9, r3 -_082728B6: - movs r1, 0x8 - ldrsh r0, [r5, r1] - subs r0, 0x1 - movs r3, 0x4 - ldrsh r2, [r5, r3] - muls r0, r2 - lsls r0, 5 - ldr r1, [r5, 0x18] - adds r1, r0 - ldr r0, [r5, 0x20] - adds r0, 0x8 - mov r10, r0 - movs r4, 0 - ldr r0, [r5, 0x28] - str r0, [sp] - ldr r3, [r5, 0x1C] - str r3, [sp, 0x8] - adds r0, r5, 0 - adds r0, 0x44 - str r0, [sp, 0x4] - cmp r4, r2 - bge _08272982 - mov r12, r4 - movs r2, 0x1 - negs r2, r2 - add r2, r9 - mov r8, r2 -_082728EC: - adds r2, r1, 0 - mov r3, r9 - cmp r3, 0x1 - bgt _0827291A - ldr r0, [r1, 0x14] - str r0, [r1, 0x1C] - ldr r0, [r1, 0x10] - str r0, [r1, 0x18] - ldr r0, [r1, 0xC] - str r0, [r1, 0x14] - ldr r0, [r1, 0x8] - str r0, [r1, 0x10] - ldr r0, [r1, 0x4] - str r0, [r1, 0xC] - ldr r0, [r1] - str r0, [r1, 0x8] - mov r0, r12 - str r0, [r1, 0x4] - str r0, [r1] - adds r7, r1, 0 - adds r7, 0x20 - adds r6, r4, 0x1 - b _08272976 -_0827291A: - mov r3, r10 - lsls r0, r3, 2 - subs r3, r1, r0 - adds r7, r1, 0 - adds r7, 0x20 - adds r6, r4, 0x1 - mov r1, r8 - cmp r1, 0 - ble _08272958 - adds r4, r0, 0 -_0827292E: - ldr r0, [r2, 0x14] - str r0, [r2, 0x1C] - ldr r0, [r2, 0x10] - str r0, [r2, 0x18] - ldr r0, [r2, 0xC] - str r0, [r2, 0x14] - ldr r0, [r2, 0x8] - str r0, [r2, 0x10] - ldr r0, [r2, 0x4] - str r0, [r2, 0xC] - ldr r0, [r2] - str r0, [r2, 0x8] - ldr r0, [r3, 0x1C] - str r0, [r2, 0x4] - ldr r0, [r3, 0x18] - str r0, [r2] - subs r2, r4 - subs r3, r4 - subs r1, 0x1 - cmp r1, 0 - bne _0827292E -_08272958: - ldr r0, [r2, 0x14] - str r0, [r2, 0x1C] - ldr r0, [r2, 0x10] - str r0, [r2, 0x18] - ldr r0, [r2, 0xC] - str r0, [r2, 0x14] - ldr r0, [r2, 0x8] - str r0, [r2, 0x10] - ldr r0, [r2, 0x4] - str r0, [r2, 0xC] - ldr r0, [r2] - str r0, [r2, 0x8] - mov r3, r12 - str r3, [r2, 0x4] - str r3, [r2] -_08272976: - adds r1, r7, 0 - adds r4, r6, 0 - movs r2, 0x4 - ldrsh r0, [r5, r2] - cmp r4, r0 - blt _082728EC -_08272982: - ldr r3, [sp] - str r3, [r5, 0x30] - ldr r0, [sp, 0x8] - str r0, [r5, 0x34] - ldr r0, [r5, 0x2C] - str r0, [r5, 0x38] - movs r0, 0x1 - ldr r1, [sp, 0x4] - strb r0, [r1] -_08272994: - add sp, 0xC - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_8272884 - - - thumb_func_start sub_82729A4 -sub_82729A4: - push {lr} - adds r1, r0, 0 - ldr r0, _082729B4 - bl sub_82729B8 - pop {r0} - bx r0 - .align 2, 0 -_082729B4: .4byte gUnknown_2027370 - thumb_func_end sub_82729A4 - - thumb_func_start sub_82729B8 -sub_82729B8: - push {r4-r7,lr} - mov r7, r8 - push {r7} - lsls r2, r1, 3 - adds r2, r1 - lsls r2, 3 - adds r4, r0, r2 - ldr r2, [r4, 0x18] - ldr r0, [r4, 0x20] - adds r1, r0, 0 - adds r1, 0x8 - adds r5, r0, 0 - adds r5, 0x9 - movs r3, 0 - movs r6, 0x4 - ldrsh r0, [r4, r6] - cmp r3, r0 - bge _08272A5A - lsls r1, 2 - mov r8, r1 - lsls r6, r5, 2 - movs r5, 0 -_082729E4: - ldr r0, [r2, 0x14] - str r0, [r2, 0xC] - ldr r0, [r2, 0x18] - str r0, [r2, 0x10] - ldr r0, [r2, 0x1C] - str r0, [r2, 0x14] - mov r0, r8 - adds r1, r0, r2 - ldr r0, [r1] - str r0, [r2, 0x18] - adds r0, r6, r2 - ldr r0, [r0] - str r0, [r2, 0x1C] - adds r7, r2, 0 - adds r7, 0x20 - adds r3, 0x1 - mov r12, r3 - movs r3, 0x4 -_08272A08: - ldr r0, [r1, 0x8] - str r0, [r1] - ldr r0, [r1, 0xC] - str r0, [r1, 0x4] - ldr r0, [r1, 0x10] - str r0, [r1, 0x8] - ldr r0, [r1, 0x14] - str r0, [r1, 0xC] - ldr r0, [r1, 0x18] - str r0, [r1, 0x10] - ldr r0, [r1, 0x1C] - str r0, [r1, 0x14] - mov r0, r8 - adds r2, r0, r1 - ldr r0, [r2] - str r0, [r1, 0x18] - adds r0, r6, r1 - ldr r0, [r0] - str r0, [r1, 0x1C] - adds r1, r2, 0 - subs r3, 0x1 - cmp r3, 0 - bge _08272A08 - ldr r0, [r2, 0x8] - str r0, [r2] - ldr r0, [r2, 0xC] - str r0, [r2, 0x4] - ldr r0, [r2, 0x10] - str r0, [r2, 0x8] - ldr r0, [r2, 0x14] - str r0, [r2, 0xC] - str r5, [r2, 0x10] - str r5, [r2, 0x14] - str r5, [r2, 0x18] - str r5, [r2, 0x1C] - adds r2, r7, 0 - mov r3, r12 - movs r1, 0x4 - ldrsh r0, [r4, r1] - cmp r3, r0 - blt _082729E4 -_08272A5A: - ldr r0, [r4, 0x28] - str r0, [r4, 0x30] - ldr r0, [r4, 0x1C] - str r0, [r4, 0x34] - ldr r0, [r4, 0x2C] - str r0, [r4, 0x38] - adds r1, r4, 0 - adds r1, 0x44 - movs r0, 0x1 - strb r0, [r1] - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_82729B8 - - thumb_func_start sub_8272A78 -sub_8272A78: - push {lr} - adds r1, r0, 0 - ldr r0, _08272A88 - bl sub_8272A8C - pop {r0} - bx r0 - .align 2, 0 -_08272A88: .4byte gUnknown_2027370 - thumb_func_end sub_8272A78 - - thumb_func_start sub_8272A8C -sub_8272A8C: - push {r4-r7,lr} - lsls r2, r1, 3 - adds r2, r1 - lsls r2, 3 - adds r4, r0, r2 - ldr r2, [r4, 0x18] - ldr r0, [r4, 0x20] - adds r1, r0, 0 - adds r1, 0x8 - movs r3, 0 - movs r5, 0x4 - ldrsh r0, [r4, r5] - cmp r3, r0 - bge _08272B20 - mov r12, r3 - lsls r5, r1, 2 -_08272AAC: - mov r0, r12 - str r0, [r2, 0xC] - ldr r0, [r2, 0x14] - str r0, [r2, 0x10] - ldr r0, [r2, 0x18] - str r0, [r2, 0x14] - ldr r0, [r2, 0x1C] - str r0, [r2, 0x18] - adds r1, r5, r2 - ldr r0, [r1] - str r0, [r2, 0x1C] - adds r6, r2, 0 - adds r6, 0x20 - adds r7, r3, 0x1 - movs r3, 0x4 -_08272ACA: - ldr r0, [r1, 0x4] - str r0, [r1] - ldr r0, [r1, 0x8] - str r0, [r1, 0x4] - ldr r0, [r1, 0xC] - str r0, [r1, 0x8] - ldr r0, [r1, 0x10] - str r0, [r1, 0xC] - ldr r0, [r1, 0x14] - str r0, [r1, 0x10] - ldr r0, [r1, 0x18] - str r0, [r1, 0x14] - ldr r0, [r1, 0x1C] - str r0, [r1, 0x18] - adds r2, r5, r1 - ldr r0, [r2] - str r0, [r1, 0x1C] - adds r1, r2, 0 - subs r3, 0x1 - cmp r3, 0 - bge _08272ACA - ldr r0, [r2, 0x4] - str r0, [r2] - ldr r0, [r2, 0x8] - str r0, [r2, 0x4] - ldr r0, [r2, 0xC] - str r0, [r2, 0x8] - ldr r0, [r2, 0x10] - str r0, [r2, 0xC] - ldr r0, [r2, 0x14] - str r0, [r2, 0x10] - ldr r0, [r2, 0x18] - str r0, [r2, 0x14] - ldr r0, [r2, 0x1C] - str r0, [r2, 0x18] - mov r1, r12 - str r1, [r2, 0x1C] - adds r2, r6, 0 - adds r3, r7, 0 - movs r1, 0x4 - ldrsh r0, [r4, r1] - cmp r3, r0 - blt _08272AAC -_08272B20: - ldr r0, [r4, 0x28] - str r0, [r4, 0x30] - ldr r0, [r4, 0x1C] - str r0, [r4, 0x34] - ldr r0, [r4, 0x2C] - str r0, [r4, 0x38] - adds r1, r4, 0 - adds r1, 0x44 - movs r0, 0x1 - strb r0, [r1] - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_8272A8C - - .align 2, 0 @ Don't pad with nop. diff --git a/include/text.h b/include/text.h index 21d4e0e18..4bb2e17a0 100644 --- a/include/text.h +++ b/include/text.h @@ -53,6 +53,10 @@ extern UnkTextStruct1 gUnknown_2027370[4]; extern u8 gUnknown_202749A[11]; extern bool8 gUnknown_20274A5; extern u16 gUnknown_202B038[4][32][32]; // Usage points to these dimensions +extern void (*gIwramTextFunc1)(s32 a0); +extern void (*gIwramTextFunc2)(s32 a0); +extern void (*gIwramTextFunc3)(s32 a0); +extern void (*gIwramTextFunc4)(s32 a0); void LoadCharmaps(void); u32 UpdateFadeInTile(u32 a0); diff --git a/ld_script.txt b/ld_script.txt index d7a5f4d8b..921346fba 100755 --- a/ld_script.txt +++ b/ld_script.txt @@ -751,8 +751,6 @@ SECTIONS { iwram_init_start = .; INCLUDE "sym_iwram_init.ld" - src/code_8272724.o(iwram_init); - asm/code_8272724.o(.text); iwram_init_end = .; } > IWRAM AT>ROM diff --git a/src/code_805D8C8_1.c b/src/code_805D8C8_1.c index 87ad465bf..d32adff7e 100644 --- a/src/code_805D8C8_1.c +++ b/src/code_805D8C8_1.c @@ -3489,9 +3489,6 @@ void sub_8062D68(void); void sub_8062230(void); void sub_8062748(u8 a0); -extern void (*gUnknown_203B080)(s32 a0); -extern void (*gUnknown_203B084)(s32 a0); - static inline void SetTxtStruct(UnkTextStruct3 *sp) { memset(sp, 0, sizeof(*sp)); @@ -3566,7 +3563,7 @@ void ShowTacticsMenu(ActionContainer *a0) if (gUnknown_202EE10.menuIndex == 7) { if (tacticIds[8] != TACTIC_UNUSED) { for (i = 0; i < 6; i++) { - gUnknown_203B080(0); + gIwramTextFunc1(0); sub_803E46C(0x3D); } scrollFirstId++; @@ -3581,7 +3578,7 @@ void ShowTacticsMenu(ActionContainer *a0) if (gUnknown_202EE10.menuIndex == 0) { if (scrollFirstId != 0) { for (i = 0; i < 6; i++) { - gUnknown_203B084(0); + gIwramTextFunc2(0); sub_803E46C(0x3D); } scrollFirstId--; diff --git a/src/code_8272724.c b/src/code_8272724.c deleted file mode 100644 index 895eb4bcd..000000000 --- a/src/code_8272724.c +++ /dev/null @@ -1,18 +0,0 @@ -#include "global.h" -#include "text.h" - -extern void sub_8272774(UnkTextStruct1 *r0, u32 r1); -extern void sub_8272884(UnkTextStruct1 *r0, u32 r1); - -IWRAM_INIT void sub_8272760(u32 r0) -{ - sub_8272774(gUnknown_2027370, r0); -} - -// Note: when decompiling make sure to add IWRAM_INIT before the function declaration just like in sub_8272760's case, so the compiler knows there to put the functions. - -// TODO once sub_8272774 is decomped -//IWRAM_INIT void sub_8272870(u32 r0) -//{ -// sub_8272884(gUnknown_2027370, r0); -//} diff --git a/src/dungeon_message.c b/src/dungeon_message.c index 6f1f4299f..2506818d6 100644 --- a/src/dungeon_message.c +++ b/src/dungeon_message.c @@ -44,11 +44,6 @@ extern void sub_8083CE0(u8 param_1); extern u32 gUnknown_202EDD0; extern u8 gUnknown_203B40C; extern u8 gUnknown_202EE01; -extern void (*gUnknown_203B08C)(s32); -extern void (*gUnknown_203B084)(s32 a0); -extern void (*gUnknown_203B080)(s32 a0); -extern u8 gSpeakerNameBuffer[]; -extern UnkTextStruct1 gUnknown_2027370[4]; extern s32 gUnknown_202EDCC; extern Palette32 gFontPalette[]; @@ -303,7 +298,7 @@ void xxx_draw_string_80524F0(void) } case 3: strPtr->unk1C068++; - gUnknown_203B08C(0); + gIwramTextFunc4(0); if (strPtr->unk1C068 > 10) { strPtr->unk1C06C = 2; } @@ -1024,7 +1019,7 @@ static bool8 TryScrollLogUp(s32 a0) sub_803E46C(0xD); for (i = 0; i < 7; i++) { - gUnknown_203B084(0); + gIwramTextFunc2(0); sub_803E46C(0xD); } @@ -1074,7 +1069,7 @@ static bool8 TryScrollLogDown(s32 a0) sub_803E46C(0xD); for (i = 0; i < 7; i++) { - gUnknown_203B080(0); + gIwramTextFunc1(0); sub_803E46C(0xD); } diff --git a/src/string_format.c b/src/string_format.c index afb146ee9..14731ca7f 100644 --- a/src/string_format.c +++ b/src/string_format.c @@ -100,9 +100,6 @@ struct UnkStruct_203B198 struct SubStruct_203B198 unk48; }; -extern UnkTextStruct1 gUnknown_2027370[4]; -extern void (*gUnknown_203B088)(s32 a0); - static const u32 gUnknown_80D48A0[] = {0x7, 0x2, 0x2}; static const struct SubStruct_203B198 gUnknown_80D48AC = { 0x00, @@ -618,7 +615,7 @@ void DrawDialogueBoxString(void) break; case 10: { gUnknown_202E748.unk28++; - gUnknown_203B088(0); + gIwramTextFunc3(0); if (gUnknown_202E748.unk28 > 17) { gUnknown_202E744 = 1; } diff --git a/src/text.c b/src/text.c index 7506488a3..a89734963 100644 --- a/src/text.c +++ b/src/text.c @@ -41,18 +41,22 @@ EWRAM_DATA static u32 sTextShadowMask = 0; // Some text color info is stored; re EWRAM_DATA static u8 sDrawTextShadow = 0; EWRAM_DATA ALIGNED(4) u16 gUnknown_202B038[4][32][32] = {0}; -extern void sub_8272760(s32 a0); -extern void sub_8272870(s32 a0); -extern void sub_82729A4(s32 a0); -extern void sub_8272A78(s32 a0); +// These text-related functions were deemed important as they're copied and run from IWRAM for improved performance. +static void sub_8272774(UnkTextStruct1 *txtStructs, s32 id); +static void sub_8272884(UnkTextStruct1 *txtStructs, s32 id); +static void sub_82729B8(UnkTextStruct1 *txtStructs, s32 id); +static void sub_8272A8C(UnkTextStruct1 *txtStructs, s32 id); +void sub_8272760(s32 id); +void sub_8272870(s32 id); +void sub_82729A4(s32 id); +void sub_8272A78(s32 id); -// Despite these not being used anywhere in this file, file order and usage point to these variables being declared here -EWRAM_INIT void (*gUnknown_203B080)(s32 a0) = sub_8272760; -EWRAM_INIT void (*gUnknown_203B084)(s32 a0) = sub_8272870; -EWRAM_INIT void (*gUnknown_203B088)(s32 a0) = sub_82729A4; -EWRAM_INIT void (*gUnknown_203B08C)(s32 a0) = sub_8272A78; +EWRAM_INIT void (*gIwramTextFunc1)(s32 a0) = sub_8272760; +EWRAM_INIT void (*gIwramTextFunc2)(s32 a0) = sub_8272870; +EWRAM_INIT void (*gIwramTextFunc3)(s32 a0) = sub_82729A4; +EWRAM_INIT void (*gIwramTextFunc4)(s32 a0) = sub_8272A78; -// This variable is only used in InitGraphics function, which could or could not belong to text.c +// This variable is only used in InitGraphics function, which may or may not belong to text.c EWRAM_INIT u8 gUnknown_203B090 = 0; static void SaveUnkTextStructAndXXX_8006438(const UnkTextStruct2 *a0, bool8 a1, bool8 a2, UnkTextStruct2_sub *a3); @@ -3561,3 +3565,256 @@ static s32 InterpretColorChar(u8 a0) } return 7; } + +// These functions run from IWRAM for improved performance. +IWRAM_INIT void sub_8272760(s32 id) +{ + sub_8272774(gUnknown_2027370, id); +} + +IWRAM_INIT static void sub_8272774(UnkTextStruct1 *txtStructs, s32 id) +{ + UnkTextStruct1 *txtStructPtr = &txtStructs[id]; + + if (txtStructPtr->unk8 > 0) { + s32 i, j; + u32 *dstPtr; + s32 n; + s32 id8, id9; + + if (txtStructPtr->unkC == 6) { + s32 unk4 = txtStructPtr->unk4; + s32 dstAdd = ((txtStructPtr->unk24 + 2) * 8); + dstAdd *= unk4; + dstPtr = txtStructPtr->unk18 + dstAdd; + n = txtStructPtr->unk8 - 2; + } + else { + dstPtr = txtStructPtr->unk18; + n = txtStructPtr->unk8; + } + + id8 = txtStructPtr->unk20 + 8; + id9 = txtStructPtr->unk20 + 9; + for (i = 0; i < txtStructPtr->unk4; i++) { + s32 to = n - 1; + u32 *loopPtr = dstPtr; + for (j = 0; j < to; j++) { + loopPtr[0] = loopPtr[2]; + loopPtr[1] = loopPtr[3]; + loopPtr[2] = loopPtr[4]; + loopPtr[3] = loopPtr[5]; + loopPtr[4] = loopPtr[6]; + loopPtr[5] = loopPtr[7]; + loopPtr[6] = loopPtr[id8]; + loopPtr[7] = loopPtr[id9]; + + loopPtr += id8; + } + + loopPtr[0] = loopPtr[2]; + loopPtr[1] = loopPtr[3]; + loopPtr[2] = loopPtr[4]; + loopPtr[3] = loopPtr[5]; + loopPtr[4] = loopPtr[6]; + loopPtr[5] = loopPtr[7]; + loopPtr[6] = 0; + loopPtr[7] = 0; + dstPtr += 8; + } + + txtStructPtr->unk30 = txtStructPtr->unk28; + txtStructPtr->unk34 = txtStructPtr->unk1C; + txtStructPtr->unk38 = txtStructPtr->unk2C; + txtStructPtr->unk44 = 1; + } +} + +IWRAM_INIT void sub_8272870(s32 id) +{ + sub_8272884(gUnknown_2027370, id); +} + +IWRAM_INIT static void sub_8272884(UnkTextStruct1 *txtStructs, s32 id) +{ + UnkTextStruct1 *txtStructPtr = &txtStructs[id]; + + if (txtStructPtr->unk8 > 0) { + s32 i, j; + u32 *dstPtr; + s32 n; + s32 id8; + s32 unk4, unk8, dstAdd; + + if (txtStructPtr->unkC == 6) { + n = txtStructPtr->unk8 - 2; + } + else { + n = txtStructPtr->unk8; + } + + unk8 = txtStructPtr->unk8 - 1; + unk4 =txtStructPtr->unk4; + dstAdd = (unk8 * unk4) * 8; + dstPtr = txtStructPtr->unk18 + dstAdd; + + id8 = txtStructPtr->unk20 + 8; + for (i = 0; i < txtStructPtr->unk4; i++) { + u32 lastTwo = 0; + s32 to = n - 1; + u32 *loopPtr = dstPtr; + + if (n < 2) { + loopPtr[7] = loopPtr[5]; + loopPtr[6] = loopPtr[4]; + loopPtr[5] = loopPtr[3]; + loopPtr[4] = loopPtr[2]; + loopPtr[3] = loopPtr[1]; + loopPtr[2] = loopPtr[0]; + loopPtr[1] = lastTwo; + loopPtr[0] = lastTwo; + } + else { + u32 *ptr8 = dstPtr - id8; + for (j = 0; j < to; j++) { + loopPtr[7] = loopPtr[5]; + loopPtr[6] = loopPtr[4]; + loopPtr[5] = loopPtr[3]; + loopPtr[4] = loopPtr[2]; + loopPtr[3] = loopPtr[1]; + loopPtr[2] = loopPtr[0]; + loopPtr[1] = ptr8[7]; + loopPtr[0] = ptr8[6]; + + loopPtr -= id8; + ptr8 -= id8; + } + + loopPtr[7] = loopPtr[5]; + loopPtr[6] = loopPtr[4]; + loopPtr[5] = loopPtr[3]; + loopPtr[4] = loopPtr[2]; + loopPtr[3] = loopPtr[1]; + loopPtr[2] = loopPtr[0]; + loopPtr[1] = 0; + loopPtr[0] = 0; + } + dstPtr += 8; + } + + txtStructPtr->unk30 = txtStructPtr->unk28; + txtStructPtr->unk34 = txtStructPtr->unk1C; + txtStructPtr->unk38 = txtStructPtr->unk2C; + txtStructPtr->unk44 = 1; + } +} + +IWRAM_INIT void sub_82729A4(s32 id) +{ + sub_82729B8(gUnknown_2027370, id); +} + +IWRAM_INIT static void sub_82729B8(UnkTextStruct1 *txtStructs, s32 id) +{ + s32 i, j; + UnkTextStruct1 *txtStructPtr = &txtStructs[id]; + u32 *dstPtr = txtStructPtr->unk18; + s32 id8 = txtStructPtr->unk20 + 8; + s32 id9 = txtStructPtr->unk20 + 9; + + for (i = 0; i < txtStructPtr->unk4; i++) { + u32 *loopPtr; + + dstPtr[3] = dstPtr[5]; + dstPtr[4] = dstPtr[6]; + dstPtr[5] = dstPtr[7]; + dstPtr[6] = dstPtr[id8]; + dstPtr[7] = dstPtr[id9]; + + loopPtr = dstPtr + id8; + for (j = 0; j < 5; j++) { + loopPtr[0] = loopPtr[2]; + loopPtr[1] = loopPtr[3]; + loopPtr[2] = loopPtr[4]; + loopPtr[3] = loopPtr[5]; + loopPtr[4] = loopPtr[6]; + loopPtr[5] = loopPtr[7]; + loopPtr[6] = loopPtr[id8]; + loopPtr[7] = loopPtr[id9]; + + loopPtr += id8; + } + + loopPtr[0] = loopPtr[2]; + loopPtr[1] = loopPtr[3]; + loopPtr[2] = loopPtr[4]; + loopPtr[3] = loopPtr[5]; + loopPtr[4] = 0; + loopPtr[5] = 0; + loopPtr[6] = 0; + loopPtr[7] = 0; + + dstPtr += 8; + } + + txtStructPtr->unk30 = txtStructPtr->unk28; + txtStructPtr->unk34 = txtStructPtr->unk1C; + txtStructPtr->unk38 = txtStructPtr->unk2C; + txtStructPtr->unk44 = 1; +} + +IWRAM_INIT void sub_8272A78(s32 id) +{ + sub_8272A8C(gUnknown_2027370, id); +} + +IWRAM_INIT static void sub_8272A8C(UnkTextStruct1 *txtStructs, s32 id) +{ + s32 i, j; + UnkTextStruct1 *txtStructPtr = &txtStructs[id]; + u32 *dstPtr = txtStructPtr->unk18; + s32 id8 = txtStructPtr->unk20 + 8; + + for (i = 0; i < txtStructPtr->unk4; i++) { + u32 *loopPtr; + + dstPtr[3] = 0; + dstPtr[4] = dstPtr[5]; + dstPtr[5] = dstPtr[6]; + dstPtr[6] = dstPtr[7]; + dstPtr[7] = dstPtr[id8]; + + loopPtr = dstPtr + id8; + for (j = 0; j < 5; j++) { + loopPtr[0] = loopPtr[1]; + loopPtr[1] = loopPtr[2]; + loopPtr[2] = loopPtr[3]; + loopPtr[3] = loopPtr[4]; + loopPtr[4] = loopPtr[5]; + loopPtr[5] = loopPtr[6]; + loopPtr[6] = loopPtr[7]; + loopPtr[7] = loopPtr[id8]; + + loopPtr += id8; + } + + loopPtr[0] = loopPtr[1]; + loopPtr[1] = loopPtr[2]; + loopPtr[2] = loopPtr[3]; + loopPtr[3] = loopPtr[4]; + loopPtr[4] = loopPtr[5]; + loopPtr[5] = loopPtr[6]; + loopPtr[6] = loopPtr[7]; + loopPtr[7] = 0; + + dstPtr += 8; + } + + txtStructPtr->unk30 = txtStructPtr->unk28; + txtStructPtr->unk34 = txtStructPtr->unk1C; + txtStructPtr->unk38 = txtStructPtr->unk2C; + txtStructPtr->unk44 = 1; +} + +// Needed to match, because without it the alignment is different. +IWRAM_INIT static UNUSED u8 sMatchAlignment = 0; diff --git a/sym_iwram_init.txt b/sym_iwram_init.txt index e6acf0ab6..690170b75 100644 --- a/sym_iwram_init.txt +++ b/sym_iwram_init.txt @@ -12,3 +12,4 @@ .include "src/ground_object.o" .include "src/ground_effect.o" .include "src/ground_event.o" +.include "src/text.o"