diff options
Diffstat (limited to 'gflib/text.c')
-rw-r--r-- | gflib/text.c | 235 |
1 files changed, 117 insertions, 118 deletions
diff --git a/gflib/text.c b/gflib/text.c index ffce2cb56..e456a695d 100644 --- a/gflib/text.c +++ b/gflib/text.c @@ -21,8 +21,8 @@ static u16 gLastTextFgColor; static u16 gLastTextShadowColor; const struct FontInfo *gFonts; -u8 gUnknown_03002F84; -struct Struct_03002F90 gUnknown_03002F90; +u8 gDisableTextPrinters; +struct TextGlyph gCurGlyph; TextFlags gTextFlags; const u8 gFontHalfRowOffsets[] = @@ -204,7 +204,7 @@ bool16 AddTextPrinter(struct TextPrinterTemplate *printerTemplate, u8 speed, voi CopyWindowToVram(gTempTextPrinter.printerTemplate.windowId, 2); gTextPrinters[printerTemplate->windowId].active = 0; } - gUnknown_03002F84 = 0; + gDisableTextPrinters = 0; return TRUE; } @@ -212,7 +212,7 @@ void RunTextPrinters(void) { int i; - if (gUnknown_03002F84 == 0) + if (gDisableTextPrinters == 0) { for (i = 0; i < NUM_TEXT_PRINTERS; ++i) { @@ -461,9 +461,9 @@ u8 GetLastTextColor(u8 colorType) } } -inline static void GLYPH_COPY(u8 *windowTiles, u32 widthOffset, u32 j, u32 i, u32 *ptr, s32 width, s32 height) +inline static void GLYPH_COPY(u8 *windowTiles, u32 widthOffset, u32 j, u32 i, u32 *glyphPixels, s32 width, s32 height) { - u32 xAdd, yAdd, r5, bits, toOrr, dummyX; + u32 xAdd, yAdd, pixelData, bits, toOrr, dummyX; u8 *dst; xAdd = j + width; @@ -471,69 +471,69 @@ inline static void GLYPH_COPY(u8 *windowTiles, u32 widthOffset, u32 j, u32 i, u3 dummyX = j; for (; i < yAdd; i++) { - r5 = *ptr++; + pixelData = *glyphPixels++; for (j = dummyX; j < xAdd; j++) { - if ((toOrr = r5 & 0xF)) + if ((toOrr = pixelData & 0xF)) { dst = windowTiles + ((j / 8) * 32) + ((j % 8) / 2) + ((i / 8) * widthOffset) + ((i % 8) * 4); bits = ((j & 1) * 4); *dst = (toOrr << bits) | (*dst & (0xF0 >> bits)); } - r5 >>= 4; + pixelData >>= 4; } } } void CopyGlyphToWindow(struct TextPrinter *textPrinter) { - struct Window *win; - struct WindowTemplate *winTempl; - u32 *unkStruct; + struct Window *window; + struct WindowTemplate *template; + u32 *glyphPixels; u32 currX, currY, widthOffset; - s32 r4, r0; + s32 glyphWidth, glyphHeight; u8 *windowTiles; - win = &gWindows[textPrinter->printerTemplate.windowId]; - winTempl = &win->window; + window = &gWindows[textPrinter->printerTemplate.windowId]; + template = &window->window; - if ((r4 = (winTempl->width * 8) - textPrinter->printerTemplate.currentX) > gUnknown_03002F90.width) - r4 = gUnknown_03002F90.width; + if ((glyphWidth = (template->width * 8) - textPrinter->printerTemplate.currentX) > gCurGlyph.width) + glyphWidth = gCurGlyph.width; - if ((r0 = (winTempl->height * 8) - textPrinter->printerTemplate.currentY) > gUnknown_03002F90.height) - r0 = gUnknown_03002F90.height; + if ((glyphHeight = (template->height * 8) - textPrinter->printerTemplate.currentY) > gCurGlyph.height) + glyphHeight = gCurGlyph.height; currX = textPrinter->printerTemplate.currentX; currY = textPrinter->printerTemplate.currentY; - unkStruct = (u32 *)&gUnknown_03002F90.unk0; - windowTiles = win->tileData; - widthOffset = winTempl->width * 32; + glyphPixels = gCurGlyph.gfxBufferTop; + windowTiles = window->tileData; + widthOffset = template->width * 32; - if (r4 < 9) + if (glyphWidth < 9) { - if (r0 < 9) + if (glyphHeight < 9) { - GLYPH_COPY(windowTiles, widthOffset, currX, currY, unkStruct, r4, r0); + GLYPH_COPY(windowTiles, widthOffset, currX, currY, glyphPixels, glyphWidth, glyphHeight); } else { - GLYPH_COPY(windowTiles, widthOffset, currX, currY, unkStruct, r4, 8); - GLYPH_COPY(windowTiles, widthOffset, currX, currY + 8, unkStruct + 16, r4, r0 - 8); + GLYPH_COPY(windowTiles, widthOffset, currX, currY, glyphPixels, glyphWidth, 8); + GLYPH_COPY(windowTiles, widthOffset, currX, currY + 8, glyphPixels + 16, glyphWidth, glyphHeight - 8); } } else { - if (r0 < 9) + if (glyphHeight < 9) { - GLYPH_COPY(windowTiles, widthOffset, currX, currY, unkStruct, 8, r0); - GLYPH_COPY(windowTiles, widthOffset, currX + 8, currY, unkStruct + 8, r4 - 8, r0); + GLYPH_COPY(windowTiles, widthOffset, currX, currY, glyphPixels, 8, glyphHeight); + GLYPH_COPY(windowTiles, widthOffset, currX + 8, currY, glyphPixels + 8, glyphWidth - 8, glyphHeight); } else { - GLYPH_COPY(windowTiles, widthOffset, currX, currY, unkStruct, 8, 8); - GLYPH_COPY(windowTiles, widthOffset, currX + 8, currY, unkStruct + 8, r4 - 8, 8); - GLYPH_COPY(windowTiles, widthOffset, currX, currY + 8, unkStruct + 16, 8, r0 - 8); - GLYPH_COPY(windowTiles, widthOffset, currX + 8, currY + 8, unkStruct + 24, r4 - 8, r0 - 8); + GLYPH_COPY(windowTiles, widthOffset, currX, currY, glyphPixels, 8, 8); + GLYPH_COPY(windowTiles, widthOffset, currX + 8, currY, glyphPixels + 8, glyphWidth - 8, 8); + GLYPH_COPY(windowTiles, widthOffset, currX, currY + 8, glyphPixels + 16, 8, glyphHeight - 8); + GLYPH_COPY(windowTiles, widthOffset, currX + 8, currY + 8, glyphPixels + 24, glyphWidth - 8, glyphHeight - 8); } } } @@ -542,7 +542,7 @@ void ClearTextSpan(struct TextPrinter *textPrinter, u32 width) { struct Window *window; struct Bitmap pixels_data; - struct Struct_03002F90 *gUnk; + struct TextGlyph *glyph; u8* glyphHeight; if (gLastTextBgColor != 0) @@ -552,8 +552,8 @@ void ClearTextSpan(struct TextPrinter *textPrinter, u32 width) pixels_data.width = window->window.width << 3; pixels_data.height = window->window.height << 3; - gUnk = &gUnknown_03002F90; - glyphHeight = &gUnk->height; + glyph = &gCurGlyph; + glyphHeight = &glyph->height; FillBitmapRect4Bit( &pixels_data, @@ -1015,8 +1015,8 @@ u16 RenderText(struct TextPrinter *textPrinter) break; case CHAR_KEYPAD_ICON: currChar = *textPrinter->printerTemplate.currentChar++; - gUnknown_03002F90.width = DrawKeypadIcon(textPrinter->printerTemplate.windowId, currChar, textPrinter->printerTemplate.currentX, textPrinter->printerTemplate.currentY); - textPrinter->printerTemplate.currentX += gUnknown_03002F90.width + textPrinter->printerTemplate.letterSpacing; + gCurGlyph.width = DrawKeypadIcon(textPrinter->printerTemplate.windowId, currChar, textPrinter->printerTemplate.currentX, textPrinter->printerTemplate.currentY); + textPrinter->printerTemplate.currentX += gCurGlyph.width + textPrinter->printerTemplate.letterSpacing; return 0; case EOS: return 1; @@ -1050,8 +1050,8 @@ u16 RenderText(struct TextPrinter *textPrinter) if (textPrinter->minLetterSpacing) { - textPrinter->printerTemplate.currentX += gUnknown_03002F90.width; - width = textPrinter->minLetterSpacing - gUnknown_03002F90.width; + textPrinter->printerTemplate.currentX += gCurGlyph.width; + width = textPrinter->minLetterSpacing - gCurGlyph.width; if (width > 0) { ClearTextSpan(textPrinter, width); @@ -1061,9 +1061,9 @@ u16 RenderText(struct TextPrinter *textPrinter) else { if (textPrinter->japanese) - textPrinter->printerTemplate.currentX += (gUnknown_03002F90.width + textPrinter->printerTemplate.letterSpacing); + textPrinter->printerTemplate.currentX += (gCurGlyph.width + textPrinter->printerTemplate.letterSpacing); else - textPrinter->printerTemplate.currentX += gUnknown_03002F90.width; + textPrinter->printerTemplate.currentX += gCurGlyph.width; } return 0; case 1: @@ -1398,8 +1398,7 @@ s32 GetStringWidth(u8 fontId, const u8 *str, s16 letterSpacing) if (lineWidth > width) return lineWidth; - else - return width; + return width; } u8 RenderTextFont9(u8 *pixels, u8 fontId, u8 *str) @@ -1499,8 +1498,8 @@ u8 RenderTextFont9(u8 *pixels, u8 fontId, u8 *str) DecompressGlyphFont1(temp, 1); break; } - CpuCopy32(gUnknown_03002F90.unk0, pixels, 0x20); - CpuCopy32(gUnknown_03002F90.unk40, pixels + 0x20, 0x20); + CpuCopy32(gCurGlyph.gfxBufferTop, pixels, 0x20); + CpuCopy32(gCurGlyph.gfxBufferBottom, pixels + 0x20, 0x20); pixels += 0x40; break; } @@ -1592,30 +1591,30 @@ void DecompressGlyphFont0(u16 glyphId, bool32 isJapanese) if (isJapanese == 1) { glyphs = gFont0JapaneseGlyphs + (0x100 * (glyphId >> 0x4)) + (0x8 * (glyphId & 0xF)); - DecompressGlyphTile(glyphs, gUnknown_03002F90.unk0); - DecompressGlyphTile(glyphs + 0x80, gUnknown_03002F90.unk40); // gUnknown_03002F90 + 0x40 - gUnknown_03002F90.width = 8; // gGlyphWidth - gUnknown_03002F90.height = 12; // gGlyphHeight + DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop); + DecompressGlyphTile(glyphs + 0x80, gCurGlyph.gfxBufferBottom); + gCurGlyph.width = 8; + gCurGlyph.height = 12; } else { glyphs = gFont0LatinGlyphs + (0x20 * glyphId); - gUnknown_03002F90.width = gFont0LatinGlyphWidths[glyphId]; + gCurGlyph.width = gFont0LatinGlyphWidths[glyphId]; - if (gUnknown_03002F90.width <= 8) + if (gCurGlyph.width <= 8) { - DecompressGlyphTile(glyphs, gUnknown_03002F90.unk0); - DecompressGlyphTile(glyphs + 0x10, gUnknown_03002F90.unk40); + DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop); + DecompressGlyphTile(glyphs + 0x10, gCurGlyph.gfxBufferBottom); } else { - DecompressGlyphTile(glyphs, gUnknown_03002F90.unk0); - DecompressGlyphTile(glyphs + 0x8, gUnknown_03002F90.unk20); - DecompressGlyphTile(glyphs + 0x10, gUnknown_03002F90.unk40); - DecompressGlyphTile(glyphs + 0x18, gUnknown_03002F90.unk60); + DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop); + DecompressGlyphTile(glyphs + 0x8, gCurGlyph.gfxBufferTop + 8); + DecompressGlyphTile(glyphs + 0x10, gCurGlyph.gfxBufferBottom); + DecompressGlyphTile(glyphs + 0x18, gCurGlyph.gfxBufferBottom + 8); } - gUnknown_03002F90.height = 13; + gCurGlyph.height = 13; } } @@ -1635,30 +1634,30 @@ void DecompressGlyphFont7(u16 glyphId, bool32 isJapanese) { int eff; glyphs = gFont1JapaneseGlyphs + (0x100 * (glyphId >> 0x4)) + (0x8 * (glyphId & (eff = 0xF))); // shh, no questions, only matching now - DecompressGlyphTile(glyphs, gUnknown_03002F90.unk0); - DecompressGlyphTile(glyphs + 0x80, gUnknown_03002F90.unk40); // gUnknown_03002F90 + 0x40 - gUnknown_03002F90.width = 8; // gGlyphWidth - gUnknown_03002F90.height = 15; // gGlyphHeight + DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop); + DecompressGlyphTile(glyphs + 0x80, gCurGlyph.gfxBufferBottom); + gCurGlyph.width = 8; + gCurGlyph.height = 15; } else { glyphs = gFont7LatinGlyphs + (0x20 * glyphId); - gUnknown_03002F90.width = gFont7LatinGlyphWidths[glyphId]; + gCurGlyph.width = gFont7LatinGlyphWidths[glyphId]; - if (gUnknown_03002F90.width <= 8) + if (gCurGlyph.width <= 8) { - DecompressGlyphTile(glyphs, gUnknown_03002F90.unk0); - DecompressGlyphTile(glyphs + 0x10, gUnknown_03002F90.unk40); + DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop); + DecompressGlyphTile(glyphs + 0x10, gCurGlyph.gfxBufferBottom); } else { - DecompressGlyphTile(glyphs, gUnknown_03002F90.unk0); - DecompressGlyphTile(glyphs + 0x8, gUnknown_03002F90.unk20); - DecompressGlyphTile(glyphs + 0x10, gUnknown_03002F90.unk40); - DecompressGlyphTile(glyphs + 0x18, gUnknown_03002F90.unk60); + DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop); + DecompressGlyphTile(glyphs + 0x8, gCurGlyph.gfxBufferTop + 8); + DecompressGlyphTile(glyphs + 0x10, gCurGlyph.gfxBufferBottom); + DecompressGlyphTile(glyphs + 0x18, gCurGlyph.gfxBufferBottom + 8); } - gUnknown_03002F90.height = 15; + gCurGlyph.height = 15; } } @@ -1677,30 +1676,30 @@ void DecompressGlyphFont8(u16 glyphId, bool32 isJapanese) if (isJapanese == TRUE) { glyphs = gFont0JapaneseGlyphs + (0x100 * (glyphId >> 0x4)) + (0x8 * (glyphId & 0xF)); - DecompressGlyphTile(glyphs, gUnknown_03002F90.unk0); - DecompressGlyphTile(glyphs + 0x80, gUnknown_03002F90.unk40); // gUnknown_03002F90 + 0x40 - gUnknown_03002F90.width = 8; // gGlyphWidth - gUnknown_03002F90.height = 12; // gGlyphHeight + DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop); + DecompressGlyphTile(glyphs + 0x80, gCurGlyph.gfxBufferBottom); + gCurGlyph.width = 8; + gCurGlyph.height = 12; } else { glyphs = gFont8LatinGlyphs + (0x20 * glyphId); - gUnknown_03002F90.width = gFont8LatinGlyphWidths[glyphId]; + gCurGlyph.width = gFont8LatinGlyphWidths[glyphId]; - if (gUnknown_03002F90.width <= 8) + if (gCurGlyph.width <= 8) { - DecompressGlyphTile(glyphs, gUnknown_03002F90.unk0); - DecompressGlyphTile(glyphs + 0x10, gUnknown_03002F90.unk40); + DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop); + DecompressGlyphTile(glyphs + 0x10, gCurGlyph.gfxBufferBottom); } else { - DecompressGlyphTile(glyphs, gUnknown_03002F90.unk0); - DecompressGlyphTile(glyphs + 0x8, gUnknown_03002F90.unk20); - DecompressGlyphTile(glyphs + 0x10, gUnknown_03002F90.unk40); - DecompressGlyphTile(glyphs + 0x18, gUnknown_03002F90.unk60); + DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop); + DecompressGlyphTile(glyphs + 0x8, gCurGlyph.gfxBufferTop + 8); + DecompressGlyphTile(glyphs + 0x10, gCurGlyph.gfxBufferBottom); + DecompressGlyphTile(glyphs + 0x18, gCurGlyph.gfxBufferBottom + 8); } - gUnknown_03002F90.height = 12; + gCurGlyph.height = 12; } } @@ -1719,32 +1718,32 @@ void DecompressGlyphFont2(u16 glyphId, bool32 isJapanese) if (isJapanese == TRUE) { glyphs = gFont2JapaneseGlyphs + (0x100 * (glyphId >> 0x3)) + (0x10 * (glyphId & 0x7)); - DecompressGlyphTile(glyphs, gUnknown_03002F90.unk0); - DecompressGlyphTile(glyphs + 0x8, gUnknown_03002F90.unk20); // gUnknown_03002F90 + 0x40 - DecompressGlyphTile(glyphs + 0x80, gUnknown_03002F90.unk40); // gUnknown_03002F90 + 0x20 - DecompressGlyphTile(glyphs + 0x88, gUnknown_03002F90.unk60); // gUnknown_03002F90 + 0x60 - gUnknown_03002F90.width = gFont2JapaneseGlyphWidths[glyphId]; // gGlyphWidth - gUnknown_03002F90.height = 14; // gGlyphHeight + DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop); + DecompressGlyphTile(glyphs + 0x8, gCurGlyph.gfxBufferTop + 8); + DecompressGlyphTile(glyphs + 0x80, gCurGlyph.gfxBufferBottom); // gCurGlyph + 0x20 + DecompressGlyphTile(glyphs + 0x88, gCurGlyph.gfxBufferBottom + 8); // gCurGlyph + 0x60 + gCurGlyph.width = gFont2JapaneseGlyphWidths[glyphId]; + gCurGlyph.height = 14; } else { glyphs = gFont2LatinGlyphs + (0x20 * glyphId); - gUnknown_03002F90.width = gFont2LatinGlyphWidths[glyphId]; + gCurGlyph.width = gFont2LatinGlyphWidths[glyphId]; - if (gUnknown_03002F90.width <= 8) + if (gCurGlyph.width <= 8) { - DecompressGlyphTile(glyphs, gUnknown_03002F90.unk0); - DecompressGlyphTile(glyphs + 0x10, gUnknown_03002F90.unk40); + DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop); + DecompressGlyphTile(glyphs + 0x10, gCurGlyph.gfxBufferBottom); } else { - DecompressGlyphTile(glyphs, gUnknown_03002F90.unk0); - DecompressGlyphTile(glyphs + 0x8, gUnknown_03002F90.unk20); - DecompressGlyphTile(glyphs + 0x10, gUnknown_03002F90.unk40); - DecompressGlyphTile(glyphs + 0x18, gUnknown_03002F90.unk60); + DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop); + DecompressGlyphTile(glyphs + 0x8, gCurGlyph.gfxBufferTop + 8); + DecompressGlyphTile(glyphs + 0x10, gCurGlyph.gfxBufferBottom); + DecompressGlyphTile(glyphs + 0x18, gCurGlyph.gfxBufferBottom + 8); } - gUnknown_03002F90.height = 14; + gCurGlyph.height = 14; } } @@ -1764,30 +1763,30 @@ void DecompressGlyphFont1(u16 glyphId, bool32 isJapanese) { int eff; glyphs = gFont1JapaneseGlyphs + (0x100 * (glyphId >> 0x4)) + (0x8 * (glyphId & (eff = 0xF))); // shh, no questions, only matching now - DecompressGlyphTile(glyphs, gUnknown_03002F90.unk0); - DecompressGlyphTile(glyphs + 0x80, gUnknown_03002F90.unk40); // gUnknown_03002F90 + 0x40 - gUnknown_03002F90.width = 8; // gGlyphWidth - gUnknown_03002F90.height = 15; // gGlyphHeight + DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop); + DecompressGlyphTile(glyphs + 0x80, gCurGlyph.gfxBufferBottom); + gCurGlyph.width = 8; + gCurGlyph.height = 15; } else { glyphs = gFont1LatinGlyphs + (0x20 * glyphId); - gUnknown_03002F90.width = gFont1LatinGlyphWidths[glyphId]; + gCurGlyph.width = gFont1LatinGlyphWidths[glyphId]; - if (gUnknown_03002F90.width <= 8) + if (gCurGlyph.width <= 8) { - DecompressGlyphTile(glyphs, gUnknown_03002F90.unk0); - DecompressGlyphTile(glyphs + 0x10, gUnknown_03002F90.unk40); + DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop); + DecompressGlyphTile(glyphs + 0x10, gCurGlyph.gfxBufferBottom); } else { - DecompressGlyphTile(glyphs, gUnknown_03002F90.unk0); - DecompressGlyphTile(glyphs + 0x8, gUnknown_03002F90.unk20); - DecompressGlyphTile(glyphs + 0x10, gUnknown_03002F90.unk40); - DecompressGlyphTile(glyphs + 0x18, gUnknown_03002F90.unk60); + DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop); + DecompressGlyphTile(glyphs + 0x8, gCurGlyph.gfxBufferTop + 8); + DecompressGlyphTile(glyphs + 0x10, gCurGlyph.gfxBufferBottom); + DecompressGlyphTile(glyphs + 0x18, gCurGlyph.gfxBufferBottom + 8); } - gUnknown_03002F90.height = 15; + gCurGlyph.height = 15; } } @@ -1804,8 +1803,8 @@ void DecompressGlyphFont9(u16 glyphId) const u16* glyphs; glyphs = gFont9JapaneseGlyphs + (0x100 * (glyphId >> 4)) + (0x8 * (glyphId & 0xF)); - DecompressGlyphTile(glyphs, gUnknown_03002F90.unk0); - DecompressGlyphTile(glyphs + 0x80, gUnknown_03002F90.unk40); - gUnknown_03002F90.width = 8; - gUnknown_03002F90.height = 12; + DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop); + DecompressGlyphTile(glyphs + 0x80, gCurGlyph.gfxBufferBottom); + gCurGlyph.width = 8; + gCurGlyph.height = 12; } |