skinpeel

Change vita's lockscreen foreground and background randomly
git clone https://git.neptards.moe/neptards/skinpeel.git
Log | Files | Refs | README | LICENSE

common.h (1368B)


      1 #ifndef GUARD_OPPOSABLY_UNRETICENT_POGAMOGGAN_UNMAIDENS_2195
      2 #define GUARD_OPPOSABLY_UNRETICENT_POGAMOGGAN_UNMAIDENS_2195
      3 #pragma once
      4 
      5 #include <stddef.h>
      6 #include <stdint.h>
      7 
      8 // wine/dlls/windowscodecs/ddsformat.c
      9 // I'm sure you can find it somewhere in microsoft's uberbloat sdks somewhere...
     10 typedef struct
     11 {
     12   uint32_t size;
     13   uint32_t flags;
     14   char four_cc[4];
     15   uint32_t rgb_bit_count;
     16   uint32_t r_bit_mask;
     17   uint32_t g_bit_mask;
     18   uint32_t b_bit_mask;
     19   uint32_t a_bit_mask;
     20 } DDS_PIXELFORMAT;
     21 
     22 typedef struct
     23 {
     24   char magic[4];
     25 
     26   uint32_t size;
     27   uint32_t flags;
     28   uint32_t height;
     29   uint32_t width;
     30   uint32_t pitch_or_linear_size;
     31   uint32_t depth;
     32   uint32_t mip_map_count;
     33   uint32_t reserved1[11];
     34   DDS_PIXELFORMAT ddspf;
     35   uint32_t caps;
     36   uint32_t caps2;
     37   uint32_t caps3;
     38   uint32_t caps4;
     39   uint32_t reserved2;
     40 } DDS;
     41 
     42 static void swizzle_1024_512(size_t i, size_t* x, size_t* y)
     43 {
     44   // https://fgiesen.wordpress.com/2009/12/13/decoding-morton-codes/
     45   // modified to 1024x512
     46   size_t srcx = (i >> 1) & 0x1555;
     47   srcx = (srcx ^ (srcx >> 1)) & 0x3333;
     48   srcx = (srcx ^ (srcx >> 2)) & 0x0f0f;
     49   srcx = (srcx ^ (srcx >> 4)) & 0x00ff;
     50   srcx |= (i & 0x4000) >> 7;
     51 
     52   size_t srcy = i & 0x1555;
     53   srcy = (srcy ^ (srcy >> 1)) & 0x3333;
     54   srcy = (srcy ^ (srcy >> 2)) & 0x0f0f;
     55   srcy = (srcy ^ (srcy >> 4)) & 0x00ff;
     56 
     57   *x = srcx; *y = srcy;
     58 }
     59 
     60 #endif