MCPcopy Create free account
hub / github.com/DaedalusX64/daedalus / ConvertIA4

Function ConvertIA4

Source/HLEGraphics/ConvertTile.cpp:424–471  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

422}
423
424static void ConvertIA4(const TileDestInfo & dsti, const TextureInfo & ti)
425{
426 u32 width {dsti.Width};
427 u32 height {dsti.Height};
428
429 u32 * dst {static_cast<u32*>(dsti.Data)};
430 u32 dst_row_stride {dsti.Pitch / sizeof(u32)};
431 u32 dst_row_offset {};
432
433 const u8 * src {gTMEM};
434 u32 src_row_stride {ti.GetLine()<<3};
435 u32 src_row_offset {ti.GetTmemAddress()<<3};
436
437 u32 row_swizzle {};
438 for (u32 y {}; y < height; ++y)
439 {
440 u32 src_offset {src_row_offset};
441 u32 dst_offset {dst_row_offset};
442
443 // Process 2 pixels at a time
444 for (u32 x {}; x+1 < width; x += 2)
445 {
446 u8 src_pixel {src[src_offset^row_swizzle]};
447
448 dst[dst_offset+0] = IA4(src_pixel>>4);
449 dst[dst_offset+1] = IA4((src_pixel&0xf));
450
451 src_offset += 1;
452 dst_offset += 2;
453 }
454
455 // Handle trailing pixel, if odd width
456 if (width&1)
457 {
458 u8 src_pixel {src[src_offset^row_swizzle]};
459
460 dst[dst_offset+0] = IA4(src_pixel>>4);
461
462 src_offset += 1;
463 dst_offset += 1;
464 }
465
466 src_row_offset += src_row_stride;
467 dst_row_offset += dst_row_stride;
468
469 row_swizzle ^= 0x4; // Alternate lines are word-swapped
470 }
471}
472
473static void ConvertI8(const TileDestInfo & dsti, const TextureInfo & ti)
474{

Callers

nothing calls this directly

Calls 3

IA4Function · 0.85
GetLineMethod · 0.80
GetTmemAddressMethod · 0.80

Tested by

no test coverage detected