#include "utils.h" static const float costbl[360]={1,0.99984769515639,0.9993908270191,0.99862953475457,0.99756405025982,0.99619469809175,0.99452189536827,0.99254615164132,0.99026806874157,0.98768834059514,0.98480775301221,0.98162718344766,0.97814760073381,0.97437006478524,0.970295726276,0.96592582628907,0.96126169593832,0.95630475596304,0.95105651629515,0.94551857559932,0.93969262078591,0.9335804264972,0.92718385456679,0.92050485345244,0.9135454576426,0.90630778703665,0.89879404629917,0.89100652418837,0.88294759285893,0.8746197071394,0.86602540378444,0.85716730070211,0.84804809615643,0.83867056794542,0.82903757255504,0.81915204428899,0.80901699437495,0.79863551004729,0.78801075360672,0.77714596145697,0.76604444311898,0.75470958022277,0.74314482547739,0.73135370161917,0.71933980033865,0.70710678118655,0.694658370459,0.6819983600625,0.66913060635886,0.65605902899051,0.64278760968654,0.62932039104984,0.61566147532566,0.60181502315205,0.58778525229247,0.57357643635105,0.55919290347075,0.54463903501503,0.5299192642332,0.51503807491005,0.5,0.48480962024634,0.46947156278589,0.45399049973955,0.43837114678908,0.4226182617407,0.4067366430758,0.39073112848927,0.37460659341591,0.3583679495453,0.34202014332567,0.32556815445716,0.30901699437495,0.29237170472274,0.275637355817,0.25881904510252,0.24192189559967,0.22495105434386,0.20791169081776,0.19080899537654,0.17364817766693,0.15643446504023,0.13917310096007,0.12186934340515,0.10452846326765,0.087155742747658,0.069756473744125,0.052335956242944,0.034899496702501,0.017452406437283,6.1230317691119e-17,-0.017452406437283,-0.034899496702501,-0.052335956242944,-0.069756473744125,-0.087155742747658,-0.10452846326765,-0.12186934340515,-0.13917310096007,-0.15643446504023,-0.17364817766693,-0.19080899537654,-0.20791169081776,-0.22495105434386,-0.24192189559967,-0.25881904510252,-0.275637355817,-0.29237170472274,-0.30901699437495,-0.32556815445716,-0.34202014332567,-0.3583679495453,-0.37460659341591,-0.39073112848927,-0.4067366430758,-0.4226182617407,-0.43837114678908,-0.45399049973955,-0.46947156278589,-0.48480962024634,-0.5,-0.51503807491005,-0.5299192642332,-0.54463903501503,-0.55919290347075,-0.57357643635105,-0.58778525229247,-0.60181502315205,-0.61566147532566,-0.62932039104984,-0.64278760968654,-0.65605902899051,-0.66913060635886,-0.6819983600625,-0.694658370459,-0.70710678118655,-0.71933980033865,-0.73135370161917,-0.74314482547739,-0.75470958022277,-0.76604444311898,-0.77714596145697,-0.78801075360672,-0.79863551004729,-0.80901699437495,-0.81915204428899,-0.82903757255504,-0.83867056794542,-0.84804809615643,-0.85716730070211,-0.86602540378444,-0.8746197071394,-0.88294759285893,-0.89100652418837,-0.89879404629917,-0.90630778703665,-0.9135454576426,-0.92050485345244,-0.92718385456679,-0.9335804264972,-0.93969262078591,-0.94551857559932,-0.95105651629515,-0.95630475596304,-0.96126169593832,-0.96592582628907,-0.970295726276,-0.97437006478524,-0.97814760073381,-0.98162718344766,-0.98480775301221,-0.98768834059514,-0.99026806874157,-0.99254615164132,-0.99452189536827,-0.99619469809175,-0.99756405025982,-0.99862953475457,-0.9993908270191,-0.99984769515639,-1,-0.99984769515639,-0.9993908270191,-0.99862953475457,-0.99756405025982,-0.99619469809175,-0.99452189536827,-0.99254615164132,-0.99026806874157,-0.98768834059514,-0.98480775301221,-0.98162718344766,-0.97814760073381,-0.97437006478524,-0.970295726276,-0.96592582628907,-0.96126169593832,-0.95630475596304,-0.95105651629515,-0.94551857559932,-0.93969262078591,-0.9335804264972,-0.92718385456679,-0.92050485345244,-0.9135454576426,-0.90630778703665,-0.89879404629917,-0.89100652418837,-0.88294759285893,-0.8746197071394,-0.86602540378444,-0.85716730070211,-0.84804809615643,-0.83867056794542,-0.82903757255504,-0.81915204428899,-0.80901699437495,-0.79863551004729,-0.78801075360672,-0.77714596145697,-0.76604444311898,-0.75470958022277,-0.74314482547739,-0.73135370161917,-0.71933980033865,-0.70710678118655,-0.694658370459,-0.6819983600625,-0.66913060635886,-0.65605902899051,-0.64278760968654,-0.62932039104984,-0.61566147532566,-0.60181502315205,-0.58778525229247,-0.57357643635105,-0.55919290347075,-0.54463903501503,-0.52991926423321,-0.51503807491005,-0.5,-0.48480962024634,-0.46947156278589,-0.45399049973955,-0.43837114678908,-0.4226182617407,-0.4067366430758,-0.39073112848927,-0.37460659341591,-0.3583679495453,-0.34202014332567,-0.32556815445716,-0.30901699437495,-0.29237170472274,-0.275637355817,-0.25881904510252,-0.24192189559967,-0.22495105434387,-0.20791169081776,-0.19080899537655,-0.17364817766693,-0.15643446504023,-0.13917310096006,-0.12186934340515,-0.10452846326765,-0.087155742747658,-0.069756473744126,-0.052335956242944,-0.034899496702502,-0.017452406437283,-1.8369095307336e-16,0.017452406437283,0.034899496702501,0.052335956242944,0.069756473744125,0.087155742747658,0.10452846326765,0.12186934340515,0.13917310096007,0.15643446504023,0.17364817766693,0.19080899537654,0.20791169081776,0.22495105434386,0.24192189559967,0.25881904510252,0.275637355817,0.29237170472274,0.30901699437495,0.32556815445716,0.34202014332567,0.3583679495453,0.37460659341591,0.39073112848927,0.4067366430758,0.4226182617407,0.43837114678908,0.45399049973955,0.46947156278589,0.48480962024634,0.5,0.51503807491005,0.5299192642332,0.54463903501503,0.55919290347075,0.57357643635105,0.58778525229247,0.60181502315205,0.61566147532566,0.62932039104984,0.64278760968654,0.65605902899051,0.66913060635886,0.6819983600625,0.694658370459,0.70710678118655,0.71933980033865,0.73135370161917,0.74314482547739,0.75470958022277,0.76604444311898,0.77714596145697,0.78801075360672,0.79863551004729,0.80901699437495,0.81915204428899,0.82903757255504,0.83867056794542,0.84804809615643,0.85716730070211,0.86602540378444,0.8746197071394,0.88294759285893,0.89100652418837,0.89879404629917,0.90630778703665,0.9135454576426,0.92050485345244,0.92718385456679,0.9335804264972,0.93969262078591,0.94551857559932,0.95105651629515,0.95630475596304,0.96126169593832,0.96592582628907,0.970295726276,0.97437006478524,0.97814760073381,0.98162718344766,0.98480775301221,0.98768834059514,0.99026806874157,0.99254615164132,0.99452189536827,0.99619469809175,0.99756405025982,0.99862953475457,0.9993908270191,0.99984769515639}; static const float sintbl[360]={0,0.017452406437284,0.034899496702501,0.052335956242944,0.069756473744125,0.087155742747658,0.10452846326765,0.12186934340515,0.13917310096007,0.15643446504023,0.17364817766693,0.19080899537654,0.20791169081776,0.22495105434387,0.24192189559967,0.25881904510252,0.275637355817,0.29237170472274,0.30901699437495,0.32556815445716,0.34202014332567,0.3583679495453,0.37460659341591,0.39073112848927,0.4067366430758,0.4226182617407,0.43837114678908,0.45399049973955,0.46947156278589,0.48480962024634,0.5,0.51503807491005,0.5299192642332,0.54463903501503,0.55919290347075,0.57357643635105,0.58778525229247,0.60181502315205,0.61566147532566,0.62932039104984,0.64278760968654,0.65605902899051,0.66913060635886,0.6819983600625,0.694658370459,0.70710678118655,0.71933980033865,0.73135370161917,0.74314482547739,0.75470958022277,0.76604444311898,0.77714596145697,0.78801075360672,0.79863551004729,0.80901699437495,0.81915204428899,0.82903757255504,0.83867056794542,0.84804809615643,0.85716730070211,0.86602540378444,0.8746197071394,0.88294759285893,0.89100652418837,0.89879404629917,0.90630778703665,0.9135454576426,0.92050485345244,0.92718385456679,0.9335804264972,0.93969262078591,0.94551857559932,0.95105651629515,0.95630475596304,0.96126169593832,0.96592582628907,0.970295726276,0.97437006478524,0.97814760073381,0.98162718344766,0.98480775301221,0.98768834059514,0.99026806874157,0.99254615164132,0.99452189536827,0.99619469809175,0.99756405025982,0.99862953475457,0.9993908270191,0.99984769515639,1,0.99984769515639,0.9993908270191,0.99862953475457,0.99756405025982,0.99619469809175,0.99452189536827,0.99254615164132,0.99026806874157,0.98768834059514,0.98480775301221,0.98162718344766,0.97814760073381,0.97437006478524,0.970295726276,0.96592582628907,0.96126169593832,0.95630475596304,0.95105651629515,0.94551857559932,0.93969262078591,0.9335804264972,0.92718385456679,0.92050485345244,0.9135454576426,0.90630778703665,0.89879404629917,0.89100652418837,0.88294759285893,0.8746197071394,0.86602540378444,0.85716730070211,0.84804809615643,0.83867056794542,0.82903757255504,0.81915204428899,0.80901699437495,0.79863551004729,0.78801075360672,0.77714596145697,0.76604444311898,0.75470958022277,0.74314482547739,0.73135370161917,0.71933980033865,0.70710678118655,0.694658370459,0.6819983600625,0.66913060635886,0.65605902899051,0.64278760968654,0.62932039104984,0.61566147532566,0.60181502315205,0.58778525229247,0.57357643635105,0.55919290347075,0.54463903501503,0.5299192642332,0.51503807491005,0.5,0.48480962024634,0.46947156278589,0.45399049973955,0.43837114678908,0.4226182617407,0.4067366430758,0.39073112848927,0.37460659341591,0.3583679495453,0.34202014332567,0.32556815445716,0.30901699437495,0.29237170472274,0.275637355817,0.25881904510252,0.24192189559967,0.22495105434386,0.20791169081776,0.19080899537654,0.17364817766693,0.15643446504023,0.13917310096007,0.12186934340515,0.10452846326765,0.087155742747659,0.069756473744126,0.052335956242944,0.034899496702501,0.017452406437283,1.2246063538224e-16,-0.017452406437283,-0.034899496702501,-0.052335956242944,-0.069756473744125,-0.087155742747658,-0.10452846326765,-0.12186934340515,-0.13917310096007,-0.15643446504023,-0.17364817766693,-0.19080899537654,-0.20791169081776,-0.22495105434386,-0.24192189559967,-0.25881904510252,-0.275637355817,-0.29237170472274,-0.30901699437495,-0.32556815445716,-0.34202014332567,-0.3583679495453,-0.37460659341591,-0.39073112848927,-0.4067366430758,-0.4226182617407,-0.43837114678908,-0.45399049973955,-0.46947156278589,-0.48480962024634,-0.5,-0.51503807491005,-0.5299192642332,-0.54463903501503,-0.55919290347075,-0.57357643635105,-0.58778525229247,-0.60181502315205,-0.61566147532566,-0.62932039104984,-0.64278760968654,-0.65605902899051,-0.66913060635886,-0.6819983600625,-0.694658370459,-0.70710678118655,-0.71933980033865,-0.73135370161917,-0.74314482547739,-0.75470958022277,-0.76604444311898,-0.77714596145697,-0.78801075360672,-0.79863551004729,-0.80901699437495,-0.81915204428899,-0.82903757255504,-0.83867056794542,-0.84804809615643,-0.85716730070211,-0.86602540378444,-0.8746197071394,-0.88294759285893,-0.89100652418837,-0.89879404629917,-0.90630778703665,-0.9135454576426,-0.92050485345244,-0.92718385456679,-0.9335804264972,-0.93969262078591,-0.94551857559932,-0.95105651629515,-0.95630475596304,-0.96126169593832,-0.96592582628907,-0.970295726276,-0.97437006478524,-0.97814760073381,-0.98162718344766,-0.98480775301221,-0.98768834059514,-0.99026806874157,-0.99254615164132,-0.99452189536827,-0.99619469809175,-0.99756405025982,-0.99862953475457,-0.9993908270191,-0.99984769515639,-1,-0.99984769515639,-0.9993908270191,-0.99862953475457,-0.99756405025982,-0.99619469809175,-0.99452189536827,-0.99254615164132,-0.99026806874157,-0.98768834059514,-0.98480775301221,-0.98162718344766,-0.97814760073381,-0.97437006478524,-0.970295726276,-0.96592582628907,-0.96126169593832,-0.95630475596304,-0.95105651629515,-0.94551857559932,-0.93969262078591,-0.9335804264972,-0.92718385456679,-0.92050485345244,-0.9135454576426,-0.90630778703665,-0.89879404629917,-0.89100652418837,-0.88294759285893,-0.8746197071394,-0.86602540378444,-0.85716730070211,-0.84804809615643,-0.83867056794542,-0.82903757255504,-0.81915204428899,-0.80901699437495,-0.79863551004729,-0.78801075360672,-0.77714596145697,-0.76604444311898,-0.75470958022277,-0.74314482547739,-0.73135370161917,-0.71933980033865,-0.70710678118655,-0.694658370459,-0.6819983600625,-0.66913060635886,-0.65605902899051,-0.64278760968654,-0.62932039104984,-0.61566147532566,-0.60181502315205,-0.58778525229247,-0.57357643635105,-0.55919290347075,-0.54463903501503,-0.52991926423321,-0.51503807491005,-0.5,-0.48480962024634,-0.46947156278589,-0.45399049973955,-0.43837114678908,-0.4226182617407,-0.4067366430758,-0.39073112848927,-0.37460659341591,-0.3583679495453,-0.34202014332567,-0.32556815445716,-0.30901699437495,-0.29237170472274,-0.275637355817,-0.25881904510252,-0.24192189559967,-0.22495105434387,-0.20791169081776,-0.19080899537654,-0.17364817766693,-0.15643446504023,-0.13917310096007,-0.12186934340515,-0.10452846326765,-0.087155742747658,-0.069756473744125,-0.052335956242944,-0.034899496702501,-0.017452406437284}; int rand_num_util=0; void invertVars(int *v1,int *v2) { int temp=*v1; *v1=*v2; *v2=temp; } void invertTableElems(int *table,int e1,int e2) { int temp=table[e1]; table[e1]=table[e2]; table[e2]=temp; } void invertTablefloats(float *table,int e1,int e2) { float temp=table[e1]; table[e1]=table[e2]; table[e2]=temp; } float angleCorrect(float angle) { while(angle<0) { angle+=360.0; } return angle; } float cos(float angle) { angle=angleCorrect(angle); int ipart=(int)angle; float t1=costbl[ipart%360]; float t2=costbl[(ipart+1)%360]; angle=angle-(float)ipart; return (t2-t1)*angle+t1; } float sin(float angle) { angle=angleCorrect(angle); int ipart=(int)angle; float t1=sintbl[ipart%360]; float t2=sintbl[(ipart+1)%360]; angle=angle-(float)ipart; return (t2-t1)*angle+t1; } float floor(float n) { int a=0; a=(int)n; n=(float)a; return n; } float sign(float n) { if(n>=0) return 1.0; else return -1.0; } int random(int min, int max) { rand_num_util=(16807*rand_num_util+15)%0x7FFFFFFF; if(rand_num_util<0) rand_num_util*=-1; return rand_num_util%(max-min)+min; } void startRandom() { if(has_colors) rand_num_util=*(volatile uint32_t*)0x900D0004; else rand_num_util=*(volatile uint32_t*)0x900D000C; } int ceiling(int n,int max) { return (n