summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-12-15 07:57:16 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-12-15 07:57:16 -0600
commit6c54f26d9e481f3915c290615dcd0370212c46f4 (patch)
treecfe1e5bc3aeaa5bcd5f975d4eee0fac58a6cdf16 /apps
parentc1fa1ec55e559219d1726194f0a4f97867a0763a (diff)
downloadnuttx-6c54f26d9e481f3915c290615dcd0370212c46f4.tar.gz
nuttx-6c54f26d9e481f3915c290615dcd0370212c46f4.tar.bz2
nuttx-6c54f26d9e481f3915c290615dcd0370212c46f4.zip
Traveler: Add another trivial plane management tool
Diffstat (limited to 'apps')
-rw-r--r--apps/graphics/traveler/tools/.gitignore3
-rw-r--r--apps/graphics/traveler/tools/Makefile.host19
-rw-r--r--apps/graphics/traveler/tools/misc/mktrig.c188
-rw-r--r--apps/graphics/traveler/tools/misc/pll2txt.c1
-rwxr-xr-xapps/graphics/traveler/tools/misc/txt2pll.c3
5 files changed, 208 insertions, 6 deletions
diff --git a/apps/graphics/traveler/tools/.gitignore b/apps/graphics/traveler/tools/.gitignore
index 2fb541fc0..a8d33fce0 100644
--- a/apps/graphics/traveler/tools/.gitignore
+++ b/apps/graphics/traveler/tools/.gitignore
@@ -1,3 +1,6 @@
/pll2txt
+/txt2pll
+/mktrig
+/trigtbl.tmp
/*.exe
/*.dSYM
diff --git a/apps/graphics/traveler/tools/Makefile.host b/apps/graphics/traveler/tools/Makefile.host
index e2116a2fd..22da1da4c 100644
--- a/apps/graphics/traveler/tools/Makefile.host
+++ b/apps/graphics/traveler/tools/Makefile.host
@@ -73,16 +73,19 @@ PLL2TXT_OBJS = $(PLL2TXT_SRCS:.c=$(OBJEXT))
TXT2PLL_SRCS = txt2pll.c
TXT2PLL_OBJS = $(TXT2PLL_SRCS:.c=$(OBJEXT))
-OBJS = $(PLL2TXT_OBJS) $(TXT2PLL_OBJS)
+MKTRIG_SRCS = mktrig.c
+MKTRIG_OBJS = $(MKTRIG_SRCS:.c=$(OBJEXT))
+
+OBJS = $(PLL2TXT_OBJS) $(TXT2PLL_OBJS) $(MKTRIG_OBJS)
# Targets
-all: pll2txt$(HOSTEXEEXT) txt2pll$(HOSTEXEEXT)
+all: pll2txt$(HOSTEXEEXT) txt2pll$(HOSTEXEEXT) mktrig$(HOSTEXEEXT)
default: all
ifdef HOSTEXEEXT
-.PHONY: pll2txt txt2pll clean
+.PHONY: pll2txt txt2pll mktrig clean
else
.PHONY: clean
endif
@@ -108,9 +111,19 @@ ifdef HOSTEXEEXT
txt2pll: txt2pll$(HOSTEXEEXT)
endif
+# mktrig - Regenerate trigonometry look-up tables
+
+mktrig$(HOSTEXEEXT): $(MKTRIG_OBJS)
+ $(Q) $(HOSTCC) $(HOSTCFLAGS) $< -o $@
+
+ifdef HOSTEXEEXT
+mktrig: mktrig$(HOSTEXEEXT)
+endif
+
clean:
$(call DELFILE, pll2txt$(HOSTEXEEXT))
$(call DELFILE, txt2pll$(HOSTEXEEXT))
+ $(call DELFILE, mktrig$(HOSTEXEEXT))
ifneq ($(CONFIG_WINDOWS_NATIVE),y)
$(Q) rm -rf *.dSYM
endif
diff --git a/apps/graphics/traveler/tools/misc/mktrig.c b/apps/graphics/traveler/tools/misc/mktrig.c
new file mode 100644
index 000000000..6d5d89848
--- /dev/null
+++ b/apps/graphics/traveler/tools/misc/mktrig.c
@@ -0,0 +1,188 @@
+
+/*******************************************************************************
+ * apps/graphics/traveler/tools/misc/mktrig.c
+ *
+ * Copyright (C) 2014 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <gnutt@nuttx.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included files
+ ****************************************************************************/
+
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+/****************************************************************************
+ * Included files
+ ****************************************************************************/
+
+#define PI 3.1415926
+
+/****************************************************************************
+ * Included files
+ ****************************************************************************/
+
+int main(int argc, char **argv, char **envp)
+{
+ FILE *outfile;
+ double angle;
+ double valuef;
+ uint32_t value32;
+ uint16_t value16;
+ int i;
+ int j;
+
+ outfile = fopen("trigtbl.tmp", "w");
+ if (!outfile)
+ {
+ fprintf(stderr, "Unable to open trigtbl.tmp\n");
+ exit(1);
+ }
+
+ fprintf(outfile, "#define TWOPI 1920\n");
+ fprintf(outfile, "#define PI 960\n");
+ fprintf(outfile, "#define HALFPI 480\n");
+ fprintf(outfile, "#define QTRPI 240\n\n");
+
+ fprintf(outfile, "const int32_t g_tan_table[PI + HALFPI + 1] =\n");
+ fprintf(outfile, "{\n");
+
+ for (i = 0; i < 1440;)
+ {
+ fprintf(outfile, " ");
+ for (j = 0; ((j < 5) && (i < 1440));)
+ {
+ angle = ((double)i) * (2.0 * PI / 1920.0);
+ valuef = (4096.0 * tan(angle));
+ if (valuef >= 0.0)
+ {
+ valuef += 0.5;
+ }
+ else
+ {
+ valuef -= 0.5;
+ }
+
+ value32 = (uint32_t)((long)(valuef));
+ fprintf(outfile, "0x%08lx", (unsigned long)value32);
+
+ i++;
+ j++;
+ if ((j < 5) && (i < 1440))
+ {
+ fprintf(outfile, ", ");
+ }
+ }
+
+ fprintf(outfile, ",\n");
+ }
+
+ fprintf(outfile, " 0x00000000\n");
+ fprintf(outfile, "};\n\n");
+
+ fprintf(outfile, "const int16_t g_sin_table[TWOPI + HALFPI + 1] =\n");
+ fprintf(outfile, "{\n");
+
+ for (i = 0; i < 2400;)
+ {
+ fprintf(outfile, " ");
+ for (j = 0; ((j < 8) && (i < 2400));)
+ {
+ angle = ((double)i) * (2.0 * PI / 1920.0);
+ valuef = (4096.0 * sin(angle));
+ if (valuef >= 0.0)
+ {
+ valuef += 0.5;
+ }
+ else
+ {
+ valuef -= 0.5;
+ }
+
+ value16 = (uint16_t)((long)(valuef));
+ fprintf(outfile, "0x%04x", (unsigned int)value16);
+
+ i++;
+ j++;
+ if ((j < 8) && (i < 2400))
+ {
+ fprintf(outfile, ", ");
+ }
+ }
+
+ fprintf(outfile, ",\n");
+ }
+
+ fprintf(outfile, " 0x1000\n");
+ fprintf(outfile, "};\n\n");
+
+ fprintf(outfile, "const int32_t cscTable[TWOPI + HALFPI + 1] =\n");
+ fprintf(outfile, "{\n");
+
+ for (i = 0; i < 2400;)
+ {
+ fprintf(outfile, " ");
+ for (j = 0; ((j < 5) && (i < 2400));)
+ {
+ angle = ((double)i) * (2.0 * PI / 1920.0);
+ valuef = (4096.0 / sin(angle));
+ if (valuef >= 0.0)
+ {
+ valuef += 0.5;
+ }
+ else
+ {
+ valuef -= 0.5;
+ }
+
+ value32 = (uint32_t)((long)(valuef));
+ fprintf(outfile, "0x%08lx", (unsigned long)value32);
+
+ i++;
+ j++;
+ if ((j < 5) && (i < 2400))
+ {
+ fprintf(outfile, ", ");
+ }
+ }
+
+ fprintf(outfile, ",\n");
+ }
+
+ fprintf(outfile, " 0x00001000\n");
+ fprintf(outfile, "};\n\n");
+
+ fclose(outfile);
+ return 0;
+}
diff --git a/apps/graphics/traveler/tools/misc/pll2txt.c b/apps/graphics/traveler/tools/misc/pll2txt.c
index 76da566a8..594e7681e 100644
--- a/apps/graphics/traveler/tools/misc/pll2txt.c
+++ b/apps/graphics/traveler/tools/misc/pll2txt.c
@@ -1,6 +1,5 @@
/*******************************************************************************
* apps/graphics/traveler/tools/misc/pll2txt.c
- * This file contains low-level texture bitmap logic
*
* Copyright (C) 2014 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
diff --git a/apps/graphics/traveler/tools/misc/txt2pll.c b/apps/graphics/traveler/tools/misc/txt2pll.c
index f77f07edb..c7b9a9e9d 100755
--- a/apps/graphics/traveler/tools/misc/txt2pll.c
+++ b/apps/graphics/traveler/tools/misc/txt2pll.c
@@ -1,6 +1,5 @@
/*******************************************************************************
- * apps/graphics/traveler/tools/misc/pll2txt.c
- * This file contains low-level texture bitmap logic
+ * apps/graphics/traveler/tools/misc/txt2pll.c
*
* Copyright (C) 2014 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>