summaryrefslogtreecommitdiff
path: root/gflib
diff options
context:
space:
mode:
Diffstat (limited to 'gflib')
-rw-r--r--gflib/bg.c112
-rw-r--r--gflib/blit.c6
-rw-r--r--gflib/text.c177
-rw-r--r--gflib/text.h17
-rw-r--r--gflib/window.c36
5 files changed, 170 insertions, 178 deletions
diff --git a/gflib/bg.c b/gflib/bg.c
index 12c42d124..66dd81a25 100644
--- a/gflib/bg.c
+++ b/gflib/bg.c
@@ -34,8 +34,8 @@ struct BgConfig2
u32 unk_3:18;
void* tilemap;
- s32 bg_x; // Maybe unsigned, but game treats it as if it is signed a LOT.
- s32 bg_y; // Same for this variable.
+ s32 bg_x;
+ s32 bg_y;
};
static struct BgControl sGpuBgConfigs;
@@ -621,15 +621,17 @@ s32 GetBgX(u8 bg)
{
if (IsInvalidBg32(bg))
return -1;
- if (!GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE))
+ else if (!GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE))
return -1;
- return sGpuBgConfigs2[bg].bg_x;
+ else
+ return sGpuBgConfigs2[bg].bg_x;
}
s32 ChangeBgY(u8 bg, s32 value, u8 op)
{
u8 mode;
- u16 temp1, temp2;
+ u16 temp1;
+ u16 temp2;
if (IsInvalidBg32(bg) || !GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE))
{
@@ -698,7 +700,8 @@ s32 ChangeBgY(u8 bg, s32 value, u8 op)
s32 ChangeBgY_ScreenOff(u8 bg, u32 value, u8 op)
{
u8 mode;
- u16 temp1, temp2;
+ u16 temp1;
+ u16 temp2;
if (IsInvalidBg32(bg) || !GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE))
{
@@ -769,9 +772,10 @@ s32 GetBgY(u8 bg)
{
if (IsInvalidBg32(bg))
return -1;
- if (!GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE))
+ else if (!GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE))
return -1;
- return sGpuBgConfigs2[bg].bg_y;
+ else
+ return sGpuBgConfigs2[bg].bg_y;
}
void SetBgAffine(u8 bg, s32 srcCenterX, s32 srcCenterY, s16 dispCenterX, s16 dispCenterY, s16 scaleX, s16 scaleY, u16 rotationAngle)
@@ -870,77 +874,81 @@ void* GetBgTilemapBuffer(u8 bg)
{
if (IsInvalidBg32(bg))
return NULL;
- if (!GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE))
+ else if (!GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE))
return NULL;
- return sGpuBgConfigs2[bg].tilemap;
+ else
+ return sGpuBgConfigs2[bg].tilemap;
}
void CopyToBgTilemapBuffer(u8 bg, const void *src, u16 mode, u16 destOffset)
{
- if (IsInvalidBg32(bg) || IsTileMapOutsideWram(bg))
- return;
- if (mode != 0)
- CpuCopy16(src, (void *)(sGpuBgConfigs2[bg].tilemap + (destOffset * 2)), mode);
- else
- LZ77UnCompWram(src, (void *)(sGpuBgConfigs2[bg].tilemap + (destOffset * 2)));
+ if (!IsInvalidBg32(bg) && !IsTileMapOutsideWram(bg))
+ {
+ if (mode != 0)
+ CpuCopy16(src, (void *)(sGpuBgConfigs2[bg].tilemap + (destOffset * 2)), mode);
+ else
+ LZ77UnCompWram(src, (void *)(sGpuBgConfigs2[bg].tilemap + (destOffset * 2)));
+ }
}
void CopyBgTilemapBufferToVram(u8 bg)
{
u16 sizeToLoad;
- if (IsInvalidBg32(bg) || IsTileMapOutsideWram(bg))
- return;
-
- switch (GetBgType(bg))
+ if (!IsInvalidBg32(bg) && !IsTileMapOutsideWram(bg))
{
- case 0:
- sizeToLoad = GetBgMetricTextMode(bg, 0) * 0x800;
- break;
- case 1:
- sizeToLoad = GetBgMetricAffineMode(bg, 0) * 0x100;
- break;
- default:
- sizeToLoad = 0;
- break;
+ switch (GetBgType(bg))
+ {
+ case 0:
+ sizeToLoad = GetBgMetricTextMode(bg, 0) * 0x800;
+ break;
+ case 1:
+ sizeToLoad = GetBgMetricAffineMode(bg, 0) * 0x100;
+ break;
+ default:
+ sizeToLoad = 0;
+ break;
+ }
+ LoadBgVram(bg, sGpuBgConfigs2[bg].tilemap, sizeToLoad, 0, 2);
}
- LoadBgVram(bg, sGpuBgConfigs2[bg].tilemap, sizeToLoad, 0, 2);
}
-void CopyToBgTilemapBufferRect(u8 bg, const void *src, u8 destX, u8 destY, u8 width, u8 height)
+void CopyToBgTilemapBufferRect(u8 bg, const void* src, u8 destX, u8 destY, u8 width, u8 height)
{
- u16 destX16, destY16;
+ u16 destX16;
+ u16 destY16;
u16 mode;
- if (IsInvalidBg32(bg) || IsTileMapOutsideWram(bg))
- return;
- switch (GetBgType(bg))
- {
- case 0:
+ if (!IsInvalidBg32(bg) && !IsTileMapOutsideWram(bg))
{
- const u16 *srcCopy = src;
- for (destY16 = destY; destY16 < (destY + height); destY16++)
+ switch (GetBgType(bg))
{
- for (destX16 = destX; destX16 < (destX + width); destX16++)
+ case 0:
+ {
+ const u16 * srcCopy = src;
+ for (destY16 = destY; destY16 < (destY + height); destY16++)
{
- ((u16 *)sGpuBgConfigs2[bg].tilemap)[((destY16 * 0x20) + destX16)] = *srcCopy++;
+ for (destX16 = destX; destX16 < (destX + width); destX16++)
+ {
+ ((u16*)sGpuBgConfigs2[bg].tilemap)[((destY16 * 0x20) + destX16)] = *srcCopy++;
+ }
}
+ break;
}
- break;
- }
- case 1:
- {
- const u8 *srcCopy = src;
- mode = GetBgMetricAffineMode(bg, 0x1);
- for (destY16 = destY; destY16 < (destY + height); destY16++)
+ case 1:
{
- for (destX16 = destX; destX16 < (destX + width); destX16++)
+ const u8 * srcCopy = src;
+ mode = GetBgMetricAffineMode(bg, 0x1);
+ for (destY16 = destY; destY16 < (destY + height); destY16++)
{
- ((u8 *)sGpuBgConfigs2[bg].tilemap)[((destY16 * mode) + destX16)] = *srcCopy++;
+ for (destX16 = destX; destX16 < (destX + width); destX16++)
+ {
+ ((u8*)sGpuBgConfigs2[bg].tilemap)[((destY16 * mode) + destX16)] = *srcCopy++;
+ }
}
+ break;
+ }
}
- break;
- }
}
}
diff --git a/gflib/blit.c b/gflib/blit.c
index 26a63fe9b..bdbb2e2fd 100644
--- a/gflib/blit.c
+++ b/gflib/blit.c
@@ -76,7 +76,7 @@ void FillBitmapRect4Bit(struct Bitmap *surface, u16 x, u16 y, u16 width, u16 hei
s32 yEnd;
s32 multiplierY;
s32 loopX, loopY;
- s32 toOrr1, toOrr2;
+ u8 toOrr1, toOrr2;
xEnd = x + width;
if (xEnd > surface->width)
@@ -87,8 +87,8 @@ void FillBitmapRect4Bit(struct Bitmap *surface, u16 x, u16 y, u16 width, u16 hei
yEnd = surface->height;
multiplierY = (surface->width + (surface->width & 7)) >> 3;
- toOrr1 = (u32)(fillValue << 0x1C) >> 0x18;
- toOrr2 = (fillValue & 0xF);
+ toOrr1 = fillValue << 4;
+ toOrr2 = fillValue & 0xF;
for (loopY = y; loopY < yEnd; loopY++)
{
diff --git a/gflib/text.c b/gflib/text.c
index 89b47ca21..4cbad1376 100644
--- a/gflib/text.c
+++ b/gflib/text.c
@@ -21,7 +21,7 @@ static u16 gLastTextFgColor;
static u16 gLastTextShadowColor;
const struct FontInfo *gFonts;
-bool8 gUnknown_03002F84;
+u8 gUnknown_03002F84;
struct Struct_03002F90 gUnknown_03002F90;
TextFlags gTextFlags;
@@ -154,7 +154,7 @@ u16 AddTextPrinterParameterized(u8 windowId, u8 fontId, const u8 *str, u8 x, u8
printerTemplate.currentY = y;
printerTemplate.letterSpacing = gFonts[fontId].letterSpacing;
printerTemplate.lineSpacing = gFonts[fontId].lineSpacing;
- printerTemplate.style = gFonts[fontId].style;
+ printerTemplate.unk = gFonts[fontId].unk;
printerTemplate.fgColor = gFonts[fontId].fgColor;
printerTemplate.bgColor = gFonts[fontId].bgColor;
printerTemplate.shadowColor = gFonts[fontId].shadowColor;
@@ -205,7 +205,7 @@ bool16 AddTextPrinter(struct TextPrinterTemplate *printerTemplate, u8 speed, voi
CopyWindowToVram(gTempTextPrinter.printerTemplate.windowId, 2);
gTextPrinters[printerTemplate->windowId].active = 0;
}
- gUnknown_03002F84 = FALSE;
+ gUnknown_03002F84 = 0;
return TRUE;
}
@@ -213,7 +213,7 @@ void RunTextPrinters(void)
{
int i;
- if (!gUnknown_03002F84)
+ if (gUnknown_03002F84 == 0)
{
for (i = 0; i < NUM_TEXT_PRINTERS; ++i)
{
@@ -451,51 +451,46 @@ u8 GetLastTextColor(u8 colorType)
{
switch (colorType)
{
- case COLOR_FOREGROUND:
+ case 0:
return gLastTextFgColor;
- case COLOR_BACKGROUND:
+ case 2:
return gLastTextBgColor;
- case COLOR_SHADOW:
+ case 1:
return gLastTextShadowColor;
default:
return 0;
}
}
-#define GLYPH_COPY(fromY_, toY_, fromX_, toX_, unk) \
- { \
- u32 i, j, *ptr, toY, fromX, toX, r5, bits; \
- u8 *dst; \
- j = fromX_; \
- i = fromY_; \
- ptr = unk; \
- toX = toX_; \
- toY = toY_; \
- fromX = fromX_; \
- \
- for (; i < toY; i++) \
- { \
- asm("":::"sl"); /* NONMATCHING */ \
- r5 = *(ptr++); \
- for (j = fromX; j < toX; j++) \
- { \
- const u32 toOrr = r5 & 0xF; \
- if (toOrr) \
- { \
- 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; \
- } \
- } \
+inline static void GLYPH_COPY(u8 *windowTiles, u32 widthOffset, u32 j, u32 i, u32 *ptr, s32 width, s32 height)
+{
+ u32 xAdd, yAdd, r5, bits, toOrr, dummyX;
+ u8 *dst;
+
+ xAdd = j + width;
+ yAdd = i + height;
+ dummyX = j;
+ for (; i < yAdd; i++)
+ {
+ r5 = *ptr++;
+ for (j = dummyX; j < xAdd; j++)
+ {
+ if ((toOrr = r5 & 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;
+ }
}
+}
void CopyGlyphToWindow(struct TextPrinter *textPrinter)
{
struct Window *win;
struct WindowTemplate *winTempl;
- struct Struct_03002F90 *unkStruct;
+ u32 *unkStruct;
u32 currX, currY, widthOffset;
s32 r4, r0;
u8 *windowTiles;
@@ -503,17 +498,15 @@ void CopyGlyphToWindow(struct TextPrinter *textPrinter)
win = &gWindows[textPrinter->printerTemplate.windowId];
winTempl = &win->window;
- r4 = (winTempl->width * 8) - textPrinter->printerTemplate.currentX;
- if (r4 > gUnknown_03002F90.width)
+ if ((r4 = (winTempl->width * 8) - textPrinter->printerTemplate.currentX) > gUnknown_03002F90.width)
r4 = gUnknown_03002F90.width;
- r0 = (winTempl->height * 8) - textPrinter->printerTemplate.currentY;
- if (r0 > gUnknown_03002F90.height)
+ if ((r0 = (winTempl->height * 8) - textPrinter->printerTemplate.currentY) > gUnknown_03002F90.height)
r0 = gUnknown_03002F90.height;
currX = textPrinter->printerTemplate.currentX;
currY = textPrinter->printerTemplate.currentY;
- unkStruct = &gUnknown_03002F90;
+ unkStruct = (u32 *)&gUnknown_03002F90.unk0;
windowTiles = win->tileData;
widthOffset = winTempl->width * 32;
@@ -521,45 +514,31 @@ void CopyGlyphToWindow(struct TextPrinter *textPrinter)
{
if (r0 < 9)
{
- GLYPH_COPY(currY, currY + r0, currX, currX + r4, unkStruct->unk0);
+ GLYPH_COPY(windowTiles, widthOffset, currX, currY, unkStruct, r4, r0);
}
else
{
- u32 temp;
- GLYPH_COPY(currY, currY + 8, currX, currX + r4, unkStruct->unk0);
-
- temp = currY + 8;
- GLYPH_COPY(temp, (temp - 8) + r0, currX, currX + r4, unkStruct->unk40);
+ GLYPH_COPY(windowTiles, widthOffset, currX, currY, unkStruct, r4, 8);
+ GLYPH_COPY(windowTiles, widthOffset, currX, currY + 8, unkStruct + 16, r4, r0 - 8);
}
}
else
{
- u32 temp;
if (r0 < 9)
{
- GLYPH_COPY(currY, currY + r0, currX, currX + 8, unkStruct->unk0);
-
- temp = currX + 8;
- GLYPH_COPY(currY, currY + r0, temp, (temp - 8) + r4, unkStruct->unk20);
+ GLYPH_COPY(windowTiles, widthOffset, currX, currY, unkStruct, 8, r0);
+ GLYPH_COPY(windowTiles, widthOffset, currX + 8, currY, unkStruct + 8, r4 - 8, r0);
}
else
{
- GLYPH_COPY(currY, currY + 8, currX, currX + 8, unkStruct->unk0);
-
- temp = currX + 8;
- GLYPH_COPY(currY, currY + 8, temp, temp - 8 + r4, unkStruct->unk20);
-
- temp = currY + 8;
- GLYPH_COPY(temp, temp - 8 + r0, currX, currX + 8, unkStruct->unk40);
- {
- u32 tempX, tempY;
- tempX = currX + 8;
- tempY = currY + 8;
- GLYPH_COPY(tempY, tempY - 8 + r0, tempX, tempX - 8 + r4, unkStruct->unk60);
- }
+ 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);
}
}
}
+
void ClearTextSpan(struct TextPrinter *textPrinter, u32 width)
{
struct Window *window;
@@ -591,7 +570,7 @@ u16 Font0Func(struct TextPrinter *textPrinter)
{
struct TextPrinterSubStruct *subStruct = (struct TextPrinterSubStruct *)(&textPrinter->subStructFields);
- if (!subStruct->hasGlyphIdBeenSet)
+ if (subStruct->hasGlyphIdBeenSet == FALSE)
{
subStruct->glyphId = 0;
subStruct->hasGlyphIdBeenSet = TRUE;
@@ -603,7 +582,7 @@ u16 Font1Func(struct TextPrinter *textPrinter)
{
struct TextPrinterSubStruct *subStruct = (struct TextPrinterSubStruct *)(&textPrinter->subStructFields);
- if (!subStruct->hasGlyphIdBeenSet)
+ if (subStruct->hasGlyphIdBeenSet == FALSE)
{
subStruct->glyphId = 1;
subStruct->hasGlyphIdBeenSet = TRUE;
@@ -615,7 +594,7 @@ u16 Font2Func(struct TextPrinter *textPrinter)
{
struct TextPrinterSubStruct *subStruct = (struct TextPrinterSubStruct *)(&textPrinter->subStructFields);
- if (!subStruct->hasGlyphIdBeenSet)
+ if (subStruct->hasGlyphIdBeenSet == FALSE)
{
subStruct->glyphId = 2;
subStruct->hasGlyphIdBeenSet = TRUE;
@@ -627,7 +606,7 @@ u16 Font3Func(struct TextPrinter *textPrinter)
{
struct TextPrinterSubStruct *subStruct = (struct TextPrinterSubStruct *)(&textPrinter->subStructFields);
- if (!subStruct->hasGlyphIdBeenSet)
+ if (subStruct->hasGlyphIdBeenSet == FALSE)
{
subStruct->glyphId = 3;
subStruct->hasGlyphIdBeenSet = TRUE;
@@ -639,7 +618,7 @@ u16 Font4Func(struct TextPrinter *textPrinter)
{
struct TextPrinterSubStruct *subStruct = (struct TextPrinterSubStruct *)(&textPrinter->subStructFields);
- if (!subStruct->hasGlyphIdBeenSet)
+ if (subStruct->hasGlyphIdBeenSet == FALSE)
{
subStruct->glyphId = 4;
subStruct->hasGlyphIdBeenSet = TRUE;
@@ -651,7 +630,7 @@ u16 Font5Func(struct TextPrinter *textPrinter)
{
struct TextPrinterSubStruct *subStruct = (struct TextPrinterSubStruct *)(&textPrinter->subStructFields);
- if (!subStruct->hasGlyphIdBeenSet)
+ if (subStruct->hasGlyphIdBeenSet == FALSE)
{
subStruct->glyphId = 5;
subStruct->hasGlyphIdBeenSet = TRUE;
@@ -663,7 +642,7 @@ u16 Font7Func(struct TextPrinter *textPrinter)
{
struct TextPrinterSubStruct *subStruct = (struct TextPrinterSubStruct *)(&textPrinter->subStructFields);
- if (!subStruct->hasGlyphIdBeenSet)
+ if (subStruct->hasGlyphIdBeenSet == FALSE)
{
subStruct->glyphId = 7;
subStruct->hasGlyphIdBeenSet = TRUE;
@@ -675,7 +654,7 @@ u16 Font8Func(struct TextPrinter *textPrinter)
{
struct TextPrinterSubStruct *subStruct = (struct TextPrinterSubStruct *)(&textPrinter->subStructFields);
- if (!subStruct->hasGlyphIdBeenSet)
+ if (subStruct->hasGlyphIdBeenSet == FALSE)
{
subStruct->glyphId = 8;
subStruct->hasGlyphIdBeenSet = TRUE;
@@ -687,7 +666,7 @@ void TextPrinterInitDownArrowCounters(struct TextPrinter *textPrinter)
{
struct TextPrinterSubStruct *subStruct = (struct TextPrinterSubStruct *)(&textPrinter->subStructFields);
- if (gTextFlags.autoScroll == TRUE)
+ if (gTextFlags.autoScroll == 1)
{
subStruct->autoScrollDelay = 0;
}
@@ -703,7 +682,7 @@ void TextPrinterDrawDownArrow(struct TextPrinter *textPrinter)
struct TextPrinterSubStruct *subStruct = (struct TextPrinterSubStruct *)(&textPrinter->subStructFields);
const u8 *arrowTiles;
- if (!gTextFlags.autoScroll)
+ if (gTextFlags.autoScroll == 0)
{
if (subStruct->downArrowDelay != 0)
{
@@ -779,7 +758,7 @@ bool8 TextPrinterWaitAutoMode(struct TextPrinter *textPrinter)
bool16 TextPrinterWaitWithDownArrow(struct TextPrinter *textPrinter)
{
bool8 result = FALSE;
- if (gTextFlags.autoScroll)
+ if (gTextFlags.autoScroll != 0)
{
result = TextPrinterWaitAutoMode(textPrinter);
}
@@ -798,14 +777,17 @@ bool16 TextPrinterWaitWithDownArrow(struct TextPrinter *textPrinter)
bool16 TextPrinterWait(struct TextPrinter *textPrinter)
{
bool16 result = FALSE;
- if (gTextFlags.autoScroll)
+ if (gTextFlags.autoScroll != 0)
{
result = TextPrinterWaitAutoMode(textPrinter);
}
- else if (JOY_NEW(A_BUTTON | B_BUTTON))
+ else
{
- result = TRUE;
- PlaySE(SE_SELECT);
+ if (JOY_NEW(A_BUTTON | B_BUTTON))
+ {
+ result = TRUE;
+ PlaySE(SE_SELECT);
+ }
}
return result;
}
@@ -821,7 +803,7 @@ void DrawDownArrow(u8 windowId, u16 x, u16 y, u8 bgColor, bool8 drawArrow, u8 *c
else
{
FillWindowPixelRect(windowId, (bgColor << 4) | bgColor, x, y, 0x8, 0x10);
- if (!drawArrow)
+ if (drawArrow == 0)
{
switch (gTextFlags.useAlternateDownArrow)
{
@@ -1013,10 +995,10 @@ u16 RenderText(struct TextPrinter *textPrinter)
textPrinter->minLetterSpacing = *textPrinter->printerTemplate.currentChar++;
return 2;
case EXT_CTRL_CODE_JPN:
- textPrinter->japanese = TRUE;
+ textPrinter->japanese = 1;
return 2;
case EXT_CTRL_CODE_ENG:
- textPrinter->japanese = FALSE;
+ textPrinter->japanese = 0;
return 2;
}
break;
@@ -1077,10 +1059,13 @@ u16 RenderText(struct TextPrinter *textPrinter)
textPrinter->printerTemplate.currentX += width;
}
}
- else if (textPrinter->japanese)
- textPrinter->printerTemplate.currentX += (gUnknown_03002F90.width + textPrinter->printerTemplate.letterSpacing);
else
- textPrinter->printerTemplate.currentX += gUnknown_03002F90.width;
+ {
+ if (textPrinter->japanese)
+ textPrinter->printerTemplate.currentX += (gUnknown_03002F90.width + textPrinter->printerTemplate.letterSpacing);
+ else
+ textPrinter->printerTemplate.currentX += gUnknown_03002F90.width;
+ }
return 0;
case 1:
if (TextPrinterWait(textPrinter))
@@ -1566,7 +1551,7 @@ void SetDefaultFontsPointer(void)
u8 GetFontAttribute(u8 fontId, u8 attributeId)
{
- u8 result = 0;
+ int result = 0;
switch (attributeId)
{
case FONTATTR_MAX_LETTER_WIDTH:
@@ -1581,8 +1566,8 @@ u8 GetFontAttribute(u8 fontId, u8 attributeId)
case FONTATTR_LINE_SPACING:
result = gFontInfos[fontId].lineSpacing;
break;
- case FONTATTR_STYLE:
- result = gFontInfos[fontId].style;
+ case FONTATTR_UNKNOWN:
+ result = gFontInfos[fontId].unk;
break;
case FONTATTR_COLOR_FOREGROUND:
result = gFontInfos[fontId].fgColor;
@@ -1612,7 +1597,7 @@ void DecompressGlyphFont0(u16 glyphId, bool32 isJapanese)
DecompressGlyphTile(glyphs, gUnknown_03002F90.unk0);
DecompressGlyphTile(glyphs + 0x80, gUnknown_03002F90.unk40); // gUnknown_03002F90 + 0x40
gUnknown_03002F90.width = 8; // gGlyphWidth
- gUnknown_03002F90.height = 12; // gGlyphHeight
+ gUnknown_03002F90.height = 12; // gGlyphHeight
}
else
{
@@ -1655,7 +1640,7 @@ void DecompressGlyphFont7(u16 glyphId, bool32 isJapanese)
DecompressGlyphTile(glyphs, gUnknown_03002F90.unk0);
DecompressGlyphTile(glyphs + 0x80, gUnknown_03002F90.unk40); // gUnknown_03002F90 + 0x40
gUnknown_03002F90.width = 8; // gGlyphWidth
- gUnknown_03002F90.height = 15; // gGlyphHeight
+ gUnknown_03002F90.height = 15; // gGlyphHeight
}
else
{
@@ -1697,7 +1682,7 @@ void DecompressGlyphFont8(u16 glyphId, bool32 isJapanese)
DecompressGlyphTile(glyphs, gUnknown_03002F90.unk0);
DecompressGlyphTile(glyphs + 0x80, gUnknown_03002F90.unk40); // gUnknown_03002F90 + 0x40
gUnknown_03002F90.width = 8; // gGlyphWidth
- gUnknown_03002F90.height = 12; // gGlyphHeight
+ gUnknown_03002F90.height = 12; // gGlyphHeight
}
else
{
@@ -1737,10 +1722,10 @@ void DecompressGlyphFont2(u16 glyphId, bool32 isJapanese)
{
glyphs = gFont2JapaneseGlyphs + (0x100 * (glyphId >> 0x3)) + (0x10 * (glyphId & 0x7));
DecompressGlyphTile(glyphs, gUnknown_03002F90.unk0);
- DecompressGlyphTile(glyphs + 0x8, gUnknown_03002F90.unk20);
- DecompressGlyphTile(glyphs + 0x80, gUnknown_03002F90.unk40);
- DecompressGlyphTile(glyphs + 0x88, gUnknown_03002F90.unk60);
- gUnknown_03002F90.width = gFont2JapaneseGlyphWidths[glyphId]; // gGlyphWidth
+ 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
}
else
@@ -1784,7 +1769,7 @@ void DecompressGlyphFont1(u16 glyphId, bool32 isJapanese)
DecompressGlyphTile(glyphs, gUnknown_03002F90.unk0);
DecompressGlyphTile(glyphs + 0x80, gUnknown_03002F90.unk40); // gUnknown_03002F90 + 0x40
gUnknown_03002F90.width = 8; // gGlyphWidth
- gUnknown_03002F90.height = 15; // gGlyphHeight
+ gUnknown_03002F90.height = 15; // gGlyphHeight
}
else
{
diff --git a/gflib/text.h b/gflib/text.h
index 4cf5bc20b9..723a2fc0e 100644
--- a/gflib/text.h
+++ b/gflib/text.h
@@ -271,18 +271,11 @@
enum
{
- COLOR_FOREGROUND,
- COLOR_SHADOW,
- COLOR_BACKGROUND
-};
-
-enum
-{
FONTATTR_MAX_LETTER_WIDTH,
FONTATTR_MAX_LETTER_HEIGHT,
FONTATTR_LETTER_SPACING,
FONTATTR_LINE_SPACING,
- FONTATTR_STYLE,
+ FONTATTR_UNKNOWN, // dunno what this is yet
FONTATTR_COLOR_FOREGROUND,
FONTATTR_COLOR_BACKGROUND,
FONTATTR_COLOR_SHADOW
@@ -310,7 +303,7 @@ struct TextPrinterTemplate
u8 currentY;
u8 letterSpacing;
u8 lineSpacing;
- u8 style:4; // 0xC
+ u8 unk:4; // 0xC
u8 fgColor:4;
u8 bgColor:4;
u8 shadowColor:4;
@@ -329,7 +322,7 @@ struct TextPrinter
u8 delayCounter;
u8 scrollDistance;
u8 minLetterSpacing; // 0x20
- bool8 japanese;
+ u8 japanese;
};
struct FontInfo
@@ -339,7 +332,7 @@ struct FontInfo
u8 maxLetterHeight;
u8 letterSpacing;
u8 lineSpacing;
- u8 style:4; //unused
+ u8 unk:4;
u8 fgColor:4;
u8 bgColor:4;
u8 shadowColor:4;
@@ -379,7 +372,7 @@ struct Struct_03002F90
extern TextFlags gTextFlags;
-extern bool8 gUnknown_03002F84;
+extern u8 gUnknown_03002F84;
extern struct Struct_03002F90 gUnknown_03002F90;
void SetFontsPointer(const struct FontInfo *fonts);
diff --git a/gflib/window.c b/gflib/window.c
index 0be59773c..7c87ea86d 100644
--- a/gflib/window.c
+++ b/gflib/window.c
@@ -30,18 +30,21 @@ static void nullsub_8(void)
bool16 InitWindows(const struct WindowTemplate *templates)
{
- int i, j;
- u8* allocatedTilemapBuffer;
+ int i;
+ void *bgTilemapBuffer;
+ int j;
+ u8 bgLayer;
u16 attrib;
+ u8* allocatedTilemapBuffer;
int allocatedBaseBlock;
- u8 bgLayer;
for (i = 0; i < 0x4; ++i)
{
- if (GetBgTilemapBuffer(i) != NULL)
+ bgTilemapBuffer = GetBgTilemapBuffer(i);
+ if (bgTilemapBuffer != NULL)
gUnknown_03002F70[i] = nullsub_8;
else
- gUnknown_03002F70[i] = NULL;
+ gUnknown_03002F70[i] = bgTilemapBuffer;
}
for (i = 0; i < 0x20; ++i)
@@ -564,19 +567,19 @@ u32 GetWindowAttribute(u8 windowId, u8 attributeId)
switch (attributeId)
{
case WINDOW_BG:
- return (u32)gWindows[windowId].window.bg;
+ return gWindows[windowId].window.bg;
case WINDOW_TILEMAP_LEFT:
- return (u32)gWindows[windowId].window.tilemapLeft;
+ return gWindows[windowId].window.tilemapLeft;
case WINDOW_TILEMAP_TOP:
- return (u32)gWindows[windowId].window.tilemapTop;
+ return gWindows[windowId].window.tilemapTop;
case WINDOW_WIDTH:
- return (u32)gWindows[windowId].window.width;
+ return gWindows[windowId].window.width;
case WINDOW_HEIGHT:
- return (u32)gWindows[windowId].window.height;
+ return gWindows[windowId].window.height;
case WINDOW_PALETTE_NUM:
- return (u32)gWindows[windowId].window.paletteNum;
+ return gWindows[windowId].window.paletteNum;
case WINDOW_BASE_BLOCK:
- return (u32)gWindows[windowId].window.baseBlock;
+ return gWindows[windowId].window.baseBlock;
case WINDOW_TILE_DATA:
return (u32)(gWindows[windowId].tileData);
default:
@@ -640,9 +643,12 @@ u16 AddWindow8Bit(const struct WindowTemplate *template)
}
return 0xFF;
}
- gWindows[windowId].tileData = memAddress;
- gWindows[windowId].window = *template;
- return windowId;
+ else
+ {
+ gWindows[windowId].tileData = memAddress;
+ gWindows[windowId].window = *template;
+ return windowId;
+ }
}
void FillWindowPixelBuffer8Bit(u8 windowId, u8 fillValue)