summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorred031000 <rubenru09@aol.com>2021-03-12 17:21:48 +0000
committerred031000 <rubenru09@aol.com>2021-03-12 17:21:48 +0000
commit63bcf753d4d57c1585140c7b3eec1aace1e89caf (patch)
tree8ea023c7915ca395fb5b22b082b058404506c3be
parentfd3ac04d131ba3237c90695b2a59f11959af75ce (diff)
GenerateFontHalfRowLookupTable nonmatching
-rw-r--r--arm9/asm/nonmatchings/GenerateFontHalfRowLookupTable.s93
-rw-r--r--arm9/asm/unk_0201BCBC.s101
-rw-r--r--arm9/src/text.c260
-rw-r--r--arm9/temp.c0
-rw-r--r--include/text.h4
-rw-r--r--tools/asm_processor/.gitattributes1
-rw-r--r--tools/asm_processor/compile.sh38
7 files changed, 371 insertions, 126 deletions
diff --git a/arm9/asm/nonmatchings/GenerateFontHalfRowLookupTable.s b/arm9/asm/nonmatchings/GenerateFontHalfRowLookupTable.s
new file mode 100644
index 00000000..2d51a2ae
--- /dev/null
+++ b/arm9/asm/nonmatchings/GenerateFontHalfRowLookupTable.s
@@ -0,0 +1,93 @@
+ .include "asm/macros.inc"
+ .include "global.inc"
+
+ .extern UNK_021C570C
+ .extern UNK_021C5734
+
+ thumb_func_start GenerateFontHalfRowLookupTable
+GenerateFontHalfRowLookupTable: ; 0x0201C05C
+ push {r3-r7, lr}
+ sub sp, #0x30
+ ldr r3, _0201C0F8 ; =UNK_021C570C
+ mov r5, #0x0
+ str r5, [sp, #0x20]
+ str r0, [sp, #0x24]
+ str r2, [sp, #0x28]
+ str r1, [sp, #0x2c]
+ strh r1, [r3, #0x6]
+ strh r0, [r3, #0x2]
+ add r0, sp, #0x20
+ strh r2, [r3, #0x4]
+ str r5, [sp, #0x14]
+ str r0, [sp, #0x8]
+ mov r12, r0
+ mov lr, r0
+ str r0, [sp, #0x18]
+_0201C07E:
+ mov r0, #0x0
+ str r0, [sp, #0x10]
+ ldr r0, [sp, #0x18]
+ str r0, [sp, #0x4]
+ ldr r0, [sp, #0x8]
+ ldr r0, [r0, #0x0]
+ str r0, [sp, #0x1c]
+_0201C08C:
+ mov r0, #0x0
+ str r0, [sp, #0xc]
+ mov r0, lr
+ str r0, [sp, #0x0]
+ ldr r0, [sp, #0x4]
+ ldr r0, [r0, #0x0]
+ lsl r7, r0, #0x4
+_0201C09A:
+ ldr r0, [sp, #0x0]
+ mov r3, #0x0
+ ldr r0, [r0, #0x0]
+ mov r4, r12
+ lsl r6, r0, #0x8
+_0201C0A4:
+ ldr r0, [r4, #0x0]
+ add r1, r7, #0x0
+ lsl r0, r0, #0xc
+ orr r0, r6
+ orr r1, r0
+ ldr r0, [sp, #0x1c]
+ add r3, r3, #0x1
+ add r2, r0, #0x0
+ orr r2, r1
+ lsl r1, r5, #0x1
+ ldr r0, _0201C0FC ; =UNK_021C5734
+ add r5, r5, #0x1
+ add r4, r4, #0x4
+ strh r2, [r0, r1]
+ cmp r3, #0x4
+ blt _0201C0A4
+ ldr r0, [sp, #0x0]
+ add r0, r0, #0x4
+ str r0, [sp, #0x0]
+ ldr r0, [sp, #0xc]
+ add r0, r0, #0x1
+ str r0, [sp, #0xc]
+ cmp r0, #0x4
+ blt _0201C09A
+ ldr r0, [sp, #0x4]
+ add r0, r0, #0x4
+ str r0, [sp, #0x4]
+ ldr r0, [sp, #0x10]
+ add r0, r0, #0x1
+ str r0, [sp, #0x10]
+ cmp r0, #0x4
+ blt _0201C08C
+ ldr r0, [sp, #0x8]
+ add r0, r0, #0x4
+ str r0, [sp, #0x8]
+ ldr r0, [sp, #0x14]
+ add r0, r0, #0x1
+ str r0, [sp, #0x14]
+ cmp r0, #0x4
+ blt _0201C07E
+ add sp, #0x30
+ pop {r3-r7, pc}
+ .balign 4
+_0201C0F8: .word UNK_021C570C
+_0201C0FC: .word UNK_021C5734
diff --git a/arm9/asm/unk_0201BCBC.s b/arm9/asm/unk_0201BCBC.s
index 5fd08f38..65282b4a 100644
--- a/arm9/asm/unk_0201BCBC.s
+++ b/arm9/asm/unk_0201BCBC.s
@@ -11,107 +11,6 @@
.text
- thumb_func_start RenderFont
-RenderFont: ; 0x0201C048
- push {r4, lr}
- add r4, r0, #0x0
-_0201C04C:
- ldrb r0, [r4, #0x9]
- add r1, r4, #0x0
- bl FontFunc
- cmp r0, #0x2
- beq _0201C04C
- pop {r4, pc}
- .balign 4
-
- thumb_func_start GenerateFontHalfRowLookupTable
-GenerateFontHalfRowLookupTable: ; 0x0201C05C
- push {r3-r7, lr}
- sub sp, #0x30
- ldr r3, _0201C0F8 ; =UNK_021C570C
- mov r5, #0x0
- str r5, [sp, #0x20]
- str r0, [sp, #0x24]
- str r2, [sp, #0x28]
- str r1, [sp, #0x2c]
- strh r1, [r3, #0x6]
- strh r0, [r3, #0x2]
- add r0, sp, #0x20
- strh r2, [r3, #0x4]
- str r5, [sp, #0x14]
- str r0, [sp, #0x8]
- mov r12, r0
- mov lr, r0
- str r0, [sp, #0x18]
-_0201C07E:
- mov r0, #0x0
- str r0, [sp, #0x10]
- ldr r0, [sp, #0x18]
- str r0, [sp, #0x4]
- ldr r0, [sp, #0x8]
- ldr r0, [r0, #0x0]
- str r0, [sp, #0x1c]
-_0201C08C:
- mov r0, #0x0
- str r0, [sp, #0xc]
- mov r0, lr
- str r0, [sp, #0x0]
- ldr r0, [sp, #0x4]
- ldr r0, [r0, #0x0]
- lsl r7, r0, #0x4
-_0201C09A:
- ldr r0, [sp, #0x0]
- mov r3, #0x0
- ldr r0, [r0, #0x0]
- mov r4, r12
- lsl r6, r0, #0x8
-_0201C0A4:
- ldr r0, [r4, #0x0]
- add r1, r7, #0x0
- lsl r0, r0, #0xc
- orr r0, r6
- orr r1, r0
- ldr r0, [sp, #0x1c]
- add r3, r3, #0x1
- add r2, r0, #0x0
- orr r2, r1
- lsl r1, r5, #0x1
- ldr r0, _0201C0FC ; =UNK_021C5734
- add r5, r5, #0x1
- add r4, r4, #0x4
- strh r2, [r0, r1]
- cmp r3, #0x4
- blt _0201C0A4
- ldr r0, [sp, #0x0]
- add r0, r0, #0x4
- str r0, [sp, #0x0]
- ldr r0, [sp, #0xc]
- add r0, r0, #0x1
- str r0, [sp, #0xc]
- cmp r0, #0x4
- blt _0201C09A
- ldr r0, [sp, #0x4]
- add r0, r0, #0x4
- str r0, [sp, #0x4]
- ldr r0, [sp, #0x10]
- add r0, r0, #0x1
- str r0, [sp, #0x10]
- cmp r0, #0x4
- blt _0201C08C
- ldr r0, [sp, #0x8]
- add r0, r0, #0x4
- str r0, [sp, #0x8]
- ldr r0, [sp, #0x14]
- add r0, r0, #0x1
- str r0, [sp, #0x14]
- cmp r0, #0x4
- blt _0201C07E
- add sp, #0x30
- pop {r3-r7, pc}
- .balign 4
-_0201C0F8: .word UNK_021C570C
-_0201C0FC: .word UNK_021C5734
-
thumb_func_start FUN_0201C100
FUN_0201C100: ; 0x0201C100
ldrh r2, [r0, #0x0]
diff --git a/arm9/src/text.c b/arm9/src/text.c
index 04f443e9..8ec3efe8 100644
--- a/arm9/src/text.c
+++ b/arm9/src/text.c
@@ -8,23 +8,23 @@ u8 UNK_021C5734[0x200];
u32 UNK_021C5714[8];
u8 UNK_021C570C[8];
-extern u32 FUN_0200CA7C(void *func, struct TextPrinter *printer, u32 param2);
+extern u32 FUN_0200CA7C(void (*func)(u32, struct TextPrinter *), struct TextPrinter *printer, u32 param2);
extern struct TextPrinter *FUN_0201B6C8(void);
extern void FUN_0200CAB4(u32 param0);
extern void FUN_0201C238(struct TextPrinter *printer);
-extern u32 RenderFont(struct TextPrinter *printer);
extern void FUN_0201C1A8(struct TextPrinter *printer);
-extern void GenerateFontHalfRowLookupTable(u8 fgColor, u8 bgColor, u8 shadowColor);
extern void CopyWindowToVram(u32 windowId);
+extern u32 FontFunc(u8 fontId, struct TextPrinter *printer);
+
THUMB_FUNC void SetFontsPointer(const struct FontInfo *fonts)
{
gFonts = fonts;
}
-THUMB_FUNC u8 FUN_0201BCC8(void *func, struct TextPrinter *printer, u32 param2)
+THUMB_FUNC u8 FUN_0201BCC8(void (*func)(u32, struct TextPrinter *), struct TextPrinter *printer, u32 param2)
{
u32 *r4 = UNK_021C5714;
s32 i;
@@ -233,7 +233,7 @@ THUMB_FUNC void RunTextPrinter(u32 param0, struct TextPrinter *printer)
{
return;
}
- printer->Unk29 = printer->callback(&printer->printerTemplate, printer->Unk2A); //TODO check
+ printer->Unk29 = printer->callback(&printer->printerTemplate, printer->Unk2A);
return;
case 1:
FUN_0201BCFC(printer->minLetterSpacing);
@@ -248,3 +248,253 @@ THUMB_FUNC void RunTextPrinter(u32 param0, struct TextPrinter *printer)
}
}
}
+
+THUMB_FUNC u32 RenderFont(struct TextPrinter *printer)
+{
+ u32 ret;
+ while (TRUE)
+ {
+ ret = FontFunc(printer->printerTemplate.fontId, printer);
+ if (ret != 2)
+ {
+ return ret;
+ }
+ }
+}
+
+#ifdef NONMATCHING
+THUMB_FUNC void GenerateFontHalfRowLookupTable(u8 fgColor, u8 bgColor, u8 shadowColor)
+{
+ u32 fg12, bg12, shadow12;
+ u32 temp;
+
+ u16 *current = UNK_021C570C;
+
+ bg12 = bgColor << 12;
+ fg12 = fgColor << 12;
+ shadow12 = shadowColor << 12;
+
+ temp = (bgColor << 8) | (bgColor << 4) | bgColor;
+ *(current++) = (bg12) | temp;
+ *(current++) = (fg12) | temp;
+ *(current++) = (shadow12) | temp;
+
+ temp = (fgColor << 8) | (bgColor << 4) | bgColor;
+ *(current++) = (bg12) | temp;
+ *(current++) = (fg12) | temp;
+ *(current++) = (shadow12) | temp;
+
+ temp = (shadowColor << 8) | (bgColor << 4) | bgColor;
+ *(current++) = (bg12) | temp;
+ *(current++) = (fg12) | temp;
+ *(current++) = (shadow12) | temp;
+
+ temp = (bgColor << 8) | (fgColor << 4) | bgColor;
+ *(current++) = (bg12) | temp;
+ *(current++) = (fg12) | temp;
+ *(current++) = (shadow12) | temp;
+
+ temp = (fgColor << 8) | (fgColor << 4) | bgColor;
+ *(current++) = (bg12) | temp;
+ *(current++) = (fg12) | temp;
+ *(current++) = (shadow12) | temp;
+
+ temp = (shadowColor << 8) | (fgColor << 4) | bgColor;
+ *(current++) = (bg12) | temp;
+ *(current++) = (fg12) | temp;
+ *(current++) = (shadow12) | temp;
+
+ temp = (bgColor << 8) | (shadowColor << 4) | bgColor;
+ *(current++) = (bg12) | temp;
+ *(current++) = (fg12) | temp;
+ *(current++) = (shadow12) | temp;
+
+ temp = (fgColor << 8) | (shadowColor << 4) | bgColor;
+ *(current++) = (bg12) | temp;
+ *(current++) = (fg12) | temp;
+ *(current++) = (shadow12) | temp;
+
+ temp = (shadowColor << 8) | (shadowColor << 4) | bgColor;
+ *(current++) = (bg12) | temp;
+ *(current++) = (fg12) | temp;
+ *(current++) = (shadow12) | temp;
+
+ temp = (bgColor << 8) | (bgColor << 4) | fgColor;
+ *(current++) = (bg12) | temp;
+ *(current++) = (fg12) | temp;
+ *(current++) = (shadow12) | temp;
+
+ temp = (fgColor << 8) | (bgColor << 4) | fgColor;
+ *(current++) = (bg12) | temp;
+ *(current++) = (fg12) | temp;
+ *(current++) = (shadow12) | temp;
+
+ temp = (shadowColor << 8) | (bgColor << 4) | fgColor;
+ *(current++) = (bg12) | temp;
+ *(current++) = (fg12) | temp;
+ *(current++) = (shadow12) | temp;
+
+ temp = (bgColor << 8) | (fgColor << 4) | fgColor;
+ *(current++) = (bg12) | temp;
+ *(current++) = (fg12) | temp;
+ *(current++) = (shadow12) | temp;
+
+ temp = (fgColor << 8) | (fgColor << 4) | fgColor;
+ *(current++) = (bg12) | temp;
+ *(current++) = (fg12) | temp;
+ *(current++) = (shadow12) | temp;
+
+ temp = (shadowColor << 8) | (fgColor << 4) | fgColor;
+ *(current++) = (bg12) | temp;
+ *(current++) = (fg12) | temp;
+ *(current++) = (shadow12) | temp;
+
+ temp = (bgColor << 8) | (shadowColor << 4) | fgColor;
+ *(current++) = (bg12) | temp;
+ *(current++) = (fg12) | temp;
+ *(current++) = (shadow12) | temp;
+
+ temp = (fgColor << 8) | (shadowColor << 4) | fgColor;
+ *(current++) = (bg12) | temp;
+ *(current++) = (fg12) | temp;
+ *(current++) = (shadow12) | temp;
+
+ temp = (shadowColor << 8) | (shadowColor << 4) | fgColor;
+ *(current++) = (bg12) | temp;
+ *(current++) = (fg12) | temp;
+ *(current++) = (shadow12) | temp;
+
+ temp = (bgColor << 8) | (bgColor << 4) | shadowColor;
+ *(current++) = (bg12) | temp;
+ *(current++) = (fg12) | temp;
+ *(current++) = (shadow12) | temp;
+
+ temp = (fgColor << 8) | (bgColor << 4) | shadowColor;
+ *(current++) = (bg12) | temp;
+ *(current++) = (fg12) | temp;
+ *(current++) = (shadow12) | temp;
+
+ temp = (shadowColor << 8) | (bgColor << 4) | shadowColor;
+ *(current++) = (bg12) | temp;
+ *(current++) = (fg12) | temp;
+ *(current++) = (shadow12) | temp;
+
+ temp = (bgColor << 8) | (fgColor << 4) | shadowColor;
+ *(current++) = (bg12) | temp;
+ *(current++) = (fg12) | temp;
+ *(current++) = (shadow12) | temp;
+
+ temp = (fgColor << 8) | (fgColor << 4) | shadowColor;
+ *(current++) = (bg12) | temp;
+ *(current++) = (fg12) | temp;
+ *(current++) = (shadow12) | temp;
+
+ temp = (shadowColor << 8) | (fgColor << 4) | shadowColor;
+ *(current++) = (bg12) | temp;
+ *(current++) = (fg12) | temp;
+ *(current++) = (shadow12) | temp;
+
+ temp = (bgColor << 8) | (shadowColor << 4) | shadowColor;
+ *(current++) = (bg12) | temp;
+ *(current++) = (fg12) | temp;
+ *(current++) = (shadow12) | temp;
+
+ temp = (fgColor << 8) | (shadowColor << 4) | shadowColor;
+ *(current++) = (bg12) | temp;
+ *(current++) = (fg12) | temp;
+ *(current++) = (shadow12) | temp;
+
+ temp = (shadowColor << 8) | (shadowColor << 4) | shadowColor;
+ *(current++) = (bg12) | temp;
+ *(current++) = (fg12) | temp;
+ *(current++) = (shadow12) | temp;
+}
+#else
+THUMB_FUNC void GenerateFontHalfRowLookupTable(u8 fgColor, u8 bgColor, u8 shadowColor) //TODO use asm preprocessor
+{
+ asm {
+ // push {r3-r7, lr}
+ sub sp, #0x30
+ ldr r3, =UNK_021C570C
+ mov r5, #0x0
+ str r5, [sp, #0x20]
+ str r0, [sp, #0x24]
+ str r2, [sp, #0x28]
+ str r1, [sp, #0x2c]
+ strh r1, [r3, #0x6]
+ strh r0, [r3, #0x2]
+ add r0, sp, #0x20
+ strh r2, [r3, #0x4]
+ str r5, [sp, #0x14]
+ str r0, [sp, #0x8]
+ mov r12, r0
+ mov lr, r0
+ str r0, [sp, #0x18]
+ _0201C07E:
+ mov r0, #0x0
+ str r0, [sp, #0x10]
+ ldr r0, [sp, #0x18]
+ str r0, [sp, #0x4]
+ ldr r0, [sp, #0x8]
+ ldr r0, [r0, #0x0]
+ str r0, [sp, #0x1c]
+ _0201C08C:
+ mov r0, #0x0
+ str r0, [sp, #0xc]
+ mov r0, lr
+ str r0, [sp, #0x0]
+ ldr r0, [sp, #0x4]
+ ldr r0, [r0, #0x0]
+ lsl r7, r0, #0x4
+ _0201C09A:
+ ldr r0, [sp, #0x0]
+ mov r3, #0x0
+ ldr r0, [r0, #0x0]
+ mov r4, r12
+ lsl r6, r0, #0x8
+ _0201C0A4:
+ ldr r0, [r4, #0x0]
+ add r1, r7, #0x0
+ lsl r0, r0, #0xc
+ orr r0, r6
+ orr r1, r0
+ ldr r0, [sp, #0x1c]
+ add r3, r3, #0x1
+ add r2, r0, #0x0
+ orr r2, r1
+ lsl r1, r5, #0x1
+ ldr r0, =UNK_021C5734
+ add r5, r5, #0x1
+ add r4, r4, #0x4
+ strh r2, [r0, r1]
+ cmp r3, #0x4
+ blt _0201C0A4
+ ldr r0, [sp, #0x0]
+ add r0, r0, #0x4
+ str r0, [sp, #0x0]
+ ldr r0, [sp, #0xc]
+ add r0, r0, #0x1
+ str r0, [sp, #0xc]
+ cmp r0, #0x4
+ blt _0201C09A
+ ldr r0, [sp, #0x4]
+ add r0, r0, #0x4
+ str r0, [sp, #0x4]
+ ldr r0, [sp, #0x10]
+ add r0, r0, #0x1
+ str r0, [sp, #0x10]
+ cmp r0, #0x4
+ blt _0201C08C
+ ldr r0, [sp, #0x8]
+ add r0, r0, #0x4
+ str r0, [sp, #0x8]
+ ldr r0, [sp, #0x14]
+ add r0, r0, #0x1
+ str r0, [sp, #0x14]
+ cmp r0, #0x4
+ blt _0201C07E
+ add sp, #0x30
+ // pop {r3-r7, pc}
+ }
+}
+#endif
diff --git a/arm9/temp.c b/arm9/temp.c
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/arm9/temp.c
diff --git a/include/text.h b/include/text.h
index 06b7f52a..48c3cbf4 100644
--- a/include/text.h
+++ b/include/text.h
@@ -56,7 +56,7 @@ struct FontInfo
};
void SetFontsPointer(const struct FontInfo *fonts);
-u8 FUN_0201BCC8(void *func, struct TextPrinter *printer, u32 param2);
+u8 FUN_0201BCC8(void (*func)(u32, struct TextPrinter *), struct TextPrinter *printer, u32 param2);
void FUN_0201BCFC(u32 param0);
BOOL FUN_0201BD44(u32 param0);
void FUN_0201BD5C(void);
@@ -67,5 +67,7 @@ u16 AddTextPrinterParameterized2(u32 windowId, u8 fontId, const u16 *str, u32 x,
u16 AddTextPrinterParameterized3(u32 windowId, u8 fontId, const u16 *str, u32 x, u32 y, u32 speed, u32 colors, u32 letterSpacing, u32 lineSpacing, u8 (*callback)(struct TextPrinterTemplate *, u16));
u16 AddTextPrinter(struct TextPrinterTemplate *printerTemplate, u32 speed, u8 (*callback)(struct TextPrinterTemplate *, u16));
void RunTextPrinter(u32 param0, struct TextPrinter *printer);
+u32 RenderFont(struct TextPrinter *printer);
+void GenerateFontHalfRowLookupTable(u8 fgColor, u8 bgColor, u8 shadowColor);
#endif //POKEDIAMOND_TEXT_H
diff --git a/tools/asm_processor/.gitattributes b/tools/asm_processor/.gitattributes
new file mode 100644
index 00000000..75c2cbe5
--- /dev/null
+++ b/tools/asm_processor/.gitattributes
@@ -0,0 +1 @@
+compile.sh text eol=lf
diff --git a/tools/asm_processor/compile.sh b/tools/asm_processor/compile.sh
index 7d950644..786da404 100644
--- a/tools/asm_processor/compile.sh
+++ b/tools/asm_processor/compile.sh
@@ -1,19 +1,19 @@
-#!/bin/bash
-
-CC="$1"
-shift
-AS="$1"
-shift
-
-temp="$(mktemp)"
-../tools/asm_processor/asm_processor.py "$2" --assembler "$AS" > "$temp.c" &&
-$CC -c "$temp.c" -o "$1"
-
-prelude=$(mktemp prelude.XXXXXX)
-cat ../include/macros.inc >> "$prelude"
-cat global.inc >> "$prelude"
-
-../tools/asm_processor/asm_processor.py "$2" --post-process "$1" --assembler "$AS" --asm-prelude "$prelude"
-$DEVKITARM/bin/arm-none-eabi-objcopy --remove-section .comment "$1" "$1"
-rm "$prelude"
-rm "$temp"
+#!/bin/bash
+
+CC="$1"
+shift
+AS="$1"
+shift
+
+temp="$(mktemp)"
+../tools/asm_processor/asm_processor.py "$2" --assembler "$AS" > "$temp.c" &&
+$CC -c "$temp.c" -o "$1"
+
+prelude=$(mktemp prelude.XXXXXX)
+cat ../include/macros.inc >> "$prelude"
+cat global.inc >> "$prelude"
+
+../tools/asm_processor/asm_processor.py "$2" --post-process "$1" --assembler "$AS" --asm-prelude "$prelude"
+arm-none-eabi-objcopy --remove-section .comment "$1" "$1"
+rm "$prelude"
+rm "$temp"