summaryrefslogtreecommitdiff
path: root/gflib
diff options
context:
space:
mode:
authorGriffinR <griffin.g.richards@gmail.com>2021-07-31 13:30:40 -0400
committerGitHub <noreply@github.com>2021-07-31 13:30:40 -0400
commit3e60a7840653e50845abf10bb02cd1b519dcd80f (patch)
treecb4a0d227a238ebdeb3b6cb9fdb92781bcc4f5e7 /gflib
parent602855ea99d8015ef5b7709f6fb1e9fd167239e2 (diff)
parentd391486247cc9f29d85787d6711f7cb993cf6585 (diff)
Merge branch 'master' into doc-frontierpass2
Diffstat (limited to 'gflib')
-rw-r--r--gflib/bg.c56
-rw-r--r--gflib/bg.h2
-rw-r--r--gflib/sprite.c27
-rw-r--r--gflib/sprite.h4
-rw-r--r--gflib/string_util.h8
-rw-r--r--gflib/text.c13
-rw-r--r--gflib/text.h6
7 files changed, 54 insertions, 62 deletions
diff --git a/gflib/bg.c b/gflib/bg.c
index 3c215c103..ec7c2113b 100644
--- a/gflib/bg.c
+++ b/gflib/bg.c
@@ -55,7 +55,7 @@ void ResetBgs(void)
static void SetBgModeInternal(u8 bgMode)
{
- sGpuBgConfigs.bgVisibilityAndMode &= 0xFFF8;
+ sGpuBgConfigs.bgVisibilityAndMode &= ~0x7;
sGpuBgConfigs.bgVisibilityAndMode |= bgMode;
}
@@ -66,13 +66,11 @@ u8 GetBgMode(void)
void ResetBgControlStructs(void)
{
- struct BgConfig* bgConfigs = &sGpuBgConfigs.configs[0];
- struct BgConfig zeroedConfig = sZeroedBgControlStruct;
int i;
for (i = 0; i < NUM_BACKGROUNDS; i++)
{
- bgConfigs[i] = zeroedConfig;
+ sGpuBgConfigs.configs[i] = sZeroedBgControlStruct;
}
}
@@ -175,36 +173,30 @@ u8 LoadBgVram(u8 bg, const void *src, u16 size, u16 destOffset, u8 mode)
u16 offset;
s8 cursor;
- if (!IsInvalidBg(bg) && sGpuBgConfigs.configs[bg].visible)
- {
- switch (mode)
- {
- case 0x1:
- offset = sGpuBgConfigs.configs[bg].charBaseIndex * BG_CHAR_SIZE;
- break;
- case 0x2:
- offset = sGpuBgConfigs.configs[bg].mapBaseIndex * BG_SCREEN_SIZE;
- break;
- default:
- cursor = -1;
- goto end;
- }
+ if (IsInvalidBg(bg) || !sGpuBgConfigs.configs[bg].visible)
+ return -1;
+ switch (mode)
+ {
+ case 0x1:
+ offset = sGpuBgConfigs.configs[bg].charBaseIndex * BG_CHAR_SIZE;
offset = destOffset + offset;
-
cursor = RequestDma3Copy(src, (void*)(offset + BG_VRAM), size, 0);
-
if (cursor == -1)
- {
return -1;
- }
- }
- else
- {
- return -1;
+ break;
+ case 0x2:
+ offset = sGpuBgConfigs.configs[bg].mapBaseIndex * BG_SCREEN_SIZE;
+ offset = destOffset + offset;
+ cursor = RequestDma3Copy(src, (void*)(offset + BG_VRAM), size, 0);
+ if (cursor == -1)
+ return -1;
+ break;
+ default:
+ cursor = -1;
+ break;
}
-end:
return cursor;
}
@@ -254,17 +246,17 @@ static void SetBgAffineInternal(u8 bg, s32 srcCenterX, s32 srcCenterY, s16 dispC
switch (sGpuBgConfigs.bgVisibilityAndMode & 0x7)
{
+ default:
+ case 0:
+ return;
case 1:
if (bg != 2)
return;
break;
case 2:
- if (bg < 2 || bg >= NUM_BACKGROUNDS)
+ if (bg != 2 && bg != 3)
return;
break;
- case 0:
- default:
- return;
}
src.texX = srcCenterX;
@@ -697,7 +689,7 @@ s32 ChangeBgY(u8 bg, s32 value, u8 op)
return sGpuBgConfigs2[bg].bg_y;
}
-s32 ChangeBgY_ScreenOff(u8 bg, u32 value, u8 op)
+s32 ChangeBgY_ScreenOff(u8 bg, s32 value, u8 op)
{
u8 mode;
u16 temp1;
diff --git a/gflib/bg.h b/gflib/bg.h
index 3c7eee292..58fd1282c 100644
--- a/gflib/bg.h
+++ b/gflib/bg.h
@@ -59,7 +59,7 @@ u16 GetBgAttribute(u8 bg, u8 attributeId);
s32 ChangeBgX(u8 bg, s32 value, u8 op);
s32 GetBgX(u8 bg);
s32 ChangeBgY(u8 bg, s32 value, u8 op);
-s32 ChangeBgY_ScreenOff(u8 bg, u32 value, u8 op);
+s32 ChangeBgY_ScreenOff(u8 bg, s32 value, u8 op);
s32 GetBgY(u8 bg);
void SetBgAffine(u8 bg, s32 srcCenterX, s32 srcCenterY, s16 dispCenterX, s16 dispCenterY, s16 scaleX, s16 scaleY, u16 rotationAngle);
u8 Unused_AdjustBgMosaic(u8 a1, u8 a2);
diff --git a/gflib/sprite.c b/gflib/sprite.c
index c66b1e47d..408daf6f9 100644
--- a/gflib/sprite.c
+++ b/gflib/sprite.c
@@ -164,8 +164,8 @@ static const struct Sprite sDummySprite =
.template = &gDummySpriteTemplate,
.subspriteTables = NULL,
.callback = SpriteCallbackDummy,
- .pos1 = { 304, 160 },
- .pos2 = { 0, 0 },
+ .x = 304, .y = 160,
+ .x2 = 0, .y2 = 0,
.centerToCornerVecX = 0,
.centerToCornerVecY = 0,
.animNum = 0,
@@ -375,13 +375,13 @@ void UpdateOamCoords(void)
{
if (sprite->coordOffsetEnabled)
{
- sprite->oam.x = sprite->pos1.x + sprite->pos2.x + sprite->centerToCornerVecX + gSpriteCoordOffsetX;
- sprite->oam.y = sprite->pos1.y + sprite->pos2.y + sprite->centerToCornerVecY + gSpriteCoordOffsetY;
+ sprite->oam.x = sprite->x + sprite->x2 + sprite->centerToCornerVecX + gSpriteCoordOffsetX;
+ sprite->oam.y = sprite->y + sprite->y2 + sprite->centerToCornerVecY + gSpriteCoordOffsetY;
}
else
{
- sprite->oam.x = sprite->pos1.x + sprite->pos2.x + sprite->centerToCornerVecX;
- sprite->oam.y = sprite->pos1.y + sprite->pos2.y + sprite->centerToCornerVecY;
+ sprite->oam.x = sprite->x + sprite->x2 + sprite->centerToCornerVecX;
+ sprite->oam.y = sprite->y + sprite->y2 + sprite->centerToCornerVecY;
}
}
}
@@ -452,6 +452,10 @@ void SortSprites(void)
// Although this doesn't result in a bug in the ROM,
// the behavior is undefined.
j--;
+#ifdef UBFIX
+ if (j == 0)
+ break;
+#endif
sprite1 = &gSprites[sSpriteOrder[j - 1]];
sprite2 = &gSprites[sSpriteOrder[j]];
@@ -579,8 +583,8 @@ u8 CreateSpriteAt(u8 index, const struct SpriteTemplate *template, s16 x, s16 y,
sprite->affineAnims = template->affineAnims;
sprite->template = template;
sprite->callback = template->callback;
- sprite->pos1.x = x;
- sprite->pos1.y = y;
+ sprite->x = x;
+ sprite->y = y;
CalcCenterToCornerVec(sprite, sprite->oam.shape, sprite->oam.size, sprite->oam.affineMode);
@@ -661,8 +665,7 @@ void ResetOamRange(u8 a, u8 b)
for (i = a; i < b; i++)
{
- struct OamData *oamBuffer = gMain.oamBuffer;
- oamBuffer[i] = *(struct OamData *)&gDummyOamData;
+ gMain.oamBuffer[i] = *(struct OamData *)&gDummyOamData;
}
}
@@ -1245,14 +1248,14 @@ void obj_update_pos2(struct Sprite *sprite, s32 a1, s32 a2)
var0 = sOamDimensions32[sprite->oam.shape][sprite->oam.size].width;
var1 = var0 << 8;
var2 = (var0 << 16) / gOamMatrices[matrixNum].a;
- sprite->pos2.x = sub_8007E28(var1, var2, a1);
+ sprite->x2 = sub_8007E28(var1, var2, a1);
}
if (a2 != 0x800)
{
var0 = sOamDimensions32[sprite->oam.shape][sprite->oam.size].height;
var1 = var0 << 8;
var2 = (var0 << 16) / gOamMatrices[matrixNum].d;
- sprite->pos2.y = sub_8007E28(var1, var2, a2);
+ sprite->y2 = sub_8007E28(var1, var2, a2);
}
}
diff --git a/gflib/sprite.h b/gflib/sprite.h
index 4a3b48225..02bc0748b 100644
--- a/gflib/sprite.h
+++ b/gflib/sprite.h
@@ -197,8 +197,8 @@ struct Sprite
/*0x18*/ const struct SubspriteTable *subspriteTables;
/*0x1C*/ SpriteCallback callback;
- /*0x20*/ struct Coords16 pos1;
- /*0x24*/ struct Coords16 pos2;
+ /*0x20*/ s16 x, y;
+ /*0x24*/ s16 x2, y2;
/*0x28*/ s8 centerToCornerVecX;
/*0x29*/ s8 centerToCornerVecY;
diff --git a/gflib/string_util.h b/gflib/string_util.h
index b921d2391..229193d52 100644
--- a/gflib/string_util.h
+++ b/gflib/string_util.h
@@ -1,10 +1,10 @@
#ifndef GUARD_STRING_UTIL_H
#define GUARD_STRING_UTIL_H
-extern u8 gStringVar1[];
-extern u8 gStringVar2[];
-extern u8 gStringVar3[];
-extern u8 gStringVar4[];
+extern u8 gStringVar1[0x100];
+extern u8 gStringVar2[0x100];
+extern u8 gStringVar3[0x100];
+extern u8 gStringVar4[0x3E8];
enum StringConvertMode
{
diff --git a/gflib/text.c b/gflib/text.c
index d75be2fbf..eb993c421 100644
--- a/gflib/text.c
+++ b/gflib/text.c
@@ -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)
@@ -1417,9 +1416,9 @@ u8 RenderTextFont9(u8 *pixels, u8 fontId, u8 *str)
fgColor = TEXT_COLOR_WHITE;
bgColor = TEXT_COLOR_TRANSPARENT;
- shadowColor = TEXT_COLOR_LIGHT_GREY;
+ shadowColor = TEXT_COLOR_LIGHT_GRAY;
- GenerateFontHalfRowLookupTable(TEXT_COLOR_WHITE, TEXT_COLOR_TRANSPARENT, TEXT_COLOR_LIGHT_GREY);
+ GenerateFontHalfRowLookupTable(TEXT_COLOR_WHITE, TEXT_COLOR_TRANSPARENT, TEXT_COLOR_LIGHT_GRAY);
strLocal = str;
strPos = 0;
@@ -1633,8 +1632,7 @@ void DecompressGlyphFont7(u16 glyphId, bool32 isJapanese)
if (isJapanese == TRUE)
{
- int eff;
- glyphs = gFont1JapaneseGlyphs + (0x100 * (glyphId >> 0x4)) + (0x8 * (glyphId & (eff = 0xF))); // shh, no questions, only matching now
+ glyphs = gFont1JapaneseGlyphs + (0x100 * (glyphId >> 0x4)) + (0x8 * (glyphId % 0x10));
DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop);
DecompressGlyphTile(glyphs + 0x80, gCurGlyph.gfxBufferBottom);
gCurGlyph.width = 8;
@@ -1762,8 +1760,7 @@ void DecompressGlyphFont1(u16 glyphId, bool32 isJapanese)
if (isJapanese == TRUE)
{
- int eff;
- glyphs = gFont1JapaneseGlyphs + (0x100 * (glyphId >> 0x4)) + (0x8 * (glyphId & (eff = 0xF))); // shh, no questions, only matching now
+ glyphs = gFont1JapaneseGlyphs + (0x100 * (glyphId >> 0x4)) + (0x8 * (glyphId % 0x10));
DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop);
DecompressGlyphTile(glyphs + 0x80, gCurGlyph.gfxBufferBottom);
gCurGlyph.width = 8;
diff --git a/gflib/text.h b/gflib/text.h
index 3e9b4f2ae..3edd0fc62 100644
--- a/gflib/text.h
+++ b/gflib/text.h
@@ -71,7 +71,7 @@
//
#define CHAR_i_ACUTE 0x6F
//
-#define CHAR_UNK_SPACER 0x77
+#define CHAR_GENDERLESS 0x77 // Empty space for lack of gender icon
//
#define CHAR_UP_ARROW 0x79
#define CHAR_DOWN_ARROW 0x7A
@@ -233,8 +233,8 @@
#define TEXT_COLOR_TRANSPARENT 0x0
#define TEXT_COLOR_WHITE 0x1
-#define TEXT_COLOR_DARK_GREY 0x2
-#define TEXT_COLOR_LIGHT_GREY 0x3
+#define TEXT_COLOR_DARK_GRAY 0x2
+#define TEXT_COLOR_LIGHT_GRAY 0x3
#define TEXT_COLOR_RED 0x4
#define TEXT_COLOR_LIGHT_RED 0x5
#define TEXT_COLOR_GREEN 0x6