Mercurial > public > hwos_code
comparison src/compass.c @ 621:1ad0531e9078
3.01 release
author | heinrichsweikamp |
---|---|
date | Sat, 23 Feb 2019 16:51:14 +0100 |
parents | cd986267a5ca |
children | c40025d8e750 |
comparison
equal
deleted
inserted
replaced
620:cd986267a5ca | 621:1ad0531e9078 |
---|---|
71 | 71 |
72 //---- Pre-scale both numerator and denominator -------------------------- | 72 //---- Pre-scale both numerator and denominator -------------------------- |
73 while( (((a>>8) | (b>>8)) & 0xC0) == 0 ) | 73 while( (((a>>8) | (b>>8)) & 0xC0) == 0 ) |
74 { | 74 { |
75 failsafe--; | 75 failsafe--; |
76 if (failsafe==0) break; | 76 if (failsafe==0) break; |
77 a <<= 1; | 77 a <<= 1; |
78 b <<= 1; | 78 b <<= 1; |
79 } | 79 } |
80 | 80 |
81 //---- Make division trials ---------------------------------------------- | 81 //---- Make division trials ---------------------------------------------- |
174 /// | 174 /// |
175 | 175 |
176 void sincos(PARAMETER Int16 x, PARAMETER Int16 y, Int16* sin, Int16* cos) | 176 void sincos(PARAMETER Int16 x, PARAMETER Int16 y, Int16* sin, Int16* cos) |
177 { | 177 { |
178 OVERLAY Int16 x2, y2, h2; | 178 OVERLAY Int16 x2, y2, h2; |
179 OVERLAY char failsafe = 250; | 179 OVERLAY char failsafe=250; |
180 | 180 |
181 //---- Fold into one quadant --------------------------------------------- | 181 //---- Fold into one quadant --------------------------------------------- |
182 OVERLAY char neg = 0; | 182 OVERLAY char neg = 0; |
183 if( x < 0 ) | 183 if( x < 0 ) |
184 { | 184 { |
185 neg |= 1; | 185 neg |= 1; |
188 if( y < 0 ) | 188 if( y < 0 ) |
189 { | 189 { |
190 neg |= 2; | 190 neg |= 2; |
191 y = -y; | 191 y = -y; |
192 } | 192 } |
193 | 193 |
194 //---- Pre-scale both numerator and denominator ---------------------- | 194 //---- Pre-scale both numerator and denominator ---------------------- |
195 while( (((x>>8) | (y>>8)) & 0xE0) == 0 ) | 195 while( (((x>>8) | (y>>8)) & 0xE0) == 0 ) |
196 { | 196 { |
197 failsafe--; | 197 failsafe--; |
198 if (failsafe == 0) break; | 198 if (failsafe==0) break; |
199 x <<= 1; | 199 x <<= 1; |
200 y <<= 1; | 200 y <<= 1; |
201 } | 201 } |
202 | 202 |
203 //---- Uses trig() to do the stuff one on quadrant ------------------- | 203 //---- Uses trig() to do the stuff one on quadrant ------------------- |