97 lines
1.9 KiB
C
97 lines
1.9 KiB
C
|
#include <string.h>
|
||
|
|
||
|
#include <gint/display.h>
|
||
|
#include <gint/keyboard.h>
|
||
|
|
||
|
#include "fsctl/menu.h"
|
||
|
#include "fsctl/fugue.h"
|
||
|
#include "fsctl/fugue/cluster.h"
|
||
|
#include "fsctl/fugue/utils.h"
|
||
|
#include "fsctl/utils/fs_table.h"
|
||
|
#include "fsctl/utils/display.h"
|
||
|
|
||
|
//---
|
||
|
// internals
|
||
|
//---
|
||
|
|
||
|
/* internal information */
|
||
|
static int clus_idx = 0;
|
||
|
|
||
|
/* fat_cluster_is_valid() : check cluster information */
|
||
|
static int fat_cluster_is_valid(fugue_fs_t *fs, int idx)
|
||
|
{
|
||
|
switch (fugue_cluster_is_valid(fs, idx))
|
||
|
{
|
||
|
case 0:
|
||
|
return C_WHITE;
|
||
|
default:
|
||
|
return C_RED;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
//---
|
||
|
// Public
|
||
|
//---
|
||
|
|
||
|
/* fat_menu_init() : init menu */
|
||
|
void fat_menu_init(void)
|
||
|
{
|
||
|
clus_idx = 0;
|
||
|
}
|
||
|
|
||
|
/* fat1_menu_display() : display menu */
|
||
|
void fat_menu_display(void)
|
||
|
{
|
||
|
fugue_fs_t fs;
|
||
|
uint16_t *table;
|
||
|
int idx;
|
||
|
|
||
|
fs_table_dtitle();
|
||
|
if (fs_table_info(&fs, NULL, NULL) != 0)
|
||
|
return;
|
||
|
|
||
|
idx = clus_idx;
|
||
|
table = fs._private.fat1;
|
||
|
for (int y = 1 ; y < 18 ; y++)
|
||
|
{
|
||
|
_printXY(0, y, "%p", &table[idx]);
|
||
|
for (int x = 0 ; x < 6 ; x++)
|
||
|
{
|
||
|
_lrectXY(x, y, fat_cluster_is_valid(&fs, idx));
|
||
|
_lrectTextXY(x, y, FAT_WORD(table[idx]));
|
||
|
idx += 1;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* fat_menu_keyboard() : handle keyboard */
|
||
|
void fat_menu_keyboard(int key)
|
||
|
{
|
||
|
switch (key)
|
||
|
{
|
||
|
case KEY_SHIFT:
|
||
|
clus_idx += 6;
|
||
|
break;
|
||
|
case KEY_ALPHA:
|
||
|
clus_idx -= 6;
|
||
|
break;
|
||
|
case KEY_EXIT:
|
||
|
clus_idx = 0;
|
||
|
break;
|
||
|
case KEY_DOWN:
|
||
|
clus_idx += 6 * 17;
|
||
|
break;
|
||
|
case KEY_UP:
|
||
|
clus_idx -= 6 * 17;
|
||
|
break;
|
||
|
case KEY_LEFT:
|
||
|
fs_table_select_left();
|
||
|
break;
|
||
|
case KEY_RIGHT:
|
||
|
fs_table_select_right();
|
||
|
break;
|
||
|
}
|
||
|
if (clus_idx < 0)
|
||
|
clus_idx = 0;
|
||
|
}
|