@@ -258,22 +258,22 @@ void CTexture::MangleMipmap(u32 mip) {
258258 return ;
259259 }
260260
261- const uint colors[4 ] = {
262- 0x000000FF ,
263- 0x0000FF00 ,
264- 0x00FF0000 ,
265- 0x0000FFFF ,
266- };
261+ constexpr uint colors[4 ] = {
262+ 0x000000FF ,
263+ 0x0000FF00 ,
264+ 0x00FF0000 ,
265+ 0x0000FFFF ,
266+ };
267267 const uint color = colors[(mip - 1 ) & 3 ];
268- ushort rgb565Color = ((color >> 3 ) & 0x001F ) | // B
269- ((color >> 5 ) & 0x07E0 ) | // G
270- ((color >> 8 ) & 0xF800 ); // R
271- ushort rgb555Color = ((color >> 3 ) & 0x001F ) | // B
272- ((color >> 6 ) & 0x03E0 ) | // G
273- ((color >> 9 ) & 0x7C00 ); // R
274- ushort rgb4Color = ((color >> 4 ) & 0x000F ) | // B
275- ((color >> 8 ) & 0x00F0 ) | // G
276- ((color >> 12 ) & 0x0F00 ); // R
268+ const ushort rgb565Color = ((color >> 3 ) & 0x001F ) | // B
269+ ((color >> 5 ) & 0x07E0 ) | // G
270+ ((color >> 8 ) & 0xF800 ); // R
271+ const ushort rgb555Color = ((color >> 3 ) & 0x001F ) | // B
272+ ((color >> 6 ) & 0x03E0 ) | // G
273+ ((color >> 9 ) & 0x7C00 ); // R
274+ const ushort rgb4Color = ((color >> 4 ) & 0x000F ) | // B
275+ ((color >> 8 ) & 0x00F0 ) | // G
276+ ((color >> 12 ) & 0x0F00 ); // R
277277
278278 int width = GetWidth ();
279279 int height = GetHeight ();
@@ -287,15 +287,15 @@ void CTexture::MangleMipmap(u32 mip) {
287287
288288 switch (GetTexelFormat ()) {
289289 case ETexelFormat::RGB565: {
290- ushort* ptr = reinterpret_cast < ushort* >(x44_aramToken_x4_buff.get ());// mARAMToken.GetMRAMSafe());
290+ const auto ptr = reinterpret_cast <ushort*>(x44_aramToken_x4_buff.get ()); // mARAMToken.GetMRAMSafe());
291291 for (int i = 0 ; i < width * height; ++i) {
292292 ptr[i + offset] = rgb565Color;
293293 CBasics::Swap2Bytes (reinterpret_cast <u8 *>(&ptr[i + offset]));
294294 }
295295 break ;
296296 }
297297 case ETexelFormat::CMPR: {
298- ushort* ptr = reinterpret_cast < ushort* >(x44_aramToken_x4_buff.get ()) + offset / 4 ;
298+ auto ptr = reinterpret_cast <ushort*>(x44_aramToken_x4_buff.get ()) + offset / 4 ;
299299 for (int i = 0 ; i < width * height / 16 ; ++i, ptr += 4 ) {
300300 ptr[0 ] = rgb565Color;
301301 CBasics::Swap2Bytes (reinterpret_cast <u8 *>(&ptr[0 ]));
@@ -307,10 +307,11 @@ void CTexture::MangleMipmap(u32 mip) {
307307 break ;
308308 }
309309 case ETexelFormat::RGB5A3: {
310- ushort* ptr = reinterpret_cast < ushort* >(x44_aramToken_x4_buff.get ());
310+ const auto ptr = reinterpret_cast <ushort*>(x44_aramToken_x4_buff.get ());
311311 for (int i = 0 ; i < width * height; ++i) {
312312 ushort& val = ptr[i + offset];
313- if (val & 0x8000 ) {
313+ CBasics::Swap2Bytes (reinterpret_cast <u8 *>(&val));
314+ if ((val & 0x8000 ) != 0 ) {
314315 val = rgb555Color | 0x8000 ;
315316 } else {
316317 val = (val & 0xF000 ) | rgb4Color;
@@ -346,7 +347,7 @@ u32 CTexture::TexelFormatBitsPerPixel(ETexelFormat fmt) {
346347 }
347348}
348349
349- bool CTexture::sMangleMips = false ;
350+ bool CTexture::sMangleMips = true ;
350351u32 CTexture::sCurrentFrameCount = 0 ;
351352u32 CTexture::sTotalAllocatedMemory = 0 ;
352353
0 commit comments