Merge pull request #1598 from atasro2/master

Give sensical names to Unused_AdjustBgMosaic
This commit is contained in:
GriffinR 2022-01-14 09:12:05 -05:00 committed by GitHub
commit 9ded1eb14e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 44 additions and 33 deletions

View File

@ -776,75 +776,75 @@ 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)
u8 Unused_AdjustBgMosaic(u8 val, u8 mode)
{
u16 result = GetGpuReg(REG_OFFSET_MOSAIC);
s16 test1 = result & 0xF;
s16 test2 = (result >> 4) & 0xF;
u16 mosaic = GetGpuReg(REG_OFFSET_MOSAIC);
s16 bgH = mosaic & 0xF;
s16 bgV = (mosaic >> 4) & 0xF;
result &= 0xFF00;
mosaic &= 0xFF00; // clear background mosaic sizes
switch (a2)
switch (mode)
{
case 0:
case BG_MOSAIC_SET_HV:
default:
test1 = a1 & 0xF;
test2 = a1 >> 0x4;
bgH = val & 0xF;
bgV = val >> 0x4;
break;
case 1:
test1 = a1 & 0xF;
case BG_MOSAIC_SET_H:
bgH = val & 0xF;
break;
case 2:
if ((test1 + a1) > 0xF)
case BG_MOSAIC_ADD_H:
if ((bgH + val) > 0xF)
{
test1 = 0xF;
bgH = 0xF;
}
else
{
test1 += a1;
bgH += val;
}
break;
case 3:
if ((test1 - a1) < 0)
case BG_MOSAIC_SUB_H:
if ((bgH - val) < 0)
{
test1 = 0x0;
bgH = 0x0;
}
else
{
test1 -= a1;
bgH -= val;
}
break;
case 4:
test2 = a1 & 0xF;
case BG_MOSAIC_SET_V:
bgV = val & 0xF;
break;
case 5:
if ((test2 + a1) > 0xF)
case BG_MOSAIC_ADD_V:
if ((bgV + val) > 0xF)
{
test2 = 0xF;
bgV = 0xF;
}
else
{
test2 += a1;
bgV += val;
}
break;
case 6:
if ((test2 - a1) < 0)
case BG_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)

View File

@ -28,6 +28,17 @@ enum {
BG_COORD_SUB,
};
// Modes for Unused_AdjustBgMosaic
enum {
BG_MOSAIC_SET_HV,
BG_MOSAIC_SET_H,
BG_MOSAIC_ADD_H,
BG_MOSAIC_SUB_H,
BG_MOSAIC_SET_V,
BG_MOSAIC_ADD_V,
BG_MOSAIC_SUB_V,
};
struct BgTemplate
{
u16 bg:2; // 0x1, 0x2 -> 0x3