summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkira Akashi <rubenru09@aol.com>2021-08-16 08:34:55 +0100
committerGitHub <noreply@github.com>2021-08-16 08:34:55 +0100
commit168950d7e03129c23ddce331593823d1d48411cf (patch)
treeeb0753d70cca0a010b552b45ab384b1ccb98a180
parenta6b9c13d97e130e43c774f81c383ad452811ef75 (diff)
parente1a3782f3cac045ea8f8a21869f17608479c5bdb (diff)
Merge pull request #447 from PikalaxALT/pikalax_work
unk_02021590
-rw-r--r--arm9/asm/unk_0200E850.s134
-rw-r--r--arm9/asm/unk_0201137C.s134
-rw-r--r--arm9/asm/unk_02021590.s514
-rw-r--r--arm9/global.inc10
-rw-r--r--arm9/src/communication_error.c1
-rw-r--r--arm9/src/font.c38
-rw-r--r--arm9/src/render_text.c2
-rw-r--r--arm9/src/script_buffers.c122
-rw-r--r--arm9/src/text.c39
-rw-r--r--arm9/src/unk_02021590.c212
-rw-r--r--arm9/src/unk_02021934.c9
-rw-r--r--include/font.h15
-rw-r--r--include/script_buffers.h2
-rw-r--r--include/string16.h11
-rw-r--r--include/unk_02021590.h52
-rw-r--r--tools/.gitignore1
16 files changed, 525 insertions, 771 deletions
diff --git a/arm9/asm/unk_0200E850.s b/arm9/asm/unk_0200E850.s
index a464171a..32fcbf7b 100644
--- a/arm9/asm/unk_0200E850.s
+++ b/arm9/asm/unk_0200E850.s
@@ -5947,3 +5947,137 @@ _02011372:
pop {r4-r6, pc}
.balign 4
_02011378: .word 0x00000385
+
+ thumb_func_start FUN_0201137C
+FUN_0201137C: ; 0x0201137C
+ push {r3-r7, lr}
+ sub sp, #0x10
+ add r4, r1, #0x0
+ add r6, r2, #0x0
+ add r5, r0, #0x0
+ lsl r0, r6, #0xc
+ ldr r2, [r4, #0x2c]
+ add r7, r3, #0x0
+ asr r1, r0, #0x1f
+ asr r3, r2, #0x1f
+ bl _ll_mul
+ add r2, r0, #0x0
+ mov r0, #0x2
+ mov r3, #0x0
+ lsl r0, r0, #0xa
+ add r0, r2, r0
+ adc r1, r3
+ lsl r1, r1, #0x14
+ lsr r0, r0, #0xc
+ orr r0, r1
+ mov r1, #0xe1
+ asr r0, r0, #0xc
+ lsl r1, r1, #0x2
+ strb r0, [r5, r1]
+ ldrb r0, [r5, r1]
+ sub r2, r6, r0
+ sub r0, r1, #0x4
+ str r4, [r5, r0]
+ add r4, #0x23
+ add r0, r1, #0x2
+ ldrb r3, [r4, #0x0]
+ sub r1, r1, #0x4
+ strb r3, [r5, r0]
+ ldr r0, [sp, #0x28]
+ add r3, r7, #0x0
+ str r0, [sp, #0x0]
+ ldr r0, [sp, #0x2c]
+ str r0, [sp, #0x4]
+ ldr r0, [sp, #0x30]
+ str r0, [sp, #0x8]
+ ldr r0, [sp, #0x34]
+ str r0, [sp, #0xc]
+ ldr r1, [r5, r1]
+ add r0, r5, #0x0
+ add r0, #0x4c
+ add r1, #0x24
+ bl FUN_02010FD0
+ ldr r0, _020113E8 ; =0x00000385
+ mov r1, #0x0
+ strb r1, [r5, r0]
+ add sp, #0x10
+ pop {r3-r7, pc}
+ .balign 4
+_020113E8: .word 0x00000385
+
+ thumb_func_start FUN_020113EC
+FUN_020113EC: ; 0x020113EC
+ push {r4-r6, lr}
+ sub sp, #0x8
+ add r4, r1, #0x0
+ ldr r1, _0201147C ; =0x00000385
+ add r5, r0, #0x0
+ ldrb r1, [r5, r1]
+ mov r6, #0x0
+ cmp r1, #0x0
+ beq _02011408
+ cmp r1, #0x1
+ beq _02011460
+ cmp r1, #0x2
+ beq _02011474
+ b _02011476
+_02011408:
+ add r0, #0x4c
+ bl FUN_020110BC
+ cmp r0, #0x1
+ bne _02011476
+ ldr r2, _0201147C ; =0x00000385
+ ldrb r0, [r5, r2]
+ sub r1, r2, #0x5
+ add r0, r0, #0x1
+ strb r0, [r5, r2]
+ ldr r0, [r4, #0x10]
+ sub r2, r2, #0x1
+ str r0, [sp, #0x0]
+ ldr r0, [r4, #0x18]
+ str r0, [sp, #0x4]
+ ldrb r2, [r5, r2]
+ ldr r1, [r5, r1]
+ ldr r3, [r4, #0x8]
+ add r0, r5, #0x0
+ bl FUN_0200FE20
+ mov r0, #0xe
+ lsl r0, r0, #0x6
+ ldr r3, [r5, r0]
+ add r0, r3, #0x0
+ add r0, #0x20
+ ldrb r0, [r0, #0x0]
+ cmp r0, #0x0
+ ldr r0, [r4, #0x18]
+ bne _02011452
+ add r3, #0x23
+ ldrb r3, [r3, #0x0]
+ ldr r2, [r4, #0x10]
+ mov r1, #0x1
+ bl FUN_0200F6E4
+ b _02011476
+_02011452:
+ add r3, #0x23
+ ldrb r3, [r3, #0x0]
+ ldr r2, [r4, #0x10]
+ mov r1, #0x2
+ bl FUN_0200F6E4
+ b _02011476
+_02011460:
+ bl FUN_0200FE90
+ cmp r0, #0x1
+ bne _02011476
+ ldr r0, _0201147C ; =0x00000385
+ mov r6, #0x1
+ ldrb r1, [r5, r0]
+ add r1, r1, #0x1
+ strb r1, [r5, r0]
+ b _02011476
+_02011474:
+ mov r6, #0x1
+_02011476:
+ add r0, r6, #0x0
+ add sp, #0x8
+ pop {r4-r6, pc}
+ .balign 4
+_0201147C: .word 0x00000385
diff --git a/arm9/asm/unk_0201137C.s b/arm9/asm/unk_0201137C.s
index 65e076bb..ad250827 100644
--- a/arm9/asm/unk_0201137C.s
+++ b/arm9/asm/unk_0201137C.s
@@ -3,140 +3,6 @@
.text
- thumb_func_start FUN_0201137C
-FUN_0201137C: ; 0x0201137C
- push {r3-r7, lr}
- sub sp, #0x10
- add r4, r1, #0x0
- add r6, r2, #0x0
- add r5, r0, #0x0
- lsl r0, r6, #0xc
- ldr r2, [r4, #0x2c]
- add r7, r3, #0x0
- asr r1, r0, #0x1f
- asr r3, r2, #0x1f
- bl _ll_mul
- add r2, r0, #0x0
- mov r0, #0x2
- mov r3, #0x0
- lsl r0, r0, #0xa
- add r0, r2, r0
- adc r1, r3
- lsl r1, r1, #0x14
- lsr r0, r0, #0xc
- orr r0, r1
- mov r1, #0xe1
- asr r0, r0, #0xc
- lsl r1, r1, #0x2
- strb r0, [r5, r1]
- ldrb r0, [r5, r1]
- sub r2, r6, r0
- sub r0, r1, #0x4
- str r4, [r5, r0]
- add r4, #0x23
- add r0, r1, #0x2
- ldrb r3, [r4, #0x0]
- sub r1, r1, #0x4
- strb r3, [r5, r0]
- ldr r0, [sp, #0x28]
- add r3, r7, #0x0
- str r0, [sp, #0x0]
- ldr r0, [sp, #0x2c]
- str r0, [sp, #0x4]
- ldr r0, [sp, #0x30]
- str r0, [sp, #0x8]
- ldr r0, [sp, #0x34]
- str r0, [sp, #0xc]
- ldr r1, [r5, r1]
- add r0, r5, #0x0
- add r0, #0x4c
- add r1, #0x24
- bl FUN_02010FD0
- ldr r0, _020113E8 ; =0x00000385
- mov r1, #0x0
- strb r1, [r5, r0]
- add sp, #0x10
- pop {r3-r7, pc}
- .balign 4
-_020113E8: .word 0x00000385
-
- thumb_func_start FUN_020113EC
-FUN_020113EC: ; 0x020113EC
- push {r4-r6, lr}
- sub sp, #0x8
- add r4, r1, #0x0
- ldr r1, _0201147C ; =0x00000385
- add r5, r0, #0x0
- ldrb r1, [r5, r1]
- mov r6, #0x0
- cmp r1, #0x0
- beq _02011408
- cmp r1, #0x1
- beq _02011460
- cmp r1, #0x2
- beq _02011474
- b _02011476
-_02011408:
- add r0, #0x4c
- bl FUN_020110BC
- cmp r0, #0x1
- bne _02011476
- ldr r2, _0201147C ; =0x00000385
- ldrb r0, [r5, r2]
- sub r1, r2, #0x5
- add r0, r0, #0x1
- strb r0, [r5, r2]
- ldr r0, [r4, #0x10]
- sub r2, r2, #0x1
- str r0, [sp, #0x0]
- ldr r0, [r4, #0x18]
- str r0, [sp, #0x4]
- ldrb r2, [r5, r2]
- ldr r1, [r5, r1]
- ldr r3, [r4, #0x8]
- add r0, r5, #0x0
- bl FUN_0200FE20
- mov r0, #0xe
- lsl r0, r0, #0x6
- ldr r3, [r5, r0]
- add r0, r3, #0x0
- add r0, #0x20
- ldrb r0, [r0, #0x0]
- cmp r0, #0x0
- ldr r0, [r4, #0x18]
- bne _02011452
- add r3, #0x23
- ldrb r3, [r3, #0x0]
- ldr r2, [r4, #0x10]
- mov r1, #0x1
- bl FUN_0200F6E4
- b _02011476
-_02011452:
- add r3, #0x23
- ldrb r3, [r3, #0x0]
- ldr r2, [r4, #0x10]
- mov r1, #0x2
- bl FUN_0200F6E4
- b _02011476
-_02011460:
- bl FUN_0200FE90
- cmp r0, #0x1
- bne _02011476
- ldr r0, _0201147C ; =0x00000385
- mov r6, #0x1
- ldrb r1, [r5, r0]
- add r1, r1, #0x1
- strb r1, [r5, r0]
- b _02011476
-_02011474:
- mov r6, #0x1
-_02011476:
- add r0, r6, #0x0
- add sp, #0x8
- pop {r4-r6, pc}
- .balign 4
-_0201147C: .word 0x00000385
-
thumb_func_start FUN_02011480
FUN_02011480: ; 0x02011480
cmp r1, #0x0
diff --git a/arm9/asm/unk_02021590.s b/arm9/asm/unk_02021590.s
deleted file mode 100644
index a648ab1d..00000000
--- a/arm9/asm/unk_02021590.s
+++ /dev/null
@@ -1,514 +0,0 @@
- .include "asm/macros.inc"
- .include "global.inc"
-
- .section .rodata
-
- .global UNK_020EE668
-UNK_020EE668: ; 0x020EE668
- .byte 0x00, 0x01, 0x02, 0x03
-
- .global UNK_020EE66C
-UNK_020EE66C: ; 0x020EE66C
- .word FUN_020216EC, FUN_0202171C
-
- .global UNK_020EE674
-UNK_020EE674: ; 0x020EE674
- .word FUN_0202173C, FUN_0202174C
-
- .text
-
- thumb_func_start FUN_02021590
-FUN_02021590: ; 0x02021590
- push {r3-r7, lr}
- sub sp, #0x8
- add r5, r0, #0x0
- add r6, r1, #0x0
- ldr r0, [sp, #0x20]
- mov r1, #0x78
- add r7, r2, #0x0
- str r3, [sp, #0x4]
- bl AllocFromHeap
- add r4, r0, #0x0
- beq _020215C0
- ldr r1, [sp, #0x20]
- ldr r3, [sp, #0x4]
- str r1, [sp, #0x0]
- add r1, r5, #0x0
- add r2, r6, #0x0
- bl FUN_02021600
- ldr r2, [sp, #0x20]
- add r0, r4, #0x0
- add r1, r7, #0x0
- bl FUN_020216D4
-_020215C0:
- add r0, r4, #0x0
- add sp, #0x8
- pop {r3-r7, pc}
- .balign 4
-
- thumb_func_start FUN_020215C8
-FUN_020215C8: ; 0x020215C8
- push {r4, lr}
- add r4, r0, #0x0
- bl FUN_02021728
- add r0, r4, #0x0
- bl FUN_020216B8
- add r0, r4, #0x0
- bl FreeToHeap
- pop {r4, pc}
- .balign 4
-
- thumb_func_start FUN_020215E0
-FUN_020215E0: ; 0x020215E0
- push {r4-r6, lr}
- add r5, r0, #0x0
- add r4, r1, #0x0
- ldr r1, [r5, #0x0]
- add r6, r2, #0x0
- cmp r1, r4
- beq _020215FC
- bl FUN_02021728
- add r0, r5, #0x0
- add r1, r4, #0x0
- add r2, r6, #0x0
- bl FUN_020216D4
-_020215FC:
- pop {r4-r6, pc}
- .balign 4
-
- thumb_func_start FUN_02021600
-FUN_02021600: ; 0x02021600
- push {r3-r6, lr}
- sub sp, #0x4
- add r5, r0, #0x0
- add r0, r1, #0x0
- ldr r1, [sp, #0x18]
- add r4, r2, #0x0
- add r6, r3, #0x0
- bl NARC_ctor
- str r0, [r5, #0x54]
- cmp r0, #0x0
- beq _020216A6
- add r1, r5, #0x0
- add r1, #0x5c
- str r1, [sp, #0x0]
- add r1, r4, #0x0
- mov r2, #0x0
- mov r3, #0x10
- bl NARC_ReadFromMember
- str r6, [r5, #0x6c]
- cmp r6, #0x0
- beq _02021638
- mov r0, #0x0
- str r0, [r5, #0x74]
- ldr r0, _020216AC ; =FUN_0202192C
- str r0, [r5, #0x70]
- b _02021660
-_02021638:
- ldr r0, [r5, #0x60]
- cmp r0, #0x0
- bne _02021642
- bl GF_AssertFail
-_02021642:
- ldr r0, [sp, #0x18]
- ldr r1, [r5, #0x64]
- bl AllocFromHeap
- str r0, [r5, #0x74]
- ldr r0, _020216B0 ; =FUN_02021924
- add r1, r4, #0x0
- str r0, [r5, #0x70]
- ldr r0, [r5, #0x74]
- str r0, [sp, #0x0]
- ldr r0, [r5, #0x54]
- ldr r2, [r5, #0x60]
- ldr r3, [r5, #0x64]
- bl NARC_ReadFromMember
-_02021660:
- add r0, r5, #0x0
- add r0, #0x6a
- ldrb r0, [r0, #0x0]
- cmp r0, #0x2
- bhi _02021674
- add r0, r5, #0x0
- add r0, #0x6b
- ldrb r0, [r0, #0x0]
- cmp r0, #0x2
- bls _02021678
-_02021674:
- bl GF_AssertFail
-_02021678:
- add r0, r5, #0x0
- add r0, #0x6a
- ldrb r0, [r0, #0x0]
- ldr r2, _020216B4 ; =UNK_020EE668
- sub r0, r0, #0x1
- lsl r3, r0, #0x1
- add r0, r5, #0x0
- add r0, #0x6b
- ldrb r0, [r0, #0x0]
- sub r1, r0, #0x1
- add r0, r2, r3
- ldrb r0, [r1, r0]
- str r0, [r5, #0x8]
- add r0, r5, #0x0
- add r0, #0x6b
- ldrb r1, [r0, #0x0]
- add r0, r5, #0x0
- add r0, #0x6a
- ldrb r0, [r0, #0x0]
- lsl r0, r0, #0x4
- mul r0, r1
- str r0, [r5, #0xc]
- str r4, [r5, #0x58]
-_020216A6:
- add sp, #0x4
- pop {r3-r6, pc}
- nop
-_020216AC: .word FUN_0202192C
-_020216B0: .word FUN_02021924
-_020216B4: .word UNK_020EE668
-
- thumb_func_start FUN_020216B8
-FUN_020216B8: ; 0x020216B8
- push {r4, lr}
- add r4, r0, #0x0
- ldr r0, [r4, #0x74]
- cmp r0, #0x0
- beq _020216C6
- bl FreeToHeap
-_020216C6:
- ldr r0, [r4, #0x54]
- cmp r0, #0x0
- beq _020216D0
- bl NARC_dtor
-_020216D0:
- pop {r4, pc}
- .balign 4
-
- thumb_func_start FUN_020216D4
-FUN_020216D4: ; 0x020216D4
- push {r3, lr}
- add r3, r1, #0x0
- add r1, r2, #0x0
- str r3, [r0, #0x0]
- ldr r2, _020216E8 ; =UNK_020EE66C
- lsl r3, r3, #0x2
- ldr r2, [r2, r3]
- blx r2
- pop {r3, pc}
- nop
-_020216E8: .word UNK_020EE66C
-
- thumb_func_start FUN_020216EC
-FUN_020216EC: ; 0x020216EC
- push {r3-r5, lr}
- add r5, r0, #0x0
- ldr r2, [r5, #0xc]
- ldr r0, [r5, #0x64]
- add r4, r2, #0x0
- mul r4, r0
- add r0, r1, #0x0
- add r1, r4, #0x0
- bl AllocFromHeap
- str r0, [r5, #0x10]
- ldr r0, _02021718 ; =FUN_02021774
- add r3, r4, #0x0
- str r0, [r5, #0x4]
- ldr r0, [r5, #0x10]
- str r0, [sp, #0x0]
- ldr r0, [r5, #0x54]
- ldr r1, [r5, #0x58]
- ldr r2, [r5, #0x5c]
- bl NARC_ReadFromMember
- pop {r3-r5, pc}
- .balign 4
-_02021718: .word FUN_02021774
-
- thumb_func_start FUN_0202171C
-FUN_0202171C: ; 0x0202171C
- ldr r1, _02021724 ; =FUN_0202181C
- str r1, [r0, #0x4]
- bx lr
- nop
-_02021724: .word FUN_0202181C
-
- thumb_func_start FUN_02021728
-FUN_02021728: ; 0x02021728
- push {r3, lr}
- ldr r1, [r0, #0x0]
- lsl r2, r1, #0x2
- ldr r1, _02021738 ; =UNK_020EE674
- ldr r1, [r1, r2]
- blx r1
- pop {r3, pc}
- nop
-_02021738: .word UNK_020EE674
-
- thumb_func_start FUN_0202173C
-FUN_0202173C: ; 0x0202173C
- push {r4, lr}
- add r4, r0, #0x0
- ldr r0, [r4, #0x10]
- bl FreeToHeap
- mov r0, #0x0
- str r0, [r4, #0x10]
- pop {r4, pc}
-
- thumb_func_start FUN_0202174C
-FUN_0202174C: ; 0x0202174C
- bx lr
- .balign 4
-
- thumb_func_start FUN_02021750
-FUN_02021750: ; 0x02021750
- push {r3, lr}
- ldr r3, [r0, #0x64]
- cmp r1, r3
- bhi _02021764
- sub r1, r1, #0x1
- lsl r1, r1, #0x10
- ldr r3, [r0, #0x4]
- lsr r1, r1, #0x10
- blx r3
- pop {r3, pc}
-_02021764:
- add r0, r2, #0x0
- mov r1, #0x0
- add r0, #0x80
- strb r1, [r0, #0x0]
- add r2, #0x81
- strb r1, [r2, #0x0]
- pop {r3, pc}
- .balign 4
-
- thumb_func_start FUN_02021774
-FUN_02021774: ; 0x02021774
- push {r3-r7, lr}
- str r1, [sp, #0x0]
- add r7, r0, #0x0
- ldr r0, [sp, #0x0]
- ldr r1, [r7, #0xc]
- add r5, r0, #0x0
- ldr r0, [r7, #0x8]
- add r6, r2, #0x0
- mul r5, r1
- ldr r4, [r7, #0x10]
- cmp r0, #0x3
- bhi _02021802
- add r0, r0, r0
- add r0, pc
- ldrh r0, [r0, #0x6]
- lsl r0, r0, #0x10
- asr r0, r0, #0x10
- add pc, r0
-_02021798: ; jump table (using 16-bit offset)
- .short _020217A0 - _02021798 - 2; case 0
- .short _020217AA - _02021798 - 2; case 1
- .short _020217C0 - _02021798 - 2; case 2
- .short _020217D6 - _02021798 - 2; case 3
-_020217A0:
- add r0, r4, r5
- add r1, r6, #0x0
- bl DecompressGlyphTile
- b _02021802
-_020217AA:
- add r0, r4, r5
- add r1, r6, #0x0
- bl DecompressGlyphTile
- add r0, r4, r5
- add r1, r6, #0x0
- add r0, #0x10
- add r1, #0x40
- bl DecompressGlyphTile
- b _02021802
-_020217C0:
- add r0, r4, r5
- add r1, r6, #0x0
- bl DecompressGlyphTile
- add r0, r4, r5
- add r1, r6, #0x0
- add r0, #0x10
- add r1, #0x20
- bl DecompressGlyphTile
- b _02021802
-_020217D6:
- add r0, r4, r5
- add r1, r6, #0x0
- bl DecompressGlyphTile
- add r0, r4, r5
- add r1, r6, #0x0
- add r0, #0x10
- add r1, #0x20
- bl DecompressGlyphTile
- add r0, r4, r5
- add r1, r6, #0x0
- add r0, #0x20
- add r1, #0x40
- bl DecompressGlyphTile
- add r0, r4, r5
- add r1, r6, #0x0
- add r0, #0x30
- add r1, #0x60
- bl DecompressGlyphTile
-_02021802:
- ldr r1, [sp, #0x0]
- ldr r2, [r7, #0x70]
- add r0, r7, #0x0
- blx r2
- add r1, r6, #0x0
- add r1, #0x80
- add r7, #0x69
- strb r0, [r1, #0x0]
- ldrb r0, [r7, #0x0]
- add r6, #0x81
- strb r0, [r6, #0x0]
- pop {r3-r7, pc}
- .balign 4
-
- thumb_func_start FUN_0202181C
-FUN_0202181C: ; 0x0202181C
- push {r3-r7, lr}
- add r4, r0, #0x0
- ldr r6, [r4, #0xc]
- add r0, #0x14
- str r0, [sp, #0x0]
- add r7, r1, #0x0
- add r5, r2, #0x0
- add r2, r7, #0x0
- ldr r3, [r4, #0x5c]
- mul r2, r6
- add r2, r3, r2
- ldr r0, [r4, #0x54]
- ldr r1, [r4, #0x58]
- add r3, r6, #0x0
- bl NARC_ReadFromMember
- ldr r0, [r4, #0x8]
- cmp r0, #0x3
- bhi _020218C0
- add r0, r0, r0
- add r0, pc
- ldrh r0, [r0, #0x6]
- lsl r0, r0, #0x10
- asr r0, r0, #0x10
- add pc, r0
-_0202184E: ; jump table (using 16-bit offset)
- .short _02021856 - _0202184E - 2; case 0
- .short _02021862 - _0202184E - 2; case 1
- .short _0202187A - _0202184E - 2; case 2
- .short _02021892 - _0202184E - 2; case 3
-_02021856:
- add r0, r4, #0x0
- add r0, #0x14
- add r1, r5, #0x0
- bl DecompressGlyphTile
- b _020218C0
-_02021862:
- add r0, r4, #0x0
- add r0, #0x14
- add r1, r5, #0x0
- bl DecompressGlyphTile
- add r0, r4, #0x0
- add r1, r5, #0x0
- add r0, #0x24
- add r1, #0x40
- bl DecompressGlyphTile
- b _020218C0
-_0202187A:
- add r0, r4, #0x0
- add r0, #0x14
- add r1, r5, #0x0
- bl DecompressGlyphTile
- add r0, r4, #0x0
- add r1, r5, #0x0
- add r0, #0x24
- add r1, #0x20
- bl DecompressGlyphTile
- b _020218C0
-_02021892:
- add r0, r4, #0x0
- add r0, #0x14
- add r1, r5, #0x0
- bl DecompressGlyphTile
- add r0, r4, #0x0
- add r1, r5, #0x0
- add r0, #0x24
- add r1, #0x20
- bl DecompressGlyphTile
- add r0, r4, #0x0
- add r1, r5, #0x0
- add r0, #0x34
- add r1, #0x40
- bl DecompressGlyphTile
- add r0, r4, #0x0
- add r1, r5, #0x0
- add r0, #0x44
- add r1, #0x60
- bl DecompressGlyphTile
-_020218C0:
- ldr r2, [r4, #0x70]
- add r0, r4, #0x0
- add r1, r7, #0x0
- blx r2
- add r1, r5, #0x0
- add r1, #0x80
- add r4, #0x69
- strb r0, [r1, #0x0]
- ldrb r0, [r4, #0x0]
- add r5, #0x81
- strb r0, [r5, #0x0]
- pop {r3-r7, pc}
-
- thumb_func_start FUN_020218D8
-FUN_020218D8: ; 0x020218D8
- push {r3-r7, lr}
- add r4, r1, #0x0
- ldrh r1, [r4, #0x0]
- add r5, r0, #0x0
- ldr r0, _0202191C ; =0x0000FFFF
- add r7, r2, #0x0
- mov r6, #0x0
- cmp r1, r0
- beq _02021916
-_020218EA:
- ldr r0, _02021920 ; =0x0000FFFE
- cmp r1, r0
- bne _02021900
- add r0, r4, #0x0
- bl MsgArray_SkipControlCode
- add r4, r0, #0x0
- ldrh r1, [r4, #0x0]
- ldr r0, _0202191C ; =0x0000FFFF
- cmp r1, r0
- beq _02021916
-_02021900:
- ldr r2, [r5, #0x70]
- add r0, r5, #0x0
- sub r1, r1, #0x1
- blx r2
- add r4, r4, #0x2
- add r0, r7, r0
- add r6, r6, r0
- ldrh r1, [r4, #0x0]
- ldr r0, _0202191C ; =0x0000FFFF
- cmp r1, r0
- bne _020218EA
-_02021916:
- sub r0, r6, r7
- pop {r3-r7, pc}
- nop
-_0202191C: .word 0x0000FFFF
-_02021920: .word 0x0000FFFE
-
- thumb_func_start FUN_02021924
-FUN_02021924: ; 0x02021924
- ldr r0, [r0, #0x74]
- ldrb r0, [r0, r1]
- bx lr
- .balign 4
-
- thumb_func_start FUN_0202192C
-FUN_0202192C: ; 0x0202192C
- add r0, #0x68
- ldrb r0, [r0, #0x0]
- bx lr
- .balign 4
diff --git a/arm9/global.inc b/arm9/global.inc
index 8658cca9..2cf762ee 100644
--- a/arm9/global.inc
+++ b/arm9/global.inc
@@ -1381,11 +1381,11 @@
.extern FUN_0202135C
.extern FUN_02021390
.extern FUN_020213A0
-.extern FUN_02021590
-.extern FUN_020215C8
-.extern FUN_020215E0
-.extern FUN_02021750
-.extern FUN_020218D8
+.extern FontData_new
+.extern FontData_delete
+.extern FontData_ModeSwitch
+.extern TryLoadGlyph
+.extern GetStringWidth
.extern StringGetWidth
.extern StringGetWidth_SingleLine_HandleClearToControlCode
.extern String_ctor
diff --git a/arm9/src/communication_error.c b/arm9/src/communication_error.c
index 0ea26458..73345af1 100644
--- a/arm9/src/communication_error.c
+++ b/arm9/src/communication_error.c
@@ -7,7 +7,6 @@
#include "msgdata/msg.naix"
#include "text.h"
-extern void FUN_02002ED0(enum GFBgLayer layer, u32 base_addr, u32 heap_id);
extern void FUN_0200A274(fx32 brightness, fx32, u32);
extern void FUN_0200CB00(struct BgConfig* bg_config, enum GFBgLayer layer, u32 num_tiles, u32, u8, u32 heap_id);
extern void FUN_0200CCA4(struct Window* window, BOOL copy_to_vram, u16 fill_value, u32 palette_num);
diff --git a/arm9/src/font.c b/arm9/src/font.c
index 6c838892..5e46b237 100644
--- a/arm9/src/font.c
+++ b/arm9/src/font.c
@@ -4,6 +4,7 @@
#include "graphic/font.naix"
#include "render_text.h"
#include "string16.h"
+#include "unk_02021590.h"
#include "text.h"
#include "unk_0201B8B8.h"
@@ -11,7 +12,12 @@ struct UnkStruct_02002C14 *UNK_02106FC8;
struct UnkStruct_02002C14 UNK_02106FCC;
-const u16 UNK_020ECB54[4][2] = { { 0, 0 }, { 1, 0 }, { 2, 0 }, { 3, 0 } };
+const u16 UNK_020ECB54[4][2] = {
+ { NARC_font_narc_0000_bin, FALSE },
+ { NARC_font_narc_0001_bin, FALSE },
+ { NARC_font_narc_0002_bin, FALSE },
+ { NARC_font_narc_0003_bin, FALSE }
+};
const struct FontInfo gFontInfos[5] = {
{ 0x0B, 0x10, 0x00, 0x00, 0x00, 0x01, 0x0F, 0x02 },
@@ -21,12 +27,6 @@ const struct FontInfo gFontInfos[5] = {
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
};
-extern struct UnkStruct_0202199C *FUN_02021590(u32, u16, u32, u16, u32);
-extern void FUN_020215E0(struct UnkStruct_0202199C *, u32, u32);
-extern void FUN_020215C8(struct UnkStruct_0202199C *param0);
-extern void FUN_02021750(struct UnkStruct_0202199C *, u32);
-extern u32 FUN_020218D8(struct UnkStruct_0202199C *, u16 *str, u32);
-
THUMB_FUNC void FUN_02002C14()
{
UNK_02106FC8 = &UNK_02106FCC;
@@ -40,10 +40,10 @@ THUMB_FUNC void FUN_02002C14()
SetFontsPointer(&gFontInfos[0]);
}
-THUMB_FUNC void FUN_02002C50(u32 param0, u32 param1)
+THUMB_FUNC void FUN_02002C50(u32 font_id, u32 heap_id)
{
- UNK_02106FC8->unk94[param0] =
- FUN_02021590(14, UNK_020ECB54[param0][0], 1, UNK_020ECB54[param0][1], param1);
+ UNK_02106FC8->unk94[font_id] =
+ FontData_new(NARC_GRAPHIC_FONT, UNK_020ECB54[font_id][0], 1, UNK_020ECB54[font_id][1], heap_id);
}
THUMB_FUNC void FUN_02002C84(s32 param0, u32 param1)
@@ -51,7 +51,7 @@ THUMB_FUNC void FUN_02002C84(s32 param0, u32 param1)
GF_ASSERT(param0 < 4);
GF_ASSERT(UNK_02106FC8->unk94[param0] != NULL);
- FUN_020215E0(UNK_02106FC8->unk94[param0], 0, param1);
+ FontData_ModeSwitch(UNK_02106FC8->unk94[param0], 0, param1);
}
THUMB_FUNC void FUN_02002CC0(s32 param0)
@@ -59,7 +59,7 @@ THUMB_FUNC void FUN_02002CC0(s32 param0)
GF_ASSERT(param0 < 4);
GF_ASSERT(UNK_02106FC8->unk94[param0] != NULL);
- FUN_020215E0(UNK_02106FC8->unk94[param0], 1, 0);
+ FontData_ModeSwitch(UNK_02106FC8->unk94[param0], 1, 0);
}
THUMB_FUNC void FUN_02002CF8(int param0)
@@ -89,16 +89,16 @@ THUMB_FUNC void FUN_02002CF8(int param0)
if (UNK_02106FC8->unk94[param0] != NULL)
{
- FUN_020215C8(UNK_02106FC8->unk94[param0]);
+ FontData_delete(UNK_02106FC8->unk94[param0]);
UNK_02106FC8->unk94[param0] = NULL;
}
}
-THUMB_FUNC struct UnkStruct_02002C14 *FUN_02002D94(u32 param0, u32 param1)
+THUMB_FUNC struct UnkStruct_02002C14_sub *FUN_02002D94(u32 param0, u32 param1)
{
- FUN_02021750(UNK_02106FC8->unk94[param0], param1);
+ TryLoadGlyph(UNK_02106FC8->unk94[param0], param1, &UNK_02106FC8->unk00);
- return UNK_02106FC8;
+ return &UNK_02106FC8->unk00;
}
THUMB_FUNC u32 FontFunc(u32 fontId, struct TextPrinter *printer)
@@ -119,14 +119,14 @@ THUMB_FUNC u32 FUN_02002DE0(u32 param0, u16 *str, u32 param2)
{
GF_ASSERT(UNK_02106FC8->unk94[param0] != NULL);
- FUN_020218D8(UNK_02106FC8->unk94[param0], str, param2);
+ return GetStringWidth(UNK_02106FC8->unk94[param0], str, param2);
}
THUMB_FUNC u32 FUN_02002E14(u32 param0, struct String *str, u32 param2)
{
GF_ASSERT(UNK_02106FC8->unk94[param0] != NULL);
- FUN_020218D8(UNK_02106FC8->unk94[param0], String_c_str(str), param2);
+ return GetStringWidth(UNK_02106FC8->unk94[param0], String_c_str(str), param2);
}
THUMB_FUNC s32 GetFontAttribute(u8 fontId, s32 attr)
@@ -163,7 +163,7 @@ THUMB_FUNC s32 GetFontAttribute(u8 fontId, s32 attr)
return ret;
}
-THUMB_FUNC void FUN_02002ED0(u32 layer, u32 baseAddr, u32 heap_id)
+THUMB_FUNC void FUN_02002ED0(enum GFBgLayer layer, u32 baseAddr, u32 heap_id)
{
GfGfxLoader_GXLoadPal(
NARC_GRAPHIC_FONT, NARC_font_narc_0006_NCLR, layer, baseAddr, 0x20, heap_id);
diff --git a/arm9/src/render_text.c b/arm9/src/render_text.c
index 34777739..aa29e82d 100644
--- a/arm9/src/render_text.c
+++ b/arm9/src/render_text.c
@@ -207,7 +207,7 @@ THUMB_FUNC u32 RenderText(struct TextPrinter *printer)
return 3;
}
- struct UnkStruct_02002C14 *r5 = FUN_02002D94(subStruct->glyphId, currentChar);
+ struct UnkStruct_02002C14_sub *r5 = FUN_02002D94(subStruct->glyphId, currentChar);
CopyGlyphToWindow(printer->printerTemplate.window,
r5->buf,
r5->width,
diff --git a/arm9/src/script_buffers.c b/arm9/src/script_buffers.c
index 1242d550..550dcab5 100644
--- a/arm9/src/script_buffers.c
+++ b/arm9/src/script_buffers.c
@@ -13,6 +13,8 @@
#include "script_buffers.h"
#include "unk_02024E64.h"
#include "text.h"
+#include "msgdata/msg.naix"
+#include "graphic/font.naix"
#pragma thumb on
@@ -34,9 +36,9 @@ const u16 UNK_020ECE6C[][2] = {
};
const u16 UNK_020ECE64[] = {
- 382,
- 384,
- 383,
+ NARC_msg_narc_0382_bin,
+ NARC_msg_narc_0384_bin,
+ NARC_msg_narc_0383_bin,
0
};
@@ -137,7 +139,7 @@ void BufferRivalsName(struct ScrStrBufs * mgr, u32 idx, struct SaveBlock2 * sav2
void BufferFriendsName(struct ScrStrBufs * mgr, u32 idx, struct SaveBlock2 * sav2)
{
struct PlayerData * data = Sav2_PlayerData_GetProfileAddr(sav2);
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 497, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0497_bin, mgr->heap_id);
if (PlayerProfile_GetTrainerGender(data) == 0)
{
ReadMsgDataIntoString(msgData, 1, mgr->tmpbuf);
@@ -152,7 +154,7 @@ void BufferFriendsName(struct ScrStrBufs * mgr, u32 idx, struct SaveBlock2 * sav
void BufferBoxMonSpeciesName(struct ScrStrBufs * mgr, u32 idx, struct BoxPokemon * mon)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 362, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0362_bin, mgr->heap_id);
ReadMsgDataIntoString(msgData, GetBoxMonData(mon, MON_DATA_SPECIES, NULL), mgr->tmpbuf);
SetStringAsPlaceholder(mgr, idx, mgr->tmpbuf, NULL);
DestroyMsgData(msgData);
@@ -165,7 +167,7 @@ void BufferBoxMonSpeciesNameWithArticle(struct ScrStrBufs * mgr, u32 idx, struct
void BufferSpeciesNameWithArticle(struct ScrStrBufs * mgr, u32 idx, u32 species)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 363, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0363_bin, mgr->heap_id);
ReadMsgDataIntoString(msgData, species, mgr->tmpbuf);
SetStringAsPlaceholder(mgr, idx, mgr->tmpbuf, NULL);
DestroyMsgData(msgData);
@@ -191,7 +193,7 @@ void BufferIntegerAsString(struct ScrStrBufs * mgr, u32 idx, int num, u32 ndigit
void BufferMoveName(struct ScrStrBufs * mgr, u32 idx, u32 move)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 588, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0588_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, move, mgr->tmpbuf);
@@ -202,7 +204,7 @@ void BufferMoveName(struct ScrStrBufs * mgr, u32 idx, u32 move)
void BufferRibbonNameOrDesc(struct ScrStrBufs * mgr, u32 idx, u32 ribbon)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 484, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0484_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, ribbon, mgr->tmpbuf);
@@ -213,7 +215,7 @@ void BufferRibbonNameOrDesc(struct ScrStrBufs * mgr, u32 idx, u32 ribbon)
void BufferAbilityName(struct ScrStrBufs * mgr, u32 idx, u32 ability)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 552, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0552_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, ability, mgr->tmpbuf);
@@ -224,7 +226,7 @@ void BufferAbilityName(struct ScrStrBufs * mgr, u32 idx, u32 ability)
void BufferNatureName(struct ScrStrBufs * mgr, u32 idx, u32 nature)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 190, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0190_bin, mgr->heap_id);
ReadMsgDataIntoString(msgData, nature, mgr->tmpbuf);
SetStringAsPlaceholder(mgr, idx, mgr->tmpbuf, NULL);
DestroyMsgData(msgData);
@@ -232,7 +234,7 @@ void BufferNatureName(struct ScrStrBufs * mgr, u32 idx, u32 nature)
void BufferItemName(struct ScrStrBufs * mgr, u32 idx, u32 item)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 344, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0344_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, item, mgr->tmpbuf);
@@ -243,7 +245,7 @@ void BufferItemName(struct ScrStrBufs * mgr, u32 idx, u32 item)
void BufferItemNameWithIndefArticle(struct ScrStrBufs * mgr, u32 idx, u32 item)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 346, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0346_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, item, mgr->tmpbuf);
@@ -254,7 +256,7 @@ void BufferItemNameWithIndefArticle(struct ScrStrBufs * mgr, u32 idx, u32 item)
void BufferItemNamePlural(struct ScrStrBufs * mgr, u32 idx, u32 item)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 347, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0347_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, item, mgr->tmpbuf);
@@ -265,7 +267,7 @@ void BufferItemNamePlural(struct ScrStrBufs * mgr, u32 idx, u32 item)
void BufferPocketName(struct ScrStrBufs * mgr, u32 idx, u32 pocket)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 349, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0349_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, pocket, mgr->tmpbuf);
@@ -276,7 +278,7 @@ void BufferPocketName(struct ScrStrBufs * mgr, u32 idx, u32 pocket)
void BufferTypeName(struct ScrStrBufs * mgr, u32 idx, u32 type)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 565, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0565_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, type, mgr->tmpbuf);
@@ -287,7 +289,7 @@ void BufferTypeName(struct ScrStrBufs * mgr, u32 idx, u32 type)
void BufferStatName(struct ScrStrBufs * mgr, u32 idx, u32 stat)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 495, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0495_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, stat, mgr->tmpbuf);
@@ -298,7 +300,7 @@ void BufferStatName(struct ScrStrBufs * mgr, u32 idx, u32 stat)
void BufferStatusName(struct ScrStrBufs * mgr, u32 idx, u32 status)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 205, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0205_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, status, mgr->tmpbuf);
@@ -309,7 +311,7 @@ void BufferStatusName(struct ScrStrBufs * mgr, u32 idx, u32 status)
void BufferFlavorDislikeText(struct ScrStrBufs * mgr, u32 idx, u32 flavor)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 548, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0548_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, flavor, mgr->tmpbuf);
@@ -320,7 +322,7 @@ void BufferFlavorDislikeText(struct ScrStrBufs * mgr, u32 idx, u32 flavor)
void BufferLandmarkName(struct ScrStrBufs * mgr, u32 idx, u32 landmark)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 382, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0382_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, landmark, mgr->tmpbuf);
@@ -331,7 +333,7 @@ void BufferLandmarkName(struct ScrStrBufs * mgr, u32 idx, u32 landmark)
void BufferPoketchAppName(struct ScrStrBufs * mgr, u32 idx, u32 app)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 406, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0406_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, app, mgr->tmpbuf);
@@ -342,7 +344,7 @@ void BufferPoketchAppName(struct ScrStrBufs * mgr, u32 idx, u32 app)
void BufferTrainerClassName(struct ScrStrBufs * mgr, u32 idx, u32 trclass)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 560, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0560_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, trclass, mgr->tmpbuf);
@@ -353,7 +355,7 @@ void BufferTrainerClassName(struct ScrStrBufs * mgr, u32 idx, u32 trclass)
void BufferTrainerClassNameWithArticle(struct ScrStrBufs * mgr, u32 idx, u32 trclass)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 561, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0561_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, trclass, mgr->tmpbuf);
@@ -364,7 +366,7 @@ void BufferTrainerClassNameWithArticle(struct ScrStrBufs * mgr, u32 idx, u32 trc
void BufferTrainerClassNameFromDataStruct(struct ScrStrBufs * mgr, u32 idx, struct TrainerDataLoaded * tr)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 560, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0560_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, tr->data.trainerClass, mgr->tmpbuf);
@@ -375,7 +377,7 @@ void BufferTrainerClassNameFromDataStruct(struct ScrStrBufs * mgr, u32 idx, stru
void BufferTrainerName(struct ScrStrBufs * mgr, u32 idx, u32 msgno)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 559, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0559_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, msgno, mgr->tmpbuf);
@@ -392,7 +394,7 @@ void BufferTrainerNameFromDataStruct(struct ScrStrBufs * mgr, u32 idx, struct Tr
void BufferUndergroundItemName(struct ScrStrBufs * mgr, u32 idx, u32 item)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 569, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0569_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, item, mgr->tmpbuf);
@@ -403,7 +405,7 @@ void BufferUndergroundItemName(struct ScrStrBufs * mgr, u32 idx, u32 item)
void BufferUndergroundItemNameWithArticle(struct ScrStrBufs * mgr, u32 idx, u32 item)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 570, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0570_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, item, mgr->tmpbuf);
@@ -414,7 +416,7 @@ void BufferUndergroundItemNameWithArticle(struct ScrStrBufs * mgr, u32 idx, u32
void BufferUndergroundTrapName(struct ScrStrBufs * mgr, u32 idx, u32 trap)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 571, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0571_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, trap, mgr->tmpbuf);
@@ -425,7 +427,7 @@ void BufferUndergroundTrapName(struct ScrStrBufs * mgr, u32 idx, u32 trap)
void BufferUndergroundTrapNameWithArticle(struct ScrStrBufs * mgr, u32 idx, u32 trap)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 572, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0572_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, trap, mgr->tmpbuf);
@@ -436,7 +438,7 @@ void BufferUndergroundTrapNameWithArticle(struct ScrStrBufs * mgr, u32 idx, u32
void BufferContestJudgeName(struct ScrStrBufs * mgr, u32 idx, u32 judge)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 194, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0194_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, judge, mgr->tmpbuf);
@@ -447,7 +449,7 @@ void BufferContestJudgeName(struct ScrStrBufs * mgr, u32 idx, u32 judge)
void BufferContestMessage(struct ScrStrBufs * mgr, u32 idx, u32 msg)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 191, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0191_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, msg, mgr->tmpbuf);
@@ -458,7 +460,7 @@ void BufferContestMessage(struct ScrStrBufs * mgr, u32 idx, u32 msg)
void BufferContestMessage2(struct ScrStrBufs * mgr, u32 idx, u32 msg)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 191, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0191_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, msg, mgr->tmpbuf);
@@ -469,7 +471,7 @@ void BufferContestMessage2(struct ScrStrBufs * mgr, u32 idx, u32 msg)
void BufferInterviewQuestion(struct ScrStrBufs * mgr, u32 idx, u32 question)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 574, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0574_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, question, mgr->tmpbuf);
@@ -480,7 +482,7 @@ void BufferInterviewQuestion(struct ScrStrBufs * mgr, u32 idx, u32 question)
void BufferInterviewAnswer(struct ScrStrBufs * mgr, u32 idx, u32 answer)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 573, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0573_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, answer, mgr->tmpbuf);
@@ -491,7 +493,7 @@ void BufferInterviewAnswer(struct ScrStrBufs * mgr, u32 idx, u32 answer)
void BufferDecorationName(struct ScrStrBufs * mgr, u32 idx, u32 decor)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 567, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0567_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, decor, mgr->tmpbuf);
@@ -502,7 +504,7 @@ void BufferDecorationName(struct ScrStrBufs * mgr, u32 idx, u32 decor)
void BufferDecorationNameWithArticle(struct ScrStrBufs * mgr, u32 idx, u32 decor)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 568, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0568_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, decor, mgr->tmpbuf);
@@ -513,7 +515,7 @@ void BufferDecorationNameWithArticle(struct ScrStrBufs * mgr, u32 idx, u32 decor
void BufferGenderSymbol(struct ScrStrBufs * mgr, u32 idx, u32 gender)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 199, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0199_bin, mgr->heap_id);
switch (gender)
{
case 0:
@@ -538,7 +540,7 @@ void BufferBoxName(struct ScrStrBufs * mgr, u32 idx, struct PCStorage * pc, int
void BufferGymName(struct ScrStrBufs * mgr, u32 idx, u32 gym)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 331, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0331_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, gym, mgr->tmpbuf);
@@ -549,7 +551,7 @@ void BufferGymName(struct ScrStrBufs * mgr, u32 idx, u32 gym)
void BufferTimeOfDayName(struct ScrStrBufs * mgr, u32 idx, u32 time)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 550, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0550_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, time, mgr->tmpbuf);
@@ -560,7 +562,7 @@ void BufferTimeOfDayName(struct ScrStrBufs * mgr, u32 idx, u32 time)
void BufferCountryName(struct ScrStrBufs * mgr, u32 idx, u32 country)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 612, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0612_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, country, mgr->tmpbuf);
@@ -592,7 +594,7 @@ void FUN_0200B518(struct ScrStrBufs * mgr, u32 idx, u32 a2)
void BufferSealName(struct ScrStrBufs * mgr, u32 idx, u32 seal)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 10, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0010_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, seal, mgr->tmpbuf);
@@ -603,7 +605,7 @@ void BufferSealName(struct ScrStrBufs * mgr, u32 idx, u32 seal)
void BufferSealNamePlural(struct ScrStrBufs * mgr, u32 idx, u32 seal)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 11, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0011_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, seal, mgr->tmpbuf);
@@ -629,7 +631,7 @@ void BufferLocationName(struct ScrStrBufs * mgr, u32 idx, u16 a2)
// Location is invalid.
// Fallback: Mystery Zone
DestroyMsgData(msgData);
- msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 382, mgr->heap_id);
+ msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0382_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, 0, mgr->tmpbuf);
@@ -641,7 +643,7 @@ void BufferLocationName(struct ScrStrBufs * mgr, u32 idx, u16 a2)
void BufferPoffinName(struct ScrStrBufs * mgr, u32 idx, u32 poffin)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 414, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0414_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, poffin, mgr->tmpbuf);
@@ -652,7 +654,7 @@ void BufferPoffinName(struct ScrStrBufs * mgr, u32 idx, u32 poffin)
void BufferFashionName(struct ScrStrBufs * mgr, u32 idx, u32 fashion)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 338, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0338_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, fashion, mgr->tmpbuf);
@@ -663,7 +665,7 @@ void BufferFashionName(struct ScrStrBufs * mgr, u32 idx, u32 fashion)
void BufferFashionNameWithArticle(struct ScrStrBufs * mgr, u32 idx, u32 fashion)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 339, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0339_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, fashion, mgr->tmpbuf);
@@ -674,7 +676,7 @@ void BufferFashionNameWithArticle(struct ScrStrBufs * mgr, u32 idx, u32 fashion)
void BufferContestBackgroundName(struct ScrStrBufs * mgr, u32 idx, u32 bg)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 340, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0340_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, bg, mgr->tmpbuf);
@@ -696,7 +698,7 @@ void BufferEasyChatWord(struct ScrStrBufs * mgr, struct SaveBlock2 * sav2, u32 r
void BufferMonthNameAbbr(struct ScrStrBufs * mgr, u32 idx, u32 month)
{
- struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, 364, mgr->heap_id);
+ struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0364_bin, mgr->heap_id);
if (msgData != NULL)
{
if (month < 1 || month > 12)
@@ -746,12 +748,12 @@ void ScrStrBufs_ResetBuffers(struct ScrStrBufs * mgr)
StringSetEmpty(mgr->array[i].msg);
}
-struct UnkStruct_0200B870 * MessagePrinter_new(u32 r5, u32 r6, u32 sp4, u32 r4)
+struct UnkStruct_0200B870 * MessagePrinter_new(u32 color1, u32 color2, u32 color3, u32 heap_id)
{
- struct UnkStruct_0200B870 * sp8 = AllocFromHeap(r4, sizeof(struct UnkStruct_0200B870));
+ struct UnkStruct_0200B870 * sp8 = AllocFromHeap(heap_id, sizeof(struct UnkStruct_0200B870));
if (sp8 != NULL)
{
- sp8->unk_0 = GfGfxLoader_GetCharData(NARC_GRAPHIC_FONT, 4, 1, &sp8->unk_4, r4);
+ sp8->unk_0 = GfGfxLoader_GetCharData(NARC_GRAPHIC_FONT, NARC_font_narc_0004_NCGR_lz, 1, &sp8->unk_4, heap_id);
int i;
u8 * ptr = sp8->unk_4->unk_14;
for (i = 0; i < sp8->unk_4->unk_10; i++)
@@ -759,35 +761,35 @@ struct UnkStruct_0200B870 * MessagePrinter_new(u32 r5, u32 r6, u32 sp4, u32 r4)
switch (ptr[i])
{
case 0x00:
- ptr[i] = (u8)((sp4 << 4) | sp4);
+ ptr[i] = (u8)((color3 << 4) | color3);
break;
case 0x01:
- ptr[i] = (u8)((sp4 << 4) | r5);
+ ptr[i] = (u8)((color3 << 4) | color1);
break;
case 0x02:
- ptr[i] = (u8)((sp4 << 4) | r6);
+ ptr[i] = (u8)((color3 << 4) | color2);
break;
case 0x10:
- ptr[i] = (u8)((r5 << 4) | sp4);
+ ptr[i] = (u8)((color1 << 4) | color3);
break;
case 0x11:
- ptr[i] = (u8)((r5 << 4) | r5);
+ ptr[i] = (u8)((color1 << 4) | color1);
break;
case 0x12:
- ptr[i] = (u8)((r5 << 4) | r6);
+ ptr[i] = (u8)((color1 << 4) | color2);
break;
case 0x20:
- ptr[i] = (u8)((r6 << 4) | sp4);
+ ptr[i] = (u8)((color2 << 4) | color3);
break;
case 0x21:
- ptr[i] = (u8)((r6 << 4) | r5);
+ ptr[i] = (u8)((color2 << 4) | color1);
break;
case 0x22:
- ptr[i] = (u8)((r6 << 4) | r6);
+ ptr[i] = (u8)((color2 << 4) | color2);
break;
}
}
- sp8->unk_28 = sp4;
+ sp8->unk_28 = color3;
}
return sp8;
}
diff --git a/arm9/src/text.c b/arm9/src/text.c
index e8c76722..64b3587e 100644
--- a/arm9/src/text.c
+++ b/arm9/src/text.c
@@ -6,10 +6,11 @@
#include "script_buffers.h"
#include "unk_0200CA44.h"
#include "font.h"
+#include "graphic/font.naix"
const struct FontInfo *gFonts = NULL;
-u16 UNK_021C5734[0x100];
+u16 sFontHalfRowLookupTable[0x100];
BOOL UNK_021C5714[8];
u16 UNK_021C570E;
u16 UNK_021C5710;
@@ -294,7 +295,7 @@ THUMB_FUNC void GenerateFontHalfRowLookupTable(u8 fgColor, u8 bgColor, u8 shadow
{
for (l = 0; l < 4; l++)
{
- UNK_021C5734[r5++] = (u16)((sp20[l] << 12) | (sp20[k] << 8) | (sp20[j] << 4) | (sp20[i] << 0));
+ sFontHalfRowLookupTable[r5++] = (u16)((sp20[l] << 12) | (sp20[k] << 8) | (sp20[j] << 4) | (sp20[i] << 0));
}
}
}
@@ -303,22 +304,22 @@ THUMB_FUNC void GenerateFontHalfRowLookupTable(u8 fgColor, u8 bgColor, u8 shadow
THUMB_FUNC void DecompressGlyphTile(const u16 *src, u16 *dst)
{
- dst[0] = UNK_021C5734[(u32)src[0] >> 8];
- dst[1] = UNK_021C5734[(u8)src[0]];
- dst[2] = UNK_021C5734[(u32)src[1] >> 8];
- dst[3] = UNK_021C5734[(u8)src[1]];
- dst[4] = UNK_021C5734[(u32)src[2] >> 8];
- dst[5] = UNK_021C5734[(u8)src[2]];
- dst[6] = UNK_021C5734[(u32)src[3] >> 8];
- dst[7] = UNK_021C5734[(u8)src[3]];
- dst[8] = UNK_021C5734[(u32)src[4] >> 8];
- dst[9] = UNK_021C5734[(u8)src[4]];
- dst[10] = UNK_021C5734[(u32)src[5] >> 8];
- dst[11] = UNK_021C5734[(u8)src[5]];
- dst[12] = UNK_021C5734[(u32)src[6] >> 8];
- dst[13] = UNK_021C5734[(u8)src[6]];
- dst[14] = UNK_021C5734[(u32)src[7] >> 8];
- dst[15] = UNK_021C5734[(u8)src[7]];
+ dst[0] = sFontHalfRowLookupTable[(u32)src[0] >> 8];
+ dst[1] = sFontHalfRowLookupTable[(u8)src[0]];
+ dst[2] = sFontHalfRowLookupTable[(u32)src[1] >> 8];
+ dst[3] = sFontHalfRowLookupTable[(u8)src[1]];
+ dst[4] = sFontHalfRowLookupTable[(u32)src[2] >> 8];
+ dst[5] = sFontHalfRowLookupTable[(u8)src[2]];
+ dst[6] = sFontHalfRowLookupTable[(u32)src[3] >> 8];
+ dst[7] = sFontHalfRowLookupTable[(u8)src[3]];
+ dst[8] = sFontHalfRowLookupTable[(u32)src[4] >> 8];
+ dst[9] = sFontHalfRowLookupTable[(u8)src[4]];
+ dst[10] = sFontHalfRowLookupTable[(u32)src[5] >> 8];
+ dst[11] = sFontHalfRowLookupTable[(u8)src[5]];
+ dst[12] = sFontHalfRowLookupTable[(u32)src[6] >> 8];
+ dst[13] = sFontHalfRowLookupTable[(u8)src[6]];
+ dst[14] = sFontHalfRowLookupTable[(u32)src[7] >> 8];
+ dst[15] = sFontHalfRowLookupTable[(u8)src[7]];
}
THUMB_FUNC void FUN_0201C1A8(struct TextPrinter *printer)
@@ -330,7 +331,7 @@ THUMB_FUNC u16 *FUN_0201C1B0(void)
{
void *res = AllocFromHeap(0, 32 * 24 * sizeof(u16));
struct UnkStruct_0200B870_sub * var;
- void *tmp = GfGfxLoader_GetCharData(NARC_GRAPHIC_FONT, 5, 0, &var, 0);
+ void *tmp = GfGfxLoader_GetCharData(NARC_GRAPHIC_FONT, NARC_font_narc_0005_NCGR, 0, &var, 0);
MI_CpuCopy32(var->unk_14, res, 32 * 24 * sizeof(u16));
FreeToHeap(tmp);
return res;
diff --git a/arm9/src/unk_02021590.c b/arm9/src/unk_02021590.c
new file mode 100644
index 00000000..e6a3d690
--- /dev/null
+++ b/arm9/src/unk_02021590.c
@@ -0,0 +1,212 @@
+#include "global.h"
+#include "heap.h"
+#include "filesystem.h"
+#include "unk_02021590.h"
+#include "unk_0201B8B8.h"
+#include "string_util.h"
+
+static const u8 sGlyphShapes[][2] = {
+ { 0, 1 },
+ { 2, 3 },
+};
+
+static void (*const sAllocators[])(struct FontData *, u32) = {
+ InitFontResources_FromPreloaded,
+ InitFontResources_LazyFromNarc,
+};
+
+static void (*const sDestructors[])(struct FontData *) = {
+ FreeLoadedFontResources_FromPreloaded,
+ FreeLoadedFontResources_LazyFromNarc,
+};
+
+THUMB_FUNC struct FontData *FontData_new(NarcId narcId, s32 fileId, u32 unk2, BOOL unk3, u32 heap_id)
+{
+ struct FontData * ret = (struct FontData *)AllocFromHeap(heap_id, sizeof(struct FontData));
+ if (ret != NULL)
+ {
+ FontData_Init(ret, narcId, fileId, unk3, heap_id);
+ InitFontResources(ret, unk2, heap_id);
+ }
+ return ret;
+}
+
+THUMB_FUNC void FontData_delete(struct FontData * ptr)
+{
+ FreeLoadedFontResources(ptr);
+ FontData_FreeWidthsAndNarc(ptr);
+ FreeToHeap(ptr);
+}
+
+THUMB_FUNC void FontData_ModeSwitch(struct FontData * ptr, u32 a1, u32 heap_id)
+{
+ if (ptr->glyphAccessMode != a1)
+ {
+ FreeLoadedFontResources(ptr);
+ InitFontResources(ptr, a1, heap_id);
+ }
+}
+
+THUMB_FUNC void FontData_Init(struct FontData *ptr, NarcId narcId, s32 fileId, BOOL unk, u32 heap_id)
+{
+ ptr->narc = NARC_ctor(narcId, heap_id);
+ if (ptr->narc != NULL)
+ {
+ NARC_ReadFromMember(ptr->narc, (u32)fileId, 0, 16, &ptr->gfxHeader);
+ ptr->isFixedWidthFont = unk;
+ if (unk)
+ {
+ ptr->glyphWidths = NULL;
+ ptr->glyphWidthFunc = GetGlyphWidth_FixedWidth;
+ }
+ else
+ {
+ GF_ASSERT(ptr->gfxHeader.widthDataStart != 0);
+ ptr->glyphWidths = AllocFromHeap(heap_id, ptr->gfxHeader.numGlyphs);
+ ptr->glyphWidthFunc = GetGlyphWidth_VariableWidth;
+ NARC_ReadFromMember(ptr->narc, (u32)fileId, ptr->gfxHeader.widthDataStart, ptr->gfxHeader.numGlyphs, ptr->glyphWidths);
+ }
+ GF_ASSERT(ptr->gfxHeader.glyphWidth <= 2 && ptr->gfxHeader.glyphHeight <= 2);
+ ptr->glyphShape = sGlyphShapes[ptr->gfxHeader.glyphWidth - 1][ptr->gfxHeader.glyphHeight - 1];
+ ptr->glyphSize = (u32)(16 * ptr->gfxHeader.glyphWidth * ptr->gfxHeader.glyphHeight);
+ ptr->fileId = (u32)fileId;
+ }
+}
+
+THUMB_FUNC void FontData_FreeWidthsAndNarc(struct FontData * ptr)
+{
+ if (ptr->glyphWidths != NULL)
+ FreeToHeap(ptr->glyphWidths);
+ if (ptr->narc != NULL)
+ NARC_dtor(ptr->narc);
+}
+
+THUMB_FUNC void InitFontResources(struct FontData * ptr, u32 a1, u32 heap_id)
+{
+ ptr->glyphAccessMode = a1;
+ sAllocators[a1](ptr, heap_id);
+}
+
+THUMB_FUNC void InitFontResources_FromPreloaded(struct FontData * ptr, u32 heap_id)
+{
+ u32 r4 = ptr->glyphSize * ptr->gfxHeader.numGlyphs;
+ ptr->narcReadBuf = AllocFromHeap(heap_id, r4);
+ ptr->uncompGlyphFunc = DecompressGlyphTiles_FromPreloaded;
+ NARC_ReadFromMember(ptr->narc, ptr->fileId, ptr->gfxHeader.headerSize, r4, ptr->narcReadBuf);
+}
+
+THUMB_FUNC void InitFontResources_LazyFromNarc(struct FontData * ptr, u32 heap_id)
+{
+#pragma unused(heap_id)
+ ptr->uncompGlyphFunc = DecompressGlyphTiles_LazyFromNarc;
+}
+
+THUMB_FUNC void FreeLoadedFontResources(struct FontData * ptr)
+{
+ sDestructors[ptr->glyphAccessMode](ptr);
+}
+
+THUMB_FUNC void FreeLoadedFontResources_FromPreloaded(struct FontData * ptr)
+{
+ FreeToHeap(ptr->narcReadBuf);
+ ptr->narcReadBuf = NULL;
+}
+
+THUMB_FUNC void FreeLoadedFontResources_LazyFromNarc(struct FontData * ptr)
+{
+#pragma unused(ptr)
+}
+
+THUMB_FUNC void TryLoadGlyph(struct FontData * ptr, u32 param1, struct UnkStruct_02002C14_sub * ptr2)
+{
+ if (param1 <= ptr->gfxHeader.numGlyphs)
+ ptr->uncompGlyphFunc(ptr, (u16)(param1 - 1), ptr2);
+ else
+ {
+ ptr2->width = 0;
+ ptr2->height = 0;
+ }
+}
+
+THUMB_FUNC void DecompressGlyphTiles_FromPreloaded(struct FontData * ptr, u16 param1, struct UnkStruct_02002C14_sub * param2)
+{
+ u8 *r4 = &((u8 *)ptr->narcReadBuf)[param1 * ptr->glyphSize];
+ switch (ptr->glyphShape)
+ {
+ case 0:
+ DecompressGlyphTile((void *)(r4), (void *)param2->buf);
+ break;
+ case 1:
+ DecompressGlyphTile((void *)(r4), (void *)param2->buf);
+ DecompressGlyphTile((void *)(r4 + 0x10), (void *)(param2->buf + 0x40));
+ break;
+ case 2:
+ DecompressGlyphTile((void *)(r4), (void *)param2->buf);
+ DecompressGlyphTile((void *)(r4 + 0x10), (void *)(param2->buf + 0x20));
+ break;
+ case 3:
+ DecompressGlyphTile((void *)(r4), (void *)param2->buf);
+ DecompressGlyphTile((void *)(r4 + 0x10), (void *)(param2->buf + 0x20));
+ DecompressGlyphTile((void *)(r4 + 0x20), (void *)(param2->buf + 0x40));
+ DecompressGlyphTile((void *)(r4 + 0x30), (void *)(param2->buf + 0x60));
+ break;
+ }
+ param2->width = (u8)ptr->glyphWidthFunc(ptr, param1);
+ param2->height = ptr->gfxHeader.fixedHeight;
+}
+
+THUMB_FUNC void DecompressGlyphTiles_LazyFromNarc(struct FontData * ptr, u16 param1, struct UnkStruct_02002C14_sub * param2)
+{
+ NARC_ReadFromMember(ptr->narc, ptr->fileId, ptr->gfxHeader.headerSize + param1 * ptr->glyphSize, ptr->glyphSize, ptr->glyphReadBuf);
+ switch (ptr->glyphShape)
+ {
+ case 0:
+ DecompressGlyphTile((void *)(ptr->glyphReadBuf), (void *)param2->buf);
+ break;
+ case 1:
+ DecompressGlyphTile((void *)(ptr->glyphReadBuf), (void *)param2->buf);
+ DecompressGlyphTile((void *)(ptr->glyphReadBuf + 0x10), (void *)(param2->buf + 0x40));
+ break;
+ case 2:
+ DecompressGlyphTile((void *)(ptr->glyphReadBuf), (void *)param2->buf);
+ DecompressGlyphTile((void *)(ptr->glyphReadBuf + 0x10), (void *)(param2->buf + 0x20));
+ break;
+ case 3:
+ DecompressGlyphTile((void *)(ptr->glyphReadBuf), (void *)param2->buf);
+ DecompressGlyphTile((void *)(ptr->glyphReadBuf + 0x10), (void *)(param2->buf + 0x20));
+ DecompressGlyphTile((void *)(ptr->glyphReadBuf + 0x20), (void *)(param2->buf + 0x40));
+ DecompressGlyphTile((void *)(ptr->glyphReadBuf + 0x30), (void *)(param2->buf + 0x60));
+ break;
+ }
+ param2->width = (u8)ptr->glyphWidthFunc(ptr, param1);
+ param2->height = ptr->gfxHeader.fixedHeight;
+}
+
+THUMB_FUNC u32 GetStringWidth(struct FontData * ptr, const u16 * str, u32 letterSpacing)
+{
+ u32 width = 0;
+
+ while (*str != EOS)
+ {
+ if (*str == 0xFFFE)
+ {
+ str = MsgArray_SkipControlCode(str);
+ if (*str == EOS)
+ break;
+ }
+ width += ptr->glyphWidthFunc(ptr, (*str) - 1) + letterSpacing;
+ str++;
+ }
+ return width - letterSpacing;
+}
+
+THUMB_FUNC int GetGlyphWidth_VariableWidth(struct FontData * ptr, int a1)
+{
+ return ptr->glyphWidths[a1];
+}
+
+THUMB_FUNC int GetGlyphWidth_FixedWidth(struct FontData * ptr, int a1)
+{
+#pragma unused(a1)
+ return ptr->gfxHeader.fixedWidth;
+}
diff --git a/arm9/src/unk_02021934.c b/arm9/src/unk_02021934.c
index b12e2d8f..07ddde87 100644
--- a/arm9/src/unk_02021934.c
+++ b/arm9/src/unk_02021934.c
@@ -3,6 +3,7 @@
#include "heap.h"
#include "string_util.h"
#include "unk_0201B8B8.h"
+#include "unk_02021590.h"
#pragma thumb on
@@ -10,7 +11,7 @@
void StrAddChar(struct String * str, u16 val);
-s32 StringGetWidth(struct UnkStruct_0202199C * r7, const u16 * arr, u32 r6)
+s32 StringGetWidth(struct FontData * r7, const u16 * arr, u32 r6)
{
s32 ret = 0;
u32 r4 = 0;
@@ -29,7 +30,7 @@ s32 StringGetWidth(struct UnkStruct_0202199C * r7, const u16 * arr, u32 r6)
}
else
{
- r4 += (r6 + r7->unk_70(r7, *arr - 1));
+ r4 += (r6 + r7->glyphWidthFunc(r7, *arr - 1));
arr++;
}
}
@@ -38,7 +39,7 @@ s32 StringGetWidth(struct UnkStruct_0202199C * r7, const u16 * arr, u32 r6)
return ret;
}
-s32 StringGetWidth_SingleLine_HandleClearToControlCode(struct UnkStruct_0202199C * r6, const u16 * arr)
+s32 StringGetWidth_SingleLine_HandleClearToControlCode(struct FontData * r6, const u16 * arr)
{
s32 ret = 0;
while (*arr != 0xFFFF)
@@ -53,7 +54,7 @@ s32 StringGetWidth_SingleLine_HandleClearToControlCode(struct UnkStruct_0202199C
}
else
{
- ret += r6->unk_70(r6, *arr - 1);
+ ret += r6->glyphWidthFunc(r6, *arr - 1);
arr++;
}
}
diff --git a/include/font.h b/include/font.h
index 963e36bc..3c0f4267 100644
--- a/include/font.h
+++ b/include/font.h
@@ -4,28 +4,33 @@
#include "global.h"
#include "text.h"
-struct UnkStruct_02002C14
+struct UnkStruct_02002C14_sub
{
const char buf[0x80];
u8 width;
u8 height;
+};
+
+struct UnkStruct_02002C14
+{
+ struct UnkStruct_02002C14_sub unk00;
void *unk84[4];
- struct UnkStruct_0202199C *unk94[4];
+ struct FontData *unk94[4];
};
extern struct UnkStruct_02002C14 *UNK_02106FC8;
void FUN_02002C14();
-void FUN_02002C50(u32 param0, u32 param1);
+void FUN_02002C50(u32 font_id, u32 heap_id);
void FUN_02002C84(s32 param0, u32 param1);
void FUN_02002CC0(s32 param0);
void FUN_02002CF8(int param0);
-struct UnkStruct_02002C14 *FUN_02002D94(u32 param0, u32 param1);
+struct UnkStruct_02002C14_sub *FUN_02002D94(u32 param0, u32 param1);
u32 FontFunc(u32 fontId, struct TextPrinter *printer);
u32 FUN_02002DE0(u32 param0, u16 *str, u32 param2);
u32 FUN_02002E14(u32 param0, struct String *str, u32 param2);
s32 GetFontAttribute(u8 fontId, s32 attr);
-void FUN_02002ED0(u32 layer, u32 baseAddr, u32 heap_id);
+void FUN_02002ED0(enum GFBgLayer layer, u32 baseAddr, u32 heap_id);
void FUN_02002EEC(u32 layer, u32 baseAddr, u32 heap_id);
s32 FUN_02002F08(u32 param0, struct String *str, u32 param2);
u32 FUN_02002F40(u32 param0, struct String *str, u32 param2, u32 param3);
diff --git a/include/script_buffers.h b/include/script_buffers.h
index b9f0e268..e5c39291 100644
--- a/include/script_buffers.h
+++ b/include/script_buffers.h
@@ -104,7 +104,7 @@ void BufferMonthNameAbbr(struct ScrStrBufs * mgr, u32 idx, u32 month);
void ScrStrBufs_UpperFirstChar(struct ScrStrBufs * mgr, u32 idx);
void StringExpandPlaceholders(struct ScrStrBufs * mgr, struct String * dest, struct String * src);
void ScrStrBufs_ResetBuffers(struct ScrStrBufs * mgr);
-struct UnkStruct_0200B870 * MessagePrinter_new(u32 r5, u32 r6, u32 sp4, u32 r4);
+struct UnkStruct_0200B870 * MessagePrinter_new(u32 color1, u32 color2, u32 color3, u32 heap_id);
void MessagePrinter_delete(struct UnkStruct_0200B870 * a0);
void FUN_0200B9A8(struct UnkStruct_0200B870 * a0, int a1, struct Window * a2, int a3, int a4);
void FUN_0200B9EC(struct UnkStruct_0200B870 * string, u32 value, u32 n, enum PrintingMode mode, struct Window *window, int x, int y);
diff --git a/include/string16.h b/include/string16.h
index 69ea4e30..f42ff918 100644
--- a/include/string16.h
+++ b/include/string16.h
@@ -2,6 +2,7 @@
#define POKEDIAMOND_STRING16_H
#include "string_util.h"
+#include "unk_02021590.h"
struct String
{
@@ -12,12 +13,6 @@ struct String
u8 padding[2];
};
-struct UnkStruct_0202199C
-{
- u8 filler_00[0x70];
- int (*unk_70)(struct UnkStruct_0202199C *, int);
-};
-
#define STR16_MAGIC 0xB6F8D2EC
struct String * String_ctor(u32 count, u32 heap_id);
@@ -25,8 +20,8 @@ BOOL StringCompare(struct String *, struct String *);
void CopyU16ArrayToStringN(struct String *, u16 *, u32); // copy
void StringSetEmpty(struct String *); // set empty
struct String * StringDup(struct String *, u32 heap_id);
-s32 StringGetWidth(struct UnkStruct_0202199C * r7, const u16 * arr, u32 r6);
-s32 StringGetWidth_SingleLine_HandleClearToControlCode(struct UnkStruct_0202199C * r6, const u16 * arr);
+s32 StringGetWidth(struct FontData * r7, const u16 * arr, u32 r6);
+s32 StringGetWidth_SingleLine_HandleClearToControlCode(struct FontData * r6, const u16 * arr);
void String_dtor(struct String * str);
void StringCopy(struct String * dest, struct String * src);
void String16_FormatInteger(struct String * str, int num, u32 ndigits, int strConvMode, BOOL whichCharset);
diff --git a/include/unk_02021590.h b/include/unk_02021590.h
new file mode 100644
index 00000000..6ed73bb8
--- /dev/null
+++ b/include/unk_02021590.h
@@ -0,0 +1,52 @@
+#ifndef POKEDIAMOND_UNK_02021590_H
+#define POKEDIAMOND_UNK_02021590_H
+
+#include "filesystem.h"
+#include "font.h"
+
+struct FontGraphicHeader
+{
+ u32 headerSize;
+ u32 widthDataStart;
+ u32 numGlyphs;
+ u8 fixedWidth;
+ u8 fixedHeight;
+ u8 glyphWidth;
+ u8 glyphHeight;
+};
+
+struct FontData
+{
+ u32 glyphAccessMode;
+ void (*uncompGlyphFunc)(struct FontData *, u16, struct UnkStruct_02002C14_sub *);
+ u32 glyphShape;
+ u32 glyphSize;
+ void * narcReadBuf;
+ u8 glyphReadBuf[0x40];
+ NARC * narc;
+ u32 fileId;
+ struct FontGraphicHeader gfxHeader;
+ BOOL isFixedWidthFont;
+ int (*glyphWidthFunc)(struct FontData *, int);
+ u8 * glyphWidths;
+};
+
+struct FontData *FontData_new(NarcId narcId, s32 fileId, u32 unk2, BOOL unk3, u32 heap_id);
+void FontData_delete(struct FontData * ptr);
+void FontData_ModeSwitch(struct FontData * ptr, u32 a1, u32 heap_id);
+void FontData_Init(struct FontData *ptr, NarcId narcId, s32 fileId, BOOL unk, u32 heap_id);
+void FontData_FreeWidthsAndNarc(struct FontData * ptr);
+void InitFontResources(struct FontData * ptr, u32 a1, u32 heap_id);
+void InitFontResources_FromPreloaded(struct FontData * ptr, u32 heap_id);
+void InitFontResources_LazyFromNarc(struct FontData * ptr, u32 heap_id);
+void FreeLoadedFontResources(struct FontData * ptr);
+void FreeLoadedFontResources_FromPreloaded(struct FontData * ptr);
+void FreeLoadedFontResources_LazyFromNarc(struct FontData * ptr);
+void TryLoadGlyph(struct FontData * ptr, u32 param1, struct UnkStruct_02002C14_sub * ptr2);
+void DecompressGlyphTiles_FromPreloaded(struct FontData * ptr, u16 param1, struct UnkStruct_02002C14_sub * param2);
+void DecompressGlyphTiles_LazyFromNarc(struct FontData * ptr, u16 param1, struct UnkStruct_02002C14_sub * param2);
+u32 GetStringWidth(struct FontData * ptr, const u16 * str, u32 letterSpacing);
+int GetGlyphWidth_VariableWidth(struct FontData * ptr, int a1);
+int GetGlyphWidth_FixedWidth(struct FontData * ptr, int a1);
+
+#endif //POKEDIAMOND_UNK_02021590_H
diff --git a/tools/.gitignore b/tools/.gitignore
new file mode 100644
index 00000000..5bae8ad8
--- /dev/null
+++ b/tools/.gitignore
@@ -0,0 +1 @@
+asmdiff