summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-12-08 12:39:02 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-12-08 12:39:02 -0600
commit2cf33eff014e7de2dab04d15159c75a976f337f9 (patch)
tree2df7307ba6e1d04d777485e9fa5b7ca635f10edd
parent8b9a789357596d976105ad1e73d369ddfd189683 (diff)
downloadnuttx-2cf33eff014e7de2dab04d15159c75a976f337f9.tar.gz
nuttx-2cf33eff014e7de2dab04d15159c75a976f337f9.tar.bz2
nuttx-2cf33eff014e7de2dab04d15159c75a976f337f9.zip
Travel: Fix more initialization errors, mostly related to file path problems
-rw-r--r--apps/graphics/traveler/include/trv_bitmaps.h4
-rw-r--r--apps/graphics/traveler/src/trv_bitmapfile.c28
-rw-r--r--apps/graphics/traveler/src/trv_main.c13
-rw-r--r--apps/graphics/traveler/src/trv_texturefile.c4
-rw-r--r--apps/graphics/traveler/src/trv_world.c2
-rw-r--r--nuttx/configs/sim/README.txt6
-rw-r--r--nuttx/configs/sim/traveler/defconfig7
7 files changed, 47 insertions, 17 deletions
diff --git a/apps/graphics/traveler/include/trv_bitmaps.h b/apps/graphics/traveler/include/trv_bitmaps.h
index 948f55dce..b3a2caabf 100644
--- a/apps/graphics/traveler/include/trv_bitmaps.h
+++ b/apps/graphics/traveler/include/trv_bitmaps.h
@@ -101,7 +101,7 @@ extern trv_pixel_t g_ground_color;
int trv_initialize_bitmaps(void);
void trv_release_bitmaps(void);
-int trv_load_bitmapfile(FAR const char *bitmapfile);
-FAR struct trv_bitmap_s *trv_read_texture(FAR char *filename);
+int trv_load_bitmapfile(FAR const char *bitmapfile, FAR const char *wldpath);
+FAR struct trv_bitmap_s *trv_read_texture(FAR const char *filename);
#endif /* __APPS_GRAPHICS_TRAVELER_INCLUDE_TRV_BITMAPS_H */
diff --git a/apps/graphics/traveler/src/trv_bitmapfile.c b/apps/graphics/traveler/src/trv_bitmapfile.c
index ea39eaae9..a17986868 100644
--- a/apps/graphics/traveler/src/trv_bitmapfile.c
+++ b/apps/graphics/traveler/src/trv_bitmapfile.c
@@ -45,6 +45,7 @@
#include "trv_fsutils.h"
#include <stdio.h>
+#include <stdlib.h>
#include <ctype.h>
#include <errno.h>
@@ -127,8 +128,9 @@ static int trv_read_filename(FAR FILE *fp, FAR char *filename)
*
***************************************************************************/
-static int trv_load_bitmaps(FAR FILE *fp)
+static int trv_load_bitmaps(FAR FILE *fp, FAR const char *wldpath)
{
+ FAR char *fullpath;
char filename[FILENAME_MAX];
int mapndx;
int ret = OK;
@@ -163,7 +165,15 @@ static int trv_load_bitmaps(FAR FILE *fp)
return ret;
}
- g_even_bitmaps[mapndx] = trv_read_texture(filename);
+ /* Get the full path to the even bit map file */
+
+ fullpath = trv_fullpath(wldpath, filename);
+
+ /* Read the bitmap texture file */
+
+ g_even_bitmaps[mapndx] = trv_read_texture(fullpath);
+ free(fullpath);
+
if (!g_even_bitmaps[mapndx])
{
return -EIO;
@@ -179,7 +189,15 @@ static int trv_load_bitmaps(FAR FILE *fp)
}
#ifndef WEDIT
- g_odd_bitmaps[mapndx] = trv_read_texture(filename);
+ /* Get the full path to the even bit map file */
+
+ fullpath = trv_fullpath(wldpath, filename);
+
+ /* Read the bitmap texture file */
+
+ g_odd_bitmaps[mapndx] = trv_read_texture(fullpath);
+ free(fullpath);
+
if (!g_odd_bitmaps[mapndx])
{
return -EIO;
@@ -202,7 +220,7 @@ static int trv_load_bitmaps(FAR FILE *fp)
*
***************************************************************************/
-int trv_load_bitmapfile(FAR const char *bitmapfile)
+int trv_load_bitmapfile(FAR const char *bitmapfile, FAR const char *wldpath)
{
FAR FILE *fp;
int ret;
@@ -218,7 +236,7 @@ int trv_load_bitmapfile(FAR const char *bitmapfile)
/* Load all of the bitmaps */
- ret = trv_load_bitmaps(fp);
+ ret = trv_load_bitmaps(fp, wldpath);
if (ret < 0)
{
trv_release_bitmaps();
diff --git a/apps/graphics/traveler/src/trv_main.c b/apps/graphics/traveler/src/trv_main.c
index 078a5aef9..53cc1cca8 100644
--- a/apps/graphics/traveler/src/trv_main.c
+++ b/apps/graphics/traveler/src/trv_main.c
@@ -169,7 +169,6 @@ int traveler_main(int argc, char *argv[])
FAR const char *wldfile;
#ifdef CONFIG_GRAPHICS_TRAVELER_PERFMON
int32_t frame_count = 0;
- double elapsed_time = 0.0;
double start_time;
#endif
int ret;
@@ -265,14 +264,20 @@ int traveler_main(int argc, char *argv[])
/* Display the world. */
trv_display_update(&g_trv_ginfo);
+
#ifdef CONFIG_GRAPHICS_TRAVELER_PERFMON
+ /* Show the frame rate */
+
frame_count++;
- elapsed_time += trv_current_time() - start_time;
if (frame_count == 100)
{
- fprintf(stderr, "fps = %3.2f\n", (double) frame_count / elapsed_time);
+ double now = trv_current_time();
+ double elapsed = now - start_time;
+
+ fprintf(stderr, "fps = %3.2f\n", (double)frame_count / elapsed);
+
frame_count = 0;
- elapsed_time = 0.0;
+ start_time = now;
}
#endif
}
diff --git a/apps/graphics/traveler/src/trv_texturefile.c b/apps/graphics/traveler/src/trv_texturefile.c
index 8fb5d2404..671e01c83 100644
--- a/apps/graphics/traveler/src/trv_texturefile.c
+++ b/apps/graphics/traveler/src/trv_texturefile.c
@@ -178,7 +178,7 @@ static void trv_quantize_texture(FAR struct trv_graphicfile_s *gfile,
*
***************************************************************************/
-FAR struct trv_bitmap_s *trv_read_texture(char *filename)
+FAR struct trv_bitmap_s *trv_read_texture(FAR const char *filename)
{
FAR struct trv_graphicfile_s *gfile;
FAR struct trv_bitmap_s *bitmap;
@@ -186,7 +186,7 @@ FAR struct trv_bitmap_s *trv_read_texture(char *filename)
gfile = tvr_graphicfile_read(filename);
if (gfile == NULL)
{
- fprintf(stderr, "Error reading texture %s.", filename);
+ fprintf(stderr, "ERROR: Read failed for texture %s\n", filename);
return NULL;
}
diff --git a/apps/graphics/traveler/src/trv_world.c b/apps/graphics/traveler/src/trv_world.c
index 084a1ea74..097205b98 100644
--- a/apps/graphics/traveler/src/trv_world.c
+++ b/apps/graphics/traveler/src/trv_world.c
@@ -415,7 +415,7 @@ static int trv_manage_wldfile(INIHANDLE inihandle, FAR const char *wldpath)
return ret;
}
- ret = trv_load_bitmapfile(filename);
+ ret = trv_load_bitmapfile(filename, wldpath);
free(filename);
return ret;
diff --git a/nuttx/configs/sim/README.txt b/nuttx/configs/sim/README.txt
index 2bfd7b941..641a73ed2 100644
--- a/nuttx/configs/sim/README.txt
+++ b/nuttx/configs/sim/README.txt
@@ -682,3 +682,9 @@ traveler
cd /usr/lib/
sudo ln -s libXext.so.6.4.0 libXext.so
+ 4. Don't enable CONFIG_GRAPHICS_TRAVELER_PERFMON. Timing is
+ really important on the target platform anyway. But for the
+ simulation platform, timing works very strangely since there
+ are not timer interrupts. So if this is enabled you will
+ most likely get divide-by-zero errors.
+
diff --git a/nuttx/configs/sim/traveler/defconfig b/nuttx/configs/sim/traveler/defconfig
index a5cb6cb4f..1aaa79b2c 100644
--- a/nuttx/configs/sim/traveler/defconfig
+++ b/nuttx/configs/sim/traveler/defconfig
@@ -234,7 +234,8 @@ CONFIG_NAME_MAX=32
#
# RTOS hooks
#
-# CONFIG_BOARD_INITIALIZE is not set
+CONFIG_BOARD_INITIALIZE=y
+# CONFIG_BOARD_INITTHREAD is not set
# CONFIG_SCHED_STARTHOOK is not set
# CONFIG_SCHED_ATEXIT is not set
# CONFIG_SCHED_ONEXIT is not set
@@ -433,7 +434,7 @@ CONFIG_STDIO_LINEBUFFER=y
CONFIG_NUNGET_CHARS=2
CONFIG_LIBM=y
# CONFIG_NOPRINTF_FIELDWIDTH is not set
-# CONFIG_LIBC_FLOATINGPOINT is not set
+CONFIG_LIBC_FLOATINGPOINT=y
# CONFIG_LIBC_IOCTL_VARIADIC is not set
CONFIG_LIB_RAND_ORDER=1
# CONFIG_EOL_IS_CR is not set
@@ -552,7 +553,7 @@ CONFIG_GRAPHICS_TRAVELER_PALRANGES=y
# Debug options
#
CONFIG_GRAPHICS_TRAVELER_ROMFSDEMO=y
-CONFIG_GRAPHICS_TRAVELER_PERFMON=y
+# CONFIG_GRAPHICS_TRAVELER_PERFMON is not set
CONFIG_GRAPHICS_TRAVELER_DEBUG_LEVEL=3
#