diff options
author | Björn Stenberg <bjorn@haxx.se> | 2002-08-11 09:17:47 +0000 |
---|---|---|
committer | Björn Stenberg <bjorn@haxx.se> | 2002-08-11 09:17:47 +0000 |
commit | cd225736f95555c7083b642675d013bff8057d76 (patch) | |
tree | b3e1bde3e0a22f11911401ea232e553341aee40c /firmware/drivers/fat.c | |
parent | 13fdf7e5a5df4cd2f34615c15fddd56f92e84d91 (diff) | |
download | rockbox-cd225736f95555c7083b642675d013bff8057d76.tar.gz rockbox-cd225736f95555c7083b642675d013bff8057d76.zip |
First version of loadable fonts patch by Alex Gitelman
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1666 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/drivers/fat.c')
-rw-r--r-- | firmware/drivers/fat.c | 38 |
1 files changed, 32 insertions, 6 deletions
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 @@ | |||
27 | #include <sys/timeb.h> | 27 | #include <sys/timeb.h> |
28 | #endif | 28 | #endif |
29 | #include <stdbool.h> | 29 | #include <stdbool.h> |
30 | #include <unicode.h> | ||
30 | #include "fat.h" | 31 | #include "fat.h" |
31 | #include "ata.h" | 32 | #include "ata.h" |
32 | #include "debug.h" | 33 | #include "debug.h" |
@@ -1029,12 +1030,14 @@ int fat_getnext(struct fat_dir *dir, struct fat_direntry *entry) | |||
1029 | /* replace shortname with longname? */ | 1030 | /* replace shortname with longname? */ |
1030 | if ( longs ) { | 1031 | if ( longs ) { |
1031 | int j,k,l=0; | 1032 | int j,k,l=0; |
1032 | |||
1033 | /* iterate backwards through the dir entries */ | 1033 | /* iterate backwards through the dir entries */ |
1034 | for (j=longs-1; j>=0; j--) { | 1034 | for (j=longs-1; j>=0; j--) { |
1035 | unsigned char* ptr = dir->cached_buf; | 1035 | unsigned char* ptr = dir->cached_buf; |
1036 | int index = longarray[j]; | 1036 | int index = longarray[j]; |
1037 | 1037 | #ifdef LOADABLE_FONTS | |
1038 | int offset_idx = 0; | ||
1039 | unsigned char uni_char[2]; | ||
1040 | #endif | ||
1038 | /* current or cached sector? */ | 1041 | /* current or cached sector? */ |
1039 | if ( sectoridx >= SECTOR_SIZE ) { | 1042 | if ( sectoridx >= SECTOR_SIZE ) { |
1040 | if ( sectoridx >= SECTOR_SIZE*2 ) { | 1043 | if ( sectoridx >= SECTOR_SIZE*2 ) { |
@@ -1052,16 +1055,39 @@ int fat_getnext(struct fat_dir *dir, struct fat_direntry *entry) | |||
1052 | index &= SECTOR_SIZE-1; | 1055 | index &= SECTOR_SIZE-1; |
1053 | } | 1056 | } |
1054 | 1057 | ||
1055 | /* piece together the name subcomponents. | 1058 | /* piece together the name subcomponents. */ |
1056 | names are stored in unicode, but we | 1059 | #ifdef LOADABLE_FONTS |
1057 | only grab the low byte (iso8859-1). | 1060 | for (k=0; k<5; k++) |
1058 | */ | 1061 | { |
1062 | offset_idx = index + k*2 + 1; | ||
1063 | uni_char[0] = ptr[offset_idx+1]; | ||
1064 | uni_char[1] = ptr[offset_idx]; | ||
1065 | entry->name[l++] = from_unicode(uni_char); | ||
1066 | } | ||
1067 | for (k=0; k<6; k++) | ||
1068 | { | ||
1069 | offset_idx = index + k*2 + 14; | ||
1070 | uni_char[0] = ptr[offset_idx+1]; | ||
1071 | uni_char[1] = ptr[offset_idx]; | ||
1072 | entry->name[l++] = from_unicode(uni_char); | ||
1073 | } | ||
1074 | for (k=0; k<2; k++) | ||
1075 | { | ||
1076 | offset_idx = index + k*2 + 28; | ||
1077 | uni_char[0] = ptr[offset_idx+1]; | ||
1078 | uni_char[1] = ptr[offset_idx]; | ||
1079 | entry->name[l++] = from_unicode(uni_char); | ||
1080 | } | ||
1081 | #else | ||
1082 | /* names are stored in unicode, but we | ||
1083 | only grab the low byte (iso8859-1). */ | ||
1059 | for (k=0; k<5; k++) | 1084 | for (k=0; k<5; k++) |
1060 | entry->name[l++] = ptr[index + k*2 + 1]; | 1085 | entry->name[l++] = ptr[index + k*2 + 1]; |
1061 | for (k=0; k<6; k++) | 1086 | for (k=0; k<6; k++) |
1062 | entry->name[l++] = ptr[index + k*2 + 14]; | 1087 | entry->name[l++] = ptr[index + k*2 + 14]; |
1063 | for (k=0; k<2; k++) | 1088 | for (k=0; k<2; k++) |
1064 | entry->name[l++] = ptr[index + k*2 + 28]; | 1089 | entry->name[l++] = ptr[index + k*2 + 28]; |
1090 | #endif | ||
1065 | } | 1091 | } |
1066 | entry->name[l]=0; | 1092 | entry->name[l]=0; |
1067 | } | 1093 | } |