Jumprun-Foo in Verzeichnis auf Badge.
authorWintermute <wintermute@hannover.ccc.de>
Tue, 22 Oct 2013 19:20:01 +0000 (21:20 +0200)
committerWintermute <wintermute@hannover.ccc.de>
Tue, 22 Oct 2013 19:20:01 +0000 (21:20 +0200)
badge/jumpnrun/levels.h
badge/jumpnrun/starter.c
badge/ui/browser.c [new file with mode: 0644]
badge/ui/browser.h [new file with mode: 0644]

index c4336cb..c02ab97 100644 (file)
@@ -10,6 +10,8 @@
 #include <stddef.h>
 #include <stdio.h>
 
+#define JUMPNRUN_PATH "/hackio"
+
 typedef struct jumpnrun_level_header {
   uint16_t tile_count;
   uint16_t item_count;
@@ -73,7 +75,8 @@ int jumpnrun_load_level_from_file       (jumpnrun_level *dest, FIL *fd);
 #define JUMPNRUN_LEVEL_LOAD(lv, lvname)                                 \
   memset(&(lv), 0, sizeof(lv));                                         \
   FIL fd;                                                               \
-  if(FR_OK != f_open(&fd, (lvname), FA_OPEN_EXISTING | FA_READ)) {      \
+  if(FR_OK != f_chdir(JUMPNRUN_PATH) ||                                 \
+     FR_OK != f_open(&fd, (lvname), FA_OPEN_EXISTING | FA_READ)) {      \
     return JUMPNRUN_ERROR;                                              \
   }                                                                     \
   if(0 != jumpnrun_load_level_header_from_file(&(lv), &fd)) {           \
index 93e769c..0645487 100644 (file)
@@ -15,7 +15,9 @@ static uint8_t jumpnrun_load_progress(void) {
   uint8_t progress = 0;
   FIL fd;
 
-  if(FR_OK == f_open(&fd, PROGRESS_FNAME, FA_OPEN_EXISTING | FA_READ)) {
+
+  if(FR_OK == f_chdir(JUMPNRUN_PATH) &&
+     FR_OK == f_open(&fd, PROGRESS_FNAME, FA_OPEN_EXISTING | FA_READ)) {
     UINT bytes;
     f_read(&fd, &progress, sizeof(progress), &bytes);
     f_close(&fd);
@@ -27,7 +29,8 @@ static uint8_t jumpnrun_load_progress(void) {
 static void jumpnrun_save_progress(uint8_t progress) {
   FIL fd;
 
-  if(FR_OK == f_open(&fd, PROGRESS_FNAME, FA_CREATE_ALWAYS | FA_WRITE)) {
+  if(FR_OK == f_chdir(JUMPNRUN_PATH) &&
+     FR_OK == f_open(&fd, PROGRESS_FNAME, FA_CREATE_ALWAYS | FA_WRITE)) {
     UINT bytes;
     f_write(&fd, &progress, sizeof(progress), &bytes);
     f_close(&fd);
@@ -80,7 +83,8 @@ static uint8_t jumpnrun_pick_level_from_fd(char *buf, size_t *first_visible, siz
 static uint8_t jumpnrun_pick_level(char *buf, size_t *first_visible, size_t *selected, uint8_t progress) {
   FIL fd;
 
-  if(FR_OK != f_open(&fd, "levels.lst", FA_OPEN_EXISTING | FA_READ)) {
+  if(FR_OK != f_chdir(JUMPNRUN_PATH) ||
+     FR_OK != f_open(&fd, "levels.lst", FA_OPEN_EXISTING | FA_READ)) {
     return JUMPNRUN_ERROR;
   }
 
diff --git a/badge/ui/browser.c b/badge/ui/browser.c
new file mode 100644 (file)
index 0000000..4c37f94
--- /dev/null
@@ -0,0 +1,6 @@
+#include "browser.h"
+#include "menu.h"
+
+void badge_browse_textfile(char const *fname) {
+
+}
diff --git a/badge/ui/browser.h b/badge/ui/browser.h
new file mode 100644 (file)
index 0000000..f1d0348
--- /dev/null
@@ -0,0 +1,6 @@
+#ifndef INCLUDED_BADGE_UI_BROWSER_H
+#define INCLUDED_BADGE_UI_BROWSER_H
+
+void badge_browse_textfile(char const *fname);
+
+#endif
This page took 0.026317 seconds and 4 git commands to generate.