Further work

This commit is contained in:
Robin Jones 2023-04-12 00:10:24 +00:00
parent 40017a53a6
commit 37f6352eec

View File

@ -13,8 +13,8 @@
#include "menu_fileinfo.h" #include "menu_fileinfo.h"
#include "rom_database.h" #include "rom_database.h"
static int scroll_menu_position = 0; static int scroll_menu_position = 1;
static int items_in_dir = 0; static int items_in_dir = 1;
static FILINFO current_fileinfo; static FILINFO current_fileinfo;
@ -57,7 +57,7 @@ FRESULT scan_file_path (char* path) {
((file_info.fattrib & AM_HID) ? 'H' : '-'), ((file_info.fattrib & AM_HID) ? 'H' : '-'),
(int)file_info.fsize, file_info.fname); (int)file_info.fsize, file_info.fname);
if (scroll_menu_position == counter -1) { if (scroll_menu_position == counter) {
printf("-> %s\n", sfno); printf("-> %s\n", sfno);
current_fileinfo = file_info; current_fileinfo = file_info;
} }
@ -66,7 +66,7 @@ FRESULT scan_file_path (char* path) {
} }
} }
} }
items_in_dir = counter -1; items_in_dir = counter;
f_closedir(&dir); f_closedir(&dir);
return res; return res;
} }
@ -74,7 +74,8 @@ FRESULT scan_file_path (char* path) {
void menu_main_refresh (char *dir_path) { void menu_main_refresh (char *dir_path) {
console_clear(); console_clear();
printf("SC64 Flashcart Menu Rev: 0.0.2\n\n"); printf("SC64 Flashcart Menu Rev: 0.0.2\n\n");
printf("SD Card Directory list:\n\n"); printf("SD Card Directory list: %s\n\n", dir_path);
printf("SD Card Directory files: %d of %d\n\n", scroll_menu_position, items_in_dir);
printf(" | DRH | FILE SIZE | FILE NAME\n"); printf(" | DRH | FILE SIZE | FILE NAME\n");
printf(" |-----|------------|----------\n"); printf(" |-----|------------|----------\n");
scan_file_path(dir_path); scan_file_path(dir_path);
@ -112,7 +113,7 @@ void menu_main_init (settings_t *settings) {
if (joypad.c[0].up) { if (joypad.c[0].up) {
//console_clear(); //console_clear();
if (scroll_menu_position > 0) { if (scroll_menu_position > 1 && scroll_menu_position <= items_in_dir) {
scroll_menu_position --; scroll_menu_position --;
} }
else { else {
@ -123,11 +124,11 @@ void menu_main_init (settings_t *settings) {
if (joypad.c[0].down) { if (joypad.c[0].down) {
//console_clear(); //console_clear();
if ((scroll_menu_position >= 0) && (scroll_menu_position < items_in_dir)) { if (scroll_menu_position < items_in_dir) {
scroll_menu_position ++; scroll_menu_position ++;
} }
else { else {
scroll_menu_position = 0; scroll_menu_position = 1;
} }
menu_main_refresh(current_dir); menu_main_refresh(current_dir);
} }
@ -150,10 +151,10 @@ void menu_main_init (settings_t *settings) {
else { else {
if (current_fileinfo.fattrib & AM_DIR) { if (current_fileinfo.fattrib & AM_DIR) {
// if this is a directory we need to transverse to it! // if this is a directory we need to transverse to it!
items_in_dir = 1;
scroll_menu_position = 1;
last_dir = current_dir; last_dir = current_dir;
current_dir = current_fileinfo.fname; current_dir = current_fileinfo.fname;
scroll_menu_position = 0;
items_in_dir = 0;
menu_main_refresh(current_dir); menu_main_refresh(current_dir);
} }
else { else {