diff options
author | aaaaaa123456789 <aaaaaa123456789@acidch.at> | 2020-09-13 04:22:50 -0300 |
---|---|---|
committer | aaaaaa123456789 <aaaaaa123456789@acidch.at> | 2020-09-13 06:30:55 -0300 |
commit | 7dc95a0103af08c95c9093b6efa6c77af77a2538 (patch) | |
tree | 663537916626ab264bbdef4ea3606415457c36a3 /gflib/bg.c | |
parent | 58a2b62bae1406d2c768698ed13efcd6a5ffbeec (diff) |
Undo PokeCodec's PRs
This commit undoes most of PokeCodec's PRs after the debate in chat. Some
harmless or completely superseded PRs have been left alone, as there is not
much benefit in attempting to undo them.
Reverts #1104, #1108, #1115, #1118, #1119, #1124, #1126, #1127, #1132, #1136,
#1137, #1139, #1140, #1144, #1148, #1149, #1150, #1153, #1155, #1177, #1179,
#1180, #1181, #1182 and #1183.
Diffstat (limited to 'gflib/bg.c')
-rw-r--r-- | gflib/bg.c | 112 |
1 files changed, 60 insertions, 52 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; - } } } |