The unified diff between revisions [8583f573..] and [1fb418de..] is displayed below. It can also be downloaded as a raw diff.

#
# old_revision [8583f573519b60d2a4dfb35aa4ec8079f05b88c1]
# new_revision [1fb418de708909ffb7935500c5a31bba681e96b8]
#
# patch "src/lsi/abi.h"
#  from [b14a77a718dd8eb49216c167be0519b98baf8b25]
#    to [c408c99ca10bdd772b2a38c5cc07b81c239584e1]
# 
# patch "src/lsi/abispec"
#  from [adb7007fe9480740656a6011fb7fba55e9999579]
#    to [5336cc1c490bbe88b7f99f0d950d9140b0ffd559]
# 
# patch "src/lsi/map3d.c"
#  from [ac23569032a89ca3240a9af9419636f07b2148a8]
#    to [21c3208dd844af80da0ef68286a121ae0203d17b]
# 
# patch "src/lsi/map3d.h"
#  from [2da3591f9e0e1a33df556a7d213288bfa6e53f90]
#    to [04ce8600529310892f86ec8e39c04bb19cf03998]
# 
# patch "src/lsi/vm.c"
#  from [6f62d2db74a2a4932bd876c11abeab092af42a19]
#    to [494a44702b477512e9979cc5799f7e188fa19d2b]
#
============================================================
--- src/lsi/abi.h	b14a77a718dd8eb49216c167be0519b98baf8b25
+++ src/lsi/abi.h	c408c99ca10bdd772b2a38c5cc07b81c239584e1
@@ -18,6 +18,7 @@ int vm_intfn___global_array_load(void);
 int vm_intfn___global_load(void);
 int vm_intfn___global_array_store(void);
 int vm_intfn___global_array_load(void);
+int vm_intfn___stackdump(void);
 int vm_intfn_printint(void);
 int vm_intfn_printreal(void);
 int vm_intfn_printstr(void);
============================================================
--- src/lsi/abispec	adb7007fe9480740656a6011fb7fba55e9999579
+++ src/lsi/abispec	5336cc1c490bbe88b7f99f0d950d9140b0ffd559
@@ -7,6 +7,7 @@ function __global_array_load
 function __global_load
 function __global_array_store
 function __global_array_load
+function __stackdump
 function printint
 function printreal
 function printstr
@@ -21,7 +22,7 @@ function beatdetect_confidence
 function beatdetect_read
 function beatdetect_phase
 function beatdetect_confidence
-funciton realtoint
+function realtoint
 function inttoreal
 function map3d_setcal
 function map3d_calibrate
============================================================
--- src/lsi/map3d.c	ac23569032a89ca3240a9af9419636f07b2148a8
+++ src/lsi/map3d.c	21c3208dd844af80da0ef68286a121ae0203d17b
@@ -24,6 +24,7 @@ struct light {
 	double cp[3][3];
 	double pan[3];
 	double tilt[3];
+	int invert;
 };
 
 struct light map3d_cal[NLIGHTS];
@@ -88,6 +89,10 @@ int map3d_load(void)
 	return 1;
 }
 
