diff options
-rw-r--r-- | arm9/arm9.lsf | 1 | ||||
-rw-r--r-- | arm9/asm/unk_02002C14.s | 2 | ||||
-rw-r--r-- | arm9/asm/unk_0201BCBC.s | 144 | ||||
-rw-r--r-- | arm9/global.inc | 2 | ||||
-rw-r--r-- | arm9/src/text.c | 85 | ||||
-rw-r--r-- | include/text.h | 56 |
6 files changed, 150 insertions, 140 deletions
diff --git a/arm9/arm9.lsf b/arm9/arm9.lsf index b762561e..8f0b150b 100644 --- a/arm9/arm9.lsf +++ b/arm9/arm9.lsf @@ -55,6 +55,7 @@ Static arm9 Object unk_0201B6D0.o Object unk_0201B8B8.o Object math_util.o + Object text.o Object unk_0201BCBC.o Object unk_0201C24C.o Object unk_0201C360.o diff --git a/arm9/asm/unk_02002C14.s b/arm9/asm/unk_02002C14.s index c6fd3590..c4049d4b 100644 --- a/arm9/asm/unk_02002C14.s +++ b/arm9/asm/unk_02002C14.s @@ -53,7 +53,7 @@ _02002C22: cmp r1, #0x4 blo _02002C22 ldr r0, _02002C4C ; =UNK_020ECB64 - bl FUN_0201BCBC + bl SetFontsPointer pop {r4, pc} nop _02002C44: .word UNK_02106FCC diff --git a/arm9/asm/unk_0201BCBC.s b/arm9/asm/unk_0201BCBC.s index 49d206bb..1f8efdda 100644 --- a/arm9/asm/unk_0201BCBC.s +++ b/arm9/asm/unk_0201BCBC.s @@ -1,146 +1,16 @@ .include "asm/macros.inc" .include "global.inc" - .section .data - - .global gFonts -gFonts: ; 0x02105BB4 - .word 0 - - .section .bss - - .global UNK_021C570C -UNK_021C570C: ; 0x021C570C - .space 0x8 - - .global UNK_021C5714 -UNK_021C5714: ; 0x021C5714 - .space 0x20 - - .global UNK_021C5734 -UNK_021C5734: ; 0x021C5734 - .space 0x200 + .extern gFonts + .extern UNK_021C570C + .extern UNK_021C5714 + .extern UNK_021C5734 + .extern FUN_0201BCC8 + .extern FUN_0201BCFC + .extern FUN_0201BD44 .text - thumb_func_start FUN_0201BCBC -FUN_0201BCBC: ; 0x0201BCBC - ldr r1, _0201BCC4 ; =gFonts - str r0, [r1, #0x0] - bx lr - nop -_0201BCC4: .word gFonts - - thumb_func_start FUN_0201BCC8 -FUN_0201BCC8: ; 0x0201BCC8 - push {r4-r6, lr} - ldr r4, _0201BCF8 ; =UNK_021C5714 - mov r5, #0x0 -_0201BCCE: - ldr r3, [r4, #0x0] - cmp r3, #0x0 - bne _0201BCE8 - ldr r6, _0201BCF8 ; =UNK_021C5714 - lsl r4, r5, #0x2 - bl FUN_0200CA7C - str r0, [r6, r4] - ldr r0, [r6, r4] - cmp r0, #0x0 - bne _0201BCF0 - mov r5, #0x8 - b _0201BCF0 -_0201BCE8: - add r5, r5, #0x1 - add r4, r4, #0x4 - cmp r5, #0x8 - blt _0201BCCE -_0201BCF0: - lsl r0, r5, #0x18 - lsr r0, r0, #0x18 - pop {r4-r6, pc} - nop -_0201BCF8: .word UNK_021C5714 - - thumb_func_start FUN_0201BCFC -FUN_0201BCFC: ; 0x0201BCFC - push {r4-r6, lr} - add r5, r0, #0x0 - cmp r5, #0x8 - blo _0201BD08 - bl ErrorHandling -_0201BD08: - ldr r6, _0201BD40 ; =UNK_021C5714 - lsl r4, r5, #0x2 - ldr r0, [r6, r4] - cmp r0, #0x0 - bne _0201BD16 - bl ErrorHandling -_0201BD16: - cmp r5, #0x8 - bhs _0201BD3C - ldr r0, [r6, r4] - cmp r0, #0x0 - beq _0201BD3C - bl FUN_0201B6C8 - add r5, r0, #0x0 - beq _0201BD32 - bl FUN_0201C238 - add r0, r5, #0x0 - bl FreeToHeap -_0201BD32: - ldr r0, [r6, r4] - bl FUN_0200CAB4 - mov r0, #0x0 - str r0, [r6, r4] -_0201BD3C: - pop {r4-r6, pc} - nop -_0201BD40: .word UNK_021C5714 - - thumb_func_start FUN_0201BD44 -FUN_0201BD44: ; 0x0201BD44 - lsl r1, r0, #0x2 - ldr r0, _0201BD58 ; =UNK_021C5714 - ldr r0, [r0, r1] - cmp r0, #0x0 - beq _0201BD52 - mov r0, #0x1 - bx lr -_0201BD52: - mov r0, #0x0 - bx lr - nop -_0201BD58: .word UNK_021C5714 - - thumb_func_start FUN_0201BD5C -FUN_0201BD5C: ; 0x0201BD5C - mov r1, #0x0 - ldr r2, _0201BD6C ; =UNK_021C5714 - add r0, r1, #0x0 -_0201BD62: - add r1, r1, #0x1 - stmia r2!, {r0} - cmp r1, #0x8 - blt _0201BD62 - bx lr - .balign 4 -_0201BD6C: .word UNK_021C5714 - - thumb_func_start FUN_0201BD70 -FUN_0201BD70: ; 0x0201BD70 - push {r3, lr} - bl FUN_0201BD44 - lsl r0, r0, #0x18 - lsr r0, r0, #0x18 - pop {r3, pc} - - thumb_func_start FUN_0201BD7C -FUN_0201BD7C: ; 0x0201BD7C - ldr r3, _0201BD80 ; =FUN_0201BCFC - bx r3 - .balign 4 -_0201BD80: .word FUN_0201BCFC - thumb_func_start AddTextPrinterParameterized AddTextPrinterParameterized: ; 0x0201BD84 push {r3, lr} diff --git a/arm9/global.inc b/arm9/global.inc index d703c8eb..d6759f95 100644 --- a/arm9/global.inc +++ b/arm9/global.inc @@ -1153,7 +1153,7 @@ .extern MTX22_2DAffine .extern CircularDistance .extern MathUtil_0201BC84 -.extern FUN_0201BCBC +.extern SetFontsPointer .extern FUN_0201BD5C .extern FUN_0201BD70 .extern FUN_0201BD7C diff --git a/arm9/src/text.c b/arm9/src/text.c new file mode 100644 index 00000000..cd846135 --- /dev/null +++ b/arm9/src/text.c @@ -0,0 +1,85 @@ +#include "text.h" +#include "heap.h" + +const struct FontInfo *gFonts = NULL; + +u8 UNK_021C5734[0x200]; +u32 UNK_021C5714[8]; +u8 UNK_021C570C[8]; + +extern u32 FUN_0200CA7C(void *param0, u32 param1, u32 param2); + +extern void *FUN_0201B6C8(void); +extern void FUN_0200CAB4(u32 param0); +extern void FUN_0201C238(void); + +THUMB_FUNC void SetFontsPointer(const struct FontInfo *fonts) +{ + gFonts = fonts; +} + +THUMB_FUNC u8 FUN_0201BCC8(void *param0, u32 param1, u32 param2) +{ + u32 *r4 = UNK_021C5714; + s32 i; + for (i = 0; i < 8; i++, r4++) + { + if (r4[0] != 0) + { + continue; + } + UNK_021C5714[i] = FUN_0200CA7C(param0, param1, param2); + if (UNK_021C5714[i] != 0) + { + break; + } + i = 8; + break; + } + return (u8)i; +} + +THUMB_FUNC void FUN_0201BCFC(u32 param0) +{ + GF_ASSERT(param0 < 8); + GF_ASSERT(UNK_021C5714[param0] != 0); + if (param0 >= 8) + { + return; + } + if (UNK_021C5714[param0] == 0) + { + return; + } + void *r5 = FUN_0201B6C8(); + if (r5) + { + FUN_0201C238(); + FreeToHeap(r5); + } + FUN_0200CAB4(UNK_021C5714[param0]); + UNK_021C5714[param0] = 0; +} + +THUMB_FUNC BOOL FUN_0201BD44(u32 param0) +{ + return UNK_021C5714[param0] ? TRUE : FALSE; +} + +THUMB_FUNC void FUN_0201BD5C(void) +{ + for (s32 i = 0; i < 8; i++) + { + UNK_021C5714[i] = 0; + } +} + +THUMB_FUNC u8 FUN_0201BD70(u32 param0) +{ + return (u8)FUN_0201BD44(param0); +} + +THUMB_FUNC void FUN_0201BD7C(u32 param0) +{ + FUN_0201BCFC(param0); +} diff --git a/include/text.h b/include/text.h index 8b7fe896..fb31b86b 100644 --- a/include/text.h +++ b/include/text.h @@ -1,6 +1,60 @@ #ifndef POKEDIAMOND_TEXT_H #define POKEDIAMOND_TEXT_H -void GetSpeciesNameIntoArray(u16 species, u32 heap_id, u16 * dest); +#include "global.h" + +struct TextPrinterTemplate +{ + const u8* currentChar; + u8 windowId; + u8 fontId; + u8 x; + u8 y; + u8 currentX; // 0x8 + u8 currentY; + u8 letterSpacing; + u8 lineSpacing; + u8 unk:4; // 0xC + u8 fgColor:4; + u8 bgColor:4; + u8 shadowColor:4; +}; + +struct TextPrinter +{ + struct TextPrinterTemplate printerTemplate; + + void (*callback)(struct TextPrinterTemplate *, u16); // 0x10 + + u8 subStructFields[7]; // always cast to struct TextPrinterSubStruct... so why bother + u8 active; + u8 state; // 0x1C + u8 textSpeed; + u8 delayCounter; + u8 scrollDistance; + u8 minLetterSpacing; // 0x20 + u8 japanese; +}; + +struct FontInfo +{ + u16 (*fontFunction)(struct TextPrinter *x); + u8 maxLetterWidth; + u8 maxLetterHeight; + u8 letterSpacing; + u8 lineSpacing; + u8 unk:4; + u8 fgColor:4; + u8 bgColor:4; + u8 shadowColor:4; +}; + +void SetFontsPointer(const struct FontInfo *fonts); +u8 FUN_0201BCC8(void *param0, u32 param1, u32 param2); +void FUN_0201BCFC(u32 param0); +BOOL FUN_0201BD44(u32 param0); +void FUN_0201BD5C(void); +u8 FUN_0201BD70(u32 param0); +void FUN_0201BCFC(u32 param0); #endif //POKEDIAMOND_TEXT_H |