diff --git a/asm/non_matchings/code_80091750/get_ascii_char_width_index.s b/asm/non_matchings/code_80091750/char_to_glyph_index.s similarity index 99% rename from asm/non_matchings/code_80091750/get_ascii_char_width_index.s rename to asm/non_matchings/code_80091750/char_to_glyph_index.s index e90a538ae..3679708ab 100644 --- a/asm/non_matchings/code_80091750/get_ascii_char_width_index.s +++ b/asm/non_matchings/code_80091750/char_to_glyph_index.s @@ -1,5 +1,5 @@ /* Originally func_80092C90 */ -glabel get_ascii_char_width_index +glabel char_to_glyph_index /* 093890 80092C90 27BDFFE8 */ addiu $sp, $sp, -0x18 /* 093894 80092C94 AFBF0014 */ sw $ra, 0x14($sp) /* 093898 80092C98 80820000 */ lb $v0, ($a0) diff --git a/asm/non_matchings/code_80091750/print_text1.s b/asm/non_matchings/code_80091750/print_text1.s index 46babad6b..4ec911497 100644 --- a/asm/non_matchings/code_80091750/print_text1.s +++ b/asm/non_matchings/code_80091750/print_text1.s @@ -20,13 +20,13 @@ glabel print_text1 /* 093FD4 800933D4 00C08025 */ move $s0, $a2 /* 093FD8 800933D8 11C0002D */ beqz $t6, .L80093490 /* 093FDC 800933DC 00008825 */ move $s1, $zero -/* 093FE0 800933E0 3C16800F */ lui $s6, %hi(gCharacterWidthMap) # $s6, 0x800f -/* 093FE4 800933E4 26D6F690 */ addiu $s6, %lo(gCharacterWidthMap) # addiu $s6, $s6, -0x970 +/* 093FE0 800933E0 3C16800F */ lui $s6, %hi(gGlyphDisplayWidth) # $s6, 0x800f +/* 093FE4 800933E4 26D6F690 */ addiu $s6, %lo(gGlyphDisplayWidth) # addiu $s6, $s6, -0x970 /* 093FE8 800933E8 C7B60080 */ lwc1 $f22, 0x80($sp) /* 093FEC 800933EC 241EFFFF */ li $fp, -1 /* 093FF0 800933F0 2417FFFE */ li $s7, -2 .L800933F4: -/* 093FF4 800933F4 0C024B24 */ jal get_ascii_char_width_index +/* 093FF4 800933F4 0C024B24 */ jal char_to_glyph_index /* 093FF8 800933F8 02002025 */ move $a0, $s0 /* 093FFC 800933FC 0440000F */ bltz $v0, .L8009343C /* 094000 80093400 28410030 */ slti $at, $v0, 0x30 @@ -70,9 +70,9 @@ glabel print_text1 /* 09408C 8009348C 00000000 */ nop .L80093490: /* 094090 80093490 8FA20088 */ lw $v0, 0x88($sp) -/* 094094 80093494 3C16800F */ lui $s6, %hi(gCharacterWidthMap) # $s6, 0x800f +/* 094094 80093494 3C16800F */ lui $s6, %hi(gGlyphDisplayWidth) # $s6, 0x800f /* 094098 80093498 24010001 */ li $at, 1 -/* 09409C 8009349C 26D6F690 */ addiu $s6, %lo(gCharacterWidthMap) # addiu $s6, $s6, -0x970 +/* 09409C 8009349C 26D6F690 */ addiu $s6, %lo(gGlyphDisplayWidth) # addiu $s6, $s6, -0x970 /* 0940A0 800934A0 2417FFFE */ li $s7, -2 /* 0940A4 800934A4 241EFFFF */ li $fp, -1 /* 0940A8 800934A8 1041000A */ beq $v0, $at, .L800934D4 @@ -121,13 +121,13 @@ glabel print_text1 /* 094138 80093538 5120004A */ beql $t1, $zero, .L80093664 /* 09413C 8009353C 8E820000 */ lw $v0, ($s4) .L80093540: -/* 094140 80093540 0C024B24 */ jal get_ascii_char_width_index +/* 094140 80093540 0C024B24 */ jal char_to_glyph_index /* 094144 80093544 02402025 */ move $a0, $s2 /* 094148 80093548 04400027 */ bltz $v0, .L800935E8 /* 09414C 8009354C 00408825 */ move $s1, $v0 /* 094150 80093550 8FAC0074 */ lw $t4, 0x74($sp) -/* 094154 80093554 3C0B800E */ lui $t3, %hi(D_800E7E84) # $t3, 0x800e -/* 094158 80093558 256B7E84 */ addiu $t3, %lo(D_800E7E84) # addiu $t3, $t3, 0x7e84 +/* 094154 80093554 3C0B800E */ lui $t3, %hi(gGlyphTextureLUT) # $t3, 0x800e +/* 094158 80093558 256B7E84 */ addiu $t3, %lo(gGlyphTextureLUT) # addiu $t3, $t3, 0x7e84 /* 09415C 8009355C 448C3000 */ mtc1 $t4, $f6 /* 094160 80093560 00115080 */ sll $t2, $s1, 2 /* 094164 80093564 014B8021 */ addu $s0, $t2, $t3 diff --git a/data/data_0DD0A0_2.s b/data/data_0DD0A0_2.s index 59b7ec033..79b7edd25 100644 --- a/data/data_0DD0A0_2.s +++ b/data/data_0DD0A0_2.s @@ -2038,7 +2038,7 @@ glabel D_800E7E34 .word D_02001F24, D_02001F34, D_02001F44, D_02001F54 .word D_02001F64, D_02001F74, D_02001F84, D_02001F94 -glabel D_800E7E84 +glabel gGlyphTextureLUT .word D_0200211C, D_02002144, D_0200216C, D_02002194 .word D_020021BC, D_020021E4, D_0200220C, D_02002234 .word D_0200225C, D_02002284, D_020022AC, D_020022D4 diff --git a/data/data_0DD0A0_3.s b/data/data_0DD0A0_3.s index 0b7af68c6..bbfbc3027 100644 --- a/data/data_0DD0A0_3.s +++ b/data/data_0DD0A0_3.s @@ -3956,7 +3956,7 @@ glabel D_800EF680 .double 1.08 .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 #balign 64 instead ? -glabel gCharacterWidthMap +glabel gGlyphDisplayWidth .hword 0x000c, 0x000d, 0x000b, 0x000b, 0x000a, 0x000b, 0x000b, 0x000d .hword 0x0007, 0x000a, 0x000c, 0x000a, 0x0012, 0x000d, 0x000c, 0x000c .hword 0x000c, 0x000c, 0x000b, 0x000d, 0x000c, 0x000c, 0x0012, 0x000d diff --git a/src/code_80091750.c b/src/code_80091750.c index c866e748c..ecb7091df 100644 --- a/src/code_80091750.c +++ b/src/code_80091750.c @@ -828,7 +828,7 @@ void func_80092C80(void) { // to get a character's width in pixels // This technically matches, but due to linker alignment shenanigans actually // matching will have to wait -s32 get_ascii_char_width_index(char *character) { +s32 char_to_glyph_index(char *character) { s32 index = 1; // Uppercase Letters @@ -879,6 +879,7 @@ s32 get_ascii_char_width_index(char *character) { index = 0x1D; break; // $ + // Doesn't appear to have a texture? case 0x24: /* switch 2 */ index = 0x1E; break; @@ -899,6 +900,7 @@ s32 get_ascii_char_width_index(char *character) { index = 0x2C; break; // ( + // Displayed as "cc" case 0x28: /* switch 2 */ index = 0x2D; break; @@ -914,7 +916,7 @@ s32 get_ascii_char_width_index(char *character) { return index; } #else -GLOBAL_ASM("asm/non_matchings/code_80091750/get_ascii_char_width_index.s") +GLOBAL_ASM("asm/non_matchings/code_80091750/char_to_glyph_index.s") #endif s32 func_80092DF8(void) { @@ -1031,22 +1033,22 @@ s32 func_80092EE4(void *arg0) { GLOBAL_ASM("asm/non_matchings/code_80091750/func_80092EE4.s") #endif -extern s16 gCharacterWidthMap[]; // D_800EF690 +extern s16 gGlyphDisplayWidth[]; // D_800EF690 //Originally func_80093034 s32 get_string_width(char *buffer) { - s32 width_index; + s32 glyphIndex; s32 stringWidth = 0; if (*buffer != 0) { do { - width_index = get_ascii_char_width_index(buffer); - if (width_index >= 0) { - stringWidth += gCharacterWidthMap[width_index]; - } else if (width_index == -1) { + glyphIndex = char_to_glyph_index(buffer); + if (glyphIndex >= 0) { + stringWidth += gGlyphDisplayWidth[glyphIndex]; + } else if (glyphIndex == -1) { stringWidth += 7; } - if (width_index >= 0x30) { + if (glyphIndex >= 0x30) { buffer += 2; } else { buffer += 1; @@ -1075,31 +1077,31 @@ void print_text1(s32, s32, char*, s32, f32, f32, s32); void print_text2(s32, s32, char*, s32, f32, f32, s32); extern Gfx D_020077A8[]; extern Gfx D_020077D8[]; -extern s32 D_800E7E84[]; +extern s32 gGlyphTextureLUT[]; extern Gfx *gDisplayListHead; // "tracking" is a uniform spacing between all characters in a given word void print_text0(s32 column, s32 row, char *text, s32 tracking, f32 x_scale, f32 y_scale, s32 arg6) { s32 stringWidth = 0; - s32 characterWidthIndex; + s32 glyphIndex; gSPDisplayList(gDisplayListHead++, D_020077A8); if (*text != 0) { do{ - characterWidthIndex = get_ascii_char_width_index(text); - if (characterWidthIndex >= 0) { - func_80099184(segmented_to_virtual(D_800E7E84[characterWidthIndex])); - gDisplayListHead = func_8009BEF0(gDisplayListHead, segmented_to_virtual(D_800E7E84[characterWidthIndex]), column + (stringWidth * x_scale), row, arg6, x_scale, y_scale); - stringWidth += gCharacterWidthMap[characterWidthIndex] + tracking; + glyphIndex = char_to_glyph_index(text); + if (glyphIndex >= 0) { + func_80099184(segmented_to_virtual(gGlyphTextureLUT[glyphIndex])); + gDisplayListHead = func_8009BEF0(gDisplayListHead, segmented_to_virtual(gGlyphTextureLUT[glyphIndex]), column + (stringWidth * x_scale), row, arg6, x_scale, y_scale); + stringWidth += gGlyphDisplayWidth[glyphIndex] + tracking; } - else if ((characterWidthIndex != -2) && (characterWidthIndex == -1)) { + else if ((glyphIndex != -2) && (glyphIndex == -1)) { stringWidth += tracking + 7; } else{ gSPDisplayList(gDisplayListHead++, D_020077D8); return; } - if (characterWidthIndex >= 0x30) { + if (glyphIndex >= 0x30) { text += 2; } else { text += 1; @@ -1122,21 +1124,21 @@ void func_80093358(s32 column, s32 row, char *text, s32 tracking, f32 x_scale, f void print_text1(s32 column, s32 row, char *text, s32 tracking, f32 x_scale, f32 y_scale, s32 arg6) { char *temp_string = text; s32 stringWidth = 0; - s32 characterWidthIndex; + s32 glyphIndex; if (*temp_string != 0) { do{ - characterWidthIndex = get_ascii_char_width_index(temp_string); - if (characterWidthIndex >= 0) { - stringWidth += ((gCharacterWidthMap[characterWidthIndex] + tracking) * x_scale); + glyphIndex = char_to_glyph_index(temp_string); + if (glyphIndex >= 0) { + stringWidth += ((gGlyphDisplayWidth[glyphIndex] + tracking) * x_scale); } - else if ((characterWidthIndex != -2) && (characterWidthIndex == -1)) { + else if ((glyphIndex != -2) && (glyphIndex == -1)) { stringWidth += ((tracking + 7) * x_scale); } else{ return; } - if (characterWidthIndex >= 0x30) { + if (glyphIndex >= 0x30) { temp_string += 2; } else { temp_string += 1; @@ -1167,14 +1169,14 @@ void print_text1(s32 column, s32 row, char *text, s32 tracking, f32 x_scale, f32 gSPDisplayList(gDisplayListHead++, D_020077A8); if (*text != 0) { do{ - characterWidthIndex = get_ascii_char_width_index(text); - if (characterWidthIndex >= 0) { - func_80099184(segmented_to_virtual(D_800E7E84[characterWidthIndex])); - gDisplayListHead = func_8009BEF0(gDisplayListHead, segmented_to_virtual(D_800E7E84[characterWidthIndex]), column, row, arg6, x_scale, y_scale); - column += (gCharacterWidthMap[characterWidthIndex] + tracking); + glyphIndex = char_to_glyph_index(text); + if (glyphIndex >= 0) { + func_80099184(segmented_to_virtual(gGlyphTextureLUT[glyphIndex])); + gDisplayListHead = func_8009BEF0(gDisplayListHead, segmented_to_virtual(gGlyphTextureLUT[glyphIndex]), column, row, arg6, x_scale, y_scale); + column += (gGlyphDisplayWidth[glyphIndex] + tracking); column *= x_scale; } - else if ((characterWidthIndex != -2) && (characterWidthIndex == -1)) { + else if ((glyphIndex != -2) && (glyphIndex == -1)) { column += (tracking + 7); column *= x_scale; } @@ -1182,7 +1184,7 @@ void print_text1(s32 column, s32 row, char *text, s32 tracking, f32 x_scale, f32 gSPDisplayList(gDisplayListHead++, D_020077D8); return; } - if (characterWidthIndex >= 0x30) { + if (glyphIndex >= 0x30) { text += 2; } else { text += 1; @@ -1214,31 +1216,31 @@ void func_80093754(s32 column, s32 row, char *text, s32 tracking, f32 x_scale, f void print_text2(s32 column, s32 row, char *text, s32 tracking, f32 x_scale, f32 y_scale, s32 arg6) { s32 temp_v0_3; s32 characterWidth; - s32 characterWidthIndex; + s32 glyphIndex; gSPDisplayList(gDisplayListHead++, D_020077A8); if (*text != 0) { do { - characterWidthIndex = get_ascii_char_width_index(text); - if (characterWidthIndex >= 0) { - temp_v0_3 = segmented_to_virtual(D_800E7E84[characterWidthIndex]); + glyphIndex = char_to_glyph_index(text); + if (glyphIndex >= 0) { + temp_v0_3 = segmented_to_virtual(gGlyphTextureLUT[glyphIndex]); func_80099184(temp_v0_3); - gDisplayListHead = func_8009BEF0(gDisplayListHead, temp_v0_3, column - (gCharacterWidthMap[characterWidthIndex] / 2), row, arg6, x_scale, y_scale); - if ((characterWidthIndex >= 0xD5) && (characterWidthIndex < 0xE0)) { + gDisplayListHead = func_8009BEF0(gDisplayListHead, temp_v0_3, column - (gGlyphDisplayWidth[glyphIndex] / 2), row, arg6, x_scale, y_scale); + if ((glyphIndex >= 0xD5) && (glyphIndex < 0xE0)) { characterWidth = 0x20; } else { characterWidth = 0xC; } column = column + (s32)((characterWidth + tracking) * x_scale); } - else if ((characterWidthIndex != -2) && (characterWidthIndex == -1)) { + else if ((glyphIndex != -2) && (glyphIndex == -1)) { column = column + (s32)((tracking + 7) * x_scale); } else{ gSPDisplayList(gDisplayListHead++, D_020077D8); return; } - if (characterWidthIndex >= 0x30) { + if (glyphIndex >= 0x30) { text += 2; } else { text += 1;