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