Changeset 1310
- Timestamp:
- 09/02/11 23:43:36 (21 months ago)
- Location:
- trunk
- Files:
-
- 4 edited
-
core/gui_fselect.c (modified) (2 diffs)
-
core/gui_menu.c (modified) (2 diffs)
-
include/font.h (modified) (1 diff)
-
lib/font/rbf_font.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/core/gui_fselect.c
r1302 r1310 1052 1052 gui_fselect_free_data(); 1053 1053 gui_fselect_marked_free_data(); 1054 if (fselect_on_select) 1055 fselect_on_select(selected_file); 1054 1056 gui_set_mode(gui_fselect_mode_old); 1055 1057 draw_restore(); 1056 if (fselect_on_select)1057 fselect_on_select(selected_file);1058 1058 } 1059 1059 } … … 1078 1078 gui_fselect_free_data(); 1079 1079 gui_fselect_marked_free_data(); 1080 if (fselect_on_select) 1081 fselect_on_select(NULL); 1080 1082 gui_set_mode(gui_fselect_mode_old); 1081 1083 draw_restore(); 1082 if (fselect_on_select) 1083 fselect_on_select(NULL); 1084 break; 1085 } 1086 } 1087 1088 //------------------------------------------------------------------- 1084 break; 1085 } 1086 } 1087 1088 //------------------------------------------------------------------- -
trunk/core/gui_menu.c
r1299 r1310 32 32 33 33 static int count; 34 static coord x, y, w, num_lines; 34 static int x, y; 35 static int w, num_lines; 35 36 static int len_bool, len_int, len_enum, len_space, len_br1, len_br2, cl_rect; 36 37 static int int_incr, incr_modified; … … 701 702 if (lang_str(curr_menu->menu[imenu].text)[0]) 702 703 sprintf(tbuf," %s ",lang_str(curr_menu->menu[imenu].text)); 703 704 j = rbf_str_width(lang_str(curr_menu->menu[imenu].text)); 705 xx += ((int)w - j - len_space*2) >> 1; 706 707 draw_filled_rect(x+len_space, yy, xx-1, yy+rbf_font_height()/2-1, MAKE_COLOR(cl>>8, cl>>8)); 708 draw_line(x+len_space, yy+rbf_font_height()/2, xx-1, yy+rbf_font_height()/2, cl); 709 draw_filled_rect(x+len_space, yy+rbf_font_height()/2+1, xx-1, yy+rbf_font_height()-1, MAKE_COLOR(cl>>8, cl>>8)); 710 711 if (j) xx += rbf_draw_string(xx, yy, tbuf, cl); 712 713 draw_filled_rect(xx, yy, x+w-len_space-1, yy+rbf_font_height()/2-1, MAKE_COLOR(cl>>8, cl>>8)); 714 draw_line(xx, yy+rbf_font_height()/2, x+w-1-len_space, yy+rbf_font_height()/2, cl); 715 draw_filled_rect(xx, yy+rbf_font_height()/2+1, x+w-len_space-1, yy+rbf_font_height()-1, MAKE_COLOR(cl>>8, cl>>8)); 704 else 705 tbuf[0] = 0; 706 707 j = rbf_str_width(tbuf); 708 xx += ((w - j) >> 1); 709 710 if (xx > (x + len_space)) 711 { 712 draw_filled_rect(x+len_space, yy, xx-1, yy+rbf_font_height()/2-1, MAKE_COLOR(cl>>8, cl>>8)); 713 draw_line(x+len_space, yy+rbf_font_height()/2, xx-1, yy+rbf_font_height()/2, cl); 714 draw_filled_rect(x+len_space, yy+rbf_font_height()/2+1, xx-1, yy+rbf_font_height()-1, MAKE_COLOR(cl>>8, cl>>8)); 715 } 716 else 717 { 718 xx = x; 719 } 720 721 if (j) xx += rbf_draw_clipped_string(xx, yy, tbuf, cl, 0, w); 722 723 if (xx < (x+w-len_space)) 724 { 725 draw_filled_rect(xx, yy, x+w-len_space-1, yy+rbf_font_height()/2-1, MAKE_COLOR(cl>>8, cl>>8)); 726 draw_line(xx, yy+rbf_font_height()/2, x+w-1-len_space, yy+rbf_font_height()/2, cl); 727 draw_filled_rect(xx, yy+rbf_font_height()/2+1, x+w-len_space-1, yy+rbf_font_height()-1, MAKE_COLOR(cl>>8, cl>>8)); 728 } 716 729 717 730 rbf_draw_char(x+w-len_space, yy, ' ', cl); -
trunk/include/font.h
r875 r1310 36 36 extern int rbf_draw_string(int x, int y, const char *str, color cl); 37 37 extern int rbf_draw_string_c(int x, int y, const char *str, color cl1, int c, color cl2); 38 extern int rbf_draw_clipped_string(int x, int y, const char *str, color cl, int l, int maxlen); 38 39 extern int rbf_draw_string_len(int x, int y, int len, const char *str, color cl); 39 40 extern int rbf_draw_string_right_len(int x, int y, int len, const char *str, color cl); -
trunk/lib/font/rbf_font.c
r1186 r1310 6 6 7 7 //------------------------------------------------------------------- 8 #define RBF_MAX_NAME 649 8 #define RBF_MAX_NAME 64 9 #define UBUFFER_SIZE 256 // Amount of uncached memory to allocate for file reading 10 10 //------------------------------------------------------------------- 11 11 static unsigned int RBF_HDR_MAGIC1 = 0x0DF00EE0; … … 50 50 // Current size of the cTable data 51 51 int cTableSize; 52 struct _font *uncached_font; // address of font in uncached memory (for passing to ufree & read) 53 char *uncached_cTable; // address of cTable in uncached memory (for passing to ufree & read) 52 int cTableSizeMax; // max size of cTable (max size currently allocated) 54 53 } font; 55 54 55 static unsigned char *ubuffer = 0; // uncached memory buffer for reading font data from SD card 56 56 static font *rbf_symbol_font = 0, *rbf_font = 0; 57 57 static int rbf_codepage = FONT_CP_WIN; … … 60 60 61 61 font *new_font() { 62 // allocate font from uncached memory63 font *f = umalloc(sizeof(font));62 // allocate font from cached memory 63 font *f = malloc(sizeof(font)); 64 64 if (f) { 65 memset(f,0,sizeof(font)); // wipe memory (use uncached address to avoid conflict with read & caching) 66 f->uncached_font = f; // save uncached memory address 67 // return address in cached memory for faster font rendering 68 return (font*)((int)f & ~CAM_UNCACHED_BIT); 65 memset(f,0,sizeof(font)); // wipe memory 66 // return address in cached memory 67 return f; 69 68 } 70 69 … … 78 77 if (rbf_font == 0) rbf_font = new_font(); 79 78 if (rbf_symbol_font == 0) rbf_symbol_font = new_font(); 79 80 // allocate uncached memory buffer for reading 81 ubuffer = umalloc(UBUFFER_SIZE); 80 82 } 81 83 … … 94 96 // See if it the existing cTable data is large enough to hold the new font data 95 97 // If not free it so new memory will be allocated 96 if ((f->cTable != 0) && (f->cTableSize < (f->charCount*f->hdr.charSize))) {97 ufree(f->uncached_cTable); // free the memory using the uncached address98 if ((f->cTable != 0) && (f->cTableSizeMax < (f->charCount*f->hdr.charSize))) { 99 free(f->cTable); // free the memory 98 100 f->cTable = 0; // clear pointer so new memory is allocated 99 f-> uncached_cTable= 0;101 f->cTableSizeMax = 0; 100 102 } 101 103 102 104 // Allocated memory if needed 103 105 if (f->cTable == 0 && !f->usingFont8x16) { 104 // Allocate memory from uncached pool 105 f->uncached_cTable = umalloc(f->charCount*f->hdr.charSize); 106 // Store cached memory address 107 f->cTable = (char*)((int)f->uncached_cTable & ~CAM_UNCACHED_BIT); 106 // Allocate memory from cached pool 107 f->cTable = malloc(f->charCount*f->hdr.charSize); 108 108 109 109 // save size 110 110 f->cTableSize = f->charCount*f->hdr.charSize; 111 if (f->cTableSizeMax == 0) f->cTableSizeMax = f->cTableSize; // Save actual size allocated 111 112 } 112 113 } … … 146 147 } 147 148 //------------------------------------------------------------------- 149 // Read data from SD file using uncached buffer and copy to cached 150 // font memory 151 int font_read(int fd, unsigned char *dest, int len) 152 { 153 // Return actual bytes read 154 int bytes_read = 0; 155 156 if (ubuffer) 157 { 158 // Read file in UBUFFER_SIZE blocks 159 while (len) 160 { 161 // Calc size of next block to read = min(UBUFFER_SIZE, len) 162 int to_read = UBUFFER_SIZE; 163 if (to_read > len) to_read = len; 164 165 // Read block and copy to dest 166 bytes_read += read(fd, ubuffer, to_read); 167 memcpy(dest, ubuffer, to_read); 168 169 // Increment dest pointer, decrement len left to read 170 dest += to_read; 171 len -= to_read; 172 } 173 } 174 175 return bytes_read; 176 } 177 //------------------------------------------------------------------- 148 178 // Load from from file. If maxchar != 0 limit charLast (for symbols) 149 // Note: pass the uncached font address to this function150 179 int rbf_font_load(char *file, font* f, int maxchar) 151 180 { … … 162 191 if (fd >= 0) { 163 192 // read header 164 i = read(fd,&f->hdr, sizeof(font_hdr));193 i = font_read(fd, (unsigned char*)&f->hdr, sizeof(font_hdr)); 165 194 166 195 // check size read is correct and magic numbers are valid … … 173 202 alloc_cTable(f); 174 203 175 // read width table (using uncached memory address)204 // read width table (using uncached buffer) 176 205 lseek(fd, f->hdr._wmapAddr, SEEK_SET); 177 read(fd,&f->wTable[f->hdr.charFirst], f->charCount);178 179 // read cTable data (using uncached memory address)206 font_read(fd, (unsigned char*)&f->wTable[f->hdr.charFirst], f->charCount); 207 208 // read cTable data (using uncached buffer) 180 209 lseek(fd, f->hdr._cmapAddr, SEEK_SET); 181 read(fd, f->uncached_cTable, f->charCount*f->hdr.charSize);210 font_read(fd, (unsigned char*)f->cTable, f->charCount*f->hdr.charSize); 182 211 183 212 close(fd); … … 198 227 init_fonts(); 199 228 // Load font 200 return rbf_font_load(file, rbf_font ->uncached_font, 0);229 return rbf_font_load(file, rbf_font, 0); 201 230 } 202 231 … … 207 236 init_fonts(); 208 237 // Load font 209 return rbf_font_load(file, rbf_symbol_font ->uncached_font, maxSymbols+32);238 return rbf_font_load(file, rbf_symbol_font, maxSymbols+32); 210 239 } 211 240
Note: See TracChangeset
for help on using the changeset viewer.