Give sensical names to Unused_AdjustBgMosaic

This commit is contained in:
MCboy 2022-01-14 13:37:27 +03:30 committed by GitHub
parent fa2d25d366
commit 998900bd1b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;
switch (a2)
u8 Unused_AdjustBgMosaic(u8 val, u8 mode)
{
case 0:
u16 mosaic = GetGpuReg(REG_OFFSET_MOSAIC);
s16 bgH = mosaic & 0xF;
s16 bgV = (mosaic >> 4) & 0xF;
mosaic &= 0xFF00; // clear background mosaic sizes
switch (mode)
{
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)