+/*
+ * invert bit 0 = swap x/z
+	  bit 1 = invert pan
+ */
 void map3d_transform(int light, double x, double y, double z,
     int *pan, int *tilt)
 {
@@ -97,9 +102,15 @@ void map3d_transform(int light, double x
 
 //	printf("Transforming for light %d: (%f, %f, %f)\n", light, x, y, z);
 	fflush(stdout);
-	pv[0] = x;
-	pv[1] = y;
-	pv[2] = z;
+	if (map3d_cal[light].invert & 1) {
+		pv[0] = z;
+		pv[1] = y;
+		pv[2] = x;
+	} else {
+		pv[0] = x;
+		pv[1] = y;
+		pv[2] = z;
+	}
 	multiply(light, pv, rv);
 	normalise(rv);
 	t = asin(rv[1]);
@@ -115,6 +126,8 @@ void map3d_transform(int light, double x
 		*tilt = 0;
 	if (*tilt > 255)
 		*tilt = 255;
+	if (map3d_cal[light].invert & 2)
+		*pan = 255-*pan;
 //	printf("pan = %d, tilt = %d\n", *pan, *tilt);
 }
 
@@ -594,7 +607,7 @@ int map3d_calibrate(int light)
          tx, ty = pan, tilt of light fixture
 	 tz = distance from light fixture to (0, 0, 0)
  */
-void map3d_setparams(int light, int opan, int otilt, double lpan, double ltilt, double dist)
+void map3d_setparams(int light, int opan, int otilt, double lpan, double ltilt, double dist, int invert)
 {
 	double n[3];
 	double up[3];
@@ -636,6 +649,8 @@ void map3d_setparams(int light, int opan
 	map3d_cal[light].M[3][0] = dist*v[0];
 	map3d_cal[light].M[3][1] = dist*v[1];
 	map3d_cal[light].M[3][2] = dist*v[2];
+	printf ("setting invert = %d\n", invert);
+	map3d_cal[light].invert = invert;
 
 	printf("\t%f\t%f\t%f\t\t%f\n", map3d_cal[light].M[0][0], map3d_cal[light].M[0][1], map3d_cal[light].M[0][2], map3d_cal[light].M[3][0]);
 	printf("\t%f\t%f\t%f\t\t%f\n", map3d_cal[light].M[1][0], map3d_cal[light].M[1][1], map3d_cal[light].M[1][2], map3d_cal[light].M[3][1]);
============================================================
--- src/lsi/map3d.h	2da3591f9e0e1a33df556a7d213288bfa6e53f90
+++ src/lsi/map3d.h	04ce8600529310892f86ec8e39c04bb19cf03998
@@ -8,4 +8,4 @@ int map3d_calibrate(int);
 void map3d_transform(int, double, double, double, int *, int *);
 void map3d_setcal(int, int, double, double, double, int, int);
 int map3d_calibrate(int);
-void map3d_setparams(int, int, int, double, double, double);
+void map3d_setparams(int, int, int, double, double, double, int);
============================================================
--- src/lsi/vm.c	6f62d2db74a2a4932bd876c11abeab092af42a19
+++ src/lsi/vm.c	494a44702b477512e9979cc5799f7e188fa19d2b
@@ -257,6 +257,19 @@ gloadarrayout:
 	return 1;
 }
 
+int vm_intfn___stackdump(void) {
+	int n = vm_current->sp - vm_current->stackbase;
+	int i;
+
+	printf("\n=====Stack dump======\n");
+	for (i = 0; i < n; i++) {
+		int e = stack_get(vm_current, i);
+		printf("%x\t%d\n", e, e);
+	}
+
+	return 1;
+}
+
 int vm_intfn_printint(void)
 {
 	printf("%d", stack_get(vm_current, 1));
@@ -768,12 +781,13 @@ int vm_intfn_map3d_setparams(void)
 
 int vm_intfn_map3d_setparams(void)
 {
-	map3d_setparams(stack_get(vm_current, 6), /* light */
-	    (double)stack_get(vm_current, 5), /* opan */
-	    (double)stack_get(vm_current, 4), /* otilt */
-	    (double)stack_getreal(vm_current, 3), /* lpan */
-	    (double)stack_getreal(vm_current, 2), /* ltilt */
-	    (double)stack_getreal(vm_current, 1)); /* dist */
+	map3d_setparams(stack_get(vm_current, 7), /* light */
+	    (double)stack_get(vm_current, 6), /* opan */
+	    (double)stack_get(vm_current, 5), /* otilt */
+	    (double)stack_getreal(vm_current, 4), /* lpan */
+	    (double)stack_getreal(vm_current, 3), /* ltilt */
+	    (double)stack_getreal(vm_current, 2), /* dist */
+	    (double)stack_get(vm_current, 1)); /* invert */
 	return 1;
 }
 
@@ -897,10 +911,10 @@ void vm_init_functions(void)
 		errx(1, "Bad version - recompile");
 
 	if ((GETINT(vm_codearea, 8) != vm_abiversion1) ||
-	    (GETINT(vm_codearea, 12) == vm_abiversion2) ||
-	    (GETINT(vm_codearea, 16) == vm_abiversion3) ||
-	    (GETINT(vm_codearea, 20) == vm_abiversion4) ||
-	    (GETINT(vm_codearea, 24) == vm_abiversion5))
+	    (GETINT(vm_codearea, 12) != vm_abiversion2) ||
+	    (GETINT(vm_codearea, 16) != vm_abiversion3) ||
+	    (GETINT(vm_codearea, 20) != vm_abiversion4) ||
+	    (GETINT(vm_codearea, 24) != vm_abiversion5))
 		errx(1, "Incompatible ABI version - recompile");
 
 	/* Now, get the function table pointer */
@@ -992,8 +1006,6 @@ int vm_spawn_args(char *fn, int n, ...)
 	}
 	newt->sp = newt->stackbase;
 
-	stack_push(newt, 0); 	/* Return value */
-
 	/* Push optional arguments */
 	va_start(ap, n);
 	while (n--) {
@@ -1003,6 +1015,8 @@ int vm_spawn_args(char *fn, int n, ...)
 	}
 	va_end(ap);
 
+	stack_push(newt, 0); 	/* Return value */
+
 	/* Push return address here, to point to some special thread exit
 	   routine */
 	stack_push(newt, 0);	/* Return address */