From 998900bd1b8394edaeafe7c32debcda62cf06561 Mon Sep 17 00:00:00 2001 From: MCboy <16516292+atasro2@users.noreply.github.com> Date: Fri, 14 Jan 2022 13:37:27 +0330 Subject: [PATCH] Give sensical names to Unused_AdjustBgMosaic --- gflib/bg.c | 77 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 44 insertions(+), 33 deletions(-) diff --git a/gflib/bg.c b/gflib/bg.c index c3a4be1d46..eb00fa7c79 100644 --- a/gflib/bg.c +++ b/gflib/bg.c @@ -776,75 +776,86 @@ void SetBgAffine(u8 bg, s32 srcCenterX, s32 srcCenterY, s16 dispCenterX, s16 dis SetBgAffineInternal(bg, srcCenterX, srcCenterY, dispCenterX, dispCenterY, scaleX, scaleY, rotationAngle); } -u8 Unused_AdjustBgMosaic(u8 a1, u8 a2) +enum { - u16 result = GetGpuReg(REG_OFFSET_MOSAIC); - s16 test1 = result & 0xF; - s16 test2 = (result >> 4) & 0xF; + MOSAIC_SET_HV, + MOSAIC_SET_H, + MOSAIC_ADD_H, + MOSAIC_SUB_H, + MOSAIC_SET_V, + MOSAIC_ADD_V, + MOSAIC_SUB_V, +}; - result &= 0xFF00; +u8 Unused_AdjustBgMosaic(u8 val, u8 mode) +{ + u16 mosaic = GetGpuReg(REG_OFFSET_MOSAIC); + s16 bgH = mosaic & 0xF; + s16 bgV = (mosaic >> 4) & 0xF; - switch (a2) + mosaic &= 0xFF00; // clear background mosaic sizes + + switch (mode) { - case 0: + case MOSAIC_SET_HV: default: - test1 = a1 & 0xF; - test2 = a1 >> 0x4; + bgH = val & 0xF; + bgV = val >> 0x4; break; - case 1: - test1 = a1 & 0xF; + case MOSAIC_SET_H: + bgH = val & 0xF; break; - case 2: - if ((test1 + a1) > 0xF) + case MOSAIC_ADD_H: + if ((bgH + val) > 0xF) { - test1 = 0xF; + bgH = 0xF; } else { - test1 += a1; + bgH += val; } break; - case 3: - if ((test1 - a1) < 0) + case MOSAIC_SUB_H: + if ((bgH - val) < 0) { - test1 = 0x0; + bgH = 0x0; } else { - test1 -= a1; + bgH -= val; } break; - case 4: - test2 = a1 & 0xF; + case MOSAIC_SET_V: + bgV = val & 0xF; break; - case 5: - if ((test2 + a1) > 0xF) + case MOSAIC_ADD_V: + if ((bgV + val) > 0xF) { - test2 = 0xF; + bgV = 0xF; } else { - test2 += a1; + bgV += val; } break; - case 6: - if ((test2 - a1) < 0) + case MOSAIC_SUB_V: + if ((bgV - val) < 0) { - test2 = 0x0; + bgV = 0x0; } else { - test2 -= a1; + bgV -= val; } break; } - result |= ((test2 << 0x4) & 0xF0); - result |= (test1 & 0xF); + mosaic |= ((bgV << 0x4) & 0xF0); + mosaic |= (bgH & 0xF); - SetGpuReg(REG_OFFSET_MOSAIC, result); + SetGpuReg(REG_OFFSET_MOSAIC, mosaic); - return result; + return mosaic; } void SetBgTilemapBuffer(u8 bg, void *tilemap)