Schrift auch in Simulator.
authorWintermute <wintermute@hannover.ccc.de>
Sat, 19 Oct 2013 18:21:32 +0000 (20:21 +0200)
committerWintermute <wintermute@hannover.ccc.de>
Sat, 19 Oct 2013 18:21:32 +0000 (20:21 +0200)
badge/jumpnrun/levels.txt
badge/ui/font.c
mock/Makefile

index 93150ce..f60b5c5 100644 (file)
@@ -1,3 +1,4 @@
+lubilove
 gnobbel
 smb
 wrongturn
index 2b60477..8ac8169 100644 (file)
@@ -1,7 +1,32 @@
 #include "font.h"
 #include "sprite.h"
 
+#ifdef __linux__
+#include <stdio.h>
+typedef FILE *FIL;
+typedef uint8_t FRESULT;
+typedef unsigned UINT;
+enum { FR_OK = 0 };
+
+void f_close(FIL *fd) { fclose(*fd); *fd = NULL; }
+FRESULT f_lseek(FIL *fd, unsigned pos) { return fseek(*fd, pos, SEEK_SET); }
+FRESULT f_read(FIL *fd, unsigned char *buffer, size_t buflen, UINT *bytes) {
+  *bytes = fread(buffer, 1, buflen, *fd);
+  return *bytes == 0;
+}
+
+#else
 #include <drivers/fatfs/ff.h>
+#endif
+
+static FRESULT open_font_file(FIL *fd) {
+#ifdef __linux__
+  *fd = fopen("../sprites/font.dat", "r");
+  return fd ? 0 : -1;
+#else
+  return f_open(fd, "font.dat", FA_OPEN_EXISTING | FA_READ);
+#endif
+}
 
 static uint8_t badge_framebuffer_render_char_with_fd(badge_framebuffer *fb, int8_t pos_x, int8_t pos_y, char c, FIL *fd) {
   UINT readbytes;
@@ -21,10 +46,6 @@ static uint8_t badge_framebuffer_render_char_with_fd(badge_framebuffer *fb, int8
   return 0;
 }
 
-static FRESULT open_font_file(FIL *fd) {
-  return f_open(fd, "font.dat", FA_OPEN_EXISTING | FA_READ);
-}
-
 uint8_t badge_framebuffer_render_char(badge_framebuffer *fb, int8_t pos_x, int8_t pos_y, char c) {
   FIL fd;
 
index 2bbea95..34ddd32 100644 (file)
@@ -17,6 +17,7 @@ BADGE_CXXSRCS = mock-main.cc \
                 mock/event.cc \
                 mock/lcd-window.cc
 BADGE_CSRCS   = badge_main_loop.c \
+                ui/font.c \
                 ui/sprite.c \
                 jumpnrun/collision.c \
                 jumpnrun/enemies.c \
This page took 0.028958 seconds and 4 git commands to generate.