| 703 | } |
| 704 | |
| 705 | static void aptConvertScreenForCapture(void* dst, const void* src, u32 height, GSPGPU_FramebufferFormat format) |
| 706 | { |
| 707 | const u32 width = 240; |
| 708 | const u32 width_po2 = 1U << (32 - __builtin_clz(width-1)); // next_po2(240) = 256 |
| 709 | const u32 bpp = gspGetBytesPerPixel(format); |
| 710 | const u32 tilesize = 8*8*bpp; |
| 711 | |
| 712 | // Terrible conversion code that is also probably really slow |
| 713 | u8* out = (u8*)dst; |
| 714 | const u8* in = (u8*)src; |
| 715 | for (u32 tiley = 0; tiley < height; tiley += 8) |
| 716 | { |
| 717 | u32 tilex = 0; |
| 718 | for (tilex = 0; tilex < width; tilex += 8) |
| 719 | { |
| 720 | for (u32 y = 0; y < 8; y ++) |
| 721 | { |
| 722 | for (u32 x = 0; x < 8; x ++) |
| 723 | { |
| 724 | static const u8 morton_x[] = { 0x00, 0x01, 0x04, 0x05, 0x10, 0x11, 0x14, 0x15 }; |
| 725 | static const u8 morton_y[] = { 0x00, 0x02, 0x08, 0x0a, 0x20, 0x22, 0x28, 0x2a }; |
| 726 | unsigned inoff = bpp*(width*(tiley+y)+(tilex+x)); |
| 727 | unsigned outoff = bpp*(morton_x[x] + morton_y[y]); |
| 728 | for (u32 c = 0; c < bpp; c ++) |
| 729 | out[outoff+c] = in[inoff+c]; |
| 730 | } |
| 731 | } |
| 732 | out += tilesize; |
| 733 | } |
| 734 | for (; tilex < width_po2; tilex += 8) |
| 735 | out += tilesize; |
| 736 | } |
| 737 | } |
| 738 | |
| 739 | static void aptScreenTransfer(NS_APPID appId, bool sysApplet) |
| 740 | { |
no test coverage detected