This commit is contained in:
PokeCodec 2020-08-24 15:32:57 -04:00
parent b52c0d1a2e
commit 75fea51712

View File

@ -34,8 +34,8 @@ struct BgConfig2
u32 unk_3:18;
void* tilemap;
u32 bg_x;
u32 bg_y;
s32 bg_x; // Maybe unsigned, but game treats it as if it is signed a lot
s32 bg_y; // Same for this variable.
};
static struct BgControl sGpuBgConfigs;
@ -698,8 +698,7 @@ s32 ChangeBgY(u8 bg, s32 value, u8 op)
s32 ChangeBgY_ScreenOff(u8 bg, u32 value, u8 op)
{
u8 mode;
u16 temp1;
u16 temp2;
u16 temp1, temp2;
if (IsInvalidBg32(bg) || !GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE))
{
@ -770,9 +769,8 @@ s32 GetBgY(u8 bg)
{
if (IsInvalidBg32(bg))
return -1;
else if (!GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE))
if (!GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE))
return -1;
else
return sGpuBgConfigs2[bg].bg_y;
}
@ -872,29 +870,28 @@ void* GetBgTilemapBuffer(u8 bg)
{
if (IsInvalidBg32(bg))
return NULL;
else if (!GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE))
if (!GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE))
return NULL;
else
return sGpuBgConfigs2[bg].tilemap;
}
void CopyToBgTilemapBuffer(u8 bg, const void *src, u16 mode, u16 destOffset)
{
if (!IsInvalidBg32(bg) && !IsTileMapOutsideWram(bg))
{
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)));
}
}
void CopyBgTilemapBufferToVram(u8 bg)
{
u16 sizeToLoad;
if (!IsInvalidBg32(bg) && !IsTileMapOutsideWram(bg))
{
if (IsInvalidBg32(bg) || IsTileMapOutsideWram(bg))
return;
switch (GetBgType(bg))
{
case 0:
@ -909,16 +906,14 @@ void CopyBgTilemapBufferToVram(u8 bg)
}
LoadBgVram(bg, sGpuBgConfigs2[bg].tilemap, sizeToLoad, 0, 2);
}
}
void CopyToBgTilemapBufferRect(u8 bg, const void *src, u8 destX, u8 destY, u8 width, u8 height)
{
u16 destX16;
u16 destY16;
u16 destX16, destY16;
u16 mode;
if (!IsInvalidBg32(bg) && !IsTileMapOutsideWram(bg))
{
if (IsInvalidBg32(bg) || IsTileMapOutsideWram(bg))
return;
switch (GetBgType(bg))
{
case 0:
@ -948,7 +943,6 @@ void CopyToBgTilemapBufferRect(u8 bg, const void* src, u8 destX, u8 destY, u8 wi
}
}
}
}
void CopyToBgTilemapBufferRect_ChangePalette(u8 bg, const void *src, u8 destX, u8 destY, u8 rectWidth, u8 rectHeight, u8 palette)
{