summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBarry Wardell <rockbox@barrywardell.net>2007-01-17 12:20:38 +0000
committerBarry Wardell <rockbox@barrywardell.net>2007-01-17 12:20:38 +0000
commitf4709d0c7c160fa594ca9289c9a28352f1d44126 (patch)
tree717b3d2d4959268f56c87692fd5021f3e9be3e73
parentb0d1bb891ec91994f7cd453e09dd38a5539e16d6 (diff)
downloadrockbox-f4709d0c7c160fa594ca9289c9a28352f1d44126.tar.gz
rockbox-f4709d0c7c160fa594ca9289c9a28352f1d44126.zip
Make the build system create a sysfont.h which includes font information for the system font. Available #defines are: SYSFONT_NAME, SYSFONT_FACENAME, SYSFONT_WIDTH, SYSFONT_HEIGHT, SYSFONT_SIZE, SYSFONT_ASCENT, SYSFONT_DESCENT, SYSFONT_FIRST_CHAR, SYSFONT_LAST_CHAR, SYSFONT_DEFAULT_CHAR, SYSFONT_PROPORTIONAL, SYSFONT_COPYRIGHT, SYSFONT_BITS_SIZE.
Also fix a small bug in the iPod bootloader printf() code and use printf() for PortalPlayer bootloaders too. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12041 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--bootloader/ipod.c2
-rw-r--r--bootloader/main-pp.c78
-rw-r--r--firmware/Makefile3
-rw-r--r--firmware/export/font.h1
-rw-r--r--tools/convbdf.c70
5 files changed, 114 insertions, 40 deletions
diff --git a/bootloader/ipod.c b/bootloader/ipod.c
index 5f7060a526..8b99fbd1ad 100644
--- a/bootloader/ipod.c
+++ b/bootloader/ipod.c
@@ -178,7 +178,7 @@ void printf(const char *format, ...)
178 178
179 lcd_puts(0, line++, ptr); 179 lcd_puts(0, line++, ptr);
180 lcd_update(); 180 lcd_update();
181 if(line >= 30) 181 if(line >= (LCD_HEIGHT/SYSFONT_HEIGHT))
182 line = 0; 182 line = 0;
183} 183}
184 184
diff --git a/bootloader/main-pp.c b/bootloader/main-pp.c
index a533cc7044..ee2af38731 100644
--- a/bootloader/main-pp.c
+++ b/bootloader/main-pp.c
@@ -24,6 +24,7 @@
24#include <stdlib.h> 24#include <stdlib.h>
25#include <stdio.h> 25#include <stdio.h>
26#include <string.h> 26#include <string.h>
27#include <stdarg.h>
27#include "cpu.h" 28#include "cpu.h"
28#include "system.h" 29#include "system.h"
29#include "lcd.h" 30#include "lcd.h"
@@ -51,6 +52,31 @@ char version[] = APPSVERSION;
51#define DRAM_START 0x10000000 52#define DRAM_START 0x10000000
52 53
53int line=0; 54int line=0;
55char printfbuf[256];
56
57void reset_screen(void)
58{
59 lcd_clear_display();
60 line = 0;
61}
62
63void printf(const char *format, ...)
64{
65 int len;
66 unsigned char *ptr;
67 va_list ap;
68 va_start(ap, format);
69
70
71 ptr = printfbuf;
72 len = vsnprintf(ptr, sizeof(printfbuf), format, ap);
73 va_end(ap);
74
75 lcd_puts(0, line++, ptr);
76 lcd_update();
77 if(line >= (LCD_HEIGHT/SYSFONT_HEIGHT))
78 line = 0;
79}
54 80
55/* Load original mi4 firmware. This function expects a file called 81/* Load original mi4 firmware. This function expects a file called
56 "/System/OF.bin" on the player. It should be a mi4 firmware decrypted 82 "/System/OF.bin" on the player. It should be a mi4 firmware decrypted
@@ -100,9 +126,7 @@ int load_rockbox(unsigned char* buf)
100 126
101 len = filesize(fd) - 8; 127 len = filesize(fd) - 8;
102 128
103 snprintf(str, sizeof(str), "Length: %x", len); 129 printf("Length: %x", len);
104 lcd_puts(0, line++ ,str);
105 lcd_update();
106 130
107 if (len > MAX_LOADSIZE) 131 if (len > MAX_LOADSIZE)
108 return -6; 132 return -6;
@@ -114,9 +138,7 @@ int load_rockbox(unsigned char* buf)
114 if(rc < 4) 138 if(rc < 4)
115 return -2; 139 return -2;
116 140
117 snprintf(str, sizeof(str), "Checksum: %x", chksum); 141 printf("Checksum: %x", chksum);
118 lcd_puts(0, line++ ,str);
119 lcd_update();
120 142
121 rc = read(fd, model, 4); 143 rc = read(fd, model, 4);
122 if(rc < 4) 144 if(rc < 4)
@@ -124,9 +146,7 @@ int load_rockbox(unsigned char* buf)
124 146
125 model[4] = 0; 147 model[4] = 0;
126 148
127 snprintf(str, sizeof(str), "Model name: %s", model); 149 printf("Model name: %s", model);
128 lcd_puts(0, line++ ,str);
129 lcd_update();
130 150
131 lseek(fd, FIRMWARE_OFFSET_FILE_DATA, SEEK_SET); 151 lseek(fd, FIRMWARE_OFFSET_FILE_DATA, SEEK_SET);
132 152
@@ -142,10 +162,8 @@ int load_rockbox(unsigned char* buf)
142 sum += buf[i]; 162 sum += buf[i];
143 } 163 }
144 164
145 snprintf(str, sizeof(str), "Sum: %x", sum); 165 printf("Sum: %x", sum);
146 lcd_puts(0, line++ ,str); 166
147 lcd_update();
148
149 if(sum != chksum) 167 if(sum != chksum)
150 return -5; 168 return -5;
151 169
@@ -170,12 +188,9 @@ void* main(void)
170 188
171 lcd_setfont(FONT_SYSFIXED); 189 lcd_setfont(FONT_SYSFIXED);
172 190
173 lcd_puts(0, line++, "Rockbox boot loader"); 191 printf("Rockbox boot loader");
174 snprintf(buf, sizeof(buf), "Version: 20%s", version); 192 printf("Version: 20%s", version);
175 lcd_puts(0, line++, buf); 193 printf(MODEL_NAME);
176 snprintf(buf, sizeof(buf), MODEL_NAME);
177 lcd_puts(0, line++, buf);
178 lcd_update();
179 194
180 i=ata_init(); 195 i=ata_init();
181 if (i==0) { 196 if (i==0) {
@@ -188,44 +203,33 @@ void* main(void)
188 for (i=39; i && buf[i]==' '; i--) { 203 for (i=39; i && buf[i]==' '; i--) {
189 buf[i]=0; 204 buf[i]=0;
190 } 205 }
191 lcd_puts(0, line++, buf); 206 printf(buf);
192 lcd_update();
193 } else { 207 } else {
194 snprintf(buf, sizeof(buf), "ATA: %d", i); 208 printf("ATA: %d", i);
195 lcd_puts(0, line++, buf);
196 lcd_update();
197 } 209 }
198 210
199 disk_init(); 211 disk_init();
200 rc = disk_mount_all(); 212 rc = disk_mount_all();
201 if (rc<=0) 213 if (rc<=0)
202 { 214 {
203 lcd_puts(0, line++, "No partition found"); 215 printf("No partition found");
204 lcd_update();
205 } 216 }
206 217
207 pinfo = disk_partinfo(0); 218 pinfo = disk_partinfo(0);
208 snprintf(buf, sizeof(buf), "Partition 0: 0x%02x %ld MB", 219 printf("Partition 0: 0x%02x %ld MB", pinfo->type, pinfo->size / 2048);
209 pinfo->type, pinfo->size / 2048);
210 lcd_puts(0, line++, buf);
211 lcd_update();
212 220
213 i=button_read_device(); 221 i=button_read_device();
214 if(i==BUTTON_LEFT) 222 if(i==BUTTON_LEFT)
215 { 223 {
216 lcd_puts(0, line++, "Loading original firmware..."); 224 printf("Loading original firmware...");
217 lcd_update();
218 rc=load_original_firmware(loadbuffer); 225 rc=load_original_firmware(loadbuffer);
219 } else { 226 } else {
220 lcd_puts(0, line++, "Loading Rockbox..."); 227 printf("Loading Rockbox...");
221 lcd_update();
222 rc=load_rockbox(loadbuffer); 228 rc=load_rockbox(loadbuffer);
223 } 229 }
224 230
225 if (rc < 0) { 231 if (rc < 0) {
226 snprintf(buf, sizeof(buf), "Rockbox error: %d",rc); 232 printf("Rockbox error: %d",rc);
227 lcd_puts(0, line++, buf);
228 lcd_update();
229 while(1) {} 233 while(1) {}
230 } 234 }
231 235
diff --git a/firmware/Makefile b/firmware/Makefile
index dea4c81b33..55c8269b24 100644
--- a/firmware/Makefile
+++ b/firmware/Makefile
@@ -40,6 +40,9 @@ clean:
40$(OBJDIR)/thread.o: thread.c export/thread.h 40$(OBJDIR)/thread.o: thread.c export/thread.h
41 $(call PRINTS,CC thread.c)$(CC) -c -O -fomit-frame-pointer $(CFLAGS) $< -o $@ 41 $(call PRINTS,CC thread.c)$(CC) -c -O -fomit-frame-pointer $(CFLAGS) $< -o $@
42 42
43sysfont.h: ../fonts/rockbox_default.bdf
44 $(call PRINTS,Create sysfont.h)$(TOOLSDIR)/convbdf -h -o $(BUILDDIR)/sysfont.h $<
45
43$(OBJDIR)/sysfont.o: ../fonts/rockbox_default.bdf 46$(OBJDIR)/sysfont.o: ../fonts/rockbox_default.bdf
44 $(call PRINTS,CONVBDF)$(TOOLSDIR)/convbdf -c -o $(OBJDIR)/sysfont.c $< 47 $(call PRINTS,CONVBDF)$(TOOLSDIR)/convbdf -c -o $(OBJDIR)/sysfont.c $<
45 $(call PRINTS,CC sysfont.c)$(CC) $(CFLAGS) -c $(OBJDIR)/sysfont.c -o $@ 48 $(call PRINTS,CC sysfont.c)$(CC) $(CFLAGS) -c $(OBJDIR)/sysfont.c -o $@
diff --git a/firmware/export/font.h b/firmware/export/font.h
index ccdb30ff00..3cf60aeac3 100644
--- a/firmware/export/font.h
+++ b/firmware/export/font.h
@@ -23,6 +23,7 @@
23 * Incore font and image definitions 23 * Incore font and image definitions
24 */ 24 */
25#include "config.h" 25#include "config.h"
26#include "sysfont.h"
26 27
27#if defined(HAVE_LCD_BITMAP) || defined(SIMULATOR) 28#if defined(HAVE_LCD_BITMAP) || defined(SIMULATOR)
28 29
diff --git a/tools/convbdf.c b/tools/convbdf.c
index 6dcd2d8394..c75b5fb444 100644
--- a/tools/convbdf.c
+++ b/tools/convbdf.c
@@ -64,6 +64,7 @@ struct font {
64#define EXTRA 300 /* # bytes extra allocation for buggy .bdf files*/ 64#define EXTRA 300 /* # bytes extra allocation for buggy .bdf files*/
65 65
66int gen_c = 0; 66int gen_c = 0;
67int gen_h = 0;
67int gen_fnt = 0; 68int gen_fnt = 0;
68int gen_map = 1; 69int gen_map = 1;
69int start_char = 0; 70int start_char = 0;
@@ -83,6 +84,7 @@ char * bdf_getline(FILE *fp, char *buf, int len);
83bitmap_t bdf_hexval(unsigned char *buf, int ndx1, int ndx2); 84bitmap_t bdf_hexval(unsigned char *buf, int ndx1, int ndx2);
84 85
85int gen_c_source(struct font* pf, char *path); 86int gen_c_source(struct font* pf, char *path);
87int gen_h_header(struct font* pf, char *path);
86int gen_fnt_file(struct font* pf, char *path); 88int gen_fnt_file(struct font* pf, char *path);
87 89
88void 90void
@@ -93,6 +95,7 @@ usage(void)
93 " convbdf [options] [-o output-file] [single-input-file]\n" 95 " convbdf [options] [-o output-file] [single-input-file]\n"
94 "Options:\n" 96 "Options:\n"
95 " -c Convert .bdf to .c source file\n" 97 " -c Convert .bdf to .c source file\n"
98 " -h Convert .bdf to .h header file (to create sysfont.h)\n"
96 " -f Convert .bdf to .fnt font file\n" 99 " -f Convert .bdf to .fnt font file\n"
97 " -s N Start output at character encodings >= N\n" 100 " -s N Start output at character encodings >= N\n"
98 " -l N Limit output to character encodings <= N\n" 101 " -l N Limit output to character encodings <= N\n"
@@ -124,6 +127,9 @@ void getopts(int *pac, char ***pav)
124 case 'c': /* generate .c output*/ 127 case 'c': /* generate .c output*/
125 gen_c = 1; 128 gen_c = 1;
126 break; 129 break;
130 case 'h': /* generate .h output*/
131 gen_h = 1;
132 break;
127 case 'f': /* generate .fnt output*/ 133 case 'f': /* generate .fnt output*/
128 gen_fnt = 1; 134 gen_fnt = 1;
129 break; 135 break;
@@ -214,6 +220,14 @@ int convbdf(char *path)
214 } 220 }
215 ret |= gen_c_source(pf, outfile); 221 ret |= gen_c_source(pf, outfile);
216 } 222 }
223
224 if (gen_h) {
225 if (!oflag) {
226 strcpy(outfile, basename(path));
227 strcat(outfile, ".h");
228 }
229 ret |= gen_h_header(pf, outfile);
230 }
217 231
218 if (gen_fnt) { 232 if (gen_fnt) {
219 if (!oflag) { 233 if (!oflag) {
@@ -234,12 +248,12 @@ int main(int ac, char **av)
234 ++av; --ac; /* skip av[0]*/ 248 ++av; --ac; /* skip av[0]*/
235 getopts(&ac, &av); /* read command line options*/ 249 getopts(&ac, &av); /* read command line options*/
236 250
237 if (ac < 1 || (!gen_c && !gen_fnt)) { 251 if (ac < 1 || (!gen_c && !gen_h && !gen_fnt)) {
238 usage(); 252 usage();
239 exit(1); 253 exit(1);
240 } 254 }
241 if (oflag) { 255 if (oflag) {
242 if (ac > 1 || (gen_c && gen_fnt)) { 256 if (ac > 1 || (gen_c && gen_fnt) || (gen_c && gen_h) || (gen_h && gen_fnt)) {
243 usage(); 257 usage();
244 exit(1); 258 exit(1);
245 } 259 }
@@ -965,6 +979,58 @@ int gen_c_source(struct font* pf, char *path)
965 return 0; 979 return 0;
966} 980}
967 981
982/* generate C header from in-core font*/
983int gen_h_header(struct font* pf, char *path)
984{
985 FILE *ofp;
986 time_t t = time(0);
987 char buf[256];
988 char hdr1[] = {
989 "/* Generated by convbdf on %s. */\n"
990 "#ifdef HAVE_LCD_BITMAP\n"
991 "\n"
992 "/* Font information*/\n"
993 "#define SYSFONT_NAME %s\n"
994 "#define SYSFONT_FACENAME %s\n"
995 "#define SYSFONT_WIDTH %d\n"
996 "#define SYSFONT_HEIGHT %d\n"
997 "#define SYSFONT_SIZE %d\n"
998 "#define SYSFONT_ASCENT %d\n"
999 "#define SYSFONT_DESCENT %d\n"
1000 "#define SYSFONT_FIRST_CHAR %d\n"
1001 "#define SYSFONT_LAST_CHAR %d\n"
1002 "#define SYSFONT_DEFAULT_CHAR %d\n"
1003 "#define SYSFONT_PROPORTIONAL %s\n"
1004 "#define SYSFONT_COPYRIGHT %s\n"
1005 "#define SYSFONT_BITS_SIZE %d\n"
1006 "\n"
1007 "#endif\n"
1008 };
1009
1010 ofp = fopen(path, "w");
1011 if (!ofp) {
1012 fprintf(stderr, "Can't create %s\n", path);
1013 return 1;
1014 }
1015
1016 strcpy(buf, ctime(&t));
1017 buf[strlen(buf)-1] = 0;
1018
1019 fprintf(ofp, hdr1, buf,
1020 pf->name,
1021 pf->facename? pf->facename: "",
1022 pf->maxwidth, pf->height,
1023 pf->size,
1024 pf->ascent, pf->descent,
1025 pf->firstchar,
1026 pf->firstchar+pf->size-1,
1027 pf->defaultchar,
1028 pf->width? 1: 0,
1029 pf->copyright? pf->copyright: "");
1030
1031 return 0;
1032}
1033
968static int writebyte(FILE *fp, unsigned char c) 1034static int writebyte(FILE *fp, unsigned char c)
969{ 1035{
970 return putc(c, fp) != EOF; 1036 return putc(c, fp) != EOF;