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); SetBgAffineInternal(bg, srcCenterX, srcCenterY, dispCenterX, dispCenterY, scaleX, scaleY, rotationAngle);
} }
u8 Unused_AdjustBgMosaic(u8 a1, u8 a2) enum
{ {
u16 result = GetGpuReg(REG_OFFSET_MOSAIC); MOSAIC_SET_HV,
s16 test1 = result & 0xF; MOSAIC_SET_H,
s16 test2 = (result >> 4) & 0xF; 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: default:
test1 = a1 & 0xF; bgH = val & 0xF;
test2 = a1 >> 0x4; bgV = val >> 0x4;
break; break;
case 1: case MOSAIC_SET_H:
test1 = a1 & 0xF; bgH = val & 0xF;
break; break;
case 2: case MOSAIC_ADD_H:
if ((test1 + a1) > 0xF) if ((bgH + val) > 0xF)
{ {
test1 = 0xF; bgH = 0xF;
} }
else else
{ {
test1 += a1; bgH += val;
} }
break; break;
case 3: case MOSAIC_SUB_H:
if ((test1 - a1) < 0) if ((bgH - val) < 0)
{ {
test1 = 0x0; bgH = 0x0;
} }
else else
{ {
test1 -= a1; bgH -= val;
} }
break; break;
case 4: case MOSAIC_SET_V:
test2 = a1 & 0xF; bgV = val & 0xF;
break; break;
case 5: case MOSAIC_ADD_V:
if ((test2 + a1) > 0xF) if ((bgV + val) > 0xF)
{ {
test2 = 0xF; bgV = 0xF;
} }
else else
{ {
test2 += a1; bgV += val;
} }
break; break;
case 6: case MOSAIC_SUB_V:
if ((test2 - a1) < 0) if ((bgV - val) < 0)
{ {
test2 = 0x0; bgV = 0x0;
} }
else else
{ {
test2 -= a1; bgV -= val;
} }
break; break;
} }
result |= ((test2 << 0x4) & 0xF0); mosaic |= ((bgV << 0x4) & 0xF0);
result |= (test1 & 0xF); mosaic |= (bgH & 0xF);
SetGpuReg(REG_OFFSET_MOSAIC, result); SetGpuReg(REG_OFFSET_MOSAIC, mosaic);
return result; return mosaic;
} }
void SetBgTilemapBuffer(u8 bg, void *tilemap) void SetBgTilemapBuffer(u8 bg, void *tilemap)