From 637dcc82c8595130b3627c526126946b43c0707a Mon Sep 17 00:00:00 2001 From: Wintermute Date: Tue, 22 Oct 2013 21:20:01 +0200 Subject: [PATCH] Jumprun-Foo in Verzeichnis auf Badge. --- badge/jumpnrun/levels.h | 5 ++++- badge/jumpnrun/starter.c | 10 +++++++--- badge/ui/browser.c | 6 ++++++ badge/ui/browser.h | 6 ++++++ 4 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 badge/ui/browser.c create mode 100644 badge/ui/browser.h diff --git a/badge/jumpnrun/levels.h b/badge/jumpnrun/levels.h index c4336cb..c02ab97 100644 --- a/badge/jumpnrun/levels.h +++ b/badge/jumpnrun/levels.h @@ -10,6 +10,8 @@ #include #include +#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)) { \ diff --git a/badge/jumpnrun/starter.c b/badge/jumpnrun/starter.c index 93e769c..0645487 100644 --- a/badge/jumpnrun/starter.c +++ b/badge/jumpnrun/starter.c @@ -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 index 0000000..4c37f94 --- /dev/null +++ b/badge/ui/browser.c @@ -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 index 0000000..f1d0348 --- /dev/null +++ b/badge/ui/browser.h @@ -0,0 +1,6 @@ +#ifndef INCLUDED_BADGE_UI_BROWSER_H +#define INCLUDED_BADGE_UI_BROWSER_H + +void badge_browse_textfile(char const *fname); + +#endif -- 2.20.1