2 #include "../ui/menu.h"
4 #include <drivers/fatfs/ff.h>
8 LEVELDESCRIPTION_MAX
= 14,
9 MENU_BUFLEN
= LEVELDESCRIPTION_MAX
+ 1 + LEVELFILE_MAX
+ 1
12 static uint8_t jumpnrun_pick_level_from_fd(char *buf
, size_t *first_visible
, size_t *selected
, FIL
*fd
) {
13 unsigned levelcount
= 0;
16 char buf
[MENU_BUFLEN
];
17 while(f_gets(buf
, MENU_BUFLEN
, fd
)) {
22 if(FR_OK
!= f_lseek(fd
, 0)) {
23 return JUMPNRUN_ERROR
;
26 char menu_buf
[levelcount
][MENU_BUFLEN
];
27 char const *menu_index
[levelcount
];
28 char const *fnames
[levelcount
];
31 for(i
= 0; i
< levelcount
&& f_gets(menu_buf
[i
], MENU_BUFLEN
, fd
); ++i
) {
32 menu_index
[i
] = menu_buf
[i
];
34 for(p
= menu_buf
[i
]; *p
&& *p
!= '|'; ++p
)
42 *selected
= badge_menu(menu_index
, i
, first_visible
, *selected
);
44 strcpy(buf
, fnames
[*selected
]);
48 static uint8_t jumpnrun_pick_level(char *buf
, size_t *first_visible
, size_t *selected
) {
51 if(FR_OK
!= f_open(&fd
, "levels.lst", FA_OPEN_EXISTING
| FA_READ
)) {
52 return JUMPNRUN_ERROR
;
55 uint8_t err
= jumpnrun_pick_level_from_fd(buf
, first_visible
, selected
, &fd
);
62 void jumpnrun_play(void) {
63 char buf
[LEVELFILE_MAX
+ 1];
64 size_t first_visible
= 0;
67 while(0 == jumpnrun_pick_level(buf
, &first_visible
, &selected
)) {
68 jumpnrun_play_level(buf
);
This page took 0.057663 seconds and 5 git commands to generate.