GFX3D: Fix clear color on big-endian systems. (Regression from commit 97848fc.)

This commit is contained in:
rogerman 2023-02-28 01:34:27 -08:00
parent dcd1072800
commit 90c8411cbf
2 changed files with 24 additions and 4 deletions

View File

@ -3665,22 +3665,22 @@ void FASTCALL _MMU_ARM9_write08(u32 adr, u8 val)
case REG_IF+3: REG_IF_WriteByte<ARMCPU_ARM9>(3,val); break;
case eng_3D_CLEAR_COLOR:
HostWriteByte(MMU.ARM9_REG, 0x0350, val);
T1WriteByte(MMU.ARM9_REG, 0x0350, val);
gfx3d_glClearColor<u8>(0, val);
return;
case eng_3D_CLEAR_COLOR+1:
HostWriteByte(MMU.ARM9_REG, 0x0351, val);
T1WriteByte(MMU.ARM9_REG, 0x0351, val);
gfx3d_glClearColor<u8>(1, val);
return;
case eng_3D_CLEAR_COLOR+2:
HostWriteByte(MMU.ARM9_REG, 0x0352, val);
T1WriteByte(MMU.ARM9_REG, 0x0352, val);
gfx3d_glClearColor<u8>(2, val);
return;
case eng_3D_CLEAR_COLOR+3:
HostWriteByte(MMU.ARM9_REG, 0x0353, val);
T1WriteByte(MMU.ARM9_REG, 0x0353, val);
gfx3d_glClearColor<u8>(3, val);
return;

View File

@ -2809,7 +2809,27 @@ void gfx3d_glFogOffset(const u32 v)
template <typename T>
void gfx3d_glClearColor(const u8 offset, const T v)
{
#ifndef MSB_FIRST
((T *)&gfx3d.pendingState.clearColor)[offset >> (sizeof(T) >> 1)] = v;
#else
switch (sizeof(T))
{
case 1:
((T *)&gfx3d.pendingState.clearColor)[offset >> (sizeof(T) >> 1)] = v;
break;
case 2:
((T *)&gfx3d.pendingState.clearColor)[offset >> (sizeof(T) >> 1)] = LE_TO_LOCAL_16(v);
break;
case 4:
((T *)&gfx3d.pendingState.clearColor)[offset >> (sizeof(T) >> 1)] = LE_TO_LOCAL_32(v);
break;
default:
break;
}
#endif
}
template void gfx3d_glClearColor< u8>(const u8 offset, const u8 v);