| 202 | |
| 203 | template <u32 (*PalConvertFn)(u16)> |
| 204 | static void ConvertCI8T(const TileDestInfo & dsti, const TextureInfo & ti) |
| 205 | { |
| 206 | u32 width {dsti.Width}; |
| 207 | u32 height {dsti.Height}; |
| 208 | |
| 209 | u32 * dst {static_cast<u32*>(dsti.Data)}; |
| 210 | u32 dst_row_stride {dsti.Pitch / sizeof(u32)}; |
| 211 | u32 dst_row_offset {}; |
| 212 | |
| 213 | const u8 * src {gTMEM}; |
| 214 | const u16 * src16 {(u16*)src}; |
| 215 | |
| 216 | u32 src_row_stride {ti.GetLine()<<3}; |
| 217 | u32 src_row_offset {ti.GetTmemAddress()<<3}; |
| 218 | |
| 219 | // Convert the palette once, here. |
| 220 | u32 palette[256] {}; |
| 221 | for (u32 i {}; i < 256; ++i) |
| 222 | { |
| 223 | u16 src_pixel {src16[0x400+(i<<2)]}; |
| 224 | palette[i] = PalConvertFn(src_pixel); |
| 225 | } |
| 226 | |
| 227 | u32 row_swizzle {}; |
| 228 | for (u32 y {}; y < height; ++y) |
| 229 | { |
| 230 | u32 src_offset {src_row_offset}; |
| 231 | u32 dst_offset {dst_row_offset}; |
| 232 | for (u32 x {}; x < width; ++x) |
| 233 | { |
| 234 | u8 src_pixel {src[src_offset^row_swizzle]}; |
| 235 | |
| 236 | dst[dst_offset+0] = palette[src_pixel]; |
| 237 | |
| 238 | src_offset += 1; |
| 239 | dst_offset += 1; |
| 240 | } |
| 241 | src_row_offset += src_row_stride; |
| 242 | dst_row_offset += dst_row_stride; |
| 243 | |
| 244 | row_swizzle ^= 0x4; // Alternate lines are word-swapped |
| 245 | } |
| 246 | } |
| 247 | |
| 248 | template <u32 (*PalConvertFn)(u16)> |
| 249 | static void ConvertCI4T(const TileDestInfo & dsti, const TextureInfo & ti) |
nothing calls this directly
no test coverage detected