Added some of the changes for x86_64 support from 9b44fc26

  * Thanks to @panreyes for proposing them! I will work on the rest
    to try to implement them ASAP
parent 2daf2ed6
......@@ -3,3 +3,4 @@
*.a
*.dcb
.idea
/3rdparty/steamworks
......@@ -46,7 +46,7 @@
* Helper function preparing params
**/
static bgdata *prep(int *params) {
static bgdata *prep(intptr_t *params) {
bgdata *t = (bgdata *)malloc(sizeof(bgdata));
t->file = strdup((char *)string_get(params[0]));
t->id = (int *)params[1];
......@@ -71,7 +71,7 @@ int bgDoLoad(void *d) {
/* --------------------------------------------------------------------------- */
int bgload(int (*fn)(), int *params) {
int bgload(int (*fn)(), intptr_t *params) {
bgdata *t = prep(params);
t->fn = fn;
......
......@@ -39,7 +39,7 @@ typedef struct {
/* --------------------------------------------------------------------------- */
extern int bgload(int (*fn)(), int *params);
extern int bgload(int (*fn)(), intptr_t *params);
/* --------------------------------------------------------------------------- */
......
#include "Constraints.h"
#include "locales.h"
#include "constantes.h"
#include "Miscelanea.h"
#include "estructuras.h"
extern cpSpace *modChipmunk_cpEspacio;
// int addConstr(cpBody *bod1, cpBody *bod2,cpConstraint * cons)
//{
// int z;
// if (bod1!=modChipmunk_cpEspacio->staticBody)
// {
// DataPointer elem= (DataPointer)bod1->data;
// LLagrega(elem->Constraints,cons);
// //printf(" creado %d \n",elem->Constraints);
// }
// if (bod2!=modChipmunk_cpEspacio->staticBody)
// {
// DataPointer elem= (DataPointer)bod2->data;
// LLagrega(elem->Constraints,cons);
// //printf(" creado %d \n",elem->Constraints);
// }
// return 0;
//}
#define agregaData \
z->data = malloc(sizeof(DatosConstraint)); \
((DatosConstraint *)z->data)->fatherA = params[0]; \
((DatosConstraint *)z->data)->fatherB = params[1];
int modaddDampedSpring(INSTANCE *my, int *params) {
cpBody *b1, *b2;
cpConstraint *z;
INSTANCE *b;
if (params[0] != 0) {
b = instance_get(params[0]);
b1 = LOCDWORD(mod_chipmunk, b, LOC_BODY);
} else {
b1 = modChipmunk_cpEspacio->staticBody;
}
if (params[1] != 0) {
b = instance_get(params[1]);
b2 = LOCDWORD(mod_chipmunk, b, LOC_BODY);
} else {
b2 = modChipmunk_cpEspacio->staticBody;
}
z = cpDampedSpringNew(b1, b2, cpv(*(float *)&params[2], *(float *)&params[3]),
cpv(*(float *)&params[4], *(float *)&params[5]), *(float *)&params[6],
*(float *)&params[7], *(float *)&params[8]);
cpSpaceAddConstraint(modChipmunk_cpEspacio, z);
// addConstr(b1,b2,z);
agregaData return (int)z;
}
int modaddPinJoint(INSTANCE *my, int *params) {
cpBody *b1, *b2;
cpConstraint *z;
INSTANCE *b;
if (params[0] != 0) {
b = instance_get(params[0]);
b1 = (cpBody *)LOCDWORD(mod_chipmunk, b, LOC_BODY);
} else {
b1 = modChipmunk_cpEspacio->staticBody;
}
if (params[1] != 0) {
b = instance_get(params[1]);
b2 = (cpBody *)LOCDWORD(mod_chipmunk, b, LOC_BODY);
} else {
b2 = modChipmunk_cpEspacio->staticBody;
}
z = cpPinJointNew(b1, b2, cpv(*(float *)&params[2], *(float *)&params[3]),
cpv(*(float *)&params[4], *(float *)&params[5]));
cpSpaceAddConstraint(modChipmunk_cpEspacio, z);
// addConstr(b1,b2,z);
agregaData return (int)z;
}
int modaddPivotJoint2(INSTANCE *my, int *params) {
cpBody *b1, *b2;
cpConstraint *z;
INSTANCE *b;
if (params[0] != 0) {
b = instance_get(params[0]);
b1 = LOCDWORD(mod_chipmunk, b, LOC_BODY);
} else {
b1 = modChipmunk_cpEspacio->staticBody;
}
if (params[1] != 0) {
b = instance_get(params[1]);
b2 = LOCDWORD(mod_chipmunk, b, LOC_BODY);
} else {
b2 = modChipmunk_cpEspacio->staticBody;
}
z = cpPivotJointNew2(b1, b2, cpv(*(float *)&params[2], *(float *)&params[3]),
cpv(*(float *)&params[4], *(float *)&params[5]));
cpSpaceAddConstraint(modChipmunk_cpEspacio, z);
// addConstr(b1,b2,z);
agregaData return (int)z;
}
int modaddSlideJoint(INSTANCE *my, int *params) {
cpBody *b1, *b2;
cpConstraint *z;
INSTANCE *b;
if (params[0] != 0) {
b = instance_get(params[0]);
b1 = LOCDWORD(mod_chipmunk, b, LOC_BODY);
} else {
b1 = modChipmunk_cpEspacio->staticBody;
}
if (params[1] != 0) {
b = instance_get(params[1]);
b2 = LOCDWORD(mod_chipmunk, b, LOC_BODY);
} else {
b2 = modChipmunk_cpEspacio->staticBody;
}
z = cpSlideJointNew(b1, b2, cpv(*(float *)&params[2], *(float *)&params[3]),
cpv(*(float *)&params[4], *(float *)&params[5]), *(float *)&params[6],
*(float *)&params[7]);
cpSpaceAddConstraint(modChipmunk_cpEspacio, z);
// addConstr(b1,b2,z);
agregaData return (int)z;
}
int modaddGrooveJoint(INSTANCE *my, int *params) {
cpBody *b1, *b2;
cpConstraint *z;
INSTANCE *b;
if (params[0] != 0) {
b = instance_get(params[0]);
b1 = LOCDWORD(mod_chipmunk, b, LOC_BODY);
} else {
b1 = modChipmunk_cpEspacio->staticBody;
}
if (params[1] != 0) {
b = instance_get(params[1]);
b2 = LOCDWORD(mod_chipmunk, b, LOC_BODY);
} else {
b2 = modChipmunk_cpEspacio->staticBody;
}
z = cpGrooveJointNew(b1, b2, cpv(*(float *)&params[2], *(float *)&params[3]),
cpv(*(float *)&params[4], *(float *)&params[5]),
cpv(*(float *)&params[6], *(float *)&params[7]));
cpSpaceAddConstraint(modChipmunk_cpEspacio, z);
// addConstr(b1,b2,z);
agregaData return (int)z;
}
int modaddSimpleMotor(INSTANCE *my, int *params) {
cpBody *b1, *b2;
cpConstraint *z;
INSTANCE *b;
if (params[0] != 0) {
b = instance_get(params[0]);
b1 = LOCDWORD(mod_chipmunk, b, LOC_BODY);
} else {
b1 = modChipmunk_cpEspacio->staticBody;
}
if (params[1] != 0) {
b = instance_get(params[1]);
b2 = LOCDWORD(mod_chipmunk, b, LOC_BODY);
} else {
b2 = modChipmunk_cpEspacio->staticBody;
}
z = cpSimpleMotorNew(b1, b2, modChipmunkdeg2rad(*(float *)&params[2]));
cpSpaceAddConstraint(modChipmunk_cpEspacio, z);
// addConstr(b1,b2,z);
agregaData return (int)z;
}
int modaddRatchetJoint(INSTANCE *my, int *params) {
cpBody *b1, *b2;
cpConstraint *z;
INSTANCE *b;
if (params[0] != 0) {
b = instance_get(params[0]);
b1 = LOCDWORD(mod_chipmunk, b, LOC_BODY);
} else {
b1 = modChipmunk_cpEspacio->staticBody;
}
if (params[1] != 0) {
b = instance_get(params[1]);
b2 = LOCDWORD(mod_chipmunk, b, LOC_BODY);
} else {
b2 = modChipmunk_cpEspacio->staticBody;
}
z = cpRatchetJointNew(b1, b2, modChipmunkdeg2rad(*(float *)&params[2]),
modChipmunkdeg2rad(*(float *)&params[3]));
cpSpaceAddConstraint(modChipmunk_cpEspacio, z);
// addConstr(b1,b2,z);
agregaData return (int)z;
}
int modaddRotaryLimitJoint(INSTANCE *my, int *params) {
cpBody *b1, *b2;
cpConstraint *z;
INSTANCE *b;
if (params[0] != 0) {
b = instance_get(params[0]);
b1 = LOCDWORD(mod_chipmunk, b, LOC_BODY);
} else {
b1 = modChipmunk_cpEspacio->staticBody;
}
if (params[1] != 0) {
b = instance_get(params[1]);
b2 = LOCDWORD(mod_chipmunk, b, LOC_BODY);
} else {
b2 = modChipmunk_cpEspacio->staticBody;
}
z = cpRotaryLimitJointNew(b1, b2, modChipmunkdeg2rad(*(float *)&params[2]),
modChipmunkdeg2rad(*(float *)&params[3]));
cpSpaceAddConstraint(modChipmunk_cpEspacio, z);
// addConstr(b1,b2,z);
agregaData return (int)z;
}
int modaddGearJoint(INSTANCE *my, int *params) {
cpBody *b1, *b2;
cpConstraint *z;
INSTANCE *b;
if (params[0] != 0) {
b = instance_get(params[0]);
b1 = LOCDWORD(mod_chipmunk, b, LOC_BODY);
} else {
b1 = modChipmunk_cpEspacio->staticBody;
}
if (params[1] != 0) {
b = instance_get(params[1]);
b2 = LOCDWORD(mod_chipmunk, b, LOC_BODY);
} else {
b2 = modChipmunk_cpEspacio->staticBody;
}
z = cpGearJointNew(b1, b2, modChipmunkdeg2rad(*(float *)&params[2]),
modChipmunkdeg2rad(*(float *)&params[3]));
cpSpaceAddConstraint(modChipmunk_cpEspacio, z);
// addConstr(b1,b2,z);
agregaData return (int)z;
}
int modaddDampedRotarySpring(INSTANCE *my, int *params) {
cpBody *b1, *b2;
cpConstraint *z;
INSTANCE *b;
if (params[0] != 0) {
b = instance_get(params[0]);
b1 = LOCDWORD(mod_chipmunk, b, LOC_BODY);
} else {
b1 = modChipmunk_cpEspacio->staticBody;
}
if (params[1] != 0) {
b = instance_get(params[1]);
b2 = LOCDWORD(mod_chipmunk, b, LOC_BODY);
} else {
b2 = modChipmunk_cpEspacio->staticBody;
}
z = cpDampedRotarySpringNew(b1, b2, modChipmunkdeg2rad(*(float *)&params[2]),
*(float *)&params[3], *(float *)&params[4]);
cpSpaceAddConstraint(modChipmunk_cpEspacio, z);
// addConstr(b1,b2,z);
agregaData return (int)z;
}
int modaddPivotJoint(INSTANCE *my, int *params) {
cpBody *b1, *b2;
cpConstraint *z;
INSTANCE *b;
if (params[0] != 0) {
b = instance_get(params[0]);
b1 = LOCDWORD(mod_chipmunk, b, LOC_BODY);
} else {
b1 = modChipmunk_cpEspacio->staticBody;
}
if (params[1] != 0) {
b = instance_get(params[1]);
b2 = LOCDWORD(mod_chipmunk, b, LOC_BODY);
} else {
b2 = modChipmunk_cpEspacio->staticBody;
}
z = cpPivotJointNew(b1, b2, cpv(*(float *)&params[2], *(float *)&params[3]));
cpSpaceAddConstraint(modChipmunk_cpEspacio, z);
// addConstr(b1,b2,z);
agregaData return (int)z;
}
int modsetPinJointProperties(INSTANCE *my, int *params) {
cpConstraint *constr = (cpConstraint *)params[0];
switch (params[1]) {
case CP_C_ANCHR1:
cpPinJointSetAnchr1(constr, cpv(*(float *)&params[2], *(float *)&params[3]));
break;
case CP_C_ANCHR2:
cpPinJointSetAnchr2(constr, cpv(*(float *)&params[2], *(float *)&params[3]));
break;
case CP_C_DIST:
cpPinJointSetDist(constr, *(float *)&params[2]);
break;
}
return 1;
}
int modsetSlideJointProperties(INSTANCE *my, int *params) {
cpConstraint *constr = (cpConstraint *)params[0];
switch (params[1]) {
case CP_C_ANCHR1:
cpSlideJointSetAnchr1(constr, cpv(*(float *)&params[2], *(float *)&params[3]));
break;
case CP_C_ANCHR2:
cpSlideJointSetAnchr2(constr, cpv(*(float *)&params[2], *(float *)&params[3]));
break;
case CP_C_MIN:
cpSlideJointSetMin(constr, *(float *)&params[2]);
break;
case CP_C_MAX:
cpSlideJointSetMax(constr, *(float *)&params[2]);
break;
}
return 1;
}
int modsetPivotJointProperties(INSTANCE *my, int *params) {
cpConstraint *constr = (cpConstraint *)params[0];
switch (params[1]) {
case CP_C_ANCHR1:
cpPivotJointSetAnchr1(constr, cpv(*(float *)&params[2], *(float *)&params[3]));
break;
case CP_C_ANCHR2:
cpPivotJointSetAnchr2(constr, cpv(*(float *)&params[2], *(float *)&params[3]));
break;
}
return 1;
}
int modsetGrooveJointProperties(INSTANCE *my, int *params) {
cpConstraint *constr = (cpConstraint *)params[0];
switch (params[1]) {
case CP_C_GROOVEA:
cpGrooveJointSetGrooveA(constr, cpv(*(float *)&params[2], *(float *)&params[3]));
break;
case CP_C_GROOVEB:
cpGrooveJointSetGrooveB(constr, cpv(*(float *)&params[2], *(float *)&params[3]));
break;
case CP_C_ANCHR2:
cpGrooveJointSetAnchr2(constr, cpv(*(float *)&params[2], *(float *)&params[3]));
break;
}
return 1;
}
int modsetDampedSpringProperties(INSTANCE *my, int *params) {
cpConstraint *constr = (cpConstraint *)params[0];
switch (params[1]) {
case CP_C_ANCHR1:
cpDampedSpringSetAnchr1(constr, cpv(*(float *)&params[2], *(float *)&params[3]));
break;
case CP_C_ANCHR2:
cpDampedSpringSetAnchr2(constr, cpv(*(float *)&params[2], *(float *)&params[3]));
break;
case CP_C_RESTLENGTH:
cpDampedSpringSetRestLength(constr, *(float *)&params[2]);
break;
case CP_C_STIFFNESS:
cpDampedSpringSetStiffness(constr, *(float *)&params[2]);
break;
case CP_C_DAMPING:
cpDampedSpringSetDamping(constr, *(float *)&params[2]);
break;
}
return 1;
}
int modsetDampedRotarySpringProperties(INSTANCE *my, int *params) {
cpConstraint *constr = (cpConstraint *)params[0];
switch (params[1]) {
case CP_C_RESTANGLE:
cpDampedRotarySpringSetRestAngle(constr, modChipmunkdeg2rad(*(float *)&params[2]));
break;
case CP_C_STIFFNESS:
cpDampedRotarySpringSetStiffness(constr, *(float *)&params[2]);
break;
case CP_C_DAMPING:
cpDampedRotarySpringSetDamping(constr, *(float *)&params[2]);
break;
}
return 1;
}
int modsetRotaryLimitJointProperties(INSTANCE *my, int *params) {
cpConstraint *constr = (cpConstraint *)params[0];
switch (params[1]) {
case CP_C_MIN:
cpRotaryLimitJointSetMin(constr, modChipmunkdeg2rad(*(float *)&params[2]));
break;
case CP_C_MAX:
cpRotaryLimitJointSetMax(constr, modChipmunkdeg2rad(*(float *)&params[2]));
break;
}
return 1;
}
int modsetRatchetJointProperties(INSTANCE *my, int *params) {
cpConstraint *constr = (cpConstraint *)params[0];
switch (params[1]) {
case CP_C_ANGLE:
cpRatchetJointSetAngle(constr, modChipmunkdeg2rad(*(float *)&params[2]));
break;
case CP_C_PHASE:
cpRatchetJointSetPhase(constr, modChipmunkdeg2rad(*(float *)&params[2]));
break;
case CP_C_RATCHET:
cpRatchetJointSetRatchet(constr, modChipmunkdeg2rad(*(float *)&params[2]));
break;
}
return 1;
}
int modsetGearJointProperties(INSTANCE *my, int *params) {
cpConstraint *constr = (cpConstraint *)params[0];
switch (params[1]) {
case CP_C_RATIO:
cpGearJointSetRatio(constr, modChipmunkdeg2rad(*(float *)&params[2]));
break;
case CP_C_PHASE:
cpGearJointSetPhase(constr, modChipmunkdeg2rad(*(float *)&params[2]));
break;
}
return 1;
}
int modsetSimpleMotorProperties(INSTANCE *my, int *params) {
cpConstraint *constr = (cpConstraint *)params[0];
switch (params[1]) {
case CP_C_RATIO:
cpSimpleMotorSetRate(constr, modChipmunkdeg2rad(*(float *)&params[2]));
break;
}
return 1;
}
int modgetPinJointProperties(INSTANCE *my, int *params) {
cpConstraint *constr = (cpConstraint *)params[0];
cpVect ar;
float *a, *b, res;
switch (params[1]) {
case CP_C_ANCHR1:
ar = cpPinJointGetAnchr1(constr);
a = params[2];
b = params[3];
*a = ar.x;
*b = ar.y;
break;
case CP_C_ANCHR2:
ar = cpPinJointGetAnchr2(constr);
a = params[2];
b = params[3];
*a = ar.x;
*b = ar.y;
break;
case CP_C_DIST:
res = cpPinJointGetDist(constr);
return *(int *)&res;
break;
}
return 1;
}
int modgetSlideJointProperties(INSTANCE *my, int *params) {
cpConstraint *constr = (cpConstraint *)params[0];
cpVect ar;
float *a, *b, res;
switch (params[1]) {
case CP_C_ANCHR1:
ar = cpSlideJointGetAnchr1(constr);
a = params[2];
b = params[3];
*a = ar.x;
*b = ar.y;
break;
case CP_C_ANCHR2:
ar = cpSlideJointGetAnchr2(constr);
a = params[2];
b = params[3];
*a = ar.x;
*b = ar.y;
break;
case CP_C_MIN:
res = cpSlideJointGetMin(constr);
return *(int *)&res;
break;
case CP_C_MAX:
res = cpSlideJointGetMax(constr);
return *(int *)&res;
break;
}
return 1;
}
int modgetPivotJointProperties(INSTANCE *my, int *params) {
cpConstraint *constr = (cpConstraint *)params[0];
cpVect ar;
float *a, *b, res;
switch (params[1]) {
case CP_C_ANCHR1:
ar = cpPivotJointGetAnchr1(constr);
a = params[2];
b = params[3];
*a = ar.x;
*b = ar.y;
break;
case CP_C_ANCHR2:
ar = cpPivotJointGetAnchr2(constr);
a = params[2];
b = params[3];
*a = ar.x;
*b = ar.y;
break;
}
return 1;
}
int modgetGrooveJointProperties(INSTANCE *my, int *params) {
cpConstraint *constr = (cpConstraint *)params[0];
cpVect ar;
float *a, *b, res;
switch (params[1]) {
case CP_C_GROOVEA:
ar = cpGrooveJointGetGrooveA(constr);
a = params[2];
b = params[3];
*a = ar.x;
*b = ar.y;
break;
case CP_C_GROOVEB:
ar = cpGrooveJointGetGrooveB(constr);
a = params[2];
b = params[3];
*a = ar.x;
*b = ar.y;
break;
case CP_C_ANCHR2:
cpGrooveJointGetAnchr2(constr);
a = params[2];
b = params[3];
*a = ar.x;
*b = ar.y;
break;
}
return 1;
}
int modgetDampedSpringProperties(INSTANCE *my, int *params) {
cpConstraint *constr = (cpConstraint *)params[0];
cpVect ar;
float *a, *b, res;
switch (params[1]) {
case CP_C_ANCHR1:
ar = cpDampedSpringGetAnchr1(constr);
a = params[2];
b = params[3];
*a = ar.x;
*b = ar.y;
break;
case CP_C_ANCHR2:
ar = cpDampedSpringGetAnchr2(constr);
a = params[2];
b = params[3];
*a = ar.x;
*b = ar.y;
break;
case CP_C_RESTLENGTH:
res = cpDampedSpringGetRestLength(constr);
return *(int *)&res;
break;
case CP_C_STIFFNESS:
res = cpDampedSpringGetStiffness(constr);
return *(int *)&res;
break;