File tree Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -44,15 +44,18 @@ int read_bit(uint8_t *data) {
44
44
}
45
45
46
46
void transpose_tiles (uint8_t * data , int width ) {
47
- int size = width * width * 0x10 ;
48
- uint8_t * transposed = xmalloc (size );
47
+ int size = width * width ;
49
48
for (int i = 0 ; i < size ; i ++ ) {
50
- int j = (i / 0x10 ) * width * 0x10 ;
51
- j = (j % size ) + 0x10 * (j / size ) + (i % 0x10 );
52
- transposed [j ] = data [i ];
49
+ int j = (i * width + i / width ) % size ;
50
+ if (i < j ) {
51
+ uint8_t tmp [0x10 ];
52
+ uint8_t * p = data + i * COUNTOF (tmp );
53
+ uint8_t * q = data + j * COUNTOF (tmp );
54
+ memcpy (tmp , p , COUNTOF (tmp ));
55
+ memcpy (p , q , COUNTOF (tmp ));
56
+ memcpy (q , tmp , COUNTOF (tmp ));
57
+ }
53
58
}
54
- memcpy (data , transposed , size );
55
- free (transposed );
56
59
}
57
60
58
61
void compress_plane (uint8_t * plane , int width ) {
You can’t perform that action at this time.
0 commit comments