From 486d4607b2ea8f5c506e5d92ccc9e11d41b326340cffda1617e1baa693564db1 Mon Sep 17 00:00:00 2001 From: Victor Roman Archidona Date: Fri, 20 Dec 2002 16:06:05 +0000 Subject: [PATCH] Cambios en la libreria math --- dlls/src/math/CHANGE_LOG.txt | 4 + dlls/src/math/math.c | 628 +++++++++++++++++++---------------- dlls/src/math/math.h | 75 +++-- 3 files changed, 389 insertions(+), 318 deletions(-) create mode 100644 dlls/src/math/CHANGE_LOG.txt diff --git a/dlls/src/math/CHANGE_LOG.txt b/dlls/src/math/CHANGE_LOG.txt new file mode 100644 index 0000000..41ab066 --- /dev/null +++ b/dlls/src/math/CHANGE_LOG.txt @@ -0,0 +1,4 @@ +19/12/2002 +---------- + * Creamos el CHANGE_LOG.txt para la libreria math de eDIV (Daijo) + * Añadidas las funciones: fixtoi8, fixtoi16, itofix8 y itofix16 (CicTec) \ No newline at end of file diff --git a/dlls/src/math/math.c b/dlls/src/math/math.c index 4e619e3..9d6ad20 100644 --- a/dlls/src/math/math.c +++ b/dlls/src/math/math.c @@ -17,341 +17,349 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -/* EDIVSTD.DLL - * Esta librería contiene los datos más básicos que puede requerir un programa - * DIV, tal como las opciones de compilación, estructura reserved, etc. - */ - #include #include - - -#include +#include +#include "export.h" #include "math.h" -int seno[90001] ; - -int ExportaFuncs(EXPORTAFUNCS_PARAMS) -{ +int ExportaFuncs(EXPORTAFUNCS_PARAMS){ CONST("pi",180000); - FUNCTION("abs",1,eDiv_Abs); - FUNCTION("pow",2,eDiv_Pow); - FUNCTION("sqrt",1,eDiv_Sqrt); - FUNCTION("rand",2,eDiv_Rand); - FUNCTION("rand_seed",1,eDiv_RandSeed) ; - FUNCTION("sin",1,eDiv_Sin) ; - FUNCTION("cos",1,eDiv_Cos) ; - FUNCTION("tan",1,eDiv_Tan) ; - FUNCTION("get_angle",1,eDiv_GetAngle) ; - FUNCTION("get_dist",1,eDiv_GetDist) ; - FUNCTION("get_distx",2,eDiv_GetDistX) ; - FUNCTION("get_disty",2,eDiv_GetDistY) ; - FUNCTION("fget_angle",4,eDiv_FgetAngle) ; - FUNCTION("fget_dist",4,eDiv_FgetDist) ; - FUNCTION("near_angle",3,eDiv_NearAngle) ; - FUNCTION("cpysign",2,eDiv_cpysign) ; - FUNCTION("max",2,eDiv_max) ; - FUNCTION("min",2,eDiv_min) ; - FUNCTION("xmax",3,eDiv_xmax) ; - FUNCTION("xmin",3,eDiv_xmin) ; - FUNCTION("xmid",3,eDiv_xmid) ; - ENTRYPOINT(first_load) ; + FUNCTION("abs",1,eDIV_abs); + FUNCTION("pow",2,eDIV_pow); + FUNCTION("sqrt",1,eDIV_sqrt); + FUNCTION("rand",2,eDIV_rand); + FUNCTION("rand_seed",1,eDIV_rand_seed); + FUNCTION("sin",1,eDIV_sin); + FUNCTION("cos",1,eDIV_cos); + FUNCTION("tan",1,eDIV_tan); + FUNCTION("get_angle",1,eDIV_get_angle); + FUNCTION("get_dist",1,eDIV_get_dist); + FUNCTION("get_distx",2,eDIV_get_distx); + FUNCTION("get_disty",2,eDIV_get_disty); + FUNCTION("fget_angle",4,eDIV_fget_angle); + FUNCTION("fget_dist",4,eDIV_fget_dist); + FUNCTION("near_angle",3,eDIV_near_angle); + FUNCTION("cpysign",2,eDIV_cpysign); + /* + FUNCTION("fcpysign",2,eDIV_fcpysign); + FUNCTION("fixtof8",1,eDIV_fixtof8); + FUNCTION("fixtof16",1,eDIV_fixtof16); + */ + FUNCTION("fixtoi8",1,eDIV_fixtoi8); + FUNCTION("fixtoi16",1,eDIV_fixtoi16); + /* + FUNCTION("ftofix8",1,eDIV_ftofix8); + FUNCTION("ftofix16",1,eDIV_ftofix16); + */ + FUNCTION("itofix8",1,eDIV_itofix8); + FUNCTION("itofix16",1,eDIV_itofix16); + /* + FUNCTION("dtoradian",1,eDIV_dtoradian); + FUNCTION("rtodegree",1,eDIV_rtodegree); + FUNCTION("fmax",2,eDIV_fmax); + FUNCTION("fmin",2,eDIV_fmin); + FUNCTION("fxmax",3,eDIV_fxmax); + FUNCTION("fxmin",3,eDIV_fxmin); + FUNCTION("fxmid",3,eDIV_fxmid); + */ + FUNCTION("max",2,eDIV_max); + FUNCTION("min",2,eDIV_min); + FUNCTION("xmax",3,eDIV_xmax); + FUNCTION("xmin",3,eDIV_xmin); + FUNCTION("xmid",3,eDIV_xmid); + + ENTRYPOINT(first_load); return TRUE; } - - - -int eDiv_Abs(FUNCTION_PARAMS) -{ - int a = getparm() ; - if ( a < 0 ) a = -a ; - return a ; +int eDIV_abs(FUNCTION_PARAMS){ + int n=getparm(); + return ((n<0)?(-n):(n)); } -int eDiv_Pow(FUNCTION_PARAMS) -{ - int a,b,c,n,i ; - b = getparm() ; - a = getparm() ; - n = 1 ; - c = b ; - if ( c < 0 ) c = -c ; - for ( i = 1 ; i < c ; i++ ) - { - n *= a ; - } - if ( b < 0 ) - n = 1 / n ; +int eDIV_pow(FUNCTION_PARAMS){ + int c,n,i; + int b=getparm(); + int a=getparm(); + n=1; + c=b; + if(c<0) c=-c; + for(i=1; iprocs_s[ fp->proc_orden[ *fp->proceso_actual ] ].id ; - id2 = a ; - x1 = local("x",id1) ; - y1 = local("y",id1) ; - x2 = local("x",id2) ; - y2 = local("y",id2) ; - if ( (x2-x1) != 0 ) - { - a = atan( (double)((y2-y1) / (x2-x1)) ) / PIOVER180 ; - if ( x2 < x1 ) - a+= 180 ; - }else - if ( y2 > y1 ) - a = 90 ; - else - a = 270 ; - a *= 1000 ; - a = prepara_angulo(a) ; - return a ; +int eDIV_get_angle(FUNCTION_PARAMS){ + int id1,id2; + int x1,x2,y1,y2; + int a=getparm(); + id1=fp->procs_s[fp->proc_orden[*fp->proceso_actual]].id; + id2=a; + x1=local("x",id1); + y1=local("y",id1); + x2=local("x",id2); + y2=local("y",id2); + if((x2-x1)!=0){ + a=(int)(atan((double)((y2-y1)/(x2-x1)))/PIOVER180); + if(x2y1) a=90; else a=270; + a*=1000; + a=prepara_angulo(a); + return a; } -int eDiv_GetDist(FUNCTION_PARAMS) -{ - int id1 , id2 ; - int x1 , x2 , y1, y2 ; - int a = getparm() ; - id1 = fp->procs_s[ fp->proc_orden[*fp->proceso_actual] ].id ; - id2 = a ; - x1 = local("x",id1) ; - y1 = local("y",id1) ; - x2 = local("x",id2) ; - y2 = local("y",id2) ; - a = sqrt( pow( x2-x1 , 2 ) + pow( y2-y1 , 2 ) ) ; - return a ; +int eDIV_get_dist(FUNCTION_PARAMS){ + int id1,id2; + int x1,x2,y1,y2; + int a=getparm(); + id1=fp->procs_s[fp->proc_orden[*fp->proceso_actual]].id; + id2=a; + x1=local("x",id1); + y1=local("y",id1); + x2=local("x",id2); + y2=local("y",id2); + return ((int)sqrt(pow(x2-x1,2)+pow(y2-y1,2))); } -int eDiv_GetDistX(FUNCTION_PARAMS) -{ - int a , b ; - b = getparm() ; /* distancia */ - a = getparm() ; /* angulo */ - a = (int) b* cos( (a/1000)*PIOVER180 ) ; - return a ; +int eDIV_get_distx(FUNCTION_PARAMS){ + int d=getparm(); /* distancia */ + int a=getparm(); /* angulo */ + return ((int)(d*cos((a/1000)*PIOVER180))); } -int eDiv_GetDistY(FUNCTION_PARAMS) -{ - int a , b ; - b = getparm() ; /* distancia */ - a = getparm() ; /* angulo */ - a = (int) b* sin( (a/1000)*PIOVER180 ) ; - return a ; +int eDIV_get_disty(FUNCTION_PARAMS){ + int d=getparm(); /* distancia */ + int a=getparm(); /* angulo */ + return ((int)(d*sin((a/1000)*PIOVER180))); } -int eDiv_FgetAngle(FUNCTION_PARAMS) -{ - int x1 , y1 , x2 , y2 , a ; - y2 = getparm() ; - x2 = getparm() ; - y1 = getparm() ; - x1 = getparm() ; - if ( (x2-x1) != 0 ) - { - a = atan( (double)((y2-y1) / (x2-x1)) ) / PIOVER180 ; - if ( x2 < x1 ) - a+= 180 ; - }else - if ( y2 > y1 ) - a = 90 ; - else - a = 270 ; - a *= 1000 ; - a = prepara_angulo(a) ; - return a ; +int eDIV_fget_angle(FUNCTION_PARAMS){ + int a; + int y2=getparm(); + int x2=getparm(); + int y1=getparm(); + int x1=getparm(); + if((x2-x1)!=0){ + a=(int)(atan((double)((y2-y1)/(x2-x1)))/PIOVER180); + if(x2y1) a=90; else a=270; + a*=1000; + a=prepara_angulo(a); + return a; } -int eDiv_FgetDist(FUNCTION_PARAMS) -{ - int x1 , y1 , x2 , y2 , a; - y2 = getparm() ; - x2 = getparm() ; - y1 = getparm() ; - x1 = getparm() ; - a = sqrt( pow( x2-x1 , 2 ) + pow( y2-y1 , 2 ) ) ; - return a ; +int eDIV_fget_dist(FUNCTION_PARAMS){ + int y2=getparm(); + int x2=getparm(); + int y1=getparm(); + int x1=getparm(); + return ((int)sqrt(pow(x2-x1,2)+pow(y2-y1,2))); } -int eDiv_NearAngle(FUNCTION_PARAMS) -{ - int a , b , c ; - c = getparm() ; - b = getparm() ; - a = getparm() ; - a = prepara_angulo(a) ; - b = prepara_angulo(b) ; - c = prepara_angulo(c) ; - if ( abs(a - b) <= c ) - return b ; - if ( a < b ) - { - if ( abs( b-a ) < 180000 ) - { - a = prepara_angulo( a+c ) ; - }else - { - a = prepara_angulo( a-c ) ; - } - return a ; - }else - { - if ( abs( b-a ) < 180000 ) - { - a = prepara_angulo( a-c ) ; - }else - { - a = prepara_angulo( a+c ) ; - } +int eDIV_near_angle(FUNCTION_PARAMS){ + int c=getparm(); + int b=getparm(); + int a=getparm(); + a=prepara_angulo(a); + b=prepara_angulo(b); + c=prepara_angulo(c); + if(abs(a-b)<=c) + return b; + if(a=0)?(n):(-n))); } -int eDiv_max(FUNCTION_PARAMS) -{ - int n2 = getparm() ; - int n1 = getparm() ; +/* +float eDIV_fcpysign(FUNCTION_PARAMS){ + float s=getparm(); + float n=getparm(); + return ((s<0)?((n<0)?(n):(-n)):((n>=0)?(n):(-n))); +} + +float eDIV_fixtof8(FUNCTION_PARAMS){ + int n=getparm(); + return ((float)(n/255.0)); +} + +float eDIV_fixtof16(FUNCTION_PARAMS){ + int n=getparm(); + return ((float)(n/65535.0)); +} +*/ + +int eDIV_fixtoi8(FUNCTION_PARAMS){ + int n=getparm(); + return (n>>8); +} + +int eDIV_fixtoi16(FUNCTION_PARAMS){ + int n=getparm(); + return (n>>16); +} + +/* +int eDIV_ftofix8(FUNCTION_PARAMS){ + float n=getparm(); + return ((int)(n*255.0)); +} + +int eDIV_ftofix16(FUNCTION_PARAMS){ + float n=getparm(); + return ((int)(n*65535.0)); +} +*/ + +int eDIV_itofix8(FUNCTION_PARAMS){ + int n=getparm(); + return (n<<8); +} + +int eDIV_itofix16(FUNCTION_PARAMS){ + int n=getparm(); + return (n<<16); +} + +/* +float eDIV_dtoradian(FUNCTION_PARAMS){ + float d=getparm(); + return (d*(PI/180.0f)); +} + +float eDIV_rtodegree(FUNCTION_PARAMS){ + float r=getparm(); + return (r*(180.0f/PI)); +} +*/ + +int eDIV_max(FUNCTION_PARAMS){ + int n2=getparm(); + int n1=getparm(); return ((n1>n2)?(n1):(n2)); } -int eDiv_min(FUNCTION_PARAMS) -{ - int n2 = getparm() ; - int n1 = getparm() ; +int eDIV_min(FUNCTION_PARAMS){ + int n2=getparm(); + int n1=getparm(); return ((n1m) m=n2; if(n3>m) m=n3; return m; } -int eDiv_xmin(FUNCTION_PARAMS) -{ - int n3 = getparm() ; - int n2 = getparm() ; - int n1 = getparm() ; - +int eDIV_xmin(FUNCTION_PARAMS){ + int n3=getparm(); + int n2=getparm(); + int n1=getparm(); int m=n1; if(n2n2 && n1>n3 && n2>=n3) || (n1>n2 && n1==n3 && n2n2)?(n1):(n2)); +} -void first_load() -{ +float eDIV_fmin(FUNCTION_PARAMS){ + float n2=getparm(); + float n1=getparm(); + return ((n1m) m=n2; + if(n3>m) m=n3; + return m; +} + +float eDIV_fxmin(FUNCTION_PARAMS){ + float n3=getparm(); + float n2=getparm(); + float n1=getparm(); + float m=n1; + if(n2n2 && n1>n3 && n2>=n3) || + (n1>n2 && n1==n3 && n2n3) || + (n1>n2 && n1>n3 && n2n3 && n2>n3)) + return n3; + return n1; +} +*/ + +/* Entrypoints */ +void first_load(FUNCTION_PARAMS){ int i ; /* Calculamos los senos del 0 al 90000C */ - for ( i = 0 ; i < 90000 ; i++ ) - { - seno[i] = ftomil( sin( (i / 1000)*PIOVER180 ) ); - } + for(i=0; i<90000; i++) + seno[i]=ftomil((float)sin((i/1000)*PIOVER180)); seno[90000]=1000; srand(time(NULL)); } - -/* - * Funciones internas de la DLL - */ -int ftomil( float n ) -{ - - return ((int)(n*1000)) ; - +/* Funciones internas de la DLL */ +int ftomil(float n){ + return((int)(n*1000)); } -int prepara_angulo( int n ) -{ - n = n % 360000 ; - if ( n < 0 ) n = n + 360000 ; - return n ; +int prepara_angulo(int n){ + n=n%360000; + if(n<0) n=n+360000; + return n; } - diff --git a/dlls/src/math/math.h b/dlls/src/math/math.h index f171458..fddfcdb 100644 --- a/dlls/src/math/math.h +++ b/dlls/src/math/math.h @@ -1,33 +1,58 @@ #ifndef __EDIV_MATH_H #define __EDIV_MATH_H + #define PIOVER180 0.017453292519943295769236907684886 +#define PI 3.141592654f + +int seno[90001]; + +int eDIV_abs(FUNCTION_PARAMS); +int eDIV_pow(FUNCTION_PARAMS); +int eDIV_sqrt(FUNCTION_PARAMS); +int eDIV_rand(FUNCTION_PARAMS); +int eDIV_rand_seed(FUNCTION_PARAMS); +int eDIV_sin(FUNCTION_PARAMS); +int eDIV_cos(FUNCTION_PARAMS); +int eDIV_tan(FUNCTION_PARAMS); +int eDIV_get_angle(FUNCTION_PARAMS); +int eDIV_get_dist(FUNCTION_PARAMS); +int eDIV_get_distx(FUNCTION_PARAMS); +int eDIV_get_disty(FUNCTION_PARAMS); +int eDIV_fget_angle(FUNCTION_PARAMS); +int eDIV_fget_dist(FUNCTION_PARAMS); +int eDIV_near_angle(FUNCTION_PARAMS); +int eDIV_cpysign(FUNCTION_PARAMS); +/* +int eDIV_fcpysign(FUNCTION_PARAMS); +float eDIV_fixtof8(FUNCTION_PARAMS); +float eDIV_fixtof16(FUNCTION_PARAMS); +*/ +int eDIV_fixtoi8(FUNCTION_PARAMS); +int eDIV_fixtoi16(FUNCTION_PARAMS); +/* +int eDIV_ftofix8(FUNCTION_PARAMS); +int eDIV_ftofix16(FUNCTION_PARAMS); +*/ +int eDIV_itofix8(FUNCTION_PARAMS); +int eDIV_itofix16(FUNCTION_PARAMS); +/* +float eDIV_dtoradian(FUNCTION_PARAMS); +float eDIV_rtodegree(FUNCTION_PARAMS); +int eDIV_fmax(FUNCTION_PARAMS); +int eDIV_fmin(FUNCTION_PARAMS); +int eDIV_fxmax(FUNCTION_PARAMS); +int eDIV_fxmin(FUNCTION_PARAMS); +int eDIV_fxmid(FUNCTION_PARAMS); +*/ +int eDIV_max(FUNCTION_PARAMS); +int eDIV_min(FUNCTION_PARAMS); +int eDIV_xmax(FUNCTION_PARAMS); +int eDIV_xmin(FUNCTION_PARAMS); +int eDIV_xmid(FUNCTION_PARAMS); -int eDiv_Abs(FUNCTION_PARAMS) ; -int eDiv_Pow(FUNCTION_PARAMS) ; -int eDiv_Sqrt(FUNCTION_PARAMS) ; -int eDiv_Rand(FUNCTION_PARAMS) ; -int eDiv_RandSeed(FUNCTION_PARAMS) ; -int eDiv_Sin(FUNCTION_PARAMS) ; -int eDiv_Cos(FUNCTION_PARAMS) ; -int eDiv_Tan(FUNCTION_PARAMS) ; -int eDiv_GetAngle(FUNCTION_PARAMS) ; -int eDiv_GetDist(FUNCTION_PARAMS) ; -int eDiv_GetDistX(FUNCTION_PARAMS) ; -int eDiv_GetDistY(FUNCTION_PARAMS) ; -int eDiv_FgetAngle(FUNCTION_PARAMS) ; -int eDiv_FgetDist(FUNCTION_PARAMS) ; -int eDiv_NearAngle(FUNCTION_PARAMS) ; - -float eDiv_cpysign(float n,float s); -float eDiv_max(float n1,float n2); -float eDiv_min(float n1,float n2); -float eDiv_xmax(float n1,float n2,float n3); -float eDiv_xmin(float n1,float n2,float n3); -float eDiv_xmid(float n1,float n2,float n3); - -int ftomil(float) ; -int prepara_angulo( int ) ; +int ftomil(float); +int prepara_angulo(int); #endif \ No newline at end of file