If your interested in the in the textures internal format. I had to directly access textures for scale2x in gameyob. Steveice implemented an index remapping tool in CTRCommon which you can find here.Sorry, I forgot to post the final code for this for anyone who can need it
Code:void ReorderImageData(u8* src, u8* palette, u8* dst, int width, int height, void(copyFunc)(u8*, u8*, int, u8*, int)) { static int tile_order[] = { 0, 1, 8, 9, 2, 3, 10, 11, 16, 17, 24, 25, 18, 19, 26, 27, 4, 5, 12, 13, 6, 7, 14, 15, 20, 21, 28, 29, 22, 23, 30, 31, 32, 33, 40, 41, 34, 35, 42, 43, 48, 49, 56, 57, 50, 51, 58, 59, 36, 37, 44, 45, 38, 39, 46, 47, 52, 53, 60, 61, 54, 55, 62, 63 }; int idx = 0; int i, j; for(int y = 0; y < height; y += 8) { for(int x = 0; x < width; x += 8) { for(int k = 0; k < 64; ++ k) { i = (tile_order[k] % 8); j = (tile_order[k] - i) / 8; int src_idx = (height - (y + j) - 1) * width + (x + i); copyFunc(src, palette, src_idx, dst, idx); idx ++; } } } }
where copyFunc is a pointer to a function similiar to these
Code:void copyRGB(u8* src, u8* palette, int src_idx, u8* dst, int dst_idx) { dst[dst_idx * 3 + 0] = src[src_idx * 3 + 2]; dst[dst_idx * 3 + 1] = src[src_idx * 3 + 1]; dst[dst_idx * 3 + 2] = src[src_idx * 3 + 0]; } void copyRGBA(u8* src, u8* palette, int src_idx, u8* dst, int dst_idx) { dst[dst_idx * 4 + 0] = src[src_idx * 4 + 3]; dst[dst_idx * 4 + 1] = src[src_idx * 4 + 2]; dst[dst_idx * 4 + 2] = src[src_idx * 4 + 1]; dst[dst_idx * 4 + 3] = src[src_idx * 4 + 0]; }
But in short this is one way to implement accessing the internal format.
Code:
inline u32 gpuTextureIndex(u32 x, u32 y, u32 w, u32 h) {
return (((y >> 3) * (w >> 3) + (x >> 3)) << 6) + ((x & 1) | ((y & 1) << 1) | ((x & 2) << 1) | ((y & 2) << 2) | ((x & 4) << 2) | ((y & 4) << 3));
}