@@ -19,18 +19,16 @@ unsigned char *loadtext(char *name, int *number){
19
19
sz += 300 ;
20
20
res = realloc (res , sz * sizeof (char ));
21
21
}
22
- bool bb = x < 0 ;
23
- if (bb )
24
- x = - x ;
25
- res [num + 2 ] = (x << 9 ) >> 25 ;
26
- res [num + 2 ] |= (bb << 7 );
22
+ if (x < 0 ){
23
+ x = (~(unsigned int )(- x ) + 1 );
24
+ }
25
+ if (y < 0 ){
26
+ y = (~(unsigned int )(- y ) + 1 );
27
+ }
28
+ res [num + 2 ] = (x << 8 ) >> 24 ;
27
29
res [num + 1 ] = (x << 16 ) >> 24 ;
28
30
res [num ] = (x << 24 ) >> 24 ;
29
- bb = y < 0 ;
30
- if (bb )
31
- y = - y ;
32
- res [num + 5 ] = (y << 9 ) >> 25 ;
33
- res [num + 5 ] |= (bb << 7 );
31
+ res [num + 5 ] = (y << 8 ) >> 24 ;
34
32
res [num + 4 ] = (y << 16 ) >> 24 ;
35
33
res [num + 3 ] = (y << 24 ) >> 24 ;
36
34
num += 6 ;
@@ -65,13 +63,11 @@ void savetext(char *name, unsigned char *arr, int num){
65
63
for (int i = 0 ; i < num ; i += 6 ){
66
64
x = arr [i ] + (arr [i + 1 ] << 8 ) + (arr [i + 2 ] << 16 );
67
65
if ((x & (1 << 23 )) != 0 ){
68
- x ^= (1 << 23 );
69
- x = - x ;
66
+ x = - (((~(unsigned int )x + 1 ) << 8 ) >> 8 );
70
67
}
71
68
y = arr [i + 3 ] + (arr [i + 4 ] << 8 ) + (arr [i + 5 ] << 16 );
72
69
if ((y & (1 << 23 )) != 0 ){
73
- y ^= (1 << 23 );
74
- y = - y ;
70
+ y = - (((~(unsigned int )y + 1 ) << 8 ) >> 8 );
75
71
}
76
72
fprintf (f , "%d %d\n" , x , y );
77
73
}
@@ -106,15 +102,13 @@ void apply(struct intrusive_list *l, void (*op)(struct position_node*, void*), v
106
102
void make (struct intrusive_list * l , unsigned char * arr , int num ){
107
103
int x , y ;
108
104
for (int i = num - 6 ; i >= 0 ; i -= 6 ){
109
- x = arr [i ] + (arr [i + 1 ] << 8 ) + (arr [i + 2 ] << 16 );
105
+ x = arr [i ] + (arr [i + 1 ] << 8 ) + (arr [i + 2 ] << 16 );
110
106
if ((x & (1 << 23 )) != 0 ){
111
- x ^= (1 << 23 );
112
- x = - x ;
107
+ x = - (((~(unsigned int )x + 1 ) << 8 ) >> 8 );
113
108
}
114
109
y = arr [i + 3 ] + (arr [i + 4 ] << 8 ) + (arr [i + 5 ] << 16 );
115
110
if ((y & (1 << 23 )) != 0 ){
116
- y ^= (1 << 23 );
117
- y = - y ;
111
+ y = - (((~(unsigned int )y + 1 ) << 8 ) >> 8 );
118
112
}
119
113
add_position (l , x , y );
120
114
}
0 commit comments