From cd225736f95555c7083b642675d013bff8057d76 Mon Sep 17 00:00:00 2001 From: Björn Stenberg Date: Sun, 11 Aug 2002 09:17:47 +0000 Subject: First version of loadable fonts patch by Alex Gitelman git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1666 a1c6a512-1295-4272-9138-f99709370657 --- firmware/drivers/fat.c | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) (limited to 'firmware/drivers/fat.c') diff --git a/firmware/drivers/fat.c b/firmware/drivers/fat.c index 75915bd710..7fe011c863 100644 --- a/firmware/drivers/fat.c +++ b/firmware/drivers/fat.c @@ -27,6 +27,7 @@ #include #endif #include +#include #include "fat.h" #include "ata.h" #include "debug.h" @@ -1029,12 +1030,14 @@ int fat_getnext(struct fat_dir *dir, struct fat_direntry *entry) /* replace shortname with longname? */ if ( longs ) { int j,k,l=0; - /* iterate backwards through the dir entries */ for (j=longs-1; j>=0; j--) { unsigned char* ptr = dir->cached_buf; int index = longarray[j]; - +#ifdef LOADABLE_FONTS + int offset_idx = 0; + unsigned char uni_char[2]; +#endif /* current or cached sector? */ if ( sectoridx >= SECTOR_SIZE ) { if ( sectoridx >= SECTOR_SIZE*2 ) { @@ -1052,16 +1055,39 @@ int fat_getnext(struct fat_dir *dir, struct fat_direntry *entry) index &= SECTOR_SIZE-1; } - /* piece together the name subcomponents. - names are stored in unicode, but we - only grab the low byte (iso8859-1). - */ + /* piece together the name subcomponents. */ +#ifdef LOADABLE_FONTS + for (k=0; k<5; k++) + { + offset_idx = index + k*2 + 1; + uni_char[0] = ptr[offset_idx+1]; + uni_char[1] = ptr[offset_idx]; + entry->name[l++] = from_unicode(uni_char); + } + for (k=0; k<6; k++) + { + offset_idx = index + k*2 + 14; + uni_char[0] = ptr[offset_idx+1]; + uni_char[1] = ptr[offset_idx]; + entry->name[l++] = from_unicode(uni_char); + } + for (k=0; k<2; k++) + { + offset_idx = index + k*2 + 28; + uni_char[0] = ptr[offset_idx+1]; + uni_char[1] = ptr[offset_idx]; + entry->name[l++] = from_unicode(uni_char); + } +#else + /* names are stored in unicode, but we + only grab the low byte (iso8859-1). */ for (k=0; k<5; k++) entry->name[l++] = ptr[index + k*2 + 1]; for (k=0; k<6; k++) entry->name[l++] = ptr[index + k*2 + 14]; for (k=0; k<2; k++) entry->name[l++] = ptr[index + k*2 + 28]; +#endif } entry->name[l]=0; } -- cgit v1.2.3